21#include <bitmaps.hlst>
23#include <com/sun/star/graphic/GraphicColorMode.hpp>
24#include <com/sun/star/sdb/application/XTableUIProvider.hpp>
25#include <com/sun/star/sdb/application/DatabaseObject.hpp>
26#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
33 using ::com::sun::star::uno::Reference;
34 using ::com::sun::star::sdbc::XConnection;
35 using ::com::sun::star::uno::Exception;
36 using ::com::sun::star::container::XNameAccess;
37 using ::com::sun::star::graphic::XGraphic;
38 using ::com::sun::star::sdb::application::XTableUIProvider;
39 using ::com::sun::star::uno::UNO_QUERY;
40 using ::com::sun::star::sdbcx::XViewsSupplier;
41 using ::com::sun::star::uno::UNO_SET_THROW;
43 namespace GraphicColorMode = css::graphic::GraphicColorMode;
44 namespace DatabaseObject = css::sdb::application::DatabaseObject;
48 void lcl_getConnectionProvidedTableIcon_nothrow(
49 const css::uno::Reference< css::sdb::application::XTableUIProvider >& _xTableUI,
50 const OUString& _rName, Reference< XGraphic >& _out_rxGraphic )
55 _out_rxGraphic = _xTableUI->getTableIcon( _rName, GraphicColorMode::NORMAL );
57 catch(
const Exception& )
63 void lcl_getTableImageResourceID_nothrow(
64 const css::uno::Reference< css::container::XNameAccess >& _xViews,
65 const OUString& _rName,
66 OUString& _out_rResourceID)
68 _out_rResourceID = OUString();
71 bool bIsView = _xViews.is() && _xViews->hasByName( _rName );
74 _out_rResourceID = VIEW_TREE_ICON;
78 _out_rResourceID = TABLE_TREE_ICON;
81 catch(
const Exception& )
88 ImageProvider::ImageProvider()
93 : mxConnection(_rxConnection)
98 if ( xSuppViews.is() )
99 mxViews.set( xSuppViews->getViews(), UNO_SET_THROW );
101 mxTableUI.set( _rxConnection, UNO_QUERY );
103 catch(
const Exception& )
109 OUString ImageProvider::getImageId(
const OUString& _rName,
const sal_Int32 _nDatabaseObjectType)
114 return getDefaultImageResourceID( _nDatabaseObjectType );
119 OUString sImageResourceID;
120 lcl_getTableImageResourceID_nothrow( mxViews, _rName, sImageResourceID );
121 return sImageResourceID;
125 Reference<XGraphic> ImageProvider::getXGraphic(
const OUString& _rName,
const sal_Int32 _nDatabaseObjectType)
131 lcl_getConnectionProvidedTableIcon_nothrow( mxTableUI, _rName, xGraphic );
136 OUString ImageProvider::getDefaultImageResourceID( sal_Int32 _nDatabaseObjectType)
138 OUString sImageResourceID;
139 switch ( _nDatabaseObjectType )
142 sImageResourceID = QUERY_TREE_ICON;
144 case DatabaseObject::FORM:
145 sImageResourceID = FORM_TREE_ICON;
148 sImageResourceID = REPORT_TREE_ICON;
151 sImageResourceID = TABLE_TREE_ICON;
154 OSL_FAIL(
"ImageProvider::getDefaultImage: invalid database object type!" );
157 return sImageResourceID;
160 OUString ImageProvider::getFolderImageId( sal_Int32 _nDatabaseObjectType )
162 OUString sImageResourceID;
163 switch ( _nDatabaseObjectType )
166 sImageResourceID = QUERYFOLDER_TREE_ICON;
168 case DatabaseObject::FORM:
169 sImageResourceID = FORMFOLDER_TREE_ICON;
172 sImageResourceID = REPORTFOLDER_TREE_ICON;
175 sImageResourceID = TABLEFOLDER_TREE_ICON;
178 OSL_FAIL(
"ImageProvider::getDefaultImage: invalid database object type!" );
182 return sImageResourceID;
185 OUString ImageProvider::getDatabaseImage()
187 return DATABASE_TREE_ICON;
#define DBG_UNHANDLED_EXCEPTION(...)