1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
20 #include <osl/diagnose.h>
22 #include "../misc/ImplHelper.hxx"
24 //------------------------------------------------------------------------
26 //------------------------------------------------------------------------
28 CFormatEtc::CFormatEtc( )
30 m_FormatEtc
.cfFormat
= 0;
31 m_FormatEtc
.ptd
= NULL
;
32 m_FormatEtc
.dwAspect
= 0;
33 m_FormatEtc
.lindex
= -1;
34 m_FormatEtc
.tymed
= TYMED_NULL
;
37 //------------------------------------------------------------------------
38 // transfer of ownership
39 //------------------------------------------------------------------------
41 CFormatEtc::CFormatEtc( const FORMATETC
& aFormatEtc
)
43 CopyFormatEtc( &m_FormatEtc
, &const_cast< FORMATETC
& >( aFormatEtc
) );
46 //------------------------------------------------------------------------
48 //------------------------------------------------------------------------
50 CFormatEtc::~CFormatEtc( )
52 DeleteTargetDevice( m_FormatEtc
.ptd
);
55 //------------------------------------------------------------------------
57 //------------------------------------------------------------------------
59 CFormatEtc::CFormatEtc( CLIPFORMAT cf
, DWORD tymed
, DVTARGETDEVICE
* ptd
, DWORD dwAspect
, LONG lindex
)
61 m_FormatEtc
.cfFormat
= cf
;
62 m_FormatEtc
.ptd
= CopyTargetDevice( ptd
);
63 m_FormatEtc
.dwAspect
= dwAspect
;
64 m_FormatEtc
.lindex
= lindex
;
65 m_FormatEtc
.tymed
= tymed
;
68 //------------------------------------------------------------------------
70 //------------------------------------------------------------------------
72 CFormatEtc::CFormatEtc( const CFormatEtc
& theOther
)
74 m_FormatEtc
.cfFormat
= theOther
.m_FormatEtc
.cfFormat
;
75 m_FormatEtc
.ptd
= CopyTargetDevice( theOther
.m_FormatEtc
.ptd
);
76 m_FormatEtc
.dwAspect
= theOther
.m_FormatEtc
.dwAspect
;
77 m_FormatEtc
.lindex
= theOther
.m_FormatEtc
.lindex
;
78 m_FormatEtc
.tymed
= theOther
.m_FormatEtc
.tymed
;
81 //------------------------------------------------------------------------
83 //------------------------------------------------------------------------
85 CFormatEtc
& CFormatEtc::operator=( const CFormatEtc
& theOther
)
87 if ( this != &theOther
)
89 DeleteTargetDevice( m_FormatEtc
.ptd
);
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
;
101 //------------------------------------------------------------------------
103 //------------------------------------------------------------------------
105 CFormatEtc::operator FORMATETC
*( )
110 //------------------------------------------------------------------------
112 //------------------------------------------------------------------------
114 CFormatEtc::operator FORMATETC( )
119 //------------------------------------------------------------------------
121 //------------------------------------------------------------------------
123 void CFormatEtc::getFORMATETC( LPFORMATETC lpFormatEtc
)
125 OSL_ASSERT( lpFormatEtc
);
126 OSL_ASSERT( !IsBadWritePtr( lpFormatEtc
, sizeof( FORMATETC
) ) );
128 CopyFormatEtc( lpFormatEtc
, &m_FormatEtc
);
131 //------------------------------------------------------------------------
133 //------------------------------------------------------------------------
135 CLIPFORMAT
CFormatEtc::getClipformat( ) const
137 return m_FormatEtc
.cfFormat
;
140 //------------------------------------------------------------------------
142 //------------------------------------------------------------------------
144 DWORD
CFormatEtc::getTymed( ) const
146 return m_FormatEtc
.tymed
;
149 //------------------------------------------------------------------------
151 //------------------------------------------------------------------------
153 void CFormatEtc::getTargetDevice( DVTARGETDEVICE
** lpDvTargetDevice
) const
155 OSL_ASSERT( lpDvTargetDevice
);
156 OSL_ASSERT( !IsBadWritePtr( lpDvTargetDevice
, sizeof( DVTARGETDEVICE
) ) );
158 *lpDvTargetDevice
= NULL
;
160 if ( m_FormatEtc
.ptd
)
161 *lpDvTargetDevice
= CopyTargetDevice( m_FormatEtc
.ptd
);
164 //------------------------------------------------------------------------
166 //------------------------------------------------------------------------
168 DWORD
CFormatEtc::getDvAspect( ) const
170 return m_FormatEtc
.dwAspect
;
173 //------------------------------------------------------------------------
175 //------------------------------------------------------------------------
177 LONG
CFormatEtc::getLindex( ) const
179 return m_FormatEtc
.lindex
;
182 //------------------------------------------------------------------------
184 //------------------------------------------------------------------------
186 void CFormatEtc::setClipformat( CLIPFORMAT cf
)
188 m_FormatEtc
.cfFormat
= cf
;
191 //------------------------------------------------------------------------
193 //------------------------------------------------------------------------
195 void CFormatEtc::setTymed( DWORD tymed
)
197 m_FormatEtc
.tymed
= tymed
;
200 //------------------------------------------------------------------------
201 // transfer of ownership!
202 //------------------------------------------------------------------------
204 void CFormatEtc::setTargetDevice( DVTARGETDEVICE
* ptd
)
206 DeleteTargetDevice( m_FormatEtc
.ptd
);
207 m_FormatEtc
.ptd
= ptd
;
210 //------------------------------------------------------------------------
212 //------------------------------------------------------------------------
214 void CFormatEtc::setDvAspect( DWORD dwAspect
)
216 m_FormatEtc
.dwAspect
= dwAspect
;
219 //------------------------------------------------------------------------
221 //------------------------------------------------------------------------
223 void CFormatEtc::setLindex( LONG lindex
)
225 m_FormatEtc
.lindex
= lindex
;
228 //------------------------------------------------------------------------
230 //------------------------------------------------------------------------
232 sal_Int32
operator==( const CFormatEtc
& lhs
, const CFormatEtc
& rhs
)
234 return CompareFormatEtc( &lhs
.m_FormatEtc
, &rhs
.m_FormatEtc
);
237 //------------------------------------------------------------------------
239 //------------------------------------------------------------------------
241 sal_Int32
operator!=( const CFormatEtc
& lhs
, const CFormatEtc
& rhs
)
243 return ( ( lhs
== rhs
) != 1 );
246 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */