sw/source/core/doc/doctxm.cxx | 2 +- sw/source/core/inc/txmsrt.hxx | 4 +++- sw/source/core/tox/txmsrt.cxx | 16 +++++++++++++++- sw/source/core/undo/rolbck.cxx | 9 +++------ 4 files changed, 22 insertions(+), 9 deletions(-)
New commits: commit ba9561220a2c87557416b7dcf95294bdf3d693ce Author: Michael Stahl <michael.st...@cib.de> AuthorDate: Wed Apr 17 15:43:33 2019 +0200 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Sat Apr 27 15:33:58 2019 +0200 tdf#123313 sw: towards fixing ToX Update Undo wrt. CrossReference Revert "tdf#123313 sw: workaround Undo problem with ToX Update" This reverts commit 60ea01af8c57f9b03ee1da1196284fa10025c22c - it was quite simply a bad idea, and only pushed due to lack of time... Much better to refactor things so that any new CrossRefHeadingBookmark are inserted (with SwUndoInsBoomark) *before* nodes are inserted into the ToX. However! This patch does not fix the problem yet; that needs some more significant changes. Change-Id: If22e43b6a2112e5f53d0186bb7bed3ee007fe727 Reviewed-on: https://gerrit.libreoffice.org/71322 Reviewed-by: Michael Stahl <michael.st...@cib.de> Tested-by: Michael Stahl <michael.st...@cib.de> (cherry picked from commit eca4f30e430bf34dd52f7583f962860012933413) Reviewed-on: https://gerrit.libreoffice.org/71375 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index 5f32399ffa64..232436722432 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -1303,7 +1303,7 @@ void SwTOXBaseSection::UpdateSequence(const SwTextNode* pOwnChapterNode, const SwTextField* pTextField = pFormatField->GetTextField(); if(!pTextField) continue; - const SwTextNode& rTextNode = pTextField->GetTextNode(); + SwTextNode& rTextNode = pTextField->GetTextNode(); ::SetProgressState( 0, pDoc->GetDocShell() ); if (rTextNode.GetText().getLength() && diff --git a/sw/source/core/inc/txmsrt.hxx b/sw/source/core/inc/txmsrt.hxx index 4bfde6cbd42b..c208d0f49f13 100644 --- a/sw/source/core/inc/txmsrt.hxx +++ b/sw/source/core/inc/txmsrt.hxx @@ -237,7 +237,9 @@ private: struct SwTOXPara : public SwTOXSortTabBase { - SwTOXPara( const SwContentNode&, SwTOXElement, sal_uInt16 nLevel = FORM_ALPHA_DELIMITTER, const OUString& sSeqName = OUString() ); + SwTOXPara(SwContentNode&, SwTOXElement, + sal_uInt16 nLevel = FORM_ALPHA_DELIMITTER, + const OUString& sSeqName = OUString()); void SetStartIndex(sal_Int32 nSet) { nStartIndex = nSet; } void SetEndIndex(sal_Int32 nSet) { nEndIndex = nSet; } diff --git a/sw/source/core/tox/txmsrt.cxx b/sw/source/core/tox/txmsrt.cxx index 3cbb6549cd6c..ecae6fc1851b 100644 --- a/sw/source/core/tox/txmsrt.cxx +++ b/sw/source/core/tox/txmsrt.cxx @@ -509,7 +509,7 @@ sal_uInt16 SwTOXContent::GetLevel() const // TOX assembled from paragraphs // Watch out for OLE/graphics when sorting! // The position must not come from the document, but from the "anchor"! -SwTOXPara::SwTOXPara( const SwContentNode& rNd, SwTOXElement eT, sal_uInt16 nLevel, const OUString& sSeqName ) +SwTOXPara::SwTOXPara(SwContentNode& rNd, SwTOXElement eT, sal_uInt16 nLevel, const OUString& sSeqName) : SwTOXSortTabBase( TOX_SORT_PARA, &rNd, nullptr, nullptr ), eType( eT ), m_nLevel(nLevel), @@ -517,6 +517,18 @@ SwTOXPara::SwTOXPara( const SwContentNode& rNd, SwTOXElement eT, sal_uInt16 nLev nEndIndex(-1), m_sSequenceName( sSeqName ) { + // tdf#123313 create any missing bookmarks *before* generating ToX nodes! + switch (eType) + { + case SwTOXElement::Template: + case SwTOXElement::OutlineLevel: + assert(rNd.IsTextNode()); + rNd.GetDoc()->getIDocumentMarkAccess()->getMarkForTextNode( + *rNd.GetTextNode(), IDocumentMarkAccess::MarkType::CROSSREF_HEADING_BOOKMARK); + break; + default: + break; + } } TextAndReading SwTOXPara::GetText_Impl(SwRootFrame const*const pLayout) const @@ -652,6 +664,8 @@ OUString SwTOXPara::GetURL() const const SwTextNode * pTextNd = pNd->GetTextNode(); SwDoc* pDoc = const_cast<SwDoc*>( pTextNd->GetDoc() ); + // tdf#123313: this *must not* create a bookmark, its Undo would + // be screwed! create it as preparatory step, in ctor! ::sw::mark::IMark const * const pMark = pDoc->getIDocumentMarkAccess()->getMarkForTextNode( *pTextNd, IDocumentMarkAccess::MarkType::CROSSREF_HEADING_BOOKMARK); diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx index 51a4bcdd813f..b8048539f459 100644 --- a/sw/source/core/undo/rolbck.cxx +++ b/sw/source/core/undo/rolbck.cxx @@ -54,7 +54,6 @@ #include <charfmt.hxx> #include <strings.hrc> #include <bookmrk.hxx> -#include <crossrefbookmark.hxx> #include <memory> OUString SwHistoryHint::GetDescription() const @@ -670,11 +669,9 @@ void SwHistoryBookmark::SetInDoc( SwDoc* pDoc, bool ) bool SwHistoryBookmark::IsEqualBookmark(const ::sw::mark::IMark& rBkmk) { - return m_aName == rBkmk.GetName() - && ( ( m_nNode == rBkmk.GetMarkPos().nNode.GetIndex() - && m_nContent == rBkmk.GetMarkPos().nContent.GetIndex()) - // tdf#123313 these are created in middle of ToX update - || dynamic_cast<sw::mark::CrossRefHeadingBookmark const*>(&rBkmk)); + return m_nNode == rBkmk.GetMarkPos().nNode.GetIndex() + && m_nContent == rBkmk.GetMarkPos().nContent.GetIndex() + && m_aName == rBkmk.GetName(); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits