1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_TABLECOPYHELPER_HXX
20 #define INCLUDED_DBACCESS_SOURCE_UI_INC_TABLECOPYHELPER_HXX
22 #include "AppElementType.hxx"
23 #include "commontypes.hxx"
24 #include <svx/dataaccessdescriptor.hxx>
25 #include <sot/storage.hxx>
26 #include <svtools/transfer.hxx>
27 #include <com/sun/star/sdbc/XConnection.hpp>
28 #include <com/sun/star/sdbc/XResultSet.hpp>
31 class SvTreeListEntry
;
34 class OGenericUnoController
;
35 /// unary_function Functor object for class DataFlavorExVector::value_type returntype is bool
36 struct TAppSupportedSotFunctor
: ::std::unary_function
<DataFlavorExVector::value_type
,bool>
38 ElementType eEntryType
;
40 TAppSupportedSotFunctor(const ElementType
& _eEntryType
,bool _bQueryDrop
)
41 : eEntryType(_eEntryType
)
42 , bQueryDrop(_bQueryDrop
)
46 inline bool operator()(const DataFlavorExVector::value_type
& _aType
)
48 switch (_aType
.mnSotId
)
50 case SotClipboardFormatId::RTF
: // RTF data descriptions
51 case SotClipboardFormatId::HTML
: // HTML data descriptions
52 case SotClipboardFormatId::DBACCESS_TABLE
: // table descriptor
53 return (E_TABLE
== eEntryType
);
54 case SotClipboardFormatId::DBACCESS_QUERY
: // query descriptor
55 case SotClipboardFormatId::DBACCESS_COMMAND
: // SQL command
56 return ((E_QUERY
== eEntryType
) || ( !bQueryDrop
&& E_TABLE
== eEntryType
));
63 class OTableCopyHelper
66 OGenericUnoController
* m_pController
;
67 OUString m_sTableNameForAppend
;
70 // is needed to describe the drop target
73 svx::ODataAccessDescriptor aDroppedData
;
75 //for transfor the tablename
76 OUString sDefaultTableName
;
79 tools::SvRef
<SotStorageStream
> aHtmlRtfStorage
;
81 SvTreeListEntry
* pDroppedAt
;
89 , nAction(DND_ACTION_NONE
)
95 OTableCopyHelper(OGenericUnoController
* _pControler
);
97 /** pastes a table into the data source
100 @param _sDestDataSourceName
101 The name of the dest data source.
103 void pasteTable( const TransferableDataHelper
& _rTransData
104 ,const OUString
& _sDestDataSourceName
105 ,const SharedConnection
& _xConnection
);
107 /** pastes a table into the data source
109 The format which should be copied.
112 @param _sDestDataSourceName
113 The name of the dest data source.
115 void pasteTable( SotClipboardFormatId _nFormatId
116 ,const TransferableDataHelper
& _rTransData
117 ,const OUString
& _sDestDataSourceName
118 ,const SharedConnection
& _xConnection
);
120 /** copies a table which was constructed by tags like HTML or RTF
124 If set to <TRUE/> than the controller checks only if a copy is possible.
128 bool copyTagTable( DropDescriptor
& _rDesc
,
130 const SharedConnection
& _xConnection
);
132 /** copies a table which was constructed by tags like HTML or RTF
136 If set to <TRUE/> than the controller checks only if a copy is possible.
140 void asyncCopyTagTable( DropDescriptor
& _rDesc
141 ,const OUString
& _sDestDataSourceName
142 ,const SharedConnection
& _xConnection
);
144 /** copies a table which was constructed by tags like HTML or RTF
152 bool copyTagTable(const TransferableDataHelper
& _aDroppedData
,
153 DropDescriptor
& _rAsyncDrop
,
154 const SharedConnection
& _xConnection
);
156 /// returns <TRUE/> if the clipboard supports a table format, otherwise <FALSE/>.
157 static bool isTableFormat(const TransferableDataHelper
& _rClipboard
);
159 inline void SetTableNameForAppend( const OUString
& _rDefaultTableName
) { m_sTableNameForAppend
= _rDefaultTableName
; }
160 inline void ResetTableNameForAppend() { SetTableNameForAppend( OUString() ); }
161 inline const OUString
& GetTableNameForAppend() const { return m_sTableNameForAppend
;}
164 /** pastes a table into the data source
167 @param _sDestDataSourceName
168 The name of the dest data source.
171 const svx::ODataAccessDescriptor
& _rPasteData
,
172 const OUString
& _sDestDataSourceName
,
173 const SharedConnection
& _xDestConnection
176 /** insert a table into the data source. The source can eihter be a table or a query
179 const OUString
& i_rSourceDataSource
,
180 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& i_rSourceConnection
,
181 const OUString
& i_rCommand
,
182 const sal_Int32 i_nCommandType
,
183 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XResultSet
>& i_rSourceRows
,
184 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& i_rSelection
,
185 const bool i_bBookmarkSelection
,
186 const OUString
& i_rDestDataSource
,
187 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& i_rDestConnection
192 #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_TABLECOPYHELPER_HXX
194 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */