LibreOffice Module sc (master) 1
nameuno.hxx
Go to the documentation of this file.
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 <svl/lstner.hxx>
23#include "address.hxx"
24#include "rangenam.hxx"
25#include <formula/grammar.hxx>
26#include <com/sun/star/sheet/XLabelRange.hpp>
27#include <com/sun/star/sheet/XLabelRanges.hpp>
28#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
29#include <com/sun/star/sheet/XNamedRange.hpp>
30#include <com/sun/star/sheet/XFormulaTokens.hpp>
31#include <com/sun/star/sheet/XNamedRanges.hpp>
32#include <com/sun/star/container/XEnumerationAccess.hpp>
33#include <com/sun/star/lang/XServiceInfo.hpp>
34#include <com/sun/star/beans/XPropertySet.hpp>
35#include <com/sun/star/document/XActionLockable.hpp>
37#include <rtl/ref.hxx>
38
39namespace com::sun::star::container { class XNamed; }
40
41class ScDocShell;
43
44class SC_DLLPUBLIC ScNamedRangeObj final : public ::cppu::WeakImplHelper<
45 css::sheet::XNamedRange,
46 css::sheet::XFormulaTokens,
47 css::sheet::XCellRangeReferrer,
48 css::beans::XPropertySet,
49 css::lang::XServiceInfo >,
50 public SfxListener
51{
52private:
55 OUString aName;
56 css::uno::Reference< css::container::XNamed > mxSheet;
57
58private:
59friend class ScVbaName;
60 ScRangeData* GetRangeData_Impl();
61 void Modify_Impl( const OUString* pNewName,
62 const ScTokenArray* pNewTokens, const OUString* pNewContent,
63 const ScAddress* pNewPos, const ScRangeData::Type* pNewType,
64 const formula::FormulaGrammar::Grammar eGrammar );
65 SCTAB GetTab_Impl();
66
67public:
69 css::uno::Reference< css::container::XNamed > const & xSheet = css::uno::Reference< css::container::XNamed > ());
70 virtual ~ScNamedRangeObj() override;
71
72 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
73
75 virtual OUString SAL_CALL getContent() override;
76 virtual void SAL_CALL setContent( const OUString& aContent ) override;
77 virtual css::table::CellAddress SAL_CALL getReferencePosition() override;
78 virtual void SAL_CALL setReferencePosition(
79 const css::table::CellAddress& aReferencePosition ) override;
80 virtual sal_Int32 SAL_CALL getType() override;
81 virtual void SAL_CALL setType( sal_Int32 nType ) override;
82
84 virtual css::uno::Sequence< css::sheet::FormulaToken > SAL_CALL getTokens() override;
85 virtual void SAL_CALL setTokens( const css::uno::Sequence< css::sheet::FormulaToken >& aTokens ) override;
86
88 virtual OUString SAL_CALL getName() override;
89 virtual void SAL_CALL setName( const OUString& aName ) override;
90
92 virtual css::uno::Reference< css::table::XCellRange > SAL_CALL
93 getReferredCells() override;
94
96 virtual css::uno::Reference< css::beans::XPropertySetInfo >
97 SAL_CALL getPropertySetInfo() override;
98 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
99 const css::uno::Any& aValue ) override;
100 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
101 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
102 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
103 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
104 const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
105 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
106 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
107 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
108 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
109
111 virtual OUString SAL_CALL getImplementationName() override;
112 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
113 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
114};
115
116class ScNamedRangesObj : public ::cppu::WeakImplHelper<
117 css::sheet::XNamedRanges,
118 css::container::XEnumerationAccess,
119 css::container::XIndexAccess,
120 css::beans::XPropertySet,
121 css::document::XActionLockable,
122 css::lang::XServiceInfo >,
123 public SfxListener
124{
125private:
126
131
133 virtual rtl::Reference<ScNamedRangeObj> GetObjectByName_Impl(const OUString& aName) = 0;
134
136 virtual SCTAB GetTab_Impl() = 0;
137
138protected:
139
142 void lock();
143
145 void unlock();
146
147public:
149 virtual ~ScNamedRangesObj() override;
150
151 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
152
154
156 virtual void SAL_CALL addNewByName( const OUString& aName, const OUString& aContent,
157 const css::table::CellAddress& aPosition, sal_Int32 nType ) override;
158 virtual void SAL_CALL addNewFromTitles( const css::table::CellRangeAddress& aSource,
159 css::sheet::Border aBorder ) override;
160 virtual void SAL_CALL removeByName( const OUString& aName ) override;
161 virtual void SAL_CALL outputList( const css::table::CellAddress& aOutputPosition ) override;
162
164 virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
165 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
166 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
167
169 virtual sal_Int32 SAL_CALL getCount() override;
170 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
171
173 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
174 createEnumeration() override;
175
177 virtual css::uno::Type SAL_CALL getElementType() override;
178 virtual sal_Bool SAL_CALL hasElements() override;
179
181 virtual css::uno::Reference< css::beans::XPropertySetInfo >
182 SAL_CALL getPropertySetInfo() override;
183 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
184 const css::uno::Any& aValue ) override;
185 virtual css::uno::Any SAL_CALL getPropertyValue(
186 const OUString& PropertyName ) override;
187 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
188 const css::uno::Reference<
189 css::beans::XPropertyChangeListener >& xListener ) override;
190 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
191 const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
192 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
193 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
194 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
195 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
196
198 virtual sal_Bool SAL_CALL isActionLocked() override;
199 virtual void SAL_CALL addActionLock() override;
200 virtual void SAL_CALL removeActionLock() override;
201 virtual void SAL_CALL setActionLocks( sal_Int16 nLock ) override;
202 virtual sal_Int16 SAL_CALL resetActionLocks() override;
203
205 virtual OUString SAL_CALL getImplementationName() override;
206 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
207 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
208};
209
211{
212private:
213
215 virtual rtl::Reference<ScNamedRangeObj> GetObjectByName_Impl(const OUString& aName) override;
216
217 virtual ScRangeName* GetRangeName_Impl() override;
218 virtual SCTAB GetTab_Impl() override;
219
220public:
222 virtual ~ScGlobalNamedRangesObj() override;
223};
224
226{
227private:
228
230 virtual rtl::Reference<ScNamedRangeObj> GetObjectByName_Impl(const OUString& aName) override;
231
232 virtual ScRangeName* GetRangeName_Impl() override;
233 virtual SCTAB GetTab_Impl() override;
234
235 css::uno::Reference< css::container::XNamed > mxSheet;
236public:
237 ScLocalNamedRangesObj(ScDocShell* pDocSh, css::uno::Reference< css::container::XNamed > xNamed );
238 virtual ~ScLocalNamedRangesObj() override;
239};
240
241class ScLabelRangeObj final : public ::cppu::WeakImplHelper<
242 css::sheet::XLabelRange,
243 css::lang::XServiceInfo >,
244 public SfxListener
245{
246private:
250
251private:
253 void Modify_Impl( const ScRange* pLabel, const ScRange* pData );
254
255public:
256 ScLabelRangeObj(ScDocShell* pDocSh, bool bCol, const ScRange& rR);
257 virtual ~ScLabelRangeObj() override;
258
259 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
260
262 virtual css::table::CellRangeAddress SAL_CALL getLabelArea() override;
263 virtual void SAL_CALL setLabelArea( const css::table::CellRangeAddress& aLabelArea ) override;
264 virtual css::table::CellRangeAddress SAL_CALL getDataArea() override;
265 virtual void SAL_CALL setDataArea( const css::table::CellRangeAddress& aDataArea ) override;
266
268 virtual OUString SAL_CALL getImplementationName() override;
269 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
270 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
271};
272
273class ScLabelRangesObj final : public ::cppu::WeakImplHelper<
274 css::sheet::XLabelRanges,
275 css::container::XEnumerationAccess,
276 css::lang::XServiceInfo >,
277 public SfxListener
278{
279private:
282
284
285public:
286 ScLabelRangesObj(ScDocShell* pDocSh, bool bCol);
287 virtual ~ScLabelRangesObj() override;
288
289 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
290
292 virtual void SAL_CALL addNew( const css::table::CellRangeAddress& aLabelArea,
293 const css::table::CellRangeAddress& aDataArea ) override;
294 virtual void SAL_CALL removeByIndex( sal_Int32 nIndex ) override;
295
297 virtual sal_Int32 SAL_CALL getCount() override;
298 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
299
301 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
302 createEnumeration() override;
303
305 virtual css::uno::Type SAL_CALL getElementType() override;
306 virtual sal_Bool SAL_CALL hasElements() override;
307
309 virtual OUString SAL_CALL getImplementationName() override;
310 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
311 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
312};
313
314/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _ADOIndex Index
virtual OUString SAL_CALL getImplementationName() override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual ~ScGlobalNamedRangesObj() override
Definition: nameuno.cxx:774
virtual ScRangeName * GetRangeName_Impl() override
Definition: nameuno.cxx:808
virtual rtl::Reference< ScNamedRangeObj > GetObjectByName_Impl(const OUString &aName) override
Definition: nameuno.cxx:801
ScGlobalNamedRangesObj(ScDocShell *pDocSh)
Definition: nameuno.cxx:768
virtual SCTAB GetTab_Impl() override
Definition: nameuno.cxx:813
virtual rtl::Reference< ScNamedRangeObj > GetObjectByIndex_Impl(sal_uInt16 nIndex) override
Definition: nameuno.cxx:779
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual OUString SAL_CALL getImplementationName() override
XServiceInfo.
ScRange aRange
criterion to find range
Definition: nameuno.hxx:249
virtual void SAL_CALL setDataArea(const css::table::CellRangeAddress &aDataArea) override
Definition: nameuno.cxx:985
virtual css::table::CellRangeAddress SAL_CALL getLabelArea() override
XLabelRange.
Definition: nameuno.cxx:957
virtual ~ScLabelRangeObj() override
Definition: nameuno.cxx:887
virtual css::table::CellRangeAddress SAL_CALL getDataArea() override
Definition: nameuno.cxx:975
ScLabelRangeObj(ScDocShell *pDocSh, bool bCol, const ScRange &rR)
Definition: nameuno.cxx:879
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: nameuno.cxx:895
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
ScDocShell * pDocShell
Definition: nameuno.hxx:247
virtual void SAL_CALL setLabelArea(const css::table::CellRangeAddress &aLabelArea) override
Definition: nameuno.cxx:967
void Modify_Impl(const ScRange *pLabel, const ScRange *pData)
Definition: nameuno.cxx:918
ScRangePair * GetData_Impl()
Definition: nameuno.cxx:905
rtl::Reference< ScLabelRangeObj > GetObjectByIndex_Impl(size_t nIndex)
Definition: nameuno.cxx:1020
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: nameuno.cxx:1008
virtual sal_Int32 SAL_CALL getCount() override
XIndexAccess.
Definition: nameuno.cxx:1109
virtual OUString SAL_CALL getImplementationName() override
XServiceInfo.
ScLabelRangesObj(ScDocShell *pDocSh, bool bCol)
Definition: nameuno.cxx:993
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
XEnumerationAccess.
Definition: nameuno.cxx:1101
virtual sal_Bool SAL_CALL hasElements() override
Definition: nameuno.cxx:1137
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual void SAL_CALL removeByIndex(sal_Int32 nIndex) override
Definition: nameuno.cxx:1067
virtual css::uno::Type SAL_CALL getElementType() override
XElementAccess.
Definition: nameuno.cxx:1132
virtual void SAL_CALL addNew(const css::table::CellRangeAddress &aLabelArea, const css::table::CellRangeAddress &aDataArea) override
XLabelRanges.
Definition: nameuno.cxx:1035
virtual ~ScLabelRangesObj() override
Definition: nameuno.cxx:1000
ScDocShell * pDocShell
Definition: nameuno.hxx:280
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: nameuno.cxx:1122
virtual ~ScLocalNamedRangesObj() override
Definition: nameuno.cxx:825
virtual rtl::Reference< ScNamedRangeObj > GetObjectByIndex_Impl(sal_uInt16 nIndex) override
Definition: nameuno.cxx:838
virtual SCTAB GetTab_Impl() override
Definition: nameuno.cxx:872
virtual ScRangeName * GetRangeName_Impl() override
Definition: nameuno.cxx:866
css::uno::Reference< css::container::XNamed > mxSheet
Definition: nameuno.hxx:235
ScLocalNamedRangesObj(ScDocShell *pDocSh, css::uno::Reference< css::container::XNamed > xNamed)
Definition: nameuno.cxx:818
virtual rtl::Reference< ScNamedRangeObj > GetObjectByName_Impl(const OUString &aName) override
Definition: nameuno.cxx:830
ScDocShell * pDocShell
Definition: nameuno.hxx:54
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
rtl::Reference< ScNamedRangesObj > mxParent
Definition: nameuno.hxx:53
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
OUString aName
Definition: nameuno.hxx:55
css::uno::Reference< css::container::XNamed > mxSheet
Definition: nameuno.hxx:56
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
virtual ~ScNamedRangesObj() override
Definition: nameuno.cxx:429
virtual void SAL_CALL outputList(const css::table::CellAddress &aOutputPosition) override
Definition: nameuno.cxx:553
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
XNameAccess.
Definition: nameuno.cxx:638
virtual void SAL_CALL addNewFromTitles(const css::table::CellRangeAddress &aSource, css::sheet::Border aBorder) override
Definition: nameuno.cxx:505
virtual void SAL_CALL setActionLocks(sal_Int16 nLock) override
Definition: nameuno.cxx:736
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: nameuno.cxx:437
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: nameuno.cxx:648
virtual ScRangeName * GetRangeName_Impl()=0
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual sal_Bool SAL_CALL isActionLocked() override
XActionLockable.
Definition: nameuno.cxx:701
ScDocShell * pDocShell
Definition: nameuno.hxx:140
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual void SAL_CALL removeActionLock() override
Definition: nameuno.cxx:720
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual SCTAB GetTab_Impl()=0
virtual void SAL_CALL addNewByName(const OUString &aName, const OUString &aContent, const css::table::CellAddress &aPosition, sal_Int32 nType) override
XNamedRanges.
Definition: nameuno.cxx:449
virtual void SAL_CALL addActionLock() override
Definition: nameuno.cxx:707
bool IsModifyAndBroadcast() const
Definition: nameuno.hxx:153
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
XPropertySet.
Definition: nameuno.cxx:609
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: nameuno.cxx:671
virtual sal_Int16 SAL_CALL resetActionLocks() override
Definition: nameuno.cxx:755
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: nameuno.cxx:588
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: nameuno.cxx:625
virtual sal_Int32 SAL_CALL getCount() override
XIndexAccess.
Definition: nameuno.cxx:571
ScNamedRangesObj(ScDocShell *pDocSh)
Definition: nameuno.cxx:422
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
virtual rtl::Reference< ScNamedRangeObj > GetObjectByName_Impl(const OUString &aName)=0
virtual OUString SAL_CALL getImplementationName() override
XServiceInfo.
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: nameuno.cxx:616
virtual css::uno::Type SAL_CALL getElementType() override
XElementAccess.
Definition: nameuno.cxx:598
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
void unlock()
called from the XActionLockable interface methods on final unlock
Definition: nameuno.cxx:694
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
XEnumerationAccess.
Definition: nameuno.cxx:563
bool mbModifyAndBroadcast
if true, adding new name or modifying existing one will set the document 'modified' and broadcast the...
Definition: nameuno.hxx:130
virtual rtl::Reference< ScNamedRangeObj > GetObjectByIndex_Impl(sal_uInt16 nIndex)=0
virtual sal_Bool SAL_CALL hasElements() override
Definition: nameuno.cxx:603
void lock()
called from the XActionLockable interface methods on initial locking
Definition: nameuno.cxx:688
virtual void SAL_CALL removeByName(const OUString &aName) override
Definition: nameuno.cxx:529
OUString getContent(const formula::FormulaGrammar::Grammar eGrammar)
Definition: vbaname.cxx:88
virtual void SAL_CALL setName(const OUString &rName) override
Definition: vbaname.cxx:60
void setContent(const OUString &sContent, const formula::FormulaGrammar::Grammar eGrammar)
Definition: vbaname.cxx:103
virtual OUString SAL_CALL getName() override
Definition: vbaname.cxx:54
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint)
sal_Int32 nIndex
OUString aName
VBAHELPER_DLLPUBLIC bool setPropertyValue(css::uno::Sequence< css::beans::PropertyValue > &aProp, const OUString &aName, const css::uno::Any &aValue)
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
bool getType(BSTR name, Type &type)
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
#define SC_DLLPUBLIC
Definition: scdllapi.h:27
unsigned char sal_Bool
sal_Int16 SCTAB
Definition: types.hxx:22