update dev300-m57
[ooovba.git] / sc / inc / dpsave.hxx
blob0f9c6fe85407086c6b0deb7e04c5638588e4a77e
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: dpsave.hxx,v $
10 * $Revision: 1.11.32.3 $
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_DPSAVE_HXX
32 #define SC_DPSAVE_HXX
34 #include <tools/string.hxx>
35 #include <tools/list.hxx>
36 #include <com/sun/star/sheet/XDimensionsSupplier.hpp>
37 #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
38 #include "scdllapi.h"
39 #include <hash_map>
40 #include <list>
41 #include <memory>
43 namespace com { namespace sun { namespace star { namespace sheet {
44 struct DataPilotFieldReference;
45 struct DataPilotFieldSortInfo;
46 struct DataPilotFieldAutoShowInfo;
47 struct DataPilotFieldLayoutInfo;
48 } } } }
50 class ScDPDimensionSaveData;
51 class ScDPTableData;
53 // --------------------------------------------------------------------
55 // classes to save Data Pilot settings
59 class ScDPSaveMember
61 private:
62 String aName;
63 ::std::auto_ptr<rtl::OUString> mpLayoutName; // custom name to be displayed in the table.
64 USHORT nVisibleMode;
65 USHORT nShowDetailsMode;
67 public:
68 ScDPSaveMember(const String& rName);
69 ScDPSaveMember(const ScDPSaveMember& r);
70 ~ScDPSaveMember();
72 BOOL operator== ( const ScDPSaveMember& r ) const;
74 const String& GetName() const { return aName; }
75 BOOL HasIsVisible() const;
76 SC_DLLPUBLIC void SetIsVisible(BOOL bSet);
77 BOOL GetIsVisible() const { return BOOL(nVisibleMode); }
78 BOOL HasShowDetails() const;
79 SC_DLLPUBLIC void SetShowDetails(BOOL bSet);
80 BOOL GetShowDetails() const { return BOOL(nShowDetailsMode); }
82 void SetName( const String& rNew ); // used if the source member was renamed (groups)
84 SC_DLLPUBLIC void SetLayoutName( const ::rtl::OUString& rName );
85 SC_DLLPUBLIC const ::rtl::OUString* GetLayoutName() const;
86 void RemoveLayoutName();
88 void WriteToSource( const com::sun::star::uno::Reference<
89 com::sun::star::uno::XInterface>& xMember,
90 sal_Int32 nPosition );
94 class SC_DLLPUBLIC ScDPSaveDimension
96 private:
97 String aName;
98 String* pSelectedPage;
99 ::std::auto_ptr<rtl::OUString> mpLayoutName;
100 ::std::auto_ptr<rtl::OUString> mpSubtotalName;
101 BOOL bIsDataLayout;
102 BOOL bDupFlag;
103 USHORT nOrientation;
104 USHORT nFunction; // enum GeneralFunction, for data dimensions
105 long nUsedHierarchy;
106 USHORT nShowEmptyMode; //! at level
107 BOOL bSubTotalDefault; //! at level
108 long nSubTotalCount;
109 USHORT* pSubTotalFuncs; // enum GeneralFunction
110 ::com::sun::star::sheet::DataPilotFieldReference* pReferenceValue;
111 ::com::sun::star::sheet::DataPilotFieldSortInfo* pSortInfo; // (level)
112 ::com::sun::star::sheet::DataPilotFieldAutoShowInfo* pAutoShowInfo; // (level)
113 ::com::sun::star::sheet::DataPilotFieldLayoutInfo* pLayoutInfo; // (level)
115 public:
116 typedef std::hash_map <String, ScDPSaveMember*, rtl::OUStringHash> MemberHash;
117 typedef std::list <ScDPSaveMember*> MemberList;
118 private:
119 MemberHash maMemberHash;
120 MemberList maMemberList;
121 public:
122 ScDPSaveDimension(const String& rName, BOOL bDataLayout);
123 ScDPSaveDimension(const ScDPSaveDimension& r);
124 ~ScDPSaveDimension();
126 BOOL operator== ( const ScDPSaveDimension& r ) const;
128 const MemberList& GetMembers() const { return maMemberList; }
129 void AddMember(ScDPSaveMember* pMember);
131 void SetDupFlag(BOOL bSet) { bDupFlag = bSet; }
132 BOOL GetDupFlag() const { return bDupFlag; }
134 const String& GetName() const { return aName; }
135 BOOL IsDataLayout() const { return bIsDataLayout; }
137 void SetName( const String& rNew ); // used if the source dim was renamed (groups)
139 void SetOrientation(USHORT nNew);
140 void SetSubTotals(long nCount, const USHORT* pFuncs);
141 long GetSubTotalsCount() const { return nSubTotalCount; }
142 USHORT GetSubTotalFunc(long nIndex) const { return pSubTotalFuncs[nIndex]; }
143 void SetShowEmpty(BOOL bSet);
144 BOOL GetShowEmpty() const { return BOOL(nShowEmptyMode); }
145 void SetFunction(USHORT nNew); // enum GeneralFunction
146 USHORT GetFunction() const { return nFunction; }
147 void SetUsedHierarchy(long nNew);
148 long GetUsedHierarchy() const { return nUsedHierarchy; }
150 void SetLayoutName(const ::rtl::OUString& rName);
151 const ::rtl::OUString* GetLayoutName() const;
152 void RemoveLayoutName();
153 void SetSubtotalName(const ::rtl::OUString& rName);
154 const ::rtl::OUString* GetSubtotalName() const;
156 bool IsMemberNameInUse(const ::rtl::OUString& rName) const;
158 const ::com::sun::star::sheet::DataPilotFieldReference* GetReferenceValue() const { return pReferenceValue; }
159 void SetReferenceValue(const ::com::sun::star::sheet::DataPilotFieldReference* pNew);
161 const ::com::sun::star::sheet::DataPilotFieldSortInfo* GetSortInfo() const { return pSortInfo; }
162 void SetSortInfo(const ::com::sun::star::sheet::DataPilotFieldSortInfo* pNew);
163 const ::com::sun::star::sheet::DataPilotFieldAutoShowInfo* GetAutoShowInfo() const { return pAutoShowInfo; }
164 void SetAutoShowInfo(const ::com::sun::star::sheet::DataPilotFieldAutoShowInfo* pNew);
165 const ::com::sun::star::sheet::DataPilotFieldLayoutInfo* GetLayoutInfo() const { return pLayoutInfo; }
166 void SetLayoutInfo(const ::com::sun::star::sheet::DataPilotFieldLayoutInfo* pNew);
168 void SetCurrentPage( const String* pPage ); // NULL = no selection (all)
169 BOOL HasCurrentPage() const;
170 const String& GetCurrentPage() const;
172 USHORT GetOrientation() const { return nOrientation; }
174 ScDPSaveMember* GetExistingMemberByName(const String& rName);
175 ScDPSaveMember* GetMemberByName(const String& rName);
177 void SetMemberPosition( const String& rName, sal_Int32 nNewPos );
179 void WriteToSource( const com::sun::star::uno::Reference<
180 com::sun::star::uno::XInterface>& xDim );
182 void UpdateMemberVisibility(const ::std::hash_map< ::rtl::OUString, bool, ::rtl::OUStringHash>& rData);
184 bool HasInvisibleMember() const;
188 class ScDPSaveData
190 private:
191 List aDimList;
192 ScDPDimensionSaveData* pDimensionData; // settings that create new dimensions
193 USHORT nColumnGrandMode;
194 USHORT nRowGrandMode;
195 USHORT nIgnoreEmptyMode;
196 USHORT nRepeatEmptyMode;
197 BOOL bFilterButton; // not passed to DataPilotSource
198 BOOL bDrillDown; // not passed to DataPilotSource
200 /** if true, all dimensions already have all of their member instances
201 * created. */
202 bool mbDimensionMembersBuilt;
204 ::std::auto_ptr<rtl::OUString> mpGrandTotalName;
206 public:
207 SC_DLLPUBLIC ScDPSaveData();
208 ScDPSaveData(const ScDPSaveData& r);
209 SC_DLLPUBLIC ~ScDPSaveData();
211 ScDPSaveData& operator= ( const ScDPSaveData& r );
213 BOOL operator== ( const ScDPSaveData& r ) const;
215 SC_DLLPUBLIC void SetGrandTotalName(const ::rtl::OUString& rName);
216 SC_DLLPUBLIC const ::rtl::OUString* GetGrandTotalName() const;
218 const List& GetDimensions() const { return aDimList; }
219 void AddDimension(ScDPSaveDimension* pDim) { aDimList.Insert(pDim, LIST_APPEND); }
221 ScDPSaveDimension* GetDimensionByName(const String& rName);
222 SC_DLLPUBLIC ScDPSaveDimension* GetDataLayoutDimension();
223 SC_DLLPUBLIC ScDPSaveDimension* GetExistingDataLayoutDimension() const;
225 ScDPSaveDimension* DuplicateDimension(const String& rName);
226 SC_DLLPUBLIC ScDPSaveDimension& DuplicateDimension(const ScDPSaveDimension& rDim);
228 SC_DLLPUBLIC ScDPSaveDimension* GetExistingDimensionByName(const String& rName) const;
229 SC_DLLPUBLIC ScDPSaveDimension* GetNewDimensionByName(const String& rName);
231 void RemoveDimensionByName(const String& rName);
233 ScDPSaveDimension* GetInnermostDimension(USHORT nOrientation);
234 ScDPSaveDimension* GetFirstDimension(::com::sun::star::sheet::DataPilotFieldOrientation eOrientation);
235 long GetDataDimensionCount() const;
238 void SetPosition( ScDPSaveDimension* pDim, long nNew );
239 SC_DLLPUBLIC void SetColumnGrand( BOOL bSet );
240 BOOL GetColumnGrand() const { return BOOL(nColumnGrandMode); }
241 SC_DLLPUBLIC void SetRowGrand( BOOL bSet );
242 BOOL GetRowGrand() const { return BOOL(nRowGrandMode); }
243 void SetIgnoreEmptyRows( BOOL bSet );
244 BOOL GetIgnoreEmptyRows() const { return BOOL(nIgnoreEmptyMode); }
245 void SetRepeatIfEmpty( BOOL bSet );
246 BOOL GetRepeatIfEmpty() const { return BOOL(nRepeatEmptyMode); }
248 SC_DLLPUBLIC void SetFilterButton( BOOL bSet );
249 BOOL GetFilterButton() const { return bFilterButton; }
250 SC_DLLPUBLIC void SetDrillDown( BOOL bSet );
251 BOOL GetDrillDown() const { return bDrillDown; }
253 void WriteToSource( const com::sun::star::uno::Reference<
254 com::sun::star::sheet::XDimensionsSupplier>& xSource );
256 BOOL IsEmpty() const;
258 const ScDPDimensionSaveData* GetExistingDimensionData() const { return pDimensionData; }
259 SC_DLLPUBLIC ScDPDimensionSaveData* GetDimensionData(); // create if not there
260 void SetDimensionData( const ScDPDimensionSaveData* pNew ); // copied
261 void BuildAllDimensionMembers(ScDPTableData* pData);
263 /**
264 * Check whether a dimension has one or more invisible members.
266 * @param rDimName dimension name
268 SC_DLLPUBLIC bool HasInvisibleMember(const ::rtl::OUString& rDimName) const;
272 #endif