Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef SC_DPTABSRC_HXX
30 : : #define SC_DPTABSRC_HXX
31 : :
32 : : #include <tools/string.hxx>
33 : : #include "global.hxx" // enum ScSubTotalFunc
34 : : #include <com/sun/star/sheet/XDimensionsSupplier.hpp>
35 : : #include <com/sun/star/sheet/XHierarchiesSupplier.hpp>
36 : : #include <com/sun/star/sheet/XLevelsSupplier.hpp>
37 : : #include <com/sun/star/sheet/XMembersSupplier.hpp>
38 : : #include <com/sun/star/sheet/XDataPilotResults.hpp>
39 : : #include <com/sun/star/sheet/XDataPilotMemberResults.hpp>
40 : : #include <com/sun/star/sheet/MemberResult.hpp>
41 : : #include <com/sun/star/sheet/GeneralFunction.hpp>
42 : : #include <com/sun/star/sheet/DataPilotFieldAutoShowInfo.hpp>
43 : : #include <com/sun/star/sheet/DataPilotFieldLayoutInfo.hpp>
44 : : #include <com/sun/star/sheet/DataPilotFieldLayoutMode.hpp>
45 : : #include <com/sun/star/sheet/DataPilotFieldReference.hpp>
46 : : #include <com/sun/star/sheet/DataPilotFieldSortInfo.hpp>
47 : : #include <com/sun/star/util/XRefreshable.hpp>
48 : : #include <com/sun/star/sheet/XDrillDownDataSupplier.hpp>
49 : : #include <com/sun/star/util/XCloneable.hpp>
50 : : #include <com/sun/star/beans/XPropertySet.hpp>
51 : : #include <com/sun/star/lang/XServiceInfo.hpp>
52 : : #include <com/sun/star/container/XNamed.hpp>
53 : : #include <cppuhelper/implbase2.hxx>
54 : : #include <cppuhelper/implbase3.hxx>
55 : : #include <cppuhelper/implbase5.hxx>
56 : : #include <cppuhelper/implbase6.hxx>
57 : : #include "rtl/ref.hxx"
58 : :
59 : : #include "dptabdat.hxx"
60 : : #include "dpglobal.hxx"
61 : :
62 : : #include <boost/unordered_map.hpp>
63 : : #include <boost/unordered_set.hpp>
64 : : #include <boost/noncopyable.hpp>
65 : : #include <boost/scoped_ptr.hpp>
66 : : #include <vector>
67 : : #include <list>
68 : :
69 : : namespace com { namespace sun { namespace star {
70 : : namespace sheet {
71 : : struct DataPilotFieldFilter;
72 : : }
73 : : namespace table {
74 : : struct CellAddress;
75 : : }
76 : : }}}
77 : :
78 : : class ScDPResultMember;
79 : : class ScDPResultData;
80 : : class ScDPItemData;
81 : : class ScDPTableData;
82 : :
83 : : //
84 : : // implementation of DataPilotSource using ScDPTableData
85 : : //
86 : :
87 : :
88 : : class ScDPDimensions;
89 : : class ScDPDimension;
90 : : class ScDPHierarchies;
91 : : class ScDPHierarchy;
92 : : class ScDPLevels;
93 : : class ScDPLevel;
94 : : class ScDPMembers;
95 : : class ScDPMember;
96 : :
97 : :
98 : : class ScDPSource : public cppu::WeakImplHelper6<
99 : : com::sun::star::sheet::XDimensionsSupplier,
100 : : com::sun::star::sheet::XDataPilotResults,
101 : : com::sun::star::util::XRefreshable,
102 : : com::sun::star::sheet::XDrillDownDataSupplier,
103 : : com::sun::star::beans::XPropertySet,
104 : : com::sun::star::lang::XServiceInfo >
105 : : {
106 : : private:
107 : : ScDPTableData* pData; // data source (ScDPObject manages its life time)
108 : : ScDPDimensions* pDimensions; // api objects
109 : : // settings:
110 : : long nColDims[SC_DP_MAX_FIELDS];
111 : : long nRowDims[SC_DP_MAX_FIELDS];
112 : : long nDataDims[SC_DP_MAX_FIELDS];
113 : : long nPageDims[SC_DP_MAX_FIELDS];
114 : : long nColDimCount;
115 : : long nRowDimCount;
116 : : long nDataDimCount;
117 : : long nPageDimCount;
118 : : bool bColumnGrand;
119 : : bool bRowGrand;
120 : : bool bIgnoreEmptyRows;
121 : : bool bRepeatIfEmpty;
122 : :
123 : : long nDupCount;
124 : :
125 : : // results:
126 : : ScDPResultData* pResData; // keep the rest in this!
127 : : ScDPResultMember* pColResRoot;
128 : : ScDPResultMember* pRowResRoot;
129 : : com::sun::star::uno::Sequence<com::sun::star::sheet::MemberResult>* pColResults;
130 : : com::sun::star::uno::Sequence<com::sun::star::sheet::MemberResult>* pRowResults;
131 : : std::vector<ScDPLevel*> aColLevelList;
132 : : std::vector<ScDPLevel*> aRowLevelList;
133 : : bool bResultOverflow;
134 : : bool bPageFiltered; // set if page field filters have been applied to cache table
135 : :
136 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
137 : : ::std::auto_ptr<rtl::OUString> mpGrandTotalName;
138 : : SAL_WNODEPRECATED_DECLARATIONS_POP
139 : :
140 : : void CreateRes_Impl();
141 : : void FillMemberResults();
142 : : void FillLevelList( sal_uInt16 nOrientation, std::vector<ScDPLevel*> &rList );
143 : : void FillCalcInfo(bool bIsRow, ScDPTableData::CalcInfo& rInfo, bool &bHasAutoShow);
144 : :
145 : : /**
146 : : * Compile a list of dimension indices that are either, column, row or
147 : : * page dimensions (i.e. all but data dimensions).
148 : : */
149 : : void GetCategoryDimensionIndices(::boost::unordered_set<sal_Int32>& rCatDims);
150 : :
151 : : /**
152 : : * Set visibilities of individual rows in the cache table based on the
153 : : * page field data.
154 : : */
155 : : void FilterCacheTableByPageDimensions();
156 : :
157 : : void SetDupCount( long nNew );
158 : :
159 : : rtl::OUString getDataDescription(); //! ???
160 : :
161 : : void setIgnoreEmptyRows(bool bSet);
162 : : void setRepeatIfEmpty(bool bSet);
163 : :
164 : : void disposeData();
165 : :
166 : : public:
167 : : ScDPSource( ScDPTableData* pD );
168 : : virtual ~ScDPSource();
169 : :
170 : 57158 : ScDPTableData* GetData() { return pData; }
171 : 1132 : const ScDPTableData* GetData() const { return pData; }
172 : :
173 : : const ::rtl::OUString* GetGrandTotalName() const;
174 : :
175 : : sal_uInt16 GetOrientation(long nColumn);
176 : : void SetOrientation(long nColumn, sal_uInt16 nNew);
177 : : long GetPosition(long nColumn);
178 : :
179 : : long GetDataDimensionCount();
180 : : ScDPDimension* GetDataDimension(long nIndex);
181 : : rtl::OUString GetDataDimName(long nIndex);
182 : : const ScDPCache* GetCache();
183 : : const ScDPItemData* GetItemDataById( long nDim, long nId );
184 : : long GetDataLayoutDim(){ return pData->GetColumnCount(); }
185 : : SCROW GetMemberId( long nDim, const ScDPItemData& rData );
186 : : sal_Bool IsDataLayoutDimension(long nDim);
187 : : sal_uInt16 GetDataLayoutOrientation();
188 : :
189 : : sal_Bool IsDateDimension(long nDim);
190 : :
191 : : sal_Bool SubTotalAllowed(long nColumn); //! move to ScDPResultData
192 : :
193 : : ScDPDimension* AddDuplicated(long nSource, const rtl::OUString& rNewName);
194 : 183 : long GetDupCount() const { return nDupCount; }
195 : :
196 : : long GetSourceDim(long nDim);
197 : :
198 : : const com::sun::star::uno::Sequence<com::sun::star::sheet::MemberResult>*
199 : : GetMemberResults( ScDPLevel* pLevel );
200 : :
201 : : ScDPDimensions* GetDimensionsObject();
202 : :
203 : : // XDimensionsSupplier
204 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
205 : : SAL_CALL getDimensions( )
206 : : throw(::com::sun::star::uno::RuntimeException);
207 : :
208 : : // XDataPilotResults
209 : : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence<
210 : : ::com::sun::star::sheet::DataResult > > SAL_CALL getResults( )
211 : : throw(::com::sun::star::uno::RuntimeException);
212 : :
213 : : // XRefreshable
214 : : virtual void SAL_CALL refresh() throw(::com::sun::star::uno::RuntimeException);
215 : : virtual void SAL_CALL addRefreshListener( const ::com::sun::star::uno::Reference<
216 : : ::com::sun::star::util::XRefreshListener >& l )
217 : : throw(::com::sun::star::uno::RuntimeException);
218 : : virtual void SAL_CALL removeRefreshListener( const ::com::sun::star::uno::Reference<
219 : : ::com::sun::star::util::XRefreshListener >& l )
220 : : throw(::com::sun::star::uno::RuntimeException);
221 : :
222 : : // XDrillDownDataSupplier
223 : : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >
224 : : SAL_CALL getDrillDownData(const ::com::sun::star::uno::Sequence<
225 : : ::com::sun::star::sheet::DataPilotFieldFilter >& aFilters )
226 : : throw(::com::sun::star::uno::RuntimeException);
227 : :
228 : : // XPropertySet
229 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
230 : : SAL_CALL getPropertySetInfo( )
231 : : throw(::com::sun::star::uno::RuntimeException);
232 : : virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName,
233 : : const ::com::sun::star::uno::Any& aValue )
234 : : throw(::com::sun::star::beans::UnknownPropertyException,
235 : : ::com::sun::star::beans::PropertyVetoException,
236 : : ::com::sun::star::lang::IllegalArgumentException,
237 : : ::com::sun::star::lang::WrappedTargetException,
238 : : ::com::sun::star::uno::RuntimeException);
239 : : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
240 : : const ::rtl::OUString& PropertyName )
241 : : throw(::com::sun::star::beans::UnknownPropertyException,
242 : : ::com::sun::star::lang::WrappedTargetException,
243 : : ::com::sun::star::uno::RuntimeException);
244 : : virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
245 : : const ::com::sun::star::uno::Reference<
246 : : ::com::sun::star::beans::XPropertyChangeListener >& xListener )
247 : : throw(::com::sun::star::beans::UnknownPropertyException,
248 : : ::com::sun::star::lang::WrappedTargetException,
249 : : ::com::sun::star::uno::RuntimeException);
250 : : virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
251 : : const ::com::sun::star::uno::Reference<
252 : : ::com::sun::star::beans::XPropertyChangeListener >& aListener )
253 : : throw(::com::sun::star::beans::UnknownPropertyException,
254 : : ::com::sun::star::lang::WrappedTargetException,
255 : : ::com::sun::star::uno::RuntimeException);
256 : : virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName,
257 : : const ::com::sun::star::uno::Reference<
258 : : ::com::sun::star::beans::XVetoableChangeListener >& aListener )
259 : : throw(::com::sun::star::beans::UnknownPropertyException,
260 : : ::com::sun::star::lang::WrappedTargetException,
261 : : ::com::sun::star::uno::RuntimeException);
262 : : virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
263 : : const ::com::sun::star::uno::Reference<
264 : : ::com::sun::star::beans::XVetoableChangeListener >& aListener )
265 : : throw(::com::sun::star::beans::UnknownPropertyException,
266 : : ::com::sun::star::lang::WrappedTargetException,
267 : : ::com::sun::star::uno::RuntimeException);
268 : :
269 : : // XServiceInfo
270 : : virtual ::rtl::OUString SAL_CALL getImplementationName( )
271 : : throw(::com::sun::star::uno::RuntimeException);
272 : : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
273 : : throw(::com::sun::star::uno::RuntimeException);
274 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
275 : : throw(::com::sun::star::uno::RuntimeException);
276 : : };
277 : :
278 : : class ScDPDimensions : public cppu::WeakImplHelper2<
279 : : com::sun::star::container::XNameAccess,
280 : : com::sun::star::lang::XServiceInfo >
281 : : {
282 : : private:
283 : : ScDPSource* pSource;
284 : : long nDimCount;
285 : : ScDPDimension** ppDims;
286 : :
287 : : public:
288 : : ScDPDimensions( ScDPSource* pSrc );
289 : : virtual ~ScDPDimensions();
290 : :
291 : : void CountChanged();
292 : :
293 : : // XNameAccess
294 : : virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
295 : : throw(::com::sun::star::container::NoSuchElementException,
296 : : ::com::sun::star::lang::WrappedTargetException,
297 : : ::com::sun::star::uno::RuntimeException);
298 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
299 : : throw(::com::sun::star::uno::RuntimeException);
300 : : virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
301 : : throw(::com::sun::star::uno::RuntimeException);
302 : :
303 : : // XElementAccess
304 : : virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
305 : : throw(::com::sun::star::uno::RuntimeException);
306 : : virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
307 : :
308 : : // XServiceInfo
309 : : virtual ::rtl::OUString SAL_CALL getImplementationName( )
310 : : throw(::com::sun::star::uno::RuntimeException);
311 : : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
312 : : throw(::com::sun::star::uno::RuntimeException);
313 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
314 : : throw(::com::sun::star::uno::RuntimeException);
315 : :
316 : : virtual long getCount() const;
317 : : virtual ScDPDimension* getByIndex(long nIndex) const;
318 : : };
319 : :
320 : : class ScDPDimension : boost::noncopyable, public cppu::WeakImplHelper5<
321 : : com::sun::star::sheet::XHierarchiesSupplier,
322 : : com::sun::star::container::XNamed,
323 : : com::sun::star::util::XCloneable,
324 : : com::sun::star::beans::XPropertySet,
325 : : com::sun::star::lang::XServiceInfo >
326 : : {
327 : : ScDPSource* pSource;
328 : : long nDim; // dimension index (== column ID)
329 : : ScDPHierarchies* pHierarchies;
330 : : long nUsedHier;
331 : : sal_uInt16 nFunction; // enum GeneralFunction
332 : : rtl::OUString aName; // if empty, take from source
333 : : boost::scoped_ptr<rtl::OUString> mpLayoutName;
334 : : boost::scoped_ptr<rtl::OUString> mpSubtotalName;
335 : : long nSourceDim; // >=0 if dup'ed
336 : : ::com::sun::star::sheet::DataPilotFieldReference
337 : : aReferenceValue; // settings for "show data as" / "displayed value"
338 : : bool bHasSelectedPage;
339 : : rtl::OUString aSelectedPage;
340 : : ScDPItemData* pSelectedData; // internal, temporary, created from aSelectedPage
341 : : bool mbHasHiddenMember;
342 : :
343 : : public:
344 : : ScDPDimension( ScDPSource* pSrc, long nD );
345 : : virtual ~ScDPDimension();
346 : :
347 : 3006 : long GetDimension() const { return nDim; } // dimension index in source
348 : 188 : long GetSourceDim() const { return nSourceDim; } // >=0 if dup'ed
349 : :
350 : : ScDPDimension* CreateCloneObject();
351 : : ScDPHierarchies* GetHierarchiesObject();
352 : :
353 : : SC_DLLPUBLIC const ::rtl::OUString* GetLayoutName() const;
354 : : const ::rtl::OUString* GetSubtotalName() const;
355 : :
356 : : // XNamed
357 : : virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
358 : : virtual void SAL_CALL setName( const ::rtl::OUString& aName )
359 : : throw(::com::sun::star::uno::RuntimeException);
360 : :
361 : : // XHierarchiesSupplier
362 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL
363 : : getHierarchies() throw(::com::sun::star::uno::RuntimeException);
364 : :
365 : : // XCloneable
366 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL
367 : : createClone() throw(::com::sun::star::uno::RuntimeException);
368 : :
369 : : // XPropertySet
370 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
371 : : SAL_CALL getPropertySetInfo( )
372 : : throw(::com::sun::star::uno::RuntimeException);
373 : : virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName,
374 : : const ::com::sun::star::uno::Any& aValue )
375 : : throw(::com::sun::star::beans::UnknownPropertyException,
376 : : ::com::sun::star::beans::PropertyVetoException,
377 : : ::com::sun::star::lang::IllegalArgumentException,
378 : : ::com::sun::star::lang::WrappedTargetException,
379 : : ::com::sun::star::uno::RuntimeException);
380 : : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
381 : : const ::rtl::OUString& PropertyName )
382 : : throw(::com::sun::star::beans::UnknownPropertyException,
383 : : ::com::sun::star::lang::WrappedTargetException,
384 : : ::com::sun::star::uno::RuntimeException);
385 : : virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
386 : : const ::com::sun::star::uno::Reference<
387 : : ::com::sun::star::beans::XPropertyChangeListener >& xListener )
388 : : throw(::com::sun::star::beans::UnknownPropertyException,
389 : : ::com::sun::star::lang::WrappedTargetException,
390 : : ::com::sun::star::uno::RuntimeException);
391 : : virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
392 : : const ::com::sun::star::uno::Reference<
393 : : ::com::sun::star::beans::XPropertyChangeListener >& aListener )
394 : : throw(::com::sun::star::beans::UnknownPropertyException,
395 : : ::com::sun::star::lang::WrappedTargetException,
396 : : ::com::sun::star::uno::RuntimeException);
397 : : virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName,
398 : : const ::com::sun::star::uno::Reference<
399 : : ::com::sun::star::beans::XVetoableChangeListener >& aListener )
400 : : throw(::com::sun::star::beans::UnknownPropertyException,
401 : : ::com::sun::star::lang::WrappedTargetException,
402 : : ::com::sun::star::uno::RuntimeException);
403 : : virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
404 : : const ::com::sun::star::uno::Reference<
405 : : ::com::sun::star::beans::XVetoableChangeListener >& aListener )
406 : : throw(::com::sun::star::beans::UnknownPropertyException,
407 : : ::com::sun::star::lang::WrappedTargetException,
408 : : ::com::sun::star::uno::RuntimeException);
409 : :
410 : : // XServiceInfo
411 : : virtual ::rtl::OUString SAL_CALL getImplementationName( )
412 : : throw(::com::sun::star::uno::RuntimeException);
413 : : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
414 : : throw(::com::sun::star::uno::RuntimeException);
415 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
416 : : throw(::com::sun::star::uno::RuntimeException);
417 : :
418 : : sal_uInt16 getOrientation() const;
419 : : void setOrientation(sal_uInt16 nNew);
420 : : long getPosition() const;
421 : : bool getIsDataLayoutDimension() const;
422 : : sal_uInt16 getFunction() const;
423 : : void setFunction(sal_uInt16 nNew); // for data dimension
424 : : long getUsedHierarchy() const;
425 : : void setUsedHierarchy(long nNew);
426 : :
427 : 76 : bool HasSelectedPage() const { return bHasSelectedPage; }
428 : : const ScDPItemData& GetSelectedData();
429 : :
430 : : const ::com::sun::star::sheet::DataPilotFieldReference& GetReferenceValue() const;
431 : : };
432 : :
433 : : class ScDPHierarchies : public cppu::WeakImplHelper2<
434 : : com::sun::star::container::XNameAccess,
435 : : com::sun::star::lang::XServiceInfo >
436 : : {
437 : : private:
438 : : ScDPSource* pSource;
439 : : long nDim;
440 : : long nHierCount;
441 : : ScDPHierarchy** ppHiers;
442 : :
443 : : public:
444 : : ScDPHierarchies( ScDPSource* pSrc, long nD );
445 : : virtual ~ScDPHierarchies();
446 : :
447 : : // XNameAccess
448 : : virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
449 : : throw(::com::sun::star::container::NoSuchElementException,
450 : : ::com::sun::star::lang::WrappedTargetException,
451 : : ::com::sun::star::uno::RuntimeException);
452 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
453 : : throw(::com::sun::star::uno::RuntimeException);
454 : : virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
455 : : throw(::com::sun::star::uno::RuntimeException);
456 : :
457 : : // XElementAccess
458 : : virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
459 : : throw(::com::sun::star::uno::RuntimeException);
460 : : virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
461 : :
462 : : // XServiceInfo
463 : : virtual ::rtl::OUString SAL_CALL getImplementationName( )
464 : : throw(::com::sun::star::uno::RuntimeException);
465 : : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
466 : : throw(::com::sun::star::uno::RuntimeException);
467 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
468 : : throw(::com::sun::star::uno::RuntimeException);
469 : :
470 : : virtual long getCount() const;
471 : : virtual ScDPHierarchy* getByIndex(long nIndex) const;
472 : : };
473 : :
474 : : class ScDPHierarchy : public cppu::WeakImplHelper3<
475 : : com::sun::star::sheet::XLevelsSupplier,
476 : : com::sun::star::container::XNamed,
477 : : com::sun::star::lang::XServiceInfo >
478 : : {
479 : : private:
480 : : ScDPSource* pSource;
481 : : long nDim;
482 : : long nHier;
483 : : ScDPLevels* pLevels;
484 : :
485 : : public:
486 : : ScDPHierarchy( ScDPSource* pSrc, long nD, long nH );
487 : : virtual ~ScDPHierarchy();
488 : :
489 : : ScDPLevels* GetLevelsObject();
490 : :
491 : : // XNamed
492 : : virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
493 : : virtual void SAL_CALL setName( const ::rtl::OUString& aName )
494 : : throw(::com::sun::star::uno::RuntimeException);
495 : :
496 : : // XLevelsSupplier
497 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL
498 : : getLevels() throw(::com::sun::star::uno::RuntimeException);
499 : :
500 : : // XServiceInfo
501 : : virtual ::rtl::OUString SAL_CALL getImplementationName( )
502 : : throw(::com::sun::star::uno::RuntimeException);
503 : : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
504 : : throw(::com::sun::star::uno::RuntimeException);
505 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
506 : : throw(::com::sun::star::uno::RuntimeException);
507 : : };
508 : :
509 : : class ScDPLevels : public cppu::WeakImplHelper2<
510 : : com::sun::star::container::XNameAccess,
511 : : com::sun::star::lang::XServiceInfo >
512 : : {
513 : : private:
514 : : ScDPSource* pSource;
515 : : long nDim;
516 : : long nHier;
517 : : long nLevCount;
518 : : ScDPLevel** ppLevs;
519 : :
520 : : public:
521 : : ScDPLevels( ScDPSource* pSrc, long nD, long nH );
522 : : virtual ~ScDPLevels();
523 : :
524 : : // XNameAccess
525 : : virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
526 : : throw(::com::sun::star::container::NoSuchElementException,
527 : : ::com::sun::star::lang::WrappedTargetException,
528 : : ::com::sun::star::uno::RuntimeException);
529 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
530 : : throw(::com::sun::star::uno::RuntimeException);
531 : : virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
532 : : throw(::com::sun::star::uno::RuntimeException);
533 : :
534 : : // XElementAccess
535 : : virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
536 : : throw(::com::sun::star::uno::RuntimeException);
537 : : virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
538 : :
539 : : // XServiceInfo
540 : : virtual ::rtl::OUString SAL_CALL getImplementationName( )
541 : : throw(::com::sun::star::uno::RuntimeException);
542 : : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
543 : : throw(::com::sun::star::uno::RuntimeException);
544 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
545 : : throw(::com::sun::star::uno::RuntimeException);
546 : :
547 : : virtual long getCount() const;
548 : : virtual ScDPLevel* getByIndex(long nIndex) const;
549 : : };
550 : :
551 : : class ScDPLevel : public cppu::WeakImplHelper5<
552 : : com::sun::star::sheet::XMembersSupplier,
553 : : com::sun::star::container::XNamed,
554 : : com::sun::star::sheet::XDataPilotMemberResults,
555 : : com::sun::star::beans::XPropertySet,
556 : : com::sun::star::lang::XServiceInfo >
557 : : {
558 : : private:
559 : : ScDPSource* pSource;
560 : : long nDim;
561 : : long nHier;
562 : : long nLev;
563 : : ScDPMembers* pMembers;
564 : : com::sun::star::uno::Sequence<com::sun::star::sheet::GeneralFunction> aSubTotals;
565 : : ::com::sun::star::sheet::DataPilotFieldSortInfo aSortInfo; // stored user settings
566 : : ::com::sun::star::sheet::DataPilotFieldAutoShowInfo aAutoShowInfo; // stored user settings
567 : : ::com::sun::star::sheet::DataPilotFieldLayoutInfo aLayoutInfo; // stored user settings
568 : : // valid only from result calculation:
569 : : ::std::vector<sal_Int32> aGlobalOrder; // result of sorting by name or position
570 : : long nSortMeasure; // measure (index of data dimension) to sort by
571 : : long nAutoMeasure; // measure (index of data dimension) for AutoShow
572 : : bool bShowEmpty:1;
573 : : bool bEnableLayout:1; // enabled only for row fields, not for the innermost one
574 : :
575 : : public:
576 : : ScDPLevel( ScDPSource* pSrc, long nD, long nH, long nL );
577 : : virtual ~ScDPLevel();
578 : :
579 : : ScDPMembers* GetMembersObject();
580 : :
581 : : // XNamed
582 : : virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
583 : : virtual void SAL_CALL setName( const ::rtl::OUString& aName )
584 : : throw(::com::sun::star::uno::RuntimeException);
585 : :
586 : : // XMembersSupplier
587 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL
588 : : getMembers() throw(::com::sun::star::uno::RuntimeException);
589 : :
590 : : // XDataPilotMemberResults
591 : : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::MemberResult > SAL_CALL
592 : : getResults() throw(::com::sun::star::uno::RuntimeException);
593 : :
594 : : // XPropertySet
595 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
596 : : SAL_CALL getPropertySetInfo( )
597 : : throw(::com::sun::star::uno::RuntimeException);
598 : : virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName,
599 : : const ::com::sun::star::uno::Any& aValue )
600 : : throw(::com::sun::star::beans::UnknownPropertyException,
601 : : ::com::sun::star::beans::PropertyVetoException,
602 : : ::com::sun::star::lang::IllegalArgumentException,
603 : : ::com::sun::star::lang::WrappedTargetException,
604 : : ::com::sun::star::uno::RuntimeException);
605 : : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
606 : : const ::rtl::OUString& PropertyName )
607 : : throw(::com::sun::star::beans::UnknownPropertyException,
608 : : ::com::sun::star::lang::WrappedTargetException,
609 : : ::com::sun::star::uno::RuntimeException);
610 : : virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
611 : : const ::com::sun::star::uno::Reference<
612 : : ::com::sun::star::beans::XPropertyChangeListener >& xListener )
613 : : throw(::com::sun::star::beans::UnknownPropertyException,
614 : : ::com::sun::star::lang::WrappedTargetException,
615 : : ::com::sun::star::uno::RuntimeException);
616 : : virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
617 : : const ::com::sun::star::uno::Reference<
618 : : ::com::sun::star::beans::XPropertyChangeListener >& aListener )
619 : : throw(::com::sun::star::beans::UnknownPropertyException,
620 : : ::com::sun::star::lang::WrappedTargetException,
621 : : ::com::sun::star::uno::RuntimeException);
622 : : virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName,
623 : : const ::com::sun::star::uno::Reference<
624 : : ::com::sun::star::beans::XVetoableChangeListener >& aListener )
625 : : throw(::com::sun::star::beans::UnknownPropertyException,
626 : : ::com::sun::star::lang::WrappedTargetException,
627 : : ::com::sun::star::uno::RuntimeException);
628 : : virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
629 : : const ::com::sun::star::uno::Reference<
630 : : ::com::sun::star::beans::XVetoableChangeListener >& aListener )
631 : : throw(::com::sun::star::beans::UnknownPropertyException,
632 : : ::com::sun::star::lang::WrappedTargetException,
633 : : ::com::sun::star::uno::RuntimeException);
634 : :
635 : : // XServiceInfo
636 : : virtual ::rtl::OUString SAL_CALL getImplementationName( )
637 : : throw(::com::sun::star::uno::RuntimeException);
638 : : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
639 : : throw(::com::sun::star::uno::RuntimeException);
640 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
641 : : throw(::com::sun::star::uno::RuntimeException);
642 : :
643 : : com::sun::star::uno::Sequence<com::sun::star::sheet::GeneralFunction> getSubTotals() const;
644 : : bool getShowEmpty() const;
645 : :
646 : 322 : const ::com::sun::star::sheet::DataPilotFieldSortInfo& GetSortInfo() const { return aSortInfo; }
647 : 553 : const ::com::sun::star::sheet::DataPilotFieldAutoShowInfo& GetAutoShow() const { return aAutoShowInfo; }
648 : :
649 : : void EvaluateSortOrder();
650 : : void SetEnableLayout(bool bSet);
651 : :
652 : : const ::std::vector<sal_Int32>& GetGlobalOrder() const { return aGlobalOrder; }
653 : 511 : ::std::vector<sal_Int32>& GetGlobalOrder() { return aGlobalOrder; }
654 : 0 : long GetSortMeasure() const { return nSortMeasure; }
655 : 2 : long GetAutoMeasure() const { return nAutoMeasure; }
656 : :
657 : 4828 : bool IsOutlineLayout() const
658 : : {
659 : : return bEnableLayout &&
660 : : aLayoutInfo.LayoutMode !=
661 [ + + ][ - + ]: 4828 : ::com::sun::star::sheet::DataPilotFieldLayoutMode::TABULAR_LAYOUT;
662 : : }
663 : :
664 : 0 : bool IsSubtotalsAtTop() const
665 : : {
666 : : return bEnableLayout &&
667 : : aLayoutInfo.LayoutMode ==
668 [ # # ][ # # ]: 0 : ::com::sun::star::sheet::DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_TOP;
669 : : }
670 : :
671 : 10651 : bool IsAddEmpty() const
672 : : {
673 [ + + ][ - + ]: 10651 : return bEnableLayout && aLayoutInfo.AddEmptyLines;
674 : : }
675 : :
676 : : //! number format (for data fields and date fields)
677 : : };
678 : :
679 : : // hash map from name to index in the member array, for fast name access
680 : : typedef ::boost::unordered_map< ::rtl::OUString, sal_Int32, ::rtl::OUStringHash > ScDPMembersHashMap;
681 : :
682 : : class ScDPMembers : public cppu::WeakImplHelper2<
683 : : com::sun::star::container::XNameAccess,
684 : : com::sun::star::lang::XServiceInfo >
685 : : {
686 : : private:
687 : : typedef std::vector<rtl::Reference<ScDPMember> > MembersType;
688 : : ScDPSource* pSource;
689 : : long nDim;
690 : : long nHier;
691 : : long nLev;
692 : : long nMbrCount;
693 : : mutable MembersType maMembers;
694 : : mutable ScDPMembersHashMap aHashMap;
695 : :
696 : : public:
697 : : ScDPMembers( ScDPSource* pSrc, long nD, long nH, long nL );
698 : : virtual ~ScDPMembers();
699 : :
700 : : // XNameAccess
701 : : virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
702 : : throw(::com::sun::star::container::NoSuchElementException,
703 : : ::com::sun::star::lang::WrappedTargetException,
704 : : ::com::sun::star::uno::RuntimeException);
705 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
706 : : throw(::com::sun::star::uno::RuntimeException);
707 : : virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
708 : : throw(::com::sun::star::uno::RuntimeException);
709 : :
710 : : // XElementAccess
711 : : virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
712 : : throw(::com::sun::star::uno::RuntimeException);
713 : : virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
714 : :
715 : : // XServiceInfo
716 : : virtual ::rtl::OUString SAL_CALL getImplementationName( )
717 : : throw(::com::sun::star::uno::RuntimeException);
718 : : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
719 : : throw(::com::sun::star::uno::RuntimeException);
720 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
721 : : throw(::com::sun::star::uno::RuntimeException);
722 : :
723 : : long getCount() const;
724 : : ScDPMember* getByIndex(long nIndex) const;
725 : :
726 : : long getMinMembers() const;
727 : :
728 : : sal_Int32 GetIndexFromName( const ::rtl::OUString& rName ) const; // <0 if not found
729 : : const std::vector<sal_Int32>& GetGlobalOrder();
730 : : const ScDPItemData* GetSrcItemDataByIndex( SCROW nIndex);
731 : : SCROW GetSrcItemsCount();
732 : : };
733 : :
734 : : class ScDPMember : boost::noncopyable, public cppu::WeakImplHelper3<
735 : : com::sun::star::container::XNamed,
736 : : com::sun::star::beans::XPropertySet,
737 : : com::sun::star::lang::XServiceInfo >
738 : : {
739 : : private:
740 : : ScDPSource* pSource;
741 : : long nDim;
742 : : long nHier;
743 : : long nLev;
744 : :
745 : : SCROW mnDataId;
746 : : boost::scoped_ptr<rtl::OUString> mpLayoutName;
747 : :
748 : : sal_Int32 nPosition; // manual sorting
749 : : bool bVisible;
750 : : bool bShowDet;
751 : :
752 : : public:
753 : : ScDPMember(ScDPSource* pSrc, long nD, long nH, long nL, SCROW nIndex);
754 : : virtual ~ScDPMember();
755 : :
756 : : rtl::OUString GetNameStr() const;
757 : : void FillItemData( ScDPItemData& rData ) const;
758 : : const ScDPItemData* GetItemData() const;
759 : 6724 : SCROW GetItemDataId() const { return mnDataId; }
760 : : bool IsNamedItem(SCROW nIndex) const;
761 : :
762 : : SC_DLLPUBLIC const ::rtl::OUString* GetLayoutName() const;
763 : : long GetDim() const;
764 : :
765 : : sal_Int32 Compare( const ScDPMember& rOther ) const; // visible order
766 : :
767 : : // XNamed
768 : : virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
769 : : virtual void SAL_CALL setName( const ::rtl::OUString& aName )
770 : : throw(::com::sun::star::uno::RuntimeException);
771 : :
772 : : // XPropertySet
773 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
774 : : SAL_CALL getPropertySetInfo( )
775 : : throw(::com::sun::star::uno::RuntimeException);
776 : : virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName,
777 : : const ::com::sun::star::uno::Any& aValue )
778 : : throw(::com::sun::star::beans::UnknownPropertyException,
779 : : ::com::sun::star::beans::PropertyVetoException,
780 : : ::com::sun::star::lang::IllegalArgumentException,
781 : : ::com::sun::star::lang::WrappedTargetException,
782 : : ::com::sun::star::uno::RuntimeException);
783 : : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
784 : : const ::rtl::OUString& PropertyName )
785 : : throw(::com::sun::star::beans::UnknownPropertyException,
786 : : ::com::sun::star::lang::WrappedTargetException,
787 : : ::com::sun::star::uno::RuntimeException);
788 : : virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
789 : : const ::com::sun::star::uno::Reference<
790 : : ::com::sun::star::beans::XPropertyChangeListener >& xListener )
791 : : throw(::com::sun::star::beans::UnknownPropertyException,
792 : : ::com::sun::star::lang::WrappedTargetException,
793 : : ::com::sun::star::uno::RuntimeException);
794 : : virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
795 : : const ::com::sun::star::uno::Reference<
796 : : ::com::sun::star::beans::XPropertyChangeListener >& aListener )
797 : : throw(::com::sun::star::beans::UnknownPropertyException,
798 : : ::com::sun::star::lang::WrappedTargetException,
799 : : ::com::sun::star::uno::RuntimeException);
800 : : virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName,
801 : : const ::com::sun::star::uno::Reference<
802 : : ::com::sun::star::beans::XVetoableChangeListener >& aListener )
803 : : throw(::com::sun::star::beans::UnknownPropertyException,
804 : : ::com::sun::star::lang::WrappedTargetException,
805 : : ::com::sun::star::uno::RuntimeException);
806 : : virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
807 : : const ::com::sun::star::uno::Reference<
808 : : ::com::sun::star::beans::XVetoableChangeListener >& aListener )
809 : : throw(::com::sun::star::beans::UnknownPropertyException,
810 : : ::com::sun::star::lang::WrappedTargetException,
811 : : ::com::sun::star::uno::RuntimeException);
812 : :
813 : : // XServiceInfo
814 : : virtual ::rtl::OUString SAL_CALL getImplementationName( )
815 : : throw(::com::sun::star::uno::RuntimeException);
816 : : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
817 : : throw(::com::sun::star::uno::RuntimeException);
818 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
819 : : throw(::com::sun::star::uno::RuntimeException);
820 : :
821 : : bool isVisible() const;
822 : : bool getShowDetails() const;
823 : : };
824 : :
825 : :
826 : : #endif
827 : :
828 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|