Tag: cws_src680_warnings01
User: sb      
Date: 06/04/07 13:22:20

Modified:
 /dba/connectivity/source/drivers/mozab/
  MConnection.cxx

Log:
 RESYNC: (1.19-1.20); FILE MERGED

File Changes:

Directory: /dba/connectivity/source/drivers/mozab/
==================================================

File [changed]: MConnection.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/mozab/MConnection.cxx?r1=1.19.28.4&r2=1.19.28.5
Delta lines:  +53 -5
--------------------
--- MConnection.cxx     29 Mar 2006 12:39:24 -0000      1.19.28.4
+++ MConnection.cxx     7 Apr 2006 20:22:18 -0000       1.19.28.5
@@ -63,6 +63,12 @@
 #include "diagnose_ex.h"
 #endif
 
+#ifndef COMPHELPER_OFFICE_RESOURCE_BUNDLE_HXX
+#include <comphelper/officeresourcebundle.hxx>
+#endif
+
+#include <boost/shared_ptr.hpp>
+
 #if OSL_DEBUG_LEVEL > 0
 # define OUtoCStr( x ) ( ::rtl::OUStringToOString ( (x), 
RTL_TEXTENCODING_ASCII_US).getStr())
 #else /* OSL_DEBUG_LEVEL */
@@ -93,6 +99,14 @@
 
 namespace connectivity { namespace mozab {
 
+// =====================================================================
+// = ConnectionImplData
+// =====================================================================
+struct ConnectionImplData
+{
+    ::boost::shared_ptr< ::comphelper::OfficeResourceBundle >   
pResourceBundle;
+};
+
 // 
-----------------------------------------------------------------------------
 const sal_Char* getSdbcScheme( SdbcScheme _eScheme )
 {
@@ -132,12 +146,27 @@
     :OSubComponent<OConnection, 
OConnection_BASE>((::cppu::OWeakObject*)_pDriver, this)
     ,m_xMetaData(NULL)
     ,m_pDriver(_pDriver)
+    ,m_pImplData( new ConnectionImplData )
     ,m_nMaxResultRecords( -1 )
     ,m_aNameMapper(NULL)
     ,m_eSDBCAddressType(SDBCAddress::Unknown)
 {
        m_pDriver->acquire();
 
+    try
+    {
+        Reference< XPropertySet > xFactoryProps( m_pDriver->getMSFactory(), 
UNO_QUERY_THROW );
+        Reference< XComponentContext > xContext(
+            xFactoryProps->getPropertyValue( ::rtl::OUString( 
RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ),
+            UNO_QUERY_THROW
+        );
+        m_pImplData->pResourceBundle.reset( new 
::comphelper::OfficeResourceBundle( xContext, "cnr" ) );
+    }
+    catch( const Exception& )
+    {
+        OSL_ENSURE( false, "OConnection::OConnection: could not obtain the 
component context!" );
+    }
+
     // Initialise m_aColumnAlias.
     m_aColumnAlias.setAlias(_pDriver->getMSFactory());
 }
@@ -342,7 +371,7 @@
     if ( isLDAP() ) {
         if ( !_aDbHelper.testLDAPConnection( this ) ) {
             OSL_TRACE("testLDAPConnection : FAILED\n" );
-            ::dbtools::throwGenericSQLException( _aDbHelper.getErrorString(), 
NULL);
+            throwGenericSQLException( _aDbHelper.getErrorResourceId() );
         }
         else {
             OSL_TRACE("testLDAPConnection : SUCCESS\n" );
@@ -353,7 +382,7 @@
     ::std::vector< ::rtl::OUString > tables;
     ::std::vector< ::rtl::OUString > types;
     if ( !_aDbHelper.getTableStrings( this, tables, types ) ) {
-        ::dbtools::throwGenericSQLException( _aDbHelper.getErrorString(), 
NULL);
+        throwGenericSQLException( _aDbHelper.getErrorResourceId() );
     }
 
 }
@@ -526,6 +555,8 @@
        // we noticed that we should be destroied in near future so we have to 
dispose our statements
        ::osl::MutexGuard aGuard(m_aMutex);
 
+    m_pImplData->pResourceBundle.reset();
+
        for (OWeakRefArray::iterator i = m_aStatements.begin(); 
m_aStatements.end() != i; ++i)
        {
                Reference< XComponent > xComp(i->get(), UNO_QUERY);
@@ -570,5 +601,22 @@
        return m_aNameMapper;
 }
 // 
-----------------------------------------------------------------------------
+
+void OConnection::throwGenericSQLException( sal_Int32 _nErrorResourceId )
+{
+    ::boost::shared_ptr< ::comphelper::OfficeResourceBundle > pResourceBundle;
+    {
+        ::osl::MutexGuard aGuard( m_aMutex );
+        pResourceBundle = m_pImplData->pResourceBundle;
+    }
+
+    OSL_ENSURE( pResourceBundle.get(), "OConnection::throwGenericSQLException: 
no resource bundle?" );
+        // this means that we're disposed, and how could anybody request us to 
throw an exception then?
+
+    ::rtl::OUString sErrorMessage;
+    if ( pResourceBundle.get() )
+        sErrorMessage = pResourceBundle->loadString( _nErrorResourceId );
+    ::dbtools::throwGenericSQLException( sErrorMessage, *this );
+}
 
 } } // namespace connectivity::mozab




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

Reply via email to