Kaydet (Commit) edc3ec2b authored tarafından Samuel Mehrbrodt's avatar Samuel Mehrbrodt

tdf#83877 Edit existing signature lines

Change-Id: I7a6861f599cb8794bcb8c246179cf6c7ff9966f3
Reviewed-on: https://gerrit.libreoffice.org/46289Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
üst 0c13d0fb
......@@ -845,9 +845,17 @@
<value>1</value>
</prop>
</node>
<node oor:name=".uno:SignatureLineDialog" oor:op="replace">
<node oor:name=".uno:InsertSignatureLine" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Signature ~Line</value>
<value xml:lang="en-US">Signatu~re Line</value>
</prop>
<prop oor:name="Properties" oor:type="xs:int">
<value>1</value>
</prop>
</node>
<node oor:name=".uno:EditSignatureLine" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Edit Signature ~Line...</value>
</prop>
<prop oor:name="Properties" oor:type="xs:int">
<value>1</value>
......
......@@ -142,6 +142,7 @@
#define FN_REDLINE_PREV_CHANGE (FN_EDIT2 + 42) /* Go to the previous change */
#define FN_REDLINE_ACCEPT_ALL (FN_EDIT2 + 43) /* Redlining Accept All*/
#define FN_REDLINE_REJECT_ALL (FN_EDIT2 + 44) /* Redlining Reject All*/
#define FN_EDIT_SIGNATURELINE (FN_EDIT2 + 45) /* Edit signature line */
// Region: Edit
#define FN_REFRESH_VIEW (FN_VIEW + 1) /* Refresh/Redraw */
......
......@@ -531,6 +531,7 @@ public:
bool HasOnlyObj(SdrObject const *pSdrObj, SdrInventor eObjInventor) const;
bool BeginTextEdit( SdrObject* pObj, SdrPageView* pPV=nullptr,
vcl::Window* pWin=nullptr, bool bIsNewObj=false, bool bSetSelectionToStart=false );
bool isSignatureLineSelected();
void StateTabWin(SfxItemSet&);
......
......@@ -3314,7 +3314,7 @@ SfxVoidItem InsertTopicField FN_INSERT_FLD_TOPIC
GroupId = SfxGroupId::Insert;
]
SfxVoidItem SignatureLineDialog FN_INSERT_SIGNATURELINE
SfxVoidItem InsertSignatureLine FN_INSERT_SIGNATURELINE
()
[
AutoUpdate = FALSE,
......@@ -3331,6 +3331,23 @@ SfxVoidItem SignatureLineDialog FN_INSERT_SIGNATURELINE
GroupId = SfxGroupId::Insert;
]
SfxVoidItem EditSignatureLine FN_EDIT_SIGNATURELINE
()
[
AutoUpdate = FALSE,
FastCall = FALSE,
ReadOnlyDoc = FALSE,
Toggle = FALSE,
Container = FALSE,
RecordAbsolute = FALSE,
RecordPerSet;
AccelConfig = TRUE,
MenuConfig = TRUE,
ToolBoxConfig = TRUE,
GroupId = SfxGroupId::Edit;
]
SfxVoidItem JumpDownThisLevel FN_NUM_BULLET_NEXT
()
[
......
......@@ -42,6 +42,12 @@ interface TextEditView : BaseTextEditView
StateMethod = GetState ;
DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
]
FN_EDIT_SIGNATURELINE // status()
[
ExecMethod = ExecDlgExt ;
StateMethod = GetState ;
DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
]
FN_EDIT_FOOTNOTE // status(final|play)
[
ExecMethod = ExecDlgExt ;
......
......@@ -15,6 +15,7 @@
#include <unotools/streamwrap.hxx>
#include <view.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/drawing/XShape.hpp>
#include <com/sun/star/graphic/GraphicProvider.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
......@@ -32,6 +33,7 @@ using namespace css::io;
using namespace css::lang;
using namespace css::frame;
using namespace css::text;
using namespace css::view;
using namespace css::drawing;
using namespace css::graphic;
......@@ -45,6 +47,38 @@ SignatureLineDialog::SignatureLineDialog(vcl::Window* pParent, SwView& rView)
get(m_pEditInstructions, "edit_instructions");
get(m_pCheckboxCanAddComments, "checkbox_can_add_comments");
get(m_pCheckboxShowSignDate, "checkbox_show_sign_date");
// No signature line selected - start with empty dialog and generate a new one
if (!rView.isSignatureLineSelected())
return;
Reference<XModel> const xModel(rView.GetCurrentDocument());
Reference<container::XIndexAccess> xIndexAccess(xModel->getCurrentSelection(), UNO_QUERY_THROW);
Reference<XPropertySet> xProps(xIndexAccess->getByIndex(0), UNO_QUERY_THROW);
// Read properties from selected signature line
xProps->getPropertyValue("SignatureLineId") >>= m_aSignatureLineId;
OUString aSuggestedSignerName;
xProps->getPropertyValue("SignatureLineSuggestedSignerName") >>= aSuggestedSignerName;
m_pEditName->SetText(aSuggestedSignerName);
OUString aSuggestedSignerTitle;
xProps->getPropertyValue("SignatureLineSuggestedSignerTitle") >>= aSuggestedSignerTitle;
m_pEditTitle->SetText(aSuggestedSignerTitle);
OUString aSuggestedSignerEmail;
xProps->getPropertyValue("SignatureLineSuggestedSignerEmail") >>= aSuggestedSignerEmail;
m_pEditEmail->SetText(aSuggestedSignerEmail);
OUString aSigningInstructions;
xProps->getPropertyValue("SignatureLineSigningInstructions") >>= aSigningInstructions;
m_pEditInstructions->SetText(aSigningInstructions);
bool bCanAddComments = false;
xProps->getPropertyValue("SignatureLineShowSignDate") >>= bCanAddComments;
m_pCheckboxCanAddComments->Check(bCanAddComments);
bool bShowSignDate = false;
xProps->getPropertyValue("SignatureLineShowSignDate") >>= bShowSignDate;
m_pCheckboxShowSignDate->Check(bShowSignDate);
// Mark this as existing shape
m_xExistingShapeProperties = xProps;
}
SignatureLineDialog::~SignatureLineDialog() { disposeOnce(); }
......@@ -63,8 +97,9 @@ void SignatureLineDialog::dispose()
void SignatureLineDialog::Apply()
{
OUString aSignatureLineId
= OStringToOUString(comphelper::xml::generateGUIDString(), RTL_TEXTENCODING_UTF8);
if (m_aSignatureLineId.isEmpty())
m_aSignatureLineId
= OStringToOUString(comphelper::xml::generateGUIDString(), RTL_TEXTENCODING_ASCII_US);
OUString aSignerName(m_pEditName->GetText());
OUString aSignerTitle(m_pEditTitle->GetText());
OUString aSignerEmail(m_pEditEmail->GetText());
......@@ -83,7 +118,7 @@ void SignatureLineDialog::Apply()
aSvgImage = aSvgImage.replaceAll("[INVALID_SIGNATURE]", "");
aSvgImage = aSvgImage.replaceAll("[DATE]", "");
// Insert graphic
// Insert/Update graphic
SvMemoryStream aSvgStream(4096, 4096);
aSvgStream.WriteOString(OUStringToOString(aSvgImage, RTL_TEXTENCODING_UTF8));
Reference<XInputStream> xInputStream(new utl::OSeekableInputStreamWrapper(aSvgStream));
......@@ -96,23 +131,20 @@ void SignatureLineDialog::Apply()
Reference<XGraphic> xGraphic(xProvider->queryGraphic(aMediaProperties));
Reference<XModel> const xModel(mrView.GetCurrentDocument());
Reference<XPropertySet> const xShapeProps(
Reference<lang::XMultiServiceFactory>(xModel, UNO_QUERY)
->createInstance("com.sun.star.drawing.GraphicObjectShape"),
UNO_QUERY);
xShapeProps->setPropertyValue("Graphic", Any(xGraphic));
xShapeProps->setPropertyValue("AnchorType", Any(TextContentAnchorType_AT_PARAGRAPH));
bool bIsExistingSignatureLine = m_xExistingShapeProperties.is();
Reference<XPropertySet> xShapeProps;
if (bIsExistingSignatureLine)
xShapeProps = m_xExistingShapeProperties;
else
xShapeProps.set(Reference<lang::XMultiServiceFactory>(xModel, UNO_QUERY)
->createInstance("com.sun.star.drawing.GraphicObjectShape"),
UNO_QUERY);
// Set shape properties
Reference<XShape> xShape(xShapeProps, UNO_QUERY);
awt::Size aShapeSize;
aShapeSize.Height = 3000;
aShapeSize.Width = 6000;
xShape->setSize(aShapeSize);
xShapeProps->setPropertyValue("Graphic", Any(xGraphic));
// Set signature line properties
xShapeProps->setPropertyValue("IsSignatureLine", Any(true));
xShapeProps->setPropertyValue("SignatureLineId", Any(aSignatureLineId));
xShapeProps->setPropertyValue("SignatureLineId", Any(m_aSignatureLineId));
if (!aSignerName.isEmpty())
xShapeProps->setPropertyValue("SignatureLineSuggestedSignerName", Any(aSignerName));
if (!aSignerTitle.isEmpty())
......@@ -125,11 +157,24 @@ void SignatureLineDialog::Apply()
xShapeProps->setPropertyValue("SignatureLineShowSignDate", Any(bShowSignDate));
xShapeProps->setPropertyValue("SignatureLineCanAddComment", Any(bCanAddComments));
// Insert into document
Reference<XTextRange> const xEnd
= Reference<XTextDocument>(xModel, UNO_QUERY)->getText()->getEnd();
Reference<XTextContent> const xShapeContent(xShapeProps, UNO_QUERY);
xShapeContent->attach(xEnd);
if (!bIsExistingSignatureLine)
{
// Default size
Reference<XShape> xShape(xShapeProps, UNO_QUERY);
awt::Size aShapeSize;
aShapeSize.Height = 3000;
aShapeSize.Width = 6000;
xShape->setSize(aShapeSize);
// Default anchoring
xShapeProps->setPropertyValue("AnchorType", Any(TextContentAnchorType_AT_PARAGRAPH));
// Insert into document
Reference<XTextRange> const xEnd
= Reference<XTextDocument>(xModel, UNO_QUERY)->getText()->getEnd();
Reference<XTextContent> const xShapeContent(xShapeProps, UNO_QUERY);
xShapeContent->attach(xEnd);
}
}
OUString SignatureLineDialog::getSignatureImage()
......
......@@ -14,6 +14,9 @@
#include <vcl/button.hxx>
#include <vcl/edit.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/uno/Reference.hxx>
class SwView;
class SW_DLLPUBLIC SignatureLineDialog : public SvxStandardDialog
......@@ -30,6 +33,8 @@ private:
SwView& mrView;
css::uno::Reference<css::beans::XPropertySet> m_xExistingShapeProperties;
OUString m_aSignatureLineId;
VclPtr<Edit> m_pEditName;
VclPtr<Edit> m_pEditTitle;
VclPtr<Edit> m_pEditEmail;
......
......@@ -20,6 +20,7 @@
#include <sfx2/request.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/objface.hxx>
#include <svx/svdograf.hxx>
#include <fldmgr.hxx>
#include <expfld.hxx>
#include <modcfg.hxx>
......@@ -61,6 +62,7 @@ void SwView::ExecDlgExt(SfxRequest const &rReq)
break;
}
case FN_INSERT_SIGNATURELINE:
case FN_EDIT_SIGNATURELINE:
{
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
assert(pFact && "SwAbstractDialogFactory fail!");
......@@ -87,6 +89,27 @@ void SwView::ExecDlgExt(SfxRequest const &rReq)
}
}
bool SwView::isSignatureLineSelected()
{
SwWrtShell& rSh = GetWrtShell();
SdrView* pSdrView = rSh.GetDrawView();
if (!pSdrView)
return false;
if (pSdrView->GetMarkedObjectCount() != 1)
return false;
SdrObject* pPickObj = pSdrView->GetMarkedObjectByIndex(0);
if (!pPickObj)
return false;
SdrGrafObj* pGraphic = dynamic_cast<SdrGrafObj*>(pPickObj);
if (!pGraphic)
return false;
return pGraphic->isSignatureLine();
}
void SwView::AutoCaption(const sal_uInt16 nType, const SvGlobalName *pOleId)
{
SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
......
......@@ -103,7 +103,10 @@ void SwView::GetState(SfxItemSet &rSet)
rSet.DisableItem(nWhich);
}
break;
case FN_EDIT_SIGNATURELINE:
if (!isSignatureLineSelected())
rSet.DisableItem(nWhich);
break;
case FN_INSERT_CAPTION:
{
// There are captions for graphics, OLE objects, frames and tables
......
......@@ -268,7 +268,7 @@
<menu:menuitem menu:id=".uno:FlowChartShapes"/>
</menu:menupopup>
</menu:menu>
<menu:menuitem menu:id=".uno:SignatureLineDialog"/>
<menu:menuitem menu:id=".uno:InsertSignatureLine"/>
<menu:menuitem menu:id=".uno:FontworkGalleryFloater"/>
<menu:menuseparator/>
<menu:menuitem menu:id=".uno:DrawText"/>
......
......@@ -68,4 +68,5 @@
<menu:menuseparator/>
<menu:menuitem menu:id=".uno:AddTextBox"/>
<menu:menuitem menu:id=".uno:RemoveTextBox"/>
<menu:menuitem menu:id=".uno:EditSignatureLine"/>
</menu:menupopup>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment