1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: TableCopyHelper.hxx,v $
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"
36 #ifndef _DBAUI_COMMON_TYPES_HXX_
37 #include "commontypes.hxx"
39 #ifndef _SVX_DATACCESSDESCRIPTOR_HXX_
40 #include <svx/dataaccessdescriptor.hxx>
42 #ifndef _SOT_STORAGE_HXX
43 #include <sot/storage.hxx>
46 #include <svtools/transfer.hxx>
48 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
49 #include <com/sun/star/sdbc/XConnection.hpp>
51 #ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_
52 #include <com/sun/star/sdbc/XResultSet.hpp>
57 //........................................................................
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
;
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
));
89 class OTableCopyHelper
92 OGenericUnoController
* m_pController
;
93 ::rtl::OUString m_sTableNameForAppend
;
96 // is needed to describe the drop target
99 ::svx::ODataAccessDescriptor aDroppedData
;
101 //for transfor the tablename
102 ::rtl::OUString sDefaultTableName
;
105 SotStorageStreamRef aHtmlRtfStorage
;
107 SvLBoxEntry
* pDroppedAt
;
112 DropDescriptor() : nType(E_TABLE
),pDroppedAt(NULL
),nAction(DND_ACTION_NONE
) { }
115 OTableCopyHelper(OGenericUnoController
* _pControler
);
117 /** pastes a table into the data source
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
129 The format which should be copied.
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
144 If set to <TRUE/> than the controller checks only if a copy is possible.
148 sal_Bool
copyTagTable( DropDescriptor
& _rDesc
,
150 const SharedConnection
& _xConnection
);
152 /** copies a table which was constructed by tags like HTML or RTF
156 If set to <TRUE/> than the controller checks only if a copy is possible.
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
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
;}
184 /** pastes a table into the data source
187 @param _sDestDataSourceName
188 The name of the dest data source.
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
199 @param _xSrcConnection
200 The connection of the source.
202 The selection of the rows to copy.
203 @param _bBookmarkSelection
204 If <TRUE/> the selection is bookmark selection.
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.
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 //........................................................................
226 //........................................................................
227 #endif // DBUI_TABLECOPYHELPER_HXX