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
19938984
Commit
19938984
authored
Sep 07, 2016
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user32: Synthesize metafile clipboard formats on the user32 side.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
68636902
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
4 deletions
+70
-4
clipboard.c
dlls/user32/clipboard.c
+68
-0
clipboard.c
dlls/user32/tests/clipboard.c
+2
-4
No files found.
dlls/user32/clipboard.c
View file @
19938984
...
@@ -140,6 +140,16 @@ static void add_synthesized_text(void)
...
@@ -140,6 +140,16 @@ static void add_synthesized_text(void)
}
}
}
}
/* add synthesized metafile formats based on what is already in the clipboard */
static
void
add_synthesized_metafile
(
void
)
{
BOOL
has_mf
=
IsClipboardFormatAvailable
(
CF_METAFILEPICT
);
BOOL
has_emf
=
IsClipboardFormatAvailable
(
CF_ENHMETAFILE
);
if
(
!
has_mf
&&
has_emf
)
add_synthesized_format
(
CF_METAFILEPICT
,
CF_ENHMETAFILE
);
else
if
(
!
has_emf
&&
has_mf
)
add_synthesized_format
(
CF_ENHMETAFILE
,
CF_METAFILEPICT
);
}
/* render synthesized ANSI text based on the contents of the 'from' format */
/* render synthesized ANSI text based on the contents of the 'from' format */
static
HANDLE
render_synthesized_textA
(
HANDLE
data
,
UINT
format
,
UINT
from
)
static
HANDLE
render_synthesized_textA
(
HANDLE
data
,
UINT
format
,
UINT
from
)
{
{
...
@@ -190,6 +200,57 @@ static HANDLE render_synthesized_textW( HANDLE data, UINT from )
...
@@ -190,6 +200,57 @@ static HANDLE render_synthesized_textW( HANDLE data, UINT from )
return
ret
;
return
ret
;
}
}
/* render a synthesized metafile based on the enhmetafile clipboard data */
static
HANDLE
render_synthesized_metafile
(
HANDLE
data
)
{
HANDLE
ret
=
0
;
UINT
size
;
void
*
bits
;
METAFILEPICT
*
pict
;
ENHMETAHEADER
header
;
HDC
hdc
=
GetDC
(
0
);
size
=
GetWinMetaFileBits
(
data
,
0
,
NULL
,
MM_ISOTROPIC
,
hdc
);
if
((
bits
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
)))
{
if
(
GetEnhMetaFileHeader
(
data
,
sizeof
(
header
),
&
header
)
&&
GetWinMetaFileBits
(
data
,
size
,
bits
,
MM_ISOTROPIC
,
hdc
))
{
if
((
ret
=
GlobalAlloc
(
GMEM_FIXED
,
sizeof
(
*
pict
)
)))
{
pict
=
(
METAFILEPICT
*
)
ret
;
pict
->
mm
=
MM_ISOTROPIC
;
pict
->
xExt
=
header
.
rclFrame
.
right
-
header
.
rclFrame
.
left
;
pict
->
yExt
=
header
.
rclFrame
.
bottom
-
header
.
rclFrame
.
top
;
pict
->
hMF
=
SetMetaFileBitsEx
(
size
,
bits
);
}
}
HeapFree
(
GetProcessHeap
(),
0
,
bits
);
}
ReleaseDC
(
0
,
hdc
);
return
ret
;
}
/* render a synthesized enhmetafile based on the metafile clipboard data */
static
HANDLE
render_synthesized_enhmetafile
(
HANDLE
data
)
{
METAFILEPICT
*
pict
;
HANDLE
ret
=
0
;
UINT
size
;
void
*
bits
;
if
(
!
(
pict
=
GlobalLock
(
data
)))
return
0
;
size
=
GetMetaFileBitsEx
(
pict
->
hMF
,
0
,
NULL
);
if
((
bits
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
)))
{
GetMetaFileBitsEx
(
pict
->
hMF
,
size
,
bits
);
ret
=
SetWinMetaFileBits
(
size
,
bits
,
NULL
,
pict
);
HeapFree
(
GetProcessHeap
(),
0
,
bits
);
}
return
ret
;
}
/* render a synthesized format */
/* render a synthesized format */
static
HANDLE
render_synthesized_format
(
UINT
format
,
UINT
from
)
static
HANDLE
render_synthesized_format
(
UINT
format
,
UINT
from
)
{
{
...
@@ -207,6 +268,12 @@ static HANDLE render_synthesized_format( UINT format, UINT from )
...
@@ -207,6 +268,12 @@ static HANDLE render_synthesized_format( UINT format, UINT from )
case
CF_UNICODETEXT
:
case
CF_UNICODETEXT
:
data
=
render_synthesized_textW
(
data
,
from
);
data
=
render_synthesized_textW
(
data
,
from
);
break
;
break
;
case
CF_METAFILEPICT
:
data
=
render_synthesized_metafile
(
data
);
break
;
case
CF_ENHMETAFILE
:
data
=
render_synthesized_enhmetafile
(
data
);
break
;
default:
default:
assert
(
0
);
assert
(
0
);
}
}
...
@@ -338,6 +405,7 @@ BOOL WINAPI CloseClipboard(void)
...
@@ -338,6 +405,7 @@ BOOL WINAPI CloseClipboard(void)
{
{
memset
(
synthesized_formats
,
0
,
sizeof
(
synthesized_formats
)
);
memset
(
synthesized_formats
,
0
,
sizeof
(
synthesized_formats
)
);
add_synthesized_text
();
add_synthesized_text
();
add_synthesized_metafile
();
}
}
SERVER_START_REQ
(
close_clipboard
)
SERVER_START_REQ
(
close_clipboard
)
...
...
dlls/user32/tests/clipboard.c
View file @
19938984
...
@@ -665,7 +665,7 @@ static void test_synthesized(void)
...
@@ -665,7 +665,7 @@ static void test_synthesized(void)
cf
=
EnumClipboardFormats
(
cf
);
cf
=
EnumClipboardFormats
(
cf
);
ok
(
cf
==
CF_METAFILEPICT
,
"cf %08x
\n
"
,
cf
);
ok
(
cf
==
CF_METAFILEPICT
,
"cf %08x
\n
"
,
cf
);
data
=
GetClipboardData
(
cf
);
data
=
GetClipboardData
(
cf
);
todo_wine
ok
(
data
!=
NULL
,
"couldn't get data, cf %08x
\n
"
,
cf
);
ok
(
data
!=
NULL
,
"couldn't get data, cf %08x
\n
"
,
cf
);
cf
=
EnumClipboardFormats
(
cf
);
cf
=
EnumClipboardFormats
(
cf
);
ok
(
cf
==
0
,
"cf %08x
\n
"
,
cf
);
ok
(
cf
==
0
,
"cf %08x
\n
"
,
cf
);
...
@@ -756,7 +756,6 @@ static void test_synthesized(void)
...
@@ -756,7 +756,6 @@ static void test_synthesized(void)
i
,
j
,
cf
,
tests
[
i
].
expected
[
j
]
);
i
,
j
,
cf
,
tests
[
i
].
expected
[
j
]
);
if
(
cf
!=
tests
[
i
].
expected
[
j
])
break
;
if
(
cf
!=
tests
[
i
].
expected
[
j
])
break
;
data
=
GetClipboardData
(
cf
);
data
=
GetClipboardData
(
cf
);
todo_wine_if
(
j
&&
cf
==
CF_METAFILEPICT
)
ok
(
data
!=
NULL
||
ok
(
data
!=
NULL
||
broken
(
tests
[
i
].
format
==
CF_DIBV5
&&
cf
==
CF_DIB
),
/* >= Vista */
broken
(
tests
[
i
].
format
==
CF_DIBV5
&&
cf
==
CF_DIB
),
/* >= Vista */
"%u: couldn't get data, cf %04x err %d
\n
"
,
i
,
cf
,
GetLastError
());
"%u: couldn't get data, cf %04x err %d
\n
"
,
i
,
cf
,
GetLastError
());
...
@@ -830,13 +829,12 @@ static void test_synthesized(void)
...
@@ -830,13 +829,12 @@ static void test_synthesized(void)
else
else
{
{
ok
(
!
data
,
"%u: format %04x got data %p
\n
"
,
i
,
cf
,
data
);
ok
(
!
data
,
"%u: format %04x got data %p
\n
"
,
i
,
cf
,
data
);
todo_wine_if
(
tests
[
i
].
format
==
CF_ENHMETAFILE
&&
tests
[
i
].
expected
[
j
]
==
CF_METAFILEPICT
)
ok
(
rendered
==
(
1
<<
tests
[
i
].
format
),
ok
(
rendered
==
(
1
<<
tests
[
i
].
format
),
"%u.%u: formats %08x have been rendered
\n
"
,
i
,
j
,
rendered
);
"%u.%u: formats %08x have been rendered
\n
"
,
i
,
j
,
rendered
);
/* try to render a second time */
/* try to render a second time */
data
=
GetClipboardData
(
cf
);
data
=
GetClipboardData
(
cf
);
rendered
=
SendMessageA
(
hwnd
,
WM_USER
,
0
,
0
);
rendered
=
SendMessageA
(
hwnd
,
WM_USER
,
0
,
0
);
todo_wine_if
(
i
>
2
&&
j
==
1
)
todo_wine_if
(
i
>
4
&&
j
==
1
)
ok
(
rendered
==
(
1
<<
tests
[
i
].
format
),
ok
(
rendered
==
(
1
<<
tests
[
i
].
format
),
"%u.%u: formats %08x have been rendered
\n
"
,
i
,
j
,
rendered
);
"%u.%u: formats %08x have been rendered
\n
"
,
i
,
j
,
rendered
);
}
}
...
...
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