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 #ifndef INCLUDED_SC_INC_NAMEUNO_HXX
21 #define INCLUDED_SC_INC_NAMEUNO_HXX
22 
23 #include <svl/lstner.hxx>
24 #include "address.hxx"
25 #include "rangenam.hxx"
26 #include <formula/grammar.hxx>
27 #include <com/sun/star/sheet/XLabelRange.hpp>
28 #include <com/sun/star/sheet/XLabelRanges.hpp>
29 #include <com/sun/star/sheet/XCellRangeReferrer.hpp>
30 #include <com/sun/star/sheet/XNamedRange.hpp>
31 #include <com/sun/star/sheet/XFormulaTokens.hpp>
32 #include <com/sun/star/sheet/XNamedRanges.hpp>
33 #include <com/sun/star/container/XEnumerationAccess.hpp>
34 #include <com/sun/star/lang/XServiceInfo.hpp>
35 #include <com/sun/star/lang/XUnoTunnel.hpp>
36 #include <com/sun/star/beans/XPropertySet.hpp>
37 #include <com/sun/star/document/XActionLockable.hpp>
38 #include <cppuhelper/implbase.hxx>
39 #include <rtl/ref.hxx>
40 
41 namespace com::sun::star::container { class XNamed; }
42 
43 class ScDocShell;
44 class ScNamedRangesObj;
45 
46 class SC_DLLPUBLIC ScNamedRangeObj final : public ::cppu::WeakImplHelper<
47  css::sheet::XNamedRange,
48  css::sheet::XFormulaTokens,
49  css::sheet::XCellRangeReferrer,
50  css::beans::XPropertySet,
51  css::lang::XUnoTunnel,
52  css::lang::XServiceInfo >,
53  public SfxListener
54 {
55 private:
58  OUString aName;
59  css::uno::Reference< css::container::XNamed > mxSheet;
60 
61 private:
62 friend class ScVbaName;
63  ScRangeData* GetRangeData_Impl();
64  void Modify_Impl( const OUString* pNewName,
65  const ScTokenArray* pNewTokens, const OUString* pNewContent,
66  const ScAddress* pNewPos, const ScRangeData::Type* pNewType,
67  const formula::FormulaGrammar::Grammar eGrammar );
68  SCTAB GetTab_Impl();
69 
70 public:
71  ScNamedRangeObj( rtl::Reference< ScNamedRangesObj > const & xParent, ScDocShell* pDocSh, const OUString& rNm,
72  css::uno::Reference< css::container::XNamed > const & xSheet = css::uno::Reference< css::container::XNamed > ());
73  virtual ~ScNamedRangeObj() override;
74 
75  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
76 
78  virtual OUString SAL_CALL getContent() override;
79  virtual void SAL_CALL setContent( const OUString& aContent ) override;
80  virtual css::table::CellAddress SAL_CALL getReferencePosition() override;
81  virtual void SAL_CALL setReferencePosition(
82  const css::table::CellAddress& aReferencePosition ) override;
83  virtual sal_Int32 SAL_CALL getType() override;
84  virtual void SAL_CALL setType( sal_Int32 nType ) override;
85 
87  virtual css::uno::Sequence< css::sheet::FormulaToken > SAL_CALL getTokens() override;
88  virtual void SAL_CALL setTokens( const css::uno::Sequence< css::sheet::FormulaToken >& aTokens ) override;
89 
91  virtual OUString SAL_CALL getName() override;
92  virtual void SAL_CALL setName( const OUString& aName ) override;
93 
95  virtual css::uno::Reference< css::table::XCellRange > SAL_CALL
96  getReferredCells() override;
97 
99  virtual css::uno::Reference< css::beans::XPropertySetInfo >
100  SAL_CALL getPropertySetInfo() override;
101  virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
102  const css::uno::Any& aValue ) override;
103  virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
104  virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
105  const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
106  virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
107  const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
108  virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
109  const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
110  virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
111  const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
112 
114  virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
115 
116  static const css::uno::Sequence<sal_Int8>& getUnoTunnelId();
117 
119  virtual OUString SAL_CALL getImplementationName() override;
120  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
121  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
122 };
123 
124 class ScNamedRangesObj : public ::cppu::WeakImplHelper<
125  css::sheet::XNamedRanges,
126  css::container::XEnumerationAccess,
127  css::container::XIndexAccess,
128  css::beans::XPropertySet,
129  css::document::XActionLockable,
130  css::lang::XServiceInfo >,
131  public SfxListener
132 {
133 private:
134 
139 
140  virtual ScNamedRangeObj* GetObjectByIndex_Impl(sal_uInt16 nIndex) = 0;
141  virtual ScNamedRangeObj* GetObjectByName_Impl(const OUString& aName) = 0;
142 
143  virtual ScRangeName* GetRangeName_Impl() = 0;
144  virtual SCTAB GetTab_Impl() = 0;
145 
146 protected:
147 
150  void lock();
151 
153  void unlock();
154 
155 public:
156  ScNamedRangesObj(ScDocShell* pDocSh);
157  virtual ~ScNamedRangesObj() override;
158 
159  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
160 
162 
164  virtual void SAL_CALL addNewByName( const OUString& aName, const OUString& aContent,
165  const css::table::CellAddress& aPosition, sal_Int32 nType ) override;
166  virtual void SAL_CALL addNewFromTitles( const css::table::CellRangeAddress& aSource,
167  css::sheet::Border aBorder ) override;
168  virtual void SAL_CALL removeByName( const OUString& aName ) override;
169  virtual void SAL_CALL outputList( const css::table::CellAddress& aOutputPosition ) override;
170 
172  virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
173  virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
174  virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
175 
177  virtual sal_Int32 SAL_CALL getCount() override;
178  virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
179 
181  virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
182  createEnumeration() override;
183 
185  virtual css::uno::Type SAL_CALL getElementType() override;
186  virtual sal_Bool SAL_CALL hasElements() override;
187 
189  virtual css::uno::Reference< css::beans::XPropertySetInfo >
190  SAL_CALL getPropertySetInfo() override;
191  virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
192  const css::uno::Any& aValue ) override;
193  virtual css::uno::Any SAL_CALL getPropertyValue(
194  const OUString& PropertyName ) override;
195  virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
196  const css::uno::Reference<
197  css::beans::XPropertyChangeListener >& xListener ) override;
198  virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
199  const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
200  virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
201  const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
202  virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
203  const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
204 
206  virtual sal_Bool SAL_CALL isActionLocked() override;
207  virtual void SAL_CALL addActionLock() override;
208  virtual void SAL_CALL removeActionLock() override;
209  virtual void SAL_CALL setActionLocks( sal_Int16 nLock ) override;
210  virtual sal_Int16 SAL_CALL resetActionLocks() override;
211 
213  virtual OUString SAL_CALL getImplementationName() override;
214  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
215  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
216 };
217 
219 {
220 private:
221 
222  virtual ScNamedRangeObj* GetObjectByIndex_Impl(sal_uInt16 nIndex) override;
223  virtual ScNamedRangeObj* GetObjectByName_Impl(const OUString& aName) override;
224 
225  virtual ScRangeName* GetRangeName_Impl() override;
226  virtual SCTAB GetTab_Impl() override;
227 
228 public:
230  virtual ~ScGlobalNamedRangesObj() override;
231 };
232 
234 {
235 private:
236 
237  virtual ScNamedRangeObj* GetObjectByIndex_Impl(sal_uInt16 nIndex) override;
238  virtual ScNamedRangeObj* GetObjectByName_Impl(const OUString& aName) override;
239 
240  virtual ScRangeName* GetRangeName_Impl() override;
241  virtual SCTAB GetTab_Impl() override;
242 
243  css::uno::Reference< css::container::XNamed > mxSheet;
244 public:
245  ScLocalNamedRangesObj(ScDocShell* pDocSh, css::uno::Reference< css::container::XNamed > const & xNamed );
246  virtual ~ScLocalNamedRangesObj() override;
247 };
248 
249 class ScLabelRangeObj final : public ::cppu::WeakImplHelper<
250  css::sheet::XLabelRange,
251  css::lang::XServiceInfo >,
252  public SfxListener
253 {
254 private:
256  bool bColumn;
258 
259 private:
261  void Modify_Impl( const ScRange* pLabel, const ScRange* pData );
262 
263 public:
264  ScLabelRangeObj(ScDocShell* pDocSh, bool bCol, const ScRange& rR);
265  virtual ~ScLabelRangeObj() override;
266 
267  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
268 
270  virtual css::table::CellRangeAddress SAL_CALL getLabelArea() override;
271  virtual void SAL_CALL setLabelArea( const css::table::CellRangeAddress& aLabelArea ) override;
272  virtual css::table::CellRangeAddress SAL_CALL getDataArea() override;
273  virtual void SAL_CALL setDataArea( const css::table::CellRangeAddress& aDataArea ) override;
274 
276  virtual OUString SAL_CALL getImplementationName() override;
277  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
278  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
279 };
280 
281 class ScLabelRangesObj final : public ::cppu::WeakImplHelper<
282  css::sheet::XLabelRanges,
283  css::container::XEnumerationAccess,
284  css::lang::XServiceInfo >,
285  public SfxListener
286 {
287 private:
289  bool bColumn;
290 
291  ScLabelRangeObj* GetObjectByIndex_Impl(size_t nIndex);
292 
293 public:
294  ScLabelRangesObj(ScDocShell* pDocSh, bool bCol);
295  virtual ~ScLabelRangesObj() override;
296 
297  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
298 
300  virtual void SAL_CALL addNew( const css::table::CellRangeAddress& aLabelArea,
301  const css::table::CellRangeAddress& aDataArea ) override;
302  virtual void SAL_CALL removeByIndex( sal_Int32 nIndex ) override;
303 
305  virtual sal_Int32 SAL_CALL getCount() override;
306  virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
307 
309  virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
310  createEnumeration() override;
311 
313  virtual css::uno::Type SAL_CALL getElementType() override;
314  virtual sal_Bool SAL_CALL hasElements() override;
315 
317  virtual OUString SAL_CALL getImplementationName() override;
318  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
319  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
320 };
321 
322 #endif
323 
324 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual OUString SAL_CALL getName() override
Definition: vbaname.cxx:51
virtual css::table::CellRangeAddress SAL_CALL getLabelArea() override
XLabelRange.
Definition: nameuno.cxx:966
OUString getContent(const formula::FormulaGrammar::Grammar eGrammar)
Definition: vbaname.cxx:85
virtual sal_Bool SAL_CALL hasElements() override
Definition: nameuno.cxx:1148
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
sal_Int32 nIndex
virtual void SAL_CALL addNewByName(const OUString &aName, const OUString &aContent, const css::table::CellAddress &aPosition, sal_Int32 nType) override
XNamedRanges.
Definition: nameuno.cxx:473
virtual void SAL_CALL setName(const OUString &rName) override
Definition: vbaname.cxx:57
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
XEnumerationAccess.
Definition: nameuno.cxx:571
virtual ScRangeName * GetRangeName_Impl() override
Definition: nameuno.cxx:875
virtual void SAL_CALL addNew(const css::table::CellRangeAddress &aLabelArea, const css::table::CellRangeAddress &aDataArea) override
XLabelRanges.
Definition: nameuno.cxx:1044
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
XNameAccess.
Definition: nameuno.cxx:647
ScRangePair * GetData_Impl()
Definition: nameuno.cxx:914
css::uno::Reference< css::container::XNamed > mxSheet
Definition: nameuno.hxx:243
bool getType(BSTR name, Type &type)
ScLabelRangesObj(ScDocShell *pDocSh, bool bCol)
Definition: nameuno.cxx:1002
virtual void SAL_CALL setDataArea(const css::table::CellRangeAddress &aDataArea) override
Definition: nameuno.cxx:994
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: nameuno.cxx:1131
rtl::Reference< ScNamedRangesObj > mxParent
Definition: nameuno.hxx:56
virtual ~ScLabelRangeObj() override
Definition: nameuno.cxx:896
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual ScNamedRangeObj * GetObjectByIndex_Impl(sal_uInt16 nIndex) override
Definition: nameuno.cxx:788
virtual ScNamedRangeObj * GetObjectByIndex_Impl(sal_uInt16 nIndex)=0
css::uno::Reference< css::container::XNamed > mxSheet
Definition: nameuno.hxx:59
virtual void SAL_CALL removeByName(const OUString &aName) override
Definition: nameuno.cxx:537
ScLabelRangeObj * GetObjectByIndex_Impl(size_t nIndex)
Definition: nameuno.cxx:1029
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual ScRangeName * GetRangeName_Impl()=0
ScRange aRange
criterion to find range
Definition: nameuno.hxx:257
virtual void SAL_CALL removeActionLock() override
Definition: nameuno.cxx:729
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: nameuno.cxx:461
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: nameuno.cxx:596
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
virtual css::uno::Type SAL_CALL getElementType() override
XElementAccess.
Definition: nameuno.cxx:1141
OUString aName
Definition: nameuno.hxx:58
ScDocShell * pDocShell
Definition: nameuno.hxx:148
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
bool IsModifyAndBroadcast() const
Definition: nameuno.hxx:161
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
ScDocShell * pDocShell
Definition: nameuno.hxx:57
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: nameuno.cxx:904
virtual sal_Int16 SAL_CALL resetActionLocks() override
Definition: nameuno.cxx:764
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual ~ScNamedRangesObj() override
Definition: nameuno.cxx:453
ScNamedRangesObj(ScDocShell *pDocSh)
Definition: nameuno.cxx:446
void Modify_Impl(const ScRange *pLabel, const ScRange *pData)
Definition: nameuno.cxx:927
virtual css::uno::Type SAL_CALL getElementType() override
XElementAccess.
Definition: nameuno.cxx:606
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
XPropertySet.
Definition: nameuno.cxx:618
virtual void SAL_CALL addNewFromTitles(const css::table::CellRangeAddress &aSource, css::sheet::Border aBorder) override
Definition: nameuno.cxx:513
unsigned char sal_Bool
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: nameuno.cxx:1017
ScDocShell * pDocShell
Definition: nameuno.hxx:288
bool mbModifyAndBroadcast
if true, adding new name or modifying existing one will set the document 'modified' and broadcast the...
Definition: nameuno.hxx:138
virtual ScNamedRangeObj * GetObjectByName_Impl(const OUString &aName)=0
bool setPropertyValue(uno::Sequence< beans::PropertyValue > &aProp, const OUString &aName, const uno::Any &aValue)
virtual sal_Int32 SAL_CALL getCount() override
XIndexAccess.
Definition: nameuno.cxx:579
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: nameuno.cxx:625
void unlock()
called from the XActionLockable interface methods on final unlock
Definition: nameuno.cxx:703
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
XEnumerationAccess.
Definition: nameuno.cxx:1110
void setContent(const OUString &sContent, const formula::FormulaGrammar::Grammar eGrammar)
Definition: vbaname.cxx:100
virtual OUString SAL_CALL getImplementationName() override
XServiceInfo.
ScLocalNamedRangesObj(ScDocShell *pDocSh, css::uno::Reference< css::container::XNamed > const &xNamed)
Definition: nameuno.cxx:827
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: nameuno.cxx:680
virtual SCTAB GetTab_Impl() override
Definition: nameuno.cxx:881
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint)
virtual css::table::CellRangeAddress SAL_CALL getDataArea() override
Definition: nameuno.cxx:984
virtual sal_Bool SAL_CALL hasElements() override
Definition: nameuno.cxx:612
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: nameuno.cxx:634
virtual void SAL_CALL outputList(const css::table::CellAddress &aOutputPosition) override
Definition: nameuno.cxx:561
virtual SCTAB GetTab_Impl() override
Definition: nameuno.cxx:822
virtual ~ScGlobalNamedRangesObj() override
Definition: nameuno.cxx:783
ScLabelRangeObj(ScDocShell *pDocSh, bool bCol, const ScRange &rR)
Definition: nameuno.cxx:888
void lock()
called from the XActionLockable interface methods on initial locking
Definition: nameuno.cxx:697
virtual void SAL_CALL removeByIndex(sal_Int32 nIndex) override
Definition: nameuno.cxx:1076
virtual void SAL_CALL setLabelArea(const css::table::CellRangeAddress &aLabelArea) override
Definition: nameuno.cxx:976
virtual void SAL_CALL addActionLock() override
Definition: nameuno.cxx:716
virtual sal_Bool SAL_CALL isActionLocked() override
XActionLockable.
Definition: nameuno.cxx:710
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:401
virtual ScRangeName * GetRangeName_Impl() override
Definition: nameuno.cxx:817
virtual ~ScLocalNamedRangesObj() override
Definition: nameuno.cxx:834
virtual OUString SAL_CALL getImplementationName() override
XServiceInfo.
virtual sal_Int32 SAL_CALL getCount() override
XIndexAccess.
Definition: nameuno.cxx:1118
virtual ScNamedRangeObj * GetObjectByName_Impl(const OUString &aName) override
Definition: nameuno.cxx:810
virtual ScNamedRangeObj * GetObjectByIndex_Impl(sal_uInt16 nIndex) override
Definition: nameuno.cxx:847
virtual ~ScLabelRangesObj() override
Definition: nameuno.cxx:1009
virtual OUString SAL_CALL getImplementationName() override
virtual SCTAB GetTab_Impl()=0
struct _ADOIndex Index
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: nameuno.cxx:657
#define SC_DLLPUBLIC
Definition: scdllapi.h:28
virtual OUString SAL_CALL getImplementationName() override
XServiceInfo.
virtual ScNamedRangeObj * GetObjectByName_Impl(const OUString &aName) override
Definition: nameuno.cxx:839
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
virtual void SAL_CALL setActionLocks(sal_Int16 nLock) override
Definition: nameuno.cxx:745
ScGlobalNamedRangesObj(ScDocShell *pDocSh)
Definition: nameuno.cxx:777
ScDocShell * pDocShell
Definition: nameuno.hxx:255
sal_Int16 SCTAB
Definition: types.hxx:23