LibreOffice Module sc (master)  1
dpdimsave.hxx
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 http://mozilla.org/MPL/2.0/.
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 http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_SC_INC_DPDIMSAVE_HXX
21 #define INCLUDED_SC_INC_DPDIMSAVE_HXX
22 
23 #include <tools/long.hxx>
24 
25 #include <vector>
26 #include <map>
27 #include <string_view>
28 
29 #include "dpitemdata.hxx"
30 #include "dpnumgroupinfo.hxx"
31 #include "scdllapi.h"
32 #include "dptypes.hxx"
33 
34 class ScDPGroupTableData;
35 class ScDPGroupDimension;
36 class ScDPObject;
37 class ScDPCache;
38 class SvNumberFormatter;
39 
41 
48 {
49  OUString aGroupName;
50  std::vector<OUString> aElements;
51  mutable std::vector<ScDPItemData> maItems;
52 
53 public:
54  ScDPSaveGroupItem( const OUString& rName );
56 
57  ScDPSaveGroupItem(ScDPSaveGroupItem const &) = default;
59  ScDPSaveGroupItem & operator =(ScDPSaveGroupItem const &) = default;
60  ScDPSaveGroupItem & operator =(ScDPSaveGroupItem &&) = default;
61 
62  void AddToData(ScDPGroupDimension& rDataDim) const;
63 
64  void AddElement( const OUString& rName );
65  void AddElementsFromGroup( const ScDPSaveGroupItem& rGroup );
66  const OUString& GetGroupName() const { return aGroupName; }
67 
69  bool RemoveElement( const OUString& rName );
70 
71  bool IsEmpty() const;
72  size_t GetElementCount() const;
73  const OUString* GetElementByIndex(size_t nIndex) const;
74 
75  void Rename( const OUString& rNewName );
76 
79  void RemoveElementsFromGroups( ScDPSaveGroupDimension& rDimension ) const;
80 
81  void ConvertElementsToItems(SvNumberFormatter* pFormatter) const;
82  bool HasInGroup(const ScDPItemData& rItem) const;
83 };
84 
85 typedef ::std::vector<ScDPSaveGroupItem> ScDPSaveGroupItemVec;
86 
92 {
93  OUString aSourceDim;
94  OUString aGroupDimName;
97  sal_Int32 nDatePart;
98 
99 public:
100  ScDPSaveGroupDimension( const OUString& rSource, const OUString& rName );
101  ScDPSaveGroupDimension( const OUString& rSource, const OUString& rName, const ScDPNumGroupInfo& rDateInfo, sal_Int32 nPart );
102 
103  void AddToData( ScDPGroupTableData& rData ) const;
104  void AddToCache(ScDPCache& rCache) const;
105  void SetDateInfo( const ScDPNumGroupInfo& rInfo, sal_Int32 nPart );
106 
107  void AddGroupItem( const ScDPSaveGroupItem& rItem );
108  const OUString& GetGroupDimName() const { return aGroupDimName; }
109  const OUString& GetSourceDimName() const { return aSourceDim; }
110 
111  sal_Int32 GetDatePart() const { return nDatePart; }
112  const ScDPNumGroupInfo& GetDateInfo() const { return aDateInfo; }
113 
114  OUString CreateGroupName( std::u16string_view rPrefix );
115  const ScDPSaveGroupItem* GetNamedGroup( const OUString& rGroupName ) const;
116  ScDPSaveGroupItem* GetNamedGroupAcc( const OUString& rGroupName );
117  void RemoveFromGroups( const OUString& rItemName );
118  void RemoveGroup(const OUString& rGroupName);
119  bool IsEmpty() const;
120  bool HasOnlyHidden(const ScDPUniqueStringSet& rVisible);
121 
122  tools::Long GetGroupCount() const;
123  const ScDPSaveGroupItem& GetGroupByIndex( tools::Long nIndex ) const;
124 
125  void Rename( const OUString& rNewName );
126 
127 private:
128  bool IsInGroup(const ScDPItemData& rItem) const;
129 };
130 
137 {
138  OUString aDimensionName;
141  sal_Int32 nDatePart;
142 
143 public:
144  ScDPSaveNumGroupDimension( const OUString& rName, const ScDPNumGroupInfo& rInfo );
145  ScDPSaveNumGroupDimension( const OUString& rName, const ScDPNumGroupInfo& rDateInfo, sal_Int32 nPart );
146 
147  void AddToData( ScDPGroupTableData& rData ) const;
148  void AddToCache(ScDPCache& rCache) const;
149 
150  const OUString& GetDimensionName() const { return aDimensionName; }
151  const ScDPNumGroupInfo& GetInfo() const { return aGroupInfo; }
152 
153  sal_Int32 GetDatePart() const { return nDatePart; }
154  const ScDPNumGroupInfo& GetDateInfo() const { return aDateInfo; }
155 
156  void SetGroupInfo( const ScDPNumGroupInfo& rNew );
157  void SetDateInfo( const ScDPNumGroupInfo& rInfo, sal_Int32 nPart );
158 };
159 
165 {
166 public:
168 
169  bool operator==( const ScDPDimensionSaveData& r ) const;
170 
171  void WriteToData( ScDPGroupTableData& rData ) const;
172 
173  void WriteToCache(ScDPCache& rCache) const;
174 
175  OUString CreateGroupDimName(
176  const OUString& rSourceName, const ScDPObject& rObject, bool bAllowSource,
177  const ::std::vector<OUString>* pDeletedNames );
178 
179  OUString CreateDateGroupDimName(
180  sal_Int32 nDatePart, const ScDPObject& rObject, bool bAllowSource,
181  const ::std::vector<OUString>* pDeletedNames );
182 
183  void AddGroupDimension( const ScDPSaveGroupDimension& rGroupDim );
184  void ReplaceGroupDimension( const ScDPSaveGroupDimension& rGroupDim );
185  void RemoveGroupDimension( const OUString& rGroupDimName );
186 
187  void AddNumGroupDimension( const ScDPSaveNumGroupDimension& rGroupDim );
188  void ReplaceNumGroupDimension( const ScDPSaveNumGroupDimension& rGroupDim );
189  void RemoveNumGroupDimension( const OUString& rGroupDimName );
190 
191  const ScDPSaveGroupDimension* GetGroupDimForBase( const OUString& rBaseDimName ) const;
192  const ScDPSaveGroupDimension* GetNamedGroupDim( const OUString& rGroupDimName ) const;
193  const ScDPSaveGroupDimension* GetFirstNamedGroupDim( const OUString& rBaseDimName ) const;
194  const ScDPSaveGroupDimension* GetNextNamedGroupDim( const OUString& rGroupDimName ) const;
195  const ScDPSaveNumGroupDimension* GetNumGroupDim( const OUString& rGroupDimName ) const;
196 
197  ScDPSaveGroupDimension* GetGroupDimAccForBase( const OUString& rBaseDimName );
198  ScDPSaveGroupDimension* GetNamedGroupDimAcc( const OUString& rGroupDimName );
199  ScDPSaveGroupDimension* GetFirstNamedGroupDimAcc( const OUString& rBaseDimName );
200  ScDPSaveGroupDimension* GetNextNamedGroupDimAcc( const OUString& rGroupDimName );
201 
202  ScDPSaveNumGroupDimension* GetNumGroupDimAcc( const OUString& rGroupDimName );
203 
204  bool HasGroupDimensions() const;
205 
206  sal_Int32 CollectDateParts( const OUString& rBaseDimName ) const;
207 
208 private:
209  typedef ::std::vector< ScDPSaveGroupDimension > ScDPSaveGroupDimVec;
210  typedef ::std::map<OUString, ScDPSaveNumGroupDimension> ScDPSaveNumGroupDimMap;
211 
212  ScDPDimensionSaveData& operator=( const ScDPDimensionSaveData& ) = delete;
213 
214  ScDPSaveGroupDimVec maGroupDims;
215  ScDPSaveNumGroupDimMap maNumGroupDims;
216 };
217 
218 #endif
219 
220 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool operator==(const XclFontData &rLeft, const XclFontData &rRight)
Definition: xlstyle.cxx:517
const OUString & GetGroupDimName() const
Definition: dpdimsave.hxx:108
This class has to do with handling exclusively grouped dimensions? TODO: Find out what this class doe...
Definition: dpdimsave.hxx:164
::std::map< OUString, ScDPSaveNumGroupDimension > ScDPSaveNumGroupDimMap
Definition: dpdimsave.hxx:210
ScDPSaveGroupItemVec aGroups
Definition: dpdimsave.hxx:95
long Long
Classes to save Data Pilot settings that create new dimensions (fields).
Definition: dpdimsave.hxx:47
const OUString & GetGroupName() const
Definition: dpdimsave.hxx:66
const OUString & GetSourceDimName() const
Definition: dpdimsave.hxx:109
const ContentProperties & rData
ScDPNumGroupInfo aDateInfo
Definition: dpdimsave.hxx:96
sal_Int32 GetDatePart() const
Definition: dpdimsave.hxx:153
const ScDPNumGroupInfo & GetDateInfo() const
Definition: dpdimsave.hxx:154
This class represents the cached data part of the datapilot cache table implementation.
Definition: dpcache.hxx:48
std::vector< ScDPItemData > maItems
items converted from the strings.
Definition: dpdimsave.hxx:51
ScDPNumGroupInfo aDateInfo
Definition: dpdimsave.hxx:140
ScDPSaveGroupDimVec maGroupDims
Definition: dpdimsave.hxx:214
sal_Int32 GetDatePart() const
Definition: dpdimsave.hxx:111
OUString aSourceDim
always the real source from the original data
Definition: dpdimsave.hxx:93
When assigning a string value, you can also assign an interned string whose life-cycle is managed by ...
Definition: dpitemdata.hxx:29
Represents a group dimension that introduces a new hierarchy for an existing dimension.
Definition: dpdimsave.hxx:136
const OUString & GetDimensionName() const
Definition: dpdimsave.hxx:150
ScDPNumGroupInfo aGroupInfo
Definition: dpdimsave.hxx:139
OUString aGroupName
name of group
Definition: dpdimsave.hxx:49
const ScDPNumGroupInfo & GetDateInfo() const
Definition: dpdimsave.hxx:112
ScDPSaveNumGroupDimMap maNumGroupDims
Definition: dpdimsave.hxx:215
::std::vector< ScDPSaveGroupDimension > ScDPSaveGroupDimVec
Definition: dpdimsave.hxx:209
std::unordered_set< OUString > ScDPUniqueStringSet
Definition: dptypes.hxx:17
std::vector< OUString > aElements
names of items in original dimension
Definition: dpdimsave.hxx:50
Represents a new group dimension whose dimension ID is higher than the highest source dimension ID...
Definition: dpdimsave.hxx:91
const ScDPNumGroupInfo & GetInfo() const
Definition: dpdimsave.hxx:151
::std::vector< ScDPSaveGroupItem > ScDPSaveGroupItemVec
Definition: dpdimsave.hxx:85
#define SC_DLLPUBLIC
Definition: scdllapi.h:28