LCOV - code coverage report
Current view: top level - sc/source/ui/unoobj - appluno.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 337 377 89.4 %
Date: 2015-06-13 12:38:46 Functions: 41 50 82.0 %
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             : #include "appluno.hxx"
      21             : #include <sal/types.h>
      22             : #include <osl/diagnose.h>
      23             : #include <cppuhelper/factory.hxx>
      24             : 
      25             : #include <sfx2/app.hxx>
      26             : #include <sfx2/sfxmodelfactory.hxx>
      27             : #include "afmtuno.hxx"
      28             : #include "funcuno.hxx"
      29             : #include "filtuno.hxx"
      30             : #include "miscuno.hxx"
      31             : #include "scmod.hxx"
      32             : #include "appoptio.hxx"
      33             : #include "inputopt.hxx"
      34             : #include "printopt.hxx"
      35             : #include "userlist.hxx"
      36             : #include "sc.hrc"
      37             : #include "unonames.hxx"
      38             : #include "funcdesc.hxx"
      39             : #include <com/sun/star/document/LinkUpdateModes.hpp>
      40             : #include <com/sun/star/sheet/FunctionArgument.hpp>
      41             : #include <boost/scoped_array.hpp>
      42             : 
      43             : using namespace com::sun::star;
      44             : 
      45             : //  Anzahl der Funktionen, die als zuletzt benutzt gespeichert werden
      46             : //! Define mit funcpage.hxx und dwfunctr.hxx zusammenfassen !!!
      47             : #define LRU_MAX 10
      48             : 
      49             : //  Spezial-Werte fuer Zoom
      50             : //! irgendwo zentral
      51             : #define SC_ZOOMVAL_OPTIMAL      (-1)
      52             : #define SC_ZOOMVAL_WHOLEPAGE    (-2)
      53             : #define SC_ZOOMVAL_PAGEWIDTH    (-3)
      54             : 
      55             : //  Anzahl der PropertyValues in einer Function-Description
      56             : #define SC_FUNCDESC_PROPCOUNT   5
      57             : 
      58             : //  alles ohne Which-ID, Map nur fuer PropertySetInfo
      59             : 
      60           9 : static const SfxItemPropertyMapEntry* lcl_GetSettingsPropertyMap()
      61             : {
      62             :     static const SfxItemPropertyMapEntry aSettingsPropertyMap_Impl[] =
      63             :     {
      64           9 :         {OUString(SC_UNONAME_DOAUTOCP), 0,  cppu::UnoType<bool>::get(),              0, 0},
      65           9 :         {OUString(SC_UNONAME_ENTERED),  0,  cppu::UnoType<bool>::get(),              0, 0},
      66           9 :         {OUString(SC_UNONAME_EXPREF),   0,  cppu::UnoType<bool>::get(),              0, 0},
      67           9 :         {OUString(SC_UNONAME_EXTFMT),   0,  cppu::UnoType<bool>::get(),              0, 0},
      68           9 :         {OUString(SC_UNONAME_LINKUPD),  0,  cppu::UnoType<sal_Int16>::get(),        0, 0},
      69           9 :         {OUString(SC_UNONAME_MARKHDR),  0,  cppu::UnoType<bool>::get(),              0, 0},
      70           9 :         {OUString(SC_UNONAME_METRIC),   0,  cppu::UnoType<sal_Int16>::get(),        0, 0},
      71           9 :         {OUString(SC_UNONAME_MOVEDIR),  0,  cppu::UnoType<sal_Int16>::get(),        0, 0},
      72           9 :         {OUString(SC_UNONAME_MOVESEL),  0,  cppu::UnoType<bool>::get(),              0, 0},
      73           9 :         {OUString(SC_UNONAME_PRALLSH),  0,  cppu::UnoType<bool>::get(),              0, 0},
      74           9 :         {OUString(SC_UNONAME_PREMPTY),  0,  cppu::UnoType<bool>::get(),              0, 0},
      75           9 :         {OUString(SC_UNONAME_RANGEFIN), 0,  cppu::UnoType<bool>::get(),              0, 0},
      76           9 :         {OUString(SC_UNONAME_SCALE),    0,  cppu::UnoType<sal_Int16>::get(),        0, 0},
      77           9 :         {OUString(SC_UNONAME_STBFUNC),  0,  cppu::UnoType<sal_Int16>::get(),        0, 0},
      78           9 :         {OUString(SC_UNONAME_ULISTS),   0,  cppu::UnoType<uno::Sequence<OUString>>::get(), 0, 0},
      79           9 :         {OUString(SC_UNONAME_PRMETRICS),0,  cppu::UnoType<bool>::get(),              0, 0},
      80           9 :         {OUString(SC_UNONAME_USETABCOL),0,  cppu::UnoType<bool>::get(),              0, 0},
      81           9 :         {OUString(SC_UNONAME_REPLWARN), 0,  cppu::UnoType<bool>::get(),              0, 0},
      82             :         { OUString(), 0, css::uno::Type(), 0, 0 }
      83         180 :     };
      84           9 :     return aSettingsPropertyMap_Impl;
      85             : }
      86             : 
      87             : #define SCFUNCTIONLISTOBJ_SERVICE       "com.sun.star.sheet.FunctionDescriptions"
      88             : #define SCRECENTFUNCTIONSOBJ_SERVICE    "com.sun.star.sheet.RecentFunctions"
      89             : #define SCSPREADSHEETSETTINGS_SERVICE   "com.sun.star.sheet.GlobalSheetSettings"
      90             : 
      91           2 : SC_SIMPLE_SERVICE_INFO( ScFunctionListObj, "stardiv.StarCalc.ScFunctionListObj", SCFUNCTIONLISTOBJ_SERVICE )
      92           2 : SC_SIMPLE_SERVICE_INFO( ScRecentFunctionsObj, "stardiv.StarCalc.ScRecentFunctionsObj", SCRECENTFUNCTIONSOBJ_SERVICE )
      93           4 : SC_SIMPLE_SERVICE_INFO( ScSpreadsheetSettings, "stardiv.StarCalc.ScSpreadsheetSettings", SCSPREADSHEETSETTINGS_SERVICE )
      94             : 
      95             : extern "C" {
      96             : 
      97         191 : SAL_DLLPUBLIC_EXPORT void * SAL_CALL sc_component_getFactory(
      98             :     const sal_Char * pImplName, void * pServiceManager, void * /* pRegistryKey */ )
      99             : {
     100         191 :     if (!pServiceManager)
     101           0 :         return NULL;
     102             : 
     103         191 :     uno::Reference<lang::XSingleServiceFactory> xFactory;
     104         382 :     OUString aImpl(OUString::createFromAscii(pImplName));
     105             : 
     106         191 :     if ( aImpl == ScSpreadsheetSettings::getImplementationName_Static() )
     107             :     {
     108             :         xFactory.set(cppu::createOneInstanceFactory(
     109             :                 static_cast<lang::XMultiServiceFactory*>(pServiceManager),
     110             :                 ScSpreadsheetSettings::getImplementationName_Static(),
     111             :                 ScSpreadsheetSettings_CreateInstance,
     112           9 :                 ScSpreadsheetSettings::getSupportedServiceNames_Static() ));
     113             :     }
     114         182 :     else if ( aImpl == ScXMLImport_getImplementationName() )
     115             :     {
     116             :         xFactory.set(cppu::createSingleFactory(
     117             :                 static_cast<lang::XMultiServiceFactory*>(pServiceManager),
     118             :                 ScXMLImport_getImplementationName(),
     119             :                 ScXMLImport_createInstance,
     120           2 :                 ScXMLImport_getSupportedServiceNames() ));
     121             :     }
     122         180 :     else if ( aImpl == ScXMLImport_Meta_getImplementationName() )
     123             :     {
     124             :         xFactory.set(cppu::createSingleFactory(
     125             :                 static_cast<lang::XMultiServiceFactory*>(pServiceManager),
     126             :                 ScXMLImport_Meta_getImplementationName(),
     127             :                 ScXMLImport_Meta_createInstance,
     128          32 :                 ScXMLImport_Meta_getSupportedServiceNames() ));
     129             :     }
     130         148 :     else if ( aImpl == ScXMLImport_Styles_getImplementationName() )
     131             :     {
     132             :         xFactory.set(cppu::createSingleFactory(
     133             :                 static_cast<lang::XMultiServiceFactory*>(pServiceManager),
     134             :                 ScXMLImport_Styles_getImplementationName(),
     135             :                 ScXMLImport_Styles_createInstance,
     136          33 :                 ScXMLImport_Styles_getSupportedServiceNames() ));
     137             :     }
     138         115 :     else if ( aImpl == ScXMLImport_Content_getImplementationName() )
     139             :     {
     140             :         xFactory.set(cppu::createSingleFactory(
     141             :                 static_cast<lang::XMultiServiceFactory*>(pServiceManager),
     142             :                 ScXMLImport_Content_getImplementationName(),
     143             :                 ScXMLImport_Content_createInstance,
     144          32 :                 ScXMLImport_Content_getSupportedServiceNames() ));
     145             :     }
     146          83 :     else if ( aImpl == ScXMLImport_Settings_getImplementationName() )
     147             :     {
     148             :         xFactory.set(cppu::createSingleFactory(
     149             :                 static_cast<lang::XMultiServiceFactory*>(pServiceManager),
     150             :                 ScXMLImport_Settings_getImplementationName(),
     151             :                 ScXMLImport_Settings_createInstance,
     152          33 :                 ScXMLImport_Settings_getSupportedServiceNames() ));
     153             :     }
     154          50 :     else if ( aImpl == ScDocument_getImplementationName() )
     155             :     {
     156             :         xFactory.set(sfx2::createSfxModelFactory(
     157             :                 static_cast<lang::XMultiServiceFactory*>(pServiceManager),
     158             :                 ScDocument_getImplementationName(),
     159             :                 ScDocument_createInstance,
     160          50 :                 ScDocument_getSupportedServiceNames() ));
     161             :     }
     162             : 
     163         191 :     void* pRet = NULL;
     164         191 :     if (xFactory.is())
     165             :     {
     166         191 :         xFactory->acquire();
     167         191 :         pRet = xFactory.get();
     168             :     }
     169         382 :     return pRet;
     170             : }
     171             : 
     172             : }   // extern C
     173             : 
     174           9 : ScSpreadsheetSettings::ScSpreadsheetSettings() :
     175           9 :     aPropSet( lcl_GetSettingsPropertyMap() )
     176             : {
     177           9 : }
     178             : 
     179          18 : ScSpreadsheetSettings::~ScSpreadsheetSettings()
     180             : {
     181          18 : }
     182             : 
     183           9 : uno::Reference<uno::XInterface> SAL_CALL ScSpreadsheetSettings_CreateInstance(
     184             :                         const uno::Reference<lang::XMultiServiceFactory>& /* rSMgr */ )
     185             : {
     186           9 :     SolarMutexGuard aGuard;
     187           9 :     ScDLL::Init();
     188           9 :     return static_cast<cppu::OWeakObject*>(new ScSpreadsheetSettings());
     189             : }
     190             : 
     191         200 : OUString ScSpreadsheetSettings::getImplementationName_Static()
     192             : {
     193         200 :     return OUString( "stardiv.StarCalc.ScSpreadsheetSettings" );
     194             : }
     195             : 
     196           9 : uno::Sequence<OUString> ScSpreadsheetSettings::getSupportedServiceNames_Static()
     197             : {
     198           9 :     uno::Sequence<OUString> aRet(1);
     199           9 :     OUString* pArray = aRet.getArray();
     200           9 :     pArray[0] = SCSPREADSHEETSETTINGS_SERVICE;
     201           9 :     return aRet;
     202             : }
     203             : 
     204          15 : bool ScSpreadsheetSettings::getPropertyBool(const OUString& aPropertyName) throw (css::uno::RuntimeException)
     205             : {
     206          15 :    uno::Any any = getPropertyValue(aPropertyName);
     207          15 :    bool b = false;
     208          15 :    any >>= b;
     209          15 :    return b;
     210             : }
     211             : 
     212          98 : sal_Int16 ScSpreadsheetSettings::getPropertyInt16(const OUString& aPropertyName) throw (css::uno::RuntimeException)
     213             : {
     214          98 :    uno::Any any = getPropertyValue(aPropertyName);
     215          98 :    sal_Int16 b = 0;
     216          98 :    any >>= b;
     217          98 :    return b;
     218             : }
     219             : 
     220             : // XPropertySet
     221             : 
     222          37 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScSpreadsheetSettings::getPropertySetInfo()
     223             :                                                         throw(uno::RuntimeException, std::exception)
     224             : {
     225          37 :     SolarMutexGuard aGuard;
     226             :     static uno::Reference<beans::XPropertySetInfo> aRef(
     227          37 :         new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
     228          37 :     return aRef;
     229             : }
     230             : 
     231          84 : void SAL_CALL ScSpreadsheetSettings::setPropertyValue(
     232             :                         const OUString& aPropertyName, const uno::Any& aValue )
     233             :                 throw (beans::UnknownPropertyException, beans::PropertyVetoException,
     234             :                        lang::IllegalArgumentException, lang::WrappedTargetException,
     235             :                        uno::RuntimeException, std::exception)
     236             : {
     237          84 :     SolarMutexGuard aGuard;
     238         168 :     OUString aString(aPropertyName);
     239             : 
     240          84 :     ScModule* pScMod = SC_MOD();
     241         168 :     ScAppOptions   aAppOpt(pScMod->GetAppOptions());
     242         168 :     ScInputOptions aInpOpt(pScMod->GetInputOptions());
     243          84 :     bool bSaveApp = false;
     244          84 :     bool bSaveInp = false;
     245             :     // print options aren't loaded until needed
     246             : 
     247          84 :     if (aString == SC_UNONAME_DOAUTOCP)
     248             :     {
     249           3 :         aAppOpt.SetAutoComplete( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
     250           3 :         bSaveApp = true;
     251             :     }
     252          81 :     else if (aString == SC_UNONAME_ENTERED)
     253             :     {
     254           3 :         aInpOpt.SetEnterEdit( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
     255           3 :         bSaveInp = true;
     256             :     }
     257          78 :     else if (aString == SC_UNONAME_EXPREF)
     258             :     {
     259           3 :         aInpOpt.SetExpandRefs( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
     260           3 :         bSaveInp = true;
     261             :     }
     262          75 :     else if (aString == SC_UNONAME_EXTFMT)
     263             :     {
     264           3 :         aInpOpt.SetExtendFormat( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
     265           3 :         bSaveInp = true;
     266             :     }
     267          72 :     else if (aString == SC_UNONAME_LINKUPD)
     268             :     {
     269             :         sal_Int16 n;
     270           9 :         if (!(aValue >>= n) || n < css::document::LinkUpdateModes::NEVER
     271           6 :             || n > css::document::LinkUpdateModes::GLOBAL_SETTING)
     272             :         {
     273             :             throw css::lang::IllegalArgumentException(
     274             :                 ("LinkUpdateMode property value must be a SHORT with a value in"
     275             :                  " the range of the css.document.LinkUpdateModes constants"),
     276           0 :                 css::uno::Reference<css::uno::XInterface>(), -1);
     277             :         }
     278             :         //TODO: ScLkUpdMode (LM_ALWAYS=0, LM_NEVER=1, LM_ON_DEMAND=2,
     279             :         // LM_UNKNOWN=3) does not match css.document.LinkUpdateModes (NEVER=0,
     280             :         // MANUAL=1, AUTO=2, GLOBAL_SETTINGS=3):
     281           3 :         aAppOpt.SetLinkMode( static_cast<ScLkUpdMode>(n) );
     282           3 :         bSaveApp = true;
     283             :     }
     284          69 :     else if (aString == SC_UNONAME_MARKHDR)
     285             :     {
     286           3 :         aInpOpt.SetMarkHeader( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
     287           3 :         bSaveInp = true;
     288             :     }
     289          66 :     else if (aString == SC_UNONAME_MOVESEL)
     290             :     {
     291           3 :         aInpOpt.SetMoveSelection( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
     292           3 :         bSaveInp = true;
     293             :     }
     294          63 :     else if (aString == SC_UNONAME_RANGEFIN)
     295             :     {
     296           3 :         aInpOpt.SetRangeFinder( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
     297           3 :         bSaveInp = true;
     298             :     }
     299          60 :     else if (aString == SC_UNONAME_USETABCOL)
     300             :     {
     301           3 :         aInpOpt.SetUseTabCol( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
     302           3 :         bSaveInp = true;
     303             :     }
     304          57 :     else if (aString == SC_UNONAME_PRMETRICS)
     305             :     {
     306           3 :         aInpOpt.SetTextWysiwyg( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
     307           3 :         bSaveInp = true;
     308             :     }
     309          54 :     else if (aString == SC_UNONAME_REPLWARN)
     310             :     {
     311          33 :         aInpOpt.SetReplaceCellsWarn( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
     312          33 :         bSaveInp = true;
     313             :     }
     314          21 :     else if (aString == SC_UNONAME_METRIC)
     315             :     {
     316           3 :         aAppOpt.SetAppMetric( (FieldUnit) ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
     317           3 :         bSaveApp = true;
     318             :     }
     319          18 :     else if (aString == SC_UNONAME_MOVEDIR)
     320             :     {
     321           3 :         aInpOpt.SetMoveDir( ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
     322           3 :         bSaveInp = true;
     323             :     }
     324          15 :     else if (aString == SC_UNONAME_SCALE)
     325             :     {
     326           3 :         short nVal = ScUnoHelpFunctions::GetInt16FromAny( aValue );
     327           3 :         if ( nVal < 0 )
     328             :         {
     329           0 :             SvxZoomType eType = SvxZoomType::PERCENT;
     330           0 :             switch (nVal)
     331             :             {
     332           0 :                 case SC_ZOOMVAL_OPTIMAL:    eType = SvxZoomType::OPTIMAL;   break;
     333           0 :                 case SC_ZOOMVAL_WHOLEPAGE:  eType = SvxZoomType::WHOLEPAGE; break;
     334           0 :                 case SC_ZOOMVAL_PAGEWIDTH:  eType = SvxZoomType::PAGEWIDTH; break;
     335             :             }
     336           0 :             aAppOpt.SetZoomType( eType );
     337             :         }
     338           3 :         else if ( nVal >= MINZOOM && nVal <= MAXZOOM )
     339             :         {
     340           3 :             aAppOpt.SetZoom( nVal );
     341           3 :             aAppOpt.SetZoomType( SvxZoomType::PERCENT );
     342             :         }
     343           3 :         bSaveApp = true;
     344             :     }
     345          12 :     else if (aString == SC_UNONAME_STBFUNC)
     346             :     {
     347           3 :         aAppOpt.SetStatusFunc( ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
     348           3 :         bSaveApp = true;
     349             :     }
     350           9 :     else if (aString == SC_UNONAME_ULISTS)
     351             :     {
     352           3 :         ScUserList* pUserList = ScGlobal::GetUserList();
     353           3 :         uno::Sequence<OUString> aSeq;
     354           3 :         if ( pUserList && ( aValue >>= aSeq ) )
     355             :         {
     356             :             //  es wird direkt die "lebende" Liste veraendert,
     357             :             //  mehr tut ScGlobal::SetUserList auch nicht
     358             : 
     359           3 :             pUserList->clear();                 // alle Eintraege raus
     360           3 :             sal_uInt16 nCount = (sal_uInt16)aSeq.getLength();
     361           3 :             const OUString* pAry = aSeq.getConstArray();
     362          27 :             for (sal_uInt16 i=0; i<nCount; i++)
     363             :             {
     364          24 :                 OUString aEntry = pAry[i];
     365          24 :                 ScUserListData* pData = new ScUserListData(aEntry);
     366          24 :                 pUserList->push_back(pData);
     367          24 :             }
     368           3 :             bSaveApp = true;    // Liste wird mit den App-Optionen gespeichert
     369           3 :         }
     370             :     }
     371           6 :     else if (aString == SC_UNONAME_PRALLSH)
     372             :     {
     373           3 :         ScPrintOptions aPrintOpt(pScMod->GetPrintOptions());
     374           3 :         aPrintOpt.SetAllSheets( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
     375           3 :         pScMod->SetPrintOptions( aPrintOpt );
     376             :     }
     377           3 :     else if (aString == SC_UNONAME_PREMPTY)
     378             :     {
     379           3 :         ScPrintOptions aPrintOpt(pScMod->GetPrintOptions());
     380           3 :         aPrintOpt.SetSkipEmpty( !ScUnoHelpFunctions::GetBoolFromAny( aValue ) );    // reversed
     381           3 :         pScMod->SetPrintOptions( aPrintOpt );
     382           3 :         SfxGetpApp()->Broadcast( SfxSimpleHint( SID_SCPRINTOPTIONS ) );    // update previews
     383             :     }
     384             : 
     385          84 :     if ( bSaveApp )
     386          18 :         pScMod->SetAppOptions( aAppOpt );
     387          84 :     if ( bSaveInp )
     388         144 :         pScMod->SetInputOptions( aInpOpt );
     389          84 : }
     390             : 
     391         239 : uno::Any SAL_CALL ScSpreadsheetSettings::getPropertyValue( const OUString& aPropertyName )
     392             :                 throw (beans::UnknownPropertyException, lang::WrappedTargetException,
     393             :                        uno::RuntimeException, std::exception)
     394             : {
     395         239 :     SolarMutexGuard aGuard;
     396         478 :     OUString aString = aPropertyName;
     397         239 :     uno::Any aRet;
     398             : 
     399         239 :     ScModule* pScMod = SC_MOD();
     400         478 :     ScAppOptions   aAppOpt = pScMod->GetAppOptions();
     401         478 :     ScInputOptions aInpOpt = pScMod->GetInputOptions();
     402             :     // print options aren't loaded until needed
     403             : 
     404         239 :     if (aString == SC_UNONAME_DOAUTOCP)     ScUnoHelpFunctions::SetBoolInAny( aRet, aAppOpt.GetAutoComplete() );
     405         232 :     else if (aString == SC_UNONAME_ENTERED ) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetEnterEdit() );
     406         225 :     else if (aString == SC_UNONAME_EXPREF )  ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetExpandRefs() );
     407         218 :     else if (aString == SC_UNONAME_EXTFMT )  ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetExtendFormat() );
     408         211 :     else if (aString == SC_UNONAME_LINKUPD ) aRet <<= (sal_Int16) aAppOpt.GetLinkMode();
     409         204 :     else if (aString == SC_UNONAME_MARKHDR ) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetMarkHeader() );
     410         197 :     else if (aString == SC_UNONAME_MOVESEL ) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetMoveSelection() );
     411         190 :     else if (aString == SC_UNONAME_RANGEFIN ) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetRangeFinder() );
     412         183 :     else if (aString == SC_UNONAME_USETABCOL ) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetUseTabCol() );
     413         176 :     else if (aString == SC_UNONAME_PRMETRICS ) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetTextWysiwyg() );
     414         169 :     else if (aString == SC_UNONAME_REPLWARN ) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetReplaceCellsWarn() );
     415         147 :     else if (aString == SC_UNONAME_METRIC )  aRet <<= (sal_Int16) aAppOpt.GetAppMetric();
     416          42 :     else if (aString == SC_UNONAME_MOVEDIR ) aRet <<= (sal_Int16) aInpOpt.GetMoveDir();
     417          35 :     else if (aString == SC_UNONAME_STBFUNC ) aRet <<= (sal_Int16) aAppOpt.GetStatusFunc();
     418          28 :     else if (aString == SC_UNONAME_SCALE )
     419             :     {
     420           7 :         sal_Int16 nZoomVal = 0;
     421           7 :         switch ( aAppOpt.GetZoomType() )
     422             :         {
     423           7 :             case SvxZoomType::PERCENT:   nZoomVal = aAppOpt.GetZoom();    break;
     424           0 :             case SvxZoomType::OPTIMAL:   nZoomVal = SC_ZOOMVAL_OPTIMAL;   break;
     425           0 :             case SvxZoomType::WHOLEPAGE: nZoomVal = SC_ZOOMVAL_WHOLEPAGE; break;
     426           0 :             case SvxZoomType::PAGEWIDTH: nZoomVal = SC_ZOOMVAL_PAGEWIDTH; break;
     427             :             default:
     428             :             {
     429             :                 // added to avoid warnings
     430             :             }
     431             :         }
     432           7 :         aRet <<= (sal_Int16) nZoomVal;
     433             :     }
     434          21 :     else if (aString == SC_UNONAME_ULISTS )
     435             :     {
     436           7 :         ScUserList* pUserList = ScGlobal::GetUserList();
     437           7 :         if (pUserList)
     438             :         {
     439           7 :             size_t nCount = pUserList->size();
     440           7 :             uno::Sequence<OUString> aSeq(nCount);
     441           7 :             OUString* pAry = aSeq.getArray();
     442          60 :             for (size_t i=0; i<nCount; ++i)
     443             :             {
     444          53 :                 OUString aEntry((*pUserList)[i]->GetString());
     445          53 :                 pAry[i] = aEntry;
     446          53 :             }
     447           7 :             aRet <<= aSeq;
     448             :         }
     449             :     }
     450          14 :     else if (aString == SC_UNONAME_PRALLSH )
     451           7 :         ScUnoHelpFunctions::SetBoolInAny( aRet, pScMod->GetPrintOptions().GetAllSheets() );
     452           7 :     else if (aString == SC_UNONAME_PREMPTY )
     453           7 :         ScUnoHelpFunctions::SetBoolInAny( aRet, !pScMod->GetPrintOptions().GetSkipEmpty() );    // reversed
     454             : 
     455         478 :     return aRet;
     456             : }
     457             : 
     458           0 : SC_IMPL_DUMMY_PROPERTY_LISTENER( ScSpreadsheetSettings )
     459             : 
     460           2 : ScRecentFunctionsObj::ScRecentFunctionsObj()
     461             : {
     462           2 : }
     463             : 
     464           4 : ScRecentFunctionsObj::~ScRecentFunctionsObj()
     465             : {
     466           4 : }
     467             : 
     468             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* SAL_CALL
     469           2 : ScRecentFunctionsObj_get_implementation(css::uno::XComponentContext*, css::uno::Sequence<css::uno::Any> const &)
     470             : {
     471           2 :     SolarMutexGuard aGuard;
     472           2 :     ScDLL::Init();
     473           2 :     return cppu::acquire(new ScRecentFunctionsObj());
     474             : }
     475             : 
     476             : // XRecentFunctions
     477             : 
     478           0 : uno::Sequence<sal_Int32> SAL_CALL ScRecentFunctionsObj::getRecentFunctionIds()
     479             :                                                         throw(uno::RuntimeException, std::exception)
     480             : {
     481           0 :     SolarMutexGuard aGuard;
     482           0 :     const ScAppOptions& rOpt = SC_MOD()->GetAppOptions();
     483           0 :     sal_uInt16 nCount = rOpt.GetLRUFuncListCount();
     484           0 :     const sal_uInt16* pFuncs = rOpt.GetLRUFuncList();
     485           0 :     if (pFuncs)
     486             :     {
     487           0 :         uno::Sequence<sal_Int32> aSeq(nCount);
     488           0 :         sal_Int32* pAry = aSeq.getArray();
     489           0 :         for (sal_uInt16 i=0; i<nCount; i++)
     490           0 :             pAry[i] = pFuncs[i];
     491           0 :         return aSeq;
     492             :     }
     493           0 :     return uno::Sequence<sal_Int32>(0);
     494             : }
     495             : 
     496           0 : void SAL_CALL ScRecentFunctionsObj::setRecentFunctionIds(
     497             :                     const uno::Sequence<sal_Int32>& aRecentFunctionIds )
     498             :                                     throw(uno::RuntimeException, std::exception)
     499             : {
     500           0 :     SolarMutexGuard aGuard;
     501           0 :     sal_uInt16 nCount = (sal_uInt16) std::min( aRecentFunctionIds.getLength(), (sal_Int32) LRU_MAX );
     502           0 :     const sal_Int32* pAry = aRecentFunctionIds.getConstArray();
     503             : 
     504           0 :     boost::scoped_array<sal_uInt16> pFuncs(nCount ? new sal_uInt16[nCount] : NULL);
     505           0 :     for (sal_uInt16 i=0; i<nCount; i++)
     506           0 :         pFuncs[i] = (sal_uInt16)pAry[i];        //! auf gueltige Werte testen?
     507             : 
     508           0 :     ScModule* pScMod = SC_MOD();
     509           0 :     ScAppOptions aNewOpts(pScMod->GetAppOptions());
     510           0 :     aNewOpts.SetLRUFuncList(pFuncs.get(), nCount);
     511           0 :     pScMod->SetAppOptions(aNewOpts);
     512             : 
     513           0 :     ScModule::RecentFunctionsChanged();       // update function list child window
     514           0 : }
     515             : 
     516           0 : sal_Int32 SAL_CALL ScRecentFunctionsObj::getMaxRecentFunctions() throw(uno::RuntimeException, std::exception)
     517             : {
     518           0 :     return LRU_MAX;
     519             : }
     520             : 
     521           4 : ScFunctionListObj::ScFunctionListObj()
     522             : {
     523           4 : }
     524             : 
     525           8 : ScFunctionListObj::~ScFunctionListObj()
     526             : {
     527           8 : }
     528             : 
     529             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* SAL_CALL
     530           4 : ScFunctionListObj_get_implementation(css::uno::XComponentContext*, css::uno::Sequence<css::uno::Any> const &)
     531             : {
     532           4 :     SolarMutexGuard aGuard;
     533           4 :     ScDLL::Init();
     534           4 :     return cppu::acquire(new ScFunctionListObj());
     535             : }
     536             : 
     537         487 : static void lcl_FillSequence( uno::Sequence<beans::PropertyValue>& rSequence, const ScFuncDesc& rDesc )
     538             : {
     539         487 :     rDesc.initArgumentInfo();   // full argument info is needed
     540             : 
     541             :     OSL_ENSURE( rSequence.getLength() == SC_FUNCDESC_PROPCOUNT, "Falscher Count" );
     542             : 
     543         487 :     beans::PropertyValue* pArray = rSequence.getArray();
     544             : 
     545         487 :     pArray[0].Name = SC_UNONAME_ID;
     546         487 :     pArray[0].Value <<= (sal_Int32) rDesc.nFIndex;
     547             : 
     548         487 :     pArray[1].Name = SC_UNONAME_CATEGORY;
     549         487 :     pArray[1].Value <<= (sal_Int32) rDesc.nCategory;
     550             : 
     551         487 :     pArray[2].Name = SC_UNONAME_NAME;
     552         487 :     if (rDesc.pFuncName)
     553         487 :         pArray[2].Value <<= OUString( *rDesc.pFuncName );
     554             : 
     555         487 :     pArray[3].Name = SC_UNONAME_DESCRIPTION;
     556         487 :     if (rDesc.pFuncDesc)
     557         487 :         pArray[3].Value <<= OUString( *rDesc.pFuncDesc );
     558             : 
     559         487 :     pArray[4].Name = SC_UNONAME_ARGUMENTS;
     560         487 :     if (!rDesc.maDefArgNames.empty() && !rDesc.maDefArgDescs.empty() && rDesc.pDefArgFlags )
     561             :     {
     562         479 :         sal_uInt16 nCount = rDesc.nArgCount;
     563         479 :                 if (nCount >= PAIRED_VAR_ARGS)
     564           3 :                     nCount -= PAIRED_VAR_ARGS - 2;
     565         476 :         else if (nCount >= VAR_ARGS)
     566          51 :             nCount -= VAR_ARGS - 1;
     567         479 :         sal_uInt16 nSeqCount = rDesc.GetSuppressedArgCount();
     568         479 :         if (nSeqCount >= PAIRED_VAR_ARGS)
     569           3 :             nSeqCount -= PAIRED_VAR_ARGS - 2;
     570         476 :         else if (nSeqCount >= VAR_ARGS)
     571          51 :             nSeqCount -= VAR_ARGS - 1;
     572             : 
     573         479 :         if (nSeqCount)
     574             :         {
     575         479 :             uno::Sequence<sheet::FunctionArgument> aArgSeq(nSeqCount);
     576         479 :             sheet::FunctionArgument* pArgAry = aArgSeq.getArray();
     577        1633 :             for (sal_uInt16 i=0, j=0; i<nCount; i++)
     578             :             {
     579        1154 :                 if (!rDesc.pDefArgFlags[i].bSuppress)
     580             :                 {
     581        1154 :                     sheet::FunctionArgument aArgument;
     582        1154 :                     aArgument.Name        = rDesc.maDefArgNames[i];
     583        1154 :                     aArgument.Description = rDesc.maDefArgDescs[i];
     584        1154 :                     aArgument.IsOptional  = rDesc.pDefArgFlags[i].bOptional;
     585        1154 :                     pArgAry[j++] = aArgument;
     586             :                 }
     587             :             }
     588         479 :             pArray[4].Value <<= aArgSeq;
     589             :         }
     590             :     }
     591         487 : }
     592             : 
     593             : // XFunctionDescriptions
     594             : 
     595           2 : uno::Sequence<beans::PropertyValue> SAL_CALL ScFunctionListObj::getById( sal_Int32 nId )
     596             :                                 throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
     597             : {
     598           2 :     SolarMutexGuard aGuard;
     599           2 :     const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
     600           2 :     if ( pFuncList )
     601             :     {
     602           2 :         sal_uInt16 nCount = (sal_uInt16)pFuncList->GetCount();
     603         751 :         for (sal_uInt16 nIndex=0; nIndex<nCount; nIndex++)
     604             :         {
     605         750 :             const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
     606         750 :             if ( pDesc && pDesc->nFIndex == nId )
     607             :             {
     608           1 :                 uno::Sequence<beans::PropertyValue> aSeq( SC_FUNCDESC_PROPCOUNT );
     609           1 :                 lcl_FillSequence( aSeq, *pDesc );
     610           2 :                 return aSeq;
     611             :             }
     612             :         }
     613             : 
     614           1 :         throw lang::IllegalArgumentException();         // not found
     615             :     }
     616             :     else
     617           1 :         throw uno::RuntimeException();                  // should not happen
     618             : }
     619             : 
     620             : // XNameAccess
     621             : 
     622           2 : uno::Any SAL_CALL ScFunctionListObj::getByName( const OUString& aName )
     623             :             throw(container::NoSuchElementException,
     624             :                     lang::WrappedTargetException, uno::RuntimeException, std::exception)
     625             : {
     626           2 :     SolarMutexGuard aGuard;
     627           4 :     OUString aNameStr(aName);
     628           2 :     const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
     629           2 :     if ( pFuncList )
     630             :     {
     631           2 :         sal_uInt16 nCount = (sal_uInt16)pFuncList->GetCount();
     632         483 :         for (sal_uInt16 nIndex=0; nIndex<nCount; nIndex++)
     633             :         {
     634         482 :             const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
     635             :             //! Case-insensitiv ???
     636         482 :             if ( pDesc && pDesc->pFuncName && aNameStr == *pDesc->pFuncName )
     637             :             {
     638           1 :                 uno::Sequence<beans::PropertyValue> aSeq( SC_FUNCDESC_PROPCOUNT );
     639           1 :                 lcl_FillSequence( aSeq, *pDesc );
     640           2 :                 return uno::makeAny(aSeq);
     641             :             }
     642             :         }
     643             : 
     644           1 :         throw container::NoSuchElementException();      // not found
     645             :     }
     646             :     else
     647           2 :         throw uno::RuntimeException();                  // should not happen
     648             : }
     649             : 
     650             : // XIndexAccess
     651             : 
     652         485 : sal_Int32 SAL_CALL ScFunctionListObj::getCount() throw(uno::RuntimeException, std::exception)
     653             : {
     654         485 :     SolarMutexGuard aGuard;
     655         485 :     sal_Int32 nCount = 0;
     656         485 :     const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
     657         485 :     if ( pFuncList )
     658         485 :         nCount = static_cast<sal_Int32>(pFuncList->GetCount());
     659         485 :     return nCount;
     660             : }
     661             : 
     662         487 : uno::Any SAL_CALL ScFunctionListObj::getByIndex( sal_Int32 nIndex )
     663             :                             throw(lang::IndexOutOfBoundsException,
     664             :                                     lang::WrappedTargetException, uno::RuntimeException, std::exception)
     665             : {
     666         487 :     SolarMutexGuard aGuard;
     667         487 :     const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
     668         487 :     if ( pFuncList )
     669             :     {
     670         487 :         if ( nIndex >= 0 && nIndex < (sal_Int32)pFuncList->GetCount() )
     671             :         {
     672         485 :             const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
     673         485 :             if ( pDesc )
     674             :             {
     675         485 :                 uno::Sequence<beans::PropertyValue> aSeq( SC_FUNCDESC_PROPCOUNT );
     676         485 :                 lcl_FillSequence( aSeq, *pDesc );
     677         970 :                 return uno::makeAny(aSeq);
     678             :             }
     679             :         }
     680             : 
     681           2 :         throw lang::IndexOutOfBoundsException();        // illegal index
     682             :     }
     683             :     else
     684         485 :         throw uno::RuntimeException();                  // should not happen
     685             : }
     686             : 
     687             : // XEnumerationAccess
     688             : 
     689           2 : uno::Reference<container::XEnumeration> SAL_CALL ScFunctionListObj::createEnumeration()
     690             :                                                     throw(uno::RuntimeException, std::exception)
     691             : {
     692           2 :     SolarMutexGuard aGuard;
     693           2 :     return new ScIndexEnumeration(this, OUString("com.sun.star.sheet.FunctionDescriptionEnumeration"));
     694             : }
     695             : 
     696             : // XElementAccess
     697             : 
     698           1 : uno::Type SAL_CALL ScFunctionListObj::getElementType() throw(uno::RuntimeException, std::exception)
     699             : {
     700           1 :     SolarMutexGuard aGuard;
     701           1 :     return cppu::UnoType<uno::Sequence<beans::PropertyValue>>::get();
     702             : }
     703             : 
     704           1 : sal_Bool SAL_CALL ScFunctionListObj::hasElements() throw(uno::RuntimeException, std::exception)
     705             : {
     706           1 :     SolarMutexGuard aGuard;
     707           1 :     return ( getCount() > 0 );
     708             : }
     709             : 
     710           1 : uno::Sequence<OUString> SAL_CALL ScFunctionListObj::getElementNames() throw(uno::RuntimeException, std::exception)
     711             : {
     712           1 :     SolarMutexGuard aGuard;
     713           1 :     const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
     714           1 :     if ( pFuncList )
     715             :     {
     716           1 :         sal_uInt32 nCount = pFuncList->GetCount();
     717           1 :         uno::Sequence<OUString> aSeq(nCount);
     718           1 :         OUString* pAry = aSeq.getArray();
     719         482 :         for (sal_uInt32 nIndex=0; nIndex<nCount; ++nIndex)
     720             :         {
     721         481 :             const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
     722         481 :             if ( pDesc && pDesc->pFuncName )
     723         481 :                 pAry[nIndex] = *pDesc->pFuncName;
     724             :         }
     725           1 :         return aSeq;
     726             :     }
     727           0 :     return uno::Sequence<OUString>(0);
     728             : }
     729             : 
     730           2 : sal_Bool SAL_CALL ScFunctionListObj::hasByName( const OUString& aName )
     731             :                                         throw(uno::RuntimeException, std::exception)
     732             : {
     733           2 :     SolarMutexGuard aGuard;
     734           2 :     const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
     735           2 :     if ( pFuncList )
     736             :     {
     737           2 :         sal_uInt32 nCount = pFuncList->GetCount();
     738         483 :         for (sal_uInt32 nIndex=0; nIndex<nCount; ++nIndex)
     739             :         {
     740         482 :             const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
     741             :             //! Case-insensitiv ???
     742         482 :             if ( pDesc && pDesc->pFuncName && aName == *pDesc->pFuncName )
     743           1 :                 return sal_True;
     744             :         }
     745             :     }
     746           1 :     return false;
     747         156 : }
     748             : 
     749             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11