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

Generated by: LCOV version 1.11