LCOV - code coverage report
Current view: top level - scaddins/source/analysis - analysishelper.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 59 147 40.1 %
Date: 2012-08-25 Functions: 22 65 33.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 11 38 28.9 %

           Branch data     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                 :            : #ifndef ANALYSISHELPER_HXX
      20                 :            : #define ANALYSISHELPER_HXX
      21                 :            : 
      22                 :            : 
      23                 :            : #include <com/sun/star/lang/XServiceName.hpp>
      24                 :            : #include <com/sun/star/lang/XServiceInfo.hpp>
      25                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      26                 :            : #include <com/sun/star/util/Date.hpp>
      27                 :            : #include <com/sun/star/util/XNumberFormatter.hpp>
      28                 :            : #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
      29                 :            : #include <com/sun/star/sheet/XAddIn.hpp>
      30                 :            : #include <com/sun/star/sheet/addin/XAnalysis.hpp>
      31                 :            : 
      32                 :            : #include <math.h>
      33                 :            : 
      34                 :            : #include <tools/resid.hxx>
      35                 :            : #include <tools/rc.hxx>
      36                 :            : 
      37                 :            : #include "analysisdefs.hxx"
      38                 :            : 
      39                 :            : 
      40                 :            : class ResMgr;
      41                 :            : class SortedIndividualInt32List;
      42                 :            : class ScaAnyConverter;
      43                 :            : 
      44                 :            : 
      45                 :            : #define PI          3.1415926535897932
      46                 :            : #define EOL         ( ( const sal_Char* ) 1 )
      47                 :            : #define EOE         ( ( const sal_Char* ) 2 )
      48                 :            : 
      49                 :            : 
      50                 :            : inline sal_Bool     IsLeapYear( sal_uInt16 nYear );
      51                 :            : 
      52                 :            : #ifdef DISABLE_DYNLOADING
      53                 :            : 
      54                 :            : // Avoid clash with the functions with same name in
      55                 :            : // scaddins/source/datefunc/datefunc.cxx. I am not sure if each pair
      56                 :            : // have identical semantics, but if yes, one copy should be enough,
      57                 :            : // but what would be a suitable library where such functions could go?
      58                 :            : // Or can the analysis library depend on the date library or the other
      59                 :            : // way around?
      60                 :            : 
      61                 :            : #define DaysInMonth analysishelper_DaysInMonth
      62                 :            : #define DateToDays analysishelper_DateToDays
      63                 :            : #define DaysToDate analysishelper_DaysToDate
      64                 :            : #define GetNullDate analysishelper_GetNullDate
      65                 :            : 
      66                 :            : #endif
      67                 :            : 
      68                 :            : sal_uInt16          DaysInMonth( sal_uInt16 nMonth, sal_uInt16 nYear );
      69                 :            : sal_Int32           DateToDays( sal_uInt16 nDay, sal_uInt16 nMonth, sal_uInt16 nYear );
      70                 :            : void                DaysToDate( sal_Int32 nDays, sal_uInt16& rDay, sal_uInt16& rMonth, sal_uInt16& rYear ) throw( ::com::sun::star::lang::IllegalArgumentException );
      71                 :            : sal_Int32           GetNullDate( const REF( ::com::sun::star::beans::XPropertySet )& xOptions ) THROWDEF_RTE;
      72                 :            : sal_Int32           GetDiffDate360(
      73                 :            :                         sal_uInt16 nDay1, sal_uInt16 nMonth1, sal_uInt16 nYear1, sal_Bool bLeapYear1,
      74                 :            :                         sal_uInt16 nDay2, sal_uInt16 nMonth2, sal_uInt16 nYear2,
      75                 :            :                         sal_Bool bUSAMethod );
      76                 :            : inline sal_Int32    GetDiffDate360( constREFXPS& xOpt, sal_Int32 nDate1, sal_Int32 nDate2, sal_Bool bUSAMethod );
      77                 :            : sal_Int32           GetDiffDate360( sal_Int32 nNullDate, sal_Int32 nDate1, sal_Int32 nDate2, sal_Bool bUSAMethod );
      78                 :            : 
      79                 :            : sal_Int32           GetDaysInYears( sal_uInt16 nYear1, sal_uInt16 nYear2 );
      80                 :            : inline sal_Int16    GetDayOfWeek( sal_Int32 nDate );
      81                 :            : void                GetDiffParam( sal_Int32 nNullDate, sal_Int32 nStartDate, sal_Int32 nEndDate, sal_Int32 nMode,
      82                 :            :                         sal_uInt16& rYears, sal_Int32& rDayDiffPart, sal_Int32& rDaysInYear ) THROWDEF_RTE_IAE;
      83                 :            :                         // rYears = full num of years
      84                 :            :                         // rDayDiffPart = num of days for last year
      85                 :            :                         // rDaysInYear = num of days in first year
      86                 :            : sal_Int32           GetDiffDate( sal_Int32 nNullDate, sal_Int32 nStartDate, sal_Int32 nEndDate, sal_Int32 nMode,
      87                 :            :                                 sal_Int32* pOptDaysIn1stYear = NULL ) THROWDEF_RTE_IAE;
      88                 :            : double              GetYearDiff( sal_Int32 nNullDate, sal_Int32 nStartDate, sal_Int32 nEndDate, sal_Int32 nMode )
      89                 :            :                                 THROWDEF_RTE_IAE;
      90                 :            : sal_Int32           GetDaysInYear( sal_Int32 nNullDate, sal_Int32 nDate, sal_Int32 nMode ) THROWDEF_RTE_IAE;
      91                 :            : double              GetYearFrac( sal_Int32 nNullDate, sal_Int32 nStartDate, sal_Int32 nEndDate, sal_Int32 nMode )
      92                 :            :                         THROWDEF_RTE_IAE;
      93                 :            : inline double       GetYearFrac( constREFXPS& xOpt, sal_Int32 nStartDate, sal_Int32 nEndDate, sal_Int32 nMode )
      94                 :            :                         THROWDEF_RTE_IAE;
      95                 :            : inline void         AlignDate( sal_uInt16& rDay, sal_uInt16 nMonth, sal_uInt16 nYear );
      96                 :            : 
      97                 :            : double              BinomialCoefficient( double n, double k );
      98                 :            : double              GetGcd( double f1, double f2 );
      99                 :            : double              ConvertToDec( const STRING& rFromNum, sal_uInt16 nBaseFrom, sal_uInt16 nCharLim ) THROWDEF_RTE_IAE;
     100                 :            : STRING              ConvertFromDec(
     101                 :            :                         double fNum, double fMin, double fMax, sal_uInt16 nBase,
     102                 :            :                         sal_Int32 nPlaces, sal_Int32 nMaxPlaces, sal_Bool bUsePlaces ) THROWDEF_RTE_IAE;
     103                 :            : double              Erf( double fX );
     104                 :            : double              Erfc( double fX );
     105                 :            : sal_Bool            ParseDouble( const sal_Unicode*& rpDoubleAsString, double& rReturn );
     106                 :            : STRING              GetString( double fNumber, sal_Bool bLeadingSign = sal_False, sal_uInt16 nMaxNumOfDigits = 15 );
     107                 :            : inline double       Exp10( sal_Int16 nPower );      // 10 ^ nPower
     108                 :            : 
     109                 :            : double              GetAmordegrc( sal_Int32 nNullDate, double fCost, sal_Int32 nDate, sal_Int32 nFirstPer,
     110                 :            :                                 double fRestVal, double fPer, double fRate, sal_Int32 nBase ) THROWDEF_RTE_IAE;
     111                 :            : double              GetAmorlinc( sal_Int32 nNullDate, double fCost, sal_Int32 nDate, sal_Int32 nFirstPer,
     112                 :            :                                 double fRestVal, double fPer, double fRate, sal_Int32 nBase ) THROWDEF_RTE_IAE;
     113                 :            : double              GetDuration( sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, double fCoup,
     114                 :            :                                 double fYield, sal_Int32 nFreq, sal_Int32 nBase ) THROWDEF_RTE_IAE;
     115                 :            : double              GetYieldmat( sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nIssue,
     116                 :            :                                 double fRate, double fPrice, sal_Int32 nBase ) THROWDEF_RTE_IAE;
     117                 :            : double              GetOddfprice( sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nIssue,
     118                 :            :                                 sal_Int32 nFirstCoup, double fRate, double fYield, double fRedemp,
     119                 :            :                                 sal_Int32 nFreq, sal_Int32 nBase ) THROWDEF_RTE_IAE;
     120                 :            : double              getYield_( sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, double fCoup, double fPrice,
     121                 :            :                                 double fRedemp, sal_Int32 nFreq, sal_Int32 nBase ) THROWDEF_RTE_IAE;
     122                 :            : double              getPrice_( sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, double fRate, double fYield,
     123                 :            :                                 double fRedemp, sal_Int32 nFreq, sal_Int32 nBase ) THROWDEF_RTE_IAE;
     124                 :            : double              GetOddfyield( sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nIssue,
     125                 :            :                                 sal_Int32 nFirstCoup, double fRate, double fPrice, double fRedemp,
     126                 :            :                                 sal_Int32 nFreq, sal_Int32 nBase ) THROWDEF_RTE_IAE;
     127                 :            : double              GetOddlprice( sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nLastInterest,
     128                 :            :                                 double fRate, double fYield, double fRedemp, sal_Int32 nFreq, sal_Int32 nBase ) THROWDEF_RTE_IAE;
     129                 :            : double              GetOddlyield( sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nLastInterest,
     130                 :            :                                 double fRate, double fPrice, double fRedemp, sal_Int32 nFreq, sal_Int32 nBase ) THROWDEF_RTE_IAE;
     131                 :            : double              GetRmz( double fZins, double fZzr, double fBw, double fZw, sal_Int32 nF );
     132                 :            : double              GetZw( double fZins, double fZzr, double fRmz, double fBw, sal_Int32 nF );
     133                 :            : 
     134                 :            : double              GetCouppcd( sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq,
     135                 :            :                                 sal_Int32 nBase ) THROWDEF_RTE_IAE;
     136                 :            : double              GetCoupncd( sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq,
     137                 :            :                                 sal_Int32 nBase ) THROWDEF_RTE_IAE;
     138                 :            : double              GetCoupdaybs( sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq,
     139                 :            :                                 sal_Int32 nBase ) THROWDEF_RTE_IAE;
     140                 :            : double              GetCoupdaysnc( sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq,
     141                 :            :                                 sal_Int32 nBase ) THROWDEF_RTE_IAE;
     142                 :            : 
     143                 :            : double              GetCoupnum( sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat,
     144                 :            :                                 sal_Int32 nFreq, sal_Int32 nBase ) THROWDEF_RTE_IAE;
     145                 :            : double              GetCoupdays( sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq,
     146                 :            :                                 sal_Int32 nBase ) THROWDEF_RTE_IAE;
     147                 :            : 
     148                 :            : 
     149                 :            : 
     150                 :            : 
     151                 :            : //-----------------------------------------------------------------------------
     152                 :            : 
     153                 :            : 
     154                 :            : 
     155                 :            : class MyList
     156                 :            : {
     157                 :            : private:
     158                 :            :     static const sal_uInt32 nStartSize;
     159                 :            :     static const sal_uInt32 nIncrSize;
     160                 :            : 
     161                 :            :     void**                  pData;          // pointer array
     162                 :            :     sal_uInt32              nSize;          // array size
     163                 :            :     sal_uInt32              nNew;           // next index to be inserted at
     164                 :            :     sal_uInt32              nAct;           // actual for iterations
     165                 :            : 
     166                 :            :     void                    _Grow( void );
     167                 :            :     inline void             Grow( void );
     168                 :            : protected:
     169                 :            : public:
     170                 :            :                             MyList( void );
     171                 :            :     virtual                 ~MyList();
     172                 :            : 
     173                 :            :     inline const void*      GetObject( sal_uInt32 nIndex ) const;
     174                 :            :     inline const void*      First( void );
     175                 :            :     inline const void*      Next( void );
     176                 :            : 
     177                 :            :     inline void             Append( void* pNewElement );
     178                 :            :     void                    Insert( void* pNewLement, sal_uInt32 nPlace );
     179                 :            : 
     180                 :            :     inline sal_uInt32       Count( void ) const;
     181                 :            : };
     182                 :            : 
     183                 :            : 
     184                 :            : 
     185                 :            : 
     186                 :       1717 : class StringList : protected MyList
     187                 :            : {
     188                 :            : public:
     189                 :            :     virtual                 ~StringList();
     190                 :            : 
     191                 :            :     inline const STRING*    First( void );
     192                 :            :     inline const STRING*    Next( void );
     193                 :            :     inline const STRING*    Get( sal_uInt32 nIndex ) const;
     194                 :            : 
     195                 :            :     using MyList::Append;
     196                 :            :     inline void             Append( STRING* pNew );
     197                 :            :     inline void             Append( const STRING& rNew );
     198                 :            : 
     199                 :            :     using MyList::Count;
     200                 :            : };
     201                 :            : 
     202                 :            : 
     203                 :            : 
     204                 :            : 
     205                 :            : enum FDCategory
     206                 :            : {
     207                 :            :     FDCat_AddIn,
     208                 :            :     FDCat_DateTime,
     209                 :            :     FDCat_Finance,
     210                 :            :     FDCat_Inf,
     211                 :            :     FDCat_Math,
     212                 :            :     FDCat_Tech
     213                 :            : };
     214                 :            : 
     215                 :            : 
     216                 :            : struct FuncDataBase
     217                 :            : {
     218                 :            :     const sal_Char*         pIntName;
     219                 :            :     sal_uInt16              nUINameID;          // resource ID to UI name
     220                 :            :     sal_uInt16              nDescrID;           // resource ID to description, parameter names and ~ description
     221                 :            :     sal_Bool                bDouble;            // name already exist in Calc
     222                 :            :     sal_Bool                bWithOpt;           // first parameter is internal
     223                 :            :     sal_uInt16              nCompListID;        // resource ID to list of valid names
     224                 :            :     sal_uInt16              nNumOfParams;       // number of named / described parameters
     225                 :            :     FDCategory              eCat;               // function category
     226                 :            : };
     227                 :            : 
     228                 :            : 
     229                 :            : 
     230                 :            : 
     231                 :            : class FuncData
     232                 :            : {
     233                 :            : private:
     234                 :            :     ::rtl::OUString         aIntName;
     235                 :            :     sal_uInt16              nUINameID;
     236                 :            :     sal_uInt16              nDescrID;           // leads also to parameter descriptions!
     237                 :            :     sal_Bool                bDouble;            // flag for names, wich already exist in Calc
     238                 :            :     sal_Bool                bWithOpt;           // has internal parameter on first position
     239                 :            : 
     240                 :            :     sal_uInt16              nParam;             // num of parameters
     241                 :            :     sal_uInt16              nCompID;
     242                 :            :     StringList              aCompList;          // list of all valid names
     243                 :            :     FDCategory              eCat;               // function category
     244                 :            : public:
     245                 :            :                             FuncData( const FuncDataBase& rBaseData, ResMgr& );
     246                 :            :     virtual                 ~FuncData();
     247                 :            : 
     248                 :            :     inline sal_uInt16       GetUINameID( void ) const;
     249                 :            :     inline sal_uInt16       GetDescrID( void ) const;
     250                 :            :     inline sal_Bool         IsDouble( void ) const;
     251                 :            :     inline sal_Bool         HasIntParam( void ) const;
     252                 :            : 
     253                 :            :     sal_uInt16              GetStrIndex( sal_uInt16 nParamNum ) const;
     254                 :            :     inline sal_Bool         Is( const ::rtl::OUString& rCompareTo ) const;
     255                 :            : 
     256                 :            :     inline const StringList&    GetCompNameList( void ) const;
     257                 :            : 
     258                 :            :     inline FDCategory       GetCategory( void ) const;
     259                 :            : };
     260                 :            : 
     261                 :            : 
     262                 :            : 
     263                 :            : 
     264                 :            : class CStrList : private MyList
     265                 :            : {
     266                 :            : public:
     267                 :            :     using MyList::Append;
     268                 :            :     inline void             Append( const sal_Char* pNew );
     269                 :            :     inline const sal_Char*  Get( sal_uInt32 nIndex ) const;
     270                 :            :     using MyList::Count;
     271                 :            : };
     272                 :            : 
     273                 :            : 
     274                 :            : 
     275                 :            : 
     276                 :            : class FuncDataList : private MyList
     277                 :            : {
     278                 :            :     ::rtl::OUString         aLastName;
     279                 :            :     sal_uInt32              nLast;
     280                 :            : public:
     281                 :            :                             FuncDataList( ResMgr& );
     282                 :            :     virtual                 ~FuncDataList();
     283                 :            :     using MyList::Append;
     284                 :            :     inline void             Append( FuncData* pNew );
     285                 :            :     inline const FuncData*  Get( sal_uInt32 nIndex ) const;
     286                 :            :     using MyList::Count;
     287                 :            : 
     288                 :            :     const FuncData*         Get( const ::rtl::OUString& aProgrammaticName ) const;
     289                 :            : };
     290                 :            : 
     291                 :            : 
     292                 :            : 
     293                 :            : class AnalysisResId : public ResId
     294                 :            : {
     295                 :            :  public:
     296                 :            :                     AnalysisResId( sal_uInt16 nId, ResMgr& rResMgr );
     297                 :            : };
     298                 :            : 
     299                 :            : 
     300                 :            : 
     301                 :            : 
     302         [ +  - ]:       1717 : class AnalysisRscStrLoader : public Resource
     303                 :            : {
     304                 :            : private:
     305                 :            :     String          aStr;
     306                 :            : public:
     307                 :       1717 :     AnalysisRscStrLoader( sal_uInt16 nRsc, sal_uInt16 nStrId, ResMgr& rResMgr ) :
     308                 :            :         Resource( AnalysisResId( nRsc, rResMgr ) ),
     309 [ +  - ][ +  - ]:       1717 :         aStr( AnalysisResId( nStrId, rResMgr ) )
                 [ +  - ]
     310                 :            :     {
     311         [ +  - ]:       1717 :         FreeResource();
     312                 :       1717 :     }
     313                 :            : 
     314                 :       1717 :     const String&   GetString() const { return aStr; }
     315                 :            : 
     316                 :            : };
     317                 :            : 
     318                 :            : 
     319                 :            : 
     320                 :            : //-----------------------------------------------------------------------------
     321                 :            : 
     322                 :            : /// sorted list with unique sal_Int32 values
     323                 :            : class SortedIndividualInt32List : private MyList
     324                 :            : {
     325                 :            : protected:
     326                 :            :     using MyList::Insert;
     327                 :            :     void                        Insert( sal_Int32 nDay );
     328                 :            :     void                        Insert( sal_Int32 nDay, sal_Int32 nNullDate, sal_Bool bInsertOnWeekend );
     329                 :            :     void                        Insert( double fDay, sal_Int32 nNullDate, sal_Bool bInsertOnWeekend )
     330                 :            :                                     throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException );
     331                 :            : 
     332                 :            :                                 /** @param rAnyConv  must be an initialized ScaAnyConmverter
     333                 :            :                                     @param bInsertOnWeekend  insertion mode: sal_False = holidays on weekend are omitted */
     334                 :            :     void                        InsertHolidayList(
     335                 :            :                                     const ScaAnyConverter& rAnyConv,
     336                 :            :                                     const ::com::sun::star::uno::Any& rHolAny,
     337                 :            :                                     sal_Int32 nNullDate,
     338                 :            :                                     sal_Bool bInsertOnWeekend ) throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException );
     339                 :            : 
     340                 :            : public:
     341                 :            :                                 SortedIndividualInt32List();
     342                 :            :     virtual                     ~SortedIndividualInt32List();
     343                 :            : 
     344                 :            :                                 using MyList::Count;
     345                 :            : 
     346                 :            :                                 /// @return  element on position nIndex or 0 on invalid index
     347                 :          0 :     inline sal_Int32            Get( sal_uInt32 nIndex ) const
     348                 :          0 :                                     { return (sal_Int32)(sal_IntPtr) MyList::GetObject( nIndex ); }
     349                 :            : 
     350                 :            :                                 /// @return  sal_True if nVal (internal date representation) is contained
     351                 :            :     sal_Bool                    Find( sal_Int32 nVal ) const;
     352                 :            : 
     353                 :            :                                 /** @param rAnyConv  is an initialized or uninitialized ScaAnyConverter
     354                 :            :                                     @param bInsertOnWeekend  insertion mode: sal_False = holidays on weekend are omitted */
     355                 :            :     void                        InsertHolidayList(
     356                 :            :                                     ScaAnyConverter& rAnyConv,
     357                 :            :                                     const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xOptions,
     358                 :            :                                     const ::com::sun::star::uno::Any& rHolAny,
     359                 :            :                                     sal_Int32 nNullDate,
     360                 :            :                                     sal_Bool bInsertOnWeekend ) throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException );
     361                 :            : };
     362                 :            : 
     363                 :            : 
     364                 :            : //-----------------------------------------------------------------------------
     365                 :            : 
     366                 :          0 : class ScaDoubleList : protected MyList
     367                 :            : {
     368                 :            : protected:
     369                 :          0 :     inline void                 ListAppend( double fValue ) { MyList::Append( new double( fValue ) ); }
     370                 :            : 
     371                 :            :     using MyList::Append;
     372                 :          0 :     inline void                 Append( double fValue ) throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException )
     373         [ #  # ]:          0 :                                     { if( CheckInsert( fValue ) ) ListAppend( fValue ); }
     374                 :            : 
     375                 :            :                                 /** @param rAnyConv  must be an initialized ScaAnyConmverter
     376                 :            :                                     @param bIgnoreEmpty  handling of empty Any's/strings: sal_False = inserted as 0.0; sal_True = omitted */
     377                 :            :     void                        Append(
     378                 :            :                                     const ScaAnyConverter& rAnyConv,
     379                 :            :                                     const ::com::sun::star::uno::Any& rAny,
     380                 :            :                                     sal_Bool bIgnoreEmpty ) throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException );
     381                 :            : 
     382                 :            :                                 /** @param rAnyConv  must be an initialized ScaAnyConmverter
     383                 :            :                                     @param bIgnoreEmpty  handling of empty Any's/strings: sal_False = inserted as 0.0; sal_True = omitted */
     384                 :            :     void                        Append(
     385                 :            :                                     const ScaAnyConverter& rAnyConv,
     386                 :            :                                     const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rAnySeq,
     387                 :            :                                     sal_Bool bIgnoreEmpty ) throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException );
     388                 :            : 
     389                 :            :                                 /** @param rAnyConv  must be an initialized ScaAnyConmverter
     390                 :            :                                     @param bIgnoreEmpty  handling of empty Any's/strings: sal_False = inserted as 0.0; sal_True = omitted */
     391                 :            :     void                        Append(
     392                 :            :                                     const ScaAnyConverter& rAnyConv,
     393                 :            :                                     const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& rAnySeq,
     394                 :            :                                     sal_Bool bIgnoreEmpty ) throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException );
     395                 :            : 
     396                 :            : public:
     397                 :            :     virtual                     ~ScaDoubleList();
     398                 :            : 
     399                 :            :                                 using MyList::Count;
     400                 :          0 :     inline const double*        Get( sal_uInt32 nIndex ) const
     401                 :          0 :                                         { return static_cast< const double* >( MyList::GetObject( nIndex ) ); }
     402                 :            : 
     403                 :          0 :     inline const double*        First() { return static_cast< const double* >( MyList::First() ); }
     404                 :          0 :     inline const double*        Next()  { return static_cast< const double* >( MyList::Next() ); }
     405                 :            : 
     406                 :            :     void                        Append( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& rValueArr )
     407                 :            :                                     throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException );
     408                 :            :     void                        Append( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< sal_Int32 > >& rValueArr )
     409                 :            :                                     throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException );
     410                 :            : 
     411                 :            :                                 /** @param rAnyConv  is an initialized or uninitialized ScaAnyConverter
     412                 :            :                                     @param bIgnoreEmpty  handling of empty Any's/strings: sal_False = inserted as 0.0; sal_True = omitted */
     413                 :            :     void                        Append(
     414                 :            :                                     ScaAnyConverter& rAnyConv,
     415                 :            :                                     const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xOpt,
     416                 :            :                                     const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rAnySeq,
     417                 :            :                                     sal_Bool bIgnoreEmpty = sal_True ) throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException );
     418                 :            : 
     419                 :            :     virtual sal_Bool            CheckInsert( double fValue ) const
     420                 :            :                                     throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException );
     421                 :            : };
     422                 :            : 
     423                 :            : 
     424                 :            : //-----------------------------------------------------------------------------
     425                 :            : 
     426                 :            : /// stores double values >0.0, throws exception for double values <0.0, does nothing for 0.0
     427         [ #  # ]:          0 : class ScaDoubleListGT0 : public ScaDoubleList
     428                 :            : {
     429                 :            : public:
     430                 :            :     virtual sal_Bool            CheckInsert( double fValue ) const
     431                 :            :                                     throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException );
     432                 :            : };
     433                 :            : 
     434                 :            : 
     435                 :            : //-----------------------------------------------------------------------------
     436                 :            : 
     437                 :            : /// stores double values >=0.0, throws exception for double values <0.0
     438         [ #  # ]:          0 : class ScaDoubleListGE0 : public ScaDoubleList
     439                 :            : {
     440                 :            : public:
     441                 :            :     virtual sal_Bool            CheckInsert( double fValue ) const
     442                 :            :                                     throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException );
     443                 :            : };
     444                 :            : 
     445                 :            : 
     446                 :            : //-----------------------------------------------------------------------------
     447                 :            : 
     448                 :            : class Complex
     449                 :            : {
     450                 :            :     double                  r;
     451                 :            :     double                  i;
     452                 :            :     sal_Unicode             c;
     453                 :            : 
     454                 :            : public:
     455                 :            :     inline                  Complex( double fReal, double fImag = 0.0, sal_Unicode cC = '\0' );
     456                 :            :                             Complex( const STRING& rComplexAsString ) THROWDEF_RTE_IAE;
     457                 :            : 
     458                 :            :     inline static sal_Bool  IsImagUnit( sal_Unicode c );
     459                 :            :     static sal_Bool         ParseString( const STRING& rComplexAsString, Complex& rReturn );
     460                 :            :     STRING                  GetString() const THROWDEF_RTE_IAE;
     461                 :            : 
     462                 :            :     inline double           Real( void ) const;
     463                 :            :     inline double           Imag( void ) const;
     464                 :            : 
     465                 :            :     double                  Arg( void ) const THROWDEF_RTE_IAE;
     466                 :            :     inline double           Abs( void ) const;
     467                 :            : 
     468                 :            :     // following functions change the complex number itself to avoid unnecessary copy actions!
     469                 :            :     void                    Power( double fPower ) THROWDEF_RTE_IAE;
     470                 :            :     void                    Sqrt( void );
     471                 :            :     void                    Sin( void ) THROWDEF_RTE_IAE;
     472                 :            :     void                    Cos( void ) THROWDEF_RTE_IAE;
     473                 :            :     void                    Div( const Complex& rDivisor ) THROWDEF_RTE_IAE;
     474                 :            :     void                    Exp( void );
     475                 :            :     inline void             Conjugate( void );
     476                 :            :     void                    Ln( void ) THROWDEF_RTE_IAE;
     477                 :            :     void                    Log10( void ) THROWDEF_RTE_IAE;
     478                 :            :     void                    Log2( void ) THROWDEF_RTE_IAE;
     479                 :            :     inline void             Mult( double fFact );
     480                 :            :     inline void             Mult( const Complex& rMult );
     481                 :            :     inline void             Sub( const Complex& rMult );
     482                 :            :     inline void             Add( const Complex& rAdd );
     483                 :            :     void                    Tan( void ) THROWDEF_RTE_IAE;
     484                 :            :     void                    Sec( void ) THROWDEF_RTE_IAE;
     485                 :            :     void                    Csc( void ) THROWDEF_RTE_IAE;
     486                 :            :     void                    Cot( void ) THROWDEF_RTE_IAE;
     487                 :            :     void                    Sinh( void ) THROWDEF_RTE_IAE;
     488                 :            :     void                    Cosh( void ) THROWDEF_RTE_IAE;
     489                 :            :     void                    Sech( void ) THROWDEF_RTE_IAE;
     490                 :            :     void                    Csch( void ) THROWDEF_RTE_IAE;
     491                 :            : 
     492                 :            : };
     493                 :            : 
     494                 :            : 
     495                 :            : 
     496                 :            : 
     497                 :            : enum ComplListAppendHandl
     498                 :            : {
     499                 :            :     AH_EmptyAsErr,
     500                 :            :     AH_EmpyAs0,
     501                 :            :     AH_IgnoreEmpty
     502                 :            : };
     503                 :            : 
     504                 :            : 
     505                 :          0 : class ComplexList : protected MyList
     506                 :            : {
     507                 :            : public:
     508                 :            :     virtual                 ~ComplexList();
     509                 :            : 
     510                 :            :     inline const Complex*   Get( sal_uInt32 nIndex ) const;
     511                 :            :     inline const Complex*   First( void );
     512                 :            :     inline const Complex*   Next( void );
     513                 :            : 
     514                 :            :     using MyList::Count;
     515                 :            : 
     516                 :            :     using MyList::Append;
     517                 :            :     inline void             Append( Complex* pNew );
     518                 :            :     void                    Append( const SEQSEQ( STRING )& rComplexNumList, ComplListAppendHandl eAH = AH_EmpyAs0 ) THROWDEF_RTE_IAE;
     519                 :            :     void                    Append( const SEQ( ANY )& aMultPars,ComplListAppendHandl eAH = AH_EmpyAs0 ) THROWDEF_RTE_IAE;
     520                 :            : };
     521                 :            : 
     522                 :            : 
     523                 :            : 
     524                 :            : 
     525                 :            : enum ConvertDataClass
     526                 :            : {
     527                 :            :     CDC_Mass, CDC_Length, CDC_Time, CDC_Pressure, CDC_Force, CDC_Energy, CDC_Power, CDC_Magnetism,
     528                 :            :     CDC_Temperature, CDC_Volume, CDC_Area, CDC_Speed, CDC_Information
     529                 :            : };
     530                 :            : 
     531                 :            : 
     532                 :            : #define INV_MATCHLEV        1764                    // guess, what this is... :-)
     533                 :            : 
     534                 :            : 
     535                 :            : class ConvertDataList;
     536                 :            : 
     537                 :            : 
     538                 :            : 
     539                 :            : 
     540                 :            : class ConvertData
     541                 :            : {
     542                 :            : protected:
     543                 :            :     friend class ConvertDataList;
     544                 :            :     double                  fConst;
     545                 :            :     STRING                  aName;
     546                 :            :     ConvertDataClass        eClass;
     547                 :            :     sal_Bool                bPrefixSupport;
     548                 :            : public:
     549                 :            :                             ConvertData(
     550                 :            :                                 const sal_Char      pUnitName[],
     551                 :            :                                 double              fConvertConstant,
     552                 :            :                                 ConvertDataClass    eClass,
     553                 :            :                                 sal_Bool            bPrefSupport = sal_False );
     554                 :            : 
     555                 :            :     virtual                 ~ConvertData();
     556                 :            : 
     557                 :            :     sal_Int16               GetMatchingLevel( const STRING& rRef ) const;
     558                 :            :                                     // 0.0 = no equality
     559                 :            :                                     // 1.0 = matches exact
     560                 :            :                                     // rest = matches without an assumed prefix of one character
     561                 :            :                                     //  rest gives power for 10 represented by the prefix (e.g. 3 for k or -9 for n
     562                 :            : 
     563                 :            :     virtual double          Convert( double fVal, const ConvertData& rTo,
     564                 :            :                                 sal_Int16 nMatchLevelFrom, sal_Int16 nMatchLevelTo ) const THROWDEF_RTE_IAE;
     565                 :            :                                     // converts fVal from this unit to rFrom unit
     566                 :            :                                     // throws exception if not from same class
     567                 :            :                                     // this implementation is for proportional cases only
     568                 :            :     virtual double          ConvertToBase( double fVal, sal_Int16 nMatchLevel ) const;
     569                 :            :     virtual double          ConvertFromBase( double fVal, sal_Int16 nMatchLevel ) const;
     570                 :            : 
     571                 :            :     inline ConvertDataClass Class( void ) const;
     572                 :            :     inline sal_Bool         IsPrefixSupport( void ) const;
     573                 :            : };
     574                 :            : 
     575                 :            : 
     576                 :            : 
     577                 :            : 
     578                 :            : class ConvertDataLinear : public ConvertData
     579                 :            : {
     580                 :            : protected:
     581                 :            :     double                  fOffs;
     582                 :            : public:
     583                 :            :     inline                  ConvertDataLinear(
     584                 :            :                                 const sal_Char      pUnitName[],
     585                 :            :                                 double              fConvertConstant,
     586                 :            :                                 double              fConvertOffset,
     587                 :            :                                 ConvertDataClass    eClass,
     588                 :            :                                 sal_Bool            bPrefSupport = sal_False );
     589                 :            : 
     590                 :            :     virtual                 ~ConvertDataLinear();
     591                 :            : 
     592                 :            :     virtual double          Convert( double fVal, const ConvertData& rTo,
     593                 :            :                                 sal_Int16 nMatchLevelFrom, sal_Int16 nMatchLevelTo ) const THROWDEF_RTE_IAE;
     594                 :            :                                     // for cases where f(x) = a + bx applies (e.g. Temperatures)
     595                 :            : 
     596                 :            :     virtual double          ConvertToBase( double fVal, sal_Int16 nMatchLevel ) const;
     597                 :            :     virtual double          ConvertFromBase( double fVal, sal_Int16 nMatchLevel ) const;
     598                 :            : };
     599                 :            : 
     600                 :            : 
     601                 :            : 
     602                 :            : 
     603                 :            : class ConvertDataList : protected MyList
     604                 :            : {
     605                 :            : private:
     606                 :            : protected:
     607                 :            :     inline ConvertData*     First( void );
     608                 :            :     inline ConvertData*     Next( void );
     609                 :            : public:
     610                 :            :                             ConvertDataList( void );
     611                 :            :     virtual                 ~ConvertDataList();
     612                 :            : 
     613                 :            :     double                  Convert( double fVal, const STRING& rFrom, const STRING& rTo ) THROWDEF_RTE_IAE;
     614                 :            : };
     615                 :            : 
     616                 :            : 
     617                 :            : 
     618                 :            : 
     619                 :          0 : inline sal_Bool IsLeapYear( sal_uInt16 n )
     620                 :            : {
     621 [ #  # ][ #  # ]:          0 :     return ( (( ( n % 4 ) == 0 ) && ( ( n % 100 ) != 0)) || ( ( n % 400 ) == 0 ) );
                 [ #  # ]
     622                 :            : }
     623                 :            : 
     624                 :            : 
     625                 :          0 : inline sal_Int32 GetDiffDate360( constREFXPS& xOpt, sal_Int32 nDate1, sal_Int32 nDate2, sal_Bool bUSAMethod )
     626                 :            : {
     627                 :          0 :     return GetDiffDate360( GetNullDate( xOpt ), nDate1, nDate2, bUSAMethod );
     628                 :            : }
     629                 :            : 
     630                 :            : 
     631                 :          0 : inline sal_Int16 GetDayOfWeek( sal_Int32 n )
     632                 :            : {   // monday = 0, ..., sunday = 6
     633                 :          0 :     return static_cast< sal_Int16 >( ( n - 1 ) % 7 );
     634                 :            : }
     635                 :            : 
     636                 :            : 
     637                 :          0 : inline double GetYearFrac( constREFXPS& xOpt, sal_Int32 nStartDate, sal_Int32 nEndDate, sal_Int32 nMode ) THROWDEF_RTE_IAE
     638                 :            : {
     639                 :          0 :     return GetYearFrac( GetNullDate( xOpt ), nStartDate, nEndDate, nMode );
     640                 :            : }
     641                 :            : 
     642                 :            : 
     643                 :            : inline void AlignDate( sal_uInt16& rD, sal_uInt16 nM, sal_uInt16 nY )
     644                 :            : {
     645                 :            :     sal_uInt16  nMax = DaysInMonth( nM, nY );
     646                 :            : 
     647                 :            :     if( rD > nMax )
     648                 :            :         rD = nMax;
     649                 :            : }
     650                 :            : 
     651                 :            : 
     652                 :       5151 : inline void MyList::Grow( void )
     653                 :            : {
     654         [ +  + ]:       5151 :     if( nNew >= nSize )
     655                 :        102 :         _Grow();
     656                 :       5151 : }
     657                 :            : 
     658                 :            : 
     659                 :     106248 : inline const void* MyList::GetObject( sal_uInt32 n ) const
     660                 :            : {
     661         [ +  - ]:     106248 :     if( n < nNew )
     662                 :     106248 :         return pData[ n ];
     663                 :            :     else
     664                 :     106248 :         return NULL;
     665                 :            : }
     666                 :            : 
     667                 :            : 
     668                 :        714 : inline const void* MyList::First( void )
     669                 :            : {
     670                 :        714 :     nAct = 0;
     671         [ +  - ]:        714 :     if( nNew )
     672                 :        714 :         return pData[ 0 ];
     673                 :            :     else
     674                 :        714 :         return NULL;
     675                 :            : }
     676                 :            : 
     677                 :            : 
     678                 :       2121 : inline const void* MyList::Next( void )
     679                 :            : {
     680                 :       2121 :     nAct++;
     681         [ +  + ]:       2121 :     if( nAct < nNew )
     682                 :       1407 :         return pData[ nAct ];
     683                 :            :     else
     684                 :            :     {
     685                 :        714 :         nAct--;
     686                 :       2121 :         return NULL;
     687                 :            :     }
     688                 :            : }
     689                 :            : 
     690                 :            : 
     691                 :       5151 : inline void MyList::Append( void* p )
     692                 :            : {
     693                 :       5151 :     Grow();
     694                 :       5151 :     pData[ nNew ] = p;
     695                 :       5151 :     nNew++;
     696                 :       5151 : }
     697                 :            : 
     698                 :            : 
     699                 :       1919 : inline sal_uInt32 MyList::Count( void ) const
     700                 :            : {
     701                 :       1919 :     return nNew;
     702                 :            : }
     703                 :            : 
     704                 :            : 
     705                 :            : 
     706                 :            : 
     707                 :        707 : inline const STRING* StringList::First( void )
     708                 :            : {
     709                 :        707 :     return ( const STRING* ) MyList::First();
     710                 :            : }
     711                 :            : 
     712                 :            : 
     713                 :       1414 : inline const STRING* StringList::Next( void )
     714                 :            : {
     715                 :       1414 :     return ( const STRING* ) MyList::Next();
     716                 :            : }
     717                 :            : 
     718                 :            : 
     719                 :        202 : inline const STRING* StringList::Get( sal_uInt32 n ) const
     720                 :            : {
     721                 :        202 :     return ( const STRING* ) MyList::GetObject( n );
     722                 :            : }
     723                 :            : 
     724                 :            : 
     725                 :            : inline void StringList::Append( STRING* p )
     726                 :            : {
     727                 :            :     MyList::Append( p );
     728                 :            : }
     729                 :            : 
     730                 :            : 
     731                 :       3434 : inline void StringList::Append( const STRING& r )
     732                 :            : {
     733                 :       3434 :     MyList::Append( new STRING( r ) );
     734                 :       3434 : }
     735                 :            : 
     736                 :            : 
     737                 :            : 
     738                 :            : 
     739                 :       1717 : inline sal_uInt16 FuncData::GetUINameID( void ) const
     740                 :            : {
     741                 :       1717 :     return nUINameID;
     742                 :            : }
     743                 :            : 
     744                 :            : 
     745                 :      11611 : inline sal_uInt16 FuncData::GetDescrID( void ) const
     746                 :            : {
     747                 :      11611 :     return nDescrID;
     748                 :            : }
     749                 :            : 
     750                 :            : 
     751                 :       1717 : inline sal_Bool FuncData::IsDouble( void ) const
     752                 :            : {
     753                 :       1717 :     return bDouble;
     754                 :            : }
     755                 :            : 
     756                 :            : 
     757                 :            : inline sal_Bool FuncData::HasIntParam( void ) const
     758                 :            : {
     759                 :            :     return bWithOpt;
     760                 :            : }
     761                 :            : 
     762                 :            : 
     763                 :      92718 : inline sal_Bool FuncData::Is( const ::rtl::OUString& r ) const
     764                 :            : {
     765                 :      92718 :     return aIntName == r;
     766                 :            : }
     767                 :            : 
     768                 :            : 
     769                 :        101 : inline const StringList& FuncData::GetCompNameList( void ) const
     770                 :            : {
     771                 :        101 :     return aCompList;
     772                 :            : }
     773                 :            : 
     774                 :            : 
     775                 :       1717 : inline FDCategory FuncData::GetCategory( void ) const
     776                 :            : {
     777                 :       1717 :     return eCat;
     778                 :            : }
     779                 :            : 
     780                 :            : 
     781                 :            : 
     782                 :            : 
     783                 :            : inline void CStrList::Append( const sal_Char* p )
     784                 :            : {
     785                 :            :     MyList::Append( ( void* ) p );
     786                 :            : }
     787                 :            : 
     788                 :            : 
     789                 :            : inline const sal_Char* CStrList::Get( sal_uInt32 n ) const
     790                 :            : {
     791                 :            :     return ( const sal_Char* ) MyList::GetObject( n );
     792                 :            : }
     793                 :            : 
     794                 :            : 
     795                 :            : 
     796                 :            : 
     797                 :       1717 : inline void FuncDataList::Append( FuncData* p )
     798                 :            : {
     799                 :       1717 :     MyList::Append( p );
     800                 :       1717 : }
     801                 :            : 
     802                 :            : 
     803                 :     106046 : inline const FuncData* FuncDataList::Get( sal_uInt32 n ) const
     804                 :            : {
     805                 :     106046 :     return ( const FuncData* ) MyList::GetObject( n );
     806                 :            : }
     807                 :            : 
     808                 :            : 
     809                 :          0 : inline Complex::Complex( double fReal, double fImag, sal_Unicode cC ) :
     810                 :          0 :         r( fReal ), i( fImag ), c( cC )
     811                 :            : {
     812                 :          0 : }
     813                 :            : 
     814                 :            : 
     815                 :          0 : inline double Complex::Real( void ) const
     816                 :            : {
     817                 :          0 :     return r;
     818                 :            : }
     819                 :            : 
     820                 :            : 
     821                 :          0 : inline double Complex::Imag( void ) const
     822                 :            : {
     823                 :          0 :     return i;
     824                 :            : }
     825                 :            : 
     826                 :            : 
     827                 :          0 : inline double Complex::Abs( void ) const
     828                 :            : {
     829                 :          0 :     return sqrt( r * r + i * i );
     830                 :            : }
     831                 :            : 
     832                 :            : 
     833                 :          0 : void Complex::Conjugate( void )
     834                 :            : {
     835                 :          0 :     i = -i;
     836                 :          0 : }
     837                 :            : 
     838                 :            : 
     839                 :          0 : inline void Complex::Mult( double f )
     840                 :            : {
     841                 :          0 :     i *= f;
     842                 :          0 :     r *= f;
     843                 :          0 : }
     844                 :            : 
     845                 :            : 
     846                 :          0 : inline void Complex::Mult( const Complex& rM )
     847                 :            : {
     848                 :          0 :     double  r_ = r;
     849                 :          0 :     double  i_ = i;
     850                 :            : 
     851                 :          0 :     r = r_ * rM.r - i_ * rM.i;
     852                 :          0 :     i = r_ * rM.i + i_ * rM.r;
     853                 :            : 
     854         [ #  # ]:          0 :     if( !c ) c = rM.c;
     855                 :          0 : }
     856                 :            : 
     857                 :            : 
     858                 :          0 : inline void Complex::Sub( const Complex& rC )
     859                 :            : {
     860                 :          0 :     r -= rC.r;
     861                 :          0 :     i -= rC.i;
     862         [ #  # ]:          0 :     if( !c ) c = rC.c;
     863                 :          0 : }
     864                 :            : 
     865                 :            : 
     866                 :          0 : inline void Complex::Add( const Complex& rAdd )
     867                 :            : {
     868                 :          0 :     r += rAdd.r;
     869                 :          0 :     i += rAdd.i;
     870         [ #  # ]:          0 :     if( !c ) c = rAdd.c;
     871                 :          0 : }
     872                 :            : 
     873                 :            : 
     874                 :            : 
     875                 :            : 
     876                 :            : inline const Complex* ComplexList::Get( sal_uInt32 n ) const
     877                 :            : {
     878                 :            :     return ( const Complex* ) MyList::GetObject( n );
     879                 :            : }
     880                 :            : 
     881                 :            : 
     882                 :          0 : inline const Complex* ComplexList::First( void )
     883                 :            : {
     884                 :          0 :     return ( const Complex* ) MyList::First();
     885                 :            : }
     886                 :            : 
     887                 :            : 
     888                 :          0 : inline const Complex* ComplexList::Next( void )
     889                 :            : {
     890                 :          0 :     return ( const Complex* ) MyList::Next();
     891                 :            : }
     892                 :            : 
     893                 :            : 
     894                 :          0 : inline void ComplexList::Append( Complex* p )
     895                 :            : {
     896                 :          0 :     MyList::Append( p );
     897                 :          0 : }
     898                 :            : 
     899                 :            : 
     900                 :            : 
     901                 :            : 
     902                 :          0 : inline ConvertDataClass ConvertData::Class( void ) const
     903                 :            : {
     904                 :          0 :     return eClass;
     905                 :            : }
     906                 :            : 
     907                 :            : 
     908                 :            : 
     909                 :          0 : inline sal_Bool ConvertData::IsPrefixSupport( void ) const
     910                 :            : {
     911                 :          0 :     return bPrefixSupport;
     912                 :            : }
     913                 :            : 
     914                 :          0 : inline ConvertDataLinear::ConvertDataLinear( const sal_Char* p, double fC, double fO, ConvertDataClass e,
     915                 :            :         sal_Bool bPrefSupport ) :
     916                 :            :     ConvertData( p, fC, e, bPrefSupport ),
     917                 :          0 :     fOffs( fO )
     918                 :            : {
     919                 :          0 : }
     920                 :            : 
     921                 :            : 
     922                 :            : 
     923                 :            : 
     924                 :          0 : inline ConvertData* ConvertDataList::First( void )
     925                 :            : {
     926                 :          0 :     return ( ConvertData* ) MyList::First();
     927                 :            : }
     928                 :            : 
     929                 :            : 
     930                 :          0 : inline ConvertData* ConvertDataList::Next( void )
     931                 :            : {
     932                 :          0 :     return ( ConvertData* ) MyList::Next();
     933                 :            : }
     934                 :            : 
     935                 :            : //-----------------------------------------------------------------------------
     936                 :            : 
     937                 :            : /// Helper class for date calculation for various financial functions
     938                 :            : class ScaDate
     939                 :            : {
     940                 :            : private:
     941                 :            :     sal_uInt16                  nOrigDay;           /// is the day of the original date.
     942                 :            :     sal_uInt16                  nDay;               /// is the calculated day depending on the current month/year.
     943                 :            :     sal_uInt16                  nMonth;             /// is the current month (one-based).
     944                 :            :     sal_uInt16                  nYear;              /// is the current year.
     945                 :            :     sal_Bool                    bLastDayMode : 1;   /// if sal_True, recalculate nDay after every calculation.
     946                 :            :     sal_Bool                    bLastDay : 1;       /// is sal_True, if original date was the last day in month.
     947                 :            :     sal_Bool                    b30Days : 1;        /// is sal_True, if every month has 30 days in calculations.
     948                 :            :     sal_Bool                    bUSMode : 1;        /// is sal_True, if the US method of 30-day-calculations is used.
     949                 :            : 
     950                 :            :                                 /// Calculates nDay from nOrigDay and current date.
     951                 :            :     void                        setDay();
     952                 :            : 
     953                 :            :                                 /// @return  count of days in current month
     954                 :            :     inline sal_uInt16           getDaysInMonth() const;
     955                 :            :                                 /// @return  count of days in given month
     956                 :            :     inline sal_uInt16           getDaysInMonth( sal_uInt16 _nMon ) const;
     957                 :            : 
     958                 :            :                                 /// @ return  count of days in the given month range
     959                 :            :     sal_Int32                   getDaysInMonthRange( sal_uInt16 nFrom, sal_uInt16 nTo ) const;
     960                 :            :                                 /// @ return  count of days in the given year range
     961                 :            :     sal_Int32                   getDaysInYearRange( sal_uInt16 nFrom, sal_uInt16 nTo ) const;
     962                 :            : 
     963                 :            :                                 /// Adds/subtracts the given count of years, does not adjust day.
     964                 :            :     void                        doAddYears( sal_Int32 nYearCount ) throw( ::com::sun::star::lang::IllegalArgumentException );
     965                 :            : 
     966                 :            : public:
     967                 :            :                                 ScaDate();
     968                 :            :                                 /** @param nBase
     969                 :            :                                         date handling mode (days in month / days in year):
     970                 :            :                                         0 = 30 days / 360 days (US NASD)
     971                 :            :                                         1 = exact / exact
     972                 :            :                                         2 = exact / 360
     973                 :            :                                         3 = exact / 365
     974                 :            :                                         4 = 30 days / 360 days (Europe)
     975                 :            :                                         5 = exact / exact (no last day adjustment) */
     976                 :            :                                 ScaDate( sal_Int32 nNullDate, sal_Int32 nDate, sal_Int32 nBase );
     977                 :            :                                 ScaDate( const ScaDate& rCopy );
     978                 :            :     ScaDate&                    operator=( const ScaDate& rCopy );
     979                 :            : 
     980                 :            :                                 /// @return  the current month.
     981                 :          0 :     inline sal_uInt16           getMonth() const    { return nMonth; };
     982                 :            :                                 /// @return  the current year.
     983                 :          0 :     inline sal_uInt16           getYear() const     { return nYear; };
     984                 :            : 
     985                 :            :                                 /// adds/subtracts the given count of months, adjusts day
     986                 :            :     void                        addMonths( sal_Int32 nMonthCount ) throw( ::com::sun::star::lang::IllegalArgumentException );
     987                 :            : 
     988                 :            :                                 /// sets the given year, adjusts day
     989                 :            :     inline void                 setYear( sal_uInt16 nNewYear );
     990                 :            :                                 /// adds/subtracts the given count of years, adjusts day
     991                 :            :     inline void                 addYears( sal_Int32 nYearCount ) throw( ::com::sun::star::lang::IllegalArgumentException );
     992                 :            : 
     993                 :            :                                 /// @return  the internal number of the current date
     994                 :            :     sal_Int32                   getDate( sal_Int32 nNullDate ) const;
     995                 :            :                                 /// @return  the number of days between the two dates
     996                 :            :     static sal_Int32            getDiff( const ScaDate& rFrom, const ScaDate& rTo ) throw( ::com::sun::star::lang::IllegalArgumentException );
     997                 :            : 
     998                 :            :     sal_Bool                    operator<( const ScaDate& rCmp ) const;
     999                 :          0 :     inline sal_Bool             operator<=( const ScaDate& rCmp ) const { return !(rCmp < *this); }
    1000                 :          0 :     inline sal_Bool             operator>( const ScaDate& rCmp ) const  { return rCmp < *this; }
    1001                 :            :     inline sal_Bool             operator>=( const ScaDate& rCmp ) const { return !(*this < rCmp); }
    1002                 :            : };
    1003                 :            : 
    1004                 :          0 : inline sal_uInt16 ScaDate::getDaysInMonth() const
    1005                 :            : {
    1006                 :          0 :     return getDaysInMonth( nMonth );
    1007                 :            : }
    1008                 :            : 
    1009                 :          0 : inline sal_uInt16 ScaDate::getDaysInMonth( sal_uInt16 _nMon ) const
    1010                 :            : {
    1011         [ #  # ]:          0 :     return b30Days ? 30 : DaysInMonth( _nMon, nYear );
    1012                 :            : }
    1013                 :            : 
    1014                 :          0 : inline void ScaDate::setYear( sal_uInt16 nNewYear )
    1015                 :            : {
    1016                 :          0 :     nYear = nNewYear;
    1017                 :          0 :     setDay();
    1018                 :          0 : }
    1019                 :            : 
    1020                 :          0 : inline void ScaDate::addYears( sal_Int32 nYearCount ) throw( ::com::sun::star::lang::IllegalArgumentException )
    1021                 :            : {
    1022                 :          0 :     doAddYears( nYearCount );
    1023                 :          0 :     setDay();
    1024                 :          0 : }
    1025                 :            : 
    1026                 :            : 
    1027                 :            : //-----------------------------------------------------------------------------
    1028                 :            : 
    1029                 :            : /// Helper class for Any->double conversion, using current language settings
    1030                 :            : class ScaAnyConverter
    1031                 :            : {
    1032                 :            : private:
    1033                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > xFormatter;
    1034                 :            :     sal_Int32                   nDefaultFormat;
    1035                 :            :     sal_Bool                    bHasValidFormat;
    1036                 :            : 
    1037                 :            :                                 /** Converts a string to double using the number formatter. If the formatter is not
    1038                 :            :                                     valid, ::rtl::math::stringToDouble() with english separators will be used.
    1039                 :            :                                     @throws com::sun::star::lang::IllegalArgumentException
    1040                 :            :                                         on strings not representing any double value.
    1041                 :            :                                     @return  the converted double value. */
    1042                 :            :     double                      convertToDouble(
    1043                 :            :                                     const ::rtl::OUString& rString ) const
    1044                 :            :                                 throw( ::com::sun::star::lang::IllegalArgumentException );
    1045                 :            : 
    1046                 :            : public:
    1047                 :            :                                 ScaAnyConverter(
    1048                 :            :                                     const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFact );
    1049                 :            :                                 ~ScaAnyConverter();
    1050                 :            : 
    1051                 :            :                                 /// Initializing with current language settings
    1052                 :            :     void                        init(
    1053                 :            :                                     const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xPropSet )
    1054                 :            :                                 throw( ::com::sun::star::uno::RuntimeException );
    1055                 :            : 
    1056                 :            :                                 /** Converts an Any to double (without initialization).
    1057                 :            :                                     The Any can be empty or contain a double or string.
    1058                 :            :                                     @throws com::sun::star::lang::IllegalArgumentException
    1059                 :            :                                         on other Any types or on invalid strings.
    1060                 :            :                                     @return  sal_True if the Any contains a double or a non-empty valid string,
    1061                 :            :                                              sal_False if the Any is empty or the string is empty */
    1062                 :            :     sal_Bool                    getDouble(
    1063                 :            :                                     double& rfResult,
    1064                 :            :                                     const ::com::sun::star::uno::Any& rAny ) const
    1065                 :            :                                 throw( ::com::sun::star::lang::IllegalArgumentException );
    1066                 :            : 
    1067                 :            :                                 /** Converts an Any to double (with initialization).
    1068                 :            :                                     The Any can be empty or contain a double or string.
    1069                 :            :                                     @throws com::sun::star::lang::IllegalArgumentException
    1070                 :            :                                         on other Any types or on invalid strings.
    1071                 :            :                                     @return  sal_True if the Any contains a double or a non-empty valid string,
    1072                 :            :                                              sal_False if the Any is empty or the string is empty */
    1073                 :            :     sal_Bool                    getDouble(
    1074                 :            :                                     double& rfResult,
    1075                 :            :                                     const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xPropSet,
    1076                 :            :                                     const ::com::sun::star::uno::Any& rAny )
    1077                 :            :                                 throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException );
    1078                 :            : 
    1079                 :            :                                 /** Converts an Any to double (with initialization).
    1080                 :            :                                     The Any can be empty or contain a double or string.
    1081                 :            :                                     @throws com::sun::star::lang::IllegalArgumentException
    1082                 :            :                                         on other Any types or on invalid strings.
    1083                 :            :                                     @return  the value of the double or string or fDefault if the Any or string is empty */
    1084                 :            :     double                      getDouble(
    1085                 :            :                                     const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xPropSet,
    1086                 :            :                                     const ::com::sun::star::uno::Any& rAny,
    1087                 :            :                                     double fDefault )
    1088                 :            :                                 throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException );
    1089                 :            : 
    1090                 :            :                                 /** Converts an Any to sal_Int32 (with initialization).
    1091                 :            :                                     The Any can be empty or contain a double or string.
    1092                 :            :                                     @throws com::sun::star::lang::IllegalArgumentException
    1093                 :            :                                         on other Any types or on invalid values or strings.
    1094                 :            :                                     @return  sal_True if the Any contains a double or a non-empty valid string,
    1095                 :            :                                              sal_False if the Any is empty or the string is empty */
    1096                 :            :     sal_Bool                    getInt32(
    1097                 :            :                                     sal_Int32& rnResult,
    1098                 :            :                                     const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xPropSet,
    1099                 :            :                                     const ::com::sun::star::uno::Any& rAny )
    1100                 :            :                                 throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException );
    1101                 :            : 
    1102                 :            :                                 /** Converts an Any to sal_Int32 (with initialization).
    1103                 :            :                                     The Any can be empty or contain a double or string.
    1104                 :            :                                     @throws com::sun::star::lang::IllegalArgumentException
    1105                 :            :                                         on other Any types or on invalid values or strings.
    1106                 :            :                                     @return  the truncated value of the double or string or nDefault if the Any or string is empty */
    1107                 :            :     sal_Int32                   getInt32(
    1108                 :            :                                     const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xPropSet,
    1109                 :            :                                     const ::com::sun::star::uno::Any& rAny,
    1110                 :            :                                     sal_Int32 nDefault )
    1111                 :            :                                 throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException );
    1112                 :            : };
    1113                 :            : 
    1114                 :            : 
    1115                 :            : //-----------------------------------------------------------------------------
    1116                 :            : 
    1117                 :            : 
    1118                 :            : #endif
    1119                 :            : 
    1120                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10