Impress Remote 1.0.5, tag sdremote-1.0.5
[LibreOffice.git] / sc / inc / dptabsrc.hxx
blob1aefebc69523c963776206a993b66231915f6edd
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 <tools/string.hxx>
24 #include "global.hxx" // enum ScSubTotalFunc
25 #include <com/sun/star/sheet/XDimensionsSupplier.hpp>
26 #include <com/sun/star/sheet/XHierarchiesSupplier.hpp>
27 #include <com/sun/star/sheet/XLevelsSupplier.hpp>
28 #include <com/sun/star/sheet/XMembersSupplier.hpp>
29 #include <com/sun/star/sheet/XDataPilotResults.hpp>
30 #include <com/sun/star/sheet/XDataPilotMemberResults.hpp>
31 #include <com/sun/star/sheet/MemberResult.hpp>
32 #include <com/sun/star/sheet/GeneralFunction.hpp>
33 #include <com/sun/star/sheet/DataPilotFieldAutoShowInfo.hpp>
34 #include <com/sun/star/sheet/DataPilotFieldLayoutInfo.hpp>
35 #include <com/sun/star/sheet/DataPilotFieldLayoutMode.hpp>
36 #include <com/sun/star/sheet/DataPilotFieldReference.hpp>
37 #include <com/sun/star/sheet/DataPilotFieldSortInfo.hpp>
38 #include <com/sun/star/util/XRefreshable.hpp>
39 #include <com/sun/star/sheet/XDrillDownDataSupplier.hpp>
40 #include <com/sun/star/util/XCloneable.hpp>
41 #include <com/sun/star/beans/XPropertySet.hpp>
42 #include <com/sun/star/lang/XServiceInfo.hpp>
43 #include <com/sun/star/container/XNamed.hpp>
44 #include <cppuhelper/implbase2.hxx>
45 #include <cppuhelper/implbase3.hxx>
46 #include <cppuhelper/implbase5.hxx>
47 #include <cppuhelper/implbase6.hxx>
48 #include "rtl/ref.hxx"
50 #include "dptabdat.hxx"
51 #include "dpglobal.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;
107 bool bColumnGrand;
108 bool bRowGrand;
109 bool bIgnoreEmptyRows;
110 bool bRepeatIfEmpty;
112 long nDupCount;
114 // results:
115 ScDPResultData* pResData; // keep the rest in this!
116 ScDPResultMember* pColResRoot;
117 ScDPResultMember* pRowResRoot;
118 com::sun::star::uno::Sequence<com::sun::star::sheet::MemberResult>* pColResults;
119 com::sun::star::uno::Sequence<com::sun::star::sheet::MemberResult>* pRowResults;
120 std::vector<ScDPLevel*> aColLevelList;
121 std::vector<ScDPLevel*> aRowLevelList;
122 bool bResultOverflow;
123 bool bPageFiltered; // set if page field filters have been applied to cache table
125 SAL_WNODEPRECATED_DECLARATIONS_PUSH
126 ::std::auto_ptr<rtl::OUString> mpGrandTotalName;
127 SAL_WNODEPRECATED_DECLARATIONS_POP
129 void CreateRes_Impl();
130 void FillMemberResults();
131 void FillLevelList( sal_uInt16 nOrientation, std::vector<ScDPLevel*> &rList );
132 void FillCalcInfo(bool bIsRow, ScDPTableData::CalcInfo& rInfo, bool &bHasAutoShow);
135 * Compile a list of dimension indices that are either, column, row or
136 * page dimensions (i.e. all but data dimensions).
138 void GetCategoryDimensionIndices(::boost::unordered_set<sal_Int32>& rCatDims);
141 * Set visibilities of individual rows in the cache table based on the
142 * page field data.
144 void FilterCacheByPageDimensions();
146 void SetDupCount( long nNew );
148 rtl::OUString getDataDescription(); //! ???
150 void setIgnoreEmptyRows(bool bSet);
151 void setRepeatIfEmpty(bool bSet);
153 void disposeData();
155 public:
156 ScDPSource( ScDPTableData* pD );
157 virtual ~ScDPSource();
159 ScDPTableData* GetData() { return pData; }
160 const ScDPTableData* GetData() const { return pData; }
162 const ::rtl::OUString* GetGrandTotalName() const;
164 sal_uInt16 GetOrientation(long nColumn);
165 void SetOrientation(long nColumn, sal_uInt16 nNew);
166 long GetPosition(long nColumn);
168 long GetDataDimensionCount();
169 ScDPDimension* GetDataDimension(long nIndex);
170 rtl::OUString GetDataDimName(long nIndex);
171 const ScDPCache* GetCache();
172 const ScDPItemData* GetItemDataById( long nDim, long nId );
173 long GetDataLayoutDim(){ return pData->GetColumnCount(); }
174 SCROW GetMemberId( long nDim, const ScDPItemData& rData );
175 sal_Bool IsDataLayoutDimension(long nDim);
176 sal_uInt16 GetDataLayoutOrientation();
178 sal_Bool IsDateDimension(long nDim);
180 sal_Bool SubTotalAllowed(long nColumn); //! move to ScDPResultData
182 ScDPDimension* AddDuplicated(long nSource, const rtl::OUString& rNewName);
183 long GetDupCount() const { return nDupCount; }
185 long GetSourceDim(long nDim);
187 const com::sun::star::uno::Sequence<com::sun::star::sheet::MemberResult>*
188 GetMemberResults( ScDPLevel* pLevel );
190 ScDPDimensions* GetDimensionsObject();
192 // XDimensionsSupplier
193 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
194 SAL_CALL getDimensions( )
195 throw(::com::sun::star::uno::RuntimeException);
197 // XDataPilotResults
198 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence<
199 ::com::sun::star::sheet::DataResult > > SAL_CALL getResults( )
200 throw(::com::sun::star::uno::RuntimeException);
202 // XRefreshable
203 virtual void SAL_CALL refresh() throw(::com::sun::star::uno::RuntimeException);
204 virtual void SAL_CALL addRefreshListener( const ::com::sun::star::uno::Reference<
205 ::com::sun::star::util::XRefreshListener >& l )
206 throw(::com::sun::star::uno::RuntimeException);
207 virtual void SAL_CALL removeRefreshListener( const ::com::sun::star::uno::Reference<
208 ::com::sun::star::util::XRefreshListener >& l )
209 throw(::com::sun::star::uno::RuntimeException);
211 // XDrillDownDataSupplier
212 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >
213 SAL_CALL getDrillDownData(const ::com::sun::star::uno::Sequence<
214 ::com::sun::star::sheet::DataPilotFieldFilter >& aFilters )
215 throw(::com::sun::star::uno::RuntimeException);
217 // XPropertySet
218 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
219 SAL_CALL getPropertySetInfo( )
220 throw(::com::sun::star::uno::RuntimeException);
221 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName,
222 const ::com::sun::star::uno::Any& aValue )
223 throw(::com::sun::star::beans::UnknownPropertyException,
224 ::com::sun::star::beans::PropertyVetoException,
225 ::com::sun::star::lang::IllegalArgumentException,
226 ::com::sun::star::lang::WrappedTargetException,
227 ::com::sun::star::uno::RuntimeException);
228 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
229 const ::rtl::OUString& PropertyName )
230 throw(::com::sun::star::beans::UnknownPropertyException,
231 ::com::sun::star::lang::WrappedTargetException,
232 ::com::sun::star::uno::RuntimeException);
233 virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
234 const ::com::sun::star::uno::Reference<
235 ::com::sun::star::beans::XPropertyChangeListener >& xListener )
236 throw(::com::sun::star::beans::UnknownPropertyException,
237 ::com::sun::star::lang::WrappedTargetException,
238 ::com::sun::star::uno::RuntimeException);
239 virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
240 const ::com::sun::star::uno::Reference<
241 ::com::sun::star::beans::XPropertyChangeListener >& aListener )
242 throw(::com::sun::star::beans::UnknownPropertyException,
243 ::com::sun::star::lang::WrappedTargetException,
244 ::com::sun::star::uno::RuntimeException);
245 virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName,
246 const ::com::sun::star::uno::Reference<
247 ::com::sun::star::beans::XVetoableChangeListener >& 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 removeVetoableChangeListener( const ::rtl::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);
258 // XServiceInfo
259 virtual ::rtl::OUString SAL_CALL getImplementationName( )
260 throw(::com::sun::star::uno::RuntimeException);
261 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
262 throw(::com::sun::star::uno::RuntimeException);
263 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
264 throw(::com::sun::star::uno::RuntimeException);
267 class ScDPDimensions : public cppu::WeakImplHelper2<
268 com::sun::star::container::XNameAccess,
269 com::sun::star::lang::XServiceInfo >
271 private:
272 ScDPSource* pSource;
273 long nDimCount;
274 ScDPDimension** ppDims;
276 public:
277 ScDPDimensions( ScDPSource* pSrc );
278 virtual ~ScDPDimensions();
280 void CountChanged();
282 // XNameAccess
283 virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
284 throw(::com::sun::star::container::NoSuchElementException,
285 ::com::sun::star::lang::WrappedTargetException,
286 ::com::sun::star::uno::RuntimeException);
287 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
288 throw(::com::sun::star::uno::RuntimeException);
289 virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
290 throw(::com::sun::star::uno::RuntimeException);
292 // XElementAccess
293 virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
294 throw(::com::sun::star::uno::RuntimeException);
295 virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
297 // XServiceInfo
298 virtual ::rtl::OUString SAL_CALL getImplementationName( )
299 throw(::com::sun::star::uno::RuntimeException);
300 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
301 throw(::com::sun::star::uno::RuntimeException);
302 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
303 throw(::com::sun::star::uno::RuntimeException);
305 virtual long getCount() const;
306 virtual ScDPDimension* getByIndex(long nIndex) const;
309 class ScDPDimension : boost::noncopyable, public cppu::WeakImplHelper5<
310 com::sun::star::sheet::XHierarchiesSupplier,
311 com::sun::star::container::XNamed,
312 com::sun::star::util::XCloneable,
313 com::sun::star::beans::XPropertySet,
314 com::sun::star::lang::XServiceInfo >
316 ScDPSource* pSource;
317 long nDim; // dimension index (== column ID)
318 ScDPHierarchies* pHierarchies;
319 long nUsedHier;
320 sal_uInt16 nFunction; // enum GeneralFunction
321 rtl::OUString aName; // if empty, take from source
322 boost::scoped_ptr<rtl::OUString> mpLayoutName;
323 boost::scoped_ptr<rtl::OUString> mpSubtotalName;
324 long nSourceDim; // >=0 if dup'ed
325 ::com::sun::star::sheet::DataPilotFieldReference
326 aReferenceValue; // settings for "show data as" / "displayed value"
327 bool bHasSelectedPage;
328 rtl::OUString aSelectedPage;
329 ScDPItemData* pSelectedData; // internal, temporary, created from aSelectedPage
330 bool mbHasHiddenMember;
332 public:
333 ScDPDimension( ScDPSource* pSrc, long nD );
334 virtual ~ScDPDimension();
336 long GetDimension() const { return nDim; } // dimension index in source
337 long GetSourceDim() const { return nSourceDim; } // >=0 if dup'ed
339 ScDPDimension* CreateCloneObject();
340 ScDPHierarchies* GetHierarchiesObject();
342 SC_DLLPUBLIC const ::rtl::OUString* GetLayoutName() const;
343 const ::rtl::OUString* GetSubtotalName() const;
345 // XNamed
346 virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
347 virtual void SAL_CALL setName( const ::rtl::OUString& aName )
348 throw(::com::sun::star::uno::RuntimeException);
350 // XHierarchiesSupplier
351 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL
352 getHierarchies() throw(::com::sun::star::uno::RuntimeException);
354 // XCloneable
355 virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL
356 createClone() throw(::com::sun::star::uno::RuntimeException);
358 // XPropertySet
359 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
360 SAL_CALL getPropertySetInfo( )
361 throw(::com::sun::star::uno::RuntimeException);
362 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName,
363 const ::com::sun::star::uno::Any& aValue )
364 throw(::com::sun::star::beans::UnknownPropertyException,
365 ::com::sun::star::beans::PropertyVetoException,
366 ::com::sun::star::lang::IllegalArgumentException,
367 ::com::sun::star::lang::WrappedTargetException,
368 ::com::sun::star::uno::RuntimeException);
369 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
370 const ::rtl::OUString& PropertyName )
371 throw(::com::sun::star::beans::UnknownPropertyException,
372 ::com::sun::star::lang::WrappedTargetException,
373 ::com::sun::star::uno::RuntimeException);
374 virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
375 const ::com::sun::star::uno::Reference<
376 ::com::sun::star::beans::XPropertyChangeListener >& xListener )
377 throw(::com::sun::star::beans::UnknownPropertyException,
378 ::com::sun::star::lang::WrappedTargetException,
379 ::com::sun::star::uno::RuntimeException);
380 virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
381 const ::com::sun::star::uno::Reference<
382 ::com::sun::star::beans::XPropertyChangeListener >& aListener )
383 throw(::com::sun::star::beans::UnknownPropertyException,
384 ::com::sun::star::lang::WrappedTargetException,
385 ::com::sun::star::uno::RuntimeException);
386 virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName,
387 const ::com::sun::star::uno::Reference<
388 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
389 throw(::com::sun::star::beans::UnknownPropertyException,
390 ::com::sun::star::lang::WrappedTargetException,
391 ::com::sun::star::uno::RuntimeException);
392 virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
393 const ::com::sun::star::uno::Reference<
394 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
395 throw(::com::sun::star::beans::UnknownPropertyException,
396 ::com::sun::star::lang::WrappedTargetException,
397 ::com::sun::star::uno::RuntimeException);
399 // XServiceInfo
400 virtual ::rtl::OUString SAL_CALL getImplementationName( )
401 throw(::com::sun::star::uno::RuntimeException);
402 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
403 throw(::com::sun::star::uno::RuntimeException);
404 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
405 throw(::com::sun::star::uno::RuntimeException);
407 sal_uInt16 getOrientation() const;
408 void setOrientation(sal_uInt16 nNew);
409 long getPosition() const;
410 bool getIsDataLayoutDimension() const;
411 sal_uInt16 getFunction() const;
412 void setFunction(sal_uInt16 nNew); // for data dimension
413 long getUsedHierarchy() const;
414 void setUsedHierarchy(long nNew);
416 bool HasSelectedPage() const { return bHasSelectedPage; }
417 const ScDPItemData& GetSelectedData();
419 const ::com::sun::star::sheet::DataPilotFieldReference& GetReferenceValue() const;
422 class ScDPHierarchies : public cppu::WeakImplHelper2<
423 com::sun::star::container::XNameAccess,
424 com::sun::star::lang::XServiceInfo >
426 private:
427 ScDPSource* pSource;
428 long nDim;
429 long nHierCount;
430 ScDPHierarchy** ppHiers;
432 public:
433 ScDPHierarchies( ScDPSource* pSrc, long nD );
434 virtual ~ScDPHierarchies();
436 // XNameAccess
437 virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
438 throw(::com::sun::star::container::NoSuchElementException,
439 ::com::sun::star::lang::WrappedTargetException,
440 ::com::sun::star::uno::RuntimeException);
441 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
442 throw(::com::sun::star::uno::RuntimeException);
443 virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
444 throw(::com::sun::star::uno::RuntimeException);
446 // XElementAccess
447 virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
448 throw(::com::sun::star::uno::RuntimeException);
449 virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
451 // XServiceInfo
452 virtual ::rtl::OUString SAL_CALL getImplementationName( )
453 throw(::com::sun::star::uno::RuntimeException);
454 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
455 throw(::com::sun::star::uno::RuntimeException);
456 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
457 throw(::com::sun::star::uno::RuntimeException);
459 virtual long getCount() const;
460 virtual ScDPHierarchy* getByIndex(long nIndex) const;
463 class ScDPHierarchy : public cppu::WeakImplHelper3<
464 com::sun::star::sheet::XLevelsSupplier,
465 com::sun::star::container::XNamed,
466 com::sun::star::lang::XServiceInfo >
468 private:
469 ScDPSource* pSource;
470 long nDim;
471 long nHier;
472 ScDPLevels* pLevels;
474 public:
475 ScDPHierarchy( ScDPSource* pSrc, long nD, long nH );
476 virtual ~ScDPHierarchy();
478 ScDPLevels* GetLevelsObject();
480 // XNamed
481 virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
482 virtual void SAL_CALL setName( const ::rtl::OUString& aName )
483 throw(::com::sun::star::uno::RuntimeException);
485 // XLevelsSupplier
486 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL
487 getLevels() throw(::com::sun::star::uno::RuntimeException);
489 // XServiceInfo
490 virtual ::rtl::OUString SAL_CALL getImplementationName( )
491 throw(::com::sun::star::uno::RuntimeException);
492 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
493 throw(::com::sun::star::uno::RuntimeException);
494 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
495 throw(::com::sun::star::uno::RuntimeException);
498 class ScDPLevels : public cppu::WeakImplHelper2<
499 com::sun::star::container::XNameAccess,
500 com::sun::star::lang::XServiceInfo >
502 private:
503 ScDPSource* pSource;
504 long nDim;
505 long nHier;
506 long nLevCount;
507 ScDPLevel** ppLevs;
509 public:
510 ScDPLevels( ScDPSource* pSrc, long nD, long nH );
511 virtual ~ScDPLevels();
513 // XNameAccess
514 virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
515 throw(::com::sun::star::container::NoSuchElementException,
516 ::com::sun::star::lang::WrappedTargetException,
517 ::com::sun::star::uno::RuntimeException);
518 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
519 throw(::com::sun::star::uno::RuntimeException);
520 virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
521 throw(::com::sun::star::uno::RuntimeException);
523 // XElementAccess
524 virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
525 throw(::com::sun::star::uno::RuntimeException);
526 virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
528 // XServiceInfo
529 virtual ::rtl::OUString SAL_CALL getImplementationName( )
530 throw(::com::sun::star::uno::RuntimeException);
531 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
532 throw(::com::sun::star::uno::RuntimeException);
533 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
534 throw(::com::sun::star::uno::RuntimeException);
536 virtual long getCount() const;
537 virtual ScDPLevel* getByIndex(long nIndex) const;
540 class ScDPLevel : public cppu::WeakImplHelper5<
541 com::sun::star::sheet::XMembersSupplier,
542 com::sun::star::container::XNamed,
543 com::sun::star::sheet::XDataPilotMemberResults,
544 com::sun::star::beans::XPropertySet,
545 com::sun::star::lang::XServiceInfo >
547 private:
548 ScDPSource* pSource;
549 long nDim;
550 long nHier;
551 long nLev;
552 ScDPMembers* pMembers;
553 com::sun::star::uno::Sequence<com::sun::star::sheet::GeneralFunction> aSubTotals;
554 ::com::sun::star::sheet::DataPilotFieldSortInfo aSortInfo; // stored user settings
555 ::com::sun::star::sheet::DataPilotFieldAutoShowInfo aAutoShowInfo; // stored user settings
556 ::com::sun::star::sheet::DataPilotFieldLayoutInfo aLayoutInfo; // stored user settings
557 // valid only from result calculation:
558 ::std::vector<sal_Int32> aGlobalOrder; // result of sorting by name or position
559 long nSortMeasure; // measure (index of data dimension) to sort by
560 long nAutoMeasure; // measure (index of data dimension) for AutoShow
561 bool bShowEmpty:1;
562 bool bEnableLayout:1; // enabled only for row fields, not for the innermost one
564 public:
565 ScDPLevel( ScDPSource* pSrc, long nD, long nH, long nL );
566 virtual ~ScDPLevel();
568 ScDPMembers* GetMembersObject();
570 // XNamed
571 virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
572 virtual void SAL_CALL setName( const ::rtl::OUString& aName )
573 throw(::com::sun::star::uno::RuntimeException);
575 // XMembersSupplier
576 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL
577 getMembers() throw(::com::sun::star::uno::RuntimeException);
579 // XDataPilotMemberResults
580 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::MemberResult > SAL_CALL
581 getResults() throw(::com::sun::star::uno::RuntimeException);
583 // XPropertySet
584 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
585 SAL_CALL getPropertySetInfo( )
586 throw(::com::sun::star::uno::RuntimeException);
587 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName,
588 const ::com::sun::star::uno::Any& aValue )
589 throw(::com::sun::star::beans::UnknownPropertyException,
590 ::com::sun::star::beans::PropertyVetoException,
591 ::com::sun::star::lang::IllegalArgumentException,
592 ::com::sun::star::lang::WrappedTargetException,
593 ::com::sun::star::uno::RuntimeException);
594 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
595 const ::rtl::OUString& PropertyName )
596 throw(::com::sun::star::beans::UnknownPropertyException,
597 ::com::sun::star::lang::WrappedTargetException,
598 ::com::sun::star::uno::RuntimeException);
599 virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
600 const ::com::sun::star::uno::Reference<
601 ::com::sun::star::beans::XPropertyChangeListener >& xListener )
602 throw(::com::sun::star::beans::UnknownPropertyException,
603 ::com::sun::star::lang::WrappedTargetException,
604 ::com::sun::star::uno::RuntimeException);
605 virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
606 const ::com::sun::star::uno::Reference<
607 ::com::sun::star::beans::XPropertyChangeListener >& aListener )
608 throw(::com::sun::star::beans::UnknownPropertyException,
609 ::com::sun::star::lang::WrappedTargetException,
610 ::com::sun::star::uno::RuntimeException);
611 virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName,
612 const ::com::sun::star::uno::Reference<
613 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
614 throw(::com::sun::star::beans::UnknownPropertyException,
615 ::com::sun::star::lang::WrappedTargetException,
616 ::com::sun::star::uno::RuntimeException);
617 virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
618 const ::com::sun::star::uno::Reference<
619 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
620 throw(::com::sun::star::beans::UnknownPropertyException,
621 ::com::sun::star::lang::WrappedTargetException,
622 ::com::sun::star::uno::RuntimeException);
624 // XServiceInfo
625 virtual ::rtl::OUString SAL_CALL getImplementationName( )
626 throw(::com::sun::star::uno::RuntimeException);
627 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
628 throw(::com::sun::star::uno::RuntimeException);
629 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
630 throw(::com::sun::star::uno::RuntimeException);
632 com::sun::star::uno::Sequence<com::sun::star::sheet::GeneralFunction> getSubTotals() const;
633 bool getShowEmpty() const;
635 const ::com::sun::star::sheet::DataPilotFieldSortInfo& GetSortInfo() const { return aSortInfo; }
636 const ::com::sun::star::sheet::DataPilotFieldAutoShowInfo& GetAutoShow() const { return aAutoShowInfo; }
638 void EvaluateSortOrder();
639 void SetEnableLayout(bool bSet);
641 const ::std::vector<sal_Int32>& GetGlobalOrder() const { return aGlobalOrder; }
642 ::std::vector<sal_Int32>& GetGlobalOrder() { return aGlobalOrder; }
643 long GetSortMeasure() const { return nSortMeasure; }
644 long GetAutoMeasure() const { return nAutoMeasure; }
646 bool IsOutlineLayout() const
648 return bEnableLayout &&
649 aLayoutInfo.LayoutMode !=
650 ::com::sun::star::sheet::DataPilotFieldLayoutMode::TABULAR_LAYOUT;
653 bool IsSubtotalsAtTop() const
655 return bEnableLayout &&
656 aLayoutInfo.LayoutMode ==
657 ::com::sun::star::sheet::DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_TOP;
660 bool IsAddEmpty() const
662 return bEnableLayout && aLayoutInfo.AddEmptyLines;
665 //! number format (for data fields and date fields)
668 // hash map from name to index in the member array, for fast name access
669 typedef ::boost::unordered_map< ::rtl::OUString, sal_Int32, ::rtl::OUStringHash > ScDPMembersHashMap;
671 class ScDPMembers : public cppu::WeakImplHelper2<
672 com::sun::star::container::XNameAccess,
673 com::sun::star::lang::XServiceInfo >
675 private:
676 typedef std::vector<rtl::Reference<ScDPMember> > MembersType;
677 ScDPSource* pSource;
678 long nDim;
679 long nHier;
680 long nLev;
681 long nMbrCount;
682 mutable MembersType maMembers;
683 mutable ScDPMembersHashMap aHashMap;
685 public:
686 ScDPMembers( ScDPSource* pSrc, long nD, long nH, long nL );
687 virtual ~ScDPMembers();
689 // XNameAccess
690 virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
691 throw(::com::sun::star::container::NoSuchElementException,
692 ::com::sun::star::lang::WrappedTargetException,
693 ::com::sun::star::uno::RuntimeException);
694 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
695 throw(::com::sun::star::uno::RuntimeException);
696 virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
697 throw(::com::sun::star::uno::RuntimeException);
699 // XElementAccess
700 virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
701 throw(::com::sun::star::uno::RuntimeException);
702 virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
704 // XServiceInfo
705 virtual ::rtl::OUString SAL_CALL getImplementationName( )
706 throw(::com::sun::star::uno::RuntimeException);
707 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
708 throw(::com::sun::star::uno::RuntimeException);
709 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
710 throw(::com::sun::star::uno::RuntimeException);
712 long getCount() const;
713 ScDPMember* getByIndex(long nIndex) const;
715 long getMinMembers() const;
717 sal_Int32 GetIndexFromName( const ::rtl::OUString& rName ) const; // <0 if not found
718 const std::vector<sal_Int32>& GetGlobalOrder();
719 const ScDPItemData* GetSrcItemDataByIndex( SCROW nIndex);
720 SCROW GetSrcItemsCount();
723 class ScDPMember : boost::noncopyable, public cppu::WeakImplHelper3<
724 com::sun::star::container::XNamed,
725 com::sun::star::beans::XPropertySet,
726 com::sun::star::lang::XServiceInfo >
728 private:
729 ScDPSource* pSource;
730 long nDim;
731 long nHier;
732 long nLev;
734 SCROW mnDataId;
735 boost::scoped_ptr<rtl::OUString> mpLayoutName;
737 sal_Int32 nPosition; // manual sorting
738 bool bVisible;
739 bool bShowDet;
741 public:
742 ScDPMember(ScDPSource* pSrc, long nD, long nH, long nL, SCROW nIndex);
743 virtual ~ScDPMember();
745 rtl::OUString GetNameStr() const;
746 void FillItemData( ScDPItemData& rData ) const;
747 const ScDPItemData* GetItemData() const;
748 SCROW GetItemDataId() const { return mnDataId; }
749 bool IsNamedItem(SCROW nIndex) const;
751 SC_DLLPUBLIC const ::rtl::OUString* GetLayoutName() const;
752 long GetDim() const;
754 sal_Int32 Compare( const ScDPMember& rOther ) const; // visible order
756 // XNamed
757 virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
758 virtual void SAL_CALL setName( const ::rtl::OUString& aName )
759 throw(::com::sun::star::uno::RuntimeException);
761 // XPropertySet
762 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
763 SAL_CALL getPropertySetInfo( )
764 throw(::com::sun::star::uno::RuntimeException);
765 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName,
766 const ::com::sun::star::uno::Any& aValue )
767 throw(::com::sun::star::beans::UnknownPropertyException,
768 ::com::sun::star::beans::PropertyVetoException,
769 ::com::sun::star::lang::IllegalArgumentException,
770 ::com::sun::star::lang::WrappedTargetException,
771 ::com::sun::star::uno::RuntimeException);
772 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
773 const ::rtl::OUString& PropertyName )
774 throw(::com::sun::star::beans::UnknownPropertyException,
775 ::com::sun::star::lang::WrappedTargetException,
776 ::com::sun::star::uno::RuntimeException);
777 virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
778 const ::com::sun::star::uno::Reference<
779 ::com::sun::star::beans::XPropertyChangeListener >& xListener )
780 throw(::com::sun::star::beans::UnknownPropertyException,
781 ::com::sun::star::lang::WrappedTargetException,
782 ::com::sun::star::uno::RuntimeException);
783 virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
784 const ::com::sun::star::uno::Reference<
785 ::com::sun::star::beans::XPropertyChangeListener >& aListener )
786 throw(::com::sun::star::beans::UnknownPropertyException,
787 ::com::sun::star::lang::WrappedTargetException,
788 ::com::sun::star::uno::RuntimeException);
789 virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName,
790 const ::com::sun::star::uno::Reference<
791 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
792 throw(::com::sun::star::beans::UnknownPropertyException,
793 ::com::sun::star::lang::WrappedTargetException,
794 ::com::sun::star::uno::RuntimeException);
795 virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
796 const ::com::sun::star::uno::Reference<
797 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
798 throw(::com::sun::star::beans::UnknownPropertyException,
799 ::com::sun::star::lang::WrappedTargetException,
800 ::com::sun::star::uno::RuntimeException);
802 // XServiceInfo
803 virtual ::rtl::OUString SAL_CALL getImplementationName( )
804 throw(::com::sun::star::uno::RuntimeException);
805 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
806 throw(::com::sun::star::uno::RuntimeException);
807 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
808 throw(::com::sun::star::uno::RuntimeException);
810 bool isVisible() const;
811 bool getShowDetails() const;
815 #endif
817 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */