[Libreoffice-commits] core.git: sfx2/source svl/source sw/source

Miklos Vajna vmiklos at collabora.co.uk
Wed Jun 8 08:14:39 UTC 2016


 sfx2/source/view/classificationhelper.cxx |   24 ++++++++++++------------
 svl/source/items/grabbagitem.cxx          |    6 +++---
 sw/source/core/doc/textboxhelper.cxx      |   21 +++++++++------------
 3 files changed, 24 insertions(+), 27 deletions(-)

New commits:
commit 42dae96f97bfcc44d5e6ccf727e1cdb178123d56
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Jun 8 08:50:52 2016 +0200

    sfx2 classification: use auto where it improves code readability
    
    std::map<OUString, basegfx::BColor>::iterator itColor = aColors.find(aLevel);
    
    vs
    
    auto itColor = aColors.find(aLevel);
    
    and so on.
    
    (And do the same at two other places as well.)
    
    Change-Id: I538998c8b8afdf18a7eb139fa4d469205c561370
    Reviewed-on: https://gerrit.libreoffice.org/26046
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/sfx2/source/view/classificationhelper.cxx b/sfx2/source/view/classificationhelper.cxx
index 120470f..f7357a4 100644
--- a/sfx2/source/view/classificationhelper.cxx
+++ b/sfx2/source/view/classificationhelper.cxx
@@ -390,7 +390,7 @@ void SfxClassificationHelper::Impl::setStartValidity(SfxClassificationPolicyType
         return;
 
     SfxClassificationCategory& rCategory = itCategory->second;
-    std::map<OUString, OUString>::iterator it = rCategory.m_aLabels.find(policyTypeToString(eType) + PROP_STARTVALIDITY());
+    auto it = rCategory.m_aLabels.find(policyTypeToString(eType) + PROP_STARTVALIDITY());
     if (it != rCategory.m_aLabels.end())
     {
         if (it->second == PROP_NONE())
@@ -554,7 +554,7 @@ bool SfxClassificationHelper::HasImpactLevel()
         return false;
 
     SfxClassificationCategory& rCategory = itCategory->second;
-    std::map<OUString, OUString>::iterator it = rCategory.m_aLabels.find(PROP_PREFIX_INTELLECTUALPROPERTY() + PROP_IMPACTSCALE());
+    auto it = rCategory.m_aLabels.find(PROP_PREFIX_INTELLECTUALPROPERTY() + PROP_IMPACTSCALE());
     if (it == rCategory.m_aLabels.end())
         return false;
 
@@ -572,7 +572,7 @@ bool SfxClassificationHelper::HasDocumentHeader()
         return false;
 
     SfxClassificationCategory& rCategory = itCategory->second;
-    std::map<OUString, OUString>::iterator it = rCategory.m_aLabels.find(PROP_PREFIX_INTELLECTUALPROPERTY() + PROP_DOCHEADER());
+    auto it = rCategory.m_aLabels.find(PROP_PREFIX_INTELLECTUALPROPERTY() + PROP_DOCHEADER());
     if (it == rCategory.m_aLabels.end() || it->second.isEmpty())
         return false;
 
@@ -586,7 +586,7 @@ bool SfxClassificationHelper::HasDocumentFooter()
         return false;
 
     SfxClassificationCategory& rCategory = itCategory->second;
-    std::map<OUString, OUString>::iterator it = rCategory.m_aLabels.find(PROP_PREFIX_INTELLECTUALPROPERTY() + PROP_DOCFOOTER());
+    auto it = rCategory.m_aLabels.find(PROP_PREFIX_INTELLECTUALPROPERTY() + PROP_DOCFOOTER());
     if (it == rCategory.m_aLabels.end() || it->second.isEmpty())
         return false;
 
@@ -602,7 +602,7 @@ basegfx::BColor SfxClassificationHelper::GetImpactLevelColor()
         return aRet;
 
     SfxClassificationCategory& rCategory = itCategory->second;
-    std::map<OUString, OUString>::iterator it = rCategory.m_aLabels.find(PROP_PREFIX_INTELLECTUALPROPERTY() + PROP_IMPACTSCALE());
+    auto it = rCategory.m_aLabels.find(PROP_PREFIX_INTELLECTUALPROPERTY() + PROP_IMPACTSCALE());
     if (it == rCategory.m_aLabels.end())
         return aRet;
     OUString aScale = it->second;
@@ -624,7 +624,7 @@ basegfx::BColor SfxClassificationHelper::GetImpactLevelColor()
             aColors["2"] = basegfx::BColor(1.0, 0.5, 0.0);
             aColors["3"] = basegfx::BColor(0.5, 0.0, 0.0);
         }
-        std::map<OUString, basegfx::BColor>::iterator itColor = aColors.find(aLevel);
+        auto itColor = aColors.find(aLevel);
         if (itColor == aColors.end())
             return aRet;
         aRet = itColor->second;
@@ -639,7 +639,7 @@ basegfx::BColor SfxClassificationHelper::GetImpactLevelColor()
             aColors["Moderate"] = basegfx::BColor(1.0, 0.5, 0.0);
             aColors["High"] = basegfx::BColor(0.5, 0.0, 0.0);
         }
-        std::map<OUString, basegfx::BColor>::iterator itColor = aColors.find(aLevel);
+        auto itColor = aColors.find(aLevel);
         if (itColor == aColors.end())
             return aRet;
         aRet = itColor->second;
@@ -657,7 +657,7 @@ sal_Int32 SfxClassificationHelper::GetImpactLevel()
         return nRet;
 
     SfxClassificationCategory& rCategory = itCategory->second;
-    std::map<OUString, OUString>::iterator it = rCategory.m_aLabels.find(PROP_PREFIX_INTELLECTUALPROPERTY() + PROP_IMPACTSCALE());
+    auto it = rCategory.m_aLabels.find(PROP_PREFIX_INTELLECTUALPROPERTY() + PROP_IMPACTSCALE());
     if (it == rCategory.m_aLabels.end())
         return nRet;
     OUString aScale = it->second;
@@ -683,7 +683,7 @@ sal_Int32 SfxClassificationHelper::GetImpactLevel()
             aValues["Moderate"] = 1;
             aValues["High"] = 2;
         }
-        std::map<OUString, sal_Int32>::iterator itValues = aValues.find(aLevel);
+        auto itValues = aValues.find(aLevel);
         if (itValues == aValues.end())
             return nRet;
         nRet = itValues->second;
@@ -699,7 +699,7 @@ OUString SfxClassificationHelper::GetImpactScale()
         return OUString();
 
     SfxClassificationCategory& rCategory = itCategory->second;
-    std::map<OUString, OUString>::iterator it = rCategory.m_aLabels.find(PROP_PREFIX_INTELLECTUALPROPERTY() + PROP_IMPACTSCALE());
+    auto it = rCategory.m_aLabels.find(PROP_PREFIX_INTELLECTUALPROPERTY() + PROP_IMPACTSCALE());
     if (it != rCategory.m_aLabels.end())
         return it->second;
 
@@ -713,7 +713,7 @@ OUString SfxClassificationHelper::GetDocumentWatermark()
         return OUString();
 
     SfxClassificationCategory& rCategory = itCategory->second;
-    std::map<OUString, OUString>::iterator it = rCategory.m_aLabels.find(PROP_PREFIX_INTELLECTUALPROPERTY() + PROP_DOCWATERMARK());
+    auto it = rCategory.m_aLabels.find(PROP_PREFIX_INTELLECTUALPROPERTY() + PROP_DOCWATERMARK());
     if (it != rCategory.m_aLabels.end())
         return it->second;
 
@@ -738,7 +738,7 @@ void SfxClassificationHelper::SetBACName(const OUString& rName, SfxClassificatio
     if (m_pImpl->m_aCategories.empty())
         m_pImpl->parsePolicy();
 
-    std::vector<SfxClassificationCategory>::iterator it = std::find_if(m_pImpl->m_aCategories.begin(), m_pImpl->m_aCategories.end(), [&](const SfxClassificationCategory& rCategory)
+    auto it = std::find_if(m_pImpl->m_aCategories.begin(), m_pImpl->m_aCategories.end(), [&](const SfxClassificationCategory& rCategory)
     {
         return rCategory.m_aName == rName;
     });
diff --git a/svl/source/items/grabbagitem.cxx b/svl/source/items/grabbagitem.cxx
index 2ed43f6..c9eb634 100644
--- a/svl/source/items/grabbagitem.cxx
+++ b/svl/source/items/grabbagitem.cxx
@@ -74,10 +74,10 @@ bool SfxGrabBagItem::QueryValue(uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
 {
     uno::Sequence<beans::PropertyValue> aValue(m_aMap.size());
     beans::PropertyValue* pValue = aValue.getArray();
-    for (std::map<OUString, uno::Any>::const_iterator i = m_aMap.begin(); i != m_aMap.end(); ++i)
+    for (const auto& i : m_aMap)
     {
-        pValue[0].Name = i->first;
-        pValue[0].Value = i->second;
+        pValue[0].Name = i.first;
+        pValue[0].Value = i.second;
         ++pValue;
     }
     rVal = uno::makeAny(aValue);
diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx
index 61402fe..0296a18 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -119,10 +119,8 @@ std::set<const SwFrameFormat*> SwTextBoxHelper::findTextBoxes(const SwDoc* pDoc)
     std::map<SwNodeIndex, const SwFrameFormat*> aFlyFormats, aDrawFormats;
 
     const SwFrameFormats& rSpzFrameFormats = *pDoc->GetSpzFrameFormats();
-    for (SwFrameFormats::const_iterator it = rSpzFrameFormats.begin(); it != rSpzFrameFormats.end(); ++it)
+    for (const SwFrameFormat* pFormat : rSpzFrameFormats)
     {
-        const SwFrameFormat* pFormat = *it;
-
         // A TextBox in the context of this class is a fly frame that has a
         // matching (same RES_CNTNT) draw frame.
         if (!pFormat->GetAttrSet().HasItem(RES_CNTNT) || !pFormat->GetContent().GetContentIdx())
@@ -182,11 +180,11 @@ std::map<SwFrameFormat*, SwFrameFormat*> SwTextBoxHelper::findShapes(const SwDoc
     std::map<SwFrameFormat*, SwFrameFormat*> aRet;
 
     const SwFrameFormats& rSpzFrameFormats = *pDoc->GetSpzFrameFormats();
-    for (SwFrameFormats::const_iterator it = rSpzFrameFormats.begin(); it != rSpzFrameFormats.end(); ++it)
+    for (SwFrameFormat* pFormat : rSpzFrameFormats)
     {
-        SwFrameFormat* pTextBox = findTextBox(*it);
+        SwFrameFormat* pTextBox = findTextBox(pFormat);
         if (pTextBox)
-            aRet[pTextBox] = *it;
+            aRet[pTextBox] = pFormat;
     }
 
     return aRet;
@@ -267,7 +265,7 @@ sal_Int32 SwTextBoxHelper::getOrdNum(const SdrObject* pObject, std::set<const Sw
 void SwTextBoxHelper::getShapeWrapThrough(const SwFrameFormat* pTextBox, bool& rWrapThrough)
 {
     std::map<SwFrameFormat*, SwFrameFormat*> aMap = findShapes(pTextBox->GetDoc());
-    std::map<SwFrameFormat*, SwFrameFormat*>::iterator it = aMap.find(const_cast<SwFrameFormat*>(pTextBox));
+    auto it = aMap.find(const_cast<SwFrameFormat*>(pTextBox));
     if (it != aMap.end())
         // pTextBox is indeed a TextBox, it->second is its shape.
         rWrapThrough = it->second->GetSurround().GetSurround() == SURROUND_THROUGHT;
@@ -291,9 +289,8 @@ SwFrameFormat* SwTextBoxHelper::findTextBox(const SwFrameFormat* pShape)
     {
         const SwFormatContent& rContent = pShape->GetContent();
         const SwFrameFormats& rSpzFrameFormats = *pShape->GetDoc()->GetSpzFrameFormats();
-        for (SwFrameFormats::const_iterator it = rSpzFrameFormats.begin(); it != rSpzFrameFormats.end(); ++it)
+        for (SwFrameFormat* pFormat : rSpzFrameFormats)
         {
-            SwFrameFormat* pFormat = *it;
             // Only a fly frame can be a TextBox.
             if (pFormat->Which() == RES_FLYFRMFMT && pFormat->GetAttrSet().HasItem(RES_CNTNT) && pFormat->GetContent() == rContent)
             {
@@ -612,13 +609,13 @@ void SwTextBoxHelper::resetLink(SwFrameFormat* pShape, std::map<const SwFrameFor
 void SwTextBoxHelper::restoreLinks(std::set<ZSortFly>& rOld, std::vector<SwFrameFormat*>& rNew, SavedLink& rSavedLinks, SavedContent& rOldContent)
 {
     std::size_t i = 0;
-    for (std::set<ZSortFly>::iterator aSetIt = rOld.begin(); aSetIt != rOld.end(); ++aSetIt, ++i)
+    for (auto aSetIt = rOld.begin(); aSetIt != rOld.end(); ++aSetIt, ++i)
     {
-        SavedLink::iterator aTextBoxIt = rSavedLinks.find(aSetIt->GetFormat());
+        auto aTextBoxIt = rSavedLinks.find(aSetIt->GetFormat());
         if (aTextBoxIt != rSavedLinks.end())
         {
             std::size_t j = 0;
-            for (std::set<ZSortFly>::iterator aSetJt = rOld.begin(); aSetJt != rOld.end(); ++aSetJt, ++j)
+            for (auto aSetJt = rOld.begin(); aSetJt != rOld.end(); ++aSetJt, ++j)
             {
                 if (aSetJt->GetFormat() == aTextBoxIt->second)
                     rNew[i]->SetFormatAttr(rNew[j]->GetContent());


More information about the Libreoffice-commits mailing list