home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / opendc12.zip / od124os2.exe / od12osp1.exe / src / basecntr / bcxfer.cpp < prev    next >
Text File  |  1997-04-02  |  62KB  |  1,782 lines

  1. /* @(#) 1.57 com/src/samples/basecntr/bcxfer.cpp, odbasepart, od96os2, odos29714c 4/2/97 11:34:01 [4/2/97 17:20:09] */
  2.  
  3. //====START_GENERATED_PROLOG======================================
  4. //
  5. //
  6. //   COMPONENT_NAME: odsamples
  7. //
  8. //   CLASSES: none
  9. //
  10. //   ORIGINS: 82,27
  11. //
  12. //
  13. //   (C) COPYRIGHT International Business Machines Corp. 1995,1996
  14. //   All Rights Reserved
  15. //   Licensed Materials - Property of IBM
  16. //   US Government Users Restricted Rights - Use, duplication or
  17. //   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  18. //
  19. //   IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  20. //   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  21. //   PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  22. //   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  23. //   USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  24. //   OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
  25. //   OR PERFORMANCE OF THIS SOFTWARE.
  26. //
  27. //====END_GENERATED_PROLOG========================================
  28. //
  29.  
  30. /* -------------------------------------------------------------------------
  31.   BCXFER.CPP
  32.   This file contains routines for data transfer.
  33.   Functions implemented include:
  34.     Write to storage / Read from storage
  35.     Clone
  36.     Drag / Drop
  37.     Copy / Paste
  38.     ContainingPartPropertiesUpdated
  39.  
  40.   Following methods are implemented:
  41.  
  42.     A> Methods inherited from ODPart
  43.  
  44.     InitPart
  45.     InitPartFromStorage
  46.     Externalize
  47.     ExternalizeKinds
  48.     CloneInto
  49.  
  50.     WritePartInfo
  51.     ReadPartInfo
  52.     ClonePartInfo
  53.  
  54.     AcquireContainingPartProperties
  55.     ContainingPartPropertiesUpdated
  56.  
  57.     Drop
  58.     DropCompleted
  59.     FulfillPromise
  60.  
  61.     B> Methods defined in BaseContainer
  62.     StartDrag
  63.     WriteKindInfo
  64.     WriteContents
  65.     ReadKindInfo
  66.     ReadContents
  67.     WriteSingleFrame
  68.     ReadSingleFrame
  69.  
  70. */
  71.  
  72. #define kBaseContainerOldPartKind "BaseContainerPartKind"
  73. #define kODPropBackgroundColorOld "BaseContainer:Property:BackgroundColor"
  74. static const ODPropertyName kPropBackgroundOld =  "BaseContainer:Value:NTColor";
  75.  
  76. // -------------------------------------------------------------------------
  77. inline void InitPropVal (Environment *ev, ODStorageUnit *su,
  78.                          ODPropertyName propName, ODValueType valName)
  79. {
  80.     if (ODSUExistsThenFocus (ev, su, propName, valName))
  81.          su->Remove (ev);
  82.  
  83.     ODSUAddPropValue (ev, su, propName, valName);
  84.  
  85. }
  86.  
  87. ODFacet* FirstFacet (Environment *ev, ODFrame *frame)
  88. {
  89.  
  90.     ODFrameFacetIterator *ffitr  = frame->CreateFacetIterator(ev);
  91.     ODFacet *facet = (ODFacet *)ffitr->First(ev);
  92.     ODDeleteObject(ffitr);
  93.     return facet;
  94.  
  95. }
  96.  
  97. // -------------------------------------------------------------------------
  98. // ODPart --> InitPart
  99. //
  100. //      Initializes this part (first time use).
  101. //
  102. //      -> does not call parent method
  103. //      -> required for all parts
  104. // -------------------------------------------------------------------------
  105.  
  106. SOM_Scope       void
  107. SOMLINK         BaseContainerInitPart
  108.                 (
  109.                 BaseContainer   *somSelf,       // in
  110.                 Environment     *ev,            // in
  111.                 ODStorageUnit   *storageUnit,   // in
  112.                 ODPart          *partWrapper    // in
  113.                 )
  114. {
  115.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  116.     BaseContainerMethodDebug("BaseContainer", "BaseContainerInitPart");
  117.  
  118.  
  119.  
  120.     try {
  121.  
  122.     BaseContainer_parent_ODPart_InitPart(somSelf,ev,storageUnit,partWrapper);
  123.  
  124.  
  125.     _fPartWrapper = partWrapper;
  126.     _fPartSU = storageUnit;
  127.     somSelf->InitPersistentObject(ev, storageUnit);
  128.     somSelf->Initialize(ev, partWrapper);
  129.  
  130.     } // end of try block
  131.     catch(ODException _exception) {
  132.         ODSetSOMException(ev, kODErrCannotInitializePart);
  133.  
  134.     } // end of catch block
  135.  
  136.  
  137.  
  138. }
  139.  
  140.  
  141.  
  142. // -------------------------------------------------------------------------
  143. // ODPart --> InitPartFromStorage
  144. //
  145. //      Initializes this part from storage.
  146. //
  147. //      -> does not call parent method
  148. //      -> required for all parts
  149. // -------------------------------------------------------------------------
  150.  
  151. SOM_Scope       void
  152. SOMLINK         BaseContainerInitPartFromStorage
  153.                 (
  154.                 BaseContainer   *somSelf,       // in
  155.                 Environment     *ev,            // in
  156.                 ODStorageUnit   *storageUnit,   // in
  157.                 ODPart          *partWrapper    // in
  158.                 )
  159.  
  160. {
  161.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  162.     BaseContainerMethodDebug("BaseContainer", "BaseContainerInitPartFromStorage");
  163.  
  164.  
  165.  
  166.     try {
  167.  
  168.     BaseContainer_parent_ODPart_InitPartFromStorage(somSelf,ev,storageUnit,partWrapper);
  169.  
  170.     // Initialize
  171.     ODDraft *fromDraft = storageUnit->GetDraft (ev);
  172.     _fPartWrapper = partWrapper;
  173.     _fPartSU = storageUnit;
  174.     somSelf->InitPersistentObjectFromStorage(ev, storageUnit);
  175.     somSelf->Initialize(ev, partWrapper);
  176.     _fNeedToInternalize = kODTrue;
  177.  
  178.    // Read in display frames and BGColor
  179.    // This is done only when part comes up. So this cannot be put
  180.    // in a generic *READ* routine
  181.  
  182.    // Read background color
  183.  
  184.     _fBackgroundColor = 0;
  185.     if(ODSUExistsThenFocus(ev, storageUnit, kODPropBackgroundColor, kPropBackground)) {
  186.        _fBackgroundColor = ODGetULongProp(ev, storageUnit, kODPropBackgroundColor, kPropBackground);
  187.     } else if(ODSUExistsThenFocus(ev, storageUnit, kODPropBackgroundColorOld, kPropBackgroundOld)) {
  188.        _fBackgroundColor = ODGetULongProp(ev, storageUnit, kODPropBackgroundColorOld, kPropBackgroundOld);
  189.     }
  190. #ifdef _PLATFORM_UNIX_
  191.     int status;
  192.     XColor color;
  193.     color.flags = DoRed | DoGreen | DoBlue;
  194.  
  195.     ODULong col = (ODULong)_fBackgroundColor;
  196.  
  197.     color.red = ((col & 0xFF0000) >> 8) | ((col & 0xFF0000) >> 16);
  198.     color.green =  (col & 0x00FF00) | ((col & 0x00FF00) >> 8);
  199.     color.blue = (col & 0x0000FF) | ((col & 0x0000FF) << 8);
  200.  
  201.     status = XAllocColor(_fDisplay,
  202.       XDefaultColormapOfScreen( _fSession->GetWindowState(ev)->GetScreen(ev)),
  203.       &color);
  204.  
  205.     if (status == 0)   // XAllocColor failed
  206.         _fBackgroundColor = WhitePixel(_fDisplay, DefaultScreen(_fDisplay));
  207.     else
  208.         _fBackgroundColor = color.pixel;
  209.  
  210. #elif defined(_PLATFORM_WIN32_)
  211.     if(storageUnit->Exists(ev, kODPropBackgroundColor, kPropBackground, 0)) {
  212.        ExchangeRedAndBlue(_fBackgroundColor);
  213.     } 
  214. #endif // _PLATFORM_WIN32_
  215.  
  216.     // Read in display frames
  217.  
  218.     if (ODSUExistsThenFocus (ev, storageUnit, kODPropDisplayFrames, kODWeakStorageUnitRef))
  219.     {
  220.  
  221.          ODStorageUnitRef aSURef;
  222.          ODULong offset, offsetLimit;
  223.  
  224.          offsetLimit = storageUnit->GetSize(ev);
  225.  
  226.          for (offset = 0; offset < offsetLimit; offset += sizeof(ODStorageUnitRef))
  227.          {
  228.               storageUnit->SetOffset(ev, offset);
  229.               ODID id = ODGetWeakSURefProp (ev, storageUnit, kODNULL, kODNULL);
  230.  
  231.               if (id != kODNULLID) {
  232.                    ODFrame* frame =  fromDraft->AcquireFrame(ev, id);
  233.                    if (!_fDisplayFrames->Contains(ev, frame))
  234.                         _fDisplayFrames->AddLast (ev, frame);
  235.                    else
  236.                         PRINT("Display frame add: ***** WRONG ******* \n");
  237.                    frame->SetDroppable(ev, kODTrue);
  238.               }
  239.          }
  240.  
  241.     }
  242.  
  243.     // clean up
  244.     ODSURemoveProperty(ev, storageUnit, kODPropContentFrame);
  245.     ODSURemoveProperty(ev, storageUnit, kODPropSuggestedFrameShape);
  246.     ODSURemoveProperty(ev, storageUnit, kBCSuggestedTransform);
  247.     ODSURemoveProperty(ev, storageUnit, kODPropMouseDownOffset);
  248.  
  249.  
  250.     } // end of try block
  251.     catch(ODException _exception) {
  252.         ODSetSOMException(ev, kODErrCannotInitializePart);
  253.     } // end of catch block
  254.  
  255. }
  256.  
  257.  
  258.  
  259. // -------------------------------------------------------------------------
  260. // ODPersistentObject --> Externalize
  261. //
  262. //      Write this part's content, and state to storage.
  263. //
  264. //      Called by your part editor when part data must be stored.
  265. //
  266. //      -> if overridden then must call parent's Externalize method first!
  267. //      -> write out part's persistent properties/values to storage
  268. //         as defined in the InitPart method of this part.
  269. //
  270. // -------------------------------------------------------------------------
  271.  
  272. SOM_Scope       void
  273. SOMLINK         BaseContainerExternalize
  274.                 (
  275.                 BaseContainer   *somSelf,       // in
  276.                 Environment     *ev             // in
  277.                 )
  278. {
  279.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  280.     BaseContainerMethodDebug("BaseContainer","BaseContainerExternalize");
  281.  
  282.     try {
  283.  
  284.     BaseContainer_parent_ODPart_Externalize(somSelf,ev);
  285.  
  286.     somSelf->WriteKindInfo (ev, somSelf->GetStorageUnit (ev));
  287.     BCCloneInfo cloneInfo;
  288.     memset (&cloneInfo, 0, sizeof (BCCloneInfo));
  289.     somSelf->WriteContents (ev, somSelf->GetStorageUnit (ev), &cloneInfo, EXTERNALIZE);
  290.  
  291.     } // end of try block
  292.     catch (...) {}
  293.  
  294. }
  295.  
  296.  
  297.  
  298. // -------------------------------------------------------------------------
  299. // BaseContainer --> ExternalizeKinds
  300. //
  301. //      Writes part's PartKind info list to storage.
  302. //
  303. //      Called by OpenDoc (but I don't know why or when???)
  304. //
  305. //      -> do not call your parent method
  306. //      -> BaseContainer has no PartKind info to write to storage
  307. //
  308. // -------------------------------------------------------------------------
  309.  
  310. SOM_Scope       void
  311. SOMLINK         BaseContainerExternalizeKinds
  312.                 (
  313.                 BaseContainer   *somSelf,       // in
  314.                 Environment     *ev,            // in
  315.                 ODTypeList      *kindset        // in
  316.                 )
  317. {
  318.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  319.     BaseContainerMethodDebug("BaseContainer","BaseContainerExternalizeKinds");
  320.  
  321. }
  322.  
  323.  
  324. // -------------------------------------------------------------------------
  325. // ODPersistentObject --> CloneInto
  326. //
  327. //      Copy an object data into a storage unit.
  328. //
  329. //      Called by OpenDoc when your part is copied to the ClipBoard, the
  330. //      Drag-Drop object, or link-source object.
  331. //
  332. //      -> if overridden then must call the parent's CloneInto method first!
  333. //      -> used to support internal data interchange
  334. //      -> the parent method clones kODPropCreateDate,
  335. //                                  kODPropModDate,
  336. //                                  kODPropModUser properties for you
  337. //      -> you need to clone any additional properties
  338. //      -> and write your part's data to the StorageUnit
  339. // -------------------------------------------------------------------------
  340.  
  341. SOM_Scope       void
  342. SOMLINK         BaseContainerCloneInto
  343.                 (
  344.                 BaseContainer   *somSelf,           // in
  345.                 Environment     *ev,                // in
  346.                 ODDraftKey       key,               // in
  347.                 ODStorageUnit   *destinationSU,     // in
  348.                 ODFrame         *initiatingFrame    // in
  349.                 )
  350. {
  351.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  352.     BaseContainerMethodDebug("BaseContainer","BaseContainerCloneInto");
  353.  
  354.     try {
  355.  
  356.     BaseContainer_parent_ODPart_CloneInto(somSelf,ev,key, destinationSU, initiatingFrame);
  357.  
  358.     BCCloneInfo cloneInfo;
  359.     memset (&cloneInfo, 0, sizeof (BCCloneInfo));
  360.  
  361.     somSelf->WriteKindInfo (ev, destinationSU);
  362.  
  363.     cloneInfo.key = key;
  364.  
  365.     somSelf->WriteContents ( ev, destinationSU, &cloneInfo, CLONE_ALL);
  366.  
  367.     } // end of try block
  368.     catch (...) {}
  369. }
  370.  
  371.  
  372.  
  373. // -------------------------------------------------------------------------
  374. // ODPart --> ReadPartInfo
  375. //
  376. //      Should read the part info data for a display frame of this part
  377. //      from the specified storage unit.
  378. //
  379. //      -> does not call parent method
  380. //      -> required for all parts
  381. // -------------------------------------------------------------------------
  382.  
  383. SOM_Scope       ODInfoType
  384. SOMLINK         BaseContainerReadPartInfo
  385.                 (
  386.                 BaseContainer       *somSelf,       // in
  387.                 Environment         *ev,            // in
  388.                 ODFrame             *frame,         // in
  389.                 ODStorageUnitView   *storUnitView   // in
  390.                 )
  391. {
  392.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  393.     BaseContainerMethodDebug("BaseContainer", "BaseContainerReadPartInfo");
  394.  
  395.     return kODNULL;
  396. }
  397.  
  398.  
  399.  
  400. // -------------------------------------------------------------------------
  401. // ODPart --> WritePartInfo
  402. //
  403. //      Should write the part info data for a display frame of this part
  404. //      from the specified storage unit.
  405. //
  406. //      -> does not call parent method
  407. //      -> required for all parts
  408. // -------------------------------------------------------------------------
  409.  
  410. SOM_Scope       void
  411. SOMLINK         BaseContainerWritePartInfo
  412.                 (
  413.                 BaseContainer       *somSelf,       // in
  414.                 Environment         *ev,            // in
  415.                 ODInfoType           partInfo,      // in
  416.                 ODStorageUnitView   *storUnitView   // in
  417.                 )
  418. {
  419.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  420.     BaseContainerMethodDebug("BaseContainer", "BaseContainerWritePartInfo");
  421.  
  422.  
  423. }
  424.  
  425.  
  426.  
  427. // -------------------------------------------------------------------------
  428. // ODPart --> ClonePartInfo
  429. //
  430. //      Should clone the part info data for a display frame of this part
  431. //      into the specified storage unit.
  432. //
  433. //      -> does not call parent method
  434. //      -> required for all parts
  435. // -------------------------------------------------------------------------
  436. SOM_Scope void    SOMLINK BaseContainerClonePartInfo(BaseContainer *somSelf,
  437.          Environment *ev,
  438.          ODDraftKey key,
  439.          ODInfoType partInfo,
  440.          ODStorageUnitView* storageUnitView,
  441.          ODFrame* scope)
  442.  
  443. {
  444.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  445.     BaseContainerMethodDebug("BaseContainer", "BaseContainerClonePartInfo");
  446.  
  447. }
  448.  
  449.  
  450.  
  451. //--------------------------------------------------------------------------
  452. // ODPart --> AcquireContainingPartProperties
  453. //
  454. //      Should write into a storage unit the container properties
  455. //      this part associates with the specified embedded frame and
  456. //      then return the storage unit.
  457. //
  458. //      ->
  459. //--------------------------------------------------------------------------
  460.  
  461. SOM_Scope       ODStorageUnit*
  462. SOMLINK         BaseContainerAcquireContainingPartProperties
  463.                 (
  464.                 BaseContainer   *somSelf,       // in
  465.                 Environment     *ev,            // in
  466.                 ODFrame         *frame          // in
  467.                 )
  468. {
  469.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  470.     BaseContainerMethodDebug("BaseContainer", "BaseContainerGetContainingPartProperties");
  471.  
  472.  
  473.     return kODNULL;
  474. }
  475.  
  476.  
  477.  
  478. //--------------------------------------------------------------------------
  479. // ODPart --> ContainingPartPropertiesUpdated
  480. //
  481. //      Should notify this part that its containing part's container
  482. //      properties have changed.
  483. //
  484. //      ->
  485. //--------------------------------------------------------------------------
  486.  
  487. SOM_Scope       void
  488. SOMLINK         BaseContainerContainingPartPropertiesUpdated
  489.                 (
  490.                 BaseContainer   *somSelf,       // in
  491.                 Environment     *ev,            // in
  492.                 ODFrame         *frame,         // in
  493.                 ODStorageUnit   *propertyUnit   // in
  494.                 )
  495. {
  496.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  497.     BaseContainerMethodDebug("BaseContainer", "BaseContainerContainingPartPropertiesChanged");
  498.  
  499.  
  500. }
  501.  
  502.  
  503. //--------------------------------------------------------------------------
  504. // ODPart --> Drop
  505. //
  506. //      Should move or copy the dragged data into this part.
  507. //
  508. //      ->
  509. //--------------------------------------------------------------------------
  510.  
  511. SOM_Scope       ODDropResult
  512. SOMLINK         BaseContainerDrop
  513.                 (
  514.                 BaseContainer       *somSelf,   // in
  515.                 Environment         *ev,        // in
  516.                 ODDragItemIterator  *dropInfo,  // in
  517.                 ODFacet             *facet,     // in
  518.                 ODPoint             *where      // in
  519.                 )
  520. {
  521.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  522.     BaseContainerMethodDebug("BaseContainer","BaseContainerDrop");
  523.  
  524.     ODDropResult        dropResult = kODDropFail;
  525.     ODCloneKind         cloneKind;
  526.     ODULong             attributes;
  527.     ODBoolean           isMovePart;
  528.     ODFrame*            myFrame = facet->GetFrame(ev);
  529.  
  530.     if (_fDraftReadOnly) {
  531.        WARNMSG(WARN_INDEX(-1), "Document is read only. Drop is not accepted.");
  532.        return dropResult;
  533.     }
  534.     somSelf->InvertDragHilite( ev, facet );
  535.  
  536.   try {
  537.  
  538.     // Get proper attributes
  539.  
  540.  
  541.     attributes = _fSession->GetDragAndDrop(ev)->GetDragAttributes(ev);
  542.     isMovePart = ((attributes & kODDropIsInSourceFrame) &&
  543.                   (attributes & kODDropIsMove)) ? kODTrue : kODFalse;
  544.  
  545.     if (attributes & kODDropIsCopy)  {
  546.         dropResult = kODDropCopy;
  547.         cloneKind = kODCloneDropCopy;
  548.     }
  549.     else {
  550.         dropResult = kODDropMove;
  551.         cloneKind = kODCloneDropMove;
  552.     }
  553.  
  554.     // where is in frame coordinates, change to content coordinates
  555.     TempODTransform intXform = myFrame->AcquireInternalTransform (ev, kODNULL);
  556.     intXform->InvertPoint (ev, where);
  557.  
  558.     // Move selection ..
  559.  
  560.     if (isMovePart) {
  561.  
  562.        ODPoint delta;
  563.        ALink *itr;
  564.        delta.x = where->x - _fMouseStart->x;
  565.        delta.y = where->y - _fMouseStart->y;
  566.  
  567.        somSelf->CompleteMoveOperation (ev, myFrame, &delta);
  568.  
  569.     } // if move part
  570.  
  571.     else {
  572.  
  573.        // It is a drop from another part
  574.  
  575.        ODStorageUnit *dropSU;
  576.        ODPoint refPoint;
  577.  
  578.        for (dropSU = dropInfo->First(ev); dropSU; dropSU = dropInfo->Next(ev)) {
  579.  
  580. #if defined(_PLATFORM_OS2_)
  581.  
  582.           // some OS/2 specific stuff for drag-drop from WPShell
  583.           if ( !dropSU->Exists(ev, kODPropContents, (ODValueType)kODDragitem, 0))
  584.           {
  585.              // nothing to process... (bug)
  586.              continue;
  587.           } /* end if */
  588.  
  589.           // get the dragitem (actual pm structure)
  590.           dropSU->Focus(ev, kODPropContents, kODPosUndefined, (ODValueType)kODDragitem, 0, kODPosUndefined);
  591.  
  592.           // create a view of our focused value for the drag manager
  593.           ODStorageUnitView *dropView = dropSU->CreateView(ev);
  594.  
  595.           // ask the drag manager to get it for us
  596.           if ( ! _fSession->GetDragAndDrop(ev)-> GetDataFromDragManager(ev,  dropView,
  597.                                           &dropSU ) )
  598.           {
  599.              // error in transfer
  600.              continue;
  601.           }
  602. #endif
  603.  
  604.           if (ODGetPointProp (ev, dropSU, kODPropMouseDownOffset, kODPoint, &refPoint) == kODNULL)
  605.              refPoint.x = refPoint.y = 0;
  606.           refPoint.x = where->x - refPoint.x;
  607.           refPoint.y = where->y - refPoint.y;
  608.  
  609.           if ((dropSU->Exists(ev, kODPropContentFrame, kODWeakStorageUnitRef, 0))
  610.               || (somSelf->ReadKindInfo(ev, dropSU) == kODFalse)
  611.               || (attributes & kODDropIsPasteAs))
  612.           {
  613.              ODFrame *embeddedFrame = somSelf->ReadSingleFrame (ev, facet,
  614.                                          dropSU, cloneKind, &refPoint);
  615.              if (embeddedFrame)
  616.              {
  617.                 ContentFrame *newObject = new ContentFrame();
  618.                 newObject->_set_myFrame (ev, embeddedFrame);
  619.                 _fEmbeddedObjects->AddLast (ev, (ODPtr)newObject);
  620.              }
  621.           }
  622.           else {
  623.  
  624.              BCCloneInfo cloneInfo;
  625.              memset (&cloneInfo, 0, sizeof(BCCloneInfo));
  626.  
  627.              ODDraft *toDraft = somSelf->GetStorageUnit(ev)->GetDraft(ev);
  628.              ODDraft *fromDraft = dropSU->GetDraft(ev);
  629.              ODDraftKey key = 0;
  630.              key = fromDraft->BeginClone (ev, toDraft, kODNULL, cloneKind);
  631.              cloneInfo.key = key;
  632.              cloneInfo.refPoint = &refPoint;
  633.              cloneInfo.myFrame = facet->GetFrame (ev);
  634.  
  635.              somSelf->ReadContents(ev, dropSU, &cloneInfo, CLONE_ALL);
  636.  
  637.              fromDraft->EndClone (ev, key);
  638.  
  639.           }
  640.        } // end for
  641.  
  642.     } // if not move part
  643.  
  644.     somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
  645.     somSelf->ChangeNotification (ev, BCC_DROP, myFrame, kODNULL, kODTrue, kODNULL);
  646.  
  647.   } // end of try block
  648.   catch (...) {}
  649.  
  650.   return dropResult;
  651. }
  652.  
  653.  
  654.  
  655. //--------------------------------------------------------------------------
  656. // ODPart --> DropCompleted
  657. //
  658. //      Should notify this part of a drag operation, resulting from an
  659. //      asynchronous drag initiated from this part, is complete.
  660. //
  661. //      ->
  662. //--------------------------------------------------------------------------
  663.  
  664. SOM_Scope       void
  665. SOMLINK         BaseContainerDropCompleted
  666.                 (
  667.                 BaseContainer   *somSelf,       // in
  668.                 Environment     *ev,            // in
  669.                 ODPart          *destPart,      // in
  670.                 ODDropResult     dropResult     // in
  671.                 )
  672.  
  673. {
  674.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  675.     BaseContainerMethodDebug("BaseContainer","BaseContainerDropCompleted");
  676.  
  677.     ALink   *itr;
  678.  
  679.  
  680.         // We have returned from drag/drop, clean up the stuff
  681.         // If drop operation was not a move OR if it was a move within myself or
  682.         // if the draft is readonly then I am going to still HAVE this selection
  683.         // In that case, set the Dragging and InLimbo flags
  684.         if ((destPart == _fPartWrapper) || (dropResult != kODDropMove) || _fDraftReadOnly)
  685.         {
  686.            for (itr=_fSelectedObjects->First(ev); itr->Content(ev); itr=itr->Next(ev))
  687.            {
  688.               ContentFrame *embedObj = (ContentFrame *)itr->Content(ev);
  689.               if (embedObj->_get_objType(ev) == COBJ_FRAMECLASS)
  690.               {
  691.                   embedObj->_get_myFrame(ev)->SetDragging(ev, kODFalse);
  692.                   embedObj->_get_myFrame(ev)->SetInLimbo (ev, kODFalse);
  693.               }
  694.            }
  695.         }
  696.  
  697.         if ((destPart != _fPartWrapper) && (dropResult == kODDropMove)) {
  698.            if (!_fDraftReadOnly)
  699.                somSelf->DeleteSelection (ev, OBJECT_DRAGGED);
  700.            else
  701.               WARNMSG (WARN_INDEX(-1), "Cannot delete selection. Document is read-only.");
  702.         }
  703.  
  704.         if (destPart)
  705.            ODSafeReleaseObject (destPart);
  706. }
  707.  
  708.  
  709. //--------------------------------------------------------------------------
  710. // ODPart --> FulfillPromise
  711. //
  712. //      Should fulfill a promise by providing the content data the
  713. //      promise represents.
  714. //
  715. //      ->
  716. //--------------------------------------------------------------------------
  717.  
  718. SOM_Scope       void
  719. SOMLINK         BaseContainerFulfillPromise
  720.                 (
  721.                 BaseContainer      *somSelf,        // in
  722.                 Environment        *ev,             // in
  723.                 ODStorageUnitView  *promiseSUView   // in
  724.                 )
  725. {
  726.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  727.     BaseContainerMethodDebug("BaseContainer","BaseContainerFulfillPromise");
  728.  
  729.  
  730. }
  731.  
  732.  
  733. //--------------------------------------------------------------------------
  734. // BaseContainer --> StartDrag
  735. //
  736. //      Should prepare the data for the drag operation
  737. //
  738. //      ->
  739. //--------------------------------------------------------------------------
  740.  
  741. SOM_Scope       void
  742. SOMLINK         BaseContainerStartDrag
  743.                 (
  744.                 BaseContainer   *somSelf,        // in
  745.                 Environment     *ev,             // in
  746.                 ODEventData     *event,          // in
  747.                 ODFrame         *embeddedFrame,  // in
  748.                 ODFacet         *facet,          // in
  749.                 ODEventInfo     *eventInfo,
  750.                 ODCloneKind     cloneKind
  751.                 )
  752. {
  753.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  754.     BaseContainerMethodDebug("BaseContainer","BaseContainerStartDrag");
  755.  
  756.     ODDragAndDrop*      dragAndDrop = kODNULL;
  757.     ODDropResult        dropResult = kODNULL;
  758.     ODPoint cursorLocation;               // where was the mouse click
  759.  
  760.  
  761.         cursorLocation = eventInfo->where;
  762.  
  763.     ODStorageUnit *toSU = kODNULL;
  764.     ODPart*        destPart = kODNULL;
  765.     ALink   *itr;
  766.  
  767.     try {
  768.  
  769.         // Get the DragAndDrop object's ContentStorageUnit
  770.  
  771.         dragAndDrop =
  772.                 somSelf->GetStorageUnit(ev)->GetSession(ev)->GetDragAndDrop(ev);
  773.         dragAndDrop->Clear(ev);
  774.         toSU = dragAndDrop->GetContentStorageUnit(ev);
  775.  
  776.         // Clone the data .. same as Copy
  777.  
  778.         ODULong num = _fSelectedObjects->Count(ev);
  779.         if (!num)
  780.            return;
  781.  
  782.         ContentFrame *cobj = (ContentFrame *) _fSelectedObjects->First(ev)->Content(ev);
  783.  
  784.         if ((num == 1) && (cobj->_get_objType(ev) == COBJ_FRAMECLASS)) {
  785.  
  786.             // special case: copy single embedded frame to DAD
  787.             ODFrame *eFrame = cobj->_get_myFrame(ev);
  788.             somSelf->WriteSingleFrame (ev, eFrame, toSU, cloneKind);
  789.  
  790.         }
  791.         else {
  792.  
  793.            somSelf->WriteKindInfo (ev, toSU);
  794.            BCCloneInfo cloneInfo;
  795.            memset (&cloneInfo, 0, sizeof(BCCloneInfo));
  796.  
  797.            ODDraft *fromDraft = somSelf->GetStorageUnit(ev)->GetDraft(ev);
  798.            ODDraft *toDraft = toSU->GetDraft(ev);
  799.            ODDraftKey key = 0;
  800.            key = fromDraft->BeginClone (ev, toDraft, kODNULL, cloneKind);
  801.            cloneInfo.key = key;
  802.  
  803.            somSelf->WriteContents (ev, toSU, &cloneInfo, CLONE_SELECTED);
  804.  
  805.            fromDraft->EndClone (ev, key);
  806.         }
  807.  
  808.         // Now do the UI stuff needed for drag/drop
  809.         // iterate through the selected embedded frames and compute region
  810.  
  811.         ODRect  embedBBox;
  812.         Rect winRect;
  813.         TempODShape tempShape = _fSelectShape->Copy(ev);
  814.         TempODTransform xform = facet->AcquireWindowContentTransform(ev, kODNULL);
  815.         tempShape->Transform(ev, xform); // now in window co-ord system
  816.         tempShape->GetBoundingBox (ev, &embedBBox);
  817.  
  818. // ---------------------- the following code sets up an outline ---------------
  819. // ----------------------   region that shows at drag time --------------------
  820.  
  821. ODType imageType;
  822.  
  823. #if defined(_PLATFORM_WIN32_)
  824.  
  825.         ODRgnHandle    dragRegion = kODNULL;
  826.         SetRect(&winRect, FixedToInt(embedBBox.left),
  827.                           FixedToInt(embedBBox.top),
  828.                           FixedToInt(embedBBox.right),
  829.                           FixedToInt(embedBBox.bottom));
  830.         dragRegion = CreateRectRgn(winRect.left,
  831.                                    winRect.top,
  832.                                    winRect.right,
  833.                                    winRect.bottom);
  834.  
  835.         imageType = kODWindowsRegionHandle;
  836. #elif defined(_PLATFORM_UNIX_)
  837.         XRectangle rgnBox;
  838.         ODRgnHandle dragRegion = XCreateRegion();
  839.  
  840.         ODAIXWindowCanvas *aixwincanvas = (ODAIXWindowCanvas *)
  841.                       (facet->GetCanvas(ev)->GetPlatformCanvas(ev, kODAIX));
  842.         Window window = aixwincanvas->GetWindow(ev);
  843.         GC gc = aixwincanvas->GetGC(ev);
  844.  
  845.         dragRegion = tempShape->GetRegion(ev);
  846.  
  847.         XSetRegion(_fDisplay, gc, dragRegion);
  848.  
  849.         XClipBox(dragRegion, &rgnBox);
  850.         XDrawRectangle(_fDisplay, window, gc, rgnBox.x, rgnBox.y, rgnBox.width, rgnBox.height);
  851.  
  852.         imageType = kODAIXRegion;
  853. #elif defined(_PLATFORM_OS2_)
  854.  
  855.         DRAGIMAGE dragRegion;         /* DRAGIMAGE structure     */
  856.  
  857.         // initialize
  858.         POINTL pts[7];
  859.         POINTL ptrOffset;
  860.         pts[ 0].x = 0;   pts[0].y = 0;
  861.  
  862.         // save region (gotten by BoundingBox routine) in integer format
  863.         winRect.xLeft = FixedToInt(embedBBox.left);
  864.         winRect.yTop =  FixedToInt(embedBBox.top);
  865.         winRect.xRight = FixedToInt(embedBBox.right);
  866.         winRect.yBottom =  FixedToInt(embedBBox.bottom);
  867.  
  868.         // offset the amount of the cursor (Don't use the cursorLocation
  869.         // variable set above because it is not an int)
  870.         winRect.xLeft -= SHORT1FROMMP(event->mp1);
  871.         winRect.xRight -= SHORT1FROMMP(event->mp1);
  872.         winRect.yTop -= SHORT2FROMMP(event->mp1);
  873.         winRect.yBottom -= SHORT2FROMMP(event->mp1);
  874.  
  875.         // specify region
  876.         pts[ 0].x = 0;               pts[ 0].y = 0;
  877.         pts[ 1].x = winRect.xLeft ;  pts[ 1].y = winRect.yBottom;
  878.         pts[ 2].x = winRect.xLeft ;  pts[ 2].y = winRect.yTop;
  879.         pts[ 3].x = winRect.xRight;  pts[ 3].y = winRect.yTop;
  880.         pts[ 4].x = winRect.xRight;  pts[ 4].y = winRect.yBottom;
  881.         pts[ 5].x = winRect.xLeft ;  pts[ 5].y = winRect.yBottom;
  882.         pts[ 6].x = 0;               pts[ 6].y = 0;
  883.         // PUT 0,0 at last location or you will get an extra line.
  884.  
  885.         // Fill in the DRAGIMAGE structure.
  886.         dragRegion.cb = sizeof(DRAGIMAGE);
  887.         dragRegion.cxOffset = 0;
  888.         dragRegion.cyOffset = 0;
  889.         dragRegion.cptl     = 7;
  890.         dragRegion.hImage = (ULONG)(PPOINTL)pts;
  891.         dragRegion.fl = DRG_POLYGON;
  892.         // ... below it gets set into the ODByteArray dragImgBA
  893.  
  894.         imageType = kODOS2DragImage;
  895. #endif
  896. // ----------------------   end of region set up --------------------
  897.  
  898.         for (itr=_fSelectedObjects->First(ev); itr->Content(ev); itr=itr->Next(ev))
  899.         {
  900.            ContentFrame *embedObj = (ContentFrame *)itr->Content(ev);
  901.            if (embedObj->_get_objType(ev) == COBJ_FRAMECLASS)
  902.            {
  903.                embedObj->_get_myFrame(ev)->SetDragging(ev, kODTrue);
  904.                embedObj->_get_myFrame(ev)->SetInLimbo(ev, kODTrue);
  905.            }
  906.         }
  907.  
  908.         xform->InvertPoint (ev, &cursorLocation); // now in my frame coord
  909.         *_fMouseStart = cursorLocation;
  910.  
  911.         _fSelectShape->GetBoundingBox (ev, &embedBBox); // frame coord
  912.         cursorLocation.x -= embedBBox.left;
  913.         cursorLocation.y -= embedBBox.top;
  914.         ODSetPointProp (ev, toSU, kODPropMouseDownOffset, kODPoint, &cursorLocation);
  915.  
  916.         ODByteArray dragImgBA = CreateByteArrayStruct(&dragRegion, sizeof(dragRegion));
  917.         ODByteArray eventBA = CreateByteArrayStruct(&event, sizeof(ODEventData*));
  918.  
  919.         // Now that all setup is done, start dragging the frames
  920. #if (defined(_PLATFORM_WIN32_) || defined(_PLATFORM_OS2_))
  921.         dropResult = dragAndDrop->StartDrag(ev,
  922.                                             facet->GetFrame(ev),
  923.                                             imageType, &dragImgBA,
  924.                                             &destPart, &eventBA);
  925. #else
  926.         dropResult = dragAndDrop->StartDrag(ev,
  927.                                             facet->GetFrame(ev),
  928.                                             imageType, &dragImgBA,
  929.                                             &destPart, (ODByteArray*)event);
  930. #endif
  931.  
  932.         DisposeByteArrayStruct(dragImgBA);
  933.         DisposeByteArrayStruct(eventBA);
  934.  
  935. #if (defined(_PLATFORM_WIN32_) || defined(_PLATFORM_OS2_))
  936.         somSelf->DropCompleted(ev, destPart, dropResult);
  937. #endif
  938.  
  939.  
  940.     } // end of try block
  941.     catch(ODException _exception) {
  942.         PRINT("Exception in Start Drag **----\n");
  943.     } // end of catch block
  944.  
  945. }
  946.  
  947.  
  948.  
  949. // -------------------------------------------------------------------------
  950. // BaseContainer --> WriteKindInfo
  951. //
  952. //      Writes Base Container kind into the storage unit.
  953. //
  954. //      -> private method of BaseContainer
  955. // -------------------------------------------------------------------------
  956.  
  957. SOM_Scope       void
  958. SOMLINK         BaseContainerWriteKindInfo
  959.                 (
  960.                 BaseContainer   *somSelf,       // in
  961.                 Environment     *ev,            // in
  962.                 ODStorageUnit   *toSU           // in
  963.                 )
  964. {
  965.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  966.     BaseContainerMethodDebug("BaseContainer", "BaseContainerWriteKindInfo");
  967.  
  968.     try {
  969.  
  970.          InitPropVal (ev, toSU, kODPropContents, kBaseContainerPartKind);
  971.  
  972.     } // end of try block
  973.     catch (...) {}
  974.  
  975. }
  976.  
  977.  
  978. // -------------------------------------------------------------------------
  979. // BaseContainer --> WriteContents
  980. //
  981. //      Writes part's content to storage.
  982. //
  983. //      -> This method is a private method of BaseContainer
  984. //
  985. // -------------------------------------------------------------------------
  986. SOM_Scope       void
  987. SOMLINK         BaseContainerWriteContents
  988.                 (
  989.                 BaseContainer   *somSelf,       // in
  990.                 Environment     *ev,            // in
  991.                 ODStorageUnit   *toSU,          // in
  992.                 BCCloneInfo     *cloneInfo,
  993.                 ODULong         writeKind
  994.                 )
  995.  
  996. {
  997.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  998.     BaseContainerMethodDebug("BaseContainer", "BaseContainerWriteContents");
  999.  
  1000.     try {
  1001.  
  1002.     // Focus on the contents property
  1003.     if(!ODSUExistsThenFocus(ev, toSU, kODPropContents, kBaseContainerPartKind)) {
  1004.        InitPropVal (ev, toSU, kODPropContents, kBaseContainerPartKind);
  1005.     }
  1006.  
  1007.     // Store the _lastFrameRect. This is the bounding rectangle of our frame,
  1008.     // the last time we were displayed as a frame view.
  1009.     ODSetRectProp(ev, toSU, kODNULL, kODNULL, &_lastFrameRect);
  1010.  
  1011.     // Store the content extent
  1012.     ODPoint extent(0,0);
  1013.     ODFrame *dispFrame = (ODFrame *)(_fDisplayFrames->First(ev)->Content(ev));
  1014.     if(dispFrame) {
  1015.        dispFrame->GetContentExtent(ev, &extent);
  1016.     }
  1017.     ODSetPointProp(ev, toSU, kODNULL, kODNULL, &extent);
  1018.  
  1019.     // Write out the background color
  1020. #ifdef _PLATFORM_UNIX_
  1021.     // For Unix we need to store RGB values separately
  1022.     XColor color;
  1023.     color.pixel = _fBackgroundColor;
  1024.     XQueryColor(_fDisplay,
  1025.       XDefaultColormapOfScreen( _fSession->GetWindowState(ev)->GetScreen(ev)),
  1026.       &color);
  1027.     ODULong col = ((color.red & 0xFF00) << 8) |
  1028.                   (color.green & 0xFF00) | ((color.blue & 0xFF00) >> 8);
  1029.     ODSetULongProp (ev, toSU, kODPropBackgroundColor, kPropBackground, col);
  1030.  
  1031. #elif defined(_PLATFORM_WIN32_)
  1032.     // On Windows, the color is defined as 0x00BBGGRR. We will store it as
  1033.     // 0x00RRGGBB so that it is in the same format in all platforms.
  1034.     COLORREF color = _fBackgroundColor;
  1035.     ExchangeRedAndBlue(color);
  1036.  
  1037.     ODSetULongProp (ev, toSU, kODPropBackgroundColor, kPropBackground, color);
  1038. #else
  1039.     ODSetULongProp (ev, toSU, kODPropBackgroundColor, kPropBackground, _fBackgroundColor);
  1040. #endif
  1041.  
  1042.     // Write part icon
  1043.     somSelf->WriteIconToSU (ev, toSU);
  1044.  
  1045.     // Write out display frames
  1046.     // We always store a weak reference to our display frames
  1047.  
  1048.     ALink* itr                   = kODNULL;
  1049.     ODFrame *displayFrame        = kODNULL;
  1050.     ODStorageUnitRef aSURef;
  1051.     ODULong offset = 0;
  1052.     ODDraft *fromDraft = somSelf->GetStorageUnit (ev) -> GetDraft (ev);
  1053.  
  1054.     InitPropVal (ev, toSU, kODPropDisplayFrames, kODWeakStorageUnitRef);
  1055.  
  1056.     for (itr = _fDisplayFrames->First(ev); itr->Content(ev); itr=itr->Next(ev))
  1057.     {
  1058.          displayFrame = (ODFrame*) itr->Content(ev);
  1059.          ODID frameID = displayFrame->GetStorageUnit (ev) ->GetID (ev);
  1060.  
  1061.          if (writeKind == EXTERNALIZE)
  1062.               displayFrame->Externalize(ev);
  1063.          else
  1064.               frameID = fromDraft->WeakClone(ev, cloneInfo->key, frameID, 0, 0);
  1065.  
  1066.          ODSetWeakSURefProp (ev, toSU, kODNULL, kODNULL, frameID);
  1067.     }
  1068.  
  1069.     // Write out embedded frames
  1070.     // Store strong reference to embedded frames.
  1071.  
  1072.     ContentObject *embeddedObject        = kODNULL;
  1073.     ALinkedList *frameList         = (writeKind == CLONE_SELECTED) ?
  1074.                                   _fSelectedObjects : _fEmbeddedObjects;
  1075.  
  1076.     ODPoint * tmpPt = new ODPoint;
  1077.     cloneInfo->refPoint = tmpPt;
  1078.  
  1079.     // Compute the embedOrigin value if CLONE_SELECTED
  1080.  
  1081.     if (writeKind == CLONE_SELECTED) {
  1082.          if (_fSelectShape) {
  1083.               ODRect sRect;
  1084.               _fSelectShape->GetBoundingBox (ev, &sRect);
  1085.               InflateRect (&sRect, -1 * kODBorderWidth, -1 * kODBorderWidth);
  1086.               cloneInfo->refPoint->x = sRect.left;
  1087.               cloneInfo->refPoint->y = sRect.top;
  1088.  
  1089.               // write out a preferred shape so that destination can use it
  1090.               toSU->AddProperty (ev, kODPropSuggestedFrameShape);
  1091.               ODFrame *aFrame = (ODFrame *)_fDisplayFrames->First(ev)->Content(ev);
  1092.               TempODShape tempShape = aFrame->CreateShape(ev);
  1093.  
  1094.               sRect.right -= sRect.left;
  1095.               sRect.left = 0;
  1096. #if (defined (_PLATFORM_WIN32_) || defined(_PLATFORM_UNIX_))
  1097.               sRect.bottom -= sRect.top;
  1098.               sRect.top = 0;
  1099. #elif defined (_PLATFORM_OS2_)
  1100.               sRect.top -= sRect.bottom;
  1101.               sRect.bottom = 0;
  1102. #endif
  1103.               tempShape->SetRectangle (ev, &sRect);
  1104.               tempShape->WriteShape(ev, toSU);
  1105.          }
  1106.     }
  1107.     else {
  1108.        cloneInfo->refPoint->x = cloneInfo->refPoint->y = 0;
  1109.     }
  1110.  
  1111.     // Write the frame list header into the kODFrameList value of our contents
  1112.     // property. The body of the frame list will be generated as the frames
  1113.     // write their own contents. If there are no embedded frames, nothing will
  1114.     // be written out.
  1115.     somSelf->WriteFrameListHeader(ev, toSU, cloneInfo, writeKind, frameList);
  1116.  
  1117.     InitPropVal (ev, toSU, kODPropEmbeddedFrames, kODStrongStorageUnitRef);
  1118.  
  1119.     ODULong num = frameList->Count(ev);
  1120.     ODSetULongProp (ev, toSU, kODNULL, kODNULL, num);
  1121.  
  1122.     for (itr = frameList->First(ev); itr->Content(ev); itr=itr->Next(ev))
  1123.     {
  1124.          embeddedObject = (ContentObject *) itr->Content(ev);
  1125.  
  1126.          // Store the object type which will be used in ReadContents to
  1127.          // determine which object to instantiate.
  1128.          ODULong objType = embeddedObject->_get_objType(ev);
  1129.          ODSetULongProp (ev, toSU, kODNULL, kODNULL, objType);
  1130.  
  1131.          embeddedObject->WriteContents (ev, toSU, writeKind, cloneInfo);
  1132.     }
  1133.  
  1134.     // Release any memory allocated for the frameListInfo
  1135.     if(cloneInfo->frameListInfo) somSelf->ReleaseFrameListInfo(ev, cloneInfo);
  1136.  
  1137.     } // end of try block
  1138.     catch (...) {}
  1139.  
  1140.  
  1141. }
  1142.  
  1143.  
  1144. // -------------------------------------------------------------------------
  1145. // BaseContainer --> ReadKindInfo
  1146. //
  1147. //      Reads Base Container kind from the storage unit.
  1148. //
  1149. //      -> private method of BaseContainer
  1150. // -------------------------------------------------------------------------
  1151.  
  1152. SOM_Scope       ODBoolean
  1153. SOMLINK         BaseContainerReadKindInfo
  1154.                 (
  1155.                 BaseContainer   *somSelf,       // in
  1156.                 Environment     *ev,            // in
  1157.                 ODStorageUnit   *fromSU           // in
  1158.                 )
  1159. {
  1160.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  1161.     BaseContainerMethodDebug("BaseContainer", "BaseContainerReadKindInfo");
  1162.  
  1163.     ODBoolean bExists = kODFalse;
  1164.  
  1165.     try {
  1166.  
  1167.     bExists = fromSU->Exists (ev, kODPropContents, kBaseContainerPartKind, 0);
  1168.     if(!bExists) {
  1169.        bExists = fromSU->Exists (ev, kODPropContents, kBaseContainerOldPartKind, 0);
  1170.     }
  1171.  
  1172.     } // end of try block
  1173.     catch (...) {}
  1174.  
  1175.     return bExists;
  1176. }
  1177.  
  1178.  
  1179. // -------------------------------------------------------------------------
  1180. // BaseContainer --> ReadContents
  1181. //
  1182. //      Read part's content from storage.
  1183. //
  1184. //      -> This method is a private method of BaseContainer
  1185. //
  1186. // -------------------------------------------------------------------------
  1187. SOM_Scope       void
  1188. SOMLINK         BaseContainerReadContents
  1189.                 (
  1190.                 BaseContainer   *somSelf,       // in
  1191.                 Environment     *ev,            // in
  1192.                 ODStorageUnit   *fromSU,          // in
  1193.                 BCCloneInfo     *cloneInfo,
  1194.                 ODULong         readKind
  1195.                 )
  1196.  
  1197. {
  1198.    BaseContainerData *somThis = BaseContainerGetData(somSelf);
  1199.    BaseContainerMethodDebug("BaseContainer", "BaseContainerReadContents");
  1200.  
  1201.    ODBoolean foundEmbeddedFrames = kODFalse;
  1202.  
  1203.    try {
  1204.  
  1205.     // Focus on our contents property
  1206.     if(ODSUExistsThenFocus(ev, fromSU, kODPropContents, kBaseContainerPartKind)) {
  1207.  
  1208.        // Read the _lastFrameRect. This is the bounding rectangle of our frame,
  1209.        // the last time we were displayed as a frame view.
  1210.        ODGetRectProp(ev, fromSU, kODNULL, kODNULL, &_lastFrameRect);
  1211.  
  1212.        // Read the content extent
  1213.        ODPoint extent;
  1214.        if(ODGetPointProp(ev, fromSU, kODNULL, kODNULL, &extent)) {
  1215.           ODFrame *dispFrame = cloneInfo->myFrame;
  1216.           if(dispFrame) {
  1217.              dispFrame->ChangeContentExtent(ev, &extent);
  1218.           }
  1219.        }
  1220.     } else {
  1221.        ODFrame *dispFrame = cloneInfo->myFrame;
  1222.        if(dispFrame){
  1223.  
  1224.           // Update the content extent 
  1225.           somSelf->UpdateContentExtent(ev, dispFrame);
  1226.  
  1227.           // Store the frame's bounding box for viewtype support
  1228.           TempODShape currShape = dispFrame->AcquireFrameShape(ev, kODNULL);
  1229.           currShape->GetBoundingBox(ev, &_lastFrameRect);
  1230.        }
  1231.     }
  1232.  
  1233.     ODDraft *fromDraft = fromSU->GetDraft (ev);
  1234.     ODDraft *toDraft = somSelf->GetStorageUnit (ev) ->GetDraft (ev);
  1235.  
  1236.     // Read Embedded frames
  1237.     if ( ODSUExistsThenFocus (ev, fromSU, kODPropEmbeddedFrames, kODStrongStorageUnitRef))
  1238.         foundEmbeddedFrames = kODTrue;
  1239.     else if ( ODSUExistsThenFocus (ev, fromSU, kODPropEmbeddedFramesOld, kODStrongStorageUnitRef))
  1240.         foundEmbeddedFrames = kODTrue;
  1241.  
  1242.     if (foundEmbeddedFrames == kODTrue)
  1243.     {
  1244.          ODULong num = 0;
  1245.          num = ODGetULongProp (ev, fromSU, kODNULL, kODNULL);
  1246.  
  1247.          int i = 0;
  1248.          for (i = 0; i < num; i++) {
  1249.  
  1250.              ODULong objType = 0;
  1251.              objType = ODGetULongProp (ev, fromSU, kODNULL, kODNULL);
  1252.              ContentObject *contObj = 0;
  1253.              somSelf->GetContentObjectFromObjType(ev, objType, &contObj);
  1254.              if (contObj) {
  1255.                  contObj->ReadContents(ev, fromSU, readKind, cloneInfo);
  1256.                  contObj->_set_linkStatus (ev, kODNotInLink);
  1257.                  _fEmbeddedObjects->AddLast(ev, contObj);
  1258.  
  1259.                  if (contObj->_get_objType(ev) ==  COBJ_FRAMECLASS)
  1260.                  {
  1261.                     ODFrame *embedFrame = ((ContentFrame *)contObj)->_get_myFrame(ev);
  1262.                     embedFrame->SetDragging(ev, kODFalse);
  1263.                     embedFrame->SetInLimbo (ev, kODFalse);
  1264.                  }
  1265.              }
  1266.          }
  1267.  
  1268.     } else if( ODSUExistsThenFocus(ev, fromSU, kODPropContents, kODFrameList) ) {
  1269.  
  1270.  
  1271.        // Read the frameList header and setup information in frameListInfo
  1272.        FrameListHeader header;
  1273.        memset(&header, 0, sizeof(header));
  1274.        somSelf->ReadFrameListHeader(ev, fromSU, cloneInfo, readKind, &header);
  1275.  
  1276.        // Read all frames
  1277.        int i;
  1278.        for(i = 0; i < header.numFrames; i++) {
  1279.  
  1280.           ContentFrame *contentFrame = new ContentFrame();
  1281.           contentFrame->ReadContents(ev, fromSU, readKind, cloneInfo);
  1282.  
  1283.           ODFrame *frame = contentFrame->_get_myFrame(ev);
  1284.  
  1285.           // Complete initialization of the content frame object.
  1286.           contentFrame->_set_linkStatus(ev, kODNotInLink);
  1287.           frame->SetDragging(ev, kODFalse);
  1288.           frame->SetInLimbo (ev, kODFalse);
  1289.  
  1290.           // Add frame to list of embedded objects
  1291.           _fEmbeddedObjects->AddLast(ev, contentFrame);
  1292.  
  1293.        }
  1294.  
  1295.        // Deallocate memory for frameListInfo
  1296.        somSelf->ReleaseFrameListInfo(ev, cloneInfo);
  1297.  
  1298.     }
  1299.  
  1300.    } // end of try block
  1301.    catch (...) {}
  1302.  
  1303. }
  1304.  
  1305.  
  1306. // -------------------------------------------------------------------------
  1307. // BaseContainer --> WriteSingleFrame
  1308. //
  1309. //      Write a single embedded frame to destination unit.
  1310. //
  1311. //      -> This method is a private method of BaseContainer
  1312. //
  1313. // -------------------------------------------------------------------------
  1314. SOM_Scope       void
  1315. SOMLINK         BaseContainerWriteSingleFrame
  1316.                 (
  1317.                 BaseContainer   *somSelf,       // in
  1318.                 Environment     *ev,            // in
  1319.                 ODFrame         *embeddedFrame, // in
  1320.                 ODStorageUnit   *toSU,          // in
  1321.                 ODCloneKind     cloneKind
  1322.                 )
  1323.  
  1324. {
  1325.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  1326.     BaseContainerMethodDebug("BaseContainer", "BaseContainerWriteSingleFrame");
  1327.  
  1328.     ODDraftKey key = 0;
  1329.     ODDraft* fromDraft = somSelf->GetStorageUnit(ev)->GetDraft(ev);
  1330.  
  1331.     try {
  1332.  
  1333.          ODDraft* toDraft = toSU->GetDraft(ev);
  1334.          ODDraftKey key = 0;
  1335.          ODID toRootID = 0;
  1336.          ODID toFrameID = 0;
  1337.  
  1338.          key = fromDraft->BeginClone(ev, toDraft, kODNULL, cloneKind);
  1339.  
  1340.          // Clone the embedded part to the root storage unit
  1341.          TempODPart tempPart = embeddedFrame->AcquirePart(ev);
  1342.          toRootID = fromDraft->Clone(ev, key, tempPart->GetID(ev), toSU->GetID(ev),
  1343.                                      embeddedFrame->GetID(ev));
  1344.          // Clone the embedded frame to any storage unit;
  1345.          // must be done after cloning the part because
  1346.          // the embedded frame strongly references the part.
  1347.          toFrameID = fromDraft->Clone(ev, key, embeddedFrame->GetID(ev), 0,
  1348.                                       embeddedFrame->GetID(ev));
  1349.  
  1350.          if (toFrameID) {
  1351.  
  1352.             ODSetWeakSURefProp (ev, toSU, kODPropContentFrame, kODWeakStorageUnitRef, toFrameID);
  1353.  
  1354.             toSU->AddProperty (ev, kODPropSuggestedFrameShape);
  1355.             TempODShape tempShape = embeddedFrame->AcquireFrameShape(ev, kODNULL);
  1356.             tempShape->WriteShape(ev, toSU);
  1357.  
  1358.             ODFacet *embeddedFacet = FirstFacet (ev, embeddedFrame);
  1359.             if (embeddedFacet)
  1360.             {
  1361.                TempODTransform embedXform = embeddedFacet->AcquireExternalTransform (ev, kODNULL);
  1362.                toSU->AddProperty (ev, kBCSuggestedTransform);
  1363.                embedXform->WriteTo (ev, toSU);
  1364.             }
  1365.  
  1366.          }
  1367.  
  1368.          fromDraft->EndClone(ev, key);
  1369.  
  1370.     } // end of try block
  1371.     catch(ODException _exception) {
  1372.          if (key)
  1373.             fromDraft->AbortClone (ev, key);
  1374.     } // end of catch block
  1375.  
  1376. }
  1377.  
  1378.  
  1379. // -------------------------------------------------------------------------
  1380. // BaseContainer --> ReadSingleFrame
  1381. //
  1382. //      Read a single embedded frame from destination unit.
  1383. //
  1384. //      -> This method is a private method of BaseContainer
  1385. //
  1386. // -------------------------------------------------------------------------
  1387. SOM_Scope       ODFrame *
  1388. SOMLINK         BaseContainerReadSingleFrame
  1389.                 (
  1390.                 BaseContainer   *somSelf,       // in
  1391.                 Environment     *ev,            // in
  1392.                 ODFacet         *myFacet,        // in
  1393.                 ODStorageUnit   *fromSU,        // in
  1394.                 ODCloneKind     cloneKind,
  1395.                 ODPoint         *refPoint
  1396.                 )
  1397.  
  1398. {
  1399.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  1400.     BaseContainerMethodDebug("BaseContainer", "BaseContainerReadSingleFrame");
  1401.  
  1402.     ODDraftKey key = 0;
  1403.     ODFrame *newFrame = 0;
  1404.     ODDraft* fromDraft = fromSU->GetDraft(ev);
  1405.  
  1406.     try {
  1407.  
  1408.          ODDraft* toDraft = somSelf->GetStorageUnit(ev)->GetDraft(ev);
  1409.          ODFrame *myDisplayFrame = myFacet->GetFrame (ev);
  1410.          ODID newPartID = 0;
  1411.          ODID newFrameID = 0;
  1412.          TempODPart newPart = 0;
  1413.  
  1414.          // get the part
  1415.          key = fromDraft->BeginClone (ev, toDraft, myDisplayFrame, cloneKind);
  1416.          newPartID = fromDraft->Clone (ev, key, fromSU->GetID(ev), 0, 0);
  1417.  
  1418.          if (newPartID == kODNULL)
  1419.          {
  1420.             fromDraft->EndClone (ev, key);
  1421.             return kODNULL;
  1422.          }
  1423.  
  1424.          ODStorageUnitRef aSURef;
  1425.          ODID oldFrameID = 0;
  1426.  
  1427.          // get the frame
  1428.          if (ODSUExistsThenFocus (ev, fromSU, kODPropContentFrame, kODWeakStorageUnitRef))
  1429.          {
  1430.  
  1431.             oldFrameID = ODGetWeakSURefProp (ev, fromSU, kODPropContentFrame, kODWeakStorageUnitRef);
  1432.             newFrameID = fromDraft->Clone (ev, key, oldFrameID, 0, 0);
  1433.             newFrame = toDraft->AcquireFrame (ev, newFrameID);
  1434.             newFrame->SetContainingFrame (ev, myDisplayFrame);
  1435.          }
  1436.          fromDraft->EndClone (ev, key);
  1437.  
  1438.          // Part is acquired only AFTER the frame is read in else EXCEPTION
  1439.          newPart = toDraft->AcquirePart (ev, newPartID);
  1440.  
  1441.          if (!newFrame) {
  1442.  
  1443.             // Attempt to create a frame
  1444.             PRINT ("Try to create a frame\n");
  1445.             TempODShape newShape = myDisplayFrame->CreateShape (ev);
  1446.  
  1447.             if (ODSUExistsThenFocus (ev, fromSU, kODPropSuggestedFrameShape, kODNULL))
  1448.                newShape->ReadShape (ev, fromSU);
  1449.             else
  1450.             {
  1451.                ODRect r;
  1452.                r.left = 0;
  1453.                r.right = ODIntToFixed(DEFAULT_EMBED_HEIGHT);
  1454. #if defined(_PLATFORM_OS2_)
  1455.                r.top     = ODIntToFixed(DEFAULT_EMBED_HEIGHT);;
  1456.                r.bottom  = 0;
  1457. #elif (defined(_PLATFORM_WIN32_) || defined(_PLATFORM_UNIX_))
  1458.                r.top     = 0;
  1459.                r.bottom  = ODIntToFixed(DEFAULT_EMBED_HEIGHT);
  1460. #endif
  1461.                newShape->SetRectangle (ev, &r);
  1462.             }
  1463.  
  1464.             newFrame = toDraft->CreateFrame(ev,
  1465.                                             kODFrameObject,     // frameType
  1466.                                             myDisplayFrame,    // containingFrame
  1467.                                             newShape,           // frameShape
  1468.                                             (ODCanvas*)kODNULL, // biasCanvas
  1469.                                             newPart,       // part
  1470.                                             _fFrameView,        // viewType
  1471.                                             _fSession->Tokenize(ev, kODPresDefault),
  1472.                                             kODFalse,           // isRoot
  1473.                                             kODFalse);          // isOverlaid
  1474.          }
  1475.  
  1476.          newFrame->SetDragging (ev, kODFalse);
  1477.          newFrame->SetInLimbo (ev, kODFalse);
  1478.  
  1479.          // create a facet for the frame
  1480.          ODTransform *embedTransform = myDisplayFrame->CreateTransform(ev);
  1481.          if (ODSUExistsThenFocus (ev, fromSU, kBCSuggestedTransform, kODNULL))
  1482.          {
  1483.             // Read in the stored transform and zero out the translation factor
  1484.             // We need to preserve rotation and scaling
  1485.  
  1486.             embedTransform->ReadFrom (ev, fromSU);
  1487.             ODPoint tempOffset;
  1488.             embedTransform->GetOffset (ev, &tempOffset);
  1489.             tempOffset.x = -tempOffset.x; tempOffset.y = -tempOffset.y;
  1490.             embedTransform->MoveBy (ev, &tempOffset);
  1491.          }
  1492.  
  1493.  
  1494.          if (refPoint)
  1495.          {
  1496.             embedTransform->MoveBy (ev, refPoint);
  1497. #if defined (_PLATFORM_OS2_)
  1498.             ODRect frameRect;
  1499.             TempODShape s = newFrame->AcquireFrameShape (ev, kODNULL);
  1500.             s->GetBoundingBox (ev, &frameRect);
  1501.             ODPoint offset(0,0);
  1502.             offset.y = frameRect.bottom - frameRect.top;
  1503.             embedTransform->MoveBy (ev, &offset);
  1504. #endif
  1505.          }
  1506.  
  1507.          TempODShape newFrameShape = newFrame->AcquireFrameShape (ev, kODNULL);
  1508.          ODShape *clipShape = newFrameShape ->Copy (ev);
  1509.  
  1510.          ODFacet *embedFacet = myFacet->CreateEmbeddedFacet (ev, newFrame,
  1511.                                clipShape,embedTransform, kODNULL, kODNULL,
  1512.                                kODNULL, kODFrameInFront);
  1513.  
  1514.          newFrame->Invalidate (ev, kODNULL, kODNULL);
  1515.          newFrame->ChangeLinkStatus (ev, kODNotInLink);
  1516.  
  1517.     } // end of try block
  1518.     catch(ODException _exception) {
  1519.          if (key)
  1520.             fromDraft->AbortClone (ev, key);
  1521.  
  1522.     } // end of catch block
  1523.  
  1524.     return newFrame;
  1525.  
  1526. }
  1527.  
  1528.  
  1529. // -------------------------------------------------------------------------
  1530. // BaseContainer --> GetContentObjectFromObjType
  1531. //
  1532. // -------------------------------------------------------------------------
  1533. SOM_Scope       void
  1534. SOMLINK         BaseContainerGetContentObjectFromObjType
  1535.                 (
  1536.                 BaseContainer   *somSelf,       // in
  1537.                 Environment     *ev,            // in
  1538.                 ODULong         objType,
  1539.                 ContentObject   **contentObject
  1540.                 )
  1541.  
  1542. {
  1543.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  1544.     BaseContainerMethodDebug("BaseContainer", "BaseContainerReadSingleFrame");
  1545.  
  1546.     switch (objType) {
  1547.  
  1548.        case COBJ_BASECLASS:
  1549.           *contentObject = new ContentObject();
  1550.           break;
  1551.  
  1552.        case COBJ_FRAMECLASS:
  1553.           *contentObject = (ContentObject*) new ContentFrame();
  1554.           break;
  1555.  
  1556.        default:
  1557.           WARNMSG(WARN_INDEX(-1), "Invalid type retrieved!!");
  1558.           break;
  1559.     }
  1560. }
  1561.  
  1562.  
  1563. // -------------------------------------------------------------------------
  1564. // BaseContainer--> WriteIconToSU
  1565. //
  1566. // -------------------------------------------------------------------------
  1567.  
  1568. SOM_Scope       void
  1569. SOMLINK         BaseContainerWriteIconToSU
  1570.                 (
  1571.                 BaseContainer       *somSelf,       // in
  1572.                 Environment         *ev,            // in
  1573.                 ODStorageUnit       *toSU   // in
  1574.                 )
  1575. {
  1576.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  1577.     BaseContainerMethodDebug("BaseContainer", "BaseContainerWritePartInfo");
  1578.  
  1579. #ifdef _PLATFORM_OS2_
  1580. // Customized icon support for OS2.
  1581.  
  1582.      HMODULE hmod;
  1583.      ULONG cbIconSize;
  1584.      PBYTE pIconData = NULL;
  1585.      //APITEST rc = 0;
  1586.      CHAR Error[256] = "";
  1587.  
  1588.      DosLoadModule(Error, sizeof(Error), "iodbasec", &hmod);
  1589.  
  1590.      if ( !DosQueryResourceSize( hmod, RT_POINTER, kODIcon, &cbIconSize) &&
  1591.          !DosGetResource( hmod, RT_POINTER, kODIcon, (PPVOID)&pIconData)  )
  1592.      {
  1593.         InitPropVal (ev, toSU,kODPropIconFamily , kODIconFamily);
  1594.         StorageUnitSetValue( toSU, ev, cbIconSize, (ODValue)pIconData );
  1595.         DosFreeResource(pIconData);
  1596.      }
  1597.      else
  1598.         PRINT("DosGetResource failed!\n");
  1599.  
  1600. #endif // _PLATFORM_OS2_
  1601.  
  1602. }
  1603.  
  1604. // -------------------------------------------------------------------------
  1605. // BaseContainer --> WriteFrameListHeader
  1606. //
  1607. //      Writes the header of the frame list to storage.
  1608. //
  1609. //      -> This method is a private method of BaseContainer
  1610. //
  1611. // -------------------------------------------------------------------------
  1612. SOM_Scope       void
  1613. SOMLINK         BaseContainerWriteFrameListHeader
  1614.                 (
  1615.                 BaseContainer   *somSelf,       // in
  1616.                 Environment     *ev,            // in
  1617.                 ODStorageUnit   *toSU,          // in
  1618.                 BCCloneInfo     *cloneInfo,
  1619.                 ODULong         writeKind,
  1620.                 ALinkedList     *objectList
  1621.                 )
  1622.  
  1623. {
  1624.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  1625.     BaseContainerMethodDebug("BaseContainer", "BaseContainerWriteFrameListHeader");
  1626.  
  1627.  
  1628.     ODULong     numFrames      = 0;
  1629.     TempODShape aggregateShape = kODNULL;
  1630.     ALink*      itr            = kODNULL;
  1631.  
  1632.     ContentFrame *embeddedObject;
  1633.  
  1634.     for (itr = objectList->First(ev); itr->Content(ev); itr=itr->Next(ev))
  1635.     {
  1636.        embeddedObject = (ContentFrame *) (itr->Content(ev));
  1637.  
  1638.        // Only account for embedded frames. Do not include intrinsic content.
  1639.        if(embeddedObject->_get_objType(ev) != COBJ_FRAMECLASS) continue;
  1640.  
  1641.        // Get the embedded frame shape in its containing part content coordinates.
  1642.        ODFrame     *frame     = embeddedObject->_get_myFrame(ev);
  1643.        ODFacet     *facet     = FirstFacet(ev, frame);
  1644.        TempODShape frameShape = frame->AcquireFrameShape(ev, kODNULL);
  1645.        TempODShape tempShape  = frameShape->Copy(ev);
  1646.        TempODTransform xform  = facet->AcquireExternalTransform(ev, kODNULL);
  1647.        tempShape->Transform(ev, xform);
  1648.  
  1649.        if(aggregateShape == kODNULL){
  1650.           aggregateShape = frame->CreateShape(ev);
  1651.        }
  1652.  
  1653.        // AggregateShape is the union of all frame shapes. It is different
  1654.        // from the selected shape because it does not include intrinsic
  1655.        // content.
  1656.        aggregateShape->Union(ev, tempShape);
  1657.  
  1658.        numFrames++;
  1659.     }
  1660.  
  1661.     // If there are no embedded frames, there is nothing to externalize.
  1662.     if(numFrames == 0) return;
  1663.  
  1664.     // AggreagateBBox is the imaginary box bounding all of the embedded frames.
  1665.     // It is defined in the containing part's content coordinates.
  1666.     ODRect aggregateBBox;
  1667.     aggregateShape->GetBoundingBox(ev, &aggregateBBox);
  1668.  
  1669.     // Offset is the top-left coordinate of the aggregate bounding box,
  1670.     // assuming a top-left origin coordinate system.
  1671.     ODPoint offset = aggregateBBox.TopLeft();
  1672. #ifdef _PLATFORM_OS2_
  1673.     embeddedObject->ChangePointBias(ev, &offset);
  1674. #endif
  1675.  
  1676.     // Extent is the width and height of the aggregate bounding box.
  1677.     ODPoint extent(aggregateBBox.Width(), aggregateBBox.Height());
  1678.  
  1679.     ODFrame *containingFrame = cloneInfo->myFrame;
  1680.     if(!containingFrame) {
  1681.        // When we externalize, the information in cloneInfo does not include
  1682.        // the containing frame. Use the first display frame as the containing
  1683.        // frame.
  1684.        containingFrame = (ODFrame *)_fDisplayFrames->First(ev)->Content(ev);
  1685.     }
  1686.  
  1687.     // The scaling factor is the scale of the internal transform of the
  1688.     // containing frame.
  1689.     ODPoint scale;
  1690.     TempODTransform intXForm = containingFrame->AcquireInternalTransform(ev, kODNULL);
  1691.     intXForm->GetScale(ev, &scale);
  1692.  
  1693.     // Write the values to the kODFrameList part kind.
  1694.     InitPropVal (ev, toSU, kODPropContents, kODFrameList);
  1695.  
  1696.     ODSetPointProp(ev, toSU, kODNULL, kODNULL, &offset);
  1697.     ODSetPointProp(ev, toSU, kODNULL, kODNULL, &extent);
  1698.     ODSetPointProp(ev, toSU, kODNULL, kODNULL, &scale);
  1699.     ODSetULongProp (ev, toSU, kODNULL, kODNULL, numFrames);
  1700.  
  1701.     // Allocate memory for the frameList information structure in cloneInfo.
  1702.     cloneInfo->frameListInfo = (BCFrameListInfo *)SOMMalloc(sizeof(BCFrameListInfo));
  1703.  
  1704.     // Create a cursor that points to the current position in the framelist
  1705.     // value.
  1706.     cloneInfo->frameListInfo->cursor = toSU->CreateCursorWithFocus(ev);
  1707.  
  1708.     // Store the offset in the frame list info. It is needed to calculate
  1709.     // the bounding box coordinates that will be stored for each frame.
  1710.     cloneInfo->frameListInfo->offset = offset;
  1711.  
  1712. }
  1713.  
  1714. // -------------------------------------------------------------------------
  1715. // BaseContainer --> ReadFrameListHeader
  1716. //
  1717. //      Reads frameList header from storage and sets up frameListInfo
  1718. //      structure.
  1719. //
  1720. //      -> This method is a private method of BaseContainer
  1721. //
  1722. // -------------------------------------------------------------------------
  1723. SOM_Scope       void
  1724. SOMLINK         BaseContainerReadFrameListHeader
  1725.                 (
  1726.                 BaseContainer   *somSelf,       // in
  1727.                 Environment     *ev,            // in
  1728.                 ODStorageUnit   *fromSU,          // in
  1729.                 BCCloneInfo     *cloneInfo,
  1730.                 ODULong         readKind,
  1731.                 FrameListHeader *header
  1732.                 )
  1733.  
  1734. {
  1735.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  1736.     BaseContainerMethodDebug("BaseContainer", "BaseContainerReadFrameListHeader");
  1737.  
  1738.     ODGetPointProp(ev, fromSU, kODNULL, kODNULL, &(header->offset));
  1739.     ODGetPointProp(ev, fromSU, kODNULL, kODNULL, &(header->extent));
  1740.     ODGetPointProp(ev, fromSU, kODNULL, kODNULL, &(header->scale));
  1741.     header->numFrames = ODGetULongProp(ev, fromSU, kODNULL, kODNULL);
  1742.  
  1743.     // Allocate memory for the frameList information structure in cloneInfo.
  1744.     cloneInfo->frameListInfo = (BCFrameListInfo *)SOMMalloc(sizeof(BCFrameListInfo));
  1745.     memset (cloneInfo->frameListInfo, 0, sizeof (BCFrameListInfo));
  1746.  
  1747.     cloneInfo->frameListInfo->offset = header->offset;
  1748.  
  1749. }
  1750.  
  1751. // -------------------------------------------------------------------------
  1752. // BaseContainer --> ReleaseFrameListInfo
  1753. //
  1754. //      Releases the frameListInfo->cursor and the frameListInfo structure
  1755. //      of the cloneInfo structure.
  1756. //
  1757. //      -> This method is a private method of BaseContainer
  1758. //
  1759. // -------------------------------------------------------------------------
  1760. SOM_Scope       void
  1761. SOMLINK         BaseContainerReleaseFrameListInfo
  1762.                 (
  1763.                 BaseContainer   *somSelf,       // in
  1764.                 Environment     *ev,            // in
  1765.                 BCCloneInfo     *cloneInfo
  1766.                 )
  1767. {
  1768.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  1769.     BaseContainerMethodDebug("BaseContainer", "BaseContainerReleaseFrameListInfo");
  1770.  
  1771.     if(cloneInfo->frameListInfo) {
  1772.  
  1773.        // Delete the storage unit cursor
  1774.        if(cloneInfo->frameListInfo->cursor)
  1775.           cloneInfo->frameListInfo->cursor->somFree();
  1776.  
  1777.        // Deallocate memory for frameListInfo
  1778.        SOMFree(cloneInfo->frameListInfo);
  1779.        cloneInfo->frameListInfo = kODNULL;
  1780.     }
  1781. }
  1782.