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