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 <matthew@epoq.co.uk>
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx
index 1a30a4e..a1f3b97 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)
{