summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2018-10-24 10:52:09 +0200
committerTomaž Vajngerl <quikee@gmail.com>2018-10-31 08:30:47 +0100
commit15018316bca863c9d7329572af906850d47e0c63 (patch)
treeee7e27ccf07995f157474e430f693f4560df8a55 /desktop
parentcdb750653e680c4c30239423ed201ed7a03eda8b (diff)
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@gmail.com>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/lib/init.cxx27
1 files changed, 16 insertions, 11 deletions
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)