summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-05-12 16:07:58 +0300
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-06-11 20:32:49 +0200
commit79d58ee14da8fbf636fb087453834abb7173d3fc (patch)
tree2eda9470235311bdfaf542ceeaf8237406458015 /xmloff
parentc88f76035cd1d088cc06067270677618340fd839 (diff)
Simplify Sequence iterations in xmloff/source/{style..xforms}
Use range-based loops or replace with comphelper or STL functions Change-Id: Ie268d80b9c01d38c745c14a81c219d9930860562 Reviewed-on: https://gerrit.libreoffice.org/72189 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/style/AttributeContainerHandler.cxx13
-rw-r--r--xmloff/source/style/XMLPageExport.cxx6
-rw-r--r--xmloff/source/style/styleexp.cxx14
-rw-r--r--xmloff/source/style/tabsthdl.cxx32
-rw-r--r--xmloff/source/style/xmlexppr.cxx28
-rw-r--r--xmloff/source/style/xmlimppr.cxx45
-rw-r--r--xmloff/source/style/xmlnume.cxx6
-rw-r--r--xmloff/source/style/xmlnumfe.cxx20
-rw-r--r--xmloff/source/style/xmltabe.cxx9
-rw-r--r--xmloff/source/table/XMLTableExport.cxx17
-rw-r--r--xmloff/source/table/XMLTableImport.cxx12
-rw-r--r--xmloff/source/text/XMLAutoTextEventImport.cxx9
-rw-r--r--xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx22
-rw-r--r--xmloff/source/text/XMLRedlineExport.cxx21
-rw-r--r--xmloff/source/text/XMLSectionExport.cxx62
-rw-r--r--xmloff/source/text/XMLTextCharStyleNamesElementExport.cxx7
-rw-r--r--xmloff/source/text/XMLTextColumnsExport.cxx10
-rw-r--r--xmloff/source/text/XMLTextNumRuleInfo.cxx14
-rw-r--r--xmloff/source/text/txtflde.cxx57
-rw-r--r--xmloff/source/text/txtfldi.cxx17
-rw-r--r--xmloff/source/text/txtimp.cxx16
-rw-r--r--xmloff/source/text/txtprhdl.cxx24
-rw-r--r--xmloff/source/transform/OOo2Oasis.cxx3
-rw-r--r--xmloff/source/transform/TransformerBase.cxx17
-rw-r--r--xmloff/source/xforms/xformsapi.cxx9
-rw-r--r--xmloff/source/xforms/xformsexport.cxx19
26 files changed, 177 insertions, 332 deletions
diff --git a/xmloff/source/style/AttributeContainerHandler.cxx b/xmloff/source/style/AttributeContainerHandler.cxx
index 2c6a1857dd9b..5db11689e28d 100644
--- a/xmloff/source/style/AttributeContainerHandler.cxx
+++ b/xmloff/source/style/AttributeContainerHandler.cxx
@@ -49,22 +49,19 @@ bool XMLAttributeContainerHandler::equals(
{
uno::Sequence< OUString > aAttribNames1( xContainer1->getElementNames() );
uno::Sequence< OUString > aAttribNames2( xContainer2->getElementNames() );
- const sal_Int32 nCount = aAttribNames1.getLength();
- if( aAttribNames2.getLength() == nCount )
+ if( aAttribNames1.getLength() == aAttribNames2.getLength() )
{
- const OUString* pAttribName = aAttribNames1.getConstArray();
-
xml::AttributeData aData1;
xml::AttributeData aData2;
- for( sal_Int32 i=0; i < nCount; i++, pAttribName++ )
+ for( const OUString& rAttribName : aAttribNames1 )
{
- if( !xContainer2->hasByName( *pAttribName ) )
+ if( !xContainer2->hasByName( rAttribName ) )
return false;
- xContainer1->getByName( *pAttribName ) >>= aData1;
- xContainer2->getByName( *pAttribName ) >>= aData2;
+ xContainer1->getByName( rAttribName ) >>= aData1;
+ xContainer2->getByName( rAttribName ) >>= aData2;
if( ( aData1.Namespace != aData2.Namespace ) ||
( aData1.Type != aData2.Type ) ||
diff --git a/xmloff/source/style/XMLPageExport.cxx b/xmloff/source/style/XMLPageExport.cxx
index c5f3efe60c46..64c7645e4980 100644
--- a/xmloff/source/style/XMLPageExport.cxx
+++ b/xmloff/source/style/XMLPageExport.cxx
@@ -200,11 +200,9 @@ void XMLPageExport::exportStyles( bool bUsed, bool bAutoStyles )
if( xPageStyles.is() )
{
uno::Sequence< OUString> aSeq = xPageStyles->getElementNames();
- const OUString* pIter = aSeq.getConstArray();
- const OUString* pEnd = pIter + aSeq.getLength();
- for(;pIter != pEnd;++pIter)
+ for(const auto& rName : aSeq)
{
- Reference< XStyle > xStyle(xPageStyles->getByName( *pIter ),uno::UNO_QUERY);
+ Reference< XStyle > xStyle(xPageStyles->getByName( rName ),uno::UNO_QUERY);
if( !bUsed || xStyle->isInUse() )
exportStyle( xStyle, bAutoStyles );
}
diff --git a/xmloff/source/style/styleexp.cxx b/xmloff/source/style/styleexp.cxx
index 963d127c12ff..e7f39c6314fe 100644
--- a/xmloff/source/style/styleexp.cxx
+++ b/xmloff/source/style/styleexp.cxx
@@ -90,9 +90,8 @@ void XMLStyleExport::exportStyleContent( const Reference< XStyle >& rStyle )
aProperty >>= aSeq;
- for (sal_Int32 i = 0; i < aSeq.getLength(); ++i)
+ for (beans::NamedValue const& rNamedCond : aSeq)
{
- beans::NamedValue const& rNamedCond = aSeq[i];
OUString aStyleName;
if (rNamedCond.Value >>= aStyleName)
@@ -444,14 +443,12 @@ void XMLStyleExport::exportStyleFamily(
bool bFirstStyle = true;
const uno::Sequence< OUString> aSeq = xStyleCont->getElementNames();
- const OUString* pIter = aSeq.getConstArray();
- const OUString* pEnd = pIter + aSeq.getLength();
- for(;pIter != pEnd;++pIter)
+ for(const auto& rName : aSeq)
{
Reference< XStyle > xStyle;
try
{
- xStyleCont->getByName( *pIter ) >>= xStyle;
+ xStyleCont->getByName( rName ) >>= xStyle;
}
catch(const lang::IndexOutOfBoundsException&)
{
@@ -501,11 +498,10 @@ void XMLStyleExport::exportStyleFamily(
{
// if next styles are supported, export all next styles that are
// unused and that for, haven't been exported in the first loop.
- pIter = aSeq.getConstArray();
- for(;pIter != pEnd;++pIter)
+ for(const auto& rName : aSeq)
{
Reference< XStyle > xStyle;
- xStyleCont->getByName( *pIter ) >>= xStyle;
+ xStyleCont->getByName( rName ) >>= xStyle;
assert(xStyle.is());
diff --git a/xmloff/source/style/tabsthdl.cxx b/xmloff/source/style/tabsthdl.cxx
index c70e73f1dc9c..bb110477e896 100644
--- a/xmloff/source/style/tabsthdl.cxx
+++ b/xmloff/source/style/tabsthdl.cxx
@@ -34,39 +34,23 @@ XMLTabStopPropHdl::~XMLTabStopPropHdl()
bool XMLTabStopPropHdl::equals( const uno::Any& r1, const uno::Any& r2 ) const
{
- bool bEqual = false;
-
uno::Sequence< style::TabStop> aSeq1;
if( r1 >>= aSeq1 )
{
uno::Sequence< style::TabStop> aSeq2;
if( r2 >>= aSeq2 )
{
- if( aSeq1.getLength() == aSeq2.getLength() )
- {
- bEqual = true;
- if( aSeq1.hasElements() )
- {
- const style::TabStop* pTabs1 = aSeq1.getConstArray();
- const style::TabStop* pTabs2 = aSeq2.getConstArray();
-
- int i=0;
-
- do
- {
- bEqual = ( pTabs1[i].Position == pTabs2[i].Position &&
- pTabs1[i].Alignment == pTabs2[i].Alignment &&
- pTabs1[i].DecimalChar == pTabs2[i].DecimalChar &&
- pTabs1[i].FillChar == pTabs2[i].FillChar );
- i++;
-
- } while( bEqual && i < aSeq1.getLength() );
- }
- }
+ return std::equal(aSeq1.begin(), aSeq1.end(), aSeq2.begin(), aSeq2.end(),
+ [](const style::TabStop& a, const style::TabStop& b) {
+ return a.Position == b.Position
+ && a.Alignment == b.Alignment
+ && a.DecimalChar == b.DecimalChar
+ && a.FillChar == b.FillChar;
+ });
}
}
- return bEqual;
+ return false;
}
bool XMLTabStopPropHdl::importXML( const OUString&, css::uno::Any&, const SvXMLUnitConverter& ) const
diff --git a/xmloff/source/style/xmlexppr.cxx b/xmloff/source/style/xmlexppr.cxx
index aa465016bb7f..a0ed1e483d9d 100644
--- a/xmloff/source/style/xmlexppr.cxx
+++ b/xmloff/source/style/xmlexppr.cxx
@@ -318,18 +318,16 @@ void FilterPropertiesInfo_Impl::FillPropertyStateArray(
{
Sequence < beans::GetPropertyTolerantResult > aResults(xTolPropSet->getPropertyValuesTolerant(rApiNames));
OSL_ENSURE( rApiNames.getLength() == aResults.getLength(), "wrong implemented XTolerantMultiPropertySet" );
- const beans::GetPropertyTolerantResult *pResults = aResults.getConstArray();
FilterPropertyInfoList_Impl::iterator aPropIter(aPropInfos.begin());
XMLPropertyState aNewProperty( -1 );
- sal_uInt32 nResultCount(aResults.getLength());
- OSL_ENSURE( nCount == nResultCount, "wrong implemented XTolerantMultiPropertySet??" );
- for( sal_uInt32 i = 0; i < nResultCount; ++i )
+ OSL_ENSURE( nCount == static_cast<sal_uInt32>(aResults.getLength()), "wrong implemented XTolerantMultiPropertySet??" );
+ for( const auto& rResult : aResults )
{
- if ((pResults->Result == beans::TolerantPropertySetResultType::SUCCESS) &&
- ((pResults->State == PropertyState_DIRECT_VALUE) || (pResults->State == PropertyState_DEFAULT_VALUE)))
+ if ((rResult.Result == beans::TolerantPropertySetResultType::SUCCESS) &&
+ ((rResult.State == PropertyState_DIRECT_VALUE) || (rResult.State == PropertyState_DEFAULT_VALUE)))
{
aNewProperty.mnIndex = -1;
- aNewProperty.maValue = pResults->Value;
+ aNewProperty.maValue = rResult.Value;
for (auto const& index : aPropIter->GetIndexes())
{
@@ -337,7 +335,6 @@ void FilterPropertiesInfo_Impl::FillPropertyStateArray(
aPropStates.AddPropertyState( aNewProperty );
}
}
- ++pResults;
++aPropIter;
}
}
@@ -923,23 +920,20 @@ void SvXMLExportPropertyMapper::_exportXML(
const SvXMLNamespaceMap *pNamespaceMap = &rNamespaceMap;
uno::Sequence< OUString > aAttribNames( xAttrContainer->getElementNames() );
- const OUString* pAttribName = aAttribNames.getConstArray();
-
- const sal_Int32 nCount = aAttribNames.getLength();
OUStringBuffer sNameBuffer;
xml::AttributeData aData;
- for( sal_Int32 i=0; i < nCount; i++, pAttribName++ )
+ for( const auto& rAttribName : aAttribNames )
{
- xAttrContainer->getByName( *pAttribName ) >>= aData;
- OUString sAttribName( *pAttribName );
+ xAttrContainer->getByName( rAttribName ) >>= aData;
+ OUString sAttribName( rAttribName );
// extract namespace prefix from attribute name if it exists
OUString sPrefix;
const sal_Int32 nColonPos =
- pAttribName->indexOf( ':' );
+ rAttribName.indexOf( ':' );
if( nColonPos != -1 )
- sPrefix = pAttribName->copy( 0, nColonPos );
+ sPrefix = rAttribName.copy( 0, nColonPos );
if( !sPrefix.isEmpty() )
{
@@ -986,7 +980,7 @@ void SvXMLExportPropertyMapper::_exportXML(
sPrefix = pNamespaceMap->GetPrefixByKey( nKey );
}
// In any case, the attribute name has to be adapted.
- sNameBuffer.append(sPrefix).append(":").append(std::u16string_view(*pAttribName).substr(nColonPos+1) );
+ sNameBuffer.append(sPrefix).append(":").append(std::u16string_view(rAttribName).substr(nColonPos+1) );
sAttribName = sNameBuffer.makeStringAndClear();
}
diff --git a/xmloff/source/style/xmlimppr.cxx b/xmloff/source/style/xmlimppr.cxx
index 1790478651e3..8e86e80dcf46 100644
--- a/xmloff/source/style/xmlimppr.cxx
+++ b/xmloff/source/style/xmlimppr.cxx
@@ -689,34 +689,29 @@ bool SvXMLImportPropertyMapper::FillTolerantMultiPropertySet_(
try
{
Sequence< SetPropertyTolerantFailed > aResults(rTolMultiPropSet->setPropertyValuesTolerant( aNames, aValues ));
- if (!aResults.hasElements())
- bSuccessful = true;
- else
+ bSuccessful = !aResults.hasElements();
+ for( const auto& rResult : aResults)
{
- sal_Int32 nCount(aResults.getLength());
- for( sal_Int32 i = 0; i < nCount; ++i)
+ Sequence<OUString> aSeq { rResult.Name };
+ OUString sMessage;
+ switch (rResult.Result)
{
- Sequence<OUString> aSeq { aResults[i].Name };
- OUString sMessage;
- switch (aResults[i].Result)
- {
- case TolerantPropertySetResultType::UNKNOWN_PROPERTY :
- sMessage = "UNKNOWN_PROPERTY";
- break;
- case TolerantPropertySetResultType::ILLEGAL_ARGUMENT :
- sMessage = "ILLEGAL_ARGUMENT";
- break;
- case TolerantPropertySetResultType::PROPERTY_VETO :
- sMessage = "PROPERTY_VETO";
- break;
- case TolerantPropertySetResultType::WRAPPED_TARGET :
- sMessage = "WRAPPED_TARGET";
- break;
- };
- rImport.SetError(
- XMLERROR_STYLE_PROP_OTHER | XMLERROR_FLAG_ERROR,
- aSeq, sMessage, nullptr );
+ case TolerantPropertySetResultType::UNKNOWN_PROPERTY :
+ sMessage = "UNKNOWN_PROPERTY";
+ break;
+ case TolerantPropertySetResultType::ILLEGAL_ARGUMENT :
+ sMessage = "ILLEGAL_ARGUMENT";
+ break;
+ case TolerantPropertySetResultType::PROPERTY_VETO :
+ sMessage = "PROPERTY_VETO";
+ break;
+ case TolerantPropertySetResultType::WRAPPED_TARGET :
+ sMessage = "WRAPPED_TARGET";
+ break;
}
+ rImport.SetError(
+ XMLERROR_STYLE_PROP_OTHER | XMLERROR_FLAG_ERROR,
+ aSeq, sMessage, nullptr );
}
}
catch ( ... )
diff --git a/xmloff/source/style/xmlnume.cxx b/xmloff/source/style/xmlnume.cxx
index 40d128d52621..894707a7a541 100644
--- a/xmloff/source/style/xmlnume.cxx
+++ b/xmloff/source/style/xmlnume.cxx
@@ -107,12 +107,8 @@ void SvxXMLNumRuleExport::exportLevelStyle( sal_Int32 nLevel,
sal_Int32 nFirstLineIndent( 0 );
sal_Int32 nIndentAt( 0 );
- const sal_Int32 nCount = rProps.getLength();
- const beans::PropertyValue* pPropArray = rProps.getConstArray();
- for( sal_Int32 i=0; i<nCount; i++ )
+ for( const beans::PropertyValue& rProp : rProps )
{
- const beans::PropertyValue& rProp = pPropArray[i];
-
if( rProp.Name == "NumberingType" )
{
rProp.Value >>= eType;
diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx
index 98a8e72f17ce..80f8511499b3 100644
--- a/xmloff/source/style/xmlnumfe.cxx
+++ b/xmloff/source/style/xmlnumfe.cxx
@@ -194,11 +194,9 @@ uno::Sequence<sal_Int32> SvXMLNumUsedList_Impl::GetWasUsed()
void SvXMLNumUsedList_Impl::SetWasUsed(const uno::Sequence<sal_Int32>& rWasUsed)
{
DBG_ASSERT(nWasUsedCount == 0, "WasUsed should be empty");
- sal_Int32 nCount(rWasUsed.getLength());
- const sal_Int32* pWasUsed = rWasUsed.getConstArray();
- for (sal_Int32 i = 0; i < nCount; i++, pWasUsed++)
+ for (const auto nWasUsed : rWasUsed)
{
- std::pair<SvXMLuInt32Set::const_iterator, bool> aPair = aWasUsed.insert( *pWasUsed );
+ std::pair<SvXMLuInt32Set::const_iterator, bool> aPair = aWasUsed.insert( nWasUsed );
if (aPair.second)
nWasUsedCount++;
}
@@ -929,16 +927,10 @@ static OUString lcl_GetDefaultCalendar( SvNumberFormatter const * pFormatter, La
lang::Locale aLocale( LanguageTag::convertToLocale( nLang ) );
uno::Sequence<OUString> aCals = pCalendar->getAllCalendars( aLocale );
- sal_Int32 nCnt = aCals.getLength();
- bool bFound = false;
- for ( sal_Int32 j=0; j < nCnt && !bFound; j++ )
- {
- if ( aCals[j] != "gregorian" )
- {
- aCalendar = aCals[j];
- bFound = true;
- }
- }
+ auto pCal = std::find_if(aCals.begin(), aCals.end(),
+ [](const OUString& rCal) { return rCal != "gregorian"; });
+ if (pCal != aCals.end())
+ aCalendar = *pCal;
}
return aCalendar;
}
diff --git a/xmloff/source/style/xmltabe.cxx b/xmloff/source/style/xmltabe.cxx
index b30f0d3e6b3a..63cb2ce79f94 100644
--- a/xmloff/source/style/xmltabe.cxx
+++ b/xmloff/source/style/xmltabe.cxx
@@ -110,16 +110,13 @@ void SvxXMLTabStopExport::Export( const uno::Any& rAny )
}
else
{
- const css::style::TabStop* pTabs = aSeq.getConstArray();
- const sal_Int32 nTabs = aSeq.getLength();
-
SvXMLElementExport rElem( rExport, XML_NAMESPACE_STYLE, XML_TAB_STOPS,
true, true );
- for( sal_Int32 nIndex = 0; nIndex < nTabs; nIndex++ )
+ for( const auto& rTab : aSeq )
{
- if( style::TabAlign_DEFAULT != pTabs[nIndex].Alignment )
- exportTabStop( &(pTabs[nIndex]) );
+ if( style::TabAlign_DEFAULT != rTab.Alignment )
+ exportTabStop( &rTab );
}
}
}
diff --git a/xmloff/source/table/XMLTableExport.cxx b/xmloff/source/table/XMLTableExport.cxx
index 228ce12d1233..b1e79f7f8733 100644
--- a/xmloff/source/table/XMLTableExport.cxx
+++ b/xmloff/source/table/XMLTableExport.cxx
@@ -155,17 +155,14 @@ XMLTableExport::XMLTableExport(SvXMLExport& rExp, const rtl::Reference< SvXMLExp
if( xFac.is() ) try
{
Sequence< OUString > sSNS( xFac->getAvailableServiceNames() );
- sal_Int32 n = sSNS.getLength();
- const OUString* pSNS( sSNS.getConstArray() );
- while( --n > 0 )
+ const OUString* pSNS = std::find_if(sSNS.begin(), sSNS.end(),
+ [](const OUString& rSNS) {
+ return rSNS == "com.sun.star.drawing.TableShape"
+ || rSNS == "com.sun.star.style.TableStyle"; });
+ if (pSNS != sSNS.end())
{
- if( *pSNS == "com.sun.star.drawing.TableShape" || *pSNS == "com.sun.star.style.TableStyle" )
- {
- mbExportTables = true;
- mbWriter = (*pSNS == "com.sun.star.style.TableStyle");
- break;
- }
- pSNS++;
+ mbExportTables = true;
+ mbWriter = (*pSNS == "com.sun.star.style.TableStyle");
}
}
catch(const Exception&)
diff --git a/xmloff/source/table/XMLTableImport.cxx b/xmloff/source/table/XMLTableImport.cxx
index 2cf7423f6411..717b13c68afa 100644
--- a/xmloff/source/table/XMLTableImport.cxx
+++ b/xmloff/source/table/XMLTableImport.cxx
@@ -27,6 +27,7 @@
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/style/XStyle.hpp>
+#include <comphelper/sequence.hxx>
#include <tools/diagnose_ex.h>
#include <xmloff/table/XMLTableImport.hxx>
@@ -194,16 +195,7 @@ XMLTableImport::XMLTableImport( SvXMLImport& rImport, const rtl::Reference< XMLP
if (xFac.is()) try
{
Sequence<OUString> sSNS = xFac->getAvailableServiceNames();
- const sal_Int32 nLength = sSNS.getLength();
- const OUString* pSNS = sSNS.getConstArray();
- for (sal_Int32 i=0; i < nLength; ++i, ++pSNS)
- {
- if (*pSNS == "com.sun.star.style.TableStyle")
- {
- bWriter = true;
- break;
- }
- }
+ bWriter = comphelper::findValue(sSNS, "com.sun.star.style.TableStyle") != -1;
}
catch(const Exception&)
{
diff --git a/xmloff/source/text/XMLAutoTextEventImport.cxx b/xmloff/source/text/XMLAutoTextEventImport.cxx
index b1059c1ae5c6..385aa707ffd3 100644
--- a/xmloff/source/text/XMLAutoTextEventImport.cxx
+++ b/xmloff/source/text/XMLAutoTextEventImport.cxx
@@ -61,21 +61,20 @@ void XMLAutoTextEventImport::initialize(
{
// The events may come as either an XNameReplace or XEventsSupplier.
- const sal_Int32 nLength = rArguments.getLength();
- for( sal_Int32 i = 0; i < nLength; i++ )
+ for( const auto& rArgument : rArguments )
{
- const Type& rType = rArguments[i].getValueType();
+ const Type& rType = rArgument.getValueType();
if ( rType == cppu::UnoType<XEventsSupplier>::get())
{
Reference<XEventsSupplier> xSupplier;
- rArguments[i] >>= xSupplier;
+ rArgument >>= xSupplier;
DBG_ASSERT(xSupplier.is(), "need XEventsSupplier or XNameReplace");
xEvents = xSupplier->getEvents();
}
else if (rType == cppu::UnoType<XNameReplace>::get())
{
- rArguments[i] >>= xEvents;
+ rArgument >>= xEvents;
DBG_ASSERT(xEvents.is(), "need XEventsSupplier or XNameReplace");
}
}
diff --git a/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx b/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx
index b84bc32b38a6..17b3c3d64e14 100644
--- a/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx
+++ b/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx
@@ -30,6 +30,7 @@
#include <rtl/ustring.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <comphelper/sequence.hxx>
using namespace ::com::sun::star::text;
using namespace ::com::sun::star::uno;
@@ -223,18 +224,8 @@ void XMLIndexBibliographyConfigurationContext::CreateAndInsert(bool)
if( xFactory.is() )
{
Sequence<OUString> aServices = xFactory->getAvailableServiceNames();
- bool bFound(false);
- sal_Int32 i(0);
- sal_Int32 nServiceCount(aServices.getLength());
- while (i < nServiceCount && !bFound)
- {
- if (aServices[i] == gsFieldMaster_Bibliography)
- // here we should use a method which compares in reverse order if available
- bFound = true;
- else
- i++;
- }
- if (bFound)
+ // here we should use a method which compares in reverse order if available
+ if (comphelper::findValue(aServices, gsFieldMaster_Bibliography) != -1)
{
Reference<XInterface> xIfc =
xFactory->createInstance(gsFieldMaster_Bibliography);
@@ -259,12 +250,7 @@ void XMLIndexBibliographyConfigurationContext::CreateAndInsert(bool)
xPropSet->setPropertyValue(gsSortAlgorithm, Any(sAlgorithm));
}
- sal_Int32 nCount = aSortKeys.size();
- Sequence<Sequence<PropertyValue> > aKeysSeq(nCount);
- for(i = 0; i < nCount; i++)
- {
- aKeysSeq[i] = aSortKeys[i];
- }
+ Sequence<Sequence<PropertyValue> > aKeysSeq = comphelper::containerToSequence(aSortKeys);
xPropSet->setPropertyValue(gsSortKeys, Any(aKeysSeq));
}
// else: can't get FieldMaster -> ignore
diff --git a/xmloff/source/text/XMLRedlineExport.cxx b/xmloff/source/text/XMLRedlineExport.cxx
index 7e21cacd9a88..7a8a7e832df0 100644
--- a/xmloff/source/text/XMLRedlineExport.cxx
+++ b/xmloff/source/text/XMLRedlineExport.cxx
@@ -470,11 +470,8 @@ void XMLRedlineExport::ExportChangeInfo(
{
OUString sComment;
- sal_Int32 nCount = rPropertyValues.getLength();
- for(sal_Int32 i = 0; i < nCount; i++)
+ for(const PropertyValue& rVal : rPropertyValues)
{
- const PropertyValue& rVal = rPropertyValues[i];
-
if( rVal.Name == "RedlineAuthor" )
{
OUString sTmp;
@@ -536,28 +533,26 @@ void XMLRedlineExport::ExportStartOrEndRedline(
Sequence<PropertyValue> aValues;
aAny >>= aValues;
- const PropertyValue* pValues = aValues.getConstArray();
// seek for redline properties
bool bIsCollapsed = false;
bool bIsStart = true;
OUString sId;
bool bIdOK = false; // have we seen an ID?
- sal_Int32 nLength = aValues.getLength();
- for(sal_Int32 i = 0; i < nLength; i++)
+ for(const auto& rValue : aValues)
{
- if (pValues[i].Name == "RedlineIdentifier")
+ if (rValue.Name == "RedlineIdentifier")
{
- pValues[i].Value >>= sId;
+ rValue.Value >>= sId;
bIdOK = true;
}
- else if (pValues[i].Name == "IsCollapsed")
+ else if (rValue.Name == "IsCollapsed")
{
- bIsCollapsed = *o3tl::doAccess<bool>(pValues[i].Value);
+ bIsCollapsed = *o3tl::doAccess<bool>(rValue.Value);
}
- else if (pValues[i].Name == "IsStart")
+ else if (rValue.Name == "IsStart")
{
- bIsStart = *o3tl::doAccess<bool>(pValues[i].Value);
+ bIsStart = *o3tl::doAccess<bool>(rValue.Value);
}
}
diff --git a/xmloff/source/text/XMLSectionExport.cxx b/xmloff/source/text/XMLSectionExport.cxx
index ed9e9e2e6cae..f01dd7d16879 100644
--- a/xmloff/source/text/XMLSectionExport.cxx
+++ b/xmloff/source/text/XMLSectionExport.cxx
@@ -1035,14 +1035,11 @@ bool XMLSectionExport::ExportIndexTemplate(
true, true);
// export sequence
- sal_Int32 nTemplateCount = rValues.getLength();
- for(sal_Int32 nTemplateNo = 0;
- nTemplateNo < nTemplateCount;
- nTemplateNo++)
+ for(auto& rValue : rValues)
{
ExportIndexTemplateElement(
eType, //i90246
- rValues[nTemplateNo]);
+ rValue);
}
}
@@ -1192,11 +1189,10 @@ void XMLSectionExport::ExportIndexTemplateElement(
// token type
enum TemplateTypeEnum nTokenType = TOK_TTYPE_INVALID;
- sal_Int32 nCount = rValues.getLength();
- for(sal_Int32 i = 0; i<nCount; i++)
+ for(const auto& rValue : rValues)
{
TemplateParamEnum nToken;
- if ( SvXMLUnitConverter::convertEnum( nToken, rValues[i].Name,
+ if ( SvXMLUnitConverter::convertEnum( nToken, rValue.Name,
aTemplateParamMap ) )
{
// Only use direct and default values.
@@ -1209,54 +1205,54 @@ void XMLSectionExport::ExportIndexTemplateElement(
case TOK_TPARAM_TOKEN_TYPE:
{
OUString sVal;
- rValues[i].Value >>= sVal;
+ rValue.Value >>= sVal;
SvXMLUnitConverter::convertEnum( nTokenType, sVal, aTemplateTypeMap);
break;
}
case TOK_TPARAM_CHAR_STYLE:
// only valid, if not empty
- rValues[i].Value >>= sCharStyle;
+ rValue.Value >>= sCharStyle;
bCharStyleOK = !sCharStyle.isEmpty();
break;
case TOK_TPARAM_TEXT:
- rValues[i].Value >>= sText;
+ rValue.Value >>= sText;
bTextOK = true;
break;
case TOK_TPARAM_TAB_RIGHT_ALIGNED:
bRightAligned =
- *o3tl::doAccess<bool>(rValues[i].Value);
+ *o3tl::doAccess<bool>(rValue.Value);
break;
case TOK_TPARAM_TAB_POSITION:
- rValues[i].Value >>= nTabPosition;
+ rValue.Value >>= nTabPosition;
bTabPositionOK = true;
break;
// #i21237#
case TOK_TPARAM_TAB_WITH_TAB:
- bWithTabStop = *o3tl::doAccess<bool>(rValues[i].Value);
+ bWithTabStop = *o3tl::doAccess<bool>(rValue.Value);
bWithTabStopOK = true;
break;
case TOK_TPARAM_TAB_FILL_CHAR:
- rValues[i].Value >>= sFillChar;
+ rValue.Value >>= sFillChar;
bFillCharOK = true;
break;
case TOK_TPARAM_CHAPTER_FORMAT:
- rValues[i].Value >>= nChapterFormat;
+ rValue.Value >>= nChapterFormat;
bChapterFormatOK = true;
break;
//---> i53420
case TOK_TPARAM_CHAPTER_LEVEL:
- rValues[i].Value >>= nLevel;
+ rValue.Value >>= nLevel;
bLevelOK = true;
break;
case TOK_TPARAM_BIBLIOGRAPHY_DATA:
- rValues[i].Value >>= nBibliographyData;
+ rValue.Value >>= nBibliographyData;
bBibliographyDataOK = true;
break;
}
@@ -1514,8 +1510,7 @@ void XMLSectionExport::ExportLevelParagraphStyles(
aAny >>= aStyleNames;
// export only if at least one style is contained
- sal_Int32 nNamesCount = aStyleNames.getLength();
- if (nNamesCount > 0)
+ if (aStyleNames.hasElements())
{
// level attribute; we count 1..10; API 0..9
sal_Int32 nLevelPlusOne = nLevel + 1;
@@ -1530,12 +1525,12 @@ void XMLSectionExport::ExportLevelParagraphStyles(
true, true);
// iterate over styles in this level
- for(sal_Int32 nName = 0; nName < nNamesCount; nName++)
+ for(const auto& rStyleName : aStyleNames)
{
// stylename attribute
GetExport().AddAttribute(XML_NAMESPACE_TEXT,
XML_STYLE_NAME,
- GetExport().EncodeStyleName( aStyleNames[nName]) );
+ GetExport().EncodeStyleName(rStyleName) );
// element
SvXMLElementExport aParaStyle(GetExport(),
@@ -1648,16 +1643,10 @@ void XMLSectionExport::ExportBibliographyConfiguration(SvXMLExport& rExport)
aAny = xPropSet->getPropertyValue(sSortKeys);
Sequence<Sequence<PropertyValue> > aKeys;
aAny >>= aKeys;
- sal_Int32 nKeysCount = aKeys.getLength();
- for(sal_Int32 nKeys = 0; nKeys < nKeysCount; nKeys++)
+ for(Sequence<PropertyValue> & rKey : aKeys)
{
- Sequence<PropertyValue> & rKey = aKeys[nKeys];
-
- sal_Int32 nKeyCount = rKey.getLength();
- for(sal_Int32 nPropertyKey = 0; nPropertyKey < nKeyCount; nPropertyKey++)
+ for(PropertyValue& rValue : rKey)
{
- PropertyValue& rValue = rKey[nPropertyKey];
-
if (rValue.Name == "SortKey")
{
sal_Int16 nKey = 0;
@@ -1817,14 +1806,11 @@ void XMLSectionExport::ExportMasterDocHeadingDummies()
OUString sStyle;
Sequence<PropertyValue> aProperties;
xChapterNumbering->getByIndex( nLevel ) >>= aProperties;
- for( sal_Int32 i = 0; i < aProperties.getLength(); i++ )
- {
- if( aProperties[i].Name == "HeadingStyleName" )
- {
- aProperties[i].Value >>= sStyle;
- break;
- }
- }
+ auto pProp = std::find_if(aProperties.begin(), aProperties.end(),
+ [](const PropertyValue& rProp) { return rProp.Name == "HeadingStyleName"; });
+ if (pProp != aProperties.end())
+ pProp->Value >>= sStyle;
+
if( !sStyle.isEmpty() )
{
GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME,
diff --git a/xmloff/source/text/XMLTextCharStyleNamesElementExport.cxx b/xmloff/source/text/XMLTextCharStyleNamesElementExport.cxx
index 55beb5f027f3..225eb6dcd246 100644
--- a/xmloff/source/text/XMLTextCharStyleNamesElementExport.cxx
+++ b/xmloff/source/text/XMLTextCharStyleNamesElementExport.cxx
@@ -54,14 +54,11 @@ XMLTextCharStyleNamesElementExport::XMLTextCharStyleNamesElementExport(
{
aName = rExport.GetNamespaceMap().GetQNameByKey(
XML_NAMESPACE_TEXT, GetXMLToken(XML_SPAN) );
- sal_Int32 i = nCount;
- const OUString *pName = aNames.getConstArray();
- while( --i )
+ for (const auto& rName : aNames)
{
rExport.AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME,
- rExport.EncodeStyleName( *pName ) );
+ rExport.EncodeStyleName( rName ) );
rExport.StartElement( aName, false );
- ++pName;
}
}
}
diff --git a/xmloff/source/text/XMLTextColumnsExport.cxx b/xmloff/source/text/XMLTextColumnsExport.cxx
index 84501d2f6653..ff7bb4e4c89d 100644
--- a/xmloff/source/text/XMLTextColumnsExport.cxx
+++ b/xmloff/source/text/XMLTextColumnsExport.cxx
@@ -63,7 +63,6 @@ void XMLTextColumnsExport::exportXML( const Any& rAny )
rAny >>= xColumns;
Sequence < TextColumn > aColumns = xColumns->getColumns();
- const TextColumn *pColumns = aColumns.getArray();
sal_Int32 nCount = aColumns.getLength();
OUStringBuffer sValue;
@@ -166,28 +165,27 @@ void XMLTextColumnsExport::exportXML( const Any& rAny )
}
}
- while( nCount-- )
+ for (const auto& rColumn : aColumns)
{
// style:rel-width
GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_REL_WIDTH,
- OUString::number(pColumns->Width) + "*" );
+ OUString::number(rColumn.Width) + "*" );
// fo:margin-left
GetExport().GetMM100UnitConverter().convertMeasureToXML( sValue,
- pColumns->LeftMargin );
+ rColumn.LeftMargin );
GetExport().AddAttribute( XML_NAMESPACE_FO, XML_START_INDENT,
sValue.makeStringAndClear() );
// fo:margin-right
GetExport().GetMM100UnitConverter().convertMeasureToXML( sValue,
- pColumns->RightMargin );
+ rColumn.RightMargin );
GetExport().AddAttribute( XML_NAMESPACE_FO, XML_END_INDENT,
sValue.makeStringAndClear() );
// style:column
SvXMLElementExport aElement( GetExport(), XML_NAMESPACE_STYLE, XML_COLUMN,
true, true );
- pColumns++;
}
}
diff --git a/xmloff/source/text/XMLTextNumRuleInfo.cxx b/xmloff/source/text/XMLTextNumRuleInfo.cxx
index 848fae8c9ae5..841711a46e27 100644
--- a/xmloff/source/text/XMLTextNumRuleInfo.cxx
+++ b/xmloff/source/text/XMLTextNumRuleInfo.cxx
@@ -177,17 +177,11 @@ void XMLTextNumRuleInfo::Set(
Sequence<PropertyValue> aProps;
mxNumRules->getByIndex( mnListLevel ) >>= aProps;
- const PropertyValue* pPropArray = aProps.getConstArray();
- sal_Int32 nCount = aProps.getLength();
- for( sal_Int32 i=0; i<nCount; i++ )
+ auto pProp = std::find_if(aProps.begin(), aProps.end(),
+ [](const PropertyValue& rProp) { return rProp.Name == "StartWith"; });
+ if (pProp != aProps.end())
{
- const PropertyValue& rProp = pPropArray[i];
-
- if ( rProp.Name == "StartWith" )
- {
- rProp.Value >>= mnListLevelStartValue;
- break;
- }
+ pProp->Value >>= mnListLevelStartValue;
}
msListLabelString.clear();
diff --git a/xmloff/source/text/txtflde.cxx b/xmloff/source/text/txtflde.cxx
index 293362b8ab10..8202d44e995d 100644
--- a/xmloff/source/text/txtflde.cxx
+++ b/xmloff/source/text/txtflde.cxx
@@ -392,40 +392,28 @@ enum FieldIdEnum XMLTextFieldExport::GetFieldID(
// get service names for rTextField (via XServiceInfo service)
Reference<XServiceInfo> xService(rTextField, UNO_QUERY);
const Sequence<OUString> aServices = xService->getSupportedServiceNames();
- const OUString* pNames = aServices.getConstArray();
- sal_Int32 nCount = aServices.getLength();
OUString sFieldName; // service name postfix of current field
// search for TextField service name
- while( nCount-- )
+ const OUString* pNames = std::find_if(aServices.begin(), aServices.end(),
+ [](const OUString& rName) { return rName.matchIgnoreAsciiCase(gsServicePrefix); });
+ if (pNames != aServices.end())
{
- if (pNames->matchIgnoreAsciiCase(gsServicePrefix))
- {
- // TextField found => postfix is field type!
- sFieldName = pNames->copy(gsServicePrefix.getLength());
- break;
- }
-
- ++pNames;
+ // TextField found => postfix is field type!
+ sFieldName = pNames->copy(gsServicePrefix.getLength());
}
// if this is not a normal text field, check if it's a presentation text field
if( sFieldName.isEmpty() )
{
- const OUString* pNames2 = aServices.getConstArray();
- sal_Int32 nCount2 = aServices.getLength();
// search for TextField service name
- while( nCount2-- )
+ pNames = std::find_if(aServices.begin(), aServices.end(),
+ [](const OUString& rName) { return rName.startsWith(gsPresentationServicePrefix); });
+ if (pNames != aServices.end())
{
- if( pNames2->startsWith(gsPresentationServicePrefix) )
- {
- // TextField found => postfix is field type!
- sFieldName = pNames2->copy(gsPresentationServicePrefix.getLength());
- break;
- }
-
- ++pNames2;
+ // TextField found => postfix is field type!
+ sFieldName = pNames->copy(gsPresentationServicePrefix.getLength());
}
if( !sFieldName.isEmpty() )
@@ -1963,10 +1951,7 @@ void XMLTextFieldExport::ExportFieldDeclarations(
aFieldMasters = xFieldMasterNameAccess->getElementNames();
}
- for(sal_Int32 i=0; i<aFieldMasters.getLength(); i++) {
-
- // get field master name
- OUString sFieldMaster = aFieldMasters[i];
+ for(const OUString& sFieldMaster : aFieldMasters) {
// workaround for #no-bug#
if ( sFieldMaster.startsWithIgnoreAsciiCase(
@@ -2707,13 +2692,12 @@ void XMLTextFieldExport::ProcessBibliographyData(
aAny >>= aValues;
// one attribute per value (unless empty)
- sal_Int32 nLength = aValues.getLength();
- for (sal_Int32 i = 0; i < nLength; i++)
+ for (const auto& rProp : aValues)
{
- if( aValues[i].Name == "BibiliographicType" )
+ if( rProp.Name == "BibiliographicType" )
{
sal_Int16 nTypeId = 0;
- aValues[i].Value >>= nTypeId;
+ rProp.Value >>= nTypeId;
OUStringBuffer sBuf;
if (SvXMLUnitConverter::convertEnum(sBuf, nTypeId,
@@ -2728,12 +2712,12 @@ void XMLTextFieldExport::ProcessBibliographyData(
else
{
OUString sStr;
- aValues[i].Value >>= sStr;
+ rProp.Value >>= sStr;
if (!sStr.isEmpty())
{
rExport.AddAttribute(XML_NAMESPACE_TEXT,
- MapBibliographyFieldName(aValues[i].Name),
+ MapBibliographyFieldName(rProp.Name),
sStr);
}
}
@@ -2762,14 +2746,7 @@ void XMLTextFieldExport::ProcessStringSequence(
const OUString& sSelected )
{
// find selected element
- sal_Int32 nSelected = -1;
- sal_Int32 nLength = rSequence.getLength();
- const OUString* pSequence = rSequence.getConstArray();
- for( sal_Int32 i = 0; i < nLength; i++ )
- {
- if( pSequence[i] == sSelected )
- nSelected = i;
- }
+ sal_Int32 nSelected = comphelper::findValue(rSequence, sSelected);
// delegate to ProcessStringSequence(OUString,sal_Int32)
ProcessStringSequence( rSequence, nSelected );
diff --git a/xmloff/source/text/txtfldi.cxx b/xmloff/source/text/txtfldi.cxx
index c1b1093a8ad3..ca2324471958 100644
--- a/xmloff/source/text/txtfldi.cxx
+++ b/xmloff/source/text/txtfldi.cxx
@@ -2490,24 +2490,23 @@ void XMLMacroFieldImportContext::PrepareField(
Sequence<PropertyValue> aValues;
pEvents->GetEventSequence( "OnClick", aValues );
- sal_Int32 nLength = aValues.getLength();
- for( sal_Int32 i = 0; i < nLength; i++ )
+ for( const auto& rValue : aValues )
{
- if ( aValues[i].Name == "ScriptType" )
+ if ( rValue.Name == "ScriptType" )
{
// ignore ScriptType
}
- else if ( aValues[i].Name == "Library" )
+ else if ( rValue.Name == "Library" )
{
- aValues[i].Value >>= sLibraryName;
+ rValue.Value >>= sLibraryName;
}
- else if ( aValues[i].Name == "MacroName" )
+ else if ( rValue.Name == "MacroName" )
{
- aValues[i].Value >>= sMacroName;
+ rValue.Value >>= sMacroName;
}
- if ( aValues[i].Name == "Script" )
+ if ( rValue.Name == "Script" )
{
- aValues[i].Value >>= sScriptURL;
+ rValue.Value >>= sScriptURL;
}
}
}
diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx
index fbb0f733ca3c..a100616f6e74 100644
--- a/xmloff/source/text/txtimp.cxx
+++ b/xmloff/source/text/txtimp.cxx
@@ -1954,16 +1954,14 @@ void XMLTextImportHelper::FindOutlineStyleName( OUString& rStyleName,
Sequence<PropertyValue> aProperties;
m_xImpl->m_xChapterNumbering->getByIndex( nOutlineLevel )
>>= aProperties;
- for( sal_Int32 i = 0; i < aProperties.getLength(); i++ )
+ auto pProp = std::find_if(aProperties.begin(), aProperties.end(),
+ [](const PropertyValue& rProp) { return rProp.Name == "HeadingStyleName"; });
+ if (pProp != aProperties.end())
{
- if (aProperties[i].Name == "HeadingStyleName")
- {
- OUString aOutlineStyle;
- aProperties[i].Value >>= aOutlineStyle;
- m_xImpl->m_xOutlineStylesCandidates[nOutlineLevel]
- .push_back( aOutlineStyle );
- break; // early out, if we found it!.
- }
+ OUString aOutlineStyle;
+ pProp->Value >>= aOutlineStyle;
+ m_xImpl->m_xOutlineStylesCandidates[nOutlineLevel]
+ .push_back( aOutlineStyle );
}
}
diff --git a/xmloff/source/text/txtprhdl.cxx b/xmloff/source/text/txtprhdl.cxx
index 54142972acdc..ca2c6501e320 100644
--- a/xmloff/source/text/txtprhdl.cxx
+++ b/xmloff/source/text/txtprhdl.cxx
@@ -637,25 +637,13 @@ bool XMLTextColumnsPropertyHandler::equals(
Sequence < TextColumn > aColumns1 = xColumns1->getColumns();
Sequence < TextColumn > aColumns2 = xColumns2->getColumns();
- sal_Int32 nCount = aColumns1.getLength();
- if( aColumns2.getLength() != nCount )
- return false;
-
- const TextColumn *pColumns1 = aColumns1.getArray();
- const TextColumn *pColumns2 = aColumns2.getArray();
-
- while( nCount-- )
- {
- if( pColumns1->Width != pColumns2->Width ||
- pColumns1->LeftMargin != pColumns2->LeftMargin ||
- pColumns1->RightMargin != pColumns2->RightMargin )
- return false;
- pColumns1++;
- pColumns2++;
- }
-
- return true;
+ return std::equal(aColumns1.begin(), aColumns1.end(), aColumns2.begin(), aColumns2.end(),
+ [](const TextColumn& a, const TextColumn& b) {
+ return a.Width == b.Width
+ && a.LeftMargin == b.LeftMargin
+ && a.RightMargin == b.RightMargin;
+ });
}
bool XMLTextColumnsPropertyHandler::importXML(
diff --git a/xmloff/source/transform/OOo2Oasis.cxx b/xmloff/source/transform/OOo2Oasis.cxx
index 5d84e725de6f..1cd92c99c89e 100644
--- a/xmloff/source/transform/OOo2Oasis.cxx
+++ b/xmloff/source/transform/OOo2Oasis.cxx
@@ -1917,8 +1917,7 @@ void OOo2OasisTransformer::Initialize(
{
Sequence<Any> aArgs( 1 + rArguments.getLength() );
aArgs[0] <<= xDocHandler;
- for(sal_Int32 i = 0; i < rArguments.getLength(); i++)
- aArgs[i+1] = rArguments[i];
+ std::copy(rArguments.begin(), rArguments.end(), std::next(aArgs.begin()));
XMLTransformerBase::initialize( aArgs );
OSL_ENSURE( GetDocHandler() == xDocHandler,
diff --git a/xmloff/source/transform/TransformerBase.cxx b/xmloff/source/transform/TransformerBase.cxx
index 249f06752fa3..23c32d8d0d95 100644
--- a/xmloff/source/transform/TransformerBase.cxx
+++ b/xmloff/source/transform/TransformerBase.cxx
@@ -374,10 +374,7 @@ void SAL_CALL XMLTransformerBase::unknown( const OUString& /*rString*/ )
// XInitialize
void SAL_CALL XMLTransformerBase::initialize( const Sequence< Any >& aArguments )
{
- const sal_Int32 nAnyCount = aArguments.getLength();
- const Any* pAny = aArguments.getConstArray();
-
- for( sal_Int32 nIndex = 0; nIndex < nAnyCount; nIndex++, pAny++ )
+ for( const auto& rArgument : aArguments )
{
// use isAssignableFrom instead of comparing the types to
// allow XExtendedDocumentHandler instead of XDocumentHandler (used in
@@ -386,9 +383,9 @@ void SAL_CALL XMLTransformerBase::initialize( const Sequence< Any >& aArguments
// uses queryInterface, and the model also has a XPropertySet interface.
// document handler
- if( cppu::UnoType<XDocumentHandler>::get().isAssignableFrom( pAny->getValueType() ) )
+ if( cppu::UnoType<XDocumentHandler>::get().isAssignableFrom( rArgument.getValueType() ) )
{
- m_xHandler.set( *pAny, UNO_QUERY );
+ m_xHandler.set( rArgument, UNO_QUERY );
// Type change to avoid crashing of dynamic_cast
if (SvXMLImport *pFastHandler = dynamic_cast<SvXMLImport*>(
uno::Reference< XFastDocumentHandler >( m_xHandler, uno::UNO_QUERY ).get() ) )
@@ -396,12 +393,12 @@ void SAL_CALL XMLTransformerBase::initialize( const Sequence< Any >& aArguments
}
// property set to transport data across
- if( cppu::UnoType<XPropertySet>::get().isAssignableFrom( pAny->getValueType() ) )
- m_xPropSet.set( *pAny, UNO_QUERY );
+ if( cppu::UnoType<XPropertySet>::get().isAssignableFrom( rArgument.getValueType() ) )
+ m_xPropSet.set( rArgument, UNO_QUERY );
// xmodel
- if( cppu::UnoType<css::frame::XModel>::get().isAssignableFrom( pAny->getValueType() ) )
- mxModel.set( *pAny, UNO_QUERY );
+ if( cppu::UnoType<css::frame::XModel>::get().isAssignableFrom( rArgument.getValueType() ) )
+ mxModel.set( rArgument, UNO_QUERY );
}
if( m_xPropSet.is() )
diff --git a/xmloff/source/xforms/xformsapi.cxx b/xmloff/source/xforms/xformsapi.cxx
index f52aac6272b6..19d2f1a051b7 100644
--- a/xmloff/source/xforms/xformsapi.cxx
+++ b/xmloff/source/xforms/xformsapi.cxx
@@ -114,12 +114,10 @@ static Reference<XPropertySet> lcl_findXFormsBindingOrSubmission(
{
// iterate over all models
Sequence<OUString> aNames = xForms->getElementNames();
- const OUString* pNames = aNames.getConstArray();
- sal_Int32 nNames = aNames.getLength();
- for( sal_Int32 n = 0; (n < nNames) && !xRet.is(); n++ )
+ for( const auto& rName : aNames )
{
Reference<xforms::XModel2> xModel(
- xForms->getByName( pNames[n] ), UNO_QUERY );
+ xForms->getByName( rName ), UNO_QUERY );
if( xModel.is() )
{
// ask model for bindings
@@ -134,6 +132,9 @@ static Reference<XPropertySet> lcl_findXFormsBindingOrSubmission(
xRet.set( xBindings->getByName( rBindingID ),
UNO_QUERY );
}
+
+ if (xRet.is())
+ break;
}
}
}
diff --git a/xmloff/source/xforms/xformsexport.cxx b/xmloff/source/xforms/xformsexport.cxx
index 5d432ffe6eb5..edd3b1434918 100644
--- a/xmloff/source/xforms/xformsexport.cxx
+++ b/xmloff/source/xforms/xformsexport.cxx
@@ -87,12 +87,10 @@ void exportXForms( SvXMLExport& rExport )
if( xForms.is() )
{
Sequence<OUString> aNames = xForms->getElementNames();
- const OUString* pNames = aNames.getConstArray();
- sal_Int32 nNames = aNames.getLength();
- for( sal_Int32 n = 0; n < nNames; n++ )
+ for( const auto& rName : aNames )
{
- Reference<XPropertySet> xModel( xForms->getByName( pNames[n] ),
+ Reference<XPropertySet> xModel( xForms->getByName( rName ),
UNO_QUERY );
exportXFormsModel( rExport, xModel );
}
@@ -219,12 +217,10 @@ void exportXFormsInstance( SvXMLExport& rExport,
OUString sURL;
Reference<XDocument> xDoc;
- const PropertyValue* pInstance = xInstance.getConstArray();
- sal_Int32 nCount = xInstance.getLength();
- for( sal_Int32 i = 0; i < nCount; i++ )
+ for( const auto& rProp : xInstance )
{
- OUString sName = pInstance[i].Name;
- const Any& rAny = pInstance[i].Value;
+ OUString sName = rProp.Name;
+ const Any& rAny = rProp.Value;
if ( sName == "ID" )
rAny >>= sId;
else if ( sName == "URL" )
@@ -337,11 +333,8 @@ void exportXFormsBinding( SvXMLExport& rExport,
{
// iterate over Prefixes for this binding
Sequence<OUString> aPrefixes = xNamespaces->getElementNames();
- const OUString* pPrefixes = aPrefixes.getConstArray();
- sal_Int32 nPrefixes = aPrefixes.getLength();
- for( sal_Int32 i = 0; i < nPrefixes; i++ )
+ for( const OUString& rPrefix : aPrefixes )
{
- const OUString& rPrefix = pPrefixes[i];
OUString sURI;
xNamespaces->getByName( rPrefix ) >>= sURI;