summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sw/inc/docary.hxx135
-rw-r--r--sw/source/core/doc/doc.cxx12
-rw-r--r--sw/source/core/doc/docbasic.cxx4
-rw-r--r--sw/source/core/doc/docfmt.cxx36
-rw-r--r--sw/source/core/doc/docnew.cxx12
-rw-r--r--sw/source/core/docnode/section.cxx18
-rw-r--r--sw/source/core/fields/fldbas.cxx12
-rw-r--r--sw/source/core/tox/tox.cxx11
-rw-r--r--sw/source/core/undo/unattr.cxx12
-rw-r--r--sw/source/core/undo/undobj1.cxx4
10 files changed, 85 insertions, 171 deletions
diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx
index 6b9636ee27fd..94b077ac8f80 100644
--- a/sw/inc/docary.hxx
+++ b/sw/inc/docary.hxx
@@ -25,19 +25,18 @@
#include <algorithm>
#include <o3tl/sorted_vector.hxx>
-class SwFieldType;
-class SwFmt;
-class SwFrmFmt;
-class SwCharFmt;
-class SwTOXType;
-class SwUndo;
-class SwSectionFmt;
-class SwNumRule;
-class SwRedline;
-class SwUnoCrsr;
-class SwOLENode;
-class SwTxtFmtColl;
-class SwGrfFmtColl;
+#include "charfmt.hxx"
+#include "fldbas.hxx"
+#include "fmtcol.hxx"
+#include "frmfmt.hxx"
+#include "numrule.hxx"
+#include "section.hxx"
+#include "tox.hxx"
+#include "unocrsr.hxx"
+#include "redline.hxx"
+
+class SwRangeRedline;
+class SwExtraRedline;
namespace com { namespace sun { namespace star { namespace i18n {
struct ForbiddenCharacters; ///< comes from the I18N UNO interface
@@ -52,93 +51,109 @@ class SwFmtsBase
{
public:
virtual size_t GetFmtCount() const = 0;
- virtual SwFmt* GetFmt(size_t idx) const = 0;
- virtual ~SwFmtsBase() = 0;
+ virtual SwFmt* GetFmt(size_t) const = 0;
+ virtual ~SwFmtsBase() {}
};
-class SwGrfFmtColls : public std::vector<SwGrfFmtColl*>, public SwFmtsBase
+template<typename Value>
+class SwFmtsBaseModify : public std::vector<Value>, public SwFmtsBase
{
public:
- virtual size_t GetFmtCount() const { return size(); }
- virtual SwFmt* GetFmt(size_t idx) const { return (SwFmt*)operator[](idx); }
- sal_uInt16 GetPos(const SwGrfFmtColl* pFmt) const;
- /// free's any remaining child objects
- virtual ~SwGrfFmtColls() {}
+ typedef std::vector<Value>::const_iterator const_iterator;
+
+private:
+ const bool mCleanup;
+
+public:
+ SwFmtsBaseModify(bool cleanup = true) : mCleanup(cleanup) {}
+
+ using std::vector<Value>::begin;
+ using std::vector<Value>::end;
+
+ // free any remaining child objects based on mCleanup
+ virtual ~SwFmtsBaseModify()
+ {
+ if (mCleanup)
+ for(const_iterator it = begin(); it != end(); ++it)
+ delete *it;
+ }
+
+ sal_uInt16 GetPos(Value const& p) const
+ {
+ const_iterator const it = std::find(begin(), end(), p);
+ return it == end() ? USHRT_MAX : it - begin();
+ }
+ bool Contains(Value const& p) const
+ { return std::find(begin(), end(), p) != end(); }
+ virtual size_t GetFmtCount() const SAL_OVERRIDE
+ { return std::vector<Value>::size(); }
+ virtual SwFmt* GetFmt(size_t idx) const SAL_OVERRIDE
+ { return (SwFmt*) std::vector<Value>::operator[](idx); }
+ void dumpAsXml(xmlTextWriterPtr) {};
};
-/// stupid base class to work around MSVC dllexport mess
-class SAL_DLLPUBLIC_TEMPLATE SwFrmFmts_Base : public std::vector<SwFrmFmt*> {};
+class SwGrfFmtColls : public SwFmtsBaseModify<SwGrfFmtColl*>
+{
+public:
+ SwGrfFmtColls() : SwFmtsBaseModify( false ) {}
+ virtual ~SwGrfFmtColls() {}
+};
/// Specific frame formats (frames, DrawObjects).
-class SW_DLLPUBLIC SwFrmFmts : public SwFrmFmts_Base, public SwFmtsBase
+class SW_DLLPUBLIC SwFrmFmts : public SwFmtsBaseModify<SwFrmFmt*>
{
public:
- virtual size_t GetFmtCount() const { return size(); }
- virtual SwFmt* GetFmt(size_t idx) const { return (SwFmt*)operator[](idx); }
- sal_uInt16 GetPos(const SwFrmFmt* pFmt) const;
- bool Contains(const SwFrmFmt* pFmt) const;
- /// free's any remaining child objects
- virtual ~SwFrmFmts();
+ virtual ~SwFrmFmts() {}
+ void dumpAsXml(xmlTextWriterPtr w, const char* pName);
};
-class SwCharFmts : public std::vector<SwCharFmt*>, public SwFmtsBase
+class SwCharFmts : public SwFmtsBaseModify<SwCharFmt*>
{
public:
- virtual size_t GetFmtCount() const { return size(); }
- virtual SwFmt* GetFmt(size_t idx) const { return (SwFmt*)operator[](idx); }
- sal_uInt16 GetPos(const SwCharFmt* pFmt) const;
- bool Contains(const SwCharFmt* pFmt) const;
- /// free's any remaining child objects
- virtual ~SwCharFmts();
+ virtual ~SwCharFmts() {}
+ void dumpAsXml(xmlTextWriterPtr w);
};
-class SwTxtFmtColls : public std::vector<SwTxtFmtColl*>, public SwFmtsBase
+class SwTxtFmtColls : public SwFmtsBaseModify<SwTxtFmtColl*>
{
public:
- virtual size_t GetFmtCount() const { return size(); }
- virtual SwFmt* GetFmt(size_t idx) const { return (SwFmt*)operator[](idx); }
- sal_uInt16 GetPos(const SwTxtFmtColl* pFmt) const;
+ SwTxtFmtColls() : SwFmtsBaseModify( false ) {}
virtual ~SwTxtFmtColls() {}
+ void dumpAsXml(xmlTextWriterPtr w);
};
/// Array of Undo-history.
-class SW_DLLPUBLIC SwSectionFmts : public std::vector<SwSectionFmt*>, public SwFmtsBase
+class SW_DLLPUBLIC SwSectionFmts : public SwFmtsBaseModify<SwSectionFmt*>
{
public:
- virtual size_t GetFmtCount() const { return size(); }
- virtual SwFmt* GetFmt(size_t idx) const { return (SwFmt*)operator[](idx); }
- sal_uInt16 GetPos(const SwSectionFmt* pFmt) const;
- bool Contains(const SwSectionFmt* pFmt) const;
- /// free's any remaining child objects
- virtual ~SwSectionFmts();
+ virtual ~SwSectionFmts() {}
+ void dumpAsXml(xmlTextWriterPtr w);
};
-class SwFldTypes : public std::vector<SwFieldType*> {
+class SwFldTypes : public SwFmtsBaseModify<SwFieldType*>
+{
public:
- /// the destructor will free all objects still in the vector
- ~SwFldTypes();
- sal_uInt16 GetPos(const SwFieldType* pFieldType) const;
+ virtual ~SwFldTypes() {}
void dumpAsXml(xmlTextWriterPtr w);
};
-class SwTOXTypes : public std::vector<SwTOXType*> {
+class SwTOXTypes : public SwFmtsBaseModify<SwTOXType*>
+{
public:
- /// the destructor will free all objects still in the vector
- ~SwTOXTypes();
- sal_uInt16 GetPos(const SwTOXType* pTOXType) const;
+ virtual ~SwTOXTypes() {}
};
-class SW_DLLPUBLIC SwNumRuleTbl : public std::vector<SwNumRule*> {
+class SW_DLLPUBLIC SwNumRuleTbl : public SwFmtsBaseModify<SwNumRule*> {
public:
- /// the destructor will free all objects still in the vector
- ~SwNumRuleTbl();
- sal_uInt16 GetPos(const SwNumRule* pRule) const;
+ virtual ~SwNumRuleTbl() {}
+ void dumpAsXml(xmlTextWriterPtr w);
};
struct CompareSwRedlineTbl
{
bool operator()(SwRedline* const &lhs, SwRedline* const &rhs) const;
};
+
class _SwRedlineTbl
: public o3tl::sorted_vector<SwRedline*, CompareSwRedlineTbl,
o3tl::find_partialorder_ptrequals>
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 8cf4f11aae04..eb63e1f7d01d 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -2704,16 +2704,4 @@ void SwDoc::setExternalData(::sw::tExternalDataType eType,
return m_externalData[eType];
}
-sal_uInt16 SwNumRuleTbl::GetPos(const SwNumRule* pRule) const
-{
- const_iterator it = std::find(begin(), end(), pRule);
- return it == end() ? USHRT_MAX : it - begin();
-}
-
-SwNumRuleTbl::~SwNumRuleTbl()
-{
- for(const_iterator it = begin(); it != end(); ++it)
- delete *it;
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/docbasic.cxx b/sw/source/core/doc/docbasic.cxx
index 1437e6135e15..34a925c1f49c 100644
--- a/sw/source/core/doc/docbasic.cxx
+++ b/sw/source/core/doc/docbasic.cxx
@@ -162,7 +162,7 @@ sal_uInt16 SwDoc::CallEvent( sal_uInt16 nEvent, const SwCallMouseEvent& rCallEve
case EVENT_OBJECT_URLITEM:
case EVENT_OBJECT_IMAGE:
{
- const SwFrmFmt* pFmt = (SwFrmFmt*)rCallEvent.PTR.pFmt;
+ SwFrmFmt* pFmt = (SwFrmFmt*)rCallEvent.PTR.pFmt;
if( bCheckPtr )
{
if ( GetSpzFrmFmts()->Contains( pFmt ) )
@@ -178,7 +178,7 @@ sal_uInt16 SwDoc::CallEvent( sal_uInt16 nEvent, const SwCallMouseEvent& rCallEve
const IMapObject* pIMapObj = rCallEvent.PTR.IMAP.pIMapObj;
if( bCheckPtr )
{
- const SwFrmFmt* pFmt = (SwFrmFmt*)rCallEvent.PTR.IMAP.pFmt;
+ SwFrmFmt* pFmt = (SwFrmFmt*)rCallEvent.PTR.IMAP.pFmt;
const ImageMap* pIMap;
if( GetSpzFrmFmts()->Contains( pFmt ) &&
0 != (pIMap = pFmt->GetURL().GetMap()) )
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index 11de2dc5de1c..a4e9b74c1f81 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -2655,40 +2655,4 @@ namespace docfunc
}
}
-SwFmtsBase::~SwFmtsBase() {}
-
-sal_uInt16 SwFrmFmts::GetPos(const SwFrmFmt* p) const
-{
- const_iterator it = std::find(begin(), end(), p);
- return it == end() ? USHRT_MAX : it - begin();
-}
-
-bool SwFrmFmts::Contains(const SwFrmFmt* p) const
-{
- return std::find(begin(), end(), p) != end();
-}
-
-SwFrmFmts::~SwFrmFmts()
-{
- for(const_iterator it = begin(); it != end(); ++it)
- delete *it;
-}
-
-sal_uInt16 SwCharFmts::GetPos(const SwCharFmt* p) const
-{
- const_iterator it = std::find(begin(), end(), p);
- return it == end() ? USHRT_MAX : it - begin();
-}
-
-bool SwCharFmts::Contains(const SwCharFmt* p) const
-{
- return std::find(begin(), end(), p) != end();
-}
-
-SwCharFmts::~SwCharFmts()
-{
- for(const_iterator it = begin(); it != end(); ++it)
- delete *it;
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index d5841dd1c259..a055e200758b 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -1397,16 +1397,4 @@ else
pTargetShell->EndAllAction();
}
-sal_uInt16 SwTxtFmtColls::GetPos(const SwTxtFmtColl* p) const
-{
- const_iterator it = std::find(begin(), end(), p);
- return it == end() ? USHRT_MAX : it - begin();
-}
-
-sal_uInt16 SwGrfFmtColls::GetPos(const SwGrfFmtColl* p) const
-{
- const_iterator it = std::find(begin(), end(), p);
- return it == end() ? USHRT_MAX : it - begin();
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx
index 54c3e589505d..1cccf10df161 100644
--- a/sw/source/core/docnode/section.cxx
+++ b/sw/source/core/docnode/section.cxx
@@ -1706,22 +1706,4 @@ sal_Bool SwIntrnlSectRefLink::IsInRange( sal_uLong nSttNd, sal_uLong nEndNd,
pSttNd->EndOfSectionIndex() < nEndNd;
}
-sal_uInt16 SwSectionFmts::GetPos(const SwSectionFmt* p) const
-{
- const_iterator it = std::find(begin(), end(), p);
- return it == end() ? USHRT_MAX : it - begin();
-}
-
-bool SwSectionFmts::Contains(const SwSectionFmt* p) const
-{
- return std::find(begin(), end(), p) != end();
-}
-
-SwSectionFmts::~SwSectionFmts()
-{
- for(const_iterator it = begin(); it != end(); ++it)
- delete *it;
-}
-
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx
index da56d0dd1446..b8cb8514a9e7 100644
--- a/sw/source/core/fields/fldbas.cxx
+++ b/sw/source/core/fields/fldbas.cxx
@@ -771,16 +771,4 @@ bool SwField::IsClickable() const
return false;
}
-sal_uInt16 SwFldTypes::GetPos(const SwFieldType* pFieldType) const
-{
- const_iterator it = std::find(begin(), end(), pFieldType);
- return it == end() ? USHRT_MAX : it - begin();
-}
-
-SwFldTypes::~SwFldTypes()
-{
- for(const_iterator it = begin(); it != end(); ++it)
- delete *it;
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/tox/tox.cxx b/sw/source/core/tox/tox.cxx
index 8b989891974c..a09062261753 100644
--- a/sw/source/core/tox/tox.cxx
+++ b/sw/source/core/tox/tox.cxx
@@ -924,15 +924,4 @@ const SwFormTokens& SwForm::GetPattern(sal_uInt16 nLevel) const
return aPattern[nLevel];
}
-sal_uInt16 SwTOXTypes::GetPos(const SwTOXType* pTOXType) const
-{
- const_iterator it = std::find(begin(), end(), pTOXType);
- return it == end() ? USHRT_MAX : it - begin();
-}
-
-SwTOXTypes::~SwTOXTypes()
-{
- for(const_iterator it = begin(); it != end(); ++it)
- delete *it;
-}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx
index 8a194d009b57..5f0474dba310 100644
--- a/sw/source/core/undo/unattr.cxx
+++ b/sw/source/core/undo/unattr.cxx
@@ -143,7 +143,7 @@ void SwUndoFmtAttr::Init()
else if ( RES_FRMFMT == m_nFmtWhich )
{
SwDoc* pDoc = m_pFmt->GetDoc();
- if ( pDoc->GetTblFrmFmts()->Contains(static_cast<const SwFrmFmt*>(m_pFmt)))
+ if ( pDoc->GetTblFrmFmts()->Contains(static_cast<SwFrmFmt*>(m_pFmt)))
{
// Table Format: save table position, table formats are volatile!
SwTable * pTbl = SwIterator<SwTable,SwFmt>::FirstElement( *m_pFmt );
@@ -153,7 +153,7 @@ void SwUndoFmtAttr::Init()
->FindTableNode()->GetIndex();
}
}
- else if ( pDoc->GetSections().Contains(static_cast<const SwSectionFmt*>(m_pFmt)))
+ else if ( pDoc->GetSections().Contains(static_cast<SwSectionFmt*>(m_pFmt)))
{
m_nNodeIndex = m_pFmt->GetCntnt().GetCntntIdx()->GetIndex();
}
@@ -231,12 +231,12 @@ bool SwUndoFmtAttr::IsFmtInDoc( SwDoc* pDoc )
{
case RES_TXTFMTCOLL:
nPos = pDoc->GetTxtFmtColls()->GetPos(
- static_cast<const SwTxtFmtColl*>(m_pFmt) );
+ static_cast<SwTxtFmtColl*>(m_pFmt) );
break;
case RES_GRFFMTCOLL:
nPos = pDoc->GetGrfFmtColls()->GetPos(
- static_cast<const SwGrfFmtColl*>(m_pFmt) );
+ static_cast<SwGrfFmtColl*>(m_pFmt) );
break;
case RES_CHRFMT:
@@ -283,11 +283,11 @@ bool SwUndoFmtAttr::IsFmtInDoc( SwDoc* pDoc )
case RES_DRAWFRMFMT:
case RES_FLYFRMFMT:
nPos = pDoc->GetSpzFrmFmts()->GetPos(
- static_cast<const SwFrmFmt*>(m_pFmt) );
+ static_cast<SwFrmFmt*>(m_pFmt) );
if ( USHRT_MAX == nPos )
{
nPos = pDoc->GetFrmFmts()->GetPos(
- static_cast<const SwFrmFmt*>(m_pFmt) );
+ static_cast<SwFrmFmt*>(m_pFmt) );
}
break;
}
diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx
index c99c19e97aab..56e0c8a1e6bc 100644
--- a/sw/source/core/undo/undobj1.cxx
+++ b/sw/source/core/undo/undobj1.cxx
@@ -533,7 +533,7 @@ void SwUndoSetFlyFmt::UndoImpl(::sw::UndoRedoContext & rContext)
SwDoc & rDoc = rContext.GetDoc();
// Is the new Format still existent?
- if( USHRT_MAX != rDoc.GetFrmFmts()->GetPos( (const SwFrmFmt*)pOldFmt ) )
+ if( USHRT_MAX != rDoc.GetFrmFmts()->GetPos( (SwFrmFmt*) pOldFmt ) )
{
if( bAnchorChgd )
pFrmFmt->DelFrms();
@@ -606,7 +606,7 @@ void SwUndoSetFlyFmt::RedoImpl(::sw::UndoRedoContext & rContext)
SwDoc & rDoc = rContext.GetDoc();
// Is the new Format still existent?
- if( USHRT_MAX != rDoc.GetFrmFmts()->GetPos( (const SwFrmFmt*)pNewFmt ) )
+ if( USHRT_MAX != rDoc.GetFrmFmts()->GetPos( (SwFrmFmt*) pNewFmt ) )
{
if( bAnchorChgd )