xref: /trunk/main/sc/inc/nameuno.hxx (revision 38d50f7b)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SC_NAMEUNO_HXX
25 #define SC_NAMEUNO_HXX
26 
27 #include <svl/lstner.hxx>
28 #include "address.hxx"
29 #include "formula/grammar.hxx"
30 #include <com/sun/star/sheet/XLabelRange.hpp>
31 #include <com/sun/star/sheet/XLabelRanges.hpp>
32 #include <com/sun/star/sheet/XCellRangeReferrer.hpp>
33 #include <com/sun/star/sheet/XNamedRange.hpp>
34 #include <com/sun/star/sheet/XFormulaTokens.hpp>
35 #include <com/sun/star/sheet/XNamedRanges.hpp>
36 #include <com/sun/star/container/XEnumerationAccess.hpp>
37 #include <com/sun/star/lang/XServiceName.hpp>
38 #include <com/sun/star/lang/XServiceInfo.hpp>
39 #include <com/sun/star/lang/XUnoTunnel.hpp>
40 #include <com/sun/star/beans/XPropertySet.hpp>
41 #include <com/sun/star/document/XActionLockable.hpp>
42 #include <cppuhelper/implbase2.hxx>
43 #include <cppuhelper/implbase3.hxx>
44 #include <cppuhelper/implbase5.hxx>
45 #include <cppuhelper/implbase6.hxx>
46 
47 class ScDocShell;
48 class ScRangeData;
49 class ScTokenArray;
50 
51 
52 class ScNamedRangeObj : public ::cppu::WeakImplHelper6<
53 							::com::sun::star::sheet::XNamedRange,
54                             ::com::sun::star::sheet::XFormulaTokens,
55 							::com::sun::star::sheet::XCellRangeReferrer,
56 							::com::sun::star::beans::XPropertySet,
57 							::com::sun::star::lang::XUnoTunnel,
58 							::com::sun::star::lang::XServiceInfo >,
59 						public SfxListener
60 {
61 private:
62 	ScDocShell*				pDocShell;
63 	String					aName;
64 
65 private:
66 	ScRangeData*			GetRangeData_Impl();
67 	void					Modify_Impl( const String* pNewName,
68                                         const ScTokenArray* pNewTokens, const String* pNewContent,
69 										const ScAddress* pNewPos, const sal_uInt16* pNewType,
70                                         const formula::FormulaGrammar::Grammar eGrammar );
71 
72 public:
73 							ScNamedRangeObj(ScDocShell* pDocSh, const String& rNm);
74 	virtual					~ScNamedRangeObj();
75 
76 	virtual void			Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
77 
78 							// XNamedRange
79 	virtual ::rtl::OUString SAL_CALL getContent() throw(::com::sun::star::uno::RuntimeException);
80 	virtual void SAL_CALL	setContent( const ::rtl::OUString& aContent )
81 								throw(::com::sun::star::uno::RuntimeException);
82 	virtual ::com::sun::star::table::CellAddress SAL_CALL getReferencePosition()
83 								throw(::com::sun::star::uno::RuntimeException);
84 	virtual void SAL_CALL	setReferencePosition(
85 								const ::com::sun::star::table::CellAddress& aReferencePosition )
86 									throw(::com::sun::star::uno::RuntimeException);
87 	virtual sal_Int32		SAL_CALL getType() throw(::com::sun::star::uno::RuntimeException);
88 	virtual void SAL_CALL	setType( sal_Int32 nType ) throw(::com::sun::star::uno::RuntimeException);
89 
90                             // XFormulaTokens
91     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken > SAL_CALL getTokens()
92                                 throw (::com::sun::star::uno::RuntimeException);
93     virtual void SAL_CALL   setTokens( const ::com::sun::star::uno::Sequence<
94                                     ::com::sun::star::sheet::FormulaToken >& aTokens )
95                                 throw (::com::sun::star::uno::RuntimeException);
96 
97 							// XNamed
98 	virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
99 	virtual void SAL_CALL	setName( const ::rtl::OUString& aName )
100 								throw(::com::sun::star::uno::RuntimeException);
101 
102 							// XCellRangeReferrer
103 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange > SAL_CALL
104 							getReferredCells() throw(::com::sun::star::uno::RuntimeException);
105 
106 							// XPropertySet
107 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
108 							SAL_CALL getPropertySetInfo()
109 								throw(::com::sun::star::uno::RuntimeException);
110 	virtual void SAL_CALL	setPropertyValue( const ::rtl::OUString& aPropertyName,
111 									const ::com::sun::star::uno::Any& aValue )
112 								throw(::com::sun::star::beans::UnknownPropertyException,
113 									::com::sun::star::beans::PropertyVetoException,
114 									::com::sun::star::lang::IllegalArgumentException,
115 									::com::sun::star::lang::WrappedTargetException,
116 									::com::sun::star::uno::RuntimeException);
117 	virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
118 									const ::rtl::OUString& PropertyName )
119 								throw(::com::sun::star::beans::UnknownPropertyException,
120 									::com::sun::star::lang::WrappedTargetException,
121 									::com::sun::star::uno::RuntimeException);
122 	virtual void SAL_CALL	addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
123 									const ::com::sun::star::uno::Reference<
124 										::com::sun::star::beans::XPropertyChangeListener >& xListener )
125 								throw(::com::sun::star::beans::UnknownPropertyException,
126 									::com::sun::star::lang::WrappedTargetException,
127 									::com::sun::star::uno::RuntimeException);
128 	virtual void SAL_CALL	removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
129 									const ::com::sun::star::uno::Reference<
130 										::com::sun::star::beans::XPropertyChangeListener >& aListener )
131 								throw(::com::sun::star::beans::UnknownPropertyException,
132 									::com::sun::star::lang::WrappedTargetException,
133 									::com::sun::star::uno::RuntimeException);
134 	virtual void SAL_CALL	addVetoableChangeListener( const ::rtl::OUString& PropertyName,
135 									const ::com::sun::star::uno::Reference<
136 										::com::sun::star::beans::XVetoableChangeListener >& aListener )
137 								throw(::com::sun::star::beans::UnknownPropertyException,
138 									::com::sun::star::lang::WrappedTargetException,
139 									::com::sun::star::uno::RuntimeException);
140 	virtual void SAL_CALL	removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
141 									const ::com::sun::star::uno::Reference<
142 										::com::sun::star::beans::XVetoableChangeListener >& aListener )
143 								throw(::com::sun::star::beans::UnknownPropertyException,
144 									::com::sun::star::lang::WrappedTargetException,
145 									::com::sun::star::uno::RuntimeException);
146 
147 							// XUnoTunnel
148 	virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
149 									sal_Int8 >& aIdentifier )
150 								throw(::com::sun::star::uno::RuntimeException);
151 
152 	static const com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
153 	static ScNamedRangeObj* getImplementation( const com::sun::star::uno::Reference<
154 									com::sun::star::uno::XInterface> xObj );
155 
156 							// XServiceInfo
157 	virtual ::rtl::OUString SAL_CALL getImplementationName()
158 								throw(::com::sun::star::uno::RuntimeException);
159 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
160 								throw(::com::sun::star::uno::RuntimeException);
161 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
162 								throw(::com::sun::star::uno::RuntimeException);
163 
164                             // methods accessible via getImplementation()
165             void            SetContentWithGrammar( const ::rtl::OUString& aContent,
166                                     const formula::FormulaGrammar::Grammar eGrammar )
167                                 throw(::com::sun::star::uno::RuntimeException);
168 };
169 
170 
171 class ScNamedRangesObj : public ::cppu::WeakImplHelper5<
172 							::com::sun::star::sheet::XNamedRanges,
173 							::com::sun::star::container::XEnumerationAccess,
174 							::com::sun::star::container::XIndexAccess,
175                             ::com::sun::star::document::XActionLockable,
176 							::com::sun::star::lang::XServiceInfo >,
177 						public SfxListener
178 {
179 private:
180 	ScDocShell*				pDocShell;
181 
182 	ScNamedRangeObj*		GetObjectByIndex_Impl(sal_uInt16 nIndex);
183 	ScNamedRangeObj*		GetObjectByName_Impl(const ::rtl::OUString& aName);
184 
185 protected:
186     /** called from the XActionLockable interface methods on initial locking */
187     virtual void            lock();
188 
189     /** called from the XActionLockable interface methods on final unlock */
190     virtual void            unlock();
191 
192 public:
193 							ScNamedRangesObj(ScDocShell* pDocSh);
194 	virtual					~ScNamedRangesObj();
195 
196 	virtual void			Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
197 
198 							// XNamedRanges
199 	virtual void SAL_CALL	addNewByName( const ::rtl::OUString& aName, const ::rtl::OUString& aContent,
200 								const ::com::sun::star::table::CellAddress& aPosition, sal_Int32 nType )
201 									throw(::com::sun::star::uno::RuntimeException);
202 	virtual void SAL_CALL	addNewFromTitles( const ::com::sun::star::table::CellRangeAddress& aSource,
203 								::com::sun::star::sheet::Border aBorder )
204 									throw(::com::sun::star::uno::RuntimeException);
205 	virtual void SAL_CALL	removeByName( const ::rtl::OUString& aName )
206 								throw(::com::sun::star::uno::RuntimeException);
207 	virtual void SAL_CALL	outputList( const ::com::sun::star::table::CellAddress& aOutputPosition )
208 								throw(::com::sun::star::uno::RuntimeException);
209 
210 							// XNameAccess
211 	virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
212 								throw(::com::sun::star::container::NoSuchElementException,
213 									::com::sun::star::lang::WrappedTargetException,
214 									::com::sun::star::uno::RuntimeException);
215 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
216 								throw(::com::sun::star::uno::RuntimeException);
217 	virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
218 								throw(::com::sun::star::uno::RuntimeException);
219 
220 							// XIndexAccess
221 	virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException);
222 	virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
223 								throw(::com::sun::star::lang::IndexOutOfBoundsException,
224 									::com::sun::star::lang::WrappedTargetException,
225 									::com::sun::star::uno::RuntimeException);
226 
227 							// XEnumerationAccess
228 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL
229 							createEnumeration() throw(::com::sun::star::uno::RuntimeException);
230 
231 							// XElementAccess
232 	virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
233 								throw(::com::sun::star::uno::RuntimeException);
234 	virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
235 
236                             // XActionLockable
237     virtual sal_Bool SAL_CALL isActionLocked() throw(::com::sun::star::uno::RuntimeException);
238     virtual void SAL_CALL addActionLock() throw(::com::sun::star::uno::RuntimeException);
239     virtual void SAL_CALL removeActionLock() throw(::com::sun::star::uno::RuntimeException);
240     virtual void SAL_CALL setActionLocks( sal_Int16 nLock ) throw(::com::sun::star::uno::RuntimeException);
241     virtual sal_Int16 SAL_CALL resetActionLocks() throw(::com::sun::star::uno::RuntimeException);
242 
243 							// XServiceInfo
244 	virtual ::rtl::OUString SAL_CALL getImplementationName()
245 								throw(::com::sun::star::uno::RuntimeException);
246 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
247 								throw(::com::sun::star::uno::RuntimeException);
248 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
249 								throw(::com::sun::star::uno::RuntimeException);
250 };
251 
252 
253 class ScLabelRangeObj : public ::cppu::WeakImplHelper2<
254 							::com::sun::star::sheet::XLabelRange,
255 							::com::sun::star::lang::XServiceInfo >,
256 						public SfxListener
257 {
258 private:
259 	ScDocShell*				pDocShell;
260 	sal_Bool				bColumn;
261 	ScRange					aRange;			// Kriterium um Bereich zu finden
262 
263 private:
264 	ScRangePair*			GetData_Impl();
265 	void					Modify_Impl( const ScRange* pLabel, const ScRange* pData );
266 
267 public:
268 							ScLabelRangeObj(ScDocShell* pDocSh, sal_Bool bCol, const ScRange& rR);
269 	virtual					~ScLabelRangeObj();
270 
271 	virtual void			Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
272 
273 							// XLabelRange
274 	virtual ::com::sun::star::table::CellRangeAddress SAL_CALL getLabelArea()
275 								throw(::com::sun::star::uno::RuntimeException);
276 	virtual void SAL_CALL	setLabelArea( const ::com::sun::star::table::CellRangeAddress& aLabelArea )
277 								throw(::com::sun::star::uno::RuntimeException);
278 	virtual ::com::sun::star::table::CellRangeAddress SAL_CALL getDataArea()
279 								throw(::com::sun::star::uno::RuntimeException);
280 	virtual void SAL_CALL	setDataArea( const ::com::sun::star::table::CellRangeAddress& aDataArea )
281 								throw(::com::sun::star::uno::RuntimeException);
282 
283 							// XServiceInfo
284 	virtual ::rtl::OUString SAL_CALL getImplementationName()
285 								throw(::com::sun::star::uno::RuntimeException);
286 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
287 								throw(::com::sun::star::uno::RuntimeException);
288 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
289 								throw(::com::sun::star::uno::RuntimeException);
290 };
291 
292 
293 class ScLabelRangesObj : public ::cppu::WeakImplHelper3<
294 							::com::sun::star::sheet::XLabelRanges,
295 							::com::sun::star::container::XEnumerationAccess,
296 							::com::sun::star::lang::XServiceInfo >,
297 						public SfxListener
298 {
299 private:
300 	ScDocShell*				pDocShell;
301 	sal_Bool					bColumn;
302 
303 	ScLabelRangeObj*		GetObjectByIndex_Impl(sal_uInt16 nIndex);
304 
305 public:
306 							ScLabelRangesObj(ScDocShell* pDocSh, sal_Bool bCol);
307 	virtual					~ScLabelRangesObj();
308 
309 	virtual void			Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
310 
311 							// XLabelRanges
312 	virtual void SAL_CALL	addNew( const ::com::sun::star::table::CellRangeAddress& aLabelArea,
313 								const ::com::sun::star::table::CellRangeAddress& aDataArea )
314 									throw(::com::sun::star::uno::RuntimeException);
315 	virtual void SAL_CALL	removeByIndex( sal_Int32 nIndex )
316 								throw(::com::sun::star::uno::RuntimeException);
317 
318 							// XIndexAccess
319 	virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException);
320 	virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
321 								throw(::com::sun::star::lang::IndexOutOfBoundsException,
322 									::com::sun::star::lang::WrappedTargetException,
323 									::com::sun::star::uno::RuntimeException);
324 
325 							// XEnumerationAccess
326 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL
327 							createEnumeration() throw(::com::sun::star::uno::RuntimeException);
328 
329 							// XElementAccess
330 	virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
331 								throw(::com::sun::star::uno::RuntimeException);
332 	virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
333 
334 							// XServiceInfo
335 	virtual ::rtl::OUString SAL_CALL getImplementationName()
336 								throw(::com::sun::star::uno::RuntimeException);
337 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
338 								throw(::com::sun::star::uno::RuntimeException);
339 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
340 								throw(::com::sun::star::uno::RuntimeException);
341 };
342 
343 
344 
345 
346 #endif
347 
348