nss: upgrade to release 3.73
[LibreOffice.git] / sc / inc / dpdimsave.hxx
blobd8cc13a6bb164a3895741b190bb8f2c09baa3bdd
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 "dpitemdata.hxx"
26 #include "dpnumgroupinfo.hxx"
27 #include "scdllapi.h"
28 #include "dptypes.hxx"
30 class ScDPGroupTableData;
31 class ScDPGroupDimension;
32 class ScDPObject;
33 class ScDPCache;
34 class SvNumberFormatter;
36 class ScDPSaveGroupDimension;
38 /**
39 * Classes to save Data Pilot settings that create new dimensions (fields).
40 * These have to be applied before the other ScDPSaveData settings.
43 class SC_DLLPUBLIC ScDPSaveGroupItem
45 OUString aGroupName; ///< name of group
46 std::vector<OUString> aElements; ///< names of items in original dimension
47 mutable std::vector<ScDPItemData> maItems; ///< items converted from the strings.
49 public:
50 ScDPSaveGroupItem( const OUString& rName );
51 ~ScDPSaveGroupItem();
53 ScDPSaveGroupItem(ScDPSaveGroupItem const &) = default;
54 ScDPSaveGroupItem(ScDPSaveGroupItem &&) = default;
55 ScDPSaveGroupItem & operator =(ScDPSaveGroupItem const &) = default;
56 ScDPSaveGroupItem & operator =(ScDPSaveGroupItem &&) = default;
58 void AddToData(ScDPGroupDimension& rDataDim) const;
60 void AddElement( const OUString& rName );
61 void AddElementsFromGroup( const ScDPSaveGroupItem& rGroup );
62 const OUString& GetGroupName() const { return aGroupName; }
64 /// @return true if found (removed)
65 bool RemoveElement( const OUString& rName );
67 bool IsEmpty() const;
68 size_t GetElementCount() const;
69 const OUString* GetElementByIndex(size_t nIndex) const;
71 void Rename( const OUString& rNewName );
73 /** remove this group's elements from their groups in rDimension
74 (rDimension must be a different dimension from the one which contains this)*/
75 void RemoveElementsFromGroups( ScDPSaveGroupDimension& rDimension ) const;
77 void ConvertElementsToItems(SvNumberFormatter* pFormatter) const;
78 bool HasInGroup(const ScDPItemData& rItem) const;
81 typedef ::std::vector<ScDPSaveGroupItem> ScDPSaveGroupItemVec;
83 /**
84 * Represents a new group dimension whose dimension ID is higher than the
85 * highest source dimension ID.
87 class SC_DLLPUBLIC ScDPSaveGroupDimension
89 OUString aSourceDim; ///< always the real source from the original data
90 OUString aGroupDimName;
91 ScDPSaveGroupItemVec aGroups;
92 mutable ScDPNumGroupInfo aDateInfo;
93 sal_Int32 nDatePart;
95 public:
96 ScDPSaveGroupDimension( const OUString& rSource, const OUString& rName );
97 ScDPSaveGroupDimension( const OUString& rSource, const OUString& rName, const ScDPNumGroupInfo& rDateInfo, sal_Int32 nPart );
99 void AddToData( ScDPGroupTableData& rData ) const;
100 void AddToCache(ScDPCache& rCache) const;
101 void SetDateInfo( const ScDPNumGroupInfo& rInfo, sal_Int32 nPart );
103 void AddGroupItem( const ScDPSaveGroupItem& rItem );
104 const OUString& GetGroupDimName() const { return aGroupDimName; }
105 const OUString& GetSourceDimName() const { return aSourceDim; }
107 sal_Int32 GetDatePart() const { return nDatePart; }
108 const ScDPNumGroupInfo& GetDateInfo() const { return aDateInfo; }
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);
118 tools::Long GetGroupCount() const;
119 const ScDPSaveGroupItem& GetGroupByIndex( tools::Long nIndex ) const;
121 void Rename( const OUString& rNewName );
123 private:
124 bool IsInGroup(const ScDPItemData& rItem) const;
128 * Represents a group dimension that introduces a new hierarchy for an
129 * existing dimension. Unlike the ScDPSaveGroupDimension counterpart, it
130 * re-uses the source dimension name and ID.
132 class SC_DLLPUBLIC ScDPSaveNumGroupDimension
134 OUString aDimensionName;
135 mutable ScDPNumGroupInfo aGroupInfo;
136 mutable ScDPNumGroupInfo aDateInfo;
137 sal_Int32 nDatePart;
139 public:
140 ScDPSaveNumGroupDimension( const OUString& rName, const ScDPNumGroupInfo& rInfo );
141 ScDPSaveNumGroupDimension( const OUString& rName, const ScDPNumGroupInfo& rDateInfo, sal_Int32 nPart );
143 void AddToData( ScDPGroupTableData& rData ) const;
144 void AddToCache(ScDPCache& rCache) const;
146 const OUString& GetDimensionName() const { return aDimensionName; }
147 const ScDPNumGroupInfo& GetInfo() const { return aGroupInfo; }
149 sal_Int32 GetDatePart() const { return nDatePart; }
150 const ScDPNumGroupInfo& GetDateInfo() const { return aDateInfo; }
152 void SetGroupInfo( const ScDPNumGroupInfo& rNew );
153 void SetDateInfo( const ScDPNumGroupInfo& rInfo, sal_Int32 nPart );
157 * This class has to do with handling exclusively grouped dimensions? TODO:
158 * Find out what this class does and document it here.
160 class SC_DLLPUBLIC ScDPDimensionSaveData
162 public:
163 ScDPDimensionSaveData();
165 bool operator==( const ScDPDimensionSaveData& r ) const;
167 void WriteToData( ScDPGroupTableData& rData ) const;
169 void WriteToCache(ScDPCache& rCache) const;
171 OUString CreateGroupDimName(
172 const OUString& rSourceName, const ScDPObject& rObject, bool bAllowSource,
173 const ::std::vector<OUString>* pDeletedNames );
175 OUString CreateDateGroupDimName(
176 sal_Int32 nDatePart, const ScDPObject& rObject, bool bAllowSource,
177 const ::std::vector<OUString>* pDeletedNames );
179 void AddGroupDimension( const ScDPSaveGroupDimension& rGroupDim );
180 void ReplaceGroupDimension( const ScDPSaveGroupDimension& rGroupDim );
181 void RemoveGroupDimension( const OUString& rGroupDimName );
183 void AddNumGroupDimension( const ScDPSaveNumGroupDimension& rGroupDim );
184 void ReplaceNumGroupDimension( const ScDPSaveNumGroupDimension& rGroupDim );
185 void RemoveNumGroupDimension( const OUString& rGroupDimName );
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;
193 ScDPSaveGroupDimension* GetGroupDimAccForBase( const OUString& rBaseDimName );
194 ScDPSaveGroupDimension* GetNamedGroupDimAcc( const OUString& rGroupDimName );
195 ScDPSaveGroupDimension* GetFirstNamedGroupDimAcc( const OUString& rBaseDimName );
196 ScDPSaveGroupDimension* GetNextNamedGroupDimAcc( const OUString& rGroupDimName );
198 ScDPSaveNumGroupDimension* GetNumGroupDimAcc( const OUString& rGroupDimName );
200 bool HasGroupDimensions() const;
202 sal_Int32 CollectDateParts( const OUString& rBaseDimName ) const;
204 private:
205 typedef ::std::vector< ScDPSaveGroupDimension > ScDPSaveGroupDimVec;
206 typedef ::std::map<OUString, ScDPSaveNumGroupDimension> ScDPSaveNumGroupDimMap;
208 ScDPDimensionSaveData& operator=( const ScDPDimensionSaveData& ) = delete;
210 ScDPSaveGroupDimVec maGroupDims;
211 ScDPSaveNumGroupDimMap maNumGroupDims;
214 #endif
216 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */