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 .
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>
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
;
59 class OTableCopyHelper
62 OGenericUnoController
* m_pController
;
63 OUString m_sTableNameForAppend
;
66 // is needed to describe the drop target
69 svx::ODataAccessDescriptor aDroppedData
;
71 //for transfor the tablename
72 OUString sDefaultTableName
;
75 tools::SvRef
<SotTempStream
> aHtmlRtfStorage
;
77 std::unique_ptr
<weld::TreeIter
> xDroppedAt
;
84 , nAction(DND_ACTION_NONE
)
90 OTableCopyHelper(OGenericUnoController
* _pController
);
92 /** pastes a table into the data source
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
104 The format which should be copied.
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
119 If set to <TRUE/> than the controller checks only if a copy is possible.
123 bool copyTagTable( DropDescriptor
const & _rDesc
,
125 const SharedConnection
& _xConnection
);
127 /** copies a table which was constructed by tags like HTML or RTF
131 If set to <TRUE/> than the controller checks only if a copy is possible.
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
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
;}
159 /** pastes a table into the data source
162 @param _sDestDataSourceName
163 The name of the dest data source.
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
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
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */