[Libreoffice-commits] core.git: sw/source

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Fri May 3 08:25:17 UTC 2019


 sw/source/core/edit/autofmt.cxx |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit b69bc0facc6e0fbc2006125e656b82a7c2556203
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Thu May 2 18:27:07 2019 +0200
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Fri May 3 10:23:04 2019 +0200

    tdf#123285 sw_redlinehide: fix SwAutoFormat::DelMoreLinesBlanks()
    
    The "Delete spaces and tabs at end and start of line" AutoFormat
    option was deleting the wrong characters: on the 2nd line, it deletes
    the spaces as it should, but on subsequent lines the selection is off by
    the number of characters that have already been removed.
    
    The range indexes are now integers, so not automatically corrected on
    deletions like the SwIndex they were before; in this case, where only
    plain characters are deleted, it should suffice to iterate the ranges in
    reverse order to avoid the problem.
    
    (regression from 180e5f515c9cd21fb8057c797a480eca7d9ed260)
    
    Change-Id: Ie8e08c00803d94e700cd5b64f29edb0b841eda2b
    Reviewed-on: https://gerrit.libreoffice.org/71686
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>

diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index 740b3cc1f99b..36319230508d 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -1308,8 +1308,10 @@ void SwAutoFormat::DelMoreLinesBlanks( bool bWithLineBreaks )
         std::vector<std::pair<TextFrameIndex, TextFrameIndex>> spaces;
         aFInfo.GetSpaces(spaces, !m_aFlags.bAFormatByInput || bWithLineBreaks);
 
-        for (auto & rSpaceRange : spaces)
+        // tdf#123285 iterate backwards - delete invalidates following indexes
+        for (auto iter = spaces.rbegin(); iter != spaces.rend(); ++iter)
         {
+            auto & rSpaceRange(*iter);
             assert(rSpaceRange.first != rSpaceRange.second);
             bool const bHasBlanks = HasSelBlanks(
                     m_pCurTextFrame, rSpaceRange.first,


More information about the Libreoffice-commits mailing list