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