summaryrefslogtreecommitdiff
path: root/sw/source/filter/ww8
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/source/filter/ww8
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/source/filter/ww8')
-rw-r--r--sw/source/filter/ww8/writerhelper.cxx19
1 files changed, 12 insertions, 7 deletions
diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx
index d903255a557c..228bc59ff5a5 100644
--- a/sw/source/filter/ww8/writerhelper.cxx
+++ b/sw/source/filter/ww8/writerhelper.cxx
@@ -118,16 +118,24 @@ namespace
sw::Frames SwPosFlyFrmsToFrames(const SwPosFlyFrms &rFlys)
{
sw::Frames aRet;
- for(SwPosFlyFrms::const_reverse_iterator it = rFlys.rbegin(); it != rFlys.rend(); ++it)
+
+ for(SwPosFlyFrms::const_iterator aIter(rFlys.begin()); aIter != rFlys.end(); ++aIter)
{
- const SwFrmFmt &rEntry = (*it)->GetFmt();
+ const SwFrmFmt &rEntry = (*aIter)->GetFmt();
+
if (const SwPosition* pAnchor = rEntry.GetAnchor().GetCntntAnchor())
+ {
aRet.push_back(sw::Frame(rEntry, *pAnchor));
+ }
else
{
- SwPosition aPos((*it)->GetNdIndex());
+ SwPosition aPos((*aIter)->GetNdIndex());
+
if (SwTxtNode* pTxtNd = aPos.nNode.GetNode().GetTxtNode())
+ {
aPos.nContent.Assign(pTxtNd, 0);
+ }
+
aRet.push_back(sw::Frame(rEntry, aPos));
}
}
@@ -514,11 +522,8 @@ namespace sw
*/
Frames GetFrames(const SwDoc &rDoc, SwPaM *pPaM /*, bool bAll*/)
{
- SwPosFlyFrms aFlys;
- rDoc.GetAllFlyFmts(aFlys, pPaM, true);
+ SwPosFlyFrms aFlys(rDoc.GetAllFlyFmts(pPaM, true));
sw::Frames aRet(SwPosFlyFrmsToFrames(aFlys));
- for(SwPosFlyFrms::const_reverse_iterator it = aFlys.rbegin(); it != aFlys.rend(); ++it)
- delete *it;
return aRet;
}