LCOV - code coverage report
Current view: top level - include/svx - dbaexchange.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 4 0.0 %
Date: 2014-04-14 Functions: 0 7 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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 <svtools/transfer.hxx>
      24             : #include <com/sun/star/beans/XPropertySet.hpp>
      25             : #include <com/sun/star/sdbc/XConnection.hpp>
      26             : #include <svx/dataaccessdescriptor.hxx>
      27             : #include <com/sun/star/uno/Sequence.hxx>
      28             : #include <svx/svxdllapi.h>
      29             : 
      30             : 
      31             : namespace svx
      32             : {
      33             : 
      34             : 
      35             : // column transfer formats
      36             : #define CTF_FIELD_DESCRIPTOR        0x0001      // the field descriptor format
      37             : #define CTF_CONTROL_EXCHANGE        0x0002      // the control exchange format
      38             : #define CTF_COLUMN_DESCRIPTOR       0x0004      // data access descriptor for a column
      39             : 
      40             : 
      41             :     //= OColumnTransferable
      42             : 
      43           0 :     class SVX_DLLPUBLIC OColumnTransferable : public TransferableHelper
      44             :     {
      45             :     protected:
      46             :         ODataAccessDescriptor   m_aDescriptor;
      47             :         OUString         m_sCompatibleFormat;
      48             :         sal_Int32               m_nFormatFlags;
      49             : 
      50             :     public:
      51             :         /** construct the transferable
      52             :         */
      53             :         OColumnTransferable(
      54             :              const OUString& _rDatasource
      55             :             ,const OUString& _rConnectionResource
      56             :             ,const sal_Int32        _nCommandType
      57             :             ,const OUString& _rCommand
      58             :             ,const OUString& _rFieldName
      59             :             ,sal_Int32  _nFormats
      60             :         );
      61             : 
      62             :         /** construct the transferable from a data access descriptor
      63             : 
      64             :             Note that some of the aspects, in particular all which cannot be represented
      65             :             as string, can only be transported via the CTF_COLUMN_DESCRIPTOR format.
      66             : 
      67             :         @param _rDescriptor
      68             :             The descriptor for the column. It must contain at least
      69             :             <ul><li>information sufficient to create a connection, that is, either one of DataSource, DatabaseLocation,
      70             :                     ConnectionResource, and daConnection</li>
      71             :                 <li>a Command</li>
      72             :                 <li>a CommandType</li>
      73             :                 <li>a ColumnName or ColumnObject</li>
      74             :             </ul>
      75             :         */
      76             :         OColumnTransferable(
      77             :             const ODataAccessDescriptor& _rDescriptor,
      78             :             sal_Int32                    _nFormats
      79             :         );
      80             : 
      81             :         /** construct the transferable from a DatabaseForm component and a field name
      82             : 
      83             :             @param _rxForm
      84             :                 the form which is bound to the data source which's field is to be dragged
      85             : 
      86             :             @param _rFieldName
      87             :                 the name of the field to be dragged
      88             : 
      89             :             @param _rxColumn
      90             :                 the column object. Won't be used if <arg>_nFormats</arg> does not include the CTF_COLUMN_DESCRIPTOR
      91             :                 flag.<br/>
      92             :                 May be <NULL/>.
      93             : 
      94             :             @param _rxConnection
      95             :                 the connection the column belongs to. Won't be used if <arg>_nFormats</arg> does not include the CTF_COLUMN_DESCRIPTOR
      96             :                 flag.<br/>
      97             :                 May be <NULL/>.
      98             : 
      99             :             @param _nFormats
     100             :                 supported formats. Must be a combination of the CTF_XXX flags
     101             :         */
     102             :         OColumnTransferable(
     103             :             const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxForm,
     104             :             const OUString& _rFieldName,
     105             :             const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn,
     106             :             const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
     107             :             sal_Int32   _nFormats
     108             :         );
     109             : 
     110             :         /** checks whether or not a column descriptor can be extracted from the data flavor vector given
     111             :             @param _rFlavors
     112             :                 available flavors
     113             :             @param _nFormats
     114             :                 formats to accept
     115             :         */
     116             :         static bool canExtractColumnDescriptor(const DataFlavorExVector& _rFlavors, sal_Int32 _nFormats);
     117             : 
     118             :         /** extracts a column descriptor from the transferable given
     119             :         */
     120             :         static bool extractColumnDescriptor(
     121             :              const TransferableDataHelper&  _rData
     122             :             ,OUString&               _rDatasource
     123             :             ,OUString&               _rDatabaseLocation
     124             :             ,OUString&               _rConnectionResource
     125             :             ,sal_Int32&                     _nCommandType
     126             :             ,OUString&               _rCommand
     127             :             ,OUString&               _rFieldName
     128             :         );
     129             : 
     130             :         /** extracts a column descriptor from the transferable given
     131             :         */
     132             :         static ODataAccessDescriptor
     133             :                         extractColumnDescriptor(const TransferableDataHelper& _rData);
     134             : 
     135             :         /** adds the data contained in the object to the given data container
     136             :             <p>This method helps you treating this class as simple container class:<br/>
     137             :             At the moment, it is a data container and a transferable.
     138             :             Using <method>addDataToContainer</method>, you can treat the class as dumb data container,
     139             :             doing the Drag'n'Drop with a TransferDataContainer instance (which may contain
     140             :             additional formats)</p>
     141             :             @TODO
     142             :                 split this class into a two separate classes: one for the data container aspect, one for
     143             :                 the transfer aspect
     144             :         */
     145             :         void addDataToContainer( TransferDataContainer* _pContainer );
     146             : 
     147             :     protected:
     148             :         // TransferableHelper overridables
     149             :         virtual void        AddSupportedFormats() SAL_OVERRIDE;
     150             :         virtual bool        GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) SAL_OVERRIDE;
     151             : 
     152             :         static sal_uInt32   getDescriptorFormatId();
     153             : 
     154             :     private:
     155             :         SVX_DLLPRIVATE void implConstruct(
     156             :             const OUString&  _rDatasource
     157             :             ,const OUString& _rConnectionResource
     158             :             ,const sal_Int32        _nCommandType
     159             :             ,const OUString& _rCommand
     160             :             ,const OUString& _rFieldName
     161             :         );
     162             :     };
     163             : 
     164             : 
     165             :     //= ODataAccessObjectTransferable
     166             : 
     167             :     /** class for transfering data access objects (tables, queries, statements ...)
     168             :     */
     169           0 :     class SVX_DLLPUBLIC ODataAccessObjectTransferable : public TransferableHelper
     170             :     {
     171             :         ODataAccessDescriptor   m_aDescriptor;
     172             :         OUString         m_sCompatibleObjectDescription;
     173             :             // needed to provide a SOT_FORMATSTR_ID_SBA_DATAEXCHANGE format
     174             : 
     175             :     public:
     176             :         /** should be used copying and the connection is needed.
     177             :             @param  _rDatasource
     178             :                 The data source name.
     179             :             @param  _nCommandType
     180             :                 The kind of command. @see com.sun.star.sdbc.CommandType
     181             :             @param  _rCommand
     182             :                 The command, either a name of a table or query or a SQL statement.
     183             :         */
     184             :         ODataAccessObjectTransferable(
     185             :             const OUString&  _rDatasourceOrLocation
     186             :             ,const OUString& _rConnectionResource
     187             :             ,const sal_Int32            _nCommandType
     188             :             ,const OUString& _rCommand
     189             :             ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection
     190             :         );
     191             : 
     192             :         /** should be used when copying a query object and no connection is available.
     193             :             @param  _rDatasource
     194             :                 The data source name.
     195             :             @param  _nCommandType
     196             :                 The kind of command. @see com.sun.star.sdbc.CommandType
     197             :             @param  _rCommand
     198             :                 The command, either a name of a table or query or a SQL statement.
     199             :         */
     200             :         ODataAccessObjectTransferable(
     201             :             const OUString&  _rDatasourceOrLocation
     202             :             ,const OUString& _rConnectionResource
     203             :             ,const sal_Int32        _nCommandType
     204             :             ,const OUString& _rCommand
     205             :         );
     206             : 
     207             :         /** with this ctor, only the object descriptor format will be provided
     208             :         */
     209             :         ODataAccessObjectTransferable(
     210             :             const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxLivingForm
     211             :         );
     212             : 
     213             :         /** checks whether or not an object descriptor can be extracted from the data flavor vector given
     214             :             @param _rFlavors
     215             :                 available flavors
     216             :             @param _nFormats
     217             :                 formats to accept
     218             :         */
     219             :         static bool canExtractObjectDescriptor(const DataFlavorExVector& _rFlavors);
     220             : 
     221             :         /** extracts a object descriptor from the transferable given
     222             :         */
     223             :         static ODataAccessDescriptor
     224             :                         extractObjectDescriptor(const TransferableDataHelper& _rData);
     225             : 
     226             :     protected:
     227             :         virtual void        AddSupportedFormats() SAL_OVERRIDE;
     228             :         virtual bool        GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) SAL_OVERRIDE;
     229             :         virtual void        ObjectReleased() SAL_OVERRIDE;
     230             : 
     231             :     protected:
     232             :         const   ODataAccessDescriptor&  getDescriptor() const   { return m_aDescriptor; }
     233           0 :                 ODataAccessDescriptor&  getDescriptor()         { return m_aDescriptor; }
     234             :     protected:
     235             :         void    addCompatibleSelectionDescription(
     236             :             const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& _rSelRows
     237             :         );
     238             :             // normally, a derived class could simply access getDescriptor[daSelection] and place the sequence therein
     239             :             // but unfortunately, we have this damned compatible format, and this can't be accessed in
     240             :             // derived classes (our class is the only one which should be contaminated with this)
     241             : 
     242             :     private:
     243             :         SVX_DLLPRIVATE void construct(  const OUString&  _rDatasourceOrLocation
     244             :                         ,const OUString& _rConnectionResource
     245             :                         ,const sal_Int32        _nCommandType
     246             :                         ,const OUString& _rCommand
     247             :                         ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection
     248             :                         ,bool _bAddCommand
     249             :                         ,const OUString& _sActiveCommand);
     250             :     };
     251             : 
     252             : 
     253             :     //= OMultiColumnTransferable
     254             : 
     255             :     /** class for transfering multiple columns
     256             :     */
     257           0 :     class SVX_DLLPUBLIC OMultiColumnTransferable : public TransferableHelper
     258             :     {
     259             :         ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >   m_aDescriptors;
     260             : 
     261             :     public:
     262             :         OMultiColumnTransferable(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _aDescriptors);
     263             : 
     264             :         /** checks whether or not an object descriptor can be extracted from the data flavor vector given
     265             :             @param _rFlavors
     266             :                 available flavors
     267             :             @param _nFormats
     268             :                 formats to accept
     269             :         */
     270             :         static bool canExtractDescriptor(const DataFlavorExVector& _rFlavors);
     271             : 
     272             :         /** extracts a object descriptor from the transferable given
     273             :         */
     274             :         static ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > extractDescriptor(const TransferableDataHelper& _rData);
     275             : 
     276             :     protected:
     277             :         virtual void        AddSupportedFormats() SAL_OVERRIDE;
     278             :         virtual bool        GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) SAL_OVERRIDE;
     279             :         virtual void        ObjectReleased() SAL_OVERRIDE;
     280             :         static sal_uInt32   getDescriptorFormatId();
     281             :     };
     282             : 
     283             : 
     284             : }   // namespace svx
     285             : 
     286             : 
     287             : #endif // INCLUDED_SVX_DBAEXCHANGE_HXX
     288             : 
     289             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10