1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir #ifndef DBUI_TABLECOPYHELPER_HXX 28*cdf0e10cSrcweir #define DBUI_TABLECOPYHELPER_HXX 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir #ifndef DBAUI_APPELEMENTTYPE_HXX 31*cdf0e10cSrcweir #include "AppElementType.hxx" 32*cdf0e10cSrcweir #endif 33*cdf0e10cSrcweir #ifndef _DBAUI_COMMON_TYPES_HXX_ 34*cdf0e10cSrcweir #include "commontypes.hxx" 35*cdf0e10cSrcweir #endif 36*cdf0e10cSrcweir #ifndef _SVX_DATACCESSDESCRIPTOR_HXX_ 37*cdf0e10cSrcweir #include <svx/dataaccessdescriptor.hxx> 38*cdf0e10cSrcweir #endif 39*cdf0e10cSrcweir #ifndef _SOT_STORAGE_HXX 40*cdf0e10cSrcweir #include <sot/storage.hxx> 41*cdf0e10cSrcweir #endif 42*cdf0e10cSrcweir #ifndef _TRANSFER_HXX 43*cdf0e10cSrcweir #include <svtools/transfer.hxx> 44*cdf0e10cSrcweir #endif 45*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ 46*cdf0e10cSrcweir #include <com/sun/star/sdbc/XConnection.hpp> 47*cdf0e10cSrcweir #endif 48*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ 49*cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSet.hpp> 50*cdf0e10cSrcweir #endif 51*cdf0e10cSrcweir #include <functional> 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir class SvLBoxEntry; 54*cdf0e10cSrcweir //........................................................................ 55*cdf0e10cSrcweir namespace dbaui 56*cdf0e10cSrcweir { 57*cdf0e10cSrcweir //........................................................................ 58*cdf0e10cSrcweir class OGenericUnoController; 59*cdf0e10cSrcweir /// unary_function Functor object for class DataFlavorExVector::value_type returntype is bool 60*cdf0e10cSrcweir struct TAppSupportedSotFunctor : ::std::unary_function<DataFlavorExVector::value_type,bool> 61*cdf0e10cSrcweir { 62*cdf0e10cSrcweir ElementType eEntryType; 63*cdf0e10cSrcweir sal_Bool bQueryDrop; 64*cdf0e10cSrcweir TAppSupportedSotFunctor(const ElementType& _eEntryType,sal_Bool _bQueryDrop) 65*cdf0e10cSrcweir : eEntryType(_eEntryType) 66*cdf0e10cSrcweir , bQueryDrop(_bQueryDrop) 67*cdf0e10cSrcweir { 68*cdf0e10cSrcweir } 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir inline bool operator()(const DataFlavorExVector::value_type& _aType) 71*cdf0e10cSrcweir { 72*cdf0e10cSrcweir switch (_aType.mnSotId) 73*cdf0e10cSrcweir { 74*cdf0e10cSrcweir case SOT_FORMAT_RTF: // RTF data descriptions 75*cdf0e10cSrcweir case SOT_FORMATSTR_ID_HTML: // HTML data descriptions 76*cdf0e10cSrcweir case SOT_FORMATSTR_ID_DBACCESS_TABLE: // table descriptor 77*cdf0e10cSrcweir return (E_TABLE == eEntryType); 78*cdf0e10cSrcweir case SOT_FORMATSTR_ID_DBACCESS_QUERY: // query descriptor 79*cdf0e10cSrcweir case SOT_FORMATSTR_ID_DBACCESS_COMMAND: // SQL command 80*cdf0e10cSrcweir return ((E_QUERY == eEntryType) || ( !bQueryDrop && E_TABLE == eEntryType)); 81*cdf0e10cSrcweir } 82*cdf0e10cSrcweir return false; 83*cdf0e10cSrcweir } 84*cdf0e10cSrcweir }; 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir class OTableCopyHelper 87*cdf0e10cSrcweir { 88*cdf0e10cSrcweir private: 89*cdf0e10cSrcweir OGenericUnoController* m_pController; 90*cdf0e10cSrcweir ::rtl::OUString m_sTableNameForAppend; 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir public: 93*cdf0e10cSrcweir // is needed to describe the drop target 94*cdf0e10cSrcweir struct DropDescriptor 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir ::svx::ODataAccessDescriptor aDroppedData; 97*cdf0e10cSrcweir //dyf add 20070601 98*cdf0e10cSrcweir //for transfor the tablename 99*cdf0e10cSrcweir ::rtl::OUString sDefaultTableName; 100*cdf0e10cSrcweir //dyf add end 101*cdf0e10cSrcweir String aUrl; 102*cdf0e10cSrcweir SotStorageStreamRef aHtmlRtfStorage; 103*cdf0e10cSrcweir ElementType nType; 104*cdf0e10cSrcweir SvLBoxEntry* pDroppedAt; 105*cdf0e10cSrcweir sal_Int8 nAction; 106*cdf0e10cSrcweir sal_Bool bHtml; 107*cdf0e10cSrcweir sal_Bool bError; 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir DropDescriptor() : nType(E_TABLE),pDroppedAt(NULL),nAction(DND_ACTION_NONE) { } 110*cdf0e10cSrcweir }; 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir OTableCopyHelper(OGenericUnoController* _pControler); 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir /** pastes a table into the data source 115*cdf0e10cSrcweir @param _rPasteData 116*cdf0e10cSrcweir The data helper. 117*cdf0e10cSrcweir @param _sDestDataSourceName 118*cdf0e10cSrcweir The name of the dest data source. 119*cdf0e10cSrcweir */ 120*cdf0e10cSrcweir void pasteTable( const TransferableDataHelper& _rTransData 121*cdf0e10cSrcweir ,const ::rtl::OUString& _sDestDataSourceName 122*cdf0e10cSrcweir ,const SharedConnection& _xConnection); 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir /** pastes a table into the data source 125*cdf0e10cSrcweir @param _nFormatId 126*cdf0e10cSrcweir The format which should be copied. 127*cdf0e10cSrcweir @param _rPasteData 128*cdf0e10cSrcweir The data helper. 129*cdf0e10cSrcweir @param _sDestDataSourceName 130*cdf0e10cSrcweir The name of the dest data source. 131*cdf0e10cSrcweir */ 132*cdf0e10cSrcweir void pasteTable( SotFormatStringId _nFormatId 133*cdf0e10cSrcweir ,const TransferableDataHelper& _rTransData 134*cdf0e10cSrcweir ,const ::rtl::OUString& _sDestDataSourceName 135*cdf0e10cSrcweir ,const SharedConnection& _xConnection); 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir /** copies a table which was constructed by tags like HTML or RTF 138*cdf0e10cSrcweir @param _rDesc 139*cdf0e10cSrcweir The Drop descriptor 140*cdf0e10cSrcweir @param _bCheck 141*cdf0e10cSrcweir If set to <TRUE/> than the controller checks only if a copy is possible. 142*cdf0e10cSrcweir @param _xConnection 143*cdf0e10cSrcweir The connection 144*cdf0e10cSrcweir */ 145*cdf0e10cSrcweir sal_Bool copyTagTable( DropDescriptor& _rDesc, 146*cdf0e10cSrcweir sal_Bool _bCheck, 147*cdf0e10cSrcweir const SharedConnection& _xConnection); 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir /** copies a table which was constructed by tags like HTML or RTF 150*cdf0e10cSrcweir @param _rDesc 151*cdf0e10cSrcweir The Drop descriptor 152*cdf0e10cSrcweir @param _bCheck 153*cdf0e10cSrcweir If set to <TRUE/> than the controller checks only if a copy is possible. 154*cdf0e10cSrcweir @param _xConnection 155*cdf0e10cSrcweir The connection 156*cdf0e10cSrcweir */ 157*cdf0e10cSrcweir void asyncCopyTagTable( DropDescriptor& _rDesc 158*cdf0e10cSrcweir ,const ::rtl::OUString& _sDestDataSourceName 159*cdf0e10cSrcweir ,const SharedConnection& _xConnection); 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir /** copies a table which was constructed by tags like HTML or RTF 162*cdf0e10cSrcweir @param _aDroppedData 163*cdf0e10cSrcweir The dropped data 164*cdf0e10cSrcweir @param _rDesc 165*cdf0e10cSrcweir IN/OUT parameter 166*cdf0e10cSrcweir @param _xConnection 167*cdf0e10cSrcweir The connection 168*cdf0e10cSrcweir */ 169*cdf0e10cSrcweir sal_Bool copyTagTable(const TransferableDataHelper& _aDroppedData, 170*cdf0e10cSrcweir DropDescriptor& _rAsyncDrop, 171*cdf0e10cSrcweir const SharedConnection& _xConnection); 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir /// returns <TRUE/> if the clipboard supports a table format, otherwise <FALSE/>. 174*cdf0e10cSrcweir sal_Bool isTableFormat(const TransferableDataHelper& _rClipboard) const; 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir inline void SetTableNameForAppend( const ::rtl::OUString& _rDefaultTableName ) { m_sTableNameForAppend = _rDefaultTableName; } 177*cdf0e10cSrcweir inline void ResetTableNameForAppend() { SetTableNameForAppend( ::rtl::OUString() ); } 178*cdf0e10cSrcweir inline const ::rtl::OUString& GetTableNameForAppend() const { return m_sTableNameForAppend ;} 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir private: 181*cdf0e10cSrcweir /** pastes a table into the data source 182*cdf0e10cSrcweir @param _rPasteData 183*cdf0e10cSrcweir The data descriptor. 184*cdf0e10cSrcweir @param _sDestDataSourceName 185*cdf0e10cSrcweir The name of the dest data source. 186*cdf0e10cSrcweir */ 187*cdf0e10cSrcweir void pasteTable( 188*cdf0e10cSrcweir const ::svx::ODataAccessDescriptor& _rPasteData, 189*cdf0e10cSrcweir const ::rtl::OUString& _sDestDataSourceName, 190*cdf0e10cSrcweir const SharedConnection& _xDestConnection 191*cdf0e10cSrcweir ); 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir /** insert a table into the data source. The source can eihter be a table or a query 194*cdf0e10cSrcweir */ 195*cdf0e10cSrcweir void insertTable( 196*cdf0e10cSrcweir const ::rtl::OUString& i_rSourceDataSource, 197*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& i_rSourceConnection, 198*cdf0e10cSrcweir const ::rtl::OUString& i_rCommand, 199*cdf0e10cSrcweir const sal_Int32 i_nCommandType, 200*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >& i_rSourceRows, 201*cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& i_rSelection, 202*cdf0e10cSrcweir const sal_Bool i_bBookmarkSelection, 203*cdf0e10cSrcweir const ::rtl::OUString& i_rDestDataSource, 204*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& i_rDestConnection 205*cdf0e10cSrcweir ); 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir }; 208*cdf0e10cSrcweir //........................................................................ 209*cdf0e10cSrcweir } // namespace dbaui 210*cdf0e10cSrcweir //........................................................................ 211*cdf0e10cSrcweir #endif // DBUI_TABLECOPYHELPER_HXX 212*cdf0e10cSrcweir 213