Tag: cws_src680_dba24c
User: fs      
Date: 2007-10-26 11:55:18+0000
Modified:
   dba/dbaccess/source/ui/misc/imageprovider.cxx

Log:
 #i73245# don't create the Table object to examine whether it's a view, instead 
ask the Views container supplied by the XViewsSupplier. This saves us O(n) 
getTables calls, with n being the number of tables

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&r2=1.3.110.1
Delta lines:  +22 -41
---------------------
--- imageprovider.cxx   2006-11-07 14:49:19+0000        1.3
+++ imageprovider.cxx   2007-10-26 11:55:15+0000        1.3.110.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: imageprovider.cxx,v $
  *
- *  $Revision: 1.3 $
+ *  $Revision: 1.3.110.1 $
  *
- *  last change: $Author: kz $ $Date: 2006/11/07 14:49:19 $
+ *  last change: $Author: fs $ $Date: 2007/10/26 11:55:15 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -36,44 +36,20 @@
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_dbaccess.hxx"
 
-#ifndef DBACCESS_IMAGEPROVIDER_HXX
 #include "imageprovider.hxx"
-#endif
-#ifndef _DBU_RESOURCE_HRC_
 #include "dbu_resource.hrc"
-#endif
-#ifndef _DBAUI_MODULE_DBU_HXX_
 #include "moduledbu.hxx"
-#endif
-#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
 #include "dbustrings.hrc"
-#endif
 
 /** === begin UNO includes === **/
-#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
-#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
-#endif
-#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
 #include <com/sun/star/beans/XPropertySet.hpp>
-#endif
-#ifndef _COM_SUN_STAR_GRAPHIC_XGRAPHIC_HPP_
 #include <com/sun/star/graphic/XGraphic.hpp>
-#endif
-#ifndef _COM_SUN_STAR_GRAPHIC_GRAPHICCOLORMODE_HPP_
 #include <com/sun/star/graphic/GraphicColorMode.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDB_APPLICATION_XTABLEUIPROVIDER_HPP_
 #include <com/sun/star/sdb/application/XTableUIProvider.hpp>
-#endif
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
 /** === end UNO includes === **/
 
-#ifndef _OSL_DIAGNOSE_H_
-#include <osl/diagnose.h>
-#endif
-
-#ifndef TOOLS_DIAGNOSE_EX_H
 #include <tools/diagnose_ex.h>
-#endif
 
 //........................................................................
 namespace dbaui
@@ -85,12 +61,13 @@
     using ::com::sun::star::sdbc::XConnection;
     using ::com::sun::star::uno::Exception;
     using ::com::sun::star::uno::UNO_QUERY_THROW;
-    using ::com::sun::star::sdbcx::XTablesSupplier;
     using ::com::sun::star::container::XNameAccess;
     using ::com::sun::star::beans::XPropertySet;
     using ::com::sun::star::graphic::XGraphic;
     using ::com::sun::star::sdb::application::XTableUIProvider;
     using ::com::sun::star::uno::UNO_QUERY;
+    using ::com::sun::star::sdbcx::XViewsSupplier;
+    using ::com::sun::star::uno::UNO_SET_THROW;
        /** === end UNO using === **/
     namespace GraphicColorMode = ::com::sun::star::graphic::GraphicColorMode;
 
@@ -99,7 +76,10 @@
        //====================================================================
     struct ImageProvider_Impl
     {
+        /// the connection we work with
         Reference< XConnection >    xConnection;
+        /// the views of the connection, if the DB supports views
+        Reference< XNameAccess >    xViews;
     };
 
        //--------------------------------------------------------------------
@@ -123,21 +103,12 @@
         }
 
            //................................................................
-        static USHORT lcl_getTableImageResourceID_nothrow( const Reference< 
XConnection >& _rxConnection, const ::rtl::OUString& _rName, bool 
_bHighContrast )
+        static USHORT lcl_getTableImageResourceID_nothrow( const 
ImageProvider_Impl& _rData, const ::rtl::OUString& _rName, bool _bHighContrast )
         {
             USHORT nResourceID( 0 );
             try
             {
-                Reference< XTablesSupplier > xTableSupp( _rxConnection, 
UNO_QUERY_THROW );
-                Reference< XNameAccess > xTables( xTableSupp->getTables(), 
UNO_QUERY_THROW );
-
-                OSL_ENSURE( xTables->hasByName( _rName ), 
"lcl_getTableImageResourceID_nothrow: table with the given name does not 
exist!" );
-
-                Reference< XPropertySet > xTableProps( xTables->getByName( 
_rName ), UNO_QUERY_THROW );
-                ::rtl::OUString sTableType;
-                OSL_VERIFY( xTableProps->getPropertyValue( PROPERTY_TYPE ) >>= 
sTableType );
-                bool bIsView = sTableType.equalsAscii( "VIEW" );
-
+                bool bIsView = _rData.xViews.is() && _rData.xViews->hasByName( 
_rName );
                 if ( bIsView )
                     nResourceID = _bHighContrast ? VIEW_TREE_ICON_SCH : 
VIEW_TREE_ICON;
                 else
@@ -164,6 +135,16 @@
         :m_pImpl( new ImageProvider_Impl )
     {
         m_pImpl->xConnection = _rxConnection;
+        try
+        {
+            Reference< XViewsSupplier > xSuppViews( m_pImpl->xConnection, 
UNO_QUERY );
+            if ( xSuppViews.is() )
+                m_pImpl->xViews.set( xSuppViews->getViews(), UNO_SET_THROW );
+        }
+        catch( const Exception& )
+        {
+               DBG_UNHANDLED_EXCEPTION();
+        }
     }
 
        //--------------------------------------------------------------------
@@ -184,7 +165,7 @@
             if ( !aObjectImage )
             {
                 // no -> determine by type
-                USHORT nImageResourceID = lcl_getTableImageResourceID_nothrow( 
m_pImpl->xConnection, _rName, _bHighContrast );
+                USHORT nImageResourceID = lcl_getTableImageResourceID_nothrow( 
*m_pImpl, _rName, _bHighContrast );
                 if ( nImageResourceID )
                     aObjectImage = Image( ModuleRes( nImageResourceID ) );
             }




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to