LibreOffice Module svx (master) 1
dbaexchange.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_SVX_DBAEXCHANGE_HXX
21#define INCLUDED_SVX_DBAEXCHANGE_HXX
22
23#include <sal/config.h>
24
26#include <vcl/transfer.hxx>
27#include <com/sun/star/beans/PropertyValue.hpp>
29#include <com/sun/star/uno/Sequence.hxx>
30#include <svx/svxdllapi.h>
31
32namespace com::sun::star::sdbc { class XConnection; }
33namespace com::sun::star::beans { class XPropertySet; }
34
35// column transfer formats
37{
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
41};
42namespace o3tl
43{
44 template<> struct typed_flags<ColumnTransferFormatFlags> : is_typed_flags<ColumnTransferFormatFlags, 0x07> {};
45}
46
47
48namespace svx
49{
50
51
52 //= OColumnTransferable
53
55 {
56 public:
58
73 void setDescriptor(const ODataAccessDescriptor& rDescriptor);
74
75
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,
103 );
104
111 static bool canExtractColumnDescriptor(const DataFlavorExVector& _rFlavors, ColumnTransferFormatFlags _nFormats);
112
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
123 );
124
128 extractColumnDescriptor(const TransferableDataHelper& _rData);
129
130 private:
131 // TransferableHelper overridables
132 virtual void AddSupportedFormats() override;
133 virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override;
134
135 static SotClipboardFormatId getDescriptorFormatId();
136
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
143 );
144
148 };
149
150
151 //= ODataAccessObjectTransferable
152
156 {
159 // needed to provide a SotClipboardFormatId::SBA_DATAEXCHANGE format
160
161 public:
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
175 );
176
185 void Update(
186 const OUString& _rDatasource,
187 const sal_Int32 _nCommandType,
188 const OUString& _rCommand
189 );
190
194 const css::uno::Reference< css::beans::XPropertySet >& _rxLivingForm
195 );
196
198
205 static bool canExtractObjectDescriptor(const DataFlavorExVector& _rFlavors);
206
210 extractObjectDescriptor(const TransferableDataHelper& _rData);
211
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;
216
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
223 );
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)
227
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);
236 };
237
238
239 //= OMultiColumnTransferable
240
244 {
245 public:
247
248 void setDescriptors(const css::uno::Sequence< css::beans::PropertyValue >& rDescriptors);
249
256 static bool canExtractDescriptor(const DataFlavorExVector& _rFlavors);
257
260 static css::uno::Sequence< css::beans::PropertyValue > extractDescriptor(const TransferableDataHelper& _rData);
261
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();
267
268 css::uno::Sequence< css::beans::PropertyValue > m_aDescriptors;
269 };
270
271
272}
273
274
275#endif // INCLUDED_SVX_DBAEXCHANGE_HXX
276
277/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OColumnTransferable(const css::uno::Reference< css::beans::XPropertySet > &_rxForm, const OUString &_rFieldName, const css::uno::Reference< css::beans::XPropertySet > &_rxColumn, const css::uno::Reference< css::sdbc::XConnection > &_rxConnection, ColumnTransferFormatFlags _nFormats)
construct the transferable from a DatabaseForm component and a field name
ODataAccessDescriptor m_aDescriptor
ColumnTransferFormatFlags m_nFormatFlags
class encapsulating the css::sdb::DataAccessDescriptor service.
class for transferring data access objects (tables, queries, statements ...)
void Update(const OUString &_rDatasource, const sal_Int32 _nCommandType, const OUString &_rCommand, const css::uno::Reference< css::sdbc::XConnection > &_rxConnection)
should be used copying and the connection is needed.
ODataAccessObjectTransferable(const css::uno::Reference< css::beans::XPropertySet > &_rxLivingForm)
with this ctor, only the object descriptor format will be provided
ODataAccessDescriptor & getDescriptor()
const ODataAccessDescriptor & getDescriptor() const
ODataAccessDescriptor m_aDescriptor
class for transferring multiple columns
css::uno::Sequence< css::beans::PropertyValue > m_aDescriptors
ColumnTransferFormatFlags
Definition: dbaexchange.hxx:37
::std::vector< DataFlavorEx > DataFlavorExVector
SotClipboardFormatId
class SAL_NO_VTABLE XPropertySet
Definition: xmlexchg.hxx:29
#define SVX_DLLPRIVATE
Definition: svxdllapi.h:30
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
#define SAL_WARN_UNUSED