desktop/source/lib/init.cxx | 4 ++-- include/sfx2/viewsh.hxx | 3 +++ sfx2/source/view/viewimp.hxx | 1 + sfx2/source/view/viewsh.cxx | 10 ++++++++++ 4 files changed, 16 insertions(+), 2 deletions(-)
New commits: commit 4787fd4fc86230893a6da309f45964116b3a67df Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Tue Sep 24 09:35:24 2024 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Tue Sep 24 10:55:58 2024 +0200 cool#9992 lok doc sign: store signing cert in the view In case signing certificate would be stored in the model (like it happens on the desktop), then the certificate viewer would show all signing certs of the currently editing users, which is far from expected. At the same time, there is just one NSS database per process, so it's hard to not have them in the same database. Fix the problem by storing a reference to the signing key in the view shell, then we can show only that in xmlsecurity/ in LOK mode, and thing else. This is just the sfx2/ side of things, the xmlsecurity/ part still needs implementing. Change-Id: Id7a56f28598ec60217c6bac095c2ff350f39bc3b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173837 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 557336b088f4..a7cbbb271b48 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -4723,9 +4723,9 @@ static void doc_initializeForRendering(LibreOfficeKitDocument* pThis, if (!aSignatureCert.empty() && !aSignatureKey.empty()) { uno::Reference<security::XCertificate> xCertificate = SfxLokHelper::getSigningCertificate(aSignatureCert, aSignatureKey); - if (!xCertificate.is()) + if (SfxViewShell* pViewShell = SfxViewShell::Current()) { - SAL_WARN("lok", "doc_initializeForRendering: cert/key didn't result in an XCertificate"); + pViewShell->SetSigningCertificate(xCertificate); } } diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx index 71380213b9c9..a5157967fc07 100644 --- a/include/sfx2/viewsh.hxx +++ b/include/sfx2/viewsh.hxx @@ -73,6 +73,7 @@ namespace com::sun::star::frame { class XModel; } namespace com::sun::star::ui { class XContextMenuInterceptor; } namespace com::sun::star::ui { struct ContextMenuExecuteEvent; } namespace com::sun::star::view { class XRenderable; } +namespace com::sun::star::security { class XCertificate; } namespace tools { class Rectangle; } namespace svtools { enum ColorConfigEntry : int; } @@ -495,6 +496,8 @@ public: OUString getA11yFocusedParagraph() const; int getA11yCaretPosition() const; + void SetSigningCertificate(const css::uno::Reference<css::security::XCertificate>& xCertificate); + css::uno::Reference<css::security::XCertificate> GetSigningCertificate() const; }; #endif // INCLUDED_SFX2_VIEWSH_HXX diff --git a/sfx2/source/view/viewimp.hxx b/sfx2/source/view/viewimp.hxx index aa0394591069..1dc24eec7a82 100644 --- a/sfx2/source/view/viewimp.hxx +++ b/sfx2/source/view/viewimp.hxx @@ -59,6 +59,7 @@ struct SfxViewShell_Impl static sal_uInt32 m_nLastViewShellId; const ViewShellId m_nViewShellId; const ViewShellDocId m_nDocId; + css::uno::Reference<css::security::XCertificate> m_xSigningCertificate; explicit SfxViewShell_Impl(SfxViewShellFlags const nFlags, ViewShellDocId nDocId); ~SfxViewShell_Impl(); diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 0676ef9e98e0..09483712ccca 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -2807,6 +2807,16 @@ int SfxViewShell::getA11yCaretPosition() const return rDocFocusListener.getCaretPosition(); } +void SfxViewShell::SetSigningCertificate(const uno::Reference<security::XCertificate>& xCertificate) +{ + pImpl->m_xSigningCertificate = xCertificate; +} + +uno::Reference<security::XCertificate> SfxViewShell::GetSigningCertificate() const +{ + return pImpl->m_xSigningCertificate; +} + bool SfxViewShell::PrepareClose ( bool bUI // TRUE: Allow Dialog and so on, FALSE: silent-mode