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

Generated by: LCOV version 1.10