]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/ole/dataobj.cpp
Found bug that skrewed up display wrt horizontal
[wxWidgets.git] / src / msw / ole / dataobj.cpp
index 14d98afe93c35f7f6d3271ff5bb79447afb06ef4..fdcae65b8b9dc5e3662b702b8afdaac3069632dc 100644 (file)
@@ -73,6 +73,12 @@ class wxIEnumFORMATETC : public IEnumFORMATETC
 {
 public:
     wxIEnumFORMATETC(const wxDataFormat* formats, ULONG nCount);
+
+    // to suppress the gcc warning about "class has virtual functions but non
+    // virtual dtor"
+#ifdef __GNUG__
+    virtual
+#endif
     ~wxIEnumFORMATETC() { delete [] m_formats; }
 
     DECLARE_IUNKNOWN_METHODS;
@@ -97,6 +103,12 @@ class wxIDataObject : public IDataObject
 {
 public:
     wxIDataObject(wxDataObject *pDataObject);
+
+    // to suppress the gcc warning about "class has virtual functions but non
+    // virtual dtor"
+#ifdef __GNUG__
+    virtual
+#endif
     ~wxIDataObject();
 
     // normally, wxDataObject controls our lifetime (i.e. we're deleted when it
@@ -297,6 +309,10 @@ STDMETHODIMP wxIDataObject::GetData(FORMATETC *pformatetcIn, STGMEDIUM *pmedium)
             pmedium->tymed = TYMED_GDI;
             break;
 
+        case wxDF_ENHMETAFILE:
+            pmedium->tymed = TYMED_ENHMF;
+            break;
+
         case wxDF_METAFILE:
             pmedium->hGlobal = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE,
                                            sizeof(METAFILEPICT));
@@ -363,7 +379,15 @@ STDMETHODIMP wxIDataObject::GetDataHere(FORMATETC *pformatetc,
                 return E_UNEXPECTED;
             break;
 
+        case TYMED_ENHMF:
+            if ( !m_pDataObject->GetDataHere(wxDF_ENHMETAFILE,
+                                             &pmedium->hEnhMetaFile) )
+                return E_UNEXPECTED;
+            break;
+
         case TYMED_MFPICT:
+            // fall through - we pass METAFILEPICT through HGLOBAL
+
         case TYMED_HGLOBAL:
             {
                 // copy data
@@ -409,7 +433,12 @@ STDMETHODIMP wxIDataObject::SetData(FORMATETC *pformatetc,
             m_pDataObject->SetData(wxDF_BITMAP, 0, &pmedium->hBitmap);
             break;
 
+        case TYMED_ENHMF:
+            m_pDataObject->SetData(wxDF_ENHMETAFILE, 0, &pmedium->hEnhMetaFile);
+            break;
+
         case TYMED_MFPICT:
+            // fall through - we pass METAFILEPICT through HGLOBAL
         case TYMED_HGLOBAL:
             {
                 wxDataFormat format = pformatetc->cfFormat;
@@ -445,9 +474,9 @@ STDMETHODIMP wxIDataObject::SetData(FORMATETC *pformatetc,
                     case CF_OEMTEXT:
                         size = strlen((const char *)pBuf);
                         break;
-#ifndef __WATCOMC__
+#if !defined(__WATCOMC__) && ! (defined(__BORLANDC__) && (__BORLANDC__ < 0x500))
                     case CF_UNICODETEXT:
-                        size = wcslen((const wchar_t *)pBuf);
+                        size = ::wcslen((const wchar_t *)pBuf);
                         break;
 #endif
                     case CF_BITMAP:
@@ -502,6 +531,10 @@ STDMETHODIMP wxIDataObject::SetData(FORMATETC *pformatetc,
             case TYMED_MFPICT:
                 pmedium->hMetaFilePict = 0;
                 break;
+
+            case TYMED_ENHMF:
+                pmedium->hEnhMetaFile = 0;
+                break;
         }
 
         ReleaseStgMedium(pmedium);
@@ -652,64 +685,47 @@ void wxDataObject::SetAutoDelete()
     m_pIDataObject = NULL;
 }
 
-bool wxDataObject::IsSupportedFormat(const wxDataFormat& format) const
-{
-    size_t nFormatCount = GetFormatCount();
-    if ( nFormatCount == 1 ) {
-        return format == GetPreferredFormat();
-    }
-    else {
-        wxDataFormat *formats = new wxDataFormat[nFormatCount];
-        GetAllFormats(formats);
+#ifdef __WXDEBUG__
 
-        size_t n;
-        for ( n = 0; n < nFormatCount; n++ ) {
-            if ( formats[n] == format )
-                break;
-        }
+const char *wxDataObject::GetFormatName(wxDataFormat format)
+{
+    // case 'xxx' is not a valid value for switch of enum 'wxDataFormat'
+    #ifdef __VISUALC__
+        #pragma warning(disable:4063)
+    #endif // VC++
+
+    static char s_szBuf[256];
+    switch ( format ) {
+        case CF_TEXT:         return "CF_TEXT";
+        case CF_BITMAP:       return "CF_BITMAP";
+        case CF_METAFILEPICT: return "CF_METAFILEPICT";
+        case CF_SYLK:         return "CF_SYLK";
+        case CF_DIF:          return "CF_DIF";
+        case CF_TIFF:         return "CF_TIFF";
+        case CF_OEMTEXT:      return "CF_OEMTEXT";
+        case CF_DIB:          return "CF_DIB";
+        case CF_PALETTE:      return "CF_PALETTE";
+        case CF_PENDATA:      return "CF_PENDATA";
+        case CF_RIFF:         return "CF_RIFF";
+        case CF_WAVE:         return "CF_WAVE";
+        case CF_UNICODETEXT:  return "CF_UNICODETEXT";
+        case CF_ENHMETAFILE:  return "CF_ENHMETAFILE";
+        case CF_HDROP:        return "CF_HDROP";
+        case CF_LOCALE:       return "CF_LOCALE";
 
-        delete [] formats;
+        default:
+            if ( !::GetClipboardFormatName(format, s_szBuf, WXSIZEOF(s_szBuf)) )
+            {
+                // it must be a new predefined format we don't know the name of
+                sprintf(s_szBuf, "unknown CF (0x%04x)", format.GetFormatId());
+            }
 
-        // found?
-        return n < nFormatCount;
+            return s_szBuf;
     }
-}
 
-#ifdef __WXDEBUG__
-
-const char *wxDataObject::GetFormatName(wxDataFormat format)
-{
-  // case 'xxx' is not a valid value for switch of enum 'wxDataFormat'
-  #ifdef __VISUALC__
-    #pragma warning(disable:4063)
-  #endif // VC++
-
-  static char s_szBuf[128];
-  switch ( format ) {
-    case CF_TEXT:         return "CF_TEXT";
-    case CF_BITMAP:       return "CF_BITMAP";
-    case CF_METAFILEPICT: return "CF_METAFILEPICT";
-    case CF_SYLK:         return "CF_SYLK";
-    case CF_DIF:          return "CF_DIF";
-    case CF_TIFF:         return "CF_TIFF";
-    case CF_OEMTEXT:      return "CF_OEMTEXT";
-    case CF_DIB:          return "CF_DIB";
-    case CF_PALETTE:      return "CF_PALETTE";
-    case CF_PENDATA:      return "CF_PENDATA";
-    case CF_RIFF:         return "CF_RIFF";
-    case CF_WAVE:         return "CF_WAVE";
-    case CF_UNICODETEXT:  return "CF_UNICODETEXT";
-    case CF_ENHMETAFILE:  return "CF_ENHMETAFILE";
-    case CF_HDROP:        return "CF_HDROP";
-    case CF_LOCALE:       return "CF_LOCALE";
-    default:
-      sprintf(s_szBuf, "clipboard format 0x%x (unknown)", format);
-      return s_szBuf;
-  }
-
-  #ifdef __VISUALC__
-    #pragma warning(default:4063)
-  #endif // VC++
+    #ifdef __VISUALC__
+        #pragma warning(default:4063)
+    #endif // VC++
 }
 
 #endif // Debug
@@ -1166,7 +1182,7 @@ static const wxChar *GetTymedName(DWORD tymed)
         case TYMED_MFPICT:    return wxT("TYMED_MFPICT");
         case TYMED_ENHMF:     return wxT("TYMED_ENHMF");
         default:
-            wxSprintf(s_szBuf, wxT("type of media format %d (unknown)"), tymed);
+            wxSprintf(s_szBuf, wxT("type of media format %ld (unknown)"), tymed);
             return s_szBuf;
     }
 }