//====START_GENERATED_PROLOG======================================
//
//
//   COMPONENT_NAME: oddataxfer
//
//   CLASSES: none
//
//   ORIGINS: 82,27,94
//
//
//   (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.10 nt/src/storage/WTranslt.cpp, oddataxfer, od96nt, odnt9712d 8/15/96 16:53:15 [ 3/21/97 17:13:20 ]
/*
	File:		Translt.cpp

	Contains:	Implementation of ODTranslation class.

	Owned by:	Vincent Lo

	Copyright:	© 1994 - 1995 by Apple Computer, Inc., all rights reserved.

	Change History (most recent first):

		<33>	10/24/95	VL		1294279: Checks existence of CFM library in
									addition to Gestalt.
		<32>	10/18/95	CC		GM 1293725: ShowTranslateDialog:
									initialEditor parameter may be null.
		<31>	10/16/95	VL		1291692: Added SOM_TRY to
									GetISOTypeFromPlatformType and
									GetPlatformTypeFromISOType.
		<30>	 10/9/95	VL		1288571: Moved
									kODErrNoSysTranslationFacility to
									ErrorDef.idl.
		<29>	 10/8/95	TJ		Fixes Recomended by Refball
		<28>	 9/12/95	DM		1280020 FB1 part trans dlg mem leaks
		<27>	 8/26/95	T‚		1274606 FB2: Patching Remarks
		<26>	 8/15/95	CC		1276520: ShowTranslateDialog: Changed
									"inout" parameter to one "in" and one
									"out".
		<25>	  8/3/95	RR		#1257260: Collapse B classes. Remove
									somInit methods. Don't call IsInitialized
									or SubclassResponsibility
		<24>	 7/28/95	VL		1270320: Use TempODTypeList for
									GetTranslationOf and CommonTranslate.
		<23>	 7/14/95	TJ		Turned On TransLation for 68K.
		<22>	 6/21/95	CC		1260937: BB: ODTypeListIterator must return
									copies of ODType values.
		<21>	  6/7/95	CC		1237791: LocalGetPlatformTypeFromISOType:
									Initialize result to 0.
		<20>	  6/2/95	CC		1236618: Use CreateTypeList factory method.
		<19>	 5/26/95	VL		1251403: Multithreading naming support.
		<18>	 5/25/95	jpa		Fixed usage of ODDebug. [1253321]
		<17>	 5/19/95	VL		1249626: Allocate memory for out
									ODByteArray in Translate.
		<16>	 4/25/95	VL		1210982: Removed 5$.
		<15>	 3/28/95	CC		1229640: Added forPaste parameter to
									ShowTranslateDialog call.
		<14>	 3/28/95	CC		1233117: Removed unused ODStorageUnit
									parameter from  ShowPartTranslateDialog.
		<13>	 3/27/95	CC		1229640: Renamed ShowTranslateDialog() to
									ShowPartTranslateDialog().
									Added ShowPartTranslateDialog().
		<12>	 3/23/95	VL		1228275: ASSERT for null ODByteArray.
		<11>	 2/10/95	CG		#1177475: Added include for StdDefs.xh.
		<10>	 1/10/95	CC		1209483 TranslateView() fixed to write into
									destination view.
		 <9>	12/20/94	VL		1195012: Make Storage calls be
									marshallable.
		 <8>	12/13/94	CG		#1187128: Moved Translation dialog code to
									Storage subsystem.
		 <7>	 10/4/94	VL		1162335: Moved consts to StorDef.h.
		 <6>	 9/29/94	RA		1189812: Mods for 68K build.
		 <5>	 9/20/94	VL		Fixes for new MEO headers.
		 <4>	 8/28/94	VL		1183500: Added implementation based on MEO
									1.1.
		 <3>	 8/16/94	VL		1180054: TypeSet should be TypeList.
		 <2>	 7/26/94	VL		Changed ODType to ODValueType.
		 <1>	 6/28/94	VL		first checked in
		 <1>	 6/28/94	VL		first checked in

	To Do: 
	In Progress:
*/
#include <Windows.h>

#define ODTranslation_Class_Source
#define VARIABLE_MACROS
#include <Translt.xih>

#ifndef SOM_Module_OpenDoc_StdDefs_defined
#include <StdDefs.xh>
#endif

#ifndef SOM_ODTypeList_xh
#include <TypeList.xh>
#endif

#ifndef SOM_ODTypeListIterator_xh
#include <TypLsItr.xh>
#endif

#ifndef SOM_ODStorageSystem_xh
#include <ODStor.xh>
#endif

#ifndef SOM_ODStorageUnitView_xh
#include <SUView.xh>
#endif

#ifndef SOM_ODSession_xh
#include <ODSessn.xh>
#endif

#ifndef SOM_Module_OpenDoc_StdTypes_defined
#include <StdTypes.xh>
#endif

#ifndef _ODMEMORY_
#include "ODMemory.h"
#endif

#ifndef _ISOSTR_
#include "ISOStr.h"
#endif

#ifndef _EXCEPT_
#include "Except.h"
#endif

#ifndef _ODMEMORY_
#include "ODMemory.h"
#endif

#ifndef _STORDEF_
#include "StorDef.h"
#endif

#ifndef _BARRAY_
#include <BArray.h>
#endif


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

#ifndef _TEMPOBJ_
#include <TempObj.h>
#endif

#ifndef _OLEMGRW_
#include <OleMgrW.h>
#endif

#pragma segment ODTranslation

#include "TransltB.cpp"	// Platform-independent methods, if any

#if ODDebug
// #define ODDebug_Translation 1
#endif

#define PLFM_TEXT						0x54584554L	/* "TEXT" */		//OLE2
#define PLFM_BITMAP						0x57504D42L	/* "BMPW" */		//OLE2
#define PLFM_METAFILEPICT				0x5750464DL	/* "MFPW" */		//OLE2
#define PLFM_SYLK						0x574C5953L	/* "SYLW" */		//OLE2
#define PLFM_DIF						0x57464944L	/* "DIFW" */		//OLE2
#define PLFM_TIFF						0x57464954L	/* "TIFW" */		//OLE2
#define PLFM_OEMTEXT					0x574D454FL	/* "OEMW" */		//OLE2
#define PLFM_DIB						0x57424944L	/* "DIBW" */		//OLE2
#define PLFM_PALETTE					0x574C4150L	/* "PALW" */		//OLE2
#define PLFM_PENDATA					0x574E4550L	/* "PENW" */		//OLE2
#define PLFM_RIFF						0x57464952L	/* "RIFW" */		//OLE2
#define PLFM_WAVE						0x57564157L	/* "WAVW" */		//OLE2
#define PLFM_UNICODETEXT					0x57494E55L	/* "UNIW" */		//OLE2
#define PLFM_ENHMETAFILE					0x57484E45L	/* "ENHW" */		//OLE2
#define PLFM_HDROP      					0x57504448L	/* "HDPW" */		//OLE2
#define PLFM_LOCALE     					0x57434F4CL	/* "LOCW" */		//OLE2

//==============================================================================
// Scalar Types
//==============================================================================

static ODType LocalGetISOTypeFromPlatformType(ODPlatformType platformType,
			ODPlatformTypeSpace typeSpace, ODTranslationData *somThis);

static ODPlatformType LocalGetPlatformTypeFromISOType(ODType isoType, ODTranslationData *somThis);

//==============================================================================
// Globals
//==============================================================================

//==============================================================================
// Class ODTranslation
//==============================================================================

//------------------------------------------------------------------------------
// ODTranslation: Purge
//------------------------------------------------------------------------------

SOM_Scope ODSize  SOMLINK ODTranslationPurge(ODTranslation *somSelf, Environment *ev,
		ODSize size)
{
    ODTranslationData *somThis = ODTranslationGetData(somSelf); 
    ODTranslationMethodDebug("ODTranslation","ODTranslationPurge");

	return 0;
}

//------------------------------------------------------------------------------
// ODTranslation: somUninit
//------------------------------------------------------------------------------

SOM_Scope void  SOMLINK ODTranslationsomUninit(ODTranslation *somSelf)
{
    ODTranslationData *somThis = ODTranslationGetData(somSelf); 
    ODTranslationMethodDebug("ODTranslation","ODTranslationsomUninit");

    parent_somUninit(somSelf);
}

//------------------------------------------------------------------------------
// ODTranslation: InitTranslation
//------------------------------------------------------------------------------

SOM_Scope void  SOMLINK ODTranslationInitTranslation(ODTranslation *somSelf, Environment *ev,
		ODSession* session)
{
    ODTranslationData *somThis = ODTranslationGetData(somSelf); 
    ODTranslationMethodDebug("ODTranslation","ODTranslationInitTranslation");

	SOM_TRY

	/* Moved from somInit. SOM itself sets fields to zero
	_fMEOExists = kODFalse;
	_fTranslationDialog = kODNULL;
	*/
        somSelf->InitObject(ev);

	_fSession = session;

	_fOleManager = session->GetOleManager(ev);

	SOM_CATCH_ALL
	SOM_ENDTRY
}

//------------------------------------------------------------------------------
// ODTranslation: CanTranslate
//------------------------------------------------------------------------------

SOM_Scope ODTranslateResult  SOMLINK ODTranslationCanTranslate(ODTranslation *somSelf, Environment *ev,
		ODValueType fromType)
{
    ODTranslationData *somThis = ODTranslationGetData(somSelf); 
    ODTranslationMethodDebug("ODTranslation","ODTranslationCanTranslate");
	
	ODTranslateResult	result;

	SOM_TRY

	ODTypeList* typeList = somSelf->GetTranslationOf(ev, fromType);
	
	if (typeList->Count(ev) > 0)
		result = kODCanTranslate;
	else
		result = kODCannotTranslate;
		
	delete typeList;
	
	SOM_CATCH_ALL
		result = kODCannotTranslate;
	SOM_ENDTRY
		
	return result;
}

//------------------------------------------------------------------------------
// ODTranslation: ShowPartTranslateDialog
//------------------------------------------------------------------------------

SOM_Scope ODBoolean  SOMLINK ODTranslationShowPartTranslateDialog(ODTranslation *somSelf, Environment *ev,
	ODPartWrapper* partWrapper)
{
    ODTranslationData *somThis = ODTranslationGetData(somSelf);
    ODTranslationMethodDebug("ODTranslation","ODTranslationShowPartTranslateDialog");

        return kODFalse;
}

//------------------------------------------------------------------------------
// ODTranslation: ShowTranslateDialog
//------------------------------------------------------------------------------

SOM_Scope ODBoolean  SOMLINK ODTranslationShowTranslateDialog(ODTranslation *somSelf, Environment *ev,
				ODTypeList*	translateToList,
				ODUShort	initialKind,
				ODUShort*	selectedKind,
				ODEditor	initialEditor,
				ODBoolean	canChangeEditor,
				ODEditor*	selectedEditor)
{
    ODTranslationData *somThis = ODTranslationGetData(somSelf);
    ODTranslationMethodDebug("ODTranslation","ODTranslationShowTranslateDialog");

	ODBoolean result = kODFalse;	ODVolatile(result);

	return result;
}

//------------------------------------------------------------------------------
// ODTranslation: GetTranslationOf
//------------------------------------------------------------------------------
// Return the set of kinds the argument may be translated into.  Internally, this
// routine converts to and from platform types to use the translation services of
// the host platform.

SOM_Scope ODTypeList*  SOMLINK ODTranslationGetTranslationOf(ODTranslation *somSelf, Environment *ev,
		ODValueType fromType)
{
    ODTranslationData *somThis = ODTranslationGetData(somSelf); 
    ODTranslationMethodDebug("ODTranslation","ODTranslationGetTranslationOf");

	SOM_TRY
	ODTypeList* toTypeList = _fSession->GetStorageSystem(ev)->CreateTypeList(ev, kODNULL);
	return toTypeList;
	SOM_CATCH_ALL

	SOM_ENDTRY
	  return kODNULL;
}

//------------------------------------------------------------------------------
// ODTranslation: TranslateView
//------------------------------------------------------------------------------

SOM_Scope ODTranslateResult  SOMLINK ODTranslationTranslateView(ODTranslation *somSelf, Environment *ev,
		ODStorageUnitView* fromView,
		ODStorageUnitView* toView)
{
    ODTranslationData *somThis = ODTranslationGetData(somSelf); 
    ODTranslationMethodDebug("ODTranslation","ODTranslationTranslateView");
	
	ODTranslateResult result = kODCannotTranslate;
        THROW(kODErrNoSysTranslationFacility);
	SOM_TRY


	SOM_CATCH_ALL
		result = kODCannotTranslate;
	SOM_ENDTRY

	return result;
}

//------------------------------------------------------------------------------
// ODTranslation: Translate
//------------------------------------------------------------------------------

SOM_Scope ODTranslateResult  SOMLINK ODTranslationTranslate(ODTranslation *somSelf, Environment *ev,
		ODValueType		fromType,
		ODByteArray*	fromDataBA,
		ODValueType		toType,
		ODByteArray*	toDataBA)
{
    ODTranslationData *somThis = ODTranslationGetData(somSelf); 
    ODTranslationMethodDebug("ODTranslation","ODTranslationTranslate");
	
	ODTranslateResult	result = kODCannotTranslate;
  	ODHandle			toDataHandle = kODNULL;

        THROW(kODErrNoSysTranslationFacility);
	
	SOM_TRY

	SOM_CATCH_ALL
		result = kODCannotTranslate;
	SOM_ENDTRY
	
	return result;
}

//------------------------------------------------------------------------------
// ODTranslation: GetISOTypeFromPlatformType
//------------------------------------------------------------------------------

SOM_Scope ODValueType  SOMLINK ODTranslationGetISOTypeFromPlatformType(ODTranslation *somSelf, Environment *ev,
		ODPlatformType platformType,
		ODPlatformTypeSpace typeSpace)
{
    ODTranslationData *somThis = ODTranslationGetData(somSelf); 
    ODTranslationMethodDebug("ODTranslation","ODTranslationGetISOTypeFromPlatformType");

	ODValueType type = kODNULL; ODVolatile(type);
	
	SOM_TRY
	
		type = LocalGetISOTypeFromPlatformType(platformType, typeSpace, somThis);
		
	SOM_CATCH_ALL
	SOM_ENDTRY
	
	return type;
}

//------------------------------------------------------------------------------
// ODTranslation: GetPlatformTypeFromISOType
//------------------------------------------------------------------------------

SOM_Scope ODPlatformType  SOMLINK ODTranslationGetPlatformTypeFromISOType(ODTranslation *somSelf, Environment *ev,
		ODValueType type)
{
    ODTranslationData *somThis = ODTranslationGetData(somSelf); 
    ODTranslationMethodDebug("ODTranslation","ODTranslationGetPlatformTypeFromISOType");
	
	SOM_TRY
		return LocalGetPlatformTypeFromISOType(type, somThis);
	SOM_CATCH_ALL
	SOM_ENDTRY

	return (ODPlatformType) kODNULL;

}

//=====================================================================================
// LocalGetISOTypeFromPlatformType
//=====================================================================================

ODType LocalGetISOTypeFromPlatformType(ODPlatformType platformType,
			ODPlatformTypeSpace typeSpace, ODTranslationData *somThis)
{
	ODType			isoType 		= kODNULL;
	ODPlatformType	PlfmType		= 0;
	ODULong			prefixSize 		= strlen(kODAppleScrapTypePrefix);
	ODULong			Size;
	char			szClipFmt[100];
	
	switch (typeSpace)
	{			
		case kODPlatformDataType:
			/* Special case: we must map "OpenDoc:Type:OleLinkSpec" to an OLE2
			 * specific clipboard format called CF_LINKSOURCE
			 */
			if ((UINT)platformType == _fOleManager->fCFLinkSource)
			{
				isoType    = (ODType)ODNewPtr(strlen(kODLinkSpec)+1);
				if(isoType)
					strcpy(isoType,kODLinkSpec);
				break;
			}

			/* Special case: we must map "OpenDoc:Type:OleLinkSpecDesc" to an
			 * OLE2 specific clipboard format called CF_LINKSOURCEDESCRIPTOR
			 */
			if ((UINT)platformType == _fOleManager->fCFLinkSrcDescriptor)
			{
				isoType    = (ODType)ODNewPtr(strlen(kODLinkSpecDescriptor)+1);
				if (isoType)
					strcpy(isoType,kODLinkSpecDescriptor);
				break;
			}

			/* Special case: we must map "OpenDoc:Type:OleObjSpec" to an OLE2
			 * specific clipboard format called CF_EMBEDDEDOBJECT
			 */
			if ((UINT)platformType == _fOleManager->fCFEmbeddedObject)
			{
				isoType    = (ODType)ODNewPtr(strlen(kODObjSpec)+1);
         				if(isoType)
					strcpy(isoType,kODObjSpec);
				break;
			}

			/* Special case: we must map "OpenDoc:Type:OleObjSpecDesc" to an
			 * OLE2 specific clipboard format called CF_LINKSOURCEDESCRIPTOR
			 */
			if ((UINT)platformType == _fOleManager->fCFObjectDescriptor)
			{
				isoType    = (ODType)ODNewPtr(strlen(kODObjSpecDescriptor)+1);
				if (isoType)
					strcpy(isoType,kODObjSpecDescriptor);
				break;
			}

			/* Figure out the four character suffix for this "Apple:XXXX" 		
			 * ISO type name, if this is one of the standard formats
			 */
			switch ( (UINT)platformType )
			{
				case CF_TEXT:
					PlfmType	= (ODPlatformType) PLFM_TEXT;
					break;					
				case CF_BITMAP:
					PlfmType	= (ODPlatformType) PLFM_BITMAP;
					break;					
				case CF_METAFILEPICT:
					PlfmType	= (ODPlatformType) PLFM_METAFILEPICT;
					break;					
				case CF_SYLK:
					PlfmType	= (ODPlatformType) PLFM_SYLK;
					break;					
				case CF_DIF:
					PlfmType	= (ODPlatformType) PLFM_DIF;
					break;					
				case CF_TIFF:
					PlfmType	= (ODPlatformType) PLFM_TIFF;
					break;					
				case CF_OEMTEXT:
					PlfmType	= (ODPlatformType) PLFM_OEMTEXT;
					break;					
				case CF_DIB:
					PlfmType	= (ODPlatformType) PLFM_DIB;
					break;					
				case CF_PALETTE:
					PlfmType	= (ODPlatformType) PLFM_PALETTE;
					break;					
				case CF_PENDATA:
					PlfmType	= (ODPlatformType) PLFM_PENDATA;
					break;					
				case CF_RIFF:
					PlfmType	= (ODPlatformType) PLFM_RIFF;
					break;					
				case CF_WAVE:
					PlfmType	= (ODPlatformType) PLFM_WAVE;
					break;					
				case CF_UNICODETEXT:
					PlfmType	= (ODPlatformType) PLFM_UNICODETEXT;
					break;					
				case CF_ENHMETAFILE:
					PlfmType	= (ODPlatformType) PLFM_ENHMETAFILE;
					break;					
				case CF_HDROP:
					PlfmType	= (ODPlatformType) PLFM_HDROP;
					break;					
				case CF_LOCALE:
					PlfmType	= (ODPlatformType) PLFM_LOCALE;
					break;					
			}

			/* Now either build the ISO type name from the four character
			 * suffix and the string "Apple:OSType:Scrap" or get the real
			 * clipboard format name.
			 */
			if (PlfmType)
			{
				isoType    = (ODType) ODNewPtr(prefixSize +
											   sizeof(ODPlatformType) + 1);
				if (isoType != kODNULL)
				{
					strcpy(isoType,kODAppleScrapTypePrefix);
					strncat(isoType,(char*)&PlfmType,sizeof(PlfmType));
				}
			}
			else
			{
				Size = GetClipboardFormatName((unsigned int) platformType,
											  szClipFmt,
											  sizeof(szClipFmt));
				if (Size)
				{
					isoType    = (ODType) ODNewPtr(Size + 1);
					if (isoType != kODNULL)
						strcpy(isoType,szClipFmt);
								}
				// 29 apr 96 rrk - the following code is copied from DR4.  If we get to this
				//                 point, we have not been handed any of the standard 
				//                 CF_xxxx types.  Also, we have tried to 
				//                 ask WIN32 for the name of this format, but failed.  We assume
				//                 that we have been handed a long that can be interpreted as a
				//                 four-character string (e.g. 0x54584554L is "TEXT").  We
				//                 append this four-character string to the common prefix
				//                 kODAppleScrapTypePrefix.
				else
				{
				  isoType = (ODValueType) ODNewPtr(prefixSize + sizeof(ODPlatformType) + 1,
								   ODGetDefaultHeap());
				  if (isoType != kODNULL) {
				    ODISOStrCopy(isoType, kODAppleScrapTypePrefix);
				    ODISOStrNConcat(isoType, (ODISOStr) &platformType, sizeof(ODPlatformType));
				    isoType[prefixSize + sizeof(ODPlatformType)] = 0;
				  }
				}
			}
			break;
			
		case kODPlatformFileType:
			isoType 	= (ODValueType) ODNewPtr(prefixSize + sizeof(ODPlatformType) + 1);
			if (isoType != kODNULL)
			{
				strcpy(isoType, kODAppleFileTypePrefix);
				strncat(isoType,(char*)&platformType,sizeof(ODPlatformType));
				isoType[prefixSize + sizeof(ODPlatformType)] = 0;
			}
			break;
						
		default:
			break;
	}
	
	return isoType;
}

//=====================================================================================
// LocalGetPlatformTypeFromISOType
//=====================================================================================

ODPlatformType LocalGetPlatformTypeFromISOType(ODType type, ODTranslationData* somThis)
{
	ODPlatformType		ClipType	= 0, *pPlfmType;
	ODULong				prefixSize 	= strlen(kODAppleScrapTypePrefix);

	if (!strncmp(kODAppleScrapTypePrefix,(ODISOStr)type,prefixSize))
	{
		/* For things that start with "Apple:OSType:Scrap", just take the
		 * four character suffix and turn that into a clipboard format
		 */
		pPlfmType = (ODPlatformType *)((ODSByte*) type + prefixSize);
//		switch (*pPlfmType)				LATER: when we are 32 bit !
		if (*pPlfmType == (ODPlatformType) PLFM_TEXT)
			ClipType	= (ODPlatformType) CF_TEXT;
		else if(*pPlfmType == (ODPlatformType) PLFM_BITMAP)
			ClipType	= (ODPlatformType) CF_BITMAP;
		else if(*pPlfmType == (ODPlatformType) PLFM_METAFILEPICT)
			ClipType	= (ODPlatformType) CF_METAFILEPICT;
		else if(*pPlfmType == (ODPlatformType) PLFM_SYLK)
			ClipType	= (ODPlatformType) CF_SYLK;
		else if(*pPlfmType == (ODPlatformType) PLFM_DIF)
			ClipType	= (ODPlatformType) CF_DIF;
		else if(*pPlfmType == (ODPlatformType) PLFM_TIFF)
			ClipType	= (ODPlatformType) CF_TIFF;
		else if(*pPlfmType == (ODPlatformType) PLFM_OEMTEXT)
			ClipType	= (ODPlatformType) CF_OEMTEXT;
		else if(*pPlfmType == (ODPlatformType) PLFM_DIB)
			ClipType	= (ODPlatformType) CF_DIB;
		else if(*pPlfmType == (ODPlatformType) PLFM_PALETTE)
			ClipType	= (ODPlatformType) CF_PALETTE;
		else if(*pPlfmType == (ODPlatformType) PLFM_PENDATA)
			ClipType	= (ODPlatformType) CF_PENDATA;
		else if(*pPlfmType == (ODPlatformType) PLFM_RIFF)
			ClipType	= (ODPlatformType) CF_RIFF;
		else if(*pPlfmType == (ODPlatformType) PLFM_WAVE)
			ClipType	= (ODPlatformType) CF_WAVE;
		else if(*pPlfmType == (ODPlatformType) PLFM_UNICODETEXT)
			ClipType	= (ODPlatformType) CF_UNICODETEXT;
		else if(*pPlfmType == (ODPlatformType) PLFM_ENHMETAFILE)
			ClipType	= (ODPlatformType) CF_ENHMETAFILE;
		else if(*pPlfmType == (ODPlatformType) PLFM_HDROP)
			ClipType	= (ODPlatformType) CF_HDROP;
		else if(*pPlfmType == (ODPlatformType) PLFM_LOCALE)
			ClipType	= (ODPlatformType) CF_LOCALE;
		else
			ClipType = (ODPlatformType) RegisterClipboardFormat(type);
	}
	else if (!strcmp(kODLinkSpecDescriptor,type))
	{
		/* Special case: we must map "OpenDoc:Type:OleLinkSpecDesc" to an OLE2
		 * specific clipboard format called CF_LINKSOURCEDESCRIPTOR
		 */
		ClipType = (ODPlatformType) _fOleManager->fCFLinkSrcDescriptor;
	}
	else if (!ODISOStrCompare(kODLinkSpec,type))
	{
		/* Special case: we must map "OpenDoc:Type:LinkSpec" to an OLE2
		 * specific clipboard format called CF_LINKSOURCE
		 */
		ClipType = (ODPlatformType) _fOleManager->fCFLinkSource;
	}
	else if (!strcmp(kODObjSpecDescriptor,type))
	{
		/* Special case: we must map "OpenDoc:Type:OleObjSpecDesc" to an OLE2
		 * specific clipboard format called CF_OBJECTDESCRIPTOR
		 */
		ClipType = (ODPlatformType) _fOleManager->fCFObjectDescriptor;
	}
	else if (!ODISOStrCompare(kODObjSpec,type))
	{
		/* Special case: we must map "OpenDoc:Type:OleObjSpec" to an OLE2
		 * specific clipboard format called CF_EMBEDDEDOBJECT
		 */
		ClipType = (ODPlatformType) _fOleManager->fCFEmbeddedObject;
	}
	else
	{
		/* For all other types, just convert the type name to a clipboard fmt
		 */
		ClipType = (ODPlatformType) RegisterClipboardFormat(type);
	}
	return ClipType;

}

