summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2017-09-27 15:55:43 +0200
committerAndras Timar <andras.timar@collabora.com>2017-09-30 12:17:08 +0200
commit10fe1a4b7b408ce8322d65c6e0701e67e4d0f25b (patch)
treeff1eaa8967913ea6110bb587f3605c831ec86246
parent2cf1e5ac3bf9f051e1d58788a420cf8fe4726f50 (diff)
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/42867 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r--sw/inc/IDocumentMarkAccess.hxx5
-rw-r--r--sw/inc/IMark.hxx5
-rw-r--r--sw/qa/core/macros-test.cxx6
-rw-r--r--sw/qa/core/uwriter.cxx9
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx25
-rw-r--r--sw/source/core/crsr/annotationmark.cxx2
-rw-r--r--sw/source/core/crsr/bookmrk.cxx49
-rw-r--r--sw/source/core/crsr/crbm.cxx2
-rw-r--r--sw/source/core/doc/DocumentContentOperationsManager.cxx22
-rw-r--r--sw/source/core/doc/docbm.cxx20
-rw-r--r--sw/source/core/inc/MarkManager.hxx4
-rw-r--r--sw/source/core/inc/annotationmark.hxx2
-rw-r--r--sw/source/core/inc/bookmrk.hxx8
-rw-r--r--sw/source/core/undo/rolbck.cxx3
-rw-r--r--sw/source/core/unocore/unobkm.cxx2
-rw-r--r--sw/source/core/unocore/unoobj2.cxx2
-rw-r--r--sw/source/filter/basflt/fltshell.cxx2
-rw-r--r--sw/source/filter/html/swhtml.cxx3
-rw-r--r--sw/source/uibase/dbui/dbmgr.cxx3
-rw-r--r--sw/source/uibase/dochdl/swdtflvr.cxx3
20 files changed, 119 insertions, 58 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 8ac5c15946ea..636c887395bd 100644
--- a/sw/qa/core/macros-test.cxx
+++ b/sw/qa/core/macros-test.cxx
@@ -210,7 +210,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);
@@ -244,7 +245,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 e0ccaaeb778b..5db51fa69266 100644
--- a/sw/qa/core/uwriter.cxx
+++ b/sw/qa/core/uwriter.cxx
@@ -1236,19 +1236,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 20e048d6558b..5d9e9df5e5c1 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -494,7 +494,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);
@@ -1289,7 +1290,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());
@@ -1461,7 +1463,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
@@ -1490,7 +1494,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());
@@ -3644,13 +3649,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__**"
@@ -4081,7 +4090,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 27e8c7973ce6..db814eb57792 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 09992bf5df48..d4728ef3541e 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)
@@ -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 = 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 508ae5782ac1..660b069a2a4b 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 cfc4f4fe9605..bb68c450575a 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -266,19 +266,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());
@@ -3871,7 +3863,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(
@@ -3963,7 +3958,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 9a13a5799a99..0822d4e1bf0f 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -366,7 +366,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
{
@@ -465,7 +466,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);
@@ -483,7 +484,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 );
@@ -497,7 +499,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 );
@@ -515,14 +518,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(
@@ -1286,7 +1290,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 1ac8829b1bf9..28306d9fce0a 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 f55770676715..06df81d2d77e 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 53800f99400a..288c3427d56d 100644
--- a/sw/source/core/unocore/unoobj2.cxx
+++ b/sw/source/core/unocore/unoobj2.cxx
@@ -795,7 +795,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 039a1c39a0ea..bf278601cdff 100644
--- a/sw/source/filter/basflt/fltshell.cxx
+++ b/sw/source/filter/basflt/fltshell.cxx
@@ -625,7 +625,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 a031bd8607c9..3ec9997c8c33 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -2806,7 +2806,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 801531c8e681..8da790f098cf 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -1480,7 +1480,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 4615824bccc3..9d480675171b 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -3759,7 +3759,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);
}