Lines 49-55
Link Here
|
49 |
#include <sb.hrc> |
49 |
#include <sb.hrc> |
50 |
#include <basrid.hxx> |
50 |
#include <basrid.hxx> |
51 |
#include "sbunoobj.hxx" |
51 |
#include "sbunoobj.hxx" |
|
|
52 |
#include "image.hxx" |
52 |
#include <com/sun/star/uno/Any.hxx> |
53 |
#include <com/sun/star/uno/Any.hxx> |
|
|
54 |
#include <com/sun/star/util/SearchOptions.hdl> |
55 |
#include <vcl/svapp.hxx> |
56 |
#include <unotools/textsearch.hxx> |
53 |
|
57 |
|
54 |
#include <algorithm> |
58 |
#include <algorithm> |
55 |
|
59 |
|
Lines 166-174
Link Here
|
166 |
void SbiRuntime::StepLE() { StepCompare( SbxLE ); } |
170 |
void SbiRuntime::StepLE() { StepCompare( SbxLE ); } |
167 |
void SbiRuntime::StepGE() { StepCompare( SbxGE ); } |
171 |
void SbiRuntime::StepGE() { StepCompare( SbxGE ); } |
168 |
|
172 |
|
|
|
173 |
namespace |
174 |
{ |
175 |
bool NeedEsc(sal_Unicode cCode) |
176 |
{ |
177 |
String sEsc(RTL_CONSTASCII_USTRINGPARAM(".^$+\\|{}()")); |
178 |
return (STRING_NOTFOUND != sEsc.Search(cCode)); |
179 |
} |
180 |
|
181 |
String VBALikeToRegexp(const String &rIn) |
182 |
{ |
183 |
String sResult; |
184 |
const sal_Unicode *start = rIn.GetBuffer(); |
185 |
const sal_Unicode *end = start + rIn.Len(); |
186 |
|
187 |
int seenright = 0; |
188 |
|
189 |
sResult.Append('^'); |
190 |
|
191 |
while (start < end) |
192 |
{ |
193 |
switch (*start) |
194 |
{ |
195 |
case '?': |
196 |
sResult.Append('.'); |
197 |
start++; |
198 |
break; |
199 |
case '*': |
200 |
sResult.Append(String(RTL_CONSTASCII_USTRINGPARAM(".*"))); |
201 |
start++; |
202 |
break; |
203 |
case '#': |
204 |
sResult.Append(String(RTL_CONSTASCII_USTRINGPARAM("[0-9]"))); |
205 |
start++; |
206 |
break; |
207 |
case ']': |
208 |
sResult.Append('\\'); |
209 |
sResult.Append(*start++); |
210 |
break; |
211 |
case '[': |
212 |
sResult.Append(*start++); |
213 |
seenright = 0; |
214 |
while (start < end && !seenright) |
215 |
{ |
216 |
switch (*start) |
217 |
{ |
218 |
case '[': |
219 |
case '?': |
220 |
case '*': |
221 |
sResult.Append('\\'); |
222 |
sResult.Append(*start); |
223 |
break; |
224 |
case ']': |
225 |
sResult.Append(*start); |
226 |
seenright = 1; |
227 |
break; |
228 |
default: |
229 |
if (NeedEsc(*start)) |
230 |
sResult.Append('\\'); |
231 |
sResult.Append(*start); |
232 |
break; |
233 |
} |
234 |
start++; |
235 |
} |
236 |
break; |
237 |
default: |
238 |
if (NeedEsc(*start)) |
239 |
sResult.Append('\\'); |
240 |
sResult.Append(*start++); |
241 |
} |
242 |
} |
243 |
|
244 |
sResult.Append('$'); |
245 |
|
246 |
return sResult; |
247 |
} |
248 |
} |
249 |
|
169 |
void SbiRuntime::StepLIKE() |
250 |
void SbiRuntime::StepLIKE() |
170 |
{ |
251 |
{ |
171 |
StarBASIC::FatalError( SbERR_NOT_IMPLEMENTED ); |
252 |
SbxVariableRef refVar1 = PopVar(); |
|
|
253 |
SbxVariableRef refVar2 = PopVar(); |
254 |
|
255 |
String pattern = VBALikeToRegexp(refVar1->GetString()); |
256 |
String value = refVar2->GetString(); |
257 |
|
258 |
com::sun::star::util::SearchOptions aSearchOpt; |
259 |
|
260 |
aSearchOpt.algorithmType = com::sun::star::util::SearchAlgorithms_REGEXP; |
261 |
|
262 |
aSearchOpt.Locale = Application::GetSettings().GetLocale(); |
263 |
aSearchOpt.searchString = pattern; |
264 |
|
265 |
int bTextMode(1); |
266 |
bool bCompatibility = ( pINST && pINST->IsCompatibility() ); |
267 |
if( bCompatibility ) |
268 |
bTextMode = GetImageFlag( SBIMG_COMPARETEXT ); |
269 |
|
270 |
if( bTextMode ) |
271 |
aSearchOpt.transliterateFlags |= com::sun::star::i18n::TransliterationModules_IGNORE_CASE; |
272 |
|
273 |
SbxVariable* pRes = new SbxVariable; |
274 |
utl::TextSearch aSearch(aSearchOpt); |
275 |
xub_StrLen nStart=0, nEnd=value.Len(); |
276 |
int bRes = aSearch.SearchFrwrd(value, &nStart, &nEnd); |
277 |
pRes->PutBool( bRes ); |
278 |
|
279 |
PushVar( pRes ); |
172 |
} |
280 |
} |
173 |
|
281 |
|
174 |
// TOS und TOS-1 sind beides Objektvariable und enthalten den selben Pointer |
282 |
// TOS und TOS-1 sind beides Objektvariable und enthalten den selben Pointer |