[Libreoffice-commits] core.git: include/tools sc/source tools/source

Caolán McNamara caolanm at redhat.com
Sun Sep 8 06:54:30 PDT 2013


 include/tools/string.hxx         |    1 -
 sc/source/core/tool/interpr1.cxx |   28 +++++++++++-----------------
 tools/source/string/tustring.cxx |   25 -------------------------
 3 files changed, 11 insertions(+), 43 deletions(-)

New commits:
commit ce9c390e1a100921fd4300d6acb602b4af2b7003
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Sep 8 14:52:59 2013 +0100

    Related: fdo#38838 String::ReleaseBufferAccess is now no more
    
    Change-Id: Ib5390183e3d98a23f9243debfe3624561ca92535

diff --git a/include/tools/string.hxx b/include/tools/string.hxx
index c26fee3..0331327 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 33eb3da..85c0f91 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 f3bb24f..a23f0fc 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 );


More information about the Libreoffice-commits mailing list