home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODF-Interest Archive / September 96 / Solution... < prev    next >
Encoding:
Internet Message Format  |  1996-09-19  |  2.1 KB  |  [TEXT/ttxt]

  1. Subject:     Solution...
  2. Sent:        9/18/96 10:32 AM
  3. Received:    9/18/96 10:32 AM
  4. From:        Adam Nash <adamnash@CS.Stanford.EDU>
  5. Reply-To:    ODF-Interest@CILabs.ORG
  6. To:          OpenDoc Development Framework Discussion List
  7.  
  8.  
  9. Hi Everyone,
  10.     In a manner that I hope is emulated, I am going to post the
  11. solution to my problem, as provided by Thomas Weisbach of the OpenDoc team:
  12.  
  13. The key is using the ODSession to resolve a particular type.  So, in
  14. my case, I wanted really to resolv the ' snd' type, while others might
  15. want to resolve 'moov', 'PICT', '3DMF'.  
  16.  
  17. Here is the sample code that I used:  (Note the use of TempODType, which
  18. is an OpenDoc utility (not in the OpenDoc API)  It is in the OpenDoc Utility
  19. headers, TempObj.h
  20.  
  21.  
  22.     // Get the proxy shape
  23.     FW_CRect cellRect;
  24.     fSparkView->GetProxyRect(ev, index, cellRect);
  25.     cellRect.Place(FW_kZeroPoint);
  26.     
  27.     // Acquire the shape
  28.     FW_CAcquiredODShape shape = ::FW_NewODShape(ev, cellRect);
  29.     
  30.     // Get the sound type...
  31.     ODSession *session = FW_CSession::GetODSession(ev);
  32.     TempODType type = session->GetTranslation(ev)->GetISOTypeFromPlatformType(ev,'snd ', kODPlatformDataType);
  33.     
  34.     // Ask our draft for the new part
  35.     ODStorageUnit *su = fSparkPart->GetStorageUnit(ev);
  36.     ODDraft *draft = su->GetDraft(ev);
  37.     FW_CAcquiredODPart newPart = draft->CreatePart(ev, type, kODNoEditor);
  38.     
  39.     // Create a proxy for the part
  40.     long silly_hack_here;
  41.     proxy = new CSparkProxy(ev, fSparkPart, fSparkContent, "Untitled Sound", 123456L, FW_CTime::GetCurrentTime());
  42.     proxy->SetCellIndex(index);
  43.     
  44.     // Add the Proxy to the part
  45.     fSparkContent->AddProxy(proxy, index);
  46.     
  47.     // Embed the part into our content
  48.     proxy->Embed(ev, GetPresentation(ev), newPart, NULL, kODFrameObject, 
  49.             shape, 
  50.                 GetPresentation(ev)->GetDefaultEmbeddedFrameViewType(ev),
  51.         NULL, 0, false, false);
  52.  
  53.  
  54.  
  55.     - Adam
  56.  
  57. -- 
  58. Adam Nash                
  59.  
  60. "The opinions expressed above are not necessarily those of
  61.  Apple Computer, Stanford University, or the United States
  62.  of America."
  63.  
  64. CS 198 Coordinator            Apple Research Labs    
  65. Stanford University - Computer Science    Apple Computer, Inc.
  66. (415) 941-4094                (408) 974-5517
  67. adamnash@cs.stanford.edu        adamnash@taurus.apple.com