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

Michaël Lefèvre lefevre00 at yahoo.fr
Wed Oct 15 12:41:45 PDT 2014


 sw/inc/undobj.hxx               |    2 -
 sw/source/core/inc/UndoCore.hxx |   40 ++++++++++++++++++++++++++++---
 sw/source/core/undo/undobj.cxx  |   51 +++++++---------------------------------
 sw/source/core/undo/unredln.cxx |    2 -
 4 files changed, 48 insertions(+), 47 deletions(-)

New commits:
commit a1a33bc181f058bef98a9a47dde3e77a3d8fb086
Author: Michaël Lefèvre <lefevre00 at yahoo.fr>
Date:   Mon Oct 13 11:41:46 2014 +0200

    fdo#75757: remove inheritance to std::vector
    
    from SwRedlineSaveDatas
    
    Change-Id: Ie178983496891c8bd964b37536058d2e6b310c29
    Reviewed-on: https://gerrit.libreoffice.org/11947
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/inc/undobj.hxx b/sw/inc/undobj.hxx
index a1febc4..f2685ff 100644
--- a/sw/inc/undobj.hxx
+++ b/sw/inc/undobj.hxx
@@ -117,7 +117,7 @@ public:
     static bool FillSaveData( const SwPaM& rRange, SwRedlineSaveDatas& rSData,
                               bool bDelRange = true, bool bCopyNext = true );
     static bool FillSaveDataForFmt( const SwPaM& , SwRedlineSaveDatas& );
-    static void SetSaveData( SwDoc& rDoc, const SwRedlineSaveDatas& rSData );
+    static void SetSaveData( SwDoc& rDoc, SwRedlineSaveDatas& rSData );
     static bool HasHiddenRedlines( const SwRedlineSaveDatas& rSData );
 };
 
diff --git a/sw/source/core/inc/UndoCore.hxx b/sw/source/core/inc/UndoCore.hxx
index 64b2b95..eff8a94 100644
--- a/sw/source/core/inc/UndoCore.hxx
+++ b/sw/source/core/inc/UndoCore.hxx
@@ -23,13 +23,13 @@
 #include <undobj.hxx>
 #include <calbck.hxx>
 #include <rtl/ustring.hxx>
+#include <redline.hxx>
 
 class SfxItemSet;
 class SwFmtColl;
 class SwFmtAnchor;
 class SdrMarkList;
 class SwUndoDelete;
-class SwRedlineSaveData;
 class SwFmt;
 
 namespace sw {
@@ -37,11 +37,43 @@ namespace sw {
     class IShellCursorSupplier;
 }
 
-class SwRedlineSaveDatas : public std::vector<SwRedlineSaveData*> {
+class SwRedlineSaveData: public SwUndRng, public SwRedlineData, private SwUndoSaveSection
+{
 public:
-    ~SwRedlineSaveDatas() { DeleteAndDestroyAll(); }
+    SwRedlineSaveData(
+        SwComparePosition eCmpPos,
+        const SwPosition& rSttPos,
+        const SwPosition& rEndPos,
+        SwRangeRedline& rRedl,
+        bool bCopyNext );
+
+    ~SwRedlineSaveData();
+
+    void RedlineToDoc( SwPaM& rPam );
+
+    SwNodeIndex* GetMvSttIdx() const
+    {
+        return SwUndoSaveSection::GetMvSttIdx();
+    }
 
-    void DeleteAndDestroyAll();
+#if OSL_DEBUG_LEVEL > 0
+    sal_uInt16 nRedlineCount;
+#endif
+};
+
+class SwRedlineSaveDatas {
+private:
+    boost::ptr_vector<SwRedlineSaveData> mvData;
+
+public:
+    SwRedlineSaveDatas() : mvData() {}
+
+    void clear() { mvData.clear(); }
+    bool empty() const { return mvData.empty(); }
+    size_t size() const { return mvData.size(); }
+    void push_back (SwRedlineSaveData* value) { mvData.push_back(value); }
+    const SwRedlineSaveData& operator[]( size_t nIdx ) const { return mvData[ nIdx ]; }
+    SwRedlineSaveData& operator[]( size_t nIdx ) { return mvData[ nIdx ]; }
 };
 
 namespace sw {
diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx
index c85e74af..5e1bb0b 100644
--- a/sw/source/core/undo/undobj.cxx
+++ b/sw/source/core/undo/undobj.cxx
@@ -41,30 +41,6 @@
 #include <comcore.hrc>
 #include <docsh.hxx>
 
-class SwRedlineSaveData: public SwUndRng, public SwRedlineData, private SwUndoSaveSection
-{
-public:
-    SwRedlineSaveData(
-        SwComparePosition eCmpPos,
-        const SwPosition& rSttPos,
-        const SwPosition& rEndPos,
-        SwRangeRedline& rRedl,
-        bool bCopyNext );
-
-    ~SwRedlineSaveData();
-
-    void RedlineToDoc( SwPaM& rPam );
-
-    SwNodeIndex* GetMvSttIdx() const
-    {
-        return SwUndoSaveSection::GetMvSttIdx();
-    }
-
-#if OSL_DEBUG_LEVEL > 0
-    sal_uInt16 nRedlineCount;
-#endif
-};
-
 // This class saves the Pam as integers and can recompose those into a PaM
 SwUndRng::SwUndRng()
     : nSttNode( 0 ), nEndNode( 0 ), nSttCntnt( 0 ), nEndCntnt( 0 )
@@ -1004,7 +980,7 @@ bool SwUndo::FillSaveData(
     bool bDelRange,
     bool bCopyNext )
 {
-    rSData.DeleteAndDestroyAll();
+    rSData.clear();
 
     SwRedlineSaveData* pNewData;
     const SwPosition* pStt = rRange.Start();
@@ -1038,7 +1014,7 @@ bool SwUndo::FillSaveDataForFmt(
     const SwPaM& rRange,
     SwRedlineSaveDatas& rSData )
 {
-    rSData.DeleteAndDestroyAll();
+    rSData.clear();
 
     SwRedlineSaveData* pNewData;
     const SwPosition *pStt = rRange.Start(), *pEnd = rRange.End();
@@ -1066,19 +1042,19 @@ bool SwUndo::FillSaveDataForFmt(
 }
 
 
-void SwUndo::SetSaveData( SwDoc& rDoc, const SwRedlineSaveDatas& rSData )
+void SwUndo::SetSaveData( SwDoc& rDoc, SwRedlineSaveDatas& rSData )
 {
     RedlineMode_t eOld = rDoc.getIDocumentRedlineAccess().GetRedlineMode();
     rDoc.getIDocumentRedlineAccess().SetRedlineMode_intern( (RedlineMode_t)(( eOld & ~nsRedlineMode_t::REDLINE_IGNORE) | nsRedlineMode_t::REDLINE_ON ));
     SwPaM aPam( rDoc.GetNodes().GetEndOfContent() );
 
     for( size_t n = rSData.size(); n; )
-        rSData[ --n ]->RedlineToDoc( aPam );
+        rSData[ --n ].RedlineToDoc( aPam );
 
 #if OSL_DEBUG_LEVEL > 0
     // check redline count against count saved in RedlineSaveData object
     assert(rSData.empty() ||
-           (rSData[0]->nRedlineCount == rDoc.getIDocumentRedlineAccess().GetRedlineTbl().size()));
+           (rSData[0].nRedlineCount == rDoc.getIDocumentRedlineAccess().GetRedlineTbl().size()));
             // "redline count not restored properly"
 #endif
 
@@ -1088,7 +1064,7 @@ void SwUndo::SetSaveData( SwDoc& rDoc, const SwRedlineSaveDatas& rSData )
 bool SwUndo::HasHiddenRedlines( const SwRedlineSaveDatas& rSData )
 {
     for( size_t n = rSData.size(); n; )
-        if( rSData[ --n ]->GetMvSttIdx() )
+        if( rSData[ --n ].GetMvSttIdx() )
             return true;
     return false;
 }
@@ -1101,8 +1077,8 @@ bool SwUndo::CanRedlineGroup( SwRedlineSaveDatas& rCurr,
 
     for( size_t n = 0; n < rCurr.size(); ++n )
     {
-        const SwRedlineSaveData& rSet = *rCurr[ n ];
-        const SwRedlineSaveData& rGet = *rCheck[ n ];
+        const SwRedlineSaveData& rSet = rCurr[ n ];
+        const SwRedlineSaveData& rGet = rCheck[ n ];
         if( rSet.nSttNode != rGet.nSttNode ||
             rSet.GetMvSttIdx() || rGet.GetMvSttIdx() ||
             ( bCurrIsEnd ? rSet.nSttCntnt != rGet.nEndCntnt
@@ -1115,8 +1091,8 @@ bool SwUndo::CanRedlineGroup( SwRedlineSaveDatas& rCurr,
 
     for( size_t n = 0; n < rCurr.size(); ++n )
     {
-        SwRedlineSaveData& rSet = *rCurr[ n ];
-        const SwRedlineSaveData& rGet = *rCheck[ n ];
+        SwRedlineSaveData& rSet = rCurr[ n ];
+        const SwRedlineSaveData& rGet = rCheck[ n ];
         if( bCurrIsEnd )
             rSet.nSttCntnt = rGet.nSttCntnt;
         else
@@ -1173,11 +1149,4 @@ bool IsDestroyFrameAnchoredAtChar(SwPosition const & rAnchorPos,
             );
 }
 
-void SwRedlineSaveDatas::DeleteAndDestroyAll()
-{
-    for( const_iterator it = begin(); it != end(); ++it )
-        delete *it;
-    clear();
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/undo/unredln.cxx b/sw/source/core/undo/unredln.cxx
index 1f0a49b..621454e 100644
--- a/sw/source/core/undo/unredln.cxx
+++ b/sw/source/core/undo/unredln.cxx
@@ -95,7 +95,7 @@ void SwUndoRedline::UndoImpl(::sw::UndoRedoContext & rContext)
         SetSaveData( *pDoc, *mpRedlSaveData );
         if( mbHiddenRedlines )
         {
-            mpRedlSaveData->DeleteAndDestroyAll();
+            mpRedlSaveData->clear();
 
             nEndExtra = pDoc->GetNodes().GetEndOfExtras().GetIndex() - nEndExtra;
             nSttNode += nEndExtra;


More information about the Libreoffice-commits mailing list