Tag: cws_src680_dba24c User: fs Date: 2007-10-26 12:16:13+0000 Modified: dba/dbaccess/source/ui/misc/imageprovider.cxx
Log: getImage -> getImages, this saves one call and all its implementation, since all clients did two calls, anyway File Changes: Directory: /dba/dbaccess/source/ui/misc/ ======================================== File [changed]: imageprovider.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/misc/imageprovider.cxx?r1=1.3.110.1&r2=1.3.110.2 Delta lines: +53 -34 --------------------- --- imageprovider.cxx 2007-10-26 11:55:15+0000 1.3.110.1 +++ imageprovider.cxx 2007-10-26 12:16:11+0000 1.3.110.2 @@ -4,9 +4,9 @@ * * $RCSfile: imageprovider.cxx,v $ * - * $Revision: 1.3.110.1 $ + * $Revision: 1.3.110.2 $ * - * last change: $Author: fs $ $Date: 2007/10/26 11:55:15 $ + * last change: $Author: fs $ $Date: 2007/10/26 12:16:11 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -72,53 +72,62 @@ namespace GraphicColorMode = ::com::sun::star::graphic::GraphicColorMode; //==================================================================== - //= ImageProvider_Impl + //= ImageProvider_Data //==================================================================== - struct ImageProvider_Impl + struct ImageProvider_Data { /// the connection we work with Reference< XConnection > xConnection; /// the views of the connection, if the DB supports views Reference< XNameAccess > xViews; + /// interface for providing table's UI + Reference< XTableUIProvider > xTableUI; }; //-------------------------------------------------------------------- namespace { //................................................................ - static Reference< XGraphic > lcl_getConnectionProvidedTableIcon_nothrow( - const Reference< XConnection >& _rxConnection, const ::rtl::OUString& _rName, bool _bHighContrast ) + static void lcl_getConnectionProvidedTableIcon_nothrow( const ImageProvider_Data& _rData, + const ::rtl::OUString& _rName, Reference< XGraphic >& _out_rxGraphic, Reference< XGraphic >& _out_rxGraphicHC ) { try { - Reference< XTableUIProvider > xProvider( _rxConnection, UNO_QUERY ); - if ( xProvider.is() ) - return xProvider->getTableIcon( _rName, _bHighContrast ? GraphicColorMode::HIGH_CONTRAST : GraphicColorMode::NORMAL ); + if ( _rData.xTableUI.is() ) + { + _out_rxGraphic = _rData.xTableUI->getTableIcon( _rName, GraphicColorMode::NORMAL ); + _out_rxGraphicHC = _rData.xTableUI->getTableIcon( _rName, GraphicColorMode::HIGH_CONTRAST ); + } } catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); } - return NULL; } //................................................................ - static USHORT lcl_getTableImageResourceID_nothrow( const ImageProvider_Impl& _rData, const ::rtl::OUString& _rName, bool _bHighContrast ) + static void lcl_getTableImageResourceID_nothrow( const ImageProvider_Data& _rData, const ::rtl::OUString& _rName, + USHORT& _out_rResourceID, USHORT& _out_rResourceID_HC ) { - USHORT nResourceID( 0 ); + _out_rResourceID = _out_rResourceID_HC = 0; try { bool bIsView = _rData.xViews.is() && _rData.xViews->hasByName( _rName ); if ( bIsView ) - nResourceID = _bHighContrast ? VIEW_TREE_ICON_SCH : VIEW_TREE_ICON; + { + _out_rResourceID = VIEW_TREE_ICON; + _out_rResourceID_HC = VIEW_TREE_ICON_SCH; + } else - nResourceID = _bHighContrast ? TABLE_TREE_ICON_SCH : TABLE_TREE_ICON; + { + _out_rResourceID = TABLE_TREE_ICON; + _out_rResourceID_HC = TABLE_TREE_ICON_SCH; + } } catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); } - return nResourceID; } } //==================================================================== @@ -126,20 +135,22 @@ //==================================================================== //-------------------------------------------------------------------- ImageProvider::ImageProvider() - :m_pImpl( new ImageProvider_Impl ) + :m_pData( new ImageProvider_Data ) { } //-------------------------------------------------------------------- ImageProvider::ImageProvider( const Reference< XConnection >& _rxConnection ) - :m_pImpl( new ImageProvider_Impl ) + :m_pData( new ImageProvider_Data ) { - m_pImpl->xConnection = _rxConnection; + m_pData->xConnection = _rxConnection; try { - Reference< XViewsSupplier > xSuppViews( m_pImpl->xConnection, UNO_QUERY ); + Reference< XViewsSupplier > xSuppViews( m_pData->xConnection, UNO_QUERY ); if ( xSuppViews.is() ) - m_pImpl->xViews.set( xSuppViews->getViews(), UNO_SET_THROW ); + m_pData->xViews.set( xSuppViews->getViews(), UNO_SET_THROW ); + + m_pData->xTableUI.set( _rxConnection, UNO_QUERY ); } catch( const Exception& ) { @@ -148,30 +159,38 @@ } //-------------------------------------------------------------------- - Image ImageProvider::getImage( const String& _rName, sal_Int32 _nDatabaseObjectType, bool _bHighContrast ) + void ImageProvider::getImages( const String& _rName, sal_Int32 _nDatabaseObjectType, Image& _out_rImage, Image& _out_rImageHC ) { - Image aObjectImage; - if ( _nDatabaseObjectType != DatabaseObject::TABLE ) + { // for types other than tables, the icon does not depend on the concrete object - aObjectImage = getDefaultImage( _nDatabaseObjectType, _bHighContrast ); + _out_rImage = getDefaultImage( _nDatabaseObjectType, false ); + _out_rImageHC = getDefaultImage( _nDatabaseObjectType, true ); + } else { // check whether the connection can give us an icon - Reference< XGraphic > xGraphic = lcl_getConnectionProvidedTableIcon_nothrow( m_pImpl->xConnection, _rName, _bHighContrast ); + Reference< XGraphic > xGraphic; + Reference< XGraphic > xGraphicHC; + lcl_getConnectionProvidedTableIcon_nothrow( *m_pData, _rName, xGraphic, xGraphicHC ); if ( xGraphic.is() ) - aObjectImage = Image( xGraphic ); + _out_rImage = Image( xGraphic ); + if ( xGraphicHC.is() ) + _out_rImageHC = Image( xGraphicHC ); - if ( !aObjectImage ) + if ( !_out_rImage || !_out_rImageHC ) { // no -> determine by type - USHORT nImageResourceID = lcl_getTableImageResourceID_nothrow( *m_pImpl, _rName, _bHighContrast ); - if ( nImageResourceID ) - aObjectImage = Image( ModuleRes( nImageResourceID ) ); + USHORT nImageResourceID = 0; + USHORT nImageResourceID_HC = 0; + lcl_getTableImageResourceID_nothrow( *m_pData, _rName, nImageResourceID, nImageResourceID_HC ); + + if ( nImageResourceID && !_out_rImage ) + _out_rImage = Image( ModuleRes( nImageResourceID ) ); + if ( nImageResourceID_HC && !_out_rImageHC ) + _out_rImageHC = Image( ModuleRes( nImageResourceID_HC ) ); } } - - return aObjectImage; } //-------------------------------------------------------------------- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
