Tag: cws_src680_dba24
User: fs      
Date: 05/02/10 08:53:14

Modified:
 /dba/dbaccess/source/core/api/
  tablecontainer.cxx

Log:
 #i15113# introduce a data-source-setting which controls which TableTypeFilter 
to use to obtain *all* tables - IBM's Universe database doesn't like our 
default behaviour

File Changes:

Directory: /dba/dbaccess/source/core/api/
=========================================

File [changed]: tablecontainer.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/api/tablecontainer.cxx?r1=1.58.50.1&r2=1.58.50.2
Delta lines:  +67 -21
---------------------
--- tablecontainer.cxx  9 Feb 2005 08:12:58 -0000       1.58.50.1
+++ tablecontainer.cxx  10 Feb 2005 16:53:11 -0000      1.58.50.2
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: tablecontainer.cxx,v $
  *
- *  $Revision: 1.58.50.1 $
+ *  $Revision: 1.58.50.2 $
  *
- *  last change: $Author: oj $ $Date: 2005/02/09 08:12:58 $
+ *  last change: $Author: fs $ $Date: 2005/02/10 16:53:11 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -181,7 +181,7 @@
                                }
                                catch(Exception)
                                {
-                                       OSL_ENSURE(0,"Exception catched!");
+                    OSL_ENSURE( 0, "lcl_isPropertySetDefaulted: Exception 
caught!" );
                                }
                        }
                        // the code below doesn't function -> I don't kow why
@@ -332,13 +332,8 @@
                        if(sCatalog.getLength())
                                aCatalog <<= sCatalog;
                        ::rtl::OUString sType,sDescription;
-                       Sequence< ::rtl::OUString> aTypeFilter(3);
-                       static const ::rtl::OUString sAll = 
::rtl::OUString::createFromAscii("%");
-                       static const ::rtl::OUString 
s_sTableTypeView(RTL_CONSTASCII_USTRINGPARAM("VIEW"));
-                       static const ::rtl::OUString 
s_sTableTypeTable(RTL_CONSTASCII_USTRINGPARAM("TABLE"));
-                       aTypeFilter[0] = s_sTableTypeView;
-                       aTypeFilter[1] = s_sTableTypeTable;
-                       aTypeFilter[2] = sAll;  // just to be sure to include 
anything else ....
+                       Sequence< ::rtl::OUString> aTypeFilter;
+            getAllTableTypeFilter( aTypeFilter );
 
                        Reference< XResultSet > xRes =  m_xMetaData.is() ? 
m_xMetaData->getTables(aCatalog,sSchema,sTable,aTypeFilter) : Reference< 
XResultSet >();
                        if(xRes.is() && xRes->next())
@@ -604,21 +599,15 @@
 
 Sequence< ::rtl::OUString > OTableContainer::getTableTypeFilter(const 
Sequence< ::rtl::OUString >& _rTableTypeFilter) const
 {
-       static const ::rtl::OUString sAll = 
::rtl::OUString::createFromAscii("%");
        Sequence< ::rtl::OUString > sTableTypes;
-       if(_rTableTypeFilter.getLength() == 0)
+       if ( _rTableTypeFilter.getLength() == 0 )
        {
-               // we want all catalogues, all schemas, all tables
-               sTableTypes.realloc(3);
-       
-               static const ::rtl::OUString 
s_sTableTypeView(RTL_CONSTASCII_USTRINGPARAM("VIEW"));
-               static const ::rtl::OUString 
s_sTableTypeTable(RTL_CONSTASCII_USTRINGPARAM("TABLE"));
-               sTableTypes[0] = s_sTableTypeView;
-               sTableTypes[1] = s_sTableTypeTable;
-               sTableTypes[2] = sAll;  // just to be sure to include anything 
else ....
+        getAllTableTypeFilter( sTableTypes );
        }
        else
+    {
                sTableTypes = _rTableTypeFilter;
+    }
        return sTableTypes;
 }
 // 
-----------------------------------------------------------------------------
@@ -634,5 +623,62 @@
 {
        // nothing to do here
 }
+
+// 
-----------------------------------------------------------------------------
+// two ways to obtain all tables from XDatabaseMetaData::getTables, via 
passing a particular
+// table type filter:
+// adhere to the standard, which requests to pass a NULL table type filter, if
+// you want to retrieve all tables
+#define FILTER_MODE_STANDARD 0
+// only pass %, which is not allowed by the standard, but understood by some 
drivers
+#define FILTER_MODE_WILDCARD 1
+// only pass TABLE and VIEW
+#define FILTER_MODE_FIXED    2
+// do the thing which showed to be the safest way, understood by nearly all
+// drivers, even the ones which do not understand the standard
+#define FILTER_MODE_MIX_ALL  3
+
+void OTableContainer::getAllTableTypeFilter( Sequence< ::rtl::OUString >& /* 
[out] */ _rFilter ) const
+{
+    sal_Int32 nFilterMode = FILTER_MODE_MIX_ALL;
+        // for compatibility reasons, this is the default: we used this way 
before we
+        // introduced the TableTypeFilterMode setting
+
+    // obtain the data source we belong to, and the TableTypeFilterMode setting
+    Any aFilterModeSetting;
+    if ( getDataSourceSetting( getDataSource( (Reference< XInterface 
>)m_rParent ), "TableTypeFilterMode", aFilterModeSetting ) )
+    {
+        OSL_VERIFY( aFilterModeSetting >>= nFilterMode );
+    }
+
+    const ::rtl::OUString sAll( RTL_CONSTASCII_USTRINGPARAM( "%" ) );
+       const ::rtl::OUString sView( RTL_CONSTASCII_USTRINGPARAM( "VIEW" ) );
+       const ::rtl::OUString sTable( RTL_CONSTASCII_USTRINGPARAM( "TABLE" ) );
+
+    switch ( nFilterMode )
+    {
+    default:
+        OSL_ENSURE( sal_False, "OTableContainer::getAllTableTypeFilter: 
unknown TableTypeFilterMode!" );
+    case FILTER_MODE_MIX_ALL:
+        _rFilter.realloc( 3 );
+        _rFilter[0] = sView;
+        _rFilter[1] = sTable;
+        _rFilter[2] = sAll;
+        break;
+    case FILTER_MODE_FIXED:
+        _rFilter.realloc( 2 );
+        _rFilter[0] = sView;
+        _rFilter[1] = sTable;
+        break;
+    case FILTER_MODE_WILDCARD:
+        _rFilter.realloc( 1 );
+        _rFilter[0] = sAll;
+        break;
+    case FILTER_MODE_STANDARD:
+        _rFilter.realloc( 0 );
+        break;
+    }
+}
+
 // 
-----------------------------------------------------------------------------
 




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

Reply via email to