LCOV - code coverage report
Current view: top level - svx/inc/svx - dbaexchange.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 3 0.0 %
Date: 2012-08-25 Functions: 0 6 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 12 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef _SVX_DBAEXCHANGE_HXX_
      30                 :            : #define _SVX_DBAEXCHANGE_HXX_
      31                 :            : 
      32                 :            : #include <svtools/transfer.hxx>
      33                 :            : #include <comphelper/stl_types.hxx>
      34                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      35                 :            : #include <com/sun/star/sdbc/XConnection.hpp>
      36                 :            : #include <svx/dataaccessdescriptor.hxx>
      37                 :            : #include <com/sun/star/uno/Sequence.hxx>
      38                 :            : #include "svx/svxdllapi.h"
      39                 :            : 
      40                 :            : //........................................................................
      41                 :            : namespace svx
      42                 :            : {
      43                 :            : //........................................................................
      44                 :            : 
      45                 :            : // column transfer formats
      46                 :            : #define CTF_FIELD_DESCRIPTOR        0x0001      // the field descriptor format
      47                 :            : #define CTF_CONTROL_EXCHANGE        0x0002      // the control exchange format
      48                 :            : #define CTF_COLUMN_DESCRIPTOR       0x0004      // data access descriptor for a column
      49                 :            : 
      50                 :            :     //====================================================================
      51                 :            :     //= OColumnTransferable
      52                 :            :     //====================================================================
      53 [ #  # ][ #  # ]:          0 :     class SVX_DLLPUBLIC OColumnTransferable : public TransferableHelper
      54                 :            :     {
      55                 :            :     protected:
      56                 :            :         ODataAccessDescriptor   m_aDescriptor;
      57                 :            :         ::rtl::OUString         m_sCompatibleFormat;
      58                 :            :         sal_Int32               m_nFormatFlags;
      59                 :            : 
      60                 :            :     public:
      61                 :            :         /** construct the transferable
      62                 :            :         */
      63                 :            :         OColumnTransferable(
      64                 :            :              const ::rtl::OUString& _rDatasource
      65                 :            :             ,const ::rtl::OUString& _rConnectionResource
      66                 :            :             ,const sal_Int32        _nCommandType
      67                 :            :             ,const ::rtl::OUString& _rCommand
      68                 :            :             ,const ::rtl::OUString& _rFieldName
      69                 :            :             ,sal_Int32  _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                 :            :             sal_Int32                    _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 ::rtl::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                 :            :             sal_Int32   _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 sal_Bool canExtractColumnDescriptor(const DataFlavorExVector& _rFlavors, sal_Int32 _nFormats);
     127                 :            : 
     128                 :            :         /** extracts a column descriptor from the transferable given
     129                 :            :         */
     130                 :            :         static sal_Bool extractColumnDescriptor(
     131                 :            :              const TransferableDataHelper&  _rData
     132                 :            :             ,::rtl::OUString&               _rDatasource
     133                 :            :             ,::rtl::OUString&               _rDatabaseLocation
     134                 :            :             ,::rtl::OUString&               _rConnectionResource
     135                 :            :             ,sal_Int32&                     _nCommandType
     136                 :            :             ,::rtl::OUString&               _rCommand
     137                 :            :             ,::rtl::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 <type>TransferDataContainer</type> 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();
     160                 :            :         virtual sal_Bool    GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
     161                 :            : 
     162                 :            :         static sal_uInt32   getDescriptorFormatId();
     163                 :            : 
     164                 :            :     private:
     165                 :            :         SVX_DLLPRIVATE void implConstruct(
     166                 :            :             const ::rtl::OUString&  _rDatasource
     167                 :            :             ,const ::rtl::OUString& _rConnectionResource
     168                 :            :             ,const sal_Int32        _nCommandType
     169                 :            :             ,const ::rtl::OUString& _rCommand
     170                 :            :             ,const ::rtl::OUString& _rFieldName
     171                 :            :         );
     172                 :            :     };
     173                 :            : 
     174                 :            :     //====================================================================
     175                 :            :     //= ODataAccessObjectTransferable
     176                 :            :     //====================================================================
     177                 :            :     /** class for transfering data access objects (tables, queries, statements ...)
     178                 :            :     */
     179 [ #  # ][ #  # ]:          0 :     class SVX_DLLPUBLIC ODataAccessObjectTransferable : public TransferableHelper
     180                 :            :     {
     181                 :            :         ODataAccessDescriptor   m_aDescriptor;
     182                 :            :         ::rtl::OUString         m_sCompatibleObjectDescription;
     183                 :            :             // needed to provide a SOT_FORMATSTR_ID_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 ::rtl::OUString&  _rDatasourceOrLocation
     196                 :            :             ,const ::rtl::OUString& _rConnectionResource
     197                 :            :             ,const sal_Int32            _nCommandType
     198                 :            :             ,const ::rtl::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 ::rtl::OUString&  _rDatasourceOrLocation
     212                 :            :             ,const ::rtl::OUString& _rConnectionResource
     213                 :            :             ,const sal_Int32        _nCommandType
     214                 :            :             ,const ::rtl::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 sal_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();
     238                 :            :         virtual sal_Bool    GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
     239                 :            :         virtual void        ObjectReleased();
     240                 :            : 
     241                 :            :     protected:
     242                 :            :         const   ODataAccessDescriptor&  getDescriptor() const   { return m_aDescriptor; }
     243                 :            :                 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 ::rtl::OUString&  _rDatasourceOrLocation
     254                 :            :                         ,const ::rtl::OUString& _rConnectionResource
     255                 :            :                         ,const sal_Int32        _nCommandType
     256                 :            :                         ,const ::rtl::OUString& _rCommand
     257                 :            :                         ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection
     258                 :            :                         ,sal_Bool _bAddCommand
     259                 :            :                         ,const ::rtl::OUString& _sActiveCommand);
     260                 :            :     };
     261                 :            : 
     262                 :            :     //====================================================================
     263                 :            :     //= OMultiColumnTransferable
     264                 :            :     //====================================================================
     265                 :            :     /** class for transfering multiple columns
     266                 :            :     */
     267 [ #  # ][ #  # ]:          0 :     class SVX_DLLPUBLIC 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 sal_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();
     288                 :            :         virtual sal_Bool    GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
     289                 :            :         virtual void        ObjectReleased();
     290                 :            :         static sal_uInt32   getDescriptorFormatId();
     291                 :            :     };
     292                 :            : 
     293                 :            : //........................................................................
     294                 :            : }   // namespace svx
     295                 :            : //........................................................................
     296                 :            : 
     297                 :            : #endif // _SVX_DBAEXCHANGE_HXX_
     298                 :            : 
     299                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10