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 <vector>
24 #include <map>
25 #include "dpitemdata.hxx"
26 #include "dpnumgroupinfo.hxx"
27 #include "scdllapi.h"
28 #include "dptypes.hxx"
29 
30 class ScDPGroupTableData;
31 class ScDPGroupDimension;
32 class ScDPObject;
33 class ScDPCache;
34 class SvNumberFormatter;
35 
37 
44 {
45  OUString aGroupName;
46  std::vector<OUString> aElements;
47  mutable std::vector<ScDPItemData> maItems;
48 
49 public:
50  ScDPSaveGroupItem( const OUString& rName );
52 
53  ScDPSaveGroupItem(ScDPSaveGroupItem const &) = default;
55  ScDPSaveGroupItem & operator =(ScDPSaveGroupItem const &) = default;
56  ScDPSaveGroupItem & operator =(ScDPSaveGroupItem &&) = default;
57 
58  void AddToData(ScDPGroupDimension& rDataDim) const;
59 
60  void AddElement( const OUString& rName );
61  void AddElementsFromGroup( const ScDPSaveGroupItem& rGroup );
62  const OUString& GetGroupName() const { return aGroupName; }
63 
65  bool RemoveElement( const OUString& rName );
66 
67  bool IsEmpty() const;
68  size_t GetElementCount() const;
69  const OUString* GetElementByIndex(size_t nIndex) const;
70 
71  void Rename( const OUString& rNewName );
72 
75  void RemoveElementsFromGroups( ScDPSaveGroupDimension& rDimension ) const;
76 
77  void ConvertElementsToItems(SvNumberFormatter* pFormatter) const;
78  bool HasInGroup(const ScDPItemData& rItem) const;
79 };
80 
81 typedef ::std::vector<ScDPSaveGroupItem> ScDPSaveGroupItemVec;
82 
88 {
89  OUString aSourceDim;
90  OUString aGroupDimName;
93  sal_Int32 nDatePart;
94 
95 public:
96  ScDPSaveGroupDimension( const OUString& rSource, const OUString& rName );
97  ScDPSaveGroupDimension( const OUString& rSource, const OUString& rName, const ScDPNumGroupInfo& rDateInfo, sal_Int32 nPart );
98 
99  void AddToData( ScDPGroupTableData& rData ) const;
100  void AddToCache(ScDPCache& rCache) const;
101  void SetDateInfo( const ScDPNumGroupInfo& rInfo, sal_Int32 nPart );
102 
103  void AddGroupItem( const ScDPSaveGroupItem& rItem );
104  const OUString& GetGroupDimName() const { return aGroupDimName; }
105  const OUString& GetSourceDimName() const { return aSourceDim; }
106 
107  sal_Int32 GetDatePart() const { return nDatePart; }
108  const ScDPNumGroupInfo& GetDateInfo() const { return aDateInfo; }
109 
110  OUString CreateGroupName( const OUString& rPrefix );
111  const ScDPSaveGroupItem* GetNamedGroup( const OUString& rGroupName ) const;
112  ScDPSaveGroupItem* GetNamedGroupAcc( const OUString& rGroupName );
113  void RemoveFromGroups( const OUString& rItemName );
114  void RemoveGroup(const OUString& rGroupName);
115  bool IsEmpty() const;
116  bool HasOnlyHidden(const ScDPUniqueStringSet& rVisible);
117 
118  long GetGroupCount() const;
119  const ScDPSaveGroupItem& GetGroupByIndex( long nIndex ) const;
120 
121  void Rename( const OUString& rNewName );
122 
123 private:
124  bool IsInGroup(const ScDPItemData& rItem) const;
125 };
126 
133 {
134  OUString aDimensionName;
137  sal_Int32 nDatePart;
138 
139 public:
140  ScDPSaveNumGroupDimension( const OUString& rName, const ScDPNumGroupInfo& rInfo );
141  ScDPSaveNumGroupDimension( const OUString& rName, const ScDPNumGroupInfo& rDateInfo, sal_Int32 nPart );
142 
143  void AddToData( ScDPGroupTableData& rData ) const;
144  void AddToCache(ScDPCache& rCache) const;
145 
146  const OUString& GetDimensionName() const { return aDimensionName; }
147  const ScDPNumGroupInfo& GetInfo() const { return aGroupInfo; }
148 
149  sal_Int32 GetDatePart() const { return nDatePart; }
150  const ScDPNumGroupInfo& GetDateInfo() const { return aDateInfo; }
151 
152  void SetGroupInfo( const ScDPNumGroupInfo& rNew );
153  void SetDateInfo( const ScDPNumGroupInfo& rInfo, sal_Int32 nPart );
154 };
155 
161 {
162 public:
164 
165  bool operator==( const ScDPDimensionSaveData& r ) const;
166 
167  void WriteToData( ScDPGroupTableData& rData ) const;
168 
169  void WriteToCache(ScDPCache& rCache) const;
170 
171  OUString CreateGroupDimName(
172  const OUString& rSourceName, const ScDPObject& rObject, bool bAllowSource,
173  const ::std::vector<OUString>* pDeletedNames );
174 
175  OUString CreateDateGroupDimName(
176  sal_Int32 nDatePart, const ScDPObject& rObject, bool bAllowSource,
177  const ::std::vector<OUString>* pDeletedNames );
178 
179  void AddGroupDimension( const ScDPSaveGroupDimension& rGroupDim );
180  void ReplaceGroupDimension( const ScDPSaveGroupDimension& rGroupDim );
181  void RemoveGroupDimension( const OUString& rGroupDimName );
182 
183  void AddNumGroupDimension( const ScDPSaveNumGroupDimension& rGroupDim );
184  void ReplaceNumGroupDimension( const ScDPSaveNumGroupDimension& rGroupDim );
185  void RemoveNumGroupDimension( const OUString& rGroupDimName );
186 
187  const ScDPSaveGroupDimension* GetGroupDimForBase( const OUString& rBaseDimName ) const;
188  const ScDPSaveGroupDimension* GetNamedGroupDim( const OUString& rGroupDimName ) const;
189  const ScDPSaveGroupDimension* GetFirstNamedGroupDim( const OUString& rBaseDimName ) const;
190  const ScDPSaveGroupDimension* GetNextNamedGroupDim( const OUString& rGroupDimName ) const;
191  const ScDPSaveNumGroupDimension* GetNumGroupDim( const OUString& rGroupDimName ) const;
192 
193  ScDPSaveGroupDimension* GetGroupDimAccForBase( const OUString& rBaseDimName );
194  ScDPSaveGroupDimension* GetNamedGroupDimAcc( const OUString& rGroupDimName );
195  ScDPSaveGroupDimension* GetFirstNamedGroupDimAcc( const OUString& rBaseDimName );
196  ScDPSaveGroupDimension* GetNextNamedGroupDimAcc( const OUString& rGroupDimName );
197 
198  ScDPSaveNumGroupDimension* GetNumGroupDimAcc( const OUString& rGroupDimName );
199 
200  bool HasGroupDimensions() const;
201 
202  sal_Int32 CollectDateParts( const OUString& rBaseDimName ) const;
203 
204 private:
205  typedef ::std::vector< ScDPSaveGroupDimension > ScDPSaveGroupDimVec;
206  typedef ::std::map<OUString, ScDPSaveNumGroupDimension> ScDPSaveNumGroupDimMap;
207 
208  ScDPDimensionSaveData& operator=( const ScDPDimensionSaveData& ) = delete;
209 
210  ScDPSaveGroupDimVec maGroupDims;
211  ScDPSaveNumGroupDimMap maNumGroupDims;
212 };
213 
214 #endif
215 
216 /* 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:104
This class has to do with handling exclusively grouped dimensions? TODO: Find out what this class doe...
Definition: dpdimsave.hxx:160
::std::map< OUString, ScDPSaveNumGroupDimension > ScDPSaveNumGroupDimMap
Definition: dpdimsave.hxx:206
ScDPSaveGroupItemVec aGroups
Definition: dpdimsave.hxx:91
Classes to save Data Pilot settings that create new dimensions (fields).
Definition: dpdimsave.hxx:43
const OUString & GetGroupName() const
Definition: dpdimsave.hxx:62
const OUString & GetSourceDimName() const
Definition: dpdimsave.hxx:105
const ContentProperties & rData
ScDPNumGroupInfo aDateInfo
Definition: dpdimsave.hxx:92
sal_Int32 GetDatePart() const
Definition: dpdimsave.hxx:149
const ScDPNumGroupInfo & GetDateInfo() const
Definition: dpdimsave.hxx:150
This class represents the cached data part of the datapilot cache table implementation.
Definition: dpcache.hxx:47
std::vector< ScDPItemData > maItems
items converted from the strings.
Definition: dpdimsave.hxx:47
ScDPNumGroupInfo aDateInfo
Definition: dpdimsave.hxx:136
ScDPSaveGroupDimVec maGroupDims
Definition: dpdimsave.hxx:210
sal_Int32 GetDatePart() const
Definition: dpdimsave.hxx:107
OUString aSourceDim
always the real source from the original data
Definition: dpdimsave.hxx:89
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:132
const OUString & GetDimensionName() const
Definition: dpdimsave.hxx:146
ScDPNumGroupInfo aGroupInfo
Definition: dpdimsave.hxx:135
OUString aGroupName
name of group
Definition: dpdimsave.hxx:45
const ScDPNumGroupInfo & GetDateInfo() const
Definition: dpdimsave.hxx:108
ScDPSaveNumGroupDimMap maNumGroupDims
Definition: dpdimsave.hxx:211
::std::vector< ScDPSaveGroupDimension > ScDPSaveGroupDimVec
Definition: dpdimsave.hxx:205
std::unordered_set< OUString > ScDPUniqueStringSet
Definition: dptypes.hxx:17
std::vector< OUString > aElements
names of items in original dimension
Definition: dpdimsave.hxx:46
Represents a new group dimension whose dimension ID is higher than the highest source dimension ID...
Definition: dpdimsave.hxx:87
const ScDPNumGroupInfo & GetInfo() const
Definition: dpdimsave.hxx:147
::std::vector< ScDPSaveGroupItem > ScDPSaveGroupItemVec
Definition: dpdimsave.hxx:81
#define SC_DLLPUBLIC
Definition: scdllapi.h:28