LCOV - code coverage report
Current view: top level - vcl/source/app - unohelp2.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 32 0.0 %
Date: 2015-06-13 12:38:46 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 <vcl/unohelp2.hxx>
      21             : #include <sot/exchange.hxx>
      22             : #include <sot/formats.hxx>
      23             : #include <tools/debug.hxx>
      24             : #include <vcl/svapp.hxx>
      25             : #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
      26             : #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
      27             : #include <cppuhelper/queryinterface.hxx>
      28             : 
      29             : using namespace ::com::sun::star;
      30             : 
      31             : namespace vcl { namespace unohelper {
      32             : 
      33           0 :     TextDataObject::TextDataObject( const OUString& rText ) : maText( rText )
      34             :     {
      35           0 :     }
      36             : 
      37           0 :     TextDataObject::~TextDataObject()
      38             :     {
      39           0 :     }
      40             : 
      41           0 :     void TextDataObject::CopyStringTo( const OUString& rContent,
      42             :         const uno::Reference< datatransfer::clipboard::XClipboard >& rxClipboard )
      43             :     {
      44             :         DBG_ASSERT( rxClipboard.is(), "TextDataObject::CopyStringTo: invalid clipboard!" );
      45           0 :         if ( !rxClipboard.is() )
      46           0 :             return;
      47             : 
      48           0 :         TextDataObject* pDataObj = new TextDataObject( rContent );
      49             : 
      50           0 :         SolarMutexReleaser aReleaser;
      51             :         try
      52             :         {
      53           0 :             rxClipboard->setContents( pDataObj, NULL );
      54             : 
      55           0 :             uno::Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( rxClipboard, uno::UNO_QUERY );
      56           0 :             if( xFlushableClipboard.is() )
      57           0 :                 xFlushableClipboard->flushClipboard();
      58             :         }
      59           0 :         catch( const uno::Exception& )
      60             :         {
      61           0 :         }
      62             :     }
      63             : 
      64             :     // ::com::sun::star::uno::XInterface
      65           0 :     uno::Any TextDataObject::queryInterface( const uno::Type & rType ) throw(uno::RuntimeException, std::exception)
      66             :     {
      67           0 :         uno::Any aRet = ::cppu::queryInterface( rType, (static_cast< datatransfer::XTransferable* >(this)) );
      68           0 :         return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ));
      69             :     }
      70             : 
      71             :     // ::com::sun::star::datatransfer::XTransferable
      72           0 :     uno::Any TextDataObject::getTransferData( const datatransfer::DataFlavor& rFlavor ) throw(datatransfer::UnsupportedFlavorException, io::IOException, uno::RuntimeException, std::exception)
      73             :     {
      74           0 :         uno::Any aAny;
      75             : 
      76           0 :         SotClipboardFormatId nT = SotExchange::GetFormat( rFlavor );
      77           0 :         if ( nT == SotClipboardFormatId::STRING )
      78             :         {
      79           0 :             aAny <<= GetString();
      80             :         }
      81             :         else
      82             :         {
      83           0 :             throw datatransfer::UnsupportedFlavorException();
      84             :         }
      85           0 :         return aAny;
      86             :     }
      87             : 
      88           0 :     uno::Sequence< datatransfer::DataFlavor > TextDataObject::getTransferDataFlavors(  ) throw(uno::RuntimeException, std::exception)
      89             :     {
      90           0 :         uno::Sequence< datatransfer::DataFlavor > aDataFlavors(1);
      91           0 :         SotExchange::GetFormatDataFlavor( SotClipboardFormatId::STRING, aDataFlavors.getArray()[0] );
      92           0 :         return aDataFlavors;
      93             :     }
      94             : 
      95           0 :     sal_Bool TextDataObject::isDataFlavorSupported( const datatransfer::DataFlavor& rFlavor ) throw(uno::RuntimeException, std::exception)
      96             :     {
      97           0 :         SotClipboardFormatId nT = SotExchange::GetFormat( rFlavor );
      98           0 :         return ( nT == SotClipboardFormatId::STRING );
      99             :     }
     100             : 
     101             : }}  // namespace vcl::unohelper
     102             : 
     103             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11