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 $
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
35 #include <tools/string.hxx>
36 #include "dpgroup.hxx" // for ScDPNumGroupInfo
39 class ScDPGroupTableData
;
40 class ScDPGroupDimension
;
42 class ScStrCollection
;
43 class SvNumberFormatter
;
45 class ScDPSaveGroupDimension
;
47 // --------------------------------------------------------------------
49 // Classes to save Data Pilot settings that create new dimensions (fields).
50 // These have to be applied before the other ScDPSaveData settings.
53 class SC_DLLPUBLIC ScDPSaveGroupItem
55 String aGroupName
; // name of group
56 ::std::vector
<String
> aElements
; // names of items in original dimension
59 ScDPSaveGroupItem( const String
& rName
);
60 ScDPSaveGroupItem( const ScDPSaveGroupItem
& r
);
63 void AddToData( ScDPGroupDimension
& rDataDim
, SvNumberFormatter
* pFormatter
) const;
65 void AddElement( const String
& rName
);
66 void AddElementsFromGroup( const ScDPSaveGroupItem
& rGroup
);
67 const String
& GetGroupName() const { return aGroupName
; }
68 bool RemoveElement( const String
& rName
); // returns true if found (removed)
71 size_t GetElementCount() const;
72 const String
* GetElementByIndex( size_t nIndex
) const;
74 void Rename( const String
& rNewName
);
76 // remove this group's elements from their groups in rDimension
77 // (rDimension must be a different dimension from the one which contains this)
78 void RemoveElementsFromGroups( ScDPSaveGroupDimension
& rDimension
) const;
81 typedef ::std::vector
<ScDPSaveGroupItem
> ScDPSaveGroupItemVec
;
83 class SC_DLLPUBLIC ScDPSaveGroupDimension
85 String aSourceDim
; // always the real source from the original data
87 ScDPSaveGroupItemVec aGroups
;
88 ScDPNumGroupInfo aDateInfo
;
92 ScDPSaveGroupDimension( const String
& rSource
, const String
& rName
);
93 ScDPSaveGroupDimension( const ScDPSaveGroupDimension
& r
);
94 ~ScDPSaveGroupDimension();
96 void AddToData( ScDPGroupTableData
& rData
) const;
98 void SetDateInfo( const ScDPNumGroupInfo
& rInfo
, sal_Int32 nPart
);
100 void AddGroupItem( const ScDPSaveGroupItem
& rItem
);
101 const String
& GetGroupDimName() const { return aGroupDimName
; }
102 const String
& GetSourceDimName() const { return aSourceDim
; }
104 sal_Int32
GetDatePart() const { return nDatePart
; }
105 const ScDPNumGroupInfo
& GetDateInfo() const { return aDateInfo
; }
107 String
CreateGroupName( const String
& rPrefix
);
108 const ScDPSaveGroupItem
* GetNamedGroup( const String
& rGroupName
) const;
109 ScDPSaveGroupItem
* GetNamedGroupAcc( const String
& rGroupName
);
110 void RemoveFromGroups( const String
& rItemName
);
111 void RemoveGroup( const String
& rGroupName
);
112 bool IsEmpty() const;
113 bool HasOnlyHidden( const ScStrCollection
& rVisible
);
115 long GetGroupCount() const;
116 const ScDPSaveGroupItem
* GetGroupByIndex( long nIndex
) const;
117 ScDPSaveGroupItem
* GetGroupAccByIndex( long nIndex
);
119 void Rename( const String
& rNewName
);
122 typedef ::std::vector
<ScDPSaveGroupDimension
> ScDPSaveGroupDimensionVec
;
124 class SC_DLLPUBLIC ScDPSaveNumGroupDimension
126 String aDimensionName
;
127 ScDPNumGroupInfo aGroupInfo
;
128 ScDPNumGroupInfo aDateInfo
;
132 ScDPSaveNumGroupDimension( const String
& rName
, const ScDPNumGroupInfo
& rInfo
);
133 ScDPSaveNumGroupDimension( const ScDPSaveNumGroupDimension
& r
);
134 ~ScDPSaveNumGroupDimension();
136 void AddToData( ScDPGroupTableData
& rData
) const;
138 const String
& GetDimensionName() const { return aDimensionName
; }
139 const ScDPNumGroupInfo
& GetInfo() const { return aGroupInfo
; }
141 sal_Int32
GetDatePart() const { return nDatePart
; }
142 const ScDPNumGroupInfo
& GetDateInfo() const { return aDateInfo
; }
144 void SetGroupInfo( const ScDPNumGroupInfo
& rNew
);
145 void SetDateInfo( const ScDPNumGroupInfo
& rInfo
, sal_Int32 nPart
);
148 typedef ::std::vector
<ScDPSaveNumGroupDimension
> ScDPSaveNumGroupDimensionVec
;
150 class SC_DLLPUBLIC ScDPDimensionSaveData
152 ScDPSaveGroupDimensionVec aGroupDimensions
;
153 ScDPSaveNumGroupDimensionVec aNumGroupDimensions
;
157 ScDPDimensionSaveData
& operator=( const ScDPDimensionSaveData
& );
160 ScDPDimensionSaveData();
161 ScDPDimensionSaveData( const ScDPDimensionSaveData
& r
);
162 ~ScDPDimensionSaveData();
164 bool operator==( const ScDPDimensionSaveData
& r
) const;
166 void WriteToData( ScDPGroupTableData
& rData
) const;
168 String
CreateGroupDimName( const String
& rSourceName
, const ScDPObject
& rObject
, bool bAllowSource
,
169 const std::vector
<String
>* pDeletedNames
);
170 void AddGroupDimension( const ScDPSaveGroupDimension
& rGroup
);
171 void RemoveGroupDimension( const String
& rDimensionName
);
173 void AddNumGroupDimension( const ScDPSaveNumGroupDimension
& rGroup
);
174 void RemoveNumGroupDimension( const String
& rDimensionName
);
176 const ScDPSaveGroupDimension
* GetGroupDimForBase( const String
& rBaseName
) const;
177 const ScDPSaveGroupDimension
* GetNamedGroupDim( const String
& rGroupDim
) const;
178 const ScDPSaveNumGroupDimension
* GetNumGroupDim( const String
& rName
) const;
180 ScDPSaveGroupDimension
* GetGroupDimAccForBase( const String
& rBaseName
);
181 ScDPSaveGroupDimension
* GetNamedGroupDimAcc( const String
& rGroupDim
);
182 ScDPSaveNumGroupDimension
* GetNumGroupDimAcc( const String
& rName
);
184 bool HasGroupDimensions() const;
186 sal_Int32
CollectDateParts( const String
& rBaseDimName
) const;