1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef ANALYSIS_HXX 25 #define ANALYSIS_HXX 26 27 28 #include <com/sun/star/sheet/XAddIn.hpp> 29 #include <com/sun/star/lang/XServiceName.hpp> 30 #include <com/sun/star/lang/XServiceInfo.hpp> 31 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 32 #include <com/sun/star/sheet/addin/XAnalysis.hpp> 33 #include <com/sun/star/sheet/LocalizedName.hpp> 34 #include <com/sun/star/sheet/XCompatibilityNames.hpp> 35 #include <com/sun/star/sheet/NoConvergenceException.hpp> 36 37 #include <cppuhelper/implbase5.hxx> // helper for implementations 38 39 #include "analysisdefs.hxx" 40 #include "analysishelper.hxx" 41 42 43 class FuncData; 44 class FuncDataList; 45 class ConvertDataList; 46 class ResMgr; 47 48 49 REF( CSS::uno::XInterface ) SAL_CALL AnalysisAddIn_CreateInstance( const REF( CSS::lang::XMultiServiceFactory )& ); 50 51 52 class AnalysisAddIn : public cppu::WeakImplHelper5< 53 CSS::sheet::XAddIn, 54 CSS::sheet::XCompatibilityNames, 55 CSS::sheet::addin::XAnalysis, 56 CSS::lang::XServiceName, 57 CSS::lang::XServiceInfo > 58 { 59 private: 60 CSS::lang::Locale aFuncLoc; 61 CSS::lang::Locale* pDefLocales; 62 FuncDataList* pFD; 63 double* pFactDoubles; 64 ConvertDataList* pCDL; 65 ResMgr* pResMgr; 66 67 ScaAnyConverter aAnyConv; 68 69 ResMgr& GetResMgr( void ); 70 STRING GetDisplFuncStr( sal_uInt16 nFuncNum ); 71 STRING GetFuncDescrStr( sal_uInt16 nResId, sal_uInt16 nStrIndex ); 72 void InitDefLocales( void ); 73 inline const CSS::lang::Locale& GetLocale( sal_uInt32 nInd ); 74 void InitData( void ); 75 76 /// Converts an Any to sal_Int32 in the range from 0 to 4 (date calculation mode). 77 sal_Int32 getDateMode( 78 const CSS::uno::Reference< CSS::beans::XPropertySet >& xPropSet, 79 const CSS::uno::Any& rAny ); 80 81 public: 82 AnalysisAddIn( 83 const CSS::uno::Reference< CSS::lang::XMultiServiceFactory >& xServiceFact ); 84 virtual ~AnalysisAddIn(); 85 86 double FactDouble( sal_Int32 nNum ); 87 88 static STRING getImplementationName_Static(); 89 static SEQ( STRING ) getSupportedServiceNames_Static(); 90 91 // XAddIn 92 virtual STRING SAL_CALL getProgrammaticFuntionName( const STRING& aDisplayName ); 93 virtual STRING SAL_CALL getDisplayFunctionName( const STRING& aProgrammaticName ); 94 virtual STRING SAL_CALL getFunctionDescription( const STRING& aProgrammaticName ); 95 virtual STRING SAL_CALL getDisplayArgumentName( const STRING& aProgrammaticFunctionName, sal_Int32 nArgument ); 96 virtual STRING SAL_CALL getArgumentDescription( const STRING& aProgrammaticFunctionName, sal_Int32 nArgument ); 97 virtual STRING SAL_CALL getProgrammaticCategoryName( const STRING& aProgrammaticFunctionName ); 98 virtual STRING SAL_CALL getDisplayCategoryName( const STRING& aProgrammaticFunctionName ); 99 100 // XCompatibilityNames 101 virtual SEQofLocName SAL_CALL getCompatibilityNames( const STRING& aProgrammaticName ); 102 103 // XLocalizable 104 virtual void SAL_CALL setLocale( const CSS::lang::Locale& eLocale ); 105 virtual CSS::lang::Locale SAL_CALL getLocale( ); 106 107 // XServiceName 108 virtual STRING SAL_CALL getServiceName( ); 109 110 // XServiceInfo 111 virtual STRING SAL_CALL getImplementationName( ); 112 virtual sal_Bool SAL_CALL supportsService( const STRING& ServiceName ); 113 virtual SEQ( STRING ) SAL_CALL getSupportedServiceNames( ); 114 115 // methods from own interfaces start here 116 117 // XAnalysis 118 // virtual double SAL_CALL get_Test( constREFXPS&, sal_Int32 nMode, double f1, double f2, double f3 ) THROWDEF_RTE; 119 120 virtual sal_Int32 SAL_CALL getWorkday( constREFXPS&, sal_Int32 nStartDate, sal_Int32 nDays, const ANY& aHDay ); 121 virtual double SAL_CALL getYearfrac( constREFXPS&, sal_Int32 nStartDate, sal_Int32 nEndDate, const ANY& aMode ); 122 virtual sal_Int32 SAL_CALL getEdate( constREFXPS&, sal_Int32 nStartDate, sal_Int32 nMonths ); 123 virtual sal_Int32 SAL_CALL getWeeknum( constREFXPS&, sal_Int32 nStartDate, sal_Int32 nMode ); 124 virtual sal_Int32 SAL_CALL getEomonth( constREFXPS&, sal_Int32 nStartDate, sal_Int32 nMonths ); 125 virtual sal_Int32 SAL_CALL getNetworkdays( constREFXPS&, sal_Int32 nStartDate, sal_Int32 nEndDate, const ANY& aHDay ); 126 127 virtual sal_Int32 SAL_CALL getIseven( sal_Int32 nVal ); 128 virtual sal_Int32 SAL_CALL getIsodd( sal_Int32 nVal ); 129 130 virtual double SAL_CALL getMultinomial( constREFXPS& xOpt, const SEQSEQ( sal_Int32 )& aVLst, const SEQ( com::sun::star::uno::Any )& aOptVLst ); 131 virtual double SAL_CALL getSeriessum( double fX, double fN, double fM, const SEQSEQ( double )& aCoeffList ); 132 virtual double SAL_CALL getQuotient( double fNum, double fDenum ); 133 134 virtual double SAL_CALL getMround( double fNum, double fMult ); 135 virtual double SAL_CALL getSqrtpi( double fNum ); 136 137 virtual double SAL_CALL getRandbetween( double fMin, double fMax ); 138 139 virtual double SAL_CALL getGcd( constREFXPS& xOpt, const SEQSEQ( double )& aVLst, const SEQ( ANY )& aOptVLst ); 140 virtual double SAL_CALL getLcm( constREFXPS& xOpt, const SEQSEQ( double )& aVLst, const SEQ( ANY )& aOptVLst ); 141 142 virtual double SAL_CALL getBesseli( double fNum, sal_Int32 nOrder ); 143 virtual double SAL_CALL getBesselj( double fNum, sal_Int32 nOrder ); 144 virtual double SAL_CALL getBesselk( double fNum, sal_Int32 nOrder ); 145 virtual double SAL_CALL getBessely( double fNum, sal_Int32 nOrder ); 146 147 virtual STRING SAL_CALL getBin2Oct( constREFXPS& xOpt, const STRING& aNum, const ANY& rPlaces ); 148 virtual double SAL_CALL getBin2Dec( const STRING& aNum ); 149 virtual STRING SAL_CALL getBin2Hex( constREFXPS& xOpt, const STRING& aNum, const ANY& rPlaces ); 150 151 virtual STRING SAL_CALL getOct2Bin( constREFXPS& xOpt, const STRING& aNum, const ANY& rPlaces ); 152 virtual double SAL_CALL getOct2Dec( const STRING& aNum ); 153 virtual STRING SAL_CALL getOct2Hex( constREFXPS& xOpt, const STRING& aNum, const ANY& rPlaces ); 154 155 virtual STRING SAL_CALL getDec2Bin( constREFXPS& xOpt, sal_Int32 fNum, const ANY& rPlaces ); 156 virtual STRING SAL_CALL getDec2Oct( constREFXPS& xOpt, sal_Int32 fNum, const ANY& rPlaces ); 157 virtual STRING SAL_CALL getDec2Hex( constREFXPS& xOpt, double fNum, const ANY& rPlaces ); 158 159 virtual STRING SAL_CALL getHex2Bin( constREFXPS& xOpt, const STRING& aNum, const ANY& rPlaces ); 160 virtual double SAL_CALL getHex2Dec( const STRING& aNum ); 161 virtual STRING SAL_CALL getHex2Oct( constREFXPS& xOpt, const STRING& aNum, const ANY& rPlaces ); 162 163 virtual sal_Int32 SAL_CALL getDelta( constREFXPS& xOpt, double fNum1, const ANY& rNum2 ); 164 165 virtual double SAL_CALL getErf( constREFXPS& xOpt, double fLowerLimit, const ANY& rUpperLimit ); 166 virtual double SAL_CALL getErfc( double fLowerLimit ); 167 168 virtual sal_Int32 SAL_CALL getGestep( constREFXPS& xOpt, double fNum, const ANY& rStep ); 169 170 virtual double SAL_CALL getFactdouble( sal_Int32 nNum ); 171 172 virtual double SAL_CALL getImabs( const STRING& aNum ); 173 virtual double SAL_CALL getImaginary( const STRING& aNum ); 174 virtual STRING SAL_CALL getImpower( const STRING& aNum, double fPower ); 175 virtual double SAL_CALL getImargument( const STRING& aNum ); 176 virtual STRING SAL_CALL getImcos( const STRING& aNum ); 177 virtual STRING SAL_CALL getImdiv( const STRING& aDivident, const STRING& aDivisor ); 178 virtual STRING SAL_CALL getImexp( const STRING& aNum ); 179 virtual STRING SAL_CALL getImconjugate( const STRING& aNum ); 180 virtual STRING SAL_CALL getImln( const STRING& aNum ); 181 virtual STRING SAL_CALL getImlog10( const STRING& aNum ); 182 virtual STRING SAL_CALL getImlog2( const STRING& aNum ); 183 virtual STRING SAL_CALL getImproduct( constREFXPS& xOpt, const SEQSEQ( STRING )& aNum1, const SEQ_ANY& aNumList ); 184 virtual double SAL_CALL getImreal( const STRING& aNum ); 185 virtual STRING SAL_CALL getImsin( const STRING& aNum ); 186 virtual STRING SAL_CALL getImsub( const STRING& aNum1, const STRING& aNum2 ); 187 virtual STRING SAL_CALL getImsum( constREFXPS& xOpt, const SEQSEQ( STRING )& aNum1, const SEQ( ANY )& aFollowingPars ); 188 189 virtual STRING SAL_CALL getImsqrt( const STRING& aNum ); 190 virtual STRING SAL_CALL getImtan( const STRING& aNum ); 191 virtual STRING SAL_CALL getImsec( const STRING& aNum ); 192 virtual STRING SAL_CALL getImcsc( const STRING& aNum ); 193 virtual STRING SAL_CALL getImcot( const STRING& aNum ); 194 virtual STRING SAL_CALL getImsinh( const STRING& aNum ); 195 virtual STRING SAL_CALL getImcosh( const STRING& aNum ); 196 virtual STRING SAL_CALL getImsech( const STRING& aNum ); 197 virtual STRING SAL_CALL getImcsch( const STRING& aNum ); 198 virtual STRING SAL_CALL getComplex( double fReal, double fImaginary, const ANY& rSuffix ); 199 200 virtual double SAL_CALL getConvert( double fVal, const STRING& aFromUnit, const STRING& aToUnit ); 201 202 virtual double SAL_CALL getAmordegrc( constREFXPS&, double fCost, sal_Int32 nDate, sal_Int32 nFirstPer, double fRestVal, double fPer, double fRate, const ANY& rOptBase ); 203 virtual double SAL_CALL getAmorlinc( constREFXPS&, double fCost, sal_Int32 nDate, sal_Int32 nFirstPer, double fRestVal, double fPer, double fRate, const ANY& rOptBase ); 204 virtual double SAL_CALL getAccrint( constREFXPS& xOpt, sal_Int32 nIssue, sal_Int32 nFirstInter, sal_Int32 nSettle, double fRate, const ANY& rVal, sal_Int32 nFreq, const ANY& rOptBase ); 205 virtual double SAL_CALL getAccrintm( constREFXPS& xOpt, sal_Int32 nIssue, sal_Int32 nSettle, double fRate, const ANY& rVal, const ANY& rOptBase ); 206 virtual double SAL_CALL getReceived( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, double fInvest, double fDisc, const ANY& rOptBase ); 207 virtual double SAL_CALL getDisc( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, double fPrice, double fRedemp, const ANY& rOptBase ); 208 virtual double SAL_CALL getDuration( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, double fCoup, double fYield, sal_Int32 nFreq, const ANY& rOptBase ); 209 virtual double SAL_CALL getEffect( double fNominal, sal_Int32 nPeriods ); 210 virtual double SAL_CALL getCumprinc( double fRate, sal_Int32 nNumPeriods, double fVal, sal_Int32 nStartPer, sal_Int32 nEndPer, sal_Int32 nPayType ); 211 virtual double SAL_CALL getCumipmt( double fRate, sal_Int32 nNumPeriods, double fVal, sal_Int32 nStartPer, sal_Int32 nEndPer, sal_Int32 nPayType ); 212 virtual double SAL_CALL getPrice( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, double fRate, double fYield, double fRedemp, sal_Int32 nFreq, const ANY& rOptBase ); 213 virtual double SAL_CALL getPricedisc( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, double fDisc, double fRedemp, const ANY& rOptBase ); 214 virtual double SAL_CALL getPricemat( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nIssue, double fRate, double fYield, const ANY& rOptBase ); 215 virtual double SAL_CALL getMduration( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, double fCoup, double fYield, sal_Int32 nFreq, const ANY& rOptBase ); 216 virtual double SAL_CALL getNominal( double fRate, sal_Int32 nPeriods ); 217 virtual double SAL_CALL getDollarfr( double fDollarDec, sal_Int32 nFrac ); 218 virtual double SAL_CALL getDollarde( double fDollarFrac, sal_Int32 nFrac ); 219 virtual double SAL_CALL getYield( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, double fCoup, double fPrice, double fRedemp, sal_Int32 nFreq, const ANY& rOptBase ); 220 virtual double SAL_CALL getYielddisc( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, double fPrice, double fRedemp, const ANY& rOptBase ); 221 virtual double SAL_CALL getYieldmat( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nIssue, double fRate, double fPrice, const ANY& rOptBase ); 222 virtual double SAL_CALL getTbilleq( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, double fDisc ); 223 virtual double SAL_CALL getTbillprice( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, double fDisc ); 224 virtual double SAL_CALL getTbillyield( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, double fPrice ); 225 virtual double SAL_CALL getOddfprice( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nIssue, sal_Int32 nFirstCoup, double fRate, double fYield, double fRedemp, sal_Int32 nFreq, const ANY& rOptBase ); 226 virtual double SAL_CALL getOddfyield( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nIssue, sal_Int32 nFirstCoup, double fRate, double fPrice, double fRedemp, sal_Int32 nFreq, const ANY& rOptBase ); 227 virtual double SAL_CALL getOddlprice( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nLastInterest, double fRate, double fYield, double fRedemp, sal_Int32 nFreq, const ANY& rOptBase ); 228 virtual double SAL_CALL getOddlyield( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nLastInterest, double fRate, double fPrice, double fRedemp, sal_Int32 nFreq, const ANY& rOptBase); 229 virtual double SAL_CALL getXirr( constREFXPS& xOpt, const SEQSEQ( double )& rValues, const SEQSEQ( sal_Int32 )& rDates, const ANY& rGuess ); 230 virtual double SAL_CALL getXnpv( double fRate, const SEQSEQ( double )& rValues, const SEQSEQ( sal_Int32 )& rDates ); 231 virtual double SAL_CALL getIntrate( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, double fInvest, double fRedemp, const ANY& rOptBase ); 232 virtual double SAL_CALL getCoupncd( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq, const ANY& rOptBase ); 233 virtual double SAL_CALL getCoupdays( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq, const ANY& rOptBase ); 234 virtual double SAL_CALL getCoupdaysnc( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq, const ANY& rOptBase ); 235 virtual double SAL_CALL getCoupdaybs( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq, const ANY& rOptBase ); 236 virtual double SAL_CALL getCouppcd( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq, const ANY& rOptBase ); 237 virtual double SAL_CALL getCoupnum( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq, const ANY& rOptBase ); 238 virtual double SAL_CALL getFvschedule( double fPrinc, const SEQSEQ( double )& rSchedule ); 239 }; 240 241 //------------------------------------------------------------------ 242 243 #endif 244