LCOV - code coverage report
Current view: top level - libreoffice/basctl/source/dlged - dlgedclip.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 41 0.0 %
Date: 2012-12-27 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             : 
      20             : #include "dlgedclip.hxx"
      21             : #include <osl/mutex.hxx>
      22             : #include <vcl/svapp.hxx>
      23             : #include <comphelper/processfactory.hxx>
      24             : #include <com/sun/star/datatransfer/XMimeContentType.hpp>
      25             : #include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp>
      26             : 
      27             : namespace basctl
      28             : {
      29             : 
      30             : using namespace comphelper;
      31             : using namespace ::com::sun::star;
      32             : using namespace ::com::sun::star::uno;
      33             : using namespace ::com::sun::star::io;
      34             : using namespace ::com::sun::star::datatransfer;
      35             : using namespace ::com::sun::star::datatransfer::clipboard;
      36             : 
      37             : 
      38             : //----------------------------------------------------------------------------
      39             : 
      40           0 : DlgEdTransferableImpl::DlgEdTransferableImpl( const Sequence< DataFlavor >& aSeqFlavors, const Sequence< Any >& aSeqData )
      41             : {
      42           0 :     m_SeqFlavors = aSeqFlavors;
      43           0 :     m_SeqData = aSeqData;
      44           0 : }
      45             : 
      46             : //----------------------------------------------------------------------------
      47             : 
      48           0 : DlgEdTransferableImpl::~DlgEdTransferableImpl()
      49             : {
      50           0 : }
      51             : 
      52             : //----------------------------------------------------------------------------
      53             : 
      54           0 : sal_Bool DlgEdTransferableImpl::compareDataFlavors( const DataFlavor& lFlavor, const DataFlavor& rFlavor )
      55             : {
      56           0 :     bool bRet = false;
      57             : 
      58             :     // compare mime content types
      59           0 :     Reference< lang::XMultiServiceFactory >  xMSF = getProcessServiceFactory();
      60             :     Reference< datatransfer::XMimeContentTypeFactory >
      61           0 :         xMCntTypeFactory( xMSF->createInstance( "com.sun.star.datatransfer.MimeContentTypeFactory" ), UNO_QUERY );
      62             : 
      63           0 :     if ( xMCntTypeFactory.is( ) )
      64             :     {
      65             :         // compare full media types
      66           0 :         Reference< datatransfer::XMimeContentType > xLType = xMCntTypeFactory->createMimeContentType( lFlavor.MimeType );
      67           0 :         Reference< datatransfer::XMimeContentType > xRType = xMCntTypeFactory->createMimeContentType( rFlavor.MimeType );
      68             : 
      69           0 :         OUString aLFullMediaType = xLType->getFullMediaType();
      70           0 :         OUString aRFullMediaType = xRType->getFullMediaType();
      71             : 
      72           0 :         bRet = aLFullMediaType.equalsIgnoreAsciiCase( aRFullMediaType );
      73             :     }
      74             : 
      75           0 :     return bRet;
      76             : }
      77             : 
      78             : // XTransferable
      79             : //----------------------------------------------------------------------------
      80             : 
      81           0 : Any SAL_CALL DlgEdTransferableImpl::getTransferData( const DataFlavor& rFlavor ) throw(UnsupportedFlavorException, IOException, RuntimeException)
      82             : {
      83           0 :     const SolarMutexGuard aGuard;
      84             : 
      85           0 :     if ( !isDataFlavorSupported( rFlavor ) )
      86           0 :         throw UnsupportedFlavorException();
      87             : 
      88           0 :     Any aData;
      89             : 
      90           0 :     for ( sal_Int32 i = 0; i < m_SeqFlavors.getLength(); i++ )
      91             :     {
      92           0 :         if ( compareDataFlavors( m_SeqFlavors[i] , rFlavor ) )
      93             :         {
      94           0 :             aData = m_SeqData[i];
      95           0 :             break;
      96             :         }
      97             :     }
      98             : 
      99           0 :     return aData;
     100             : }
     101             : 
     102             : //----------------------------------------------------------------------------
     103             : 
     104           0 : Sequence< DataFlavor > SAL_CALL DlgEdTransferableImpl::getTransferDataFlavors(  ) throw(RuntimeException)
     105             : {
     106           0 :     const SolarMutexGuard aGuard;
     107             : 
     108           0 :     return m_SeqFlavors;
     109             : }
     110             : 
     111             : //----------------------------------------------------------------------------
     112             : 
     113           0 : sal_Bool SAL_CALL DlgEdTransferableImpl::isDataFlavorSupported( const DataFlavor& rFlavor ) throw(RuntimeException)
     114             : {
     115           0 :     const SolarMutexGuard aGuard;
     116             : 
     117           0 :     for ( sal_Int32 i = 0; i < m_SeqFlavors.getLength(); i++ )
     118           0 :         if ( compareDataFlavors( m_SeqFlavors[i] , rFlavor ) )
     119           0 :             return true;
     120           0 :     return false;
     121             : }
     122             : 
     123             : // XClipboardOwner
     124             : //----------------------------------------------------------------------------
     125             : 
     126           0 : void SAL_CALL DlgEdTransferableImpl::lostOwnership( const Reference< XClipboard >&, const Reference< XTransferable >& ) throw(RuntimeException)
     127             : {
     128           0 :     const SolarMutexGuard aGuard;
     129             : 
     130           0 :     m_SeqFlavors = Sequence< DataFlavor >();
     131           0 :     m_SeqData = Sequence< Any >();
     132           0 : }
     133             : 
     134             : 
     135             : } // namespace basctl
     136             : 
     137             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10