tdf#48459 sw inline heading: don't apply inside frames or over 120 chars
[LibreOffice.git] / sc / inc / datauno.hxx
blob9159e0af1718a53998b0120c5ea33e193c218e30
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 #pragma once
22 #include "global.hxx"
23 #include "queryparam.hxx"
24 #include "subtotalparam.hxx"
26 #include <com/sun/star/sheet/GeneralFunction.hpp>
27 #include <com/sun/star/sheet/XCellRangeReferrer.hpp>
28 #include <com/sun/star/sheet/XSheetFilterDescriptor.hpp>
29 #include <com/sun/star/sheet/XSheetFilterDescriptor2.hpp>
30 #include <com/sun/star/sheet/XSheetFilterDescriptor3.hpp>
31 #include <com/sun/star/sheet/XConsolidationDescriptor.hpp>
32 #include <com/sun/star/sheet/XDatabaseRanges.hpp>
33 #include <com/sun/star/sheet/XDatabaseRange.hpp>
34 #include <com/sun/star/sheet/XUnnamedDatabaseRanges.hpp>
35 #include <com/sun/star/sheet/XSubTotalDescriptor.hpp>
36 #include <com/sun/star/sheet/XSubTotalField.hpp>
37 #include <com/sun/star/lang/XServiceInfo.hpp>
38 #include <com/sun/star/container/XEnumerationAccess.hpp>
39 #include <com/sun/star/container/XIndexAccess.hpp>
40 #include <com/sun/star/beans/XPropertySet.hpp>
41 #include <com/sun/star/container/XNamed.hpp>
42 #include <com/sun/star/util/XRefreshable.hpp>
43 #include <cppuhelper/implbase.hxx>
44 #include <rtl/ref.hxx>
45 #include <svl/itemprop.hxx>
46 #include <svl/lstner.hxx>
48 #include <vector>
50 namespace com::sun::star::sheet { struct TableFilterField2; }
51 namespace com::sun::star::sheet { struct TableFilterField3; }
52 namespace com::sun::star::sheet { struct TableFilterField; }
54 class ScDBData;
55 class ScDocShell;
57 class ScSubTotalFieldObj;
58 class ScDatabaseRangeObj;
59 class ScDataPilotDescriptorBase;
61 struct ScSortParam;
63 class ScDataUnoConversion
65 public:
66 static css::sheet::GeneralFunction SubTotalToGeneral( ScSubTotalFunc eSubTotal );
69 // ImportDescriptor is not available as Uno-object any longer, only Property-Sequence
71 class ScImportDescriptor
73 public:
74 static void FillImportParam(
75 ScImportParam& rParam,
76 const css::uno::Sequence<css::beans::PropertyValue>& rSeq );
77 static void FillProperties(
78 css::uno::Sequence<css::beans::PropertyValue>& rSeq,
79 const ScImportParam& rParam );
80 static tools::Long GetPropertyCount() { return 4; }
83 // SortDescriptor is not available as Uno-object any longer, only Property-Sequence
85 class ScSortDescriptor
87 public:
88 static void FillSortParam(
89 ScSortParam& rParam,
90 const css::uno::Sequence<css::beans::PropertyValue>& rSeq );
91 static void FillProperties(
92 css::uno::Sequence<css::beans::PropertyValue>& rSeq,
93 const ScSortParam& rParam );
94 //! SortAscending needs to get out of the SheetSortDescriptor service description
95 static tools::Long GetPropertyCount()
97 return 9; // TableSortDescriptor and SheetSortDescriptor
102 // ScSubTotalDescriptorBase - base class for SubTotalDescriptor stand alone and in DB area (context?)
104 // to uno, both look the same
106 class ScSubTotalDescriptorBase : public cppu::WeakImplHelper<
107 css::sheet::XSubTotalDescriptor,
108 css::container::XEnumerationAccess,
109 css::container::XIndexAccess,
110 css::beans::XPropertySet,
111 css::lang::XServiceInfo >
113 private:
114 SfxItemPropertySet aPropSet;
116 rtl::Reference<ScSubTotalFieldObj> GetObjectByIndex_Impl(sal_uInt16 nIndex);
118 public:
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;
132 // XIndexAccess
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;
140 // XElementAccess
141 virtual css::uno::Type SAL_CALL getElementType() override;
142 virtual sal_Bool SAL_CALL hasElements() override;
144 // XPropertySet
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;
160 // XServiceInfo
161 virtual OUString SAL_CALL getImplementationName() override;
162 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
163 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
166 // ScSubTotalDescriptor - dummy container to use with XImportTarget
168 class ScSubTotalDescriptor final : public ScSubTotalDescriptorBase
170 private:
171 ScSubTotalParam aStoredParam;
173 public:
174 ScSubTotalDescriptor();
175 virtual ~ScSubTotalDescriptor() override;
177 // from ScSubTotalDescriptorBase:
178 virtual void GetData( ScSubTotalParam& rParam ) const override;
179 virtual void PutData( const ScSubTotalParam& rParam ) override;
181 // external access:
182 void SetParam( const ScSubTotalParam& rNew );
185 // ScRangeSubTotalDescriptor - SubTotalDescriptor of a data base area
187 class ScRangeSubTotalDescriptor final : public ScSubTotalDescriptorBase
189 private:
190 rtl::Reference<ScDatabaseRangeObj> mxParent;
192 public:
193 ScRangeSubTotalDescriptor(ScDatabaseRangeObj* pPar);
194 virtual ~ScRangeSubTotalDescriptor() override;
196 // from ScSubTotalDescriptorBase:
197 virtual void GetData( ScSubTotalParam& rParam ) const override;
198 virtual void PutData( const ScSubTotalParam& rParam ) override;
201 class ScSubTotalFieldObj final : public cppu::WeakImplHelper<
202 css::sheet::XSubTotalField,
203 css::lang::XServiceInfo >
205 private:
206 rtl::Reference<ScSubTotalDescriptorBase> xParent;
207 sal_uInt16 nPos;
209 public:
210 ScSubTotalFieldObj( ScSubTotalDescriptorBase* pDesc, sal_uInt16 nP );
211 virtual ~ScSubTotalFieldObj() override;
213 // XSubTotalField
214 virtual sal_Int32 SAL_CALL getGroupColumn() override;
215 virtual void SAL_CALL setGroupColumn( sal_Int32 nGroupColumn ) override;
216 virtual css::uno::Sequence< css::sheet::SubTotalColumn > SAL_CALL
217 getSubTotalColumns() override;
218 virtual void SAL_CALL setSubTotalColumns( const css::uno::Sequence<
219 css::sheet::SubTotalColumn >& aSubTotalColumns ) override;
221 // XServiceInfo
222 virtual OUString SAL_CALL getImplementationName() override;
223 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
224 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
227 class ScConsolidationDescriptor final : public cppu::WeakImplHelper<
228 css::sheet::XConsolidationDescriptor,
229 css::lang::XServiceInfo >
231 private:
232 ScConsolidateParam aParam;
234 public:
235 ScConsolidationDescriptor();
236 virtual ~ScConsolidationDescriptor() override;
238 void SetParam( const ScConsolidateParam& rNew );
239 const ScConsolidateParam& GetParam() const { return aParam; }
241 // XConsolidationDescriptor
242 virtual css::sheet::GeneralFunction SAL_CALL getFunction() override;
243 virtual void SAL_CALL setFunction( css::sheet::GeneralFunction nFunction ) override;
244 virtual css::uno::Sequence< css::table::CellRangeAddress > SAL_CALL
245 getSources( ) override;
246 virtual void SAL_CALL setSources( const css::uno::Sequence< css::table::CellRangeAddress >& aSources ) override;
247 virtual css::table::CellAddress SAL_CALL getStartOutputPosition() override;
248 virtual void SAL_CALL setStartOutputPosition(
249 const css::table::CellAddress& aStartOutputPosition ) override;
250 virtual sal_Bool SAL_CALL getUseColumnHeaders() override;
251 virtual void SAL_CALL setUseColumnHeaders( sal_Bool bUseColumnHeaders ) override;
252 virtual sal_Bool SAL_CALL getUseRowHeaders() override;
253 virtual void SAL_CALL setUseRowHeaders( sal_Bool bUseRowHeaders ) override;
254 virtual sal_Bool SAL_CALL getInsertLinks() override;
255 virtual void SAL_CALL setInsertLinks( sal_Bool bInsertLinks ) override;
257 // XServiceInfo
258 virtual OUString SAL_CALL getImplementationName() override;
259 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
260 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
263 // ScFilterDescriptorBase - base class for FilterDescriptor
264 // stand alone, in a DB area (or context?) and in the DataPilot
266 // to uno, all three look the same
268 class ScFilterDescriptorBase : public cppu::WeakImplHelper<
269 css::sheet::XSheetFilterDescriptor,
270 css::sheet::XSheetFilterDescriptor2,
271 css::sheet::XSheetFilterDescriptor3,
272 css::beans::XPropertySet,
273 css::lang::XServiceInfo >,
274 public SfxListener
276 private:
277 SfxItemPropertySet aPropSet;
278 ScDocShell* pDocSh;
280 public:
281 ScFilterDescriptorBase(ScDocShell* pDocShell);
282 virtual ~ScFilterDescriptorBase() override;
284 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
286 // in the derived classes(?):
287 // (nField[] here within the area)
288 virtual void GetData( ScQueryParam& rParam ) const = 0;
289 virtual void PutData( const ScQueryParam& rParam ) = 0;
291 // XSheetFilterDescriptor
292 virtual css::uno::Sequence< css::sheet::TableFilterField > SAL_CALL
293 getFilterFields() override;
294 virtual void SAL_CALL setFilterFields( const css::uno::Sequence<
295 css::sheet::TableFilterField >& aFilterFields ) override;
297 // XSheetFilterDescriptor2
298 virtual css::uno::Sequence< css::sheet::TableFilterField2 > SAL_CALL
299 getFilterFields2() override;
300 virtual void SAL_CALL setFilterFields2( const css::uno::Sequence<
301 css::sheet::TableFilterField2 >& aFilterFields ) override;
303 // XSheetFilterDescriptor3
304 virtual css::uno::Sequence< css::sheet::TableFilterField3 > SAL_CALL
305 getFilterFields3() override;
306 virtual void SAL_CALL setFilterFields3( const css::uno::Sequence<
307 css::sheet::TableFilterField3 >& aFilterFields ) override;
309 // XPropertySet
310 virtual css::uno::Reference< css::beans::XPropertySetInfo >
311 SAL_CALL getPropertySetInfo() override;
312 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
313 const css::uno::Any& aValue ) override;
314 virtual css::uno::Any SAL_CALL getPropertyValue(
315 const OUString& PropertyName ) override;
316 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
317 const css::uno::Reference<
318 css::beans::XPropertyChangeListener >& xListener ) override;
319 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
320 const css::uno::Reference<
321 css::beans::XPropertyChangeListener >& aListener ) override;
322 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
323 const css::uno::Reference<
324 css::beans::XVetoableChangeListener >& aListener ) override;
325 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
326 const css::uno::Reference<
327 css::beans::XVetoableChangeListener >& aListener ) override;
329 // XServiceInfo
330 virtual OUString SAL_CALL getImplementationName() override;
331 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
332 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
335 // ScFilterDescriptor - dummy container to use with XFilterable
337 class ScFilterDescriptor final : public ScFilterDescriptorBase
339 private:
340 ScQueryParam aStoredParam; // nField[] here within the area
342 public:
343 ScFilterDescriptor(ScDocShell* pDocSh);
344 virtual ~ScFilterDescriptor() override;
346 // from ScFilterDescriptorBase:
347 virtual void GetData( ScQueryParam& rParam ) const override;
348 virtual void PutData( const ScQueryParam& rParam ) override;
350 // external access:
351 void SetParam( const ScQueryParam& rNew );
352 const ScQueryParam& GetParam() const { return aStoredParam; }
355 // ScRangeFilterDescriptor - FilterDescriptor of a data base area
357 class ScRangeFilterDescriptor final : public ScFilterDescriptorBase
359 private:
360 rtl::Reference<ScDatabaseRangeObj> mxParent;
362 public:
363 ScRangeFilterDescriptor(ScDocShell* pDocSh, ScDatabaseRangeObj* pPar);
364 virtual ~ScRangeFilterDescriptor() override;
366 // from ScFilterDescriptorBase:
367 virtual void GetData( ScQueryParam& rParam ) const override;
368 virtual void PutData( const ScQueryParam& rParam ) override;
371 // ScDataPilotFilterDescriptor - FilterDescriptor of a DataPilotDescriptors
373 class ScDataPilotFilterDescriptor final : public ScFilterDescriptorBase
375 private:
376 rtl::Reference<ScDataPilotDescriptorBase> mxParent;
378 public:
379 ScDataPilotFilterDescriptor(ScDocShell* pDocSh, ScDataPilotDescriptorBase* pPar);
380 virtual ~ScDataPilotFilterDescriptor() override;
382 // from ScFilterDescriptorBase:
383 virtual void GetData( ScQueryParam& rParam ) const override;
384 virtual void PutData( const ScQueryParam& rParam ) override;
387 class ScDatabaseRangeObj final : public cppu::WeakImplHelper<
388 css::sheet::XDatabaseRange,
389 css::util::XRefreshable,
390 css::container::XNamed,
391 css::sheet::XCellRangeReferrer,
392 css::beans::XPropertySet,
393 css::lang::XServiceInfo >,
394 public SfxListener
396 private:
397 ScDocShell* pDocShell;
398 OUString aName;
399 SfxItemPropertySet aPropSet;
400 std::vector< css::uno::Reference< css::util::XRefreshListener > >
401 aRefreshListeners;
402 bool bIsUnnamed;
403 SCTAB aTab;
405 private:
406 ScDBData* GetDBData_Impl() const;
407 void Refreshed_Impl();
409 public:
410 ScDatabaseRangeObj(ScDocShell* pDocSh, OUString aNm);
411 SC_DLLPUBLIC ScDatabaseRangeObj(ScDocShell* pDocSh, const SCTAB nTab);
412 virtual ~ScDatabaseRangeObj() override;
414 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
416 // nField[] here within the area:
417 void GetQueryParam(ScQueryParam& rQueryParam) const;
418 void SetQueryParam(const ScQueryParam& rQueryParam);
419 void GetSubTotalParam(ScSubTotalParam& rSubTotalParam) const;
420 void SetSubTotalParam(const ScSubTotalParam& rSubTotalParam);
422 // XNamed
423 virtual OUString SAL_CALL getName() override;
424 virtual void SAL_CALL setName( const OUString& aName ) override;
426 // XDatabaseRange
427 virtual css::table::CellRangeAddress SAL_CALL getDataArea() override;
428 virtual void SAL_CALL setDataArea( const css::table::CellRangeAddress& aDataArea ) override;
429 virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL
430 getSortDescriptor() override;
431 virtual css::uno::Reference< css::sheet::XSheetFilterDescriptor > SAL_CALL
432 getFilterDescriptor() override;
433 virtual css::uno::Reference< css::sheet::XSubTotalDescriptor > SAL_CALL
434 getSubTotalDescriptor() override;
435 virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL
436 getImportDescriptor() override;
438 // XRefreshable
439 virtual void SAL_CALL refresh() override;
440 virtual void SAL_CALL addRefreshListener( const css::uno::Reference<
441 css::util::XRefreshListener >& l ) override;
442 virtual void SAL_CALL removeRefreshListener( const css::uno::Reference<
443 css::util::XRefreshListener >& l ) override;
445 // XCellRangeReferrer
446 virtual css::uno::Reference< css::table::XCellRange > SAL_CALL
447 getReferredCells() override;
449 // XPropertySet
450 virtual css::uno::Reference< css::beans::XPropertySetInfo >
451 SAL_CALL getPropertySetInfo() override;
452 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
453 const css::uno::Any& aValue ) override;
454 virtual css::uno::Any SAL_CALL getPropertyValue(
455 const OUString& PropertyName ) override;
456 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
457 const css::uno::Reference<
458 css::beans::XPropertyChangeListener >& xListener ) override;
459 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
460 const css::uno::Reference<
461 css::beans::XPropertyChangeListener >& aListener ) override;
462 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
463 const css::uno::Reference<
464 css::beans::XVetoableChangeListener >& aListener ) override;
465 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
466 const css::uno::Reference<
467 css::beans::XVetoableChangeListener >& aListener ) override;
469 // XServiceInfo
470 virtual OUString SAL_CALL getImplementationName() override;
471 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
472 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
475 class ScDatabaseRangesObj final : public cppu::WeakImplHelper<
476 css::sheet::XDatabaseRanges,
477 css::container::XEnumerationAccess,
478 css::container::XIndexAccess,
479 css::lang::XServiceInfo >,
480 public SfxListener
482 private:
483 ScDocShell* pDocShell;
485 rtl::Reference<ScDatabaseRangeObj> GetObjectByIndex_Impl(size_t nIndex);
486 rtl::Reference<ScDatabaseRangeObj> GetObjectByName_Impl(const OUString& aName);
488 public:
489 ScDatabaseRangesObj(ScDocShell* pDocSh);
490 virtual ~ScDatabaseRangesObj() override;
492 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
494 // XDatabaseRanges
495 virtual void SAL_CALL addNewByName( const OUString& aName,
496 const css::table::CellRangeAddress& aRange ) override;
497 virtual void SAL_CALL removeByName( const OUString& aName ) override;
499 // XEnumerationAccess
500 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
501 createEnumeration() override;
503 // XIndexAccess
504 virtual sal_Int32 SAL_CALL getCount() override;
505 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
507 // XElementAccess
508 virtual css::uno::Type SAL_CALL getElementType() override;
509 virtual sal_Bool SAL_CALL hasElements() override;
511 // XNameAccess
512 virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
513 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
514 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
516 // XServiceInfo
517 virtual OUString SAL_CALL getImplementationName() override;
518 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
519 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
522 class ScUnnamedDatabaseRangesObj final : public cppu::WeakImplHelper<
523 css::sheet::XUnnamedDatabaseRanges>,
524 public SfxListener
526 private:
527 ScDocShell* pDocShell;
529 public:
530 ScUnnamedDatabaseRangesObj(ScDocShell* pDocSh);
531 virtual ~ScUnnamedDatabaseRangesObj() override;
533 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
535 // XUnnamedDatabaseRanges
536 virtual void SAL_CALL setByTable( const css::table::CellRangeAddress& aRange ) override;
537 virtual css::uno::Any SAL_CALL getByTable( sal_Int32 nTab ) override;
538 virtual sal_Bool SAL_CALL hasByTable( sal_Int32 nTab ) override;
541 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */