home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc / OpenDoc Development / Debugging Support / OpenDoc™ Source Code / Layout / Frame.cpp < prev    next >
Encoding:
Text File  |  1996-08-28  |  81.6 KB  |  2,776 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        Frame.cpp
  3.  
  4.     Contains:    Implementation of ODFrame
  5.  
  6.     Owned by:    Joshua Susser
  7.  
  8.     Copyright:    © 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.     
  12.          <7>     6/26/96    eeh        1360132: make limbo focus searching simpler
  13.                                     and more exception-safe.
  14.          <6>     6/25/96    eeh        1360132: force frames to release foci
  15.                                     before being put into limbo.
  16.          <5>     5/30/96    CC        1329275: InitFrameFromStorage: Force link
  17.                                     status to kODNotInLink if root frame of
  18.                                     draft.
  19.          <3>     3/26/96    CC        1329842: kODPropLinkStatus is not a
  20.                                     required property.
  21.          <2>     3/15/96    CC        1329241: InitFrameNonPersistent: Initialize
  22.                                     fLinkStatus.
  23.                                     1329268: ChangeLinkStatus: Look for source
  24.                                     frame if no containing frame.
  25.         <74>     11/2/95    RR        #1298614 Check for NULL su in PrepareToSwap
  26.         <73>     11/1/95    JBS        1289931 GM: move release calls from
  27.                                     somUninit to Release all, use SafeRelease
  28.         <72>    10/24/95    TÇ        Removed two errant semicolons introduced
  29.                                     with fix of #1288922 don't force
  30.                                     DrawActiveBorder, wait for Window::Update
  31.         <71>    10/24/95    jpa        1293441: Ignore exceptions from
  32.                                     DisplayFrame{Closed,Removed}.
  33.         <70>    10/18/95    JBS        1288922 don't force DrawActiveBorder, wait
  34.                                     for Window::Update
  35.         <69>    10/17/95    jpa        1292659: Fixed leaks if parts throw
  36.         <68>     10/9/95    JBS        1290561 GM: ChangeLinkStatus dirties draft
  37.                                     unnecessarily; 1289931 GM: release objects
  38.                                     in ReleaseAll, not somUninit
  39.         <67>     10/8/95    TJ        Fixes Recomended by Refball
  40.         <66>     9/21/95    JBS        1284283 window refcounting in PrepareToSwap
  41.         <65>     9/13/95    DM        1277216 GM:API return no ODPoints nor
  42.                                     ODPolygons
  43.         <64>     9/12/95    JBS        1283657 part->FacedAdded called twice in
  44.                                     Frame::FacetAdded
  45.         <63>      9/8/95    JBS        1281770 Frame::ChangeLinkStatus short
  46.                                     circuits
  47.         <62>      9/8/95    TÇ        1281096 FB2:Many constants in ODTypesB
  48.                                     without kOD prefix!
  49.         <61>      9/6/95    VL        1270294: Added and use
  50.                                     kFrameIsInRemoveFrame to avoid recursive
  51.                                     removal. Removed CHECKVALID in GetID.
  52.         <60>     8/31/95    JBS        1278337 error code cleanup
  53.         <59>     8/25/95    JBS        1263078 FB: fix part editor swapping;
  54.                                     1278052 FB: add InLimbo flag
  55.         <58>     8/17/95    CC        1273056: ContentUpdated acquires wrong
  56.                                     part.
  57.         <57>     8/16/95    NP        1274946: ErrorDef.idl problems. Add include
  58.                                     file.
  59.         <56>     8/12/95    TÇ        1276807 Opt./Bug: use StdTypIO routines for
  60.                                     portable streaming & smaller footprint
  61.         <55>      8/7/95    JBS        1262428 ASSERT in AcquirePart if part NULL;
  62.                                     1265721 don't purge facets' if invalid
  63.         <54>      8/3/95    RR        #1257260: Collapse B classes. Remove
  64.                                     somInit methods. Don't call IsInitialized
  65.                                     or SubclassResponsibility
  66.         <53>     7/27/95    JBS        1231232 SetContainingFrame - remove part
  67.                                     notification
  68.                                     1264303 AcquireContainingFrame - don't lazy
  69.                                     internalize if IsRoot
  70.         <52>     7/27/95    DM        #1270320: Mem leaks: must cast when
  71.                                     assigning from temp ref to another in
  72.                                     EditInLink and ContentUpdated
  73.         <51>     7/26/95    DM        #1270320: Memory leak fixes. delete
  74.                                     typeString returns from GetType in
  75.                                     Externalize and CloneInto
  76.         <50>      7/3/95    RR        1242642 BB: refcounting. SetContainingFrame
  77.                                     needed to Acquire before calling
  78.                                     window->CloseAndRemove.
  79.         <49>     6/29/95    DM        1242642 BB: refcounting: acquire member
  80.                                     vars (not locals) when possible, add
  81.                                     "Acquire" to names of local "ReadIfAny"
  82.                                     functions, release biasTransform    in
  83.                                     InitFrameFromStorage.
  84.         <48>     6/28/95    RR        1242642 BB Mostly ref counting. Release
  85.                                     window in CLose and Remove
  86.         <47>     6/23/95    JBS        1261323 add isSubframe param to InitFrame;
  87.                                     1238245 (done) InitFrame throws error on
  88.                                     non-subframe recursive embed
  89.         <46>     6/23/95    JBS        1251627 fix refcounting throughout file
  90.         <45>     6/21/95    JBS        1238245: (not done) InitFrame check for
  91.                                     recursive embedding; 1243657 SetWindow
  92.                                     throws if not root frame
  93.         <44>     6/20/95    JBS        1257315 change AcquireWindow to GetWindow
  94.         <43>     5/31/95    JBS        1250140 fixed refcount bug in AcquirePart
  95.         <42>     5/26/95    RR        #1251403: Multithreading naming support
  96.         <41>     5/17/95    RR        #1250135/1250137/1250143 Getters increment
  97.                                     refcount
  98.         <40>     5/17/95    JBS        1245283 Undoable frame deletion - close
  99.                                     part windows in SetContainingFrame; 1242496
  100.                                     change SOM_CATCH to SOM_TRY; 1250140 bump
  101.                                     refcount in AcquireContainingFrame, AcquirePart,
  102.                                     AcquireWindow
  103.         <39>     5/15/95    JBS        1245156 implement Purge
  104.         <38>      5/5/95    TJ        Put "VOID" into CHECKVALID since #$&* SCpp
  105.                                     won't take empty macro arguments.
  106.         <37>      5/4/95    JBS        1243651 added CHECKVALID to most methods,
  107.                                     and fixed ternalization to respect
  108.                                     fValidState
  109.         <36>     4/27/95    JBS        1209506 $5 comments eliminated
  110.         <35>     4/25/95    JBS        1242496 use SOM_TRY, etc. for exception
  111.                                     handling; 1241983 Externalize assumes
  112.                                     containing frame is persistent; 1183059
  113.                                     throw kODErrIllegalNullStorageUnitInput if
  114.                                     SU is nil; 1242527  AcquireContainingFrame
  115.                                     should not write SU; 1242546  Frame should
  116.                                     compute IsRoot from contFrame
  117.         <34>     4/14/95    TÇ        #1235279 BB: InfoUtil & StdTypIO functions
  118.                                     should take Environment* and SU* when
  119.                                     possible.  Also Clone a little better to
  120.                                     help out Save A Copy.
  121.         <33>     4/13/95    JBS        1211972 don't mark draft dirty if frame is
  122.                                     non-persistent;1233726 Frame::CloneInto
  123.                                     should call part->ClonePartInfo;1238250
  124.                                     Frame PartInfo should have multiple
  125.                                     values;1237963 don't validate
  126.                                     ContainingFrame property on init
  127.         <32>      4/3/95    CC        1234631: ChangeLinkStatus: Set _fLinkStatus
  128.                                     BEFORE notifying the part!
  129.         <31>     3/28/95    JBS        1229656 implemented EditInLink
  130.         <30>     3/28/95    JBS        1229656 add EditInLink()
  131.         <29>      3/8/95    JBS        1165158 AdjustBorderShape implementation
  132.         <28>     2/24/95    CC        Commented out redefinition of
  133.                                     ODFrameMethodDebug.
  134.         <27>     2/15/95    JBS        1198600 code review cleanup; 1195854 added
  135.                                     SetDirty, dirty/write properties
  136.                                     individually; 1189547 don't allow viewType
  137.                                     and pres to be NULL; 1183059 throw if NULL
  138.                                     su in InitFrameFromStorage; 1206295 don't
  139.                                     externalize UsedShape
  140.         <26>     1/25/95    CC        1206295: (for JBS) Temporarily add
  141.         <25>     1/20/95    JBS        1195017, 1205669: part API changes
  142.         <24>     11/1/94    CC        1196908 - SetContainingFrame: remove all
  143.                                     facets displaying this frame and call
  144.                                     ODPart::FacetRemoved();
  145.                                     FacetRemoved(): Guard against facets not in
  146.                                     the collection of display facets.
  147.                                     somUninit(): Fixed memory leak by deleting
  148.                                     fFacets collection.
  149.         <23>     9/29/94    JBS        1188214: more coord bias impl
  150.         <22>     9/26/94    JBS        1186332, 1188981 - nonpersistence; 1183568
  151.                                     - keep fIsDirty flag
  152.         <21>     9/22/94    JBS        1188214: coordinate bias implementation
  153.         <20>      9/7/94    CC        #1185056 - Use StdTypIO methods to
  154.                                     internalize/externalize fLinkStatus field.
  155.         <19>      9/6/94    CC        1153777- Implement GetLinkStatus(),
  156.                                     ChangeLinkStatus(), and ContentUpdated(),
  157.                                     and maintain the persistent fLinkStatus
  158.                                     field.
  159.         <18>     8/31/94    TÇ        #1183129, #1183116, #1183119, #1183111:
  160.                                     Lots of ErrorCode cleanup.
  161.         <17>     8/31/94    VL        1183174: Fixed CloneInto to avoid multiple
  162.                                     cloning. Removed CloneTo which was
  163.                                     commented out in <14>. Removed CMDraft.xh
  164.                                     because we are not depending on it with the
  165.                                     new cloning mechanism.
  166.         <16>     8/30/94    TÇ        #1183567 StdTypIO routine implementation.
  167.                                     Added Get/SetProp for time_t, ODPoint,
  168.                                     ODRect, Strong/WeakStorageUnitRefs.  Use
  169.                                     Get/SetProp routines for
  170.                                     Strong/WeakStorageUnitRefs.
  171.         <15>     8/29/94    TÇ        #1183567 StdTypIO routine implementation &
  172.                                     fixup
  173.         <14>     8/26/94    VL        1183174: Implemented CloneInto & removed
  174.                                     CloneTo.
  175.         <13>     8/19/94    TÇ        #1180922 Need to Stop using obsolete types
  176.                                     (kOD ID) and fixed a nasty bug where
  177.                                     destPartId was not being initialized to 0
  178.                                     in CloneTo which was causing a crash in
  179.                                     Bento.
  180.         <12>     8/18/94    jpa        Filled in imaging factories [1180387]
  181.         <11>     8/16/94    TÇ        #1180922  Remove more obsolete types from
  182.                                     StdTypes.idl.  Localized kODPartInfo to
  183.                                     this file.
  184.         <10>     8/16/94    VL        1143605: Fixed parameters to CloneInto.
  185.          <9>     8/15/94    JBS        1180387: added Imaging factory methods
  186.          <8>     8/12/94    JBS        1179920: move fWindow from Facet to Frame
  187.          <7>     8/11/94    VL        1180299: Use modified CreateView.
  188.          <6>     8/10/94    JBS        1179919: coordinate system bias changes;
  189.                                     1179920: Frame::AcquireWindow()
  190.          <5>      8/5/94    JBS        #1179151 Part API cleanup
  191.          <4>     7/15/94    TÇ        #ifdef'd out externalization of viewtype &
  192.                                     presentation for now to get the Externalize
  193.                                     method to not crash.
  194.          <3>      7/7/94    JBS        added ::ReleaseAll()
  195.          <2>     6/30/94    jpa        Include Draft.xh, not CMDraft.h.
  196.          <1>     6/30/94    JBS        first checked in
  197.          <0>     6/29/94    SV        SOMverted
  198.     In Progress:
  199.         
  200. */
  201.  
  202. #define ODFrame_Class_Source
  203.  
  204. #ifndef _ALTPOINT_
  205. #include <AltPoint.h>
  206. #endif
  207.  
  208. #ifndef SOM_ODFrame_xih
  209. #define VARIABLE_MACROS
  210. #include <Frame.xih>
  211. #endif
  212.  
  213. #ifndef _PLFMDEF_
  214. #include "PlfmDef.h"
  215. #endif
  216.  
  217. #ifndef SOM_ODFrameFacetIterator_xh
  218. #include <FrFaItr.xh>
  219. #endif
  220.  
  221. #ifndef SOM_ODFacet_xh
  222. #include <Facet.xh>
  223. #endif
  224.  
  225. #ifndef SOM_ODPart_xh
  226. #include <Part.xh>
  227. #endif
  228.  
  229. #ifndef SOM_ODSession_xh
  230. #include <ODSessn.xh>
  231. #endif
  232.  
  233. #ifndef SOM_ODStorageUnit_xh
  234. #include <StorageU.xh>
  235. #endif
  236.  
  237. #ifndef SOM_ODDraft_xh
  238. #include <Draft.xh>
  239. #endif
  240.  
  241. #ifndef SOM_ODDocument_xh
  242. #include <Document.xh>
  243. #endif
  244.  
  245. #ifndef SOM_ODStorageUnitCursor_xh
  246. #include <SUCursor.xh>
  247. #endif
  248.  
  249. #ifndef SOM_ODStorageUnitView_xh
  250. #include <SUView.xh>
  251. #endif
  252.  
  253. #ifndef SOM_ODCanvas_xh
  254. #include <Canvas.xh>
  255. #endif
  256.  
  257. #ifndef SOM_ODShape_xh
  258. #include <Shape.xh>
  259. #endif
  260.  
  261. #ifndef SOM_ODTransform_xh
  262. #include <Trnsform.xh>
  263. #endif
  264.  
  265. #ifndef ODWindowState_Class_Source
  266. #include <WinStat.xh>
  267. #endif
  268.  
  269. #ifndef SOM_ODWindow_xh
  270. #include <Window.xh>
  271. #endif
  272.  
  273. #ifndef SOM_ODWindowIterator_xh
  274. #include <WinIter.xh>
  275. #endif
  276.  
  277. #ifndef SOM_ODArbitrator_xh
  278. #include <Arbitrat.xh>
  279. #endif
  280.  
  281. #ifndef SOM_Module_OpenDoc_Foci_defined
  282. #include <Foci.xh>
  283. #endif
  284.  
  285. #ifndef _ISOSTR_
  286. #include "ISOStr.h"
  287. #endif
  288.  
  289. #ifndef _ODUTILS_
  290. #include <ODUtils.h>
  291. #endif
  292.  
  293. #ifndef _DOCUTILS_
  294. #include <DocUtils.h>
  295. #endif
  296.  
  297. #ifndef SOM_Module_OpenDoc_StdProps_defined
  298. #include <StdProps.xh>
  299. #endif
  300.  
  301. #ifndef SOM_Module_OpenDoc_StdTypes_defined
  302. #include <StdTypes.xh>
  303. #endif
  304.  
  305. #ifndef _EXCEPT_
  306. #include "Except.h"
  307. #endif
  308.  
  309. #ifndef _ORDCOLL_
  310. #include "OrdColl.h"
  311. #endif
  312.  
  313. #ifndef _ODMEMORY_
  314. #include "ODMemory.h"
  315. #endif
  316.  
  317. #ifndef _ODTYPES_
  318. #include <ODTypes.h>
  319. #endif
  320.  
  321. #ifndef _AEHSHTBL_
  322. #include "AEHshTbl.h"
  323. #endif
  324.  
  325. #ifndef _STORUTIL_
  326. #include <StorUtil.h>
  327. #endif
  328.  
  329. #ifndef _STDTYPIO_
  330. #include <StdTypIO.h>
  331. #endif
  332.  
  333. #ifndef _ODDEBUG_
  334. #include "ODDebug.h"
  335. #endif
  336.  
  337. #ifndef _BIAS_
  338. #include "bias.h"
  339. #endif
  340.  
  341. #ifndef _TEMPOBJ_
  342. #include "TempObj.h"
  343. #endif
  344.  
  345. #ifndef _UTILERRS_
  346. #include "UtilErrs.h"
  347. #endif
  348.  
  349. #pragma segment ODFrame
  350.  
  351. //==============================================================================
  352. // Debugging
  353. //==============================================================================
  354.  
  355. //#undef    ODFrameMethodDebug
  356. //#define ODFrameMethodDebug(c,m) PRINT(">>%s::%s\n",c,m)
  357.  
  358. //==============================================================================
  359. // Constants
  360. //==============================================================================
  361.  
  362.     // dirty mask
  363.     const ODULong kNotDirty                    = 0x0000UL;
  364.     const ODULong kContainingFrameDirty        = 0x0001UL;
  365.     const ODULong kFrameShapeDirty            = 0x0002UL;
  366.     const ODULong kInternalTransformDirty    = 0x0004UL;
  367.     const ODULong kPartDirty                = 0x0008UL;
  368.     const ODULong kPartInfoDirty            = 0x0010UL;
  369.     const ODULong kViewTypeDirty            = 0x0020UL;
  370.     const ODULong kPresentationDirty        = 0x0040UL;
  371.     const ODULong kFrameGroupDirty            = 0x0080UL;
  372.     const ODULong kSequenceNumberDirty        = 0x0100UL;
  373.     const ODULong kLinkStatusDirty            = 0x0200UL;
  374.     const ODULong kFlagsDirty                = 0x0400UL;
  375.     const ODULong kAllDirty                    = 0xFFFFUL;
  376.  
  377.     // valid mask
  378.     const ODUShort kFrameIsValid    = 0x0000U;
  379.     const ODUShort kFrameIsRemoved    = 0x0001U;
  380.     const ODUShort kFrameIsClosed    = 0x0002U;
  381.     const ODUShort kFrameIsInRelease    = 0x0004U;
  382.  
  383.     const ODULong kODStorageUnitRefLen = 4UL;
  384.     
  385.     const short    kNumFoci                = 7;
  386.  
  387. //==============================================================================
  388. // Macros
  389. //==============================================================================
  390.  
  391. #define CHECKVALID(RET) if ( _fValidState == kFrameIsValid ) ; else \
  392.                             { ODSetSOMException(ev, kODErrInvalidFrame); return RET;}
  393. #define VOID /**/
  394.  
  395.  
  396. //==============================================================================
  397. // Forward decls.
  398. //==============================================================================
  399.  
  400. static ODBoolean FrameIsContained( Environment *ev, ODFrame* self,
  401.         ODFrame* frame );
  402.  
  403. //==============================================================================
  404. // ODFrame
  405. //==============================================================================
  406.  
  407. //------------------------------------------------------------------------------
  408. // ODFrame: GetID
  409. //------------------------------------------------------------------------------
  410.  
  411. SOM_Scope ODID  SOMLINK ODFrameGetID(ODFrame *somSelf, Environment *ev)
  412. {
  413.     ODFrameData *somThis = ODFrameGetData(somSelf);
  414.     ODFrameMethodDebug("ODFrame","GetID");
  415.     
  416.     ODID id = 0;
  417.     
  418.     if ( _fNPID != 0 )
  419.         id = _fNPID;
  420.     else
  421.     {
  422.         SOM_TRY
  423.             id = parent_GetID(somSelf, ev);
  424.         SOM_CATCH_ALL
  425.             id = 0;
  426.         SOM_ENDTRY
  427.     }
  428.     return id;
  429. }
  430.  
  431. //------------------------------------------------------------------------------
  432. // ODFrame: AcquireContainingFrame
  433. //------------------------------------------------------------------------------
  434.  
  435. SOM_Scope ODFrame*  SOMLINK ODFrameAcquireContainingFrame(ODFrame *somSelf, Environment *ev)
  436. {
  437.     ODFrameData *somThis = ODFrameGetData(somSelf);
  438.     ODFrameMethodDebug("ODFrame","AcquireContainingFrame");
  439.  
  440.     CHECKVALID(kODNULL);
  441.     
  442.     ODFrame* contFrame = kODNULL;
  443.     SOM_TRY
  444.         ODStorageUnit* su = somSelf->GetStorageUnit(ev);
  445.         ODID frameID = 0;
  446.     
  447.         // if there is no containing frame, and this is not a root frame,
  448.         // and this is not a non-persistent frame, we should
  449.         // try to get the containing frame from the storage unit
  450.         if ( !_fContainingFrame && !_fIsRoot && su )
  451.         {
  452.             frameID = ODGetWeakSURefProp(ev, su, kODPropContainingFrame, kODWeakStorageUnitRef);
  453.             if ( frameID )
  454.                 _fContainingFrame = _fDraft->AcquireFrame(ev, frameID);
  455.         }
  456.         contFrame = _fContainingFrame;
  457.         // bump ref count for caller
  458.         ODAcquireObject(ev, _fContainingFrame);
  459.     SOM_CATCH_ALL
  460.         contFrame = kODNULL;
  461.     SOM_ENDTRY
  462.     return contFrame;
  463. }
  464.  
  465. SOM_Scope void  SOMLINK ODFrameSetContainingFrame(ODFrame *somSelf, Environment *ev,
  466.         ODFrame* frame)
  467. {
  468.     ODFrameData *somThis = ODFrameGetData(somSelf);
  469.     ODFrameMethodDebug("ODFrame","SetContainingFrame");
  470.  
  471.     CHECKVALID( VOID );
  472.     
  473.     ODSession* session = kODNULL;
  474.     ODWindowState* winState = kODNULL;
  475.     ODWindowIterator* windows = kODNULL;    ODVolatile(windows);
  476.     ODWindow* win = kODNULL;
  477.     
  478.     SOM_TRY
  479.         // when setting contFrame to NULL, make sure it has no facets
  480.         if ( (frame == kODNULL) && _fFacets && (_fFacets->Count() != 0) )
  481.             THROW(kODErrFrameHasFacets);
  482.     
  483.         ODAcquireObject(ev, frame);
  484.         ODReleaseObject(ev, _fContainingFrame);
  485.         _fContainingFrame = frame;
  486.         _fIsRoot = (frame == kODNULL);
  487.         
  488.         // close any part windows with sourceFrame of this frame or an embedded frame.
  489.         if ( frame == kODNULL )
  490.         {
  491.             TempODPart tempPart = somSelf->AcquirePart(ev);
  492.             session = tempPart->GetStorageUnit(ev)->GetSession(ev);
  493.             winState = session->GetWindowState(ev);
  494.             windows = winState->CreateWindowIterator(ev);
  495.             for ( win = windows->First(ev);
  496.                     windows->IsNotComplete(ev);
  497.                     win = windows->Next(ev) )
  498.             {
  499.                 TempODFrame testFrame = win->AcquireSourceFrame(ev);
  500.                 while ( testFrame != kODNULL )
  501.                 {
  502.                     if ( testFrame == somSelf )
  503.                     {
  504.                         win->Acquire(ev);
  505.                         win->CloseAndRemove(ev);
  506.                         ODReleaseObject(ev, testFrame); // sets to kODNULL
  507.                     }
  508.                     else
  509.                     {
  510.                         ODFrame* spam = testFrame;
  511.                         TempODFrame oldFrame = spam;
  512.                         testFrame = kODNULL; // to avoid double Release if following fails
  513.                         testFrame = oldFrame->AcquireContainingFrame(ev);
  514.                     }
  515.                 }
  516.             }
  517.             ODDeleteObject(windows);
  518.         }
  519.         
  520.         somSelf->SetDirty(ev, kContainingFrameDirty);
  521.     SOM_CATCH_ALL
  522.         ODDeleteObject(windows);
  523.     SOM_ENDTRY
  524. }
  525.  
  526. //------------------------------------------------------------------------------
  527. // ODFrame: AcquireWindow
  528. //------------------------------------------------------------------------------
  529.  
  530. SOM_Scope ODWindow*  SOMLINK ODFrameAcquireWindow(ODFrame *somSelf, Environment *ev)
  531. {
  532.     ODFrameData *somThis = ODFrameGetData(somSelf);
  533.     ODFrameMethodDebug("ODFrame","AcquireWindow");
  534.  
  535.     CHECKVALID(kODNULL);
  536. //    WASSERT( !_fIsInLimbo );
  537.     
  538.     ODWindow* window = kODNULL;    ODVolatile(window);
  539.  
  540.     SOM_TRY
  541.         if ( _fWindow )
  542.         {
  543.             window = _fWindow;
  544.             ODAcquireObject(ev, _fWindow);
  545.         }
  546.         else if ( !_fIsRoot )
  547.         {
  548.             TempODFrame containingFrame = somSelf->AcquireContainingFrame(ev);
  549.             window = containingFrame->AcquireWindow(ev); // bumps ref count for caller
  550.         }
  551.     SOM_CATCH_ALL
  552.         window = kODNULL;
  553.     SOM_ENDTRY
  554.     return window;
  555. }
  556.  
  557. SOM_Scope void  SOMLINK ODFrameSetWindow(ODFrame *somSelf, Environment *ev,
  558.         ODWindow* window)
  559. {
  560.     ODFrameData *somThis = ODFrameGetData(somSelf);
  561.     ODFrameMethodDebug("ODFrame","SetWindow");
  562.  
  563.     CHECKVALID( VOID );
  564.  
  565.     SOM_TRY
  566.         if ( !_fIsRoot )
  567.             THROW(kODErrNotRootFrame);
  568.     
  569.         ODAcquireObject(ev, window);
  570.         ODReleaseObject(ev, _fWindow);
  571.         _fWindow = window;
  572.     SOM_CATCH_ALL
  573.     SOM_ENDTRY
  574. }
  575.  
  576. //------------------------------------------------------------------------------
  577. // ODFrame: GetPartInfo
  578. //------------------------------------------------------------------------------
  579.  
  580. SOM_Scope ODInfoType  SOMLINK ODFrameGetPartInfo(ODFrame *somSelf, Environment *ev)
  581. {
  582.     ODFrameData *somThis = ODFrameGetData(somSelf);
  583.     ODFrameMethodDebug("ODFrame","GetPartInfo");
  584.  
  585.     CHECKVALID(kODNULL);
  586.     
  587.     if ( _fPart == kODNULL )    // part has not been internalized yet
  588.     {
  589.         SOM_TRY
  590.             somSelf->AcquirePart(ev)->Release(ev);    // force internalization of partInfo
  591.         SOM_CATCH_ALL
  592.         SOM_ENDTRY
  593.     }
  594.  
  595.     return _fPartInfo;
  596. }
  597.  
  598. SOM_Scope void  SOMLINK ODFrameSetPartInfo(ODFrame *somSelf, Environment *ev,
  599.         ODInfoType partInfo)
  600. {
  601.     ODFrameData *somThis = ODFrameGetData(somSelf);
  602.     ODFrameMethodDebug("ODFrame","SetPartInfo");
  603.  
  604.     CHECKVALID( VOID );
  605.  
  606.     _fPartInfo = partInfo;
  607. }
  608.     
  609. //------------------------------------------------------------------------------
  610. // ODFrame: GetViewType
  611. //------------------------------------------------------------------------------
  612.  
  613. SOM_Scope ODTypeToken  SOMLINK ODFrameGetViewType(ODFrame *somSelf, Environment *ev)
  614. {
  615.     ODFrameData *somThis = ODFrameGetData(somSelf);
  616.     ODFrameMethodDebug("ODFrame","GetViewType");
  617.  
  618.     CHECKVALID(kODNULL);
  619.     
  620.     return _fViewType;
  621. }
  622.  
  623. SOM_Scope void  SOMLINK ODFrameSetViewType(ODFrame *somSelf, Environment *ev,
  624.         ODTypeToken viewType)
  625. {
  626.     ODFrameData *somThis = ODFrameGetData(somSelf);
  627.     ODFrameMethodDebug("ODFrame","SetViewType");
  628.  
  629.     CHECKVALID( VOID );
  630.  
  631.     SOM_TRY
  632.         if ( kODNULL == viewType )
  633.             THROW(kODErrIllegalNullTokenInput);
  634.     
  635.         if ( _fViewType != viewType )
  636.         {
  637.             _fViewType = viewType;
  638.     
  639.             somSelf->SetDirty(ev, kViewTypeDirty);
  640.         }
  641.     SOM_CATCH_ALL
  642.     SOM_ENDTRY
  643. }
  644.  
  645. SOM_Scope void  SOMLINK ODFrameChangeViewType(ODFrame *somSelf, Environment *ev,
  646.         ODTypeToken viewType)
  647. {
  648.     ODFrameData *somThis = ODFrameGetData(somSelf);
  649.     ODFrameMethodDebug("ODFrame","ChangeViewType");
  650.  
  651.     CHECKVALID( VOID );
  652.  
  653.     SOM_TRY
  654.         if ( kODNULL == viewType )
  655.             THROW(kODErrIllegalNullTokenInput);
  656.     
  657.         if ( viewType != _fViewType )
  658.         {
  659.             _fViewType = viewType;
  660.             
  661.             TempODPart tempPart = somSelf->AcquirePart(ev);
  662.             tempPart->ViewTypeChanged(ev, somSelf);
  663.         
  664.             somSelf->SetDirty(ev, kViewTypeDirty);
  665.         }
  666.     SOM_CATCH_ALL
  667.     SOM_ENDTRY
  668. }
  669.  
  670. //------------------------------------------------------------------------------
  671. // ODFrame: GetPresentation
  672. //------------------------------------------------------------------------------
  673.  
  674. SOM_Scope ODTypeToken  SOMLINK ODFrameGetPresentation(ODFrame *somSelf, Environment *ev)
  675. {
  676.     ODFrameData *somThis = ODFrameGetData(somSelf);
  677.     ODFrameMethodDebug("ODFrame","GetPresentation");
  678.  
  679.     CHECKVALID(kODNULL);
  680.     
  681.     return _fPresentation;
  682. }
  683.  
  684. SOM_Scope void  SOMLINK ODFrameSetPresentation(ODFrame *somSelf, Environment *ev,
  685.         ODTypeToken presentation)
  686. {
  687.     ODFrameData *somThis = ODFrameGetData(somSelf);
  688.     ODFrameMethodDebug("ODFrame","SetPresentation");
  689.  
  690.     CHECKVALID( VOID );
  691.     
  692.     SOM_TRY
  693.         if ( kODNULL == presentation )
  694.             THROW(kODErrIllegalNullTokenInput);
  695.     
  696.         if ( _fPresentation != presentation )
  697.         {
  698.             _fPresentation = presentation;
  699.         
  700.             somSelf->SetDirty(ev, kPresentationDirty);
  701.         }
  702.     SOM_CATCH_ALL
  703.     SOM_ENDTRY
  704. }
  705.  
  706. SOM_Scope void  SOMLINK ODFrameChangePresentation(ODFrame *somSelf, Environment *ev,
  707.         ODTypeToken presentation)
  708. {
  709.     ODFrameData *somThis = ODFrameGetData(somSelf);
  710.     ODFrameMethodDebug("ODFrame","ChangePresentation");
  711.  
  712.     CHECKVALID( VOID );
  713.     
  714.     SOM_TRY
  715.         if ( kODNULL == presentation )
  716.             THROW(kODErrIllegalNullTokenInput);
  717.     
  718.         if ( _fPresentation != presentation )
  719.         {
  720.             _fPresentation = presentation;
  721.  
  722.             TempODPart tempPart = somSelf->AcquirePart(ev);
  723.             tempPart->PresentationChanged(ev, somSelf);
  724.         
  725.             somSelf->SetDirty(ev, kPresentationDirty);
  726.         }
  727.     SOM_CATCH_ALL
  728.     SOM_ENDTRY
  729. }
  730.  
  731. //------------------------------------------------------------------------------
  732. // ODFrame: GetFrameGroup
  733. //------------------------------------------------------------------------------
  734.  
  735. SOM_Scope ODULong  SOMLINK ODFrameGetFrameGroup(ODFrame *somSelf, Environment *ev)
  736. {
  737.     ODFrameData *somThis = ODFrameGetData(somSelf);
  738.     ODFrameMethodDebug("ODFrame","GetFrameGroup");
  739.  
  740.     CHECKVALID(0);
  741.     
  742.     return _fFrameGroup;
  743. }
  744.  
  745. SOM_Scope void  SOMLINK ODFrameSetFrameGroup(ODFrame *somSelf, Environment *ev,
  746.         ODULong groupID)
  747. {
  748.     ODFrameData *somThis = ODFrameGetData(somSelf);
  749.     ODFrameMethodDebug("ODFrame","SetFrameGroup");
  750.  
  751.     CHECKVALID( VOID );
  752.     
  753.     SOM_TRY
  754.         if ( groupID != _fFrameGroup )
  755.         {
  756.             _fFrameGroup = groupID;
  757.         
  758.             somSelf->SetDirty(ev, kFrameGroupDirty);
  759.         }
  760.     SOM_CATCH_ALL
  761.     SOM_ENDTRY
  762. }
  763.  
  764. //------------------------------------------------------------------------------
  765. // ODFrame: GetSequenceNumber
  766. //------------------------------------------------------------------------------
  767.  
  768. SOM_Scope ODULong  SOMLINK ODFrameGetSequenceNumber(ODFrame *somSelf, Environment *ev)
  769. {
  770.     ODFrameData *somThis = ODFrameGetData(somSelf);
  771.     ODFrameMethodDebug("ODFrame","GetSequenceNumber");
  772.  
  773.     CHECKVALID(0);
  774.     
  775.     return _fSequenceNumber;
  776. }
  777.  
  778. SOM_Scope void  SOMLINK ODFrameChangeSequenceNumber(ODFrame *somSelf, Environment *ev,
  779.         ODULong sequenceNumber)
  780. {
  781.     ODFrameData *somThis = ODFrameGetData(somSelf);
  782.     ODFrameMethodDebug("ODFrame","ChangeSequenceNumber");
  783.  
  784.     CHECKVALID( VOID );
  785.     
  786.     SOM_TRY
  787.         if ( sequenceNumber != _fSequenceNumber )
  788.         {
  789.             _fSequenceNumber = sequenceNumber;
  790.         
  791.             somSelf->SetDirty(ev, kSequenceNumberDirty);
  792.         }
  793.     SOM_CATCH_ALL
  794.     SOM_ENDTRY
  795. }
  796.  
  797. //------------------------------------------------------------------------------
  798. // ODFrame: IsRoot
  799. //------------------------------------------------------------------------------
  800.  
  801. SOM_Scope ODBoolean  SOMLINK ODFrameIsRoot(ODFrame *somSelf, Environment *ev)
  802. {
  803.     ODFrameData *somThis = ODFrameGetData(somSelf);
  804.     ODFrameMethodDebug("ODFrame","IsRoot");
  805.  
  806.     CHECKVALID(kODFalse);
  807.     
  808.     return _fIsRoot;
  809. }
  810.  
  811. //------------------------------------------------------------------------------
  812. // ODFrame: IsSubframe
  813. //------------------------------------------------------------------------------
  814.  
  815. SOM_Scope ODBoolean  SOMLINK ODFrameIsSubframe(ODFrame *somSelf, Environment *ev)
  816. {
  817.     ODFrameData *somThis = ODFrameGetData(somSelf);
  818.     ODFrameMethodDebug("ODFrame","IsSubframe");
  819.  
  820.     CHECKVALID(kODFalse);
  821.     
  822.     return _fIsSubframe;
  823. }
  824.  
  825. SOM_Scope void  SOMLINK ODFrameSetSubframe(ODFrame *somSelf, Environment *ev,
  826.         ODBoolean isSubframe)
  827. {
  828.     ODFrameData *somThis = ODFrameGetData(somSelf);
  829.     ODFrameMethodDebug("ODFrame","SetSubframe");
  830.  
  831.     CHECKVALID( VOID );
  832.     
  833.     SOM_TRY
  834.         if ( isSubframe != _fIsSubframe)
  835.         {
  836.             _fIsSubframe = isSubframe;
  837.         
  838.             somSelf->SetDirty(ev, kFlagsDirty);
  839.         }
  840.     SOM_CATCH_ALL
  841.     SOM_ENDTRY
  842. }
  843.     
  844. //------------------------------------------------------------------------------
  845. // ODFrame: IsOverlaid
  846. //------------------------------------------------------------------------------
  847.  
  848. SOM_Scope ODBoolean  SOMLINK ODFrameIsOverlaid(ODFrame *somSelf, Environment *ev)
  849. {
  850.     ODFrameData *somThis = ODFrameGetData(somSelf);
  851.     ODFrameMethodDebug("ODFrame","IsOverlaid");
  852.  
  853.     CHECKVALID(kODFalse);
  854.     
  855.     return _fIsOverlaid;
  856. }
  857.  
  858. //------------------------------------------------------------------------------
  859. // ODFrame: IsFrozen
  860. //------------------------------------------------------------------------------
  861.  
  862. SOM_Scope ODBoolean  SOMLINK ODFrameIsFrozen(ODFrame *somSelf, Environment *ev)
  863. {
  864.     ODFrameData *somThis = ODFrameGetData(somSelf);
  865.     ODFrameMethodDebug("ODFrame","IsFrozen");
  866.  
  867.     CHECKVALID(kODFalse);
  868.     
  869.     return _fIsFrozen;
  870. }
  871.  
  872. SOM_Scope void  SOMLINK ODFrameSetFrozen(ODFrame *somSelf, Environment *ev,
  873.         ODBoolean isFrozen)
  874. {
  875.     ODFrameData *somThis = ODFrameGetData(somSelf);
  876.     ODFrameMethodDebug("ODFrame","SetFrozen");
  877.  
  878.     CHECKVALID( VOID );
  879.     
  880.     SOM_TRY
  881.         if ( isFrozen != _fIsFrozen)
  882.         {
  883.             _fIsFrozen = isFrozen;
  884.         
  885.             somSelf->SetDirty(ev, kFlagsDirty);
  886.         }
  887.     SOM_CATCH_ALL
  888.     SOM_ENDTRY
  889. }
  890.  
  891. //------------------------------------------------------------------------------
  892. // ODFrame: DoesPropagateEvents
  893. //------------------------------------------------------------------------------
  894.  
  895. SOM_Scope ODBoolean  SOMLINK ODFrameDoesPropagateEvents(ODFrame *somSelf, Environment *ev)
  896. {
  897.     ODFrameData *somThis = ODFrameGetData(somSelf);
  898.     ODFrameMethodDebug("ODFrame","DoesPropagateEvents");
  899.  
  900.     CHECKVALID(kODFalse);
  901.     
  902.     return _fDoesPropagateEvents;
  903. }
  904.  
  905. SOM_Scope void  SOMLINK ODFrameSetPropagateEvents(ODFrame *somSelf, Environment *ev,
  906.         ODBoolean doesPropagateEvents)
  907. {
  908.     ODFrameData *somThis = ODFrameGetData(somSelf);
  909.     ODFrameMethodDebug("ODFrame","SetPropagateEvents");
  910.  
  911.     CHECKVALID( VOID );
  912.     
  913.     if ( doesPropagateEvents != _fDoesPropagateEvents)
  914.         _fDoesPropagateEvents = doesPropagateEvents;
  915. }
  916.     
  917. //------------------------------------------------------------------------------
  918. // ODFrame: IsInLimbo
  919. //------------------------------------------------------------------------------
  920.  
  921. SOM_Scope ODBoolean  SOMLINK ODFrameIsInLimbo(ODFrame *somSelf, Environment *ev)
  922. {
  923.     ODFrameData *somThis = ODFrameGetData(somSelf);
  924.     ODFrameMethodDebug("ODFrame","IsInLimbo");
  925.  
  926.     CHECKVALID(kODFalse);
  927.     
  928.     return _fIsInLimbo;
  929. }
  930.  
  931. SOM_Scope void  SOMLINK ODFrameSetInLimbo(ODFrame *somSelf, Environment *ev,
  932.         ODBoolean isInLimbo)
  933. {
  934.     ODFrameData *somThis = ODFrameGetData(somSelf);
  935.     ODFrameMethodDebug("ODFrame","SetInLimbo");
  936.  
  937.     CHECKVALID( VOID );
  938.     
  939. //    if ( isInLimbo != _fIsInLimbo)
  940.     _fIsInLimbo = isInLimbo;
  941.     if ( isInLimbo )
  942.     {
  943.         SOM_TRY
  944.             // Since SetInLimbo is called only on the root frame of a hierarchy
  945.             // being put into limbo, we need to search through all embedded
  946.             // frames for any with foci and then release them.  To make this
  947.             // less expensive, we'll first build a list of frame/focus pairs,
  948.             // then for each frame found do a recursive search to see if it is
  949.             // contained within (or equal to) this frame.
  950.             
  951.             TempODPart tempPart = somSelf->AcquirePart(ev);
  952.             ODSession* session = tempPart->GetStorageUnit(ev)->GetSession(ev);
  953.             ODArbitrator* arb = session->GetArbitrator(ev);
  954.  
  955.             ODFocusType foci[kNumFoci] = { kODSelectionFocus, kODMenuFocus, kODKeyFocus,
  956.                     kODModalFocus, kODMouseFocus, kODScrollingFocus, kODClipboardFocus };
  957.             ODFocusType* focus = foci;
  958.             for ( int i = 0; i < kNumFoci; ++i )
  959.             {
  960.                 ODTypeToken focusToken = session->Tokenize( ev, *focus++ );
  961.                 TempODFrame activeFrame = session->GetArbitrator(ev)->
  962.                         AcquireFocusOwner( ev, focusToken );
  963.                 if ( FrameIsContained( ev, somSelf, activeFrame ) )
  964.                     arb->TransferFocus( ev, focusToken, kODNULL, kODNULL );
  965.             }
  966.         SOM_CATCH_ALL
  967.         SOM_ENDTRY
  968.     }
  969. }
  970.     
  971. //------------------------------------------------------------------------------
  972. // ODFrame: AcquirePart
  973. //------------------------------------------------------------------------------
  974.  
  975. SOM_Scope ODPart*  SOMLINK ODFrameAcquirePart(ODFrame *somSelf, Environment *ev)
  976. {
  977.     ODFrameData *somThis = ODFrameGetData(somSelf);
  978.     ODFrameMethodDebug("ODFrame","AcquirePart");
  979.  
  980.     CHECKVALID(kODNULL);
  981.     
  982.     ODFrameFacetIterator* i = kODNULL; ODVolatile(i);
  983.     
  984.     SOM_TRY
  985.         if ( _fPart == kODNULL )    // part has not been internalized yet
  986.         {
  987.             ODStorageUnit     *su = somSelf->GetStorageUnit(ev);
  988.             ODStorageUnitView *suView = kODNULL;
  989.             
  990.             if ( su )
  991.             {
  992.                 _fPart = _fDraft->AcquirePart(ev,
  993.                         ODGetStrongSURefProp(ev, su, kODPropPart, kODStrongStorageUnitRef));
  994.                 ASSERT(_fPart, kODErrAssertionFailed);
  995.                 
  996.                 su->Focus(ev, kODPropPartInfo, kODPosUndefined, kODNULL, 0, kODPosUndefined);
  997.                 {    
  998.                     TempODStorageUnitView suView = su->CreateView(ev);
  999.                     _fPartInfo = (ODInfoType)(_fPart->ReadPartInfo(ev, somSelf, suView));
  1000.                 }
  1001.                 
  1002.                 _fPart->DisplayFrameConnected(ev, somSelf);
  1003.  
  1004.                 i = somSelf->CreateFacetIterator(ev);
  1005.                 for (ODFacet* facet = i->First(ev); i->IsNotComplete(ev); facet = i->Next(ev))
  1006.                     _fPart->FacetAdded(ev, facet);
  1007.                 ODDeleteObject(i);
  1008.             }
  1009.         }
  1010.         // bump ref count for caller
  1011.         ODAcquireObject(ev, _fPart);
  1012.     SOM_CATCH_ALL
  1013.         ODSafeReleaseObject(_fPart); _fPart = kODNULL;
  1014.         ODDeleteObject(i);
  1015.     SOM_ENDTRY
  1016.     
  1017.     return _fPart;
  1018. }
  1019.     
  1020. //------------------------------------------------------------------------------
  1021. // ODFrame: ChangePart
  1022. //------------------------------------------------------------------------------
  1023.  
  1024. SOM_Scope void  SOMLINK ODFrameChangePart(ODFrame *somSelf, Environment *ev,
  1025.         ODPart* part)
  1026. {
  1027.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1028.     ODFrameMethodDebug("ODFrame","ChangePart");
  1029.  
  1030.     CHECKVALID( VOID );
  1031.     
  1032.     SOM_TRY
  1033.         if ( !part )
  1034.             THROW(kODErrIllegalNullPartInput);
  1035.         if ( _fPart == kODNULL )
  1036.             somSelf->AcquirePart(ev)->Release(ev);    // force internalization of part
  1037.         ASSERT( _fPart, kODErrInvalidPersistentFormat);
  1038.         
  1039.         ODFrameFacetIterator* i = somSelf->CreateFacetIterator(ev);
  1040.         ODFacet* facet = kODNULL;
  1041.         
  1042.         for (facet = i->First(ev); i->IsNotComplete(ev); facet = i->Next(ev))
  1043.             _fPart->FacetRemoved(ev, facet);
  1044.         TRY
  1045.             _fPart->DisplayFrameRemoved(ev, somSelf);
  1046.         CATCH_ALL
  1047.             WARN("Part returned err %d removing frame",ErrorCode());
  1048.             // don't reraise
  1049.         ENDTRY
  1050.     
  1051.         ODAcquireObject(ev, part);
  1052.         ODReleaseObject(ev, _fPart);
  1053.         _fPart = part;
  1054.     
  1055.         _fPart->DisplayFrameAdded(ev, somSelf);
  1056.         for (facet = i->First(ev); i->IsNotComplete(ev); facet = i->Next(ev))
  1057.             _fPart->FacetAdded(ev, facet);
  1058.         
  1059.         delete i;
  1060.     
  1061.         somSelf->SetDirty(ev, kPartDirty);
  1062.     SOM_CATCH_ALL
  1063.     SOM_ENDTRY
  1064. }
  1065.     
  1066. //------------------------------------------------------------------------------
  1067. // ODFrame: FacetAdded
  1068. //------------------------------------------------------------------------------
  1069.  
  1070. SOM_Scope void  SOMLINK ODFrameFacetAdded(ODFrame *somSelf, Environment *ev,
  1071.         ODFacet* facet)
  1072. {
  1073.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1074.     ODFrameMethodDebug("ODFrame","FacetAdded");
  1075.  
  1076.     CHECKVALID( VOID );
  1077.     
  1078.     SOM_TRY
  1079.         TempODPart tempPart = somSelf->AcquirePart(ev);
  1080.         _fFacets->AddLast(facet);
  1081.         tempPart->FacetAdded(ev, facet);
  1082.     SOM_CATCH_ALL
  1083.     SOM_ENDTRY
  1084. }
  1085.  
  1086. //------------------------------------------------------------------------------
  1087. // ODFrame: FacetRemoved
  1088. //------------------------------------------------------------------------------
  1089.  
  1090. SOM_Scope void  SOMLINK ODFrameFacetRemoved(ODFrame *somSelf, Environment *ev,
  1091.         ODFacet* facet)
  1092. {
  1093.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1094.     ODFrameMethodDebug("ODFrame","FacetRemoved");
  1095.  
  1096.     CHECKVALID( VOID );
  1097.     
  1098.     SOM_TRY
  1099.         if ( _fFacets->Contains(facet) )
  1100.         {
  1101.             _fFacets->Remove(facet);
  1102.             TempODPart tempPart = somSelf->AcquirePart(ev);
  1103.             tempPart->FacetRemoved(ev, facet);
  1104.         }
  1105.     SOM_CATCH_ALL
  1106.     SOM_ENDTRY
  1107. }
  1108.  
  1109. //------------------------------------------------------------------------------
  1110. // ODFrame: CreateFacetIterator
  1111. //------------------------------------------------------------------------------
  1112.  
  1113. SOM_Scope ODFrameFacetIterator*  SOMLINK ODFrameCreateFacetIterator(ODFrame *somSelf, Environment *ev)
  1114. {
  1115.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1116.     ODFrameMethodDebug("ODFrame","CreateFacetIterator");
  1117.  
  1118.     ODFrameFacetIterator* iter = kODNULL; ODVolatile(iter);
  1119.  
  1120.     CHECKVALID(kODNULL);
  1121.     
  1122.     SOM_TRY
  1123.         iter = new ODFrameFacetIterator;
  1124.           THROW_IF_NULL(iter);
  1125.         iter->InitFrameFacetIterator(ev, somSelf);
  1126.     SOM_CATCH_ALL
  1127.         ODDeleteObject(iter);
  1128.         iter = kODNULL;
  1129.     SOM_ENDTRY
  1130.     return iter;
  1131. }
  1132.  
  1133. //------------------------------------------------------------------------------
  1134. // ODFrame: CreateShape
  1135. //------------------------------------------------------------------------------
  1136.  
  1137. SOM_Scope ODShape*  SOMLINK ODFrameCreateShape(ODFrame *somSelf, Environment *ev)
  1138. {
  1139.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1140.     ODFrameMethodDebug("ODFrame","CreateShape");
  1141.  
  1142.     CHECKVALID(kODNULL);
  1143.     
  1144.     ODShape *s = kODNULL;  ODVolatile(s);
  1145.     
  1146.     SOM_TRY
  1147.         s = new ODShape;
  1148.         THROW_IF_NULL(s);
  1149.         s->InitShape(ev);
  1150.     SOM_CATCH_ALL
  1151.           ODDeleteObject(s);
  1152.         s = kODNULL;
  1153.     SOM_ENDTRY
  1154.     return s;
  1155. }
  1156.  
  1157. //------------------------------------------------------------------------------
  1158. // ODFrame: AcquireFrameShape
  1159. //------------------------------------------------------------------------------
  1160.  
  1161. SOM_Scope ODShape*  SOMLINK ODFrameAcquireFrameShape(ODFrame *somSelf, Environment *ev,
  1162.         ODCanvas* biasCanvas)
  1163. {
  1164.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1165.     ODFrameMethodDebug("ODFrame","AcquireFrameShape");
  1166.  
  1167.     CHECKVALID(kODNULL);
  1168.     
  1169.     ODShape* s;
  1170.     SOM_TRY
  1171.         s = BiasShapeGet(ev, _fFrameShape, biasCanvas);
  1172.     SOM_CATCH_ALL
  1173.         s = kODNULL;
  1174.     SOM_ENDTRY
  1175.     return s;
  1176. }
  1177.  
  1178. //------------------------------------------------------------------------------
  1179. // ODFrame: ChangeFrameShape
  1180. //------------------------------------------------------------------------------
  1181.  
  1182. SOM_Scope void  SOMLINK ODFrameChangeFrameShape(ODFrame *somSelf, Environment *ev,
  1183.         ODShape* shape, ODCanvas* biasCanvas)
  1184. {
  1185.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1186.     ODFrameMethodDebug("ODFrame","ChangeFrameShape");
  1187.  
  1188.     CHECKVALID( VOID );
  1189.     
  1190.     ODSession* session;
  1191.     ODTypeToken    selectionFocus;
  1192.  
  1193.     SOM_TRY
  1194.         if (shape)
  1195.         {
  1196.             TempODPart tempPart = somSelf->AcquirePart(ev);
  1197.             session = tempPart->GetStorageUnit(ev)->GetSession(ev);
  1198.             selectionFocus = session->Tokenize(ev, kODSelectionFocus);
  1199.     
  1200.             TempODFrame activeFrame = session->GetArbitrator(ev)->AcquireFocusOwner(ev, selectionFocus);
  1201.             if ( ODObjectsAreEqual(ev, somSelf, activeFrame) )
  1202.                 somSelf->InvalidateActiveBorder(ev);
  1203.     
  1204.             ODAcquireObject(ev, shape);
  1205.             ODReleaseObject(ev, _fFrameShape);
  1206.             _fFrameShape = BiasShapeSet(ev, shape, biasCanvas);
  1207.     
  1208.             tempPart->FrameShapeChanged(ev, somSelf);
  1209.         }
  1210.         else
  1211.             THROW(kODErrIllegalNullShapeInput);    // frame's MUST have a frameShape
  1212.     
  1213.         somSelf->SetDirty(ev, kFrameShapeDirty);
  1214.     SOM_CATCH_ALL
  1215.     SOM_ENDTRY
  1216. }
  1217.  
  1218. //------------------------------------------------------------------------------
  1219. // ODFrame: RequestFrameShape
  1220. //------------------------------------------------------------------------------
  1221.  
  1222. SOM_Scope ODShape*  SOMLINK ODFrameRequestFrameShape(ODFrame *somSelf, Environment *ev,
  1223.         ODShape* shape, ODCanvas* biasCanvas)
  1224. {
  1225.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1226.     ODFrameMethodDebug("ODFrame","RequestFrameShape");
  1227.  
  1228.     CHECKVALID(kODNULL);
  1229.     
  1230.     ODShape* s = kODNULL;
  1231.     SOM_TRY
  1232.         TempODFrame containingFrame = somSelf->AcquireContainingFrame(ev);
  1233.         ODSession* session;
  1234.         ODTypeToken    selectionFocus;
  1235.         
  1236.         if ( shape == kODNULL )
  1237.         {
  1238.             THROW(kODErrIllegalNullShapeInput);
  1239.             return kODNULL;
  1240.         }
  1241.     
  1242.         if ( containingFrame )    // root frames can't negotiate
  1243.         {
  1244.             TempODPart containingPart = containingFrame->AcquirePart(ev);
  1245.             BiasShapeSet(ev, shape, biasCanvas);
  1246.             if (containingPart)
  1247.                 shape = containingPart->RequestFrameShape(ev, somSelf, shape);    
  1248.  
  1249.             TempODPart tempPart = somSelf->AcquirePart(ev);
  1250.             session = tempPart->GetStorageUnit(ev)->GetSession(ev);
  1251.             selectionFocus = session->Tokenize(ev, kODSelectionFocus);
  1252.     
  1253.             TempODFrame activeFrame = session->GetArbitrator(ev)->AcquireFocusOwner(ev, selectionFocus);
  1254.             if ( ODObjectsAreEqual(ev, somSelf, activeFrame) )
  1255.                 somSelf->InvalidateActiveBorder(ev);
  1256.     
  1257.             // shape's refcount is already inflated by containing part
  1258.             ODReleaseObject(ev, _fFrameShape);
  1259.             _fFrameShape = shape;
  1260.         }
  1261.     
  1262.         somSelf->SetDirty(ev, kFrameShapeDirty);
  1263.     
  1264.         s = BiasShapeGet(ev, _fFrameShape, biasCanvas);
  1265.     SOM_CATCH_ALL
  1266.         s = kODNULL;
  1267.     SOM_ENDTRY
  1268.     return s;
  1269. }
  1270.  
  1271. //------------------------------------------------------------------------------
  1272. // ODFrame: AcquireUsedShape
  1273. //------------------------------------------------------------------------------
  1274.  
  1275. SOM_Scope ODShape*  SOMLINK ODFrameAcquireUsedShape(ODFrame *somSelf, Environment *ev,
  1276.         ODCanvas* biasCanvas)
  1277. {
  1278.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1279.     ODFrameMethodDebug("ODFrame","AcquireUsedShape");
  1280.  
  1281.     CHECKVALID(kODNULL);
  1282.     
  1283.     ODShape* s;
  1284.     SOM_TRY
  1285.         if ( _fUsedShape )
  1286.             s = BiasShapeGet(ev, _fUsedShape, biasCanvas);
  1287.         else
  1288.             s = ODCopyAndRelease(ev, BiasShapeGet(ev, _fFrameShape, biasCanvas));
  1289.     SOM_CATCH_ALL
  1290.         s = kODNULL;
  1291.     SOM_ENDTRY
  1292.     return s;
  1293. }
  1294.  
  1295. //------------------------------------------------------------------------------
  1296. // ODFrame: ChangeUsedShape
  1297. //------------------------------------------------------------------------------
  1298.  
  1299. SOM_Scope void  SOMLINK ODFrameChangeUsedShape(ODFrame *somSelf, Environment *ev,
  1300.         ODShape* shape, ODCanvas* biasCanvas)
  1301. {
  1302.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1303.     ODFrameMethodDebug("ODFrame","ChangeUsedShape");
  1304.  
  1305.     CHECKVALID( VOID );
  1306.     
  1307.     SOM_TRY
  1308.         TempODFrame containingFrame = somSelf->AcquireContainingFrame(ev);
  1309.         TempODPart containingPart = kODNULL;
  1310.         
  1311.         ODAcquireObject(ev, shape);
  1312.         ODReleaseObject(ev, _fUsedShape);
  1313.         _fUsedShape = BiasShapeSet(ev, shape, biasCanvas);
  1314.     
  1315.         if ( containingFrame )
  1316.         {    containingPart = containingFrame->AcquirePart(ev);
  1317.             if ( containingPart )
  1318.                 containingPart->UsedShapeChanged(ev, somSelf);
  1319.         }
  1320.     SOM_CATCH_ALL
  1321.     SOM_ENDTRY
  1322. }
  1323.  
  1324. //------------------------------------------------------------------------------
  1325. // ODFrame: CreateTransform
  1326. //------------------------------------------------------------------------------
  1327.  
  1328. SOM_Scope ODTransform*  SOMLINK ODFrameCreateTransform(ODFrame *somSelf, Environment *ev)
  1329. {
  1330.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1331.     ODFrameMethodDebug("ODFrame","CreateTransform");
  1332.  
  1333.     CHECKVALID(kODNULL);
  1334.     
  1335.     ODTransform *t = kODNULL;  ODVolatile(t);
  1336.     SOM_TRY
  1337.         t = new ODTransform;
  1338.         THROW_IF_NULL(t);
  1339.         t->InitTransform(ev);
  1340.     SOM_CATCH_ALL
  1341.         ODDeleteObject(t);
  1342.         t = kODNULL;
  1343.     SOM_ENDTRY
  1344.     return t;
  1345. }
  1346.  
  1347. //------------------------------------------------------------------------------
  1348. // ODFrame: AcquireInternalTransform
  1349. //------------------------------------------------------------------------------
  1350.  
  1351. SOM_Scope ODTransform*  SOMLINK ODFrameAcquireInternalTransform(ODFrame *somSelf, Environment *ev,
  1352.         ODCanvas* biasCanvas)
  1353. {
  1354.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1355.     ODFrameMethodDebug("ODFrame","AcquireInternalTransform");
  1356.  
  1357.     CHECKVALID(kODNULL);
  1358.     
  1359.     ODTransform *t;
  1360.     SOM_TRY
  1361.         t = BiasTransformGet(ev, _fInternalTransform, biasCanvas);
  1362.     SOM_CATCH_ALL
  1363.         t = kODNULL;
  1364.     SOM_ENDTRY
  1365.     return t;
  1366. }
  1367.  
  1368. //------------------------------------------------------------------------------
  1369. // ODFrame: ChangeInternalTransform
  1370. //------------------------------------------------------------------------------
  1371.  
  1372. SOM_Scope void  SOMLINK ODFrameChangeInternalTransform(ODFrame *somSelf, Environment *ev,
  1373.         ODTransform* transform, ODCanvas* biasCanvas)
  1374. {
  1375.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1376.     ODFrameMethodDebug("ODFrame","ChangeInternalTransform");
  1377.  
  1378.     CHECKVALID( VOID );
  1379.     
  1380.     ODFrameFacetIterator* i = kODNULL; ODVolatile(i);
  1381.     SOM_TRY
  1382.         if ( transform )
  1383.         {
  1384.             ODAcquireObject(ev, transform);
  1385.             ODReleaseObject(ev, _fInternalTransform);
  1386.             _fInternalTransform = BiasTransformSet(ev, transform, biasCanvas);
  1387.             
  1388.             i = somSelf->CreateFacetIterator(ev);
  1389.             for (ODFacet* facet = i->First(ev); i->IsNotComplete(ev); facet = i->Next(ev))
  1390.                 facet->InternalTransformChanged(ev);
  1391.             delete i;
  1392.         }
  1393.         else
  1394.         {
  1395.             THROW(kODErrIllegalNullTransformInput);
  1396.         }
  1397.     
  1398.         somSelf->SetDirty(ev, kInternalTransformDirty);
  1399.     SOM_CATCH_ALL
  1400.         ODDeleteObject(i);
  1401.     SOM_ENDTRY
  1402. }
  1403.  
  1404. //------------------------------------------------------------------------------
  1405. // ODFrame: GetContentExtent
  1406. //------------------------------------------------------------------------------
  1407.  
  1408. SOM_Scope void  SOMLINK ODFrameGetContentExtent(ODFrame *somSelf, Environment *ev, ODPoint* contentExtent)
  1409. {
  1410.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1411.     ODFrameMethodDebug("ODFrame","GetContentExtent");
  1412.  
  1413.     ODPoint pt(0,0);
  1414.     *contentExtent = pt;
  1415.  
  1416.     CHECKVALID(VOID);
  1417.     
  1418.     *contentExtent = _fContentExtent;
  1419. }
  1420.  
  1421. //------------------------------------------------------------------------------
  1422. // ODFrame: ChangeContentExtent
  1423. //------------------------------------------------------------------------------
  1424.  
  1425. SOM_Scope void  SOMLINK ODFrameChangeContentExtent(ODFrame *somSelf, Environment *ev,
  1426.         ODPoint* contentExtent)
  1427. {
  1428.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1429.     ODFrameMethodDebug("ODFrame","ChangeContentExtent");
  1430.  
  1431.     CHECKVALID( VOID );
  1432.     
  1433.     ODFrameFacetIterator* i = kODNULL; ODVolatile(i);
  1434.     SOM_TRY
  1435.         _fContentExtent = *contentExtent;
  1436.         
  1437.         // compute biasTransform of each facet's canvas
  1438.         i = somSelf->CreateFacetIterator(ev);    
  1439.         for (ODFacet* facet = i->First(ev); i->IsNotComplete(ev); facet = i->Next(ev))
  1440.         {
  1441.             if ( facet->HasCanvas(ev) )
  1442.                 facet->GetCanvas(ev)->ComputeBiasTransform(ev);
  1443.         }
  1444.         delete i;
  1445.     SOM_CATCH_ALL
  1446.         ODDeleteObject(i);
  1447.     SOM_ENDTRY
  1448. }
  1449.  
  1450. //------------------------------------------------------------------------------
  1451. // ODFrame: IsDroppable
  1452. //------------------------------------------------------------------------------
  1453.  
  1454. SOM_Scope ODBoolean  SOMLINK ODFrameIsDroppable(ODFrame *somSelf, Environment *ev)
  1455. {
  1456.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1457.     ODFrameMethodDebug("ODFrame","IsDroppable");
  1458.  
  1459.     CHECKVALID(kODFalse);
  1460.     
  1461.     return _fIsDroppable;
  1462. }
  1463.  
  1464. SOM_Scope void  SOMLINK ODFrameSetDroppable(ODFrame *somSelf, Environment *ev,
  1465.         ODBoolean isDroppable)
  1466. {
  1467.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1468.     ODFrameMethodDebug("ODFrame","SetDroppable");
  1469.  
  1470.     CHECKVALID( VOID );
  1471.     
  1472.     _fIsDroppable = isDroppable;
  1473. }
  1474.  
  1475. //------------------------------------------------------------------------------
  1476. // ODFrame: IsDragging
  1477. //------------------------------------------------------------------------------
  1478.  
  1479. SOM_Scope ODBoolean  SOMLINK ODFrameIsDragging(ODFrame *somSelf, Environment *ev)
  1480. {
  1481.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1482.     ODFrameMethodDebug("ODFrame","IsDragging");
  1483.  
  1484.     CHECKVALID(kODFalse);
  1485.     
  1486.     return _fIsDragging;
  1487. }
  1488.  
  1489. //------------------------------------------------------------------------------
  1490. // ODFrame: SetDragging
  1491. //------------------------------------------------------------------------------
  1492.  
  1493. SOM_Scope void  SOMLINK ODFrameSetDragging(ODFrame *somSelf, Environment *ev,
  1494.         ODBoolean isDragging)
  1495. {
  1496.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1497.     ODFrameMethodDebug("ODFrame","SetDragging");
  1498.  
  1499.     CHECKVALID( VOID );
  1500.     
  1501.     _fIsDragging = isDragging;
  1502. }
  1503.  
  1504. //------------------------------------------------------------------------------
  1505. // ODFrame: ContentUpdated
  1506. //------------------------------------------------------------------------------
  1507.  
  1508. SOM_Scope void  SOMLINK ODFrameContentUpdated(ODFrame *somSelf, Environment *ev,
  1509.         ODUpdateID change)
  1510. {
  1511.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1512.     ODFrameMethodDebug("ODFrame","ContentUpdated");
  1513.  
  1514.     CHECKVALID( VOID );
  1515.     
  1516.     SOM_TRY
  1517.         TempODFrame embeddedFrame = somSelf;
  1518.         TempODFrame containingFrame = somSelf->AcquireContainingFrame(ev);
  1519.         
  1520.         embeddedFrame->Acquire(ev); // will be released in loop below
  1521.         while ( containingFrame != kODNULL )
  1522.         {
  1523.             TempODPart containingPart = containingFrame->AcquirePart(ev);
  1524.             containingPart->EmbeddedFrameUpdated(ev, embeddedFrame, change);
  1525.             ODReleaseObject(ev, embeddedFrame);
  1526.             embeddedFrame = (ODFrame*) containingFrame; // do not bitwise copy!
  1527.             containingFrame = kODNULL; // avoid double Release in case following fails
  1528.             containingFrame = embeddedFrame->AcquireContainingFrame(ev);
  1529.         }
  1530.         ODReleaseObject(ev, embeddedFrame);
  1531.     SOM_CATCH_ALL
  1532.     SOM_ENDTRY
  1533. }
  1534.  
  1535. //------------------------------------------------------------------------------
  1536. // ODFrame: ChangeLinkStatus
  1537. //------------------------------------------------------------------------------
  1538.  
  1539. SOM_Scope void  SOMLINK ODFrameChangeLinkStatus(ODFrame *somSelf, Environment *ev,
  1540.         ODLinkStatus status)
  1541. {
  1542.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1543.     ODFrameMethodDebug("ODFrame","ChangeLinkStatus");
  1544.  
  1545.     CHECKVALID( VOID );
  1546.     
  1547.     SOM_TRY
  1548.         ODLinkStatus newStatus = _fLinkStatus;
  1549.         ODLinkStatus cfStatus = kODNotInLink;
  1550.  
  1551.         TempODFrame containingFrame = somSelf->AcquireContainingFrame(ev);
  1552.         if ( containingFrame == kODNULL )
  1553.         {
  1554.             // Loop looking for a containing frame in case the source frame
  1555.             // turns out to be the root frame of another window [cc]
  1556.             TempODFrame sourceFrame = somSelf;
  1557.             sourceFrame->Acquire(ev); // because it will be Released below
  1558.             do
  1559.             {
  1560.                 TempODWindow tempWindow = sourceFrame->AcquireWindow(ev);
  1561.                 sourceFrame = tempWindow->AcquireSourceFrame(ev);
  1562.                 if ( sourceFrame )
  1563.                 {
  1564.                     containingFrame = sourceFrame->AcquireContainingFrame(ev);
  1565.                 }
  1566.             }
  1567.             while ( (containingFrame == kODNULL) && (sourceFrame != kODNULL) );
  1568.         }
  1569.  
  1570.         if ( containingFrame )
  1571.         {
  1572.             cfStatus = containingFrame->GetLinkStatus(ev);
  1573.         }
  1574.  
  1575.         if ( (status != kODNotInLink)
  1576.                 && (status != kODInLinkSource)
  1577.                 && (status != kODInLinkDestination) )
  1578.             THROW(kODErrInvalidLinkStatus);        
  1579.         
  1580.         // the logic below will automatically fix the link status of an embedded
  1581.         // frame to be at least as restrictive as the status of its containing frame
  1582.         if ( cfStatus == kODNotInLink )
  1583.         {
  1584.             newStatus = status;
  1585.         }
  1586.         else if ( cfStatus == kODInLinkSource )
  1587.         {
  1588.             if ( status == kODInLinkDestination )
  1589.                 newStatus = kODInLinkDestination;
  1590.             else
  1591.                 newStatus = kODInLinkSource;
  1592.         }
  1593.         else if ( cfStatus == kODInLinkDestination )
  1594.         {
  1595.             newStatus = kODInLinkDestination;
  1596.         }
  1597.         else
  1598.             THROW(kODErrInvalidLinkStatus);        
  1599.         
  1600.         if ( _fLinkStatus != newStatus )
  1601.         {
  1602.             _fLinkStatus = newStatus;
  1603.             TempODPart tempPart = somSelf->AcquirePart(ev);
  1604.             tempPart->LinkStatusChanged(ev, somSelf);
  1605.         }
  1606.     
  1607.         // don't mark draft dirty, just mark property dirty
  1608.         _fDirty |= kLinkStatusDirty;
  1609.     SOM_CATCH_ALL
  1610.     SOM_ENDTRY
  1611. }
  1612.  
  1613. //------------------------------------------------------------------------------
  1614. // ODFrame: GetLinkStatus
  1615. //------------------------------------------------------------------------------
  1616.  
  1617. SOM_Scope ODLinkStatus  SOMLINK ODFrameGetLinkStatus(ODFrame *somSelf, Environment *ev)
  1618. {
  1619.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1620.     ODFrameMethodDebug("ODFrame","GetLinkStatus");
  1621.  
  1622.     CHECKVALID(kODFalse);
  1623.     
  1624.     return _fLinkStatus;
  1625. }
  1626.  
  1627. //------------------------------------------------------------------------------
  1628. // ODFrame: EditInLink
  1629. //------------------------------------------------------------------------------
  1630.  
  1631. SOM_Scope ODBoolean  SOMLINK ODFrameEditInLink(ODFrame *somSelf, Environment *ev)
  1632. {
  1633.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1634.     ODFrameMethodDebug("ODFrame","EditInLink");
  1635.  
  1636.     CHECKVALID(kODFalse);
  1637.     
  1638.     ODBoolean success = kODFalse;    ODVolatile(success);
  1639.  
  1640.     SOM_TRY    
  1641.         if ( _fLinkStatus == kODInLinkDestination )
  1642.         {
  1643.             TempODFrame lastFrame = somSelf;
  1644.             lastFrame->Acquire(ev); // because it will be Released below
  1645.             while ( kODTrue )
  1646.             {
  1647.                 TempODFrame nextFrame = lastFrame->AcquireContainingFrame(ev);
  1648.                 if ( nextFrame == kODNULL )
  1649.                 {
  1650.                     TempODWindow tempWindow = lastFrame->AcquireWindow(ev);
  1651.                     nextFrame = tempWindow->AcquireSourceFrame(ev);
  1652.                 }
  1653.                 if ( nextFrame == kODNULL )
  1654.                     break;
  1655.                 
  1656.                 // the test below should never be true if nextFrame is lastFrame's
  1657.                 // sourceFrame, therefore below nextFrame will always be the
  1658.                 // containing frame of lastFrame
  1659.                 if ( nextFrame->GetLinkStatus(ev) != kODInLinkDestination )
  1660.                 {
  1661.                     TempODPart tempPart = nextFrame->AcquirePart(ev);
  1662.                     success = tempPart->EditInLinkAttempted(ev, lastFrame);
  1663.                     break;
  1664.                 }
  1665.                 else
  1666.                 {
  1667.                     ODReleaseObject(ev, lastFrame);
  1668.                     lastFrame = (ODFrame*) nextFrame; // do not bitwise copy!
  1669.                     nextFrame = kODNULL; // to prevent Release on loop
  1670.                 }
  1671.             }
  1672.         }
  1673.     SOM_CATCH_ALL
  1674.         success = kODFalse;
  1675.     SOM_ENDTRY
  1676.     return success;
  1677. }
  1678.  
  1679. //------------------------------------------------------------------------------
  1680. // ODFrame: Invalidate
  1681. //------------------------------------------------------------------------------
  1682.  
  1683. SOM_Scope void  SOMLINK ODFrameInvalidate(ODFrame *somSelf, Environment *ev,
  1684.         ODShape* invalidShape, ODCanvas* biasCanvas)
  1685. {
  1686.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1687.     ODFrameMethodDebug("ODFrame","Invalidate");
  1688.  
  1689.     CHECKVALID( VOID );
  1690.     
  1691.     ODFrameFacetIterator* i = kODNULL; ODVolatile(i);
  1692.     SOM_TRY
  1693.         i = somSelf->CreateFacetIterator(ev);    
  1694.         for (ODFacet* facet = i->First(ev); i->IsNotComplete(ev); facet = i->Next(ev))
  1695.             facet->Invalidate(ev, invalidShape, biasCanvas);
  1696.         delete i;
  1697.     SOM_CATCH_ALL
  1698.         ODDeleteObject(i);
  1699.     SOM_ENDTRY
  1700. }
  1701.  
  1702. //------------------------------------------------------------------------------
  1703. // ODFrame: Validate
  1704. //------------------------------------------------------------------------------
  1705.  
  1706. SOM_Scope void  SOMLINK ODFrameValidate(ODFrame *somSelf, Environment *ev,
  1707.         ODShape* validShape, ODCanvas* biasCanvas)
  1708. {
  1709.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1710.     ODFrameMethodDebug("ODFrame","Validate");
  1711.  
  1712.     CHECKVALID( VOID );
  1713.     
  1714.     ODFrameFacetIterator* i = kODNULL; ODVolatile(i);
  1715.     SOM_TRY
  1716.         i = somSelf->CreateFacetIterator(ev);    
  1717.         for (ODFacet* facet = i->First(ev); i->IsNotComplete(ev); facet = i->Next(ev))
  1718.             facet->Validate(ev, validShape, biasCanvas);
  1719.         delete i;
  1720.     SOM_CATCH_ALL
  1721.         ODDeleteObject(i);
  1722.     SOM_ENDTRY
  1723. }
  1724.  
  1725.  
  1726. //------------------------------------------------------------------------------
  1727. // ODFrame: InvalidateActiveBorder
  1728. //------------------------------------------------------------------------------
  1729. SOM_Scope void  SOMLINK ODFrameInvalidateActiveBorder(ODFrame *somSelf, Environment *ev)
  1730. {
  1731.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1732.     ODFrameMethodDebug("ODFrame","InvalidateActiveBorder");
  1733.  
  1734.     CHECKVALID( VOID );
  1735.     
  1736.     if ( _fIsRoot )        // don't draw for root frame with subframes
  1737.         return;
  1738.     
  1739.     ODFrameFacetIterator* i = kODNULL; ODVolatile(i);
  1740.     SOM_TRY
  1741.         if ( _fIsSubframe )
  1742.         {
  1743.             // don't draw for subframes. instead, have containingFrame draw
  1744.             TempODFrame containingFrame = somSelf->AcquireContainingFrame(ev);
  1745.             containingFrame->InvalidateActiveBorder(ev);
  1746.         }
  1747.         else
  1748.         {
  1749.             // draw active border on all my facets
  1750.             i = somSelf->CreateFacetIterator(ev);
  1751.             for ( ODFacet* facet = i->First(ev);
  1752.                     i->IsNotComplete(ev);
  1753.                     facet = i->Next(ev) )
  1754.             {
  1755.                 facet->InvalidateActiveBorder(ev);
  1756.             }
  1757.             ODDeleteObject(i);
  1758.         }
  1759.     SOM_CATCH_ALL
  1760.         ODDeleteObject(i);
  1761.     SOM_ENDTRY
  1762. }
  1763.  
  1764. //------------------------------------------------------------------------------
  1765. // ODFrame: DrawActiveBorder
  1766. //------------------------------------------------------------------------------
  1767.  
  1768. SOM_Scope void  SOMLINK ODFrameDrawActiveBorder(ODFrame *somSelf, Environment *ev)
  1769. {
  1770.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1771.     ODFrameMethodDebug("ODFrame","DrawActiveBorder");
  1772.  
  1773.     CHECKVALID( VOID );
  1774.     
  1775.     if ( _fIsRoot )        // don't draw for root frame with subframes
  1776.         return;
  1777.  
  1778.     ODFrameFacetIterator* i = kODNULL; ODVolatile(i);
  1779.     SOM_TRY
  1780.         if ( _fIsSubframe )
  1781.         {
  1782.             // don't draw for subframes. instead, have containingFrame draw
  1783.             TempODFrame containingFrame = somSelf->AcquireContainingFrame(ev);
  1784.             containingFrame->DrawActiveBorder(ev);
  1785.         }
  1786.         else
  1787.         {
  1788.             // draw active border on all my facets
  1789.             i = somSelf->CreateFacetIterator(ev);
  1790.             for ( ODFacet* facet = i->First(ev);
  1791.                     i->IsNotComplete(ev);
  1792.                     facet = i->Next(ev) )
  1793.             {
  1794.                 facet->DrawActiveBorder(ev);
  1795.             }
  1796.             delete i;
  1797.         }
  1798.     SOM_CATCH_ALL
  1799.         ODDeleteObject(i);
  1800.     SOM_ENDTRY
  1801. }
  1802.  
  1803. //------------------------------------------------------------------------------
  1804. // ODFrame: Release
  1805. //------------------------------------------------------------------------------
  1806.  
  1807. SOM_Scope void  SOMLINK ODFrameRelease(ODFrame *somSelf, Environment *ev)
  1808. {
  1809.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1810.     ODFrameMethodDebug("ODFrame","Release");
  1811.  
  1812.     // *DON'T* CHECKVALID - need to be able to release invalid frames
  1813.  
  1814.     SOM_TRY
  1815.         if ( (somSelf->GetRefCount(ev) == 1) &&
  1816.             (_fValidState & kFrameIsRemoved) &&
  1817.             !(_fValidState & kFrameIsInRelease) &&
  1818.             somSelf->GetStorageUnit(ev) )
  1819.         {
  1820.             // remove persistent frames previously removed which are
  1821.             // finally unreferenced
  1822.             _fValidState |= kFrameIsInRelease;
  1823.             _fDraft->RemoveFrame(ev, somSelf);
  1824.         }
  1825.         else
  1826.         {
  1827.             parent_Release(somSelf, ev);
  1828.             if (somSelf->GetRefCount(ev) == 0)
  1829.             {
  1830.                 // only release frames previously closed or non-persistent
  1831.                 _fDraft->ReleaseFrame(ev, somSelf);
  1832.                 _fValidState &= ~kFrameIsInRelease;
  1833.             }
  1834.         }
  1835.     SOM_CATCH_ALL
  1836.     SOM_ENDTRY
  1837. }
  1838.  
  1839. //------------------------------------------------------------------------------
  1840. // ODFrame: Close
  1841. //------------------------------------------------------------------------------
  1842.  
  1843. SOM_Scope void  SOMLINK ODFrameClose(ODFrame *somSelf, Environment *ev)
  1844. {
  1845.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1846.     ODFrameMethodDebug("ODFrame","Close");
  1847.  
  1848.     CHECKVALID( VOID );
  1849.  
  1850.     ODFrameFacetIterator* i = kODNULL; ODVolatile(i);
  1851.  
  1852.     SOM_TRY
  1853.         if ( _fPart ) // if fPart not already internalized, don't force it
  1854.         {
  1855.             i = somSelf->CreateFacetIterator(ev);
  1856.             for (ODFacet* facet = i->First(ev); i->IsNotComplete(ev); facet = i->Next(ev))
  1857.                 _fPart->FacetRemoved(ev, facet);
  1858.             ODDeleteObject(i);
  1859.         
  1860.             TRY
  1861.                 _fPart->DisplayFrameClosed(ev, somSelf);
  1862.             CATCH_ALL
  1863.                 WARN("Part returned err %d closing frame",ErrorCode());
  1864.                 // don't reraise
  1865.             ENDTRY
  1866.             ODReleaseObject(ev,_fPart);
  1867.         }
  1868.         ODReleaseObject(ev, _fContainingFrame);
  1869.         ODReleaseObject(ev, _fWindow);
  1870.         somSelf->Release(ev);
  1871.     SOM_CATCH_ALL
  1872.         ODDeleteObject(i);
  1873.     SOM_ENDTRY
  1874. }
  1875.  
  1876. //------------------------------------------------------------------------------
  1877. // ODFrame: Remove
  1878. //------------------------------------------------------------------------------
  1879.  
  1880. SOM_Scope void  SOMLINK ODFrameRemove(ODFrame *somSelf, Environment *ev)
  1881. {
  1882.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1883.     ODFrameMethodDebug("ODFrame","Remove");
  1884.  
  1885.     CHECKVALID( VOID );
  1886.  
  1887.     ODFrameFacetIterator* i = kODNULL; ODVolatile(i);
  1888.  
  1889.     SOM_TRY
  1890.         if ( _fPart == kODNULL )
  1891.             somSelf->AcquirePart(ev)->Release(ev);    // force internalization of fPart
  1892.  
  1893.         if ( _fFacets->Count() != 0 )
  1894.             THROW(kODErrFrameHasFacets);
  1895.         
  1896.         TRY
  1897.             _fPart->DisplayFrameRemoved(ev, somSelf);
  1898.         CATCH_ALL
  1899.             WARN("Part returned err %d removing frame",ErrorCode());
  1900.             // don't reraise
  1901.         ENDTRY
  1902.         
  1903.         ODReleaseObject(ev, _fPart);
  1904.         ODReleaseObject(ev, _fContainingFrame);
  1905.         ODReleaseObject(ev, _fWindow);
  1906.         
  1907.         if (somSelf->GetRefCount(ev) == 1)
  1908.         {
  1909.             _fDraft->RemoveFrame(ev, somSelf);
  1910.         }
  1911.         else
  1912.         {
  1913.             somSelf->Release(ev);
  1914.             _fValidState = kFrameIsRemoved;
  1915.         }
  1916.     SOM_CATCH_ALL
  1917.         ODDeleteObject(i);
  1918.     SOM_ENDTRY
  1919. }
  1920.  
  1921. //------------------------------------------------------------------------------
  1922. // ODFrame: Purge
  1923. //------------------------------------------------------------------------------
  1924.  
  1925. SOM_Scope ODSize  SOMLINK ODFramePurge(ODFrame *somSelf, Environment *ev,
  1926.         ODSize numBytes)
  1927. {
  1928.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1929.     ODFrameMethodDebug("ODFrame","Purge");
  1930.  
  1931.     // *DON'T* CHECKVALID - still need to purge invalid frames
  1932.  
  1933.     ODSize freed = 0;                    ODVolatile(freed);
  1934.     ODFrameFacetIterator* i = kODNULL;    ODVolatile(i);
  1935.  
  1936.     SOM_TRY
  1937.         // purge geometric objects
  1938.         if ( _fFrameShape != kODNULL )
  1939.             freed += _fFrameShape->Purge(ev, numBytes-freed);
  1940.         if ( _fUsedShape != kODNULL )
  1941.             freed += _fUsedShape->Purge(ev, numBytes-freed);
  1942.         if ( _fInternalTransform != kODNULL )
  1943.             freed += _fInternalTransform->Purge(ev, numBytes-freed);
  1944.         
  1945.         if ( _fValidState == kFrameIsValid )
  1946.         {
  1947.             // purge facets
  1948.             i = new ODFrameFacetIterator;
  1949.             THROW_IF_NULL(i);
  1950.             i->InitFrameFacetIterator(ev, somSelf);
  1951.             for ( ODFacet* facet = i->First(ev);
  1952.                     i->IsNotComplete(ev);
  1953.                     facet = i->Next(ev) )
  1954.             {
  1955.                 freed += facet->Purge(ev, numBytes-freed);
  1956.             }
  1957.             ODDeleteObject(i);
  1958.         }
  1959.         
  1960.         // dh - call parent's purge method
  1961.         freed += parent_Purge(somSelf, ev, numBytes);
  1962.         
  1963.     SOM_CATCH_ALL
  1964.         ODDeleteObject(i);
  1965.         WARN("Error %ld trying to purge in ODFramePurge",ErrorCode());
  1966.         SetErrorCode(kODNoError);        // dh - Eat the exception; Purge should not 
  1967.                                         // propagate it because clients function
  1968.                                         // fine whether memory was purged or not.
  1969.     SOM_ENDTRY
  1970.  
  1971.     return freed;
  1972. }
  1973.  
  1974. //------------------------------------------------------------------------------
  1975. // WriteShapeIfAny  [static]
  1976. //------------------------------------------------------------------------------
  1977.  
  1978. static void
  1979. WriteShapeIfAny( Environment *ev, ODStorageUnit *su, ODShape *shape, ODPropertyName property )
  1980. {
  1981.     if (shape) {
  1982.         su->Focus(ev, property, kODPosUndefined, kODNULL, (ODValueIndex)0, kODPosUndefined);
  1983.          shape->WriteShape(ev, su);
  1984.     } else if (su->Exists(ev, property, kODNULL, 1)) {
  1985.         su->Focus(ev, property, kODPosUndefined, kODNULL, (ODValueIndex)1, kODPosUndefined);
  1986.         su->DeleteValue(ev, su->GetSize(ev));
  1987.     }
  1988. }
  1989.  
  1990. //------------------------------------------------------------------------------
  1991. // ODFrame: Externalize
  1992. //------------------------------------------------------------------------------
  1993.  
  1994. SOM_Scope void  SOMLINK ODFrameExternalize(ODFrame *somSelf, Environment *ev)
  1995. {
  1996.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1997.     ODFrameMethodDebug("ODFrame","Externalize");
  1998.  
  1999.     // *DON'T* CHECKVALID - need to write an "I'm invalid" representation
  2000.  
  2001.     SOM_TRY
  2002.         ODStorageUnit* su = kODNULL;
  2003.         ODSession* session = kODNULL;
  2004.         ODISOStr typeString = kODNULL;
  2005.         
  2006.         su = somSelf->GetStorageUnit(ev);
  2007.         if ( su == kODNULL) return;        // don't externalize non-persistent frames
  2008.         
  2009.         parent_Externalize(somSelf, ev);
  2010.     
  2011.         session = su->GetSession(ev);
  2012.         
  2013.         // if frame is invalid because of removal, delete Part property to
  2014.         // indicate persistently that frame is invalid.
  2015.         if ( _fDirty && _fValidState )
  2016.         {
  2017.             ODSURemoveProperty(ev, su, kODPropPart);
  2018.             ODSURemoveProperty(ev, su, kODPropContainingFrame);
  2019.             _fDirty = kNotDirty;
  2020.             return;
  2021.         }
  2022.     
  2023.         if ( _fDirty & kContainingFrameDirty )
  2024.         {
  2025.             // can't write suRef to non-persistent containingFrame
  2026.             if ( _fContainingFrame && _fContainingFrame->GetStorageUnit(ev) )
  2027.                 ODSetWeakSURefProp(ev, su, kODPropContainingFrame, kODWeakStorageUnitRef, 
  2028.                                     _fContainingFrame->GetStorageUnit(ev)->GetID(ev));
  2029.             else
  2030.             {
  2031.                 if ( ODSUExistsThenFocus(ev, su, kODPropContainingFrame, kODWeakStorageUnitRef) )
  2032.                     su->Remove(ev);
  2033.                 ODSUAddPropValue(ev, su, kODPropContainingFrame, kODWeakStorageUnitRef);
  2034.             }
  2035.         }
  2036.         
  2037.         // geometry
  2038.         
  2039.         // no bias transform needed, already in standard bias
  2040.         ODSURemoveProperty(ev, su, kODPropBiasTransform);
  2041.     
  2042.         if ( _fDirty & kFrameShapeDirty )
  2043.         {
  2044.             su->Focus(ev, kODPropFrameShape, kODPosUndefined, kODNULL, (ODValueIndex)0, kODPosUndefined);
  2045.             _fFrameShape->WriteShape(ev, su);
  2046.         }
  2047.         
  2048.         if ( _fDirty & kInternalTransformDirty )
  2049.         {
  2050.             su->Focus(ev, kODPropInternalTransform, kODPosUndefined, kODNULL, (ODValueIndex)0, kODPosUndefined);
  2051.             _fInternalTransform->WriteTo(ev, su);
  2052.         }
  2053.         
  2054.         // part & partInfo
  2055.         
  2056.         if ( _fDirty & kPartDirty )
  2057.         {
  2058.             ASSERT( _fPart, kODErrInvalidFrame);
  2059.             ODSetStrongSURefProp(ev, su, kODPropPart, kODStrongStorageUnitRef, _fPart->GetID(ev));
  2060.         }
  2061.         
  2062.         // always try to write partInfo, part knows if it's dirty
  2063.         if ( _fPart ) // only have to write partInfo if part has been internalized
  2064.         {
  2065.             su->Focus(ev, kODPropPartInfo, kODPosUndefined, kODNULL, (ODValueIndex)0, kODPosUndefined);
  2066.             TempODStorageUnitView suView = su->CreateView(ev);
  2067.             _fPart->WritePartInfo(ev, (ODInfoType)_fPartInfo, suView);
  2068.         }
  2069.         
  2070.         // viewType & presentation
  2071.         
  2072.         if ( _fDirty & kViewTypeDirty )
  2073.         {
  2074.             if ( (_fViewType != kODNULL) && session->GetType(ev, _fViewType, &typeString) )
  2075.             {
  2076.                 ODSetISOStrProp(ev, su, kODPropViewType, kODISOStr, typeString);
  2077.                 delete typeString; typeString = kODNULL;
  2078.             }
  2079.         }
  2080.         
  2081.         if ( _fDirty & kPresentationDirty )
  2082.         {
  2083.             if ( (_fPresentation != kODNULL) && session->GetType(ev, _fPresentation, &typeString) )
  2084.             {
  2085.                 ODSetISOStrProp(ev, su, kODPropPresentation, kODISOStr, typeString);
  2086.                 delete typeString; typeString = kODNULL;
  2087.             }
  2088.         }
  2089.         
  2090.         if ( _fDirty & kFrameGroupDirty )
  2091.             ODSetULongProp(ev, su, kODPropFrameGroup, kODULong, _fFrameGroup);
  2092.         if ( _fDirty & kSequenceNumberDirty )
  2093.             ODSetULongProp(ev, su, kODPropSequenceNumber, kODULong, _fSequenceNumber);
  2094.         if ( _fDirty & kLinkStatusDirty )
  2095.             ODSetULongProp(ev, su, kODPropLinkStatus, kODULong, _fLinkStatus);
  2096.     
  2097.         if ( _fDirty & kFlagsDirty )
  2098.         {
  2099.             ODSetBooleanProp(ev, su, kODPropIsSubframe, kODBoolean, _fIsSubframe);
  2100.             ODSetBooleanProp(ev, su, kODPropIsOverlaid, kODBoolean, _fIsOverlaid);
  2101.             ODSetBooleanProp(ev, su, kODPropIsFrozen, kODBoolean, _fIsFrozen);
  2102.         }
  2103.     
  2104.         _fDirty = kNotDirty;
  2105.     SOM_CATCH_ALL
  2106.     SOM_ENDTRY
  2107. }
  2108.  
  2109. //------------------------------------------------------------------------------
  2110. // ODFrame: CloneInto
  2111. //------------------------------------------------------------------------------
  2112.  
  2113. SOM_Scope void  SOMLINK ODFrameCloneInto(ODFrame *somSelf, Environment *ev,
  2114.         ODDraftKey key,
  2115.         ODStorageUnit* toSU,
  2116.         ODFrame* scopeFrame)
  2117. {
  2118.     ODFrameData *somThis = ODFrameGetData(somSelf);
  2119.     ODFrameMethodDebug("ODFrame","CloneInto");
  2120.  
  2121.     // *DON'T* CHECKVALID - need to write an "I'm invalid" representation
  2122.  
  2123.     SOM_TRY    
  2124.         if ( kODNULL == toSU ) THROW(kODErrIllegalNullInput);
  2125.     
  2126.         ODStorageUnitID        fromSUID = somSelf->GetID(ev);
  2127.         ODDraft*            fromDraft = _fDraft;
  2128.         ODISOStr            typeString = kODNULL;
  2129.     
  2130.         if (toSU->Exists(ev, kODPropFrameShape, kODNULL, 0) == kODFalse)
  2131.         {
  2132.             parent_CloneInto(somSelf, ev, key, toSU, scopeFrame);
  2133.             
  2134.             // if frame is invalid because of removal, don't write Part
  2135.             // Property to indicate that frame is invalid.
  2136.             if ( _fValidState )
  2137.                 return;
  2138.  
  2139.             if (_fContainingFrame)
  2140.             {
  2141.                 ODID toContainingFrameID = fromDraft->WeakClone(ev, key, _fContainingFrame->GetID(ev), 0, 0);
  2142.                 ODSetWeakSURefProp(ev, toSU, kODPropContainingFrame, kODWeakStorageUnitRef, 
  2143.                                     toContainingFrameID);
  2144.             }
  2145.             
  2146.             toSU->AddProperty(ev, kODPropFrameShape);
  2147.             _fFrameShape->WriteShape(ev, toSU);
  2148.             
  2149.             ODSUAddPropValue(ev, toSU, kODPropInternalTransform, kODTransform);
  2150.             _fInternalTransform->WriteTo(ev, toSU);
  2151.             
  2152.             // part & partInfo
  2153.             
  2154.             if ( _fPart == kODNULL )
  2155.                 somSelf->AcquirePart(ev)->Release(ev); // force internalization of fPart
  2156.  
  2157.             ODID toPartID = fromDraft->Clone(ev, key, _fPart->GetID(ev), 0, (scopeFrame ? scopeFrame->GetID(ev) : 0));
  2158.             ODSetStrongSURefProp(ev, toSU, kODPropPart, kODStrongStorageUnitRef, toPartID);
  2159.         
  2160.             toSU->AddProperty(ev, kODPropPartInfo);
  2161.             {
  2162.                 TempODStorageUnitView suView = toSU->CreateView(ev);
  2163.                 _fPart->ClonePartInfo(ev, key, (ODInfoType)_fPartInfo, suView, scopeFrame);
  2164.             }
  2165.             
  2166.     
  2167.             // Window Properties
  2168.             ODStorageUnit* fromSU = somSelf->GetStorageUnit(ev);
  2169.             if (fromSU && _fIsRoot)
  2170.             {
  2171.                 ODID windowPropsID;
  2172.                 if ((windowPropsID = ODGetStrongSURefProp(ev, fromSU, kODPropWindowProperties, kODStrongStorageUnitRef))
  2173.                     != 0)
  2174.                 {                
  2175.                     ODID toWindowPropsID = fromDraft->Clone(ev, key, windowPropsID, 0, (scopeFrame ? scopeFrame->GetID(ev) : 0));
  2176.                     ODSetStrongSURefProp(ev, toSU, kODPropWindowProperties, kODStrongStorageUnitRef, toWindowPropsID);
  2177.                 }
  2178.             }
  2179.             // viewType & presentation
  2180.             
  2181.             ODSession* session = toSU->GetSession(ev);
  2182.             
  2183.             ASSERT(_fViewType, kODErrInvalidFrame);
  2184.             if ( (_fViewType != kODNULL) && session->GetType(ev, _fViewType, &typeString) )
  2185.             {
  2186.                 ODSetISOStrProp(ev, toSU, kODPropViewType, kODISOStr, typeString);
  2187.                 delete typeString; typeString = kODNULL;
  2188.             }
  2189.         
  2190.             ASSERT(_fPresentation, kODErrInvalidFrame);
  2191.             if ( (_fPresentation != kODNULL) && session->GetType(ev, _fPresentation, &typeString) )
  2192.             {
  2193.                 ODSetISOStrProp(ev, toSU, kODPropPresentation, kODISOStr, typeString);
  2194.                 delete typeString; typeString = kODNULL;
  2195.             }
  2196.         
  2197.             ODSetULongProp(ev, toSU, kODPropFrameGroup, kODULong, _fFrameGroup);
  2198.             ODSetULongProp(ev, toSU, kODPropSequenceNumber, kODULong, _fSequenceNumber);
  2199.             ODSetULongProp(ev, toSU, kODPropLinkStatus, kODULong, _fLinkStatus);
  2200.             ODSetBooleanProp(ev, toSU, kODPropIsSubframe, kODBoolean, _fIsSubframe);
  2201.             ODSetBooleanProp(ev, toSU, kODPropIsOverlaid, kODBoolean, _fIsOverlaid);
  2202.             ODSetBooleanProp(ev, toSU, kODPropIsFrozen, kODBoolean, _fIsFrozen);
  2203.         }
  2204.         else
  2205.         {
  2206.             if ( _fPart == kODNULL )
  2207.                 somSelf->AcquirePart(ev)->Release(ev); // force internalization of fPart
  2208.             ODID toPartID = fromDraft->Clone(ev, key, _fPart->GetID(ev), 0, (scopeFrame ? scopeFrame->GetID(ev) : 0));
  2209.         }
  2210.     SOM_CATCH_ALL
  2211.     SOM_ENDTRY
  2212. }
  2213.  
  2214. //------------------------------------------------------------------------------
  2215. // ODFrame: GetFacets
  2216. //------------------------------------------------------------------------------
  2217.  
  2218. SOM_Scope OrderedCollection*  SOMLINK ODFrameGetFacets(ODFrame *somSelf, Environment *ev)
  2219. {
  2220.     ODFrameData *somThis = ODFrameGetData(somSelf);
  2221.     ODFrameMethodDebug("ODFrame","GetFacets");
  2222.  
  2223.     CHECKVALID(kODNULL);
  2224.  
  2225.     return _fFacets;
  2226. }
  2227.  
  2228. //------------------------------------------------------------------------------
  2229. // ODFrame: PrepareToSwap
  2230. //------------------------------------------------------------------------------
  2231.  
  2232. SOM_Scope void  SOMLINK ODFramePrepareToSwap(ODFrame *somSelf, Environment *ev,
  2233.         ODPart* part)
  2234. {
  2235.     ODFrameData *somThis = ODFrameGetData(somSelf);
  2236.     ODFrameMethodDebug("ODFrame","PrepareToSwap");
  2237.  
  2238.     CHECKVALID( VOID );
  2239.  
  2240.     SOM_TRY
  2241.         ODBoolean swappingMyPart = kODFalse;
  2242.         
  2243.         if ( _fPart )
  2244.             swappingMyPart = ODObjectsAreEqual(ev, part, _fPart);
  2245.         else
  2246.         {
  2247.             ODStorageUnit* su = somSelf->GetStorageUnit(ev);
  2248.             if ( su )
  2249.             {
  2250.                 ODID myPartID = ODGetStrongSURefProp(ev, su, kODPropPart,
  2251.                                                         kODStrongStorageUnitRef);
  2252.                 swappingMyPart = ( part->GetID(ev) == myPartID );
  2253.             }
  2254.         }
  2255.         
  2256.         if ( swappingMyPart )
  2257.         {
  2258.             if ( _fIsRoot && _fWindow )
  2259.             {
  2260.                 _fWindow->Acquire(ev);    // balanced by Release in Close below
  2261.                 _fWindow->Close(ev);
  2262.                 _fWindow = kODNULL;
  2263.             }
  2264.             else
  2265.             {
  2266.                 somSelf->Acquire(ev);  // because Close calls Release on self
  2267.                 somSelf->Close(ev);
  2268.             }
  2269.         }
  2270.     SOM_CATCH_ALL
  2271.     SOM_ENDTRY
  2272. }
  2273.  
  2274.  
  2275. //------------------------------------------------------------------------------
  2276. // ODFrame: SetDirty
  2277. //------------------------------------------------------------------------------
  2278.  
  2279. SOM_Scope void  SOMLINK ODFrameSetDirty(ODFrame *somSelf, Environment *ev,
  2280.                                         ODULong dirtyProperty)
  2281. {
  2282.     ODFrameData *somThis = ODFrameGetData(somSelf);
  2283.     ODFrameMethodDebug("ODFrame","SetDirty");
  2284.  
  2285.     SOM_TRY
  2286.         if ( somSelf->GetStorageUnit(ev) ) // don't set non-persistent frames dirty
  2287.         {
  2288.             _fDirty |= dirtyProperty;
  2289.             if (HAS_WRITE_ACCESS(_fDraft->GetPermissions(ev)))
  2290.             {
  2291.                 _fDraft->SetChangedFromPrev(ev);
  2292.             }
  2293.         }
  2294.     SOM_CATCH_ALL
  2295.     SOM_ENDTRY
  2296. }
  2297.  
  2298. //------------------------------------------------------------------------------
  2299. // ODFrame: CommonInitFrame
  2300. //------------------------------------------------------------------------------
  2301.  
  2302. SOM_Scope void  SOMLINK ODFrameCommonInitFrame(ODFrame *somSelf, Environment *ev)
  2303. {
  2304.     ODFrameData *somThis = ODFrameGetData(somSelf);
  2305.     ODFrameMethodDebug("ODFrame","CommonInitFrame");
  2306.  
  2307.     SOM_TRY
  2308.         _fFacets = new OrderedCollection;
  2309.           THROW_IF_NULL(_fFacets);
  2310.     SOM_CATCH_ALL
  2311.     SOM_ENDTRY
  2312. }
  2313.  
  2314. //------------------------------------------------------------------------------
  2315. // ODFrame: InitFrame
  2316. //------------------------------------------------------------------------------
  2317. SOM_Scope void  SOMLINK ODFrameInitFrame(ODFrame *somSelf, Environment *ev,
  2318.         
  2319.                 ODStorageUnit*    storageUnit,
  2320.                 ODFrame*         containingFrame,
  2321.                 ODShape*         frameShape,
  2322.                 ODCanvas*        biasCanvas,
  2323.                 ODPart*         part,
  2324.                 ODTypeToken        viewType,
  2325.                 ODTypeToken        presentation,
  2326.                 ODBoolean        isSubframe,
  2327.                 ODBoolean         isOverlaid)
  2328. {
  2329.     ODFrameData *somThis = ODFrameGetData(somSelf);
  2330.     ODFrameMethodDebug("ODFrame","InitFrame");
  2331.  
  2332.     /* Moved from somInit. SOM itself sets fields to zero
  2333.     _fDraft             = kODNULL;
  2334.     _fNPID                = 0;
  2335.     _fDirty                = kNotDirty;
  2336.  
  2337.     _fContainingFrame     = kODNULL;
  2338.     _fWindow             = kODNULL;
  2339.  
  2340.     _fFrameShape        = (ODShape*) kODNULL;
  2341.     _fUsedShape            = (ODShape*) kODNULL;
  2342.  
  2343.     _fInternalTransform    = (ODTransform*) kODNULL;    
  2344.  
  2345.     _fFacets            = kODNULL;
  2346.  
  2347.     _fPart                = kODNULL;
  2348.     _fPartInfo            = (ODInfoType) kODNULL;
  2349.     _fViewType            = (ODTypeToken) 0;
  2350.     _fPresentation        = (ODTypeToken) 0;
  2351.  
  2352.     _fFrameGroup        = 0;
  2353.     _fSequenceNumber    = 0;
  2354.  
  2355.     _fLinkStatus        = kODNotInLink;
  2356.     _fIsRoot            = kODFalse;
  2357.     _fIsSubframe         = kODFalse;
  2358.     _fIsOverlaid          = kODFalse;
  2359.     _fIsFrozen             = kODFalse;
  2360.     _fIsDroppable         = kODFalse;
  2361.     _fIsDragging         = kODFalse;
  2362.     _fDoesPropagateEvents =    kODFalse;
  2363.     */
  2364.     _fDirty                = kNotDirty;
  2365.     _fLinkStatus        = kODNotInLink;
  2366.     _fValidState        = kFrameIsValid;
  2367.     
  2368.     // *DON'T* CHECKVALID - new frames will never be invalid
  2369.     
  2370.     SOM_TRY
  2371.         if ( kODNULL == storageUnit )    THROW(kODErrIllegalNullStorageUnitInput);
  2372.         if ( kODNULL == frameShape    )    THROW(kODErrIllegalNullShapeInput);
  2373.         if ( kODNULL == part )            THROW(kODErrIllegalNullPartInput);
  2374.         if ( kODNULL == viewType )        THROW(kODErrIllegalNullTokenInput);
  2375.         if ( kODNULL == presentation )    THROW(kODErrIllegalNullTokenInput);
  2376.     
  2377.         // check for recursive embedding
  2378.         if ( (containingFrame != kODNULL) && !isSubframe )
  2379.         {
  2380.             TempODFrame tempFrame = containingFrame;
  2381.             tempFrame->Acquire(ev);   // because it will be released below
  2382.             while ( tempFrame )
  2383.             {
  2384.                 TempODPart tempPart = tempFrame->AcquirePart(ev);
  2385.                 if (tempPart == part)
  2386.                     THROW(kODErrIllegalRecursiveEmbedding);
  2387.                 ODFrame* spam = tempFrame;
  2388.                 TempODFrame oldFrame = spam;
  2389.                 tempFrame = kODNULL; // to avoid double Release if following fails
  2390.                 tempFrame = oldFrame->AcquireContainingFrame(ev);
  2391.             }
  2392.         }
  2393.         
  2394.         somSelf->InitPersistentObject(ev, storageUnit);
  2395.         _fDraft = storageUnit->GetDraft(ev);
  2396.         
  2397.         _fContainingFrame = containingFrame;
  2398.         ODAcquireObject(ev, _fContainingFrame);
  2399.     
  2400.         _fFrameShape = BiasShapeSet(ev, frameShape, biasCanvas);
  2401.         ODAcquireObject(ev, _fFrameShape);
  2402.     
  2403.         _fInternalTransform    = somSelf->CreateTransform(ev);
  2404.         _fContentExtent        = ODPoint(0,0);
  2405.     
  2406.         _fViewType        = viewType;
  2407.         _fPresentation    = presentation;
  2408.         _fIsRoot        = (containingFrame == kODNULL);
  2409.         _fIsSubframe    = isSubframe;
  2410.         _fIsOverlaid     = isOverlaid;
  2411.     
  2412.         somSelf->CommonInitFrame(ev);
  2413.         
  2414.         ODSUAddPropValue(ev, storageUnit, kODPropContainingFrame, kODWeakStorageUnitRef);
  2415.         ODSUAddPropValue(ev, storageUnit, kODPropFrameShape, kODPolygon);
  2416.         ODSUAddPropValue(ev, storageUnit, kODPropInternalTransform, kODTransform);
  2417.         ODSUAddPropValue(ev, storageUnit, kODPropPart, kODStrongStorageUnitRef);
  2418.     //    ODSUAddPropValue(ev, storageUnit, kODPropPartInfo, kODPartInfo);
  2419.         ODSUAddPropValue(ev, storageUnit, kODPropViewType, kODISOStr);
  2420.         ODSUAddPropValue(ev, storageUnit, kODPropPresentation, kODISOStr);
  2421.         ODSUAddPropValue(ev, storageUnit, kODPropFrameGroup, kODULong);
  2422.         ODSUAddPropValue(ev, storageUnit, kODPropSequenceNumber, kODULong);
  2423.         ODSUAddPropValue(ev, storageUnit, kODPropLinkStatus, kODULong);
  2424.         ODSUAddPropValue(ev, storageUnit, kODPropIsSubframe, kODBoolean);
  2425.         ODSUAddPropValue(ev, storageUnit, kODPropIsOverlaid, kODBoolean);
  2426.         ODSUAddPropValue(ev, storageUnit, kODPropIsFrozen, kODBoolean);
  2427.     
  2428.         _fPart = part;
  2429.         ODAcquireObject(ev, _fPart);
  2430.         _fPart->DisplayFrameAdded(ev, somSelf);
  2431.             
  2432.         somSelf->SetDirty(ev, kAllDirty);
  2433.     SOM_CATCH_ALL
  2434.     SOM_ENDTRY
  2435. }
  2436.  
  2437. //------------------------------------------------------------------------------
  2438. // ReadAndAcquireShapeIfAny  [static]
  2439. //------------------------------------------------------------------------------
  2440.  
  2441. static ODShape* // DMc refcount - include "acquire" in function name:
  2442. ReadAndAcquireShapeIfAny( Environment *ev, ODStorageUnit *su, ODPropertyName property )
  2443. {
  2444.     ODShape* shape = kODNULL;
  2445.     if( su->Exists(ev, property, kODNULL, 0) ) {
  2446.         shape= new ODShape;
  2447.           THROW_IF_NULL(shape);
  2448.         TRY{
  2449.             shape->InitShape(ev);
  2450.             su->Focus(ev, property, kODPosUndefined, kODNULL, 0, kODPosUndefined);
  2451.             shape->ReadShape(ev, su);
  2452.         }CATCH_ALL{
  2453.             delete shape;
  2454.             RERAISE;
  2455.         }ENDTRY
  2456.     }
  2457.     return shape;
  2458. }
  2459.  
  2460. //------------------------------------------------------------------------------
  2461. // ReadAndAcquireTransformIfAny  [static]
  2462. //------------------------------------------------------------------------------
  2463.  
  2464. static ODTransform* // DMc refcount - include "acquire" in function name:
  2465. ReadAndAcquireTransformIfAny( Environment *ev, ODStorageUnit *su, ODPropertyName property )
  2466. {
  2467.     ODTransform* transform = kODNULL;
  2468.     if( su->Exists(ev, property, kODNULL, 0) ) {
  2469.         transform= new ODTransform;
  2470.           THROW_IF_NULL(transform);
  2471.         TRY{
  2472.             transform->InitTransform(ev);
  2473.             su->Focus(ev, property, kODPosUndefined, kODNULL, 0, kODPosUndefined);
  2474.             transform->ReadFrom(ev, su);
  2475.         }CATCH_ALL{
  2476.             delete transform;
  2477.             RERAISE;
  2478.         }ENDTRY
  2479.     }
  2480.     return transform;
  2481. }
  2482.  
  2483. //------------------------------------------------------------------------------
  2484. // ODFrame: InitFrameFromStorage
  2485. //------------------------------------------------------------------------------
  2486.  
  2487. SOM_Scope void  SOMLINK ODFrameInitFrameFromStorage(ODFrame *somSelf, Environment *ev,
  2488.         ODStorageUnit*    storageUnit)
  2489. {
  2490.     ODFrameData *somThis = ODFrameGetData(somSelf);
  2491.     ODFrameMethodDebug("ODFrame","InitFrameFromStorage");
  2492.  
  2493.     /* Moved from somInit. SOM itself sets fields to zero
  2494.     _fDraft             = kODNULL;
  2495.     _fNPID                = 0;
  2496.     _fDirty                = kNotDirty;
  2497.  
  2498.     _fContainingFrame     = kODNULL;
  2499.     _fWindow             = kODNULL;
  2500.  
  2501.     _fFrameShape        = (ODShape*) kODNULL;
  2502.     _fUsedShape            = (ODShape*) kODNULL;
  2503.  
  2504.     _fInternalTransform    = (ODTransform*) kODNULL;    
  2505.  
  2506.     _fFacets            = kODNULL;
  2507.  
  2508.     _fPart                = kODNULL;
  2509.     _fPartInfo            = (ODInfoType) kODNULL;
  2510.     _fViewType            = (ODTypeToken) 0;
  2511.     _fPresentation        = (ODTypeToken) 0;
  2512.  
  2513.     _fFrameGroup        = 0;
  2514.     _fSequenceNumber    = 0;
  2515.  
  2516.     _fLinkStatus        = kODNotInLink;
  2517.     _fIsRoot            = kODFalse;
  2518.     _fIsSubframe         = kODFalse;
  2519.     _fIsOverlaid          = kODFalse;
  2520.     _fIsFrozen             = kODFalse;
  2521.     _fIsDroppable         = kODFalse;
  2522.     _fIsDragging         = kODFalse;
  2523.     _fDoesPropagateEvents =    kODFalse;
  2524.     */
  2525.     _fDirty                = kNotDirty;
  2526.     _fLinkStatus        = kODNotInLink;
  2527.     _fValidState        = kFrameIsValid;
  2528.  
  2529.     // *DON'T* CHECKVALID - need to read an "I'm invalid" representation
  2530.     
  2531.     SOM_TRY
  2532.         if (!storageUnit)
  2533.             THROW(kODErrIllegalNullStorageUnitInput);
  2534.             
  2535.         somSelf->InitPersistentObjectFromStorage(ev, storageUnit);
  2536.         _fDraft = storageUnit->GetDraft(ev);
  2537.     
  2538.     // mark this frame as invalid/removed if it was externalized without a part
  2539.     if ( !storageUnit->Exists(ev, kODPropPart, kODStrongStorageUnitRef, 0) )
  2540.     {
  2541.         _fValidState = kFrameIsRemoved;
  2542.         _fDirty = kNotDirty;
  2543.         return;
  2544.     }
  2545.     
  2546.         ASSERT(storageUnit->Exists(ev, kODPropFrameShape, kODPolygon, 0), kODErrInvalidPersistentFormat);
  2547.         ASSERT(storageUnit->Exists(ev, kODPropInternalTransform, kODTransform, 0), kODErrInvalidPersistentFormat);
  2548.         ASSERT(storageUnit->Exists(ev, kODPropViewType, kODISOStr, 0), kODErrInvalidPersistentFormat);
  2549.         ASSERT(storageUnit->Exists(ev, kODPropPresentation, kODISOStr, 0), kODErrInvalidPersistentFormat);
  2550.         ASSERT(storageUnit->Exists(ev, kODPropFrameGroup, kODULong, 0), kODErrInvalidPersistentFormat);
  2551.         ASSERT(storageUnit->Exists(ev, kODPropSequenceNumber, kODULong, 0), kODErrInvalidPersistentFormat);
  2552.         ASSERT(storageUnit->Exists(ev, kODPropIsSubframe, kODBoolean, 0), kODErrInvalidPersistentFormat);
  2553.         ASSERT(storageUnit->Exists(ev, kODPropIsOverlaid, kODBoolean, 0), kODErrInvalidPersistentFormat);
  2554.         ASSERT(storageUnit->Exists(ev, kODPropIsFrozen, kODBoolean, 0), kODErrInvalidPersistentFormat);
  2555.     
  2556.         // Note: kODPropLinkStatus is not a required property
  2557.  
  2558.         somSelf->CommonInitFrame(ev);
  2559.     
  2560.         ODULong valueSize = 0;
  2561.         ODStorageUnit* su = somSelf->GetStorageUnit(ev);
  2562.         ODSession* session = su->GetSession(ev);
  2563.         ODType typeString;
  2564.     
  2565.         // don't internalize _fContainingFrame - be lazy and do it later
  2566.         
  2567.         // geometry - must use biasTransform to normalize
  2568.         
  2569.         TempODTransform biasTransform = // DMc refcount - make temp
  2570.             ReadAndAcquireTransformIfAny(ev, su, kODPropBiasTransform);
  2571.         
  2572.         _fFrameShape = ReadAndAcquireShapeIfAny(ev, su, kODPropFrameShape);
  2573.         if ( !_fFrameShape )
  2574.             THROW(kODErrInvalidPersistentFormat);
  2575.         if ( _fFrameShape && biasTransform )
  2576.             _fFrameShape->Transform(ev, biasTransform);
  2577.         
  2578.         _fInternalTransform = ReadAndAcquireTransformIfAny(ev, su, kODPropInternalTransform);
  2579.         if ( _fInternalTransform && biasTransform )
  2580.             _fInternalTransform->PreCompose(ev, biasTransform);
  2581.     
  2582.         // don't internalize _fPart or _fPartInfo
  2583.         
  2584.         // internalize viewType and presentation
  2585.     
  2586.         typeString = ODGetISOStrProp(ev, su, kODPropViewType, kODISOStr, kODNULL, &valueSize);
  2587.         if ( valueSize > 0 )
  2588.             _fViewType = session->Tokenize(ev, typeString);
  2589.         if (typeString)
  2590.             ODDisposePtr(typeString);
  2591.         
  2592.         typeString = ODGetISOStrProp(ev, su, kODPropPresentation, kODISOStr, kODNULL, &valueSize);
  2593.         if ( valueSize > 0 )
  2594.             _fPresentation = session->Tokenize(ev, typeString);
  2595.         if (typeString)
  2596.             ODDisposePtr(typeString);
  2597.         
  2598.         // _fIsRoot set if containingFrame is valid suRef
  2599.         if ( ODSUExistsThenFocus(ev, su, kODPropContainingFrame, kODWeakStorageUnitRef) )
  2600.         {
  2601.             ODStorageUnitRef value;
  2602.             StorageUnitGetValue(su, ev, kODStorageUnitRefLen, (ODValue)&value);
  2603.             _fIsRoot = !(su->IsValidStorageUnitRef(ev, value));
  2604.         }
  2605.         else
  2606.             _fIsRoot = kODTrue;
  2607.  
  2608.         
  2609.         _fFrameGroup      = ODGetULongProp(ev, su, kODPropFrameGroup, kODULong);
  2610.         _fSequenceNumber = ODGetULongProp(ev, su, kODPropSequenceNumber, kODULong);
  2611.         _fIsSubframe     = ODGetBooleanProp(ev, su, kODPropIsSubframe, kODBoolean);
  2612.         _fIsOverlaid     = ODGetBooleanProp(ev, su, kODPropIsOverlaid, kODBoolean);
  2613.         _fIsFrozen         = ODGetBooleanProp(ev, su, kODPropIsFrozen, kODBoolean);
  2614.     
  2615.         _fDirty = kNotDirty;
  2616.  
  2617.         if ( su->Exists(ev, kODPropLinkStatus, kODULong, 0) )
  2618.         {
  2619.             _fLinkStatus = ODGetULongProp(ev, su, kODPropLinkStatus, kODULong);
  2620.             if ( _fLinkStatus != kODNotInLink )
  2621.             {
  2622.                 // If this frame displays the root part of the draft,
  2623.                 // the link status SHOULD be kODNotInLink since it has no
  2624.                 // containing frame. (This is true even for subframes
  2625.                 // displaying the root part of the draft.) This frame
  2626.                 // was probably cloned from a document where it was
  2627.                 // embedded in a link. Force the link status back to kODNotInLink.
  2628.                 ODStorageUnitID    rootPartID, partID;
  2629.                 TempODStorageUnit draftProperties = _fDraft->AcquireDraftProperties(ev);
  2630.                 rootPartID = ODGetStrongSURefProp(ev, draftProperties,
  2631.                                 kODPropRootPartSU, kODStrongStorageUnitRef);
  2632.                 partID = ODGetStrongSURefProp(ev, su,
  2633.                                 kODPropPart, kODStrongStorageUnitRef);
  2634.                 if ( (partID != kODNULLID) && (rootPartID == partID) )
  2635.                 {
  2636.                      _fLinkStatus = kODNotInLink;
  2637.                     // don't mark draft dirty, just mark property dirty
  2638.                      _fDirty |= kLinkStatusDirty;
  2639.                 }
  2640.             }
  2641.         }
  2642.  
  2643.     SOM_CATCH_ALL
  2644.     SOM_ENDTRY
  2645. }
  2646.  
  2647. //------------------------------------------------------------------------------
  2648. // ODFrame: InitFrameNonPersistent
  2649. //------------------------------------------------------------------------------
  2650. SOM_Scope void  SOMLINK ODFrameInitFrameNonPersistent(ODFrame *somSelf, Environment *ev,
  2651.                 ODDraft*    draft,
  2652.                 ODID         id,
  2653.                 ODFrame*     containingFrame,
  2654.                 ODShape*     frameShape,
  2655.                 ODCanvas*    biasCanvas,
  2656.                 ODPart*     part,
  2657.                 ODTypeToken    viewType,
  2658.                 ODTypeToken    presentation,
  2659.                 ODBoolean    isSubframe,
  2660.                 ODBoolean     isOverlaid)
  2661. {
  2662.     ODFrameData *somThis = ODFrameGetData(somSelf);
  2663.     ODFrameMethodDebug("ODFrame","InitFrameNonPersistent");
  2664.  
  2665.     // *DON'T* CHECKVALID - new frames will never be invalid
  2666.     
  2667.     SOM_TRY
  2668.         if ( kODNULL == draft )            THROW(kODErrIllegalNullStorageUnitInput);
  2669.         if ( kODNULL == frameShape    )    THROW(kODErrIllegalNullShapeInput);
  2670.         if ( kODNULL == part )            THROW(kODErrIllegalNullPartInput);
  2671.         if ( kODNULL == viewType )        THROW(kODErrIllegalNullTokenInput);
  2672.         if ( kODNULL == presentation )    THROW(kODErrIllegalNullTokenInput);
  2673.             
  2674.         // check for recursive embedding
  2675.         if ( (containingFrame != kODNULL) && !isSubframe )
  2676.         {
  2677.             TempODFrame tempFrame = containingFrame;
  2678.             tempFrame->Acquire(ev);   // because it will be released below
  2679.             while ( tempFrame )
  2680.             {
  2681.                 TempODPart tempPart = tempFrame->AcquirePart(ev);
  2682.                 if (tempPart == part)
  2683.                     THROW(kODErrIllegalRecursiveEmbedding);
  2684.                 ODFrame* spam = tempFrame;
  2685.                 TempODFrame oldFrame = spam;
  2686.                 tempFrame = kODNULL; // to avoid double Release if following fails
  2687.                 tempFrame = oldFrame->AcquireContainingFrame(ev);
  2688.             }
  2689.         }
  2690.  
  2691.         somSelf->InitPersistentObject(ev, kODNULL);
  2692.     
  2693.         _fLinkStatus = kODNotInLink;
  2694.         _fDraft = draft;
  2695.         _fNPID = id;
  2696.         
  2697.         _fContainingFrame = containingFrame;
  2698.         ODAcquireObject(ev, _fContainingFrame);
  2699.     
  2700.         _fFrameShape = BiasShapeSet(ev, frameShape, biasCanvas);
  2701.         ODAcquireObject(ev, _fFrameShape);
  2702.     
  2703.         _fInternalTransform    = somSelf->CreateTransform(ev);
  2704.         _fContentExtent        = ODPoint(0,0);
  2705.     
  2706.         _fViewType        = viewType;
  2707.         _fPresentation    = presentation;
  2708.         _fIsRoot        = (containingFrame == kODNULL);
  2709.         _fIsSubframe    = isSubframe;
  2710.         _fIsOverlaid     = isOverlaid;
  2711.     
  2712.         somSelf->CommonInitFrame(ev);
  2713.         
  2714.         _fPart = part;
  2715.         ODAcquireObject(ev, _fPart);
  2716.         _fPart->DisplayFrameAdded(ev, somSelf);
  2717.     SOM_CATCH_ALL
  2718.     SOM_ENDTRY
  2719. }
  2720.  
  2721. //------------------------------------------------------------------------------
  2722. // ODFrame: ReleaseAll
  2723. //------------------------------------------------------------------------------
  2724.  
  2725. SOM_Scope void  SOMLINK ODFrameReleaseAll(ODFrame *somSelf, Environment *ev)
  2726. {
  2727.     ODFrameData *somThis = ODFrameGetData(somSelf);
  2728.     ODFrameMethodDebug("ODFrame","ReleaseAll");
  2729.  
  2730.     // *DON'T* CHECKVALID - still need to finalize invalid frames
  2731.     
  2732.     SOM_TRY
  2733.         ODSafeReleaseObject(_fContainingFrame);
  2734.         ODSafeReleaseObject(_fWindow);
  2735.         ODSafeReleaseObject(_fPart);
  2736.  
  2737.         ODSafeReleaseObject(_fFrameShape);
  2738.         ODSafeReleaseObject(_fUsedShape);
  2739.         ODSafeReleaseObject(_fInternalTransform);
  2740.     
  2741.         parent_ReleaseAll(somSelf,ev);
  2742.     SOM_CATCH_ALL
  2743.     SOM_ENDTRY
  2744. }
  2745.  
  2746. //------------------------------------------------------------------------------
  2747. // ODFrame: somUninit
  2748. //------------------------------------------------------------------------------
  2749.  
  2750. SOM_Scope void  SOMLINK ODFramesomUninit(ODFrame *somSelf)
  2751. {
  2752.     ODFrameData *somThis = ODFrameGetData(somSelf);
  2753.     ODFrameMethodDebug("ODFrame","somUninit");
  2754.     
  2755.     ODDeleteObject(_fFacets);
  2756. }
  2757.  
  2758. //------------------------------------------------------------------------------
  2759. // static functions
  2760. //------------------------------------------------------------------------------
  2761.  
  2762. static ODBoolean FrameIsContained( Environment *ev, ODFrame* self,
  2763.         ODFrame* frame )
  2764. {
  2765.     if ( frame == kODNULL )
  2766.         return kODFalse;
  2767.     else if ( ODObjectsAreEqual(ev, self, frame) )
  2768.         return kODTrue;
  2769.     else
  2770.     {
  2771.         TempODFrame parent = frame->AcquireContainingFrame( ev );
  2772.         return FrameIsContained( ev, self, parent );
  2773.     }
  2774. }
  2775.  
  2776.