summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/container/embeddedobjectcontainer.cxx8
-rw-r--r--comphelper/source/misc/AccessibleImplementationHelper.cxx5
-rw-r--r--comphelper/source/misc/backupfilehelper.cxx8
-rw-r--r--comphelper/source/misc/docpasswordhelper.cxx18
-rw-r--r--comphelper/source/misc/mimeconfighelper.cxx59
-rw-r--r--comphelper/source/misc/storagehelper.cxx11
-rw-r--r--comphelper/source/xml/ofopxmlhelper.cxx26
7 files changed, 61 insertions, 74 deletions
diff --git a/comphelper/source/container/embeddedobjectcontainer.cxx b/comphelper/source/container/embeddedobjectcontainer.cxx
index 311edd303a86..2c3a6f937652 100644
--- a/comphelper/source/container/embeddedobjectcontainer.cxx
+++ b/comphelper/source/container/embeddedobjectcontainer.cxx
@@ -761,14 +761,14 @@ uno::Reference < embed::XEmbeddedObject > EmbeddedObjectContainer::CopyAndGetEmb
if ( !xOrigInfo.is() )
throw uno::RuntimeException();
- uno::Sequence< beans::Property > aPropertiesList = xOrigInfo->getProperties();
- for ( sal_Int32 nInd = 0; nInd < aPropertiesList.getLength(); nInd++ )
+ const uno::Sequence< beans::Property > aPropertiesList = xOrigInfo->getProperties();
+ for ( const auto & p : aPropertiesList )
{
try
{
xTargetProps->setPropertyValue(
- aPropertiesList[nInd].Name,
- xOrigProps->getPropertyValue( aPropertiesList[nInd].Name ) );
+ p.Name,
+ xOrigProps->getPropertyValue( p.Name ) );
}
catch (const beans::PropertyVetoException&)
{
diff --git a/comphelper/source/misc/AccessibleImplementationHelper.cxx b/comphelper/source/misc/AccessibleImplementationHelper.cxx
index ceba64e04800..a45b6e5f3cd7 100644
--- a/comphelper/source/misc/AccessibleImplementationHelper.cxx
+++ b/comphelper/source/misc/AccessibleImplementationHelper.cxx
@@ -31,11 +31,10 @@ namespace comphelper
OUString GetkeyBindingStrByXkeyBinding(const Sequence<KeyStroke>& keySet)
{
OUStringBuffer buf;
- for (int iIndex = 0; iIndex < keySet.getLength(); iIndex++)
+ for (const auto& k : keySet)
{
- KeyStroke stroke = keySet[iIndex];
buf.append('\n');
- buf.append(stroke.KeyChar);
+ buf.append(k.KeyChar);
}
return buf.makeStringAndClear();
}
diff --git a/comphelper/source/misc/backupfilehelper.cxx b/comphelper/source/misc/backupfilehelper.cxx
index 5381f48a62aa..4476e7f17717 100644
--- a/comphelper/source/misc/backupfilehelper.cxx
+++ b/comphelper/source/misc/backupfilehelper.cxx
@@ -411,14 +411,10 @@ namespace
e.Context, anyEx );
}
- for (sal_Int32 i = 0; i < xAllPackages.getLength(); ++i)
+ for (const uno::Sequence< uno::Reference< deployment::XPackage > > & xPackageList : std::as_const(xAllPackages))
{
- uno::Sequence< uno::Reference< deployment::XPackage > > xPackageList = xAllPackages[i];
-
- for (sal_Int32 j = 0; j < xPackageList.getLength(); ++j)
+ for (const uno::Reference< deployment::XPackage > & xPackage : xPackageList)
{
- uno::Reference< deployment::XPackage > xPackage = xPackageList[j];
-
if (xPackage.is())
{
maEntries.emplace_back(xPackage);
diff --git a/comphelper/source/misc/docpasswordhelper.cxx b/comphelper/source/misc/docpasswordhelper.cxx
index 1b6f323eb458..4dd9c8312bee 100644
--- a/comphelper/source/misc/docpasswordhelper.cxx
+++ b/comphelper/source/misc/docpasswordhelper.cxx
@@ -119,16 +119,16 @@ bool DocPasswordHelper::IsModifyPasswordCorrect( const OUString& aPassword, cons
uno::Sequence< sal_Int8 > aHash;
sal_Int32 nCount = 0;
- for ( sal_Int32 nInd = 0; nInd < aInfo.getLength(); nInd++ )
+ for ( const auto & prop : aInfo )
{
- if ( aInfo[nInd].Name == "algorithm-name" )
- aInfo[nInd].Value >>= sAlgorithm;
- else if ( aInfo[nInd].Name == "salt" )
- aInfo[nInd].Value >>= aSalt;
- else if ( aInfo[nInd].Name == "iteration-count" )
- aInfo[nInd].Value >>= nCount;
- else if ( aInfo[nInd].Name == "hash" )
- aInfo[nInd].Value >>= aHash;
+ if ( prop.Name == "algorithm-name" )
+ prop.Value >>= sAlgorithm;
+ else if ( prop.Name == "salt" )
+ prop.Value >>= aSalt;
+ else if ( prop.Name == "iteration-count" )
+ prop.Value >>= nCount;
+ else if ( prop.Name == "hash" )
+ prop.Value >>= aHash;
}
if ( sAlgorithm == "PBKDF2" && aSalt.hasElements() && nCount > 0 && aHash.hasElements() )
diff --git a/comphelper/source/misc/mimeconfighelper.cxx b/comphelper/source/misc/mimeconfighelper.cxx
index d0858a89d578..b41b1d3850c7 100644
--- a/comphelper/source/misc/mimeconfighelper.cxx
+++ b/comphelper/source/misc/mimeconfighelper.cxx
@@ -203,9 +203,9 @@ OUString MimeConfigurationHelper::GetDocServiceNameFromFilter( const OUString& a
uno::Sequence< beans::PropertyValue > aFilterData;
if ( aFilterAnyData >>= aFilterData )
{
- for ( sal_Int32 nInd = 0; nInd < aFilterData.getLength(); nInd++ )
- if ( aFilterData[nInd].Name == "DocumentService" )
- aFilterData[nInd].Value >>= aDocServiceName;
+ for ( const auto & prop : std::as_const(aFilterData) )
+ if ( prop.Name == "DocumentService" )
+ prop.Value >>= aDocServiceName;
}
}
catch( uno::Exception& )
@@ -234,11 +234,11 @@ OUString MimeConfigurationHelper::GetDocServiceNameFromMediaType( const OUString
uno::Sequence< beans::PropertyValue > aType;
if ( xEnum->nextElement() >>= aType )
{
- for ( sal_Int32 nInd = 0; nInd < aType.getLength(); nInd++ )
+ for ( const auto & prop : std::as_const(aType) )
{
OUString aFilterName;
- if ( aType[nInd].Name == "PreferredFilter"
- && ( aType[nInd].Value >>= aFilterName ) && !aFilterName.isEmpty() )
+ if ( prop.Name == "PreferredFilter"
+ && ( prop.Value >>= aFilterName ) && !aFilterName.isEmpty() )
{
OUString aDocumentName = GetDocServiceNameFromFilter( aFilterName );
if ( !aDocumentName.isEmpty() )
@@ -452,17 +452,17 @@ uno::Sequence< beans::NamedValue > MimeConfigurationHelper::GetObjectPropsByDocu
{
try
{
- uno::Sequence< OUString > aClassIDs = xObjConfig->getElementNames();
- for ( sal_Int32 nInd = 0; nInd < aClassIDs.getLength(); nInd++ )
+ const uno::Sequence< OUString > aClassIDs = xObjConfig->getElementNames();
+ for ( const OUString & id : aClassIDs )
{
uno::Reference< container::XNameAccess > xObjectProps;
OUString aEntryDocName;
- if ( ( xObjConfig->getByName( aClassIDs[nInd] ) >>= xObjectProps ) && xObjectProps.is()
+ if ( ( xObjConfig->getByName( id ) >>= xObjectProps ) && xObjectProps.is()
&& ( xObjectProps->getByName("ObjectDocumentServiceName") >>= aEntryDocName )
&& aEntryDocName == aDocName )
{
- return GetObjPropsFromConfigEntry( GetSequenceClassIDRepresentation( aClassIDs[nInd] ),
+ return GetObjPropsFromConfigEntry( GetSequenceClassIDRepresentation( id ),
xObjectProps );
}
}
@@ -518,13 +518,13 @@ OUString MimeConfigurationHelper::GetFactoryNameByDocumentName( const OUString&
{
try
{
- uno::Sequence< OUString > aClassIDs = xObjConfig->getElementNames();
- for ( sal_Int32 nInd = 0; nInd < aClassIDs.getLength(); nInd++ )
+ const uno::Sequence< OUString > aClassIDs = xObjConfig->getElementNames();
+ for ( const OUString & id : aClassIDs )
{
uno::Reference< container::XNameAccess > xObjectProps;
OUString aEntryDocName;
- if ( ( xObjConfig->getByName( aClassIDs[nInd] ) >>= xObjectProps ) && xObjectProps.is()
+ if ( ( xObjConfig->getByName( id ) >>= xObjectProps ) && xObjectProps.is()
&& ( xObjectProps->getByName( "ObjectDocumentServiceName" ) >>= aEntryDocName )
&& aEntryDocName == aDocName )
{
@@ -563,9 +563,9 @@ OUString MimeConfigurationHelper::UpdateMediaDescriptorWithFilterName(
{
OUString aFilterName;
- for ( sal_Int32 nInd = 0; nInd < aMediaDescr.getLength(); nInd++ )
- if ( aMediaDescr[nInd].Name == "FilterName" )
- aMediaDescr[nInd].Value >>= aFilterName;
+ for ( const auto & prop : std::as_const(aMediaDescr) )
+ if ( prop.Name == "FilterName" )
+ prop.Value >>= aFilterName;
if ( aFilterName.isEmpty() )
{
@@ -582,9 +582,9 @@ OUString MimeConfigurationHelper::UpdateMediaDescriptorWithFilterName(
OUString aTypeName = xTypeDetection->queryTypeByDescriptor( aTempMD, true );
// get FilterName
- for ( sal_Int32 nInd = 0; nInd < aTempMD.getLength(); nInd++ )
- if ( aTempMD[nInd].Name == "FilterName" )
- aTempMD[nInd].Value >>= aFilterName;
+ for ( const auto & prop : std::as_const(aTempMD) )
+ if ( prop.Name == "FilterName" )
+ prop.Value >>= aFilterName;
if ( !aFilterName.isEmpty() )
{
@@ -601,14 +601,14 @@ OUString MimeConfigurationHelper::UpdateMediaDescriptorWithFilterName(
if ( xNameAccess.is() && ( xNameAccess->getByName( aTypeName ) >>= aTypes ) )
{
- for ( sal_Int32 nInd = 0; nInd < aTypes.getLength(); nInd++ )
+ for ( const auto & prop : std::as_const(aTypes) )
{
- if ( aTypes[nInd].Name == "PreferredFilter" && ( aTypes[nInd].Value >>= aFilterName ) )
+ if ( prop.Name == "PreferredFilter" && ( prop.Value >>= aFilterName ) )
{
sal_Int32 nOldLen = aMediaDescr.getLength();
aMediaDescr.realloc( nOldLen + 1 );
aMediaDescr[nOldLen].Name = "FilterName";
- aMediaDescr[ nOldLen ].Value = aTypes[nInd].Value;
+ aMediaDescr[ nOldLen ].Value = prop.Value;
break;
}
}
@@ -624,10 +624,10 @@ OUString MimeConfigurationHelper::UpdateMediaDescriptorWithFilterName(
uno::Sequence< beans::NamedValue >& aObject )
{
OUString aDocName;
- for ( sal_Int32 nInd = 0; nInd < aObject.getLength(); nInd++ )
- if ( aObject[nInd].Name == "ObjectDocumentServiceName" )
+ for ( const auto & nv : std::as_const(aObject) )
+ if ( nv.Name == "ObjectDocumentServiceName" )
{
- aObject[nInd].Value >>= aDocName;
+ nv.Value >>= aDocName;
break;
}
@@ -862,14 +862,7 @@ uno::Sequence< beans::PropertyValue > MimeConfigurationHelper::SearchForFilter(
bool MimeConfigurationHelper::ClassIDsEqual( const uno::Sequence< sal_Int8 >& aClassID1, const uno::Sequence< sal_Int8 >& aClassID2 )
{
- if ( aClassID1.getLength() != aClassID2.getLength() )
- return false;
-
- for ( sal_Int32 nInd = 0; nInd < aClassID1.getLength(); nInd++ )
- if ( aClassID1[nInd] != aClassID2[nInd] )
- return false;
-
- return true;
+ return aClassID1 == aClassID2;
}
diff --git a/comphelper/source/misc/storagehelper.cxx b/comphelper/source/misc/storagehelper.cxx
index e01e49b654b8..01cec5831223 100644
--- a/comphelper/source/misc/storagehelper.cxx
+++ b/comphelper/source/misc/storagehelper.cxx
@@ -474,7 +474,7 @@ uno::Sequence< beans::NamedValue > OStorageHelper::CreateGpgPackageEncryptionDat
comphelper::getProcessComponentContext()));
// fire up certificate chooser dialog - user can multi-select!
- uno::Sequence< uno::Reference< security::XCertificate > > xSignCertificates=
+ const uno::Sequence< uno::Reference< security::XCertificate > > xSignCertificates=
xSigner->chooseEncryptionCertificate();
if (!xSignCertificates.hasElements())
@@ -493,12 +493,11 @@ uno::Sequence< beans::NamedValue > OStorageHelper::CreateGpgPackageEncryptionDat
throw uno::RuntimeException("The GpgME library failed to initialize for the OpenPGP protocol.");
ctx->setArmor(false);
- const uno::Reference< security::XCertificate >* pCerts=xSignCertificates.getConstArray();
- for (sal_uInt32 i = 0, nNum = xSignCertificates.getLength(); i < nNum; i++, pCerts++)
+ for (const auto & cert : xSignCertificates)
{
uno::Sequence < sal_Int8 > aKeyID;
- if (pCerts->is())
- aKeyID = (*pCerts)->getSHA1Thumbprint();
+ if (cert.is())
+ aKeyID = cert->getSHA1Thumbprint();
std::vector<GpgME::Key> keys;
keys.push_back(
@@ -526,7 +525,7 @@ uno::Sequence< beans::NamedValue > OStorageHelper::CreateGpgPackageEncryptionDat
if(crypt_res.error() || !len)
throw lang::IllegalArgumentException(
"Not a suitable key, or failed to encrypt.",
- css::uno::Reference<css::uno::XInterface>(), i);
+ css::uno::Reference<css::uno::XInterface>(), -1);
uno::Sequence < sal_Int8 > aCipherValue(len);
result = cipher.seek(0,SEEK_SET);
diff --git a/comphelper/source/xml/ofopxmlhelper.cxx b/comphelper/source/xml/ofopxmlhelper.cxx
index 46785b35cbba..bde7bb00280e 100644
--- a/comphelper/source/xml/ofopxmlhelper.cxx
+++ b/comphelper/source/xml/ofopxmlhelper.cxx
@@ -156,21 +156,21 @@ void WriteRelationsInfoSequence(
xWriter->startDocument();
xWriter->startElement( aRelListElement, xRootAttrList );
- for ( sal_Int32 nInd = 0; nInd < aSequence.getLength(); nInd++ )
+ for ( const auto & i : aSequence )
{
AttributeList *pAttrList = new AttributeList;
uno::Reference< css::xml::sax::XAttributeList > xAttrList( pAttrList );
- for( sal_Int32 nSecInd = 0; nSecInd < aSequence[nInd].getLength(); nSecInd++ )
+ for( const beans::StringPair & pair : i )
{
- if ( !(aSequence[nInd][nSecInd].First == "Id"
- || aSequence[nInd][nSecInd].First == "Type"
- || aSequence[nInd][nSecInd].First == "TargetMode"
- || aSequence[nInd][nSecInd].First == "Target") )
+ if ( !(pair.First == "Id"
+ || pair.First == "Type"
+ || pair.First == "TargetMode"
+ || pair.First == "Target") )
{
// TODO/LATER: should the extensions be allowed?
throw lang::IllegalArgumentException();
}
- pAttrList->AddAttribute( aSequence[nInd][nSecInd].First, aCDATAString, aSequence[nInd][nSecInd].Second );
+ pAttrList->AddAttribute( pair.First, aCDATAString, pair.Second );
}
xWriter->startElement( aRelElement, xAttrList );
@@ -215,24 +215,24 @@ void WriteContentSequence(
xWriter->startDocument();
xWriter->startElement( aTypesElement, xRootAttrList );
- for ( sal_Int32 nInd = 0; nInd < aDefaultsSequence.getLength(); nInd++ )
+ for ( const beans::StringPair & pair : aDefaultsSequence )
{
AttributeList *pAttrList = new AttributeList;
uno::Reference< css::xml::sax::XAttributeList > xAttrList( pAttrList );
- pAttrList->AddAttribute( "Extension", aCDATAString, aDefaultsSequence[nInd].First );
- pAttrList->AddAttribute( aContentTypeAttr, aCDATAString, aDefaultsSequence[nInd].Second );
+ pAttrList->AddAttribute( "Extension", aCDATAString, pair.First );
+ pAttrList->AddAttribute( aContentTypeAttr, aCDATAString, pair.Second );
xWriter->startElement( aDefaultElement, xAttrList );
xWriter->ignorableWhitespace( aWhiteSpace );
xWriter->endElement( aDefaultElement );
}
- for ( sal_Int32 nInd = 0; nInd < aOverridesSequence.getLength(); nInd++ )
+ for ( const beans::StringPair & pair : aOverridesSequence )
{
AttributeList *pAttrList = new AttributeList;
uno::Reference< css::xml::sax::XAttributeList > xAttrList( pAttrList );
- pAttrList->AddAttribute( "PartName", aCDATAString, aOverridesSequence[nInd].First );
- pAttrList->AddAttribute( aContentTypeAttr, aCDATAString, aOverridesSequence[nInd].Second );
+ pAttrList->AddAttribute( "PartName", aCDATAString, pair.First );
+ pAttrList->AddAttribute( aContentTypeAttr, aCDATAString, pair.Second );
xWriter->startElement( aOverrideElement, xAttrList );
xWriter->ignorableWhitespace( aWhiteSpace );