diff options
author | Caolán McNamara <caolanm@redhat.com> | 2013-10-18 20:35:37 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-10-19 14:24:40 +0100 |
commit | f2bdfdb2952b4ef6064be65130242fbabb71f885 (patch) | |
tree | 4d7687f80de54d82ddea3bc3aa8ef4520aae0ff5 /tools | |
parent | 301b5a408d7b0e53f86b1aad0afb8b454fc71991 (diff) |
Related: fdo#38838 remove String::Replace
Change-Id: Ia6602809a65db0a7dcfef80cc474aab67d520980
Diffstat (limited to 'tools')
-rw-r--r-- | tools/source/string/strimp.cxx | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/tools/source/string/strimp.cxx b/tools/source/string/strimp.cxx index 6b0c40129d4e..99a2778d2db4 100644 --- a/tools/source/string/strimp.cxx +++ b/tools/source/string/strimp.cxx @@ -244,98 +244,6 @@ STRING& STRING::Insert( const STRING& rStr, xub_StrLen nIndex ) return *this; } -STRING& STRING::Replace( xub_StrLen nIndex, xub_StrLen nCount, const STRING& rStr ) -{ - DBG_CHKTHIS( STRING, DBGCHECKSTRING ); - DBG_CHKOBJ( &rStr, STRING, DBGCHECKSTRING ); - - // Append if index > current length - if ( nIndex >= mpData->mnLen ) - { - Append( rStr ); - return *this; - } - - // assign if index = 0 and length >= stringlen - if ( (nIndex == 0) && (nCount >= mpData->mnLen) ) - { - Assign( rStr ); - return *this; - } - - // Use erase if replacestring is empty - sal_Int32 nStrLen = rStr.mpData->mnLen; - if ( !nStrLen ) - return Erase( nIndex, nCount ); - - // Adjust nCount if it's larger than the string - if ( nCount > mpData->mnLen - nIndex ) - nCount = static_cast< xub_StrLen >(mpData->mnLen-nIndex); - - if ( !nCount ) - return Insert( rStr, nIndex ); - - // Use character-based assignment if length is equal - if ( nCount == nStrLen ) - { - ImplCopyData(); - memcpy( mpData->maStr+nIndex, rStr.mpData->maStr, nCount*sizeof( STRCODE ) ); - return *this; - } - - // detect overflow - nStrLen = ImplGetCopyLen( mpData->mnLen-nCount, nStrLen ); - - // allocate string of new size - STRINGDATA* pNewData = ImplAllocData( mpData->mnLen-nCount+nStrLen ); - - // copy string - memcpy( pNewData->maStr, mpData->maStr, nIndex*sizeof( STRCODE ) ); - memcpy( pNewData->maStr+nIndex, rStr.mpData->maStr, nStrLen*sizeof( STRCODE ) ); - memcpy( pNewData->maStr+nIndex+nStrLen, mpData->maStr+nIndex+nCount, - (mpData->mnLen-nIndex-nCount+1)*sizeof( STRCODE ) ); - - // free old string - STRING_RELEASE((STRING_TYPE *)mpData); - mpData = pNewData; - - return *this; -} - -STRING& STRING::Erase( xub_StrLen nIndex, xub_StrLen nCount ) -{ - DBG_CHKTHIS( STRING, DBGCHECKSTRING ); - - // Return if index outside string or count = 0 - if ( (nIndex >= mpData->mnLen) || !nCount ) - return *this; - - // Adjust nCount if it's larger than the string - if ( nCount > mpData->mnLen - nIndex ) - nCount = static_cast< xub_StrLen >(mpData->mnLen-nIndex); - - if ( mpData->mnLen - nCount ) - { - // allocate string of new size - STRINGDATA* pNewData = ImplAllocData( mpData->mnLen-nCount ); - - // copy string - memcpy( pNewData->maStr, mpData->maStr, nIndex*sizeof( STRCODE ) ); - memcpy( pNewData->maStr+nIndex, mpData->maStr+nIndex+nCount, - (mpData->mnLen-nIndex-nCount+1)*sizeof( STRCODE ) ); - - // free old string - STRING_RELEASE((STRING_TYPE *)mpData); - mpData = pNewData; - } - else - { - STRING_NEW((STRING_TYPE **)&mpData); - } - - return *this; -} - xub_StrLen STRING::Search( STRCODE c, xub_StrLen nIndex ) const { DBG_CHKTHIS( STRING, DBGCHECKSTRING ); |