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