xref: /aoo41x/main/sc/source/ui/unoobj/appluno.cxx (revision 1b1b70fb)
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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sc.hxx"
26 
27 #include "appluno.hxx"
28 #include "sal/types.h"
29 #include <osl/diagnose.h>
30 #include <cppuhelper/factory.hxx>
31 
32 #include <sfx2/app.hxx>
33 #include <sfx2/sfxmodelfactory.hxx>
34 #include "afmtuno.hxx"
35 #include "funcuno.hxx"
36 #include "filtuno.hxx"
37 #include "miscuno.hxx"
38 #include "scmod.hxx"
39 #include "appoptio.hxx"
40 #include "inputopt.hxx"
41 #include "printopt.hxx"
42 #include "userlist.hxx"
43 #include "sc.hrc"			// VAR_ARGS
44 #include "unoguard.hxx"
45 #include "unonames.hxx"
46 #include "funcdesc.hxx"
47 #include <com/sun/star/sheet/FunctionArgument.hpp>
48 
49 using namespace com::sun::star;
50 
51 //------------------------------------------------------------------------
52 
53 // Calc document
54 extern uno::Sequence< rtl::OUString > SAL_CALL ScDocument_getSupportedServiceNames() throw();
55 extern rtl::OUString SAL_CALL ScDocument_getImplementationName() throw();
56 extern uno::Reference< uno::XInterface > SAL_CALL ScDocument_createInstance(
57 			const uno::Reference< lang::XMultiServiceFactory > & rSMgr, const sal_uInt64 _nCreationFlags ) throw( uno::Exception );
58 
59 // Calc XML import
60 extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLImport_getSupportedServiceNames() throw();
61 extern rtl::OUString SAL_CALL ScXMLImport_getImplementationName() throw();
62 extern uno::Reference< uno::XInterface > SAL_CALL ScXMLImport_createInstance(
63 			const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
64 extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLImport_Meta_getSupportedServiceNames() throw();
65 extern rtl::OUString SAL_CALL ScXMLImport_Meta_getImplementationName() throw();
66 extern uno::Reference< uno::XInterface > SAL_CALL ScXMLImport_Meta_createInstance(
67 			const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
68 extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLImport_Styles_getSupportedServiceNames() throw();
69 extern rtl::OUString SAL_CALL ScXMLImport_Styles_getImplementationName() throw();
70 extern uno::Reference< uno::XInterface > SAL_CALL ScXMLImport_Styles_createInstance(
71 			const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
72 extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLImport_Content_getSupportedServiceNames() throw();
73 extern rtl::OUString SAL_CALL ScXMLImport_Content_getImplementationName() throw();
74 extern uno::Reference< uno::XInterface > SAL_CALL ScXMLImport_Content_createInstance(
75 			const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
76 extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLImport_Settings_getSupportedServiceNames() throw();
77 extern rtl::OUString SAL_CALL ScXMLImport_Settings_getImplementationName() throw();
78 extern uno::Reference< uno::XInterface > SAL_CALL ScXMLImport_Settings_createInstance(
79 			const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
80 
81 // Calc XML export
82 extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLOOoExport_getSupportedServiceNames() throw();
83 extern rtl::OUString SAL_CALL ScXMLOOoExport_getImplementationName() throw();
84 extern uno::Reference< uno::XInterface > SAL_CALL ScXMLOOoExport_createInstance(
85 			const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
86 extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLOOoExport_Meta_getSupportedServiceNames() throw();
87 extern rtl::OUString SAL_CALL ScXMLOOoExport_Meta_getImplementationName() throw();
88 extern uno::Reference< uno::XInterface > SAL_CALL ScXMLOOoExport_Meta_createInstance(
89 			const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
90 extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLOOoExport_Styles_getSupportedServiceNames() throw();
91 extern rtl::OUString SAL_CALL ScXMLOOoExport_Styles_getImplementationName() throw();
92 extern uno::Reference< uno::XInterface > SAL_CALL ScXMLOOoExport_Styles_createInstance(
93 			const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
94 extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLOOoExport_Content_getSupportedServiceNames() throw();
95 extern rtl::OUString SAL_CALL ScXMLOOoExport_Content_getImplementationName() throw();
96 extern uno::Reference< uno::XInterface > SAL_CALL ScXMLOOoExport_Content_createInstance(
97 			const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
98 extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLOOoExport_Settings_getSupportedServiceNames() throw();
99 extern rtl::OUString SAL_CALL ScXMLOOoExport_Settings_getImplementationName() throw();
100 extern uno::Reference< uno::XInterface > SAL_CALL ScXMLOOoExport_Settings_createInstance(
101 			const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
102 
103 // Calc XML Oasis export
104 extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLOasisExport_getSupportedServiceNames() throw();
105 extern rtl::OUString SAL_CALL ScXMLOasisExport_getImplementationName() throw();
106 extern uno::Reference< uno::XInterface > SAL_CALL ScXMLOasisExport_createInstance(
107 			const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
108 extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLOasisExport_Meta_getSupportedServiceNames() throw();
109 extern rtl::OUString SAL_CALL ScXMLOasisExport_Meta_getImplementationName() throw();
110 extern uno::Reference< uno::XInterface > SAL_CALL ScXMLOasisExport_Meta_createInstance(
111 			const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
112 extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLOasisExport_Styles_getSupportedServiceNames() throw();
113 extern rtl::OUString SAL_CALL ScXMLOasisExport_Styles_getImplementationName() throw();
114 extern uno::Reference< uno::XInterface > SAL_CALL ScXMLOasisExport_Styles_createInstance(
115 			const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
116 extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLOasisExport_Content_getSupportedServiceNames() throw();
117 extern rtl::OUString SAL_CALL ScXMLOasisExport_Content_getImplementationName() throw();
118 extern uno::Reference< uno::XInterface > SAL_CALL ScXMLOasisExport_Content_createInstance(
119 			const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
120 extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLOasisExport_Settings_getSupportedServiceNames() throw();
121 extern rtl::OUString SAL_CALL ScXMLOasisExport_Settings_getImplementationName() throw();
122 extern uno::Reference< uno::XInterface > SAL_CALL ScXMLOasisExport_Settings_createInstance(
123 			const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
124 
125 //------------------------------------------------------------------------
126 
127 //	Anzahl der Funktionen, die als zuletzt benutzt gespeichert werden
128 //!	Define mit funcpage.hxx und dwfunctr.hxx zusammenfassen !!!
129 #define LRU_MAX 10
130 
131 //	Spezial-Werte fuer Zoom
132 //!	irgendwo zentral
133 #define SC_ZOOMVAL_OPTIMAL		(-1)
134 #define SC_ZOOMVAL_WHOLEPAGE	(-2)
135 #define SC_ZOOMVAL_PAGEWIDTH	(-3)
136 
137 //	Anzahl der PropertyValues in einer Function-Description
138 #define SC_FUNCDESC_PROPCOUNT	5
139 
140 //------------------------------------------------------------------------
141 
142 //	alles ohne Which-ID, Map nur fuer PropertySetInfo
143 
144 static const SfxItemPropertyMapEntry* lcl_GetSettingsPropertyMap()
145 {
146     static SfxItemPropertyMapEntry aSettingsPropertyMap_Impl[] =
147 	{
148         {MAP_CHAR_LEN(SC_UNONAME_DOAUTOCP), 0,  &getBooleanCppuType(),              0, 0},
149         {MAP_CHAR_LEN(SC_UNONAME_ENTERED),  0,  &getBooleanCppuType(),              0, 0},
150         {MAP_CHAR_LEN(SC_UNONAME_EXPREF),   0,  &getBooleanCppuType(),              0, 0},
151         {MAP_CHAR_LEN(SC_UNONAME_EXTFMT),   0,  &getBooleanCppuType(),              0, 0},
152         {MAP_CHAR_LEN(SC_UNONAME_LINKUPD),  0,  &getCppuType((sal_Int16*)0),        0, 0},
153         {MAP_CHAR_LEN(SC_UNONAME_MARKHDR),  0,  &getBooleanCppuType(),              0, 0},
154         {MAP_CHAR_LEN(SC_UNONAME_METRIC),   0,  &getCppuType((sal_Int16*)0),        0, 0},
155         {MAP_CHAR_LEN(SC_UNONAME_MOVEDIR),  0,  &getCppuType((sal_Int16*)0),        0, 0},
156         {MAP_CHAR_LEN(SC_UNONAME_MOVESEL),  0,  &getBooleanCppuType(),              0, 0},
157         {MAP_CHAR_LEN(SC_UNONAME_PRALLSH),  0,  &getBooleanCppuType(),              0, 0},
158         {MAP_CHAR_LEN(SC_UNONAME_PREMPTY),  0,  &getBooleanCppuType(),              0, 0},
159         {MAP_CHAR_LEN(SC_UNONAME_RANGEFIN), 0,  &getBooleanCppuType(),              0, 0},
160         {MAP_CHAR_LEN(SC_UNONAME_SCALE),    0,  &getCppuType((sal_Int16*)0),        0, 0},
161         {MAP_CHAR_LEN(SC_UNONAME_STBFUNC),  0,  &getCppuType((sal_Int16*)0),        0, 0},
162         {MAP_CHAR_LEN(SC_UNONAME_ULISTS),   0,  &getCppuType((uno::Sequence<rtl::OUString>*)0), 0, 0},
163         {MAP_CHAR_LEN(SC_UNONAME_PRMETRICS),0,  &getBooleanCppuType(),              0, 0},
164         {MAP_CHAR_LEN(SC_UNONAME_USETABCOL),0,  &getBooleanCppuType(),              0, 0},
165         {MAP_CHAR_LEN(SC_UNONAME_REPLWARN), 0,  &getBooleanCppuType(),              0, 0},
166         {0,0,0,0,0,0}
167 	};
168 	return aSettingsPropertyMap_Impl;
169 }
170 
171 //------------------------------------------------------------------------
172 
173 #define SCFUNCTIONLISTOBJ_SERVICE		"com.sun.star.sheet.FunctionDescriptions"
174 #define SCRECENTFUNCTIONSOBJ_SERVICE	"com.sun.star.sheet.RecentFunctions"
175 #define SCSPREADSHEETSETTINGS_SERVICE	"com.sun.star.sheet.GlobalSheetSettings"
176 
177 SC_SIMPLE_SERVICE_INFO( ScFunctionListObj, "ScFunctionListObj", SCFUNCTIONLISTOBJ_SERVICE )
178 SC_SIMPLE_SERVICE_INFO( ScRecentFunctionsObj, "ScRecentFunctionsObj", SCRECENTFUNCTIONSOBJ_SERVICE )
179 SC_SIMPLE_SERVICE_INFO( ScSpreadsheetSettings, "ScSpreadsheetSettings", SCSPREADSHEETSETTINGS_SERVICE )
180 
181 //------------------------------------------------------------------------
182 
183 extern "C" {
184 
185 SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
186     const sal_Char ** ppEnvTypeName, uno_Environment ** /* ppEnv */ )
187 {
188 	*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
189 }
190 
191 SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
192     const sal_Char * pImplName, void * pServiceManager, void * /* pRegistryKey */ )
193 {
194 	if (!pServiceManager)
195 		return NULL;
196 
197 	uno::Reference<lang::XSingleServiceFactory> xFactory;
198 	rtl::OUString aImpl(rtl::OUString::createFromAscii(pImplName));
199 
200 	if ( aImpl == ScSpreadsheetSettings::getImplementationName_Static() )
201 		xFactory.set(cppu::createOneInstanceFactory(
202 				reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
203 				ScSpreadsheetSettings::getImplementationName_Static(),
204 				ScSpreadsheetSettings_CreateInstance,
205 				ScSpreadsheetSettings::getSupportedServiceNames_Static() ));
206 
207 	if ( aImpl == ScRecentFunctionsObj::getImplementationName_Static() )
208 		xFactory.set(cppu::createOneInstanceFactory(
209 				reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
210 				ScRecentFunctionsObj::getImplementationName_Static(),
211 				ScRecentFunctionsObj_CreateInstance,
212 				ScRecentFunctionsObj::getSupportedServiceNames_Static() ));
213 
214 	if ( aImpl == ScFunctionListObj::getImplementationName_Static() )
215 		xFactory.set(cppu::createOneInstanceFactory(
216 				reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
217 				ScFunctionListObj::getImplementationName_Static(),
218 				ScFunctionListObj_CreateInstance,
219 				ScFunctionListObj::getSupportedServiceNames_Static() ));
220 
221 	if ( aImpl == ScAutoFormatsObj::getImplementationName_Static() )
222 		xFactory.set(cppu::createOneInstanceFactory(
223 				reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
224 				ScAutoFormatsObj::getImplementationName_Static(),
225 				ScAutoFormatsObj_CreateInstance,
226 				ScAutoFormatsObj::getSupportedServiceNames_Static() ));
227 
228 	if ( aImpl == ScFunctionAccess::getImplementationName_Static() )
229 		xFactory.set(cppu::createOneInstanceFactory(
230 				reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
231 				ScFunctionAccess::getImplementationName_Static(),
232 				ScFunctionAccess_CreateInstance,
233 				ScFunctionAccess::getSupportedServiceNames_Static() ));
234 
235 	if ( aImpl == ScFilterOptionsObj::getImplementationName_Static() )
236 		xFactory.set(cppu::createSingleFactory(
237 				reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
238 				ScFilterOptionsObj::getImplementationName_Static(),
239 				ScFilterOptionsObj_CreateInstance,
240 				ScFilterOptionsObj::getSupportedServiceNames_Static() ));
241 
242 	if ( aImpl == ScXMLImport_getImplementationName() )
243 		xFactory.set(cppu::createSingleFactory(
244 				reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
245 				ScXMLImport_getImplementationName(),
246 				ScXMLImport_createInstance,
247 				ScXMLImport_getSupportedServiceNames() ));
248 
249 	if ( aImpl == ScXMLImport_Meta_getImplementationName() )
250 		xFactory.set(cppu::createSingleFactory(
251 				reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
252 				ScXMLImport_Meta_getImplementationName(),
253 				ScXMLImport_Meta_createInstance,
254 				ScXMLImport_Meta_getSupportedServiceNames() ));
255 
256 	if ( aImpl == ScXMLImport_Styles_getImplementationName() )
257 		xFactory.set(cppu::createSingleFactory(
258 				reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
259 				ScXMLImport_Styles_getImplementationName(),
260 				ScXMLImport_Styles_createInstance,
261 				ScXMLImport_Styles_getSupportedServiceNames() ));
262 
263 	if ( aImpl == ScXMLImport_Content_getImplementationName() )
264 		xFactory.set(cppu::createSingleFactory(
265 				reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
266 				ScXMLImport_Content_getImplementationName(),
267 				ScXMLImport_Content_createInstance,
268 				ScXMLImport_Content_getSupportedServiceNames() ));
269 
270 	if ( aImpl == ScXMLImport_Settings_getImplementationName() )
271 		xFactory.set(cppu::createSingleFactory(
272 				reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
273 				ScXMLImport_Settings_getImplementationName(),
274 				ScXMLImport_Settings_createInstance,
275 				ScXMLImport_Settings_getSupportedServiceNames() ));
276 
277 	if ( aImpl == ScXMLOOoExport_getImplementationName() )
278 		xFactory = cppu::createSingleFactory(
279 				reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
280 				ScXMLOOoExport_getImplementationName(),
281 				ScXMLOOoExport_createInstance,
282 				ScXMLOOoExport_getSupportedServiceNames() );
283 
284 	if ( aImpl == ScXMLOOoExport_Meta_getImplementationName() )
285 		xFactory = cppu::createSingleFactory(
286 				reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
287 				ScXMLOOoExport_Meta_getImplementationName(),
288 				ScXMLOOoExport_Meta_createInstance,
289 				ScXMLOOoExport_Meta_getSupportedServiceNames() );
290 
291 	if ( aImpl == ScXMLOOoExport_Styles_getImplementationName() )
292 		xFactory = cppu::createSingleFactory(
293 				reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
294 				ScXMLOOoExport_Styles_getImplementationName(),
295 				ScXMLOOoExport_Styles_createInstance,
296 				ScXMLOOoExport_Styles_getSupportedServiceNames() );
297 
298 	if ( aImpl == ScXMLOOoExport_Content_getImplementationName() )
299 		xFactory = cppu::createSingleFactory(
300 				reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
301 				ScXMLOOoExport_Content_getImplementationName(),
302 				ScXMLOOoExport_Content_createInstance,
303 				ScXMLOOoExport_Content_getSupportedServiceNames() );
304 
305 	if ( aImpl == ScXMLOOoExport_Settings_getImplementationName() )
306 		xFactory = cppu::createSingleFactory(
307 				reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
308 				ScXMLOOoExport_Settings_getImplementationName(),
309 				ScXMLOOoExport_Settings_createInstance,
310 				ScXMLOOoExport_Settings_getSupportedServiceNames() );
311 
312 	if ( aImpl == ScXMLOasisExport_getImplementationName() )
313 		xFactory = cppu::createSingleFactory(
314 				reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
315 				ScXMLOasisExport_getImplementationName(),
316 				ScXMLOasisExport_createInstance,
317 				ScXMLOasisExport_getSupportedServiceNames() );
318 	if ( aImpl == ScXMLOasisExport_Meta_getImplementationName() )
319 		xFactory = cppu::createSingleFactory(
320 				reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
321 				ScXMLOasisExport_Meta_getImplementationName(),
322 				ScXMLOasisExport_Meta_createInstance,
323 				ScXMLOasisExport_Meta_getSupportedServiceNames() );
324 	if ( aImpl == ScXMLOasisExport_Styles_getImplementationName() )
325 		xFactory = cppu::createSingleFactory(
326 				reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
327 				ScXMLOasisExport_Styles_getImplementationName(),
328 				ScXMLOasisExport_Styles_createInstance,
329 				ScXMLOasisExport_Styles_getSupportedServiceNames() );
330 	if ( aImpl == ScXMLOasisExport_Content_getImplementationName() )
331 		xFactory = cppu::createSingleFactory(
332 				reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
333 				ScXMLOasisExport_Content_getImplementationName(),
334 				ScXMLOasisExport_Content_createInstance,
335 				ScXMLOasisExport_Content_getSupportedServiceNames() );
336 	if ( aImpl == ScXMLOasisExport_Settings_getImplementationName() )
337 		xFactory = cppu::createSingleFactory(
338 				reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
339 				ScXMLOasisExport_Settings_getImplementationName(),
340 				ScXMLOasisExport_Settings_createInstance,
341 				ScXMLOasisExport_Settings_getSupportedServiceNames() );
342 
343 	if ( aImpl == ScDocument_getImplementationName() )
344 		xFactory.set(sfx2::createSfxModelFactory(
345 				reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
346 				ScDocument_getImplementationName(),
347 				ScDocument_createInstance,
348 				ScDocument_getSupportedServiceNames() ));
349 
350 	void* pRet = NULL;
351 	if (xFactory.is())
352 	{
353 		xFactory->acquire();
354 		pRet = xFactory.get();
355 	}
356 	return pRet;
357 }
358 
359 }	// extern C
360 
361 //------------------------------------------------------------------------
362 
363 ScSpreadsheetSettings::ScSpreadsheetSettings() :
364 	aPropSet( lcl_GetSettingsPropertyMap() )
365 {
366 }
367 
368 ScSpreadsheetSettings::~ScSpreadsheetSettings()
369 {
370 }
371 
372 uno::Reference<uno::XInterface>	SAL_CALL ScSpreadsheetSettings_CreateInstance(
373                         const uno::Reference<lang::XMultiServiceFactory>& /* rSMgr */ )
374 {
375 	ScUnoGuard aGuard;
376 	ScDLL::Init();
377 	static uno::Reference<uno::XInterface> xInst((cppu::OWeakObject*)new ScSpreadsheetSettings());
378 	return xInst;
379 }
380 
381 rtl::OUString ScSpreadsheetSettings::getImplementationName_Static()
382 {
383 	return rtl::OUString::createFromAscii( "stardiv.StarCalc.ScSpreadsheetSettings" );
384 }
385 
386 uno::Sequence<rtl::OUString> ScSpreadsheetSettings::getSupportedServiceNames_Static()
387 {
388 	uno::Sequence<rtl::OUString> aRet(1);
389 	rtl::OUString* pArray = aRet.getArray();
390 	pArray[0] = rtl::OUString::createFromAscii( SCSPREADSHEETSETTINGS_SERVICE );
391 	return aRet;
392 }
393 
394 // XPropertySet
395 
396 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScSpreadsheetSettings::getPropertySetInfo()
397 														throw(uno::RuntimeException)
398 {
399 	ScUnoGuard aGuard;
400 	static uno::Reference<beans::XPropertySetInfo> aRef(
401 		new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
402 	return aRef;
403 }
404 
405 void SAL_CALL ScSpreadsheetSettings::setPropertyValue(
406 						const rtl::OUString& aPropertyName, const uno::Any& aValue )
407 				throw(beans::UnknownPropertyException, beans::PropertyVetoException,
408 						lang::IllegalArgumentException, lang::WrappedTargetException,
409 						uno::RuntimeException)
410 {
411 	ScUnoGuard aGuard;
412 	String aString(aPropertyName);
413 
414 	ScModule* pScMod = SC_MOD();
415 	ScAppOptions   aAppOpt(pScMod->GetAppOptions());
416 	ScInputOptions aInpOpt(pScMod->GetInputOptions());
417 	sal_Bool bSaveApp = sal_False;
418 	sal_Bool bSaveInp = sal_False;
419 	// print options aren't loaded until needed
420 
421 	if (aString.EqualsAscii( SC_UNONAME_DOAUTOCP ))
422 	{
423 		aAppOpt.SetAutoComplete( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
424 		bSaveApp = sal_True;
425 	}
426 	else if (aString.EqualsAscii( SC_UNONAME_ENTERED ))
427 	{
428 		aInpOpt.SetEnterEdit( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
429 		bSaveInp = sal_True;
430 	}
431 	else if (aString.EqualsAscii( SC_UNONAME_EXPREF ))
432 	{
433 		aInpOpt.SetExpandRefs( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
434 		bSaveInp = sal_True;
435 	}
436 	else if (aString.EqualsAscii( SC_UNONAME_EXTFMT ))
437 	{
438 		aInpOpt.SetExtendFormat( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
439 		bSaveInp = sal_True;
440 	}
441 	else if (aString.EqualsAscii( SC_UNONAME_LINKUPD ))
442 	{
443 		aAppOpt.SetLinkMode( (ScLkUpdMode) ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
444 		bSaveApp = sal_True;
445 	}
446 	else if (aString.EqualsAscii( SC_UNONAME_MARKHDR ))
447 	{
448 		aInpOpt.SetMarkHeader( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
449 		bSaveInp = sal_True;
450 	}
451 	else if (aString.EqualsAscii( SC_UNONAME_MOVESEL ))
452 	{
453 		aInpOpt.SetMoveSelection( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
454 		bSaveInp = sal_True;
455 	}
456 	else if (aString.EqualsAscii( SC_UNONAME_RANGEFIN ))
457 	{
458 		aInpOpt.SetRangeFinder( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
459 		bSaveInp = sal_True;
460 	}
461 	else if (aString.EqualsAscii( SC_UNONAME_USETABCOL ))
462 	{
463 		aInpOpt.SetUseTabCol( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
464 		bSaveInp = sal_True;
465 	}
466 	else if (aString.EqualsAscii( SC_UNONAME_PRMETRICS ))
467 	{
468 		aInpOpt.SetTextWysiwyg( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
469 		bSaveInp = sal_True;
470 	}
471     else if (aString.EqualsAscii( SC_UNONAME_REPLWARN ))
472 	{
473         aInpOpt.SetReplaceCellsWarn( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
474 		bSaveInp = sal_True;
475 	}
476 	else if (aString.EqualsAscii( SC_UNONAME_METRIC ))
477 	{
478 		aAppOpt.SetAppMetric( (FieldUnit) ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
479 		bSaveApp = sal_True;
480 	}
481 	else if (aString.EqualsAscii( SC_UNONAME_MOVEDIR ))
482 	{
483 		aInpOpt.SetMoveDir( ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
484 		bSaveInp = sal_True;
485 	}
486 	else if (aString.EqualsAscii( SC_UNONAME_SCALE ))
487 	{
488 		short nVal = ScUnoHelpFunctions::GetInt16FromAny( aValue );
489 		if ( nVal < 0 )
490 		{
491 			SvxZoomType eType = SVX_ZOOM_PERCENT;
492 			switch (nVal)
493 			{
494 				case SC_ZOOMVAL_OPTIMAL:	eType = SVX_ZOOM_OPTIMAL;	break;
495 				case SC_ZOOMVAL_WHOLEPAGE:	eType = SVX_ZOOM_WHOLEPAGE;	break;
496 				case SC_ZOOMVAL_PAGEWIDTH:	eType = SVX_ZOOM_PAGEWIDTH;	break;
497 			}
498 			aAppOpt.SetZoomType( eType );
499 		}
500 		else if ( nVal >= MINZOOM && nVal <= MAXZOOM )
501 		{
502 			aAppOpt.SetZoom( nVal );
503 			aAppOpt.SetZoomType( SVX_ZOOM_PERCENT );
504 		}
505 		bSaveApp = sal_True;
506 	}
507 	else if (aString.EqualsAscii( SC_UNONAME_STBFUNC ))
508 	{
509 		aAppOpt.SetStatusFunc( ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
510 		bSaveApp = sal_True;
511 	}
512 	else if (aString.EqualsAscii( SC_UNONAME_ULISTS ))
513 	{
514 		ScUserList* pUserList = ScGlobal::GetUserList();
515 		uno::Sequence<rtl::OUString> aSeq;
516 		if ( pUserList && ( aValue >>= aSeq ) )
517 		{
518 			//	es wird direkt die "lebende" Liste veraendert,
519 			//	mehr tut ScGlobal::SetUserList auch nicht
520 
521 			pUserList->FreeAll();					// alle Eintraege raus
522 			sal_uInt16 nCount = (sal_uInt16)aSeq.getLength();
523 			const rtl::OUString* pAry = aSeq.getConstArray();
524 			for (sal_uInt16 i=0; i<nCount; i++)
525 			{
526 				String aEntry = pAry[i];
527 				ScUserListData* pData = new ScUserListData(aEntry);
528 				if (!pUserList->Insert(pData))		// hinten anhaengen
529 					delete pData;					// sollte nicht vorkommen
530 			}
531 			bSaveApp = sal_True;	// Liste wird mit den App-Optionen gespeichert
532 		}
533 	}
534 	else if (aString.EqualsAscii( SC_UNONAME_PRALLSH ))
535 	{
536 		ScPrintOptions aPrintOpt(pScMod->GetPrintOptions());
537 		aPrintOpt.SetAllSheets( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
538 		pScMod->SetPrintOptions( aPrintOpt );
539 	}
540 	else if (aString.EqualsAscii( SC_UNONAME_PREMPTY ))
541 	{
542 		ScPrintOptions aPrintOpt(pScMod->GetPrintOptions());
543 		aPrintOpt.SetSkipEmpty( !ScUnoHelpFunctions::GetBoolFromAny( aValue ) );	// reversed
544 		pScMod->SetPrintOptions( aPrintOpt );
545 		SFX_APP()->Broadcast( SfxSimpleHint( SID_SCPRINTOPTIONS ) );	// update previews
546 	}
547 
548 	if ( bSaveApp )
549 		pScMod->SetAppOptions( aAppOpt );
550 	if ( bSaveInp )
551 		pScMod->SetInputOptions( aInpOpt );
552 }
553 
554 uno::Any SAL_CALL ScSpreadsheetSettings::getPropertyValue( const rtl::OUString& aPropertyName )
555 				throw(beans::UnknownPropertyException, lang::WrappedTargetException,
556 						uno::RuntimeException)
557 {
558 	ScUnoGuard aGuard;
559 	String aString = aPropertyName;
560 	uno::Any aRet;
561 
562 	ScModule* pScMod = SC_MOD();
563 	ScAppOptions   aAppOpt = pScMod->GetAppOptions();
564 	ScInputOptions aInpOpt = pScMod->GetInputOptions();
565 	// print options aren't loaded until needed
566 
567 	if (aString.EqualsAscii( SC_UNONAME_DOAUTOCP ))		ScUnoHelpFunctions::SetBoolInAny( aRet, aAppOpt.GetAutoComplete() );
568 	else if (aString.EqualsAscii( SC_UNONAME_ENTERED ))	ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetEnterEdit() );
569 	else if (aString.EqualsAscii( SC_UNONAME_EXPREF ))	ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetExpandRefs() );
570 	else if (aString.EqualsAscii( SC_UNONAME_EXTFMT ))	ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetExtendFormat() );
571 	else if (aString.EqualsAscii( SC_UNONAME_LINKUPD ))	aRet <<= (sal_Int16) aAppOpt.GetLinkMode();
572 	else if (aString.EqualsAscii( SC_UNONAME_MARKHDR ))	ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetMarkHeader() );
573 	else if (aString.EqualsAscii( SC_UNONAME_MOVESEL ))	ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetMoveSelection() );
574 	else if (aString.EqualsAscii( SC_UNONAME_RANGEFIN )) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetRangeFinder() );
575 	else if (aString.EqualsAscii( SC_UNONAME_USETABCOL )) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetUseTabCol() );
576 	else if (aString.EqualsAscii( SC_UNONAME_PRMETRICS )) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetTextWysiwyg() );
577     else if (aString.EqualsAscii( SC_UNONAME_REPLWARN )) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetReplaceCellsWarn() );
578 	else if (aString.EqualsAscii( SC_UNONAME_METRIC ))	aRet <<= (sal_Int16) aAppOpt.GetAppMetric();
579 	else if (aString.EqualsAscii( SC_UNONAME_MOVEDIR ))	aRet <<= (sal_Int16) aInpOpt.GetMoveDir();
580 	else if (aString.EqualsAscii( SC_UNONAME_STBFUNC ))	aRet <<= (sal_Int16) aAppOpt.GetStatusFunc();
581 	else if (aString.EqualsAscii( SC_UNONAME_SCALE ))
582 	{
583 		sal_Int16 nZoomVal = 0;
584 		switch ( aAppOpt.GetZoomType() )
585 		{
586 			case SVX_ZOOM_PERCENT:	 nZoomVal = aAppOpt.GetZoom();	  break;
587 			case SVX_ZOOM_OPTIMAL:	 nZoomVal = SC_ZOOMVAL_OPTIMAL;	  break;
588 			case SVX_ZOOM_WHOLEPAGE: nZoomVal = SC_ZOOMVAL_WHOLEPAGE; break;
589 			case SVX_ZOOM_PAGEWIDTH: nZoomVal = SC_ZOOMVAL_PAGEWIDTH; break;
590             default:
591             {
592                 // added to avoid warnings
593             }
594 		}
595 		aRet <<= (sal_Int16) nZoomVal;
596 	}
597 	else if (aString.EqualsAscii( SC_UNONAME_ULISTS ))
598 	{
599 		ScUserList* pUserList = ScGlobal::GetUserList();
600 		if (pUserList)
601 		{
602 			sal_uInt16 nCount = pUserList->GetCount();
603 			uno::Sequence<rtl::OUString> aSeq(nCount);
604 			rtl::OUString* pAry = aSeq.getArray();
605 			for (sal_uInt16 i=0; i<nCount; i++)
606 			{
607 				String aEntry((*pUserList)[i]->GetString());
608 				pAry[i] = aEntry;
609 			}
610 			aRet <<= aSeq;
611 		}
612 	}
613 	else if (aString.EqualsAscii( SC_UNONAME_PRALLSH ))
614 		ScUnoHelpFunctions::SetBoolInAny( aRet, pScMod->GetPrintOptions().GetAllSheets() );
615 	else if (aString.EqualsAscii( SC_UNONAME_PREMPTY ))
616 		ScUnoHelpFunctions::SetBoolInAny( aRet, !pScMod->GetPrintOptions().GetSkipEmpty() );	// reversed
617 
618 	return aRet;
619 }
620 
621 SC_IMPL_DUMMY_PROPERTY_LISTENER( ScSpreadsheetSettings )
622 
623 //------------------------------------------------------------------------
624 
625 ScRecentFunctionsObj::ScRecentFunctionsObj()
626 {
627 }
628 
629 ScRecentFunctionsObj::~ScRecentFunctionsObj()
630 {
631 }
632 
633 // stuff for exService_...
634 
635 uno::Reference<uno::XInterface>	SAL_CALL ScRecentFunctionsObj_CreateInstance(
636                         const uno::Reference<lang::XMultiServiceFactory>& /* rSMgr */ )
637 {
638 	ScUnoGuard aGuard;
639 	ScDLL::Init();
640 	static uno::Reference<uno::XInterface> xInst((cppu::OWeakObject*)new ScRecentFunctionsObj());
641 	return xInst;
642 }
643 
644 rtl::OUString ScRecentFunctionsObj::getImplementationName_Static()
645 {
646 	return rtl::OUString::createFromAscii( "stardiv.StarCalc.ScRecentFunctionsObj" );
647 }
648 
649 uno::Sequence<rtl::OUString> ScRecentFunctionsObj::getSupportedServiceNames_Static()
650 {
651 	uno::Sequence<rtl::OUString> aRet(1);
652 	rtl::OUString* pArray = aRet.getArray();
653 	pArray[0] = rtl::OUString::createFromAscii( SCRECENTFUNCTIONSOBJ_SERVICE );
654 	return aRet;
655 }
656 
657 // XRecentFunctions
658 
659 uno::Sequence<sal_Int32> SAL_CALL ScRecentFunctionsObj::getRecentFunctionIds()
660 														throw(uno::RuntimeException)
661 {
662 	ScUnoGuard aGuard;
663 	const ScAppOptions& rOpt = SC_MOD()->GetAppOptions();
664 	sal_uInt16 nCount = rOpt.GetLRUFuncListCount();
665 	const sal_uInt16* pFuncs = rOpt.GetLRUFuncList();
666 	if (pFuncs)
667 	{
668 		uno::Sequence<sal_Int32> aSeq(nCount);
669 		sal_Int32* pAry = aSeq.getArray();
670 		for (sal_uInt16 i=0; i<nCount; i++)
671 			pAry[i] = pFuncs[i];
672 		return aSeq;
673 	}
674 	return uno::Sequence<sal_Int32>(0);
675 }
676 
677 void SAL_CALL ScRecentFunctionsObj::setRecentFunctionIds(
678 					const uno::Sequence<sal_Int32>& aRecentFunctionIds )
679 									throw(uno::RuntimeException)
680 {
681 	ScUnoGuard aGuard;
682 	sal_uInt16 nCount = (sal_uInt16) Min( aRecentFunctionIds.getLength(), (sal_Int32) LRU_MAX );
683 	const sal_Int32* pAry = aRecentFunctionIds.getConstArray();
684 
685 	sal_uInt16* pFuncs = nCount ? new sal_uInt16[nCount] : NULL;
686 	for (sal_uInt16 i=0; i<nCount; i++)
687 		pFuncs[i] = (sal_uInt16)pAry[i];		//! auf gueltige Werte testen?
688 
689 	ScModule* pScMod = SC_MOD();
690 	ScAppOptions aNewOpts(pScMod->GetAppOptions());
691 	aNewOpts.SetLRUFuncList(pFuncs, nCount);
692 	pScMod->SetAppOptions(aNewOpts);
693 
694 	pScMod->RecentFunctionsChanged();		// update function list child window
695 
696 	delete[] pFuncs;
697 }
698 
699 sal_Int32 SAL_CALL ScRecentFunctionsObj::getMaxRecentFunctions() throw(uno::RuntimeException)
700 {
701 	return LRU_MAX;
702 }
703 
704 //------------------------------------------------------------------------
705 
706 ScFunctionListObj::ScFunctionListObj()
707 {
708 }
709 
710 ScFunctionListObj::~ScFunctionListObj()
711 {
712 }
713 
714 // stuff for exService_...
715 
716 uno::Reference<uno::XInterface>	SAL_CALL ScFunctionListObj_CreateInstance(
717                         const uno::Reference<lang::XMultiServiceFactory>& /* rSMgr */ )
718 {
719 	ScUnoGuard aGuard;
720 	ScDLL::Init();
721 	static uno::Reference<uno::XInterface> xInst((cppu::OWeakObject*)new ScFunctionListObj());
722 	return xInst;
723 }
724 
725 rtl::OUString ScFunctionListObj::getImplementationName_Static()
726 {
727 	return rtl::OUString::createFromAscii( "stardiv.StarCalc.ScFunctionListObj" );
728 }
729 
730 uno::Sequence<rtl::OUString> ScFunctionListObj::getSupportedServiceNames_Static()
731 {
732 	uno::Sequence<rtl::OUString> aRet(1);
733 	rtl::OUString* pArray = aRet.getArray();
734 	pArray[0] = rtl::OUString::createFromAscii( SCFUNCTIONLISTOBJ_SERVICE );
735 	return aRet;
736 }
737 
738 
739 static void lcl_FillSequence( uno::Sequence<beans::PropertyValue>& rSequence, const ScFuncDesc& rDesc )
740 {
741     rDesc.initArgumentInfo();   // full argument info is needed
742 
743 	DBG_ASSERT( rSequence.getLength() == SC_FUNCDESC_PROPCOUNT, "Falscher Count" );
744 
745 	beans::PropertyValue* pArray = rSequence.getArray();
746 
747 	pArray[0].Name = rtl::OUString::createFromAscii( SC_UNONAME_ID );
748 	pArray[0].Value <<= (sal_Int32) rDesc.nFIndex;
749 
750 	pArray[1].Name = rtl::OUString::createFromAscii( SC_UNONAME_CATEGORY );
751 	pArray[1].Value <<= (sal_Int32) rDesc.nCategory;
752 
753 	pArray[2].Name = rtl::OUString::createFromAscii( SC_UNONAME_NAME );
754 	if (rDesc.pFuncName)
755 		pArray[2].Value <<= rtl::OUString( *rDesc.pFuncName );
756 
757 	pArray[3].Name = rtl::OUString::createFromAscii( SC_UNONAME_DESCRIPTION );
758 	if (rDesc.pFuncDesc)
759 		pArray[3].Value <<= rtl::OUString( *rDesc.pFuncDesc );
760 
761 	pArray[4].Name = rtl::OUString::createFromAscii( SC_UNONAME_ARGUMENTS );
762 	if (rDesc.ppDefArgNames && rDesc.ppDefArgDescs && rDesc.pDefArgFlags )
763 	{
764 		sal_uInt16 nCount = rDesc.nArgCount;
765 		if (nCount >= PAIRED_VAR_ARGS)
766 		    nCount -= PAIRED_VAR_ARGS - 2;
767         else if (nCount >= VAR_ARGS)
768             nCount -= VAR_ARGS - 1;
769         sal_uInt16 nSeqCount = rDesc.GetSuppressedArgCount();
770         if (nSeqCount >= PAIRED_VAR_ARGS)
771             nSeqCount -= PAIRED_VAR_ARGS - 2;
772         else if (nSeqCount >= VAR_ARGS)
773             nSeqCount -= VAR_ARGS - 1;
774 
775         if (nSeqCount)
776         {
777             uno::Sequence<sheet::FunctionArgument> aArgSeq(nSeqCount);
778             sheet::FunctionArgument* pArgAry = aArgSeq.getArray();
779             for (sal_uInt16 i=0, j=0; i<nCount; i++)
780             {
781                 if (!rDesc.pDefArgFlags[i].bSuppress)
782                 {
783                     String aArgName;
784                     if (rDesc.ppDefArgNames[i]) aArgName = *rDesc.ppDefArgNames[i];
785                     String aArgDesc;
786                     if (rDesc.ppDefArgDescs[i]) aArgDesc = *rDesc.ppDefArgDescs[i];
787                     sheet::FunctionArgument aArgument;
788                     aArgument.Name		  = aArgName;
789                     aArgument.Description = aArgDesc;
790                     aArgument.IsOptional  = rDesc.pDefArgFlags[i].bOptional;
791                     pArgAry[j++] = aArgument;
792                 }
793             }
794             pArray[4].Value <<= aArgSeq;
795         }
796 	}
797 }
798 
799 // XFunctionDescriptions
800 
801 uno::Sequence<beans::PropertyValue> SAL_CALL ScFunctionListObj::getById( sal_Int32 nId )
802 								throw(lang::IllegalArgumentException, uno::RuntimeException)
803 {
804 	ScUnoGuard aGuard;
805 	const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
806 	if ( pFuncList )
807 	{
808 		sal_uInt16 nCount = (sal_uInt16)pFuncList->GetCount();
809 		for (sal_uInt16 nIndex=0; nIndex<nCount; nIndex++)
810 		{
811 			const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
812 			if ( pDesc && pDesc->nFIndex == nId )
813 			{
814 				uno::Sequence<beans::PropertyValue> aSeq( SC_FUNCDESC_PROPCOUNT );
815 				lcl_FillSequence( aSeq, *pDesc );
816 				return aSeq;
817 			}
818 		}
819 
820 		throw lang::IllegalArgumentException();			// not found
821 	}
822 	else
823 		throw uno::RuntimeException();					// should not happen
824 
825 //    return uno::Sequence<beans::PropertyValue>(0);
826 }
827 
828 // XNameAccess
829 
830 uno::Any SAL_CALL ScFunctionListObj::getByName( const rtl::OUString& aName )
831 			throw(container::NoSuchElementException,
832 					lang::WrappedTargetException, uno::RuntimeException)
833 {
834 	ScUnoGuard aGuard;
835 	String aNameStr(aName);
836 	const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
837 	if ( pFuncList )
838 	{
839 		sal_uInt16 nCount = (sal_uInt16)pFuncList->GetCount();
840 		for (sal_uInt16 nIndex=0; nIndex<nCount; nIndex++)
841 		{
842 			const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
843 			//!	Case-insensitiv ???
844 			if ( pDesc && pDesc->pFuncName && aNameStr == *pDesc->pFuncName )
845 			{
846 				uno::Sequence<beans::PropertyValue> aSeq( SC_FUNCDESC_PROPCOUNT );
847 				lcl_FillSequence( aSeq, *pDesc );
848                 return uno::makeAny(aSeq);
849 			}
850 		}
851 
852 		throw container::NoSuchElementException();		// not found
853 	}
854 	else
855 		throw uno::RuntimeException();					// should not happen
856 
857 //    return uno::Any();
858 }
859 
860 // XIndexAccess
861 
862 sal_Int32 SAL_CALL ScFunctionListObj::getCount() throw(uno::RuntimeException)
863 {
864 	ScUnoGuard aGuard;
865 	sal_uInt16 nCount = 0;
866 	const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
867 	if ( pFuncList )
868 		nCount = (sal_uInt16)pFuncList->GetCount();
869 	return nCount;
870 }
871 
872 uno::Any SAL_CALL ScFunctionListObj::getByIndex( sal_Int32 nIndex )
873 							throw(lang::IndexOutOfBoundsException,
874 									lang::WrappedTargetException, uno::RuntimeException)
875 {
876 	ScUnoGuard aGuard;
877 	const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
878 	if ( pFuncList )
879 	{
880 		if ( nIndex >= 0 && nIndex < (sal_Int32)pFuncList->GetCount() )
881 		{
882 			const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
883 			if ( pDesc )
884 			{
885 				uno::Sequence<beans::PropertyValue> aSeq( SC_FUNCDESC_PROPCOUNT );
886 				lcl_FillSequence( aSeq, *pDesc );
887                 return uno::makeAny(aSeq);
888 			}
889 		}
890 
891 		throw lang::IndexOutOfBoundsException();		// illegal index
892 	}
893 	else
894 		throw uno::RuntimeException();					// should not happen
895 
896 //    return uno::Any();
897 }
898 
899 // XEnumerationAccess
900 
901 uno::Reference<container::XEnumeration> SAL_CALL ScFunctionListObj::createEnumeration()
902 													throw(uno::RuntimeException)
903 {
904 	ScUnoGuard aGuard;
905     return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.FunctionDescriptionEnumeration")));
906 }
907 
908 // XElementAccess
909 
910 uno::Type SAL_CALL ScFunctionListObj::getElementType() throw(uno::RuntimeException)
911 {
912 	ScUnoGuard aGuard;
913 	return getCppuType((uno::Sequence<beans::PropertyValue>*)0);
914 }
915 
916 sal_Bool SAL_CALL ScFunctionListObj::hasElements() throw(uno::RuntimeException)
917 {
918 	ScUnoGuard aGuard;
919 	return ( getCount() > 0 );
920 }
921 
922 uno::Sequence<rtl::OUString> SAL_CALL ScFunctionListObj::getElementNames() throw(uno::RuntimeException)
923 {
924 	ScUnoGuard aGuard;
925 	const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
926 	if ( pFuncList )
927 	{
928 		sal_uInt16 nCount = (sal_uInt16)pFuncList->GetCount();
929 		uno::Sequence<rtl::OUString> aSeq(nCount);
930 		rtl::OUString* pAry = aSeq.getArray();
931 		for (sal_uInt16 nIndex=0; nIndex<nCount; nIndex++)
932 		{
933 			const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
934 			if ( pDesc && pDesc->pFuncName )
935 				pAry[nIndex] = *pDesc->pFuncName;
936 		}
937 		return aSeq;
938 	}
939 	return uno::Sequence<rtl::OUString>(0);
940 }
941 
942 sal_Bool SAL_CALL ScFunctionListObj::hasByName( const rtl::OUString& aName )
943 										throw(uno::RuntimeException)
944 {
945 	ScUnoGuard aGuard;
946 	String aNameStr(aName);
947 	const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
948 	if ( pFuncList )
949 	{
950 		sal_uInt16 nCount = (sal_uInt16)pFuncList->GetCount();
951 		for (sal_uInt16 nIndex=0; nIndex<nCount; nIndex++)
952 		{
953 			const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
954 			//!	Case-insensitiv ???
955 			if ( pDesc && pDesc->pFuncName && aNameStr == *pDesc->pFuncName )
956 				return sal_True;
957 		}
958 	}
959 	return sal_False;
960 }
961 
962 //------------------------------------------------------------------------
963 
964 
965 
966 
967