Bump version to 4.1-6
[LibreOffice.git] / dtrans / source / win32 / dtobj / XTDataObject.hxx
bloba8a87c692660ff4607e1a41f294306355ef8abae
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 _XTDATAOBJECT_HXX_
22 #define _XTDATAOBJECT_HXX_
24 #include <com/sun/star/datatransfer/XTransferable.hpp>
25 #include <com/sun/star/datatransfer/clipboard/XClipboardOwner.hpp>
27 #include "DataFmtTransl.hxx"
29 #include "FetcList.hxx"
31 #if defined _MSC_VER
32 #pragma warning(push,1)
33 #endif
34 #include <windows.h>
35 #include <ole2.h>
36 #include <objidl.h>
37 #if defined _MSC_VER
38 #pragma warning(pop)
39 #endif
41 /*--------------------------------------------------------------------------
42 - the function principle of the windows clipboard:
43 a data provider offers all formats he can deliver on the clipboard
44 a clipboard client ask for the available formats on the clipboard
45 and decides if there is a format he can use
46 if there is one, he requests the data in this format
48 - This class inherits from IDataObject an so can be placed on the
49 OleClipboard. The class wrapps a transferable object which is the
50 original DataSource
51 - DataFlavors offerd by this transferable will be translated into
52 appropriate clipboard formats
53 - if the transferable contains text data always text and unicodetext
54 will be offered or vice versa
55 - text data will be automaticaly converted between text und unicode text
56 - although the transferable may support text in different charsets
57 (codepages) only text in one codepage can be offered by the clipboard
59 ----------------------------------------------------------------------------*/
61 class CStgTransferHelper;
63 class CXTDataObject : public IDataObject
65 public:
66 CXTDataObject( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
67 const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& aXTransferable );
68 virtual ~CXTDataObject() {}
70 //-----------------------------------------------------------------
71 // ole interface implementation
72 //-----------------------------------------------------------------
74 //IUnknown interface methods
75 STDMETHODIMP QueryInterface(REFIID iid, LPVOID* ppvObject);
76 STDMETHODIMP_( ULONG ) AddRef( );
77 STDMETHODIMP_( ULONG ) Release( );
79 // IDataObject interface methods
80 STDMETHODIMP GetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium );
81 STDMETHODIMP GetDataHere( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium );
82 STDMETHODIMP QueryGetData( LPFORMATETC pFormatetc );
83 STDMETHODIMP GetCanonicalFormatEtc( LPFORMATETC pFormatectIn, LPFORMATETC pFormatetcOut );
84 STDMETHODIMP SetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium, BOOL fRelease );
85 STDMETHODIMP EnumFormatEtc( DWORD dwDirection, IEnumFORMATETC** ppenumFormatetc );
86 STDMETHODIMP DAdvise( LPFORMATETC pFormatetc, DWORD advf, LPADVISESINK pAdvSink, DWORD* pdwConnection );
87 STDMETHODIMP DUnadvise( DWORD dwConnection );
88 STDMETHODIMP EnumDAdvise( LPENUMSTATDATA* ppenumAdvise );
90 operator IDataObject*( );
92 private:
93 com::sun::star::datatransfer::DataFlavor SAL_CALL formatEtcToDataFlavor( const FORMATETC& aFormatEtc ) const;
95 void SAL_CALL renderDataAndSetupStgMedium( const sal_Int8* lpStorage,
96 const FORMATETC& fetc,
97 sal_uInt32 nInitStgSize,
98 sal_uInt32 nBytesToTransfer,
99 STGMEDIUM& stgmedium );
101 void SAL_CALL renderLocaleAndSetupStgMedium( FORMATETC& fetc, STGMEDIUM& stgmedium );
102 void SAL_CALL renderUnicodeAndSetupStgMedium( FORMATETC& fetc, STGMEDIUM& stgmedium );
103 void SAL_CALL renderAnyDataAndSetupStgMedium( FORMATETC& fetc, STGMEDIUM& stgmedium );
105 HRESULT SAL_CALL renderSynthesizedFormatAndSetupStgMedium( FORMATETC& fetc, STGMEDIUM& stgmedium );
106 void SAL_CALL renderSynthesizedUnicodeAndSetupStgMedium( FORMATETC& fetc, STGMEDIUM& stgmedium );
107 void SAL_CALL renderSynthesizedTextAndSetupStgMedium( FORMATETC& fetc, STGMEDIUM& stgmedium );
108 void SAL_CALL renderSynthesizedHtmlAndSetupStgMedium( FORMATETC& fetc, STGMEDIUM& stgmedium );
110 void SAL_CALL setupStgMedium( const FORMATETC& fetc,
111 CStgTransferHelper& stgTransHlp,
112 STGMEDIUM& stgmedium );
114 void validateFormatEtc( LPFORMATETC lpFormatEtc ) const;
115 void SAL_CALL invalidateStgMedium( STGMEDIUM& stgmedium ) const;
117 HRESULT SAL_CALL translateStgExceptionCode( HRESULT hr ) const;
119 inline void SAL_CALL InitializeFormatEtcContainer( );
121 private:
122 LONG m_nRefCnt;
123 ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > m_XTransferable;
124 CFormatEtcContainer m_FormatEtcContainer;
125 sal_Bool m_bFormatEtcContainerInitialized;
126 CDataFormatTranslator m_DataFormatTranslator;
127 CFormatRegistrar m_FormatRegistrar;
130 //------------------------------------------------------------------------
132 //------------------------------------------------------------------------
134 class CEnumFormatEtc : public IEnumFORMATETC
136 public:
137 CEnumFormatEtc( LPUNKNOWN lpUnkOuter, const CFormatEtcContainer& aFormatEtcContainer );
138 virtual ~CEnumFormatEtc() {}
140 // IUnknown
141 STDMETHODIMP QueryInterface( REFIID iid, LPVOID* ppvObject );
142 STDMETHODIMP_( ULONG ) AddRef( );
143 STDMETHODIMP_( ULONG ) Release( );
145 //IEnumFORMATETC
146 STDMETHODIMP Next( ULONG nRequested, LPFORMATETC lpDest, ULONG* lpFetched );
147 STDMETHODIMP Skip( ULONG celt );
148 STDMETHODIMP Reset( );
149 STDMETHODIMP Clone( IEnumFORMATETC** ppenum );
151 private:
152 LONG m_nRefCnt;
153 LPUNKNOWN m_lpUnkOuter;
154 CFormatEtcContainer m_FormatEtcContainer;
157 typedef CEnumFormatEtc *PCEnumFormatEtc;
159 #endif
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */