desktop/source/app/dispatchwatcher.cxx | 36 ++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-)
New commits: commit b703550bb0c42b49ec7ab6d44135b5a538c34c0e Author: Michael Meeks <michael.me...@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 <c...@libreoffice.org> Reviewed-by: Michael Meeks <michael.me...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/40694 Reviewed-by: Andras Timar <andras.ti...@collabora.com> Tested-by: Andras Timar <andras.ti...@collabora.com> 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"; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits