1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dbaexchange.hxx,v $
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_
35 #include <bf_svtools/transfer.hxx>
37 #ifndef _COMPHELPER_STLTYPES_HXX_
38 #include <comphelper/stl_types.hxx>
40 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
41 #include <com/sun/star/beans/XPropertySet.hpp>
43 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
44 #include <com/sun/star/sdbc/XConnection.hpp>
48 //........................................................................
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
64 ::rtl::OUString m_sCompatibleFormat
;
65 sal_Int32 m_nFormatFlags
;
68 /** construct the transferable
71 const ::rtl::OUString
& _rDatasource
,
72 const sal_Int32 _nCommandType
,
73 const ::rtl::OUString
& _rCommand
,
74 const ::rtl::OUString
& _rFieldName
,
78 /** construct the transferable from a DatabaseForm component and a field name
81 the form which is bound to the data source which's field is to be dragged
84 the name of the field to be dragged
87 the column object. Won't be used if <arg>_nFormats</arg> does not include the CTF_COLUMN_DESCRIPTOR
92 the connection the column belongs to. Won't be used if <arg>_nFormats</arg> does not include the CTF_COLUMN_DESCRIPTOR
97 supported formats. Must be a combination of the CTF_XXX flags
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
,
107 /** checks whether or not a column descriptor can be extracted from the data flavor vector given
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>
135 split this class into a two separate classes: one for the data container aspect, one for
138 void addDataToContainer( TransferDataContainer
* _pContainer
);
141 // TransferableHelper overridables
142 virtual void AddSupportedFormats();
143 virtual sal_Bool
GetData( const ::com::sun::star::datatransfer::DataFlavor
& rFlavor
);
145 static sal_uInt32
getDescriptorFormatId();
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
167 /** should be used copying and the connection is needed.
169 The data source name.
171 The kind of command. @see com.sun.star.sdbc.CommandType
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.
184 The data source name.
186 The kind of command. @see com.sun.star.sdbc.CommandType
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
208 static sal_Bool
canExtractObjectDescriptor(const DataFlavorExVector
& _rFlavors
);
210 /** extracts a object descriptor from the transferable given
214 virtual void AddSupportedFormats();
215 virtual sal_Bool
GetData( const ::com::sun::star::datatransfer::DataFlavor
& rFlavor
);
216 virtual void ObjectReleased();
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)
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 //........................................................................
238 //........................................................................
240 }//end of namespace binfilter
241 #endif // _SVX_DBAEXCHANGE_HXX_