DWFXPackageWriter.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_DWFX_PACKAGE_WRITER_H
00020 #define _DWFTK_DWFX_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/DWFXPackageVersionExtension.h"
00041 #include "dwf/opc/ZipWriter.h"
00042 
00043 namespace DWFToolkit
00044 {
00045 
00046 //
00047 // fwd decl
00048 //
00049 class OPCPart;
00050 class OPCCoreProperties;
00051 class DWFXPackage;
00052 class DWFXDWFSection;
00053 class DWFXDWFDocument;
00054 class DWFXFixedPage;
00055 class DWFXDWFProperties;
00056 class DWFXCustomProperties;
00057 
00067 class DWFXPackageWriter : public DWFPackageWriter
00068                         _DWFTK_EXPORT_API_MEMORY_CONTROL_BASE_MEMBER
00069 {
00070 public:
00078     typedef enum teProxyGraphicsRulesType
00079     {
00080         eAlways                     = 0x00,
00081         eIfNoPageOutput             = 0x01,
00082         eIfOnlyPartialPageOutput    = 0x02
00083     } teProxyGraphicsRulesType;
00084 
00085 
00086 public:
00087 
00094     class DWFXUndeclaredResourceReceiver : public DWFPackageWriter::UndeclaredResource::Receiver
00095     {
00096         DWFToolkit::OPCZipWriter* _pZipper;
00097 
00098     public:
00102         DWFXUndeclaredResourceReceiver( DWFToolkit::OPCZipWriter* pZipper )
00103         : _pZipper( pZipper )
00104         { ; }
00105 
00109         void receiveResource( const DWFCore::DWFString &rStoragePath, DWFInputStream* pInStream, DWFZipFileDescriptor::teFileMode eZipMode ) throw();
00110     };
00111 
00117     class DWFXUndeclaredContentTypeReceiver : public DWFPackageWriter::UndeclaredContentType::Receiver
00118     {
00119         DWFXPackage* _pPackage;
00120 
00121     public:
00125         DWFXUndeclaredContentTypeReceiver( DWFXPackage* pPackage )
00126         : _pPackage( pPackage )
00127         { ; }
00128 
00132         void receiveContentType( const DWFCore::DWFString &rExtension, const DWFCore::DWFString &rContentType ) throw();
00133     };
00134 
00140     class DWFXUndeclaredPackageRelationshipsReceiver : public DWFPackageWriter::UndeclaredPackageRelationships::Receiver
00141     {
00142         typedef _DWFTK_STD_VECTOR(OPCPart*) _tPartVector;
00143 
00144         DWFXPackage* _pPackage;
00145         _tPartVector _oPartVector;
00146 
00147     public:
00151         DWFXUndeclaredPackageRelationshipsReceiver( DWFXPackage* pPackage )
00152         : _pPackage( pPackage )
00153         { ; }
00154 
00158         ~DWFXUndeclaredPackageRelationshipsReceiver();
00159 
00163         void receiveRelationship( DWFToolkit::OPCRelationship* pRelationship ) throw();
00164     };
00165 
00166 
00176     _DWFTK_API
00177     DWFXPackageWriter( const DWFFile&   rDWFPackageFile,
00178                        const DWFString& zDWFPackagePassword = /*NOXLATE*/L"",
00179                        DWFXPackageVersionExtension*  pVersionExtension = NULL,
00180                        bool             bNoPasswordSalting = true )
00181         throw();
00182 
00188     _DWFTK_API
00189     virtual ~DWFXPackageWriter()
00190         throw();
00191 
00195     _DWFTK_API
00196     virtual void addSection( DWFSection*    pSection,
00197                      DWFInterface*  pInterface = NULL )
00198         throw( DWFException );
00199 
00203     _DWFTK_API
00204     virtual void addGlobalSection( DWFGlobalSection* pSection )
00205         throw( DWFException );
00206 
00219     _DWFTK_API
00220     virtual void addProxyGraphicsSection( DWFSection* pSection, teProxyGraphicsRulesType eRules=eAlways, bool bAsFirstPage=true )
00221         throw( DWFException );
00222 
00234     _DWFTK_API
00235     virtual void setCoreProperties( DWFPropertySet* pSet )
00236         throw( DWFException );
00237 
00249     _DWFTK_API
00250     virtual void setDWFProperties( DWFPropertySet* pSet )
00251         throw( DWFException );
00252 
00262     _DWFTK_API
00263     virtual void setCustomProperties( DWFPropertySet* pSet )
00264         throw( DWFException );
00265 
00273         _DWFTK_API
00274     virtual void addProxyPage( const DWFString& zProxyPageXPSPath )
00275         throw( DWFException );
00276 
00285     _DWFTK_API
00286     void write( const DWFString&                 zSourceProductVendor = /*NOXLATE*/L"",
00287                 const DWFString&                 zSourceProductName = /*NOXLATE*/L"",
00288                 const DWFString&                 zSourceProductVersion = /*NOXLATE*/L"",
00289                 const DWFString&                 zDWFProductVendor = /*NOXLATE*/L"",
00290                 const DWFString&                 zDWFProductVersion = /*NOXLATE*/L"",
00291                 DWFZipFileDescriptor::teFileMode eCompressionMode = DWFZipFileDescriptor::eZipSmallest )
00292         throw( DWFException );
00293 
00298 
00299 private:
00300 
00301     typedef _DWFTK_STD_MAP(DWFResource*, OPCPart*)           _tResourcePartMap;
00302     typedef _DWFTK_STD_MAP(DWFString, DWFResource*)          _tResourceIDMap;
00303 
00304 private:
00305 
00306     DWFString                       _zDWFPassword;
00307 
00308     DWFXPackage*                    _pPackage;
00309 
00310     _tResourcePartMap               _oResourcePartMap;
00311     _tResourceIDMap                 _oResourceIDMap;
00312 
00313     OPCCoreProperties*              _pCoreProperties;
00314     DWFXDWFProperties*              _pDWFProperties;
00315     DWFXCustomProperties*           _pCustomProperties;
00316 
00317     // Proxy graphics info
00318     DWFSection*                     _pProxyGraphicsSection;
00319     teProxyGraphicsRulesType        _eProxyGraphicsRules;
00320     bool                            _bProxyGraphicsGoOnFirstPage;
00321     DWFXPackageVersionExtension*    _pVersionExtension;
00322 
00323 private:
00324 
00325     //
00326     //
00327     //
00328     void _writeSection( DWFSection* pSection, DWFXDWFDocument* pDocument )
00329         throw( DWFException );
00330 
00331     //
00332     //  Use this to iterate over section resources to determined whether 
00333     //  we will create a fixed page or not for this section.
00334     //
00335     bool _fixedPageDesired( DWFSection* pSection )
00336         throw( DWFException );
00337 
00338     //
00339     //
00340     //
00341     DWFXFixedPage* _createFixedPage( DWFSection* pSection, bool bAppend=true )
00342         throw( DWFException );
00343 
00344     //
00345     //
00346     //
00347     void _addResourcePartsByRole( const DWFString& zRole,
00348                                   DWFXDWFSection*  pDescriptorPart,
00349                                   DWFXFixedPage*   pFixedPage = NULL )
00350         throw( DWFException );
00351 
00352     //
00353     //
00354     //
00355     void _addResourcePart( DWFResource&    rResource,
00356                            DWFXDWFSection* pDescriptorPart,
00357                            DWFXFixedPage*  pFixedPage = NULL )
00358         throw( DWFException );
00359 
00360     //
00361     //  After adding all resources to the DWFXPackage call this to add
00362     //  resource relationships
00363     //
00364     void _addResourceRelationships()
00365         throw( DWFException );
00366 
00367     void _addRelationships( DWFSection& rSection )
00368         throw( DWFException );
00369 
00370     void _addRelationships( DWFResource& rResource )
00371         throw( DWFException );
00372 
00373     //
00374     //  This sets the DWFToolkitVersion in DWF Properties. It also supports
00375     //  the old method of setting the properties provided in the argument via
00376     //  the arguments to DWFPackageWriter::write(...). If any properties have
00377     //  been directly added to the manifest based on the old API usage, this
00378     //  moves the properties into the appropriate places.
00379     //
00380     void _updateProperties( const DWFString& zSourceProductVendor,
00381                             const DWFString& zSourceProductName,
00382                             const DWFString& zSourceProductVersion,
00383                             const DWFString& zDWFProductVendor,
00384                             const DWFString& zDWFProductVersion )
00385         throw( DWFException );
00386 
00387 private:
00388 
00389     //
00390     //  Not implemented
00391     //
00392     DWFXPackageWriter();
00393     DWFXPackageWriter( const DWFXPackageWriter& );
00394     DWFXPackageWriter& operator=( const DWFXPackageWriter& );
00395 
00396 };
00397 
00398 }
00399 
00400 #endif
00401 #endif

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