winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
April 2009
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
2 participants
664 discussions
Start a n
N
ew thread
Huw Davies : ole32: After a call to GetData the consumer should hold a ref on the source data object .
by Alexandre Julliard
16 Apr '09
16 Apr '09
Module: wine Branch: master Commit: fca4ed5596eaab51438771df58178c4a8184713d URL:
http://source.winehq.org/git/wine.git/?a=commit;h=fca4ed5596eaab51438771df5…
Author: Huw Davies <huw(a)codeweavers.com> Date: Thu Apr 16 12:17:00 2009 +0100 ole32: After a call to GetData the consumer should hold a ref on the source data object. --- dlls/ole32/clipboard.c | 36 ++++++++++++++---------- dlls/ole32/tests/clipboard.c | 61 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 81 insertions(+), 16 deletions(-) diff --git a/dlls/ole32/clipboard.c b/dlls/ole32/clipboard.c index b7527e9..c1ef5d3 100644 --- a/dlls/ole32/clipboard.c +++ b/dlls/ole32/clipboard.c @@ -134,6 +134,8 @@ typedef struct snapshot LONG ref; DWORD seq_no; /* Clipboard sequence number corresponding to this snapshot */ + + IDataObject *data; /* If we unmarshal a remote data object we hold a ref here */ } snapshot; /**************************************************************************** @@ -830,6 +832,8 @@ static ULONG WINAPI snapshot_Release(IDataObject *iface) ole_clipbrd *clipbrd; HRESULT hr = get_ole_clipbrd(&clipbrd); + if(This->data) IDataObject_Release(This->data); + if(SUCCEEDED(hr) && clipbrd->latest_snapshot == This) clipbrd->latest_snapshot = NULL; HeapFree(GetProcessHeap(), 0, This); @@ -907,25 +911,26 @@ static HRESULT WINAPI snapshot_GetData(IDataObject *iface, FORMATETC *pformatetcIn, STGMEDIUM *pmedium) { - HANDLE h, hData = 0; - HRESULT hr; - IDataObject *data; + snapshot *This = impl_from_IDataObject(iface); + HANDLE h, hData = 0; + HRESULT hr; - TRACE("(%p,%p,%p)\n", iface, pformatetcIn, pmedium); + TRACE("(%p,%p,%p)\n", iface, pformatetcIn, pmedium); - if ( !pformatetcIn || !pmedium ) - return E_INVALIDARG; + if ( !pformatetcIn || !pmedium ) return E_INVALIDARG; - if ( !OpenClipboard(NULL)) return CLIPBRD_E_CANT_OPEN; + if ( !OpenClipboard(NULL)) return CLIPBRD_E_CANT_OPEN; + + if(!This->data) + hr = get_current_dataobject(&This->data); + + if(This->data) + { + hr = IDataObject_GetData(This->data, pformatetcIn, pmedium); + CloseClipboard(); + return hr; + } - hr = get_current_dataobject(&data); - if ( hr == S_OK ) - { - hr = IDataObject_GetData(data, pformatetcIn, pmedium); - IDataObject_Release(data); - CloseClipboard(); - return hr; - } /* * Otherwise, get the data from the windows clipboard using GetClipboardData @@ -1130,6 +1135,7 @@ static snapshot *snapshot_construct(DWORD seq_no) This->lpVtbl = &snapshot_vtable; This->ref = 0; This->seq_no = seq_no; + This->data = NULL; return This; } diff --git a/dlls/ole32/tests/clipboard.c b/dlls/ole32/tests/clipboard.c index eef57bd..c77ec95 100644 --- a/dlls/ole32/tests/clipboard.c +++ b/dlls/ole32/tests/clipboard.c @@ -862,14 +862,27 @@ static void test_set_clipboard(void) OleUninitialize(); } +static inline ULONG count_refs(IDataObject *d) +{ + IDataObject_AddRef(d); + return IDataObject_Release(d); +} + static void test_consumer_refs(void) { HRESULT hr; IDataObject *src, *get1, *get2, *get3; - LONG refs; + ULONG refs, old_refs; + FORMATETC fmt; + STGMEDIUM med; + + InitFormatEtc(fmt, CF_TEXT, TYMED_HGLOBAL); OleInitialize(NULL); + /* First show that each clipboard state results in + a different data object */ + hr = DataObjectImpl_CreateText("data1", &src); ok(hr == S_OK, "got %08x\n", hr); @@ -888,6 +901,12 @@ static void test_consumer_refs(void) OleFlushClipboard(); + DataObjectImpl_GetData_calls = 0; + hr = IDataObject_GetData(get1, &fmt, &med); + ok(hr == S_OK, "got %08x\n", hr); + ok(DataObjectImpl_GetData_calls == 0, "GetData called\n"); + ReleaseStgMedium(&med); + hr = OleGetClipboard(&get2); ok(hr == S_OK, "got %08x\n", hr); @@ -904,6 +923,46 @@ static void test_consumer_refs(void) IDataObject_Release(get3); IDataObject_Release(get2); IDataObject_Release(get1); + + /* Now call GetData before the flush and show that this + takes a ref on our src data obj. */ + + hr = OleSetClipboard(src); + ok(hr == S_OK, "got %08x\n", hr); + + old_refs = count_refs(src); + trace("old_refs %d\n", old_refs); + + hr = OleGetClipboard(&get1); + ok(hr == S_OK, "got %08x\n", hr); + + refs = count_refs(src); + ok(refs == old_refs, "%d %d\n", refs, old_refs); + + DataObjectImpl_GetData_calls = 0; + hr = IDataObject_GetData(get1, &fmt, &med); + ok(hr == S_OK, "got %08x\n", hr); + ok(DataObjectImpl_GetData_calls == 1, "GetData not called\n"); + ReleaseStgMedium(&med); + refs = count_refs(src); + ok(refs == old_refs + 1, "%d %d\n", refs, old_refs); + + OleFlushClipboard(); + + DataObjectImpl_GetData_calls = 0; + hr = IDataObject_GetData(get1, &fmt, &med); + ok(hr == S_OK, "got %08x\n", hr); + ok(DataObjectImpl_GetData_calls == 1, "GetData not called\n"); + ReleaseStgMedium(&med); + + refs = count_refs(src); + ok(refs == 2, "%d\n", refs); + + IDataObject_Release(get1); + + refs = count_refs(src); + ok(refs == 1, "%d\n", refs); + IDataObject_Release(src); OleUninitialize();
1
0
0
0
Huw Davies : ole32: Now that the consumer side of the clipboard separated from the main clipboard object , simplify the initialization code.
by Alexandre Julliard
16 Apr '09
16 Apr '09
Module: wine Branch: master Commit: d2156f3894f5a5bfa31191c6241ebdbf60692eb0 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=d2156f3894f5a5bfa31191c62…
Author: Huw Davies <huw(a)codeweavers.com> Date: Thu Apr 16 12:16:17 2009 +0100 ole32: Now that the consumer side of the clipboard separated from the main clipboard object, simplify the initialization code. --- dlls/ole32/clipboard.c | 117 +++++++++++++++++++++--------------------------- 1 files changed, 51 insertions(+), 66 deletions(-) diff --git a/dlls/ole32/clipboard.c b/dlls/ole32/clipboard.c index a93ff85..b7527e9 100644 --- a/dlls/ole32/clipboard.c +++ b/dlls/ole32/clipboard.c @@ -813,31 +813,6 @@ static ULONG WINAPI snapshot_AddRef(IDataObject *iface) return InterlockedIncrement(&This->ref); } -/*********************************************************************** - * destroy_clipbrd_window - * Destroy the clipboard window and unregister its class - */ -static void destroy_clipbrd_window(HWND hwnd) -{ - static const WCHAR ole32W[] = {'o','l','e','3','2',0}; - HINSTANCE hinst = GetModuleHandleW(ole32W); - - DestroyWindow(hwnd); - UnregisterClassW( clipbrd_wndclass, hinst ); -} - -static void OLEClipbrd_Destroy(ole_clipbrd* This) -{ - TRACE("()\n"); - - if (!This) return; - - if ( This->window ) destroy_clipbrd_window(This->window); - - IStream_Release(This->marshal_data); - HeapFree(GetProcessHeap(), 0, This); -} - /************************************************************************ * snapshot_Release */ @@ -1160,35 +1135,8 @@ static snapshot *snapshot_construct(DWORD seq_no) } /********************************************************* - * Construct the OLEClipbrd class. + * register_clipboard_formats */ -static ole_clipbrd* OLEClipbrd_Construct(void) -{ - ole_clipbrd* This; - HGLOBAL h; - - This = HeapAlloc( GetProcessHeap(), 0, sizeof(*This) ); - if (!This) return NULL; - - This->latest_snapshot = NULL; - This->window = NULL; - This->src_data = NULL; - This->cached_enum = NULL; - - h = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, 0); - if(!h) goto error; - - if(FAILED(CreateStreamOnHGlobal(h, TRUE, &This->marshal_data))) - goto error; - - return This; - -error: - if(h) GlobalFree(h); - HeapFree(GetProcessHeap(), 0, This); - return NULL; -} - static void register_clipboard_formats(void) { static const WCHAR DataObjectW[] = { 'D','a','t','a','O','b','j','e','c','t',0 }; @@ -1209,15 +1157,40 @@ static void register_clipboard_formats(void) */ void OLEClipbrd_Initialize(void) { - register_clipboard_formats(); + register_clipboard_formats(); - if ( !theOleClipboard ) - { - TRACE("()\n"); - theOleClipboard = OLEClipbrd_Construct(); - } -} + if ( !theOleClipboard ) + { + ole_clipbrd* clipbrd; + HGLOBAL h; + + TRACE("()\n"); + + clipbrd = HeapAlloc( GetProcessHeap(), 0, sizeof(*clipbrd) ); + if (!clipbrd) return; + clipbrd->latest_snapshot = NULL; + clipbrd->window = NULL; + clipbrd->src_data = NULL; + clipbrd->cached_enum = NULL; + + h = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, 0); + if(!h) + { + HeapFree(GetProcessHeap(), 0, clipbrd); + return; + } + + if(FAILED(CreateStreamOnHGlobal(h, TRUE, &clipbrd->marshal_data))) + { + GlobalFree(h); + HeapFree(GetProcessHeap(), 0, clipbrd); + return; + } + + theOleClipboard = clipbrd; + } +} /*********************************************************************** * OLEClipbrd_UnInitialize() @@ -1225,13 +1198,25 @@ void OLEClipbrd_Initialize(void) */ void OLEClipbrd_UnInitialize(void) { - TRACE("()\n"); + ole_clipbrd *clipbrd = theOleClipboard; - if ( theOleClipboard ) - { - OLEClipbrd_Destroy( theOleClipboard ); - theOleClipboard = NULL; - } + TRACE("()\n"); + + if ( clipbrd ) + { + static const WCHAR ole32W[] = {'o','l','e','3','2',0}; + HINSTANCE hinst = GetModuleHandleW(ole32W); + + if ( clipbrd->window ) + { + DestroyWindow(clipbrd->window); + UnregisterClassW( clipbrd_wndclass, hinst ); + } + + IStream_Release(clipbrd->marshal_data); + HeapFree(GetProcessHeap(), 0, clipbrd); + theOleClipboard = NULL; + } } /*********************************************************************
1
0
0
0
Huw Davies : ole32: The consumer data object is not a singleton, but reflects the state of the clipboard when it was acquired.
by Alexandre Julliard
16 Apr '09
16 Apr '09
Module: wine Branch: master Commit: df08d463c921a94681d04b9b00952808e792ed34 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=df08d463c921a94681d04b9b0…
Author: Huw Davies <huw(a)codeweavers.com> Date: Thu Apr 16 12:14:49 2009 +0100 ole32: The consumer data object is not a singleton, but reflects the state of the clipboard when it was acquired. --- dlls/ole32/clipboard.c | 294 ++++++++++++++++++++---------------------- dlls/ole32/tests/clipboard.c | 4 - 2 files changed, 140 insertions(+), 158 deletions(-) Diff:
http://source.winehq.org/git/wine.git/?a=commitdiff;h=df08d463c921a94681d04…
1
0
0
0
Huw Davies : ole32/tests: Tests that show the consumer data object isn' t a singleton.
by Alexandre Julliard
16 Apr '09
16 Apr '09
Module: wine Branch: master Commit: f8a1b7e5a5c375af628cb622c0f05c283b24dc89 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=f8a1b7e5a5c375af628cb622c…
Author: Huw Davies <huw(a)codeweavers.com> Date: Thu Apr 16 12:14:19 2009 +0100 ole32/tests: Tests that show the consumer data object isn't a singleton. --- dlls/ole32/tests/clipboard.c | 51 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 51 insertions(+), 0 deletions(-) diff --git a/dlls/ole32/tests/clipboard.c b/dlls/ole32/tests/clipboard.c index fc55d38..aadc1ec 100644 --- a/dlls/ole32/tests/clipboard.c +++ b/dlls/ole32/tests/clipboard.c @@ -862,8 +862,59 @@ static void test_set_clipboard(void) OleUninitialize(); } +static void test_consumer_refs(void) +{ + HRESULT hr; + IDataObject *src, *get1, *get2, *get3; + LONG refs; + + OleInitialize(NULL); + + hr = DataObjectImpl_CreateText("data1", &src); + ok(hr == S_OK, "got %08x\n", hr); + + hr = OleSetClipboard(src); + ok(hr == S_OK, "got %08x\n", hr); + + hr = OleGetClipboard(&get1); + ok(hr == S_OK, "got %08x\n", hr); + + hr = OleGetClipboard(&get2); + ok(hr == S_OK, "got %08x\n", hr); + + ok(get1 == get2, "data objects differ\n"); + refs = IDataObject_Release(get2); +todo_wine + ok(refs == 1, "got %d\n", refs); + + OleFlushClipboard(); + + hr = OleGetClipboard(&get2); + ok(hr == S_OK, "got %08x\n", hr); + +todo_wine + ok(get1 != get2, "data objects match\n"); + + OleSetClipboard(NULL); + + hr = OleGetClipboard(&get3); + ok(hr == S_OK, "got %08x\n", hr); + +todo_wine { + ok(get1 != get3, "data objects match\n"); + ok(get2 != get3, "data objects match\n"); +} + + IDataObject_Release(get3); + IDataObject_Release(get2); + IDataObject_Release(get1); + IDataObject_Release(src); + + OleUninitialize(); +} START_TEST(clipboard) { test_set_clipboard(); + test_consumer_refs(); }
1
0
0
0
Huw Davies : ole32: If there' s a current data object on the ole clipboard GetData should use it.
by Alexandre Julliard
16 Apr '09
16 Apr '09
Module: wine Branch: master Commit: 4311691a88da680dd0c81078b8151d5300806323 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=4311691a88da680dd0c81078b…
Author: Huw Davies <huw(a)codeweavers.com> Date: Thu Apr 16 12:13:39 2009 +0100 ole32: If there's a current data object on the ole clipboard GetData should use it. --- dlls/ole32/clipboard.c | 110 +++++++++++++++++++++++++++++++++++++---------- 1 files changed, 86 insertions(+), 24 deletions(-) diff --git a/dlls/ole32/clipboard.c b/dlls/ole32/clipboard.c index 9e92abe..83d923e 100644 --- a/dlls/ole32/clipboard.c +++ b/dlls/ole32/clipboard.c @@ -859,14 +859,71 @@ static ULONG WINAPI OLEClipbrd_IDataObject_Release( return ref; } +/************************************************************ + * get_current_ole_clip_window + * + * Return the window that owns the ole clipboard. + * + * If the clipboard is flushed or not owned by ole this will + * return NULL. + */ +static HWND get_current_ole_clip_window(void) +{ + HGLOBAL h; + HWND *ptr, wnd; + + h = GetClipboardData(dataobject_clipboard_format); + if(!h) return NULL; + ptr = GlobalLock(h); + if(!ptr) return NULL; + wnd = *ptr; + GlobalUnlock(h); + return wnd; +} + +/************************************************************ + * get_current_dataobject + * + * Return an unmarshalled IDataObject if there is a current + * (ie non-flushed) object on the ole clipboard. + */ +static HRESULT get_current_dataobject(IDataObject **data) +{ + HRESULT hr = S_FALSE; + HWND wnd = get_current_ole_clip_window(); + HGLOBAL h; + void *ptr; + IStream *stm; + LARGE_INTEGER pos; + + *data = NULL; + if(!wnd) return S_FALSE; + + h = GetPropW(wnd, wine_marshal_dataobject); + if(!h) return S_FALSE; + ptr = GlobalLock(h); + if(!ptr) return S_FALSE; + + hr = CreateStreamOnHGlobal(NULL, TRUE, &stm); + if(FAILED(hr)) goto end; + + hr = IStream_Write(stm, ptr, GlobalSize(h), NULL); + if(SUCCEEDED(hr)) + { + pos.QuadPart = 0; + IStream_Seek(stm, pos, STREAM_SEEK_SET, NULL); + hr = CoUnmarshalInterface(stm, &IID_IDataObject, (void**)data); + } + IStream_Release(stm); + +end: + GlobalUnlock(h); + return hr; +} /************************************************************************ * OLEClipbrd_IDataObject_GetData (IDataObject) * - * The OLE Clipboard's implementation of this method delegates to - * a data source if there is one or wraps around the windows clipboard - * - * See Windows documentation for more details on IDataObject methods. */ static HRESULT WINAPI OLEClipbrd_IDataObject_GetData( IDataObject* iface, @@ -874,39 +931,40 @@ static HRESULT WINAPI OLEClipbrd_IDataObject_GetData( STGMEDIUM* pmedium) { HANDLE h, hData = 0; - ole_clipbrd *This = impl_from_IDataObject(iface); HRESULT hr; + IDataObject *data; TRACE("(%p,%p,%p)\n", iface, pformatetcIn, pmedium); if ( !pformatetcIn || !pmedium ) return E_INVALIDARG; - /* - * If we have a data source placed on the clipboard (via OleSetClipboard) - * simply delegate to the source object's QueryGetData - * NOTE: This code assumes that the IDataObject is in the same address space! - * We will need to add marshalling support when Wine handles multiple processes. - */ - if ( This->src_data ) + if ( !OpenClipboard(NULL)) return CLIPBRD_E_CANT_OPEN; + + hr = get_current_dataobject(&data); + if ( hr == S_OK ) { - return IDataObject_GetData(This->src_data, pformatetcIn, pmedium); + hr = IDataObject_GetData(data, pformatetcIn, pmedium); + IDataObject_Release(data); + CloseClipboard(); + return hr; } - if ( pformatetcIn->lindex != -1 ) - return DV_E_FORMATETC; - - if ( (pformatetcIn->tymed & TYMED_HGLOBAL) != TYMED_HGLOBAL ) - return DV_E_TYMED; -/* - if ( pformatetcIn->dwAspect != DVASPECT_CONTENT ) - return DV_E_DVASPECT; -*/ - /* * Otherwise, get the data from the windows clipboard using GetClipboardData */ - if ( !OpenClipboard(NULL)) return CLIPBRD_E_CANT_OPEN; + + if ( pformatetcIn->lindex != -1 ) + { + hr = DV_E_FORMATETC; + goto end; + } + + if ( (pformatetcIn->tymed & TYMED_HGLOBAL) != TYMED_HGLOBAL ) + { + hr = DV_E_TYMED; + goto end; + } h = GetClipboardData(pformatetcIn->cfFormat); hr = dup_global_mem(h, GMEM_MOVEABLE, &hData); @@ -918,12 +976,16 @@ static HRESULT WINAPI OLEClipbrd_IDataObject_GetData( pmedium->u.hGlobal = hData; pmedium->pUnkForRelease = NULL; +end: if ( !CloseClipboard() ) return CLIPBRD_E_CANT_CLOSE; if(FAILED(hr)) return hr; return (hData == 0) ? DV_E_FORMATETC : S_OK; } +/************************************************************************ + * OLEClipbrd_IDataObject_GetDataHere (IDataObject) + */ static HRESULT WINAPI OLEClipbrd_IDataObject_GetDataHere( IDataObject* iface, LPFORMATETC pformatetc,
1
0
0
0
Huw Davies : ole32: Store the marshalled IDataObject in a window property of the clipboard window .
by Alexandre Julliard
16 Apr '09
16 Apr '09
Module: wine Branch: master Commit: 6d4a39409995c91372c182aa55f791d440ba34a1 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=6d4a39409995c91372c182aa5…
Author: Huw Davies <huw(a)codeweavers.com> Date: Thu Apr 16 12:12:03 2009 +0100 ole32: Store the marshalled IDataObject in a window property of the clipboard window. This is somewhat different from how Windows behaves. Windows stores two properties; an IID and an endpoint number. --- dlls/ole32/clipboard.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 56 insertions(+), 1 deletions(-) diff --git a/dlls/ole32/clipboard.c b/dlls/ole32/clipboard.c index 3cfb1a8..9e92abe 100644 --- a/dlls/ole32/clipboard.c +++ b/dlls/ole32/clipboard.c @@ -137,6 +137,7 @@ typedef struct ole_clipbrd HWND window; /* Hidden clipboard window */ IDataObject *src_data; /* Source object passed to OleSetClipboard */ ole_priv_data *cached_enum; /* Cached result from the enumeration of src data object */ + IStream *marshal_data; /* Stream onto which to marshal src_data */ } ole_clipbrd; static inline ole_clipbrd *impl_from_IDataObject(IDataObject *iface) @@ -174,6 +175,8 @@ static inline HRESULT get_ole_clipbrd(ole_clipbrd **clipbrd) */ static const WCHAR clipbrd_wndclass[] = {'C','L','I','P','B','R','D','W','N','D','C','L','A','S','S',0}; +static const WCHAR wine_marshal_dataobject[] = {'W','i','n','e',' ','m','a','r','s','h','a','l',' ','d','a','t','a','o','b','j','e','c','t',0}; + static UINT dataobject_clipboard_format; static UINT ole_priv_data_clipboard_format; static UINT embed_source_clipboard_format; @@ -829,6 +832,7 @@ static void OLEClipbrd_Destroy(ole_clipbrd* This) if ( This->window ) destroy_clipbrd_window(This->window); + IStream_Release(This->marshal_data); HeapFree(GetProcessHeap(), 0, This); } @@ -1119,6 +1123,7 @@ static const IDataObjectVtbl OLEClipbrd_IDataObject_VTable = static ole_clipbrd* OLEClipbrd_Construct(void) { ole_clipbrd* This; + HGLOBAL h; This = HeapAlloc( GetProcessHeap(), 0, sizeof(*This) ); if (!This) return NULL; @@ -1130,7 +1135,18 @@ static ole_clipbrd* OLEClipbrd_Construct(void) This->src_data = NULL; This->cached_enum = NULL; + h = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, 0); + if(!h) goto error; + + if(FAILED(CreateStreamOnHGlobal(h, TRUE, &This->marshal_data))) + goto error; + return This; + +error: + if(h) GlobalFree(h); + HeapFree(GetProcessHeap(), 0, This); + return NULL; } static void register_clipboard_formats(void) @@ -1291,17 +1307,45 @@ static inline HRESULT get_clipbrd_window(ole_clipbrd *clipbrd, HWND *wnd) return *wnd ? S_OK : E_FAIL; } + +/********************************************************************** + * release_marshal_data + * + * Releases the data and sets the stream back to zero size. + */ +static inline void release_marshal_data(IStream *stm) +{ + LARGE_INTEGER pos; + ULARGE_INTEGER size; + pos.QuadPart = size.QuadPart = 0; + + IStream_Seek(stm, pos, STREAM_SEEK_SET, NULL); + CoReleaseMarshalData(stm); + IStream_Seek(stm, pos, STREAM_SEEK_SET, NULL); + IStream_SetSize(stm, size); +} + /*********************************************************************** * set_src_dataobject * * Clears and sets the clipboard's src IDataObject. + * + * To marshal the source dataobject we do something rather different from Windows. + * We set a window prop which contains the marshalled data. + * Windows set two props one of which is an IID, the other is an endpoint number. */ static HRESULT set_src_dataobject(ole_clipbrd *clipbrd, IDataObject *data) { - HRESULT hr = S_OK; + HRESULT hr; + HWND wnd; + + if(FAILED(hr = get_clipbrd_window(clipbrd, &wnd))) return hr; if(clipbrd->src_data) { + RemovePropW(wnd, wine_marshal_dataobject); + release_marshal_data(clipbrd->marshal_data); + IDataObject_Release(clipbrd->src_data); clipbrd->src_data = NULL; HeapFree(GetProcessHeap(), 0, clipbrd->cached_enum); @@ -1310,8 +1354,19 @@ static HRESULT set_src_dataobject(ole_clipbrd *clipbrd, IDataObject *data) if(data) { + HGLOBAL h; + IUnknown *unk; + IDataObject_AddRef(data); clipbrd->src_data = data; + + IDataObject_QueryInterface(data, &IID_IUnknown, (void**)&unk); + hr = CoMarshalInterface(clipbrd->marshal_data, &IID_IDataObject, unk, + MSHCTX_LOCAL, NULL, MSHLFLAGS_TABLESTRONG); + IUnknown_Release(unk); /* Don't hold a ref on IUnknown, we have one on IDataObject. */ + if(FAILED(hr)) return hr; + GetHGlobalFromStream(clipbrd->marshal_data, &h); + SetPropW(wnd, wine_marshal_dataobject, h); hr = set_clipboard_formats(clipbrd, data); } return hr;
1
0
0
0
Huw Davies : ole32: Rename a variable.
by Alexandre Julliard
16 Apr '09
16 Apr '09
Module: wine Branch: master Commit: 1ec12f68b184baf8b0cd28592085a3aafedc75d5 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=1ec12f68b184baf8b0cd28592…
Author: Huw Davies <huw(a)codeweavers.com> Date: Thu Apr 16 12:09:56 2009 +0100 ole32: Rename a variable. --- dlls/ole32/clipboard.c | 45 ++++++++++++++++++++++----------------------- 1 files changed, 22 insertions(+), 23 deletions(-) diff --git a/dlls/ole32/clipboard.c b/dlls/ole32/clipboard.c index 5990d90..3cfb1a8 100644 --- a/dlls/ole32/clipboard.c +++ b/dlls/ole32/clipboard.c @@ -135,7 +135,7 @@ typedef struct ole_clipbrd LONG ref; HWND window; /* Hidden clipboard window */ - IDataObject *pIDataObjectSrc; /* Source object passed to OleSetClipboard */ + IDataObject *src_data; /* Source object passed to OleSetClipboard */ ole_priv_data *cached_enum; /* Cached result from the enumeration of src data object */ } ole_clipbrd; @@ -461,7 +461,7 @@ static HRESULT render_embed_source_hack(IDataObject *data, LPFORMATETC fmt) hr = StgCreateDocfileOnILockBytes(ptrILockBytes, STGM_SHARE_EXCLUSIVE|STGM_READWRITE, 0, &std.u.pstg); ILockBytes_Release(ptrILockBytes); - if (FAILED(hr = IDataObject_GetDataHere(theOleClipboard->pIDataObjectSrc, fmt, &std))) + if (FAILED(hr = IDataObject_GetDataHere(theOleClipboard->src_data, fmt, &std))) { WARN("() : IDataObject_GetDataHere failed to render clipboard data! (%x)\n", hr); GlobalFree(hStorage); @@ -485,7 +485,7 @@ static HRESULT render_embed_source_hack(IDataObject *data, LPFORMATETC fmt) /* Get the metafile picture out of it */ - if (SUCCEEDED(hr = IDataObject_GetData(theOleClipboard->pIDataObjectSrc, &fmt2, &std2))) + if (SUCCEEDED(hr = IDataObject_GetData(theOleClipboard->src_data, &fmt2, &std2))) { mfp = GlobalLock(std2.u.hGlobal); } @@ -884,9 +884,9 @@ static HRESULT WINAPI OLEClipbrd_IDataObject_GetData( * NOTE: This code assumes that the IDataObject is in the same address space! * We will need to add marshalling support when Wine handles multiple processes. */ - if ( This->pIDataObjectSrc ) + if ( This->src_data ) { - return IDataObject_GetData(This->pIDataObjectSrc, pformatetcIn, pmedium); + return IDataObject_GetData(This->src_data, pformatetcIn, pmedium); } if ( pformatetcIn->lindex != -1 ) @@ -1127,7 +1127,7 @@ static ole_clipbrd* OLEClipbrd_Construct(void) This->ref = 1; This->window = NULL; - This->pIDataObjectSrc = NULL; + This->src_data = NULL; This->cached_enum = NULL; return This; @@ -1300,10 +1300,10 @@ static HRESULT set_src_dataobject(ole_clipbrd *clipbrd, IDataObject *data) { HRESULT hr = S_OK; - if(clipbrd->pIDataObjectSrc) + if(clipbrd->src_data) { - IDataObject_Release(clipbrd->pIDataObjectSrc); - clipbrd->pIDataObjectSrc = NULL; + IDataObject_Release(clipbrd->src_data); + clipbrd->src_data = NULL; HeapFree(GetProcessHeap(), 0, clipbrd->cached_enum); clipbrd->cached_enum = NULL; } @@ -1311,7 +1311,7 @@ static HRESULT set_src_dataobject(ole_clipbrd *clipbrd, IDataObject *data) if(data) { IDataObject_AddRef(data); - clipbrd->pIDataObjectSrc = data; + clipbrd->src_data = data; hr = set_clipboard_formats(clipbrd, data); } return hr; @@ -1337,7 +1337,7 @@ static LRESULT CALLBACK clipbrd_wndproc(HWND hwnd, UINT message, WPARAM wparam, entry = find_format_in_list(clipbrd->cached_enum->entries, clipbrd->cached_enum->count, cf); if(entry) - render_format(clipbrd->pIDataObjectSrc, &entry->fmtetc); + render_format(clipbrd->src_data, &entry->fmtetc); break; } @@ -1352,7 +1352,7 @@ static LRESULT CALLBACK clipbrd_wndproc(HWND hwnd, UINT message, WPARAM wparam, for(i = 0; i < clipbrd->cached_enum->count; i++) { if(entries[i].first_use) - render_format(clipbrd->pIDataObjectSrc, &entries[i].fmtetc); + render_format(clipbrd->src_data, &entries[i].fmtetc); } break; } @@ -1530,7 +1530,7 @@ HRESULT WINAPI OleFlushClipboard(void) /* * Already flushed or no source DataObject? Nothing to do. */ - if (!clipbrd->pIDataObjectSrc) return S_OK; + if (!clipbrd->src_data) return S_OK; if (!OpenClipboard(wnd)) return CLIPBRD_E_CANT_OPEN; @@ -1538,7 +1538,7 @@ HRESULT WINAPI OleFlushClipboard(void) * Render all HGLOBAL formats supported by the source into * the windows clipboard. */ - if ( FAILED( hr = IDataObject_EnumFormatEtc( clipbrd->pIDataObjectSrc, + if ( FAILED( hr = IDataObject_EnumFormatEtc( clipbrd->src_data, DATADIR_GET, &penumFormatetc) )) goto end; @@ -1553,7 +1553,7 @@ HRESULT WINAPI OleFlushClipboard(void) GetClipboardFormatNameA(rgelt.cfFormat, szFmtName, sizeof(szFmtName)-1) ? szFmtName : ""); - if ( FAILED(render_format( clipbrd->pIDataObjectSrc, &rgelt )) ) + if ( FAILED(render_format( clipbrd->src_data, &rgelt )) ) continue; } } @@ -1575,16 +1575,15 @@ end: /*********************************************************************** * OleIsCurrentClipboard [OLE32.@] */ -HRESULT WINAPI OleIsCurrentClipboard(IDataObject *pDataObject) +HRESULT WINAPI OleIsCurrentClipboard(IDataObject *data) { - HRESULT hr; - ole_clipbrd *clipbrd; - TRACE("()\n"); + HRESULT hr; + ole_clipbrd *clipbrd; + TRACE("()\n"); - if(FAILED(hr = get_ole_clipbrd(&clipbrd))) return hr; + if(FAILED(hr = get_ole_clipbrd(&clipbrd))) return hr; - if (pDataObject == NULL) - return S_FALSE; + if (data == NULL) return S_FALSE; - return (pDataObject == clipbrd->pIDataObjectSrc) ? S_OK : S_FALSE; + return (data == clipbrd->src_data) ? S_OK : S_FALSE; }
1
0
0
0
Huw Davies : ole32: Don't pass a window if we're reading from the clipboard .
by Alexandre Julliard
16 Apr '09
16 Apr '09
Module: wine Branch: master Commit: bd9eb3b527585389686d6573d4aa52bd9f37c0ec URL:
http://source.winehq.org/git/wine.git/?a=commit;h=bd9eb3b527585389686d6573d…
Author: Huw Davies <huw(a)codeweavers.com> Date: Thu Apr 16 12:09:19 2009 +0100 ole32: Don't pass a window if we're reading from the clipboard. --- dlls/ole32/clipboard.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diff --git a/dlls/ole32/clipboard.c b/dlls/ole32/clipboard.c index 0e2acf4..5990d90 100644 --- a/dlls/ole32/clipboard.c +++ b/dlls/ole32/clipboard.c @@ -902,7 +902,7 @@ static HRESULT WINAPI OLEClipbrd_IDataObject_GetData( /* * Otherwise, get the data from the windows clipboard using GetClipboardData */ - if ( !OpenClipboard(theOleClipboard->window)) return CLIPBRD_E_CANT_OPEN; + if ( !OpenClipboard(NULL)) return CLIPBRD_E_CANT_OPEN; h = GetClipboardData(pformatetcIn->cfFormat); hr = dup_global_mem(h, GMEM_MOVEABLE, &hData); @@ -1006,7 +1006,6 @@ static HRESULT WINAPI OLEClipbrd_IDataObject_EnumFormatEtc( IEnumFORMATETC** enum_fmt) { HRESULT hr = S_OK; - ole_clipbrd *This = impl_from_IDataObject(iface); HGLOBAL handle; ole_priv_data *data = NULL; @@ -1015,7 +1014,7 @@ static HRESULT WINAPI OLEClipbrd_IDataObject_EnumFormatEtc( *enum_fmt = NULL; if ( dwDirection != DATADIR_GET ) return E_NOTIMPL; - if ( !OpenClipboard(This->window) ) return CLIPBRD_E_CANT_OPEN; + if ( !OpenClipboard(NULL) ) return CLIPBRD_E_CANT_OPEN; handle = GetClipboardData( ole_priv_data_clipboard_format ); if(handle)
1
0
0
0
Huw Davies : ole32: Add a function to return (and possibly create) the clipboard's window.
by Alexandre Julliard
16 Apr '09
16 Apr '09
Module: wine Branch: master Commit: 6526b570e15dd0d31157e5432315b648cb2980f4 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=6526b570e15dd0d31157e5432…
Author: Huw Davies <huw(a)codeweavers.com> Date: Thu Apr 16 12:09:04 2009 +0100 ole32: Add a function to return (and possibly create) the clipboard's window. --- dlls/ole32/clipboard.c | 59 ++++++++++++++++++++++++++---------------------- 1 files changed, 32 insertions(+), 27 deletions(-) diff --git a/dlls/ole32/clipboard.c b/dlls/ole32/clipboard.c index 0b67476..0e2acf4 100644 --- a/dlls/ole32/clipboard.c +++ b/dlls/ole32/clipboard.c @@ -134,7 +134,7 @@ typedef struct ole_clipbrd LONG ref; - HWND hWndClipboard; /* Hidden clipboard window */ + HWND window; /* Hidden clipboard window */ IDataObject *pIDataObjectSrc; /* Source object passed to OleSetClipboard */ ole_priv_data *cached_enum; /* Cached result from the enumeration of src data object */ } ole_clipbrd; @@ -809,10 +809,10 @@ static ULONG WINAPI OLEClipbrd_IDataObject_AddRef( } /*********************************************************************** - * OLEClipbrd_DestroyWindow(HWND) + * destroy_clipbrd_window * Destroy the clipboard window and unregister its class */ -static void OLEClipbrd_DestroyWindow(HWND hwnd) +static void destroy_clipbrd_window(HWND hwnd) { static const WCHAR ole32W[] = {'o','l','e','3','2',0}; HINSTANCE hinst = GetModuleHandleW(ole32W); @@ -827,8 +827,7 @@ static void OLEClipbrd_Destroy(ole_clipbrd* This) if (!This) return; - if ( This->hWndClipboard ) - OLEClipbrd_DestroyWindow(This->hWndClipboard); + if ( This->window ) destroy_clipbrd_window(This->window); HeapFree(GetProcessHeap(), 0, This); } @@ -903,7 +902,7 @@ static HRESULT WINAPI OLEClipbrd_IDataObject_GetData( /* * Otherwise, get the data from the windows clipboard using GetClipboardData */ - if ( !OpenClipboard(theOleClipboard->hWndClipboard)) return CLIPBRD_E_CANT_OPEN; + if ( !OpenClipboard(theOleClipboard->window)) return CLIPBRD_E_CANT_OPEN; h = GetClipboardData(pformatetcIn->cfFormat); hr = dup_global_mem(h, GMEM_MOVEABLE, &hData); @@ -1016,7 +1015,7 @@ static HRESULT WINAPI OLEClipbrd_IDataObject_EnumFormatEtc( *enum_fmt = NULL; if ( dwDirection != DATADIR_GET ) return E_NOTIMPL; - if ( !OpenClipboard(This->hWndClipboard) ) return CLIPBRD_E_CANT_OPEN; + if ( !OpenClipboard(This->window) ) return CLIPBRD_E_CANT_OPEN; handle = GetClipboardData( ole_priv_data_clipboard_format ); if(handle) @@ -1128,7 +1127,7 @@ static ole_clipbrd* OLEClipbrd_Construct(void) This->lpvtbl = &OLEClipbrd_IDataObject_VTable; This->ref = 1; - This->hWndClipboard = NULL; + This->window = NULL; This->pIDataObjectSrc = NULL; This->cached_enum = NULL; @@ -1279,6 +1278,20 @@ static HRESULT set_clipboard_formats(ole_clipbrd *clipbrd, IDataObject *data) return S_OK; } +static HWND create_clipbrd_window(void); + +/*********************************************************************** + * get_clipbrd_window + */ +static inline HRESULT get_clipbrd_window(ole_clipbrd *clipbrd, HWND *wnd) +{ + if ( !clipbrd->window ) + clipbrd->window = create_clipbrd_window(); + + *wnd = clipbrd->window; + return *wnd ? S_OK : E_FAIL; +} + /*********************************************************************** * set_src_dataobject * @@ -1362,10 +1375,9 @@ static LRESULT CALLBACK clipbrd_wndproc(HWND hwnd, UINT message, WPARAM wparam, /*********************************************************************** - * OLEClipbrd_CreateWindow() - * Create the clipboard window + * create_clipbrd_window */ -static HWND OLEClipbrd_CreateWindow(void) +static HWND create_clipbrd_window(void) { WNDCLASSEXW class; static const WCHAR ole32W[] = {'o','l','e','3','2',0}; @@ -1440,24 +1452,16 @@ HRESULT WINAPI OleSetClipboard(IDataObject* data) { HRESULT hr; ole_clipbrd *clipbrd; + HWND wnd; TRACE("(%p)\n", data); if(FAILED(hr = get_ole_clipbrd(&clipbrd))) return hr; - /* - * If the Ole clipboard window hasn't been created yet, create it now. - */ - if ( !clipbrd->hWndClipboard ) - clipbrd->hWndClipboard = OLEClipbrd_CreateWindow(); - if ( !clipbrd->hWndClipboard ) return E_FAIL; + if(FAILED(hr = get_clipbrd_window(clipbrd, &wnd))) return hr; - if ( !OpenClipboard(clipbrd->hWndClipboard) ) return CLIPBRD_E_CANT_OPEN; + if ( !OpenClipboard(wnd) ) return CLIPBRD_E_CANT_OPEN; - /* - * Empty the current clipboard and make our window the clipboard owner - * NOTE: This will trigger a WM_DESTROYCLIPBOARD message - */ if ( !EmptyClipboard() ) { hr = CLIPBRD_E_CANT_EMPTY; @@ -1467,7 +1471,7 @@ HRESULT WINAPI OleSetClipboard(IDataObject* data) hr = set_src_dataobject(clipbrd, data); if(FAILED(hr)) goto end; - hr = set_dataobject_format(clipbrd->hWndClipboard); + hr = set_dataobject_format(wnd); end: @@ -1516,19 +1520,20 @@ HRESULT WINAPI OleFlushClipboard(void) FORMATETC rgelt; HRESULT hr; ole_clipbrd *clipbrd; + HWND wnd; TRACE("()\n"); if(FAILED(hr = get_ole_clipbrd(&clipbrd))) return hr; + if(FAILED(hr = get_clipbrd_window(clipbrd, &wnd))) return hr; + /* * Already flushed or no source DataObject? Nothing to do. */ - if (!clipbrd->pIDataObjectSrc) - return S_OK; + if (!clipbrd->pIDataObjectSrc) return S_OK; - if (!OpenClipboard(clipbrd->hWndClipboard)) - return CLIPBRD_E_CANT_OPEN; + if (!OpenClipboard(wnd)) return CLIPBRD_E_CANT_OPEN; /* * Render all HGLOBAL formats supported by the source into
1
0
0
0
Huw Davies : ole32: Add a helper function to set and release the source IDataObject.
by Alexandre Julliard
16 Apr '09
16 Apr '09
Module: wine Branch: master Commit: 6ce9922f3d98c15b827a8179e3d132f10aff7218 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=6ce9922f3d98c15b827a8179e…
Author: Huw Davies <huw(a)codeweavers.com> Date: Thu Apr 16 12:08:11 2009 +0100 ole32: Add a helper function to set and release the source IDataObject. --- dlls/ole32/clipboard.c | 244 +++++++++++++++++++++++------------------------ 1 files changed, 119 insertions(+), 125 deletions(-) diff --git a/dlls/ole32/clipboard.c b/dlls/ole32/clipboard.c index 2c39e45..0b67476 100644 --- a/dlls/ole32/clipboard.c +++ b/dlls/ole32/clipboard.c @@ -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:
1
0
0
0
← Newer
1
...
34
35
36
37
38
39
40
...
67
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
Results per page:
10
25
50
100
200