Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
2de8137f
Commit
2de8137f
authored
Aug 21, 2011
by
Nikolay Sivov
Committed by
Alexandre Julliard
Aug 22, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
oleaut32: Use type names and sizeof() instead of hardcoded values for save/load methods.
parent
1a7d52c9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
126 deletions
+64
-126
olefont.c
dlls/oleaut32/olefont.c
+64
-126
No files found.
dlls/oleaut32/olefont.c
View file @
2de8137f
...
...
@@ -287,13 +287,6 @@ struct OLEFontImpl
IConnectionPoint
*
pFontEventsCP
;
};
/*
* Here, I define utility macros to help with the casting of the
* "this" parameter.
* There is a version to accommodate all of the VTables implemented
* by this object.
*/
static
inline
OLEFontImpl
*
impl_from_IFont
(
IFont
*
iface
)
{
return
CONTAINING_RECORD
(
iface
,
OLEFontImpl
,
IFont_iface
);
...
...
@@ -1626,80 +1619,50 @@ static HRESULT WINAPI OLEFontImpl_Load(
IPersistStream
*
iface
,
IStream
*
pLoadStream
)
{
char
readBuffer
[
0x100
];
OLEFontImpl
*
this
=
impl_from_IPersistStream
(
iface
);
BYTE
version
,
attributes
,
string_size
;
char
readBuffer
[
0x100
];
ULONG
cbRead
;
BYTE
bVersion
;
BYTE
bAttributes
;
BYTE
bStringSize
;
INT
len
;
OLEFontImpl
*
this
=
impl_from_IPersistStream
(
iface
);
/*
* Read the version byte
*/
IStream_Read
(
pLoadStream
,
&
bVersion
,
1
,
&
cbRead
);
if
(
(
cbRead
!=
1
)
||
(
bVersion
!=
0x01
)
)
return
E_FAIL
;
/*
* Charset
*/
IStream_Read
(
pLoadStream
,
&
this
->
description
.
sCharset
,
2
,
&
cbRead
);
if
(
cbRead
!=
2
)
return
E_FAIL
;
/*
* Attributes
*/
IStream_Read
(
pLoadStream
,
&
bAttributes
,
1
,
&
cbRead
);
/* Version */
IStream_Read
(
pLoadStream
,
&
version
,
sizeof
(
BYTE
),
&
cbRead
);
if
((
cbRead
!=
sizeof
(
BYTE
))
||
(
version
!=
0x01
))
return
E_FAIL
;
if
(
cbRead
!=
1
)
return
E_FAIL
;
/* Charset */
IStream_Read
(
pLoadStream
,
&
this
->
description
.
sCharset
,
sizeof
(
WORD
),
&
cbRead
);
if
(
cbRead
!=
sizeof
(
WORD
))
return
E_FAIL
;
this
->
description
.
fItalic
=
(
bAttributes
&
FONTPERSIST_ITALIC
)
!=
0
;
this
->
description
.
fStrikethrough
=
(
bAttributes
&
FONTPERSIST_STRIKETHROUGH
)
!=
0
;
this
->
description
.
fUnderline
=
(
bAttributes
&
FONTPERSIST_UNDERLINE
)
!=
0
;
/* Attributes */
IStream_Read
(
pLoadStream
,
&
attributes
,
sizeof
(
BYTE
),
&
cbRead
)
;
if
(
cbRead
!=
sizeof
(
BYTE
))
return
E_FAIL
;
/*
* Weight
*/
IStream_Read
(
pLoadStream
,
&
this
->
description
.
sWeight
,
2
,
&
cbRead
);
this
->
description
.
fItalic
=
(
attributes
&
FONTPERSIST_ITALIC
)
!=
0
;
this
->
description
.
fStrikethrough
=
(
attributes
&
FONTPERSIST_STRIKETHROUGH
)
!=
0
;
this
->
description
.
fUnderline
=
(
attributes
&
FONTPERSIST_UNDERLINE
)
!=
0
;
if
(
cbRead
!=
2
)
return
E_FAIL
;
/* Weight */
IStream_Read
(
pLoadStream
,
&
this
->
description
.
sWeight
,
sizeof
(
WORD
),
&
cbRead
);
if
(
cbRead
!=
sizeof
(
WORD
))
return
E_FAIL
;
/*
* Size
*/
IStream_Read
(
pLoadStream
,
&
this
->
description
.
cySize
.
s
.
Lo
,
4
,
&
cbRead
);
if
(
cbRead
!=
4
)
return
E_FAIL
;
/* Size */
IStream_Read
(
pLoadStream
,
&
this
->
description
.
cySize
.
s
.
Lo
,
sizeof
(
DWORD
),
&
cbRead
);
if
(
cbRead
!=
sizeof
(
DWORD
))
return
E_FAIL
;
this
->
description
.
cySize
.
s
.
Hi
=
0
;
/*
* FontName
*/
IStream_Read
(
pLoadStream
,
&
bStringSize
,
1
,
&
cbRead
);
if
(
cbRead
!=
1
)
return
E_FAIL
;
/* Name */
IStream_Read
(
pLoadStream
,
&
string_size
,
sizeof
(
BYTE
),
&
cbRead
);
if
(
cbRead
!=
sizeof
(
BYTE
))
return
E_FAIL
;
IStream_Read
(
pLoadStream
,
readBuffer
,
bStringSize
,
&
cbRead
);
if
(
cbRead
!=
bStringSize
)
return
E_FAIL
;
IStream_Read
(
pLoadStream
,
readBuffer
,
string_size
,
&
cbRead
);
if
(
cbRead
!=
string_size
)
return
E_FAIL
;
HeapFree
(
GetProcessHeap
(),
0
,
this
->
description
.
lpstrName
);
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
readBuffer
,
bStringS
ize
,
NULL
,
0
);
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
readBuffer
,
string_s
ize
,
NULL
,
0
);
this
->
description
.
lpstrName
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
len
+
1
)
*
sizeof
(
WCHAR
)
);
MultiByteToWideChar
(
CP_ACP
,
0
,
readBuffer
,
bStringS
ize
,
this
->
description
.
lpstrName
,
len
);
MultiByteToWideChar
(
CP_ACP
,
0
,
readBuffer
,
string_s
ize
,
this
->
description
.
lpstrName
,
len
);
this
->
description
.
lpstrName
[
len
]
=
0
;
/* Ensure use of this font causes a new one to be created */
...
...
@@ -1718,91 +1681,66 @@ static HRESULT WINAPI OLEFontImpl_Save(
IStream
*
pOutStream
,
BOOL
fClearDirty
)
{
OLEFontImpl
*
this
=
impl_from_IPersistStream
(
iface
);
BYTE
attributes
,
string_size
;
const
BYTE
version
=
0x01
;
char
*
writeBuffer
=
NULL
;
ULONG
cbWritten
;
BYTE
bVersion
=
0x01
;
BYTE
bAttributes
;
BYTE
bStringSize
;
ULONG
written
;
OLEFontImpl
*
this
=
impl_from_IPersistStream
(
iface
);
TRACE
(
"(%p)->(%p %d)
\n
"
,
this
,
pOutStream
,
fClearDirty
);
/*
* Read the version byte
*/
IStream_Write
(
pOutStream
,
&
bVersion
,
1
,
&
cbWritten
);
/* Version */
IStream_Write
(
pOutStream
,
&
version
,
sizeof
(
BYTE
),
&
written
);
if
(
written
!=
sizeof
(
BYTE
))
return
E_FAIL
;
if
(
cbWritten
!=
1
)
return
E_FAIL
;
/* Charset */
IStream_Write
(
pOutStream
,
&
this
->
description
.
sCharset
,
sizeof
(
WORD
),
&
written
);
if
(
written
!=
sizeof
(
WORD
))
return
E_FAIL
;
/*
* Charset
*/
IStream_Write
(
pOutStream
,
&
this
->
description
.
sCharset
,
2
,
&
cbWritten
);
if
(
cbWritten
!=
2
)
return
E_FAIL
;
/*
* Attributes
*/
bAttributes
=
0
;
/* Attributes */
attributes
=
0
;
if
(
this
->
description
.
fItalic
)
bA
ttributes
|=
FONTPERSIST_ITALIC
;
a
ttributes
|=
FONTPERSIST_ITALIC
;
if
(
this
->
description
.
fStrikethrough
)
bA
ttributes
|=
FONTPERSIST_STRIKETHROUGH
;
a
ttributes
|=
FONTPERSIST_STRIKETHROUGH
;
if
(
this
->
description
.
fUnderline
)
bA
ttributes
|=
FONTPERSIST_UNDERLINE
;
a
ttributes
|=
FONTPERSIST_UNDERLINE
;
IStream_Write
(
pOutStream
,
&
bAttributes
,
1
,
&
cbWritten
);
IStream_Write
(
pOutStream
,
&
attributes
,
sizeof
(
BYTE
),
&
written
);
if
(
written
!=
sizeof
(
BYTE
))
return
E_FAIL
;
if
(
cbWritten
!=
1
)
return
E_FAIL
;
/* Weight */
IStream_Write
(
pOutStream
,
&
this
->
description
.
sWeight
,
sizeof
(
WORD
),
&
written
);
if
(
written
!=
sizeof
(
WORD
))
return
E_FAIL
;
/*
* Weight
*/
IStream_Write
(
pOutStream
,
&
this
->
description
.
sWeight
,
2
,
&
cbWritten
);
if
(
cbWritten
!=
2
)
return
E_FAIL
;
/*
* Size
*/
IStream_Write
(
pOutStream
,
&
this
->
description
.
cySize
.
s
.
Lo
,
4
,
&
cbWritten
);
/* Size */
IStream_Write
(
pOutStream
,
&
this
->
description
.
cySize
.
s
.
Lo
,
sizeof
(
DWORD
),
&
written
);
if
(
written
!=
sizeof
(
DWORD
))
return
E_FAIL
;
if
(
cbWritten
!=
4
)
return
E_FAIL
;
/*
* FontName
*/
if
(
this
->
description
.
lpstrName
!=
0
)
bStringSize
=
WideCharToMultiByte
(
CP_ACP
,
0
,
this
->
description
.
lpstrName
,
/* FontName */
if
(
this
->
description
.
lpstrName
)
string_size
=
WideCharToMultiByte
(
CP_ACP
,
0
,
this
->
description
.
lpstrName
,
strlenW
(
this
->
description
.
lpstrName
),
NULL
,
0
,
NULL
,
NULL
);
else
bStringSize
=
0
;
IStream_Write
(
pOutStream
,
&
bStringSize
,
1
,
&
cbWritten
);
string_size
=
0
;
if
(
cbWritten
!=
1
)
return
E_FAIL
;
IStream_Write
(
pOutStream
,
&
string_size
,
sizeof
(
BYTE
),
&
written
);
if
(
written
!=
sizeof
(
BYTE
))
return
E_FAIL
;
if
(
bStringSize
!=
0
)
if
(
string_size
)
{
if
(
!
(
writeBuffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
bStringS
ize
)))
return
E_OUTOFMEMORY
;
if
(
!
(
writeBuffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
string_s
ize
)))
return
E_OUTOFMEMORY
;
WideCharToMultiByte
(
CP_ACP
,
0
,
this
->
description
.
lpstrName
,
strlenW
(
this
->
description
.
lpstrName
),
writeBuffer
,
bStringS
ize
,
NULL
,
NULL
);
writeBuffer
,
string_s
ize
,
NULL
,
NULL
);
IStream_Write
(
pOutStream
,
writeBuffer
,
bStringSize
,
&
cbW
ritten
);
HeapFree
(
GetProcessHeap
(),
0
,
writeBuffer
);
IStream_Write
(
pOutStream
,
writeBuffer
,
string_size
,
&
w
ritten
);
HeapFree
(
GetProcessHeap
(),
0
,
writeBuffer
);
if
(
cbWritten
!=
bStringSize
)
return
E_FAIL
;
if
(
written
!=
string_size
)
return
E_FAIL
;
}
return
S_OK
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment