summaryrefslogtreecommitdiff
path: root/dbaccess/source/ui/misc/imageprovider.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'dbaccess/source/ui/misc/imageprovider.cxx')
-rw-r--r--dbaccess/source/ui/misc/imageprovider.cxx78
1 files changed, 16 insertions, 62 deletions
diff --git a/dbaccess/source/ui/misc/imageprovider.cxx b/dbaccess/source/ui/misc/imageprovider.cxx
index 585b87bc9294..6cba1b80ca30 100644
--- a/dbaccess/source/ui/misc/imageprovider.cxx
+++ b/dbaccess/source/ui/misc/imageprovider.cxx
@@ -25,7 +25,7 @@
#include <com/sun/star/sdb/application/DatabaseObject.hpp>
#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
namespace dbaui
{
@@ -43,26 +43,16 @@ namespace dbaui
namespace GraphicColorMode = css::graphic::GraphicColorMode;
namespace DatabaseObject = css::sdb::application::DatabaseObject;
- // ImageProvider_Data
- 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
{
- void lcl_getConnectionProvidedTableIcon_nothrow( const ImageProvider_Data& _rData,
+ void lcl_getConnectionProvidedTableIcon_nothrow(
+ const css::uno::Reference< css::sdb::application::XTableUIProvider >& _xTableUI,
const OUString& _rName, Reference< XGraphic >& _out_rxGraphic )
{
try
{
- if ( _rData.xTableUI.is() )
- _out_rxGraphic = _rData.xTableUI->getTableIcon( _rName, GraphicColorMode::NORMAL );
+ if ( _xTableUI.is() )
+ _out_rxGraphic = _xTableUI->getTableIcon( _rName, GraphicColorMode::NORMAL );
}
catch( const Exception& )
{
@@ -70,13 +60,15 @@ namespace dbaui
}
}
- void lcl_getTableImageResourceID_nothrow( const ImageProvider_Data& _rData, const OUString& _rName,
+ void lcl_getTableImageResourceID_nothrow(
+ const css::uno::Reference< css::container::XNameAccess >& _xViews,
+ const OUString& _rName,
OUString& _out_rResourceID)
{
_out_rResourceID = OUString();
try
{
- bool bIsView = _rData.xViews.is() && _rData.xViews->hasByName( _rName );
+ bool bIsView = _xViews.is() && _xViews->hasByName( _rName );
if ( bIsView )
{
_out_rResourceID = VIEW_TREE_ICON;
@@ -94,21 +86,19 @@ namespace dbaui
}
// ImageProvider
ImageProvider::ImageProvider()
- :m_pData( std::make_shared<ImageProvider_Data>() )
{
}
ImageProvider::ImageProvider( const Reference< XConnection >& _rxConnection )
- :m_pData( std::make_shared<ImageProvider_Data>() )
+ : mxConnection(_rxConnection)
{
- m_pData->xConnection = _rxConnection;
try
{
- Reference< XViewsSupplier > xSuppViews( m_pData->xConnection, UNO_QUERY );
+ Reference< XViewsSupplier > xSuppViews( mxConnection, UNO_QUERY );
if ( xSuppViews.is() )
- m_pData->xViews.set( xSuppViews->getViews(), UNO_SET_THROW );
+ mxViews.set( xSuppViews->getViews(), UNO_SET_THROW );
- m_pData->xTableUI.set( _rxConnection, UNO_QUERY );
+ mxTableUI.set( _rxConnection, UNO_QUERY );
}
catch( const Exception& )
{
@@ -116,33 +106,6 @@ namespace dbaui
}
}
- void ImageProvider::getImages( const OUString& _rName, const sal_Int32 _nDatabaseObjectType, Image& _out_rImage )
- {
- if ( _nDatabaseObjectType != DatabaseObject::TABLE )
- {
- // for types other than tables, the icon does not depend on the concrete object
- _out_rImage = getDefaultImage( _nDatabaseObjectType );
- }
- else
- {
- // check whether the connection can give us an icon
- Reference< XGraphic > xGraphic;
- lcl_getConnectionProvidedTableIcon_nothrow( *m_pData, _rName, xGraphic );
- if ( xGraphic.is() )
- _out_rImage = Image( xGraphic );
-
- if ( !_out_rImage )
- {
- // no -> determine by type
- OUString sImageResourceID;
- lcl_getTableImageResourceID_nothrow( *m_pData, _rName, sImageResourceID );
-
- if (!sImageResourceID.isEmpty() && !_out_rImage)
- _out_rImage = Image(StockImage::Yes, sImageResourceID);
- }
- }
- }
-
OUString ImageProvider::getImageId(const OUString& _rName, const sal_Int32 _nDatabaseObjectType)
{
if (_nDatabaseObjectType != DatabaseObject::TABLE)
@@ -154,7 +117,7 @@ namespace dbaui
{
// no -> determine by type
OUString sImageResourceID;
- lcl_getTableImageResourceID_nothrow( *m_pData, _rName, sImageResourceID );
+ lcl_getTableImageResourceID_nothrow( mxViews, _rName, sImageResourceID );
return sImageResourceID;
}
}
@@ -165,20 +128,11 @@ namespace dbaui
if (_nDatabaseObjectType == DatabaseObject::TABLE)
{
// check whether the connection can give us an icon
- lcl_getConnectionProvidedTableIcon_nothrow( *m_pData, _rName, xGraphic );
+ lcl_getConnectionProvidedTableIcon_nothrow( mxTableUI, _rName, xGraphic );
}
return xGraphic;
}
- Image ImageProvider::getDefaultImage( sal_Int32 _nDatabaseObjectType )
- {
- Image aObjectImage;
- OUString sImageResourceID( getDefaultImageResourceID( _nDatabaseObjectType) );
- if (!sImageResourceID.isEmpty())
- aObjectImage = Image(StockImage::Yes, sImageResourceID);
- return aObjectImage;
- }
-
OUString ImageProvider::getDefaultImageResourceID( sal_Int32 _nDatabaseObjectType)
{
OUString sImageResourceID;
@@ -228,7 +182,7 @@ namespace dbaui
return sImageResourceID;
}
- OUString ImageProvider::getDatabaseImage()
+ const OUString & ImageProvider::getDatabaseImage()
{
return DATABASE_TREE_ICON;
}