diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2018-11-21 19:07:41 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2018-11-22 10:27:50 +0100 |
commit | 7b34fb18a4d60bfc4e32b7c382ac596cbc2e776f (patch) | |
tree | 19a69baf3757eeff875cf556f13626196723cbdb /sd/source/filter/sdfilter.cxx | |
parent | 4c19552052083b9b10d581f1a93f6ddecf241bcd (diff) |
Re-factor internal filter logic, and impl. preload properly.
Change-Id: I4c55ceb19d5db2c1e4756901d0d8b14878641a99
Reviewed-on: https://gerrit.libreoffice.org/63761
Tested-by: Jenkins
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'sd/source/filter/sdfilter.cxx')
-rw-r--r-- | sd/source/filter/sdfilter.cxx | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/sd/source/filter/sdfilter.cxx b/sd/source/filter/sdfilter.cxx index b822baa21c5c..fbffe2cf5ed9 100644 --- a/sd/source/filter/sdfilter.cxx +++ b/sd/source/filter/sdfilter.cxx @@ -58,14 +58,41 @@ OUString SdFilter::ImplGetFullLibraryName( const OUString& rLibraryName ) } #ifndef DISABLE_DYNLOADING + +typedef std::map<OUString, std::unique_ptr<osl::Module>> SdModuleMap; +static SdModuleMap g_SdModuleMap; + extern "C" { static void thisModule() {} } -::osl::Module* SdFilter::OpenLibrary( const OUString& rLibraryName ) +oslGenericFunction SdFilter::GetLibrarySymbol( const OUString& rLibraryName, const OUString &rFnSymbol ) +{ + osl::Module *pMod = nullptr; + auto it = g_SdModuleMap.find(rLibraryName); + if (it != g_SdModuleMap.end()) + pMod = it->second.get(); + + if (!pMod) + { + pMod = new osl::Module; + if (pMod->loadRelative(&thisModule, ImplGetFullLibraryName(rLibraryName), + SAL_LOADMODULE_GLOBAL | SAL_LOADMODULE_LAZY)) + g_SdModuleMap[rLibraryName] = std::unique_ptr<osl::Module>(pMod); + else + { + delete pMod; + pMod = nullptr; + } + } + if (!pMod) + return nullptr; + else + return pMod->getFunctionSymbol(rFnSymbol); +} + +void SdFilter::Preload() { - std::unique_ptr< osl::Module > mod(new osl::Module); - return mod->loadRelative(&thisModule, ImplGetFullLibraryName(rLibraryName), - SAL_LOADMODULE_GLOBAL | SAL_LOADMODULE_LAZY) - ? mod.release() : nullptr; + (void)GetLibrarySymbol("sdfilt", "ImportPPT"); + (void)GetLibrarySymbol("icg", "ImportCGM"); } #endif |