summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2019-04-01 21:57:13 +0200
committerLászló Németh <nemeth@numbertext.org>2019-04-02 09:33:42 +0200
commit376e3a4893356d2eb7c2a5a902b533982e2663ae (patch)
tree4147f37dc24373ac0a8485358583cedcbb735dc2 /editeng
parent7ac53984d7749e50cf2f6f2dcc19e3d53d7ff603 (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>
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 c85c8a55e1b2..ca29b4e22f7c 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -1180,7 +1180,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 );
@@ -1212,6 +1212,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,
@@ -1267,6 +1283,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 ];
@@ -1274,8 +1291,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;
}