Tag: cws_src680_dba201b
User: fs      
Date: 05/07/20 02:56:55

Modified:
 /dba/dbaccess/source/ui/misc/
  DExport.cxx, HtmlReader.cxx, RtfReader.cxx, TokenWriter.cxx,
  TableCopyHelper.cxx

Log:
 #i51255# XConnection replaced with SharedConnection, and DataSourceHolder 
replaced with SharedModel

File Changes:

Directory: /dba/dbaccess/source/ui/misc/
========================================

File [changed]: DExport.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/misc/DExport.cxx?r1=1.24.94.1&r2=1.24.94.2
Delta lines:  +4 -4
-------------------
--- DExport.cxx 11 Jul 2005 13:37:23 -0000      1.24.94.1
+++ DExport.cxx 20 Jul 2005 09:56:49 -0000      1.24.94.2
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: DExport.cxx,v $
  *
- *  $Revision: 1.24.94.1 $
+ *  $Revision: 1.24.94.2 $
  *
- *  last change: $Author: fs $ $Date: 2005/07/11 13:37:23 $
+ *  last change: $Author: fs $ $Date: 2005/07/20 09:56:49 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -244,7 +244,7 @@
        SetColumnTypes(pList,_pInfoMap);
 }
 //---------------------------------------------------------------------------
-ODatabaseExport::ODatabaseExport(const Reference< XConnection >& _rxConnection,
+ODatabaseExport::ODatabaseExport(const SharedConnection& _rxConnection,
                                                                 const 
Reference< XNumberFormatter >& _rxNumberF,
                                                                 const 
Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
                                                                 const 
TColumnVector* pList,
@@ -656,7 +656,7 @@
        {
                ::rtl::OUString sDestName = 
::dbtools::composeTableName(m_xConnection->getMetaData(),m_xTable,sal_False,::dbtools::eInDataManipulation);
 
-               
xProp->setPropertyValue(PROPERTY_ACTIVECONNECTION,makeAny(m_xConnection));
+               
xProp->setPropertyValue(PROPERTY_ACTIVECONNECTION,makeAny(m_xConnection.getTyped()));
                
xProp->setPropertyValue(PROPERTY_COMMANDTYPE,makeAny(CommandType::TABLE));
                xProp->setPropertyValue(PROPERTY_COMMAND,makeAny(sDestName));
                
xProp->setPropertyValue(PROPERTY_IGNORERESULT,::cppu::bool2any(sal_True));

File [changed]: HtmlReader.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/misc/HtmlReader.cxx?r1=1.18&r2=1.18.146.1
Delta lines:  +4 -4
-------------------
--- HtmlReader.cxx      2 Aug 2004 16:05:00 -0000       1.18
+++ HtmlReader.cxx      20 Jul 2005 09:56:50 -0000      1.18.146.1
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: HtmlReader.cxx,v $
  *
- *  $Revision: 1.18 $
+ *  $Revision: 1.18.146.1 $
  *
- *  last change: $Author: hr $ $Date: 2004/08/02 16:05:00 $
+ *  last change: $Author: fs $ $Date: 2005/07/20 09:56:50 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -217,7 +217,7 @@
 // ==========================================================================
 // OHTMLReader
 // ==========================================================================
-OHTMLReader::OHTMLReader(SvStream& rIn,const Reference< 
::com::sun::star::sdbc::XConnection >& _rxConnection,
+OHTMLReader::OHTMLReader(SvStream& rIn,const SharedConnection& _rxConnection,
                                                const Reference< 
::com::sun::star::util::XNumberFormatter >& _rxNumberF,
                                                const 
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory 
>& _rM,
                                                const TColumnVector* pList,

File [changed]: RtfReader.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/misc/RtfReader.cxx?r1=1.14&r2=1.14.146.1
Delta lines:  +4 -4
-------------------
--- RtfReader.cxx       2 Aug 2004 16:05:51 -0000       1.14
+++ RtfReader.cxx       20 Jul 2005 09:56:51 -0000      1.14.146.1
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: RtfReader.cxx,v $
  *
- *  $Revision: 1.14 $
+ *  $Revision: 1.14.146.1 $
  *
- *  last change: $Author: hr $ $Date: 2004/08/02 16:05:51 $
+ *  last change: $Author: fs $ $Date: 2005/07/20 09:56:51 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -160,7 +160,7 @@
 // ORTFReader
 // ==========================================================================
 ORTFReader::ORTFReader(        SvStream& rIn,
-                                               const Reference< XConnection >& 
_rxConnection,
+                                               const SharedConnection& 
_rxConnection,
                                                const Reference< 
::com::sun::star::util::XNumberFormatter >& _rxNumberF,
                                                const 
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory 
>& _rM,
                                                const TColumnVector* pList,

File [changed]: TokenWriter.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/misc/TokenWriter.cxx?r1=1.25&r2=1.25.22.1
Delta lines:  +81 -81
---------------------
--- TokenWriter.cxx     13 Apr 2005 08:35:45 -0000      1.25
+++ TokenWriter.cxx     20 Jul 2005 09:56:52 -0000      1.25.22.1
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: TokenWriter.cxx,v $
  *
- *  $Revision: 1.25 $
+ *  $Revision: 1.25.22.1 $
  *
- *  last change: $Author: obo $ $Date: 2005/04/13 08:35:45 $
+ *  last change: $Author: fs $ $Date: 2005/07/20 09:56:52 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -82,6 +82,9 @@
 #ifndef _COMPHELPER_TYPES_HXX_
 #include <comphelper/types.hxx>
 #endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
 #ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
 #endif
@@ -97,6 +100,9 @@
 #ifndef _COM_SUN_STAR_SDB_XQUERIESSUPPLIER_HPP_
 #include <com/sun/star/sdb/XQueriesSupplier.hpp>
 #endif
+#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#endif
 #ifndef _COM_SUN_STAR_AWT_FONTWEIGHT_HPP_
 #include <com/sun/star/awt/FontWeight.hpp>
 #endif
@@ -157,6 +163,8 @@
 using namespace ::com::sun::star::lang;
 using namespace ::com::sun::star::sdbcx;
 using namespace ::com::sun::star::awt;
+using namespace ::com::sun::star::util;
+using ::com::sun::star::frame::XModel;
 
 #if defined(MAC)
 const char __FAR_DATA ODatabaseImportExport::sNewLine = '\015';
@@ -184,7 +192,6 @@
        ,m_xFormatter(_rxNumberF)
        ,m_xFactory(_rM)
        ,m_nCommandType(CommandType::TABLE)
-       ,m_bDisposeConnection(sal_False)
        ,m_bInInitialize(sal_False)
        ,m_bCheckOnly(sal_False)
 {
@@ -192,26 +199,7 @@
        DBG_CTOR(ODatabaseImportExport,NULL);
 
        osl_incrementInterlockedCount( &m_refCount );
-       // get the information we need
-       m_sDataSourceName = _aDataDescriptor.getDataSource();
-       _aDataDescriptor[daCommandType] >>= m_nCommandType;
-       _aDataDescriptor[daCommand]             >>= m_sName;
-       // some additonal information
-       if(_aDataDescriptor.has(daConnection))
-               _aDataDescriptor[daConnection]  >>= m_xConnection;
-       if(_aDataDescriptor.has(daSelection))
-               _aDataDescriptor[daSelection]   >>= m_aSelection;
-
-       sal_Bool bBookmarkSelection = sal_True; // the default if not present
-       if ( _aDataDescriptor.has( daBookmarkSelection ) )
-       {
-               _aDataDescriptor[ daBookmarkSelection ] >>= bBookmarkSelection;
-               DBG_ASSERT( !bBookmarkSelection, 
"ODatabaseImportExport::ODatabaseImportExport: bookmarked selection not yet 
supported!" );
-       }
-       
-
-       if(_aDataDescriptor.has(daCursor))
-               _aDataDescriptor[daCursor]      >>= m_xResultSet;
+    impl_initFromDescriptor( _aDataDescriptor, false );
 
        xub_StrLen nCount = rExchange.GetTokenCount(char(11));
        if( nCount > SBA_FORMAT_SELECTION_COUNT && rExchange.GetToken(4).Len())
@@ -223,16 +211,14 @@
 }
 // 
-----------------------------------------------------------------------------
 // import data
-ODatabaseImportExport::ODatabaseImportExport(  const 
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& 
_rxConnection,
-                                               const 
::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& 
_rxNumberF,
-                                               const 
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory 
>& _rM) 
+ODatabaseImportExport::ODatabaseImportExport( const SharedConnection& 
_rxConnection,
+        const Reference< XNumberFormatter >& _rxNumberF, const Reference< 
XMultiServiceFactory >& _rM )
        : m_xConnection(_rxConnection)
        ,m_pReader(NULL)
        ,m_pRowMarker(NULL) 
        ,m_xFormatter(_rxNumberF)
        ,m_xFactory(_rM)
        ,m_nCommandType(::com::sun::star::sdb::CommandType::TABLE)
-       ,m_bDisposeConnection(sal_False)
        ,m_bInInitialize(sal_False)
        ,m_bCheckOnly(sal_False)
 {
@@ -261,18 +247,16 @@
                Reference< XEventListener> 
xEvt((::cppu::OWeakObject*)this,UNO_QUERY);
                xComponent->removeEventListener(xEvt);
        }
-       if(m_bDisposeConnection)
-               ::comphelper::disposeComponent(m_xConnection);
+    m_xConnection.clear();
        
        ::comphelper::disposeComponent(m_xRow);
 
        m_xObject                               = NULL;
-       m_xConnection                   = NULL;
        m_xResultSetMetaData    = NULL;
        m_xResultSet                    = NULL;
        m_xRow                                  = NULL;
 
-       m_aDataSourceHolder.reset();
+    m_aKeepModelAlive.clear();
 }
 // 
-----------------------------------------------------------------------------
 void SAL_CALL ODatabaseImportExport::disposing( const EventObject& Source ) 
throw(::com::sun::star::uno::RuntimeException)
@@ -281,25 +265,32 @@
        Reference<XConnection> xCon(Source.Source,UNO_QUERY);
        if(m_xConnection.is() && m_xConnection == xCon)
        {
-               m_xConnection = NULL;
+               m_xConnection.clear();
                disposing();
                if(!m_bInInitialize)
                        initialize();
-               m_bDisposeConnection = m_xConnection.is();
        }
 }
 // 
-----------------------------------------------------------------------------
-void ODatabaseImportExport::initialize(const ODataAccessDescriptor& 
_aDataDescriptor)
+void ODatabaseImportExport::initialize( const ODataAccessDescriptor& 
_aDataDescriptor )
+{
+    impl_initFromDescriptor( _aDataDescriptor, true );
+}
+
+// 
-----------------------------------------------------------------------------
+void ODatabaseImportExport::impl_initFromDescriptor( const 
ODataAccessDescriptor& _aDataDescriptor, bool _bPlusDefaultInit)
 {
        DBG_CHKTHIS(ODatabaseImportExport,NULL);
-       // get the information we need
        m_sDataSourceName = _aDataDescriptor.getDataSource();
        _aDataDescriptor[daCommandType] >>= m_nCommandType;
        _aDataDescriptor[daCommand]             >>= m_sName;
        // some additonal information
-       if ( _aDataDescriptor.has(daConnection) )
-               _aDataDescriptor[daConnection]  >>= m_xConnection;
-       if ( _aDataDescriptor.has(daSelection) )
+       if(_aDataDescriptor.has(daConnection))
+    {
+        Reference< XConnection > xPureConn( _aDataDescriptor[daConnection], 
UNO_QUERY );
+        m_xConnection = SharedConnection( xPureConn, false /* don't take 
ownership */ );
+    }
+       if(_aDataDescriptor.has(daSelection))
                _aDataDescriptor[daSelection]   >>= m_aSelection;
 
        sal_Bool bBookmarkSelection = sal_True; // the default if not present
@@ -310,9 +301,10 @@
        }
        
 
-       if ( _aDataDescriptor.has(daCursor) )
+       if(_aDataDescriptor.has(daCursor))
                _aDataDescriptor[daCursor]      >>= m_xResultSet;
 
+    if ( _bPlusDefaultInit )
        initialize();
 }
 // 
-----------------------------------------------------------------------------
@@ -328,13 +320,21 @@
 
                try
                {
-                       m_aDataSourceHolder.reset(new 
ODataSourceHolder(Reference< 
com::sun::star::util::XCloseable>(xDatabaseContext->getByName(m_sDataSourceName),UNO_QUERY)));
+            Reference< XDataSource > xDataSource( xDatabaseContext->getByName( 
m_sDataSourceName ), UNO_QUERY_THROW );
+            Reference< XModel > xDocument( getDataSourceOrModel( xDataSource 
), UNO_QUERY_THROW );
+            m_aKeepModelAlive = SharedModel( xDocument );
                }
-               catch(Exception)
+        catch( const Exception& )
                {
+            OSL_ENSURE( sal_False, "ODatabaseImportExport::initialize: could 
not obtaine the document model!" );
                }
+
                Reference< XEventListener> 
xEvt((::cppu::OWeakObject*)this,UNO_QUERY);
-               SQLExceptionInfo aInfo = 
::dbaui::createConnection(m_sDataSourceName,xDatabaseContext,m_xFactory,xEvt,m_xConnection);
+
+        Reference< XConnection > xConnection;
+               SQLExceptionInfo aInfo = ::dbaui::createConnection( 
m_sDataSourceName, xDatabaseContext, m_xFactory, xEvt, xConnection );
+        m_xConnection = SharedConnection( xConnection );
+
                if(aInfo.isValid() && aInfo.getType() == 
SQLExceptionInfo::SQL_EXCEPTION)
                        throw *static_cast<const SQLException*>(aInfo);
        }
@@ -390,7 +390,7 @@
                                Reference<XPropertySet > 
xProp(m_xResultSet,UNO_QUERY);
                                if(xProp.is())
                                {
-                                       
xProp->setPropertyValue(PROPERTY_ACTIVECONNECTION,makeAny(m_xConnection));
+                                       xProp->setPropertyValue( 
PROPERTY_ACTIVECONNECTION, makeAny( m_xConnection.getTyped() ) );
                                        
xProp->setPropertyValue(PROPERTY_COMMANDTYPE,makeAny(m_nCommandType));
                                        
xProp->setPropertyValue(PROPERTY_COMMAND,makeAny(m_sName));
                                        Reference<XRowSet> 
xRowSet(xProp,UNO_QUERY);
@@ -490,7 +490,7 @@
        sal_Int32 nColor = 0;
        if(m_xObject.is())
                m_xObject->getPropertyValue(PROPERTY_TEXTCOLOR) >>= nColor;
-       Color aColor(nColor);
+    ::Color aColor(nColor);
 
        ByteString aFonts(String(m_aFont.Name),eDestEnc);
        if(!aFonts.Len())
@@ -794,7 +794,7 @@
        sal_Int32 nColor = 0;
        if(m_xObject.is())
                m_xObject->getPropertyValue(PROPERTY_TEXTCOLOR) >>= nColor;
-       Color aColor(nColor);
+    ::Color aColor(nColor);
        HTMLOutFuncs::Out_Color( (*m_pStream), aColor );
 
        ::rtl::OString sOut( ' ' );
@@ -1071,7 +1071,7 @@
        sal_Int32 nColor = 0;
        if(m_xObject.is())
                m_xObject->getPropertyValue(PROPERTY_TEXTCOLOR) >>= nColor;
-       Color aColor(nColor);
+    ::Color aColor(nColor);
 
        HTMLOutFuncs::Out_Color( (*m_pStream), aColor );
        (*m_pStream) << ">";

File [changed]: TableCopyHelper.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/misc/TableCopyHelper.cxx?r1=1.2.84.2&r2=1.2.84.3
Delta lines:  +8 -8
-------------------
--- TableCopyHelper.cxx 11 Jul 2005 13:37:23 -0000      1.2.84.2
+++ TableCopyHelper.cxx 20 Jul 2005 09:56:52 -0000      1.2.84.3
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: TableCopyHelper.cxx,v $
  *
- *  $Revision: 1.2.84.2 $
+ *  $Revision: 1.2.84.3 $
  *
- *  last change: $Author: fs $ $Date: 2005/07/11 13:37:23 $
+ *  last change: $Author: fs $ $Date: 2005/07/20 09:56:52 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -511,7 +511,7 @@
 void OTableCopyHelper::pasteTable( SotFormatStringId _nFormatId
                                   ,const TransferableDataHelper& _rTransData 
                                   ,const ::rtl::OUString& _sDestDataSourceName
-                                  ,const Reference<XConnection>& _xConnection)
+                                  ,const SharedConnection& _xConnection)
 {
        if ( _nFormatId == SOT_FORMATSTR_ID_DBACCESS_TABLE || _nFormatId == 
SOT_FORMATSTR_ID_DBACCESS_QUERY )
        {
@@ -550,7 +550,7 @@
 // 
-----------------------------------------------------------------------------
 void OTableCopyHelper::pasteTable( const TransferableDataHelper& _rTransData 
                                   ,const ::rtl::OUString& _sDestDataSourceName
-                                  ,const Reference<XConnection>& _xConnection)
+                                  ,const SharedConnection& _xConnection)
 {
        if ( _rTransData.HasFormat(SOT_FORMATSTR_ID_DBACCESS_TABLE) || 
_rTransData.HasFormat(SOT_FORMATSTR_ID_DBACCESS_QUERY) )
                pasteTable( 
SOT_FORMATSTR_ID_DBACCESS_TABLE,_rTransData,_sDestDataSourceName,_xConnection);
@@ -564,7 +564,7 @@
 // 
-----------------------------------------------------------------------------
 void OTableCopyHelper::pasteTable( ::svx::ODataAccessDescriptor& _rPasteData
                                   ,const ::rtl::OUString& _sDestDataSourceName
-                                  ,const Reference<XConnection>& 
_xDestConnection)
+                                  ,const SharedConnection& _xDestConnection)
 {
        Reference<XConnection> xSrcConnection;
        Reference<XResultSet>   xSrcRs;                 // the source resultset 
may be empty
@@ -798,7 +798,7 @@
        }
 }
 // 
-----------------------------------------------------------------------------
-sal_Bool OTableCopyHelper::copyTagTable(OTableCopyHelper::DropDescriptor& 
_rDesc, sal_Bool _bCheck,const Reference<XConnection>& _xConnection)
+sal_Bool OTableCopyHelper::copyTagTable(OTableCopyHelper::DropDescriptor& 
_rDesc, sal_Bool _bCheck,const SharedConnection& _xConnection)
 {
     Reference<XEventListener> xEvt;
        ODatabaseImportExport* pImport = NULL;
@@ -829,7 +829,7 @@
 // 
-----------------------------------------------------------------------------
 sal_Bool OTableCopyHelper::copyTagTable(const TransferableDataHelper& 
_aDroppedData
                                         ,DropDescriptor& _rAsyncDrop
-                                        ,const Reference<XConnection>& 
_xConnection)
+                                        ,const SharedConnection& _xConnection)
 {
     sal_Bool bRet = sal_False;
     sal_Bool bHtml = _aDroppedData.HasFormat(SOT_FORMATSTR_ID_HTML) || 
_aDroppedData.HasFormat(SOT_FORMATSTR_ID_HTML_SIMPLE);
@@ -863,7 +863,7 @@
 // 
-----------------------------------------------------------------------------
 void OTableCopyHelper::asyncCopyTagTable(  DropDescriptor& _rDesc
                                 ,const ::rtl::OUString& _sDestDataSourceName
-                                ,const ::com::sun::star::uno::Reference< 
::com::sun::star::sdbc::XConnection>& _xConnection)
+                                ,const SharedConnection& _xConnection)
 {
     if ( _rDesc.aHtmlRtfStorage.Is() )
        {




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

Reply via email to