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 "transferable.hxx"
21
22 // ctor
23
CTransferable(wchar_t * dataString)24 CTransferable::CTransferable( wchar_t* dataString ) :
25 m_seqDFlv( 1 ),
26 m_Data( dataString )
27 {
28 DataFlavor df;
29
30 /*
31 df.MimeType = L"text/plain; charset=unicode";
32 df.DataType = cppu::UnoType<OUString>::get();
33
34 m_seqDFlv[0] = df;
35 */
36
37 //df.MimeType = L"text/plain; charset=windows1252";
38 df.MimeType = L"text/plain";
39 df.DataType = cppu::UnoType<Sequence< sal_Int8 >>::get();
40
41 m_seqDFlv[0] = df;
42 }
43
44 // getTransferData
45
getTransferData(const DataFlavor & aFlavor)46 Any SAL_CALL CTransferable::getTransferData( const DataFlavor& aFlavor )
47 throw(UnsupportedFlavorException, IOException, RuntimeException)
48 {
49 Any anyData;
50
51 /*if ( aFlavor == m_seqDFlv[0] )
52 {
53 anyData = makeAny( m_Data );
54 }
55 else*/ if ( aFlavor == m_seqDFlv[0] )
56 {
57 OString aStr( m_Data.getStr( ), m_Data.getLength( ), 1252 );
58 Sequence< sal_Int8 > sOfChars( aStr.getLength( ) );
59 sal_Int32 lenStr = aStr.getLength( );
60
61 for ( sal_Int32 i = 0; i < lenStr; ++i )
62 sOfChars[i] = aStr[i];
63
64 anyData = makeAny( sOfChars );
65 }
66
67 return anyData;
68 }
69
70 // getTransferDataFlavors
71
getTransferDataFlavors()72 Sequence< DataFlavor > SAL_CALL CTransferable::getTransferDataFlavors( )
73 throw(RuntimeException)
74 {
75 return m_seqDFlv;
76 }
77
78 // isDataFlavorSupported
79
isDataFlavorSupported(const DataFlavor & aFlavor)80 sal_Bool SAL_CALL CTransferable::isDataFlavorSupported( const DataFlavor& aFlavor )
81 throw(RuntimeException)
82 {
83 sal_Int32 nLength = m_seqDFlv.getLength( );
84 sal_Bool bRet = sal_False;
85
86 for ( sal_Int32 i = 0; i < nLength; ++i )
87 {
88 if ( m_seqDFlv[i] == aFlavor )
89 {
90 bRet = sal_True;
91 break;
92 }
93 }
94
95 return bRet;
96 }
97
98 // lostOwnership
99
lostOwnership(const Reference<XClipboard> & xClipboard,const Reference<XTransferable> & xTrans)100 void SAL_CALL CTransferable::lostOwnership( const Reference< XClipboard >& xClipboard, const Reference< XTransferable >& xTrans )
101 throw(RuntimeException)
102 {
103 }
104
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
106