Coverage Report

Created: 2026-06-30 11:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sc/inc/cellsuno.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 <config_options.h>
23
#include "address.hxx"
24
#include "rangelst.hxx"
25
26
#include <formula/grammar.hxx>
27
#include <rtl/ref.hxx>
28
#include <sal/types.h>
29
#include <tools/link.hxx>
30
#include <svl/itemset.hxx>
31
#include <svl/lstner.hxx>
32
#include <svl/listener.hxx>
33
#include <com/sun/star/table/XTableChartsSupplier.hpp>
34
#include <com/sun/star/table/XTablePivotChartsSupplier.hpp>
35
#include <com/sun/star/chart/XChartDataArray.hpp>
36
#include <com/sun/star/text/XTextFieldsSupplier.hpp>
37
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
38
#include <com/sun/star/sheet/XSheetCellRange.hpp>
39
#include <com/sun/star/sheet/XFormulaQuery.hpp>
40
#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
41
#include <com/sun/star/sheet/XSheetOperation.hpp>
42
#include <com/sun/star/sheet/XSheetCellRangeContainer.hpp>
43
#include <com/sun/star/sheet/XCellFormatRangesSupplier.hpp>
44
#include <com/sun/star/sheet/XUniqueCellFormatRangesSupplier.hpp>
45
#include <com/sun/star/sheet/XCellRangesQuery.hpp>
46
#include <com/sun/star/sheet/XSheetFilterableEx.hpp>
47
#include <com/sun/star/sheet/XSpreadsheet.hpp>
48
#include <com/sun/star/sheet/XSheetPageBreak.hpp>
49
#include <com/sun/star/sheet/XCellRangeMovement.hpp>
50
#include <com/sun/star/text/XText.hpp>
51
#include <com/sun/star/sheet/XPrintAreas.hpp>
52
#include <com/sun/star/sheet/XSheetLinkable.hpp>
53
#include <com/sun/star/sheet/XSubTotalCalculatable.hpp>
54
#include <com/sun/star/sheet/XArrayFormulaRange.hpp>
55
#include <com/sun/star/sheet/XCellRangeData.hpp>
56
#include <com/sun/star/sheet/XCellRangeFormula.hpp>
57
#include <com/sun/star/sheet/XCellSeries.hpp>
58
#include <com/sun/star/sheet/XMultipleOperation.hpp>
59
#include <com/sun/star/sheet/XFormulaTokens.hpp>
60
#include <com/sun/star/sheet/XArrayFormulaTokens.hpp>
61
#include <com/sun/star/sheet/XCellAddressable.hpp>
62
#include <com/sun/star/util/XReplaceable.hpp>
63
#include <com/sun/star/util/XIndent.hpp>
64
#include <com/sun/star/lang/XServiceInfo.hpp>
65
#include <com/sun/star/container/XNameContainer.hpp>
66
#include <com/sun/star/util/XMergeable.hpp>
67
#include <com/sun/star/table/XAutoFormattable.hpp>
68
#include <com/sun/star/util/XSortable.hpp>
69
#include <com/sun/star/util/XImportable.hpp>
70
#include <com/sun/star/table/XColumnRowRange.hpp>
71
#include <com/sun/star/table/XCell2.hpp>
72
#include <com/sun/star/sheet/XDataPilotTablesSupplier.hpp>
73
#include <com/sun/star/sheet/XSheetAnnotationAnchor.hpp>
74
#include <com/sun/star/sheet/XScenariosSupplier.hpp>
75
#include <com/sun/star/sheet/XSheetAnnotationsSupplier.hpp>
76
#include <com/sun/star/sheet/XSheetAuditing.hpp>
77
#include <com/sun/star/sheet/XSheetOutline.hpp>
78
#include <com/sun/star/util/XProtectable.hpp>
79
#include <com/sun/star/sheet/XScenario.hpp>
80
#include <com/sun/star/sheet/XScenarioEnhanced.hpp>
81
#include <com/sun/star/util/XModifyBroadcaster.hpp>
82
#include <com/sun/star/beans/XPropertyState.hpp>
83
#include <com/sun/star/beans/XMultiPropertySet.hpp>
84
#include <com/sun/star/document/XActionLockable.hpp>
85
#include <com/sun/star/beans/XTolerantMultiPropertySet.hpp>
86
#include <com/sun/star/sheet/XExternalSheetName.hpp>
87
#include <com/sun/star/document/XEventsSupplier.hpp>
88
#include <cppuhelper/implbase.hxx>
89
90
#include <memory>
91
#include <optional>
92
#include <vector>
93
94
namespace com::sun::star::table { struct BorderLine2; }
95
namespace com::sun::star::table { struct BorderLine; }
96
namespace com::sun::star::table { struct TableBorder2; }
97
namespace com::sun::star::table { struct TableBorder; }
98
99
class ScDocShell;
100
class ScMarkData;
101
class ScMemChart;
102
class ScPrintRangeSaver;
103
class ScAttrRectIterator;
104
class ScCellRangeObj;
105
class ScPatternAttr;
106
class SvxBoxItem;
107
class SvxBoxInfoItem;
108
class SvxItemPropertySet;
109
class SvxUnoText;
110
class ScDocument;
111
class SfxHint;
112
class SfxItemPropertyMap;
113
class SfxItemPropertySet;
114
struct SfxItemPropertyMapEntry;
115
class ScTableRowsObj;
116
class ScTableColumnsObj;
117
class ScTableValidationObj;
118
class ScCellObj;
119
class ScScenariosObj;
120
class SolarMutexGuard;
121
class SvxUnoTextRangeBase;
122
123
namespace editeng { class SvxBorderLine; }
124
125
class ScLinkListener final : public SvtListener
126
{
127
    Link<const SfxHint&,void>  aLink;
128
public:
129
0
                    ScLinkListener(const Link<const SfxHint&,void>& rL) : aLink(rL) {}
130
    virtual         ~ScLinkListener() override;
131
    virtual void Notify( const SfxHint& rHint ) override;
132
};
133
134
typedef std::vector< css::uno::Reference< css::util::XModifyListener > > XModifyListenerArr_Impl;
135
136
//  ScCellRangesBase - base class for ScCellRangesObj (with access by index)
137
//                                and ScCellRangeObj  (without access by index)
138
139
//  XServiceInfo is implemented in derived classes
140
141
class ScHelperFunctions
142
{
143
public:
144
    static const ::editeng::SvxBorderLine* GetBorderLine( ::editeng::SvxBorderLine& rLine, const css::table::BorderLine& rStruct );
145
    static const ::editeng::SvxBorderLine* GetBorderLine( ::editeng::SvxBorderLine& rLine, const css::table::BorderLine2& rStruct );
146
    static void FillBoxItems( SvxBoxItem& rOuter, SvxBoxInfoItem& rInner, const css::table::TableBorder& rBorder );
147
    static void FillBoxItems( SvxBoxItem& rOuter, SvxBoxInfoItem& rInner, const css::table::TableBorder2& rBorder );
148
    static void FillBorderLine( css::table::BorderLine& rStruct, const ::editeng::SvxBorderLine* pLine );
149
    static void FillBorderLine( css::table::BorderLine2& rStruct, const ::editeng::SvxBorderLine* pLine );
150
    static void AssignTableBorderToAny( css::uno::Any& rAny,
151
            const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner, bool bInvalidateHorVerDist = false );
152
    static void AssignTableBorder2ToAny( css::uno::Any& rAny,
153
            const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner, bool bInvalidateHorVerDist = false );
154
    static void ApplyBorder( ScDocShell* pDocShell, const ScRangeList& rRanges,
155
                        const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner );
156
};
157
158
namespace ooo::vba::excel {
159
    class ScVbaCellRangeAccess;  // Vba Helper class
160
}
161
162
class SAL_DLLPUBLIC_RTTI SAL_LOPLUGIN_ANNOTATE("crosscast") ScCellRangesBase :
163
                         public cppu::WeakImplHelper<
164
                            css::beans::XPropertySet,
165
                             css::beans::XMultiPropertySet,
166
                             css::beans::XPropertyState,
167
                             css::sheet::XSheetOperation,
168
                             css::chart::XChartDataArray,
169
                             css::util::XIndent,
170
                             css::sheet::XCellRangesQuery,
171
                             css::sheet::XFormulaQuery,
172
                             css::util::XReplaceable,
173
                             css::util::XModifyBroadcaster,
174
                             css::lang::XServiceInfo,
175
                             css::beans::XTolerantMultiPropertySet>,
176
                         public SfxListener
177
{
178
    friend class ScTabViewObj;      // for select()
179
    friend class ScTableSheetObj;   // for createCursorByRange()
180
    friend class ooo::vba::excel::ScVbaCellRangeAccess;
181
182
private:
183
    const SfxItemPropertySet* pPropSet;
184
    ScDocShell*             pDocShell;
185
    std::unique_ptr<ScLinkListener> pValueListener;
186
    std::unique_ptr<ScPatternAttr>  pCurrentFlat;
187
    std::unique_ptr<ScPatternAttr>  pCurrentDeep;
188
    std::optional<SfxItemSet>       moCurrentDataSet;
189
    std::optional<SfxItemSet>       moNoDfltCurrentDataSet;
190
    std::unique_ptr<ScMarkData>     pMarkData;
191
    ScRangeList             aRanges;
192
    sal_Int64               nObjectId;
193
    bool                    bChartColAsHdr;
194
    bool                    bChartRowAsHdr;
195
    bool                    bCursorOnly;
196
    bool                    bGotDataChangedHint;
197
    XModifyListenerArr_Impl aValueListeners;
198
199
    DECL_LINK( ValueListenerHdl, const SfxHint&, void );
200
201
private:
202
    void            PaintGridRanges_Impl();
203
    ScRangeListRef  GetLimitedChartRanges_Impl( sal_Int32 nDataColumns, sal_Int32 nDataRows ) const;
204
    void            ForceChartListener_Impl();
205
    std::unique_ptr<ScMemChart> CreateMemChart_Impl() const;
206
207
    const ScPatternAttr*    GetCurrentAttrsFlat();
208
    const ScPatternAttr*    GetCurrentAttrsDeep();
209
    SC_DLLPUBLIC SfxItemSet* GetCurrentDataSet(bool bNoDflt = false);
210
    void                    ForgetMarkData();
211
    void                    ForgetCurrentAttrs();
212
213
    css::uno::Reference<css::sheet::XSheetCellRanges>
214
                            QueryDifferences_Impl(const css::table::CellAddress& aCompare,
215
                                                    bool bColumnDiff);
216
    css::uno::Reference<css::uno::XInterface>
217
                            Find_Impl(const css::uno::Reference<css::util::XSearchDescriptor>& xDesc,
218
                                    const ScAddress* pLastPos);
219
220
protected:
221
    const ScMarkData*       GetMarkData();
222
223
    // GetItemPropertyMap for derived classes must contain all entries, including base class
224
    SC_DLLPUBLIC virtual const SfxItemPropertyMap& GetItemPropertyMap();
225
    css::beans::PropertyState GetOnePropertyState(
226
                                sal_uInt16 nItemWhich, const SfxItemPropertyMapEntry* pEntry );
227
    /// @throws css::uno::RuntimeException
228
    SC_DLLPUBLIC virtual void GetOnePropertyValue( const SfxItemPropertyMapEntry* pEntry,
229
                                css::uno::Any& );
230
    /// @throws css::lang::IllegalArgumentException
231
    /// @throws css::uno::RuntimeException
232
    SC_DLLPUBLIC virtual void SetOnePropertyValue( const SfxItemPropertyMapEntry* pEntry,
233
                                                const css::uno::Any& aValue );
234
235
0
    ScRangeList& AccessRanges() { return aRanges; }
236
    SC_DLLPUBLIC virtual void AdjustUpdatedRanges(UpdateRefMode mode);
237
238
public:
239
                            ScCellRangesBase(ScDocShell* pDocSh, const ScRange& rR);
240
                            ScCellRangesBase(ScDocShell* pDocSh, ScRangeList aR);
241
    virtual                 ~ScCellRangesBase() override;
242
243
    SC_DLLPUBLIC virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
244
    virtual void            RefChanged();
245
246
                            // from derived classes and by getImplementation
247
91.7k
    ScDocShell*             GetDocShell() const     { return pDocShell; }
248
    ScDocument*             GetDocument() const;
249
50.7k
    const ScRangeList&      GetRangeList() const    { return aRanges; }
250
    void                    AddRange(const ScRange& rRange, const bool bMergeRanges);
251
252
                            // arouse object created via service:
253
    void                    InitInsertRange(ScDocShell* pDocSh, const ScRange& rR);
254
255
    void                    SetNewRange(const ScRange& rNew);   // for cursor
256
    void                    SetNewRanges(const ScRangeList& rNew);
257
258
    void                    SetCursorOnly(bool bSet);
259
0
    bool                    IsCursorOnly() const            { return bCursorOnly; }
260
261
    SC_DLLPUBLIC rtl::Reference<ScTableValidationObj> getValidation();
262
    SC_DLLPUBLIC void setValidation(const rtl::Reference<ScTableValidationObj>&);
263
264
                            // XSheetOperation
265
    virtual double SAL_CALL computeFunction( css::sheet::GeneralFunction nFunction ) override;
266
    virtual void SAL_CALL   clearContents( sal_Int32 nContentFlags ) override;
267
268
                            // XPropertySet
269
    virtual css::uno::Reference< css::beans::XPropertySetInfo >
270
                            SAL_CALL getPropertySetInfo() override;
271
    SC_DLLPUBLIC virtual void SAL_CALL   setPropertyValue( const OUString& aPropertyName,
272
                                    const css::uno::Any& aValue ) override;
273
    virtual css::uno::Any SAL_CALL getPropertyValue(
274
                                    const OUString& PropertyName ) override;
275
    virtual void SAL_CALL   addPropertyChangeListener( const OUString& aPropertyName,
276
                                    const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
277
    virtual void SAL_CALL   removePropertyChangeListener( const OUString& aPropertyName,
278
                                    const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
279
    virtual void SAL_CALL   addVetoableChangeListener( const OUString& PropertyName,
280
                                    const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
281
    virtual void SAL_CALL   removeVetoableChangeListener( const OUString& PropertyName,
282
                                    const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
283
284
                            // XMultiPropertySet
285
    virtual void SAL_CALL   setPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames,
286
                                    const css::uno::Sequence< css::uno::Any >& aValues ) override;
287
    virtual css::uno::Sequence< css::uno::Any > SAL_CALL
288
                            getPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames ) override;
289
    virtual void SAL_CALL addPropertiesChangeListener( const css::uno::Sequence< OUString >& aPropertyNames,
290
                                    const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
291
    virtual void SAL_CALL removePropertiesChangeListener( const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
292
    virtual void SAL_CALL firePropertiesChangeEvent( const css::uno::Sequence< OUString >& aPropertyNames,
293
                                    const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
294
295
                            // XTolerantMultiPropertySet
296
    virtual css::uno::Sequence< css::beans::SetPropertyTolerantFailed > SAL_CALL
297
        setPropertyValuesTolerant( const css::uno::Sequence< OUString >& aPropertyNames,
298
                                    const css::uno::Sequence< css::uno::Any >& aValues ) override;
299
    virtual css::uno::Sequence< css::beans::GetPropertyTolerantResult > SAL_CALL
300
        getPropertyValuesTolerant( const css::uno::Sequence< OUString >& aPropertyNames ) override;
301
    virtual css::uno::Sequence< css::beans::GetDirectPropertyTolerantResult > SAL_CALL
302
        getDirectPropertyValuesTolerant( const css::uno::Sequence< OUString >& aPropertyNames ) override;
303
304
                            // XPropertyState
305
    virtual css::beans::PropertyState SAL_CALL getPropertyState(
306
                                    const OUString& PropertyName ) override;
307
    virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL
308
                            getPropertyStates( const css::uno::Sequence<
309
                                        OUString >& aPropertyName ) override;
310
    virtual void SAL_CALL   setPropertyToDefault( const OUString& PropertyName ) override;
311
    virtual css::uno::Any SAL_CALL getPropertyDefault(
312
                                    const OUString& aPropertyName ) override;
313
314
                            // XIndent
315
    virtual void SAL_CALL   decrementIndent() override;
316
    virtual void SAL_CALL   incrementIndent() override;
317
318
                            // XChartData
319
    virtual void SAL_CALL   addChartDataChangeEventListener(
320
                                const css::uno::Reference< css::chart::XChartDataChangeEventListener >& aListener ) override;
321
    virtual void SAL_CALL   removeChartDataChangeEventListener( const css::uno::Reference<
322
                                    css::chart::XChartDataChangeEventListener >& aListener ) override;
323
    virtual double SAL_CALL getNotANumber() override;
324
    virtual sal_Bool SAL_CALL isNotANumber( double nNumber ) override;
325
326
                            // XChartDataArray
327
    virtual css::uno::Sequence< css::uno::Sequence< double > > SAL_CALL
328
                            getData() override;
329
    virtual void SAL_CALL   setData( const css::uno::Sequence< css::uno::Sequence< double > >& aData ) override;
330
    virtual css::uno::Sequence< OUString > SAL_CALL getRowDescriptions() override;
331
    virtual void SAL_CALL setRowDescriptions( const css::uno::Sequence< OUString >& aRowDescriptions ) override;
332
    virtual css::uno::Sequence< OUString > SAL_CALL getColumnDescriptions() override;
333
    virtual void SAL_CALL   setColumnDescriptions( const css::uno::Sequence< OUString >& aColumnDescriptions ) override;
334
335
                            // XCellRangesQuery
336
    virtual css::uno::Reference< css::sheet::XSheetCellRanges > SAL_CALL
337
                            queryVisibleCells() override;
338
    virtual css::uno::Reference< css::sheet::XSheetCellRanges > SAL_CALL
339
                            queryEmptyCells() override;
340
    virtual css::uno::Reference< css::sheet::XSheetCellRanges > SAL_CALL
341
                            queryContentCells( sal_Int16 nContentFlags ) override;
342
    virtual css::uno::Reference< css::sheet::XSheetCellRanges > SAL_CALL
343
                            queryFormulaCells( sal_Int32 nResultFlags ) override;
344
    virtual css::uno::Reference< css::sheet::XSheetCellRanges > SAL_CALL
345
                            queryColumnDifferences(
346
                                const css::table::CellAddress& aCompare ) override;
347
    virtual css::uno::Reference< css::sheet::XSheetCellRanges > SAL_CALL
348
                            queryRowDifferences(
349
                                const css::table::CellAddress& aCompare ) override;
350
    virtual css::uno::Reference< css::sheet::XSheetCellRanges > SAL_CALL
351
                            queryIntersection(
352
                                const css::table::CellRangeAddress& aRange ) override;
353
354
                            // XFormulaQuery
355
    virtual css::uno::Reference< css::sheet::XSheetCellRanges > SAL_CALL
356
                            queryDependents( sal_Bool bRecursive ) override;
357
    virtual css::uno::Reference< css::sheet::XSheetCellRanges > SAL_CALL
358
                            queryPrecedents( sal_Bool bRecursive ) override;
359
360
                            // XSearchable
361
    virtual css::uno::Reference< css::util::XSearchDescriptor > SAL_CALL
362
                            createSearchDescriptor() override;
363
    virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL
364
                            findAll( const css::uno::Reference< css::util::XSearchDescriptor >& xDesc ) override;
365
    virtual css::uno::Reference< css::uno::XInterface > SAL_CALL
366
                            findFirst( const css::uno::Reference< css::util::XSearchDescriptor >& xDesc ) override;
367
    virtual css::uno::Reference< css::uno::XInterface > SAL_CALL
368
                            findNext( const css::uno::Reference< css::uno::XInterface >& xStartAt,
369
                                      const css::uno::Reference< css::util::XSearchDescriptor >& xDesc ) override;
370
371
                            // XReplaceable
372
    virtual css::uno::Reference< css::util::XReplaceDescriptor > SAL_CALL
373
                            createReplaceDescriptor() override;
374
    virtual sal_Int32 SAL_CALL replaceAll( const css::uno::Reference< css::util::XSearchDescriptor >& xDesc ) override;
375
376
                            // XModifyBroadcaster
377
    virtual void SAL_CALL   addModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
378
    virtual void SAL_CALL   removeModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
379
380
                            // XServiceInfo
381
    virtual OUString SAL_CALL getImplementationName() override;
382
    virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
383
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
384
};
385
386
using ScCellRangesObj_BASE = cppu::ImplInheritanceHelper<ScCellRangesBase,
387
                                                         css::sheet::XSheetCellRangeContainer,
388
                                                         css::container::XNameContainer,
389
                                                         css::container::XEnumerationAccess>;
390
class SC_DLLPUBLIC ScCellRangesObj final : public ScCellRangesObj_BASE
391
{
392
public:
393
    struct ScNamedEntry
394
    {
395
        OUString  aName;
396
        ScRange   aRange;
397
0
        const OUString& GetName() const { return aName; }
398
0
        const ScRange& GetRange() const { return aRange; }
399
    };
400
private:
401
    std::vector<ScNamedEntry> m_aNamedEntries;
402
403
    rtl::Reference<ScCellRangeObj> GetObjectByIndex_Impl(sal_Int32 nIndex) const;
404
405
public:
406
                            ScCellRangesObj(ScDocShell* pDocSh, const ScRangeList& rR);
407
    virtual                 ~ScCellRangesObj() override;
408
409
    virtual void            RefChanged() override;
410
411
                            // XSheetCellRanges
412
    virtual css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL
413
                            getCells() override;
414
    virtual OUString SAL_CALL getRangeAddressesAsString() override;
415
    virtual css::uno::Sequence< css::table::CellRangeAddress > SAL_CALL
416
                            getRangeAddresses() override;
417
418
                            // XSheetCellRangeContainer
419
    virtual void SAL_CALL   addRangeAddress( const css::table::CellRangeAddress& rRange,
420
                                        sal_Bool bMergeRanges ) override;
421
    virtual void SAL_CALL   removeRangeAddress( const css::table::CellRangeAddress& rRange ) override;
422
    virtual void SAL_CALL   addRangeAddresses( const css::uno::Sequence<
423
                                        css::table::CellRangeAddress >& rRanges,
424
                                        sal_Bool bMergeRanges ) override;
425
    virtual void SAL_CALL   removeRangeAddresses( const css::uno::Sequence<
426
                                        css::table::CellRangeAddress >& rRanges ) override;
427
428
                            // XNameContainer
429
    virtual void SAL_CALL   insertByName( const OUString& aName,
430
                                const css::uno::Any& aElement ) override;
431
    virtual void SAL_CALL   removeByName( const OUString& Name ) override;
432
433
                            // XNameReplace
434
    virtual void SAL_CALL   replaceByName( const OUString& aName,
435
                                const css::uno::Any& aElement ) override;
436
437
                            // XNameAccess
438
    virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
439
    virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
440
    virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
441
442
                            // XIndexAccess
443
    virtual sal_Int32 SAL_CALL getCount() override;
444
    virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
445
446
                            // XElementAccess
447
    virtual css::uno::Type SAL_CALL getElementType() override;
448
    virtual sal_Bool SAL_CALL hasElements() override;
449
450
                            // XEnumerationAccess
451
    virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
452
                            createEnumeration() override;
453
454
                            // XServiceInfo
455
    virtual OUString SAL_CALL getImplementationName() override;
456
    virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
457
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
458
459
    void addRangeAddresses( const ScRangeList& rRanges, bool bMergeRanges );
460
};
461
462
using ScCellRangeObj_BASE = cppu::ImplInheritanceHelper<ScCellRangesBase,
463
                                                        css::sheet::XCellRangeAddressable,
464
                                                        css::sheet::XSheetCellRange,
465
                                                        css::sheet::XArrayFormulaRange,
466
                                                        css::sheet::XArrayFormulaTokens,
467
                                                        css::sheet::XCellRangeData,
468
                                                        css::sheet::XCellRangeFormula,
469
                                                        css::sheet::XMultipleOperation,
470
                                                        css::util::XMergeable,
471
                                                        css::sheet::XCellSeries,
472
                                                        css::table::XAutoFormattable,
473
                                                        css::util::XSortable,
474
                                                        css::sheet::XSheetFilterableEx,
475
                                                        css::sheet::XSubTotalCalculatable,
476
                                                        css::util::XImportable,
477
                                                        css::sheet::XCellFormatRangesSupplier,
478
                                                        css::sheet::XUniqueCellFormatRangesSupplier,
479
                                                        css::table::XColumnRowRange>;
480
class SAL_DLLPUBLIC_RTTI ScCellRangeObj : public ScCellRangeObj_BASE
481
{
482
private:
483
    const SfxItemPropertySet*       pRangePropSet;
484
    ScRange                 aRange;
485
486
protected:
487
115
    const ScRange&          GetRange() const    { return aRange; }
488
    virtual const SfxItemPropertyMap& GetItemPropertyMap() override;
489
    virtual void GetOnePropertyValue( const SfxItemPropertyMapEntry* pEntry,
490
                                css::uno::Any& ) override;
491
    virtual void            SetOnePropertyValue( const SfxItemPropertyMapEntry* pEntry,
492
                                                const css::uno::Any& aValue ) override;
493
494
    /// @throws css::lang::IndexOutOfBoundsException
495
    /// @throws css::uno::RuntimeException
496
    rtl::Reference< ScCellObj >
497
                            GetCellByPosition_Impl( sal_Int32 nColumn, sal_Int32 nRow );
498
499
            /// @throws css::uno::RuntimeException
500
            void            SetArrayFormula_Impl( const OUString& rFormula,
501
                                const formula::FormulaGrammar::Grammar eGrammar );
502
503
public:
504
    SC_DLLPUBLIC            ScCellRangeObj(ScDocShell* pDocSh, const ScRange& rR);
505
    virtual                 ~ScCellRangeObj() override;
506
507
                            // uses ObjectShell from document, if set (returns NULL otherwise)
508
    static css::uno::Reference<css::table::XCellRange>
509
                            CreateRangeFromDoc( const ScDocument& rDoc, const ScRange& rR );
510
511
    virtual void            RefChanged() override;
512
513
                            // XCellRangeAddressable
514
    virtual css::table::CellRangeAddress SAL_CALL getRangeAddress() override;
515
516
                            // XSheetCellRange
517
    virtual css::uno::Reference< css::sheet::XSpreadsheet > SAL_CALL
518
                            getSpreadsheet() override;
519
520
                            // XArrayFormulaRange
521
    virtual OUString SAL_CALL getArrayFormula() override;
522
    virtual void SAL_CALL   setArrayFormula( const OUString& aFormula ) override;
523
524
                            // XArrayFormulaTokens
525
    virtual css::uno::Sequence< css::sheet::FormulaToken > SAL_CALL getArrayTokens() override;
526
    SC_DLLPUBLIC virtual void SAL_CALL   setArrayTokens( const css::uno::Sequence<
527
                                    css::sheet::FormulaToken >& aTokens ) override;
528
529
                            // XCellRangeData
530
    virtual css::uno::Sequence< css::uno::Sequence< css::uno::Any > > SAL_CALL getDataArray() override;
531
    virtual void SAL_CALL   setDataArray( const css::uno::Sequence< css::uno::Sequence< css::uno::Any > >& aArray ) override;
532
533
                            // XCellRangeFormula
534
    virtual css::uno::Sequence< css::uno::Sequence<
535
                            OUString > > SAL_CALL getFormulaArray() override;
536
    virtual void SAL_CALL   setFormulaArray( const css::uno::Sequence< css::uno::Sequence< OUString > >& aArray ) override;
537
538
                            // XMultipleOperation
539
    virtual void SAL_CALL   setTableOperation(
540
                                const css::table::CellRangeAddress& aFormulaRange,
541
                                css::sheet::TableOperationMode nMode,
542
                                const css::table::CellAddress& aColumnCell,
543
                                const css::table::CellAddress& aRowCell ) override;
544
545
                            // XMergeable
546
    virtual void SAL_CALL   merge( sal_Bool bMerge ) override;
547
    virtual sal_Bool SAL_CALL getIsMerged() override;
548
549
                            // XCellSeries
550
    virtual void SAL_CALL   fillSeries( css::sheet::FillDirection nFillDirection,
551
                                css::sheet::FillMode nFillMode,
552
                                css::sheet::FillDateMode nFillDateMode,
553
                                double fStep, double fEndValue ) override;
554
    virtual void SAL_CALL   fillAuto( css::sheet::FillDirection nFillDirection,
555
                                sal_Int32 nSourceCount ) override;
556
557
                            // XAutoFormattable
558
    virtual void SAL_CALL   autoFormat( const OUString& aName ) override;
559
560
                            // XSortable
561
    virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL
562
                            createSortDescriptor() override;
563
    virtual void SAL_CALL   sort( const css::uno::Sequence<
564
                                css::beans::PropertyValue >& xDescriptor ) override;
565
566
                            // XSheetFilterableEx
567
    virtual css::uno::Reference< css::sheet::XSheetFilterDescriptor > SAL_CALL
568
                            createFilterDescriptorByObject( const css::uno::Reference<
569
                                css::sheet::XSheetFilterable >& xObject ) override;
570
571
                            // XSheetFilterable
572
    virtual css::uno::Reference< css::sheet::XSheetFilterDescriptor > SAL_CALL
573
                            createFilterDescriptor( sal_Bool bEmpty ) override;
574
    virtual void SAL_CALL   filter( const css::uno::Reference<
575
                                css::sheet::XSheetFilterDescriptor >& xDescriptor ) override;
576
577
                            // XSubTotalCalculatable
578
    virtual css::uno::Reference< css::sheet::XSubTotalDescriptor > SAL_CALL
579
                            createSubTotalDescriptor( sal_Bool bEmpty ) override;
580
    virtual void SAL_CALL   applySubTotals(const css::uno::Reference< css::sheet::XSubTotalDescriptor >& xDescriptor,
581
                                sal_Bool bReplace) override;
582
    virtual void SAL_CALL   removeSubTotals() override;
583
584
                            // XImportable
585
    virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL
586
                            createImportDescriptor( sal_Bool bEmpty ) override;
587
    virtual void SAL_CALL   doImport( const css::uno::Sequence< css::beans::PropertyValue >& aDescriptor ) override;
588
589
                            // XCellFormatRangesSupplier
590
    virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL
591
                            getCellFormatRanges() override;
592
593
                            // XUniqueCellFormatRangesSupplier
594
    virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL
595
                            getUniqueCellFormatRanges() override;
596
597
                            // XColumnRowRange
598
    virtual css::uno::Reference< css::table::XTableColumns > SAL_CALL
599
                            getColumns() override;
600
    virtual css::uno::Reference< css::table::XTableRows > SAL_CALL
601
                            getRows() override;
602
603
                            // XCellRange
604
    virtual css::uno::Reference< css::table::XCell > SAL_CALL
605
                            getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow ) override;
606
    virtual css::uno::Reference< css::table::XCellRange > SAL_CALL
607
                            getCellRangeByPosition( sal_Int32 nLeft, sal_Int32 nTop,
608
                                sal_Int32 nRight, sal_Int32 nBottom ) override;
609
    virtual css::uno::Reference< css::table::XCellRange > SAL_CALL
610
                            getCellRangeByName( const OUString& aRange ) override;
611
    /// @throws css::uno::RuntimeException
612
    css::uno::Reference< css::table::XCellRange >
613
                            getCellRangeByName( const OUString& aRange,  const ScAddress::Details& rDetails );
614
615
                            // XPropertySet override due to Range-Properties
616
    virtual css::uno::Reference< css::beans::XPropertySetInfo >
617
                            SAL_CALL getPropertySetInfo() override;
618
619
                            // XServiceInfo
620
    virtual OUString SAL_CALL getImplementationName() override;
621
    virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
622
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
623
624
    rtl::Reference< ScCellRangeObj >
625
                            getScCellRangeByPosition( sal_Int32 nLeft, sal_Int32 nTop,
626
                                sal_Int32 nRight, sal_Int32 nBottom );
627
    SC_DLLPUBLIC rtl::Reference< ScCellRangeObj >
628
                            getScCellRangeByName( const OUString& aRange );
629
    rtl::Reference< ScCellRangeObj >
630
                            getScCellRangeByName( const OUString& aRange, const ScAddress::Details& rDetails );
631
    rtl::Reference< ScTableRowsObj >
632
                            getScRowsByPosition( SolarMutexGuard& rGuard, sal_Int32 nLeft, sal_Int32 nTop,
633
                                sal_Int32 nRight, sal_Int32 nBottom );
634
    SC_DLLPUBLIC rtl::Reference< ScTableColumnsObj > getScColumns();
635
    SC_DLLPUBLIC rtl::Reference< ScTableRowsObj > getScRows();
636
    SC_DLLPUBLIC rtl::Reference< ScCellObj >
637
                            getScCellByPosition( sal_Int32 nColumn, sal_Int32 nRow );
638
};
639
640
//! really derive cell from range?
641
642
using ScCellObj_BASE = cppu::ImplInheritanceHelper<ScCellRangeObj,
643
                                                   css::text::XText,
644
                                                   css::container::XEnumerationAccess,
645
                                                   css::table::XCell2,
646
                                                   css::sheet::XFormulaTokens,
647
                                                   css::sheet::XCellAddressable,
648
                                                   css::sheet::XSheetAnnotationAnchor,
649
                                                   css::text::XTextFieldsSupplier,
650
                                                   css::document::XActionLockable>;
651
class SAL_DLLPUBLIC_RTTI ScCellObj final : public ScCellObj_BASE
652
{
653
private:
654
    rtl::Reference<SvxUnoText> mxUnoText;
655
    const SfxItemPropertySet*   pCellPropSet;
656
    ScAddress               aCellPos;
657
    sal_Int16               nActionLockCount;
658
659
private:
660
    OUString    GetInputString_Impl(bool bEnglish) const;
661
    OUString    GetOutputString_Impl() const;
662
    void        SetString_Impl(const OUString& rString, bool bInterpret, bool bEnglish);
663
    double      GetValue_Impl() const;
664
    void        SetValue_Impl(double fValue);
665
    css::table::CellContentType GetContentType_Impl();
666
    sal_Int32 GetResultType_Impl() const;
667
668
    virtual const SfxItemPropertyMap& GetItemPropertyMap() override;
669
    virtual void GetOnePropertyValue( const SfxItemPropertyMapEntry* pEntry,
670
                                css::uno::Any& ) override;
671
    virtual void            SetOnePropertyValue( const SfxItemPropertyMapEntry* pEntry,
672
                                                const css::uno::Any& aValue ) override;
673
674
    SvxUnoTextRangeBase*
675
    getSvxUnoTextRange(const css::uno::Reference<css::text::XTextRange>& xRange);
676
    bool insertScEditFieldObj(const css::uno::Reference<css::text::XTextRange>& xRange,
677
                              const css::uno::Reference<css::text::XTextContent>& xContent,
678
                              bool bAbsorb);
679
680
public:
681
    static const SvxItemPropertySet* GetEditPropertySet();
682
    static const SfxItemPropertyMap& GetCellPropertyMap();
683
684
    SC_DLLPUBLIC ScCellObj(ScDocShell* pDocSh, const ScAddress& rP);
685
    SC_DLLPUBLIC virtual    ~ScCellObj() override;
686
687
    virtual void            RefChanged() override;
688
689
    SvxUnoText&             GetUnoText();
690
691
                            // XML import needs to set results at formula cells,
692
                            // not meant for any other purpose.
693
0
    const ScAddress&        GetPosition() const { return aCellPos; }
694
695
    SC_DLLPUBLIC void       InputEnglishString( const OUString& rText );
696
697
                            // XText
698
    virtual void SAL_CALL   insertTextContent( const css::uno::Reference< css::text::XTextRange >& xRange,
699
                                const css::uno::Reference< css::text::XTextContent >& xContent,
700
                                sal_Bool bAbsorb ) override;
701
    virtual void SAL_CALL   removeTextContent( const css::uno::Reference< css::text::XTextContent >& xContent ) override;
702
703
                            // XSimpleText
704
    virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL
705
                            createTextCursor() override;
706
    virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL
707
                            createTextCursorByRange( const css::uno::Reference< css::text::XTextRange >& aTextPosition ) override;
708
    virtual void SAL_CALL   insertString( const css::uno::Reference< css::text::XTextRange >& xRange,
709
                                        const OUString& aString, sal_Bool bAbsorb ) override;
710
    virtual void SAL_CALL   insertControlCharacter( const css::uno::Reference< css::text::XTextRange >& xRange,
711
                                        sal_Int16 nControlCharacter, sal_Bool bAbsorb ) override;
712
713
                            // XTextRange
714
    virtual css::uno::Reference< css::text::XText > SAL_CALL
715
                            getText() override;
716
    virtual css::uno::Reference< css::text::XTextRange > SAL_CALL
717
                            getStart() override;
718
    virtual css::uno::Reference< css::text::XTextRange > SAL_CALL
719
                            getEnd() override;
720
    virtual OUString SAL_CALL getString() override;
721
    virtual void SAL_CALL   setString( const OUString& aString ) override;
722
723
                            // XEnumerationAccess
724
    virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
725
                            createEnumeration() override;
726
727
                            // XElementAccess
728
    virtual css::uno::Type SAL_CALL getElementType() override;
729
    virtual sal_Bool SAL_CALL hasElements() override;
730
731
                            // XCell
732
    virtual OUString SAL_CALL getFormula() override;
733
    virtual void SAL_CALL   setFormula( const OUString& aFormula ) override;
734
    virtual void SAL_CALL   setFormulaResult( double nValue ) override;
735
    virtual void SAL_CALL   setFormulaString( const OUString& aFormula ) override;
736
    virtual double SAL_CALL getValue() override;
737
    virtual void SAL_CALL   setValue( double nValue ) override;
738
    virtual css::table::CellContentType SAL_CALL getType() override;
739
    virtual sal_Int32 SAL_CALL getError() override;
740
741
                            // XFormulaTokens
742
    virtual css::uno::Sequence< css::sheet::FormulaToken > SAL_CALL getTokens() override;
743
    virtual void SAL_CALL   setTokens( const css::uno::Sequence< css::sheet::FormulaToken >& aTokens ) override;
744
745
                            // XCellAddressable
746
    SC_DLLPUBLIC virtual css::table::CellAddress SAL_CALL getCellAddress() override;
747
748
                            // XSheetAnnotationAnchor
749
    virtual css::uno::Reference< css::sheet::XSheetAnnotation > SAL_CALL
750
                            getAnnotation() override;
751
752
                            // XTextFieldsSupplier
753
    virtual css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL
754
                            getTextFields() override;
755
    virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL
756
                            getTextFieldMasters() override;
757
758
                            // XPropertySet override due to cell properties
759
    virtual css::uno::Reference< css::beans::XPropertySetInfo >
760
                            SAL_CALL getPropertySetInfo() override;
761
762
                            // XServiceInfo
763
    virtual OUString SAL_CALL getImplementationName() override;
764
    virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
765
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
766
767
                            // XActionLockable
768
    virtual sal_Bool SAL_CALL isActionLocked() override;
769
    virtual void SAL_CALL   addActionLock() override;
770
    virtual void SAL_CALL   removeActionLock() override;
771
    virtual void SAL_CALL   setActionLocks( sal_Int16 nLock ) override;
772
    virtual sal_Int16 SAL_CALL resetActionLocks() override;
773
};
774
775
using ScTableSheetObj_BASE = cppu::ImplInheritanceHelper<ScCellRangeObj,
776
                                                         css::sheet::XSpreadsheet,
777
                                                         css::container::XNamed,
778
                                                         css::sheet::XSheetPageBreak,
779
                                                         css::sheet::XCellRangeMovement,
780
                                                         css::table::XTableChartsSupplier,
781
                                                         css::table::XTablePivotChartsSupplier,
782
                                                         css::sheet::XDataPilotTablesSupplier,
783
                                                         css::sheet::XScenariosSupplier,
784
                                                         css::sheet::XSheetAnnotationsSupplier,
785
                                                         css::drawing::XDrawPageSupplier,
786
                                                         css::sheet::XPrintAreas,
787
                                                         css::sheet::XSheetLinkable,
788
                                                         css::sheet::XSheetAuditing,
789
                                                         css::sheet::XSheetOutline,
790
                                                         css::util::XProtectable,
791
                                                         css::sheet::XScenario,
792
                                                         css::sheet::XScenarioEnhanced,
793
                                                         css::sheet::XExternalSheetName,
794
                                                         css::document::XEventsSupplier>;
795
class SC_DLLPUBLIC ScTableSheetObj final : public ScTableSheetObj_BASE
796
{
797
    friend class ScTableSheetsObj;      // for insertByName()
798
799
private:
800
    const SfxItemPropertySet*       pSheetPropSet;
801
802
    SCTAB                   GetTab_Impl() const;
803
    void                    PrintAreaUndo_Impl( std::unique_ptr<ScPrintRangeSaver> pOldRanges );
804
805
    virtual const SfxItemPropertyMap& GetItemPropertyMap() override;
806
    virtual void GetOnePropertyValue( const SfxItemPropertyMapEntry* pEntry,
807
                                css::uno::Any& ) override;
808
    virtual void            SetOnePropertyValue( const SfxItemPropertyMapEntry* pEntry,
809
                                                const css::uno::Any& aValue ) override;
810
811
public:
812
                            ScTableSheetObj(ScDocShell* pDocSh, SCTAB nTab);
813
    virtual                 ~ScTableSheetObj() override;
814
815
    void                    InitInsertSheet(ScDocShell* pDocSh, SCTAB nTab);
816
817
                            // XSpreadsheet
818
    virtual css::uno::Reference< css::sheet::XSheetCellCursor >
819
                            SAL_CALL createCursor() override;
820
    virtual css::uno::Reference< css::sheet::XSheetCellCursor > SAL_CALL
821
                            createCursorByRange( const css::uno::Reference<
822
                                css::sheet::XSheetCellRange >& aRange ) override;
823
824
                            // XSheetCellRange
825
    virtual css::uno::Reference< css::sheet::XSpreadsheet > SAL_CALL
826
                            getSpreadsheet() override;
827
828
                            // XCellRange
829
    virtual css::uno::Reference< css::table::XCell > SAL_CALL
830
                            getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow ) override;
831
    virtual css::uno::Reference< css::table::XCellRange > SAL_CALL
832
                            getCellRangeByPosition( sal_Int32 nLeft, sal_Int32 nTop,
833
                                sal_Int32 nRight, sal_Int32 nBottom ) override;
834
    using ScCellRangeObj::getCellRangeByName;
835
    virtual css::uno::Reference< css::table::XCellRange > SAL_CALL
836
                            getCellRangeByName( const OUString& aRange ) override;
837
838
                            // XNamed
839
    virtual OUString SAL_CALL getName() override;
840
    virtual void SAL_CALL   setName( const OUString& aName ) override;
841
842
                            // XSheetPageBreak
843
    virtual css::uno::Sequence< css::sheet::TablePageBreakData > SAL_CALL
844
                            getColumnPageBreaks() override;
845
    virtual css::uno::Sequence< css::sheet::TablePageBreakData > SAL_CALL
846
                            getRowPageBreaks() override;
847
    virtual void SAL_CALL   removeAllManualPageBreaks() override;
848
849
                            // XCellRangeMovement
850
    virtual void SAL_CALL   insertCells( const css::table::CellRangeAddress& aRange,
851
                                css::sheet::CellInsertMode nMode ) override;
852
    virtual void SAL_CALL   removeRange( const css::table::CellRangeAddress& aRange,
853
                                css::sheet::CellDeleteMode nMode ) override;
854
    virtual void SAL_CALL   moveRange( const css::table::CellAddress& aDestination,
855
                                const css::table::CellRangeAddress& aSource ) override;
856
    virtual void SAL_CALL   copyRange( const css::table::CellAddress& aDestination,
857
                                const css::table::CellRangeAddress& aSource ) override;
858
859
                            // XTableChartsSupplier
860
    virtual css::uno::Reference< css::table::XTableCharts > SAL_CALL
861
                            getCharts() override;
862
863
                            // XTablePivotChartsSupplier
864
    virtual css::uno::Reference<css::table::XTablePivotCharts> SAL_CALL
865
                            getPivotCharts() override;
866
867
                            // XDataPilotTablesSupplier
868
    virtual css::uno::Reference< css::sheet::XDataPilotTables > SAL_CALL
869
                            getDataPilotTables() override;
870
871
                            // XScenariosSupplier
872
    virtual css::uno::Reference< css::sheet::XScenarios > SAL_CALL
873
                            getScenarios() override;
874
875
                            // XSheetAnnotationsSupplier
876
    virtual css::uno::Reference< css::sheet::XSheetAnnotations > SAL_CALL
877
                            getAnnotations() override;
878
879
                            // XDrawPageSupplier
880
    virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL
881
                            getDrawPage() override;
882
883
                            // XPrintAreas
884
    virtual css::uno::Sequence< css::table::CellRangeAddress > SAL_CALL
885
                            getPrintAreas() override;
886
    virtual void SAL_CALL setPrintAreas( const css::uno::Sequence<
887
                                css::table::CellRangeAddress >& aPrintAreas ) override;
888
    virtual sal_Bool SAL_CALL getPrintTitleColumns() override;
889
    virtual void SAL_CALL   setPrintTitleColumns( sal_Bool bPrintTitleColumns ) override;
890
    virtual css::table::CellRangeAddress SAL_CALL getTitleColumns() override;
891
    virtual void SAL_CALL   setTitleColumns(
892
                                const css::table::CellRangeAddress& aTitleColumns ) override;
893
    virtual sal_Bool SAL_CALL getPrintTitleRows() override;
894
    virtual void SAL_CALL   setPrintTitleRows( sal_Bool bPrintTitleRows ) override;
895
    virtual css::table::CellRangeAddress SAL_CALL getTitleRows() override;
896
    virtual void SAL_CALL   setTitleRows(
897
                                const css::table::CellRangeAddress& aTitleRows ) override;
898
899
                            // XSheetLinkable
900
    virtual css::sheet::SheetLinkMode SAL_CALL getLinkMode() override;
901
    virtual void SAL_CALL   setLinkMode( css::sheet::SheetLinkMode nLinkMode ) override;
902
    virtual OUString SAL_CALL getLinkUrl() override;
903
    virtual void SAL_CALL   setLinkUrl( const OUString& aLinkUrl ) override;
904
    virtual OUString SAL_CALL getLinkSheetName() override;
905
    virtual void SAL_CALL   setLinkSheetName( const OUString& aLinkSheetName ) override;
906
    virtual void SAL_CALL   link( const OUString& aUrl,
907
                                const OUString& aSheetName,
908
                                const OUString& aFilterName,
909
                                const OUString& aFilterOptions,
910
                                css::sheet::SheetLinkMode nMode ) override;
911
912
                            // XSheetAuditing
913
    virtual sal_Bool SAL_CALL hideDependents( const css::table::CellAddress& aPosition ) override;
914
    virtual sal_Bool SAL_CALL hidePrecedents( const css::table::CellAddress& aPosition ) override;
915
    virtual sal_Bool SAL_CALL showDependents( const css::table::CellAddress& aPosition ) override;
916
    virtual sal_Bool SAL_CALL showPrecedents( const css::table::CellAddress& aPosition ) override;
917
    virtual sal_Bool SAL_CALL showErrors( const css::table::CellAddress& aPosition ) override;
918
    virtual sal_Bool SAL_CALL showInvalid() override;
919
    virtual void SAL_CALL   clearArrows() override;
920
921
                            // XSheetOutline
922
    virtual void SAL_CALL   group( const css::table::CellRangeAddress& aRange,
923
                                css::table::TableOrientation nOrientation ) override;
924
    virtual void SAL_CALL   ungroup( const css::table::CellRangeAddress& aRange,
925
                                css::table::TableOrientation nOrientation ) override;
926
    virtual void SAL_CALL   autoOutline( const css::table::CellRangeAddress& aRange ) override;
927
    virtual void SAL_CALL   clearOutline() override;
928
    virtual void SAL_CALL   hideDetail( const css::table::CellRangeAddress& aRange ) override;
929
    virtual void SAL_CALL   showDetail( const css::table::CellRangeAddress& aRange ) override;
930
    virtual void SAL_CALL   showLevel( sal_Int16 nLevel,
931
                                css::table::TableOrientation nOrientation ) override;
932
933
                            // XProtectable
934
    virtual void SAL_CALL   protect( const OUString& aPassword ) override;
935
    virtual void SAL_CALL   unprotect( const OUString& aPassword ) override;
936
    virtual sal_Bool SAL_CALL isProtected() override;
937
938
                            // XScenario
939
    virtual sal_Bool SAL_CALL getIsScenario() override;
940
    virtual OUString SAL_CALL getScenarioComment() override;
941
    virtual void SAL_CALL   setScenarioComment( const OUString& aScenarioComment ) override;
942
    virtual void SAL_CALL   addRanges( const css::uno::Sequence<
943
                                css::table::CellRangeAddress >& aRanges ) override;
944
    virtual void SAL_CALL   apply() override;
945
                            // XScenarioEnhanced
946
    virtual css::uno::Sequence< css::table::CellRangeAddress > SAL_CALL
947
                            getRanges(  ) override;
948
949
                            // XExternalSheetName
950
    virtual void SAL_CALL   setExternalName( const OUString& aUrl, const OUString& aSheetName ) override;
951
952
                            // XEventsSupplier
953
    virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents() override;
954
955
                            // XPropertySet override due to sheet properties
956
    virtual css::uno::Reference< css::beans::XPropertySetInfo >
957
                            SAL_CALL getPropertySetInfo() override;
958
959
                            // XServiceInfo
960
    virtual OUString SAL_CALL getImplementationName() override;
961
    virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
962
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
963
964
    rtl::Reference< ScScenariosObj > getScScenarios() const;
965
966
protected:
967
    void AdjustUpdatedRanges(UpdateRefMode mode) override;
968
};
969
970
using ScTableColumnObj_BASE = cppu::ImplInheritanceHelper<ScCellRangeObj,
971
                                                          css::container::XNamed>;
972
class ScTableColumnObj final : public ScTableColumnObj_BASE
973
{
974
private:
975
    const SfxItemPropertySet*       pColPropSet;
976
977
    virtual const SfxItemPropertyMap& GetItemPropertyMap() override;
978
    virtual void GetOnePropertyValue( const SfxItemPropertyMapEntry* pEntry,
979
                                css::uno::Any& ) override;
980
    virtual void            SetOnePropertyValue( const SfxItemPropertyMapEntry* pEntry,
981
                                                const css::uno::Any& aValue ) override;
982
983
public:
984
                            ScTableColumnObj(ScDocShell* pDocSh, SCCOL nCol, SCTAB nTab);
985
    virtual                 ~ScTableColumnObj() override;
986
987
                            // XNamed
988
    virtual OUString SAL_CALL getName() override;
989
    virtual void SAL_CALL   setName( const OUString& aName ) override;
990
991
                            // XPropertySet override due to column properties
992
    virtual css::uno::Reference< css::beans::XPropertySetInfo >
993
                            SAL_CALL getPropertySetInfo() override;
994
995
                            // XServiceInfo
996
    virtual OUString SAL_CALL getImplementationName() override;
997
    virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
998
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
999
1000
protected:
1001
    void AdjustUpdatedRanges(UpdateRefMode mode) override;
1002
};
1003
1004
class ScTableRowObj final : public ScCellRangeObj
1005
{
1006
private:
1007
    const SfxItemPropertySet*       pRowPropSet;
1008
1009
    virtual const SfxItemPropertyMap& GetItemPropertyMap() override;
1010
    virtual void GetOnePropertyValue( const SfxItemPropertyMapEntry* pEntry,
1011
                                css::uno::Any& ) override;
1012
    virtual void            SetOnePropertyValue( const SfxItemPropertyMapEntry* pEntry,
1013
                                                const css::uno::Any& aValue ) override;
1014
1015
public:
1016
                            ScTableRowObj(ScDocShell* pDocSh, SCROW nRow, SCTAB nTab);
1017
    virtual                 ~ScTableRowObj() override;
1018
1019
                            // XPropertySet override due to row properties
1020
    virtual css::uno::Reference< css::beans::XPropertySetInfo >
1021
                            SAL_CALL getPropertySetInfo() override;
1022
1023
                            // XServiceInfo
1024
    virtual OUString SAL_CALL getImplementationName() override;
1025
    virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
1026
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
1027
1028
protected:
1029
    void AdjustUpdatedRanges(UpdateRefMode mode) override;
1030
};
1031
1032
class ScCellsObj final : public cppu::WeakImplHelper<
1033
                            css::container::XEnumerationAccess,
1034
                            css::lang::XServiceInfo >,
1035
                        public SfxListener
1036
{
1037
private:
1038
    ScDocShell*             pDocShell;
1039
    ScRangeList             aRanges;
1040
1041
public:
1042
                            ScCellsObj(ScDocShell* pDocSh, ScRangeList aR);
1043
    virtual                 ~ScCellsObj() override;
1044
1045
    virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
1046
1047
                            // XEnumerationAccess
1048
    virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
1049
                            createEnumeration() override;
1050
1051
                            // XElementAccess
1052
    virtual css::uno::Type SAL_CALL getElementType() override;
1053
    virtual sal_Bool SAL_CALL hasElements() override;
1054
1055
                            // XServiceInfo
1056
    virtual OUString SAL_CALL getImplementationName() override;
1057
    virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
1058
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
1059
};
1060
1061
class ScCellsEnumeration final : public cppu::WeakImplHelper<
1062
                                css::container::XEnumeration,
1063
                                css::lang::XServiceInfo >,
1064
                            public SfxListener
1065
{
1066
private:
1067
    ScDocShell*             pDocShell;
1068
    ScRangeList             aRanges;
1069
    ScAddress               aPos;
1070
    std::unique_ptr<ScMarkData> pMark;
1071
    bool                    bAtEnd;
1072
1073
private:
1074
    void                    Advance_Impl();
1075
    void                    CheckPos_Impl();
1076
1077
public:
1078
                            ScCellsEnumeration(ScDocShell* pDocSh, ScRangeList aR);
1079
    virtual                 ~ScCellsEnumeration() override;
1080
1081
    virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
1082
1083
                            // XEnumeration
1084
    virtual sal_Bool SAL_CALL hasMoreElements() override;
1085
    virtual css::uno::Any SAL_CALL nextElement() override;
1086
1087
                            // XServiceInfo
1088
    virtual OUString SAL_CALL getImplementationName() override;
1089
    virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
1090
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
1091
};
1092
1093
class ScCellFormatsObj final : public cppu::WeakImplHelper<
1094
                            css::container::XIndexAccess,
1095
                            css::container::XEnumerationAccess,
1096
                            css::lang::XServiceInfo >,
1097
                        public SfxListener
1098
{
1099
private:
1100
    ScDocShell*             pDocShell;
1101
    ScRange                 aTotalRange;
1102
1103
private:
1104
    rtl::Reference<ScCellRangeObj> GetObjectByIndex_Impl(tools::Long nIndex) const;
1105
1106
public:
1107
                            ScCellFormatsObj(ScDocShell* pDocSh, const ScRange& rR);
1108
    virtual                 ~ScCellFormatsObj() override;
1109
1110
    virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
1111
1112
                            // XIndexAccess
1113
    virtual sal_Int32 SAL_CALL getCount() override;
1114
    virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
1115
1116
                            // XEnumerationAccess
1117
    virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
1118
                            createEnumeration() override;
1119
1120
                            // XElementAccess
1121
    virtual css::uno::Type SAL_CALL getElementType() override;
1122
    virtual sal_Bool SAL_CALL hasElements() override;
1123
1124
                            // XServiceInfo
1125
    virtual OUString SAL_CALL getImplementationName() override;
1126
    virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
1127
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
1128
};
1129
1130
class ScCellFormatsEnumeration final : public cppu::WeakImplHelper<
1131
                                    css::container::XEnumeration,
1132
                                    css::lang::XServiceInfo >,
1133
                                 public SfxListener
1134
{
1135
private:
1136
    ScDocShell*             pDocShell;
1137
    SCTAB                   nTab;
1138
    std::unique_ptr<ScAttrRectIterator> pIter;
1139
    ScRange                 aNext;
1140
    bool                    bAtEnd;
1141
    bool                    bDirty;
1142
1143
private:
1144
    void                    Advance_Impl();
1145
    rtl::Reference<ScCellRangeObj> NextObject_Impl();
1146
1147
public:
1148
                            ScCellFormatsEnumeration(ScDocShell* pDocSh, const ScRange& rR);
1149
    virtual                 ~ScCellFormatsEnumeration() override;
1150
1151
    virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
1152
1153
                            // XEnumeration
1154
    virtual sal_Bool SAL_CALL hasMoreElements() override;
1155
    virtual css::uno::Any SAL_CALL nextElement() override;
1156
1157
                            // XServiceInfo
1158
    virtual OUString SAL_CALL getImplementationName() override;
1159
    virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
1160
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
1161
};
1162
1163
class ScUniqueCellFormatsObj final : public cppu::WeakImplHelper<
1164
                            css::container::XIndexAccess,
1165
                            css::container::XEnumerationAccess,
1166
                            css::lang::XServiceInfo >,
1167
                        public SfxListener
1168
{
1169
private:
1170
    ScDocShell*                     pDocShell;
1171
    std::vector<ScRangeList>        aRangeLists;
1172
1173
public:
1174
                            ScUniqueCellFormatsObj(ScDocShell* pDocSh, const ScRange& rR);
1175
    virtual                 ~ScUniqueCellFormatsObj() override;
1176
1177
    virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
1178
1179
                            // XIndexAccess
1180
    virtual sal_Int32 SAL_CALL getCount() override;
1181
    virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
1182
1183
                            // XEnumerationAccess
1184
    virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
1185
                            createEnumeration() override;
1186
1187
                            // XElementAccess
1188
    virtual css::uno::Type SAL_CALL getElementType() override;
1189
    virtual sal_Bool SAL_CALL hasElements() override;
1190
1191
                            // XServiceInfo
1192
    virtual OUString SAL_CALL getImplementationName() override;
1193
    virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
1194
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
1195
};
1196
1197
class ScUniqueCellFormatsEnumeration final : public cppu::WeakImplHelper<
1198
                                    css::container::XEnumeration,
1199
                                    css::lang::XServiceInfo >,
1200
                                 public SfxListener
1201
{
1202
private:
1203
    std::vector<ScRangeList>        aRangeLists;
1204
    ScDocShell*                     pDocShell;
1205
    sal_Int32                       nCurrentPosition;
1206
1207
public:
1208
                            ScUniqueCellFormatsEnumeration(ScDocShell* pDocShell, std::vector<ScRangeList>&& rRangeLists);
1209
    virtual                 ~ScUniqueCellFormatsEnumeration() override;
1210
1211
    virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
1212
1213
                            // XEnumeration
1214
    virtual sal_Bool SAL_CALL hasMoreElements() override;
1215
    virtual css::uno::Any SAL_CALL nextElement() override;
1216
1217
                            // XServiceInfo
1218
    virtual OUString SAL_CALL getImplementationName() override;
1219
    virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
1220
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
1221
};
1222
1223
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */