Tag: cws_src680_codecleanup01 User: mt Date: 05/10/07 19:11:44 Modified: /dba/dbaccess/source/ui/misc/ TokenWriter.cxx
Log: RESYNC: (1.25-1.27); FILE MERGED File Changes: Directory: /dba/dbaccess/source/ui/misc/ ======================================== File [changed]: TokenWriter.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/misc/TokenWriter.cxx?r1=1.25.48.1&r2=1.25.48.2 Delta lines: +99 -125 ---------------------- --- TokenWriter.cxx 26 Jul 2005 12:40:54 -0000 1.25.48.1 +++ TokenWriter.cxx 8 Oct 2005 02:11:41 -0000 1.25.48.2 @@ -1,22 +1,20 @@ /************************************************************************* * + * OpenOffice.org - a multi-platform office productivity suite + * * $RCSfile$ * * $Revision$ * * last change: $Author$ $Date$ * - * The Contents of this file are made available subject to the terms of - * either of the following licenses - * - * - GNU Lesser General Public License Version 2.1 - * - Sun Industry Standards Source License Version 1.1 + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. * - * Sun Microsystems Inc., October, 2000 * * GNU Lesser General Public License Version 2.1 * ============================================= - * Copyright 2000 by Sun Microsystems, Inc. + * Copyright 2005 by Sun Microsystems, Inc. * 901 San Antonio Road, Palo Alto, CA 94303, USA * * This library is free software; you can redistribute it and/or @@ -33,30 +31,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * - * - * Sun Industry Standards Source License Version 1.1 - * ================================================= - * The contents of this file are subject to the Sun Industry Standards - * Source License Version 1.1 (the License); You may not use this file - * except in compliance with the License. You may obtain a copy of the - * License at http://www.openoffice.org/license.html. - * - * Software provided under this License is provided on an AS IS basis, - * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, - * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, - * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. - * See the License for the specific provisions governing your rights and - * obligations concerning the Software. - * - * The Initial Developer of the Original Code is: Sun Microsystems, Inc. - * - * Copyright: 2000 by Sun Microsystems, Inc. - * - * All Rights Reserved. - * - * Contributor(s): _______________________________________ - * - * ************************************************************************/ #ifndef DBAUI_TOKENWRITER_HXX #include "TokenWriter.hxx" @@ -82,6 +56,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 +74,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 +137,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(UNX) const char __FAR_DATA ODatabaseImportExport::sNewLine = '\012'; @@ -182,7 +164,6 @@ ,m_xFormatter(_rxNumberF) ,m_xFactory(_rM) ,m_nCommandType(CommandType::TABLE) - ,m_bDisposeConnection(sal_False) ,m_bInInitialize(sal_False) ,m_bCheckOnly(sal_False) { @@ -190,26 +171,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()) @@ -221,16 +183,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 ::dbtools::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) { @@ -259,18 +219,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) @@ -279,25 +237,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.reset( xPureConn, SharedConnection::NoTakeOwnership ); + } + if(_aDataDescriptor.has(daSelection)) _aDataDescriptor[daSelection] >>= m_aSelection; sal_Bool bBookmarkSelection = sal_True; // the default if not present @@ -308,9 +273,10 @@ } - if ( _aDataDescriptor.has(daCursor) ) + if(_aDataDescriptor.has(daCursor)) _aDataDescriptor[daCursor] >>= m_xResultSet; + if ( _bPlusDefaultInit ) initialize(); } // ----------------------------------------------------------------------------- @@ -326,13 +292,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.reset( xConnection ); + if(aInfo.isValid() && aInfo.getType() == SQLExceptionInfo::SQL_EXCEPTION) throw *static_cast<const SQLException*>(aInfo); } @@ -388,7 +362,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); @@ -483,7 +457,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()) @@ -787,7 +761,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( ' ' ); @@ -1064,7 +1038,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) << ">"; --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
