summaryrefslogtreecommitdiff
path: root/xmlsecurity
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-06-13 10:27:38 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-06-29 08:18:35 +0200
commit71112060e0930fc58087c3762e836b1e12b60f75 (patch)
tree3bd54aa5b5864d9cd31d0aa3ec4080b46cf66a2d /xmlsecurity
parentd6da9e495d7ca32de6cda1a94cb4c8cd26b240cc (diff)
loplugin:oncevar various
Change-Id: I8b82d46d4688b1a59d6fe1b05da7d5c8dfc13ca6 Reviewed-on: https://gerrit.libreoffice.org/38766 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmlsecurity')
-rw-r--r--xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx3
-rw-r--r--xmlsecurity/qa/unit/signing/signing.cxx3
-rw-r--r--xmlsecurity/source/component/documentdigitalsignatures.cxx9
-rw-r--r--xmlsecurity/source/helper/documentsignaturehelper.cxx12
-rw-r--r--xmlsecurity/source/helper/documentsignaturemanager.cxx5
-rw-r--r--xmlsecurity/source/helper/xmlsignaturehelper.cxx9
-rw-r--r--xmlsecurity/source/xmlsec/nss/nssinitializer.cxx3
7 files changed, 15 insertions, 29 deletions
diff --git a/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx b/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx
index 59ff206e2c28..89ba2751062d 100644
--- a/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx
+++ b/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx
@@ -425,8 +425,7 @@ void PDFSigningTest::testTokenize()
// Just make sure the tokenizer finishes without an error, don't look at the signature.
CPPUNIT_ASSERT(aDocument.Read(aStream));
- OUString aNoPages("tdf107149.pdf");
- if (aNoPages == rName)
+ if (OUString(rName) == "tdf107149.pdf")
// This failed, page list was empty.
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aDocument.GetPages().size());
}
diff --git a/xmlsecurity/qa/unit/signing/signing.cxx b/xmlsecurity/qa/unit/signing/signing.cxx
index 95fb711a3596..729670dab027 100644
--- a/xmlsecurity/qa/unit/signing/signing.cxx
+++ b/xmlsecurity/qa/unit/signing/signing.cxx
@@ -353,8 +353,7 @@ void SigningTest::testOOXMLRemoveAll()
CPPUNIT_ASSERT(!xNameAccess->hasByName("_xmlsignatures"));
// And that content types no longer contains signature types.
- sal_Int32 nOpenMode = embed::ElementModes::READWRITE;
- uno::Reference<io::XStream> xStream(xStorage->openStreamElement("[Content_Types].xml", nOpenMode), uno::UNO_QUERY);
+ uno::Reference<io::XStream> xStream(xStorage->openStreamElement("[Content_Types].xml", embed::ElementModes::READWRITE), uno::UNO_QUERY);
uno::Reference<io::XInputStream> xInputStream = xStream->getInputStream();
uno::Sequence< uno::Sequence<beans::StringPair> > aContentTypeInfo = comphelper::OFOPXMLHelper::ReadContentTypeSequence(xInputStream, mxComponentContext);
uno::Sequence<beans::StringPair>& rOverrides = aContentTypeInfo[1];
diff --git a/xmlsecurity/source/component/documentdigitalsignatures.cxx b/xmlsecurity/source/component/documentdigitalsignatures.cxx
index 518b4acb1c93..6cec7f5a9c8e 100644
--- a/xmlsecurity/source/component/documentdigitalsignatures.cxx
+++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx
@@ -400,8 +400,7 @@ void DocumentDigitalSignatures::manageTrustedSources( )
Reference< css::xml::crypto::XSecurityEnvironment > xSecEnv;
- DocumentSignatureMode eMode{};
- DocumentSignatureManager aSignatureManager(mxCtx, eMode);
+ DocumentSignatureManager aSignatureManager(mxCtx, {});
if (aSignatureManager.init())
xSecEnv = aSignatureManager.getSecurityEnvironment();
@@ -412,8 +411,7 @@ void DocumentDigitalSignatures::manageTrustedSources( )
void DocumentDigitalSignatures::showCertificate(
const Reference< css::security::XCertificate >& Certificate )
{
- DocumentSignatureMode eMode{};
- DocumentSignatureManager aSignatureManager(mxCtx, eMode);
+ DocumentSignatureManager aSignatureManager(mxCtx, {});
bool bInit = aSignatureManager.init();
@@ -454,8 +452,7 @@ Reference< css::security::XCertificate > DocumentDigitalSignatures::chooseCertif
{
std::vector< Reference< css::xml::crypto::XXMLSecurityContext > > xSecContexts;
- DocumentSignatureMode eMode{};
- DocumentSignatureManager aSignatureManager(mxCtx, eMode);
+ DocumentSignatureManager aSignatureManager(mxCtx, {});
if (aSignatureManager.init()) {
xSecContexts.push_back(aSignatureManager.getSecurityContext());
xSecContexts.push_back(aSignatureManager.getGpgSecurityContext());
diff --git a/xmlsecurity/source/helper/documentsignaturehelper.cxx b/xmlsecurity/source/helper/documentsignaturehelper.cxx
index fadf1a6309b2..1eecea496128 100644
--- a/xmlsecurity/source/helper/documentsignaturehelper.cxx
+++ b/xmlsecurity/source/helper/documentsignaturehelper.cxx
@@ -139,13 +139,12 @@ bool DocumentSignatureHelper::isODFPre_1_2(const OUString & sVersion)
bool DocumentSignatureHelper::isOOo3_2_Signature(const SignatureInformation & sigInfo)
{
- OUString sManifestURI("META-INF/manifest.xml");
bool bOOo3_2 = false;
typedef ::std::vector< SignatureReferenceInformation >::const_iterator CIT;
for (CIT i = sigInfo.vSignatureReferenceInfors.begin();
i < sigInfo.vSignatureReferenceInfors.end(); ++i)
{
- if (i->ouURI.equals(sManifestURI))
+ if (i->ouURI == "META-INF/manifest.xml")
{
bOOo3_2 = true;
break;
@@ -223,14 +222,13 @@ DocumentSignatureHelper::CreateElementList(
xSubStore.clear();
// Object folders...
- OUString aMatchStr( "Object " );
Reference < css::container::XNameAccess > xElements( rxStore, UNO_QUERY );
Sequence< OUString > aElementNames = xElements->getElementNames();
sal_Int32 nElements = aElementNames.getLength();
const OUString* pNames = aElementNames.getConstArray();
for ( sal_Int32 n = 0; n < nElements; n++ )
{
- if ( ( pNames[n].match( aMatchStr ) ) && rxStore->isStorageElement( pNames[n] ) )
+ if ( ( pNames[n].match( "Object " ) ) && rxStore->isStorageElement( pNames[n] ) )
{
Reference < css::embed::XStorage > xTmpSubStore = rxStore->openStorageElement( pNames[n], css::embed::ElementModes::READ );
ImplFillElementList(aElements, xTmpSubStore, pNames[n]+aSep, true, mode);
@@ -305,8 +303,7 @@ void DocumentSignatureHelper::AppendContentTypes(const uno::Reference<embed::XSt
// ODF
return;
- sal_Int32 nOpenMode = embed::ElementModes::READ;
- uno::Reference<io::XInputStream> xRelStream(xStorage->openStreamElement("[Content_Types].xml", nOpenMode), uno::UNO_QUERY);
+ uno::Reference<io::XInputStream> xRelStream(xStorage->openStreamElement("[Content_Types].xml", embed::ElementModes::READ), uno::UNO_QUERY);
uno::Sequence< uno::Sequence<beans::StringPair> > aContentTypeInfo = comphelper::OFOPXMLHelper::ReadContentTypeSequence(xRelStream, comphelper::getProcessComponentContext());
if (aContentTypeInfo.getLength() < 2)
{
@@ -362,8 +359,7 @@ SignatureStreamHelper DocumentSignatureHelper::OpenSignatureStream(
{
try
{
- OUString aSIGStoreName( "META-INF" );
- aHelper.xSignatureStorage = rxStore->openStorageElement( aSIGStoreName, nSubStorageOpenMode );
+ aHelper.xSignatureStorage = rxStore->openStorageElement( "META-INF", nSubStorageOpenMode );
if ( aHelper.xSignatureStorage.is() )
{
OUString aSIGStreamName;
diff --git a/xmlsecurity/source/helper/documentsignaturemanager.cxx b/xmlsecurity/source/helper/documentsignaturemanager.cxx
index 41f7e5594cf2..01bcbc0dab9f 100644
--- a/xmlsecurity/source/helper/documentsignaturemanager.cxx
+++ b/xmlsecurity/source/helper/documentsignaturemanager.cxx
@@ -162,12 +162,11 @@ bool DocumentSignatureManager::isXML(const OUString& rURI)
//Files can only be encrypted if they are in the manifest.xml.
//That is, the current file cannot be encrypted, otherwise bPropsAvailable
//would be true.
- OUString aXMLExt("XML");
sal_Int32 nSep = rURI.lastIndexOf('.');
- if (nSep != (-1))
+ if (nSep != -1)
{
OUString aExt = rURI.copy(nSep+1);
- if (aExt.equalsIgnoreAsciiCase(aXMLExt))
+ if (aExt.equalsIgnoreAsciiCase("XML"))
bIsXML = true;
}
}
diff --git a/xmlsecurity/source/helper/xmlsignaturehelper.cxx b/xmlsecurity/source/helper/xmlsignaturehelper.cxx
index 6242518ce4e1..b6078d373916 100644
--- a/xmlsecurity/source/helper/xmlsignaturehelper.cxx
+++ b/xmlsecurity/source/helper/xmlsignaturehelper.cxx
@@ -201,8 +201,7 @@ void XMLSignatureHelper::ExportSignature(
void XMLSignatureHelper::ExportOOXMLSignature(const uno::Reference<embed::XStorage>& xRootStorage, const uno::Reference<embed::XStorage>& xSignatureStorage, const SignatureInformation& rInformation, int nSignatureIndex)
{
- sal_Int32 nOpenMode = embed::ElementModes::READWRITE;
- uno::Reference<io::XOutputStream> xOutputStream(xSignatureStorage->openStreamElement("sig" + OUString::number(nSignatureIndex) + ".xml", nOpenMode), uno::UNO_QUERY);
+ uno::Reference<io::XOutputStream> xOutputStream(xSignatureStorage->openStreamElement("sig" + OUString::number(nSignatureIndex) + ".xml", embed::ElementModes::READWRITE), uno::UNO_QUERY);
if (rInformation.aSignatureBytes.hasElements())
// This is a signature roundtrip, just write back the signature as-is.
@@ -504,8 +503,7 @@ void XMLSignatureHelper::ExportSignatureRelations(const css::uno::Reference<css:
void XMLSignatureHelper::ExportSignatureContentTypes(const css::uno::Reference<css::embed::XStorage>& xStorage, int nSignatureCount)
{
- sal_Int32 nOpenMode = embed::ElementModes::READWRITE;
- uno::Reference<io::XStream> xStream(xStorage->openStreamElement("[Content_Types].xml", nOpenMode), uno::UNO_QUERY);
+ uno::Reference<io::XStream> xStream(xStorage->openStreamElement("[Content_Types].xml", embed::ElementModes::READWRITE), uno::UNO_QUERY);
uno::Reference<io::XInputStream> xInputStream = xStream->getInputStream();
uno::Sequence< uno::Sequence<beans::StringPair> > aContentTypeInfo = comphelper::OFOPXMLHelper::ReadContentTypeSequence(xInputStream, mxCtx);
if (aContentTypeInfo.getLength() < 2)
@@ -554,8 +552,7 @@ void XMLSignatureHelper::ExportSignatureContentTypes(const css::uno::Reference<c
}
bool XMLSignatureHelper::CreateAndWriteOOXMLSignature(const uno::Reference<embed::XStorage>& xRootStorage, const uno::Reference<embed::XStorage>& xSignatureStorage, int nSignatureIndex)
{
- sal_Int32 nOpenMode = embed::ElementModes::READWRITE;
- uno::Reference<io::XOutputStream> xOutputStream(xSignatureStorage->openStreamElement("sig" + OUString::number(nSignatureIndex) + ".xml", nOpenMode), uno::UNO_QUERY);
+ uno::Reference<io::XOutputStream> xOutputStream(xSignatureStorage->openStreamElement("sig" + OUString::number(nSignatureIndex) + ".xml", embed::ElementModes::READWRITE), uno::UNO_QUERY);
uno::Reference<xml::sax::XWriter> xSaxWriter = xml::sax::Writer::create(mxCtx);
xSaxWriter->setOutputStream(xOutputStream);
xSaxWriter->startDocument();
diff --git a/xmlsecurity/source/xmlsec/nss/nssinitializer.cxx b/xmlsecurity/source/xmlsec/nss/nssinitializer.cxx
index 44ed6971f65d..f4f5a7212373 100644
--- a/xmlsecurity/source/xmlsec/nss/nssinitializer.cxx
+++ b/xmlsecurity/source/xmlsec/nss/nssinitializer.cxx
@@ -186,7 +186,6 @@ OString getMozillaCurrentProfile( const css::uno::Reference< css::uno::XComponen
mozilla::MozillaProductType_Thunderbird,
mozilla::MozillaProductType_Firefox,
mozilla::MozillaProductType_Mozilla };
- int nProduct = SAL_N_ELEMENTS(productTypes);
uno::Reference<uno::XInterface> xInstance = rxContext->getServiceManager()->createInstanceWithContext("com.sun.star.mozilla.MozillaBootstrap", rxContext);
OSL_ENSURE( xInstance.is(), "failed to create instance" );
@@ -196,7 +195,7 @@ OString getMozillaCurrentProfile( const css::uno::Reference< css::uno::XComponen
if (xMozillaBootstrap.is())
{
- for (int i=0; i<nProduct; ++i)
+ for (int i=0; i<int(SAL_N_ELEMENTS(productTypes)); ++i)
{
OUString profile = xMozillaBootstrap->getDefaultProfile(productTypes[i]);