[Libreoffice-commits] core.git: writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Mon May 23 08:40:23 UTC 2016


 writerfilter/source/rtftok/rtfdispatchflag.cxx        |    4 
 writerfilter/source/rtftok/rtfdocumentimpl.cxx        |   66 ++---
 writerfilter/source/rtftok/rtfreferenceproperties.cxx |    8 
 writerfilter/source/rtftok/rtfreferencetable.cxx      |    4 
 writerfilter/source/rtftok/rtfsdrimport.cxx           |  235 ++++++++----------
 writerfilter/source/rtftok/rtfsprm.cxx                |   60 ++--
 writerfilter/source/rtftok/rtftokenizer.cxx           |    4 
 7 files changed, 187 insertions(+), 194 deletions(-)

New commits:
commit 514966907c6fb8ca05e5445a8376de923ba177bc
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon May 23 09:04:27 2016 +0200

    writerfilter: use auto where it improves code readability
    
    for (std::vector< std::pair<Id, RTFValue::Pointer_t> >::const_iterator i = m_pSprms->begin(); i != m_pSprms->end(); ++i)
    
    vs
    
    for (auto& rSprm : *m_pSprms)
    
    and so on.
    
    Change-Id: I2b4d975af096fb59815b074cbcb9934bead9e6f0
    Reviewed-on: https://gerrit.libreoffice.org/25350
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/writerfilter/source/rtftok/rtfdispatchflag.cxx b/writerfilter/source/rtftok/rtfdispatchflag.cxx
index 6888f3f..8844503 100644
--- a/writerfilter/source/rtftok/rtfdispatchflag.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchflag.cxx
@@ -917,8 +917,8 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
         }
         m_aStates.top().aDrawingObject.xPropertySet.set(m_aStates.top().aDrawingObject.xShape, uno::UNO_QUERY);
         std::vector<beans::PropertyValue>& rPendingProperties = m_aStates.top().aDrawingObject.aPendingProperties;
-        for (std::vector<beans::PropertyValue>::iterator i = rPendingProperties.begin(); i != rPendingProperties.end(); ++i)
-            m_aStates.top().aDrawingObject.xPropertySet->setPropertyValue(i->Name, i->Value);
+        for (auto& rPendingProperty : rPendingProperties)
+            m_aStates.top().aDrawingObject.xPropertySet->setPropertyValue(rPendingProperty.Name, rPendingProperty.Value);
         m_pSdrImport->resolveDhgt(m_aStates.top().aDrawingObject.xPropertySet, m_aStates.top().aDrawingObject.nDhgt, /*bOldStyle=*/true);
     }
     break;
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 6f01330..761cf20 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -419,27 +419,27 @@ void RTFDocumentImpl::setNeedSect(bool bNeedSect)
 /// Copy rProps to rStyleAttributes and rStyleSprms, but in case of nested sprms, copy their children as toplevel sprms/attributes.
 static void lcl_copyFlatten(RTFReferenceProperties& rProps, RTFSprms& rStyleAttributes, RTFSprms& rStyleSprms)
 {
-    for (RTFSprms::Iterator_t it = rProps.getSprms().begin(); it != rProps.getSprms().end(); ++it)
+    for (auto& rSprm : rProps.getSprms())
     {
         // createStyleProperties() puts properties to rPr, but here we need a flat list.
-        if (it->first == NS_ooxml::LN_CT_Style_rPr)
+        if (rSprm.first == NS_ooxml::LN_CT_Style_rPr)
         {
             // rPr can have both attributes and SPRMs, copy over both types.
-            RTFSprms& rRPrSprms = it->second->getSprms();
-            for (RTFSprms::Iterator_t itRPrSprm = rRPrSprms.begin(); itRPrSprm != rRPrSprms.end(); ++itRPrSprm)
-                rStyleSprms.set(itRPrSprm->first, itRPrSprm->second);
+            RTFSprms& rRPrSprms = rSprm.second->getSprms();
+            for (auto& rRPrSprm : rRPrSprms)
+                rStyleSprms.set(rRPrSprm.first, rRPrSprm.second);
 
-            RTFSprms& rRPrAttributes = it->second->getAttributes();
-            for (RTFSprms::Iterator_t itRPrAttribute = rRPrAttributes.begin(); itRPrAttribute != rRPrAttributes.end(); ++itRPrAttribute)
-                rStyleAttributes.set(itRPrAttribute->first, itRPrAttribute->second);
+            RTFSprms& rRPrAttributes = rSprm.second->getAttributes();
+            for (auto& rRPrAttribute : rRPrAttributes)
+                rStyleAttributes.set(rRPrAttribute.first, rRPrAttribute.second);
         }
         else
-            rStyleSprms.set(it->first, it->second);
+            rStyleSprms.set(rSprm.first, rSprm.second);
     }
 
     RTFSprms& rAttributes = rProps.getAttributes();
-    for (RTFSprms::Iterator_t itAttr = rAttributes.begin(); itAttr != rAttributes.end(); ++itAttr)
-        rStyleAttributes.set(itAttr->first, itAttr->second);
+    for (auto& rAttribute : rAttributes)
+        rStyleAttributes.set(rAttribute.first, rAttribute.second);
 }
 
 writerfilter::Reference<Properties>::Pointer_t RTFDocumentImpl::getProperties(RTFSprms& rAttributes, RTFSprms& rSprms)
@@ -447,14 +447,14 @@ writerfilter::Reference<Properties>::Pointer_t RTFDocumentImpl::getProperties(RT
     int nStyle = 0;
     if (!m_aStates.empty())
         nStyle = m_aStates.top().nCurrentStyleIndex;
-    RTFReferenceTable::Entries_t::iterator it = m_aStyleTableEntries.find(nStyle);
+    auto it = m_aStyleTableEntries.find(nStyle);
     if (it != m_aStyleTableEntries.end())
     {
         RTFReferenceProperties& rProps = *static_cast<RTFReferenceProperties*>(it->second.get());
 
         // cloneAndDeduplicate() wants to know about only a single "style", so
         // let's merge paragraph and character style properties here.
-        RTFReferenceTable::Entries_t::iterator itChar = m_aStyleTableEntries.end();
+        auto itChar = m_aStyleTableEntries.end();
         if (!m_aStates.empty())
         {
             int nCharStyle = m_aStates.top().nCurrentCharacterStyleIndex;
@@ -654,7 +654,7 @@ rtl_TextEncoding RTFDocumentImpl::getEncoding(int nFontIndex)
 {
     if (!m_pSuperstream)
     {
-        std::map<int, rtl_TextEncoding>::iterator it = m_aFontEncodings.find(nFontIndex);
+        auto it = m_aFontEncodings.find(nFontIndex);
         if (it != m_aFontEncodings.end())
             // We have a font encoding associated to this font.
             return it->second;
@@ -949,9 +949,9 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XS
     auto pExtentValue = std::make_shared<RTFValue>(aExtentAttributes);
     // docpr sprm
     RTFSprms aDocprAttributes;
-    for (RTFSprms::Iterator_t i = m_aStates.top().aCharacterAttributes.begin(); i != m_aStates.top().aCharacterAttributes.end(); ++i)
-        if (i->first == NS_ooxml::LN_CT_NonVisualDrawingProps_name || i->first == NS_ooxml::LN_CT_NonVisualDrawingProps_descr)
-            aDocprAttributes.set(i->first, i->second);
+    for (auto& rCharacterAttribute : m_aStates.top().aCharacterAttributes)
+        if (rCharacterAttribute.first == NS_ooxml::LN_CT_NonVisualDrawingProps_name || rCharacterAttribute.first == NS_ooxml::LN_CT_NonVisualDrawingProps_descr)
+            aDocprAttributes.set(rCharacterAttribute.first, rCharacterAttribute.second);
     auto pDocprValue = std::make_shared<RTFValue>(aDocprAttributes);
     if (bInline)
     {
@@ -974,23 +974,23 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XS
         RTFSprms aAnchorWrapAttributes;
         m_aStates.top().aShape.aAnchorAttributes.set(NS_ooxml::LN_CT_Anchor_behindDoc, std::make_shared<RTFValue>((m_aStates.top().aShape.bInBackground) ? 1 : 0));
         RTFSprms aAnchorSprms;
-        for (RTFSprms::Iterator_t i = m_aStates.top().aCharacterAttributes.begin(); i != m_aStates.top().aCharacterAttributes.end(); ++i)
+        for (auto& rCharacterAttribute : m_aStates.top().aCharacterAttributes)
         {
-            if (i->first == NS_ooxml::LN_CT_WrapSquare_wrapText)
-                aAnchorWrapAttributes.set(i->first, i->second);
+            if (rCharacterAttribute.first == NS_ooxml::LN_CT_WrapSquare_wrapText)
+                aAnchorWrapAttributes.set(rCharacterAttribute.first, rCharacterAttribute.second);
         }
         sal_Int32 nWrap = -1;
-        for (RTFSprms::Iterator_t i = m_aStates.top().aCharacterSprms.begin(); i != m_aStates.top().aCharacterSprms.end(); ++i)
+        for (auto& rCharacterSprm : m_aStates.top().aCharacterSprms)
         {
-            if (i->first == NS_ooxml::LN_EG_WrapType_wrapNone || i->first == NS_ooxml::LN_EG_WrapType_wrapTight)
+            if (rCharacterSprm.first == NS_ooxml::LN_EG_WrapType_wrapNone || rCharacterSprm.first == NS_ooxml::LN_EG_WrapType_wrapTight)
             {
-                nWrap = i->first;
+                nWrap = rCharacterSprm.first;
 
                 // If there is a wrap polygon prepared by RTFSdrImport, pick it up here.
-                if (i->first == NS_ooxml::LN_EG_WrapType_wrapTight && !m_aStates.top().aShape.aWrapPolygonSprms.empty())
-                    i->second->getSprms().set(NS_ooxml::LN_CT_WrapTight_wrapPolygon, std::make_shared<RTFValue>(RTFSprms(), m_aStates.top().aShape.aWrapPolygonSprms));
+                if (rCharacterSprm.first == NS_ooxml::LN_EG_WrapType_wrapTight && !m_aStates.top().aShape.aWrapPolygonSprms.empty())
+                    rCharacterSprm.second->getSprms().set(NS_ooxml::LN_CT_WrapTight_wrapPolygon, std::make_shared<RTFValue>(RTFSprms(), m_aStates.top().aShape.aWrapPolygonSprms));
 
-                aAnchorSprms.set(i->first, i->second);
+                aAnchorSprms.set(rCharacterSprm.first, rCharacterSprm.second);
             }
         }
         auto pAnchorWrapValue = std::make_shared<RTFValue>(aAnchorWrapAttributes);
@@ -1237,7 +1237,7 @@ void RTFDocumentImpl::text(OUString& rString)
                 //See fdo#47347 initial invalid font entry properties are inserted first,
                 //so when we attempt to insert the correct ones, there's already an
                 //entry in the map for them, so the new ones aren't inserted.
-                RTFReferenceTable::Entries_t::iterator lb = m_aFontTableEntries.lower_bound(m_nCurrentFontIndex);
+                auto lb = m_aFontTableEntries.lower_bound(m_nCurrentFontIndex);
                 if (lb != m_aFontTableEntries.end() && !(m_aFontTableEntries.key_comp()(m_nCurrentFontIndex, lb->first)))
                     lb->second = pProp;
                 else
@@ -1539,9 +1539,9 @@ void RTFDocumentImpl::replayBuffer(RTFBuffer_t& rBuffer,
 
 bool findPropertyName(const std::vector<beans::PropertyValue>& rProperties, const OUString& rName)
 {
-    for (std::vector<beans::PropertyValue>::const_iterator it = rProperties.begin(); it != rProperties.end(); ++it)
+    for (auto& rProperty : rProperties)
     {
-        if (it->Name == rName)
+        if (rProperty.Name == rName)
             return true;
     }
     return false;
@@ -1918,8 +1918,8 @@ RTFError RTFDocumentImpl::popState()
     }
     break;
     case Destination::LISTENTRY:
-        for (RTFSprms::Iterator_t i = aState.aListLevelEntries.begin(); i != aState.aListLevelEntries.end(); ++i)
-            aState.aTableSprms.set(i->first, i->second, RTFOverwrite::NO_APPEND);
+        for (auto& rListLevelEntry : aState.aListLevelEntries)
+            aState.aTableSprms.set(rListLevelEntry.first, rListLevelEntry.second, RTFOverwrite::NO_APPEND);
         break;
     case Destination::FIELDINSTRUCTION:
     {
@@ -2071,8 +2071,8 @@ RTFError RTFDocumentImpl::popState()
         else if (aState.bInShapeGroup && !aState.bInShape)
         {
             // End of a groupshape, as we're in shapegroup, but not in a real shape.
-            for (std::vector< std::pair<OUString, OUString> >::iterator i = aState.aShape.aGroupProperties.begin(); i != aState.aShape.aGroupProperties.end(); ++i)
-                m_pSdrImport->appendGroupProperty(i->first, i->second);
+            for (auto& rGroupProperty : aState.aShape.aGroupProperties)
+                m_pSdrImport->appendGroupProperty(rGroupProperty.first, rGroupProperty.second);
             aState.aShape.aGroupProperties.clear();
         }
         break;
diff --git a/writerfilter/source/rtftok/rtfreferenceproperties.cxx b/writerfilter/source/rtftok/rtfreferenceproperties.cxx
index 969c1db..7e33484 100644
--- a/writerfilter/source/rtftok/rtfreferenceproperties.cxx
+++ b/writerfilter/source/rtftok/rtfreferenceproperties.cxx
@@ -30,11 +30,11 @@ RTFReferenceProperties::~RTFReferenceProperties() = default;
 
 void RTFReferenceProperties::resolve(Properties& rHandler)
 {
-    for (RTFSprms::Iterator_t i = m_aAttributes.begin(); i != m_aAttributes.end(); ++i)
-        rHandler.attribute(i->first, *i->second.get());
-    for (RTFSprms::Iterator_t i = m_aSprms.begin(); i != m_aSprms.end(); ++i)
+    for (auto& rAttribute : m_aAttributes)
+        rHandler.attribute(rAttribute.first, *rAttribute.second.get());
+    for (auto& rSprm : m_aSprms)
     {
-        RTFSprm aSprm(i->first, i->second);
+        RTFSprm aSprm(rSprm.first, rSprm.second);
         rHandler.sprm(aSprm);
     }
 }
diff --git a/writerfilter/source/rtftok/rtfreferencetable.cxx b/writerfilter/source/rtftok/rtfreferencetable.cxx
index 4177b8d..769321e 100644
--- a/writerfilter/source/rtftok/rtfreferencetable.cxx
+++ b/writerfilter/source/rtftok/rtfreferencetable.cxx
@@ -23,8 +23,8 @@ RTFReferenceTable::~RTFReferenceTable() = default;
 
 void RTFReferenceTable::resolve(Table& rHandler)
 {
-    for (Entries_t::const_iterator i = m_aEntries.begin(); i != m_aEntries.end(); ++i)
-        rHandler.entry(i->first, i->second);
+    for (auto& rEntry : m_aEntries)
+        rHandler.entry(rEntry.first, rEntry.second);
 }
 
 } // namespace rtftok
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index 3984fd6..7062c48 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -353,33 +353,32 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
     bool bCustom(false);
     int const nType = initShape(xShape, xPropertySet, bCustom, rShape, bClose, shapeOrPict);
 
-    for (std::vector< std::pair<OUString, OUString> >::iterator i = rShape.aProperties.begin();
-            i != rShape.aProperties.end(); ++i)
+    for (auto& rProperty : rShape.aProperties)
     {
-        if (i->first == "shapeType")
+        if (rProperty.first == "shapeType")
         {
             continue; // ignore: already handled by initShape
         }
-        else if (i->first == "wzName")
+        else if (rProperty.first == "wzName")
         {
             if (m_bTextFrame)
             {
                 uno::Reference<container::XNamed> xNamed(xShape, uno::UNO_QUERY);
-                xNamed->setName(i->second);
+                xNamed->setName(rProperty.second);
             }
             else
-                xPropertySet->setPropertyValue("Name", uno::makeAny(i->second));
+                xPropertySet->setPropertyValue("Name", uno::makeAny(rProperty.second));
         }
-        else if (i->first == "wzDescription")
-            xPropertySet->setPropertyValue("Description", uno::makeAny(i->second));
-        else if (i->first == "pib")
+        else if (rProperty.first == "wzDescription")
+            xPropertySet->setPropertyValue("Description", uno::makeAny(rProperty.second));
+        else if (rProperty.first == "pib")
         {
-            m_rImport.setDestinationText(i->second);
+            m_rImport.setDestinationText(rProperty.second);
             bPib = true;
         }
-        else if (i->first == "fillColor" && xPropertySet.is())
+        else if (rProperty.first == "fillColor" && xPropertySet.is())
         {
-            aAny <<= msfilter::util::BGRToRGB(i->second.toUInt32());
+            aAny <<= msfilter::util::BGRToRGB(rProperty.second.toUInt32());
             if (m_bTextFrame)
                 xPropertySet->setPropertyValue("BackColor", aAny);
             else
@@ -388,28 +387,28 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
             // fillType will decide, possible it'll be the start color of a gradient.
             aFillModel.moColor.set("#" + OUString::fromUtf8(msfilter::util::ConvertColor(aAny.get<sal_Int32>())));
         }
-        else if (i->first == "fillBackColor")
+        else if (rProperty.first == "fillBackColor")
             // fillType will decide, possible it'll be the end color of a gradient.
-            aFillModel.moColor2.set("#" + OUString::fromUtf8(msfilter::util::ConvertColor(msfilter::util::BGRToRGB(i->second.toInt32()))));
-        else if (i->first == "lineColor")
-            aLineColor <<= msfilter::util::BGRToRGB(i->second.toInt32());
-        else if (i->first == "lineBackColor")
+            aFillModel.moColor2.set("#" + OUString::fromUtf8(msfilter::util::ConvertColor(msfilter::util::BGRToRGB(rProperty.second.toInt32()))));
+        else if (rProperty.first == "lineColor")
+            aLineColor <<= msfilter::util::BGRToRGB(rProperty.second.toInt32());
+        else if (rProperty.first == "lineBackColor")
             ; // Ignore: complementer of lineColor
-        else if (i->first == "txflTextFlow" && xPropertySet.is())
+        else if (rProperty.first == "txflTextFlow" && xPropertySet.is())
         {
-            if (i->second.toInt32() == 1)
+            if (rProperty.second.toInt32() == 1)
                 eWritingMode = text::WritingMode_TB_RL;
         }
-        else if (i->first == "fLine" && xPropertySet.is())
-            resolveFLine(xPropertySet, i->second.toInt32());
-        else if (i->first == "fillOpacity" && xPropertySet.is())
+        else if (rProperty.first == "fLine" && xPropertySet.is())
+            resolveFLine(xPropertySet, rProperty.second.toInt32());
+        else if (rProperty.first == "fillOpacity" && xPropertySet.is())
         {
-            int opacity = 100 - (i->second.toInt32())*100/65536;
+            int opacity = 100 - (rProperty.second.toInt32())*100/65536;
             xPropertySet->setPropertyValue("FillTransparence", uno::Any(sal_uInt32(opacity)));
         }
-        else if (i->first == "lineWidth")
-            aLineWidth <<= i->second.toInt32()/360;
-        else if (i->first == "pVerticies")
+        else if (rProperty.first == "lineWidth")
+            aLineWidth <<= rProperty.second.toInt32()/360;
+        else if (rProperty.first == "pVerticies")
         {
             std::vector<drawing::EnhancedCustomShapeParameterPair> aCoordinates;
             sal_Int32 nSize = 0; // Size of a token (its value is hardwired in the exporter)
@@ -417,7 +416,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
             sal_Int32 nCharIndex = 0; // Character index
             do
             {
-                OUString aToken = i->second.getToken(0, ';', nCharIndex);
+                OUString aToken = rProperty.second.getToken(0, ';', nCharIndex);
                 if (!nSize)
                     nSize = aToken.toInt32();
                 else if (!nCount)
@@ -449,7 +448,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
             aPropertyValue.Value <<= comphelper::containerToSequence(aCoordinates);
             aPath.push_back(aPropertyValue);
         }
-        else if (i->first == "pSegmentInfo")
+        else if (rProperty.first == "pSegmentInfo")
         {
             std::vector<drawing::EnhancedCustomShapeSegment> aSegments;
             sal_Int32 nSize = 0;
@@ -457,7 +456,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
             sal_Int32 nCharIndex = 0;
             do
             {
-                sal_Int32 nSeg = i->second.getToken(0, ';', nCharIndex).toInt32();
+                sal_Int32 nSeg = rProperty.second.getToken(0, ';', nCharIndex).toInt32();
                 if (!nSize)
                     nSize = nSeg;
                 else if (!nCount)
@@ -517,98 +516,98 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
             aPropertyValue.Value <<= comphelper::containerToSequence(aSegments);
             aPath.push_back(aPropertyValue);
         }
-        else if (i->first == "geoLeft")
-            aViewBox.X = i->second.toInt32();
-        else if (i->first == "geoTop")
-            aViewBox.Y = i->second.toInt32();
-        else if (i->first == "geoRight")
-            aViewBox.Width = i->second.toInt32();
-        else if (i->first == "geoBottom")
-            aViewBox.Height = i->second.toInt32();
-        else if (i->first == "dhgt")
+        else if (rProperty.first == "geoLeft")
+            aViewBox.X = rProperty.second.toInt32();
+        else if (rProperty.first == "geoTop")
+            aViewBox.Y = rProperty.second.toInt32();
+        else if (rProperty.first == "geoRight")
+            aViewBox.Width = rProperty.second.toInt32();
+        else if (rProperty.first == "geoBottom")
+            aViewBox.Height = rProperty.second.toInt32();
+        else if (rProperty.first == "dhgt")
         {
             // dhgt is Word 2007, \shpz is Word 97-2003, the later has priority.
             if (!rShape.oZ)
-                resolveDhgt(xPropertySet, i->second.toInt32(), /*bOldStyle=*/false);
+                resolveDhgt(xPropertySet, rProperty.second.toInt32(), /*bOldStyle=*/false);
         }
         // These are in EMU, convert to mm100.
-        else if (i->first == "dxTextLeft")
+        else if (rProperty.first == "dxTextLeft")
         {
             if (xPropertySet.is())
-                xPropertySet->setPropertyValue("LeftBorderDistance", uno::makeAny(i->second.toInt32() / 360));
+                xPropertySet->setPropertyValue("LeftBorderDistance", uno::makeAny(rProperty.second.toInt32() / 360));
         }
-        else if (i->first == "dyTextTop")
+        else if (rProperty.first == "dyTextTop")
         {
             if (xPropertySet.is())
-                xPropertySet->setPropertyValue("TopBorderDistance", uno::makeAny(i->second.toInt32() / 360));
+                xPropertySet->setPropertyValue("TopBorderDistance", uno::makeAny(rProperty.second.toInt32() / 360));
         }
-        else if (i->first == "dxTextRight")
+        else if (rProperty.first == "dxTextRight")
         {
             if (xPropertySet.is())
-                xPropertySet->setPropertyValue("RightBorderDistance", uno::makeAny(i->second.toInt32() / 360));
+                xPropertySet->setPropertyValue("RightBorderDistance", uno::makeAny(rProperty.second.toInt32() / 360));
         }
-        else if (i->first == "dyTextBottom")
+        else if (rProperty.first == "dyTextBottom")
         {
             if (xPropertySet.is())
-                xPropertySet->setPropertyValue("BottomBorderDistance", uno::makeAny(i->second.toInt32() / 360));
+                xPropertySet->setPropertyValue("BottomBorderDistance", uno::makeAny(rProperty.second.toInt32() / 360));
         }
-        else if (i->first == "dxWrapDistLeft")
+        else if (rProperty.first == "dxWrapDistLeft")
         {
             if (m_bTextGraphicObject)
-                rShape.aAnchorAttributes.set(NS_ooxml::LN_CT_Anchor_distL, std::make_shared<RTFValue>(i->second.toInt32()));
+                rShape.aAnchorAttributes.set(NS_ooxml::LN_CT_Anchor_distL, std::make_shared<RTFValue>(rProperty.second.toInt32()));
             else if (xPropertySet.is())
-                xPropertySet->setPropertyValue("LeftMargin", uno::makeAny(i->second.toInt32() / 360));
+                xPropertySet->setPropertyValue("LeftMargin", uno::makeAny(rProperty.second.toInt32() / 360));
         }
-        else if (i->first == "dyWrapDistTop")
+        else if (rProperty.first == "dyWrapDistTop")
         {
             if (m_bTextGraphicObject)
-                rShape.aAnchorAttributes.set(NS_ooxml::LN_CT_Anchor_distT, std::make_shared<RTFValue>(i->second.toInt32()));
+                rShape.aAnchorAttributes.set(NS_ooxml::LN_CT_Anchor_distT, std::make_shared<RTFValue>(rProperty.second.toInt32()));
             else if (xPropertySet.is())
-                xPropertySet->setPropertyValue("TopMargin", uno::makeAny(i->second.toInt32() / 360));
+                xPropertySet->setPropertyValue("TopMargin", uno::makeAny(rProperty.second.toInt32() / 360));
         }
-        else if (i->first == "dxWrapDistRight")
+        else if (rProperty.first == "dxWrapDistRight")
         {
             if (m_bTextGraphicObject)
-                rShape.aAnchorAttributes.set(NS_ooxml::LN_CT_Anchor_distR, std::make_shared<RTFValue>(i->second.toInt32()));
+                rShape.aAnchorAttributes.set(NS_ooxml::LN_CT_Anchor_distR, std::make_shared<RTFValue>(rProperty.second.toInt32()));
             else if (xPropertySet.is())
-                xPropertySet->setPropertyValue("RightMargin", uno::makeAny(i->second.toInt32() / 360));
+                xPropertySet->setPropertyValue("RightMargin", uno::makeAny(rProperty.second.toInt32() / 360));
         }
-        else if (i->first == "dyWrapDistBottom")
+        else if (rProperty.first == "dyWrapDistBottom")
         {
             if (m_bTextGraphicObject)
-                rShape.aAnchorAttributes.set(NS_ooxml::LN_CT_Anchor_distB, std::make_shared<RTFValue>(i->second.toInt32()));
+                rShape.aAnchorAttributes.set(NS_ooxml::LN_CT_Anchor_distB, std::make_shared<RTFValue>(rProperty.second.toInt32()));
             else if (xPropertySet.is())
-                xPropertySet->setPropertyValue("BottomMargin", uno::makeAny(i->second.toInt32() / 360));
+                xPropertySet->setPropertyValue("BottomMargin", uno::makeAny(rProperty.second.toInt32() / 360));
         }
-        else if (i->first == "fillType")
+        else if (rProperty.first == "fillType")
         {
-            switch (i->second.toInt32())
+            switch (rProperty.second.toInt32())
             {
             case 7: // Shade using the fillAngle
                 aFillModel.moType.set(oox::XML_gradient);
                 break;
             default:
-                SAL_INFO("writerfilter", "TODO handle fillType value '" << i->second << "'");
+                SAL_INFO("writerfilter", "TODO handle fillType value '" << rProperty.second << "'");
                 break;
             }
         }
-        else if (i->first == "fillFocus")
-            aFillModel.moFocus.set(i->second.toDouble() / 100); // percent
-        else if (i->first == "fShadow" && xPropertySet.is())
+        else if (rProperty.first == "fillFocus")
+            aFillModel.moFocus.set(rProperty.second.toDouble() / 100); // percent
+        else if (rProperty.first == "fShadow" && xPropertySet.is())
         {
-            if (i->second.toInt32() == 1)
+            if (rProperty.second.toInt32() == 1)
                 aShadowModel.mbHasShadow = true;
         }
-        else if (i->first == "shadowColor")
-            aShadowModel.moColor.set("#" + OUString::fromUtf8(msfilter::util::ConvertColor(msfilter::util::BGRToRGB(i->second.toInt32()))));
-        else if (i->first == "shadowOffsetX")
+        else if (rProperty.first == "shadowColor")
+            aShadowModel.moColor.set("#" + OUString::fromUtf8(msfilter::util::ConvertColor(msfilter::util::BGRToRGB(rProperty.second.toInt32()))));
+        else if (rProperty.first == "shadowOffsetX")
             // EMUs to points
-            aShadowModel.moOffset.set(OUString::number(i->second.toDouble() / 12700) + "pt");
-        else if (i->first == "posh" || i->first == "posv" || i->first == "fFitShapeToText" || i->first == "fFilled" || i->first == "rotation")
-            applyProperty(xShape, i->first, i->second);
-        else if (i->first == "posrelh")
+            aShadowModel.moOffset.set(OUString::number(rProperty.second.toDouble() / 12700) + "pt");
+        else if (rProperty.first == "posh" || rProperty.first == "posv" || rProperty.first == "fFitShapeToText" || rProperty.first == "fFilled" || rProperty.first == "rotation")
+            applyProperty(xShape, rProperty.first, rProperty.second);
+        else if (rProperty.first == "posrelh")
         {
-            switch (i->second.toInt32())
+            switch (rProperty.second.toInt32())
             {
             case 1:
                 rShape.nHoriOrientRelation = text::RelOrientation::PAGE_FRAME;
@@ -617,9 +616,9 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
                 break;
             }
         }
-        else if (i->first == "posrelv")
+        else if (rProperty.first == "posrelv")
         {
-            switch (i->second.toInt32())
+            switch (rProperty.second.toInt32())
             {
             case 1:
                 rShape.nVertOrientRelation = text::RelOrientation::PAGE_FRAME;
@@ -628,36 +627,36 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
                 break;
             }
         }
-        else if (i->first == "groupLeft")
-            oGroupLeft.reset(convertTwipToMm100(i->second.toInt32()));
-        else if (i->first == "groupTop")
-            oGroupTop.reset(convertTwipToMm100(i->second.toInt32()));
-        else if (i->first == "groupRight")
-            oGroupRight.reset(convertTwipToMm100(i->second.toInt32()));
-        else if (i->first == "groupBottom")
-            oGroupBottom.reset(convertTwipToMm100(i->second.toInt32()));
-        else if (i->first == "relLeft")
-            oRelLeft.reset(convertTwipToMm100(i->second.toInt32()));
-        else if (i->first == "relTop")
-            oRelTop.reset(convertTwipToMm100(i->second.toInt32()));
-        else if (i->first == "relRight")
-            oRelRight.reset(convertTwipToMm100(i->second.toInt32()));
-        else if (i->first == "relBottom")
-            oRelBottom.reset(convertTwipToMm100(i->second.toInt32()));
-        else if (i->first == "fBehindDocument")
-            bOpaque = !i->second.toInt32();
-        else if (i->first == "pctHoriz" || i->first == "pctVert")
-        {
-            sal_Int16 nPercentage = rtl::math::round(i->second.toDouble() / 10);
-            boost::optional<sal_Int16>& rPercentage = i->first == "pctHoriz" ? oRelativeWidth : oRelativeHeight;
+        else if (rProperty.first == "groupLeft")
+            oGroupLeft.reset(convertTwipToMm100(rProperty.second.toInt32()));
+        else if (rProperty.first == "groupTop")
+            oGroupTop.reset(convertTwipToMm100(rProperty.second.toInt32()));
+        else if (rProperty.first == "groupRight")
+            oGroupRight.reset(convertTwipToMm100(rProperty.second.toInt32()));
+        else if (rProperty.first == "groupBottom")
+            oGroupBottom.reset(convertTwipToMm100(rProperty.second.toInt32()));
+        else if (rProperty.first == "relLeft")
+            oRelLeft.reset(convertTwipToMm100(rProperty.second.toInt32()));
+        else if (rProperty.first == "relTop")
+            oRelTop.reset(convertTwipToMm100(rProperty.second.toInt32()));
+        else if (rProperty.first == "relRight")
+            oRelRight.reset(convertTwipToMm100(rProperty.second.toInt32()));
+        else if (rProperty.first == "relBottom")
+            oRelBottom.reset(convertTwipToMm100(rProperty.second.toInt32()));
+        else if (rProperty.first == "fBehindDocument")
+            bOpaque = !rProperty.second.toInt32();
+        else if (rProperty.first == "pctHoriz" || rProperty.first == "pctVert")
+        {
+            sal_Int16 nPercentage = rtl::math::round(rProperty.second.toDouble() / 10);
+            boost::optional<sal_Int16>& rPercentage = rProperty.first == "pctHoriz" ? oRelativeWidth : oRelativeHeight;
             if (nPercentage)
                 rPercentage = nPercentage;
         }
-        else if (i->first == "sizerelh")
+        else if (rProperty.first == "sizerelh")
         {
             if (xPropertySet.is())
             {
-                switch (i->second.toInt32())
+                switch (rProperty.second.toInt32())
                 {
                 case 0: // margin
                     nRelativeWidthRelation = text::RelOrientation::FRAME;
@@ -666,16 +665,16 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
                     nRelativeWidthRelation = text::RelOrientation::PAGE_FRAME;
                     break;
                 default:
-                    SAL_WARN("writerfilter", "RTFSdrImport::resolve: unhandled sizerelh value: " << i->second);
+                    SAL_WARN("writerfilter", "RTFSdrImport::resolve: unhandled sizerelh value: " << rProperty.second);
                     break;
                 }
             }
         }
-        else if (i->first == "sizerelv")
+        else if (rProperty.first == "sizerelv")
         {
             if (xPropertySet.is())
             {
-                switch (i->second.toInt32())
+                switch (rProperty.second.toInt32())
                 {
                 case 0: // margin
                     nRelativeHeightRelation = text::RelOrientation::FRAME;
@@ -684,12 +683,12 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
                     nRelativeHeightRelation = text::RelOrientation::PAGE_FRAME;
                     break;
                 default:
-                    SAL_WARN("writerfilter", "RTFSdrImport::resolve: unhandled sizerelv value: " << i->second);
+                    SAL_WARN("writerfilter", "RTFSdrImport::resolve: unhandled sizerelv value: " << rProperty.second);
                     break;
                 }
             }
         }
-        else if (i->first == "fHorizRule") // TODO: what does "fStandardHR" do?
+        else if (rProperty.first == "fHorizRule") // TODO: what does "fStandardHR" do?
         {
             // horizontal rule: relative width defaults to 100% of paragraph
             // TODO: does it have a default height?
@@ -704,28 +703,28 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
                 xPropertySet->setPropertyValue("VertOrient", uno::makeAny(nVertOrient));
             }
         }
-        else if (i->first == "pctHR")
+        else if (rProperty.first == "pctHR")
         {
             // horizontal rule relative width in permille
-            oRelativeWidth = i->second.toInt32() / 10;
+            oRelativeWidth = rProperty.second.toInt32() / 10;
         }
-        else if (i->first == "dxHeightHR")
+        else if (rProperty.first == "dxHeightHR")
         {
             // horizontal rule height
-            sal_uInt32 const nHeight(convertTwipToMm100(i->second.toInt32()));
+            sal_uInt32 const nHeight(convertTwipToMm100(rProperty.second.toInt32()));
             rShape.nBottom = rShape.nTop + nHeight;
         }
-        else if (i->first == "dxWidthHR")
+        else if (rProperty.first == "dxWidthHR")
         {
             // horizontal rule width
-            sal_uInt32 const nWidth(convertTwipToMm100(i->second.toInt32()));
+            sal_uInt32 const nWidth(convertTwipToMm100(rProperty.second.toInt32()));
             rShape.nRight = rShape.nLeft + nWidth;
         }
-        else if (i->first == "alignHR")
+        else if (rProperty.first == "alignHR")
         {
             // horizontal orientation *for horizontal rule*
             sal_Int16 nHoriOrient = text::HoriOrientation::NONE;
-            switch (i->second.toInt32())
+            switch (rProperty.second.toInt32())
             {
             case 0:
                 nHoriOrient = text::HoriOrientation::LEFT;
@@ -742,7 +741,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
                 xPropertySet->setPropertyValue("HoriOrient", uno::makeAny(nHoriOrient));
             }
         }
-        else if (i->first == "pWrapPolygonVertices")
+        else if (rProperty.first == "pWrapPolygonVertices")
         {
             RTFSprms aPolygonSprms;
             sal_Int32 nSize = 0; // Size of a token
@@ -750,7 +749,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
             sal_Int32 nCharIndex = 0; // Character index
             do
             {
-                OUString aToken = i->second.getToken(0, ';', nCharIndex);
+                OUString aToken = rProperty.second.getToken(0, ';', nCharIndex);
                 if (!nSize)
                     nSize = aToken.toInt32();
                 else if (!nCount)
@@ -780,10 +779,10 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
             while (nCharIndex >= 0);
             rShape.aWrapPolygonSprms = aPolygonSprms;
         }
-        else if (i->first == "fRelFlipV")
-            obRelFlipV = i->second.toInt32() == 1;
+        else if (rProperty.first == "fRelFlipV")
+            obRelFlipV = rProperty.second.toInt32() == 1;
         else
-            SAL_INFO("writerfilter", "TODO handle shape property '" << i->first << "':'" << i->second << "'");
+            SAL_INFO("writerfilter", "TODO handle shape property '" << rProperty.first << "':'" << rProperty.second << "'");
     }
 
     if (xPropertySet.is())
diff --git a/writerfilter/source/rtftok/rtfsprm.cxx b/writerfilter/source/rtftok/rtfsprm.cxx
index dc8f256..2877dbf 100644
--- a/writerfilter/source/rtftok/rtfsprm.cxx
+++ b/writerfilter/source/rtftok/rtfsprm.cxx
@@ -74,13 +74,13 @@ RTFValue::Pointer_t RTFSprms::find(Id nKeyword, bool bFirst, bool bForWrite)
     if (bForWrite)
         ensureCopyBeforeWrite();
 
-    for (RTFSprms::Iterator_t i = m_pSprms->begin(); i != m_pSprms->end(); ++i)
-        if (i->first == nKeyword)
+    for (auto& rSprm : *m_pSprms)
+        if (rSprm.first == nKeyword)
         {
             if (bFirst)
-                return i->second;
+                return rSprm.second;
             else
-                pValue = i->second;
+                pValue = rSprm.second;
         }
     return pValue;
 }
@@ -91,12 +91,12 @@ void RTFSprms::set(Id nKeyword, RTFValue::Pointer_t pValue, RTFOverwrite eOverwr
     bool bFound = false;
     if (eOverwrite == RTFOverwrite::YES || eOverwrite == RTFOverwrite::NO_IGNORE)
     {
-        for (RTFSprms::Iterator_t i = m_pSprms->begin(); i != m_pSprms->end(); ++i)
-            if (i->first == nKeyword)
+        for (auto& rSprm : *m_pSprms)
+            if (rSprm.first == nKeyword)
             {
                 if (eOverwrite == RTFOverwrite::YES)
                 {
-                    i->second = pValue;
+                    rSprm.second = pValue;
                     return;
                 }
                 else
@@ -113,7 +113,7 @@ void RTFSprms::set(Id nKeyword, RTFValue::Pointer_t pValue, RTFOverwrite eOverwr
 bool RTFSprms::erase(Id nKeyword)
 {
     ensureCopyBeforeWrite();
-    for (RTFSprms::Iterator_t i = m_pSprms->begin(); i != m_pSprms->end(); ++i)
+    for (auto i = m_pSprms->begin(); i != m_pSprms->end(); ++i)
     {
         if (i->first == nKeyword)
         {
@@ -127,7 +127,7 @@ bool RTFSprms::erase(Id nKeyword)
 void RTFSprms::eraseLast(Id nKeyword)
 {
     ensureCopyBeforeWrite();
-    for (RTFSprms::ReverseIterator_t i = m_pSprms->rbegin(); i != m_pSprms->rend(); ++i)
+    for (auto i = m_pSprms->rbegin(); i != m_pSprms->rend(); ++i)
     {
         if (i->first == nKeyword)
         {
@@ -158,42 +158,37 @@ RTFSprms RTFSprms::cloneAndDeduplicate(RTFSprms& rReference) const
 
     // Note: apparently some attributes are set with OVERWRITE_NO_APPEND;
     // it is probably a bad idea to mess with those in any way here?
-    for (RTFSprms::Iterator_t i = rReference.begin(); i != rReference.end(); ++i)
+    for (auto& rSprm : rReference)
     {
-        RTFValue::Pointer_t const pValue(ret.find(i->first));
+        RTFValue::Pointer_t const pValue(ret.find(rSprm.first));
         if (pValue)
         {
-            if (i->second->equals(*pValue))
+            if (rSprm.second->equals(*pValue))
             {
-                ret.erase(i->first); // duplicate to style
+                ret.erase(rSprm.first); // duplicate to style
             }
-            else if (!i->second->getSprms().empty() || !i->second->getAttributes().empty())
+            else if (!rSprm.second->getSprms().empty() || !rSprm.second->getAttributes().empty())
             {
-                RTFSprms const sprms(
-                    pValue->getSprms().cloneAndDeduplicate(i->second->getSprms()));
-                RTFSprms const attributes(
-                    pValue->getAttributes().cloneAndDeduplicate(i->second->getAttributes()));
-                ret.set(i->first, RTFValue::Pointer_t(
-                            pValue->CloneWithSprms(attributes, sprms)));
+                RTFSprms const sprms(pValue->getSprms().cloneAndDeduplicate(rSprm.second->getSprms()));
+                RTFSprms const attributes(pValue->getAttributes().cloneAndDeduplicate(rSprm.second->getAttributes()));
+                ret.set(rSprm.first, RTFValue::Pointer_t(pValue->CloneWithSprms(attributes, sprms)));
             }
         }
         else
         {
             // not found - try to override style with default
-            RTFValue::Pointer_t const pDefault(getDefaultSPRM(i->first));
+            RTFValue::Pointer_t const pDefault(getDefaultSPRM(rSprm.first));
             if (pDefault)
             {
-                ret.set(i->first, pDefault);
+                ret.set(rSprm.first, pDefault);
             }
-            else if (!i->second->getSprms().empty() || !i->second->getAttributes().empty())
+            else if (!rSprm.second->getSprms().empty() || !rSprm.second->getAttributes().empty())
             {
-                RTFSprms const sprms(
-                    RTFSprms().cloneAndDeduplicate(i->second->getSprms()));
-                RTFSprms const attributes(
-                    RTFSprms().cloneAndDeduplicate(i->second->getAttributes()));
+                RTFSprms const sprms(RTFSprms().cloneAndDeduplicate(rSprm.second->getSprms()));
+                RTFSprms const attributes(RTFSprms().cloneAndDeduplicate(rSprm.second->getAttributes()));
                 if (!sprms.empty() || !attributes.empty())
                 {
-                    ret.set(i->first, std::make_shared<RTFValue>(attributes, sprms));
+                    ret.set(rSprm.first, std::make_shared<RTFValue>(attributes, sprms));
                 }
             }
         }
@@ -203,9 +198,8 @@ RTFSprms RTFSprms::cloneAndDeduplicate(RTFSprms& rReference) const
 
 bool RTFSprms::equals(RTFValue& rOther)
 {
-    RTFSprms::Iterator_t i = m_pSprms->begin();
-    while (i != m_pSprms->end())
-        if (!i->second->equals(rOther))
+    for (auto& rSprm : *m_pSprms)
+        if (!rSprm.second->equals(rOther))
             return false;
     return true;
 }
@@ -215,8 +209,8 @@ void RTFSprms::ensureCopyBeforeWrite()
     if (m_pSprms->m_nRefCount > 1)
     {
         boost::intrusive_ptr<RTFSprmsImpl> pClone(new RTFSprmsImpl());
-        for (std::vector< std::pair<Id, RTFValue::Pointer_t> >::const_iterator i = m_pSprms->begin(); i != m_pSprms->end(); ++i)
-            pClone->push_back(std::make_pair(i->first, RTFValue::Pointer_t(i->second->Clone())));
+        for (auto& rSprm : *m_pSprms)
+            pClone->push_back(std::make_pair(rSprm.first, RTFValue::Pointer_t(rSprm.second->Clone())));
         m_pSprms = pClone;
     }
 }
diff --git a/writerfilter/source/rtftok/rtftokenizer.cxx b/writerfilter/source/rtftok/rtftokenizer.cxx
index cdcdb11..2dab789 100644
--- a/writerfilter/source/rtftok/rtftokenizer.cxx
+++ b/writerfilter/source/rtftok/rtftokenizer.cxx
@@ -268,7 +268,7 @@ RTFError RTFTokenizer::resolveKeyword()
 
 bool RTFTokenizer::lookupMathKeyword(RTFMathSymbol& rSymbol)
 {
-    std::vector<RTFMathSymbol>::iterator low = std::lower_bound(s_aRTFMathControlWords.begin(), s_aRTFMathControlWords.end(), rSymbol);
+    auto low = std::lower_bound(s_aRTFMathControlWords.begin(), s_aRTFMathControlWords.end(), rSymbol);
     int i = low - s_aRTFMathControlWords.begin();
     if (low == s_aRTFMathControlWords.end() || rSymbol < *low)
         return false;
@@ -290,7 +290,7 @@ RTFError RTFTokenizer::dispatchKeyword(OString& rKeyword, bool bParam, int nPara
              "' with param? " << (bParam ? 1 : 0) <<" param val: '" << (bParam ? nParam : 0) << "'");
     RTFSymbol aSymbol;
     aSymbol.sKeyword = rKeyword.getStr();
-    std::vector<RTFSymbol>::iterator low = std::lower_bound(s_aRTFControlWords.begin(), s_aRTFControlWords.end(), aSymbol);
+    auto low = std::lower_bound(s_aRTFControlWords.begin(), s_aRTFControlWords.end(), aSymbol);
     int i = low - s_aRTFControlWords.begin();
     if (low == s_aRTFControlWords.end() || aSymbol < *low)
     {


More information about the Libreoffice-commits mailing list