#include "stdafx.h"
#include "3Document.h"
#include "3CntrItem.h"
#include "4CntrItem.h"
#include "3ObjOle.h"			// This header.

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#ifdef SUPER_CLASS
#undef SUPER_CLASS
#endif

#define SUPER_CLASS MC3ObjBase

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	MC3ObjOle::MC3ObjOle
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDfCiDjDiDfIiDgHiDiJiDeOiDfOiBeC_xHqqkZx_FDFoundDoc_xZkqqHx_iCmM_xHqqkZx_InStream_xZkqqHx_iCmFjFeLjHhGiBeC_xHqqkZx_
 *************************************************************************/
MC3ObjOle::MC3ObjOle ()
{
	// m_mmrtFrame_xZkqqHx_iCmN_xHqqkZx_double_xZkqqHx_iMfOiCpAiOgHiCkEiCmMiCmFiBeB_xHqqkZx_8_xZkqqHx_iCmMjEhLjAjEiCmFiDeBiDiJiDeDiDjDiDiBiDjDiDgHiCkKjDpMiCoJiBeC_xHqqkZx_
	// sizeof(SUPER_CLASS)_xZkqqHx_iCmNiBeB_xHqqkZx_4_xZkqqHx_iCmMjEhLjAjEiClOiCmBiClNiCmMiCmFiBeBjFoCjAlDiCmJ_xHqqkZx_4_xZkqqHx_iCpAjBkLiClHiBeC_xHqqkZx_
	ASSERT(ALIGNMENT8(sizeof(SUPER_CLASS)) == offsetof(MC3ObjOle, m_mmrtFrame));
	// memcmp_xZkqqHx_iCmFiDeJiDhFiDfHiDeGiDeOiDgHjEoEiKhCiCpAiClHiCoJiClNiCnPiBeBiNfMjBkCjBmMiDeNiDiDiDgCiDhGiCoAjBfDiCmEiCePiCmFjGiEiCnPiCoJiBeC_xHqqkZx_
	memset(&m_mmrtFrame, 0, sizeof(MC3ObjOle) - offsetof(MC3ObjOle, m_mmrtFrame));

	m_pOleItem = NULL;
	m_mmrtFrame.SetRect(0, 0, 0, 0);
} // MC3ObjOle::MC3ObjOle.

//----- 05.06.13 Fukushiro M. _xZkqqHx_iNoNiPjMiOgO_xHqqkZx_ ()-----
///*************************************************************************
// * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	MC3ObjOle::IsKindOf
// *
// * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_jFjEjFgJiCkKiClBiCmMiMfOiBeBiIlNiCkCiCmNiClBiCmMiMfOiCmMiDfEiDhFiDeOiDiJiDfIiCmMiMfOiCkJiCmHiCkEiCkJiCpAjClCiCnHiCoJiBeC_xHqqkZx_
// *
// * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	nType	: _xZkqqHx_jClCiCnHiCoJiMfOiCpAiOhHjCoIiBeC_xHqqkZx_
// *
// * <_xZkqqHx_jFnEjCgM_xHqqkZx_>	TRUE	: nType_xZkqqHx_iMfOiBeBiIlNiCkCiCmNiClLiCmMiDfEiDhFiDeOiDiJiDfIiCmMiPoKiNiH_xHqqkZx_
// *			FALSE	: _xZkqqHx_iClLiCkEiCmFiCmIiCkCiPoKiNiH_xHqqkZx_
// *************************************************************************/
//BOOL MC3ObjOle::IsKindOf (FTObjectType nType) const
//{
//	if (nType == FDOJ_OLE) return TRUE;
//	return SUPER_CLASS::IsKindOf(nType);
//} // MC3ObjOle::IsKindOf.
//----- 05.06.13 Fukushiro M. _xZkqqHx_iNoNiPjMiPeJ_xHqqkZx_ ()-----

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	MC3ObjOle::Type
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iClBiCmMiDeOiDiJiDfIiCmMiMfOiCpAjFnEiClH_xHqqkZx_.
 *
 * <_xZkqqHx_jFnEjCgM_xHqqkZx_>	_xZkqqHx_iDeOiDiJiDfIiCmMiMfO_xHqqkZx_
 *************************************************************************/
FTObjectType MC3ObjOle::Type () const
{
	return FDOJ_OLE;
} // MC3ObjOle::Type.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	MC3ObjOle::OutStream
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_jFjEjFgJiCmMiPpDjBnEiCpAiDfIiDgHiDiKiBfLiDiAiCmJiPjBiCkLiPgPiClHiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	ar	: _xZkqqHx_iPjBiCkLiPgPiClFjHhAiCmM_xHqqkZx_MCARCHIVE
 *
 * <_xZkqqHx_jCiNiInD_xHqqkZx_>	m_pOleItem_xZkqqHx_iCmNiDfGiDiKiDeBiDiJiDeDiDfJiCmMjFeLjHhGiCmNiCmIiCkCiBeCjDmHiCnNiNjOiCnNiOjOiCmJiCmNiBeB_xHqqkZx_
 *			Document_xZkqqHx_iCmMiDfGiDiKiDeBiDiJiDeDiDfJiCmFjAnNjCoIiClFiCmEiCkNiCoKiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	99.03.03 Fukushiro M. CArchive_xZkqqHx_iCpA_xHqqkZx_MCARCHIVE_xZkqqHx_iCmJiPeDjAlDiBeC_xHqqkZx_
 *************************************************************************/
void MC3ObjOle::OutStream (MCARCHIVE& ar)
{
	// Superclass_xZkqqHx_iKnGjAjEiCpAiOmAiNhDiBeC_xHqqkZx_
	SUPER_CLASS::OutStream(ar);

	if (g_nVersion == 3)
	//----- Version3.x_xZkqqHx_iCmMiPoKiNiH_xHqqkZx_ -----
	{
		DBLPoint mmptLeftTop(m_mmrtFrame.left, m_mmrtFrame.top);
		ar << mmptLeftTop;	// _xZkqqHx_iDhEiDiMiBfLiDiAiCmMiNlGiPoDiNmAjFfHiBeC_xHqqkZx_
		if (m_pOleItem != NULL)
		{
			CSize size = ((CMolipDrawCntrItem*)m_pOleItem)->GetSize();
			if (size.cx == 0 || size.cy == 0)
			{
				ar << double(m_mmrtFrame.Width());
				ar << double(m_mmrtFrame.Height());
			} else
			{
				double dRatioX = m_mmrtFrame.Width() * (g_dDisplayPPM / double(size.cx));
				double dRatioY = m_mmrtFrame.Height() * (g_dDisplayPPM / double(size.cy));
				ar << dRatioX;		// OLE_xZkqqHx_iDeJiDhFiDfHiDeGiDeOiDgHiCmGiDhEiDiMiBfLiDiAiCmMiKgHiPgLjEoEiBeC_xHqqkZx_
				ar << dRatioY;		// OLE_xZkqqHx_iDeJiDhFiDfHiDeGiDeOiDgHiCmGiDhEiDiMiBfLiDiAiCmMiKgHiPgLjEoEiBeC_xHqqkZx_
			}
			ar << WORD(TRUE);
			// OLE_xZkqqHx_iDgIiDeMiDiFiDiBiDjDiDgHiCpAiLeMjIfOiBeC_xHqqkZx_
			ar << m_pOleItem;
		} else
		{
			ar << double(m_mmrtFrame.Width());
			ar << double(m_mmrtFrame.Height());
			ar << WORD(FALSE);
		}
	} else
	//----- Version4.x_xZkqqHx_iCmMiPoKiNiH_xHqqkZx_ -----
	{
		ar << m_mmrtFrame;		// _xZkqqHx_iDhEiDiMiBfLiDiAiCmMiNmAjFfHiBeC_xHqqkZx_
		if (m_pOleItem != NULL)
		{
			ar << WORD(TRUE);
			// OLE_xZkqqHx_iDgIiDeMiDiFiDiBiDjDiDgHiCpAiLeMjIfOiBeC_xHqqkZx_
			ar << m_pOleItem;
		} else
		{
			ar << WORD(FALSE);
		}
	}

} // MC3ObjOle::OutStream.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	MC3ObjOle::InStream
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_jFjEjFgJiCmMiPpDjBnEiCpAiDfIiDgHiDiKiBfLiDiAiCkJiCoHjDmHiCnNiNjOiCnOiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	ar	: _xZkqqHx_jDmHiCnNiNjOiCnNjHhAiCmM_xHqqkZx_MCARCHIVE
 *
 * <_xZkqqHx_jCiNiInD_xHqqkZx_>	m_pOleItem_xZkqqHx_iCmNiDfGiDiKiDeBiDiJiDeDiDfJiCmMjFeLjHhGiCmNiCmIiCkCiBeCjDmHiCnNiNjOiCnNiOjOiCmJiCmNiBeB_xHqqkZx_
 *			Document_xZkqqHx_iCmMiDfGiDiKiDeBiDiJiDeDiDfJiCmFjAnNjCoIiClFiCmEiCkNiCoKiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	99.03.03 Fukushiro M. CArchive_xZkqqHx_iCpA_xHqqkZx_MCARCHIVE_xZkqqHx_iCmJiPeDjAlDiBeC_xHqqkZx_
 *************************************************************************/
void MC3ObjOle::InStream (MCARCHIVE& ar)
{
	SUPER_CLASS::InStream(ar);

	if (g_nVersion == 3)
	//----- Version3.x_xZkqqHx_iCmMiPoKiNiH_xHqqkZx_ -----
	{
		DBLPoint mmptLeftTop;
		double dRatioX, dRatioY;
		ar >> mmptLeftTop;	// _xZkqqHx_iDhEiDiMiBfLiDiAiCmMiNlGiPoDiNmAjFfHiBeC_xHqqkZx_
		ar >> dRatioX;		// OLE_xZkqqHx_iDeJiDhFiDfHiDeGiDeOiDgHiCmGiDhEiDiMiBfLiDiAiCmMiKgHiPgLjEoEiBeC_xHqqkZx_
		ar >> dRatioY;		// OLE_xZkqqHx_iDeJiDhFiDfHiDeGiDeOiDgHiCmGiDhEiDiMiBfLiDiAiCmMiKgHiPgLjEoEiBeC_xHqqkZx_
		WORD wIsOle;
		ar >> wIsOle;
		if (wIsOle)
		{
			// OLE_xZkqqHx_iDgIiDeMiDiFiDiBiDjDiDgHiCpAjAlGjAkMiBeBiDgIiDeMiDiFiDiBiDjDiDgHiCmJjCmHiJmBiBeC_xHqqkZx_
			CDocItem* pItem;
			ar >> pItem;
			CMolipDrawCntrItem* pItem3_0 = (CMolipDrawCntrItem*)pItem;
			// 4.0_xZkqqHx_iCmM_xHqqkZx_OLE_xZkqqHx_iDeJiDhFiDfHiDeGiDeOiDgHiCpAiNoMjAkMiBeC_xHqqkZx_
			CMolipDrawCntrItem4_0* pItem4_0 = new CMolipDrawCntrItem4_0(g_pDoc);
			// 4.0_xZkqqHx_iCmM_xHqqkZx_OLE_xZkqqHx_iDeJiDhFiDfHiDeGiDeOiDgHiCmJ_xHqqkZx_OLE_xZkqqHx_iDgGiBfLiDfOiCpAjFkBiOmKiBeC_xHqqkZx_
			pItem4_0->CreateCloneFrom(pItem3_0);
			// 3.0_xZkqqHx_iCmM_xHqqkZx_OLE_xZkqqHx_iDeJiDhFiDfHiDeGiDeOiDgHiCpAiNoNiPjMiBeC_xHqqkZx_
			pItem3_0->Delete();
			// 4.0OLE_xZkqqHx_iDgIiDeMiDiFiDiBiDjDiDgHiCpAjAnNjCoIiBeC_xHqqkZx_
			m_pOleItem = (COleClientItem*)pItem4_0;

			m_mmrtFrame.left = mmptLeftTop.x;
			m_mmrtFrame.top = mmptLeftTop.y;
			CSize size = pItem4_0->GetSize();
			if (size.cx == 0 || size.cy == 0)
			{
				m_mmrtFrame.right = m_mmrtFrame.left + dRatioX;
				m_mmrtFrame.bottom = m_mmrtFrame.top + dRatioY;
			} else
			{
				m_mmrtFrame.right = m_mmrtFrame.left + dRatioX * (double(size.cx) / g_dDisplayPPM);
				m_mmrtFrame.bottom = m_mmrtFrame.top + dRatioY * (double(size.cy) / g_dDisplayPPM);
			}
		} else
		{
			m_pOleItem = NULL;
			m_mmrtFrame.left = mmptLeftTop.x;
			m_mmrtFrame.top = mmptLeftTop.y;
			m_mmrtFrame.right = m_mmrtFrame.left + dRatioX;
			m_mmrtFrame.bottom = m_mmrtFrame.top + dRatioY;
		}
	} else
	//----- Version4.x_xZkqqHx_iCmMiPoKiNiH_xHqqkZx_ -----
	{
		ar >> m_mmrtFrame;	// _xZkqqHx_iDhEiDiMiBfLiDiAiCmMiNmAjFfHiBeC_xHqqkZx_
		WORD wIsOle;
		ar >> wIsOle;
		if (wIsOle)
		{
			// OLE_xZkqqHx_iDgIiDeMiDiFiDiBiDjDiDgHiCpAjAlGjAkMiBeBiDgIiDeMiDiFiDiBiDjDiDgHiCmJjCmHiJmBiBeC_xHqqkZx_
			CDocItem* pItem;
			ar >> pItem;
			CMolipDrawCntrItem4_0* pItem4_0 = (CMolipDrawCntrItem4_0*)pItem;
			// 3.0_xZkqqHx_iCmM_xHqqkZx_OLE_xZkqqHx_iDeJiDhFiDfHiDeGiDeOiDgHiCpAiNoMjAkMiBeC_xHqqkZx_
			CMolipDrawCntrItem* pItem3_0 = new CMolipDrawCntrItem(g_pDoc);
			// 3.0_xZkqqHx_iCmM_xHqqkZx_OLE_xZkqqHx_iDeJiDhFiDfHiDeGiDeOiDgHiCmJ_xHqqkZx_OLE_xZkqqHx_iDgGiBfLiDfOiCpAjFkBiOmKiBeC_xHqqkZx_
			pItem3_0->CreateCloneFrom(pItem4_0);
			// 4.0_xZkqqHx_iCmM_xHqqkZx_OLE_xZkqqHx_iDeJiDhFiDfHiDeGiDeOiDgHiCpAiNoNiPjMiBeC_xHqqkZx_
			pItem4_0->Delete();
			// 3.0OLE_xZkqqHx_iDgIiDeMiDiFiDiBiDjDiDgHiCpAjAnNjCoIiBeC_xHqqkZx_
			m_pOleItem = (COleClientItem*)pItem3_0;
		} else
		{
			m_pOleItem = NULL;
		}
	}
} // MC3ObjOle::InStream.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	MC3ObjOle::~MC3ObjOle
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDgGiDfIiDgHiDiJiDeOiDfOiBeC_xHqqkZx_
 *************************************************************************/
MC3ObjOle::~MC3ObjOle ()
{
	if (m_pOleItem != NULL)
	{
		// _xZkqqHx_iDeBiDhGiDiKiPeJjHlJiOjOiCmJ_xHqqkZx_ m_pOleItem->Delete();_xZkqqHx_iCpAiOmAiNhDiClHiCoJiCmG_xHqqkZx_
		// Molip_xZkqqHx_iCpA_xHqqkZx_OLE_xZkqqHx_iCmGiClFiCmEiDhJiBfLiDfIiDgHiClFiClNjAoGiCmMiDeBiDhGiDiKiCkJ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