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
6ce9922f
Commit
6ce9922f
authored
Apr 16, 2009
by
Huw Davies
Committed by
Alexandre Julliard
Apr 16, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ole32: Add a helper function to set and release the source IDataObject.
parent
bf8d85ce
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
119 additions
and
125 deletions
+119
-125
clipboard.c
dlls/ole32/clipboard.c
+119
-125
No files found.
dlls/ole32/clipboard.c
View file @
6ce9922f
...
...
@@ -753,68 +753,6 @@ static HRESULT render_format(IDataObject *data, LPFORMATETC fmt)
return
hr
;
}
/***********************************************************************
* clipbrd_wndproc
*/
static
LRESULT
CALLBACK
clipbrd_wndproc
(
HWND
hwnd
,
UINT
message
,
WPARAM
wparam
,
LPARAM
lparam
)
{
ole_clipbrd
*
clipbrd
;
get_ole_clipbrd
(
&
clipbrd
);
switch
(
message
)
{
case
WM_RENDERFORMAT
:
{
UINT
cf
=
wparam
;
ole_priv_data_entry
*
entry
;
TRACE
(
"(): WM_RENDERFORMAT(cfFormat=%x)
\n
"
,
cf
);
entry
=
find_format_in_list
(
clipbrd
->
cached_enum
->
entries
,
clipbrd
->
cached_enum
->
count
,
cf
);
if
(
entry
)
render_format
(
clipbrd
->
pIDataObjectSrc
,
&
entry
->
fmtetc
);
break
;
}
case
WM_RENDERALLFORMATS
:
{
DWORD
i
;
ole_priv_data_entry
*
entries
=
clipbrd
->
cached_enum
->
entries
;
TRACE
(
"(): WM_RENDERALLFORMATS
\n
"
);
for
(
i
=
0
;
i
<
clipbrd
->
cached_enum
->
count
;
i
++
)
{
if
(
entries
[
i
].
first_use
)
render_format
(
clipbrd
->
pIDataObjectSrc
,
&
entries
[
i
].
fmtetc
);
}
break
;
}
case
WM_DESTROYCLIPBOARD
:
{
TRACE
(
"(): WM_DESTROYCLIPBOARD
\n
"
);
if
(
clipbrd
->
pIDataObjectSrc
)
{
IDataObject_Release
(
clipbrd
->
pIDataObjectSrc
);
clipbrd
->
pIDataObjectSrc
=
NULL
;
HeapFree
(
GetProcessHeap
(),
0
,
clipbrd
->
cached_enum
);
clipbrd
->
cached_enum
=
NULL
;
}
break
;
}
default:
return
DefWindowProcW
(
hwnd
,
message
,
wparam
,
lparam
);
}
return
0
;
}
/*---------------------------------------------------------------------*
* Implementation of the internal IDataObject interface exposed by
* the OLE clipboard.
...
...
@@ -1249,37 +1187,6 @@ void OLEClipbrd_UnInitialize(void)
}
}
/***********************************************************************
* OLEClipbrd_CreateWindow()
* Create the clipboard window
*/
static
HWND
OLEClipbrd_CreateWindow
(
void
)
{
WNDCLASSEXW
class
;
static
const
WCHAR
ole32W
[]
=
{
'o'
,
'l'
,
'e'
,
'3'
,
'2'
,
0
};
static
const
WCHAR
title
[]
=
{
'C'
,
'l'
,
'i'
,
'p'
,
'b'
,
'o'
,
'a'
,
'r'
,
'd'
,
'W'
,
'i'
,
'n'
,
'd'
,
'o'
,
'w'
,
0
};
HINSTANCE
hinst
=
GetModuleHandleW
(
ole32W
);
class
.
cbSize
=
sizeof
(
class
);
class
.
style
=
0
;
class
.
lpfnWndProc
=
clipbrd_wndproc
;
class
.
cbClsExtra
=
0
;
class
.
cbWndExtra
=
0
;
class
.
hInstance
=
hinst
;
class
.
hIcon
=
0
;
class
.
hCursor
=
0
;
class
.
hbrBackground
=
0
;
class
.
lpszMenuName
=
NULL
;
class
.
lpszClassName
=
clipbrd_wndclass
;
class
.
hIconSm
=
NULL
;
RegisterClassExW
(
&
class
);
return
CreateWindowW
(
clipbrd_wndclass
,
title
,
WS_POPUP
|
WS_CLIPSIBLINGS
|
WS_OVERLAPPED
,
CW_USEDEFAULT
,
CW_USEDEFAULT
,
CW_USEDEFAULT
,
CW_USEDEFAULT
,
NULL
,
NULL
,
hinst
,
0
);
}
/*********************************************************************
* set_clipboard_formats
*
...
...
@@ -1372,6 +1279,119 @@ static HRESULT set_clipboard_formats(ole_clipbrd *clipbrd, IDataObject *data)
return
S_OK
;
}
/***********************************************************************
* set_src_dataobject
*
* Clears and sets the clipboard's src IDataObject.
*/
static
HRESULT
set_src_dataobject
(
ole_clipbrd
*
clipbrd
,
IDataObject
*
data
)
{
HRESULT
hr
=
S_OK
;
if
(
clipbrd
->
pIDataObjectSrc
)
{
IDataObject_Release
(
clipbrd
->
pIDataObjectSrc
);
clipbrd
->
pIDataObjectSrc
=
NULL
;
HeapFree
(
GetProcessHeap
(),
0
,
clipbrd
->
cached_enum
);
clipbrd
->
cached_enum
=
NULL
;
}
if
(
data
)
{
IDataObject_AddRef
(
data
);
clipbrd
->
pIDataObjectSrc
=
data
;
hr
=
set_clipboard_formats
(
clipbrd
,
data
);
}
return
hr
;
}
/***********************************************************************
* clipbrd_wndproc
*/
static
LRESULT
CALLBACK
clipbrd_wndproc
(
HWND
hwnd
,
UINT
message
,
WPARAM
wparam
,
LPARAM
lparam
)
{
ole_clipbrd
*
clipbrd
;
get_ole_clipbrd
(
&
clipbrd
);
switch
(
message
)
{
case
WM_RENDERFORMAT
:
{
UINT
cf
=
wparam
;
ole_priv_data_entry
*
entry
;
TRACE
(
"(): WM_RENDERFORMAT(cfFormat=%x)
\n
"
,
cf
);
entry
=
find_format_in_list
(
clipbrd
->
cached_enum
->
entries
,
clipbrd
->
cached_enum
->
count
,
cf
);
if
(
entry
)
render_format
(
clipbrd
->
pIDataObjectSrc
,
&
entry
->
fmtetc
);
break
;
}
case
WM_RENDERALLFORMATS
:
{
DWORD
i
;
ole_priv_data_entry
*
entries
=
clipbrd
->
cached_enum
->
entries
;
TRACE
(
"(): WM_RENDERALLFORMATS
\n
"
);
for
(
i
=
0
;
i
<
clipbrd
->
cached_enum
->
count
;
i
++
)
{
if
(
entries
[
i
].
first_use
)
render_format
(
clipbrd
->
pIDataObjectSrc
,
&
entries
[
i
].
fmtetc
);
}
break
;
}
case
WM_DESTROYCLIPBOARD
:
{
TRACE
(
"(): WM_DESTROYCLIPBOARD
\n
"
);
set_src_dataobject
(
clipbrd
,
NULL
);
break
;
}
default:
return
DefWindowProcW
(
hwnd
,
message
,
wparam
,
lparam
);
}
return
0
;
}
/***********************************************************************
* OLEClipbrd_CreateWindow()
* Create the clipboard window
*/
static
HWND
OLEClipbrd_CreateWindow
(
void
)
{
WNDCLASSEXW
class
;
static
const
WCHAR
ole32W
[]
=
{
'o'
,
'l'
,
'e'
,
'3'
,
'2'
,
0
};
static
const
WCHAR
title
[]
=
{
'C'
,
'l'
,
'i'
,
'p'
,
'b'
,
'o'
,
'a'
,
'r'
,
'd'
,
'W'
,
'i'
,
'n'
,
'd'
,
'o'
,
'w'
,
0
};
HINSTANCE
hinst
=
GetModuleHandleW
(
ole32W
);
class
.
cbSize
=
sizeof
(
class
);
class
.
style
=
0
;
class
.
lpfnWndProc
=
clipbrd_wndproc
;
class
.
cbClsExtra
=
0
;
class
.
cbWndExtra
=
0
;
class
.
hInstance
=
hinst
;
class
.
hIcon
=
0
;
class
.
hCursor
=
0
;
class
.
hbrBackground
=
0
;
class
.
lpszMenuName
=
NULL
;
class
.
lpszClassName
=
clipbrd_wndclass
;
class
.
hIconSm
=
NULL
;
RegisterClassExW
(
&
class
);
return
CreateWindowW
(
clipbrd_wndclass
,
title
,
WS_POPUP
|
WS_CLIPSIBLINGS
|
WS_OVERLAPPED
,
CW_USEDEFAULT
,
CW_USEDEFAULT
,
CW_USEDEFAULT
,
CW_USEDEFAULT
,
NULL
,
NULL
,
hinst
,
0
);
}
/*********************************************************************
* set_dataobject_format
*
...
...
@@ -1416,12 +1436,12 @@ static HRESULT set_dataobject_format(HWND hwnd)
* CLIPBRD_E_CANT_SET SetClipboard failed
*/
HRESULT
WINAPI
OleSetClipboard
(
IDataObject
*
pDataObj
)
HRESULT
WINAPI
OleSetClipboard
(
IDataObject
*
data
)
{
HRESULT
hr
;
ole_clipbrd
*
clipbrd
;
TRACE
(
"(%p)
\n
"
,
pDataObj
);
TRACE
(
"(%p)
\n
"
,
data
);
if
(
FAILED
(
hr
=
get_ole_clipbrd
(
&
clipbrd
)))
return
hr
;
...
...
@@ -1444,25 +1464,8 @@ HRESULT WINAPI OleSetClipboard(IDataObject* pDataObj)
goto
end
;
}
/*
* If we are already holding on to an IDataObject first release that.
*/
if
(
clipbrd
->
pIDataObjectSrc
)
{
IDataObject_Release
(
clipbrd
->
pIDataObjectSrc
);
clipbrd
->
pIDataObjectSrc
=
NULL
;
HeapFree
(
GetProcessHeap
(),
0
,
clipbrd
->
cached_enum
);
clipbrd
->
cached_enum
=
NULL
;
}
/* A NULL value indicates that the clipboard should be emptied. */
clipbrd
->
pIDataObjectSrc
=
pDataObj
;
if
(
pDataObj
)
{
IDataObject_AddRef
(
clipbrd
->
pIDataObjectSrc
);
hr
=
set_clipboard_formats
(
clipbrd
,
pDataObj
);
if
(
FAILED
(
hr
))
goto
end
;
}
hr
=
set_src_dataobject
(
clipbrd
,
data
);
if
(
FAILED
(
hr
))
goto
end
;
hr
=
set_dataobject_format
(
clipbrd
->
hWndClipboard
);
...
...
@@ -1472,13 +1475,7 @@ end:
if
(
FAILED
(
hr
)
)
{
if
(
clipbrd
->
pIDataObjectSrc
)
{
IDataObject_Release
(
clipbrd
->
pIDataObjectSrc
);
clipbrd
->
pIDataObjectSrc
=
NULL
;
HeapFree
(
GetProcessHeap
(),
0
,
clipbrd
->
cached_enum
);
clipbrd
->
cached_enum
=
NULL
;
}
set_src_dataobject
(
clipbrd
,
NULL
);
}
return
hr
;
...
...
@@ -1561,10 +1558,7 @@ HRESULT WINAPI OleFlushClipboard(void)
hr
=
set_dataobject_format
(
NULL
);
IDataObject_Release
(
clipbrd
->
pIDataObjectSrc
);
clipbrd
->
pIDataObjectSrc
=
NULL
;
HeapFree
(
GetProcessHeap
(),
0
,
clipbrd
->
cached_enum
);
clipbrd
->
cached_enum
=
NULL
;
set_src_dataobject
(
clipbrd
,
NULL
);
end:
...
...
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