cui/source/dialogs/SignSignatureLineDialog.cxx | 2 desktop/source/lib/init.cxx | 14 ++ include/sfx2/digitalsignatures.hxx | 8 + include/sfx2/objsh.hxx | 2 include/svx/signaturelinehelper.hxx | 3 sd/sdi/_drvwsh.sdi | 1 sd/source/ui/func/fuconrec.cxx | 1 sd/source/ui/view/drviewse.cxx | 38 ++++++ sfx2/source/doc/objserv.cxx | 74 ++++++++----- svx/sdi/svx.sdi | 2 svx/source/dialog/signaturelinehelper.cxx | 9 + svx/source/svdraw/svdedtv1.cxx | 11 + xmlsecurity/source/component/documentdigitalsignatures.cxx | 29 +++-- 13 files changed, 150 insertions(+), 44 deletions(-)
New commits: commit 817b1c6a5cbf266f77049a0e9c26b882f5e1bd2c Author: Miklos Vajna <[email protected]> AuthorDate: Wed Jan 8 09:42:53 2025 +0100 Commit: Miklos Vajna <[email protected]> CommitDate: Tue Feb 11 13:50:16 2025 +0100 cool#10630 lok doc sign: allow setting the pos of the Impress sign line Open a PDF in LOK mode, insert a signature line, try to drag the selected signature widget/shape, nothing happens. Given that the inserted shape has a default position at page center, you typically want to adjust that default position, but that requires adding a few exceptions, since PDFs are normally read-only. Desktop Impress gets around this since commit 5d296183072dc7cfe7a9985c38388b56f37d873c (sd signature line: allow move / resize of shape before signing, 2020-06-26), but LOK clients want to rather dispatch an UNO command (instead of handling this in the mouse event handler), so this requires additional work. A first problem is in isCommandAllowed() in desktop/ that explicitly rejects the UNO command for read-only documents: allow this when a signature widget is selected. A second problem is in SdrEditView::SetGeoAttrToMarked(), check for the signature widget there as well. Given that the implementation of .uno:TransformDialog already has a set of flags to prevent doing anything for read-only documents, it looks safe to allow the execution of the command itself. The size of the widget should be also possible to modify, that's not yet done here. Change-Id: I92a60717e98ac33f7a1eb9770cd0c7903f60759c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180049 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index fa273ea8de8d..1d6fbc1be272 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -5143,13 +5143,23 @@ static bool isCommandAllowed(OUString& command) { return true; else { - if (command == u".uno:Save"_ustr && SfxViewShell::Current() && SfxViewShell::Current()->IsAllowChangeComments()) + SfxViewShell* pViewShell = SfxViewShell::Current(); + if (command == u".uno:Save"_ustr && pViewShell && pViewShell->IsAllowChangeComments()) return true; for (size_t i = 0; i < std::size(nonAllowedList); i++) { if (nonAllowedList[i] == command) - return false; + { + bool bRet = false; + if (pViewShell && command == u".uno:TransformDialog"_ustr) + { + // If the just added signature line shape is selected, allow moving it. + SfxObjectShell* pDocShell = pViewShell->GetObjectShell(); + bRet = pDocShell->GetSignPDFCertificate().is(); + } + return bRet; + } } return true; } diff --git a/sd/sdi/_drvwsh.sdi b/sd/sdi/_drvwsh.sdi index 23767a837e9f..917d369ac8fc 100644 --- a/sd/sdi/_drvwsh.sdi +++ b/sd/sdi/_drvwsh.sdi @@ -236,6 +236,7 @@ interface DrawView [ ExecMethod = FuTemporary ; StateMethod = GetMenuState ; + ReadOnlyDoc = TRUE ; ] SID_ATTR_TRANSFORM_WIDTH // ole : no, status : ? diff --git a/svx/source/svdraw/svdedtv1.cxx b/svx/source/svdraw/svdedtv1.cxx index acf0b6885028..00034815fb7b 100644 --- a/svx/source/svdraw/svdedtv1.cxx +++ b/svx/source/svdraw/svdedtv1.cxx @@ -69,6 +69,7 @@ #include <sfx2/viewsh.hxx> #include <comphelper/lok.hxx> #include <osl/diagnose.h> +#include <sfx2/objsh.hxx> // EditView @@ -1825,7 +1826,15 @@ void SdrEditView::SetGeoAttrToMarked(const SfxItemSet& rAttr, bool addPageMargin } // change position - if (bChgPos && m_bMoveAllowed) { + bool bMoveAllowed = m_bMoveAllowed; + SfxViewShell* pViewShell = GetSfxViewShell(); + SfxObjectShell* pObjectShell = pViewShell ? pViewShell->GetObjectShell() : nullptr; + if (!bMoveAllowed && pObjectShell && pObjectShell->GetSignPDFCertificate().is()) + { + // If the just added signature line shape is selected, allow moving it. + bMoveAllowed = true; + } + if (bChgPos && bMoveAllowed) { MoveMarkedObj(Size(nPosDX,nPosDY)); } commit 6210a57d901b0981214105ce7b35bcd673716322 Author: Miklos Vajna <[email protected]> AuthorDate: Mon Jan 6 10:17:42 2025 +0100 Commit: Miklos Vajna <[email protected]> CommitDate: Tue Feb 11 13:50:16 2025 +0100 cool#10630 doc sign: fix Impress sign line, to be able to finish signing again Open a PDF for signing on the desktop, insert a signature line, click the "finish signing" button on the infobar, Draw first asks if you want to save your modified document as ODG, then crashes. The first problem is that opening a PDF for signing and adding a signature line / visual signature didn't result in a modified doc model, but that now happens since commit aca32a55456aa4e907b216fb490b3c15d26c3d55 (tdf#146547 sfx2: allow read-only documents to be modified, 2023-06-16). Probably we want to keep this feaature that read-only documents can be modified in some cases, so explicitly mark the PDF document as not-modified before signing in SfxObjectShell::SignDocumentContentUsingCertificate(). The other problem is that visual signing tried to reload the document: this is handy, as it shows if our PDF export worked correctly, but reloading is problematic since the signing code moved to async and it assumes that the underlying object shell is never deleted, so callbacks can have a pointer to it without worrying about the lifecycle. Fix this problem by not reloading, but clearing the marker on the signature shape and invalidating the signature status, instead of reloading, in SfxObjectShell::ExecFile_Impl(). With this, visual signing of an existing PDF file works again in desktop Draw. Change-Id: I743983947d4607aa06674a1329bc8efb5af8a6d9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179856 Tested-by: Jenkins Reviewed-by: Miklos Vajna <[email protected]> diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx index 7e6682c57bee..83e0fac51af8 100644 --- a/include/sfx2/objsh.hxx +++ b/include/sfx2/objsh.hxx @@ -815,6 +815,8 @@ public: /// Gets the certificate that is already picked by the user but not yet used for signing. css::uno::Reference<css::security::XCertificate> GetSignPDFCertificate() const; + void ResetSignPDFCertificate(); + /// Gets grab-bagged password info to unprotect change tracking with verification css::uno::Sequence< css::beans::PropertyValue > GetDocumentProtectionFromGrabBag() const; diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index 356ab50550db..dd289052e2af 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -430,27 +430,30 @@ bool SfxObjectShell::IsSignPDF() const return false; } -uno::Reference<security::XCertificate> SfxObjectShell::GetSignPDFCertificate() const +namespace +{ +uno::Reference<beans::XPropertySet> GetSelectedShapeOfModel(const uno::Reference<frame::XModel>& xModel) { - uno::Reference<frame::XModel> xModel = GetBaseModel(); if (!xModel.is()) { - return uno::Reference<security::XCertificate>(); + return uno::Reference<beans::XPropertySet>(); } uno::Reference<drawing::XShapes> xShapes(xModel->getCurrentSelection(), uno::UNO_QUERY); if (!xShapes.is() || xShapes->getCount() < 1) { - return uno::Reference<security::XCertificate>(); + return uno::Reference<beans::XPropertySet>(); } uno::Reference<beans::XPropertySet> xShapeProps(xShapes->getByIndex(0), uno::UNO_QUERY); - if (!xShapeProps.is()) - { - return uno::Reference<security::XCertificate>(); - } + return xShapeProps; +} +} - if (!xShapeProps->getPropertySetInfo()->hasPropertyByName(u"InteropGrabBag"_ustr)) +uno::Reference<security::XCertificate> SfxObjectShell::GetSignPDFCertificate() const +{ + uno::Reference<beans::XPropertySet> xShapeProps = GetSelectedShapeOfModel(GetBaseModel()); + if (!xShapeProps.is() || !xShapeProps->getPropertySetInfo()->hasPropertyByName(u"InteropGrabBag"_ustr)) { return uno::Reference<security::XCertificate>(); } @@ -465,6 +468,27 @@ uno::Reference<security::XCertificate> SfxObjectShell::GetSignPDFCertificate() c return uno::Reference<security::XCertificate>(it->second, uno::UNO_QUERY); } +void SfxObjectShell::ResetSignPDFCertificate() +{ + uno::Reference<beans::XPropertySet> xShapeProps = GetSelectedShapeOfModel(GetBaseModel()); + if (!xShapeProps->getPropertySetInfo()->hasPropertyByName("InteropGrabBag")) + { + return; + } + + comphelper::SequenceAsHashMap aMap(xShapeProps->getPropertyValue("InteropGrabBag")); + auto it = aMap.find("SignatureCertificate"); + if (it == aMap.end()) + { + return; + } + + aMap.erase(it); + xShapeProps->setPropertyValue("InteropGrabBag", uno::Any(aMap.getAsConstPropertyValueList())); + // The shape's property is now reset, so the doc model is no longer modified. + SetModified(false); +} + static void sendErrorToLOK(const ErrCodeMsg& error) { if (error.GetCode().GetClass() == ErrCodeClass::NONE) @@ -585,26 +609,15 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) aSigningContext.m_xCertificate = std::move(xCertificate); bHaveWeSigned |= SignDocumentContentUsingCertificate(aSigningContext); - // Reload to show how the PDF actually looks like after signing. This also - // changes "finish signing" on the infobar back to "sign document" as a side - // effect. + // Reset the picked certificate for PDF signing, then recheck signatures to show how + // the PDF actually looks like after signing. Also change the "finish signing" on + // the infobar back to "sign document". if (SfxViewFrame* pFrame = GetFrame()) { - // Store current page before reload. - SfxAllItemSet aSet(SfxGetpApp()->GetPool()); - uno::Reference<drawing::XDrawView> xController( - GetBaseModel()->getCurrentController(), uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xPage(xController->getCurrentPage(), - uno::UNO_QUERY); - sal_Int32 nPage{}; - xPage->getPropertyValue(u"Number"_ustr) >>= nPage; - if (nPage > 0) - { - // nPage is 1-based. - aSet.Put(SfxInt32Item(SID_PAGE_NUMBER, nPage - 1)); - } - SfxRequest aReq(SID_RELOAD, SfxCallMode::SLOT, aSet); - pFrame->ExecReload_Impl(aReq); + ResetSignPDFCertificate(); + RecheckSignature(false); + pFrame->RemoveInfoBar(u"readonly"); + pFrame->AppendReadOnlyInfobar(); } } else @@ -2249,6 +2262,13 @@ bool SfxObjectShell::SignDocumentContentUsingCertificate(svl::crypto::SigningCon // the document is not new and is not modified OUString aODFVersion(comphelper::OStorageHelper::GetODFVersionFromStorage(GetStorage())); + if (IsModified() && IsSignPDF()) + { + // When signing a PDF, then adding/resizing/moving the signature line would nominally modify + // the document, but ignore that for signing. + SetModified(false); + } + if (IsModified() || !GetMedium() || GetMedium()->GetName().isEmpty() || (GetMedium()->GetFilter()->IsOwnFormat() && aODFVersion.compareTo(ODFVER_012_TEXT) < 0 && !bHasSign)) { commit 8ed16bf8fc730eafc8ab2ff17d45091b8aeb9919 Author: Miklos Vajna <[email protected]> AuthorDate: Fri Jan 3 13:44:59 2025 +0100 Commit: Miklos Vajna <[email protected]> CommitDate: Tue Feb 11 13:50:16 2025 +0100 cool#10630 lok doc sign: fix Impress sign line when picking a certificate Once .uno:InsertSignatureLine gets dispatched, a visual signature placeholder gets inserted, then a certificate picker shows up, but no certificates are visible in the list. The first problem is that .uno:InsertSignatureLine needs to take sign key/cert parameters in DrawViewShell::FuPermanent() (similar to .uno:Signature), so it can learn what certificate to use for signing. The second problem is that once that sign cert is attached to the view, the cert chooser for signature lines were not taking the sign cert from the view in DocumentDigitalSignatures::chooseCertificatesImpl() -- this needs routing the info about the current view from sd/ (where we still have that info) to xmlsecurity/. With this, a LOK client dispatching .uno:InsertSignatureLine with the 2 new parameters set can insert a signature line, it'll show up, but the subsequent .uno:Signature dispatch still needs fixing up. (Currently it wants to "save" the modified PDF, while it should just sign.) Change-Id: Ie536842152ef097aa6959c67916f2beb6d356e4a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179819 Tested-by: Jenkins Reviewed-by: Miklos Vajna <[email protected]> diff --git a/cui/source/dialogs/SignSignatureLineDialog.cxx b/cui/source/dialogs/SignSignatureLineDialog.cxx index a58e9298054d..a1cf837c107c 100644 --- a/cui/source/dialogs/SignSignatureLineDialog.cxx +++ b/cui/source/dialogs/SignSignatureLineDialog.cxx @@ -158,7 +158,7 @@ IMPL_LINK_NOARG(SignSignatureLineDialog, chooseCertificate, weld::Button&, void) return; Reference<XCertificate> xSignCertificate - = svx::SignatureLineHelper::getSignatureCertificate(pShell, m_xDialog.get()); + = svx::SignatureLineHelper::getSignatureCertificate(pShell, nullptr, m_xDialog.get()); if (xSignCertificate.is()) { diff --git a/include/sfx2/digitalsignatures.hxx b/include/sfx2/digitalsignatures.hxx index fe5f2bc97874..7778f5e1fb89 100644 --- a/include/sfx2/digitalsignatures.hxx +++ b/include/sfx2/digitalsignatures.hxx @@ -15,6 +15,7 @@ #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/io/XStream.hpp> #include <com/sun/star/security/XCertificate.hpp> +#include <com/sun/star/security/CertificateKind.hpp> #include <sal/types.h> @@ -56,6 +57,13 @@ public: SetSignScriptingContent(const css::uno::Reference<css::io::XStream>& xScriptingSignStream) = 0; + /// View-aware replacement for selectSigningCertificateWithType(). + virtual css::uno::Reference<css::security::XCertificate> + SelectSigningCertificateWithType(SfxViewShell* pViewShell, + const css::security::CertificateKind certificateKind, + OUString& rDescription) + = 0; + protected: ~DigitalSignatures() noexcept = default; }; diff --git a/include/svx/signaturelinehelper.hxx b/include/svx/signaturelinehelper.hxx index 9a10a09a29ce..e8105a37bd7f 100644 --- a/include/svx/signaturelinehelper.hxx +++ b/include/svx/signaturelinehelper.hxx @@ -26,6 +26,7 @@ class Window; } class SdrView; class SfxObjectShell; +class SfxViewShell; namespace svx::SignatureLineHelper { @@ -39,7 +40,7 @@ SVX_DLLPUBLIC OUString getSignatureImage(const OUString& rType = OUString()); * Choose a signature for signature line purposes. */ SVX_DLLPUBLIC css::uno::Reference<css::security::XCertificate> -getSignatureCertificate(SfxObjectShell* pShell, weld::Window* pParent); +getSignatureCertificate(SfxObjectShell* pShell, SfxViewShell* pViewShell, weld::Window* pParent); /** * Get a signer name out of a certificate. diff --git a/sd/source/ui/func/fuconrec.cxx b/sd/source/ui/func/fuconrec.cxx index 45abc8058d82..5cbdb1e82596 100644 --- a/sd/source/ui/func/fuconrec.cxx +++ b/sd/source/ui/func/fuconrec.cxx @@ -514,6 +514,7 @@ void FuConstructRectangle::Deactivate() uno::Reference<security::XCertificate> xCertificate = svx::SignatureLineHelper::getSignatureCertificate(mpViewShell->GetObjectShell(), + mpViewShell->GetViewShell(), mpViewShell->GetFrameWeld()); if (!xCertificate.is()) { diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx index 9a7c8df31f7a..ea2f65a01c00 100644 --- a/sd/source/ui/view/drviewse.cxx +++ b/sd/source/ui/view/drviewse.cxx @@ -98,6 +98,7 @@ #include <basegfx/utils/zoomtools.hxx> #include <officecfg/Office/Draw.hxx> #include <officecfg/Office/Impress.hxx> +#include <sfx2/lokhelper.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -455,6 +456,36 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq) case SID_CONNECTOR_LINES_CIRCLES: case SID_INSERT_SIGNATURELINE: { + if (nSId == SID_INSERT_SIGNATURELINE) + { + // See if a signing cert is passed as a parameter: if so, parse that. + std::string aSignatureCert; + std::string aSignatureKey; + const SfxStringItem* pSignatureCert = rReq.GetArg<SfxStringItem>(FN_PARAM_1); + if (pSignatureCert) + { + aSignatureCert = pSignatureCert->GetValue().toUtf8(); + } + const SfxStringItem* pSignatureKey = rReq.GetArg<SfxStringItem>(FN_PARAM_2); + if (pSignatureKey) + { + aSignatureKey = pSignatureKey->GetValue().toUtf8(); + } + + SfxViewFrame* pFrame = GetFrame(); + SfxViewShell* pViewShell = pFrame ? pFrame->GetViewShell() : nullptr; + if (pViewShell) + { + uno::Reference<security::XCertificate> xSigningCertificate; + if (!aSignatureCert.empty() && !aSignatureKey.empty()) + { + xSigningCertificate = SfxLokHelper::getSigningCertificate(aSignatureCert, aSignatureKey); + } + // Always set the signing certificate, to clear data from a previous dispatch. + pViewShell->SetSigningCertificate(xSigningCertificate); + } + } + bCreateDirectly = comphelper::LibreOfficeKit::isActive(); bRectangle = true; SetCurrentFunction( FuConstructRectangle::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq, bPermanent ) ); diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi index e1e00a4b80b2..e62ad2ef9655 100644 --- a/svx/sdi/svx.sdi +++ b/svx/sdi/svx.sdi @@ -12416,7 +12416,7 @@ SfxVoidItem AnchorMenu SID_ANCHOR_MENU ] SfxVoidItem InsertSignatureLine SID_INSERT_SIGNATURELINE -() +(SfxStringItem SignatureCert FN_PARAM_1, SfxStringItem SignatureKey FN_PARAM_2) [ AutoUpdate = FALSE, FastCall = FALSE, diff --git a/svx/source/dialog/signaturelinehelper.cxx b/svx/source/dialog/signaturelinehelper.cxx index 52fb02c80e87..e079d62d5631 100644 --- a/svx/source/dialog/signaturelinehelper.cxx +++ b/svx/source/dialog/signaturelinehelper.cxx @@ -33,6 +33,7 @@ #include <unotools/streamwrap.hxx> #include <unotools/syslocale.hxx> #include <vcl/weld.hxx> +#include <sfx2/digitalsignatures.hxx> using namespace com::sun::star; @@ -57,8 +58,8 @@ OUString getSignatureImage(const OUString& rType) return OUString::fromUtf8(svg); } -uno::Reference<security::XCertificate> getSignatureCertificate(SfxObjectShell* pShell, - weld::Window* pParent) +uno::Reference<security::XCertificate> +getSignatureCertificate(SfxObjectShell* pShell, SfxViewShell* pViewShell, weld::Window* pParent) { if (!pShell) { @@ -91,8 +92,10 @@ uno::Reference<security::XCertificate> getSignatureCertificate(SfxObjectShell* p { certificateKind = security::CertificateKind_X509; } + auto xModelSigner = dynamic_cast<sfx2::DigitalSignatures*>(xSigner.get()); + assert(xModelSigner); uno::Reference<security::XCertificate> xSignCertificate - = xSigner->selectSigningCertificateWithType(certificateKind, aDescription); + = xModelSigner->SelectSigningCertificateWithType(pViewShell, certificateKind, aDescription); return xSignCertificate; } diff --git a/xmlsecurity/source/component/documentdigitalsignatures.cxx b/xmlsecurity/source/component/documentdigitalsignatures.cxx index 541748fc7c73..6d8291c7bf83 100644 --- a/xmlsecurity/source/component/documentdigitalsignatures.cxx +++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx @@ -99,7 +99,7 @@ private: DocumentSignatureMode eMode); css::uno::Sequence<css::uno::Reference<css::security::XCertificate>> - chooseCertificatesImpl(std::map<OUString, OUString>& rProperties, const CertificateChooserUserAction eAction, + chooseCertificatesImpl(SfxViewShell* pViewShell, std::map<OUString, OUString>& rProperties, const CertificateChooserUserAction eAction, const CertificateKind certificateKind=CertificateKind_NONE); bool @@ -207,6 +207,12 @@ public: /// See sfx2::DigitalSignatures::SetSignScriptingContent(). void SetSignScriptingContent( const css::uno::Reference<css::io::XStream>& xScriptingSignStream) override; + + /// See sfx2::DigitalSignatures::SelectSigningCertificateWithType(). + css::uno::Reference<css::security::XCertificate> + SelectSigningCertificateWithType(SfxViewShell* pViewShell, + const css::security::CertificateKind certificateKind, + OUString& rDescription) override; }; } @@ -639,7 +645,8 @@ sal_Bool DocumentDigitalSignatures::isAuthorTrusted( } uno::Sequence<Reference<css::security::XCertificate>> -DocumentDigitalSignatures::chooseCertificatesImpl(std::map<OUString, OUString>& rProperties, +DocumentDigitalSignatures::chooseCertificatesImpl(SfxViewShell* pViewShell, + std::map<OUString, OUString>& rProperties, const CertificateChooserUserAction eAction, const CertificateKind certificateKind) { @@ -654,7 +661,7 @@ DocumentDigitalSignatures::chooseCertificatesImpl(std::map<OUString, OUString>& xSecContexts.push_back(aSignatureManager.getGpgSecurityContext()); } - std::shared_ptr<CertificateChooser> aChooser = CertificateChooser::getInstance(Application::GetFrameWeld(mxParentWindow), nullptr, std::move(xSecContexts), eAction); + std::shared_ptr<CertificateChooser> aChooser = CertificateChooser::getInstance(Application::GetFrameWeld(mxParentWindow), pViewShell, std::move(xSecContexts), eAction); if (aChooser->run() != RET_OK) return { Reference< css::security::XCertificate >(nullptr) }; @@ -674,7 +681,7 @@ Reference< css::security::XCertificate > DocumentDigitalSignatures::chooseCertif Reference< css::security::XCertificate > DocumentDigitalSignatures::chooseSigningCertificate(OUString& rDescription) { std::map<OUString, OUString> aProperties; - Reference< css::security::XCertificate > xCert = chooseCertificatesImpl( aProperties, CertificateChooserUserAction::Sign )[0]; + Reference< css::security::XCertificate > xCert = chooseCertificatesImpl( nullptr, aProperties, CertificateChooserUserAction::Sign )[0]; rDescription = aProperties[u"Description"_ustr]; return xCert; } @@ -682,7 +689,7 @@ Reference< css::security::XCertificate > DocumentDigitalSignatures::chooseSignin Reference< css::security::XCertificate > DocumentDigitalSignatures::selectSigningCertificate(OUString& rDescription) { std::map<OUString, OUString> aProperties; - Reference< css::security::XCertificate > xCert = chooseCertificatesImpl( aProperties, CertificateChooserUserAction::SelectSign )[0]; + Reference< css::security::XCertificate > xCert = chooseCertificatesImpl( nullptr, aProperties, CertificateChooserUserAction::SelectSign )[0]; rDescription = aProperties[u"Description"_ustr]; return xCert; } @@ -690,10 +697,16 @@ Reference< css::security::XCertificate > DocumentDigitalSignatures::selectSignin Reference<css::security::XCertificate> DocumentDigitalSignatures::selectSigningCertificateWithType(const CertificateKind certificateKind, OUString& rDescription) +{ + return SelectSigningCertificateWithType(nullptr, certificateKind, rDescription); +} + +Reference<css::security::XCertificate> +DocumentDigitalSignatures::SelectSigningCertificateWithType(SfxViewShell* pViewShell, const CertificateKind certificateKind, OUString& rDescription) { std::map<OUString, OUString> aProperties; Reference<css::security::XCertificate> xCert - = chooseCertificatesImpl(aProperties, CertificateChooserUserAction::SelectSign, certificateKind)[0]; + = chooseCertificatesImpl(pViewShell, aProperties, CertificateChooserUserAction::SelectSign, certificateKind)[0]; rDescription = aProperties[u"Description"_ustr]; return xCert; } @@ -703,7 +716,7 @@ DocumentDigitalSignatures::chooseEncryptionCertificate(const CertificateKind cer { std::map<OUString, OUString> aProperties; uno::Sequence< Reference< css::security::XCertificate > > aCerts= - chooseCertificatesImpl( aProperties, CertificateChooserUserAction::Encrypt , certificateKind ); + chooseCertificatesImpl( nullptr, aProperties, CertificateChooserUserAction::Encrypt , certificateKind ); if (aCerts.getLength() == 1 && !aCerts[0].is()) // our error case contract is: empty sequence, so map that! return uno::Sequence< Reference< css::security::XCertificate > >(); @@ -714,7 +727,7 @@ DocumentDigitalSignatures::chooseEncryptionCertificate(const CertificateKind cer css::uno::Reference< css::security::XCertificate > DocumentDigitalSignatures::chooseCertificateWithProps(Sequence<css::beans::PropertyValue>& rProperties) { std::map<OUString, OUString> aProperties; - auto xCert = chooseCertificatesImpl( aProperties, CertificateChooserUserAction::Sign )[0]; + auto xCert = chooseCertificatesImpl( nullptr, aProperties, CertificateChooserUserAction::Sign )[0]; std::vector<css::beans::PropertyValue> vec; vec.reserve(aProperties.size()); commit 8ac88a346b9a09f68f5eca8cef371dca97c5af40 Author: Miklos Vajna <[email protected]> AuthorDate: Thu Dec 19 08:53:09 2024 +0100 Commit: Miklos Vajna <[email protected]> CommitDate: Tue Feb 11 13:50:16 2025 +0100 cool#10630 lok doc sign: fix Impress sign line when creating directly Once .uno:InsertSignatureLine gets dispatched, FuConstructRectangle gets activated, the signature line (a graphic shape) gets inserted, but then FuConstructRectangle is not deactivated in the "create directly" case, so next clicks keep inserting new signature lines, while the expectation is that "create directly" inserts one shape and selects it. The "create directly" mode is the default for LOK, but you can trigger it on the desktop with the KeyModifier=8192 (KEY_MOD1, i.e. Ctrl) UNO command parameter, too. The normal mode would send the mouse button down/up events to FuConstructRectangle and sd::FuConstructRectangle::MouseButtonUp() would select the shape after a drag to determine the position/size. The "create directly" mode will insert instantly, so sd::FuConstructRectangle::MouseButtonUp() is not called, so the shape is not selected, so the shape insert mode is not deactivated. Fix this by selecting the object for the create direct mode the same say as FuConstructRectangle would do, at the place where e.g. text editing is started for Impress textboxes. Do this for rectangle shapes for now, but later other shapes might want to do the same: e.g. curve insert doesn't have this problem, but it seems line insert has the same problem -- that's not changed here. Change-Id: I3ae85a07010f95b80a862e0cc631994113613eda Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178865 Tested-by: Jenkins Reviewed-by: Miklos Vajna <[email protected]> diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx index 2b354a104556..9a7c8df31f7a 100644 --- a/sd/source/ui/view/drviewse.cxx +++ b/sd/source/ui/view/drviewse.cxx @@ -228,6 +228,7 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq) // for LibreOfficeKit - choosing a shape should construct it directly bool bCreateDirectly = false; + bool bRectangle = false; switch ( nSId ) { @@ -455,6 +456,7 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq) case SID_INSERT_SIGNATURELINE: { bCreateDirectly = comphelper::LibreOfficeKit::isActive(); + bRectangle = true; SetCurrentFunction( FuConstructRectangle::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq, bPermanent ) ); rReq.Done(); } @@ -674,6 +676,11 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq) break; } } + + if (bRectangle && !bPermanent) + { + GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SfxCallMode::ASYNCHRON); + } } void DrawViewShell::FuDeleteSelectedObjects()
