Tag: cws_src680_qiq
User: fs      
Date: 06/05/23 23:41:40

Modified:
 /dba/dbaccess/source/core/dataaccess/
  connection.cxx, connection.hxx

Log:
 #i51143# implement XConnectionTools

File Changes:

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

File [changed]: connection.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/connection.cxx?r1=1.46.2.1&r2=1.46.2.2
Delta lines:  +56 -9
--------------------
--- connection.cxx      10 May 2006 14:23:54 -0000      1.46.2.1
+++ connection.cxx      24 May 2006 06:41:37 -0000      1.46.2.2
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: connection.cxx,v $
  *
- *  $Revision: 1.46.2.1 $
+ *  $Revision: 1.46.2.2 $
  *
- *  last change: $Author: fs $ $Date: 2006/05/10 14:23:54 $
+ *  last change: $Author: fs $ $Date: 2006/05/24 06:41:37 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -68,6 +68,7 @@
 #include "querycomposer.hxx"
 #endif
 
+/** === begin UNO includes === **/
 #ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
 #include <com/sun/star/sdb/CommandType.hpp>
 #endif
@@ -80,6 +81,10 @@
 #ifndef _COM_SUN_STAR_REFLECTION_XPROXYFACTORY_HPP_
 #include <com/sun/star/reflection/XProxyFactory.hpp>
 #endif
+#ifndef _COM_SUN_STAR_BEANS_NAMEDVALUE_HPP_
+#include <com/sun/star/beans/NamedValue.hpp>
+#endif
+/** === end UNO includes === **/
 
 #ifndef _CONNECTIVITY_DBTOOLS_HXX_
 #include <connectivity/dbtools.hxx>
@@ -343,7 +348,7 @@
                                // same for tables
                        ,m_aTableFilter(_rDB.m_pImpl->m_aTableFilter)
                        ,m_aTableTypeFilter(_rDB.m_pImpl->m_aTableTypeFilter)
-                       ,m_xORB(_rxORB)
+                       ,m_aContext( _rxORB )
                        ,m_xMasterConnection(_rxMaster)
             ,m_aWarnings( Reference< XWarningsSupplier >( _rxMaster, UNO_QUERY 
) )
                        ,m_pTables(NULL)
@@ -598,7 +603,7 @@
        checkDisposed();
 
        //      Reference< XNumberFormatsSupplier >  xSupplier = 
pParent->getNumberFormatsSupplier();
-       Reference< XSQLQueryComposer >  xComposer(new 
OQueryComposer(getTables(),this, m_xORB));
+       Reference< XSQLQueryComposer >  xComposer( new OQueryComposer( 
getTables(), this, m_aContext.getLegacyServiceFactory() ) );
        m_aComposers.push_back(WeakReferenceHelper(xComposer));
        return xComposer;
 }
@@ -680,10 +685,11 @@
        {
                case CommandType::TABLE:
                        {
-                               sal_Bool bUseCatalogInSelect = 
::dbtools::isDataSourcePropertyEnabled(*this,PROPERTY_USECATALOGINSELECT,sal_True);
-                               sal_Bool bUseSchemaInSelect = 
::dbtools::isDataSourcePropertyEnabled(*this,PROPERTY_USESCHEMAINSELECT,sal_True);
                                aStatement = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT * FROM "));
-                               aStatement += 
::dbtools::quoteTableName(getMetaData(), 
command,::dbtools::eInDataManipulation,bUseCatalogInSelect,bUseSchemaInSelect);
+
+                ::rtl::OUString sCatalog, sSchema, sTable;
+                ::dbtools::qualifiedNameComponents( getMetaData(), command, 
sCatalog, sSchema, sTable, ::dbtools::eInDataManipulation );
+                aStatement += ::dbtools::composeTableNameForSelect( this, 
sCatalog, sSchema, sTable );
                        }
                        break;
                case CommandType::QUERY:
@@ -707,7 +713,7 @@
         || ( _sServiceSpecifier.equalsAscii( 
"com.sun.star.sdb.SingleSelectQueryAnalyzer" ) )
         )
        {
-               xRet = new OSingleSelectQueryComposer(getTables(),this, m_xORB);
+               xRet = new OSingleSelectQueryComposer( getTables(),this, 
m_aContext.getLegacyServiceFactory() );
                m_aComposers.push_back(WeakReferenceHelper(xRet));
        }
        return Reference< XInterface >(xRet,UNO_QUERY);
@@ -734,7 +740,7 @@
                {
                        Reference<XDatabaseMetaData> xMeta = getMetaData();
                        if ( xMeta.is() )
-                               m_xMasterTables = 
::dbtools::getDataDefinitionByURLAndConnection(xMeta->getURL(),m_xMasterConnection,m_xORB);
+                               m_xMasterTables = 
::dbtools::getDataDefinitionByURLAndConnection( xMeta->getURL(), 
m_xMasterConnection, m_aContext.getLegacyServiceFactory() );
                }
                catch(SQLException&)
                {
@@ -761,6 +767,47 @@
        Reference<XGroupsSupplier> xGrp(getMasterTables(),UNO_QUERY);
        return xGrp.is() ? xGrp->getGroups() : Reference< XNameAccess >();
 }
+
+// 
-----------------------------------------------------------------------------
+void OConnection::impl_loadConnectionTools_throw()
+{
+    Sequence< Any > aArguments( 1 );
+    aArguments[0] <<= NamedValue( ::rtl::OUString( 
RTL_CONSTASCII_USTRINGPARAM( "Connection" ) ), makeAny( Reference< XConnection 
>( this ) ) );
+
+    if ( !m_aContext.createComponentWithArguments( 
"com.sun.star.sdb.tools.ConnectionTools", aArguments, m_xConnectionTools ) )
+        throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 
"service not registered: com.sun.star.sdb.tools.ConnectionTools" ) ), *this );
+}
+
+// 
-----------------------------------------------------------------------------
+Reference< tools::XTableName > SAL_CALL OConnection::createTableName(  ) throw 
(RuntimeException)
+{
+       MutexGuard aGuard(m_aMutex);
+       checkDisposed();
+    impl_loadConnectionTools_throw();
+
+    return m_xConnectionTools->createTableName();
+}
+
+// 
-----------------------------------------------------------------------------
+Reference< tools::XObjectNames > SAL_CALL OConnection::createObjectNames(  ) 
throw (RuntimeException)
+{
+       MutexGuard aGuard(m_aMutex);
+       checkDisposed();
+    impl_loadConnectionTools_throw();
+
+    return m_xConnectionTools->createObjectNames();
+}
+
+// 
-----------------------------------------------------------------------------
+Reference< tools::XDataSourceMetaData > SAL_CALL 
OConnection::getDataSourceMetaData(  ) throw (RuntimeException)
+{
+       MutexGuard aGuard(m_aMutex);
+       checkDisposed();
+    impl_loadConnectionTools_throw();
+
+    return m_xConnectionTools->getDataSourceMetaData();
+}
+
 
 // 
-----------------------------------------------------------------------------
 void OConnection::impl_checkTableQueryNames_nothrow()

File [changed]: connection.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/connection.hxx?r1=1.23.4.2&r2=1.23.4.3
Delta lines:  +70 -39
---------------------
--- connection.hxx      11 May 2006 11:25:53 -0000      1.23.4.2
+++ connection.hxx      24 May 2006 06:41:37 -0000      1.23.4.3
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: connection.hxx,v $
  *
- *  $Revision: 1.23.4.2 $
+ *  $Revision: 1.23.4.3 $
  *
- *  last change: $Author: fs $ $Date: 2006/05/11 11:25:53 $
+ *  last change: $Author: fs $ $Date: 2006/05/24 06:41:37 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -35,6 +35,26 @@
 #ifndef _DBA_CORE_CONNECTION_HXX_
 #define _DBA_CORE_CONNECTION_HXX_
 
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+#ifndef _DBA_CORE_QUERYCONTAINER_HXX_
+#include "querycontainer.hxx"
+#endif
+#ifndef _DBA_CORE_TABLECONTAINER_HXX_
+#include "tablecontainer.hxx"
+#endif
+#ifndef _DBA_CORE_VIEWCONTAINER_HXX_
+#include "viewcontainer.hxx"
+#endif
+#ifndef DBA_CORE_REFRESHLISTENER_HXX
+#include "RefreshListener.hxx"
+#endif
+#ifndef DBA_CORE_WARNINGS_HXX
+#include "warning.hxx"
+#endif
+
+/** === begin UNO includes === **/
 #ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
 #include <com/sun/star/container/XChild.hpp>
 #endif
@@ -62,32 +82,26 @@
 #ifndef _COM_SUN_STAR_SDB_XQUERIESSUPPLIER_HPP_
 #include <com/sun/star/sdb/XQueriesSupplier.hpp>
 #endif
-#ifndef _CPPUHELPER_IMPLBASE12_HXX_
-#include <cppuhelper/implbase12.hxx>
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #endif
-#ifndef _DBASHARED_APITOOLS_HXX_
-#include "apitools.hxx"
+#ifndef _COM_SUN_STAR_SDB_TOOLS_XCONNECTIONTOOLS_HPP_
+#include <com/sun/star/sdb/tools/XConnectionTools.hpp>
 #endif
-#ifndef _DBA_CORE_QUERYCONTAINER_HXX_
-#include "querycontainer.hxx"
-#endif
-#ifndef _DBA_CORE_TABLECONTAINER_HXX_
-#include "tablecontainer.hxx"
+/** === end UNO includes === **/
+
+#if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_13)
+#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_13
+#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 13
+#include <comphelper/implbase_var.hxx>
 #endif
-#ifndef _DBA_CORE_VIEWCONTAINER_HXX_
-#include "viewcontainer.hxx"
+
+#ifndef COMPHELPER_COMPONENTCONTEXT_HXX
+#include <comphelper/componentcontext.hxx>
 #endif
+
 #ifndef _CONNECTIVITY_CONNECTIONWRAPPER_HXX_
-#include "connectivity/ConnectionWrapper.hxx"
-#endif
-#ifndef DBA_CORE_REFRESHLISTENER_HXX
-#include "RefreshListener.hxx"
-#endif
-#ifndef DBA_CORE_WARNINGS_HXX
-#include "warning.hxx"
-#endif
-#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <connectivity/ConnectionWrapper.hxx>
 #endif
 
 //........................................................................
@@ -97,7 +111,7 @@
 
 //==========================================================================
 //==========================================================================
-typedef ::cppu::ImplHelper12<  ::com::sun::star::container::XChild
+typedef ::comphelper::ImplHelper13  <   ::com::sun::star::container::XChild
                                                        ,       
::com::sun::star::sdbcx::XTablesSupplier
                                                        ,       
::com::sun::star::sdbcx::XViewsSupplier
                                                        ,       
::com::sun::star::sdbc::XConnection
@@ -109,6 +123,7 @@
                                                        ,       
::com::sun::star::lang::XMultiServiceFactory
                                                        ,       
::com::sun::star::sdbcx::XUsersSupplier
                                                        ,       
::com::sun::star::sdbcx::XGroupsSupplier
+                                    ,   
::com::sun::star::sdb::tools::XConnectionTools
                                                        >       
OConnection_Base;
 
 class ODatabaseSource;
@@ -132,8 +147,9 @@
        // the filter as set on the parent data link at construction of the 
connection
        ::com::sun::star::uno::Sequence< ::rtl::OUString >      m_aTableFilter;
        ::com::sun::star::uno::Sequence< ::rtl::OUString >      
m_aTableTypeFilter;
-       ::com::sun::star::uno::Reference< 
::com::sun::star::lang::XMultiServiceFactory >        m_xORB;
+    ::comphelper::ComponentContext                      m_aContext;
        ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > 
                        m_xMasterConnection;
+    ::com::sun::star::uno::Reference< 
::com::sun::star::sdb::tools::XConnectionTools >  m_xConnectionTools;
 
        OTableContainer*                        m_pTables;
        OViewContainer*                         m_pViews;
@@ -221,6 +237,11 @@
        // XGroupsSupplier
     virtual ::com::sun::star::uno::Reference< 
::com::sun::star::container::XNameAccess > SAL_CALL getGroups(  ) 
throw(::com::sun::star::uno::RuntimeException);
 
+    // XConnectionTools
+    virtual ::com::sun::star::uno::Reference< 
::com::sun::star::sdb::tools::XTableName > SAL_CALL createTableName(  ) throw 
(::com::sun::star::uno::RuntimeException);
+    virtual ::com::sun::star::uno::Reference< 
::com::sun::star::sdb::tools::XObjectNames > SAL_CALL createObjectNames(  ) 
throw (::com::sun::star::uno::RuntimeException);
+    virtual ::com::sun::star::uno::Reference< 
::com::sun::star::sdb::tools::XDataSourceMetaData > SAL_CALL 
getDataSourceMetaData(  ) throw (::com::sun::star::uno::RuntimeException);
+
        // IRefreshListener
        virtual void refresh(const ::com::sun::star::uno::Reference< 
::com::sun::star::container::XNameAccess >& _rToBeRefreshed);
 
@@ -237,6 +258,16 @@
     /** checks whether or not there are naming conflicts between tables and 
queries
     */
     void impl_checkTableQueryNames_nothrow();
+
+    /** loads the XConnectionTools implementation which we forward the 
respective functionality to
+
+        @throws ::com::sun::star::uno::RuntimeException
+            if the implementation cannot be loaded
+
+        @postcond
+            m_xConnectionTools is nol <NULL/>
+    */
+    void    impl_loadConnectionTools_throw();
 };
 
 //........................................................................




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

Reply via email to