diff options
Diffstat (limited to 'sw/source/uibase')
-rw-r--r-- | sw/source/uibase/dialog/SignatureLineDialog.cxx | 87 | ||||
-rw-r--r-- | sw/source/uibase/inc/SignatureLineDialog.hxx | 5 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewdlg2.cxx | 23 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewstat.cxx | 5 |
4 files changed, 98 insertions, 22 deletions
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 |