summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2018-06-29 09:10:48 +0200
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2018-07-06 07:41:04 +0200
commit9891fd076c30d353e9edfee9678f0b8e96d26238 (patch)
tree3ec45dce87e478fc8b1b7f38c9bcdde9242921f0
parent3f66d987ce3a46eb836f2c11bbaf360bd6195e27 (diff)
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@cib.de>
-rw-r--r--cui/source/dialogs/SignatureLineDialog.cxx44
-rw-r--r--sc/sdi/tabvwsh.sdi3
-rw-r--r--sc/source/ui/inc/tabvwsh.hxx1
-rw-r--r--sc/source/ui/view/tabvwshb.cxx54
-rw-r--r--sc/uiconfig/scalc/menubar/menubar.xml1
-rw-r--r--sc/uiconfig/scalc/popupmenu/graphic.xml3
-rw-r--r--xmloff/source/draw/ximpshap.cxx13
7 files changed, 114 insertions, 5 deletions
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 );