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

Generated by: LCOV version 1.10