[Libreoffice-commits] core.git: cui/source sc/sdi sc/source sc/uiconfig xmloff/source
Samuel Mehrbrodt
Samuel.Mehrbrodt at cib.de
Fri Jul 6 05:41:32 UTC 2018
cui/source/dialogs/SignatureLineDialog.cxx | 44 ++++++++++++++++++++---
sc/sdi/tabvwsh.sdi | 3 +
sc/source/ui/inc/tabvwsh.hxx | 1
sc/source/ui/view/tabvwshb.cxx | 54 +++++++++++++++++++++++++++++
sc/uiconfig/scalc/menubar/menubar.xml | 1
sc/uiconfig/scalc/popupmenu/graphic.xml | 3 +
xmloff/source/draw/ximpshap.cxx | 13 ++++++
7 files changed, 114 insertions(+), 5 deletions(-)
New commits:
commit 9891fd076c30d353e9edfee9678f0b8e96d26238
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Date: Fri Jun 29 09:10:48 2018 +0200
tdf#117903 Add signature line feature to calc
Change-Id: I4e9121803a26cba1f40f8f1c673c7809543ef2ec
Reviewed-on: https://gerrit.libreoffice.org/57015
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
diff --git a/cui/source/dialogs/SignatureLineDialog.cxx b/cui/source/dialogs/SignatureLineDialog.cxx
index bd3d2a75003a..3089830ef7a4 100644
--- a/cui/source/dialogs/SignatureLineDialog.cxx
+++ b/cui/source/dialogs/SignatureLineDialog.cxx
@@ -16,12 +16,17 @@
#include <vcl/weld.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
#include <com/sun/star/drawing/XShape.hpp>
#include <com/sun/star/graphic/GraphicProvider.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/graphic/XGraphicProvider.hpp>
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheetView.hpp>
#include <com/sun/star/text/TextContentAnchorType.hpp>
#include <com/sun/star/text/XTextContent.hpp>
#include <com/sun/star/text/XTextDocument.hpp>
@@ -29,10 +34,12 @@
using namespace css;
using namespace css::uno;
using namespace css::beans;
+using namespace css::container;
using namespace css::frame;
using namespace css::io;
using namespace css::lang;
using namespace css::frame;
+using namespace css::sheet;
using namespace css::text;
using namespace css::drawing;
using namespace css::graphic;
@@ -161,11 +168,38 @@ void SignatureLineDialog::Apply()
// Default anchoring
xShapeProps->setPropertyValue("AnchorType", Any(TextContentAnchorType_AT_PARAGRAPH));
- // Insert into document
- Reference<XTextRange> const xEnd
- = Reference<XTextDocument>(m_xModel, UNO_QUERY)->getText()->getEnd();
- Reference<XTextContent> const xShapeContent(xShapeProps, UNO_QUERY);
- xShapeContent->attach(xEnd);
+ const Reference<XServiceInfo> xServiceInfo(m_xModel, UNO_QUERY);
+
+ // Writer
+ const Reference<XTextDocument> xTextDocument(m_xModel, UNO_QUERY);
+ if (xTextDocument.is())
+ {
+ // Insert into document
+ Reference<XTextRange> const xEnd
+ = Reference<XTextDocument>(m_xModel, UNO_QUERY)->getText()->getEnd();
+ Reference<XTextContent> const xShapeContent(xShapeProps, UNO_QUERY);
+ xShapeContent->attach(xEnd);
+ return;
+ }
+
+ // Calc
+ const Reference<XSpreadsheetDocument> xSpreadsheetDocument(m_xModel, UNO_QUERY);
+ if (xSpreadsheetDocument.is())
+ {
+ Reference<XPropertySet> xSheetCell(m_xModel->getCurrentSelection(), UNO_QUERY_THROW);
+ awt::Point aCellPosition;
+ xSheetCell->getPropertyValue("Position") >>= aCellPosition;
+ xShape->setPosition(aCellPosition);
+
+ Reference<XSpreadsheetView> xView(m_xModel->getCurrentController(), UNO_QUERY_THROW);
+ Reference<XSpreadsheet> xSheet(xView->getActiveSheet(), UNO_QUERY_THROW);
+ Reference<XDrawPageSupplier> xDrawPageSupplier(xSheet, UNO_QUERY_THROW);
+ Reference<XDrawPage> xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_QUERY_THROW);
+ Reference<XShapes> xShapes(xDrawPage, UNO_QUERY_THROW);
+
+ xShapes->add(xShape);
+ return;
+ }
}
}
diff --git a/sc/sdi/tabvwsh.sdi b/sc/sdi/tabvwsh.sdi
index 8df105eb28ec..7f33a247a394 100644
--- a/sc/sdi/tabvwsh.sdi
+++ b/sc/sdi/tabvwsh.sdi
@@ -56,6 +56,9 @@ interface BaseSelection
SID_INSERT_OBJECT [ ExecMethod = ExecDrawIns; StateMethod = GetDrawInsState; ]
SID_INSERT_FLOATINGFRAME [ ExecMethod = ExecDrawIns; StateMethod = GetDrawInsState; ]
SID_INSERT_AVMEDIA [ ExecMethod = ExecDrawIns; StateMethod = GetDrawInsState; ]
+ SID_INSERT_SIGNATURELINE [ ExecMethod = ExecDrawIns; StateMethod = GetDrawInsState; ]
+ SID_EDIT_SIGNATURELINE [ ExecMethod = ExecDrawIns; StateMethod = GetDrawInsState; ]
+ SID_SIGN_SIGNATURELINE [ ExecMethod = ExecDrawIns; StateMethod = GetDrawInsState; ]
SID_IMAP [ ExecMethod = ExecImageMap; StateMethod = GetImageMapState; ]
SID_IMAP_EXEC [ ExecMethod = ExecImageMap; StateMethod = GetImageMapState; ]
diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index 8b4753e18c42..a59a0ae265ac 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -174,6 +174,7 @@ private:
void DoReadUserData( const OUString& rData );
void DoReadUserDataSequence( const css::uno::Sequence< css::beans::PropertyValue >& rSettings );
+ bool IsSignatureLineSelected();
DECL_LINK( SimpleRefClose, const OUString*, void );
DECL_LINK( SimpleRefDone, const OUString&, void );
diff --git a/sc/source/ui/view/tabvwshb.cxx b/sc/source/ui/view/tabvwshb.cxx
index ae40de856b47..c52bf0b3d1d5 100644
--- a/sc/source/ui/view/tabvwshb.cxx
+++ b/sc/source/ui/view/tabvwshb.cxx
@@ -344,6 +344,30 @@ void ScTabViewShell::ExecDrawIns(SfxRequest& rReq)
FuInsertOLE(*this, pWin, pView, pDrModel, rReq);
break;
+ case SID_INSERT_SIGNATURELINE:
+ case SID_EDIT_SIGNATURELINE:
+ {
+ const uno::Reference<frame::XModel> xModel( GetViewData().GetDocShell()->GetBaseModel() );
+
+ VclAbstractDialogFactory* pFact = VclAbstractDialogFactory::Create();
+ ScopedVclPtr<AbstractSignatureLineDialog> pDialog(pFact->CreateSignatureLineDialog(
+ pWin->GetFrameWeld(), xModel, rReq.GetSlot() == SID_EDIT_SIGNATURELINE));
+ pDialog->Execute();
+ break;
+ }
+
+ case SID_SIGN_SIGNATURELINE:
+ {
+ const uno::Reference<frame::XModel> xModel(
+ GetViewData().GetDocShell()->GetBaseModel());
+
+ VclAbstractDialogFactory* pFact = VclAbstractDialogFactory::Create();
+ VclPtr<AbstractSignSignatureLineDialog> pDialog
+ = pFact->CreateSignSignatureLineDialog(GetFrameWeld(), xModel);
+ pDialog->Execute();
+ break;
+ }
+
case SID_INSERT_DIAGRAM_FROM_FILE:
try
{
@@ -505,6 +529,16 @@ void ScTabViewShell::GetDrawInsState(SfxItemSet &rSet)
rSet.DisableItem( nWhich );
break;
+ case SID_INSERT_SIGNATURELINE:
+ if ( bTabProt || bShared )
+ rSet.DisableItem( nWhich );
+ break;
+ case SID_EDIT_SIGNATURELINE:
+ case SID_SIGN_SIGNATURELINE:
+ if (!IsSignatureLineSelected())
+ rSet.DisableItem(nWhich);
+ break;
+
case SID_INSERT_GRAPHIC:
if (bTabProt || bShared)
{
@@ -539,6 +573,26 @@ void ScTabViewShell::GetDrawInsState(SfxItemSet &rSet)
}
}
+bool ScTabViewShell::IsSignatureLineSelected()
+{
+ SdrView* pSdrView = GetSdrView();
+ 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 ScTabViewShell::ExecuteUndo(SfxRequest& rReq)
{
SfxShell* pSh = GetViewData().GetDispatcher().GetShell(0);
diff --git a/sc/uiconfig/scalc/menubar/menubar.xml b/sc/uiconfig/scalc/menubar/menubar.xml
index 9cebf9db0cd3..35d099157f0a 100644
--- a/sc/uiconfig/scalc/menubar/menubar.xml
+++ b/sc/uiconfig/scalc/menubar/menubar.xml
@@ -308,6 +308,7 @@
<menu:menuitem menu:id=".uno:ScrollBar"/>
</menu:menupopup>
</menu:menu>
+ <menu:menuitem menu:id=".uno:InsertSignatureLine"/>
</menu:menupopup>
</menu:menu>
<menu:menu menu:id=".uno:FormatMenu">
diff --git a/sc/uiconfig/scalc/popupmenu/graphic.xml b/sc/uiconfig/scalc/popupmenu/graphic.xml
index 6185490898eb..716459b81a41 100644
--- a/sc/uiconfig/scalc/popupmenu/graphic.xml
+++ b/sc/uiconfig/scalc/popupmenu/graphic.xml
@@ -75,4 +75,7 @@
<menu:menuitem menu:id=".uno:Crop"/>
</menu:menupopup>
</menu:menu>
+ <menu:menuseparator/>
+ <menu:menuitem menu:id=".uno:EditSignatureLine"/>
+ <menu:menuitem menu:id=".uno:SignSignatureLine"/>
</menu:menupopup>
diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx
index 5d2bad9e303b..5f5420f4fb72 100644
--- a/xmloff/source/draw/ximpshap.cxx
+++ b/xmloff/source/draw/ximpshap.cxx
@@ -3510,6 +3510,19 @@ SvXMLImportContextRef SdXMLFrameShapeContext::CreateChildContext( sal_uInt16 nPr
}
}
}
+ else if ((XML_NAMESPACE_LO_EXT == nPrefix) && IsXMLToken(rLocalName, XML_SIGNATURELINE))
+ {
+ SdXMLShapeContext* pSContext = dynamic_cast<SdXMLShapeContext*>(mxImplContext.get());
+ if (pSContext)
+ {
+ uno::Reference<beans::XPropertySet> xPropSet(pSContext->getShape(), uno::UNO_QUERY);
+ if (xPropSet.is())
+ {
+ xContext = new SignatureLineContext(GetImport(), nPrefix, rLocalName, xAttrList,
+ pSContext->getShape());
+ }
+ }
+ }
// call parent for content
if (!xContext)
xContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
More information about the Libreoffice-commits
mailing list