Section.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/Section.h#4 $
00019 //  $DateTime: 2008/06/18 18:08:14 $
00020 //  $Author: gaoje $
00021 //  $Change: 101166 $
00022 //  $Revision: #4 $
00023 //
00024 
00025 
00026 #ifndef _DWFTK_SECTION_H
00027 #define _DWFTK_SECTION_H
00028 
00029 
00034 
00035 
00036 #include "dwfcore/STL.h"
00037 #include "dwfcore/Owner.h"
00038 #include "dwfcore/SkipList.h"
00039 #include "dwfcore/XMLParser.h"
00040 using namespace DWFCore;
00041 
00042 #include "dwf/Toolkit.h"
00043 #include "dwf/package/XML.h"
00044 #include "dwf/package/Source.h"
00045 #include "dwf/package/Content.h"
00046 #include "dwf/package/Resource.h"
00047 #include "dwf/package/Interface.h"
00048 #include "dwf/package/ObjectDefinition.h"
00049 #include "dwf/package/ObjectDefinitionResource.h"
00050 #include "dwf/package/writer/PackageWriter.h"
00051 #include "dwf/package/reader/PackageReader.h"
00052 #include "dwf/package/reader/ObjectDefinitionReader.h"
00053 #include "dwf/presentation/reader/ContentPresentationReader.h"
00054 #include "dwf/package/reader/SectionDescriptorReader.h"
00055 #include "dwf/package/utility/ResourceContainer.h"
00056 #include "dwf/package/utility/PropertyContainer.h"
00057 #include "dwf/package/utility/DefinedObjectContainer.h"
00058 #include "dwf/presentation/ContentPresentation.h"
00059 
00060 namespace DWFToolkit
00061 {
00062 
00081 class DWFSection : public    DWFXMLBuildable
00082 #ifndef DWFTK_READ_ONLY
00083                  , public    DWFXMLSerializable
00084 #endif
00085                  , public    DWFOwnable
00086                  , public    DWFResourceContainer
00087                  , public    DWFPropertyContainer
00088                  , protected DWFXMLElementBuilder
00089                  _DWFTK_EXPORT_API_MEMORY_CONTROL_BASE_MEMBER
00090 {
00091 
00092 public:
00093 
00099     typedef struct tBehavior
00100     {
00107         bool    bRenameOnPublish;
00108 
00115         bool    bPublishDescriptor;
00116 
00117         //
00118         // if true, the publishing logic of the toolkit
00119         // will treat this section as a standard DWF section
00120         // with respect to it's package documentation, in particular,
00121         // the manifest will include a list of the sections resources.
00122         // by default, this is true
00123         //
00124         bool    bPublishResourcesToManifest;
00125 
00126         tBehavior( bool bRenameOnPub = true, 
00127                    bool bPubDescriptor = true,
00128                    bool bPublishResourcesToManifest = true )
00129                  : bRenameOnPublish( bRenameOnPub )
00130                  , bPublishDescriptor( bPubDescriptor )
00131                  , bPublishResourcesToManifest( bPublishResourcesToManifest )
00132         {}
00133 
00134     } tBehavior;
00135 
00139     typedef _DWFTK_STD_VECTOR(DWFSection*)  tList;
00143     typedef DWFWCharKeySkipList<DWFSection*>                                    tMap;
00147     typedef std::multimap<const wchar_t*, DWFSection*, tDWFWCharCompareLess>    tMultiMap;
00151     typedef std::map<DWFString, DWFString>                                      tStringMap;
00155     typedef _DWFTK_STD_MULTIMAP(DWFString, DWFString) tStringMultiMap;
00156 
00157 public:
00158 
00168     class Factory _DWFTK_EXPORT_API_MEMORY_CONTROL_BASE
00169     {
00170 
00171     public:
00172 
00176         typedef _DWFTK_STD_VECTOR(DWFSection::Factory*)     tList;
00180         typedef DWFWCharKeySkipList<DWFSection::Factory*>   tMap;
00181 
00182     public:
00183 
00190         _DWFTK_API
00191         Factory( const DWFString& zType )
00192             throw();
00193 
00199         _DWFTK_API
00200         virtual ~Factory()
00201             throw();
00202 
00209         _DWFTK_API
00210         const DWFString& type() const
00211             throw();
00212 
00227         _DWFTK_API
00228         virtual DWFSection* build( const DWFString&     zName,
00229                                    const DWFString&     zTitle,
00230                                    DWFPackageReader*    pPackageReader )
00231             throw( DWFException );
00232 
00248         _DWFTK_API
00249         virtual DWFSection* build( const DWFString&     zType,
00250                                    const DWFString&     zName,
00251                                    const DWFString&     zTitle,
00252                                    DWFPackageReader*    pPackageReader )
00253             throw( DWFException );
00254 
00255     private:
00256 
00257         DWFString _zType;
00258     };
00259 
00260 public:
00261 
00274     _DWFTK_API
00275     DWFSection( DWFPackageReader* pPackageReader )
00276         throw();
00277 
00293     _DWFTK_API
00294     DWFSection( const DWFString&  zType,
00295                 const DWFString&  zName,
00296                 const DWFString&  zTitle,
00297                 DWFPackageReader* pPackageReader )
00298         throw();
00299 
00314     _DWFTK_API
00315     DWFSection( const DWFString& zType,
00316                 const DWFString& zTitle,
00317                 const DWFString& zObjectID,
00318                 double           nVersion,
00319                 double           nPlotOrder,
00320                 const DWFSource& rSource )
00321         throw();
00322 
00329     _DWFTK_API
00330     DWFSection( const DWFSection& rSection)
00331         throw();
00332 
00339     _DWFTK_API
00340     DWFSection& operator=( const DWFSection& rSection)
00341         throw();
00342 
00348     _DWFTK_API
00349     virtual ~DWFSection()
00350         throw();
00351 
00362     _DWFTK_API
00363     virtual const DWFString& name() const
00364         throw()
00365     {
00366         return _zName;
00367     }
00368 
00383     _DWFTK_API
00384     virtual void rename( const DWFString& zName )
00385         throw();
00386 
00393     _DWFTK_API
00394     const DWFString& type() const
00395         throw()
00396     {
00397         return _zType;
00398     }
00399 
00406     _DWFTK_API
00407     virtual const DWFString& title() const
00408         throw()
00409     {
00410         return _zTitle;
00411     }
00412 
00420     _DWFTK_API
00421     virtual void retitle( const DWFString& zTitle )
00422         throw()
00423     {
00424         _zTitle = zTitle;
00425     }
00426 
00434     _DWFTK_API
00435     virtual void setLabel( const DWFString& zLabel )
00436         throw()
00437     {
00438         _zLabel = zLabel;
00439     }
00440 
00448     _DWFTK_API
00449     virtual const DWFString& label()
00450         throw()
00451     {
00452         return _zLabel;
00453     }
00454 
00462     _DWFTK_API
00463     virtual void setLabelIconResource( DWFResource& rResource )
00464         throw()
00465     {
00466         _pLabelIconResource = &rResource;
00467     }
00468 
00476     _DWFTK_API
00477     virtual void setLabelIconResourceID( const DWFString& zResourceID )
00478         throw()
00479     {
00480         _zLabelIconResourceID = zResourceID;
00481     }
00482 
00490     _DWFTK_API
00491     virtual const DWFString& labelIconResourceID()
00492         throw()
00493     {
00494         return _zLabelIconResourceID;
00495     }
00496 
00504     _DWFTK_API
00505     virtual const DWFString& initialURI()
00506         throw()
00507     {
00508         return _zInitialURI;
00509     }
00510 
00518     _DWFTK_API
00519     virtual void setInitialURI( const DWFString& zInitialURI )
00520         throw()
00521     {
00522         _zInitialURI = zInitialURI;
00523     }
00524 
00535     _DWFTK_API
00536     virtual const DWFSource& source() const
00537         throw()
00538     {
00539         return _oSource;
00540     }
00541 
00550     _DWFTK_API
00551     virtual void addSource( const DWFSource& rSource )
00552         throw();
00553 
00565     _DWFTK_API
00566     virtual DWFInterface* buildInterface()
00567         throw( DWFException )
00568     {
00569         return NULL;
00570     }
00571 
00582     _DWFTK_API
00583     virtual const DWFString& objectID() const
00584         throw()
00585     {
00586         return _zObjectID;
00587     }
00588 
00598     _DWFTK_API
00599     virtual double version() const
00600         throw()
00601     {
00602         return _nVersion;
00603     }
00604 
00611     _DWFTK_API
00612     virtual double order() const
00613         throw()
00614     {
00615         return _nPlotOrder;
00616     }
00617 
00626     _DWFTK_API
00627     virtual void reorder( double nPlotOrder )
00628         throw()
00629     {
00630         _nPlotOrder = nPlotOrder;
00631     }
00632 
00640     _DWFTK_API
00641     virtual void setContentManager( DWFContentManager* pContentManager )
00642         throw()
00643     {
00644         _pContentManager = pContentManager;
00645     }
00646 
00655     _DWFTK_API
00656     virtual DWFContentManager* getContentManager() const
00657         throw()
00658     {
00659         return _pContentManager;
00660     }
00661 
00665     _DWFTK_API
00666     virtual DWFResource* addResource( DWFResource*       pResource,
00667                                       bool               bOwnResource,
00668                                       bool               bReplace = true,
00669                                       bool               bDeleteReplacedIfOwned = true,
00670                                       const DWFResource* pParentResource = NULL )
00671         throw( DWFException );
00672 
00686     _DWFTK_API
00687     virtual
00688     const DWFResource& readDescriptor( DWFSectionDescriptorReader* pSectionDescriptorReader = NULL ) const
00689         throw( DWFException );
00690 
00702     _DWFTK_API
00703     virtual 
00704     void readDescriptor( DWFSectionDescriptorReader& rSectionDescriptorReader,
00705                          DWFResource&                rResource ) const
00706         throw( DWFException );
00707 
00719     _DWFTK_API
00720     virtual 
00721     void readDescriptor( DWFSectionDescriptorReader& rSectionDescriptorReader,
00722                          DWFInputStream&             rSectionDescriptorStream ) const
00723         throw( DWFException );
00724 
00743     _DWFTK_API
00744     virtual DWFContent* getContentDefinition( DWFResource* pResource, 
00745                                               DWFContentResourceReader* pReaderFilter = NULL,
00746                                               bool bLoadContent = true )
00747         throw( DWFException );
00748 
00766     _DWFTK_API
00767     virtual DWFContent::tIterator* getContentDefinition( DWFContentResourceReader* pReaderFilter = NULL,
00768                                                          bool bLoadContent = true )
00769         throw( DWFException );
00770 
00789     _DWFTK_API
00790     virtual void getContentDefinition( DWFContent::tMap& oResourceObjectIDContent,
00791                                        DWFContentResourceReader* pReaderFilter = NULL,
00792                                        bool bLoadContent = true )
00793         throw( DWFException );
00794 
00807     _DWFTK_API
00808     virtual void getContentDefinition( DWFContentResourceReader& rReader,
00809                                        DWFResource* pResource = NULL )
00810         throw( DWFException );
00811 
00823     _DWFTK_API
00824     virtual void getContentDefinition( DWFContentResourceReader& rReader,
00825                                        DWFInputStream& rContentResourceStream )
00826         throw( DWFException );
00827 
00835     _DWFTK_API
00836     virtual void getAssociatedContentIDs( tStringMultiMap& oResourceIDContentIDMap ) const
00837         throw();
00838 
00851     _DWFTK_API
00852     virtual void updateResourceContentMapping( const DWFString& zResourceObjectID,
00853                                                const DWFString& zOldContentID,
00854                                                const DWFString& zNewContentID )
00855         throw( DWFException );
00856 
00869     _DWFTK_API
00870     virtual void updateResourceContentMapping( DWFResource* pResource,
00871                                                const DWFString& zOldContentID,
00872                                                const DWFString& zNewContentID )
00873         throw( DWFException );
00874 
00883     _DWFTK_API
00884     virtual DWFObjectDefinition* getObjectDefinition() const
00885         throw( DWFException );
00886 
00900     _DWFTK_API
00901     virtual DWFObjectDefinition* getObjectDefinition( DWFObjectDefinitionReader& rObjectDefinitionFilter,
00902                                                       DWFResource&               rResource ) const
00903         throw( DWFException );
00904 
00917     _DWFTK_API
00918     virtual 
00919     void getObjectDefinition( DWFObjectDefinitionReader& rObjectDefinitionReader,
00920                               DWFResource*               pResource = NULL ) const
00921         throw( DWFException );
00922 
00934     _DWFTK_API
00935     virtual 
00936     void getObjectDefinition( DWFObjectDefinitionReader& rObjectDefinitionReader,
00937                               DWFInputStream&            rObjectDefinitionStream ) const
00938         throw( DWFException );
00939 
00948     _DWFTK_API
00949     virtual
00950     void readContentPresentations()
00951         throw( DWFException );
00952 
00964     _DWFTK_API
00965     virtual
00966     void readContentPresentations( DWFContentPresentationReader& rContentPresentationFilter,
00967                                    DWFResource&                  rResource ) const
00968         throw( DWFException );
00969 
00982     _DWFTK_API
00983     virtual 
00984     void readContentPresentations( DWFContentPresentationReader& rContentPresentationReader,
00985                                    DWFResource*                  pResource) const
00986         throw( DWFException );
00987 
00999     _DWFTK_API
01000     virtual 
01001     void readContentPresentations( DWFContentPresentationReader& rContentPresentationReader,
01002                                    DWFInputStream&               rContentPresentationStream ) const
01003         throw( DWFException );
01004 
01008     _DWFTK_API
01009     virtual void parseAttributeList( const char** ppAttributeList )
01010         throw( DWFException );
01011 
01019     _DWFTK_API
01020     virtual DWFSection::tBehavior behavior() const
01021         throw();
01022 
01030     _DWFTK_API
01031     virtual void applyBehavior( const DWFSection::tBehavior& rBehavior )
01032         throw();
01033 
01034 #ifndef DWFTK_READ_ONLY
01035 
01039     _DWFTK_API
01040     virtual void serializeXML( DWFXMLSerializer& rSerializer, unsigned int nFlags )
01041         throw( DWFException );
01042 
01043 #endif
01044 
01045 protected:
01046 
01047     static const wchar_t* const kzProperty_Label;
01048     static const wchar_t* const kzProperty_LabelIconResourceID;
01049     static const wchar_t* const kzProperty_InitialURI;
01050     static const wchar_t* const kzPropertyCategory_Hidden;
01051 
01052 protected:
01053 
01054     typedef std::multimap<DWFResource*, DWFString>    tResourceStringMultiMap;
01055 
01056 protected:
01057 
01058     DWFString           _zType;
01059     DWFString           _zName;
01060     DWFString           _zTitle;
01061     DWFString           _zLabel;
01062     DWFString           _zLabelIconResourceID;
01063     DWFResource*        _pLabelIconResource;
01064     DWFString           _zInitialURI;
01065     DWFString           _zObjectID;
01066     double              _nVersion;
01067     double              _nPlotOrder;
01068     DWFSource           _oSource;
01069 
01070     DWFPackageReader*           _pPackageReader;
01071     DWFContentManager*          _pContentManager;
01072     
01073     //
01074     //  Track resources that are associated with contents, mapping them to the content ID.
01075     //
01076     tResourceStringMultiMap     _oResourceToContentID;
01077 
01081     tBehavior                   _tBehavior;
01082 
01083     bool                        _bContentPresentationsRead;
01084 
01085 protected:
01086 
01090     _DWFTK_API
01091     virtual DWFResource* buildResource( const char**      ppAttributeList,
01092                                         DWFPackageReader* pPackageReader )
01093         throw( DWFException );
01094 
01098     _DWFTK_API
01099     virtual DWFFontResource* buildFontResource( const char**      ppAttributeList,
01100                                                 DWFPackageReader* pPackageReader )
01101         throw( DWFException );
01102 
01106     _DWFTK_API
01107     virtual DWFImageResource* buildImageResource( const char**      ppAttributeList,
01108                                                   DWFPackageReader* pPackageReader )
01109         throw( DWFException );
01110 
01114     _DWFTK_API
01115     DWFGraphicResource* buildGraphicResource( const char**      ppAttributeList,
01116                                               DWFPackageReader* pPackageReader )
01117         throw( DWFException );
01118 
01119     //
01120     //
01121     //
01122     _DWFTK_API
01123     void _parseDocument( DWFInputStream& rDocumentStream,
01124                          DWFCore::DWFXMLCallback& rDocumentReader ) const
01125         throw( DWFException );
01126 
01127 private:
01128 
01129     //
01130     //  This traps the resource containers _remove calls to remove the mapping of the
01131     //  resource to contentID, and then passes the call onto the base class.
01132     //
01133     _DWFTK_API
01134     virtual DWFResource* _remove( DWFResource* pResource, bool bDeleteIfOwned )
01135         throw();
01136 };
01137 
01138     //
01139     // required for win32 dll external linkage
01140     //
01141 #ifdef  _DWFCORE_WIN32_SYSTEM
01142 #ifndef DWFTK_STATIC
01143 
01144 //DNT_Start
01145 _declspec(selectany) const wchar_t* const DWFSection::kzProperty_Label                  = L"_Label";
01146 _declspec(selectany) const wchar_t* const DWFSection::kzProperty_LabelIconResourceID    = L"_LabelIconResourceID";
01147 _declspec(selectany) const wchar_t* const DWFSection::kzProperty_InitialURI             = L"_InitialURI";
01148 _declspec(selectany) const wchar_t* const DWFSection::kzPropertyCategory_Hidden         = L"hidden";
01149 //DNT_End
01150 
01151 #endif
01152 #endif
01153 
01154 }
01155 
01156 #endif

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