Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / sc / inc / nameuno.hxx
blob62375e598007f2da20f893e02a3b7c416a2608a0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SC_INC_NAMEUNO_HXX
21 #define INCLUDED_SC_INC_NAMEUNO_HXX
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/XNamed.hpp>
34 #include <com/sun/star/container/XEnumerationAccess.hpp>
35 #include <com/sun/star/lang/XServiceName.hpp>
36 #include <com/sun/star/lang/XServiceInfo.hpp>
37 #include <com/sun/star/lang/XUnoTunnel.hpp>
38 #include <com/sun/star/beans/XPropertySet.hpp>
39 #include <com/sun/star/document/XActionLockable.hpp>
40 #include <cppuhelper/implbase.hxx>
41 #include <rtl/ref.hxx>
43 class ScDocShell;
44 class ScNamedRangesObj;
46 class SC_DLLPUBLIC ScNamedRangeObj : 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
55 private:
56 rtl::Reference< ScNamedRangesObj > mxParent;
57 ScDocShell* pDocShell;
58 OUString aName;
59 css::uno::Reference< css::container::XNamed > mxSheet;
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();
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;
75 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
77 /// XNamedRange
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;
86 /// XFormulaTokens
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;
90 /// XNamed
91 virtual OUString SAL_CALL getName() override;
92 virtual void SAL_CALL setName( const OUString& aName ) override;
94 /// XCellRangeReferrer
95 virtual css::uno::Reference< css::table::XCellRange > SAL_CALL
96 getReferredCells() override;
98 /// XPropertySet
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;
113 /// XUnoTunnel
114 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
116 static const css::uno::Sequence<sal_Int8>& getUnoTunnelId();
118 /// XServiceInfo
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;
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
133 private:
135 /** if true, adding new name or modifying existing one will set the
136 document 'modified' and broadcast the change. We turn this off during
137 import. */
138 bool mbModifyAndBroadcast;
140 virtual ScNamedRangeObj* GetObjectByIndex_Impl(sal_uInt16 nIndex) = 0;
141 virtual ScNamedRangeObj* GetObjectByName_Impl(const OUString& aName) = 0;
143 virtual ScRangeName* GetRangeName_Impl() = 0;
144 virtual SCTAB GetTab_Impl() = 0;
146 protected:
148 ScDocShell* pDocShell;
149 /** called from the XActionLockable interface methods on initial locking */
150 void lock();
152 /** called from the XActionLockable interface methods on final unlock */
153 void unlock();
155 public:
156 ScNamedRangesObj(ScDocShell* pDocSh);
157 virtual ~ScNamedRangesObj() override;
159 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
161 bool IsModifyAndBroadcast() const { return mbModifyAndBroadcast;}
163 /// XNamedRanges
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;
171 /// XNameAccess
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;
176 /// XIndexAccess
177 virtual sal_Int32 SAL_CALL getCount() override;
178 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
180 /// XEnumerationAccess
181 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
182 createEnumeration() override;
184 /// XElementAccess
185 virtual css::uno::Type SAL_CALL getElementType() override;
186 virtual sal_Bool SAL_CALL hasElements() override;
188 /// XPropertySet
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;
205 /// XActionLockable
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;
212 /// XServiceInfo
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;
218 class ScGlobalNamedRangesObj: public ScNamedRangesObj
220 private:
222 virtual ScNamedRangeObj* GetObjectByIndex_Impl(sal_uInt16 nIndex) override;
223 virtual ScNamedRangeObj* GetObjectByName_Impl(const OUString& aName) override;
225 virtual ScRangeName* GetRangeName_Impl() override;
226 virtual SCTAB GetTab_Impl() override;
228 public:
229 ScGlobalNamedRangesObj(ScDocShell* pDocSh);
230 virtual ~ScGlobalNamedRangesObj() override;
233 class ScLocalNamedRangesObj: public ScNamedRangesObj
235 private:
237 virtual ScNamedRangeObj* GetObjectByIndex_Impl(sal_uInt16 nIndex) override;
238 virtual ScNamedRangeObj* GetObjectByName_Impl(const OUString& aName) override;
240 virtual ScRangeName* GetRangeName_Impl() override;
241 virtual SCTAB GetTab_Impl() override;
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;
249 class ScLabelRangeObj : public ::cppu::WeakImplHelper<
250 css::sheet::XLabelRange,
251 css::lang::XServiceInfo >,
252 public SfxListener
254 private:
255 ScDocShell* pDocShell;
256 bool bColumn;
257 ScRange aRange; ///< criterion to find range
259 private:
260 ScRangePair* GetData_Impl();
261 void Modify_Impl( const ScRange* pLabel, const ScRange* pData );
263 public:
264 ScLabelRangeObj(ScDocShell* pDocSh, bool bCol, const ScRange& rR);
265 virtual ~ScLabelRangeObj() override;
267 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
269 /// XLabelRange
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;
275 /// XServiceInfo
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;
281 class ScLabelRangesObj : public ::cppu::WeakImplHelper<
282 css::sheet::XLabelRanges,
283 css::container::XEnumerationAccess,
284 css::lang::XServiceInfo >,
285 public SfxListener
287 private:
288 ScDocShell* pDocShell;
289 bool bColumn;
291 ScLabelRangeObj* GetObjectByIndex_Impl(size_t nIndex);
293 public:
294 ScLabelRangesObj(ScDocShell* pDocSh, bool bCol);
295 virtual ~ScLabelRangesObj() override;
297 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
299 /// XLabelRanges
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;
304 /// XIndexAccess
305 virtual sal_Int32 SAL_CALL getCount() override;
306 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
308 /// XEnumerationAccess
309 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
310 createEnumeration() override;
312 /// XElementAccess
313 virtual css::uno::Type SAL_CALL getElementType() override;
314 virtual sal_Bool SAL_CALL hasElements() override;
316 /// XServiceInfo
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;
322 #endif
324 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */