[Libreoffice-commits] core.git: desktop/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Oct 31 07:31:13 UTC 2018


 desktop/source/lib/init.cxx |   27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

New commits:
commit 15018316bca863c9d7329572af906850d47e0c63
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Wed Oct 24 10:52:09 2018 +0200
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Wed Oct 31 08:30:47 2018 +0100

    lok: Get the object shell from the document
    
    Change-Id: Id62c0db3c9f404aaab70de0a73a20b2bb57b0393
    Reviewed-on: https://gerrit.libreoffice.org/62272
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index b08c6d694f4a..1119886763ce 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3604,13 +3604,27 @@ static void doc_postWindow(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindo
 }
 
 // CERTIFICATE AND DOCUMENT SIGNING
-static bool doc_insertCertificate(LibreOfficeKitDocument* /*pThis*/,
+static bool doc_insertCertificate(LibreOfficeKitDocument* pThis,
                                   const unsigned char* pCertificateBinary, const int nCertificateBinarySize,
                                   const unsigned char* pPrivateKeyBinary, const int nPrivateKeySize)
 {
     if (!xContext.is())
         return false;
 
+    LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
+
+    if (!pDocument->mxComponent.is())
+        return false;
+
+    SfxBaseModel* pBaseModel = dynamic_cast<SfxBaseModel*>(pDocument->mxComponent.get());
+    if (!pBaseModel)
+        return false;
+
+    SfxObjectShell* pObjectShell = pBaseModel->GetObjectShell();
+
+    if (!pObjectShell)
+        return false;
+
     uno::Reference<xml::crypto::XSEInitializer> xSEInitializer = xml::crypto::SEInitializer::create(xContext);
     uno::Reference<xml::crypto::XXMLSecurityContext> xSecurityContext;
     xSecurityContext = xSEInitializer->createSecurityContext(OUString());
@@ -3636,16 +3650,7 @@ static bool doc_insertCertificate(LibreOfficeKitDocument* /*pThis*/,
     if (!xCertificate.is())
         return false;
 
-    printf("CERTIFICATE\n\tIssuerName: %s \n\tSubjectName: %s\n\tPK %s\n\n",
-            xCertificate->getIssuerName().toUtf8().getStr(),
-            xCertificate->getSubjectName().toUtf8().getStr(),
-            xCertificate->getSubjectPublicKeyAlgorithm().toUtf8().getStr());
-
-    SfxObjectShell* pDoc = SfxObjectShell::Current();
-    if (!pDoc)
-        return false;
-
-    return pDoc->SignDocumentContentUsingCertificate(xCertificate);
+    return pObjectShell->SignDocumentContentUsingCertificate(xCertificate);
 }
 
 static int doc_getSignatureState(LibreOfficeKitDocument* pThis)


More information about the Libreoffice-commits mailing list