update dev300-m57
[ooovba.git] / sc / inc / dptabsrc.hxx
blobdeb04981ad74751289f9c4f40fbf20d785f1228e
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: dptabsrc.hxx,v $
10 * $Revision: 1.12 $
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_DPTABSRC_HXX
32 #define SC_DPTABSRC_HXX
34 #include <vector>
35 #include <hash_map>
36 #include <memory>
37 #include <tools/string.hxx>
38 #include <tools/list.hxx>
39 #include "global.hxx" // enum ScSubTotalFunc
40 #include <com/sun/star/sheet/XDimensionsSupplier.hpp>
41 #include <com/sun/star/sheet/XHierarchiesSupplier.hpp>
42 #include <com/sun/star/sheet/XLevelsSupplier.hpp>
43 #include <com/sun/star/sheet/XMembersSupplier.hpp>
44 #include <com/sun/star/sheet/XDataPilotResults.hpp>
45 #include <com/sun/star/sheet/XDataPilotMemberResults.hpp>
46 #include <com/sun/star/sheet/MemberResult.hpp>
47 #include <com/sun/star/sheet/GeneralFunction.hpp>
48 #include <com/sun/star/sheet/DataPilotFieldAutoShowInfo.hpp>
49 #include <com/sun/star/sheet/DataPilotFieldLayoutInfo.hpp>
50 #include <com/sun/star/sheet/DataPilotFieldLayoutMode.hpp>
51 #include <com/sun/star/sheet/DataPilotFieldReference.hpp>
52 #include <com/sun/star/sheet/DataPilotFieldSortInfo.hpp>
53 #include <com/sun/star/util/XRefreshable.hpp>
54 #include <com/sun/star/sheet/XDrillDownDataSupplier.hpp>
55 #include <com/sun/star/util/XCloneable.hpp>
56 #include <com/sun/star/beans/XPropertySet.hpp>
57 #include <com/sun/star/lang/XServiceInfo.hpp>
58 #include <com/sun/star/container/XNamed.hpp>
59 #include <cppuhelper/implbase2.hxx>
60 #include <cppuhelper/implbase3.hxx>
61 #include <cppuhelper/implbase5.hxx>
62 #include <cppuhelper/implbase6.hxx>
64 #include "dptabdat.hxx"
66 namespace com { namespace sun { namespace star {
67 namespace sheet {
68 struct DataPilotFieldFilter;
70 namespace table {
71 struct CellAddress;
73 }}}
75 class ScDPResultMember;
76 class ScDPResultData;
77 struct ScDPItemData;
78 class ScDPTableData;
80 // ------------------------------------------------------------------------
83 // should be dynamic!
84 #define SC_DAPI_MAXFIELDS 256
87 // --------------------------------------------------------------------
89 // implementation of DataPilotSource using ScDPTableData
93 class ScDPDimensions;
94 class ScDPDimension;
95 class ScDPHierarchies;
96 class ScDPHierarchy;
97 class ScDPLevels;
98 class ScDPLevel;
99 class ScDPMembers;
100 class ScDPMember;
103 class ScDPSource : public cppu::WeakImplHelper6<
104 com::sun::star::sheet::XDimensionsSupplier,
105 com::sun::star::sheet::XDataPilotResults,
106 com::sun::star::util::XRefreshable,
107 com::sun::star::sheet::XDrillDownDataSupplier,
108 com::sun::star::beans::XPropertySet,
109 com::sun::star::lang::XServiceInfo >
111 private:
112 ScDPTableData* pData; // data source (ScDPObject manages its life time)
113 ScDPDimensions* pDimensions; // api objects
114 // settings:
115 long nColDims[SC_DAPI_MAXFIELDS];
116 long nRowDims[SC_DAPI_MAXFIELDS];
117 long nDataDims[SC_DAPI_MAXFIELDS];
118 long nPageDims[SC_DAPI_MAXFIELDS];
119 long nColDimCount;
120 long nRowDimCount;
121 long nDataDimCount;
122 long nPageDimCount;
123 BOOL bColumnGrand;
124 BOOL bRowGrand;
125 BOOL bIgnoreEmptyRows;
126 BOOL bRepeatIfEmpty;
128 long nDupCount;
130 // results:
131 ScDPResultData* pResData; // keep the rest in this!
132 ScDPResultMember* pColResRoot;
133 ScDPResultMember* pRowResRoot;
134 com::sun::star::uno::Sequence<com::sun::star::sheet::MemberResult>* pColResults;
135 com::sun::star::uno::Sequence<com::sun::star::sheet::MemberResult>* pRowResults;
136 List aColLevelList;
137 List aRowLevelList;
138 BOOL bResultOverflow;
140 ::std::auto_ptr<rtl::OUString> mpGrandTotalName;
142 void CreateRes_Impl();
143 void FillMemberResults();
144 void FillLevelList( USHORT nOrientation, List& rList );
145 void FillCalcInfo(bool bIsRow, ScDPTableData::CalcInfo& rInfo, bool &bHasAutoShow);
147 /**
148 * Compile a list of dimension indices that are either, column, row or
149 * page dimensions (i.e. all but data dimensions).
151 void GetCategoryDimensionIndices(::std::hash_set<sal_Int32>& rCatDims);
153 /**
154 * Set visibilities of individual rows in the cache table based on the
155 * page field data.
157 void FilterCacheTableByPageDimensions();
159 void SetDupCount( long nNew );
161 public:
162 ScDPSource( ScDPTableData* pD ); // TableData is deleted by Source
163 virtual ~ScDPSource();
165 ScDPTableData* GetData() { return pData; }
166 const ScDPTableData* GetData() const { return pData; }
168 void SetGrandTotalName(const ::rtl::OUString& rName);
169 const ::rtl::OUString* GetGrandTotalName() const;
171 USHORT GetOrientation(long nColumn);
172 void SetOrientation(long nColumn, USHORT nNew);
173 long GetPosition(long nColumn);
175 long GetDataDimensionCount();
176 ScDPDimension* GetDataDimension(long nIndex);
177 String GetDataDimName(long nIndex);
178 BOOL IsDataLayoutDimension(long nDim);
179 USHORT GetDataLayoutOrientation();
181 BOOL IsDateDimension(long nDim);
183 BOOL SubTotalAllowed(long nColumn); //! move to ScDPResultData
185 ScDPDimension* AddDuplicated(long nSource, const String& rNewName);
186 long GetDupCount() const { return nDupCount; }
188 long GetSourceDim(long nDim);
190 const com::sun::star::uno::Sequence<com::sun::star::sheet::MemberResult>*
191 GetMemberResults( ScDPLevel* pLevel );
193 ScDPDimensions* GetDimensionsObject();
195 //UNUSED2009-05 void DumpState( ScDocument* pDoc, const ScAddress& rPos );
197 // XDimensionsSupplier
198 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
199 SAL_CALL getDimensions( )
200 throw(::com::sun::star::uno::RuntimeException);
202 // XDataPilotResults
203 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence<
204 ::com::sun::star::sheet::DataResult > > SAL_CALL getResults( )
205 throw(::com::sun::star::uno::RuntimeException);
207 // XRefreshable
208 virtual void SAL_CALL refresh() throw(::com::sun::star::uno::RuntimeException);
209 virtual void SAL_CALL addRefreshListener( const ::com::sun::star::uno::Reference<
210 ::com::sun::star::util::XRefreshListener >& l )
211 throw(::com::sun::star::uno::RuntimeException);
212 virtual void SAL_CALL removeRefreshListener( const ::com::sun::star::uno::Reference<
213 ::com::sun::star::util::XRefreshListener >& l )
214 throw(::com::sun::star::uno::RuntimeException);
216 // XDrillDownDataSupplier
217 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >
218 SAL_CALL getDrillDownData(const ::com::sun::star::uno::Sequence<
219 ::com::sun::star::sheet::DataPilotFieldFilter >& aFilters )
220 throw(::com::sun::star::uno::RuntimeException);
222 // XPropertySet
223 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
224 SAL_CALL getPropertySetInfo( )
225 throw(::com::sun::star::uno::RuntimeException);
226 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName,
227 const ::com::sun::star::uno::Any& aValue )
228 throw(::com::sun::star::beans::UnknownPropertyException,
229 ::com::sun::star::beans::PropertyVetoException,
230 ::com::sun::star::lang::IllegalArgumentException,
231 ::com::sun::star::lang::WrappedTargetException,
232 ::com::sun::star::uno::RuntimeException);
233 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
234 const ::rtl::OUString& PropertyName )
235 throw(::com::sun::star::beans::UnknownPropertyException,
236 ::com::sun::star::lang::WrappedTargetException,
237 ::com::sun::star::uno::RuntimeException);
238 virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
239 const ::com::sun::star::uno::Reference<
240 ::com::sun::star::beans::XPropertyChangeListener >& xListener )
241 throw(::com::sun::star::beans::UnknownPropertyException,
242 ::com::sun::star::lang::WrappedTargetException,
243 ::com::sun::star::uno::RuntimeException);
244 virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
245 const ::com::sun::star::uno::Reference<
246 ::com::sun::star::beans::XPropertyChangeListener >& aListener )
247 throw(::com::sun::star::beans::UnknownPropertyException,
248 ::com::sun::star::lang::WrappedTargetException,
249 ::com::sun::star::uno::RuntimeException);
250 virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName,
251 const ::com::sun::star::uno::Reference<
252 ::com::sun::star::beans::XVetoableChangeListener >& 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 removeVetoableChangeListener( 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);
263 // XServiceInfo
264 virtual ::rtl::OUString SAL_CALL getImplementationName( )
265 throw(::com::sun::star::uno::RuntimeException);
266 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
267 throw(::com::sun::star::uno::RuntimeException);
268 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
269 throw(::com::sun::star::uno::RuntimeException);
271 virtual String getDataDescription(); //! ???
273 virtual BOOL getColumnGrand() const;
274 virtual void setColumnGrand(BOOL bSet);
275 virtual BOOL getRowGrand() const;
276 virtual void setRowGrand(BOOL bSet);
278 virtual BOOL getIgnoreEmptyRows() const;
279 virtual void setIgnoreEmptyRows(BOOL bSet);
280 virtual BOOL getRepeatIfEmpty() const;
281 virtual void setRepeatIfEmpty(BOOL bSet);
283 virtual void validate(); //! ???
284 virtual void disposeData();
287 class ScDPDimensions : public cppu::WeakImplHelper2<
288 com::sun::star::container::XNameAccess,
289 com::sun::star::lang::XServiceInfo >
291 private:
292 ScDPSource* pSource;
293 long nDimCount;
294 ScDPDimension** ppDims;
296 public:
297 ScDPDimensions( ScDPSource* pSrc );
298 virtual ~ScDPDimensions();
300 void CountChanged();
302 // XNameAccess
303 virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
304 throw(::com::sun::star::container::NoSuchElementException,
305 ::com::sun::star::lang::WrappedTargetException,
306 ::com::sun::star::uno::RuntimeException);
307 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
308 throw(::com::sun::star::uno::RuntimeException);
309 virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
310 throw(::com::sun::star::uno::RuntimeException);
312 // XElementAccess
313 virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
314 throw(::com::sun::star::uno::RuntimeException);
315 virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
317 // XServiceInfo
318 virtual ::rtl::OUString SAL_CALL getImplementationName( )
319 throw(::com::sun::star::uno::RuntimeException);
320 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
321 throw(::com::sun::star::uno::RuntimeException);
322 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
323 throw(::com::sun::star::uno::RuntimeException);
325 virtual long getCount() const;
326 virtual ScDPDimension* getByIndex(long nIndex) const;
329 class ScDPDimension : public cppu::WeakImplHelper5<
330 com::sun::star::sheet::XHierarchiesSupplier,
331 com::sun::star::container::XNamed,
332 com::sun::star::util::XCloneable,
333 com::sun::star::beans::XPropertySet,
334 com::sun::star::lang::XServiceInfo >
336 private:
337 ScDPSource* pSource;
338 long nDim; // dimension index (== column ID)
339 ScDPHierarchies* pHierarchies;
340 long nUsedHier;
341 USHORT nFunction; // enum GeneralFunction
342 String aName; // if empty, take from source
343 ::std::auto_ptr<rtl::OUString> mpLayoutName;
344 ::std::auto_ptr<rtl::OUString> mpSubtotalName;
345 long nSourceDim; // >=0 if dup'ed
346 ::com::sun::star::sheet::DataPilotFieldReference
347 aReferenceValue; // settings for "show data as" / "displayed value"
348 BOOL bHasSelectedPage;
349 String aSelectedPage;
350 ScDPItemData* pSelectedData; // internal, temporary, created from aSelectedPage
351 sal_Bool mbHasHiddenMember;
353 public:
354 ScDPDimension( ScDPSource* pSrc, long nD );
355 virtual ~ScDPDimension();
357 long GetDimension() const { return nDim; } // dimension index in source
358 long GetSourceDim() const { return nSourceDim; } // >=0 if dup'ed
360 ScDPDimension* CreateCloneObject();
361 ScDPHierarchies* GetHierarchiesObject();
363 SC_DLLPUBLIC const ::rtl::OUString* GetLayoutName() const;
364 const ::rtl::OUString* GetSubtotalName() const;
366 // XNamed
367 virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
368 virtual void SAL_CALL setName( const ::rtl::OUString& aName )
369 throw(::com::sun::star::uno::RuntimeException);
371 // XHierarchiesSupplier
372 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL
373 getHierarchies() throw(::com::sun::star::uno::RuntimeException);
375 // XCloneable
376 virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL
377 createClone() throw(::com::sun::star::uno::RuntimeException);
379 // XPropertySet
380 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
381 SAL_CALL getPropertySetInfo( )
382 throw(::com::sun::star::uno::RuntimeException);
383 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName,
384 const ::com::sun::star::uno::Any& aValue )
385 throw(::com::sun::star::beans::UnknownPropertyException,
386 ::com::sun::star::beans::PropertyVetoException,
387 ::com::sun::star::lang::IllegalArgumentException,
388 ::com::sun::star::lang::WrappedTargetException,
389 ::com::sun::star::uno::RuntimeException);
390 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
391 const ::rtl::OUString& PropertyName )
392 throw(::com::sun::star::beans::UnknownPropertyException,
393 ::com::sun::star::lang::WrappedTargetException,
394 ::com::sun::star::uno::RuntimeException);
395 virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
396 const ::com::sun::star::uno::Reference<
397 ::com::sun::star::beans::XPropertyChangeListener >& xListener )
398 throw(::com::sun::star::beans::UnknownPropertyException,
399 ::com::sun::star::lang::WrappedTargetException,
400 ::com::sun::star::uno::RuntimeException);
401 virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
402 const ::com::sun::star::uno::Reference<
403 ::com::sun::star::beans::XPropertyChangeListener >& aListener )
404 throw(::com::sun::star::beans::UnknownPropertyException,
405 ::com::sun::star::lang::WrappedTargetException,
406 ::com::sun::star::uno::RuntimeException);
407 virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName,
408 const ::com::sun::star::uno::Reference<
409 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
410 throw(::com::sun::star::beans::UnknownPropertyException,
411 ::com::sun::star::lang::WrappedTargetException,
412 ::com::sun::star::uno::RuntimeException);
413 virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
414 const ::com::sun::star::uno::Reference<
415 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
416 throw(::com::sun::star::beans::UnknownPropertyException,
417 ::com::sun::star::lang::WrappedTargetException,
418 ::com::sun::star::uno::RuntimeException);
420 // XServiceInfo
421 virtual ::rtl::OUString SAL_CALL getImplementationName( )
422 throw(::com::sun::star::uno::RuntimeException);
423 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
424 throw(::com::sun::star::uno::RuntimeException);
425 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
426 throw(::com::sun::star::uno::RuntimeException);
428 virtual USHORT getOrientation() const;
429 virtual void setOrientation(USHORT nNew);
430 virtual long getPosition() const;
431 virtual void setPosition(long nNew);
432 virtual BOOL getIsDataLayoutDimension() const;
433 virtual USHORT getFunction() const;
434 virtual void setFunction(USHORT nNew); // for data dimension
435 virtual long getUsedHierarchy() const;
436 virtual void setUsedHierarchy(long nNew);
437 virtual BOOL isDuplicated() const;
439 BOOL HasSelectedPage() const { return bHasSelectedPage; }
440 const ScDPItemData& GetSelectedData();
442 const ::com::sun::star::sheet::DataPilotFieldReference& GetReferenceValue() const;
444 //UNUSED2009-05 BOOL IsValidPage( const ScDPItemData& rData );
447 class ScDPHierarchies : public cppu::WeakImplHelper2<
448 com::sun::star::container::XNameAccess,
449 com::sun::star::lang::XServiceInfo >
451 private:
452 ScDPSource* pSource;
453 long nDim;
454 long nHierCount;
455 ScDPHierarchy** ppHiers;
457 public:
458 ScDPHierarchies( ScDPSource* pSrc, long nD );
459 virtual ~ScDPHierarchies();
461 // XNameAccess
462 virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
463 throw(::com::sun::star::container::NoSuchElementException,
464 ::com::sun::star::lang::WrappedTargetException,
465 ::com::sun::star::uno::RuntimeException);
466 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
467 throw(::com::sun::star::uno::RuntimeException);
468 virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
469 throw(::com::sun::star::uno::RuntimeException);
471 // XElementAccess
472 virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
473 throw(::com::sun::star::uno::RuntimeException);
474 virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
476 // XServiceInfo
477 virtual ::rtl::OUString SAL_CALL getImplementationName( )
478 throw(::com::sun::star::uno::RuntimeException);
479 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
480 throw(::com::sun::star::uno::RuntimeException);
481 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
482 throw(::com::sun::star::uno::RuntimeException);
484 virtual long getCount() const;
485 virtual ScDPHierarchy* getByIndex(long nIndex) const;
488 class ScDPHierarchy : public cppu::WeakImplHelper3<
489 com::sun::star::sheet::XLevelsSupplier,
490 com::sun::star::container::XNamed,
491 com::sun::star::lang::XServiceInfo >
493 private:
494 ScDPSource* pSource;
495 long nDim;
496 long nHier;
497 ScDPLevels* pLevels;
499 public:
500 ScDPHierarchy( ScDPSource* pSrc, long nD, long nH );
501 virtual ~ScDPHierarchy();
503 ScDPLevels* GetLevelsObject();
505 // XNamed
506 virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
507 virtual void SAL_CALL setName( const ::rtl::OUString& aName )
508 throw(::com::sun::star::uno::RuntimeException);
510 // XLevelsSupplier
511 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL
512 getLevels() throw(::com::sun::star::uno::RuntimeException);
514 // XServiceInfo
515 virtual ::rtl::OUString SAL_CALL getImplementationName( )
516 throw(::com::sun::star::uno::RuntimeException);
517 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
518 throw(::com::sun::star::uno::RuntimeException);
519 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
520 throw(::com::sun::star::uno::RuntimeException);
523 class ScDPLevels : public cppu::WeakImplHelper2<
524 com::sun::star::container::XNameAccess,
525 com::sun::star::lang::XServiceInfo >
527 private:
528 ScDPSource* pSource;
529 long nDim;
530 long nHier;
531 long nLevCount;
532 ScDPLevel** ppLevs;
534 public:
535 ScDPLevels( ScDPSource* pSrc, long nD, long nH );
536 virtual ~ScDPLevels();
538 // XNameAccess
539 virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
540 throw(::com::sun::star::container::NoSuchElementException,
541 ::com::sun::star::lang::WrappedTargetException,
542 ::com::sun::star::uno::RuntimeException);
543 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
544 throw(::com::sun::star::uno::RuntimeException);
545 virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
546 throw(::com::sun::star::uno::RuntimeException);
548 // XElementAccess
549 virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
550 throw(::com::sun::star::uno::RuntimeException);
551 virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
553 // XServiceInfo
554 virtual ::rtl::OUString SAL_CALL getImplementationName( )
555 throw(::com::sun::star::uno::RuntimeException);
556 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
557 throw(::com::sun::star::uno::RuntimeException);
558 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
559 throw(::com::sun::star::uno::RuntimeException);
561 virtual long getCount() const;
562 virtual ScDPLevel* getByIndex(long nIndex) const;
565 class ScDPLevel : public cppu::WeakImplHelper5<
566 com::sun::star::sheet::XMembersSupplier,
567 com::sun::star::container::XNamed,
568 com::sun::star::sheet::XDataPilotMemberResults,
569 com::sun::star::beans::XPropertySet,
570 com::sun::star::lang::XServiceInfo >
572 private:
573 ScDPSource* pSource;
574 long nDim;
575 long nHier;
576 long nLev;
577 ScDPMembers* pMembers;
578 com::sun::star::uno::Sequence<com::sun::star::sheet::GeneralFunction> aSubTotals;
579 BOOL bShowEmpty;
580 ::com::sun::star::sheet::DataPilotFieldSortInfo aSortInfo; // stored user settings
581 ::com::sun::star::sheet::DataPilotFieldAutoShowInfo aAutoShowInfo; // stored user settings
582 ::com::sun::star::sheet::DataPilotFieldLayoutInfo aLayoutInfo; // stored user settings
583 // valid only from result calculation:
584 ::std::vector<sal_Int32> aGlobalOrder; // result of sorting by name or position
585 long nSortMeasure; // measure (index of data dimension) to sort by
586 long nAutoMeasure; // measure (index of data dimension) for AutoShow
587 BOOL bEnableLayout; // enabled only for row fields, not for the innermost one
589 public:
590 ScDPLevel( ScDPSource* pSrc, long nD, long nH, long nL );
591 virtual ~ScDPLevel();
593 ScDPMembers* GetMembersObject();
595 // XNamed
596 virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
597 virtual void SAL_CALL setName( const ::rtl::OUString& aName )
598 throw(::com::sun::star::uno::RuntimeException);
600 // XMembersSupplier
601 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL
602 getMembers() throw(::com::sun::star::uno::RuntimeException);
604 // XDataPilotMemberResults
605 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::MemberResult > SAL_CALL
606 getResults() throw(::com::sun::star::uno::RuntimeException);
608 // XPropertySet
609 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
610 SAL_CALL getPropertySetInfo( )
611 throw(::com::sun::star::uno::RuntimeException);
612 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName,
613 const ::com::sun::star::uno::Any& aValue )
614 throw(::com::sun::star::beans::UnknownPropertyException,
615 ::com::sun::star::beans::PropertyVetoException,
616 ::com::sun::star::lang::IllegalArgumentException,
617 ::com::sun::star::lang::WrappedTargetException,
618 ::com::sun::star::uno::RuntimeException);
619 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
620 const ::rtl::OUString& PropertyName )
621 throw(::com::sun::star::beans::UnknownPropertyException,
622 ::com::sun::star::lang::WrappedTargetException,
623 ::com::sun::star::uno::RuntimeException);
624 virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
625 const ::com::sun::star::uno::Reference<
626 ::com::sun::star::beans::XPropertyChangeListener >& xListener )
627 throw(::com::sun::star::beans::UnknownPropertyException,
628 ::com::sun::star::lang::WrappedTargetException,
629 ::com::sun::star::uno::RuntimeException);
630 virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
631 const ::com::sun::star::uno::Reference<
632 ::com::sun::star::beans::XPropertyChangeListener >& aListener )
633 throw(::com::sun::star::beans::UnknownPropertyException,
634 ::com::sun::star::lang::WrappedTargetException,
635 ::com::sun::star::uno::RuntimeException);
636 virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName,
637 const ::com::sun::star::uno::Reference<
638 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
639 throw(::com::sun::star::beans::UnknownPropertyException,
640 ::com::sun::star::lang::WrappedTargetException,
641 ::com::sun::star::uno::RuntimeException);
642 virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
643 const ::com::sun::star::uno::Reference<
644 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
645 throw(::com::sun::star::beans::UnknownPropertyException,
646 ::com::sun::star::lang::WrappedTargetException,
647 ::com::sun::star::uno::RuntimeException);
649 // XServiceInfo
650 virtual ::rtl::OUString SAL_CALL getImplementationName( )
651 throw(::com::sun::star::uno::RuntimeException);
652 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
653 throw(::com::sun::star::uno::RuntimeException);
654 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
655 throw(::com::sun::star::uno::RuntimeException);
657 virtual com::sun::star::uno::Sequence<com::sun::star::sheet::GeneralFunction> getSubTotals() const;
658 virtual void setSubTotals(const com::sun::star::uno::Sequence<
659 com::sun::star::sheet::GeneralFunction>& rNew);
660 virtual BOOL getShowEmpty() const;
661 virtual void setShowEmpty(BOOL bSet);
663 const ::com::sun::star::sheet::DataPilotFieldSortInfo& GetSortInfo() const { return aSortInfo; }
664 const ::com::sun::star::sheet::DataPilotFieldAutoShowInfo& GetAutoShow() const { return aAutoShowInfo; }
666 void EvaluateSortOrder();
667 void SetEnableLayout( BOOL bSet );
669 const ::std::vector<sal_Int32>& GetGlobalOrder() const { return aGlobalOrder; }
670 ::std::vector<sal_Int32>& GetGlobalOrder() { return aGlobalOrder; }
671 long GetSortMeasure() const { return nSortMeasure; }
672 long GetAutoMeasure() const { return nAutoMeasure; }
674 BOOL IsOutlineLayout() const
675 { return bEnableLayout &&
676 aLayoutInfo.LayoutMode !=
677 ::com::sun::star::sheet::DataPilotFieldLayoutMode::TABULAR_LAYOUT; }
679 BOOL IsSubtotalsAtTop() const
680 { return bEnableLayout &&
681 aLayoutInfo.LayoutMode ==
682 ::com::sun::star::sheet::DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_TOP; }
684 BOOL IsAddEmpty() const { return bEnableLayout && aLayoutInfo.AddEmptyLines; }
686 //! number format (for data fields and date fields)
689 // hash map from name to index in the member array, for fast name access
690 typedef ::std::hash_map< ::rtl::OUString, sal_Int32, ::rtl::OUStringHash > ScDPMembersHashMap;
692 class ScDPMembers : public cppu::WeakImplHelper2<
693 com::sun::star::container::XNameAccess,
694 com::sun::star::lang::XServiceInfo >
696 private:
697 ScDPSource* pSource;
698 long nDim;
699 long nHier;
700 long nLev;
701 long nMbrCount;
702 ScDPMember** ppMbrs;
703 mutable ScDPMembersHashMap aHashMap;
705 public:
706 ScDPMembers( ScDPSource* pSrc, long nD, long nH, long nL );
707 virtual ~ScDPMembers();
709 // XNameAccess
710 virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
711 throw(::com::sun::star::container::NoSuchElementException,
712 ::com::sun::star::lang::WrappedTargetException,
713 ::com::sun::star::uno::RuntimeException);
714 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
715 throw(::com::sun::star::uno::RuntimeException);
716 virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
717 throw(::com::sun::star::uno::RuntimeException);
719 // XElementAccess
720 virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
721 throw(::com::sun::star::uno::RuntimeException);
722 virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
724 // XServiceInfo
725 virtual ::rtl::OUString SAL_CALL getImplementationName( )
726 throw(::com::sun::star::uno::RuntimeException);
727 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
728 throw(::com::sun::star::uno::RuntimeException);
729 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
730 throw(::com::sun::star::uno::RuntimeException);
732 virtual long getCount() const;
733 virtual ScDPMember* getByIndex(long nIndex) const;
735 long getMinMembers() const;
737 sal_Int32 GetIndexFromName( const ::rtl::OUString& rName ) const; // <0 if not found
740 class ScDPMember : public cppu::WeakImplHelper3<
741 com::sun::star::container::XNamed,
742 com::sun::star::beans::XPropertySet,
743 com::sun::star::lang::XServiceInfo >
745 private:
746 ScDPSource* pSource;
747 long nDim;
748 long nHier;
749 long nLev;
751 ScDPItemData maData;
752 ::std::auto_ptr<rtl::OUString> mpLayoutName;
754 sal_Int32 nPosition; // manual sorting
755 BOOL bVisible;
756 BOOL bShowDet;
758 public:
759 ScDPMember( ScDPSource* pSrc, long nD, long nH, long nL,
760 const String& rN, double fV, BOOL bHV );
761 virtual ~ScDPMember();
763 BOOL IsNamedItem( const ScDPItemData& r ) const;
764 String GetNameStr() const;
765 void FillItemData( ScDPItemData& rData ) const;
766 SC_DLLPUBLIC const ::rtl::OUString* GetLayoutName() const;
768 sal_Int32 Compare( const ScDPMember& rOther ) const; // visible order
770 // XNamed
771 virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
772 virtual void SAL_CALL setName( const ::rtl::OUString& aName )
773 throw(::com::sun::star::uno::RuntimeException);
775 // XPropertySet
776 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
777 SAL_CALL getPropertySetInfo( )
778 throw(::com::sun::star::uno::RuntimeException);
779 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName,
780 const ::com::sun::star::uno::Any& aValue )
781 throw(::com::sun::star::beans::UnknownPropertyException,
782 ::com::sun::star::beans::PropertyVetoException,
783 ::com::sun::star::lang::IllegalArgumentException,
784 ::com::sun::star::lang::WrappedTargetException,
785 ::com::sun::star::uno::RuntimeException);
786 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
787 const ::rtl::OUString& PropertyName )
788 throw(::com::sun::star::beans::UnknownPropertyException,
789 ::com::sun::star::lang::WrappedTargetException,
790 ::com::sun::star::uno::RuntimeException);
791 virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
792 const ::com::sun::star::uno::Reference<
793 ::com::sun::star::beans::XPropertyChangeListener >& xListener )
794 throw(::com::sun::star::beans::UnknownPropertyException,
795 ::com::sun::star::lang::WrappedTargetException,
796 ::com::sun::star::uno::RuntimeException);
797 virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
798 const ::com::sun::star::uno::Reference<
799 ::com::sun::star::beans::XPropertyChangeListener >& aListener )
800 throw(::com::sun::star::beans::UnknownPropertyException,
801 ::com::sun::star::lang::WrappedTargetException,
802 ::com::sun::star::uno::RuntimeException);
803 virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName,
804 const ::com::sun::star::uno::Reference<
805 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
806 throw(::com::sun::star::beans::UnknownPropertyException,
807 ::com::sun::star::lang::WrappedTargetException,
808 ::com::sun::star::uno::RuntimeException);
809 virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
810 const ::com::sun::star::uno::Reference<
811 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
812 throw(::com::sun::star::beans::UnknownPropertyException,
813 ::com::sun::star::lang::WrappedTargetException,
814 ::com::sun::star::uno::RuntimeException);
816 // XServiceInfo
817 virtual ::rtl::OUString SAL_CALL getImplementationName( )
818 throw(::com::sun::star::uno::RuntimeException);
819 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
820 throw(::com::sun::star::uno::RuntimeException);
821 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
822 throw(::com::sun::star::uno::RuntimeException);
824 virtual BOOL getIsVisible() const;
825 virtual void setIsVisible(BOOL bSet);
826 virtual BOOL getShowDetails() const;
827 virtual void setShowDetails(BOOL bSet);
829 sal_Int32 getPosition() const;
830 void setPosition(sal_Int32 nNew);
834 #endif