LibreOffice Module scaddins (master) 1
analysis.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include "analysisdefs.hxx"
21#include "analysis.hxx"
22#include "bessel.hxx"
23#include <comphelper/random.hxx>
25#include <cppuhelper/weak.hxx>
26#include <o3tl/any.hxx>
27#include <rtl/math.hxx>
28#include <sal/macros.h>
29#include <unotools/resmgr.hxx>
31#include <algorithm>
32#include <cmath>
33#include <float.h>
34
35constexpr OUStringLiteral ADDIN_SERVICE = u"com.sun.star.sheet.AddIn";
36constexpr OUStringLiteral MY_SERVICE = u"com.sun.star.sheet.addin.Analysis";
37constexpr OUStringLiteral MY_IMPLNAME = u"com.sun.star.sheet.addin.AnalysisImpl";
38
39using namespace ::com::sun::star;
40using namespace sca::analysis;
41
42OUString AnalysisAddIn::GetFuncDescrStr(const TranslateId* pResId, sal_uInt16 nStrIndex)
43{
44 return AnalysisResId(pResId[nStrIndex - 1]);
45}
46
48{
50
51 pFD.reset(new FuncDataList);
53
54 pDefLocales.reset();
55}
56
57AnalysisAddIn::AnalysisAddIn( const uno::Reference< uno::XComponentContext >& xContext ) :
59 aAnyConv( xContext )
60{
61}
62
64{
65}
66
68 const uno::Reference< beans::XPropertySet >& xPropSet,
69 const uno::Any& rAny )
70{
71 sal_Int32 nMode = aAnyConv.getInt32( xPropSet, rAny, 0 );
72 if( (nMode < 0) || (nMode > 4) )
73 throw lang::IllegalArgumentException();
74 return nMode;
75}
76
77#define MAXFACTDOUBLE 300
78
79double AnalysisAddIn::FactDouble( sal_Int32 nNum )
80{
81 if( nNum < 0 || nNum > MAXFACTDOUBLE )
82 throw lang::IllegalArgumentException();
83
84 if( !pFactDoubles )
85 {
86 pFactDoubles.reset( new double[ MAXFACTDOUBLE + 1 ] );
87
88 pFactDoubles[ 0 ] = 1.0; // by default
89
90 double fOdd = 1.0;
91 double fEven = 2.0;
92
93 pFactDoubles[ 1 ] = fOdd;
94 pFactDoubles[ 2 ] = fEven;
95
96 bool bOdd = true;
97
98 for( sal_uInt16 nCnt = 3 ; nCnt <= MAXFACTDOUBLE ; nCnt++ )
99 {
100 if( bOdd )
101 {
102 fOdd *= nCnt;
103 pFactDoubles[ nCnt ] = fOdd;
104 }
105 else
106 {
107 fEven *= nCnt;
108 pFactDoubles[ nCnt ] = fEven;
109 }
110
111 bOdd = !bOdd;
112
113 }
114 }
115
116 return pFactDoubles[ nNum ];
117}
118
119// XServiceName
121{
122 // name of specific AddIn service
123 return MY_SERVICE;
124}
125
126// XServiceInfo
128{
129 return MY_IMPLNAME;
130}
131
132sal_Bool SAL_CALL AnalysisAddIn::supportsService( const OUString& aName )
133{
134 return cppu::supportsService(this, aName);
135}
136
137uno::Sequence< OUString > SAL_CALL AnalysisAddIn::getSupportedServiceNames()
138{
139 return { ADDIN_SERVICE, MY_SERVICE };
140}
141
142// XLocalizable
143void SAL_CALL AnalysisAddIn::setLocale( const lang::Locale& eLocale )
144{
145 aFuncLoc = eLocale;
146
147 InitData(); // change of locale invalidates resources!
148}
149
150lang::Locale SAL_CALL AnalysisAddIn::getLocale()
151{
152 return aFuncLoc;
153}
154
155// XAddIn
156OUString SAL_CALL AnalysisAddIn::getProgrammaticFuntionName( const OUString& )
157{
158 // not used by calc
159 // (but should be implemented for other uses of the AddIn service)
160
161 return OUString();
162}
163
164OUString SAL_CALL AnalysisAddIn::getDisplayFunctionName( const OUString& aProgrammaticName )
165{
166 OUString aRet;
167
168 auto it = std::find_if(pFD->begin(), pFD->end(), FindFuncData( aProgrammaticName ) );
169 if( it != pFD->end() )
170 {
171 aRet = AnalysisResId(it->GetUINameID());
172 if( it->IsDouble() )
173 {
174 const OUString& rSuffix = it->GetSuffix();
175 if (!rSuffix.isEmpty())
176 aRet += rSuffix;
177 else
178 aRet += "_ADD";
179 }
180 }
181 else
182 {
183 aRet = "UNKNOWNFUNC_" + aProgrammaticName;
184 }
185
186 return aRet;
187}
188
189OUString SAL_CALL AnalysisAddIn::getFunctionDescription( const OUString& aProgrammaticName )
190{
191 OUString aRet;
192
193 auto it = std::find_if(pFD->begin(), pFD->end(), FindFuncData( aProgrammaticName ) );
194 if( it != pFD->end() )
195 aRet = GetFuncDescrStr( it->GetDescrID(), 1 );
196
197 return aRet;
198}
199
200OUString SAL_CALL AnalysisAddIn::getDisplayArgumentName( const OUString& aName, sal_Int32 nArg )
201{
202 OUString aRet;
203
204 auto it = std::find_if(pFD->begin(), pFD->end(), FindFuncData( aName ) );
205 if( it != pFD->end() && nArg <= 0xFFFF )
206 {
207 sal_uInt16 nStr = it->GetStrIndex( sal_uInt16( nArg ) );
208 if( nStr )
209 aRet = GetFuncDescrStr( it->GetDescrID(), nStr );
210 else
211 aRet = "internal";
212 }
213
214 return aRet;
215}
216
217OUString SAL_CALL AnalysisAddIn::getArgumentDescription( const OUString& aName, sal_Int32 nArg )
218{
219 OUString aRet;
220
221 auto it = std::find_if(pFD->begin(), pFD->end(), FindFuncData( aName ) );
222 if( it != pFD->end() && nArg <= 0xFFFF )
223 {
224 sal_uInt16 nStr = it->GetStrIndex( sal_uInt16( nArg ) );
225 if( nStr )
226 aRet = GetFuncDescrStr( it->GetDescrID(), nStr + 1 );
227 else
228 aRet = "for internal use only";
229 }
230
231 return aRet;
232}
233
234constexpr OUStringLiteral pDefCatName = u"Add-In";
235
236OUString SAL_CALL AnalysisAddIn::getProgrammaticCategoryName( const OUString& aName )
237{
238 // return non-translated strings
239 // return OUString( "Add-In" );
240 auto it = std::find_if(pFD->begin(), pFD->end(), FindFuncData( aName ) );
241 OUString aRet;
242 if( it != pFD->end() )
243 {
244 switch( it->GetCategory() )
245 {
246 case FDCategory::DateTime: aRet = "Date&Time"; break;
247 case FDCategory::Finance: aRet = "Financial"; break;
248 case FDCategory::Inf: aRet = "Information"; break;
249 case FDCategory::Math: aRet = "Mathematical"; break;
250 case FDCategory::Tech: aRet = "Technical"; break;
251 }
252 }
253 else
254 aRet = pDefCatName;
255
256 return aRet;
257}
258
259OUString SAL_CALL AnalysisAddIn::getDisplayCategoryName( const OUString& aProgrammaticFunctionName )
260{
261 // return translated strings, not used for predefined categories
262 auto it = std::find_if(pFD->begin(), pFD->end(), FindFuncData( aProgrammaticFunctionName ) );
263 OUString aRet;
264 if( it != pFD->end() )
265 {
266 switch( it->GetCategory() )
267 {
268 case FDCategory::DateTime: aRet = "Date&Time"; break;
269 case FDCategory::Finance: aRet = "Financial"; break;
270 case FDCategory::Inf: aRet = "Information"; break;
271 case FDCategory::Math: aRet = "Mathematical"; break;
272 case FDCategory::Tech: aRet = "Technical"; break;
273 }
274 }
275 else
276 aRet = pDefCatName;
277
278 return aRet;
279}
280
281static const char* pLang[] = { "de", "en" };
282static const char* pCoun[] = { "DE", "US" };
283const sal_uInt32 nNumOfLoc = SAL_N_ELEMENTS(pLang);
284
286{
287 pDefLocales.reset( new lang::Locale[ nNumOfLoc ] );
288
289 for( sal_uInt32 n = 0 ; n < nNumOfLoc ; n++ )
290 {
291 pDefLocales[ n ].Language = OUString::createFromAscii( pLang[ n ] );
292 pDefLocales[ n ].Country = OUString::createFromAscii( pCoun[ n ] );
293 }
294}
295
296inline const lang::Locale& AnalysisAddIn::GetLocale( sal_uInt32 nInd )
297{
298 if( !pDefLocales )
300
301 if( nInd < nNumOfLoc )
302 return pDefLocales[ nInd ];
303 else
304 return aFuncLoc;
305}
306
307uno::Sequence< sheet::LocalizedName > SAL_CALL AnalysisAddIn::getCompatibilityNames( const OUString& aProgrammaticName )
308{
309 auto it = std::find_if(pFD->begin(), pFD->end(), FindFuncData( aProgrammaticName ) );
310 if( it == pFD->end() )
311 return uno::Sequence< sheet::LocalizedName >( 0 );
312
313 const std::vector<OUString>& r = it->GetCompNameList();
314 sal_uInt32 nCount = r.size();
315
316 uno::Sequence< sheet::LocalizedName > aRet( nCount );
317
318 sheet::LocalizedName* pArray = aRet.getArray();
319
320 for( sal_uInt32 n = 0 ; n < nCount ; n++ )
321 {
322 pArray[ n ] = sheet::LocalizedName( GetLocale( n ), r[n] );
323 }
324
325 return aRet;
326}
327
328// XAnalysis
330sal_Int32 SAL_CALL AnalysisAddIn::getWorkday( const uno::Reference< beans::XPropertySet >& xOptions,
331 sal_Int32 nDate, sal_Int32 nDays, const uno::Any& aHDay )
332{
333 if( !nDays )
334 return nDate;
335
336 sal_Int32 nNullDate = GetNullDate( xOptions );
337
339
340 aSrtLst.InsertHolidayList( aAnyConv, xOptions, aHDay, nNullDate );
341
342 sal_Int32 nActDate = nDate + nNullDate;
343
344 if( nDays > 0 )
345 {
346 if( GetDayOfWeek( nActDate ) == 5 )
347 // when starting on Saturday, assuming we're starting on Sunday to get the jump over the weekend
348 nActDate++;
349
350 while( nDays )
351 {
352 nActDate++;
353
354 if( GetDayOfWeek( nActDate ) < 5 )
355 {
356 if( !aSrtLst.Find( nActDate ) )
357 nDays--;
358 }
359 else
360 nActDate++; // jump over weekend
361 }
362 }
363 else
364 {
365 if( GetDayOfWeek( nActDate ) == 6 )
366 // when starting on Sunday, assuming we're starting on Saturday to get the jump over the weekend
367 nActDate--;
368
369 while( nDays )
370 {
371 nActDate--;
372
373 if( GetDayOfWeek( nActDate ) < 5 )
374 {
375 if( !aSrtLst.Find( nActDate ) )
376 nDays++;
377 }
378 else
379 nActDate--; // jump over weekend
380 }
381 }
382
383 return nActDate - nNullDate;
384}
385
387double SAL_CALL AnalysisAddIn::getYearfrac( const uno::Reference< beans::XPropertySet >& xOpt,
388 sal_Int32 nStartDate, sal_Int32 nEndDate, const uno::Any& rMode )
389{
390 double fRet = GetYearFrac( xOpt, nStartDate, nEndDate, getDateMode( xOpt, rMode ) );
391 return finiteOrThrow( fRet );
392}
393
394sal_Int32 SAL_CALL AnalysisAddIn::getEdate( const uno::Reference< beans::XPropertySet >& xOpt, sal_Int32 nStartDate, sal_Int32 nMonths )
395{
396 sal_Int32 nNullDate = GetNullDate( xOpt );
397 ScaDate aDate( nNullDate, nStartDate, 5 );
398 aDate.addMonths( nMonths );
399 return aDate.getDate( nNullDate );
400}
401
402sal_Int32 SAL_CALL AnalysisAddIn::getWeeknum( const uno::Reference< beans::XPropertySet >& xOpt, sal_Int32 nDate, sal_Int32 nMode )
403{
404 nDate += GetNullDate( xOpt );
405
406 sal_uInt16 nDay, nMonth, nYear;
407 DaysToDate( nDate, nDay, nMonth, nYear );
408
409 sal_Int32 nFirstInYear = DateToDays( 1, 1, nYear );
410 sal_uInt16 nFirstDayInYear = GetDayOfWeek( nFirstInYear );
411
412 return ( nDate - nFirstInYear + ( ( nMode == 1 )? ( nFirstDayInYear + 1 ) % 7 : nFirstDayInYear ) ) / 7 + 1;
413}
414
415sal_Int32 SAL_CALL AnalysisAddIn::getEomonth( const uno::Reference< beans::XPropertySet >& xOpt, sal_Int32 nDate, sal_Int32 nMonths )
416{
417 sal_Int32 nNullDate = GetNullDate( xOpt );
418 nDate += nNullDate;
419 sal_uInt16 nDay, nMonth, nYear;
420 DaysToDate( nDate, nDay, nMonth, nYear );
421
422 sal_Int32 nNewMonth = nMonth + nMonths;
423
424 if( nNewMonth > 12 )
425 {
426 nYear = sal::static_int_cast<sal_uInt16>( nYear + ( nNewMonth / 12 ) );
427 nNewMonth %= 12;
428 }
429 else if( nNewMonth < 1 )
430 {
431 nNewMonth = -nNewMonth;
432 nYear = sal::static_int_cast<sal_uInt16>( nYear - ( nNewMonth / 12 ) );
433 nYear--;
434 nNewMonth %= 12;
435 nNewMonth = 12 - nNewMonth;
436 }
437
438 return DateToDays( DaysInMonth( sal_uInt16( nNewMonth ), nYear ), sal_uInt16( nNewMonth ), nYear ) - nNullDate;
439}
440
441sal_Int32 SAL_CALL AnalysisAddIn::getNetworkdays( const uno::Reference< beans::XPropertySet >& xOpt,
442 sal_Int32 nStartDate, sal_Int32 nEndDate, const uno::Any& aHDay )
443{
444 sal_Int32 nNullDate = GetNullDate( xOpt );
445
447
448 aSrtLst.InsertHolidayList( aAnyConv, xOpt, aHDay, nNullDate );
449
450 sal_Int32 nActDate = nStartDate + nNullDate;
451 sal_Int32 nStopDate = nEndDate + nNullDate;
452 sal_Int32 nCnt = 0;
453
454 if( nActDate <= nStopDate )
455 {
456 while( nActDate <= nStopDate )
457 {
458 if( GetDayOfWeek( nActDate ) < 5 && !aSrtLst.Find( nActDate ) )
459 nCnt++;
460
461 nActDate++;
462 }
463 }
464 else
465 {
466 while( nActDate >= nStopDate )
467 {
468 if( GetDayOfWeek( nActDate ) < 5 && !aSrtLst.Find( nActDate ) )
469 nCnt--;
470
471 nActDate--;
472 }
473 }
474
475 return nCnt;
476}
477
478sal_Int32 SAL_CALL AnalysisAddIn::getIseven( sal_Int32 nVal )
479{
480 return ( nVal & 0x00000001 )? 0 : 1;
481}
482
483sal_Int32 SAL_CALL AnalysisAddIn::getIsodd( sal_Int32 nVal )
484{
485 return ( nVal & 0x00000001 )? 1 : 0;
486}
487
488double SAL_CALL
489AnalysisAddIn::getMultinomial( const uno::Reference< beans::XPropertySet >& xOpt, const uno::Sequence< uno::Sequence< sal_Int32 > >& aVLst,
490 const uno::Sequence< uno::Any >& aOptVLst )
491{
492 ScaDoubleListGE0 aValList;
493
494 aValList.Append( aVLst );
495 aValList.Append( aAnyConv, xOpt, aOptVLst );
496
497 if( aValList.Count() == 0 )
498 return 0.0;
499
500 double nZ = 0;
501 double fRet = 1.0;
502
503 for( sal_uInt32 i = 0; i < aValList.Count(); ++i )
504 {
505 const double d = aValList.Get(i);
506 double n = (d >= 0.0) ? rtl::math::approxFloor( d ) : rtl::math::approxCeil( d );
507 if ( n < 0.0 )
508 throw lang::IllegalArgumentException();
509
510 if( n > 0.0 )
511 {
512 nZ += n;
513 fRet *= BinomialCoefficient(nZ, n);
514 }
515 }
516 return finiteOrThrow( fRet );
517}
518
519double SAL_CALL AnalysisAddIn::getSeriessum( double fX, double fN, double fM, const uno::Sequence< uno::Sequence< double > >& aCoeffList )
520{
521 double fRet = 0.0;
522
523 // #i32269# 0^0 is undefined, Excel returns #NUM! error
524 if( fX == 0.0 && fN == 0 )
525 throw uno::RuntimeException("undefined expression: 0^0");
526
527 if( fX != 0.0 )
528 {
529 for( const uno::Sequence< double >& rList : aCoeffList )
530 {
531 for( const double fCoef : rList )
532 {
533 fRet += fCoef * pow( fX, fN );
534
535 fN += fM;
536 }
537 }
538 }
539
540 return finiteOrThrow( fRet );
541}
542
543double SAL_CALL AnalysisAddIn::getQuotient( double fNum, double fDenom )
544{
545 double fRet;
546 if( (fNum < 0) != (fDenom < 0) )
547 fRet = ::rtl::math::approxCeil( fNum / fDenom );
548 else
549 fRet = ::rtl::math::approxFloor( fNum / fDenom );
550 return finiteOrThrow( fRet );
551}
552
553double SAL_CALL AnalysisAddIn::getMround( double fNum, double fMult )
554{
555 if( fMult == 0.0 )
556 return fMult;
557
558 double fRet = fMult * ::rtl::math::round( ::rtl::math::approxValue( fNum / fMult));
559 return finiteOrThrow( fRet );
560}
561
562double SAL_CALL AnalysisAddIn::getSqrtpi( double fNum )
563{
564 double fRet = sqrt( fNum * M_PI );
565 return finiteOrThrow( fRet );
566}
567
568double SAL_CALL AnalysisAddIn::getRandbetween( double fMin, double fMax )
569{
570 fMin = ::rtl::math::round( fMin, 0, rtl_math_RoundingMode_Up );
571 fMax = ::rtl::math::round( fMax, 0, rtl_math_RoundingMode_Up );
572 if( fMin > fMax )
573 throw lang::IllegalArgumentException();
574
575 double fRet = floor(comphelper::rng::uniform_real_distribution(fMin, nextafter(fMax+1, -DBL_MAX)));
576 return finiteOrThrow( fRet );
577}
578
579double SAL_CALL AnalysisAddIn::getGcd( const uno::Reference< beans::XPropertySet >& xOpt, const uno::Sequence< uno::Sequence< double > >& aVLst, const uno::Sequence< uno::Any >& aOptVLst )
580{
581 ScaDoubleListGT0 aValList;
582
583 aValList.Append( aVLst );
584 aValList.Append( aAnyConv, xOpt, aOptVLst );
585
586 if( aValList.Count() == 0 )
587 return 0.0;
588
589 double f = aValList.Get(0);
590 for( sal_uInt32 i = 1; i < aValList.Count(); ++i )
591 {
592 f = GetGcd( aValList.Get(i), f );
593 }
594
595 return finiteOrThrow( f );
596}
597
598double SAL_CALL AnalysisAddIn::getLcm( const uno::Reference< beans::XPropertySet >& xOpt, const uno::Sequence< uno::Sequence< double > >& aVLst, const uno::Sequence< uno::Any >& aOptVLst )
599{
600 ScaDoubleListGE0 aValList;
601
602 aValList.Append( aVLst );
603 aValList.Append( aAnyConv, xOpt, aOptVLst );
604
605 if( aValList.Count() == 0 )
606 return 0.0;
607
608 double f = rtl::math::approxFloor( aValList.Get(0) );
609 if( f < 0.0 )
610 throw lang::IllegalArgumentException();
611
612 if( f == 0.0 )
613 return f;
614
615 for( sal_uInt32 i = 1; i < aValList.Count(); ++i )
616 {
617 double fTmp = rtl::math::approxFloor( aValList.Get(i) );
618 if( fTmp < 0.0 )
619 throw lang::IllegalArgumentException();
620
621 f = fTmp * f / GetGcd( fTmp, f );
622 if( f == 0.0 )
623 return f;
624 }
625
626 return finiteOrThrow( f );
627}
628
629double SAL_CALL AnalysisAddIn::getBesseli( double fNum, sal_Int32 nOrder )
630{
631 double fRet = sca::analysis::BesselI( fNum, nOrder );
632 return finiteOrThrow( fRet );
633}
634
635double SAL_CALL AnalysisAddIn::getBesselj( double fNum, sal_Int32 nOrder )
636{
637 double fRet = sca::analysis::BesselJ( fNum, nOrder );
638 return finiteOrThrow( fRet );
639}
640
641double SAL_CALL AnalysisAddIn::getBesselk( double fNum, sal_Int32 nOrder )
642{
643 if( nOrder < 0 || fNum <= 0.0 )
644 throw lang::IllegalArgumentException();
645
646 double fRet = sca::analysis::BesselK( fNum, nOrder );
647 return finiteOrThrow( fRet );
648}
649
650double SAL_CALL AnalysisAddIn::getBessely( double fNum, sal_Int32 nOrder )
651{
652 if( nOrder < 0 || fNum <= 0.0 )
653 throw lang::IllegalArgumentException();
654
655 double fRet = sca::analysis::BesselY( fNum, nOrder );
656 return finiteOrThrow( fRet );
657}
658
659const double SCA_MAX2 = 511.0; // min. val for binary numbers (9 bits + sign)
660const double SCA_MIN2 = -SCA_MAX2-1.0; // min. val for binary numbers (9 bits + sign)
661const double SCA_MAX8 = 536870911.0; // max. val for octal numbers (29 bits + sign)
662const double SCA_MIN8 = -SCA_MAX8-1.0; // min. val for octal numbers (29 bits + sign)
663const double SCA_MAX16 = 549755813887.0; // max. val for hexadecimal numbers (39 bits + sign)
664const double SCA_MIN16 = -SCA_MAX16-1.0; // min. val for hexadecimal numbers (39 bits + sign)
665const sal_Int32 SCA_MAXPLACES = 10; // max. number of places
666
667OUString SAL_CALL AnalysisAddIn::getBin2Oct( const uno::Reference< beans::XPropertySet >& xOpt, const OUString& aNum, const uno::Any& rPlaces )
668{
669 double fVal = ConvertToDec( aNum, 2, SCA_MAXPLACES );
670 sal_Int32 nPlaces = 0;
671 bool bUsePlaces = aAnyConv.getInt32( nPlaces, xOpt, rPlaces );
672 return ConvertFromDec( fVal, SCA_MIN8, SCA_MAX8, 8, nPlaces, SCA_MAXPLACES, bUsePlaces );
673}
674
675double SAL_CALL AnalysisAddIn::getBin2Dec( const OUString& aNum )
676{
677 double fRet = ConvertToDec( aNum, 2, SCA_MAXPLACES );
678 return finiteOrThrow( fRet );
679}
680
681OUString SAL_CALL AnalysisAddIn::getBin2Hex( const uno::Reference< beans::XPropertySet >& xOpt, const OUString& aNum, const uno::Any& rPlaces )
682{
683 double fVal = ConvertToDec( aNum, 2, SCA_MAXPLACES );
684 sal_Int32 nPlaces = 0;
685 bool bUsePlaces = aAnyConv.getInt32( nPlaces, xOpt, rPlaces );
686 return ConvertFromDec( fVal, SCA_MIN16, SCA_MAX16, 16, nPlaces, SCA_MAXPLACES, bUsePlaces );
687}
688
689OUString SAL_CALL AnalysisAddIn::getOct2Bin( const uno::Reference< beans::XPropertySet >& xOpt, const OUString& aNum, const uno::Any& rPlaces )
690{
691 double fVal = ConvertToDec( aNum, 8, SCA_MAXPLACES );
692 sal_Int32 nPlaces = 0;
693 bool bUsePlaces = aAnyConv.getInt32( nPlaces, xOpt, rPlaces );
694 return ConvertFromDec( fVal, SCA_MIN2, SCA_MAX2, 2, nPlaces, SCA_MAXPLACES, bUsePlaces );
695}
696
697double SAL_CALL AnalysisAddIn::getOct2Dec( const OUString& aNum )
698{
699 double fRet = ConvertToDec( aNum, 8, SCA_MAXPLACES );
700 return finiteOrThrow( fRet );
701}
702
703OUString SAL_CALL AnalysisAddIn::getOct2Hex( const uno::Reference< beans::XPropertySet >& xOpt, const OUString& aNum, const uno::Any& rPlaces )
704{
705 double fVal = ConvertToDec( aNum, 8, SCA_MAXPLACES );
706 sal_Int32 nPlaces = 0;
707 bool bUsePlaces = aAnyConv.getInt32( nPlaces, xOpt, rPlaces );
708 return ConvertFromDec( fVal, SCA_MIN16, SCA_MAX16, 16, nPlaces, SCA_MAXPLACES, bUsePlaces );
709}
710
711OUString SAL_CALL AnalysisAddIn::getDec2Bin( const uno::Reference< beans::XPropertySet >& xOpt, sal_Int32 nNum, const uno::Any& rPlaces )
712{
713 sal_Int32 nPlaces = 0;
714 bool bUsePlaces = aAnyConv.getInt32( nPlaces, xOpt, rPlaces );
715 return ConvertFromDec( nNum, SCA_MIN2, SCA_MAX2, 2, nPlaces, SCA_MAXPLACES, bUsePlaces );
716}
717
718OUString SAL_CALL AnalysisAddIn::getDec2Oct( const uno::Reference< beans::XPropertySet >& xOpt, sal_Int32 nNum, const uno::Any& rPlaces )
719{
720 sal_Int32 nPlaces = 0;
721 bool bUsePlaces = aAnyConv.getInt32( nPlaces, xOpt, rPlaces );
722 return ConvertFromDec( nNum, SCA_MIN8, SCA_MAX8, 8, nPlaces, SCA_MAXPLACES, bUsePlaces );
723}
724
725OUString SAL_CALL AnalysisAddIn::getDec2Hex( const uno::Reference< beans::XPropertySet >& xOpt, double fNum, const uno::Any& rPlaces )
726{
727 sal_Int32 nPlaces = 0;
728 bool bUsePlaces = aAnyConv.getInt32( nPlaces, xOpt, rPlaces );
729 return ConvertFromDec( fNum, SCA_MIN16, SCA_MAX16, 16, nPlaces, SCA_MAXPLACES, bUsePlaces );
730}
731
732OUString SAL_CALL AnalysisAddIn::getHex2Bin( const uno::Reference< beans::XPropertySet >& xOpt, const OUString& aNum, const uno::Any& rPlaces )
733{
734 double fVal = ConvertToDec( aNum, 16, SCA_MAXPLACES );
735 sal_Int32 nPlaces = 0;
736 bool bUsePlaces = aAnyConv.getInt32( nPlaces, xOpt, rPlaces );
737 return ConvertFromDec( fVal, SCA_MIN2, SCA_MAX2, 2, nPlaces, SCA_MAXPLACES, bUsePlaces );
738}
739
740double SAL_CALL AnalysisAddIn::getHex2Dec( const OUString& aNum )
741{
742 double fRet = ConvertToDec( aNum, 16, SCA_MAXPLACES );
743 return finiteOrThrow( fRet );
744}
745
746OUString SAL_CALL AnalysisAddIn::getHex2Oct( const uno::Reference< beans::XPropertySet >& xOpt, const OUString& aNum, const uno::Any& rPlaces )
747{
748 double fVal = ConvertToDec( aNum, 16, SCA_MAXPLACES );
749 sal_Int32 nPlaces = 0;
750 bool bUsePlaces = aAnyConv.getInt32( nPlaces, xOpt, rPlaces );
751 return ConvertFromDec( fVal, SCA_MIN8, SCA_MAX8, 8, nPlaces, SCA_MAXPLACES, bUsePlaces );
752}
753
754sal_Int32 SAL_CALL AnalysisAddIn::getDelta( const uno::Reference< beans::XPropertySet >& xOpt, double fNum1, const uno::Any& rNum2 )
755{
756 return sal_Int32(fNum1 == aAnyConv.getDouble( xOpt, rNum2, 0.0 ));
757}
758
759double SAL_CALL AnalysisAddIn::getErf( const uno::Reference< beans::XPropertySet >& xOpt, double fLL, const uno::Any& rUL )
760{
761 double fUL, fRet;
762 bool bContainsValue = aAnyConv.getDouble( fUL, xOpt, rUL );
763
764 fRet = bContainsValue ? (Erf( fUL ) - Erf( fLL )) : Erf( fLL );
765 return finiteOrThrow( fRet );
766}
767
768double SAL_CALL AnalysisAddIn::getErfc( double f )
769{
770 double fRet = Erfc( f );
771 return finiteOrThrow( fRet );
772}
773
774sal_Int32 SAL_CALL AnalysisAddIn::getGestep( const uno::Reference< beans::XPropertySet >& xOpt, double fNum, const uno::Any& rStep )
775{
776 return sal_Int32(fNum >= aAnyConv.getDouble( xOpt, rStep, 0.0 ));
777}
778
779double SAL_CALL AnalysisAddIn::getFactdouble( sal_Int32 nNum )
780{
781 double fRet = FactDouble( nNum );
782 return finiteOrThrow( fRet );
783}
784
785double SAL_CALL AnalysisAddIn::getImabs( const OUString& aNum )
786{
787 double fRet = Complex( aNum ).Abs();
788 return finiteOrThrow( fRet );
789}
790
791double SAL_CALL AnalysisAddIn::getImaginary( const OUString& aNum )
792{
793 double fRet = Complex( aNum ).Imag();
794 return finiteOrThrow( fRet );
795}
796
797OUString SAL_CALL AnalysisAddIn::getImpower( const OUString& aNum, double f )
798{
799 Complex z( aNum );
800
801 z.Power( f );
802
803 return z.GetString();
804}
805
806double SAL_CALL AnalysisAddIn::getImargument( const OUString& aNum )
807{
808 double fRet = Complex( aNum ).Arg();
809 return finiteOrThrow( fRet );
810}
811
812OUString SAL_CALL AnalysisAddIn::getImcos( const OUString& aNum )
813{
814 Complex z( aNum );
815
816 z.Cos();
817
818 return z.GetString();
819}
820
821OUString SAL_CALL AnalysisAddIn::getImdiv( const OUString& aDivid, const OUString& aDivis )
822{
823 Complex z( aDivid );
824
825 z.Div( Complex( aDivis ) );
826
827 return z.GetString();
828}
829
830OUString SAL_CALL AnalysisAddIn::getImexp( const OUString& aNum )
831{
832 Complex z( aNum );
833
834 z.Exp();
835
836 return z.GetString();
837}
838
839OUString SAL_CALL AnalysisAddIn::getImconjugate( const OUString& aNum )
840{
841 Complex z( aNum );
842
843 z.Conjugate();
844
845 return z.GetString();
846}
847
848OUString SAL_CALL AnalysisAddIn::getImln( const OUString& aNum )
849{
850 Complex z( aNum );
851
852 z.Ln();
853
854 return z.GetString();
855}
856
857OUString SAL_CALL AnalysisAddIn::getImlog10( const OUString& aNum )
858{
859 Complex z( aNum );
860
861 z.Log10();
862
863 return z.GetString();
864}
865
866OUString SAL_CALL AnalysisAddIn::getImlog2( const OUString& aNum )
867{
868 Complex z( aNum );
869
870 z.Log2();
871
872 return z.GetString();
873}
874
875OUString SAL_CALL AnalysisAddIn::getImproduct( const uno::Reference< beans::XPropertySet >&, const uno::Sequence< uno::Sequence< OUString > >& aNum1, const uno::Sequence< uno::Any >& aNL )
876{
877 ComplexList z_list;
878
879 z_list.Append( aNum1 );
880 z_list.Append( aNL );
881
882 if( z_list.empty() )
883 return Complex( 0 ).GetString();
884
885 Complex z = z_list.Get(0);
886 for( sal_uInt32 i = 1; i < z_list.Count(); ++i )
887 z.Mult( z_list.Get(i) );
888
889 return z.GetString();
890}
891
892double SAL_CALL AnalysisAddIn::getImreal( const OUString& aNum )
893{
894 double fRet = Complex( aNum ).Real();
895 return finiteOrThrow( fRet );
896}
897
898OUString SAL_CALL AnalysisAddIn::getImsin( const OUString& aNum )
899{
900 Complex z( aNum );
901
902 z.Sin();
903
904 return z.GetString();
905}
906
907OUString SAL_CALL AnalysisAddIn::getImsub( const OUString& aNum1, const OUString& aNum2 )
908{
909 Complex z( aNum1 );
910
911 z.Sub( Complex( aNum2 ) );
912
913 return z.GetString();
914}
915
916OUString SAL_CALL AnalysisAddIn::getImsum( const uno::Reference< beans::XPropertySet >&, const uno::Sequence< uno::Sequence< OUString > >& aNum1, const uno::Sequence< uno::Any >& aFollowingPars )
917{
918 ComplexList z_list;
919
920 z_list.Append( aNum1 );
921 z_list.Append( aFollowingPars );
922
923 if( z_list.empty() )
924 return Complex( 0 ).GetString();
925
926 Complex z( z_list.Get(0) );
927 for( sal_uInt32 i = 1; i < z_list.Count(); ++i )
928 z.Add( z_list.Get(i) );
929
930 return z.GetString();
931}
932
933OUString SAL_CALL AnalysisAddIn::getImsqrt( const OUString& aNum )
934{
935 Complex z( aNum );
936
937 z.Sqrt();
938
939 return z.GetString();
940}
941
942OUString SAL_CALL AnalysisAddIn::getImtan( const OUString& aNum )
943{
944 Complex z( aNum );
945
946 z.Tan();
947
948 return z.GetString();
949}
950
951OUString SAL_CALL AnalysisAddIn::getImsec( const OUString& aNum )
952{
953 Complex z( aNum );
954
955 z.Sec();
956
957 return z.GetString();
958}
959
960OUString SAL_CALL AnalysisAddIn::getImcsc( const OUString& aNum )
961{
962 Complex z( aNum );
963
964 z.Csc();
965
966 return z.GetString();
967}
968
969OUString SAL_CALL AnalysisAddIn::getImcot( const OUString& aNum )
970{
971 Complex z( aNum );
972
973 z.Cot();
974
975 return z.GetString();
976}
977
978OUString SAL_CALL AnalysisAddIn::getImsinh( const OUString& aNum )
979{
980 Complex z( aNum );
981
982 z.Sinh();
983
984 return z.GetString();
985}
986
987OUString SAL_CALL AnalysisAddIn::getImcosh( const OUString& aNum )
988{
989 Complex z( aNum );
990
991 z.Cosh();
992
993 return z.GetString();
994}
995
996OUString SAL_CALL AnalysisAddIn::getImsech( const OUString& aNum )
997{
998 Complex z( aNum );
999
1000 z.Sech();
1001
1002 return z.GetString();
1003}
1004
1005OUString SAL_CALL AnalysisAddIn::getImcsch( const OUString& aNum )
1006{
1007 Complex z( aNum );
1008
1009 z.Csch();
1010
1011 return z.GetString();
1012}
1013
1014OUString SAL_CALL AnalysisAddIn::getComplex( double fR, double fI, const uno::Any& rSuff )
1015{
1016 bool bi;
1017
1018 switch( rSuff.getValueTypeClass() )
1019 {
1020 case uno::TypeClass_VOID:
1021 bi = true;
1022 break;
1023 case uno::TypeClass_STRING:
1024 {
1025 auto pSuff = o3tl::forceAccess<OUString>(rSuff);
1026 bi = *pSuff == "i" || pSuff->isEmpty();
1027 if( !bi && *pSuff != "j" )
1028 throw lang::IllegalArgumentException();
1029 }
1030 break;
1031 default:
1032 throw lang::IllegalArgumentException();
1033 }
1034
1035 return Complex( fR, fI, bi ? 'i' : 'j' ).GetString();
1036}
1037
1038double SAL_CALL AnalysisAddIn::getConvert( double f, const OUString& aFU, const OUString& aTU )
1039{
1040 if( !pCDL )
1041 pCDL.reset(new ConvertDataList());
1042
1043 double fRet = pCDL->Convert( f, aFU, aTU );
1044 return finiteOrThrow( fRet );
1045}
1046
1048{
1049 return Translate::get(aResId, aResLocale);
1050}
1051
1052extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
1054 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
1055{
1056 return cppu::acquire(new AnalysisAddIn(context));
1057}
1058
1059/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const double SCA_MAX16
Definition: analysis.cxx:663
const double SCA_MIN2
Definition: analysis.cxx:660
#define MAXFACTDOUBLE
Definition: analysis.cxx:77
static const char * pCoun[]
Definition: analysis.cxx:282
const double SCA_MIN16
Definition: analysis.cxx:664
const sal_uInt32 nNumOfLoc
Definition: analysis.cxx:283
const double SCA_MAX2
Definition: analysis.cxx:659
const double SCA_MAX8
Definition: analysis.cxx:661
constexpr OUStringLiteral MY_IMPLNAME
Definition: analysis.cxx:37
const sal_Int32 SCA_MAXPLACES
Definition: analysis.cxx:665
static const char * pLang[]
Definition: analysis.cxx:281
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * scaddins_AnalysisAddIn_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: analysis.cxx:1053
constexpr OUStringLiteral pDefCatName
Definition: analysis.cxx:234
const double SCA_MIN8
Definition: analysis.cxx:662
constexpr OUStringLiteral ADDIN_SERVICE
Definition: analysis.cxx:35
constexpr OUStringLiteral MY_SERVICE
Definition: analysis.cxx:36
cppu::WeakComponentImplHelper< css::sheet::XAddIn, css::sheet::XCompatibilityNames, css::sheet::addin::XAnalysis, css::lang::XServiceName, css::lang::XServiceInfo > AnalysisAddIn_Base
Definition: analysis.hxx:45
double finiteOrThrow(double d)
double d
std::unique_ptr< sca::analysis::ConvertDataList > pCDL
Definition: analysis.hxx:54
virtual OUString SAL_CALL getImexp(const OUString &aNum) override
Definition: analysis.cxx:830
virtual double SAL_CALL getMultinomial(const css::uno::Reference< css::beans::XPropertySet > &xOpt, const css::uno::Sequence< css::uno::Sequence< sal_Int32 > > &aVLst, const css::uno::Sequence< css::uno::Any > &aOptVLst) override
Definition: analysis.cxx:489
virtual double SAL_CALL getQuotient(double fNum, double fDenum) override
Definition: analysis.cxx:543
virtual OUString SAL_CALL getImlog10(const OUString &aNum) override
Definition: analysis.cxx:857
virtual OUString SAL_CALL getDisplayCategoryName(const OUString &aProgrammaticFunctionName) override
Definition: analysis.cxx:259
virtual OUString SAL_CALL getOct2Hex(const css::uno::Reference< css::beans::XPropertySet > &xOpt, const OUString &aNum, const css::uno::Any &rPlaces) override
Definition: analysis.cxx:703
virtual OUString SAL_CALL getImsec(const OUString &aNum) override
Definition: analysis.cxx:951
virtual OUString SAL_CALL getImcsc(const OUString &aNum) override
Definition: analysis.cxx:960
virtual OUString SAL_CALL getDisplayFunctionName(const OUString &aProgrammaticName) override
Definition: analysis.cxx:164
css::lang::Locale aFuncLoc
Definition: analysis.hxx:50
std::locale aResLocale
Definition: analysis.hxx:55
virtual double SAL_CALL getImabs(const OUString &aNum) override
Definition: analysis.cxx:785
virtual double SAL_CALL getSqrtpi(double fNum) override
Definition: analysis.cxx:562
virtual OUString SAL_CALL getDec2Hex(const css::uno::Reference< css::beans::XPropertySet > &xOpt, double fNum, const css::uno::Any &rPlaces) override
Definition: analysis.cxx:725
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: analysis.cxx:137
virtual double SAL_CALL getBesseli(double fNum, sal_Int32 nOrder) override
Definition: analysis.cxx:629
virtual OUString SAL_CALL getBin2Oct(const css::uno::Reference< css::beans::XPropertySet > &xOpt, const OUString &aNum, const css::uno::Any &rPlaces) override
Definition: analysis.cxx:667
virtual OUString SAL_CALL getImsum(const css::uno::Reference< css::beans::XPropertySet > &xOpt, const css::uno::Sequence< css::uno::Sequence< OUString > > &aNum1, const css::uno::Sequence< css::uno::Any > &aFollowingPars) override
Definition: analysis.cxx:916
virtual OUString SAL_CALL getServiceName() override
Definition: analysis.cxx:120
virtual sal_Int32 SAL_CALL getNetworkdays(const css::uno::Reference< css::beans::XPropertySet > &, sal_Int32 nStartDate, sal_Int32 nEndDate, const css::uno::Any &aHDay) override
Definition: analysis.cxx:441
virtual OUString SAL_CALL getImln(const OUString &aNum) override
Definition: analysis.cxx:848
virtual sal_Int32 SAL_CALL getEomonth(const css::uno::Reference< css::beans::XPropertySet > &, sal_Int32 nStartDate, sal_Int32 nMonths) override
Definition: analysis.cxx:415
virtual OUString SAL_CALL getProgrammaticCategoryName(const OUString &aProgrammaticFunctionName) override
Definition: analysis.cxx:236
std::unique_ptr< css::lang::Locale[]> pDefLocales
Definition: analysis.hxx:51
virtual sal_Int32 SAL_CALL getGestep(const css::uno::Reference< css::beans::XPropertySet > &xOpt, double fNum, const css::uno::Any &rStep) override
Definition: analysis.cxx:774
virtual double SAL_CALL getRandbetween(double fMin, double fMax) override
Definition: analysis.cxx:568
virtual OUString SAL_CALL getImcosh(const OUString &aNum) override
Definition: analysis.cxx:987
virtual sal_Int32 SAL_CALL getIsodd(sal_Int32 nVal) override
Definition: analysis.cxx:483
virtual OUString SAL_CALL getFunctionDescription(const OUString &aProgrammaticName) override
Definition: analysis.cxx:189
virtual OUString SAL_CALL getImsech(const OUString &aNum) override
Definition: analysis.cxx:996
virtual css::lang::Locale SAL_CALL getLocale() override
Definition: analysis.cxx:150
virtual OUString SAL_CALL getDisplayArgumentName(const OUString &aProgrammaticFunctionName, sal_Int32 nArgument) override
Definition: analysis.cxx:200
virtual OUString SAL_CALL getImsin(const OUString &aNum) override
Definition: analysis.cxx:898
virtual OUString SAL_CALL getImlog2(const OUString &aNum) override
Definition: analysis.cxx:866
virtual OUString SAL_CALL getDec2Bin(const css::uno::Reference< css::beans::XPropertySet > &xOpt, sal_Int32 fNum, const css::uno::Any &rPlaces) override
Definition: analysis.cxx:711
virtual OUString SAL_CALL getImsinh(const OUString &aNum) override
Definition: analysis.cxx:978
virtual double SAL_CALL getErfc(double fLowerLimit) override
Definition: analysis.cxx:768
virtual OUString SAL_CALL getHex2Bin(const css::uno::Reference< css::beans::XPropertySet > &xOpt, const OUString &aNum, const css::uno::Any &rPlaces) override
Definition: analysis.cxx:732
virtual double SAL_CALL getImaginary(const OUString &aNum) override
Definition: analysis.cxx:791
void InitData()
Definition: analysis.cxx:47
virtual double SAL_CALL getSeriessum(double fX, double fN, double fM, const css::uno::Sequence< css::uno::Sequence< double > > &aCoeffList) override
Definition: analysis.cxx:519
virtual OUString SAL_CALL getImcos(const OUString &aNum) override
Definition: analysis.cxx:812
virtual css::uno::Sequence< css::sheet::LocalizedName > SAL_CALL getCompatibilityNames(const OUString &aProgrammaticName) override
Definition: analysis.cxx:307
virtual OUString SAL_CALL getBin2Hex(const css::uno::Reference< css::beans::XPropertySet > &xOpt, const OUString &aNum, const css::uno::Any &rPlaces) override
Definition: analysis.cxx:681
virtual OUString SAL_CALL getDec2Oct(const css::uno::Reference< css::beans::XPropertySet > &xOpt, sal_Int32 fNum, const css::uno::Any &rPlaces) override
Definition: analysis.cxx:718
virtual double SAL_CALL getOct2Dec(const OUString &aNum) override
Definition: analysis.cxx:697
std::unique_ptr< sca::analysis::FuncDataList > pFD
Definition: analysis.hxx:52
virtual OUString SAL_CALL getImplementationName() override
Definition: analysis.cxx:127
OUString GetFuncDescrStr(const TranslateId *pResId, sal_uInt16 nStrIndex)
Definition: analysis.cxx:42
virtual OUString SAL_CALL getImproduct(const css::uno::Reference< css::beans::XPropertySet > &xOpt, const css::uno::Sequence< css::uno::Sequence< OUString > > &aNum1, const css::uno::Sequence< css::uno::Any > &aNumList) override
Definition: analysis.cxx:875
const css::lang::Locale & GetLocale(sal_uInt32 nInd)
Definition: analysis.cxx:296
virtual void SAL_CALL setLocale(const css::lang::Locale &eLocale) override
Definition: analysis.cxx:143
virtual OUString SAL_CALL getImsub(const OUString &aNum1, const OUString &aNum2) override
Definition: analysis.cxx:907
virtual OUString SAL_CALL getImpower(const OUString &aNum, double fPower) override
Definition: analysis.cxx:797
virtual OUString SAL_CALL getImdiv(const OUString &aDivident, const OUString &aDivisor) override
Definition: analysis.cxx:821
OUString AnalysisResId(TranslateId aId)
Definition: analysis.cxx:1047
virtual OUString SAL_CALL getOct2Bin(const css::uno::Reference< css::beans::XPropertySet > &xOpt, const OUString &aNum, const css::uno::Any &rPlaces) override
Definition: analysis.cxx:689
virtual double SAL_CALL getImreal(const OUString &aNum) override
Definition: analysis.cxx:892
virtual OUString SAL_CALL getImconjugate(const OUString &aNum) override
Definition: analysis.cxx:839
virtual double SAL_CALL getConvert(double fVal, const OUString &aFromUnit, const OUString &aToUnit) override
Definition: analysis.cxx:1038
virtual OUString SAL_CALL getImcot(const OUString &aNum) override
Definition: analysis.cxx:969
virtual OUString SAL_CALL getComplex(double fReal, double fImaginary, const css::uno::Any &rSuffix) override
Definition: analysis.cxx:1014
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: analysis.cxx:132
virtual OUString SAL_CALL getArgumentDescription(const OUString &aProgrammaticFunctionName, sal_Int32 nArgument) override
Definition: analysis.cxx:217
virtual OUString SAL_CALL getImsqrt(const OUString &aNum) override
Definition: analysis.cxx:933
virtual OUString SAL_CALL getProgrammaticFuntionName(const OUString &aDisplayName) override
Definition: analysis.cxx:156
virtual OUString SAL_CALL getHex2Oct(const css::uno::Reference< css::beans::XPropertySet > &xOpt, const OUString &aNum, const css::uno::Any &rPlaces) override
Definition: analysis.cxx:746
void InitDefLocales()
Definition: analysis.cxx:285
double FactDouble(sal_Int32 nNum)
Definition: analysis.cxx:79
virtual double SAL_CALL getBesselj(double fNum, sal_Int32 nOrder) override
Definition: analysis.cxx:635
virtual sal_Int32 SAL_CALL getWorkday(const css::uno::Reference< css::beans::XPropertySet > &, sal_Int32 nStartDate, sal_Int32 nDays, const css::uno::Any &aHDay) override
Workday.
Definition: analysis.cxx:330
virtual sal_Int32 SAL_CALL getWeeknum(const css::uno::Reference< css::beans::XPropertySet > &, sal_Int32 nStartDate, sal_Int32 nMode) override
Definition: analysis.cxx:402
virtual double SAL_CALL getErf(const css::uno::Reference< css::beans::XPropertySet > &xOpt, double fLowerLimit, const css::uno::Any &rUpperLimit) override
Definition: analysis.cxx:759
virtual double SAL_CALL getHex2Dec(const OUString &aNum) override
Definition: analysis.cxx:740
virtual double SAL_CALL getFactdouble(sal_Int32 nNum) override
Definition: analysis.cxx:779
virtual double SAL_CALL getGcd(const css::uno::Reference< css::beans::XPropertySet > &xOpt, const css::uno::Sequence< css::uno::Sequence< double > > &aVLst, const css::uno::Sequence< css::uno::Any > &aOptVLst) override
Definition: analysis.cxx:579
virtual sal_Int32 SAL_CALL getDelta(const css::uno::Reference< css::beans::XPropertySet > &xOpt, double fNum1, const css::uno::Any &rNum2) override
Definition: analysis.cxx:754
virtual double SAL_CALL getBessely(double fNum, sal_Int32 nOrder) override
Definition: analysis.cxx:650
virtual sal_Int32 SAL_CALL getEdate(const css::uno::Reference< css::beans::XPropertySet > &, sal_Int32 nStartDate, sal_Int32 nMonths) override
Definition: analysis.cxx:394
virtual double SAL_CALL getImargument(const OUString &aNum) override
Definition: analysis.cxx:806
virtual double SAL_CALL getLcm(const css::uno::Reference< css::beans::XPropertySet > &xOpt, const css::uno::Sequence< css::uno::Sequence< double > > &aVLst, const css::uno::Sequence< css::uno::Any > &aOptVLst) override
Definition: analysis.cxx:598
virtual double SAL_CALL getBesselk(double fNum, sal_Int32 nOrder) override
Definition: analysis.cxx:641
sca::analysis::ScaAnyConverter aAnyConv
Definition: analysis.hxx:57
virtual sal_Int32 SAL_CALL getIseven(sal_Int32 nVal) override
Definition: analysis.cxx:478
virtual ~AnalysisAddIn() override
Definition: analysis.cxx:63
sal_Int32 getDateMode(const css::uno::Reference< css::beans::XPropertySet > &xPropSet, const css::uno::Any &rAny)
Converts an Any to sal_Int32 in the range from 0 to 4 (date calculation mode).
Definition: analysis.cxx:67
virtual double SAL_CALL getMround(double fNum, double fMult) override
Definition: analysis.cxx:553
virtual OUString SAL_CALL getImtan(const OUString &aNum) override
Definition: analysis.cxx:942
virtual double SAL_CALL getYearfrac(const css::uno::Reference< css::beans::XPropertySet > &, sal_Int32 nStartDate, sal_Int32 nEndDate, const css::uno::Any &aMode) override
Yearfrac.
Definition: analysis.cxx:387
virtual double SAL_CALL getBin2Dec(const OUString &aNum) override
Definition: analysis.cxx:675
virtual OUString SAL_CALL getImcsch(const OUString &aNum) override
Definition: analysis.cxx:1005
AnalysisAddIn(const css::uno::Reference< css::uno::XComponentContext > &xContext)
Definition: analysis.cxx:57
std::unique_ptr< double[]> pFactDoubles
Definition: analysis.hxx:53
void Append(Complex &&pNew)
const Complex & Get(sal_uInt32 nIndex) const
OUString GetString() const
bool getDouble(double &rfResult, const css::uno::Any &rAny) const
Converts an Any to double (without initialization).
bool getInt32(sal_Int32 &rnResult, const css::uno::Reference< css::beans::XPropertySet > &xPropSet, const css::uno::Any &rAny)
Converts an Any to sal_Int32 (with initialization).
Helper class for date calculation for various financial functions.
sal_Int32 getDate(sal_Int32 nNullDate) const
void addMonths(sal_Int32 nMonthCount)
adds/subtracts the given count of months, adjusts day
stores double values >=0.0, throws exception for double values <0.0
stores double values >0.0, throws exception for double values <0.0, does nothing for 0....
double Get(sal_uInt32 n) const
sorted list with unique sal_Int32 values
void InsertHolidayList(const ScaAnyConverter &rAnyConv, const css::uno::Any &rHolAny, sal_Int32 nNullDate, bool bInsertOnWeekend)
int nCount
float u
float z
std::mutex m_aMutex
OUString aName
sal_Int64 n
#define SAL_N_ELEMENTS(arr)
std::locale Create(std::string_view aPrefixName, const LanguageTag &rLocale)
OUString get(TranslateId sContextAndId, const std::locale &loc)
double uniform_real_distribution(double a=0.0, double b=1.0)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
int i
double BinomialCoefficient(double n, double k)
void InitFuncDataList(FuncDataList &rList)
double Erfc(double x)
double BesselI(double x, sal_Int32 n)
Returns the result for the modified BESSEL function of first kind (I), n-th order,...
Definition: bessel.cxx:164
double GetGcd(double f1, double f2)
double BesselK(double fNum, sal_Int32 nOrder)
Returns the result for the modified BESSEL function of second kind (K), n-th order,...
Definition: bessel.cxx:275
OUString ConvertFromDec(double fNum, double fMin, double fMax, sal_uInt16 nBase, sal_Int32 nPlaces, sal_Int32 nMaxPlaces, bool bUsePlaces)
double ConvertToDec(const OUString &aStr, sal_uInt16 nBase, sal_uInt16 nCharLim)
double BesselY(double fNum, sal_Int32 nOrder)
Returns the result for the unmodified BESSEL function of second kind (Y), n-th order,...
Definition: bessel.cxx:426
double BesselJ(double x, sal_Int32 N)
Returns the result for the unmodified BESSEL function of first kind (J), n-th order,...
Definition: bessel.cxx:53
sal_Int16 GetDayOfWeek(sal_Int32 nDate)
double Erf(double x)
std::vector< FuncData > FuncDataList
const char DaysToDate[]
const char DateToDays[]
const char GetYearFrac[]
const char GetNullDate[]
const char DaysInMonth[]
unsigned char sal_Bool