// // Copyright (c) 2006 by Autodesk, Inc. // // By using this code, you are agreeing to the terms and conditions of // the License Agreement included in the documentation for this code. // // AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED, // AS TO THE CORRECTNESS OF THIS CODE OR ANY DERIVATIVE // WORKS WHICH INCORPORATE IT. // // AUTODESK PROVIDES THE CODE ON AN "AS-IS" BASIS // AND EXPLICITLY DISCLAIMS ANY LIABILITY, INCLUDING // CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS, // OMISSIONS, AND OTHER PROBLEMS IN THE CODE. // // Use, duplication, or disclosure by the U.S. Government is subject to // restrictions set forth in FAR 52.227-19 (Commercial Computer Software // Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical // Data and Computer Software), as applicable. // // PublishMetadata.cpp : Defines the entry point for the console application. // #include #include #include "dwfcore/MIME.h" #include "dwfcore/FileInputStream.h" #include "dwfcore/StreamFileDescriptor.h" #include "dwfcore/File.h" #include "dwfcore/String.h" #ifdef _DWFCORE_WIN32_SYSTEM #if _USE_VLD #define _USE_VLD_FOR_MEMORY_LEAK_TEST #include #else #define _USE_CRTDBG_FOR_MEMORY_LEAK_TEST #include #endif #endif #include "dwf/package/ContentManager.h" #include "dwf/package/Constants.h" #include "dwf/package/GlobalSection.h" #include "dwf/package/GraphicResource.h" #include "dwf/package/Manifest.h" #include "dwf/package/SectionContentResource.h" #include "dwf/package/reader/PackageReader.h" #include "dwf/publisher/model/Model.h" #include "dwf/publisher/impl/DWF6PackagePublisher.h" #include "dwf/publisher/impl/DWFXPackagePublisher.h" #include "dwf/publisher/impl/PublishedContentElement.h" #ifdef _DWFCORE_WIN32_SYSTEM #include "dwf/publisher/win32/EmbeddedFontImpl.h" #include #endif #include "dwf/presentation/ContentPresentationResource.h" #include "dwf/presentation/ContentPresentationReferenceNode.h" #include "dwf/presentation/ContentPresentationModelViewNode.h" #include "dwf/presentation/PropertyReference.h" using namespace std; using namespace DWFCore; using namespace DWFToolkit; //////////////////////////////////////////////////////////////////////////////////// // // Some of this sample code is taken from the HOOPS/Stream toolkit (v.10.00) samples // //////////////////////////////////////////////////////////////////////////////////// DWFModel* createModel( DWFPublisher& rPublisher, DWFContent* pContent, bool bCompressAll ); DWFData* createData( DWFPublisher& oPublisher, DWFContent* pContent ); void getContentInstances( DWFContent* pContent, DWFString& zOut ); void printTypeInfo( DWFPackageReader::tPackageInfo& tInfo ); void recure_children( DWFDefinedObjectInstance* pInst ); int main(int /*argc*/, char* /*argv[]*/) { #if defined(_USE_CRTDBG_FOR_MEMORY_LEAK_TEST) // // Enable memory leak reporting in Debug mode under Win32. // int tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ); // Turn on leak-checking bit tmpFlag |= _CRTDBG_LEAK_CHECK_DF; // Turn off CRT block checking bit tmpFlag &= ~_CRTDBG_CHECK_CRT_DF; // Set flag to the new value _CrtSetDbgFlag( tmpFlag ); // For mem leak debugging... Please do not delete. //long foo = 0; //_CrtSetBreakAlloc(foo); #endif try { ////////////////////////////////////////// // File to be opened // DWFString name ("2013-01-15-test.dwf"); DWFFile oDWF( name ); DWFPackageReader oReader( oDWF ); DWFManifest& rManifest = oReader.getManifest(); DWFSection* pSection = NULL; DWFManifest::SectionIterator* piSections = rManifest.getSections(); if (piSections) { for (; piSections->valid(); piSections->next()) { pSection = piSections->get(); DWFObjectDefinition* pDef = pSection->getObjectDefinition(); if (pDef) { DWFDefinedObjectInstance::tList oRootInstances; pDef->getRootInstances( oRootInstances ); DWFDefinedObjectInstance* pInst = NULL; DWFDefinedObjectInstance::tList::const_iterator iInst = oRootInstances.begin(); for (; iInst != oRootInstances.end(); iInst++) { pInst = *iInst; recure_children( pInst ); } DWFCORE_FREE_OBJECT( pDef ); } } DWFCORE_FREE_OBJECT( piSections ); } } catch (DWFException& ex) { wcout << ex.type() << L": " << ex.message() << endl; wcout << L"(function) " << ex.function() << endl; wcout << L"(file) " << ex.file() << endl; wcout << L"(line) " << ex.line() << endl; } return 0; } void recure_children ( DWFDefinedObjectInstance* pInst ) { ////////////////////////////////////////// // Add the property here ////////////////////////////////////////// pInst->addProperty( DWFCORE_ALLOC_OBJECT( DWFProperty( L"propName", L"propValue", L"propCategory" ) ), true ); DWFDefinedObjectInstance::tMap::Iterator* piChildren = pInst->resolvedChildren(); if (piChildren) { for (;piChildren->valid(); piChildren->next()) { recure_children( piChildren->value() ); } DWFCORE_FREE_OBJECT( piChildren ); } } void printTypeInfo( DWFPackageReader::tPackageInfo& tInfo ) { if (tInfo.eType != DWFPackageReader::eDWFPackage) { cout << "File is not a DWF package "; if (tInfo.eType == DWFPackageReader::eW2DStream) { cout << "[W2D Stream]"; } else if (tInfo.eType == DWFPackageReader::eDWFStream) { cout << "[DWF Stream (<6.0)]"; } else if (tInfo.eType == DWFPackageReader::eZIPFile) { cout << "[ZIP Archive]"; } else { cout << "[Unknown]"; } cout << endl; exit( 0 ); } cout << setprecision(2) << "DWF Package version [" << (float)(tInfo.nVersion)/100.0f << "]\n" << endl; }