xref: /aoo41x/main/sc/inc/dpdimsave.hxx (revision 38d50f7b)
1*38d50f7bSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*38d50f7bSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*38d50f7bSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*38d50f7bSAndrew Rist  * distributed with this work for additional information
6*38d50f7bSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*38d50f7bSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*38d50f7bSAndrew Rist  * "License"); you may not use this file except in compliance
9*38d50f7bSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*38d50f7bSAndrew Rist  *
11*38d50f7bSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*38d50f7bSAndrew Rist  *
13*38d50f7bSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*38d50f7bSAndrew Rist  * software distributed under the License is distributed on an
15*38d50f7bSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*38d50f7bSAndrew Rist  * KIND, either express or implied.  See the License for the
17*38d50f7bSAndrew Rist  * specific language governing permissions and limitations
18*38d50f7bSAndrew Rist  * under the License.
19*38d50f7bSAndrew Rist  *
20*38d50f7bSAndrew Rist  *************************************************************/
21*38d50f7bSAndrew Rist 
22*38d50f7bSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef SC_DPDIMSAVE_HXX
25cdf0e10cSrcweir #define SC_DPDIMSAVE_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <vector>
28cdf0e10cSrcweir #include <map>
29cdf0e10cSrcweir #include <tools/string.hxx>
30cdf0e10cSrcweir #include "dpgroup.hxx"      // for ScDPNumGroupInfo
31cdf0e10cSrcweir #include "scdllapi.h"
32cdf0e10cSrcweir 
33cdf0e10cSrcweir class ScDPGroupTableData;
34cdf0e10cSrcweir class ScDPGroupDimension;
35cdf0e10cSrcweir class ScDPObject;
36cdf0e10cSrcweir class ScStrCollection;
37cdf0e10cSrcweir class SvNumberFormatter;
38cdf0e10cSrcweir 
39cdf0e10cSrcweir class ScDPSaveGroupDimension;
40cdf0e10cSrcweir 
41cdf0e10cSrcweir // --------------------------------------------------------------------
42cdf0e10cSrcweir //
43cdf0e10cSrcweir //  Classes to save Data Pilot settings that create new dimensions (fields).
44cdf0e10cSrcweir //  These have to be applied before the other ScDPSaveData settings.
45cdf0e10cSrcweir //
46cdf0e10cSrcweir 
47cdf0e10cSrcweir // ============================================================================
48cdf0e10cSrcweir 
49cdf0e10cSrcweir class SC_DLLPUBLIC ScDPSaveGroupItem
50cdf0e10cSrcweir {
51cdf0e10cSrcweir     String                  aGroupName;     // name of group
52cdf0e10cSrcweir     ::std::vector<String>   aElements;      // names of items in original dimension
53cdf0e10cSrcweir 
54cdf0e10cSrcweir public:
55cdf0e10cSrcweir                 ScDPSaveGroupItem( const String& rName );
56cdf0e10cSrcweir                 ~ScDPSaveGroupItem();
57cdf0e10cSrcweir 
58cdf0e10cSrcweir     void    AddToData( ScDPGroupDimension& rDataDim, SvNumberFormatter* pFormatter ) const;
59cdf0e10cSrcweir 
60cdf0e10cSrcweir     void    AddElement( const String& rName );
61cdf0e10cSrcweir     void    AddElementsFromGroup( const ScDPSaveGroupItem& rGroup );
GetGroupName() const62cdf0e10cSrcweir     const String& GetGroupName() const   { return aGroupName; }
63cdf0e10cSrcweir     bool    RemoveElement( const String& rName );   // returns true if found (removed)
64cdf0e10cSrcweir 
65cdf0e10cSrcweir     bool    IsEmpty() const;
66cdf0e10cSrcweir     size_t  GetElementCount() const;
67cdf0e10cSrcweir     const String* GetElementByIndex( size_t nIndex ) const;
68cdf0e10cSrcweir 
69cdf0e10cSrcweir     void    Rename( const String& rNewName );
70cdf0e10cSrcweir 
71cdf0e10cSrcweir     // remove this group's elements from their groups in rDimension
72cdf0e10cSrcweir     // (rDimension must be a different dimension from the one which contains this)
73cdf0e10cSrcweir     void    RemoveElementsFromGroups( ScDPSaveGroupDimension& rDimension ) const;
74cdf0e10cSrcweir };
75cdf0e10cSrcweir 
76cdf0e10cSrcweir typedef ::std::vector<ScDPSaveGroupItem> ScDPSaveGroupItemVec;
77cdf0e10cSrcweir 
78cdf0e10cSrcweir // ============================================================================
79cdf0e10cSrcweir 
80cdf0e10cSrcweir class SC_DLLPUBLIC ScDPSaveGroupDimension
81cdf0e10cSrcweir {
82cdf0e10cSrcweir     String                  aSourceDim;     // always the real source from the original data
83cdf0e10cSrcweir     String                  aGroupDimName;
84cdf0e10cSrcweir     ScDPSaveGroupItemVec    aGroups;
85cdf0e10cSrcweir     ScDPNumGroupInfo        aDateInfo;
86cdf0e10cSrcweir     sal_Int32               nDatePart;
87cdf0e10cSrcweir 
88cdf0e10cSrcweir public:
89cdf0e10cSrcweir                 ScDPSaveGroupDimension( const String& rSource, const String& rName );
90cdf0e10cSrcweir                 ScDPSaveGroupDimension( const String& rSource, const String& rName, const ScDPNumGroupInfo& rDateInfo, sal_Int32 nPart );
91cdf0e10cSrcweir                 ~ScDPSaveGroupDimension();
92cdf0e10cSrcweir 
93cdf0e10cSrcweir     void    AddToData( ScDPGroupTableData& rData ) const;
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     void    SetDateInfo( const ScDPNumGroupInfo& rInfo, sal_Int32 nPart );
96cdf0e10cSrcweir 
97cdf0e10cSrcweir     void    AddGroupItem( const ScDPSaveGroupItem& rItem );
GetGroupDimName() const98cdf0e10cSrcweir     const String& GetGroupDimName() const   { return aGroupDimName; }
GetSourceDimName() const99cdf0e10cSrcweir     const String& GetSourceDimName() const  { return aSourceDim; }
100cdf0e10cSrcweir 
GetDatePart() const101cdf0e10cSrcweir     sal_Int32   GetDatePart() const             { return nDatePart; }
GetDateInfo() const102cdf0e10cSrcweir     const ScDPNumGroupInfo& GetDateInfo() const { return aDateInfo; }
103cdf0e10cSrcweir 
104cdf0e10cSrcweir     String  CreateGroupName( const String& rPrefix );
105cdf0e10cSrcweir     const ScDPSaveGroupItem* GetNamedGroup( const String& rGroupName ) const;
106cdf0e10cSrcweir     ScDPSaveGroupItem* GetNamedGroupAcc( const String& rGroupName );
107cdf0e10cSrcweir     void    RemoveFromGroups( const String& rItemName );
108cdf0e10cSrcweir     void    RemoveGroup( const String& rGroupName );
109cdf0e10cSrcweir     bool    IsEmpty() const;
110cdf0e10cSrcweir     bool    HasOnlyHidden( const ScStrCollection& rVisible );
111cdf0e10cSrcweir 
112cdf0e10cSrcweir     long    GetGroupCount() const;
113cdf0e10cSrcweir     const ScDPSaveGroupItem* GetGroupByIndex( long nIndex ) const;
114cdf0e10cSrcweir     ScDPSaveGroupItem* GetGroupAccByIndex( long nIndex );
115cdf0e10cSrcweir 
116cdf0e10cSrcweir     void    Rename( const String& rNewName );
117cdf0e10cSrcweir };
118cdf0e10cSrcweir 
119cdf0e10cSrcweir // ============================================================================
120cdf0e10cSrcweir 
121cdf0e10cSrcweir class SC_DLLPUBLIC ScDPSaveNumGroupDimension
122cdf0e10cSrcweir {
123cdf0e10cSrcweir     String              aDimensionName;
124cdf0e10cSrcweir     ScDPNumGroupInfo    aGroupInfo;
125cdf0e10cSrcweir     ScDPNumGroupInfo    aDateInfo;
126cdf0e10cSrcweir     sal_Int32           nDatePart;
127cdf0e10cSrcweir 
128cdf0e10cSrcweir public:
129cdf0e10cSrcweir                 ScDPSaveNumGroupDimension( const String& rName, const ScDPNumGroupInfo& rInfo );
130cdf0e10cSrcweir                 ScDPSaveNumGroupDimension( const String& rName, const ScDPNumGroupInfo& rDateInfo, sal_Int32 nPart );
131cdf0e10cSrcweir                 ~ScDPSaveNumGroupDimension();
132cdf0e10cSrcweir 
133cdf0e10cSrcweir     void        AddToData( ScDPGroupTableData& rData ) const;
134cdf0e10cSrcweir 
GetDimensionName() const135cdf0e10cSrcweir     const String& GetDimensionName() const  { return aDimensionName; }
GetInfo() const136cdf0e10cSrcweir     const ScDPNumGroupInfo& GetInfo() const { return aGroupInfo; }
137cdf0e10cSrcweir 
GetDatePart() const138cdf0e10cSrcweir     sal_Int32   GetDatePart() const             { return nDatePart; }
GetDateInfo() const139cdf0e10cSrcweir     const ScDPNumGroupInfo& GetDateInfo() const { return aDateInfo; }
140cdf0e10cSrcweir 
141cdf0e10cSrcweir     void        SetGroupInfo( const ScDPNumGroupInfo& rNew );
142cdf0e10cSrcweir     void        SetDateInfo( const ScDPNumGroupInfo& rInfo, sal_Int32 nPart );
143cdf0e10cSrcweir };
144cdf0e10cSrcweir 
145cdf0e10cSrcweir // ============================================================================
146cdf0e10cSrcweir 
147cdf0e10cSrcweir class SC_DLLPUBLIC ScDPDimensionSaveData
148cdf0e10cSrcweir {
149cdf0e10cSrcweir public:
150cdf0e10cSrcweir             ScDPDimensionSaveData();
151cdf0e10cSrcweir             ~ScDPDimensionSaveData();
152cdf0e10cSrcweir 
153cdf0e10cSrcweir     bool    operator==( const ScDPDimensionSaveData& r ) const;
154cdf0e10cSrcweir 
155cdf0e10cSrcweir     void    WriteToData( ScDPGroupTableData& rData ) const;
156cdf0e10cSrcweir 
157cdf0e10cSrcweir     String  CreateGroupDimName( const String& rSourceName, const ScDPObject& rObject, bool bAllowSource, const ::std::vector< String >* pDeletedNames );
158cdf0e10cSrcweir     String  CreateDateGroupDimName( sal_Int32 nDatePart, const ScDPObject& rObject, bool bAllowSource, const ::std::vector< String >* pDeletedNames );
159cdf0e10cSrcweir 
160cdf0e10cSrcweir     void    AddGroupDimension( const ScDPSaveGroupDimension& rGroupDim );
161cdf0e10cSrcweir     void    ReplaceGroupDimension( const ScDPSaveGroupDimension& rGroupDim );
162cdf0e10cSrcweir     void    RemoveGroupDimension( const String& rGroupDimName );
163cdf0e10cSrcweir 
164cdf0e10cSrcweir     void    AddNumGroupDimension( const ScDPSaveNumGroupDimension& rGroupDim );
165cdf0e10cSrcweir     void    ReplaceNumGroupDimension( const ScDPSaveNumGroupDimension& rGroupDim );
166cdf0e10cSrcweir     void    RemoveNumGroupDimension( const String& rGroupDimName );
167cdf0e10cSrcweir 
168cdf0e10cSrcweir     const ScDPSaveGroupDimension* GetGroupDimForBase( const String& rBaseDimName ) const;
169cdf0e10cSrcweir     const ScDPSaveGroupDimension* GetNamedGroupDim( const String& rGroupDimName ) const;
170cdf0e10cSrcweir     const ScDPSaveGroupDimension* GetFirstNamedGroupDim( const String& rBaseDimName ) const;
171cdf0e10cSrcweir     const ScDPSaveGroupDimension* GetNextNamedGroupDim( const String& rGroupDimName ) const;
172cdf0e10cSrcweir     const ScDPSaveNumGroupDimension* GetNumGroupDim( const String& rGroupDimName ) const;
173cdf0e10cSrcweir 
174cdf0e10cSrcweir     ScDPSaveGroupDimension* GetGroupDimAccForBase( const String& rBaseDimName );
175cdf0e10cSrcweir     ScDPSaveGroupDimension* GetNamedGroupDimAcc( const String& rGroupDimName );
176cdf0e10cSrcweir     ScDPSaveGroupDimension* GetFirstNamedGroupDimAcc( const String& rBaseDimName );
177cdf0e10cSrcweir     ScDPSaveGroupDimension* GetNextNamedGroupDimAcc( const String& rGroupDimName );
178cdf0e10cSrcweir 
179cdf0e10cSrcweir     ScDPSaveNumGroupDimension* GetNumGroupDimAcc( const String& rGroupDimName );
180cdf0e10cSrcweir 
181cdf0e10cSrcweir     bool    HasGroupDimensions() const;
182cdf0e10cSrcweir 
183cdf0e10cSrcweir     sal_Int32 CollectDateParts( const String& rBaseDimName ) const;
184cdf0e10cSrcweir 
185cdf0e10cSrcweir private:
186cdf0e10cSrcweir     typedef ::std::vector< ScDPSaveGroupDimension >         ScDPSaveGroupDimVec;
187cdf0e10cSrcweir     typedef ::std::map< String, ScDPSaveNumGroupDimension > ScDPSaveNumGroupDimMap;
188cdf0e10cSrcweir 
189cdf0e10cSrcweir     ScDPDimensionSaveData& operator=( const ScDPDimensionSaveData& );
190cdf0e10cSrcweir 
191cdf0e10cSrcweir     ScDPSaveGroupDimVec maGroupDims;
192cdf0e10cSrcweir     ScDPSaveNumGroupDimMap maNumGroupDims;
193cdf0e10cSrcweir };
194cdf0e10cSrcweir 
195cdf0e10cSrcweir // ============================================================================
196cdf0e10cSrcweir 
197cdf0e10cSrcweir #endif
198cdf0e10cSrcweir 
199