update ooo310-m15
[ooovba.git] / sc / inc / dpsave.hxx
blobd1d961ac79a6da12845445f3652270a089beb0e9
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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(BOOL bSet); // to be removed!
141 void SetSubTotals(long nCount, const USHORT* pFuncs);
142 long GetSubTotalsCount() const { return nSubTotalCount; }
143 USHORT GetSubTotalFunc(long nIndex) const { return pSubTotalFuncs[nIndex]; }
144 void SetShowEmpty(BOOL bSet);
145 BOOL GetShowEmpty() const { return BOOL(nShowEmptyMode); }
146 void SetFunction(USHORT nNew); // enum GeneralFunction
147 USHORT GetFunction() const { return nFunction; }
148 void SetUsedHierarchy(long nNew);
149 long GetUsedHierarchy() const { return nUsedHierarchy; }
151 void SetLayoutName(const ::rtl::OUString& rName);
152 const ::rtl::OUString* GetLayoutName() const;
153 void RemoveLayoutName();
154 void SetSubtotalName(const ::rtl::OUString& rName);
155 const ::rtl::OUString* GetSubtotalName() const;
157 bool IsMemberNameInUse(const ::rtl::OUString& rName) const;
159 const ::com::sun::star::sheet::DataPilotFieldReference* GetReferenceValue() const { return pReferenceValue; }
160 void SetReferenceValue(const ::com::sun::star::sheet::DataPilotFieldReference* pNew);
162 const ::com::sun::star::sheet::DataPilotFieldSortInfo* GetSortInfo() const { return pSortInfo; }
163 void SetSortInfo(const ::com::sun::star::sheet::DataPilotFieldSortInfo* pNew);
164 const ::com::sun::star::sheet::DataPilotFieldAutoShowInfo* GetAutoShowInfo() const { return pAutoShowInfo; }
165 void SetAutoShowInfo(const ::com::sun::star::sheet::DataPilotFieldAutoShowInfo* pNew);
166 const ::com::sun::star::sheet::DataPilotFieldLayoutInfo* GetLayoutInfo() const { return pLayoutInfo; }
167 void SetLayoutInfo(const ::com::sun::star::sheet::DataPilotFieldLayoutInfo* pNew);
169 void SetCurrentPage( const String* pPage ); // NULL = no selection (all)
170 BOOL HasCurrentPage() const;
171 const String& GetCurrentPage() const;
173 USHORT GetOrientation() const { return nOrientation; }
175 ScDPSaveMember* GetExistingMemberByName(const String& rName);
176 ScDPSaveMember* GetMemberByName(const String& rName);
178 void SetMemberPosition( const String& rName, sal_Int32 nNewPos );
180 void WriteToSource( const com::sun::star::uno::Reference<
181 com::sun::star::uno::XInterface>& xDim );
183 void UpdateMemberVisibility(const ::std::hash_map< ::rtl::OUString, bool, ::rtl::OUStringHash>& rData);
185 bool HasInvisibleMember() const;
189 class ScDPSaveData
191 private:
192 List aDimList;
193 ScDPDimensionSaveData* pDimensionData; // settings that create new dimensions
194 USHORT nColumnGrandMode;
195 USHORT nRowGrandMode;
196 USHORT nIgnoreEmptyMode;
197 USHORT nRepeatEmptyMode;
198 BOOL bFilterButton; // not passed to DataPilotSource
199 BOOL bDrillDown; // not passed to DataPilotSource
201 /** if true, all dimensions already have all of their member instances
202 * created. */
203 bool mbDimensionMembersBuilt;
205 ::std::auto_ptr<rtl::OUString> mpGrandTotalName;
207 public:
208 SC_DLLPUBLIC ScDPSaveData();
209 ScDPSaveData(const ScDPSaveData& r);
210 SC_DLLPUBLIC ~ScDPSaveData();
212 ScDPSaveData& operator= ( const ScDPSaveData& r );
214 BOOL operator== ( const ScDPSaveData& r ) const;
216 SC_DLLPUBLIC void SetGrandTotalName(const ::rtl::OUString& rName);
217 SC_DLLPUBLIC const ::rtl::OUString* GetGrandTotalName() const;
219 const List& GetDimensions() const { return aDimList; }
220 void AddDimension(ScDPSaveDimension* pDim) { aDimList.Insert(pDim, LIST_APPEND); }
222 ScDPSaveDimension* GetDimensionByName(const String& rName);
223 SC_DLLPUBLIC ScDPSaveDimension* GetDataLayoutDimension();
224 SC_DLLPUBLIC ScDPSaveDimension* GetExistingDataLayoutDimension() const;
226 ScDPSaveDimension* DuplicateDimension(const String& rName);
227 SC_DLLPUBLIC ScDPSaveDimension& DuplicateDimension(const ScDPSaveDimension& rDim);
229 SC_DLLPUBLIC ScDPSaveDimension* GetExistingDimensionByName(const String& rName) const;
230 SC_DLLPUBLIC ScDPSaveDimension* GetNewDimensionByName(const String& rName);
232 void RemoveDimensionByName(const String& rName);
234 ScDPSaveDimension* GetInnermostDimension(USHORT nOrientation);
235 ScDPSaveDimension* GetFirstDimension(::com::sun::star::sheet::DataPilotFieldOrientation eOrientation);
236 long GetDataDimensionCount() const;
239 void SetPosition( ScDPSaveDimension* pDim, long nNew );
240 SC_DLLPUBLIC void SetColumnGrand( BOOL bSet );
241 BOOL GetColumnGrand() const { return BOOL(nColumnGrandMode); }
242 SC_DLLPUBLIC void SetRowGrand( BOOL bSet );
243 BOOL GetRowGrand() const { return BOOL(nRowGrandMode); }
244 void SetIgnoreEmptyRows( BOOL bSet );
245 BOOL GetIgnoreEmptyRows() const { return BOOL(nIgnoreEmptyMode); }
246 void SetRepeatIfEmpty( BOOL bSet );
247 BOOL GetRepeatIfEmpty() const { return BOOL(nRepeatEmptyMode); }
249 SC_DLLPUBLIC void SetFilterButton( BOOL bSet );
250 BOOL GetFilterButton() const { return bFilterButton; }
251 SC_DLLPUBLIC void SetDrillDown( BOOL bSet );
252 BOOL GetDrillDown() const { return bDrillDown; }
254 void WriteToSource( const com::sun::star::uno::Reference<
255 com::sun::star::sheet::XDimensionsSupplier>& xSource );
257 BOOL IsEmpty() const;
259 const ScDPDimensionSaveData* GetExistingDimensionData() const { return pDimensionData; }
260 SC_DLLPUBLIC ScDPDimensionSaveData* GetDimensionData(); // create if not there
261 void SetDimensionData( const ScDPDimensionSaveData* pNew ); // copied
262 void BuildAllDimensionMembers(ScDPTableData* pData);
264 /**
265 * Check whether a dimension has one or more invisible members.
267 * @param rDimName dimension name
269 SC_DLLPUBLIC bool HasInvisibleMember(const ::rtl::OUString& rDimName) const;
273 #endif