sw/inc/index.hxx | 2 +- sw/inc/pam.hxx | 4 ++-- sw/source/filter/ww8/writerhelper.cxx | 22 +++++++++++++++++++++- sw/source/filter/ww8/writerhelper.hxx | 4 ++++ sw/source/filter/ww8/wrtww8.cxx | 3 +++ 5 files changed, 31 insertions(+), 4 deletions(-)
New commits: commit ab706f85bb777ba160712c072c9d2a08ebcddcc6 Author: Michael Stahl <mst...@redhat.com> Date: Fri Jun 5 15:32:32 2015 +0200 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 diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx index f6b0b08..e8db7a7 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 cdefebc..c80e119 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 78168f3..432a287 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(); commit f1ecbd9e3541cbe0b8ae1075ab158f5e3f4a651a Author: Michael Stahl <mst...@redhat.com> Date: Fri Jun 5 14:41:08 2015 +0200 sw: let's export the debug-logging stuff so msword filters can use it Change-Id: I2caec82a89e44ee60bb49c6c0069dc30c8de400f diff --git a/sw/inc/index.hxx b/sw/inc/index.hxx index 3330861..e430fa8 100644 --- a/sw/inc/index.hxx +++ b/sw/inc/index.hxx @@ -109,7 +109,7 @@ public: void SetMark(const sw::mark::IMark* pMark); }; -std::ostream& operator <<(std::ostream& s, const SwIndex& index); +SW_DLLPUBLIC std::ostream& operator <<(std::ostream& s, const SwIndex& index); class SwIndexReg { diff --git a/sw/inc/pam.hxx b/sw/inc/pam.hxx index 4518954..40715b4 100644 --- a/sw/inc/pam.hxx +++ b/sw/inc/pam.hxx @@ -77,7 +77,7 @@ struct SW_DLLPUBLIC SwPosition void dumpAsXml(struct _xmlTextWriter* pWriter) const; }; -std::ostream &operator <<(std::ostream& s, const SwPosition& position); +SW_DLLPUBLIC std::ostream &operator <<(std::ostream& s, const SwPosition& position); // Result of comparing positions. enum SwComparePosition { @@ -322,7 +322,7 @@ public: void dumpAsXml(struct _xmlTextWriter* pWriter) const; }; -std::ostream &operator <<(std::ostream& s, const SwPaM& pam); +SW_DLLPUBLIC std::ostream &operator <<(std::ostream& s, const SwPaM& pam); bool CheckNodesRange( const SwNodeIndex&, const SwNodeIndex&, bool bChkSection ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits