Tag: cws_src680_dba203c
User: fs      
Date: 06/04/25 01:43:51

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

Log:
 outsourced the warnings handling during #i62646#

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.45&r2=1.45.84.1
Delta lines:  +10 -75
---------------------
--- connection.cxx      24 Oct 2005 08:28:24 -0000      1.45
+++ connection.cxx      25 Apr 2006 08:43:48 -0000      1.45.84.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: connection.cxx,v $
  *
- *  $Revision: 1.45 $
+ *  $Revision: 1.45.84.1 $
  *
- *  last change: $Author: rt $ $Date: 2005/10/24 08:28:24 $
+ *  last change: $Author: fs $ $Date: 2006/04/25 08:43:48 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -331,6 +331,7 @@
                        ,m_aTableTypeFilter(_rDB.m_pImpl->m_aTableTypeFilter)
                        ,m_xORB(_rxORB)
                        ,m_xMasterConnection(_rxMaster)
+            ,m_aWarnings( Reference< XWarningsSupplier >( _rxMaster, UNO_QUERY 
) )
                        ,m_pTables(NULL)
                        ,m_pViews(NULL)
                        ,m_bSupportsViews(sal_False)
@@ -350,25 +351,14 @@
                Reference<XAggregation> xAgg = 
xProxyFactory->createProxy(_rxMaster.get());
                setDelegation(xAgg,m_refCount);
                DBG_ASSERT(m_xConnection.is(), "OConnection::OConnection : 
invalid master connection !");
-               if (!m_xProxyConnection->queryAggregation(getCppuType( 
(Reference<XWarningsSupplier>*)0)).hasValue())
-               {
-                       DBG_ERROR("OConnection::OConnection : the connection is 
assumed to be a warnings supplier ! Won't use it !");
-                       // as we're the owner of the conn and don't want to use 
it -> dispose
-                       Reference< XComponent > xConnComp;
-                       
::comphelper::query_aggregation(m_xProxyConnection,xConnComp);
-                       if (xConnComp.is())
-                               xConnComp->dispose();
-
-                       m_xMasterConnection = NULL;
-               }
        }
        catch(const Exception&)
        {
        }
+
        try
        {
-               m_pQueries = new OQueryContainer(Reference< XNameContainer 
>(_rDB.getQueryDefinitions( ),UNO_QUERY), this,_rxORB, this);
-               m_xQueries = m_pQueries;
+               m_xQueries = new OQueryContainer(Reference< XNameContainer 
>(_rDB.getQueryDefinitions( ),UNO_QUERY), this,_rxORB, &m_aWarnings);
 
                sal_Bool bCase = sal_True;
                Reference<XDatabaseMetaData> xMeta;
@@ -381,7 +371,7 @@
                {
                }
                Reference< XNameContainer > 
xDefNames(_rDB.getTables(),UNO_QUERY);
-               m_pTables = new OTableContainer(*this, m_aMutex,this, bCase, 
xDefNames,this,this);
+               m_pTables = new OTableContainer(*this, m_aMutex,this, bCase, 
xDefNames,this,&m_aWarnings);
 
                // check if we supports types
                if ( xMeta.is() )
@@ -411,7 +401,7 @@
                        }
                        if(m_bSupportsViews)
                        {
-                               m_pViews = new OViewContainer(*this, m_aMutex, 
this, bCase,this,this);
+                               m_pViews = new OViewContainer(*this, m_aMutex, 
this, bCase,this,&m_aWarnings);
                                m_pViews->addContainerListener(m_pTables);
                                m_pTables->addContainerListener(m_pViews);
                        }
@@ -435,65 +425,13 @@
 }
 
 
-// IWarningsContainer
-//------------------------------------------------------------------------------
-void OConnection::appendWarning(const SQLException& _rWarning)
-{
-       implConcatWarnings(m_aAdditionalWarnings, makeAny(_rWarning));
-}
-
-//------------------------------------------------------------------------------
-void OConnection::appendWarning(const SQLContext& _rContext)
-{
-       implConcatWarnings(m_aAdditionalWarnings, makeAny(_rContext));
-}
-
-//------------------------------------------------------------------------------
-void OConnection::appendWarning(const SQLWarning& _rWarning)
-{
-       implConcatWarnings(m_aAdditionalWarnings, makeAny(_rWarning));
-}
-
 // XWarningsSupplier
 //--------------------------------------------------------------------------
 Any SAL_CALL OConnection::getWarnings() throw(SQLException, RuntimeException)
 {
        MutexGuard aGuard(m_aMutex);
        checkDisposed();
-       Reference<XWarningsSupplier> xWarnings;
-       ::comphelper::query_aggregation(m_xProxyConnection,xWarnings);
-       Any aReturn = xWarnings->getWarnings();
-       if (!m_aAdditionalWarnings.hasValue())
-               return aReturn;
-       else
-       {
-               // copy m_aAdditionalWarnings, and append the original warnings
-               Any aOverallWarnings(m_aAdditionalWarnings);
-               implConcatWarnings(aOverallWarnings, aReturn);
-               return aOverallWarnings;
-       }
-}
-
-//--------------------------------------------------------------------------
-void OConnection::implConcatWarnings(Any& _rChainLeft, const Any& _rChainRight)
-{
-       if (!_rChainLeft.hasValue())
-               _rChainLeft = _rChainRight;
-       else
-       {
-               // to travel the chain by reference (and not by value), we need 
the getValue ...
-               // looks like a hack, but the meaning of getValue is 
documented, and it's the only chance for reference-traveling ....
-
-               DBG_ASSERT(SQLExceptionInfo(_rChainLeft).isValid(), 
"OConnection::appendWarning: invalid warnings chain (this will crash)!");
-
-               const SQLException* pChainTravel = static_cast<const 
SQLException*>(_rChainLeft.getValue());
-               SQLExceptionIteratorHelper aReferenceIterHelper(pChainTravel);
-               while (aReferenceIterHelper.hasMoreElements())
-                       pChainTravel = aReferenceIterHelper.next();
-
-               // reached the end of the chain, and pChainTravel points to the 
last element
-               const_cast<SQLException*>(pChainTravel)->NextException = 
_rChainRight;
-       }
+    return m_aWarnings.getWarnings();
 }
 
 //--------------------------------------------------------------------------
@@ -501,10 +439,7 @@
 {
        MutexGuard aGuard(m_aMutex);
        checkDisposed();
-       Reference<XWarningsSupplier> xWarnings;
-       ::comphelper::query_aggregation(m_xProxyConnection,xWarnings);
-       xWarnings->clearWarnings();
-       m_aAdditionalWarnings.clear();
+    m_aWarnings.clearWarnings();
 }
 
 //--------------------------------------------------------------------------

File [changed]: connection.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/connection.hxx?r1=1.22&r2=1.22.110.1
Delta lines:  +9 -14
--------------------
--- connection.hxx      8 Sep 2005 11:38:02 -0000       1.22
+++ connection.hxx      25 Apr 2006 08:43:48 -0000      1.22.110.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: connection.hxx,v $
  *
- *  $Revision: 1.22 $
+ *  $Revision: 1.22.110.1 $
  *
- *  last change: $Author: rt $ $Date: 2005/09/08 11:38:02 $
+ *  last change: $Author: fs $ $Date: 2006/04/25 08:43:48 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -83,6 +83,9 @@
 #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>
 #endif
@@ -115,15 +118,14 @@
                                                        ,public OSubComponent
                                                        ,public 
::connectivity::OConnectionWrapper
                                                        ,public OConnection_Base
-                                                       ,public 
IWarningsContainer
                                                        ,public IRefreshListener
 {
 protected:
        ::com::sun::star::uno::Reference< 
::com::sun::star::sdbcx::XTablesSupplier >
                                                        m_xMasterTables; // 
just to avoid the recreation of the catalog
        OWeakRefArray                   m_aStatements;
-       OQueryContainer*                m_pQueries;
-       ::com::sun::star::uno::Reference< 
::com::sun::star::container::XNameAccess >            m_xQueries;
+       ::com::sun::star::uno::Reference< 
::com::sun::star::container::XNameAccess >
+                            m_xQueries;
        OWeakRefArray                   m_aComposers;
 
        // the filter as set on the parent data link at construction of the 
connection
@@ -134,7 +136,7 @@
 
        OTableContainer*                        m_pTables;
        OViewContainer*                         m_pViews;
-       ::com::sun::star::uno::Any      m_aAdditionalWarnings;  // own warnings 
(appended to the ones got by the master connection)
+    WarningsContainer           m_aWarnings;
        sal_Bool                                        m_bSupportsViews;       
        // true when the getTableTypes return "VIEW" as type
        sal_Bool                                        m_bSupportsUsers;
        sal_Bool                                        m_bSupportsGroups;
@@ -220,15 +222,8 @@
 
        // IRefreshListener
        virtual void refresh(const ::com::sun::star::uno::Reference< 
::com::sun::star::container::XNameAccess >& _rToBeRefreshed);
-protected:
-       // IWarningsContainer
-       virtual void appendWarning(const ::com::sun::star::sdbc::SQLException& 
_rWarning);
-       virtual void appendWarning(const ::com::sun::star::sdbc::SQLWarning& 
_rWarning);
-       virtual void appendWarning(const ::com::sun::star::sdb::SQLContext& 
_rContext);
 
 protected:
-       static void implConcatWarnings(::com::sun::star::uno::Any& _rChainLeft, 
const ::com::sun::star::uno::Any& _rChainRight);
-
        inline  void checkDisposed() throw 
(::com::sun::star::lang::DisposedException)
        {
                if ( rBHelper.bDisposed || !m_xConnection.is() )




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

Reply via email to