summaryrefslogtreecommitdiff
path: root/sdext
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-07-27 18:32:04 +0300
committerArkadiy Illarionov <qarkai@gmail.com>2019-07-29 18:44:51 +0200
commitc26f2fcf82d549a6475e9e55cdffde901190635b (patch)
tree085e073de73fd46d3b39ac77b0843daf427c5aec /sdext
parent25b200ff79c71c831bc7e6fe8b1ec0b5315e96d6 (diff)
Simplify Sequence iterations in sdext
Use range-based loops and STL algorithms Change-Id: I0ffc0c7481b35cf6a297f8123b567d4331ff1a3f Reviewed-on: https://gerrit.libreoffice.org/76478 Tested-by: Jenkins Reviewed-by: Arkadiy Illarionov <qarkai@gmail.com>
Diffstat (limited to 'sdext')
-rw-r--r--sdext/source/minimizer/configurationaccess.cxx16
-rw-r--r--sdext/source/minimizer/fileopendialog.cxx25
-rw-r--r--sdext/source/minimizer/impoptimizer.cxx46
-rw-r--r--sdext/source/minimizer/optimizationstats.cxx4
-rw-r--r--sdext/source/minimizer/pppoptimizerdialog.cxx9
-rw-r--r--sdext/source/pdfimport/filterdet.cxx8
-rw-r--r--sdext/source/pdfimport/pdfiadaptor.cxx42
-rw-r--r--sdext/source/presenter/PresenterAccessibility.cxx10
-rw-r--r--sdext/source/presenter/PresenterConfigurationAccess.cxx12
-rw-r--r--sdext/source/presenter/PresenterScreen.cxx30
-rw-r--r--sdext/source/presenter/PresenterTheme.cxx13
11 files changed, 87 insertions, 128 deletions
diff --git a/sdext/source/minimizer/configurationaccess.cxx b/sdext/source/minimizer/configurationaccess.cxx
index a711610bc0aa..bf6a472a1e68 100644
--- a/sdext/source/minimizer/configurationaccess.cxx
+++ b/sdext/source/minimizer/configurationaccess.cxx
@@ -46,11 +46,10 @@ void OptimizerSettings::LoadSettingsFromConfiguration( const Reference< XNameAcc
return;
const Sequence< OUString > aElements( rSettings->getElementNames() );
- for ( int i = 0; i < aElements.getLength(); i++ )
+ for ( const OUString& aPropertyName : aElements )
{
try
{
- const OUString aPropertyName( aElements[ i ] );
Any aValue( rSettings->getByName( aPropertyName ) );
switch( TKGet( aPropertyName ) )
{
@@ -177,11 +176,11 @@ void ConfigurationAccess::LoadStrings()
if ( xSet.is() )
{
const Sequence< OUString > aElements( xSet->getElementNames() );
- for ( int i = 0; i < aElements.getLength(); i++ )
+ for ( const auto& rElement : aElements )
{
try
{
- OUString aString, aPropertyName( aElements[ i ] );
+ OUString aString, aPropertyName( rElement );
if ( xSet->getByName( aPropertyName ) >>= aString )
maStrings[ TKGet( aPropertyName ) ] = aString;
}
@@ -217,11 +216,11 @@ void ConfigurationAccess::LoadConfiguration()
if ( xSet.is() )
{
const Sequence< OUString > aElements( xSet->getElementNames() );
- for ( int i = 0; i < aElements.getLength(); i++ )
+ for ( const auto& rElement : aElements )
{
try
{
- OUString aPath( "Settings/Templates/" + aElements[ i ] );
+ OUString aPath( "Settings/Templates/" + rElement );
Reference< container::XNameAccess > xTemplates( GetConfigurationNode( xRoot, aPath ), UNO_QUERY );
if ( xTemplates.is() )
{
@@ -248,7 +247,6 @@ void ConfigurationAccess::SaveConfiguration()
{
do
{
- int i;
Reference<util::XChangesBatch> xRoot( OpenConfiguration( false ), UNO_QUERY_THROW );
// storing the last used settings
@@ -261,8 +259,8 @@ void ConfigurationAccess::SaveConfiguration()
Reference< container::XNameContainer > xNameContainer( xSet, UNO_QUERY_THROW );
const Sequence< OUString > aElements( xSet->getElementNames() );
- for( i = 0; i < aElements.getLength(); i++ )
- xNameContainer->removeByName( aElements[ i ] );
+ for( const auto& rElement : aElements )
+ xNameContainer->removeByName( rElement );
for( std::vector<OptimizerSettings>::size_type k = 1; k < maSettings.size(); k++ )
{
diff --git a/sdext/source/minimizer/fileopendialog.cxx b/sdext/source/minimizer/fileopendialog.cxx
index b415a696625e..5afe2165f17e 100644
--- a/sdext/source/minimizer/fileopendialog.cxx
+++ b/sdext/source/minimizer/fileopendialog.cxx
@@ -73,18 +73,18 @@ FileOpenDialog::FileOpenDialog( const Reference< XComponentContext >& rxContext
Reference< XNameAccess > xFilters( rxContext->getServiceManager()->createInstanceWithContext(
"com.sun.star.document.FilterFactory", rxContext ), UNO_QUERY_THROW );
Sequence< OUString > aFilterList( xFilters->getElementNames() );
- for ( int i = 0; i < aFilterList.getLength(); i++ )
+ for ( const auto& rFilter : aFilterList )
{
try
{
Sequence< PropertyValue > aFilterProperties;
- if ( xFilters->getByName( aFilterList[ i ] ) >>= aFilterProperties )
+ if ( xFilters->getByName( rFilter ) >>= aFilterProperties )
{
FilterEntry aFilterEntry;
bool bImpressFilter = false;
- for ( int j = 0; j < aFilterProperties.getLength(); j++ )
+ for ( const PropertyValue& rProperty : aFilterProperties )
{
- PropertyValue& rProperty( aFilterProperties[ j ] );
+ bool bStop = false;
switch( TKGet( rProperty.Name ) )
{
case TK_DocumentService :
@@ -94,7 +94,7 @@ FileOpenDialog::FileOpenDialog( const Reference< XComponentContext >& rxContext
if ( sDocumentService == "com.sun.star.presentation.PresentationDocument" )
bImpressFilter = true;
else
- j = aFilterProperties.getLength();
+ bStop = true;
}
break;
case TK_Name : rProperty.Value >>= aFilterEntry.maFilterEntryName; break;
@@ -103,6 +103,9 @@ FileOpenDialog::FileOpenDialog( const Reference< XComponentContext >& rxContext
case TK_Flags : rProperty.Value >>= aFilterEntry.maFlags; break;
default : break;
}
+
+ if (bStop)
+ break;
}
if ( bImpressFilter && ( ( aFilterEntry.maFlags & 3 ) == 3 ) )
{
@@ -126,14 +129,10 @@ FileOpenDialog::FileOpenDialog( const Reference< XComponentContext >& rxContext
if ( xTypes->getByName( rFilterEntry.maType ) >>= aTypeProperties )
{
Sequence< OUString > aExtensions;
- for ( int i = 0; i < aTypeProperties.getLength(); i++ )
- {
- if( aTypeProperties[ i ].Name == "Extensions" )
- {
- aTypeProperties[ i ].Value >>= aExtensions;
- break;
- }
- }
+ auto pProp = std::find_if(aTypeProperties.begin(), aTypeProperties.end(),
+ [](const PropertyValue& rProp) { return rProp.Name == "Extensions"; });
+ if (pProp != aTypeProperties.end())
+ pProp->Value >>= aExtensions;
if ( aExtensions.hasElements() )
{
// The filter title must be formed in the same way it is
diff --git a/sdext/source/minimizer/impoptimizer.cxx b/sdext/source/minimizer/impoptimizer.cxx
index 1105c027cb44..ab92521a569f 100644
--- a/sdext/source/minimizer/impoptimizer.cxx
+++ b/sdext/source/minimizer/impoptimizer.cxx
@@ -581,37 +581,35 @@ void ImpOptimizer::Optimize( const Sequence< PropertyValue >& rArguments )
SetStatusValue( TK_Progress, Any( static_cast< sal_Int32 >( 0 ) ) );
DispatchStatus();
- int i, nICount;
- for ( i = 0, nICount = rArguments.getLength(); i < nICount; i++ )
+ for ( const auto& rArgument : rArguments )
{
- switch( TKGet( rArguments[ i ].Name ) )
+ switch( TKGet( rArgument.Name ) )
{
- case TK_StatusDispatcher : rArguments[ i ].Value >>= mxStatusDispatcher; break;
- case TK_InformationDialog: rArguments[ i ].Value >>= mxInformationDialog; break;
+ case TK_StatusDispatcher : rArgument.Value >>= mxStatusDispatcher; break;
+ case TK_InformationDialog: rArgument.Value >>= mxInformationDialog; break;
case TK_Settings :
{
css::uno::Sequence< css::beans::PropertyValue > aSettings;
- int j, nJCount;
- rArguments[ i ].Value >>= aSettings;
- for ( j = 0, nJCount = aSettings.getLength(); j < nJCount; j++ )
+ rArgument.Value >>= aSettings;
+ for ( const auto& rSetting : aSettings )
{
- switch( TKGet( aSettings[ j ].Name ) )
+ switch( TKGet( rSetting.Name ) )
{
- case TK_JPEGCompression : aSettings[ j ].Value >>= mbJPEGCompression; break;
- case TK_JPEGQuality : aSettings[ j ].Value >>= mnJPEGQuality; break;
- case TK_RemoveCropArea : aSettings[ j ].Value >>= mbRemoveCropArea; break;
- case TK_ImageResolution : aSettings[ j ].Value >>= mnImageResolution; break;
- case TK_EmbedLinkedGraphics : aSettings[ j ].Value >>= mbEmbedLinkedGraphics; break;
- case TK_OLEOptimization : aSettings[ j ].Value >>= mbOLEOptimization; break;
- case TK_OLEOptimizationType : aSettings[ j ].Value >>= mnOLEOptimizationType; break;
- case TK_CustomShowName : aSettings[ j ].Value >>= maCustomShowName; break;
- case TK_DeleteUnusedMasterPages : aSettings[ j ].Value >>= mbDeleteUnusedMasterPages; break;
- case TK_DeleteHiddenSlides : aSettings[ j ].Value >>= mbDeleteHiddenSlides; break;
- case TK_DeleteNotesPages : aSettings[ j ].Value >>= mbDeleteNotesPages; break;
- case TK_SaveAsURL : aSettings[ j ].Value >>= maSaveAsURL; break;
- case TK_FilterName : aSettings[ j ].Value >>= maFilterName; break;
- case TK_OpenNewDocument : aSettings[ j ].Value >>= mbOpenNewDocument; break;
- case TK_EstimatedFileSize : aSettings[ j ].Value >>= nEstimatedFileSize; break;
+ case TK_JPEGCompression : rSetting.Value >>= mbJPEGCompression; break;
+ case TK_JPEGQuality : rSetting.Value >>= mnJPEGQuality; break;
+ case TK_RemoveCropArea : rSetting.Value >>= mbRemoveCropArea; break;
+ case TK_ImageResolution : rSetting.Value >>= mnImageResolution; break;
+ case TK_EmbedLinkedGraphics : rSetting.Value >>= mbEmbedLinkedGraphics; break;
+ case TK_OLEOptimization : rSetting.Value >>= mbOLEOptimization; break;
+ case TK_OLEOptimizationType : rSetting.Value >>= mnOLEOptimizationType; break;
+ case TK_CustomShowName : rSetting.Value >>= maCustomShowName; break;
+ case TK_DeleteUnusedMasterPages : rSetting.Value >>= mbDeleteUnusedMasterPages; break;
+ case TK_DeleteHiddenSlides : rSetting.Value >>= mbDeleteHiddenSlides; break;
+ case TK_DeleteNotesPages : rSetting.Value >>= mbDeleteNotesPages; break;
+ case TK_SaveAsURL : rSetting.Value >>= maSaveAsURL; break;
+ case TK_FilterName : rSetting.Value >>= maFilterName; break;
+ case TK_OpenNewDocument : rSetting.Value >>= mbOpenNewDocument; break;
+ case TK_EstimatedFileSize : rSetting.Value >>= nEstimatedFileSize; break;
default: break;
}
}
diff --git a/sdext/source/minimizer/optimizationstats.cxx b/sdext/source/minimizer/optimizationstats.cxx
index f1f817338961..03fff4dfa93e 100644
--- a/sdext/source/minimizer/optimizationstats.cxx
+++ b/sdext/source/minimizer/optimizationstats.cxx
@@ -65,8 +65,8 @@ css::beans::PropertyValues OptimizationStats::GetStatusSequence()
void OptimizationStats::InitializeStatusValues( const uno::Sequence< PropertyValue >& rOptimizationStats )
{
- for( int i = 0; i < rOptimizationStats.getLength(); i++ )
- maStats[ TKGet( rOptimizationStats[ i ].Name ) ] = rOptimizationStats[ i ].Value;
+ for( const auto& rStat : rOptimizationStats )
+ maStats[ TKGet( rStat.Name ) ] = rStat.Value;
}
diff --git a/sdext/source/minimizer/pppoptimizerdialog.cxx b/sdext/source/minimizer/pppoptimizerdialog.cxx
index 1c8cf4b2c6b0..8c0d0a28d26d 100644
--- a/sdext/source/minimizer/pppoptimizerdialog.cxx
+++ b/sdext/source/minimizer/pppoptimizerdialog.cxx
@@ -81,12 +81,9 @@ Sequence< Reference< css::frame::XDispatch > > SAL_CALL PPPOptimizerDialog::quer
const Sequence< css::frame::DispatchDescriptor >& aDescripts )
{
Sequence< Reference< css::frame::XDispatch> > aReturn( aDescripts.getLength() );
- Reference< css::frame::XDispatch>* pReturn = aReturn.getArray();
- const css::frame::DispatchDescriptor* pDescripts = aDescripts.getConstArray();
- for (sal_Int32 i = 0; i < aDescripts.getLength(); ++i, ++pReturn, ++pDescripts )
- {
- *pReturn = queryDispatch( pDescripts->FeatureURL, pDescripts->FrameName, pDescripts->SearchFlags );
- }
+ std::transform(aDescripts.begin(), aDescripts.end(), aReturn.begin(),
+ [this](const css::frame::DispatchDescriptor& rDescr) -> Reference<css::frame::XDispatch> {
+ return queryDispatch(rDescr.FeatureURL, rDescr.FrameName, rDescr.SearchFlags); });
return aReturn;
}
diff --git a/sdext/source/pdfimport/filterdet.cxx b/sdext/source/pdfimport/filterdet.cxx
index 4b72c932f44c..01a1177f70e7 100644
--- a/sdext/source/pdfimport/filterdet.cxx
+++ b/sdext/source/pdfimport/filterdet.cxx
@@ -548,13 +548,11 @@ uno::Reference< io::XStream > getAdditionalStream( const OUString&
}
if( ! bAuthenticated )
{
- const beans::PropertyValue* pAttribs = rFilterData.getConstArray();
- sal_Int32 nAttribs = rFilterData.getLength();
uno::Reference< task::XInteractionHandler > xIntHdl;
- for( sal_Int32 i = 0; i < nAttribs; i++ )
+ for( const beans::PropertyValue& rAttrib : rFilterData )
{
- if ( pAttribs[i].Name == "InteractionHandler" )
- pAttribs[i].Value >>= xIntHdl;
+ if ( rAttrib.Name == "InteractionHandler" )
+ rAttrib.Value >>= xIntHdl;
}
if( ! bMayUseUI || ! xIntHdl.is() )
{
diff --git a/sdext/source/pdfimport/pdfiadaptor.cxx b/sdext/source/pdfimport/pdfiadaptor.cxx
index e66cf59f7f79..ee415ed31255 100644
--- a/sdext/source/pdfimport/pdfiadaptor.cxx
+++ b/sdext/source/pdfimport/pdfiadaptor.cxx
@@ -86,14 +86,10 @@ sal_Bool SAL_CALL PDFIHybridAdaptor::filter( const uno::Sequence< beans::Propert
if( ! xSubStream.is() )
{
uno::Reference< io::XInputStream > xInput;
- for( sal_Int32 i = 0; i < nAttribs; i++ )
- {
- if ( pAttribs[i].Name == "InputStream" )
- {
- pAttribs[i].Value >>= xInput;
- break;
- }
- }
+ auto pAttr = std::find_if(rFilterData.begin(), rFilterData.end(),
+ [](const beans::PropertyValue& rAttr) { return rAttr.Name == "InputStream"; });
+ if (pAttr != rFilterData.end())
+ pAttr->Value >>= xInput;
if( xInput.is() )
{
// TODO(P2): extracting hybrid substream twice - once during detection, second time here
@@ -284,23 +280,21 @@ sal_Bool SAL_CALL PDFIRawAdaptor::importer( const uno::Sequence< beans::Property
OUString aURL;
OUString aPwd;
OUString aFilterOptions;
- const beans::PropertyValue* pAttribs = rSourceData.getConstArray();
- sal_Int32 nAttribs = rSourceData.getLength();
- for( sal_Int32 i = 0; i < nAttribs; i++, pAttribs++ )
+ for( const beans::PropertyValue& rAttrib : rSourceData )
{
- SAL_INFO("sdext.pdfimport", "importer Attrib: " << pAttribs->Name );
- if ( pAttribs->Name == "InputStream" )
- pAttribs->Value >>= xInput;
- else if ( pAttribs->Name == "URL" )
- pAttribs->Value >>= aURL;
- else if ( pAttribs->Name == "StatusIndicator" )
- pAttribs->Value >>= xStatus;
- else if ( pAttribs->Name == "InteractionHandler" )
- pAttribs->Value >>= xInteractionHandler;
- else if ( pAttribs->Name == "Password" )
- pAttribs->Value >>= aPwd;
- else if ( pAttribs->Name == "FilterOptions" )
- pAttribs->Value >>= aFilterOptions;
+ SAL_INFO("sdext.pdfimport", "importer Attrib: " << rAttrib.Name );
+ if ( rAttrib.Name == "InputStream" )
+ rAttrib.Value >>= xInput;
+ else if ( rAttrib.Name == "URL" )
+ rAttrib.Value >>= aURL;
+ else if ( rAttrib.Name == "StatusIndicator" )
+ rAttrib.Value >>= xStatus;
+ else if ( rAttrib.Name == "InteractionHandler" )
+ rAttrib.Value >>= xInteractionHandler;
+ else if ( rAttrib.Name == "Password" )
+ rAttrib.Value >>= aPwd;
+ else if ( rAttrib.Name == "FilterOptions" )
+ rAttrib.Value >>= aFilterOptions;
}
if( !xInput.is() )
return false;
diff --git a/sdext/source/presenter/PresenterAccessibility.cxx b/sdext/source/presenter/PresenterAccessibility.cxx
index bf2ed293cac5..0febc4f41122 100644
--- a/sdext/source/presenter/PresenterAccessibility.cxx
+++ b/sdext/source/presenter/PresenterAccessibility.cxx
@@ -701,7 +701,7 @@ void SAL_CALL PresenterAccessible::disposing (const css::lang::EventObject& rEve
void SAL_CALL PresenterAccessible::initialize (const css::uno::Sequence<css::uno::Any>& rArguments)
{
- if (rArguments.getLength() >= 1)
+ if (rArguments.hasElements())
{
mxAccessibleParent.set(rArguments[0], UNO_QUERY);
if (mpAccessibleConsole.is())
@@ -1257,12 +1257,8 @@ sal_Bool SAL_CALL AccessibleStateSet::contains (sal_Int16 nState)
sal_Bool SAL_CALL AccessibleStateSet::containsAll (const css::uno::Sequence<sal_Int16>& rStateSet)
{
- for (sal_Int32 nIndex=0,nCount=rStateSet.getLength(); nIndex<nCount; ++nIndex)
- {
- if ((mnStateSet & GetStateMask(rStateSet[nIndex])) == 0)
- return false;
- }
- return true;
+ return std::none_of(rStateSet.begin(), rStateSet.end(),
+ [this](const sal_Int16 nState) { return (mnStateSet & GetStateMask(nState)) == 0; });
}
css::uno::Sequence<sal_Int16> SAL_CALL AccessibleStateSet::getStates()
diff --git a/sdext/source/presenter/PresenterConfigurationAccess.cxx b/sdext/source/presenter/PresenterConfigurationAccess.cxx
index 58fc6a6d058f..1331addbffa1 100644
--- a/sdext/source/presenter/PresenterConfigurationAccess.cxx
+++ b/sdext/source/presenter/PresenterConfigurationAccess.cxx
@@ -182,10 +182,9 @@ void PresenterConfigurationAccess::ForAll (
::std::vector<Any> aValues(rArguments.size());
Sequence<OUString> aKeys (rxContainer->getElementNames());
- for (sal_Int32 nItemIndex=0; nItemIndex<aKeys.getLength(); ++nItemIndex)
+ for (const OUString& rsKey : aKeys)
{
bool bHasAllValues (true);
- const OUString& rsKey (aKeys[nItemIndex]);
Reference<container::XNameAccess> xSetItem (rxContainer->getByName(rsKey), UNO_QUERY);
Reference<beans::XPropertySet> xSet (xSetItem, UNO_QUERY);
OSL_ASSERT(xSet.is());
@@ -215,9 +214,8 @@ void PresenterConfigurationAccess::ForAll (
if (rxContainer.is())
{
Sequence<OUString> aKeys (rxContainer->getElementNames());
- for (sal_Int32 nItemIndex=0; nItemIndex<aKeys.getLength(); ++nItemIndex)
+ for (const OUString& rsKey : aKeys)
{
- const OUString& rsKey (aKeys[nItemIndex]);
Reference<beans::XPropertySet> xSet (rxContainer->getByName(rsKey), UNO_QUERY);
if (xSet.is())
rProcessor(rsKey, xSet);
@@ -232,13 +230,13 @@ Any PresenterConfigurationAccess::Find (
if (rxContainer.is())
{
Sequence<OUString> aKeys (rxContainer->getElementNames());
- for (sal_Int32 nItemIndex=0; nItemIndex<aKeys.getLength(); ++nItemIndex)
+ for (const auto& rKey : aKeys)
{
Reference<beans::XPropertySet> xProperties (
- rxContainer->getByName(aKeys[nItemIndex]),
+ rxContainer->getByName(rKey),
UNO_QUERY);
if (xProperties.is())
- if (rPredicate(aKeys[nItemIndex], xProperties))
+ if (rPredicate(rKey, xProperties))
return Any(xProperties);
}
}
diff --git a/sdext/source/presenter/PresenterScreen.cxx b/sdext/source/presenter/PresenterScreen.cxx
index 9e73456ff1bd..8689934bf58d 100644
--- a/sdext/source/presenter/PresenterScreen.cxx
+++ b/sdext/source/presenter/PresenterScreen.cxx
@@ -128,30 +128,16 @@ Any SAL_CALL PresenterScreenJob::execute(
const Sequence< beans::NamedValue >& Arguments )
{
Sequence< beans::NamedValue > lEnv;
-
- sal_Int32 i = 0;
- sal_Int32 c = Arguments.getLength();
- const beans::NamedValue* p = Arguments.getConstArray();
- for (i=0; i<c; ++i)
- {
- if ( p[i].Name == "Environment" )
- {
- p[i].Value >>= lEnv;
- break;
- }
- }
+ auto pArg = std::find_if(Arguments.begin(), Arguments.end(),
+ [](const beans::NamedValue& rArg) { return rArg.Name == "Environment"; });
+ if (pArg != Arguments.end())
+ pArg->Value >>= lEnv;
Reference<frame::XModel2> xModel;
- c = lEnv.getLength();
- p = lEnv.getConstArray();
- for (i=0; i<c; ++i)
- {
- if ( p[i].Name == "Model" )
- {
- p[i].Value >>= xModel;
- break;
- }
- }
+ auto pProp = std::find_if(lEnv.begin(), lEnv.end(),
+ [](const beans::NamedValue& rProp) { return rProp.Name == "Model"; });
+ if (pProp != lEnv.end())
+ pProp->Value >>= xModel;
Reference< XServiceInfo > xInfo( xModel, UNO_QUERY );
if( xInfo.is() && xInfo->supportsService("com.sun.star.presentation.PresentationDocument") )
diff --git a/sdext/source/presenter/PresenterTheme.cxx b/sdext/source/presenter/PresenterTheme.cxx
index 751332d5e00e..53522ec77e1a 100644
--- a/sdext/source/presenter/PresenterTheme.cxx
+++ b/sdext/source/presenter/PresenterTheme.cxx
@@ -32,6 +32,7 @@
#include <com/sun/star/util/Color.hpp>
#include <osl/diagnose.h>
#include <map>
+#include <numeric>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -330,13 +331,8 @@ bool PresenterTheme::ConvertToColor (
Sequence<sal_Int8> aByteSequence;
if (rColorSequence >>= aByteSequence)
{
- const sal_Int32 nByteCount (aByteSequence.getLength());
- const sal_uInt8* pArray = reinterpret_cast<const sal_uInt8*>(aByteSequence.getConstArray());
- rColor = 0;
- for (sal_Int32 nIndex=0; nIndex<nByteCount; ++nIndex)
- {
- rColor = (rColor << 8) | *pArray++;
- }
+ rColor = std::accumulate(aByteSequence.begin(), aByteSequence.end(), sal_uInt32(0),
+ [](const sal_uInt32 nRes, const sal_uInt8 nByte) { return (nRes << 8) | nByte; });
return true;
}
else
@@ -763,9 +759,8 @@ std::shared_ptr<PresenterTheme::Theme> ReadContext::ReadTheme (
{
// Iterate over all themes and search the one with the given name.
Sequence<OUString> aKeys (xThemes->getElementNames());
- for (sal_Int32 nItemIndex=0; nItemIndex < aKeys.getLength(); ++nItemIndex)
+ for (const OUString& rsKey : aKeys)
{
- const OUString& rsKey (aKeys[nItemIndex]);
Reference<container::XHierarchicalNameAccess> xTheme (
xThemes->getByName(rsKey), UNO_QUERY);
if (xTheme.is())