LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/ui/unoobj - appluno.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 389 439 88.6 %
Date: 2013-07-09 Functions: 38 53 71.7 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10