1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 25 #ifndef _XTDATAOBJECT_HXX_ 26 #define _XTDATAOBJECT_HXX_ 27 28 29 //------------------------------------------------------------------------ 30 // includes 31 //------------------------------------------------------------------------ 32 33 #if defined _MSC_VER 34 #pragma warning(push,1) 35 #endif 36 #include <windows.h> 37 #include <ole2.h> 38 #include <objidl.h> 39 #if defined _MSC_VER 40 #pragma warning(pop) 41 #endif 42 43 #include <vector> 44 45 // forward declaration 46 //class CWinClipbImpl; 47 class EnumFormatEtc; 48 49 /*-------------------------------------------------------------------------- 50 - the function principle of the windows clipboard: 51 a data provider offers all formats he can deliver on the clipboard 52 a clipboard client ask for the available formats on the clipboard 53 and decides if there is a format he can use 54 if there is one, he requests the data in this format 55 56 - This class inherits from IDataObject an so can be placed on the 57 OleClipboard. The class wrapps a transferable object which is the 58 original DataSource 59 - DataFlavors offerd by this transferable will be translated into 60 appropriate clipboard formats 61 - if the transferable contains text data always text and unicodetext 62 will be offered or vice versa 63 - text data will be automaticaly converted between text und unicode text 64 - although the transferable may support text in different charsets 65 (codepages) only text in one codepage can be offered by the clipboard 66 67 ----------------------------------------------------------------------------*/ 68 69 class CXTDataObject : public IDataObject 70 { 71 public: 72 CXTDataObject( ); 73 74 //----------------------------------------------------------------- 75 // ole interface implementation 76 //----------------------------------------------------------------- 77 78 //IUnknown interface methods 79 STDMETHODIMP QueryInterface(REFIID iid, LPVOID* ppvObject); 80 STDMETHODIMP_( ULONG ) AddRef( ); 81 STDMETHODIMP_( ULONG ) Release( ); 82 83 // IDataObject interface methods 84 STDMETHODIMP GetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium ); 85 STDMETHODIMP GetDataHere( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium ); 86 STDMETHODIMP QueryGetData( LPFORMATETC pFormatetc ); 87 STDMETHODIMP GetCanonicalFormatEtc( LPFORMATETC pFormatectIn, LPFORMATETC pFormatetcOut ); 88 STDMETHODIMP SetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium, BOOL fRelease ); 89 STDMETHODIMP EnumFormatEtc( DWORD dwDirection, IEnumFORMATETC** ppenumFormatetc ); 90 STDMETHODIMP DAdvise( LPFORMATETC pFormatetc, DWORD advf, LPADVISESINK pAdvSink, DWORD* pdwConnection ); 91 STDMETHODIMP DUnadvise( DWORD dwConnection ); 92 STDMETHODIMP EnumDAdvise( LPENUMSTATDATA* ppenumAdvise ); 93 94 operator IDataObject*( ); 95 96 private: 97 98 private: 99 LONG m_nRefCnt; 100 }; 101 102 //------------------------------------------------------------------------ 103 // 104 //------------------------------------------------------------------------ 105 106 class CEnumFormatEtc : public IEnumFORMATETC 107 { 108 public: 109 CEnumFormatEtc( LPUNKNOWN pUnkDataObj ); 110 111 // IUnknown 112 STDMETHODIMP QueryInterface( REFIID iid, LPVOID* ppvObject ); 113 STDMETHODIMP_( ULONG ) AddRef( ); 114 STDMETHODIMP_( ULONG ) Release( ); 115 116 //IEnumFORMATETC 117 STDMETHODIMP Next( ULONG celt, LPFORMATETC rgelt, ULONG* pceltFetched ); 118 STDMETHODIMP Skip( ULONG celt ); 119 STDMETHODIMP Reset( ); 120 STDMETHODIMP Clone( IEnumFORMATETC** ppenum ); 121 122 private: 123 LONG m_nRefCnt; 124 LPUNKNOWN m_pUnkDataObj; 125 ULONG m_nCurrPos; 126 }; 127 128 typedef CEnumFormatEtc *PCEnumFormatEtc; 129 130 #endif 131