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

Generated by: LCOV version 1.10