[Libreoffice-commits] core.git: 5 commits - include/xmloff svtools/inc svtools/source xmloff/inc xmloff/source

Michael Stahl mstahl at redhat.com
Fri Aug 7 08:11:51 PDT 2015


 include/xmloff/xmltkmap.hxx         |    6 -
 svtools/inc/pch/precompiled_svt.hxx |    1 
 svtools/source/contnr/fileview.cxx  |  115 +++++-------------------------------
 xmloff/inc/pch/precompiled_xo.hxx   |    1 
 xmloff/source/core/xmltkmap.cxx     |   26 ++++----
 xmloff/source/style/impastpl.cxx    |  103 ++++++++++++++++----------------
 xmloff/source/style/impastpl.hxx    |   83 +++++++++++++++----------
 xmloff/source/style/xmlnumfi.cxx    |   62 ++++++-------------
 8 files changed, 154 insertions(+), 243 deletions(-)

New commits:
commit febd02b705c06929810835c5e2f677bfc91fb52c
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Aug 7 15:35:01 2015 +0200

    xmloff: replace boost::ptr_set with std::set<std::unique_ptr>
    
    boost::ptr_set was actually quite nice here, pity about the obnoxious
    warnings...
    
    Change-Id: I46973635fd26e4f1db96f2806c211b83436bef5e

diff --git a/xmloff/inc/pch/precompiled_xo.hxx b/xmloff/inc/pch/precompiled_xo.hxx
index 685fa2b..49a133d 100644
--- a/xmloff/inc/pch/precompiled_xo.hxx
+++ b/xmloff/inc/pch/precompiled_xo.hxx
@@ -34,7 +34,6 @@
 #include <boost/bind.hpp>
 #include <boost/iterator_adaptors.hpp>
 #include <boost/noncopyable.hpp>
-#include <boost/ptr_container/ptr_set.hpp>
 #include <boost/ptr_container/ptr_vector.hpp>
 #include <memory>
 #include <boost/scoped_ptr.hpp>
diff --git a/xmloff/source/style/impastpl.cxx b/xmloff/source/style/impastpl.cxx
index c0054f0..7c98e3e 100644
--- a/xmloff/source/style/impastpl.cxx
+++ b/xmloff/source/style/impastpl.cxx
@@ -60,7 +60,7 @@ XMLAutoStyleFamily::~XMLAutoStyleFamily() {}
 
 void XMLAutoStyleFamily::ClearEntries()
 {
-    maParentSet.clear();
+    m_ParentSet.clear();
 }
 
 static OUString
@@ -506,16 +506,17 @@ bool SvXMLAutoStylePoolP_Impl::Add(
 
     XMLAutoStyleFamily &rFamily = **iter;
 
-    XMLAutoStylePoolParent aTmp(rParentName);
-    XMLAutoStyleFamily::ParentSetType::iterator it2 = rFamily.maParentSet.find(aTmp);
-    if (it2 == rFamily.maParentSet.end())
+    std::unique_ptr<XMLAutoStylePoolParent> pTmp(new XMLAutoStylePoolParent(rParentName));
+    auto it2 = rFamily.m_ParentSet.find(pTmp);
+    if (it2 == rFamily.m_ParentSet.end())
     {
         std::pair<XMLAutoStyleFamily::ParentSetType::iterator,bool> r =
-            rFamily.maParentSet.insert(new XMLAutoStylePoolParent(rParentName));
+            rFamily.m_ParentSet.insert(std::unique_ptr<XMLAutoStylePoolParent>(
+                        new XMLAutoStylePoolParent(rParentName)));
         it2 = r.first;
     }
 
-    XMLAutoStylePoolParent& rParent = *it2;
+    XMLAutoStylePoolParent& rParent = **it2;
 
     bool bRet = false;
     if (rParent.Add(rFamily, rProperties, rName, bDontSeek))
@@ -539,16 +540,17 @@ bool SvXMLAutoStylePoolP_Impl::AddNamed(
 
     XMLAutoStyleFamily &rFamily = **iter;
 
-    XMLAutoStylePoolParent aTmp(rParentName);
-    XMLAutoStyleFamily::ParentSetType::iterator it2 = rFamily.maParentSet.find(aTmp);
-    if (it2 == rFamily.maParentSet.end())
+    std::unique_ptr<XMLAutoStylePoolParent> pTmp(new XMLAutoStylePoolParent(rParentName));
+    auto it2 = rFamily.m_ParentSet.find(pTmp);
+    if (it2 == rFamily.m_ParentSet.end())
     {
         std::pair<XMLAutoStyleFamily::ParentSetType::iterator,bool> r =
-            rFamily.maParentSet.insert(new XMLAutoStylePoolParent(rParentName));
+            rFamily.m_ParentSet.insert(std::unique_ptr<XMLAutoStylePoolParent>(
+                        new XMLAutoStylePoolParent(rParentName)));
         it2 = r.first;
     }
 
-    XMLAutoStylePoolParent& rParent = *it2;
+    XMLAutoStylePoolParent& rParent = **it2;
 
     bool bRet = false;
     if (rParent.AddNamed(rFamily, rProperties, rName))
@@ -575,11 +577,11 @@ OUString SvXMLAutoStylePoolP_Impl::Find( sal_Int32 nFamily,
     assert(iter != m_FamilySet.end()); // family must be known
 
     XMLAutoStyleFamily const& rFamily = **iter;
-    XMLAutoStylePoolParent aTmp( rParent );
-    XMLAutoStyleFamily::ParentSetType::const_iterator it2 = rFamily.maParentSet.find(aTmp);
-    if (it2 != rFamily.maParentSet.end())
+    std::unique_ptr<XMLAutoStylePoolParent> pTmp(new XMLAutoStylePoolParent(rParent));
+    auto const it2 = rFamily.m_ParentSet.find(pTmp);
+    if (it2 != rFamily.m_ParentSet.end())
     {
-        sName = it2->Find(rFamily, rProperties);
+        sName = (*it2)->Find(rFamily, rProperties);
     }
 
     return sName;
@@ -628,8 +630,7 @@ void SvXMLAutoStylePoolP_Impl::exportXML(
     // which contains a parent-name and a SvXMLAutoStylePoolProperties_Impl
     std::vector<AutoStylePoolExport> aExpStyles(nCount);
 
-    XMLAutoStyleFamily::ParentSetType::iterator it = rFamily.maParentSet.begin(), itEnd = rFamily.maParentSet.end();
-    for (; it != itEnd; ++it)
+    for (auto const& it : rFamily.m_ParentSet)
     {
         XMLAutoStylePoolParent& rParent = *it;
         size_t nProperties = rParent.GetPropertiesList().size();
diff --git a/xmloff/source/style/impastpl.hxx b/xmloff/source/style/impastpl.hxx
index 5093281..0989389 100644
--- a/xmloff/source/style/impastpl.hxx
+++ b/xmloff/source/style/impastpl.hxx
@@ -20,7 +20,6 @@
 #ifndef INCLUDED_XMLOFF_SOURCE_STYLE_IMPASTPL_HXX
 #define INCLUDED_XMLOFF_SOURCE_STYLE_IMPASTPL_HXX
 
-#include <boost/ptr_container/ptr_set.hpp>
 #include <sal/types.h>
 #include <rtl/ustring.hxx>
 #include <set>
@@ -37,39 +36,10 @@
 
 class SvXMLAutoStylePoolP;
 class XMLAutoStylePoolParent;
+class XMLAutoStyleFamily;
 class SvXMLExportPropertyMapper;
 class SvXMLExport;
 
-// Implementationclass for stylefamily-information
-
-struct XMLAutoStyleFamily : boost::noncopyable
-{
-    typedef boost::ptr_set<XMLAutoStylePoolParent> ParentSetType;
-    typedef std::set<OUString> NameSetType;
-
-    sal_uInt32                   mnFamily;
-    OUString                     maStrFamilyName;
-    rtl::Reference < SvXMLExportPropertyMapper >  mxMapper;
-
-    ParentSetType maParentSet;
-    NameSetType maNameSet;
-    sal_uInt32                          mnCount;
-    sal_uInt32                          mnName;
-    OUString                     maStrPrefix;
-    bool                         mbAsFamily;
-
-    XMLAutoStyleFamily( sal_Int32 nFamily, const OUString& rStrName,
-            const rtl::Reference<SvXMLExportPropertyMapper>& rMapper,
-            const OUString& rStrPrefix, bool bAsFamily = true );
-
-    explicit XMLAutoStyleFamily( sal_Int32 nFamily );
-    ~XMLAutoStyleFamily();
-
-    friend bool operator<(const XMLAutoStyleFamily& r1, const XMLAutoStyleFamily& r2);
-
-    void ClearEntries();
-};
-
 // Properties of a pool
 
 class XMLAutoStylePoolProperties
@@ -128,6 +98,44 @@ public:
     bool operator< (const XMLAutoStylePoolParent& rOther) const;
 };
 
+// Implementationclass for stylefamily-information
+
+struct XMLAutoStyleFamily : boost::noncopyable
+{
+    struct XMLAutoStylePoolParent_Less
+    {
+        bool operator()(std::unique_ptr<XMLAutoStylePoolParent> const& lhs,
+                        std::unique_ptr<XMLAutoStylePoolParent> const& rhs) const
+        {
+            return (*lhs) < (*rhs);
+        }
+    };
+    typedef std::set<std::unique_ptr<XMLAutoStylePoolParent>, XMLAutoStylePoolParent_Less> ParentSetType;
+    typedef std::set<OUString> NameSetType;
+
+    sal_uInt32 mnFamily;
+    OUString maStrFamilyName;
+    rtl::Reference<SvXMLExportPropertyMapper> mxMapper;
+
+    ParentSetType m_ParentSet;
+    NameSetType maNameSet;
+    sal_uInt32 mnCount;
+    sal_uInt32 mnName;
+    OUString maStrPrefix;
+    bool mbAsFamily;
+
+    XMLAutoStyleFamily( sal_Int32 nFamily, const OUString& rStrName,
+            const rtl::Reference<SvXMLExportPropertyMapper>& rMapper,
+            const OUString& rStrPrefix, bool bAsFamily = true );
+
+    explicit XMLAutoStyleFamily( sal_Int32 nFamily );
+    ~XMLAutoStyleFamily();
+
+    friend bool operator<(const XMLAutoStyleFamily& r1, const XMLAutoStyleFamily& r2);
+
+    void ClearEntries();
+};
+
 // Implementationclass of SvXMLAutoStylePool
 
 class SvXMLAutoStylePoolP_Impl
commit 18c502b0049a5330f870ad43e1c49b46cbae81fc
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Aug 7 15:19:39 2015 +0200

    xmloff: replace boost::ptr_set with std::set<std::unqiue_ptr>
    
    Change-Id: Iaacebe5d88ad8b124f0891f5a7763b9868a6022a

diff --git a/xmloff/source/style/impastpl.cxx b/xmloff/source/style/impastpl.cxx
index 0bc2d51..c0054f0 100644
--- a/xmloff/source/style/impastpl.cxx
+++ b/xmloff/source/style/impastpl.cxx
@@ -419,43 +419,43 @@ void SvXMLAutoStylePoolP_Impl::AddFamily(
     }
 
 #if OSL_DEBUG_LEVEL > 0
-    XMLAutoStyleFamily aTemporary( nFamily );
-    FamilySetType::iterator aFind = maFamilySet.find(aTemporary);
-    if( aFind != maFamilySet.end() )
+    std::unique_ptr<XMLAutoStyleFamily> pTemp(new XMLAutoStyleFamily(nFamily));
+    auto const iter = m_FamilySet.find(pTemp);
+    if (iter != m_FamilySet.end())
     {
         // FIXME: do we really intend to replace the previous nFamily
         // entry in this case ?
-        SAL_WARN_IF( aFind->mxMapper != rMapper, "xmloff",
+        SAL_WARN_IF( (*iter)->mxMapper != rMapper, "xmloff",
                      "Adding duplicate family " << rStrName <<
                      " with mismatching mapper ! " <<
-                     typeid(*aFind->mxMapper.get()).name() << " " <<
+                     typeid((*iter)->mxMapper.get()).name() << " " <<
                      typeid(*rMapper.get()).name() );
     }
 #endif
 
-    XMLAutoStyleFamily *pFamily = new XMLAutoStyleFamily( nFamily, rStrName, rMapper, aPrefix, bAsFamily );
-    maFamilySet.insert(pFamily);
+    std::unique_ptr<XMLAutoStyleFamily> pFamily(
+        new XMLAutoStyleFamily(nFamily, rStrName, rMapper, aPrefix, bAsFamily));
+    m_FamilySet.insert(std::move(pFamily));
 }
 
 void SvXMLAutoStylePoolP_Impl::SetFamilyPropSetMapper(
         sal_Int32 nFamily,
         const rtl::Reference < SvXMLExportPropertyMapper > & rMapper )
 {
-
-    XMLAutoStyleFamily aTemporary( nFamily );
-    FamilySetType::iterator aFind = maFamilySet.find(aTemporary);
-    if (aFind != maFamilySet.end())
-        aFind->mxMapper = rMapper;
+    std::unique_ptr<XMLAutoStyleFamily> pTemp(new XMLAutoStyleFamily(nFamily));
+    auto const iter = m_FamilySet.find(pTemp);
+    if (iter != m_FamilySet.end())
+        (*iter)->mxMapper = rMapper;
 }
 
 // Adds a name to list
 void SvXMLAutoStylePoolP_Impl::RegisterName( sal_Int32 nFamily, const OUString& rName )
 {
-    XMLAutoStyleFamily aTmp( nFamily );
-    FamilySetType::iterator aFind = maFamilySet.find(aTmp);
-    assert(aFind != maFamilySet.end()); // family must be known
+    std::unique_ptr<XMLAutoStyleFamily> pTemp(new XMLAutoStyleFamily(nFamily));
+    auto const iter = m_FamilySet.find(pTemp);
+    assert(iter != m_FamilySet.end()); // family must be known
     // SAL_DEBUG("SvXMLAutoStylePoolP_Impl::RegisterName: " << nFamily << ", '" << rName << "'");
-    aFind->maNameSet.insert(rName);
+    (*iter)->maNameSet.insert(rName);
 }
 
 
@@ -471,7 +471,7 @@ void SvXMLAutoStylePoolP_Impl::GetRegisteredNames(
     vector<OUString> aNames;
 
     // iterate over families
-    for (FamilySetType::iterator aJ = maFamilySet.begin(); aJ != maFamilySet.end(); ++aJ)
+    for (auto const& aJ : m_FamilySet)
     {
         XMLAutoStyleFamily &rFamily = *aJ;
 
@@ -500,11 +500,11 @@ bool SvXMLAutoStylePoolP_Impl::Add(
     OUString& rName, sal_Int32 nFamily, const OUString& rParentName,
     const ::std::vector< XMLPropertyState >& rProperties, bool bDontSeek )
 {
-    XMLAutoStyleFamily aTemporary( nFamily );
-    FamilySetType::iterator aFind = maFamilySet.find(aTemporary);
-    assert(aFind != maFamilySet.end()); // family must be known
+    std::unique_ptr<XMLAutoStyleFamily> pTemp(new XMLAutoStyleFamily(nFamily));
+    auto const iter = m_FamilySet.find(pTemp);
+    assert(iter != m_FamilySet.end()); // family must be known
 
-    XMLAutoStyleFamily &rFamily = *aFind;
+    XMLAutoStyleFamily &rFamily = **iter;
 
     XMLAutoStylePoolParent aTmp(rParentName);
     XMLAutoStyleFamily::ParentSetType::iterator it2 = rFamily.maParentSet.find(aTmp);
@@ -533,11 +533,11 @@ bool SvXMLAutoStylePoolP_Impl::AddNamed(
 {
     // get family and parent the same way as in Add()
 
-    XMLAutoStyleFamily aTemporary( nFamily );
-    FamilySetType::iterator aFind = maFamilySet.find(aTemporary);
-    assert(aFind != maFamilySet.end());  // family must be known
+    std::unique_ptr<XMLAutoStyleFamily> pTemp(new XMLAutoStyleFamily(nFamily));
+    auto const iter = m_FamilySet.find(pTemp);
+    assert(iter != m_FamilySet.end());  // family must be known
 
-    XMLAutoStyleFamily &rFamily = *aFind;
+    XMLAutoStyleFamily &rFamily = **iter;
 
     XMLAutoStylePoolParent aTmp(rParentName);
     XMLAutoStyleFamily::ParentSetType::iterator it2 = rFamily.maParentSet.find(aTmp);
@@ -570,11 +570,11 @@ OUString SvXMLAutoStylePoolP_Impl::Find( sal_Int32 nFamily,
 {
     OUString sName;
 
-    XMLAutoStyleFamily aTemporary( nFamily );
-    FamilySetType::const_iterator const iter = maFamilySet.find(aTemporary);
-    assert(iter != maFamilySet.end()); // family must be known
+    std::unique_ptr<XMLAutoStyleFamily> pTemp(new XMLAutoStyleFamily(nFamily));
+    auto const iter = m_FamilySet.find(pTemp);
+    assert(iter != m_FamilySet.end()); // family must be known
 
-    XMLAutoStyleFamily const& rFamily = *iter;
+    XMLAutoStyleFamily const& rFamily = **iter;
     XMLAutoStylePoolParent aTmp( rParent );
     XMLAutoStyleFamily::ParentSetType::const_iterator it2 = rFamily.maParentSet.find(aTmp);
     if (it2 != rFamily.maParentSet.end())
@@ -614,11 +614,11 @@ void SvXMLAutoStylePoolP_Impl::exportXML(
         const SvXMLAutoStylePoolP *pAntiImpl) const
 {
     // Get list of parents for current family (nFamily)
-    XMLAutoStyleFamily aTmp( nFamily );
-    FamilySetType::const_iterator aFind = maFamilySet.find(aTmp);
-    assert(aFind != maFamilySet.end()); // family must be known
+    std::unique_ptr<XMLAutoStyleFamily> pTemp(new XMLAutoStyleFamily(nFamily));
+    auto const iter = m_FamilySet.find(pTemp);
+    assert(iter != m_FamilySet.end()); // family must be known
 
-    const XMLAutoStyleFamily &rFamily = *aFind;
+    const XMLAutoStyleFamily &rFamily = **iter;
     sal_uInt32 nCount = rFamily.mnCount;
 
     if (!nCount)
@@ -754,7 +754,7 @@ void SvXMLAutoStylePoolP_Impl::exportXML(
 
 void SvXMLAutoStylePoolP_Impl::ClearEntries()
 {
-    for (FamilySetType::iterator aI = maFamilySet.begin(); aI != maFamilySet.end(); ++aI)
+    for (auto & aI : m_FamilySet)
         aI->ClearEntries();
 }
 
diff --git a/xmloff/source/style/impastpl.hxx b/xmloff/source/style/impastpl.hxx
index 3e5670c..5093281 100644
--- a/xmloff/source/style/impastpl.hxx
+++ b/xmloff/source/style/impastpl.hxx
@@ -24,6 +24,7 @@
 #include <sal/types.h>
 #include <rtl/ustring.hxx>
 #include <set>
+#include <memory>
 #include <vector>
 #include <com/sun/star/uno/Reference.h>
 #include <com/sun/star/xml/sax/XAttributeList.hpp>
@@ -131,11 +132,19 @@ public:
 
 class SvXMLAutoStylePoolP_Impl
 {
+    struct XMLAutoStyleFamily_Less
+    {
+        bool operator()(std::unique_ptr<XMLAutoStyleFamily> const& lhs,
+                        std::unique_ptr<XMLAutoStyleFamily> const& rhs) const
+        {
+            return (*lhs) < (*rhs);
+        }
+    };
     // A set that finds and sorts based only on mnFamily
-    typedef boost::ptr_set<XMLAutoStyleFamily> FamilySetType;
+    typedef std::set<std::unique_ptr<XMLAutoStyleFamily>, XMLAutoStyleFamily_Less> FamilySetType;
 
     SvXMLExport& rExport;
-    FamilySetType maFamilySet;
+    FamilySetType m_FamilySet;
 
 public:
 
commit 1fa505d8f11ab97cd9cdcf5c6cd11ae357c29408
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Aug 7 14:45:01 2015 +0200

    xmloff: replace boost::ptr_set with std::map
    
    Change-Id: Ib4effa78cba72954c21ebadf0c5286b2d5207b4f

diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx
index 6a80964..49ad1aa 100644
--- a/xmloff/source/style/xmlnumfi.cxx
+++ b/xmloff/source/style/xmlnumfi.cxx
@@ -45,7 +45,6 @@
 #include <xmloff/languagetagodf.hxx>
 
 #include <boost/ptr_container/ptr_vector.hpp>
-#include <boost/ptr_container/ptr_set.hpp>
 
 using namespace ::com::sun::star;
 using namespace ::xmloff::token;
@@ -60,18 +59,7 @@ struct SvXMLNumFmtEntry
         aName(rN), nKey(nK), bRemoveAfterUse(bR) {}
 };
 
-struct SvXMLEmbeddedElement
-{
-    sal_Int32    nFormatPos;
-    OUString     aText;
-
-    SvXMLEmbeddedElement( sal_Int32 nFP, const OUString& rT ) :
-        nFormatPos(nFP), aText(rT) {}
-
-    bool operator < ( const SvXMLEmbeddedElement& r ) const { return nFormatPos <  r.nFormatPos; }
-};
-
-typedef boost::ptr_set<SvXMLEmbeddedElement> SvXMLEmbeddedElementArr;
+typedef std::map<sal_Int32, OUString> SvXMLEmbeddedElementArr;
 
 class SvXMLNumImpData
 {
@@ -117,7 +105,7 @@ struct SvXMLNumberInfo
     bool        bDecReplace;
     bool        bExpSign;
     double      fDisplayFactor;
-    SvXMLEmbeddedElementArr aEmbeddedElements;
+    SvXMLEmbeddedElementArr m_EmbeddedElements;
 
     SvXMLNumberInfo()
     {
@@ -1059,25 +1047,18 @@ void SvXMLNumFmtElementContext::Characters( const OUString& rChars )
 
 void SvXMLNumFmtElementContext::AddEmbeddedElement( sal_Int32 nFormatPos, const OUString& rContent )
 {
-    if ( !rContent.isEmpty() )
-    {
-        SvXMLEmbeddedElement* pObj = new SvXMLEmbeddedElement( nFormatPos, rContent );
-        if ( !aNumInfo.aEmbeddedElements.insert( pObj ).second )
-        {
-            //  there's already an element at this position - append text to existing element
+    if (rContent.isEmpty())
+        return;
 
-            delete pObj;
-            for (SvXMLEmbeddedElementArr::iterator it = aNumInfo.aEmbeddedElements.begin();
-                 it != aNumInfo.aEmbeddedElements.end(); ++it)
-            {
-                pObj = &*it;
-                if ( pObj->nFormatPos == nFormatPos )
-                {
-                    pObj->aText += rContent;
-                    break;
-                }
-            }
-        }
+    auto const iter(aNumInfo.m_EmbeddedElements.find(nFormatPos));
+    if (iter == aNumInfo.m_EmbeddedElements.end())
+    {
+        aNumInfo.m_EmbeddedElements.insert(std::make_pair(nFormatPos, rContent));
+    }
+    else
+    {
+        // there's already an element at this position - append text to existing element
+        iter->second += rContent;
     }
 }
 
@@ -1818,7 +1799,7 @@ void SvXMLNumFormatContext::AddNumber( const SvXMLNumberInfo& rInfo )
         nGenPrec = 0;               // generate format without decimals...
 
     bool bGrouping = rInfo.bGrouping;
-    sal_uInt16 nEmbeddedCount = rInfo.aEmbeddedElements.size();
+    size_t const nEmbeddedCount = rInfo.m_EmbeddedElements.size();
     if ( nEmbeddedCount )
         bGrouping = false;      // grouping and embedded characters can't be used together
 
@@ -1870,9 +1851,8 @@ void SvXMLNumFormatContext::AddNumber( const SvXMLNumberInfo& rInfo )
             nZeroPos = aNumStr.getLength();
         }
 
-        //  aEmbeddedElements is sorted - last entry has the largest position (leftmost)
-        const SvXMLEmbeddedElement* pLastObj = &*rInfo.aEmbeddedElements.rbegin();
-        sal_Int32 nLastFormatPos = pLastObj->nFormatPos;
+        // m_EmbeddedElements is sorted - last entry has the largest position (leftmost)
+        sal_Int32 const nLastFormatPos = rInfo.m_EmbeddedElements.rbegin()->first;
         if ( nLastFormatPos >= nZeroPos )
         {
             //  add '#' characters so all embedded texts are really embedded in digits
@@ -1886,12 +1866,10 @@ void SvXMLNumFormatContext::AddNumber( const SvXMLNumberInfo& rInfo )
             nZeroPos = nZeroPos + nAddCount;
         }
 
-        //  aEmbeddedElements is sorted with ascending positions - loop is from right to left
-        for (SvXMLEmbeddedElementArr::const_iterator it = rInfo.aEmbeddedElements.begin();
-             it != rInfo.aEmbeddedElements.end(); ++it)
+        // m_EmbeddedElements is sorted with ascending positions - loop is from right to left
+        for (auto const& it : rInfo.m_EmbeddedElements)
         {
-            const SvXMLEmbeddedElement* pObj = &*it;
-            sal_Int32 nFormatPos = pObj->nFormatPos;
+            sal_Int32 const nFormatPos = it.first;
             sal_Int32 nInsertPos = nZeroPos - nFormatPos;
             if ( nFormatPos >= 0 && nInsertPos >= 0 )
             {
@@ -1899,7 +1877,7 @@ void SvXMLNumFormatContext::AddNumber( const SvXMLNumberInfo& rInfo )
                 //  be recognized as thousands separator in French.
 
                 aNumStr.insert(nInsertPos, '"');
-                aNumStr.insert(nInsertPos, pObj->aText);
+                aNumStr.insert(nInsertPos, it.second);
                 aNumStr.insert(nInsertPos, '"');
             }
         }
commit 3de4481f654e5158870aa97c9faea66db6d972bb
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Aug 7 14:25:16 2015 +0200

    xmloff: replace boost::ptr_set with std::set
    
    Change-Id: Idc03bf695d94f47f2057629b4175c2bdf3a83f22

diff --git a/include/xmloff/xmltkmap.hxx b/include/xmloff/xmltkmap.hxx
index 70d2918..d0f2288 100644
--- a/include/xmloff/xmltkmap.hxx
+++ b/include/xmloff/xmltkmap.hxx
@@ -27,7 +27,6 @@
 
 
 class SvXMLTokenMap_Impl;
-class SvXMLTokenMapEntry_Impl;
 
 #define XML_TOK_UNKNOWN 0xffffU
 #define XML_TOKEN_MAP_END { 0xffffU, ::xmloff::token::XML_TOKEN_INVALID, 0U }
@@ -41,10 +40,7 @@ struct SvXMLTokenMapEntry
 
 class XMLOFF_DLLPUBLIC SvXMLTokenMap
 {
-    SvXMLTokenMap_Impl      *pImpl;
-
-    SAL_DLLPRIVATE SvXMLTokenMapEntry_Impl *_Find(
-        sal_uInt16 nKind, const OUString& rName ) const;
+    SvXMLTokenMap_Impl      *m_pImpl;
 
 public:
 
diff --git a/xmloff/source/core/xmltkmap.cxx b/xmloff/source/core/xmltkmap.cxx
index da04fd2..361cbf6 100644
--- a/xmloff/source/core/xmltkmap.cxx
+++ b/xmloff/source/core/xmltkmap.cxx
@@ -20,7 +20,8 @@
 #include <rtl/ustring.hxx>
 #include <xmloff/xmltkmap.hxx>
 #include <xmloff/xmltoken.hxx>
-#include <boost/ptr_container/ptr_set.hpp>
+
+#include <set>
 
 using namespace ::xmloff::token;
 
@@ -55,16 +56,18 @@ public:
     }
 };
 
-class SvXMLTokenMap_Impl : public boost::ptr_set<SvXMLTokenMapEntry_Impl> {};
+class SvXMLTokenMap_Impl : public std::set<SvXMLTokenMapEntry_Impl> {};
 
-SvXMLTokenMapEntry_Impl *SvXMLTokenMap::_Find( sal_uInt16 nKeyPrefix,
-                                                const OUString& rLName ) const
+SvXMLTokenMapEntry_Impl const* lcl_Find(
+        SvXMLTokenMap_Impl const* pImpl,
+        sal_uInt16 nKeyPrefix,
+        const OUString& rLName )
 {
-    SvXMLTokenMapEntry_Impl *pRet = 0;
+    SvXMLTokenMapEntry_Impl const* pRet = nullptr;
     SvXMLTokenMapEntry_Impl aTst( nKeyPrefix, rLName );
 
     SvXMLTokenMap_Impl::iterator it = pImpl->find( aTst );
-    if( it != pImpl->end() )
+    if (it != pImpl->end())
     {
         pRet = &*it;
     }
@@ -72,25 +75,26 @@ SvXMLTokenMapEntry_Impl *SvXMLTokenMap::_Find( sal_uInt16 nKeyPrefix,
     return pRet;
 }
 
-SvXMLTokenMap::SvXMLTokenMap( const SvXMLTokenMapEntry *pMap ) :
-    pImpl( new SvXMLTokenMap_Impl )
+SvXMLTokenMap::SvXMLTokenMap( const SvXMLTokenMapEntry *pMap )
+    : m_pImpl( new SvXMLTokenMap_Impl )
 {
     while( pMap->eLocalName != XML_TOKEN_INVALID )
     {
-        pImpl->insert( new SvXMLTokenMapEntry_Impl( *pMap ) );
+        m_pImpl->insert(SvXMLTokenMapEntry_Impl( *pMap ));
         pMap++;
     }
 }
 
 SvXMLTokenMap::~SvXMLTokenMap()
 {
-    delete pImpl;
+    delete m_pImpl;
 }
 
 sal_uInt16 SvXMLTokenMap::Get( sal_uInt16 nKeyPrefix,
                                const OUString& rLName ) const
 {
-    SvXMLTokenMapEntry_Impl *pEntry = _Find( nKeyPrefix, rLName );
+    SvXMLTokenMapEntry_Impl const*const pEntry(
+            lcl_Find(m_pImpl, nKeyPrefix, rLName));
     if( pEntry )
         return pEntry->GetToken();
     else
commit d7b4e6b434885c630ee94e8233fb142cbf0a0107
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Aug 7 13:56:14 2015 +0200

    svtools: convert boost::ptr_set to std::unordered_map
    
    Change-Id: I2b5a57978e693f3b08726a09a0d1f6cc32d9f593

diff --git a/svtools/inc/pch/precompiled_svt.hxx b/svtools/inc/pch/precompiled_svt.hxx
index 023fb2c..851c041 100644
--- a/svtools/inc/pch/precompiled_svt.hxx
+++ b/svtools/inc/pch/precompiled_svt.hxx
@@ -22,7 +22,6 @@
 #include <basegfx/range/b2drange.hxx>
 #include <boost/noncopyable.hpp>
 #include <boost/optional.hpp>
-#include <boost/ptr_container/ptr_set.hpp>
 #include <boost/ptr_container/ptr_vector.hpp>
 #include <memory>
 #include <boost/scoped_ptr.hpp>
diff --git a/svtools/source/contnr/fileview.cxx b/svtools/source/contnr/fileview.cxx
index c85b1dd..38fa3c4 100644
--- a/svtools/source/contnr/fileview.cxx
+++ b/svtools/source/contnr/fileview.cxx
@@ -53,6 +53,7 @@
 
 #include <algorithm>
 #include <vector>
+#include <unordered_map>
 #include <tools/urlobj.hxx>
 #include <comphelper/processfactory.hxx>
 #include <comphelper/string.hxx>
@@ -71,7 +72,6 @@
 #include <unotools/intlwrapper.hxx>
 #include <unotools/syslocale.hxx>
 #include <svl/urlfilter.hxx>
-#include <boost/ptr_container/ptr_set.hpp>
 #include <boost/scoped_ptr.hpp>
 #include <o3tl/typed_flags_set.hxx>
 
@@ -228,88 +228,17 @@ public:
     virtual void        ExcecuteContextMenuAction( sal_uInt16 nSelectedPopentry ) SAL_OVERRIDE;
 };
 
-// class HashedEntry --------------------------------------------------
-
-class HashedEntry
-{   // just a special String which can be compared on equality much faster
-protected:
-    OUString                maName;
-    sal_Int32               mnHashCode;
-public:
-    inline                  HashedEntry( const OUString& rName );
-    inline                  HashedEntry( const INetURLObject& rURL );
-    virtual                 ~HashedEntry();
-
-    inline bool operator    ==( const HashedEntry& rRef ) const;
-    inline bool operator    !=( const HashedEntry& rRef ) const;
-    inline bool operator    <( const HashedEntry& rRef ) const;
-};
-
-inline HashedEntry::HashedEntry( const OUString& rName ): maName( rName ), mnHashCode( rName.hashCode() )
-{
-}
-
-inline HashedEntry::HashedEntry( const INetURLObject& rURL ):
-    maName( rURL.GetMainURL( INetURLObject::NO_DECODE ) ),
-    mnHashCode( maName.hashCode() )
-{
-}
-
-HashedEntry::~HashedEntry()
-{
-}
-
-inline bool HashedEntry::operator ==( const HashedEntry& rRef ) const
-{
-    return mnHashCode == rRef.mnHashCode && maName == rRef.maName;
-}
-
-inline bool HashedEntry::operator !=( const HashedEntry& rRef ) const
-{
-    return mnHashCode != rRef.mnHashCode || maName != rRef.maName;
-}
-
-inline bool HashedEntry::operator <( const HashedEntry& rRef ) const
-{
-    if( mnHashCode == rRef.mnHashCode )
-        return maName.reverseCompareTo( rRef.maName ) < 0;
-    else
-       return mnHashCode < rRef.mnHashCode;
-}
-
-// class NameTranslationEntry -----------------------------------------
-
-class NameTranslationEntry : public HashedEntry
-{// a fast comparable String and another String, which is used to get a substitution for a given String
-protected:
-    OUString                maTranslatedName;
-public:
-    inline                  NameTranslationEntry( const OString& rOriginalName, const OString& rTranslatedName );
-
-    inline const OUString&  GetTranslation() const;
-};
-
-inline NameTranslationEntry::NameTranslationEntry( const OString& rOrg, const OString& rTrans )
-    : HashedEntry(OStringToOUString(rOrg, RTL_TEXTENCODING_ASCII_US))
-    , maTranslatedName(OStringToOUString(rTrans, RTL_TEXTENCODING_UTF8))
-{
-}
-
-inline const OUString& NameTranslationEntry::GetTranslation() const
-{
-    return maTranslatedName;
-}
-
 // class NameTranslationList -----------------------------------------
 // provides a list of _unique_ Entries
-class NameTranslationList : protected boost::ptr_set<HashedEntry>
+class NameTranslationList
 {   // contains a list of substitutes of strings for a given folder (as URL)
     // explanation of the circumstances see in remarks for Init();
 protected:
     INetURLObject               maTransFile;    // URL of file with translation entries
-    HashedEntry                 maHashedURL;    // for future purposes when dealing with a set of cached
-                                                //  NameTranslationLists
+    /// for future purposes when dealing with a set of cached NameTranslationLists
+    OUString m_HashedURL;
 private:
+    std::unordered_map<OUString, OUString, OUStringHash> m_Translation;
     const OUString              maTransFileName;
     void                        Init();         // reads the translation file and fills the (internal) list
 
@@ -318,14 +247,11 @@ public:
                                             // rBaseURL: path to folder for which the translation of the entries
                                             //  should be done
 
-    using boost::ptr_set<HashedEntry>::operator==;
-    using boost::ptr_set<HashedEntry>::operator!=;
-    inline bool operator        !=( const HashedEntry& rRef ) const;
-
     const OUString*             Translate( const OUString& rName ) const;
                                             // returns NULL, if rName can't be found
 
     inline const OUString&      GetTransTableFileName() const;
+    OUString const& GetHashedURL() { return m_HashedURL; }
                                             // returns the name for the file, which contains the translation strings
 };
 
@@ -356,7 +282,12 @@ void NameTranslationList::Init()
             sal_uInt16          nKeyCnt = aConfig.GetKeyCount();
 
             for( sal_uInt16 nCnt = 0 ; nCnt < nKeyCnt ; ++nCnt )
-                insert( new NameTranslationEntry( aConfig.GetKeyName( nCnt ), aConfig.ReadKey( nCnt ) ) );
+            {
+                m_Translation.insert(std::make_pair(
+                    OStringToOUString(aConfig.GetKeyName(nCnt), RTL_TEXTENCODING_ASCII_US),
+                    OStringToOUString(aConfig.ReadKey(nCnt), RTL_TEXTENCODING_UTF8)
+                    ));
+            }
         }
     }
     catch( Exception const & ) {}
@@ -364,29 +295,17 @@ void NameTranslationList::Init()
 
 NameTranslationList::NameTranslationList( const INetURLObject& rBaseURL ):
     maTransFile( rBaseURL ),
-    maHashedURL( rBaseURL ),
+    m_HashedURL(rBaseURL.GetMainURL(INetURLObject::NO_DECODE)),
     maTransFileName( OUString(".nametranslation.table") )
 {
     maTransFile.insertName( maTransFileName );
     Init();
 }
 
-inline bool NameTranslationList::operator !=( const HashedEntry& rRef ) const
-{
-    return maHashedURL != rRef;
-}
-
 const OUString* NameTranslationList::Translate( const OUString& rName ) const
 {
-    HashedEntry  aRef( rName );
-    const NameTranslationEntry* pSearch = NULL;
-    for( const_iterator it = begin(); it != end(); ++it )
-        if( (*it) == aRef )
-        {
-            pSearch = static_cast<const NameTranslationEntry*>(&*it);
-        }
-
-    return pSearch ? &pSearch->GetTranslation() : NULL;
+    auto const iter(m_Translation.find(rName));
+    return (iter != m_Translation.end()) ? &iter->second : nullptr;
 }
 
 // class NameTranslator_Impl ------------------------------------------
@@ -1525,11 +1444,9 @@ NameTranslator_Impl::~NameTranslator_Impl()
 
 void NameTranslator_Impl::SetActualFolder( const INetURLObject& rActualFolder )
 {
-    HashedEntry aActFolder( rActualFolder );
-
     if( mpActFolder )
     {
-        if( *mpActFolder != aActFolder )
+        if (mpActFolder->GetHashedURL() != rActualFolder.GetMainURL(INetURLObject::NO_DECODE))
         {
             delete mpActFolder;
             mpActFolder = new NameTranslationList( rActualFolder );


More information about the Libreoffice-commits mailing list