1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#pragma once
#include <com/sun/star/sheet/XDimensionsSupplier.hpp>
#include <com/sun/star/sheet/XHierarchiesSupplier.hpp>
#include <com/sun/star/sheet/XLevelsSupplier.hpp>
#include <com/sun/star/sheet/XMembersSupplier.hpp>
#include <com/sun/star/sheet/XDataPilotResults.hpp>
#include <com/sun/star/sheet/XDataPilotMemberResults.hpp>
#include <com/sun/star/sheet/DataPilotFieldAutoShowInfo.hpp>
#include <com/sun/star/sheet/DataPilotFieldLayoutInfo.hpp>
#include <com/sun/star/sheet/DataPilotFieldLayoutMode.hpp>
#include <com/sun/star/sheet/DataPilotFieldReference.hpp>
#include <com/sun/star/sheet/DataPilotFieldSortInfo.hpp>
#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
#include <com/sun/star/util/XRefreshable.hpp>
#include <com/sun/star/sheet/XDrillDownDataSupplier.hpp>
#include <com/sun/star/util/XCloneable.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/container/XNamed.hpp>
#include <cppuhelper/implbase.hxx>
#include <rtl/ref.hxx>
#include "dptabdat.hxx"
#include "dpresfilter.hxx"
#include <memory>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <optional>
namespace com::sun::star {
namespace sheet {
struct DataPilotFieldFilter;
struct MemberResult;
}
}
class ScDPResultMember;
class ScDPResultData;
class ScDPItemData;
class ScDPDimensions;
class ScDPDimension;
class ScDPHierarchies;
class ScDPHierarchy;
class ScDPLevels;
class ScDPLevel;
class ScDPMembers;
class ScDPMember;
enum class ScGeneralFunction;
// implementation of DataPilotSource using ScDPTableData
class ScDPSource final : public cppu::WeakImplHelper<
css::sheet::XDimensionsSupplier,
css::sheet::XDataPilotResults,
css::util::XRefreshable,
css::sheet::XDrillDownDataSupplier,
css::beans::XPropertySet,
css::lang::XServiceInfo >
{
private:
ScDPTableData* pData; // data source (ScDPObject manages its life time)
rtl::Reference<ScDPDimensions> pDimensions; // api objects
// settings:
std::vector<sal_Int32> maColDims;
std::vector<sal_Int32> maRowDims;
std::vector<sal_Int32> maDataDims;
std::vector<sal_Int32> maPageDims;
ScDPResultTree maResFilterSet;
bool bColumnGrand;
bool bRowGrand;
bool bIgnoreEmptyRows;
bool bRepeatIfEmpty;
sal_Int32 nDupCount;
// results:
std::unique_ptr<ScDPResultData> pResData; // keep the rest in this!
std::unique_ptr<ScDPResultMember> pColResRoot;
std::unique_ptr<ScDPResultMember> pRowResRoot;
std::unique_ptr<css::uno::Sequence<css::sheet::MemberResult>[]> pColResults;
std::unique_ptr<css::uno::Sequence<css::sheet::MemberResult>[]> pRowResults;
std::vector<ScDPLevel*> aColLevelList;
std::vector<ScDPLevel*> aRowLevelList;
bool bResultOverflow;
bool bPageFiltered; // set if page field filters have been applied to cache table
std::optional<OUString> mpGrandTotalName;
void CreateRes_Impl();
void FillMemberResults();
void FillLevelList( css::sheet::DataPilotFieldOrientation nOrientation, std::vector<ScDPLevel*> &rList );
void FillCalcInfo(bool bIsRow, ScDPTableData::CalcInfo& rInfo, bool &bHasAutoShow);
/**
* Compile a list of dimension indices that are either, column, row or
* page dimensions (i.e. all but data dimensions).
*/
void GetCategoryDimensionIndices(std::unordered_set<sal_Int32>& rCatDims);
/**
* Set visibilities of individual rows in the cache table based on the
* page field data.
*/
void FilterCacheByPageDimensions();
void SetDupCount( tools::Long nNew );
OUString getDataDescription(); //! ???
void setIgnoreEmptyRows(bool bSet);
void setRepeatIfEmpty(bool bSet);
void disposeData();
public:
ScDPSource( ScDPTableData* pD );
virtual ~ScDPSource() override;
ScDPTableData* GetData() { return pData; }
const ScDPTableData* GetData() const { return pData; }
const std::optional<OUString> &
GetGrandTotalName() const;
css::sheet::DataPilotFieldOrientation
GetOrientation(sal_Int32 nColumn);
void SetOrientation(sal_Int32 nColumn, css::sheet::DataPilotFieldOrientation nNew);
sal_Int32 GetPosition(sal_Int32 nColumn);
sal_Int32 GetDataDimensionCount() const;
ScDPDimension* GetDataDimension(sal_Int32 nIndex);
OUString GetDataDimName(sal_Int32 nIndex);
const ScDPCache* GetCache();
const ScDPItemData* GetItemDataById( sal_Int32 nDim, sal_Int32 nId );
bool IsDataLayoutDimension(sal_Int32 nDim);
css::sheet::DataPilotFieldOrientation
GetDataLayoutOrientation();
bool IsDateDimension(sal_Int32 nDim);
bool SubTotalAllowed(sal_Int32 nColumn); //! move to ScDPResultData
ScDPDimension* AddDuplicated(std::u16string_view rNewName);
sal_Int32 GetDupCount() const { return nDupCount; }
sal_Int32 GetSourceDim(sal_Int32 nDim);
const css::uno::Sequence<css::sheet::MemberResult>*
GetMemberResults( const ScDPLevel* pLevel );
ScDPDimensions* GetDimensionsObject();
// XDimensionsSupplier
virtual css::uno::Reference< css::container::XNameAccess >
SAL_CALL getDimensions( ) override;
// XDataPilotResults
virtual css::uno::Sequence< css::uno::Sequence< css::sheet::DataResult > > SAL_CALL getResults( ) override;
virtual css::uno::Sequence<double> SAL_CALL
getFilteredResults(
const css::uno::Sequence<css::sheet::DataPilotFieldFilter>& aFilters ) override;
// XRefreshable
virtual void SAL_CALL refresh() override;
virtual void SAL_CALL addRefreshListener( const css::uno::Reference< css::util::XRefreshListener >& l ) override;
virtual void SAL_CALL removeRefreshListener( const css::uno::Reference< css::util::XRefreshListener >& l ) override;
// XDrillDownDataSupplier
virtual css::uno::Sequence< css::uno::Sequence< css::uno::Any > >
SAL_CALL getDrillDownData(const css::uno::Sequence<
css::sheet::DataPilotFieldFilter >& aFilters ) override;
// XPropertySet
virtual css::uno::Reference< css::beans::XPropertySetInfo >
SAL_CALL getPropertySetInfo( ) override;
virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
const css::uno::Any& aValue ) override;
virtual css::uno::Any SAL_CALL getPropertyValue(
const OUString& PropertyName ) override;
virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
// XServiceInfo
virtual OUString SAL_CALL getImplementationName( ) override;
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
#if DUMP_PIVOT_TABLE
void DumpResults() const;
#endif
};
class ScDPDimensions final : public cppu::WeakImplHelper<
css::container::XNameAccess,
css::lang::XServiceInfo >
{
private:
ScDPSource* pSource;
sal_Int32 nDimCount;
std::unique_ptr<rtl::Reference<ScDPDimension>[]>
ppDims;
public:
ScDPDimensions( ScDPSource* pSrc );
virtual ~ScDPDimensions() override;
void CountChanged();
// XNameAccess
virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
// XElementAccess
virtual css::uno::Type SAL_CALL getElementType() override;
virtual sal_Bool SAL_CALL hasElements() override;
// XServiceInfo
virtual OUString SAL_CALL getImplementationName( ) override;
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
tools::Long getCount() const;
ScDPDimension* getByIndex(tools::Long nIndex) const;
};
class ScDPDimension final : public cppu::WeakImplHelper<
css::sheet::XHierarchiesSupplier,
css::container::XNamed,
css::util::XCloneable,
css::beans::XPropertySet,
css::lang::XServiceInfo >
{
ScDPSource* pSource;
sal_Int32 nDim; // dimension index (== column ID)
rtl::Reference<ScDPHierarchies> mxHierarchies;
ScGeneralFunction nFunction;
OUString aName; // if empty, take from source
std::optional<OUString> mpLayoutName;
std::optional<OUString> mpSubtotalName;
sal_Int32 nSourceDim; // >=0 if dup'ed
css::sheet::DataPilotFieldReference
aReferenceValue; // settings for "show data as" / "displayed value"
bool bHasSelectedPage;
OUString aSelectedPage;
std::unique_ptr<ScDPItemData>
pSelectedData; // internal, temporary, created from aSelectedPage
bool mbHasHiddenMember;
public:
ScDPDimension( ScDPSource* pSrc, tools::Long nD );
virtual ~ScDPDimension() override;
ScDPDimension(const ScDPDimension&) = delete;
ScDPDimension& operator=(const ScDPDimension&) = delete;
sal_Int32 GetDimension() const { return nDim; } // dimension index in source
sal_Int32 GetSourceDim() const { return nSourceDim; } // >=0 if dup'ed
ScDPDimension* CreateCloneObject();
ScDPHierarchies* GetHierarchiesObject();
const std::optional<OUString> & GetLayoutName() const;
const std::optional<OUString> & GetSubtotalName() const;
// XNamed
virtual OUString SAL_CALL getName() override;
virtual void SAL_CALL setName( const OUString& aName ) override;
// XHierarchiesSupplier
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL
getHierarchies() override;
// XCloneable
virtual css::uno::Reference< css::util::XCloneable > SAL_CALL
createClone() override;
// XPropertySet
virtual css::uno::Reference< css::beans::XPropertySetInfo >
SAL_CALL getPropertySetInfo( ) override;
virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
const css::uno::Any& aValue ) override;
virtual css::uno::Any SAL_CALL getPropertyValue(
const OUString& PropertyName ) override;
virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
const css::uno::Reference<
css::beans::XPropertyChangeListener >& xListener ) override;
virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
// XServiceInfo
virtual OUString SAL_CALL getImplementationName( ) override;
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
css::sheet::DataPilotFieldOrientation getOrientation() const;
bool getIsDataLayoutDimension() const;
ScGeneralFunction getFunction() const { return nFunction;}
void setFunction(ScGeneralFunction nNew); // for data dimension
static tools::Long getUsedHierarchy() { return 0;}
bool HasSelectedPage() const { return bHasSelectedPage; }
const ScDPItemData& GetSelectedData();
const css::sheet::DataPilotFieldReference& GetReferenceValue() const { return aReferenceValue;}
};
class ScDPHierarchies final : public cppu::WeakImplHelper<
css::container::XNameAccess,
css::lang::XServiceInfo >
{
private:
ScDPSource* pSource;
sal_Int32 nDim;
// date columns have 3 hierarchies (flat/quarter/week), other columns only one
// #i52547# don't offer the incomplete date hierarchy implementation
static const tools::Long nHierCount = 1;
std::unique_ptr<rtl::Reference<ScDPHierarchy>[]>
ppHiers;
public:
ScDPHierarchies( ScDPSource* pSrc, tools::Long nD );
virtual ~ScDPHierarchies() override;
// XNameAccess
virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
// XElementAccess
virtual css::uno::Type SAL_CALL getElementType() override;
virtual sal_Bool SAL_CALL hasElements() override;
// XServiceInfo
virtual OUString SAL_CALL getImplementationName( ) override;
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
static sal_Int32 getCount();
ScDPHierarchy* getByIndex(tools::Long nIndex) const;
};
class ScDPHierarchy final : public cppu::WeakImplHelper<
css::sheet::XLevelsSupplier,
css::container::XNamed,
css::lang::XServiceInfo >
{
private:
ScDPSource* pSource;
sal_Int32 nDim;
sal_Int32 nHier;
rtl::Reference<ScDPLevels> mxLevels;
public:
ScDPHierarchy( ScDPSource* pSrc, sal_Int32 nDim, sal_Int32 nHier );
virtual ~ScDPHierarchy() override;
ScDPLevels* GetLevelsObject();
// XNamed
virtual OUString SAL_CALL getName() override;
virtual void SAL_CALL setName( const OUString& aName ) override;
// XLevelsSupplier
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL
getLevels() override;
// XServiceInfo
virtual OUString SAL_CALL getImplementationName( ) override;
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
};
class ScDPLevels final : public cppu::WeakImplHelper<
css::container::XNameAccess,
css::lang::XServiceInfo >
{
private:
ScDPSource* pSource;
sal_Int32 nDim;
sal_Int32 nHier;
sal_Int32 nLevCount;
std::unique_ptr<rtl::Reference<ScDPLevel>[]>
ppLevs;
public:
ScDPLevels( ScDPSource* pSrc, sal_Int32 nDim, sal_Int32 nHier );
virtual ~ScDPLevels() override;
// XNameAccess
virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
// XElementAccess
virtual css::uno::Type SAL_CALL getElementType() override;
virtual sal_Bool SAL_CALL hasElements() override;
// XServiceInfo
virtual OUString SAL_CALL getImplementationName( ) override;
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
sal_Int32 getCount() const;
ScDPLevel* getByIndex(sal_Int32 nIndex) const;
};
class ScDPLevel final : public cppu::WeakImplHelper<
css::sheet::XMembersSupplier,
css::container::XNamed,
css::sheet::XDataPilotMemberResults,
css::beans::XPropertySet,
css::lang::XServiceInfo >
{
private:
ScDPSource* pSource;
sal_Int32 nDim;
sal_Int32 nHier;
sal_Int32 nLev;
rtl::Reference<ScDPMembers> mxMembers;
css::uno::Sequence<sal_Int16> aSubTotals;
css::sheet::DataPilotFieldSortInfo aSortInfo; // stored user settings
css::sheet::DataPilotFieldAutoShowInfo aAutoShowInfo; // stored user settings
css::sheet::DataPilotFieldLayoutInfo aLayoutInfo; // stored user settings
// valid only from result calculation:
::std::vector<sal_Int32> aGlobalOrder; // result of sorting by name or position
sal_Int32 nSortMeasure; // measure (index of data dimension) to sort by
sal_Int32 nAutoMeasure; // measure (index of data dimension) for AutoShow
bool bShowEmpty:1;
bool bEnableLayout:1; // enabled only for row fields, not for the innermost one
bool bRepeatItemLabels:1;
public:
ScDPLevel( ScDPSource* pSrc, sal_Int32 nDim, sal_Int32 nHier, sal_Int32 nLevel );
virtual ~ScDPLevel() override;
ScDPMembers* GetMembersObject();
// XNamed
virtual OUString SAL_CALL getName() override;
virtual void SAL_CALL setName( const OUString& aName ) override;
// XMembersSupplier
virtual css::uno::Reference< css::sheet::XMembersAccess > SAL_CALL
getMembers() override;
// XDataPilotMemberResults
virtual css::uno::Sequence< css::sheet::MemberResult > SAL_CALL
getResults() override;
// XPropertySet
virtual css::uno::Reference< css::beans::XPropertySetInfo >
SAL_CALL getPropertySetInfo( ) override;
virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
const css::uno::Any& aValue ) override;
virtual css::uno::Any SAL_CALL getPropertyValue(
const OUString& PropertyName ) override;
virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
// XServiceInfo
virtual OUString SAL_CALL getImplementationName( ) override;
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
css::uno::Sequence<sal_Int16> getSubTotals() const;
bool getShowEmpty() const { return bShowEmpty;}
bool getRepeatItemLabels() const { return bRepeatItemLabels; }
const css::sheet::DataPilotFieldSortInfo& GetSortInfo() const { return aSortInfo; }
const css::sheet::DataPilotFieldAutoShowInfo& GetAutoShow() const { return aAutoShowInfo; }
void EvaluateSortOrder();
void SetEnableLayout(bool bSet);
const ::std::vector<sal_Int32>& GetGlobalOrder() const { return aGlobalOrder; }
::std::vector<sal_Int32>& GetGlobalOrder() { return aGlobalOrder; }
sal_Int32 GetSortMeasure() const { return nSortMeasure; }
sal_Int32 GetAutoMeasure() const { return nAutoMeasure; }
bool IsOutlineLayout() const
{
return bEnableLayout &&
aLayoutInfo.LayoutMode !=
css::sheet::DataPilotFieldLayoutMode::TABULAR_LAYOUT;
}
bool IsSubtotalsAtTop() const
{
return bEnableLayout &&
aLayoutInfo.LayoutMode ==
css::sheet::DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_TOP;
}
bool IsAddEmpty() const
{
return bEnableLayout && aLayoutInfo.AddEmptyLines;
}
//! number format (for data fields and date fields)
};
// hash map from name to index in the member array, for fast name access
typedef std::unordered_map< OUString, sal_Int32 > ScDPMembersHashMap;
class ScDPMembers final : public cppu::WeakImplHelper<
css::sheet::XMembersAccess,
css::lang::XServiceInfo >
{
private:
typedef std::vector<rtl::Reference<ScDPMember> > MembersType;
ScDPSource* pSource;
sal_Int32 nDim;
sal_Int32 nHier;
sal_Int32 nLev;
sal_Int32 nMbrCount;
mutable MembersType maMembers;
mutable ScDPMembersHashMap aHashMap;
public:
ScDPMembers( ScDPSource* pSrc, sal_Int32 nDim, sal_Int32 nHier, sal_Int32 nLev );
virtual ~ScDPMembers() override;
// XMembersAccess
virtual css::uno::Sequence< OUString > SAL_CALL getLocaleIndependentElementNames() override;
// XNameAccess
virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
// XElementAccess
virtual css::uno::Type SAL_CALL getElementType() override;
virtual sal_Bool SAL_CALL hasElements() override;
// XServiceInfo
virtual OUString SAL_CALL getImplementationName( ) override;
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
sal_Int32 getCount() const { return nMbrCount;}
ScDPMember* getByIndex(sal_Int32 nIndex) const;
sal_Int32 getMinMembers() const;
sal_Int32 GetIndexFromName( const OUString& rName ) const; // <0 if not found
const ScDPItemData* GetSrcItemDataByIndex( SCROW nIndex);
private:
/// @throws css::uno::RuntimeException
css::uno::Sequence< OUString > getElementNames( bool bLocaleIndependent ) const;
};
class ScDPMember final : public cppu::WeakImplHelper<
css::container::XNamed,
css::beans::XPropertySet,
css::lang::XServiceInfo >
{
private:
ScDPSource* pSource;
sal_Int32 nDim;
sal_Int32 nHier;
sal_Int32 nLev;
SCROW mnDataId;
std::optional<OUString> mpLayoutName;
sal_Int32 nPosition; // manual sorting
bool bVisible;
bool bShowDet;
public:
ScDPMember(ScDPSource* pSrc, sal_Int32 nDim, sal_Int32 nHier, sal_Int32 nLev, SCROW nIndex);
virtual ~ScDPMember() override;
ScDPMember(const ScDPMember&) = delete;
ScDPMember& operator=(const ScDPMember&) = delete;
OUString GetNameStr( bool bLocaleIndependent ) const;
ScDPItemData FillItemData() const;
const ScDPItemData* GetItemData() const;
SCROW GetItemDataId() const { return mnDataId; }
bool IsNamedItem(SCROW nIndex) const;
const std::optional<OUString> & GetLayoutName() const;
tools::Long GetDim() const { return nDim;}
sal_Int32 Compare( const ScDPMember& rOther ) const; // visible order
// XNamed
virtual OUString SAL_CALL getName() override;
virtual void SAL_CALL setName( const OUString& aName ) override;
// XPropertySet
virtual css::uno::Reference< css::beans::XPropertySetInfo >
SAL_CALL getPropertySetInfo( ) override;
virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
const css::uno::Any& aValue ) override;
virtual css::uno::Any SAL_CALL getPropertyValue(
const OUString& PropertyName ) override;
virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
// XServiceInfo
virtual OUString SAL_CALL getImplementationName( ) override;
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
bool isVisible() const { return bVisible;}
bool getShowDetails() const { return bShowDet;}
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|