LCOV - code coverage report
Current view: top level - vcl/unx/generic/dtrans - X11_transferable.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 38 0.0 %
Date: 2012-08-25 Functions: 0 6 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 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                 :            : 
      30                 :            : #if OSL_DEBUG_LEVEL > 1
      31                 :            : #include <stdio.h>
      32                 :            : #endif
      33                 :            : 
      34                 :            : #include <X11_transferable.hxx>
      35                 :            : #include <X11/Xatom.h>
      36                 :            : #include <com/sun/star/io/IOException.hpp>
      37                 :            : 
      38                 :            : using namespace com::sun::star::datatransfer;
      39                 :            : using namespace com::sun::star::lang;
      40                 :            : using namespace com::sun::star::io;
      41                 :            : using namespace com::sun::star::uno;
      42                 :            : using namespace cppu;
      43                 :            : using namespace osl;
      44                 :            : 
      45                 :            : using namespace x11;
      46                 :            : 
      47                 :            : using ::rtl::OUString;
      48                 :            : 
      49                 :            : 
      50                 :          0 : X11Transferable::X11Transferable(
      51                 :            :     SelectionManager& rManager,
      52                 :            :     Atom selection
      53                 :            :     ) :
      54                 :            :         m_rManager( rManager ),
      55                 :          0 :         m_aSelection( selection )
      56                 :            : {
      57                 :          0 : }
      58                 :            : 
      59                 :            : //==================================================================================================
      60                 :            : 
      61                 :          0 : X11Transferable::~X11Transferable()
      62                 :            : {
      63                 :          0 : }
      64                 :            : 
      65                 :            : //==================================================================================================
      66                 :            : 
      67                 :          0 : Any SAL_CALL X11Transferable::getTransferData( const DataFlavor& rFlavor )
      68                 :            :     throw(UnsupportedFlavorException, IOException, RuntimeException)
      69                 :            : {
      70                 :          0 :     Any aRet;
      71                 :          0 :     Sequence< sal_Int8 > aData;
      72                 :          0 :     bool bSuccess = m_rManager.getPasteData( m_aSelection ? m_aSelection : XA_PRIMARY, rFlavor.MimeType, aData );
      73                 :          0 :     if( ! bSuccess && m_aSelection == 0 )
      74                 :          0 :         bSuccess = m_rManager.getPasteData( m_rManager.getAtom( OUString("CLIPBOARD") ), rFlavor.MimeType, aData );
      75                 :            : 
      76                 :          0 :     if( ! bSuccess )
      77                 :            :     {
      78                 :          0 :         throw UnsupportedFlavorException( rFlavor.MimeType, static_cast < XTransferable * > ( this ) );
      79                 :            :     }
      80                 :          0 :     if( rFlavor.MimeType.equalsIgnoreAsciiCase( OUString("text/plain;charset=utf-16") ) )
      81                 :            :     {
      82                 :          0 :         int nLen = aData.getLength()/2;
      83                 :          0 :         if( ((sal_Unicode*)aData.getConstArray())[nLen-1] == 0 )
      84                 :          0 :             nLen--;
      85                 :          0 :         OUString aString( (sal_Unicode*)aData.getConstArray(), nLen );
      86                 :            : #if OSL_DEBUG_LEVEL > 1
      87                 :            :     fprintf( stderr, "X11Transferable::getTransferData( \"%s\" )\n -> \"%s\"\n",
      88                 :            :              OUStringToOString( rFlavor.MimeType, RTL_TEXTENCODING_ISO_8859_1 ).getStr(),
      89                 :            :              OUStringToOString( aString, RTL_TEXTENCODING_ISO_8859_1 ).getStr() );
      90                 :            : #endif
      91                 :          0 :         aRet <<= aString;
      92                 :            :     }
      93                 :            :     else
      94                 :          0 :         aRet <<= aData;
      95                 :          0 :     return aRet;
      96                 :            : }
      97                 :            : 
      98                 :            : //==================================================================================================
      99                 :            : 
     100                 :          0 : Sequence< DataFlavor > SAL_CALL X11Transferable::getTransferDataFlavors()
     101                 :            :     throw(RuntimeException)
     102                 :            : {
     103                 :          0 :     Sequence< DataFlavor > aFlavorList;
     104                 :          0 :     bool bSuccess = m_rManager.getPasteDataTypes( m_aSelection ? m_aSelection : XA_PRIMARY, aFlavorList );
     105                 :          0 :     if( ! bSuccess && m_aSelection == 0 )
     106                 :          0 :         bSuccess = m_rManager.getPasteDataTypes( m_rManager.getAtom( OUString("CLIPBOARD") ), aFlavorList );
     107                 :            : 
     108                 :          0 :     return aFlavorList;
     109                 :            : }
     110                 :            : 
     111                 :            : //==================================================================================================
     112                 :            : 
     113                 :          0 : sal_Bool SAL_CALL X11Transferable::isDataFlavorSupported( const DataFlavor& aFlavor )
     114                 :            :     throw(RuntimeException)
     115                 :            : {
     116                 :          0 :     if( aFlavor.DataType != getCppuType( (Sequence< sal_Int8 >*)0 ) )
     117                 :            :     {
     118                 :          0 :         if( ! aFlavor.MimeType.equalsIgnoreAsciiCase( OUString("text/plain;charset=utf-16") ) &&
     119                 :          0 :             aFlavor.DataType == getCppuType( (OUString*)0 ) )
     120                 :          0 :             return false;
     121                 :            :     }
     122                 :            : 
     123                 :          0 :     Sequence< DataFlavor > aFlavors( getTransferDataFlavors() );
     124                 :          0 :     for( int i = 0; i < aFlavors.getLength(); i++ )
     125                 :          0 :         if( aFlavor.MimeType.equalsIgnoreAsciiCase( aFlavors.getConstArray()[i].MimeType ) &&
     126                 :          0 :             aFlavor.DataType == aFlavors.getConstArray()[i].DataType )
     127                 :          0 :             return sal_True;
     128                 :            : 
     129                 :          0 :     return sal_False;
     130                 :            : }
     131                 :            : 
     132                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10