xref: /AOO41X/main/dtrans/test/win32/dnd/transferable.cxx (revision 48123e16153c92857455f9e7a0d17cc19307983f)
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     throw(UnsupportedFlavorException, IOException, RuntimeException)
61 {
62     Any anyData;
63 
64     /*if ( aFlavor == m_seqDFlv[0] )
65     {
66         anyData = makeAny( m_Data );
67     }
68     else*/ if ( aFlavor == m_seqDFlv[0] )
69     {
70         OString aStr( m_Data.getStr( ), m_Data.getLength( ), 1252 );
71         Sequence< sal_Int8 > sOfChars( aStr.getLength( ) );
72         sal_Int32 lenStr = aStr.getLength( );
73 
74         for ( sal_Int32 i = 0; i < lenStr; ++i )
75             sOfChars[i] = aStr[i];
76 
77         anyData = makeAny( sOfChars );
78     }
79 
80     return anyData;
81 }
82 
83 //----------------------------------------------------------------
84 //  getTransferDataFlavors
85 //----------------------------------------------------------------
86 
getTransferDataFlavors()87 Sequence< DataFlavor > SAL_CALL CTransferable::getTransferDataFlavors(  )
88     throw(RuntimeException)
89 {
90     return m_seqDFlv;
91 }
92 
93 //----------------------------------------------------------------
94 //  isDataFlavorSupported
95 //----------------------------------------------------------------
96 
isDataFlavorSupported(const DataFlavor & aFlavor)97 sal_Bool SAL_CALL CTransferable::isDataFlavorSupported( const DataFlavor& aFlavor )
98     throw(RuntimeException)
99 {
100     sal_Int32 nLength = m_seqDFlv.getLength( );
101     sal_Bool bRet     = sal_False;
102 
103     for ( sal_Int32 i = 0; i < nLength; ++i )
104     {
105         if ( m_seqDFlv[i] == aFlavor )
106         {
107             bRet = sal_True;
108             break;
109         }
110     }
111 
112     return bRet;
113 }
114 
115 //----------------------------------------------------------------
116 //  lostOwnership
117 //----------------------------------------------------------------
118 
lostOwnership(const Reference<XClipboard> & xClipboard,const Reference<XTransferable> & xTrans)119 void SAL_CALL CTransferable::lostOwnership( const Reference< XClipboard >& xClipboard, const Reference< XTransferable >& xTrans )
120     throw(RuntimeException)
121 {
122 }
123