DWF6PackageWriter.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 
00019 #ifndef _DWFTK_DWF6_PACKAGE_WRITER_H
00020 #define _DWFTK_DWF6_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/writer/PackageWriter.h"
00040 #include "dwf/package/writer/DWF6PackageVersionExtension.h"
00041 
00042 namespace DWFToolkit
00043 {
00044 
00054 class DWF6PackageWriter : public DWFPackageWriter
00055                         _DWFTK_EXPORT_API_MEMORY_CONTROL_BASE_MEMBER
00056 {
00057 
00058 public:
00065     class DWF6UndeclaredResourceReceiver : public DWFPackageWriter::UndeclaredResource::Receiver
00066     {
00067         DWFPackageFileDescriptor* _pPackageDescriptor;
00068         DWFString _zDWFPassword;
00069         bool _bPKZIPCompliantPassword;
00070 
00071     public:
00075         DWF6UndeclaredResourceReceiver( DWFPackageFileDescriptor* pPackageDescriptor, const DWFString& zDWFPassword, bool bPKZIPCompliantPassword )
00076         : _pPackageDescriptor( pPackageDescriptor )
00077         , _zDWFPassword( zDWFPassword )
00078         , _bPKZIPCompliantPassword( bPKZIPCompliantPassword )
00079         { ; }
00080 
00084         void receiveResource( const DWFCore::DWFString &rStoragePath, DWFInputStream* pInStream, DWFZipFileDescriptor::teFileMode eZipMode ) throw();
00085     };
00086 
00087 
00088 public:
00098     _DWFTK_API
00099     DWF6PackageWriter( const DWFFile&                rDWFPackageFile,
00100                        const DWFString&              zDWFPackagePassword = /*NOXLATE*/L"",
00101                        DWF6PackageVersionExtension*  pVersionExtension = NULL,
00102                        bool                          bNoPasswordSalting = true )
00103         throw();
00104 
00110     _DWFTK_API
00111     virtual ~DWF6PackageWriter()
00112         throw();
00113 
00117     _DWFTK_API
00118     virtual void addSection( DWFSection*    pSection,
00119                      DWFInterface*  pInterface = NULL )
00120         throw( DWFException );
00121 
00125     _DWFTK_API
00126     virtual void addGlobalSection( DWFGlobalSection* pSection )
00127         throw( DWFException );
00128 
00136     _DWFTK_API
00137     virtual void addSignatureRequest( DWFSignatureRequest* pSignatureRequest )
00138         throw( DWFException );
00139 
00151     _DWFTK_API
00152     virtual void setCoreProperties( DWFPropertySet* pSet )
00153         throw( DWFException );
00154 
00166     _DWFTK_API
00167     virtual void setDWFProperties( DWFPropertySet* pSet )
00168         throw( DWFException );
00169 
00179     _DWFTK_API
00180     virtual void setCustomProperties( DWFPropertySet* pSet )
00181         throw( DWFException );
00182 
00190     _DWFTK_API
00191     void write( const DWFString&                 zSourceProductVendor = /*NOXLATE*/L"",
00192                 const DWFString&                 zSourceProductName = /*NOXLATE*/L"",
00193                 const DWFString&                 zSourceProductVersion = /*NOXLATE*/L"",
00194                 const DWFString&                 zDWFProductVendor = /*NOXLATE*/L"",
00195                 const DWFString&                 zDWFProductVersion = /*NOXLATE*/L"",
00196                 DWFZipFileDescriptor::teFileMode eCompressionMode = DWFZipFileDescriptor::eZipSmallest )
00197         throw( DWFException );
00198 
00199 private:
00200 
00201     //
00202     //  This is used only in cases where the content is available but not loaded - may happen
00203     //  during aggregation.
00204     //
00205     void _serializeContent( DWFContent* pContent )
00206         throw( DWFException );
00207 
00208     //
00209     //
00210     //
00211     void _serializeResource( const DWFString&   zSection,
00212                              DWFResource&       rResource )
00213         throw( DWFException );
00214 
00215 
00216     //
00217     //  This is called from package writer to add any document-wide properties to
00218     //  the manifest.
00219     //
00220     virtual void _addPropertiesToManifest( const DWFString& zSourceProductVendor,
00221                                            const DWFString& zSourceProductName,
00222                                            const DWFString& zSourceProductVersion,
00223                                            const DWFString& zDWFProductVendor,
00224                                            const DWFString& zDWFProductVersion )
00225         throw( DWFException );
00226 
00227     //
00228     //  Determine the extension if necessary based on section type counts and by
00229     //  looking for content, content presentations, or raster overlays.
00230     //
00231     void _determinePackageVersionExtension( const DWFString& zTypeInfo )
00232         throw( DWFException );
00233 
00234     //
00235     //  Methods for signature management
00236     //
00237 
00238     //
00239     //  If signatures are getting written we need to ensure that a signature section exists
00240     //
00241     DWFSection* _ensureSignatureSection()
00242         throw( DWFException );
00243 
00244     //
00245     //  Preprocess the signature requestes, creating mappings from the items being signed to
00246     //  the signature references pointing to them. A requests consists of one or more reference.
00247     //
00248     void _partitionSignatureReferences()
00249         throw( DWFException );
00250 
00251     //
00252     //  Add the reference to the mapped vector corresponding to the item pointer provided.
00253     //  This will be used for signature processing.
00254     //
00255     void _addToItemReferenceMap( void* pItem, DWFSignatureRequest::Reference* pReference )
00256         throw();
00257 
00258     //
00259     //  If a mapped vector exists, this will return a pointer to that vector, NULL otherwise. If a URI is
00260     //  provided, this will also set the URI on th references.
00261     //
00262     DWFSignatureRequest::tReferenceVector* _signatureReferences( void* pItem, const DWFString& zURI = /*NOXLATE*/L"")
00263         throw();
00264 
00265     //
00266     // For each of the digests covered by the given resources, produce a digestStream, and chain to the given initial stream.
00267     //
00268     DWFOutputStream* _wrapOutputStreamForReferences( DWFOutputStream* pInitialOutputStream, void* pItem, const DWFString& zURI = /*NOXLATE*/L"" )
00269         throw( DWFException );
00270 
00271 
00272 private:
00273 
00274     typedef _DWFTK_STD_VECTOR(DWFSignatureRequest*)                        _tSignatureRequestVector;
00275     typedef _DWFTK_STD_MAP(void*, DWFSignatureRequest::tReferenceVector*)  _tItemReferenceMap;
00276 
00277 private:
00278 
00279     DWFString                       _zDWFPassword;
00280     DWFPackageFileDescriptor*       _pPackageDescriptor;
00281     DWFXMLSerializer*               _pXMLSerializer;
00282     DWF6PackageVersionExtension*    _pVersionExtension;
00283 
00284     DWFPropertySet*                 _pDWFProperties;
00285     DWFPropertySet*                 _pCustomProperties;
00286 
00287     //
00288     // For Digital Signatures, we generate many digest streams, which will need
00289     // to be deleted after all signatures have been generated. Note that we DO NOT
00290     // take ownership of the real streams, and they can be deleted as soon as
00291     // everything has been written to them.
00292     //
00293     std::vector<DWFOutputStream*>           _oStreamsToDelete;
00294 
00295     //
00296     // The list of signature request that we have been asked to generate.
00297     //
00298     _tSignatureRequestVector                _oSignatureRequests;
00299     DWFSignatureRequest::tReferenceVector   _oManifestReferences;
00300     _tItemReferenceMap                      _oItemSignatureReferenceMap;
00301 
00302 private:
00303 
00304     DWF6PackageWriter();
00305     DWF6PackageWriter( const DWF6PackageWriter& );
00306     DWF6PackageWriter& operator=( const DWF6PackageWriter& );
00307 };
00308 
00309 }
00310 
00311 #endif
00312 #endif
00313 

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