fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / svtools / source / misc / stringtransfer.cxx
blobeba7a5697c0ec113e44237fc6f9f4934417d574e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <svtools/stringtransfer.hxx>
22 //........................................................................
23 namespace svt
25 //........................................................................
27 using namespace ::com::sun::star::uno;
28 using namespace ::com::sun::star::datatransfer;
30 //====================================================================
31 //= OStringTransferable
32 //====================================================================
33 //--------------------------------------------------------------------
34 OStringTransferable::OStringTransferable(const OUString& _rContent)
35 :TransferableHelper()
36 ,m_sContent( _rContent )
40 //--------------------------------------------------------------------
41 void OStringTransferable::AddSupportedFormats()
43 AddFormat(SOT_FORMAT_STRING);
46 //--------------------------------------------------------------------
47 sal_Bool OStringTransferable::GetData( const DataFlavor& _rFlavor )
49 sal_uInt32 nFormat = SotExchange::GetFormat( _rFlavor );
50 if (SOT_FORMAT_STRING == nFormat)
51 return SetString( m_sContent, _rFlavor );
53 return sal_False;
56 //====================================================================
57 //= OStringTransfer
58 //====================================================================
59 //--------------------------------------------------------------------
60 void OStringTransfer::CopyString( const OUString& _rContent, Window* _pWindow )
62 OStringTransferable* pTransferable = new OStringTransferable( _rContent );
63 Reference< XTransferable > xTransfer = pTransferable;
64 pTransferable->CopyToClipboard( _pWindow );
67 //--------------------------------------------------------------------
68 sal_Bool OStringTransfer::PasteString( OUString& _rContent, Window* _pWindow )
70 TransferableDataHelper aClipboardData = TransferableDataHelper::CreateFromSystemClipboard( _pWindow );
72 // check for a string format
73 const DataFlavorExVector& rFormats = aClipboardData.GetDataFlavorExVector();
74 for ( DataFlavorExVector::const_iterator aSearch = rFormats.begin();
75 aSearch != rFormats.end();
76 ++aSearch
79 if (SOT_FORMAT_STRING == aSearch->mnSotId)
81 String sContent;
82 sal_Bool bSuccess = aClipboardData.GetString( SOT_FORMAT_STRING, sContent );
83 _rContent = sContent;
84 return bSuccess;
88 return sal_False;
91 //--------------------------------------------------------------------
92 void OStringTransfer::StartStringDrag( const OUString& _rContent, Window* _pWindow, sal_Int8 _nDragSourceActions )
94 OStringTransferable* pTransferable = new OStringTransferable( _rContent );
95 Reference< XTransferable > xTransfer = pTransferable;
96 pTransferable->StartDrag(_pWindow, _nDragSourceActions);
99 //........................................................................
100 } // namespace svt
101 //........................................................................
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */