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 _XTDATAOBJECT_HXX_
30 #define _XTDATAOBJECT_HXX_
31 
32 
33 //------------------------------------------------------------------------
34 // includes
35 //------------------------------------------------------------------------
36 
37 #if defined _MSC_VER
38 #pragma warning(push,1)
39 #endif
40 #include <windows.h>
41 #include <ole2.h>
42 #include <objidl.h>
43 #if defined _MSC_VER
44 #pragma warning(pop)
45 #endif
46 
47 #include <vector>
48 
49 // forward declaration
50 //class CWinClipbImpl;
51 class EnumFormatEtc;
52 
53 /*--------------------------------------------------------------------------
54 	- the function principle of the windows clipboard:
55 	  a data provider offers all formats he can deliver on the clipboard
56 	  a clipboard client ask for the available formats on the clipboard
57 	  and decides if there is a format he can use
58 	  if there is one, he requests the data in this format
59 
60 	- This class inherits from IDataObject an so can be placed on the
61 	  OleClipboard. The class wrapps a transferable object which is the
62 	  original DataSource
63 	- DataFlavors offerd by this transferable will be translated into
64 	  appropriate clipboard formats
65 	- if the transferable contains text data always text and unicodetext
66 	  will be offered or vice versa
67 	- text data will be automaticaly converted between text und unicode text
68 	- although the transferable may support text in different charsets
69 	  (codepages) only text in one codepage can be offered by the clipboard
70 
71 ----------------------------------------------------------------------------*/
72 
73 class CXTDataObject : public IDataObject
74 {
75 public:
76 	CXTDataObject( );
77 
78 	//-----------------------------------------------------------------
79 	// ole interface implementation
80 	//-----------------------------------------------------------------
81 
82     //IUnknown interface methods
83     STDMETHODIMP           QueryInterface(REFIID iid, LPVOID* ppvObject);
84     STDMETHODIMP_( ULONG ) AddRef( );
85     STDMETHODIMP_( ULONG ) Release( );
86 
87     // IDataObject interface methods
88     STDMETHODIMP GetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium );
89     STDMETHODIMP GetDataHere( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium );
90     STDMETHODIMP QueryGetData( LPFORMATETC pFormatetc );
91     STDMETHODIMP GetCanonicalFormatEtc( LPFORMATETC pFormatectIn, LPFORMATETC pFormatetcOut );
92     STDMETHODIMP SetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium, BOOL fRelease );
93     STDMETHODIMP EnumFormatEtc( DWORD dwDirection, IEnumFORMATETC** ppenumFormatetc );
94     STDMETHODIMP DAdvise( LPFORMATETC pFormatetc, DWORD advf, LPADVISESINK pAdvSink, DWORD* pdwConnection );
95     STDMETHODIMP DUnadvise( DWORD dwConnection );
96     STDMETHODIMP EnumDAdvise( LPENUMSTATDATA* ppenumAdvise );
97 
98 	operator IDataObject*( );
99 
100 private:
101 
102 private:
103 	LONG m_nRefCnt;
104 };
105 
106 //------------------------------------------------------------------------
107 //
108 //------------------------------------------------------------------------
109 
110 class CEnumFormatEtc : public IEnumFORMATETC
111 {
112 public:
113 	CEnumFormatEtc( LPUNKNOWN pUnkDataObj );
114 
115     // IUnknown
116     STDMETHODIMP           QueryInterface( REFIID iid, LPVOID* ppvObject );
117     STDMETHODIMP_( ULONG ) AddRef( );
118     STDMETHODIMP_( ULONG ) Release( );
119 
120     //IEnumFORMATETC
121     STDMETHODIMP Next( ULONG celt, LPFORMATETC rgelt, ULONG* pceltFetched );
122     STDMETHODIMP Skip( ULONG celt );
123     STDMETHODIMP Reset( );
124     STDMETHODIMP Clone( IEnumFORMATETC** ppenum );
125 
126 private:
127 	LONG								m_nRefCnt;
128 	LPUNKNOWN							m_pUnkDataObj;
129     ULONG								m_nCurrPos;
130 };
131 
132 typedef CEnumFormatEtc *PCEnumFormatEtc;
133 
134 #endif
135