LibreOffice Module sc (master) 1
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at .
18 */
20#pragma once
22#include <memory>
23#include <unordered_set>
24#include <vector>
26#include "dptabdat.hxx"
27#include "scdllapi.h"
28#include "dpitemdata.hxx"
29#include "dpnumgroupinfo.hxx"
31class ScDocument;
33typedef ::std::vector<ScDPItemData> ScDPItemDataVec;
37 ScDPItemData aGroupName; // name of group item
38 ScDPItemDataVec aElements; // names of items in original dimension
41 ScDPGroupItem( const ScDPItemData& rName );
43 void AddElement( const ScDPItemData& rName );
45 const ScDPItemData& GetName() const { return aGroupName; }
46 bool HasElement( const ScDPItemData& rData ) const;
47 bool HasCommonElement( const ScDPGroupItem& rOther ) const;
56 OUString aGroupName;
57 std::vector<ScDPGroupItem> aItems;
58 mutable std::vector<SCROW> maMemberEntries;
61 ScDPGroupDimension( tools::Long nSource, OUString aNewName );
67 void AddItem( const ScDPGroupItem& rItem );
68 void SetGroupDim( tools::Long nDim ); // called from AddGroupDimension
71 tools::Long GetGroupDim() const { return nGroupDim; }
72 const OUString& GetName() const { return aGroupName; }
74 const std::vector< SCROW >& GetColumnEntries( const ScDPFilteredCache& rCacheTable ) const;
75 const ScDPGroupItem* GetGroupForData( const ScDPItemData& rData ) const; // rData = entry in original dim.
76 const ScDPGroupItem* GetGroupForName( const ScDPItemData& rName ) const; // rName = entry in group dim.
77 const ScDPGroupItem* GetGroupByIndex( size_t nIndex ) const;
79 void DisposeData();
81 size_t GetItemCount() const { return aItems.size(); }
83 void SetDateDimension();
84 bool IsDateDimension() const { return mbDateDimension;}
89 mutable ScDPNumGroupInfo aGroupInfo; // settings
90 mutable std::vector<SCROW> maMemberEntries;
99 ScDPNumGroupDimension& operator=( const ScDPNumGroupDimension& rOther );
101 const ScDPNumGroupInfo& GetInfo() const { return aGroupInfo; }
103 const std::vector<SCROW>& GetNumEntries(SCCOL nSourceDim, const ScDPCache* pCache) const;
105 void SetDateDimension();
107 void DisposeData();
109 bool IsDateDimension() const { return mbDateDimension;}
112// proxy implementation of ScDPTableData to add grouped items
116 std::shared_ptr<ScDPTableData> pSourceData;
117 sal_Int32 nSourceCount;
118 std::vector<ScDPGroupDimension>
120 std::unique_ptr<ScDPNumGroupDimension[]>
121 pNumGroups; // array[nSourceCount]
124 void FillGroupValues(std::vector<SCROW>& rItems, const std::vector<sal_Int32>& rDims);
125 virtual sal_Int32 GetSourceDim( sal_Int32 nDim ) override;
127 bool IsNumGroupDimension( tools::Long nDimension ) const;
128 void GetNumGroupInfo(tools::Long nDimension, ScDPNumGroupInfo& rInfo);
130 void ModifyFilterCriteria(::std::vector<ScDPFilteredCache::Criterion>& rCriteria);
133 // takes ownership of pSource
134 ScDPGroupTableData( const std::shared_ptr<ScDPTableData>& pSource, ScDocument* pDocument );
135 virtual ~ScDPGroupTableData() override;
137 const std::shared_ptr<ScDPTableData>& GetSourceTableData() const { return pSourceData;}
139 void AddGroupDimension( const ScDPGroupDimension& rGroup );
140 void SetNumGroupDimension( sal_Int32 nIndex, const ScDPNumGroupDimension& rGroup );
141 sal_Int32 GetDimensionIndex( std::u16string_view rName );
143 virtual sal_Int32 GetColumnCount() override;
144 virtual sal_Int32 GetMembersCount( sal_Int32 nDim ) override;
145 virtual const std::vector< SCROW >& GetColumnEntries( sal_Int32 nColumn ) override ;
146 virtual const ScDPItemData* GetMemberById( sal_Int32 nDim, sal_Int32 nId) override;
147 virtual sal_Int32 Compare( sal_Int32 nDim, sal_Int32 nDataId1, sal_Int32 nDataId2) override;
149 virtual OUString getDimensionName(sal_Int32 nColumn) override;
150 virtual bool getIsDataLayoutDimension(sal_Int32 nColumn) override;
151 virtual bool IsDateDimension(sal_Int32 nDim) override;
152 virtual sal_uInt32 GetNumberFormat(sal_Int32 nDim) override;
153 virtual void DisposeData() override;
154 virtual void SetEmptyFlags( bool bIgnoreEmptyRows, bool bRepeatIfEmpty ) override;
156 virtual bool IsRepeatIfEmpty() override;
158 virtual void CreateCacheTable() override;
159 virtual void FilterCacheTable(std::vector<ScDPFilteredCache::Criterion>&& rCriteria, std::unordered_set<sal_Int32>&& rDataDims) override;
160 virtual void GetDrillDownData(std::vector<ScDPFilteredCache::Criterion>&& rCriteria,
161 std::unordered_set<sal_Int32>&& rCatDims,
162 css::uno::Sequence< css::uno::Sequence< css::uno::Any > >& rData) override;
163 virtual void CalcResults(CalcInfo& rInfo, bool bAutoShow) override;
164 virtual const ScDPFilteredCache& GetCacheTable() const override;
165 virtual void ReloadCacheTable() override;
167 virtual bool IsBaseForGroup(sal_Int32 nDim) const override;
168 virtual sal_Int32 GetGroupBase(sal_Int32 nGroupDim) const override;
169 virtual bool IsNumOrDateGroup(sal_Int32 nDim) const override;
170 virtual bool IsInGroup( const ScDPItemData& rGroupData, sal_Int32 nGroupIndex,
171 const ScDPItemData& rBaseData, sal_Int32 nBaseIndex ) const override;
172 virtual bool HasCommonElement( const ScDPItemData& rFirstData, sal_Int32 nFirstIndex,
173 const ScDPItemData& rSecondData, sal_Int32 nSecondIndex ) const override;
176 virtual void Dump() const override;
180/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This class represents the cached data part of the datapilot cache table implementation.
Definition: dpcache.hxx:48
multi-item (group) filter.
This class is only a wrapper to the actual cache, to provide filtering on the raw data based on the q...
tools::Long GetSourceDim() const
Definition: dpgroup.hxx:70
ScDPGroupDimension & operator=(const ScDPGroupDimension &rOther)
Definition: dpgroup.cxx:356
ScDPGroupDimension(tools::Long nSource, OUString aNewName)
Definition: dpgroup.cxx:334
void SetDateDimension()
Definition: dpgroup.cxx:419
tools::Long nSourceDim
Definition: dpgroup.hxx:54
const ScDPGroupItem * GetGroupByIndex(size_t nIndex) const
Definition: dpgroup.cxx:406
bool IsDateDimension() const
Definition: dpgroup.hxx:84
tools::Long nGroupDim
Definition: dpgroup.hxx:55
const ScDPGroupItem * GetGroupForData(const ScDPItemData &rData) const
Definition: dpgroup.cxx:386
tools::Long GetGroupDim() const
Definition: dpgroup.hxx:71
const OUString & GetName() const
Definition: dpgroup.hxx:72
size_t GetItemCount() const
Definition: dpgroup.hxx:81
OUString aGroupName
Definition: dpgroup.hxx:56
const ScDPGroupItem * GetGroupForName(const ScDPItemData &rName) const
Definition: dpgroup.cxx:396
std::vector< SCROW > maMemberEntries
Definition: dpgroup.hxx:58
std::vector< ScDPGroupItem > aItems
Definition: dpgroup.hxx:57
const std::vector< SCROW > & GetColumnEntries(const ScDPFilteredCache &rCacheTable) const
Definition: dpgroup.cxx:376
void SetGroupDim(tools::Long nDim)
Definition: dpgroup.cxx:371
void AddItem(const ScDPGroupItem &rItem)
Definition: dpgroup.cxx:366
ScDPItemDataVec aElements
Definition: dpgroup.hxx:38
void AddElement(const ScDPItemData &rName)
Definition: dpgroup.cxx:311
ScDPItemData aGroupName
Definition: dpgroup.hxx:37
bool HasElement(const ScDPItemData &rData) const
Definition: dpgroup.cxx:316
void FillGroupFilter(ScDPFilteredCache::GroupFilter &rFilter) const
Definition: dpgroup.cxx:328
ScDPGroupItem(const ScDPItemData &rName)
Definition: dpgroup.cxx:306
const ScDPItemData & GetName() const
Definition: dpgroup.hxx:45
bool HasCommonElement(const ScDPGroupItem &rOther) const
Definition: dpgroup.cxx:322
virtual sal_Int32 GetSourceDim(sal_Int32 nDim) override
Definition: dpgroup.cxx:993
virtual const ScDPItemData * GetMemberById(sal_Int32 nDim, sal_Int32 nId) override
Definition: dpgroup.cxx:549
virtual sal_Int32 GetMembersCount(sal_Int32 nDim) override
Definition: dpgroup.cxx:521
virtual bool IsNumOrDateGroup(sal_Int32 nDim) const override
Definition: dpgroup.cxx:890
virtual bool HasCommonElement(const ScDPItemData &rFirstData, sal_Int32 nFirstIndex, const ScDPItemData &rSecondData, sal_Int32 nSecondIndex) const override
Definition: dpgroup.cxx:936
virtual void FilterCacheTable(std::vector< ScDPFilteredCache::Criterion > &&rCriteria, std::unordered_set< sal_Int32 > &&rDataDims) override
Definition: dpgroup.cxx:751
sal_Int32 GetDimensionIndex(std::u16string_view rName)
Definition: dpgroup.cxx:498
std::shared_ptr< ScDPTableData > pSourceData
Definition: dpgroup.hxx:116
virtual void CalcResults(CalcInfo &rInfo, bool bAutoShow) override
Definition: dpgroup.cxx:763
const std::shared_ptr< ScDPTableData > & GetSourceTableData() const
Definition: dpgroup.hxx:137
virtual void SetEmptyFlags(bool bIgnoreEmptyRows, bool bRepeatIfEmpty) override
Definition: dpgroup.cxx:610
virtual void DisposeData() override
Definition: dpgroup.cxx:599
virtual void CreateCacheTable() override
Definition: dpgroup.cxx:620
virtual bool IsDateDimension(sal_Int32 nDim) override
Definition: dpgroup.cxx:573
virtual sal_Int32 GetGroupBase(sal_Int32 nGroupDim) const override
Definition: dpgroup.cxx:880
virtual bool getIsDataLayoutDimension(sal_Int32 nColumn) override
Definition: dpgroup.cxx:567
sal_Int32 nSourceCount
Definition: dpgroup.hxx:117
void FillGroupValues(std::vector< SCROW > &rItems, const std::vector< sal_Int32 > &rDims)
Definition: dpgroup.cxx:804
virtual sal_uInt32 GetNumberFormat(sal_Int32 nDim) override
Definition: dpgroup.cxx:586
virtual bool IsRepeatIfEmpty() override
Definition: dpgroup.cxx:615
virtual bool IsBaseForGroup(sal_Int32 nDim) const override
Definition: dpgroup.cxx:874
void GetNumGroupInfo(tools::Long nDimension, ScDPNumGroupInfo &rInfo)
Definition: dpgroup.cxx:516
virtual void Dump() const override
bool IsNumGroupDimension(tools::Long nDimension) const
Definition: dpgroup.cxx:511
void SetNumGroupDimension(sal_Int32 nIndex, const ScDPNumGroupDimension &rGroup)
Definition: dpgroup.cxx:488
virtual const std::vector< SCROW > & GetColumnEntries(sal_Int32 nColumn) override
Definition: dpgroup.cxx:526
virtual const ScDPFilteredCache & GetCacheTable() const override
Definition: dpgroup.cxx:794
void AddGroupDimension(const ScDPGroupDimension &rGroup)
Definition: dpgroup.cxx:481
virtual ~ScDPGroupTableData() override
Definition: dpgroup.cxx:477
std::unique_ptr< ScDPNumGroupDimension[]> pNumGroups
Definition: dpgroup.hxx:121
ScDocument * pDoc
Definition: dpgroup.hxx:122
virtual bool IsInGroup(const ScDPItemData &rGroupData, sal_Int32 nGroupIndex, const ScDPItemData &rBaseData, sal_Int32 nBaseIndex) const override
Definition: dpgroup.cxx:908
virtual void GetDrillDownData(std::vector< ScDPFilteredCache::Criterion > &&rCriteria, std::unordered_set< sal_Int32 > &&rCatDims, css::uno::Sequence< css::uno::Sequence< css::uno::Any > > &rData) override
Definition: dpgroup.cxx:757
void ModifyFilterCriteria(::std::vector< ScDPFilteredCache::Criterion > &rCriteria)
Definition: dpgroup.cxx:641
virtual void ReloadCacheTable() override
Definition: dpgroup.cxx:799
ScDPGroupTableData(const std::shared_ptr< ScDPTableData > &pSource, ScDocument *pDocument)
Definition: dpgroup.cxx:465
std::vector< ScDPGroupDimension > aGroups
Definition: dpgroup.hxx:119
virtual OUString getDimensionName(sal_Int32 nColumn) override
Definition: dpgroup.cxx:554
virtual sal_Int32 GetColumnCount() override
use (new) typed collection instead of ScStrCollection or separate Str and ValueCollection
Definition: dpgroup.cxx:506
virtual sal_Int32 Compare(sal_Int32 nDim, sal_Int32 nDataId1, sal_Int32 nDataId2) override
Definition: dpgroup.cxx:1005
When assigning a string value, you can also assign an interned string whose life-cycle is managed by ...
Definition: dpitemdata.hxx:29
std::vector< SCROW > maMemberEntries
Definition: dpgroup.hxx:90
ScDPNumGroupInfo aGroupInfo
Definition: dpgroup.hxx:89
bool IsDateDimension() const
Definition: dpgroup.hxx:109
const ScDPNumGroupInfo & GetInfo() const
Definition: dpgroup.hxx:101
Base class that abstracts different data source types of a datapilot table.
Definition: dptabdat.hxx:57
::std::vector< ScDPItemData > ScDPItemDataVec
Definition: dpgroup.hxx:31
long Long
Definition: scdllapi.h:27
sal_Int16 SCCOL
Definition: types.hxx:21