Kaydet (Commit) cced3906 authored tarafından Michael Stahl's avatar Michael Stahl Kaydeden (comit) Andras Timar

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 ab706f85)
Reviewed-on: https://gerrit.libreoffice.org/17231Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst a8969508
......@@ -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;
......
......@@ -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
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment