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 29 #ifndef _DOTRANSFERABLE_HXX_ 30 #define _DOTRANSFERABLE_HXX_ 31 32 //------------------------------------------------------------------------ 33 // includes 34 //------------------------------------------------------------------------ 35 36 #include <com/sun/star/datatransfer/XTransferable.hpp> 37 38 #ifndef _CPPUHELPER_IMPLBASE1_HXX_ 39 #include <cppuhelper/implbase2.hxx> 40 #endif 41 #include "DataFmtTransl.hxx" 42 #include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp> 43 #include <com/sun/star/datatransfer/XMimeContentType.hpp> 44 #include <com/sun/star/datatransfer/XSystemTransferable.hpp> 45 46 #include <systools/win32/comtools.hxx> 47 48 //------------------------------------------------------------------------ 49 // deklarations 50 //------------------------------------------------------------------------ 51 52 // forward 53 class CDTransObjFactory; 54 class CFormatEtc; 55 56 class CDOTransferable : public ::cppu::WeakImplHelper2< ::com::sun::star::datatransfer::XTransferable, 57 ::com::sun::star::datatransfer::XSystemTransferable> 58 { 59 public: 60 typedef com::sun::star::uno::Sequence< sal_Int8 > ByteSequence_t; 61 62 //------------------------------------------------------------------------ 63 // XTransferable 64 //------------------------------------------------------------------------ 65 66 virtual ::com::sun::star::uno::Any SAL_CALL getTransferData( const ::com::sun::star::datatransfer::DataFlavor& aFlavor ) 67 throw( ::com::sun::star::datatransfer::UnsupportedFlavorException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException ); 68 69 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors( ) 70 throw( ::com::sun::star::uno::RuntimeException ); 71 72 virtual sal_Bool SAL_CALL isDataFlavorSupported( const ::com::sun::star::datatransfer::DataFlavor& aFlavor ) 73 throw( ::com::sun::star::uno::RuntimeException ); 74 //------------------------------------------------------------------------ 75 // XSystemTransferable 76 //------------------------------------------------------------------------ 77 virtual ::com::sun::star::uno::Any SAL_CALL getData( const com::sun::star::uno::Sequence<sal_Int8>& aProcessId ) throw 78 (::com::sun::star::uno::RuntimeException); 79 80 81 private: 82 // should be created only by CDTransObjFactory 83 explicit CDOTransferable( 84 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ServiceManager, 85 IDataObjectPtr rDataObject ); 86 87 //------------------------------------------------------------------------ 88 // some helper functions 89 //------------------------------------------------------------------------ 90 91 void SAL_CALL initFlavorList( ); 92 93 void SAL_CALL addSupportedFlavor( const com::sun::star::datatransfer::DataFlavor& aFlavor ); 94 com::sun::star::datatransfer::DataFlavor SAL_CALL formatEtcToDataFlavor( const FORMATETC& aFormatEtc ); 95 96 ByteSequence_t SAL_CALL getClipboardData( CFormatEtc& aFormatEtc ); 97 rtl::OUString SAL_CALL synthesizeUnicodeText( ); 98 99 void SAL_CALL clipDataToByteStream( CLIPFORMAT cf, STGMEDIUM stgmedium, ByteSequence_t& aByteSequence ); 100 101 ::com::sun::star::uno::Any SAL_CALL byteStreamToAny( ByteSequence_t& aByteStream, const com::sun::star::uno::Type& aRequestedDataType ); 102 rtl::OUString SAL_CALL byteStreamToOUString( ByteSequence_t& aByteStream ); 103 104 LCID SAL_CALL getLocaleFromClipboard( ); 105 106 sal_Bool SAL_CALL compareDataFlavors( const com::sun::star::datatransfer::DataFlavor& lhs, 107 const com::sun::star::datatransfer::DataFlavor& rhs ); 108 109 sal_Bool SAL_CALL cmpFullMediaType( const com::sun::star::uno::Reference< com::sun::star::datatransfer::XMimeContentType >& xLhs, 110 const com::sun::star::uno::Reference< com::sun::star::datatransfer::XMimeContentType >& xRhs ) const; 111 112 sal_Bool SAL_CALL cmpAllContentTypeParameter( const com::sun::star::uno::Reference< com::sun::star::datatransfer::XMimeContentType >& xLhs, 113 const com::sun::star::uno::Reference< com::sun::star::datatransfer::XMimeContentType >& xRhs ) const; 114 115 private: 116 IDataObjectPtr m_rDataObject; 117 com::sun::star::uno::Sequence< com::sun::star::datatransfer::DataFlavor > m_FlavorList; 118 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_SrvMgr; 119 CDataFormatTranslator m_DataFormatTranslator; 120 com::sun::star::uno::Reference< com::sun::star::datatransfer::XMimeContentTypeFactory > m_rXMimeCntFactory; 121 ::osl::Mutex m_aMutex; 122 sal_Bool m_bUnicodeRegistered; 123 CLIPFORMAT m_TxtFormatOnClipboard; 124 125 // non supported operations 126 private: 127 CDOTransferable( const CDOTransferable& ); 128 CDOTransferable& operator=( const CDOTransferable& ); 129 130 friend class CDTransObjFactory; 131 }; 132 133 #endif 134