Coverage Report

Created: 2026-07-10 11:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sc/inc/dapiuno.hxx
Line
Count
Source
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 "cellsuno.hxx"
23
#include "dpglobal.hxx"
24
25
#include <svl/lstner.hxx>
26
#include <svl/itemprop.hxx>
27
28
#include <com/sun/star/lang/XServiceInfo.hpp>
29
#include <com/sun/star/beans/XPropertySet.hpp>
30
#include <com/sun/star/container/XEnumerationAccess.hpp>
31
#include <com/sun/star/container/XNameContainer.hpp>
32
#include <com/sun/star/util/XModifyBroadcaster.hpp>
33
34
#include <com/sun/star/sheet/DataPilotFieldGroupInfo.hpp>
35
#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
36
#include <com/sun/star/sheet/XDataPilotDataLayoutFieldSupplier.hpp>
37
#include <com/sun/star/sheet/XDataPilotDescriptor.hpp>
38
#include <com/sun/star/sheet/XDataPilotField.hpp>
39
#include <com/sun/star/sheet/XDataPilotFieldGrouping.hpp>
40
#include <com/sun/star/sheet/XDataPilotTable2.hpp>
41
#include <com/sun/star/sheet/XDataPilotTables.hpp>
42
43
#include <cppuhelper/implbase.hxx>
44
45
#include <memory>
46
#include <utility>
47
#include <vector>
48
49
namespace com::sun::star::sheet { struct DataPilotFieldAutoShowInfo; }
50
namespace com::sun::star::sheet { class XMembersAccess; }
51
namespace com::sun::star::sheet { struct DataPilotFieldLayoutInfo; }
52
namespace com::sun::star::sheet { struct DataPilotFieldReference; }
53
namespace com::sun::star::sheet { struct DataPilotFieldSortInfo; }
54
55
56
class ScDocShell;
57
class ScDPSaveDimension;
58
class ScTokenArray;
59
struct ScDPNumGroupInfo;
60
61
class ScDataPilotTableObj;
62
class ScDataPilotFieldObj;
63
class ScDataPilotItemObj;
64
enum class ScGeneralFunction;
65
class ScDPObject;
66
67
class ScDataPilotConversion
68
{
69
public:
70
    static ScGeneralFunction   FirstFunc( PivotFunc nBits );
71
    static PivotFunc           FunctionBit( sal_Int16 eFunc );
72
73
    static void         FillGroupInfo(
74
                            css::sheet::DataPilotFieldGroupInfo& rInfo,
75
                            const ScDPNumGroupInfo& rGroupInfo );
76
};
77
78
/** DataPilotTables collection per sheet. */
79
class ScDataPilotTablesObj final : public cppu::WeakImplHelper<
80
                                        css::sheet::XDataPilotTables,
81
                                        css::container::XEnumerationAccess,
82
                                        css::container::XIndexAccess,
83
                                        css::lang::XServiceInfo>,
84
                                    public SfxListener
85
{
86
private:
87
    ScDocShell*             pDocShell;
88
    SCTAB                   nTab;
89
90
    rtl::Reference<ScDataPilotTableObj> GetObjectByIndex_Impl( sal_Int32 nIndex );
91
    rtl::Reference<ScDataPilotTableObj> GetObjectByName_Impl(const OUString& aName);
92
93
public:
94
                            ScDataPilotTablesObj(ScDocShell& rDocSh, SCTAB nT);
95
    virtual                 ~ScDataPilotTablesObj() override;
96
97
    virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
98
99
                            // XDataPilotTables
100
    virtual css::uno::Reference< css::sheet::XDataPilotDescriptor > SAL_CALL
101
                            createDataPilotDescriptor() override;
102
    virtual void SAL_CALL   insertNewByName( const OUString& aName,
103
                                    const css::table::CellAddress& aOutputAddress,
104
                                    const css::uno::Reference< css::sheet::XDataPilotDescriptor >& xDescriptor ) override;
105
    virtual void SAL_CALL   removeByName( const OUString& aName ) override;
106
107
                            // XNameAccess
108
    virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
109
    virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
110
    virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
111
112
                            // XIndexAccess
113
    virtual sal_Int32 SAL_CALL getCount() override;
114
    virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
115
116
                            // XEnumerationAccess
117
    virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
118
                            createEnumeration() override;
119
120
                            // XElementAccess
121
    virtual css::uno::Type SAL_CALL getElementType() override;
122
    virtual sal_Bool SAL_CALL hasElements() override;
123
124
                            // XServiceInfo
125
    virtual OUString SAL_CALL getImplementationName() override;
126
    virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
127
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
128
};
129
130
class ScDataPilotFieldsObj;
131
132
//  ScDataPilotDescriptorBase is never instantiated directly
133
class SAL_DLLPUBLIC_RTTI ScDataPilotDescriptorBase : public cppu::WeakImplHelper<
134
                                    css::sheet::XDataPilotDescriptor,
135
                                    css::beans::XPropertySet,
136
                                    css::sheet::XDataPilotDataLayoutFieldSupplier,
137
                                    css::lang::XServiceInfo>,
138
                                  public SfxListener
139
{
140
private:
141
    SfxItemPropertySet  maPropSet;
142
    ScDocShell*         pDocShell;
143
144
public:
145
                            ScDataPilotDescriptorBase(ScDocShell& rDocSh);
146
    virtual                 ~ScDataPilotDescriptorBase() override;
147
148
    virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
149
150
16
    ScDocShell*             GetDocShell() const     { return pDocShell; }
151
152
                            // in the derivatives:
153
    virtual ScDPObject* GetDPObject() const = 0;
154
    virtual void SetDPObject(ScDPObject* pDPObj) = 0;
155
156
                            // XDataPilotDescriptor
157
                            //  getName, setName, getTag, setTag in derived classes
158
159
    virtual css::table::CellRangeAddress SAL_CALL getSourceRange() override;
160
    virtual void SAL_CALL setSourceRange( const css::table::CellRangeAddress& aSourceRange ) override;
161
    virtual css::uno::Reference< css::sheet::XSheetFilterDescriptor > SAL_CALL
162
                            getFilterDescriptor() override;
163
    virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL
164
                            getDataPilotFields() override;
165
    virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL
166
                            getColumnFields() override;
167
    virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL
168
                            getRowFields() override;
169
    virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL
170
                            getPageFields() override;
171
    virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL
172
                            getDataFields() override;
173
    virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL
174
                            getHiddenFields() override;
175
176
                            // XPropertySet
177
    virtual css::uno::Reference< css::beans::XPropertySetInfo >
178
                            SAL_CALL getPropertySetInfo(  ) override;
179
    virtual void SAL_CALL   setPropertyValue( const OUString& aPropertyName,
180
                                    const css::uno::Any& aValue ) override;
181
    virtual css::uno::Any SAL_CALL getPropertyValue(
182
                                    const OUString& PropertyName ) override;
183
    virtual void SAL_CALL   addPropertyChangeListener( const OUString& aPropertyName,
184
                                    const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
185
    virtual void SAL_CALL   removePropertyChangeListener( const OUString& aPropertyName,
186
                                    const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
187
    virtual void SAL_CALL   addVetoableChangeListener( const OUString& PropertyName,
188
                                    const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
189
    virtual void SAL_CALL   removeVetoableChangeListener( const OUString& PropertyName,
190
                                    const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
191
192
                            // XDataPilotDataLayoutFieldSupplier
193
    virtual css::uno::Reference< css::sheet::XDataPilotField >
194
                            SAL_CALL getDataLayoutField() override;
195
196
                            // XServiceInfo is in derived classes
197
198
    SC_DLLPUBLIC rtl::Reference<ScDataPilotFieldsObj> getScDataPilotFields();
199
    SC_DLLPUBLIC rtl::Reference<ScDataPilotFieldObj> getScDataLayoutField();
200
};
201
202
class ScDataPilotDescriptor final : public ScDataPilotDescriptorBase
203
{
204
private:
205
    std::unique_ptr<ScDPObject>  mpDPObject;
206
207
public:
208
                            ScDataPilotDescriptor(ScDocShell& rDocSh);
209
    virtual                 ~ScDataPilotDescriptor() override;
210
211
    virtual ScDPObject* GetDPObject() const override;
212
    virtual void SetDPObject(ScDPObject* pDPObj) override;
213
214
                            // rest of XDataPilotDescriptor (incl. XNamed)
215
    virtual OUString SAL_CALL getName() override;
216
    virtual void SAL_CALL   setName( const OUString& aName ) override;
217
    virtual OUString SAL_CALL getTag() override;
218
    virtual void SAL_CALL   setTag( const OUString& aTag ) override;
219
220
                            // XServiceInfo
221
    virtual OUString SAL_CALL getImplementationName() override;
222
    virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
223
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
224
};
225
226
class ScDataPilotTableObj final : public ScDataPilotDescriptorBase,
227
                            public css::sheet::XDataPilotTable2,
228
                            public css::util::XModifyBroadcaster
229
{
230
private:
231
    SCTAB                   nTab;
232
    OUString                aName;
233
    XModifyListenerArr_Impl aModifyListeners;
234
235
    void                    Refreshed_Impl();
236
237
public:
238
                            ScDataPilotTableObj(ScDocShell& rDocSh, SCTAB nT, OUString aN);
239
    virtual                 ~ScDataPilotTableObj() override;
240
241
    virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
242
    virtual void SAL_CALL   acquire() noexcept override;
243
    virtual void SAL_CALL   release() noexcept override;
244
245
    virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
246
247
    virtual ScDPObject* GetDPObject() const override;
248
    virtual void SetDPObject(ScDPObject* pDPObj) override;
249
250
                            // rest of XDataPilotDescriptor (incl. XNamed)
251
    virtual OUString SAL_CALL getName() override;
252
    virtual void SAL_CALL   setName( const OUString& aName ) override;
253
    virtual OUString SAL_CALL getTag() override;
254
    virtual void SAL_CALL   setTag( const OUString& aTag ) override;
255
256
                            // XDataPilotTable
257
    virtual css::table::CellRangeAddress SAL_CALL getOutputRange() override;
258
    virtual void SAL_CALL   refresh() override;
259
260
                            // XDataPilotTable2
261
    virtual css::uno::Sequence< css::uno::Sequence< css::uno::Any > >
262
        SAL_CALL getDrillDownData(const css::table::CellAddress& aAddr) override;
263
264
    virtual css::sheet::DataPilotTablePositionData
265
        SAL_CALL getPositionData(const css::table::CellAddress& aAddr) override;
266
267
    virtual void SAL_CALL insertDrillDownSheet(const css::table::CellAddress& aAddr) override;
268
269
    virtual css::table::CellRangeAddress SAL_CALL getOutputRangeByType( sal_Int32 nType ) override;
270
271
                            // XModifyBroadcaster
272
    virtual void SAL_CALL   addModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
273
    virtual void SAL_CALL   removeModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
274
275
                            // XTypeProvider (override)
276
    virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
277
    virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
278
279
                            // XServiceInfo
280
    virtual OUString SAL_CALL getImplementationName() override;
281
    virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
282
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
283
};
284
285
struct ScFieldIdentifier
286
{
287
    OUString            maFieldName;    /// Source field name.
288
    sal_Int32           mnFieldIdx;     /// Field index (if several fields with same name exist).
289
    bool                mbDataLayout;   /// True = data layout field collecting all data fields as items.
290
291
    explicit     ScFieldIdentifier() :
292
6.21k
                            mnFieldIdx( 0 ), mbDataLayout( false ) {}
293
294
    explicit     ScFieldIdentifier( OUString aFieldName, bool bDataLayout ) :
295
38
                            maFieldName(std::move( aFieldName )), mnFieldIdx( 0 ), mbDataLayout( bDataLayout ) {}
296
};
297
298
/** Base class of all implementation objects based on a DataPilot descriptor
299
    or DataPilot table object. Wraps acquiring and releasing the parent. */
300
class ScDataPilotChildObjBase
301
{
302
protected:
303
    explicit            ScDataPilotChildObjBase( ScDataPilotDescriptorBase& rParent );
304
    explicit            ScDataPilotChildObjBase( ScDataPilotDescriptorBase& rParent, ScFieldIdentifier aFieldId );
305
    virtual             ~ScDataPilotChildObjBase();
306
307
    /** Returns the wrapped DataPilot object (calls GetDPObject() at parent). */
308
    ScDPObject*         GetDPObject() const;
309
    /** Sets the passed DataPilot object (calls SetDPObject() at parent). */
310
    void                SetDPObject( ScDPObject* pDPObject );
311
312
    /** Returns the DataPilot dimension object related to the field described by maFieldId. */
313
    ScDPSaveDimension*  GetDPDimension( ScDPObject** ppDPObject = nullptr ) const;
314
315
    /** Returns the number of members for the field described by maFieldId. */
316
    sal_Int32           GetMemberCount() const;
317
    /** Returns the collection of members for the field described by maFieldId. */
318
    css::uno::Reference< css::sheet::XMembersAccess > GetMembers() const;
319
320
    ScDocShell* GetDocShell() const;
321
protected:
322
    rtl::Reference<ScDataPilotDescriptorBase> mxParent;
323
    ScFieldIdentifier   maFieldId;
324
325
private:
326
    ScDataPilotChildObjBase& operator=( const ScDataPilotChildObjBase& ) = delete;
327
};
328
329
typedef ::cppu::WeakImplHelper
330
<
331
    css::container::XEnumerationAccess,
332
    css::container::XIndexAccess,
333
    css::container::XNameAccess,
334
    css::lang::XServiceInfo
335
>
336
ScDataPilotFieldsObjImpl;
337
338
/** Collection of all DataPilot fields, or of all fields from a specific dimension. */
339
class SAL_DLLPUBLIC_RTTI ScDataPilotFieldsObj final : public ScDataPilotChildObjBase, public ScDataPilotFieldsObjImpl
340
{
341
public:
342
    explicit            ScDataPilotFieldsObj(
343
                            ScDataPilotDescriptorBase& rParent );
344
345
    explicit            ScDataPilotFieldsObj(
346
                            ScDataPilotDescriptorBase& rParent,
347
                            css::sheet::DataPilotFieldOrientation eOrient );
348
349
    virtual             ~ScDataPilotFieldsObj() override;
350
351
                            // XNameAccess
352
    virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
353
    virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
354
    virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
355
356
                            // XIndexAccess
357
    virtual sal_Int32 SAL_CALL getCount() override;
358
    virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
359
360
                            // XEnumerationAccess
361
    virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
362
                            createEnumeration() override;
363
364
                            // XElementAccess
365
    virtual css::uno::Type SAL_CALL getElementType() override;
366
    virtual sal_Bool SAL_CALL hasElements() override;
367
368
                            // XServiceInfo
369
    virtual OUString SAL_CALL getImplementationName() override;
370
    virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
371
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
372
373
    SC_DLLPUBLIC rtl::Reference<ScDataPilotFieldObj>
374
    getScDataPilotFieldObjByIndex(sal_Int32 nIndex, bool bCalculated = false,
375
                                  const OUString& aFieldName = u""_ustr,
376
                                  const std::shared_ptr<ScTokenArray>& pArray = nullptr);
377
    SC_DLLPUBLIC rtl::Reference<ScDataPilotFieldObj> getScDataPilotFieldObjByName( const OUString& aName );
378
379
private:
380
    rtl::Reference<ScDataPilotFieldObj> GetObjectByIndex_Impl(sal_Int32 nIndex,
381
                                                              bool bCalculated = false,
382
                                                              const OUString& rFieldName = u""_ustr,
383
                                                              const std::shared_ptr<ScTokenArray>& pArray = nullptr) const;
384
    rtl::Reference<ScDataPilotFieldObj> GetObjectByName_Impl( const OUString& rName ) const;
385
386
private:
387
    css::uno::Any maOrient;    /// Field orientation, no value = all fields.
388
};
389
390
typedef ::cppu::WeakImplHelper
391
<
392
    css::container::XNamed,
393
    css::beans::XPropertySet,
394
    css::sheet::XDataPilotField,
395
    css::sheet::XDataPilotFieldGrouping,
396
    css::lang::XServiceInfo
397
>
398
ScDataPilotFieldObjImpl;
399
400
/** Implementation of a single DataPilot field. */
401
class SAL_DLLPUBLIC_RTTI ScDataPilotFieldObj final : public ScDataPilotChildObjBase, public ScDataPilotFieldObjImpl
402
{
403
public:
404
                        ScDataPilotFieldObj(
405
                            ScDataPilotDescriptorBase& rParent,
406
                            const ScFieldIdentifier& rIdent );
407
408
                        ScDataPilotFieldObj(
409
                            ScDataPilotDescriptorBase& rParent,
410
                            const ScFieldIdentifier& rIdent,
411
                            css::uno::Any aOrient );
412
413
    virtual             ~ScDataPilotFieldObj() override;
414
415
                            // XNamed
416
    SC_DLLPUBLIC virtual OUString SAL_CALL getName() override;
417
    virtual void SAL_CALL   setName(const OUString& aName) override;
418
419
                            // XPropertySet
420
    virtual css::uno::Reference< css::beans::XPropertySetInfo >
421
                            SAL_CALL getPropertySetInfo(  ) override;
422
    virtual void SAL_CALL   setPropertyValue( const OUString& aPropertyName,
423
                                    const css::uno::Any& aValue ) override;
424
    virtual css::uno::Any SAL_CALL getPropertyValue(const OUString& PropertyName ) override;
425
    virtual void SAL_CALL   addPropertyChangeListener( const OUString& aPropertyName,
426
                                    const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
427
    virtual void SAL_CALL   removePropertyChangeListener( const OUString& aPropertyName,
428
                                    const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
429
    virtual void SAL_CALL   addVetoableChangeListener( const OUString& PropertyName,
430
                                    const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
431
    virtual void SAL_CALL   removeVetoableChangeListener( const OUString& PropertyName,
432
                                    const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
433
434
                            // XDatePilotField
435
    virtual css::uno::Reference<css::container::XIndexAccess> SAL_CALL
436
                                getItems() override;
437
438
                            // only called from property-functions:
439
    css::sheet::DataPilotFieldOrientation getOrientation() const;
440
    void setOrientation(css::sheet::DataPilotFieldOrientation Orientation);
441
    sal_Int16 getFunction() const;
442
    void setFunction(ScGeneralFunction Function);
443
    css::uno::Sequence< sal_Int16 > getSubtotals() const;
444
    void setSubtotals(const std::vector< ScGeneralFunction >& rFunctions);
445
    void setCurrentPage(const OUString& sPage);
446
    void setUseCurrentPage(bool bUse);
447
    const css::sheet::DataPilotFieldAutoShowInfo* getAutoShowInfo() const;
448
    void setAutoShowInfo(const css::sheet::DataPilotFieldAutoShowInfo* pInfo);
449
    const css::sheet::DataPilotFieldLayoutInfo* getLayoutInfo() const;
450
    void setLayoutInfo(const css::sheet::DataPilotFieldLayoutInfo* pInfo);
451
    const css::sheet::DataPilotFieldReference* getReference() const;
452
    void setReference(const css::sheet::DataPilotFieldReference* pInfo);
453
    const css::sheet::DataPilotFieldSortInfo* getSortInfo() const;
454
    void setSortInfo(const css::sheet::DataPilotFieldSortInfo* pInfo);
455
    bool getShowEmpty() const;
456
    void setShowEmpty(bool bShow);
457
    bool getRepeatItemLabels() const;
458
    void setRepeatItemLabels(bool bShow);
459
460
    bool hasGroupInfo() const;
461
    css::sheet::DataPilotFieldGroupInfo getGroupInfo();
462
    void setGroupInfo(const css::sheet::DataPilotFieldGroupInfo* pInfo);
463
464
                            // XDataPilotFieldGrouping
465
    virtual css::uno::Reference < css::sheet::XDataPilotField > SAL_CALL
466
        createNameGroup(const css::uno::Sequence< OUString >& aItems) override;
467
    virtual css::uno::Reference < css::sheet::XDataPilotField > SAL_CALL
468
        createDateGroup(const css::sheet::DataPilotFieldGroupInfo& rInfo) override;
469
470
                            // XServiceInfo
471
    virtual OUString SAL_CALL getImplementationName() override;
472
    virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
473
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
474
475
    SC_DLLPUBLIC rtl::Reference< ScDataPilotFieldObj >
476
        createNameGroup(const std::vector< OUString >& aItems);
477
    SC_DLLPUBLIC rtl::Reference< ScDataPilotFieldObj >
478
        createScDateGroup(const css::sheet::DataPilotFieldGroupInfo& rInfo);
479
480
private:
481
    css::uno::Reference< css::container::XIndexAccess >
482
                        mxItems;
483
    SfxItemPropertySet  maPropSet;
484
    css::uno::Any maOrient;
485
};
486
487
typedef ::std::vector< OUString > ScFieldGroupMembers;
488
489
struct ScFieldGroup
490
{
491
    OUString     maName;
492
    ScFieldGroupMembers maMembers;
493
};
494
495
typedef ::std::vector< ScFieldGroup > ScFieldGroups;
496
497
typedef ::cppu::WeakImplHelper
498
<
499
    css::container::XNameContainer,
500
    css::container::XEnumerationAccess,
501
    css::container::XIndexAccess,
502
    css::lang::XServiceInfo
503
>
504
ScDataPilotFieldGroupsObjImpl;
505
506
/** Implementation of all grouped items in a DataPilot field.
507
508
    This is a stand-alone object without any connection to the base DataPilot
509
    field. Grouping info has to be written back with the GroupInfo property of
510
    the DataPilot field after modifying this object.
511
 */
512
class ScDataPilotFieldGroupsObj final : public ScDataPilotFieldGroupsObjImpl
513
{
514
public:
515
    explicit            ScDataPilotFieldGroupsObj( ScFieldGroups&& rGroups );
516
    virtual             ~ScDataPilotFieldGroupsObj() override;
517
518
                            // XNameAccess
519
    virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
520
    virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
521
    virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
522
523
                                // XNameReplace
524
    virtual void SAL_CALL replaceByName( const OUString& aName,
525
                                const css::uno::Any& aElement ) override;
526
527
                            // XNameContainer
528
    virtual void SAL_CALL insertByName( const OUString& aName,
529
                                const css::uno::Any& aElement ) override;
530
    virtual void SAL_CALL removeByName( const OUString& Name ) override;
531
532
                        // XIndexAccess
533
    virtual sal_Int32 SAL_CALL getCount() override;
534
    virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
535
536
                            // XEnumerationAccess
537
    virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
538
                            createEnumeration() override;
539
540
                            // XElementAccess
541
    virtual css::uno::Type SAL_CALL getElementType() override;
542
    virtual sal_Bool SAL_CALL hasElements() override;
543
544
                            // XServiceInfo
545
    virtual OUString SAL_CALL getImplementationName() override;
546
    virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
547
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
548
549
    // implementation
550
    /// @throws css::uno::RuntimeException
551
    ScFieldGroup&       getFieldGroup( const OUString& rName );
552
    /// @throws css::uno::RuntimeException
553
    void                renameFieldGroup( const OUString& rOldName, const OUString& rNewName );
554
555
private:
556
    ScFieldGroups::iterator implFindByName( const OUString& rName );
557
558
private:
559
    ScFieldGroups       maGroups;
560
};
561
562
typedef ::cppu::WeakImplHelper
563
<
564
    css::container::XNameContainer,
565
    css::container::XEnumerationAccess,
566
    css::container::XIndexAccess,
567
    css::container::XNamed,
568
    css::lang::XServiceInfo
569
>
570
ScDataPilotFieldGroupObjImpl;
571
572
class ScDataPilotFieldGroupObj final : public ScDataPilotFieldGroupObjImpl
573
{
574
public:
575
    explicit            ScDataPilotFieldGroupObj( ScDataPilotFieldGroupsObj& rParent, OUString aGroupName );
576
    virtual             ~ScDataPilotFieldGroupObj() override;
577
578
                            // XNameAccess
579
    virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
580
    virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
581
    virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
582
583
                                // XNameReplace
584
    virtual void SAL_CALL replaceByName( const OUString& aName,
585
                                const css::uno::Any& aElement ) override;
586
587
                                // XNameContainer
588
    virtual void SAL_CALL insertByName( const OUString& aName,
589
                                const css::uno::Any& aElement ) override;
590
    virtual void SAL_CALL removeByName( const OUString& Name ) override;
591
592
                    // XIndexAccess
593
    virtual sal_Int32 SAL_CALL getCount() override;
594
    virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
595
596
                            // XEnumerationAccess
597
    virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
598
                            createEnumeration() override;
599
600
                            // XElementAccess
601
    virtual css::uno::Type SAL_CALL getElementType() override;
602
    virtual sal_Bool SAL_CALL hasElements() override;
603
604
                            // XNamed
605
    virtual OUString SAL_CALL getName() override;
606
    virtual void SAL_CALL   setName( const OUString& aName ) override;
607
608
                            // XServiceInfo
609
    virtual OUString SAL_CALL getImplementationName() override;
610
    virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
611
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
612
613
private:
614
    rtl::Reference<ScDataPilotFieldGroupsObj> mxParent;
615
    OUString     maGroupName;
616
};
617
618
typedef ::cppu::WeakImplHelper
619
<
620
    css::container::XNamed,
621
    css::lang::XServiceInfo
622
>
623
ScDataPilotFieldGroupItemObjImpl;
624
625
class ScDataPilotFieldGroupItemObj final : public ScDataPilotFieldGroupItemObjImpl
626
{
627
public:
628
    explicit            ScDataPilotFieldGroupItemObj( ScDataPilotFieldGroupObj& rParent, OUString aName );
629
    virtual             ~ScDataPilotFieldGroupItemObj() override;
630
631
                            // XNamed
632
    virtual OUString SAL_CALL getName() override;
633
    virtual void SAL_CALL   setName( const OUString& aName ) override;
634
635
                            // XServiceInfo
636
    virtual OUString SAL_CALL getImplementationName() override;
637
    virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
638
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
639
640
private:
641
    rtl::Reference<ScDataPilotFieldGroupObj> mxParent;
642
    OUString     maName;
643
};
644
645
typedef ::cppu::WeakImplHelper
646
<
647
    css::container::XEnumerationAccess,
648
    css::container::XIndexAccess,
649
    css::container::XNameAccess,
650
    css::lang::XServiceInfo
651
>
652
ScDataPilotItemsObjImpl;
653
654
class ScDataPilotItemsObj final : public ScDataPilotChildObjBase, public ScDataPilotItemsObjImpl
655
{
656
public:
657
    explicit            ScDataPilotItemsObj( ScDataPilotDescriptorBase& rParent, const ScFieldIdentifier& rFieldId );
658
    virtual             ~ScDataPilotItemsObj() override;
659
660
                            // XNameAccess
661
    virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
662
    virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
663
    virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
664
665
                            // XIndexAccess
666
    virtual sal_Int32 SAL_CALL getCount() override;
667
    virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
668
669
                            // XEnumerationAccess
670
    virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
671
                            createEnumeration() override;
672
673
                            // XElementAccess
674
    virtual css::uno::Type SAL_CALL getElementType() override;
675
    virtual sal_Bool SAL_CALL hasElements() override;
676
677
                            // XServiceInfo
678
    virtual OUString SAL_CALL getImplementationName() override;
679
    virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
680
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
681
682
private:
683
    ScDataPilotItemObj* GetObjectByIndex_Impl( sal_Int32 nIndex ) const;
684
};
685
686
typedef ::cppu::WeakImplHelper
687
<
688
    css::container::XNamed,
689
    css::beans::XPropertySet,
690
    css::lang::XServiceInfo
691
>
692
ScDataPilotItemObjImpl;
693
694
class ScDataPilotItemObj final : public ScDataPilotChildObjBase, public ScDataPilotItemObjImpl
695
{
696
public:
697
    explicit            ScDataPilotItemObj(
698
                            ScDataPilotDescriptorBase& rParent,
699
                            const ScFieldIdentifier& rFieldId,
700
                            sal_Int32 nIndex );
701
702
    virtual             ~ScDataPilotItemObj() override;
703
704
                            // XNamed
705
    virtual OUString SAL_CALL getName() override;
706
    virtual void SAL_CALL   setName( const OUString& aName ) override;
707
708
                            // XPropertySet
709
    virtual css::uno::Reference< css::beans::XPropertySetInfo >
710
                            SAL_CALL getPropertySetInfo(  ) override;
711
    virtual void SAL_CALL   setPropertyValue( const OUString& aPropertyName,
712
                                    const css::uno::Any& aValue ) override;
713
    virtual css::uno::Any SAL_CALL getPropertyValue(
714
                                    const OUString& PropertyName ) override;
715
    virtual void SAL_CALL   addPropertyChangeListener( const OUString& aPropertyName,
716
                                    const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
717
    virtual void SAL_CALL   removePropertyChangeListener( const OUString& aPropertyName,
718
                                    const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
719
    virtual void SAL_CALL   addVetoableChangeListener( const OUString& PropertyName,
720
                                    const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
721
    virtual void SAL_CALL   removeVetoableChangeListener( const OUString& PropertyName,
722
                                    const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
723
724
                            // XServiceInfo
725
    virtual OUString SAL_CALL getImplementationName() override;
726
    virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
727
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
728
729
private:
730
    SfxItemPropertySet  maPropSet;
731
    sal_Int32           mnIndex;
732
};
733
734
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */