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 -*- */
2 /*
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"
31 class ScDocument;
33 typedef ::std::vector<ScDPItemData> ScDPItemDataVec;
36 {
37  ScDPItemData aGroupName; // name of group item
38  ScDPItemDataVec aElements; // names of items in original dimension
40 public:
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;
49  void FillGroupFilter( ScDPFilteredCache::GroupFilter& rFilter ) const;
50 };
53 {
56  OUString aGroupName;
57  std::vector<ScDPGroupItem> aItems;
58  mutable std::vector<SCROW> maMemberEntries;
60 public:
61  ScDPGroupDimension( tools::Long nSource, const OUString& rNewName );
62  ScDPGroupDimension( const ScDPGroupDimension& rOther );
67  void AddItem( const ScDPGroupItem& rItem );
68  void SetGroupDim( tools::Long nDim ); // called from AddGroupDimension
70  tools::Long GetSourceDim() const { return nSourceDim; }
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;}
85 };
88 {
89  mutable ScDPNumGroupInfo aGroupInfo; // settings
90  mutable std::vector<SCROW> maMemberEntries;
93 public:
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;}
110 };
112 // proxy implementation of ScDPTableData to add grouped items
114 class ScDPGroupTableData final : public ScDPTableData
115 {
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);
132 public:
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(const std::vector<ScDPFilteredCache::Criterion>& rCriteria, const std::unordered_set<sal_Int32>& rDataDims) override;
160  virtual void GetDrillDownData(const std::vector<ScDPFilteredCache::Criterion>& rCriteria,
161  const 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;
177 #endif
178 };
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void GetNumGroupInfo(tools::Long nDimension, ScDPNumGroupInfo &rInfo)
Definition: dpgroup.cxx:514
void FillGroupValues(std::vector< SCROW > &rItems, const std::vector< sal_Int32 > &rDims)
Definition: dpgroup.cxx:804
virtual void FilterCacheTable(const std::vector< ScDPFilteredCache::Criterion > &rCriteria, const std::unordered_set< sal_Int32 > &rDataDims) override
Definition: dpgroup.cxx:749
virtual void CalcResults(CalcInfo &rInfo, bool bAutoShow) override
Definition: dpgroup.cxx:763
OUString aGroupName
Definition: dpgroup.hxx:56
const ScDPNumGroupInfo & GetInfo() const
Definition: dpgroup.hxx:101
void AddGroupDimension(const ScDPGroupDimension &rGroup)
Definition: dpgroup.cxx:479
const std::vector< SCROW > & GetColumnEntries(const ScDPFilteredCache &rCacheTable) const
Definition: dpgroup.cxx:374
virtual bool IsNumOrDateGroup(sal_Int32 nDim) const override
Definition: dpgroup.cxx:890
ScDPItemData aGroupName
Definition: dpgroup.hxx:37
ScDPGroupTableData(const std::shared_ptr< ScDPTableData > &pSource, ScDocument *pDocument)
Definition: dpgroup.cxx:463
long Long
bool HasElement(const ScDPItemData &rData) const
Definition: dpgroup.cxx:314
std::vector< ScDPGroupDimension > aGroups
Definition: dpgroup.hxx:119
std::vector< ScDPGroupItem > aItems
Definition: dpgroup.hxx:57
virtual ~ScDPGroupTableData() override
Definition: dpgroup.cxx:475
This class represents the cached data part of the datapilot cache table implementation.
Definition: dpcache.hxx:47
std::unique_ptr< ScDPNumGroupDimension[]> pNumGroups
Definition: dpgroup.hxx:121
virtual void Dump() const override
bool IsNumGroupDimension(tools::Long nDimension) const
Definition: dpgroup.cxx:509
tools::Long GetGroupDim() const
Definition: dpgroup.hxx:71
void SetNumGroupDimension(sal_Int32 nIndex, const ScDPNumGroupDimension &rGroup)
Definition: dpgroup.cxx:486
virtual sal_Int32 GetSourceDim(sal_Int32 nDim) override
Definition: dpgroup.cxx:993
virtual void GetDrillDownData(const std::vector< ScDPFilteredCache::Criterion > &rCriteria, const std::unordered_set< sal_Int32 > &rCatDims, css::uno::Sequence< css::uno::Sequence< css::uno::Any > > &rData) override
Definition: dpgroup.cxx:756
tools::Long nSourceDim
Definition: dpgroup.hxx:54
multi-item (group) filter.
ScDocument * pDoc
Definition: dpgroup.hxx:122
::std::vector< ScDPItemData > ScDPItemDataVec
Definition: dpgroup.hxx:31
virtual bool IsBaseForGroup(sal_Int32 nDim) const override
Definition: dpgroup.cxx:874
void SetDateDimension()
Definition: dpgroup.cxx:417
bool IsDateDimension() const
Definition: dpgroup.hxx:84
virtual bool HasCommonElement(const ScDPItemData &rFirstData, sal_Int32 nFirstIndex, const ScDPItemData &rSecondData, sal_Int32 nSecondIndex) const override
Definition: dpgroup.cxx:936
virtual const std::vector< SCROW > & GetColumnEntries(sal_Int32 nColumn) override
Definition: dpgroup.cxx:524
When assigning a string value, you can also assign an interned string whose life-cycle is managed by ...
Definition: dpitemdata.hxx:28
void AddElement(const ScDPItemData &rName)
Definition: dpgroup.cxx:309
const ScDPGroupItem * GetGroupByIndex(size_t nIndex) const
Definition: dpgroup.cxx:404
ScDPGroupItem(const ScDPItemData &rName)
Definition: dpgroup.cxx:304
virtual sal_Int32 Compare(sal_Int32 nDim, sal_Int32 nDataId1, sal_Int32 nDataId2) override
Definition: dpgroup.cxx:1005
virtual bool IsDateDimension(sal_Int32 nDim) override
Definition: dpgroup.cxx:571
sal_Int16 SCCOL
Definition: types.hxx:21
virtual sal_Int32 GetGroupBase(sal_Int32 nGroupDim) const override
Definition: dpgroup.cxx:880
tools::Long GetSourceDim() const
Definition: dpgroup.hxx:70
virtual void CreateCacheTable() override
Definition: dpgroup.cxx:618
virtual bool IsInGroup(const ScDPItemData &rGroupData, sal_Int32 nGroupIndex, const ScDPItemData &rBaseData, sal_Int32 nBaseIndex) const override
Definition: dpgroup.cxx:908
std::vector< SCROW > maMemberEntries
Definition: dpgroup.hxx:58
void FillGroupFilter(ScDPFilteredCache::GroupFilter &rFilter) const
Definition: dpgroup.cxx:326
sal_Int32 GetDimensionIndex(std::u16string_view rName)
Definition: dpgroup.cxx:496
virtual void ReloadCacheTable() override
Definition: dpgroup.cxx:799
virtual sal_Int32 GetMembersCount(sal_Int32 nDim) override
Definition: dpgroup.cxx:519
ScDPGroupDimension(tools::Long nSource, const OUString &rNewName)
Definition: dpgroup.cxx:332
virtual void DisposeData() override
Definition: dpgroup.cxx:597
virtual sal_Int32 GetColumnCount() override
use (new) typed collection instead of ScStrCollection or separate Str and ValueCollection ...
Definition: dpgroup.cxx:504
virtual sal_uInt32 GetNumberFormat(sal_Int32 nDim) override
Definition: dpgroup.cxx:584
const std::shared_ptr< ScDPTableData > & GetSourceTableData() const
Definition: dpgroup.hxx:137
std::vector< SCROW > maMemberEntries
Definition: dpgroup.hxx:90
void AddItem(const ScDPGroupItem &rItem)
Definition: dpgroup.cxx:364
const OUString & GetName() const
Definition: dpgroup.hxx:72
std::shared_ptr< ScDPTableData > pSourceData
Definition: dpgroup.hxx:116
virtual const ScDPItemData * GetMemberById(sal_Int32 nDim, sal_Int32 nId) override
Definition: dpgroup.cxx:547
Base class that abstracts different data source types of a datapilot table.
Definition: dptabdat.hxx:56
tools::Long nGroupDim
Definition: dpgroup.hxx:55
virtual void SetEmptyFlags(bool bIgnoreEmptyRows, bool bRepeatIfEmpty) override
Definition: dpgroup.cxx:608
bool HasCommonElement(const ScDPGroupItem &rOther) const
Definition: dpgroup.cxx:320
ScDPGroupDimension & operator=(const ScDPGroupDimension &rOther)
Definition: dpgroup.cxx:354
ScDPItemDataVec aElements
Definition: dpgroup.hxx:38
void ModifyFilterCriteria(::std::vector< ScDPFilteredCache::Criterion > &rCriteria)
Definition: dpgroup.cxx:639
ScDPNumGroupInfo aGroupInfo
Definition: dpgroup.hxx:89
const ScDPGroupItem * GetGroupForData(const ScDPItemData &rData) const
Definition: dpgroup.cxx:384
void SetGroupDim(tools::Long nDim)
Definition: dpgroup.cxx:369
virtual bool getIsDataLayoutDimension(sal_Int32 nColumn) override
Definition: dpgroup.cxx:565
This class is only a wrapper to the actual cache, to provide filtering on the raw data based on the q...
virtual const ScDPFilteredCache & GetCacheTable() const override
Definition: dpgroup.cxx:794
const ScDPGroupItem * GetGroupForName(const ScDPItemData &rName) const
Definition: dpgroup.cxx:394
virtual OUString getDimensionName(sal_Int32 nColumn) override
Definition: dpgroup.cxx:552
size_t GetItemCount() const
Definition: dpgroup.hxx:81
Definition: scdllapi.h:27
sal_Int32 nSourceCount
Definition: dpgroup.hxx:117
const ScDPItemData & GetName() const
Definition: dpgroup.hxx:45
bool IsDateDimension() const
Definition: dpgroup.hxx:109
virtual bool IsRepeatIfEmpty() override
Definition: dpgroup.cxx:613