fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / dbaccess / source / ui / inc / TableCopyHelper.hxx
blobceba0c89c35e994f9fdd1a96a8c6cf76ab9c0af2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
29 #include <functional>
31 class SvTreeListEntry;
32 namespace dbaui
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;
39 bool bQueryDrop;
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));
57 default: break;
59 return false;
63 class OTableCopyHelper
65 private:
66 OGenericUnoController* m_pController;
67 OUString m_sTableNameForAppend;
69 public:
70 // is needed to describe the drop target
71 struct DropDescriptor
73 svx::ODataAccessDescriptor aDroppedData;
75 //for transfor the tablename
76 OUString sDefaultTableName;
78 OUString aUrl;
79 tools::SvRef<SotStorageStream> aHtmlRtfStorage;
80 ElementType nType;
81 SvTreeListEntry* pDroppedAt;
82 sal_Int8 nAction;
83 bool bHtml;
84 bool bError;
86 DropDescriptor()
87 : nType(E_TABLE)
88 , pDroppedAt(NULL)
89 , nAction(DND_ACTION_NONE)
90 , bHtml(false)
91 , bError(false)
92 { }
95 OTableCopyHelper(OGenericUnoController* _pControler);
97 /** pastes a table into the data source
98 @param _rPasteData
99 The data helper.
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
108 @param _nFormatId
109 The format which should be copied.
110 @param _rPasteData
111 The data helper.
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
121 @param _rDesc
122 The Drop descriptor
123 @param _bCheck
124 If set to <TRUE/> than the controller checks only if a copy is possible.
125 @param _xConnection
126 The connection
128 bool copyTagTable( DropDescriptor& _rDesc,
129 bool _bCheck,
130 const SharedConnection& _xConnection);
132 /** copies a table which was constructed by tags like HTML or RTF
133 @param _rDesc
134 The Drop descriptor
135 @param _bCheck
136 If set to <TRUE/> than the controller checks only if a copy is possible.
137 @param _xConnection
138 The connection
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
145 @param _aDroppedData
146 The dropped data
147 @param _rDesc
148 IN/OUT parameter
149 @param _xConnection
150 The connection
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 ;}
163 private:
164 /** pastes a table into the data source
165 @param _rPasteData
166 The data descriptor.
167 @param _sDestDataSourceName
168 The name of the dest data source.
170 void pasteTable(
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
178 void insertTable(
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
191 } // namespace dbaui
192 #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_TABLECOPYHELPER_HXX
194 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */