diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-06-09 18:03:22 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-06-09 23:44:55 +0200 |
commit | f1566f0b813e439531a37154b52d491fd9d3224b (patch) | |
tree | 5da4b80c0928164d9ee595e3d04e8698e9318c0d | |
parent | dbf3eba5514f0ed48683e2b58ac56c96b6d48792 (diff) |
sd signature line: select certificate after drawing the shape's rectangle
Also move the shape-type-specific setup to
FuConstructRectangle::SetAttributes() where the rest of the shape types
are handled.
Change-Id: I9ecf94957ec82ba187f2767b01d96fb14de2b657
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95958
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
-rw-r--r-- | cui/source/dialogs/signature-line-draw.svg | 10 | ||||
-rw-r--r-- | include/svx/signaturelinehelper.hxx | 8 | ||||
-rw-r--r-- | sd/source/ui/func/fuconrec.cxx | 50 | ||||
-rw-r--r-- | svx/source/dialog/signaturelinehelper.cxx | 27 |
4 files changed, 68 insertions, 27 deletions
diff --git a/cui/source/dialogs/signature-line-draw.svg b/cui/source/dialogs/signature-line-draw.svg index cd256d098a27..564b5cdf3ef9 100644 --- a/cui/source/dialogs/signature-line-draw.svg +++ b/cui/source/dialogs/signature-line-draw.svg @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> -<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" version="1.2" width="90mm" height="45mm" viewBox="0 0 9000 4500" preserveAspectRatio="xMidYMid" fill-rule="evenodd" stroke-width="28.222" stroke-linejoin="round" xml:space="preserve" id="svg577" inkscape:version="0.92.2 5c3e80d, 2017-08-06"> +<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" version="1.2" width="90mm" height="45mm" viewBox="0 0 9000 4500" preserveAspectRatio="xMidYMid" xml:space="preserve" id="svg577" inkscape:version="0.92.2 5c3e80d, 2017-08-06" sodipodi:docname="test.svg" stroke-linejoin="round" stroke-width="28.222" fill-rule="evenodd"> <metadata id="metadata581"> <rdf:RDF> <cc:Work rdf:about=""> @@ -9,7 +9,7 @@ </cc:Work> </rdf:RDF> </metadata> - <sodipodi:namedview pagecolor="#ffffff" bordercolor="#666666" borderopacity="1" objecttolerance="10" gridtolerance="10" guidetolerance="10" inkscape:pageopacity="0" inkscape:pageshadow="2" inkscape:window-width="1920" inkscape:window-height="1015" id="namedview579" showgrid="false" inkscape:zoom="3.6100926" inkscape:cx="169.5801" inkscape:cy="97.595557" inkscape:window-x="0" inkscape:window-y="0" inkscape:window-maximized="1" inkscape:current-layer="g569" inkscape:pagecheckerboard="false"/> + <sodipodi:namedview pagecolor="#ffffff" bordercolor="#666666" borderopacity="1" objecttolerance="10" gridtolerance="10" guidetolerance="10" inkscape:pageopacity="0" inkscape:pageshadow="2" inkscape:window-width="1920" inkscape:window-height="1015" id="namedview579" showgrid="false" inkscape:zoom="3.6100926" inkscape:cx="133.43144" inkscape:cy="97.595557" inkscape:window-x="0" inkscape:window-y="0" inkscape:window-maximized="1" inkscape:current-layer="g569" inkscape:pagecheckerboard="false" units="cm"/> <defs class="ClipPathGroup" id="defs8"> <clipPath id="presentation_clip_path" clipPathUnits="userSpaceOnUse"> <rect x="0" y="0" width="9000" height="4500" id="rect2"/> @@ -28,9 +28,9 @@ </g> <g class="SlideGroup" id="g575"> <path inkscape:connector-curvature="0" style="fill:none;stroke:#ffcccc;stroke-width:355.69763184;stroke-linecap:round;stroke-linejoin:round" d="M 2677.6009,4322.3785 C 4637.7107,2683.4298 4480.4998,1439.2788 4416.8177,177.68919 4135.9768,2203.3862 5181.4191,2928.0647 6822.3029,3068.6459 5584.8956,2678.4757 4273.5892,2702.5453 2677.6009,4322.3785 Z" id="path8"/> - <g id="g569" class="Page"><text id="text233" class="TextShape" x="-1300" y="-105.83334"><tspan style="font-weight:400;font-size:600px;font-family:'Liberation Sans', sans-serif" id="tspan231" font-weight="400" font-size="600px" class="TextParagraph"><tspan style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:493.88891602px;font-family:'Liberation Sans', sans-serif;-inkscape-font-specification:'Liberation Sans, sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#000000;stroke:none" id="tspan229" y="2065.1667" x="250" class="TextPosition">[SIGNER_NAME]</tspan></tspan></text> -<text id="text233-7" class="TextShape" transform="scale(0.96176919,1.0397505)" x="-1351.6757" y="-991.06195" style="font-size:12.47700596px;stroke-width:29.34383965"><tspan style="font-weight:400;font-size:623.85028076px;font-family:'Liberation Sans', sans-serif;stroke-width:29.34383965" id="tspan231-0" font-weight="400" font-size="600px" class="TextParagraph"><tspan style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:513.52124023px;font-family:'Liberation Sans', sans-serif;-inkscape-font-specification:'Liberation Sans, sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#000000;stroke:none;stroke-width:29.34383965" id="tspan229-2" y="1266.2363" x="259.93756" class="TextPosition">Digitally signed by:</tspan></tspan></text> -<text id="text233-74" class="TextShape" x="-1300" y="639.29163"><tspan style="font-weight:400;font-size:600px;font-family:'Liberation Sans', sans-serif" id="tspan231-3" font-weight="400" font-size="600px" class="TextParagraph"><tspan style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:493.88891602px;font-family:'Liberation Sans', sans-serif;-inkscape-font-specification:'Liberation Sans, sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#000000;stroke:none" id="tspan229-9" y="2810.2917" x="250" class="TextPosition">Date: [DATE]</tspan></tspan></text> + <g id="g569" class="Page"><text xml:space="preserve" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:493.88882446px;line-height:1.25;font-family:'Liberation Sans', sans-serif;-inkscape-font-specification:'Liberation Sans, sans-serif';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:746.70703125" x="265.50031" y="877.50842" id="text31-3"><tspan sodipodi:role="line" id="tspan29-6" x="265.50031" y="877.50842" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:493.88882446px;font-family:'Liberation Sans', sans-serif;-inkscape-font-specification:'Liberation Sans, sans-serif';stroke-width:746.70703125">Digitally signed by:</tspan></text> +<text xml:space="preserve" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:493.88879395px;line-height:1.25;font-family:'Liberation Sans', sans-serif;-inkscape-font-specification:'Liberation Sans, sans-serif';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:746.70697021" x="228.1967" y="2377.5085" id="text31-3-3"><tspan sodipodi:role="line" id="tspan29-6-5" x="228.1967" y="2377.5085" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:493.88879395px;font-family:'Liberation Sans', sans-serif;-inkscape-font-specification:'Liberation Sans, sans-serif';stroke-width:746.70697021">[SIGNER_NAME]</tspan></text> +<text xml:space="preserve" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:493.6913147px;line-height:1.25;font-family:'Liberation Sans', sans-serif;-inkscape-font-specification:'Liberation Sans, sans-serif';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:746.40844727" x="206.12776" y="3879.1411" id="text31-3-3-9" transform="scale(1.0003999,0.99960029)"><tspan sodipodi:role="line" id="tspan29-6-5-1" x="206.12776" y="3879.1411" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:493.6913147px;font-family:'Liberation Sans', sans-serif;-inkscape-font-specification:'Liberation Sans, sans-serif';stroke-width:746.40844727">Date: [DATE]</tspan></text> </g> </g> </svg> diff --git a/include/svx/signaturelinehelper.hxx b/include/svx/signaturelinehelper.hxx index 4cdb40651479..0906d88ef095 100644 --- a/include/svx/signaturelinehelper.hxx +++ b/include/svx/signaturelinehelper.hxx @@ -21,6 +21,7 @@ namespace weld { class Window; } +class SdrView; class SfxObjectShell; namespace svx::SignatureLineHelper @@ -52,6 +53,13 @@ SVX_DLLPUBLIC OUString getLocalizedDate(); * Interprets rSVG as a graphic and gives back the resuling UNO wrapper. */ SVX_DLLPUBLIC css::uno::Reference<css::graphic::XGraphic> importSVG(const OUString& rSVG); + +/** + * Sets xCertificate as the signing certificate of the selected shape on pView. + */ +SVX_DLLPUBLIC void +setShapeCertificate(SdrView* pView, + const css::uno::Reference<css::security::XCertificate>& xCertificate); } #endif diff --git a/sd/source/ui/func/fuconrec.cxx b/sd/source/ui/func/fuconrec.cxx index 63daa06171c4..91ed61ad3d63 100644 --- a/sd/source/ui/func/fuconrec.cxx +++ b/sd/source/ui/func/fuconrec.cxx @@ -59,6 +59,7 @@ #include <basegfx/polygon/b2dpolygontools.hxx> #include <basegfx/polygon/b2dpolygon.hxx> #include <svx/xfillit0.hxx> +#include <svx/signaturelinehelper.hxx> #include <sdresid.hxx> #include <View.hxx> @@ -430,28 +431,6 @@ void FuConstructRectangle::Activate() void FuConstructRectangle::Deactivate() { - if (nSlotId == SID_INSERT_SIGNATURELINE) - { - const SdrMarkList& rMarkList = mpView->GetMarkedObjectList(); - if (rMarkList.GetMarkCount() > 0) - { - // Avoid the default solid fill and line, we'll set a graphic instead. - const SdrMark* pMark = rMarkList.GetMark(0); - SdrObject* pObject = pMark->GetMarkedSdrObj(); - SfxItemSet aSet = pObject->GetMergedItemSet(); - - XFillStyleItem aFillStyleItem(aSet.Get(XATTR_FILLSTYLE)); - aFillStyleItem.SetValue(drawing::FillStyle_NONE); - aSet.Put(aFillStyleItem); - - XLineStyleItem aLineStyleItem(aSet.Get(XATTR_LINESTYLE)); - aLineStyleItem.SetValue(drawing::LineStyle_NONE); - aSet.Put(aLineStyleItem); - - pObject->SetMergedItemSet(aSet); - } - } - if( nSlotId == SID_TOOL_CONNECTOR || nSlotId == SID_CONNECTOR_ARROW_START || nSlotId == SID_CONNECTOR_ARROW_END || @@ -491,6 +470,27 @@ void FuConstructRectangle::Deactivate() mpView->SetGlueVisible( false ); } FuConstruct::Deactivate(); + + if (nSlotId != SID_INSERT_SIGNATURELINE) + { + return; + } + + // Finished drawing a signature rectangle, now set it up. + if (!mpViewShell) + { + return; + } + + uno::Reference<security::XCertificate> xCertificate + = svx::SignatureLineHelper::getSignatureCertificate(mpViewShell->GetObjectShell(), + mpViewShell->GetFrameWeld()); + if (!xCertificate.is()) + { + return; + } + + svx::SignatureLineHelper::setShapeCertificate(mpView, xCertificate); } namespace { @@ -621,6 +621,12 @@ void FuConstructRectangle::SetAttributes(SfxItemSet& rAttr, SdrObject* pObj) break; } } + else if (nSlotId == SID_INSERT_SIGNATURELINE) + { + // Avoid the default solid fill and line, we'll set a graphic instead. + rAttr.Put(XFillStyleItem(drawing::FillStyle_NONE)); + rAttr.Put(XLineStyleItem(drawing::LineStyle_NONE)); + } } /** diff --git a/svx/source/dialog/signaturelinehelper.cxx b/svx/source/dialog/signaturelinehelper.cxx index 69010ec09b10..11ef1face66a 100644 --- a/svx/source/dialog/signaturelinehelper.cxx +++ b/svx/source/dialog/signaturelinehelper.cxx @@ -14,6 +14,7 @@ #include <com/sun/star/security/XCertificate.hpp> #include <comphelper/processfactory.hxx> +#include <comphelper/sequenceashashmap.hxx> #include <comphelper/storagehelper.hxx> #include <comphelper/xmlsechelper.hxx> #include <config_folders.h> @@ -22,6 +23,8 @@ #include <sfx2/docfile.hxx> #include <sfx2/docfilt.hxx> #include <sfx2/objsh.hxx> +#include <svx/svdmark.hxx> +#include <svx/svdview.hxx> #include <tools/stream.hxx> #include <unotools/localedatawrapper.hxx> #include <unotools/streamwrap.hxx> @@ -119,6 +122,30 @@ uno::Reference<graphic::XGraphic> importSVG(const OUString& rSVG) uno::Reference<graphic::XGraphic> xGraphic(xProvider->queryGraphic(aMediaProperties)); return xGraphic; } + +void setShapeCertificate(SdrView* pView, + const css::uno::Reference<css::security::XCertificate>& xCertificate) +{ + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + if (rMarkList.GetMarkCount() < 1) + { + return; + } + + const SdrMark* pMark = rMarkList.GetMark(0); + SdrObject* pSignatureLine = pMark->GetMarkedSdrObj(); + if (!pSignatureLine) + { + return; + } + + // Remember the selected certificate. + uno::Reference<beans::XPropertySet> xShapeProps(pSignatureLine->getUnoShape(), uno::UNO_QUERY); + comphelper::SequenceAsHashMap aMap(xShapeProps->getPropertyValue("InteropGrabBag")); + aMap["SignatureCertificate"] <<= xCertificate; + xShapeProps->setPropertyValue("InteropGrabBag", + uno::makeAny(aMap.getAsConstPropertyValueList())); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |