home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 56.8 KB | 2,203 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWODPart.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 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 FWKIND_H
- #include "FWKind.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 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
-
- #ifndef FWLNKITE_H
- #include "FWLnkIte.h"
- #endif
-
- #ifndef FWINTER_H
- #include "FWInter.h"
- #endif
-
- #ifndef FWSESION_H
- #include "FWSesion.h"
- #endif
-
- #ifndef FWSUUTIL_H
- #include "FWSUUtil.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
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwpart3
- #endif
-
- const char* kUnknownExceptionString = "Unknown exception!";
-
- //========================================================================================
- // 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);
- part->GetDataInterchange(ev)->PrivHandleFulfillPromise(ev, promise, promiseSUView);
-
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
- FW_ASSERT(frame);
- FW_MDroppableFrame* droppable = frame->GetDroppable(ev);
- if (droppable)
- result = droppable->DragEnter(ev, facet, dragInfo, where);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
- FW_ASSERT(frame);
- FW_MDroppableFrame* droppable = frame->GetDroppable(ev);
- if (droppable)
- result = droppable->DragWithin(ev, facet, dragInfo, where);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- FW_CATCH_END
-
- return result;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::DragLeave
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::DragLeave(Environment *ev,
- ODFacet* facet,
- const FW_CPoint& where)
- {
- FW_TRY
- {
- FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
- FW_ASSERT(frame);
- FW_MDroppableFrame* droppable = frame->GetDroppable(ev);
- if (droppable)
- droppable->DragLeave(ev, facet, where);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
- FW_ASSERT(frame);
- FW_MDroppableFrame* droppable = frame->GetDroppable(ev);
- if (droppable)
- result = droppable->Drop(ev, dropInfo, facet, where);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- FW_CATCH_END
-
- return result;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::DropCompleted
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::DropCompleted(Environment *ev,
- ODPart* destPart,
- ODDropResult dropResult)
- {
- FW_UNUSED(destPart);
- FW_UNUSED(dropResult);
- FW_TRY
- {
- FW_DEBUG_MESSAGE("DropCompleted: Not Yet Implemented");
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::ContainingPartPropertiesUpdated
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::ContainingPartPropertiesUpdated(Environment *ev,
- ODFrame* odFrame,
- ODStorageUnit* propertyUnit)
- {
- FW_TRY
- {
- FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
- FW_ASSERT(frame);
- if (frame->GetAdoptsContainerProperties(ev))
- frame->AdoptContainingPartProperties(ev, propertyUnit);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::AcquireContainingPartProperties
- //---------------------------------------------------------------------------------------
-
- ODStorageUnit* FW_CODPart::AcquireContainingPartProperties(Environment *ev,
- FW_CEmbeddingPart* embeddingPart,
- ODFrame* embeddedFrame)
- {
- ODStorageUnit* su = NULL;
-
- FW_TRY
- {
- su = embeddingPart->AcquireContainingPartProperties(ev, embeddedFrame);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- FW_CATCH_END
-
- return su;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::RevealFrame
- //---------------------------------------------------------------------------------------
-
- FW_Boolean FW_CODPart::RevealFrame(Environment *ev,
- FW_CEmbeddingPart* part,
- 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);
-
- FW_MProxy* proxy = part->GetProxy(ev, embeddedFrame);
- FW_ASSERT(proxy);
- result = proxy->Reveal(ev, embeddingFrame, embeddedFrame, revealShape);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- FW_CATCH_END
-
- return result;
- }
-
- //---------------------------------------------------------------------------------------
- // 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_PrivSetShapeTransformMaker(ev, odFrame);
-
- // ----- Look for the presentation -----
- FW_CPresentation* newPresentation = part->PrivGetPresentation(ev, odFrame);
-
- // [HLX] I used SetPresentation and not ChangePresentation because the frame is
- // not yet part of my list of display frame
- odFrame->SetPresentation(ev, newPresentation->GetPresentationType(ev));
-
- // ----- Create the frame -----
- FW_CFrame* frame = newPresentation->PrivNewFrame(ev, odFrame, FALSE);
- if (frame == NULL)
- frame = part->NewFrame(ev, odFrame, newPresentation, FALSE);
-
- // ----- Create the part Info -----
- // odFrame->SetPartInfo(ev, (ODInfoType)frame);
-
- // ----- Notify the frame -----
- frame->FrameAdded(ev, odFrame, FALSE); // brand new frame
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::DisplayFrameRemoved
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::DisplayFrameRemoved(Environment *ev,
- FW_CPart* part,
- ODFrame* odFrame,
- FW_Boolean toStorage)
- {
- FW_TRY
- {
- part->PrivDisplayFrameRemoved(ev, odFrame, toStorage);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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, odFrame, TRUE); // From storage
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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_CFrame*) partInfo;
- FW_ASSERT(frame);
-
- ODStorageUnit* su = storageUnitView->GetStorageUnit(ev);
-
- FW_CAcquireODPropertyName propName(ev, storageUnitView);
- FW_SUForceFocus(ev, su, propName, frame->GetPart(ev)->GetPartKind(ev)->GetType(ev));
-
- FW_CAcquireODStorageUnitView suView(ev, su);
- frame->PrivExternalizeFrame(ev, suView); // framework info
- frame->ExternalizeFrame(ev, suView); // user info
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::ReadPartInfo
- //---------------------------------------------------------------------------------------
-
- ODInfoType FW_CODPart::ReadPartInfo(Environment *ev,
- FW_CPart* part,
- ODFrame* odFrame,
- ODStorageUnitView* storageUnitView)
- {
- FW_CFrame* frame = NULL;
-
- FW_TRY
- {
- // ----- Create a global shape and transform if neccessary -----
- FW_PrivSetShapeTransformMaker(ev, odFrame);
-
- // ----- Determine the presentation -----
- FW_CPresentation* presentation = part->PrivGetPresentation(ev, odFrame);
- // [HLX] I used SetPresentation and not ChangePresentation because the frame is
- // not yet part of my list of display frame
- odFrame->SetPresentation(ev, presentation->GetPresentationType(ev));
-
- // ----- Create the FW_CFrame object -----
- frame = presentation->PrivNewFrame(ev, odFrame, TRUE);
- if (frame == NULL)
- frame = part->NewFrame(ev, odFrame, presentation, TRUE);
-
- // ----- Internalize the frame -----
- ODStorageUnit* su = storageUnitView->GetStorageUnit(ev);
-
- FW_CAcquireODPropertyName propName(ev, storageUnitView);
-
- if (FW_SUExistsThenFocus(ev, su, propName, frame->GetPart(ev)->GetPartKind(ev)->GetType(ev)) )
- {
- FW_CAcquireODStorageUnitView suView(ev, su);
- frame->PrivInternalizeFrame(ev, suView); // framework info
- frame->InternalizeFrame(ev, suView); // user info
- }
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- FW_CATCH_END
-
- return (ODInfoType)frame;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::ClonePartInfo
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::ClonePartInfo(Environment *ev,
- ODDraftKey key,
- ODInfoType partInfo,
- ODStorageUnitView* storageUnitView,
- ODFrame* scope)
- {
- FW_TRY
- {
- FW_ASSERT(partInfo != NULL);
-
- FW_CFrame* frame = (FW_CFrame*) partInfo;
- FW_ASSERT(frame);
-
- ODStorageUnit* su = storageUnitView->GetStorageUnit(ev);
-
- FW_CAcquireODPropertyName propName(ev, storageUnitView);
- FW_SUForceFocus(ev, su, propName, frame->GetPart(ev)->GetPartKind(ev)->GetType(ev));
-
- FW_CAcquireODStorageUnitView suView(ev, su);
- frame->PrivExternalizeFrame(ev, suView); // framework info
-
- frame->ClonePartInfo(ev, key, partInfo, suView, scope); // user info
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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, odFrame);
- }
- else
- {
- FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
- FW_ASSERT(frame != NULL);
- return part->OpenPartWindow(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);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- FW_CATCH_END
-
- return id;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::RequestEmbeddedFrame
- //---------------------------------------------------------------------------------------
-
- ODFrame* FW_CODPart::RequestEmbeddedFrame(Environment *ev,
- FW_CEmbeddingPart* part,
- ODFrame* containingFrame,
- ODFrame* baseFrame,
- ODShape* suggestedFrameShape,
- 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);
-
- FW_MProxy* baseProxy = part->GetProxy(ev, baseFrame);
- FW_ASSERT(baseProxy);
-
- FW_ASSERT(baseFrame->GetFrameGroup(ev) == baseProxy->GetFrameGroup(ev));
- ODID frameGroup = baseProxy->GetFrameGroup(ev);
- FW_ASSERT(baseFrame->GetFrameGroup(ev) == frameGroup);
-
- FW_Boolean hasAGroup = (frameGroup != 0);
-
- if (!hasAGroup)
- {
- FW_ASSERT(baseProxy->GetSequenceNumber(ev) == 0);
- frameGroup = part->PrivGetNextFrameGroup(ev);
- }
-
- // ----- Call the frame -----
- FW_MProxy* proxy = embeddingFrame->EmbeddedFrameRequested(ev,
- baseProxy,
- baseFrame,
- suggestedFrameShape,
- embeddedPart,
- viewType,
- presentation,
- frameGroup,
- isOverlaid,
- baseFrame->IsSubframe(ev));
- if (proxy == NULL)
- return NULL; // RequestEmbeddedFrame not supported
-
- ODID newSequenceNumber = 0;
- // ----- Set the group and sequence -----
- if (!hasAGroup)
- {
- baseProxy->PrivSetFrameGroup(ev, frameGroup);
- baseProxy->ChangeSequenceNumber(ev, 1);
- newSequenceNumber = 1;
- }
- else
- {
- // ----- Look for the highest sequence number ------
- newSequenceNumber = 0;
- FW_CPartProxyIterator ite(part);
- for (FW_MProxy* aProxy = ite.First(); ite.IsNotComplete(); aProxy = ite.Next())
- {
- if (aProxy->GetFrameGroup(ev) == frameGroup)
- {
- ODID sequenceNumber = aProxy->GetSequenceNumber(ev);
- if (sequenceNumber > newSequenceNumber)
- newSequenceNumber = sequenceNumber;
- }
- }
- }
-
- newSequenceNumber++;
- proxy->PrivSetFrameGroup(ev, frameGroup);
- proxy->ChangeSequenceNumber(ev, newSequenceNumber);
-
- frame = proxy->AcquireEmbeddedFrame(ev, embeddingFrame);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- FW_CATCH_END
-
- return frame;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::RemoveEmbeddedFrame
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::RemoveEmbeddedFrame(Environment *ev,
- FW_CEmbeddingPart* part,
- ODFrame* embeddedFrame)
- {
- FW_TRY
- {
- FW_CAcquiredODFrame aqODContainingFrame = embeddedFrame->AcquireContainingFrame(ev);
- FW_CEmbeddingFrame* containingFrame = FW_CEmbeddingFrame::ODtoFWEmbeddingFrame(ev, aqODContainingFrame);
- FW_ASSERT(containingFrame != NULL);
-
- // ----- Find the proxy -----
- FW_MProxy* proxy = containingFrame->GetProxy(ev, embeddedFrame);
- FW_ASSERT(proxy != NULL);
-
- proxy->RemoveEmbeddedFrames(ev); // remove all embedded frames
-
- // ----- Save frame group and sequence number -----
- ODID sequenceNumber = proxy->GetSequenceNumber(ev);
- ODID frameGroup = proxy->GetFrameGroup(ev);
-
- // ----- Ask the part to delete it -----
- part->EmbeddedFrameRemoved(ev, proxy);
-
- // ------ Deal with frame group and sequence number
- FW_MProxy* lonelyProxy = NULL;
- unsigned short count = 0;
- FW_CPartProxyIterator ite(part);
- for (FW_MProxy* aProxy = ite.First(); ite.IsNotComplete(); aProxy = ite.Next())
- {
- if (aProxy->GetFrameGroup(ev) == frameGroup)
- {
- count++;
- lonelyProxy = aProxy;
- ODID aSequenceNumber = aProxy->GetSequenceNumber(ev);
- if (aSequenceNumber > sequenceNumber)
- aProxy->ChangeSequenceNumber(ev, aSequenceNumber-1);
- }
- }
-
- // ----- In the case where I am the only proxy of this group change it back to 0 -----
- if (count == 1)
- {
- lonelyProxy->PrivSetFrameGroup(ev, 0);
- lonelyProxy->ChangeSequenceNumber(ev, 0);
- }
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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_MProxy* proxy = containingFrame->GetProxy(ev, embeddedFrame);
- FW_ASSERT(proxy);
-
- newFrameShape = proxy->FrameShapeRequested(ev, containingFrame, embeddedFrame, frameShape);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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_MProxy* proxy = containingFrame->GetProxy(ev, embeddedFrame);
-
- // If proxy is null it means that the embedded part is changing its used shape before
- // I had time to finish building all my structures
- if (proxy != NULL)
- proxy->UsedShapeChanged(ev, containingFrame, embeddedFrame);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::AdjustBorderShape
- //---------------------------------------------------------------------------------------
-
- ODShape* FW_CODPart::AdjustBorderShape(Environment *ev,
- ODFacet* embeddedFacet,
- ODShape* shape)
- {
- FW_TRY
- {
- 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_MProxy* proxy = containingFrame->GetProxy(ev, embeddedFrame);
- FW_ASSERT(proxy);
- FW_CProxyFrame* proxyFrame = proxy->GetProxyFrame(ev, embeddedFrame->GetID(ev));
-
- FW_CAcquiredODTransform tempx;
-
- if (shape != NULL)
- {
- // ----- I need to acquire it before returning it -----
- shape->Acquire(ev);
-
- // ----- Get transform to go from content to embedding content coordinates -----
- tempx = FW_CopyAndRelease(ev, containingFrame->AcquireInternalTransform(ev, NULL));
- FW_CAcquiredODTransform aqExternalxForm = embeddedFacet->AcquireExternalTransform(ev, NULL);
- tempx->PostCompose(ev, aqExternalxForm);
-
- shape->Transform(ev, tempx);
-
- // ----- 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 -----
- if (shape != NULL)
- shape->InverseTransform(ev, tempx);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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);
-
- // ----- Set the facet's part info -----
- FW_PrivCreateFacetPartInfo(ev, facet);
-
- // ----- Notify the frame -----
- frame->PrivFacetAdded(ev, facet);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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);
-
- // ----- Notify the frame -----
- frame->PrivFacetRemoved(ev, facet);
-
- // ----- Delete the facet part info -----
- FW_PrivDeleteFacetPartInfo(ev, facet);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::CanvasChanged
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::CanvasChanged(Environment *ev, ODFacet* facet)
- {
- FW_TRY
- {
- FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
- FW_ASSERT(frame != NULL);
- frame->CanvasChanged(ev, facet);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::CanvasUpdated
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::CanvasUpdated(Environment *ev, ODCanvas* canvas)
- {
- FW_UNUSED(canvas);
- FW_TRY
- {
- FW_DEBUG_MESSAGE("CanvasUpdate: Not Yet Implemented");
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::HighlightChanged
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::HighlightChanged(Environment *ev, ODFacet* facet)
- {
- FW_TRY
- {
- ODHighlight to = facet->GetHighlight(ev);
- ODHighlight from = FW_PrivGetFacetHighlight(ev, facet); // return the previous facet Highlight
- FW_PrivSetFacetHighlight(ev, facet, to); // set previuous hilite
-
- FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
- frame->HighlightChanged(ev, facet, from, to);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::GetPrintResolution
- //---------------------------------------------------------------------------------------
-
- unsigned long FW_CODPart::GetPrintResolution(Environment *ev, ODFrame* odFrame)
- {
- FW_UNUSED(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);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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 links that are destinations of the updated link
- FW_CPartLinkDestIterator iter(part);
- for (FW_CLinkDestination* link = iter.First(); iter.IsNotComplete(); link = iter.Next())
- {
- if (updatedLink->IsEqualTo(ev, link->GetODLink(ev)) && (link->IsRegistered(ev)))
- {
- link->LinkUpdated(ev, updateID);
- }
- }
-
- // $$$$$ [MH] It would be good to avoid each link calling ContentUpdated on the frame, and do it here
- // but we don't know here what frame(s) to call it on. The solution would be to collect a
- // list of unique frames or presentations from the links that are updated, then iterate
- // that list calling ContentUpdated once on each.
-
- // we must dirty the part!
- part->Changed(ev);
-
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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::fgModalFocusToken)
- {
- 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);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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->FocusStateChanged(ev, focus, FALSE, odProposedFrame);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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)->GetType(ev), 0))
- return;
-
- // Add Content Property if not exist
- if (!toSU->Exists(ev, kODPropContents, NULL, 0))
- toSU->AddProperty(ev, kODPropContents);
-
- part->CloneInto(ev, key, toSU, scope);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::ExternalizeKinds
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::ExternalizeKinds(Environment *ev, FW_CPart* part, ODTypeList* kindset)
- {
- FW_TRY
- {
- part->ExternalizeKinds(ev, kindset);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::ChangeKind
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::ChangeKind(Environment *ev, FW_CPart* part, ODType kind)
- {
- FW_TRY
- {
- part->ChangeKind(ev, kind);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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.
- FW_Boolean handled = TRUE;
-
- FW_TRY
- {
- FW_CFrame* fwFrame = NULL;
- if (odFrame != NULL) {
- fwFrame = FW_CFrame::ODtoFWFrame(ev, odFrame);
-
- // mlanett: Cyberdog 1.0 is sending us events with bogus ODFrames
- #ifdef FW_BUILD_MAC
- if (event->what == kODEvtMenu && fwFrame == NULL)
- #endif
- #ifdef FW_BUILD_WIN
- if (event->message == kODEvtMenu && fwFrame == NULL)
- #endif
- return FW_kNotHandled;
-
- FW_ASSERT(fwFrame);
- }
-
- handled = (part->GetEventDispatcher(ev)->Dispatch(ev, event, fwFrame, odFacet, eventInfo) == FW_kHandled);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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 = FW_CSession::GetArbitrator(ev);
- FW_CAcquiredODFrame aqFrameWithFocus = arbitrator->AcquireFocusOwner(ev, FW_CPart::fgMenuFocusToken);
-
- 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->PrivDispatchAdjustMenus(ev, menuBar, hasMenuFocus, rootFrame);
-
- target = target->GetNextEventHandler(ev);
- }
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::UndoAction
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::UndoAction(Environment *ev, FW_CPart* part, ODActionData* actionState)
- {
- FW_UNUSED(part);
- FW_TRY
- {
- // actionState may contain a pointer to the command object
- if (actionState->_maximum == sizeof(FW_CCommand*))
- {
- FW_CCommand* command = *(FW_CCommand**)actionState->_buffer;
- FW_ASSERT(command);
- if (command) // [EXERPART] Should not happen but the exerPart calls me with nothing to undo
- command->HandleUndo(ev);
- }
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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;
- FW_ASSERT(command);
- if (command) // [EXERPART] Should not happen but the exerPart calls me with nothing to undo
- command->HandleRedo(ev);
- }
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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;
- FW_ASSERT(command);
- if (command == NULL) // [EXERPART] Should not happen but the exerPart calls me with nothing to undo
- return;
-
- 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);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::WriteActionState
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::WriteActionState(Environment *ev,
- ODActionData* actionState,
- ODStorageUnitView* storageUnitView)
- {
- FW_UNUSED(actionState);
- FW_UNUSED(storageUnitView);
- FW_TRY
- {
- FW_DEBUG_MESSAGE("WriteActionState: Not Yet Implemented");
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::ReadActionState
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::ReadActionState(Environment *ev, ODStorageUnitView* storageUnitView, ODActionData* actionData)
- {
- FW_UNUSED(storageUnitView);
- FW_UNUSED(actionData);
- FW_TRY
- {
- FW_DEBUG_MESSAGE("ReadActionState: Not Yet Implemented");
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::InitPart
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::InitPart(Environment *ev,
- FW_CPart* part,
- ODStorageUnit* storageUnit)
- {
- FW_UNUSED(storageUnit);
-
- FW_TRY
- {
- // ----- Common initialization -----
- part->Initialize(ev, storageUnit, FALSE);
-
- part->PrivSetDirty(ev, TRUE);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::InitPartFromStorage
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::InitPartFromStorage(Environment *ev,
- FW_CPart* part,
- ODStorageUnit* storageUnit)
- {
- FW_TRY
- {
- // ----- Common initialization -----
- part->Initialize(ev, storageUnit, TRUE);
-
- // ----- Determine the preferred kind -----
- part->PrivDeterminePreferredKind(ev, storageUnit);
-
- // ----- Read Part Specific data -----
- part->InternalizeContent(ev, storageUnit, NULL);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- FW_CATCH_END
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CODPart::Externalize
- //---------------------------------------------------------------------------------------
-
- void FW_CODPart::Externalize(Environment *ev, FW_CPart* part)
- {
- FW_TRY
- {
- part->ExternalizeContent(ev, part->GetStorageUnit(ev), NULL);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- FW_SetException(ev, exception);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- 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);
- }
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE(kUnknownExceptionString);
- FW_SetEvError(ev, kODErrUndefined);
- }
- FW_CATCH_END
-
- return bytesFreed;
- }
-