[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-6-4' - 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 1af4ce1b76226862197f649b240e780b5c981ccc Author: László Németh AuthorDate: Thu May 28 08:50:39 2020 +0200 Commit: Gabor Kelemen CommitDate: Wed Jul 22 20:43:59 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 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98952 Tested-by: Gabor Kelemen Reviewed-by: Gabor Kelemen diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx index ad85d8f89550..9c0dbc2629da 100644 --- a/editeng/source/misc/svxacorr.cxx +++ b/editeng/source/misc/svxacorr.cxx @@ -264,6 +264,7 @@ bool SvxAutoCorrect::IsAutoCorrectChar( sal_Unicode cChar ) cChar == '*' || cChar == '_' || cChar == '%' || cChar == '.' || cChar == ',' || cChar == ';' || cChar == ':' || cChar == '?' || cChar == '!' || +cChar == '<' || cChar == '>' || cChar == '/' || cChar == '-'; } @@ -314,6 +315,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 ) @@ -1192,7 +1199,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 ) @@ -1211,6 +1227,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 ); @@ -1240,6 +1261,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 SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUSt
[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-6-4' - editeng/source include/editeng
editeng/source/misc/svxacorr.cxx | 55 +-- include/editeng/svxacorr.hxx | 10 ++- 2 files changed, 33 insertions(+), 32 deletions(-) New commits: commit aad0972496411d8ef3834f699b4b1211c2998ab5 Author: László Németh AuthorDate: Wed May 27 18:15:26 2020 +0200 Commit: Gabor Kelemen CommitDate: Tue Jul 21 11:51:04 2020 +0200 AutoCorrect: clean-up InsertQuote Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95211 Tested-by: László Németh Reviewed-by: László Németh (cherry picked from commit c87c7ddca46ae093a703ca673a204e4593402c38) Change-Id: I577115805e5bcc29f6eb4d853aaa523495f30126 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99052 Tested-by: Gabor Kelemen Reviewed-by: Gabor Kelemen diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx index 10f91239625a..ad85d8f89550 100644 --- a/editeng/source/misc/svxacorr.cxx +++ b/editeng/source/misc/svxacorr.cxx @@ -1190,9 +1190,8 @@ sal_Unicode SvxAutoCorrect::GetQuote( sal_Unicode cInsChar, bool bSttQuote, void SvxAutoCorrect::InsertQuote( SvxAutoCorrDoc& rDoc, sal_Int32 nInsPos, sal_Unicode cInsChar, bool bSttQuote, -bool bIns, bool b_iApostrophe ) const +bool bIns, LanguageType eLang, ACQuotes eType ) const { -const LanguageType eLang = GetDocLanguage( rDoc, nInsPos ); sal_Unicode cRet = GetQuote( cInsChar, bSttQuote, eLang ); OUString sChg( cInsChar ); @@ -1203,36 +1202,21 @@ void SvxAutoCorrect::InsertQuote( SvxAutoCorrDoc& rDoc, sal_Int32 nInsPos, sChg = OUString(cRet); -if( '\"' == cInsChar ) +if( eType == ACQuotes::NonBreakingSpace ) { -if (primary(eLang) == primary(LANGUAGE_FRENCH) && eLang != LANGUAGE_FRENCH_SWISS) +OUString s( cNonBreakingSpace ); // UNICODE code for no break space +if( rDoc.Insert( bSttQuote ? nInsPos+1 : nInsPos, s )) { -OUString s( cNonBreakingSpace ); // UNICODE code for no break space -if( rDoc.Insert( bSttQuote ? nInsPos+1 : nInsPos, s )) -{ -if( !bSttQuote ) -++nInsPos; -} +if( !bSttQuote ) +++nInsPos; } } rDoc.Replace( nInsPos, sChg ); -// i' -> I' in English (last step for the undo) -if( b_iApostrophe && eLang.anyOf( -LANGUAGE_ENGLISH, -LANGUAGE_ENGLISH_US, -LANGUAGE_ENGLISH_UK, -LANGUAGE_ENGLISH_AUS, -LANGUAGE_ENGLISH_CAN, -LANGUAGE_ENGLISH_NZ, -LANGUAGE_ENGLISH_EIRE, -LANGUAGE_ENGLISH_SAFRICA, -LANGUAGE_ENGLISH_JAMAICA, -LANGUAGE_ENGLISH_CARRIBEAN)) -{ +// i' -> I' in English (last step for the Undo) +if( eType == ACQuotes::CapitalizeIAm ) rDoc.Replace( nInsPos-1, "I" ); -} } OUString SvxAutoCorrect::GetQuote( SvxAutoCorrDoc const & rDoc, sal_Int32 nInsPos, @@ -1283,7 +1267,8 @@ void SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt, { sal_Unicode cPrev; bool bSttQuote = !nInsPos; -bool b_iApostrophe = false; +ACQuotes eType = ACQuotes::NONE; +const LanguageType eLang = GetDocLanguage( rDoc, nInsPos ); if (!bSttQuote) { cPrev = rTxt[ nInsPos-1 ]; @@ -1293,17 +1278,25 @@ void SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt, ( cEnDash == cPrev ); // tdf#38394 use opening quotation mark << in French l'<> if ( !bSingle && !bSttQuote && cPrev == cApostrophe && +primary(eLang) == primary(LANGUAGE_FRENCH) && (nInsPos == 2 || (nInsPos > 2 && IsWordDelim( rTxt[ nInsPos-3 ] ))) ) { -const LanguageType eLang = GetDocLanguage( rDoc, nInsPos ); -if ( primary(eLang) == primary(LANGUAGE_FRENCH) ) -bSttQuote = true; +bSttQuote = true; } // tdf#108423 for capitalization of English i'm -b_iApostrophe = bSingle && ( cPrev == 'i' ) && -(( nInsPos == 1 ) || IsWordDelim( rTxt[ nInsPos-2 ] )); +else if ( bSingle && ( cPrev == 'i' ) && +primary(eLang) == primary(LANGUAGE_ENGLISH) && +( nInsPos == 1 || IsWordDelim( rTxt[ nInsPos-2 ] ) ) ) +{ +eType = ACQuotes::CapitalizeIAm; +} } -InsertQuote( rDoc, nInsPos, cChar, bSttQuote, bInsert, b_iApostrophe ); + +if ( eType == ACQuotes: