summaryrefslogtreecommitdiff
path: root/sw/inc
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2022-07-20 17:54:16 +0200
committerMichael Stahl <michael.stahl@allotropia.de>2022-07-26 15:23:59 +0200
commit7974cea6c788e02d7c36573e2d10dcc51884f70e (patch)
treece649c3cb04a180029039d65085264c560f2cf3e /sw/inc
parent5b1a8f39ee58fe5372eea18ce1ee99c95b11ba05 (diff)
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 <michael.stahl@allotropia.de>
Diffstat (limited to 'sw/inc')
-rw-r--r--sw/inc/contentindex.hxx17
-rw-r--r--sw/inc/ndtxt.hxx3
2 files changed, 17 insertions, 3 deletions
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 <sal/types.h>
#include "swdllapi.h"
+#include <o3tl/typed_flags_set.hxx>
+
#include <iostream>
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<SwContentIndexReg::UpdateMode> : is_typed_flags<SwContentIndexReg::UpdateMode, 0x07> {};
+}
+
#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,