From 2d5c1a3f6de583629c29fc0eeea630c8f8a0eb89 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Fri, 9 Mar 2012 11:08:16 -0500 Subject: Even more cleanup and fixing. --- sc/inc/dptabdat.hxx | 4 +-- sc/inc/dptablecache.hxx | 3 --- sc/source/core/data/dptablecache.cxx | 50 ------------------------------------ sc/source/core/data/dptabsrc.cxx | 33 +++++++++++++++++++----- 4 files changed, 29 insertions(+), 61 deletions(-) (limited to 'sc') diff --git a/sc/inc/dptabdat.hxx b/sc/inc/dptabdat.hxx index 8cd3c474b920..de323e6b41e2 100644 --- a/sc/inc/dptabdat.hxx +++ b/sc/inc/dptabdat.hxx @@ -60,8 +60,8 @@ namespace com { namespace sun { namespace star { namespace sheet { #define SC_DAPI_LEVEL_QUARTER 1 #define SC_DAPI_LEVEL_MONTH 2 #define SC_DAPI_LEVEL_DAY 3 -#define SC_DAPI_LEVEL_WEEK 1 -#define SC_DAPI_LEVEL_WEEKDAY 2 +#define SC_DAPI_LEVEL_WEEK 4 +#define SC_DAPI_LEVEL_WEEKDAY 5 // diff --git a/sc/inc/dptablecache.hxx b/sc/inc/dptablecache.hxx index 8a322843dd92..62af3987d9bb 100644 --- a/sc/inc/dptablecache.hxx +++ b/sc/inc/dptablecache.hxx @@ -128,7 +128,6 @@ public: void RemoveReference(ScDPObject* pObj) const; const ObjectSetType& GetAllReferences() const; - SCROW GetIdByItemData(long nDim, const rtl::OUString& sItemData) const; SCROW GetIdByItemData(long nDim, const ScDPItemData& rItem) const; rtl::OUString GetFormattedString(long nDim, const ScDPItemData& rItem) const; long AppendGroupField(); @@ -138,8 +137,6 @@ public: void GetGroupDimMemberIds(long nDim, std::vector& rIds) const; void ClearGroupFields(); - SCROW GetAdditionalItemID( const ScDPItemData& rData ) const; - SCCOL GetDimensionIndex(const rtl::OUString& sName) const; sal_uLong GetNumberFormat( long nDim ) const; bool IsDateDimension( long nDim ) const ; diff --git a/sc/source/core/data/dptablecache.cxx b/sc/source/core/data/dptablecache.cxx index 7109b911d40f..ff12648e6d1a 100644 --- a/sc/source/core/data/dptablecache.cxx +++ b/sc/source/core/data/dptablecache.cxx @@ -872,49 +872,6 @@ const ScDPCache::ObjectSetType& ScDPCache::GetAllReferences() const return maRefObjects; } -SCROW ScDPCache::GetIdByItemData(long nDim, const rtl::OUString& sItemData) const -{ - if (nDim < 0) - return -1; - - if (nDim < mnColumnCount) - { - // source field. - const DataListType& rItems = maFields[nDim].maItems; - for (size_t i = 0, n = rItems.size(); i < n; ++i) - { - if (rItems[i].GetString() == sItemData) - return i; - } - - if (!maFields[nDim].mpGroup) - return -1; - - // grouped source field. - const DataListType& rGI = maFields[nDim].mpGroup->maItems; - for (size_t i = 0, n = rGI.size(); i < n; ++i) - { - if (rGI[i].GetString() == sItemData) - return rItems.size() + i; - } - return -1; - } - - // group field. - nDim -= mnColumnCount; - if (static_cast(nDim) < maGroupFields.size()) - { - const DataListType& rGI = maGroupFields[nDim].maItems; - for (size_t i = 0, n = rGI.size(); i < n; ++i) - { - if (rGI[i].GetString() == sItemData) - return i; - } - } - - return -1; -} - SCROW ScDPCache::GetIdByItemData(long nDim, const ScDPItemData& rItem) const { if (nDim < 0) @@ -1125,13 +1082,6 @@ void ScDPCache::ClearGroupFields() std::for_each(maFields.begin(), maFields.end(), ClearGroupItems()); } -SCROW ScDPCache::GetAdditionalItemID(const ScDPItemData&) const -{ - fprintf(stdout, "ScDPCache::GetAdditionalItemID: FIXME\n"); - return -1; -} - - SCROW ScDPCache::GetOrder(long nDim, SCROW nIndex) const { OSL_ENSURE( IsValid(), " IsValid() == false " ); diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx index 3f2de93b4180..95140468e2ec 100644 --- a/sc/source/core/data/dptabsrc.cxx +++ b/sc/source/core/data/dptabsrc.cxx @@ -66,6 +66,7 @@ #include #include #include +#include #include #include @@ -2490,7 +2491,8 @@ ScDPMember* ScDPMembers::getByIndex(long nIndex) const } else if ( nHier != SC_DAPI_HIERARCHY_FLAT && pSource->IsDateDimension( nSrcDim ) ) { - long nVal = 0; + sal_Int32 nGroupBy = 0; + sal_Int32 nVal = 0; rtl::OUString aName; if ( nLev == SC_DAPI_LEVEL_YEAR ) // YEAR is in both hierarchies @@ -2521,14 +2523,33 @@ ScDPMember* ScDPMembers::getByIndex(long nIndex) const else nVal = nIndex + 1; // Quarter, Day, Week are 1-based + switch (nLev) + { + case SC_DAPI_LEVEL_YEAR: + nGroupBy = sheet::DataPilotFieldGroupBy::YEARS; + break; + case SC_DAPI_LEVEL_QUARTER: + case SC_DAPI_LEVEL_WEEK: + nGroupBy = sheet::DataPilotFieldGroupBy::QUARTERS; + break; + case SC_DAPI_LEVEL_MONTH: + case SC_DAPI_LEVEL_WEEKDAY: + nGroupBy = sheet::DataPilotFieldGroupBy::MONTHS; + break; + case SC_DAPI_LEVEL_DAY: + nGroupBy = sheet::DataPilotFieldGroupBy::DAYS; + break; + nGroupBy = sheet::DataPilotFieldGroupBy::YEARS; + break; + default: + ; + } if (aName.isEmpty()) aName = rtl::OUString::valueOf(nVal); - // TODO: This needs fixing. - fprintf(stdout, "ScDPMembers::getByIndex: FIXME\n"); - ScDPItemData aData(nVal); - pNew = new ScDPMember( - pSource, nDim, nHier, nLev, pSource->GetCache()->GetAdditionalItemID(aData)); + ScDPItemData aData(nGroupBy, nVal); + SCROW nId = pSource->GetCache()->GetIdByItemData(nDim, aData); + pNew = new ScDPMember(pSource, nDim, nHier, nLev, nId); } else { -- cgit