summaryrefslogtreecommitdiff
path: root/oox/source
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-08-12 23:07:08 +0300
committerArkadiy Illarionov <qarkai@gmail.com>2019-08-27 12:58:33 +0200
commit36543fc426f0358086484f9b8e439cf051d0e12b (patch)
treedac91006fb5b9a902e2bfee05099a8ebe4c1fa71 /oox/source
parentb742b4d7f1f3bb6e1fce45ccf5d885e587e01801 (diff)
Simplify Sequence iterations in oox
Use range-based loops, STL and comphelper functions Change-Id: Ic3a186e7381bd8391ab85a2602a30f06fe5db740 Reviewed-on: https://gerrit.libreoffice.org/78089 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-by: Arkadiy Illarionov <qarkai@gmail.com>
Diffstat (limited to 'oox/source')
-rw-r--r--oox/source/core/filterbase.cxx11
-rw-r--r--oox/source/core/xmlfilterbase.cxx59
-rw-r--r--oox/source/docprop/docprophandler.cxx25
-rw-r--r--oox/source/docprop/ooxmldocpropimport.cxx46
-rw-r--r--oox/source/drawingml/chart/chartspaceconverter.cxx20
-rw-r--r--oox/source/drawingml/customshapeproperties.cxx26
-rw-r--r--oox/source/drawingml/diagram/diagram.cxx10
-rw-r--r--oox/source/drawingml/shape.cxx30
-rw-r--r--oox/source/drawingml/textcharacterproperties.cxx12
-rw-r--r--oox/source/export/chartexport.cxx119
-rw-r--r--oox/source/export/drawingml.cxx606
-rw-r--r--oox/source/export/shapes.cxx11
-rw-r--r--oox/source/helper/propertyset.cxx6
-rw-r--r--oox/source/mathml/importutils.cxx10
-rw-r--r--oox/source/ole/vbaexport.cxx8
-rw-r--r--oox/source/ppt/timenode.cxx9
-rw-r--r--oox/source/shape/ShapeFilterBase.cxx6
-rw-r--r--oox/source/vml/vmlformatting.cxx3
-rw-r--r--oox/source/vml/vmlshape.cxx55
19 files changed, 482 insertions, 590 deletions
diff --git a/oox/source/core/filterbase.cxx b/oox/source/core/filterbase.cxx
index 1346353c9d22..c99c77ba870f 100644
--- a/oox/source/core/filterbase.cxx
+++ b/oox/source/core/filterbase.cxx
@@ -29,6 +29,7 @@
#include <com/sun/star/uno/XComponentContext.hpp>
#include <cppuhelper/supportsservice.hxx>
#include <comphelper/documentconstants.hxx>
+#include <comphelper/sequence.hxx>
#include <unotools/mediadescriptor.hxx>
#include <osl/mutex.hxx>
#include <osl/diagnose.h>
@@ -430,14 +431,8 @@ void SAL_CALL FilterBase::initialize( const Sequence< Any >& rArgs )
{
css::uno::Sequence<OUString> aUserDataSeq;
rVal.Value >>= aUserDataSeq;
- sal_Int32 nUserDataSeqLen = aUserDataSeq.getLength();
- for (sal_Int32 j = 0; j < nUserDataSeqLen; ++j)
- {
- if (aUserDataSeq[j] == "macro-enabled")
- {
- mxImpl->mbExportVBA = true;
- }
- }
+ if (comphelper::findValue(aUserDataSeq, "macro-enabled") != -1)
+ mxImpl->mbExportVBA = true;
}
else if (rVal.Name == "Flags")
{
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index d62250344686..48e1ad66f079 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -163,8 +163,8 @@ void registerNamespaces( FastParser& rParser )
// Filter out duplicates: a namespace can have multiple URLs, think of
// strict vs transitional.
std::set<sal_Int32> aSet;
- for (sal_Int32 i = 0; i < ids.getLength(); ++i)
- aSet.insert(ids[i].Second);
+ for (const auto& rId : ids)
+ aSet.insert(rId.Second);
for (auto const& elem : aSet)
rParser.registerNamespace(elem);
@@ -878,20 +878,16 @@ Reference< XInputStream > XmlFilterBase::implGetInputStream( MediaDescriptor& rM
Reference<XStream> XmlFilterBase::implGetOutputStream( MediaDescriptor& rMediaDescriptor ) const
{
- Sequence< NamedValue > aMediaEncData = rMediaDescriptor.getUnpackedValueOrDefault(
+ const Sequence< NamedValue > aMediaEncData = rMediaDescriptor.getUnpackedValueOrDefault(
MediaDescriptor::PROP_ENCRYPTIONDATA(),
Sequence< NamedValue >() );
OUString aPassword;
- for (int i=0; i<aMediaEncData.getLength(); i++)
- {
- if (aMediaEncData[i].Name == "OOXPassword")
- {
- Any& any = aMediaEncData[i].Value;
- any >>= aPassword;
- break;
- }
- }
+ auto pProp = std::find_if(aMediaEncData.begin(), aMediaEncData.end(),
+ [](const NamedValue& rProp) { return rProp.Name == "OOXPassword"; });
+ if (pProp != aMediaEncData.end())
+ pProp->Value >>= aPassword;
+
if (aPassword.isEmpty())
{
return FilterBase::implGetOutputStream( rMediaDescriptor );
@@ -909,21 +905,16 @@ bool XmlFilterBase::implFinalizeExport( MediaDescriptor& rMediaDescriptor )
{
bool bRet = true;
- Sequence< NamedValue > aMediaEncData = rMediaDescriptor.getUnpackedValueOrDefault(
+ const Sequence< NamedValue > aMediaEncData = rMediaDescriptor.getUnpackedValueOrDefault(
MediaDescriptor::PROP_ENCRYPTIONDATA(),
Sequence< NamedValue >() );
OUString aPassword;
- for (int i=0; i<aMediaEncData.getLength(); i++)
- {
- if (aMediaEncData[i].Name == "OOXPassword")
- {
- Any& any = aMediaEncData[i].Value;
- any >>= aPassword;
- break;
- }
- }
+ auto pProp = std::find_if(aMediaEncData.begin(), aMediaEncData.end(),
+ [](const NamedValue& rProp) { return rProp.Name == "OOXPassword"; });
+ if (pProp != aMediaEncData.end())
+ pProp->Value >>= aPassword;
if (!aPassword.isEmpty())
{
@@ -979,19 +970,17 @@ void XmlFilterBase::importCustomFragments(css::uno::Reference<css::embed::XStora
Reference<XRelationshipAccess> xRelations(xDocumentStorage, UNO_QUERY);
if (xRelations.is())
{
- uno::Sequence<uno::Sequence<beans::StringPair>> aSeqs = xRelations->getAllRelationships();
+ const uno::Sequence<uno::Sequence<beans::StringPair>> aSeqs = xRelations->getAllRelationships();
std::vector<StreamDataSequence> aCustomFragments;
std::vector<OUString> aCustomFragmentTypes;
std::vector<OUString> aCustomFragmentTargets;
- for (sal_Int32 j = 0; j < aSeqs.getLength(); j++)
+ for (const uno::Sequence<beans::StringPair>& aSeq : aSeqs)
{
OUString sType;
OUString sTarget;
- 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];
if (aPair.First == "Target")
sTarget = aPair.Second;
else if (aPair.First == "Type")
@@ -1070,32 +1059,32 @@ void XmlFilterBase::exportCustomFragments()
uno::Sequence<beans::PropertyValue> propList;
xPropSet->getPropertyValue(aName) >>= propList;
- for (sal_Int32 nProp = 0; nProp < propList.getLength(); ++nProp)
+ for (const auto& rProp : std::as_const(propList))
{
- const OUString propName = propList[nProp].Name;
+ const OUString propName = rProp.Name;
if (propName == "OOXCustomXml")
{
- propList[nProp].Value >>= customXmlDomlist;
+ rProp.Value >>= customXmlDomlist;
}
else if (propName == "OOXCustomXmlProps")
{
- propList[nProp].Value >>= customXmlDomPropslist;
+ rProp.Value >>= customXmlDomPropslist;
}
else if (propName == "OOXCustomFragments")
{
- propList[nProp].Value >>= customFragments;
+ rProp.Value >>= customFragments;
}
else if (propName == "OOXCustomFragmentTypes")
{
- propList[nProp].Value >>= customFragmentTypes;
+ rProp.Value >>= customFragmentTypes;
}
else if (propName == "OOXCustomFragmentTargets")
{
- propList[nProp].Value >>= customFragmentTargets;
+ rProp.Value >>= customFragmentTargets;
}
else if (propName == "OOXContentTypes")
{
- propList[nProp].Value >>= aContentTypes;
+ rProp.Value >>= aContentTypes;
}
}
diff --git a/oox/source/docprop/docprophandler.cxx b/oox/source/docprop/docprophandler.cxx
index cf3ce7b5d48e..258270774595 100644
--- a/oox/source/docprop/docprophandler.cxx
+++ b/oox/source/docprop/docprophandler.cxx
@@ -249,22 +249,19 @@ void OOXMLDocPropHandler::UpdateDocStatistic( const OUString& aChars )
if ( !aName.isEmpty() )
{
- bool bFound = false;
- sal_Int32 nLen = aSet.getLength();
- for ( sal_Int32 nInd = 0; nInd < nLen; nInd++ )
- if ( aSet[nInd].Name == aName )
- {
- aSet[nInd].Value <<= aChars.toInt32();
- bFound = true;
+ sal_Int32 nInd = 0;
+ for ( auto pProp = aSet.getConstArray(); nInd < aSet.getLength(); ++nInd )
+ if ( pProp[nInd].Name == aName )
break;
- }
- if ( !bFound )
- {
- aSet.realloc( nLen + 1 );
- aSet[nLen].Name = aName;
- aSet[nLen].Value <<= aChars.toInt32();
- }
+ if (nInd == aSet.getLength())
+ aSet.realloc( nInd + 1 );
+
+ beans::NamedValue aProp;
+ aProp.Name = aName;
+ aProp.Value <<= aChars.toInt32();
+
+ aSet[nInd] = aProp;
m_xDocProp->setDocumentStatistics( aSet );
}
diff --git a/oox/source/docprop/ooxmldocpropimport.cxx b/oox/source/docprop/ooxmldocpropimport.cxx
index 1a257792dfbd..b6a2c5a0b812 100644
--- a/oox/source/docprop/ooxmldocpropimport.cxx
+++ b/oox/source/docprop/ooxmldocpropimport.cxx
@@ -56,33 +56,29 @@ Sequence< InputSource > lclGetRelatedStreams( const Reference< XStorage >& rxSto
Reference< XRelationshipAccess > xRelation( rxStorage, UNO_QUERY_THROW );
Reference< XHierarchicalStorageAccess > xHierarchy( rxStorage, UNO_QUERY_THROW );
- Sequence< Sequence< StringPair > > aPropsInfo = xRelation->getRelationshipsByType( rStreamType );
+ const Sequence< Sequence< StringPair > > aPropsInfo = xRelation->getRelationshipsByType( rStreamType );
::std::vector< InputSource > aResult;
- for( sal_Int32 nIndex = 0, nLength = aPropsInfo.getLength(); nIndex < nLength; ++nIndex )
+ for( const Sequence< StringPair >& rEntries : aPropsInfo )
{
- const Sequence< StringPair >& rEntries = aPropsInfo[ nIndex ];
- for( sal_Int32 nEntryIndex = 0, nEntryLength = rEntries.getLength(); nEntryIndex < nEntryLength; ++nEntryIndex )
+ auto pEntry = std::find_if(rEntries.begin(), rEntries.end(),
+ [](const StringPair& rEntry) { return rEntry.First == "Target"; });
+ if (pEntry != rEntries.end())
{
- const StringPair& rEntry = rEntries[ nEntryIndex ];
- if ( rEntry.First == "Target" )
+ // The stream path is always a relative one, ignore the leading "/" if it's there.
+ OUString aStreamPath = pEntry->Second;
+ if (aStreamPath.startsWith("/"))
+ aStreamPath = aStreamPath.copy(1);
+
+ Reference< XExtendedStorageStream > xExtStream(
+ xHierarchy->openStreamElementByHierarchicalName( aStreamPath, ElementModes::READ ), UNO_SET_THROW );
+ Reference< XInputStream > xInStream = xExtStream->getInputStream();
+ if( xInStream.is() )
{
- // The stream path is always a relative one, ignore the leading "/" if it's there.
- OUString aStreamPath = rEntry.Second;
- if (aStreamPath.startsWith("/"))
- aStreamPath = aStreamPath.copy(1);
-
- Reference< XExtendedStorageStream > xExtStream(
- xHierarchy->openStreamElementByHierarchicalName( aStreamPath, ElementModes::READ ), UNO_SET_THROW );
- Reference< XInputStream > xInStream = xExtStream->getInputStream();
- if( xInStream.is() )
- {
- aResult.emplace_back();
- aResult.back().sSystemId = rEntry.Second;
- aResult.back().aInputStream = xExtStream->getInputStream();
- }
- break;
+ aResult.emplace_back();
+ aResult.back().sSystemId = pEntry->Second;
+ aResult.back().aInputStream = xExtStream->getInputStream();
}
}
}
@@ -157,10 +153,10 @@ void SAL_CALL DocumentPropertiesImport::importProperties(
if( aCoreStreams.hasElements() )
aParser.parseStream( aCoreStreams[ 0 ], true );
- for( sal_Int32 nIndex = 0; nIndex < aExtStreams.getLength(); ++nIndex )
- aParser.parseStream( aExtStreams[ nIndex ], true );
- for( sal_Int32 nIndex = 0; nIndex < aCustomStreams.getLength(); ++nIndex )
- aParser.parseStream( aCustomStreams[ nIndex ], true );
+ for( const auto& rExtStream : std::as_const(aExtStreams) )
+ aParser.parseStream( rExtStream, true );
+ for( const auto& rCustomStream : std::as_const(aCustomStreams) )
+ aParser.parseStream( rCustomStream, true );
}
}
diff --git a/oox/source/drawingml/chart/chartspaceconverter.cxx b/oox/source/drawingml/chart/chartspaceconverter.cxx
index 4b8d6655e40e..997aa4d41fbe 100644
--- a/oox/source/drawingml/chart/chartspaceconverter.cxx
+++ b/oox/source/drawingml/chart/chartspaceconverter.cxx
@@ -105,21 +105,21 @@ static bool lcl_useWorkaroundForNoGapInOOXML( Reference< chart2::XChartDocument
if (!xDSCont.is())
return false;
- Sequence<uno::Reference<chart2::XDataSeries> > aDataSeriesSeq = xDSCont->getDataSeries();
+ const Sequence<uno::Reference<chart2::XDataSeries> > aDataSeriesSeq = xDSCont->getDataSeries();
bool bHasNoGapBlankValue = false;
bool bHasEmptyCell = false;
- for (sal_Int32 i = 0; i < aDataSeriesSeq.getLength(); ++i)
+ for (const auto& rDataSeries : aDataSeriesSeq)
{
- uno::Reference<chart2::data::XDataSource> xDSrc(aDataSeriesSeq[i], uno::UNO_QUERY);
+ uno::Reference<chart2::data::XDataSource> xDSrc(rDataSeries, uno::UNO_QUERY);
if (!xDSrc.is())
return false;
- uno::Sequence<Reference<chart2::data::XLabeledDataSequence> > aDataSeqs = xDSrc->getDataSequences();
- for (sal_Int32 j = 0; j < aDataSeqs.getLength(); ++j)
+ const uno::Sequence<Reference<chart2::data::XLabeledDataSequence> > aDataSeqs = xDSrc->getDataSequences();
+ for (const auto& rDataSeq : aDataSeqs)
{
- Reference<chart2::data::XDataSequence> xValues = aDataSeqs[j]->getValues();
+ Reference<chart2::data::XDataSequence> xValues = rDataSeq->getValues();
if(!xValues.is())
return false;
Reference<beans::XPropertySet> xPropSet(xValues, uno::UNO_QUERY);
@@ -130,14 +130,14 @@ static bool lcl_useWorkaroundForNoGapInOOXML( Reference< chart2::XChartDocument
xPropSet->getPropertyValue("Role") >>= aRoleName;
if (aRoleName == "values-y")
{
- uno::Sequence<uno::Any> aData = xValues->getData();
- for (sal_Int32 nVal = 0; nVal < aData.getLength(); ++nVal)
+ const uno::Sequence<uno::Any> aData = xValues->getData();
+ for (const auto& rVal : aData)
{
double fVal;
OUString sStr;
- if (aData[nVal] >>= fVal)
+ if (rVal >>= fVal)
continue;
- else if (aData[nVal] >>= sStr)
+ else if (rVal >>= sStr)
bHasNoGapBlankValue = true;
else
bHasEmptyCell = true;
diff --git a/oox/source/drawingml/customshapeproperties.cxx b/oox/source/drawingml/customshapeproperties.cxx
index 048fb4610709..14c7a777811f 100644
--- a/oox/source/drawingml/customshapeproperties.cxx
+++ b/oox/source/drawingml/customshapeproperties.cxx
@@ -154,20 +154,18 @@ void CustomShapeProperties::pushToPropSet(
aPropSet.setProperty( PROP_CustomShapeGeometry, aSeq );
const OUString sCustomShapeGeometry("CustomShapeGeometry");
+ const OUString sAdjustmentValues("AdjustmentValues");
uno::Any aGeoPropSet = xPropSet->getPropertyValue( sCustomShapeGeometry );
uno::Sequence< beans::PropertyValue > aGeoPropSeq;
- sal_Int32 i, nCount = 0;
if (aGeoPropSet >>= aGeoPropSeq)
{
- nCount = aGeoPropSeq.getLength();
- for ( i = 0; i < nCount; i++ )
+ for ( const auto& rGeoProp : std::as_const(aGeoPropSeq) )
{
- const OUString sAdjustmentValues("AdjustmentValues");
- if ( aGeoPropSeq[ i ].Name == sAdjustmentValues )
+ if ( rGeoProp.Name == sAdjustmentValues )
{
OUString presetTextWarp;
- if ( aGeoPropSeq[ i ].Value >>= presetTextWarp )
+ if ( rGeoProp.Value >>= presetTextWarp )
{
aPropertyMap.setProperty( PROP_PresetTextWarp, presetTextWarp );
}
@@ -180,14 +178,12 @@ void CustomShapeProperties::pushToPropSet(
const OUString sType = "Type";
if ( aGeoPropSet >>= aGeoPropSeq )
{
- nCount = aGeoPropSeq.getLength();
- for ( i = 0; i < nCount; i++ )
+ for ( auto& rGeoProp : aGeoPropSeq )
{
- const OUString sAdjustmentValues("AdjustmentValues");
- if ( aGeoPropSeq[ i ].Name == sAdjustmentValues )
+ if ( rGeoProp.Name == sAdjustmentValues )
{
uno::Sequence< css::drawing::EnhancedCustomShapeAdjustmentValue > aAdjustmentSeq;
- if ( aGeoPropSeq[ i ].Value >>= aAdjustmentSeq )
+ if ( rGeoProp.Value >>= aAdjustmentSeq )
{
int nIndex=0;
for (auto const& adjustmentGuide : maAdjustmentGuideList)
@@ -211,16 +207,16 @@ void CustomShapeProperties::pushToPropSet(
aAdjustmentSeq[ nIndex++ ] = aAdjustmentVal;
}
}
- aGeoPropSeq[ i ].Value <<= aAdjustmentSeq;
+ rGeoProp.Value <<= aAdjustmentSeq;
xPropSet->setPropertyValue( sCustomShapeGeometry, Any( aGeoPropSeq ) );
}
}
- else if ( aGeoPropSeq[ i ].Name == sType )
+ else if ( rGeoProp.Name == sType )
{
if ( sConnectorShapeType.getLength() > 0 )
- aGeoPropSeq[ i ].Value <<= sConnectorShapeType;
+ rGeoProp.Value <<= sConnectorShapeType;
else
- aGeoPropSeq[ i ].Value <<= OUString( "ooxml-CustomShape" );
+ rGeoProp.Value <<= OUString( "ooxml-CustomShape" );
}
}
}
diff --git a/oox/source/drawingml/diagram/diagram.cxx b/oox/source/drawingml/diagram/diagram.cxx
index 678299ea3abd..d690cdc40991 100644
--- a/oox/source/drawingml/diagram/diagram.cxx
+++ b/oox/source/drawingml/diagram/diagram.cxx
@@ -692,15 +692,15 @@ void reloadDiagram(SdrObject* pObj, core::XmlFilterBase& rFilter)
// retrieve the doms from the GrabBag
uno::Sequence<beans::PropertyValue> propList;
xPropSet->getPropertyValue(UNO_NAME_MISC_OBJ_INTEROPGRABBAG) >>= propList;
- for (sal_Int32 nProp = 0; nProp < propList.getLength(); ++nProp)
+ for (const auto& rProp : std::as_const(propList))
{
- OUString propName = propList[nProp].Name;
+ OUString propName = rProp.Name;
if (propName == "OOXLayout")
- propList[nProp].Value >>= layoutDom;
+ rProp.Value >>= layoutDom;
else if (propName == "OOXStyle")
- propList[nProp].Value >>= styleDom;
+ rProp.Value >>= styleDom;
else if (propName == "OOXColor")
- propList[nProp].Value >>= colorDom;
+ rProp.Value >>= colorDom;
}
ShapePtr pShape(new Shape());
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index b14cbef6ac15..eba300fc89d5 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -1503,15 +1503,8 @@ void Shape::keepDiagramCompatibilityInfo()
// We keep the previous items, if present
if ( aGrabBag.hasElements() )
- {
- sal_Int32 length = aGrabBag.getLength();
- aGrabBag.realloc( length+maDiagramDoms.getLength() );
-
- for( sal_Int32 i = 0; i < maDiagramDoms.getLength(); ++i )
- aGrabBag[length+i] = maDiagramDoms[i];
-
- xSet->setPropertyValue( aGrabBagPropName, Any( aGrabBag ) );
- } else
+ xSet->setPropertyValue( aGrabBagPropName, Any( comphelper::concatSequences(aGrabBag, maDiagramDoms) ) );
+ else
xSet->setPropertyValue( aGrabBagPropName, Any( maDiagramDoms ) );
}
catch( const Exception& )
@@ -1771,20 +1764,21 @@ void Shape::putPropertiesToGrabBag( const Sequence< PropertyValue >& aProperties
// get existing grab bag
Sequence< PropertyValue > aGrabBag;
xSet->getPropertyValue( aGrabBagPropName ) >>= aGrabBag;
- sal_Int32 length = aGrabBag.getLength();
- // update grab bag size to contain the new items
- aGrabBag.realloc( length + aProperties.getLength() );
+ std::vector<PropertyValue> aVec;
+ aVec.reserve(aProperties.getLength());
// put the new items
- for( sal_Int32 i=0; i < aProperties.getLength(); ++i )
- {
- aGrabBag[length + i].Name = aProperties[i].Name;
- aGrabBag[length + i].Value = aProperties[i].Value;
- }
+ std::transform(aProperties.begin(), aProperties.end(), std::back_inserter(aVec),
+ [](const PropertyValue& rProp) {
+ PropertyValue aProp;
+ aProp.Name = rProp.Name;
+ aProp.Value = rProp.Value;
+ return aProp;
+ });
// put it back to the shape
- xSet->setPropertyValue( aGrabBagPropName, Any( aGrabBag ) );
+ xSet->setPropertyValue( aGrabBagPropName, Any( comphelper::concatSequences(aGrabBag, aVec) ) );
}
}
diff --git a/oox/source/drawingml/textcharacterproperties.cxx b/oox/source/drawingml/textcharacterproperties.cxx
index 552dcf933e81..6a0f37532d8b 100644
--- a/oox/source/drawingml/textcharacterproperties.cxx
+++ b/oox/source/drawingml/textcharacterproperties.cxx
@@ -21,6 +21,7 @@
#include <com/sun/star/lang/Locale.hpp>
#include <com/sun/star/awt/FontSlant.hpp>
#include <com/sun/star/awt/FontWeight.hpp>
+#include <comphelper/sequence.hxx>
#include <i18nlangtag/languagetag.hxx>
#include <editeng/escapementitem.hxx>
#include <oox/helper/helper.hxx>
@@ -166,16 +167,7 @@ static void pushToGrabBag( PropertySet& rPropSet, const std::vector<PropertyValu
Any aAnyGrabBag = rPropSet.getAnyProperty(PROP_CharInteropGrabBag);
aAnyGrabBag >>= aGrabBag;
- sal_Int32 nLength = aGrabBag.getLength();
- aGrabBag.realloc(nLength + aVectorOfProperyValues.size());
-
- for (size_t i = 0; i < aVectorOfProperyValues.size(); i++)
- {
- PropertyValue aPropertyValue = aVectorOfProperyValues[i];
- aGrabBag[nLength + i] = aPropertyValue;
- }
-
- rPropSet.setAnyProperty(PROP_CharInteropGrabBag, makeAny(aGrabBag));
+ rPropSet.setAnyProperty(PROP_CharInteropGrabBag, makeAny(comphelper::concatSequences(aGrabBag, aVectorOfProperyValues)));
}
void TextCharacterProperties::pushToPropSet( PropertySet& rPropSet, const XmlFilterBase& rFilter ) const
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 925afd0af96b..b7fdec22de69 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -168,11 +168,10 @@ static Reference< chart2::data::XLabeledDataSequence > lcl_getCategories( const
{
Reference< chart2::XCoordinateSystemContainer > xCooSysCnt(
xDiagram, uno::UNO_QUERY_THROW );
- Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq(
+ const Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq(
xCooSysCnt->getCoordinateSystems());
- for( sal_Int32 i=0; i<aCooSysSeq.getLength(); ++i )
+ for( const auto& xCooSys : aCooSysSeq )
{
- Reference< chart2::XCoordinateSystem > xCooSys( aCooSysSeq[i] );
OSL_ASSERT( xCooSys.is());
for( sal_Int32 nN = xCooSys->getDimension(); nN--; )
{
@@ -252,13 +251,13 @@ static OUString lcl_flattenStringSequence( const Sequence< OUString > & rSequenc
{
OUStringBuffer aResult;
bool bPrecedeWithSpace = false;
- for( sal_Int32 nIndex=0; nIndex<rSequence.getLength(); ++nIndex )
+ for( const auto& rString : rSequence )
{
- if( !rSequence[nIndex].isEmpty())
+ if( !rString.isEmpty())
{
if( bPrecedeWithSpace )
aResult.append( ' ' );
- aResult.append( rSequence[nIndex] );
+ aResult.append( rString );
bPrecedeWithSpace = true;
}
}
@@ -276,7 +275,7 @@ static Sequence< OUString > lcl_getLabelSequence( const Reference< chart2::data:
}
else if( xLabelSeq.is())
{
- Sequence< uno::Any > aAnies( xLabelSeq->getData());
+ const Sequence< uno::Any > aAnies( xLabelSeq->getData());
aLabels.realloc( aAnies.getLength());
for( sal_Int32 i=0; i<aAnies.getLength(); ++i )
aAnies[i] >>= aLabels[i];
@@ -430,10 +429,10 @@ Reference<chart2::XDataSeries> getPrimaryDataSeries(const Reference<chart2::XCha
Reference< chart2::XDataSeriesContainer > xDSCnt(xChartType, uno::UNO_QUERY_THROW);
// export dataseries for current chart-type
- Sequence< Reference< chart2::XDataSeries > > aSeriesSeq(xDSCnt->getDataSeries());
- for (sal_Int32 nSeriesIdx = 0; nSeriesIdx < aSeriesSeq.getLength(); ++nSeriesIdx)
+ const Sequence< Reference< chart2::XDataSeries > > aSeriesSeq(xDSCnt->getDataSeries());
+ for (const auto& rSeries : aSeriesSeq)
{
- Reference<chart2::XDataSeries> xSource(aSeriesSeq[nSeriesIdx], uno::UNO_QUERY);
+ Reference<chart2::XDataSeries> xSource(rSeries, uno::UNO_QUERY);
if (xSource.is())
return xSource;
}
@@ -459,14 +458,14 @@ Sequence< Sequence< OUString > > ChartExport::getSplitCategoriesList( const OUSt
try
{
Reference< chart2::XCoordinateSystemContainer > xCooSysCnt(xDiagram, uno::UNO_QUERY_THROW);
- Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq(xCooSysCnt->getCoordinateSystems());
- for (sal_Int32 i = 0; i < aCooSysSeq.getLength(); ++i)
+ const Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq(xCooSysCnt->getCoordinateSystems());
+ for (const auto& rCooSys : aCooSysSeq)
{
- const Reference< chart2::XChartTypeContainer > xCTCnt(aCooSysSeq[i], uno::UNO_QUERY_THROW);
+ const Reference< chart2::XChartTypeContainer > xCTCnt(rCooSys, uno::UNO_QUERY_THROW);
const Sequence< Reference< chart2::XChartType > > aChartTypeSeq(xCTCnt->getChartTypes());
- for (sal_Int32 j = 0; j < aChartTypeSeq.getLength(); ++j)
+ for (const auto& rChartType : aChartTypeSeq)
{
- Reference< chart2::XDataSeries > xDataSeries = getPrimaryDataSeries(aChartTypeSeq[j]);
+ Reference< chart2::XDataSeries > xDataSeries = getPrimaryDataSeries(rChartType);
if (xDataSeries.is())
{
uno::Reference< chart2::data::XDataSource > xSeriesSource(xDataSeries, uno::UNO_QUERY);
@@ -498,14 +497,14 @@ Sequence< Sequence< OUString > > ChartExport::getSplitCategoriesList( const OUSt
{
css::uno::Reference< css::chart2::XAnyDescriptionAccess > xDataAccess(xChartDoc->getDataProvider(), uno::UNO_QUERY);
const Sequence< Sequence< uno::Any > >aAnyCategories(bSeriesUsesColumns ? xDataAccess->getAnyRowDescriptions() : xDataAccess->getAnyColumnDescriptions());
- sal_Int32 nLevelCount = 1;//minimum is 1!
- for (auto const& elemLabel : aAnyCategories)
- {
- nLevelCount = std::max<sal_Int32>(elemLabel.getLength(), nLevelCount);
- }
+ auto pMax = std::max_element(aAnyCategories.begin(), aAnyCategories.end(),
+ [](const Sequence<uno::Any>& a, const Sequence<uno::Any>& b) {
+ return a.getLength() < b.getLength(); });
- if (nLevelCount > 1)
+ //minimum is 1!
+ if (pMax != aAnyCategories.end() && pMax->getLength() > 1)
{
+ sal_Int32 nLevelCount = pMax->getLength();
//we have complex categories
//sort the categories name
Sequence<Sequence<OUString>>aFinalSplitSource(nLevelCount);
@@ -540,16 +539,16 @@ Sequence< Sequence< OUString > > ChartExport::getSplitCategoriesList( const OUSt
if (xCategoriesSource.is())
{
- Sequence< Reference< chart2::data::XLabeledDataSequence >> aCategories = xCategoriesSource->getDataSequences();
+ const Sequence< Reference< chart2::data::XLabeledDataSequence >> aCategories = xCategoriesSource->getDataSequences();
if (aCategories.getLength() > 1)
{
//we have complex categories
//sort the categories name
- Sequence<Sequence<OUString>>aFinalSplitSource(aCategories.getLength());
- for (sal_Int32 i = 0; i < aFinalSplitSource.getLength(); i++) {
- const uno::Reference< chart2::data::XDataSequence > xCategories = aCategories[i]->getValues();
- aFinalSplitSource[aFinalSplitSource.getLength() - i - 1] = lcl_getLabelSequence(xCategories);
- }
+ Sequence<Sequence<OUString>> aFinalSplitSource(aCategories.getLength());
+ std::transform(aCategories.begin(), aCategories.end(),
+ std::reverse_iterator(aFinalSplitSource.end()),
+ [](const Reference<chart2::data::XLabeledDataSequence>& xCat) {
+ return lcl_getLabelSequence(xCat->getValues()); });
return aFinalSplitSource;
}
}
@@ -1225,22 +1224,21 @@ void ChartExport::exportPlotArea( const Reference< css::chart::XChartDocument >&
}
// chart type
- Sequence< Reference< chart2::XCoordinateSystem > >
+ const Sequence< Reference< chart2::XCoordinateSystem > >
aCooSysSeq( xBCooSysCnt->getCoordinateSystems());
- for( sal_Int32 nCSIdx=0; nCSIdx<aCooSysSeq.getLength(); ++nCSIdx )
+ for( const auto& rCS : aCooSysSeq )
{
-
- Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nCSIdx], uno::UNO_QUERY );
+ Reference< chart2::XChartTypeContainer > xCTCnt( rCS, uno::UNO_QUERY );
if( ! xCTCnt.is())
continue;
mnSeriesCount=0;
- Sequence< Reference< chart2::XChartType > > aCTSeq( xCTCnt->getChartTypes());
- for( sal_Int32 nCTIdx=0; nCTIdx<aCTSeq.getLength(); ++nCTIdx )
+ const Sequence< Reference< chart2::XChartType > > aCTSeq( xCTCnt->getChartTypes());
+ for( const auto& rCT : aCTSeq )
{
- Reference< chart2::XDataSeriesContainer > xDSCnt( aCTSeq[nCTIdx], uno::UNO_QUERY );
+ Reference< chart2::XDataSeriesContainer > xDSCnt( rCT, uno::UNO_QUERY );
if( ! xDSCnt.is())
return;
- Reference< chart2::XChartType > xChartType( aCTSeq[nCTIdx], uno::UNO_QUERY );
+ Reference< chart2::XChartType > xChartType( rCT, uno::UNO_QUERY );
if( ! xChartType.is())
continue;
// note: if xDSCnt.is() then also aCTSeq[nCTIdx]
@@ -1696,10 +1694,9 @@ std::vector<Sequence<Reference<chart2::XDataSeries> > > splitDataSeriesByAxis(co
if(xDSCnt.is())
{
sal_Int32 nAxisIndexOfFirstSeries = -1;
- Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries());
- for (sal_Int32 nIndex = 0, nEnd = aSeriesSeq.getLength(); nIndex < nEnd; ++nIndex)
+ const Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries());
+ for (const uno::Reference<chart2::XDataSeries>& xSeries : aSeriesSeq)
{
- uno::Reference<chart2::XDataSeries> xSeries = aSeriesSeq[nIndex];
Reference<beans::XPropertySet> xPropSet(xSeries, uno::UNO_QUERY);
if (!xPropSet.is())
continue;
@@ -2014,10 +2011,10 @@ void ChartExport::exportSeries( const Reference<chart2::XChartType>& xChartType,
OUString aChartType( xChartType->getChartType());
sal_Int32 eChartType = lcl_getChartType( aChartType );
- for( sal_Int32 nSeriesIdx=0; nSeriesIdx<rSeriesSeq.getLength(); ++nSeriesIdx )
+ for( const auto& rSeries : std::as_const(rSeriesSeq) )
{
// export series
- Reference< chart2::data::XDataSource > xSource( rSeriesSeq[nSeriesIdx], uno::UNO_QUERY );
+ Reference< chart2::data::XDataSource > xSource( rSeries, uno::UNO_QUERY );
if( xSource.is())
{
Reference< chart2::XDataSeries > xDataSeries( xSource, uno::UNO_QUERY );
@@ -2079,7 +2076,7 @@ void ChartExport::exportSeries( const Reference<chart2::XChartType>& xChartType,
// export shape properties
Reference< XPropertySet > xOldPropSet = SchXMLSeriesHelper::createOldAPISeriesPropertySet(
- rSeriesSeq[nSeriesIdx], getModel() );
+ rSeries, getModel() );
if( xOldPropSet.is() )
{
exportShapeProps( xOldPropSet );
@@ -2124,12 +2121,12 @@ void ChartExport::exportSeries( const Reference<chart2::XChartType>& xChartType,
}
// export data points
- exportDataPoints( uno::Reference< beans::XPropertySet >( rSeriesSeq[nSeriesIdx], uno::UNO_QUERY ), nSeriesLength, eChartType );
+ exportDataPoints( uno::Reference< beans::XPropertySet >( rSeries, uno::UNO_QUERY ), nSeriesLength, eChartType );
// export data labels
- exportDataLabels(rSeriesSeq[nSeriesIdx], nSeriesLength, eChartType);
+ exportDataLabels(rSeries, nSeriesLength, eChartType);
- exportTrendlines( rSeriesSeq[nSeriesIdx] );
+ exportTrendlines( rSeries );
if( eChartType != chart::TYPEID_PIE &&
eChartType != chart::TYPEID_RADARLINE )
@@ -2205,9 +2202,8 @@ void ChartExport::exportCandleStickSeries(
const Sequence< Reference< chart2::XDataSeries > > & aSeriesSeq,
bool& rPrimaryAxes)
{
- for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aSeriesSeq.getLength(); ++nSeriesIdx )
+ for( const Reference< chart2::XDataSeries >& xSeries : aSeriesSeq )
{
- Reference< chart2::XDataSeries > xSeries( aSeriesSeq[nSeriesIdx] );
rPrimaryAxes = lcl_isSeriesAttachedToFirstAxis(xSeries);
Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY );
@@ -2293,7 +2289,7 @@ void ChartExport::exportSeriesCategory( const Reference< chart2::data::XDataSequ
pFS->startElement(FSNS(XML_c, XML_cat));
OUString aCellRange = xValueSeq.is() ? xValueSeq->getSourceRangeRepresentation() : OUString();
- Sequence< Sequence< OUString >> aFinalSplitSource = getSplitCategoriesList(aCellRange);
+ const Sequence< Sequence< OUString >> aFinalSplitSource = getSplitCategoriesList(aCellRange);
aCellRange = parseFormula( aCellRange );
if(aFinalSplitSource.getLength() > 1)
@@ -2305,19 +2301,18 @@ void ChartExport::exportSeriesCategory( const Reference< chart2::data::XDataSequ
pFS->writeEscaped(aCellRange);
pFS->endElement(FSNS(XML_c, XML_f));
- sal_Int32 ptCount = aFinalSplitSource.getLength();
pFS->startElement(FSNS(XML_c, XML_multiLvlStrCache));
pFS->singleElement(FSNS(XML_c, XML_ptCount), XML_val, OString::number(aFinalSplitSource[0].getLength()));
- for(sal_Int32 i = 0; i < ptCount; i++)
+ for(const auto& rSeq : aFinalSplitSource)
{
pFS->startElement(FSNS(XML_c, XML_lvl));
- for(sal_Int32 j = 0; j < aFinalSplitSource[i].getLength(); j++)
+ for(sal_Int32 j = 0; j < rSeq.getLength(); j++)
{
- if(!aFinalSplitSource[i][j].isEmpty())
+ if(!rSeq[j].isEmpty())
{
pFS->startElement(FSNS(XML_c, XML_pt), XML_idx, OString::number(j));
pFS->startElement(FSNS(XML_c, XML_v));
- pFS->writeEscaped(aFinalSplitSource[i][j]);
+ pFS->writeEscaped(rSeq[j]);
pFS->endElement(FSNS(XML_c, XML_v));
pFS->endElement(FSNS(XML_c, XML_pt));
}
@@ -3275,13 +3270,8 @@ void ChartExport::exportDataLabels(
;
}
- const sal_Int32* p = aAttrLabelIndices.getConstArray();
- const sal_Int32* pEnd = p + aAttrLabelIndices.getLength();
-
-
- for (; p != pEnd; ++p)
+ for (const sal_Int32 nIdx : std::as_const(aAttrLabelIndices))
{
- sal_Int32 nIdx = *p;
uno::Reference<beans::XPropertySet> xLabelPropSet = xSeries->getDataPointByIndex(nIdx);
if (!xLabelPropSet.is())
@@ -3524,12 +3514,9 @@ void ChartExport::exportTrendlines( const Reference< chart2::XDataSeries >& xSer
Reference< chart2::XRegressionCurveContainer > xRegressionCurveContainer( xSeries, UNO_QUERY );
if( xRegressionCurveContainer.is() )
{
- Sequence< Reference< chart2::XRegressionCurve > > aRegCurveSeq = xRegressionCurveContainer->getRegressionCurves();
- const Reference< chart2::XRegressionCurve >* pBeg = aRegCurveSeq.getConstArray();
- const Reference< chart2::XRegressionCurve >* pEnd = pBeg + aRegCurveSeq.getLength();
- for( const Reference< chart2::XRegressionCurve >* pIt = pBeg; pIt != pEnd; ++pIt )
+ const Sequence< Reference< chart2::XRegressionCurve > > aRegCurveSeq = xRegressionCurveContainer->getRegressionCurves();
+ for( const Reference< chart2::XRegressionCurve >& xRegCurve : aRegCurveSeq )
{
- Reference< chart2::XRegressionCurve > xRegCurve = *pIt;
if (!xRegCurve.is())
continue;
@@ -3798,11 +3785,11 @@ Reference< chart2::data::XDataSequence> getLabeledSequence(
else
aDirection = "negative";
- for( sal_Int32 nI=0; nI< aSequences.getLength(); ++nI )
+ for( const auto& rSequence : aSequences )
{
- if( aSequences[nI].is())
+ if( rSequence.is())
{
- uno::Reference< chart2::data::XDataSequence > xSequence( aSequences[nI]->getValues());
+ uno::Reference< chart2::data::XDataSequence > xSequence( rSequence->getValues());
uno::Reference< beans::XPropertySet > xSeqProp( xSequence, uno::UNO_QUERY_THROW );
OUString aRole;
if( ( xSeqProp->getPropertyValue( "Role" ) >>= aRole ) &&
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 27dd7e5b2a16..32dd9c02588d 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -40,6 +40,7 @@
#include <i18nlangtag/languagetag.hxx>
#include <cstdio>
+#include <numeric>
#include <com/sun/star/awt/CharSet.hpp>
#include <com/sun/star/awt/FontDescriptor.hpp>
#include <com/sun/star/awt/FontSlant.hpp>
@@ -308,10 +309,10 @@ void DrawingML::WriteColor( const OUString& sColorSchemeName, const Sequence< Pr
void DrawingML::WriteColorTransformations( const Sequence< PropertyValue >& aTransformations, sal_Int32 nAlpha )
{
- for( sal_Int32 i = 0; i < aTransformations.getLength(); i++ )
+ for( const auto& rTransformation : aTransformations )
{
- sal_Int32 nToken = Color::getColorTransformationToken( aTransformations[i].Name );
- if( nToken != XML_TOKEN_INVALID && aTransformations[i].Value.hasValue() )
+ sal_Int32 nToken = Color::getColorTransformationToken( rTransformation.Name );
+ if( nToken != XML_TOKEN_INVALID && rTransformation.Value.hasValue() )
{
if(nToken == XML_alpha && nAlpha < MAX_PERCENT)
{
@@ -319,7 +320,7 @@ void DrawingML::WriteColorTransformations( const Sequence< PropertyValue >& aTra
}
else
{
- sal_Int32 nValue = aTransformations[i].Value.get<sal_Int32>();
+ sal_Int32 nValue = rTransformation.Value.get<sal_Int32>();
mpFS->singleElementNS(XML_a, nToken, XML_val, OString::number(nValue));
}
}
@@ -355,16 +356,16 @@ void DrawingML::WriteSolidFill( const Reference< XPropertySet >& rXPropSet )
{
Sequence< PropertyValue > aGrabBag;
mAny >>= aGrabBag;
- for( sal_Int32 i=0; i < aGrabBag.getLength(); ++i )
+ for( const auto& rProp : std::as_const(aGrabBag) )
{
- if( aGrabBag[i].Name == "SpPrSolidFillSchemeClr" )
- aGrabBag[i].Value >>= sColorFillScheme;
- else if( aGrabBag[i].Name == "OriginalSolidFillClr" )
- aGrabBag[i].Value >>= nOriginalColor;
- else if( aGrabBag[i].Name == "StyleFillRef" )
- aGrabBag[i].Value >>= aStyleProperties;
- else if( aGrabBag[i].Name == "SpPrSolidFillSchemeClrTransformations" )
- aGrabBag[i].Value >>= aTransformations;
+ if( rProp.Name == "SpPrSolidFillSchemeClr" )
+ rProp.Value >>= sColorFillScheme;
+ else if( rProp.Name == "OriginalSolidFillClr" )
+ rProp.Value >>= nOriginalColor;
+ else if( rProp.Name == "StyleFillRef" )
+ rProp.Value >>= aStyleProperties;
+ else if( rProp.Name == "SpPrSolidFillSchemeClrTransformations" )
+ rProp.Value >>= aTransformations;
}
}
@@ -392,24 +393,20 @@ void DrawingML::WriteSolidFill( const Reference< XPropertySet >& rXPropSet )
{
sal_uInt32 nThemeColor = 0;
sal_Int32 nThemeAlpha = MAX_PERCENT;
- for( sal_Int32 i=0; i < aStyleProperties.getLength(); ++i )
+ for( const auto& rStyleProp : std::as_const(aStyleProperties) )
{
- if( aStyleProperties[i].Name == "Color" )
+ if( rStyleProp.Name == "Color" )
{
- aStyleProperties[i].Value >>= nThemeColor;
+ rStyleProp.Value >>= nThemeColor;
}
- else if(aStyleProperties[i].Name == "Transformations" )
+ else if(rStyleProp.Name == "Transformations" )
{
Sequence< PropertyValue > aStyleTransformations;
- aStyleProperties[i].Value >>= aStyleTransformations;
- for( sal_Int32 j = 0; j < aStyleTransformations.getLength(); j++ )
- {
- if (aStyleTransformations[j].Name == "alpha" )
- {
- aStyleTransformations[j].Value >>= nThemeAlpha;
- break;
- }
- }
+ rStyleProp.Value >>= aStyleTransformations;
+ auto pProp = std::find_if(std::cbegin(aStyleTransformations), std::cend(aStyleTransformations),
+ [](const PropertyValue& rProp) { return rProp.Name == "alpha"; });
+ if (pProp != std::cend(aStyleTransformations))
+ pProp->Value >>= nThemeAlpha;
}
}
if ( nFillColor != nThemeColor || nAlpha != nThemeAlpha )
@@ -468,11 +465,11 @@ void DrawingML::WriteGradientFill( const Reference< XPropertySet >& rXPropSet )
{
Sequence< PropertyValue > aGrabBag;
mAny >>= aGrabBag;
- for( sal_Int32 i=0; i < aGrabBag.getLength(); ++i )
- if( aGrabBag[i].Name == "GradFillDefinition" )
- aGrabBag[i].Value >>= aGradientStops;
- else if( aGrabBag[i].Name == "OriginalGradFill" )
- aGrabBag[i].Value >>= aOriginalGradient;
+ for( const auto& rProp : std::as_const(aGrabBag) )
+ if( rProp.Name == "GradFillDefinition" )
+ rProp.Value >>= aGradientStops;
+ else if( rProp.Name == "OriginalGradFill" )
+ rProp.Value >>= aOriginalGradient;
}
// check if an ooxml gradient had been imported and if the user has modified it
@@ -503,10 +500,10 @@ void DrawingML::WriteGrabBagGradientFill( const Sequence< PropertyValue >& aGrad
mpFS->startElementNS(XML_a, XML_gsLst);
// get original stops and write them
- for( sal_Int32 i=0; i < aGradientStops.getLength(); ++i )
+ for( const auto& rGradientStop : aGradientStops )
{
Sequence< PropertyValue > aGradientStop;
- aGradientStops[i].Value >>= aGradientStop;
+ rGradientStop.Value >>= aGradientStop;
// get values
OUString sSchemeClr;
@@ -514,18 +511,18 @@ void DrawingML::WriteGrabBagGradientFill( const Sequence< PropertyValue >& aGrad
sal_Int16 nTransparency = 0;
::Color nRgbClr;
Sequence< PropertyValue > aTransformations;
- for( sal_Int32 j=0; j < aGradientStop.getLength(); ++j )
- {
- if( aGradientStop[j].Name == "SchemeClr" )
- aGradientStop[j].Value >>= sSchemeClr;
- else if( aGradientStop[j].Name == "RgbClr" )
- aGradientStop[j].Value >>= nRgbClr;
- else if( aGradientStop[j].Name == "Pos" )
- aGradientStop[j].Value >>= nPos;
- else if( aGradientStop[j].Name == "Transparency" )
- aGradientStop[j].Value >>= nTransparency;
- else if( aGradientStop[j].Name == "Transformations" )
- aGradientStop[j].Value >>= aTransformations;
+ for( const auto& rProp : std::as_const(aGradientStop) )
+ {
+ if( rProp.Name == "SchemeClr" )
+ rProp.Value >>= sSchemeClr;
+ else if( rProp.Name == "RgbClr" )
+ rProp.Value >>= nRgbClr;
+ else if( rProp.Name == "Pos" )
+ rProp.Value >>= nPos;
+ else if( rProp.Name == "Transparency" )
+ rProp.Value >>= nTransparency;
+ else if( rProp.Name == "Transformations" )
+ rProp.Value >>= aTransformations;
}
// write stop
mpFS->startElementNS(XML_a, XML_gs, XML_pos, OString::number(nPos * 100000.0).getStr());
@@ -739,30 +736,27 @@ void DrawingML::WriteOutline( const Reference<XPropertySet>& rXPropSet, Referenc
Sequence<PropertyValue> aGrabBag;
mAny >>= aGrabBag;
- for (sal_Int32 i=0; i < aGrabBag.getLength(); ++i)
+ for (const auto& rProp : std::as_const(aGrabBag))
{
- if( aGrabBag[i].Name == "SpPrLnSolidFillSchemeClr" )
- aGrabBag[i].Value >>= sColorFillScheme;
- else if( aGrabBag[i].Name == "OriginalLnSolidFillClr" )
- aGrabBag[i].Value >>= nOriginalColor;
- else if( aGrabBag[i].Name == "StyleLnRef" )
- aGrabBag[i].Value >>= aStyleProperties;
- else if( aGrabBag[i].Name == "SpPrLnSolidFillSchemeClrTransformations" )
- aGrabBag[i].Value >>= aTransformations;
+ if( rProp.Name == "SpPrLnSolidFillSchemeClr" )
+ rProp.Value >>= sColorFillScheme;
+ else if( rProp.Name == "OriginalLnSolidFillClr" )
+ rProp.Value >>= nOriginalColor;
+ else if( rProp.Name == "StyleLnRef" )
+ rProp.Value >>= aStyleProperties;
+ else if( rProp.Name == "SpPrLnSolidFillSchemeClrTransformations" )
+ rProp.Value >>= aTransformations;
}
- if (aStyleProperties.hasElements())
+ for (const auto& rStyleProp : std::as_const(aStyleProperties))
{
- for (sal_Int32 i=0; i < aStyleProperties.getLength(); ++i)
- {
- if( aStyleProperties[i].Name == "Color" )
- aStyleProperties[i].Value >>= nStyleColor;
- else if( aStyleProperties[i].Name == "LineStyle" )
- aStyleProperties[i].Value >>= aStyleLineStyle;
- else if( aStyleProperties[i].Name == "LineJoint" )
- aStyleProperties[i].Value >>= aStyleLineJoint;
- else if( aStyleProperties[i].Name == "LineWidth" )
- aStyleProperties[i].Value >>= nStyleLineWidth;
- }
+ if( rStyleProp.Name == "Color" )
+ rStyleProp.Value >>= nStyleColor;
+ else if( rStyleProp.Name == "LineStyle" )
+ rStyleProp.Value >>= aStyleLineStyle;
+ else if( rStyleProp.Name == "LineJoint" )
+ rStyleProp.Value >>= aStyleLineJoint;
+ else if( rStyleProp.Name == "LineWidth" )
+ rStyleProp.Value >>= nStyleLineWidth;
}
}
@@ -2165,10 +2159,6 @@ void DrawingML::WriteParagraphNumbering(const Reference< XPropertySet >& rXPropS
if (!aPropertySequence.hasElements())
return;
- sal_Int32 nPropertyCount = aPropertySequence.getLength();
-
- const PropertyValue* pPropValue = aPropertySequence.getArray();
-
SvxNumType nNumberingType = SVX_NUM_NUMBER_NONE;
bool bSDot = false;
bool bPBehind = false;
@@ -2183,22 +2173,22 @@ void DrawingML::WriteParagraphNumbering(const Reference< XPropertySet >& rXPropS
bool bHasBulletColor = false;
awt::Size aGraphicSize;
- for ( sal_Int32 i = 0; i < nPropertyCount; i++ )
+ for ( const PropertyValue& rPropValue : std::as_const(aPropertySequence) )
{
- OUString aPropName( pPropValue[ i ].Name );
+ OUString aPropName( rPropValue.Name );
SAL_INFO("oox.shape", "pro name: " << aPropName);
if ( aPropName == "NumberingType" )
{
- nNumberingType = static_cast<SvxNumType>(*o3tl::doAccess<sal_Int16>(pPropValue[i].Value));
+ nNumberingType = static_cast<SvxNumType>(*o3tl::doAccess<sal_Int16>(rPropValue.Value));
}
else if ( aPropName == "Prefix" )
{
- if( *o3tl::doAccess<OUString>(pPropValue[i].Value) == ")")
+ if( *o3tl::doAccess<OUString>(rPropValue.Value) == ")")
bPBoth = true;
}
else if ( aPropName == "Suffix" )
{
- auto s = o3tl::doAccess<OUString>(pPropValue[i].Value);
+ auto s = o3tl::doAccess<OUString>(rPropValue.Value);
if( *s == ".")
bSDot = true;
else if( *s == ")")
@@ -2206,16 +2196,16 @@ void DrawingML::WriteParagraphNumbering(const Reference< XPropertySet >& rXPropS
}
else if(aPropName == "BulletColor")
{
- nBulletColor = ::Color(*o3tl::doAccess<sal_uInt32>(pPropValue[i].Value));
+ nBulletColor = ::Color(*o3tl::doAccess<sal_uInt32>(rPropValue.Value));
bHasBulletColor = true;
}
else if ( aPropName == "BulletChar" )
{
- aBulletChar = (*o3tl::doAccess<OUString>(pPropValue[i].Value))[ 0 ];
+ aBulletChar = (*o3tl::doAccess<OUString>(rPropValue.Value))[ 0 ];
}
else if ( aPropName == "BulletFont" )
{
- aFontDesc = *o3tl::doAccess<awt::FontDescriptor>(pPropValue[i].Value);
+ aFontDesc = *o3tl::doAccess<awt::FontDescriptor>(rPropValue.Value);
bHasFontDesc = true;
// Our numbullet dialog has set the wrong textencoding for our "StarSymbol" font,
@@ -2228,20 +2218,20 @@ void DrawingML::WriteParagraphNumbering(const Reference< XPropertySet >& rXPropS
}
else if ( aPropName == "BulletRelSize" )
{
- nBulletRelSize = *o3tl::doAccess<sal_Int16>(pPropValue[i].Value);
+ nBulletRelSize = *o3tl::doAccess<sal_Int16>(rPropValue.Value);
}
else if ( aPropName == "StartWith" )
{
- nStartWith = *o3tl::doAccess<sal_Int16>(pPropValue[i].Value);
+ nStartWith = *o3tl::doAccess<sal_Int16>(rPropValue.Value);
}
else if (aPropName == "GraphicBitmap")
{
- auto xBitmap = pPropValue[i].Value.get<uno::Reference<awt::XBitmap>>();
+ auto xBitmap = rPropValue.Value.get<uno::Reference<awt::XBitmap>>();
xGraphic.set(xBitmap, uno::UNO_QUERY);
}
else if ( aPropName == "GraphicSize" )
{
- aGraphicSize = *o3tl::doAccess<awt::Size>(pPropValue[i].Value);
+ aGraphicSize = *o3tl::doAccess<awt::Size>(rPropValue.Value);
SAL_INFO("oox.shape", "graphic size: " << aGraphicSize.Width << "x" << aGraphicSize.Height);
}
}
@@ -2351,15 +2341,13 @@ bool DrawingML::IsDiagram(const Reference<XShape>& rXShape)
uno::Sequence<beans::PropertyValue> propList;
xPropSet->getPropertyValue(aName) >>= propList;
- for (sal_Int32 nProp = 0; nProp < propList.getLength(); ++nProp)
- {
- // if we find any of the diagram components, it's a diagram
- OUString propName = propList[nProp].Name;
- if (propName == "OOXData" || propName == "OOXLayout" || propName == "OOXStyle"
- || propName == "OOXColor" || propName == "OOXDrawing")
- return true;
- }
- return false;
+ return std::any_of(std::cbegin(propList), std::cend(propList),
+ [](const beans::PropertyValue& rProp) {
+ // if we find any of the diagram components, it's a diagram
+ OUString propName = rProp.Name;
+ return propName == "OOXData" || propName == "OOXLayout" || propName == "OOXStyle"
+ || propName == "OOXColor" || propName == "OOXDrawing";
+ });
}
sal_Int32 DrawingML::getBulletMarginIndentation (const Reference< XPropertySet >& rXPropSet,sal_Int16 nLevel, const OUString& propName)
@@ -2380,16 +2368,12 @@ sal_Int32 DrawingML::getBulletMarginIndentation (const Reference< XPropertySet >
if (!aPropertySequence.hasElements())
return 0;
- sal_Int32 nPropertyCount = aPropertySequence.getLength();
-
- const PropertyValue* pPropValue = aPropertySequence.getArray();
-
- for ( sal_Int32 i = 0; i < nPropertyCount; i++ )
+ for ( const PropertyValue& rPropValue : std::as_const(aPropertySequence) )
{
- OUString aPropName( pPropValue[ i ].Name );
+ OUString aPropName( rPropValue.Name );
SAL_INFO("oox.shape", "pro name: " << aPropName);
if ( aPropName == propName )
- return *o3tl::doAccess<sal_Int32>(pPropValue[i].Value);
+ return *o3tl::doAccess<sal_Int32>(rPropValue.Value);
}
return 0;
@@ -2634,9 +2618,9 @@ void DrawingML::WriteText( const Reference< XInterface >& rXIface, const OUStrin
Sequence< PropertyValue > aProps;
if ( mAny >>= aProps )
{
- for ( sal_Int32 i = 0, nElems = aProps.getLength(); i < nElems; ++i )
+ for ( const auto& rProp : std::as_const(aProps) )
{
- if ( aProps[ i ].Name == "TextPreRotateAngle" && ( aProps[ i ].Value >>= nTextRotateAngle ) )
+ if ( rProp.Name == "TextPreRotateAngle" && ( rProp.Value >>= nTextRotateAngle ) )
{
if ( nTextRotateAngle == -90 )
{
@@ -2651,15 +2635,15 @@ void DrawingML::WriteText( const Reference< XInterface >& rXIface, const OUStrin
if (!bIsFontworkShape)
break;
}
- else if (aProps[i].Name == "AdjustmentValues")
- aProps[i].Value >>= aAdjustmentSeq;
- else if (aProps[i].Name == "TextPath")
+ else if (rProp.Name == "AdjustmentValues")
+ rProp.Value >>= aAdjustmentSeq;
+ else if (rProp.Name == "TextPath")
{
- aProps[i].Value >>= aTextPathSeq;
- for (int k = 0; k < aTextPathSeq.getLength(); k++)
+ rProp.Value >>= aTextPathSeq;
+ for (const auto& rTextPath : std::as_const(aTextPathSeq))
{
- if (aTextPathSeq[k].Name == "ScaleX")
- aTextPathSeq[k].Value >>= bScaleX;
+ if (rTextPath.Name == "ScaleX")
+ rTextPath.Value >>= bScaleX;
}
}
}
@@ -2713,7 +2697,7 @@ void DrawingML::WriteText( const Reference< XInterface >& rXIface, const OUStrin
XML_rot, (nTextRotateAngle != 0) ? oox::drawingml::calcRotationValue( nTextRotateAngle * 100 ).getStr() : nullptr );
if (bIsFontworkShape)
{
- if (aAdjustmentSeq.getLength() > 0)
+ if (aAdjustmentSeq.hasElements())
{
mpFS->startElementNS(XML_a, XML_prstTxWarp, XML_prst, presetWarp.toUtf8());
mpFS->startElementNS(XML_a, XML_avLst);
@@ -2998,9 +2982,8 @@ bool DrawingML::WriteCustomGeometry(
uno::Sequence<drawing::EnhancedCustomShapeParameterPair> aPairs;
uno::Sequence<drawing::EnhancedCustomShapeSegment> aSegments;
uno::Sequence<awt::Size> aPathSize;
- for (int j = 0; j < aPathProp.getLength(); ++j )
+ for (const beans::PropertyValue& rPathProp : std::as_const(aPathProp))
{
- const beans::PropertyValue& rPathProp = aPathProp[j];
if (rPathProp.Name == "Coordinates")
rPathProp.Value >>= aPairs;
else if (rPathProp.Name == "Segments")
@@ -3025,11 +3008,8 @@ bool DrawingML::WriteCustomGeometry(
aSegments[3].Command = drawing::EnhancedCustomShapeSegmentCommand::ENDSUBPATH;
}
- int nExpectedPairCount = 0;
- for( int j = 0; j < aSegments.getLength(); ++j )
- {
- nExpectedPairCount += aSegments[j].Count;
- }
+ int nExpectedPairCount = std::accumulate(std::cbegin(aSegments), std::cend(aSegments), 0,
+ [](const int nSum, const drawing::EnhancedCustomShapeSegment& rSegment) { return nSum + rSegment.Count; });
if ( nExpectedPairCount > aPairs.getLength() )
{
@@ -3060,10 +3040,10 @@ bool DrawingML::WriteCustomGeometry(
aPairs[0].Second.Value >>= nYMin;
sal_Int32 nYMax = nYMin;
- for ( int j = 0; j < aPairs.getLength(); ++j )
+ for ( const auto& rPair : std::as_const(aPairs) )
{
- sal_Int32 nX = GetCustomGeometryPointValue(aPairs[j].First, rSdrObjCustomShape);
- sal_Int32 nY = GetCustomGeometryPointValue(aPairs[j].Second, rSdrObjCustomShape);
+ sal_Int32 nX = GetCustomGeometryPointValue(rPair.First, rSdrObjCustomShape);
+ sal_Int32 nY = GetCustomGeometryPointValue(rPair.Second, rSdrObjCustomShape);
if (nX < nXMin)
nXMin = nX;
if (nY < nYMin)
@@ -3081,15 +3061,15 @@ bool DrawingML::WriteCustomGeometry(
int nPairIndex = 0;
bool bOK = true;
- for (int j = 0; j < aSegments.getLength() && bOK; ++j)
+ for (const auto& rSegment : std::as_const(aSegments))
{
- if ( aSegments[ j ].Command == drawing::EnhancedCustomShapeSegmentCommand::CLOSESUBPATH )
+ if ( rSegment.Command == drawing::EnhancedCustomShapeSegmentCommand::CLOSESUBPATH )
{
mpFS->singleElementNS(XML_a, XML_close);
}
- for (int k = 0; k < aSegments[j].Count && bOK; ++k)
+ for (int k = 0; k < rSegment.Count && bOK; ++k)
{
- switch( aSegments[ j ].Command )
+ switch( rSegment.Command )
{
case drawing::EnhancedCustomShapeSegmentCommand::MOVETO :
{
@@ -3179,6 +3159,8 @@ bool DrawingML::WriteCustomGeometry(
break;
}
}
+ if (!bOK)
+ break;
}
mpFS->endElementNS( XML_a, XML_path );
mpFS->endElementNS( XML_a, XML_pathLst );
@@ -3386,14 +3368,14 @@ void DrawingML::WriteStyleProperties( sal_Int32 nTokenId, const Sequence< Proper
OUString sSchemeClr;
sal_uInt32 nIdx = 0;
Sequence< PropertyValue > aTransformations;
- for( sal_Int32 i=0; i < aProperties.getLength(); ++i)
+ for( const auto& rProp : aProperties)
{
- if( aProperties[i].Name == "SchemeClr" )
- aProperties[i].Value >>= sSchemeClr;
- else if( aProperties[i].Name == "Idx" )
- aProperties[i].Value >>= nIdx;
- else if( aProperties[i].Name == "Transformations" )
- aProperties[i].Value >>= aTransformations;
+ if( rProp.Name == "SchemeClr" )
+ rProp.Value >>= sSchemeClr;
+ else if( rProp.Name == "Idx" )
+ rProp.Value >>= nIdx;
+ else if( rProp.Name == "Transformations" )
+ rProp.Value >>= aTransformations;
}
mpFS->startElementNS(XML_a, nTokenId, XML_idx, OString::number(nIdx));
WriteColor(sSchemeClr, aTransformations);
@@ -3416,14 +3398,14 @@ void DrawingML::WriteShapeStyle( const Reference< XPropertySet >& xPropSet )
Sequence< PropertyValue > aGrabBag;
Sequence< PropertyValue > aFillRefProperties, aLnRefProperties, aEffectRefProperties;
mAny >>= aGrabBag;
- for( sal_Int32 i=0; i < aGrabBag.getLength(); ++i)
+ for( const auto& rProp : std::as_const(aGrabBag))
{
- if( aGrabBag[i].Name == "StyleFillRef" )
- aGrabBag[i].Value >>= aFillRefProperties;
- else if( aGrabBag[i].Name == "StyleLnRef" )
- aGrabBag[i].Value >>= aLnRefProperties;
- else if( aGrabBag[i].Name == "StyleEffectRef" )
- aGrabBag[i].Value >>= aEffectRefProperties;
+ if( rProp.Name == "StyleFillRef" )
+ rProp.Value >>= aFillRefProperties;
+ else if( rProp.Name == "StyleLnRef" )
+ rProp.Value >>= aLnRefProperties;
+ else if( rProp.Name == "StyleEffectRef" )
+ rProp.Value >>= aEffectRefProperties;
}
WriteStyleProperties( XML_lnRef, aLnRefProperties );
@@ -3470,131 +3452,131 @@ void DrawingML::WriteShapeEffect( const OUString& sName, const Sequence< Propert
Sequence< PropertyValue > aTransformations;
sax_fastparser::FastAttributeList *aOuterShdwAttrList = FastSerializerHelper::createAttrList();
sax_fastparser::XFastAttributeListRef xOuterShdwAttrList( aOuterShdwAttrList );
- for( sal_Int32 i=0; i < aEffectProps.getLength(); ++i )
+ for( const auto& rEffectProp : aEffectProps )
{
- if( aEffectProps[i].Name == "Attribs" )
+ if( rEffectProp.Name == "Attribs" )
{
// read tag attributes
uno::Sequence< beans::PropertyValue > aOuterShdwProps;
- aEffectProps[i].Value >>= aOuterShdwProps;
- for( sal_Int32 j=0; j < aOuterShdwProps.getLength(); ++j )
+ rEffectProp.Value >>= aOuterShdwProps;
+ for( const auto& rOuterShdwProp : std::as_const(aOuterShdwProps) )
{
- if( aOuterShdwProps[j].Name == "algn" )
+ if( rOuterShdwProp.Name == "algn" )
{
OUString sVal;
- aOuterShdwProps[j].Value >>= sVal;
+ rOuterShdwProp.Value >>= sVal;
aOuterShdwAttrList->add( XML_algn, OUStringToOString( sVal, RTL_TEXTENCODING_UTF8 ).getStr() );
}
- else if( aOuterShdwProps[j].Name == "blurRad" )
+ else if( rOuterShdwProp.Name == "blurRad" )
{
sal_Int32 nVal = 0;
- aOuterShdwProps[j].Value >>= nVal;
+ rOuterShdwProp.Value >>= nVal;
aOuterShdwAttrList->add( XML_blurRad, OString::number( nVal ).getStr() );
}
- else if( aOuterShdwProps[j].Name == "dir" )
+ else if( rOuterShdwProp.Name == "dir" )
{
sal_Int32 nVal = 0;
- aOuterShdwProps[j].Value >>= nVal;
+ rOuterShdwProp.Value >>= nVal;
aOuterShdwAttrList->add( XML_dir, OString::number( nVal ).getStr() );
}
- else if( aOuterShdwProps[j].Name == "dist" )
+ else if( rOuterShdwProp.Name == "dist" )
{
sal_Int32 nVal = 0;
- aOuterShdwProps[j].Value >>= nVal;
+ rOuterShdwProp.Value >>= nVal;
aOuterShdwAttrList->add( XML_dist, OString::number( nVal ).getStr() );
}
- else if( aOuterShdwProps[j].Name == "kx" )
+ else if( rOuterShdwProp.Name == "kx" )
{
sal_Int32 nVal = 0;
- aOuterShdwProps[j].Value >>= nVal;
+ rOuterShdwProp.Value >>= nVal;
aOuterShdwAttrList->add( XML_kx, OString::number( nVal ).getStr() );
}
- else if( aOuterShdwProps[j].Name == "ky" )
+ else if( rOuterShdwProp.Name == "ky" )
{
sal_Int32 nVal = 0;
- aOuterShdwProps[j].Value >>= nVal;
+ rOuterShdwProp.Value >>= nVal;
aOuterShdwAttrList->add( XML_ky, OString::number( nVal ).getStr() );
}
- else if( aOuterShdwProps[j].Name == "rotWithShape" )
+ else if( rOuterShdwProp.Name == "rotWithShape" )
{
sal_Int32 nVal = 0;
- aOuterShdwProps[j].Value >>= nVal;
+ rOuterShdwProp.Value >>= nVal;
aOuterShdwAttrList->add( XML_rotWithShape, OString::number( nVal ).getStr() );
}
- else if( aOuterShdwProps[j].Name == "sx" )
+ else if( rOuterShdwProp.Name == "sx" )
{
sal_Int32 nVal = 0;
- aOuterShdwProps[j].Value >>= nVal;
+ rOuterShdwProp.Value >>= nVal;
aOuterShdwAttrList->add( XML_sx, OString::number( nVal ).getStr() );
}
- else if( aOuterShdwProps[j].Name == "sy" )
+ else if( rOuterShdwProp.Name == "sy" )
{
sal_Int32 nVal = 0;
- aOuterShdwProps[j].Value >>= nVal;
+ rOuterShdwProp.Value >>= nVal;
aOuterShdwAttrList->add( XML_sy, OString::number( nVal ).getStr() );
}
- else if( aOuterShdwProps[j].Name == "rad" )
+ else if( rOuterShdwProp.Name == "rad" )
{
sal_Int32 nVal = 0;
- aOuterShdwProps[j].Value >>= nVal;
+ rOuterShdwProp.Value >>= nVal;
aOuterShdwAttrList->add( XML_rad, OString::number( nVal ).getStr() );
}
- else if( aOuterShdwProps[j].Name == "endA" )
+ else if( rOuterShdwProp.Name == "endA" )
{
sal_Int32 nVal = 0;
- aOuterShdwProps[j].Value >>= nVal;
+ rOuterShdwProp.Value >>= nVal;
aOuterShdwAttrList->add( XML_endA, OString::number( nVal ).getStr() );
}
- else if( aOuterShdwProps[j].Name == "endPos" )
+ else if( rOuterShdwProp.Name == "endPos" )
{
sal_Int32 nVal = 0;
- aOuterShdwProps[j].Value >>= nVal;
+ rOuterShdwProp.Value >>= nVal;
aOuterShdwAttrList->add( XML_endPos, OString::number( nVal ).getStr() );
}
- else if( aOuterShdwProps[j].Name == "fadeDir" )
+ else if( rOuterShdwProp.Name == "fadeDir" )
{
sal_Int32 nVal = 0;
- aOuterShdwProps[j].Value >>= nVal;
+ rOuterShdwProp.Value >>= nVal;
aOuterShdwAttrList->add( XML_fadeDir, OString::number( nVal ).getStr() );
}
- else if( aOuterShdwProps[j].Name == "stA" )
+ else if( rOuterShdwProp.Name == "stA" )
{
sal_Int32 nVal = 0;
- aOuterShdwProps[j].Value >>= nVal;
+ rOuterShdwProp.Value >>= nVal;
aOuterShdwAttrList->add( XML_stA, OString::number( nVal ).getStr() );
}
- else if( aOuterShdwProps[j].Name == "stPos" )
+ else if( rOuterShdwProp.Name == "stPos" )
{
sal_Int32 nVal = 0;
- aOuterShdwProps[j].Value >>= nVal;
+ rOuterShdwProp.Value >>= nVal;
aOuterShdwAttrList->add( XML_stPos, OString::number( nVal ).getStr() );
}
- else if( aOuterShdwProps[j].Name == "grow" )
+ else if( rOuterShdwProp.Name == "grow" )
{
sal_Int32 nVal = 0;
- aOuterShdwProps[j].Value >>= nVal;
+ rOuterShdwProp.Value >>= nVal;
aOuterShdwAttrList->add( XML_grow, OString::number( nVal ).getStr() );
}
}
}
- else if(aEffectProps[i].Name == "RgbClr")
+ else if(rEffectProp.Name == "RgbClr")
{
- aEffectProps[i].Value >>= nRgbClr;
+ rEffectProp.Value >>= nRgbClr;
}
- else if(aEffectProps[i].Name == "RgbClrTransparency")
+ else if(rEffectProp.Name == "RgbClrTransparency")
{
sal_Int32 nTransparency;
- if (aEffectProps[i].Value >>= nTransparency)
+ if (rEffectProp.Value >>= nTransparency)
// Calculate alpha value (see oox/source/drawingml/color.cxx : getTransparency())
nAlpha = MAX_PERCENT - ( PER_PERCENT * nTransparency );
}
- else if(aEffectProps[i].Name == "SchemeClr")
+ else if(rEffectProp.Name == "SchemeClr")
{
- aEffectProps[i].Value >>= sSchemeClr;
+ rEffectProp.Value >>= sSchemeClr;
}
- else if(aEffectProps[i].Name == "SchemeClrTransformations")
+ else if(rEffectProp.Name == "SchemeClrTransformations")
{
- aEffectProps[i].Value >>= aTransformations;
+ rEffectProp.Value >>= aTransformations;
}
}
@@ -3630,21 +3612,15 @@ void DrawingML::WriteShapeEffects( const Reference< XPropertySet >& rXPropSet )
if( GetProperty( rXPropSet, "InteropGrabBag" ) )
{
mAny >>= aGrabBag;
- for( sal_Int32 i=0; i < aGrabBag.getLength(); ++i )
+ auto pProp = std::find_if(std::cbegin(aGrabBag), std::cend(aGrabBag),
+ [](const PropertyValue& rProp) { return rProp.Name == "EffectProperties"; });
+ if (pProp != std::cend(aGrabBag))
{
- if( aGrabBag[i].Name == "EffectProperties" )
- {
- aGrabBag[i].Value >>= aEffects;
- for( sal_Int32 j=0; j < aEffects.getLength(); ++j )
- {
- if( aEffects[j].Name == "outerShdw" )
- {
- aEffects[j].Value >>= aOuterShdwProps;
- break;
- }
- }
- break;
- }
+ pProp->Value >>= aEffects;
+ auto pEffect = std::find_if(std::cbegin(aEffects), std::cend(aEffects),
+ [](const PropertyValue& rEffect) { return rEffect.Name == "outerShdw"; });
+ if (pEffect != std::cend(aEffects))
+ pEffect->Value >>= aOuterShdwProps;
}
}
@@ -3681,53 +3657,53 @@ void DrawingML::WriteShapeEffects( const Reference< XPropertySet >& rXPropSet )
}
else
{
- for( sal_Int32 i=0; i < aOuterShdwProps.getLength(); ++i )
+ for( auto& rOuterShdwProp : aOuterShdwProps )
{
- if( aOuterShdwProps[i].Name == "Attribs" )
+ if( rOuterShdwProp.Name == "Attribs" )
{
Sequence< PropertyValue > aAttribsProps;
- aOuterShdwProps[i].Value >>= aAttribsProps;
+ rOuterShdwProp.Value >>= aAttribsProps;
double dX = +0.0, dY = +0.0;
rXPropSet->getPropertyValue( "ShadowXDistance" ) >>= dX;
rXPropSet->getPropertyValue( "ShadowYDistance" ) >>= dY;
- for( sal_Int32 j=0; j < aAttribsProps.getLength(); ++j )
+ for( auto& rAttribsProp : aAttribsProps )
{
- if( aAttribsProps[j].Name == "dist" )
+ if( rAttribsProp.Name == "dist" )
{
- aAttribsProps[j].Value <<= lcl_CalculateDist(dX, dY);
+ rAttribsProp.Value <<= lcl_CalculateDist(dX, dY);
}
- else if( aAttribsProps[j].Name == "dir" )
+ else if( rAttribsProp.Name == "dir" )
{
- aAttribsProps[j].Value <<= lcl_CalculateDir(dX, dY);
+ rAttribsProp.Value <<= lcl_CalculateDir(dX, dY);
}
}
- aOuterShdwProps[i].Value <<= aAttribsProps;
+ rOuterShdwProp.Value <<= aAttribsProps;
}
- else if( aOuterShdwProps[i].Name == "RgbClr" )
+ else if( rOuterShdwProp.Name == "RgbClr" )
{
- aOuterShdwProps[i].Value = rXPropSet->getPropertyValue( "ShadowColor" );
+ rOuterShdwProp.Value = rXPropSet->getPropertyValue( "ShadowColor" );
}
- else if( aOuterShdwProps[i].Name == "RgbClrTransparency" )
+ else if( rOuterShdwProp.Name == "RgbClrTransparency" )
{
- aOuterShdwProps[i].Value = rXPropSet->getPropertyValue( "ShadowTransparence" );
+ rOuterShdwProp.Value = rXPropSet->getPropertyValue( "ShadowTransparence" );
}
}
mpFS->startElementNS(XML_a, XML_effectLst);
- for( sal_Int32 i=0; i < aEffects.getLength(); ++i )
+ for( const auto& rEffect : std::as_const(aEffects) )
{
- if( aEffects[i].Name == "outerShdw" )
+ if( rEffect.Name == "outerShdw" )
{
- WriteShapeEffect( aEffects[i].Name, aOuterShdwProps );
+ WriteShapeEffect( rEffect.Name, aOuterShdwProps );
}
else
{
Sequence< PropertyValue > aEffectProps;
- aEffects[i].Value >>= aEffectProps;
- WriteShapeEffect( aEffects[i].Name, aEffectProps );
+ rEffect.Value >>= aEffectProps;
+ WriteShapeEffect( rEffect.Name, aEffectProps );
}
}
mpFS->endElementNS(XML_a, XML_effectLst);
@@ -3743,22 +3719,20 @@ void DrawingML::WriteShape3DEffects( const Reference< XPropertySet >& xPropSet )
// extract the relevant properties from the grab bag
Sequence< PropertyValue > aGrabBag, aEffectProps, aLightRigProps, aShape3DProps;
mAny >>= aGrabBag;
- for( sal_Int32 i=0; i < aGrabBag.getLength(); ++i )
+ auto pProp = std::find_if(std::cbegin(aGrabBag), std::cend(aGrabBag),
+ [](const PropertyValue& rProp) { return rProp.Name == "3DEffectProperties"; });
+ if (pProp != std::cend(aGrabBag))
{
- if( aGrabBag[i].Name == "3DEffectProperties" )
+ Sequence< PropertyValue > a3DEffectProps;
+ pProp->Value >>= a3DEffectProps;
+ for( const auto& r3DEffectProp : std::as_const(a3DEffectProps) )
{
- Sequence< PropertyValue > a3DEffectProps;
- aGrabBag[i].Value >>= a3DEffectProps;
- for( sal_Int32 j=0; j < a3DEffectProps.getLength(); ++j )
- {
- if( a3DEffectProps[j].Name == "Camera" )
- a3DEffectProps[j].Value >>= aEffectProps;
- else if( a3DEffectProps[j].Name == "LightRig" )
- a3DEffectProps[j].Value >>= aLightRigProps;
- else if( a3DEffectProps[j].Name == "Shape3D" )
- a3DEffectProps[j].Value >>= aShape3DProps;
- }
- break;
+ if( r3DEffectProp.Name == "Camera" )
+ r3DEffectProp.Value >>= aEffectProps;
+ else if( r3DEffectProp.Name == "LightRig" )
+ r3DEffectProp.Value >>= aLightRigProps;
+ else if( r3DEffectProp.Name == "Shape3D" )
+ r3DEffectProp.Value >>= aShape3DProps;
}
}
if( !aEffectProps.hasElements() && !aLightRigProps.hasElements() && !aShape3DProps.hasElements() )
@@ -3769,37 +3743,37 @@ void DrawingML::WriteShape3DEffects( const Reference< XPropertySet >& xPropSet )
sax_fastparser::XFastAttributeListRef xCameraAttrList( aCameraAttrList );
sax_fastparser::FastAttributeList *aCameraRotationAttrList = FastSerializerHelper::createAttrList();
sax_fastparser::XFastAttributeListRef xRotAttrList( aCameraRotationAttrList );
- for( sal_Int32 i=0; i < aEffectProps.getLength(); ++i )
+ for( const auto& rEffectProp : std::as_const(aEffectProps) )
{
- if( aEffectProps[i].Name == "prst" )
+ if( rEffectProp.Name == "prst" )
{
OUString sVal;
- aEffectProps[i].Value >>= sVal;
+ rEffectProp.Value >>= sVal;
aCameraAttrList->add( XML_prst, OUStringToOString( sVal, RTL_TEXTENCODING_UTF8 ).getStr() );
}
- else if( aEffectProps[i].Name == "fov" )
+ else if( rEffectProp.Name == "fov" )
{
float fVal = 0;
- aEffectProps[i].Value >>= fVal;
+ rEffectProp.Value >>= fVal;
aCameraAttrList->add( XML_fov, OString::number( fVal * 60000 ).getStr() );
}
- else if( aEffectProps[i].Name == "zoom" )
+ else if( rEffectProp.Name == "zoom" )
{
float fVal = 1;
- aEffectProps[i].Value >>= fVal;
+ rEffectProp.Value >>= fVal;
aCameraAttrList->add( XML_zoom, OString::number( fVal * 100000 ).getStr() );
}
- else if( aEffectProps[i].Name == "rotLat" ||
- aEffectProps[i].Name == "rotLon" ||
- aEffectProps[i].Name == "rotRev" )
+ else if( rEffectProp.Name == "rotLat" ||
+ rEffectProp.Name == "rotLon" ||
+ rEffectProp.Name == "rotRev" )
{
sal_Int32 nVal = 0, nToken = XML_none;
- aEffectProps[i].Value >>= nVal;
- if( aEffectProps[i].Name == "rotLat" )
+ rEffectProp.Value >>= nVal;
+ if( rEffectProp.Name == "rotLat" )
nToken = XML_lat;
- else if( aEffectProps[i].Name == "rotLon" )
+ else if( rEffectProp.Name == "rotLon" )
nToken = XML_lon;
- else if( aEffectProps[i].Name == "rotRev" )
+ else if( rEffectProp.Name == "rotRev" )
nToken = XML_rev;
aCameraRotationAttrList->add( nToken, OString::number( nVal ).getStr() );
bCameraRotationPresent = true;
@@ -3811,30 +3785,30 @@ void DrawingML::WriteShape3DEffects( const Reference< XPropertySet >& xPropSet )
sax_fastparser::XFastAttributeListRef xLightAttrList( aLightRigAttrList );
sax_fastparser::FastAttributeList *aLightRigRotationAttrList = FastSerializerHelper::createAttrList();
sax_fastparser::XFastAttributeListRef xLightRotAttrList( aLightRigRotationAttrList );
- for( sal_Int32 i=0; i < aLightRigProps.getLength(); ++i )
+ for( const auto& rLightRigProp : std::as_const(aLightRigProps) )
{
- if( aLightRigProps[i].Name == "rig" || aLightRigProps[i].Name == "dir" )
+ if( rLightRigProp.Name == "rig" || rLightRigProp.Name == "dir" )
{
OUString sVal;
sal_Int32 nToken = XML_none;
- aLightRigProps[i].Value >>= sVal;
- if( aLightRigProps[i].Name == "rig" )
+ rLightRigProp.Value >>= sVal;
+ if( rLightRigProp.Name == "rig" )
nToken = XML_rig;
- else if( aLightRigProps[i].Name == "dir" )
+ else if( rLightRigProp.Name == "dir" )
nToken = XML_dir;
aLightRigAttrList->add( nToken, OUStringToOString( sVal, RTL_TEXTENCODING_UTF8 ).getStr() );
}
- else if( aLightRigProps[i].Name == "rotLat" ||
- aLightRigProps[i].Name == "rotLon" ||
- aLightRigProps[i].Name == "rotRev" )
+ else if( rLightRigProp.Name == "rotLat" ||
+ rLightRigProp.Name == "rotLon" ||
+ rLightRigProp.Name == "rotRev" )
{
sal_Int32 nVal = 0, nToken = XML_none;
- aLightRigProps[i].Value >>= nVal;
- if( aLightRigProps[i].Name == "rotLat" )
+ rLightRigProp.Value >>= nVal;
+ if( rLightRigProp.Name == "rotLat" )
nToken = XML_lat;
- else if( aLightRigProps[i].Name == "rotLon" )
+ else if( rLightRigProp.Name == "rotLon" )
nToken = XML_lon;
- else if( aLightRigProps[i].Name == "rotRev" )
+ else if( rLightRigProp.Name == "rotRev" )
nToken = XML_rev;
aLightRigRotationAttrList->add( nToken, OString::number( nVal ).getStr() );
bLightRigRotationPresent = true;
@@ -3885,43 +3859,43 @@ void DrawingML::WriteShape3DEffects( const Reference< XPropertySet >& xPropSet )
sax_fastparser::FastAttributeList *aBevelBAttrList = FastSerializerHelper::createAttrList();
sax_fastparser::XFastAttributeListRef xBevelBAttrList( aBevelBAttrList );
sax_fastparser::FastAttributeList *aShape3DAttrList = FastSerializerHelper::createAttrList();
- for( sal_Int32 i=0; i < aShape3DProps.getLength(); ++i )
+ for( const auto& rShape3DProp : std::as_const(aShape3DProps) )
{
- if( aShape3DProps[i].Name == "extrusionH" || aShape3DProps[i].Name == "contourW" || aShape3DProps[i].Name == "z" )
+ if( rShape3DProp.Name == "extrusionH" || rShape3DProp.Name == "contourW" || rShape3DProp.Name == "z" )
{
sal_Int32 nVal = 0, nToken = XML_none;
- aShape3DProps[i].Value >>= nVal;
- if( aShape3DProps[i].Name == "extrusionH" )
+ rShape3DProp.Value >>= nVal;
+ if( rShape3DProp.Name == "extrusionH" )
nToken = XML_extrusionH;
- else if( aShape3DProps[i].Name == "contourW" )
+ else if( rShape3DProp.Name == "contourW" )
nToken = XML_contourW;
- else if( aShape3DProps[i].Name == "z" )
+ else if( rShape3DProp.Name == "z" )
nToken = XML_z;
aShape3DAttrList->add( nToken, OString::number( nVal ).getStr() );
}
- else if( aShape3DProps[i].Name == "prstMaterial" )
+ else if( rShape3DProp.Name == "prstMaterial" )
{
OUString sVal;
- aShape3DProps[i].Value >>= sVal;
+ rShape3DProp.Value >>= sVal;
aShape3DAttrList->add( XML_prstMaterial, OUStringToOString( sVal, RTL_TEXTENCODING_UTF8 ).getStr() );
}
- else if( aShape3DProps[i].Name == "extrusionClr" )
+ else if( rShape3DProp.Name == "extrusionClr" )
{
- aShape3DProps[i].Value >>= aExtrusionColorProps;
+ rShape3DProp.Value >>= aExtrusionColorProps;
}
- else if( aShape3DProps[i].Name == "contourClr" )
+ else if( rShape3DProp.Name == "contourClr" )
{
- aShape3DProps[i].Value >>= aContourColorProps;
+ rShape3DProp.Value >>= aContourColorProps;
}
- else if( aShape3DProps[i].Name == "bevelT" || aShape3DProps[i].Name == "bevelB" )
+ else if( rShape3DProp.Name == "bevelT" || rShape3DProp.Name == "bevelB" )
{
Sequence< PropertyValue > aBevelProps;
- aShape3DProps[i].Value >>= aBevelProps;
+ rShape3DProp.Value >>= aBevelProps;
if ( !aBevelProps.hasElements() )
continue;
sax_fastparser::FastAttributeList *aBevelAttrList = nullptr;
- if( aShape3DProps[i].Name == "bevelT" )
+ if( rShape3DProp.Name == "bevelT" )
{
bBevelTPresent = true;
aBevelAttrList = aBevelTAttrList;
@@ -3931,22 +3905,22 @@ void DrawingML::WriteShape3DEffects( const Reference< XPropertySet >& xPropSet )
bBevelBPresent = true;
aBevelAttrList = aBevelBAttrList;
}
- for( sal_Int32 j=0; j < aBevelProps.getLength(); ++j )
+ for( const auto& rBevelProp : std::as_const(aBevelProps) )
{
- if( aBevelProps[j].Name == "w" || aBevelProps[j].Name == "h" )
+ if( rBevelProp.Name == "w" || rBevelProp.Name == "h" )
{
sal_Int32 nVal = 0, nToken = XML_none;
- aBevelProps[j].Value >>= nVal;
- if( aBevelProps[j].Name == "w" )
+ rBevelProp.Value >>= nVal;
+ if( rBevelProp.Name == "w" )
nToken = XML_w;
- else if( aBevelProps[j].Name == "h" )
+ else if( rBevelProp.Name == "h" )
nToken = XML_h;
aBevelAttrList->add( nToken, OString::number( nVal ).getStr() );
}
- else if( aBevelProps[j].Name == "prst" )
+ else if( rBevelProp.Name == "prst" )
{
OUString sVal;
- aBevelProps[j].Value >>= sVal;
+ rBevelProp.Value >>= sVal;
aBevelAttrList->add( XML_prst, OUStringToOString( sVal, RTL_TEXTENCODING_UTF8 ).getStr() );
}
}
@@ -3970,16 +3944,16 @@ void DrawingML::WriteShape3DEffects( const Reference< XPropertySet >& xPropSet )
::Color nColor;
sal_Int32 nTransparency(0);
Sequence< PropertyValue > aColorTransformations;
- for( sal_Int32 i=0; i < aExtrusionColorProps.getLength(); ++i )
+ for( const auto& rExtrusionColorProp : std::as_const(aExtrusionColorProps) )
{
- if( aExtrusionColorProps[i].Name == "schemeClr" )
- aExtrusionColorProps[i].Value >>= sSchemeClr;
- else if( aExtrusionColorProps[i].Name == "schemeClrTransformations" )
- aExtrusionColorProps[i].Value >>= aColorTransformations;
- else if( aExtrusionColorProps[i].Name == "rgbClr" )
- aExtrusionColorProps[i].Value >>= nColor;
- else if( aExtrusionColorProps[i].Name == "rgbClrTransparency" )
- aExtrusionColorProps[i].Value >>= nTransparency;
+ if( rExtrusionColorProp.Name == "schemeClr" )
+ rExtrusionColorProp.Value >>= sSchemeClr;
+ else if( rExtrusionColorProp.Name == "schemeClrTransformations" )
+ rExtrusionColorProp.Value >>= aColorTransformations;
+ else if( rExtrusionColorProp.Name == "rgbClr" )
+ rExtrusionColorProp.Value >>= nColor;
+ else if( rExtrusionColorProp.Name == "rgbClrTransparency" )
+ rExtrusionColorProp.Value >>= nTransparency;
}
mpFS->startElementNS(XML_a, XML_extrusionClr);
@@ -3996,16 +3970,16 @@ void DrawingML::WriteShape3DEffects( const Reference< XPropertySet >& xPropSet )
::Color nColor;
sal_Int32 nTransparency(0);
Sequence< PropertyValue > aColorTransformations;
- for( sal_Int32 i=0; i < aContourColorProps.getLength(); ++i )
+ for( const auto& rContourColorProp : std::as_const(aContourColorProps) )
{
- if( aContourColorProps[i].Name == "schemeClr" )
- aContourColorProps[i].Value >>= sSchemeClr;
- else if( aContourColorProps[i].Name == "schemeClrTransformations" )
- aContourColorProps[i].Value >>= aColorTransformations;
- else if( aContourColorProps[i].Name == "rgbClr" )
- aContourColorProps[i].Value >>= nColor;
- else if( aContourColorProps[i].Name == "rgbClrTransparency" )
- aContourColorProps[i].Value >>= nTransparency;
+ if( rContourColorProp.Name == "schemeClr" )
+ rContourColorProp.Value >>= sSchemeClr;
+ else if( rContourColorProp.Name == "schemeClrTransformations" )
+ rContourColorProp.Value >>= aColorTransformations;
+ else if( rContourColorProp.Name == "rgbClr" )
+ rContourColorProp.Value >>= nColor;
+ else if( rContourColorProp.Name == "rgbClrTransparency" )
+ rContourColorProp.Value >>= nTransparency;
}
mpFS->startElementNS(XML_a, XML_contourClr);
@@ -4027,14 +4001,10 @@ void DrawingML::WriteArtisticEffect( const Reference< XPropertySet >& rXPropSet
PropertyValue aEffect;
Sequence< PropertyValue > aGrabBag;
mAny >>= aGrabBag;
- for( sal_Int32 i=0; i < aGrabBag.getLength(); ++i )
- {
- if( aGrabBag[i].Name == "ArtisticEffectProperties" )
- {
- aGrabBag[i].Value >>= aEffect;
- break;
- }
- }
+ auto pProp = std::find_if(std::cbegin(aGrabBag), std::cend(aGrabBag),
+ [](const PropertyValue& rProp) { return rProp.Name == "ArtisticEffectProperties"; });
+ if (pProp != std::cend(aGrabBag))
+ pProp->Value >>= aEffect;
sal_Int32 nEffectToken = ArtisticEffectProperties::getEffectToken( aEffect.Name );
if( nEffectToken == XML_none )
return;
@@ -4043,27 +4013,27 @@ void DrawingML::WriteArtisticEffect( const Reference< XPropertySet >& rXPropSet
aEffect.Value >>= aAttrs;
sax_fastparser::FastAttributeList *aAttrList = FastSerializerHelper::createAttrList();
OString sRelId;
- for( sal_Int32 i=0; i < aAttrs.getLength(); ++i )
+ for( const auto& rAttr : std::as_const(aAttrs) )
{
- sal_Int32 nToken = ArtisticEffectProperties::getEffectToken( aAttrs[i].Name );
+ sal_Int32 nToken = ArtisticEffectProperties::getEffectToken( rAttr.Name );
if( nToken != XML_none )
{
sal_Int32 nVal = 0;
- aAttrs[i].Value >>= nVal;
+ rAttr.Value >>= nVal;
aAttrList->add( nToken, OString::number( nVal ).getStr() );
}
- else if( aAttrs[i].Name == "OriginalGraphic" )
+ else if( rAttr.Name == "OriginalGraphic" )
{
Sequence< PropertyValue > aGraphic;
- aAttrs[i].Value >>= aGraphic;
+ rAttr.Value >>= aGraphic;
Sequence< sal_Int8 > aGraphicData;
OUString sGraphicId;
- for( sal_Int32 j=0; j < aGraphic.getLength(); ++j )
+ for( const auto& rProp : std::as_const(aGraphic) )
{
- if( aGraphic[j].Name == "Id" )
- aGraphic[j].Value >>= sGraphicId;
- else if( aGraphic[j].Name == "Data" )
- aGraphic[j].Value >>= aGraphicData;
+ if( rProp.Name == "Id" )
+ rProp.Value >>= sGraphicId;
+ else if( rProp.Name == "Data" )
+ rProp.Value >>= aGraphicData;
}
sRelId = WriteWdpPicture( sGraphicId, aGraphicData );
}
@@ -4129,25 +4099,25 @@ void DrawingML::WriteDiagram(const css::uno::Reference<css::drawing::XShape>& rX
// retrieve the doms from the GrabBag
uno::Sequence<beans::PropertyValue> propList;
xPropSet->getPropertyValue(UNO_NAME_MISC_OBJ_INTEROPGRABBAG) >>= propList;
- for (sal_Int32 nProp = 0; nProp < propList.getLength(); ++nProp)
+ for (const auto& rProp : std::as_const(propList))
{
- OUString propName = propList[nProp].Name;
+ OUString propName = rProp.Name;
if (propName == "OOXData")
- propList[nProp].Value >>= dataDom;
+ rProp.Value >>= dataDom;
else if (propName == "OOXLayout")
- propList[nProp].Value >>= layoutDom;
+ rProp.Value >>= layoutDom;
else if (propName == "OOXStyle")
- propList[nProp].Value >>= styleDom;
+ rProp.Value >>= styleDom;
else if (propName == "OOXColor")
- propList[nProp].Value >>= colorDom;
+ rProp.Value >>= colorDom;
else if (propName == "OOXDrawing")
{
- propList[nProp].Value >>= diagramDrawing;
+ rProp.Value >>= diagramDrawing;
diagramDrawing[0]
>>= drawingDom; // if there is OOXDrawing property then set drawingDom here only.
}
else if (propName == "OOXDiagramDataRels")
- propList[nProp].Value >>= xDataRelSeq;
+ rProp.Value >>= xDataRelSeq;
}
// check that we have the 4 mandatory XDocuments
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 5e9d069c3290..ebab46728bef 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -659,15 +659,12 @@ static void lcl_AnalyzeHandles( const uno::Sequence<beans::PropertyValues> & rHa
std::vector< std::pair< sal_Int32, sal_Int32> > &rHandlePositionList,
Sequence< EnhancedCustomShapeAdjustmentValue > &rSeq)
{
- sal_uInt16 k;
- sal_uInt16 nHandles = rHandles.getLength();
- for ( k = 0; k < nHandles ; k++ )
+ for ( const Sequence< PropertyValue >& rPropSeq : rHandles )
{
const OUString sPosition( "Position" );
bool bPosition = false;
EnhancedCustomShapeParameterPair aPosition;
EnhancedCustomShapeParameterPair aPolar;
- const Sequence< PropertyValue >& rPropSeq = rHandles[ k ];
for ( const PropertyValue& rPropVal: rPropSeq )
{
if ( rPropVal.Name == sPosition )
@@ -731,17 +728,15 @@ ShapeExport& ShapeExport::WriteCustomShape( const Reference< XShape >& xShape )
{
bHasGeometrySeq = true;
SAL_INFO("oox.shape", "got custom shape geometry sequence");
- for (int i = 0; i < aGeometrySeq.getLength(); i++)
+ for (const PropertyValue& rProp : std::as_const(aGeometrySeq))
{
- const PropertyValue& rProp = aGeometrySeq[i];
SAL_INFO("oox.shape", "geometry property: " << rProp.Name);
if (rProp.Name == "TextPath")
{
uno::Sequence<beans::PropertyValue> aTextPathSeq;
rProp.Value >>= aTextPathSeq;
- for (int k = 0; k < aTextPathSeq.getLength(); k++)
+ for (const PropertyValue& rTextProp : std::as_const(aTextPathSeq))
{
- const PropertyValue& rTextProp = aTextPathSeq[k];
if (rTextProp.Name == "TextPath")
{
rTextProp.Value >>= bIsFontworkShape;
diff --git a/oox/source/helper/propertyset.cxx b/oox/source/helper/propertyset.cxx
index ca972c8f3c90..8bf9aec42991 100644
--- a/oox/source/helper/propertyset.cxx
+++ b/oox/source/helper/propertyset.cxx
@@ -90,11 +90,9 @@ void PropertySet::setProperties( const Sequence< OUString >& rPropNames, const S
if( mxPropSet.is() )
{
- const OUString* pPropName = rPropNames.getConstArray();
- const OUString* pPropNameEnd = pPropName + rPropNames.getLength();
const Any* pValue = rValues.getConstArray();
- for( ; pPropName != pPropNameEnd; ++pPropName, ++pValue )
- implSetPropertyValue( *pPropName, *pValue );
+ for( const OUString& rPropName : rPropNames )
+ implSetPropertyValue( rPropName, *pValue++ );
}
}
diff --git a/oox/source/mathml/importutils.cxx b/oox/source/mathml/importutils.cxx
index 20decf4e7d45..178a3eed6791 100644
--- a/oox/source/mathml/importutils.cxx
+++ b/oox/source/mathml/importutils.cxx
@@ -46,14 +46,10 @@ AttributeListBuilder::AttributeListBuilder( const uno::Reference< xml::sax::XFas
{
if( a.get() == nullptr )
return;
- uno::Sequence< xml::FastAttribute > aFastAttrSeq = a->getFastAttributes();
- const xml::FastAttribute* pFastAttr = aFastAttrSeq.getConstArray();
- sal_Int32 nFastAttrLength = aFastAttrSeq.getLength();
- for( int i = 0;
- i < nFastAttrLength;
- ++i )
+ const uno::Sequence< xml::FastAttribute > aFastAttrSeq = a->getFastAttributes();
+ for( const xml::FastAttribute& rFastAttr : aFastAttrSeq )
{
- attrs[ pFastAttr[ i ].Token ] = pFastAttr[ i ].Value;
+ attrs[ rFastAttr.Token ] = rFastAttr.Value;
}
}
diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index 1dd2b5d25537..052285cbdfbb 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -733,7 +733,7 @@ void writePROJECTMODULE(SvStream& rStrm, const OUString& name, const sal_uInt16
// section 2.3.4.2.3
void writePROJECTMODULES(SvStream& rStrm, const css::uno::Reference<css::container::XNameContainer>& xNameContainer, const std::vector<sal_Int32>& rLibrayMap)
{
- css::uno::Sequence<OUString> aElementNames = xNameContainer->getElementNames();
+ const css::uno::Sequence<OUString> aElementNames = xNameContainer->getElementNames();
sal_Int32 n = aElementNames.getLength();
css::uno::Reference<css::script::vba::XVBAModuleInfo> xModuleInfo(xNameContainer, css::uno::UNO_QUERY);
assert(xModuleInfo.is());
@@ -839,7 +839,7 @@ void exportVBAProjectStream(SvStream& rStrm)
void exportPROJECTStream(SvStream& rStrm, const css::uno::Reference<css::container::XNameContainer>& xNameContainer,
const OUString& projectName, const std::vector<sal_Int32>& rLibraryMap)
{
- css::uno::Sequence<OUString> aElementNames = xNameContainer->getElementNames();
+ const css::uno::Sequence<OUString> aElementNames = xNameContainer->getElementNames();
sal_Int32 n = aElementNames.getLength();
css::uno::Reference<css::script::vba::XVBAModuleInfo> xModuleInfo(xNameContainer, css::uno::UNO_QUERY);
assert(xModuleInfo.is());
@@ -964,7 +964,7 @@ void exportPROJECTwmStream(SvStream& rStrm, const css::uno::Sequence<OUString>&
void getCorrectExportOrder(const css::uno::Reference<css::container::XNameContainer>& xNameContainer, std::vector<sal_Int32>& rLibraryMap)
{
- css::uno::Sequence<OUString> aElementNames = xNameContainer->getElementNames();
+ const css::uno::Sequence<OUString> aElementNames = xNameContainer->getElementNames();
sal_Int32 n = aElementNames.getLength();
css::uno::Reference<css::script::vba::XVBAModuleInfo> xModuleInfo(xNameContainer, css::uno::UNO_QUERY);
@@ -1027,7 +1027,7 @@ void VbaExport::exportVBA(SotStorage* pRootStorage)
if (!xNameContainer.is()) {
return;
}
- css::uno::Sequence<OUString> aElementNames = xNameContainer->getElementNames();
+ const css::uno::Sequence<OUString> aElementNames = xNameContainer->getElementNames();
sal_Int32 n = aElementNames.getLength(); // get the number of modules
// export the elements in the order MSO expects them
// we store the index of the
diff --git a/oox/source/ppt/timenode.cxx b/oox/source/ppt/timenode.cxx
index 6a2fcce8f469..3c59b54c9cdc 100644
--- a/oox/source/ppt/timenode.cxx
+++ b/oox/source/ppt/timenode.cxx
@@ -144,14 +144,12 @@ namespace oox { namespace ppt {
{
Reference< XAnimationNode > xEffectNode( xE2->nextElement(), UNO_QUERY_THROW );
const Sequence< NamedValue > aUserData( xEffectNode->getUserData() );
- const NamedValue* p = aUserData.getConstArray();
- sal_Int32 nLength = aUserData.getLength();
- while( nLength-- )
+ for( const NamedValue& rProp : aUserData )
{
- if ( p->Name == "node-type" )
+ if ( rProp.Name == "node-type" )
{
sal_Int16 nNodeType = 0;
- p->Value >>= nNodeType;
+ rProp.Value >>= nNodeType;
if( nNodeType != css::presentation::EffectNodeType::ON_CLICK )
{
// first effect does not start on click, so correct
@@ -160,7 +158,6 @@ namespace oox { namespace ppt {
break;
}
}
- p++;
}
}
}
diff --git a/oox/source/shape/ShapeFilterBase.cxx b/oox/source/shape/ShapeFilterBase.cxx
index 1ebae0c9a230..562504090f76 100644
--- a/oox/source/shape/ShapeFilterBase.cxx
+++ b/oox/source/shape/ShapeFilterBase.cxx
@@ -120,12 +120,12 @@ void ShapeFilterBase::importTheme()
uno::Sequence<beans::PropertyValue> aGrabBag;
xPropSet->getPropertyValue("InteropGrabBag") >>= aGrabBag;
- for (int i = 0; i < aGrabBag.getLength(); i++)
+ for (const auto& rProp : std::as_const(aGrabBag))
{
- if (aGrabBag[i].Name == "OOXTheme")
+ if (rProp.Name == "OOXTheme")
{
uno::Reference<xml::sax::XFastSAXSerializable> xDoc;
- if (aGrabBag[i].Value >>= xDoc)
+ if (rProp.Value >>= xDoc)
{
rtl::Reference<core::FragmentHandler> xFragmentHandler(
new drawingml::ThemeFragmentHandler(*this, OUString(), *pTheme));
diff --git a/oox/source/vml/vmlformatting.cxx b/oox/source/vml/vmlformatting.cxx
index 143ef173b386..3d1d10e16fc2 100644
--- a/oox/source/vml/vmlformatting.cxx
+++ b/oox/source/vml/vmlformatting.cxx
@@ -917,9 +917,8 @@ void TextpathModel::pushToPropMap(ShapePropertyMap& rPropMap, const uno::Referen
uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
uno::Sequence<beans::PropertyValue> aGeomPropSeq = xPropertySet->getPropertyValue("CustomShapeGeometry").get< uno::Sequence<beans::PropertyValue> >();
bool bFound = false;
- for (int i = 0; i < aGeomPropSeq.getLength(); ++i)
+ for (beans::PropertyValue& rProp : aGeomPropSeq)
{
- beans::PropertyValue& rProp = aGeomPropSeq[i];
if (rProp.Name == "TextPath")
{
bFound = true;
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index eca5399bf72c..c21471e5c475 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -1263,32 +1263,31 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes
embed::ElementModes::READ);
SAL_WARN_IF(!xStorage.is(), "oox.vml", "No xStorage!");
- uno::Sequence<security::DocumentSignatureInformation> xSignatureInfo
+ const uno::Sequence<security::DocumentSignatureInformation> xSignatureInfo
= xSignatures->verifyScriptingContentSignatures(xStorage,
uno::Reference<io::XInputStream>());
- for (int i = 0; i < xSignatureInfo.getLength(); i++)
+ // Try to find matching signature line image - if none exists that is fine,
+ // then the signature line is not digitally signed.
+ auto pSignInfo = std::find_if(xSignatureInfo.begin(), xSignatureInfo.end(),
+ [this](const security::DocumentSignatureInformation& rSigInfo) {
+ return rSigInfo.SignatureLineId == getShapeModel().maSignatureId; });
+ if (pSignInfo != xSignatureInfo.end())
{
- // Try to find matching signature line image - if none exists that is fine,
- // then the signature line is not digitally signed.
- if (xSignatureInfo[i].SignatureLineId == getShapeModel().maSignatureId)
+ bIsSigned = true;
+ if (pSignInfo->SignatureIsValid)
{
- bIsSigned = true;
- if (xSignatureInfo[i].SignatureIsValid)
- {
- // Signature is valid, use the 'valid' image
- SAL_WARN_IF(!xSignatureInfo[i].ValidSignatureLineImage.is(), "oox.vml",
- "No ValidSignatureLineImage!");
- xGraphic = xSignatureInfo[i].ValidSignatureLineImage;
- }
- else
- {
- // Signature is invalid, use the 'invalid' image
- SAL_WARN_IF(!xSignatureInfo[i].InvalidSignatureLineImage.is(), "oox.vml",
- "No InvalidSignatureLineImage!");
- xGraphic = xSignatureInfo[i].InvalidSignatureLineImage;
- }
- break;
+ // Signature is valid, use the 'valid' image
+ SAL_WARN_IF(!pSignInfo->ValidSignatureLineImage.is(), "oox.vml",
+ "No ValidSignatureLineImage!");
+ xGraphic = pSignInfo->ValidSignatureLineImage;
+ }
+ else
+ {
+ // Signature is invalid, use the 'invalid' image
+ SAL_WARN_IF(!pSignInfo->InvalidSignatureLineImage.is(), "oox.vml",
+ "No InvalidSignatureLineImage!");
+ xGraphic = pSignInfo->InvalidSignatureLineImage;
}
}
}
@@ -1418,17 +1417,9 @@ Reference< XShape > GroupShape::implConvertAndInsert( const Reference< XShapes >
beans::PropertyValue aPair;
aPair.Name = "mso-edit-as";
aPair.Value <<= maTypeModel.maEditAs;
- if (aGrabBag.hasElements())
- {
- sal_Int32 nLength = aGrabBag.getLength();
- aGrabBag.realloc(nLength + 1);
- aGrabBag[nLength] = aPair;
- }
- else
- {
- aGrabBag.realloc(1);
- aGrabBag[0] = aPair;
- }
+ sal_Int32 nLength = aGrabBag.getLength();
+ aGrabBag.realloc(nLength + 1);
+ aGrabBag[nLength] = aPair;
xPropertySet->setPropertyValue("InteropGrabBag", uno::makeAny(aGrabBag));
}
// Make sure group shapes are inline as well, unless there is an explicit different style.