Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #ifdef DBG_UTIL
21 : : static sal_Bool ImplDbgCheckAsciiStr( const sal_Char* pAsciiStr, sal_Int32 nLen )
22 : : {
23 : : while ( nLen && *pAsciiStr )
24 : : {
25 : : if ( ((unsigned char)*pAsciiStr) > 127 )
26 : : return sal_False;
27 : : ++pAsciiStr,
28 : : --nLen;
29 : : }
30 : :
31 : : return sal_True;
32 : : }
33 : : #endif
34 : :
35 : 525199 : static void ImplCopyAsciiStr( sal_Unicode* pDest, const sal_Char* pSrc,
36 : : sal_Int32 nLen )
37 : : {
38 : : DBG_ASSERT( ImplDbgCheckAsciiStr( pSrc, nLen ),
39 : : "UniString::CopyAsciiStr() - pAsciiStr include characters > 127" );
40 : :
41 [ + + ]: 2703086 : while ( nLen )
42 : : {
43 : 2177887 : *pDest = (unsigned char)*pSrc;
44 : : ++pDest,
45 : : ++pSrc,
46 : 2177887 : --nLen;
47 : : }
48 : 525199 : }
49 : :
50 : 1633755 : static sal_Int32 ImplStringCompareAscii( const sal_Unicode* pStr1, const sal_Char* pStr2 )
51 : : {
52 : : sal_Int32 nRet;
53 [ + + ][ + + ]: 11024892 : while ( ((nRet = ((sal_Int32)*pStr1)-((sal_Int32)((unsigned char)*pStr2))) == 0) &&
[ + + ]
54 : : *pStr2 )
55 : : {
56 : : ++pStr1,
57 : 9391137 : ++pStr2;
58 : : }
59 : :
60 : 1633755 : return nRet;
61 : : }
62 : :
63 : 2275964 : static sal_Int32 ImplStringCompareAscii( const sal_Unicode* pStr1, const sal_Char* pStr2,
64 : : xub_StrLen nCount )
65 : : {
66 : 2275964 : sal_Int32 nRet = 0;
67 [ + + ][ + + ]: 3853810 : while ( nCount &&
[ + + ][ + + ]
68 : : ((nRet = ((sal_Int32)*pStr1)-((sal_Int32)((unsigned char)*pStr2))) == 0) &&
69 : : *pStr2 )
70 : : {
71 : : ++pStr1,
72 : : ++pStr2,
73 : 1577846 : --nCount;
74 : : }
75 : :
76 : 2275964 : return nRet;
77 : : }
78 : :
79 : 76653883 : static sal_Int32 ImplStringCompareWithoutZeroAscii( const sal_Unicode* pStr1, const sal_Char* pStr2,
80 : : xub_StrLen nCount )
81 : : {
82 : 76653883 : sal_Int32 nRet = 0;
83 [ + + ][ + + ]: 78330550 : while ( nCount &&
[ + + ]
84 : : ((nRet = ((sal_Int32)*pStr1)-((sal_Int32)((unsigned char)*pStr2))) == 0) )
85 : : {
86 : : ++pStr1,
87 : : ++pStr2,
88 : 1676667 : --nCount;
89 : : }
90 : :
91 : 76653883 : return nRet;
92 : : }
93 : :
94 : 6043776 : static sal_Int32 ImplStringICompareAscii( const sal_Unicode* pStr1, const sal_Char* pStr2 )
95 : : {
96 : : sal_Int32 nRet;
97 : : sal_Unicode c1;
98 : : sal_Char c2;
99 [ + + ]: 2451096 : do
100 : : {
101 : : // Convert if char is between 'A' and 'Z'
102 : 6043776 : c1 = *pStr1;
103 : 6043776 : c2 = *pStr2;
104 [ + + ][ + + ]: 6043776 : if ( (c1 >= 65) && (c1 <= 90) )
105 : 1842466 : c1 += 32;
106 [ + + ][ + + ]: 6043776 : if ( (c2 >= 65) && (c2 <= 90) )
107 : 843838 : c2 += 32;
108 : 6043776 : nRet = ((sal_Int32)c1)-((sal_Int32)((unsigned char)c2));
109 [ + + ]: 6043776 : if ( nRet != 0 )
110 : 3592680 : break;
111 : :
112 : : ++pStr1,
113 : 2451096 : ++pStr2;
114 : : }
115 : : while ( c2 );
116 : :
117 : 3758864 : return nRet;
118 : : }
119 : :
120 : 308191522 : static sal_Int32 ImplStringICompareAscii( const sal_Unicode* pStr1, const sal_Char* pStr2,
121 : : xub_StrLen nCount )
122 : : {
123 : 308191522 : sal_Int32 nRet = 0;
124 : : sal_Unicode c1;
125 : : sal_Char c2;
126 [ + + ]: 38160203 : do
127 : : {
128 [ + + ]: 345936572 : if ( !nCount )
129 : 53954 : break;
130 : :
131 : : // Convert if char is between 'A' and 'Z'
132 : 345882618 : c1 = *pStr1;
133 : 345882618 : c2 = *pStr2;
134 [ + + ][ + + ]: 345882618 : if ( (c1 >= 65) && (c1 <= 90) )
135 : 311198710 : c1 += 32;
136 [ + + ][ + + ]: 345882618 : if ( (c2 >= 65) && (c2 <= 90) )
137 : 309150958 : c2 += 32;
138 : 345882618 : nRet = ((sal_Int32)c1)-((sal_Int32)((unsigned char)c2));
139 [ + + ]: 345882618 : if ( nRet != 0 )
140 : 307722415 : break;
141 : :
142 : : ++pStr1,
143 : : ++pStr2,
144 : 38160203 : --nCount;
145 : : }
146 : : while ( c2 );
147 : :
148 : 308191522 : return nRet;
149 : : }
150 : :
151 : 88326 : UniString& UniString::AssignAscii( const sal_Char* pAsciiStr )
152 : : {
153 : : DBG_CHKTHIS( UniString, DbgCheckUniString );
154 : : DBG_ASSERT( pAsciiStr, "UniString::AssignAscii() - pAsciiStr is NULL" );
155 : :
156 : : // Determine string length
157 : 88326 : xub_StrLen nLen = ImplStringLen( pAsciiStr );
158 : :
159 [ - + ]: 88326 : if ( !nLen )
160 : : {
161 : 0 : STRING_NEW((STRING_TYPE **)&mpData);
162 : : }
163 : : else
164 : : {
165 : : // Replace string in-place if new size is equal
166 [ + + ][ + + ]: 88326 : if ( (nLen == mpData->mnLen) && (mpData->mnRefCount == 1) )
167 : 510 : ImplCopyAsciiStr( mpData->maStr, pAsciiStr, nLen );
168 : : else
169 : : {
170 : : // release old string
171 : 87816 : STRING_RELEASE((STRING_TYPE *)mpData);
172 : :
173 : : // copy new string
174 : 87816 : mpData = ImplAllocData( nLen );
175 : 87816 : ImplCopyAsciiStr( mpData->maStr, pAsciiStr, nLen );
176 : : }
177 : : }
178 : :
179 : 88326 : return *this;
180 : : }
181 : :
182 : 426214 : UniString& UniString::AssignAscii( const sal_Char* pAsciiStr, xub_StrLen nLen )
183 : : {
184 : : DBG_CHKTHIS( UniString, DbgCheckUniString );
185 : : DBG_ASSERT( pAsciiStr, "UniString::AssignAscii() - pAsciiStr is NULL" );
186 : :
187 [ - + ]: 426214 : if ( nLen == STRING_LEN )
188 : 0 : nLen = ImplStringLen( pAsciiStr );
189 : :
190 : : #ifdef DBG_UTIL
191 : : if ( DbgIsAssert() )
192 : : {
193 : : for ( xub_StrLen i = 0; i < nLen; ++i )
194 : : {
195 : : if ( !pAsciiStr[i] )
196 : : {
197 : : OSL_FAIL( "UniString::AssignAscii() : nLen is wrong" );
198 : : }
199 : : }
200 : : }
201 : : #endif
202 : :
203 [ - + ]: 426214 : if ( !nLen )
204 : : {
205 : 0 : STRING_NEW((STRING_TYPE **)&mpData);
206 : : }
207 : : else
208 : : {
209 : : // Replace string in-place if new size is equal
210 [ + + ][ + + ]: 426214 : if ( (nLen == mpData->mnLen) && (mpData->mnRefCount == 1) )
211 : 270059 : ImplCopyAsciiStr( mpData->maStr, pAsciiStr, nLen );
212 : : else
213 : : {
214 : : // release old string
215 : 156155 : STRING_RELEASE((STRING_TYPE *)mpData);
216 : :
217 : : // copy new string
218 : 156155 : mpData = ImplAllocData( nLen );
219 : 156155 : ImplCopyAsciiStr( mpData->maStr, pAsciiStr, nLen );
220 : : }
221 : : }
222 : :
223 : 426214 : return *this;
224 : : }
225 : :
226 : 4167 : UniString& UniString::AppendAscii( const sal_Char* pAsciiStr )
227 : : {
228 : : DBG_CHKTHIS( UniString, DbgCheckUniString );
229 : : DBG_ASSERT( pAsciiStr, "UniString::AppendAscii() - pAsciiStr is NULL" );
230 : :
231 : : // determine string length
232 : 4167 : sal_Int32 nCopyLen = ImplStringLen( pAsciiStr );
233 : :
234 : : // detect overflow
235 : 4167 : nCopyLen = ImplGetCopyLen( mpData->mnLen, nCopyLen );
236 : :
237 : : // If appended string is not empty
238 [ + - ]: 4167 : if ( nCopyLen )
239 : : {
240 : : // Allocate new string
241 : 4167 : UniStringData* pNewData = ImplAllocData( mpData->mnLen+nCopyLen );
242 : :
243 : : // copy string data
244 : 4167 : memcpy( pNewData->maStr, mpData->maStr, mpData->mnLen*sizeof( sal_Unicode ) );
245 : 4167 : ImplCopyAsciiStr( pNewData->maStr+mpData->mnLen, pAsciiStr, nCopyLen );
246 : :
247 : : // release old string
248 : 4167 : STRING_RELEASE((STRING_TYPE *)mpData);
249 : 4167 : mpData = pNewData;
250 : : }
251 : :
252 : 4167 : return *this;
253 : : }
254 : :
255 : 6472 : UniString& UniString::AppendAscii( const sal_Char* pAsciiStr, xub_StrLen nLen )
256 : : {
257 : : DBG_CHKTHIS( UniString, DbgCheckUniString );
258 : : DBG_ASSERT( pAsciiStr, "UniString::AppendAscii() - pAsciiStr is NULL" );
259 : :
260 [ - + ]: 6472 : if ( nLen == STRING_LEN )
261 : 0 : nLen = ImplStringLen( pAsciiStr );
262 : :
263 : : #ifdef DBG_UTIL
264 : : if ( DbgIsAssert() )
265 : : {
266 : : for ( xub_StrLen i = 0; i < nLen; ++i )
267 : : {
268 : : if ( !pAsciiStr[i] )
269 : : {
270 : : OSL_FAIL( "UniString::AppendAscii() : nLen is wrong" );
271 : : }
272 : : }
273 : : }
274 : : #endif
275 : :
276 : : // detect overflow
277 : 6472 : sal_Int32 nCopyLen = ImplGetCopyLen( mpData->mnLen, nLen );
278 : :
279 : : // If appended string is not empty
280 [ + - ]: 6472 : if ( nCopyLen )
281 : : {
282 : : // Allocate new string
283 : 6472 : UniStringData* pNewData = ImplAllocData( mpData->mnLen+nCopyLen );
284 : :
285 : : // copy string data
286 : 6472 : memcpy( pNewData->maStr, mpData->maStr, mpData->mnLen*sizeof( sal_Unicode ) );
287 : 6472 : ImplCopyAsciiStr( pNewData->maStr+mpData->mnLen, pAsciiStr, nCopyLen );
288 : :
289 : : // release old string
290 : 6472 : STRING_RELEASE((STRING_TYPE *)mpData);
291 : 6472 : mpData = pNewData;
292 : : }
293 : :
294 : 6472 : return *this;
295 : : }
296 : :
297 : 20 : UniString& UniString::InsertAscii( const char* pAsciiStr, xub_StrLen nIndex )
298 : : {
299 : : DBG_CHKTHIS( UniString, DbgCheckUniString );
300 : : DBG_ASSERT( pAsciiStr, "UniString::InsertAscii() - pAsciiStr is NULL" );
301 : :
302 : : // Determine string length
303 : 20 : sal_Int32 nCopyLen = ImplStringLen( pAsciiStr );
304 : :
305 : : // detect overflow
306 : 20 : nCopyLen = ImplGetCopyLen( mpData->mnLen, nCopyLen );
307 : :
308 : : // If appended string is not empty
309 [ - + ]: 20 : if ( !nCopyLen )
310 : 0 : return *this;
311 : :
312 : : // Adjust index if exceeds length
313 [ - + ]: 20 : if ( nIndex > mpData->mnLen )
314 : 0 : nIndex = static_cast< xub_StrLen >(mpData->mnLen);
315 : :
316 : : // Allocate new string
317 : 20 : UniStringData* pNewData = ImplAllocData( mpData->mnLen+nCopyLen );
318 : :
319 : : // copy string data
320 : 20 : memcpy( pNewData->maStr, mpData->maStr, nIndex*sizeof( sal_Unicode ) );
321 : 20 : ImplCopyAsciiStr( pNewData->maStr+nIndex, pAsciiStr, nCopyLen );
322 : 20 : memcpy( pNewData->maStr+nIndex+nCopyLen, mpData->maStr+nIndex,
323 : 40 : (mpData->mnLen-nIndex)*sizeof( sal_Unicode ) );
324 : :
325 : : // release old string
326 : 20 : STRING_RELEASE((STRING_TYPE *)mpData);
327 : 20 : mpData = pNewData;
328 : :
329 : 20 : return *this;
330 : : }
331 : :
332 : 0 : UniString& UniString::ReplaceAscii( xub_StrLen nIndex, xub_StrLen nCount,
333 : : const sal_Char* pAsciiStr, xub_StrLen nStrLen )
334 : : {
335 : : DBG_CHKTHIS( UniString, DbgCheckUniString );
336 : : DBG_ASSERT( pAsciiStr, "UniString::ReplaceAscii() - pAsciiStr is NULL" );
337 : :
338 : : // Use append if index >= length
339 [ # # ]: 0 : if ( nIndex >= mpData->mnLen )
340 : : {
341 : 0 : AppendAscii( pAsciiStr, nStrLen );
342 : 0 : return *this;
343 : : }
344 : :
345 : : // Use assign if index = 0 and count >= length
346 [ # # ][ # # ]: 0 : if ( (nIndex == 0) && (nCount >= mpData->mnLen) )
347 : : {
348 : 0 : AssignAscii( pAsciiStr, nStrLen );
349 : 0 : return *this;
350 : : }
351 : :
352 : : // Use erase if length is equal
353 [ # # ]: 0 : if ( nStrLen == STRING_LEN )
354 : 0 : nStrLen = ImplStringLen( pAsciiStr );
355 [ # # ]: 0 : if ( !nStrLen )
356 : 0 : return Erase( nIndex, nCount );
357 : :
358 : : // nCount must not exceed string length
359 [ # # ]: 0 : if ( nCount > mpData->mnLen - nIndex )
360 : 0 : nCount = static_cast< xub_StrLen >(mpData->mnLen-nIndex);
361 : :
362 : : // Use assign if length matches
363 [ # # ]: 0 : if ( nCount == nStrLen )
364 : : {
365 : 0 : ImplCopyData();
366 : 0 : ImplCopyAsciiStr( mpData->maStr+nIndex, pAsciiStr, nStrLen );
367 : 0 : return *this;
368 : : }
369 : :
370 : : // detect overflow
371 : 0 : sal_Int32 n = ImplGetCopyLen( mpData->mnLen-nCount, nStrLen );
372 : :
373 : : // allocate new string
374 : 0 : STRINGDATA* pNewData = ImplAllocData( mpData->mnLen-nCount+n );
375 : :
376 : : // copy string data
377 : 0 : memcpy( pNewData->maStr, mpData->maStr, nIndex*sizeof( STRCODE ) );
378 : 0 : ImplCopyAsciiStr( pNewData->maStr+nIndex, pAsciiStr, n );
379 : 0 : memcpy( pNewData->maStr+nIndex+n, mpData->maStr+nIndex+nCount,
380 : 0 : (mpData->mnLen-nIndex-nCount+1)*sizeof( STRCODE ) );
381 : :
382 : : // release old string
383 : 0 : STRING_RELEASE((STRING_TYPE *)mpData);
384 : 0 : mpData = pNewData;
385 : :
386 : 0 : return *this;
387 : : }
388 : :
389 : 1183103 : StringCompare UniString::CompareToAscii( const sal_Char* pAsciiStr,
390 : : xub_StrLen nLen ) const
391 : : {
392 : : DBG_CHKTHIS( UniString, DbgCheckUniString );
393 : : DBG_ASSERT( ImplDbgCheckAsciiStr( pAsciiStr, nLen ),
394 : : "UniString::CompareToAscii() - pAsciiStr include characters > 127" );
395 : :
396 : : // String vergleichen
397 : 1183103 : sal_Int32 nCompare = ImplStringCompareAscii( mpData->maStr, pAsciiStr, nLen );
398 : :
399 : : // Rueckgabewert anpassen
400 [ + + ]: 1183103 : if ( nCompare == 0 )
401 : 15816 : return COMPARE_EQUAL;
402 [ + + ]: 1167287 : else if ( nCompare < 0 )
403 : 760291 : return COMPARE_LESS;
404 : : else
405 : 1183103 : return COMPARE_GREATER;
406 : : }
407 : :
408 : 308120339 : StringCompare UniString::CompareIgnoreCaseToAscii( const sal_Char* pAsciiStr,
409 : : xub_StrLen nLen ) const
410 : : {
411 : : DBG_CHKTHIS( UniString, DbgCheckUniString );
412 : : DBG_ASSERT( ImplDbgCheckAsciiStr( pAsciiStr, nLen ),
413 : : "UniString::CompareIgnoreCaseToAscii() - pAsciiStr include characters > 127" );
414 : :
415 : : // compare strings
416 : 308120339 : sal_Int32 nCompare = ImplStringICompareAscii( mpData->maStr, pAsciiStr, nLen );
417 : :
418 [ + + ]: 308120339 : if ( nCompare == 0 )
419 : 465675 : return COMPARE_EQUAL;
420 [ + + ]: 307654664 : else if ( nCompare < 0 )
421 : 174849346 : return COMPARE_LESS;
422 : : else
423 : 308120339 : return COMPARE_GREATER;
424 : : }
425 : :
426 : 1633755 : sal_Bool UniString::EqualsAscii( const sal_Char* pAsciiStr ) const
427 : : {
428 : : DBG_CHKTHIS( UniString, DbgCheckUniString );
429 : : DBG_ASSERT( ImplDbgCheckAsciiStr( pAsciiStr, STRING_LEN ),
430 : : "UniString::EqualsAscii() - pAsciiStr include characters > 127" );
431 : :
432 : 1633755 : return (ImplStringCompareAscii( mpData->maStr, pAsciiStr ) == 0);
433 : : }
434 : :
435 : 3758864 : sal_Bool UniString::EqualsIgnoreCaseAscii( const sal_Char* pAsciiStr ) const
436 : : {
437 : : DBG_CHKTHIS( UniString, DbgCheckUniString );
438 : : DBG_ASSERT( ImplDbgCheckAsciiStr( pAsciiStr, STRING_LEN ),
439 : : "UniString::EqualsIgnoreCaseAscii() - pAsciiStr include characters > 127" );
440 : :
441 : 3758864 : return (ImplStringICompareAscii( mpData->maStr, pAsciiStr ) == 0);
442 : : }
443 : :
444 : 1092891 : sal_Bool UniString::EqualsAscii( const sal_Char* pAsciiStr,
445 : : xub_StrLen nIndex, xub_StrLen nLen ) const
446 : : {
447 : : DBG_CHKTHIS( UniString, DbgCheckUniString );
448 : : DBG_ASSERT( ImplDbgCheckAsciiStr( pAsciiStr, nLen ),
449 : : "UniString::EqualsAscii() - pAsciiStr include characters > 127" );
450 : :
451 : : // Are there enough codes for comparing?
452 [ + + ]: 1092891 : if ( nIndex > mpData->mnLen )
453 : 30 : return (*pAsciiStr == 0);
454 : :
455 : 1092891 : return (ImplStringCompareAscii( mpData->maStr+nIndex, pAsciiStr, nLen ) == 0);
456 : : }
457 : :
458 : 71183 : sal_Bool UniString::EqualsIgnoreCaseAscii( const sal_Char* pAsciiStr,
459 : : xub_StrLen nIndex, xub_StrLen nLen ) const
460 : : {
461 : : DBG_CHKTHIS( UniString, DbgCheckUniString );
462 : : DBG_ASSERT( ImplDbgCheckAsciiStr( pAsciiStr, nLen ),
463 : : "UniString::EqualsIgnoreCaseAscii() - pAsciiStr include characters > 127" );
464 : :
465 : : // Are there enough codes for comparing?
466 [ - + ]: 71183 : if ( nIndex > mpData->mnLen )
467 : 0 : return (*pAsciiStr == 0);
468 : :
469 : 71183 : return (ImplStringICompareAscii( mpData->maStr+nIndex, pAsciiStr, nLen ) == 0);
470 : : }
471 : :
472 : 11839664 : xub_StrLen UniString::SearchAscii( const sal_Char* pAsciiStr, xub_StrLen nIndex ) const
473 : : {
474 : : DBG_CHKTHIS( UniString, DbgCheckUniString );
475 : : DBG_ASSERT( ImplDbgCheckAsciiStr( pAsciiStr, STRING_LEN ),
476 : : "UniString::SearchAscii() - pAsciiStr include characters > 127" );
477 : :
478 : 11839664 : sal_Int32 nLen = mpData->mnLen;
479 : 11839664 : xub_StrLen nStrLen = ImplStringLen( pAsciiStr );
480 : :
481 : : // If length of pAsciiStr is 0 or index exceeds length, it was not found
482 [ + + ][ + - ]: 11839664 : if ( !nStrLen || (nIndex >= nLen) )
483 : 13266 : return STRING_NOTFOUND;
484 : :
485 : 11826398 : const sal_Unicode* pStr = mpData->maStr;
486 : 11826398 : pStr += nIndex;
487 : :
488 [ + + ]: 11826398 : if ( nStrLen == 1 )
489 : : {
490 : 17 : sal_Unicode cSearch = (unsigned char)*pAsciiStr;
491 [ + + ]: 458 : while ( nIndex < nLen )
492 : : {
493 [ - + ]: 441 : if ( *pStr == cSearch )
494 : 0 : return nIndex;
495 : : ++pStr,
496 : 441 : ++nIndex;
497 : : }
498 : : }
499 : : else
500 : : {
501 : : // Only search within string
502 [ + + ]: 88364870 : while ( nLen - nIndex >= nStrLen )
503 : : {
504 : : // Check if string matches
505 [ + + ]: 76653883 : if ( ImplStringCompareWithoutZeroAscii( pStr, pAsciiStr, nStrLen ) == 0 )
506 : 115394 : return nIndex;
507 : : ++pStr,
508 : 76538489 : ++nIndex;
509 : : }
510 : : }
511 : :
512 : 11839664 : return STRING_NOTFOUND;
513 : : }
514 : :
515 : 179 : xub_StrLen UniString::SearchAndReplaceAscii( const sal_Char* pAsciiStr, const UniString& rRepStr,
516 : : xub_StrLen nIndex )
517 : : {
518 : : DBG_CHKTHIS( UniString, DbgCheckUniString );
519 : : DBG_ASSERT( ImplDbgCheckAsciiStr( pAsciiStr, STRING_LEN ),
520 : : "UniString::SearchAndReplaceAscii() - pAsciiStr include characters > 127" );
521 : :
522 : 179 : xub_StrLen nSPos = SearchAscii( pAsciiStr, nIndex );
523 [ + + ]: 179 : if ( nSPos != STRING_NOTFOUND )
524 : 155 : Replace( nSPos, ImplStringLen( pAsciiStr ), rRepStr );
525 : :
526 : 179 : return nSPos;
527 : : }
528 : :
529 : 10955 : void UniString::SearchAndReplaceAllAscii( const sal_Char* pAsciiStr, const UniString& rRepStr )
530 : : {
531 : : DBG_CHKTHIS( UniString, DbgCheckUniString );
532 : : DBG_ASSERT( ImplDbgCheckAsciiStr( pAsciiStr, STRING_LEN ),
533 : : "UniString::SearchAndReplaceAllAscii() - pAsciiStr include characters > 127" );
534 : :
535 : 10955 : xub_StrLen nCharLen = ImplStringLen( pAsciiStr );
536 : 10955 : xub_StrLen nSPos = SearchAscii( pAsciiStr, 0 );
537 [ + + ]: 11239 : while ( nSPos != STRING_NOTFOUND )
538 : : {
539 : 284 : Replace( nSPos, nCharLen, rRepStr );
540 : 284 : nSPos = nSPos + rRepStr.Len();
541 : 284 : nSPos = SearchAscii( pAsciiStr, nSPos );
542 : : }
543 : 10955 : }
544 : :
545 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|