sw/source/core/text/porfld.cxx |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

New commits:
commit ee0a6a4179b17b76dfd97982ef87d92661afc28c
Author:     Matthew Kogan <matt...@epoq.co.uk>
AuthorDate: Tue Jan 16 11:03:43 2024 +0000
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Jan 17 15:23:48 2024 +0100

    tdf#159101 sw: Fix space appearing at start of line when field wraps
    
    Adding the ' ' to ScanPortionEnd fails pretty quickly with infinite
    loop.
    
    The important part of fixing the forum-mso-en-13115.docx was that the
    SetHasFollow(true) condition is not affected by a ' '.
    
    (regression from commit 21473f46fda5f1c7f220493667a96fff7c78a7b3)
    
    Change-Id: I6452673c0fe05ca549b63a398a977fc71db64bae
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162167
    Tested-by: Jenkins
    Reviewed-by: Matthew Kogan <matt...@epoq.co.uk>
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit 4cdb542348b20d8a558cd6413c7cccdc50241fa9)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162146
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx
index 1a30a4ecd7d1..a1f3b9729383 100644
--- a/sw/source/core/text/porfld.cxx
+++ b/sw/source/core/text/porfld.cxx
@@ -402,10 +402,13 @@ bool SwFieldPortion::Format( SwTextFormatInfo &rInf )
             // These characters should not be contained in the follow
             // field portion. They are handled via the HookChar mechanism.
             const sal_Unicode nNew = !aNew.isEmpty() ? aNew[0] : 0;
-            auto IsHook = [](const sal_Unicode cNew) -> bool
+            auto IsHook = [](const sal_Unicode cNew, bool const isSpace = 
false) -> bool
             {
                 switch (cNew)
                 {
+                    case ' ': // tdf#159101 this one is not in ScanPortionEnd
+                              // but is required for justified text
+                        return isSpace;
                     case CH_BREAK:
                     case CH_TAB:
                     case CHAR_HARDHYPHEN: // non-breaking hyphen
@@ -422,7 +425,7 @@ bool SwFieldPortion::Format( SwTextFormatInfo &rInf )
                         return false;
                 }
             };
-            if (IsHook(nNew))
+            if (IsHook(nNew, true))
             {
                 if (nNew == CH_BREAK)
                 {

Reply via email to