[Libreoffice-commits] core.git: desktop/source
Michael Meeks
michael.meeks at collabora.com
Mon Jul 31 09:53:09 UTC 2017
desktop/source/app/dispatchwatcher.cxx | 36 ++++++++++++++++++++++++---------
1 file changed, 27 insertions(+), 9 deletions(-)
New commits:
commit ff1471d33113a26b414a473c81b0b316c3b82504
Author: Michael Meeks <michael.meeks at collabora.com>
Date: Sat Jul 29 16:45:39 2017 +0100
tdf#109262 - load libraries, and handle exceptions for --script-cat
Change-Id: I928ec885f445615fa1fb8a7cfb4ccc0015381d67
Reviewed-on: https://gerrit.libreoffice.org/40550
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
diff --git a/desktop/source/app/dispatchwatcher.cxx b/desktop/source/app/dispatchwatcher.cxx
index edf87ca25833..bd6094795ecf 100644
--- a/desktop/source/app/dispatchwatcher.cxx
+++ b/desktop/source/app/dispatchwatcher.cxx
@@ -195,8 +195,18 @@ void scriptCat(const Reference< XModel >& xDoc )
for ( sal_Int32 i = 0 ; i < aLibNames.getLength() ; ++i )
{
std::cout << "Library: '" << aLibNames[i] << "' children: ";
- Reference< XNameContainer > xContainer(
- xLibraries->getByName( aLibNames[i] ), UNO_QUERY );
+ Reference< XNameContainer > xContainer;
+ try {
+ if (!xLibraries->isLibraryLoaded( aLibNames[i] ))
+ xLibraries->loadLibrary( aLibNames[i] );
+ xContainer = Reference< XNameContainer >(
+ xLibraries->getByName( aLibNames[i] ), UNO_QUERY );
+ }
+ catch (const css::uno::Exception &e)
+ {
+ std::cout << "[" << aLibNames[i] << "] - failed to load library: " << e.Message << "\n";
+ continue;
+ }
if( !xContainer.is() )
std::cout << "0\n";
else
@@ -209,14 +219,22 @@ void scriptCat(const Reference< XModel >& xDoc )
rtl::OUString &rObjectName = aObjectNames[j];
rtl::OUString aCodeString;
- Any aCode = xContainer->getByName( rObjectName );
+ try
+ {
+ Any aCode = xContainer->getByName( rObjectName );
+
+ if (! (aCode >>= aCodeString ) )
+ std::cout << "[" << rObjectName << "] - error fetching code\n";
+ else
+ std::cout << "[" << rObjectName << "]\n"
+ << aCodeString.trim()
+ << "\n[/" << rObjectName << "]\n";
+ }
+ catch (const css::uno::Exception &e)
+ {
+ std::cout << "[" << rObjectName << "] - exception " << e.Message << " fetching code\n";
+ }
- if (! (aCode >>= aCodeString ) )
- std::cout << "[" << rObjectName << "] - error fetching code\n";
- else
- std::cout << "[" << rObjectName << "]\n"
- << aCodeString.trim()
- << "\n[/" << rObjectName << "]\n";
if (j < aObjectNames.getLength() - 1)
std::cout << "\n----------------------------------------------------------\n";
std::cout << "\n";
More information about the Libreoffice-commits
mailing list