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

Takeshi Abe tabe at fixedpoint.jp
Wed Oct 1 12:56:32 PDT 2014


 sw/inc/docary.hxx             |    9 ++++++++-
 sw/source/core/doc/docnew.cxx |   28 ++++++++++++++--------------
 2 files changed, 22 insertions(+), 15 deletions(-)

New commits:
commit 8eae6dc82e85ede74a0676759f698bea79fb7fd9
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Wed Oct 1 14:54:59 2014 +0900

    fdo#75757: remove inheritance to std::vector
    
    from SwGrfFmtColls.
    
    Change-Id: I4dd83917584406704d1a52f85b8973f2714e9d0b
    Reviewed-on: https://gerrit.libreoffice.org/11731
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx
index 0f75324..333c91d 100644
--- a/sw/inc/docary.hxx
+++ b/sw/inc/docary.hxx
@@ -60,11 +60,18 @@ public:
     virtual ~SwFmtsBase() = 0;
 };
 
-class SwGrfFmtColls : public std::vector<SwGrfFmtColl*>, public SwFmtsBase
+class SwGrfFmtColls : public SwFmtsBase
 {
+private:
+    std::vector<SwGrfFmtColl*> mvColls;
+
 public:
     virtual size_t GetFmtCount() const SAL_OVERRIDE { return size(); }
     virtual SwFmt* GetFmt(size_t idx) const SAL_OVERRIDE { return (SwFmt*)operator[](idx); }
+    size_t size() const { return mvColls.size(); }
+    SwGrfFmtColl *operator[](size_t idx) const { return mvColls[idx]; }
+    void push_back(SwGrfFmtColl* pColl) { mvColls.push_back(pColl); }
+    void DeleteAndDestroy(int nStartIdx, int nEndIdx);
     sal_uInt16 GetPos(const SwGrfFmtColl* pFmt) const;
     /// free's any remaining child objects
     virtual ~SwGrfFmtColls() {}
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index f64c32f..2521962 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -406,16 +406,6 @@ static void DeleteAndDestroy(SwCharFmts& rFmts, int aStartIdx, int aEndIdx)
     rFmts.erase( rFmts.begin() + aStartIdx, rFmts.begin() + aEndIdx);
 }
 
-static void DeleteAndDestroy(SwGrfFmtColls& rFmts, int aStartIdx, int aEndIdx)
-{
-    if (aEndIdx < aStartIdx)
-        return;
-    for( SwGrfFmtColls::const_iterator it = rFmts.begin() + aStartIdx;
-         it != rFmts.begin() + aEndIdx; ++it )
-             delete *it;
-    rFmts.erase( rFmts.begin() + aStartIdx, rFmts.begin() + aEndIdx);
-}
-
 /**
  * Speciality: a member of the class SwDoc is located at
  * position 0 in the array of the Format and GDI objects.
@@ -557,7 +547,7 @@ SwDoc::~SwDoc()
     OSL_ENSURE( mpDfltGrfFmtColl == (*mpGrfFmtCollTbl)[0],
             "DefaultGrfCollection must always be at the start" );
 
-    DeleteAndDestroy(*mpGrfFmtCollTbl, 1, mpGrfFmtCollTbl->size());
+    mpGrfFmtCollTbl->DeleteAndDestroy(1, mpGrfFmtCollTbl->size());
     delete mpGrfFmtCollTbl;
 
     // Without explicitly freeing the DocumentDeviceManager
@@ -747,7 +737,7 @@ void SwDoc::ClearDoc()
     if( 2 < mpTxtFmtCollTbl->size() )
         DeleteAndDestroy(*mpTxtFmtCollTbl, 2, mpTxtFmtCollTbl->size());
     DeleteAndDestroy(*mpTxtFmtCollTbl, 1, mpTxtFmtCollTbl->size());
-    DeleteAndDestroy(*mpGrfFmtCollTbl, 1, mpGrfFmtCollTbl->size());
+    mpGrfFmtCollTbl->DeleteAndDestroy(1, mpGrfFmtCollTbl->size());
     DeleteAndDestroy(*mpCharFmtTbl, 1, mpCharFmtTbl->size());
 
     if( getIDocumentLayoutAccess().GetCurrentViewShell() )
@@ -1176,10 +1166,20 @@ sal_uInt16 SwTxtFmtColls::GetPos(const SwTxtFmtColl* p) const
     return it == end() ? USHRT_MAX : it - begin();
 }
 
+void SwGrfFmtColls::DeleteAndDestroy(int nStartIdx, int nEndIdx)
+{
+    if (nEndIdx < nStartIdx)
+        return;
+    for( std::vector<SwGrfFmtColl*>::const_iterator it = mvColls.begin() + nStartIdx;
+         it != mvColls.begin() + nEndIdx; ++it )
+             delete *it;
+    mvColls.erase( mvColls.begin() + nStartIdx, mvColls.begin() + nEndIdx);
+}
+
 sal_uInt16 SwGrfFmtColls::GetPos(const SwGrfFmtColl* p) const
 {
-    const_iterator it = std::find(begin(), end(), p);
-    return it == end() ? USHRT_MAX : it - begin();
+    std::vector<SwGrfFmtColl*>::const_iterator it = std::find(mvColls.begin(), mvColls.end(), p);
+    return it == mvColls.end() ? USHRT_MAX : it - mvColls.begin();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list