17#include <com/sun/star/beans/XPropertySet.hpp>
18#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
19#include <com/sun/star/drawing/XShape.hpp>
20#include <com/sun/star/graphic/XGraphic.hpp>
21#include <com/sun/star/lang/XMultiServiceFactory.hpp>
22#include <com/sun/star/sheet/XSpreadsheet.hpp>
23#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
24#include <com/sun/star/sheet/XSpreadsheetView.hpp>
25#include <com/sun/star/text/TextContentAnchorType.hpp>
26#include <com/sun/star/text/XTextContent.hpp>
27#include <com/sun/star/text/XTextDocument.hpp>
28#include <com/sun/star/text/XTextViewCursor.hpp>
29#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
32using namespace css::uno;
33using namespace css::beans;
34using namespace css::container;
35using namespace css::frame;
36using namespace css::lang;
37using namespace css::frame;
38using namespace css::sheet;
39using namespace css::text;
40using namespace css::drawing;
41using namespace css::graphic;
46 "SignatureLineDialog")
47 , m_xEditName(m_xBuilder->weld_entry(
"edit_name"))
48 , m_xEditTitle(m_xBuilder->weld_entry(
"edit_title"))
49 , m_xEditEmail(m_xBuilder->weld_entry(
"edit_email"))
50 , m_xEditInstructions(m_xBuilder->weld_text_view(
"edit_instructions"))
51 , m_xCheckboxCanAddComments(m_xBuilder->weld_check_button(
"checkbox_can_add_comments"))
52 , m_xCheckboxShowSignDate(m_xBuilder->weld_check_button(
"checkbox_show_sign_date"))
65 Reference<container::XIndexAccess> xIndexAccess(
m_xModel->getCurrentSelection(),
67 Reference<XPropertySet> xProps(xIndexAccess->getByIndex(0), UNO_QUERY_THROW);
71 OUString aSuggestedSignerName;
72 xProps->getPropertyValue(
"SignatureLineSuggestedSignerName") >>= aSuggestedSignerName;
74 OUString aSuggestedSignerTitle;
75 xProps->getPropertyValue(
"SignatureLineSuggestedSignerTitle") >>= aSuggestedSignerTitle;
77 OUString aSuggestedSignerEmail;
78 xProps->getPropertyValue(
"SignatureLineSuggestedSignerEmail") >>= aSuggestedSignerEmail;
80 OUString aSigningInstructions;
81 xProps->getPropertyValue(
"SignatureLineSigningInstructions") >>= aSigningInstructions;
83 bool bCanAddComments =
false;
84 xProps->getPropertyValue(
"SignatureLineCanAddComment") >>= bCanAddComments;
86 bool bShowSignDate =
false;
87 xProps->getPropertyValue(
"SignatureLineShowSignDate") >>= bShowSignDate;
108 aSvgImage = aSvgImage.replaceAll(
"[SIGNER_NAME]",
getCDataString(aSignerName));
109 aSvgImage = aSvgImage.replaceAll(
"[SIGNER_TITLE]",
getCDataString(aSignerTitle));
112 aSvgImage = aSvgImage.replaceAll(
"[SIGNATURE]",
"");
113 aSvgImage = aSvgImage.replaceAll(
"[SIGNED_BY]",
"");
114 aSvgImage = aSvgImage.replaceAll(
"[INVALID_SIGNATURE]",
"");
115 aSvgImage = aSvgImage.replaceAll(
"[DATE]",
"");
121 Reference<XPropertySet> xShapeProps;
122 if (bIsExistingSignatureLine)
125 xShapeProps.set(Reference<lang::XMultiServiceFactory>(
m_xModel, UNO_QUERY_THROW)
129 xShapeProps->setPropertyValue(
"Graphic",
Any(xGraphic));
130 xShapeProps->setPropertyValue(
"SignatureLineUnsignedImage",
Any(xGraphic));
133 xShapeProps->setPropertyValue(
"IsSignatureLine",
Any(
true));
135 if (!aSignerName.isEmpty())
136 xShapeProps->setPropertyValue(
"SignatureLineSuggestedSignerName",
Any(aSignerName));
137 if (!aSignerTitle.isEmpty())
138 xShapeProps->setPropertyValue(
"SignatureLineSuggestedSignerTitle",
Any(aSignerTitle));
139 if (!aSignerEmail.isEmpty())
140 xShapeProps->setPropertyValue(
"SignatureLineSuggestedSignerEmail",
Any(aSignerEmail));
141 if (!aSigningInstructions.isEmpty())
142 xShapeProps->setPropertyValue(
"SignatureLineSigningInstructions",
143 Any(aSigningInstructions));
144 xShapeProps->setPropertyValue(
"SignatureLineShowSignDate",
Any(bShowSignDate));
145 xShapeProps->setPropertyValue(
"SignatureLineCanAddComment",
Any(bCanAddComments));
147 if (bIsExistingSignatureLine)
151 Reference<XShape> xShape(xShapeProps, UNO_QUERY);
152 awt::Size aShapeSize;
153 aShapeSize.Height = 3000;
154 aShapeSize.Width = 6000;
155 xShape->setSize(aShapeSize);
158 xShapeProps->setPropertyValue(
"AnchorType",
Any(TextContentAnchorType_AT_PARAGRAPH));
161 const Reference<XTextDocument> xTextDocument(
m_xModel, UNO_QUERY);
162 if (xTextDocument.is())
164 Reference<XTextContent> xTextContent(xShape, UNO_QUERY_THROW);
165 Reference<XTextViewCursorSupplier> xViewCursorSupplier(
m_xModel->getCurrentController(),
167 Reference<XTextViewCursor> xCursor = xViewCursorSupplier->getViewCursor();
169 Reference<XText>
const xText(xCursor->getText());
171 xText->insertTextContent(xCursor, xTextContent,
true);
176 const Reference<XSpreadsheetDocument> xSpreadsheetDocument(
m_xModel, UNO_QUERY);
177 if (!xSpreadsheetDocument.is())
180 Reference<XPropertySet> xSheetCell(
m_xModel->getCurrentSelection(), UNO_QUERY_THROW);
181 awt::Point aCellPosition;
182 xSheetCell->getPropertyValue(
"Position") >>= aCellPosition;
183 xShape->setPosition(aCellPosition);
185 Reference<XSpreadsheetView> xView(
m_xModel->getCurrentController(), UNO_QUERY_THROW);
186 Reference<XSpreadsheet> xSheet(xView->getActiveSheet(), UNO_SET_THROW);
187 Reference<XDrawPageSupplier> xDrawPageSupplier(xSheet, UNO_QUERY_THROW);
188 Reference<XDrawPage> xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW);
189 Reference<XShapes> xShapes(xDrawPage, UNO_QUERY_THROW);
191 xShapes->add(xShape);
HRESULT createInstance(REFIID iid, Ifc **ppIfc)
static OUString getCDataString(std::u16string_view rString)
css::uno::Reference< css::frame::XModel > m_xModel
std::unique_ptr< weld::Entry > m_xEditName
css::uno::Reference< css::beans::XPropertySet > m_xExistingShapeProperties
std::unique_ptr< weld::Entry > m_xEditTitle
OUString m_aSignatureLineId
std::unique_ptr< weld::CheckButton > m_xCheckboxShowSignDate
std::unique_ptr< weld::Entry > m_xEditEmail
std::unique_ptr< weld::TextView > m_xEditInstructions
std::unique_ptr< weld::CheckButton > m_xCheckboxCanAddComments
SignatureLineDialog(weld::Widget *pParent, css::uno::Reference< css::frame::XModel > xModel, bool bEditExisting)
virtual void Apply() override
OString generateGUIDString()
uno::Reference< graphic::XGraphic > importSVG(std::u16string_view rSVG)
OUString getSignatureImage(const OUString &rType=OUString())
Reference< XModel > xModel