diff options
author | Tor Lillqvist <tml@iki.fi> | 2012-10-07 07:52:26 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@iki.fi> | 2012-10-07 07:59:15 +0300 |
commit | 97593ae24a98daca89fad176dc2492e582b3a821 (patch) | |
tree | f52189545a5c5ffbc7cece7bca595b2cd18c9cc0 /sd | |
parent | 1691752dd29d661552700d9bcac5d3a3953fb91a (diff) |
Handle lack of module loading/unloading API when DISABLE_DYNLOADING
There are basicically two classes of cases:
1) Where the code is for obscure historical reasons or what I see as
misguided "optimization" split into a more libraries than necessary,
and these then are loaded at run-time. Instead, just use direct
linking.
2) Where dynamic loading is part of the functionality offered to some
upper (scripting etc) layer, or where some system-specific non-LO
library is loaded dynamically, as it is not necessarily present on
end-user machines. Can't have such in the DISABLE_DYNLOADING case.
Change-Id: I9eceac5fb635245def2f4f3320821447bb7cd8c0
Diffstat (limited to 'sd')
-rw-r--r-- | sd/inc/sdfilter.hxx | 3 | ||||
-rw-r--r-- | sd/source/filter/cgm/sdcgmfilter.cxx | 47 | ||||
-rw-r--r-- | sd/source/filter/sdfilter.cxx | 3 | ||||
-rw-r--r-- | sd/source/filter/sdpptwrp.cxx | 45 | ||||
-rw-r--r-- | sd/source/ui/dlg/sdabstdlg.cxx | 12 | ||||
-rw-r--r-- | sd/source/ui/dlg/sduiexp.cxx | 4 |
6 files changed, 98 insertions, 16 deletions
diff --git a/sd/inc/sdfilter.hxx b/sd/inc/sdfilter.hxx index 1f3ea8024930..d44121487001 100644 --- a/sd/inc/sdfilter.hxx +++ b/sd/inc/sdfilter.hxx @@ -57,8 +57,9 @@ protected: SdDrawDocument& mrDocument; sal_Bool mbIsDraw : 1; sal_Bool mbShowProgress : 1; - +#ifndef DISABLE_DYNLOADING ::osl::Module* OpenLibrary( const ::rtl::OUString& rLibraryName ) const; +#endif void CreateStatusIndicator(); private: diff --git a/sd/source/filter/cgm/sdcgmfilter.cxx b/sd/source/filter/cgm/sdcgmfilter.cxx index 6c6ef43ce22a..7135ee81fc1d 100644 --- a/sd/source/filter/cgm/sdcgmfilter.cxx +++ b/sd/source/filter/cgm/sdcgmfilter.cxx @@ -66,8 +66,16 @@ using namespace ::com::sun::star::frame; // - Typedefs - // ------------ -typedef sal_uInt32 ( __LOADONCALLAPI *ImportCGM )( ::rtl::OUString&, Reference< XModel >&, sal_uInt32, Reference< XStatusIndicator >& ); -typedef sal_Bool ( __LOADONCALLAPI *ExportCGM )( ::rtl::OUString&, Reference< XModel >&, Reference< XStatusIndicator >&, void* ); + +typedef sal_uInt32 ( __LOADONCALLAPI *ImportCGMPointer )( ::rtl::OUString&, Reference< XModel >&, sal_uInt32, Reference< XStatusIndicator >& ); +typedef sal_Bool ( __LOADONCALLAPI *ExportCGMPointer )( ::rtl::OUString&, Reference< XModel >&, Reference< XStatusIndicator >&, void* ); + +#ifdef DISABLE_DYNLOADING + +extern "C" sal_uInt32 ImportCGM( ::rtl::OUString&, Reference< XModel >&, sal_uInt32, Reference< XStatusIndicator >& ); +extern "C" sal_Bool ExportCGM( ::rtl::OUString&, Reference< XModel >&, Reference< XStatusIndicator >&, void* ); + +#endif // --------------- // - SdPPTFilter - @@ -88,12 +96,22 @@ SdCGMFilter::~SdCGMFilter() sal_Bool SdCGMFilter::Import() { +#ifndef DISABLE_DYNLOADING ::osl::Module* pLibrary = OpenLibrary( mrMedium.GetFilter()->GetUserData() ); +#endif sal_Bool bRet = sal_False; - if( pLibrary && mxModel.is() ) + if( +#ifndef DISABLE_DYNLOADING + pLibrary && +#endif + mxModel.is() ) { - ImportCGM FncImportCGM = reinterpret_cast< ImportCGM >( pLibrary->getFunctionSymbol( "ImportCGM" ) ); +#ifndef DISABLE_DYNLOADING + ImportCGMPointer FncImportCGM = reinterpret_cast< ImportCGM >( pLibrary->getFunctionSymbol( "ImportCGM" ) ); +#else + ImportCGMPointer FncImportCGM = ImportCGM; +#endif ::rtl::OUString aFileURL( mrMedium.GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ); sal_uInt32 nRetValue; @@ -122,9 +140,9 @@ sal_Bool SdCGMFilter::Import() } } } - +#ifndef DISABLE_DYNLOADING delete pLibrary; - +#endif return bRet; } @@ -132,12 +150,22 @@ sal_Bool SdCGMFilter::Import() sal_Bool SdCGMFilter::Export() { +#ifndef DISABLE_DYNLOADING ::osl::Module* pLibrary = OpenLibrary( mrMedium.GetFilter()->GetUserData() ); +#endif sal_Bool bRet = sal_False; - if( pLibrary && mxModel.is() ) + if( +#ifndef DISABLE_DYNLOADING + pLibrary && +#endif + mxModel.is() ) { - ExportCGM FncCGMExport = reinterpret_cast< ExportCGM >( pLibrary->getFunctionSymbol( "ExportCGM" ) ); +#ifndef DISABLE_DYNLOADING + ExportCGMPointer FncCGMExport = reinterpret_cast< ExportCGM >( pLibrary->getFunctionSymbol( "ExportCGM" ) ); +#else + ExportCGMPointer FncCGMExport = ExportCGM; +#endif if( FncCGMExport ) { @@ -148,8 +176,9 @@ sal_Bool SdCGMFilter::Export() } } +#ifndef DISABLE_DYNLOADING delete pLibrary; - +#endif return bRet; } diff --git a/sd/source/filter/sdfilter.cxx b/sd/source/filter/sdfilter.cxx index ec245925a3af..d379ffd1780f 100644 --- a/sd/source/filter/sdfilter.cxx +++ b/sd/source/filter/sdfilter.cxx @@ -85,6 +85,7 @@ SdFilter::~SdFilter() // ----------------------------------------------------------------------------- +#ifndef DISABLE_DYNLOADING extern "C" { static void SAL_CALL thisModule() {} } ::osl::Module* SdFilter::OpenLibrary( const ::rtl::OUString& rLibraryName ) const @@ -95,6 +96,8 @@ extern "C" { static void SAL_CALL thisModule() {} } ? mod.release() : 0; } +#endif + // ----------------------------------------------------------------------------- void SdFilter::CreateStatusIndicator() diff --git a/sd/source/filter/sdpptwrp.cxx b/sd/source/filter/sdpptwrp.cxx index 6be40e8e9535..c11c9585ece5 100644 --- a/sd/source/filter/sdpptwrp.cxx +++ b/sd/source/filter/sdpptwrp.cxx @@ -49,14 +49,27 @@ using namespace ::com::sun::star::beans; using namespace ::com::sun::star::task; using namespace ::com::sun::star::frame; -typedef sal_Bool ( __LOADONCALLAPI *ExportPPT )( const std::vector< com::sun::star::beans::PropertyValue >&, SvStorageRef&, +typedef sal_Bool ( __LOADONCALLAPI *ExportPPTPointer )( const std::vector< com::sun::star::beans::PropertyValue >&, SvStorageRef&, Reference< XModel > &, Reference< XStatusIndicator > &, SvMemoryStream*, sal_uInt32 nCnvrtFlags ); -typedef sal_Bool ( SAL_CALL *ImportPPT )( SdDrawDocument*, SvStream&, SvStorage&, SfxMedium& ); +typedef sal_Bool ( SAL_CALL *ImportPPTPointer )( SdDrawDocument*, SvStream&, SvStorage&, SfxMedium& ); -typedef sal_Bool ( __LOADONCALLAPI *SaveVBA )( SfxObjectShell&, SvMemoryStream*& ); +typedef sal_Bool ( __LOADONCALLAPI *SaveVBAPointer )( SfxObjectShell&, SvMemoryStream*& ); + +#ifdef DISABLE_DYNLOADING + +extern "C" sal_Bool ExportPPT( const std::vector< com::sun::star::beans::PropertyValue >&, SvStorageRef&, + Reference< XModel > &, + Reference< XStatusIndicator > &, + SvMemoryStream*, sal_uInt32 nCnvrtFlags ); + +extern "C" sal_Bool ImportPPT( SdDrawDocument*, SvStream&, SvStorage&, SfxMedium& ); + +extern "C" sal_Bool SaveVBA( SfxObjectShell&, SvMemoryStream*& ); + +#endif // --------------- // - SdPPTFilter - @@ -102,16 +115,22 @@ sal_Bool SdPPTFilter::Import() mrMedium.SetError( ERRCODE_SVX_READ_FILTER_PPOINT, OSL_LOG_PREFIX ); else { +#ifndef DISABLE_DYNLOADING ::osl::Module* pLibrary = OpenLibrary( mrMedium.GetFilter()->GetUserData() ); if ( pLibrary ) { - ImportPPT PPTImport = reinterpret_cast< ImportPPT >( pLibrary->getFunctionSymbol( "ImportPPT" ) ); + ImportPPTPointer PPTImport = reinterpret_cast< ImportPPT >( pLibrary->getFunctionSymbol( "ImportPPT" ) ); if ( PPTImport ) bRet = PPTImport( &mrDocument, *pDocStream, *pStorage, mrMedium ); if ( !bRet ) mrMedium.SetError( SVSTREAM_WRONGVERSION, OSL_LOG_PREFIX ); } +#else + bRet = ImportPPT( &mrDocument, *pDocStream, *pStorage, mrMedium ); + if ( !bRet ) + mrMedium.SetError( SVSTREAM_WRONGVERSION, OSL_LOG_PREFIX ); +#endif } delete pDocStream; @@ -125,15 +144,23 @@ sal_Bool SdPPTFilter::Import() sal_Bool SdPPTFilter::Export() { +#ifndef DISABLE_DYNLOADING ::osl::Module* pLibrary = OpenLibrary( mrMedium.GetFilter()->GetUserData() ); +#endif sal_Bool bRet = sal_False; +#ifndef DISABLE_DYNLOADING if( pLibrary ) +#endif { if( mxModel.is() ) { SotStorageRef xStorRef = new SotStorage( mrMedium.GetOutStream(), sal_False ); - ExportPPT PPTExport = reinterpret_cast<ExportPPT>(pLibrary->getFunctionSymbol( "ExportPPT" )); +#ifndef DISABLE_DYNLOADING + ExportPPTPointer PPTExport = reinterpret_cast<ExportPPT>(pLibrary->getFunctionSymbol( "ExportPPT" )); +#else + ExportPPTPointer PPTExport = ExportPPT; +#endif if( PPTExport && xStorRef.Is() ) { @@ -166,7 +193,9 @@ sal_Bool SdPPTFilter::Export() xStorRef->Commit(); } } +#ifndef DISABLE_DYNLOADING delete pLibrary; +#endif } return bRet; } @@ -176,15 +205,19 @@ void SdPPTFilter::PreSaveBasic() const SvtFilterOptions& rFilterOptions = SvtFilterOptions::Get(); if( rFilterOptions.IsLoadPPointBasicStorage() ) { +#ifndef DISABLE_DYNLOADING ::osl::Module* pLibrary = OpenLibrary( mrMedium.GetFilter()->GetUserData() ); if( pLibrary ) { - SaveVBA pSaveVBA= reinterpret_cast<SaveVBA>(pLibrary->getFunctionSymbol( "SaveVBA" )); + SaveVBAPointer pSaveVBA= reinterpret_cast<SaveVBA>(pLibrary->getFunctionSymbol( "SaveVBA" )); if( pSaveVBA ) { pSaveVBA( (SfxObjectShell&) mrDocShell, pBas ); } } +#else + SaveVBA( (SfxObjectShell&) mrDocShell, pBas ); +#endif } } diff --git a/sd/source/ui/dlg/sdabstdlg.cxx b/sd/source/ui/dlg/sdabstdlg.cxx index 520f5a4a4926..6c4951e40ffe 100644 --- a/sd/source/ui/dlg/sdabstdlg.cxx +++ b/sd/source/ui/dlg/sdabstdlg.cxx @@ -35,10 +35,19 @@ typedef SdAbstractDialogFactory* (__LOADONCALLAPI *SdFuncPtrCreateDialogFactory)(); +#ifndef DISABLE_DYNLOADING + extern "C" { static void SAL_CALL thisModule() {} } +#else + +extern "C" SdAbstractDialogFactory* SdCreateDialogFactory(); + +#endif + SdAbstractDialogFactory* SdAbstractDialogFactory::Create() { +#ifndef DISABLE_DYNLOADING SdFuncPtrCreateDialogFactory fp = 0; static ::osl::Module aDialogLibrary; static const ::rtl::OUString sLibName(::vcl::unohelper::CreateLibraryName("sdui", sal_True)); @@ -48,6 +57,9 @@ SdAbstractDialogFactory* SdAbstractDialogFactory::Create() if ( fp ) return fp(); return 0; +#else + return SdCreateDialogFactory(); +#endif } diff --git a/sd/source/ui/dlg/sduiexp.cxx b/sd/source/ui/dlg/sduiexp.cxx index 962f86cdbf5a..d9505a198514 100644 --- a/sd/source/ui/dlg/sduiexp.cxx +++ b/sd/source/ui/dlg/sduiexp.cxx @@ -34,6 +34,10 @@ #include "sddlgfact.hxx" #include "sal/types.h" +#ifdef DISABLE_DYNLOADING +#define CreateDialogFactory SdCreateDialogFactory +#endif + extern "C" { SAL_DLLPUBLIC_EXPORT SdAbstractDialogFactory* CreateDialogFactory() |