summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2019-04-01 21:57:13 +0200
committerAdolfo Jayme Barrientos <fitojb@ubuntu.com>2019-04-03 17:53:19 +0200
commit62ba1f0af72b0c86889a3aea19efd76da3cbe840 (patch)
treeaf5ca1db36fafccc59bb2d7087e431cefc52d858 /editeng
parent01f5cc7c6a1467ec3a788ffb0fb29a6a64963578 (diff)
tdf#108423 autocorrect English word i' -> I’
Now correction of the ASCII quotation mark to the typographical one (’) capitalizes the preceding single lowercase i, too, as in MSO, if the language of the text is English. Change-Id: Ic7586f07aa13f441e25494ff4cc11c672ac4a67a Reviewed-on: https://gerrit.libreoffice.org/70088 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org> (cherry picked from commit 376e3a4893356d2eb7c2a5a902b533982e2663ae) Reviewed-on: https://gerrit.libreoffice.org/70190 Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/misc/svxacorr.cxx23
1 files changed, 21 insertions, 2 deletions
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index 2d3a3069241d..e1a32bb154b5 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -1168,7 +1168,7 @@ 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 bIns, bool b_iApostrophe )
{
const LanguageType eLang = GetDocLanguage( rDoc, nInsPos );
sal_Unicode cRet = GetQuote( cInsChar, bSttQuote, eLang );
@@ -1200,6 +1200,22 @@ void SvxAutoCorrect::InsertQuote( SvxAutoCorrDoc& rDoc, sal_Int32 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))
+ {
+ rDoc.Replace( nInsPos-1, "I" );
+ }
}
OUString SvxAutoCorrect::GetQuote( SvxAutoCorrDoc const & rDoc, sal_Int32 nInsPos,
@@ -1255,6 +1271,7 @@ void SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt,
{
sal_Unicode cPrev;
bool bSttQuote = !nInsPos;
+ bool b_iApostrophe = false;
if (!bSttQuote)
{
cPrev = rTxt[ nInsPos-1 ];
@@ -1262,8 +1279,10 @@ void SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt,
lcl_IsInAsciiArr( "([{", cPrev ) ||
( cEmDash == cPrev ) ||
( cEnDash == cPrev );
+ b_iApostrophe = bSingle && ( cPrev == 'i' ) &&
+ (( nInsPos == 1 ) || IsWordDelim( rTxt[ nInsPos-2 ] ));
}
- InsertQuote( rDoc, nInsPos, cChar, bSttQuote, bInsert );
+ InsertQuote( rDoc, nInsPos, cChar, bSttQuote, bInsert, b_iApostrophe );
break;
}