summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2014-10-01 14:54:59 +0900
committerMichael Stahl <mstahl@redhat.com>2014-10-01 19:56:11 +0000
commit8eae6dc82e85ede74a0676759f698bea79fb7fd9 (patch)
tree7bc301ff26604cebe857b8eeb90d04f0e0607615
parent4173bc5f7e1849a706c7cb9dcb34f7edfa9e7d1f (diff)
fdo#75757: remove inheritance to std::vector
from SwGrfFmtColls. Change-Id: I4dd83917584406704d1a52f85b8973f2714e9d0b Reviewed-on: https://gerrit.libreoffice.org/11731 Reviewed-by: Michael Stahl <mstahl@redhat.com> Tested-by: Michael Stahl <mstahl@redhat.com>
-rw-r--r--sw/inc/docary.hxx9
-rw-r--r--sw/source/core/doc/docnew.cxx28
2 files changed, 22 insertions, 15 deletions
diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx
index 0f753243c07c..333c91dad028 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 f64c32f67b51..2521962c12d6 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: */