diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2017-07-29 16:45:39 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2017-08-09 14:42:56 +0200 |
commit | b703550bb0c42b49ec7ab6d44135b5a538c34c0e (patch) | |
tree | ffb958cdd80b67e27bac9471efb7d1c968d37a24 /desktop | |
parent | d2801a3634b1e4e0fb52f1257fd7482aed8c337c (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>
Reviewed-on: https://gerrit.libreoffice.org/40694
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/app/dispatchwatcher.cxx | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/desktop/source/app/dispatchwatcher.cxx b/desktop/source/app/dispatchwatcher.cxx index da9a31930b17..639aef032ead 100644 --- a/desktop/source/app/dispatchwatcher.cxx +++ b/desktop/source/app/dispatchwatcher.cxx @@ -196,8 +196,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 @@ -210,14 +220,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"; |