diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-05-21 09:11:25 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-05-21 09:54:30 +0200 |
commit | 60846212c7f5271a86fd43555d633f77d59f5a10 (patch) | |
tree | ba3d9464385a2f3abdeea93b1fe887bf385f8463 | |
parent | 8477bbf8d6867e656b8132f0ddd682d08590a547 (diff) |
use for-range on Sequence in sfx2..sw
Change-Id: I09806869f2fdbae61f4c5d5c9db6859202bb63b5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94609
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | sfx2/source/appl/shutdowniconaqua.mm | 12 | ||||
-rw-r--r-- | shell/source/win32/simplemail/smplmailclient.cxx | 12 | ||||
-rw-r--r-- | svtools/source/uno/wizard/unowizard.cxx | 10 | ||||
-rw-r--r-- | svx/source/accessibility/AccessibleControlShape.cxx | 4 | ||||
-rw-r--r-- | svx/source/dialog/svxbmpnumvalueset.cxx | 27 | ||||
-rw-r--r-- | svx/source/items/customshapeitem.cxx | 7 | ||||
-rw-r--r-- | sw/qa/extras/htmlimport/htmlimport.cxx | 8 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 4 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 4 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport2.cxx | 18 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport3.cxx | 56 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport4.cxx | 16 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport6.cxx | 8 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport8.cxx | 4 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 8 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport2.cxx | 7 | ||||
-rw-r--r-- | sw/qa/extras/rtfexport/rtfexport.cxx | 26 | ||||
-rw-r--r-- | sw/qa/extras/rtfexport/rtfexport2.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/unocore/unoobj.cxx | 10 |
19 files changed, 108 insertions, 137 deletions
diff --git a/sfx2/source/appl/shutdowniconaqua.mm b/sfx2/source/appl/shutdowniconaqua.mm index 4a0f61b5dcf5..78c89f33865c 100644 --- a/sfx2/source/appl/shutdowniconaqua.mm +++ b/sfx2/source/appl/shutdowniconaqua.mm @@ -192,17 +192,17 @@ class RecentFilesStringLength : public ::cppu::WeakImplHelper< css::util::XStrin css::uno::Sequence< css::beans::PropertyValue >& rPickListEntry = aHistoryList[i]; RecentMenuEntry aRecentFile; - for ( int j = 0; j < rPickListEntry.getLength(); j++ ) + for ( const css::beans::PropertyValue& rProp : rPickListEntry ) { - css::uno::Any a = rPickListEntry[j].Value; + const css::uno::Any& a = rProp.Value; - if ( rPickListEntry[j].Name == HISTORY_PROPERTYNAME_URL ) + if ( rProp.Name == HISTORY_PROPERTYNAME_URL ) a >>= aRecentFile.aURL; - else if ( rPickListEntry[j].Name == HISTORY_PROPERTYNAME_FILTER ) + else if ( rProp.Name == HISTORY_PROPERTYNAME_FILTER ) a >>= aRecentFile.aFilter; - else if ( rPickListEntry[j].Name == HISTORY_PROPERTYNAME_TITLE ) + else if ( rProp.Name == HISTORY_PROPERTYNAME_TITLE ) a >>= aRecentFile.aTitle; - else if ( rPickListEntry[j].Name == HISTORY_PROPERTYNAME_PASSWORD ) + else if ( rProp.Name == HISTORY_PROPERTYNAME_PASSWORD ) a >>= aRecentFile.aPassword; } diff --git a/shell/source/win32/simplemail/smplmailclient.cxx b/shell/source/win32/simplemail/smplmailclient.cxx index 45331098b835..97c040321519 100644 --- a/shell/source/win32/simplemail/smplmailclient.cxx +++ b/shell/source/win32/simplemail/smplmailclient.cxx @@ -275,18 +275,18 @@ void CSmplMailClient::assembleCommandLine( rCommandArgs.push_back(to); } - Sequence<OUString> ccRecipients = xSimpleMailMessage->getCcRecipient(); - for (int i = 0; i < ccRecipients.getLength(); i++) + const Sequence<OUString> ccRecipients = xSimpleMailMessage->getCcRecipient(); + for (OUString const & s : ccRecipients) { rCommandArgs.push_back(CC); - rCommandArgs.push_back(ccRecipients[i]); + rCommandArgs.push_back(s); } - Sequence<OUString> bccRecipients = xSimpleMailMessage->getBccRecipient(); - for (int i = 0; i < bccRecipients.getLength(); i++) + const Sequence<OUString> bccRecipients = xSimpleMailMessage->getBccRecipient(); + for (OUString const & s : bccRecipients) { rCommandArgs.push_back(BCC); - rCommandArgs.push_back(bccRecipients[i]); + rCommandArgs.push_back(s); } OUString from = xSimpleMailMessage->getOriginator(); diff --git a/svtools/source/uno/wizard/unowizard.cxx b/svtools/source/uno/wizard/unowizard.cxx index fb4995c4a99f..ddc87539c66a 100644 --- a/svtools/source/uno/wizard/unowizard.cxx +++ b/svtools/source/uno/wizard/unowizard.cxx @@ -171,20 +171,22 @@ namespace { throw IllegalArgumentException( OUString(), i_rContext, 2 ); // each path must be of length 1, at least - for ( sal_Int32 i = 0; i < i_rPaths.getLength(); ++i ) + sal_Int32 i = 0; + for ( const Sequence< sal_Int16 >& rPath : i_rPaths ) { - if ( !i_rPaths[i].hasElements() ) + if ( !rPath.hasElements() ) throw IllegalArgumentException( OUString(), i_rContext, 2 ); // page IDs must be in ascending order - auto pPageId = std::adjacent_find(i_rPaths[i].begin(), i_rPaths[i].end(), std::greater_equal<sal_Int16>()); - if (pPageId != i_rPaths[i].end()) + auto pPageId = std::adjacent_find(rPath.begin(), rPath.end(), std::greater_equal<sal_Int16>()); + if (pPageId != rPath.end()) { throw IllegalArgumentException( "Path " + OUString::number(i) + ": invalid page ID sequence - each page ID must be greater than the previous one.", i_rContext, 2 ); } + ++i; } // if we have one path, that's okay diff --git a/svx/source/accessibility/AccessibleControlShape.cxx b/svx/source/accessibility/AccessibleControlShape.cxx index a775d572b254..2eaf8448f9c5 100644 --- a/svx/source/accessibility/AccessibleControlShape.cxx +++ b/svx/source/accessibility/AccessibleControlShape.cxx @@ -785,8 +785,8 @@ void AccessibleControlShape::initializeComposedState() // now, only states which are not in the responsibility of the UNO control should be part of this state set { Sequence< sal_Int16 > aInitStates = pComposedStates->getStates(); - for ( sal_Int32 i=0; i<aInitStates.getLength(); ++i ) - OSL_ENSURE( !isComposedState( aInitStates.getConstArray()[i] ), + for ( sal_Int16 state : aInitStates ) + OSL_ENSURE( !isComposedState( state ), "AccessibleControlShape::initializeComposedState: invalid initial composed state (should be controlled by the UNO-control)!" ); } #endif diff --git a/svx/source/dialog/svxbmpnumvalueset.cxx b/svx/source/dialog/svxbmpnumvalueset.cxx index 6ca545e9973d..e04ae513d4fa 100644 --- a/svx/source/dialog/svxbmpnumvalueset.cxx +++ b/svx/source/dialog/svxbmpnumvalueset.cxx @@ -284,23 +284,22 @@ void SvxNumValueSet::UserDraw( const UserDrawEvent& rUDEvt ) Any aLevelAny = xLevel->getByIndex(i); Sequence<PropertyValue> aLevel; aLevelAny >>= aLevel; - const PropertyValue* pValues = aLevel.getConstArray(); aNumberingTypes[i] = 0; aParentNumberings[i] = 0; - for(sal_Int32 nProperty = 0; nProperty < aLevel.getLength() - 1; nProperty++) + for(const PropertyValue& rProp : std::as_const(aLevel)) { - if ( pValues[nProperty].Name == "NumberingType" ) - pValues[nProperty].Value >>= aNumberingTypes[i]; - else if ( pValues[nProperty].Name == "BulletFontName" ) - pValues[nProperty].Value >>= sFontNames[i]; - else if ( pValues[nProperty].Name == "BulletChar" ) - pValues[nProperty].Value >>= sBulletChars[i]; - else if ( pValues[nProperty].Name == "Prefix" ) - pValues[nProperty].Value >>= sPrefixes[i]; - else if ( pValues[nProperty].Name == "Suffix" ) - pValues[nProperty].Value >>= sSuffixes[i]; - else if ( pValues[nProperty].Name == "ParentNumbering" ) - pValues[nProperty].Value >>= aParentNumberings[i]; + if ( rProp.Name == "NumberingType" ) + rProp.Value >>= aNumberingTypes[i]; + else if ( rProp.Name == "BulletFontName" ) + rProp.Value >>= sFontNames[i]; + else if ( rProp.Name == "BulletChar" ) + rProp.Value >>= sBulletChars[i]; + else if ( rProp.Name == "Prefix" ) + rProp.Value >>= sPrefixes[i]; + else if ( rProp.Name == "Suffix" ) + rProp.Value >>= sSuffixes[i]; + else if ( rProp.Name == "ParentNumbering" ) + rProp.Value >>= aParentNumberings[i]; } Sequence< PropertyValue > aProperties(2); PropertyValue* pProperties = aProperties.getArray(); diff --git a/svx/source/items/customshapeitem.cxx b/svx/source/items/customshapeitem.cxx index 0b63b0e8ccea..8626d893ed7e 100644 --- a/svx/source/items/customshapeitem.cxx +++ b/svx/source/items/customshapeitem.cxx @@ -120,12 +120,11 @@ void SdrCustomShapeGeometryItem::SetPropertyValue( const css::beans::PropertyVal css::uno::Any* pAny = GetPropertyValueByName( rPropVal.Name ); if ( pAny ) { // property is already available - sal_Int32 i; if ( auto rSecSequence = o3tl::tryAccess<css::uno::Sequence<beans::PropertyValue>>(*pAny) ) { // old property is a sequence->each entry has to be removed from the HashPairMap - for ( i = 0; i < rSecSequence->getLength(); i++ ) + for ( auto const & i : *rSecSequence ) { - PropertyPairHashMap::iterator aHashIter( aPropPairHashMap.find( PropertyPair( rPropVal.Name, (*rSecSequence)[ i ].Name ) ) ); + PropertyPairHashMap::iterator aHashIter( aPropPairHashMap.find( PropertyPair( rPropVal.Name, i.Name ) ) ); if ( aHashIter != aPropPairHashMap.end() ) aPropPairHashMap.erase( aHashIter ); } @@ -133,7 +132,7 @@ void SdrCustomShapeGeometryItem::SetPropertyValue( const css::beans::PropertyVal *pAny = rPropVal.Value; if ( auto rSecSequence = o3tl::tryAccess<css::uno::Sequence<beans::PropertyValue>>(*pAny) ) { // the new property is a sequence->each entry has to be inserted into the HashPairMap - for ( i = 0; i < rSecSequence->getLength(); i++ ) + for ( sal_Int32 i = 0; i < rSecSequence->getLength(); i++ ) { beans::PropertyValue const & rPropVal2 = (*rSecSequence)[ i ]; aPropPairHashMap[ PropertyPair( rPropVal.Name, rPropVal2.Name ) ] = i; diff --git a/sw/qa/extras/htmlimport/htmlimport.cxx b/sw/qa/extras/htmlimport/htmlimport.cxx index 35af0a03ad3e..fe323ca2592c 100644 --- a/sw/qa/extras/htmlimport/htmlimport.cxx +++ b/sw/qa/extras/htmlimport/htmlimport.cxx @@ -152,10 +152,8 @@ DECLARE_HTMLIMPORT_TEST(testListStyleType, "list-style.html") xLevels->getByIndex(0) >>= aProps; // 1st level bool bBulletFound=false; - for (int i = 0; i < aProps.getLength(); ++i) + for (beans::PropertyValue const & rProp : std::as_const(aProps)) { - const beans::PropertyValue& rProp = aProps[i]; - if (rProp.Name == "BulletChar") { // should be 'o'. @@ -173,10 +171,8 @@ DECLARE_HTMLIMPORT_TEST(testListStyleType, "list-style.html") uno::UNO_QUERY); xLevels->getByIndex(0) >>= aProps; // 1st level - for (int i = 0; i < aProps.getLength(); ++i) + for (beans::PropertyValue const & rProp : std::as_const(aProps)) { - const beans::PropertyValue& rProp = aProps[i]; - if (rProp.Name == "NumberingType") { printf("style is %d\n", rProp.Value.get<sal_Int16>()); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index ed5216c15a10..ac4bf4cd2053 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -896,10 +896,8 @@ DECLARE_OOXMLEXPORT_TEST(testTdf89890, "tdf89890.docx") xLevels->getByIndex(0) >>= aProps; // 1st level bool bFound = false; - for (int i = 0; i < aProps.getLength(); ++i) + for (beans::PropertyValue const & rProp : std::as_const(aProps)) { - const beans::PropertyValue& rProp = aProps[i]; - if (rProp.Name == "GraphicSize") { // Height of the graphic was too large: 4382 after import, then 2485 after roundtrip. diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx index df21b60935a5..087373aaf7e4 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx @@ -227,10 +227,8 @@ DECLARE_OOXMLEXPORT_TEST(testTdf82065_Ind_start_strict, "tdf82065_Ind_start_stri uno::Sequence<beans::PropertyValue> aProps; xLevels->getByIndex(0) >>= aProps; // 1st level bool bFoundIndentAt = false; - for (int i = 0; i < aProps.getLength(); ++i) + for (beans::PropertyValue const & rProp : std::as_const(aProps)) { - const beans::PropertyValue& rProp = aProps[i]; - if (rProp.Name == "IndentAt") { CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("IndentAt", double(6001), rProp.Value.get<double>(), 10 ); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx index 50b43fed1a44..fa75e2d6af85 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx @@ -574,10 +574,8 @@ DECLARE_OOXMLEXPORT_TEST(testI120928, "i120928.docx") uno::Reference<awt::XBitmap> xBitmap; sal_Int16 nNumberingType = -1; - for (int i = 0; i < aProps.getLength(); ++i) + for (beans::PropertyValue const & rProp : std::as_const(aProps)) { - const beans::PropertyValue& rProp = aProps[i]; - if (rProp.Name == "NumberingType") nNumberingType = rProp.Value.get<sal_Int16>(); else if (rProp.Name == "GraphicBitmap") @@ -643,10 +641,10 @@ DECLARE_OOXMLEXPORT_TEST(testWatermark, "watermark.docx") // 1st problem: last character was missing CPPUNIT_ASSERT_EQUAL(OUString("SAMPLE"), xShape->getString()); - uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(xShape, "CustomShapeGeometry"); + const uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(xShape, "CustomShapeGeometry"); bool bFound = false; - for (int i = 0; i < aProps.getLength(); ++i) - if (aProps[i].Name == "TextPath") + for (beans::PropertyValue const & prop : aProps) + if (prop.Name == "TextPath") bFound = true; // 2nd problem: v:textpath wasn't imported CPPUNIT_ASSERT_EQUAL(true, bFound); @@ -910,9 +908,8 @@ DECLARE_OOXMLEXPORT_TEST(testFdo66781, "fdo66781.docx") uno::Sequence<beans::PropertyValue> aProps; xLevels->getByIndex(0) >>= aProps; // 1st level - for (int i = 0; i < aProps.getLength(); ++i) + for (beans::PropertyValue const & rProp : std::as_const(aProps)) { - const beans::PropertyValue& rProp = aProps[i]; if (rProp.Name == "BulletChar") { CPPUNIT_ASSERT_EQUAL(OUString("\x0", 1, RTL_TEXTENCODING_ASCII_US), rProp.Value.get<OUString>()); @@ -1057,10 +1054,9 @@ DECLARE_OOXMLEXPORT_TEST(testFdo67737, "fdo67737.docx") { // The problem was that imported shapes did not import and render the 'flip:x' and 'flip:y' attributes uno::Reference<drawing::XShape> xArrow = getShape(1); - uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(xArrow, "CustomShapeGeometry"); - for (int i = 0; i < aProps.getLength(); ++i) + const uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(xArrow, "CustomShapeGeometry"); + for (beans::PropertyValue const & rProp : aProps) { - const beans::PropertyValue& rProp = aProps[i]; if (rProp.Name == "MirroredY") { CPPUNIT_ASSERT_EQUAL( true, rProp.Value.get<bool>() ); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx index 2876bb47929a..109c961c5fbc 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx @@ -191,20 +191,20 @@ DECLARE_OOXMLEXPORT_TEST(testStyleInheritance, "style-inheritance.docx") // Check latent styles uno::Sequence<beans::PropertyValue> aGrabBag = getProperty< uno::Sequence<beans::PropertyValue> >(mxComponent, "InteropGrabBag"); uno::Sequence<beans::PropertyValue> aLatentStyles; - for (sal_Int32 i = 0; i < aGrabBag.getLength(); ++i) - if (aGrabBag[i].Name == "latentStyles") - aGrabBag[i].Value >>= aLatentStyles; + for (beans::PropertyValue const & prop : std::as_const(aGrabBag)) + if (prop.Name == "latentStyles") + prop.Value >>= aLatentStyles; CPPUNIT_ASSERT(aLatentStyles.getLength()); // document should have latent styles // Check latent style default attributes OUString aCount; uno::Sequence<beans::PropertyValue> aLatentStyleExceptions; - for (sal_Int32 i = 0; i < aLatentStyles.getLength(); ++i) + for (beans::PropertyValue const & prop : std::as_const(aLatentStyles)) { - if (aLatentStyles[i].Name == "count") - aCount = aLatentStyles[i].Value.get<OUString>(); - else if (aLatentStyles[i].Name == "lsdExceptions") - aLatentStyles[i].Value >>= aLatentStyleExceptions; + if (prop.Name == "count") + aCount = prop.Value.get<OUString>(); + else if (prop.Name == "lsdExceptions") + prop.Value >>= aLatentStyleExceptions; } CPPUNIT_ASSERT_EQUAL(OUString("371"), aCount); // This check the "count" attribute. @@ -212,9 +212,9 @@ DECLARE_OOXMLEXPORT_TEST(testStyleInheritance, "style-inheritance.docx") uno::Sequence<beans::PropertyValue> aLatentStyleException; aLatentStyleExceptions[0].Value >>= aLatentStyleException; OUString aName; - for (sal_Int32 i = 0; i < aLatentStyleException.getLength(); ++i) - if (aLatentStyleException[i].Name == "name") - aName = aLatentStyleException[i].Value.get<OUString>(); + for (beans::PropertyValue const & prop : std::as_const(aLatentStyleException)) + if (prop.Name == "name") + aName = prop.Value.get<OUString>(); CPPUNIT_ASSERT_EQUAL(OUString("Normal"), aName); // This checks the "name" attribute of the first exception. // This numbering style wasn't roundtripped. @@ -420,13 +420,13 @@ DECLARE_OOXMLEXPORT_TEST(testSmartart, "smartart.docx") CPPUNIT_ASSERT(aGrabBag.hasElements()); // Grab Bag not empty bool bTheme = false; - for(int i = 0; i < aGrabBag.getLength(); ++i) + for(beans::PropertyValue const & prop : std::as_const(aGrabBag)) { - if (aGrabBag[i].Name == "OOXTheme") + if (prop.Name == "OOXTheme") { bTheme = true; uno::Reference<xml::dom::XDocument> aThemeDom; - CPPUNIT_ASSERT(aGrabBag[i].Value >>= aThemeDom); // PropertyValue of proper type + CPPUNIT_ASSERT(prop.Value >>= aThemeDom); // PropertyValue of proper type CPPUNIT_ASSERT(aThemeDom.get()); // Reference not empty } } @@ -442,42 +442,42 @@ DECLARE_OOXMLEXPORT_TEST(testSmartart, "smartart.docx") CPPUNIT_ASSERT(aGrabBag.hasElements()); // Grab Bag not empty bool bData = false, bLayout = false, bQStyle = false, bColor = false, bDrawing = false; - for(int i = 0; i < aGrabBag.getLength(); ++i) + for(beans::PropertyValue const & prop : std::as_const(aGrabBag)) { - if (aGrabBag[i].Name == "OOXData") + if (prop.Name == "OOXData") { bData = true; uno::Reference<xml::dom::XDocument> aDataDom; - CPPUNIT_ASSERT(aGrabBag[i].Value >>= aDataDom); // PropertyValue of proper type + CPPUNIT_ASSERT(prop.Value >>= aDataDom); // PropertyValue of proper type CPPUNIT_ASSERT(aDataDom.get()); // Reference not empty } - else if (aGrabBag[i].Name == "OOXLayout") + else if (prop.Name == "OOXLayout") { bLayout = true; uno::Reference<xml::dom::XDocument> aLayoutDom; - CPPUNIT_ASSERT(aGrabBag[i].Value >>= aLayoutDom); // PropertyValue of proper type + CPPUNIT_ASSERT(prop.Value >>= aLayoutDom); // PropertyValue of proper type CPPUNIT_ASSERT(aLayoutDom.get()); // Reference not empty } - else if (aGrabBag[i].Name == "OOXStyle") + else if (prop.Name == "OOXStyle") { bQStyle = true; uno::Reference<xml::dom::XDocument> aStyleDom; - CPPUNIT_ASSERT(aGrabBag[i].Value >>= aStyleDom); // PropertyValue of proper type + CPPUNIT_ASSERT(prop.Value >>= aStyleDom); // PropertyValue of proper type CPPUNIT_ASSERT(aStyleDom.get()); // Reference not empty } - else if (aGrabBag[i].Name == "OOXColor") + else if (prop.Name == "OOXColor") { bColor = true; uno::Reference<xml::dom::XDocument> aColorDom; - CPPUNIT_ASSERT(aGrabBag[i].Value >>= aColorDom); // PropertyValue of proper type + CPPUNIT_ASSERT(prop.Value >>= aColorDom); // PropertyValue of proper type CPPUNIT_ASSERT(aColorDom.get()); // Reference not empty } - else if (aGrabBag[i].Name == "OOXDrawing") + else if (prop.Name == "OOXDrawing") { bDrawing = true; uno::Sequence< uno::Any > diagramDrawing; uno::Reference<xml::dom::XDocument> aDrawingDom; - CPPUNIT_ASSERT(aGrabBag[i].Value >>= diagramDrawing); + CPPUNIT_ASSERT(prop.Value >>= diagramDrawing); CPPUNIT_ASSERT(diagramDrawing[0] >>= aDrawingDom); // PropertyValue of proper type CPPUNIT_ASSERT(aDrawingDom.get()); // Reference not empty } @@ -530,14 +530,14 @@ DECLARE_OOXMLEXPORT_TEST(testCustomXmlGrabBag, "customxml.docx") xTextDocumentPropertySet->getPropertyValue("InteropGrabBag") >>= aGrabBag; CPPUNIT_ASSERT(aGrabBag.hasElements()); // Grab Bag not empty bool CustomXml = false; - for(int i = 0; i < aGrabBag.getLength(); ++i) + for(beans::PropertyValue const & prop : std::as_const(aGrabBag)) { - if (aGrabBag[i].Name == "OOXCustomXml" || aGrabBag[i].Name == "OOXCustomXmlProps") + if (prop.Name == "OOXCustomXml" || prop.Name == "OOXCustomXmlProps") { CustomXml = true; uno::Reference<xml::dom::XDocument> aCustomXmlDom; uno::Sequence<uno::Reference<xml::dom::XDocument> > aCustomXmlDomList; - CPPUNIT_ASSERT(aGrabBag[i].Value >>= aCustomXmlDomList); // PropertyValue of proper type + CPPUNIT_ASSERT(prop.Value >>= aCustomXmlDomList); // PropertyValue of proper type sal_Int32 length = aCustomXmlDomList.getLength(); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), length); aCustomXmlDom = aCustomXmlDomList[0]; diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx index 08642a53da7f..621cc1325e6b 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx @@ -172,11 +172,11 @@ DECLARE_OOXMLEXPORT_TEST(testMsoSpt180, "mso-spt180.docx") return; uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY); - uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(xGroup->getByIndex(0), "CustomShapeGeometry"); + const uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(xGroup->getByIndex(0), "CustomShapeGeometry"); OUString aType; - for (int i = 0; i < aProps.getLength(); ++i) - if (aProps[i].Name == "Type") - aType = aProps[i].Value.get<OUString>(); + for (beans::PropertyValue const & prop : aProps) + if (prop.Name == "Type") + aType = prop.Value.get<OUString>(); // This was exported as borderCallout90, which is an invalid drawingML preset shape string. CPPUNIT_ASSERT_EQUAL(OUString("ooxml-borderCallout1"), aType); } @@ -467,14 +467,14 @@ DECLARE_OOXMLEXPORT_TEST(testEmbeddedXlsx, "embedded-xlsx.docx") // finally check the embedded files are present in the zipped document uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL()); - uno::Sequence<OUString> names = xNameAccess->getElementNames(); + const uno::Sequence<OUString> names = xNameAccess->getElementNames(); int nSheetFiles = 0; int nImageFiles = 0; - for (int i=0; i<names.getLength(); i++) + for (OUString const & n : names) { - if(names[i].startsWith("word/embeddings/oleObject")) + if(n.startsWith("word/embeddings/oleObject")) nSheetFiles++; - if(names[i].startsWith("word/media/image")) + if(n.startsWith("word/media/image")) nImageFiles++; } CPPUNIT_ASSERT_EQUAL(2, nSheetFiles); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx index 14d8a979facc..9a453ac89553 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx @@ -142,19 +142,17 @@ DECLARE_OOXMLEXPORT_TEST(testDMLCustomGeometry, "dml-customgeometry-cubicbezier. { // The problem was that a custom shape was not exported. - uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(getShape(1), "CustomShapeGeometry"); + const uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(getShape(1), "CustomShapeGeometry"); uno::Sequence<beans::PropertyValue> aPathProps; - for (int i = 0; i < aProps.getLength(); ++i) + for (beans::PropertyValue const & rProp : aProps) { - const beans::PropertyValue& rProp = aProps[i]; if (rProp.Name == "Path") rProp.Value >>= aPathProps; } uno::Sequence<drawing::EnhancedCustomShapeParameterPair> aPairs; uno::Sequence<drawing::EnhancedCustomShapeSegment> aSegments; - for (int i = 0; i < aPathProps.getLength(); ++i) + for (beans::PropertyValue const & rProp : std::as_const(aPathProps)) { - const beans::PropertyValue& rProp = aPathProps[i]; if (rProp.Name == "Coordinates") rProp.Value >>= aPairs; else if (rProp.Name == "Segments") diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx index e41501720a49..56e6e6b1079f 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx @@ -805,10 +805,8 @@ DECLARE_OOXMLEXPORT_TEST(testFdo59638, "fdo59638.docx") uno::Sequence<beans::PropertyValue> aProps; xLevels->getByIndex(0) >>= aProps; // 1st level - for (int i = 0; i < aProps.getLength(); ++i) + for (beans::PropertyValue const & rProp : std::as_const(aProps)) { - const beans::PropertyValue& rProp = aProps[i]; - if (rProp.Name == "BulletChar") { // Was '*', should be 'o'. diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index e08fadcc6b70..343c08a94d89 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -1303,10 +1303,8 @@ DECLARE_OOXMLIMPORT_TEST(testTdf101626, "tdf101626.docx") uno::Sequence<beans::PropertyValue> aProps; xLevels->getByIndex(0) >>= aProps; // 1st level - for (int i = 0; i < aProps.getLength(); ++i) + for (beans::PropertyValue const & rProp : std::as_const(aProps)) { - const beans::PropertyValue& rProp = aProps[i]; - if (rProp.Name == "BulletChar") { // the bulletChar has to be 0x2d! @@ -1325,10 +1323,8 @@ DECLARE_OOXMLIMPORT_TEST( testTdf106606, "tdf106606.docx" ) uno::Sequence<beans::PropertyValue> aProps; xLevels->getByIndex( 0 ) >>= aProps; // 1st level - for ( int i = 0; i < aProps.getLength(); ++i ) + for ( beans::PropertyValue const & rProp : std::as_const(aProps)) { - const beans::PropertyValue& rProp = aProps[i]; - // If the image was prematurely removed from cache when processed for previous numbering list, then the sequence hasn't the property. if ( rProp.Name == "GraphicBitmap" ) return true; diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx index be99a8b9c47a..78e79add953a 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx @@ -539,12 +539,11 @@ DECLARE_OOXMLIMPORT_TEST(testTdf103345, "numbering-circle.docx") uno::Sequence<beans::PropertyValue> aProps; xLevels->getByIndex(0) >>= aProps; // 1st level - for (int i = 0; i < aProps.getLength(); ++i) + for (beans::PropertyValue const& prop : std::as_const(aProps)) { - if (aProps[i].Name == "NumberingType") + if (prop.Name == "NumberingType") { - CPPUNIT_ASSERT_EQUAL(style::NumberingType::CIRCLE_NUMBER, - aProps[i].Value.get<sal_Int16>()); + CPPUNIT_ASSERT_EQUAL(style::NumberingType::CIRCLE_NUMBER, prop.Value.get<sal_Int16>()); return; } } diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx index 76d880c17a0f..4fec96ab05d5 100644 --- a/sw/qa/extras/rtfexport/rtfexport.cxx +++ b/sw/qa/extras/rtfexport/rtfexport.cxx @@ -410,19 +410,17 @@ DECLARE_RTFEXPORT_TEST(testFdo53113, "fdo53113.odt") * xray oCoordinates(1).Second.Value ' 102 */ - uno::Sequence<beans::PropertyValue> aProps + const uno::Sequence<beans::PropertyValue> aProps = getProperty<uno::Sequence<beans::PropertyValue>>(getShape(1), "CustomShapeGeometry"); uno::Sequence<beans::PropertyValue> aPathProps; - for (int i = 0; i < aProps.getLength(); ++i) + for (beans::PropertyValue const& rProp : aProps) { - const beans::PropertyValue& rProp = aProps[i]; if (rProp.Name == "Path") rProp.Value >>= aPathProps; } uno::Sequence<drawing::EnhancedCustomShapeParameterPair> aPairs; - for (int i = 0; i < aPathProps.getLength(); ++i) + for (beans::PropertyValue const& rProp : std::as_const(aPathProps)) { - const beans::PropertyValue& rProp = aPathProps[i]; if (rProp.Name == "Coordinates") rProp.Value >>= aPairs; } @@ -540,10 +538,8 @@ DECLARE_RTFEXPORT_TEST(testI120928, "i120928.rtf") uno::Reference<awt::XBitmap> xBitmap; sal_Int16 nNumberingType = -1; - for (int i = 0; i < aProps.getLength(); ++i) + for (beans::PropertyValue const& rProp : std::as_const(aProps)) { - const beans::PropertyValue& rProp = aProps[i]; - if (rProp.Name == "NumberingType") nNumberingType = rProp.Value.get<sal_Int16>(); else if (rProp.Name == "GraphicBitmap") @@ -669,10 +665,8 @@ DECLARE_RTFEXPORT_TEST(testFdo66682, "fdo66682.rtf") xLevels->getByIndex(0) >>= aProps; // 1st level OUString aListFormat; - for (int i = 0; i < aProps.getLength(); ++i) + for (beans::PropertyValue const& rProp : std::as_const(aProps)) { - const beans::PropertyValue& rProp = aProps[i]; - if (rProp.Name == "ListFormat") aListFormat = rProp.Value.get<OUString>(); } @@ -1282,9 +1276,9 @@ DECLARE_RTFEXPORT_TEST(testTdf104085, "tdf104085.rtf") uno::UNO_QUERY); uno::Sequence<beans::PropertyValue> aProps; xLevels->getByIndex(0) >>= aProps; - for (int i = 0; i < aProps.getLength(); ++i) + for (beans::PropertyValue const& prop : std::as_const(aProps)) { - if (aProps[i].Name == "BulletChar") + if (prop.Name == "BulletChar") return; } CPPUNIT_FAIL("no BulletChar property"); @@ -1310,12 +1304,12 @@ DECLARE_RTFEXPORT_TEST(testLeveljcCenter, "leveljc-center.rtf") uno::UNO_QUERY); uno::Sequence<beans::PropertyValue> aProps; xLevels->getByIndex(0) >>= aProps; - for (int i = 0; i < aProps.getLength(); ++i) + for (beans::PropertyValue const& prop : std::as_const(aProps)) { - if (aProps[i].Name == "Adjust") + if (prop.Name == "Adjust") { sal_Int16 nValue = 0; - CPPUNIT_ASSERT(aProps[i].Value >>= nValue); + CPPUNIT_ASSERT(prop.Value >>= nValue); CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER, nValue); return; } diff --git a/sw/qa/extras/rtfexport/rtfexport2.cxx b/sw/qa/extras/rtfexport/rtfexport2.cxx index d20b46873dd9..75226144932c 100644 --- a/sw/qa/extras/rtfexport/rtfexport2.cxx +++ b/sw/qa/extras/rtfexport/rtfexport2.cxx @@ -887,10 +887,8 @@ DECLARE_RTFEXPORT_TEST(testFdo59638, "fdo59638.rtf") uno::Sequence<beans::PropertyValue> aProps; xLevels->getByIndex(0) >>= aProps; // 1st level - for (int i = 0; i < aProps.getLength(); ++i) + for (beans::PropertyValue const& rProp : std::as_const(aProps)) { - const beans::PropertyValue& rProp = aProps[i]; - if (rProp.Name == "BulletChar") { // Was '*', should be 'o'. diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index ddd352386d11..c3690beab846 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -521,21 +521,21 @@ SwUnoCursorHelper::SetCursorPropertyValue( SfxItemPropertyMap const& rMap(rPropSet.getPropertyMap()); SfxItemSet items{rPam.GetDoc()->GetAttrPool(), aCharAutoFormatSetRange}; - for (sal_Int32 i = 0; i < props.getLength(); ++i) + for (beans::NamedValue const & prop : std::as_const(props)) { SfxItemPropertySimpleEntry const*const pEntry = - rMap.getByName(props[i].Name); + rMap.getByName(prop.Name); if (!pEntry) { throw beans::UnknownPropertyException( - "Unknown property: " + props[i].Name); + "Unknown property: " + prop.Name); } if (pEntry->nFlags & beans::PropertyAttribute::READONLY) { throw beans::PropertyVetoException( - "Property is read-only: " + props[i].Name); + "Property is read-only: " + prop.Name); } - rPropSet.setPropertyValue(*pEntry, props[i].Value, items); + rPropSet.setPropertyValue(*pEntry, prop.Value, items); } SwFormatAutoFormat item(RES_PARATR_LIST_AUTOFMT); |