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 2 : static const SfxItemPropertyMapEntry* lcl_GetSettingsPropertyMap()
138 : {
139 : static SfxItemPropertyMapEntry aSettingsPropertyMap_Impl[] =
140 : {
141 2 : {MAP_CHAR_LEN(SC_UNONAME_DOAUTOCP), 0, &getBooleanCppuType(), 0, 0},
142 2 : {MAP_CHAR_LEN(SC_UNONAME_ENTERED), 0, &getBooleanCppuType(), 0, 0},
143 2 : {MAP_CHAR_LEN(SC_UNONAME_EXPREF), 0, &getBooleanCppuType(), 0, 0},
144 2 : {MAP_CHAR_LEN(SC_UNONAME_EXTFMT), 0, &getBooleanCppuType(), 0, 0},
145 2 : {MAP_CHAR_LEN(SC_UNONAME_LINKUPD), 0, &getCppuType((sal_Int16*)0), 0, 0},
146 2 : {MAP_CHAR_LEN(SC_UNONAME_MARKHDR), 0, &getBooleanCppuType(), 0, 0},
147 2 : {MAP_CHAR_LEN(SC_UNONAME_METRIC), 0, &getCppuType((sal_Int16*)0), 0, 0},
148 2 : {MAP_CHAR_LEN(SC_UNONAME_MOVEDIR), 0, &getCppuType((sal_Int16*)0), 0, 0},
149 2 : {MAP_CHAR_LEN(SC_UNONAME_MOVESEL), 0, &getBooleanCppuType(), 0, 0},
150 2 : {MAP_CHAR_LEN(SC_UNONAME_PRALLSH), 0, &getBooleanCppuType(), 0, 0},
151 2 : {MAP_CHAR_LEN(SC_UNONAME_PREMPTY), 0, &getBooleanCppuType(), 0, 0},
152 2 : {MAP_CHAR_LEN(SC_UNONAME_RANGEFIN), 0, &getBooleanCppuType(), 0, 0},
153 2 : {MAP_CHAR_LEN(SC_UNONAME_SCALE), 0, &getCppuType((sal_Int16*)0), 0, 0},
154 2 : {MAP_CHAR_LEN(SC_UNONAME_STBFUNC), 0, &getCppuType((sal_Int16*)0), 0, 0},
155 2 : {MAP_CHAR_LEN(SC_UNONAME_ULISTS), 0, &getCppuType((uno::Sequence<rtl::OUString>*)0), 0, 0},
156 2 : {MAP_CHAR_LEN(SC_UNONAME_PRMETRICS),0, &getBooleanCppuType(), 0, 0},
157 2 : {MAP_CHAR_LEN(SC_UNONAME_USETABCOL),0, &getBooleanCppuType(), 0, 0},
158 2 : {MAP_CHAR_LEN(SC_UNONAME_REPLWARN), 0, &getBooleanCppuType(), 0, 0},
159 : {0,0,0,0,0,0}
160 38 : };
161 2 : 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 144 : SAL_DLLPUBLIC_EXPORT void * SAL_CALL sc_component_getFactory(
179 : const sal_Char * pImplName, void * pServiceManager, void * /* pRegistryKey */ )
180 : {
181 144 : if (!pServiceManager)
182 0 : return NULL;
183 :
184 144 : uno::Reference<lang::XSingleServiceFactory> xFactory;
185 144 : rtl::OUString aImpl(rtl::OUString::createFromAscii(pImplName));
186 :
187 144 : if ( aImpl == ScSpreadsheetSettings::getImplementationName_Static() )
188 : xFactory.set(cppu::createOneInstanceFactory(
189 : reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
190 : ScSpreadsheetSettings::getImplementationName_Static(),
191 : ScSpreadsheetSettings_CreateInstance,
192 2 : ScSpreadsheetSettings::getSupportedServiceNames_Static() ));
193 :
194 144 : 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 144 : 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 144 : 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 144 : 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 144 : 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 144 : 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 144 : 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 26 : ScXMLImport_Meta_getSupportedServiceNames() ));
242 :
243 144 : 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 26 : ScXMLImport_Styles_getSupportedServiceNames() ));
249 :
250 144 : 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 26 : ScXMLImport_Content_getSupportedServiceNames() ));
256 :
257 144 : 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 26 : ScXMLImport_Settings_getSupportedServiceNames() ));
263 :
264 144 : 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 144 : 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 144 : 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 144 : 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 144 : 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 144 : 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 144 : if ( aImpl == ScXMLOasisExport_Meta_getImplementationName() )
306 : xFactory = cppu::createSingleFactory(
307 : reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
308 : ScXMLOasisExport_Meta_getImplementationName(),
309 : ScXMLOasisExport_Meta_createInstance,
310 2 : ScXMLOasisExport_Meta_getSupportedServiceNames() );
311 144 : if ( aImpl == ScXMLOasisExport_Styles_getImplementationName() )
312 : xFactory = cppu::createSingleFactory(
313 : reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
314 : ScXMLOasisExport_Styles_getImplementationName(),
315 : ScXMLOasisExport_Styles_createInstance,
316 2 : ScXMLOasisExport_Styles_getSupportedServiceNames() );
317 144 : if ( aImpl == ScXMLOasisExport_Content_getImplementationName() )
318 : xFactory = cppu::createSingleFactory(
319 : reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
320 : ScXMLOasisExport_Content_getImplementationName(),
321 : ScXMLOasisExport_Content_createInstance,
322 2 : ScXMLOasisExport_Content_getSupportedServiceNames() );
323 144 : if ( aImpl == ScXMLOasisExport_Settings_getImplementationName() )
324 : xFactory = cppu::createSingleFactory(
325 : reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
326 : ScXMLOasisExport_Settings_getImplementationName(),
327 : ScXMLOasisExport_Settings_createInstance,
328 2 : ScXMLOasisExport_Settings_getSupportedServiceNames() );
329 :
330 144 : if ( aImpl == ScDocument_getImplementationName() )
331 : xFactory.set(sfx2::createSfxModelFactory(
332 : reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
333 : ScDocument_getImplementationName(),
334 : ScDocument_createInstance,
335 30 : ScDocument_getSupportedServiceNames() ));
336 :
337 144 : void* pRet = NULL;
338 144 : if (xFactory.is())
339 : {
340 144 : xFactory->acquire();
341 144 : pRet = xFactory.get();
342 : }
343 144 : return pRet;
344 : }
345 :
346 : } // extern C
347 :
348 : //------------------------------------------------------------------------
349 :
350 2 : ScSpreadsheetSettings::ScSpreadsheetSettings() :
351 2 : aPropSet( lcl_GetSettingsPropertyMap() )
352 : {
353 2 : }
354 :
355 4 : ScSpreadsheetSettings::~ScSpreadsheetSettings()
356 : {
357 4 : }
358 :
359 2 : uno::Reference<uno::XInterface> SAL_CALL ScSpreadsheetSettings_CreateInstance(
360 : const uno::Reference<lang::XMultiServiceFactory>& /* rSMgr */ )
361 : {
362 2 : SolarMutexGuard aGuard;
363 2 : ScDLL::Init();
364 2 : static uno::Reference<uno::XInterface> xInst((cppu::OWeakObject*)new ScSpreadsheetSettings());
365 2 : return xInst;
366 : }
367 :
368 146 : rtl::OUString ScSpreadsheetSettings::getImplementationName_Static()
369 : {
370 146 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "stardiv.StarCalc.ScSpreadsheetSettings" ));
371 : }
372 :
373 2 : uno::Sequence<rtl::OUString> ScSpreadsheetSettings::getSupportedServiceNames_Static()
374 : {
375 2 : uno::Sequence<rtl::OUString> aRet(1);
376 2 : rtl::OUString* pArray = aRet.getArray();
377 2 : pArray[0] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SCSPREADSHEETSETTINGS_SERVICE ));
378 2 : 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 16 : uno::Any SAL_CALL ScSpreadsheetSettings::getPropertyValue( const rtl::OUString& aPropertyName )
541 : throw(beans::UnknownPropertyException, lang::WrappedTargetException,
542 : uno::RuntimeException)
543 : {
544 16 : SolarMutexGuard aGuard;
545 16 : String aString = aPropertyName;
546 16 : uno::Any aRet;
547 :
548 16 : ScModule* pScMod = SC_MOD();
549 16 : ScAppOptions aAppOpt = pScMod->GetAppOptions();
550 16 : ScInputOptions aInpOpt = pScMod->GetInputOptions();
551 : // print options aren't loaded until needed
552 :
553 16 : if (aString.EqualsAscii( SC_UNONAME_DOAUTOCP )) ScUnoHelpFunctions::SetBoolInAny( aRet, aAppOpt.GetAutoComplete() );
554 16 : else if (aString.EqualsAscii( SC_UNONAME_ENTERED )) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetEnterEdit() );
555 16 : else if (aString.EqualsAscii( SC_UNONAME_EXPREF )) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetExpandRefs() );
556 16 : else if (aString.EqualsAscii( SC_UNONAME_EXTFMT )) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetExtendFormat() );
557 16 : else if (aString.EqualsAscii( SC_UNONAME_LINKUPD )) aRet <<= (sal_Int16) aAppOpt.GetLinkMode();
558 16 : else if (aString.EqualsAscii( SC_UNONAME_MARKHDR )) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetMarkHeader() );
559 16 : else if (aString.EqualsAscii( SC_UNONAME_MOVESEL )) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetMoveSelection() );
560 16 : else if (aString.EqualsAscii( SC_UNONAME_RANGEFIN )) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetRangeFinder() );
561 16 : else if (aString.EqualsAscii( SC_UNONAME_USETABCOL )) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetUseTabCol() );
562 16 : else if (aString.EqualsAscii( SC_UNONAME_PRMETRICS )) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetTextWysiwyg() );
563 16 : else if (aString.EqualsAscii( SC_UNONAME_REPLWARN )) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetReplaceCellsWarn() );
564 16 : 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 16 : 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 144 : rtl::OUString ScRecentFunctionsObj::getImplementationName_Static()
631 : {
632 144 : 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 144 : rtl::OUString ScFunctionListObj::getImplementationName_Static()
712 : {
713 144 : 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 >= VAR_ARGS)
752 0 : nCount -= VAR_ARGS - 1;
753 0 : sal_uInt16 nSeqCount = rDesc.GetSuppressedArgCount();
754 0 : if (nSeqCount >= VAR_ARGS)
755 0 : nSeqCount -= VAR_ARGS - 1;
756 :
757 0 : if (nSeqCount)
758 : {
759 0 : uno::Sequence<sheet::FunctionArgument> aArgSeq(nSeqCount);
760 0 : sheet::FunctionArgument* pArgAry = aArgSeq.getArray();
761 0 : for (sal_uInt16 i=0, j=0; i<nCount; i++)
762 : {
763 0 : if (!rDesc.pDefArgFlags[i].bSuppress)
764 : {
765 0 : String aArgName;
766 0 : if (rDesc.ppDefArgNames[i]) aArgName = *rDesc.ppDefArgNames[i];
767 0 : String aArgDesc;
768 0 : if (rDesc.ppDefArgDescs[i]) aArgDesc = *rDesc.ppDefArgDescs[i];
769 0 : sheet::FunctionArgument aArgument;
770 0 : aArgument.Name = aArgName;
771 0 : aArgument.Description = aArgDesc;
772 0 : aArgument.IsOptional = rDesc.pDefArgFlags[i].bOptional;
773 0 : pArgAry[j++] = aArgument;
774 : }
775 : }
776 0 : pArray[4].Value <<= aArgSeq;
777 : }
778 : }
779 0 : }
780 :
781 : // XFunctionDescriptions
782 :
783 0 : uno::Sequence<beans::PropertyValue> SAL_CALL ScFunctionListObj::getById( sal_Int32 nId )
784 : throw(lang::IllegalArgumentException, uno::RuntimeException)
785 : {
786 0 : SolarMutexGuard aGuard;
787 0 : const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
788 0 : if ( pFuncList )
789 : {
790 0 : sal_uInt16 nCount = (sal_uInt16)pFuncList->GetCount();
791 0 : for (sal_uInt16 nIndex=0; nIndex<nCount; nIndex++)
792 : {
793 0 : const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
794 0 : if ( pDesc && pDesc->nFIndex == nId )
795 : {
796 0 : uno::Sequence<beans::PropertyValue> aSeq( SC_FUNCDESC_PROPCOUNT );
797 0 : lcl_FillSequence( aSeq, *pDesc );
798 0 : return aSeq;
799 : }
800 : }
801 :
802 0 : throw lang::IllegalArgumentException(); // not found
803 : }
804 : else
805 0 : throw uno::RuntimeException(); // should not happen
806 : }
807 :
808 : // XNameAccess
809 :
810 0 : uno::Any SAL_CALL ScFunctionListObj::getByName( const rtl::OUString& aName )
811 : throw(container::NoSuchElementException,
812 : lang::WrappedTargetException, uno::RuntimeException)
813 : {
814 0 : SolarMutexGuard aGuard;
815 0 : ::rtl::OUString aNameStr(aName);
816 0 : const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
817 0 : if ( pFuncList )
818 : {
819 0 : sal_uInt16 nCount = (sal_uInt16)pFuncList->GetCount();
820 0 : for (sal_uInt16 nIndex=0; nIndex<nCount; nIndex++)
821 : {
822 0 : const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
823 : //! Case-insensitiv ???
824 0 : if ( pDesc && pDesc->pFuncName && aNameStr == *pDesc->pFuncName )
825 : {
826 0 : uno::Sequence<beans::PropertyValue> aSeq( SC_FUNCDESC_PROPCOUNT );
827 0 : lcl_FillSequence( aSeq, *pDesc );
828 0 : return uno::makeAny(aSeq);
829 : }
830 : }
831 :
832 0 : throw container::NoSuchElementException(); // not found
833 : }
834 : else
835 0 : throw uno::RuntimeException(); // should not happen
836 : }
837 :
838 : // XIndexAccess
839 :
840 0 : sal_Int32 SAL_CALL ScFunctionListObj::getCount() throw(uno::RuntimeException)
841 : {
842 0 : SolarMutexGuard aGuard;
843 0 : sal_Int32 nCount = 0;
844 0 : const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
845 0 : if ( pFuncList )
846 0 : nCount = static_cast<sal_Int32>(pFuncList->GetCount());
847 0 : return nCount;
848 : }
849 :
850 0 : uno::Any SAL_CALL ScFunctionListObj::getByIndex( sal_Int32 nIndex )
851 : throw(lang::IndexOutOfBoundsException,
852 : lang::WrappedTargetException, uno::RuntimeException)
853 : {
854 0 : SolarMutexGuard aGuard;
855 0 : const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
856 0 : if ( pFuncList )
857 : {
858 0 : if ( nIndex >= 0 && nIndex < (sal_Int32)pFuncList->GetCount() )
859 : {
860 0 : const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
861 0 : if ( pDesc )
862 : {
863 0 : uno::Sequence<beans::PropertyValue> aSeq( SC_FUNCDESC_PROPCOUNT );
864 0 : lcl_FillSequence( aSeq, *pDesc );
865 0 : return uno::makeAny(aSeq);
866 : }
867 : }
868 :
869 0 : throw lang::IndexOutOfBoundsException(); // illegal index
870 : }
871 : else
872 0 : throw uno::RuntimeException(); // should not happen
873 : }
874 :
875 : // XEnumerationAccess
876 :
877 0 : uno::Reference<container::XEnumeration> SAL_CALL ScFunctionListObj::createEnumeration()
878 : throw(uno::RuntimeException)
879 : {
880 0 : SolarMutexGuard aGuard;
881 0 : return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.FunctionDescriptionEnumeration")));
882 : }
883 :
884 : // XElementAccess
885 :
886 0 : uno::Type SAL_CALL ScFunctionListObj::getElementType() throw(uno::RuntimeException)
887 : {
888 0 : SolarMutexGuard aGuard;
889 0 : return getCppuType((uno::Sequence<beans::PropertyValue>*)0);
890 : }
891 :
892 0 : sal_Bool SAL_CALL ScFunctionListObj::hasElements() throw(uno::RuntimeException)
893 : {
894 0 : SolarMutexGuard aGuard;
895 0 : return ( getCount() > 0 );
896 : }
897 :
898 0 : uno::Sequence<rtl::OUString> SAL_CALL ScFunctionListObj::getElementNames() throw(uno::RuntimeException)
899 : {
900 0 : SolarMutexGuard aGuard;
901 0 : const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
902 0 : if ( pFuncList )
903 : {
904 0 : sal_uInt32 nCount = pFuncList->GetCount();
905 0 : uno::Sequence<rtl::OUString> aSeq(nCount);
906 0 : rtl::OUString* pAry = aSeq.getArray();
907 0 : for (sal_uInt32 nIndex=0; nIndex<nCount; ++nIndex)
908 : {
909 0 : const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
910 0 : if ( pDesc && pDesc->pFuncName )
911 0 : pAry[nIndex] = *pDesc->pFuncName;
912 : }
913 0 : return aSeq;
914 : }
915 0 : return uno::Sequence<rtl::OUString>(0);
916 : }
917 :
918 0 : sal_Bool SAL_CALL ScFunctionListObj::hasByName( const rtl::OUString& aName )
919 : throw(uno::RuntimeException)
920 : {
921 0 : SolarMutexGuard aGuard;
922 0 : const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
923 0 : if ( pFuncList )
924 : {
925 0 : sal_uInt32 nCount = pFuncList->GetCount();
926 0 : for (sal_uInt32 nIndex=0; nIndex<nCount; ++nIndex)
927 : {
928 0 : const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
929 : //! Case-insensitiv ???
930 0 : if ( pDesc && pDesc->pFuncName && aName == *pDesc->pFuncName )
931 0 : return sal_True;
932 : }
933 : }
934 0 : return false;
935 : }
936 :
937 : //------------------------------------------------------------------------
938 :
939 :
940 :
941 :
942 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|