diff options
author | Michael Stahl <mstahl@redhat.com> | 2015-06-05 15:32:32 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2015-06-05 15:35:22 +0200 |
commit | ab706f85bb777ba160712c072c9d2a08ebcddcc6 (patch) | |
tree | b9761c24839258ede0942c06c08aed146a222f96 | |
parent | f1ecbd9e3541cbe0b8ae1075ab158f5e3f4a651a (diff) |
sw: WW8 export: avoid invalidated positions in sw::Frames
When exporting ooo67907-1.doc we get ~SwIndexReg assert because there's
a frame anchored in a redline, and the SwPosition in the sw::Frame for
it is invalidated during SetRedlineMode because the node it points to is
deleted. Add another horrible workaround to the redline trainwreck.
Change-Id: Ia9b2393c77f42502862daaa30fd54eb3b040a214
-rw-r--r-- | sw/source/filter/ww8/writerhelper.cxx | 22 | ||||
-rw-r--r-- | sw/source/filter/ww8/writerhelper.hxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtww8.cxx | 3 |
3 files changed, 28 insertions, 1 deletions
diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx index f6b0b08af8e2..e8db7a7a6092 100644 --- a/sw/source/filter/ww8/writerhelper.cxx +++ b/sw/source/filter/ww8/writerhelper.cxx @@ -126,7 +126,11 @@ namespace if (const SwPosition* pAnchor = rEntry.GetAnchor().GetContentAnchor()) { - aRet.push_back(sw::Frame(rEntry, *pAnchor)); + // the anchor position will be invalidated by SetRedlineMode + // so set a dummy position and fix it in UpdateFramePositions + SwPosition const dummy(SwNodeIndex( + const_cast<SwNodes&>(pAnchor->nNode.GetNodes()))); + aRet.push_back(sw::Frame(rEntry, dummy)); } else { @@ -522,6 +526,22 @@ namespace sw return aRet; } + void UpdateFramePositions(Frames & rFrames) + { + for (Frame & rFrame : rFrames) + { + SwFormatAnchor const& rAnchor = rFrame.GetFrameFormat().GetAnchor(); + if (SwPosition const*const pAnchor = rAnchor.GetContentAnchor()) + { + rFrame.SetPosition(*pAnchor); + } + else + { // these don't need to be corrected, they're not in redlines + assert(FLY_AT_PAGE == rAnchor.GetAnchorId()); + } + } + } + Frames GetFramesInNode(const Frames &rFrames, const SwNode &rNode) { Frames aRet; diff --git a/sw/source/filter/ww8/writerhelper.hxx b/sw/source/filter/ww8/writerhelper.hxx index cdefebc386cb..c80e11990325 100644 --- a/sw/source/filter/ww8/writerhelper.hxx +++ b/sw/source/filter/ww8/writerhelper.hxx @@ -126,6 +126,7 @@ namespace sw The anchor position of this frame */ const SwPosition &GetPosition() const { return maPos; } + void SetPosition(SwPosition const& rPos) { maPos = rPos; } /** Get the node this frame is anchored into @@ -633,6 +634,9 @@ namespace sw */ Frames GetFrames(const SwDoc &rDoc, SwPaM *pPaM = 0); + /** fix up frame positions, must be called after SetRedlineMode */ + void UpdateFramePositions(Frames & rFrames); + /** Get the Frames anchored to a given node Given a container of frames, find the ones anchored to a given node diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index 78168f3caae4..432a287dc193 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -3060,6 +3060,9 @@ void MSWordExportBase::ExportDocument( bool bWriteAll ) nsRedlineMode_t::REDLINE_SHOW_INSERT); } + // fix the SwPositions in m_aFrames after SetRedlineMode + UpdateFramePositions(m_aFrames); + m_aFontHelper.InitFontTable( SupportsUnicode(), *m_pDoc ); GatherChapterFields(); |