Kaydet (Commit) 623da78e authored tarafından László Németh's avatar László Németh Kaydeden (comit) Andras Timar

AutoCorrect: fix not immediately replacement of Emoji :short_names:

Cherry-picked from 86782d5d
and cd2ba312.

[86782d5d:

AutoCorrect: direct replacement of keywords surrounded by colons

Replacing immediately (without pressing space or enter) and
inside words, too. For example, fixing tdf#55292 – complete input
method for n-dash, m-dash – is possible now by  :--: -> n-dash,
:---: -> m-dash AutoCorrect replacements.]

cd2ba312:

unbreak calc again, a fix for the previous commit by Markus Mohrhard]

Change-Id: Id7d9411599bec620fa91c246b531d26150f20c6a
Reviewed-on: https://gerrit.libreoffice.org/16002Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>
üst 7dfd0e88
...@@ -2825,12 +2825,17 @@ const SvxAutocorrWord* SvxAutocorrWordList::WordMatches(const SvxAutocorrWord *p ...@@ -2825,12 +2825,17 @@ const SvxAutocorrWord* SvxAutocorrWordList::WordMatches(const SvxAutocorrWord *p
sal_Int32 right_wildcard = rChk.endsWith( ".*" ) ? 2 : 0; // "word.*" pattern? sal_Int32 right_wildcard = rChk.endsWith( ".*" ) ? 2 : 0; // "word.*" pattern?
sal_Int32 nSttWdPos = nEndPos; sal_Int32 nSttWdPos = nEndPos;
if ( nEndPos >= rChk.getLength() - left_wildcard - right_wildcard ) // direct replacement of keywords surrounded by colons (for example, ":name:")
bool bColonNameColon = rTxt.getLength() > nEndPos &&
rTxt[nEndPos] == ':' && rChk[0] == ':' && rChk.endsWith(":");
if ( nEndPos + (bColonNameColon ? 1 : 0) >= rChk.getLength() - left_wildcard - right_wildcard )
{ {
bool bWasWordDelim = false; bool bWasWordDelim = false;
sal_Int32 nCalcStt = nEndPos - rChk.getLength() + left_wildcard; sal_Int32 nCalcStt = nEndPos - rChk.getLength() + left_wildcard;
if( !right_wildcard && ( !nCalcStt || nCalcStt == rStt || left_wildcard || if (bColonNameColon)
nCalcStt++;
if( !right_wildcard && ( !nCalcStt || nCalcStt == rStt || left_wildcard || bColonNameColon ||
( nCalcStt < rStt && ( nCalcStt < rStt &&
IsWordDelim( rTxt[ nCalcStt - 1 ] ))) ) IsWordDelim( rTxt[ nCalcStt - 1 ] ))) )
{ {
......
...@@ -326,8 +326,11 @@ bool SwAutoCorrDoc::ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos, ...@@ -326,8 +326,11 @@ bool SwAutoCorrDoc::ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos,
SwDoc* pDoc = rEditSh.GetDoc(); SwDoc* pDoc = rEditSh.GetDoc();
if( pFnd ) if( pFnd )
{ {
// replace also last colon of keywords surrounded by colons (for example, ":name:")
bool replaceLastChar = pFnd->GetShort()[0] == ':' && pFnd->GetShort().endsWith(":");
const SwNodeIndex& rNd = rCrsr.GetPoint()->nNode; const SwNodeIndex& rNd = rCrsr.GetPoint()->nNode;
SwPaM aPam( rNd, rSttPos, rNd, nEndPos ); SwPaM aPam( rNd, rSttPos, rNd, nEndPos + (replaceLastChar ? 1 : 0) );
if( pFnd->IsTextOnly() ) if( pFnd->IsTextOnly() )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment