LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/basctl/source/dlged - dlgedclip.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 41 0.0 %
Date: 2013-07-09 Functions: 0 10 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/MimeContentTypeFactory.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< uno::XComponentContext >  xContext = getProcessComponentContext();
      60             :     Reference< datatransfer::XMimeContentTypeFactory >
      61           0 :         xMCntTypeFactory = MimeContentTypeFactory::create(xContext);;
      62             : 
      63             :     // compare full media types
      64           0 :     Reference< datatransfer::XMimeContentType > xLType = xMCntTypeFactory->createMimeContentType( lFlavor.MimeType );
      65           0 :     Reference< datatransfer::XMimeContentType > xRType = xMCntTypeFactory->createMimeContentType( rFlavor.MimeType );
      66             : 
      67           0 :     OUString aLFullMediaType = xLType->getFullMediaType();
      68           0 :     OUString aRFullMediaType = xRType->getFullMediaType();
      69             : 
      70           0 :     bRet = aLFullMediaType.equalsIgnoreAsciiCase( aRFullMediaType );
      71             : 
      72           0 :     return bRet;
      73             : }
      74             : 
      75             : // XTransferable
      76             : //----------------------------------------------------------------------------
      77             : 
      78           0 : Any SAL_CALL DlgEdTransferableImpl::getTransferData( const DataFlavor& rFlavor ) throw(UnsupportedFlavorException, IOException, RuntimeException)
      79             : {
      80           0 :     const SolarMutexGuard aGuard;
      81             : 
      82           0 :     if ( !isDataFlavorSupported( rFlavor ) )
      83           0 :         throw UnsupportedFlavorException();
      84             : 
      85           0 :     Any aData;
      86             : 
      87           0 :     for ( sal_Int32 i = 0; i < m_SeqFlavors.getLength(); i++ )
      88             :     {
      89           0 :         if ( compareDataFlavors( m_SeqFlavors[i] , rFlavor ) )
      90             :         {
      91           0 :             aData = m_SeqData[i];
      92           0 :             break;
      93             :         }
      94             :     }
      95             : 
      96           0 :     return aData;
      97             : }
      98             : 
      99             : //----------------------------------------------------------------------------
     100             : 
     101           0 : Sequence< DataFlavor > SAL_CALL DlgEdTransferableImpl::getTransferDataFlavors(  ) throw(RuntimeException)
     102             : {
     103           0 :     const SolarMutexGuard aGuard;
     104             : 
     105           0 :     return m_SeqFlavors;
     106             : }
     107             : 
     108             : //----------------------------------------------------------------------------
     109             : 
     110           0 : sal_Bool SAL_CALL DlgEdTransferableImpl::isDataFlavorSupported( const DataFlavor& rFlavor ) throw(RuntimeException)
     111             : {
     112           0 :     const SolarMutexGuard aGuard;
     113             : 
     114           0 :     for ( sal_Int32 i = 0; i < m_SeqFlavors.getLength(); i++ )
     115           0 :         if ( compareDataFlavors( m_SeqFlavors[i] , rFlavor ) )
     116           0 :             return true;
     117           0 :     return false;
     118             : }
     119             : 
     120             : // XClipboardOwner
     121             : //----------------------------------------------------------------------------
     122             : 
     123           0 : void SAL_CALL DlgEdTransferableImpl::lostOwnership( const Reference< XClipboard >&, const Reference< XTransferable >& ) throw(RuntimeException)
     124             : {
     125           0 :     const SolarMutexGuard aGuard;
     126             : 
     127           0 :     m_SeqFlavors = Sequence< DataFlavor >();
     128           0 :     m_SeqData = Sequence< Any >();
     129           0 : }
     130             : 
     131             : 
     132           0 : } // namespace basctl
     133             : 
     134             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10