LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/tools/source/string - strascii.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 154 190 81.1 %
Date: 2013-07-09 Functions: 20 21 95.2 %
Legend: Lines: hit not hit

          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       22204 : 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      255617 :     while ( nLen )
      42             :     {
      43      211209 :         *pDest = (unsigned char)*pSrc;
      44             :         ++pDest,
      45             :         ++pSrc,
      46      211209 :         --nLen;
      47             :     }
      48       22204 : }
      49             : 
      50      654047 : static sal_Int32 ImplStringCompareAscii( const sal_Unicode* pStr1, const sal_Char* pStr2 )
      51             : {
      52             :     sal_Int32 nRet;
      53     2603940 :     while ( ((nRet = ((sal_Int32)*pStr1)-((sal_Int32)((unsigned char)*pStr2))) == 0) &&
      54             :             *pStr2 )
      55             :     {
      56             :         ++pStr1,
      57     1295846 :         ++pStr2;
      58             :     }
      59             : 
      60      654047 :     return nRet;
      61             : }
      62             : 
      63      849604 : static sal_Int32 ImplStringCompareAscii( const sal_Unicode* pStr1, const sal_Char* pStr2,
      64             :                                          xub_StrLen nCount )
      65             : {
      66      849604 :     sal_Int32 nRet = 0;
      67     4171646 :     while ( nCount &&
      68     2489600 :             ((nRet = ((sal_Int32)*pStr1)-((sal_Int32)((unsigned char)*pStr2))) == 0) &&
      69             :             *pStr2 )
      70             :     {
      71             :         ++pStr1,
      72             :         ++pStr2,
      73      815856 :         --nCount;
      74             :     }
      75             : 
      76      849604 :     return nRet;
      77             : }
      78             : 
      79    29491076 : static sal_Int32 ImplStringCompareWithoutZeroAscii( const sal_Unicode* pStr1, const sal_Char* pStr2,
      80             :                                                     xub_StrLen nCount )
      81             : {
      82    29491076 :     sal_Int32 nRet = 0;
      83    88505705 :     while ( nCount &&
      84    29505827 :             ((nRet = ((sal_Int32)*pStr1)-((sal_Int32)((unsigned char)*pStr2))) == 0) )
      85             :     {
      86             :         ++pStr1,
      87             :         ++pStr2,
      88       17726 :         --nCount;
      89             :     }
      90             : 
      91    29491076 :     return nRet;
      92             : }
      93             : 
      94     1172089 : 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      229989 :     do
     100             :     {
     101             :         // Convert if char is between 'A' and 'Z'
     102     1172089 :         c1 = *pStr1;
     103     1172089 :         c2 = *pStr2;
     104     1172089 :         if ( (c1 >= 65) && (c1 <= 90) )
     105      201420 :             c1 += 32;
     106     1172089 :         if ( (c2 >= 65) && (c2 <= 90) )
     107      303630 :             c2 += 32;
     108     1172089 :         nRet = ((sal_Int32)c1)-((sal_Int32)((unsigned char)c2));
     109     1172089 :         if ( nRet != 0 )
     110      942100 :             break;
     111             : 
     112             :         ++pStr1,
     113      229989 :         ++pStr2;
     114             :     }
     115             :     while ( c2 );
     116             : 
     117      954144 :     return nRet;
     118             : }
     119             : 
     120   169419044 : static sal_Int32 ImplStringICompareAscii( const sal_Unicode* pStr1, const sal_Char* pStr2,
     121             :                                           xub_StrLen nCount )
     122             : {
     123   169419044 :     sal_Int32   nRet = 0;
     124             :     sal_Unicode c1;
     125             :     sal_Char    c2;
     126    21352150 :     do
     127             :     {
     128   190547681 :         if ( !nCount )
     129        2197 :             break;
     130             : 
     131             :         // Convert if char is between 'A' and 'Z'
     132   190545484 :         c1 = *pStr1;
     133   190545484 :         c2 = *pStr2;
     134   190545484 :         if ( (c1 >= 65) && (c1 <= 90) )
     135   171327079 :             c1 += 32;
     136   190545484 :         if ( (c2 >= 65) && (c2 <= 90) )
     137   170229550 :             c2 += 32;
     138   190545484 :         nRet = ((sal_Int32)c1)-((sal_Int32)((unsigned char)c2));
     139   190545484 :         if ( nRet != 0 )
     140   169193334 :             break;
     141             : 
     142             :         ++pStr1,
     143             :         ++pStr2,
     144    21352150 :         --nCount;
     145             :     }
     146             :     while ( c2 );
     147             : 
     148   169419044 :     return nRet;
     149             : }
     150             : 
     151       12601 : 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       12601 :     xub_StrLen nLen = ImplStringLen( pAsciiStr );
     158             : 
     159       12601 :     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       12601 :         if ( (nLen == mpData->mnLen) && (mpData->mnRefCount == 1) )
     167           0 :             ImplCopyAsciiStr( mpData->maStr, pAsciiStr, nLen );
     168             :         else
     169             :         {
     170             :             // release old string
     171       12601 :             STRING_RELEASE((STRING_TYPE *)mpData);
     172             : 
     173             :             // copy new string
     174       12601 :             mpData = ImplAllocData( nLen );
     175       12601 :             ImplCopyAsciiStr( mpData->maStr, pAsciiStr, nLen );
     176             :         }
     177             :     }
     178             : 
     179       12601 :     return *this;
     180             : }
     181             : 
     182        7377 : 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        7377 :     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        7377 :     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        7377 :         if ( (nLen == mpData->mnLen) && (mpData->mnRefCount == 1) )
     211           0 :             ImplCopyAsciiStr( mpData->maStr, pAsciiStr, nLen );
     212             :         else
     213             :         {
     214             :             // release old string
     215        7377 :             STRING_RELEASE((STRING_TYPE *)mpData);
     216             : 
     217             :             // copy new string
     218        7377 :             mpData = ImplAllocData( nLen );
     219        7377 :             ImplCopyAsciiStr( mpData->maStr, pAsciiStr, nLen );
     220             :         }
     221             :     }
     222             : 
     223        7377 :     return *this;
     224             : }
     225             : 
     226        1273 : 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        1273 :     sal_Int32 nCopyLen = ImplStringLen( pAsciiStr );
     233             : 
     234             :     // detect overflow
     235        1273 :     nCopyLen = ImplGetCopyLen( mpData->mnLen, nCopyLen );
     236             : 
     237             :     // If appended string is not empty
     238        1273 :     if ( nCopyLen )
     239             :     {
     240             :         // Allocate new string
     241        1272 :         UniStringData* pNewData = ImplAllocData( mpData->mnLen+nCopyLen );
     242             : 
     243             :         // copy string data
     244        1272 :         memcpy( pNewData->maStr, mpData->maStr, mpData->mnLen*sizeof( sal_Unicode ) );
     245        1272 :         ImplCopyAsciiStr( pNewData->maStr+mpData->mnLen, pAsciiStr, nCopyLen );
     246             : 
     247             :         // release old string
     248        1272 :         STRING_RELEASE((STRING_TYPE *)mpData);
     249        1272 :         mpData = pNewData;
     250             :     }
     251             : 
     252        1273 :     return *this;
     253             : }
     254             : 
     255         949 : 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         949 :     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         949 :     sal_Int32 nCopyLen = ImplGetCopyLen( mpData->mnLen, nLen );
     278             : 
     279             :     // If appended string is not empty
     280         949 :     if ( nCopyLen )
     281             :     {
     282             :         // Allocate new string
     283         949 :         UniStringData* pNewData = ImplAllocData( mpData->mnLen+nCopyLen );
     284             : 
     285             :         // copy string data
     286         949 :         memcpy( pNewData->maStr, mpData->maStr, mpData->mnLen*sizeof( sal_Unicode ) );
     287         949 :         ImplCopyAsciiStr( pNewData->maStr+mpData->mnLen, pAsciiStr, nCopyLen );
     288             : 
     289             :         // release old string
     290         949 :         STRING_RELEASE((STRING_TYPE *)mpData);
     291         949 :         mpData = pNewData;
     292             :     }
     293             : 
     294         949 :     return *this;
     295             : }
     296             : 
     297           5 : 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           5 :     sal_Int32 nCopyLen = ImplStringLen( pAsciiStr );
     304             : 
     305             :     // detect overflow
     306           5 :     nCopyLen = ImplGetCopyLen( mpData->mnLen, nCopyLen );
     307             : 
     308             :     // If appended string is not empty
     309           5 :     if ( !nCopyLen )
     310           0 :         return *this;
     311             : 
     312             :     // Adjust index if exceeds length
     313           5 :     if ( nIndex > mpData->mnLen )
     314           0 :         nIndex = static_cast< xub_StrLen >(mpData->mnLen);
     315             : 
     316             :     // Allocate new string
     317           5 :     UniStringData* pNewData = ImplAllocData( mpData->mnLen+nCopyLen );
     318             : 
     319             :     // copy string data
     320           5 :     memcpy( pNewData->maStr, mpData->maStr, nIndex*sizeof( sal_Unicode ) );
     321           5 :     ImplCopyAsciiStr( pNewData->maStr+nIndex, pAsciiStr, nCopyLen );
     322           5 :     memcpy( pNewData->maStr+nIndex+nCopyLen, mpData->maStr+nIndex,
     323          10 :             (mpData->mnLen-nIndex)*sizeof( sal_Unicode ) );
     324             : 
     325             :     // release old string
     326           5 :     STRING_RELEASE((STRING_TYPE *)mpData);
     327           5 :     mpData = pNewData;
     328             : 
     329           5 :     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      729917 : 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      729917 :     sal_Int32 nCompare = ImplStringCompareAscii( mpData->maStr, pAsciiStr, nLen );
     398             : 
     399             :     // Rueckgabewert anpassen
     400      729917 :     if ( nCompare == 0 )
     401        8412 :         return COMPARE_EQUAL;
     402      721505 :     else if ( nCompare < 0 )
     403      460070 :         return COMPARE_LESS;
     404             :     else
     405      261435 :         return COMPARE_GREATER;
     406             : }
     407             : 
     408   169366100 : 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   169366100 :     sal_Int32 nCompare = ImplStringICompareAscii( mpData->maStr, pAsciiStr, nLen );
     417             : 
     418   169366100 :     if ( nCompare == 0 )
     419      223355 :         return COMPARE_EQUAL;
     420   169142745 :     else if ( nCompare < 0 )
     421    93317437 :         return COMPARE_LESS;
     422             :     else
     423    75825308 :         return COMPARE_GREATER;
     424             : }
     425             : 
     426      654047 : 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      654047 :     return (ImplStringCompareAscii( mpData->maStr, pAsciiStr ) == 0);
     433             : }
     434             : 
     435      954144 : 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      954144 :     return (ImplStringICompareAscii( mpData->maStr, pAsciiStr ) == 0);
     442             : }
     443             : 
     444      119693 : 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      119693 :     if ( nIndex > mpData->mnLen )
     453           6 :         return (*pAsciiStr == 0);
     454             : 
     455      119687 :     return (ImplStringCompareAscii( mpData->maStr+nIndex, pAsciiStr, nLen ) == 0);
     456             : }
     457             : 
     458       52944 : 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       52944 :     if ( nIndex > mpData->mnLen )
     467           0 :         return (*pAsciiStr == 0);
     468             : 
     469       52944 :     return (ImplStringICompareAscii( mpData->maStr+nIndex, pAsciiStr, nLen ) == 0);
     470             : }
     471             : 
     472     3942004 : 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     3942004 :     sal_Int32 nLen = mpData->mnLen;
     479     3942004 :     xub_StrLen nStrLen  = ImplStringLen( pAsciiStr );
     480             : 
     481             :     // If length of pAsciiStr is 0 or index exceeds length, it was not found
     482     3942004 :     if ( !nStrLen || (nIndex >= nLen) )
     483          47 :         return STRING_NOTFOUND;
     484             : 
     485     3941957 :     const sal_Unicode* pStr = mpData->maStr;
     486     3941957 :     pStr += nIndex;
     487             : 
     488     3941957 :     if ( nStrLen == 1 )
     489             :     {
     490           4 :         sal_Unicode cSearch = (unsigned char)*pAsciiStr;
     491         143 :         while ( nIndex < nLen )
     492             :         {
     493         135 :             if ( *pStr == cSearch )
     494           0 :                 return nIndex;
     495             :             ++pStr,
     496         135 :             ++nIndex;
     497             :         }
     498             :     }
     499             :     else
     500             :     {
     501             :         // Only search within string
     502    37372007 :         while ( nLen - nIndex >= nStrLen )
     503             :         {
     504             :             // Check if string matches
     505    29491076 :             if ( ImplStringCompareWithoutZeroAscii( pStr, pAsciiStr, nStrLen ) == 0 )
     506        2975 :                 return nIndex;
     507             :             ++pStr,
     508    29488101 :             ++nIndex;
     509             :         }
     510             :     }
     511             : 
     512     3938982 :     return STRING_NOTFOUND;
     513             : }
     514             : 
     515          65 : 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          65 :     xub_StrLen nSPos = SearchAscii( pAsciiStr, nIndex );
     523          65 :     if ( nSPos != STRING_NOTFOUND )
     524          56 :         Replace( nSPos, ImplStringLen( pAsciiStr ), rRepStr );
     525             : 
     526          65 :     return nSPos;
     527             : }
     528             : 
     529        6195 : 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        6195 :     xub_StrLen nCharLen = ImplStringLen( pAsciiStr );
     536        6195 :     xub_StrLen nSPos = SearchAscii( pAsciiStr, 0 );
     537       12518 :     while ( nSPos != STRING_NOTFOUND )
     538             :     {
     539         128 :         Replace( nSPos, nCharLen, rRepStr );
     540         128 :         nSPos = nSPos + rRepStr.Len();
     541         128 :         nSPos = SearchAscii( pAsciiStr, nSPos );
     542             :     }
     543        6195 : }
     544             : 
     545             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10