Coverage Report

Created: 2025-07-07 10:01

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