//====START_GENERATED_PROLOG======================================
//
//
//   COMPONENT_NAME: odscriptableparts
//
//   CLASSES: none
//
//   ORIGINS: 82,27
//
//
//   (C) COPYRIGHT International Business Machines Corp. 1995,1996
//   All Rights Reserved
//   Licensed Materials - Property of IBM
//   US Government Users Restricted Rights - Use, duplication or
//   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
//   	
//   IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
//   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
//   PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
//   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
//   USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
//   OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
//   OR PERFORMANCE OF THIS SOFTWARE.
//
//====END_GENERATED_PROLOG========================================
//
//  @(#) 1.13 com/src/samples/scrbase/iodscrbc.cpp, odbasescript, od96nt, odnt9712d 3/12/97 11:38:39 [3/21/97 17:38:26]
/*
 *  This file was generated by the SOM Compiler and Emitter Framework.
 *  Generated using:
 *      SOM Emitter emitxtm.dll: Development
 */

#ifndef SOM_Module_iodscrbc_Source
#define SOM_Module_iodscrbc_Source
#endif
#define ScriptableBaseContainer_Class_Source
#define M_ScriptableBaseContainer_Class_Source

#include <TempObj.h>
#include <ODMath.h>

#ifndef SOM_ODMenubar_xh
#include <Menubar.xh>
#endif
#ifndef SOM_ODFacet_xh
#include <Facet.xh>
#endif
#ifndef SOM_ODFrame_xh
#include <Frame.xh>
#endif
#ifndef SOM_ODTransform_xh
#include <Trnsform.xh>
#endif
#ifndef SOM_ODFrameFacetIterator_xh
#include <FrFaItr.xh>
#endif
#include "StorageU.xh"
#include "screxten.xh"
#include "StdExts.xh"

#define VARIABLE_MACROS
#include "iodscrbc.xih"
#include "iodbcext.xh"
#include "stdProps.xh"
#include "scrcomp.xh"


#define kODCommandScriptStart (CMD_Offset_Subclass+1)
#define kODCommandScriptEnd   (CMD_Offset_Subclass+2)

#define kScriptableBaseContainerPartKind         "ScriptableBaseContainerPartKind"
#define kScriptableBaseContainerPartHandlerName  "ScriptableBaseContainer"
#define kScriptableBaseContainerPartHandlerDisplayName    "IBM Scriptable Base ContainerPart"
const   ODType   kScriptableBaseContainerPartKindDisplayName = "IBM ScriptableBaseContainer Kind";
const   ODType   kScriptableBaseContainerPartCategory        = "Container";




//==========================================================================
// GetContentFrame - this local utility function will safely get a
//   ODFrame pointer or a null given a linked list item.  It is needed
//   because not all elements of the Content list will be ContentFrame's.
//   Some will be ContentObject's while other types are possible in the
//   future.
//   The argument 'theConent' is specified as a SOMObject but is expected
//   to be either a ContentObject or a ContentFrame.
//==========================================================================

ODFrame * getContentFrame (Environment *ev, SOMObject *theContent) {
   ODFrame *RetFrame = NULL ;                   // default return - null
   char * actualClassName = theContent->somGetClassName() ; // for debug
   ContentFrame *aContentFrame = new ContentFrame ;
                                                // a object known to be a ContentFrame

   if ( theContent->somIsA( aContentFrame->somGetClass() ) ) {
      RetFrame = ((ContentFrame *) theContent)->_get_myFrame(ev);
                                               // if it is a ContentFrame, get the
   }                                           //  associated ODFrame
   delete aContentFrame ;                      // release the temp object
   return RetFrame ;                           // return the Frame
}





//==========================================================================
SOM_Scope void  SOMLINK ScriptableBaseContainerSelectAllParts(ScriptableBaseContainer *somSelf,
                                                               Environment *ev)
{
    ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
    ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainerSelectAllParts");
  somSelf->SelectAll(ev);
}
//==========================================================================
SOM_Scope boolean  SOMLINK ScriptableBaseContainerEmbedPart(ScriptableBaseContainer *somSelf,
                                                             Environment *ev,
                                                            string partKind,
                                                            long x,
                                                            long y)
{
    ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
    ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainerEmbedPart");
    ODPoint *cursorLocation      = new ODPoint;

    cursorLocation->x = ODIntToFixed(x);
    cursorLocation->y = ODIntToFixed(y);


    ODFrame     *frame;
    ODFacet     *facet;
    ODTransform *newExternalTransform;

    frame = (ODFrame *)(somSelf->GetDisplayFrames(ev)->First(ev)->Content(ev));

    do {
      if (! frame)
        break;
      newExternalTransform = frame->CreateTransform(ev);
      if (! newExternalTransform)
        break;
      ODFrameFacetIterator *ffitr  = frame->CreateFacetIterator(ev);
      if (ffitr) {
        facet = (ODFacet *)ffitr->First(ev);
        ODDeleteObject(ffitr);
      }
      if (! facet)
        break;
      // Get the containing frame's windowframe transform
      TempODTransform xform = facet->AcquireWindowContentTransform(ev, kODNULL);

      // Invert the mouse coords (placing it in the containing frame coords)
      xform->InvertPoint(ev, cursorLocation);

      newExternalTransform->SetOffset(ev, cursorLocation);
      somSelf->Embed(ev, (ODType) partKind, frame, newExternalTransform);

    } while (FALSE);

    return(kODTrue);
}
//==========================================================================
SOM_Scope void  SOMLINK ScriptableBaseContainerAbortMenuSelection(ScriptableBaseContainer *somSelf,
                                                                   Environment *ev)
{
  ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
  ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainerAbortMenuSelection");
  _fDoMenuSelection = kODFalse;

}
//==========================================================================
SOM_Scope void  SOMLINK ScriptableBaseContainerSelectMenuItem(ScriptableBaseContainer *somSelf,
                                                               Environment *ev,
                                                              long menuId)
{
    ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
    ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainerSelectMenuItem");

}

//==========================================================================
SOM_Scope ALinkedList*  SOMLINK ScriptableBaseContainerAcquireContentList(ScriptableBaseContainer *somSelf,
                                                                           Environment *ev)
{
    ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
    ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainerAcquireContentList");

    ALinkedList *newList = NULL,
                *lst     = somSelf->GetEmbeddedObjects(ev);
    ALink       *link    = NULL;

    if (_fScriptExtension && lst) {
      newList =  new ALinkedList();
      if (newList) {
        link = lst->First(ev);
        for (; link && link->Content(ev); link = link->Next(ev)) {
          ODFrame *frame;
          ODPart  *part;

          frame = getContentFrame(ev, (SOMObject *)link->Content(ev)) ;
          if (frame) {
            part = frame->AcquirePart(ev); //->GetRealPart(ev);
            if (part) {
              part->Acquire(ev);
              newList->AddLast(ev, (ODPtr) part);
            }
          }
        }
      }
    }
    return(newList);
}

//==========================================================================
SOM_Scope void  SOMLINK ScriptableBaseContainerReleaseContentList(ScriptableBaseContainer *somSelf,
                                                                   Environment *ev,
                                                                  ALinkedList* list)
{
    ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
    ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainerReleaseContentList");

    if (_fScriptExtension && list) {
      for (ALink *link = list->First(ev);
           link && link->Content(ev);
           link = link->Next(ev)) {

          ODPart *part = (ODPart *) link->Content(ev);
          part->Release(ev);
        }
      delete list;
    }
}

//==========================================================================

SOM_Scope void  SOMLINK ScriptableBaseContainerPartAdded(ScriptableBaseContainer *somSelf,
                                                          Environment *ev,
                                                         ContentFrame* cf)
{
    ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
    ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainerPartAdded");

    if (_fScriptExtension) {

      ODFrame *frame = getContentFrame(ev, cf) ;
      ODPart  *part;

      if (frame) {
        part = frame->AcquirePart(ev)->GetRealPart(ev);
        _fScriptExtension->PartAdded(ev, part);
        frame->AcquirePart(ev)->ReleaseRealPart(ev);
      }
    }
}

//==========================================================================

/*
 * SOM_Scope void  SOMLINK ScriptableBaseContainerPartRemoved(ScriptableBaseContainer *somSelf,
 *                                                             Environment *ev,
 *                                                            ODPart* part)
 */

/*
 * The prototype for ScriptableBaseContainerPartRemoved was replaced by the following prototype:
 */
SOM_Scope void  SOMLINK ScriptableBaseContainerPartRemoved(ScriptableBaseContainer *somSelf,
                                                            Environment *ev,
                                                           ODPart* part)
{
    ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
    ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainerPartRemoved");

    if (_fScriptExtension) {
        ODPart *realpart;
        realpart = (ODPart *) part->GetRealPart(ev);
        _fScriptExtension->PartRemoved(ev, realpart);
        part->ReleaseRealPart(ev);
    }

}

//==========================================================================
SOM_Scope void  SOMLINK ScriptableBaseContainerContentChangeCheck(ScriptableBaseContainer *somSelf,
                                                                   Environment *ev,
                                                                  ALinkedList* list)
{
    ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
    ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainerContentChangeCheck");


    if (_fScriptExtension) {

      ALinkedList *lst = somSelf->GetEmbeddedObjects(ev);
      ALink       *link;

      for (link = list->First(ev); link && link->Content(ev); link = link->Next(ev)) {

        if (somSelf->ContainsPart(ev, (ODPart* )link->Content(ev), lst) == kODFalse) {
          somSelf->PartRemoved(ev, (ODPart *) link->Content(ev));
        }
      }
      for (link = lst->First(ev); link && link->Content(ev); link = link->Next(ev)) {

        ODFrame *frame;

        frame = getContentFrame(ev,  (SOMObject *)link->Content(ev));
        if (frame) {
          ODPart *prt = frame->AcquirePart(ev);
          if (prt && list->Contains(ev, (ODPtr) prt) == kODFalse) {
            somSelf->PartAdded(ev, (ContentFrame *) link->Content(ev));
          }
        }
      }
      somSelf->ReleaseContentList(ev, list);
    }
}
//==========================================================================
SOM_Scope ODBoolean  SOMLINK ScriptableBaseContainerContainsPart(ScriptableBaseContainer *somSelf,
                                                                  Environment *ev,
                                                                 ODPart* part,
                                                                 ALinkedList* list)
{
    ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
    ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainerContainsPart");

    ALink *link = NULL;
    if (list) {
      for (link = list->First(ev);
           link && link->Content(ev);
           link = link->Next(ev)) {
        ODFrame *frame;

        frame = getContentFrame(ev, (SOMObject *)link->Content(ev));
        if (frame) {
          ODPart  *prt;
          prt = frame->AcquirePart(ev); //->GetRealPart(ev);
          if (prt == part)
            return(kODTrue);
        }
      }
    }
    return(kODFalse);
}

//==========================================================================

/*
 *Method from the IDL attribute statement:
 *"attribute long BackgroundColor"
 */

SOM_Scope long  SOMLINK ScriptableBaseContainer_get_BackgroundColor(ScriptableBaseContainer *somSelf,
                                                                     Environment *ev)
{
    ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
    ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainer_get_BackgroundColor");

    /* Return statement to be customized: */
    return((long) somSelf->GetBackgroundColor(ev));
}

//==========================================================================
/*
 *Method from the IDL attribute statement:
 *"attribute long BackgroundColor"
 */

SOM_Scope void  SOMLINK ScriptableBaseContainer_set_BackgroundColor(ScriptableBaseContainer *somSelf,
                                                                     Environment *ev,
                                                                    long BackgroundColor)
{
    ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
    ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainer_set_BackgroundColor");
    somSelf->SetBackgroundColor(ev, (COLORREF) BackgroundColor);
}

//==========================================================================
SOM_Scope void  SOMLINK ScriptableBaseContainersomInit(ScriptableBaseContainer *somSelf)
{
    ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
    ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainersomInit");

    _fMenuBar = NULL;
    _fScriptExtension = NULL;
    _fDoMenuSelection = kODTrue;
    ScriptableBaseContainer_parent_BaseContainer_somInit(somSelf);
}

//==========================================================================
SOM_Scope void  SOMLINK ScriptableBaseContainersomUninit(ScriptableBaseContainer *somSelf)
{
    ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
    ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainersomUninit");
    Environment *ev = SOM_CreateLocalEnvironment();

    if (_fMenuBar)
      _fMenuBar->Release(ev);
    if (_fScriptExtension) {
      _fScriptExtension->Release(ev);
      _fScriptExtension = NULL;
    }
    SOM_DestroyLocalEnvironment(ev);
    ScriptableBaseContainer_parent_BaseContainer_somUninit(somSelf);
}

//==========================================================================
SOM_Scope ODBoolean  SOMLINK ScriptableBaseContainerHasExtension(ScriptableBaseContainer *somSelf,
                                                                  Environment *ev,
                                                                 ODType extensionName)
{
    ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
    ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainerHasExtension");

   if (strcmp(extensionName, kODScriptExtension)== 0)
     { return kODTrue ; }

   try
   {
      return (ScriptableBaseContainer_parent_BaseContainer_HasExtension(somSelf,
                                                                      ev,
                                                                      extensionName));
   }
   catch(ODException _exception)
   {
   }

    return kODFalse;
}

//==========================================================================
SOM_Scope ODExtension*  SOMLINK ScriptableBaseContainerAcquireExtension(ScriptableBaseContainer *somSelf,
                                                                         Environment *ev,
                                                                        ODType extensionName)
{
  ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
  ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainerAcquireExtension");

  if (strcmp(extensionName, kODScriptExtension)== 0) {
    if (_fScriptExtension == kODNULL) {
      _fScriptExtension = new ODS_BaseContainer;
      if (_fScriptExtension)  {
        _fScriptExtension->InitScriptExtension(ev,somSelf);
      }
    }
    if (_fScriptExtension != NULL) {
      _fScriptExtension->Acquire(ev) ;
    }
    return _fScriptExtension ;
  }

  try
  {

    return (ScriptableBaseContainer_parent_BaseContainer_AcquireExtension(somSelf,
                                                                          ev,
                                                                          extensionName));
  }
  catch(ODException _exception)
  {
  }

  return kODNULL;
}
//==========================================================================
SOM_Scope void  SOMLINK ScriptableBaseContainerReleaseExtension(ScriptableBaseContainer *somSelf,
                                                                 Environment *ev,
                                                                ODExtension* extension)
{
    ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
    ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainerReleaseExtension");

    try
    {
      if (extension == (ODExtension *) _fScriptExtension)
      {
        delete _fScriptExtension ;
        _fScriptExtension = NULL ;
      }
      else
        ScriptableBaseContainer_parent_BaseContainer_ReleaseExtension(somSelf,
                                                                      ev,
                                                                      extension);
    }
    catch(ODException _exception)
    {
    }
}
//==========================================================================
SOM_Scope void  SOMLINK ScriptableBaseContainerInstallMenuItems(ScriptableBaseContainer *somSelf,
                                                                 Environment *ev,
                                                                ODMenuBar* menuBar)
{
  ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
  ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainerInstallMenuItems");

#if defined(__IBMCPP__) || defined(_IBMR2)
  //nl_catd bcNLSCat;       // NLS message catalog handle
  //char *bcText;           // pointer for NLS message
  //setlocale(LC_ALL,"");

  //bcNLSCat=catopen(BC_NLS_CATALOG, NL_CAT_LOCALE);   // Open NLS message catalog
  char bcText[256];
#else
    char bcText[256];
#endif

  ScriptableBaseContainer_parent_BaseContainer_InstallMenuItems(somSelf,
                                                                ev,
                                                                menuBar);
  menuBar->Acquire(ev);
  _fMenuBar = menuBar;
  ODPlatformMenuItem *mi = new ODPlatformMenuItem;

  // add a menu separator line to EDIT menu
  mi->id=CMD(Dash);
  #if defined(_PLATFORM_WIN32_)
      mi->afAttribute=MF_SEPARATOR;
  #elif defined(_PLATFORM_OS2_)
      mi->afAttribute=CA_TITLESEPARATOR;
  #endif

  menuBar->AddMenuItemLast(ev, IDMS_EDIT, kODNULL, mi);

  mi->afAttribute=0;           // use default attributes
  mi->id=CMD(ScriptStart);
  menuBar->AddMenuItemLast(ev, IDMS_EDIT, kODNULL, mi);
#if defined(__IBMCPP__) || defined(_IBMR2)
  // bcText=catgets(bcNLSCat, BCMSG_SET, BC_MOVE, "Move");
  strcpy(bcText, "Edit Scripts");
#else
  strcpy (bcText, "Edit Scripts");
#endif
  menuBar->SetMenuItemText(ev, IDMS_EDIT, mi->id, bcText);

  mi->id=CMD(ScriptEnd);
  menuBar->AddMenuItemLast(ev, IDMS_EDIT, kODNULL, mi);
#if defined(__IBMCPP__) || defined(_IBMR2)
  // bcText=catgets(bcNLSCat, BCMSG_SET, BC_MOVE, "Move");
  strcpy(bcText, "Remove Scripts");
#else
  strcpy (bcText, "Remove Scripts");
#endif
  menuBar->SetMenuItemText(ev, IDMS_EDIT, mi->id, bcText);


  delete mi;                      // cleanup menuitem buffer

}
//==========================================================================
SOM_Scope ODBoolean  SOMLINK ScriptableBaseContainerHandleMenuEvent(ScriptableBaseContainer *somSelf,
                                                                     Environment *ev,
                                                                    ODFrame* frame,
                                                                    ODEventData* event)
{
    ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
    ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainerHandleMenuEvent");

#ifdef _PLATFORM_WIN32_
    ODCommandID command = event->wParam;
#endif //_PLATFORM_WIN32_
#ifdef _PLATFORM_OS2_
    ODCommandID command = LONGFROMMP(event->mp1);
#endif // _PLATFORM_OS2_

    if (_fScriptExtension) {
      _fDoMenuSelection = kODTrue;
      _fScriptExtension->TriggerMenuEvent(ev, (long) command);
      if (_fDoMenuSelection == kODFalse)
        return(kODTrue);

    }
    switch (command) {

      case CMD(ScriptStart) :
      {
        ODS_BaseContainer *theExt ;
        if ( (theExt=(ODS_BaseContainer *) somSelf->AcquireExtension(ev,kODScriptExtension)) != NULL) {
          theExt->InitScriptEditor(ev) ;
          theExt->Release(ev) ;
          _fMenuBar->EnableMenuItem(ev, IDMS_EDIT,
                                    CMD(ScriptEnd),
                                    kODTrue) ;
        }
        return(kODTrue);
      }
      case CMD(ScriptEnd)   :
      {
        if (_fScriptExtension) {
          _fScriptExtension->EndScripting(ev) ;
          _fMenuBar->EnableMenuItem(ev, IDMS_EDIT,
                                    CMD(ScriptStart),
                                    kODTrue) ;
          // _fScriptExtension->Release(ev);
          // somSelf->ReleaseExtension(ev, _fScriptExtension);
          // _fScriptExtension = NULL;
        }
        return(kODTrue);
      }
      default:
        return (ScriptableBaseContainer_parent_BaseContainer_HandleMenuEvent(somSelf,
                                                                             ev,
                                                                             frame,
                                                                             event));
    }
}
//==========================================================================
SOM_Scope void  SOMLINK ScriptableBaseContainerAdjustMenus(ScriptableBaseContainer *somSelf,
                                                            Environment *ev,
                                                           ODFrame* frame)
{
    ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
    ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainerAdjustMenus");

    ScriptableBaseContainer_parent_BaseContainer_AdjustMenus(somSelf,
                                                             ev,
                                                             frame);
    _fMenuBar->EnableMenuItem(ev, IDMS_EDIT, CMD(ScriptStart), kODTrue);
    _fMenuBar->EnableMenuItem(ev, IDMS_EDIT, CMD(ScriptEnd),
                               (((_fScriptExtension != NULL) &&
                                 (_fScriptExtension->getScrComp(ev) != NULL))
                                ? kODTrue: kODFalse));

}
//==========================================================================
SOM_Scope ContentObject*  SOMLINK ScriptableBaseContainerEmbed(ScriptableBaseContainer *somSelf,
                                                     Environment *ev,
                                                     ODType part,
                                                     ODFrame* containingFrame,
                                                     ODTransform* newEmbedTransform)
{
    ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
    ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainerEmbed");
    ALinkedList *content;
    ContentObject *result;

    content = somSelf->AcquireContentList(ev);

    result = ScriptableBaseContainer_parent_BaseContainer_Embed(somSelf,
                                                                ev, part,
                                                             containingFrame,
                                                           newEmbedTransform);
    somSelf->ContentChangeCheck(ev, content);
    return(result);
}

//==========================================================================
SOM_Scope ODFrame*  SOMLINK ScriptableBaseContainerRequestEmbeddedFrame(ScriptableBaseContainer *somSelf,
                                                                         Environment *ev,
                                                                        ODFrame* containingFrame,
                                                                        ODFrame* baseFrame,
                                                                        ODShape* frameShape,
                                                                        ODPart* embedPart,
                                                                        ODTypeToken viewType,
                                                                        ODTypeToken presentation,
                                                                        ODBoolean isOverlaid)
{
    ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
    ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainerRequestEmbeddedFrame");
    ALinkedList *content;

    content = somSelf->AcquireContentList(ev);
    ODFrame *result;

    result = ScriptableBaseContainer_parent_BaseContainer_RequestEmbeddedFrame(somSelf,
                                                                              ev,
                                                                              containingFrame,
                                                                              baseFrame,
                                                                              frameShape,
                                                                              embedPart,
                                                                              viewType,
                                                                              presentation,
                                                                              isOverlaid);
    somSelf->ContentChangeCheck(ev, content);
    return(result);

}

//==========================================================================
SOM_Scope void  SOMLINK ScriptableBaseContainerRemoveEmbeddedFrame(ScriptableBaseContainer *somSelf,
                                                                    Environment *ev,
                                                                   ODFrame* embeddedFrame)
{
    ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
    ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainerRemoveEmbeddedFrame");
    ALinkedList *content;

    content = somSelf->AcquireContentList(ev);
    ScriptableBaseContainer_parent_BaseContainer_RemoveEmbeddedFrame(somSelf,
                                                                     ev,
                                                                     embeddedFrame);
    somSelf->ContentChangeCheck(ev, content);
}

//==========================================================================
SOM_Scope void  SOMLINK ScriptableBaseContainerDisplayFrameClosed(ScriptableBaseContainer *somSelf,
                                                                   Environment *ev,
                                                                  ODFrame* frame)
{
    ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
    ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainerDisplayFrameClosed");
    ALinkedList *content;

    content = somSelf->AcquireContentList(ev);
    ScriptableBaseContainer_parent_BaseContainer_DisplayFrameClosed(somSelf,
                                                                    ev,
                                                                    frame);
    somSelf->ContentChangeCheck(ev, content);
}

//==========================================================================
SOM_Scope void  SOMLINK ScriptableBaseContainerDisplayFrameRemoved(ScriptableBaseContainer *somSelf,
                                                                    Environment *ev,
                                                                   ODFrame* frame)
{
    ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
    ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainerDisplayFrameRemoved");
    ALinkedList *content;

    content = somSelf->AcquireContentList(ev);
    ScriptableBaseContainer_parent_BaseContainer_DisplayFrameRemoved(somSelf,
                                                                     ev,
                                                                     frame);
    somSelf->ContentChangeCheck(ev, content);
    ALinkedList *frames = somSelf->GetDisplayFrames(ev);

    if ((frames == NULL || frames->First(ev)->Content(ev) == NULL)
        && _fScriptExtension) {
      _fScriptExtension->EndScripting(ev) ;
    }

}

//==========================================================================
SOM_Scope void  SOMLINK ScriptableBaseContainerPasteSelection(ScriptableBaseContainer *somSelf,
                                                               Environment *ev,
                                                              ODFacet* facet,
                                                              ODPoint* toWhere)
{
    ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
    ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainerPasteSelection");
    ALinkedList *content;

    content = somSelf->AcquireContentList(ev);
    ScriptableBaseContainer_parent_BaseContainer_PasteSelection(somSelf,
                                                                ev,
                                                                facet,
                                                                toWhere);
    somSelf->ContentChangeCheck(ev, content);
}

//==========================================================================
SOM_Scope void  SOMLINK ScriptableBaseContainerDeleteSelection(ScriptableBaseContainer *somSelf,
                                                                Environment *ev,
                                                                ODULong         type)

{
    ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
    ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainerDeleteSelection");
    ALinkedList *content;

    content = somSelf->AcquireContentList(ev);
    ScriptableBaseContainer_parent_BaseContainer_DeleteSelection(somSelf,
                                                                 ev, type);
    somSelf->ContentChangeCheck(ev, content);
}

//==========================================================================

SOM_Scope ODDropResult  SOMLINK ScriptableBaseContainerDrop(ScriptableBaseContainer *somSelf,
                                                             Environment *ev,
                                                            ODDragItemIterator* dropInfo,
                                                            ODFacet* facet,
                                                            ODPoint* where)
{
    ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
    ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainerDrop");
    ODDropResult result;
    ALinkedList *content;

    content = somSelf->AcquireContentList(ev);
    result = ScriptableBaseContainer_parent_BaseContainer_Drop(somSelf,
                                                               ev,
                                                               dropInfo,
                                                               facet,
                                                               where);
    somSelf->ContentChangeCheck(ev, content);
    return(result);
}
//=========================================================================
SOM_Scope void  SOMLINK ScriptableBaseContainerReadContents(ScriptableBaseContainer *somSelf,
                                                             Environment *ev,
                                                            ODStorageUnit* fromSU,
                                                            BCCloneInfo* cloneInfo,
                                                            ODULong readKind)
{
    ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
    ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainerReadContents");
    ALinkedList *content;

    content = somSelf->AcquireContentList(ev);

    ScriptableBaseContainer_parent_BaseContainer_ReadContents(somSelf,
                                                              ev,
                                                              fromSU,
                                                              cloneInfo,
                                                              readKind);
    somSelf->ContentChangeCheck(ev, content);
}
//==========================================================================
SOM_Scope void  SOMLINK ScriptableBaseContainerExternalize(ScriptableBaseContainer *somSelf,
                                                            Environment *ev)
{
    ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
    ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainerExternalize");

    ScriptableBaseContainer_parent_BaseContainer_Externalize(somSelf,
                                                             ev);
    if (_fScriptExtension) {
      ODStorageUnit* su = somSelf->GetStorageUnit(ev);
      _fScriptExtension->ScriptExternalize(ev, su);
    }
}
//==========================================================================
SOM_Scope void  SOMLINK ScriptableBaseContainerInitPartFromStorage(ScriptableBaseContainer *somSelf,
                                                                    Environment *ev,
                                                                   ODStorageUnit* storageUnit,
                                                                   ODPart* partWrapper)
{
    ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
    ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainerInitPartFromStorage");

    ScriptableBaseContainer_parent_BaseContainer_InitPartFromStorage(somSelf,
                                                                     ev,
                                                                     storageUnit,
                                                                     partWrapper);
     if (storageUnit->Exists(ev, kODPropAttachedScriptType, kODNULL, (ODValueIndex)0))
     {
       ODS_BaseContainer *theExt ;
       if ( (theExt=(ODS_BaseContainer *) somSelf->AcquireExtension(ev,kODScriptExtension)) != NULL) {
         theExt->InitScriptFromStorage(ev, somSelf, storageUnit) ;
         theExt->Release(ev) ;
       }
     }

}

//==========================================================================

SOM_Scope void  SOMLINK ScriptableBaseContainerCloneInto(ScriptableBaseContainer *somSelf,
                                                          Environment *ev,
                                                         ODDraftKey key,
                                                         ODStorageUnit* toSU,
                                                         ODFrame* scope)
{
    ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
    ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainerCloneInto");

    ScriptableBaseContainer_parent_BaseContainer_CloneInto(somSelf,
                                                           ev,
                                                           key,
                                                           toSU,
                                                           scope);
    if (_fScriptExtension)
      _fScriptExtension->ScriptExternalize(ev, toSU);
}
//==========================================================================

SOM_Scope void SOMLINK ScriptableBaseContainerFacetAdded(ScriptableBaseContainer *somSelf,
                                                         Environment     *ev,
                                                         ODFacet         *facet)



{
    ScriptableBaseContainerData *somThis = ScriptableBaseContainerGetData(somSelf);
    ScriptableBaseContainerMethodDebug("ScriptableBaseContainer","ScriptableBaseContainerFacetAdded");

    ScriptableBaseContainer_parent_BaseContainer_FacetAdded(somSelf, ev, facet);
    if (_fScriptExtension) {
     _fScriptExtension->TriggerPartContentsInitialized(ev);
    }
}
//==========================================================================
SOM_Scope ISOString  SOMLINK M_ScriptableBaseContainerPartclsGetODPartHandlerName(M_ScriptableBaseContainer *somSelf,
                                                                                   Environment *ev)
{
    /* M_ScriptableBaseContainerData *somThis = M_ScriptableBaseContainerGetData(somSelf); */
    M_ScriptableBaseContainerMethodDebug("M_ScriptableBaseContainer","M_ScriptableBaseContainerPartclsGetODPartHandlerName");

    string handlerName;

    handlerName = (string)SOMMalloc(strlen(kScriptableBaseContainerPartHandlerName)+1);
    strcpy(handlerName,kScriptableBaseContainerPartHandlerName);

    return (ISOString) handlerName;
}

//==========================================================================
SOM_Scope string  SOMLINK M_ScriptableBaseContainerPartclsGetODPartHandlerDisplayName(M_ScriptableBaseContainer *somSelf,
                                                                                       Environment *ev)
{
    /* M_ScriptableBaseContainerData *somThis = M_ScriptableBaseContainerGetData(somSelf); */
    M_ScriptableBaseContainerMethodDebug("M_ScriptableBaseContainer","M_ScriptableBaseContainerPartclsGetODPartHandlerDisplayName");

    string displayName = (string)SOMMalloc(strlen(kScriptableBaseContainerPartHandlerDisplayName)+1);
    strcpy(displayName,kScriptableBaseContainerPartHandlerDisplayName);

    return displayName;
}

//==========================================================================
SOM_Scope _IDL_SEQUENCE_PartKindInfo  SOMLINK M_ScriptableBaseContainerPartclsGetODPartKinds(M_ScriptableBaseContainer *somSelf,
                                                                                              Environment *ev)
{
    /* M_ScriptableBaseContainerData *somThis = M_ScriptableBaseContainerGetData(somSelf); */
    M_ScriptableBaseContainerMethodDebug("M_ScriptableBaseContainer","M_ScriptableBaseContainerPartclsGetODPartKinds");

    _IDL_SEQUENCE_PartKindInfo BaseContainerPartInfo;

    // Create structure PartKindInfo  and allocate memory for its fields
    PartKindInfo * info = (PartKindInfo *)SOMMalloc(sizeof(PartKindInfo));
    info->partKindName = (ISOString) SOMMalloc(strlen(kScriptableBaseContainerPartKind) + 1);
    info->partKindDisplayName = (string)SOMMalloc(strlen(kScriptableBaseContainerPartKindDisplayName)+1);
    info->filenameFilters =  (string)SOMMalloc(strlen("")+1);
    info->filenameTypes =  (string)SOMMalloc(strlen("")+1);
    info->categories =  (string)SOMMalloc(strlen(kScriptableBaseContainerPartCategory)+1);
    info->categoryDisplayName =  (string)SOMMalloc(strlen("")+1);
    info->objectID =  (string)SOMMalloc(strlen("")+1);

    // Copy the information into the structure
    strcpy(info->partKindName , kScriptableBaseContainerPartKind);
    strcpy(info->partKindDisplayName, kScriptableBaseContainerPartKindDisplayName);
    strcpy(info->filenameFilters, "");
    strcpy(info->filenameTypes, "");
    strcpy(info->categories, kScriptableBaseContainerPartCategory);
    strcpy(info->categoryDisplayName, "");
    strcpy(info->objectID, "");

    BaseContainerPartInfo._maximum = 1;
    BaseContainerPartInfo._length = 1;
    BaseContainerPartInfo._buffer = info;

    return BaseContainerPartInfo;
}

//==========================================================================
SOM_Scope string  SOMLINK M_ScriptableBaseContainerPartclsGetOLE2ClassId(M_ScriptableBaseContainer *somSelf,
                                                                          Environment *ev)
{
    /* M_ScriptableBaseContainerData *somThis = M_ScriptableBaseContainerGetData(somSelf); */
    M_ScriptableBaseContainerMethodDebug("M_ScriptableBaseContainer","M_ScriptableBaseContainerPartclsGetOLE2ClassId");

    // OLE2 Class ID is determined by running the tool UUIDGEN.EXE
    // or GUIDGEN.EXE found in the IBM VAC++ SDK\BIN directory
    // this tool is gauranteed to generate a unique ID based on your
    // network address and the time of day (DCE Standard)


    string OLE2 = "{5B3CC201-1816-11D0-BA74-08005AA56CEE}";
    string OLE2ClassId = (string)SOMMalloc(strlen(OLE2)+1);
    strcpy(OLE2ClassId,OLE2);


    return OLE2ClassId;
}

//==========================================================================
SOM_Scope string  SOMLINK M_ScriptableBaseContainerPartclsGetWindowsIconFileName(M_ScriptableBaseContainer *somSelf,
                                                                                  Environment *ev)
{
    /* M_ScriptableBaseContainerData *somThis = M_ScriptableBaseContainerGetData(somSelf); */
    M_ScriptableBaseContainerMethodDebug("M_ScriptableBaseContainer","M_ScriptableBaseContainerPartclsGetWindowsIconFileName");

    string kWindowsIcon = "iodscrbc.ico";
    string WindowsIconFileName = (string)SOMMalloc(strlen(kWindowsIcon)+1);
    strcpy(WindowsIconFileName,kWindowsIcon);
    return(WindowsIconFileName);
}
