//====START_GENERATED_PROLOG======================================
//
//
//   COMPONENT_NAME: odbitmappart
//
//   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.11 com/src/samples/bitmap/iodbitmp.cpp, odbitmappart, od96nt, odnt9714c 3/24/97 18:42:29 [4/2/97 17:54:41]

/*
 *  This file was generated by the SOM Compiler.
 *  Generated using:
 *     SOM incremental update: 2.43
 */


/*
 *  This file was generated by the SOM Compiler and Emitter Framework.
 *  Generated using:
 *      SOM Emitter emitxtm: 2.41
 */

//     This part will be our public utilities testcase.  It currently uses
//     AltPoint, AltPoly, FocusLib, TempObj, ODDebug, ODUtils, BArray,
//     and StdTypIO

//#define OD_CLIPBOARD_CODE           //     use ODClipboard APIs

#ifndef SOM_Module_iodbitmp_Source
#define SOM_Module_iodbitmp_Source
#endif
#define Bitmap_Class_Source
#define VARIABLE_MACROS
#define METHOD_MACROS

// Include alternate ODPoint and ODRect definitions. Used in SizeFrameToBitmap for one.
#ifndef _ALTPOINT_
#include "AltPoint.h"
#endif

#ifdef _PLATFORM_WIN32_
#   include <windows.h>
#   include <winuser.h>
#   include <wingdi.h>
#endif

#   include <odall.h>
#   include <odres.h>

#ifndef _STORUTIL_
#include <storutil.h>
#endif

#   define DosBeep(x, y) Beep(x, y)
#   define NULLHANDLE kODNULL

#include "Resource.h"
#include "iodbitmp.xih"

#ifndef _FOCUSLIB_
#include "FocusLib.h" /* PubUtil for setting up drawing area */
//     used in Draw, InvertDragHilite, and elsewhere
#endif

#ifndef _ODDEBUG_
#include "ODDebug.h"  /* PubUtil for help with debugging (such as logging) */
//     use LOG() in the Drag/Drop code (since ICSDEBUG chokes with the dreaded
//     "PM Resource Interlock" if you hit a breakpoint during a drag)
#endif

#ifndef _ODUTILS_
#include "ODUtils.h"  /* PubUtil for dealing with ref-count objects */
//     provides ODCopyAndRelease (among other things); used in Draw and elsewhere
#endif

#ifndef _TEMPOBJ_
#include "TempObj.h"  /* PubUtil for automatically releasing ref-count objects */
//     provides TempODShape and TempODTransform, whose destructors call
//     Release on the shape/transform as the object goes out of scope
//     used in SizeFrameToBitmap, Draw, and InvertDragHilite
#endif

//     Include wrappers for methods that expect an ODByteArray parameter.
//     Used primarily in Externalize/InitPartFromStorage for Get/SetValue.
#ifndef _BARRAY_
#include "barray.h"   /* PubUtil for dealing with storage system's byte arrays */
#endif

// Include utilities for reversing Endian-ness.
// (ConvertODxxx in Externalize/InitPartFromStorage)
#ifndef _FLIPEND_
#include "FlipEnd.h"
#endif

#include <stdio.h>
#include <stdtypio.h> // Used in InitPart/FromStorage
#include <string.h>

#include "iodbitmp.hpp"

void PrintValues(Environment* ev, ODStorageUnit* storageUnit) {
#ifdef ODDebug
        ODULong numValues = storageUnit->CountValues(ev);
        PRINT("%d unrecognized (and no recognized) part kinds in bitmap SU.\n", numValues);
        //  Iterate through all the values belonging to kODPropContents property and
        //  print them out for debug.
        storageUnit->Focus(ev, kODPropContents, kODPosUndefined, kODNULL,
                           0, kODPosAll);
        for (int i = 1; i <= numValues; i++) {
               storageUnit->Focus(ev, kODNULL, kODPosSame, kODNULL,
                                  0, kODPosNextSib);
               PRINT("Unrecognized value is %s,   ", storageUnit->GetType(ev));
               PRINT("Value size is %d.\n", storageUnit->GetSize(ev));
        }
#endif
}


SOM_Scope void  SOMLINK BitmapCommonInit(Bitmap *somSelf,
                                         Environment *ev,
                                         ODPart *partWrapper)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapCommonInit");

    // Load our resource module before calling SimplePart our resources
    // are loaded when we install our menus.

    Bitmap_parent_SimplePart_CommonInit(somSelf, ev, partWrapper);

   _MySession = _GetStorageUnit(ev)->GetSession(ev);
    _fDraftReadOnly = (somSelf->GetStorageUnit(ev)->
                       GetDraft(ev)->GetPermissions(ev) == kODDPReadOnly);

   _ViewAsSmallIcon = _MySession->Tokenize(ev, kODViewAsSmallIcon);
   _ViewAsLargeIcon = _MySession->Tokenize(ev, kODViewAsLargeIcon);
   _ViewAsThumbnail = _MySession->Tokenize(ev, kODViewAsThumbnail);
   _ViewAsFrame = _MySession->Tokenize(ev, kODViewAsFrame);

//      Note: WIN32 doesn't have memory DC's, so we get the DC
// associated with the facet window during FacetAdded

#ifdef _PLATFORM_OS2_
   /***********************************************************/
   /**** Create memory DC and PS used for bitmap creation. ****/
   /***********************************************************/

   HAB hab=WinQueryAnchorBlock(HWND_DESKTOP);

   _hdcMemory = DevOpenDC (hab, OD_MEMORY, (PSZ)"*", 0L, 0L, 0L);

   SIZEL BitmapDimensions = {0, 0};
   _hpsMemory = GpiCreatePS (hab, _hdcMemory, &BitmapDimensions,
      PU_PELS | GPIF_DEFAULT | GPIT_MICRO | GPIA_ASSOC);
   /**** End of memory DC and PS creation. ****/
#endif

   // Simple Part will call InstallMenus from its CommonInit
}


SOM_Scope char*  SOMLINK BitmapGetBitmapFileName(Bitmap *somSelf,
                                                       Environment *ev,
                                                      ODPlatformWindow hwnd)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapGetBitmapFileName");

   char *ReturnString = (char*) malloc(kODMaxFileNameSize);

try {
   // Invoke PlatOpenDlg to display a File Dialog window and return
   // the name of the bitmap file to open.
   PlatOpenDlg(hwnd, ReturnString);
   if (ReturnString == "") {
      free(ReturnString);
      ReturnString = kODNULL;
   }
} catch(...) {}

   return(ReturnString);
}


SOM_Scope ODBoolean  SOMLINK BitmapLoadBitmap(Bitmap *somSelf,
                                                    Environment *ev)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapLoadBitmap");

   ODBoolean ReturnValue = FAILURE;

try {
   // Delete the previous bitmap if it exists.
   if (_BitmapBuffer != kODNULL) {
      SOMFree(_BitmapBuffer);
      _BitmapBuffer = kODNULL;
      _BitmapFileSize = 0;
   }

   // Invoke PlatReadFile to allocate the buffer for the file and to
   // read the file in.
   ReturnValue = PlatReadFile(_BitmapFileName, _BitmapBuffer, _BitmapFileSize);
   if (ReturnValue == SUCCESS && !strcmp(_fPreferredKind,kKindIBMBitmap))  {
      _EnableFileNameOnly = kODTrue;
   }

} catch(...) {}
   return(ReturnValue);
}


SOM_Scope ODBoolean  SOMLINK BitmapCreateBitmap(Bitmap *somSelf,
                                                      Environment *ev)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapCreateBitmap");
    HBITMAP hbm;
    ODBoolean returnValue = kODFalse;

try {
    _CreatePalette(ev);
    hbm = PlatCreateBitmap(_BitmapFileName, _BitmapBuffer, _hdcMemory);

    if (hbm) {
      _CurrentBitmapHandle = hbm;
      returnValue = kODTrue;
    }

} catch(...) {
    _NoBitmap(ev, kODNULL);
}
   return(returnValue);
}

SOM_Scope HBITMAP  SOMLINK BitmapDuplicateBitmap(Bitmap *somSelf,
                                                       Environment *ev,
                                                      ODFacet* facet,
                                                      HBITMAP source)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapDuplicateBitmap");

   HBITMAP destination = kODNULL;

#ifdef _LEFT_TO_PORT_
   HWND hwnd = facet->GetFacetHWND(ev);
   HAB hab = WinQueryAnchorBlock(hwnd);

   HDC hdcSrc = DevOpenDC(hab, OD_MEMORY, "*", 0L, NULL, NULL);
   HDC hdcDest = DevOpenDC(hab, OD_MEMORY, "*", 0L, NULL, NULL);

   SIZEL size = {0, 0};
   HPS hpsSrc = GpiCreatePS(hab, hdcSrc, &size,
                   PU_PELS | GPIT_MICRO | GPIA_ASSOC);
   HPS hpsDest = GpiCreatePS(hab, hdcDest, &size,
                   PU_PELS | GPIT_MICRO | GPIA_ASSOC);

   BITMAPINFOHEADER2 InfoHeader;
   InfoHeader.cbFix = sizeof(BITMAPINFOHEADER2);
   GpiQueryBitmapInfoHeader(source, &InfoHeader);
   SIZEL BitmapDimensions = {InfoHeader.cx, InfoHeader.cy};

   destination = GpiCreateBitmap(hpsDest, &InfoHeader, 0L, NULL,
                    (BITMAPINFO2 *) &InfoHeader);

   if (destination==GPI_ERROR) {
      short errorid = ERRORIDERROR(WinGetLastError(hab));
      DosBeep(250,500);
   } /* endif */

   GpiSetBitmap(hpsSrc, source);
   GpiSetBitmap(hpsDest, destination);

   POINTL ptl[3];
   ptl[0].x = 0L;
   ptl[0].y = 0L;
   ptl[1].x = BitmapDimensions.cx;
   ptl[1].y = BitmapDimensions.cy;
   ptl[2].x = 0L;
   ptl[2].y = 0L;

   if (GpiBitBlt(hpsDest, hpsSrc, 3L, ptl, ROP_SRCCOPY, BBO_IGNORE)) {
      GpiSetBitmapDimension(destination, &BitmapDimensions);
   } else {
      short errorid = ERRORIDERROR(WinGetLastError(hab));
      DosBeep(250,500);
   } /* endif */

   GpiDestroyPS(hpsSrc);
   GpiDestroyPS(hpsDest);

   DevCloseDC(hdcSrc);
   DevCloseDC(hdcDest);
#endif

   return(destination);
}


SOM_Scope void  SOMLINK BitmapSizeFrameToBitmap(Bitmap *somSelf,
                                                      Environment *ev,
                                                     ODFacet* facet)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapSizeFrameToBitmap");

try {
   ODCanvas *canvas = facet->GetCanvas(ev);
   ODFrame *frame = facet->GetFrame(ev);

   ODWindow *window = facet->GetWindow(ev);
   HWND hwnd = window->GetPlatformWindow(ev);

#ifdef _PLATFORM_WIN32_
   SIZE BitmapDimensions;
   GetBitmapDimensionEx(_CurrentBitmapHandle, &BitmapDimensions);
   RECT frameRect = {0, 0, BitmapDimensions.cx, BitmapDimensions.cy};
#elif defined(_PLATFORM_OS2_)
   SIZEL BitmapDimensions;
   GpiQueryBitmapDimension(_CurrentBitmapHandle, &BitmapDimensions);
   RECTL frameRect = {0, 0, BitmapDimensions.cx, BitmapDimensions.cy};
#endif

   if (!frame->IsRoot(ev)) {
      ODRect frameODRect(frameRect);

      TempODShape newShape = facet->CreateShape(ev);
      newShape->SetRectangle(ev, &frameODRect);

      ODPoint* scale = new ODPoint;
      TempODTransform TempTrans = facet->AcquireFrameTransform(ev, canvas);
      TempTrans->GetScale(ev, scale);

      TempODTransform newTransform = facet->CreateTransform(ev);
      newTransform->ScaleBy(ev, scale);
      newShape->InverseTransform(ev, newTransform);

      frame->RequestFrameShape(ev, newShape, canvas);
      frame->ChangeUsedShape(ev, kODNULL, canvas);

   // If the new bitmap is the same size as the old one, then we don't get a
   // FrameShapeChanged (and thus an invalidate) when we resize the DocShell.
   // (there must be some smarts in there that check to see if the new shape
   // is the same size as the old one before calling FrameShapeChanged)
   } else {
      facet->Invalidate(ev, kODNULL, canvas);
   } /* endif */
} catch(...) {}
}


SOM_Scope ODBoolean  SOMLINK BitmapRealizePalette(Bitmap *somSelf,
                                                        Environment *ev,
                                                       ODFacet* facet)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapRealizePalette");

   ODBoolean ReturnValue=SUCCESS;

#ifdef _LEFT_TO_PORT_
   ODCanvas *canvas = facet->GetCanvas(ev);
   ODPlatformCanvas *pCanvas = canvas->GetPlatformCanvas(ev, kODGPI);
   HPS hpsDraw = pCanvas->GetPS(ev, facet);
   HWND hwnd = facet->GetWindow(ev)->GetPlatformWindow(ev);
   ULONG ColorsChanged;

   if (GpiSelectPalette(hpsDraw, _BitmapPalette)==PAL_ERROR) {
      ReturnValue=FAILURE;
   } /* endif */

   if (WinRealizePalette(hwnd, hpsDraw, &ColorsChanged)==PAL_ERROR) {
      ReturnValue=FAILURE;
   } /* endif */

   pCanvas->ReleasePS(ev, facet);
#endif

   return(ReturnValue);
}

SOM_Scope ODBoolean  SOMLINK BitmapCreatePalette(Bitmap *somSelf,
                                                        Environment *ev)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapCreatePalette");

   ODBoolean result = kODFalse;
   HPALETTE newPalette;

try {
   newPalette = PlatCreatePalette(_BitmapBuffer);
   if (newPalette) {
      DeleteObject(_BitmapPalette);
      _BitmapPalette = newPalette;
      result = kODTrue;
   }
} catch(...) {}

   return(result);
}


SOM_Scope void  SOMLINK BitmapInstallMenus(Bitmap *somSelf,
                                                  Environment *ev)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapInstallMenus");

try {
    // Let the SimplePart install its menu items first.
    Bitmap_parent_SimplePart_InstallMenus(somSelf, ev);

    ODPlatformMenuBar BitmapMenu;

#ifdef _PLATFORM_OS2_
   DosQueryModuleHandle(kBitmapFileName, &_MyResources);
#elif defined(_PLATFORM_WIN32_)
   _MyResources = GetModuleHandle(kBitmapFileName);
#endif

   // First Install the Popup Menu
   // We'll load the menu from our resource file.
   _MyPopupMenu = somSelf->GetPopupMenu(ev);
   if (_MyPopupMenu) {

#ifdef _PLATFORM_OS2_
      BitmapMenu = WinLoadMenu(HWND_OBJECT, _MyResources, BitmapMenuID);
#elif defined(_PLATFORM_WIN32_)
      BitmapMenu = LoadMenu(_MyResources, MAKEINTRESOURCE(BitmapMenuID));
#endif
      if (BitmapMenu!=NULLHANDLE) {
         _MyPopupMenu->AddMenuLast(ev, BitmapMenuID, BitmapMenu, _MyWrapper);
         _MyPopupMenu->SetMenuItemText(ev, ID_BASEPOPUP, BitmapMenuID, "Bitmap");
      } /* endif */

      _MyPopupMenu->RemoveMenuItem(ev, ID_BASEPOPUP, ID_HELPSUBMENU);
   } /* endif */

   // Now Install the base menu bar
   // We'll reload the menu from the resource file to get a different handle.
   _MyMenuBar = somSelf->GetMenuBar(ev);
   if (_MyMenuBar) {

      // Reload the menu to get a different handle
#ifdef _PLATFORM_OS2_
      BitmapMenu = WinLoadMenu(HWND_OBJECT, _MyResources, BitmapMenuID);
#elif defined(_PLATFORM_WIN32_)
      BitmapMenu = LoadMenu(_MyResources, MAKEINTRESOURCE(BitmapMenuID));
#endif

      if (BitmapMenu!=NULLHANDLE) {
         _MyMenuBar->AddMenuLast(ev, BitmapMenuID, BitmapMenu, _MyWrapper);
         _MyMenuBar->SetMenuItemText(ev, ID_BASEMENUBAR, BitmapMenuID, "Bitmap");
      } /* endif BitmapMenu */
   } /* endif _MyMenuBar */
} catch(...) {}
}


SOM_Scope ODBoolean  SOMLINK BitmapCopyBitmapToClipboard(Bitmap *somSelf,
                                                               Environment *ev,
                                                              ODFacet* facet)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapCopyBitmapToClipboard");

   ODBoolean ReturnValue=SUCCESS;

/* Make copy of bitmap to give to clipboard */
   HBITMAP DuplicateHandle = _DuplicateBitmap(ev, facet, _CurrentBitmapHandle);


#ifdef MANUAL_PM_CLIPBOARD_CODE

   HAB hab = WinQueryAnchorBlock(facet->GetFacetHWND(ev));

   if (DuplicateHandle!=GPI_ERROR) {
      ReturnValue = WinOpenClipbrd(hab);
      if (ReturnValue) {
         ReturnValue = WinEmptyClipbrd(hab);
         if (ReturnValue) {
            ReturnValue = WinSetClipbrdData(hab, (ULONG) DuplicateHandle,
                             CF_BITMAP, CFI_HANDLE);
         } /* endif */
         WinCloseClipbrd(hab);
      } /* endif */
   } else {
      ReturnValue=FAILURE;
   } /* endif */

   if (!ReturnValue) {
      short errorid = ERRORIDERROR(WinGetLastError(hab));
      DosBeep(250,500);
   } /* endif */

#endif /* Manual PM Clipboard Code */


#ifdef OD_CLIPBOARD_CODE

   ODFrame* frame = facet->GetFrame(ev);

   ODArbitrator* arbitrator = _MySession->GetArbitrator( ev );
   ODTypeToken clipboardFocus = _MySession->Tokenize( ev, kODClipboardFocus );
   arbitrator->RequestFocus( ev, clipboardFocus, frame );

   ODClipboard*   clipboard = _MySession->GetClipboard(ev);

   try {
      clipboard->Clear( ev );
      ODStorageUnit* su = clipboard->GetContentStorageUnit(ev);
      su->AddProperty(ev, kODPropContents);

      if (DuplicateHandle)
         {
         su->AddValue(ev, (ODValueType) kODBitmapType);

         StorageUnitSetValue(su, ev, sizeof(HBITMAP),
                             (ODValue) &DuplicateHandle);
         }
      clipboard->ExportClipboard( ev );
   } catch (... ) {
      ReturnValue = kODFalse;
      DosBeep(250,500);
   } /* endtry */

   arbitrator->RelinquishFocus( ev, clipboardFocus, frame );

#endif /* OD Clipboard Code */


   return(ReturnValue);
}


SOM_Scope ODBoolean  SOMLINK BitmapPasteBitmapFromClipboard(Bitmap *somSelf,
                                                                  Environment *ev,
                                                                 ODFacet* facet)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapPasteBitmapFromClipboard");

   ODBoolean ReturnValue=SUCCESS;
   HBITMAP DuplicateHandle = NULLHANDLE;


#ifdef MANUAL_PM_CLIPBOARD_CODE

   HAB hab = WinQueryAnchorBlock(HWND_DESKTOP);
   ReturnValue = WinOpenClipbrd(hab);
   if (ReturnValue) {
      ULONG FormatInfo;
      ReturnValue = WinQueryClipbrdFmtInfo(hab, CF_BITMAP, &FormatInfo);
      if (ReturnValue) {
         HBITMAP NewBMPHandle = (HBITMAP) WinQueryClipbrdData(hab, CF_BITMAP);
         DuplicateHandle = _DuplicateBitmap(ev, facet, NewBMPHandle);
      } /* endif */
      WinCloseClipbrd(hab);
   } /* endif */

   if (!ReturnValue) {
      short errorid = ERRORIDERROR(WinGetLastError(hab));
      DosBeep(250,500);
   } /* endif */

#endif /* Manual PM Clipboard Code */


#ifdef OD_CLIPBOARD_CODE

   ODFrame* frame = facet->GetFrame(ev);

   ODArbitrator *arbitrator = _MySession->GetArbitrator( ev );
   ODTypeToken clipboardFocus = _MySession->Tokenize( ev, kODClipboardFocus );
   arbitrator->RequestFocus( ev, clipboardFocus, frame );

   ODClipboard*   clipboard = _MySession->GetClipboard( ev );

   try {
      ODStorageUnit* su = clipboard->GetContentStorageUnit( ev );

      if ( su->Exists(ev, kODPropContents, kODBitmapType, 0) ) {
         HBITMAP NewBMPHandle = NULLHANDLE;
         su->Focus(ev, kODPropContents, kODPosUndefined, kODBitmapType, 0,
                   kODPosUndefined);
         StorageUnitGetValue(su, ev, sizeof(HBITMAP), (ODValue) &NewBMPHandle);
         DuplicateHandle = _DuplicateBitmap(ev, facet, NewBMPHandle);
      } /* endif */
   } catch (... ) {
      ReturnValue = kODFalse;
      DosBeep(250,500);
   } /* endtry */

   arbitrator->RelinquishFocus( ev, clipboardFocus, frame );

#endif /* OD Clipboard Code */


#ifdef _LEFT_TO_PORT_
   if (DuplicateHandle!=GPI_ERROR) {
      GpiDeletePalette(_BitmapPalette);
      _BitmapPalette = NULLHANDLE;

      GpiDeleteBitmap(_CurrentBitmapHandle);
      _CurrentBitmapHandle = DuplicateHandle;

      _BitmapFileSize = 0;
      _FileNameOnly = kODFalse;
      _EnableFileNameOnly = kODFalse;
   } else {
      HAB hab = WinQueryAnchorBlock(HWND_DESKTOP);
      short errorid = ERRORIDERROR(WinGetLastError(hab));
      DosBeep(250,500);
   } /* endif */
#endif

#ifdef _PLATFORM_WIN32_
   if (DuplicateHandle!=kODNULL) {
      DeleteObject(_BitmapPalette);
      _BitmapPalette = NULLHANDLE;

      DeleteObject(_CurrentBitmapHandle);
      _CurrentBitmapHandle = DuplicateHandle;

      _BitmapFileSize = 0;
      _FileNameOnly = kODFalse;
      _EnableFileNameOnly = kODFalse;
   } else {
      ULONG error = GetLastError();
      DosBeep(250,500);
   } /* endif */
#endif

   return(ReturnValue);
}


SOM_Scope void  SOMLINK BitmapInvertDragHilite(Bitmap *somSelf,
                                                     Environment *ev,
                                                    ODFacet* facet)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapInvertDragHilite");

#ifdef _LEFT_TO_PORT_
   HPS hps;

   CFocusWindow f(ev, facet, (ODShape*)kODNULL, &hps, (HWND*)kODNULL, CFocusWindow::DragPS);

   ODTempPolygon poly;
   POLYGON polygon;
   ODContour *pContour;
   int i;
   TempODShape clipShape = facet->AcquireAggregateClipShape(ev, kODNULL);
   clipShape->CopyPolygon(ev,&poly);    // [137664]

   GpiSetMix( hps, FM_INVERT );
   GpiBeginPath(hps, 1);
   for (pContour = poly.FirstContour(), i = 0;
        i < poly.GetNContours();
        pContour = pContour->NextContour(), i++)
   {
      pContour->AsPOLYGON(polygon);
      GpiMove(hps, &polygon.aPointl[polygon.ulPoints-1]);
      GpiPolyLine(hps, polygon.ulPoints, polygon.aPointl);
      SOMFree(polygon.aPointl);
   }
   GpiEndPath(hps);
   GpiSetLineWidthGeom(hps, 8);
   GpiStrokePath(hps, 1, 0);
#endif
}


SOM_Scope void  SOMLINK BitmapNoBitmap(Bitmap *somSelf,
                                             Environment *ev,
                                            ODFacet* facet)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapNoBitmap");

try {
    if (facet == kODNULL)
       facet = _MyFacet;

    if (_BitmapFileName != NULL) {
       free(_BitmapFileName);
       _BitmapFileName = NULL;
    } /* endif */

    if (_BitmapBuffer != NULL) {
       SOMFree(_BitmapBuffer);
       _BitmapBuffer = kODNULL;
       _BitmapFileSize = 0;
    }

    if (_CurrentBitmapHandle != _NoBitmapSelectedHandle) {
#ifdef _PLATFORM_WIN32_
       DeleteObject(_CurrentBitmapHandle);
       DeleteObject(_BitmapPalette);
#elif defined(_PLATFORM_OS2_)
       GpiDeleteBitmap(_CurrentBitmapHandle);
       GpiDeletePalette(_BitmapPalette);
#endif
    } /* endif */

    _CurrentBitmapHandle = _NoBitmapSelectedHandle;
    _EnablePaletteManagement = kODTrue;
    _BitmapPalette = NULL;

#ifdef _PLATFORM_WIN32_
    SelectObject(_hdcMemory, _CurrentBitmapHandle);
#elif defined(_PLATFORM_OS2_)
    ODCanvas *canvas = facet->GetCanvas(ev);
    ODPlatformCanvas *pCanvas = canvas->GetPlatformCanvas(ev, kODGPI);
    GpiSelectPalette(pCanvas->GetPS(ev, facet), NULL);
    pCanvas->ReleasePS(ev, facet);
#endif
} catch(...) {}
}


SOM_Scope ODBoolean  SOMLINK BitmapNewBitmap(Bitmap *somSelf,
                                                   Environment *ev,
                                                  char* filename)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapNewBitmap");

    ODBoolean ReturnValue = kODFalse;
    ODBoolean DifferentBitmap = kODTrue;
    char *OldBitmapFileName = kODNULL;

try {
    if (_BitmapFileName!=NULL) {
       if (strcmp(_BitmapFileName, filename)==0) {
          DifferentBitmap = kODFalse;
       } else {
          OldBitmapFileName = strdup(_BitmapFileName);
          free(_BitmapFileName);
       } /* endif */
    } /* endif */

    if (DifferentBitmap) {
       _BitmapFileName = strdup(filename);

       if (_LoadBitmap(ev)) {
          if (_CurrentBitmapHandle!=_NoBitmapSelectedHandle) {
#ifdef _PLATFORM_WIN32_
             DeleteObject(_CurrentBitmapHandle);
#elif defined(_PLATFORM_OS2_)
             GpiDeleteBitmap(_CurrentBitmapHandle);
#endif
          } /* endif */
          if (_CreateBitmap(ev)) {
             ReturnValue = kODTrue;
             _EnablePaletteManagement = kODFalse;
          } /* endif */
       } /* endif */

       if (!ReturnValue) {
          free(_BitmapFileName);

          if (OldBitmapFileName!=kODNULL) {
             _BitmapFileName = strdup(OldBitmapFileName);
          } else {
             _BitmapFileName = kODNULL;
          } /* endif */
       } /* endif */
    } else {
       ReturnValue = kODTrue;
    } /* endif */
} catch(...) {}

    return(ReturnValue);
}

SOM_Scope void  SOMLINK BitmapChangeNotification(Bitmap *somSelf,
                                                 Environment *ev,
                                                 ODFrame* frame,
                                                 ODULong reason)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapChangeNotification");

try {
    if (!_fDirty) {
      _fDirty = kODTrue;
      somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
    }
    ODUpdateID change = _MySession->UniqueUpdateID(ev);
    frame->ContentUpdated (ev, change);
} catch(...) {}
}

SOM_Scope void  SOMLINK BitmapAddPropertiesToSU(Bitmap *somSelf,
                                        Environment *ev,
                                        ODStorageUnit*  storageUnit)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapAddPropertiesToSU");

try {

    // Create our content property and preferred content property kind.
    ODSUForceFocus(ev, storageUnit, kODPropContents, _fPreferredKind);

    // Create the standard data kind value within our content property
    if ( !storageUnit->Exists(ev, kODPropContents, kODKindODFBitmap, 0) ) {
       storageUnit->Focus(ev, kODPropContents, kODPosUndefined, kODNULL, 0, kODPosUndefined);
       storageUnit->AddValue(ev, kODKindODFBitmap);
    }

} catch(...) {
#ifdef ODDebug
  PRINT("Error during Bitmap::AddPropertiesToSU.\n");
#endif
} /* end catch */
}

SOM_Scope void  SOMLINK BitmapPrepareSU(Bitmap *somSelf,
                                                Environment *ev,
                                                ODStorageUnit*  su)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapPrepareSU");

try {
    su->Focus(ev, kODPropContents, kODPosUndefined, kODNULL, 0, kODPosAll);
    ODULong numValues = su->CountValues(ev);
    ODBoolean IBMBitmapKindRead = kODFalse;

    // Loop through all the values using a storage unit index.
    for ( ODULong index = numValues; index >= 1; index-- ) {
       su->Focus(ev, kODPropContents, kODPosUndefined,
                 kODNULL, index, kODPosUndefined);

       // Get the ISO type name for the value. The temp object
       // will automatically delete the returned value when this
       // scope is exited.
       TempODValueType kindValue = su->GetType(ev);

       // Default to remove unrecognized values and those in wrong fidelity order.
       ODBoolean removeIt = kODTrue;

       // Check for recognized values
       if ( !strcmp(_fPreferredKind,kKindIBMBitmap) ) {
          // Don't remove the kKindIBMBitmap value if it's there,
          // but ensure there is only one in the content property.
          if ( !IBMBitmapKindRead && !strcmp(kindValue,kKindIBMBitmap) ) {
             removeIt = kODFalse;  // Leave the preferred kind alone
             IBMBitmapKindRead = kODTrue; // First time kind was encountered
          }
          // The IBMBitmapKind is the highest fidelity kind, so should be first
          // in the storage unit.  If it has not been included yet, delete the
          // ODF value.
          else { // IBMBitmapKindRead == true
             if ( !strcmp(kindValue,kODKindODFBitmap) )
                removeIt = kODFalse; // Safe to leave this kind after IBMBitmapKind
          }
       } else if ( !strcmp(_fPreferredKind,kODKindODFBitmap) ) {
            if ( !strcmp(kindValue,kODKindODFBitmap) )
               removeIt = kODFalse; // Leave the preferred kind alone
       }

       // Remove the unrecognized values and those in wrong fidelity order
       if ( removeIt )
          su->Remove(ev);
    } /* end for */

} catch(...) {
#ifdef ODDebug
  PRINT("Error during Bitmap::PrepareSU.\n");
#endif
} /* end catch */
}


SOM_Scope void  SOMLINK BitmapExternalizeOneKind(Bitmap *somSelf,
                                              Environment *ev,
                                              ODStorageUnit* su,
                                              ODValueType  kind)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapExternalizeOneKind");

try {
    // Track the old value size in case the new value is smaller.
    ODULong oldSize = 0;
    ODULong newSize = 0;
    ODULong fileNameSize = 0;

    // Externalize kKindIBMBitmap
    if ( !strcmp(kind,kKindIBMBitmap) ) {
       ODSUForceFocus (ev, su, kODPropContents, kKindIBMBitmap);
       oldSize = su->GetSize(ev);
       if (_BitmapFileName != kODNULL)
          fileNameSize = strlen(_BitmapFileName) + 1;

       // Fill in our BitmapExternalizedData block
       BitmapExternalizedData outData;
       outData.bdNegative = _Negative;
       outData.bdFileNameSize = ConvertODULongToStd(fileNameSize);
       if (_FileNameOnly)
          outData.bdFileDataSize = 0;
       else
          outData.bdFileDataSize = ConvertODULongToStd(_BitmapFileSize);

       // Write all the Bitmap information to the storage unit
       StorageUnitSetValue(su, ev, sizeof(outData), &outData);
       if (fileNameSize > 0)
          StorageUnitSetValue(su, ev, fileNameSize, _BitmapFileName);
       if (!_FileNameOnly && _BitmapFileSize > 0)
          StorageUnitSetValue(su, ev, _BitmapFileSize, _BitmapBuffer);
       newSize = sizeof(outData) + fileNameSize + _BitmapFileSize;

    // Otherwise, externalize the Apple ODF bitmap standard kind
    } else if (!strcmp(kind,kODKindODFBitmap) ) {
       ODSUForceFocus (ev, su, kODPropContents, kODKindODFBitmap);
       oldSize = su->GetSize(ev);
       if (_BitmapFileSize > 0)
          StorageUnitSetValue(su, ev, _BitmapFileSize, _BitmapBuffer);
       newSize = _BitmapFileSize;
    }

    // Delete any unneeded space in the storage unit.
    if (oldSize > newSize) {
       su->DeleteValue(ev, oldSize - newSize);
    }

} catch(...) {
#ifdef ODDebug
  PRINT("Error during Bitmap::ExternalizeOneKind.\n");
#endif
} /* end catch */
}


SOM_Scope void  SOMLINK BitmapsomInit(Bitmap *somSelf)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapsomInit");

    Bitmap_parent_SimplePart_somInit(somSelf);

    _fDirty = kODFalse;
    _fDraftReadOnly = kODFalse;
    _fPreferredKind = NULL;
    _fInternalizedKind = NULL;

    _CurrentBitmapHandle = NULL;
    _BitmapPalette = NULL;

    _BitmapFileName = NULL;
    _BitmapBuffer = NULL;
    _FileNameOnly = kODTrue;

    _UsePromises = kODFalse;
    _PaletteManage = kODFalse;
    _Negative = kODFalse;

    _EnablePaletteManagement = kODFalse;
    _EnableFileNameOnly = kODTrue;

    _MyFacet = kODNULL;
}


SOM_Scope void  SOMLINK BitmapsomUninit(Bitmap *somSelf)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapsomUninit");

#ifdef _PLATFORM_WIN32_
    DeleteObject(_BitmapPalette);
    DeleteObject(_CurrentBitmapHandle);
    DeleteObject(_NoBitmapSelectedHandle);
    DeleteDC(_hdcMemory);
#elif defined(_PLATFORM_OS2_)
    GpiDeletePalette(_BitmapPalette);
    GpiDeleteBitmap(_CurrentBitmapHandle);
    GpiDeleteBitmap(_NoBitmapSelectedHandle);
    GpiDestroyPS(_hpsMemory);
    DevCloseDC(_hdcMemory);
#endif
    if (_BitmapFileName)
       free(_BitmapFileName);
    if (_BitmapBuffer)
       SOMFree(_BitmapBuffer);

    Bitmap_parent_SimplePart_somUninit(somSelf);
}


SOM_Scope void  SOMLINK BitmapDisplayFrameAdded(Bitmap *somSelf,
                                                      Environment *ev,
                                                     ODFrame* frame)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapDisplayFrameAdded");

try {
    Bitmap_parent_SimplePart_DisplayFrameAdded(somSelf, ev, frame);

    frame->SetDroppable(ev, kODFalse);

    if (frame->IsRoot(ev) && (_MyPopupMenu!=kODNULL)) {
      _MyPopupMenu->RemoveMenu(ev, ID_OPENASSUBMENU);
      _MyPopupMenu->RemoveMenu(ev, ID_SHOWASSUBMENU);
    } /* endif */
} catch(...) {}
}


SOM_Scope void  SOMLINK BitmapDisplayFrameConnected(Bitmap *somSelf,
                                                          Environment *ev,
                                                         ODFrame* frame)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapDisplayFrameConnected");

    _DisplayFrameAdded(ev, frame);
}


SOM_Scope void  SOMLINK BitmapFrameShapeChanged(Bitmap *somSelf,
                                                      Environment *ev,
                                                     ODFrame* frame)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapFrameShapeChanged");

try {
    frame->Invalidate(ev, kODNULL, kODNULL);
} catch(...) {}
}


SOM_Scope void  SOMLINK BitmapViewTypeChanged(Bitmap *somSelf,
                                                    Environment *ev,
                                                   ODFrame* frame)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapViewTypeChanged");

try {
    ODFrameFacetIterator *iter = frame->CreateFacetIterator(ev);
    ODFacet *facet = iter->First(ev); // We only draw to single facet
    delete iter;

    if (facet==kODNULL) {
       return;
    } /* endif */

    ODCanvas *canvas = facet->GetCanvas(ev);
    HWND facetHWND = facet->GetFacetHWND(ev);

    ODTypeToken viewType = frame->GetViewType(ev);
    if (viewType==_ViewAsFrame) {
       frame->ChangeUsedShape(ev, kODNULL, canvas);
    } else {
#ifdef _LEFT_TO_PORT_
       RECTL usedRECTL = {0, 0, 0, 0};
       if (viewType==_ViewAsSmallIcon) {
          usedRECTL.xRight = SMALLICONSIZE;
          usedRECTL.yTop = SMALLICONSIZE;
       } else {
          if (viewType==_ViewAsLargeIcon) {
          usedRECTL.xRight = LARGEICONSIZE;
          usedRECTL.yTop = LARGEICONSIZE;
          } else {
             if (viewType==_ViewAsThumbnail) {
             usedRECTL.xRight = THUMBNAILSIZE;
             usedRECTL.yTop = THUMBNAILSIZE;
             } else {
                WinMessageBox(HWND_DESKTOP, facetHWND,
                   (PSZ)"Picture Part doesn't support this view type", (PSZ)"",
                   5, MB_OK | MB_ERROR);
#endif

#ifdef _PLATFORM_WIN32_
                MessageBox(facetHWND,
                   "Picture Part doesn't support this view type", NULL,
                   MB_OK | MB_ICONERROR);
#endif
                frame->ChangeViewType(ev, _ViewAsFrame);
                return;
#ifdef _LEFT_TO_PORT_
             } /* endif */
          } /* endif */
       } /* endif */

       ODRect usedODRect(usedRECTL);
       ODShape *usedShape = frame->CreateShape(ev);
       usedShape->SetRectangle(ev, &usedODRect);
       frame->ChangeUsedShape(ev, usedShape, canvas);
#endif
    } /* endif */
} catch(...) {}
}


SOM_Scope void  SOMLINK BitmapFacetAdded(Bitmap *somSelf,
                                               Environment *ev,
                                              ODFacet* facet)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapFacetAdded");

try {
   ODBoolean result = kODFalse;
   if (_MyFacet!=kODNULL) { // Added to support Open As Window
      return;
   } /* endif */

   _MyFacet = facet;
   HWND facetHWND = facet->GetFacetHWND(ev);

   ODCanvas *canvas = facet->GetCanvas(ev);

#ifdef _PLATFORM_OS2_
   SIZEL BitmapDimensions = {NOBITMAP_WIDTH, NOBITMAP_HEIGHT};
   ODPlatformCanvas *pCanvas = canvas->GetPlatformCanvas(ev, kODGPI);
   _NoBitmapSelectedHandle = GpiLoadBitmap(pCanvas->GetPS(ev, facet),
      _MyResources, NOBITMAP, BitmapDimensions.cx, BitmapDimensions.cy);
   pCanvas->ReleasePS(ev, facet);

   if (_NoBitmapSelectedHandle==GPI_ERROR) {
      HAB hab = WinQueryAnchorBlock(facetHWND);
      short error = ERRORIDERROR(WinGetLastError(hab));
   } else {
      GpiSetBitmapDimension(_NoBitmapSelectedHandle, &BitmapDimensions);
      result = kODTrue;
      _EnablePaletteManagement = kODTrue;
   } /* endif */
#endif

#ifdef _PLATFORM_WIN32_
   HDC hdc = GetDC(facetHWND);
   _hdcMemory = CreateCompatibleDC(hdc);
   ReleaseDC(facetHWND, hdc);

   _NoBitmapSelectedHandle = LoadBitmap(_MyResources, MAKEINTRESOURCE(NOBITMAP));

   if (_NoBitmapSelectedHandle==kODNULL) {
      DWORD error = GetLastError();
#ifdef ODDebug
      PRINT ("Error %d occurred trying to load the default bitmap.\n", error);
#endif
   } else {
      SelectObject(_hdcMemory, _NoBitmapSelectedHandle);  // Initializes the palette
      SetBitmapDimensionEx(_NoBitmapSelectedHandle,
         NOBITMAP_WIDTH, NOBITMAP_HEIGHT, kODNULL);
      result = kODTrue;
      _EnablePaletteManagement = kODTrue;
   } /* endif */
#endif

   if (_BitmapFileName == NULL) {
      ODBoolean BitmapInBentoFile = kODFalse;
      if (_BitmapFileSize>0) { /* Bitmap stored inside Bento file? */
         if (_CreateBitmap(ev)) {
            _FileNameOnly = kODFalse;
            _EnableFileNameOnly = kODFalse;
            BitmapInBentoFile = kODTrue;
            _EnablePaletteManagement = kODFalse;
         } /* endif */
      } /* endif */
      if (!BitmapInBentoFile) {
         _NoBitmap(ev, facet);
      } /* endif */
   } else {
      char *filename = strdup(_BitmapFileName);
      free(_BitmapFileName);
      _BitmapFileName = NULL;
      result = _NewBitmap(ev, filename);
   } /* endif */

#ifdef _LEFT_TO_PORT_
//                Prepare bitmaps for use when this facet's frame is shown as
//                a small or large icon (we get thumbnail support for free,
//                since we already support scaling the bitmap to an arbitrary
//                size (such as 64x64)).
    HPOINTER MyIcon = NULLHANDLE;
    MyIcon = WinLoadPointer(HWND_DESKTOP, _MyResources, BMPPartIcon);

    POINTERINFO info;
    WinQueryPointerInfo(MyIcon, &info);
    _SmallIcon = info.hbmMiniColor;
    _LargeIcon = info.hbmColor;

/*     Store bitmap dimensions for use later during Draw */
    BITMAPINFOHEADER2 header;
    header.cbFix = sizeof(BITMAPINFOHEADER2);
    GpiQueryBitmapInfoHeader(_SmallIcon, &header);

    SIZEL dimensions = {header.cx, header.cy};
    GpiSetBitmapDimension(_SmallIcon, &dimensions);

    GpiQueryBitmapInfoHeader(_LargeIcon, &header);

    dimensions.cx = header.cx; dimensions.cy = header.cy;
    GpiSetBitmapDimension(_LargeIcon, &dimensions);
#endif

   if (result) {
      if (_CurrentBitmapHandle==_NoBitmapSelectedHandle) {
         _SizeFrameToBitmap(ev, facet);
      } /* endif */
   } else {
   } /* endif */

   ODFrame *frame = facet->GetFrame(ev);
   _ViewTypeChanged(ev, frame); /* adjust used shape for icons, thumbnails */

   Bitmap_parent_SimplePart_FacetAdded(somSelf, ev, facet);
} catch(...) {}
}


SOM_Scope ODBoolean  SOMLINK BitmapHandleEvent(Bitmap *somSelf,
                                                     Environment *ev,
                                                    ODEventData* event,
                                                    ODFrame* frame,
                                                    ODFacet* facet,
                                                    ODEventInfo* eventInfo)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapHandleEvent");

    ODBoolean handled = kODTrue;

#ifdef _PLATFORM_WIN32_
    switch (event->message) {
#elif defined(_PLATFORM_OS2_)
    switch (event->msg) {
#endif

    case SET_DATA:
#ifdef _PLATFORM_WIN32_
       switch ((int) event->wParam) {
       case NEW_BITMAP:
          if (_NewBitmap(ev, (char *)event->lParam)) {
#elif defined(_PLATFORM_OS2_)
       switch ((int) event->mp1) {
       case NEW_BITMAP:
          if (_NewBitmap(ev, (char *)event->mp2)) {
#endif
             _SizeFrameToBitmap(ev, facet);
             somSelf->ChangeNotification(ev, frame, 0);
          } /* endif */
          break;
       default:
          handled = kODFalse;
         break;
       } /* endswitch */
       break;
    default:
       handled = Bitmap_parent_SimplePart_HandleEvent(somSelf, ev,
                                                           event,
                                                           frame,
                                                           facet,
                                                           eventInfo);
      break;
    } /* endswitch */

    return(handled);
}


SOM_Scope ODBoolean  SOMLINK BitmapHandleMenuEvent(Bitmap *somSelf,
                                                         Environment *ev,
                                                        ODFrame* focusFrame,
                                                        ODEventData* event)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapHandleMenuEvent");

    ODBoolean handled = kODTrue;

    ODFrameFacetIterator *iter = focusFrame->CreateFacetIterator(ev);
    ODFacet *facet = iter->First(ev);
    delete iter;

    ODPlatformWindow hwnd = facet->GetFacetHWND(ev);
    ODCanvas *canvas = facet->GetCanvas(ev);
    char *filename;

#ifdef _PLATFORM_WIN32_
    switch (LOWORD(event->wParam)) {
#elif defined(_PLATFORM_OS2_)
    switch (SHORT1FROMMP(event->mp1)) {
#endif

    case MenuLoad:
       filename = _GetBitmapFileName(ev, hwnd);
       if (filename != NULL)

#ifdef _PLATFORM_WIN32_
          SendMessage(hwnd, SET_DATA, (WPARAM) NEW_BITMAP, (LPARAM) filename);
#endif
       break;
    case MenuUnload:
       _NoBitmap(ev, facet);
       _SizeFrameToBitmap(ev, facet);
       somSelf->ChangeNotification(ev, focusFrame, 0);
       break;
    case MenuStoreFileName:
       _FileNameOnly = !_FileNameOnly;
       somSelf->ChangeNotification(ev, focusFrame, 0);
       break;
    case EDIT_CUT:
       if (_CopyBitmapToClipboard(ev, facet)) {
          _NoBitmap(ev, facet);
          _SizeFrameToBitmap(ev, facet);
          somSelf->ChangeNotification(ev, focusFrame, 0);
       }
       break;
    case EDIT_COPY:
       if (_CopyBitmapToClipboard(ev, facet)) {
       } /* endif */
       break;
    case EDIT_PASTE:
       if (_PasteBitmapFromClipboard(ev, facet)) {
          _SizeFrameToBitmap(ev, facet);
          somSelf->ChangeNotification(ev, focusFrame, 0);
       }
       break;
    case VIEW_OAWINDOW:
       _Open(ev, focusFrame);
       break;
    case VIEW_PROPERTIES:
       _MySession->GetInfo(ev)->ShowPartFrameInfo(ev, facet, kODTrue);
       break;
    case VIEW_SASMALLICON:
       focusFrame->ChangeViewType(ev, _ViewAsSmallIcon);
       break;
    case VIEW_SALARGEICON:
       focusFrame->ChangeViewType(ev, _ViewAsLargeIcon);
       break;
    case VIEW_SATHUMBNAIL:
       focusFrame->ChangeViewType(ev, _ViewAsThumbnail);
       break;
    case VIEW_SAFRAME:
       focusFrame->ChangeViewType(ev, _ViewAsFrame);
       break;
    case MenuPromises:
       _UsePromises = !_UsePromises;
       somSelf->ChangeNotification(ev, focusFrame, 0);
       break;
    case MenuPalette:
       _PaletteManage = !_PaletteManage;
       somSelf->ChangeNotification(ev, focusFrame, 0);
       break;
    case MenuDefaultSize:
       _SizeFrameToBitmap(ev, facet);
       break;
    case MenuNegative:
       _Negative = !_Negative;
       somSelf->ChangeNotification(ev, focusFrame, 0);
    case MenuRefresh:
       facet->Invalidate(ev, kODNULL, canvas);
       break;
    default:
       handled = kODFalse;
      break;
    } /* endswitch */

    return(handled);
}


SOM_Scope void  SOMLINK BitmapAdjustMenus(Bitmap *somSelf,
                                                Environment *ev,
                                               ODFrame* frame)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapAdjustMenus");

try {
   ODBoolean IsNonRoot = !frame->IsRoot(ev);
   ODBoolean IsNativeKind = (!strcmp(_fPreferredKind,kKindIBMBitmap));

   // Process the Bitmap specific base menubar items
   _MyMenuBar->CheckMenuItem(ev, BitmapMenuID, MenuStoreFileName,
      _FileNameOnly);
   _MyMenuBar->CheckMenuItem(ev, BitmapMenuID, MenuPromises, _UsePromises);
   _MyMenuBar->CheckMenuItem(ev, BitmapMenuID, MenuPalette, _PaletteManage);
   _MyMenuBar->CheckMenuItem(ev, BitmapMenuID, MenuNegative, _Negative);

   // Only enable the Bitmap menubar items if the draft is writeable.
   _MyMenuBar->EnableMenuItem(ev, ID_BASEMENUBAR, BitmapMenuID, !_fDraftReadOnly);
   if (!_fDraftReadOnly) {
      _MyMenuBar->EnableMenuItem(ev, BitmapMenuID, MenuStoreFileName,
                                 _EnableFileNameOnly && IsNativeKind);
      _MyMenuBar->EnableMenuItem(ev, BitmapMenuID, MenuNegative,
                                 IsNativeKind);
      _MyMenuBar->EnableMenuItem(ev, BitmapMenuID, MenuPromises, kODFalse);
      _MyMenuBar->EnableMenuItem(ev, BitmapMenuID, MenuPalette,
                                 _EnablePaletteManagement && IsNativeKind);
   }

   // Disable the printing-related menu items.
   _MyMenuBar->EnableMenuItem(ev, IDMS_DOCUMENT, DOC_SETUP, kODFalse);
   _MyMenuBar->EnableMenuItem(ev, IDMS_DOCUMENT, DOC_PRINT, kODFalse);

   // Disable these until we port the clipboard support (_LEFT_TO_PORT_)
   _MyMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_CUT, kODFalse);
   _MyMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_COPY, kODFalse);
   _MyMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_PASTE, kODFalse);

   // Disable the other functions we don't support since we aren't a container
   _MyMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_CREATE, kODFalse);
   _MyMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_LINK_MENU, kODFalse);
   _MyMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_PASTEAS, kODFalse);
   _MyMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_DELETE, kODFalse);
   _MyMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_SELECTALL, kODFalse);
   _MyMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_DESELECTALL, kODFalse);
   _MyMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_OPENSEL, kODFalse);
   _MyMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_SELPROPERTIES, kODFalse);
   _MyMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_INSERT, kODFalse);

#ifdef _LEFT_TO_PORT_
// Added for Popup Menubar Support
   _MyPopupMenu->CheckMenuItem(ev, BitmapMenuID, MenuStoreFileName,
      _FileNameOnly);
   _MyPopupMenu->CheckMenuItem(ev, BitmapMenuID, MenuPromises, _UsePromises);
   _MyPopupMenu->CheckMenuItem(ev, BitmapMenuID, MenuPalette, _PaletteManage);

   _MyPopupMenu->EnableMenuItem(ev, BitmapMenuID, MenuStoreFileName,
      _FileNameOnly);
   _MyPopupMenu->EnableMenuItem(ev, BitmapMenuID, MenuPromises, kODFalse);
   _MyPopupMenu->EnableMenuItem(ev, BitmapMenuID, MenuPalette,
      _EnablePaletteManagement);
#endif
} catch(...) {}
}


SOM_Scope void  SOMLINK BitmapDraw(Bitmap *somSelf,
                                         Environment *ev, ODFacet* facet,
                                        ODShape* invalidShape)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapDraw");

try {
    ODFrame *frame = facet->GetFrame(ev);
    ODCanvas *canvas = facet->GetCanvas(ev);

    ODTypeToken viewType = frame->GetViewType(ev);

    TempODShape frameShape = ODCopyAndRelease(ev,
                frame->AcquireUsedShape(ev, canvas));
    HRGN frameRgn = frameShape->GetRegion(ev);

#ifdef _PLATFORM_WIN32_
    HDC hdcDraw;
    CFocus f(facet, invalidShape, &hdcDraw); // Set up drawing environment

    RECT frameRect;
    GetRgnBox(frameRgn, &frameRect);
    if (_BitmapPalette) {
      SelectPalette(hdcDraw, _BitmapPalette, TRUE);
      RealizePalette(hdcDraw);
    }

#endif

    if ((viewType==_ViewAsFrame) || (viewType==_ViewAsThumbnail)) {
       PlatDrawBitmap(hdcDraw, _hdcMemory, frameRect, _CurrentBitmapHandle, _Negative);
    } else { // Icon viewtype

    }
} catch(...) {}
}


#ifdef _LEFT_TO_PORT_
SOM_Scope ODDragResult  SOMLINK BitmapDragEnter(Bitmap *somSelf,
                                                      Environment *ev,
                                                     ODDragItemIterator* dragInfo,
                                                     ODFacet* facet,
                                                     ODPoint* where)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapDragEnter");

//  SetOutputMode(kWriteToFile);
/*      Above function isn't public anymore; opened defect #149417  */
/* for now, have to use the "Logging" menu in the debug docshell in */
/* order to change the output mode (default is OpenDoc.log)         */
    LOG("Bitmap Part: Entering DragEnter method\n");

    _InvertDragHilite( ev, facet );

    ODDragResult ReturnValue = MRFROM2SHORT (DOR_NEVERDROP, 0);

    if (dragInfo!=NULL) {
       ODStorageUnit *dropSU = dragInfo->First(ev); /* single drag item only */
       if (dropSU->Exists(ev, kODPropContents, (ODValueType)kODDragitem, 0)) {
          dropSU->Focus(ev, kODPropContents, kODPosUndefined,
             (ODValueType)kODDragitem, 0, kODPosUndefined);

          DRAGITEM item;
          StorageUnitGetValue(dropSU, ev, sizeof(DRAGITEM), (ODValue) &item);

          int TypeStringLength = DrgQueryStrNameLen(item.hstrType) + 1;
          char *type = (char *) malloc ((TypeStringLength + 1)*sizeof(char));
          DrgQueryStrName(item.hstrType, TypeStringLength, type);

          if (strcmp(type, "Bitmap")==0) {
             ReturnValue = MRFROM2SHORT(DOR_DROP, DO_COPY);
             LOG("Bitmap Part: DragEnter: type==Bitmap\n");
             LOG("Bitmap Part: DragEnter: Returning (DOR_DROP, DO_COPY)\n");
          } else {
             LOG("Bitmap Part: DragEnter: type!=Bitmap (got back %s instead)\n", type);
             LOG("Bitmap Part: DragEnter: Returning (DOR_NEVERDROP, 0)\n");
          } /* endif */
       } /* endif */
    } /* endif */

    return(ReturnValue);
}


SOM_Scope ODDragResult  SOMLINK BitmapDragWithin(Bitmap *somSelf,
                                                       Environment *ev,
                                                      ODDragItemIterator* dragInfo,
                                                      ODFacet* facet,
                                                      ODPoint* where)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapDragWithin");

    ODDragResult ReturnValue;

    LOG("Bitmap Part: Entering DragWithin method\n");
    ReturnValue = MRFROM2SHORT(DOR_DROP, DO_COPY);

    return(ReturnValue);
}


SOM_Scope void  SOMLINK BitmapDragLeave(Bitmap *somSelf,
                                              Environment *ev,
                                             ODFacet* facet,
                                             ODPoint* where)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapDragLeave");

    _InvertDragHilite( ev, facet );
}


SOM_Scope ODDropResult  SOMLINK BitmapDrop(Bitmap *somSelf,
                                                 Environment *ev,
                                                ODDragItemIterator* dropInfo,
                                                ODFacet* facet,
                                                ODPoint* where)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapDrop");

    LOG("Bitmap Part: Entering Drop method\n");
    _InvertDragHilite( ev, facet );

    ODDropResult ReturnValue = kODDropFail;

    if (dropInfo!=NULL) {
       ODStorageUnit *dropSU = dropInfo->First(ev); /* single drag item only */
       if (dropSU->Exists(ev, kODPropContents, (ODValueType)kODDragitem, 0)) {
          dropSU->Focus(ev, kODPropContents, kODPosUndefined,
             (ODValueType)kODDragitem, 0, kODPosUndefined);

          // create a view of our focused value for the drag manager
          ODStorageUnitView *dropView = dropSU->CreateView(ev);

          ODStorageUnit *renderedSU;

          if (_MySession->GetDragAndDrop(ev)->GetDataFromDragManager(ev,
           dropView, &renderedSU)) {

             if (renderedSU->Exists(ev, kODPropContents,
              (ODValueType)kODFileType, 0)) {

                renderedSU->Focus(ev, kODPropContents, kODPosUndefined,
                   (ODValueType)kODFileType, 0, kODPosUndefined);

                ULONG strLength = renderedSU->GetSize( ev );

                char *filename = (char *) malloc((strLength+1)*sizeof(char));

                StorageUnitGetValue(renderedSU, ev, strLength, (ODValue) filename);
                LOG("Bitmap Part: filename == \"%s\"\n", filename);

                WinSendMsg(facet->GetFacetHWND(ev), WM_SEMANTICEVENT,
                   (MPARAM) NEW_BITMAP, (MPARAM) filename);
                ReturnValue = kODDropMove;
             } /* endif */
          } /* endif */
       } /* endif */
    } /* endif */

    return(ReturnValue);
}
#endif


SOM_Scope void  SOMLINK BitmapExternalize(Bitmap *somSelf,
                                                Environment *ev)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapExternalize");

try {
    // No need to externalize our contents if we haven't changed any content
    // or if the draft is readonly.
    if (_fDirty && !_fDraftReadOnly) {

       ODStorageUnit* su = _GetStorageUnit(ev);

       // Ensure our values are in the content property.
       somSelf->AddPropertiesToSU(ev, su);

       // Remove unrecognized values from the content property.
       somSelf->PrepareSU(ev, su);

       // Set our preferred kind property.
       ODSetISOStrProp(ev, su, kODPropPreferredKind, kODISOStr, _fPreferredKind);

       // Externalize the preferred kind.
       somSelf->ExternalizeOneKind(ev, su, _fPreferredKind);

       // Externalize standard data interchange kinds as well as bitmap kind
       if (!strcmp(_fPreferredKind,kKindIBMBitmap)) {
          somSelf->ExternalizeOneKind(ev, su, kODKindODFBitmap);
       }
       _fDirty = kODFalse;  // All changes are now externalized to the storage unit.
    } /* endif */

    // Externalize the parent's contents last, since it has lowest fidelity?
    Bitmap_parent_SimplePart_Externalize(somSelf, ev);

} catch(...) {}
}


SOM_Scope void  SOMLINK BitmapInitPart(Bitmap *somSelf,
                                             Environment *ev,
                                            ODStorageUnit* storageUnit,
                                            ODPart* PartWrapper)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapInitPart");

try {
    // Set for use by CommonInit
    _MyWrapper = PartWrapper;
    Bitmap_parent_SimplePart_InitPart(somSelf, ev, storageUnit,
                                      PartWrapper);

    // We only need to set the preferred kind when we come up from stationery.
    if(!storageUnit->Exists(ev, kODPropPreferredKind, kODISOStr, 0))
    {
        // Set a default value to our preferred kind property.
        ODSetISOStrProp(ev, storageUnit, kODPropPreferredKind, kODISOStr, kKindIBMBitmap);
    }
} catch(...) {}
}


SOM_Scope void  SOMLINK BitmapInitPartFromStorage(Bitmap *somSelf,
                                                  Environment *ev,
                                                  ODStorageUnit* storageUnit,
                                                  ODPart* partWrapper)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapInitPartFromStorage");

try {
    // Set for use by CommonInit
    _MyWrapper = partWrapper;

    Bitmap_parent_SimplePart_InitPartFromStorage(somSelf, ev,
                                                 storageUnit,
                                                 partWrapper);
    ODType nonPreferredKind;
    ODULong kindSize;

    // Obtain the preferred kind property.  If it has not been set, use kKindIBMBitmap
    // as the preferred kind (the highest fidelity kind recognized by this part)
    if (ODSUExistsThenFocus (ev, storageUnit, kODPropPreferredKind, kODISOStr)) {
       _fPreferredKind = ODGetISOStrProp(ev, storageUnit, kODPropPreferredKind, kODISOStr,
                                         kODNULL, &kindSize);
    } else {   // use the default preferred kind (highest fidelity)
       _fPreferredKind = kKindIBMBitmap;
    }

    // Ensure that we recognize the preferred kind, set up the alternate kind
    if (!strcmp(_fPreferredKind,kKindIBMBitmap))
       nonPreferredKind = kODKindODFBitmap;
    else if (!strcmp(_fPreferredKind,kODKindODFBitmap))
       nonPreferredKind = kKindIBMBitmap;
    else {
#ifdef ODDebug
       PRINT("Unrecognized preferred kind: %s.\n", _fPreferredKind);
#endif
       _fPreferredKind = kKindIBMBitmap;
       nonPreferredKind = kODKindODFBitmap;
    }

    if (ODSUExistsThenFocus (ev, storageUnit, kODPropContents, _fPreferredKind))
       _fInternalizedKind = _fPreferredKind;
    else if (ODSUExistsThenFocus (ev, storageUnit, kODPropContents, nonPreferredKind))
       _fInternalizedKind = nonPreferredKind;

    // Now we are ready to actually read the data in.
    if (_fInternalizedKind == kODNULL) {
        ODULong numValues = storageUnit->CountValues(ev);
        if (numValues > 0)
           PrintValues(ev, storageUnit);
    } else if (!strcmp(_fInternalizedKind,kKindIBMBitmap)) {
       BitmapExternalizedData inData;
       StorageUnitGetValue(storageUnit, ev, sizeof(inData), (ODValue) &inData);
       _Negative = inData.bdNegative;

       // Convert size fields from standard Endianness
       inData.bdFileNameSize = ConvertODULongFromStd(inData.bdFileNameSize);
       _BitmapFileSize = ConvertODULongFromStd(inData.bdFileDataSize);

       // Extract the Filename from the storage unit.
       if (inData.bdFileNameSize > 0) {
          _BitmapFileName = (char *) malloc(inData.bdFileNameSize);
          StorageUnitGetValue(storageUnit, ev, inData.bdFileNameSize, _BitmapFileName);
       }

       // Extract the filedata itself from the storage unit
       if (_BitmapFileSize > 0) {
           _BitmapBuffer = (char*) SOMMalloc(_BitmapFileSize);
           StorageUnitGetValue(storageUnit, ev, _BitmapFileSize,
                                               (ODValue) _BitmapBuffer);
          _FileNameOnly == kODFalse;
       } else { // Default is to only deal with the file name.
          _FileNameOnly == kODTrue;
       }

    // See if Apple's ODFBitmap part kind is in SU.  If so, read in the
    // bitmap and store the bitmap data into a file
    } else if (!strcmp(_fInternalizedKind,kODKindODFBitmap)) {
        _BitmapFileSize = storageUnit->GetSize(ev);
        if (_BitmapFileSize != 0) {
            _BitmapBuffer = (char*) SOMMalloc(_BitmapFileSize);
            StorageUnitGetValue(storageUnit, ev, _BitmapFileSize,
                                             (ODValue) _BitmapBuffer);
            _FileNameOnly == kODFalse;
        } /* endif */
    } /* endif */

} catch(...) {
#ifdef ODDebug
  PRINT("Error during Bitmap::InitPartFromStorage.\n");
#endif
}

}


SOM_Scope void  SOMLINK BitmapFacetRemoved(Bitmap *somSelf,
                                                 Environment *ev,
                                                ODFacet* facet)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapFacetRemoved");

    if (facet!=_MyFacet) { // Added to support Open As Window
       return;
    } /* endif */

#ifdef _LEFT_TO_PORT_
    GpiDeleteBitmap(_SmallIcon);
    GpiDeleteBitmap(_LargeIcon);
#endif

    Bitmap_parent_SimplePart_FacetRemoved(somSelf, ev, facet);
}

SOM_Scope ODBoolean  SOMLINK BitmapHasExtension(Bitmap *somSelf,
                                                      Environment *ev,
                                                     ODType extensionName)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapHasExtension");

    return (Bitmap_parent_SimplePart_HasExtension(somSelf,
                                                       ev, extensionName));
}


SOM_Scope ODExtension*  SOMLINK BitmapAcquireExtension(Bitmap *somSelf,
                                                             Environment *ev,
                                                            ODType extensionName)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapAcquireExtension");

    return (Bitmap_parent_SimplePart_AcquireExtension(somSelf,
                                                           ev,
                                                           extensionName));
}


SOM_Scope void  SOMLINK BitmapReleaseExtension(Bitmap *somSelf,
                                                     Environment *ev,
                                                    ODExtension* extension)
{
    BitmapData *somThis = BitmapGetData(somSelf);
    BitmapMethodDebug("Bitmap","BitmapReleaseExtension");

    if (extension != kODNULL)
    {
       ODReleaseObject( ev, extension );
    }
}


SOM_Scope ISOString  SOMLINK M_BitmapclsGetODPartHandlerName(M_Bitmap *somSelf,
                                                                   Environment *ev)
{
    /* M_BitmapData *somThis = M_BitmapGetData(somSelf); */
    M_BitmapMethodDebug("M_Bitmap","M_BitmapclsGetODPartHandlerName");

    char * handlerName = (char *) SOMMalloc(strlen(kPartHandlerName)+1);
    strcpy(handlerName, kPartHandlerName);
    return (ISOString) handlerName;
}


SOM_Scope string  SOMLINK M_BitmapclsGetODPartHandlerDisplayName(M_Bitmap *somSelf,
                                                                       Environment *ev)
{
    /* M_BitmapData *somThis = M_BitmapGetData(somSelf); */
    M_BitmapMethodDebug("M_Bitmap","M_BitmapclsGetODPartHandlerDisplayName");

   string displayName = (char *) SOMMalloc(strlen(kPartHandlerDisplayName)+1);
   strcpy(displayName, kPartHandlerDisplayName);
   return displayName;
}


SOM_Scope _IDL_SEQUENCE_PartKindInfo  SOMLINK M_BitmapclsGetODPartKinds(M_Bitmap *somSelf,
                                                                              Environment *ev)
{
    /* M_BitmapData *somThis = M_BitmapGetData(somSelf); */
    M_BitmapMethodDebug("M_Bitmap","M_BitmapclsGetODPartKinds");

   _IDL_SEQUENCE_PartKindInfo BitmapInfo;

   // First create the PartKindInfo block for IBM bitmaps
   // Create structure PartKindInfo  and allocate memory for variable
   PartKindInfo * info = (PartKindInfo *) SOMMalloc(sizeof(PartKindInfo)*2); // times 2, because we are creating 2 blocks
   info->partKindName = (ISOString) SOMMalloc(strlen(kKindIBMBitmap)+1);
   info->partKindDisplayName = (string) SOMMalloc(strlen(kBitmapKindDisplayName)+1);
   info->filenameTypes = (string) SOMMalloc(strlen(kBitmapFileNameType)+1);
   info->filenameFilters =  (string) SOMMalloc(strlen(kBitmapFileNameFilter)+1);
   info->objectID = (string)SOMMalloc(strlen("")+1);
   info->categories =  (string) SOMMalloc(strlen(kBitmapCategory)+1);
   info->categoryDisplayName = (string) SOMMalloc(strlen(kBitmapCategoryDisplayName)+1);

   // Copy the information into the structure
   strcpy(info->partKindName , kKindIBMBitmap);
   strcpy(info->partKindDisplayName, kBitmapKindDisplayName);
   strcpy(info->filenameTypes, kBitmapFileNameType);
   strcpy(info->filenameFilters, kBitmapFileNameFilter);
   strcpy(info->objectID, "");
   strcpy(info->categories, kBitmapCategory);
   strcpy(info->categoryDisplayName, kBitmapCategoryDisplayName);

   // Now create a second PartKindInfo block for the ODF bitmap kind from Apple
   info++;  // point to the second block
   info->partKindName = (ISOString) SOMMalloc(strlen(kODKindODFBitmap)+1);
   info->partKindDisplayName = (string) SOMMalloc(strlen(kODFBitmapKindDisplayName)+1);
   info->filenameTypes = (string) SOMMalloc(strlen(kODFBitmapFileNameType)+1);
   info->filenameFilters =  (string) SOMMalloc(strlen(kBitmapFileNameFilter)+1);
   info->objectID = (string)SOMMalloc(strlen("")+1);
   info->categories =  (string) SOMMalloc(strlen(kBitmapCategory)+1);
   info->categoryDisplayName = (string) SOMMalloc(strlen(kBitmapCategoryDisplayName)+1);

   // Copy the information into the structure
   strcpy(info->partKindName , kODKindODFBitmap);
   strcpy(info->partKindDisplayName, kODFBitmapKindDisplayName);
   strcpy(info->filenameTypes, kODFBitmapFileNameType);
   strcpy(info->filenameFilters, kBitmapFileNameFilter);
   strcpy(info->objectID, "");
   strcpy(info->categories, kBitmapCategory);
   strcpy(info->categoryDisplayName, kBitmapCategoryDisplayName);

   info--;   // back up and point to the first block again
   BitmapInfo._maximum = 2;
   BitmapInfo._length = 2;
   BitmapInfo._buffer = info;
   return BitmapInfo;
}


SOM_Scope string  SOMLINK M_BitmapclsGetOLE2ClassId(M_Bitmap *somSelf,
                                                          Environment *ev)
{
    /* M_BitmapData *somThis = M_BitmapGetData(somSelf); */
    M_BitmapMethodDebug("M_Bitmap","M_BitmapclsGetOLE2ClassId");

    // 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 = "{33d0eae0-2ed4-11d0-b268-08005a49d940}";
    string OLE2ClassId = (string)SOMMalloc(strlen(OLE2)+1);
    strcpy(OLE2ClassId,OLE2);

    return OLE2ClassId;
}


SOM_Scope string  SOMLINK M_BitmapclsGetWindowsIconFileName(M_Bitmap *somSelf,
                                                                  Environment *ev)
{
    /* M_BitmapData *somThis = M_BitmapGetData(somSelf); */
    M_BitmapMethodDebug("M_Bitmap","M_BitmapclsGetWindowsIconFileName");

    string fileName = (string) SOMMalloc (strlen("")+1);
    fileName = "";
    return fileName;
}
