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 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 ScRangeData
* GetRangeData_Impl();
68 void Modify_Impl( const String
* pNewName
,
69 const ScTokenArray
* pNewTokens
, const String
* pNewContent
,
70 const ScAddress
* pNewPos
, const sal_uInt16
* pNewType
,
71 const formula::FormulaGrammar::Grammar eGrammar
);
75 ScNamedRangeObj( rtl::Reference
< ScNamedRangesObj
> xParent
, ScDocShell
* pDocSh
, const String
& rNm
,
76 com::sun::star::uno::Reference
< com::sun::star::container::XNamed
> xSheet
= com::sun::star::uno::Reference
< com::sun::star::container::XNamed
> ());
77 virtual ~ScNamedRangeObj();
79 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
82 virtual ::rtl::OUString SAL_CALL
getContent() throw(::com::sun::star::uno::RuntimeException
);
83 virtual void SAL_CALL
setContent( const ::rtl::OUString
& aContent
)
84 throw(::com::sun::star::uno::RuntimeException
);
85 virtual ::com::sun::star::table::CellAddress SAL_CALL
getReferencePosition()
86 throw(::com::sun::star::uno::RuntimeException
);
87 virtual void SAL_CALL
setReferencePosition(
88 const ::com::sun::star::table::CellAddress
& aReferencePosition
)
89 throw(::com::sun::star::uno::RuntimeException
);
90 virtual sal_Int32 SAL_CALL
getType() throw(::com::sun::star::uno::RuntimeException
);
91 virtual void SAL_CALL
setType( sal_Int32 nType
) throw(::com::sun::star::uno::RuntimeException
);
94 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::sheet::FormulaToken
> SAL_CALL
getTokens()
95 throw (::com::sun::star::uno::RuntimeException
);
96 virtual void SAL_CALL
setTokens( const ::com::sun::star::uno::Sequence
<
97 ::com::sun::star::sheet::FormulaToken
>& aTokens
)
98 throw (::com::sun::star::uno::RuntimeException
);
101 virtual ::rtl::OUString SAL_CALL
getName() throw(::com::sun::star::uno::RuntimeException
);
102 virtual void SAL_CALL
setName( const ::rtl::OUString
& aName
)
103 throw(::com::sun::star::uno::RuntimeException
);
105 // XCellRangeReferrer
106 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::table::XCellRange
> SAL_CALL
107 getReferredCells() throw(::com::sun::star::uno::RuntimeException
);
110 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
>
111 SAL_CALL
getPropertySetInfo()
112 throw(::com::sun::star::uno::RuntimeException
);
113 virtual void SAL_CALL
setPropertyValue( const ::rtl::OUString
& aPropertyName
,
114 const ::com::sun::star::uno::Any
& aValue
)
115 throw(::com::sun::star::beans::UnknownPropertyException
,
116 ::com::sun::star::beans::PropertyVetoException
,
117 ::com::sun::star::lang::IllegalArgumentException
,
118 ::com::sun::star::lang::WrappedTargetException
,
119 ::com::sun::star::uno::RuntimeException
);
120 virtual ::com::sun::star::uno::Any SAL_CALL
getPropertyValue(
121 const ::rtl::OUString
& PropertyName
)
122 throw(::com::sun::star::beans::UnknownPropertyException
,
123 ::com::sun::star::lang::WrappedTargetException
,
124 ::com::sun::star::uno::RuntimeException
);
125 virtual void SAL_CALL
addPropertyChangeListener( const ::rtl::OUString
& aPropertyName
,
126 const ::com::sun::star::uno::Reference
<
127 ::com::sun::star::beans::XPropertyChangeListener
>& xListener
)
128 throw(::com::sun::star::beans::UnknownPropertyException
,
129 ::com::sun::star::lang::WrappedTargetException
,
130 ::com::sun::star::uno::RuntimeException
);
131 virtual void SAL_CALL
removePropertyChangeListener( const ::rtl::OUString
& aPropertyName
,
132 const ::com::sun::star::uno::Reference
<
133 ::com::sun::star::beans::XPropertyChangeListener
>& aListener
)
134 throw(::com::sun::star::beans::UnknownPropertyException
,
135 ::com::sun::star::lang::WrappedTargetException
,
136 ::com::sun::star::uno::RuntimeException
);
137 virtual void SAL_CALL
addVetoableChangeListener( const ::rtl::OUString
& PropertyName
,
138 const ::com::sun::star::uno::Reference
<
139 ::com::sun::star::beans::XVetoableChangeListener
>& aListener
)
140 throw(::com::sun::star::beans::UnknownPropertyException
,
141 ::com::sun::star::lang::WrappedTargetException
,
142 ::com::sun::star::uno::RuntimeException
);
143 virtual void SAL_CALL
removeVetoableChangeListener( const ::rtl::OUString
& PropertyName
,
144 const ::com::sun::star::uno::Reference
<
145 ::com::sun::star::beans::XVetoableChangeListener
>& aListener
)
146 throw(::com::sun::star::beans::UnknownPropertyException
,
147 ::com::sun::star::lang::WrappedTargetException
,
148 ::com::sun::star::uno::RuntimeException
);
151 virtual sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
<
152 sal_Int8
>& aIdentifier
)
153 throw(::com::sun::star::uno::RuntimeException
);
155 static const com::sun::star::uno::Sequence
<sal_Int8
>& getUnoTunnelId();
158 virtual ::rtl::OUString SAL_CALL
getImplementationName()
159 throw(::com::sun::star::uno::RuntimeException
);
160 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
)
161 throw(::com::sun::star::uno::RuntimeException
);
162 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames()
163 throw(::com::sun::star::uno::RuntimeException
);
167 class ScNamedRangesObj
: public ::cppu::WeakImplHelper6
<
168 ::com::sun::star::sheet::XNamedRanges
,
169 ::com::sun::star::container::XEnumerationAccess
,
170 ::com::sun::star::container::XIndexAccess
,
171 ::com::sun::star::beans::XPropertySet
,
172 ::com::sun::star::document::XActionLockable
,
173 ::com::sun::star::lang::XServiceInfo
>,
178 // if true, adding new name or modifying existing one will set the
179 // document 'modified' and broadcast the change. We turn this off during
181 sal_Bool mbModifyAndBroadcast
;
183 virtual ScNamedRangeObj
* GetObjectByIndex_Impl(sal_uInt16 nIndex
) = 0;
184 virtual ScNamedRangeObj
* GetObjectByName_Impl(const ::rtl::OUString
& aName
) = 0;
186 virtual ScRangeName
* GetRangeName_Impl() = 0;
187 virtual SCTAB
GetTab_Impl() = 0;
191 ScDocShell
* pDocShell
;
192 /** called from the XActionLockable interface methods on initial locking */
195 /** called from the XActionLockable interface methods on final unlock */
196 virtual void unlock();
199 ScNamedRangesObj(ScDocShell
* pDocSh
);
200 virtual ~ScNamedRangesObj();
202 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
204 bool IsModifyAndBroadcast() const;
207 virtual void SAL_CALL
addNewByName( const ::rtl::OUString
& aName
, const ::rtl::OUString
& aContent
,
208 const ::com::sun::star::table::CellAddress
& aPosition
, sal_Int32 nType
)
209 throw(::com::sun::star::uno::RuntimeException
);
210 virtual void SAL_CALL
addNewFromTitles( const ::com::sun::star::table::CellRangeAddress
& aSource
,
211 ::com::sun::star::sheet::Border aBorder
)
212 throw(::com::sun::star::uno::RuntimeException
);
213 virtual void SAL_CALL
removeByName( const ::rtl::OUString
& aName
)
214 throw(::com::sun::star::uno::RuntimeException
);
215 virtual void SAL_CALL
outputList( const ::com::sun::star::table::CellAddress
& aOutputPosition
)
216 throw(::com::sun::star::uno::RuntimeException
);
219 virtual ::com::sun::star::uno::Any SAL_CALL
getByName( const ::rtl::OUString
& aName
)
220 throw(::com::sun::star::container::NoSuchElementException
,
221 ::com::sun::star::lang::WrappedTargetException
,
222 ::com::sun::star::uno::RuntimeException
);
223 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getElementNames()
224 throw(::com::sun::star::uno::RuntimeException
);
225 virtual sal_Bool SAL_CALL
hasByName( const ::rtl::OUString
& aName
)
226 throw(::com::sun::star::uno::RuntimeException
);
229 virtual sal_Int32 SAL_CALL
getCount() throw(::com::sun::star::uno::RuntimeException
);
230 virtual ::com::sun::star::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
)
231 throw(::com::sun::star::lang::IndexOutOfBoundsException
,
232 ::com::sun::star::lang::WrappedTargetException
,
233 ::com::sun::star::uno::RuntimeException
);
235 // XEnumerationAccess
236 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XEnumeration
> SAL_CALL
237 createEnumeration() throw(::com::sun::star::uno::RuntimeException
);
240 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType()
241 throw(::com::sun::star::uno::RuntimeException
);
242 virtual sal_Bool SAL_CALL
hasElements() throw(::com::sun::star::uno::RuntimeException
);
245 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
>
246 SAL_CALL
getPropertySetInfo()
247 throw(::com::sun::star::uno::RuntimeException
);
248 virtual void SAL_CALL
setPropertyValue( const ::rtl::OUString
& aPropertyName
,
249 const ::com::sun::star::uno::Any
& aValue
)
250 throw(::com::sun::star::beans::UnknownPropertyException
,
251 ::com::sun::star::beans::PropertyVetoException
,
252 ::com::sun::star::lang::IllegalArgumentException
,
253 ::com::sun::star::lang::WrappedTargetException
,
254 ::com::sun::star::uno::RuntimeException
);
255 virtual ::com::sun::star::uno::Any SAL_CALL
getPropertyValue(
256 const ::rtl::OUString
& PropertyName
)
257 throw(::com::sun::star::beans::UnknownPropertyException
,
258 ::com::sun::star::lang::WrappedTargetException
,
259 ::com::sun::star::uno::RuntimeException
);
260 virtual void SAL_CALL
addPropertyChangeListener( const ::rtl::OUString
& aPropertyName
,
261 const ::com::sun::star::uno::Reference
<
262 ::com::sun::star::beans::XPropertyChangeListener
>& xListener
)
263 throw(::com::sun::star::beans::UnknownPropertyException
,
264 ::com::sun::star::lang::WrappedTargetException
,
265 ::com::sun::star::uno::RuntimeException
);
266 virtual void SAL_CALL
removePropertyChangeListener( const ::rtl::OUString
& aPropertyName
,
267 const ::com::sun::star::uno::Reference
<
268 ::com::sun::star::beans::XPropertyChangeListener
>& aListener
)
269 throw(::com::sun::star::beans::UnknownPropertyException
,
270 ::com::sun::star::lang::WrappedTargetException
,
271 ::com::sun::star::uno::RuntimeException
);
272 virtual void SAL_CALL
addVetoableChangeListener( const ::rtl::OUString
& PropertyName
,
273 const ::com::sun::star::uno::Reference
<
274 ::com::sun::star::beans::XVetoableChangeListener
>& aListener
)
275 throw(::com::sun::star::beans::UnknownPropertyException
,
276 ::com::sun::star::lang::WrappedTargetException
,
277 ::com::sun::star::uno::RuntimeException
);
278 virtual void SAL_CALL
removeVetoableChangeListener( const ::rtl::OUString
& PropertyName
,
279 const ::com::sun::star::uno::Reference
<
280 ::com::sun::star::beans::XVetoableChangeListener
>& aListener
)
281 throw(::com::sun::star::beans::UnknownPropertyException
,
282 ::com::sun::star::lang::WrappedTargetException
,
283 ::com::sun::star::uno::RuntimeException
);
286 virtual sal_Bool SAL_CALL
isActionLocked() throw(::com::sun::star::uno::RuntimeException
);
287 virtual void SAL_CALL
addActionLock() throw(::com::sun::star::uno::RuntimeException
);
288 virtual void SAL_CALL
removeActionLock() throw(::com::sun::star::uno::RuntimeException
);
289 virtual void SAL_CALL
setActionLocks( sal_Int16 nLock
) throw(::com::sun::star::uno::RuntimeException
);
290 virtual sal_Int16 SAL_CALL
resetActionLocks() throw(::com::sun::star::uno::RuntimeException
);
293 virtual ::rtl::OUString SAL_CALL
getImplementationName()
294 throw(::com::sun::star::uno::RuntimeException
);
295 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
)
296 throw(::com::sun::star::uno::RuntimeException
);
297 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames()
298 throw(::com::sun::star::uno::RuntimeException
);
301 class ScGlobalNamedRangesObj
: public ScNamedRangesObj
305 virtual ScNamedRangeObj
* GetObjectByIndex_Impl(sal_uInt16 nIndex
);
306 virtual ScNamedRangeObj
* GetObjectByName_Impl(const ::rtl::OUString
& aName
);
308 virtual ScRangeName
* GetRangeName_Impl();
309 virtual SCTAB
GetTab_Impl();
312 ScGlobalNamedRangesObj(ScDocShell
* pDocSh
);
313 virtual ~ScGlobalNamedRangesObj();
316 class ScLocalNamedRangesObj
: public ScNamedRangesObj
320 virtual ScNamedRangeObj
* GetObjectByIndex_Impl(sal_uInt16 nIndex
);
321 virtual ScNamedRangeObj
* GetObjectByName_Impl(const ::rtl::OUString
& aName
);
323 virtual ScRangeName
* GetRangeName_Impl();
324 virtual SCTAB
GetTab_Impl();
326 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNamed
> mxSheet
;
328 ScLocalNamedRangesObj(ScDocShell
* pDocSh
, ::com::sun::star::uno::Reference
< com::sun::star::container::XNamed
> xNamed
);
329 virtual ~ScLocalNamedRangesObj();
333 class ScLabelRangeObj
: public ::cppu::WeakImplHelper2
<
334 ::com::sun::star::sheet::XLabelRange
,
335 ::com::sun::star::lang::XServiceInfo
>,
339 ScDocShell
* pDocShell
;
341 ScRange aRange
; // criterion to find range
344 ScRangePair
* GetData_Impl();
345 void Modify_Impl( const ScRange
* pLabel
, const ScRange
* pData
);
348 ScLabelRangeObj(ScDocShell
* pDocSh
, sal_Bool bCol
, const ScRange
& rR
);
349 virtual ~ScLabelRangeObj();
351 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
354 virtual ::com::sun::star::table::CellRangeAddress SAL_CALL
getLabelArea()
355 throw(::com::sun::star::uno::RuntimeException
);
356 virtual void SAL_CALL
setLabelArea( const ::com::sun::star::table::CellRangeAddress
& aLabelArea
)
357 throw(::com::sun::star::uno::RuntimeException
);
358 virtual ::com::sun::star::table::CellRangeAddress SAL_CALL
getDataArea()
359 throw(::com::sun::star::uno::RuntimeException
);
360 virtual void SAL_CALL
setDataArea( const ::com::sun::star::table::CellRangeAddress
& aDataArea
)
361 throw(::com::sun::star::uno::RuntimeException
);
364 virtual ::rtl::OUString SAL_CALL
getImplementationName()
365 throw(::com::sun::star::uno::RuntimeException
);
366 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
)
367 throw(::com::sun::star::uno::RuntimeException
);
368 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames()
369 throw(::com::sun::star::uno::RuntimeException
);
373 class ScLabelRangesObj
: public ::cppu::WeakImplHelper3
<
374 ::com::sun::star::sheet::XLabelRanges
,
375 ::com::sun::star::container::XEnumerationAccess
,
376 ::com::sun::star::lang::XServiceInfo
>,
380 ScDocShell
* pDocShell
;
383 ScLabelRangeObj
* GetObjectByIndex_Impl(size_t nIndex
);
386 ScLabelRangesObj(ScDocShell
* pDocSh
, sal_Bool bCol
);
387 virtual ~ScLabelRangesObj();
389 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
392 virtual void SAL_CALL
addNew( const ::com::sun::star::table::CellRangeAddress
& aLabelArea
,
393 const ::com::sun::star::table::CellRangeAddress
& aDataArea
)
394 throw(::com::sun::star::uno::RuntimeException
);
395 virtual void SAL_CALL
removeByIndex( sal_Int32 nIndex
)
396 throw(::com::sun::star::uno::RuntimeException
);
399 virtual sal_Int32 SAL_CALL
getCount() throw(::com::sun::star::uno::RuntimeException
);
400 virtual ::com::sun::star::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
)
401 throw(::com::sun::star::lang::IndexOutOfBoundsException
,
402 ::com::sun::star::lang::WrappedTargetException
,
403 ::com::sun::star::uno::RuntimeException
);
405 // XEnumerationAccess
406 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XEnumeration
> SAL_CALL
407 createEnumeration() throw(::com::sun::star::uno::RuntimeException
);
410 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType()
411 throw(::com::sun::star::uno::RuntimeException
);
412 virtual sal_Bool SAL_CALL
hasElements() throw(::com::sun::star::uno::RuntimeException
);
415 virtual ::rtl::OUString SAL_CALL
getImplementationName()
416 throw(::com::sun::star::uno::RuntimeException
);
417 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
)
418 throw(::com::sun::star::uno::RuntimeException
);
419 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames()
420 throw(::com::sun::star::uno::RuntimeException
);
428 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */