nss: upgrade to release 3.73
[LibreOffice.git] / sc / inc / dpgroup.hxx
blobeaf560437b8da4d14f4bd29e19a1749c43fc9a25
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
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 http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SC_INC_DPGROUP_HXX
21 #define INCLUDED_SC_INC_DPGROUP_HXX
23 #include <memory>
24 #include <unordered_set>
25 #include <vector>
27 #include "dptabdat.hxx"
28 #include "scdllapi.h"
29 #include "dpitemdata.hxx"
30 #include "dpnumgroupinfo.hxx"
32 class ScDocument;
34 typedef ::std::vector<ScDPItemData> ScDPItemDataVec;
36 class ScDPGroupItem
38 ScDPItemData aGroupName; // name of group item
39 ScDPItemDataVec aElements; // names of items in original dimension
41 public:
42 ScDPGroupItem( const ScDPItemData& rName );
44 void AddElement( const ScDPItemData& rName );
46 const ScDPItemData& GetName() const { return aGroupName; }
47 bool HasElement( const ScDPItemData& rData ) const;
48 bool HasCommonElement( const ScDPGroupItem& rOther ) const;
50 void FillGroupFilter( ScDPFilteredCache::GroupFilter& rFilter ) const;
53 class ScDPGroupDimension
55 tools::Long nSourceDim;
56 tools::Long nGroupDim;
57 OUString aGroupName;
58 std::vector<ScDPGroupItem> aItems;
59 mutable std::vector<SCROW> maMemberEntries;
60 bool mbDateDimension;
61 public:
62 ScDPGroupDimension( tools::Long nSource, const OUString& rNewName );
63 ScDPGroupDimension( const ScDPGroupDimension& rOther );
64 ~ScDPGroupDimension();
66 ScDPGroupDimension& operator=( const ScDPGroupDimension& rOther );
68 void AddItem( const ScDPGroupItem& rItem );
69 void SetGroupDim( tools::Long nDim ); // called from AddGroupDimension
71 tools::Long GetSourceDim() const { return nSourceDim; }
72 tools::Long GetGroupDim() const { return nGroupDim; }
73 const OUString& GetName() const { return aGroupName; }
75 const std::vector< SCROW >& GetColumnEntries( const ScDPFilteredCache& rCacheTable ) const;
76 const ScDPGroupItem* GetGroupForData( const ScDPItemData& rData ) const; // rData = entry in original dim.
77 const ScDPGroupItem* GetGroupForName( const ScDPItemData& rName ) const; // rName = entry in group dim.
78 const ScDPGroupItem* GetGroupByIndex( size_t nIndex ) const;
80 void DisposeData();
82 size_t GetItemCount() const { return aItems.size(); }
84 void SetDateDimension();
85 bool IsDateDimension() const { return mbDateDimension;}
88 class SC_DLLPUBLIC ScDPNumGroupDimension
90 mutable ScDPNumGroupInfo aGroupInfo; // settings
91 mutable std::vector<SCROW> maMemberEntries;
92 bool mbDateDimension;
94 public:
95 ScDPNumGroupDimension();
96 ScDPNumGroupDimension( const ScDPNumGroupInfo& rInfo );
97 ScDPNumGroupDimension( const ScDPNumGroupDimension& rOther );
98 ~ScDPNumGroupDimension();
100 ScDPNumGroupDimension& operator=( const ScDPNumGroupDimension& rOther );
102 const ScDPNumGroupInfo& GetInfo() const { return aGroupInfo; }
104 const std::vector<SCROW>& GetNumEntries(SCCOL nSourceDim, const ScDPCache* pCache) const;
106 void SetDateDimension();
108 void DisposeData();
110 bool IsDateDimension() const { return mbDateDimension;}
113 // proxy implementation of ScDPTableData to add grouped items
115 class ScDPGroupTableData final : public ScDPTableData
117 std::shared_ptr<ScDPTableData> pSourceData;
118 sal_Int32 nSourceCount;
119 std::vector<ScDPGroupDimension>
120 aGroups;
121 std::unique_ptr<ScDPNumGroupDimension[]>
122 pNumGroups; // array[nSourceCount]
123 ScDocument* pDoc;
125 void FillGroupValues(std::vector<SCROW>& rItems, const std::vector<sal_Int32>& rDims);
126 virtual sal_Int32 GetSourceDim( sal_Int32 nDim ) override;
128 bool IsNumGroupDimension( tools::Long nDimension ) const;
129 void GetNumGroupInfo(tools::Long nDimension, ScDPNumGroupInfo& rInfo);
131 void ModifyFilterCriteria(::std::vector<ScDPFilteredCache::Criterion>& rCriteria);
133 public:
134 // takes ownership of pSource
135 ScDPGroupTableData( const std::shared_ptr<ScDPTableData>& pSource, ScDocument* pDocument );
136 virtual ~ScDPGroupTableData() override;
138 const std::shared_ptr<ScDPTableData>& GetSourceTableData() const { return pSourceData;}
140 void AddGroupDimension( const ScDPGroupDimension& rGroup );
141 void SetNumGroupDimension( sal_Int32 nIndex, const ScDPNumGroupDimension& rGroup );
142 sal_Int32 GetDimensionIndex( const OUString& rName );
144 virtual sal_Int32 GetColumnCount() override;
145 virtual sal_Int32 GetMembersCount( sal_Int32 nDim ) override;
146 virtual const std::vector< SCROW >& GetColumnEntries( sal_Int32 nColumn ) override ;
147 virtual const ScDPItemData* GetMemberById( sal_Int32 nDim, sal_Int32 nId) override;
148 virtual sal_Int32 Compare( sal_Int32 nDim, sal_Int32 nDataId1, sal_Int32 nDataId2) override;
150 virtual OUString getDimensionName(sal_Int32 nColumn) override;
151 virtual bool getIsDataLayoutDimension(sal_Int32 nColumn) override;
152 virtual bool IsDateDimension(sal_Int32 nDim) override;
153 virtual sal_uInt32 GetNumberFormat(sal_Int32 nDim) override;
154 virtual void DisposeData() override;
155 virtual void SetEmptyFlags( bool bIgnoreEmptyRows, bool bRepeatIfEmpty ) override;
157 virtual bool IsRepeatIfEmpty() override;
159 virtual void CreateCacheTable() override;
160 virtual void FilterCacheTable(const std::vector<ScDPFilteredCache::Criterion>& rCriteria, const std::unordered_set<sal_Int32>& rDataDims) override;
161 virtual void GetDrillDownData(const std::vector<ScDPFilteredCache::Criterion>& rCriteria,
162 const std::unordered_set<sal_Int32>& rCatDims,
163 css::uno::Sequence< css::uno::Sequence< css::uno::Any > >& rData) override;
164 virtual void CalcResults(CalcInfo& rInfo, bool bAutoShow) override;
165 virtual const ScDPFilteredCache& GetCacheTable() const override;
166 virtual void ReloadCacheTable() override;
168 virtual bool IsBaseForGroup(sal_Int32 nDim) const override;
169 virtual sal_Int32 GetGroupBase(sal_Int32 nGroupDim) const override;
170 virtual bool IsNumOrDateGroup(sal_Int32 nDim) const override;
171 virtual bool IsInGroup( const ScDPItemData& rGroupData, sal_Int32 nGroupIndex,
172 const ScDPItemData& rBaseData, sal_Int32 nBaseIndex ) const override;
173 virtual bool HasCommonElement( const ScDPItemData& rFirstData, sal_Int32 nFirstIndex,
174 const ScDPItemData& rSecondData, sal_Int32 nSecondIndex ) const override;
176 #if DUMP_PIVOT_TABLE
177 virtual void Dump() const override;
178 #endif
181 #endif
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */