Opened 2 months ago

Last modified 2 months ago

#16297 new enhancement

wxSetClipboardData(wxDF_HTML)

Reported by: troelsk Owned by:
Priority: normal Milestone:
Component: wxMSW Version: dev-latest
Keywords: wxSetClipboardData wxClipboard Cc:
Blocked By: Blocking:
Patch: yes

Description

Patch: Enable this code for MinGW builds. Add example code.
Additional patch: Optimization; get rid of the temporary buffer, 1 buffer is enough.

Attachments (2)

html.patch download (3.9 KB) - added by troelsk 2 months ago.
MinGW, example
buffer.patch download (1.6 KB) - added by troelsk 2 months ago.
Optimization

Download all attachments as: .zip

Change History (6)

Changed 2 months ago by troelsk

MinGW, example

Changed 2 months ago by troelsk

Optimization

comment:1 Changed 2 months ago by troelsk

The HTML output works perfectly with LibreOffice (Ctrl+Shift+V).
(Works with Office/Word/Outlook too, except for line spacing, the space between lines is as tall as the text line itself)

comment:2 Changed 2 months ago by VZ

In 76632:

Remove spurious MSVC check around wxDF_HTML code in wxMSW.

For some reason, support for wxDF_HTML in clipboard code was disabled for
non-MSVC compilers. Enable it now as it's not compiler-specific at all.

See #16297.

comment:3 Changed 2 months ago by VZ

In 76633:

Remove spurious MSVC check around wxDF_HTML code in wxMSW.

For some reason, support for wxDF_HTML in clipboard code was disabled for
non-MSVC compilers. Enable it now as it's not compiler-specific at all.

See #16297.

comment:4 Changed 2 months ago by vadz

Thanks for noticing this compiler check, I agree that it has nothing to do there and remove it now. About the rest:

  1. I like the idea of showing HTML support in the sample, but could you please change it to use wxClipboardLocker? We want to show good practices in the samples... I also don't think this should be MSW-specific, both wxGTK and wxOSX support wxDF_HTML too.
  2. The buffer patch: what's the point of using one buffer but then calling GlobalReAlloc()? Can't we do just a single allocation? Also, could you please change the code to use GlobalPtrLock from source:wxWidgets/trunk/include/wx/msw/private.h instead of GlobalLock/GlobalUnlock?
  3. Most importantly: I think this code is completely wrong as it calls GlobalFree() on the handle passed to the clipboard when the documentation clearly says that the clipboard takes ownership of the handle on success. So I wonder how does this work at all... Either this code or the MSDN documentation is completely wrong. I'd bet on this code being wrong as it makes sense for the things to work as documented.
Note: See TracTickets for help on using tickets.