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).
This commit is contained in:
Artur Wieczorek 2017-05-01 21:03:41 +02:00
parent 2dd726471f
commit 670e1fe948
2 changed files with 36 additions and 19 deletions

View File

@ -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"

View File

@ -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 <windows.h>
#include <oleauto.h>
#include "wx/msw/dib.h"
#include "wx/msw/wrapshl.h"
#include "wx/msw/ole/oleutils.h"
#if wxUSE_OLE
#include <oleauto.h>
#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