// $Revision: 1.6 $ // Copyright (C) 1993-1994 Taligent, Inc. All Rights Reserved. #ifndef Taligent_GUICOMPOUNDDOCUMENTEMBEDDERIMP #define Taligent_GUICOMPOUNDDOCUMENTEMBEDDERIMP // // This file contains the implementation of the template functions // for the templates defined in GUICompoundDocumentEmbedder.h // #ifndef NO_Internal #ifndef HIDE_TEMPLATE_DEFINITIONS #define MAKE_TGUIEmbedderModelSelectionFor_DEFINITIONS_VISIBLE #else #define inline #endif #ifdef MAKE_TGUIEmbedderModelSelectionFor_DEFINITIONS_VISIBLE // // TGUIEmbedderModelSelectionFor Implementation // TemplateVersionDefinitionsMacro(TGUIEmbedderModelSelectionFor,AModel); TemplateDynamicCastDefinitionsMacroOne(TGUIEmbedderModelSelectionFor,AModel,TGUIEmbedderModelSelection); template TGUIEmbedderModelSelectionFor::TGUIEmbedderModelSelectionFor() : TGUIEmbedderModelSelection() { } template TGUIEmbedderModelSelectionFor::TGUIEmbedderModelSelectionFor( const TModelReference& theModelRef ) : TGUIEmbedderModelSelection( theModelRef ) { } template TGUIEmbedderModelSelectionFor::TGUIEmbedderModelSelectionFor( const AModel& theModel ) : TGUIEmbedderModelSelection( theModel ) { } template TGUIEmbedderModelSelectionFor::TGUIEmbedderModelSelectionFor( const TGUIEmbedderModelSelectionFor& copy ) : TGUIEmbedderModelSelection( copy ) { } template TGUIEmbedderModelSelectionFor::~TGUIEmbedderModelSelectionFor() { } template const AModel* TGUIEmbedderModelSelectionFor::GetModelForReading() const { const TModel* theModel = TModelSelection::GetModelForReading(); AModel* theModelSubclass; DynamicCastTo( theModelSubclass, theModel ); if (theModelSubclass == NIL ) { throw TCompoundDocumentException( TCompoundDocumentException:: kModelDoesNotExist ); } return theModelSubclass; } template AModel* TGUIEmbedderModelSelectionFor::GetModelForWriting() const { TModel* theModel = TModelSelection::GetModelForWriting(); AModel* theModelSubclass; DynamicCastTo( theModelSubclass, theModel ); if (theModelSubclass == NIL ) { throw TCompoundDocumentException( TCompoundDocumentException:: kModelDoesNotExist ); } return theModelSubclass; } template void TGUIEmbedderModelSelectionFor::CreateAvailableTypesList( TSequenceOf& theTypes ) const { theTypes.Add( new (kSameHeap, &theTypes) TTypeDescription( AModel ::GetTypeDescription() ) ); TGUIEmbedderModelSelection::CreateAvailableTypesList( theTypes ); } template void TGUIEmbedderModelSelectionFor::ChooseTypes( const TSequenceOf& theChoices, TSequenceOf& theChosen ) const { TTypeDescription* member = theChoices.Member( AModel ::GetTypeDescription() ); if ( member ) { theChosen.Add( member ); } else { TGUIEmbedderModelSelection::ChooseTypes( theChoices, theChosen ); } } template TModel* TGUIEmbedderModelSelectionFor::HandleCreateModel( const TTypeDescription& theType ) const { if ( theType != TTypeDescription( AModel :: GetTypeDescription() ) ) { throw TCompoundDocumentException( TCompoundDocumentException:: kTypeUnacceptable ); } return new AModel; } template void TGUIEmbedderModelSelectionFor::HandleCopyDataInto(TModel& theModel) const { AModel* theModelSubclass; DynamicCastTo( theModelSubclass, &theModel ); if ( theModelSubclass != NIL ) { CopyDataIntoGUIEmbedderModel( *theModelSubclass ); CopyDataIntoModelSubclass( *theModelSubclass ); } else { TGUIEmbedderModelSelection::HandleCopyDataInto( theModel ); } } template TModel* TGUIEmbedderModelSelectionFor::HandleReplaceData(TModel* newModel) { TModel* undoModel = HandleOrphanData(); AModel* theModel; DynamicCastTo( theModel, newModel ); if ( theModel != NIL ) { MoveDataOutofGUIEmbedderModel( *theModel ); MoveDataOutofModelSubclass( *theModel ); } else { TGUIEmbedderModel* theGUIEmbedderModel = NIL; DynamicCastTo( theGUIEmbedderModel, newModel ); if ( theGUIEmbedderModel != NIL ) { MoveDataOutofGUIEmbedderModel( *theGUIEmbedderModel ); } else { TEmbedderModel* theEmbedderModel; DynamicCastTo( theEmbedderModel, newModel ); if ( theEmbedderModel != NIL ) { MoveDataOutofEmbedderModel( *theEmbedderModel ); } } } return undoModel; } template TModel* TGUIEmbedderModelSelectionFor::HandleOrphanData() { AModel* undoModel = new AModel; MoveDataIntoGUIEmbedderModel( *undoModel ); MoveDataIntoModelSubclass( *undoModel ); return undoModel; }; #endif #ifdef HIDE_TEMPLATE_DEFINITIONS #undef inline #endif #endif //NO_Internal #endif