From 7974cea6c788e02d7c36573e2d10dcc51884f70e Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Wed, 20 Jul 2022 17:54:16 +0200 Subject: tdf#150017 sw: Replace should not shorten bookmarks If there is a bookmark on the text that is replaced, its end will be after the 1st character of the replacement text. This is very odd and it would be much better to put the end at the end of the replacement text, particularly if the end of the bookmark used to be at the end of the replaced text. Text attributes already work such that the attribute on the first character before the replace is expanded to the entire replacement text; this seems odd too but as it happens Word does the same thing, so this patch makes bookmarks consistent with attributes. Change-Id: I6a4b43c779c207a31edb02b416d50c30386c94c1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137272 Tested-by: Jenkins Reviewed-by: Michael Stahl --- sw/inc/contentindex.hxx | 17 ++++++++++++++++- sw/inc/ndtxt.hxx | 3 +-- 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'sw/inc') diff --git a/sw/inc/contentindex.hxx b/sw/inc/contentindex.hxx index 00337570ecb5..c05845b378c7 100644 --- a/sw/inc/contentindex.hxx +++ b/sw/inc/contentindex.hxx @@ -21,6 +21,8 @@ #include #include "swdllapi.h" +#include + #include class SwContentNode; @@ -112,9 +114,17 @@ class SAL_WARN_UNUSED SwContentIndexReg const SwContentIndex * m_pFirst; const SwContentIndex * m_pLast; +public: + enum class UpdateMode { + Default = 0, + Negative = (1<<0), + Delete = (1<<1), + Replace = (1<<2), + }; + protected: virtual void Update( SwContentIndex const & rPos, const sal_Int32 nChangeLen, - const bool bNegative = false, const bool bDelete = false ); + UpdateMode eMode); bool HasAnyIndex() const { return nullptr != m_pFirst; } @@ -126,6 +136,11 @@ public: const SwContentIndex* GetFirstIndex() const { return m_pFirst; } }; +namespace o3tl +{ + template<> struct typed_flags : is_typed_flags {}; +} + #ifndef DBG_UTIL inline sal_Int32 SwContentIndex::operator++() diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx index 5b71bfd3d593..9a5aa068ade6 100644 --- a/sw/inc/ndtxt.hxx +++ b/sw/inc/ndtxt.hxx @@ -763,8 +763,7 @@ public: virtual void Update( SwContentIndex const & rPos, const sal_Int32 nChangeLen, - const bool bNegative = false, - const bool bDelete = false ) override; + UpdateMode eMode) override; /// change text to Upper/Lower/Hiragana/Katakana/... void TransliterateText( utl::TransliterationWrapper& rTrans, -- cgit