Hi

Please review and apply if appropriate this patch:
I have replaced four public (deprecated) String variables of
ScFuncDesc in sc/inc/funcdesc.hxx by OUString and changed all uses of
these variables to use OUString instead. Most places by using relevant
methods for OUString, and a few places (where a String is retrieved
using a ResId), by casting the String to an OUString.

funcdesc.hxx and its implementation in global.cxx still contain other
uses of deprecated datatypes, but I hope to change these in a later
patch.

Regards
Sören Möller
(LGPLv3+ / MPL)
From d8c5ec79dff93bbc3c101e64bd59907527ee193f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20M=C3=B6ller?= <[email protected]>
Date: Sun, 9 Jan 2011 18:12:47 +0100
Subject: [PATCH] Changed String to OUString in public variables of ScFuncDesc

I have changed four public variables of ScFuncDesc in sc/inc/funcdesc.hxx from deprecated String to OUString and corrected all uses of these variables
---
 sc/inc/appluno.hxx                |    1 +
 sc/inc/funcdesc.hxx               |   22 ++++++------
 sc/source/core/data/global.cxx    |   72 ++++++++++++++++++------------------
 sc/source/core/tool/addincol.cxx  |   16 ++++----
 sc/source/ui/formdlg/dwfunctr.cxx |    2 +-
 sc/source/ui/unoobj/appluno.cxx   |   21 +++++------
 6 files changed, 67 insertions(+), 67 deletions(-)

diff --git a/sc/inc/appluno.hxx b/sc/inc/appluno.hxx
index 681dd8d..f8d82cd 100644
--- a/sc/inc/appluno.hxx
+++ b/sc/inc/appluno.hxx
@@ -38,6 +38,7 @@
 #include <com/sun/star/container/XNameAccess.hpp>
 #include <cppuhelper/implbase2.hxx>
 #include <cppuhelper/implbase4.hxx>
+#include <rtl/ustring.hxx>
 
 class ScFunctionDescriptionObj;
 
diff --git a/sc/inc/funcdesc.hxx b/sc/inc/funcdesc.hxx
index 3640bfc..c07dda0 100644
--- a/sc/inc/funcdesc.hxx
+++ b/sc/inc/funcdesc.hxx
@@ -93,17 +93,17 @@ public:
         suppressed). */
     USHORT  GetSuppressedArgCount() const;
 
-    String          *pFuncName;              // Function name
-    String          *pFuncDesc;              // Description of function
-    String         **ppDefArgNames;          // Parameter name(s)
-    String         **ppDefArgDescs;          // Description(s) of parameter(s)
-    ParameterFlags  *pDefArgFlags;           // Flags for each parameter
-    USHORT           nFIndex;                // Unique function index
-    USHORT           nCategory;              // Function category
-    USHORT           nArgCount;              // All parameter count, suppressed and unsuppressed
-    USHORT           nHelpId;                // HelpID of function
-    bool             bIncomplete         :1; // Incomplete argument info (set for add-in info from configuration)
-    bool             bHasSuppressedArgs  :1; // Whether there is any suppressed parameter.
+    ::rtl::OUString      *pFuncName;              // Function name
+    ::rtl::OUString      *pFuncDesc;              // Description of function
+    ::rtl::OUString     **ppDefArgNames;          // Parameter name(s)
+    ::rtl::OUString     **ppDefArgDescs;          // Description(s) of parameter(s)
+    ParameterFlags       *pDefArgFlags;           // Flags for each parameter
+    USHORT                nFIndex;                // Unique function index
+    USHORT                nCategory;              // Function category
+    USHORT                nArgCount;              // All parameter count, suppressed and unsuppressed
+    USHORT                nHelpId;                // HelpID of function
+    bool                  bIncomplete         :1; // Incomplete argument info (set for add-in info from configuration)
+    bool                  bHasSuppressedArgs  :1; // Whether there is any suppressed parameter.
 };
 
 //============================================================================
diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx
index 93550a9..e46a3e6 100644
--- a/sc/source/core/data/global.cxx
+++ b/sc/source/core/data/global.cxx
@@ -1168,17 +1168,17 @@ ScFuncRes::ScFuncRes( ResId &aRes, ScFuncDesc* pDesc, bool & rbSuppressed )
         }
     }
 
-    pDesc->pFuncName = new String( ScCompiler::GetNativeSymbol( static_cast<OpCode>( aRes.GetId())));
-    pDesc->pFuncDesc = new String(ScResId(1));
+    pDesc->pFuncName = new ::rtl::OUString( ScCompiler::GetNativeSymbol( static_cast<OpCode>( aRes.GetId())));
+    pDesc->pFuncDesc = (::rtl::OUString*)(new String(ScResId(1)));
 
     if (nArgs)
     {
-        pDesc->ppDefArgNames = new String*[nArgs];
-        pDesc->ppDefArgDescs = new String*[nArgs];
+        pDesc->ppDefArgNames = new ::rtl::OUString*[nArgs];
+        pDesc->ppDefArgDescs = new ::rtl::OUString*[nArgs];
         for (USHORT i = 0; i < nArgs; i++)
         {
-            pDesc->ppDefArgNames[i] = new String(ScResId(2*(i+1)  ));
-            pDesc->ppDefArgDescs[i] = new String(ScResId(2*(i+1)+1));
+            pDesc->ppDefArgNames[i] = (::rtl::OUString*)(new String(ScResId(2*(i+1)  )));
+            pDesc->ppDefArgDescs[i] = (::rtl::OUString*)(new String(ScResId(2*(i+1)+1)));
         }
     }
 
@@ -1250,7 +1250,7 @@ ScFunctionList::ScFunctionList() :
                     pDesc->nFIndex = i;
                     aFunctionList.Insert( pDesc, LIST_APPEND );
 
-                    nStrLen = (*(pDesc->pFuncName)).Len();
+                    nStrLen = (*(pDesc->pFuncName)).getLength();
                     if (nStrLen > nMaxFuncNameLen)
                         nMaxFuncNameLen = nStrLen;
                 }
@@ -1283,73 +1283,73 @@ ScFunctionList::ScFunctionList() :
         pAddInFuncData->GetParamDesc( aArgName, aArgDesc, 0 );
           pDesc->nFIndex     = nNextId++;				//  ??? OpCode vergeben
           pDesc->nCategory   = ID_FUNCTION_GRP_ADDINS;
-          pDesc->pFuncName   = new String(pAddInFuncData->GetInternalName());
-          pDesc->pFuncName->ToUpperAscii();
-          pDesc->pFuncDesc   = new String( aArgDesc );
-        *(pDesc->pFuncDesc) += '\n';
-          pDesc->pFuncDesc->AppendAscii(RTL_CONSTASCII_STRINGPARAM( "( AddIn: " ));
+          pDesc->pFuncName   = new ::rtl::OUString(pAddInFuncData->GetInternalName());
+          pDesc->pFuncName->toAsciiUpperCase();
+          pDesc->pFuncDesc   = new ::rtl::OUString( aArgDesc );
+        *(pDesc->pFuncDesc) += *(new ::rtl::OUString( '\n' ));
+        *(pDesc->pFuncDesc) += ::rtl::OUString::createFromAscii("( AddIn: ");
         *(pDesc->pFuncDesc) += pAddInFuncData->GetModuleName();
-          pDesc->pFuncDesc->AppendAscii(RTL_CONSTASCII_STRINGPARAM( " )" ));
+        *(pDesc->pFuncDesc) += ::rtl::OUString::createFromAscii( " )" );
           pDesc->nArgCount   = nArgs;
         if (nArgs)
         {
             pDesc->pDefArgFlags  = new ScFuncDesc::ParameterFlags[nArgs];
-            pDesc->ppDefArgNames = new String*[nArgs];
-            pDesc->ppDefArgDescs = new String*[nArgs];
+            pDesc->ppDefArgNames = new ::rtl::OUString*[nArgs];
+            pDesc->ppDefArgDescs = new ::rtl::OUString*[nArgs];
             for (j = 0; j < nArgs; j++)
             {
                 pDesc->pDefArgFlags[j].bOptional = false;
                 pDesc->pDefArgFlags[j].bSuppress = false;
                 pAddInFuncData->GetParamDesc( aArgName, aArgDesc, j+1 );
                 if ( aArgName.Len() )
-                    pDesc->ppDefArgNames[j] = new String( aArgName );
+                    pDesc->ppDefArgNames[j] = new ::rtl::OUString( aArgName );
                 else
                 {
                     switch (pAddInFuncData->GetParamType(j+1))
                     {
                         case PTR_DOUBLE:
-                            pDesc->ppDefArgNames[j] = new String( aDefArgNameValue );
+                            pDesc->ppDefArgNames[j] = new ::rtl::OUString( aDefArgNameValue );
                             break;
                         case PTR_STRING:
-                            pDesc->ppDefArgNames[j] = new String( aDefArgNameString );
+                            pDesc->ppDefArgNames[j] = new ::rtl::OUString( aDefArgNameString );
                             break;
                         case PTR_DOUBLE_ARR:
-                            pDesc->ppDefArgNames[j] = new String( aDefArgNameValues );
+                            pDesc->ppDefArgNames[j] = new ::rtl::OUString( aDefArgNameValues );
                             break;
                         case PTR_STRING_ARR:
-                            pDesc->ppDefArgNames[j] = new String( aDefArgNameStrings );
+                            pDesc->ppDefArgNames[j] = new ::rtl::OUString( aDefArgNameStrings );
                             break;
                         case PTR_CELL_ARR:
-                            pDesc->ppDefArgNames[j] = new String( aDefArgNameCells );
+                            pDesc->ppDefArgNames[j] = new ::rtl::OUString( aDefArgNameCells );
                             break;
                         default:
-                            pDesc->ppDefArgNames[j] = new String( aDefArgNameNone );
+                            pDesc->ppDefArgNames[j] = new ::rtl::OUString( aDefArgNameNone );
                             break;
                     }
                 }
                 if ( aArgDesc.Len() )
-                    pDesc->ppDefArgDescs[j] = new String( aArgDesc );
+                    pDesc->ppDefArgDescs[j] = new ::rtl::OUString( aArgDesc );
                 else
                 {
                     switch (pAddInFuncData->GetParamType(j+1))
                     {
                         case PTR_DOUBLE:
-                            pDesc->ppDefArgDescs[j] = new String( aDefArgDescValue );
+                            pDesc->ppDefArgDescs[j] = new ::rtl::OUString( aDefArgDescValue );
                             break;
                         case PTR_STRING:
-                            pDesc->ppDefArgDescs[j] = new String( aDefArgDescString );
+                            pDesc->ppDefArgDescs[j] = new ::rtl::OUString( aDefArgDescString );
                             break;
                         case PTR_DOUBLE_ARR:
-                            pDesc->ppDefArgDescs[j] = new String( aDefArgDescValues );
+                            pDesc->ppDefArgDescs[j] = new ::rtl::OUString( aDefArgDescValues );
                             break;
                         case PTR_STRING_ARR:
-                            pDesc->ppDefArgDescs[j] = new String( aDefArgDescStrings );
+                            pDesc->ppDefArgDescs[j] = new ::rtl::OUString( aDefArgDescStrings );
                             break;
                         case PTR_CELL_ARR:
-                            pDesc->ppDefArgDescs[j] = new String( aDefArgDescCells );
+                            pDesc->ppDefArgDescs[j] = new ::rtl::OUString( aDefArgDescCells );
                             break;
                         default:
-                            pDesc->ppDefArgDescs[j] = new String( aDefArgDescNone );
+                            pDesc->ppDefArgDescs[j] = new ::rtl::OUString( aDefArgDescNone );
                             break;
                     }
                 }
@@ -1357,7 +1357,7 @@ ScFunctionList::ScFunctionList() :
         }
 
         aFunctionList.Insert(pDesc, LIST_APPEND);
-        nStrLen = (*(pDesc->pFuncName)).Len();
+        nStrLen = (*(pDesc->pFuncName)).getLength();
         if ( nStrLen > nMaxFuncNameLen)
             nMaxFuncNameLen = nStrLen;
     }
@@ -1374,7 +1374,7 @@ ScFunctionList::ScFunctionList() :
         if ( pUnoAddIns->FillFunctionDesc( nFunc, *pDesc ) )
         {
             aFunctionList.Insert(pDesc, LIST_APPEND);
-            nStrLen = (*(pDesc->pFuncName)).Len();
+            nStrLen = (*(pDesc->pFuncName)).getLength();
             if (nStrLen > nMaxFuncNameLen)
                 nMaxFuncNameLen = nStrLen;
         }
@@ -1476,7 +1476,7 @@ String ScFuncDesc::GetParamList() const
                 else
                 {
                     nLastAdded = i;
-                    aSig += *(ppDefArgNames[i]);
+                    aSig += (String)*(ppDefArgNames[i]);
                     if ( i != nArgCount-1 )
                     {
                         aSig.Append(sep);
@@ -1497,7 +1497,7 @@ String ScFuncDesc::GetParamList() const
             {
                 if (!pDefArgFlags[nArg].bSuppress)
                 {
-                    aSig += *(ppDefArgNames[nArg]);
+                    aSig += (String)*(ppDefArgNames[nArg]);
                     aSig.Append(sep);
                     aSig.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " " ));
                 }
@@ -1506,11 +1506,11 @@ String ScFuncDesc::GetParamList() const
              * there were, we'd have to cope with it here and above for the fix
              * parameters. For now parameters are always added, so no special
              * treatment of a trailing "; " necessary. */
-            aSig += *(ppDefArgNames[nFix]);
+            aSig += (String)*(ppDefArgNames[nFix]);
             aSig += '1';
             aSig.Append(sep);
             aSig.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " " ));
-            aSig += *(ppDefArgNames[nFix]);
+            aSig += (String)*(ppDefArgNames[nFix]);
             aSig += '2';
             aSig.Append(sep);
             aSig.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " ... " ));
@@ -1769,7 +1769,7 @@ const ScFuncDesc* ScFunctionMgr::Get( const String& rFName ) const
     const ScFuncDesc*	pDesc = NULL;
     if (rFName.Len() <= pFuncList->GetMaxFuncNameLen())
         for (pDesc = First(0); pDesc; pDesc = Next())
-            if (rFName.EqualsIgnoreCaseAscii(*(pDesc->pFuncName)))
+            if (rFName.EqualsIgnoreCaseAscii((String)(*(pDesc->pFuncName))))
                 break;
     return pDesc;
 }
diff --git a/sc/source/core/tool/addincol.cxx b/sc/source/core/tool/addincol.cxx
index ed7eb29..307add6 100644
--- a/sc/source/core/tool/addincol.cxx
+++ b/sc/source/core/tool/addincol.cxx
@@ -1048,7 +1048,7 @@ void ScUnoAddInCollection::ReadFromAddIn( const uno::Reference<uno::XInterface>&
 
 void lcl_UpdateFunctionList( ScFunctionList& rFunctionList, const ScUnoAddInFuncData& rFuncData )
 {
-    String aCompare = rFuncData.GetUpperLocal();    // as used in FillFunctionDescFromData
+    ::rtl::OUString aCompare = (::rtl::OUString)rFuncData.GetUpperLocal();    // as used in FillFunctionDescFromData
 
     ULONG nCount = rFunctionList.GetCount();
     for (ULONG nPos=0; nPos<nCount; nPos++)
@@ -1328,14 +1328,14 @@ BOOL ScUnoAddInCollection::FillFunctionDescFromData( const ScUnoAddInFuncData& r
 
     // nFIndex is set from outside
 
-    rDesc.pFuncName = new String( rFuncData.GetUpperLocal() );     //! upper?
+    rDesc.pFuncName = new ::rtl::OUString( rFuncData.GetUpperLocal() );     //! upper?
     rDesc.nCategory = rFuncData.GetCategory();
     rDesc.nHelpId = rFuncData.GetHelpId();
 
     String aDesc = rFuncData.GetDescription();
     if (!aDesc.Len())
         aDesc = rFuncData.GetLocalName();      // use name if no description is available
-    rDesc.pFuncDesc = new String( aDesc );
+    rDesc.pFuncDesc = new ::rtl::OUString( aDesc );
 
     // AddInArgumentType_CALLER is already left out in FuncData
 
@@ -1345,18 +1345,18 @@ BOOL ScUnoAddInCollection::FillFunctionDescFromData( const ScUnoAddInFuncData& r
         BOOL bMultiple = FALSE;
         const ScAddInArgDesc* pArgs = rFuncData.GetArguments();
 
-        rDesc.ppDefArgNames = new String*[nArgCount];
-        rDesc.ppDefArgDescs = new String*[nArgCount];
+        rDesc.ppDefArgNames = new ::rtl::OUString*[nArgCount];
+        rDesc.ppDefArgDescs = new ::rtl::OUString*[nArgCount];
         rDesc.pDefArgFlags   = new ScFuncDesc::ParameterFlags[nArgCount];
         for ( long nArg=0; nArg<nArgCount; nArg++ )
         {
-            rDesc.ppDefArgNames[nArg] = new String( pArgs[nArg].aName );
-            rDesc.ppDefArgDescs[nArg] = new String( pArgs[nArg].aDescription );
+            rDesc.ppDefArgNames[nArg] = new ::rtl::OUString( pArgs[nArg].aName );
+            rDesc.ppDefArgDescs[nArg] = new ::rtl::OUString( pArgs[nArg].aDescription );
             rDesc.pDefArgFlags[nArg].bOptional = pArgs[nArg].bOptional;
             rDesc.pDefArgFlags[nArg].bSuppress = false;
 
             // no empty names...
-            if ( rDesc.ppDefArgNames[nArg]->Len() == 0 )
+            if ( rDesc.ppDefArgNames[nArg]->getLength() == 0 )
             {
                 String aDefName( RTL_CONSTASCII_USTRINGPARAM("arg") );
                 aDefName += String::CreateFromInt32( nArg+1 );
diff --git a/sc/source/ui/formdlg/dwfunctr.cxx b/sc/source/ui/formdlg/dwfunctr.cxx
index f003caa..2e1aa63 100644
--- a/sc/source/ui/formdlg/dwfunctr.cxx
+++ b/sc/source/ui/formdlg/dwfunctr.cxx
@@ -618,7 +618,7 @@ void ScFunctionDockWin::SetDescription()
             aString += '\n';
         }
 
-        aString+=*(pDesc->pFuncDesc);
+        aString+=(String)*(pDesc->pFuncDesc);
 
         aFiFuncDesc.SetText(aString);
         aFiFuncDesc.StateChanged(STATE_CHANGE_TEXT);
diff --git a/sc/source/ui/unoobj/appluno.cxx b/sc/source/ui/unoobj/appluno.cxx
index a30360a..edf669e 100644
--- a/sc/source/ui/unoobj/appluno.cxx
+++ b/sc/source/ui/unoobj/appluno.cxx
@@ -952,7 +952,7 @@ uno::Any SAL_CALL ScFunctionListObj::getByName( const rtl::OUString& aName )
                     lang::WrappedTargetException, uno::RuntimeException)
 {
     SolarMutexGuard aGuard;
-    String aNameStr(aName);
+    ::rtl::OUString aNameStr(aName);
     const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
     if ( pFuncList )
     {
@@ -982,10 +982,10 @@ uno::Any SAL_CALL ScFunctionListObj::getByName( const rtl::OUString& aName )
 sal_Int32 SAL_CALL ScFunctionListObj::getCount() throw(uno::RuntimeException)
 {
     SolarMutexGuard aGuard;
-    USHORT nCount = 0;
+    sal_Int32 nCount = 0;
     const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
     if ( pFuncList )
-        nCount = (USHORT)pFuncList->GetCount();
+        nCount = (sal_Int32)pFuncList->GetCount();
     return nCount;
 }
 
@@ -1045,10 +1045,10 @@ uno::Sequence<rtl::OUString> SAL_CALL ScFunctionListObj::getElementNames() throw
     const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
     if ( pFuncList )
     {
-        USHORT nCount = (USHORT)pFuncList->GetCount();
+        sal_uInt32 nCount = pFuncList->GetCount();
         uno::Sequence<rtl::OUString> aSeq(nCount);
         rtl::OUString* pAry = aSeq.getArray();
-        for (USHORT nIndex=0; nIndex<nCount; nIndex++)
+        for (sal_uInt32 nIndex=0; nIndex<nCount; nIndex++)
         {
             const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
             if ( pDesc && pDesc->pFuncName )
@@ -1063,20 +1063,19 @@ sal_Bool SAL_CALL ScFunctionListObj::hasByName( const rtl::OUString& aName )
                                         throw(uno::RuntimeException)
 {
     SolarMutexGuard aGuard;
-    String aNameStr(aName);
     const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
     if ( pFuncList )
     {
-        USHORT nCount = (USHORT)pFuncList->GetCount();
-        for (USHORT nIndex=0; nIndex<nCount; nIndex++)
+        sal_uInt32 nCount = pFuncList->GetCount();
+        for (sal_uInt32 nIndex=0; nIndex<nCount; nIndex++)
         {
             const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
             //!	Case-insensitiv ???
-            if ( pDesc && pDesc->pFuncName && aNameStr == *pDesc->pFuncName )
-                return TRUE;
+            if ( pDesc && pDesc->pFuncName && aName == *pDesc->pFuncName )
+                return sal_True;
         }
     }
-    return FALSE;
+    return sal_False;
 }
 
 //------------------------------------------------------------------------
-- 
1.7.0.4

_______________________________________________
LibreOffice mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice

Reply via email to