LibreOffice Module scaddins (master) 1
Public Member Functions | Private Member Functions | Private Attributes | List of all members
sca::analysis::ScaAnyConverter Class Reference

Helper class for Any->double conversion, using current language settings. More...

#include <analysishelper.hxx>

Public Member Functions

 ScaAnyConverter (const css::uno::Reference< css::uno::XComponentContext > &xContext)
 
 ~ScaAnyConverter ()
 
void init (const css::uno::Reference< css::beans::XPropertySet > &xPropSet)
 Initializing with current language settings. More...
 
bool getDouble (double &rfResult, const css::uno::Any &rAny) const
 Converts an Any to double (without initialization). More...
 
bool getDouble (double &rfResult, const css::uno::Reference< css::beans::XPropertySet > &xPropSet, const css::uno::Any &rAny)
 Converts an Any to double (with initialization). More...
 
double getDouble (const css::uno::Reference< css::beans::XPropertySet > &xPropSet, const css::uno::Any &rAny, double fDefault)
 Converts an Any to double (with initialization). More...
 
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). More...
 
sal_Int32 getInt32 (const css::uno::Reference< css::beans::XPropertySet > &xPropSet, const css::uno::Any &rAny, sal_Int32 nDefault)
 Converts an Any to sal_Int32 (with initialization). More...
 

Private Member Functions

double convertToDouble (const OUString &rString) const
 Converts a string to double using the number formatter. More...
 

Private Attributes

css::uno::Reference< css::util::XNumberFormatter2 > xFormatter
 
sal_Int32 nDefaultFormat
 
bool bHasValidFormat
 

Detailed Description

Helper class for Any->double conversion, using current language settings.

Definition at line 824 of file analysishelper.hxx.

Constructor & Destructor Documentation

◆ ScaAnyConverter()

sca::analysis::ScaAnyConverter::ScaAnyConverter ( const css::uno::Reference< css::uno::XComponentContext > &  xContext)
explicit

Definition at line 2669 of file analysishelper.cxx.

References xFormatter.

◆ ~ScaAnyConverter()

sca::analysis::ScaAnyConverter::~ScaAnyConverter ( )

Definition at line 2676 of file analysishelper.cxx.

Member Function Documentation

◆ convertToDouble()

double sca::analysis::ScaAnyConverter::convertToDouble ( const OUString &  rString) const
private

Converts a string to double using the number formatter.

If the formatter is not valid, ::rtl::math::stringToDouble() with english separators will be used.

Exceptions
css::lang::IllegalArgumentExceptionon strings not representing any double value.
Returns
the converted double value.

Definition at line 2704 of file analysishelper.cxx.

References bHasValidFormat, nDefaultFormat, and xFormatter.

◆ getDouble() [1/3]

double sca::analysis::ScaAnyConverter::getDouble ( const css::uno::Reference< css::beans::XPropertySet > &  xPropSet,
const css::uno::Any &  rAny,
double  fDefault 
)

Converts an Any to double (with initialization).

The Any can be empty or contain a double or string.

Exceptions
css::lang::IllegalArgumentExceptionon other Any types or on invalid strings.
Returns
the value of the double or string or fDefault if the Any or string is empty

◆ getDouble() [2/3]

bool sca::analysis::ScaAnyConverter::getDouble ( double &  rfResult,
const css::uno::Any &  rAny 
) const

Converts an Any to double (without initialization).

The Any can be empty or contain a double or string.

Exceptions
css::lang::IllegalArgumentExceptionon other Any types or on invalid strings.
Returns
true if the Any contains a double or a non-empty valid string, false if the Any is empty or the string is empty

Referenced by AnalysisAddIn::getAccrint(), AnalysisAddIn::getAccrintm(), AnalysisAddIn::getDelta(), AnalysisAddIn::getErf(), AnalysisAddIn::getGestep(), and AnalysisAddIn::getXirr().

◆ getDouble() [3/3]

bool sca::analysis::ScaAnyConverter::getDouble ( double &  rfResult,
const css::uno::Reference< css::beans::XPropertySet > &  xPropSet,
const css::uno::Any &  rAny 
)

Converts an Any to double (with initialization).

The Any can be empty or contain a double or string.

Exceptions
css::lang::IllegalArgumentExceptionon other Any types or on invalid strings.
Returns
true if the Any contains a double or a non-empty valid string, false if the Any is empty or the string is empty

◆ getInt32() [1/2]

sal_Int32 sca::analysis::ScaAnyConverter::getInt32 ( const css::uno::Reference< css::beans::XPropertySet > &  xPropSet,
const css::uno::Any &  rAny,
sal_Int32  nDefault 
)

Converts an Any to sal_Int32 (with initialization).

The Any can be empty or contain a double or string.

Exceptions
css::lang::IllegalArgumentExceptionon other Any types or on invalid values or strings.
Returns
the truncated value of the double or string or nDefault if the Any or string is empty

◆ getInt32() [2/2]

bool sca::analysis::ScaAnyConverter::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).

The Any can be empty or contain a double or string.

Exceptions
css::lang::IllegalArgumentExceptionon other Any types or on invalid values or strings.
Returns
true if the Any contains a double or a non-empty valid string, false if the Any is empty or the string is empty

Referenced by AnalysisAddIn::getBin2Hex(), AnalysisAddIn::getBin2Oct(), AnalysisAddIn::getDateMode(), AnalysisAddIn::getDec2Bin(), AnalysisAddIn::getDec2Hex(), AnalysisAddIn::getDec2Oct(), AnalysisAddIn::getHex2Bin(), AnalysisAddIn::getHex2Oct(), AnalysisAddIn::getOct2Bin(), and AnalysisAddIn::getOct2Hex().

◆ init()

void sca::analysis::ScaAnyConverter::init ( const css::uno::Reference< css::beans::XPropertySet > &  xPropSet)

Initializing with current language settings.

Exceptions
css::uno::RuntimeException

Definition at line 2680 of file analysishelper.cxx.

References bHasValidFormat, nDefaultFormat, and xFormatter.

Member Data Documentation

◆ bHasValidFormat

bool sca::analysis::ScaAnyConverter::bHasValidFormat
private

Definition at line 829 of file analysishelper.hxx.

Referenced by convertToDouble(), and init().

◆ nDefaultFormat

sal_Int32 sca::analysis::ScaAnyConverter::nDefaultFormat
private

Definition at line 828 of file analysishelper.hxx.

Referenced by convertToDouble(), and init().

◆ xFormatter

css::uno::Reference< css::util::XNumberFormatter2 > sca::analysis::ScaAnyConverter::xFormatter
private

Definition at line 827 of file analysishelper.hxx.

Referenced by convertToDouble(), init(), and ScaAnyConverter().


The documentation for this class was generated from the following files: