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