[Libreoffice-commits] core.git: sw/inc sw/qa sw/source

Michael Stahl mstahl at redhat.com
Wed Sep 27 14:41:51 UTC 2017


 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 
 sw/source/core/doc/DocumentContentOperationsManager.cxx |   22 +++----
 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(+), 58 deletions(-)

New commits:
commit 421a23bb36bbf51edfabc58b7d2cd28ad37719d0
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Sep 27 15:55:43 2017 +0200

    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)
    
    Change-Id: I3c99b8c6d720951655198e682018794337859373

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 cc75587a04dd..4c712f8da7a0 100644
--- a/sw/qa/core/macros-test.cxx
+++ b/sw/qa/core/macros-test.cxx
@@ -207,7 +207,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);
@@ -241,7 +242,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 2363e6d5fa95..98ed54f2d2fb 100644
--- a/sw/qa/core/uwriter.cxx
+++ b/sw/qa/core/uwriter.cxx
@@ -1549,19 +1549,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 8b1e7c5185ac..3146016937ba 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -549,7 +549,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);
@@ -1418,7 +1419,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());
@@ -1589,7 +1591,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
@@ -1618,7 +1622,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());
@@ -3768,13 +3773,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__**"
@@ -4223,7 +4232,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 a73c1715bb36..c427cba19067 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();
         assert(pTextNode);
diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx
index 095d9d462ce3..7a2b17004248 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 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);
+        }
+        SwPosition const& rEnd(pField->GetMarkEnd());
+        assert(rEnd.nNode.GetNode().GetTextNode()->GetText()[rEnd.nContent.GetIndex() - 1] == aEndMark);
+    }
+
+    void lcl_SetFieldMarks(Fieldmark* const pField,
         SwDoc* const io_pDoc,
         const sal_Unicode aStartMark,
         const sal_Unicode aEndMark)
@@ -278,7 +291,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())
         {
@@ -397,9 +410,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)
@@ -411,15 +431,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 = 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 = 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 cf03566e24bb..ceca8453e8d2 100644
--- a/sw/source/core/crsr/crbm.cxx
+++ b/sw/source/core/crsr/crbm.cxx
@@ -86,7 +86,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 4d72d883e8fe..f5d491cd1bc8 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -268,19 +268,11 @@ namespace
                 lcl_SetCpyPos(pMark->GetOtherMarkPos(), rStt, *pCpyStt, *aTmpPam.GetMark(), nDelCount);
             }
 
-            const IDocumentMarkAccess::MarkType aMarkType = IDocumentMarkAccess::GetType(*pMark);
-            if (aMarkType == IDocumentMarkAccess::MarkType::CHECKBOX_FIELDMARK)
-            {
-                // Node's CopyText() copies also dummy characters, which need to be removed
-                // (they will be added later in MarkBase::InitDoc inside IDocumentMarkAccess::makeMark)
-                // CHECKBOX_FIELDMARK doesn't contain any other data in its range, so just clear it
-                pDestDoc->getIDocumentContentOperations().DeleteRange(aTmpPam);
-            }
-
             ::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());
@@ -3900,7 +3892,10 @@ bool DocumentContentOperationsManager::ReplaceRangeImpl( SwPaM& rPam, const OUSt
                 m_rDoc.GetIDocumentUndoRedo().StartUndo(SwUndoId::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(
@@ -3991,7 +3986,10 @@ bool DocumentContentOperationsManager::ReplaceRangeImpl( SwPaM& rPam, const OUSt
                 m_rDoc.GetIDocumentUndoRedo().EndUndo(SwUndoId::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 85554d3baee2..5fe3a250da5d 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -367,7 +367,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
         {
@@ -466,7 +467,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);
@@ -484,7 +485,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<sw::mark::IFieldmark*>( pMark );
         if (pFieldMark)
             pFieldMark->SetFieldname( rType );
@@ -498,7 +500,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<sw::mark::IFieldmark*>( pMark );
         if (pFieldMark)
             pFieldMark->SetFieldname( rType );
@@ -516,14 +519,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(
@@ -1281,7 +1285,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 f0c34634cc8a..76363043e505 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)
             {
             }
 
@@ -162,7 +162,7 @@ namespace sw {
             Bookmark(const SwPaM& rPaM,
                 const vcl::KeyCode& rCode,
                 const OUString& rName);
-            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;
 
@@ -230,7 +230,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;
         };
 
@@ -240,7 +240,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 0d1fe53bf690..6459a46f692e 100644
--- a/sw/source/core/undo/rolbck.cxx
+++ b/sw/source/core/undo/rolbck.cxx
@@ -646,7 +646,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 94b6c8053215..13ca1b40db25 100644
--- a/sw/source/core/unocore/unobkm.cxx
+++ b/sw/source/core/unocore/unobkm.cxx
@@ -240,7 +240,7 @@ void SwXBookmark::attachToRangeEx(
     }
     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 b672f49ee175..cf1afe3de44a 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 d0df613b7033..a2110025381c 100644
--- a/sw/source/filter/basflt/fltshell.cxx
+++ b/sw/source/filter/basflt/fltshell.cxx
@@ -640,7 +640,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 9026e8537454..2c947e3db384 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -2799,7 +2799,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 483ffd686a0e..7e45823ddd29 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -1477,7 +1477,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 74f7c18f725b..3f0ebad4116a 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -3755,7 +3755,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);
     }
 


More information about the Libreoffice-commits mailing list