1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_dtrans.hxx" 30 #include "transferable.hxx" 31 32 //---------------------------------------------------------------- 33 // ctor 34 //---------------------------------------------------------------- 35 36 37 38 CTransferable::CTransferable( wchar_t* dataString ) : 39 m_seqDFlv( 1 ), 40 m_Data( dataString ) 41 { 42 DataFlavor df; 43 44 /* 45 df.MimeType = L"text/plain; charset=unicode"; 46 df.DataType = getCppuType( ( OUString* )0 ); 47 48 m_seqDFlv[0] = df; 49 */ 50 51 //df.MimeType = L"text/plain; charset=windows1252"; 52 df.MimeType = L"text/plain"; 53 df.DataType = getCppuType( ( Sequence< sal_Int8 >* )0 ); 54 55 56 m_seqDFlv[0] = df; 57 } 58 59 //---------------------------------------------------------------- 60 // getTransferData 61 //---------------------------------------------------------------- 62 63 Any SAL_CALL CTransferable::getTransferData( const DataFlavor& aFlavor ) 64 throw(UnsupportedFlavorException, IOException, RuntimeException) 65 { 66 Any anyData; 67 68 /*if ( aFlavor == m_seqDFlv[0] ) 69 { 70 anyData = makeAny( m_Data ); 71 } 72 else*/ if ( aFlavor == m_seqDFlv[0] ) 73 { 74 OString aStr( m_Data.getStr( ), m_Data.getLength( ), 1252 ); 75 Sequence< sal_Int8 > sOfChars( aStr.getLength( ) ); 76 sal_Int32 lenStr = aStr.getLength( ); 77 78 for ( sal_Int32 i = 0; i < lenStr; ++i ) 79 sOfChars[i] = aStr[i]; 80 81 anyData = makeAny( sOfChars ); 82 } 83 84 return anyData; 85 } 86 87 //---------------------------------------------------------------- 88 // getTransferDataFlavors 89 //---------------------------------------------------------------- 90 91 Sequence< DataFlavor > SAL_CALL CTransferable::getTransferDataFlavors( ) 92 throw(RuntimeException) 93 { 94 return m_seqDFlv; 95 } 96 97 //---------------------------------------------------------------- 98 // isDataFlavorSupported 99 //---------------------------------------------------------------- 100 101 sal_Bool SAL_CALL CTransferable::isDataFlavorSupported( const DataFlavor& aFlavor ) 102 throw(RuntimeException) 103 { 104 sal_Int32 nLength = m_seqDFlv.getLength( ); 105 sal_Bool bRet = sal_False; 106 107 for ( sal_Int32 i = 0; i < nLength; ++i ) 108 { 109 if ( m_seqDFlv[i] == aFlavor ) 110 { 111 bRet = sal_True; 112 break; 113 } 114 } 115 116 return bRet; 117 } 118 119 //---------------------------------------------------------------- 120 // lostOwnership 121 //---------------------------------------------------------------- 122 123 void SAL_CALL CTransferable::lostOwnership( const Reference< XClipboard >& xClipboard, const Reference< XTransferable >& xTrans ) 124 throw(RuntimeException) 125 { 126 } 127