// $Revision: 1.4 $ #ifndef TaligentSamples_GIFTRANSLATOR #include "GIFTranslator.h" #endif #ifndef TaligentSamples_ATOMICMODEL #include #endif #ifndef TaligentSamples_GRAPHICDOCUMENTVIEW #include #endif #ifndef Taligent_GIF #include #endif #ifndef Taligent_GUICOMPOUNDDOCUMENT #include #endif #ifndef Taligent_SCRAPITEMON #include #endif #ifndef Taligent_MODELSCRAPITEM #include #endif MCollectibleDefinitionsMacro(TGIFTranslator, kOriginalVersion); const TTypeDescription TGIFTranslator::kGraphicScrapType( StaticTypeInfo(TScrapItemOn)); const TTypeDescription TGIFTranslator::kEmbedderModelScrapType = TEmbedderModel::GetTypeDescription(); TGIFTranslator::TGIFTranslator() { } TGIFTranslator::TGIFTranslator(const TGIFTranslator& source) : TForeignDataTranslator(source) { } TGIFTranslator::~TGIFTranslator() { } TGIFTranslator& TGIFTranslator::operator=(const TGIFTranslator& source) { if (&source != this) { TForeignDataTranslator::operator=(source); } return *this; } TStream& TGIFTranslator::operator>>=(TStream& toStream) const { ::WriteVersion(toStream); TForeignDataTranslator::operator>>=(toStream); return toStream; } TStream& TGIFTranslator::operator<<=(TStream& fromStream) { ::ReadVersion(fromStream, kOriginalVersion, kOriginalVersion); TForeignDataTranslator::operator<<=(fromStream); return fromStream; } TScrapItem* TGIFTranslator::CreateScrapItem(const TForeignData& inputData, const TTypeDescription& desiredType, TMemoryHeap* heap) const { TAllocationHeap newHeap(heap); TDeleterFor scrapItem = 0; if (desiredType == kGraphicScrapType) { MGraphic* graphic = CreateGraphic(inputData); scrapItem = new (newHeap) TScrapItemOn( graphic, TGPoint::kOrigin); } else if (desiredType == kEmbedderModelScrapType) { MGraphic* graphic = CreateGraphic(inputData); TModel* model = new (newHeap) TAtomicModelOn(graphic); TModelPresenterState* presenterState = new (newHeap) TGUIPresenterStateFor >; scrapItem = CreateEmbedderScrapItem(model, presenterState, heap); } else { throw TForeignDataException(TForeignDataException::kInvalidTranslator); } return scrapItem.OrphanObject(); } void TGIFTranslator::ExportData(const TTypeDescription& inputType, const TScrapItem& inputData, const TForeignDataType& desiredType, TForeignData& output) const { throw TForeignDataException(TForeignDataException::kInvalidTranslator); } MGraphic* TGIFTranslator::CreateGraphic(const TForeignData& inputData) const { TDeleterFor stream = inputData.CreateStreamForReading(); TGIFConverter converter; TModifiableImage* image = converter.CreateFrom(*stream); return (MGraphic*)image; }