build fix
[LibreOffice.git] / sc / inc / dptabsrc.hxx
blob26e949a813b79cd05f9a264d5201031c0eb32c4d
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 INCLUDED_SC_INC_DPTABSRC_HXX
21 #define INCLUDED_SC_INC_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/DataPilotFieldAutoShowInfo.hpp>
32 #include <com/sun/star/sheet/DataPilotFieldLayoutInfo.hpp>
33 #include <com/sun/star/sheet/DataPilotFieldLayoutMode.hpp>
34 #include <com/sun/star/sheet/DataPilotFieldReference.hpp>
35 #include <com/sun/star/sheet/DataPilotFieldSortInfo.hpp>
36 #include <com/sun/star/util/XRefreshable.hpp>
37 #include <com/sun/star/sheet/XDrillDownDataSupplier.hpp>
38 #include <com/sun/star/util/XCloneable.hpp>
39 #include <com/sun/star/beans/XPropertySet.hpp>
40 #include <com/sun/star/lang/XServiceInfo.hpp>
41 #include <com/sun/star/container/XNamed.hpp>
42 #include <cppuhelper/implbase.hxx>
43 #include <rtl/ref.hxx>
45 #include "dptabdat.hxx"
46 #include "dpglobal.hxx"
47 #include "dpresfilter.hxx"
49 #include <list>
50 #include <memory>
51 #include <unordered_map>
52 #include <unordered_set>
53 #include <vector>
55 namespace com { namespace sun { namespace star {
56 namespace sheet {
57 struct DataPilotFieldFilter;
59 namespace table {
60 struct CellAddress;
62 }}}
64 class ScDPResultMember;
65 class ScDPResultData;
66 class ScDPItemData;
67 class ScDPTableData;
69 // implementation of DataPilotSource using ScDPTableData
71 class ScDPDimensions;
72 class ScDPDimension;
73 class ScDPHierarchies;
74 class ScDPHierarchy;
75 class ScDPLevels;
76 class ScDPLevel;
77 class ScDPMembers;
78 class ScDPMember;
80 class ScDPSource : public cppu::WeakImplHelper<
81 css::sheet::XDimensionsSupplier,
82 css::sheet::XDataPilotResults,
83 css::util::XRefreshable,
84 css::sheet::XDrillDownDataSupplier,
85 css::beans::XPropertySet,
86 css::lang::XServiceInfo >
88 private:
89 ScDPTableData* pData; // data source (ScDPObject manages its life time)
90 rtl::Reference<ScDPDimensions> pDimensions; // api objects
91 // settings:
93 std::vector<long> maColDims;
94 std::vector<long> maRowDims;
95 std::vector<long> maDataDims;
96 std::vector<long> maPageDims;
97 ScDPResultTree maResFilterSet;
99 bool bColumnGrand;
100 bool bRowGrand;
101 bool bIgnoreEmptyRows;
102 bool bRepeatIfEmpty;
104 long nDupCount;
106 // results:
107 ScDPResultData* pResData; // keep the rest in this!
108 ScDPResultMember* pColResRoot;
109 ScDPResultMember* pRowResRoot;
110 css::uno::Sequence<css::sheet::MemberResult>* pColResults;
111 css::uno::Sequence<css::sheet::MemberResult>* pRowResults;
112 std::vector<ScDPLevel*> aColLevelList;
113 std::vector<ScDPLevel*> aRowLevelList;
114 bool bResultOverflow;
115 bool bPageFiltered; // set if page field filters have been applied to cache table
117 ::std::unique_ptr<OUString> mpGrandTotalName;
119 void CreateRes_Impl();
120 void FillMemberResults();
121 void FillLevelList( sal_uInt16 nOrientation, std::vector<ScDPLevel*> &rList );
122 void FillCalcInfo(bool bIsRow, ScDPTableData::CalcInfo& rInfo, bool &bHasAutoShow);
125 * Compile a list of dimension indices that are either, column, row or
126 * page dimensions (i.e. all but data dimensions).
128 void GetCategoryDimensionIndices(std::unordered_set<sal_Int32>& rCatDims);
131 * Set visibilities of individual rows in the cache table based on the
132 * page field data.
134 void FilterCacheByPageDimensions();
136 void SetDupCount( long nNew );
138 OUString getDataDescription(); //! ???
140 void setIgnoreEmptyRows(bool bSet);
141 void setRepeatIfEmpty(bool bSet);
143 void disposeData();
145 public:
146 ScDPSource( ScDPTableData* pD );
147 virtual ~ScDPSource() override;
149 ScDPTableData* GetData() { return pData; }
150 const ScDPTableData* GetData() const { return pData; }
152 const OUString* GetGrandTotalName() const;
154 sal_uInt16 GetOrientation(long nColumn);
155 void SetOrientation(long nColumn, sal_uInt16 nNew);
156 long GetPosition(long nColumn);
158 long GetDataDimensionCount();
159 ScDPDimension* GetDataDimension(long nIndex);
160 OUString GetDataDimName(long nIndex);
161 const ScDPCache* GetCache();
162 const ScDPItemData* GetItemDataById( long nDim, long nId );
163 bool IsDataLayoutDimension(long nDim);
164 sal_uInt16 GetDataLayoutOrientation();
166 bool IsDateDimension(long nDim);
168 bool SubTotalAllowed(long nColumn); //! move to ScDPResultData
170 ScDPDimension* AddDuplicated(long nSource, const OUString& rNewName);
171 long GetDupCount() const { return nDupCount; }
173 long GetSourceDim(long nDim);
175 const css::uno::Sequence<css::sheet::MemberResult>*
176 GetMemberResults( ScDPLevel* pLevel );
178 ScDPDimensions* GetDimensionsObject();
180 // XDimensionsSupplier
181 virtual css::uno::Reference< css::container::XNameAccess >
182 SAL_CALL getDimensions( )
183 throw(css::uno::RuntimeException, std::exception) override;
185 // XDataPilotResults
186 virtual css::uno::Sequence< css::uno::Sequence< css::sheet::DataResult > > SAL_CALL getResults( )
187 throw(css::uno::RuntimeException, std::exception) override;
189 virtual css::uno::Sequence<double> SAL_CALL
190 getFilteredResults(
191 const css::uno::Sequence<css::sheet::DataPilotFieldFilter>& aFilters )
192 throw (css::uno::RuntimeException, std::exception) override;
194 // XRefreshable
195 virtual void SAL_CALL refresh() throw(css::uno::RuntimeException, std::exception) override;
196 virtual void SAL_CALL addRefreshListener( const css::uno::Reference< css::util::XRefreshListener >& l )
197 throw(css::uno::RuntimeException, std::exception) override;
198 virtual void SAL_CALL removeRefreshListener( const css::uno::Reference< css::util::XRefreshListener >& l )
199 throw(css::uno::RuntimeException, std::exception) override;
201 // XDrillDownDataSupplier
202 virtual css::uno::Sequence< css::uno::Sequence< css::uno::Any > >
203 SAL_CALL getDrillDownData(const css::uno::Sequence<
204 css::sheet::DataPilotFieldFilter >& aFilters )
205 throw(css::uno::RuntimeException, std::exception) override;
207 // XPropertySet
208 virtual css::uno::Reference< css::beans::XPropertySetInfo >
209 SAL_CALL getPropertySetInfo( )
210 throw(css::uno::RuntimeException, std::exception) override;
211 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
212 const css::uno::Any& aValue )
213 throw(css::beans::UnknownPropertyException,
214 css::beans::PropertyVetoException,
215 css::lang::IllegalArgumentException,
216 css::lang::WrappedTargetException,
217 css::uno::RuntimeException, std::exception) override;
218 virtual css::uno::Any SAL_CALL getPropertyValue(
219 const OUString& PropertyName )
220 throw(css::beans::UnknownPropertyException,
221 css::lang::WrappedTargetException,
222 css::uno::RuntimeException, std::exception) override;
223 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
224 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener )
225 throw(css::beans::UnknownPropertyException,
226 css::lang::WrappedTargetException,
227 css::uno::RuntimeException, std::exception) override;
228 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
229 const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener )
230 throw(css::beans::UnknownPropertyException,
231 css::lang::WrappedTargetException,
232 css::uno::RuntimeException, std::exception) override;
233 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
234 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener )
235 throw(css::beans::UnknownPropertyException,
236 css::lang::WrappedTargetException,
237 css::uno::RuntimeException, std::exception) override;
238 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
239 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener )
240 throw(css::beans::UnknownPropertyException,
241 css::lang::WrappedTargetException,
242 css::uno::RuntimeException, std::exception) override;
244 // XServiceInfo
245 virtual OUString SAL_CALL getImplementationName( )
246 throw(css::uno::RuntimeException, std::exception) override;
247 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
248 throw(css::uno::RuntimeException, std::exception) override;
249 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
250 throw(css::uno::RuntimeException, std::exception) override;
252 #if DUMP_PIVOT_TABLE
253 void DumpResults() const;
254 #endif
257 class ScDPDimensions : public cppu::WeakImplHelper<
258 css::container::XNameAccess,
259 css::lang::XServiceInfo >
261 private:
262 ScDPSource* pSource;
263 long nDimCount;
264 ScDPDimension** ppDims;
266 public:
267 ScDPDimensions( ScDPSource* pSrc );
268 virtual ~ScDPDimensions() override;
270 void CountChanged();
272 // XNameAccess
273 virtual css::uno::Any SAL_CALL getByName( const OUString& aName )
274 throw(css::container::NoSuchElementException,
275 css::lang::WrappedTargetException,
276 css::uno::RuntimeException, std::exception) override;
277 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames()
278 throw(css::uno::RuntimeException, std::exception) override;
279 virtual sal_Bool SAL_CALL hasByName( const OUString& aName )
280 throw(css::uno::RuntimeException, std::exception) override;
282 // XElementAccess
283 virtual css::uno::Type SAL_CALL getElementType()
284 throw(css::uno::RuntimeException, std::exception) override;
285 virtual sal_Bool SAL_CALL hasElements() throw(css::uno::RuntimeException, std::exception) override;
287 // XServiceInfo
288 virtual OUString SAL_CALL getImplementationName( )
289 throw(css::uno::RuntimeException, std::exception) override;
290 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
291 throw(css::uno::RuntimeException, std::exception) override;
292 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
293 throw(css::uno::RuntimeException, std::exception) override;
295 long getCount() const;
296 ScDPDimension* getByIndex(long nIndex) const;
299 class ScDPDimension : public cppu::WeakImplHelper<
300 css::sheet::XHierarchiesSupplier,
301 css::container::XNamed,
302 css::util::XCloneable,
303 css::beans::XPropertySet,
304 css::lang::XServiceInfo >
306 ScDPSource* pSource;
307 long nDim; // dimension index (== column ID)
308 rtl::Reference<ScDPHierarchies> mxHierarchies;
309 sal_uInt16 nFunction; // enum GeneralFunction2
310 OUString aName; // if empty, take from source
311 std::unique_ptr<OUString> mpLayoutName;
312 std::unique_ptr<OUString> mpSubtotalName;
313 long nSourceDim; // >=0 if dup'ed
314 css::sheet::DataPilotFieldReference
315 aReferenceValue; // settings for "show data as" / "displayed value"
316 bool bHasSelectedPage;
317 OUString aSelectedPage;
318 std::unique_ptr<ScDPItemData>
319 pSelectedData; // internal, temporary, created from aSelectedPage
320 bool mbHasHiddenMember;
322 public:
323 ScDPDimension( ScDPSource* pSrc, long nD );
324 virtual ~ScDPDimension() override;
325 ScDPDimension(const ScDPDimension&) = delete;
326 ScDPDimension& operator=(const ScDPDimension&) = delete;
328 long GetDimension() const { return nDim; } // dimension index in source
329 long GetSourceDim() const { return nSourceDim; } // >=0 if dup'ed
331 ScDPDimension* CreateCloneObject();
332 ScDPHierarchies* GetHierarchiesObject();
334 SC_DLLPUBLIC const OUString* GetLayoutName() const;
335 const OUString* GetSubtotalName() const;
337 // XNamed
338 virtual OUString SAL_CALL getName() throw(css::uno::RuntimeException, std::exception) override;
339 virtual void SAL_CALL setName( const OUString& aName )
340 throw(css::uno::RuntimeException, std::exception) override;
342 // XHierarchiesSupplier
343 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL
344 getHierarchies() throw(css::uno::RuntimeException, std::exception) override;
346 // XCloneable
347 virtual css::uno::Reference< css::util::XCloneable > SAL_CALL
348 createClone() throw(css::uno::RuntimeException, std::exception) override;
350 // XPropertySet
351 virtual css::uno::Reference< css::beans::XPropertySetInfo >
352 SAL_CALL getPropertySetInfo( )
353 throw(css::uno::RuntimeException, std::exception) override;
354 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
355 const css::uno::Any& aValue )
356 throw(css::beans::UnknownPropertyException,
357 css::beans::PropertyVetoException,
358 css::lang::IllegalArgumentException,
359 css::lang::WrappedTargetException,
360 css::uno::RuntimeException, std::exception) override;
361 virtual css::uno::Any SAL_CALL getPropertyValue(
362 const OUString& PropertyName )
363 throw(css::beans::UnknownPropertyException,
364 css::lang::WrappedTargetException,
365 css::uno::RuntimeException, std::exception) override;
366 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
367 const css::uno::Reference<
368 css::beans::XPropertyChangeListener >& xListener )
369 throw(css::beans::UnknownPropertyException,
370 css::lang::WrappedTargetException,
371 css::uno::RuntimeException, std::exception) override;
372 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
373 const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener )
374 throw(css::beans::UnknownPropertyException,
375 css::lang::WrappedTargetException,
376 css::uno::RuntimeException, std::exception) override;
377 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
378 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener )
379 throw(css::beans::UnknownPropertyException,
380 css::lang::WrappedTargetException,
381 css::uno::RuntimeException, std::exception) override;
382 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
383 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener )
384 throw(css::beans::UnknownPropertyException,
385 css::lang::WrappedTargetException,
386 css::uno::RuntimeException, std::exception) override;
388 // XServiceInfo
389 virtual OUString SAL_CALL getImplementationName( )
390 throw(css::uno::RuntimeException, std::exception) override;
391 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
392 throw(css::uno::RuntimeException, std::exception) override;
393 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
394 throw(css::uno::RuntimeException, std::exception) override;
396 sal_uInt16 getOrientation() const;
397 bool getIsDataLayoutDimension() const;
398 sal_uInt16 getFunction() const { return nFunction;}
399 void setFunction(sal_uInt16 nNew); // for data dimension
400 static long getUsedHierarchy() { return 0;}
402 bool HasSelectedPage() const { return bHasSelectedPage; }
403 const ScDPItemData& GetSelectedData();
405 const css::sheet::DataPilotFieldReference& GetReferenceValue() const { return aReferenceValue;}
408 class ScDPHierarchies : public cppu::WeakImplHelper<
409 css::container::XNameAccess,
410 css::lang::XServiceInfo >
412 private:
413 ScDPSource* pSource;
414 long nDim;
415 // date columns have 3 hierarchies (flat/quarter/week), other columns only one
416 // #i52547# don't offer the incomplete date hierarchy implementation
417 static const long nHierCount = 1;
418 ScDPHierarchy** ppHiers;
420 public:
421 ScDPHierarchies( ScDPSource* pSrc, long nD );
422 virtual ~ScDPHierarchies() override;
424 // XNameAccess
425 virtual css::uno::Any SAL_CALL getByName( const OUString& aName )
426 throw(css::container::NoSuchElementException,
427 css::lang::WrappedTargetException,
428 css::uno::RuntimeException, std::exception) override;
429 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames()
430 throw(css::uno::RuntimeException, std::exception) override;
431 virtual sal_Bool SAL_CALL hasByName( const OUString& aName )
432 throw(css::uno::RuntimeException, std::exception) override;
434 // XElementAccess
435 virtual css::uno::Type SAL_CALL getElementType()
436 throw(css::uno::RuntimeException, std::exception) override;
437 virtual sal_Bool SAL_CALL hasElements() throw(css::uno::RuntimeException, std::exception) override;
439 // XServiceInfo
440 virtual OUString SAL_CALL getImplementationName( )
441 throw(css::uno::RuntimeException, std::exception) override;
442 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
443 throw(css::uno::RuntimeException, std::exception) override;
444 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
445 throw(css::uno::RuntimeException, std::exception) override;
447 static long getCount();
448 ScDPHierarchy* getByIndex(long nIndex) const;
451 class ScDPHierarchy : public cppu::WeakImplHelper<
452 css::sheet::XLevelsSupplier,
453 css::container::XNamed,
454 css::lang::XServiceInfo >
456 private:
457 ScDPSource* pSource;
458 long nDim;
459 long nHier;
460 rtl::Reference<ScDPLevels> mxLevels;
462 public:
463 ScDPHierarchy( ScDPSource* pSrc, long nD, long nH );
464 virtual ~ScDPHierarchy() override;
466 ScDPLevels* GetLevelsObject();
468 // XNamed
469 virtual OUString SAL_CALL getName() throw(css::uno::RuntimeException, std::exception) override;
470 virtual void SAL_CALL setName( const OUString& aName )
471 throw(css::uno::RuntimeException, std::exception) override;
473 // XLevelsSupplier
474 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL
475 getLevels() throw(css::uno::RuntimeException, std::exception) override;
477 // XServiceInfo
478 virtual OUString SAL_CALL getImplementationName( )
479 throw(css::uno::RuntimeException, std::exception) override;
480 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
481 throw(css::uno::RuntimeException, std::exception) override;
482 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
483 throw(css::uno::RuntimeException, std::exception) override;
486 class ScDPLevels : public cppu::WeakImplHelper<
487 css::container::XNameAccess,
488 css::lang::XServiceInfo >
490 private:
491 ScDPSource* pSource;
492 long nDim;
493 long nHier;
494 long nLevCount;
495 ScDPLevel** ppLevs;
497 public:
498 ScDPLevels( ScDPSource* pSrc, long nD, long nH );
499 virtual ~ScDPLevels() override;
501 // XNameAccess
502 virtual css::uno::Any SAL_CALL getByName( const OUString& aName )
503 throw(css::container::NoSuchElementException,
504 css::lang::WrappedTargetException,
505 css::uno::RuntimeException, std::exception) override;
506 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames()
507 throw(css::uno::RuntimeException, std::exception) override;
508 virtual sal_Bool SAL_CALL hasByName( const OUString& aName )
509 throw(css::uno::RuntimeException, std::exception) override;
511 // XElementAccess
512 virtual css::uno::Type SAL_CALL getElementType()
513 throw(css::uno::RuntimeException, std::exception) override;
514 virtual sal_Bool SAL_CALL hasElements() throw(css::uno::RuntimeException, std::exception) override;
516 // XServiceInfo
517 virtual OUString SAL_CALL getImplementationName( )
518 throw(css::uno::RuntimeException, std::exception) override;
519 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
520 throw(css::uno::RuntimeException, std::exception) override;
521 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
522 throw(css::uno::RuntimeException, std::exception) override;
524 long getCount() const;
525 ScDPLevel* getByIndex(long nIndex) const;
528 class ScDPLevel : public cppu::WeakImplHelper<
529 css::sheet::XMembersSupplier,
530 css::container::XNamed,
531 css::sheet::XDataPilotMemberResults,
532 css::beans::XPropertySet,
533 css::lang::XServiceInfo >
535 private:
536 ScDPSource* pSource;
537 long nDim;
538 long nHier;
539 long nLev;
540 rtl::Reference<ScDPMembers> mxMembers;
541 css::uno::Sequence<sal_Int16> aSubTotals;
542 css::sheet::DataPilotFieldSortInfo aSortInfo; // stored user settings
543 css::sheet::DataPilotFieldAutoShowInfo aAutoShowInfo; // stored user settings
544 css::sheet::DataPilotFieldLayoutInfo aLayoutInfo; // stored user settings
545 // valid only from result calculation:
546 ::std::vector<sal_Int32> aGlobalOrder; // result of sorting by name or position
547 long nSortMeasure; // measure (index of data dimension) to sort by
548 long nAutoMeasure; // measure (index of data dimension) for AutoShow
549 bool bShowEmpty:1;
550 bool bEnableLayout:1; // enabled only for row fields, not for the innermost one
551 bool bRepeatItemLabels:1;
553 public:
554 ScDPLevel( ScDPSource* pSrc, long nD, long nH, long nL );
555 virtual ~ScDPLevel() override;
557 ScDPMembers* GetMembersObject();
559 // XNamed
560 virtual OUString SAL_CALL getName() throw(css::uno::RuntimeException, std::exception) override;
561 virtual void SAL_CALL setName( const OUString& aName )
562 throw(css::uno::RuntimeException, std::exception) override;
564 // XMembersSupplier
565 virtual css::uno::Reference< css::sheet::XMembersAccess > SAL_CALL
566 getMembers() throw(css::uno::RuntimeException, std::exception) override;
568 // XDataPilotMemberResults
569 virtual css::uno::Sequence< css::sheet::MemberResult > SAL_CALL
570 getResults() throw(css::uno::RuntimeException, std::exception) override;
572 // XPropertySet
573 virtual css::uno::Reference< css::beans::XPropertySetInfo >
574 SAL_CALL getPropertySetInfo( )
575 throw(css::uno::RuntimeException, std::exception) override;
576 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
577 const css::uno::Any& aValue )
578 throw(css::beans::UnknownPropertyException,
579 css::beans::PropertyVetoException,
580 css::lang::IllegalArgumentException,
581 css::lang::WrappedTargetException,
582 css::uno::RuntimeException, std::exception) override;
583 virtual css::uno::Any SAL_CALL getPropertyValue(
584 const OUString& PropertyName )
585 throw(css::beans::UnknownPropertyException,
586 css::lang::WrappedTargetException,
587 css::uno::RuntimeException, std::exception) override;
588 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
589 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener )
590 throw(css::beans::UnknownPropertyException,
591 css::lang::WrappedTargetException,
592 css::uno::RuntimeException, std::exception) override;
593 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
594 const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener )
595 throw(css::beans::UnknownPropertyException,
596 css::lang::WrappedTargetException,
597 css::uno::RuntimeException, std::exception) override;
598 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
599 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener )
600 throw(css::beans::UnknownPropertyException,
601 css::lang::WrappedTargetException,
602 css::uno::RuntimeException, std::exception) override;
603 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
604 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener )
605 throw(css::beans::UnknownPropertyException,
606 css::lang::WrappedTargetException,
607 css::uno::RuntimeException, std::exception) override;
609 // XServiceInfo
610 virtual OUString SAL_CALL getImplementationName( )
611 throw(css::uno::RuntimeException, std::exception) override;
612 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
613 throw(css::uno::RuntimeException, std::exception) override;
614 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
615 throw(css::uno::RuntimeException, std::exception) override;
617 css::uno::Sequence<sal_Int16> getSubTotals() const;
618 bool getShowEmpty() const { return bShowEmpty;}
619 bool getRepeatItemLabels() const { return bRepeatItemLabels; }
621 const css::sheet::DataPilotFieldSortInfo& GetSortInfo() const { return aSortInfo; }
622 const css::sheet::DataPilotFieldAutoShowInfo& GetAutoShow() const { return aAutoShowInfo; }
624 void EvaluateSortOrder();
625 void SetEnableLayout(bool bSet);
627 const ::std::vector<sal_Int32>& GetGlobalOrder() const { return aGlobalOrder; }
628 ::std::vector<sal_Int32>& GetGlobalOrder() { return aGlobalOrder; }
629 long GetSortMeasure() const { return nSortMeasure; }
630 long GetAutoMeasure() const { return nAutoMeasure; }
632 bool IsOutlineLayout() const
634 return bEnableLayout &&
635 aLayoutInfo.LayoutMode !=
636 css::sheet::DataPilotFieldLayoutMode::TABULAR_LAYOUT;
639 bool IsSubtotalsAtTop() const
641 return bEnableLayout &&
642 aLayoutInfo.LayoutMode ==
643 css::sheet::DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_TOP;
646 bool IsAddEmpty() const
648 return bEnableLayout && aLayoutInfo.AddEmptyLines;
651 //! number format (for data fields and date fields)
654 // hash map from name to index in the member array, for fast name access
655 typedef std::unordered_map< OUString, sal_Int32, OUStringHash > ScDPMembersHashMap;
657 class ScDPMembers : public cppu::WeakImplHelper<
658 css::sheet::XMembersAccess,
659 css::lang::XServiceInfo >
661 private:
662 typedef std::vector<rtl::Reference<ScDPMember> > MembersType;
663 ScDPSource* pSource;
664 long nDim;
665 long nHier;
666 long nLev;
667 long nMbrCount;
668 mutable MembersType maMembers;
669 mutable ScDPMembersHashMap aHashMap;
671 public:
672 ScDPMembers( ScDPSource* pSrc, long nD, long nH, long nL );
673 virtual ~ScDPMembers() override;
675 // XMembersAccess
676 virtual css::uno::Sequence< OUString > SAL_CALL getLocaleIndependentElementNames()
677 throw(css::uno::RuntimeException, std::exception) override;
679 // XNameAccess
680 virtual css::uno::Any SAL_CALL getByName( const OUString& aName )
681 throw(css::container::NoSuchElementException,
682 css::lang::WrappedTargetException,
683 css::uno::RuntimeException, std::exception) override;
684 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames()
685 throw(css::uno::RuntimeException, std::exception) override;
686 virtual sal_Bool SAL_CALL hasByName( const OUString& aName )
687 throw(css::uno::RuntimeException, std::exception) override;
689 // XElementAccess
690 virtual css::uno::Type SAL_CALL getElementType()
691 throw(css::uno::RuntimeException, std::exception) override;
692 virtual sal_Bool SAL_CALL hasElements() throw(css::uno::RuntimeException, std::exception) override;
694 // XServiceInfo
695 virtual OUString SAL_CALL getImplementationName( )
696 throw(css::uno::RuntimeException, std::exception) override;
697 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
698 throw(css::uno::RuntimeException, std::exception) override;
699 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
700 throw(css::uno::RuntimeException, std::exception) override;
702 long getCount() const { return nMbrCount;}
703 ScDPMember* getByIndex(long nIndex) const;
705 long getMinMembers() const;
707 sal_Int32 GetIndexFromName( const OUString& rName ) const; // <0 if not found
708 const ScDPItemData* GetSrcItemDataByIndex( SCROW nIndex);
710 private:
711 css::uno::Sequence< OUString > getElementNames( bool bLocaleIndependent ) const
712 throw(css::uno::RuntimeException, std::exception);
715 class ScDPMember : public cppu::WeakImplHelper<
716 css::container::XNamed,
717 css::beans::XPropertySet,
718 css::lang::XServiceInfo >
720 private:
721 ScDPSource* pSource;
722 long nDim;
723 long nHier;
724 long nLev;
726 SCROW mnDataId;
727 std::unique_ptr<OUString> mpLayoutName;
729 sal_Int32 nPosition; // manual sorting
730 bool bVisible;
731 bool bShowDet;
733 public:
734 ScDPMember(ScDPSource* pSrc, long nD, long nH, long nL, SCROW nIndex);
735 virtual ~ScDPMember() override;
736 ScDPMember(const ScDPMember&) = delete;
737 ScDPMember& operator=(const ScDPMember&) = delete;
739 OUString GetNameStr( bool bLocaleIndependent ) const;
740 ScDPItemData FillItemData() const;
741 const ScDPItemData* GetItemData() const;
742 SCROW GetItemDataId() const { return mnDataId; }
743 bool IsNamedItem(SCROW nIndex) const;
745 SC_DLLPUBLIC const OUString* GetLayoutName() const;
746 long GetDim() const { return nDim;}
748 sal_Int32 Compare( const ScDPMember& rOther ) const; // visible order
750 // XNamed
751 virtual OUString SAL_CALL getName() throw(css::uno::RuntimeException, std::exception) override;
752 virtual void SAL_CALL setName( const OUString& aName )
753 throw(css::uno::RuntimeException, std::exception) override;
755 // XPropertySet
756 virtual css::uno::Reference< css::beans::XPropertySetInfo >
757 SAL_CALL getPropertySetInfo( )
758 throw(css::uno::RuntimeException, std::exception) override;
759 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
760 const css::uno::Any& aValue )
761 throw(css::beans::UnknownPropertyException,
762 css::beans::PropertyVetoException,
763 css::lang::IllegalArgumentException,
764 css::lang::WrappedTargetException,
765 css::uno::RuntimeException, std::exception) override;
766 virtual css::uno::Any SAL_CALL getPropertyValue(
767 const OUString& PropertyName )
768 throw(css::beans::UnknownPropertyException,
769 css::lang::WrappedTargetException,
770 css::uno::RuntimeException, std::exception) override;
771 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
772 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener )
773 throw(css::beans::UnknownPropertyException,
774 css::lang::WrappedTargetException,
775 css::uno::RuntimeException, std::exception) override;
776 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
777 const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener )
778 throw(css::beans::UnknownPropertyException,
779 css::lang::WrappedTargetException,
780 css::uno::RuntimeException, std::exception) override;
781 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
782 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener )
783 throw(css::beans::UnknownPropertyException,
784 css::lang::WrappedTargetException,
785 css::uno::RuntimeException, std::exception) override;
786 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
787 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener )
788 throw(css::beans::UnknownPropertyException,
789 css::lang::WrappedTargetException,
790 css::uno::RuntimeException, std::exception) override;
792 // XServiceInfo
793 virtual OUString SAL_CALL getImplementationName( )
794 throw(css::uno::RuntimeException, std::exception) override;
795 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
796 throw(css::uno::RuntimeException, std::exception) override;
797 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
798 throw(css::uno::RuntimeException, std::exception) override;
800 bool isVisible() const { return bVisible;}
801 bool getShowDetails() const { return bShowDet;}
804 #endif
806 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */