summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-06-12 11:21:20 +0300
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-06-13 19:43:13 +0200
commit54afdbd1b442d93313a01e58dba8fe3b84f596d1 (patch)
tree4564dd8bf6443521622b96b52e22caf65bb87d4d
parent8b3c861c46ae12d21b7b3a550e2daa21d2006b77 (diff)
Simplify Sequence iterations in writerfilter, writerperfect, xmlhelp
Use range-based loops or replace with comphelper or STL functions Change-Id: I9113e04d15ad84d0abac087afc627969e8ebc354 Reviewed-on: https://gerrit.libreoffice.org/73867 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableHandler.cxx40
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx109
-rw-r--r--writerfilter/source/dmapper/GraphicImport.cxx16
-rw-r--r--writerfilter/source/dmapper/NumberingManager.cxx25
-rw-r--r--writerfilter/source/dmapper/PropertyMap.cxx24
-rw-r--r--writerfilter/source/dmapper/StyleSheetTable.cxx19
-rw-r--r--writerfilter/source/dmapper/ThemeTable.cxx8
-rw-r--r--writerfilter/source/ooxml/OOXMLDocumentImpl.cxx15
-rw-r--r--writerfilter/source/ooxml/OOXMLStreamImpl.cxx15
-rw-r--r--writerperfect/qa/unit/WpftLoader.cxx17
-rw-r--r--writerperfect/source/calc/MSWorksCalcImportFilter.cxx20
-rw-r--r--writerperfect/source/common/WPXSvInputStream.cxx8
-rw-r--r--writerperfect/source/writer/EPUBExportFilter.cxx24
-rw-r--r--writerperfect/source/writer/WordPerfectImportFilter.cxx12
-rw-r--r--writerperfect/source/writer/exp/xmlimp.cxx61
-rw-r--r--xmlhelp/source/cxxhelp/provider/content.cxx19
-rw-r--r--xmlhelp/source/cxxhelp/provider/databases.cxx26
-rw-r--r--xmlhelp/source/cxxhelp/provider/resultsetbase.cxx13
-rw-r--r--xmlhelp/source/treeview/tvfactory.cxx4
-rw-r--r--xmlhelp/source/treeview/tvread.cxx26
20 files changed, 212 insertions, 289 deletions
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index 0844050c37a7..27a710f5a0b6 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -889,7 +889,7 @@ static bool lcl_emptyRow(std::vector<RowSequence_t>& rTableRanges, sal_Int32 nRo
}
RowSequence_t rRowSeq = rTableRanges[nRow];
- if (rRowSeq.getLength() == 0)
+ if (!rRowSeq.hasElements())
{
SAL_WARN("writerfilter.dmapper", "m_aCellProperties not in sync with rTableRanges?");
return false;
@@ -906,12 +906,14 @@ static bool lcl_emptyRow(std::vector<RowSequence_t>& rTableRanges, sal_Int32 nRo
uno::Reference<text::XTextRangeCompare> xTextRangeCompare(rRowSeq[0][0]->getText(), uno::UNO_QUERY);
try
{
- for (sal_Int32 nCell = 0; nCell < rRowSeq.getLength(); ++nCell)
- // See SwXText::Impl::ConvertCell(), we need to compare the start of
- // the start and the end of the end. However for our text ranges, only
- // the starts are set, so compareRegionStarts() does what we need.
- if (xTextRangeCompare->compareRegionStarts(rRowSeq[nCell][0], rRowSeq[nCell][1]) != 0)
- return false;
+ // See SwXText::Impl::ConvertCell(), we need to compare the start of
+ // the start and the end of the end. However for our text ranges, only
+ // the starts are set, so compareRegionStarts() does what we need.
+ bool bRangesAreNotEqual = std::any_of(rRowSeq.begin(), rRowSeq.end(),
+ [&xTextRangeCompare](const CellSequence_t& rCellSeq) {
+ return xTextRangeCompare->compareRegionStarts(rCellSeq[0], rCellSeq[1]) != 0; });
+ if (bRangesAreNotEqual)
+ return false;
}
catch (const lang::IllegalArgumentException& e)
{
@@ -1083,21 +1085,19 @@ void DomainMapperTableHandler::endTable(unsigned int nestedTableLevel, bool bTab
}
// OOXML table style may container paragraph properties, apply these now.
- for (int i = 0; i < aTableInfo.aTableProperties.getLength(); ++i)
+ auto pTableProp = std::find_if(aTableInfo.aTableProperties.begin(), aTableInfo.aTableProperties.end(),
+ [](const beans::PropertyValue& rProp) { return rProp.Name == "ParaBottomMargin"; });
+ if (pTableProp != aTableInfo.aTableProperties.end())
{
- if (aTableInfo.aTableProperties[i].Name == "ParaBottomMargin")
+ uno::Reference<table::XCellRange> xCellRange(xTable, uno::UNO_QUERY);
+ uno::Any aBottomMargin = pTableProp->Value;
+ sal_Int32 nRows = aCellProperties.getLength();
+ for (sal_Int32 nRow = 0; nRow < nRows; ++nRow)
{
- uno::Reference<table::XCellRange> xCellRange(xTable, uno::UNO_QUERY);
- uno::Any aBottomMargin = aTableInfo.aTableProperties[i].Value;
- sal_Int32 nRows = aCellProperties.getLength();
- for (sal_Int32 nRow = 0; nRow < nRows; ++nRow)
- {
- const uno::Sequence< beans::PropertyValues > aCurrentRow = aCellProperties[nRow];
- sal_Int32 nCells = aCurrentRow.getLength();
- for (sal_Int32 nCell = 0; nCell < nCells; ++nCell)
- lcl_ApplyCellParaProps(xCellRange->getCellByPosition(nCell, nRow), aBottomMargin);
- }
- break;
+ const uno::Sequence< beans::PropertyValues > aCurrentRow = aCellProperties[nRow];
+ sal_Int32 nCells = aCurrentRow.getLength();
+ for (sal_Int32 nCell = 0; nCell < nCells; ++nCell)
+ lcl_ApplyCellParaProps(xCellRange->getCellByPosition(nCell, nRow), aBottomMargin);
}
}
}
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index f03ee6f8271b..d70ebb443691 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -633,9 +633,9 @@ FieldContextPtr const & DomainMapper_Impl::GetTopFieldContext()
void DomainMapper_Impl::InitTabStopFromStyle( const uno::Sequence< style::TabStop >& rInitTabStops )
{
OSL_ENSURE(m_aCurrentTabStops.empty(), "tab stops already initialized");
- for( sal_Int32 nTab = 0; nTab < rInitTabStops.getLength(); ++nTab)
+ for( const auto& rTabStop : rInitTabStops)
{
- m_aCurrentTabStops.emplace_back(rInitTabStops[nTab] );
+ m_aCurrentTabStops.emplace_back(rTabStop);
}
}
@@ -1626,13 +1626,12 @@ void DomainMapper_Impl::appendTextPortion( const OUString& rString, const Proper
{
// If we are in comments, then disable CharGrabBag, comment text doesn't support that.
uno::Sequence< beans::PropertyValue > aValues = pPropertyMap->GetPropertyValues(/*bCharGrabBag=*/!m_bIsInComments);
- sal_Int32 len = aValues.getLength();
if (m_bStartTOC || m_bStartIndex || m_bStartBibliography)
- for( int i =0; i < len; ++i )
+ for( auto& rValue : aValues )
{
- if (aValues[i].Name == "CharHidden")
- aValues[i].Value <<= false;
+ if (rValue.Name == "CharHidden")
+ rValue.Value <<= false;
}
uno::Reference< text::XTextRange > xTextRange;
@@ -2339,18 +2338,18 @@ void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape
xShapePropertySet->getPropertyValue("FrameInteropGrabBag") >>= aGrabBag;
bool checkBtLrStatus = false;
- for (int i = 0; i < aGrabBag.getLength(); ++i)
+ for (const auto& rProp : aGrabBag)
{
- if (aGrabBag[i].Name == "mso-layout-flow-alt")
+ if (rProp.Name == "mso-layout-flow-alt")
{
- m_bFrameBtLr = aGrabBag[i].Value.get<OUString>() == "bottom-to-top";
+ m_bFrameBtLr = rProp.Value.get<OUString>() == "bottom-to-top";
checkBtLrStatus = true;
}
- if (aGrabBag[i].Name == "VML-Z-ORDER")
+ if (rProp.Name == "VML-Z-ORDER")
{
GraphicZOrderHelper* pZOrderHelper = m_rDMapper.graphicZOrderHelper();
sal_Int32 zOrder(0);
- aGrabBag[i].Value >>= zOrder;
+ rProp.Value >>= zOrder;
xShapePropertySet->setPropertyValue( "ZOrder", uno::makeAny(pZOrderHelper->findZOrder(zOrder)));
pZOrderHelper->addItem(xShapePropertySet, zOrder);
xShapePropertySet->setPropertyValue(getPropertyName( PROP_OPAQUE ), uno::makeAny( zOrder >= 0 ) );
@@ -2359,7 +2358,7 @@ void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape
if(checkBtLrStatus && checkZOrderStatus)
break;
- if ( aGrabBag[i].Name == "TxbxHasLink" )
+ if ( rProp.Name == "TxbxHasLink" )
{
//Chaining of textboxes will happen in ~DomainMapper_Impl
//i.e when all the textboxes are read and all its attributes
@@ -2391,19 +2390,19 @@ void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape
uno::Reference<beans::XPropertySet> xShapePropertySet(xShape, uno::UNO_QUERY);
uno::Sequence<beans::PropertyValue> aGrabBag;
xShapePropertySet->getPropertyValue("InteropGrabBag") >>= aGrabBag;
- for (int i = 0; i < aGrabBag.getLength(); ++i)
+ for (const auto& rProp : aGrabBag)
{
- if (aGrabBag[i].Name == "VML-Z-ORDER")
+ if (rProp.Name == "VML-Z-ORDER")
{
GraphicZOrderHelper* pZOrderHelper = m_rDMapper.graphicZOrderHelper();
sal_Int32 zOrder(0);
- aGrabBag[i].Value >>= zOrder;
+ rProp.Value >>= zOrder;
xShapePropertySet->setPropertyValue( "ZOrder", uno::makeAny(pZOrderHelper->findZOrder(zOrder)));
pZOrderHelper->addItem(xShapePropertySet, zOrder);
xShapePropertySet->setPropertyValue(getPropertyName( PROP_OPAQUE ), uno::makeAny( zOrder >= 0 ) );
checkZOrderStatus = true;
}
- else if ( aGrabBag[i].Name == "TxbxHasLink" )
+ else if ( rProp.Name == "TxbxHasLink" )
{
//Chaining of textboxes will happen in ~DomainMapper_Impl
//i.e when all the textboxes are read and all its attributes
@@ -2527,17 +2526,17 @@ bool DomainMapper_Impl::IsSdtEndBefore()
if(pContext)
{
uno::Sequence< beans::PropertyValue > currentCharProps = pContext->GetPropertyValues();
- for (int i =0; i< currentCharProps.getLength(); i++)
+ for (const auto& rCurrentCharProp : currentCharProps)
{
- if (currentCharProps[i].Name == "CharInteropGrabBag")
+ if (rCurrentCharProp.Name == "CharInteropGrabBag")
{
uno::Sequence<beans::PropertyValue> aCharGrabBag;
- currentCharProps[i].Value >>= aCharGrabBag;
- for (int j=0; j < aCharGrabBag.getLength();j++)
+ rCurrentCharProp.Value >>= aCharGrabBag;
+ for (const auto& rProp : aCharGrabBag)
{
- if(aCharGrabBag[j].Name == "SdtEndBefore")
+ if(rProp.Name == "SdtEndBefore")
{
- aCharGrabBag[j].Value >>= bIsSdtEndBefore;
+ rProp.Value >>= bIsSdtEndBefore;
}
}
}
@@ -2935,11 +2934,10 @@ void DomainMapper_Impl::SetNumberFormat( const OUString& rCommand,
static uno::Any lcl_getGrabBagValue( const uno::Sequence<beans::PropertyValue>& grabBag, OUString const & name )
{
- for (int i = 0; i < grabBag.getLength(); ++i)
- {
- if (grabBag[i].Name == name )
- return grabBag[i].Value ;
- }
+ auto pProp = std::find_if(grabBag.begin(), grabBag.end(),
+ [&name](const beans::PropertyValue& rProp) { return rProp.Name == name; });
+ if (pProp != grabBag.end())
+ return pProp->Value;
return uno::Any();
}
@@ -3728,10 +3726,7 @@ static uno::Sequence< beans::PropertyValues > lcl_createTOXLevelHyperlinks( bool
pNewLevel[aNewLevel.getLength() - (bHyperlinks ? 3 : 1)] = aChapterSeparator;
}
//copy the 'old' entries except the last (page no)
- for( sal_Int32 nToken = 0; nToken < aLevel.getLength() - 1; ++nToken)
- {
- pNewLevel[nToken + 1] = aLevel[nToken];
- }
+ std::copy(aLevel.begin(), std::prev(aLevel.end()), std::next(aNewLevel.begin()));
//copy page no entry (last or last but one depending on bHyperlinks
sal_Int32 nPageNo = aNewLevel.getLength() - (bHyperlinks ? 2 : 3);
pNewLevel[nPageNo] = aLevel[aLevel.getLength() - 1];
@@ -5966,21 +5961,17 @@ uno::Reference<beans::XPropertySet> DomainMapper_Impl::GetCurrentNumberingCharSt
}
uno::Sequence<beans::PropertyValue> aProps;
xLevels->getByIndex(nListLevel) >>= aProps;
- for (int i = 0; i < aProps.getLength(); ++i)
+ auto pProp = std::find_if(aProps.begin(), aProps.end(),
+ [](const beans::PropertyValue& rProp) { return rProp.Name == "CharStyleName"; });
+ if (pProp != aProps.end())
{
- const beans::PropertyValue& rProp = aProps[i];
-
- if (rProp.Name == "CharStyleName")
- {
- OUString aCharStyle;
- rProp.Value >>= aCharStyle;
- uno::Reference<container::XNameAccess> xCharacterStyles;
- uno::Reference< style::XStyleFamiliesSupplier > xStylesSupplier(GetTextDocument(), uno::UNO_QUERY);
- uno::Reference< container::XNameAccess > xStyleFamilies = xStylesSupplier->getStyleFamilies();
- xStyleFamilies->getByName("CharacterStyles") >>= xCharacterStyles;
- xRet.set(xCharacterStyles->getByName(aCharStyle), uno::UNO_QUERY_THROW);
- break;
- }
+ OUString aCharStyle;
+ pProp->Value >>= aCharStyle;
+ uno::Reference<container::XNameAccess> xCharacterStyles;
+ uno::Reference< style::XStyleFamiliesSupplier > xStylesSupplier(GetTextDocument(), uno::UNO_QUERY);
+ uno::Reference< container::XNameAccess > xStyleFamilies = xStylesSupplier->getStyleFamilies();
+ xStyleFamilies->getByName("CharacterStyles") >>= xCharacterStyles;
+ xRet.set(xCharacterStyles->getByName(aCharStyle), uno::UNO_QUERY_THROW);
}
}
catch( const uno::Exception& )
@@ -6039,16 +6030,10 @@ sal_Int32 DomainMapper_Impl::getNumberingProperty(const sal_Int32 nListId, sal_I
{
uno::Sequence<beans::PropertyValue> aProps;
xNumberingRules->getByIndex(nNumberingLevel) >>= aProps;
- for (int i = 0; i < aProps.getLength(); ++i)
- {
- const beans::PropertyValue& rProp = aProps[i];
-
- if (rProp.Name == aProp)
- {
- rProp.Value >>= nRet;
- break;
- }
- }
+ auto pProp = std::find_if(aProps.begin(), aProps.end(),
+ [&aProp](const beans::PropertyValue& rProp) { return rProp.Name == aProp; });
+ if (pProp != aProps.end())
+ pProp->Value >>= nRet;
}
}
catch( const uno::Exception& )
@@ -6076,16 +6061,10 @@ sal_Int32 DomainMapper_Impl::getCurrentNumberingProperty(const OUString& aProp)
{
uno::Sequence<beans::PropertyValue> aProps;
xNumberingRules->getByIndex(nNumberingLevel) >>= aProps;
- for (int i = 0; i < aProps.getLength(); ++i)
- {
- const beans::PropertyValue& rProp = aProps[i];
-
- if (rProp.Name == aProp)
- {
- rProp.Value >>= nRet;
- break;
- }
- }
+ auto pPropVal = std::find_if(aProps.begin(), aProps.end(),
+ [&aProp](const beans::PropertyValue& rProp) { return rProp.Name == aProp; });
+ if (pPropVal != aProps.end())
+ pPropVal->Value >>= nRet;
}
return nRet;
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index d9458ba468c2..d5d09a90dcbb 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -656,16 +656,14 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
xShapeProps->getPropertyValue("RotateAngle") >>= nRotation;
css::beans::PropertyValues aGrabBag;
- bool bContainsEffects = false;
xShapeProps->getPropertyValue("InteropGrabBag") >>= aGrabBag;
- for( sal_Int32 i = 0; i < aGrabBag.getLength(); ++i )
- {
- // if the shape contains effects in the grab bag, we should not transform it
- // in a XTextContent so those effects can be preserved
- if( aGrabBag[i].Name == "EffectProperties" || aGrabBag[i].Name == "3DEffectProperties" ||
- aGrabBag[i].Name == "ArtisticEffectProperties" )
- bContainsEffects = true;
- }
+ // if the shape contains effects in the grab bag, we should not transform it
+ // in a XTextContent so those effects can be preserved
+ bool bContainsEffects = std::any_of(aGrabBag.begin(), aGrabBag.end(), [](const auto& rProp) {
+ return rProp.Name == "EffectProperties"
+ || rProp.Name == "3DEffectProperties"
+ || rProp.Name == "ArtisticEffectProperties";
+ });
xShapeProps->getPropertyValue("Shadow") >>= m_pImpl->bShadow;
if (m_pImpl->bShadow)
diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx
index 4afa77f94f05..666ee674cddc 100644
--- a/writerfilter/source/dmapper/NumberingManager.cxx
+++ b/writerfilter/source/dmapper/NumberingManager.cxx
@@ -74,20 +74,20 @@ static sal_Int32 lcl_findProperty( const uno::Sequence< beans::PropertyValue >&
static void lcl_mergeProperties( uno::Sequence< beans::PropertyValue >& aSrc,
uno::Sequence< beans::PropertyValue >& aDst )
{
- for ( sal_Int32 i = 0, nSrcLen = aSrc.getLength( ); i < nSrcLen; i++ )
+ for ( const auto& rProp : aSrc )
{
// Look for the same property in aDst
- sal_Int32 nPos = lcl_findProperty( aDst, aSrc[i].Name );
+ sal_Int32 nPos = lcl_findProperty( aDst, rProp.Name );
if ( nPos >= 0 )
{
// Replace the property value by the one in aSrc
- aDst[nPos] = aSrc[i];
+ aDst[nPos] = rProp;
}
else
{
// Simply add the new value
aDst.realloc( aDst.getLength( ) + 1 );
- aDst[ aDst.getLength( ) - 1 ] = aSrc[i];
+ aDst[ aDst.getLength( ) - 1 ] = rProp;
}
}
}
@@ -338,19 +338,18 @@ void ListLevel::AddParaProperties( uno::Sequence< beans::PropertyValue >* props
OUString sParaLeftMargin = getPropertyName(
PROP_PARA_LEFT_MARGIN );
- sal_Int32 nLen = aParaProps.getLength( );
- for ( sal_Int32 i = 0; i < nLen; i++ )
+ for ( const auto& rParaProp : aParaProps )
{
- if ( !hasFirstLineIndent && aParaProps[i].Name == sParaIndent )
+ if ( !hasFirstLineIndent && rParaProp.Name == sParaIndent )
{
aProps.realloc( aProps.getLength() + 1 );
- aProps[aProps.getLength( ) - 1] = aParaProps[i];
+ aProps[aProps.getLength( ) - 1] = rParaProp;
aProps[aProps.getLength( ) - 1].Name = sFirstLineIndent;
}
- else if ( !hasIndentAt && aParaProps[i].Name == sParaLeftMargin )
+ else if ( !hasIndentAt && rParaProp.Name == sParaLeftMargin )
{
aProps.realloc( aProps.getLength() + 1 );
- aProps[aProps.getLength( ) - 1] = aParaProps[i];
+ aProps[aProps.getLength( ) - 1] = rParaProp;
aProps[aProps.getLength( ) - 1].Name = sIndentAt;
}
@@ -547,11 +546,7 @@ void ListDef::CreateNumberingRules( DomainMapper& rDMapper,
if( aAbsCharStyleProps.hasElements() )
{
// Change the sequence into a vector
- PropertyValueVector_t aStyleProps;
- for ( sal_Int32 i = 0, nLen = aAbsCharStyleProps.getLength() ; i < nLen; i++ )
- {
- aStyleProps.push_back( aAbsCharStyleProps[i] );
- }
+ auto aStyleProps = comphelper::sequenceToContainer<PropertyValueVector_t>(aAbsCharStyleProps);
//create (or find) a character style containing the character
// attributes of the symbol and apply it to the numbering level
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index cf5f3b4d3381..68f1f7119564 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -160,11 +160,8 @@ uno::Sequence< beans::PropertyValue > PropertyMap::GetPropertyValues( bool bChar
{
uno::Sequence< beans::PropertyValue > aSeq;
rPropPair.second.getValue() >>= aSeq;
- for ( sal_Int32 i = 0; i < aSeq.getLength(); ++i )
- {
- pCellGrabBagValues[nCellGrabBagValue] = aSeq[i];
- ++nCellGrabBagValue;
- }
+ std::copy(aSeq.begin(), aSeq.end(), pCellGrabBagValues + nCellGrabBagValue);
+ nCellGrabBagValue += aSeq.getLength();
}
else
{
@@ -452,12 +449,11 @@ static OUString lcl_FindUnusedPageStyleName( const uno::Sequence< OUString >& rP
// find the highest number x in each style with the name "DEFAULT_STYLE+x" and
// return an incremented name
- const OUString* pStyleNames = rPageStyleNames.getConstArray();
- for ( sal_Int32 nStyle = 0; nStyle < rPageStyleNames.getLength(); ++nStyle )
+ for ( const auto& rStyleName : rPageStyleNames )
{
- if ( pStyleNames[nStyle].startsWith( DEFAULT_STYLE ) )
+ if ( rStyleName.startsWith( DEFAULT_STYLE ) )
{
- sal_Int32 nIndex = pStyleNames[nStyle].copy( strlen( DEFAULT_STYLE ) ).toInt32();
+ sal_Int32 nIndex = rStyleName.copy( strlen( DEFAULT_STYLE ) ).toInt32();
if ( nIndex > nMaxIndex )
nMaxIndex = nIndex;
}
@@ -1604,14 +1600,14 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
// Ignore write-only properties.
static const std::set<OUString> aBlacklist
= { "FooterBackGraphicURL", "BackGraphicURL", "HeaderBackGraphicURL" };
- for ( int i = 0; i < propertyList.getLength(); ++i )
+ for ( const auto& rProperty : propertyList )
{
- if ( (propertyList[i].Attributes & beans::PropertyAttribute::READONLY) == 0 )
+ if ( (rProperty.Attributes & beans::PropertyAttribute::READONLY) == 0 )
{
- if (aBlacklist.find(propertyList[i].Name) == aBlacklist.end())
+ if (aBlacklist.find(rProperty.Name) == aBlacklist.end())
evenOddStyle->setPropertyValue(
- propertyList[i].Name,
- pageProperties->getPropertyValue(propertyList[i].Name));
+ rProperty.Name,
+ pageProperties->getPropertyValue(rProperty.Name));
}
}
evenOddStyle->setPropertyValue( "FollowStyle", uno::makeAny( *pageStyle ) );
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx
index eef56e7db718..3e41aa93404e 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.cxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.cxx
@@ -360,10 +360,8 @@ void StyleSheetTable_Impl::SetPropertiesToDefault(const uno::Reference<style::XS
uno::Sequence<beans::Property> aProperties = xPropertySetInfo->getProperties();
std::vector<OUString> aPropertyNames;
aPropertyNames.reserve(aProperties.getLength());
- for (sal_Int32 i = 0; i < aProperties.getLength(); ++i)
- {
- aPropertyNames.push_back(aProperties[i].Name);
- }
+ std::transform(aProperties.begin(), aProperties.end(), std::back_inserter(aPropertyNames),
+ [](const beans::Property& rProp) { return rProp.Name; });
uno::Reference<beans::XPropertyState> xPropertyState(xStyle, uno::UNO_QUERY);
uno::Sequence<beans::PropertyState> aStates = xPropertyState->getPropertyStates(comphelper::containerToSequence(aPropertyNames));
@@ -1479,11 +1477,11 @@ void StyleSheetTable::applyDefaults(bool bParaProperties)
xParagraphStyles->getByName("Paragraph style") >>= xDefault;
uno::Sequence< beans::PropertyValue > aPropValues = m_pImpl->m_pDefaultParaProps->GetPropertyValues();
- for( sal_Int32 i = 0; i < aPropValues.getLength(); ++i )
+ for( const auto& rPropValue : aPropValues )
{
try
{
- xDefault->setPropertyValue(aPropValues[i].Name, aPropValues[i].Value);
+ xDefault->setPropertyValue(rPropValue.Name, rPropValue.Value);
}
catch( const uno::Exception& )
{
@@ -1494,11 +1492,11 @@ void StyleSheetTable::applyDefaults(bool bParaProperties)
if( !bParaProperties && m_pImpl->m_pDefaultCharProps.get())
{
uno::Sequence< beans::PropertyValue > aPropValues = m_pImpl->m_pDefaultCharProps->GetPropertyValues();
- for( sal_Int32 i = 0; i < aPropValues.getLength(); ++i )
+ for( const auto& rPropValue : aPropValues )
{
try
{
- m_pImpl->m_xTextDefaults->setPropertyValue( aPropValues[i].Name, aPropValues[i].Value );
+ m_pImpl->m_xTextDefaults->setPropertyValue( rPropValue.Name, rPropValue.Value );
}
catch( const uno::Exception& )
{
@@ -1528,11 +1526,10 @@ OUString StyleSheetTable::getOrCreateCharStyle( PropertyValueVector_t& rCharProp
//search for all character styles with the name sListLabel + <index>
sal_Int32 nStyleFound = 0;
uno::Sequence< OUString > aStyleNames = xCharStyles->getElementNames();
- const OUString* pStyleNames = aStyleNames.getConstArray();
- for( sal_Int32 nStyle = 0; nStyle < aStyleNames.getLength(); ++nStyle )
+ for( const auto& rStyleName : aStyleNames )
{
OUString sSuffix;
- if( pStyleNames[nStyle].startsWith( cListLabel, &sSuffix ) )
+ if( rStyleName.startsWith( cListLabel, &sSuffix ) )
{
sal_Int32 nSuffix = sSuffix.toInt32();
if( nSuffix > 0 && nSuffix > nStyleFound )
diff --git a/writerfilter/source/dmapper/ThemeTable.cxx b/writerfilter/source/dmapper/ThemeTable.cxx
index 2eac8d818112..754a278ea082 100644
--- a/writerfilter/source/dmapper/ThemeTable.cxx
+++ b/writerfilter/source/dmapper/ThemeTable.cxx
@@ -243,13 +243,13 @@ const OUString ThemeTable::getFontNameForTheme(const Id id) const
void ThemeTable::setThemeFontLangProperties(const uno::Sequence<beans::PropertyValue>& aPropSeq)
{
- for (sal_Int32 i = 0 ; i < aPropSeq.getLength() ; i ++)
+ for (const auto& rProp : aPropSeq)
{
OUString sLocaleName;
- aPropSeq.getConstArray()[i].Value >>= sLocaleName;
- if (aPropSeq.getConstArray()[i].Name == "eastAsia")
+ rProp.Value >>= sLocaleName;
+ if (rProp.Name == "eastAsia")
m_pImpl->m_themeFontLangEastAsia = fromLocaleToScriptTag(sLocaleName);
- if (aPropSeq.getConstArray()[i].Name == "bidi")
+ if (rProp.Name == "bidi")
m_pImpl->m_themeFontLangBidi = fromLocaleToScriptTag(sLocaleName);
}
diff --git a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
index 0d00b0eff303..9601a5311923 100644
--- a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
+++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
@@ -560,12 +560,10 @@ void OOXMLDocumentImpl::resolveCustomXmlStream(Stream & rStream)
uno::Sequence<uno::Sequence< beans::StringPair>> aSeqs = xRelationshipAccess->getAllRelationships();
std::vector<uno::Reference<xml::dom::XDocument>> aCustomXmlDomList;
std::vector<uno::Reference<xml::dom::XDocument>> aCustomXmlDomPropsList;
- for (sal_Int32 j = 0; j < aSeqs.getLength(); j++)
+ for (const uno::Sequence<beans::StringPair>& aSeq : aSeqs)
{
- const uno::Sequence<beans::StringPair>& aSeq = aSeqs[j];
- for (sal_Int32 i = 0; i < aSeq.getLength(); i++)
+ for (const beans::StringPair& aPair : aSeq)
{
- const beans::StringPair& aPair = aSeq[i];
// Need to resolve only customxml files from document relationships.
// Skipping other files.
if (aPair.Second == sCustomType ||
@@ -629,10 +627,9 @@ void OOXMLDocumentImpl::resolveGlossaryStream(Stream & /*rStream*/)
uno::Sequence< uno::Sequence< beans::StringPair > >aSeqs = xRelationshipAccess->getAllRelationships();
std::vector< uno::Sequence<uno::Any> > aGlossaryDomList;
- for (sal_Int32 j = 0; j < aSeqs.getLength(); j++)
+ for (const uno::Sequence< beans::StringPair >& aSeq : aSeqs)
{
OOXMLStream::Pointer_t gStream;
- uno::Sequence< beans::StringPair > aSeq = aSeqs[j];
//Follows following aSeq[0] is Id, aSeq[1] is Type, aSeq[2] is Target
if (aSeq.getLength() < 3)
{
@@ -728,12 +725,10 @@ void OOXMLDocumentImpl::resolveEmbeddingsStream(const OOXMLStream::Pointer_t& pS
bool bHeaderFooterFound = false;
OOXMLStream::StreamType_t streamType = OOXMLStream::UNKNOWN;
uno::Sequence< uno::Sequence< beans::StringPair > >aSeqs = xRelationshipAccess->getAllRelationships();
- for (sal_Int32 j = 0; j < aSeqs.getLength(); j++)
+ for (const uno::Sequence< beans::StringPair >& aSeq : aSeqs)
{
- uno::Sequence< beans::StringPair > aSeq = aSeqs[j];
- for (sal_Int32 i = 0; i < aSeq.getLength(); i++)
+ for (const beans::StringPair& aPair : aSeq)
{
- beans::StringPair aPair = aSeq[i];
if (aPair.Second == sChartType ||
aPair.Second == sChartTypeStrict)
{
diff --git a/writerfilter/source/ooxml/OOXMLStreamImpl.cxx b/writerfilter/source/ooxml/OOXMLStreamImpl.cxx
index e4e53acc8f1f..cd9426fe1a41 100644
--- a/writerfilter/source/ooxml/OOXMLStreamImpl.cxx
+++ b/writerfilter/source/ooxml/OOXMLStreamImpl.cxx
@@ -96,15 +96,13 @@ bool OOXMLStreamImpl::lcl_getTarget(const uno::Reference<embed::XRelationshipAcc
{
// Cache is empty? Then let's build it!
uno::Sequence< uno::Sequence<beans::StringPair> >aSeqs = xRelationshipAccess->getAllRelationships();
- for (sal_Int32 i = 0; i < aSeqs.getLength(); ++i)
+ for (const uno::Sequence<beans::StringPair>& rSeq : aSeqs)
{
- const uno::Sequence<beans::StringPair>& rSeq = aSeqs[i];
OUString aId;
OUString aTarget;
bool bExternal = false;
- for (sal_Int32 j = 0; j < rSeq.getLength(); ++j)
+ for (const beans::StringPair& rPair : rSeq)
{
- const beans::StringPair& rPair = rSeq[j];
if (rPair.First == sId)
aId = rPair.Second;
else if (rPair.First == sTarget)
@@ -262,16 +260,12 @@ bool OOXMLStreamImpl::lcl_getTarget(const uno::Reference<embed::XRelationshipAcc
uno::Sequence< uno::Sequence< beans::StringPair > >aSeqs =
xRelationshipAccess->getAllRelationships();
- for (sal_Int32 j = 0; j < aSeqs.getLength(); j++)
+ for (const uno::Sequence< beans::StringPair > &rSeq : aSeqs)
{
- const uno::Sequence< beans::StringPair > &rSeq = aSeqs[j];
-
bool bExternalTarget = false;
OUString sMyTarget;
- for (sal_Int32 i = 0; i < rSeq.getLength(); i++)
+ for (const beans::StringPair &rPair : rSeq)
{
- const beans::StringPair &rPair = rSeq[i];
-
if (rPair.First == sType &&
( rPair.Second == sStreamType ||
rPair.Second == sStreamTypeStrict ))
@@ -301,7 +295,6 @@ bool OOXMLStreamImpl::lcl_getTarget(const uno::Reference<embed::XRelationshipAcc
else if (rPair.First == sTargetMode &&
rPair.Second == sExternal)
bExternalTarget = true;
-
}
if (bFound)
diff --git a/writerperfect/qa/unit/WpftLoader.cxx b/writerperfect/qa/unit/WpftLoader.cxx
index 79fc2a05dc68..4c5696c18067 100644
--- a/writerperfect/qa/unit/WpftLoader.cxx
+++ b/writerperfect/qa/unit/WpftLoader.cxx
@@ -181,22 +181,21 @@ void WpftLoader::impl_dispose()
void WpftLoader::impl_detectFilterName(uno::Sequence<beans::PropertyValue>& rDescriptor,
const OUString& rTypeName)
{
- const sal_Int32 nDescriptorLen = rDescriptor.getLength();
-
- for (sal_Int32 n = 0; nDescriptorLen != n; ++n)
- {
- if ("FilterName" == rDescriptor[n].Name)
- return;
- }
+ bool bHasFilterName
+ = std::any_of(rDescriptor.begin(), rDescriptor.end(),
+ [](const beans::PropertyValue& rProp) { return "FilterName" == rProp.Name; });
+ if (bHasFilterName)
+ return;
uno::Sequence<beans::PropertyValue> aTypes;
if (m_xTypeMap->getByName(rTypeName) >>= aTypes)
{
- for (sal_Int32 n = 0; aTypes.getLength() != n; ++n)
+ for (const auto& rType : aTypes)
{
OUString aFilterName;
- if (("PreferredFilter" == aTypes[n].Name) && (aTypes[n].Value >>= aFilterName))
+ if (("PreferredFilter" == rType.Name) && (rType.Value >>= aFilterName))
{
+ const sal_Int32 nDescriptorLen = rDescriptor.getLength();
rDescriptor.realloc(nDescriptorLen + 1);
rDescriptor[nDescriptorLen].Name = "FilterName";
rDescriptor[nDescriptorLen].Value <<= aFilterName;
diff --git a/writerperfect/source/calc/MSWorksCalcImportFilter.cxx b/writerperfect/source/calc/MSWorksCalcImportFilter.cxx
index 8a54381ac576..b62e8ff2d493 100644
--- a/writerperfect/source/calc/MSWorksCalcImportFilter.cxx
+++ b/writerperfect/source/calc/MSWorksCalcImportFilter.cxx
@@ -277,18 +277,16 @@ MSWorksCalcImportFilter::filter(const css::uno::Sequence<css::beans::PropertyVal
css::uno::Reference<ucb::XContent> xContent;
css::uno::Reference<css::awt::XWindow> xDialogParent;
- sal_Int32 nLength = rDescriptor.getLength();
- const css::beans::PropertyValue* pValue = rDescriptor.getConstArray();
- for (sal_Int32 i = 0; i < nLength; i++)
+ for (const auto& rValue : rDescriptor)
{
- if (pValue[i].Name == "InputStream")
- pValue[i].Value >>= xInputStream;
- else if (pValue[i].Name == "UCBContent")
- pValue[i].Value >>= xContent;
- else if (pValue[i].Name == "FileName" || pValue[i].Name == "URL")
- pValue[i].Value >>= sUrl;
- else if (pValue[i].Name == "ParentWindow")
- pValue[i].Value >>= xDialogParent;
+ if (rValue.Name == "InputStream")
+ rValue.Value >>= xInputStream;
+ else if (rValue.Name == "UCBContent")
+ rValue.Value >>= xContent;
+ else if (rValue.Name == "FileName" || rValue.Name == "URL")
+ rValue.Value >>= sUrl;
+ else if (rValue.Name == "ParentWindow")
+ rValue.Value >>= xDialogParent;
}
if (!getXContext().is() || !xInputStream.is())
diff --git a/writerperfect/source/common/WPXSvInputStream.cxx b/writerperfect/source/common/WPXSvInputStream.cxx
index 5daacca66904..4b57b25cbdad 100644
--- a/writerperfect/source/common/WPXSvInputStream.cxx
+++ b/writerperfect/source/common/WPXSvInputStream.cxx
@@ -367,12 +367,12 @@ void ZipStorageImpl::traverse(const Reference<container::XNameAccess>& rxContain
maStreams.reserve(lNames.getLength());
- for (sal_Int32 n = 0; n < lNames.getLength(); ++n)
+ for (const auto& rName : lNames)
{
- if (!lNames[n].endsWith("/")) // skip dirs
+ if (!rName.endsWith("/")) // skip dirs
{
- maStreams.emplace_back(OUStringToOString(lNames[n], RTL_TEXTENCODING_UTF8));
- maNameMap[lNames[n]] = maStreams.size() - 1;
+ maStreams.emplace_back(OUStringToOString(rName, RTL_TEXTENCODING_UTF8));
+ maNameMap[rName] = maStreams.size() - 1;
}
}
}
diff --git a/writerperfect/source/writer/EPUBExportFilter.cxx b/writerperfect/source/writer/EPUBExportFilter.cxx
index 695265be579c..36167b38d52c 100644
--- a/writerperfect/source/writer/EPUBExportFilter.cxx
+++ b/writerperfect/source/writer/EPUBExportFilter.cxx
@@ -58,25 +58,25 @@ sal_Bool EPUBExportFilter::filter(const uno::Sequence<beans::PropertyValue>& rDe
sal_Int32 nLayoutMethod = EPUBExportFilter::GetDefaultLayoutMethod();
uno::Sequence<beans::PropertyValue> aFilterData;
OUString aFilterOptions;
- for (sal_Int32 i = 0; i < rDescriptor.getLength(); ++i)
+ for (const auto& rProp : rDescriptor)
{
- if (rDescriptor[i].Name == "FilterData")
- rDescriptor[i].Value >>= aFilterData;
- else if (rDescriptor[i].Name == "FilterOptions")
- rDescriptor[i].Value >>= aFilterOptions;
+ if (rProp.Name == "FilterData")
+ rProp.Value >>= aFilterData;
+ else if (rProp.Name == "FilterOptions")
+ rProp.Value >>= aFilterOptions;
}
if (aFilterOptions == "layout=fixed")
nLayoutMethod = libepubgen::EPUB_LAYOUT_METHOD_FIXED;
- for (sal_Int32 i = 0; i < aFilterData.getLength(); ++i)
+ for (const auto& rProp : aFilterData)
{
- if (aFilterData[i].Name == "EPUBVersion")
- aFilterData[i].Value >>= nVersion;
- else if (aFilterData[i].Name == "EPUBSplitMethod")
- aFilterData[i].Value >>= nSplitMethod;
- else if (aFilterData[i].Name == "EPUBLayoutMethod")
- aFilterData[i].Value >>= nLayoutMethod;
+ if (rProp.Name == "EPUBVersion")
+ rProp.Value >>= nVersion;
+ else if (rProp.Name == "EPUBSplitMethod")
+ rProp.Value >>= nSplitMethod;
+ else if (rProp.Name == "EPUBLayoutMethod")
+ rProp.Value >>= nLayoutMethod;
}
// Build the export filter chain: the package has direct access to the ZIP
diff --git a/writerperfect/source/writer/WordPerfectImportFilter.cxx b/writerperfect/source/writer/WordPerfectImportFilter.cxx
index aee0d94f50f0..76baa0f21a92 100644
--- a/writerperfect/source/writer/WordPerfectImportFilter.cxx
+++ b/writerperfect/source/writer/WordPerfectImportFilter.cxx
@@ -92,16 +92,14 @@ static bool handleEmbeddedWPGImage(const librevenge::RVNGBinaryData& input,
bool WordPerfectImportFilter::importImpl(const Sequence<css::beans::PropertyValue>& aDescriptor)
{
- sal_Int32 nLength = aDescriptor.getLength();
- const PropertyValue* pValue = aDescriptor.getConstArray();
Reference<XInputStream> xInputStream;
Reference<XWindow> xDialogParent;
- for (sal_Int32 i = 0; i < nLength; i++)
+ for (const auto& rValue : aDescriptor)
{
- if (pValue[i].Name == "InputStream")
- pValue[i].Value >>= xInputStream;
- else if (pValue[i].Name == "ParentWindow")
- pValue[i].Value >>= xDialogParent;
+ if (rValue.Name == "InputStream")
+ rValue.Value >>= xInputStream;
+ else if (rValue.Name == "ParentWindow")
+ rValue.Value >>= xDialogParent;
}
if (!xInputStream.is())
{
diff --git a/writerperfect/source/writer/exp/xmlimp.cxx b/writerperfect/source/writer/exp/xmlimp.cxx
index dcb4d7641205..890e896d5fb9 100644
--- a/writerperfect/source/writer/exp/xmlimp.cxx
+++ b/writerperfect/source/writer/exp/xmlimp.cxx
@@ -59,14 +59,11 @@ OUString FindMediaDir(const OUString& rDocumentBaseURL,
OUString aMediaDir;
// See if filter data contains a media directory explicitly.
- for (sal_Int32 i = 0; i < rFilterData.getLength(); ++i)
- {
- if (rFilterData[i].Name == "RVNGMediaDir")
- {
- rFilterData[i].Value >>= aMediaDir;
- break;
- }
- }
+ auto pProp = std::find_if(
+ rFilterData.begin(), rFilterData.end(),
+ [](const beans::PropertyValue& rProp) { return rProp.Name == "RVNGMediaDir"; });
+ if (pProp != rFilterData.end())
+ pProp->Value >>= aMediaDir;
if (!aMediaDir.isEmpty())
return aMediaDir + "/";
@@ -91,14 +88,11 @@ OUString FindCoverImage(const OUString& rDocumentBaseURL, OUString& rMimeType,
OUString aRet;
// See if filter data contains a cover image explicitly.
- for (sal_Int32 i = 0; i < rFilterData.getLength(); ++i)
- {
- if (rFilterData[i].Name == "RVNGCoverImage")
- {
- rFilterData[i].Value >>= aRet;
- break;
- }
- }
+ auto pProp = std::find_if(
+ rFilterData.begin(), rFilterData.end(),
+ [](const beans::PropertyValue& rProp) { return rProp.Name == "RVNGCoverImage"; });
+ if (pProp != rFilterData.end())
+ pProp->Value >>= aRet;
if (!aRet.isEmpty())
{
@@ -143,35 +137,35 @@ void FindXMPMetadata(const uno::Reference<uno::XComponentContext>& xContext,
{
// See if filter data contains metadata explicitly.
OUString aValue;
- for (sal_Int32 i = 0; i < rFilterData.getLength(); ++i)
+ for (const auto& rProp : rFilterData)
{
- if (rFilterData[i].Name == "RVNGIdentifier")
+ if (rProp.Name == "RVNGIdentifier")
{
- rFilterData[i].Value >>= aValue;
+ rProp.Value >>= aValue;
if (!aValue.isEmpty())
rMetaData.insert("dc:identifier", aValue.toUtf8().getStr());
}
- else if (rFilterData[i].Name == "RVNGTitle")
+ else if (rProp.Name == "RVNGTitle")
{
- rFilterData[i].Value >>= aValue;
+ rProp.Value >>= aValue;
if (!aValue.isEmpty())
rMetaData.insert("dc:title", aValue.toUtf8().getStr());
}
- else if (rFilterData[i].Name == "RVNGInitialCreator")
+ else if (rProp.Name == "RVNGInitialCreator")
{
- rFilterData[i].Value >>= aValue;
+ rProp.Value >>= aValue;
if (!aValue.isEmpty())
rMetaData.insert("meta:initial-creator", aValue.toUtf8().getStr());
}
- else if (rFilterData[i].Name == "RVNGLanguage")
+ else if (rProp.Name == "RVNGLanguage")
{
- rFilterData[i].Value >>= aValue;
+ rProp.Value >>= aValue;
if (!aValue.isEmpty())
rMetaData.insert("dc:language", aValue.toUtf8().getStr());
}
- else if (rFilterData[i].Name == "RVNGDate")
+ else if (rProp.Name == "RVNGDate")
{
- rFilterData[i].Value >>= aValue;
+ rProp.Value >>= aValue;
if (!aValue.isEmpty())
rMetaData.insert("dc:date", aValue.toUtf8().getStr());
}
@@ -353,14 +347,11 @@ XMLImport::XMLImport(const uno::Reference<uno::XComponentContext>& xContext,
, mrPageMetafiles(rPageMetafiles)
{
uno::Sequence<beans::PropertyValue> aFilterData;
- for (sal_Int32 i = 0; i < rDescriptor.getLength(); ++i)
- {
- if (rDescriptor[i].Name == "FilterData")
- {
- rDescriptor[i].Value >>= aFilterData;
- break;
- }
- }
+ auto pDescriptor = std::find_if(
+ rDescriptor.begin(), rDescriptor.end(),
+ [](const beans::PropertyValue& rProp) { return rProp.Name == "FilterData"; });
+ if (pDescriptor != rDescriptor.end())
+ pDescriptor->Value >>= aFilterData;
maMediaDir = FindMediaDir(rURL, aFilterData);
diff --git a/xmlhelp/source/cxxhelp/provider/content.cxx b/xmlhelp/source/cxxhelp/provider/content.cxx
index 33a6bc6bf4cf..30c36cbf5414 100644
--- a/xmlhelp/source/cxxhelp/provider/content.cxx
+++ b/xmlhelp/source/cxxhelp/provider/content.cxx
@@ -234,14 +234,13 @@ uno::Any SAL_CALL Content::execute(
uno::Sequence< uno::Any > ret(propertyValues.getLength());
uno::Sequence< beans::Property > props(getProperties(Environment));
// No properties can be set
- for(sal_Int32 i = 0; i < ret.getLength(); ++i) {
- ret[i] <<= beans::UnknownPropertyException();
- for(sal_Int32 j = 0; j < props.getLength(); ++j)
- if(props[j].Name == propertyValues[i].Name) {
- ret[i] <<= lang::IllegalAccessException();
- break;
- }
- }
+ std::transform(propertyValues.begin(), propertyValues.end(), ret.begin(),
+ [&props](const beans::PropertyValue& rPropVal) {
+ if (std::any_of(props.begin(), props.end(),
+ [&rPropVal](const beans::Property& rProp) { return rProp.Name == rPropVal.Name; }))
+ return css::uno::toAny(lang::IllegalAccessException());
+ return css::uno::toAny(beans::UnknownPropertyException());
+ });
aRet <<= ret;
}
@@ -331,10 +330,8 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
rtl::Reference< ::ucbhelper::PropertyValueSet > xRow =
new ::ucbhelper::PropertyValueSet( m_xContext );
- for ( sal_Int32 n = 0; n < rProperties.getLength(); ++n )
+ for ( const beans::Property& rProp : rProperties )
{
- const beans::Property& rProp = rProperties[n];
-
if ( rProp.Name == "ContentType" )
xRow->appendString(
rProp,
diff --git a/xmlhelp/source/cxxhelp/provider/databases.cxx b/xmlhelp/source/cxxhelp/provider/databases.cxx
index e12ae7930853..61756c23eeda 100644
--- a/xmlhelp/source/cxxhelp/provider/databases.cxx
+++ b/xmlhelp/source/cxxhelp/provider/databases.cxx
@@ -1160,19 +1160,16 @@ Reference< deployment::XPackage > ExtensionIteratorBase::implGetHelpPackageFromP
{
Sequence< Reference< deployment::XPackage > > aPkgSeq = xPackage->getBundle
( Reference<task::XAbortChannel>(), Reference<ucb::XCommandEnvironment>() );
- sal_Int32 nPkgCount = aPkgSeq.getLength();
- const Reference< deployment::XPackage >* pSeq = aPkgSeq.getConstArray();
- for( sal_Int32 iPkg = 0 ; iPkg < nPkgCount ; ++iPkg )
+ auto pSubPkg = std::find_if(aPkgSeq.begin(), aPkgSeq.end(),
+ [&aHelpMediaType](const Reference< deployment::XPackage >& xSubPkg) {
+ const Reference< deployment::XPackageTypeInfo > xPackageTypeInfo = xSubPkg->getPackageType();
+ OUString aMediaType = xPackageTypeInfo->getMediaType();
+ return aMediaType == aHelpMediaType;
+ });
+ if (pSubPkg != aPkgSeq.end())
{
- const Reference< deployment::XPackage > xSubPkg = pSeq[ iPkg ];
- const Reference< deployment::XPackageTypeInfo > xPackageTypeInfo = xSubPkg->getPackageType();
- OUString aMediaType = xPackageTypeInfo->getMediaType();
- if( aMediaType == aHelpMediaType )
- {
- xHelpPackage = xSubPkg;
- o_xParentPackageBundle = xPackage;
- break;
- }
+ xHelpPackage = *pSubPkg;
+ o_xParentPackageBundle = xPackage;
}
}
else
@@ -1319,11 +1316,8 @@ void ExtensionIteratorBase::implGetLanguageVectorFromPackage( ::std::vector< OUS
OUString aExtensionPath = xPackage->getURL();
Sequence< OUString > aEntrySeq = m_xSFA->getFolderContents( aExtensionPath, true );
- const OUString* pSeq = aEntrySeq.getConstArray();
- sal_Int32 nCount = aEntrySeq.getLength();
- for( sal_Int32 i = 0 ; i < nCount ; ++i )
+ for( const OUString& aEntry : aEntrySeq )
{
- OUString aEntry = pSeq[i];
if( m_xSFA->isFolder( aEntry ) )
{
sal_Int32 nLastSlash = aEntry.lastIndexOf( '/' );
diff --git a/xmlhelp/source/cxxhelp/provider/resultsetbase.cxx b/xmlhelp/source/cxxhelp/provider/resultsetbase.cxx
index c399d32c660c..fa9ac9ba6f84 100644
--- a/xmlhelp/source/cxxhelp/provider/resultsetbase.cxx
+++ b/xmlhelp/source/cxxhelp/provider/resultsetbase.cxx
@@ -370,18 +370,17 @@ public:
beans::Property SAL_CALL getPropertyByName( const OUString& aName ) override
{
- for( int i = 0; i < m_aSeq.getLength(); ++i )
- if( aName == m_aSeq[i].Name )
- return m_aSeq[i];
+ auto pProp = std::find_if(m_aSeq.begin(), m_aSeq.end(),
+ [&aName](const beans::Property& rProp) { return aName == rProp.Name; });
+ if (pProp != m_aSeq.end())
+ return *pProp;
throw beans::UnknownPropertyException();
}
sal_Bool SAL_CALL hasPropertyByName( const OUString& Name ) override
{
- for( int i = 0; i < m_aSeq.getLength(); ++i )
- if( Name == m_aSeq[i].Name )
- return true;
- return false;
+ return std::any_of(m_aSeq.begin(), m_aSeq.end(),
+ [&Name](const beans::Property& rProp) { return Name == rProp.Name; });
}
private:
diff --git a/xmlhelp/source/treeview/tvfactory.cxx b/xmlhelp/source/treeview/tvfactory.cxx
index 60a0596f9dc4..65e624433bf6 100644
--- a/xmlhelp/source/treeview/tvfactory.cxx
+++ b/xmlhelp/source/treeview/tvfactory.cxx
@@ -87,10 +87,10 @@ TVFactory::createInstanceWithArguments(
}
OUString hierview;
- for( int i = 0; i < Arguments.getLength(); ++i )
+ for( const auto& rArgument : Arguments )
{
PropertyValue pV;
- if( ! ( Arguments[i] >>= pV ) )
+ if( ! ( rArgument >>= pV ) )
continue;
if( pV.Name != "nodepath" )
diff --git a/xmlhelp/source/treeview/tvread.cxx b/xmlhelp/source/treeview/tvread.cxx
index 32be860859c0..f11ae69d948e 100644
--- a/xmlhelp/source/treeview/tvread.cxx
+++ b/xmlhelp/source/treeview/tvread.cxx
@@ -897,19 +897,16 @@ Reference< deployment::XPackage > ExtensionIteratorBase::implGetHelpPackageFromP
{
Sequence< Reference< deployment::XPackage > > aPkgSeq = xPackage->getBundle
( Reference<task::XAbortChannel>(), Reference<ucb::XCommandEnvironment>() );
- sal_Int32 nPkgCount = aPkgSeq.getLength();
- const Reference< deployment::XPackage >* pSeq = aPkgSeq.getConstArray();
- for( sal_Int32 iPkg = 0 ; iPkg < nPkgCount ; ++iPkg )
+ auto pSubPkg = std::find_if(aPkgSeq.begin(), aPkgSeq.end(),
+ [](const Reference< deployment::XPackage >& xSubPkg) {
+ const Reference< deployment::XPackageTypeInfo > xPackageTypeInfo = xSubPkg->getPackageType();
+ OUString aMediaType = xPackageTypeInfo->getMediaType();
+ return aMediaType == aHelpMediaType;
+ });
+ if (pSubPkg != aPkgSeq.end())
{
- const Reference< deployment::XPackage > xSubPkg = pSeq[ iPkg ];
- const Reference< deployment::XPackageTypeInfo > xPackageTypeInfo = xSubPkg->getPackageType();
- OUString aMediaType = xPackageTypeInfo->getMediaType();
- if( aMediaType == aHelpMediaType )
- {
- xHelpPackage = xSubPkg;
- o_xParentPackageBundle = xPackage;
- break;
- }
+ xHelpPackage = *pSubPkg;
+ o_xParentPackageBundle = xPackage;
}
}
else
@@ -1025,11 +1022,8 @@ void ExtensionIteratorBase::implGetLanguageVectorFromPackage( ::std::vector< OUS
OUString aExtensionPath = xPackage->getURL();
Sequence< OUString > aEntrySeq = m_xSFA->getFolderContents( aExtensionPath, true );
- const OUString* pSeq = aEntrySeq.getConstArray();
- sal_Int32 nCount = aEntrySeq.getLength();
- for( sal_Int32 i = 0 ; i < nCount ; ++i )
+ for( const OUString& aEntry : aEntrySeq )
{
- OUString aEntry = pSeq[i];
if( m_xSFA->isFolder( aEntry ) )
{
sal_Int32 nLastSlash = aEntry.lastIndexOf( '/' );