LCOV - code coverage report
Current view: top level - dbaccess/source/ui/inc - TableCopyHelper.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 16 0.0 %
Date: 2014-04-14 Functions: 0 8 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             : #ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_TABLECOPYHELPER_HXX
      20             : #define INCLUDED_DBACCESS_SOURCE_UI_INC_TABLECOPYHELPER_HXX
      21             : 
      22             : #include "AppElementType.hxx"
      23             : #include "commontypes.hxx"
      24             : #include <svx/dataaccessdescriptor.hxx>
      25             : #include <sot/storage.hxx>
      26             : #include <svtools/transfer.hxx>
      27             : #include <com/sun/star/sdbc/XConnection.hpp>
      28             : #include <com/sun/star/sdbc/XResultSet.hpp>
      29             : #include <functional>
      30             : 
      31             : class SvTreeListEntry;
      32             : namespace dbaui
      33             : {
      34             :     class OGenericUnoController;
      35             :     /// unary_function Functor object for class DataFlavorExVector::value_type returntype is bool
      36             :     struct TAppSupportedSotFunctor : ::std::unary_function<DataFlavorExVector::value_type,bool>
      37             :     {
      38             :         ElementType eEntryType;
      39             :         sal_Bool    bQueryDrop;
      40           0 :         TAppSupportedSotFunctor(const ElementType& _eEntryType,sal_Bool _bQueryDrop)
      41             :             : eEntryType(_eEntryType)
      42           0 :             , bQueryDrop(_bQueryDrop)
      43             :         {
      44           0 :         }
      45             : 
      46           0 :         inline bool operator()(const DataFlavorExVector::value_type& _aType)
      47             :         {
      48           0 :             switch (_aType.mnSotId)
      49             :             {
      50             :                 case SOT_FORMAT_RTF:                    // RTF data descriptions
      51             :                 case SOT_FORMATSTR_ID_HTML:             // HTML data descriptions
      52             :                 case SOT_FORMATSTR_ID_DBACCESS_TABLE:   // table descriptor
      53           0 :                     return (E_TABLE == eEntryType);
      54             :                 case SOT_FORMATSTR_ID_DBACCESS_QUERY:   // query descriptor
      55             :                 case SOT_FORMATSTR_ID_DBACCESS_COMMAND: // SQL command
      56           0 :                     return ((E_QUERY == eEntryType) || ( !bQueryDrop && E_TABLE == eEntryType));
      57             :             }
      58           0 :             return false;
      59             :         }
      60             :     };
      61             : 
      62           0 :     class OTableCopyHelper
      63             :     {
      64             :     private:
      65             :         OGenericUnoController*  m_pController;
      66             :         OUString         m_sTableNameForAppend;
      67             : 
      68             :     public:
      69             :         // is needed to describe the drop target
      70           0 :         struct DropDescriptor
      71             :         {
      72             :             ::svx::ODataAccessDescriptor    aDroppedData;
      73             : 
      74             :             //for transfor the tablename
      75             :             OUString                 sDefaultTableName;
      76             : 
      77             :             OUString                        aUrl;
      78             :             SotStorageStreamRef             aHtmlRtfStorage;
      79             :             ElementType                     nType;
      80             :             SvTreeListEntry*                    pDroppedAt;
      81             :             sal_Int8                        nAction;
      82             :             sal_Bool                        bHtml;
      83             :             sal_Bool                        bError;
      84             : 
      85           0 :             DropDescriptor()
      86             :                 : nType(E_TABLE)
      87             :                 , pDroppedAt(NULL)
      88             :                 , nAction(DND_ACTION_NONE)
      89             :                 , bHtml(sal_False)
      90           0 :                 , bError(sal_False)
      91           0 :                 { }
      92             :         };
      93             : 
      94             :         OTableCopyHelper(OGenericUnoController* _pControler);
      95             : 
      96             :         /** pastes a table into the data source
      97             :             @param  _rPasteData
      98             :                 The data helper.
      99             :             @param  _sDestDataSourceName
     100             :                 The name of the dest data source.
     101             :         */
     102             :         void pasteTable( const TransferableDataHelper& _rTransData
     103             :                         ,const OUString& _sDestDataSourceName
     104             :                         ,const SharedConnection& _xConnection);
     105             : 
     106             :         /** pastes a table into the data source
     107             :             @param  _nFormatId
     108             :                 The format which should be copied.
     109             :             @param  _rPasteData
     110             :                 The data helper.
     111             :             @param  _sDestDataSourceName
     112             :                 The name of the dest data source.
     113             :         */
     114             :         void pasteTable( SotFormatStringId _nFormatId
     115             :                         ,const TransferableDataHelper& _rTransData
     116             :                         ,const OUString& _sDestDataSourceName
     117             :                         ,const SharedConnection& _xConnection);
     118             : 
     119             :         /** copies a table which was constructed by tags like HTML or RTF
     120             :             @param  _rDesc
     121             :                 The Drop descriptor
     122             :             @param  _bCheck
     123             :                 If set to <TRUE/> than the controller checks only if a copy is possible.
     124             :             @param  _xConnection
     125             :                 The connection
     126             :         */
     127             :         sal_Bool copyTagTable(  DropDescriptor& _rDesc,
     128             :                                 sal_Bool _bCheck,
     129             :                                 const SharedConnection& _xConnection);
     130             : 
     131             :         /** copies a table which was constructed by tags like HTML or RTF
     132             :             @param  _rDesc
     133             :                 The Drop descriptor
     134             :             @param  _bCheck
     135             :                 If set to <TRUE/> than the controller checks only if a copy is possible.
     136             :             @param  _xConnection
     137             :                 The connection
     138             :         */
     139             :         void asyncCopyTagTable(  DropDescriptor& _rDesc
     140             :                                 ,const OUString& _sDestDataSourceName
     141             :                                 ,const SharedConnection& _xConnection);
     142             : 
     143             :         /** copies a table which was constructed by tags like HTML or RTF
     144             :             @param  _aDroppedData
     145             :                 The dropped data
     146             :             @param  _rDesc
     147             :                 IN/OUT parameter
     148             :             @param  _xConnection
     149             :                 The connection
     150             :         */
     151             :         sal_Bool copyTagTable(const TransferableDataHelper& _aDroppedData,
     152             :                               DropDescriptor& _rAsyncDrop,
     153             :                               const SharedConnection& _xConnection);
     154             : 
     155             :         /// returns <TRUE/> if the clipboard supports a table format, otherwise <FALSE/>.
     156             :         sal_Bool isTableFormat(const TransferableDataHelper& _rClipboard) const;
     157             : 
     158           0 :         inline void                     SetTableNameForAppend( const OUString& _rDefaultTableName ) { m_sTableNameForAppend = _rDefaultTableName; }
     159           0 :         inline void                     ResetTableNameForAppend() { SetTableNameForAppend( OUString() ); }
     160           0 :         inline const OUString&   GetTableNameForAppend() const { return m_sTableNameForAppend ;}
     161             : 
     162             :     private:
     163             :         /** pastes a table into the data source
     164             :             @param  _rPasteData
     165             :                 The data descriptor.
     166             :             @param  _sDestDataSourceName
     167             :                 The name of the dest data source.
     168             :         */
     169             :         void pasteTable(
     170             :             const ::svx::ODataAccessDescriptor& _rPasteData,
     171             :             const OUString& _sDestDataSourceName,
     172             :             const SharedConnection& _xDestConnection
     173             :         );
     174             : 
     175             :         /** insert a table into the data source. The source can eihter be a table or a query
     176             :         */
     177             :         void insertTable(
     178             :             const OUString& i_rSourceDataSource,
     179             :             const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& i_rSourceConnection,
     180             :             const OUString& i_rCommand,
     181             :             const sal_Int32 i_nCommandType,
     182             :             const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >& i_rSourceRows,
     183             :             const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& i_rSelection,
     184             :             const sal_Bool i_bBookmarkSelection,
     185             :             const OUString& i_rDestDataSource,
     186             :             const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& i_rDestConnection
     187             :         );
     188             : 
     189             :     };
     190             : }   // namespace dbaui
     191             : #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_TABLECOPYHELPER_HXX
     192             : 
     193             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10