summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2013-08-23 11:35:27 +0200
committerLászló Németh <nemeth@numbertext.org>2013-08-23 11:42:47 +0200
commit9eb39ccff8741d59e47af34b4038b7fcb79d15c2 (patch)
tree72d77043c435219b2b674e422a0ed4c5852e88fd /editeng
parent19cb39f0ffafaaa2f016035bd4ec297b87652681 (diff)
fdo#68373 allow "*word" pattern matching
Change-Id: I13682f3886451838e522b259dbb2d686bff1437b
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/misc/svxacorr.cxx25
1 files changed, 16 insertions, 9 deletions
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index b8406f8b3727..043cba5494fe 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -2710,20 +2710,29 @@ const SvxAutocorrWord* SvxAutocorrWordList::WordMatches(const SvxAutocorrWord *p
xub_StrLen nEndPos) const
{
const String& rChk = pFnd->GetShort();
- if( nEndPos >= rChk.Len() )
+ xub_StrLen left_wildcard = ( rChk.GetChar( 0 ) == C_ASTERISK ) ? 1 : 0; // "*word" pattern?
+ xub_StrLen nSttWdPos = nEndPos;
+ bool bWasWordDelim = false;
+ if( nEndPos >= rChk.Len() - left_wildcard)
{
- xub_StrLen nCalcStt = nEndPos - rChk.Len();
- if( ( !nCalcStt || nCalcStt == rStt ||
+
+ xub_StrLen nCalcStt = nEndPos - rChk.Len() + left_wildcard;
+ if( ( !nCalcStt || nCalcStt == rStt || left_wildcard ||
( nCalcStt < rStt &&
IsWordDelim( rTxt.GetChar( nCalcStt - 1 ) ))) )
{
TransliterationWrapper& rCmp = GetIgnoreTranslWrapper();
-
- OUString sWord(rTxt.GetBuffer() + nCalcStt, rChk.Len());
- if( rCmp.isEqual( rChk, sWord ))
+ OUString sWord(rTxt.GetBuffer() + nCalcStt, rChk.Len() - left_wildcard);
+ if( (!left_wildcard && rCmp.isEqual( rChk, sWord )) || (left_wildcard && rCmp.isEqual( rChk.Copy(1), sWord) ))
{
rStt = nCalcStt;
- return pFnd;
+ if (!left_wildcard) return pFnd;
+ // get the first word delimiter position before the matching "*word" pattern
+ while( rStt && !(bWasWordDelim = IsWordDelim( rTxt.GetChar( --rStt ))))
+ ;
+ if (bWasWordDelim) rStt++;
+ SvxAutocorrWord* pNew = new SvxAutocorrWord(OUString(rTxt.GetBuffer() + rStt, nEndPos - rStt), OUString(rTxt.GetBuffer() + rStt, nEndPos - rStt - rChk.Len() + 1) + OUString(pFnd->GetLong()));
+ if( Insert( pNew ) ) return pNew; else delete pNew;
}
}
// match "word*" patterns, eg. "i18n*"
@@ -2731,8 +2740,6 @@ const SvxAutocorrWord* SvxAutocorrWordList::WordMatches(const SvxAutocorrWord *p
{
String sTmp( rChk.Copy( 0, rChk.Len() - 1 ) );
// Get the last word delimiter position
- xub_StrLen nSttWdPos = nEndPos;
- bool bWasWordDelim = false;
bool not_suffix;
while( nSttWdPos && !(bWasWordDelim = IsWordDelim( rTxt.GetChar( --nSttWdPos ))))
;