1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 SC_DPDIMSAVE_HXX
21 #define SC_DPDIMSAVE_HXX
25 #include "dpgroup.hxx"
27 #include "dptypes.hxx"
29 class ScDPGroupTableData
;
30 class ScDPGroupDimension
;
33 class SvNumberFormatter
;
35 class ScDPSaveGroupDimension
;
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.
49 ScDPSaveGroupItem( const OUString
& rName
);
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
);
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
;
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
;
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;
115 ScDPSaveGroupItem
* GetGroupAccByIndex( long nIndex
);
117 void Rename( const OUString
& rNewName
);
120 bool IsInGroup(const ScDPItemData
& rItem
) const;
124 * Represents a group dimension that introduces a new hierarchy for an
125 * existing dimension. Unlike the ScDPSaveGroupDimension counterpart, it
126 * re-uses the source dimension name and ID.
128 class SC_DLLPUBLIC ScDPSaveNumGroupDimension
130 OUString aDimensionName
;
131 mutable ScDPNumGroupInfo aGroupInfo
;
132 mutable ScDPNumGroupInfo aDateInfo
;
136 ScDPSaveNumGroupDimension( const OUString
& rName
, const ScDPNumGroupInfo
& rInfo
);
137 ScDPSaveNumGroupDimension( const OUString
& rName
, const ScDPNumGroupInfo
& rDateInfo
, sal_Int32 nPart
);
138 ~ScDPSaveNumGroupDimension();
140 void AddToData( ScDPGroupTableData
& rData
) const;
141 void AddToCache(ScDPCache
& rCache
) const;
143 const OUString
& GetDimensionName() const { return aDimensionName
; }
144 const ScDPNumGroupInfo
& GetInfo() const { return aGroupInfo
; }
146 sal_Int32
GetDatePart() const { return nDatePart
; }
147 const ScDPNumGroupInfo
& GetDateInfo() const { return aDateInfo
; }
149 void SetGroupInfo( const ScDPNumGroupInfo
& rNew
);
150 void SetDateInfo( const ScDPNumGroupInfo
& rInfo
, sal_Int32 nPart
);
154 * This class has to do with handling exclusively grouped dimensions? TODO:
155 * Find out what this class does and document it here.
157 class SC_DLLPUBLIC ScDPDimensionSaveData
160 ScDPDimensionSaveData();
161 ~ScDPDimensionSaveData();
163 bool operator==( const ScDPDimensionSaveData
& r
) const;
165 void WriteToData( ScDPGroupTableData
& rData
) const;
167 void WriteToCache(ScDPCache
& rCache
) const;
169 OUString
CreateGroupDimName(
170 const OUString
& rSourceName
, const ScDPObject
& rObject
, bool bAllowSource
,
171 const ::std::vector
<OUString
>* pDeletedNames
);
173 OUString
CreateDateGroupDimName(
174 sal_Int32 nDatePart
, const ScDPObject
& rObject
, bool bAllowSource
,
175 const ::std::vector
<OUString
>* pDeletedNames
);
177 void AddGroupDimension( const ScDPSaveGroupDimension
& rGroupDim
);
178 void ReplaceGroupDimension( const ScDPSaveGroupDimension
& rGroupDim
);
179 void RemoveGroupDimension( const OUString
& rGroupDimName
);
181 void AddNumGroupDimension( const ScDPSaveNumGroupDimension
& rGroupDim
);
182 void ReplaceNumGroupDimension( const ScDPSaveNumGroupDimension
& rGroupDim
);
183 void RemoveNumGroupDimension( const OUString
& rGroupDimName
);
185 const ScDPSaveGroupDimension
* GetGroupDimForBase( const OUString
& rBaseDimName
) const;
186 const ScDPSaveGroupDimension
* GetNamedGroupDim( const OUString
& rGroupDimName
) const;
187 const ScDPSaveGroupDimension
* GetFirstNamedGroupDim( const OUString
& rBaseDimName
) const;
188 const ScDPSaveGroupDimension
* GetNextNamedGroupDim( const OUString
& rGroupDimName
) const;
189 const ScDPSaveNumGroupDimension
* GetNumGroupDim( const OUString
& rGroupDimName
) const;
191 ScDPSaveGroupDimension
* GetGroupDimAccForBase( const OUString
& rBaseDimName
);
192 ScDPSaveGroupDimension
* GetNamedGroupDimAcc( const OUString
& rGroupDimName
);
193 ScDPSaveGroupDimension
* GetFirstNamedGroupDimAcc( const OUString
& rBaseDimName
);
194 ScDPSaveGroupDimension
* GetNextNamedGroupDimAcc( const OUString
& rGroupDimName
);
196 ScDPSaveNumGroupDimension
* GetNumGroupDimAcc( const OUString
& rGroupDimName
);
198 bool HasGroupDimensions() const;
200 sal_Int32
CollectDateParts( const OUString
& rBaseDimName
) const;
203 typedef ::std::vector
< ScDPSaveGroupDimension
> ScDPSaveGroupDimVec
;
204 typedef ::std::map
<OUString
, ScDPSaveNumGroupDimension
> ScDPSaveNumGroupDimMap
;
206 ScDPDimensionSaveData
& operator=( const ScDPDimensionSaveData
& );
208 ScDPSaveGroupDimVec maGroupDims
;
209 ScDPSaveNumGroupDimMap maNumGroupDims
;
214 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */