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

Michael Stahl mstahl at redhat.com
Thu Oct 1 02:30:55 PDT 2015


 sw/source/core/doc/tblrwcl.cxx   |   29 ++++++++++++++++------------
 sw/source/core/inc/UndoSort.hxx  |    8 ++++---
 sw/source/core/inc/tblrwcl.hxx   |    8 ++-----
 sw/source/core/undo/unsort.cxx   |   40 +++++++++++++++++++++------------------
 sw/source/core/undo/untbl.cxx    |    3 ++
 sw/source/filter/xml/xmltbli.cxx |   28 ++++++++++++++-------------
 6 files changed, 65 insertions(+), 51 deletions(-)

New commits:
commit 1bda8ef1b0d532339db02cd932da275b00fb3f91
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Oct 1 11:00:10 2015 +0200

    sw: convert this sal_uLong
    
    Although, why not just use the pointer?
    
    Change-Id: I1781a04bb97dba2ac6c769973345bb3c66f28904

diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx
index f9d9198..d12e012 100644
--- a/sw/source/core/doc/tblrwcl.cxx
+++ b/sw/source/core/doc/tblrwcl.cxx
@@ -4519,7 +4519,7 @@ void SwShareBoxFormats::RemoveFormat( const SwFrameFormat& rFormat )
 
 bool SwShareBoxFormats::Seek_Entry( const SwFrameFormat& rFormat, sal_uInt16* pPos ) const
 {
-    sal_uLong nIdx = reinterpret_cast<sal_uLong>(&rFormat);
+    sal_uIntPtr nIdx = reinterpret_cast<sal_uIntPtr>(&rFormat);
     auto nO = m_ShareArr.size();
     decltype(nO) nU = 0;
     if( nO > 0 )
@@ -4528,7 +4528,7 @@ bool SwShareBoxFormats::Seek_Entry( const SwFrameFormat& rFormat, sal_uInt16* pP
         while( nU <= nO )
         {
             const auto nM = nU + ( nO - nU ) / 2;
-            sal_uLong nFormat = reinterpret_cast<sal_uLong>(&m_ShareArr[ nM ]->GetOldFormat());
+            sal_uIntPtr nFormat = reinterpret_cast<sal_uIntPtr>(&m_ShareArr[ nM ]->GetOldFormat());
             if( nFormat == nIdx )
             {
                 if( pPos )
commit 277bf2338b313317e70db0cf9d09342558ae0792
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Sep 30 23:22:11 2015 +0200

    sw: replace boost::ptr_vector with std::vector<std::unique_ptr>
    
    Change-Id: I821a853a0e4776d2b5ba2ca69d421ec0af8e865e

diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx
index b4abdb8..f9d9198 100644
--- a/sw/source/core/doc/tblrwcl.cxx
+++ b/sw/source/core/doc/tblrwcl.cxx
@@ -4411,16 +4411,16 @@ SwFrameFormat* SwShareBoxFormats::GetFormat( const SwFrameFormat& rFormat, long
 {
     sal_uInt16 nPos;
     return Seek_Entry( rFormat, &nPos )
-                    ? aShareArr[ nPos ].GetFormat( nWidth )
-                    : 0;
+                    ? m_ShareArr[ nPos ]->GetFormat(nWidth)
+                    : nullptr;
 }
 SwFrameFormat* SwShareBoxFormats::GetFormat( const SwFrameFormat& rFormat,
                                      const SfxPoolItem& rItem ) const
 {
     sal_uInt16 nPos;
     return Seek_Entry( rFormat, &nPos )
-                    ? aShareArr[ nPos ].GetFormat( rItem )
-                    : 0;
+                    ? m_ShareArr[ nPos ]->GetFormat(rItem)
+                    : nullptr;
 }
 
 void SwShareBoxFormats::AddFormat( const SwFrameFormat& rOld, SwFrameFormat& rNew )
@@ -4431,10 +4431,10 @@ void SwShareBoxFormats::AddFormat( const SwFrameFormat& rOld, SwFrameFormat& rNe
         if( !Seek_Entry( rOld, &nPos ))
         {
             pEntry = new SwShareBoxFormat( rOld );
-            aShareArr.insert( aShareArr.begin() + nPos, pEntry );
+            m_ShareArr.insert(m_ShareArr.begin() + nPos, std::unique_ptr<SwShareBoxFormat>(pEntry));
         }
         else
-            pEntry = &aShareArr[ nPos ];
+            pEntry = m_ShareArr[ nPos ].get();
 
         pEntry->AddFormat( rNew );
     }
@@ -4508,22 +4508,27 @@ void SwShareBoxFormats::SetAttr( SwTableLine& rLine, const SfxPoolItem& rItem )
 
 void SwShareBoxFormats::RemoveFormat( const SwFrameFormat& rFormat )
 {
-    for( auto i = aShareArr.size(); i; )
-        if( aShareArr[ --i ].RemoveFormat( rFormat ))
-            aShareArr.erase( aShareArr.begin() + i );
+    for (auto i = m_ShareArr.size(); i; )
+    {
+        if (m_ShareArr[ --i ]->RemoveFormat(rFormat))
+        {
+            m_ShareArr.erase( m_ShareArr.begin() + i );
+        }
+    }
 }
 
 bool SwShareBoxFormats::Seek_Entry( const SwFrameFormat& rFormat, sal_uInt16* pPos ) const
 {
     sal_uLong nIdx = reinterpret_cast<sal_uLong>(&rFormat);
-    _SwShareBoxFormats::size_type nO = aShareArr.size(), nU = 0;
+    auto nO = m_ShareArr.size();
+    decltype(nO) nU = 0;
     if( nO > 0 )
     {
         nO--;
         while( nU <= nO )
         {
             const auto nM = nU + ( nO - nU ) / 2;
-            sal_uLong nFormat = reinterpret_cast<sal_uLong>(&aShareArr[ nM ].GetOldFormat());
+            sal_uLong nFormat = reinterpret_cast<sal_uLong>(&m_ShareArr[ nM ]->GetOldFormat());
             if( nFormat == nIdx )
             {
                 if( pPos )
diff --git a/sw/source/core/inc/tblrwcl.hxx b/sw/source/core/inc/tblrwcl.hxx
index 46c50cc..96d064c 100644
--- a/sw/source/core/inc/tblrwcl.hxx
+++ b/sw/source/core/inc/tblrwcl.hxx
@@ -20,10 +20,9 @@
 #define INCLUDED_SW_SOURCE_CORE_INC_TBLRWCL_HXX
 
 #include <cstddef>
+#include <memory>
 #include <vector>
 
-#include <boost/ptr_container/ptr_vector.hpp>
-
 #include <swtypes.hxx>
 #include <tblsel.hxx>
 #include <swtable.hxx>
@@ -174,11 +173,10 @@ public:
     bool RemoveFormat( const SwFrameFormat& rFormat );
 };
 
-typedef boost::ptr_vector<SwShareBoxFormat> _SwShareBoxFormats;
-
 class SwShareBoxFormats
 {
-    _SwShareBoxFormats aShareArr;
+    std::vector<std::unique_ptr<SwShareBoxFormat>> m_ShareArr;
+
     bool Seek_Entry( const SwFrameFormat& rFormat, sal_uInt16* pPos ) const;
 
     void ChangeFrameFormat( SwTableBox* pBox, SwTableLine* pLn, SwFrameFormat& rFormat );
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index 6589657..9af9efe 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -63,6 +63,9 @@
 #include <comcore.hrc>
 #include <unochart.hxx>
 #include <calbck.hxx>
+
+#include <boost/ptr_container/ptr_vector.hpp>
+
 #include <memory>
 #include <vector>
 
commit ba785e0c93102e354c646c96a1de29f468080108
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Sep 30 23:09:06 2015 +0200

    sw: replace boost::ptr_vector with std::vector<std::unique_ptr>
    
    Change-Id: I913648a8dd407c5629df7a0355d2cfdf66240cf9

diff --git a/sw/source/core/inc/UndoSort.hxx b/sw/source/core/inc/UndoSort.hxx
index 426b862..4bc178b 100644
--- a/sw/source/core/inc/UndoSort.hxx
+++ b/sw/source/core/inc/UndoSort.hxx
@@ -21,9 +21,12 @@
 #define INCLUDED_SW_SOURCE_CORE_INC_UNDOSORT_HXX
 
 #include <undobj.hxx>
-#include <boost/ptr_container/ptr_vector.hpp>
+
 #include <rtl/ustring.hxx>
 
+#include <memory>
+#include <vector>
+
 struct SwSortOptions;
 class SwTableNode;
 class SwUndoAttrTable;
@@ -59,8 +62,7 @@ typedef std::vector<SwNodeIndex*> SwUndoSortList;
 class SwUndoSort : public SwUndo, private SwUndRng
 {
     SwSortOptions*    pSortOpt;
-    boost::ptr_vector<SwSortUndoElement>
-                      aSortList;
+    std::vector<std::unique_ptr<SwSortUndoElement>> m_SortList;
     SwUndoAttrTable*  pUndoTableAttr;
     SwRedlineData*    pRedlData;
     sal_uLong         nTableNd;
diff --git a/sw/source/core/undo/unsort.cxx b/sw/source/core/undo/unsort.cxx
index a32c1cb..42b4d81 100644
--- a/sw/source/core/undo/unsort.cxx
+++ b/sw/source/core/undo/unsort.cxx
@@ -94,12 +94,12 @@ void SwUndoSort::UndoImpl(::sw::UndoRedoContext & rContext)
         const SwTable& rTable = pTableNd->GetTable();
 
         SwMovedBoxes aMovedList;
-        for( size_t i=0; i < aSortList.size(); i++)
+        for (size_t i=0; i < m_SortList.size(); i++)
         {
             const SwTableBox* pSource = rTable.GetTableBox(
-                    *aSortList[i].SORT_TXT_TBL.TBL.pSource );
+                    *m_SortList[i]->SORT_TXT_TBL.TBL.pSource );
             const SwTableBox* pTarget = rTable.GetTableBox(
-                    *aSortList[i].SORT_TXT_TBL.TBL.pTarget );
+                    *m_SortList[i]->SORT_TXT_TBL.TBL.pTarget );
 
             // move back
             MoveCell(&rDoc, pTarget, pSource,
@@ -125,17 +125,21 @@ void SwUndoSort::UndoImpl(::sw::UndoRedoContext & rContext)
         // The IndexList must be created based on (asc.) sorted SourcePosition.
         SwUndoSortList aIdxList;
 
-        for( size_t i = 0; i < aSortList.size(); ++i)
-            for( size_t ii=0; ii < aSortList.size(); ++ii )
-                if( aSortList[ii].SORT_TXT_TBL.TXT.nSource == nSttNode + i )
+        for (size_t i = 0; i < m_SortList.size(); ++i)
+        {
+            for (size_t ii = 0; ii < m_SortList.size(); ++ii)
+            {
+                if (m_SortList[ii]->SORT_TXT_TBL.TXT.nSource == nSttNode + i)
                 {
                     SwNodeIndex* pIdx = new SwNodeIndex( rDoc.GetNodes(),
-                        aSortList[ii].SORT_TXT_TBL.TXT.nTarget );
+                        m_SortList[ii]->SORT_TXT_TBL.TXT.nTarget );
                     aIdxList.insert( aIdxList.begin() + i, pIdx );
                     break;
                 }
+            }
+        }
 
-        for(size_t i=0; i < aSortList.size(); ++i)
+        for (size_t i = 0; i < m_SortList.size(); ++i)
         {
             SwNodeIndex aIdx( rDoc.GetNodes(), nSttNode + i );
             SwNodeRange aRg( *aIdxList[i], 0, *aIdxList[i], 1 );
@@ -169,12 +173,12 @@ void SwUndoSort::RedoImpl(::sw::UndoRedoContext & rContext)
         const SwTable& rTable = pTableNd->GetTable();
 
         SwMovedBoxes aMovedList;
-        for(size_t i=0; i < aSortList.size(); ++i)
+        for (size_t i = 0; i < m_SortList.size(); ++i)
         {
             const SwTableBox* pSource = rTable.GetTableBox(
-                    *aSortList[i].SORT_TXT_TBL.TBL.pSource );
+                    *m_SortList[i]->SORT_TXT_TBL.TBL.pSource );
             const SwTableBox* pTarget = rTable.GetTableBox(
-                    *aSortList[i].SORT_TXT_TBL.TBL.pTarget );
+                    *m_SortList[i]->SORT_TXT_TBL.TBL.pTarget );
 
             // move back
             MoveCell(&rDoc, pSource, pTarget,
@@ -203,14 +207,14 @@ void SwUndoSort::RedoImpl(::sw::UndoRedoContext & rContext)
 
         SwUndoSortList aIdxList;
 
-        for( size_t i = 0; i < aSortList.size(); ++i)
+        for (size_t i = 0; i < m_SortList.size(); ++i)
         {   // current position is starting point
             SwNodeIndex* pIdx = new SwNodeIndex( rDoc.GetNodes(),
-                    aSortList[i].SORT_TXT_TBL.TXT.nSource);
+                    m_SortList[i]->SORT_TXT_TBL.TXT.nSource);
             aIdxList.insert( aIdxList.begin() + i, pIdx );
         }
 
-        for( size_t i = 0; i < aSortList.size(); ++i)
+        for (size_t i = 0; i < m_SortList.size(); ++i)
         {
             SwNodeIndex aIdx( rDoc.GetNodes(), nSttNode + i);
             SwNodeRange aRg( *aIdxList[i], 0, *aIdxList[i], 1 );
@@ -245,14 +249,14 @@ void SwUndoSort::RepeatImpl(::sw::RepeatContext & rContext)
 
 void SwUndoSort::Insert( const OUString& rOrgPos, const OUString& rNewPos)
 {
-    SwSortUndoElement* pEle = new SwSortUndoElement(rOrgPos, rNewPos);
-    aSortList.push_back( pEle );
+    std::unique_ptr<SwSortUndoElement> p(new SwSortUndoElement(rOrgPos, rNewPos));
+    m_SortList.push_back(std::move(p));
 }
 
 void SwUndoSort::Insert( sal_uLong nOrgPos, sal_uLong nNewPos)
 {
-    SwSortUndoElement* pEle = new SwSortUndoElement(nOrgPos, nNewPos);
-    aSortList.push_back( pEle );
+    std::unique_ptr<SwSortUndoElement> p(new SwSortUndoElement(nOrgPos, nNewPos));
+    m_SortList.push_back(std::move(p));
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit d119c840b76a250c79f30bae246fad0b255817d2
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Sep 30 23:03:04 2015 +0200

    sw: replace boost::ptr_vector with std::vector<std::unique_ptr>
    
    Change-Id: Iabe9ccea6a5e9753348895cca4546c89fc6971cf

diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx
index dde95da..93d12a5 100644
--- a/sw/source/filter/xml/xmltbli.cxx
+++ b/sw/source/filter/xml/xmltbli.cxx
@@ -58,7 +58,8 @@
 #include <osl/mutex.hxx>
 #include "ndtxt.hxx"
 
-#include <boost/ptr_container/ptr_vector.hpp>
+#include <vector>
+#include <memory>
 
 #include <limits.h>
 
@@ -293,8 +294,7 @@ class SwXMLTableRow_Impl
     OUString   aStyleName;
     OUString   aDfltCellStyleName;
     OUString   mXmlId;
-    boost::ptr_vector<SwXMLTableCell_Impl>
-               aCells;
+    std::vector<std::unique_ptr<SwXMLTableCell_Impl>> m_Cells;
     bool       bSplitable;
 
 public:
@@ -338,7 +338,7 @@ SwXMLTableRow_Impl::SwXMLTableRow_Impl( const OUString& rStyleName,
 
     for( sal_uInt32 i=0U; i<nCells; ++i )
     {
-        aCells.push_back( new SwXMLTableCell_Impl );
+        m_Cells.push_back(std::unique_ptr<SwXMLTableCell_Impl>(new SwXMLTableCell_Impl));
     }
 }
 
@@ -347,9 +347,9 @@ inline SwXMLTableCell_Impl *SwXMLTableRow_Impl::GetCell( sal_uInt32 nCol )
     OSL_ENSURE( nCol < USHRT_MAX,
             "SwXMLTableRow_Impl::GetCell: column number is to big" );
     // #i95726# - some fault tolerance
-    OSL_ENSURE( nCol < aCells.size(),
+    OSL_ENSURE( nCol < m_Cells.size(),
             "SwXMLTableRow_Impl::GetCell: column number is out of bound" );
-    return nCol < aCells.size() ? &aCells[nCol] : 0;
+    return nCol < m_Cells.size() ? m_Cells[nCol].get() : nullptr;
 }
 
 void SwXMLTableRow_Impl::Expand( sal_uInt32 nCells, bool bOneCell )
@@ -359,15 +359,15 @@ void SwXMLTableRow_Impl::Expand( sal_uInt32 nCells, bool bOneCell )
     if( nCells > USHRT_MAX )
         nCells = USHRT_MAX;
 
-    sal_uInt32 nColSpan = nCells - aCells.size();
-    for( size_t i=aCells.size(); i<nCells; ++i )
+    sal_uInt32 nColSpan = nCells - m_Cells.size();
+    for (size_t i = m_Cells.size(); i < nCells; ++i)
     {
-        aCells.push_back( new SwXMLTableCell_Impl( 1UL,
-                                                bOneCell ? nColSpan : 1UL ) );
+        m_Cells.push_back(std::unique_ptr<SwXMLTableCell_Impl>(
+                new SwXMLTableCell_Impl(1UL, (bOneCell) ? nColSpan : 1UL)));
         nColSpan--;
     }
 
-    OSL_ENSURE( nCells<=aCells.size(),
+    OSL_ENSURE( nCells <= m_Cells.size(),
             "SwXMLTableRow_Impl::Expand: wrong number of cells" );
 }
 
@@ -382,8 +382,10 @@ inline void SwXMLTableRow_Impl::Set( const OUString& rStyleName,
 
 void SwXMLTableRow_Impl::Dispose()
 {
-    for( size_t i=0; i < aCells.size(); ++i )
-        aCells[i].Dispose();
+    for (auto & pCell : m_Cells)
+    {
+        pCell->Dispose();
+    }
 }
 
 class SwXMLTableCellContext_Impl : public SvXMLImportContext


More information about the Libreoffice-commits mailing list