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

Caolán McNamara caolanm at redhat.com
Sun Jul 14 12:05:40 PDT 2013


 include/tools/string.hxx         |    2 -
 sw/source/ui/dbui/dbinsdlg.cxx   |   60 ++++++++++++---------------------------
 tools/source/string/strascii.cxx |   57 -------------------------------------
 3 files changed, 19 insertions(+), 100 deletions(-)

New commits:
commit c162a4c8e496ed457da67ab24da55cb9ee446c02
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Jul 14 20:04:07 2013 +0100

    remove String::ReplaceAscii
    
    last remaining users used it as a complicated way to do a simple thing
    
    Change-Id: I810b1542b03bd6faa54f6f076b58cb7d3e680ab0

diff --git a/include/tools/string.hxx b/include/tools/string.hxx
index 33f6522..e185480 100644
--- a/include/tools/string.hxx
+++ b/include/tools/string.hxx
@@ -221,8 +221,6 @@ public:
     UniString&          Insert( sal_Unicode c, xub_StrLen nIndex = STRING_LEN );
     UniString&          InsertAscii( const sal_Char* pAsciiStr, xub_StrLen nIndex = STRING_LEN );
     UniString&          Replace( xub_StrLen nIndex, xub_StrLen nLen, const UniString& rStr );
-    UniString&          ReplaceAscii( xub_StrLen nIndex, xub_StrLen nLen,
-                                      const sal_Char* pAsciiStr, xub_StrLen nStrLen = STRING_LEN );
     UniString&          Erase( xub_StrLen nIndex = 0, xub_StrLen nCount = STRING_LEN );
     UniString           Copy( xub_StrLen nIndex = 0, xub_StrLen nCount = STRING_LEN ) const;
 
diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx
index d43b132..3ba2fbd 100644
--- a/sw/source/ui/dbui/dbinsdlg.cxx
+++ b/sw/source/ui/dbui/dbinsdlg.cxx
@@ -1468,56 +1468,34 @@ void SwInsertDBColAutoPilot::SetTabSet()
 
 _DB_ColumnConfigData::~_DB_ColumnConfigData() {}
 
-static Sequence<OUString> lcl_createSourceNames(const String& rNodeName)
+static Sequence<OUString> lcl_createSourceNames(const OUString& rNodeName)
 {
     Sequence<OUString> aSourceNames(11);
     OUString* pNames = aSourceNames.getArray();
-
-    String sTmp( rNodeName );
-    const xub_StrLen nPos = sTmp.Len();
-    pNames[0] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
-                            RTL_CONSTASCII_STRINGPARAM( "/DataSource" ));
-    pNames[1] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
-                            RTL_CONSTASCII_STRINGPARAM( "/Command" ));
-    pNames[2] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
-                            RTL_CONSTASCII_STRINGPARAM( "/CommandType" ));
-    pNames[3] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
-                            RTL_CONSTASCII_STRINGPARAM( "/ColumnsToText" ));
-    pNames[4] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
-                            RTL_CONSTASCII_STRINGPARAM( "/ColumnsToTable" ));
-    pNames[5] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
-                            RTL_CONSTASCII_STRINGPARAM( "/ParaStyle" ));
-    pNames[6] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
-                            RTL_CONSTASCII_STRINGPARAM( "/TableAutoFormat" ));
-    pNames[7] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
-                            RTL_CONSTASCII_STRINGPARAM( "/IsTable" ));
-    pNames[8] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
-                            RTL_CONSTASCII_STRINGPARAM( "/IsField" ));
-    pNames[9] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
-                            RTL_CONSTASCII_STRINGPARAM( "/IsHeadlineOn" ));
-    pNames[10] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
-                            RTL_CONSTASCII_STRINGPARAM( "/IsEmptyHeadline" ));
+    pNames[0] = rNodeName + "/DataSource";
+    pNames[1] = rNodeName + "/Command";
+    pNames[2] = rNodeName + "/CommandType";
+    pNames[3] = rNodeName + "/ColumnsToText";
+    pNames[4] = rNodeName + "/ColumnsToTable";
+    pNames[5] = rNodeName + "/ParaStyle";
+    pNames[6] = rNodeName + "/TableAutoFormat";
+    pNames[7] = rNodeName + "/IsTable";
+    pNames[8] = rNodeName + "/IsField";
+    pNames[9] = rNodeName + "/IsHeadlineOn";
+    pNames[10] = rNodeName + "/IsEmptyHeadline";
     return aSourceNames;
 }
 
-static Sequence<OUString> lcl_CreateSubNames( const String& rSubNodeName )
+static Sequence<OUString> lcl_CreateSubNames(const OUString& rSubNodeName)
 {
     Sequence<OUString> aSubSourceNames(6);
     OUString* pNames = aSubSourceNames.getArray();
-    String sTmp( rSubNodeName );
-    const xub_StrLen nPos = sTmp.Len();
-    pNames[0] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
-                            RTL_CONSTASCII_STRINGPARAM( "/ColumnName" ));
-    pNames[1] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
-                            RTL_CONSTASCII_STRINGPARAM( "/ColumnIndex" ));
-    pNames[2] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
-                            RTL_CONSTASCII_STRINGPARAM( "/IsNumberFormat" ));
-    pNames[3] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
-                            RTL_CONSTASCII_STRINGPARAM( "/IsNumberFormatFromDataBase" ));
-    pNames[4] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
-                            RTL_CONSTASCII_STRINGPARAM( "/NumberFormat" ));
-    pNames[5] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
-                            RTL_CONSTASCII_STRINGPARAM( "/NumberFormatLocale" ));
+    pNames[0] = rSubNodeName + "/ColumnName";
+    pNames[1] = rSubNodeName + "/ColumnIndex";
+    pNames[2] = rSubNodeName + "/IsNumberFormat";
+    pNames[3] = rSubNodeName + "/IsNumberFormatFromDataBase";
+    pNames[4] = rSubNodeName + "/NumberFormat";
+    pNames[5] = rSubNodeName + "/NumberFormatLocale";
     return aSubSourceNames;
 }
 
diff --git a/tools/source/string/strascii.cxx b/tools/source/string/strascii.cxx
index fe43542..7cae272 100644
--- a/tools/source/string/strascii.cxx
+++ b/tools/source/string/strascii.cxx
@@ -329,63 +329,6 @@ UniString& UniString::InsertAscii( const char* pAsciiStr, xub_StrLen nIndex )
     return *this;
 }
 
-UniString& UniString::ReplaceAscii( xub_StrLen nIndex, xub_StrLen nCount,
-                                    const sal_Char* pAsciiStr, xub_StrLen nStrLen )
-{
-    DBG_CHKTHIS( UniString, DbgCheckUniString );
-    DBG_ASSERT( pAsciiStr, "UniString::ReplaceAscii() - pAsciiStr is NULL" );
-
-    // Use append if index >= length
-    if ( nIndex >= mpData->mnLen )
-    {
-        AppendAscii( pAsciiStr, nStrLen );
-        return *this;
-    }
-
-    // Use assign if index = 0 and count >= length
-    if ( (nIndex == 0) && (nCount >= mpData->mnLen) )
-    {
-        AssignAscii( pAsciiStr, nStrLen );
-        return *this;
-    }
-
-    // Use erase if length is equal
-    if ( nStrLen == STRING_LEN )
-        nStrLen = ImplStringLen( pAsciiStr );
-    if ( !nStrLen )
-        return Erase( nIndex, nCount );
-
-    // nCount must not exceed string length
-    if ( nCount > mpData->mnLen - nIndex )
-        nCount = static_cast< xub_StrLen >(mpData->mnLen-nIndex);
-
-    // Use assign if length matches
-    if ( nCount == nStrLen )
-    {
-        ImplCopyData();
-        ImplCopyAsciiStr( mpData->maStr+nIndex, pAsciiStr, nStrLen );
-        return *this;
-    }
-
-    // detect overflow
-    sal_Int32 n = ImplGetCopyLen( mpData->mnLen-nCount, nStrLen );
-
-    // allocate new string
-    STRINGDATA* pNewData = ImplAllocData( mpData->mnLen-nCount+n );
-
-    // copy string data
-    memcpy( pNewData->maStr, mpData->maStr, nIndex*sizeof( STRCODE ) );
-    ImplCopyAsciiStr( pNewData->maStr+nIndex, pAsciiStr, n );
-    memcpy( pNewData->maStr+nIndex+n, mpData->maStr+nIndex+nCount,
-            (mpData->mnLen-nIndex-nCount+1)*sizeof( STRCODE ) );
-
-    // release old string
-    STRING_RELEASE((STRING_TYPE *)mpData);
-    mpData = pNewData;
-
-    return *this;
-}
-
 StringCompare UniString::CompareToAscii( const sal_Char* pAsciiStr,
                                          xub_StrLen nLen ) const
 {


More information about the Libreoffice-commits mailing list