String to rtl::OUString.
This commit is contained in:
@@ -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.
|
||||
|
@@ -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
|
||||
|
@@ -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 );
|
||||
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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.
|
||||
|
Reference in New Issue
Block a user