LCOV - code coverage report
Current view: top level - scaddins/source/analysis - analysis.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 220 548 40.1 %
Date: 2015-06-13 12:38:46 Functions: 45 101 44.6 %
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 "analysis.hxx"
      21             : #include "analysis.hrc"
      22             : #include "bessel.hxx"
      23             : #include <cppuhelper/factory.hxx>
      24             : #include <comphelper/processfactory.hxx>
      25             : #include <cppuhelper/supportsservice.hxx>
      26             : #include <formula/random.hxx>
      27             : #include <osl/diagnose.h>
      28             : #include <rtl/ustrbuf.hxx>
      29             : #include <rtl/math.hxx>
      30             : #include <sal/macros.h>
      31             : #include <string.h>
      32             : #include <tools/resmgr.hxx>
      33             : #include <tools/rcid.h>
      34             : #include <cmath>
      35             : 
      36             : #define ADDIN_SERVICE               "com.sun.star.sheet.AddIn"
      37             : #define MY_SERVICE                  "com.sun.star.sheet.addin.Analysis"
      38             : #define MY_IMPLNAME                 "com.sun.star.sheet.addin.AnalysisImpl"
      39             : 
      40             : using namespace                 ::com::sun::star;
      41             : using namespace sca::analysis;
      42             : using namespace std;
      43             : 
      44          20 : extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL analysis_component_getFactory(
      45             :     const sal_Char* pImplName, void* pServiceManager, void* /*pRegistryKey*/ )
      46             : {
      47          20 :     void* pRet = 0;
      48             : 
      49          20 :     if( pServiceManager && OUString::createFromAscii( pImplName ) == AnalysisAddIn::getImplementationName_Static() )
      50             :     {
      51             :         uno::Reference< lang::XSingleServiceFactory >  xFactory( cppu::createOneInstanceFactory(
      52             :                 static_cast< lang::XMultiServiceFactory* >( pServiceManager ),
      53             :                 AnalysisAddIn::getImplementationName_Static(),
      54             :                 AnalysisAddIn_CreateInstance,
      55          20 :                 AnalysisAddIn::getSupportedServiceNames_Static() ) );
      56             : 
      57          20 :         if( xFactory.is() )
      58             :         {
      59          20 :             xFactory->acquire();
      60          20 :             pRet = xFactory.get();
      61          20 :         }
      62             :     }
      63             : 
      64          20 :     return pRet;
      65             : }
      66             : 
      67       38700 : ResMgr& AnalysisAddIn::GetResMgr() throw( uno::RuntimeException )
      68             : {
      69       38700 :     if( !pResMgr )
      70             :     {
      71           0 :         InitData();     // try to get resource manager
      72             : 
      73           0 :         if( !pResMgr )
      74           0 :             throw uno::RuntimeException();
      75             :     }
      76             : 
      77       38700 :     return *pResMgr;
      78             : }
      79             : 
      80        1818 : OUString AnalysisAddIn::GetDisplFuncStr( sal_uInt16 nFuncNum ) throw( uno::RuntimeException )
      81             : {
      82        1818 :     return AnalysisRscStrLoader( RID_ANALYSIS_FUNCTION_NAMES, nFuncNum, GetResMgr() ).GetString();
      83             : }
      84             : 
      85       12294 : class AnalysisResourcePublisher : public Resource
      86             : {
      87             : public:
      88       12294 :                     AnalysisResourcePublisher( const AnalysisResId& rId ) : Resource( rId ) {}
      89       12294 :     bool            IsAvailableRes( const ResId& rId ) const { return Resource::IsAvailableRes( rId ); }
      90       12294 :     void            FreeResource() { Resource::FreeResource(); }
      91             : };
      92             : 
      93       12294 : class AnalysisFuncRes : public Resource
      94             : {
      95             : public:
      96             :     AnalysisFuncRes( ResId& rRes, ResMgr& rResMgr, sal_uInt16 nInd, OUString& rRet );
      97             : };
      98             : 
      99       12294 : AnalysisFuncRes::AnalysisFuncRes( ResId& rRes, ResMgr& rResMgr, sal_uInt16 nInd, OUString& rRet ) : Resource( rRes )
     100             : {
     101       12294 :     rRet = AnalysisResId(nInd, rResMgr).toString();
     102             : 
     103       12294 :     FreeResource();
     104       12294 : }
     105             : 
     106       12294 : OUString AnalysisAddIn::GetFuncDescrStr( sal_uInt16 nResId, sal_uInt16 nStrIndex ) throw( uno::RuntimeException )
     107             : {
     108       12294 :     OUString                      aRet;
     109       24588 :     AnalysisResourcePublisher   aResPubl( AnalysisResId( RID_ANALYSIS_FUNCTION_DESCRIPTIONS, GetResMgr() ) );
     110       12294 :     AnalysisResId               aRes( nResId, GetResMgr() );
     111       12294 :     aRes.SetRT( RSC_RESOURCE );
     112       12294 :     if( aResPubl.IsAvailableRes( aRes ) )
     113             :     {
     114       12294 :         AnalysisFuncRes         aSubRes( aRes, GetResMgr(), nStrIndex, aRet );
     115             :     }
     116             : 
     117       12294 :     aResPubl.FreeResource();
     118             : 
     119       24588 :     return aRet;
     120             : }
     121             : 
     122          18 : void AnalysisAddIn::InitData()
     123             : {
     124          18 :     delete pResMgr;
     125          18 :     pResMgr = ResMgr::CreateResMgr("analysis", LanguageTag(aFuncLoc));
     126             : 
     127          18 :     delete pFD;
     128             : 
     129          18 :     if( pResMgr )
     130          18 :         pFD = new FuncDataList( *pResMgr );
     131             :     else
     132           0 :         pFD = NULL;
     133             : 
     134          18 :     if( pDefLocales )
     135             :     {
     136           0 :         delete pDefLocales;
     137           0 :         pDefLocales = NULL;
     138             :     }
     139          18 : }
     140             : 
     141          20 : AnalysisAddIn::AnalysisAddIn( const uno::Reference< uno::XComponentContext >& xContext ) :
     142             :     pDefLocales( NULL ),
     143             :     pFD( NULL ),
     144             :     pFactDoubles( NULL ),
     145             :     pCDL( NULL ),
     146             :     pResMgr( NULL ),
     147          21 :     aAnyConv( xContext )
     148             : {
     149          19 : }
     150             : 
     151          33 : AnalysisAddIn::~AnalysisAddIn()
     152             : {
     153          11 :     delete pResMgr;
     154          11 :     delete pCDL;
     155          11 :     delete[] pFactDoubles;
     156          11 :     delete pFD;
     157          11 :     delete[] pDefLocales;
     158          22 : }
     159             : 
     160          72 : sal_Int32 AnalysisAddIn::getDateMode(
     161             :         const uno::Reference< beans::XPropertySet >& xPropSet,
     162             :         const uno::Any& rAny ) throw( uno::RuntimeException, lang::IllegalArgumentException )
     163             : {
     164          72 :     sal_Int32 nMode = aAnyConv.getInt32( xPropSet, rAny, 0 );
     165          72 :     if( (nMode < 0) || (nMode > 4) )
     166           0 :         throw lang::IllegalArgumentException();
     167          72 :     return nMode;
     168             : }
     169             : 
     170             : #define MAXFACTDOUBLE   300
     171             : 
     172           9 : double AnalysisAddIn::FactDouble( sal_Int32 nNum ) throw( uno::RuntimeException, lang::IllegalArgumentException )
     173             : {
     174           9 :     if( nNum < 0 || nNum > MAXFACTDOUBLE )
     175           0 :         throw lang::IllegalArgumentException();
     176             : 
     177           9 :     if( !pFactDoubles )
     178             :     {
     179           1 :         pFactDoubles = new double[ MAXFACTDOUBLE + 1 ];
     180             : 
     181           1 :         pFactDoubles[ 0 ] = 1.0;    // by default
     182             : 
     183           1 :         double      fOdd = 1.0;
     184           1 :         double      fEven = 2.0;
     185             : 
     186           1 :         pFactDoubles[ 1 ] = fOdd;
     187           1 :         pFactDoubles[ 2 ] = fEven;
     188             : 
     189           1 :         bool    bOdd = true;
     190             : 
     191         299 :         for( sal_uInt16 nCnt = 3 ; nCnt <= MAXFACTDOUBLE ; nCnt++ )
     192             :         {
     193         298 :             if( bOdd )
     194             :             {
     195         149 :                 fOdd *= nCnt;
     196         149 :                 pFactDoubles[ nCnt ] = fOdd;
     197             :             }
     198             :             else
     199             :             {
     200         149 :                 fEven *= nCnt;
     201         149 :                 pFactDoubles[ nCnt ] = fEven;
     202             :             }
     203             : 
     204         298 :             bOdd = !bOdd;
     205             : 
     206             :         }
     207             :     }
     208             : 
     209           9 :     return pFactDoubles[ nNum ];
     210             : }
     211             : 
     212          41 : OUString AnalysisAddIn::getImplementationName_Static()
     213             : {
     214          41 :     return OUString( MY_IMPLNAME );
     215             : }
     216             : 
     217          21 : uno::Sequence< OUString > AnalysisAddIn::getSupportedServiceNames_Static()
     218             : {
     219          21 :     uno::Sequence< OUString >   aRet(2);
     220          21 :     OUString*         pArray = aRet.getArray();
     221          21 :     pArray[0] = ADDIN_SERVICE;
     222          21 :     pArray[1] = MY_SERVICE;
     223          21 :     return aRet;
     224             : }
     225             : 
     226          20 : uno::Reference< uno::XInterface > SAL_CALL AnalysisAddIn_CreateInstance(
     227             :         const uno::Reference< lang::XMultiServiceFactory >& xServiceFact )
     228             : {
     229          20 :     return static_cast<cppu::OWeakObject*>(new AnalysisAddIn( comphelper::getComponentContext(xServiceFact) ));
     230             : }
     231             : 
     232             : // XServiceName
     233          18 : OUString SAL_CALL AnalysisAddIn::getServiceName() throw( uno::RuntimeException, std::exception )
     234             : {
     235             :     // name of specific AddIn service
     236          18 :     return OUString( MY_SERVICE );
     237             : }
     238             : 
     239             : // XServiceInfo
     240           1 : OUString SAL_CALL AnalysisAddIn::getImplementationName() throw( uno::RuntimeException, std::exception )
     241             : {
     242           1 :     return getImplementationName_Static();
     243             : }
     244             : 
     245           0 : sal_Bool SAL_CALL AnalysisAddIn::supportsService( const OUString& aName ) throw( uno::RuntimeException, std::exception )
     246             : {
     247           0 :     return cppu::supportsService(this, aName);
     248             : }
     249             : 
     250           1 : uno::Sequence< OUString > SAL_CALL AnalysisAddIn::getSupportedServiceNames() throw( uno::RuntimeException, std::exception )
     251             : {
     252           1 :     return getSupportedServiceNames_Static();
     253             : }
     254             : 
     255             : // XLocalizable
     256          18 : void SAL_CALL AnalysisAddIn::setLocale( const lang::Locale& eLocale ) throw( uno::RuntimeException, std::exception )
     257             : {
     258          18 :     aFuncLoc = eLocale;
     259             : 
     260          18 :     InitData();     // change of locale invalidates resources!
     261          18 : }
     262             : 
     263           0 : lang::Locale SAL_CALL AnalysisAddIn::getLocale() throw( uno::RuntimeException, std::exception )
     264             : {
     265           0 :     return aFuncLoc;
     266             : }
     267             : 
     268             : // XAddIn
     269           0 : OUString SAL_CALL AnalysisAddIn::getProgrammaticFuntionName( const OUString& ) throw( uno::RuntimeException, std::exception )
     270             : {
     271             :     //  not used by calc
     272             :     //  (but should be implemented for other uses of the AddIn service)
     273             : 
     274           0 :     return OUString();
     275             : }
     276             : 
     277        1818 : OUString SAL_CALL AnalysisAddIn::getDisplayFunctionName( const OUString& aProgrammaticName ) throw( uno::RuntimeException, std::exception )
     278             : {
     279        1818 :     OUString          aRet;
     280             : 
     281        1818 :     const FuncData* p = pFD->Get( aProgrammaticName );
     282        1818 :     if( p )
     283             :     {
     284        1818 :         aRet = GetDisplFuncStr( p->GetUINameID() );
     285        1818 :         if( p->IsDouble() )
     286         216 :             aRet += "_ADD";
     287             :     }
     288             :     else
     289             :     {
     290           0 :         aRet = "UNKNOWNFUNC_" + aProgrammaticName;
     291             :     }
     292             : 
     293        1818 :     return aRet;
     294             : }
     295             : 
     296        1818 : OUString SAL_CALL AnalysisAddIn::getFunctionDescription( const OUString& aProgrammaticName ) throw( uno::RuntimeException, std::exception )
     297             : {
     298        1818 :     OUString          aRet;
     299             : 
     300        1818 :     const FuncData* p = pFD->Get( aProgrammaticName );
     301        1818 :     if( p )
     302        1818 :         aRet = GetFuncDescrStr( p->GetDescrID(), 1 );
     303             : 
     304        1818 :     return aRet;
     305             : }
     306             : 
     307        5238 : OUString SAL_CALL AnalysisAddIn::getDisplayArgumentName( const OUString& aName, sal_Int32 nArg ) throw( uno::RuntimeException, std::exception )
     308             : {
     309        5238 :     OUString          aRet;
     310             : 
     311        5238 :     const FuncData* p = pFD->Get( aName );
     312        5238 :     if( p && nArg <= 0xFFFF )
     313             :     {
     314        5238 :         sal_uInt16  nStr = p->GetStrIndex( sal_uInt16( nArg ) );
     315        5238 :         if( nStr )
     316        5238 :             aRet = GetFuncDescrStr( p->GetDescrID(), nStr );
     317             :         else
     318           0 :             aRet = "internal";
     319             :     }
     320             : 
     321        5238 :     return aRet;
     322             : }
     323             : 
     324        5238 : OUString SAL_CALL AnalysisAddIn::getArgumentDescription( const OUString& aName, sal_Int32 nArg ) throw( uno::RuntimeException, std::exception )
     325             : {
     326        5238 :     OUString          aRet;
     327             : 
     328        5238 :     const FuncData* p = pFD->Get( aName );
     329        5238 :     if( p && nArg <= 0xFFFF )
     330             :     {
     331        5238 :         sal_uInt16  nStr = p->GetStrIndex( sal_uInt16( nArg ) );
     332        5238 :         if( nStr )
     333        5238 :             aRet = GetFuncDescrStr( p->GetDescrID(), nStr + 1 );
     334             :         else
     335           0 :             aRet = "for internal use only";
     336             :     }
     337             : 
     338        5238 :     return aRet;
     339             : }
     340             : 
     341             : static const char pDefCatName[] = "Add-In";
     342             : 
     343        1818 : OUString SAL_CALL AnalysisAddIn::getProgrammaticCategoryName( const OUString& aName ) throw( uno::RuntimeException, std::exception )
     344             : {
     345             :     //  return non-translated strings
     346             :     //  return OUString( "Add-In" );
     347        1818 :     const FuncData*     p = pFD->Get( aName );
     348        1818 :     OUString              aRet;
     349        1818 :     if( p )
     350             :     {
     351        1818 :         switch( p->GetCategory() )
     352             :         {
     353         108 :             case FDCat_DateTime:    aRet = "Date&Time";         break;
     354         666 :             case FDCat_Finance:     aRet = "Financial";         break;
     355          36 :             case FDCat_Inf:         aRet = "Information";       break;
     356         144 :             case FDCat_Math:        aRet = "Mathematical";      break;
     357         864 :             case FDCat_Tech:        aRet = "Technical";         break;
     358             :             default:
     359           0 :                                     aRet = pDefCatName;         break;
     360             :         }
     361             :     }
     362             :     else
     363           0 :         aRet = pDefCatName;
     364             : 
     365        1818 :     return aRet;
     366             : }
     367             : 
     368           0 : OUString SAL_CALL AnalysisAddIn::getDisplayCategoryName( const OUString& aProgrammaticFunctionName ) throw( uno::RuntimeException, std::exception )
     369             : {
     370             :     //  return translated strings, not used for predefined categories
     371             :     //  return OUString( "Add-In" );
     372           0 :     const FuncData*     p = pFD->Get( aProgrammaticFunctionName );
     373           0 :     OUString              aRet;
     374           0 :     if( p )
     375             :     {
     376           0 :         switch( p->GetCategory() )
     377             :         {
     378           0 :             case FDCat_DateTime:    aRet = "Date&Time";         break;
     379           0 :             case FDCat_Finance:     aRet = "Financial";         break;
     380           0 :             case FDCat_Inf:         aRet = "Information";       break;
     381           0 :             case FDCat_Math:        aRet = "Mathematical";      break;
     382           0 :             case FDCat_Tech:        aRet = "Technical";         break;
     383             :             default:
     384           0 :                                     aRet = pDefCatName;         break;
     385             :         }
     386             :     }
     387             :     else
     388           0 :         aRet = pDefCatName;
     389             : 
     390           0 :     return aRet;
     391             : }
     392             : 
     393             : static const sal_Char*      pLang[] = { "de", "en" };
     394             : static const sal_Char*      pCoun[] = { "DE", "US" };
     395             : static const sal_uInt32     nNumOfLoc = SAL_N_ELEMENTS(pLang);
     396             : 
     397           2 : void AnalysisAddIn::InitDefLocales()
     398             : {
     399           2 :     pDefLocales = new lang::Locale[ nNumOfLoc ];
     400             : 
     401           6 :     for( sal_uInt32 n = 0 ; n < nNumOfLoc ; n++ )
     402             :     {
     403           4 :         pDefLocales[ n ].Language = OUString::createFromAscii( pLang[ n ] );
     404           4 :         pDefLocales[ n ].Country = OUString::createFromAscii( pCoun[ n ] );
     405             :     }
     406           2 : }
     407             : 
     408         404 : inline const lang::Locale& AnalysisAddIn::GetLocale( sal_uInt32 nInd )
     409             : {
     410         404 :     if( !pDefLocales )
     411           2 :         InitDefLocales();
     412             : 
     413         404 :     if( nInd < sizeof( pLang ) )
     414         404 :         return pDefLocales[ nInd ];
     415             :     else
     416           0 :         return aFuncLoc;
     417             : }
     418             : 
     419         202 : uno::Sequence< sheet::LocalizedName > SAL_CALL AnalysisAddIn::getCompatibilityNames( const OUString& aProgrammaticName ) throw( uno::RuntimeException, std::exception )
     420             : {
     421         202 :     const FuncData*             p = pFD->Get( aProgrammaticName );
     422             : 
     423         202 :     if( !p )
     424           0 :         return uno::Sequence< sheet::LocalizedName >( 0 );
     425             : 
     426         202 :     const std::vector<OUString>& r = p->GetCompNameList();
     427         202 :     sal_uInt32                   nCount = r.size();
     428             : 
     429         202 :     uno::Sequence< sheet::LocalizedName >                aRet( nCount );
     430             : 
     431         202 :     sheet::LocalizedName*  pArray = aRet.getArray();
     432             : 
     433         606 :     for( sal_uInt32 n = 0 ; n < nCount ; n++ )
     434             :     {
     435         404 :         pArray[ n ] = sheet::LocalizedName( GetLocale( n ), r[n] );
     436             :     }
     437             : 
     438         202 :     return aRet;
     439             : }
     440             : 
     441             : // XAnalysis
     442             : /** Workday */
     443           0 : sal_Int32 SAL_CALL AnalysisAddIn::getWorkday( const uno::Reference< beans::XPropertySet >& xOptions,
     444             :     sal_Int32 nDate, sal_Int32 nDays, const uno::Any& aHDay ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     445             : {
     446           0 :     if( !nDays )
     447           0 :         return nDate;
     448             : 
     449           0 :     sal_Int32                   nNullDate = GetNullDate( xOptions );
     450             : 
     451           0 :     SortedIndividualInt32List   aSrtLst;
     452             : 
     453           0 :     aSrtLst.InsertHolidayList( aAnyConv, xOptions, aHDay, nNullDate, false );
     454             : 
     455           0 :     sal_Int32                   nActDate = nDate + nNullDate;
     456             : 
     457           0 :     if( nDays > 0 )
     458             :     {
     459           0 :         if( GetDayOfWeek( nActDate ) == 5 )
     460             :             // when starting on Saturday, assuming we're starting on Sunday to get the jump over the weekend
     461           0 :             nActDate++;
     462             : 
     463           0 :         while( nDays )
     464             :         {
     465           0 :             nActDate++;
     466             : 
     467           0 :             if( GetDayOfWeek( nActDate ) < 5 )
     468             :             {
     469           0 :                 if( !aSrtLst.Find( nActDate ) )
     470           0 :                     nDays--;
     471             :             }
     472             :             else
     473           0 :                 nActDate++;     // jump over weekend
     474             :         }
     475             :     }
     476             :     else
     477             :     {
     478           0 :         if( GetDayOfWeek( nActDate ) == 6 )
     479             :             // when starting on Sunday, assuming we're starting on Saturday to get the jump over the weekend
     480           0 :             nActDate--;
     481             : 
     482           0 :         while( nDays )
     483             :         {
     484           0 :             nActDate--;
     485             : 
     486           0 :             if( GetDayOfWeek( nActDate ) < 5 )
     487             :             {
     488           0 :                 if( !aSrtLst.Find( nActDate ) )
     489           0 :                     nDays++;
     490             :             }
     491             :             else
     492           0 :                 nActDate--;     // jump over weekend
     493             :         }
     494             :     }
     495             : 
     496           0 :     return nActDate - nNullDate;
     497             : }
     498             : 
     499             : /** Yearfrac */
     500           0 : double SAL_CALL AnalysisAddIn::getYearfrac( const uno::Reference< beans::XPropertySet >& xOpt,
     501             :     sal_Int32 nStartDate, sal_Int32 nEndDate, const uno::Any& rMode ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     502             : {
     503           0 :     double fRet = GetYearFrac( xOpt, nStartDate, nEndDate, getDateMode( xOpt, rMode ) );
     504           0 :     RETURN_FINITE( fRet );
     505             : }
     506             : 
     507           0 : sal_Int32 SAL_CALL AnalysisAddIn::getEdate( const uno::Reference< beans::XPropertySet >& xOpt, sal_Int32 nStartDate, sal_Int32 nMonths ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     508             : {
     509           0 :     sal_Int32 nNullDate = GetNullDate( xOpt );
     510           0 :     ScaDate aDate( nNullDate, nStartDate, 5 );
     511           0 :     aDate.addMonths( nMonths );
     512           0 :     return aDate.getDate( nNullDate );
     513             : }
     514             : 
     515           0 : sal_Int32 SAL_CALL AnalysisAddIn::getWeeknum( const uno::Reference< beans::XPropertySet >& xOpt, sal_Int32 nDate, sal_Int32 nMode ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     516             : {
     517           0 :     nDate += GetNullDate( xOpt );
     518             : 
     519             :     sal_uInt16  nDay, nMonth, nYear;
     520           0 :     DaysToDate( nDate, nDay, nMonth, nYear );
     521             : 
     522           0 :     sal_Int32   nFirstInYear = DateToDays( 1, 1, nYear );
     523           0 :     sal_uInt16  nFirstDayInYear = GetDayOfWeek( nFirstInYear );
     524             : 
     525           0 :     return ( nDate - nFirstInYear + ( ( nMode == 1 )? ( nFirstDayInYear + 1 ) % 7 : nFirstDayInYear ) ) / 7 + 1;
     526             : }
     527             : 
     528           0 : sal_Int32 SAL_CALL AnalysisAddIn::getEomonth( const uno::Reference< beans::XPropertySet >& xOpt, sal_Int32 nDate, sal_Int32 nMonths ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     529             : {
     530           0 :     sal_Int32   nNullDate = GetNullDate( xOpt );
     531           0 :     nDate += nNullDate;
     532             :     sal_uInt16  nDay, nMonth, nYear;
     533           0 :     DaysToDate( nDate, nDay, nMonth, nYear );
     534             : 
     535           0 :     sal_Int32   nNewMonth = nMonth + nMonths;
     536             : 
     537           0 :     if( nNewMonth > 12 )
     538             :     {
     539           0 :         nYear = sal::static_int_cast<sal_uInt16>( nYear + ( nNewMonth / 12 ) );
     540           0 :         nNewMonth %= 12;
     541             :     }
     542           0 :     else if( nNewMonth < 1 )
     543             :     {
     544           0 :         nNewMonth = -nNewMonth;
     545           0 :         nYear = sal::static_int_cast<sal_uInt16>( nYear - ( nNewMonth / 12 ) );
     546           0 :         nYear--;
     547           0 :         nNewMonth %= 12;
     548           0 :         nNewMonth = 12 - nNewMonth;
     549             :     }
     550             : 
     551           0 :     return DateToDays( DaysInMonth( sal_uInt16( nNewMonth ), nYear ), sal_uInt16( nNewMonth ), nYear ) - nNullDate;
     552             : }
     553             : 
     554           0 : sal_Int32 SAL_CALL AnalysisAddIn::getNetworkdays( const uno::Reference< beans::XPropertySet >& xOpt,
     555             :         sal_Int32 nStartDate, sal_Int32 nEndDate, const uno::Any& aHDay ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     556             : {
     557           0 :     sal_Int32                   nNullDate = GetNullDate( xOpt );
     558             : 
     559           0 :     SortedIndividualInt32List   aSrtLst;
     560             : 
     561           0 :     aSrtLst.InsertHolidayList( aAnyConv, xOpt, aHDay, nNullDate, false );
     562             : 
     563           0 :     sal_Int32                   nActDate = nStartDate + nNullDate;
     564           0 :     sal_Int32                   nStopDate = nEndDate + nNullDate;
     565           0 :     sal_Int32                   nCnt = 0;
     566             : 
     567           0 :     if( nActDate <= nStopDate )
     568             :     {
     569           0 :         while( nActDate <= nStopDate )
     570             :         {
     571           0 :             if( GetDayOfWeek( nActDate ) < 5 && !aSrtLst.Find( nActDate ) )
     572           0 :                 nCnt++;
     573             : 
     574           0 :             nActDate++;
     575             :         }
     576             :     }
     577             :     else
     578             :     {
     579           0 :         while( nActDate >= nStopDate )
     580             :         {
     581           0 :             if( GetDayOfWeek( nActDate ) < 5 && !aSrtLst.Find( nActDate ) )
     582           0 :                 nCnt--;
     583             : 
     584           0 :             nActDate--;
     585             :         }
     586             :     }
     587             : 
     588           0 :     return nCnt;
     589             : }
     590             : 
     591           0 : sal_Int32 SAL_CALL AnalysisAddIn::getIseven( sal_Int32 nVal ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     592             : {
     593           0 :     return ( nVal & 0x00000001 )? 0 : 1;
     594             : }
     595             : 
     596           0 : sal_Int32 SAL_CALL AnalysisAddIn::getIsodd( sal_Int32 nVal ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     597             : {
     598           0 :     return ( nVal & 0x00000001 )? 1 : 0;
     599             : }
     600             : 
     601             : double SAL_CALL
     602           3 : AnalysisAddIn::getMultinomial( const uno::Reference< beans::XPropertySet >& xOpt, const uno::Sequence< uno::Sequence< sal_Int32 > >& aVLst,
     603             :                                const uno::Sequence< uno::Any >& aOptVLst ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     604             : {
     605           3 :     ScaDoubleListGE0 aValList;
     606             : 
     607           3 :     aValList.Append( aVLst );
     608           3 :     aValList.Append( aAnyConv, xOpt, aOptVLst );
     609             : 
     610           3 :     if( aValList.Count() == 0 )
     611           0 :         return 0.0;
     612             : 
     613           3 :     double nZ = 0;
     614           3 :     double fRet = 1.0;
     615             : 
     616           9 :     for( sal_uInt32 i = 0; i < aValList.Count(); ++i )
     617             :     {
     618           6 :         const double d = aValList.Get(i);
     619           6 :         double n = (d >= 0.0) ? rtl::math::approxFloor( d ) : rtl::math::approxCeil( d );
     620           6 :         if ( n < 0.0 )
     621           0 :             throw lang::IllegalArgumentException();
     622             : 
     623           6 :         if( n > 0.0 )
     624             :         {
     625           6 :             nZ += n;
     626           6 :             fRet *= BinomialCoefficient(nZ, n);
     627             :         }
     628             :     }
     629           3 :     RETURN_FINITE( fRet );
     630             : }
     631             : 
     632           3 : double SAL_CALL AnalysisAddIn::getSeriessum( double fX, double fN, double fM, const uno::Sequence< uno::Sequence< double > >& aCoeffList ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     633             : {
     634           3 :     double                          fRet = 0.0;
     635             : 
     636             :     // #i32269# 0^0 is undefined, Excel returns #NUM! error
     637           3 :     if( fX == 0.0 && fN == 0 )
     638           0 :         throw uno::RuntimeException();
     639             : 
     640           3 :     if( fX != 0.0 )
     641             :     {
     642             :         sal_Int32       n1, n2;
     643           3 :         sal_Int32       nE1 = aCoeffList.getLength();
     644             :         sal_Int32       nE2;
     645             : 
     646           6 :         for( n1 = 0 ; n1 < nE1 ; n1++ )
     647             :         {
     648           3 :             const uno::Sequence< double >&    rList = aCoeffList[ n1 ];
     649           3 :             nE2 = rList.getLength();
     650           3 :             const double*           pList = rList.getConstArray();
     651             : 
     652           6 :             for( n2 = 0 ; n2 < nE2 ; n2++ )
     653             :             {
     654           3 :                 fRet += pList[ n2 ] * pow( fX, fN );
     655             : 
     656           3 :                 fN += fM;
     657             :             }
     658             :         }
     659             :     }
     660             : 
     661           3 :     RETURN_FINITE( fRet );
     662             : }
     663             : 
     664           6 : double SAL_CALL AnalysisAddIn::getQuotient( double fNum, double fDenom ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     665             : {
     666             :     double fRet;
     667           6 :     if( (fNum < 0) != (fDenom < 0) )
     668           0 :         fRet = ::rtl::math::approxCeil( fNum / fDenom );
     669             :     else
     670           6 :         fRet = ::rtl::math::approxFloor( fNum / fDenom );
     671           6 :     RETURN_FINITE( fRet );
     672             : }
     673             : 
     674           6 : double SAL_CALL AnalysisAddIn::getMround( double fNum, double fMult ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     675             : {
     676           6 :     if( fMult == 0.0 )
     677           0 :         return fMult;
     678             : 
     679           6 :     double fRet = fMult * ::rtl::math::round( fNum / fMult );
     680           6 :     RETURN_FINITE( fRet );
     681             : }
     682             : 
     683           3 : double SAL_CALL AnalysisAddIn::getSqrtpi( double fNum ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     684             : {
     685           3 :     double fRet = sqrt( fNum * PI );
     686           3 :     RETURN_FINITE( fRet );
     687             : }
     688             : 
     689           0 : double SAL_CALL AnalysisAddIn::getRandbetween( double fMin, double fMax ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     690             : {
     691           0 :     fMin = ::rtl::math::round( fMin, 0, rtl_math_RoundingMode_Up );
     692           0 :     fMax = ::rtl::math::round( fMax, 0, rtl_math_RoundingMode_Up );
     693           0 :     if( fMin > fMax )
     694           0 :         throw lang::IllegalArgumentException();
     695             : 
     696           0 :     double fRet = floor(formula::rng::fRandom(fMin, nextafter(fMax+1, -DBL_MAX)));
     697           0 :     RETURN_FINITE( fRet );
     698             : }
     699             : 
     700           0 : double SAL_CALL AnalysisAddIn::getGcd( const uno::Reference< beans::XPropertySet >& xOpt, const uno::Sequence< uno::Sequence< double > >& aVLst, const uno::Sequence< uno::Any >& aOptVLst ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     701             : {
     702           0 :     ScaDoubleListGT0 aValList;
     703             : 
     704           0 :     aValList.Append( aVLst );
     705           0 :     aValList.Append( aAnyConv, xOpt, aOptVLst );
     706             : 
     707           0 :     if( aValList.Count() == 0 )
     708           0 :         return 0.0;
     709             : 
     710           0 :     double          f = aValList.Get(0);
     711           0 :     for( sal_uInt32 i = 1; i < aValList.Count(); ++i )
     712             :     {
     713           0 :         f = GetGcd( aValList.Get(i), f );
     714             :     }
     715             : 
     716           0 :     RETURN_FINITE( f );
     717             : }
     718             : 
     719           0 : double SAL_CALL AnalysisAddIn::getLcm( const uno::Reference< beans::XPropertySet >& xOpt, const uno::Sequence< uno::Sequence< double > >& aVLst, const uno::Sequence< uno::Any >& aOptVLst ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     720             : {
     721           0 :     ScaDoubleListGE0 aValList;
     722             : 
     723           0 :     aValList.Append( aVLst );
     724           0 :     aValList.Append( aAnyConv, xOpt, aOptVLst );
     725             : 
     726           0 :     if( aValList.Count() == 0 )
     727           0 :         return 0.0;
     728             : 
     729           0 :     double          f = aValList.Get(0);
     730             : 
     731           0 :     if( f == 0.0 )
     732           0 :         return f;
     733             : 
     734           0 :     for( sal_uInt32 i = 1; i < aValList.Count(); ++i )
     735             :     {
     736           0 :         double      fTmp = aValList.Get(i);
     737           0 :         if( f == 0.0 )
     738           0 :             return f;
     739             :         else
     740           0 :             f = fTmp * f / GetGcd( fTmp, f );
     741             :     }
     742             : 
     743           0 :     RETURN_FINITE( f );
     744             : }
     745             : 
     746           0 : double SAL_CALL AnalysisAddIn::getBesseli( double fNum, sal_Int32 nOrder ) throw( uno::RuntimeException, lang::IllegalArgumentException, sheet::NoConvergenceException, std::exception )
     747             : {
     748           0 :     double fRet = sca::analysis::BesselI( fNum, nOrder );
     749           0 :     RETURN_FINITE( fRet );
     750             : }
     751             : 
     752           0 : double SAL_CALL AnalysisAddIn::getBesselj( double fNum, sal_Int32 nOrder ) throw( uno::RuntimeException, lang::IllegalArgumentException, sheet::NoConvergenceException, std::exception )
     753             : {
     754           0 :     double fRet = sca::analysis::BesselJ( fNum, nOrder );
     755           0 :     RETURN_FINITE( fRet );
     756             : }
     757             : 
     758           0 : double SAL_CALL AnalysisAddIn::getBesselk( double fNum, sal_Int32 nOrder ) throw( uno::RuntimeException, lang::IllegalArgumentException, sheet::NoConvergenceException, std::exception )
     759             : {
     760           0 :     if( nOrder < 0 || fNum <= 0.0 )
     761           0 :         throw lang::IllegalArgumentException();
     762             : 
     763           0 :     double fRet = sca::analysis::BesselK( fNum, nOrder );
     764           0 :     RETURN_FINITE( fRet );
     765             : }
     766             : 
     767           0 : double SAL_CALL AnalysisAddIn::getBessely( double fNum, sal_Int32 nOrder ) throw( uno::RuntimeException, lang::IllegalArgumentException, sheet::NoConvergenceException, std::exception )
     768             : {
     769           0 :     if( nOrder < 0 || fNum <= 0.0 )
     770           0 :         throw lang::IllegalArgumentException();
     771             : 
     772           0 :     double fRet = sca::analysis::BesselY( fNum, nOrder );
     773           0 :     RETURN_FINITE( fRet );
     774             : }
     775             : 
     776             : const double    SCA_MAX2        = 511.0;            // min. val for binary numbers (9 bits + sign)
     777          20 : const double    SCA_MIN2        = -SCA_MAX2-1.0;    // min. val for binary numbers (9 bits + sign)
     778             : const double    SCA_MAX8        = 536870911.0;      // max. val for octal numbers (29 bits + sign)
     779          20 : const double    SCA_MIN8        = -SCA_MAX8-1.0;    // min. val for octal numbers (29 bits + sign)
     780             : const double    SCA_MAX16       = 549755813888.0;   // max. val for hexadecimal numbers (39 bits + sign)
     781          20 : const double    SCA_MIN16       = -SCA_MAX16-1.0;   // min. val for hexadecimal numbers (39 bits + sign)
     782             : const sal_Int32 SCA_MAXPLACES   = 10;               // max. number of places
     783             : 
     784           0 : OUString SAL_CALL AnalysisAddIn::getBin2Oct( const uno::Reference< beans::XPropertySet >& xOpt, const OUString& aNum, const uno::Any& rPlaces ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     785             : {
     786           0 :     double fVal = ConvertToDec( aNum, 2, SCA_MAXPLACES );
     787           0 :     sal_Int32 nPlaces = 0;
     788           0 :     bool bUsePlaces = aAnyConv.getInt32( nPlaces, xOpt, rPlaces );
     789           0 :     return ConvertFromDec( fVal, SCA_MIN8, SCA_MAX8, 8, nPlaces, SCA_MAXPLACES, bUsePlaces );
     790             : }
     791             : 
     792           0 : double SAL_CALL AnalysisAddIn::getBin2Dec( const OUString& aNum ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     793             : {
     794           0 :     double fRet = ConvertToDec( aNum, 2, SCA_MAXPLACES );
     795           0 :     RETURN_FINITE( fRet );
     796             : }
     797             : 
     798           0 : OUString SAL_CALL AnalysisAddIn::getBin2Hex( const uno::Reference< beans::XPropertySet >& xOpt, const OUString& aNum, const uno::Any& rPlaces ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     799             : {
     800           0 :     double fVal = ConvertToDec( aNum, 2, SCA_MAXPLACES );
     801           0 :     sal_Int32 nPlaces = 0;
     802           0 :     bool bUsePlaces = aAnyConv.getInt32( nPlaces, xOpt, rPlaces );
     803           0 :     return ConvertFromDec( fVal, SCA_MIN16, SCA_MAX16, 16, nPlaces, SCA_MAXPLACES, bUsePlaces );
     804             : }
     805             : 
     806           0 : OUString SAL_CALL AnalysisAddIn::getOct2Bin( const uno::Reference< beans::XPropertySet >& xOpt, const OUString& aNum, const uno::Any& rPlaces ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     807             : {
     808           0 :     double fVal = ConvertToDec( aNum, 8, SCA_MAXPLACES );
     809           0 :     sal_Int32 nPlaces = 0;
     810           0 :     bool bUsePlaces = aAnyConv.getInt32( nPlaces, xOpt, rPlaces );
     811           0 :     return ConvertFromDec( fVal, SCA_MIN2, SCA_MAX2, 2, nPlaces, SCA_MAXPLACES, bUsePlaces );
     812             : }
     813             : 
     814           3 : double SAL_CALL AnalysisAddIn::getOct2Dec( const OUString& aNum ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     815             : {
     816           3 :     double fRet = ConvertToDec( aNum, 8, SCA_MAXPLACES );
     817           3 :     RETURN_FINITE( fRet );
     818             : }
     819             : 
     820           0 : OUString SAL_CALL AnalysisAddIn::getOct2Hex( const uno::Reference< beans::XPropertySet >& xOpt, const OUString& aNum, const uno::Any& rPlaces ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     821             : {
     822           0 :     double fVal = ConvertToDec( aNum, 8, SCA_MAXPLACES );
     823           0 :     sal_Int32 nPlaces = 0;
     824           0 :     bool bUsePlaces = aAnyConv.getInt32( nPlaces, xOpt, rPlaces );
     825           0 :     return ConvertFromDec( fVal, SCA_MIN16, SCA_MAX16, 16, nPlaces, SCA_MAXPLACES, bUsePlaces );
     826             : }
     827             : 
     828           0 : OUString SAL_CALL AnalysisAddIn::getDec2Bin( const uno::Reference< beans::XPropertySet >& xOpt, sal_Int32 nNum, const uno::Any& rPlaces ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     829             : {
     830           0 :     sal_Int32 nPlaces = 0;
     831           0 :     bool bUsePlaces = aAnyConv.getInt32( nPlaces, xOpt, rPlaces );
     832           0 :     return ConvertFromDec( nNum, SCA_MIN2, SCA_MAX2, 2, nPlaces, SCA_MAXPLACES, bUsePlaces );
     833             : }
     834             : 
     835           0 : OUString SAL_CALL AnalysisAddIn::getDec2Oct( const uno::Reference< beans::XPropertySet >& xOpt, sal_Int32 nNum, const uno::Any& rPlaces ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     836             : {
     837           0 :     sal_Int32 nPlaces = 0;
     838           0 :     bool bUsePlaces = aAnyConv.getInt32( nPlaces, xOpt, rPlaces );
     839           0 :     return ConvertFromDec( nNum, SCA_MIN8, SCA_MAX8, 8, nPlaces, SCA_MAXPLACES, bUsePlaces );
     840             : }
     841             : 
     842           0 : OUString SAL_CALL AnalysisAddIn::getDec2Hex( const uno::Reference< beans::XPropertySet >& xOpt, double fNum, const uno::Any& rPlaces ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     843             : {
     844           0 :     sal_Int32 nPlaces = 0;
     845           0 :     bool bUsePlaces = aAnyConv.getInt32( nPlaces, xOpt, rPlaces );
     846           0 :     return ConvertFromDec( fNum, SCA_MIN16, SCA_MAX16, 16, nPlaces, SCA_MAXPLACES, bUsePlaces );
     847             : }
     848             : 
     849           0 : OUString SAL_CALL AnalysisAddIn::getHex2Bin( const uno::Reference< beans::XPropertySet >& xOpt, const OUString& aNum, const uno::Any& rPlaces ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     850             : {
     851           0 :     double fVal = ConvertToDec( aNum, 16, SCA_MAXPLACES );
     852           0 :     sal_Int32 nPlaces = 0;
     853           0 :     bool bUsePlaces = aAnyConv.getInt32( nPlaces, xOpt, rPlaces );
     854           0 :     return ConvertFromDec( fVal, SCA_MIN2, SCA_MAX2, 2, nPlaces, SCA_MAXPLACES, bUsePlaces );
     855             : }
     856             : 
     857           0 : double SAL_CALL AnalysisAddIn::getHex2Dec( const OUString& aNum ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     858             : {
     859           0 :     double fRet = ConvertToDec( aNum, 16, SCA_MAXPLACES );
     860           0 :     RETURN_FINITE( fRet );
     861             : }
     862             : 
     863           0 : OUString SAL_CALL AnalysisAddIn::getHex2Oct( const uno::Reference< beans::XPropertySet >& xOpt, const OUString& aNum, const uno::Any& rPlaces ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     864             : {
     865           0 :     double fVal = ConvertToDec( aNum, 16, SCA_MAXPLACES );
     866           0 :     sal_Int32 nPlaces = 0;
     867           0 :     bool bUsePlaces = aAnyConv.getInt32( nPlaces, xOpt, rPlaces );
     868           0 :     return ConvertFromDec( fVal, SCA_MIN8, SCA_MAX8, 8, nPlaces, SCA_MAXPLACES, bUsePlaces );
     869             : }
     870             : 
     871           0 : sal_Int32 SAL_CALL AnalysisAddIn::getDelta( const uno::Reference< beans::XPropertySet >& xOpt, double fNum1, const uno::Any& rNum2 ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     872             : {
     873           0 :     return sal_Int32(fNum1 == aAnyConv.getDouble( xOpt, rNum2, 0.0 ));
     874             : }
     875             : 
     876           0 : double SAL_CALL AnalysisAddIn::getErf( const uno::Reference< beans::XPropertySet >& xOpt, double fLL, const uno::Any& rUL ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     877             : {
     878             :     double fUL, fRet;
     879           0 :     bool bContainsValue = aAnyConv.getDouble( fUL, xOpt, rUL );
     880             : 
     881           0 :     fRet = bContainsValue ? (Erf( fUL ) - Erf( fLL )) : Erf( fLL );
     882           0 :     RETURN_FINITE( fRet );
     883             : }
     884             : 
     885           0 : double SAL_CALL AnalysisAddIn::getErfc( double f ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     886             : {
     887           0 :     double fRet = Erfc( f );
     888           0 :     RETURN_FINITE( fRet );
     889             : }
     890             : 
     891           0 : sal_Int32 SAL_CALL AnalysisAddIn::getGestep( const uno::Reference< beans::XPropertySet >& xOpt, double fNum, const uno::Any& rStep ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     892             : {
     893           0 :     return sal_Int32(fNum >= aAnyConv.getDouble( xOpt, rStep, 0.0 ));
     894             : }
     895             : 
     896           9 : double SAL_CALL AnalysisAddIn::getFactdouble( sal_Int32 nNum ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     897             : {
     898           9 :     double fRet = FactDouble( nNum );
     899           9 :     RETURN_FINITE( fRet );
     900             : }
     901             : 
     902           3 : double SAL_CALL AnalysisAddIn::getImabs( const OUString& aNum ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     903             : {
     904           3 :     double fRet = Complex( aNum ).Abs();
     905           3 :     RETURN_FINITE( fRet );
     906             : }
     907             : 
     908           3 : double SAL_CALL AnalysisAddIn::getImaginary( const OUString& aNum ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     909             : {
     910           3 :     double fRet = Complex( aNum ).Imag();
     911           3 :     RETURN_FINITE( fRet );
     912             : }
     913             : 
     914           0 : OUString SAL_CALL AnalysisAddIn::getImpower( const OUString& aNum, double f ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     915             : {
     916           0 :     Complex     z( aNum );
     917             : 
     918           0 :     z.Power( f );
     919             : 
     920           0 :     return z.GetString();
     921             : }
     922             : 
     923           3 : double SAL_CALL AnalysisAddIn::getImargument( const OUString& aNum ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     924             : {
     925           3 :     double fRet = Complex( aNum ).Arg();
     926           3 :     RETURN_FINITE( fRet );
     927             : }
     928             : 
     929           0 : OUString SAL_CALL AnalysisAddIn::getImcos( const OUString& aNum ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     930             : {
     931           0 :     Complex     z( aNum );
     932             : 
     933           0 :     z.Cos();
     934             : 
     935           0 :     return z.GetString();
     936             : }
     937             : 
     938           0 : OUString SAL_CALL AnalysisAddIn::getImdiv( const OUString& aDivid, const OUString& aDivis ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     939             : {
     940           0 :     Complex     z( aDivid );
     941             : 
     942           0 :     z.Div( Complex( aDivis ) );
     943             : 
     944           0 :     return z.GetString();
     945             : }
     946             : 
     947           0 : OUString SAL_CALL AnalysisAddIn::getImexp( const OUString& aNum ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     948             : {
     949           0 :     Complex     z( aNum );
     950             : 
     951           0 :     z.Exp();
     952             : 
     953           0 :     return z.GetString();
     954             : }
     955             : 
     956           0 : OUString SAL_CALL AnalysisAddIn::getImconjugate( const OUString& aNum ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     957             : {
     958           0 :     Complex     z( aNum );
     959             : 
     960           0 :     z.Conjugate();
     961             : 
     962           0 :     return z.GetString();
     963             : }
     964             : 
     965           0 : OUString SAL_CALL AnalysisAddIn::getImln( const OUString& aNum ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     966             : {
     967           0 :     Complex     z( aNum );
     968             : 
     969           0 :     z.Ln();
     970             : 
     971           0 :     return z.GetString();
     972             : }
     973             : 
     974           0 : OUString SAL_CALL AnalysisAddIn::getImlog10( const OUString& aNum ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     975             : {
     976           0 :     Complex     z( aNum );
     977             : 
     978           0 :     z.Log10();
     979             : 
     980           0 :     return z.GetString();
     981             : }
     982             : 
     983           0 : OUString SAL_CALL AnalysisAddIn::getImlog2( const OUString& aNum ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     984             : {
     985           0 :     Complex     z( aNum );
     986             : 
     987           0 :     z.Log2();
     988             : 
     989           0 :     return z.GetString();
     990             : }
     991             : 
     992           0 : OUString SAL_CALL AnalysisAddIn::getImproduct( const uno::Reference< beans::XPropertySet >&, const uno::Sequence< uno::Sequence< OUString > >& aNum1, const uno::Sequence< uno::Any >& aNL ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
     993             : {
     994           0 :     ComplexList     z_list;
     995             : 
     996           0 :     z_list.Append( aNum1, AH_IgnoreEmpty );
     997           0 :     z_list.Append( aNL, AH_IgnoreEmpty );
     998             : 
     999           0 :     if( z_list.empty() )
    1000           0 :         return Complex( 0 ).GetString();
    1001             : 
    1002           0 :     Complex         z( *(z_list.Get(0)) );
    1003           0 :     for( sal_uInt32 i = 1; i < z_list.Count(); ++i )
    1004           0 :         z.Mult( *(z_list.Get(i)) );
    1005             : 
    1006           0 :     return z.GetString();
    1007             : }
    1008             : 
    1009           3 : double SAL_CALL AnalysisAddIn::getImreal( const OUString& aNum ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
    1010             : {
    1011           3 :     double fRet = Complex( aNum ).Real();
    1012           3 :     RETURN_FINITE( fRet );
    1013             : }
    1014             : 
    1015           0 : OUString SAL_CALL AnalysisAddIn::getImsin( const OUString& aNum ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
    1016             : {
    1017           0 :     Complex     z( aNum );
    1018             : 
    1019           0 :     z.Sin();
    1020             : 
    1021           0 :     return z.GetString();
    1022             : }
    1023             : 
    1024           0 : OUString SAL_CALL AnalysisAddIn::getImsub( const OUString& aNum1, const OUString& aNum2 ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
    1025             : {
    1026           0 :     Complex     z( aNum1 );
    1027             : 
    1028           0 :     z.Sub( Complex( aNum2 ) );
    1029             : 
    1030           0 :     return z.GetString();
    1031             : }
    1032             : 
    1033           0 : OUString SAL_CALL AnalysisAddIn::getImsum( const uno::Reference< beans::XPropertySet >&, const uno::Sequence< uno::Sequence< OUString > >& aNum1, const uno::Sequence< uno::Any >& aFollowingPars ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
    1034             : {
    1035           0 :     ComplexList     z_list;
    1036             : 
    1037           0 :     z_list.Append( aNum1, AH_IgnoreEmpty );
    1038           0 :     z_list.Append( aFollowingPars, AH_IgnoreEmpty );
    1039             : 
    1040           0 :     if( z_list.empty() )
    1041           0 :         return Complex( 0 ).GetString();
    1042             : 
    1043           0 :     Complex         z( *(z_list.Get(0)) );
    1044           0 :     for( sal_uInt32 i = 1; i < z_list.Count(); ++i )
    1045           0 :         z.Add( *(z_list.Get(i)) );
    1046             : 
    1047           0 :     return z.GetString();
    1048             : }
    1049             : 
    1050           0 : OUString SAL_CALL AnalysisAddIn::getImsqrt( const OUString& aNum ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
    1051             : {
    1052           0 :     Complex     z( aNum );
    1053             : 
    1054           0 :     z.Sqrt();
    1055             : 
    1056           0 :     return z.GetString();
    1057             : }
    1058             : 
    1059           0 : OUString SAL_CALL AnalysisAddIn::getImtan( const OUString& aNum ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
    1060             : {
    1061           0 :     Complex     z( aNum );
    1062             : 
    1063           0 :     z.Tan();
    1064             : 
    1065           0 :     return z.GetString();
    1066             : }
    1067             : 
    1068           0 : OUString SAL_CALL AnalysisAddIn::getImsec( const OUString& aNum ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
    1069             : {
    1070           0 :     Complex     z( aNum );
    1071             : 
    1072           0 :     z.Sec();
    1073             : 
    1074           0 :     return z.GetString();
    1075             : }
    1076             : 
    1077           0 : OUString SAL_CALL AnalysisAddIn::getImcsc( const OUString& aNum ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
    1078             : {
    1079           0 :     Complex     z( aNum );
    1080             : 
    1081           0 :     z.Csc();
    1082             : 
    1083           0 :     return z.GetString();
    1084             : }
    1085             : 
    1086           0 : OUString SAL_CALL AnalysisAddIn::getImcot( const OUString& aNum ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
    1087             : {
    1088           0 :     Complex     z( aNum );
    1089             : 
    1090           0 :     z.Cot();
    1091             : 
    1092           0 :     return z.GetString();
    1093             : }
    1094             : 
    1095           0 : OUString SAL_CALL AnalysisAddIn::getImsinh( const OUString& aNum ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
    1096             : {
    1097           0 :     Complex     z( aNum );
    1098             : 
    1099           0 :     z.Sinh();
    1100             : 
    1101           0 :     return z.GetString();
    1102             : }
    1103             : 
    1104           0 : OUString SAL_CALL AnalysisAddIn::getImcosh( const OUString& aNum ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
    1105             : {
    1106           0 :     Complex     z( aNum );
    1107             : 
    1108           0 :     z.Cosh();
    1109             : 
    1110           0 :     return z.GetString();
    1111             : }
    1112             : 
    1113           0 : OUString SAL_CALL AnalysisAddIn::getImsech( const OUString& aNum ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
    1114             : {
    1115           0 :     Complex     z( aNum );
    1116             : 
    1117           0 :     z.Sech();
    1118             : 
    1119           0 :     return z.GetString();
    1120             : }
    1121             : 
    1122           0 : OUString SAL_CALL AnalysisAddIn::getImcsch( const OUString& aNum ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
    1123             : {
    1124           0 :     Complex     z( aNum );
    1125             : 
    1126           0 :     z.Csch();
    1127             : 
    1128           0 :     return z.GetString();
    1129             : }
    1130             : 
    1131           0 : OUString SAL_CALL AnalysisAddIn::getComplex( double fR, double fI, const uno::Any& rSuff ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
    1132             : {
    1133             :     bool    bi;
    1134             : 
    1135           0 :     switch( rSuff.getValueTypeClass() )
    1136             :     {
    1137             :         case uno::TypeClass_VOID:
    1138           0 :             bi = true;
    1139           0 :             break;
    1140             :         case uno::TypeClass_STRING:
    1141             :             {
    1142           0 :             const OUString*   pSuff = static_cast<const OUString*>(rSuff.getValue());
    1143           0 :             bi = *pSuff == "i" || pSuff->isEmpty();
    1144           0 :             if( !bi && *pSuff != "j" )
    1145           0 :                 throw lang::IllegalArgumentException();
    1146             :             }
    1147           0 :             break;
    1148             :         default:
    1149           0 :             throw lang::IllegalArgumentException();
    1150             :     }
    1151             : 
    1152           0 :     return Complex( fR, fI, bi ? 'i' : 'j' ).GetString();
    1153             : }
    1154             : 
    1155           6 : double SAL_CALL AnalysisAddIn::getConvert( double f, const OUString& aFU, const OUString& aTU ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
    1156             : {
    1157           6 :     if( !pCDL )
    1158           1 :         pCDL = new ConvertDataList();
    1159             : 
    1160           6 :     double fRet = pCDL->Convert( f, aFU, aTU );
    1161           6 :     RETURN_FINITE( fRet );
    1162          60 : }
    1163             : 
    1164             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11