From 670e1fe948c0914f71c5f69e98e7f99076100666 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Mon, 1 May 2017 21:03:41 +0200 Subject: [PATCH] Allow build wxDataObject without OLE support (when wxUSE_OLE==0) Reorganize the code by putting OLE-dependent code into the blocks controlled by wxUSE_OLE and by sharing remaining code (like implementation of wxDataFormat, wxBitmapDataObject, wxFileDataObject, etc.) to allow building wxDataObject and its specializations also without OLE support. Since wxDataObject no longer requires OLE support, corresponding check in checkconf.h can be removed. Thanks to this additional flexibility, it is possible to use wxClipboard whether OLE support (wxUSE_OLE) is enabled or not, either with OLE-based wxDataObject (OLE clipboard) or with wxDataObject decoupled from OLE (Win clipboard API). --- include/wx/msw/chkconf.h | 9 -------- src/msw/ole/dataobj.cpp | 46 +++++++++++++++++++++++++++++++--------- 2 files changed, 36 insertions(+), 19 deletions(-) diff --git a/include/wx/msw/chkconf.h b/include/wx/msw/chkconf.h index c672b728c2..34369c17ca 100644 --- a/include/wx/msw/chkconf.h +++ b/include/wx/msw/chkconf.h @@ -355,15 +355,6 @@ # endif # endif -# if wxUSE_DATAOBJ -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_DATAOBJ requires wxUSE_OLE" -# else -# undef wxUSE_DATAOBJ -# define wxUSE_DATAOBJ 0 -# endif -# endif - # if wxUSE_OLE_AUTOMATION # ifdef wxABORT_ON_CONFIG_ERROR # error "wxAutomationObject requires wxUSE_OLE" diff --git a/src/msw/ole/dataobj.cpp b/src/msw/ole/dataobj.cpp index 8ed8893c79..9807b50c45 100644 --- a/src/msw/ole/dataobj.cpp +++ b/src/msw/ole/dataobj.cpp @@ -23,6 +23,8 @@ #pragma hdrstop #endif +#if wxUSE_DATAOBJ + #ifndef WX_PRECOMP #include "wx/intl.h" #include "wx/log.h" @@ -32,23 +34,24 @@ #include "wx/dataobj.h" -#if wxUSE_OLE - #include "wx/scopedarray.h" #include "wx/vector.h" #include "wx/msw/private.h" // includes - -#include +#include "wx/msw/dib.h" #include "wx/msw/wrapshl.h" -#include "wx/msw/ole/oleutils.h" +#if wxUSE_OLE +#include -#include "wx/msw/dib.h" +#include "wx/msw/ole/oleutils.h" +#endif // wxUSE_OLE #ifndef CFSTR_SHELLURL #define CFSTR_SHELLURL wxT("UniformResourceLocator") #endif +#if wxUSE_OLE + // ---------------------------------------------------------------------------- // functions // ---------------------------------------------------------------------------- @@ -59,6 +62,8 @@ #define GetTymedName(tymed) wxEmptyString #endif // wxDEBUG_LEVEL/!wxDEBUG_LEVEL +#endif // wxUSE_OLE + namespace { @@ -84,6 +89,7 @@ wxDataFormat HtmlFormatFixup(wxDataFormat format) return format; } +#if wxUSE_OLE // helper function for wxCopyStgMedium() HGLOBAL wxGlobalClone(HGLOBAL hglobIn) { @@ -153,9 +159,11 @@ HRESULT wxCopyStgMedium(const STGMEDIUM *pmediumIn, STGMEDIUM *pmediumOut) return hres; } +#endif // wxUSE_OLE } // anonymous namespace +#if wxUSE_OLE // ---------------------------------------------------------------------------- // wxIEnumFORMATETC interface implementation // ---------------------------------------------------------------------------- @@ -331,6 +339,7 @@ wxIDataObject::SaveSystemData(FORMATETC *pformatetc, return S_OK; } +#endif // wxUSE_OLE // ============================================================================ // implementation @@ -389,6 +398,7 @@ wxString wxDataFormat::GetId() const return s; } +#if wxUSE_OLE // ---------------------------------------------------------------------------- // wxIEnumFORMATETC // ---------------------------------------------------------------------------- @@ -1029,6 +1039,8 @@ const wxChar *wxDataObject::GetFormatName(wxDataFormat format) #endif // wxDEBUG_LEVEL +#endif // wxUSE_OLE + // ---------------------------------------------------------------------------- // wxBitmapDataObject supports CF_DIB format // ---------------------------------------------------------------------------- @@ -1483,6 +1495,7 @@ void wxURLDataObject::SetURL(const wxString& url) #endif } +#if wxUSE_OLE // ---------------------------------------------------------------------------- // private functions // ---------------------------------------------------------------------------- @@ -1514,8 +1527,6 @@ static const wxChar *GetTymedName(DWORD tymed) // wxDataObject // ---------------------------------------------------------------------------- -#if wxUSE_DATAOBJ - wxDataObject::wxDataObject() { } @@ -1533,8 +1544,23 @@ const wxChar *wxDataObject::GetFormatName(wxDataFormat WXUNUSED(format)) return NULL; } -#endif // wxUSE_DATAOBJ +const void* wxDataObject::GetSizeFromBuffer(const void* WXUNUSED(buffer), + size_t* size, const wxDataFormat& WXUNUSED(format)) +{ + *size = 0; + return NULL; +} +void* wxDataObject::SetSizeInBuffer(void* buffer, size_t WXUNUSED(size), + const wxDataFormat& WXUNUSED(format)) +{ + return buffer; +} + +size_t wxDataObject::GetBufferOffset(const wxDataFormat& WXUNUSED(format)) +{ + return 0; +} #endif // wxUSE_OLE/!wxUSE_OLE - +#endif // wxUSE_DATAOBJ