Hello, last week .docx support was broken because of a mistake during the gbuild changes and I wasted quite some time finding out what was wrong. As something similar had happened to me already before I'd like to apply the attached patches. However I have some issues with it:
- the error dialog that pops up just says 'General error. General input/output error.', which is completely unhelpful, however I don't feel like digging more for how to pass the information as far as the place where the dialog is shown, so I'd like to add at least debug output - the debug output in the patch is done just using fprintf(stderr), as I cannot find anything that would simply log a debug message and not do more - is there anything like that in LO? - osl_loadModule*() functions are plain C functions from stable API, so no overloading to add the extra argument for the error message, the best I've come up with was simply a wrapper around dlerror(), which I admit is not very nice API either, would there be any better approach? -- Lubos Lunak l.lu...@suse.cz
diff --git a/cppuhelper/source/shlib.cxx b/cppuhelper/source/shlib.cxx index a979454..1beed1f 100644 --- a/cppuhelper/source/shlib.cxx +++ b/cppuhelper/source/shlib.cxx @@ -367,9 +367,14 @@ Reference< XInterface > SAL_CALL loadSharedLibComponentFactory( aModulePath.pData, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL ); if (! lib) { - throw loader::CannotActivateFactoryException( - OUSTR("loading component library failed: ") + aModulePath, - Reference< XInterface >() ); + OUStringBuffer message = OUSTR("loading component library failed: ") + aModulePath; + if( const char* error = osl_loadModuleLastError()) + { + message.appendAscii( " (" ); + message.append( OStringToOUString( error, RTL_TEXTENCODING_UTF8 )); + message.appendAscii( ")" ); + } + throw loader::CannotActivateFactoryException( message.makeStringAndClear(), Reference< XInterface >() ); } Reference< XInterface > xRet; diff --git a/sal/inc/osl/module.h b/sal/inc/osl/module.h index 803b0b6..2a92d39 100644 --- a/sal/inc/osl/module.h +++ b/sal/inc/osl/module.h @@ -102,6 +102,16 @@ oslModule SAL_CALL osl_loadModuleAscii(const sal_Char *pModuleName, sal_Int32 nR oslModule SAL_CALL osl_loadModuleRelative( oslGenericFunction baseModule, rtl_uString * relativePath, sal_Int32 mode); +/** + Return an error message for the last error in any of the osl_loadModule*() functions, + or NULL if none. + @since 3.5.0 +*/ +// TODO 4.0: this is kind of retarded, the osl_loadModule functions themselves should provide +// this, but this is stable API and C-only, so no simple extending is possible and I don't +// feel like making the API even more ugly by introducing osl_loadModule*WithError() copies +const char* SAL_CALL osl_loadModuleLastError(); + /** Retrieve the handle of an already loaded module. This function can be used to search for a function symbol in the process address space. diff --git a/sal/osl/unx/module.c b/sal/osl/unx/module.c index a5beea9..7b7ca6f 100644 --- a/sal/osl/unx/module.c +++ b/sal/osl/unx/module.c @@ -104,6 +104,11 @@ oslModule SAL_CALL osl_loadModuleAscii(const sal_Char *pModuleName, sal_Int32 nR return NULL; } +const char* SAL_CALL osl_loadModuleLastError() +{ + return dlerror(); +} + /*****************************************************************************/ /* osl_getModuleHandle */ /*****************************************************************************/ diff --git a/sal/osl/w32/module.cxx b/sal/osl/w32/module.cxx index a332d3a..1a906dd 100644 --- a/sal/osl/w32/module.cxx +++ b/sal/osl/w32/module.cxx @@ -144,6 +144,11 @@ oslModule SAL_CALL osl_loadModuleAscii(const sal_Char *pModuleName, sal_Int32 nR return ret; } +const char* SAL_CALL osl_loadModuleLastError() +{ + return NULL; // TODO +} + /*****************************************************************************/ /* osl_getModuleHandle */ /*****************************************************************************/ diff --git a/sal/util/sal.map b/sal/util/sal.map index 152b023..b4367e2 100755 --- a/sal/util/sal.map +++ b/sal/util/sal.map @@ -609,6 +609,7 @@ LIBO_UDK_3.5 { # symbols available in >= LibO 3.5 global: rtl_stringbuffer_remove; rtl_uStringbuffer_remove; + osl_loadModuleLastError; } UDK_3.10; PRIVATE_1.0 {
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 31ee8f0..fca227b 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -2281,8 +2281,13 @@ sal_Bool SfxObjectShell::ExportTo( SfxMedium& rMedium ) try{ xExporter = uno::Reference< document::XExporter > ( xFilterFact->createInstanceWithArguments( aFilterName, uno::Sequence < uno::Any >() ), uno::UNO_QUERY ); - }catch(const uno::Exception&) - { xExporter.clear(); } + }catch(const uno::Exception& e) + { +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "%s\n", rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr()); +#endif + xExporter.clear(); + } } }
_______________________________________________ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice