1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: Fetc.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dtrans.hxx"
34 //------------------------------------------------------------------------
36 //------------------------------------------------------------------------
37 #include <osl/diagnose.h>
39 #include "..\misc\ImplHelper.hxx"
41 //------------------------------------------------------------------------
43 //------------------------------------------------------------------------
45 CFormatEtc::CFormatEtc( )
47 m_FormatEtc
.cfFormat
= 0;
48 m_FormatEtc
.ptd
= NULL
;
49 m_FormatEtc
.dwAspect
= 0;
50 m_FormatEtc
.lindex
= -1;
51 m_FormatEtc
.tymed
= TYMED_NULL
;
54 //------------------------------------------------------------------------
55 // transfer of ownership
56 //------------------------------------------------------------------------
58 CFormatEtc::CFormatEtc( const FORMATETC
& aFormatEtc
)
60 CopyFormatEtc( &m_FormatEtc
, &const_cast< FORMATETC
& >( aFormatEtc
) );
63 //------------------------------------------------------------------------
65 //------------------------------------------------------------------------
67 CFormatEtc::~CFormatEtc( )
69 DeleteTargetDevice( m_FormatEtc
.ptd
);
72 //------------------------------------------------------------------------
74 //------------------------------------------------------------------------
76 CFormatEtc::CFormatEtc( CLIPFORMAT cf
, DWORD tymed
, DVTARGETDEVICE
* ptd
, DWORD dwAspect
, LONG lindex
)
78 m_FormatEtc
.cfFormat
= cf
;
79 m_FormatEtc
.ptd
= CopyTargetDevice( ptd
);
80 m_FormatEtc
.dwAspect
= dwAspect
;
81 m_FormatEtc
.lindex
= lindex
;
82 m_FormatEtc
.tymed
= tymed
;
85 //------------------------------------------------------------------------
87 //------------------------------------------------------------------------
89 CFormatEtc::CFormatEtc( const CFormatEtc
& theOther
)
91 m_FormatEtc
.cfFormat
= theOther
.m_FormatEtc
.cfFormat
;
92 m_FormatEtc
.ptd
= CopyTargetDevice( theOther
.m_FormatEtc
.ptd
);
93 m_FormatEtc
.dwAspect
= theOther
.m_FormatEtc
.dwAspect
;
94 m_FormatEtc
.lindex
= theOther
.m_FormatEtc
.lindex
;
95 m_FormatEtc
.tymed
= theOther
.m_FormatEtc
.tymed
;
98 //------------------------------------------------------------------------
100 //------------------------------------------------------------------------
102 CFormatEtc
& CFormatEtc::operator=( const CFormatEtc
& theOther
)
104 if ( this != &theOther
)
106 DeleteTargetDevice( m_FormatEtc
.ptd
);
108 m_FormatEtc
.cfFormat
= theOther
.m_FormatEtc
.cfFormat
;
109 m_FormatEtc
.ptd
= CopyTargetDevice( theOther
.m_FormatEtc
.ptd
);
110 m_FormatEtc
.dwAspect
= theOther
.m_FormatEtc
.dwAspect
;
111 m_FormatEtc
.lindex
= theOther
.m_FormatEtc
.lindex
;
112 m_FormatEtc
.tymed
= theOther
.m_FormatEtc
.tymed
;
118 //------------------------------------------------------------------------
120 //------------------------------------------------------------------------
122 CFormatEtc::operator FORMATETC
*( )
127 //------------------------------------------------------------------------
129 //------------------------------------------------------------------------
131 CFormatEtc::operator FORMATETC( )
136 //------------------------------------------------------------------------
138 //------------------------------------------------------------------------
140 void CFormatEtc::getFORMATETC( LPFORMATETC lpFormatEtc
)
142 OSL_ASSERT( lpFormatEtc
);
143 OSL_ASSERT( !IsBadWritePtr( lpFormatEtc
, sizeof( FORMATETC
) ) );
145 CopyFormatEtc( lpFormatEtc
, &m_FormatEtc
);
148 //------------------------------------------------------------------------
150 //------------------------------------------------------------------------
152 CLIPFORMAT
CFormatEtc::getClipformat( ) const
154 return m_FormatEtc
.cfFormat
;
157 //------------------------------------------------------------------------
159 //------------------------------------------------------------------------
161 DWORD
CFormatEtc::getTymed( ) const
163 return m_FormatEtc
.tymed
;
166 //------------------------------------------------------------------------
168 //------------------------------------------------------------------------
170 void CFormatEtc::getTargetDevice( DVTARGETDEVICE
** lpDvTargetDevice
) const
172 OSL_ASSERT( lpDvTargetDevice
);
173 OSL_ASSERT( !IsBadWritePtr( lpDvTargetDevice
, sizeof( DVTARGETDEVICE
) ) );
175 *lpDvTargetDevice
= NULL
;
177 if ( m_FormatEtc
.ptd
)
178 *lpDvTargetDevice
= CopyTargetDevice( m_FormatEtc
.ptd
);
181 //------------------------------------------------------------------------
183 //------------------------------------------------------------------------
185 DWORD
CFormatEtc::getDvAspect( ) const
187 return m_FormatEtc
.dwAspect
;
190 //------------------------------------------------------------------------
192 //------------------------------------------------------------------------
194 LONG
CFormatEtc::getLindex( ) const
196 return m_FormatEtc
.lindex
;
199 //------------------------------------------------------------------------
201 //------------------------------------------------------------------------
203 void CFormatEtc::setClipformat( CLIPFORMAT cf
)
205 m_FormatEtc
.cfFormat
= cf
;
208 //------------------------------------------------------------------------
210 //------------------------------------------------------------------------
212 void CFormatEtc::setTymed( DWORD tymed
)
214 m_FormatEtc
.tymed
= tymed
;
217 //------------------------------------------------------------------------
218 // transfer of ownership!
219 //------------------------------------------------------------------------
221 void CFormatEtc::setTargetDevice( DVTARGETDEVICE
* ptd
)
223 DeleteTargetDevice( m_FormatEtc
.ptd
);
224 m_FormatEtc
.ptd
= ptd
;
227 //------------------------------------------------------------------------
229 //------------------------------------------------------------------------
231 void CFormatEtc::setDvAspect( DWORD dwAspect
)
233 m_FormatEtc
.dwAspect
= dwAspect
;
236 //------------------------------------------------------------------------
238 //------------------------------------------------------------------------
240 void CFormatEtc::setLindex( LONG lindex
)
242 m_FormatEtc
.lindex
= lindex
;
245 //------------------------------------------------------------------------
247 //------------------------------------------------------------------------
249 sal_Int32
operator==( const CFormatEtc
& lhs
, const CFormatEtc
& rhs
)
251 return CompareFormatEtc( &lhs
.m_FormatEtc
, &rhs
.m_FormatEtc
);
254 //------------------------------------------------------------------------
256 //------------------------------------------------------------------------
258 sal_Int32
operator!=( const CFormatEtc
& lhs
, const CFormatEtc
& rhs
)
260 return ( ( lhs
== rhs
) != 1 );