summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@suse.com>2011-11-15 02:02:14 -0500
committerKohei Yoshida <kohei.yoshida@suse.com>2011-11-15 02:02:52 -0500
commite786e2d25ab0105e88d7ca260c7ef4a88c9b821c (patch)
treecbeab4b56c87f944d095f1c2347b4752527ed5c1
parent35054d3f6213c11546200820c706c8a1527ec605 (diff)
String to rtl::OUString.
-rw-r--r--comphelper/inc/comphelper/string.hxx3
-rw-r--r--comphelper/source/misc/string.cxx12
-rw-r--r--sc/inc/dptabres.hxx4
-rw-r--r--sc/source/core/data/dptabres.cxx14
-rw-r--r--sc/source/core/data/dptabsrc.cxx5
5 files changed, 27 insertions, 11 deletions
diff --git a/comphelper/inc/comphelper/string.hxx b/comphelper/inc/comphelper/string.hxx
index 4545302b4086..620db1b8bf34 100644
--- a/comphelper/inc/comphelper/string.hxx
+++ b/comphelper/inc/comphelper/string.hxx
@@ -352,6 +352,9 @@ COMPHELPER_DLLPUBLIC inline rtl::OUStringBuffer& padToLength(
return detail::padToLength(rBuffer, nLength, cFill);
}
+COMPHELPER_DLLPUBLIC rtl::OUString removeTrailingChars(
+ const rtl::OUString& rStr, sal_Unicode cChar);
+
/** Convert a sequence of strings to a single comma separated string.
Note that no escaping of commas or anything fancy is done.
diff --git a/comphelper/source/misc/string.cxx b/comphelper/source/misc/string.cxx
index 873a1ffe34e9..6f59564814b9 100644
--- a/comphelper/source/misc/string.cxx
+++ b/comphelper/source/misc/string.cxx
@@ -235,6 +235,18 @@ sal_uInt32 decimalStringToNumber(
return result;
}
+rtl::OUString removeTrailingChars(const rtl::OUString& rStr, sal_Unicode cChar)
+{
+ sal_Int32 n = rStr.getLength();
+ const sal_Unicode* p = &rStr.getStr()[n-1]; // last char
+ while (n > 0 && *p == cChar)
+ {
+ --p;
+ --n;
+ }
+ return rStr.copy(0, n);
+}
+
using namespace ::com::sun::star;
// convert between sequence of string and comma separated string
diff --git a/sc/inc/dptabres.hxx b/sc/inc/dptabres.hxx
index b8a2414a90c7..2c92f22bd5c3 100644
--- a/sc/inc/dptabres.hxx
+++ b/sc/inc/dptabres.hxx
@@ -299,7 +299,7 @@ private:
ScSubTotalFunc* pMeasFuncs;
::com::sun::star::sheet::DataPilotFieldReference* pMeasRefs;
sal_uInt16* pMeasRefOrient;
- std::vector<String> maMeasureNames;
+ std::vector<rtl::OUString> maMeasureNames;
bool bLateInit:1;
bool bDataAtCol:1;
bool bDataAtRow:1;
@@ -312,7 +312,7 @@ public:
void SetMeasureData( long nCount, const ScSubTotalFunc* pFunctions,
const ::com::sun::star::sheet::DataPilotFieldReference* pRefs,
- const sal_uInt16* pRefOrient, std::vector<String>& rNames );
+ const sal_uInt16* pRefOrient, std::vector<rtl::OUString>& rNames );
void SetDataLayoutOrientation( sal_uInt16 nOrient );
void SetLateInit( bool bSet );
diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx
index b7c5e0a0bc76..62feb0b1bb80 100644
--- a/sc/source/core/data/dptabres.cxx
+++ b/sc/source/core/data/dptabres.cxx
@@ -786,7 +786,7 @@ ScDPResultData::~ScDPResultData()
void ScDPResultData::SetMeasureData( long nCount, const ScSubTotalFunc* pFunctions,
const sheet::DataPilotFieldReference* pRefs, const sal_uInt16* pRefOrient,
- std::vector<String>& rNames )
+ std::vector<rtl::OUString>& rNames )
{
delete[] pMeasFuncs;
delete[] pMeasRefs;
@@ -815,7 +815,7 @@ void ScDPResultData::SetMeasureData( long nCount, const ScSubTotalFunc* pFunctio
pMeasRefs = new sheet::DataPilotFieldReference[1]; // default ctor is ok
pMeasRefOrient = new sal_uInt16[1];
pMeasRefOrient[0] = sheet::DataPilotFieldOrientation_HIDDEN;
- std::vector<String> aMeasureName;
+ std::vector<rtl::OUString> aMeasureName;
aMeasureName.push_back(ScGlobal::GetRscString(STR_EMPTYDATA));
maMeasureNames.swap(aMeasureName);
}
@@ -887,18 +887,18 @@ String ScDPResultData::GetMeasureString(long nMeasure, bool bForce, ScSubTotalFu
if (pLayoutName)
return *pLayoutName;
}
- String aRet;
+ rtl::OUStringBuffer aRet;
ScSubTotalFunc eFunc = ( eForceFunc == SUBTOTAL_FUNC_NONE ) ?
GetMeasureFunction(nMeasure) : eForceFunc;
sal_uInt16 nId = nFuncStrIds[eFunc];
if (nId)
{
- aRet += ScGlobal::GetRscString(nId); // function name
- aRet.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " - " ));
+ aRet.append(ScGlobal::GetRscString(nId)); // function name
+ aRet.appendAscii(RTL_CONSTASCII_STRINGPARAM(" - "));
}
- aRet += maMeasureNames[nMeasure]; // field name
+ aRet.append(maMeasureNames[nMeasure]); // field name
- return aRet;
+ return aRet.makeStringAndClear();
}
}
diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx
index 008ea39a8271..b0ac47722a3d 100644
--- a/sc/source/core/data/dptabsrc.cxx
+++ b/sc/source/core/data/dptabsrc.cxx
@@ -69,6 +69,7 @@
#include <com/sun/star/sheet/DataPilotFieldAutoShowInfo.hpp>
#include <com/sun/star/table/CellAddress.hpp>
+#include "comphelper/string.hxx"
#include <unotools/collatorwrapper.hxx>
#include <unotools/calendarwrapper.hxx>
#include <com/sun/star/i18n/CalendarDisplayIndex.hpp>
@@ -792,7 +793,7 @@ void ScDPSource::CreateRes_Impl()
// TODO: Aggreate pDataNames, pDataRefValues, nDataRefOrient, and
// eDataFunctions into a structure and use vector instead of static
// or pointer arrays.
- vector<String> aDataNames;
+ vector<rtl::OUString> aDataNames;
sheet::DataPilotFieldReference* pDataRefValues = NULL;
ScSubTotalFunc eDataFunctions[SC_DAPI_MAXFIELDS];
sal_uInt16 nDataRefOrient[SC_DAPI_MAXFIELDS];
@@ -854,7 +855,7 @@ void ScDPSource::CreateRes_Impl()
// asterisk is added to duplicated dimension names by ScDPSaveData::WriteToSource
//! modify user visible strings as in ScDPResultData::GetMeasureString instead!
- aDataNames[i].EraseTrailingChars('*');
+ aDataNames[i] = comphelper::string::removeTrailingChars(aDataNames[i], '*');
//! if the name is overridden by user, a flag must be set
//! so the user defined name replaces the function string and field name.