Bump version to 6.4-15
[LibreOffice.git] / sc / inc / datauno.hxx
blob14c06d4b48488dc43f0483bb65f5ba35db598825
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SC_INC_DATAUNO_HXX
21 #define INCLUDED_SC_INC_DATAUNO_HXX
23 #include "global.hxx"
24 #include "queryparam.hxx"
25 #include "subtotalparam.hxx"
27 #include <com/sun/star/sheet/GeneralFunction.hpp>
28 #include <com/sun/star/sheet/XCellRangeReferrer.hpp>
29 #include <com/sun/star/sheet/XSheetFilterDescriptor.hpp>
30 #include <com/sun/star/sheet/XSheetFilterDescriptor2.hpp>
31 #include <com/sun/star/sheet/XSheetFilterDescriptor3.hpp>
32 #include <com/sun/star/sheet/XConsolidationDescriptor.hpp>
33 #include <com/sun/star/sheet/XDatabaseRanges.hpp>
34 #include <com/sun/star/sheet/XDatabaseRange.hpp>
35 #include <com/sun/star/sheet/XUnnamedDatabaseRanges.hpp>
36 #include <com/sun/star/sheet/XSubTotalDescriptor.hpp>
37 #include <com/sun/star/sheet/XSubTotalField.hpp>
38 #include <com/sun/star/lang/XServiceInfo.hpp>
39 #include <com/sun/star/container/XEnumerationAccess.hpp>
40 #include <com/sun/star/container/XIndexAccess.hpp>
41 #include <com/sun/star/beans/XPropertySet.hpp>
42 #include <com/sun/star/lang/XUnoTunnel.hpp>
43 #include <com/sun/star/container/XNamed.hpp>
44 #include <com/sun/star/util/XRefreshable.hpp>
45 #include <comphelper/servicehelper.hxx>
46 #include <cppuhelper/implbase.hxx>
47 #include <rtl/ref.hxx>
48 #include <svl/itemprop.hxx>
49 #include <svl/lstner.hxx>
51 #include <vector>
53 namespace com { namespace sun { namespace star { namespace sheet { struct TableFilterField2; } } } }
54 namespace com { namespace sun { namespace star { namespace sheet { struct TableFilterField3; } } } }
55 namespace com { namespace sun { namespace star { namespace sheet { struct TableFilterField; } } } }
57 class ScDBData;
58 class ScDocShell;
60 class ScSubTotalFieldObj;
61 class ScDatabaseRangeObj;
62 class ScDataPilotDescriptorBase;
64 struct ScSortParam;
66 class ScDataUnoConversion
68 public:
69 static css::sheet::GeneralFunction SubTotalToGeneral( ScSubTotalFunc eSubTotal );
72 // ImportDescriptor is not available as Uno-object any longer, only Property-Sequence
74 class ScImportDescriptor
76 public:
77 static void FillImportParam(
78 ScImportParam& rParam,
79 const css::uno::Sequence<css::beans::PropertyValue>& rSeq );
80 static void FillProperties(
81 css::uno::Sequence<css::beans::PropertyValue>& rSeq,
82 const ScImportParam& rParam );
83 static long GetPropertyCount() { return 4; }
86 // SortDescriptor is not available as Uno-object any longer, only Property-Sequence
88 class ScSortDescriptor
90 public:
91 static void FillSortParam(
92 ScSortParam& rParam,
93 const css::uno::Sequence<css::beans::PropertyValue>& rSeq );
94 static void FillProperties(
95 css::uno::Sequence<css::beans::PropertyValue>& rSeq,
96 const ScSortParam& rParam );
97 //! SortAscending needs to get out of the SheetSortDescriptor service description
98 static long GetPropertyCount()
100 return 9; // TableSortDescriptor and SheetSortDescriptor
105 // ScSubTotalDescriptorBase - base class for SubTotalDescriptor stand alone and in DB area (context?)
107 // to uno, both look the same
109 class ScSubTotalDescriptorBase : public cppu::WeakImplHelper<
110 css::sheet::XSubTotalDescriptor,
111 css::container::XEnumerationAccess,
112 css::container::XIndexAccess,
113 css::beans::XPropertySet,
114 css::lang::XUnoTunnel,
115 css::lang::XServiceInfo >
117 private:
118 SfxItemPropertySet const aPropSet;
120 ScSubTotalFieldObj* GetObjectByIndex_Impl(sal_uInt16 nIndex);
122 public:
123 ScSubTotalDescriptorBase();
124 virtual ~ScSubTotalDescriptorBase() override;
126 // in derived classes:
127 // (Fields are within the range)
128 virtual void GetData( ScSubTotalParam& rParam ) const = 0;
129 virtual void PutData( const ScSubTotalParam& rParam ) = 0;
131 // XSubTotalDescriptor
132 virtual void SAL_CALL addNew( const css::uno::Sequence< css::sheet::SubTotalColumn >& aSubTotalColumns,
133 sal_Int32 nGroupColumn ) override;
134 virtual void SAL_CALL clear() override;
136 // XIndexAccess
137 virtual sal_Int32 SAL_CALL getCount() override;
138 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
140 // XEnumerationAccess
141 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
142 createEnumeration() override;
144 // XElementAccess
145 virtual css::uno::Type SAL_CALL getElementType() override;
146 virtual sal_Bool SAL_CALL hasElements() override;
148 // XPropertySet
149 virtual css::uno::Reference< css::beans::XPropertySetInfo >
150 SAL_CALL getPropertySetInfo() override;
151 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
152 const css::uno::Any& aValue ) override;
153 virtual css::uno::Any SAL_CALL getPropertyValue(
154 const OUString& PropertyName ) override;
155 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
156 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
157 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
158 const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
159 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
160 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
161 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
162 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
164 // XUnoTunnel
165 UNO3_GETIMPLEMENTATION_DECL(ScSubTotalDescriptorBase)
167 // XServiceInfo
168 virtual OUString SAL_CALL getImplementationName() override;
169 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
170 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
173 // ScSubTotalDescriptor - dummy container to use with XImportTarget
175 class ScSubTotalDescriptor final : public ScSubTotalDescriptorBase
177 private:
178 ScSubTotalParam aStoredParam;
180 public:
181 ScSubTotalDescriptor();
182 virtual ~ScSubTotalDescriptor() override;
184 // from ScSubTotalDescriptorBase:
185 virtual void GetData( ScSubTotalParam& rParam ) const override;
186 virtual void PutData( const ScSubTotalParam& rParam ) override;
188 // external access:
189 void SetParam( const ScSubTotalParam& rNew );
192 // ScRangeSubTotalDescriptor - SubTotalDescriptor of a data base area
194 class ScRangeSubTotalDescriptor final : public ScSubTotalDescriptorBase
196 private:
197 rtl::Reference<ScDatabaseRangeObj> mxParent;
199 public:
200 ScRangeSubTotalDescriptor(ScDatabaseRangeObj* pPar);
201 virtual ~ScRangeSubTotalDescriptor() override;
203 // from ScSubTotalDescriptorBase:
204 virtual void GetData( ScSubTotalParam& rParam ) const override;
205 virtual void PutData( const ScSubTotalParam& rParam ) override;
208 class ScSubTotalFieldObj : public cppu::WeakImplHelper<
209 css::sheet::XSubTotalField,
210 css::lang::XServiceInfo >
212 private:
213 rtl::Reference<ScSubTotalDescriptorBase> xParent;
214 sal_uInt16 nPos;
216 public:
217 ScSubTotalFieldObj( ScSubTotalDescriptorBase* pDesc, sal_uInt16 nP );
218 virtual ~ScSubTotalFieldObj() override;
220 // XSubTotalField
221 virtual sal_Int32 SAL_CALL getGroupColumn() override;
222 virtual void SAL_CALL setGroupColumn( sal_Int32 nGroupColumn ) override;
223 virtual css::uno::Sequence< css::sheet::SubTotalColumn > SAL_CALL
224 getSubTotalColumns() override;
225 virtual void SAL_CALL setSubTotalColumns( const css::uno::Sequence<
226 css::sheet::SubTotalColumn >& aSubTotalColumns ) override;
228 // XServiceInfo
229 virtual OUString SAL_CALL getImplementationName() override;
230 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
231 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
234 class ScConsolidationDescriptor final : public cppu::WeakImplHelper<
235 css::sheet::XConsolidationDescriptor,
236 css::lang::XServiceInfo >
238 private:
239 ScConsolidateParam aParam;
241 public:
242 ScConsolidationDescriptor();
243 virtual ~ScConsolidationDescriptor() override;
245 void SetParam( const ScConsolidateParam& rNew );
246 const ScConsolidateParam& GetParam() const { return aParam; }
248 // XConsolidationDescriptor
249 virtual css::sheet::GeneralFunction SAL_CALL getFunction() override;
250 virtual void SAL_CALL setFunction( css::sheet::GeneralFunction nFunction ) override;
251 virtual css::uno::Sequence< css::table::CellRangeAddress > SAL_CALL
252 getSources( ) override;
253 virtual void SAL_CALL setSources( const css::uno::Sequence< css::table::CellRangeAddress >& aSources ) override;
254 virtual css::table::CellAddress SAL_CALL getStartOutputPosition() override;
255 virtual void SAL_CALL setStartOutputPosition(
256 const css::table::CellAddress& aStartOutputPosition ) override;
257 virtual sal_Bool SAL_CALL getUseColumnHeaders() override;
258 virtual void SAL_CALL setUseColumnHeaders( sal_Bool bUseColumnHeaders ) override;
259 virtual sal_Bool SAL_CALL getUseRowHeaders() override;
260 virtual void SAL_CALL setUseRowHeaders( sal_Bool bUseRowHeaders ) override;
261 virtual sal_Bool SAL_CALL getInsertLinks() override;
262 virtual void SAL_CALL setInsertLinks( sal_Bool bInsertLinks ) override;
264 // XServiceInfo
265 virtual OUString SAL_CALL getImplementationName() override;
266 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
267 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
270 // ScFilterDescriptorBase - base class for FilterDescriptor
271 // stand alone, in a DB area (or context?) and in the DataPilot
273 // to uno, all three look the same
275 class ScFilterDescriptorBase : public cppu::WeakImplHelper<
276 css::sheet::XSheetFilterDescriptor,
277 css::sheet::XSheetFilterDescriptor2,
278 css::sheet::XSheetFilterDescriptor3,
279 css::beans::XPropertySet,
280 css::lang::XServiceInfo >,
281 public SfxListener
283 private:
284 SfxItemPropertySet const aPropSet;
285 ScDocShell* pDocSh;
287 public:
288 ScFilterDescriptorBase(ScDocShell* pDocShell);
289 virtual ~ScFilterDescriptorBase() override;
291 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
293 // in the derived classes(?):
294 // (nField[] here within the area)
295 virtual void GetData( ScQueryParam& rParam ) const = 0;
296 virtual void PutData( const ScQueryParam& rParam ) = 0;
298 // XSheetFilterDescriptor
299 virtual css::uno::Sequence< css::sheet::TableFilterField > SAL_CALL
300 getFilterFields() override;
301 virtual void SAL_CALL setFilterFields( const css::uno::Sequence<
302 css::sheet::TableFilterField >& aFilterFields ) override;
304 // XSheetFilterDescriptor2
305 virtual css::uno::Sequence< css::sheet::TableFilterField2 > SAL_CALL
306 getFilterFields2() override;
307 virtual void SAL_CALL setFilterFields2( const css::uno::Sequence<
308 css::sheet::TableFilterField2 >& aFilterFields ) override;
310 // XSheetFilterDescriptor3
311 virtual css::uno::Sequence< css::sheet::TableFilterField3 > SAL_CALL
312 getFilterFields3() override;
313 virtual void SAL_CALL setFilterFields3( const css::uno::Sequence<
314 css::sheet::TableFilterField3 >& aFilterFields ) override;
316 // XPropertySet
317 virtual css::uno::Reference< css::beans::XPropertySetInfo >
318 SAL_CALL getPropertySetInfo() override;
319 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
320 const css::uno::Any& aValue ) override;
321 virtual css::uno::Any SAL_CALL getPropertyValue(
322 const OUString& PropertyName ) override;
323 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
324 const css::uno::Reference<
325 css::beans::XPropertyChangeListener >& xListener ) override;
326 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
327 const css::uno::Reference<
328 css::beans::XPropertyChangeListener >& aListener ) override;
329 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
330 const css::uno::Reference<
331 css::beans::XVetoableChangeListener >& aListener ) override;
332 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
333 const css::uno::Reference<
334 css::beans::XVetoableChangeListener >& aListener ) override;
336 // XServiceInfo
337 virtual OUString SAL_CALL getImplementationName() override;
338 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
339 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
342 // ScFilterDescriptor - dummy container to use with XFilterable
344 class ScFilterDescriptor final : public ScFilterDescriptorBase
346 private:
347 ScQueryParam aStoredParam; // nField[] here within the area
349 public:
350 ScFilterDescriptor(ScDocShell* pDocSh);
351 virtual ~ScFilterDescriptor() override;
353 // from ScFilterDescriptorBase:
354 virtual void GetData( ScQueryParam& rParam ) const override;
355 virtual void PutData( const ScQueryParam& rParam ) override;
357 // external access:
358 void SetParam( const ScQueryParam& rNew );
359 const ScQueryParam& GetParam() const { return aStoredParam; }
362 // ScRangeFilterDescriptor - FilterDescriptor of a data base area
364 class ScRangeFilterDescriptor final : public ScFilterDescriptorBase
366 private:
367 rtl::Reference<ScDatabaseRangeObj> mxParent;
369 public:
370 ScRangeFilterDescriptor(ScDocShell* pDocSh, ScDatabaseRangeObj* pPar);
371 virtual ~ScRangeFilterDescriptor() override;
373 // from ScFilterDescriptorBase:
374 virtual void GetData( ScQueryParam& rParam ) const override;
375 virtual void PutData( const ScQueryParam& rParam ) override;
378 // ScDataPilotFilterDescriptor - FilterDescriptor of a DataPilotDescriptors
380 class ScDataPilotFilterDescriptor final : public ScFilterDescriptorBase
382 private:
383 rtl::Reference<ScDataPilotDescriptorBase> mxParent;
385 public:
386 ScDataPilotFilterDescriptor(ScDocShell* pDocSh, ScDataPilotDescriptorBase* pPar);
387 virtual ~ScDataPilotFilterDescriptor() override;
389 // from ScFilterDescriptorBase:
390 virtual void GetData( ScQueryParam& rParam ) const override;
391 virtual void PutData( const ScQueryParam& rParam ) override;
394 class ScDatabaseRangeObj : public cppu::WeakImplHelper<
395 css::sheet::XDatabaseRange,
396 css::util::XRefreshable,
397 css::container::XNamed,
398 css::sheet::XCellRangeReferrer,
399 css::beans::XPropertySet,
400 css::lang::XServiceInfo >,
401 public SfxListener
403 private:
404 ScDocShell* pDocShell;
405 OUString aName;
406 SfxItemPropertySet const aPropSet;
407 std::vector< css::uno::Reference< css::util::XRefreshListener > >
408 aRefreshListeners;
409 bool const bIsUnnamed;
410 SCTAB const aTab;
412 private:
413 ScDBData* GetDBData_Impl() const;
414 void Refreshed_Impl();
416 public:
417 ScDatabaseRangeObj(ScDocShell* pDocSh, const OUString& rNm);
418 SC_DLLPUBLIC ScDatabaseRangeObj(ScDocShell* pDocSh, const SCTAB nTab);
419 virtual ~ScDatabaseRangeObj() override;
421 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
423 // nField[] here within the area:
424 void GetQueryParam(ScQueryParam& rQueryParam) const;
425 void SetQueryParam(const ScQueryParam& rQueryParam);
426 void GetSubTotalParam(ScSubTotalParam& rSubTotalParam) const;
427 void SetSubTotalParam(const ScSubTotalParam& rSubTotalParam);
429 // XNamed
430 virtual OUString SAL_CALL getName() override;
431 virtual void SAL_CALL setName( const OUString& aName ) override;
433 // XDatabaseRange
434 virtual css::table::CellRangeAddress SAL_CALL getDataArea() override;
435 virtual void SAL_CALL setDataArea( const css::table::CellRangeAddress& aDataArea ) override;
436 virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL
437 getSortDescriptor() override;
438 virtual css::uno::Reference< css::sheet::XSheetFilterDescriptor > SAL_CALL
439 getFilterDescriptor() override;
440 virtual css::uno::Reference< css::sheet::XSubTotalDescriptor > SAL_CALL
441 getSubTotalDescriptor() override;
442 virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL
443 getImportDescriptor() override;
445 // XRefreshable
446 virtual void SAL_CALL refresh() override;
447 virtual void SAL_CALL addRefreshListener( const css::uno::Reference<
448 css::util::XRefreshListener >& l ) override;
449 virtual void SAL_CALL removeRefreshListener( const css::uno::Reference<
450 css::util::XRefreshListener >& l ) override;
452 // XCellRangeReferrer
453 virtual css::uno::Reference< css::table::XCellRange > SAL_CALL
454 getReferredCells() override;
456 // XPropertySet
457 virtual css::uno::Reference< css::beans::XPropertySetInfo >
458 SAL_CALL getPropertySetInfo() override;
459 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
460 const css::uno::Any& aValue ) override;
461 virtual css::uno::Any SAL_CALL getPropertyValue(
462 const OUString& PropertyName ) override;
463 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
464 const css::uno::Reference<
465 css::beans::XPropertyChangeListener >& xListener ) override;
466 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
467 const css::uno::Reference<
468 css::beans::XPropertyChangeListener >& aListener ) override;
469 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
470 const css::uno::Reference<
471 css::beans::XVetoableChangeListener >& aListener ) override;
472 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
473 const css::uno::Reference<
474 css::beans::XVetoableChangeListener >& aListener ) override;
476 // XServiceInfo
477 virtual OUString SAL_CALL getImplementationName() override;
478 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
479 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
482 class ScDatabaseRangesObj final : public cppu::WeakImplHelper<
483 css::sheet::XDatabaseRanges,
484 css::container::XEnumerationAccess,
485 css::container::XIndexAccess,
486 css::lang::XServiceInfo >,
487 public SfxListener
489 private:
490 ScDocShell* pDocShell;
492 ScDatabaseRangeObj* GetObjectByIndex_Impl(size_t nIndex);
493 ScDatabaseRangeObj* GetObjectByName_Impl(const OUString& aName);
495 public:
496 ScDatabaseRangesObj(ScDocShell* pDocSh);
497 virtual ~ScDatabaseRangesObj() override;
499 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
501 // XDatabaseRanges
502 virtual void SAL_CALL addNewByName( const OUString& aName,
503 const css::table::CellRangeAddress& aRange ) override;
504 virtual void SAL_CALL removeByName( const OUString& aName ) override;
506 // XEnumerationAccess
507 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
508 createEnumeration() override;
510 // XIndexAccess
511 virtual sal_Int32 SAL_CALL getCount() override;
512 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
514 // XElementAccess
515 virtual css::uno::Type SAL_CALL getElementType() override;
516 virtual sal_Bool SAL_CALL hasElements() override;
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;
523 // XServiceInfo
524 virtual OUString SAL_CALL getImplementationName() override;
525 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
526 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
529 class ScUnnamedDatabaseRangesObj final : public cppu::WeakImplHelper<
530 css::sheet::XUnnamedDatabaseRanges>,
531 public SfxListener
533 private:
534 ScDocShell* pDocShell;
536 public:
537 ScUnnamedDatabaseRangesObj(ScDocShell* pDocSh);
538 virtual ~ScUnnamedDatabaseRangesObj() override;
540 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
542 // XUnnamedDatabaseRanges
543 virtual void SAL_CALL setByTable( const css::table::CellRangeAddress& aRange ) override;
544 virtual css::uno::Any SAL_CALL getByTable( sal_Int32 nTab ) override;
545 virtual sal_Bool SAL_CALL hasByTable( sal_Int32 nTab ) override;
548 #endif
550 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */