diff options
author | Release Engineers <releng@openoffice.org> | 2008-11-27 15:23:33 +0000 |
---|---|---|
committer | Release Engineers <releng@openoffice.org> | 2008-11-27 15:23:33 +0000 |
commit | 5beec3891e1328a30b6c1fa33c2227ce8381855b (patch) | |
tree | a228838850e863e7659656b49d6da883f3bc0726 /sc/source/core/data/dptabres.cxx | |
parent | 811e7a83cbca79b0779ac2f77fc74b1f99c48439 (diff) |
CWS-TOOLING: integrate CWS koheidatapilot02
2008-11-24 15:34:25 +0100 kohei r264231 : modified ScViewData::IsMultiMarked() to treat simple-filtered areas as simple-marked areas,
for backword compatibility. Simple-filtered areas are not multi-marked areas.
2008-11-07 20:38:51 +0100 kohei r263485 : more unused methods in the header without definitions.
2008-11-07 20:26:25 +0100 kohei r263484 : removed more unused methods.
2008-11-07 19:40:39 +0100 kohei r263481 : removed unused methods based on Caolan's callcatcher output on m35.
2008-11-06 19:32:22 +0100 kohei r263405 : CWS-TOOLING: rebase CWS koheidatapilot02 to trunk@263288 (milestone: DEV300:m35)
2008-10-06 15:18:57 +0200 kohei r262062 : #i94619# allow XDataPilotTable interface to be queried again. Patch submitted by
Noel Power.
2008-10-01 21:49:39 +0200 kohei r262020 : #i90402# don't insert drill-down sheet when the document is in read-only mode.
2008-10-01 03:03:19 +0200 kohei r261982 : #i93918# exclude hidden items and items that are excluded due to
ranks (i.e. top X items).
#i93998# reduce memory consumption of datapilot cache tables by
pooling cache table cell data & use null pointers to represent
empty cells.
2008-09-30 23:35:14 +0200 kohei r261981 : #i92378# keep the layout dialog open when the destination range is not empty
and the user has decided to cancel data pilot creation.
2008-09-30 23:14:55 +0200 kohei r261980 : #i94281# fixed a regression where the data pilot layout dialog fails to
appear on a filtered cell range.
Diffstat (limited to 'sc/source/core/data/dptabres.cxx')
-rw-r--r-- | sc/source/core/data/dptabres.cxx | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx index 0a52f12c97c3..398d4d1c7e01 100644 --- a/sc/source/core/data/dptabres.cxx +++ b/sc/source/core/data/dptabres.cxx @@ -51,6 +51,7 @@ #include <math.h> #include <float.h> //! Test !!! #include <algorithm> +#include <hash_map> #include <com/sun/star/sheet/DataResultFlags.hpp> #include <com/sun/star/sheet/MemberResultFlags.hpp> @@ -59,9 +60,13 @@ #include <com/sun/star/sheet/DataPilotFieldReferenceItemType.hpp> #include <com/sun/star/sheet/DataPilotFieldShowItemsMode.hpp> #include <com/sun/star/sheet/DataPilotFieldSortMode.hpp> +#include <com/sun/star/sheet/DataPilotFieldFilter.hpp> using namespace com::sun::star; using ::std::vector; +using ::std::pair; +using ::std::hash_map; +using ::com::sun::star::uno::Sequence; // ----------------------------------------------------------------------- @@ -1577,6 +1582,12 @@ ScDPAggData* ScDPResultMember::GetColTotal( long nMeasure ) const return lcl_GetChildTotal( const_cast<ScDPAggData*>(&aColTotal), nMeasure ); } +void ScDPResultMember::FillVisibilityData(ScDPResultVisibilityData& rData) const +{ + if (pChildDimension) + pChildDimension->FillVisibilityData(rData); +} + // ----------------------------------------------------------------------- ScDPDataMember::ScDPDataMember( const ScDPResultData* pData, const ScDPResultMember* pRes ) : @@ -3231,6 +3242,26 @@ ScDPResultDimension* ScDPResultDimension::GetFirstChildDimension() const return NULL; } +void ScDPResultDimension::FillVisibilityData(ScDPResultVisibilityData& rData) const +{ + if (IsDataLayout()) + return; + + MemberArray::const_iterator itr = maMemberArray.begin(), itrEnd = maMemberArray.end(); + + for (;itr != itrEnd; ++itr) + { + ScDPResultMember* pMember = *itr; + if (pMember->IsValid()) + { + ScDPItemData aItem; + pMember->FillItemData(aItem); + rData.addVisibleMember(GetName(), aItem); + pMember->FillVisibilityData(rData); + } + } +} + // ----------------------------------------------------------------------- ScDPDataDimension::ScDPDataDimension( const ScDPResultData* pData ) : @@ -3559,3 +3590,88 @@ ScDPDataMember* ScDPDataDimension::GetMember(long n) const return aMembers[(USHORT)n]; } +// ---------------------------------------------------------------------------- + +ScDPResultVisibilityData::ScDPResultVisibilityData( + ScSimpleSharedString& rSharedString, ScDPSource* pSource) : + mrSharedString(rSharedString), + mpSource(pSource) +{ +} + +ScDPResultVisibilityData::~ScDPResultVisibilityData() +{ +} + +void ScDPResultVisibilityData::addVisibleMember(const String& rDimName, const ScDPItemData& rMemberItem) +{ + DimMemberType::iterator itr = maDimensions.find(rDimName); + if (itr == maDimensions.end()) + { + pair<DimMemberType::iterator, bool> r = maDimensions.insert( + DimMemberType::value_type(rDimName, VisibleMemberType())); + + if (!r.second) + // insertion failed. + return; + + itr = r.first; + } + VisibleMemberType& rMem = itr->second; + VisibleMemberType::iterator itrMem = rMem.find(rMemberItem); + if (itrMem == rMem.end()) + rMem.insert(rMemberItem); +} + +void ScDPResultVisibilityData::fillFieldFilters(vector<ScDPCacheTable::Criterion>& rFilters) const +{ + typedef hash_map<String, long, ScStringHashCode> FieldNameMapType; + FieldNameMapType aFieldNames; + ScDPTableData* pData = mpSource->GetData(); + long nColumnCount = pData->GetColumnCount(); + for (long i = 0; i < nColumnCount; ++i) + { + aFieldNames.insert( + FieldNameMapType::value_type(pData->getDimensionName(i), i)); + } + + const ScDPDimensions* pDims = mpSource->GetDimensionsObject(); + for (DimMemberType::const_iterator itr = maDimensions.begin(), itrEnd = maDimensions.end(); + itr != itrEnd; ++itr) + { + const String& rDimName = itr->first; + ScDPCacheTable::Criterion aCri; + FieldNameMapType::const_iterator itrField = aFieldNames.find(rDimName); + if (itrField == aFieldNames.end()) + // This should never happen! + continue; + + long nDimIndex = itrField->second; + aCri.mnFieldIndex = static_cast<sal_Int32>(nDimIndex); + aCri.mpFilter.reset(new ScDPCacheTable::GroupFilter(mrSharedString)); + ScDPCacheTable::GroupFilter* pGrpFilter = + static_cast<ScDPCacheTable::GroupFilter*>(aCri.mpFilter.get()); + + const VisibleMemberType& rMem = itr->second; + for (VisibleMemberType::const_iterator itrMem = rMem.begin(), itrMemEnd = rMem.end(); + itrMem != itrMemEnd; ++itrMem) + { + const ScDPItemData& rMemItem = *itrMem; + pGrpFilter->addMatchItem(rMemItem.aString, rMemItem.fValue, rMemItem.bHasValue); + } + + ScDPDimension* pDim = pDims->getByIndex(nDimIndex); + ScDPMembers* pMembers = pDim->GetHierarchiesObject()->getByIndex(0)-> + GetLevelsObject()->getByIndex(0)->GetMembersObject(); + if (pGrpFilter->getMatchItemCount() < static_cast<size_t>(pMembers->getCount())) + rFilters.push_back(aCri); + } +} + +size_t ScDPResultVisibilityData::MemberHash::operator() (const ScDPItemData& r) const +{ + if (r.bHasValue) + return static_cast<size_t>(::rtl::math::approxFloor(r.fValue)); + else + return rtl_ustr_hashCode_WithLength(r.aString.GetBuffer(), r.aString.Len()); +} |