update dev300-m58
[ooovba.git] / sc / source / ui / unoobj / appluno.cxx
blob18d3b8625ec88d4291f63112dabb8f097cd8f361
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: appluno.cxx,v $
10 * $Revision: 1.25 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 #include "appluno.hxx"
35 #include "sal/types.h"
36 #include <osl/diagnose.h>
37 #include <cppuhelper/factory.hxx>
39 #include <sfx2/app.hxx>
40 #include <sfx2/sfxmodelfactory.hxx>
41 #include "afmtuno.hxx"
42 #include "funcuno.hxx"
43 #include "filtuno.hxx"
44 #include "miscuno.hxx"
45 #include "scmod.hxx"
46 #include "appoptio.hxx"
47 #include "inputopt.hxx"
48 #include "printopt.hxx"
49 #include "userlist.hxx"
50 #include "sc.hrc" // VAR_ARGS
51 #include "unoguard.hxx"
52 #include "unonames.hxx"
53 #include "funcdesc.hxx"
54 #include <com/sun/star/sheet/FunctionArgument.hpp>
56 using namespace com::sun::star;
58 //------------------------------------------------------------------------
60 // Calc document
61 extern uno::Sequence< rtl::OUString > SAL_CALL ScDocument_getSupportedServiceNames() throw();
62 extern rtl::OUString SAL_CALL ScDocument_getImplementationName() throw();
63 extern uno::Reference< uno::XInterface > SAL_CALL ScDocument_createInstance(
64 const uno::Reference< lang::XMultiServiceFactory > & rSMgr, const sal_uInt64 _nCreationFlags ) throw( uno::Exception );
66 // Calc XML import
67 extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLImport_getSupportedServiceNames() throw();
68 extern rtl::OUString SAL_CALL ScXMLImport_getImplementationName() throw();
69 extern uno::Reference< uno::XInterface > SAL_CALL ScXMLImport_createInstance(
70 const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
71 extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLImport_Meta_getSupportedServiceNames() throw();
72 extern rtl::OUString SAL_CALL ScXMLImport_Meta_getImplementationName() throw();
73 extern uno::Reference< uno::XInterface > SAL_CALL ScXMLImport_Meta_createInstance(
74 const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
75 extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLImport_Styles_getSupportedServiceNames() throw();
76 extern rtl::OUString SAL_CALL ScXMLImport_Styles_getImplementationName() throw();
77 extern uno::Reference< uno::XInterface > SAL_CALL ScXMLImport_Styles_createInstance(
78 const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
79 extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLImport_Content_getSupportedServiceNames() throw();
80 extern rtl::OUString SAL_CALL ScXMLImport_Content_getImplementationName() throw();
81 extern uno::Reference< uno::XInterface > SAL_CALL ScXMLImport_Content_createInstance(
82 const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
83 extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLImport_Settings_getSupportedServiceNames() throw();
84 extern rtl::OUString SAL_CALL ScXMLImport_Settings_getImplementationName() throw();
85 extern uno::Reference< uno::XInterface > SAL_CALL ScXMLImport_Settings_createInstance(
86 const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
88 // Calc XML export
89 extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLOOoExport_getSupportedServiceNames() throw();
90 extern rtl::OUString SAL_CALL ScXMLOOoExport_getImplementationName() throw();
91 extern uno::Reference< uno::XInterface > SAL_CALL ScXMLOOoExport_createInstance(
92 const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
93 extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLOOoExport_Meta_getSupportedServiceNames() throw();
94 extern rtl::OUString SAL_CALL ScXMLOOoExport_Meta_getImplementationName() throw();
95 extern uno::Reference< uno::XInterface > SAL_CALL ScXMLOOoExport_Meta_createInstance(
96 const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
97 extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLOOoExport_Styles_getSupportedServiceNames() throw();
98 extern rtl::OUString SAL_CALL ScXMLOOoExport_Styles_getImplementationName() throw();
99 extern uno::Reference< uno::XInterface > SAL_CALL ScXMLOOoExport_Styles_createInstance(
100 const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
101 extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLOOoExport_Content_getSupportedServiceNames() throw();
102 extern rtl::OUString SAL_CALL ScXMLOOoExport_Content_getImplementationName() throw();
103 extern uno::Reference< uno::XInterface > SAL_CALL ScXMLOOoExport_Content_createInstance(
104 const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
105 extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLOOoExport_Settings_getSupportedServiceNames() throw();
106 extern rtl::OUString SAL_CALL ScXMLOOoExport_Settings_getImplementationName() throw();
107 extern uno::Reference< uno::XInterface > SAL_CALL ScXMLOOoExport_Settings_createInstance(
108 const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
110 // Calc XML Oasis export
111 extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLOasisExport_getSupportedServiceNames() throw();
112 extern rtl::OUString SAL_CALL ScXMLOasisExport_getImplementationName() throw();
113 extern uno::Reference< uno::XInterface > SAL_CALL ScXMLOasisExport_createInstance(
114 const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
115 extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLOasisExport_Meta_getSupportedServiceNames() throw();
116 extern rtl::OUString SAL_CALL ScXMLOasisExport_Meta_getImplementationName() throw();
117 extern uno::Reference< uno::XInterface > SAL_CALL ScXMLOasisExport_Meta_createInstance(
118 const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
119 extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLOasisExport_Styles_getSupportedServiceNames() throw();
120 extern rtl::OUString SAL_CALL ScXMLOasisExport_Styles_getImplementationName() throw();
121 extern uno::Reference< uno::XInterface > SAL_CALL ScXMLOasisExport_Styles_createInstance(
122 const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
123 extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLOasisExport_Content_getSupportedServiceNames() throw();
124 extern rtl::OUString SAL_CALL ScXMLOasisExport_Content_getImplementationName() throw();
125 extern uno::Reference< uno::XInterface > SAL_CALL ScXMLOasisExport_Content_createInstance(
126 const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
127 extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLOasisExport_Settings_getSupportedServiceNames() throw();
128 extern rtl::OUString SAL_CALL ScXMLOasisExport_Settings_getImplementationName() throw();
129 extern uno::Reference< uno::XInterface > SAL_CALL ScXMLOasisExport_Settings_createInstance(
130 const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
132 //------------------------------------------------------------------------
134 // Anzahl der Funktionen, die als zuletzt benutzt gespeichert werden
135 //! Define mit funcpage.hxx und dwfunctr.hxx zusammenfassen !!!
136 #define LRU_MAX 10
138 // Spezial-Werte fuer Zoom
139 //! irgendwo zentral
140 #define SC_ZOOMVAL_OPTIMAL (-1)
141 #define SC_ZOOMVAL_WHOLEPAGE (-2)
142 #define SC_ZOOMVAL_PAGEWIDTH (-3)
144 // Anzahl der PropertyValues in einer Function-Description
145 #define SC_FUNCDESC_PROPCOUNT 5
147 //------------------------------------------------------------------------
149 // alles ohne Which-ID, Map nur fuer PropertySetInfo
151 static const SfxItemPropertyMapEntry* lcl_GetSettingsPropertyMap()
153 static SfxItemPropertyMapEntry aSettingsPropertyMap_Impl[] =
155 {MAP_CHAR_LEN(SC_UNONAME_DOAUTOCP), 0, &getBooleanCppuType(), 0, 0},
156 {MAP_CHAR_LEN(SC_UNONAME_ENTERED), 0, &getBooleanCppuType(), 0, 0},
157 {MAP_CHAR_LEN(SC_UNONAME_EXPREF), 0, &getBooleanCppuType(), 0, 0},
158 {MAP_CHAR_LEN(SC_UNONAME_EXTFMT), 0, &getBooleanCppuType(), 0, 0},
159 {MAP_CHAR_LEN(SC_UNONAME_LINKUPD), 0, &getCppuType((sal_Int16*)0), 0, 0},
160 {MAP_CHAR_LEN(SC_UNONAME_MARKHDR), 0, &getBooleanCppuType(), 0, 0},
161 {MAP_CHAR_LEN(SC_UNONAME_METRIC), 0, &getCppuType((sal_Int16*)0), 0, 0},
162 {MAP_CHAR_LEN(SC_UNONAME_MOVEDIR), 0, &getCppuType((sal_Int16*)0), 0, 0},
163 {MAP_CHAR_LEN(SC_UNONAME_MOVESEL), 0, &getBooleanCppuType(), 0, 0},
164 {MAP_CHAR_LEN(SC_UNONAME_PRALLSH), 0, &getBooleanCppuType(), 0, 0},
165 {MAP_CHAR_LEN(SC_UNONAME_PREMPTY), 0, &getBooleanCppuType(), 0, 0},
166 {MAP_CHAR_LEN(SC_UNONAME_RANGEFIN), 0, &getBooleanCppuType(), 0, 0},
167 {MAP_CHAR_LEN(SC_UNONAME_SCALE), 0, &getCppuType((sal_Int16*)0), 0, 0},
168 {MAP_CHAR_LEN(SC_UNONAME_STBFUNC), 0, &getCppuType((sal_Int16*)0), 0, 0},
169 {MAP_CHAR_LEN(SC_UNONAME_ULISTS), 0, &getCppuType((uno::Sequence<rtl::OUString>*)0), 0, 0},
170 {MAP_CHAR_LEN(SC_UNONAME_PRMETRICS),0, &getBooleanCppuType(), 0, 0},
171 {MAP_CHAR_LEN(SC_UNONAME_USETABCOL),0, &getBooleanCppuType(), 0, 0},
172 {MAP_CHAR_LEN(SC_UNONAME_REPLWARN), 0, &getBooleanCppuType(), 0, 0},
173 {0,0,0,0,0,0}
175 return aSettingsPropertyMap_Impl;
178 //------------------------------------------------------------------------
180 #define SCFUNCTIONLISTOBJ_SERVICE "com.sun.star.sheet.FunctionDescriptions"
181 #define SCRECENTFUNCTIONSOBJ_SERVICE "com.sun.star.sheet.RecentFunctions"
182 #define SCSPREADSHEETSETTINGS_SERVICE "com.sun.star.sheet.GlobalSheetSettings"
184 SC_SIMPLE_SERVICE_INFO( ScFunctionListObj, "ScFunctionListObj", SCFUNCTIONLISTOBJ_SERVICE )
185 SC_SIMPLE_SERVICE_INFO( ScRecentFunctionsObj, "ScRecentFunctionsObj", SCRECENTFUNCTIONSOBJ_SERVICE )
186 SC_SIMPLE_SERVICE_INFO( ScSpreadsheetSettings, "ScSpreadsheetSettings", SCSPREADSHEETSETTINGS_SERVICE )
188 //------------------------------------------------------------------------
190 static void lcl_WriteInfo( registry::XRegistryKey* pRegistryKey,
191 const rtl::OUString& rImplementationName,
192 const uno::Sequence< rtl::OUString >& rServices )
193 throw( registry::InvalidRegistryException )
195 rtl::OUString aImpl(rtl::OUString::createFromAscii( "/" ));
196 aImpl += rImplementationName;
197 aImpl += rtl::OUString::createFromAscii( "/UNO/SERVICES" );
198 uno::Reference<registry::XRegistryKey> xNewKey(pRegistryKey->createKey(aImpl));
200 const rtl::OUString* pArray = rServices.getConstArray();
201 for( sal_Int32 i = 0; i < rServices.getLength(); i++ )
202 xNewKey->createKey( pArray[i]);
205 extern "C" {
207 SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
208 const sal_Char ** ppEnvTypeName, uno_Environment ** /* ppEnv */ )
210 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
213 SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
214 void * /* pServiceManager */, registry::XRegistryKey * pRegistryKey )
216 if (pRegistryKey)
220 lcl_WriteInfo( pRegistryKey,
221 ScSpreadsheetSettings::getImplementationName_Static(),
222 ScSpreadsheetSettings::getSupportedServiceNames_Static() );
224 lcl_WriteInfo( pRegistryKey,
225 ScRecentFunctionsObj::getImplementationName_Static(),
226 ScRecentFunctionsObj::getSupportedServiceNames_Static() );
228 lcl_WriteInfo( pRegistryKey,
229 ScFunctionListObj::getImplementationName_Static(),
230 ScFunctionListObj::getSupportedServiceNames_Static() );
232 lcl_WriteInfo( pRegistryKey,
233 ScAutoFormatsObj::getImplementationName_Static(),
234 ScAutoFormatsObj::getSupportedServiceNames_Static() );
236 lcl_WriteInfo( pRegistryKey,
237 ScFunctionAccess::getImplementationName_Static(),
238 ScFunctionAccess::getSupportedServiceNames_Static() );
240 lcl_WriteInfo( pRegistryKey,
241 ScFilterOptionsObj::getImplementationName_Static(),
242 ScFilterOptionsObj::getSupportedServiceNames_Static() );
244 lcl_WriteInfo( pRegistryKey,
245 ScXMLImport_getImplementationName(),
246 ScXMLImport_getSupportedServiceNames() );
248 lcl_WriteInfo( pRegistryKey,
249 ScXMLImport_Meta_getImplementationName(),
250 ScXMLImport_Meta_getSupportedServiceNames() );
252 lcl_WriteInfo( pRegistryKey,
253 ScXMLImport_Styles_getImplementationName(),
254 ScXMLImport_Styles_getSupportedServiceNames() );
256 lcl_WriteInfo( pRegistryKey,
257 ScXMLImport_Content_getImplementationName(),
258 ScXMLImport_Content_getSupportedServiceNames() );
260 lcl_WriteInfo( pRegistryKey,
261 ScXMLImport_Settings_getImplementationName(),
262 ScXMLImport_Settings_getSupportedServiceNames() );
264 lcl_WriteInfo( pRegistryKey,
265 ScXMLOOoExport_getImplementationName(),
266 ScXMLOOoExport_getSupportedServiceNames() );
268 lcl_WriteInfo( pRegistryKey,
269 ScXMLOOoExport_Meta_getImplementationName(),
270 ScXMLOOoExport_Meta_getSupportedServiceNames() );
272 lcl_WriteInfo( pRegistryKey,
273 ScXMLOOoExport_Styles_getImplementationName(),
274 ScXMLOOoExport_Styles_getSupportedServiceNames() );
276 lcl_WriteInfo( pRegistryKey,
277 ScXMLOOoExport_Content_getImplementationName(),
278 ScXMLOOoExport_Content_getSupportedServiceNames() );
280 lcl_WriteInfo( pRegistryKey,
281 ScXMLOOoExport_Settings_getImplementationName(),
282 ScXMLOOoExport_Settings_getSupportedServiceNames() );
284 lcl_WriteInfo( pRegistryKey,
285 ScXMLOasisExport_getImplementationName(),
286 ScXMLOasisExport_getSupportedServiceNames() );
288 lcl_WriteInfo( pRegistryKey,
289 ScXMLOasisExport_Meta_getImplementationName(),
290 ScXMLOasisExport_Meta_getSupportedServiceNames() );
292 lcl_WriteInfo( pRegistryKey,
293 ScXMLOasisExport_Styles_getImplementationName(),
294 ScXMLOasisExport_Styles_getSupportedServiceNames() );
296 lcl_WriteInfo( pRegistryKey,
297 ScXMLOasisExport_Content_getImplementationName(),
298 ScXMLOasisExport_Content_getSupportedServiceNames() );
300 lcl_WriteInfo( pRegistryKey,
301 ScXMLOasisExport_Settings_getImplementationName(),
302 ScXMLOasisExport_Settings_getSupportedServiceNames() );
304 lcl_WriteInfo( pRegistryKey,
305 ScDocument_getImplementationName(),
306 ScDocument_getSupportedServiceNames() );
308 return sal_True;
310 catch (registry::InvalidRegistryException&)
312 OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
315 return sal_False;
318 SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
319 const sal_Char * pImplName, void * pServiceManager, void * /* pRegistryKey */ )
321 if (!pServiceManager)
322 return NULL;
324 uno::Reference<lang::XSingleServiceFactory> xFactory;
325 rtl::OUString aImpl(rtl::OUString::createFromAscii(pImplName));
327 if ( aImpl == ScSpreadsheetSettings::getImplementationName_Static() )
328 xFactory.set(cppu::createOneInstanceFactory(
329 reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
330 ScSpreadsheetSettings::getImplementationName_Static(),
331 ScSpreadsheetSettings_CreateInstance,
332 ScSpreadsheetSettings::getSupportedServiceNames_Static() ));
334 if ( aImpl == ScRecentFunctionsObj::getImplementationName_Static() )
335 xFactory.set(cppu::createOneInstanceFactory(
336 reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
337 ScRecentFunctionsObj::getImplementationName_Static(),
338 ScRecentFunctionsObj_CreateInstance,
339 ScRecentFunctionsObj::getSupportedServiceNames_Static() ));
341 if ( aImpl == ScFunctionListObj::getImplementationName_Static() )
342 xFactory.set(cppu::createOneInstanceFactory(
343 reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
344 ScFunctionListObj::getImplementationName_Static(),
345 ScFunctionListObj_CreateInstance,
346 ScFunctionListObj::getSupportedServiceNames_Static() ));
348 if ( aImpl == ScAutoFormatsObj::getImplementationName_Static() )
349 xFactory.set(cppu::createOneInstanceFactory(
350 reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
351 ScAutoFormatsObj::getImplementationName_Static(),
352 ScAutoFormatsObj_CreateInstance,
353 ScAutoFormatsObj::getSupportedServiceNames_Static() ));
355 if ( aImpl == ScFunctionAccess::getImplementationName_Static() )
356 xFactory.set(cppu::createOneInstanceFactory(
357 reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
358 ScFunctionAccess::getImplementationName_Static(),
359 ScFunctionAccess_CreateInstance,
360 ScFunctionAccess::getSupportedServiceNames_Static() ));
362 if ( aImpl == ScFilterOptionsObj::getImplementationName_Static() )
363 xFactory.set(cppu::createSingleFactory(
364 reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
365 ScFilterOptionsObj::getImplementationName_Static(),
366 ScFilterOptionsObj_CreateInstance,
367 ScFilterOptionsObj::getSupportedServiceNames_Static() ));
369 if ( aImpl == ScXMLImport_getImplementationName() )
370 xFactory.set(cppu::createSingleFactory(
371 reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
372 ScXMLImport_getImplementationName(),
373 ScXMLImport_createInstance,
374 ScXMLImport_getSupportedServiceNames() ));
376 if ( aImpl == ScXMLImport_Meta_getImplementationName() )
377 xFactory.set(cppu::createSingleFactory(
378 reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
379 ScXMLImport_Meta_getImplementationName(),
380 ScXMLImport_Meta_createInstance,
381 ScXMLImport_Meta_getSupportedServiceNames() ));
383 if ( aImpl == ScXMLImport_Styles_getImplementationName() )
384 xFactory.set(cppu::createSingleFactory(
385 reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
386 ScXMLImport_Styles_getImplementationName(),
387 ScXMLImport_Styles_createInstance,
388 ScXMLImport_Styles_getSupportedServiceNames() ));
390 if ( aImpl == ScXMLImport_Content_getImplementationName() )
391 xFactory.set(cppu::createSingleFactory(
392 reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
393 ScXMLImport_Content_getImplementationName(),
394 ScXMLImport_Content_createInstance,
395 ScXMLImport_Content_getSupportedServiceNames() ));
397 if ( aImpl == ScXMLImport_Settings_getImplementationName() )
398 xFactory.set(cppu::createSingleFactory(
399 reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
400 ScXMLImport_Settings_getImplementationName(),
401 ScXMLImport_Settings_createInstance,
402 ScXMLImport_Settings_getSupportedServiceNames() ));
404 if ( aImpl == ScXMLOOoExport_getImplementationName() )
405 xFactory = cppu::createSingleFactory(
406 reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
407 ScXMLOOoExport_getImplementationName(),
408 ScXMLOOoExport_createInstance,
409 ScXMLOOoExport_getSupportedServiceNames() );
411 if ( aImpl == ScXMLOOoExport_Meta_getImplementationName() )
412 xFactory = cppu::createSingleFactory(
413 reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
414 ScXMLOOoExport_Meta_getImplementationName(),
415 ScXMLOOoExport_Meta_createInstance,
416 ScXMLOOoExport_Meta_getSupportedServiceNames() );
418 if ( aImpl == ScXMLOOoExport_Styles_getImplementationName() )
419 xFactory = cppu::createSingleFactory(
420 reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
421 ScXMLOOoExport_Styles_getImplementationName(),
422 ScXMLOOoExport_Styles_createInstance,
423 ScXMLOOoExport_Styles_getSupportedServiceNames() );
425 if ( aImpl == ScXMLOOoExport_Content_getImplementationName() )
426 xFactory = cppu::createSingleFactory(
427 reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
428 ScXMLOOoExport_Content_getImplementationName(),
429 ScXMLOOoExport_Content_createInstance,
430 ScXMLOOoExport_Content_getSupportedServiceNames() );
432 if ( aImpl == ScXMLOOoExport_Settings_getImplementationName() )
433 xFactory = cppu::createSingleFactory(
434 reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
435 ScXMLOOoExport_Settings_getImplementationName(),
436 ScXMLOOoExport_Settings_createInstance,
437 ScXMLOOoExport_Settings_getSupportedServiceNames() );
439 if ( aImpl == ScXMLOasisExport_getImplementationName() )
440 xFactory = cppu::createSingleFactory(
441 reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
442 ScXMLOasisExport_getImplementationName(),
443 ScXMLOasisExport_createInstance,
444 ScXMLOasisExport_getSupportedServiceNames() );
445 if ( aImpl == ScXMLOasisExport_Meta_getImplementationName() )
446 xFactory = cppu::createSingleFactory(
447 reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
448 ScXMLOasisExport_Meta_getImplementationName(),
449 ScXMLOasisExport_Meta_createInstance,
450 ScXMLOasisExport_Meta_getSupportedServiceNames() );
451 if ( aImpl == ScXMLOasisExport_Styles_getImplementationName() )
452 xFactory = cppu::createSingleFactory(
453 reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
454 ScXMLOasisExport_Styles_getImplementationName(),
455 ScXMLOasisExport_Styles_createInstance,
456 ScXMLOasisExport_Styles_getSupportedServiceNames() );
457 if ( aImpl == ScXMLOasisExport_Content_getImplementationName() )
458 xFactory = cppu::createSingleFactory(
459 reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
460 ScXMLOasisExport_Content_getImplementationName(),
461 ScXMLOasisExport_Content_createInstance,
462 ScXMLOasisExport_Content_getSupportedServiceNames() );
463 if ( aImpl == ScXMLOasisExport_Settings_getImplementationName() )
464 xFactory = cppu::createSingleFactory(
465 reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
466 ScXMLOasisExport_Settings_getImplementationName(),
467 ScXMLOasisExport_Settings_createInstance,
468 ScXMLOasisExport_Settings_getSupportedServiceNames() );
470 if ( aImpl == ScDocument_getImplementationName() )
471 xFactory.set(sfx2::createSfxModelFactory(
472 reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
473 ScDocument_getImplementationName(),
474 ScDocument_createInstance,
475 ScDocument_getSupportedServiceNames() ));
477 void* pRet = NULL;
478 if (xFactory.is())
480 xFactory->acquire();
481 pRet = xFactory.get();
483 return pRet;
486 } // extern C
488 //------------------------------------------------------------------------
490 ScSpreadsheetSettings::ScSpreadsheetSettings() :
491 aPropSet( lcl_GetSettingsPropertyMap() )
495 ScSpreadsheetSettings::~ScSpreadsheetSettings()
499 uno::Reference<uno::XInterface> SAL_CALL ScSpreadsheetSettings_CreateInstance(
500 const uno::Reference<lang::XMultiServiceFactory>& /* rSMgr */ )
502 ScUnoGuard aGuard;
503 ScDLL::Init();
504 static uno::Reference<uno::XInterface> xInst((cppu::OWeakObject*)new ScSpreadsheetSettings());
505 return xInst;
508 rtl::OUString ScSpreadsheetSettings::getImplementationName_Static()
510 return rtl::OUString::createFromAscii( "stardiv.StarCalc.ScSpreadsheetSettings" );
513 uno::Sequence<rtl::OUString> ScSpreadsheetSettings::getSupportedServiceNames_Static()
515 uno::Sequence<rtl::OUString> aRet(1);
516 rtl::OUString* pArray = aRet.getArray();
517 pArray[0] = rtl::OUString::createFromAscii( SCSPREADSHEETSETTINGS_SERVICE );
518 return aRet;
521 // XPropertySet
523 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScSpreadsheetSettings::getPropertySetInfo()
524 throw(uno::RuntimeException)
526 ScUnoGuard aGuard;
527 static uno::Reference<beans::XPropertySetInfo> aRef(
528 new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
529 return aRef;
532 void SAL_CALL ScSpreadsheetSettings::setPropertyValue(
533 const rtl::OUString& aPropertyName, const uno::Any& aValue )
534 throw(beans::UnknownPropertyException, beans::PropertyVetoException,
535 lang::IllegalArgumentException, lang::WrappedTargetException,
536 uno::RuntimeException)
538 ScUnoGuard aGuard;
539 String aString(aPropertyName);
541 ScModule* pScMod = SC_MOD();
542 ScAppOptions aAppOpt(pScMod->GetAppOptions());
543 ScInputOptions aInpOpt(pScMod->GetInputOptions());
544 BOOL bSaveApp = FALSE;
545 BOOL bSaveInp = FALSE;
546 // print options aren't loaded until needed
548 if (aString.EqualsAscii( SC_UNONAME_DOAUTOCP ))
550 aAppOpt.SetAutoComplete( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
551 bSaveApp = TRUE;
553 else if (aString.EqualsAscii( SC_UNONAME_ENTERED ))
555 aInpOpt.SetEnterEdit( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
556 bSaveInp = TRUE;
558 else if (aString.EqualsAscii( SC_UNONAME_EXPREF ))
560 aInpOpt.SetExpandRefs( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
561 bSaveInp = TRUE;
563 else if (aString.EqualsAscii( SC_UNONAME_EXTFMT ))
565 aInpOpt.SetExtendFormat( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
566 bSaveInp = TRUE;
568 else if (aString.EqualsAscii( SC_UNONAME_LINKUPD ))
570 aAppOpt.SetLinkMode( (ScLkUpdMode) ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
571 bSaveApp = TRUE;
573 else if (aString.EqualsAscii( SC_UNONAME_MARKHDR ))
575 aInpOpt.SetMarkHeader( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
576 bSaveInp = TRUE;
578 else if (aString.EqualsAscii( SC_UNONAME_MOVESEL ))
580 aInpOpt.SetMoveSelection( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
581 bSaveInp = TRUE;
583 else if (aString.EqualsAscii( SC_UNONAME_RANGEFIN ))
585 aInpOpt.SetRangeFinder( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
586 bSaveInp = TRUE;
588 else if (aString.EqualsAscii( SC_UNONAME_USETABCOL ))
590 aInpOpt.SetUseTabCol( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
591 bSaveInp = TRUE;
593 else if (aString.EqualsAscii( SC_UNONAME_PRMETRICS ))
595 aInpOpt.SetTextWysiwyg( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
596 bSaveInp = TRUE;
598 else if (aString.EqualsAscii( SC_UNONAME_REPLWARN ))
600 aInpOpt.SetReplaceCellsWarn( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
601 bSaveInp = TRUE;
603 else if (aString.EqualsAscii( SC_UNONAME_METRIC ))
605 aAppOpt.SetAppMetric( (FieldUnit) ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
606 bSaveApp = TRUE;
608 else if (aString.EqualsAscii( SC_UNONAME_MOVEDIR ))
610 aInpOpt.SetMoveDir( ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
611 bSaveInp = TRUE;
613 else if (aString.EqualsAscii( SC_UNONAME_SCALE ))
615 short nVal = ScUnoHelpFunctions::GetInt16FromAny( aValue );
616 if ( nVal < 0 )
618 SvxZoomType eType = SVX_ZOOM_PERCENT;
619 switch (nVal)
621 case SC_ZOOMVAL_OPTIMAL: eType = SVX_ZOOM_OPTIMAL; break;
622 case SC_ZOOMVAL_WHOLEPAGE: eType = SVX_ZOOM_WHOLEPAGE; break;
623 case SC_ZOOMVAL_PAGEWIDTH: eType = SVX_ZOOM_PAGEWIDTH; break;
625 aAppOpt.SetZoomType( eType );
627 else if ( nVal >= MINZOOM && nVal <= MAXZOOM )
629 aAppOpt.SetZoom( nVal );
630 aAppOpt.SetZoomType( SVX_ZOOM_PERCENT );
632 bSaveApp = TRUE;
634 else if (aString.EqualsAscii( SC_UNONAME_STBFUNC ))
636 aAppOpt.SetStatusFunc( ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
637 bSaveApp = TRUE;
639 else if (aString.EqualsAscii( SC_UNONAME_ULISTS ))
641 ScUserList* pUserList = ScGlobal::GetUserList();
642 uno::Sequence<rtl::OUString> aSeq;
643 if ( pUserList && ( aValue >>= aSeq ) )
645 // es wird direkt die "lebende" Liste veraendert,
646 // mehr tut ScGlobal::SetUserList auch nicht
648 pUserList->FreeAll(); // alle Eintraege raus
649 USHORT nCount = (USHORT)aSeq.getLength();
650 const rtl::OUString* pAry = aSeq.getConstArray();
651 for (USHORT i=0; i<nCount; i++)
653 String aEntry = pAry[i];
654 ScUserListData* pData = new ScUserListData(aEntry);
655 if (!pUserList->Insert(pData)) // hinten anhaengen
656 delete pData; // sollte nicht vorkommen
658 bSaveApp = TRUE; // Liste wird mit den App-Optionen gespeichert
661 else if (aString.EqualsAscii( SC_UNONAME_PRALLSH ))
663 ScPrintOptions aPrintOpt(pScMod->GetPrintOptions());
664 aPrintOpt.SetAllSheets( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
665 pScMod->SetPrintOptions( aPrintOpt );
667 else if (aString.EqualsAscii( SC_UNONAME_PREMPTY ))
669 ScPrintOptions aPrintOpt(pScMod->GetPrintOptions());
670 aPrintOpt.SetSkipEmpty( !ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); // reversed
671 pScMod->SetPrintOptions( aPrintOpt );
672 SFX_APP()->Broadcast( SfxSimpleHint( SID_SCPRINTOPTIONS ) ); // update previews
675 if ( bSaveApp )
676 pScMod->SetAppOptions( aAppOpt );
677 if ( bSaveInp )
678 pScMod->SetInputOptions( aInpOpt );
681 uno::Any SAL_CALL ScSpreadsheetSettings::getPropertyValue( const rtl::OUString& aPropertyName )
682 throw(beans::UnknownPropertyException, lang::WrappedTargetException,
683 uno::RuntimeException)
685 ScUnoGuard aGuard;
686 String aString = aPropertyName;
687 uno::Any aRet;
689 ScModule* pScMod = SC_MOD();
690 ScAppOptions aAppOpt = pScMod->GetAppOptions();
691 ScInputOptions aInpOpt = pScMod->GetInputOptions();
692 // print options aren't loaded until needed
694 if (aString.EqualsAscii( SC_UNONAME_DOAUTOCP )) ScUnoHelpFunctions::SetBoolInAny( aRet, aAppOpt.GetAutoComplete() );
695 else if (aString.EqualsAscii( SC_UNONAME_ENTERED )) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetEnterEdit() );
696 else if (aString.EqualsAscii( SC_UNONAME_EXPREF )) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetExpandRefs() );
697 else if (aString.EqualsAscii( SC_UNONAME_EXTFMT )) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetExtendFormat() );
698 else if (aString.EqualsAscii( SC_UNONAME_LINKUPD )) aRet <<= (sal_Int16) aAppOpt.GetLinkMode();
699 else if (aString.EqualsAscii( SC_UNONAME_MARKHDR )) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetMarkHeader() );
700 else if (aString.EqualsAscii( SC_UNONAME_MOVESEL )) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetMoveSelection() );
701 else if (aString.EqualsAscii( SC_UNONAME_RANGEFIN )) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetRangeFinder() );
702 else if (aString.EqualsAscii( SC_UNONAME_USETABCOL )) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetUseTabCol() );
703 else if (aString.EqualsAscii( SC_UNONAME_PRMETRICS )) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetTextWysiwyg() );
704 else if (aString.EqualsAscii( SC_UNONAME_REPLWARN )) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetReplaceCellsWarn() );
705 else if (aString.EqualsAscii( SC_UNONAME_METRIC )) aRet <<= (sal_Int16) aAppOpt.GetAppMetric();
706 else if (aString.EqualsAscii( SC_UNONAME_MOVEDIR )) aRet <<= (sal_Int16) aInpOpt.GetMoveDir();
707 else if (aString.EqualsAscii( SC_UNONAME_STBFUNC )) aRet <<= (sal_Int16) aAppOpt.GetStatusFunc();
708 else if (aString.EqualsAscii( SC_UNONAME_SCALE ))
710 INT16 nZoomVal = 0;
711 switch ( aAppOpt.GetZoomType() )
713 case SVX_ZOOM_PERCENT: nZoomVal = aAppOpt.GetZoom(); break;
714 case SVX_ZOOM_OPTIMAL: nZoomVal = SC_ZOOMVAL_OPTIMAL; break;
715 case SVX_ZOOM_WHOLEPAGE: nZoomVal = SC_ZOOMVAL_WHOLEPAGE; break;
716 case SVX_ZOOM_PAGEWIDTH: nZoomVal = SC_ZOOMVAL_PAGEWIDTH; break;
717 default:
719 // added to avoid warnings
722 aRet <<= (sal_Int16) nZoomVal;
724 else if (aString.EqualsAscii( SC_UNONAME_ULISTS ))
726 ScUserList* pUserList = ScGlobal::GetUserList();
727 if (pUserList)
729 USHORT nCount = pUserList->GetCount();
730 uno::Sequence<rtl::OUString> aSeq(nCount);
731 rtl::OUString* pAry = aSeq.getArray();
732 for (USHORT i=0; i<nCount; i++)
734 String aEntry((*pUserList)[i]->GetString());
735 pAry[i] = aEntry;
737 aRet <<= aSeq;
740 else if (aString.EqualsAscii( SC_UNONAME_PRALLSH ))
741 ScUnoHelpFunctions::SetBoolInAny( aRet, pScMod->GetPrintOptions().GetAllSheets() );
742 else if (aString.EqualsAscii( SC_UNONAME_PREMPTY ))
743 ScUnoHelpFunctions::SetBoolInAny( aRet, !pScMod->GetPrintOptions().GetSkipEmpty() ); // reversed
745 return aRet;
748 SC_IMPL_DUMMY_PROPERTY_LISTENER( ScSpreadsheetSettings )
750 //------------------------------------------------------------------------
752 ScRecentFunctionsObj::ScRecentFunctionsObj()
756 ScRecentFunctionsObj::~ScRecentFunctionsObj()
760 // stuff for exService_...
762 uno::Reference<uno::XInterface> SAL_CALL ScRecentFunctionsObj_CreateInstance(
763 const uno::Reference<lang::XMultiServiceFactory>& /* rSMgr */ )
765 ScUnoGuard aGuard;
766 ScDLL::Init();
767 static uno::Reference<uno::XInterface> xInst((cppu::OWeakObject*)new ScRecentFunctionsObj());
768 return xInst;
771 rtl::OUString ScRecentFunctionsObj::getImplementationName_Static()
773 return rtl::OUString::createFromAscii( "stardiv.StarCalc.ScRecentFunctionsObj" );
776 uno::Sequence<rtl::OUString> ScRecentFunctionsObj::getSupportedServiceNames_Static()
778 uno::Sequence<rtl::OUString> aRet(1);
779 rtl::OUString* pArray = aRet.getArray();
780 pArray[0] = rtl::OUString::createFromAscii( SCRECENTFUNCTIONSOBJ_SERVICE );
781 return aRet;
784 // XRecentFunctions
786 uno::Sequence<sal_Int32> SAL_CALL ScRecentFunctionsObj::getRecentFunctionIds()
787 throw(uno::RuntimeException)
789 ScUnoGuard aGuard;
790 const ScAppOptions& rOpt = SC_MOD()->GetAppOptions();
791 USHORT nCount = rOpt.GetLRUFuncListCount();
792 const USHORT* pFuncs = rOpt.GetLRUFuncList();
793 if (pFuncs)
795 uno::Sequence<sal_Int32> aSeq(nCount);
796 sal_Int32* pAry = aSeq.getArray();
797 for (USHORT i=0; i<nCount; i++)
798 pAry[i] = pFuncs[i];
799 return aSeq;
801 return uno::Sequence<sal_Int32>(0);
804 void SAL_CALL ScRecentFunctionsObj::setRecentFunctionIds(
805 const uno::Sequence<sal_Int32>& aRecentFunctionIds )
806 throw(uno::RuntimeException)
808 ScUnoGuard aGuard;
809 USHORT nCount = (USHORT) Min( aRecentFunctionIds.getLength(), (INT32) LRU_MAX );
810 const INT32* pAry = aRecentFunctionIds.getConstArray();
812 USHORT* pFuncs = nCount ? new USHORT[nCount] : NULL;
813 for (USHORT i=0; i<nCount; i++)
814 pFuncs[i] = (USHORT)pAry[i]; //! auf gueltige Werte testen?
816 ScModule* pScMod = SC_MOD();
817 ScAppOptions aNewOpts(pScMod->GetAppOptions());
818 aNewOpts.SetLRUFuncList(pFuncs, nCount);
819 pScMod->SetAppOptions(aNewOpts);
821 pScMod->RecentFunctionsChanged(); // update function list child window
823 delete[] pFuncs;
826 sal_Int32 SAL_CALL ScRecentFunctionsObj::getMaxRecentFunctions() throw(uno::RuntimeException)
828 return LRU_MAX;
831 //------------------------------------------------------------------------
833 ScFunctionListObj::ScFunctionListObj()
837 ScFunctionListObj::~ScFunctionListObj()
841 // stuff for exService_...
843 uno::Reference<uno::XInterface> SAL_CALL ScFunctionListObj_CreateInstance(
844 const uno::Reference<lang::XMultiServiceFactory>& /* rSMgr */ )
846 ScUnoGuard aGuard;
847 ScDLL::Init();
848 static uno::Reference<uno::XInterface> xInst((cppu::OWeakObject*)new ScFunctionListObj());
849 return xInst;
852 rtl::OUString ScFunctionListObj::getImplementationName_Static()
854 return rtl::OUString::createFromAscii( "stardiv.StarCalc.ScFunctionListObj" );
857 uno::Sequence<rtl::OUString> ScFunctionListObj::getSupportedServiceNames_Static()
859 uno::Sequence<rtl::OUString> aRet(1);
860 rtl::OUString* pArray = aRet.getArray();
861 pArray[0] = rtl::OUString::createFromAscii( SCFUNCTIONLISTOBJ_SERVICE );
862 return aRet;
866 static void lcl_FillSequence( uno::Sequence<beans::PropertyValue>& rSequence, const ScFuncDesc& rDesc )
868 rDesc.initArgumentInfo(); // full argument info is needed
870 DBG_ASSERT( rSequence.getLength() == SC_FUNCDESC_PROPCOUNT, "Falscher Count" );
872 beans::PropertyValue* pArray = rSequence.getArray();
874 pArray[0].Name = rtl::OUString::createFromAscii( SC_UNONAME_ID );
875 pArray[0].Value <<= (sal_Int32) rDesc.nFIndex;
877 pArray[1].Name = rtl::OUString::createFromAscii( SC_UNONAME_CATEGORY );
878 pArray[1].Value <<= (sal_Int32) rDesc.nCategory;
880 pArray[2].Name = rtl::OUString::createFromAscii( SC_UNONAME_NAME );
881 if (rDesc.pFuncName)
882 pArray[2].Value <<= rtl::OUString( *rDesc.pFuncName );
884 pArray[3].Name = rtl::OUString::createFromAscii( SC_UNONAME_DESCRIPTION );
885 if (rDesc.pFuncDesc)
886 pArray[3].Value <<= rtl::OUString( *rDesc.pFuncDesc );
888 pArray[4].Name = rtl::OUString::createFromAscii( SC_UNONAME_ARGUMENTS );
889 if (rDesc.ppDefArgNames && rDesc.ppDefArgDescs && rDesc.pDefArgFlags )
891 USHORT nCount = rDesc.nArgCount;
892 if (nCount >= VAR_ARGS)
893 nCount -= VAR_ARGS - 1;
894 USHORT nSeqCount = rDesc.GetSuppressedArgCount();
895 if (nSeqCount >= VAR_ARGS)
896 nSeqCount -= VAR_ARGS - 1;
898 if (nSeqCount)
900 uno::Sequence<sheet::FunctionArgument> aArgSeq(nSeqCount);
901 sheet::FunctionArgument* pArgAry = aArgSeq.getArray();
902 for (USHORT i=0, j=0; i<nCount; i++)
904 if (!rDesc.pDefArgFlags[i].bSuppress)
906 String aArgName;
907 if (rDesc.ppDefArgNames[i]) aArgName = *rDesc.ppDefArgNames[i];
908 String aArgDesc;
909 if (rDesc.ppDefArgDescs[i]) aArgDesc = *rDesc.ppDefArgDescs[i];
910 sheet::FunctionArgument aArgument;
911 aArgument.Name = aArgName;
912 aArgument.Description = aArgDesc;
913 aArgument.IsOptional = rDesc.pDefArgFlags[i].bOptional;
914 pArgAry[j++] = aArgument;
917 pArray[4].Value <<= aArgSeq;
922 // XFunctionDescriptions
924 uno::Sequence<beans::PropertyValue> SAL_CALL ScFunctionListObj::getById( sal_Int32 nId )
925 throw(lang::IllegalArgumentException, uno::RuntimeException)
927 ScUnoGuard aGuard;
928 const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
929 if ( pFuncList )
931 USHORT nCount = (USHORT)pFuncList->GetCount();
932 for (USHORT nIndex=0; nIndex<nCount; nIndex++)
934 const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
935 if ( pDesc && pDesc->nFIndex == nId )
937 uno::Sequence<beans::PropertyValue> aSeq( SC_FUNCDESC_PROPCOUNT );
938 lcl_FillSequence( aSeq, *pDesc );
939 return aSeq;
943 throw lang::IllegalArgumentException(); // not found
945 else
946 throw uno::RuntimeException(); // should not happen
948 // return uno::Sequence<beans::PropertyValue>(0);
951 // XNameAccess
953 uno::Any SAL_CALL ScFunctionListObj::getByName( const rtl::OUString& aName )
954 throw(container::NoSuchElementException,
955 lang::WrappedTargetException, uno::RuntimeException)
957 ScUnoGuard aGuard;
958 String aNameStr(aName);
959 const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
960 if ( pFuncList )
962 USHORT nCount = (USHORT)pFuncList->GetCount();
963 for (USHORT nIndex=0; nIndex<nCount; nIndex++)
965 const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
966 //! Case-insensitiv ???
967 if ( pDesc && pDesc->pFuncName && aNameStr == *pDesc->pFuncName )
969 uno::Sequence<beans::PropertyValue> aSeq( SC_FUNCDESC_PROPCOUNT );
970 lcl_FillSequence( aSeq, *pDesc );
971 return uno::makeAny(aSeq);
975 throw container::NoSuchElementException(); // not found
977 else
978 throw uno::RuntimeException(); // should not happen
980 // return uno::Any();
983 // XIndexAccess
985 sal_Int32 SAL_CALL ScFunctionListObj::getCount() throw(uno::RuntimeException)
987 ScUnoGuard aGuard;
988 USHORT nCount = 0;
989 const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
990 if ( pFuncList )
991 nCount = (USHORT)pFuncList->GetCount();
992 return nCount;
995 uno::Any SAL_CALL ScFunctionListObj::getByIndex( sal_Int32 nIndex )
996 throw(lang::IndexOutOfBoundsException,
997 lang::WrappedTargetException, uno::RuntimeException)
999 ScUnoGuard aGuard;
1000 const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
1001 if ( pFuncList )
1003 if ( nIndex >= 0 && nIndex < (sal_Int32)pFuncList->GetCount() )
1005 const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
1006 if ( pDesc )
1008 uno::Sequence<beans::PropertyValue> aSeq( SC_FUNCDESC_PROPCOUNT );
1009 lcl_FillSequence( aSeq, *pDesc );
1010 return uno::makeAny(aSeq);
1014 throw lang::IndexOutOfBoundsException(); // illegal index
1016 else
1017 throw uno::RuntimeException(); // should not happen
1019 // return uno::Any();
1022 // XEnumerationAccess
1024 uno::Reference<container::XEnumeration> SAL_CALL ScFunctionListObj::createEnumeration()
1025 throw(uno::RuntimeException)
1027 ScUnoGuard aGuard;
1028 return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.FunctionDescriptionEnumeration")));
1031 // XElementAccess
1033 uno::Type SAL_CALL ScFunctionListObj::getElementType() throw(uno::RuntimeException)
1035 ScUnoGuard aGuard;
1036 return getCppuType((uno::Sequence<beans::PropertyValue>*)0);
1039 sal_Bool SAL_CALL ScFunctionListObj::hasElements() throw(uno::RuntimeException)
1041 ScUnoGuard aGuard;
1042 return ( getCount() > 0 );
1045 uno::Sequence<rtl::OUString> SAL_CALL ScFunctionListObj::getElementNames() throw(uno::RuntimeException)
1047 ScUnoGuard aGuard;
1048 const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
1049 if ( pFuncList )
1051 USHORT nCount = (USHORT)pFuncList->GetCount();
1052 uno::Sequence<rtl::OUString> aSeq(nCount);
1053 rtl::OUString* pAry = aSeq.getArray();
1054 for (USHORT nIndex=0; nIndex<nCount; nIndex++)
1056 const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
1057 if ( pDesc && pDesc->pFuncName )
1058 pAry[nIndex] = *pDesc->pFuncName;
1060 return aSeq;
1062 return uno::Sequence<rtl::OUString>(0);
1065 sal_Bool SAL_CALL ScFunctionListObj::hasByName( const rtl::OUString& aName )
1066 throw(uno::RuntimeException)
1068 ScUnoGuard aGuard;
1069 String aNameStr(aName);
1070 const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
1071 if ( pFuncList )
1073 USHORT nCount = (USHORT)pFuncList->GetCount();
1074 for (USHORT nIndex=0; nIndex<nCount; nIndex++)
1076 const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
1077 //! Case-insensitiv ???
1078 if ( pDesc && pDesc->pFuncName && aNameStr == *pDesc->pFuncName )
1079 return TRUE;
1082 return FALSE;
1085 //------------------------------------------------------------------------