LCOV - code coverage report
Current view: top level - svtools/source/misc - stringtransfer.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 32 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 6 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 <sal/config.h>
      21             : 
      22             : #include <sot/exchange.hxx>
      23             : #include <svtools/stringtransfer.hxx>
      24             : 
      25             : 
      26             : namespace svt
      27             : {
      28             : 
      29             : 
      30             :     using namespace ::com::sun::star::uno;
      31             :     using namespace ::com::sun::star::datatransfer;
      32             : 
      33             : 
      34             :     //= OStringTransferable
      35             : 
      36             : 
      37           0 :     OStringTransferable::OStringTransferable(const OUString& _rContent)
      38             :         :TransferableHelper()
      39           0 :         ,m_sContent( _rContent )
      40             :     {
      41           0 :     }
      42             : 
      43             : 
      44           0 :     void OStringTransferable::AddSupportedFormats()
      45             :     {
      46           0 :         AddFormat(SotClipboardFormatId::STRING);
      47           0 :     }
      48             : 
      49             : 
      50           0 :     bool OStringTransferable::GetData( const DataFlavor& _rFlavor, const OUString& /*rDestDoc*/ )
      51             :     {
      52           0 :         SotClipboardFormatId nFormat = SotExchange::GetFormat( _rFlavor );
      53           0 :         if (SotClipboardFormatId::STRING == nFormat)
      54           0 :             return SetString( m_sContent, _rFlavor );
      55             : 
      56           0 :         return false;
      57             :     }
      58             : 
      59             : 
      60             :     //= OStringTransfer
      61             : 
      62             : 
      63           0 :     void OStringTransfer::CopyString( const OUString& _rContent, vcl::Window* _pWindow )
      64             :     {
      65           0 :         OStringTransferable* pTransferable = new OStringTransferable( _rContent );
      66           0 :         Reference< XTransferable > xTransfer = pTransferable;
      67           0 :         pTransferable->CopyToClipboard( _pWindow );
      68           0 :     }
      69             : 
      70             : 
      71           0 :     bool OStringTransfer::PasteString( OUString& _rContent, vcl::Window* _pWindow )
      72             :     {
      73           0 :         TransferableDataHelper aClipboardData = TransferableDataHelper::CreateFromSystemClipboard( _pWindow );
      74             : 
      75             :         // check for a string format
      76           0 :         const DataFlavorExVector& rFormats = aClipboardData.GetDataFlavorExVector();
      77           0 :         for (   DataFlavorExVector::const_iterator aSearch = rFormats.begin();
      78           0 :                 aSearch != rFormats.end();
      79             :                 ++aSearch
      80             :             )
      81             :         {
      82           0 :             if (SotClipboardFormatId::STRING == aSearch->mnSotId)
      83             :             {
      84           0 :                 OUString sContent;
      85           0 :                 bool bSuccess = aClipboardData.GetString( SotClipboardFormatId::STRING, sContent );
      86           0 :                 _rContent = sContent;
      87           0 :                 return bSuccess;
      88             :             }
      89             :         }
      90             : 
      91           0 :         return false;
      92             :     }
      93             : 
      94             : 
      95           0 :     void OStringTransfer::StartStringDrag( const OUString& _rContent, vcl::Window* _pWindow, sal_Int8 _nDragSourceActions )
      96             :     {
      97           0 :         OStringTransferable* pTransferable = new OStringTransferable( _rContent );
      98           0 :         Reference< XTransferable > xTransfer = pTransferable;
      99           0 :         pTransferable->StartDrag(_pWindow, _nDragSourceActions);
     100           0 :     }
     101             : 
     102             : 
     103             : }   // namespace svt
     104             : 
     105             : 
     106             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11