summaryrefslogtreecommitdiffstats
path: root/dbaccess/source/ui
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@sun.com>2010-01-11 12:15:28 +0100
committerFrank Schoenheit [fs] <frank.schoenheit@sun.com>2010-01-11 12:15:28 +0100
commit0e793ea5d3e758ed431065b675a79c17a9f15ef7 (patch)
tree7038bd404feff100f3e5e5ab955046f462fd3e66 /dbaccess/source/ui
parentdba33e: svx split (diff)
downloadcore-0e793ea5d3e758ed431065b675a79c17a9f15ef7.tar.gz
core-0e793ea5d3e758ed431065b675a79c17a9f15ef7.zip
dba33f: #i108038# (re-)add Selection support to the Copy Table Wizard
Diffstat (limited to 'dbaccess/source/ui')
-rw-r--r--dbaccess/source/ui/browser/dbexchange.cxx222
-rw-r--r--dbaccess/source/ui/browser/sbagrid.cxx25
-rw-r--r--dbaccess/source/ui/inc/TableCopyHelper.hxx31
-rw-r--r--dbaccess/source/ui/inc/TokenWriter.hxx50
-rw-r--r--dbaccess/source/ui/inc/dbexchange.hxx23
-rw-r--r--dbaccess/source/ui/misc/TableCopyHelper.cxx122
-rw-r--r--dbaccess/source/ui/misc/TokenWriter.cxx87
-rw-r--r--dbaccess/source/ui/uno/copytablewizard.cxx183
8 files changed, 350 insertions, 393 deletions
diff --git a/dbaccess/source/ui/browser/dbexchange.cxx b/dbaccess/source/ui/browser/dbexchange.cxx
index 70caccc10a3e..0aa4074806ec 100644
--- a/dbaccess/source/ui/browser/dbexchange.cxx
+++ b/dbaccess/source/ui/browser/dbexchange.cxx
@@ -31,36 +31,16 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_dbaccess.hxx"
-#ifndef DBAUI_DBEXCHANGE_HXX
#include "dbexchange.hxx"
-#endif
-#ifndef _SOT_FORMATS_HXX
#include <sot/formats.hxx>
-#endif
-#ifndef _SOT_STORAGE_HXX
#include <sot/storage.hxx>
-#endif
-#ifndef _OSL_DIAGNOSE_H_
#include <osl/diagnose.h>
-#endif
-#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
#include <com/sun/star/sdb/CommandType.hpp>
-#endif
-#ifndef DBAUI_TOKENWRITER_HXX
+#include <com/sun/star/sdb/XResultSetAccess.hpp>
#include "TokenWriter.hxx"
-#endif
-#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
#include "dbustrings.hrc"
-#endif
-//#ifndef _COMPHELPER_EXTRACT_HXX_
-//#include <comphelper/extract.hxx>
-//#endif
-#ifndef _COMPHELPER_UNO3_HXX_
#include <comphelper/uno3.hxx>
-#endif
-#ifndef _SVX_DATACCESSDESCRIPTOR_HXX_
#include <svx/dataaccessdescriptor.hxx>
-#endif
#include "UITools.hxx"
@@ -78,23 +58,17 @@ namespace dbaui
namespace
{
- template<class T > void lcl_addListener(const Reference<T>& _xComponent,ODataClipboard* _pListener)
+ template<class T > void lcl_setListener(const Reference<T>& _xComponent, const Reference< XEventListener >& i_rListener, const bool i_bAdd )
{
- if ( _xComponent.is() )
- {
- Reference< XComponent> xCom(_xComponent,UNO_QUERY);
- if ( xCom.is() )
- xCom->addEventListener(Reference< XEventListener>((::cppu::OWeakObject*)_pListener,UNO_QUERY));
- }
- }
- template<class T > void lcl_removeListener(const Reference<T>& _xComponent,ODataClipboard* _pListener)
- {
- if ( _xComponent.is() )
- {
- Reference< XComponent> xCom(_xComponent,UNO_QUERY);
- if ( xCom.is() )
- xCom->removeEventListener(Reference< XEventListener>((::cppu::OWeakObject*)_pListener,UNO_QUERY));
- }
+ if ( !_xComponent.is() )
+ return;
+
+ Reference< XComponent> xCom( _xComponent, UNO_QUERY );
+ OSL_ENSURE( xCom.is(), "lcl_setListener: no component!" );
+ if ( !xCom.is() )
+ return;
+
+ i_bAdd ? xCom->addEventListener( i_rListener ) : xCom->removeEventListener( i_rListener );
}
}
@@ -111,13 +85,11 @@ namespace dbaui
,m_pRtf(NULL)
{
osl_incrementInterlockedCount( &m_refCount );
- lcl_addListener(_rxConnection,this);
+ lcl_setListener( _rxConnection, this, true );
- m_pHtml = new OHTMLImportExport(getDescriptor(), _rxORB, _rxFormatter);
- m_aEventListeners.push_back(m_pHtml);
+ m_pHtml.set( new OHTMLImportExport( getDescriptor(), _rxORB, _rxFormatter ) );
+ m_pRtf.set( new ORTFImportExport( getDescriptor(), _rxORB, _rxFormatter ) );
- m_pRtf = new ORTFImportExport(getDescriptor(), _rxORB, _rxFormatter);
- m_aEventListeners.push_back(m_pRtf);
osl_decrementInterlockedCount( &m_refCount );
}
@@ -132,47 +104,50 @@ namespace dbaui
,m_pHtml(NULL)
,m_pRtf(NULL)
{
- m_pHtml = new OHTMLImportExport(getDescriptor(),_rxORB, _rxFormatter);
- m_aEventListeners.push_back(m_pHtml);
-
- m_pRtf = new ORTFImportExport(getDescriptor(),_rxORB, _rxFormatter);
- m_aEventListeners.push_back(m_pRtf);
+ m_pHtml.set( new OHTMLImportExport( getDescriptor(),_rxORB, _rxFormatter ) );
+ m_pRtf.set( new ORTFImportExport( getDescriptor(),_rxORB, _rxFormatter ) );
}
// -----------------------------------------------------------------------------
- ODataClipboard::ODataClipboard( const Reference< XPropertySet >& _rxLivingForm,
- const Sequence< Any >& _rSelectedRows,
- const Reference< XResultSet>& _rxResultSet,
- const Reference< XMultiServiceFactory >& _rxORB)
- :ODataAccessObjectTransferable( _rxLivingForm )
+ ODataClipboard::ODataClipboard( const Reference< XPropertySet >& i_rAliveForm,
+ const Sequence< Any >& i_rSelectedRows,
+ const sal_Bool i_bBookmarkSelection,
+ const Reference< XMultiServiceFactory >& i_rORB )
+ :ODataAccessObjectTransferable( i_rAliveForm )
,m_pHtml(NULL)
,m_pRtf(NULL)
{
+ OSL_PRECOND( i_rORB.is(), "ODataClipboard::ODataClipboard: having no factory is not good ..." );
+
osl_incrementInterlockedCount( &m_refCount );
Reference<XConnection> xConnection;
- getDescriptor()[daConnection] >>= xConnection;
- lcl_addListener(xConnection,this);
- lcl_addListener(_rxResultSet,this);
-
- getDescriptor()[daSelection] <<= _rSelectedRows;
- getDescriptor()[daBookmarkSelection]<<= sal_False; // by definition, it's the indicies
- getDescriptor()[daCursor] <<= _rxResultSet;
- addCompatibleSelectionDescription( _rSelectedRows );
-
- if ( xConnection.is() && _rxORB.is() )
- {
- Reference< XNumberFormatter > xFormatter( getNumberFormatter( xConnection, _rxORB ) );
- if ( xFormatter.is() )
- {
- m_pHtml = new OHTMLImportExport( getDescriptor(),_rxORB, xFormatter );
- m_aEventListeners.push_back( m_pHtml );
-
- m_pRtf = new ORTFImportExport( getDescriptor(),_rxORB, xFormatter );
- m_aEventListeners.push_back( m_pRtf );
- }
- }
+ getDescriptor()[ daConnection ] >>= xConnection;
+ lcl_setListener( xConnection, this, true );
+
+ // do not pass the form itself as source result set, since the client might operate on the form, which
+ // might lead to undesired effects. Instead, use a clone.
+ Reference< XResultSet > xResultSetClone;
+ Reference< XResultSetAccess > xResultSetAccess( i_rAliveForm, UNO_QUERY );
+ if ( xResultSetAccess.is() )
+ xResultSetClone = xResultSetAccess->createResultSet();
+ OSL_ENSURE( xResultSetClone.is(), "ODataClipboard::ODataClipboard: could not clone the form's result set" );
+ lcl_setListener( xResultSetClone, this, true );
+ getDescriptor()[daCursor] <<= xResultSetClone;
+ getDescriptor()[daSelection] <<= i_rSelectedRows;
+ getDescriptor()[daBookmarkSelection]<<= i_bBookmarkSelection;
+ addCompatibleSelectionDescription( i_rSelectedRows );
+
+ if ( xConnection.is() && i_rORB.is() )
+ {
+ Reference< XNumberFormatter > xFormatter( getNumberFormatter( xConnection, i_rORB ) );
+ if ( xFormatter.is() )
+ {
+ m_pHtml.set( new OHTMLImportExport( getDescriptor(), i_rORB, xFormatter ) );
+ m_pRtf.set( new ORTFImportExport( getDescriptor(), i_rORB, xFormatter ) );
+ }
+ }
osl_decrementInterlockedCount( &m_refCount );
}
@@ -195,13 +170,11 @@ namespace dbaui
// -----------------------------------------------------------------------------
void ODataClipboard::AddSupportedFormats()
{
- // RTF?
- if (m_pRtf)
- AddFormat(SOT_FORMAT_RTF);
+ if ( m_pRtf.is() )
+ AddFormat( SOT_FORMAT_RTF );
- // HTML?
- if (m_pHtml)
- AddFormat(SOT_FORMATSTR_ID_HTML);
+ if ( m_pHtml.is() )
+ AddFormat( SOT_FORMATSTR_ID_HTML );
ODataAccessObjectTransferable::AddSupportedFormats();
}
@@ -213,13 +186,14 @@ namespace dbaui
switch (nFormat)
{
case SOT_FORMAT_RTF:
- if ( m_pRtf )
+ if ( m_pRtf.is() )
m_pRtf->initialize(getDescriptor());
- return m_pRtf && SetObject(m_pRtf, SOT_FORMAT_RTF, rFlavor);
+ return m_pRtf.is() && SetObject( m_pRtf.get(), SOT_FORMAT_RTF, rFlavor );
+
case SOT_FORMATSTR_ID_HTML:
- if ( m_pHtml )
+ if ( m_pHtml.is() )
m_pHtml->initialize(getDescriptor());
- return m_pHtml && SetObject(m_pHtml, SOT_FORMATSTR_ID_HTML, rFlavor);
+ return m_pHtml.is() && SetObject( m_pHtml.get(), SOT_FORMATSTR_ID_HTML, rFlavor );
}
return ODataAccessObjectTransferable::GetData( rFlavor );
@@ -228,59 +202,65 @@ namespace dbaui
// -----------------------------------------------------------------------------
void ODataClipboard::ObjectReleased()
{
- if ( m_pHtml )
+ if ( m_pHtml.is() )
{
m_pHtml->dispose();
- m_pHtml = NULL;
- } // if ( m_pHtml )
- if ( m_pRtf )
+ m_pHtml.clear();
+ }
+
+ if ( m_pRtf.is() )
{
m_pRtf->dispose();
- m_pRtf = NULL;
+ m_pRtf.clear();
+ }
+
+ if ( getDescriptor().has( daConnection ) )
+ {
+ Reference<XConnection> xConnection( getDescriptor()[daConnection], UNO_QUERY );
+ lcl_setListener( xConnection, this, false );
+ }
+
+ if ( getDescriptor().has( daCursor ) )
+ {
+ Reference< XResultSet > xResultSet( getDescriptor()[ daCursor ], UNO_QUERY );
+ lcl_setListener( xResultSet, this, false );
}
- m_aEventListeners.clear();
- Reference<XConnection> xConnection;
- Reference<XResultSet> xProp;
- if ( getDescriptor().has(daConnection) && (getDescriptor()[daConnection] >>= xConnection) )
- lcl_removeListener(xConnection,this);
- if ( getDescriptor().has(daCursor) && (getDescriptor()[daCursor] >>= xProp) )
- lcl_removeListener(xProp,this);
ODataAccessObjectTransferable::ObjectReleased( );
}
+
// -----------------------------------------------------------------------------
- void SAL_CALL ODataClipboard::disposing( const ::com::sun::star::lang::EventObject& ) throw (::com::sun::star::uno::RuntimeException)
+ void SAL_CALL ODataClipboard::disposing( const ::com::sun::star::lang::EventObject& i_rSource ) throw (::com::sun::star::uno::RuntimeException)
{
- Reference<XConnection> xConnection;
- Reference<XResultSet> xProp;
- if ( getDescriptor().has(daConnection) && (getDescriptor()[daConnection] >>= xConnection) )
- {
- lcl_removeListener(xConnection,this);
- getDescriptor().erase(daConnection);
- } // if ( getDescriptor().has(daConnection) && (getDescriptor()[daConnection] >>= xConnection) )
- if ( getDescriptor().has(daCursor) && (getDescriptor()[daCursor] >>= xProp) )
- {
- lcl_removeListener(xProp,this);
- getDescriptor().erase(daCursor);
- } // if ( getDescriptor().has(daCursor) && (getDescriptor()[daCursor] >>= xProp) )
-
- if ( getDescriptor().has(daColumnObject) )
- getDescriptor().erase(daColumnObject);
+ ODataAccessDescriptor& rDescriptor( getDescriptor() );
- if ( getDescriptor().has(daComponent) )
- getDescriptor().erase(daComponent);
+ if ( rDescriptor.has( daConnection ) )
+ {
+ Reference< XConnection > xConnection( rDescriptor[daConnection], UNO_QUERY );
+ if ( xConnection == i_rSource.Source )
+ {
+ rDescriptor.erase( daConnection );
+ }
+ }
+ if ( rDescriptor.has( daCursor ) )
+ {
+ Reference< XResultSet > xResultSet( rDescriptor[ daCursor ], UNO_QUERY );
+ if ( xResultSet == i_rSource.Source )
+ {
+ rDescriptor.erase( daCursor );
+ // Selection and BookmarkSelection are meaningless without a result set
+ if ( rDescriptor.has( daSelection ) )
+ rDescriptor.erase( daSelection );
+ if ( rDescriptor.has( daBookmarkSelection ) )
+ rDescriptor.erase( daBookmarkSelection );
+ }
+ }
+ // no matter whether it was the source connection or the source result set which died,
+ // we cannot provide the data anymore.
ClearFormats();
- //getDescriptor().clear();
- AddSupportedFormats();
-
- /*m_pHtml = NULL;
- m_pRtf = NULL;
- m_aEventListeners.clear();*/
}
- // -----------------------------------------------------------------------------
- IMPLEMENT_FORWARD_XINTERFACE2( ODataClipboard, ODataAccessObjectTransferable, TDataClipboard_BASE )
}
diff --git a/dbaccess/source/ui/browser/sbagrid.cxx b/dbaccess/source/ui/browser/sbagrid.cxx
index 46f6c576c022..c3da97bfae7a 100644
--- a/dbaccess/source/ui/browser/sbagrid.cxx
+++ b/dbaccess/source/ui/browser/sbagrid.cxx
@@ -1443,39 +1443,30 @@ void SbaGridControl::DoRowDrag( sal_Int16 nRowPos )
// -----------------------------------------------------------------------
void SbaGridControl::implTransferSelectedRows( sal_Int16 nRowPos, bool _bTrueIfClipboardFalseIfDrag )
{
- Reference< XPropertySet > xDataSource(getDataSource(), UNO_QUERY);
- DBG_ASSERT(xDataSource.is(), "SbaGridControl::implTransferSelectedRows : invalid data source !");
+ Reference< XPropertySet > xForm( getDataSource(), UNO_QUERY );
+ DBG_ASSERT( xForm.is(), "SbaGridControl::implTransferSelectedRows: invalid form!" );
// build the sequence of numbers of selected rows
Sequence< Any > aSelectedRows;
+ sal_Bool bSelectionBookmarks = sal_True;
// collect the affected rows
if ((GetSelectRowCount() == 0) && (nRowPos >= 0))
{
- aSelectedRows.realloc(1);
+ aSelectedRows.realloc( 1 );
aSelectedRows[0] <<= (sal_Int32)(nRowPos + 1);
+ bSelectionBookmarks = sal_False;
}
else if ( !IsAllSelected() && GetSelectRowCount() )
{
- aSelectedRows.realloc(GetSelectRowCount());
- Any* pSelectedRows = aSelectedRows.getArray();
-
- for (long nIdx = FirstSelectedRow();
- nIdx >= 0;
- nIdx = NextSelectedRow(), ++pSelectedRows)
- {
- (*pSelectedRows) <<= (sal_Int32)(nIdx + 1);
- }
+ aSelectedRows = getSelectionBookmarks();
+ bSelectionBookmarks = sal_True;
}
Reference< XResultSet> xRowSetClone;
try
{
- Reference< XResultSetAccess > xResultSetAccess(xDataSource,UNO_QUERY);
- if ( xResultSetAccess.is() )
- xRowSetClone = xResultSetAccess->createResultSet();
-
- ODataClipboard* pTransfer = new ODataClipboard(xDataSource, aSelectedRows,xRowSetClone, getServiceManager());
+ ODataClipboard* pTransfer = new ODataClipboard( xForm, aSelectedRows, bSelectionBookmarks, getServiceManager() );
Reference< XTransferable > xEnsureDelete = pTransfer;
if ( _bTrueIfClipboardFalseIfDrag )
diff --git a/dbaccess/source/ui/inc/TableCopyHelper.hxx b/dbaccess/source/ui/inc/TableCopyHelper.hxx
index c0b5e77cc403..6261286b6d06 100644
--- a/dbaccess/source/ui/inc/TableCopyHelper.hxx
+++ b/dbaccess/source/ui/inc/TableCopyHelper.hxx
@@ -194,30 +194,17 @@ namespace dbaui
);
/** insert a table into the data source. The source can eihter be a table or a query
- @param _nCommandType
- The command type.
- @param _xSrcConnection
- The connection of the source.
- @param _aSelection
- The selection of the rows to copy.
- @param _bBookmarkSelection
- If <TRUE/> the selection is bookmark selection.
- @param _sCommand
- The name of the query or table.
- @param _sSrcDataSourceName
- The name of the source data source.
- @param _sDestDataSourceName
- The name of the dest data source.
*/
void insertTable(
- sal_Int32 _nCommandType,
- const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xSrcConnection,
- const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& _aSelection,
- sal_Bool _bBookmarkSelection,
- const ::rtl::OUString& _sCommand,
- const ::rtl::OUString& _sSrcDataSourceName,
- const ::rtl::OUString& _sDestDataSourceName,
- const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xDestConnection
+ const ::rtl::OUString& i_rSourceDataSource,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& i_rSourceConnection,
+ const ::rtl::OUString& i_rCommand,
+ const sal_Int32 i_nCommandType,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >& i_rSourceRows,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& i_rSelection,
+ const sal_Bool i_bBookmarkSelection,
+ const ::rtl::OUString& i_rDestDataSource,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& i_rDestConnection
);
};
diff --git a/dbaccess/source/ui/inc/TokenWriter.hxx b/dbaccess/source/ui/inc/TokenWriter.hxx
index 27a103e1af8a..90bbb4c37862 100644
--- a/dbaccess/source/ui/inc/TokenWriter.hxx
+++ b/dbaccess/source/ui/inc/TokenWriter.hxx
@@ -30,51 +30,25 @@
#ifndef DBAUI_TOKENWRITER_HXX
#define DBAUI_TOKENWRITER_HXX
-#ifndef DBAUI_DATABASEEXPORT_HXX
#include "DExport.hxx"
-#endif
-#ifndef _DBAUI_MODULE_DBU_HXX_
#include "moduledbu.hxx"
-#endif
-#ifndef _STREAM_HXX //autogen
-#include <tools/stream.hxx>
-#endif
-#ifndef _COM_SUN_STAR_AWT_FONTDESCRIPTOR_HPP_
+#include "commontypes.hxx"
+
#include <com/sun/star/awt/FontDescriptor.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_
#include <com/sun/star/sdbc/XResultSet.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBC_XRESULTSETUPDATE_HPP_
#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
#include <com/sun/star/sdbc/XRow.hpp>
-#endif
-#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#endif
-#ifndef _COM_SUN_STAR_LANG_XEVENTLISTENER_HPP_
#include <com/sun/star/lang/XEventListener.hpp>
-#endif
-#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
#include <com/sun/star/frame/XModel.hpp>
-#endif
-#ifndef _CPPUHELPER_IMPLBASE1_HXX_
-#include <cppuhelper/implbase1.hxx>
-#endif
-#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
#include <com/sun/star/beans/PropertyValue.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
#include <com/sun/star/sdb/CommandType.hpp>
-#endif
-#ifndef _SVX_DATACCESSDESCRIPTOR_HXX_
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+
+#include <cppuhelper/implbase1.hxx>
+#include <tools/stream.hxx>
#include <svx/dataaccessdescriptor.hxx>
-#endif
-#ifndef _DBAUI_COMMON_TYPES_HXX_
-#include "commontypes.hxx"
-#endif
+
#include <memory>
namespace com { namespace sun { namespace star {
@@ -98,13 +72,15 @@ namespace dbaui
protected:
::com::sun::star::lang::Locale m_aLocale;
::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any> m_aSelection;
+ sal_Bool m_bBookmarkSelection;
SvStream* m_pStream;
::com::sun::star::awt::FontDescriptor m_aFont;
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xObject; // table/query
- SharedConnection m_xConnection; //
- ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > m_xResultSet; //
- ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow > m_xRow; //
- ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > m_xResultSetMetaData; //
+ SharedConnection m_xConnection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > m_xResultSet;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow > m_xRow;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XRowLocate > m_xRowLocate;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > m_xResultSetMetaData;
::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > m_xRowSetColumns;
::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > m_xFormatter; // a number formatter working with the connection's NumberFormatsSupplier
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> m_xFactory;
diff --git a/dbaccess/source/ui/inc/dbexchange.hxx b/dbaccess/source/ui/inc/dbexchange.hxx
index 6627e3b2af1d..ea2fc3494221 100644
--- a/dbaccess/source/ui/inc/dbexchange.hxx
+++ b/dbaccess/source/ui/inc/dbexchange.hxx
@@ -56,20 +56,19 @@
#endif
#include <vector>
+#include <rtl/ref.hxx>
+
namespace dbaui
{
class ORTFImportExport;
class OHTMLImportExport;
- typedef ::cppu::ImplHelper1< ::com::sun::star::lang::XEventListener > TDataClipboard_BASE;
- class ODataClipboard : public ::svx::ODataAccessObjectTransferable
- , public TDataClipboard_BASE
+ class ODataClipboard : public ::svx::ODataAccessObjectTransferable
{
- ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener> > m_aEventListeners;
- OHTMLImportExport* m_pHtml;
- ORTFImportExport* m_pRtf;
+ ::rtl::Reference< OHTMLImportExport > m_pHtml;
+ ::rtl::Reference< ORTFImportExport > m_pRtf;
public:
ODataClipboard(
@@ -90,15 +89,15 @@ namespace dbaui
);
ODataClipboard(
- const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxLivingForm,
- const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& _rSelectedRows,
- const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _rxResultSet,
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& i_rAliveForm,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& i_rSelectedRows,
+ const sal_Bool i_bBookmarkSelection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_rORB
);
- DECLARE_XINTERFACE( )
-
+ // XEventListener
virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+
protected:
virtual void AddSupportedFormats();
virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
diff --git a/dbaccess/source/ui/misc/TableCopyHelper.cxx b/dbaccess/source/ui/misc/TableCopyHelper.cxx
index 4b1258677037..f0ac851b58b7 100644
--- a/dbaccess/source/ui/misc/TableCopyHelper.cxx
+++ b/dbaccess/source/ui/misc/TableCopyHelper.cxx
@@ -163,21 +163,15 @@ using namespace ::com::sun::star::ucb;
OTableCopyHelper::OTableCopyHelper(OGenericUnoController* _pControler)
:m_pController(_pControler)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OTableCopyHelper::OTableCopyHelper" );
}
// -----------------------------------------------------------------------------
-void OTableCopyHelper::insertTable(sal_Int32 _nCommandType
- ,const Reference<XConnection>& _xSrcConnection
- ,const Sequence< Any >& _aSelection
- ,sal_Bool _bBookmarkSelection
- ,const ::rtl::OUString& _sCommand
- ,const ::rtl::OUString& _sSrcDataSourceName
- ,const ::rtl::OUString& _sDestDataSourceName
- ,const Reference<XConnection>& _xDestConnection)
+void OTableCopyHelper::insertTable( const ::rtl::OUString& i_rSourceDataSource, const Reference<XConnection>& i_rSourceConnection,
+ const ::rtl::OUString& i_rCommand, const sal_Int32 i_nCommandType,
+ const Reference< XResultSet >& i_rSourceRows, const Sequence< Any >& i_rSelection, const sal_Bool i_bBookmarkSelection,
+ const ::rtl::OUString& i_rDestDataSource, const Reference<XConnection>& i_rDestConnection)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OTableCopyHelper::insertTable" );
- if ( CommandType::QUERY != _nCommandType && CommandType::TABLE != _nCommandType )
+ if ( CommandType::QUERY != i_nCommandType && CommandType::TABLE != i_nCommandType )
{
DBG_ERROR( "OTableCopyHelper::insertTable: invalid call (no supported format found)!" );
return;
@@ -185,11 +179,11 @@ void OTableCopyHelper::insertTable(sal_Int32 _nCommandType
try
{
- Reference<XConnection> xSrcConnection( _xSrcConnection );
- if ( _sSrcDataSourceName == _sDestDataSourceName )
- xSrcConnection = _xDestConnection;
+ Reference<XConnection> xSrcConnection( i_rSourceConnection );
+ if ( i_rSourceDataSource == i_rDestDataSource )
+ xSrcConnection = i_rDestConnection;
- if ( !xSrcConnection.is() || !_xDestConnection.is() )
+ if ( !xSrcConnection.is() || !i_rDestConnection.is() )
{
OSL_ENSURE( false, "OTableCopyHelper::insertTable: no connection/s!" );
return;
@@ -200,14 +194,15 @@ void OTableCopyHelper::insertTable(sal_Int32 _nCommandType
Reference< XDataAccessDescriptorFactory > xFactory( DataAccessDescriptorFactory::get( aContext.getUNOContext() ) );
Reference< XPropertySet > xSource( xFactory->createDataAccessDescriptor(), UNO_SET_THROW );
- xSource->setPropertyValue( PROPERTY_COMMAND_TYPE, makeAny( _nCommandType ) );
- xSource->setPropertyValue( PROPERTY_COMMAND, makeAny( _sCommand ) );
+ xSource->setPropertyValue( PROPERTY_COMMAND_TYPE, makeAny( i_nCommandType ) );
+ xSource->setPropertyValue( PROPERTY_COMMAND, makeAny( i_rCommand ) );
xSource->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( xSrcConnection ) );
- xSource->setPropertyValue( PROPERTY_SELECTION, makeAny( _aSelection ) );
- xSource->setPropertyValue( PROPERTY_BOOKMARK_SELECTION, makeAny( _bBookmarkSelection ) );
+ xSource->setPropertyValue( PROPERTY_RESULT_SET, makeAny( i_rSourceRows ) );
+ xSource->setPropertyValue( PROPERTY_SELECTION, makeAny( i_rSelection ) );
+ xSource->setPropertyValue( PROPERTY_BOOKMARK_SELECTION, makeAny( i_bBookmarkSelection ) );
Reference< XPropertySet > xDest( xFactory->createDataAccessDescriptor(), UNO_SET_THROW );
- xDest->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( _xDestConnection ) );
+ xDest->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( i_rDestConnection ) );
Reference< XCopyTableWizard > xWizard( CopyTableWizard::create( aContext.getUNOContext(), xSource, xDest ), UNO_SET_THROW );
@@ -230,72 +225,62 @@ void OTableCopyHelper::insertTable(sal_Int32 _nCommandType
}
// -----------------------------------------------------------------------------
-void OTableCopyHelper::pasteTable( const ::svx::ODataAccessDescriptor& _rPasteData, const ::rtl::OUString& _sDestDataSourceName,
- const SharedConnection& _xDestConnection )
+void OTableCopyHelper::pasteTable( const ::svx::ODataAccessDescriptor& _rPasteData, const ::rtl::OUString& i_rDestDataSourceName,
+ const SharedConnection& i_rDestConnection )
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OTableCopyHelper::pasteTable" );
- Reference<XConnection> xSrcConnection;
- ::rtl::OUString sCommand,
- sSrcDataSourceName = _rPasteData.getDataSource();
+ ::rtl::OUString sSrcDataSourceName = _rPasteData.getDataSource();
+
+ ::rtl::OUString sCommand;
+ _rPasteData[ daCommand ] >>= sCommand;
- _rPasteData[daCommand] >>= sCommand;
+ Reference<XConnection> xSrcConnection;
if ( _rPasteData.has(daConnection) )
- _rPasteData[daConnection] >>= xSrcConnection;
-#if OSL_DEBUG_LEVEL > 0
+ {
+ OSL_VERIFY( _rPasteData[daConnection] >>= xSrcConnection );
+ }
+
+ Reference< XResultSet > xResultSet;
if ( _rPasteData.has(daCursor) )
{
- Reference< XResultSet > xSrcRs;
- _rPasteData[daCursor] >>= xSrcRs;
- OSL_ENSURE( !xSrcRs.is(), "OTableCopyHelper::pasteTable: source result set not supported anymore!" );
- // There was a time where we supported passing a result set as shortcut to the source
- // object. That is, we do not need to create an own result set we already have one.
- // Since we UNOized the Copy Table Wizard (#i81658#), we removed this support, since it
- // contradicted the semantics of DataAccessDescriptor.ResultSet.
- //
- // This shouldn't be a problem, since there seems to be no client which actually
- // passed a result set here.
- // However, if there still is, we probably need to introduce an (undocumented?) property
- // at the DataAccessDescriptor, which takes this "source result set".
+ OSL_VERIFY( _rPasteData[ daCursor ] >>= xResultSet );
}
- if ( _rPasteData.has( daSelection ) || _rPasteData.has( daBookmarkSelection ) )
+ Sequence< Any > aSelection;
+ if ( _rPasteData.has( daSelection ) )
{
- OSL_ENSURE( false, "OTableCopyHelper::pasteTable: bookmark/selection not supported anymore!" );
- // similar notes here: Selection and BookmarkSelection are not supported in the UNOized
- // copy table wizard anymore (it doesn't make sense without support for a source result set),
- // and there seem to be no clients which actually use it. So, instead of implementing an
- // unused case, we dropped this here.
+ OSL_VERIFY( _rPasteData[ daSelection ] >>= aSelection );
+ OSL_ENSURE( _rPasteData.has( daBookmarkSelection ), "OTableCopyHelper::pasteTable: you should specify BookmarkSelection, too, to be on the safe side!" );
}
-#endif
- // paste into the tables
+
+ sal_Bool bBookmarkSelection( sal_True );
+ if ( _rPasteData.has( daBookmarkSelection ) )
+ {
+ OSL_VERIFY( _rPasteData[ daBookmarkSelection ] >>= bBookmarkSelection );
+ }
+ OSL_ENSURE( bBookmarkSelection, "OTableCopyHelper::pasteTable: working with selection-indicies (instead of bookmarks) is error-prone, and thus deprecated!" );
+
sal_Int32 nCommandType = CommandType::COMMAND;
if ( _rPasteData.has(daCommandType) )
_rPasteData[daCommandType] >>= nCommandType;
- insertTable( nCommandType
- ,xSrcConnection
- ,Sequence< Any >()
- ,sal_False
- ,sCommand
- ,sSrcDataSourceName
- ,_sDestDataSourceName
- ,_xDestConnection);
+ insertTable( sSrcDataSourceName, xSrcConnection, sCommand, nCommandType,
+ xResultSet, aSelection, bBookmarkSelection,
+ i_rDestDataSourceName, i_rDestConnection );
}
// -----------------------------------------------------------------------------
void OTableCopyHelper::pasteTable( SotFormatStringId _nFormatId
,const TransferableDataHelper& _rTransData
- ,const ::rtl::OUString& _sDestDataSourceName
+ ,const ::rtl::OUString& i_rDestDataSource
,const SharedConnection& _xConnection)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OTableCopyHelper::pasteTable" );
if ( _nFormatId == SOT_FORMATSTR_ID_DBACCESS_TABLE || _nFormatId == SOT_FORMATSTR_ID_DBACCESS_QUERY )
{
if ( ODataAccessObjectTransferable::canExtractObjectDescriptor(_rTransData.GetDataFlavorExVector()) )
{
::svx::ODataAccessDescriptor aPasteData = ODataAccessObjectTransferable::extractObjectDescriptor(_rTransData);
- pasteTable( aPasteData,_sDestDataSourceName,_xConnection);
+ pasteTable( aPasteData,i_rDestDataSource,_xConnection);
}
}
else if ( _rTransData.HasFormat(_nFormatId) )
@@ -329,22 +314,20 @@ void OTableCopyHelper::pasteTable( SotFormatStringId _nFormatId
// -----------------------------------------------------------------------------
void OTableCopyHelper::pasteTable( const TransferableDataHelper& _rTransData
- ,const ::rtl::OUString& _sDestDataSourceName
+ ,const ::rtl::OUString& i_rDestDataSource
,const SharedConnection& _xConnection)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OTableCopyHelper::pasteTable" );
if ( _rTransData.HasFormat(SOT_FORMATSTR_ID_DBACCESS_TABLE) || _rTransData.HasFormat(SOT_FORMATSTR_ID_DBACCESS_QUERY) )
- pasteTable( SOT_FORMATSTR_ID_DBACCESS_TABLE,_rTransData,_sDestDataSourceName,_xConnection);
+ pasteTable( SOT_FORMATSTR_ID_DBACCESS_TABLE,_rTransData,i_rDestDataSource,_xConnection);
else if ( _rTransData.HasFormat(SOT_FORMATSTR_ID_HTML) )
- pasteTable( SOT_FORMATSTR_ID_HTML,_rTransData,_sDestDataSourceName,_xConnection);
+ pasteTable( SOT_FORMATSTR_ID_HTML,_rTransData,i_rDestDataSource,_xConnection);
else if ( _rTransData.HasFormat(SOT_FORMAT_RTF) )
- pasteTable( SOT_FORMAT_RTF,_rTransData,_sDestDataSourceName,_xConnection);
+ pasteTable( SOT_FORMAT_RTF,_rTransData,i_rDestDataSource,_xConnection);
}
// -----------------------------------------------------------------------------
sal_Bool OTableCopyHelper::copyTagTable(OTableCopyHelper::DropDescriptor& _rDesc, sal_Bool _bCheck,const SharedConnection& _xConnection)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OTableCopyHelper::copyTagTable" );
Reference<XEventListener> xEvt;
ODatabaseImportExport* pImport = NULL;
if ( _rDesc.bHtml )
@@ -367,7 +350,6 @@ sal_Bool OTableCopyHelper::copyTagTable(OTableCopyHelper::DropDescriptor& _rDesc
// -----------------------------------------------------------------------------
sal_Bool OTableCopyHelper::isTableFormat(const TransferableDataHelper& _rClipboard) const
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OTableCopyHelper::isTableFormat" );
sal_Bool bTableFormat = _rClipboard.HasFormat(SOT_FORMATSTR_ID_DBACCESS_TABLE)
|| _rClipboard.HasFormat(SOT_FORMATSTR_ID_DBACCESS_QUERY)
|| _rClipboard.HasFormat(SOT_FORMAT_RTF)
@@ -380,7 +362,6 @@ sal_Bool OTableCopyHelper::copyTagTable(const TransferableDataHelper& _aDroppedD
,DropDescriptor& _rAsyncDrop
,const SharedConnection& _xConnection)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OTableCopyHelper::copyTagTable" );
sal_Bool bRet = sal_False;
sal_Bool bHtml = _aDroppedData.HasFormat(SOT_FORMATSTR_ID_HTML);
if ( bHtml || _aDroppedData.HasFormat(SOT_FORMAT_RTF) )
@@ -413,10 +394,9 @@ sal_Bool OTableCopyHelper::copyTagTable(const TransferableDataHelper& _aDroppedD
}
// -----------------------------------------------------------------------------
void OTableCopyHelper::asyncCopyTagTable( DropDescriptor& _rDesc
- ,const ::rtl::OUString& _sDestDataSourceName
+ ,const ::rtl::OUString& i_rDestDataSource
,const SharedConnection& _xConnection)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OTableCopyHelper::asyncCopyTagTable" );
if ( _rDesc.aHtmlRtfStorage.Is() )
{
copyTagTable(_rDesc,sal_False,_xConnection);
@@ -427,7 +407,7 @@ void OTableCopyHelper::asyncCopyTagTable( DropDescriptor& _rDesc
::utl::UCBContentHelper::Kill(aURL.GetMainURL(INetURLObject::NO_DECODE));
}
else if ( !_rDesc.bError )
- pasteTable(_rDesc.aDroppedData,_sDestDataSourceName,_xConnection);
+ pasteTable(_rDesc.aDroppedData,i_rDestDataSource,_xConnection);
else
m_pController->showError(SQLException(String(ModuleRes(STR_NO_TABLE_FORMAT_INSIDE)),*m_pController,::rtl::OUString::createFromAscii("S1000") ,0,Any()));
}
diff --git a/dbaccess/source/ui/misc/TokenWriter.cxx b/dbaccess/source/ui/misc/TokenWriter.cxx
index d872590b3763..a3dc2e6e1e96 100644
--- a/dbaccess/source/ui/misc/TokenWriter.cxx
+++ b/dbaccess/source/ui/misc/TokenWriter.cxx
@@ -104,6 +104,7 @@ ODatabaseImportExport::ODatabaseImportExport(const ::svx::ODataAccessDescriptor&
const Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
const String& rExchange)
:m_xFormatter(_rxNumberF)
+ ,m_bBookmarkSelection( NULL )
,m_xFactory(_rM)
,m_nCommandType(CommandType::TABLE)
,m_bNeedToReInitialize(sal_False)
@@ -133,7 +134,8 @@ ODatabaseImportExport::ODatabaseImportExport(const ::svx::ODataAccessDescriptor&
// import data
ODatabaseImportExport::ODatabaseImportExport( const ::dbtools::SharedConnection& _rxConnection,
const Reference< XNumberFormatter >& _rxNumberF, const Reference< XMultiServiceFactory >& _rM )
- :m_xConnection(_rxConnection)
+ :m_bBookmarkSelection( NULL )
+ ,m_xConnection(_rxConnection)
,m_xFormatter(_rxNumberF)
,m_xFactory(_rM)
,m_nCommandType(::com::sun::star::sdb::CommandType::TABLE)
@@ -187,6 +189,7 @@ void ODatabaseImportExport::dispose()
m_xResultSetMetaData.clear();
m_xResultSet.clear();
m_xRow.clear();
+ m_xRowLocate.clear();
m_xFormatter.clear();
}
// -----------------------------------------------------------------------------
@@ -231,20 +234,37 @@ void ODatabaseImportExport::impl_initFromDescriptor( const ODataAccessDescriptor
if (xComponent.is() && xEvt.is())
xComponent->addEventListener(xEvt);
}
- if(_aDataDescriptor.has(daSelection))
- _aDataDescriptor[daSelection] >>= m_aSelection;
- sal_Bool bBookmarkSelection = sal_True; // the default if not present
+ if ( _aDataDescriptor.has( daSelection ) )
+ _aDataDescriptor[ daSelection ] >>= m_aSelection;
+
if ( _aDataDescriptor.has( daBookmarkSelection ) )
+ _aDataDescriptor[ daBookmarkSelection ] >>= m_bBookmarkSelection;
+
+ if ( _aDataDescriptor.has( daCursor ) )
{
- _aDataDescriptor[ daBookmarkSelection ] >>= bBookmarkSelection;
- DBG_ASSERT( !bBookmarkSelection, "ODatabaseImportExport::ODatabaseImportExport: bookmarked selection not yet supported!" );
+ _aDataDescriptor[ daCursor ] >>= m_xResultSet;
+ m_xRowLocate.set( m_xResultSet, UNO_QUERY );
}
+ if ( m_aSelection.getLength() != 0 )
+ {
+ if ( !m_xResultSet.is() )
+ {
+ OSL_ENSURE( false, "ODatabaseImportExport::impl_initFromDescriptor: selection without result set is nonsense!" );
+ m_aSelection.realloc( 0 );
+ }
+ }
- if(_aDataDescriptor.has(daCursor))
- _aDataDescriptor[daCursor] >>= m_xResultSet;
- } // if ( !_bPlusDefaultInit )
+ if ( m_aSelection.getLength() != 0 )
+ {
+ if ( m_bBookmarkSelection && !m_xRowLocate.is() )
+ {
+ OSL_ENSURE( false, "ODatabaseImportExport::impl_initFromDescriptor: no XRowLocate -> no bookmars!" );
+ m_aSelection.realloc( 0 );
+ }
+ }
+ }
else
initialize();
@@ -314,19 +334,14 @@ void ODatabaseImportExport::initialize()
// the result set may be already set with the datadescriptor
if ( !m_xResultSet.is() )
{
- m_xResultSet.set(m_xFactory->createInstance(::rtl::OUString::createFromAscii("com.sun.star.sdb.RowSet")),UNO_QUERY);
- Reference<XPropertySet > xProp(m_xResultSet,UNO_QUERY);
- if(xProp.is())
- {
- xProp->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( m_xConnection.getTyped() ) );
- xProp->setPropertyValue(PROPERTY_COMMAND_TYPE,makeAny(m_nCommandType));
- xProp->setPropertyValue(PROPERTY_COMMAND,makeAny(m_sName));
- Reference<XRowSet> xRowSet(xProp,UNO_QUERY);
- xRowSet->execute();
- }
- else
- OSL_ENSURE(sal_False, "ODatabaseImportExport::initialize: could not instantiate a rowset!");
- } // if ( !m_xResultSet.is() )
+ m_xResultSet.set( m_xFactory->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.sdb.RowSet" ) ), UNO_QUERY );
+ Reference< XPropertySet > xProp( m_xResultSet, UNO_QUERY_THROW );
+ xProp->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( m_xConnection.getTyped() ) );
+ xProp->setPropertyValue( PROPERTY_COMMAND_TYPE, makeAny( m_nCommandType ) );
+ xProp->setPropertyValue( PROPERTY_COMMAND, makeAny( m_sName ) );
+ Reference< XRowSet > xRowSet( xProp, UNO_QUERY );
+ xRowSet->execute();
+ }
impl_initializeRowMember_throw();
}
catch(Exception& )
@@ -375,7 +390,8 @@ void ODatabaseImportExport::impl_initializeRowMember_throw()
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::impl_initializeRowMember_throw" );
if ( !m_xRow.is() && m_xResultSet.is() )
{
- m_xRow.set(m_xResultSet,UNO_QUERY);
+ m_xRow.set( m_xResultSet, UNO_QUERY );
+ m_xRowLocate.set( m_xResultSet, UNO_QUERY );
m_xResultSetMetaData = Reference<XResultSetMetaDataSupplier>(m_xRow,UNO_QUERY)->getMetaData();
Reference<XColumnsSupplier> xSup(m_xResultSet,UNO_QUERY_THROW);
m_xRowSetColumns.set(xSup->getColumns(),UNO_QUERY_THROW);
@@ -570,22 +586,29 @@ BOOL ORTFImportExport::Write()
Reference< XRowSet > xRowSet(m_xRow,UNO_QUERY);
sal_Int32 k=1;
sal_Int32 kk=0;
- if(m_aSelection.getLength())
+ if ( m_aSelection.getLength() )
{
const Any* pSelIter = m_aSelection.getConstArray();
const Any* pEnd = pSelIter + m_aSelection.getLength();
+
sal_Bool bContinue = sal_True;
- for(;pSelIter != pEnd && bContinue;++pSelIter)
+ for( ; pSelIter != pEnd && bContinue; ++pSelIter )
{
- sal_Int32 nPos = -1;
- *pSelIter >>= nPos;
- OSL_ENSURE(nPos != -1,"Invalid posiotion!");
- bContinue = (m_xResultSet->absolute(nPos));
- if ( bContinue )
- appendRow(pHorzChar,nCount,k,kk);
+ if ( m_bBookmarkSelection )
+ {
+ bContinue = m_xRowLocate->moveToBookmark( *pSelIter );
+ }
+ else
+ {
+ sal_Int32 nPos = -1;
+ OSL_VERIFY( *pSelIter >>= nPos );
+ bContinue = ( m_xResultSet->absolute( nPos ) );
+ }
+ if ( bContinue )
+ appendRow( pHorzChar, nCount, k, kk );
}
- } // if(m_aSelection.getLength())
+ }
else
{
m_xResultSet->beforeFirst(); // set back before the first row
diff --git a/dbaccess/source/ui/uno/copytablewizard.cxx b/dbaccess/source/ui/uno/copytablewizard.cxx
index aa2b87fca329..8642250c45c6 100644
--- a/dbaccess/source/ui/uno/copytablewizard.cxx
+++ b/dbaccess/source/ui/uno/copytablewizard.cxx
@@ -261,6 +261,17 @@ namespace dbaui
sal_Int32& _out_rCommandType
) const;
+ /** extracts the result set to copy records from, and the selection-related aspects, if any.
+
+ Effectively, this method extracts m_xSourceResultSet, m_aSourceSelection, and m_bSourceSelectionBookmarks.
+
+ If an inconsistent/insufficent sub set of those properties is present in the descriptor, and exception
+ is thrown.
+ */
+ void impl_extractSourceResultSet_throw(
+ const Reference< XPropertySet >& i_rDescriptor
+ );
+
/** checks whether the given copy source descriptor contains settings which are not
supported (yet)
@@ -302,7 +313,7 @@ namespace dbaui
/** creates the INSERT INTO statement
@param _xTable The destination table.
*/
- ::rtl::OUString impl_getSelectStatement_nothrow(const Reference< XPropertySet >& _xTable);
+ ::rtl::OUString impl_getServerSideCopyStatement_throw( const Reference< XPropertySet >& _xTable );
/** creates the statement which, when executed, will produce the source data to copy
@@ -345,8 +356,9 @@ private:
sal_Int32 m_nCommandType;
::std::auto_ptr< ICopyTableSourceObject >
m_pSourceObject;
+ Reference< XResultSet > m_xSourceResultSet;
Sequence< Any > m_aSourceSelection;
- bool m_bSourceSelectionBookmarks;
+ sal_Bool m_bSourceSelectionBookmarks;
// destination
SharedConnection m_xDestConnection;
@@ -393,13 +405,13 @@ CopyTableWizard::CopyTableWizard( const Reference< XMultiServiceFactory >& _rxOR
,m_xSourceConnection()
,m_nCommandType( CommandType::COMMAND )
,m_pSourceObject()
+ ,m_xSourceResultSet()
,m_aSourceSelection()
- ,m_bSourceSelectionBookmarks( true )
+ ,m_bSourceSelectionBookmarks( sal_True )
,m_xDestConnection()
,m_aCopyTableListeners( m_aMutex )
,m_nOverrideExecutionResult( -1 )
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::CopyTableWizard" );
}
//-------------------------------------------------------------------------
@@ -415,7 +427,7 @@ CopyTableWizard::~CopyTableWizard()
// TODO: shouldn't we have explicit disposal support? If a listener is registered
// at our instance, and perhaps holds this our instance by a hard ref, then we'll never
- // destroyed.
+ // be destroyed.
// However, adding XComponent support to the GenericUNODialog probably requires
// some thinking - would it break existing clients which do not call a dispose, then?
}
@@ -462,7 +474,6 @@ Reference< XPropertySetInfo > SAL_CALL CopyTableWizard::getPropertySetInfo() thr
//--------------------------------------------------------------------
::sal_Int16 SAL_CALL CopyTableWizard::getOperation() throw (RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::getOperation" );
CopyTableAccessGuard aGuard( *this );
return m_nOperation;
}
@@ -470,7 +481,6 @@ Reference< XPropertySetInfo > SAL_CALL CopyTableWizard::getPropertySetInfo() thr
//--------------------------------------------------------------------
void SAL_CALL CopyTableWizard::setOperation( ::sal_Int16 _operation ) throw (IllegalArgumentException, RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::setOperation" );
CopyTableAccessGuard aGuard( *this );
if ( ( _operation != CopyTableOperation::CopyDefinitionAndData )
@@ -495,7 +505,6 @@ void SAL_CALL CopyTableWizard::setOperation( ::sal_Int16 _operation ) throw (Ill
//--------------------------------------------------------------------
::rtl::OUString SAL_CALL CopyTableWizard::getDestinationTableName() throw (RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::getDestinationTableName" );
CopyTableAccessGuard aGuard( *this );
return m_sDestinationTable;
}
@@ -503,7 +512,6 @@ void SAL_CALL CopyTableWizard::setOperation( ::sal_Int16 _operation ) throw (Ill
//--------------------------------------------------------------------
void SAL_CALL CopyTableWizard::setDestinationTableName( const ::rtl::OUString& _destinationTableName ) throw (RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::setDestinationTableName" );
CopyTableAccessGuard aGuard( *this );
m_sDestinationTable = _destinationTableName;
}
@@ -511,7 +519,6 @@ void SAL_CALL CopyTableWizard::setDestinationTableName( const ::rtl::OUString& _
//--------------------------------------------------------------------
Optional< ::rtl::OUString > SAL_CALL CopyTableWizard::getCreatePrimaryKey() throw (RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::getCreatePrimaryKey" );
CopyTableAccessGuard aGuard( *this );
return m_aPrimaryKeyName;
}
@@ -519,7 +526,6 @@ Optional< ::rtl::OUString > SAL_CALL CopyTableWizard::getCreatePrimaryKey() thro
//--------------------------------------------------------------------
void SAL_CALL CopyTableWizard::setCreatePrimaryKey( const Optional< ::rtl::OUString >& _newPrimaryKey ) throw (IllegalArgumentException, RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::setCreatePrimaryKey" );
CopyTableAccessGuard aGuard( *this );
if ( _newPrimaryKey.IsPresent && !OCopyTableWizard::supportsPrimaryKey( m_xDestConnection ) )
@@ -546,7 +552,6 @@ void SAL_CALL CopyTableWizard::setUseHeaderLineAsColumnNames( sal_Bool _bUseHead
//--------------------------------------------------------------------
void SAL_CALL CopyTableWizard::addCopyTableListener( const Reference< XCopyTableListener >& _rxListener ) throw (RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::addCopyTableListener" );
CopyTableAccessGuard aGuard( *this );
if ( _rxListener.is() )
m_aCopyTableListeners.addInterface( _rxListener );
@@ -555,7 +560,6 @@ void SAL_CALL CopyTableWizard::addCopyTableListener( const Reference< XCopyTable
//--------------------------------------------------------------------
void SAL_CALL CopyTableWizard::removeCopyTableListener( const Reference< XCopyTableListener >& _rxListener ) throw (RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::removeCopyTableListener" );
CopyTableAccessGuard aGuard( *this );
if ( _rxListener.is() )
m_aCopyTableListeners.removeInterface( _rxListener );
@@ -564,7 +568,6 @@ void SAL_CALL CopyTableWizard::removeCopyTableListener( const Reference< XCopyTa
//--------------------------------------------------------------------
void SAL_CALL CopyTableWizard::setTitle( const ::rtl::OUString& _rTitle ) throw (RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::setTitle" );
CopyTableAccessGuard aGuard( *this );
CopyTableWizard_DialogBase::setTitle( _rTitle );
}
@@ -572,7 +575,6 @@ void SAL_CALL CopyTableWizard::setTitle( const ::rtl::OUString& _rTitle ) throw
//--------------------------------------------------------------------
::sal_Int16 SAL_CALL CopyTableWizard::execute( ) throw (RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::execute" );
CopyTableAccessGuard aGuard( *this );
m_nOverrideExecutionResult = -1;
@@ -586,7 +588,6 @@ void SAL_CALL CopyTableWizard::setTitle( const ::rtl::OUString& _rTitle ) throw
//-------------------------------------------------------------------------
OCopyTableWizard& CopyTableWizard::impl_getDialog_throw()
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_getDialog_throw" );
OCopyTableWizard* pWizard = dynamic_cast< OCopyTableWizard* >( m_pDialog );
if ( !pWizard )
throw DisposedException( ::rtl::OUString(), *this );
@@ -596,7 +597,6 @@ OCopyTableWizard& CopyTableWizard::impl_getDialog_throw()
//-------------------------------------------------------------------------
const OCopyTableWizard& CopyTableWizard::impl_getDialog_throw() const
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_getDialog_throw" );
const OCopyTableWizard* pWizard = dynamic_cast< const OCopyTableWizard* >( m_pDialog );
if ( !pWizard )
throw DisposedException( ::rtl::OUString(), *const_cast< CopyTableWizard* >( this ) );
@@ -606,7 +606,6 @@ const OCopyTableWizard& CopyTableWizard::impl_getDialog_throw() const
//-------------------------------------------------------------------------
void CopyTableWizard::impl_attributesToDialog_nothrow( OCopyTableWizard& _rDialog ) const
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_attributesToDialog_nothrow" );
// primary key column
_rDialog.setCreatePrimaryKey( m_aPrimaryKeyName.IsPresent, m_aPrimaryKeyName.Value );
_rDialog.setUseHeaderLine(m_bUseHeaderLineAsColumnNames);
@@ -617,7 +616,6 @@ void CopyTableWizard::impl_attributesToDialog_nothrow( OCopyTableWizard& _rDialo
//-------------------------------------------------------------------------
void CopyTableWizard::impl_dialogToAttributes_nothrow( const OCopyTableWizard& _rDialog )
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_dialogToAttributes_nothrow" );
m_aPrimaryKeyName.IsPresent = _rDialog.shouldCreatePrimaryKey();
if ( m_aPrimaryKeyName.IsPresent )
m_aPrimaryKeyName.Value = _rDialog.getPrimaryKeyName();
@@ -692,7 +690,6 @@ Reference< XPropertySet > CopyTableWizard::impl_ensureDataAccessDescriptor_throw
const Sequence< Any >& _rAllArgs, const sal_Int16 _nArgPos, SharedConnection& _out_rxConnection,
InteractionHandler& _out_rxDocInteractionHandler ) const
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_ensureDataAccessDescriptor_throw" );
Reference< XPropertySet > xDescriptor;
_rAllArgs[ _nArgPos ] >>= xDescriptor;
@@ -745,32 +742,19 @@ namespace
//-------------------------------------------------------------------------
void CopyTableWizard::impl_checkForUnsupportedSettings_throw( const Reference< XPropertySet >& _rxSourceDescriptor ) const
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_checkForUnsupportedSettings_throw" );
OSL_PRECOND( _rxSourceDescriptor.is(), "CopyTableWizard::impl_checkForUnsupportedSettings_throw: illegal argument!" );
Reference< XPropertySetInfo > xPSI( _rxSourceDescriptor->getPropertySetInfo(), UNO_SET_THROW );
::rtl::OUString sUnsupportedSetting;
- // in theory, we could allow to use a mere result set as copy source. However, since this is currently
- // not implemented at all, we report this in the initialization phase already
- if ( xPSI->hasPropertyByName( PROPERTY_RESULT_SET ) )
- {
- Reference< XResultSet > xSource( _rxSourceDescriptor->getPropertyValue( PROPERTY_RESULT_SET ), UNO_QUERY );
- if ( xSource.is() )
- sUnsupportedSetting = PROPERTY_RESULT_SET;
- }
-
- if ( sUnsupportedSetting.getLength() == 0 )
+ const ::rtl::OUString aSettings[] = {
+ PROPERTY_FILTER, PROPERTY_ORDER, PROPERTY_HAVING_CLAUSE, PROPERTY_GROUP_BY
+ };
+ for ( size_t i=0; i < sizeof( aSettings ) / sizeof( aSettings[0] ); ++i )
{
- const ::rtl::OUString aSettings[] = {
- PROPERTY_FILTER, PROPERTY_ORDER, PROPERTY_HAVING_CLAUSE, PROPERTY_GROUP_BY
- };
- for ( size_t i=0; i < sizeof( aSettings ) / sizeof( aSettings[0] ); ++i )
+ if ( lcl_hasNonEmptyStringValue_throw( _rxSourceDescriptor, xPSI, aSettings[i] ) )
{
- if ( lcl_hasNonEmptyStringValue_throw( _rxSourceDescriptor, xPSI, aSettings[i] ) )
- {
- sUnsupportedSetting = aSettings[i];
- break;
- }
+ sUnsupportedSetting = aSettings[i];
+ break;
}
}
@@ -790,17 +774,15 @@ void CopyTableWizard::impl_checkForUnsupportedSettings_throw( const Reference< X
//-------------------------------------------------------------------------
::std::auto_ptr< ICopyTableSourceObject > CopyTableWizard::impl_extractSourceObject_throw( const Reference< XPropertySet >& _rxDescriptor, sal_Int32& _out_rCommandType ) const
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_extractSourceObject_throw" );
OSL_PRECOND( _rxDescriptor.is() && m_xSourceConnection.is(), "CopyTableWizard::impl_extractSourceObject_throw: illegal arguments!" );
- impl_checkForUnsupportedSettings_throw( _rxDescriptor );
-
Reference< XPropertySetInfo > xPSI( _rxDescriptor->getPropertySetInfo(), UNO_SET_THROW );
if ( !xPSI->hasPropertyByName( PROPERTY_COMMAND )
|| !xPSI->hasPropertyByName( PROPERTY_COMMAND_TYPE )
)
throw IllegalArgumentException(
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Expecting a table or query specification." ) ),
+ // TODO: resource
*const_cast< CopyTableWizard* >( this ),
1
);
@@ -860,10 +842,48 @@ void CopyTableWizard::impl_checkForUnsupportedSettings_throw( const Reference< X
}
//-------------------------------------------------------------------------
+void CopyTableWizard::impl_extractSourceResultSet_throw( const Reference< XPropertySet >& i_rDescriptor )
+{
+ Reference< XPropertySetInfo > xPSI( i_rDescriptor->getPropertySetInfo(), UNO_SET_THROW );
+
+ // extract relevant settings
+ if ( xPSI->hasPropertyByName( PROPERTY_RESULT_SET ) )
+ m_xSourceResultSet.set( i_rDescriptor->getPropertyValue( PROPERTY_RESULT_SET ), UNO_QUERY );
+
+ if ( xPSI->hasPropertyByName( PROPERTY_SELECTION ) )
+ OSL_VERIFY( i_rDescriptor->getPropertyValue( PROPERTY_SELECTION ) >>= m_aSourceSelection );
+
+ if ( xPSI->hasPropertyByName( PROPERTY_BOOKMARK_SELECTION ) )
+ OSL_VERIFY( i_rDescriptor->getPropertyValue( PROPERTY_BOOKMARK_SELECTION ) >>= m_bSourceSelectionBookmarks );
+
+ // sanity checks
+ const bool bHasResultSet = m_xSourceResultSet.is();
+ const bool bHasSelection = ( m_aSourceSelection.getLength() != 0 );
+ if ( bHasSelection && !bHasResultSet )
+ throw IllegalArgumentException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "A result set is needed when specifying a selection to copy." ) ),
+ // TODO: resource
+ *this,
+ 1
+ );
+
+ if ( bHasSelection && m_bSourceSelectionBookmarks )
+ {
+ Reference< XRowLocate > xRowLocate( m_xSourceResultSet, UNO_QUERY );
+ if ( !xRowLocate.is() )
+ {
+ ::dbtools::throwGenericSQLException(
+ String( ModuleRes( STR_CTW_COPY_SOURCE_NEEDS_BOOKMARKS ) ),
+ *this
+ );
+ }
+ }
+}
+
+//-------------------------------------------------------------------------
SharedConnection CopyTableWizard::impl_extractConnection_throw( const Reference< XPropertySet >& _rxDataSourceDescriptor,
InteractionHandler& _out_rxDocInteractionHandler ) const
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_extractConnection_throw" );
SharedConnection xConnection;
OSL_PRECOND( _rxDataSourceDescriptor.is(), "CopyTableWizard::impl_extractConnection_throw: no descriptor!" );
@@ -957,7 +977,6 @@ SharedConnection CopyTableWizard::impl_extractConnection_throw( const Reference<
//-------------------------------------------------------------------------
::utl::SharedUNOComponent< XPreparedStatement > CopyTableWizard::impl_createSourceStatement_throw() const
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_createSourceStatement_throw" );
OSL_PRECOND( m_xSourceConnection.is(), "CopyTableWizard::impl_createSourceStatement_throw: illegal call!" );
if ( !m_xSourceConnection.is() )
throw RuntimeException( ::rtl::OUString(), *const_cast< CopyTableWizard* >( this ) );
@@ -1062,7 +1081,6 @@ namespace
//-------------------------------------------------------------------------
bool CopyTableWizard::impl_processCopyError_nothrow( const CopyTableRowEvent& _rEvent )
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_processCopyError_nothrow" );
Reference< XCopyTableListener > xListener;
try
{
@@ -1141,7 +1159,6 @@ bool CopyTableWizard::impl_processCopyError_nothrow( const CopyTableRowEvent& _r
void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSourceResultSet,
const Reference< XPropertySet >& _rxDestTable )
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_copyRows_throw" );
OSL_PRECOND( m_xDestConnection.is(), "CopyTableWizard::impl_copyRows_throw: illegal call!" );
if ( !m_xDestConnection.is() )
throw RuntimeException( ::rtl::OUString(), *this );
@@ -1153,16 +1170,7 @@ void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSou
bool bAutoIncrement = rWizard.shouldCreatePrimaryKey();
Reference< XRow > xRow ( _rxSourceResultSet, UNO_QUERY_THROW );
- Reference< XRowLocate > xRowLocate ( _rxSourceResultSet, UNO_QUERY );
-
- bool bSelectedRecordsOnly = m_aSourceSelection.getLength() > 0;
- if ( bSelectedRecordsOnly && m_bSourceSelectionBookmarks && !xRowLocate.is() )
- {
- ::dbtools::throwGenericSQLException(
- String( ModuleRes( STR_CTW_COPY_SOURCE_NEEDS_BOOKMARKS ) ),
- *this
- );
- }
+ Reference< XRowLocate > xRowLocate ( _rxSourceResultSet, UNO_QUERY_THROW );
Reference< XResultSetMetaDataSupplier > xSuppResMeta( _rxSourceResultSet, UNO_QUERY_THROW );
Reference< XResultSetMetaData> xMeta( xSuppResMeta->getMetaData() );
@@ -1180,9 +1188,11 @@ void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSou
Reference< XPreparedStatement > xStatement( ODatabaseExport::createPreparedStatment( xDestMetaData, _rxDestTable, aColumnMapping ), UNO_SET_THROW );
Reference< XParameters > xStatementParams( xStatement, UNO_QUERY_THROW );
+ const bool bSelectedRecordsOnly = m_aSourceSelection.getLength() != 0;
+ const Any* pSelectedRow = m_aSourceSelection.getConstArray();
+ const Any* pSelEnd = pSelectedRow + m_aSourceSelection.getLength();
+
sal_Int32 nRowCount = 0;
- const Any* pSelectedRow = m_aSourceSelection.getConstArray();
- const Any* pSelEnd = pSelectedRow + m_aSourceSelection.getLength();
bool bContinue = false;
CopyTableRowEvent aCopyEvent;
@@ -1198,7 +1208,7 @@ void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSou
{
if ( m_bSourceSelectionBookmarks )
{
- xRowLocate->moveToBookmark( *pSelectedRow );
+ bContinue = xRowLocate->moveToBookmark( *pSelectedRow );
}
else
{
@@ -1358,7 +1368,6 @@ void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSou
//-------------------------------------------------------------------------
void CopyTableWizard::impl_doCopy_nothrow()
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::impl_doCopy_nothrow" );
Any aError;
try
@@ -1399,26 +1408,41 @@ void CopyTableWizard::impl_doCopy_nothrow()
}
}
- bool bServerCopy = CommandType::TABLE == m_nCommandType && m_xSourceConnection.getTyped() == m_xDestConnection.getTyped() && !m_aSourceSelection.getLength();
- try
+ ::utl::SharedUNOComponent< XPreparedStatement > xSourceStatement;
+ ::utl::SharedUNOComponent< XResultSet > xSourceResultSet;
+
+ if ( m_xSourceResultSet.is() )
{
- if ( bServerCopy )
- {
- m_xDestConnection->createStatement()->executeUpdate( impl_getSelectStatement_nothrow(xTable) );
- }
+ xSourceResultSet.reset( m_xSourceResultSet, ::utl::SharedUNOComponent< XResultSet >::NoTakeOwnership );
}
- catch( const Exception& e )
+ else
{
- (void)e;
- bServerCopy = false;
+ const bool bIsSameConnection = ( m_xSourceConnection.getTyped() == m_xDestConnection.getTyped() );
+ const bool bIsTable = ( CommandType::TABLE == m_nCommandType );
+ bool bDone = false;
+ if ( bIsSameConnection && bIsTable )
+ {
+ // try whether the server supports copying via SQL
+ try
+ {
+ m_xDestConnection->createStatement()->executeUpdate( impl_getServerSideCopyStatement_throw(xTable) );
+ bDone = true;
+ }
+ catch( const Exception& )
+ {
+ // this is allowed.
+ }
+ }
+
+ if ( !bDone )
+ {
+ xSourceStatement.set( impl_createSourceStatement_throw(), UNO_SET_THROW );
+ xSourceResultSet.set( xSourceStatement->executeQuery(), UNO_SET_THROW );
+ }
}
- if ( !bServerCopy )
- {
- ::utl::SharedUNOComponent< XPreparedStatement > xStatement( impl_createSourceStatement_throw(), UNO_SET_THROW );
- Reference< XResultSet > xSourceResultSet( xStatement->executeQuery() );
+ if ( xSourceResultSet.is() )
impl_copyRows_throw( xSourceResultSet, xTable );
- }
}
break;
@@ -1458,7 +1482,7 @@ void CopyTableWizard::impl_doCopy_nothrow()
}
}
// -----------------------------------------------------------------------------
-::rtl::OUString CopyTableWizard::impl_getSelectStatement_nothrow(const Reference< XPropertySet >& _xTable)
+::rtl::OUString CopyTableWizard::impl_getServerSideCopyStatement_throw(const Reference< XPropertySet >& _xTable)
{
const Reference<XColumnsSupplier> xDestColsSup(_xTable,UNO_QUERY_THROW);
const Sequence< ::rtl::OUString> aDestColumnNames = xDestColsSup->getColumns()->getElementNames();
@@ -1496,7 +1520,6 @@ void CopyTableWizard::impl_doCopy_nothrow()
//-------------------------------------------------------------------------
void SAL_CALL CopyTableWizard::initialize( const Sequence< Any >& _rArguments ) throw (Exception, RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::initialize" );
::osl::MutexGuard aGuard( m_aMutex );
if ( isInitialized() )
throw AlreadyInitializedException( ::rtl::OUString(), *this );
@@ -1525,7 +1548,9 @@ void SAL_CALL CopyTableWizard::initialize( const Sequence< Any >& _rArguments )
InteractionHandler xSourceDocHandler;
Reference< XPropertySet > xSourceDescriptor( impl_ensureDataAccessDescriptor_throw( _rArguments, 0, m_xSourceConnection, xSourceDocHandler ) );
+ impl_checkForUnsupportedSettings_throw( xSourceDescriptor );
m_pSourceObject = impl_extractSourceObject_throw( xSourceDescriptor, m_nCommandType );
+ impl_extractSourceResultSet_throw( xSourceDescriptor );
InteractionHandler xDestDocHandler;
impl_ensureDataAccessDescriptor_throw( _rArguments, 1, m_xDestConnection, xDestDocHandler );
@@ -1549,14 +1574,12 @@ void SAL_CALL CopyTableWizard::initialize( const Sequence< Any >& _rArguments )
//-------------------------------------------------------------------------
::cppu::IPropertyArrayHelper& CopyTableWizard::getInfoHelper()
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::getInfoHelper" );
return *getArrayHelper();
}
//------------------------------------------------------------------------------
::cppu::IPropertyArrayHelper* CopyTableWizard::createArrayHelper( ) const
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::createArrayHelper" );
Sequence< Property > aProps;
describeProperties( aProps );
return new ::cppu::OPropertyArrayHelper( aProps );
@@ -1565,7 +1588,6 @@ void SAL_CALL CopyTableWizard::initialize( const Sequence< Any >& _rArguments )
//------------------------------------------------------------------------------
Dialog* CopyTableWizard::createDialog( Window* _pParent )
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::createDialog" );
OSL_PRECOND( isInitialized(), "CopyTableWizard::createDialog: not initialized!" );
// this should have been prevented in ::execute already
@@ -1588,7 +1610,6 @@ Dialog* CopyTableWizard::createDialog( Window* _pParent )
//------------------------------------------------------------------------------
void CopyTableWizard::executedDialog( sal_Int16 _nExecutionResult )
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "uno", "Ocke.Janssen@sun.com", "CopyTableWizard::executedDialog" );
CopyTableWizard_DialogBase::executedDialog( _nExecutionResult );
if ( _nExecutionResult == RET_OK )