diff options
Diffstat (limited to 'cui/source/dialogs/SignatureLineDialog.cxx')
-rw-r--r-- | cui/source/dialogs/SignatureLineDialog.cxx | 44 |
1 files changed, 39 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; + } } } |