summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2020-05-29 16:46:44 +0200
committerLászló Németh <nemeth@numbertext.org>2020-05-31 23:13:59 +0200
commita0c90f1bccd9b5a349d3199746facab549f27dba (patch)
treebfbcd83d624c46a5d54317d20f450c896c51b2ce /editeng
parent57f07b1d7378d218648667c5b1315cc8ad905875 (diff)
tdf#128860 AutoCorrect: fix apostrophe in Czech, German,
Icelandic, Slovak and Slovene at "Single quotes" replacement outside of second level quotations. For example: ‚quote' -> ‚quote‘ but now apostrophe' -> apostrophe’ instead of the bad apostrophe' -> apostrophe‘ Change-Id: Ie6d367639cb80ec9f11e4d824b87f537e5285182 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95213 Tested-by: Jenkins Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/misc/svxacorr.cxx22
1 files changed, 22 insertions, 0 deletions
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index 24a5235e9c1a..b381b1726f45 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -316,6 +316,7 @@ static constexpr sal_Unicode cRightDoubleAngleQuote = 0xBB;
// (the first character is also the opening quote we are looking for)
const sal_Unicode aStopDoubleAngleQuoteStart[] = { 0x201E, 0x201D, 0 }; // preceding ,,
const sal_Unicode aStopDoubleAngleQuoteEnd[] = { cRightDoubleAngleQuote, cLeftDoubleAngleQuote, 0x201D, 0x201E, 0 }; // preceding >>
+const sal_Unicode aStopSingleQuoteEnd[] = { 0x201A, 0x2018, 0x201C, 0x201E, 0 };
SvxAutoCorrect::SvxAutoCorrect( const OUString& rShareAutocorrFile,
const OUString& rUserAutocorrFile )
@@ -1209,6 +1210,8 @@ void SvxAutoCorrect::InsertQuote( SvxAutoCorrDoc& rDoc, sal_Int32 nInsPos,
? cLeftDoubleAngleQuote
: cRightDoubleAngleQuote;
}
+ else if ( eType == ACQuotes::UseApostrophe )
+ cRet = cApostrophe;
else
cRet = GetQuote( cInsChar, bSttQuote, eLang );
@@ -1341,6 +1344,25 @@ void SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt,
{
eType = ACQuotes::DoubleAngleQuote;
}
+ // 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.
+ else if ( bSingle && nInsPos && !bSttQuote &&
+ ( primary(eLang) == primary(LANGUAGE_GERMAN) || eLang.anyOf (
+ LANGUAGE_CZECH,
+ LANGUAGE_ICELANDIC,
+ LANGUAGE_SLOVAK,
+ LANGUAGE_SLOVENIAN ) ) &&
+ !lcl_HasPrecedingChar( rTxt, nInsPos, aStopSingleQuoteEnd[0], aStopSingleQuoteEnd + 1 ) )
+ {
+ LocaleDataWrapper& rLcl = GetLocaleDataWrapper( eLang );
+ CharClass& rCC = GetCharClass( eLang );
+ if ( rLcl.getQuotationMarkStart() == OUStringChar(aStopSingleQuoteEnd[0]) &&
+ // use apostrophe only after letters, not after digits or punctuation
+ rCC.isLetter(rTxt, nInsPos-1) )
+ {
+ eType = ACQuotes::UseApostrophe;
+ }
+ }
}
if ( eType == ACQuotes::NONE && !bSingle &&