summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2014-04-21 12:43:32 +0200
committerLászló Németh <nemeth@numbertext.org>2014-04-21 12:46:02 +0200
commit022e351c2431e0260220a51a54d576f49f789ebc (patch)
treedc701cef5c51605b6b8d0256cb423e0e445241ea /editeng
parentfdb9807a10885efdf71b0f0654ef79d8113bcabf (diff)
fdo#77603 new wildcard in autocorrection: .* instead of *
Change-Id: I04700e742239c97de39cf502fd8b0845b03c4e3a
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/misc/svxacorr.cxx19
1 files changed, 11 insertions, 8 deletions
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index 6d0fd5113478..b04a77788d86 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -73,7 +73,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";
@@ -2745,7 +2744,8 @@ const SvxAutocorrWord* SvxAutocorrWordList::WordMatches(const SvxAutocorrWord *p
sal_Int32 nEndPos) const
{
const OUString& rChk = pFnd->GetShort();
- sal_Int32 left_wildcard = ( rChk[0] == C_ASTERISK ) ? 1 : 0; // "*word" pattern?
+
+ sal_Int32 left_wildcard = rChk.startsWith( ".*" ) ? 2 : 0; // ".*word" pattern?
sal_Int32 nSttWdPos = nEndPos;
if( nEndPos >= rChk.getLength() - left_wildcard)
{
@@ -2758,22 +2758,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 ])))