LCOV - code coverage report
Current view: top level - basctl/source/dlged - dlgedclip.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 40 0.0 %
Date: 2014-11-03 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           0 : DlgEdTransferableImpl::DlgEdTransferableImpl( const Sequence< DataFlavor >& aSeqFlavors, const Sequence< Any >& aSeqData )
      37             : {
      38           0 :     m_SeqFlavors = aSeqFlavors;
      39           0 :     m_SeqData = aSeqData;
      40           0 : }
      41           0 : DlgEdTransferableImpl::~DlgEdTransferableImpl()
      42             : {
      43           0 : }
      44           0 : bool DlgEdTransferableImpl::compareDataFlavors( const DataFlavor& lFlavor, const DataFlavor& rFlavor )
      45             : {
      46             :     // compare mime content types
      47           0 :     Reference< uno::XComponentContext >  xContext = getProcessComponentContext();
      48             :     Reference< datatransfer::XMimeContentTypeFactory >
      49           0 :         xMCntTypeFactory = MimeContentTypeFactory::create(xContext);;
      50             : 
      51             :     // compare full media types
      52           0 :     Reference< datatransfer::XMimeContentType > xLType = xMCntTypeFactory->createMimeContentType( lFlavor.MimeType );
      53           0 :     Reference< datatransfer::XMimeContentType > xRType = xMCntTypeFactory->createMimeContentType( rFlavor.MimeType );
      54             : 
      55           0 :     OUString aLFullMediaType = xLType->getFullMediaType();
      56           0 :     OUString aRFullMediaType = xRType->getFullMediaType();
      57             : 
      58           0 :     bool bRet = aLFullMediaType.equalsIgnoreAsciiCase( aRFullMediaType );
      59             : 
      60           0 :     return bRet;
      61             : }
      62             : 
      63             : // XTransferable
      64           0 : Any SAL_CALL DlgEdTransferableImpl::getTransferData( const DataFlavor& rFlavor ) throw(UnsupportedFlavorException, IOException, RuntimeException, std::exception)
      65             : {
      66           0 :     const SolarMutexGuard aGuard;
      67             : 
      68           0 :     if ( !isDataFlavorSupported( rFlavor ) )
      69           0 :         throw UnsupportedFlavorException();
      70             : 
      71           0 :     Any aData;
      72             : 
      73           0 :     for ( sal_Int32 i = 0; i < m_SeqFlavors.getLength(); i++ )
      74             :     {
      75           0 :         if ( compareDataFlavors( m_SeqFlavors[i] , rFlavor ) )
      76             :         {
      77           0 :             aData = m_SeqData[i];
      78           0 :             break;
      79             :         }
      80             :     }
      81             : 
      82           0 :     return aData;
      83             : }
      84           0 : Sequence< DataFlavor > SAL_CALL DlgEdTransferableImpl::getTransferDataFlavors(  ) throw(RuntimeException, std::exception)
      85             : {
      86           0 :     const SolarMutexGuard aGuard;
      87             : 
      88           0 :     return m_SeqFlavors;
      89             : }
      90           0 : sal_Bool SAL_CALL DlgEdTransferableImpl::isDataFlavorSupported( const DataFlavor& rFlavor ) throw(RuntimeException, std::exception)
      91             : {
      92           0 :     const SolarMutexGuard aGuard;
      93             : 
      94           0 :     for ( sal_Int32 i = 0; i < m_SeqFlavors.getLength(); i++ )
      95           0 :         if ( compareDataFlavors( m_SeqFlavors[i] , rFlavor ) )
      96           0 :             return true;
      97           0 :     return false;
      98             : }
      99             : 
     100             : // XClipboardOwner
     101           0 : void SAL_CALL DlgEdTransferableImpl::lostOwnership( const Reference< XClipboard >&, const Reference< XTransferable >& ) throw(RuntimeException, std::exception)
     102             : {
     103           0 :     const SolarMutexGuard aGuard;
     104             : 
     105           0 :     m_SeqFlavors = Sequence< DataFlavor >();
     106           0 :     m_SeqData = Sequence< Any >();
     107           0 : }
     108           0 : } // namespace basctl
     109             : 
     110             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10