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