update dev300-m58
[ooovba.git] / sc / inc / dpdimsave.hxx
blob4c711eb67eb7446521776129a723c9c5a3d87f90
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dpdimsave.hxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_DPDIMSAVE_HXX
32 #define SC_DPDIMSAVE_HXX
34 #include <vector>
35 #include <map>
36 #include <tools/string.hxx>
37 #include "dpgroup.hxx" // for ScDPNumGroupInfo
38 #include "scdllapi.h"
40 class ScDPGroupTableData;
41 class ScDPGroupDimension;
42 class ScDPObject;
43 class ScStrCollection;
44 class SvNumberFormatter;
46 class ScDPSaveGroupDimension;
48 // --------------------------------------------------------------------
50 // Classes to save Data Pilot settings that create new dimensions (fields).
51 // These have to be applied before the other ScDPSaveData settings.
54 // ============================================================================
56 class SC_DLLPUBLIC ScDPSaveGroupItem
58 String aGroupName; // name of group
59 ::std::vector<String> aElements; // names of items in original dimension
61 public:
62 ScDPSaveGroupItem( const String& rName );
63 ~ScDPSaveGroupItem();
65 void AddToData( ScDPGroupDimension& rDataDim, SvNumberFormatter* pFormatter ) const;
67 void AddElement( const String& rName );
68 void AddElementsFromGroup( const ScDPSaveGroupItem& rGroup );
69 const String& GetGroupName() const { return aGroupName; }
70 bool RemoveElement( const String& rName ); // returns true if found (removed)
72 bool IsEmpty() const;
73 size_t GetElementCount() const;
74 const String* GetElementByIndex( size_t nIndex ) const;
76 void Rename( const String& rNewName );
78 // remove this group's elements from their groups in rDimension
79 // (rDimension must be a different dimension from the one which contains this)
80 void RemoveElementsFromGroups( ScDPSaveGroupDimension& rDimension ) const;
83 typedef ::std::vector<ScDPSaveGroupItem> ScDPSaveGroupItemVec;
85 // ============================================================================
87 class SC_DLLPUBLIC ScDPSaveGroupDimension
89 String aSourceDim; // always the real source from the original data
90 String aGroupDimName;
91 ScDPSaveGroupItemVec aGroups;
92 ScDPNumGroupInfo aDateInfo;
93 sal_Int32 nDatePart;
95 public:
96 ScDPSaveGroupDimension( const String& rSource, const String& rName );
97 ScDPSaveGroupDimension( const String& rSource, const String& rName, const ScDPNumGroupInfo& rDateInfo, sal_Int32 nPart );
98 ~ScDPSaveGroupDimension();
100 void AddToData( ScDPGroupTableData& rData ) const;
102 void SetDateInfo( const ScDPNumGroupInfo& rInfo, sal_Int32 nPart );
104 void AddGroupItem( const ScDPSaveGroupItem& rItem );
105 const String& GetGroupDimName() const { return aGroupDimName; }
106 const String& GetSourceDimName() const { return aSourceDim; }
108 sal_Int32 GetDatePart() const { return nDatePart; }
109 const ScDPNumGroupInfo& GetDateInfo() const { return aDateInfo; }
111 String CreateGroupName( const String& rPrefix );
112 const ScDPSaveGroupItem* GetNamedGroup( const String& rGroupName ) const;
113 ScDPSaveGroupItem* GetNamedGroupAcc( const String& rGroupName );
114 void RemoveFromGroups( const String& rItemName );
115 void RemoveGroup( const String& rGroupName );
116 bool IsEmpty() const;
117 bool HasOnlyHidden( const ScStrCollection& rVisible );
119 long GetGroupCount() const;
120 const ScDPSaveGroupItem* GetGroupByIndex( long nIndex ) const;
121 ScDPSaveGroupItem* GetGroupAccByIndex( long nIndex );
123 void Rename( const String& rNewName );
126 // ============================================================================
128 class SC_DLLPUBLIC ScDPSaveNumGroupDimension
130 String aDimensionName;
131 ScDPNumGroupInfo aGroupInfo;
132 ScDPNumGroupInfo aDateInfo;
133 sal_Int32 nDatePart;
135 public:
136 ScDPSaveNumGroupDimension( const String& rName, const ScDPNumGroupInfo& rInfo );
137 ScDPSaveNumGroupDimension( const String& rName, const ScDPNumGroupInfo& rDateInfo, sal_Int32 nPart );
138 ~ScDPSaveNumGroupDimension();
140 void AddToData( ScDPGroupTableData& rData ) const;
142 const String& 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 );
152 // ============================================================================
154 class SC_DLLPUBLIC ScDPDimensionSaveData
156 public:
157 ScDPDimensionSaveData();
158 ~ScDPDimensionSaveData();
160 bool operator==( const ScDPDimensionSaveData& r ) const;
162 void WriteToData( ScDPGroupTableData& rData ) const;
164 String CreateGroupDimName( const String& rSourceName, const ScDPObject& rObject, bool bAllowSource, const ::std::vector< String >* pDeletedNames );
165 String CreateDateGroupDimName( sal_Int32 nDatePart, const ScDPObject& rObject, bool bAllowSource, const ::std::vector< String >* pDeletedNames );
167 void AddGroupDimension( const ScDPSaveGroupDimension& rGroupDim );
168 void ReplaceGroupDimension( const ScDPSaveGroupDimension& rGroupDim );
169 void RemoveGroupDimension( const String& rGroupDimName );
171 void AddNumGroupDimension( const ScDPSaveNumGroupDimension& rGroupDim );
172 void ReplaceNumGroupDimension( const ScDPSaveNumGroupDimension& rGroupDim );
173 void RemoveNumGroupDimension( const String& rGroupDimName );
175 const ScDPSaveGroupDimension* GetGroupDimForBase( const String& rBaseDimName ) const;
176 const ScDPSaveGroupDimension* GetNamedGroupDim( const String& rGroupDimName ) const;
177 const ScDPSaveGroupDimension* GetFirstNamedGroupDim( const String& rBaseDimName ) const;
178 const ScDPSaveGroupDimension* GetNextNamedGroupDim( const String& rGroupDimName ) const;
179 const ScDPSaveNumGroupDimension* GetNumGroupDim( const String& rGroupDimName ) const;
181 ScDPSaveGroupDimension* GetGroupDimAccForBase( const String& rBaseDimName );
182 ScDPSaveGroupDimension* GetNamedGroupDimAcc( const String& rGroupDimName );
183 ScDPSaveGroupDimension* GetFirstNamedGroupDimAcc( const String& rBaseDimName );
184 ScDPSaveGroupDimension* GetNextNamedGroupDimAcc( const String& rGroupDimName );
186 ScDPSaveNumGroupDimension* GetNumGroupDimAcc( const String& rGroupDimName );
188 bool HasGroupDimensions() const;
190 sal_Int32 CollectDateParts( const String& rBaseDimName ) const;
192 private:
193 typedef ::std::vector< ScDPSaveGroupDimension > ScDPSaveGroupDimVec;
194 typedef ::std::map< String, ScDPSaveNumGroupDimension > ScDPSaveNumGroupDimMap;
196 ScDPDimensionSaveData& operator=( const ScDPDimensionSaveData& );
198 ScDPSaveGroupDimVec maGroupDims;
199 ScDPSaveNumGroupDimMap maNumGroupDims;
202 // ============================================================================
204 #endif