home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 56.3 KB | 2,257 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWODPart.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWFrameW.hpp"
-
- #ifndef FWODPART_H
- #include "FWODPart.h"
- #endif
-
- #ifndef FWPART_H
- #include "FWPart.h"
- #endif
-
- #ifndef FWPRMISE_H
- #include "FWPrmise.h"
- #endif
-
- #ifndef FWDRGDRP_H
- #include "FWDrgDrp.h"
- #endif
-
- #ifndef FWFRMING_H
- #include "FWFrming.h"
- #endif
-
- #ifndef FWPRTITE_H
- #include "FWPrtIte.h"
- #endif
-
- #ifndef FWPRESEN_H
- #include "FWPresen.h"
- #endif
-
- #ifndef FWFRMINF_H
- #include "FWFrmInf.h"
- #endif
-
- #ifndef FWPXYFRM_H
- #include "FWPxyFrm.h"
- #endif
-
- #ifndef FWPROXY_H
- #include "FWProxy.h"
- #endif
-
- #ifndef FWLNKMGR_H
- #include "FWLnkMgr.h"
- #endif
-
- #ifndef FWCMD_H
- #include "FWCmd.h"
- #endif
-
- #ifndef FWBARRAY_H
- #include "FWBArray.h"
- #endif
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- #ifndef FWMNUBAR_H
- #include "FWMnuBar.h"
- #endif
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWCLNINF_H
- #include "FWClnInf.h"
- #endif
-
- #ifndef FWDEBUG_H
- #include "FWDebug.h"
- #endif
-
- #ifndef FWEVENTD_H
- #include "FWEventD.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_Module_OpenDoc_Commands_defined
- #include <CmdDefs.xh>
- #endif
-
- #ifndef SOM_ODFrame_xh
- #include <Frame.xh>
- #endif
-
- #ifndef SOM_ODLinkSource_xh
- #include <LinkSrc.xh>
- #endif
-
- #ifndef SOM_ODLink_xh
- #include <Link.xh>
- #endif
-
- #ifndef SOM_ODClipboard_xh
- #include <Clipbd.xh>
- #endif
-
- #ifndef SOM_ODDraft_xh
- #include <Draft.xh>
- #endif
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- #ifndef SOM_ODArbitrator_xh
- #include <Arbitrat.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_Errors_defined
- #include <ErrorDef.xh>
- #endif
-
- //========================================================================================
- // Runtime Information
- //========================================================================================
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwpart2
- #endif
-
- #ifdef FW_DEBUG
- #define FW_kInvalidException "Your mother wears army boots"
- #endif
-
- //========================================================================================
- // class FW_CODPart
- //========================================================================================
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::FulfillPromise
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::FulfillPromise(Environment *ev, FW_CPart* part, ODStorageUnitView* promiseSUView)
- {
- FW_TRY
- {
- FW_CPromise* promise = NULL;
-
- FW_CByteArray bArray;
- promiseSUView->GetValue(ev, sizeof(FW_CPromise*), bArray);
- bArray.CopyBuffer(&promise, sizeof(FW_CPromise*));
-
- promiseSUView->SetOffset(ev, 0);
-
- unsigned short unfulfillPromise = promise->PrivHandleFulfillPromise(ev, promiseSUView);
-
- if (unfulfillPromise == 0)
- part->DeletePromise(ev, promise->GetStorageKind(ev));
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::DragEnter
- //---------------------------------------------------------------------------------------
-
- ODDragResult FW_CODPart::DragEnter(Environment *ev,
- ODDragItemIterator* dragInfo,
- ODFacet* facet,
- const FW_CPoint& where)
- {
- ODDragResult result = FALSE;
-
- FW_TRY
- {
- FW_MDragDroppable* theDrag = FW_MDragDroppable::ODFrameToDragDroppable(ev, facet->GetFrame(ev));
- FW_ASSERT(theDrag != NULL);
-
- result = theDrag->DragEnter(ev, facet, dragInfo, where);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
-
- return result;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::DragWithin
- //---------------------------------------------------------------------------------------
-
- ODDragResult FW_CODPart::DragWithin(Environment *ev,
- ODDragItemIterator* dragInfo,
- ODFacet* facet,
- const FW_CPoint& where)
- {
- ODDragResult result = FALSE;
-
- FW_TRY
- {
- FW_MDragDroppable* theDrag = FW_MDragDroppable::ODFrameToDragDroppable(ev, facet->GetFrame(ev));
- FW_ASSERT(theDrag != NULL);
-
- result = theDrag->DragWithin(ev, facet, dragInfo, where);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
-
- return result;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::DragLeave
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::DragLeave(Environment *ev,
- ODFacet* facet,
- const FW_CPoint& where)
- {
- FW_TRY
- {
- FW_MDragDroppable* theDrag = FW_MDragDroppable::ODFrameToDragDroppable(ev, facet->GetFrame(ev));
- FW_ASSERT(theDrag != NULL);
-
- theDrag->DragLeave(ev, facet, where);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::Drop
- //---------------------------------------------------------------------------------------
-
- ODDropResult FW_CODPart::Drop(Environment *ev,
- ODDragItemIterator* dropInfo,
- ODFacet* facet,
- const FW_CPoint& where)
- {
- ODDropResult result = kODDropFail;
-
- FW_TRY
- {
- FW_MDragDroppable* theDrop = FW_MDragDroppable::ODFrameToDragDroppable(ev, facet->GetFrame(ev));
- FW_ASSERT(theDrop != NULL);
-
- result = theDrop->Drop(ev, dropInfo, facet, where);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
-
- return result;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::DropCompleted
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::DropCompleted(Environment *ev,
- ODPart* destPart,
- ODDropResult dropResult)
- {
- FW_TRY
- {
- FW_DEBUG_MESSAGE("DropCompleted: Not Yet Implemented");
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::ContainingPartPropertiesUpdated
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::ContainingPartPropertiesUpdated(Environment *ev,
- ODFrame* odFrame,
- ODStorageUnit* propertyUnit)
- {
- FW_TRY
- {
- FW_DEBUG_MESSAGE("ContainingPartPropertiesUpdated: Not Yet Implemented");
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::AcquireContainingPartProperties
- //---------------------------------------------------------------------------------------
-
- ODStorageUnit* FW_CODPart::AcquireContainingPartProperties(Environment *ev, ODFrame* odFrame)
- {
- ODStorageUnit* su = NULL;
-
- FW_TRY
- {
- FW_DEBUG_MESSAGE("AcquireContainingPartProperties: Not Yet Implemented");
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
-
- return su;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::RevealFrame
- //---------------------------------------------------------------------------------------
-
- FW_Boolean FW_CODPart::RevealFrame(Environment *ev,
- ODFrame* embeddedFrame,
- ODShape* revealShape)
- {
- ODBoolean result = FALSE;
-
- FW_TRY
- {
- FW_CAcquiredODFrame aqContainingFrame = embeddedFrame->AcquireContainingFrame(ev);
- FW_CEmbeddingFrame* embeddingFrame = FW_CEmbeddingFrame::ODtoFWEmbeddingFrame(ev, aqContainingFrame);
- FW_ASSERT(embeddingFrame);
-
- result = embeddingFrame->RevealFrame(ev, embeddedFrame, revealShape);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
-
- return result;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::EmbeddedFrameSpec
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::EmbeddedFrameSpec(Environment *ev,
- ODFrame* embeddedFrame,
- ODObjectSpec* spec)
- {
- FW_TRY
- {
- FW_CAcquiredODFrame aqODContainingFrame = embeddedFrame->AcquireContainingFrame(ev);
- FW_ASSERT(FW_CFrame::ODtoFWFrame(ev, aqODContainingFrame) != NULL);
-
- FW_CEmbeddingFrame* containingFrame = FW_CEmbeddingFrame::ODtoFWEmbeddingFrame(ev, aqODContainingFrame);
- if (containingFrame)
- containingFrame->EmbeddedFrameSpec(ev, embeddedFrame, spec);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::DisplayFrameAdded
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::DisplayFrameAdded(Environment *ev,
- FW_CPart* part,
- ODFrame* odFrame)
- {
- FW_TRY
- {
- // ----- Create a global shape and transform if neccessary -----
- FW_PrivCreateShapeTransformMaker(ev, odFrame);
-
- // ----- Look for the presentation -----
- FW_CPresentation* newPresentation = part->PrivGetPresentation(ev, odFrame);
- odFrame->SetPresentation(ev, newPresentation->GetPresentationType(ev));
-
- // ----- Create the frame -----
- FW_CFrame* frame = part->NewFrame(ev, odFrame, newPresentation, FALSE);
-
- // ----- Create the part Info -----
- FW_CFramePartInfo* framePartInfo = new FW_CFramePartInfo(ev, frame);
- odFrame->SetPartInfo(ev, (ODInfoType)framePartInfo);
-
- // ----- Notify the frame -----
- frame->FrameAdded(ev, FALSE); // brand new frame
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::AttachSourceFrame
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::AttachSourceFrame(Environment *ev,
- ODFrame* odFrame,
- ODFrame* odSourceFrame)
- {
- FW_TRY
- {
- if (odSourceFrame != NULL && odFrame != NULL)
- {
- FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
- FW_ASSERT(frame);
-
- FW_CFrame* sourceFrame = FW_CFrame::ODtoFWFrame(ev, odSourceFrame);
- FW_ASSERT(sourceFrame != NULL);
-
- frame->PrivAttachSourceFrame(ev, sourceFrame);
- }
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::DisplayFrameRemoved
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::DisplayFrameRemoved(Environment *ev,
- ODFrame* odFrame)
- {
- FW_TRY
- {
- FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
- FW_ASSERT(frame);
-
- // ----- Notify the frame that it is going to be removed
- frame->FrameRemoved(ev, FALSE); // The frame is gone
-
- // ----- delete the frame (will release odFrame) -----
- delete frame;
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::DisplayFrameConnected
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::DisplayFrameConnected(Environment *ev,
- ODFrame* odFrame)
- {
- FW_TRY
- {
- FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
- FW_ASSERT(frame);
-
- // ----- Notify the frame
- frame->FrameAdded(ev, TRUE); // From storage
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::DisplayFrameClosed
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::DisplayFrameClosed(Environment *ev,
- ODFrame* odFrame)
- {
- FW_TRY
- {
- FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
- FW_ASSERT(frame != NULL);
-
- // ----- Notify the frame that it is going to be closed
- frame->FrameRemoved(ev, TRUE); // frame stays in storage
-
- // ----- delete it
- delete frame;
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::FrameShapeChanged
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::FrameShapeChanged(Environment *ev,
- ODFrame* odFrame)
- {
- FW_TRY
- {
- FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
- FW_ASSERT(frame != NULL);
-
- frame->FrameShapeChanged(ev);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::ViewTypeChanged
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::ViewTypeChanged(Environment *ev,
- ODFrame* odFrame)
- {
- FW_TRY
- {
- FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
- FW_ASSERT(frame != NULL);
-
- ODTypeToken newViewType = odFrame->GetViewType(ev);
- ODTypeToken oldViewType = frame->PrivGetPreviousViewType(ev);
-
- if (newViewType != oldViewType)
- {
- frame->PrivSetPreviousViewType(ev, newViewType);
- frame->ViewTypeChanged(ev, newViewType, oldViewType);
- }
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::PresentationChanged
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::PresentationChanged(Environment *ev,
- ODFrame* odFrame)
- {
- FW_TRY
- {
- FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
- FW_ASSERT(frame != NULL);
-
- frame->PresentationChanged(ev);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::SequenceChanged
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::SequenceChanged(Environment *ev,
- ODFrame* odFrame)
- {
- FW_TRY
- {
- FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
- FW_ASSERT(frame != NULL);
-
- frame->SequenceChanged(ev);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::WritePartInfo
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::WritePartInfo(Environment *ev,
- ODInfoType partInfo,
- ODStorageUnitView* storageUnitView)
- {
- FW_TRY
- {
- FW_ASSERT(partInfo != NULL);
-
- FW_CFrame* frame = ((FW_CFramePartInfo*)partInfo)->GetFrame();
- FW_ASSERT(frame);
-
- ODStorageUnit* su = storageUnitView->GetStorageUnit(ev);
-
- FW_CAcquireODPropertyName propName(ev, storageUnitView);
- FW_SUForceFocus(ev, su, propName, frame->GetPart(ev)->GetPartKind(ev));
-
- FW_CAcquireODStorageUnitView suView(ev, su);
- frame->ExternalizeFrame(ev, suView);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::ReadPartInfo
- //---------------------------------------------------------------------------------------
-
- ODInfoType FW_CODPart::ReadPartInfo(Environment *ev,
- FW_CPart* part,
- ODFrame* odFrame,
- ODStorageUnitView* storageUnitView)
- {
- ODInfoType partInfo = NULL;
-
- FW_TRY
- {
- // ----- Create a global shape and transform if neccessary -----
- FW_PrivCreateShapeTransformMaker(ev, odFrame);
-
- // ----- Determine the presentation -----
- FW_CPresentation* presentation = part->PrivGetPresentation(ev, odFrame);
- odFrame->SetPresentation(ev, presentation->GetPresentationType(ev));
-
- // ----- Create the FW_CFrame object -----
- FW_CFrame* frame = part->NewFrame(ev, odFrame, presentation, TRUE);
-
- // ----- Create the FW_CFramePartInfo object -----
- partInfo = (ODInfoType)new FW_CFramePartInfo(ev, frame);
-
- // ----- Internalize the frame -----
- ODStorageUnit* su = storageUnitView->GetStorageUnit(ev);
-
- FW_CAcquireODPropertyName propName(ev, storageUnitView);;
-
- if (FW_SUExistsThenFocus(ev, su, propName, frame->GetPart(ev)->GetPartKind(ev)) )
- {
- FW_CAcquireODStorageUnitView suView(ev, su);
- frame->InternalizeFrame(ev, suView);
- }
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
-
- return partInfo;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::ClonePartInfo
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::ClonePartInfo(Environment *ev,
- ODDraftKey key,
- ODInfoType partInfo,
- ODStorageUnitView* storageUnitView,
- ODFrame* scope)
- {
- FW_TRY
- {
- FW_CODPart::WritePartInfo(ev, partInfo, storageUnitView);
-
- // FW_ASSERT(partInfo != NULL);
- // FW_CFramePartInfo* framePartInfo = (FW_CFramePartInfo*)partInfo;
- // FW_CFrame* frame = framePartInfo->GetFrame();
- // frame->ClonePartInfo(ev, key, partInfo, storageUnitView, scope);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::Open
- //---------------------------------------------------------------------------------------
- // if odFrame is != of NULL we are opening the window from storage. If odFrame == NULL it
- // is the first time.
-
- ODID FW_CODPart::Open(Environment *ev,
- FW_CPart* part,
- ODFrame* odFrame)
- {
- ODID id = 0;
-
- FW_TRY
- {
- FW_CWindow* window = NULL;
-
- if (odFrame)
- {
- if (odFrame->IsRoot(ev))
- {
- window = new FW_CWindow(ev, part->GetODPart(ev), odFrame);
- }
- else
- {
- FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
- FW_ASSERT(frame != NULL);
- return frame->GetPresentation(ev)->ViewInWindow(ev, frame, NULL);
- }
- }
- else
- {
- window = part->NewDocumentWindow(ev);
- }
- FW_ASSERT(window);
-
- // ATTENTION: the order is very important
- window->Show(ev);
- window->Select(ev);
-
- id = window->GetID(ev);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
-
- return id;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::RequestEmbeddedFrame
- //---------------------------------------------------------------------------------------
-
- ODFrame* FW_CODPart::RequestEmbeddedFrame(Environment *ev,
- ODFrame* containingFrame,
- ODFrame* baseFrame,
- ODShape* frameShape,
- ODPart* embeddedPart,
- ODTypeToken viewType,
- ODTypeToken presentation,
- FW_Boolean isOverlaid)
- {
- ODFrame* frame = NULL;
-
- FW_TRY
- {
- FW_CEmbeddingFrame* embeddingFrame = FW_CEmbeddingFrame::ODtoFWEmbeddingFrame(ev, containingFrame);
- FW_ASSERT(embeddingFrame);
-
- frame = embeddingFrame->EmbeddedFrameRequested(ev, baseFrame, frameShape, embeddedPart, viewType, presentation, isOverlaid);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
-
- return frame;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::RemoveEmbeddedFrame
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::RemoveEmbeddedFrame(Environment *ev,
- ODFrame* embeddedFrame)
- {
- FW_TRY
- {
- FW_CAcquiredODFrame aqODContainingFrame = embeddedFrame->AcquireContainingFrame(ev);
- FW_ASSERT(aqODContainingFrame != NULL);
- FW_CEmbeddingFrame* containingFrame = FW_CEmbeddingFrame::ODtoFWEmbeddingFrame(ev, aqODContainingFrame);
- FW_ASSERT(containingFrame != NULL);
-
- // ----- Find the proxyFrame -----
- FW_CAcquiredProxyFrame aqProxyFrame = containingFrame->PrivAcquireProxyFrame(ev, embeddedFrame->GetID(ev));
- FW_ASSERT(((const void*)aqProxyFrame) != NULL);
-
- containingFrame->PrivRemoveEmbeddedFrame(ev, aqProxyFrame); // Note: removes the ODEmbeddedFrame from the draft
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::RequestFrameShape
- //---------------------------------------------------------------------------------------
-
- ODShape* FW_CODPart::RequestFrameShape(Environment *ev,
- ODFrame* embeddedFrame,
- ODShape* frameShape)
- {
- ODShape* newFrameShape = NULL;
-
- FW_TRY
- {
- FW_CAcquiredODFrame aqODContainingFrame = embeddedFrame->AcquireContainingFrame(ev);
-
- FW_CEmbeddingFrame* containingFrame = FW_CEmbeddingFrame::ODtoFWEmbeddingFrame(ev, aqODContainingFrame);
- FW_ASSERT(containingFrame);
-
- FW_CAcquiredProxyFrame aqProxyFrame = containingFrame->PrivAcquireProxyFrame(ev, embeddedFrame->GetID(ev));
- FW_ASSERT((const void*)aqProxyFrame != NULL);
-
- FW_MProxy *proxy = aqProxyFrame->GetProxy(ev);
- FW_ASSERT(proxy);
-
- newFrameShape = proxy->FrameShapeRequested(ev, embeddedFrame, frameShape);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
-
- return newFrameShape;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::UsedShapeChanged
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::UsedShapeChanged(Environment *ev,
- ODFrame* embeddedFrame)
- {
- FW_TRY
- {
- FW_CAcquiredODFrame aqContainingFrame = embeddedFrame->AcquireContainingFrame(ev);
- FW_CEmbeddingFrame *containingFrame = FW_CEmbeddingFrame::ODtoFWEmbeddingFrame(ev, aqContainingFrame);
- FW_ASSERT(containingFrame != NULL); // Should not be called if not an embedding frame or not one of our frame
-
- FW_CAcquiredProxyFrame aqProxyFrame = containingFrame->PrivAcquireProxyFrame(ev, embeddedFrame->GetID(ev));
-
- // If proxyFrame is null it means that the embedded part is changing its used shape before
- // I had time to finish building all my structures
- if ((const void*)aqProxyFrame != NULL)
- {
- FW_MProxy *proxy = aqProxyFrame->GetProxy(ev);
- FW_ASSERT(proxy);
-
- proxy->UsedShapeChanged(ev, containingFrame, embeddedFrame);
- }
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::AdjustBorderShape
- //---------------------------------------------------------------------------------------
-
- ODShape* FW_CODPart::AdjustBorderShape(Environment *ev,
- ODFacet* embeddedFacet,
- ODShape* shape)
- {
- FW_TRY
- {
- if (shape != NULL)
- {
- ODFrame* embeddedFrame = embeddedFacet->GetFrame(ev);
- FW_CAcquiredODFrame aqContainingFrame = embeddedFrame->AcquireContainingFrame(ev);
- FW_CEmbeddingFrame *containingFrame = FW_CEmbeddingFrame::ODtoFWEmbeddingFrame(ev, aqContainingFrame);
- FW_ASSERT(containingFrame != NULL); // Should not be called if not an embedding frame or not one of our frame
-
- FW_CAcquiredProxyFrame aqProxyFrame = containingFrame->PrivAcquireProxyFrame(ev, embeddedFrame->GetID(ev));
- FW_ASSERT((const void*)aqProxyFrame != NULL);
-
- FW_MProxy *proxy = aqProxyFrame->GetProxy(ev);
- FW_ASSERT(proxy);
-
- // ----- I need to acquire it before returning it -----
- shape->Acquire(ev);
-
- // ----- Put it in embeddingFrame content coordinate -----
- FW_CAcquiredODTransform aqExternalxForm = embeddedFacet->AcquireExternalTransform(ev, NULL);
- shape->Transform(ev, aqExternalxForm);
-
- // ----- Put it in embeddingFrame frame coordinate -----
- FW_CAcquiredODTransform aqInternalxform = containingFrame->AcquireInternalTransform(ev, NULL);
- shape->Transform(ev, aqInternalxform);
-
- // ----- Intersect with content shape -----
- FW_CAcquiredODShape aqContentShape = containingFrame->AcquireContentShape(ev);
- shape->Intersect(ev, aqContentShape);
-
- // ----- Call the proxy to intersect with content -----
- proxy->AdjustBorderShape(ev, containingFrame, embeddedFacet, shape);
-
- // ----- Put it back in embeddedFacet frame coordinate -----
- shape->InverseTransform(ev, aqInternalxform);
- shape->InverseTransform(ev, aqExternalxForm);
- }
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
-
- return shape;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::FacetAdded
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::FacetAdded(Environment *ev, ODFacet* facet)
- {
- FW_TRY
- {
- FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
- FW_ASSERT(frame != NULL);
-
- frame->FacetAdded(ev, facet);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::FacetRemoved
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::FacetRemoved(Environment *ev, ODFacet* facet)
- {
- FW_TRY
- {
- FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
- FW_ASSERT(frame != NULL);
-
- frame->FacetRemoved(ev, facet);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::CanvasChanged
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::CanvasChanged(Environment *ev, ODFacet* facet)
- {
- FW_TRY
- {
- FW_CGraphicDevice* graphicDevice = FW_CFacetPartInfo::GetFacetGraphicDevice(ev, facet);
- if(graphicDevice != NULL)
- graphicDevice->CanvasChanged(ev, facet->GetCanvas(ev));
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::GeometryChanged
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::GeometryChanged(Environment *ev,
- ODFacet* facet,
- FW_Boolean clipShapeChanged,
- FW_Boolean externalTransformChanged)
- {
- FW_TRY
- {
- FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
- FW_ASSERT(frame != NULL);
- frame->GeometryChanged(ev, facet, clipShapeChanged, externalTransformChanged);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::Draw
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::Draw(Environment *ev,
- ODFacet* facet,
- ODShape* invalidShape)
- {
- FW_TRY
- {
- FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
- FW_ASSERT(frame != NULL);
-
- frame->HandleDraw(ev, facet, invalidShape);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::CanvasUpdated
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::CanvasUpdated(Environment *ev, ODCanvas* canvas)
- {
- FW_TRY
- {
- FW_DEBUG_MESSAGE("CanvasUpdate: Not Yet Implemented");
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::HighlightChanged
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::HighlightChanged(Environment *ev, ODFacet* facet)
- {
- FW_TRY
- {
- FW_DEBUG_MESSAGE("HighlightChanged: Not Yet Implemented");
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::GetPrintResolution
- //---------------------------------------------------------------------------------------
-
- unsigned long FW_CODPart::GetPrintResolution(Environment *ev, ODFrame* odFrame)
- {
- ODULong resolution = 0;
-
- FW_TRY
- {
- FW_DEBUG_MESSAGE("GetPrintResolution: Not Yet Implemented");
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
-
- return resolution;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::CreateLink
- //---------------------------------------------------------------------------------------
-
- ODLinkSource* FW_CODPart::CreateLink(Environment *ev, FW_CPart* part, ODByteArray* data)
- {
- ODLinkSource* odLinkSource = NULL;
-
- FW_TRY
- {
- FW_CLinkManager* linkMgr = part->GetLinkManager(ev);
- FW_ASSERT(linkMgr);
- odLinkSource = linkMgr->CreateLink(ev, data);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
-
- return odLinkSource;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::LinkUpdated
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::LinkUpdated(Environment *ev,
- FW_CPart* part,
- ODLink* updatedLink,
- ODUpdateID updateID)
- {
- FW_TRY
- {
- // Notify all the subscribers that are destinations of the updated link
- FW_CPartSubscribeIterator iter(part);
- for (FW_CSubscribeLink* link = iter.First(); iter.IsNotComplete(); link = iter.Next())
- {
- if (updatedLink->IsEqualTo(ev, link->GetODLink(ev)) && (link->IsAutoUpdate(ev)))
- {
- link->LinkUpdated(ev, updateID);
- }
- }
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::RevealLink
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::RevealLink(Environment *ev, FW_CPart* part, ODLinkSource* linkSource)
- {
- FW_TRY
- {
- FW_CLinkManager* linkMgr = part->GetLinkManager(ev);
- FW_ASSERT(linkMgr);
- linkMgr->RevealLink(ev, linkSource);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::EmbeddedFrameUpdated
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::EmbeddedFrameUpdated(Environment *ev,
- FW_CPart* part,
- ODFrame* odFrame,
- ODUpdateID updateID)
- {
- FW_TRY
- {
- FW_CLinkManager* linkMgr = part->GetLinkManager(ev);
- if (linkMgr)
- linkMgr->DoUpdateLinks(ev, odFrame, updateID);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::EditInLinkAttempted
- //---------------------------------------------------------------------------------------
-
- FW_Boolean FW_CODPart::EditInLinkAttempted(Environment *ev, FW_CPart* part, ODFrame* odFrame)
- {
- FW_Boolean result = FALSE;
-
- FW_TRY
- {
- FW_CLinkManager* linkMgr = part->GetLinkManager(ev);
- FW_ASSERT(linkMgr);
- result = linkMgr->EditInLinkAttempted(ev, odFrame);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
-
- return result;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::LinkStatusChanged
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::LinkStatusChanged(Environment *ev, FW_CPart* part, ODFrame* odFrame)
- {
- FW_TRY
- {
- FW_CLinkManager* linkMgr = part->GetLinkManager(ev);
- if (linkMgr)
- linkMgr->DoChangeLinkStatus(ev, odFrame);
- else
- part->LinkStatusChanged(ev, odFrame);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::BeginRelinquishFocus
- //---------------------------------------------------------------------------------------
-
- FW_Boolean FW_CODPart::BeginRelinquishFocus(Environment *ev,
- FW_CPart* part,
- ODTypeToken focus,
- ODFrame* odOwnerFrame,
- ODFrame* proposedFrame)
- {
- FW_Boolean result = FALSE;
-
- FW_TRY
- {
- if (focus == FW_CPart::gModalFocusToken)
- {
- FW_CAcquiredODPart aqODPart = proposedFrame->AcquirePart(ev);
- return (aqODPart == part->GetODPart(ev));
- }
-
- FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odOwnerFrame);
- result = frame->BeginRelinquishFocus(ev, focus, proposedFrame);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
-
- return result;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::CommitRelinquishFocus
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::CommitRelinquishFocus(Environment *ev,
- ODTypeToken focus,
- ODFrame* odOwnerFrame,
- ODFrame* odProposedFrame)
- {
- FW_TRY
- {
- FW_CFrame* ownerFrame = FW_CFrame::ODtoFWFrame(ev, odOwnerFrame);
- FW_ASSERT(ownerFrame != NULL);
-
- ownerFrame->CommitRelinquishFocus(ev, focus, odProposedFrame);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::AbortRelinquishFocus
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::AbortRelinquishFocus(Environment *ev,
- ODTypeToken focus,
- ODFrame* ownerFrame,
- ODFrame* proposedFrame)
- {
- FW_TRY
- {
- FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, ownerFrame);
- FW_ASSERT(frame);
-
- frame->AbortRelinquishFocus(ev, focus, proposedFrame);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::FocusAcquired
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::FocusAcquired(Environment *ev,
- ODTypeToken focus,
- ODFrame* ownerFrame)
- {
- FW_TRY
- {
- FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, ownerFrame);
- FW_ASSERT(frame != NULL);
-
- frame->FocusStateChanged(ev, focus, TRUE, NULL);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::FocusLost
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::FocusLost(Environment *ev,
- ODTypeToken focus,
- ODFrame* ownerFrame)
- {
- FW_TRY
- {
- FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, ownerFrame);
- FW_ASSERT(frame != NULL);
-
- frame->FocusStateChanged(ev, focus, FALSE, NULL);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::CloneInto
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::CloneInto(Environment *ev,
- FW_CPart* part,
- ODDraftKey key,
- ODStorageUnit* toSU,
- ODFrame* scope)
- {
- FW_TRY
- {
- // Since this method may be called multiple times during one Cloning
- // transaction, the Part should check to see whether it really needs
- // to write out any data
- if (toSU->Exists(ev, kODPropContents, part->GetPartKind(ev), 0))
- return;
-
- part->AddProperties(ev, toSU);
-
- part->PrivCloneInto(ev, key, toSU, scope);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::ExternalizeKinds
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::ExternalizeKinds(Environment *ev, ODTypeList* kindset)
- {
- FW_TRY
- {
- FW_DEBUG_MESSAGE("ExternalizeKinds: Not Yet Implemented");
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::ChangeKind
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::ChangeKind(Environment *ev, ODType kind)
- {
- FW_TRY
- {
- FW_DEBUG_MESSAGE("ChangeKind: Not Yet Implemented");
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::HandleEvent
- //---------------------------------------------------------------------------------------
-
- FW_Boolean FW_CODPart::HandleEvent(Environment *ev,
- FW_CPart* part,
- ODEventData* event,
- ODFrame* odFrame,
- ODFacet* odFacet,
- ODEventInfo* eventInfo)
- {
- // Set the default value to TRUE so if Dispatch fails while trying to handle the
- // event I will still returns true. Dispatch will anyway returns FALSE if I don't
- // handle the event. It is unlikely that I will fail in not handling the event.
- ODBoolean handled = TRUE;
-
- FW_TRY
- {
- handled = part->GetEventDispatcher(ev)->Dispatch(ev, event, odFrame, odFacet, eventInfo);
-
- /*
- if (fDialogToClose)
- {
- // NOTICE: Closing a Window generates an event for that window. So to avoid
- // closing the window more than once, first save it in a local and set
- // fDialogToClose NULL, then call CloseWindow.
-
- FW_CWindow* dialogWindow = fDialogToClose;
- fDialogToClose = NULL;
-
- ODFrame* rootFrame = dialogWindow->GetODWindow(ev)->GetRootFrame(ev);
- part->GetSession(ev)->GetArbitrator(ev)->RelinquishFocus(ev, gModalFocusToken, rootFrame);
- part->FocusLost(ev, gModalFocusToken, rootFrame);
- part->EnableMenuBar(ev, TRUE);
-
- // [HLX] Don't know what to do
- FW_DEBUG_MESSAGE("CloseWindow doesn't extist anymore...");
- // dialogWindow->CloseWindow(ev);
- }
- */
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
-
- return handled;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::AdjustMenus
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::AdjustMenus(Environment *ev, FW_CPart* part, ODFrame* odFrame)
- {
- FW_TRY
- {
- FW_CFrame *frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
- FW_ASSERT(frame != NULL);
-
- // ----- Look if this frame has the menuFocus -----
- ODArbitrator* arbitrator = part->GetSession(ev)->GetArbitrator(ev);
- FW_CAcquiredODFrame aqFrameWithFocus = arbitrator->AcquireFocusOwner(ev, FW_CPart::gMenuFocusToken);
-
- FW_CMenuBar *menuBar = part->GetMenuBar(ev);
- menuBar->DisableAll(ev);
-
- FW_Boolean hasMenuFocus = (aqFrameWithFocus == odFrame);
- FW_Boolean rootFrame = frame->IsRoot(ev);
-
- FW_MEventHandler* target = frame->GetTarget(ev);
- FW_Boolean handled = FALSE;
- while (target != NULL && handled == FALSE)
- {
- handled = target->DispatchAdjustMenus(ev, menuBar, hasMenuFocus, rootFrame);
-
- target = target->GetNextEventHandler(ev);
- }
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::UndoAction
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::UndoAction(Environment *ev, FW_CPart* part, ODActionData* actionState)
- {
- FW_TRY
- {
- // actionState may contain a pointer to the command object
- if (actionState->_maximum == sizeof(FW_CCommand*))
- {
- FW_CCommand* command = *(FW_CCommand**)actionState->_buffer;
- command->UndoIt(ev);
- }
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::RedoAction
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::RedoAction(Environment *ev, ODActionData* actionState)
- {
- FW_TRY
- {
- // actionState may contain a pointer to the command object
- if (actionState->_maximum == sizeof(FW_CCommand*))
- {
- FW_CCommand* command = *(FW_CCommand**)actionState->_buffer;
- command->RedoIt(ev);
- }
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::DisposeActionState
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::DisposeActionState(Environment *ev,
- ODActionData* actionState,
- ODDoneState doneState)
- {
- FW_TRY
- {
- // actionState may contain a pointer to the command object
- if (actionState->_maximum == sizeof(FW_CCommand*))
- {
- FW_CCommand* command = *(FW_CCommand**)actionState->_buffer;
- if (doneState == kODUndone)
- command->CommitUndone(ev);
- else // doneState is kODDone or kODRedone
- command->CommitDone(ev);
- delete command;
- }
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::WriteActionState
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::WriteActionState(Environment *ev,
- ODActionData* actionState,
- ODStorageUnitView* storageUnitView)
- {
- FW_TRY
- {
- FW_DEBUG_MESSAGE("WriteActionState: Not Yet Implemented");
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::ReadActionState
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::ReadActionState(Environment *ev, ODStorageUnitView* storageUnitView, ODActionData* actionData)
- {
- FW_TRY
- {
- FW_DEBUG_MESSAGE("ReadActionState: Not Yet Implemented");
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::InitPart
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::InitPart(Environment *ev,
- FW_CPart* part,
- ODStorageUnit* storageUnit)
- {
- FW_TRY
- {
- // ----- Common initialization -----
- part->Initialize(ev);
-
- // ----- Add Needed Properties -----
- part->AddProperties(ev, storageUnit);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::InitPartFromStorage
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::InitPartFromStorage(Environment *ev,
- FW_CPart* part,
- ODStorageUnit* storageUnit)
- {
- FW_TRY
- {
- // ----- Common initialization -----
- part->Initialize(ev);
-
- // ----- Read proxy frames (if any) -----
- part->PrivInternalizeProxyFrames(ev, storageUnit, NULL);
-
- // ----- Read Part Specific data -----
- part->InternalizeContent(ev, storageUnit, NULL);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::Externalize
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::Externalize(Environment *ev, FW_CPart* part)
- {
- FW_TRY
- {
- ODStorageUnit* partStorageUnit = part->GetStorageUnit(ev);
-
- if (partStorageUnit->GetDraft(ev)->GetPermissions(ev) >= kODDPSharedWrite)
- {
- // ----- Write proxy frames (if any) -----
- part->PrivExternalizeProxyFrames(ev, partStorageUnit, NULL);
-
- // ----- Create the necessary properties if necessary
- part->AddProperties(ev, partStorageUnit);
-
- // ----- Externalize part specific data -----
- part->ExternalizeContent(ev, partStorageUnit, NULL);
- }
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::Release
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::Release(Environment *ev, FW_CPart* part)
- {
- FW_TRY
- {
- part->Release(ev);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::ReleaseAll
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::ReleaseAll(Environment *ev, FW_CPart* part)
- {
- FW_TRY
- {
- part->ReleaseAll(ev);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::Purge
- //---------------------------------------------------------------------------------------
-
- ODSize FW_CODPart::Purge(Environment *ev, FW_CPart* part, ODSize size)
- {
- ODSize bytesFreed = 0;
-
- FW_TRY
- {
- bytesFreed = part->Purge(ev, size);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetODException(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
-
- return bytesFreed;
- }
-