Kaydet (Commit) 56b40400 authored tarafından Alexandre Vicenzi's avatar Alexandre Vicenzi Kaydeden (comit) Marcos Souza

fdo#54938 Convert oox and scaddins to cppu::supportsService

Change-Id: If75e6e96887d63a555094a2a9c73ca8a157fe964
Reviewed-on: https://gerrit.libreoffice.org/7836Tested-by: 's avatarLibreOffice gerrit bot <gerrit@libreoffice.org>
Reviewed-by: 's avatarMarcos Souza <marcos.souza.org@gmail.com>
üst ff5ad7e3
...@@ -17,20 +17,21 @@ ...@@ -17,20 +17,21 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include "oox/core/filterbase.hxx"
#include <set>
#include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/drawing/XShape.hpp>
#include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/task/XStatusIndicator.hpp>
#include <com/sun/star/task/XInteractionHandler.hpp> #include <com/sun/star/task/XInteractionHandler.hpp>
#include <com/sun/star/task/XStatusIndicator.hpp>
#include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/drawing/XShape.hpp>
#include <comphelper/docpasswordhelper.hxx> #include <comphelper/docpasswordhelper.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <unotools/mediadescriptor.hxx> #include <unotools/mediadescriptor.hxx>
#include <osl/mutex.hxx> #include <osl/mutex.hxx>
#include <rtl/instance.hxx> #include <rtl/instance.hxx>
#include <rtl/uri.hxx> #include <rtl/uri.hxx>
#include <set>
#include "oox/core/filterbase.hxx"
#include "oox/helper/binaryinputstream.hxx" #include "oox/helper/binaryinputstream.hxx"
#include "oox/helper/binaryoutputstream.hxx" #include "oox/helper/binaryoutputstream.hxx"
#include "oox/helper/graphichelper.hxx" #include "oox/helper/graphichelper.hxx"
...@@ -41,8 +42,6 @@ ...@@ -41,8 +42,6 @@
namespace oox { namespace oox {
namespace core { namespace core {
// ============================================================================
using namespace ::com::sun::star::beans; using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::frame; using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::graphic; using namespace ::com::sun::star::graphic;
...@@ -58,8 +57,6 @@ using ::comphelper::SequenceAsHashMap; ...@@ -58,8 +57,6 @@ using ::comphelper::SequenceAsHashMap;
using ::oox::ole::OleObjectHelper; using ::oox::ole::OleObjectHelper;
using ::oox::ole::VbaProject; using ::oox::ole::VbaProject;
// ============================================================================
namespace { namespace {
struct UrlPool struct UrlPool
...@@ -70,8 +67,6 @@ struct UrlPool ...@@ -70,8 +67,6 @@ struct UrlPool
struct StaticUrlPool : public ::rtl::Static< UrlPool, StaticUrlPool > {}; struct StaticUrlPool : public ::rtl::Static< UrlPool, StaticUrlPool > {};
// ----------------------------------------------------------------------------
/** This guard prevents recursive loading/saving of the same document. */ /** This guard prevents recursive loading/saving of the same document. */
class DocumentOpenedGuard class DocumentOpenedGuard
{ {
...@@ -111,8 +106,6 @@ DocumentOpenedGuard::~DocumentOpenedGuard() ...@@ -111,8 +106,6 @@ DocumentOpenedGuard::~DocumentOpenedGuard()
} // namespace } // namespace
// ============================================================================
/** Specifies whether this filter is an import or export filter. */ /** Specifies whether this filter is an import or export filter. */
enum FilterDirection enum FilterDirection
{ {
...@@ -121,8 +114,6 @@ enum FilterDirection ...@@ -121,8 +114,6 @@ enum FilterDirection
FILTERDIRECTION_EXPORT FILTERDIRECTION_EXPORT
}; };
// ----------------------------------------------------------------------------
struct FilterBaseImpl struct FilterBaseImpl
{ {
typedef ::boost::shared_ptr< GraphicHelper > GraphicHelperRef; typedef ::boost::shared_ptr< GraphicHelper > GraphicHelperRef;
...@@ -161,8 +152,6 @@ struct FilterBaseImpl ...@@ -161,8 +152,6 @@ struct FilterBaseImpl
void initializeFilter(); void initializeFilter();
}; };
// ----------------------------------------------------------------------------
FilterBaseImpl::FilterBaseImpl( const Reference< XComponentContext >& rxContext ) throw( RuntimeException ) : FilterBaseImpl::FilterBaseImpl( const Reference< XComponentContext >& rxContext ) throw( RuntimeException ) :
meDirection( FILTERDIRECTION_UNKNOWN ), meDirection( FILTERDIRECTION_UNKNOWN ),
meVersion( ECMA_DIALECT ), meVersion( ECMA_DIALECT ),
...@@ -352,7 +341,7 @@ void FilterBase::commitStorage() const ...@@ -352,7 +341,7 @@ void FilterBase::commitStorage() const
mxImpl->mxStorage->commit(); mxImpl->mxStorage->commit();
} }
// helpers -------------------------------------------------------------------- // helpers
GraphicHelper& FilterBase::getGraphicHelper() const GraphicHelper& FilterBase::getGraphicHelper() const
{ {
...@@ -399,7 +388,7 @@ bool FilterBase::importBinaryData( StreamDataSequence& orDataSeq, const OUString ...@@ -399,7 +388,7 @@ bool FilterBase::importBinaryData( StreamDataSequence& orDataSeq, const OUString
return true; return true;
} }
// com.sun.star.lang.XServiceInfo interface ----------------------------------- // com.sun.star.lang.XServiceInfo interface
OUString SAL_CALL FilterBase::getImplementationName() throw( RuntimeException ) OUString SAL_CALL FilterBase::getImplementationName() throw( RuntimeException )
{ {
...@@ -408,9 +397,7 @@ OUString SAL_CALL FilterBase::getImplementationName() throw( RuntimeException ) ...@@ -408,9 +397,7 @@ OUString SAL_CALL FilterBase::getImplementationName() throw( RuntimeException )
sal_Bool SAL_CALL FilterBase::supportsService( const OUString& rServiceName ) throw( RuntimeException ) sal_Bool SAL_CALL FilterBase::supportsService( const OUString& rServiceName ) throw( RuntimeException )
{ {
return return cppu::supportsService(this, rServiceName);
(rServiceName == "com.sun.star.document.ImportFilter" ) ||
(rServiceName == "com.sun.star.document.ExportFilter" );
} }
Sequence< OUString > SAL_CALL FilterBase::getSupportedServiceNames() throw( RuntimeException ) Sequence< OUString > SAL_CALL FilterBase::getSupportedServiceNames() throw( RuntimeException )
...@@ -421,7 +408,7 @@ Sequence< OUString > SAL_CALL FilterBase::getSupportedServiceNames() throw( Runt ...@@ -421,7 +408,7 @@ Sequence< OUString > SAL_CALL FilterBase::getSupportedServiceNames() throw( Runt
return aServiceNames; return aServiceNames;
} }
// com.sun.star.lang.XInitialization interface -------------------------------- // com.sun.star.lang.XInitialization interface
void SAL_CALL FilterBase::initialize( const Sequence< Any >& rArgs ) throw( Exception, RuntimeException ) void SAL_CALL FilterBase::initialize( const Sequence< Any >& rArgs ) throw( Exception, RuntimeException )
{ {
...@@ -434,7 +421,7 @@ void SAL_CALL FilterBase::initialize( const Sequence< Any >& rArgs ) throw( Exce ...@@ -434,7 +421,7 @@ void SAL_CALL FilterBase::initialize( const Sequence< Any >& rArgs ) throw( Exce
} }
} }
// com.sun.star.document.XImporter interface ---------------------------------- // com.sun.star.document.XImporter interface
void SAL_CALL FilterBase::setTargetDocument( const Reference< XComponent >& rxDocument ) throw( IllegalArgumentException, RuntimeException ) void SAL_CALL FilterBase::setTargetDocument( const Reference< XComponent >& rxDocument ) throw( IllegalArgumentException, RuntimeException )
{ {
...@@ -442,7 +429,7 @@ void SAL_CALL FilterBase::setTargetDocument( const Reference< XComponent >& rxDo ...@@ -442,7 +429,7 @@ void SAL_CALL FilterBase::setTargetDocument( const Reference< XComponent >& rxDo
mxImpl->meDirection = FILTERDIRECTION_IMPORT; mxImpl->meDirection = FILTERDIRECTION_IMPORT;
} }
// com.sun.star.document.XExporter interface ---------------------------------- // com.sun.star.document.XExporter interface
void SAL_CALL FilterBase::setSourceDocument( const Reference< XComponent >& rxDocument ) throw( IllegalArgumentException, RuntimeException ) void SAL_CALL FilterBase::setSourceDocument( const Reference< XComponent >& rxDocument ) throw( IllegalArgumentException, RuntimeException )
{ {
...@@ -450,7 +437,7 @@ void SAL_CALL FilterBase::setSourceDocument( const Reference< XComponent >& rxDo ...@@ -450,7 +437,7 @@ void SAL_CALL FilterBase::setSourceDocument( const Reference< XComponent >& rxDo
mxImpl->meDirection = FILTERDIRECTION_EXPORT; mxImpl->meDirection = FILTERDIRECTION_EXPORT;
} }
// com.sun.star.document.XFilter interface ------------------------------------ // com.sun.star.document.XFilter interface
sal_Bool SAL_CALL FilterBase::filter( const Sequence< PropertyValue >& rMediaDescSeq ) throw( RuntimeException ) sal_Bool SAL_CALL FilterBase::filter( const Sequence< PropertyValue >& rMediaDescSeq ) throw( RuntimeException )
{ {
...@@ -491,7 +478,7 @@ void SAL_CALL FilterBase::cancel() throw( RuntimeException ) ...@@ -491,7 +478,7 @@ void SAL_CALL FilterBase::cancel() throw( RuntimeException )
{ {
} }
// protected ------------------------------------------------------------------ // protected
Reference< XInputStream > FilterBase::implGetInputStream( MediaDescriptor& rMediaDesc ) const Reference< XInputStream > FilterBase::implGetInputStream( MediaDescriptor& rMediaDesc ) const
{ {
...@@ -513,7 +500,7 @@ Reference< XStream > FilterBase::getMainDocumentStream( ) const ...@@ -513,7 +500,7 @@ Reference< XStream > FilterBase::getMainDocumentStream( ) const
return mxImpl->mxOutStream; return mxImpl->mxOutStream;
} }
// private -------------------------------------------------------------------- // private
void FilterBase::setMediaDescriptor( const Sequence< PropertyValue >& rMediaDescSeq ) void FilterBase::setMediaDescriptor( const Sequence< PropertyValue >& rMediaDescSeq )
{ {
...@@ -568,8 +555,6 @@ GraphicHelper* FilterBase::implCreateGraphicHelper() const ...@@ -568,8 +555,6 @@ GraphicHelper* FilterBase::implCreateGraphicHelper() const
return new GraphicHelper( mxImpl->mxComponentContext, mxImpl->mxTargetFrame, mxImpl->mxStorage ); return new GraphicHelper( mxImpl->mxComponentContext, mxImpl->mxTargetFrame, mxImpl->mxStorage );
} }
// ============================================================================
} // namespace core } // namespace core
} // namespace oox } // namespace oox
......
...@@ -17,36 +17,25 @@ ...@@ -17,36 +17,25 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
//------------------------------------------------------------------
//
// date functions add in
//
//------------------------------------------------------------------
#include "datefunc.hxx" #include "datefunc.hxx"
#include "datefunc.hrc" #include "datefunc.hrc"
#include <com/sun/star/util/Date.hpp>
#include <cppuhelper/factory.hxx> #include <cppuhelper/factory.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <osl/diagnose.h> #include <osl/diagnose.h>
#include <rtl/ustrbuf.hxx> #include <rtl/ustrbuf.hxx>
#include <tools/resmgr.hxx>
#include <tools/rcid.h> #include <tools/rcid.h>
#include <com/sun/star/util/Date.hpp> #include <tools/resmgr.hxx>
using namespace ::com::sun::star; using namespace ::com::sun::star;
using namespace ::rtl; using namespace ::rtl;
//------------------------------------------------------------------
#define ADDIN_SERVICE "com.sun.star.sheet.AddIn" #define ADDIN_SERVICE "com.sun.star.sheet.AddIn"
#define MY_SERVICE "com.sun.star.sheet.addin.DateFunctions" #define MY_SERVICE "com.sun.star.sheet.addin.DateFunctions"
#define MY_IMPLNAME "com.sun.star.sheet.addin.DateFunctionsImpl" #define MY_IMPLNAME "com.sun.star.sheet.addin.DateFunctionsImpl"
//------------------------------------------------------------------
#define STR_FROM_ANSI( s ) OUString( s, strlen( s ), RTL_TEXTENCODING_MS_1252 ) #define STR_FROM_ANSI( s ) OUString( s, strlen( s ), RTL_TEXTENCODING_MS_1252 )
//------------------------------------------------------------------
const sal_uInt32 ScaList::nStartSize = 16; const sal_uInt32 ScaList::nStartSize = 16;
const sal_uInt32 ScaList::nIncrSize = 16; const sal_uInt32 ScaList::nIncrSize = 16;
...@@ -74,24 +63,17 @@ void ScaList::_Grow() ...@@ -74,24 +63,17 @@ void ScaList::_Grow()
pData = pNewData; pData = pNewData;
} }
//------------------------------------------------------------------
ScaStringList::~ScaStringList() ScaStringList::~ScaStringList()
{ {
for( OUString* pStr = First(); pStr; pStr = Next() ) for( OUString* pStr = First(); pStr; pStr = Next() )
delete pStr; delete pStr;
} }
//------------------------------------------------------------------
ScaResId::ScaResId( sal_uInt16 nId, ResMgr& rResMgr ) : ScaResId::ScaResId( sal_uInt16 nId, ResMgr& rResMgr ) :
ResId( nId, rResMgr ) ResId( nId, rResMgr )
{ {
} }
//------------------------------------------------------------------
#define UNIQUE sal_False // function name does not exist in Calc #define UNIQUE sal_False // function name does not exist in Calc
#define STDPAR sal_False // all parameters are described #define STDPAR sal_False // all parameters are described
...@@ -114,9 +96,6 @@ const ScaFuncDataBase pFuncDataArr[] = ...@@ -114,9 +96,6 @@ const ScaFuncDataBase pFuncDataArr[] =
#undef FUNCDATA #undef FUNCDATA
//------------------------------------------------------------------
ScaFuncData::ScaFuncData( const ScaFuncDataBase& rBaseData, ResMgr& rResMgr ) : ScaFuncData::ScaFuncData( const ScaFuncDataBase& rBaseData, ResMgr& rResMgr ) :
aIntName( OUString::createFromAscii( rBaseData.pIntName ) ), aIntName( OUString::createFromAscii( rBaseData.pIntName ) ),
nUINameID( rBaseData.nUINameID ), nUINameID( rBaseData.nUINameID ),
...@@ -146,8 +125,6 @@ sal_uInt16 ScaFuncData::GetStrIndex( sal_uInt16 nParam ) const ...@@ -146,8 +125,6 @@ sal_uInt16 ScaFuncData::GetStrIndex( sal_uInt16 nParam ) const
} }
//------------------------------------------------------------------
ScaFuncDataList::ScaFuncDataList( ResMgr& rResMgr ) : ScaFuncDataList::ScaFuncDataList( ResMgr& rResMgr ) :
nLast( 0xFFFFFFFF ) nLast( 0xFFFFFFFF )
{ {
...@@ -179,9 +156,6 @@ const ScaFuncData* ScaFuncDataList::Get( const OUString& rProgrammaticName ) con ...@@ -179,9 +156,6 @@ const ScaFuncData* ScaFuncDataList::Get( const OUString& rProgrammaticName ) con
return NULL; return NULL;
} }
//------------------------------------------------------------------
ScaFuncRes::ScaFuncRes( ResId& rResId, ResMgr& rResMgr, sal_uInt16 nIndex, OUString& rRet ) : ScaFuncRes::ScaFuncRes( ResId& rResId, ResMgr& rResMgr, sal_uInt16 nIndex, OUString& rRet ) :
Resource( rResId ) Resource( rResId )
{ {
...@@ -189,13 +163,7 @@ ScaFuncRes::ScaFuncRes( ResId& rResId, ResMgr& rResMgr, sal_uInt16 nIndex, OUStr ...@@ -189,13 +163,7 @@ ScaFuncRes::ScaFuncRes( ResId& rResId, ResMgr& rResMgr, sal_uInt16 nIndex, OUStr
FreeResource(); FreeResource();
} }
//------------------------------------------------------------------
//
// entry points for service registration / instantiation // entry points for service registration / instantiation
//
//------------------------------------------------------------------
uno::Reference< uno::XInterface > SAL_CALL ScaDateAddIn_CreateInstance( uno::Reference< uno::XInterface > SAL_CALL ScaDateAddIn_CreateInstance(
const uno::Reference< lang::XMultiServiceFactory >& ) const uno::Reference< lang::XMultiServiceFactory >& )
{ {
...@@ -203,9 +171,6 @@ uno::Reference< uno::XInterface > SAL_CALL ScaDateAddIn_CreateInstance( ...@@ -203,9 +171,6 @@ uno::Reference< uno::XInterface > SAL_CALL ScaDateAddIn_CreateInstance(
return xInst; return xInst;
} }
//------------------------------------------------------------------------
extern "C" { extern "C" {
SAL_DLLPUBLIC_EXPORT void * SAL_CALL date_component_getFactory( SAL_DLLPUBLIC_EXPORT void * SAL_CALL date_component_getFactory(
...@@ -234,12 +199,7 @@ SAL_DLLPUBLIC_EXPORT void * SAL_CALL date_component_getFactory( ...@@ -234,12 +199,7 @@ SAL_DLLPUBLIC_EXPORT void * SAL_CALL date_component_getFactory(
} // extern C } // extern C
//------------------------------------------------------------------------
//
// "normal" service implementation // "normal" service implementation
//
//------------------------------------------------------------------------
ScaDateAddIn::ScaDateAddIn() : ScaDateAddIn::ScaDateAddIn() :
pDefLocales( NULL ), pDefLocales( NULL ),
pResMgr( NULL ), pResMgr( NULL ),
...@@ -331,9 +291,6 @@ OUString ScaDateAddIn::GetFuncDescrStr( sal_uInt16 nResId, sal_uInt16 nStrIndex ...@@ -331,9 +291,6 @@ OUString ScaDateAddIn::GetFuncDescrStr( sal_uInt16 nResId, sal_uInt16 nStrIndex
return aRet; return aRet;
} }
//------------------------------------------------------------------------
OUString ScaDateAddIn::getImplementationName_Static() OUString ScaDateAddIn::getImplementationName_Static()
{ {
return OUString( MY_IMPLNAME ); return OUString( MY_IMPLNAME );
...@@ -349,7 +306,6 @@ uno::Sequence< OUString > ScaDateAddIn::getSupportedServiceNames_Static() ...@@ -349,7 +306,6 @@ uno::Sequence< OUString > ScaDateAddIn::getSupportedServiceNames_Static()
} }
// XServiceName // XServiceName
OUString SAL_CALL ScaDateAddIn::getServiceName() throw( uno::RuntimeException ) OUString SAL_CALL ScaDateAddIn::getServiceName() throw( uno::RuntimeException )
{ {
// name of specific AddIn service // name of specific AddIn service
...@@ -357,7 +313,6 @@ OUString SAL_CALL ScaDateAddIn::getServiceName() throw( uno::RuntimeException ) ...@@ -357,7 +313,6 @@ OUString SAL_CALL ScaDateAddIn::getServiceName() throw( uno::RuntimeException )
} }
// XServiceInfo // XServiceInfo
OUString SAL_CALL ScaDateAddIn::getImplementationName() throw( uno::RuntimeException ) OUString SAL_CALL ScaDateAddIn::getImplementationName() throw( uno::RuntimeException )
{ {
return getImplementationName_Static(); return getImplementationName_Static();
...@@ -365,7 +320,7 @@ OUString SAL_CALL ScaDateAddIn::getImplementationName() throw( uno::RuntimeExcep ...@@ -365,7 +320,7 @@ OUString SAL_CALL ScaDateAddIn::getImplementationName() throw( uno::RuntimeExcep
sal_Bool SAL_CALL ScaDateAddIn::supportsService( const OUString& aServiceName ) throw( uno::RuntimeException ) sal_Bool SAL_CALL ScaDateAddIn::supportsService( const OUString& aServiceName ) throw( uno::RuntimeException )
{ {
return aServiceName == ADDIN_SERVICE || aServiceName == MY_SERVICE; return cppu::supportsService(this, aServiceName);
} }
uno::Sequence< OUString > SAL_CALL ScaDateAddIn::getSupportedServiceNames() throw( uno::RuntimeException ) uno::Sequence< OUString > SAL_CALL ScaDateAddIn::getSupportedServiceNames() throw( uno::RuntimeException )
...@@ -374,7 +329,6 @@ uno::Sequence< OUString > SAL_CALL ScaDateAddIn::getSupportedServiceNames() thro ...@@ -374,7 +329,6 @@ uno::Sequence< OUString > SAL_CALL ScaDateAddIn::getSupportedServiceNames() thro
} }
// XLocalizable // XLocalizable
void SAL_CALL ScaDateAddIn::setLocale( const lang::Locale& eLocale ) throw( uno::RuntimeException ) void SAL_CALL ScaDateAddIn::setLocale( const lang::Locale& eLocale ) throw( uno::RuntimeException )
{ {
aFuncLoc = eLocale; aFuncLoc = eLocale;
...@@ -386,14 +340,6 @@ lang::Locale SAL_CALL ScaDateAddIn::getLocale() throw( uno::RuntimeException ) ...@@ -386,14 +340,6 @@ lang::Locale SAL_CALL ScaDateAddIn::getLocale() throw( uno::RuntimeException )
return aFuncLoc; return aFuncLoc;
} }
//------------------------------------------------------------------
//
// function descriptions start here
//
//------------------------------------------------------------------
// XAddIn
OUString SAL_CALL ScaDateAddIn::getProgrammaticFuntionName( const OUString& ) throw( uno::RuntimeException ) OUString SAL_CALL ScaDateAddIn::getProgrammaticFuntionName( const OUString& ) throw( uno::RuntimeException )
{ {
// not used by calc // not used by calc
...@@ -500,9 +446,7 @@ OUString SAL_CALL ScaDateAddIn::getDisplayCategoryName( ...@@ -500,9 +446,7 @@ OUString SAL_CALL ScaDateAddIn::getDisplayCategoryName(
return getProgrammaticCategoryName( aProgrammaticName ); return getProgrammaticCategoryName( aProgrammaticName );
} }
// XCompatibilityNames // XCompatibilityNames
uno::Sequence< sheet::LocalizedName > SAL_CALL ScaDateAddIn::getCompatibilityNames( uno::Sequence< sheet::LocalizedName > SAL_CALL ScaDateAddIn::getCompatibilityNames(
const OUString& aProgrammaticName ) throw( uno::RuntimeException ) const OUString& aProgrammaticName ) throw( uno::RuntimeException )
{ {
...@@ -523,8 +467,8 @@ uno::Sequence< sheet::LocalizedName > SAL_CALL ScaDateAddIn::getCompatibilityNam ...@@ -523,8 +467,8 @@ uno::Sequence< sheet::LocalizedName > SAL_CALL ScaDateAddIn::getCompatibilityNam
} }
namespace { namespace {
// auxiliary functions
// auxiliary functions
sal_Bool IsLeapYear( sal_uInt16 nYear ) sal_Bool IsLeapYear( sal_uInt16 nYear )
{ {
return ((((nYear % 4) == 0) && ((nYear % 100) != 0)) || ((nYear % 400) == 0)); return ((((nYear % 4) == 0) && ((nYear % 100) != 0)) || ((nYear % 400) == 0));
...@@ -630,7 +574,6 @@ void DaysToDate( sal_Int32 nDays, ...@@ -630,7 +574,6 @@ void DaysToDate( sal_Int32 nDays,
* this function returns this internal Date value for the document null date * this function returns this internal Date value for the document null date
* *
*/ */
sal_Int32 GetNullDate( const uno::Reference< beans::XPropertySet >& xOptions ) sal_Int32 GetNullDate( const uno::Reference< beans::XPropertySet >& xOptions )
throw( uno::RuntimeException ) throw( uno::RuntimeException )
{ {
...@@ -745,7 +688,6 @@ sal_Int32 SAL_CALL ScaDateAddIn::getDiffWeeks( ...@@ -745,7 +688,6 @@ sal_Int32 SAL_CALL ScaDateAddIn::getDiffWeeks(
* *
* mode 1 is the difference in calendar month * mode 1 is the difference in calendar month
*/ */
sal_Int32 SAL_CALL ScaDateAddIn::getDiffMonths( sal_Int32 SAL_CALL ScaDateAddIn::getDiffMonths(
const uno::Reference< beans::XPropertySet >& xOptions, const uno::Reference< beans::XPropertySet >& xOptions,
sal_Int32 nStartDate, sal_Int32 nEndDate, sal_Int32 nStartDate, sal_Int32 nEndDate,
...@@ -791,7 +733,6 @@ sal_Int32 SAL_CALL ScaDateAddIn::getDiffMonths( ...@@ -791,7 +733,6 @@ sal_Int32 SAL_CALL ScaDateAddIn::getDiffMonths(
* *
* mode 1 is the difference in calendar years * mode 1 is the difference in calendar years
*/ */
sal_Int32 SAL_CALL ScaDateAddIn::getDiffYears( sal_Int32 SAL_CALL ScaDateAddIn::getDiffYears(
const uno::Reference< beans::XPropertySet >& xOptions, const uno::Reference< beans::XPropertySet >& xOptions,
sal_Int32 nStartDate, sal_Int32 nEndDate, sal_Int32 nStartDate, sal_Int32 nEndDate,
...@@ -816,7 +757,6 @@ sal_Int32 SAL_CALL ScaDateAddIn::getDiffYears( ...@@ -816,7 +757,6 @@ sal_Int32 SAL_CALL ScaDateAddIn::getDiffYears(
/** /**
* Check if a Date is in a leap year in the Gregorian calendar * Check if a Date is in a leap year in the Gregorian calendar
*/ */
sal_Int32 SAL_CALL ScaDateAddIn::getIsLeapYear( sal_Int32 SAL_CALL ScaDateAddIn::getIsLeapYear(
const uno::Reference< beans::XPropertySet >& xOptions, const uno::Reference< beans::XPropertySet >& xOptions,
sal_Int32 nDate ) throw( uno::RuntimeException, lang::IllegalArgumentException ) sal_Int32 nDate ) throw( uno::RuntimeException, lang::IllegalArgumentException )
...@@ -833,7 +773,6 @@ sal_Int32 SAL_CALL ScaDateAddIn::getIsLeapYear( ...@@ -833,7 +773,6 @@ sal_Int32 SAL_CALL ScaDateAddIn::getIsLeapYear(
/** /**
* Get the Number of Days in the month for a date * Get the Number of Days in the month for a date
*/ */
sal_Int32 SAL_CALL ScaDateAddIn::getDaysInMonth( sal_Int32 SAL_CALL ScaDateAddIn::getDaysInMonth(
const uno::Reference<beans::XPropertySet>& xOptions, const uno::Reference<beans::XPropertySet>& xOptions,
sal_Int32 nDate ) throw( uno::RuntimeException, lang::IllegalArgumentException ) sal_Int32 nDate ) throw( uno::RuntimeException, lang::IllegalArgumentException )
...@@ -850,7 +789,6 @@ sal_Int32 SAL_CALL ScaDateAddIn::getDaysInMonth( ...@@ -850,7 +789,6 @@ sal_Int32 SAL_CALL ScaDateAddIn::getDaysInMonth(
/** /**
* Get number of days in the year of a date specified * Get number of days in the year of a date specified
*/ */
sal_Int32 SAL_CALL ScaDateAddIn::getDaysInYear( sal_Int32 SAL_CALL ScaDateAddIn::getDaysInYear(
const uno::Reference< beans::XPropertySet >& xOptions, const uno::Reference< beans::XPropertySet >& xOptions,
sal_Int32 nDate ) throw( uno::RuntimeException, lang::IllegalArgumentException ) sal_Int32 nDate ) throw( uno::RuntimeException, lang::IllegalArgumentException )
...@@ -879,7 +817,6 @@ sal_Int32 SAL_CALL ScaDateAddIn::getDaysInYear( ...@@ -879,7 +817,6 @@ sal_Int32 SAL_CALL ScaDateAddIn::getDaysInYear(
* *
* @see #IsLeapYear #WeekNumber * @see #IsLeapYear #WeekNumber
*/ */
sal_Int32 SAL_CALL ScaDateAddIn::getWeeksInYear( sal_Int32 SAL_CALL ScaDateAddIn::getWeeksInYear(
const uno::Reference< beans::XPropertySet >& xOptions, const uno::Reference< beans::XPropertySet >& xOptions,
sal_Int32 nDate ) throw( uno::RuntimeException, lang::IllegalArgumentException ) sal_Int32 nDate ) throw( uno::RuntimeException, lang::IllegalArgumentException )
...@@ -909,7 +846,6 @@ sal_Int32 SAL_CALL ScaDateAddIn::getWeeksInYear( ...@@ -909,7 +846,6 @@ sal_Int32 SAL_CALL ScaDateAddIn::getWeeksInYear(
* This function rotates each character by 13 in the alphabet. * This function rotates each character by 13 in the alphabet.
* Only the characters 'a' ... 'z' and 'A' ... 'Z' are modified. * Only the characters 'a' ... 'z' and 'A' ... 'Z' are modified.
*/ */
OUString SAL_CALL ScaDateAddIn::getRot13( const OUString& aSrcString ) throw( uno::RuntimeException, lang::IllegalArgumentException ) OUString SAL_CALL ScaDateAddIn::getRot13( const OUString& aSrcString ) throw( uno::RuntimeException, lang::IllegalArgumentException )
{ {
OUStringBuffer aBuffer( aSrcString ); OUStringBuffer aBuffer( aSrcString );
...@@ -924,6 +860,4 @@ OUString SAL_CALL ScaDateAddIn::getRot13( const OUString& aSrcString ) throw( un ...@@ -924,6 +860,4 @@ OUString SAL_CALL ScaDateAddIn::getRot13( const OUString& aSrcString ) throw( un
return aBuffer.makeStringAndClear(); return aBuffer.makeStringAndClear();
} }
//------------------------------------------------------------------
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -17,43 +17,34 @@ ...@@ -17,43 +17,34 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
//------------------------------------------------------------------
//
// pricing functions add in // pricing functions add in
// //
// all of the UNO add-in technical details have been copied from // all of the UNO add-in technical details have been copied from
// ../datefunc/datefunc.cxx // ../datefunc/datefunc.cxx
//
//------------------------------------------------------------------
#include "pricing.hxx" #include "pricing.hxx"
#include "black_scholes.hxx" #include "black_scholes.hxx"
#include "pricing.hrc" #include "pricing.hrc"
#include <cppuhelper/factory.hxx> #include <cppuhelper/factory.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <iostream>
#include <osl/diagnose.h> #include <osl/diagnose.h>
#include <rtl/ustrbuf.hxx>
#include <rtl/math.hxx> #include <rtl/math.hxx>
#include <tools/resmgr.hxx> #include <rtl/ustrbuf.hxx>
#include <tools/rcid.h> #include <tools/rcid.h>
#include <tools/resmgr.hxx>
#include <iostream>
using namespace ::com::sun::star; using namespace ::com::sun::star;
using namespace sca::pricing; using namespace sca::pricing;
//------------------------------------------------------------------
#define ADDIN_SERVICE "com.sun.star.sheet.AddIn" #define ADDIN_SERVICE "com.sun.star.sheet.AddIn"
#define MY_SERVICE "com.sun.star.sheet.addin.PricingFunctions" #define MY_SERVICE "com.sun.star.sheet.addin.PricingFunctions"
#define MY_IMPLNAME "com.sun.star.sheet.addin.PricingFunctionsImpl" #define MY_IMPLNAME "com.sun.star.sheet.addin.PricingFunctionsImpl"
//------------------------------------------------------------------
#define STR_FROM_ANSI( s ) OUString( s, strlen( s ), RTL_TEXTENCODING_MS_1252 ) #define STR_FROM_ANSI( s ) OUString( s, strlen( s ), RTL_TEXTENCODING_MS_1252 )
//------------------------------------------------------------------
const sal_uInt32 ScaList::nStartSize = 16; const sal_uInt32 ScaList::nStartSize = 16;
const sal_uInt32 ScaList::nIncrSize = 16; const sal_uInt32 ScaList::nIncrSize = 16;
...@@ -81,24 +72,17 @@ void ScaList::_Grow() ...@@ -81,24 +72,17 @@ void ScaList::_Grow()
pData = pNewData; pData = pNewData;
} }
//------------------------------------------------------------------
ScaStringList::~ScaStringList() ScaStringList::~ScaStringList()
{ {
for( OUString* pStr = First(); pStr; pStr = Next() ) for( OUString* pStr = First(); pStr; pStr = Next() )
delete pStr; delete pStr;
} }
//------------------------------------------------------------------
ScaResId::ScaResId( sal_uInt16 nId, ResMgr& rResMgr ) : ScaResId::ScaResId( sal_uInt16 nId, ResMgr& rResMgr ) :
ResId( nId, rResMgr ) ResId( nId, rResMgr )
{ {
} }
//------------------------------------------------------------------
#define UNIQUE sal_False // function name does not exist in Calc #define UNIQUE sal_False // function name does not exist in Calc
#define STDPAR sal_False // all parameters are described #define STDPAR sal_False // all parameters are described
...@@ -116,9 +100,6 @@ const ScaFuncDataBase pFuncDataArr[] = ...@@ -116,9 +100,6 @@ const ScaFuncDataBase pFuncDataArr[] =
#undef FUNCDATA #undef FUNCDATA
//------------------------------------------------------------------
ScaFuncData::ScaFuncData( const ScaFuncDataBase& rBaseData, ResMgr& rResMgr ) : ScaFuncData::ScaFuncData( const ScaFuncDataBase& rBaseData, ResMgr& rResMgr ) :
aIntName( OUString::createFromAscii( rBaseData.pIntName ) ), aIntName( OUString::createFromAscii( rBaseData.pIntName ) ),
nUINameID( rBaseData.nUINameID ), nUINameID( rBaseData.nUINameID ),
...@@ -147,9 +128,6 @@ sal_uInt16 ScaFuncData::GetStrIndex( sal_uInt16 nParam ) const ...@@ -147,9 +128,6 @@ sal_uInt16 ScaFuncData::GetStrIndex( sal_uInt16 nParam ) const
return (nParam > nParamCount) ? (nParamCount * 2) : (nParam * 2); return (nParam > nParamCount) ? (nParamCount * 2) : (nParam * 2);
} }
//------------------------------------------------------------------
ScaFuncDataList::ScaFuncDataList( ResMgr& rResMgr ) : ScaFuncDataList::ScaFuncDataList( ResMgr& rResMgr ) :
nLast( 0xFFFFFFFF ) nLast( 0xFFFFFFFF )
{ {
...@@ -183,7 +161,6 @@ const ScaFuncData* ScaFuncDataList::Get( const OUString& rProgrammaticName ) con ...@@ -183,7 +161,6 @@ const ScaFuncData* ScaFuncDataList::Get( const OUString& rProgrammaticName ) con
} }
//------------------------------------------------------------------
ScaFuncRes::ScaFuncRes( ResId& rResId, ResMgr& rResMgr, sal_uInt16 nIndex, OUString& rRet ) : ScaFuncRes::ScaFuncRes( ResId& rResId, ResMgr& rResMgr, sal_uInt16 nIndex, OUString& rRet ) :
Resource( rResId ) Resource( rResId )
...@@ -192,13 +169,7 @@ ScaFuncRes::ScaFuncRes( ResId& rResId, ResMgr& rResMgr, sal_uInt16 nIndex, OUStr ...@@ -192,13 +169,7 @@ ScaFuncRes::ScaFuncRes( ResId& rResId, ResMgr& rResMgr, sal_uInt16 nIndex, OUStr
FreeResource(); FreeResource();
} }
// entry points for service registration / instantiation
//------------------------------------------------------------------
//
// entry points for service registration / instantiation
//
//------------------------------------------------------------------
uno::Reference< uno::XInterface > SAL_CALL ScaPricingAddIn_CreateInstance( uno::Reference< uno::XInterface > SAL_CALL ScaPricingAddIn_CreateInstance(
const uno::Reference< lang::XMultiServiceFactory >& ) const uno::Reference< lang::XMultiServiceFactory >& )
{ {
...@@ -207,8 +178,6 @@ uno::Reference< uno::XInterface > SAL_CALL ScaPricingAddIn_CreateInstance( ...@@ -207,8 +178,6 @@ uno::Reference< uno::XInterface > SAL_CALL ScaPricingAddIn_CreateInstance(
} }
//------------------------------------------------------------------------
extern "C" { extern "C" {
SAL_DLLPUBLIC_EXPORT void * SAL_CALL pricing_component_getFactory( SAL_DLLPUBLIC_EXPORT void * SAL_CALL pricing_component_getFactory(
...@@ -237,12 +206,7 @@ SAL_DLLPUBLIC_EXPORT void * SAL_CALL pricing_component_getFactory( ...@@ -237,12 +206,7 @@ SAL_DLLPUBLIC_EXPORT void * SAL_CALL pricing_component_getFactory(
} // extern C } // extern C
//------------------------------------------------------------------------
//
// "normal" service implementation // "normal" service implementation
//
//------------------------------------------------------------------------
ScaPricingAddIn::ScaPricingAddIn() : ScaPricingAddIn::ScaPricingAddIn() :
pDefLocales( NULL ), pDefLocales( NULL ),
pResMgr( NULL ), pResMgr( NULL ),
...@@ -335,9 +299,6 @@ OUString ScaPricingAddIn::GetFuncDescrStr( sal_uInt16 nResId, sal_uInt16 nStrInd ...@@ -335,9 +299,6 @@ OUString ScaPricingAddIn::GetFuncDescrStr( sal_uInt16 nResId, sal_uInt16 nStrInd
return aRet; return aRet;
} }
//------------------------------------------------------------------------
OUString ScaPricingAddIn::getImplementationName_Static() OUString ScaPricingAddIn::getImplementationName_Static()
{ {
return OUString( MY_IMPLNAME ); return OUString( MY_IMPLNAME );
...@@ -353,7 +314,6 @@ uno::Sequence< OUString > ScaPricingAddIn::getSupportedServiceNames_Static() ...@@ -353,7 +314,6 @@ uno::Sequence< OUString > ScaPricingAddIn::getSupportedServiceNames_Static()
} }
// XServiceName // XServiceName
OUString SAL_CALL ScaPricingAddIn::getServiceName() throw( uno::RuntimeException ) OUString SAL_CALL ScaPricingAddIn::getServiceName() throw( uno::RuntimeException )
{ {
// name of specific AddIn service // name of specific AddIn service
...@@ -361,7 +321,6 @@ OUString SAL_CALL ScaPricingAddIn::getServiceName() throw( uno::RuntimeException ...@@ -361,7 +321,6 @@ OUString SAL_CALL ScaPricingAddIn::getServiceName() throw( uno::RuntimeException
} }
// XServiceInfo // XServiceInfo
OUString SAL_CALL ScaPricingAddIn::getImplementationName() throw( uno::RuntimeException ) OUString SAL_CALL ScaPricingAddIn::getImplementationName() throw( uno::RuntimeException )
{ {
return getImplementationName_Static(); return getImplementationName_Static();
...@@ -369,7 +328,7 @@ OUString SAL_CALL ScaPricingAddIn::getImplementationName() throw( uno::RuntimeEx ...@@ -369,7 +328,7 @@ OUString SAL_CALL ScaPricingAddIn::getImplementationName() throw( uno::RuntimeEx
sal_Bool SAL_CALL ScaPricingAddIn::supportsService( const OUString& aServiceName ) throw( uno::RuntimeException ) sal_Bool SAL_CALL ScaPricingAddIn::supportsService( const OUString& aServiceName ) throw( uno::RuntimeException )
{ {
return aServiceName == ADDIN_SERVICE || aServiceName == MY_SERVICE; return cppu::supportsService(this, aServiceName);
} }
uno::Sequence< OUString > SAL_CALL ScaPricingAddIn::getSupportedServiceNames() throw( uno::RuntimeException ) uno::Sequence< OUString > SAL_CALL ScaPricingAddIn::getSupportedServiceNames() throw( uno::RuntimeException )
...@@ -378,7 +337,6 @@ uno::Sequence< OUString > SAL_CALL ScaPricingAddIn::getSupportedServiceNames() t ...@@ -378,7 +337,6 @@ uno::Sequence< OUString > SAL_CALL ScaPricingAddIn::getSupportedServiceNames() t
} }
// XLocalizable // XLocalizable
void SAL_CALL ScaPricingAddIn::setLocale( const lang::Locale& eLocale ) throw( uno::RuntimeException ) void SAL_CALL ScaPricingAddIn::setLocale( const lang::Locale& eLocale ) throw( uno::RuntimeException )
{ {
aFuncLoc = eLocale; aFuncLoc = eLocale;
...@@ -390,12 +348,7 @@ lang::Locale SAL_CALL ScaPricingAddIn::getLocale() throw( uno::RuntimeException ...@@ -390,12 +348,7 @@ lang::Locale SAL_CALL ScaPricingAddIn::getLocale() throw( uno::RuntimeException
return aFuncLoc; return aFuncLoc;
} }
//------------------------------------------------------------------ // function descriptions start here
//
// function descriptions start here
//
//------------------------------------------------------------------
// XAddIn // XAddIn
OUString SAL_CALL ScaPricingAddIn::getProgrammaticFuntionName( const OUString& ) throw( uno::RuntimeException ) OUString SAL_CALL ScaPricingAddIn::getProgrammaticFuntionName( const OUString& ) throw( uno::RuntimeException )
{ {
...@@ -503,9 +456,7 @@ OUString SAL_CALL ScaPricingAddIn::getDisplayCategoryName( ...@@ -503,9 +456,7 @@ OUString SAL_CALL ScaPricingAddIn::getDisplayCategoryName(
return getProgrammaticCategoryName( aProgrammaticName ); return getProgrammaticCategoryName( aProgrammaticName );
} }
// XCompatibilityNames // XCompatibilityNames
uno::Sequence< sheet::LocalizedName > SAL_CALL ScaPricingAddIn::getCompatibilityNames( uno::Sequence< sheet::LocalizedName > SAL_CALL ScaPricingAddIn::getCompatibilityNames(
const OUString& aProgrammaticName ) throw( uno::RuntimeException ) const OUString& aProgrammaticName ) throw( uno::RuntimeException )
{ {
...@@ -525,13 +476,7 @@ uno::Sequence< sheet::LocalizedName > SAL_CALL ScaPricingAddIn::getCompatibility ...@@ -525,13 +476,7 @@ uno::Sequence< sheet::LocalizedName > SAL_CALL ScaPricingAddIn::getCompatibility
return aRet; return aRet;
} }
// ---------------------------------------------------------------------
// ---------------------------------------------------------------------
// actual function implementation starts here // actual function implementation starts here
//
// auxillary input handling functions // auxillary input handling functions
namespace { namespace {
...@@ -639,7 +584,6 @@ bool getinput_greek(bs::types::Greeks& greek, const uno::Any& anyval) { ...@@ -639,7 +584,6 @@ bool getinput_greek(bs::types::Greeks& greek, const uno::Any& anyval) {
} // namespace for auxillary functions } // namespace for auxillary functions
// OPT_BARRIER(...) // OPT_BARRIER(...)
double SAL_CALL ScaPricingAddIn::getOptBarrier( double spot, double vol, double SAL_CALL ScaPricingAddIn::getOptBarrier( double spot, double vol,
double r, double rf, double T, double strike, double r, double rf, double T, double strike,
...@@ -729,7 +673,4 @@ double SAL_CALL ScaPricingAddIn::getOptProbInMoney( double spot, double vol, ...@@ -729,7 +673,4 @@ double SAL_CALL ScaPricingAddIn::getOptProbInMoney( double spot, double vol,
} }
//------------------------------------------------------------------
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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