diff options
author | Michael Stahl <Michael.Stahl@cib.de> | 2020-04-28 16:53:57 +0200 |
---|---|---|
committer | Michael Stahl <michael.stahl@cib.de> | 2020-05-15 17:56:23 +0200 |
commit | e125c6c6693d4540ab3aacb11151e05b511b8051 (patch) | |
tree | a81d88af3559f2c8da57a49bdee4ff6dfd2ba627 | |
parent | bb6af185cb7a88dfc73ad067d928625f0a2ed590 (diff) |
replace hard-coded "1.2" ODF version strings
Most of these are calls to
DocumentDigitalSignatures::createWithVersion(), where it doesn't make a
difference if "1.2" or "1.3" is passed in but maybe it will be different
with "1.4".
There is another ctor createDefault() which looks appropriate for
non-ODF contexts and can also be used when no actual signing or
verifying is done.
In cases where there's an actual document its Storage has the version.
Change-Id: Id636bbf965d9f96c7ed5f50774c509032525b2b1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93091
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@cib.de>
-rw-r--r-- | comphelper/source/misc/storagehelper.cxx | 5 | ||||
-rw-r--r-- | cui/source/dialogs/SignSignatureLineDialog.cxx | 16 | ||||
-rw-r--r-- | filter/source/pdf/impdialog.cxx | 4 | ||||
-rw-r--r-- | oox/source/vml/vmlshape.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/edit/edfcol.cxx | 5 | ||||
-rw-r--r-- | xmloff/source/draw/SignatureLineContext.cxx | 9 | ||||
-rw-r--r-- | xmloff/source/text/txtparai.cxx | 2 | ||||
-rw-r--r-- | xmlsecurity/qa/unit/signing/signing.cxx | 4 |
8 files changed, 32 insertions, 17 deletions
diff --git a/comphelper/source/misc/storagehelper.cxx b/comphelper/source/misc/storagehelper.cxx index 4c9d55b68251..e01e49b654b8 100644 --- a/comphelper/source/misc/storagehelper.cxx +++ b/comphelper/source/misc/storagehelper.cxx @@ -469,8 +469,9 @@ uno::Sequence< beans::NamedValue > OStorageHelper::CreateGpgPackageEncryptionDat uno::Sequence< beans::NamedValue > aEncryptionData(1); uno::Reference< security::XDocumentDigitalSignatures > xSigner( - security::DocumentDigitalSignatures::createWithVersion( - comphelper::getProcessComponentContext(), "1.2" ) ); + // here none of the version-dependent methods are called + security::DocumentDigitalSignatures::createDefault( + comphelper::getProcessComponentContext())); // fire up certificate chooser dialog - user can multi-select! uno::Sequence< uno::Reference< security::XCertificate > > xSignCertificates= diff --git a/cui/source/dialogs/SignSignatureLineDialog.cxx b/cui/source/dialogs/SignSignatureLineDialog.cxx index 9def0559183f..10f80f72983d 100644 --- a/cui/source/dialogs/SignSignatureLineDialog.cxx +++ b/cui/source/dialogs/SignSignatureLineDialog.cxx @@ -18,6 +18,7 @@ #include <comphelper/graphicmimetype.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/xmlsechelper.hxx> +#include <comphelper/storagehelper.hxx> #include <sfx2/docfile.hxx> #include <sfx2/docfilt.hxx> #include <sfx2/objsh.hxx> @@ -166,8 +167,19 @@ IMPL_LINK_NOARG(SignSignatureLineDialog, chooseCertificate, weld::Button&, void) if (!pShell->PrepareForSigning(m_xDialog.get())) return; - Reference<XDocumentDigitalSignatures> xSigner(DocumentDigitalSignatures::createWithVersion( - comphelper::getProcessComponentContext(), "1.2")); + Reference<XDocumentDigitalSignatures> xSigner; + if (pShell->GetMedium()->GetFilter()->IsAlienFormat()) + { + xSigner + = DocumentDigitalSignatures::createDefault(comphelper::getProcessComponentContext()); + } + else + { + OUString const aODFVersion( + comphelper::OStorageHelper::GetODFVersionFromStorage(pShell->GetStorage())); + xSigner = DocumentDigitalSignatures::createWithVersion( + comphelper::getProcessComponentContext(), aODFVersion); + } xSigner->setParentWindow(m_xDialog->GetXWindow()); OUString aDescription; CertificateKind certificateKind = CertificateKind_NONE; diff --git a/filter/source/pdf/impdialog.cxx b/filter/source/pdf/impdialog.cxx index 954e7d3a8c03..4d9e7a28b8ec 100644 --- a/filter/source/pdf/impdialog.cxx +++ b/filter/source/pdf/impdialog.cxx @@ -1527,8 +1527,8 @@ ImpPDFTabSigningPage::~ImpPDFTabSigningPage() IMPL_LINK_NOARG(ImpPDFTabSigningPage, ClickmaPbSignCertSelect, weld::Button&, void) { Reference< security::XDocumentDigitalSignatures > xSigner( - security::DocumentDigitalSignatures::createWithVersion( - comphelper::getProcessComponentContext(), "1.2" ) ); + security::DocumentDigitalSignatures::createDefault( + comphelper::getProcessComponentContext())); xSigner->setParentWindow(GetFrameWeld()->GetXWindow()); // The use may provide a description while choosing a certificate. diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index 7da04739c8e1..a6687ab65100 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -1247,8 +1247,8 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes { // Get the document signatures Reference<security::XDocumentDigitalSignatures> xSignatures( - security::DocumentDigitalSignatures::createWithVersion( - comphelper::getProcessComponentContext(), "1.2")); + security::DocumentDigitalSignatures::createDefault( + comphelper::getProcessComponentContext())); uno::Reference<embed::XStorage> xStorage = comphelper::OStorageHelper::GetStorageOfFormatFromURL( diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx index 6ecde0f71c77..d0154b4886ef 100644 --- a/sw/source/core/edit/edfcol.cxx +++ b/sw/source/core/edit/edfcol.cxx @@ -1764,8 +1764,9 @@ void SwEditShell::SignParagraph() // 2. Get certificate. uno::Reference<security::XDocumentDigitalSignatures> xSigner( - security::DocumentDigitalSignatures::createWithVersion( - comphelper::getProcessComponentContext(), "1.2" ) ); + // here none of the version-dependent methods are called + security::DocumentDigitalSignatures::createDefault( + comphelper::getProcessComponentContext())); uno::Sequence<css::beans::PropertyValue> aProperties; uno::Reference<security::XCertificate> xCertificate = xSigner->chooseCertificateWithProps(aProperties); diff --git a/xmloff/source/draw/SignatureLineContext.cxx b/xmloff/source/draw/SignatureLineContext.cxx index 10c2440fd022..497bd8489c70 100644 --- a/xmloff/source/draw/SignatureLineContext.cxx +++ b/xmloff/source/draw/SignatureLineContext.cxx @@ -72,10 +72,6 @@ SignatureLineContext::SignatureLineContext(SvXMLImport& rImport, sal_uInt16 nPrf try { // Get the document signatures - Reference<XDocumentDigitalSignatures> xSignatures( - security::DocumentDigitalSignatures::createWithVersion( - comphelper::getProcessComponentContext(), "1.2")); - css::uno::Reference<XStorable> xStorable(GetImport().GetModel(), UNO_QUERY_THROW); Reference<XStorage> xStorage = comphelper::OStorageHelper::GetStorageOfFormatFromURL( ZIP_STORAGE_FORMAT_STRING, xStorable->getLocation(), ElementModes::READ); @@ -86,6 +82,11 @@ SignatureLineContext::SignatureLineContext(SvXMLImport& rImport, sal_uInt16 nPrf return; } + OUString const aODFVersion(comphelper::OStorageHelper::GetODFVersionFromStorage(xStorage)); + Reference<XDocumentDigitalSignatures> xSignatures( + security::DocumentDigitalSignatures::createWithVersion( + comphelper::getProcessComponentContext(), aODFVersion)); + Sequence<DocumentSignatureInformation> xSignatureInfo = xSignatures->verifyDocumentContentSignatures(xStorage, Reference<XInputStream>()); diff --git a/xmloff/source/text/txtparai.cxx b/xmloff/source/text/txtparai.cxx index 5e05107684cc..dc59304fb368 100644 --- a/xmloff/source/text/txtparai.cxx +++ b/xmloff/source/text/txtparai.cxx @@ -2337,7 +2337,7 @@ XMLNumberedParaContext::XMLNumberedParaContext( i_rImport.GetTextImport()->GetTextListHelper() ); if (m_ListId.isEmpty()) { - SAL_WARN_IF( i_rImport.GetODFVersion() == "1.2", "xmloff.text", "invalid numbered-paragraph: no list-id (1.2)" ); + SAL_WARN_IF(0 <= i_rImport.GetODFVersion().compareTo("1.2"), "xmloff.text", "invalid numbered-paragraph: no list-id (1.2)"); m_ListId = rTextListsHelper.GetNumberedParagraphListId(m_Level, StyleName); SAL_WARN_IF(m_ListId.isEmpty(), "xmloff.text", "numbered-paragraph: no ListId"); diff --git a/xmlsecurity/qa/unit/signing/signing.cxx b/xmlsecurity/qa/unit/signing/signing.cxx index 4720ee340f7e..fb2c91fc3f42 100644 --- a/xmlsecurity/qa/unit/signing/signing.cxx +++ b/xmlsecurity/qa/unit/signing/signing.cxx @@ -845,8 +845,8 @@ CPPUNIT_TEST_FIXTURE(SigningTest, testSignatureLineOOXML) { // Given: A document (docx) with a signature line and a valid signature uno::Reference<security::XDocumentDigitalSignatures> xSignatures( - security::DocumentDigitalSignatures::createWithVersion( - comphelper::getProcessComponentContext(), "1.2")); + security::DocumentDigitalSignatures::createDefault( + comphelper::getProcessComponentContext())); uno::Reference<embed::XStorage> xStorage = comphelper::OStorageHelper::GetStorageOfFormatFromURL( |