diff options
author | Caolán McNamara <caolanm@redhat.com> | 2013-09-08 14:52:59 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-09-08 14:52:59 +0100 |
commit | ce9c390e1a100921fd4300d6acb602b4af2b7003 (patch) | |
tree | 90e3be5f1fab209aed9ec63abd24dd17c2d25a04 | |
parent | 3b21a1657b314b72049e8881d7f21cf56fb72484 (diff) |
Related: fdo#38838 String::ReleaseBufferAccess is now no more
Change-Id: Ib5390183e3d98a23f9243debfe3624561ca92535
-rw-r--r-- | include/tools/string.hxx | 1 | ||||
-rw-r--r-- | sc/source/core/tool/interpr1.cxx | 28 | ||||
-rw-r--r-- | tools/source/string/tustring.cxx | 25 |
3 files changed, 11 insertions, 43 deletions
diff --git a/include/tools/string.hxx b/include/tools/string.hxx index c26fee36ab65..03313273853a 100644 --- a/include/tools/string.hxx +++ b/include/tools/string.hxx @@ -274,7 +274,6 @@ public: const sal_Unicode* GetBuffer() const { return mpData->maStr; } sal_Unicode* GetBufferAccess(); - void ReleaseBufferAccess( xub_StrLen nLen = STRING_LEN ); friend sal_Bool operator == ( const UniString& rStr1, const UniString& rStr2 ) { return rStr1.Equals( rStr2 ); } diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 33eb3dae684d..85c0f917fc3e 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -3158,31 +3158,25 @@ void ScInterpreter::ScUpper() void ScInterpreter::ScPropper() { //2do: what to do with I18N-CJK ?!? - String aStr( GetString() ); - const xub_StrLen nLen = aStr.Len(); - // #i82487# don't try to write to empty string's BufferAccess - // (would crash now that the empty string is const) + OUStringBuffer aStr(GetString()); + const sal_Int32 nLen = aStr.getLength(); if ( nLen > 0 ) { - String aUpr( ScGlobal::pCharClass->uppercase( aStr ) ); - String aLwr( ScGlobal::pCharClass->lowercase( aStr ) ); - sal_Unicode* pStr = aStr.GetBufferAccess(); - const sal_Unicode* pUpr = aUpr.GetBuffer(); - const sal_Unicode* pLwr = aLwr.GetBuffer(); - *pStr = *pUpr; - xub_StrLen nPos = 1; + OUString aUpr(ScGlobal::pCharClass->uppercase(aStr.toString())); + OUString aLwr(ScGlobal::pCharClass->lowercase(aStr.toString())); + aStr[0] = aUpr[0]; + sal_Int32 nPos = 1; while( nPos < nLen ) { - OUString aTmpStr( pStr[nPos-1] ); + OUString aTmpStr( aStr[nPos-1] ); if ( !ScGlobal::pCharClass->isLetter( aTmpStr, 0 ) ) - pStr[nPos] = pUpr[nPos]; + aStr[nPos] = aUpr[nPos]; else - pStr[nPos] = pLwr[nPos]; - nPos++; + aStr[nPos] = aLwr[nPos]; + ++nPos; } - aStr.ReleaseBufferAccess( nLen ); } - PushString( aStr ); + PushString(aStr.makeStringAndClear()); } diff --git a/tools/source/string/tustring.cxx b/tools/source/string/tustring.cxx index f3bb24f09ab5..a23f0fcfa766 100644 --- a/tools/source/string/tustring.cxx +++ b/tools/source/string/tustring.cxx @@ -240,31 +240,6 @@ STRCODE* STRING::GetBufferAccess() return mpData->maStr; } -void STRING::ReleaseBufferAccess( xub_StrLen nLen ) -{ - // String not consinstent, thus no functionality test - DBG_CHKTHIS( STRING, NULL ); - DBG_ASSERT( mpData->mnRefCount == 1, "String::ReleaseCharStr() called for String with RefCount" ); - - if ( nLen > mpData->mnLen ) - nLen = ImplStringLen( mpData->maStr ); - OSL_ASSERT(nLen <= mpData->mnLen); - if ( !nLen ) - { - STRING_NEW((STRING_TYPE **)&mpData); - } - // shorten buffer is difference > 8 chars - else if ( mpData->mnLen - nLen > 8 ) - { - STRINGDATA* pNewData = ImplAllocData( nLen ); - memcpy( pNewData->maStr, mpData->maStr, nLen*sizeof( STRCODE ) ); - STRING_RELEASE((STRING_TYPE *)mpData); - mpData = pNewData; - } - else - mpData->mnLen = nLen; -} - STRING& STRING::Insert( STRCODE c, xub_StrLen nIndex ) { DBG_CHKTHIS( STRING, DBGCHECKSTRING ); |