summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorFred Kruse <fred.kruse@gmx.de>2022-11-13 18:37:31 +0100
committerMiklos Vajna <vmiklos@collabora.com>2022-11-25 11:08:12 +0100
commit5f249506ff2eddeaac47d521509bf1dde0b58d01 (patch)
tree37d753630e594033e5a0c7970f9322a5de0bb85c /editeng
parentfc6aa9e49973c845915754caf765ff57e5b0cd59 (diff)
tdf#151801 solves bug for autocorrect non default quotes
Regards German and some other languages. A bug in the mechanism to distingish between apostroph and single end quote is solved. Now, it works also for user defined quotes, like a single angle quote ('French' quote). Change-Id: Ib4beca7a4304d57d7fdf977c20cf62410be3d2c6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142662 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/misc/svxacorr.cxx39
1 files changed, 30 insertions, 9 deletions
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index cf5d7474e49d..5e229ba10d24 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -1280,7 +1280,7 @@ OUString SvxAutoCorrect::GetQuote( SvxAutoCorrDoc const & rDoc, sal_Int32 nInsPo
// search preceding opening quote in the paragraph before the insert position
static bool lcl_HasPrecedingChar( std::u16string_view rTxt, sal_Int32 nPos,
- const sal_Unicode sPrecedingChar, const sal_Unicode* aStopChars )
+ const sal_Unicode sPrecedingChar, const sal_Unicode sStopChar, const sal_Unicode* aStopChars )
{
sal_Unicode cTmpChar;
@@ -1289,6 +1289,9 @@ static bool lcl_HasPrecedingChar( std::u16string_view rTxt, sal_Int32 nPos,
if ( cTmpChar == sPrecedingChar )
return true;
+ if ( cTmpChar == sStopChar )
+ return false;
+
for ( const sal_Unicode* pCh = aStopChars; *pCh; ++pCh )
if ( cTmpChar == *pCh )
return false;
@@ -1358,13 +1361,15 @@ void SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt,
( ( eLang == LANGUAGE_HUNGARIAN &&
lcl_HasPrecedingChar( rTxt, nInsPos,
bSttQuote ? aStopDoubleAngleQuoteStart[0] : aStopDoubleAngleQuoteEnd[0],
- bSttQuote ? aStopDoubleAngleQuoteStart + 1 : aStopDoubleAngleQuoteEnd + 1 ) ) ||
+ bSttQuote ? aStopDoubleAngleQuoteStart[1] : aStopDoubleAngleQuoteEnd[1],
+ bSttQuote ? aStopDoubleAngleQuoteStart + 1 : aStopDoubleAngleQuoteEnd + 2 ) ) ||
( eLang.anyOf(
LANGUAGE_ROMANIAN,
LANGUAGE_ROMANIAN_MOLDOVA ) &&
lcl_HasPrecedingChar( rTxt, nInsPos,
bSttQuote ? aStopDoubleAngleQuoteStart[0] : aStopDoubleAngleQuoteEndRo[0],
- bSttQuote ? aStopDoubleAngleQuoteStart + 1 : aStopDoubleAngleQuoteEndRo + 1 ) ) ) )
+ bSttQuote ? aStopDoubleAngleQuoteStart[1] : aStopDoubleAngleQuoteEndRo[1],
+ bSttQuote ? aStopDoubleAngleQuoteStart + 1 : aStopDoubleAngleQuoteEndRo + 2 ) ) ) )
{
LocaleDataWrapper& rLcl = GetLocaleDataWrapper( eLang );
// only if the opening double quotation mark is the default one
@@ -1375,7 +1380,7 @@ void SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt,
// tdf#128860 use apostrophe outside of second level quotation in Czech, German, Icelandic,
// Slovak and Slovenian instead of the – in this case, bad – closing quotation mark U+2018.
// tdf#123786 the same for Russian and Ukrainian
- ( ( eLang.anyOf (
+ ( eLang.anyOf (
LANGUAGE_CZECH,
LANGUAGE_GERMAN,
LANGUAGE_GERMAN_SWISS,
@@ -1384,17 +1389,33 @@ void SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt,
LANGUAGE_GERMAN_LIECHTENSTEIN,
LANGUAGE_ICELANDIC,
LANGUAGE_SLOVAK,
- LANGUAGE_SLOVENIAN ) &&
- !lcl_HasPrecedingChar( rTxt, nInsPos, aStopSingleQuoteEnd[0], aStopSingleQuoteEnd + 1 ) ) ||
+ LANGUAGE_SLOVENIAN ) ) )
+ {
+ sal_Unicode sStartChar = GetStartSingleQuote();
+ sal_Unicode sEndChar = GetEndSingleQuote();
+ if ( !sStartChar || !sEndChar ) {
+ LocaleDataWrapper& rLcl = GetLocaleDataWrapper( eLang );
+ if ( !sStartChar ) sStartChar = rLcl.getQuotationMarkStart()[0];
+ if ( !sEndChar ) sEndChar = rLcl.getQuotationMarkStart()[0];
+ }
+ if ( !lcl_HasPrecedingChar( rTxt, nInsPos, sStartChar, sEndChar, aStopSingleQuoteEnd + 1 ) )
+ {
+ CharClass& rCC = GetCharClass( eLang );
+ if ( rCC.isLetter(rTxt, nInsPos-1) )
+ {
+ eType = ACQuotes::UseApostrophe;
+ }
+ }
+ }
+ else if ( bSingle && nInsPos && !bSttQuote &&
( eLang.anyOf (
LANGUAGE_RUSSIAN,
LANGUAGE_UKRAINIAN ) &&
- !lcl_HasPrecedingChar( rTxt, nInsPos, aStopSingleQuoteEndRuUa[0], aStopSingleQuoteEndRuUa + 1 ) ) ) )
+ !lcl_HasPrecedingChar( rTxt, nInsPos, aStopSingleQuoteEndRuUa[0], aStopSingleQuoteEndRuUa[1], aStopSingleQuoteEndRuUa + 2 ) ) )
{
LocaleDataWrapper& rLcl = GetLocaleDataWrapper( eLang );
CharClass& rCC = GetCharClass( eLang );
- if ( ( rLcl.getQuotationMarkStart() == OUStringChar(aStopSingleQuoteEnd[0]) ||
- rLcl.getQuotationMarkStart() == OUStringChar(aStopSingleQuoteEndRuUa[0]) ) &&
+ if ( rLcl.getQuotationMarkStart() == OUStringChar(aStopSingleQuoteEndRuUa[0]) &&
// use apostrophe only after letters, not after digits or punctuation
rCC.isLetter(rTxt, nInsPos-1) )
{