diff options
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/dptabdat.hxx | 2 | ||||
-rw-r--r-- | sc/inc/dptablecache.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/dpitemdata.cxx | 11 | ||||
-rw-r--r-- | sc/source/core/data/dptabdat.cxx | 64 | ||||
-rw-r--r-- | sc/source/core/data/dptablecache.cxx | 17 | ||||
-rw-r--r-- | sc/source/core/data/dptabres.cxx | 13 |
6 files changed, 53 insertions, 56 deletions
diff --git a/sc/inc/dptabdat.hxx b/sc/inc/dptabdat.hxx index e64f3fc8d0f8..8cd3c474b920 100644 --- a/sc/inc/dptabdat.hxx +++ b/sc/inc/dptabdat.hxx @@ -128,6 +128,8 @@ public: ScDPTableData(ScDocument* pDoc); virtual ~ScDPTableData(); + rtl::OUString GetFormattedString(long nDim, const ScDPItemData& rItem) const; + long GetDatePart( long nDateVal, long nHierarchy, long nLevel ); //! use (new) typed collection instead of ScStrCollection diff --git a/sc/inc/dptablecache.hxx b/sc/inc/dptablecache.hxx index dac253768320..c8f7816d661a 100644 --- a/sc/inc/dptablecache.hxx +++ b/sc/inc/dptablecache.hxx @@ -130,7 +130,7 @@ public: SCROW GetIdByItemData(long nDim, const rtl::OUString& sItemData) const; SCROW GetIdByItemData(long nDim, const ScDPItemData& rData) const; - + rtl::OUString GetFormattedString(long nDim, const ScDPItemData& rItem) const; void AppendGroupField(); void ResetGroupItems(long nDim); SCROW SetGroupItem(long nDim, const ScDPItemData& rData); diff --git a/sc/source/core/data/dpitemdata.cxx b/sc/source/core/data/dpitemdata.cxx index b7d6c2864bef..b74eb85d9f1c 100644 --- a/sc/source/core/data/dpitemdata.cxx +++ b/sc/source/core/data/dpitemdata.cxx @@ -213,8 +213,15 @@ bool ScDPItemData::IsValue() const rtl::OUString ScDPItemData::GetString() const { - if (meType == String) - return *mpString; + switch (meType) + { + case String: + return *mpString; + case Value: + return rtl::OUString::valueOf(mfValue); + default: + ; + } // TODO: Generate appropriate string. return rtl::OUString::createFromAscii("fail"); diff --git a/sc/source/core/data/dptabdat.cxx b/sc/source/core/data/dptabdat.cxx index 4993207fc182..fd78b8bd9603 100644 --- a/sc/source/core/data/dptabdat.cxx +++ b/sc/source/core/data/dptabdat.cxx @@ -31,6 +31,14 @@ // INCLUDE --------------------------------------------------------------- +#include "dptabdat.hxx" + +#include "global.hxx" +#include "dpcachetable.hxx" +#include "dptabres.hxx" +#include "document.hxx" +#include "dpobject.hxx" + #include <stdio.h> #include <rtl/math.hxx> #include <tools/date.hxx> @@ -39,60 +47,11 @@ #include <com/sun/star/sheet/DataPilotFieldFilter.hpp> -#include "dptabdat.hxx" -#include "global.hxx" -#include "dpcachetable.hxx" -#include "dptabres.hxx" -#include "document.hxx" -#include "dpobject.hxx" - using namespace ::com::sun::star; using ::com::sun::star::uno::Sequence; using ::com::sun::star::uno::Any; using ::std::vector; -#include <stdio.h> -#include <string> -#include <sys/time.h> - -namespace { - -class stack_printer -{ -public: - explicit stack_printer(const char* msg) : - msMsg(msg) - { - fprintf(stdout, "%s: --begin\n", msMsg.c_str()); - mfStartTime = getTime(); - } - - ~stack_printer() - { - double fEndTime = getTime(); - fprintf(stdout, "%s: --end (duration: %g sec)\n", msMsg.c_str(), (fEndTime-mfStartTime)); - } - - void printTime(int line) const - { - double fEndTime = getTime(); - fprintf(stdout, "%s: --(%d) (duration: %g sec)\n", msMsg.c_str(), line, (fEndTime-mfStartTime)); - } - -private: - double getTime() const - { - timeval tv; - gettimeofday(&tv, NULL); - return tv.tv_sec + tv.tv_usec / 1000000.0; - } - - ::std::string msMsg; - double mfStartTime; -}; - -} - // --------------------------------------------------------------------------- ScDPTableData::CalcInfo::CalcInfo() : @@ -114,6 +73,12 @@ ScDPTableData::~ScDPTableData() { } +rtl::OUString ScDPTableData::GetFormattedString(long nDim, const ScDPItemData& rItem) const +{ + const ScDPCache* pCache = GetCacheTable().getCache(); + return pCache->GetFormattedString(nDim, rItem); +} + long ScDPTableData::GetDatePart( long nDateVal, long nHierarchy, long nLevel ) { if ( nDateVal == nLastDateVal && nHierarchy == nLastHier && nLevel == nLastLevel ) @@ -227,7 +192,6 @@ void ScDPTableData::FillRowDataFromCacheTable(sal_Int32 nRow, const ScDPCacheTab void ScDPTableData::ProcessRowData(CalcInfo& rInfo, CalcRowData& rData, bool bAutoShow) { - stack_printer __stack_printer__("ScDPTableData::ProcessRowData"); if (!bAutoShow) { LateInitParams aColParams(rInfo.aColDims, rInfo.aColLevels, false); diff --git a/sc/source/core/data/dptablecache.cxx b/sc/source/core/data/dptablecache.cxx index 372ca929f5fd..5cd984c654ee 100644 --- a/sc/source/core/data/dptablecache.cxx +++ b/sc/source/core/data/dptablecache.cxx @@ -980,6 +980,23 @@ SCROW ScDPCache::GetIdByItemData(long nDim, const ScDPItemData& rData) const return -1; } +rtl::OUString ScDPCache::GetFormattedString(long nDim, const ScDPItemData& rItem) const +{ + if (!rItem.IsValue()) + return rItem.GetString(); + + sal_uLong nNumFormat = GetNumberFormat(nDim); + SvNumberFormatter* pFormatter = mpDoc->GetFormatTable(); + if (pFormatter) + { + Color* pColor = NULL; + String aStr; + pFormatter->GetOutputString(rItem.GetValue(), nNumFormat, aStr, &pColor); + return aStr; + } + return rtl::OUString::createFromAscii("fail again"); +} + void ScDPCache::AppendGroupField() { maGroupFields.push_back(new GroupField); diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx index 7a59b0ea4fef..a282f8fb7f52 100644 --- a/sc/source/core/data/dptabres.cxx +++ b/sc/source/core/data/dptabres.cxx @@ -1423,8 +1423,8 @@ void ScDPResultMember::FillMemberResults( uno::Sequence<sheet::MemberResult>* pS sheet::MemberResult* pArray = pSequences->getArray(); OSL_ENSURE( rPos+nSize <= pSequences->getLength(), "bumm" ); - sal_Bool bIsNumeric = false; - String aName; + bool bIsNumeric = false; + rtl::OUString aName; if ( pMemberName ) // if pMemberName != NULL, use instead of real member name { aName = *pMemberName; @@ -1433,7 +1433,14 @@ void ScDPResultMember::FillMemberResults( uno::Sequence<sheet::MemberResult>* pS { ScDPItemData aItemData; FillItemData( aItemData ); - aName = aItemData.GetString(); + if (aParentDimData.mpParentDim) + { + long nDim = aParentDimData.mpParentDim->GetDimension(); + aName = pResultData->GetSource()->GetData()->GetFormattedString(nDim, aItemData); + } + else + aName = aItemData.GetString(); + bIsNumeric = aItemData.IsValue(); } |