Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / inc / dptabsrc.hxx
blobba4ff07af506d5910ed2073a66942db665c50b7b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef SC_DPTABSRC_HXX
21 #define SC_DPTABSRC_HXX
23 #include "global.hxx"
24 #include <com/sun/star/sheet/XDimensionsSupplier.hpp>
25 #include <com/sun/star/sheet/XHierarchiesSupplier.hpp>
26 #include <com/sun/star/sheet/XLevelsSupplier.hpp>
27 #include <com/sun/star/sheet/XMembersSupplier.hpp>
28 #include <com/sun/star/sheet/XDataPilotResults.hpp>
29 #include <com/sun/star/sheet/XDataPilotMemberResults.hpp>
30 #include <com/sun/star/sheet/MemberResult.hpp>
31 #include <com/sun/star/sheet/GeneralFunction.hpp>
32 #include <com/sun/star/sheet/DataPilotFieldAutoShowInfo.hpp>
33 #include <com/sun/star/sheet/DataPilotFieldLayoutInfo.hpp>
34 #include <com/sun/star/sheet/DataPilotFieldLayoutMode.hpp>
35 #include <com/sun/star/sheet/DataPilotFieldReference.hpp>
36 #include <com/sun/star/sheet/DataPilotFieldSortInfo.hpp>
37 #include <com/sun/star/util/XRefreshable.hpp>
38 #include <com/sun/star/sheet/XDrillDownDataSupplier.hpp>
39 #include <com/sun/star/util/XCloneable.hpp>
40 #include <com/sun/star/beans/XPropertySet.hpp>
41 #include <com/sun/star/lang/XServiceInfo.hpp>
42 #include <com/sun/star/container/XNamed.hpp>
43 #include <cppuhelper/implbase2.hxx>
44 #include <cppuhelper/implbase3.hxx>
45 #include <cppuhelper/implbase5.hxx>
46 #include <cppuhelper/implbase6.hxx>
47 #include "rtl/ref.hxx"
49 #include "dptabdat.hxx"
50 #include "dpglobal.hxx"
51 #include "dpresfilter.hxx"
53 #include <boost/unordered_map.hpp>
54 #include <boost/unordered_set.hpp>
55 #include <boost/noncopyable.hpp>
56 #include <boost/scoped_ptr.hpp>
57 #include <vector>
58 #include <list>
60 namespace com { namespace sun { namespace star {
61 namespace sheet {
62 struct DataPilotFieldFilter;
64 namespace table {
65 struct CellAddress;
67 }}}
69 class ScDPResultMember;
70 class ScDPResultData;
71 class ScDPItemData;
72 class ScDPTableData;
75 // implementation of DataPilotSource using ScDPTableData
79 class ScDPDimensions;
80 class ScDPDimension;
81 class ScDPHierarchies;
82 class ScDPHierarchy;
83 class ScDPLevels;
84 class ScDPLevel;
85 class ScDPMembers;
86 class ScDPMember;
89 class ScDPSource : public cppu::WeakImplHelper6<
90 com::sun::star::sheet::XDimensionsSupplier,
91 com::sun::star::sheet::XDataPilotResults,
92 com::sun::star::util::XRefreshable,
93 com::sun::star::sheet::XDrillDownDataSupplier,
94 com::sun::star::beans::XPropertySet,
95 com::sun::star::lang::XServiceInfo >
97 private:
98 ScDPTableData* pData; // data source (ScDPObject manages its life time)
99 ScDPDimensions* pDimensions; // api objects
100 // settings:
102 std::vector<long> maColDims;
103 std::vector<long> maRowDims;
104 std::vector<long> maDataDims;
105 std::vector<long> maPageDims;
106 ScDPResultTree maResFilterSet;
108 bool bColumnGrand;
109 bool bRowGrand;
110 bool bIgnoreEmptyRows;
111 bool bRepeatIfEmpty;
113 long nDupCount;
115 // results:
116 ScDPResultData* pResData; // keep the rest in this!
117 ScDPResultMember* pColResRoot;
118 ScDPResultMember* pRowResRoot;
119 com::sun::star::uno::Sequence<com::sun::star::sheet::MemberResult>* pColResults;
120 com::sun::star::uno::Sequence<com::sun::star::sheet::MemberResult>* pRowResults;
121 std::vector<ScDPLevel*> aColLevelList;
122 std::vector<ScDPLevel*> aRowLevelList;
123 bool bResultOverflow;
124 bool bPageFiltered; // set if page field filters have been applied to cache table
126 SAL_WNODEPRECATED_DECLARATIONS_PUSH
127 ::std::auto_ptr<OUString> mpGrandTotalName;
128 SAL_WNODEPRECATED_DECLARATIONS_POP
130 void CreateRes_Impl();
131 void FillMemberResults();
132 void FillLevelList( sal_uInt16 nOrientation, std::vector<ScDPLevel*> &rList );
133 void FillCalcInfo(bool bIsRow, ScDPTableData::CalcInfo& rInfo, bool &bHasAutoShow);
136 * Compile a list of dimension indices that are either, column, row or
137 * page dimensions (i.e. all but data dimensions).
139 void GetCategoryDimensionIndices(::boost::unordered_set<sal_Int32>& rCatDims);
142 * Set visibilities of individual rows in the cache table based on the
143 * page field data.
145 void FilterCacheByPageDimensions();
147 void SetDupCount( long nNew );
149 OUString getDataDescription(); //! ???
151 void setIgnoreEmptyRows(bool bSet);
152 void setRepeatIfEmpty(bool bSet);
154 void disposeData();
156 public:
157 ScDPSource( ScDPTableData* pD );
158 virtual ~ScDPSource();
160 ScDPTableData* GetData() { return pData; }
161 const ScDPTableData* GetData() const { return pData; }
163 const OUString* GetGrandTotalName() const;
165 sal_uInt16 GetOrientation(long nColumn);
166 void SetOrientation(long nColumn, sal_uInt16 nNew);
167 long GetPosition(long nColumn);
169 long GetDataDimensionCount();
170 ScDPDimension* GetDataDimension(long nIndex);
171 OUString GetDataDimName(long nIndex);
172 const ScDPCache* GetCache();
173 const ScDPItemData* GetItemDataById( long nDim, long nId );
174 long GetDataLayoutDim(){ return pData->GetColumnCount(); }
175 SCROW GetMemberId( long nDim, const ScDPItemData& rData );
176 sal_Bool IsDataLayoutDimension(long nDim);
177 sal_uInt16 GetDataLayoutOrientation();
179 sal_Bool IsDateDimension(long nDim);
181 sal_Bool SubTotalAllowed(long nColumn); //! move to ScDPResultData
183 ScDPDimension* AddDuplicated(long nSource, const OUString& rNewName);
184 long GetDupCount() const { return nDupCount; }
186 long GetSourceDim(long nDim);
188 const com::sun::star::uno::Sequence<com::sun::star::sheet::MemberResult>*
189 GetMemberResults( ScDPLevel* pLevel );
191 ScDPDimensions* GetDimensionsObject();
193 // XDimensionsSupplier
194 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
195 SAL_CALL getDimensions( )
196 throw(::com::sun::star::uno::RuntimeException);
198 // XDataPilotResults
199 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence<
200 ::com::sun::star::sheet::DataResult > > SAL_CALL getResults( )
201 throw(::com::sun::star::uno::RuntimeException);
203 virtual com::sun::star::uno::Sequence<double> SAL_CALL
204 getFilteredResults(
205 const com::sun::star::uno::Sequence<com::sun::star::sheet::DataPilotFieldFilter>& aFilters )
206 throw (com::sun::star::uno::RuntimeException);
208 // XRefreshable
209 virtual void SAL_CALL refresh() throw(::com::sun::star::uno::RuntimeException);
210 virtual void SAL_CALL addRefreshListener( const ::com::sun::star::uno::Reference<
211 ::com::sun::star::util::XRefreshListener >& l )
212 throw(::com::sun::star::uno::RuntimeException);
213 virtual void SAL_CALL removeRefreshListener( const ::com::sun::star::uno::Reference<
214 ::com::sun::star::util::XRefreshListener >& l )
215 throw(::com::sun::star::uno::RuntimeException);
217 // XDrillDownDataSupplier
218 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >
219 SAL_CALL getDrillDownData(const ::com::sun::star::uno::Sequence<
220 ::com::sun::star::sheet::DataPilotFieldFilter >& aFilters )
221 throw(::com::sun::star::uno::RuntimeException);
223 // XPropertySet
224 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
225 SAL_CALL getPropertySetInfo( )
226 throw(::com::sun::star::uno::RuntimeException);
227 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
228 const ::com::sun::star::uno::Any& aValue )
229 throw(::com::sun::star::beans::UnknownPropertyException,
230 ::com::sun::star::beans::PropertyVetoException,
231 ::com::sun::star::lang::IllegalArgumentException,
232 ::com::sun::star::lang::WrappedTargetException,
233 ::com::sun::star::uno::RuntimeException);
234 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
235 const OUString& PropertyName )
236 throw(::com::sun::star::beans::UnknownPropertyException,
237 ::com::sun::star::lang::WrappedTargetException,
238 ::com::sun::star::uno::RuntimeException);
239 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
240 const ::com::sun::star::uno::Reference<
241 ::com::sun::star::beans::XPropertyChangeListener >& xListener )
242 throw(::com::sun::star::beans::UnknownPropertyException,
243 ::com::sun::star::lang::WrappedTargetException,
244 ::com::sun::star::uno::RuntimeException);
245 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
246 const ::com::sun::star::uno::Reference<
247 ::com::sun::star::beans::XPropertyChangeListener >& aListener )
248 throw(::com::sun::star::beans::UnknownPropertyException,
249 ::com::sun::star::lang::WrappedTargetException,
250 ::com::sun::star::uno::RuntimeException);
251 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
252 const ::com::sun::star::uno::Reference<
253 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
254 throw(::com::sun::star::beans::UnknownPropertyException,
255 ::com::sun::star::lang::WrappedTargetException,
256 ::com::sun::star::uno::RuntimeException);
257 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
258 const ::com::sun::star::uno::Reference<
259 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
260 throw(::com::sun::star::beans::UnknownPropertyException,
261 ::com::sun::star::lang::WrappedTargetException,
262 ::com::sun::star::uno::RuntimeException);
264 // XServiceInfo
265 virtual OUString SAL_CALL getImplementationName( )
266 throw(::com::sun::star::uno::RuntimeException);
267 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
268 throw(::com::sun::star::uno::RuntimeException);
269 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
270 throw(::com::sun::star::uno::RuntimeException);
272 #if DEBUG_PIVOT_TABLE
273 void DumpResults() const;
274 #endif
277 class ScDPDimensions : public cppu::WeakImplHelper2<
278 com::sun::star::container::XNameAccess,
279 com::sun::star::lang::XServiceInfo >
281 private:
282 ScDPSource* pSource;
283 long nDimCount;
284 ScDPDimension** ppDims;
286 public:
287 ScDPDimensions( ScDPSource* pSrc );
288 virtual ~ScDPDimensions();
290 void CountChanged();
292 // XNameAccess
293 virtual ::com::sun::star::uno::Any SAL_CALL getByName( const OUString& aName )
294 throw(::com::sun::star::container::NoSuchElementException,
295 ::com::sun::star::lang::WrappedTargetException,
296 ::com::sun::star::uno::RuntimeException);
297 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames()
298 throw(::com::sun::star::uno::RuntimeException);
299 virtual sal_Bool SAL_CALL hasByName( const OUString& aName )
300 throw(::com::sun::star::uno::RuntimeException);
302 // XElementAccess
303 virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
304 throw(::com::sun::star::uno::RuntimeException);
305 virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
307 // XServiceInfo
308 virtual OUString SAL_CALL getImplementationName( )
309 throw(::com::sun::star::uno::RuntimeException);
310 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
311 throw(::com::sun::star::uno::RuntimeException);
312 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
313 throw(::com::sun::star::uno::RuntimeException);
315 virtual long getCount() const;
316 virtual ScDPDimension* getByIndex(long nIndex) const;
319 class ScDPDimension : boost::noncopyable, public cppu::WeakImplHelper5<
320 com::sun::star::sheet::XHierarchiesSupplier,
321 com::sun::star::container::XNamed,
322 com::sun::star::util::XCloneable,
323 com::sun::star::beans::XPropertySet,
324 com::sun::star::lang::XServiceInfo >
326 ScDPSource* pSource;
327 long nDim; // dimension index (== column ID)
328 ScDPHierarchies* pHierarchies;
329 long nUsedHier;
330 sal_uInt16 nFunction; // enum GeneralFunction
331 OUString aName; // if empty, take from source
332 boost::scoped_ptr<OUString> mpLayoutName;
333 boost::scoped_ptr<OUString> mpSubtotalName;
334 long nSourceDim; // >=0 if dup'ed
335 ::com::sun::star::sheet::DataPilotFieldReference
336 aReferenceValue; // settings for "show data as" / "displayed value"
337 bool bHasSelectedPage;
338 OUString aSelectedPage;
339 ScDPItemData* pSelectedData; // internal, temporary, created from aSelectedPage
340 bool mbHasHiddenMember;
342 public:
343 ScDPDimension( ScDPSource* pSrc, long nD );
344 virtual ~ScDPDimension();
346 long GetDimension() const { return nDim; } // dimension index in source
347 long GetSourceDim() const { return nSourceDim; } // >=0 if dup'ed
349 ScDPDimension* CreateCloneObject();
350 ScDPHierarchies* GetHierarchiesObject();
352 SC_DLLPUBLIC const OUString* GetLayoutName() const;
353 const OUString* GetSubtotalName() const;
355 // XNamed
356 virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
357 virtual void SAL_CALL setName( const OUString& aName )
358 throw(::com::sun::star::uno::RuntimeException);
360 // XHierarchiesSupplier
361 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL
362 getHierarchies() throw(::com::sun::star::uno::RuntimeException);
364 // XCloneable
365 virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL
366 createClone() throw(::com::sun::star::uno::RuntimeException);
368 // XPropertySet
369 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
370 SAL_CALL getPropertySetInfo( )
371 throw(::com::sun::star::uno::RuntimeException);
372 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
373 const ::com::sun::star::uno::Any& aValue )
374 throw(::com::sun::star::beans::UnknownPropertyException,
375 ::com::sun::star::beans::PropertyVetoException,
376 ::com::sun::star::lang::IllegalArgumentException,
377 ::com::sun::star::lang::WrappedTargetException,
378 ::com::sun::star::uno::RuntimeException);
379 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
380 const OUString& PropertyName )
381 throw(::com::sun::star::beans::UnknownPropertyException,
382 ::com::sun::star::lang::WrappedTargetException,
383 ::com::sun::star::uno::RuntimeException);
384 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
385 const ::com::sun::star::uno::Reference<
386 ::com::sun::star::beans::XPropertyChangeListener >& xListener )
387 throw(::com::sun::star::beans::UnknownPropertyException,
388 ::com::sun::star::lang::WrappedTargetException,
389 ::com::sun::star::uno::RuntimeException);
390 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
391 const ::com::sun::star::uno::Reference<
392 ::com::sun::star::beans::XPropertyChangeListener >& aListener )
393 throw(::com::sun::star::beans::UnknownPropertyException,
394 ::com::sun::star::lang::WrappedTargetException,
395 ::com::sun::star::uno::RuntimeException);
396 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
397 const ::com::sun::star::uno::Reference<
398 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
399 throw(::com::sun::star::beans::UnknownPropertyException,
400 ::com::sun::star::lang::WrappedTargetException,
401 ::com::sun::star::uno::RuntimeException);
402 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
403 const ::com::sun::star::uno::Reference<
404 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
405 throw(::com::sun::star::beans::UnknownPropertyException,
406 ::com::sun::star::lang::WrappedTargetException,
407 ::com::sun::star::uno::RuntimeException);
409 // XServiceInfo
410 virtual OUString SAL_CALL getImplementationName( )
411 throw(::com::sun::star::uno::RuntimeException);
412 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
413 throw(::com::sun::star::uno::RuntimeException);
414 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
415 throw(::com::sun::star::uno::RuntimeException);
417 sal_uInt16 getOrientation() const;
418 void setOrientation(sal_uInt16 nNew);
419 long getPosition() const;
420 bool getIsDataLayoutDimension() const;
421 sal_uInt16 getFunction() const;
422 void setFunction(sal_uInt16 nNew); // for data dimension
423 long getUsedHierarchy() const;
424 void setUsedHierarchy(long nNew);
426 bool HasSelectedPage() const { return bHasSelectedPage; }
427 const ScDPItemData& GetSelectedData();
429 const ::com::sun::star::sheet::DataPilotFieldReference& GetReferenceValue() const;
432 class ScDPHierarchies : public cppu::WeakImplHelper2<
433 com::sun::star::container::XNameAccess,
434 com::sun::star::lang::XServiceInfo >
436 private:
437 ScDPSource* pSource;
438 long nDim;
439 long nHierCount;
440 ScDPHierarchy** ppHiers;
442 public:
443 ScDPHierarchies( ScDPSource* pSrc, long nD );
444 virtual ~ScDPHierarchies();
446 // XNameAccess
447 virtual ::com::sun::star::uno::Any SAL_CALL getByName( const OUString& aName )
448 throw(::com::sun::star::container::NoSuchElementException,
449 ::com::sun::star::lang::WrappedTargetException,
450 ::com::sun::star::uno::RuntimeException);
451 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames()
452 throw(::com::sun::star::uno::RuntimeException);
453 virtual sal_Bool SAL_CALL hasByName( const OUString& aName )
454 throw(::com::sun::star::uno::RuntimeException);
456 // XElementAccess
457 virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
458 throw(::com::sun::star::uno::RuntimeException);
459 virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
461 // XServiceInfo
462 virtual OUString SAL_CALL getImplementationName( )
463 throw(::com::sun::star::uno::RuntimeException);
464 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
465 throw(::com::sun::star::uno::RuntimeException);
466 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
467 throw(::com::sun::star::uno::RuntimeException);
469 virtual long getCount() const;
470 virtual ScDPHierarchy* getByIndex(long nIndex) const;
473 class ScDPHierarchy : public cppu::WeakImplHelper3<
474 com::sun::star::sheet::XLevelsSupplier,
475 com::sun::star::container::XNamed,
476 com::sun::star::lang::XServiceInfo >
478 private:
479 ScDPSource* pSource;
480 long nDim;
481 long nHier;
482 ScDPLevels* pLevels;
484 public:
485 ScDPHierarchy( ScDPSource* pSrc, long nD, long nH );
486 virtual ~ScDPHierarchy();
488 ScDPLevels* GetLevelsObject();
490 // XNamed
491 virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
492 virtual void SAL_CALL setName( const OUString& aName )
493 throw(::com::sun::star::uno::RuntimeException);
495 // XLevelsSupplier
496 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL
497 getLevels() throw(::com::sun::star::uno::RuntimeException);
499 // XServiceInfo
500 virtual OUString SAL_CALL getImplementationName( )
501 throw(::com::sun::star::uno::RuntimeException);
502 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
503 throw(::com::sun::star::uno::RuntimeException);
504 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
505 throw(::com::sun::star::uno::RuntimeException);
508 class ScDPLevels : public cppu::WeakImplHelper2<
509 com::sun::star::container::XNameAccess,
510 com::sun::star::lang::XServiceInfo >
512 private:
513 ScDPSource* pSource;
514 long nDim;
515 long nHier;
516 long nLevCount;
517 ScDPLevel** ppLevs;
519 public:
520 ScDPLevels( ScDPSource* pSrc, long nD, long nH );
521 virtual ~ScDPLevels();
523 // XNameAccess
524 virtual ::com::sun::star::uno::Any SAL_CALL getByName( const OUString& aName )
525 throw(::com::sun::star::container::NoSuchElementException,
526 ::com::sun::star::lang::WrappedTargetException,
527 ::com::sun::star::uno::RuntimeException);
528 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames()
529 throw(::com::sun::star::uno::RuntimeException);
530 virtual sal_Bool SAL_CALL hasByName( const OUString& aName )
531 throw(::com::sun::star::uno::RuntimeException);
533 // XElementAccess
534 virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
535 throw(::com::sun::star::uno::RuntimeException);
536 virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
538 // XServiceInfo
539 virtual OUString SAL_CALL getImplementationName( )
540 throw(::com::sun::star::uno::RuntimeException);
541 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
542 throw(::com::sun::star::uno::RuntimeException);
543 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
544 throw(::com::sun::star::uno::RuntimeException);
546 virtual long getCount() const;
547 virtual ScDPLevel* getByIndex(long nIndex) const;
550 class ScDPLevel : public cppu::WeakImplHelper5<
551 com::sun::star::sheet::XMembersSupplier,
552 com::sun::star::container::XNamed,
553 com::sun::star::sheet::XDataPilotMemberResults,
554 com::sun::star::beans::XPropertySet,
555 com::sun::star::lang::XServiceInfo >
557 private:
558 ScDPSource* pSource;
559 long nDim;
560 long nHier;
561 long nLev;
562 ScDPMembers* pMembers;
563 com::sun::star::uno::Sequence<com::sun::star::sheet::GeneralFunction> aSubTotals;
564 ::com::sun::star::sheet::DataPilotFieldSortInfo aSortInfo; // stored user settings
565 ::com::sun::star::sheet::DataPilotFieldAutoShowInfo aAutoShowInfo; // stored user settings
566 ::com::sun::star::sheet::DataPilotFieldLayoutInfo aLayoutInfo; // stored user settings
567 // valid only from result calculation:
568 ::std::vector<sal_Int32> aGlobalOrder; // result of sorting by name or position
569 long nSortMeasure; // measure (index of data dimension) to sort by
570 long nAutoMeasure; // measure (index of data dimension) for AutoShow
571 bool bShowEmpty:1;
572 bool bEnableLayout:1; // enabled only for row fields, not for the innermost one
574 public:
575 ScDPLevel( ScDPSource* pSrc, long nD, long nH, long nL );
576 virtual ~ScDPLevel();
578 ScDPMembers* GetMembersObject();
580 // XNamed
581 virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
582 virtual void SAL_CALL setName( const OUString& aName )
583 throw(::com::sun::star::uno::RuntimeException);
585 // XMembersSupplier
586 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL
587 getMembers() throw(::com::sun::star::uno::RuntimeException);
589 // XDataPilotMemberResults
590 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::MemberResult > SAL_CALL
591 getResults() throw(::com::sun::star::uno::RuntimeException);
593 // XPropertySet
594 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
595 SAL_CALL getPropertySetInfo( )
596 throw(::com::sun::star::uno::RuntimeException);
597 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
598 const ::com::sun::star::uno::Any& aValue )
599 throw(::com::sun::star::beans::UnknownPropertyException,
600 ::com::sun::star::beans::PropertyVetoException,
601 ::com::sun::star::lang::IllegalArgumentException,
602 ::com::sun::star::lang::WrappedTargetException,
603 ::com::sun::star::uno::RuntimeException);
604 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
605 const OUString& PropertyName )
606 throw(::com::sun::star::beans::UnknownPropertyException,
607 ::com::sun::star::lang::WrappedTargetException,
608 ::com::sun::star::uno::RuntimeException);
609 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
610 const ::com::sun::star::uno::Reference<
611 ::com::sun::star::beans::XPropertyChangeListener >& xListener )
612 throw(::com::sun::star::beans::UnknownPropertyException,
613 ::com::sun::star::lang::WrappedTargetException,
614 ::com::sun::star::uno::RuntimeException);
615 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
616 const ::com::sun::star::uno::Reference<
617 ::com::sun::star::beans::XPropertyChangeListener >& aListener )
618 throw(::com::sun::star::beans::UnknownPropertyException,
619 ::com::sun::star::lang::WrappedTargetException,
620 ::com::sun::star::uno::RuntimeException);
621 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
622 const ::com::sun::star::uno::Reference<
623 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
624 throw(::com::sun::star::beans::UnknownPropertyException,
625 ::com::sun::star::lang::WrappedTargetException,
626 ::com::sun::star::uno::RuntimeException);
627 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
628 const ::com::sun::star::uno::Reference<
629 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
630 throw(::com::sun::star::beans::UnknownPropertyException,
631 ::com::sun::star::lang::WrappedTargetException,
632 ::com::sun::star::uno::RuntimeException);
634 // XServiceInfo
635 virtual OUString SAL_CALL getImplementationName( )
636 throw(::com::sun::star::uno::RuntimeException);
637 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
638 throw(::com::sun::star::uno::RuntimeException);
639 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
640 throw(::com::sun::star::uno::RuntimeException);
642 com::sun::star::uno::Sequence<com::sun::star::sheet::GeneralFunction> getSubTotals() const;
643 bool getShowEmpty() const;
645 const ::com::sun::star::sheet::DataPilotFieldSortInfo& GetSortInfo() const { return aSortInfo; }
646 const ::com::sun::star::sheet::DataPilotFieldAutoShowInfo& GetAutoShow() const { return aAutoShowInfo; }
648 void EvaluateSortOrder();
649 void SetEnableLayout(bool bSet);
651 const ::std::vector<sal_Int32>& GetGlobalOrder() const { return aGlobalOrder; }
652 ::std::vector<sal_Int32>& GetGlobalOrder() { return aGlobalOrder; }
653 long GetSortMeasure() const { return nSortMeasure; }
654 long GetAutoMeasure() const { return nAutoMeasure; }
656 bool IsOutlineLayout() const
658 return bEnableLayout &&
659 aLayoutInfo.LayoutMode !=
660 ::com::sun::star::sheet::DataPilotFieldLayoutMode::TABULAR_LAYOUT;
663 bool IsSubtotalsAtTop() const
665 return bEnableLayout &&
666 aLayoutInfo.LayoutMode ==
667 ::com::sun::star::sheet::DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_TOP;
670 bool IsAddEmpty() const
672 return bEnableLayout && aLayoutInfo.AddEmptyLines;
675 //! number format (for data fields and date fields)
678 // hash map from name to index in the member array, for fast name access
679 typedef ::boost::unordered_map< OUString, sal_Int32, OUStringHash > ScDPMembersHashMap;
681 class ScDPMembers : public cppu::WeakImplHelper2<
682 com::sun::star::container::XNameAccess,
683 com::sun::star::lang::XServiceInfo >
685 private:
686 typedef std::vector<rtl::Reference<ScDPMember> > MembersType;
687 ScDPSource* pSource;
688 long nDim;
689 long nHier;
690 long nLev;
691 long nMbrCount;
692 mutable MembersType maMembers;
693 mutable ScDPMembersHashMap aHashMap;
695 public:
696 ScDPMembers( ScDPSource* pSrc, long nD, long nH, long nL );
697 virtual ~ScDPMembers();
699 // XNameAccess
700 virtual ::com::sun::star::uno::Any SAL_CALL getByName( const OUString& aName )
701 throw(::com::sun::star::container::NoSuchElementException,
702 ::com::sun::star::lang::WrappedTargetException,
703 ::com::sun::star::uno::RuntimeException);
704 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames()
705 throw(::com::sun::star::uno::RuntimeException);
706 virtual sal_Bool SAL_CALL hasByName( const OUString& aName )
707 throw(::com::sun::star::uno::RuntimeException);
709 // XElementAccess
710 virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
711 throw(::com::sun::star::uno::RuntimeException);
712 virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
714 // XServiceInfo
715 virtual OUString SAL_CALL getImplementationName( )
716 throw(::com::sun::star::uno::RuntimeException);
717 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
718 throw(::com::sun::star::uno::RuntimeException);
719 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
720 throw(::com::sun::star::uno::RuntimeException);
722 long getCount() const;
723 ScDPMember* getByIndex(long nIndex) const;
725 long getMinMembers() const;
727 sal_Int32 GetIndexFromName( const OUString& rName ) const; // <0 if not found
728 const std::vector<sal_Int32>& GetGlobalOrder();
729 const ScDPItemData* GetSrcItemDataByIndex( SCROW nIndex);
730 SCROW GetSrcItemsCount();
733 class ScDPMember : boost::noncopyable, public cppu::WeakImplHelper3<
734 com::sun::star::container::XNamed,
735 com::sun::star::beans::XPropertySet,
736 com::sun::star::lang::XServiceInfo >
738 private:
739 ScDPSource* pSource;
740 long nDim;
741 long nHier;
742 long nLev;
744 SCROW mnDataId;
745 boost::scoped_ptr<OUString> mpLayoutName;
747 sal_Int32 nPosition; // manual sorting
748 bool bVisible;
749 bool bShowDet;
751 public:
752 ScDPMember(ScDPSource* pSrc, long nD, long nH, long nL, SCROW nIndex);
753 virtual ~ScDPMember();
755 OUString GetNameStr() const;
756 void FillItemData( ScDPItemData& rData ) const;
757 const ScDPItemData* GetItemData() const;
758 SCROW GetItemDataId() const { return mnDataId; }
759 bool IsNamedItem(SCROW nIndex) const;
761 SC_DLLPUBLIC const OUString* GetLayoutName() const;
762 long GetDim() const;
764 sal_Int32 Compare( const ScDPMember& rOther ) const; // visible order
766 // XNamed
767 virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
768 virtual void SAL_CALL setName( const OUString& aName )
769 throw(::com::sun::star::uno::RuntimeException);
771 // XPropertySet
772 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
773 SAL_CALL getPropertySetInfo( )
774 throw(::com::sun::star::uno::RuntimeException);
775 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
776 const ::com::sun::star::uno::Any& aValue )
777 throw(::com::sun::star::beans::UnknownPropertyException,
778 ::com::sun::star::beans::PropertyVetoException,
779 ::com::sun::star::lang::IllegalArgumentException,
780 ::com::sun::star::lang::WrappedTargetException,
781 ::com::sun::star::uno::RuntimeException);
782 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
783 const OUString& PropertyName )
784 throw(::com::sun::star::beans::UnknownPropertyException,
785 ::com::sun::star::lang::WrappedTargetException,
786 ::com::sun::star::uno::RuntimeException);
787 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
788 const ::com::sun::star::uno::Reference<
789 ::com::sun::star::beans::XPropertyChangeListener >& xListener )
790 throw(::com::sun::star::beans::UnknownPropertyException,
791 ::com::sun::star::lang::WrappedTargetException,
792 ::com::sun::star::uno::RuntimeException);
793 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
794 const ::com::sun::star::uno::Reference<
795 ::com::sun::star::beans::XPropertyChangeListener >& aListener )
796 throw(::com::sun::star::beans::UnknownPropertyException,
797 ::com::sun::star::lang::WrappedTargetException,
798 ::com::sun::star::uno::RuntimeException);
799 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
800 const ::com::sun::star::uno::Reference<
801 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
802 throw(::com::sun::star::beans::UnknownPropertyException,
803 ::com::sun::star::lang::WrappedTargetException,
804 ::com::sun::star::uno::RuntimeException);
805 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
806 const ::com::sun::star::uno::Reference<
807 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
808 throw(::com::sun::star::beans::UnknownPropertyException,
809 ::com::sun::star::lang::WrappedTargetException,
810 ::com::sun::star::uno::RuntimeException);
812 // XServiceInfo
813 virtual OUString SAL_CALL getImplementationName( )
814 throw(::com::sun::star::uno::RuntimeException);
815 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
816 throw(::com::sun::star::uno::RuntimeException);
817 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
818 throw(::com::sun::star::uno::RuntimeException);
820 bool isVisible() const;
821 bool getShowDetails() const;
825 #endif
827 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */