sync master with lastest vba changes
[ooovba.git] / binfilter / inc / bf_svx / dbaexchange.hxx
blob8e7b3ef8ea90842859c745d6632f0d24e40be0a3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dbaexchange.hxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SVX_DBAEXCHANGE_HXX_
32 #define _SVX_DBAEXCHANGE_HXX_
34 #ifndef _TRANSFER_HXX
35 #include <bf_svtools/transfer.hxx>
36 #endif
37 #ifndef _COMPHELPER_STLTYPES_HXX_
38 #include <comphelper/stl_types.hxx>
39 #endif
40 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
41 #include <com/sun/star/beans/XPropertySet.hpp>
42 #endif
43 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
44 #include <com/sun/star/sdbc/XConnection.hpp>
45 #endif
46 namespace binfilter {
48 //........................................................................
49 namespace svx
51 //........................................................................
53 // column transfer formats
54 #define CTF_FIELD_DESCRIPTOR 0x0001 // the field descriptor format
55 #define CTF_CONTROL_EXCHANGE 0x0002 // the control exchange format
56 #define CTF_COLUMN_DESCRIPTOR 0x0004 // data access descriptor for a column
58 //====================================================================
59 //= OColumnTransferable
60 //====================================================================
61 class OColumnTransferable : public TransferableHelper
63 protected:
64 ::rtl::OUString m_sCompatibleFormat;
65 sal_Int32 m_nFormatFlags;
67 public:
68 /** construct the transferable
70 OColumnTransferable(
71 const ::rtl::OUString& _rDatasource,
72 const sal_Int32 _nCommandType,
73 const ::rtl::OUString& _rCommand,
74 const ::rtl::OUString& _rFieldName,
75 sal_Int32 _nFormats
78 /** construct the transferable from a DatabaseForm component and a field name
80 @param _rxForm
81 the form which is bound to the data source which's field is to be dragged
83 @param _rFieldName
84 the name of the field to be dragged
86 @param _rxColumn
87 the column object. Won't be used if <arg>_nFormats</arg> does not include the CTF_COLUMN_DESCRIPTOR
88 flag.<br/>
89 May be <NULL/>.
91 @param _rxConnection
92 the connection the column belongs to. Won't be used if <arg>_nFormats</arg> does not include the CTF_COLUMN_DESCRIPTOR
93 flag.<br/>
94 May be <NULL/>.
96 @param _nFormats
97 supported formats. Must be a combination of the CTF_XXX flags
99 OColumnTransferable(
100 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxForm,
101 const ::rtl::OUString& _rFieldName,
102 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn,
103 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
104 sal_Int32 _nFormats
107 /** checks whether or not a column descriptor can be extracted from the data flavor vector given
108 @param _rFlavors
109 available flavors
110 @param _nFormats
111 formats to accept
113 static sal_Bool canExtractColumnDescriptor(const DataFlavorExVector& _rFlavors, sal_Int32 _nFormats);
115 /** extracts a column descriptor from the transferable given
117 static sal_Bool extractColumnDescriptor(
118 const TransferableDataHelper& _rData,
119 ::rtl::OUString& _rDatasource,
120 sal_Int32& _nCommandType,
121 ::rtl::OUString& _rCommand,
122 ::rtl::OUString& _rFieldName
125 /** extracts a column descriptor from the transferable given
128 /** adds the data contained in the object to the given data container
129 <p>This method helps you treating this class as simple container class:<br/>
130 At the moment, it is a data container and a transferable.
131 Using <method>addDataToContainer</method>, you can treat the class as dumb data container,
132 doing the Drag'n'Drop with a <type>TransferDataContainer</type> instance (which may contain
133 additional formats)</p>
134 @TODO
135 split this class into a two separate classes: one for the data container aspect, one for
136 the transfer aspect
138 void addDataToContainer( TransferDataContainer* _pContainer );
140 protected:
141 // TransferableHelper overridables
142 virtual void AddSupportedFormats();
143 virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
145 static sal_uInt32 getDescriptorFormatId();
147 private:
148 void implConstruct(
149 const ::rtl::OUString& _rDatasource,
150 const sal_Int32 _nCommandType,
151 const ::rtl::OUString& _rCommand,
152 const ::rtl::OUString& _rFieldName
156 //====================================================================
157 //= ODataAccessObjectTransferable
158 //====================================================================
159 /** class for transfering data access objects (tables, queries, statements ...)
161 class ODataAccessObjectTransferable : public TransferableHelper
163 ::rtl::OUString m_sCompatibleObjectDescription;
164 // needed to provide a SOT_FORMATSTR_ID_SBA_DATAEXCHANGE format
166 public:
167 /** should be used copying and the connection is needed.
168 @param _rDatasource
169 The data source name.
170 @param _nCommandType
171 The kind of command. @see com.sun.star.sdbc.CommandType
172 @param _rCommand
173 The command, either a name of a table or query or a SQL statement.
175 ODataAccessObjectTransferable(
176 const ::rtl::OUString& _rDatasource,
177 const sal_Int32 _nCommandType,
178 const ::rtl::OUString& _rCommand,
179 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection
182 /** should be used when copying a query object and no connection is available.
183 @param _rDatasource
184 The data source name.
185 @param _nCommandType
186 The kind of command. @see com.sun.star.sdbc.CommandType
187 @param _rCommand
188 The command, either a name of a table or query or a SQL statement.
190 ODataAccessObjectTransferable(
191 const ::rtl::OUString& _rDatasource,
192 const sal_Int32 _nCommandType,
193 const ::rtl::OUString& _rCommand
196 /** with this ctor, only the object descriptor format will be provided
198 ODataAccessObjectTransferable(
199 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxLivingForm
202 /** checks whether or not an object descriptor can be extracted from the data flavor vector given
203 @param _rFlavors
204 available flavors
205 @param _nFormats
206 formats to accept
208 static sal_Bool canExtractObjectDescriptor(const DataFlavorExVector& _rFlavors);
210 /** extracts a object descriptor from the transferable given
213 protected:
214 virtual void AddSupportedFormats();
215 virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
216 virtual void ObjectReleased();
218 protected:
219 protected:
220 void addCompatibleSelectionDescription(
221 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& _rSelRows
223 // normally, a derived class could simply access getDescriptor[daSelection] and place the sequence therein
224 // but unfortunately, we have this damned compatible format, and this can't be accessed in
225 // derived classes (our class is the only one which should be contaminated with this)
227 private:
228 void construct( const ::rtl::OUString& _rDatasource,
229 const sal_Int32 _nCommandType,
230 const ::rtl::OUString& _rCommand,
231 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
232 sal_Bool _bAddCommand,
233 const ::rtl::OUString& _sActiveCommand);
236 //........................................................................
237 } // namespace svx
238 //........................................................................
240 }//end of namespace binfilter
241 #endif // _SVX_DBAEXCHANGE_HXX_