android: Update app icon to new startcenter icon
[LibreOffice.git] / dbaccess / source / ui / inc / TableCopyHelper.hxx
blobb543dade80bb0ea0930bdbb0f63f99c8414df78b
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 #pragma once
21 #include "AppElementType.hxx"
22 #include "commontypes.hxx"
23 #include <svx/dataaccessdescriptor.hxx>
24 #include <sot/storage.hxx>
25 #include <vcl/transfer.hxx>
26 #include <vcl/weld.hxx>
27 #include <com/sun/star/sdbc/XConnection.hpp>
28 #include <com/sun/star/sdbc/XResultSet.hpp>
30 namespace dbaui
32 class OGenericUnoController;
33 /// Functor object for class DataFlavorExVector::value_type returntype is bool
34 struct TAppSupportedSotFunctor
36 ElementType eEntryType;
37 TAppSupportedSotFunctor(const ElementType& _eEntryType)
38 : eEntryType(_eEntryType)
42 bool operator()(const DataFlavorExVector::value_type& _aType)
44 switch (_aType.mnSotId)
46 case SotClipboardFormatId::RTF: // RTF data descriptions
47 case SotClipboardFormatId::HTML: // HTML data descriptions
48 case SotClipboardFormatId::DBACCESS_TABLE: // table descriptor
49 return (E_TABLE == eEntryType);
50 case SotClipboardFormatId::DBACCESS_QUERY: // query descriptor
51 case SotClipboardFormatId::DBACCESS_COMMAND: // SQL command
52 return E_QUERY == eEntryType;
53 default: break;
55 return false;
59 class OTableCopyHelper
61 private:
62 OGenericUnoController* m_pController;
63 OUString m_sTableNameForAppend;
65 public:
66 // is needed to describe the drop target
67 struct DropDescriptor
69 svx::ODataAccessDescriptor aDroppedData;
71 //for transfor the tablename
72 OUString sDefaultTableName;
74 OUString aUrl;
75 tools::SvRef<SotTempStream> aHtmlRtfStorage;
76 ElementType nType;
77 std::unique_ptr<weld::TreeIter> xDroppedAt;
78 sal_Int8 nAction;
79 bool bHtml;
80 bool bError;
82 DropDescriptor()
83 : nType(E_TABLE)
84 , nAction(DND_ACTION_NONE)
85 , bHtml(false)
86 , bError(false)
87 { }
90 OTableCopyHelper(OGenericUnoController* _pController);
92 /** pastes a table into the data source
93 @param _rPasteData
94 The data helper.
95 @param _sDestDataSourceName
96 The name of the dest data source.
98 void pasteTable( const TransferableDataHelper& _rTransData
99 ,std::u16string_view _sDestDataSourceName
100 ,const SharedConnection& _xConnection);
102 /** pastes a table into the data source
103 @param _nFormatId
104 The format which should be copied.
105 @param _rPasteData
106 The data helper.
107 @param _sDestDataSourceName
108 The name of the dest data source.
110 void pasteTable( SotClipboardFormatId _nFormatId
111 ,const TransferableDataHelper& _rTransData
112 ,std::u16string_view _sDestDataSourceName
113 ,const SharedConnection& _xConnection);
115 /** copies a table which was constructed by tags like HTML or RTF
116 @param _rDesc
117 The Drop descriptor
118 @param _bCheck
119 If set to <TRUE/> than the controller checks only if a copy is possible.
120 @param _xConnection
121 The connection
123 bool copyTagTable( DropDescriptor const & _rDesc,
124 bool _bCheck,
125 const SharedConnection& _xConnection);
127 /** copies a table which was constructed by tags like HTML or RTF
128 @param _rDesc
129 The Drop descriptor
130 @param _bCheck
131 If set to <TRUE/> than the controller checks only if a copy is possible.
132 @param _xConnection
133 The connection
135 void asyncCopyTagTable( DropDescriptor& _rDesc
136 ,std::u16string_view _sDestDataSourceName
137 ,const SharedConnection& _xConnection);
139 /** copies a table which was constructed by tags like HTML or RTF
140 @param _aDroppedData
141 The dropped data
142 @param _rDesc
143 IN/OUT parameter
144 @param _xConnection
145 The connection
147 bool copyTagTable(const TransferableDataHelper& _aDroppedData,
148 DropDescriptor& _rAsyncDrop,
149 const SharedConnection& _xConnection);
151 /// returns <TRUE/> if the clipboard supports a table format, otherwise <FALSE/>.
152 static bool isTableFormat(const TransferableDataHelper& _rClipboard);
154 void SetTableNameForAppend( const OUString& _rDefaultTableName ) { m_sTableNameForAppend = _rDefaultTableName; }
155 void ResetTableNameForAppend() { SetTableNameForAppend( OUString() ); }
156 const OUString& GetTableNameForAppend() const { return m_sTableNameForAppend ;}
158 private:
159 /** pastes a table into the data source
160 @param _rPasteData
161 The data descriptor.
162 @param _sDestDataSourceName
163 The name of the dest data source.
165 void pasteTable(
166 const svx::ODataAccessDescriptor& _rPasteData,
167 std::u16string_view _sDestDataSourceName,
168 const SharedConnection& _xDestConnection
171 /** insert a table into the data source. The source can either be a table or a query
173 void insertTable(
174 std::u16string_view i_rSourceDataSource,
175 const css::uno::Reference< css::sdbc::XConnection>& i_rSourceConnection,
176 const OUString& i_rCommand,
177 const sal_Int32 i_nCommandType,
178 const css::uno::Reference< css::sdbc::XResultSet >& i_rSourceRows,
179 const css::uno::Sequence< css::uno::Any >& i_rSelection,
180 const bool i_bBookmarkSelection,
181 std::u16string_view i_rDestDataSource,
182 const css::uno::Reference< css::sdbc::XConnection>& i_rDestConnection
186 } // namespace dbaui
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */