LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / sc / inc / datauno.hxx
blob0d692f51c61bd149feb3769d0c48f0af148bfbdf
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/lang/XUnoTunnel.hpp>
42 #include <com/sun/star/container/XNamed.hpp>
43 #include <com/sun/star/util/XRefreshable.hpp>
44 #include <comphelper/servicehelper.hxx>
45 #include <cppuhelper/implbase.hxx>
46 #include <rtl/ref.hxx>
47 #include <svl/itemprop.hxx>
48 #include <svl/lstner.hxx>
50 #include <vector>
52 namespace com::sun::star::sheet { struct TableFilterField2; }
53 namespace com::sun::star::sheet { struct TableFilterField3; }
54 namespace com::sun::star::sheet { struct TableFilterField; }
56 class ScDBData;
57 class ScDocShell;
59 class ScSubTotalFieldObj;
60 class ScDatabaseRangeObj;
61 class ScDataPilotDescriptorBase;
63 struct ScSortParam;
65 class ScDataUnoConversion
67 public:
68 static css::sheet::GeneralFunction SubTotalToGeneral( ScSubTotalFunc eSubTotal );
71 // ImportDescriptor is not available as Uno-object any longer, only Property-Sequence
73 class ScImportDescriptor
75 public:
76 static void FillImportParam(
77 ScImportParam& rParam,
78 const css::uno::Sequence<css::beans::PropertyValue>& rSeq );
79 static void FillProperties(
80 css::uno::Sequence<css::beans::PropertyValue>& rSeq,
81 const ScImportParam& rParam );
82 static tools::Long GetPropertyCount() { return 4; }
85 // SortDescriptor is not available as Uno-object any longer, only Property-Sequence
87 class ScSortDescriptor
89 public:
90 static void FillSortParam(
91 ScSortParam& rParam,
92 const css::uno::Sequence<css::beans::PropertyValue>& rSeq );
93 static void FillProperties(
94 css::uno::Sequence<css::beans::PropertyValue>& rSeq,
95 const ScSortParam& rParam );
96 //! SortAscending needs to get out of the SheetSortDescriptor service description
97 static tools::Long GetPropertyCount()
99 return 9; // TableSortDescriptor and SheetSortDescriptor
104 // ScSubTotalDescriptorBase - base class for SubTotalDescriptor stand alone and in DB area (context?)
106 // to uno, both look the same
108 class ScSubTotalDescriptorBase : public cppu::WeakImplHelper<
109 css::sheet::XSubTotalDescriptor,
110 css::container::XEnumerationAccess,
111 css::container::XIndexAccess,
112 css::beans::XPropertySet,
113 css::lang::XUnoTunnel,
114 css::lang::XServiceInfo >
116 private:
117 SfxItemPropertySet aPropSet;
119 rtl::Reference<ScSubTotalFieldObj> GetObjectByIndex_Impl(sal_uInt16 nIndex);
121 public:
122 ScSubTotalDescriptorBase();
123 virtual ~ScSubTotalDescriptorBase() override;
125 // in derived classes:
126 // (Fields are within the range)
127 virtual void GetData( ScSubTotalParam& rParam ) const = 0;
128 virtual void PutData( const ScSubTotalParam& rParam ) = 0;
130 // XSubTotalDescriptor
131 virtual void SAL_CALL addNew( const css::uno::Sequence< css::sheet::SubTotalColumn >& aSubTotalColumns,
132 sal_Int32 nGroupColumn ) override;
133 virtual void SAL_CALL clear() override;
135 // XIndexAccess
136 virtual sal_Int32 SAL_CALL getCount() override;
137 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
139 // XEnumerationAccess
140 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
141 createEnumeration() override;
143 // XElementAccess
144 virtual css::uno::Type SAL_CALL getElementType() override;
145 virtual sal_Bool SAL_CALL hasElements() override;
147 // XPropertySet
148 virtual css::uno::Reference< css::beans::XPropertySetInfo >
149 SAL_CALL getPropertySetInfo() override;
150 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
151 const css::uno::Any& aValue ) override;
152 virtual css::uno::Any SAL_CALL getPropertyValue(
153 const OUString& PropertyName ) override;
154 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
155 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
156 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
157 const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
158 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
159 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
160 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
161 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
163 // XUnoTunnel
164 UNO3_GETIMPLEMENTATION_DECL(ScSubTotalDescriptorBase)
166 // XServiceInfo
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 final : public ScSubTotalDescriptorBase
176 private:
177 ScSubTotalParam aStoredParam;
179 public:
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;
187 // external access:
188 void SetParam( const ScSubTotalParam& rNew );
191 // ScRangeSubTotalDescriptor - SubTotalDescriptor of a data base area
193 class ScRangeSubTotalDescriptor final : public ScSubTotalDescriptorBase
195 private:
196 rtl::Reference<ScDatabaseRangeObj> mxParent;
198 public:
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 final : public cppu::WeakImplHelper<
208 css::sheet::XSubTotalField,
209 css::lang::XServiceInfo >
211 private:
212 rtl::Reference<ScSubTotalDescriptorBase> xParent;
213 sal_uInt16 nPos;
215 public:
216 ScSubTotalFieldObj( ScSubTotalDescriptorBase* pDesc, sal_uInt16 nP );
217 virtual ~ScSubTotalFieldObj() override;
219 // XSubTotalField
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;
227 // XServiceInfo
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 final : public cppu::WeakImplHelper<
234 css::sheet::XConsolidationDescriptor,
235 css::lang::XServiceInfo >
237 private:
238 ScConsolidateParam aParam;
240 public:
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;
263 // XServiceInfo
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 >,
280 public SfxListener
282 private:
283 SfxItemPropertySet aPropSet;
284 ScDocShell* pDocSh;
286 public:
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;
315 // XPropertySet
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;
335 // XServiceInfo
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 final : public ScFilterDescriptorBase
345 private:
346 ScQueryParam aStoredParam; // nField[] here within the area
348 public:
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;
356 // external access:
357 void SetParam( const ScQueryParam& rNew );
358 const ScQueryParam& GetParam() const { return aStoredParam; }
361 // ScRangeFilterDescriptor - FilterDescriptor of a data base area
363 class ScRangeFilterDescriptor final : public ScFilterDescriptorBase
365 private:
366 rtl::Reference<ScDatabaseRangeObj> mxParent;
368 public:
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 final : public ScFilterDescriptorBase
381 private:
382 rtl::Reference<ScDataPilotDescriptorBase> mxParent;
384 public:
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 final : 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 >,
400 public SfxListener
402 private:
403 ScDocShell* pDocShell;
404 OUString aName;
405 SfxItemPropertySet aPropSet;
406 std::vector< css::uno::Reference< css::util::XRefreshListener > >
407 aRefreshListeners;
408 bool bIsUnnamed;
409 SCTAB aTab;
411 private:
412 ScDBData* GetDBData_Impl() const;
413 void Refreshed_Impl();
415 public:
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);
428 // XNamed
429 virtual OUString SAL_CALL getName() override;
430 virtual void SAL_CALL setName( const OUString& aName ) override;
432 // XDatabaseRange
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;
444 // XRefreshable
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;
455 // XPropertySet
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;
475 // XServiceInfo
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 final : public cppu::WeakImplHelper<
482 css::sheet::XDatabaseRanges,
483 css::container::XEnumerationAccess,
484 css::container::XIndexAccess,
485 css::lang::XServiceInfo >,
486 public SfxListener
488 private:
489 ScDocShell* pDocShell;
491 rtl::Reference<ScDatabaseRangeObj> GetObjectByIndex_Impl(size_t nIndex);
492 rtl::Reference<ScDatabaseRangeObj> GetObjectByName_Impl(const OUString& aName);
494 public:
495 ScDatabaseRangesObj(ScDocShell* pDocSh);
496 virtual ~ScDatabaseRangesObj() override;
498 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
500 // XDatabaseRanges
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;
509 // XIndexAccess
510 virtual sal_Int32 SAL_CALL getCount() override;
511 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
513 // XElementAccess
514 virtual css::uno::Type SAL_CALL getElementType() override;
515 virtual sal_Bool SAL_CALL hasElements() override;
517 // XNameAccess
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;
522 // XServiceInfo
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 final : public cppu::WeakImplHelper<
529 css::sheet::XUnnamedDatabaseRanges>,
530 public SfxListener
532 private:
533 ScDocShell* pDocShell;
535 public:
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;
547 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */