summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
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)