summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2017-07-29 16:45:39 +0100
committerMichael Meeks <michael.meeks@collabora.com>2017-07-31 11:52:20 +0200
commitff1471d33113a26b414a473c81b0b316c3b82504 (patch)
treec734af48cd12f4be2f0dbd2a1ffb0a7ad174b03a
parent6f57c09aadd40009173f8ae3654004dd0cad9fb8 (diff)
tdf#109262 - load libraries, and handle exceptions for --script-cat
Change-Id: I928ec885f445615fa1fb8a7cfb4ccc0015381d67 Reviewed-on: https://gerrit.libreoffice.org/40550 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r--desktop/source/app/dispatchwatcher.cxx36
1 files changed, 27 insertions, 9 deletions
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";