tdf#104816 sw: if non-section content, let all sections hide.
[LibreOffice.git] / sc / inc / dpdimsave.hxx
blobc49f2d33f969f77dbe2a897438786f356846052b
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 void AddToData(ScDPGroupDimension& rDataDim) const;
55 void AddElement( const OUString& rName );
56 void AddElementsFromGroup( const ScDPSaveGroupItem& rGroup );
57 const OUString& GetGroupName() const { return aGroupName; }
59 /// @return true if found (removed)
60 bool RemoveElement( const OUString& rName );
62 bool IsEmpty() const;
63 size_t GetElementCount() const;
64 const OUString* GetElementByIndex(size_t nIndex) const;
66 void Rename( const OUString& rNewName );
68 /** remove this group's elements from their groups in rDimension
69 (rDimension must be a different dimension from the one which contains this)*/
70 void RemoveElementsFromGroups( ScDPSaveGroupDimension& rDimension ) const;
72 void ConvertElementsToItems(SvNumberFormatter* pFormatter) const;
73 bool HasInGroup(const ScDPItemData& rItem) const;
76 typedef ::std::vector<ScDPSaveGroupItem> ScDPSaveGroupItemVec;
78 /**
79 * Represents a new group dimension whose dimension ID is higher than the
80 * highest source dimension ID.
82 class SC_DLLPUBLIC ScDPSaveGroupDimension
84 OUString aSourceDim; ///< always the real source from the original data
85 OUString aGroupDimName;
86 ScDPSaveGroupItemVec aGroups;
87 mutable ScDPNumGroupInfo aDateInfo;
88 sal_Int32 nDatePart;
90 public:
91 ScDPSaveGroupDimension( const OUString& rSource, const OUString& rName );
92 ScDPSaveGroupDimension( const OUString& rSource, const OUString& rName, const ScDPNumGroupInfo& rDateInfo, sal_Int32 nPart );
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 );
138 void AddToData( ScDPGroupTableData& rData ) const;
139 void AddToCache(ScDPCache& rCache) const;
141 const OUString& GetDimensionName() const { return aDimensionName; }
142 const ScDPNumGroupInfo& GetInfo() const { return aGroupInfo; }
144 sal_Int32 GetDatePart() const { return nDatePart; }
145 const ScDPNumGroupInfo& GetDateInfo() const { return aDateInfo; }
147 void SetGroupInfo( const ScDPNumGroupInfo& rNew );
148 void SetDateInfo( const ScDPNumGroupInfo& rInfo, sal_Int32 nPart );
152 * This class has to do with handling exclusively grouped dimensions? TODO:
153 * Find out what this class does and document it here.
155 class SC_DLLPUBLIC ScDPDimensionSaveData
157 public:
158 ScDPDimensionSaveData();
160 bool operator==( const ScDPDimensionSaveData& r ) const;
162 void WriteToData( ScDPGroupTableData& rData ) const;
164 void WriteToCache(ScDPCache& rCache) const;
166 OUString CreateGroupDimName(
167 const OUString& rSourceName, const ScDPObject& rObject, bool bAllowSource,
168 const ::std::vector<OUString>* pDeletedNames );
170 OUString CreateDateGroupDimName(
171 sal_Int32 nDatePart, const ScDPObject& rObject, bool bAllowSource,
172 const ::std::vector<OUString>* pDeletedNames );
174 void AddGroupDimension( const ScDPSaveGroupDimension& rGroupDim );
175 void ReplaceGroupDimension( const ScDPSaveGroupDimension& rGroupDim );
176 void RemoveGroupDimension( const OUString& rGroupDimName );
178 void AddNumGroupDimension( const ScDPSaveNumGroupDimension& rGroupDim );
179 void ReplaceNumGroupDimension( const ScDPSaveNumGroupDimension& rGroupDim );
180 void RemoveNumGroupDimension( const OUString& rGroupDimName );
182 const ScDPSaveGroupDimension* GetGroupDimForBase( const OUString& rBaseDimName ) const;
183 const ScDPSaveGroupDimension* GetNamedGroupDim( const OUString& rGroupDimName ) const;
184 const ScDPSaveGroupDimension* GetFirstNamedGroupDim( const OUString& rBaseDimName ) const;
185 const ScDPSaveGroupDimension* GetNextNamedGroupDim( const OUString& rGroupDimName ) const;
186 const ScDPSaveNumGroupDimension* GetNumGroupDim( const OUString& rGroupDimName ) const;
188 ScDPSaveGroupDimension* GetGroupDimAccForBase( const OUString& rBaseDimName );
189 ScDPSaveGroupDimension* GetNamedGroupDimAcc( const OUString& rGroupDimName );
190 ScDPSaveGroupDimension* GetFirstNamedGroupDimAcc( const OUString& rBaseDimName );
191 ScDPSaveGroupDimension* GetNextNamedGroupDimAcc( const OUString& rGroupDimName );
193 ScDPSaveNumGroupDimension* GetNumGroupDimAcc( const OUString& rGroupDimName );
195 bool HasGroupDimensions() const;
197 sal_Int32 CollectDateParts( const OUString& rBaseDimName ) const;
199 private:
200 typedef ::std::vector< ScDPSaveGroupDimension > ScDPSaveGroupDimVec;
201 typedef ::std::map<OUString, ScDPSaveNumGroupDimension> ScDPSaveNumGroupDimMap;
203 ScDPDimensionSaveData& operator=( const ScDPDimensionSaveData& ) = delete;
205 ScDPSaveGroupDimVec maGroupDims;
206 ScDPSaveNumGroupDimMap maNumGroupDims;
209 #endif
211 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */