diff options
author | Kohei Yoshida <kohei.yoshida@suse.com> | 2012-03-05 23:18:36 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-03-09 11:13:31 -0500 |
commit | c2f8b7a17e71f9379db7d44e763ad831cfd27825 (patch) | |
tree | 487630d0ad34882e47cb67e5e4d004562442b92c /sc | |
parent | Make sure to clear group field data when reloading the cache. (diff) | |
download | core-c2f8b7a17e71f9379db7d44e763ad831cfd27825.tar.gz core-c2f8b7a17e71f9379db7d44e763ad831cfd27825.zip |
More on correctly formatting grouped values.
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/dptabdat.hxx | 1 | ||||
-rw-r--r-- | sc/inc/dptablecache.hxx | 1 | ||||
-rw-r--r-- | sc/source/core/data/dpitemdata.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/data/dptabdat.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/data/dptablecache.cxx | 38 | ||||
-rw-r--r-- | sc/source/core/data/dptabres.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/dptabsrc.cxx | 6 |
7 files changed, 40 insertions, 20 deletions
diff --git a/sc/inc/dptabdat.hxx b/sc/inc/dptabdat.hxx index 8cd3c474b920..369881fe087b 100644 --- a/sc/inc/dptabdat.hxx +++ b/sc/inc/dptabdat.hxx @@ -128,6 +128,7 @@ public: ScDPTableData(ScDocument* pDoc); virtual ~ScDPTableData(); + rtl::OUString GetFormattedString(const ScDPItemData& rItem) const; rtl::OUString GetFormattedString(long nDim, const ScDPItemData& rItem) const; long GetDatePart( long nDateVal, long nHierarchy, long nLevel ); diff --git a/sc/inc/dptablecache.hxx b/sc/inc/dptablecache.hxx index 6c07f6f8016d..0fdc5f91df54 100644 --- a/sc/inc/dptablecache.hxx +++ b/sc/inc/dptablecache.hxx @@ -130,6 +130,7 @@ public: SCROW GetIdByItemData(long nDim, const rtl::OUString& sItemData) const; SCROW GetIdByItemData(long nDim, const ScDPItemData& rItem) const; + rtl::OUString GetFormattedString(const ScDPItemData& rItem) const; rtl::OUString GetFormattedString(long nDim, const ScDPItemData& rItem) const; void AppendGroupField(); void ResetGroupItems(long nDim); diff --git a/sc/source/core/data/dpitemdata.cxx b/sc/source/core/data/dpitemdata.cxx index 92cbab55602b..97e6a35d94c8 100644 --- a/sc/source/core/data/dpitemdata.cxx +++ b/sc/source/core/data/dpitemdata.cxx @@ -279,12 +279,14 @@ rtl::OUString ScDPItemData::GetString() const return *mpString; case Value: return rtl::OUString::valueOf(mfValue); + case GroupValue: + return rtl::OUString::createFromAscii("fail"); + case Empty: default: ; } - // TODO: Generate appropriate string. - return rtl::OUString::createFromAscii("fail"); + return rtl::OUString(); } double ScDPItemData::GetValue() const diff --git a/sc/source/core/data/dptabdat.cxx b/sc/source/core/data/dptabdat.cxx index fd78b8bd9603..7757af521ba5 100644 --- a/sc/source/core/data/dptabdat.cxx +++ b/sc/source/core/data/dptabdat.cxx @@ -73,6 +73,12 @@ ScDPTableData::~ScDPTableData() { } +rtl::OUString ScDPTableData::GetFormattedString(const ScDPItemData& rItem) const +{ + const ScDPCache* pCache = GetCacheTable().getCache(); + return pCache->GetFormattedString(rItem); +} + rtl::OUString ScDPTableData::GetFormattedString(long nDim, const ScDPItemData& rItem) const { const ScDPCache* pCache = GetCacheTable().getCache(); diff --git a/sc/source/core/data/dptablecache.cxx b/sc/source/core/data/dptablecache.cxx index db34b0eda7c8..f3b1d41a5ef2 100644 --- a/sc/source/core/data/dptablecache.cxx +++ b/sc/source/core/data/dptablecache.cxx @@ -712,14 +712,14 @@ namespace { typedef boost::unordered_set<rtl::OUString, rtl::OUStringHash> LabelSet; -class InsertLabel : public std::unary_function<ScDPItemData, void> +class InsertLabel : public std::unary_function<rtl::OUString, void> { LabelSet& mrNames; public: InsertLabel(LabelSet& rNames) : mrNames(rNames) {} - void operator() (const ScDPItemData& r) + void operator() (const rtl::OUString& r) { - mrNames.insert(r.GetString()); + mrNames.insert(r); } }; @@ -1018,7 +1018,7 @@ SCROW ScDPCache::GetIdByItemData(long nDim, const ScDPItemData& rItem) const return -1; } -rtl::OUString ScDPCache::GetFormattedString(long nDim, const ScDPItemData& rItem) const +rtl::OUString ScDPCache::GetFormattedString(const ScDPItemData& rItem) const { if (rItem.GetType() == ScDPItemData::GroupValue) { @@ -1027,19 +1027,26 @@ rtl::OUString ScDPCache::GetFormattedString(long nDim, const ScDPItemData& rItem aAttr.mnGroupType, aAttr.mnValue, mpDoc->GetFormatTable()); } - if (!rItem.IsValue()) - return rItem.GetString(); + return rItem.GetString(); +} - sal_uLong nNumFormat = GetNumberFormat(nDim); - SvNumberFormatter* pFormatter = mpDoc->GetFormatTable(); - if (pFormatter) +rtl::OUString ScDPCache::GetFormattedString(long nDim, const ScDPItemData& rItem) const +{ + if (rItem.IsValue()) { - Color* pColor = NULL; - String aStr; - pFormatter->GetOutputString(rItem.GetValue(), nNumFormat, aStr, &pColor); - return aStr; + // Format value using the stored number format. + 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"); + + return GetFormattedString(rItem); } void ScDPCache::AppendGroupField() @@ -1066,6 +1073,9 @@ void ScDPCache::ResetGroupItems(long nDim) SCROW ScDPCache::SetGroupItem(long nDim, const ScDPItemData& rData) { + if (nDim < 0) + return -1; + long nSourceCount = static_cast<long>(maFields.size()); if (nDim < nSourceCount) { diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx index f60f56bb698d..1f8adaad3ceb 100644 --- a/sc/source/core/data/dptabres.cxx +++ b/sc/source/core/data/dptabres.cxx @@ -1439,7 +1439,7 @@ void ScDPResultMember::FillMemberResults( uno::Sequence<sheet::MemberResult>* pS aName = pResultData->GetSource()->GetData()->GetFormattedString(nDim, aItemData); } else - aName = aItemData.GetString(); + aName = pResultData->GetSource()->GetData()->GetFormattedString(aItemData); ScDPItemData::Type eType = aItemData.GetType(); bIsNumeric = eType == ScDPItemData::Value || ScDPItemData::GroupValue; diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx index 4087c42af6ba..59ed83780dae 100644 --- a/sc/source/core/data/dptabsrc.cxx +++ b/sc/source/core/data/dptabsrc.cxx @@ -2627,12 +2627,12 @@ const OUString* ScDPMember::GetLayoutName() const rtl::OUString ScDPMember::GetNameStr() const { - return GetItemData().GetString(); + return pSource->GetData()->GetFormattedString(GetItemData()); } ::rtl::OUString SAL_CALL ScDPMember::getName() throw(uno::RuntimeException) { - return GetItemData().GetString(); + return GetNameStr(); } void SAL_CALL ScDPMember::setName( const ::rtl::OUString& /* rNewName */ ) throw(uno::RuntimeException) @@ -2724,7 +2724,7 @@ const ScDPCache* ScDPSource::GetCache() const ScDPItemData& ScDPMember::GetItemData() const { - return *pSource->GetItemDataById( (SCCOL)nDim, mnDataId );//ms-cache-core + return *pSource->GetItemDataById(nDim, mnDataId); } const ScDPItemData* ScDPSource::GetItemDataById(long nDim, long nId) |