Related: tdf#139974 Keep HYPHEN-MINUS with a number to the right
Force line break
1234567890
-1234567890
instead of
1234567890-
1234567890
but still
abcdef-
abcdef
Change-Id: I0b427b33b05eea12d13aad148c604385ffe000d2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128691
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index 171aa67..36747c1 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -2756,11 +2756,24 @@ EditPaM ImpEditEngine::ImpInsertText(const EditSelection& aCurSel, const OUStrin
{
const sal_Unicode c = aLine[nPos];
// Ignore NO-BREAK spaces, NBSP, NNBSP, ZWNBSP.
if (c != 0x00A0 && c != 0x202F && c != 0xFEFF)
if (c == 0x00A0 || c == 0x202F || c == 0xFEFF)
break;
if (c == '-' && nPos + 1 < nMaxNewChars)
{
nMaxNewChars = nPos + 1; // line break after
nPos = 0; // will break loop
// Keep HYPHEN-MINUS with a number to the right.
const sal_Int16 t = unicode::getUnicodeType(aLine[nPos+1]);
if ( t == css::i18n::UnicodeType::DECIMAL_DIGIT_NUMBER ||
t == css::i18n::UnicodeType::LETTER_NUMBER ||
t == css::i18n::UnicodeType::OTHER_NUMBER)
nMaxNewChars = nPos; // line break before
else
nMaxNewChars = nPos + 1; // line break after
}
else
{
nMaxNewChars = nPos + 1; // line break after
}
nPos = 0; // will break loop
}
}
}