officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu | 12 + sw/inc/cmdid.h | 1 sw/inc/view.hxx | 1 sw/sdi/swriter.sdi | 19 ++ sw/sdi/viewsh.sdi | 6 sw/source/uibase/dialog/SignatureLineDialog.cxx | 87 +++++++--- sw/source/uibase/inc/SignatureLineDialog.hxx | 5 sw/source/uibase/uiview/viewdlg2.cxx | 23 ++ sw/source/uibase/uiview/viewstat.cxx | 5 sw/uiconfig/swriter/menubar/menubar.xml | 2 sw/uiconfig/swriter/popupmenu/draw.xml | 1 11 files changed, 136 insertions(+), 26 deletions(-)
New commits: commit edc3ec2b168e58624211de3dfa14eb17eceda8ec Author: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> Date: Tue Dec 12 12:39:32 2017 +0100 tdf#83877 Edit existing signature lines Change-Id: I7a6861f599cb8794bcb8c246179cf6c7ff9966f3 Reviewed-on: https://gerrit.libreoffice.org/46289 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> diff --git a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu index 8efa138bb380..23964bfe7fdb 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu @@ -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> diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h index c0ae37149ba0..99b25ec056a8 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -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 */ diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx index 6e8f4b7d9511..bec26a1a99c5 100644 --- a/sw/inc/view.hxx +++ b/sw/inc/view.hxx @@ -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&); diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi index 75e75897bf41..1080b680f52a 100644 --- a/sw/sdi/swriter.sdi +++ b/sw/sdi/swriter.sdi @@ -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 () [ diff --git a/sw/sdi/viewsh.sdi b/sw/sdi/viewsh.sdi index 9e4fdabee84d..c6d718457daa 100644 --- a/sw/sdi/viewsh.sdi +++ b/sw/sdi/viewsh.sdi @@ -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 ; diff --git a/sw/source/uibase/dialog/SignatureLineDialog.cxx b/sw/source/uibase/dialog/SignatureLineDialog.cxx index 7944d68cb8a1..b574a7b455e4 100644 --- a/sw/source/uibase/dialog/SignatureLineDialog.cxx +++ b/sw/source/uibase/dialog/SignatureLineDialog.cxx @@ -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() diff --git a/sw/source/uibase/inc/SignatureLineDialog.hxx b/sw/source/uibase/inc/SignatureLineDialog.hxx index 390ab9b203b1..f85ebcc39fbb 100644 --- a/sw/source/uibase/inc/SignatureLineDialog.hxx +++ b/sw/source/uibase/inc/SignatureLineDialog.hxx @@ -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; diff --git a/sw/source/uibase/uiview/viewdlg2.cxx b/sw/source/uibase/uiview/viewdlg2.cxx index 38beca593167..e3f328a3b3c3 100644 --- a/sw/source/uibase/uiview/viewdlg2.cxx +++ b/sw/source/uibase/uiview/viewdlg2.cxx @@ -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(); diff --git a/sw/source/uibase/uiview/viewstat.cxx b/sw/source/uibase/uiview/viewstat.cxx index 9f3132f0dbf0..1f7797b7dad4 100644 --- a/sw/source/uibase/uiview/viewstat.cxx +++ b/sw/source/uibase/uiview/viewstat.cxx @@ -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 diff --git a/sw/uiconfig/swriter/menubar/menubar.xml b/sw/uiconfig/swriter/menubar/menubar.xml index 67de5a0934f6..4ede0569fc1f 100644 --- a/sw/uiconfig/swriter/menubar/menubar.xml +++ b/sw/uiconfig/swriter/menubar/menubar.xml @@ -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"/> diff --git a/sw/uiconfig/swriter/popupmenu/draw.xml b/sw/uiconfig/swriter/popupmenu/draw.xml index 0f2c33cf4dd4..f9920588aa03 100644 --- a/sw/uiconfig/swriter/popupmenu/draw.xml +++ b/sw/uiconfig/swriter/popupmenu/draw.xml @@ -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> _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits