LibreOffice Module dtrans (master)  1
Fetc.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <osl/diagnose.h>
21 #include "Fetc.hxx"
22 #include "../misc/ImplHelper.hxx"
23 
25 {
26  m_FormatEtc.cfFormat = 0;
27  m_FormatEtc.ptd = nullptr;
28  m_FormatEtc.dwAspect = 0;
29  m_FormatEtc.lindex = -1;
30  m_FormatEtc.tymed = TYMED_NULL;
31 }
32 
33 // transfer of ownership
34 
35 CFormatEtc::CFormatEtc( const FORMATETC& aFormatEtc )
36 {
37  CopyFormatEtc( &m_FormatEtc, &const_cast< FORMATETC& >( aFormatEtc ) );
38 }
39 
41 {
43 }
44 
45 CFormatEtc::CFormatEtc( CLIPFORMAT cf, DWORD tymed, DVTARGETDEVICE* ptd, DWORD dwAspect, LONG lindex )
46 {
47  m_FormatEtc.cfFormat = cf;
48  m_FormatEtc.ptd = CopyTargetDevice( ptd );
49  m_FormatEtc.dwAspect = dwAspect;
50  m_FormatEtc.lindex = lindex;
51  m_FormatEtc.tymed = tymed;
52 }
53 
55 {
56  m_FormatEtc.cfFormat = theOther.m_FormatEtc.cfFormat;
57  m_FormatEtc.ptd = CopyTargetDevice( theOther.m_FormatEtc.ptd );
58  m_FormatEtc.dwAspect = theOther.m_FormatEtc.dwAspect;
59  m_FormatEtc.lindex = theOther.m_FormatEtc.lindex;
60  m_FormatEtc.tymed = theOther.m_FormatEtc.tymed;
61 }
62 
64 {
65  if ( this != &theOther )
66  {
68 
69  m_FormatEtc.cfFormat = theOther.m_FormatEtc.cfFormat;
70  m_FormatEtc.ptd = CopyTargetDevice( theOther.m_FormatEtc.ptd );
71  m_FormatEtc.dwAspect = theOther.m_FormatEtc.dwAspect;
72  m_FormatEtc.lindex = theOther.m_FormatEtc.lindex;
73  m_FormatEtc.tymed = theOther.m_FormatEtc.tymed;
74  }
75 
76  return *this;
77 }
78 
79 CFormatEtc::operator FORMATETC*( )
80 {
81  return &m_FormatEtc;
82 }
83 
84 CFormatEtc::operator FORMATETC( )
85 {
86  return m_FormatEtc;
87 }
88 
89 void CFormatEtc::getFORMATETC( LPFORMATETC lpFormatEtc )
90 {
91  OSL_ASSERT( lpFormatEtc );
92  OSL_ASSERT( !IsBadWritePtr( lpFormatEtc, sizeof( FORMATETC ) ) );
93 
94  CopyFormatEtc( lpFormatEtc, &m_FormatEtc );
95 }
96 
97 CLIPFORMAT CFormatEtc::getClipformat( ) const
98 {
99  return m_FormatEtc.cfFormat;
100 }
101 
102 DWORD CFormatEtc::getTymed( ) const
103 {
104  return m_FormatEtc.tymed;
105 }
106 
107 void CFormatEtc::getTargetDevice( DVTARGETDEVICE** lpDvTargetDevice ) const
108 {
109  OSL_ASSERT( lpDvTargetDevice );
110  OSL_ASSERT( !IsBadWritePtr( lpDvTargetDevice, sizeof( DVTARGETDEVICE ) ) );
111 
112  *lpDvTargetDevice = nullptr;
113 
114  if ( m_FormatEtc.ptd )
115  *lpDvTargetDevice = CopyTargetDevice( m_FormatEtc.ptd );
116 }
117 
119 {
120  return m_FormatEtc.dwAspect;
121 }
122 
124 {
125  return m_FormatEtc.lindex;
126 }
127 
128 void CFormatEtc::setClipformat( CLIPFORMAT cf )
129 {
130  m_FormatEtc.cfFormat = cf;
131 }
132 
133 void CFormatEtc::setTymed( DWORD tymed )
134 {
135  m_FormatEtc.tymed = tymed;
136 }
137 
138 // transfer of ownership!
139 
140 void CFormatEtc::setTargetDevice( DVTARGETDEVICE* ptd )
141 {
143  m_FormatEtc.ptd = ptd;
144 }
145 
146 void CFormatEtc::setDvAspect( DWORD dwAspect )
147 {
148  m_FormatEtc.dwAspect = dwAspect;
149 }
150 
151 void CFormatEtc::setLindex( LONG lindex )
152 {
153  m_FormatEtc.lindex = lindex;
154 }
155 
156 bool operator==( const CFormatEtc& lhs, const CFormatEtc& rhs )
157 {
158  return CompareFormatEtc( &lhs.m_FormatEtc, &rhs.m_FormatEtc );
159 }
160 
161 bool operator!=( const CFormatEtc& lhs, const CFormatEtc& rhs )
162 {
163  return !( lhs == rhs );
164 }
165 
166 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void getFORMATETC(LPFORMATETC lpFormatEtc)
Definition: Fetc.cxx:89
sal_Int32 CompareFormatEtc(const FORMATETC *pFetcLhs, const FORMATETC *pFetcRhs)
Definition: ImplHelper.cxx:271
void getTargetDevice(DVTARGETDEVICE **ptd) const
Definition: Fetc.cxx:107
FORMATETC m_FormatEtc
Definition: Fetc.hxx:68
LONG
CLIPFORMAT getClipformat() const
Definition: Fetc.cxx:97
void setTargetDevice(DVTARGETDEVICE *ptd)
Definition: Fetc.cxx:140
CFormatEtc & operator=(const CFormatEtc &theOther)
Definition: Fetc.cxx:63
void setDvAspect(DWORD dwAspect)
Definition: Fetc.cxx:146
void setClipformat(CLIPFORMAT cf)
Definition: Fetc.cxx:128
bool operator==(const CFormatEtc &lhs, const CFormatEtc &rhs)
Definition: Fetc.cxx:156
void DeleteTargetDevice(DVTARGETDEVICE *ptd)
Definition: ImplHelper.cxx:166
bool CopyFormatEtc(LPFORMATETC petcDest, LPFORMATETC petcSrc)
Definition: ImplHelper.cxx:235
~CFormatEtc()
Definition: Fetc.cxx:40
CFormatEtc()
Definition: Fetc.cxx:24
DVTARGETDEVICE * CopyTargetDevice(DVTARGETDEVICE *ptdSrc)
Definition: ImplHelper.cxx:193
LONG getLindex() const
Definition: Fetc.cxx:123
void setLindex(LONG lindex)
Definition: Fetc.cxx:151
DWORD getTymed() const
Definition: Fetc.cxx:102
bool operator!=(const CFormatEtc &lhs, const CFormatEtc &rhs)
Definition: Fetc.cxx:161
DWORD getDvAspect() const
Definition: Fetc.cxx:118
void setTymed(DWORD tymed)
Definition: Fetc.cxx:133