Bump version to 6.4-15
[LibreOffice.git] / include / svx / dbaexchange.hxx
blobd831dc4e2ed05b9e20aa8a95e13ef3ffd9595212
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 .
20 #ifndef INCLUDED_SVX_DBAEXCHANGE_HXX
21 #define INCLUDED_SVX_DBAEXCHANGE_HXX
23 #include <sal/config.h>
25 #include <o3tl/typed_flags_set.hxx>
26 #include <vcl/transfer.hxx>
27 #include <com/sun/star/beans/PropertyValue.hpp>
28 #include <svx/dataaccessdescriptor.hxx>
29 #include <com/sun/star/uno/Sequence.hxx>
30 #include <svx/svxdllapi.h>
32 namespace com::sun::star::sdbc { class XConnection; }
33 namespace com::sun::star::beans { class XPropertySet; }
35 // column transfer formats
36 enum class ColumnTransferFormatFlags
38 FIELD_DESCRIPTOR = 0x01, // the field descriptor format
39 CONTROL_EXCHANGE = 0x02, // the control exchange format
40 COLUMN_DESCRIPTOR = 0x04, // data access descriptor for a column
42 namespace o3tl
44 template<> struct typed_flags<ColumnTransferFormatFlags> : is_typed_flags<ColumnTransferFormatFlags, 0x07> {};
48 namespace svx
52 //= OColumnTransferable
54 class SAL_WARN_UNUSED SVX_DLLPUBLIC OColumnTransferable final : public TransferableHelper
56 public:
57 /** construct the transferable from a data access descriptor
59 Note that some of the aspects, in particular all which cannot be represented
60 as string, can only be transported via the CTF_COLUMN_DESCRIPTOR format.
62 @param _rDescriptor
63 The descriptor for the column. It must contain at least
64 <ul><li>information sufficient to create a connection, that is, either one of DataSource, DatabaseLocation,
65 ConnectionResource, and DataAccessDescriptorProperty::Connection</li>
66 <li>a Command</li>
67 <li>a CommandType</li>
68 <li>a ColumnName or ColumnObject</li>
69 </ul>
71 OColumnTransferable(
72 const ODataAccessDescriptor& _rDescriptor,
73 ColumnTransferFormatFlags _nFormats
76 /** construct the transferable from a DatabaseForm component and a field name
78 @param _rxForm
79 the form which is bound to the data source which's field is to be dragged
81 @param _rFieldName
82 the name of the field to be dragged
84 @param _rxColumn
85 the column object. Won't be used if <arg>_nFormats</arg> does not include the CTF_COLUMN_DESCRIPTOR
86 flag.<br/>
87 May be <NULL/>.
89 @param _rxConnection
90 the connection the column belongs to. Won't be used if <arg>_nFormats</arg> does not include the CTF_COLUMN_DESCRIPTOR
91 flag.<br/>
92 May be <NULL/>.
94 @param _nFormats
95 supported formats. Must be a combination of the CTF_XXX flags
97 OColumnTransferable(
98 const css::uno::Reference< css::beans::XPropertySet >& _rxForm,
99 const OUString& _rFieldName,
100 const css::uno::Reference< css::beans::XPropertySet >& _rxColumn,
101 const css::uno::Reference< css::sdbc::XConnection >& _rxConnection,
102 ColumnTransferFormatFlags _nFormats
105 /** checks whether or not a column descriptor can be extracted from the data flavor vector given
106 @param _rFlavors
107 available flavors
108 @param _nFormats
109 formats to accept
111 static bool canExtractColumnDescriptor(const DataFlavorExVector& _rFlavors, ColumnTransferFormatFlags _nFormats);
113 /** extracts a column descriptor from the transferable given
115 static bool extractColumnDescriptor(
116 const TransferableDataHelper& _rData
117 ,OUString& _rDatasource
118 ,OUString& _rDatabaseLocation
119 ,OUString& _rConnectionResource
120 ,sal_Int32& _nCommandType
121 ,OUString& _rCommand
122 ,OUString& _rFieldName
125 /** extracts a column descriptor from the transferable given
127 static ODataAccessDescriptor
128 extractColumnDescriptor(const TransferableDataHelper& _rData);
130 private:
131 // TransferableHelper overridables
132 virtual void AddSupportedFormats() override;
133 virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override;
135 static SotClipboardFormatId getDescriptorFormatId();
137 SVX_DLLPRIVATE void implConstruct(
138 const OUString& _rDatasource
139 ,const OUString& _rConnectionResource
140 ,const sal_Int32 _nCommandType
141 ,const OUString& _rCommand
142 ,const OUString& _rFieldName
145 ODataAccessDescriptor m_aDescriptor;
146 OUString m_sCompatibleFormat;
147 ColumnTransferFormatFlags const m_nFormatFlags;
151 //= ODataAccessObjectTransferable
153 /** class for transferring data access objects (tables, queries, statements ...)
155 class SAL_WARN_UNUSED SVX_DLLPUBLIC ODataAccessObjectTransferable : public TransferableHelper
157 ODataAccessDescriptor m_aDescriptor;
158 OUString m_sCompatibleObjectDescription;
159 // needed to provide a SotClipboardFormatId::SBA_DATAEXCHANGE format
161 public:
162 /** should be used copying and the connection is needed.
163 @param _rDatasource
164 The data source name.
165 @param _nCommandType
166 The kind of command. @see com.sun.star.sdbc.CommandType
167 @param _rCommand
168 The command, either a name of a table or query or a SQL statement.
170 ODataAccessObjectTransferable(
171 const OUString& _rDatasourceOrLocation
172 ,const sal_Int32 _nCommandType
173 ,const OUString& _rCommand
174 ,const css::uno::Reference< css::sdbc::XConnection >& _rxConnection
177 /** should be used when copying a query object and no connection is available.
178 @param _rDatasource
179 The data source name.
180 @param _nCommandType
181 The kind of command. @see com.sun.star.sdbc.CommandType
182 @param _rCommand
183 The command, either a name of a table or query or a SQL statement.
185 ODataAccessObjectTransferable(
186 const OUString& _rDatasourceOrLocation
187 ,const sal_Int32 _nCommandType
188 ,const OUString& _rCommand
191 /** with this ctor, only the object descriptor format will be provided
193 ODataAccessObjectTransferable(
194 const css::uno::Reference< css::beans::XPropertySet >& _rxLivingForm
197 /** checks whether or not an object descriptor can be extracted from the data flavor vector given
198 @param _rFlavors
199 available flavors
200 @param _nFormats
201 formats to accept
203 static bool canExtractObjectDescriptor(const DataFlavorExVector& _rFlavors);
205 /** extracts an object descriptor from the transferable given
207 static ODataAccessDescriptor
208 extractObjectDescriptor(const TransferableDataHelper& _rData);
210 protected:
211 virtual void AddSupportedFormats() override;
212 virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override;
213 virtual void ObjectReleased() override;
215 protected:
216 const ODataAccessDescriptor& getDescriptor() const { return m_aDescriptor; }
217 ODataAccessDescriptor& getDescriptor() { return m_aDescriptor; }
218 protected:
219 void addCompatibleSelectionDescription(
220 const css::uno::Sequence< css::uno::Any >& _rSelRows
222 // normally, a derived class could simply access getDescriptor[DataAccessDescriptorProperty::Selection] and place the sequence therein
223 // but unfortunately, we have this damned compatible format, and this can't be accessed in
224 // derived classes (our class is the only one which should be contaminated with this)
226 private:
227 SVX_DLLPRIVATE void construct( const OUString& _rDatasourceOrLocation
228 ,const OUString& _rConnectionResource
229 ,const sal_Int32 _nCommandType
230 ,const OUString& _rCommand
231 ,const css::uno::Reference< css::sdbc::XConnection >& _rxConnection
232 ,bool _bAddCommand
233 ,const OUString& _sActiveCommand);
237 //= OMultiColumnTransferable
239 /** class for transferring multiple columns
241 class SAL_WARN_UNUSED SVX_DLLPUBLIC OMultiColumnTransferable final : public TransferableHelper
243 public:
244 OMultiColumnTransferable(const css::uno::Sequence< css::beans::PropertyValue >& _aDescriptors);
246 /** checks whether or not an object descriptor can be extracted from the data flavor vector given
247 @param _rFlavors
248 available flavors
249 @param _nFormats
250 formats to accept
252 static bool canExtractDescriptor(const DataFlavorExVector& _rFlavors);
254 /** extracts an object descriptor from the transferable given
256 static css::uno::Sequence< css::beans::PropertyValue > extractDescriptor(const TransferableDataHelper& _rData);
258 private:
259 virtual void AddSupportedFormats() override;
260 virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override;
261 virtual void ObjectReleased() override;
262 static SotClipboardFormatId getDescriptorFormatId();
264 css::uno::Sequence< css::beans::PropertyValue > m_aDescriptors;
271 #endif // INCLUDED_SVX_DBAEXCHANGE_HXX
273 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */