PackageWriter.h

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 
00019 #ifndef _DWFTK_PACKAGE_WRITER_H
00020 #define _DWFTK_PACKAGE_WRITER_H
00021 
00026 
00027 
00028 #ifndef DWFTK_READ_ONLY
00029 
00030 
00031 #include "dwfcore/STL.h"
00032 #include "dwfcore/DWFXMLSerializer.h"
00033 #include "dwfcore/UUID.h"
00034 #include "dwfcore/Vector.h"
00035 #include "dwfcore/DigestOutputStream.h"
00036 using namespace DWFCore;
00037 
00038 #include "dwf/Toolkit.h"
00039 #include "dwf/package/XML.h"
00040 #include "dwf/package/Constants.h"
00041 #include "dwf/package/utility/DWFPackageFileDescriptor.h"
00042 #include "dwf/package/SignatureRequest.h"
00043 #include "dwf/opc/Relationship.h"
00044 
00045 namespace DWFToolkit
00046 {
00047 
00048 //
00049 // fwd decl
00050 //
00051 class DWFPropertySet;
00052 class DWFManifest;
00053 class DWFResource;
00054 class DWFInterface;
00055 class DWFSection;
00056 class DWFGlobalSection;
00057 class DWFContentManager;
00058 class DWFPropertyContainer;
00059 class DWFSignatureRequest;
00060 class DWFContentPresentationContainer;
00061 class DWFPackageContentPresentations;
00071 class DWFPackageWriter      _DWFTK_EXPORT_API_MEMORY_CONTROL_BASE
00072 {
00073 
00074 public:
00075 
00080     typedef enum teDocumentType
00081     {
00082         eManifest               = 0x0100,
00083         eContentPresentation    = 0x0200,
00084         eDescriptor             = 0x0400,
00085         eObjectDefinition       = 0x0800,
00086         eGlobalContent          = 0x1000,
00087         eSectionContent         = 0x2000,
00088         eSignatureRequest       = 0x4000
00089     } teDocumentType;
00090 
00095     typedef enum teSectionType
00096     {
00097         eNone               = 0x00,
00098         eEPlot              = 0x01,
00099         eEModel             = 0x02,
00100         eGlobal             = 0x04,
00101         eData               = 0x08,
00102         eSignatures         = 0x10
00103 
00104     } teSectionType;
00105 
00106     typedef enum teMergeContent {
00107         eNoMerge,
00108         eMergePriorityPrimary,
00109         eMergePrioritySecondary
00110     } teMergeContent;
00111 
00120     class UndeclaredResource
00121     {
00122     public:
00127         class Receiver
00128         {
00129         public:
00138             virtual void receiveResource( const DWFCore::DWFString &rStoragePath, DWFInputStream* pInStream, DWFZipFileDescriptor::teFileMode eZipMode ) throw() = 0;
00139         };
00140 
00145         class Provider
00146         {
00147         public:
00152             virtual void provideResources( Receiver* pReceiver ) throw() = 0;
00153         };
00154 
00155     };
00156 
00163 
00164     class UndeclaredContentType
00165     {
00166     public:
00172         class Receiver
00173         {
00174         public:
00180             virtual void receiveContentType( const DWFCore::DWFString &rExtension, const DWFCore::DWFString &rContentType ) throw() = 0;
00181         };
00182 
00188         class Provider
00189         {
00190         public:
00195             virtual void provideContentTypes( Receiver* pReceiver ) throw() = 0;
00196         };
00197 
00198 
00199     };
00200 
00205     class UndeclaredPackageRelationships
00206     {
00207     public:
00213         class Receiver
00214         {
00215         public:
00220             virtual void receiveRelationship( DWFToolkit::OPCRelationship* pRelationship ) throw() = 0;
00221         };
00222 
00228         class Provider
00229         {
00230         public:
00235             virtual void provideRelationships( Receiver* pReceiver ) throw() = 0;
00236         };
00237 
00238     };
00239 
00240 public:
00241 
00248     _DWFTK_API
00249     DWFPackageWriter( const DWFFile& rDWFPackageFile )
00250         throw();
00251 
00257     _DWFTK_API
00258     virtual ~DWFPackageWriter()
00259         throw();
00260         
00268     _DWFTK_API
00269     virtual void enablePasswordSalting( bool bEnable )
00270         throw();
00271 
00289     _DWFTK_API
00290     virtual void addSection( DWFSection*    pSection,
00291                              DWFInterface*  pInterface = NULL )
00292         throw( DWFException );
00293 
00305     _DWFTK_API
00306     virtual void addGlobalSection( DWFGlobalSection* pSection )
00307         throw( DWFException );
00308 
00325     _DWFTK_API
00326     virtual DWFInterface* addInterface( DWFInterface* pInterface )
00327         throw( DWFException );
00328 
00340     _DWFTK_API
00341     virtual void attachContentManager( DWFContentManager* pContentManager, bool bTakesOwnership = true )
00342         throw( DWFException );
00343 
00356     _DWFTK_API
00357     virtual DWFContentManager* getContentManager()
00358         throw( DWFException );
00359 
00372     _DWFTK_API
00373     virtual void addPresentation( DWFContentPresentation* pPresentation, bool bOwnPresentation = true )
00374         throw( DWFException );
00375 
00382     _DWFTK_API
00383     virtual void setUndeclaredResourceProvider( UndeclaredResource::Provider* pProvider )
00384         throw( DWFException );
00385 
00394     _DWFTK_API
00395     virtual void setUndeclaredContentTypeProvider( UndeclaredContentType::Provider* pProvider )
00396         throw( DWFException );
00397 
00407     _DWFTK_API
00408     virtual void setUndeclaredPackageRelationshipsProvider( UndeclaredPackageRelationships::Provider* pProvider )
00409         throw( DWFException );
00410 
00411 
00424     _DWFTK_API
00425     virtual DWFPropertyContainer& getManifestProperties()
00426         throw( DWFException );
00427 
00439     _DWFTK_API
00440     virtual void setCoreProperties( DWFPropertySet* pSet )
00441         throw( DWFException ) = 0;
00442 
00454     _DWFTK_API
00455     virtual void setDWFProperties( DWFPropertySet* pSet )
00456         throw( DWFException ) = 0;
00457 
00467     _DWFTK_API
00468     virtual void setCustomProperties( DWFPropertySet* pSet )
00469         throw( DWFException ) = 0;
00470 
00482     _DWFTK_API
00483     virtual void initializeForAggregation( teMergeContent eMergeType = eMergePriorityPrimary )
00484         throw( DWFException );
00485 
00528     _DWFTK_API
00529     virtual void write( const DWFString&                 zSourceProductVendor = /*NOXLATE*/L"",
00530                         const DWFString&                 zSourceProductName = /*NOXLATE*/L"",
00531                         const DWFString&                 zSourceProductVersion = /*NOXLATE*/L"",
00532                         const DWFString&                 zDWFProductVendor = /*NOXLATE*/L"",
00533                         const DWFString&                 zDWFProductVersion = /*NOXLATE*/L"",
00534                         DWFZipFileDescriptor::teFileMode eCompressionMode = DWFZipFileDescriptor::eZipSmallest )
00535         throw( DWFException ) = 0;
00536 
00537 protected:
00538 
00539     //
00540     // 
00541     //
00542     virtual void _ensureManifest()
00543         throw( DWFException );
00544 
00545     //
00546     //  This will aggregate content from other packages, and merge if the merge flag is set
00547     //
00548     virtual void _aggregateContent()
00549         throw( DWFException );
00550 
00551     //
00552     //  If aggregation was performed this will cleanup, and more important - restore
00553     //  contents to their original owner content managers.
00554     //
00555     virtual void _postAggregationCleanup()
00556         throw();
00557 
00558 
00559 
00560 protected:
00561     typedef _DWFTK_STD_VECTOR(DWFSection*)                  _tSectionVector;
00562     typedef _DWFTK_STD_VECTOR(DWFGlobalSection*)            _tGlobalSectionVector;
00563     typedef _DWFTK_STD_MAP(DWFSection*, DWFContentManager*) _tSectionToContentManager;
00564     typedef DWFSortedVector<DWFContentManager*>             _tSortedContentManagerVector;
00565     typedef _DWFTK_STD_MAP(DWFContent*, DWFContentManager*) _tContentToContentManager;
00566     typedef _DWFTK_STD_VECTOR(DWFOutputStream*)             _tStreamsVector;
00567 
00568 protected:
00569 
00570     DWFFile                         _rDWFPackage;
00571 
00572     DWFUUID                         _oUUID;
00573 
00574     DWFManifest*                    _pPackageManifest;
00575 
00576     double                          _nNextPlot;
00577 
00578     bool                            _bEPlotGlobalAdded;
00579     bool                            _bEModelGlobalAdded;
00580 
00581     size_t                          _nEPlotSectionCount;
00582     size_t                          _nEModelSectionCount;
00583 
00584     _tSectionVector                 _oSections;
00585     _tGlobalSectionVector           _oGlobalSections;
00586 
00587     bool                            _bAggregating;
00588     teMergeContent                  _eMergeType;
00589         
00590         bool                            _bNoPasswordSalting;
00591 
00592     //
00593     //  The section and the "original" content manager that it was associated with before being added
00594     //
00595     _tSectionToContentManager       _oSectionToContentManager;
00596 
00597     //
00598     //  The contents that get aggregated and the "original" content managers they came from
00599     //
00600     _tContentToContentManager       _oContentToContentManager;
00601 
00602     //
00603     //  A provider for undeclared resource types
00604     //
00605     UndeclaredResource::Provider*   _pUndeclaredResourceProvider;
00606 
00607     //
00608     //  A provider for undeclared content types (DWFX)
00609     //
00610     UndeclaredContentType::Provider* _pUndeclaredContentTypeProvider;
00611 
00612     //
00613     //  A provider for undeclared package relationships (DWFX)
00614     //
00615     UndeclaredPackageRelationships::Provider* _pUndeclaredPackageRelationshipsProvider;
00616 
00617     DWFPackageContentPresentations* _pPackageContentPresentations;
00618 
00619 private:
00620 
00621     DWFPackageWriter();
00622     DWFPackageWriter( const DWFPackageWriter& );
00623     DWFPackageWriter& operator=( const DWFPackageWriter& );
00624 };
00625 
00626 }
00627 
00628 #endif
00629 #endif
00630 

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