From 1015cd4ff73ee25e55b4da8c8bc55a41e652da87 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 20 Jun 2012 16:36:51 +0200 Subject: Convert SV_DECL_PTRARR_DEL of Sw*Fmts to std::vector MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - I had to convert SwFrmFmts, SwSpzFrmFmts, SwCharFmts, SwSectionsFmts, SwTextFormatColl, SwGrfFmtColl all together because of the code that wants to work with any of them. - Introduce a pure virtual base class SwFmtsBase, since there are a handful of methods that want to work with any of the std::vector types. - the class SwSpzFrmFmts was dropped, and the code changed to use SwFrmFmts instead, since the 2 types are identical. Change-Id: I8c4056b5aedd574a33666e2d649a8b849958441c Signed-off-by: Fridrich Štrba --- sw/inc/docary.hxx | 75 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 63 insertions(+), 12 deletions(-) (limited to 'sw/inc/docary.hxx') diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx index 2a8642229da0..6c7f99402d03 100644 --- a/sw/inc/docary.hxx +++ b/sw/inc/docary.hxx @@ -33,6 +33,7 @@ #include class SwFieldType; +class SwFmt; class SwFrmFmt; class SwCharFmt; class SwTOXType; @@ -42,6 +43,8 @@ class SwNumRule; class SwRedline; class SwUnoCrsr; class SwOLENode; +class SwTxtFmtColl; +class SwGrfFmtColl; namespace com { namespace sun { namespace star { namespace i18n { struct ForbiddenCharacters; // comes from the I18N UNO interface @@ -50,18 +53,70 @@ namespace com { namespace sun { namespace star { namespace i18n { #include #include -// PageDescriptor-interface -// typedef SwPageDesc * SwPageDescPtr; -// SV_DECL_PTRARR_DEL(SwPageDescs, SwPageDescPtr,1); +// provides some methods for generic operations on lists that contain +// SwFmt* subclasses. +class SwFmtsBase +{ +public: + virtual size_t GetFmtCount() const = 0; + virtual SwFmt* GetFmt(size_t idx) const = 0; + virtual ~SwFmtsBase() = 0; +}; -typedef SwFrmFmt* SwFrmFmtPtr; -SV_DECL_PTRARR_DEL(SwFrmFmts,SwFrmFmtPtr,4) +class SwGrfFmtColls : public std::vector, 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() {} +}; // Specific frame formats (frames, DrawObjects). -SV_DECL_PTRARR_DEL(SwSpzFrmFmts,SwFrmFmtPtr,0) +class SW_DLLPUBLIC SwFrmFmts : public std::vector, 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 SwFrmFmt* pFmt) const; + bool Contains(const SwFrmFmt* pFmt) const; + // free's any remaining child objects + virtual ~SwFrmFmts(); +}; -typedef SwCharFmt* SwCharFmtPtr; -SV_DECL_PTRARR_DEL(SwCharFmts,SwCharFmtPtr,4) +class SwCharFmts : public std::vector, 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 SwCharFmt* pFmt) const; + bool Contains(const SwCharFmt* pFmt) const; + // free's any remaining child objects + virtual ~SwCharFmts(); +}; + +class SwTxtFmtColls : public std::vector, 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 SwTxtFmtColl* pFmt) const; + bool Contains(const SwTxtFmtColl* pFmt) const; + virtual ~SwTxtFmtColls() {} +}; + +// Array of Undo-history. +class SW_DLLPUBLIC SwSectionFmts : public std::vector, 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 SwSectionFmt* pFmt) const; + bool Contains(const SwSectionFmt* pFmt) const; + // free's any remaining child objects + virtual ~SwSectionFmts(); +}; class SwFldTypes : public std::vector { public: @@ -77,10 +132,6 @@ public: sal_uInt16 GetPos(const SwTOXType* pTOXType) const; }; -// Array of Undo-history. -typedef SwSectionFmt* SwSectionFmtPtr; -SV_DECL_PTRARR_DEL(SwSectionFmts,SwSectionFmtPtr,0) - class SW_DLLPUBLIC SwNumRuleTbl : public std::vector { public: // the destructor will free all objects still in the vector -- cgit