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

New commits:
commit 15018316bca863c9d7329572af906850d47e0c63
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Wed Oct 24 10:52:09 2018 +0200
Commit:     Tomaž Vajngerl <qui...@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 <qui...@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)
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to