home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-16 | 7.2 KB | 208 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWPrstng.cpp
- // Release Version: $ ODF 1 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWFrameW.hpp"
-
- #ifndef FWPRSTNG_H
- #include "FWPrstng.h"
- #endif
-
- #ifndef FWPARTNG_H
- #include "FWPartng.h"
- #endif
-
- #ifndef FWFRMING_H
- #include "FWFrming.h"
- #endif
-
- #ifndef FWITERS_H
- #include "FWIters.h"
- #endif
-
- #ifndef FWPXYFRM_H
- #include "FWPxyFrm.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- #ifndef SOM_ODShape_xh
- #include <Shape.xh>
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment fw_embedding
- #endif
-
- //========================================================================================
- // class FW_CEmbeddingPresentation
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingPresentation::FW_CEmbeddingPresentation
- //----------------------------------------------------------------------------------------
-
- FW_CEmbeddingPresentation::FW_CEmbeddingPresentation(Environment *ev,
- FW_CEmbeddingPart* thePart,
- FW_CSelection* selection,
- ODTypeToken presentationType,
- ODTypeToken defaultEmbeddedFrameViewType) :
- FW_CPresentation(ev, thePart, selection, presentationType, defaultEmbeddedFrameViewType)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingPresentation::~FW_CEmbeddingPresentation
- //----------------------------------------------------------------------------------------
-
- FW_CEmbeddingPresentation::~FW_CEmbeddingPresentation()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingPresentation::Embed
- //----------------------------------------------------------------------------------------
-
- FW_DECLARE_THROW_POINT (FW_CEmbeddingPresentation_Embed);
-
- void FW_CEmbeddingPresentation::Embed(Environment *ev,
- ODPart *embeddedPart,
- ODFrame* odEmbeddedFrame, // Might be null
- ODType suggestedFrameType, // preferred frame type
- FW_MProxy* proxy,
- ODShape* frameShape,
- ODTypeToken viewType,
- ODTypeToken presentationType,
- ODID frameGroupID,
- FW_Boolean isOverlaid,
- FW_Boolean subFrame)
- {
- /* Exception Handling
- If an exception is thrown while we are partway through creating frames then we
- have destroy all previously created frames.
- */
- FW_ASSERT(embeddedPart);
- FW_ASSERT(frameShape);
- FW_ASSERT(proxy);
-
- ODFrame* passedInFrame = NULL;
- ODFrame* sourceFrame = NULL;
- ODFrame* newEmbeddedFrame = NULL;
-
- // ----- Force the frame type to be the one of the embedded frame ------
- if (odEmbeddedFrame != NULL)
- suggestedFrameType = (odEmbeddedFrame->GetStorageUnit(ev) != NULL) ? kODFrameObject : kODNonPersistentFrameObject;
-
- // ----- Create an embedded frame for each of my display frame -----
- FW_TRY
- { // loop protection
- FW_CPresentationFrameIterator ite(ev, this);
- for (FW_CEmbeddingFrame* embeddingFrame = (FW_CEmbeddingFrame*)ite.First(ev); ite.IsNotComplete(ev); embeddingFrame = (FW_CEmbeddingFrame*)ite.Next(ev))
- {
- FW_CProxyFrame* proxyFrame;
-
- FW_CAcquiredODShape aqItsShape(frameShape->Copy(ev));
-
- // ----- Create the frame -----
- FW_Boolean isEmbeddedFrame = FALSE;
- if (odEmbeddedFrame != NULL)
- {
- FW_CAcquiredODFrame aqContainingFrame = odEmbeddedFrame->AcquireContainingFrame(ev);
- isEmbeddedFrame = (aqContainingFrame == embeddingFrame->GetODFrame(ev));
- }
-
- if (isEmbeddedFrame)
- {
- odEmbeddedFrame->SetViewType(ev, viewType);
- odEmbeddedFrame->SetPresentation(ev, presentationType == NULL ? GetPart(ev)->GetSession(ev)->Tokenize(ev, kODPresDefault) : presentationType);
- odEmbeddedFrame->SetFrameGroup(ev, frameGroupID);
- odEmbeddedFrame->ChangeSequenceNumber(ev, 0);
- odEmbeddedFrame->SetSubframe(ev, subFrame);
-
- newEmbeddedFrame = odEmbeddedFrame;
- passedInFrame = odEmbeddedFrame;
- odEmbeddedFrame = NULL; // We used it. Next time around we want to create a new frame
-
- proxyFrame = proxy->PrivNewProxyFrame(ev, (FW_CEmbeddingPart*)GetPart(ev), embeddingFrame, newEmbeddedFrame);
-
- // Change the frame shape after we have a proxyFrame (only if necessary)
- FW_CAcquiredODShape aqFrameShape = newEmbeddedFrame->AcquireFrameShape(ev, NULL);
- if (!aqFrameShape->IsSameAs(ev, aqItsShape))
- newEmbeddedFrame->ChangeFrameShape(ev, aqItsShape, NULL);
- }
- else
- {
- FW_CAcquiredODFrame embeddedODFrame = embeddingFrame->PrivCreateEmbeddedFrame(ev,
- suggestedFrameType,
- embeddedPart,
- aqItsShape,
- NULL,
- viewType,
- presentationType,
- isOverlaid,
- subFrame);
-
- // ----- Create the proxyFrame for this embedded frame -----
- proxyFrame = proxy->PrivNewProxyFrame(ev, embeddingFrame->GetPart(ev), embeddingFrame, embeddedODFrame);
-
- proxyFrame->PrivSetFrameGroup(ev, frameGroupID);
- newEmbeddedFrame = proxyFrame->GetFrame(ev);
-
- // ----- Set the newly embedded frame's link status -----
- // [HLX] Because of a bug in OpenDoc 1.0 I cannot change the linkStatus
- // of an embedded frame embedded into a non persistent frame
- if (embeddingFrame->IsPersistent(ev))
- embeddedODFrame->ChangeLinkStatus(ev, kODNotInLink);
- }
-
- FW_TRY
- {
- // ----- Attach source frames if needed -----
- // If we are creating two or more frames at the same time then this tells the embedded part
- // that those frames are supposed to display the same content.
- if (sourceFrame)
- embeddedPart->AttachSourceFrame(ev, newEmbeddedFrame, sourceFrame);
- sourceFrame = newEmbeddedFrame;
-
- // ----- Create its facets -----
- // We have to make sure not to leave a dangling frame if this fails
- FW_CHECK_THROW_POINT (FW_CEmbeddingPresentation_Embed);
- // XXX if isEmbedded frame then we shouldn't destroy it (since we didn't create it)
- proxyFrame->CreateAllFacets(ev);
- }
- FW_CATCH_BEGIN
- FW_CATCH_EVERYTHING () {
- embeddingFrame->PrivRemoveEmbeddedFrame (ev, proxyFrame);
- FW_THROW_SAME ();
- }
- FW_CATCH_END
- }
- } // FW_TRY loop protection
- FW_CATCH_BEGIN
- FW_CATCH_EVERYTHING () {
- // Work in reverse to clean up everything from previous passes through the loop.
- // That is if we completed two loops and failed partway through loop 3, assume that loop 3
- // was cleaned up properly (in try/catch block above) and undo loops 1 and 2.
- // XXX Should we release passedInFrame since we didn't create it?
- // XXX not implemented
- FW_THROW_SAME ();
- }
- FW_CATCH_END
-
- // ----- If we haven't use odEmbeddedFrame there is a problem -----
- FW_ASSERT(odEmbeddedFrame == NULL);
- }
-