Kaydet (Commit) d062a16b authored tarafından Thomas Arnhold's avatar Thomas Arnhold

cleanup macros in scaddins

Change-Id: Id3c05d7771845f4a9f8c1105d9c9f126c6131cee
üst b2b371a5
......@@ -20,25 +20,12 @@
#ifndef ANALYSISDEFS_HXX
#define ANALYSISDEFS_HXX
#define XPROPSET ::com::sun::star::beans::XPropertySet
#define REF(c) ::com::sun::star::uno::Reference< c >
#define constREFXPS const REF(XPROPSET)
#define SEQ(c) ::com::sun::star::uno::Sequence< c >
#define SEQSEQ(c) ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< c > >
#define SEQofLocName SEQ( ::com::sun::star::sheet::LocalizedName )
#define ANY ::com::sun::star::uno::Any
#define SEQ_ANY SEQ(ANY)
#define STRFROMASCII(s) OUString::createFromAscii( s )
#define STRFROMANSI(s) OUString( s, strlen( s ), RTL_TEXTENCODING_MS_1252 )
#define THROWDEF_RTE throw(::com::sun::star::uno::RuntimeException)
#define THROW_RTE throw ::com::sun::star::uno::RuntimeException()
#define THROWDEF_RTE_IAE throw(::com::sun::star::uno::RuntimeException,::com::sun::star::lang::IllegalArgumentException)
#define THROW_IAE throw ::com::sun::star::lang::IllegalArgumentException()
#define THROWDEF_RTE_IAE_NCE throw(::com::sun::star::uno::RuntimeException,::com::sun::star::lang::IllegalArgumentException,::com::sun::star::sheet::NoConvergenceException)
#define CHK_Freq ( nFreq != 1 && nFreq != 2 && nFreq != 4 )
#define CHK_FINITE(d) if( !::rtl::math::isFinite( d ) ) THROW_IAE
#define RETURN_FINITE(d) if( ::rtl::math::isFinite( d ) ) return d; else THROW_IAE
#define CHK_FINITE(d) if( !::rtl::math::isFinite( d ) ) throw css::lang::IllegalArgumentException()
#define RETURN_FINITE(d) if( ::rtl::math::isFinite( d ) ) return d; else throw css::lang::IllegalArgumentException()
#endif
......
......@@ -546,11 +546,11 @@ bool getinput_putcall(bs::types::PutCall& pc, const OUString& str) {
return true;
}
bool getinput_putcall(bs::types::PutCall& pc, const ANY& anyval) {
bool getinput_putcall(bs::types::PutCall& pc, const uno::Any& anyval) {
OUString str;
if(anyval.getValueTypeClass() == ::com::sun::star::uno::TypeClass_STRING) {
if(anyval.getValueTypeClass() == uno::TypeClass_STRING) {
anyval >>= str;
} else if(anyval.getValueTypeClass() == ::com::sun::star::uno::TypeClass_VOID) {
} else if(anyval.getValueTypeClass() == uno::TypeClass_VOID) {
str="c"; // call as default
} else {
return false;
......@@ -558,10 +558,10 @@ bool getinput_putcall(bs::types::PutCall& pc, const ANY& anyval) {
return getinput_putcall(pc, str);
}
bool getinput_strike(double& strike, const ANY& anyval) {
if(anyval.getValueTypeClass() == ::com::sun::star::uno::TypeClass_DOUBLE) {
bool getinput_strike(double& strike, const uno::Any& anyval) {
if(anyval.getValueTypeClass() == uno::TypeClass_DOUBLE) {
anyval >>= strike;
} else if(anyval.getValueTypeClass() == ::com::sun::star::uno::TypeClass_VOID) {
} else if(anyval.getValueTypeClass() == uno::TypeClass_VOID) {
strike=-1.0; // -1 as default (means not set)
} else {
return false;
......@@ -602,11 +602,11 @@ bool getinput_fordom(bs::types::ForDom& fd, const OUString& str) {
return true;
}
bool getinput_greek(bs::types::Greeks& greek, const ANY& anyval) {
bool getinput_greek(bs::types::Greeks& greek, const uno::Any& anyval) {
OUString str;
if(anyval.getValueTypeClass() == ::com::sun::star::uno::TypeClass_STRING) {
if(anyval.getValueTypeClass() == uno::TypeClass_STRING) {
anyval >>= str;
} else if(anyval.getValueTypeClass() == ::com::sun::star::uno::TypeClass_VOID) {
} else if(anyval.getValueTypeClass() == uno::TypeClass_VOID) {
str="value";
} else {
return false;
......@@ -645,7 +645,7 @@ double SAL_CALL ScaPricingAddIn::getOptBarrier( double spot, double vol,
double r, double rf, double T, double strike,
double barrier_low, double barrier_up, double rebate,
const OUString& put_call, const OUString& in_out,
const OUString& barriercont, const ANY& greekstr ) THROWDEF_RTE_IAE
const OUString& barriercont, const uno::Any& greekstr ) throw( uno::RuntimeException, lang::IllegalArgumentException )
{
bs::types::PutCall pc;
bs::types::BarrierKIO kio;
......@@ -657,7 +657,7 @@ double SAL_CALL ScaPricingAddIn::getOptBarrier( double spot, double vol,
!getinput_inout(kio,in_out) ||
!getinput_barrier(bcont,barriercont) ||
!getinput_greek(greek,greekstr) ){
THROW_IAE;
throw lang::IllegalArgumentException();
}
double fRet=bs::barrier(spot,vol,r,rf,T,strike, barrier_low,barrier_up,
......@@ -671,7 +671,7 @@ double SAL_CALL ScaPricingAddIn::getOptTouch( double spot, double vol,
double r, double rf, double T,
double barrier_low, double barrier_up,
const OUString& for_dom, const OUString& in_out,
const OUString& barriercont, const ANY& greekstr ) THROWDEF_RTE_IAE
const OUString& barriercont, const uno::Any& greekstr ) throw( uno::RuntimeException, lang::IllegalArgumentException )
{
bs::types::ForDom fd;
bs::types::BarrierKIO kio;
......@@ -683,7 +683,7 @@ double SAL_CALL ScaPricingAddIn::getOptTouch( double spot, double vol,
!getinput_inout(kio,in_out) ||
!getinput_barrier(bcont,barriercont) ||
!getinput_greek(greek,greekstr) ){
THROW_IAE;
throw lang::IllegalArgumentException();
}
double fRet=bs::touch(spot,vol,r,rf,T,barrier_low,barrier_up,
......@@ -695,11 +695,11 @@ double SAL_CALL ScaPricingAddIn::getOptTouch( double spot, double vol,
// OPT_PRB_HIT(...)
double SAL_CALL ScaPricingAddIn::getOptProbHit( double spot, double vol,
double mu, double T,
double barrier_low, double barrier_up ) THROWDEF_RTE_IAE
double barrier_low, double barrier_up ) throw( uno::RuntimeException, lang::IllegalArgumentException )
{
// read and check input values
if( spot<=0.0 || vol<=0.0 || T<0.0 ) {
THROW_IAE;
throw lang::IllegalArgumentException();
}
double fRet=bs::prob_hit(spot,vol,mu,T,barrier_low,barrier_up);
......@@ -711,7 +711,7 @@ double SAL_CALL ScaPricingAddIn::getOptProbHit( double spot, double vol,
double SAL_CALL ScaPricingAddIn::getOptProbInMoney( double spot, double vol,
double mu, double T,
double barrier_low, double barrier_up,
const ANY& strikeval, const ANY& put_call ) THROWDEF_RTE_IAE
const uno::Any& strikeval, const uno::Any& put_call ) throw( uno::RuntimeException, lang::IllegalArgumentException )
{
bs::types::PutCall pc=bs::types::Call;
double K;
......@@ -720,7 +720,7 @@ double SAL_CALL ScaPricingAddIn::getOptProbInMoney( double spot, double vol,
if( spot<=0.0 || vol<=0.0 || T<0.0 ||
!getinput_putcall(pc,put_call) ||
!getinput_strike(K,strikeval) ) {
THROW_IAE;
throw lang::IllegalArgumentException();
}
double fRet=bs::prob_in_money(spot,vol,mu,T,K,barrier_low,barrier_up,pc);
......
......@@ -43,10 +43,7 @@
#include <tools/rc.hxx>
#include <tools/resary.hxx>
#define ANY ::com::sun::star::uno::Any
#define THROWDEF_RTE_IAE throw(::com::sun::star::uno::RuntimeException,::com::sun::star::lang::IllegalArgumentException)
#define THROW_IAE throw ::com::sun::star::lang::IllegalArgumentException()
#define RETURN_FINITE(d) if( ::rtl::math::isFinite( d ) ) return d; else THROW_IAE
#define RETURN_FINITE(d) if( ::rtl::math::isFinite( d ) ) return d; else throw css::lang::IllegalArgumentException()
......@@ -325,64 +322,64 @@ inline ScaFuncData* ScaFuncDataList::Next()
//------------------------------------------------------------------
//------------------------------------------------------------------
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL PricingFunctionAddIn_CreateInstance(
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& );
css::uno::Reference< css::uno::XInterface > SAL_CALL PricingFunctionAddIn_CreateInstance(
const css::uno::Reference< css::lang::XMultiServiceFactory >& );
// AddIn class for pricing functions
class ScaPricingAddIn : public ::cppu::WeakImplHelper5<
::com::sun::star::sheet::XAddIn,
::com::sun::star::sheet::XCompatibilityNames,
::com::sun::star::sheet::addin::XPricingFunctions,
::com::sun::star::lang::XServiceName,
::com::sun::star::lang::XServiceInfo >
css::sheet::XAddIn,
css::sheet::XCompatibilityNames,
css::sheet::addin::XPricingFunctions,
css::lang::XServiceName,
css::lang::XServiceInfo >
{
private:
::com::sun::star::lang::Locale aFuncLoc;
::com::sun::star::lang::Locale* pDefLocales;
css::lang::Locale aFuncLoc;
css::lang::Locale* pDefLocales;
ResMgr* pResMgr;
sca::pricing::ScaFuncDataList* pFuncDataList;
void InitDefLocales();
const ::com::sun::star::lang::Locale& GetLocale( sal_uInt32 nIndex );
ResMgr& GetResMgr() throw( ::com::sun::star::uno::RuntimeException );
const css::lang::Locale& GetLocale( sal_uInt32 nIndex );
ResMgr& GetResMgr() throw( css::uno::RuntimeException );
void InitData();
::rtl::OUString GetDisplFuncStr( sal_uInt16 nResId ) throw( ::com::sun::star::uno::RuntimeException );
::rtl::OUString GetFuncDescrStr( sal_uInt16 nResId, sal_uInt16 nStrIndex ) throw( ::com::sun::star::uno::RuntimeException );
::rtl::OUString GetDisplFuncStr( sal_uInt16 nResId ) throw( css::uno::RuntimeException );
::rtl::OUString GetFuncDescrStr( sal_uInt16 nResId, sal_uInt16 nStrIndex ) throw( css::uno::RuntimeException );
public:
ScaPricingAddIn();
virtual ~ScaPricingAddIn();
static ::rtl::OUString getImplementationName_Static();
static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static();
static css::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static();
// XAddIn
virtual ::rtl::OUString SAL_CALL getProgrammaticFuntionName( const ::rtl::OUString& aDisplayName ) throw( ::com::sun::star::uno::RuntimeException );
virtual ::rtl::OUString SAL_CALL getDisplayFunctionName( const ::rtl::OUString& aProgrammaticName ) throw( ::com::sun::star::uno::RuntimeException );
virtual ::rtl::OUString SAL_CALL getFunctionDescription( const ::rtl::OUString& aProgrammaticName ) throw( ::com::sun::star::uno::RuntimeException );
virtual ::rtl::OUString SAL_CALL getDisplayArgumentName( const ::rtl::OUString& aProgrammaticName, sal_Int32 nArgument ) throw( ::com::sun::star::uno::RuntimeException );
virtual ::rtl::OUString SAL_CALL getArgumentDescription( const ::rtl::OUString& aProgrammaticName, sal_Int32 nArgument ) throw( ::com::sun::star::uno::RuntimeException );
virtual ::rtl::OUString SAL_CALL getProgrammaticCategoryName( const ::rtl::OUString& aProgrammaticName ) throw( ::com::sun::star::uno::RuntimeException );
virtual ::rtl::OUString SAL_CALL getDisplayCategoryName( const ::rtl::OUString& aProgrammaticName ) throw( ::com::sun::star::uno::RuntimeException );
virtual ::rtl::OUString SAL_CALL getProgrammaticFuntionName( const ::rtl::OUString& aDisplayName ) throw( css::uno::RuntimeException );
virtual ::rtl::OUString SAL_CALL getDisplayFunctionName( const ::rtl::OUString& aProgrammaticName ) throw( css::uno::RuntimeException );
virtual ::rtl::OUString SAL_CALL getFunctionDescription( const ::rtl::OUString& aProgrammaticName ) throw( css::uno::RuntimeException );
virtual ::rtl::OUString SAL_CALL getDisplayArgumentName( const ::rtl::OUString& aProgrammaticName, sal_Int32 nArgument ) throw( css::uno::RuntimeException );
virtual ::rtl::OUString SAL_CALL getArgumentDescription( const ::rtl::OUString& aProgrammaticName, sal_Int32 nArgument ) throw( css::uno::RuntimeException );
virtual ::rtl::OUString SAL_CALL getProgrammaticCategoryName( const ::rtl::OUString& aProgrammaticName ) throw( css::uno::RuntimeException );
virtual ::rtl::OUString SAL_CALL getDisplayCategoryName( const ::rtl::OUString& aProgrammaticName ) throw( css::uno::RuntimeException );
// XCompatibilityNames
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::LocalizedName > SAL_CALL getCompatibilityNames( const ::rtl::OUString& aProgrammaticName ) throw( ::com::sun::star::uno::RuntimeException );
virtual css::uno::Sequence< css::sheet::LocalizedName > SAL_CALL getCompatibilityNames( const ::rtl::OUString& aProgrammaticName ) throw( css::uno::RuntimeException );
// XLocalizable
virtual void SAL_CALL setLocale( const ::com::sun::star::lang::Locale& eLocale ) throw( ::com::sun::star::uno::RuntimeException );
virtual ::com::sun::star::lang::Locale SAL_CALL getLocale() throw( ::com::sun::star::uno::RuntimeException );
virtual void SAL_CALL setLocale( const css::lang::Locale& eLocale ) throw( css::uno::RuntimeException );
virtual css::lang::Locale SAL_CALL getLocale() throw( css::uno::RuntimeException );
// XServiceName
virtual ::rtl::OUString SAL_CALL getServiceName() throw( ::com::sun::star::uno::RuntimeException );
virtual ::rtl::OUString SAL_CALL getServiceName() throw( css::uno::RuntimeException );
// XServiceInfo
virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( ::com::sun::star::uno::RuntimeException );
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
virtual ::rtl::OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException );
virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( css::uno::RuntimeException );
virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException );
// ----------------------------------------
// methods from own interfaces start here
......@@ -392,22 +389,22 @@ public:
double r, double rf, double T, double strike,
double barrier_low, double barrier_up, double rebate,
const OUString& put_call, const OUString& in_out,
const OUString& continuous, const ANY& greek ) THROWDEF_RTE_IAE;
const OUString& continuous, const css::uno::Any& greek ) throw( css::uno::RuntimeException, css::lang::IllegalArgumentException );
virtual double SAL_CALL getOptTouch( double spot, double vol,
double r, double rf, double T,
double barrier_low, double barrier_up,
const OUString& for_dom, const OUString& in_out,
const OUString& barriercont, const ANY& greekstr ) THROWDEF_RTE_IAE;
const OUString& barriercont, const css::uno::Any& greekstr ) throw( css::uno::RuntimeException, css::lang::IllegalArgumentException );
virtual double SAL_CALL getOptProbHit( double spot, double vol,
double mu, double T,
double barrier_low, double barrier_up ) THROWDEF_RTE_IAE;
double barrier_low, double barrier_up ) throw( css::uno::RuntimeException, css::lang::IllegalArgumentException );
virtual double SAL_CALL getOptProbInMoney( double spot, double vol,
double mu, double T,
double barrier_low, double barrier_up,
const ANY& strikeval, const ANY& put_call ) THROWDEF_RTE_IAE;
const css::uno::Any& strikeval, const css::uno::Any& put_call ) throw( css::uno::RuntimeException, css::lang::IllegalArgumentException );
};
//------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment