From 8a8ad9dc540246fa1b8531e929668ef80184798c Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Thu, 4 Nov 2010 11:01:57 +0100 Subject: tl88:#i100744# Better exception handling while retrieving information from packages --- .../source/deployment/gui/dp_gui_extlistbox.cxx | 54 +++++++++++++--------- .../deployment/registry/package/dp_package.cxx | 18 +++++--- 2 files changed, 43 insertions(+), 29 deletions(-) mode change 100644 => 100755 desktop/source/deployment/registry/package/dp_package.cxx diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx index e1e517a55c..f689783d17 100755 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx @@ -71,29 +71,34 @@ Entry_Impl::Entry_Impl( const uno::Reference< deployment::XPackage > &xPackage, m_pPublisher( NULL ), m_xPackage( xPackage ) { - m_sTitle = xPackage->getDisplayName(); - m_sVersion = xPackage->getVersion(); - m_sDescription = xPackage->getDescription(); - - beans::StringPair aInfo( m_xPackage->getPublisherInfo() ); - m_sPublisher = aInfo.First; - m_sPublisherURL = aInfo.Second; - - // get the icons for the package if there are any - uno::Reference< graphic::XGraphic > xGraphic = xPackage->getIcon( false ); - if ( xGraphic.is() ) - m_aIcon = Image( xGraphic ); - - xGraphic = xPackage->getIcon( true ); - if ( xGraphic.is() ) - m_aIconHC = Image( xGraphic ); - else - m_aIconHC = m_aIcon; + try + { + m_sTitle = xPackage->getDisplayName(); + m_sVersion = xPackage->getVersion(); + m_sDescription = xPackage->getDescription(); + + beans::StringPair aInfo( m_xPackage->getPublisherInfo() ); + m_sPublisher = aInfo.First; + m_sPublisherURL = aInfo.Second; + + // get the icons for the package if there are any + uno::Reference< graphic::XGraphic > xGraphic = xPackage->getIcon( false ); + if ( xGraphic.is() ) + m_aIcon = Image( xGraphic ); + + xGraphic = xPackage->getIcon( true ); + if ( xGraphic.is() ) + m_aIconHC = Image( xGraphic ); + else + m_aIconHC = m_aIcon; - if ( eState == AMBIGUOUS ) - m_sErrorText = DialogHelper::getResourceString( RID_STR_ERROR_UNKNOWN_STATUS ); - else if ( eState == NOT_REGISTERED ) - checkDependencies(); + if ( eState == AMBIGUOUS ) + m_sErrorText = DialogHelper::getResourceString( RID_STR_ERROR_UNKNOWN_STATUS ); + else if ( eState == NOT_REGISTERED ) + checkDependencies(); + } + catch (deployment::ExtensionRemovedException &) {} + catch (uno::RuntimeException &) {} } //------------------------------------------------------------------------------ @@ -963,6 +968,11 @@ long ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > & bool bLocked = m_pManager->isReadOnly( xPackage ); TEntry_Impl pEntry( new Entry_Impl( xPackage, eState, bLocked ) ); + + // Don't add empty entries + if ( ! pEntry->m_sTitle.Len() ) + return 0; + xPackage->addEventListener( uno::Reference< lang::XEventListener > ( m_xRemoveListener, uno::UNO_QUERY ) ); ::osl::ClearableMutexGuard guard(m_entriesMutex); diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx old mode 100644 new mode 100755 index 6209aad0d0..6928e6bc1d --- a/desktop/source/deployment/registry/package/dp_package.cxx +++ b/desktop/source/deployment/registry/package/dp_package.cxx @@ -986,16 +986,20 @@ OUString BackendImpl::PackageImpl::getDescription() if (sRelativeURL.getLength()) { OUString sURL = m_url_expanded + OUSTR("/") + sRelativeURL; - sDescription = getTextFromURL( - css::uno::Reference< css::ucb::XCommandEnvironment >(), sURL); + try + { + sDescription = getTextFromURL( css::uno::Reference< css::ucb::XCommandEnvironment >(), sURL ); + } + catch ( css::deployment::DeploymentException& ) + { + OSL_ENSURE( 0, ::rtl::OUStringToOString( ::comphelper::anyToString( ::cppu::getCaughtException() ), RTL_TEXTENCODING_UTF8 ).getStr() ); + } } + if (sDescription.getLength()) - return sDescription; - else if(m_oldDescription.getLength()) - return m_oldDescription; - else - return OUString(); + return sDescription; + return m_oldDescription; } //______________________________________________________________________________ -- cgit v1.2.3