tdf#151073 - enable firebird for appstore build w/o experimental mode
[LibreOffice.git] / include / svx / dbaexchange.hxx
blobc5a0193b886a25751566c3dfc34cb8ac9d6d1c6f
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 SVXCORE_DLLPUBLIC OColumnTransferable final : public TransferDataContainer
56 public:
57 OColumnTransferable(ColumnTransferFormatFlags nFormats);
59 /** construct the transferable from a data access descriptor
61 Note that some of the aspects, in particular all which cannot be represented
62 as string, can only be transported via the CTF_COLUMN_DESCRIPTOR format.
64 @param rDescriptor
65 The descriptor for the column. It must contain at least
66 <ul><li>information sufficient to create a connection, that is, either one of DataSource, DatabaseLocation,
67 ConnectionResource, and DataAccessDescriptorProperty::Connection</li>
68 <li>a Command</li>
69 <li>a CommandType</li>
70 <li>a ColumnName or ColumnObject</li>
71 </ul>
73 void setDescriptor(const ODataAccessDescriptor& rDescriptor);
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 m_nFormatFlags;
151 //= ODataAccessObjectTransferable
153 /** class for transferring data access objects (tables, queries, statements ...)
155 class SAL_WARN_UNUSED SVXCORE_DLLPUBLIC ODataAccessObjectTransferable : public TransferDataContainer
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 void Update(
171 const OUString& _rDatasource,
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 void Update(
186 const OUString& _rDatasource,
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 ODataAccessObjectTransferable();
199 /** checks whether or not an object descriptor can be extracted from the data flavor vector given
200 @param _rFlavors
201 available flavors
202 @param _nFormats
203 formats to accept
205 static bool canExtractObjectDescriptor(const DataFlavorExVector& _rFlavors);
207 /** extracts an object descriptor from the transferable given
209 static ODataAccessDescriptor
210 extractObjectDescriptor(const TransferableDataHelper& _rData);
212 protected:
213 virtual void AddSupportedFormats() override;
214 virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override;
215 virtual void ObjectReleased() override;
217 protected:
218 const ODataAccessDescriptor& getDescriptor() const { return m_aDescriptor; }
219 ODataAccessDescriptor& getDescriptor() { return m_aDescriptor; }
220 protected:
221 void addCompatibleSelectionDescription(
222 const css::uno::Sequence< css::uno::Any >& _rSelRows
224 // normally, a derived class could simply access getDescriptor[DataAccessDescriptorProperty::Selection] and place the sequence therein
225 // but unfortunately, we have this damned compatible format, and this can't be accessed in
226 // derived classes (our class is the only one which should be contaminated with this)
228 private:
229 SVX_DLLPRIVATE void construct( const OUString& _rDatasourceOrLocation
230 ,const OUString& _rConnectionResource
231 ,const sal_Int32 _nCommandType
232 ,const OUString& _rCommand
233 ,const css::uno::Reference< css::sdbc::XConnection >& _rxConnection
234 ,bool _bAddCommand
235 ,const OUString& _sActiveCommand);
239 //= OMultiColumnTransferable
241 /** class for transferring multiple columns
243 class SAL_WARN_UNUSED SVXCORE_DLLPUBLIC OMultiColumnTransferable final : public TransferDataContainer
245 public:
246 OMultiColumnTransferable();
248 void setDescriptors(const css::uno::Sequence< css::beans::PropertyValue >& rDescriptors);
250 /** checks whether or not an object descriptor can be extracted from the data flavor vector given
251 @param _rFlavors
252 available flavors
253 @param _nFormats
254 formats to accept
256 static bool canExtractDescriptor(const DataFlavorExVector& _rFlavors);
258 /** extracts an object descriptor from the transferable given
260 static css::uno::Sequence< css::beans::PropertyValue > extractDescriptor(const TransferableDataHelper& _rData);
262 private:
263 virtual void AddSupportedFormats() override;
264 virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override;
265 virtual void ObjectReleased() override;
266 static SotClipboardFormatId getDescriptorFormatId();
268 css::uno::Sequence< css::beans::PropertyValue > m_aDescriptors;
275 #endif // INCLUDED_SVX_DBAEXCHANGE_HXX
277 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */