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

Generated by: LCOV version 1.10