Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef SC_DPDIMSAVE_HXX
30 : : #define SC_DPDIMSAVE_HXX
31 : :
32 : : #include <vector>
33 : : #include <map>
34 : : #include <tools/string.hxx>
35 : : #include "dpgroup.hxx" // for ScDPNumGroupInfo
36 : : #include "scdllapi.h"
37 : : #include "dptypes.hxx"
38 : :
39 : : class ScDPGroupTableData;
40 : : class ScDPGroupDimension;
41 : : class ScDPObject;
42 : : class ScDPCache;
43 : : class SvNumberFormatter;
44 : :
45 : : class ScDPSaveGroupDimension;
46 : :
47 : : //
48 : : // Classes to save Data Pilot settings that create new dimensions (fields).
49 : : // These have to be applied before the other ScDPSaveData settings.
50 : : //
51 : :
52 [ # # ][ # # ]: 27 : class SC_DLLPUBLIC ScDPSaveGroupItem
[ + - ][ + - ]
53 : : {
54 : : rtl::OUString aGroupName; // name of group
55 : : std::vector<rtl::OUString> aElements; // names of items in original dimension
56 : : mutable std::vector<ScDPItemData> maItems; // items converted from the strings.
57 : :
58 : : public:
59 : : ScDPSaveGroupItem( const rtl::OUString& rName );
60 : : ~ScDPSaveGroupItem();
61 : :
62 : : void AddToData(ScDPGroupDimension& rDataDim) const;
63 : :
64 : : void AddElement( const rtl::OUString& rName );
65 : : void AddElementsFromGroup( const ScDPSaveGroupItem& rGroup );
66 : 23 : const rtl::OUString& GetGroupName() const { return aGroupName; }
67 : : bool RemoveElement( const rtl::OUString& rName ); // returns true if found (removed)
68 : :
69 : : bool IsEmpty() const;
70 : : size_t GetElementCount() const;
71 : : const rtl::OUString* GetElementByIndex(size_t nIndex) const;
72 : :
73 : : void Rename( const rtl::OUString& rNewName );
74 : :
75 : : // remove this group's elements from their groups in rDimension
76 : : // (rDimension must be a different dimension from the one which contains this)
77 : : void RemoveElementsFromGroups( ScDPSaveGroupDimension& rDimension ) const;
78 : :
79 : : void ConvertElementsToItems(SvNumberFormatter* pFormatter) const;
80 : : bool HasInGroup(const ScDPItemData& rItem) const;
81 : : };
82 : :
83 : : typedef ::std::vector<ScDPSaveGroupItem> ScDPSaveGroupItemVec;
84 : :
85 : : /**
86 : : * Represents a new group dimension whose dimension ID is higher than the
87 : : * highest source dimension ID.
88 : : */
89 [ + - ][ + - ]: 22 : class SC_DLLPUBLIC ScDPSaveGroupDimension
90 : : {
91 : : rtl::OUString aSourceDim; // always the real source from the original data
92 : : rtl::OUString aGroupDimName;
93 : : ScDPSaveGroupItemVec aGroups;
94 : : mutable ScDPNumGroupInfo aDateInfo;
95 : : sal_Int32 nDatePart;
96 : :
97 : : public:
98 : : ScDPSaveGroupDimension( const rtl::OUString& rSource, const rtl::OUString& rName );
99 : : ScDPSaveGroupDimension( const rtl::OUString& rSource, const rtl::OUString& rName, const ScDPNumGroupInfo& rDateInfo, sal_Int32 nPart );
100 : : ~ScDPSaveGroupDimension();
101 : :
102 : : void AddToData( ScDPGroupTableData& rData ) const;
103 : : void AddToCache(ScDPCache& rCache) const;
104 : : void SetDateInfo( const ScDPNumGroupInfo& rInfo, sal_Int32 nPart );
105 : :
106 : : void AddGroupItem( const ScDPSaveGroupItem& rItem );
107 : 34 : const rtl::OUString& GetGroupDimName() const { return aGroupDimName; }
108 : 6 : const rtl::OUString& GetSourceDimName() const { return aSourceDim; }
109 : :
110 : 6 : sal_Int32 GetDatePart() const { return nDatePart; }
111 : 3 : const ScDPNumGroupInfo& GetDateInfo() const { return aDateInfo; }
112 : :
113 : : rtl::OUString CreateGroupName( const rtl::OUString& rPrefix );
114 : : const ScDPSaveGroupItem* GetNamedGroup( const rtl::OUString& rGroupName ) const;
115 : : ScDPSaveGroupItem* GetNamedGroupAcc( const rtl::OUString& rGroupName );
116 : : void RemoveFromGroups( const rtl::OUString& rItemName );
117 : : void RemoveGroup(const rtl::OUString& rGroupName);
118 : : bool IsEmpty() const;
119 : : bool HasOnlyHidden(const ScDPUniqueStringSet& rVisible);
120 : :
121 : : long GetGroupCount() const;
122 : : const ScDPSaveGroupItem* GetGroupByIndex( long nIndex ) const;
123 : : ScDPSaveGroupItem* GetGroupAccByIndex( long nIndex );
124 : :
125 : : void Rename( const rtl::OUString& rNewName );
126 : :
127 : : private:
128 : : bool IsInGroup(const ScDPItemData& rItem) const;
129 : : };
130 : :
131 : : /**
132 : : * Represents a group dimension that introduces a new hierarchy for an
133 : : * existing dimension. Unlike the ScDPSaveGroupDimension counterpart, it
134 : : * re-uses the source dimension name and ID.
135 : : */
136 [ # # ][ # # ]: 12 : class SC_DLLPUBLIC ScDPSaveNumGroupDimension
[ + - ][ + - ]
137 : : {
138 : : rtl::OUString aDimensionName;
139 : : mutable ScDPNumGroupInfo aGroupInfo;
140 : : mutable ScDPNumGroupInfo aDateInfo;
141 : : sal_Int32 nDatePart;
142 : :
143 : : public:
144 : : ScDPSaveNumGroupDimension( const rtl::OUString& rName, const ScDPNumGroupInfo& rInfo );
145 : : ScDPSaveNumGroupDimension( const rtl::OUString& rName, const ScDPNumGroupInfo& rDateInfo, sal_Int32 nPart );
146 : : ~ScDPSaveNumGroupDimension();
147 : :
148 : : void AddToData( ScDPGroupTableData& rData ) const;
149 : : void AddToCache(ScDPCache& rCache) const;
150 : :
151 : 12 : const rtl::OUString& GetDimensionName() const { return aDimensionName; }
152 : 0 : const ScDPNumGroupInfo& GetInfo() const { return aGroupInfo; }
153 : :
154 : 0 : sal_Int32 GetDatePart() const { return nDatePart; }
155 : 0 : const ScDPNumGroupInfo& GetDateInfo() const { return aDateInfo; }
156 : :
157 : : void SetGroupInfo( const ScDPNumGroupInfo& rNew );
158 : : void SetDateInfo( const ScDPNumGroupInfo& rInfo, sal_Int32 nPart );
159 : : };
160 : :
161 : : /**
162 : : * This class has to do with handling exclusively grouped dimensions? TODO:
163 : : * Find out what this class does and document it here.
164 : : */
165 [ + - ]: 5 : class SC_DLLPUBLIC ScDPDimensionSaveData
166 : : {
167 : : public:
168 : : ScDPDimensionSaveData();
169 : : ~ScDPDimensionSaveData();
170 : :
171 : : bool operator==( const ScDPDimensionSaveData& r ) const;
172 : :
173 : : void WriteToData( ScDPGroupTableData& rData ) const;
174 : :
175 : : void WriteToCache(ScDPCache& rCache) const;
176 : :
177 : : rtl::OUString CreateGroupDimName(
178 : : const rtl::OUString& rSourceName, const ScDPObject& rObject, bool bAllowSource,
179 : : const ::std::vector<rtl::OUString>* pDeletedNames );
180 : :
181 : : rtl::OUString CreateDateGroupDimName(
182 : : sal_Int32 nDatePart, const ScDPObject& rObject, bool bAllowSource,
183 : : const ::std::vector<rtl::OUString>* pDeletedNames );
184 : :
185 : : void AddGroupDimension( const ScDPSaveGroupDimension& rGroupDim );
186 : : void ReplaceGroupDimension( const ScDPSaveGroupDimension& rGroupDim );
187 : : void RemoveGroupDimension( const rtl::OUString& rGroupDimName );
188 : :
189 : : void AddNumGroupDimension( const ScDPSaveNumGroupDimension& rGroupDim );
190 : : void ReplaceNumGroupDimension( const ScDPSaveNumGroupDimension& rGroupDim );
191 : : void RemoveNumGroupDimension( const rtl::OUString& rGroupDimName );
192 : :
193 : : const ScDPSaveGroupDimension* GetGroupDimForBase( const rtl::OUString& rBaseDimName ) const;
194 : : const ScDPSaveGroupDimension* GetNamedGroupDim( const rtl::OUString& rGroupDimName ) const;
195 : : const ScDPSaveGroupDimension* GetFirstNamedGroupDim( const rtl::OUString& rBaseDimName ) const;
196 : : const ScDPSaveGroupDimension* GetNextNamedGroupDim( const rtl::OUString& rGroupDimName ) const;
197 : : const ScDPSaveNumGroupDimension* GetNumGroupDim( const rtl::OUString& rGroupDimName ) const;
198 : :
199 : : ScDPSaveGroupDimension* GetGroupDimAccForBase( const rtl::OUString& rBaseDimName );
200 : : ScDPSaveGroupDimension* GetNamedGroupDimAcc( const rtl::OUString& rGroupDimName );
201 : : ScDPSaveGroupDimension* GetFirstNamedGroupDimAcc( const rtl::OUString& rBaseDimName );
202 : : ScDPSaveGroupDimension* GetNextNamedGroupDimAcc( const rtl::OUString& rGroupDimName );
203 : :
204 : : ScDPSaveNumGroupDimension* GetNumGroupDimAcc( const rtl::OUString& rGroupDimName );
205 : :
206 : : bool HasGroupDimensions() const;
207 : :
208 : : sal_Int32 CollectDateParts( const rtl::OUString& rBaseDimName ) const;
209 : :
210 : : private:
211 : : typedef ::std::vector< ScDPSaveGroupDimension > ScDPSaveGroupDimVec;
212 : : typedef ::std::map<rtl::OUString, ScDPSaveNumGroupDimension> ScDPSaveNumGroupDimMap;
213 : :
214 : : ScDPDimensionSaveData& operator=( const ScDPDimensionSaveData& );
215 : :
216 : : ScDPSaveGroupDimVec maGroupDims;
217 : : ScDPSaveNumGroupDimMap maNumGroupDims;
218 : : };
219 : :
220 : : #endif
221 : :
222 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|