Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / sc / inc / dpdimsave.hxx
blobb05769398d7382018492bdbe6c9d9a7f11ae2ff3
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_DPDIMSAVE_HXX
21 #define INCLUDED_SC_INC_DPDIMSAVE_HXX
23 #include <vector>
24 #include <map>
25 #include "dpgroup.hxx"
26 #include "scdllapi.h"
27 #include "dptypes.hxx"
29 class ScDPGroupTableData;
30 class ScDPGroupDimension;
31 class ScDPObject;
32 class ScDPCache;
33 class SvNumberFormatter;
35 class ScDPSaveGroupDimension;
37 /**
38 * Classes to save Data Pilot settings that create new dimensions (fields).
39 * These have to be applied before the other ScDPSaveData settings.
42 class SC_DLLPUBLIC ScDPSaveGroupItem
44 OUString aGroupName; ///< name of group
45 std::vector<OUString> aElements; ///< names of items in original dimension
46 mutable std::vector<ScDPItemData> maItems; ///< items converted from the strings.
48 public:
49 ScDPSaveGroupItem( const OUString& rName );
50 ~ScDPSaveGroupItem();
52 void AddToData(ScDPGroupDimension& rDataDim) const;
54 void AddElement( const OUString& rName );
55 void AddElementsFromGroup( const ScDPSaveGroupItem& rGroup );
56 const OUString& GetGroupName() const { return aGroupName; }
58 /// @return true if found (removed)
59 bool RemoveElement( const OUString& rName );
61 bool IsEmpty() const;
62 size_t GetElementCount() const;
63 const OUString* GetElementByIndex(size_t nIndex) const;
65 void Rename( const OUString& rNewName );
67 /** remove this group's elements from their groups in rDimension
68 (rDimension must be a different dimension from the one which contains this)*/
69 void RemoveElementsFromGroups( ScDPSaveGroupDimension& rDimension ) const;
71 void ConvertElementsToItems(SvNumberFormatter* pFormatter) const;
72 bool HasInGroup(const ScDPItemData& rItem) const;
75 typedef ::std::vector<ScDPSaveGroupItem> ScDPSaveGroupItemVec;
77 /**
78 * Represents a new group dimension whose dimension ID is higher than the
79 * highest source dimension ID.
81 class SC_DLLPUBLIC ScDPSaveGroupDimension
83 OUString aSourceDim; ///< always the real source from the original data
84 OUString aGroupDimName;
85 ScDPSaveGroupItemVec aGroups;
86 mutable ScDPNumGroupInfo aDateInfo;
87 sal_Int32 nDatePart;
89 public:
90 ScDPSaveGroupDimension( const OUString& rSource, const OUString& rName );
91 ScDPSaveGroupDimension( const OUString& rSource, const OUString& rName, const ScDPNumGroupInfo& rDateInfo, sal_Int32 nPart );
92 ~ScDPSaveGroupDimension();
94 void AddToData( ScDPGroupTableData& rData ) const;
95 void AddToCache(ScDPCache& rCache) const;
96 void SetDateInfo( const ScDPNumGroupInfo& rInfo, sal_Int32 nPart );
98 void AddGroupItem( const ScDPSaveGroupItem& rItem );
99 const OUString& GetGroupDimName() const { return aGroupDimName; }
100 const OUString& GetSourceDimName() const { return aSourceDim; }
102 sal_Int32 GetDatePart() const { return nDatePart; }
103 const ScDPNumGroupInfo& GetDateInfo() const { return aDateInfo; }
105 OUString CreateGroupName( const OUString& rPrefix );
106 const ScDPSaveGroupItem* GetNamedGroup( const OUString& rGroupName ) const;
107 ScDPSaveGroupItem* GetNamedGroupAcc( const OUString& rGroupName );
108 void RemoveFromGroups( const OUString& rItemName );
109 void RemoveGroup(const OUString& rGroupName);
110 bool IsEmpty() const;
111 bool HasOnlyHidden(const ScDPUniqueStringSet& rVisible);
113 long GetGroupCount() const;
114 const ScDPSaveGroupItem& GetGroupByIndex( long nIndex ) const;
116 void Rename( const OUString& rNewName );
118 private:
119 bool IsInGroup(const ScDPItemData& rItem) const;
123 * Represents a group dimension that introduces a new hierarchy for an
124 * existing dimension. Unlike the ScDPSaveGroupDimension counterpart, it
125 * re-uses the source dimension name and ID.
127 class SC_DLLPUBLIC ScDPSaveNumGroupDimension
129 OUString aDimensionName;
130 mutable ScDPNumGroupInfo aGroupInfo;
131 mutable ScDPNumGroupInfo aDateInfo;
132 sal_Int32 nDatePart;
134 public:
135 ScDPSaveNumGroupDimension( const OUString& rName, const ScDPNumGroupInfo& rInfo );
136 ScDPSaveNumGroupDimension( const OUString& rName, const ScDPNumGroupInfo& rDateInfo, sal_Int32 nPart );
137 ~ScDPSaveNumGroupDimension();
139 void AddToData( ScDPGroupTableData& rData ) const;
140 void AddToCache(ScDPCache& rCache) const;
142 const OUString& GetDimensionName() const { return aDimensionName; }
143 const ScDPNumGroupInfo& GetInfo() const { return aGroupInfo; }
145 sal_Int32 GetDatePart() const { return nDatePart; }
146 const ScDPNumGroupInfo& GetDateInfo() const { return aDateInfo; }
148 void SetGroupInfo( const ScDPNumGroupInfo& rNew );
149 void SetDateInfo( const ScDPNumGroupInfo& rInfo, sal_Int32 nPart );
153 * This class has to do with handling exclusively grouped dimensions? TODO:
154 * Find out what this class does and document it here.
156 class SC_DLLPUBLIC ScDPDimensionSaveData
158 public:
159 ScDPDimensionSaveData();
160 ~ScDPDimensionSaveData();
162 bool operator==( const ScDPDimensionSaveData& r ) const;
164 void WriteToData( ScDPGroupTableData& rData ) const;
166 void WriteToCache(ScDPCache& rCache) const;
168 OUString CreateGroupDimName(
169 const OUString& rSourceName, const ScDPObject& rObject, bool bAllowSource,
170 const ::std::vector<OUString>* pDeletedNames );
172 OUString CreateDateGroupDimName(
173 sal_Int32 nDatePart, const ScDPObject& rObject, bool bAllowSource,
174 const ::std::vector<OUString>* pDeletedNames );
176 void AddGroupDimension( const ScDPSaveGroupDimension& rGroupDim );
177 void ReplaceGroupDimension( const ScDPSaveGroupDimension& rGroupDim );
178 void RemoveGroupDimension( const OUString& rGroupDimName );
180 void AddNumGroupDimension( const ScDPSaveNumGroupDimension& rGroupDim );
181 void ReplaceNumGroupDimension( const ScDPSaveNumGroupDimension& rGroupDim );
182 void RemoveNumGroupDimension( const OUString& rGroupDimName );
184 const ScDPSaveGroupDimension* GetGroupDimForBase( const OUString& rBaseDimName ) const;
185 const ScDPSaveGroupDimension* GetNamedGroupDim( const OUString& rGroupDimName ) const;
186 const ScDPSaveGroupDimension* GetFirstNamedGroupDim( const OUString& rBaseDimName ) const;
187 const ScDPSaveGroupDimension* GetNextNamedGroupDim( const OUString& rGroupDimName ) const;
188 const ScDPSaveNumGroupDimension* GetNumGroupDim( const OUString& rGroupDimName ) const;
190 ScDPSaveGroupDimension* GetGroupDimAccForBase( const OUString& rBaseDimName );
191 ScDPSaveGroupDimension* GetNamedGroupDimAcc( const OUString& rGroupDimName );
192 ScDPSaveGroupDimension* GetFirstNamedGroupDimAcc( const OUString& rBaseDimName );
193 ScDPSaveGroupDimension* GetNextNamedGroupDimAcc( const OUString& rGroupDimName );
195 ScDPSaveNumGroupDimension* GetNumGroupDimAcc( const OUString& rGroupDimName );
197 bool HasGroupDimensions() const;
199 sal_Int32 CollectDateParts( const OUString& rBaseDimName ) const;
201 private:
202 typedef ::std::vector< ScDPSaveGroupDimension > ScDPSaveGroupDimVec;
203 typedef ::std::map<OUString, ScDPSaveNumGroupDimension> ScDPSaveNumGroupDimMap;
205 ScDPDimensionSaveData& operator=( const ScDPDimensionSaveData& ) = delete;
207 ScDPSaveGroupDimVec maGroupDims;
208 ScDPSaveNumGroupDimMap maNumGroupDims;
211 #endif
213 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */