1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: nameuno.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_NAMEUNO_HXX
32 #define SC_NAMEUNO_HXX
34 #include <svtools/lstner.hxx>
35 #include "address.hxx"
36 #include "formula/grammar.hxx"
37 #include <com/sun/star/sheet/XLabelRange.hpp>
38 #include <com/sun/star/sheet/XLabelRanges.hpp>
39 #include <com/sun/star/sheet/XCellRangeReferrer.hpp>
40 #include <com/sun/star/sheet/XNamedRange.hpp>
41 #include <com/sun/star/sheet/XFormulaTokens.hpp>
42 #include <com/sun/star/sheet/XNamedRanges.hpp>
43 #include <com/sun/star/container/XEnumerationAccess.hpp>
44 #include <com/sun/star/lang/XServiceName.hpp>
45 #include <com/sun/star/lang/XServiceInfo.hpp>
46 #include <com/sun/star/lang/XUnoTunnel.hpp>
47 #include <com/sun/star/beans/XPropertySet.hpp>
48 #include <com/sun/star/document/XActionLockable.hpp>
49 #include <cppuhelper/implbase2.hxx>
50 #include <cppuhelper/implbase3.hxx>
51 #include <cppuhelper/implbase5.hxx>
52 #include <cppuhelper/implbase6.hxx>
59 class ScNamedRangeObj
: public ::cppu::WeakImplHelper6
<
60 ::com::sun::star::sheet::XNamedRange
,
61 ::com::sun::star::sheet::XFormulaTokens
,
62 ::com::sun::star::sheet::XCellRangeReferrer
,
63 ::com::sun::star::beans::XPropertySet
,
64 ::com::sun::star::lang::XUnoTunnel
,
65 ::com::sun::star::lang::XServiceInfo
>,
69 ScDocShell
* pDocShell
;
73 ScRangeData
* GetRangeData_Impl();
74 void Modify_Impl( const String
* pNewName
,
75 const ScTokenArray
* pNewTokens
, const String
* pNewContent
,
76 const ScAddress
* pNewPos
, const sal_uInt16
* pNewType
,
77 const formula::FormulaGrammar::Grammar eGrammar
);
80 ScNamedRangeObj(ScDocShell
* pDocSh
, const String
& rNm
);
81 virtual ~ScNamedRangeObj();
83 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
86 virtual ::rtl::OUString SAL_CALL
getContent() throw(::com::sun::star::uno::RuntimeException
);
87 virtual void SAL_CALL
setContent( const ::rtl::OUString
& aContent
)
88 throw(::com::sun::star::uno::RuntimeException
);
89 virtual ::com::sun::star::table::CellAddress SAL_CALL
getReferencePosition()
90 throw(::com::sun::star::uno::RuntimeException
);
91 virtual void SAL_CALL
setReferencePosition(
92 const ::com::sun::star::table::CellAddress
& aReferencePosition
)
93 throw(::com::sun::star::uno::RuntimeException
);
94 virtual sal_Int32 SAL_CALL
getType() throw(::com::sun::star::uno::RuntimeException
);
95 virtual void SAL_CALL
setType( sal_Int32 nType
) throw(::com::sun::star::uno::RuntimeException
);
98 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::sheet::FormulaToken
> SAL_CALL
getTokens()
99 throw (::com::sun::star::uno::RuntimeException
);
100 virtual void SAL_CALL
setTokens( const ::com::sun::star::uno::Sequence
<
101 ::com::sun::star::sheet::FormulaToken
>& aTokens
)
102 throw (::com::sun::star::uno::RuntimeException
);
105 virtual ::rtl::OUString SAL_CALL
getName() throw(::com::sun::star::uno::RuntimeException
);
106 virtual void SAL_CALL
setName( const ::rtl::OUString
& aName
)
107 throw(::com::sun::star::uno::RuntimeException
);
109 // XCellRangeReferrer
110 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::table::XCellRange
> SAL_CALL
111 getReferredCells() throw(::com::sun::star::uno::RuntimeException
);
114 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
>
115 SAL_CALL
getPropertySetInfo()
116 throw(::com::sun::star::uno::RuntimeException
);
117 virtual void SAL_CALL
setPropertyValue( const ::rtl::OUString
& aPropertyName
,
118 const ::com::sun::star::uno::Any
& aValue
)
119 throw(::com::sun::star::beans::UnknownPropertyException
,
120 ::com::sun::star::beans::PropertyVetoException
,
121 ::com::sun::star::lang::IllegalArgumentException
,
122 ::com::sun::star::lang::WrappedTargetException
,
123 ::com::sun::star::uno::RuntimeException
);
124 virtual ::com::sun::star::uno::Any SAL_CALL
getPropertyValue(
125 const ::rtl::OUString
& PropertyName
)
126 throw(::com::sun::star::beans::UnknownPropertyException
,
127 ::com::sun::star::lang::WrappedTargetException
,
128 ::com::sun::star::uno::RuntimeException
);
129 virtual void SAL_CALL
addPropertyChangeListener( const ::rtl::OUString
& aPropertyName
,
130 const ::com::sun::star::uno::Reference
<
131 ::com::sun::star::beans::XPropertyChangeListener
>& xListener
)
132 throw(::com::sun::star::beans::UnknownPropertyException
,
133 ::com::sun::star::lang::WrappedTargetException
,
134 ::com::sun::star::uno::RuntimeException
);
135 virtual void SAL_CALL
removePropertyChangeListener( const ::rtl::OUString
& aPropertyName
,
136 const ::com::sun::star::uno::Reference
<
137 ::com::sun::star::beans::XPropertyChangeListener
>& aListener
)
138 throw(::com::sun::star::beans::UnknownPropertyException
,
139 ::com::sun::star::lang::WrappedTargetException
,
140 ::com::sun::star::uno::RuntimeException
);
141 virtual void SAL_CALL
addVetoableChangeListener( const ::rtl::OUString
& PropertyName
,
142 const ::com::sun::star::uno::Reference
<
143 ::com::sun::star::beans::XVetoableChangeListener
>& aListener
)
144 throw(::com::sun::star::beans::UnknownPropertyException
,
145 ::com::sun::star::lang::WrappedTargetException
,
146 ::com::sun::star::uno::RuntimeException
);
147 virtual void SAL_CALL
removeVetoableChangeListener( const ::rtl::OUString
& PropertyName
,
148 const ::com::sun::star::uno::Reference
<
149 ::com::sun::star::beans::XVetoableChangeListener
>& aListener
)
150 throw(::com::sun::star::beans::UnknownPropertyException
,
151 ::com::sun::star::lang::WrappedTargetException
,
152 ::com::sun::star::uno::RuntimeException
);
155 virtual sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
<
156 sal_Int8
>& aIdentifier
)
157 throw(::com::sun::star::uno::RuntimeException
);
159 static const com::sun::star::uno::Sequence
<sal_Int8
>& getUnoTunnelId();
160 static ScNamedRangeObj
* getImplementation( const com::sun::star::uno::Reference
<
161 com::sun::star::uno::XInterface
> xObj
);
164 virtual ::rtl::OUString SAL_CALL
getImplementationName()
165 throw(::com::sun::star::uno::RuntimeException
);
166 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
)
167 throw(::com::sun::star::uno::RuntimeException
);
168 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames()
169 throw(::com::sun::star::uno::RuntimeException
);
171 // methods accessible via getImplementation()
172 void SetContentWithGrammar( const ::rtl::OUString
& aContent
,
173 const formula::FormulaGrammar::Grammar eGrammar
)
174 throw(::com::sun::star::uno::RuntimeException
);
178 class ScNamedRangesObj
: public ::cppu::WeakImplHelper5
<
179 ::com::sun::star::sheet::XNamedRanges
,
180 ::com::sun::star::container::XEnumerationAccess
,
181 ::com::sun::star::container::XIndexAccess
,
182 ::com::sun::star::document::XActionLockable
,
183 ::com::sun::star::lang::XServiceInfo
>,
187 ScDocShell
* pDocShell
;
189 ScNamedRangeObj
* GetObjectByIndex_Impl(sal_uInt16 nIndex
);
190 ScNamedRangeObj
* GetObjectByName_Impl(const ::rtl::OUString
& aName
);
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
);
206 virtual void SAL_CALL
addNewByName( const ::rtl::OUString
& aName
, const ::rtl::OUString
& aContent
,
207 const ::com::sun::star::table::CellAddress
& aPosition
, sal_Int32 nType
)
208 throw(::com::sun::star::uno::RuntimeException
);
209 virtual void SAL_CALL
addNewFromTitles( const ::com::sun::star::table::CellRangeAddress
& aSource
,
210 ::com::sun::star::sheet::Border aBorder
)
211 throw(::com::sun::star::uno::RuntimeException
);
212 virtual void SAL_CALL
removeByName( const ::rtl::OUString
& aName
)
213 throw(::com::sun::star::uno::RuntimeException
);
214 virtual void SAL_CALL
outputList( const ::com::sun::star::table::CellAddress
& aOutputPosition
)
215 throw(::com::sun::star::uno::RuntimeException
);
218 virtual ::com::sun::star::uno::Any SAL_CALL
getByName( const ::rtl::OUString
& aName
)
219 throw(::com::sun::star::container::NoSuchElementException
,
220 ::com::sun::star::lang::WrappedTargetException
,
221 ::com::sun::star::uno::RuntimeException
);
222 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getElementNames()
223 throw(::com::sun::star::uno::RuntimeException
);
224 virtual sal_Bool SAL_CALL
hasByName( const ::rtl::OUString
& aName
)
225 throw(::com::sun::star::uno::RuntimeException
);
228 virtual sal_Int32 SAL_CALL
getCount() throw(::com::sun::star::uno::RuntimeException
);
229 virtual ::com::sun::star::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
)
230 throw(::com::sun::star::lang::IndexOutOfBoundsException
,
231 ::com::sun::star::lang::WrappedTargetException
,
232 ::com::sun::star::uno::RuntimeException
);
234 // XEnumerationAccess
235 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XEnumeration
> SAL_CALL
236 createEnumeration() throw(::com::sun::star::uno::RuntimeException
);
239 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType()
240 throw(::com::sun::star::uno::RuntimeException
);
241 virtual sal_Bool SAL_CALL
hasElements() throw(::com::sun::star::uno::RuntimeException
);
244 virtual sal_Bool SAL_CALL
isActionLocked() throw(::com::sun::star::uno::RuntimeException
);
245 virtual void SAL_CALL
addActionLock() throw(::com::sun::star::uno::RuntimeException
);
246 virtual void SAL_CALL
removeActionLock() throw(::com::sun::star::uno::RuntimeException
);
247 virtual void SAL_CALL
setActionLocks( sal_Int16 nLock
) throw(::com::sun::star::uno::RuntimeException
);
248 virtual sal_Int16 SAL_CALL
resetActionLocks() throw(::com::sun::star::uno::RuntimeException
);
251 virtual ::rtl::OUString SAL_CALL
getImplementationName()
252 throw(::com::sun::star::uno::RuntimeException
);
253 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
)
254 throw(::com::sun::star::uno::RuntimeException
);
255 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames()
256 throw(::com::sun::star::uno::RuntimeException
);
260 class ScLabelRangeObj
: public ::cppu::WeakImplHelper2
<
261 ::com::sun::star::sheet::XLabelRange
,
262 ::com::sun::star::lang::XServiceInfo
>,
266 ScDocShell
* pDocShell
;
268 ScRange aRange
; // Kriterium um Bereich zu finden
271 ScRangePair
* GetData_Impl();
272 void Modify_Impl( const ScRange
* pLabel
, const ScRange
* pData
);
275 ScLabelRangeObj(ScDocShell
* pDocSh
, sal_Bool bCol
, const ScRange
& rR
);
276 virtual ~ScLabelRangeObj();
278 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
281 virtual ::com::sun::star::table::CellRangeAddress SAL_CALL
getLabelArea()
282 throw(::com::sun::star::uno::RuntimeException
);
283 virtual void SAL_CALL
setLabelArea( const ::com::sun::star::table::CellRangeAddress
& aLabelArea
)
284 throw(::com::sun::star::uno::RuntimeException
);
285 virtual ::com::sun::star::table::CellRangeAddress SAL_CALL
getDataArea()
286 throw(::com::sun::star::uno::RuntimeException
);
287 virtual void SAL_CALL
setDataArea( const ::com::sun::star::table::CellRangeAddress
& aDataArea
)
288 throw(::com::sun::star::uno::RuntimeException
);
291 virtual ::rtl::OUString SAL_CALL
getImplementationName()
292 throw(::com::sun::star::uno::RuntimeException
);
293 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
)
294 throw(::com::sun::star::uno::RuntimeException
);
295 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames()
296 throw(::com::sun::star::uno::RuntimeException
);
300 class ScLabelRangesObj
: public ::cppu::WeakImplHelper3
<
301 ::com::sun::star::sheet::XLabelRanges
,
302 ::com::sun::star::container::XEnumerationAccess
,
303 ::com::sun::star::lang::XServiceInfo
>,
307 ScDocShell
* pDocShell
;
310 ScLabelRangeObj
* GetObjectByIndex_Impl(sal_uInt16 nIndex
);
313 ScLabelRangesObj(ScDocShell
* pDocSh
, sal_Bool bCol
);
314 virtual ~ScLabelRangesObj();
316 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
319 virtual void SAL_CALL
addNew( const ::com::sun::star::table::CellRangeAddress
& aLabelArea
,
320 const ::com::sun::star::table::CellRangeAddress
& aDataArea
)
321 throw(::com::sun::star::uno::RuntimeException
);
322 virtual void SAL_CALL
removeByIndex( sal_Int32 nIndex
)
323 throw(::com::sun::star::uno::RuntimeException
);
326 virtual sal_Int32 SAL_CALL
getCount() throw(::com::sun::star::uno::RuntimeException
);
327 virtual ::com::sun::star::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
)
328 throw(::com::sun::star::lang::IndexOutOfBoundsException
,
329 ::com::sun::star::lang::WrappedTargetException
,
330 ::com::sun::star::uno::RuntimeException
);
332 // XEnumerationAccess
333 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XEnumeration
> SAL_CALL
334 createEnumeration() throw(::com::sun::star::uno::RuntimeException
);
337 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType()
338 throw(::com::sun::star::uno::RuntimeException
);
339 virtual sal_Bool SAL_CALL
hasElements() throw(::com::sun::star::uno::RuntimeException
);
342 virtual ::rtl::OUString SAL_CALL
getImplementationName()
343 throw(::com::sun::star::uno::RuntimeException
);
344 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
)
345 throw(::com::sun::star::uno::RuntimeException
);
346 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames()
347 throw(::com::sun::star::uno::RuntimeException
);