xref: /aoo42x/main/sc/inc/nameuno.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SC_NAMEUNO_HXX
29 #define SC_NAMEUNO_HXX
30 
31 #include <svl/lstner.hxx>
32 #include "address.hxx"
33 #include "formula/grammar.hxx"
34 #include <com/sun/star/sheet/XLabelRange.hpp>
35 #include <com/sun/star/sheet/XLabelRanges.hpp>
36 #include <com/sun/star/sheet/XCellRangeReferrer.hpp>
37 #include <com/sun/star/sheet/XNamedRange.hpp>
38 #include <com/sun/star/sheet/XFormulaTokens.hpp>
39 #include <com/sun/star/sheet/XNamedRanges.hpp>
40 #include <com/sun/star/container/XEnumerationAccess.hpp>
41 #include <com/sun/star/lang/XServiceName.hpp>
42 #include <com/sun/star/lang/XServiceInfo.hpp>
43 #include <com/sun/star/lang/XUnoTunnel.hpp>
44 #include <com/sun/star/beans/XPropertySet.hpp>
45 #include <com/sun/star/document/XActionLockable.hpp>
46 #include <cppuhelper/implbase2.hxx>
47 #include <cppuhelper/implbase3.hxx>
48 #include <cppuhelper/implbase5.hxx>
49 #include <cppuhelper/implbase6.hxx>
50 
51 class ScDocShell;
52 class ScRangeData;
53 class ScTokenArray;
54 
55 
56 class ScNamedRangeObj : public ::cppu::WeakImplHelper6<
57 							::com::sun::star::sheet::XNamedRange,
58                             ::com::sun::star::sheet::XFormulaTokens,
59 							::com::sun::star::sheet::XCellRangeReferrer,
60 							::com::sun::star::beans::XPropertySet,
61 							::com::sun::star::lang::XUnoTunnel,
62 							::com::sun::star::lang::XServiceInfo >,
63 						public SfxListener
64 {
65 private:
66 	ScDocShell*				pDocShell;
67 	String					aName;
68 
69 private:
70 	ScRangeData*			GetRangeData_Impl();
71 	void					Modify_Impl( const String* pNewName,
72                                         const ScTokenArray* pNewTokens, const String* pNewContent,
73 										const ScAddress* pNewPos, const sal_uInt16* pNewType,
74                                         const formula::FormulaGrammar::Grammar eGrammar );
75 
76 public:
77 							ScNamedRangeObj(ScDocShell* pDocSh, const String& rNm);
78 	virtual					~ScNamedRangeObj();
79 
80 	virtual void			Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
81 
82 							// XNamedRange
83 	virtual ::rtl::OUString SAL_CALL getContent() throw(::com::sun::star::uno::RuntimeException);
84 	virtual void SAL_CALL	setContent( const ::rtl::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);
93 
94                             // XFormulaTokens
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);
100 
101 							// XNamed
102 	virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
103 	virtual void SAL_CALL	setName( const ::rtl::OUString& aName )
104 								throw(::com::sun::star::uno::RuntimeException);
105 
106 							// XCellRangeReferrer
107 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange > SAL_CALL
108 							getReferredCells() throw(::com::sun::star::uno::RuntimeException);
109 
110 							// XPropertySet
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 ::rtl::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 ::rtl::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 ::rtl::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 ::rtl::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 ::rtl::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 ::rtl::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);
150 
151 							// XUnoTunnel
152 	virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
153 									sal_Int8 >& aIdentifier )
154 								throw(::com::sun::star::uno::RuntimeException);
155 
156 	static const com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
157 	static ScNamedRangeObj* getImplementation( const com::sun::star::uno::Reference<
158 									com::sun::star::uno::XInterface> xObj );
159 
160 							// XServiceInfo
161 	virtual ::rtl::OUString SAL_CALL getImplementationName()
162 								throw(::com::sun::star::uno::RuntimeException);
163 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
164 								throw(::com::sun::star::uno::RuntimeException);
165 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
166 								throw(::com::sun::star::uno::RuntimeException);
167 
168                             // methods accessible via getImplementation()
169             void            SetContentWithGrammar( const ::rtl::OUString& aContent,
170                                     const formula::FormulaGrammar::Grammar eGrammar )
171                                 throw(::com::sun::star::uno::RuntimeException);
172 };
173 
174 
175 class ScNamedRangesObj : public ::cppu::WeakImplHelper5<
176 							::com::sun::star::sheet::XNamedRanges,
177 							::com::sun::star::container::XEnumerationAccess,
178 							::com::sun::star::container::XIndexAccess,
179                             ::com::sun::star::document::XActionLockable,
180 							::com::sun::star::lang::XServiceInfo >,
181 						public SfxListener
182 {
183 private:
184 	ScDocShell*				pDocShell;
185 
186 	ScNamedRangeObj*		GetObjectByIndex_Impl(sal_uInt16 nIndex);
187 	ScNamedRangeObj*		GetObjectByName_Impl(const ::rtl::OUString& aName);
188 
189 protected:
190     /** called from the XActionLockable interface methods on initial locking */
191     virtual void            lock();
192 
193     /** called from the XActionLockable interface methods on final unlock */
194     virtual void            unlock();
195 
196 public:
197 							ScNamedRangesObj(ScDocShell* pDocSh);
198 	virtual					~ScNamedRangesObj();
199 
200 	virtual void			Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
201 
202 							// XNamedRanges
203 	virtual void SAL_CALL	addNewByName( const ::rtl::OUString& aName, const ::rtl::OUString& aContent,
204 								const ::com::sun::star::table::CellAddress& aPosition, sal_Int32 nType )
205 									throw(::com::sun::star::uno::RuntimeException);
206 	virtual void SAL_CALL	addNewFromTitles( const ::com::sun::star::table::CellRangeAddress& aSource,
207 								::com::sun::star::sheet::Border aBorder )
208 									throw(::com::sun::star::uno::RuntimeException);
209 	virtual void SAL_CALL	removeByName( const ::rtl::OUString& aName )
210 								throw(::com::sun::star::uno::RuntimeException);
211 	virtual void SAL_CALL	outputList( const ::com::sun::star::table::CellAddress& aOutputPosition )
212 								throw(::com::sun::star::uno::RuntimeException);
213 
214 							// XNameAccess
215 	virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
216 								throw(::com::sun::star::container::NoSuchElementException,
217 									::com::sun::star::lang::WrappedTargetException,
218 									::com::sun::star::uno::RuntimeException);
219 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
220 								throw(::com::sun::star::uno::RuntimeException);
221 	virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
222 								throw(::com::sun::star::uno::RuntimeException);
223 
224 							// XIndexAccess
225 	virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException);
226 	virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
227 								throw(::com::sun::star::lang::IndexOutOfBoundsException,
228 									::com::sun::star::lang::WrappedTargetException,
229 									::com::sun::star::uno::RuntimeException);
230 
231 							// XEnumerationAccess
232 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL
233 							createEnumeration() throw(::com::sun::star::uno::RuntimeException);
234 
235 							// XElementAccess
236 	virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
237 								throw(::com::sun::star::uno::RuntimeException);
238 	virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
239 
240                             // XActionLockable
241     virtual sal_Bool SAL_CALL isActionLocked() throw(::com::sun::star::uno::RuntimeException);
242     virtual void SAL_CALL addActionLock() throw(::com::sun::star::uno::RuntimeException);
243     virtual void SAL_CALL removeActionLock() throw(::com::sun::star::uno::RuntimeException);
244     virtual void SAL_CALL setActionLocks( sal_Int16 nLock ) throw(::com::sun::star::uno::RuntimeException);
245     virtual sal_Int16 SAL_CALL resetActionLocks() throw(::com::sun::star::uno::RuntimeException);
246 
247 							// XServiceInfo
248 	virtual ::rtl::OUString SAL_CALL getImplementationName()
249 								throw(::com::sun::star::uno::RuntimeException);
250 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
251 								throw(::com::sun::star::uno::RuntimeException);
252 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
253 								throw(::com::sun::star::uno::RuntimeException);
254 };
255 
256 
257 class ScLabelRangeObj : public ::cppu::WeakImplHelper2<
258 							::com::sun::star::sheet::XLabelRange,
259 							::com::sun::star::lang::XServiceInfo >,
260 						public SfxListener
261 {
262 private:
263 	ScDocShell*				pDocShell;
264 	sal_Bool				bColumn;
265 	ScRange					aRange;			// Kriterium um Bereich zu finden
266 
267 private:
268 	ScRangePair*			GetData_Impl();
269 	void					Modify_Impl( const ScRange* pLabel, const ScRange* pData );
270 
271 public:
272 							ScLabelRangeObj(ScDocShell* pDocSh, sal_Bool bCol, const ScRange& rR);
273 	virtual					~ScLabelRangeObj();
274 
275 	virtual void			Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
276 
277 							// XLabelRange
278 	virtual ::com::sun::star::table::CellRangeAddress SAL_CALL getLabelArea()
279 								throw(::com::sun::star::uno::RuntimeException);
280 	virtual void SAL_CALL	setLabelArea( const ::com::sun::star::table::CellRangeAddress& aLabelArea )
281 								throw(::com::sun::star::uno::RuntimeException);
282 	virtual ::com::sun::star::table::CellRangeAddress SAL_CALL getDataArea()
283 								throw(::com::sun::star::uno::RuntimeException);
284 	virtual void SAL_CALL	setDataArea( const ::com::sun::star::table::CellRangeAddress& aDataArea )
285 								throw(::com::sun::star::uno::RuntimeException);
286 
287 							// XServiceInfo
288 	virtual ::rtl::OUString SAL_CALL getImplementationName()
289 								throw(::com::sun::star::uno::RuntimeException);
290 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
291 								throw(::com::sun::star::uno::RuntimeException);
292 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
293 								throw(::com::sun::star::uno::RuntimeException);
294 };
295 
296 
297 class ScLabelRangesObj : public ::cppu::WeakImplHelper3<
298 							::com::sun::star::sheet::XLabelRanges,
299 							::com::sun::star::container::XEnumerationAccess,
300 							::com::sun::star::lang::XServiceInfo >,
301 						public SfxListener
302 {
303 private:
304 	ScDocShell*				pDocShell;
305 	sal_Bool					bColumn;
306 
307 	ScLabelRangeObj*		GetObjectByIndex_Impl(sal_uInt16 nIndex);
308 
309 public:
310 							ScLabelRangesObj(ScDocShell* pDocSh, sal_Bool bCol);
311 	virtual					~ScLabelRangesObj();
312 
313 	virtual void			Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
314 
315 							// XLabelRanges
316 	virtual void SAL_CALL	addNew( const ::com::sun::star::table::CellRangeAddress& aLabelArea,
317 								const ::com::sun::star::table::CellRangeAddress& aDataArea )
318 									throw(::com::sun::star::uno::RuntimeException);
319 	virtual void SAL_CALL	removeByIndex( sal_Int32 nIndex )
320 								throw(::com::sun::star::uno::RuntimeException);
321 
322 							// XIndexAccess
323 	virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException);
324 	virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
325 								throw(::com::sun::star::lang::IndexOutOfBoundsException,
326 									::com::sun::star::lang::WrappedTargetException,
327 									::com::sun::star::uno::RuntimeException);
328 
329 							// XEnumerationAccess
330 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL
331 							createEnumeration() throw(::com::sun::star::uno::RuntimeException);
332 
333 							// XElementAccess
334 	virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
335 								throw(::com::sun::star::uno::RuntimeException);
336 	virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
337 
338 							// XServiceInfo
339 	virtual ::rtl::OUString SAL_CALL getImplementationName()
340 								throw(::com::sun::star::uno::RuntimeException);
341 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
342 								throw(::com::sun::star::uno::RuntimeException);
343 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
344 								throw(::com::sun::star::uno::RuntimeException);
345 };
346 
347 
348 
349 
350 #endif
351 
352