summaryrefslogtreecommitdiff
path: root/sw/inc
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2012-06-29 11:39:59 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-05-13 20:38:19 +0100
commit72e54b69601dc44932d4a3c9882d24d2380ae3b7 (patch)
treedb36225f46e419198994713a2a9d25bcf1d50833 /sw/inc
parenta85f5b1ee0ccf5e1999f5452ce162e251191dd98 (diff)
Resolves: #i120106# implement a SwPosFlyFrms which avoids memory leaks
Use boost::shared_ptr and stl tools to implement a SwPosFlyFrms which can be used and handed over by value and cleans up it's content to avoid memory leaks. Found by: Chao Huang Patch by: Chao Huang, alg Review by: Chao Huang, alg (cherry picked from commit c26f80aa1ba65b63e313dce9c6d7e40ab8efede6) Conflicts: sw/inc/doc.hxx sw/inc/flypos.hxx sw/source/core/doc/doclay.cxx sw/source/core/layout/flypos.cxx sw/source/core/unocore/unoobj2.cxx sw/source/filter/html/htmlfly.cxx sw/source/filter/ww8/writerhelper.cxx Change-Id: If610457654b1056d799d4336cd249815f7878a96 Fix build breaker from i120106 Patch by: Chao Huang Suggested by: alg (cherry picked from commit 880aadbeba4e31049d5b7f0a34323553fb6249fb) Conflicts: sw/source/filter/ww8/writerhelper.cxx Change-Id: I516fcb6ee69944c54cc9eb76c069eb8b28749050
Diffstat (limited to 'sw/inc')
-rw-r--r--sw/inc/doc.hxx4
-rw-r--r--sw/inc/flypos.hxx15
2 files changed, 11 insertions, 8 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index d1956b84b921..f0b97f068010 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -53,6 +53,7 @@ class SwList;
#include <swatrset.hxx>
#include <toxe.hxx> // enums
#include <flyenum.hxx>
+#include <flypos.hxx>
#include <itabenum.hxx>
#include <swdbdata.hxx>
#include <chcmprse.hxx>
@@ -143,7 +144,6 @@ class SwNodes;
class SwNumRule;
class SwNumRuleTbl;
class SwPageDesc;
-class SwPosFlyFrms;
class SwPagePreViewPrtData;
class SwRedline;
class SwRedlineTbl;
@@ -1048,7 +1048,7 @@ public:
have to be surrounded completely by ::com::sun::star::awt::Selection.
( Start < Pos < End ) !!!
(Required for Writers.) */
- void GetAllFlyFmts( SwPosFlyFrms& rPosFlyFmts, const SwPaM* = 0,
+ SwPosFlyFrms GetAllFlyFmts( const SwPaM* = 0,
bool bDrawAlso = false,
bool bAsCharAlso = false ) const;
diff --git a/sw/inc/flypos.hxx b/sw/inc/flypos.hxx
index fadc98c43312..e7b9fa010267 100644
--- a/sw/inc/flypos.hxx
+++ b/sw/inc/flypos.hxx
@@ -19,8 +19,8 @@
#ifndef _FLYPOS_HXX
#define _FLYPOS_HXX
-
#include <swdllapi.h>
+#include <boost/shared_ptr.hpp>
#include <set>
class SwFrmFmt;
@@ -37,16 +37,19 @@ public:
SwPosFlyFrm( const SwNodeIndex& , const SwFrmFmt*, sal_uInt16 nArrPos );
virtual ~SwPosFlyFrm(); ///< Virtual for Writer (DLL !!)
- /// Operators for sort array.
- sal_Bool operator==( const SwPosFlyFrm& );
- sal_Bool operator<( const SwPosFlyFrm& );
-
const SwFrmFmt& GetFmt() const { return *pFrmFmt; }
const SwNodeIndex& GetNdIndex() const { return *pNdIdx; }
sal_uInt32 GetOrdNum() const { return nOrdNum; }
};
-class SwPosFlyFrms : public std::multiset<SwPosFlyFrm*> {};
+// define needed classes to safely handle an array of allocated SwPosFlyFrm(s).
+// SwPosFlyFrms can be handled by value (as return value), only refcounts to
+// contained SwPosFlyFrm* will be copied. When releasing the last SwPosFlyFrmPtr
+// instance the allocated instance will be freed. The array is sorted by
+// GetNdIndex by using a ::std::set container.
+typedef ::boost::shared_ptr< SwPosFlyFrm > SwPosFlyFrmPtr;
+struct SwPosFlyFrmCmp { bool operator()(const SwPosFlyFrmPtr& rA, const SwPosFlyFrmPtr& rB) const; };
+typedef ::std::set< SwPosFlyFrmPtr, SwPosFlyFrmCmp > SwPosFlyFrms;
#endif // _FLYPOS_HXX