From fb741b48a4d11c1f91702a73ef600c7df976a298 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Wed, 27 Sep 2017 15:55:43 +0200 Subject: tdf#112679 sw: fix copying of fieldmarks Aha, now we know that the reason for the defensive programming in lcl_AssureFieldMarksSet() was that there are actually 2 different use-cases for it: usually a new mark is inserted, so there are no dummy characters and they must be inserted. However when copying text, the dummy characters are copied too, so they must not be inserted, or we get duplicate fieldmarks. This also reverts commit d4036d3a89b65a4912f62e3930eb1a31cd90a16b which fixed the problem only for CHECKBOX_FIELDMARK in a different way. (regression from bb069fe7b8b6a24f9ff4df4c7052961e17ea3a8c) (cherry picked from commit 421a23bb36bbf51edfabc58b7d2cd28ad37719d0) Silence --disable-assert-always-abort warnings (cherry picked from commit 7e76b983301b02dd7020636905b764b981b1fff0) loplugin:constparams (cherry picked from commit 14e2a82002042a3fe4d8866b635ee84a436a7a7c) Change-Id: I3c99b8c6d720951655198e682018794337859373 Reviewed-on: https://gerrit.libreoffice.org/42868 Tested-by: Jenkins Reviewed-by: Andras Timar --- sw/inc/IDocumentMarkAccess.hxx | 5 ++- sw/inc/IMark.hxx | 5 +++ sw/qa/core/macros-test.cxx | 6 ++- sw/qa/core/uwriter.cxx | 9 ++-- sw/qa/extras/uiwriter/uiwriter.cxx | 25 +++++++---- sw/source/core/crsr/annotationmark.cxx | 2 +- sw/source/core/crsr/bookmrk.cxx | 49 +++++++++++++++++----- sw/source/core/crsr/crbm.cxx | 2 +- .../core/doc/DocumentContentOperationsManager.cxx | 13 ++++-- sw/source/core/doc/docbm.cxx | 20 +++++---- sw/source/core/inc/MarkManager.hxx | 4 +- sw/source/core/inc/annotationmark.hxx | 2 +- sw/source/core/inc/bookmrk.hxx | 8 ++-- sw/source/core/undo/rolbck.cxx | 3 +- sw/source/core/unocore/unobkm.cxx | 2 +- sw/source/core/unocore/unoobj2.cxx | 2 +- sw/source/filter/basflt/fltshell.cxx | 2 +- sw/source/filter/html/swhtml.cxx | 3 +- sw/source/uibase/dbui/dbmgr.cxx | 3 +- sw/source/uibase/dochdl/swdtflvr.cxx | 3 +- 20 files changed, 119 insertions(+), 49 deletions(-) diff --git a/sw/inc/IDocumentMarkAccess.hxx b/sw/inc/IDocumentMarkAccess.hxx index 6bd844d0c59f..ff0a13cccbc4 100644 --- a/sw/inc/IDocumentMarkAccess.hxx +++ b/sw/inc/IDocumentMarkAccess.hxx @@ -72,12 +72,15 @@ class IDocumentMarkAccess @param eMark [in] the type of the new mark. + @param eMode + [in] is the new mark part of a text copy operation + @returns a pointer to the new mark (name might have changed). */ virtual ::sw::mark::IMark* makeMark(const SwPaM& rPaM, const OUString& rProposedName, - MarkType eMark) = 0; + MarkType eMark, ::sw::mark::InsertMode eMode) = 0; virtual sw::mark::IFieldmark* makeFieldBookmark( const SwPaM& rPaM, const OUString& rName, diff --git a/sw/inc/IMark.hxx b/sw/inc/IMark.hxx index 9ae6fb81d486..f4b38a9a189b 100644 --- a/sw/inc/IMark.hxx +++ b/sw/inc/IMark.hxx @@ -31,6 +31,11 @@ struct SwPosition; namespace sw { namespace mark { + enum class InsertMode + { + New, + CopyText, + }; class SW_DLLPUBLIC IMark : virtual public SwModify // inherited as interface diff --git a/sw/qa/core/macros-test.cxx b/sw/qa/core/macros-test.cxx index 88e4e1116304..05dea3607884 100644 --- a/sw/qa/core/macros-test.cxx +++ b/sw/qa/core/macros-test.cxx @@ -209,7 +209,8 @@ void SwMacrosTest::testBookmarkDeleteAndJoin() aPaM.Move(fnMoveForward, GoInDoc); IDocumentMarkAccess & rIDMA = *pDoc->getIDocumentMarkAccess(); sw::mark::IMark *pMark = - rIDMA.makeMark(aPaM, "test", IDocumentMarkAccess::MarkType::BOOKMARK); + rIDMA.makeMark(aPaM, "test", IDocumentMarkAccess::MarkType::BOOKMARK, + ::sw::mark::InsertMode::New); CPPUNIT_ASSERT(pMark); // select so pMark start position is on a node that is fully deleted aPaM.Move(fnMoveBackward, GoInNode); @@ -243,7 +244,8 @@ void SwMacrosTest::testBookmarkDeleteTdf90816() aPaM.Move(fnMoveBackward, GoInContent); IDocumentMarkAccess & rIDMA = *pDoc->getIDocumentMarkAccess(); sw::mark::IMark *pMark = - rIDMA.makeMark(aPaM, "test", IDocumentMarkAccess::MarkType::BOOKMARK); + rIDMA.makeMark(aPaM, "test", IDocumentMarkAccess::MarkType::BOOKMARK, + ::sw::mark::InsertMode::New); CPPUNIT_ASSERT(pMark); // delete the same selection as the bookmark diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx index 01c67e4f5395..ee0704824c2d 100644 --- a/sw/qa/core/uwriter.cxx +++ b/sw/qa/core/uwriter.cxx @@ -1238,19 +1238,22 @@ void SwDocTest::testMarkMove() m_pDoc->getIDocumentContentOperations().InsertString(aPaM, "Paragraph 1"); aPaM.SetMark(); aPaM.GetMark()->nContent -= aPaM.GetMark()->nContent.GetIndex(); - pMarksAccess->makeMark(aPaM, "Para1", IDocumentMarkAccess::MarkType::BOOKMARK); + pMarksAccess->makeMark(aPaM, "Para1", + IDocumentMarkAccess::MarkType::BOOKMARK, sw::mark::InsertMode::New); m_pDoc->getIDocumentContentOperations().AppendTextNode(*aPaM.GetPoint()); m_pDoc->getIDocumentContentOperations().InsertString(aPaM, "Paragraph 2"); aPaM.SetMark(); aPaM.GetMark()->nContent -= aPaM.GetMark()->nContent.GetIndex(); - pMarksAccess->makeMark(aPaM, "Para2", IDocumentMarkAccess::MarkType::BOOKMARK); + pMarksAccess->makeMark(aPaM, "Para2", + IDocumentMarkAccess::MarkType::BOOKMARK, sw::mark::InsertMode::New); m_pDoc->getIDocumentContentOperations().AppendTextNode(*aPaM.GetPoint()); m_pDoc->getIDocumentContentOperations().InsertString(aPaM, "Paragraph 3"); aPaM.SetMark(); aPaM.GetMark()->nContent -= aPaM.GetMark()->nContent.GetIndex(); - pMarksAccess->makeMark(aPaM, "Para3", IDocumentMarkAccess::MarkType::BOOKMARK); + pMarksAccess->makeMark(aPaM, "Para3", + IDocumentMarkAccess::MarkType::BOOKMARK, sw::mark::InsertMode::New); } // join paragraph 2 and 3 and check diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index d01b4bbcfb2a..7803895f2fba 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -430,7 +430,8 @@ void SwUiWriterTest::testBookmarkCopy() rIDCO.InsertString(aPaM, "bar"); aPaM.SetMark(); aPaM.MovePara(GoCurrPara, fnParaStart); - rIDMA.makeMark(aPaM, "Mark", IDocumentMarkAccess::MarkType::BOOKMARK); + rIDMA.makeMark(aPaM, "Mark", IDocumentMarkAccess::MarkType::BOOKMARK, + ::sw::mark::InsertMode::New); aPaM.Exchange(); aPaM.DeleteMark(); rIDCO.SplitNode(*aPaM.GetPoint(), false); @@ -1135,7 +1136,8 @@ void SwUiWriterTest::testBookmarkUndo() IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess(); SwPaM aPaM( SwNodeIndex(pDoc->GetNodes().GetEndOfContent(), -1) ); - pMarkAccess->makeMark(aPaM, "Mark", IDocumentMarkAccess::MarkType::BOOKMARK); + pMarkAccess->makeMark(aPaM, "Mark", IDocumentMarkAccess::MarkType::BOOKMARK, + ::sw::mark::InsertMode::New); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMarkAccess->getAllMarksCount()); rUndoManager.Undo(); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), pMarkAccess->getAllMarksCount()); @@ -1287,7 +1289,9 @@ void SwUiWriterTest::testTdf63214() aPaM.SetMark(); aPaM.Move(fnMoveForward, GoInContent); //Inserting a crossRefBookmark - pMarkAccess->makeMark(aPaM, "Bookmark", IDocumentMarkAccess::MarkType::CROSSREF_HEADING_BOOKMARK); + pMarkAccess->makeMark(aPaM, "Bookmark", + IDocumentMarkAccess::MarkType::CROSSREF_HEADING_BOOKMARK, + ::sw::mark::InsertMode::New); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMarkAccess->getAllMarksCount()); } //moving cursor to the end of paragraph @@ -1316,7 +1320,8 @@ void SwUiWriterTest::testTdf51741() IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess(); SwPaM aPaM( SwNodeIndex(pDoc->GetNodes().GetEndOfContent(), -1) ); //Modification 1 - pMarkAccess->makeMark(aPaM, "Mark", IDocumentMarkAccess::MarkType::BOOKMARK); + pMarkAccess->makeMark(aPaM, "Mark", IDocumentMarkAccess::MarkType::BOOKMARK, + ::sw::mark::InsertMode::New); CPPUNIT_ASSERT(pWrtShell->IsModified()); pWrtShell->ResetModified(); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMarkAccess->getAllMarksCount()); @@ -3439,13 +3444,17 @@ void SwUiWriterTest::testTdf94804() SwPaM* pCrsr = pDoc->GetEditShell()->GetCursor(); IDocumentMarkAccess* pIDMAccess(pDoc->getIDocumentMarkAccess()); //make first bookmark, CROSSREF_HEADING, with *empty* name - sw::mark::IMark* pMark1(pIDMAccess->makeMark(*pCrsr, "", IDocumentMarkAccess::MarkType::CROSSREF_HEADING_BOOKMARK)); + sw::mark::IMark* pMark1(pIDMAccess->makeMark(*pCrsr, "", + IDocumentMarkAccess::MarkType::CROSSREF_HEADING_BOOKMARK, + ::sw::mark::InsertMode::New)); //get the new(autogenerated) bookmark name rtl::OUString bookmark1name = pMark1->GetName(); //match the bookmark name, it should be like "__RefHeading__**" CPPUNIT_ASSERT(bookmark1name.match("__RefHeading__")); //make second bookmark, CROSSREF_NUMITEM, with *empty* name - sw::mark::IMark* pMark2(pIDMAccess->makeMark(*pCrsr, "", IDocumentMarkAccess::MarkType::CROSSREF_NUMITEM_BOOKMARK)); + sw::mark::IMark* pMark2(pIDMAccess->makeMark(*pCrsr, "", + IDocumentMarkAccess::MarkType::CROSSREF_NUMITEM_BOOKMARK, + ::sw::mark::InsertMode::New)); //get the new(autogenerated) bookmark name rtl::OUString bookmark2name = pMark2->GetName(); //match the bookmark name, it should be like "__RefNumPara__**" @@ -3714,7 +3723,9 @@ void SwUiWriterTest::testTdf96479() SwPaM aPaM(aIdx); IDocumentMarkAccess &rIDMA = *pDoc->getIDocumentMarkAccess(); sw::mark::IMark *pMark = - rIDMA.makeMark(aPaM, "original", IDocumentMarkAccess::MarkType::BOOKMARK); + rIDMA.makeMark(aPaM, "original", + IDocumentMarkAccess::MarkType::BOOKMARK, + ::sw::mark::InsertMode::New); CPPUNIT_ASSERT(!pMark->IsExpanded()); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), rIDMA.getBookmarksCount()); diff --git a/sw/source/core/crsr/annotationmark.cxx b/sw/source/core/crsr/annotationmark.cxx index c2ad1f4e7f02..82d0bd54279c 100644 --- a/sw/source/core/crsr/annotationmark.cxx +++ b/sw/source/core/crsr/annotationmark.cxx @@ -49,7 +49,7 @@ namespace sw { namespace mark { } - void AnnotationMark::InitDoc(SwDoc* const io_pDoc) + void AnnotationMark::InitDoc(SwDoc* const io_pDoc, sw::mark::InsertMode const) { SwTextNode *pTextNode = GetMarkEnd().nNode.GetNode().GetTextNode(); diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx index bb3f7626c590..849e5a8bf75d 100644 --- a/sw/source/core/crsr/bookmrk.cxx +++ b/sw/source/core/crsr/bookmrk.cxx @@ -65,7 +65,20 @@ namespace } } - void lcl_AssureFieldMarksSet(Fieldmark* const pField, + void lcl_AssertFieldMarksSet(Fieldmark const * const pField, + const sal_Unicode aStartMark, + const sal_Unicode aEndMark) + { + if (aEndMark != CH_TXT_ATR_FORMELEMENT) + { + SwPosition const& rStart(pField->GetMarkStart()); + assert(rStart.nNode.GetNode().GetTextNode()->GetText()[rStart.nContent.GetIndex()] == aStartMark); (void) rStart; (void) aStartMark; + } + SwPosition const& rEnd(pField->GetMarkEnd()); + assert(rEnd.nNode.GetNode().GetTextNode()->GetText()[rEnd.nContent.GetIndex() - 1] == aEndMark); (void) rEnd; + } + + void lcl_SetFieldMarks(Fieldmark* const pField, SwDoc* const io_pDoc, const sal_Unicode aStartMark, const sal_Unicode aEndMark) @@ -280,7 +293,7 @@ namespace sw { namespace mark m_aName = rName; } - void Bookmark::InitDoc(SwDoc* const io_pDoc) + void Bookmark::InitDoc(SwDoc* const io_pDoc, sw::mark::InsertMode const) { if (io_pDoc->GetIDocumentUndoRedo().DoesUndo()) { @@ -399,9 +412,16 @@ namespace sw { namespace mark : Fieldmark(rPaM) { } - void TextFieldmark::InitDoc(SwDoc* const io_pDoc) + void TextFieldmark::InitDoc(SwDoc* const io_pDoc, sw::mark::InsertMode const eMode) { - lcl_AssureFieldMarksSet(this, io_pDoc, CH_TXT_ATR_FIELDSTART, CH_TXT_ATR_FIELDEND); + if (eMode == sw::mark::InsertMode::New) + { + lcl_SetFieldMarks(this, io_pDoc, CH_TXT_ATR_FIELDSTART, CH_TXT_ATR_FIELDEND); + } + else + { + lcl_AssertFieldMarksSet(this, CH_TXT_ATR_FIELDSTART, CH_TXT_ATR_FIELDEND); + } } void TextFieldmark::ReleaseDoc(SwDoc* const pDoc) @@ -413,15 +433,22 @@ namespace sw { namespace mark : Fieldmark(rPaM) { } - void CheckboxFieldmark::InitDoc(SwDoc* const io_pDoc) + void CheckboxFieldmark::InitDoc(SwDoc* const io_pDoc, sw::mark::InsertMode const eMode) { - lcl_AssureFieldMarksSet(this, io_pDoc, CH_TXT_ATR_FIELDSTART, CH_TXT_ATR_FORMELEMENT); + if (eMode == sw::mark::InsertMode::New) + { + lcl_SetFieldMarks(this, io_pDoc, CH_TXT_ATR_FIELDSTART, CH_TXT_ATR_FORMELEMENT); - // For some reason the end mark is moved from 1 by the Insert: we don't - // want this for checkboxes - SwPosition aNewEndPos = this->GetMarkEnd(); - aNewEndPos.nContent--; - SetMarkEndPos( aNewEndPos ); + // For some reason the end mark is moved from 1 by the Insert: + // we don't want this for checkboxes + SwPosition aNewEndPos = this->GetMarkEnd(); + aNewEndPos.nContent--; + SetMarkEndPos( aNewEndPos ); + } + else + { + lcl_AssertFieldMarksSet(this, CH_TXT_ATR_FIELDSTART, CH_TXT_ATR_FORMELEMENT); + } } void CheckboxFieldmark::ReleaseDoc(SwDoc* const pDoc) diff --git a/sw/source/core/crsr/crbm.cxx b/sw/source/core/crsr/crbm.cxx index 946af35c5cae..f1a50fad65ea 100644 --- a/sw/source/core/crsr/crbm.cxx +++ b/sw/source/core/crsr/crbm.cxx @@ -87,7 +87,7 @@ namespace ::sw::mark::IMark* pMark = getIDocumentMarkAccess()->makeMark( *GetCursor(), rName, - eMark); + eMark, sw::mark::InsertMode::New); ::sw::mark::IBookmark* pBookmark = dynamic_cast< ::sw::mark::IBookmark* >(pMark); if(pBookmark) { diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index 4150718228fb..cd8258db8b00 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -269,7 +269,8 @@ namespace ::sw::mark::IMark* const pNewMark = pDestDoc->getIDocumentMarkAccess()->makeMark( aTmpPam, pMark->GetName(), - IDocumentMarkAccess::GetType(*pMark)); + IDocumentMarkAccess::GetType(*pMark), + ::sw::mark::InsertMode::CopyText); // Explicitly try to get exactly the same name as in the source // because NavigatorReminders, DdeBookmarks etc. ignore the proposed name pDestDoc->getIDocumentMarkAccess()->renameMark(pNewMark, pMark->GetName()); @@ -3861,7 +3862,10 @@ bool DocumentContentOperationsManager::ReplaceRangeImpl( SwPaM& rPam, const OUSt m_rDoc.GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, nullptr); // If any Redline will change (split!) the node - const ::sw::mark::IMark* pBkmk = m_rDoc.getIDocumentMarkAccess()->makeMark( aDelPam, OUString(), IDocumentMarkAccess::MarkType::UNO_BOOKMARK ); + const ::sw::mark::IMark* pBkmk = + m_rDoc.getIDocumentMarkAccess()->makeMark( aDelPam, + OUString(), IDocumentMarkAccess::MarkType::UNO_BOOKMARK, + ::sw::mark::InsertMode::New); //JP 06.01.98: MUSS noch optimiert werden!!! m_rDoc.getIDocumentRedlineAccess().SetRedlineFlags( @@ -3953,7 +3957,10 @@ bool DocumentContentOperationsManager::ReplaceRangeImpl( SwPaM& rPam, const OUSt m_rDoc.GetIDocumentUndoRedo().EndUndo(UNDO_EMPTY, nullptr); // If any Redline will change (split!) the node - const ::sw::mark::IMark* pBkmk = m_rDoc.getIDocumentMarkAccess()->makeMark( aDelPam, OUString(), IDocumentMarkAccess::MarkType::UNO_BOOKMARK ); + const ::sw::mark::IMark* pBkmk = + m_rDoc.getIDocumentMarkAccess()->makeMark( aDelPam, + OUString(), IDocumentMarkAccess::MarkType::UNO_BOOKMARK, + ::sw::mark::InsertMode::New); SwIndex& rIdx = aDelPam.GetPoint()->nContent; rIdx.Assign( nullptr, 0 ); diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx index 1604d7ccf35c..99eec9fe1e37 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -369,7 +369,8 @@ namespace sw { namespace mark ::sw::mark::IMark* MarkManager::makeMark(const SwPaM& rPaM, const OUString& rName, - const IDocumentMarkAccess::MarkType eType) + const IDocumentMarkAccess::MarkType eType, + sw::mark::InsertMode const eMode) { #if OSL_DEBUG_LEVEL > 0 { @@ -468,7 +469,7 @@ namespace sw { namespace mark // no special array for these break; } - pMarkBase->InitDoc(m_pDoc); + pMarkBase->InitDoc(m_pDoc, eMode); SAL_INFO("sw.core", "--- makeType ---"); SAL_INFO("sw.core", "Marks"); lcl_DebugMarks(m_vAllMarks); @@ -486,7 +487,8 @@ namespace sw { namespace mark const OUString& rType ) { sw::mark::IMark* pMark = makeMark( rPaM, rName, - IDocumentMarkAccess::MarkType::TEXT_FIELDMARK ); + IDocumentMarkAccess::MarkType::TEXT_FIELDMARK, + sw::mark::InsertMode::New); sw::mark::IFieldmark* pFieldMark = dynamic_cast( pMark ); if (pFieldMark) pFieldMark->SetFieldname( rType ); @@ -500,7 +502,8 @@ namespace sw { namespace mark const OUString& rType) { sw::mark::IMark* pMark = makeMark( rPaM, rName, - IDocumentMarkAccess::MarkType::CHECKBOX_FIELDMARK ); + IDocumentMarkAccess::MarkType::CHECKBOX_FIELDMARK, + sw::mark::InsertMode::New); sw::mark::IFieldmark* pFieldMark = dynamic_cast( pMark ); if (pFieldMark) pFieldMark->SetFieldname( rType ); @@ -518,14 +521,15 @@ namespace sw { namespace mark if(ppExistingMark != m_vBookmarks.end()) return ppExistingMark->get(); const SwPaM aPaM(aPos); - return makeMark(aPaM, OUString(), eType); + return makeMark(aPaM, OUString(), eType, sw::mark::InsertMode::New); } sw::mark::IMark* MarkManager::makeAnnotationMark( const SwPaM& rPaM, const OUString& rName ) { - return makeMark( rPaM, rName, IDocumentMarkAccess::MarkType::ANNOTATIONMARK ); + return makeMark(rPaM, rName, IDocumentMarkAccess::MarkType::ANNOTATIONMARK, + sw::mark::InsertMode::New); } void MarkManager::repositionMark( @@ -1289,7 +1293,9 @@ void SaveBookmark::SetInDoc( if(!aPam.HasMark() || CheckNodesRange(aPam.GetPoint()->nNode, aPam.GetMark()->nNode, true)) { - ::sw::mark::IBookmark* const pBookmark = dynamic_cast< ::sw::mark::IBookmark* >(pDoc->getIDocumentMarkAccess()->makeMark(aPam, m_aName, m_eOrigBkmType)); + ::sw::mark::IBookmark* const pBookmark = dynamic_cast<::sw::mark::IBookmark*>( + pDoc->getIDocumentMarkAccess()->makeMark(aPam, m_aName, + m_eOrigBkmType, sw::mark::InsertMode::New)); if(pBookmark) { pBookmark->SetKeyCode(m_aCode); diff --git a/sw/source/core/inc/MarkManager.hxx b/sw/source/core/inc/MarkManager.hxx index 093e11855bcb..ecfbd0975017 100644 --- a/sw/source/core/inc/MarkManager.hxx +++ b/sw/source/core/inc/MarkManager.hxx @@ -35,7 +35,9 @@ namespace sw { public: MarkManager(/*[in/out]*/ SwDoc& rDoc); // IDocumentMarkAccess - virtual ::sw::mark::IMark* makeMark(const SwPaM& rPaM, const OUString& rName, IDocumentMarkAccess::MarkType eMark) override; + virtual ::sw::mark::IMark* makeMark(const SwPaM& rPaM, + const OUString& rName, IDocumentMarkAccess::MarkType eMark, + sw::mark::InsertMode eMode) override; virtual sw::mark::IFieldmark* makeFieldBookmark( const SwPaM& rPaM, const OUString& rName, diff --git a/sw/source/core/inc/annotationmark.hxx b/sw/source/core/inc/annotationmark.hxx index a6075ae26017..c4d164ed5158 100644 --- a/sw/source/core/inc/annotationmark.hxx +++ b/sw/source/core/inc/annotationmark.hxx @@ -36,7 +36,7 @@ namespace sw { namespace mark virtual ~AnnotationMark() override; - virtual void InitDoc(SwDoc* const io_Doc) override; + virtual void InitDoc(SwDoc* const io_Doc, sw::mark::InsertMode eMode) override; const SwFormatField* GetAnnotationFormatField() const; }; diff --git a/sw/source/core/inc/bookmrk.hxx b/sw/source/core/inc/bookmrk.hxx index 6e1866002f0f..42323e1f6222 100644 --- a/sw/source/core/inc/bookmrk.hxx +++ b/sw/source/core/inc/bookmrk.hxx @@ -95,7 +95,7 @@ namespace sw { m_pPos1.swap(m_pPos2); } - virtual void InitDoc(SwDoc* const) + virtual void InitDoc(SwDoc* const, sw::mark::InsertMode) { } @@ -163,7 +163,7 @@ namespace sw { const vcl::KeyCode& rCode, const OUString& rName, const OUString& rShortName); - virtual void InitDoc(SwDoc* const io_Doc) override; + virtual void InitDoc(SwDoc* const io_Doc, sw::mark::InsertMode eMode) override; virtual void DeregisterFromDoc(SwDoc* const io_pDoc) override; @@ -231,7 +231,7 @@ namespace sw { { public: TextFieldmark(const SwPaM& rPaM); - virtual void InitDoc(SwDoc* const io_pDoc) override; + virtual void InitDoc(SwDoc* const io_pDoc, sw::mark::InsertMode eMode) override; virtual void ReleaseDoc(SwDoc* const pDoc) override; }; @@ -241,7 +241,7 @@ namespace sw { { public: CheckboxFieldmark(const SwPaM& rPaM); - virtual void InitDoc(SwDoc* const io_pDoc) override; + virtual void InitDoc(SwDoc* const io_pDoc, sw::mark::InsertMode eMode) override; virtual void ReleaseDoc(SwDoc* const pDoc) override; bool IsChecked() const override; void SetChecked(bool checked) override; diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx index 3e553387dfe0..ad4fcaa9f525 100644 --- a/sw/source/core/undo/rolbck.cxx +++ b/sw/source/core/undo/rolbck.cxx @@ -648,7 +648,8 @@ void SwHistoryBookmark::SetInDoc( SwDoc* pDoc, bool ) pMarkAccess->deleteMark( pMark ); } ::sw::mark::IBookmark* const pBookmark = - dynamic_cast< ::sw::mark::IBookmark* >( pMarkAccess->makeMark(*pPam, m_aName, m_eBkmkType) ); + dynamic_cast<::sw::mark::IBookmark*>( + pMarkAccess->makeMark(*pPam, m_aName, m_eBkmkType, sw::mark::InsertMode::New)); if ( pBookmark != nullptr ) { pBookmark->SetKeyCode(m_aKeycode); diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx index feca7d3cdee8..7ae5136f4acf 100644 --- a/sw/source/core/unocore/unobkm.cxx +++ b/sw/source/core/unocore/unobkm.cxx @@ -244,7 +244,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) } m_pImpl->registerInMark(*this, m_pImpl->m_pDoc->getIDocumentMarkAccess()->makeMark( - aPam, m_pImpl->m_sMarkName, eType)); + aPam, m_pImpl->m_sMarkName, eType, ::sw::mark::InsertMode::New)); // #i81002# // Check, if bookmark has been created. // E.g., the creation of a cross-reference bookmark is suppress, diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index da92fcaa2ad5..b0d697ea3f10 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -794,7 +794,7 @@ void SwXTextRange::SetPositions(const SwPaM& rPam) m_pImpl->Invalidate(); IDocumentMarkAccess* const pMA = m_pImpl->m_rDoc.getIDocumentMarkAccess(); m_pImpl->m_pMark = pMA->makeMark(rPam, OUString(), - IDocumentMarkAccess::MarkType::UNO_BOOKMARK); + IDocumentMarkAccess::MarkType::UNO_BOOKMARK, sw::mark::InsertMode::New); m_pImpl->m_pMark->Add(m_pImpl.get()); } diff --git a/sw/source/filter/basflt/fltshell.cxx b/sw/source/filter/basflt/fltshell.cxx index e95c8fa7a5a6..fcf7a9731aea 100644 --- a/sw/source/filter/basflt/fltshell.cxx +++ b/sw/source/filter/basflt/fltshell.cxx @@ -615,7 +615,7 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, IDocumentMarkAccess::IsLegalPaMForCrossRefHeadingBookmark( aRegion ) ) ? IDocumentMarkAccess::MarkType::CROSSREF_HEADING_BOOKMARK : IDocumentMarkAccess::MarkType::BOOKMARK; - pDoc->getIDocumentMarkAccess()->makeMark( aRegion, rName, eBookmarkType ); + pDoc->getIDocumentMarkAccess()->makeMark(aRegion, rName, eBookmarkType, sw::mark::InsertMode::New); } } break; diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index 7d81018855be..058c39ad0b89 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -2815,7 +2815,8 @@ void SwHTMLParser::SetAttr_( bool bChkEnd, bool bBeforeTable, const ::sw::mark::IMark* const pNewMark = pMarkAccess->makeMark( *pAttrPam, sName, - IDocumentMarkAccess::MarkType::BOOKMARK ); + IDocumentMarkAccess::MarkType::BOOKMARK, + ::sw::mark::InsertMode::New); // jump to bookmark if( JUMPTO_MARK == m_eJumpTo && pNewMark->GetName() == m_sJmpMark ) diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index 991b6127c251..2f6ae80d87c4 100644 --- a/sw/source/uibase/dbui/dbmgr.cxx +++ b/sw/source/uibase/dbui/dbmgr.cxx @@ -1486,7 +1486,8 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell, SwDocMergeInfo aMergeInfo; // Name of the mark is actually irrelevant, UNO bookmarks have internals names. aMergeInfo.startPageInTarget = pTargetDoc->getIDocumentMarkAccess()->makeMark( - appendedDocStart, "", IDocumentMarkAccess::MarkType::UNO_BOOKMARK ); + appendedDocStart, "", IDocumentMarkAccess::MarkType::UNO_BOOKMARK, + ::sw::mark::InsertMode::New); aMergeInfo.nDBRow = nStartRow; rMergeDescriptor.pMailMergeConfigItem->AddMergedDocument( aMergeInfo ); } diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index 2e7546b146ef..c3b2b1a08958 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -3774,7 +3774,8 @@ bool SwTrnsfrDdeLink::WriteData( SvStream& rStrm ) ::sw::mark::IMark* const pNewMark = pMarkAccess->makeMark( aPaM, sMarkName, - IDocumentMarkAccess::MarkType::BOOKMARK); + IDocumentMarkAccess::MarkType::BOOKMARK, + ::sw::mark::InsertMode::New); rServerObject.SetDdeBookmark(*pNewMark); } -- cgit