LCOV - code coverage report
Current view: top level - dbaccess/source/ui/inc - TableCopyHelper.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 5 17 29.4 %
Date: 2015-06-13 12:38:46 Functions: 3 8 37.5 %
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             :         bool    bQueryDrop;
      40           0 :         TAppSupportedSotFunctor(const ElementType& _eEntryType,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 SotClipboardFormatId::RTF:                    // RTF data descriptions
      51             :                 case SotClipboardFormatId::HTML:             // HTML data descriptions
      52             :                 case SotClipboardFormatId::DBACCESS_TABLE:   // table descriptor
      53           0 :                     return (E_TABLE == eEntryType);
      54             :                 case SotClipboardFormatId::DBACCESS_QUERY:   // query descriptor
      55             :                 case SotClipboardFormatId::DBACCESS_COMMAND: // SQL command
      56           0 :                     return ((E_QUERY == eEntryType) || ( !bQueryDrop && E_TABLE == eEntryType));
      57           0 :                 default: break;
      58             :             }
      59           0 :             return false;
      60             :         }
      61             :     };
      62             : 
      63           8 :     class OTableCopyHelper
      64             :     {
      65             :     private:
      66             :         OGenericUnoController*  m_pController;
      67             :         OUString         m_sTableNameForAppend;
      68             : 
      69             :     public:
      70             :         // is needed to describe the drop target
      71           8 :         struct DropDescriptor
      72             :         {
      73             :             svx::ODataAccessDescriptor    aDroppedData;
      74             : 
      75             :             //for transfor the tablename
      76             :             OUString                 sDefaultTableName;
      77             : 
      78             :             OUString                        aUrl;
      79             :             tools::SvRef<SotStorageStream>             aHtmlRtfStorage;
      80             :             ElementType                     nType;
      81             :             SvTreeListEntry*                    pDroppedAt;
      82             :             sal_Int8                        nAction;
      83             :             bool                        bHtml;
      84             :             bool                        bError;
      85             : 
      86          10 :             DropDescriptor()
      87             :                 : nType(E_TABLE)
      88             :                 , pDroppedAt(NULL)
      89             :                 , nAction(DND_ACTION_NONE)
      90             :                 , bHtml(false)
      91          10 :                 , bError(false)
      92          10 :                 { }
      93             :         };
      94             : 
      95             :         OTableCopyHelper(OGenericUnoController* _pControler);
      96             : 
      97             :         /** pastes a table into the data source
      98             :             @param  _rPasteData
      99             :                 The data helper.
     100             :             @param  _sDestDataSourceName
     101             :                 The name of the dest data source.
     102             :         */
     103             :         void pasteTable( const TransferableDataHelper& _rTransData
     104             :                         ,const OUString& _sDestDataSourceName
     105             :                         ,const SharedConnection& _xConnection);
     106             : 
     107             :         /** pastes a table into the data source
     108             :             @param  _nFormatId
     109             :                 The format which should be copied.
     110             :             @param  _rPasteData
     111             :                 The data helper.
     112             :             @param  _sDestDataSourceName
     113             :                 The name of the dest data source.
     114             :         */
     115             :         void pasteTable( SotClipboardFormatId _nFormatId
     116             :                         ,const TransferableDataHelper& _rTransData
     117             :                         ,const OUString& _sDestDataSourceName
     118             :                         ,const SharedConnection& _xConnection);
     119             : 
     120             :         /** copies a table which was constructed by tags like HTML or RTF
     121             :             @param  _rDesc
     122             :                 The Drop descriptor
     123             :             @param  _bCheck
     124             :                 If set to <TRUE/> than the controller checks only if a copy is possible.
     125             :             @param  _xConnection
     126             :                 The connection
     127             :         */
     128             :         bool copyTagTable(  DropDescriptor& _rDesc,
     129             :                             bool _bCheck,
     130             :                             const SharedConnection& _xConnection);
     131             : 
     132             :         /** copies a table which was constructed by tags like HTML or RTF
     133             :             @param  _rDesc
     134             :                 The Drop descriptor
     135             :             @param  _bCheck
     136             :                 If set to <TRUE/> than the controller checks only if a copy is possible.
     137             :             @param  _xConnection
     138             :                 The connection
     139             :         */
     140             :         void asyncCopyTagTable(  DropDescriptor& _rDesc
     141             :                                 ,const OUString& _sDestDataSourceName
     142             :                                 ,const SharedConnection& _xConnection);
     143             : 
     144             :         /** copies a table which was constructed by tags like HTML or RTF
     145             :             @param  _aDroppedData
     146             :                 The dropped data
     147             :             @param  _rDesc
     148             :                 IN/OUT parameter
     149             :             @param  _xConnection
     150             :                 The connection
     151             :         */
     152             :         bool copyTagTable(const TransferableDataHelper& _aDroppedData,
     153             :                           DropDescriptor& _rAsyncDrop,
     154             :                           const SharedConnection& _xConnection);
     155             : 
     156             :         /// returns <TRUE/> if the clipboard supports a table format, otherwise <FALSE/>.
     157             :         static bool isTableFormat(const TransferableDataHelper& _rClipboard);
     158             : 
     159           0 :         inline void                     SetTableNameForAppend( const OUString& _rDefaultTableName ) { m_sTableNameForAppend = _rDefaultTableName; }
     160           0 :         inline void                     ResetTableNameForAppend() { SetTableNameForAppend( OUString() ); }
     161           0 :         inline const OUString&   GetTableNameForAppend() const { return m_sTableNameForAppend ;}
     162             : 
     163             :     private:
     164             :         /** pastes a table into the data source
     165             :             @param  _rPasteData
     166             :                 The data descriptor.
     167             :             @param  _sDestDataSourceName
     168             :                 The name of the dest data source.
     169             :         */
     170             :         void pasteTable(
     171             :             const svx::ODataAccessDescriptor& _rPasteData,
     172             :             const OUString& _sDestDataSourceName,
     173             :             const SharedConnection& _xDestConnection
     174             :         );
     175             : 
     176             :         /** insert a table into the data source. The source can eihter be a table or a query
     177             :         */
     178             :         void insertTable(
     179             :             const OUString& i_rSourceDataSource,
     180             :             const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& i_rSourceConnection,
     181             :             const OUString& i_rCommand,
     182             :             const sal_Int32 i_nCommandType,
     183             :             const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >& i_rSourceRows,
     184             :             const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& i_rSelection,
     185             :             const bool i_bBookmarkSelection,
     186             :             const OUString& i_rDestDataSource,
     187             :             const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& i_rDestConnection
     188             :         );
     189             : 
     190             :     };
     191             : }   // namespace dbaui
     192             : #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_TABLECOPYHELPER_HXX
     193             : 
     194             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11