xref: /aoo41x/main/sc/inc/dpsave.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_DPSAVE_HXX
25cdf0e10cSrcweir #define SC_DPSAVE_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <tools/string.hxx>
28cdf0e10cSrcweir #include <tools/list.hxx>
29cdf0e10cSrcweir #include <com/sun/star/sheet/XDimensionsSupplier.hpp>
30cdf0e10cSrcweir #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
31cdf0e10cSrcweir #include "scdllapi.h"
32cdf0e10cSrcweir #include <hash_map>
33cdf0e10cSrcweir #include <list>
34cdf0e10cSrcweir #include <memory>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace sheet {
37cdf0e10cSrcweir     struct DataPilotFieldReference;
38cdf0e10cSrcweir     struct DataPilotFieldSortInfo;
39cdf0e10cSrcweir     struct DataPilotFieldAutoShowInfo;
40cdf0e10cSrcweir     struct DataPilotFieldLayoutInfo;
41cdf0e10cSrcweir } } } }
42cdf0e10cSrcweir 
43cdf0e10cSrcweir class ScDPDimensionSaveData;
44cdf0e10cSrcweir class ScDPTableData;
45cdf0e10cSrcweir class ScDPObject;
46cdf0e10cSrcweir 
47cdf0e10cSrcweir // --------------------------------------------------------------------
48cdf0e10cSrcweir //
49cdf0e10cSrcweir //	classes to save Data Pilot settings
50cdf0e10cSrcweir //
51cdf0e10cSrcweir 
52cdf0e10cSrcweir 
53cdf0e10cSrcweir class ScDPSaveMember
54cdf0e10cSrcweir {
55cdf0e10cSrcweir private:
56cdf0e10cSrcweir 	String		aName;
57cdf0e10cSrcweir     ::std::auto_ptr<rtl::OUString> mpLayoutName; // custom name to be displayed in the table.
58cdf0e10cSrcweir 	sal_uInt16		nVisibleMode;
59cdf0e10cSrcweir 	sal_uInt16		nShowDetailsMode;
60cdf0e10cSrcweir 
61cdf0e10cSrcweir public:
62cdf0e10cSrcweir 							ScDPSaveMember(const String& rName);
63cdf0e10cSrcweir 							ScDPSaveMember(const ScDPSaveMember& r);
64cdf0e10cSrcweir 							~ScDPSaveMember();
65cdf0e10cSrcweir 
66cdf0e10cSrcweir 	sal_Bool		 			operator== ( const ScDPSaveMember& r ) const;
67cdf0e10cSrcweir 
GetName() const68cdf0e10cSrcweir     const String&           GetName() const { return aName; }
69cdf0e10cSrcweir     SC_DLLPUBLIC sal_Bool   HasIsVisible() const;
70cdf0e10cSrcweir     SC_DLLPUBLIC void		SetIsVisible(sal_Bool bSet);
GetIsVisible() const71cdf0e10cSrcweir     sal_Bool                GetIsVisible() const { return sal_Bool(nVisibleMode); }
72cdf0e10cSrcweir     SC_DLLPUBLIC sal_Bool   HasShowDetails() const;
73cdf0e10cSrcweir     SC_DLLPUBLIC void		SetShowDetails(sal_Bool bSet);
GetShowDetails() const74cdf0e10cSrcweir     sal_Bool                GetShowDetails() const { return sal_Bool(nShowDetailsMode); }
75cdf0e10cSrcweir 
76cdf0e10cSrcweir     void                    SetName( const String& rNew );  // used if the source member was renamed (groups)
77cdf0e10cSrcweir 
78cdf0e10cSrcweir     SC_DLLPUBLIC void       SetLayoutName( const ::rtl::OUString& rName );
79cdf0e10cSrcweir     SC_DLLPUBLIC const ::rtl::OUString*  GetLayoutName() const;
80cdf0e10cSrcweir     void                    RemoveLayoutName();
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 	void					WriteToSource( const com::sun::star::uno::Reference<
83cdf0e10cSrcweir                                             com::sun::star::uno::XInterface>& xMember,
84cdf0e10cSrcweir                                             sal_Int32 nPosition );
85cdf0e10cSrcweir };
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 
88cdf0e10cSrcweir bool operator == (const ::com::sun::star::sheet::DataPilotFieldSortInfo &l, const ::com::sun::star::sheet::DataPilotFieldSortInfo &r );
89cdf0e10cSrcweir bool operator == (const ::com::sun::star::sheet::DataPilotFieldAutoShowInfo &l, const ::com::sun::star::sheet::DataPilotFieldAutoShowInfo &r );
90cdf0e10cSrcweir bool operator == (const ::com::sun::star::sheet::DataPilotFieldReference &l, const ::com::sun::star::sheet::DataPilotFieldReference &r );
91cdf0e10cSrcweir class SC_DLLPUBLIC ScDPSaveDimension
92cdf0e10cSrcweir {
93cdf0e10cSrcweir private:
94cdf0e10cSrcweir 	String		aName;
95cdf0e10cSrcweir 	String*		pSelectedPage;
96cdf0e10cSrcweir     ::std::auto_ptr<rtl::OUString> mpLayoutName;
97cdf0e10cSrcweir     ::std::auto_ptr<rtl::OUString> mpSubtotalName;
98cdf0e10cSrcweir 	sal_Bool		bIsDataLayout;
99cdf0e10cSrcweir 	sal_Bool		bDupFlag;
100cdf0e10cSrcweir 	sal_uInt16		nOrientation;
101cdf0e10cSrcweir 	sal_uInt16		nFunction;			// enum GeneralFunction, for data dimensions
102cdf0e10cSrcweir 	long		nUsedHierarchy;
103cdf0e10cSrcweir 	sal_uInt16		nShowEmptyMode;		//!	at level
104cdf0e10cSrcweir 	sal_Bool		bSubTotalDefault;	//!	at level
105cdf0e10cSrcweir 	long		nSubTotalCount;
106cdf0e10cSrcweir 	sal_uInt16*		pSubTotalFuncs;		// enum GeneralFunction
107cdf0e10cSrcweir 	::com::sun::star::sheet::DataPilotFieldReference* pReferenceValue;
108cdf0e10cSrcweir     ::com::sun::star::sheet::DataPilotFieldSortInfo*  pSortInfo;            // (level)
109cdf0e10cSrcweir     ::com::sun::star::sheet::DataPilotFieldAutoShowInfo* pAutoShowInfo;     // (level)
110cdf0e10cSrcweir     ::com::sun::star::sheet::DataPilotFieldLayoutInfo* pLayoutInfo;         // (level)
111cdf0e10cSrcweir 
112cdf0e10cSrcweir public:
113cdf0e10cSrcweir     typedef	std::hash_map <String, ScDPSaveMember*, rtl::OUStringHash> MemberHash;
114cdf0e10cSrcweir     typedef	std::list <ScDPSaveMember*>                                MemberList;
115cdf0e10cSrcweir private:
116cdf0e10cSrcweir     MemberHash maMemberHash;
117cdf0e10cSrcweir     MemberList maMemberList;
118cdf0e10cSrcweir public:
119cdf0e10cSrcweir 							ScDPSaveDimension(const String& rName, sal_Bool bDataLayout);
120cdf0e10cSrcweir 							ScDPSaveDimension(const ScDPSaveDimension& r);
121cdf0e10cSrcweir 							~ScDPSaveDimension();
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 	sal_Bool		 			operator== ( const ScDPSaveDimension& r ) const;
124cdf0e10cSrcweir 
GetMembers() const125cdf0e10cSrcweir     const MemberList&       GetMembers() const { return maMemberList; }
126cdf0e10cSrcweir 	void					AddMember(ScDPSaveMember* pMember);
127cdf0e10cSrcweir 
SetDupFlag(sal_Bool bSet)128cdf0e10cSrcweir 	void					SetDupFlag(sal_Bool bSet)	{ bDupFlag = bSet; }
GetDupFlag() const129cdf0e10cSrcweir 	sal_Bool					GetDupFlag() const		{ return bDupFlag; }
130cdf0e10cSrcweir 
GetName() const131cdf0e10cSrcweir 	const String&			GetName() const			{ return aName; }
IsDataLayout() const132cdf0e10cSrcweir 	sal_Bool					IsDataLayout() const	{ return bIsDataLayout; }
133cdf0e10cSrcweir 
134cdf0e10cSrcweir     void                    SetName( const String& rNew );  // used if the source dim was renamed (groups)
135cdf0e10cSrcweir 
136cdf0e10cSrcweir     void					SetOrientation(sal_uInt16 nNew);
137cdf0e10cSrcweir     void					SetSubTotals(long nCount, const sal_uInt16* pFuncs);
GetSubTotalsCount() const138cdf0e10cSrcweir     long                    GetSubTotalsCount() const { return nSubTotalCount; }
GetSubTotalFunc(long nIndex) const139cdf0e10cSrcweir     sal_uInt16                  GetSubTotalFunc(long nIndex) const { return pSubTotalFuncs[nIndex]; }
140cdf0e10cSrcweir     bool                    HasShowEmpty() const;
141cdf0e10cSrcweir     void					SetShowEmpty(sal_Bool bSet);
GetShowEmpty() const142cdf0e10cSrcweir     sal_Bool                    GetShowEmpty() const { return sal_Bool(nShowEmptyMode); }
143cdf0e10cSrcweir     void					SetFunction(sal_uInt16 nNew);		// enum GeneralFunction
GetFunction() const144cdf0e10cSrcweir     sal_uInt16                  GetFunction() const { return nFunction; }
145cdf0e10cSrcweir 	void					SetUsedHierarchy(long nNew);
GetUsedHierarchy() const146cdf0e10cSrcweir     long                    GetUsedHierarchy() const { return nUsedHierarchy; }
147cdf0e10cSrcweir 
148cdf0e10cSrcweir     void                    SetLayoutName(const ::rtl::OUString& rName);
149cdf0e10cSrcweir     const ::rtl::OUString*  GetLayoutName() const;
150cdf0e10cSrcweir     void                    RemoveLayoutName();
151cdf0e10cSrcweir     void                    SetSubtotalName(const ::rtl::OUString& rName);
152cdf0e10cSrcweir     const ::rtl::OUString*  GetSubtotalName() const;
153cdf0e10cSrcweir 
154cdf0e10cSrcweir     bool                    IsMemberNameInUse(const ::rtl::OUString& rName) const;
155cdf0e10cSrcweir 
GetReferenceValue() const156cdf0e10cSrcweir 	const ::com::sun::star::sheet::DataPilotFieldReference* GetReferenceValue() const	{ return pReferenceValue; }
157cdf0e10cSrcweir     void					SetReferenceValue(const ::com::sun::star::sheet::DataPilotFieldReference* pNew);
158cdf0e10cSrcweir 
GetSortInfo() const159cdf0e10cSrcweir     const ::com::sun::star::sheet::DataPilotFieldSortInfo* GetSortInfo() const          { return pSortInfo; }
160cdf0e10cSrcweir     void                    SetSortInfo(const ::com::sun::star::sheet::DataPilotFieldSortInfo* pNew);
GetAutoShowInfo() const161cdf0e10cSrcweir     const ::com::sun::star::sheet::DataPilotFieldAutoShowInfo* GetAutoShowInfo() const  { return pAutoShowInfo; }
162cdf0e10cSrcweir     void                    SetAutoShowInfo(const ::com::sun::star::sheet::DataPilotFieldAutoShowInfo* pNew);
GetLayoutInfo() const163cdf0e10cSrcweir     const ::com::sun::star::sheet::DataPilotFieldLayoutInfo* GetLayoutInfo() const      { return pLayoutInfo; }
164cdf0e10cSrcweir     void                    SetLayoutInfo(const ::com::sun::star::sheet::DataPilotFieldLayoutInfo* pNew);
165cdf0e10cSrcweir 
166cdf0e10cSrcweir     void					SetCurrentPage( const String* pPage );		// NULL = no selection (all)
167cdf0e10cSrcweir     sal_Bool					HasCurrentPage() const;
168cdf0e10cSrcweir     const String&			GetCurrentPage() const;
169cdf0e10cSrcweir 
GetOrientation() const170cdf0e10cSrcweir 	sal_uInt16					GetOrientation() const	{ return nOrientation; }
171cdf0e10cSrcweir 
172cdf0e10cSrcweir 	ScDPSaveMember* 		GetExistingMemberByName(const String& rName);
173cdf0e10cSrcweir     ScDPSaveMember*			GetMemberByName(const String& rName);
174cdf0e10cSrcweir 
175cdf0e10cSrcweir     void                    SetMemberPosition( const String& rName, sal_Int32 nNewPos );
176cdf0e10cSrcweir 
177cdf0e10cSrcweir 	void					WriteToSource( const com::sun::star::uno::Reference<
178cdf0e10cSrcweir 											com::sun::star::uno::XInterface>& xDim );
179cdf0e10cSrcweir 	void					Refresh( const com::sun::star::uno::Reference<
180cdf0e10cSrcweir 									com::sun::star::sheet::XDimensionsSupplier>& xSource ,
181cdf0e10cSrcweir 									const	std::list<String> & deletedDims);
182cdf0e10cSrcweir 
183cdf0e10cSrcweir     void                    UpdateMemberVisibility(const ::std::hash_map< ::rtl::OUString, bool, ::rtl::OUStringHash>& rData);
184cdf0e10cSrcweir 
185cdf0e10cSrcweir     bool                    HasInvisibleMember() const;
186cdf0e10cSrcweir };
187cdf0e10cSrcweir 
188cdf0e10cSrcweir 
189cdf0e10cSrcweir class ScDPSaveData
190cdf0e10cSrcweir {
191cdf0e10cSrcweir private:
192cdf0e10cSrcweir 	List		aDimList;
193cdf0e10cSrcweir     ScDPDimensionSaveData* pDimensionData;      // settings that create new dimensions
194cdf0e10cSrcweir 	sal_uInt16		nColumnGrandMode;
195cdf0e10cSrcweir 	sal_uInt16		nRowGrandMode;
196cdf0e10cSrcweir 	sal_uInt16		nIgnoreEmptyMode;
197cdf0e10cSrcweir 	sal_uInt16		nRepeatEmptyMode;
198cdf0e10cSrcweir     sal_Bool        bFilterButton;      // not passed to DataPilotSource
199cdf0e10cSrcweir     sal_Bool        bDrillDown;         // not passed to DataPilotSource
200cdf0e10cSrcweir     // Wang Xu Ming -- 2009-8-17
201cdf0e10cSrcweir     // DataPilot Migration - Cache&&Performance
202cdf0e10cSrcweir     long      mnCacheId;
203cdf0e10cSrcweir     // End Comments
204cdf0e10cSrcweir 
205cdf0e10cSrcweir     /** if true, all dimensions already have all of their member instances
206cdf0e10cSrcweir      *  created. */
207cdf0e10cSrcweir     bool        mbDimensionMembersBuilt;
208cdf0e10cSrcweir 
209cdf0e10cSrcweir     ::std::auto_ptr<rtl::OUString> mpGrandTotalName;
210cdf0e10cSrcweir 
211cdf0e10cSrcweir public:
212cdf0e10cSrcweir     SC_DLLPUBLIC						ScDPSaveData();
213cdf0e10cSrcweir 							ScDPSaveData(const ScDPSaveData& r);
214cdf0e10cSrcweir     SC_DLLPUBLIC						~ScDPSaveData();
215cdf0e10cSrcweir 
216cdf0e10cSrcweir 	ScDPSaveData& 			operator= ( const ScDPSaveData& r );
217cdf0e10cSrcweir 
218cdf0e10cSrcweir 	sal_Bool		 			operator== ( const ScDPSaveData& r ) const;
219cdf0e10cSrcweir 
220cdf0e10cSrcweir     SC_DLLPUBLIC void                    SetGrandTotalName(const ::rtl::OUString& rName);
221cdf0e10cSrcweir     SC_DLLPUBLIC const ::rtl::OUString*  GetGrandTotalName() const;
222cdf0e10cSrcweir 
GetDimensions() const223cdf0e10cSrcweir 	const List&				GetDimensions() const { return aDimList; }
AddDimension(ScDPSaveDimension * pDim)224cdf0e10cSrcweir 	void					AddDimension(ScDPSaveDimension* pDim) { aDimList.Insert(pDim, LIST_APPEND); }
225cdf0e10cSrcweir 
226cdf0e10cSrcweir 	ScDPSaveDimension*		GetDimensionByName(const String& rName);
227cdf0e10cSrcweir     SC_DLLPUBLIC ScDPSaveDimension*		GetDataLayoutDimension();
228cdf0e10cSrcweir     SC_DLLPUBLIC ScDPSaveDimension*      GetExistingDataLayoutDimension() const;
229cdf0e10cSrcweir 
230cdf0e10cSrcweir 	ScDPSaveDimension*		DuplicateDimension(const String& rName);
231cdf0e10cSrcweir     SC_DLLPUBLIC ScDPSaveDimension&      DuplicateDimension(const ScDPSaveDimension& rDim);
232cdf0e10cSrcweir 
233cdf0e10cSrcweir     SC_DLLPUBLIC ScDPSaveDimension*		GetExistingDimensionByName(const String& rName) const;
234cdf0e10cSrcweir     SC_DLLPUBLIC ScDPSaveDimension*		GetNewDimensionByName(const String& rName);
235cdf0e10cSrcweir 
236cdf0e10cSrcweir     void                    RemoveDimensionByName(const String& rName);
237cdf0e10cSrcweir 
238cdf0e10cSrcweir     ScDPSaveDimension*      GetInnermostDimension(sal_uInt16 nOrientation);
239cdf0e10cSrcweir     ScDPSaveDimension*      GetFirstDimension(::com::sun::star::sheet::DataPilotFieldOrientation eOrientation);
240cdf0e10cSrcweir     long                    GetDataDimensionCount() const;
241cdf0e10cSrcweir 
242cdf0e10cSrcweir 
243cdf0e10cSrcweir 	void					SetPosition( ScDPSaveDimension* pDim, long nNew );
244cdf0e10cSrcweir     SC_DLLPUBLIC void					SetColumnGrand( sal_Bool bSet );
GetColumnGrand() const245cdf0e10cSrcweir 	sal_Bool					GetColumnGrand() const { return sal_Bool(nColumnGrandMode); }
246cdf0e10cSrcweir     SC_DLLPUBLIC void					SetRowGrand( sal_Bool bSet );
GetRowGrand() const247cdf0e10cSrcweir 	sal_Bool					GetRowGrand() const { return sal_Bool(nRowGrandMode); }
248cdf0e10cSrcweir 	void					SetIgnoreEmptyRows( sal_Bool bSet );
GetIgnoreEmptyRows() const249cdf0e10cSrcweir 	sal_Bool					GetIgnoreEmptyRows() const { return sal_Bool(nIgnoreEmptyMode); }
250cdf0e10cSrcweir 	void					SetRepeatIfEmpty( sal_Bool bSet );
GetRepeatIfEmpty() const251cdf0e10cSrcweir 	sal_Bool					GetRepeatIfEmpty() const { return sal_Bool(nRepeatEmptyMode); }
252cdf0e10cSrcweir 
253cdf0e10cSrcweir     SC_DLLPUBLIC void                    SetFilterButton( sal_Bool bSet );
GetFilterButton() const254cdf0e10cSrcweir     sal_Bool                    GetFilterButton() const { return bFilterButton; }
255cdf0e10cSrcweir     SC_DLLPUBLIC void                    SetDrillDown( sal_Bool bSet );
GetDrillDown() const256cdf0e10cSrcweir     sal_Bool                    GetDrillDown() const { return bDrillDown; }
257cdf0e10cSrcweir 
258cdf0e10cSrcweir 	void					WriteToSource( const com::sun::star::uno::Reference<
259cdf0e10cSrcweir 		com::sun::star::sheet::XDimensionsSupplier>& xSource );
260cdf0e10cSrcweir     // Wang Xu Ming -- 2009-8-17
261cdf0e10cSrcweir     // DataPilot Migration - Cache&&Performance
262cdf0e10cSrcweir 	void					Refresh( const com::sun::star::uno::Reference<
263cdf0e10cSrcweir 											com::sun::star::sheet::XDimensionsSupplier>& xSource );
264cdf0e10cSrcweir 	sal_Bool					IsEmpty() const;
GetCacheId() const265cdf0e10cSrcweir     inline long GetCacheId() const{ return mnCacheId; }
SetCacheId(long nCacheId)266cdf0e10cSrcweir     inline void SetCacheId( long nCacheId ){ mnCacheId = nCacheId; }
267cdf0e10cSrcweir     // End Comments
GetExistingDimensionData() const268cdf0e10cSrcweir     const ScDPDimensionSaveData* GetExistingDimensionData() const   { return pDimensionData; }
269cdf0e10cSrcweir     SC_DLLPUBLIC ScDPDimensionSaveData*  GetDimensionData();     // create if not there
270cdf0e10cSrcweir     void                    SetDimensionData( const ScDPDimensionSaveData* pNew );      // copied
271cdf0e10cSrcweir     void                    BuildAllDimensionMembers(ScDPTableData* pData);
272cdf0e10cSrcweir     void                    BuildAllDimensionMembersFromSource(ScDPObject* pDPObj);
273cdf0e10cSrcweir 
274cdf0e10cSrcweir     /**
275cdf0e10cSrcweir      * Check whether a dimension has one or more invisible members.
276cdf0e10cSrcweir      *
277cdf0e10cSrcweir      * @param rDimName dimension name
278cdf0e10cSrcweir      */
279cdf0e10cSrcweir     SC_DLLPUBLIC bool       HasInvisibleMember(const ::rtl::OUString& rDimName) const;
280cdf0e10cSrcweir };
281cdf0e10cSrcweir 
282cdf0e10cSrcweir 
283cdf0e10cSrcweir #endif
284cdf0e10cSrcweir 
285