LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / sc / inc / dpgroup.hxx
blobf7dd09b0de2ffa38e7919b1858f3360af1a89f67
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 #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;
35 class ScDPGroupItem
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;
52 class ScDPGroupDimension
54 tools::Long nSourceDim;
55 tools::Long nGroupDim;
56 OUString aGroupName;
57 std::vector<ScDPGroupItem> aItems;
58 mutable std::vector<SCROW> maMemberEntries;
59 bool mbDateDimension;
60 public:
61 ScDPGroupDimension( tools::Long nSource, const OUString& rNewName );
62 ScDPGroupDimension( const ScDPGroupDimension& rOther );
63 ~ScDPGroupDimension();
65 ScDPGroupDimension& operator=( 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;}
87 class SC_DLLPUBLIC ScDPNumGroupDimension
89 mutable ScDPNumGroupInfo aGroupInfo; // settings
90 mutable std::vector<SCROW> maMemberEntries;
91 bool mbDateDimension;
93 public:
94 ScDPNumGroupDimension();
95 ScDPNumGroupDimension( const ScDPNumGroupInfo& rInfo );
96 ScDPNumGroupDimension( const ScDPNumGroupDimension& rOther );
97 ~ScDPNumGroupDimension();
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
114 class ScDPGroupTableData final : public ScDPTableData
116 std::shared_ptr<ScDPTableData> pSourceData;
117 sal_Int32 nSourceCount;
118 std::vector<ScDPGroupDimension>
119 aGroups;
120 std::unique_ptr<ScDPNumGroupDimension[]>
121 pNumGroups; // array[nSourceCount]
122 ScDocument* pDoc;
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(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;
175 #if DUMP_PIVOT_TABLE
176 virtual void Dump() const override;
177 #endif
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */