[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - editeng/source include/editeng sw/qa
editeng/source/misc/svxacorr.cxx | 22 ++ include/editeng/svxacorr.hxx |1 + sw/qa/extras/uiwriter/data/tdf128860.fodt | 14 ++ sw/qa/extras/uiwriter/uiwriter.cxx| 27 +++ 4 files changed, 64 insertions(+) New commits: commit c3ef223ba5f893f8096d205ef09b5f5262ab6baa Author: László Németh AuthorDate: Fri May 29 16:46:44 2020 +0200 Commit: Xisco Fauli CommitDate: Tue Jun 2 15:42:43 2020 +0200 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 Reviewed-by: László Németh (cherry picked from commit a0c90f1bccd9b5a349d3199746facab549f27dba) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95316 Reviewed-by: Xisco Fauli 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 && diff --git a/include/editeng/svxacorr.hxx b/include/editeng/svxacorr.hxx index c9d9a866a949..697ac614f76d 100644 --- a/include/editeng/svxacorr.hxx +++ b/include/editeng/svxacorr.hxx @@ -86,6 +86,7 @@ enum class ACQuotes NonBreakingSpace, CapitalizeIAm, DoubleAngleQuote, +UseApostrophe, }; // TODO: handle code points > U+ and check users of this class diff --git a/sw/qa/extras/uiwriter/data/tdf128860.fodt b/sw/qa/extras/uiwriter/data/tdf128860.fodt new file mode 100644 index ..5e93b60f667b --- /dev/null +++ b/sw/qa/extras/uiwriter/data/tdf128860.fodt @@ -0,0 +1,14 @@ + +http://openoffice.org/2009/office; xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text"> + + + + + + + + + + + + diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 9ba5cb946328..1cdc40cc43a6 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -369,6
[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - editeng/source include/editeng sw/qa
editeng/source/misc/svxacorr.cxx | 74 +- include/editeng/svxacorr.hxx |1 sw/qa/extras/uiwriter/data/tdf133524.fodt | 14 + sw/qa/extras/uiwriter/uiwriter.cxx| 49 +++ 4 files changed, 137 insertions(+), 1 deletion(-) New commits: commit 4f0751949b6c2a495891e67a893ef98d4e4b5a80 Author: László Németh AuthorDate: Thu May 28 08:50:39 2020 +0200 Commit: Adolfo Jayme Barrientos CommitDate: Tue Jun 2 01:15:11 2020 +0200 tdf#133524 AutoCorrect: support double angle quotes Add two methods to support double angle quotes, as part of "Double quotes" replacement: 1. Correct ">>" and "<<" to » and « in several languages, where double angle quotes are default or alternative primary or second level quotation marks, but actual LibreOffice locale settings don't contain double angle quotes. 2. Correct " to double angle quotes, if the cursor is there in a primary level quotation (i.e. there is a preceding primary level opening quote, but not other quotes). For example, it's possible to type Hungarian or Romanian quotation marks in „... »quote« ...” pressing only Shift + 2 (") for them. (These languages, where "Single quotes" replacement is used for apostrophe and third level quotes instead of the standard second level quotation marks.) Change-Id: Icd1584a5a2b81422de693217d2d1f7f3058a74b1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95212 Tested-by: Jenkins Tested-by: László Németh Reviewed-by: László Németh (cherry picked from commit 57f07b1d7378d218648667c5b1315cc8ad905875) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95310 Reviewed-by: Adolfo Jayme Barrientos diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx index ebc0ec810a60..24a5235e9c1a 100644 --- a/editeng/source/misc/svxacorr.cxx +++ b/editeng/source/misc/svxacorr.cxx @@ -259,6 +259,7 @@ bool SvxAutoCorrect::IsAutoCorrectChar( sal_Unicode cChar ) cChar == '*' || cChar == '_' || cChar == '%' || cChar == '.' || cChar == ',' || cChar == ';' || cChar == ':' || cChar == '?' || cChar == '!' || +cChar == '<' || cChar == '>' || cChar == '/' || cChar == '-'; } @@ -309,6 +310,12 @@ ACFlags SvxAutoCorrect::GetDefaultFlags() static constexpr sal_Unicode cEmDash = 0x2014; static constexpr sal_Unicode cEnDash = 0x2013; static constexpr sal_Unicode cApostrophe = 0x2019; +static constexpr sal_Unicode cLeftDoubleAngleQuote = 0xAB; +static constexpr sal_Unicode cRightDoubleAngleQuote = 0xBB; +// stop characters for searching preceding quotes +// (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 >> SvxAutoCorrect::SvxAutoCorrect( const OUString& rShareAutocorrFile, const OUString& rUserAutocorrFile ) @@ -1194,7 +1201,16 @@ void SvxAutoCorrect::InsertQuote( SvxAutoCorrDoc& rDoc, sal_Int32 nInsPos, sal_Unicode cInsChar, bool bSttQuote, bool bIns, LanguageType eLang, ACQuotes eType ) const { -sal_Unicode cRet = GetQuote( cInsChar, bSttQuote, eLang ); +sal_Unicode cRet; + +if ( eType == ACQuotes::DoubleAngleQuote ) +{ +cRet = ( '<' == cInsChar || ('\"' == cInsChar && !bSttQuote) ) +? cLeftDoubleAngleQuote +: cRightDoubleAngleQuote; +} +else +cRet = GetQuote( cInsChar, bSttQuote, eLang ); OUString sChg( cInsChar ); if( bIns ) @@ -1213,6 +1229,11 @@ void SvxAutoCorrect::InsertQuote( SvxAutoCorrDoc& rDoc, sal_Int32 nInsPos, ++nInsPos; } } +else if( eType == ACQuotes::DoubleAngleQuote && cInsChar != '\"' ) +{ +rDoc.Delete( nInsPos-1, nInsPos); +--nInsPos; +} rDoc.Replace( nInsPos, sChg ); @@ -1242,6 +1263,26 @@ OUString SvxAutoCorrect::GetQuote( SvxAutoCorrDoc const & rDoc, sal_Int32 nInsPo return sRet; } +// search preceding opening quote in the paragraph before the insert position +static bool lcl_HasPrecedingChar( const OUString& rTxt, sal_Int32 nPos, +const sal_Unicode sPrecedingChar, const sal_Unicode* aStopChars ) +{ +sal_Unicode cTmpChar; + +do { +cTmpChar = rTxt[ --nPos ]; +if ( cTmpChar == sPrecedingChar ) +return true; + +for ( const sal_Unicode* pCh = aStopChars; *pCh; ++pCh ) +if ( cTmpChar == *pCh ) +return false; + +} while ( nPos > 0 ); + +return false; +} + // WARNING: rText may become invalid, see comment below void