1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "appluno.hxx"
22 #include "sal/types.h"
23 #include <osl/diagnose.h>
24 #include <cppuhelper/factory.hxx>
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"
33 #include "appoptio.hxx"
34 #include "inputopt.hxx"
35 #include "printopt.hxx"
36 #include "userlist.hxx"
38 #include "unonames.hxx"
39 #include "funcdesc.hxx"
40 #include <com/sun/star/sheet/FunctionArgument.hpp>
41 #include "ScPanelFactory.hxx"
43 using namespace com::sun::star
;
45 //------------------------------------------------------------------------
48 extern uno::Sequence
< OUString
> SAL_CALL
ScDocument_getSupportedServiceNames() throw();
49 extern OUString SAL_CALL
ScDocument_getImplementationName() throw();
50 extern uno::Reference
< uno::XInterface
> SAL_CALL
ScDocument_createInstance(
51 const uno::Reference
< lang::XMultiServiceFactory
> & rSMgr
, const sal_uInt64 _nCreationFlags
) throw( uno::Exception
);
54 extern uno::Sequence
< OUString
> SAL_CALL
ScXMLImport_getSupportedServiceNames() throw();
55 extern OUString SAL_CALL
ScXMLImport_getImplementationName() throw();
56 extern uno::Reference
< uno::XInterface
> SAL_CALL
ScXMLImport_createInstance(
57 const uno::Reference
< lang::XMultiServiceFactory
> & rSMgr
) throw( uno::Exception
);
58 extern uno::Sequence
< OUString
> SAL_CALL
ScXMLImport_Meta_getSupportedServiceNames() throw();
59 extern OUString SAL_CALL
ScXMLImport_Meta_getImplementationName() throw();
60 extern uno::Reference
< uno::XInterface
> SAL_CALL
ScXMLImport_Meta_createInstance(
61 const uno::Reference
< lang::XMultiServiceFactory
> & rSMgr
) throw( uno::Exception
);
62 extern uno::Sequence
< OUString
> SAL_CALL
ScXMLImport_Styles_getSupportedServiceNames() throw();
63 extern OUString SAL_CALL
ScXMLImport_Styles_getImplementationName() throw();
64 extern uno::Reference
< uno::XInterface
> SAL_CALL
ScXMLImport_Styles_createInstance(
65 const uno::Reference
< lang::XMultiServiceFactory
> & rSMgr
) throw( uno::Exception
);
66 extern uno::Sequence
< OUString
> SAL_CALL
ScXMLImport_Content_getSupportedServiceNames() throw();
67 extern OUString SAL_CALL
ScXMLImport_Content_getImplementationName() throw();
68 extern uno::Reference
< uno::XInterface
> SAL_CALL
ScXMLImport_Content_createInstance(
69 const uno::Reference
< lang::XMultiServiceFactory
> & rSMgr
) throw( uno::Exception
);
70 extern uno::Sequence
< OUString
> SAL_CALL
ScXMLImport_Settings_getSupportedServiceNames() throw();
71 extern OUString SAL_CALL
ScXMLImport_Settings_getImplementationName() throw();
72 extern uno::Reference
< uno::XInterface
> SAL_CALL
ScXMLImport_Settings_createInstance(
73 const uno::Reference
< lang::XMultiServiceFactory
> & rSMgr
) throw( uno::Exception
);
76 extern uno::Sequence
< OUString
> SAL_CALL
ScXMLOOoExport_getSupportedServiceNames() throw();
77 extern OUString SAL_CALL
ScXMLOOoExport_getImplementationName() throw();
78 extern uno::Reference
< uno::XInterface
> SAL_CALL
ScXMLOOoExport_createInstance(
79 const uno::Reference
< lang::XMultiServiceFactory
> & rSMgr
) throw( uno::Exception
);
80 extern uno::Sequence
< OUString
> SAL_CALL
ScXMLOOoExport_Meta_getSupportedServiceNames() throw();
81 extern OUString SAL_CALL
ScXMLOOoExport_Meta_getImplementationName() throw();
82 extern uno::Reference
< uno::XInterface
> SAL_CALL
ScXMLOOoExport_Meta_createInstance(
83 const uno::Reference
< lang::XMultiServiceFactory
> & rSMgr
) throw( uno::Exception
);
84 extern uno::Sequence
< OUString
> SAL_CALL
ScXMLOOoExport_Styles_getSupportedServiceNames() throw();
85 extern OUString SAL_CALL
ScXMLOOoExport_Styles_getImplementationName() throw();
86 extern uno::Reference
< uno::XInterface
> SAL_CALL
ScXMLOOoExport_Styles_createInstance(
87 const uno::Reference
< lang::XMultiServiceFactory
> & rSMgr
) throw( uno::Exception
);
88 extern uno::Sequence
< OUString
> SAL_CALL
ScXMLOOoExport_Content_getSupportedServiceNames() throw();
89 extern OUString SAL_CALL
ScXMLOOoExport_Content_getImplementationName() throw();
90 extern uno::Reference
< uno::XInterface
> SAL_CALL
ScXMLOOoExport_Content_createInstance(
91 const uno::Reference
< lang::XMultiServiceFactory
> & rSMgr
) throw( uno::Exception
);
92 extern uno::Sequence
< OUString
> SAL_CALL
ScXMLOOoExport_Settings_getSupportedServiceNames() throw();
93 extern OUString SAL_CALL
ScXMLOOoExport_Settings_getImplementationName() throw();
94 extern uno::Reference
< uno::XInterface
> SAL_CALL
ScXMLOOoExport_Settings_createInstance(
95 const uno::Reference
< lang::XMultiServiceFactory
> & rSMgr
) throw( uno::Exception
);
97 // Calc XML Oasis export
98 extern uno::Sequence
< OUString
> SAL_CALL
ScXMLOasisExport_getSupportedServiceNames() throw();
99 extern OUString SAL_CALL
ScXMLOasisExport_getImplementationName() throw();
100 extern uno::Reference
< uno::XInterface
> SAL_CALL
ScXMLOasisExport_createInstance(
101 const uno::Reference
< lang::XMultiServiceFactory
> & rSMgr
) throw( uno::Exception
);
102 extern uno::Sequence
< OUString
> SAL_CALL
ScXMLOasisExport_Meta_getSupportedServiceNames() throw();
103 extern OUString SAL_CALL
ScXMLOasisExport_Meta_getImplementationName() throw();
104 extern uno::Reference
< uno::XInterface
> SAL_CALL
ScXMLOasisExport_Meta_createInstance(
105 const uno::Reference
< lang::XMultiServiceFactory
> & rSMgr
) throw( uno::Exception
);
106 extern uno::Sequence
< OUString
> SAL_CALL
ScXMLOasisExport_Styles_getSupportedServiceNames() throw();
107 extern OUString SAL_CALL
ScXMLOasisExport_Styles_getImplementationName() throw();
108 extern uno::Reference
< uno::XInterface
> SAL_CALL
ScXMLOasisExport_Styles_createInstance(
109 const uno::Reference
< lang::XMultiServiceFactory
> & rSMgr
) throw( uno::Exception
);
110 extern uno::Sequence
< OUString
> SAL_CALL
ScXMLOasisExport_Content_getSupportedServiceNames() throw();
111 extern OUString SAL_CALL
ScXMLOasisExport_Content_getImplementationName() throw();
112 extern uno::Reference
< uno::XInterface
> SAL_CALL
ScXMLOasisExport_Content_createInstance(
113 const uno::Reference
< lang::XMultiServiceFactory
> & rSMgr
) throw( uno::Exception
);
114 extern uno::Sequence
< OUString
> SAL_CALL
ScXMLOasisExport_Settings_getSupportedServiceNames() throw();
115 extern OUString SAL_CALL
ScXMLOasisExport_Settings_getImplementationName() throw();
116 extern uno::Reference
< uno::XInterface
> SAL_CALL
ScXMLOasisExport_Settings_createInstance(
117 const uno::Reference
< lang::XMultiServiceFactory
> & rSMgr
) throw( uno::Exception
);
119 //------------------------------------------------------------------------
121 // Anzahl der Funktionen, die als zuletzt benutzt gespeichert werden
122 //! Define mit funcpage.hxx und dwfunctr.hxx zusammenfassen !!!
125 // Spezial-Werte fuer Zoom
127 #define SC_ZOOMVAL_OPTIMAL (-1)
128 #define SC_ZOOMVAL_WHOLEPAGE (-2)
129 #define SC_ZOOMVAL_PAGEWIDTH (-3)
131 // Anzahl der PropertyValues in einer Function-Description
132 #define SC_FUNCDESC_PROPCOUNT 5
134 //------------------------------------------------------------------------
136 // alles ohne Which-ID, Map nur fuer PropertySetInfo
138 static const SfxItemPropertyMapEntry
* lcl_GetSettingsPropertyMap()
140 static const SfxItemPropertyMapEntry aSettingsPropertyMap_Impl
[] =
142 {MAP_CHAR_LEN(SC_UNONAME_DOAUTOCP
), 0, &getBooleanCppuType(), 0, 0},
143 {MAP_CHAR_LEN(SC_UNONAME_ENTERED
), 0, &getBooleanCppuType(), 0, 0},
144 {MAP_CHAR_LEN(SC_UNONAME_EXPREF
), 0, &getBooleanCppuType(), 0, 0},
145 {MAP_CHAR_LEN(SC_UNONAME_EXTFMT
), 0, &getBooleanCppuType(), 0, 0},
146 {MAP_CHAR_LEN(SC_UNONAME_LINKUPD
), 0, &getCppuType((sal_Int16
*)0), 0, 0},
147 {MAP_CHAR_LEN(SC_UNONAME_MARKHDR
), 0, &getBooleanCppuType(), 0, 0},
148 {MAP_CHAR_LEN(SC_UNONAME_METRIC
), 0, &getCppuType((sal_Int16
*)0), 0, 0},
149 {MAP_CHAR_LEN(SC_UNONAME_MOVEDIR
), 0, &getCppuType((sal_Int16
*)0), 0, 0},
150 {MAP_CHAR_LEN(SC_UNONAME_MOVESEL
), 0, &getBooleanCppuType(), 0, 0},
151 {MAP_CHAR_LEN(SC_UNONAME_PRALLSH
), 0, &getBooleanCppuType(), 0, 0},
152 {MAP_CHAR_LEN(SC_UNONAME_PREMPTY
), 0, &getBooleanCppuType(), 0, 0},
153 {MAP_CHAR_LEN(SC_UNONAME_RANGEFIN
), 0, &getBooleanCppuType(), 0, 0},
154 {MAP_CHAR_LEN(SC_UNONAME_SCALE
), 0, &getCppuType((sal_Int16
*)0), 0, 0},
155 {MAP_CHAR_LEN(SC_UNONAME_STBFUNC
), 0, &getCppuType((sal_Int16
*)0), 0, 0},
156 {MAP_CHAR_LEN(SC_UNONAME_ULISTS
), 0, &getCppuType((uno::Sequence
<OUString
>*)0), 0, 0},
157 {MAP_CHAR_LEN(SC_UNONAME_PRMETRICS
),0, &getBooleanCppuType(), 0, 0},
158 {MAP_CHAR_LEN(SC_UNONAME_USETABCOL
),0, &getBooleanCppuType(), 0, 0},
159 {MAP_CHAR_LEN(SC_UNONAME_REPLWARN
), 0, &getBooleanCppuType(), 0, 0},
162 return aSettingsPropertyMap_Impl
;
165 //------------------------------------------------------------------------
167 #define SCFUNCTIONLISTOBJ_SERVICE "com.sun.star.sheet.FunctionDescriptions"
168 #define SCRECENTFUNCTIONSOBJ_SERVICE "com.sun.star.sheet.RecentFunctions"
169 #define SCSPREADSHEETSETTINGS_SERVICE "com.sun.star.sheet.GlobalSheetSettings"
171 SC_SIMPLE_SERVICE_INFO( ScFunctionListObj
, "ScFunctionListObj", SCFUNCTIONLISTOBJ_SERVICE
)
172 SC_SIMPLE_SERVICE_INFO( ScRecentFunctionsObj
, "ScRecentFunctionsObj", SCRECENTFUNCTIONSOBJ_SERVICE
)
173 SC_SIMPLE_SERVICE_INFO( ScSpreadsheetSettings
, "ScSpreadsheetSettings", SCSPREADSHEETSETTINGS_SERVICE
)
175 //------------------------------------------------------------------------
179 SAL_DLLPUBLIC_EXPORT
void * SAL_CALL
sc_component_getFactory(
180 const sal_Char
* pImplName
, void * pServiceManager
, void * /* pRegistryKey */ )
182 if (!pServiceManager
)
185 uno::Reference
<lang::XSingleServiceFactory
> xFactory
;
186 OUString
aImpl(OUString::createFromAscii(pImplName
));
188 if ( aImpl
== ScSpreadsheetSettings::getImplementationName_Static() )
190 xFactory
.set(cppu::createOneInstanceFactory(
191 reinterpret_cast<lang::XMultiServiceFactory
*>(pServiceManager
),
192 ScSpreadsheetSettings::getImplementationName_Static(),
193 ScSpreadsheetSettings_CreateInstance
,
194 ScSpreadsheetSettings::getSupportedServiceNames_Static() ));
196 else if ( aImpl
== ScRecentFunctionsObj::getImplementationName_Static() )
198 xFactory
.set(cppu::createOneInstanceFactory(
199 reinterpret_cast<lang::XMultiServiceFactory
*>(pServiceManager
),
200 ScRecentFunctionsObj::getImplementationName_Static(),
201 ScRecentFunctionsObj_CreateInstance
,
202 ScRecentFunctionsObj::getSupportedServiceNames_Static() ));
204 else if ( aImpl
== ScFunctionListObj::getImplementationName_Static() )
206 xFactory
.set(cppu::createOneInstanceFactory(
207 reinterpret_cast<lang::XMultiServiceFactory
*>(pServiceManager
),
208 ScFunctionListObj::getImplementationName_Static(),
209 ScFunctionListObj_CreateInstance
,
210 ScFunctionListObj::getSupportedServiceNames_Static() ));
212 else if ( aImpl
== ScAutoFormatsObj::getImplementationName_Static() )
214 xFactory
.set(cppu::createOneInstanceFactory(
215 reinterpret_cast<lang::XMultiServiceFactory
*>(pServiceManager
),
216 ScAutoFormatsObj::getImplementationName_Static(),
217 ScAutoFormatsObj_CreateInstance
,
218 ScAutoFormatsObj::getSupportedServiceNames_Static() ));
220 else if ( aImpl
== ScFunctionAccess::getImplementationName_Static() )
222 xFactory
.set(cppu::createOneInstanceFactory(
223 reinterpret_cast<lang::XMultiServiceFactory
*>(pServiceManager
),
224 ScFunctionAccess::getImplementationName_Static(),
225 ScFunctionAccess_CreateInstance
,
226 ScFunctionAccess::getSupportedServiceNames_Static() ));
228 else if ( aImpl
== ScFilterOptionsObj::getImplementationName_Static() )
230 xFactory
.set(cppu::createSingleFactory(
231 reinterpret_cast<lang::XMultiServiceFactory
*>(pServiceManager
),
232 ScFilterOptionsObj::getImplementationName_Static(),
233 ScFilterOptionsObj_CreateInstance
,
234 ScFilterOptionsObj::getSupportedServiceNames_Static() ));
236 else if ( aImpl
== ScXMLImport_getImplementationName() )
238 xFactory
.set(cppu::createSingleFactory(
239 reinterpret_cast<lang::XMultiServiceFactory
*>(pServiceManager
),
240 ScXMLImport_getImplementationName(),
241 ScXMLImport_createInstance
,
242 ScXMLImport_getSupportedServiceNames() ));
244 else if ( aImpl
== ScXMLImport_Meta_getImplementationName() )
246 xFactory
.set(cppu::createSingleFactory(
247 reinterpret_cast<lang::XMultiServiceFactory
*>(pServiceManager
),
248 ScXMLImport_Meta_getImplementationName(),
249 ScXMLImport_Meta_createInstance
,
250 ScXMLImport_Meta_getSupportedServiceNames() ));
252 else if ( aImpl
== ScXMLImport_Styles_getImplementationName() )
254 xFactory
.set(cppu::createSingleFactory(
255 reinterpret_cast<lang::XMultiServiceFactory
*>(pServiceManager
),
256 ScXMLImport_Styles_getImplementationName(),
257 ScXMLImport_Styles_createInstance
,
258 ScXMLImport_Styles_getSupportedServiceNames() ));
260 else if ( aImpl
== ScXMLImport_Content_getImplementationName() )
262 xFactory
.set(cppu::createSingleFactory(
263 reinterpret_cast<lang::XMultiServiceFactory
*>(pServiceManager
),
264 ScXMLImport_Content_getImplementationName(),
265 ScXMLImport_Content_createInstance
,
266 ScXMLImport_Content_getSupportedServiceNames() ));
268 else if ( aImpl
== ScXMLImport_Settings_getImplementationName() )
270 xFactory
.set(cppu::createSingleFactory(
271 reinterpret_cast<lang::XMultiServiceFactory
*>(pServiceManager
),
272 ScXMLImport_Settings_getImplementationName(),
273 ScXMLImport_Settings_createInstance
,
274 ScXMLImport_Settings_getSupportedServiceNames() ));
276 else if ( aImpl
== ScXMLOOoExport_getImplementationName() )
278 xFactory
= cppu::createSingleFactory(
279 reinterpret_cast<lang::XMultiServiceFactory
*>(pServiceManager
),
280 ScXMLOOoExport_getImplementationName(),
281 ScXMLOOoExport_createInstance
,
282 ScXMLOOoExport_getSupportedServiceNames() );
284 else if ( aImpl
== ScXMLOOoExport_Meta_getImplementationName() )
286 xFactory
= cppu::createSingleFactory(
287 reinterpret_cast<lang::XMultiServiceFactory
*>(pServiceManager
),
288 ScXMLOOoExport_Meta_getImplementationName(),
289 ScXMLOOoExport_Meta_createInstance
,
290 ScXMLOOoExport_Meta_getSupportedServiceNames() );
292 else if ( aImpl
== ScXMLOOoExport_Styles_getImplementationName() )
294 xFactory
= cppu::createSingleFactory(
295 reinterpret_cast<lang::XMultiServiceFactory
*>(pServiceManager
),
296 ScXMLOOoExport_Styles_getImplementationName(),
297 ScXMLOOoExport_Styles_createInstance
,
298 ScXMLOOoExport_Styles_getSupportedServiceNames() );
300 else if ( aImpl
== ScXMLOOoExport_Content_getImplementationName() )
302 xFactory
= cppu::createSingleFactory(
303 reinterpret_cast<lang::XMultiServiceFactory
*>(pServiceManager
),
304 ScXMLOOoExport_Content_getImplementationName(),
305 ScXMLOOoExport_Content_createInstance
,
306 ScXMLOOoExport_Content_getSupportedServiceNames() );
308 else if ( aImpl
== ScXMLOOoExport_Settings_getImplementationName() )
310 xFactory
= cppu::createSingleFactory(
311 reinterpret_cast<lang::XMultiServiceFactory
*>(pServiceManager
),
312 ScXMLOOoExport_Settings_getImplementationName(),
313 ScXMLOOoExport_Settings_createInstance
,
314 ScXMLOOoExport_Settings_getSupportedServiceNames() );
316 else if ( aImpl
== ScXMLOasisExport_getImplementationName() )
318 xFactory
= cppu::createSingleFactory(
319 reinterpret_cast<lang::XMultiServiceFactory
*>(pServiceManager
),
320 ScXMLOasisExport_getImplementationName(),
321 ScXMLOasisExport_createInstance
,
322 ScXMLOasisExport_getSupportedServiceNames() );
324 else if ( aImpl
== ScXMLOasisExport_Meta_getImplementationName() )
326 xFactory
= cppu::createSingleFactory(
327 reinterpret_cast<lang::XMultiServiceFactory
*>(pServiceManager
),
328 ScXMLOasisExport_Meta_getImplementationName(),
329 ScXMLOasisExport_Meta_createInstance
,
330 ScXMLOasisExport_Meta_getSupportedServiceNames() );
332 else if ( aImpl
== ScXMLOasisExport_Styles_getImplementationName() )
334 xFactory
= cppu::createSingleFactory(
335 reinterpret_cast<lang::XMultiServiceFactory
*>(pServiceManager
),
336 ScXMLOasisExport_Styles_getImplementationName(),
337 ScXMLOasisExport_Styles_createInstance
,
338 ScXMLOasisExport_Styles_getSupportedServiceNames() );
340 else if ( aImpl
== ScXMLOasisExport_Content_getImplementationName() )
342 xFactory
= cppu::createSingleFactory(
343 reinterpret_cast<lang::XMultiServiceFactory
*>(pServiceManager
),
344 ScXMLOasisExport_Content_getImplementationName(),
345 ScXMLOasisExport_Content_createInstance
,
346 ScXMLOasisExport_Content_getSupportedServiceNames() );
348 else if ( aImpl
== ScXMLOasisExport_Settings_getImplementationName() )
350 xFactory
= cppu::createSingleFactory(
351 reinterpret_cast<lang::XMultiServiceFactory
*>(pServiceManager
),
352 ScXMLOasisExport_Settings_getImplementationName(),
353 ScXMLOasisExport_Settings_createInstance
,
354 ScXMLOasisExport_Settings_getSupportedServiceNames() );
356 else if ( aImpl
== ScDocument_getImplementationName() )
358 xFactory
.set(sfx2::createSfxModelFactory(
359 reinterpret_cast<lang::XMultiServiceFactory
*>(pServiceManager
),
360 ScDocument_getImplementationName(),
361 ScDocument_createInstance
,
362 ScDocument_getSupportedServiceNames() ));
364 else if ( aImpl
== ::sc::sidebar::ScPanelFactory::getImplementationName() )
366 xFactory
= ::cppu::createSingleFactory(
367 reinterpret_cast<lang::XMultiServiceFactory
*>(pServiceManager
),
368 ::sc::sidebar::ScPanelFactory::getImplementationName(),
369 ::sc::sidebar::ScPanelFactory::createInstance
,
370 ::sc::sidebar::ScPanelFactory::getSupportedServiceNames() );
377 pRet
= xFactory
.get();
384 //------------------------------------------------------------------------
386 ScSpreadsheetSettings::ScSpreadsheetSettings() :
387 aPropSet( lcl_GetSettingsPropertyMap() )
391 ScSpreadsheetSettings::~ScSpreadsheetSettings()
395 uno::Reference
<uno::XInterface
> SAL_CALL
ScSpreadsheetSettings_CreateInstance(
396 const uno::Reference
<lang::XMultiServiceFactory
>& /* rSMgr */ )
398 SolarMutexGuard aGuard
;
400 static uno::Reference
<uno::XInterface
> xInst((cppu::OWeakObject
*)new ScSpreadsheetSettings());
404 OUString
ScSpreadsheetSettings::getImplementationName_Static()
406 return OUString( "stardiv.StarCalc.ScSpreadsheetSettings" );
409 uno::Sequence
<OUString
> ScSpreadsheetSettings::getSupportedServiceNames_Static()
411 uno::Sequence
<OUString
> aRet(1);
412 OUString
* pArray
= aRet
.getArray();
413 pArray
[0] = OUString( SCSPREADSHEETSETTINGS_SERVICE
);
417 sal_Bool
ScSpreadsheetSettings::getPropertyBool(const OUString
& aPropertyName
) throw (css::uno::RuntimeException
)
419 uno::Any any
= getPropertyValue(aPropertyName
);
420 sal_Bool b
= sal_False
;
425 sal_Int16
ScSpreadsheetSettings::getPropertyInt16(const OUString
& aPropertyName
) throw (css::uno::RuntimeException
)
427 uno::Any any
= getPropertyValue(aPropertyName
);
435 uno::Reference
<beans::XPropertySetInfo
> SAL_CALL
ScSpreadsheetSettings::getPropertySetInfo()
436 throw(uno::RuntimeException
)
438 SolarMutexGuard aGuard
;
439 static uno::Reference
<beans::XPropertySetInfo
> aRef(
440 new SfxItemPropertySetInfo( aPropSet
.getPropertyMap() ));
444 void SAL_CALL
ScSpreadsheetSettings::setPropertyValue(
445 const OUString
& aPropertyName
, const uno::Any
& aValue
)
446 throw(beans::UnknownPropertyException
, beans::PropertyVetoException
,
447 lang::IllegalArgumentException
, lang::WrappedTargetException
,
448 uno::RuntimeException
)
450 SolarMutexGuard aGuard
;
451 OUString
aString(aPropertyName
);
453 ScModule
* pScMod
= SC_MOD();
454 ScAppOptions
aAppOpt(pScMod
->GetAppOptions());
455 ScInputOptions
aInpOpt(pScMod
->GetInputOptions());
456 sal_Bool bSaveApp
= false;
457 sal_Bool bSaveInp
= false;
458 // print options aren't loaded until needed
460 if (aString
.equalsAscii( SC_UNONAME_DOAUTOCP
))
462 aAppOpt
.SetAutoComplete( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
465 else if (aString
.equalsAscii( SC_UNONAME_ENTERED
))
467 aInpOpt
.SetEnterEdit( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
470 else if (aString
.equalsAscii( SC_UNONAME_EXPREF
))
472 aInpOpt
.SetExpandRefs( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
475 else if (aString
.equalsAscii( SC_UNONAME_EXTFMT
))
477 aInpOpt
.SetExtendFormat( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
480 else if (aString
.equalsAscii( SC_UNONAME_LINKUPD
))
482 aAppOpt
.SetLinkMode( (ScLkUpdMode
) ScUnoHelpFunctions::GetInt16FromAny( aValue
) );
485 else if (aString
.equalsAscii( SC_UNONAME_MARKHDR
))
487 aInpOpt
.SetMarkHeader( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
490 else if (aString
.equalsAscii( SC_UNONAME_MOVESEL
))
492 aInpOpt
.SetMoveSelection( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
495 else if (aString
.equalsAscii( SC_UNONAME_RANGEFIN
))
497 aInpOpt
.SetRangeFinder( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
500 else if (aString
.equalsAscii( SC_UNONAME_USETABCOL
))
502 aInpOpt
.SetUseTabCol( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
505 else if (aString
.equalsAscii( SC_UNONAME_PRMETRICS
))
507 aInpOpt
.SetTextWysiwyg( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
510 else if (aString
.equalsAscii( SC_UNONAME_REPLWARN
))
512 aInpOpt
.SetReplaceCellsWarn( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
515 else if (aString
.equalsAscii( SC_UNONAME_METRIC
))
517 aAppOpt
.SetAppMetric( (FieldUnit
) ScUnoHelpFunctions::GetInt16FromAny( aValue
) );
520 else if (aString
.equalsAscii( SC_UNONAME_MOVEDIR
))
522 aInpOpt
.SetMoveDir( ScUnoHelpFunctions::GetInt16FromAny( aValue
) );
525 else if (aString
.equalsAscii( SC_UNONAME_SCALE
))
527 short nVal
= ScUnoHelpFunctions::GetInt16FromAny( aValue
);
530 SvxZoomType eType
= SVX_ZOOM_PERCENT
;
533 case SC_ZOOMVAL_OPTIMAL
: eType
= SVX_ZOOM_OPTIMAL
; break;
534 case SC_ZOOMVAL_WHOLEPAGE
: eType
= SVX_ZOOM_WHOLEPAGE
; break;
535 case SC_ZOOMVAL_PAGEWIDTH
: eType
= SVX_ZOOM_PAGEWIDTH
; break;
537 aAppOpt
.SetZoomType( eType
);
539 else if ( nVal
>= MINZOOM
&& nVal
<= MAXZOOM
)
541 aAppOpt
.SetZoom( nVal
);
542 aAppOpt
.SetZoomType( SVX_ZOOM_PERCENT
);
546 else if (aString
.equalsAscii( SC_UNONAME_STBFUNC
))
548 aAppOpt
.SetStatusFunc( ScUnoHelpFunctions::GetInt16FromAny( aValue
) );
551 else if (aString
.equalsAscii( SC_UNONAME_ULISTS
))
553 ScUserList
* pUserList
= ScGlobal::GetUserList();
554 uno::Sequence
<OUString
> aSeq
;
555 if ( pUserList
&& ( aValue
>>= aSeq
) )
557 // es wird direkt die "lebende" Liste veraendert,
558 // mehr tut ScGlobal::SetUserList auch nicht
560 pUserList
->clear(); // alle Eintraege raus
561 sal_uInt16 nCount
= (sal_uInt16
)aSeq
.getLength();
562 const OUString
* pAry
= aSeq
.getConstArray();
563 for (sal_uInt16 i
=0; i
<nCount
; i
++)
565 OUString aEntry
= pAry
[i
];
566 ScUserListData
* pData
= new ScUserListData(aEntry
);
567 pUserList
->push_back(pData
);
569 bSaveApp
= sal_True
; // Liste wird mit den App-Optionen gespeichert
572 else if (aString
.equalsAscii( SC_UNONAME_PRALLSH
))
574 ScPrintOptions
aPrintOpt(pScMod
->GetPrintOptions());
575 aPrintOpt
.SetAllSheets( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
576 pScMod
->SetPrintOptions( aPrintOpt
);
578 else if (aString
.equalsAscii( SC_UNONAME_PREMPTY
))
580 ScPrintOptions
aPrintOpt(pScMod
->GetPrintOptions());
581 aPrintOpt
.SetSkipEmpty( !ScUnoHelpFunctions::GetBoolFromAny( aValue
) ); // reversed
582 pScMod
->SetPrintOptions( aPrintOpt
);
583 SFX_APP()->Broadcast( SfxSimpleHint( SID_SCPRINTOPTIONS
) ); // update previews
587 pScMod
->SetAppOptions( aAppOpt
);
589 pScMod
->SetInputOptions( aInpOpt
);
592 uno::Any SAL_CALL
ScSpreadsheetSettings::getPropertyValue( const OUString
& aPropertyName
)
593 throw(beans::UnknownPropertyException
, lang::WrappedTargetException
,
594 uno::RuntimeException
)
596 SolarMutexGuard aGuard
;
597 OUString aString
= aPropertyName
;
600 ScModule
* pScMod
= SC_MOD();
601 ScAppOptions aAppOpt
= pScMod
->GetAppOptions();
602 ScInputOptions aInpOpt
= pScMod
->GetInputOptions();
603 // print options aren't loaded until needed
605 if (aString
.equalsAscii( SC_UNONAME_DOAUTOCP
)) ScUnoHelpFunctions::SetBoolInAny( aRet
, aAppOpt
.GetAutoComplete() );
606 else if (aString
.equalsAscii( SC_UNONAME_ENTERED
)) ScUnoHelpFunctions::SetBoolInAny( aRet
, aInpOpt
.GetEnterEdit() );
607 else if (aString
.equalsAscii( SC_UNONAME_EXPREF
)) ScUnoHelpFunctions::SetBoolInAny( aRet
, aInpOpt
.GetExpandRefs() );
608 else if (aString
.equalsAscii( SC_UNONAME_EXTFMT
)) ScUnoHelpFunctions::SetBoolInAny( aRet
, aInpOpt
.GetExtendFormat() );
609 else if (aString
.equalsAscii( SC_UNONAME_LINKUPD
)) aRet
<<= (sal_Int16
) aAppOpt
.GetLinkMode();
610 else if (aString
.equalsAscii( SC_UNONAME_MARKHDR
)) ScUnoHelpFunctions::SetBoolInAny( aRet
, aInpOpt
.GetMarkHeader() );
611 else if (aString
.equalsAscii( SC_UNONAME_MOVESEL
)) ScUnoHelpFunctions::SetBoolInAny( aRet
, aInpOpt
.GetMoveSelection() );
612 else if (aString
.equalsAscii( SC_UNONAME_RANGEFIN
)) ScUnoHelpFunctions::SetBoolInAny( aRet
, aInpOpt
.GetRangeFinder() );
613 else if (aString
.equalsAscii( SC_UNONAME_USETABCOL
)) ScUnoHelpFunctions::SetBoolInAny( aRet
, aInpOpt
.GetUseTabCol() );
614 else if (aString
.equalsAscii( SC_UNONAME_PRMETRICS
)) ScUnoHelpFunctions::SetBoolInAny( aRet
, aInpOpt
.GetTextWysiwyg() );
615 else if (aString
.equalsAscii( SC_UNONAME_REPLWARN
)) ScUnoHelpFunctions::SetBoolInAny( aRet
, aInpOpt
.GetReplaceCellsWarn() );
616 else if (aString
.equalsAscii( SC_UNONAME_METRIC
)) aRet
<<= (sal_Int16
) aAppOpt
.GetAppMetric();
617 else if (aString
.equalsAscii( SC_UNONAME_MOVEDIR
)) aRet
<<= (sal_Int16
) aInpOpt
.GetMoveDir();
618 else if (aString
.equalsAscii( SC_UNONAME_STBFUNC
)) aRet
<<= (sal_Int16
) aAppOpt
.GetStatusFunc();
619 else if (aString
.equalsAscii( SC_UNONAME_SCALE
))
621 sal_Int16 nZoomVal
= 0;
622 switch ( aAppOpt
.GetZoomType() )
624 case SVX_ZOOM_PERCENT
: nZoomVal
= aAppOpt
.GetZoom(); break;
625 case SVX_ZOOM_OPTIMAL
: nZoomVal
= SC_ZOOMVAL_OPTIMAL
; break;
626 case SVX_ZOOM_WHOLEPAGE
: nZoomVal
= SC_ZOOMVAL_WHOLEPAGE
; break;
627 case SVX_ZOOM_PAGEWIDTH
: nZoomVal
= SC_ZOOMVAL_PAGEWIDTH
; break;
630 // added to avoid warnings
633 aRet
<<= (sal_Int16
) nZoomVal
;
635 else if (aString
.equalsAscii( SC_UNONAME_ULISTS
))
637 ScUserList
* pUserList
= ScGlobal::GetUserList();
640 size_t nCount
= pUserList
->size();
641 uno::Sequence
<OUString
> aSeq(nCount
);
642 OUString
* pAry
= aSeq
.getArray();
643 for (size_t i
=0; i
<nCount
; ++i
)
645 OUString
aEntry((*pUserList
)[i
]->GetString());
651 else if (aString
.equalsAscii( SC_UNONAME_PRALLSH
))
652 ScUnoHelpFunctions::SetBoolInAny( aRet
, pScMod
->GetPrintOptions().GetAllSheets() );
653 else if (aString
.equalsAscii( SC_UNONAME_PREMPTY
))
654 ScUnoHelpFunctions::SetBoolInAny( aRet
, !pScMod
->GetPrintOptions().GetSkipEmpty() ); // reversed
659 SC_IMPL_DUMMY_PROPERTY_LISTENER( ScSpreadsheetSettings
)
661 //------------------------------------------------------------------------
663 ScRecentFunctionsObj::ScRecentFunctionsObj()
667 ScRecentFunctionsObj::~ScRecentFunctionsObj()
671 // stuff for exService_...
673 uno::Reference
<uno::XInterface
> SAL_CALL
ScRecentFunctionsObj_CreateInstance(
674 const uno::Reference
<lang::XMultiServiceFactory
>& /* rSMgr */ )
676 SolarMutexGuard aGuard
;
678 static uno::Reference
<uno::XInterface
> xInst((cppu::OWeakObject
*)new ScRecentFunctionsObj());
682 OUString
ScRecentFunctionsObj::getImplementationName_Static()
684 return OUString( "stardiv.StarCalc.ScRecentFunctionsObj" );
687 uno::Sequence
<OUString
> ScRecentFunctionsObj::getSupportedServiceNames_Static()
689 uno::Sequence
<OUString
> aRet(1);
690 OUString
* pArray
= aRet
.getArray();
691 pArray
[0] = OUString( SCRECENTFUNCTIONSOBJ_SERVICE
);
697 uno::Sequence
<sal_Int32
> SAL_CALL
ScRecentFunctionsObj::getRecentFunctionIds()
698 throw(uno::RuntimeException
)
700 SolarMutexGuard aGuard
;
701 const ScAppOptions
& rOpt
= SC_MOD()->GetAppOptions();
702 sal_uInt16 nCount
= rOpt
.GetLRUFuncListCount();
703 const sal_uInt16
* pFuncs
= rOpt
.GetLRUFuncList();
706 uno::Sequence
<sal_Int32
> aSeq(nCount
);
707 sal_Int32
* pAry
= aSeq
.getArray();
708 for (sal_uInt16 i
=0; i
<nCount
; i
++)
712 return uno::Sequence
<sal_Int32
>(0);
715 void SAL_CALL
ScRecentFunctionsObj::setRecentFunctionIds(
716 const uno::Sequence
<sal_Int32
>& aRecentFunctionIds
)
717 throw(uno::RuntimeException
)
719 SolarMutexGuard aGuard
;
720 sal_uInt16 nCount
= (sal_uInt16
) std::min( aRecentFunctionIds
.getLength(), (sal_Int32
) LRU_MAX
);
721 const sal_Int32
* pAry
= aRecentFunctionIds
.getConstArray();
723 sal_uInt16
* pFuncs
= nCount
? new sal_uInt16
[nCount
] : NULL
;
724 for (sal_uInt16 i
=0; i
<nCount
; i
++)
725 pFuncs
[i
] = (sal_uInt16
)pAry
[i
]; //! auf gueltige Werte testen?
727 ScModule
* pScMod
= SC_MOD();
728 ScAppOptions
aNewOpts(pScMod
->GetAppOptions());
729 aNewOpts
.SetLRUFuncList(pFuncs
, nCount
);
730 pScMod
->SetAppOptions(aNewOpts
);
732 pScMod
->RecentFunctionsChanged(); // update function list child window
737 sal_Int32 SAL_CALL
ScRecentFunctionsObj::getMaxRecentFunctions() throw(uno::RuntimeException
)
742 //------------------------------------------------------------------------
744 ScFunctionListObj::ScFunctionListObj()
748 ScFunctionListObj::~ScFunctionListObj()
752 // stuff for exService_...
754 uno::Reference
<uno::XInterface
> SAL_CALL
ScFunctionListObj_CreateInstance(
755 const uno::Reference
<lang::XMultiServiceFactory
>& /* rSMgr */ )
757 SolarMutexGuard aGuard
;
759 static uno::Reference
<uno::XInterface
> xInst((cppu::OWeakObject
*)new ScFunctionListObj());
763 OUString
ScFunctionListObj::getImplementationName_Static()
765 return OUString( "stardiv.StarCalc.ScFunctionListObj" );
768 uno::Sequence
<OUString
> ScFunctionListObj::getSupportedServiceNames_Static()
770 uno::Sequence
<OUString
> aRet(1);
771 OUString
* pArray
= aRet
.getArray();
772 pArray
[0] = OUString( SCFUNCTIONLISTOBJ_SERVICE
);
777 static void lcl_FillSequence( uno::Sequence
<beans::PropertyValue
>& rSequence
, const ScFuncDesc
& rDesc
)
779 rDesc
.initArgumentInfo(); // full argument info is needed
781 OSL_ENSURE( rSequence
.getLength() == SC_FUNCDESC_PROPCOUNT
, "Falscher Count" );
783 beans::PropertyValue
* pArray
= rSequence
.getArray();
785 pArray
[0].Name
= OUString( SC_UNONAME_ID
);
786 pArray
[0].Value
<<= (sal_Int32
) rDesc
.nFIndex
;
788 pArray
[1].Name
= OUString( SC_UNONAME_CATEGORY
);
789 pArray
[1].Value
<<= (sal_Int32
) rDesc
.nCategory
;
791 pArray
[2].Name
= OUString( SC_UNONAME_NAME
);
793 pArray
[2].Value
<<= OUString( *rDesc
.pFuncName
);
795 pArray
[3].Name
= OUString( SC_UNONAME_DESCRIPTION
);
797 pArray
[3].Value
<<= OUString( *rDesc
.pFuncDesc
);
799 pArray
[4].Name
= OUString( SC_UNONAME_ARGUMENTS
);
800 if (rDesc
.ppDefArgNames
&& rDesc
.ppDefArgDescs
&& rDesc
.pDefArgFlags
)
802 sal_uInt16 nCount
= rDesc
.nArgCount
;
803 if (nCount
>= PAIRED_VAR_ARGS
)
804 nCount
-= PAIRED_VAR_ARGS
- 2;
805 else if (nCount
>= VAR_ARGS
)
806 nCount
-= VAR_ARGS
- 1;
807 sal_uInt16 nSeqCount
= rDesc
.GetSuppressedArgCount();
808 if (nSeqCount
>= PAIRED_VAR_ARGS
)
809 nSeqCount
-= PAIRED_VAR_ARGS
- 2;
810 else if (nSeqCount
>= VAR_ARGS
)
811 nSeqCount
-= VAR_ARGS
- 1;
815 uno::Sequence
<sheet::FunctionArgument
> aArgSeq(nSeqCount
);
816 sheet::FunctionArgument
* pArgAry
= aArgSeq
.getArray();
817 for (sal_uInt16 i
=0, j
=0; i
<nCount
; i
++)
819 if (!rDesc
.pDefArgFlags
[i
].bSuppress
)
822 if (rDesc
.ppDefArgNames
[i
]) aArgName
= *rDesc
.ppDefArgNames
[i
];
824 if (rDesc
.ppDefArgDescs
[i
]) aArgDesc
= *rDesc
.ppDefArgDescs
[i
];
825 sheet::FunctionArgument aArgument
;
826 aArgument
.Name
= aArgName
;
827 aArgument
.Description
= aArgDesc
;
828 aArgument
.IsOptional
= rDesc
.pDefArgFlags
[i
].bOptional
;
829 pArgAry
[j
++] = aArgument
;
832 pArray
[4].Value
<<= aArgSeq
;
837 // XFunctionDescriptions
839 uno::Sequence
<beans::PropertyValue
> SAL_CALL
ScFunctionListObj::getById( sal_Int32 nId
)
840 throw(lang::IllegalArgumentException
, uno::RuntimeException
)
842 SolarMutexGuard aGuard
;
843 const ScFunctionList
* pFuncList
= ScGlobal::GetStarCalcFunctionList();
846 sal_uInt16 nCount
= (sal_uInt16
)pFuncList
->GetCount();
847 for (sal_uInt16 nIndex
=0; nIndex
<nCount
; nIndex
++)
849 const ScFuncDesc
* pDesc
= pFuncList
->GetFunction(nIndex
);
850 if ( pDesc
&& pDesc
->nFIndex
== nId
)
852 uno::Sequence
<beans::PropertyValue
> aSeq( SC_FUNCDESC_PROPCOUNT
);
853 lcl_FillSequence( aSeq
, *pDesc
);
858 throw lang::IllegalArgumentException(); // not found
861 throw uno::RuntimeException(); // should not happen
866 uno::Any SAL_CALL
ScFunctionListObj::getByName( const OUString
& aName
)
867 throw(container::NoSuchElementException
,
868 lang::WrappedTargetException
, uno::RuntimeException
)
870 SolarMutexGuard aGuard
;
871 OUString
aNameStr(aName
);
872 const ScFunctionList
* pFuncList
= ScGlobal::GetStarCalcFunctionList();
875 sal_uInt16 nCount
= (sal_uInt16
)pFuncList
->GetCount();
876 for (sal_uInt16 nIndex
=0; nIndex
<nCount
; nIndex
++)
878 const ScFuncDesc
* pDesc
= pFuncList
->GetFunction(nIndex
);
879 //! Case-insensitiv ???
880 if ( pDesc
&& pDesc
->pFuncName
&& aNameStr
== *pDesc
->pFuncName
)
882 uno::Sequence
<beans::PropertyValue
> aSeq( SC_FUNCDESC_PROPCOUNT
);
883 lcl_FillSequence( aSeq
, *pDesc
);
884 return uno::makeAny(aSeq
);
888 throw container::NoSuchElementException(); // not found
891 throw uno::RuntimeException(); // should not happen
896 sal_Int32 SAL_CALL
ScFunctionListObj::getCount() throw(uno::RuntimeException
)
898 SolarMutexGuard aGuard
;
899 sal_Int32 nCount
= 0;
900 const ScFunctionList
* pFuncList
= ScGlobal::GetStarCalcFunctionList();
902 nCount
= static_cast<sal_Int32
>(pFuncList
->GetCount());
906 uno::Any SAL_CALL
ScFunctionListObj::getByIndex( sal_Int32 nIndex
)
907 throw(lang::IndexOutOfBoundsException
,
908 lang::WrappedTargetException
, uno::RuntimeException
)
910 SolarMutexGuard aGuard
;
911 const ScFunctionList
* pFuncList
= ScGlobal::GetStarCalcFunctionList();
914 if ( nIndex
>= 0 && nIndex
< (sal_Int32
)pFuncList
->GetCount() )
916 const ScFuncDesc
* pDesc
= pFuncList
->GetFunction(nIndex
);
919 uno::Sequence
<beans::PropertyValue
> aSeq( SC_FUNCDESC_PROPCOUNT
);
920 lcl_FillSequence( aSeq
, *pDesc
);
921 return uno::makeAny(aSeq
);
925 throw lang::IndexOutOfBoundsException(); // illegal index
928 throw uno::RuntimeException(); // should not happen
931 // XEnumerationAccess
933 uno::Reference
<container::XEnumeration
> SAL_CALL
ScFunctionListObj::createEnumeration()
934 throw(uno::RuntimeException
)
936 SolarMutexGuard aGuard
;
937 return new ScIndexEnumeration(this, OUString("com.sun.star.sheet.FunctionDescriptionEnumeration"));
942 uno::Type SAL_CALL
ScFunctionListObj::getElementType() throw(uno::RuntimeException
)
944 SolarMutexGuard aGuard
;
945 return getCppuType((uno::Sequence
<beans::PropertyValue
>*)0);
948 sal_Bool SAL_CALL
ScFunctionListObj::hasElements() throw(uno::RuntimeException
)
950 SolarMutexGuard aGuard
;
951 return ( getCount() > 0 );
954 uno::Sequence
<OUString
> SAL_CALL
ScFunctionListObj::getElementNames() throw(uno::RuntimeException
)
956 SolarMutexGuard aGuard
;
957 const ScFunctionList
* pFuncList
= ScGlobal::GetStarCalcFunctionList();
960 sal_uInt32 nCount
= pFuncList
->GetCount();
961 uno::Sequence
<OUString
> aSeq(nCount
);
962 OUString
* pAry
= aSeq
.getArray();
963 for (sal_uInt32 nIndex
=0; nIndex
<nCount
; ++nIndex
)
965 const ScFuncDesc
* pDesc
= pFuncList
->GetFunction(nIndex
);
966 if ( pDesc
&& pDesc
->pFuncName
)
967 pAry
[nIndex
] = *pDesc
->pFuncName
;
971 return uno::Sequence
<OUString
>(0);
974 sal_Bool SAL_CALL
ScFunctionListObj::hasByName( const OUString
& aName
)
975 throw(uno::RuntimeException
)
977 SolarMutexGuard aGuard
;
978 const ScFunctionList
* pFuncList
= ScGlobal::GetStarCalcFunctionList();
981 sal_uInt32 nCount
= pFuncList
->GetCount();
982 for (sal_uInt32 nIndex
=0; nIndex
<nCount
; ++nIndex
)
984 const ScFuncDesc
* pDesc
= pFuncList
->GetFunction(nIndex
);
985 //! Case-insensitiv ???
986 if ( pDesc
&& pDesc
->pFuncName
&& aName
== *pDesc
->pFuncName
)
993 //------------------------------------------------------------------------
998 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */