PackageReader.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (c) 1996-2006 by Autodesk, Inc.
00003 //
00004 //  By using this code, you are agreeing to the terms and conditions of
00005 //  the License Agreement included in the documentation for this code.
00006 //
00007 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE CORRECTNESS
00008 //  OF THIS CODE OR ANY DERIVATIVE WORKS WHICH INCORPORATE IT. AUTODESK
00009 //  PROVIDES THE CODE ON AN "AS-IS" BASIS AND EXPLICITLY DISCLAIMS ANY
00010 //  LIABILITY, INCLUDING CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00011 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00012 //
00013 //  Use, duplication, or disclosure by the U.S. Government is subject to
00014 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00015 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00016 //  Data and Computer Software), as applicable.
00017 //
00018 //  $Header: //DWF/Development/Components/Internal/DWF Toolkit/v7.6/develop/global/src/dwf/package/reader/PackageReader.h#6 $
00019 //  $DateTime: 2008/10/07 14:45:56 $
00020 //  $Author: clarkt $
00021 //  $Change: 115654 $
00022 //  $Revision: #6 $
00023 //
00024 
00025 #ifndef _DWFTK_PACKAGE_READER_H
00026 #define _DWFTK_PACKAGE_READER_H
00027 
00028 
00033 
00034 #include "dwfcore/SkipList.h"
00035 #include "dwfcore/TempFile.h"
00036 #include "dwfcore/InputStream.h"
00037 #include "dwfcore/XMLParser.h"
00038 #include "dwfcore/ZipFileDescriptor.h"
00039 #include "dwfcore/Synchronization.h"
00040 
00041 using namespace DWFCore;
00042 
00043 #include "dwf/Toolkit.h"
00044 
00045 #include "dwf/opc/Constants.h"
00046 #include "dwf/opc/Package.h"
00047 
00048 #ifdef HAVE_CONFIG_H
00049 #include "dwf/config.h"
00050 #endif
00051 
00052 namespace DWFToolkit
00053 {
00054 
00055 //
00056 // fwd decl
00057 //
00058 class DWFManifest;
00059 class DWFManifestReader;
00060 class DWFSectionBuilder;
00061 class DWFXPackage;
00062 class OPCPart;
00063 class OPCZipFileReader;
00064 class OPCCoreProperties;
00065 class DWFXFixedPageResourceExtractor;
00066 class DWFXDWFProperties;
00067 class DWFXCustomProperties;
00068 
00069     //
00070     // dictates the size of the heap buffer
00071     // used to cache input stream data for the parser
00072     //
00073 #ifndef DWFTK_XML_PARSER_BUFFER_BYTES
00074 #define DWFTK_XML_PARSER_BUFFER_BYTES   16384
00075 #endif
00076 
00094 class DWFPackageReader 
00095     _DWFTK_EXPORT_API_MEMORY_CONTROL_BASE
00096 {
00097 
00098 public:
00099 
00103     typedef enum
00104     {
00108         eDWFPackage,
00112         eDWFPackageEncrypted,
00116         eW2DStream,
00120         eDWFStream,
00124         eZIPFile,
00128         eUnknown,
00132         eDWFXPackage,
00136         eDWFXPackageEncrypted
00137 
00138     } tePackageType;
00139 
00140     typedef struct
00141     {
00148         unsigned long   nVersion;
00152         tePackageType   eType;
00158         DWFString       zTypeGUID;
00159 
00160         bool            bDigitallySigned;
00161 
00162     } tPackageInfo;
00163 
00164     typedef void (*tpfPasswordCallback)(DWFPackageReader& rReader, DWFResource& rResource, DWFString& zPassword);
00165 
00166 public:
00167 
00177     _DWFTK_API
00178     DWFPackageReader( const DWFFile&   zDWFPackageFile,
00179                       const DWFString& zDWFPackagePassword = /*NOXLATE*/L"" )
00180         throw();
00181 
00191     _DWFTK_API
00192     DWFPackageReader( DWFInputStream&   rDWFPackageStream,
00193                       const DWFString&  zDWFPackagePassword = /*NOXLATE*/L"" )
00194         throw();
00195 
00201     _DWFTK_API
00202     virtual ~DWFPackageReader()
00203         throw();
00204 
00211     _DWFTK_API
00212     void setPackagePassword( const DWFString& zDWFPackagePassword )
00213         throw();
00214 
00221     _DWFTK_API
00222     void getPackageInfo( tPackageInfo& rInfo )
00223         throw( DWFException );
00224 
00234     _DWFTK_API
00235     static void GetPackageInfo( const unsigned char* pBuffer,
00236                                 tPackageInfo&        rInfo )
00237         throw( DWFException );
00238 
00249     _DWFTK_API
00250     DWFManifest& getManifest( DWFManifestReader* pFilter = NULL )
00251         throw( DWFException );
00252 
00264     _DWFTK_API
00265     void getManifest( DWFManifestReader& rManifestReader )
00266         throw( DWFException );
00267 
00280     _DWFTK_API
00281     virtual DWFInputStream* extract( const DWFString& zFilename,
00282                                      bool             bCache = false )
00283         throw( DWFException );
00284 
00296     _DWFTK_API
00297     DWFSectionBuilder& getSectionBuilder()
00298         throw( DWFException );
00299 
00300 
00309     _DWFTK_API
00310     DWFXDWFProperties* getDWFProperties()
00311         throw( DWFException );
00312 
00321     _DWFTK_API
00322     DWFXCustomProperties* getCustomProperties()
00323         throw( DWFException );
00324 
00325 
00334     _DWFTK_API
00335     OPCCoreProperties* getCoreProperties()
00336         throw( DWFException );
00337 
00338 
00339 protected:
00340 
00346     _DWFTK_API
00347     DWFPackageReader()
00348         throw();
00349 
00356     _DWFTK_API
00357     virtual DWFZipFileDescriptor* _open()
00358         throw( DWFException );
00359 
00360 private:
00361 
00362     //
00363     //
00364     //
00365     void _makeSectionBuilder()
00366         throw( DWFException );
00367 
00368     //
00369     //
00370     //
00371     void _getManifestFilename( DWFString& zManifestFilename )
00372         throw( DWFException );
00373 
00374     //
00375     //
00376     //
00377     OPCPart* _getDWFXManifestPart(bool bInitializeStream, bool bLoadRelationships)
00378         throw( DWFException );
00379 
00380     //
00381     //
00382     //
00383     bool _isOPCSigned()
00384         throw( DWFException );
00385 
00386     bool _findSignatureResource(OPCRelationshipContainer &oSignatureRels)
00387         throw( DWFException );
00388 
00389 private:
00390     //
00391     // necessary to prevent too blatant exposure to accessing passwords
00392     //
00393     friend class DWFResource;
00394     int _requestResourcePassword( DWFResource& rResource, DWFString& zPassword );
00395 
00396 protected:
00397 
00403     DWFStringKeySkipList<DWFTempFile*> _oLocalFileCache;
00404 
00405 private:
00406 
00407     DWFFile                 _zDWFPackage;
00408     DWFString               _zDWFPassword;
00409     DWFInputStream*         _pDWFStream;
00410 
00411     DWFXPackage*            _pDWFXPackage;
00412     tPackageInfo            _tPackageInfo;
00413 
00414     DWFManifest*            _pPackageManifest;
00415     DWFSectionBuilder*      _pSectionBuilder;
00416     DWFZipFileIndex         _oZipFileIndex;
00417 
00418     typedef _DWFTK_STD_MAP(DWFString, DWFXFixedPageResourceExtractor*)  _tFixedPageResourceExtractorMap;
00419     _tFixedPageResourceExtractorMap                                     _oFixedPageResourceExtractorMap;  
00420 
00421     DWFString               _zCachedDWFXManifestName;
00422     DWFXDWFProperties*      _pDWFXDWFProperties;
00423     DWFXCustomProperties*   _pDWFXCustomProperties;
00424     OPCCoreProperties*      _pOPCCoreProperties;
00425     DWFThreadMutex          _oExtractMutex;
00426 
00427 private:
00428 
00429     DWFPackageReader( const DWFPackageReader& );
00430     DWFPackageReader& operator=( const DWFPackageReader& );
00431 };
00432 
00433 }
00434 
00435 #endif

Generated on Tue Jan 6 22:40:05 2009 for Autodesk DWF Toolkit by  doxygen 1.4.5