diff options
author | Pranam Lashkari <lpranam@collabora.com> | 2022-05-20 20:24:46 +0530 |
---|---|---|
committer | Pranam Lashkari <lpranam@collabora.com> | 2022-05-25 20:01:16 +0200 |
commit | 3a885196bbf673960f72c45e21b1226b80ad26d1 (patch) | |
tree | 883b765770323ac378420f13884a7ad6c6a9084b | |
parent | 3796bcf5f22751fdd3d5a1c89aa92795694ccec4 (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>
(cherry picked from commit 0d3bba5c383ef8b9f62c121a26fed4445c813949)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134792
Tested-by: Jenkins
(cherry picked from commit a4536c53eceac8eec6e5ac273583fefb6bafcb3f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134898
-rw-r--r-- | sw/inc/docufld.hxx | 1 | ||||
-rw-r--r-- | sw/source/core/fields/docufld.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/txtnode/thints.cxx | 4 |
3 files changed, 9 insertions, 1 deletions
diff --git a/sw/inc/docufld.hxx b/sw/inc/docufld.hxx index f1023e372970..32ab1d5d12ba 100644 --- a/sw/inc/docufld.hxx +++ b/sw/inc/docufld.hxx @@ -481,6 +481,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 902a7bcea33a..a3b5d5a5e12d 100644 --- a/sw/source/core/fields/docufld.cxx +++ b/sw/source/core/fields/docufld.cxx @@ -1831,6 +1831,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 75f04356e476..71d0263850d2 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -1092,7 +1092,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; |