From b6cfbd08c2a9b686cfe024a63469cbcd10d9a4bd Mon Sep 17 00:00:00 2001 From: Sören Möller Date: Wed, 4 Jul 2012 22:53:11 +0200 Subject: Replaced deprecated tools/String with OUString in ScMatrix Change-Id: If431e5ef8b5c97384a1bb1c7fa36c6894ece8343 --- sc/inc/global.hxx | 4 ++++ sc/inc/scmatrix.hxx | 18 ++++++++-------- sc/qa/unit/ucalc.cxx | 2 +- sc/source/core/data/global.cxx | 8 ++++++++ sc/source/core/tool/scmatrix.cxx | 44 ++++++++++++++++++++-------------------- 5 files changed, 44 insertions(+), 32 deletions(-) (limited to 'sc') diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx index 1f29753acf6b..371431fc0265 100644 --- a/sc/inc/global.hxx +++ b/sc/inc/global.hxx @@ -35,6 +35,7 @@ #include #include #include "scdllapi.h" +#include #include #include @@ -231,6 +232,7 @@ const sal_uInt16 IDF_AUTOFILL = IDF_ALL & ~(IDF_NOTE | IDF_OBJECTS); #define EMPTY_STRING ScGlobal::GetEmptyString() +#define EMPTY_OUSTRING ScGlobal::GetEmptyOUString() // layer id's for drawing #define SC_LAYER_FRONT 0 @@ -496,6 +498,7 @@ class ScGlobal static String** ppRscString; static String* pStrScDoc; static String* pEmptyString; + static ::rtl::OUString* pEmptyOUString; static String* pStrClipDocName; static SvxBrushItem* pEmptyBrushItem; static SvxBrushItem* pButtonBrushItem; @@ -585,6 +588,7 @@ public: static SvxBrushItem* GetEmbeddedBrushItem() { return pEmbeddedBrushItem; } static SvxBrushItem* GetProtectedBrushItem() { return pProtectedBrushItem; } SC_DLLPUBLIC static const String& GetEmptyString(); + SC_DLLPUBLIC static const ::rtl::OUString& GetEmptyOUString(); static const String& GetScDocString(); /** Returns the specified image list with outline symbols. */ diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx index 222f863b1828..9657540bcad0 100644 --- a/sc/inc/scmatrix.hxx +++ b/sc/inc/scmatrix.hxx @@ -32,8 +32,8 @@ #include "global.hxx" #include "types.hxx" #include "formula/errorcodes.hxx" -#include #include "scdllapi.h" +#include #include @@ -53,12 +53,12 @@ struct ScMatrixValue { union { double fVal; - const String* pS; + const ::rtl::OUString* pS; }; ScMatValType nType; /// Only valid if ScMatrix methods indicate so! - const String& GetString() const { return pS ? *pS : EMPTY_STRING; } + const ::rtl::OUString& GetString() const { return pS ? *pS : EMPTY_OUSTRING; } /// Only valid if ScMatrix methods indicate that this is no string! sal_uInt16 GetError() const { return GetDoubleErrorValue( fVal); } @@ -92,7 +92,7 @@ struct ScMatrixValue if (!pS) return r.pS == NULL; - return GetString().Equals(r.GetString()); + return GetString().equals(r.GetString()); } bool operator!= (const ScMatrixValue& r) const @@ -274,8 +274,8 @@ public: void PutDouble( double fVal, SCSIZE nC, SCSIZE nR); void PutDouble( double fVal, SCSIZE nIndex); - void PutString( const String& rStr, SCSIZE nC, SCSIZE nR); - void PutString( const String& rStr, SCSIZE nIndex); + void PutString( const ::rtl::OUString& rStr, SCSIZE nC, SCSIZE nR); + void PutString( const ::rtl::OUString& rStr, SCSIZE nIndex); void PutEmpty( SCSIZE nC, SCSIZE nR); /// Jump FALSE without path void PutEmptyPath( SCSIZE nC, SCSIZE nR); @@ -303,15 +303,15 @@ public: double GetDouble( SCSIZE nIndex) const; /// @return empty string if empty or empty path, else string content. - const String& GetString( SCSIZE nC, SCSIZE nR) const; + const ::rtl::OUString& GetString( SCSIZE nC, SCSIZE nR) const; /// @return empty string if empty or empty path, else string content. - const String& GetString( SCSIZE nIndex) const; + const ::rtl::OUString& GetString( SCSIZE nIndex) const; /** @returns the matrix element's string if one is present, otherwise the numerical value formatted as string, or in case of an error the error string is returned; an empty string for empty, a "FALSE" string for empty path. */ - String GetString( SvNumberFormatter& rFormatter, SCSIZE nC, SCSIZE nR) const; + ::rtl::OUString GetString( SvNumberFormatter& rFormatter, SCSIZE nC, SCSIZE nR) const; /// @ATTENTION: If bString the ScMatrixValue->pS may still be NULL to indicate /// an empty string! diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 43c160793ad9..f317f52068e1 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -1198,7 +1198,7 @@ struct PartiallyFilledEmptyMatrix else if (nCol == 8 && nRow == 2) { CPPUNIT_ASSERT_MESSAGE("element is not of value type", rVal.nType == SC_MATVAL_STRING); - CPPUNIT_ASSERT_MESSAGE("element value is not what is expected", rVal.pS->EqualsAscii("Test")); + CPPUNIT_ASSERT_MESSAGE("element value is not what is expected", rVal.pS->equalsAscii("Test")); } else if (nCol == 8 && nRow == 11) { diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx index ee2bea9e45b0..011d2e0d63e3 100644 --- a/sc/source/core/data/global.cxx +++ b/sc/source/core/data/global.cxx @@ -110,6 +110,7 @@ CollatorWrapper* ScGlobal::pCaseCollator = NULL; IntlWrapper* ScGlobal::pScIntlWrapper = NULL; sal_Unicode ScGlobal::cListDelimiter = ','; String* ScGlobal::pEmptyString = NULL; +::rtl::OUString* ScGlobal::pEmptyOUString = NULL; String* ScGlobal::pStrClipDocName = NULL; SvxBrushItem* ScGlobal::pEmptyBrushItem = NULL; @@ -520,6 +521,11 @@ const String& ScGlobal::GetEmptyString() return *pEmptyString; } +const ::rtl::OUString& ScGlobal::GetEmptyOUString() +{ + return *pEmptyOUString; +} + ImageList* ScGlobal::GetOutlineSymbols() { ImageList*& rpImageList = pOutlineBitmaps; @@ -531,6 +537,7 @@ ImageList* ScGlobal::GetOutlineSymbols() void ScGlobal::Init() { pEmptyString = new String; + pEmptyOUString = new ::rtl::OUString; // Die Default-Sprache fuer Zahlenformate (ScGlobal::eLnge) // muss immer LANGUAGE_SYSTEM sein @@ -680,6 +687,7 @@ void ScGlobal::Clear() ScDocumentPool::DeleteVersionMaps(); DELETEZ(pEmptyString); + DELETEZ(pEmptyOUString); } //------------------------------------------------------------------------ diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx index 47ed6e9731d4..0aa891a9269c 100644 --- a/sc/source/core/tool/scmatrix.cxx +++ b/sc/source/core/tool/scmatrix.cxx @@ -52,7 +52,7 @@ using ::mdds::matrix_element_t; namespace { -typedef ::mdds::mixed_type_matrix MatrixImplType; +typedef ::mdds::mixed_type_matrix< ::rtl::OUString, sal_uInt8> MatrixImplType; struct ElemEqual : public unary_function { @@ -194,8 +194,8 @@ public: void SetErrorAtInterpreter( sal_uInt16 nError ) const; void PutDouble(double fVal, SCSIZE nC, SCSIZE nR); void PutDouble( double fVal, SCSIZE nIndex); - void PutString(const String& rStr, SCSIZE nC, SCSIZE nR); - void PutString(const String& rStr, SCSIZE nIndex); + void PutString(const ::rtl::OUString& rStr, SCSIZE nC, SCSIZE nR); + void PutString(const ::rtl::OUString& rStr, SCSIZE nIndex); void PutEmpty(SCSIZE nC, SCSIZE nR); void PutEmptyPath(SCSIZE nC, SCSIZE nR); @@ -204,9 +204,9 @@ public: sal_uInt16 GetError( SCSIZE nC, SCSIZE nR) const; double GetDouble(SCSIZE nC, SCSIZE nR) const; double GetDouble( SCSIZE nIndex) const; - const String& GetString(SCSIZE nC, SCSIZE nR) const; - const String& GetString( SCSIZE nIndex) const; - String GetString( SvNumberFormatter& rFormatter, SCSIZE nC, SCSIZE nR) const; + const ::rtl::OUString& GetString(SCSIZE nC, SCSIZE nR) const; + const ::rtl::OUString& GetString( SCSIZE nIndex) const; + ::rtl::OUString GetString( SvNumberFormatter& rFormatter, SCSIZE nC, SCSIZE nR) const; ScMatrixValue Get(SCSIZE nC, SCSIZE nR) const; bool IsString( SCSIZE nIndex ) const; bool IsString( SCSIZE nC, SCSIZE nR ) const; @@ -351,17 +351,17 @@ void ScMatrixImpl::PutDouble( double fVal, SCSIZE nIndex) PutDouble(fVal, nC, nR); } -void ScMatrixImpl::PutString(const String& rStr, SCSIZE nC, SCSIZE nR) +void ScMatrixImpl::PutString(const ::rtl::OUString& rStr, SCSIZE nC, SCSIZE nR) { if (ValidColRow( nC, nR)) - maMat.set_string(nR, nC, new String(rStr)); + maMat.set_string(nR, nC, new ::rtl::OUString(rStr)); else { OSL_FAIL("ScMatrixImpl::PutString: dimension error"); } } -void ScMatrixImpl::PutString(const String& rStr, SCSIZE nIndex) +void ScMatrixImpl::PutString(const ::rtl::OUString& rStr, SCSIZE nIndex) { SCSIZE nC, nR; CalcPosition(nIndex, nC, nR); @@ -450,7 +450,7 @@ double ScMatrixImpl::GetDouble( SCSIZE nIndex) const return GetDouble(nC, nR); } -const String& ScMatrixImpl::GetString(SCSIZE nC, SCSIZE nR) const +const ::rtl::OUString& ScMatrixImpl::GetString(SCSIZE nC, SCSIZE nR) const { if (ValidColRowOrReplicated( nC, nR )) { @@ -459,7 +459,7 @@ const String& ScMatrixImpl::GetString(SCSIZE nC, SCSIZE nR) const case ::mdds::element_string: return *maMat.get_string(nR, nC); case ::mdds::element_empty: - return ScGlobal::GetEmptyString(); + return EMPTY_OUSTRING; default: SetErrorAtInterpreter( GetError(nC, nR)); OSL_FAIL("ScMatrixImpl::GetString: access error, no string"); @@ -469,22 +469,22 @@ const String& ScMatrixImpl::GetString(SCSIZE nC, SCSIZE nR) const { OSL_FAIL("ScMatrixImpl::GetString: dimension error"); } - return ScGlobal::GetEmptyString(); + return EMPTY_OUSTRING; } -const String& ScMatrixImpl::GetString( SCSIZE nIndex) const +const ::rtl::OUString& ScMatrixImpl::GetString( SCSIZE nIndex) const { SCSIZE nC, nR; CalcPosition(nIndex, nC, nR); return GetString(nC, nR); } -String ScMatrixImpl::GetString( SvNumberFormatter& rFormatter, SCSIZE nC, SCSIZE nR) const +::rtl::OUString ScMatrixImpl::GetString( SvNumberFormatter& rFormatter, SCSIZE nC, SCSIZE nR) const { if (!ValidColRowOrReplicated( nC, nR )) { OSL_FAIL("ScMatrixImpl::GetString: dimension error"); - return String(); + return ::rtl::OUString(); } if (IsString( nC, nR)) @@ -493,7 +493,7 @@ String ScMatrixImpl::GetString( SvNumberFormatter& rFormatter, SCSIZE nC, SCSIZE { // result of empty FALSE jump path sal_uLong nKey = rFormatter.GetStandardFormat( NUMBERFORMAT_LOGICAL, ScGlobal::eLnge); - String aStr; + ::rtl::OUString aStr; Color* pColor = NULL; rFormatter.GetOutputString( 0.0, nKey, aStr, &pColor); return aStr; @@ -511,7 +511,7 @@ String ScMatrixImpl::GetString( SvNumberFormatter& rFormatter, SCSIZE nC, SCSIZE double fVal= GetDouble( nC, nR); sal_uLong nKey = rFormatter.GetStandardFormat( NUMBERFORMAT_NUMBER, ScGlobal::eLnge); - String aStr; + ::rtl::OUString aStr; rFormatter.GetInputLineString( fVal, nKey, aStr); return aStr; } @@ -1010,12 +1010,12 @@ void ScMatrix::PutDouble( double fVal, SCSIZE nIndex) pImpl->PutDouble(fVal, nIndex); } -void ScMatrix::PutString(const String& rStr, SCSIZE nC, SCSIZE nR) +void ScMatrix::PutString(const ::rtl::OUString& rStr, SCSIZE nC, SCSIZE nR) { pImpl->PutString(rStr, nC, nR); } -void ScMatrix::PutString(const String& rStr, SCSIZE nIndex) +void ScMatrix::PutString(const ::rtl::OUString& rStr, SCSIZE nIndex) { pImpl->PutString(rStr, nIndex); } @@ -1055,17 +1055,17 @@ double ScMatrix::GetDouble( SCSIZE nIndex) const return pImpl->GetDouble(nIndex); } -const String& ScMatrix::GetString(SCSIZE nC, SCSIZE nR) const +const ::rtl::OUString& ScMatrix::GetString(SCSIZE nC, SCSIZE nR) const { return pImpl->GetString(nC, nR); } -const String& ScMatrix::GetString( SCSIZE nIndex) const +const ::rtl::OUString& ScMatrix::GetString( SCSIZE nIndex) const { return pImpl->GetString(nIndex); } -String ScMatrix::GetString( SvNumberFormatter& rFormatter, SCSIZE nC, SCSIZE nR) const +::rtl::OUString ScMatrix::GetString( SvNumberFormatter& rFormatter, SCSIZE nC, SCSIZE nR) const { return pImpl->GetString(rFormatter, nC, nR); } -- cgit