xref: /aoo41x/main/dtrans/source/win32/dtobj/Fetc.cxx (revision 48123e16)
1*48123e16SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*48123e16SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*48123e16SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*48123e16SAndrew Rist  * distributed with this work for additional information
6*48123e16SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*48123e16SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*48123e16SAndrew Rist  * "License"); you may not use this file except in compliance
9*48123e16SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*48123e16SAndrew Rist  *
11*48123e16SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*48123e16SAndrew Rist  *
13*48123e16SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*48123e16SAndrew Rist  * software distributed under the License is distributed on an
15*48123e16SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*48123e16SAndrew Rist  * KIND, either express or implied.  See the License for the
17*48123e16SAndrew Rist  * specific language governing permissions and limitations
18*48123e16SAndrew Rist  * under the License.
19*48123e16SAndrew Rist  *
20*48123e16SAndrew Rist  *************************************************************/
21*48123e16SAndrew Rist 
22*48123e16SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_dtrans.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir //------------------------------------------------------------------------
28cdf0e10cSrcweir // includes
29cdf0e10cSrcweir //------------------------------------------------------------------------
30cdf0e10cSrcweir #include <osl/diagnose.h>
31cdf0e10cSrcweir #include "Fetc.hxx"
32cdf0e10cSrcweir #include "..\misc\ImplHelper.hxx"
33cdf0e10cSrcweir 
34cdf0e10cSrcweir //------------------------------------------------------------------------
35cdf0e10cSrcweir //
36cdf0e10cSrcweir //------------------------------------------------------------------------
37cdf0e10cSrcweir 
CFormatEtc()38cdf0e10cSrcweir CFormatEtc::CFormatEtc(  )
39cdf0e10cSrcweir {
40cdf0e10cSrcweir 	m_FormatEtc.cfFormat = 0;
41cdf0e10cSrcweir 	m_FormatEtc.ptd      = NULL;
42cdf0e10cSrcweir 	m_FormatEtc.dwAspect = 0;
43cdf0e10cSrcweir 	m_FormatEtc.lindex   = -1;
44cdf0e10cSrcweir 	m_FormatEtc.tymed    = TYMED_NULL;
45cdf0e10cSrcweir }
46cdf0e10cSrcweir 
47cdf0e10cSrcweir //------------------------------------------------------------------------
48cdf0e10cSrcweir // transfer of ownership
49cdf0e10cSrcweir //------------------------------------------------------------------------
50cdf0e10cSrcweir 
CFormatEtc(const FORMATETC & aFormatEtc)51cdf0e10cSrcweir CFormatEtc::CFormatEtc( const FORMATETC& aFormatEtc )
52cdf0e10cSrcweir {
53cdf0e10cSrcweir 	CopyFormatEtc( &m_FormatEtc, &const_cast< FORMATETC& >( aFormatEtc ) );
54cdf0e10cSrcweir }
55cdf0e10cSrcweir 
56cdf0e10cSrcweir //------------------------------------------------------------------------
57cdf0e10cSrcweir //
58cdf0e10cSrcweir //------------------------------------------------------------------------
59cdf0e10cSrcweir 
~CFormatEtc()60cdf0e10cSrcweir CFormatEtc::~CFormatEtc( )
61cdf0e10cSrcweir {
62cdf0e10cSrcweir 	DeleteTargetDevice( m_FormatEtc.ptd );
63cdf0e10cSrcweir }
64cdf0e10cSrcweir 
65cdf0e10cSrcweir //------------------------------------------------------------------------
66cdf0e10cSrcweir //
67cdf0e10cSrcweir //------------------------------------------------------------------------
68cdf0e10cSrcweir 
CFormatEtc(CLIPFORMAT cf,DWORD tymed,DVTARGETDEVICE * ptd,DWORD dwAspect,LONG lindex)69cdf0e10cSrcweir CFormatEtc::CFormatEtc( CLIPFORMAT cf, DWORD tymed, DVTARGETDEVICE* ptd, DWORD dwAspect, LONG lindex )
70cdf0e10cSrcweir {
71cdf0e10cSrcweir 	m_FormatEtc.cfFormat = cf;
72cdf0e10cSrcweir 	m_FormatEtc.ptd      = CopyTargetDevice( ptd );
73cdf0e10cSrcweir 	m_FormatEtc.dwAspect = dwAspect;
74cdf0e10cSrcweir 	m_FormatEtc.lindex   = lindex;
75cdf0e10cSrcweir 	m_FormatEtc.tymed    = tymed;
76cdf0e10cSrcweir }
77cdf0e10cSrcweir 
78cdf0e10cSrcweir //------------------------------------------------------------------------
79cdf0e10cSrcweir //
80cdf0e10cSrcweir //------------------------------------------------------------------------
81cdf0e10cSrcweir 
CFormatEtc(const CFormatEtc & theOther)82cdf0e10cSrcweir CFormatEtc::CFormatEtc( const CFormatEtc& theOther )
83cdf0e10cSrcweir {
84cdf0e10cSrcweir 	m_FormatEtc.cfFormat = theOther.m_FormatEtc.cfFormat;
85cdf0e10cSrcweir 	m_FormatEtc.ptd      = CopyTargetDevice( theOther.m_FormatEtc.ptd );
86cdf0e10cSrcweir 	m_FormatEtc.dwAspect = theOther.m_FormatEtc.dwAspect;
87cdf0e10cSrcweir 	m_FormatEtc.lindex   = theOther.m_FormatEtc.lindex;
88cdf0e10cSrcweir 	m_FormatEtc.tymed    = theOther.m_FormatEtc.tymed;
89cdf0e10cSrcweir }
90cdf0e10cSrcweir 
91cdf0e10cSrcweir //------------------------------------------------------------------------
92cdf0e10cSrcweir //
93cdf0e10cSrcweir //------------------------------------------------------------------------
94cdf0e10cSrcweir 
operator =(const CFormatEtc & theOther)95cdf0e10cSrcweir CFormatEtc& CFormatEtc::operator=( const CFormatEtc& theOther )
96cdf0e10cSrcweir {
97cdf0e10cSrcweir 	if ( this != &theOther )
98cdf0e10cSrcweir 	{
99cdf0e10cSrcweir 		DeleteTargetDevice( m_FormatEtc.ptd );
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 		m_FormatEtc.cfFormat = theOther.m_FormatEtc.cfFormat;
102cdf0e10cSrcweir 		m_FormatEtc.ptd      = CopyTargetDevice( theOther.m_FormatEtc.ptd );
103cdf0e10cSrcweir 		m_FormatEtc.dwAspect = theOther.m_FormatEtc.dwAspect;
104cdf0e10cSrcweir 		m_FormatEtc.lindex   = theOther.m_FormatEtc.lindex;
105cdf0e10cSrcweir 		m_FormatEtc.tymed    = theOther.m_FormatEtc.tymed;
106cdf0e10cSrcweir 	}
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 	return *this;
109cdf0e10cSrcweir }
110cdf0e10cSrcweir 
111cdf0e10cSrcweir //------------------------------------------------------------------------
112cdf0e10cSrcweir //
113cdf0e10cSrcweir //------------------------------------------------------------------------
114cdf0e10cSrcweir 
operator FORMATETC*()115cdf0e10cSrcweir CFormatEtc::operator FORMATETC*( )
116cdf0e10cSrcweir {
117cdf0e10cSrcweir 	return &m_FormatEtc;
118cdf0e10cSrcweir }
119cdf0e10cSrcweir 
120cdf0e10cSrcweir //------------------------------------------------------------------------
121cdf0e10cSrcweir //
122cdf0e10cSrcweir //------------------------------------------------------------------------
123cdf0e10cSrcweir 
operator FORMATETC()124cdf0e10cSrcweir CFormatEtc::operator FORMATETC( )
125cdf0e10cSrcweir {
126cdf0e10cSrcweir 	return m_FormatEtc;
127cdf0e10cSrcweir }
128cdf0e10cSrcweir 
129cdf0e10cSrcweir //------------------------------------------------------------------------
130cdf0e10cSrcweir //
131cdf0e10cSrcweir //------------------------------------------------------------------------
132cdf0e10cSrcweir 
getFORMATETC(LPFORMATETC lpFormatEtc)133cdf0e10cSrcweir void CFormatEtc::getFORMATETC( LPFORMATETC lpFormatEtc )
134cdf0e10cSrcweir {
135cdf0e10cSrcweir 	OSL_ASSERT( lpFormatEtc );
136cdf0e10cSrcweir 	OSL_ASSERT( !IsBadWritePtr( lpFormatEtc, sizeof( FORMATETC ) ) );
137cdf0e10cSrcweir 
138cdf0e10cSrcweir 	CopyFormatEtc( lpFormatEtc, &m_FormatEtc );
139cdf0e10cSrcweir }
140cdf0e10cSrcweir 
141cdf0e10cSrcweir //------------------------------------------------------------------------
142cdf0e10cSrcweir //
143cdf0e10cSrcweir //------------------------------------------------------------------------
144cdf0e10cSrcweir 
getClipformat() const145cdf0e10cSrcweir CLIPFORMAT CFormatEtc::getClipformat( ) const
146cdf0e10cSrcweir {
147cdf0e10cSrcweir 	return m_FormatEtc.cfFormat;
148cdf0e10cSrcweir }
149cdf0e10cSrcweir 
150cdf0e10cSrcweir //------------------------------------------------------------------------
151cdf0e10cSrcweir //
152cdf0e10cSrcweir //------------------------------------------------------------------------
153cdf0e10cSrcweir 
getTymed() const154cdf0e10cSrcweir DWORD CFormatEtc::getTymed( ) const
155cdf0e10cSrcweir {
156cdf0e10cSrcweir 	return m_FormatEtc.tymed;
157cdf0e10cSrcweir }
158cdf0e10cSrcweir 
159cdf0e10cSrcweir //------------------------------------------------------------------------
160cdf0e10cSrcweir //
161cdf0e10cSrcweir //------------------------------------------------------------------------
162cdf0e10cSrcweir 
getTargetDevice(DVTARGETDEVICE ** lpDvTargetDevice) const163cdf0e10cSrcweir void CFormatEtc::getTargetDevice( DVTARGETDEVICE** lpDvTargetDevice ) const
164cdf0e10cSrcweir {
165cdf0e10cSrcweir 	OSL_ASSERT( lpDvTargetDevice );
166cdf0e10cSrcweir 	OSL_ASSERT( !IsBadWritePtr( lpDvTargetDevice, sizeof( DVTARGETDEVICE ) ) );
167cdf0e10cSrcweir 
168cdf0e10cSrcweir 	*lpDvTargetDevice = NULL;
169cdf0e10cSrcweir 
170cdf0e10cSrcweir 	if ( m_FormatEtc.ptd )
171cdf0e10cSrcweir 		*lpDvTargetDevice = CopyTargetDevice( m_FormatEtc.ptd );
172cdf0e10cSrcweir }
173cdf0e10cSrcweir 
174cdf0e10cSrcweir //------------------------------------------------------------------------
175cdf0e10cSrcweir //
176cdf0e10cSrcweir //------------------------------------------------------------------------
177cdf0e10cSrcweir 
getDvAspect() const178cdf0e10cSrcweir DWORD CFormatEtc::getDvAspect( ) const
179cdf0e10cSrcweir {
180cdf0e10cSrcweir 	return m_FormatEtc.dwAspect;
181cdf0e10cSrcweir }
182cdf0e10cSrcweir 
183cdf0e10cSrcweir //------------------------------------------------------------------------
184cdf0e10cSrcweir //
185cdf0e10cSrcweir //------------------------------------------------------------------------
186cdf0e10cSrcweir 
getLindex() const187cdf0e10cSrcweir LONG CFormatEtc::getLindex( ) const
188cdf0e10cSrcweir {
189cdf0e10cSrcweir 	return m_FormatEtc.lindex;
190cdf0e10cSrcweir }
191cdf0e10cSrcweir 
192cdf0e10cSrcweir //------------------------------------------------------------------------
193cdf0e10cSrcweir //
194cdf0e10cSrcweir //------------------------------------------------------------------------
195cdf0e10cSrcweir 
setClipformat(CLIPFORMAT cf)196cdf0e10cSrcweir void CFormatEtc::setClipformat( CLIPFORMAT cf )
197cdf0e10cSrcweir {
198cdf0e10cSrcweir 	m_FormatEtc.cfFormat = cf;
199cdf0e10cSrcweir }
200cdf0e10cSrcweir 
201cdf0e10cSrcweir //------------------------------------------------------------------------
202cdf0e10cSrcweir //
203cdf0e10cSrcweir //------------------------------------------------------------------------
204cdf0e10cSrcweir 
setTymed(DWORD tymed)205cdf0e10cSrcweir void CFormatEtc::setTymed( DWORD tymed )
206cdf0e10cSrcweir {
207cdf0e10cSrcweir 	m_FormatEtc.tymed = tymed;
208cdf0e10cSrcweir }
209cdf0e10cSrcweir 
210cdf0e10cSrcweir //------------------------------------------------------------------------
211cdf0e10cSrcweir // transfer of ownership!
212cdf0e10cSrcweir //------------------------------------------------------------------------
213cdf0e10cSrcweir 
setTargetDevice(DVTARGETDEVICE * ptd)214cdf0e10cSrcweir void CFormatEtc::setTargetDevice( DVTARGETDEVICE* ptd )
215cdf0e10cSrcweir {
216cdf0e10cSrcweir 	DeleteTargetDevice( m_FormatEtc.ptd );
217cdf0e10cSrcweir 	m_FormatEtc.ptd = ptd;
218cdf0e10cSrcweir }
219cdf0e10cSrcweir 
220cdf0e10cSrcweir //------------------------------------------------------------------------
221cdf0e10cSrcweir //
222cdf0e10cSrcweir //------------------------------------------------------------------------
223cdf0e10cSrcweir 
setDvAspect(DWORD dwAspect)224cdf0e10cSrcweir void CFormatEtc::setDvAspect( DWORD dwAspect )
225cdf0e10cSrcweir {
226cdf0e10cSrcweir 	m_FormatEtc.dwAspect = dwAspect;
227cdf0e10cSrcweir }
228cdf0e10cSrcweir 
229cdf0e10cSrcweir //------------------------------------------------------------------------
230cdf0e10cSrcweir //
231cdf0e10cSrcweir //------------------------------------------------------------------------
232cdf0e10cSrcweir 
setLindex(LONG lindex)233cdf0e10cSrcweir void CFormatEtc::setLindex( LONG lindex )
234cdf0e10cSrcweir {
235cdf0e10cSrcweir 	m_FormatEtc.lindex = lindex;
236cdf0e10cSrcweir }
237cdf0e10cSrcweir 
238cdf0e10cSrcweir //------------------------------------------------------------------------
239cdf0e10cSrcweir //
240cdf0e10cSrcweir //------------------------------------------------------------------------
241cdf0e10cSrcweir 
operator ==(const CFormatEtc & lhs,const CFormatEtc & rhs)242cdf0e10cSrcweir sal_Int32 operator==( const CFormatEtc& lhs, const CFormatEtc& rhs )
243cdf0e10cSrcweir {
244cdf0e10cSrcweir 	return CompareFormatEtc( &lhs.m_FormatEtc, &rhs.m_FormatEtc );
245cdf0e10cSrcweir }
246cdf0e10cSrcweir 
247cdf0e10cSrcweir //------------------------------------------------------------------------
248cdf0e10cSrcweir //
249cdf0e10cSrcweir //------------------------------------------------------------------------
250cdf0e10cSrcweir 
operator !=(const CFormatEtc & lhs,const CFormatEtc & rhs)251cdf0e10cSrcweir sal_Int32 operator!=( const CFormatEtc& lhs, const CFormatEtc& rhs )
252cdf0e10cSrcweir {
253cdf0e10cSrcweir 	return ( ( lhs == rhs ) != 1 );
254cdf0e10cSrcweir }
255cdf0e10cSrcweir 
256