From 1d1d0bd4d941c58306f3086cf3103b40ad0978ba Mon Sep 17 00:00:00 2001 From: Julien Nabet Date: Sun, 17 Oct 2021 11:59:18 +0200 Subject: Simplify Sequences in xmlsecurity Change-Id: I749e19f786ad006dffcd65dd1ee60e57c428f57b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123717 Tested-by: Jenkins Reviewed-by: Julien Nabet --- xmlsecurity/qa/unit/signing/signing.cxx | 9 +++------ .../source/component/documentdigitalsignatures.cxx | 7 ++----- xmlsecurity/source/helper/xsecsign.cxx | 19 ++++++++++--------- xmlsecurity/source/helper/xsecverify.cxx | 14 ++++++++------ 4 files changed, 23 insertions(+), 26 deletions(-) (limited to 'xmlsecurity') diff --git a/xmlsecurity/qa/unit/signing/signing.cxx b/xmlsecurity/qa/unit/signing/signing.cxx index aeb401328429..298ee6d38f38 100644 --- a/xmlsecurity/qa/unit/signing/signing.cxx +++ b/xmlsecurity/qa/unit/signing/signing.cxx @@ -1218,8 +1218,7 @@ CPPUNIT_TEST_FIXTURE(SigningTest, testPreserveMacroTemplateSignature12_ODF) // create new document from template mxComponent->dispose(); - mxComponent = mxDesktop->loadComponentFromURL(aURL, "_default", 0, - uno::Sequence(0)); + mxComponent = mxDesktop->loadComponentFromURL(aURL, "_default", 0, {}); CPPUNIT_ASSERT_MESSAGE(OUStringToOString(sLoadMessage, RTL_TEXTENCODING_UTF8).getStr(), mxComponent.is()); @@ -1316,8 +1315,7 @@ CPPUNIT_TEST_FIXTURE(SigningTest, testDropMacroTemplateSignature) // create new document from template mxComponent->dispose(); - mxComponent = mxDesktop->loadComponentFromURL(aURL, "_default", 0, - uno::Sequence(0)); + mxComponent = mxDesktop->loadComponentFromURL(aURL, "_default", 0, {}); CPPUNIT_ASSERT_MESSAGE(OUStringToOString(sLoadMessage, RTL_TEXTENCODING_UTF8).getStr(), mxComponent.is()); @@ -1410,8 +1408,7 @@ CPPUNIT_TEST_FIXTURE(SigningTest, testPreserveMacroTemplateSignature10) // create new document from template mxComponent->dispose(); - mxComponent = mxDesktop->loadComponentFromURL(aURL, "_default", 0, - uno::Sequence(0)); + mxComponent = mxDesktop->loadComponentFromURL(aURL, "_default", 0, {}); CPPUNIT_ASSERT_MESSAGE(OUStringToOString(sLoadMessage, RTL_TEXTENCODING_UTF8).getStr(), mxComponent.is()); diff --git a/xmlsecurity/source/component/documentdigitalsignatures.cxx b/xmlsecurity/source/component/documentdigitalsignatures.cxx index 686c49d91b63..50cbdf7184a0 100644 --- a/xmlsecurity/source/component/documentdigitalsignatures.cxx +++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx @@ -689,13 +689,10 @@ DocumentDigitalSignatures::chooseCertificatesImpl(std::map& CertificateChooser aChooser(Application::GetFrameWeld(mxParentWindow), std::move(xSecContexts), eAction); - uno::Sequence< Reference< css::security::XCertificate > > xCerts(1); - xCerts[0] = Reference< css::security::XCertificate >(nullptr); - if (aChooser.run() != RET_OK) - return xCerts; + return { Reference< css::security::XCertificate >(nullptr) }; - xCerts = aChooser.GetSelectedCertificates(); + uno::Sequence< Reference< css::security::XCertificate > > xCerts = aChooser.GetSelectedCertificates(); rProperties["Description"] = aChooser.GetDescription(); rProperties["Usage"] = aChooser.GetUsageText(); diff --git a/xmlsecurity/source/helper/xsecsign.cxx b/xmlsecurity/source/helper/xsecsign.cxx index 862375febc90..5b3eb6fa266b 100644 --- a/xmlsecurity/source/helper/xsecsign.cxx +++ b/xmlsecurity/source/helper/xsecsign.cxx @@ -67,15 +67,16 @@ css::uno::Reference< css::xml::crypto::sax::XReferenceResolvedListener > XSecCon rtl::Reference xSignatureCreator(new SignatureCreatorImpl); - css::uno::Sequence args(5); - args[0] <<= OUString::number(nSecurityId); - args[1] <<= uno::Reference(m_xSAXEventKeeper); - args[2] <<= OUString::number(nIdOfSignatureElementCollector); - - //for nss, the internal module is used for signing, which needs to be improved later - args[3] <<= m_xSecurityContext->getSecurityEnvironment(); - - args[4] <<= m_xXMLSignature; + css::uno::Sequence args + { + makeAny(OUString::number(nSecurityId)), + makeAny(uno::Reference(m_xSAXEventKeeper)), + makeAny(OUString::number(nIdOfSignatureElementCollector)), + + //for nss, the internal module is used for signing, which needs to be improved later + makeAny(m_xSecurityContext->getSecurityEnvironment()), + makeAny(m_xXMLSignature) + }; xSignatureCreator->initialize(args); sal_Int32 nBlockerId = m_xSAXEventKeeper->addBlocker(); diff --git a/xmlsecurity/source/helper/xsecverify.cxx b/xmlsecurity/source/helper/xsecverify.cxx index 82efa17eb807..cd0b11c626ab 100644 --- a/xmlsecurity/source/helper/xsecverify.cxx +++ b/xmlsecurity/source/helper/xsecverify.cxx @@ -72,12 +72,14 @@ css::uno::Reference< css::xml::crypto::sax::XReferenceResolvedListener > XSecCon css::uno::Reference xInitialization(xReferenceResolvedListener, css::uno::UNO_QUERY); - css::uno::Sequence args(5); - args[0] <<= OUString::number(nSecurityId); - args[1] <<= uno::Reference(m_xSAXEventKeeper); - args[2] <<= OUString::number(nIdOfSignatureElementCollector); - args[3] <<= m_xSecurityContext; - args[4] <<= m_xXMLSignature; + css::uno::Sequence args + { + makeAny(OUString::number(nSecurityId)), + makeAny(uno::Reference(m_xSAXEventKeeper)), + makeAny(OUString::number(nIdOfSignatureElementCollector)), + makeAny(m_xSecurityContext), + makeAny(m_xXMLSignature) + }; xInitialization->initialize(args); css::uno::Reference< css::xml::crypto::sax::XSignatureVerifyResultBroadcaster > -- cgit