summaryrefslogtreecommitdiff
path: root/xmlsecurity/source/helper
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-05-09 15:17:26 +0300
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-05-09 18:21:59 +0200
commitfac093e5e63bd53bae3de552fedba927bd5c4561 (patch)
tree7b921dc813a6d6e0df55ef6d15edabb76e52bd40 /xmlsecurity/source/helper
parent2479ab8b788ca000f2e979d0858de8d05de8e858 (diff)
Simplify Sequence iterations in xmlscript, xmlsecurity
Use range-based loops or replace with comphelper or STL functions Change-Id: I3d63811caf80c87a9d560087e1f0d933ebcc0d55 Reviewed-on: https://gerrit.libreoffice.org/72040 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmlsecurity/source/helper')
-rw-r--r--xmlsecurity/source/helper/documentsignaturehelper.cxx30
-rw-r--r--xmlsecurity/source/helper/documentsignaturemanager.cxx7
2 files changed, 15 insertions, 22 deletions
diff --git a/xmlsecurity/source/helper/documentsignaturehelper.cxx b/xmlsecurity/source/helper/documentsignaturehelper.cxx
index f1929f927758..66a058c1d3dd 100644
--- a/xmlsecurity/source/helper/documentsignaturehelper.cxx
+++ b/xmlsecurity/source/helper/documentsignaturehelper.cxx
@@ -87,42 +87,40 @@ static void ImplFillElementList(
{
Reference < css::container::XNameAccess > xElements( rxStore, UNO_QUERY );
Sequence< OUString > aElements = xElements->getElementNames();
- sal_Int32 nElements = aElements.getLength();
- const OUString* pNames = aElements.getConstArray();
- for ( sal_Int32 n = 0; n < nElements; n++ )
+ for ( const auto& rName : aElements )
{
- if (pNames[n] == "[Content_Types].xml")
+ if (rName == "[Content_Types].xml")
// OOXML
continue;
// If the user enabled validating according to OOo 3.0
// then mimetype and all content of META-INF must be excluded.
if (mode != DocumentSignatureAlgorithm::OOo3_2
- && (pNames[n] == "META-INF" || pNames[n] == "mimetype"))
+ && (rName == "META-INF" || rName == "mimetype"))
{
continue;
}
else
{
OUString sEncName = ::rtl::Uri::encode(
- pNames[n], rtl_UriCharClassRelSegment,
+ rName, rtl_UriCharClassRelSegment,
rtl_UriEncodeStrict, RTL_TEXTENCODING_UTF8);
- if (sEncName.isEmpty() && !pNames[n].isEmpty())
+ if (sEncName.isEmpty() && !rName.isEmpty())
throw css::uno::RuntimeException("Failed to encode element name of XStorage", nullptr);
- if ( rxStore->isStreamElement( pNames[n] ) )
+ if ( rxStore->isStreamElement( rName ) )
{
//Exclude documentsignatures.xml!
- if (pNames[n] ==
+ if (rName ==
DocumentSignatureHelper::GetDocumentContentSignatureDefaultStreamName())
continue;
OUString aFullName( rRootStorageName + sEncName );
rList.push_back(aFullName);
}
- else if ( bRecursive && rxStore->isStorageElement( pNames[n] ) )
+ else if ( bRecursive && rxStore->isStorageElement( rName ) )
{
- Reference < css::embed::XStorage > xSubStore = rxStore->openStorageElement( pNames[n], css::embed::ElementModes::READ );
+ Reference < css::embed::XStorage > xSubStore = rxStore->openStorageElement( rName, css::embed::ElementModes::READ );
OUString aFullRootName( rRootStorageName + sEncName + "/" );
ImplFillElementList(rList, xSubStore, aFullRootName, bRecursive, mode);
}
@@ -217,14 +215,12 @@ DocumentSignatureHelper::CreateElementList(
// Object folders...
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++ )
+ for ( const auto& rName : aElementNames )
{
- if ( ( pNames[n].match( "Object " ) ) && rxStore->isStorageElement( pNames[n] ) )
+ if ( ( rName.match( "Object " ) ) && rxStore->isStorageElement( rName ) )
{
- Reference < css::embed::XStorage > xTmpSubStore = rxStore->openStorageElement( pNames[n], css::embed::ElementModes::READ );
- ImplFillElementList(aElements, xTmpSubStore, pNames[n]+aSep, true, mode);
+ Reference < css::embed::XStorage > xTmpSubStore = rxStore->openStorageElement( rName, css::embed::ElementModes::READ );
+ ImplFillElementList(aElements, xTmpSubStore, rName+aSep, true, mode);
}
}
}
diff --git a/xmlsecurity/source/helper/documentsignaturemanager.cxx b/xmlsecurity/source/helper/documentsignaturemanager.cxx
index 9cd197e786ae..305a98fb884d 100644
--- a/xmlsecurity/source/helper/documentsignaturemanager.cxx
+++ b/xmlsecurity/source/helper/documentsignaturemanager.cxx
@@ -181,15 +181,12 @@ bool DocumentSignatureManager::isXML(const OUString& rURI)
if (readManifest())
{
- for (int i = 0; i < m_manifest.getLength(); i++)
+ for (const uno::Sequence<beans::PropertyValue>& entry : m_manifest)
{
- const uno::Sequence<beans::PropertyValue>& entry = m_manifest[i];
OUString sPath, sMediaType;
bool bEncrypted = false;
- for (int j = 0; j < entry.getLength(); j++)
+ for (const beans::PropertyValue& prop : entry)
{
- const beans::PropertyValue& prop = entry[j];
-
if (prop.Name == sPropFullPath)
prop.Value >>= sPath;
else if (prop.Name == sPropMediaType)