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