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 "ImplHelper.hxx"
25 CFormatEtc::CFormatEtc( )
27 m_FormatEtc
.cfFormat
= 0;
28 m_FormatEtc
.ptd
= nullptr;
29 m_FormatEtc
.dwAspect
= 0;
30 m_FormatEtc
.lindex
= -1;
31 m_FormatEtc
.tymed
= TYMED_NULL
;
34 // transfer of ownership
36 CFormatEtc::CFormatEtc( const FORMATETC
& aFormatEtc
)
38 CopyFormatEtc( &m_FormatEtc
, &const_cast< FORMATETC
& >( aFormatEtc
) );
41 CFormatEtc::~CFormatEtc( )
43 DeleteTargetDevice( m_FormatEtc
.ptd
);
46 CFormatEtc::CFormatEtc( CLIPFORMAT cf
, DWORD tymed
, DVTARGETDEVICE
* ptd
, DWORD dwAspect
, LONG lindex
)
48 m_FormatEtc
.cfFormat
= cf
;
49 m_FormatEtc
.ptd
= CopyTargetDevice( ptd
);
50 m_FormatEtc
.dwAspect
= dwAspect
;
51 m_FormatEtc
.lindex
= lindex
;
52 m_FormatEtc
.tymed
= tymed
;
55 CFormatEtc::CFormatEtc( const CFormatEtc
& theOther
)
57 m_FormatEtc
.cfFormat
= theOther
.m_FormatEtc
.cfFormat
;
58 m_FormatEtc
.ptd
= CopyTargetDevice( theOther
.m_FormatEtc
.ptd
);
59 m_FormatEtc
.dwAspect
= theOther
.m_FormatEtc
.dwAspect
;
60 m_FormatEtc
.lindex
= theOther
.m_FormatEtc
.lindex
;
61 m_FormatEtc
.tymed
= theOther
.m_FormatEtc
.tymed
;
64 CFormatEtc
& CFormatEtc::operator=( const CFormatEtc
& theOther
)
66 if ( this != &theOther
)
68 DeleteTargetDevice( m_FormatEtc
.ptd
);
70 m_FormatEtc
.cfFormat
= theOther
.m_FormatEtc
.cfFormat
;
71 m_FormatEtc
.ptd
= CopyTargetDevice( theOther
.m_FormatEtc
.ptd
);
72 m_FormatEtc
.dwAspect
= theOther
.m_FormatEtc
.dwAspect
;
73 m_FormatEtc
.lindex
= theOther
.m_FormatEtc
.lindex
;
74 m_FormatEtc
.tymed
= theOther
.m_FormatEtc
.tymed
;
80 CFormatEtc::operator FORMATETC
*( )
85 CFormatEtc::operator FORMATETC( )
90 void CFormatEtc::getFORMATETC( LPFORMATETC lpFormatEtc
)
92 OSL_ASSERT( lpFormatEtc
);
93 OSL_ASSERT( !IsBadWritePtr( lpFormatEtc
, sizeof( FORMATETC
) ) );
95 CopyFormatEtc( lpFormatEtc
, &m_FormatEtc
);
98 CLIPFORMAT
CFormatEtc::getClipformat( ) const
100 return m_FormatEtc
.cfFormat
;
103 DWORD
CFormatEtc::getTymed( ) const
105 return m_FormatEtc
.tymed
;
108 void CFormatEtc::getTargetDevice( DVTARGETDEVICE
** lpDvTargetDevice
) const
110 assert(lpDvTargetDevice
);
111 OSL_ASSERT( !IsBadWritePtr( lpDvTargetDevice
, sizeof( DVTARGETDEVICE
) ) );
113 *lpDvTargetDevice
= nullptr;
115 if ( m_FormatEtc
.ptd
)
116 *lpDvTargetDevice
= CopyTargetDevice( m_FormatEtc
.ptd
);
119 DWORD
CFormatEtc::getDvAspect( ) const
121 return m_FormatEtc
.dwAspect
;
124 LONG
CFormatEtc::getLindex( ) const
126 return m_FormatEtc
.lindex
;
129 void CFormatEtc::setClipformat( CLIPFORMAT cf
)
131 m_FormatEtc
.cfFormat
= cf
;
134 void CFormatEtc::setTymed( DWORD tymed
)
136 m_FormatEtc
.tymed
= tymed
;
139 // transfer of ownership!
141 void CFormatEtc::setTargetDevice( DVTARGETDEVICE
* ptd
)
143 DeleteTargetDevice( m_FormatEtc
.ptd
);
144 m_FormatEtc
.ptd
= ptd
;
147 void CFormatEtc::setDvAspect( DWORD dwAspect
)
149 m_FormatEtc
.dwAspect
= dwAspect
;
152 void CFormatEtc::setLindex( LONG lindex
)
154 m_FormatEtc
.lindex
= lindex
;
157 bool operator==( const CFormatEtc
& lhs
, const CFormatEtc
& rhs
)
159 return CompareFormatEtc( &lhs
.m_FormatEtc
, &rhs
.m_FormatEtc
);
162 bool operator!=( const CFormatEtc
& lhs
, const CFormatEtc
& rhs
)
164 return !( lhs
== rhs
);
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */