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

Generated by: LCOV version 1.10