1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_dtrans.hxx"
26 #include "transferable.hxx"
27
28 //----------------------------------------------------------------
29 // ctor
30 //----------------------------------------------------------------
31
32
33
CTransferable(wchar_t * dataString)34 CTransferable::CTransferable( wchar_t* dataString ) :
35 m_seqDFlv( 1 ),
36 m_Data( dataString )
37 {
38 DataFlavor df;
39
40 /*
41 df.MimeType = L"text/plain; charset=unicode";
42 df.DataType = getCppuType( ( OUString* )0 );
43
44 m_seqDFlv[0] = df;
45 */
46
47 //df.MimeType = L"text/plain; charset=windows1252";
48 df.MimeType = L"text/plain";
49 df.DataType = getCppuType( ( Sequence< sal_Int8 >* )0 );
50
51
52 m_seqDFlv[0] = df;
53 }
54
55 //----------------------------------------------------------------
56 // getTransferData
57 //----------------------------------------------------------------
58
getTransferData(const DataFlavor & aFlavor)59 Any SAL_CALL CTransferable::getTransferData( const DataFlavor& aFlavor )
60 {
61 Any anyData;
62
63 /*if ( aFlavor == m_seqDFlv[0] )
64 {
65 anyData = makeAny( m_Data );
66 }
67 else*/ if ( aFlavor == m_seqDFlv[0] )
68 {
69 OString aStr( m_Data.getStr( ), m_Data.getLength( ), 1252 );
70 Sequence< sal_Int8 > sOfChars( aStr.getLength( ) );
71 sal_Int32 lenStr = aStr.getLength( );
72
73 for ( sal_Int32 i = 0; i < lenStr; ++i )
74 sOfChars[i] = aStr[i];
75
76 anyData = makeAny( sOfChars );
77 }
78
79 return anyData;
80 }
81
82 //----------------------------------------------------------------
83 // getTransferDataFlavors
84 //----------------------------------------------------------------
85
getTransferDataFlavors()86 Sequence< DataFlavor > SAL_CALL CTransferable::getTransferDataFlavors( )
87 {
88 return m_seqDFlv;
89 }
90
91 //----------------------------------------------------------------
92 // isDataFlavorSupported
93 //----------------------------------------------------------------
94
isDataFlavorSupported(const DataFlavor & aFlavor)95 sal_Bool SAL_CALL CTransferable::isDataFlavorSupported( const DataFlavor& aFlavor )
96 {
97 sal_Int32 nLength = m_seqDFlv.getLength( );
98 sal_Bool bRet = sal_False;
99
100 for ( sal_Int32 i = 0; i < nLength; ++i )
101 {
102 if ( m_seqDFlv[i] == aFlavor )
103 {
104 bRet = sal_True;
105 break;
106 }
107 }
108
109 return bRet;
110 }
111
112 //----------------------------------------------------------------
113 // lostOwnership
114 //----------------------------------------------------------------
115
lostOwnership(const Reference<XClipboard> & xClipboard,const Reference<XTransferable> & xTrans)116 void SAL_CALL CTransferable::lostOwnership( const Reference< XClipboard >& xClipboard, const Reference< XTransferable >& xTrans )
117 {
118 }
119