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