1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #ifndef _DOTRANSFERABLE_HXX_
22 #define _DOTRANSFERABLE_HXX_
24 #include <com/sun/star/datatransfer/XTransferable.hpp>
26 #include <cppuhelper/implbase2.hxx>
27 #include "DataFmtTransl.hxx"
28 #include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp>
29 #include <com/sun/star/datatransfer/XMimeContentType.hpp>
30 #include <com/sun/star/datatransfer/XSystemTransferable.hpp>
32 #include <systools/win32/comtools.hxx>
35 class CDTransObjFactory
;
38 class CDOTransferable
: public ::cppu::WeakImplHelper2
< ::com::sun::star::datatransfer::XTransferable
,
39 ::com::sun::star::datatransfer::XSystemTransferable
>
42 typedef com::sun::star::uno::Sequence
< sal_Int8
> ByteSequence_t
;
44 //------------------------------------------------------------------------
46 //------------------------------------------------------------------------
48 virtual ::com::sun::star::uno::Any SAL_CALL
getTransferData( const ::com::sun::star::datatransfer::DataFlavor
& aFlavor
)
49 throw( ::com::sun::star::datatransfer::UnsupportedFlavorException
, ::com::sun::star::io::IOException
, ::com::sun::star::uno::RuntimeException
);
51 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::datatransfer::DataFlavor
> SAL_CALL
getTransferDataFlavors( )
52 throw( ::com::sun::star::uno::RuntimeException
);
54 virtual sal_Bool SAL_CALL
isDataFlavorSupported( const ::com::sun::star::datatransfer::DataFlavor
& aFlavor
)
55 throw( ::com::sun::star::uno::RuntimeException
);
56 //------------------------------------------------------------------------
57 // XSystemTransferable
58 //------------------------------------------------------------------------
59 virtual ::com::sun::star::uno::Any SAL_CALL
getData( const com::sun::star::uno::Sequence
<sal_Int8
>& aProcessId
) throw
60 (::com::sun::star::uno::RuntimeException
);
64 // should be created only by CDTransObjFactory
65 explicit CDOTransferable(
66 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& rxContext
,
67 IDataObjectPtr rDataObject
);
69 //------------------------------------------------------------------------
70 // some helper functions
71 //------------------------------------------------------------------------
73 void SAL_CALL
initFlavorList( );
75 void SAL_CALL
addSupportedFlavor( const com::sun::star::datatransfer::DataFlavor
& aFlavor
);
76 com::sun::star::datatransfer::DataFlavor SAL_CALL
formatEtcToDataFlavor( const FORMATETC
& aFormatEtc
);
78 ByteSequence_t SAL_CALL
getClipboardData( CFormatEtc
& aFormatEtc
);
79 OUString SAL_CALL
synthesizeUnicodeText( );
81 void SAL_CALL
clipDataToByteStream( CLIPFORMAT cf
, STGMEDIUM stgmedium
, ByteSequence_t
& aByteSequence
);
83 ::com::sun::star::uno::Any SAL_CALL
byteStreamToAny( ByteSequence_t
& aByteStream
, const com::sun::star::uno::Type
& aRequestedDataType
);
84 OUString SAL_CALL
byteStreamToOUString( ByteSequence_t
& aByteStream
);
86 LCID SAL_CALL
getLocaleFromClipboard( );
88 sal_Bool SAL_CALL
compareDataFlavors( const com::sun::star::datatransfer::DataFlavor
& lhs
,
89 const com::sun::star::datatransfer::DataFlavor
& rhs
);
91 sal_Bool SAL_CALL
cmpFullMediaType( const com::sun::star::uno::Reference
< com::sun::star::datatransfer::XMimeContentType
>& xLhs
,
92 const com::sun::star::uno::Reference
< com::sun::star::datatransfer::XMimeContentType
>& xRhs
) const;
94 sal_Bool SAL_CALL
cmpAllContentTypeParameter( const com::sun::star::uno::Reference
< com::sun::star::datatransfer::XMimeContentType
>& xLhs
,
95 const com::sun::star::uno::Reference
< com::sun::star::datatransfer::XMimeContentType
>& xRhs
) const;
98 IDataObjectPtr m_rDataObject
;
99 com::sun::star::uno::Sequence
< com::sun::star::datatransfer::DataFlavor
> m_FlavorList
;
100 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> m_xContext
;
101 CDataFormatTranslator m_DataFormatTranslator
;
102 com::sun::star::uno::Reference
< com::sun::star::datatransfer::XMimeContentTypeFactory
> m_rXMimeCntFactory
;
103 ::osl::Mutex m_aMutex
;
104 sal_Bool m_bUnicodeRegistered
;
105 CLIPFORMAT m_TxtFormatOnClipboard
;
107 // non supported operations
109 CDOTransferable( const CDOTransferable
& );
110 CDOTransferable
& operator=( const CDOTransferable
& );
112 friend class CDTransObjFactory
;
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */