118 lines
2.8 KiB
C++
118 lines
2.8 KiB
C++
// DWFFile.cpp : Implementation of CDWFFile
|
|
|
|
#include "stdafx.h"
|
|
#include "assert.h"
|
|
#include "DWFFileImpl.h"
|
|
|
|
#include "myEPlotSectionImpl.h"
|
|
|
|
// CDWFFile
|
|
|
|
//CDWFFileImpl::~CDWFFile()
|
|
//{
|
|
// // It seems we never get here? Use FinalRelease
|
|
//};
|
|
|
|
CDWFFileImpl::~CDWFFileImpl()
|
|
{
|
|
if (m_oReader!=NULL)
|
|
delete m_oReader;
|
|
|
|
if (m_DWF!=NULL)
|
|
delete m_DWF;
|
|
}
|
|
|
|
bool CDWFFileImpl::Open(const CString &DWFPath)
|
|
{
|
|
if (m_isOpen)
|
|
{
|
|
throw CString("\nCDWFFileImpl::Open already open");
|
|
}
|
|
try
|
|
{
|
|
myDoTRACE("\nCDWFFileImpl::Open('%s')", DWFPath);
|
|
m_DWF = new DWFFile( DWFPath );
|
|
m_oReader = new DWFPackageReader( *m_DWF );
|
|
|
|
m_oReader->getPackageInfo( m_tInfo );
|
|
|
|
wchar_t zBuffer[256] = {0};
|
|
|
|
myTRACE("\nCDWFFileImpl::Opened('%s')", DWFPath);
|
|
if (m_tInfo.eType == DWFPackageReader::eW2DStream ||
|
|
m_tInfo.eType == DWFPackageReader::eDWFStream)
|
|
{ // Dit is wel heel gemakkelijk
|
|
m_W2DFileName = DWFString(DWFPath);
|
|
assert(m_W2DFileName.chars() != 0);
|
|
m_isOpen = TRUE;
|
|
return true;
|
|
}
|
|
|
|
if (m_tInfo.eType != DWFPackageReader::eDWFPackage)
|
|
{
|
|
_DWFCORE_SWPRINTF( zBuffer, 256, L"File is not a DWF package [%s]",
|
|
(m_tInfo.eType == DWFPackageReader::eW2DStream) ? L"W2D Stream" :
|
|
(m_tInfo.eType == DWFPackageReader::eDWFStream) ? L"DWF Stream (<6.0)" :
|
|
(m_tInfo.eType == DWFPackageReader::eZIPFile) ? L"ZIP Archive" : L"Unknown" );
|
|
|
|
myTRACE("%ls", zBuffer);
|
|
throw myCString("ERROR: Unable to open file: %s\n%ls", DWFPath, zBuffer);
|
|
}
|
|
|
|
//
|
|
// read and parse the manifest
|
|
//
|
|
DWFManifest& rManifest = m_oReader->getManifest();
|
|
|
|
if (!m_EPlotSections.ProcessManifest(rManifest, CString(DWFPath)))
|
|
{
|
|
CString err("Unable to retrieve EPlotSections. Perhaps it is a 3D DWF?");
|
|
throw myCString ("\nCDWFFileImpl::Open('%s')\n%s", DWFPath, err);
|
|
}
|
|
|
|
m_isOpen = TRUE;
|
|
return true;
|
|
}
|
|
catch (DWFException& ex)
|
|
{
|
|
CString err;
|
|
err.Format("%ls\n%ls\n%s\n%ls(%d)",ex.type(),ex.message(),ex.function(),ex.file(),ex.line());
|
|
throw myCString ("\nCDWFFileImpl::Open('%s')\n%s", DWFPath, err);
|
|
}
|
|
}
|
|
|
|
#if DESIRED_CODE(WHIP_OUTPUT)
|
|
bool CDWFFileImpl::get_PropertiesXML(CString & pVal)
|
|
{
|
|
if (!m_isOpen)
|
|
throw myCString ("\nDWF File is not opened");
|
|
|
|
if (m_DWF!=NULL)
|
|
{
|
|
DWFCore::DWFBufferOutputStream m_XMLProps(1024);
|
|
DWFUUID _oUUID;
|
|
DWFXMLSerializer XML(_oUUID);
|
|
XML.attach(m_XMLProps);
|
|
|
|
DWFManifest& rManifest = m_oReader->getManifest();
|
|
rManifest.serializeXML(XML, DWFPackageWriter::eManifest);
|
|
XML.detach();
|
|
|
|
pVal = CString((LPCSTR)m_XMLProps.buffer(), (int)m_XMLProps.bytes());
|
|
return true;
|
|
}
|
|
else
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
#endif
|
|
|
|
CEPlotSectionsImpl *CDWFFileImpl::get_EPlotSections()
|
|
{
|
|
if (!m_isOpen)
|
|
throw myCString("\nDWF File is not opened");
|
|
|
|
return &m_EPlotSections;
|
|
}
|