diff options
author | László Németh <nemeth@numbertext.org> | 2014-04-21 12:43:32 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2014-04-22 09:46:38 +0200 |
commit | e098576f4629a3ff42b963d7f589ed41c0cadca2 (patch) | |
tree | b5707c13e20e0da1c23752bb4b864ef9fc6a0e23 | |
parent | eae151d7784e5a1f4400d2042ec2683a89ec6b36 (diff) |
fdo#77603 new wildcard in autocorrection: .* instead of *
(cherry picked from commit 022e351c2431e0260220a51a54d576f49f789ebc)
Conflicts:
editeng/source/misc/svxacorr.cxx
Change-Id: I04700e742239c97de39cf502fd8b0845b03c4e3a
-rw-r--r-- | editeng/source/misc/svxacorr.cxx | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx index 667f5614cb6d..f0501f3917c9 100644 --- a/editeng/source/misc/svxacorr.cxx +++ b/editeng/source/misc/svxacorr.cxx @@ -72,7 +72,6 @@ static const int C_NONE = 0x00; static const int C_FULL_STOP = 0x01; static const int C_EXCLAMATION_MARK = 0x02; static const int C_QUESTION_MARK = 0x04; -static const int C_ASTERISK = 0x2A; static const sal_Unicode cNonBreakingSpace = 0xA0; static const sal_Char pXMLImplWrdStt_ExcptLstStr[] = "WordExceptList.xml"; @@ -2761,7 +2760,7 @@ const SvxAutocorrWord* SvxAutocorrWordList::WordMatches(const SvxAutocorrWord *p sal_Int32 nEndPos) const { const OUString& rChk = pFnd->GetShort(); - xub_StrLen left_wildcard = ( rChk[0] == C_ASTERISK ) ? 1 : 0; // "*word" pattern? + xub_StrLen left_wildcard = rChk.startsWith( ".*" ) ? 2 : 0; // ".*word" pattern? xub_StrLen nSttWdPos = nEndPos; if( nEndPos >= rChk.getLength() - left_wildcard) { @@ -2774,22 +2773,25 @@ const SvxAutocorrWord* SvxAutocorrWordList::WordMatches(const SvxAutocorrWord *p { TransliterationWrapper& rCmp = GetIgnoreTranslWrapper(); OUString sWord = rTxt.copy(nCalcStt, rChk.getLength() - left_wildcard); - if( (!left_wildcard && rCmp.isEqual( rChk, sWord )) || (left_wildcard && rCmp.isEqual( rChk.copy(1), sWord) )) + if( (!left_wildcard && rCmp.isEqual( rChk, sWord )) || (left_wildcard && rCmp.isEqual( rChk.copy(left_wildcard), sWord) )) { rStt = nCalcStt; if (!left_wildcard) return pFnd; - // get the first word delimiter position before the matching "*word" pattern + // get the first word delimiter position before the matching ".*word" pattern while( rStt && !(bWasWordDelim = IsWordDelim( rTxt[ --rStt ]))) ; if (bWasWordDelim) rStt++; - SvxAutocorrWord* pNew = new SvxAutocorrWord(rTxt.copy(rStt, nEndPos - rStt), rTxt.copy(rStt, nEndPos - rStt - rChk.getLength() + 1) + pFnd->GetLong()); + OUString left_pattern = rTxt.copy(rStt, nEndPos - rStt - rChk.getLength() + left_wildcard); + // avoid double spaces before simple "word" replacement + left_pattern += (left_pattern.getLength() == 0 && pFnd->GetLong()[0] == 0x20) ? pFnd->GetLong().copy(1) : pFnd->GetLong(); + SvxAutocorrWord* pNew = new SvxAutocorrWord(rTxt.copy(rStt, nEndPos - rStt), left_pattern); if( Insert( pNew ) ) return pNew; else delete pNew; } } - // match "word*" patterns, eg. "i18n*" - if ( rChk[ rChk.getLength() - 1] == C_ASTERISK ) + // match "word.*" patterns, eg. "i18n.*" + if ( rChk.endsWith( ".*" ) ) { - OUString sTmp( rChk.copy( 0, rChk.getLength() - 1 ) ); + OUString sTmp( rChk.copy( 0, rChk.getLength() - 2 ) ); // Get the last word delimiter position bool not_suffix; while( nSttWdPos && !(bWasWordDelim = IsWordDelim( rTxt[ --nSttWdPos ]))) |