diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-07-22 17:36:17 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-07-24 09:03:05 +0200 |
commit | a573cabdcf105e33b395a36d08f90aecbc5d7dce (patch) | |
tree | 90f1722ec8877e6a248f77c20f1a9557ece2d906 /sw/source/core/crsr/findtxt.cxx | |
parent | 09407951bba3808483bb2e7d2fd7e4b8660b134b (diff) |
sw: find & replace: fix soft hyphen cleaning
If there is a formatted soft hyphen after the search string, then
replace skipped the replacement, even if there was a match.
Do the same for comments & footnotes, though the primary reported
problem was just soft hyphens.
(The same happened when manually doing find & replace using the Ctrl-H
dialog.)
(cherry picked from commit d8270636a57e7dc68ede51308c380e2098f765d7)
Conflicts:
sw/Module_sw.mk
Change-Id: I8437e84dea99ceef98d515beef5893cf954e674f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99274
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/source/core/crsr/findtxt.cxx')
-rw-r--r-- | sw/source/core/crsr/findtxt.cxx | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx index 03239dfb1063..5b3572632a0a 100644 --- a/sw/source/core/crsr/findtxt.cxx +++ b/sw/source/core/crsr/findtxt.cxx @@ -291,7 +291,10 @@ lcl_CleanStr(const SwTextNode& rNd, if ( bEmpty && nStart == nCurrent ) { rArr.push_back( nCurrent ); - --rEnd.GetAnyIndex(); + if (rEnd.GetAnyIndex() > nCurrent.GetAnyIndex()) + { + --rEnd.GetAnyIndex(); + } buf.remove(nCurrent.GetAnyIndex(), 1); } else @@ -307,7 +310,10 @@ lcl_CleanStr(const SwTextNode& rNd, if( bRemoveCommentAnchors ) { rArr.push_back( nCurrent ); - --rEnd.GetAnyIndex(); + if (rEnd.GetAnyIndex() > nCurrent.GetAnyIndex()) + { + --rEnd.GetAnyIndex(); + } buf.remove( nCurrent.GetAnyIndex(), 1 ); } } @@ -323,7 +329,14 @@ lcl_CleanStr(const SwTextNode& rNd, if ( bNewSoftHyphen ) { rArr.push_back( nCurrent ); - --rEnd.GetAnyIndex(); + + // If the soft hyphen to be removed is past the end of the range we're searching in, + // don't adjust the end. + if (rEnd.GetAnyIndex() > nCurrent.GetAnyIndex()) + { + --rEnd.GetAnyIndex(); + } + buf.remove(nCurrent.GetAnyIndex(), 1); ++nSoftHyphen.GetAnyIndex(); } |