Kaydet (Commit) ff1471d3 authored tarafından Michael Meeks's avatar Michael Meeks

tdf#109262 - load libraries, and handle exceptions for --script-cat

Change-Id: I928ec885f445615fa1fb8a7cfb4ccc0015381d67
Reviewed-on: https://gerrit.libreoffice.org/40550Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
üst 6f57c09a
......@@ -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";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment