1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SC_INC_DATAUNO_HXX
21 #define INCLUDED_SC_INC_DATAUNO_HXX
24 #include "queryparam.hxx"
25 #include "subtotalparam.hxx"
27 #include <com/sun/star/sheet/TableFilterField.hpp>
28 #include <com/sun/star/sheet/GeneralFunction.hpp>
29 #include <com/sun/star/sheet/XCellRangeReferrer.hpp>
30 #include <com/sun/star/sheet/XSheetFilterDescriptor.hpp>
31 #include <com/sun/star/sheet/XSheetFilterDescriptor2.hpp>
32 #include <com/sun/star/sheet/XSheetFilterDescriptor3.hpp>
33 #include <com/sun/star/sheet/XConsolidationDescriptor.hpp>
34 #include <com/sun/star/sheet/XDatabaseRanges.hpp>
35 #include <com/sun/star/sheet/XDatabaseRange.hpp>
36 #include <com/sun/star/sheet/XUnnamedDatabaseRanges.hpp>
37 #include <com/sun/star/sheet/XSubTotalDescriptor.hpp>
38 #include <com/sun/star/sheet/XSubTotalField.hpp>
39 #include <com/sun/star/lang/XServiceInfo.hpp>
40 #include <com/sun/star/container/XEnumerationAccess.hpp>
41 #include <com/sun/star/container/XIndexAccess.hpp>
42 #include <com/sun/star/beans/XPropertySet.hpp>
43 #include <com/sun/star/lang/XUnoTunnel.hpp>
44 #include <com/sun/star/container/XNamed.hpp>
45 #include <com/sun/star/util/XRefreshable.hpp>
46 #include <cppuhelper/implbase.hxx>
47 #include <rtl/ref.hxx>
48 #include <svl/itemprop.hxx>
49 #include <svl/lstner.hxx>
56 class ScSubTotalFieldObj
;
57 class ScDatabaseRangeObj
;
58 class ScDataPilotDescriptorBase
;
62 class ScDataUnoConversion
65 static css::sheet::GeneralFunction
SubTotalToGeneral( ScSubTotalFunc eSubTotal
);
68 // ImportDescriptor is not available as Uno-object any longer, only Property-Sequence
70 class ScImportDescriptor
73 static void FillImportParam(
74 ScImportParam
& rParam
,
75 const css::uno::Sequence
<css::beans::PropertyValue
>& rSeq
);
76 static void FillProperties(
77 css::uno::Sequence
<css::beans::PropertyValue
>& rSeq
,
78 const ScImportParam
& rParam
);
79 static long GetPropertyCount() { return 4; }
82 // SortDescriptor is not available as Uno-object any longer, only Property-Sequence
84 class ScSortDescriptor
87 static void FillSortParam(
89 const css::uno::Sequence
<css::beans::PropertyValue
>& rSeq
);
90 static void FillProperties(
91 css::uno::Sequence
<css::beans::PropertyValue
>& rSeq
,
92 const ScSortParam
& rParam
);
93 //! SortAscending needs to get out of the SheetSortDescriptor service description
94 static long GetPropertyCount()
96 return 9; // TableSortDescriptor and SheetSortDescriptor
101 // ScSubTotalDescriptorBase - base class for SubTotalDescriptor stand alone and in DB area (context?)
103 // to uno, both look the same
105 class ScSubTotalDescriptorBase
: public cppu::WeakImplHelper
<
106 css::sheet::XSubTotalDescriptor
,
107 css::container::XEnumerationAccess
,
108 css::container::XIndexAccess
,
109 css::beans::XPropertySet
,
110 css::lang::XUnoTunnel
,
111 css::lang::XServiceInfo
>
114 SfxItemPropertySet aPropSet
;
116 ScSubTotalFieldObj
* GetObjectByIndex_Impl(sal_uInt16 nIndex
);
119 ScSubTotalDescriptorBase();
120 virtual ~ScSubTotalDescriptorBase() override
;
122 // in derived classes:
123 // (Fields are within the range)
124 virtual void GetData( ScSubTotalParam
& rParam
) const = 0;
125 virtual void PutData( const ScSubTotalParam
& rParam
) = 0;
127 // XSubTotalDescriptor
128 virtual void SAL_CALL
addNew( const css::uno::Sequence
< css::sheet::SubTotalColumn
>& aSubTotalColumns
,
129 sal_Int32 nGroupColumn
) override
;
130 virtual void SAL_CALL
clear() override
;
133 virtual sal_Int32 SAL_CALL
getCount() override
;
134 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) override
;
136 // XEnumerationAccess
137 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
138 createEnumeration() override
;
141 virtual css::uno::Type SAL_CALL
getElementType() override
;
142 virtual sal_Bool SAL_CALL
hasElements() override
;
145 virtual css::uno::Reference
< css::beans::XPropertySetInfo
>
146 SAL_CALL
getPropertySetInfo() override
;
147 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
,
148 const css::uno::Any
& aValue
) override
;
149 virtual css::uno::Any SAL_CALL
getPropertyValue(
150 const OUString
& PropertyName
) override
;
151 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
,
152 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
153 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
,
154 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& aListener
) override
;
155 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
,
156 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
157 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
,
158 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
161 virtual sal_Int64 SAL_CALL
getSomething( const css::uno::Sequence
< sal_Int8
>& aIdentifier
) override
;
163 static const css::uno::Sequence
<sal_Int8
>& getUnoTunnelId();
164 static ScSubTotalDescriptorBase
* getImplementation(const css::uno::Reference
<css::sheet::XSubTotalDescriptor
>& rObj
);
167 virtual OUString SAL_CALL
getImplementationName() override
;
168 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
169 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
172 // ScSubTotalDescriptor - dummy container to use with XImportTarget
174 class ScSubTotalDescriptor
: public ScSubTotalDescriptorBase
177 ScSubTotalParam aStoredParam
;
180 ScSubTotalDescriptor();
181 virtual ~ScSubTotalDescriptor() override
;
183 // from ScSubTotalDescriptorBase:
184 virtual void GetData( ScSubTotalParam
& rParam
) const override
;
185 virtual void PutData( const ScSubTotalParam
& rParam
) override
;
188 void SetParam( const ScSubTotalParam
& rNew
);
191 // ScRangeSubTotalDescriptor - SubTotalDescriptor of a data base area
193 class ScRangeSubTotalDescriptor
: public ScSubTotalDescriptorBase
196 rtl::Reference
<ScDatabaseRangeObj
> mxParent
;
199 ScRangeSubTotalDescriptor(ScDatabaseRangeObj
* pPar
);
200 virtual ~ScRangeSubTotalDescriptor() override
;
202 // from ScSubTotalDescriptorBase:
203 virtual void GetData( ScSubTotalParam
& rParam
) const override
;
204 virtual void PutData( const ScSubTotalParam
& rParam
) override
;
207 class ScSubTotalFieldObj
: public cppu::WeakImplHelper
<
208 css::sheet::XSubTotalField
,
209 css::lang::XServiceInfo
>
212 rtl::Reference
<ScSubTotalDescriptorBase
> xParent
;
216 ScSubTotalFieldObj( ScSubTotalDescriptorBase
* pDesc
, sal_uInt16 nP
);
217 virtual ~ScSubTotalFieldObj() override
;
220 virtual sal_Int32 SAL_CALL
getGroupColumn() override
;
221 virtual void SAL_CALL
setGroupColumn( sal_Int32 nGroupColumn
) override
;
222 virtual css::uno::Sequence
< css::sheet::SubTotalColumn
> SAL_CALL
223 getSubTotalColumns() override
;
224 virtual void SAL_CALL
setSubTotalColumns( const css::uno::Sequence
<
225 css::sheet::SubTotalColumn
>& aSubTotalColumns
) override
;
228 virtual OUString SAL_CALL
getImplementationName() override
;
229 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
230 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
233 class ScConsolidationDescriptor
: public cppu::WeakImplHelper
<
234 css::sheet::XConsolidationDescriptor
,
235 css::lang::XServiceInfo
>
238 ScConsolidateParam aParam
;
241 ScConsolidationDescriptor();
242 virtual ~ScConsolidationDescriptor() override
;
244 void SetParam( const ScConsolidateParam
& rNew
);
245 const ScConsolidateParam
& GetParam() const { return aParam
; }
247 // XConsolidationDescriptor
248 virtual css::sheet::GeneralFunction SAL_CALL
getFunction() override
;
249 virtual void SAL_CALL
setFunction( css::sheet::GeneralFunction nFunction
) override
;
250 virtual css::uno::Sequence
< css::table::CellRangeAddress
> SAL_CALL
251 getSources( ) override
;
252 virtual void SAL_CALL
setSources( const css::uno::Sequence
< css::table::CellRangeAddress
>& aSources
) override
;
253 virtual css::table::CellAddress SAL_CALL
getStartOutputPosition() override
;
254 virtual void SAL_CALL
setStartOutputPosition(
255 const css::table::CellAddress
& aStartOutputPosition
) override
;
256 virtual sal_Bool SAL_CALL
getUseColumnHeaders() override
;
257 virtual void SAL_CALL
setUseColumnHeaders( sal_Bool bUseColumnHeaders
) override
;
258 virtual sal_Bool SAL_CALL
getUseRowHeaders() override
;
259 virtual void SAL_CALL
setUseRowHeaders( sal_Bool bUseRowHeaders
) override
;
260 virtual sal_Bool SAL_CALL
getInsertLinks() override
;
261 virtual void SAL_CALL
setInsertLinks( sal_Bool bInsertLinks
) override
;
264 virtual OUString SAL_CALL
getImplementationName() override
;
265 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
266 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
269 // ScFilterDescriptorBase - base class for FilterDescriptor
270 // stand alone, in a DB area (or context?) and in the DataPilot
272 // to uno, all three look the same
274 class ScFilterDescriptorBase
: public cppu::WeakImplHelper
<
275 css::sheet::XSheetFilterDescriptor
,
276 css::sheet::XSheetFilterDescriptor2
,
277 css::sheet::XSheetFilterDescriptor3
,
278 css::beans::XPropertySet
,
279 css::lang::XServiceInfo
>,
283 SfxItemPropertySet aPropSet
;
287 ScFilterDescriptorBase(ScDocShell
* pDocShell
);
288 virtual ~ScFilterDescriptorBase() override
;
290 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
292 // in the derived classes(?):
293 // (nField[] here within the area)
294 virtual void GetData( ScQueryParam
& rParam
) const = 0;
295 virtual void PutData( const ScQueryParam
& rParam
) = 0;
297 // XSheetFilterDescriptor
298 virtual css::uno::Sequence
< css::sheet::TableFilterField
> SAL_CALL
299 getFilterFields() override
;
300 virtual void SAL_CALL
setFilterFields( const css::uno::Sequence
<
301 css::sheet::TableFilterField
>& aFilterFields
) override
;
303 // XSheetFilterDescriptor2
304 virtual css::uno::Sequence
< css::sheet::TableFilterField2
> SAL_CALL
305 getFilterFields2() override
;
306 virtual void SAL_CALL
setFilterFields2( const css::uno::Sequence
<
307 css::sheet::TableFilterField2
>& aFilterFields
) override
;
309 // XSheetFilterDescriptor3
310 virtual css::uno::Sequence
< css::sheet::TableFilterField3
> SAL_CALL
311 getFilterFields3() override
;
312 virtual void SAL_CALL
setFilterFields3( const css::uno::Sequence
<
313 css::sheet::TableFilterField3
>& aFilterFields
) override
;
316 virtual css::uno::Reference
< css::beans::XPropertySetInfo
>
317 SAL_CALL
getPropertySetInfo() override
;
318 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
,
319 const css::uno::Any
& aValue
) override
;
320 virtual css::uno::Any SAL_CALL
getPropertyValue(
321 const OUString
& PropertyName
) override
;
322 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
,
323 const css::uno::Reference
<
324 css::beans::XPropertyChangeListener
>& xListener
) override
;
325 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
,
326 const css::uno::Reference
<
327 css::beans::XPropertyChangeListener
>& aListener
) override
;
328 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
,
329 const css::uno::Reference
<
330 css::beans::XVetoableChangeListener
>& aListener
) override
;
331 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
,
332 const css::uno::Reference
<
333 css::beans::XVetoableChangeListener
>& aListener
) override
;
336 virtual OUString SAL_CALL
getImplementationName() override
;
337 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
338 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
341 // ScFilterDescriptor - dummy container to use with XFilterable
343 class ScFilterDescriptor
: public ScFilterDescriptorBase
346 ScQueryParam aStoredParam
; // nField[] here within the area
349 ScFilterDescriptor(ScDocShell
* pDocSh
);
350 virtual ~ScFilterDescriptor() override
;
352 // from ScFilterDescriptorBase:
353 virtual void GetData( ScQueryParam
& rParam
) const override
;
354 virtual void PutData( const ScQueryParam
& rParam
) override
;
357 void SetParam( const ScQueryParam
& rNew
);
358 const ScQueryParam
& GetParam() const { return aStoredParam
; }
361 // ScRangeFilterDescriptor - FilterDescriptor of a data base area
363 class ScRangeFilterDescriptor
: public ScFilterDescriptorBase
366 rtl::Reference
<ScDatabaseRangeObj
> mxParent
;
369 ScRangeFilterDescriptor(ScDocShell
* pDocSh
, ScDatabaseRangeObj
* pPar
);
370 virtual ~ScRangeFilterDescriptor() override
;
372 // from ScFilterDescriptorBase:
373 virtual void GetData( ScQueryParam
& rParam
) const override
;
374 virtual void PutData( const ScQueryParam
& rParam
) override
;
377 // ScDataPilotFilterDescriptor - FilterDescriptor of a DataPilotDescriptors
379 class ScDataPilotFilterDescriptor
: public ScFilterDescriptorBase
382 rtl::Reference
<ScDataPilotDescriptorBase
> mxParent
;
385 ScDataPilotFilterDescriptor(ScDocShell
* pDocSh
, ScDataPilotDescriptorBase
* pPar
);
386 virtual ~ScDataPilotFilterDescriptor() override
;
388 // from ScFilterDescriptorBase:
389 virtual void GetData( ScQueryParam
& rParam
) const override
;
390 virtual void PutData( const ScQueryParam
& rParam
) override
;
393 class ScDatabaseRangeObj
: public cppu::WeakImplHelper
<
394 css::sheet::XDatabaseRange
,
395 css::util::XRefreshable
,
396 css::container::XNamed
,
397 css::sheet::XCellRangeReferrer
,
398 css::beans::XPropertySet
,
399 css::lang::XServiceInfo
>,
403 ScDocShell
* pDocShell
;
405 SfxItemPropertySet aPropSet
;
406 std::vector
< css::uno::Reference
< css::util::XRefreshListener
> >
412 ScDBData
* GetDBData_Impl() const;
413 void Refreshed_Impl();
416 ScDatabaseRangeObj(ScDocShell
* pDocSh
, const OUString
& rNm
);
417 SC_DLLPUBLIC
ScDatabaseRangeObj(ScDocShell
* pDocSh
, const SCTAB nTab
);
418 virtual ~ScDatabaseRangeObj() override
;
420 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
422 // nField[] here within the area:
423 void GetQueryParam(ScQueryParam
& rQueryParam
) const;
424 void SetQueryParam(const ScQueryParam
& rQueryParam
);
425 void GetSubTotalParam(ScSubTotalParam
& rSubTotalParam
) const;
426 void SetSubTotalParam(const ScSubTotalParam
& rSubTotalParam
);
429 virtual OUString SAL_CALL
getName() override
;
430 virtual void SAL_CALL
setName( const OUString
& aName
) override
;
433 virtual css::table::CellRangeAddress SAL_CALL
getDataArea() override
;
434 virtual void SAL_CALL
setDataArea( const css::table::CellRangeAddress
& aDataArea
) override
;
435 virtual css::uno::Sequence
< css::beans::PropertyValue
> SAL_CALL
436 getSortDescriptor() override
;
437 virtual css::uno::Reference
< css::sheet::XSheetFilterDescriptor
> SAL_CALL
438 getFilterDescriptor() override
;
439 virtual css::uno::Reference
< css::sheet::XSubTotalDescriptor
> SAL_CALL
440 getSubTotalDescriptor() override
;
441 virtual css::uno::Sequence
< css::beans::PropertyValue
> SAL_CALL
442 getImportDescriptor() override
;
445 virtual void SAL_CALL
refresh() override
;
446 virtual void SAL_CALL
addRefreshListener( const css::uno::Reference
<
447 css::util::XRefreshListener
>& l
) override
;
448 virtual void SAL_CALL
removeRefreshListener( const css::uno::Reference
<
449 css::util::XRefreshListener
>& l
) override
;
451 // XCellRangeReferrer
452 virtual css::uno::Reference
< css::table::XCellRange
> SAL_CALL
453 getReferredCells() override
;
456 virtual css::uno::Reference
< css::beans::XPropertySetInfo
>
457 SAL_CALL
getPropertySetInfo() override
;
458 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
,
459 const css::uno::Any
& aValue
) override
;
460 virtual css::uno::Any SAL_CALL
getPropertyValue(
461 const OUString
& PropertyName
) override
;
462 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
,
463 const css::uno::Reference
<
464 css::beans::XPropertyChangeListener
>& xListener
) override
;
465 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
,
466 const css::uno::Reference
<
467 css::beans::XPropertyChangeListener
>& aListener
) override
;
468 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
,
469 const css::uno::Reference
<
470 css::beans::XVetoableChangeListener
>& aListener
) override
;
471 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
,
472 const css::uno::Reference
<
473 css::beans::XVetoableChangeListener
>& aListener
) override
;
476 virtual OUString SAL_CALL
getImplementationName() override
;
477 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
478 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
481 class ScDatabaseRangesObj
: public cppu::WeakImplHelper
<
482 css::sheet::XDatabaseRanges
,
483 css::container::XEnumerationAccess
,
484 css::container::XIndexAccess
,
485 css::lang::XServiceInfo
>,
489 ScDocShell
* pDocShell
;
491 ScDatabaseRangeObj
* GetObjectByIndex_Impl(size_t nIndex
);
492 ScDatabaseRangeObj
* GetObjectByName_Impl(const OUString
& aName
);
495 ScDatabaseRangesObj(ScDocShell
* pDocSh
);
496 virtual ~ScDatabaseRangesObj() override
;
498 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
501 virtual void SAL_CALL
addNewByName( const OUString
& aName
,
502 const css::table::CellRangeAddress
& aRange
) override
;
503 virtual void SAL_CALL
removeByName( const OUString
& aName
) override
;
505 // XEnumerationAccess
506 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
507 createEnumeration() override
;
510 virtual sal_Int32 SAL_CALL
getCount() override
;
511 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) override
;
514 virtual css::uno::Type SAL_CALL
getElementType() override
;
515 virtual sal_Bool SAL_CALL
hasElements() override
;
518 virtual css::uno::Any SAL_CALL
getByName( const OUString
& aName
) override
;
519 virtual css::uno::Sequence
< OUString
> SAL_CALL
getElementNames() override
;
520 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
;
523 virtual OUString SAL_CALL
getImplementationName() override
;
524 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
525 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
528 class ScUnnamedDatabaseRangesObj
: public cppu::WeakImplHelper
<
529 css::sheet::XUnnamedDatabaseRanges
>,
533 ScDocShell
* pDocShell
;
536 ScUnnamedDatabaseRangesObj(ScDocShell
* pDocSh
);
537 virtual ~ScUnnamedDatabaseRangesObj() override
;
539 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
541 // XUnnamedDatabaseRanges
542 virtual void SAL_CALL
setByTable( const css::table::CellRangeAddress
& aRange
) override
;
543 virtual css::uno::Any SAL_CALL
getByTable( sal_Int32 nTab
) override
;
544 virtual sal_Bool SAL_CALL
hasByTable( sal_Int32 nTab
) override
;
549 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */