home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 5.5 KB | 206 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: Content.cpp
- // Release Version: $ ODF 2 $
- //
- // Author: M.Boetcher
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "Embed.hpp"
-
- #ifndef CONTENT_H
- #include "Content.h"
- #endif
-
- #ifndef PART_H
- #include "Part.h"
- #endif
-
- #ifndef PROXY_H
- #include "Proxy.h"
- #endif
-
- #ifndef FRAME_H
- #include "Frame.h"
- #endif
-
- #ifndef FWPRESEN_H
- #include "FWPresen.h"
- #endif
-
- #ifndef FWKIND_H
- #include "FWKind.h"
- #endif
-
- #ifndef FWSUSINK_H
- #include "FWSUSink.h"
- #endif
-
- #ifndef FWSUUTIL_H
- #include "FWSUUtil.h"
- #endif
-
- #ifndef FWBUFSIN_H
- #include "FWBufSin.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- //========================================================================================
- // Runtime information
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfembed
- #endif
-
- FW_DEFINE_AUTO(CEmbedContent)
-
- //========================================================================================
- // CLASS CEmbedContent
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CEmbedContent constructor
- //----------------------------------------------------------------------------------------
-
- CEmbedContent::CEmbedContent(Environment* ev, CEmbedPart* part)
- : FW_CEmbeddingContent(ev, part),
- fEmbedPart(part),
- fProxy(NULL)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedContent destructor
- //----------------------------------------------------------------------------------------
-
- CEmbedContent::~CEmbedContent()
- {
- delete fProxy;
- fProxy = NULL;
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedContent::Externalize
- //----------------------------------------------------------------------------------------
-
- void CEmbedContent::ExternalizeKind(Environment* ev,
- ODStorageUnit* storageUnit,
- FW_CKind* kind,
- FW_StorageKinds storageKind,
- FW_CPromise* promise,
- FW_CCloneInfo* cloneInfo)
- {
- FW_UNUSED(storageKind);
- FW_UNUSED(promise);
-
- FW_ASSERT(kind->IsPartKind(ev)); // We only support one kind
-
- // ----- Create a stream -----
- FW_PStorageUnitSink suSink(ev, storageUnit, kODPropContents, kind->GetType(ev));
- FW_CWritableStream stream(suSink);
-
- // ----- Write number of embedded parts -----
- unsigned long count = (fProxy ? 1 : 0);
- stream << count;
-
- // ----- Write embedded part -----
- if (fProxy)
- fProxy->Externalize(ev, suSink->GetStorageUnitView(ev), cloneInfo);
-
- // ----- Delete whatever follows -----
- FW_SUDeleteEndOfFocusedValue(ev, storageUnit);
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedContent::InternalizeKind
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CEmbedContent::InternalizeKind(Environment* ev,
- ODStorageUnit* storageUnit,
- FW_CKind* kind,
- FW_StorageKinds storageKind,
- FW_CCloneInfo* cloneInfo)
- {
- FW_UNUSED(storageKind);
- FW_ASSERT(kind->IsPartKind(ev)); // We only support one kind
-
- // ----- Create a stream -----
- FW_PStorageUnitSink suSink(ev, storageUnit, kODPropContents, kind->GetType(ev));
- FW_PBufferedSink sink(ev, suSink);
- FW_CReadableStream stream(sink);
-
- // ----- Read number of embedded parts -----
- unsigned long count;
- stream >> count;
-
- // ----- Read embedded part, if any -----
- if (count == 1)
- {
- fProxy = new CEmbedProxy(ev, fEmbedPart);
- fProxy->Internalize(ev, suSink->GetStorageUnitView(ev), cloneInfo);
- }
-
- return true;
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedContent::SingleEmbeddedFrameInternalized
- //----------------------------------------------------------------------------------------
-
- void CEmbedContent::SingleEmbeddedFrameInternalized(Environment* ev,
- FW_CEmbeddingFrame* scopeFrame,
- ODPart* odEmbeddedPart,
- ODFrame* odEmbeddedFrame,
- ODShape* suggestedShape,
- ODTypeToken viewType)
- {
- FW_UNUSED(suggestedShape);
- // ----- Detach existing proxy, if any -----
- if (fProxy)
- {
- fProxy->SetSelectState(ev, false);
- fProxy->DetachEmbeddedFrames(ev);
- }
-
- // ----- Calculate the frame shape -----
- FW_CAcquiredODShape aqFrameShape = ((CEmbedFrame*)scopeFrame)->CreateFrameShape(ev);
-
- // ----- Create the proxy -----
- CEmbedProxy* newProxy = new CEmbedProxy(ev, fEmbedPart);
-
- // ----- Embed the Part/Frame -----
- newProxy->Embed(ev,
- scopeFrame->GetPresentation(ev),
- odEmbeddedPart,
- odEmbeddedFrame,
- kODFrameObject,
- aqFrameShape,
- viewType,
- NULL, // no presentation
- 0, // group id
- FALSE, // is overlaid
- false); // sub-frame?
-
- // ----- Set the proxy -----
- fProxy = newProxy;
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedContent::IsDataOnlyOneProxy
- //----------------------------------------------------------------------------------------
-
- FW_MProxy* CEmbedContent::IsDataOnlyOneProxy(Environment* ev) const
- {
- FW_UNUSED(ev);
- return fProxy;
- }
-