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 SC_NAMEUNO_HXX
21 #define SC_NAMEUNO_HXX
23 #include <svl/lstner.hxx>
24 #include "address.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/XNamed.hpp>
33 #include <com/sun/star/container/XEnumerationAccess.hpp>
34 #include <com/sun/star/lang/XServiceName.hpp>
35 #include <com/sun/star/lang/XServiceInfo.hpp>
36 #include <com/sun/star/lang/XUnoTunnel.hpp>
37 #include <com/sun/star/beans/XPropertySet.hpp>
38 #include <com/sun/star/document/XActionLockable.hpp>
39 #include <cppuhelper/implbase2.hxx>
40 #include <cppuhelper/implbase3.hxx>
41 #include <cppuhelper/implbase5.hxx>
42 #include <cppuhelper/implbase6.hxx>
43 #include <rtl/ref.hxx>
49 class ScNamedRangesObj
;
51 class SC_DLLPUBLIC ScNamedRangeObj
: public ::cppu::WeakImplHelper6
<
52 ::com::sun::star::sheet::XNamedRange
,
53 ::com::sun::star::sheet::XFormulaTokens
,
54 ::com::sun::star::sheet::XCellRangeReferrer
,
55 ::com::sun::star::beans::XPropertySet
,
56 ::com::sun::star::lang::XUnoTunnel
,
57 ::com::sun::star::lang::XServiceInfo
>,
61 rtl::Reference
< ScNamedRangesObj
> mxParent
;
62 ScDocShell
* pDocShell
;
64 com::sun::star::uno::Reference
< com::sun::star::container::XNamed
> mxSheet
;
67 friend class ScVbaName
;
68 ScRangeData
* GetRangeData_Impl();
69 void Modify_Impl( const OUString
* pNewName
,
70 const ScTokenArray
* pNewTokens
, const OUString
* pNewContent
,
71 const ScAddress
* pNewPos
, const sal_uInt16
* pNewType
,
72 const formula::FormulaGrammar::Grammar eGrammar
);
76 ScNamedRangeObj( rtl::Reference
< ScNamedRangesObj
> xParent
, ScDocShell
* pDocSh
, const OUString
& rNm
,
77 com::sun::star::uno::Reference
< com::sun::star::container::XNamed
> xSheet
= com::sun::star::uno::Reference
< com::sun::star::container::XNamed
> ());
78 virtual ~ScNamedRangeObj();
80 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
83 virtual OUString SAL_CALL
getContent() throw(::com::sun::star::uno::RuntimeException
);
84 virtual void SAL_CALL
setContent( const OUString
& aContent
)
85 throw(::com::sun::star::uno::RuntimeException
);
86 virtual ::com::sun::star::table::CellAddress SAL_CALL
getReferencePosition()
87 throw(::com::sun::star::uno::RuntimeException
);
88 virtual void SAL_CALL
setReferencePosition(
89 const ::com::sun::star::table::CellAddress
& aReferencePosition
)
90 throw(::com::sun::star::uno::RuntimeException
);
91 virtual sal_Int32 SAL_CALL
getType() throw(::com::sun::star::uno::RuntimeException
);
92 virtual void SAL_CALL
setType( sal_Int32 nType
) throw(::com::sun::star::uno::RuntimeException
);
95 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::sheet::FormulaToken
> SAL_CALL
getTokens()
96 throw (::com::sun::star::uno::RuntimeException
);
97 virtual void SAL_CALL
setTokens( const ::com::sun::star::uno::Sequence
<
98 ::com::sun::star::sheet::FormulaToken
>& aTokens
)
99 throw (::com::sun::star::uno::RuntimeException
);
102 virtual OUString SAL_CALL
getName() throw(::com::sun::star::uno::RuntimeException
);
103 virtual void SAL_CALL
setName( const OUString
& aName
)
104 throw(::com::sun::star::uno::RuntimeException
);
106 /// XCellRangeReferrer
107 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::table::XCellRange
> SAL_CALL
108 getReferredCells() throw(::com::sun::star::uno::RuntimeException
);
111 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
>
112 SAL_CALL
getPropertySetInfo()
113 throw(::com::sun::star::uno::RuntimeException
);
114 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
,
115 const ::com::sun::star::uno::Any
& aValue
)
116 throw(::com::sun::star::beans::UnknownPropertyException
,
117 ::com::sun::star::beans::PropertyVetoException
,
118 ::com::sun::star::lang::IllegalArgumentException
,
119 ::com::sun::star::lang::WrappedTargetException
,
120 ::com::sun::star::uno::RuntimeException
);
121 virtual ::com::sun::star::uno::Any SAL_CALL
getPropertyValue(
122 const OUString
& PropertyName
)
123 throw(::com::sun::star::beans::UnknownPropertyException
,
124 ::com::sun::star::lang::WrappedTargetException
,
125 ::com::sun::star::uno::RuntimeException
);
126 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
,
127 const ::com::sun::star::uno::Reference
<
128 ::com::sun::star::beans::XPropertyChangeListener
>& xListener
)
129 throw(::com::sun::star::beans::UnknownPropertyException
,
130 ::com::sun::star::lang::WrappedTargetException
,
131 ::com::sun::star::uno::RuntimeException
);
132 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
,
133 const ::com::sun::star::uno::Reference
<
134 ::com::sun::star::beans::XPropertyChangeListener
>& aListener
)
135 throw(::com::sun::star::beans::UnknownPropertyException
,
136 ::com::sun::star::lang::WrappedTargetException
,
137 ::com::sun::star::uno::RuntimeException
);
138 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
,
139 const ::com::sun::star::uno::Reference
<
140 ::com::sun::star::beans::XVetoableChangeListener
>& aListener
)
141 throw(::com::sun::star::beans::UnknownPropertyException
,
142 ::com::sun::star::lang::WrappedTargetException
,
143 ::com::sun::star::uno::RuntimeException
);
144 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
,
145 const ::com::sun::star::uno::Reference
<
146 ::com::sun::star::beans::XVetoableChangeListener
>& aListener
)
147 throw(::com::sun::star::beans::UnknownPropertyException
,
148 ::com::sun::star::lang::WrappedTargetException
,
149 ::com::sun::star::uno::RuntimeException
);
152 virtual sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
<
153 sal_Int8
>& aIdentifier
)
154 throw(::com::sun::star::uno::RuntimeException
);
156 static const com::sun::star::uno::Sequence
<sal_Int8
>& getUnoTunnelId();
159 virtual OUString SAL_CALL
getImplementationName()
160 throw(::com::sun::star::uno::RuntimeException
);
161 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
)
162 throw(::com::sun::star::uno::RuntimeException
);
163 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames()
164 throw(::com::sun::star::uno::RuntimeException
);
168 class ScNamedRangesObj
: public ::cppu::WeakImplHelper6
<
169 ::com::sun::star::sheet::XNamedRanges
,
170 ::com::sun::star::container::XEnumerationAccess
,
171 ::com::sun::star::container::XIndexAccess
,
172 ::com::sun::star::beans::XPropertySet
,
173 ::com::sun::star::document::XActionLockable
,
174 ::com::sun::star::lang::XServiceInfo
>,
179 /** if true, adding new name or modifying existing one will set the
180 document 'modified' and broadcast the change. We turn this off during
182 sal_Bool mbModifyAndBroadcast
;
184 virtual ScNamedRangeObj
* GetObjectByIndex_Impl(sal_uInt16 nIndex
) = 0;
185 virtual ScNamedRangeObj
* GetObjectByName_Impl(const OUString
& aName
) = 0;
187 virtual ScRangeName
* GetRangeName_Impl() = 0;
188 virtual SCTAB
GetTab_Impl() = 0;
192 ScDocShell
* pDocShell
;
193 /** called from the XActionLockable interface methods on initial locking */
196 /** called from the XActionLockable interface methods on final unlock */
197 virtual void unlock();
200 ScNamedRangesObj(ScDocShell
* pDocSh
);
201 virtual ~ScNamedRangesObj();
203 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
205 bool IsModifyAndBroadcast() const;
208 virtual void SAL_CALL
addNewByName( const OUString
& aName
, const OUString
& aContent
,
209 const ::com::sun::star::table::CellAddress
& aPosition
, sal_Int32 nType
)
210 throw(::com::sun::star::uno::RuntimeException
);
211 virtual void SAL_CALL
addNewFromTitles( const ::com::sun::star::table::CellRangeAddress
& aSource
,
212 ::com::sun::star::sheet::Border aBorder
)
213 throw(::com::sun::star::uno::RuntimeException
);
214 virtual void SAL_CALL
removeByName( const OUString
& aName
)
215 throw(::com::sun::star::uno::RuntimeException
);
216 virtual void SAL_CALL
outputList( const ::com::sun::star::table::CellAddress
& aOutputPosition
)
217 throw(::com::sun::star::uno::RuntimeException
);
220 virtual ::com::sun::star::uno::Any SAL_CALL
getByName( const OUString
& aName
)
221 throw(::com::sun::star::container::NoSuchElementException
,
222 ::com::sun::star::lang::WrappedTargetException
,
223 ::com::sun::star::uno::RuntimeException
);
224 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getElementNames()
225 throw(::com::sun::star::uno::RuntimeException
);
226 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
)
227 throw(::com::sun::star::uno::RuntimeException
);
230 virtual sal_Int32 SAL_CALL
getCount() throw(::com::sun::star::uno::RuntimeException
);
231 virtual ::com::sun::star::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
)
232 throw(::com::sun::star::lang::IndexOutOfBoundsException
,
233 ::com::sun::star::lang::WrappedTargetException
,
234 ::com::sun::star::uno::RuntimeException
);
236 /// XEnumerationAccess
237 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XEnumeration
> SAL_CALL
238 createEnumeration() throw(::com::sun::star::uno::RuntimeException
);
241 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType()
242 throw(::com::sun::star::uno::RuntimeException
);
243 virtual sal_Bool SAL_CALL
hasElements() throw(::com::sun::star::uno::RuntimeException
);
246 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
>
247 SAL_CALL
getPropertySetInfo()
248 throw(::com::sun::star::uno::RuntimeException
);
249 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
,
250 const ::com::sun::star::uno::Any
& aValue
)
251 throw(::com::sun::star::beans::UnknownPropertyException
,
252 ::com::sun::star::beans::PropertyVetoException
,
253 ::com::sun::star::lang::IllegalArgumentException
,
254 ::com::sun::star::lang::WrappedTargetException
,
255 ::com::sun::star::uno::RuntimeException
);
256 virtual ::com::sun::star::uno::Any SAL_CALL
getPropertyValue(
257 const OUString
& PropertyName
)
258 throw(::com::sun::star::beans::UnknownPropertyException
,
259 ::com::sun::star::lang::WrappedTargetException
,
260 ::com::sun::star::uno::RuntimeException
);
261 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
,
262 const ::com::sun::star::uno::Reference
<
263 ::com::sun::star::beans::XPropertyChangeListener
>& xListener
)
264 throw(::com::sun::star::beans::UnknownPropertyException
,
265 ::com::sun::star::lang::WrappedTargetException
,
266 ::com::sun::star::uno::RuntimeException
);
267 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
,
268 const ::com::sun::star::uno::Reference
<
269 ::com::sun::star::beans::XPropertyChangeListener
>& aListener
)
270 throw(::com::sun::star::beans::UnknownPropertyException
,
271 ::com::sun::star::lang::WrappedTargetException
,
272 ::com::sun::star::uno::RuntimeException
);
273 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
,
274 const ::com::sun::star::uno::Reference
<
275 ::com::sun::star::beans::XVetoableChangeListener
>& aListener
)
276 throw(::com::sun::star::beans::UnknownPropertyException
,
277 ::com::sun::star::lang::WrappedTargetException
,
278 ::com::sun::star::uno::RuntimeException
);
279 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
,
280 const ::com::sun::star::uno::Reference
<
281 ::com::sun::star::beans::XVetoableChangeListener
>& aListener
)
282 throw(::com::sun::star::beans::UnknownPropertyException
,
283 ::com::sun::star::lang::WrappedTargetException
,
284 ::com::sun::star::uno::RuntimeException
);
287 virtual sal_Bool SAL_CALL
isActionLocked() throw(::com::sun::star::uno::RuntimeException
);
288 virtual void SAL_CALL
addActionLock() throw(::com::sun::star::uno::RuntimeException
);
289 virtual void SAL_CALL
removeActionLock() throw(::com::sun::star::uno::RuntimeException
);
290 virtual void SAL_CALL
setActionLocks( sal_Int16 nLock
) throw(::com::sun::star::uno::RuntimeException
);
291 virtual sal_Int16 SAL_CALL
resetActionLocks() throw(::com::sun::star::uno::RuntimeException
);
294 virtual OUString SAL_CALL
getImplementationName()
295 throw(::com::sun::star::uno::RuntimeException
);
296 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
)
297 throw(::com::sun::star::uno::RuntimeException
);
298 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames()
299 throw(::com::sun::star::uno::RuntimeException
);
302 class ScGlobalNamedRangesObj
: public ScNamedRangesObj
306 virtual ScNamedRangeObj
* GetObjectByIndex_Impl(sal_uInt16 nIndex
);
307 virtual ScNamedRangeObj
* GetObjectByName_Impl(const OUString
& aName
);
309 virtual ScRangeName
* GetRangeName_Impl();
310 virtual SCTAB
GetTab_Impl();
313 ScGlobalNamedRangesObj(ScDocShell
* pDocSh
);
314 virtual ~ScGlobalNamedRangesObj();
317 class ScLocalNamedRangesObj
: public ScNamedRangesObj
321 virtual ScNamedRangeObj
* GetObjectByIndex_Impl(sal_uInt16 nIndex
);
322 virtual ScNamedRangeObj
* GetObjectByName_Impl(const OUString
& aName
);
324 virtual ScRangeName
* GetRangeName_Impl();
325 virtual SCTAB
GetTab_Impl();
327 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNamed
> mxSheet
;
329 ScLocalNamedRangesObj(ScDocShell
* pDocSh
, ::com::sun::star::uno::Reference
< com::sun::star::container::XNamed
> xNamed
);
330 virtual ~ScLocalNamedRangesObj();
334 class ScLabelRangeObj
: public ::cppu::WeakImplHelper2
<
335 ::com::sun::star::sheet::XLabelRange
,
336 ::com::sun::star::lang::XServiceInfo
>,
340 ScDocShell
* pDocShell
;
342 ScRange aRange
; ///< criterion to find range
345 ScRangePair
* GetData_Impl();
346 void Modify_Impl( const ScRange
* pLabel
, const ScRange
* pData
);
349 ScLabelRangeObj(ScDocShell
* pDocSh
, sal_Bool bCol
, const ScRange
& rR
);
350 virtual ~ScLabelRangeObj();
352 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
355 virtual ::com::sun::star::table::CellRangeAddress SAL_CALL
getLabelArea()
356 throw(::com::sun::star::uno::RuntimeException
);
357 virtual void SAL_CALL
setLabelArea( const ::com::sun::star::table::CellRangeAddress
& aLabelArea
)
358 throw(::com::sun::star::uno::RuntimeException
);
359 virtual ::com::sun::star::table::CellRangeAddress SAL_CALL
getDataArea()
360 throw(::com::sun::star::uno::RuntimeException
);
361 virtual void SAL_CALL
setDataArea( const ::com::sun::star::table::CellRangeAddress
& aDataArea
)
362 throw(::com::sun::star::uno::RuntimeException
);
365 virtual OUString SAL_CALL
getImplementationName()
366 throw(::com::sun::star::uno::RuntimeException
);
367 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
)
368 throw(::com::sun::star::uno::RuntimeException
);
369 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames()
370 throw(::com::sun::star::uno::RuntimeException
);
374 class ScLabelRangesObj
: public ::cppu::WeakImplHelper3
<
375 ::com::sun::star::sheet::XLabelRanges
,
376 ::com::sun::star::container::XEnumerationAccess
,
377 ::com::sun::star::lang::XServiceInfo
>,
381 ScDocShell
* pDocShell
;
384 ScLabelRangeObj
* GetObjectByIndex_Impl(size_t nIndex
);
387 ScLabelRangesObj(ScDocShell
* pDocSh
, sal_Bool bCol
);
388 virtual ~ScLabelRangesObj();
390 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
393 virtual void SAL_CALL
addNew( const ::com::sun::star::table::CellRangeAddress
& aLabelArea
,
394 const ::com::sun::star::table::CellRangeAddress
& aDataArea
)
395 throw(::com::sun::star::uno::RuntimeException
);
396 virtual void SAL_CALL
removeByIndex( sal_Int32 nIndex
)
397 throw(::com::sun::star::uno::RuntimeException
);
400 virtual sal_Int32 SAL_CALL
getCount() throw(::com::sun::star::uno::RuntimeException
);
401 virtual ::com::sun::star::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
)
402 throw(::com::sun::star::lang::IndexOutOfBoundsException
,
403 ::com::sun::star::lang::WrappedTargetException
,
404 ::com::sun::star::uno::RuntimeException
);
406 /// XEnumerationAccess
407 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XEnumeration
> SAL_CALL
408 createEnumeration() throw(::com::sun::star::uno::RuntimeException
);
411 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType()
412 throw(::com::sun::star::uno::RuntimeException
);
413 virtual sal_Bool SAL_CALL
hasElements() throw(::com::sun::star::uno::RuntimeException
);
416 virtual OUString SAL_CALL
getImplementationName()
417 throw(::com::sun::star::uno::RuntimeException
);
418 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
)
419 throw(::com::sun::star::uno::RuntimeException
);
420 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames()
421 throw(::com::sun::star::uno::RuntimeException
);
429 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */