Ensure msword lib has not yet been unloaded when aReaderWriter pReaders are destroyed.
...as some may use code exported from msword lib. The newly introduced sw::Filters class can still be improved, bundling what is currently exported through various channels from fltini.cxx. Also, the code is still not thread safe.
This commit is contained in:
@@ -28,13 +28,33 @@
|
|||||||
#ifndef _INIT_HXX
|
#ifndef _INIT_HXX
|
||||||
#define _INIT_HXX
|
#define _INIT_HXX
|
||||||
|
|
||||||
|
#include "sal/config.h"
|
||||||
|
|
||||||
|
#include "boost/noncopyable.hpp"
|
||||||
|
#include "osl/module.h"
|
||||||
|
#include "osl/module.hxx"
|
||||||
|
|
||||||
class ViewShell;
|
class ViewShell;
|
||||||
|
|
||||||
void _InitCore(); // bastyp/init.cxx
|
void _InitCore(); // bastyp/init.cxx
|
||||||
void _FinitCore();
|
void _FinitCore();
|
||||||
|
|
||||||
void _InitFilter(); // basflt/fltini.cxx
|
namespace sw {
|
||||||
void _FinitFilter();
|
|
||||||
|
// basflt/fltini.cxx
|
||||||
|
class Filters: private boost::noncopyable {
|
||||||
|
public:
|
||||||
|
Filters();
|
||||||
|
|
||||||
|
~Filters();
|
||||||
|
|
||||||
|
oslGenericFunction GetMswordLibSymbol( const char *pSymbol );
|
||||||
|
|
||||||
|
private:
|
||||||
|
osl::Module msword_;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// layout/newfrm.cxx
|
// layout/newfrm.cxx
|
||||||
void _FrmInit();
|
void _FrmInit();
|
||||||
|
@@ -369,9 +369,6 @@ public:
|
|||||||
|
|
||||||
// BEGIN source/filter/basflt/fltini.cxx
|
// BEGIN source/filter/basflt/fltini.cxx
|
||||||
|
|
||||||
extern void _InitFilter();
|
|
||||||
extern void _FinitFilter();
|
|
||||||
|
|
||||||
extern SwRead ReadAscii, /*ReadSwg, ReadSw3, */ReadHTML, ReadXML;
|
extern SwRead ReadAscii, /*ReadSwg, ReadSw3, */ReadHTML, ReadXML;
|
||||||
|
|
||||||
SW_DLLPUBLIC SwRead SwGetReaderXML();
|
SW_DLLPUBLIC SwRead SwGetReaderXML();
|
||||||
|
@@ -31,6 +31,8 @@
|
|||||||
#include <sfx2/sfxdefs.hxx>
|
#include <sfx2/sfxdefs.hxx>
|
||||||
#include <sfx2/module.hxx>
|
#include <sfx2/module.hxx>
|
||||||
|
|
||||||
|
namespace sw { class Filters; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is a wrapper for a Load-On-Demand-DLL. One instance
|
* This class is a wrapper for a Load-On-Demand-DLL. One instance
|
||||||
* per SfxApplication will be created for the runtime of
|
* per SfxApplication will be created for the runtime of
|
||||||
@@ -39,6 +41,8 @@
|
|||||||
namespace SwGlobals
|
namespace SwGlobals
|
||||||
{
|
{
|
||||||
void ensure();
|
void ensure();
|
||||||
|
|
||||||
|
sw::Filters & getFilters();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -54,6 +54,7 @@
|
|||||||
#include <wdocsh.hxx>
|
#include <wdocsh.hxx>
|
||||||
#include <fltini.hxx>
|
#include <fltini.hxx>
|
||||||
#include <hints.hxx>
|
#include <hints.hxx>
|
||||||
|
#include <init.hxx>
|
||||||
#include <frmatr.hxx>
|
#include <frmatr.hxx>
|
||||||
#include <fmtfsize.hxx>
|
#include <fmtfsize.hxx>
|
||||||
#include <swtable.hxx>
|
#include <swtable.hxx>
|
||||||
@@ -134,7 +135,15 @@ inline void _SetFltPtr( sal_uInt16 rPos, SwRead pReader )
|
|||||||
aReaderWriter[ rPos ].pReader = pReader;
|
aReaderWriter[ rPos ].pReader = pReader;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _InitFilter()
|
namespace {
|
||||||
|
|
||||||
|
extern "C" { static void SAL_CALL thisModule() {} }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace sw {
|
||||||
|
|
||||||
|
Filters::Filters()
|
||||||
{
|
{
|
||||||
_SetFltPtr( READER_WRITER_BAS, (ReadAscii = new AsciiReader) );
|
_SetFltPtr( READER_WRITER_BAS, (ReadAscii = new AsciiReader) );
|
||||||
_SetFltPtr( READER_WRITER_HTML, (ReadHTML = new HTMLReader) );
|
_SetFltPtr( READER_WRITER_HTML, (ReadHTML = new HTMLReader) );
|
||||||
@@ -144,7 +153,7 @@ void _InitFilter()
|
|||||||
_SetFltPtr( READER_WRITER_TEXT, ReadAscii );
|
_SetFltPtr( READER_WRITER_TEXT, ReadAscii );
|
||||||
}
|
}
|
||||||
|
|
||||||
void _FinitFilter()
|
Filters::~Filters()
|
||||||
{
|
{
|
||||||
// die Reader vernichten
|
// die Reader vernichten
|
||||||
for( sal_uInt16 n = 0; n < MAXFILTER; ++n )
|
for( sal_uInt16 n = 0; n < MAXFILTER; ++n )
|
||||||
@@ -155,6 +164,17 @@ void _FinitFilter()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
oslGenericFunction Filters::GetMswordLibSymbol( const char *pSymbol )
|
||||||
|
{
|
||||||
|
static ::rtl::OUString aLibName( RTL_CONSTASCII_USTRINGPARAM( SVLIBRARY( "msword" ) ) );
|
||||||
|
if (!msword_.is())
|
||||||
|
SvLibrary::LoadModule( msword_, aLibName, &thisModule, SAL_LOADMODULE_GLOBAL | SAL_LOADMODULE_LAZY );
|
||||||
|
if (msword_.is())
|
||||||
|
return msword_.getFunctionSymbol( ::rtl::OUString::createFromAscii( pSymbol ) );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
namespace SwReaderWriter {
|
namespace SwReaderWriter {
|
||||||
|
|
||||||
@@ -807,23 +827,9 @@ void SwAsciiOptions::WriteUserData( String& rStr )
|
|||||||
rStr += ',';
|
rStr += ',';
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" { static void SAL_CALL thisModule() {} }
|
|
||||||
|
|
||||||
static oslGenericFunction GetMswordLibSymbol( const char *pSymbol )
|
|
||||||
{
|
|
||||||
static ::osl::Module aModule;
|
|
||||||
static sal_Bool bLoaded = sal_False;
|
|
||||||
static ::rtl::OUString aLibName( RTL_CONSTASCII_USTRINGPARAM( SVLIBRARY( "msword" ) ) );
|
|
||||||
if (!bLoaded)
|
|
||||||
bLoaded = SvLibrary::LoadModule( aModule, aLibName, &thisModule, SAL_LOADMODULE_GLOBAL | SAL_LOADMODULE_LAZY );
|
|
||||||
if (bLoaded)
|
|
||||||
return aModule.getFunctionSymbol( ::rtl::OUString::createFromAscii( pSymbol ) );
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
Reader* GetRTFReader()
|
Reader* GetRTFReader()
|
||||||
{
|
{
|
||||||
FnGetReader pFunction = reinterpret_cast<FnGetReader>( GetMswordLibSymbol( "ImportRTF" ) );
|
FnGetReader pFunction = reinterpret_cast<FnGetReader>( SwGlobals::getFilters().GetMswordLibSymbol( "ImportRTF" ) );
|
||||||
|
|
||||||
if ( pFunction )
|
if ( pFunction )
|
||||||
return (*pFunction)();
|
return (*pFunction)();
|
||||||
@@ -833,7 +839,7 @@ Reader* GetRTFReader()
|
|||||||
|
|
||||||
void GetRTFWriter( const String& rFltName, const String& rBaseURL, WriterRef& xRet )
|
void GetRTFWriter( const String& rFltName, const String& rBaseURL, WriterRef& xRet )
|
||||||
{
|
{
|
||||||
FnGetWriter pFunction = reinterpret_cast<FnGetWriter>( GetMswordLibSymbol( "ExportRTF" ) );
|
FnGetWriter pFunction = reinterpret_cast<FnGetWriter>( SwGlobals::getFilters().GetMswordLibSymbol( "ExportRTF" ) );
|
||||||
|
|
||||||
if ( pFunction )
|
if ( pFunction )
|
||||||
(*pFunction)( rFltName, rBaseURL, xRet );
|
(*pFunction)( rFltName, rBaseURL, xRet );
|
||||||
@@ -843,7 +849,7 @@ void GetRTFWriter( const String& rFltName, const String& rBaseURL, WriterRef& xR
|
|||||||
|
|
||||||
Reader* GetWW8Reader()
|
Reader* GetWW8Reader()
|
||||||
{
|
{
|
||||||
FnGetReader pFunction = reinterpret_cast<FnGetReader>( GetMswordLibSymbol( "ImportDOC" ) );
|
FnGetReader pFunction = reinterpret_cast<FnGetReader>( SwGlobals::getFilters().GetMswordLibSymbol( "ImportDOC" ) );
|
||||||
|
|
||||||
if ( pFunction )
|
if ( pFunction )
|
||||||
return (*pFunction)();
|
return (*pFunction)();
|
||||||
@@ -853,7 +859,7 @@ Reader* GetWW8Reader()
|
|||||||
|
|
||||||
void GetWW8Writer( const String& rFltName, const String& rBaseURL, WriterRef& xRet )
|
void GetWW8Writer( const String& rFltName, const String& rBaseURL, WriterRef& xRet )
|
||||||
{
|
{
|
||||||
FnGetWriter pFunction = reinterpret_cast<FnGetWriter>( GetMswordLibSymbol( "ExportDOC" ) );
|
FnGetWriter pFunction = reinterpret_cast<FnGetWriter>( SwGlobals::getFilters().GetMswordLibSymbol( "ExportDOC" ) );
|
||||||
|
|
||||||
if ( pFunction )
|
if ( pFunction )
|
||||||
(*pFunction)( rFltName, rBaseURL, xRet );
|
(*pFunction)( rFltName, rBaseURL, xRet );
|
||||||
@@ -866,7 +872,7 @@ typedef sal_uLong ( __LOADONCALLAPI *GetSaveWarning )( SfxObjectShell& );
|
|||||||
|
|
||||||
sal_uLong SaveOrDelMSVBAStorage( SfxObjectShell& rDoc, SotStorage& rStor, sal_Bool bSaveInto, const String& rStorageName )
|
sal_uLong SaveOrDelMSVBAStorage( SfxObjectShell& rDoc, SotStorage& rStor, sal_Bool bSaveInto, const String& rStorageName )
|
||||||
{
|
{
|
||||||
SaveOrDel pFunction = reinterpret_cast<SaveOrDel>( GetMswordLibSymbol( "SaveOrDelMSVBAStorage_ww8" ) );
|
SaveOrDel pFunction = reinterpret_cast<SaveOrDel>( SwGlobals::getFilters().GetMswordLibSymbol( "SaveOrDelMSVBAStorage_ww8" ) );
|
||||||
if( pFunction )
|
if( pFunction )
|
||||||
return pFunction( rDoc, rStor, bSaveInto, rStorageName );
|
return pFunction( rDoc, rStor, bSaveInto, rStorageName );
|
||||||
return ERRCODE_NONE;
|
return ERRCODE_NONE;
|
||||||
@@ -874,7 +880,7 @@ sal_uLong SaveOrDelMSVBAStorage( SfxObjectShell& rDoc, SotStorage& rStor, sal_Bo
|
|||||||
|
|
||||||
sal_uLong GetSaveWarningOfMSVBAStorage( SfxObjectShell &rDocS )
|
sal_uLong GetSaveWarningOfMSVBAStorage( SfxObjectShell &rDocS )
|
||||||
{
|
{
|
||||||
GetSaveWarning pFunction = reinterpret_cast<GetSaveWarning>( GetMswordLibSymbol( "GetSaveWarningOfMSVBAStorage_ww8" ) );
|
GetSaveWarning pFunction = reinterpret_cast<GetSaveWarning>( SwGlobals::getFilters().GetMswordLibSymbol( "GetSaveWarningOfMSVBAStorage_ww8" ) );
|
||||||
if( pFunction )
|
if( pFunction )
|
||||||
return pFunction( rDocS );
|
return pFunction( rDocS );
|
||||||
return ERRCODE_NONE;
|
return ERRCODE_NONE;
|
||||||
|
@@ -78,6 +78,11 @@ namespace SwGlobals
|
|||||||
{
|
{
|
||||||
theSwDLLInstance::get();
|
theSwDLLInstance::get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sw::Filters & getFilters()
|
||||||
|
{
|
||||||
|
return theSwDLLInstance::get().get()->getFilters();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SwDLL::SwDLL()
|
SwDLL::SwDLL()
|
||||||
@@ -126,7 +131,7 @@ SwDLL::SwDLL()
|
|||||||
|
|
||||||
// Initialisation of Statics
|
// Initialisation of Statics
|
||||||
::_InitCore();
|
::_InitCore();
|
||||||
::_InitFilter();
|
filters_.reset(new sw::Filters);
|
||||||
::_InitUI();
|
::_InitUI();
|
||||||
|
|
||||||
pModule->InitAttrPool();
|
pModule->InitAttrPool();
|
||||||
@@ -148,7 +153,7 @@ SwDLL::~SwDLL()
|
|||||||
SW_MOD()->RemoveAttrPool();
|
SW_MOD()->RemoveAttrPool();
|
||||||
|
|
||||||
::_FinitUI();
|
::_FinitUI();
|
||||||
::_FinitFilter();
|
filters_.reset();
|
||||||
::_FinitCore();
|
::_FinitCore();
|
||||||
// sign out Objekt-Factory
|
// sign out Objekt-Factory
|
||||||
SdrObjFactory::RemoveMakeObjectHdl(LINK(&aSwObjectFactory, SwObjectFactory, MakeObject ));
|
SdrObjFactory::RemoveMakeObjectHdl(LINK(&aSwObjectFactory, SwObjectFactory, MakeObject ));
|
||||||
@@ -160,4 +165,10 @@ SwDLL::~SwDLL()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sw::Filters & SwDLL::getFilters()
|
||||||
|
{
|
||||||
|
OSL_ASSERT(filters_);
|
||||||
|
return *filters_.get();
|
||||||
|
}
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@@ -28,7 +28,14 @@
|
|||||||
#ifndef SWDLL_IMPL_INCLUDE
|
#ifndef SWDLL_IMPL_INCLUDE
|
||||||
#define SWDLL_IMPL_INCLUDE
|
#define SWDLL_IMPL_INCLUDE
|
||||||
|
|
||||||
class SwDLL
|
#include "sal/config.h"
|
||||||
|
|
||||||
|
#include "boost/noncopyable.hpp"
|
||||||
|
#include "boost/scoped_ptr.hpp"
|
||||||
|
|
||||||
|
namespace sw { class Filters; }
|
||||||
|
|
||||||
|
class SwDLL: private boost::noncopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void RegisterFactories();
|
static void RegisterFactories();
|
||||||
@@ -37,6 +44,11 @@ public:
|
|||||||
|
|
||||||
SwDLL();
|
SwDLL();
|
||||||
~SwDLL();
|
~SwDLL();
|
||||||
|
|
||||||
|
sw::Filters & getFilters();
|
||||||
|
|
||||||
|
private:
|
||||||
|
boost::scoped_ptr< sw::Filters > filters_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user