summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2019-04-17 15:43:33 +0200
committerMichael Stahl <Michael.Stahl@cib.de>2019-04-26 15:55:06 +0200
commiteca4f30e430bf34dd52f7583f962860012933413 (patch)
tree1947b005f21256abf15ff4e3fa3ecccaa41b3958
parent6ec6d013227e66156e00c1d5ac9d0d2ddd208fae (diff)
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.Stahl@cib.de> Tested-by: Michael Stahl <Michael.Stahl@cib.de>
-rw-r--r--sw/source/core/doc/doctxm.cxx2
-rw-r--r--sw/source/core/inc/txmsrt.hxx4
-rw-r--r--sw/source/core/tox/txmsrt.cxx16
-rw-r--r--sw/source/core/undo/rolbck.cxx9
4 files changed, 22 insertions, 9 deletions
diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx
index 6210e4b4b6a9..d1dd7e59139d 100644
--- a/sw/source/core/doc/doctxm.cxx
+++ b/sw/source/core/doc/doctxm.cxx
@@ -1301,7 +1301,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 887d987da85c..a722921acdba 100644
--- a/sw/source/core/inc/txmsrt.hxx
+++ b/sw/source/core/inc/txmsrt.hxx
@@ -240,7 +240,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 6261095ec992..b394ee4bd688 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 1c5e6098f0d2..1fc7850b6de1 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();
}
SwHistoryNoTextFieldmark::SwHistoryNoTextFieldmark(const ::sw::mark::IFieldmark& rFieldMark)