Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / dtrans / test / win32 / dnd / transferable.cxx
blob924c031763b5a0c31a758bc7c2640278660e1a9a
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 "transferable.hxx"
22 // ctor
24 CTransferable::CTransferable( wchar_t* dataString ) :
25 m_seqDFlv( 1 ),
26 m_Data( dataString )
28 DataFlavor df;
31 df.MimeType = L"text/plain; charset=unicode";
32 df.DataType = cppu::UnoType<OUString>::get();
34 m_seqDFlv[0] = df;
37 //df.MimeType = L"text/plain; charset=windows1252";
38 df.MimeType = L"text/plain";
39 df.DataType = cppu::UnoType<Sequence< sal_Int8 >>::get();
41 m_seqDFlv[0] = df;
44 // getTransferData
46 Any SAL_CALL CTransferable::getTransferData( const DataFlavor& aFlavor )
47 throw(UnsupportedFlavorException, IOException, RuntimeException)
49 Any anyData;
51 /*if ( aFlavor == m_seqDFlv[0] )
53 anyData = makeAny( m_Data );
55 else*/ if ( aFlavor == m_seqDFlv[0] )
57 OString aStr( m_Data.getStr( ), m_Data.getLength( ), 1252 );
58 Sequence< sal_Int8 > sOfChars( aStr.getLength( ) );
59 sal_Int32 lenStr = aStr.getLength( );
61 for ( sal_Int32 i = 0; i < lenStr; ++i )
62 sOfChars[i] = aStr[i];
64 anyData = makeAny( sOfChars );
67 return anyData;
70 // getTransferDataFlavors
72 Sequence< DataFlavor > SAL_CALL CTransferable::getTransferDataFlavors( )
73 throw(RuntimeException)
75 return m_seqDFlv;
78 // isDataFlavorSupported
80 sal_Bool SAL_CALL CTransferable::isDataFlavorSupported( const DataFlavor& aFlavor )
81 throw(RuntimeException)
83 sal_Int32 nLength = m_seqDFlv.getLength( );
84 sal_Bool bRet = sal_False;
86 for ( sal_Int32 i = 0; i < nLength; ++i )
88 if ( m_seqDFlv[i] == aFlavor )
90 bRet = sal_True;
91 break;
95 return bRet;
98 // lostOwnership
100 void SAL_CALL CTransferable::lostOwnership( const Reference< XClipboard >& xClipboard, const Reference< XTransferable >& xTrans )
101 throw(RuntimeException)
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */