summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPranam Lashkari <lpranam@collabora.com>2022-05-20 20:24:46 +0530
committerGökay ŞATIR <gokaysatir@collabora.com>2022-05-23 17:13:29 +0200
commit0d3bba5c383ef8b9f62c121a26fed4445c813949 (patch)
treed083fce70c3a319f30e06a66e922cb52cd03fcbb
parent89ceb3504c74e6f7875785d436a378a991ba2f8a (diff)
comments: reassign ID when copy comment
reassigning new ID will make all the comments have unique IDs this will also ensure there is no mixup when working with comments ID Signed-off-by: Pranam Lashkari <lpranam@collabora.com> Change-Id: I94b433130c68354ab94d4d6e9b86751038b31af5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134686 Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Reviewed-by: Gökay ŞATIR <gokaysatir@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
-rw-r--r--sw/inc/docufld.hxx1
-rw-r--r--sw/source/core/fields/docufld.cxx5
-rw-r--r--sw/source/core/txtnode/thints.cxx4
3 files changed, 9 insertions, 1 deletions
diff --git a/sw/inc/docufld.hxx b/sw/inc/docufld.hxx
index b4fe720970b6..f7bc73bad0db 100644
--- a/sw/inc/docufld.hxx
+++ b/sw/inc/docufld.hxx
@@ -474,6 +474,7 @@ public:
Date GetDate() const { return Date(m_aDateTime.GetDate()); }
tools::Time GetTime() const { return tools::Time(m_aDateTime.GetTime()); }
sal_uInt32 GetPostItId() const { return m_nPostItId; }
+ void SetPostItId(const sal_uInt32 nPostItId = 0);
/// Author
virtual OUString GetPar1() const override;
diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx
index b32c4937ed1e..574cac74fe37 100644
--- a/sw/source/core/fields/docufld.cxx
+++ b/sw/source/core/fields/docufld.cxx
@@ -1829,6 +1829,11 @@ sal_Int32 SwPostItField::GetNumberOfParagraphs() const
return mpText ? mpText->Count() : 1;
}
+void SwPostItField::SetPostItId(const sal_uInt32 nPostItId)
+{
+ m_nPostItId = nPostItId == 0 ? s_nLastPostItId++ : nPostItId;
+}
+
bool SwPostItField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
{
switch( nWhichId )
diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx
index af1f220fa448..f0a784f6fc42 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -1080,7 +1080,9 @@ SwTextAttr* MakeTextAttr(
// the relation to its annotation mark (relation established via annotation field's name).
// If the annotation mark is also copied, the relation and thus the annotated text range will be reestablished,
// when the annotation mark is created and inserted into the document.
- const_cast<SwPostItField&>(dynamic_cast<const SwPostItField&>(*(pNew->GetFormatField().GetField()))).SetName(OUString());
+ auto& pField = const_cast<SwPostItField&>(dynamic_cast<const SwPostItField&>(*(pNew->GetFormatField().GetField())));
+ pField.SetName(OUString());
+ pField.SetPostItId();
}
}
break;