1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
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
>,
56 rtl::Reference
< ScNamedRangesObj
> mxParent
;
57 ScDocShell
* pDocShell
;
59 css::uno::Reference
< css::container::XNamed
> mxSheet
;
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
);
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
;
78 virtual OUString SAL_CALL
getContent() throw(css::uno::RuntimeException
, std::exception
) override
;
79 virtual void SAL_CALL
setContent( const OUString
& aContent
)
80 throw (css::uno::RuntimeException
,
81 std::exception
) override
;
82 virtual css::table::CellAddress SAL_CALL
getReferencePosition()
83 throw(css::uno::RuntimeException
, std::exception
) override
;
84 virtual void SAL_CALL
setReferencePosition(
85 const css::table::CellAddress
& aReferencePosition
)
86 throw (css::uno::RuntimeException
,
87 std::exception
) override
;
88 virtual sal_Int32 SAL_CALL
getType() throw(css::uno::RuntimeException
, std::exception
) override
;
89 virtual void SAL_CALL
setType( sal_Int32 nType
)
90 throw (css::uno::RuntimeException
,
91 std::exception
) override
;
94 virtual css::uno::Sequence
< css::sheet::FormulaToken
> SAL_CALL
getTokens()
95 throw (css::uno::RuntimeException
,
96 std::exception
) override
;
97 virtual void SAL_CALL
setTokens( const css::uno::Sequence
< css::sheet::FormulaToken
>& aTokens
)
98 throw (css::uno::RuntimeException
,
99 std::exception
) override
;
102 virtual OUString SAL_CALL
getName() throw(css::uno::RuntimeException
, std::exception
) override
;
103 virtual void SAL_CALL
setName( const OUString
& aName
)
104 throw (css::uno::RuntimeException
,
105 std::exception
) override
;
107 /// XCellRangeReferrer
108 virtual css::uno::Reference
< css::table::XCellRange
> SAL_CALL
109 getReferredCells() throw(css::uno::RuntimeException
, std::exception
) override
;
112 virtual css::uno::Reference
< css::beans::XPropertySetInfo
>
113 SAL_CALL
getPropertySetInfo()
114 throw(css::uno::RuntimeException
, std::exception
) override
;
115 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
,
116 const css::uno::Any
& aValue
)
117 throw(css::beans::UnknownPropertyException
,
118 css::beans::PropertyVetoException
,
119 css::lang::IllegalArgumentException
,
120 css::lang::WrappedTargetException
,
121 css::uno::RuntimeException
, std::exception
) override
;
122 virtual css::uno::Any SAL_CALL
getPropertyValue( const OUString
& PropertyName
)
123 throw(css::beans::UnknownPropertyException
,
124 css::lang::WrappedTargetException
,
125 css::uno::RuntimeException
, std::exception
) override
;
126 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
,
127 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
)
128 throw(css::beans::UnknownPropertyException
,
129 css::lang::WrappedTargetException
,
130 css::uno::RuntimeException
, std::exception
) override
;
131 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
,
132 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& aListener
)
133 throw(css::beans::UnknownPropertyException
,
134 css::lang::WrappedTargetException
,
135 css::uno::RuntimeException
, std::exception
) override
;
136 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
,
137 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
)
138 throw(css::beans::UnknownPropertyException
,
139 css::lang::WrappedTargetException
,
140 css::uno::RuntimeException
, std::exception
) override
;
141 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
,
142 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
)
143 throw(css::beans::UnknownPropertyException
,
144 css::lang::WrappedTargetException
,
145 css::uno::RuntimeException
, std::exception
) override
;
148 virtual sal_Int64 SAL_CALL
getSomething( const css::uno::Sequence
< sal_Int8
>& aIdentifier
)
149 throw(css::uno::RuntimeException
, std::exception
) override
;
151 static const css::uno::Sequence
<sal_Int8
>& getUnoTunnelId();
154 virtual OUString SAL_CALL
getImplementationName()
155 throw(css::uno::RuntimeException
, std::exception
) override
;
156 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
)
157 throw(css::uno::RuntimeException
, std::exception
) override
;
158 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames()
159 throw(css::uno::RuntimeException
, std::exception
) override
;
162 class ScNamedRangesObj
: public ::cppu::WeakImplHelper
<
163 css::sheet::XNamedRanges
,
164 css::container::XEnumerationAccess
,
165 css::container::XIndexAccess
,
166 css::beans::XPropertySet
,
167 css::document::XActionLockable
,
168 css::lang::XServiceInfo
>,
173 /** if true, adding new name or modifying existing one will set the
174 document 'modified' and broadcast the change. We turn this off during
176 bool mbModifyAndBroadcast
;
178 virtual ScNamedRangeObj
* GetObjectByIndex_Impl(sal_uInt16 nIndex
) = 0;
179 virtual ScNamedRangeObj
* GetObjectByName_Impl(const OUString
& aName
) = 0;
181 virtual ScRangeName
* GetRangeName_Impl() = 0;
182 virtual SCTAB
GetTab_Impl() = 0;
186 ScDocShell
* pDocShell
;
187 /** called from the XActionLockable interface methods on initial locking */
190 /** called from the XActionLockable interface methods on final unlock */
194 ScNamedRangesObj(ScDocShell
* pDocSh
);
195 virtual ~ScNamedRangesObj() override
;
197 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
199 bool IsModifyAndBroadcast() const { return mbModifyAndBroadcast
;}
202 virtual void SAL_CALL
addNewByName( const OUString
& aName
, const OUString
& aContent
,
203 const css::table::CellAddress
& aPosition
, sal_Int32 nType
)
204 throw (css::uno::RuntimeException
,
205 std::exception
) override
;
206 virtual void SAL_CALL
addNewFromTitles( const css::table::CellRangeAddress
& aSource
,
207 css::sheet::Border aBorder
)
208 throw(css::uno::RuntimeException
, std::exception
) override
;
209 virtual void SAL_CALL
removeByName( const OUString
& aName
)
210 throw(css::uno::RuntimeException
, std::exception
) override
;
211 virtual void SAL_CALL
outputList( const css::table::CellAddress
& aOutputPosition
)
212 throw(css::uno::RuntimeException
, std::exception
) override
;
215 virtual css::uno::Any SAL_CALL
getByName( const OUString
& aName
)
216 throw(css::container::NoSuchElementException
,
217 css::lang::WrappedTargetException
,
218 css::uno::RuntimeException
, std::exception
) override
;
219 virtual css::uno::Sequence
< OUString
> SAL_CALL
getElementNames()
220 throw(css::uno::RuntimeException
, std::exception
) override
;
221 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
)
222 throw(css::uno::RuntimeException
, std::exception
) override
;
225 virtual sal_Int32 SAL_CALL
getCount() throw(css::uno::RuntimeException
, std::exception
) override
;
226 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
)
227 throw(css::lang::IndexOutOfBoundsException
,
228 css::lang::WrappedTargetException
,
229 css::uno::RuntimeException
, std::exception
) override
;
231 /// XEnumerationAccess
232 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
233 createEnumeration() throw(css::uno::RuntimeException
, std::exception
) override
;
236 virtual css::uno::Type SAL_CALL
getElementType()
237 throw(css::uno::RuntimeException
, std::exception
) override
;
238 virtual sal_Bool SAL_CALL
hasElements() throw(css::uno::RuntimeException
, std::exception
) override
;
241 virtual css::uno::Reference
< css::beans::XPropertySetInfo
>
242 SAL_CALL
getPropertySetInfo()
243 throw(css::uno::RuntimeException
, std::exception
) override
;
244 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
,
245 const css::uno::Any
& aValue
)
246 throw(css::beans::UnknownPropertyException
,
247 css::beans::PropertyVetoException
,
248 css::lang::IllegalArgumentException
,
249 css::lang::WrappedTargetException
,
250 css::uno::RuntimeException
, std::exception
) override
;
251 virtual css::uno::Any SAL_CALL
getPropertyValue(
252 const OUString
& PropertyName
)
253 throw(css::beans::UnknownPropertyException
,
254 css::lang::WrappedTargetException
,
255 css::uno::RuntimeException
, std::exception
) override
;
256 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
,
257 const css::uno::Reference
<
258 css::beans::XPropertyChangeListener
>& xListener
)
259 throw(css::beans::UnknownPropertyException
,
260 css::lang::WrappedTargetException
,
261 css::uno::RuntimeException
, std::exception
) override
;
262 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
,
263 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& aListener
)
264 throw(css::beans::UnknownPropertyException
,
265 css::lang::WrappedTargetException
,
266 css::uno::RuntimeException
, std::exception
) override
;
267 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
,
268 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
)
269 throw(css::beans::UnknownPropertyException
,
270 css::lang::WrappedTargetException
,
271 css::uno::RuntimeException
, std::exception
) override
;
272 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
,
273 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
)
274 throw(css::beans::UnknownPropertyException
,
275 css::lang::WrappedTargetException
,
276 css::uno::RuntimeException
, std::exception
) override
;
279 virtual sal_Bool SAL_CALL
isActionLocked() throw(css::uno::RuntimeException
, std::exception
) override
;
280 virtual void SAL_CALL
addActionLock() throw(css::uno::RuntimeException
, std::exception
) override
;
281 virtual void SAL_CALL
removeActionLock() throw(css::uno::RuntimeException
, std::exception
) override
;
282 virtual void SAL_CALL
setActionLocks( sal_Int16 nLock
) throw(css::uno::RuntimeException
, std::exception
) override
;
283 virtual sal_Int16 SAL_CALL
resetActionLocks() throw(css::uno::RuntimeException
, std::exception
) override
;
286 virtual OUString SAL_CALL
getImplementationName()
287 throw(css::uno::RuntimeException
, std::exception
) override
;
288 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
)
289 throw(css::uno::RuntimeException
, std::exception
) override
;
290 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames()
291 throw(css::uno::RuntimeException
, std::exception
) override
;
294 class ScGlobalNamedRangesObj
: public ScNamedRangesObj
298 virtual ScNamedRangeObj
* GetObjectByIndex_Impl(sal_uInt16 nIndex
) override
;
299 virtual ScNamedRangeObj
* GetObjectByName_Impl(const OUString
& aName
) override
;
301 virtual ScRangeName
* GetRangeName_Impl() override
;
302 virtual SCTAB
GetTab_Impl() override
;
305 ScGlobalNamedRangesObj(ScDocShell
* pDocSh
);
306 virtual ~ScGlobalNamedRangesObj() override
;
309 class ScLocalNamedRangesObj
: public ScNamedRangesObj
313 virtual ScNamedRangeObj
* GetObjectByIndex_Impl(sal_uInt16 nIndex
) override
;
314 virtual ScNamedRangeObj
* GetObjectByName_Impl(const OUString
& aName
) override
;
316 virtual ScRangeName
* GetRangeName_Impl() override
;
317 virtual SCTAB
GetTab_Impl() override
;
319 css::uno::Reference
< css::container::XNamed
> mxSheet
;
321 ScLocalNamedRangesObj(ScDocShell
* pDocSh
, css::uno::Reference
< css::container::XNamed
> const & xNamed
);
322 virtual ~ScLocalNamedRangesObj() override
;
325 class ScLabelRangeObj
: public ::cppu::WeakImplHelper
<
326 css::sheet::XLabelRange
,
327 css::lang::XServiceInfo
>,
331 ScDocShell
* pDocShell
;
333 ScRange aRange
; ///< criterion to find range
336 ScRangePair
* GetData_Impl();
337 void Modify_Impl( const ScRange
* pLabel
, const ScRange
* pData
);
340 ScLabelRangeObj(ScDocShell
* pDocSh
, bool bCol
, const ScRange
& rR
);
341 virtual ~ScLabelRangeObj() override
;
343 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
346 virtual css::table::CellRangeAddress SAL_CALL
getLabelArea()
347 throw(css::uno::RuntimeException
, std::exception
) override
;
348 virtual void SAL_CALL
setLabelArea( const css::table::CellRangeAddress
& aLabelArea
)
349 throw(css::uno::RuntimeException
, std::exception
) override
;
350 virtual css::table::CellRangeAddress SAL_CALL
getDataArea()
351 throw(css::uno::RuntimeException
, std::exception
) override
;
352 virtual void SAL_CALL
setDataArea( const css::table::CellRangeAddress
& aDataArea
)
353 throw(css::uno::RuntimeException
, std::exception
) override
;
356 virtual OUString SAL_CALL
getImplementationName()
357 throw(css::uno::RuntimeException
, std::exception
) override
;
358 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
)
359 throw(css::uno::RuntimeException
, std::exception
) override
;
360 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames()
361 throw(css::uno::RuntimeException
, std::exception
) override
;
364 class ScLabelRangesObj
: public ::cppu::WeakImplHelper
<
365 css::sheet::XLabelRanges
,
366 css::container::XEnumerationAccess
,
367 css::lang::XServiceInfo
>,
371 ScDocShell
* pDocShell
;
374 ScLabelRangeObj
* GetObjectByIndex_Impl(size_t nIndex
);
377 ScLabelRangesObj(ScDocShell
* pDocSh
, bool bCol
);
378 virtual ~ScLabelRangesObj() override
;
380 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
383 virtual void SAL_CALL
addNew( const css::table::CellRangeAddress
& aLabelArea
,
384 const css::table::CellRangeAddress
& aDataArea
)
385 throw(css::uno::RuntimeException
, std::exception
) override
;
386 virtual void SAL_CALL
removeByIndex( sal_Int32 nIndex
)
387 throw(css::uno::RuntimeException
, std::exception
) override
;
390 virtual sal_Int32 SAL_CALL
getCount() throw(css::uno::RuntimeException
, std::exception
) override
;
391 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
)
392 throw(css::lang::IndexOutOfBoundsException
,
393 css::lang::WrappedTargetException
,
394 css::uno::RuntimeException
, std::exception
) override
;
396 /// XEnumerationAccess
397 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
398 createEnumeration() throw(css::uno::RuntimeException
, std::exception
) override
;
401 virtual css::uno::Type SAL_CALL
getElementType()
402 throw(css::uno::RuntimeException
, std::exception
) override
;
403 virtual sal_Bool SAL_CALL
hasElements() throw(css::uno::RuntimeException
, std::exception
) override
;
406 virtual OUString SAL_CALL
getImplementationName()
407 throw(css::uno::RuntimeException
, std::exception
) override
;
408 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
)
409 throw(css::uno::RuntimeException
, std::exception
) override
;
410 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames()
411 throw(css::uno::RuntimeException
, std::exception
) override
;
416 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */