-#if 0
- if (!file.IsNull() && (file.Cmp("") == 0))
- M_METAFILEDATA->m_metafile = (WXHANDLE) GetMetaFile( file );
-#endif
+void wxMetafileRefData::Close()
+{
+ CGPDFContextEndPage(m_context);
+
+ CGContextRelease(m_context);
+ m_context = NULL;
+
+ UpdateDocumentFromData();
+}
+
+void wxMetafileRefData::UpdateDocumentFromData()
+{
+ wxCFRef<CGDataProviderRef> provider(wxMacCGDataProviderCreateWithCFData(m_data));
+ m_pdfDoc.reset(CGPDFDocumentCreateWithProvider(provider));
+ if ( m_pdfDoc != NULL )
+ {
+ CGPDFPageRef page = CGPDFDocumentGetPage( m_pdfDoc, 1 );
+ CGRect rect = CGPDFPageGetBoxRect ( page, kCGPDFMediaBox);
+ m_width = wx_static_cast(int, rect.size.width);
+ m_height = wx_static_cast(int, rect.size.height);
+ }
+}
+
+wxMetaFile::wxMetaFile(const wxString& file)
+{
+ m_refData = new wxMetafileRefData(file);