home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / opendc12.zip / od124os2.exe / od12osr1.exe / src / Frame.cpp < prev    next >
Text File  |  1997-03-21  |  104KB  |  3,020 lines

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