21#include <core_resource.hxx>
25#include <com/sun/star/task/InteractionHandler.hpp>
26#include <com/sun/star/task/XInteractionHandler.hpp>
27#include <com/sun/star/sdb/application/CopyTableOperation.hpp>
28#include <com/sun/star/sdb/application/CopyTableWizard.hpp>
29#include <com/sun/star/sdb/DataAccessDescriptorFactory.hpp>
30#include <com/sun/star/sdb/CommandType.hpp>
60 :m_pController(_pController)
65 const OUString& i_rCommand,
const sal_Int32 i_nCommandType,
71 SAL_WARN(
"dbaccess.ui",
"OTableCopyHelper::insertTable: invalid call (no supported format found)!" );
78 if ( i_rSourceDataSource == i_rDestDataSource )
79 xSrcConnection = i_rDestConnection;
81 if ( !xSrcConnection.is() || !i_rDestConnection.is() )
83 SAL_WARN(
"dbaccess.ui",
"OTableCopyHelper::insertTable: no connection/s!" );
104 Reference<XCopyTableWizard> xWizard(CopyTableWizard::createWithInteractionHandler(aContext, xSource, xDest, xInteractionHandler), UNO_SET_THROW);
109 bool bAppendToExisting = !sTableNameForAppend.isEmpty();
110 xWizard->setOperation( bAppendToExisting ? CopyTableOperation::AppendData : CopyTableOperation::CopyDefinitionAndData );
114 catch(
const SQLException& )
130 _rPasteData[ DataAccessDescriptorProperty::Command ] >>= sCommand;
133 if ( _rPasteData.
has(DataAccessDescriptorProperty::Connection) )
135 OSL_VERIFY( _rPasteData[DataAccessDescriptorProperty::Connection] >>= xSrcConnection );
139 if ( _rPasteData.
has(DataAccessDescriptorProperty::Cursor) )
141 OSL_VERIFY( _rPasteData[ DataAccessDescriptorProperty::Cursor ] >>= xResultSet );
145 if ( _rPasteData.
has( DataAccessDescriptorProperty::Selection ) )
147 OSL_VERIFY( _rPasteData[ DataAccessDescriptorProperty::Selection ] >>= aSelection );
148 OSL_ENSURE( _rPasteData.
has( DataAccessDescriptorProperty::BookmarkSelection ),
"OTableCopyHelper::pasteTable: you should specify BookmarkSelection, too, to be on the safe side!" );
151 bool bBookmarkSelection(
true );
152 if ( _rPasteData.
has( DataAccessDescriptorProperty::BookmarkSelection ) )
154 OSL_VERIFY( _rPasteData[ DataAccessDescriptorProperty::BookmarkSelection ] >>= bBookmarkSelection );
156 OSL_ENSURE( bBookmarkSelection,
"OTableCopyHelper::pasteTable: working with selection-indices (instead of bookmarks) is error-prone, and thus deprecated!" );
158 sal_Int32 nCommandType = CommandType::COMMAND;
159 if ( _rPasteData.
has(DataAccessDescriptorProperty::CommandType) )
160 _rPasteData[DataAccessDescriptorProperty::CommandType] >>= nCommandType;
162 insertTable( sSrcDataSourceName, xSrcConnection, sCommand, nCommandType,
163 xResultSet, aSelection, bBookmarkSelection,
164 i_rDestDataSourceName, i_rDestConnection );
169 ,std::u16string_view i_rDestDataSource
172 if ( _nFormatId == SotClipboardFormatId::DBACCESS_TABLE || _nFormatId == SotClipboardFormatId::DBACCESS_QUERY )
174 if ( ODataAccessObjectTransferable::canExtractObjectDescriptor(_rTransData.
GetDataFlavorExVector()) )
177 pasteTable( aPasteData,i_rDestDataSource,_xConnection);
180 else if ( _rTransData.
HasFormat(_nFormatId) )
186 if ( _nFormatId != SotClipboardFormatId::RTF )
192 aTrans.
bHtml = SotClipboardFormatId::HTML == _nFormatId;
197 catch(
const SQLException&)
211 ,std::u16string_view i_rDestDataSource
214 if ( _rTransData.
HasFormat(SotClipboardFormatId::DBACCESS_TABLE) || _rTransData.
HasFormat(SotClipboardFormatId::DBACCESS_QUERY) )
215 pasteTable( SotClipboardFormatId::DBACCESS_TABLE,_rTransData,i_rDestDataSource,_xConnection);
216 else if ( _rTransData.
HasFormat(SotClipboardFormatId::HTML) )
217 pasteTable( SotClipboardFormatId::HTML,_rTransData,i_rDestDataSource,_xConnection);
218 else if ( _rTransData.
HasFormat(SotClipboardFormatId::RTF) )
219 pasteTable( SotClipboardFormatId::RTF,_rTransData,i_rDestDataSource,_xConnection);
232 pImport->enableCheckOnly();
237 pImport->setStream(pStream);
238 return pImport->Read();
243 bool bTableFormat = _rClipboard.
HasFormat(SotClipboardFormatId::DBACCESS_TABLE)
244 || _rClipboard.
HasFormat(SotClipboardFormatId::DBACCESS_QUERY)
245 || _rClipboard.
HasFormat(SotClipboardFormatId::RTF)
246 || _rClipboard.
HasFormat(SotClipboardFormatId::HTML);
256 bool bHtml = _aDroppedData.
HasFormat(SotClipboardFormatId::HTML);
257 if ( bHtml || _aDroppedData.
HasFormat(SotClipboardFormatId::RTF) )
265 _rAsyncDrop.
bHtml = bHtml;
286 ,std::u16string_view i_rDestDataSource
298 else if ( !_rDesc.
bError )
const DataFlavorExVector & GetDataFlavorExVector() const
bool GetSotStorageStream(SotClipboardFormatId nFormat, tools::SvRef< SotTempStream > &rStreamRef) const
bool HasFormat(SotClipboardFormatId nFormat) const
static css::uno::Reference< css::awt::XWindow > GetInterface(vcl::Window *pWindow)
void showError(const ::dbtools::SQLExceptionInfo &_rInfo)
ODataView * getView() const
const css::uno::Reference< css::uno::XComponentContext > & getORB() const
static bool isTableFormat(const TransferableDataHelper &_rClipboard)
returns <TRUE> if the clipboard supports a table format, otherwise <FALSE>.
OGenericUnoController * m_pController
void pasteTable(const TransferableDataHelper &_rTransData, std::u16string_view _sDestDataSourceName, const SharedConnection &_xConnection)
pastes a table into the data source
bool copyTagTable(DropDescriptor const &_rDesc, bool _bCheck, const SharedConnection &_xConnection)
copies a table which was constructed by tags like HTML or RTF
void asyncCopyTagTable(DropDescriptor &_rDesc, std::u16string_view _sDestDataSourceName, const SharedConnection &_xConnection)
copies a table which was constructed by tags like HTML or RTF
OTableCopyHelper(OGenericUnoController *_pController)
const OUString & GetTableNameForAppend() const
void insertTable(std::u16string_view i_rSourceDataSource, const css::uno::Reference< css::sdbc::XConnection > &i_rSourceConnection, const OUString &i_rCommand, const sal_Int32 i_nCommandType, const css::uno::Reference< css::sdbc::XResultSet > &i_rSourceRows, const css::uno::Sequence< css::uno::Any > &i_rSelection, const bool i_bBookmarkSelection, std::u16string_view i_rDestDataSource, const css::uno::Reference< css::sdbc::XConnection > &i_rDestConnection)
insert a table into the data source.
bool has(DataAccessDescriptorProperty _eWhich) const
OUString getDataSource() const
OUString const & GetURL() const
OUString GetFileName() const
#define DBG_UNHANDLED_EXCEPTION(...)
Reference< XSingleServiceFactory > xFactory
#define SAL_WARN(area, stream)
css::uno::Reference< css::util::XNumberFormatter > getNumberFormatter(const css::uno::Reference< css::sdbc::XConnection > &_rxConnection, const css::uno::Reference< css::uno::XComponentContext > &_rxContext)
creates a number formatter
#define STREAM_SEEK_TO_BEGIN
constexpr OUStringLiteral PROPERTY_COMMAND(u"Command")
constexpr OUStringLiteral PROPERTY_BOOKMARK_SELECTION(u"BookmarkSelection")
constexpr OUStringLiteral PROPERTY_RESULT_SET(u"ResultSet")
constexpr OUStringLiteral PROPERTY_SELECTION(u"Selection")
constexpr OUStringLiteral PROPERTY_ACTIVE_CONNECTION(u"ActiveConnection")
constexpr OUStringLiteral PROPERTY_COMMAND_TYPE(u"CommandType")
svx::ODataAccessDescriptor aDroppedData
OUString sDefaultTableName
tools::SvRef< SotTempStream > aHtmlRtfStorage