summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-06-05 15:32:32 +0200
committerCaolán McNamara <caolanm@redhat.com>2015-07-20 20:01:31 +0000
commit2acb668ad89a9e023561f39df7891be1ee454391 (patch)
treef273caab2b3d8542cfd5c7816b4c15c4246a6384 /sw
parentd4e89800a477609775152e859623bd3f317d423c (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 (cherry picked from commit ab706f85bb777ba160712c072c9d2a08ebcddcc6) Reviewed-on: https://gerrit.libreoffice.org/17231 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/filter/ww8/writerhelper.cxx22
-rw-r--r--sw/source/filter/ww8/writerhelper.hxx4
-rw-r--r--sw/source/filter/ww8/wrtww8.cxx3
3 files changed, 28 insertions, 1 deletions
diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx
index 9a0846612ba0..cf762a6237f4 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 dbd033e42ab5..bbef36303424 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 611559e083d3..9dad99d8a424 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -3107,6 +3107,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();