1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: DOTransferable.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 #ifndef _DOTRANSFERABLE_HXX_
33 #define _DOTRANSFERABLE_HXX_
35 //------------------------------------------------------------------------
37 //------------------------------------------------------------------------
39 #include <com/sun/star/datatransfer/XTransferable.hpp>
41 #ifndef _CPPUHELPER_IMPLBASE1_HXX_
42 #include <cppuhelper/implbase2.hxx>
44 #include "DataFmtTransl.hxx"
45 #include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp>
46 #include <com/sun/star/datatransfer/XMimeContentType.hpp>
47 #include <com/sun/star/datatransfer/XSystemTransferable.hpp>
49 #include <systools/win32/comtools.hxx>
51 //------------------------------------------------------------------------
53 //------------------------------------------------------------------------
56 class CDTransObjFactory
;
59 class CDOTransferable
: public ::cppu::WeakImplHelper2
< ::com::sun::star::datatransfer::XTransferable
,
60 ::com::sun::star::datatransfer::XSystemTransferable
>
63 typedef com::sun::star::uno::Sequence
< sal_Int8
> ByteSequence_t
;
65 //------------------------------------------------------------------------
67 //------------------------------------------------------------------------
69 virtual ::com::sun::star::uno::Any SAL_CALL
getTransferData( const ::com::sun::star::datatransfer::DataFlavor
& aFlavor
)
70 throw( ::com::sun::star::datatransfer::UnsupportedFlavorException
, ::com::sun::star::io::IOException
, ::com::sun::star::uno::RuntimeException
);
72 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::datatransfer::DataFlavor
> SAL_CALL
getTransferDataFlavors( )
73 throw( ::com::sun::star::uno::RuntimeException
);
75 virtual sal_Bool SAL_CALL
isDataFlavorSupported( const ::com::sun::star::datatransfer::DataFlavor
& aFlavor
)
76 throw( ::com::sun::star::uno::RuntimeException
);
77 //------------------------------------------------------------------------
78 // XSystemTransferable
79 //------------------------------------------------------------------------
80 virtual ::com::sun::star::uno::Any SAL_CALL
getData( const com::sun::star::uno::Sequence
<sal_Int8
>& aProcessId
) throw
81 (::com::sun::star::uno::RuntimeException
);
85 // should be created only by CDTransObjFactory
86 explicit CDOTransferable(
87 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& ServiceManager
,
88 IDataObjectPtr rDataObject
);
90 //------------------------------------------------------------------------
91 // some helper functions
92 //------------------------------------------------------------------------
94 void SAL_CALL
initFlavorList( );
96 void SAL_CALL
addSupportedFlavor( const com::sun::star::datatransfer::DataFlavor
& aFlavor
);
97 com::sun::star::datatransfer::DataFlavor SAL_CALL
formatEtcToDataFlavor( const FORMATETC
& aFormatEtc
);
99 ByteSequence_t SAL_CALL
getClipboardData( CFormatEtc
& aFormatEtc
);
100 rtl::OUString SAL_CALL
synthesizeUnicodeText( );
102 void SAL_CALL
clipDataToByteStream( CLIPFORMAT cf
, STGMEDIUM stgmedium
, ByteSequence_t
& aByteSequence
);
104 ::com::sun::star::uno::Any SAL_CALL
byteStreamToAny( ByteSequence_t
& aByteStream
, const com::sun::star::uno::Type
& aRequestedDataType
);
105 rtl::OUString SAL_CALL
byteStreamToOUString( ByteSequence_t
& aByteStream
);
107 LCID SAL_CALL
getLocaleFromClipboard( );
109 sal_Bool SAL_CALL
compareDataFlavors( const com::sun::star::datatransfer::DataFlavor
& lhs
,
110 const com::sun::star::datatransfer::DataFlavor
& rhs
);
112 sal_Bool SAL_CALL
cmpFullMediaType( 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;
115 sal_Bool SAL_CALL
cmpAllContentTypeParameter( const com::sun::star::uno::Reference
< com::sun::star::datatransfer::XMimeContentType
>& xLhs
,
116 const com::sun::star::uno::Reference
< com::sun::star::datatransfer::XMimeContentType
>& xRhs
) const;
119 IDataObjectPtr m_rDataObject
;
120 com::sun::star::uno::Sequence
< com::sun::star::datatransfer::DataFlavor
> m_FlavorList
;
121 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> m_SrvMgr
;
122 CDataFormatTranslator m_DataFormatTranslator
;
123 com::sun::star::uno::Reference
< com::sun::star::datatransfer::XMimeContentTypeFactory
> m_rXMimeCntFactory
;
124 ::osl::Mutex m_aMutex
;
125 sal_Bool m_bUnicodeRegistered
;
126 CLIPFORMAT m_TxtFormatOnClipboard
;
128 // non supported operations
130 CDOTransferable( const CDOTransferable
& );
131 CDOTransferable
& operator=( const CDOTransferable
& );
133 friend class CDTransObjFactory
;