#include "stdafx.h"
#include "DynamicDraw.h"
#include "DynamicDrawView.h"	// For g_pView.
#include "CntrItem.h"			// For CMolipDrawCntrItem4_0.
#include "ObjOle.h"				// For FCObjOle.
#include "ToolOleEdit.h"		// This header.

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


/////////////////////////////////////////////////////////////////////////
// FCToolOleEdit_xZkqqHx_iDiBiDjDiDgPiKnGjAjEiBeC_xHqqkZx_

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	FCToolOleEdit::Select
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iClBiCmMiDgDiBfLiDiLiCkKjBeJjBpAiClDiCoKiClNiCmGiCkLiBeBiDfCiBfLiDiLiClDiCoKiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	pDC	:_xZkqqHx_jFgAiJoGjHhAiDgGiDgPiDeDiDfIiDfCiDjDiDgFiDeMiDfIiDgHiCpAiOhHjCoIiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	00.02.19 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
void FCToolOleEdit::Select (CDC* pDC)
{
	// Superclass_xZkqqHx_iKnGjAjEiCpAiOmAiNhDiBeC_xHqqkZx_
	BASE_CLASS::Select(pDC);
//----- 05.06.13 Fukushiro M. _xZkqqHx_iNoNiPjMiOgO_xHqqkZx_ ()-----
//	// _xZkqqHx_iMjPiNpFiMiLiJmKiCmMjFmPjAjEiCpAiPiJiKpKiJlLiBeC_xHqqkZx_
//	m_pHitObj = NULL;
//----- 05.06.13 Fukushiro M. _xZkqqHx_iNoNiPjMiPeJ_xHqqkZx_ ()-----
	// _xZkqqHx_iCgOiCgLiCgEiOmAiNhDiPiIjHjNiBeC_xHqqkZx_
	StateRunVerb(pDC);
//----- 00.11.24 Fukushiro M. _xZkqqHx_jFmPiNfIiPeJ_xHqqkZx_ ()-----
} // FCToolOleEdit::Select.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	FCToolOleEdit::Unselect
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iClBiCmMiDgDiBfLiDiLiCkKjBeJjBpAiJpAiPjMiClDiCoKiClNiCmGiCkLiBeBiDfCiBfLiDiLiClDiCoKiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	pDC	:_xZkqqHx_jFgAiJoGjHhAiDgGiDgPiDeDiDfIiDfCiDjDiDgFiDeMiDfIiDgHiCpAiOhHjCoIiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	00.11.24 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
void FCToolOleEdit::Unselect (CDC* pDC)
{
	g_pDoc->CloseOleDocuments();
	// Superclass_xZkqqHx_iKnGjAjEiOmAiNhDiBeC_xHqqkZx_
	BASE_CLASS::Unselect(pDC);
} // FCToolOleEdit::Unselect.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	FCToolOleEdit::CanHandle
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iOhHjCoIiClDiCoKiClNjFjEjFgJiCkKiClBiCmMiDgDiBfLiDiLiCmFiIlFiCkGiCoJiCkJiCmHiCkEiCkJiCpAjFnEiClHiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	pObj	:_xZkqqHx_jFjEjFgJiCpAiOhHjCoIiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jFnEjCgM_xHqqkZx_>	_xZkqqHx_iJmCjEfMiCmMiPoKiNiHiCmN_xHqqkZx_ TRUE_xZkqqHx_iBeBjFhDiJmCjEfMiCmMiPoKiNiHiCmN_xHqqkZx_ FALSE _xZkqqHx_iCpAjFnEiClHiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	00.02.19 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
BOOL FCToolOleEdit::CanHandle (const FCObjDynabase* pObj) const
{
//----- 00.12.30 Fukushiro M. _xZkqqHx_jFmPiNfIjBeP_xHqqkZx_ ()-----
//	return pObj->IsKindOf(FDOJ_OLE);
//----- 00.12.30 Fukushiro M. _xZkqqHx_jFmPiNfIiMoD_xHqqkZx_ ()-----
	if (!pObj->IsKindOf(FDOJ_OLE)) return FALSE;
	if (!((FCObjOle*)pObj)->IsOleItemValid()) return FALSE;
	// Superclass_xZkqqHx_iKnGjAjEiOmAiNhDiBeC_xHqqkZx_
	return BASE_CLASS::CanHandle(pObj);
//----- 00.12.30 Fukushiro M. _xZkqqHx_jFmPiNfIiPeJ_xHqqkZx_ ()-----
} // FCToolOleEdit::CanHandle.

//----- 05.06.13 Fukushiro M. _xZkqqHx_iNoNiPjMiOgO_xHqqkZx_ ()-----
///*************************************************************************
// * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	FCToolOleEdit::TransFDA
// *
// * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iMiIjCoIjAkLjHeMiMmAiDeJiBfLiDgHiDhNiDgHiDjDiCmMjBeKiInKiCpAjFnEiClHiBeC_xHqqkZx_ToolOleEdit.mdrw_xZkqqHx_iCpAiOfBiPmGiBeC_xHqqkZx_
// *
// * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	iState	:_xZkqqHx_iMlLiNnNiCmMiPpDjBnEiCpAiOhHjCoIiBeC_xHqqkZx_
// *			iEvent	:_xZkqqHx_iDeDiDhIiDjDiDgHiCpAiOhHjCoIiBeC_xHqqkZx_
// *
// * <_xZkqqHx_jFnEjCgM_xHqqkZx_>	_xZkqqHx_jBeKiInKiMoDiCmMiPpDjBnEiCpAjFnEiClHiBeC_xHqqkZx_
// *
// * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	00.02.19 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
// *************************************************************************/
//int FCToolOleEdit::TransFDA (int iState, int iEvent)
//{
//	// _xZkqqHx_iInKiNhDjAoGiPpDjBnEiBeC_xHqqkZx_
//	int iNextState = STATE_NONE;	// _xZkqqHx_iPpDjBnEjGlDiClFiBeC_xHqqkZx_
//	// FDA_xZkqqHx_iCmMiMlLiNnNiCmMiPpDjBnEiBeC_xHqqkZx_
//	switch (iState)
//	{
//	case STATE_IDLE:	// _xZkqqHx_jBnCiClPiBeC_xHqqkZx_
//		switch (iEvent)
//		{
//		case WM_LBUTTONDOWN:	// _xZkqqHx_iNlGiDhLiDfOiDjDiDfPiDeFiDjDiBeC_xHqqkZx_
//			if (CheckHitObject(m_pHitObj, FDOZ_ON_EDIT) && !g_pDoc->IsOleDocumentsOpened())
//				iNextState = STATE_SELECT_OBJ;	// _xZkqqHx_jFjEjFgJjBeJjBpAiBeC_xHqqkZx_
//			break;
//		}
//		break;
//	case STATE_SELECT_OBJ:			// _xZkqqHx_jFjEjFgJjBeJjBpAiBeC_xHqqkZx_
//		iNextState = STATE_RUN_VERB;	// OLE_xZkqqHx_jFnCiPfHiLeOjDkOiBeC_xHqqkZx_
//		break;
//	case STATE_RUN_VERB:	// OLE_xZkqqHx_jFnCiPfHiLeOjDkOiBeC_xHqqkZx_
//		iNextState = STATE_IDLE;	// _xZkqqHx_jBnCiClPiBeC_xHqqkZx_
//		break;
//	}
//	// _xZkqqHx_iPpDjBnEjBeKiInKjGlDiClFiCmMiPoKiNiHiCmNiDfIiBfLiDhAiBfLiDeOiDiJiDfIiCmMiPpDjBnEjBeKiInKiCpAiMmEiCnBiPgPiClHiBeC_xHqqkZx_
//	if (iNextState == STATE_NONE)
//		iNextState = BASE_CLASS::TransFDA(iState, iEvent);
//	return iNextState;
//} // FCToolOleEdit::TransFDA.
//----- 05.06.13 Fukushiro M. _xZkqqHx_iNoNiPjMiPeJ_xHqqkZx_ ()-----

//----- 05.06.13 Fukushiro M. _xZkqqHx_iNoNiPjMiOgO_xHqqkZx_ ()-----
///*************************************************************************
// * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	FCToolOleEdit::StateFDA
// *
// * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iPpDjBnEiCmJiJjOiClGiClNiPiIjHjNiCpAiOmAiNhDiClHiCoJiBeC_xHqqkZx_
// *
// * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	iState	:_xZkqqHx_iMlLiNnNiCmMiPpDjBnEiCpAiOhHjCoIiBeC_xHqqkZx_
// *			pDC		:_xZkqqHx_jFgAiJoGjHhAiDgGiDgPiDeDiDfIiDfCiDjDiDgFiDeMiDfIiDgHiBeC_xHqqkZx_
// *
// * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	00.02.19 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
// *************************************************************************/
//void FCToolOleEdit::StateFDA (int iState, CDC* pDC)
//{
//	// FDA_xZkqqHx_iCmMiOjPiCmMiPpDjBnEiBeC_xHqqkZx_
//	switch (iState)
//	{
////----- 00.11.24 Fukushiro M. _xZkqqHx_jCmHiJmBiOgO_xHqqkZx_ ()-----
//	case STATE_SELECT_OBJ:			// _xZkqqHx_jFjEjFgJjBeJjBpAiBeC_xHqqkZx_
//		StateSelectObj(pDC);
//		break;
////----- 00.11.24 Fukushiro M. _xZkqqHx_jCmHiJmBiPeJ_xHqqkZx_ ()-----
//	case STATE_RUN_VERB:	// OLE_xZkqqHx_jFnCiPfHiLeOjDkOiBeC_xHqqkZx_
//		StateRunVerb(pDC);
//		break;
//	default:
//		BASE_CLASS::StateFDA(iState, pDC);
//	}
//} // FCToolOleEdit::StateFDA.
//----- 05.06.13 Fukushiro M. _xZkqqHx_iNoNiPjMiPeJ_xHqqkZx_ ()-----

//----- 05.06.13 Fukushiro M. _xZkqqHx_iNoNiPjMiOgO_xHqqkZx_ ()-----
///*************************************************************************
// * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	FCToolOleEdit::StateSelectObj
// *
// * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_jFjEjFgJjBeJjBpAiPiIjHjNiBeC_xHqqkZx_
// *
// * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	pDC	:_xZkqqHx_jFgAiJoGjHhAiDgGiDgPiDeDiDfIiDfCiDjDiDgFiDeMiDfIiDgHiCpAiOhHjCoIiBeC_xHqqkZx_
// *
// * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	00.11.24 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
// *************************************************************************/
//void FCToolOleEdit::StateSelectObj (CDC* pDC)
//{
//	TRACE(_T("StateSelectObj\r\n"));
//	// _xZkqqHx_iNkBiCmMjBeJjBpAjFjEjFgJiCpAiJpAiPjMiClFiBeBjAfGiClNiCmJjBeJjBpAiClFjClMiClHiBeC_xHqqkZx_
//	g_pView->ClearSelectObj(pDC);
//	if (CanHandle(m_pHitObj))
//	//----- _xZkqqHx_jFnCiPfHiJmCjEfMiCmMiPoKiNiH_xHqqkZx_ -----
//	{
//		g_pView->AppendSelectObj(m_pHitObj, pDC);
//	}
//} // FCToolOleEdit::StateSelectObj.
//----- 05.06.13 Fukushiro M. _xZkqqHx_iNoNiPjMiPeJ_xHqqkZx_ ()-----

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	FCToolOleEdit::StateRunVerb
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	OLE_xZkqqHx_jFnCiPfHiLeOjDkOiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	pDC	:_xZkqqHx_jFgAiJoGjHhAiDgGiDgPiDeDiDfIiDfCiDjDiDgFiDeMiDfIiDgHiCpAiOhHjCoIiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	00.02.19 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
void FCToolOleEdit::StateRunVerb (CDC* pDC)
{
	TRACE(_T("StateRunVerb\r\n"));

//----- 02.06.05 Fukushiro M. _xZkqqHx_jCmHiJmBiOgO_xHqqkZx_ (_xZkqqHx_iDiMiDeDiDiEiBfLiCmMjFnCiPfHiMkAiCpAjBfDjFjEjGjFiPmB_xHqqkZx_->Undo->_xZkqqHx_jBlNiKhAjApMiDgDiBfLiDiLiCpAjBeJjBpA_xHqqkZx_->Redo->_xZkqqHx_jBlNiKhAjApMiCpAiNoMjAkMiClHiCoJiCmGjHiOiClPiCoJ_xHqqkZx_)-----
	// _xZkqqHx_jFjEjFgJjFnCiPfHiJmCjEfMiCmFiCmIiCkPiCoKiCmOjFjMiLeBiBeC_xHqqkZx_
	if (!FFCanEditObject()) return;
//----- 02.06.05 Fukushiro M. _xZkqqHx_jCmHiJmBiPeJ_xHqqkZx_ (_xZkqqHx_iDiMiDeDiDiEiBfLiCmMjFnCiPfHiMkAiCpAjBfDjFjEjGjFiPmB_xHqqkZx_->Undo->_xZkqqHx_jBlNiKhAjApMiDgDiBfLiDiLiCpAjBeJjBpA_xHqqkZx_->Redo->_xZkqqHx_jBlNiKhAjApMiCpAiNoMjAkMiClHiCoJiCmGjHiOiClPiCoJ_xHqqkZx_)-----

	// OLE_xZkqqHx_jFnCiPfHjCiGiCmIiCoHiCmOjFjMiLeBiBeC_xHqqkZx_
	if (g_pDoc->IsOleDocumentsOpened()) return;
	//----- _xZkqqHx_jBeJjBpAjCiGiCmMjFjEjFgJiCmMiCkEiClPiBeBiNmFiPiJiCmM_xHqqkZx_OLE_xZkqqHx_jFjEjFgJiCpAjFnCiPfHiPpDjBnEiCmJiClHiCoJ_xHqqkZx_ -----
	ObjDynabaseVector::const_iterator iObj;
	for (iObj = g_pView->SelectObjVector().begin();
		 iObj != g_pView->SelectObjVector().end(); iObj++)
	{
		if ((*iObj)->IsKindOf(FDOJ_OLE))
		{
			FCObjOle* pOle = (FCObjOle*)*iObj;
			if (pOle->GetOleClientItem() != NULL)
			{
				// OLE_xZkqqHx_iDeJiDhFiDfHiDeGiDeOiDgHiCpAjFnCiPfHiPpDjBnEiCmJiBeC_xHqqkZx_
				pOle->OpenOleDocument();
				break;
			}
		}
	}
	// OLE_xZkqqHx_iDeJiDhFiDfHiDeGiDeOiDgHiCmMjFnCiPfHiKeKiOgOiCpAiClBiCmMiDgDiBfLiDiLiCmJjCmKjCgNiClHiCoJiBeC_xHqqkZx_
	OnSelectObjModified();
} // FCToolOleEdit::StateRunVerb.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	FCToolOleEdit::ResetEditHandleList
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_jFnCiPfHiDgOiDjDiDgIiDiLiDiKiDfIiDgHiCpAiNmEjAnNjCoIiClHiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	05.06.03 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
void FCToolOleEdit::ResetEditHandleList ()
{
	// _xZkqqHx_jFnCiPfHiDgOiDjDiDgIiDiLiDiKiDfIiDgHiCpAiDeOiDiKiDeBiBeC_xHqqkZx_
	ClearEditHandleList();
//----- 05.06.14 Fukushiro M. _xZkqqHx_jFmPiNfIjBeP_xHqqkZx_ ()-----
//	//----- _xZkqqHx_jFnCiPfHiPpDjBnEiCmM_xHqqkZx_OLE_xZkqqHx_jFjEjFgJiCpAiOoGjDlOiClHiCoJ_xHqqkZx_ -----
//	ObjDynabaseVector::const_iterator iObj;
//	for (iObj = g_pView->SelectObjVector().begin();
//		 iObj != g_pView->SelectObjVector().end(); iObj++)
//	{
//		if ((*iObj)->IsKindOf(FDOJ_OLE))
//		{
//			FCObjOle* pOle = (FCObjOle*)*iObj;
//			if (pOle->IsEditting())
//			{
//				// _xZkqqHx_iLoJiMgAiCpAjDgPjIfOiBeC_xHqqkZx_ID=(_xZkqqHx_jFjEjFgJ_xHqqkZx_ID, 0, 0, 0)_xZkqqHx_iBeC_xHqqkZx_
//				AddEditHandle(	pOle->GetResizeFrame(),
//								FCHandleId(long(pOle->GetObjID()), 0, 0, 0));
//				break;
//			}
//		}
//	}
//----- 05.06.14 Fukushiro M. _xZkqqHx_jFmPiNfIiMoD_xHqqkZx_ ()-----
	ObjDynabaseVector::const_iterator iObj;
	for (iObj = g_pView->SelectObjVector().begin();
		 iObj != g_pView->SelectObjVector().end(); iObj++)
	{
		// _xZkqqHx_iLoJiMgAiCpAjDgPjIfOiBeC_xHqqkZx_ID=(_xZkqqHx_jFjEjFgJ_xHqqkZx_ID, 0, 0, 0)_xZkqqHx_iBeC_xHqqkZx_
		AddEditHandle(	(*iObj)->GetResizeFrame(),
						FCHandleId(long((*iObj)->GetObjID()), 0, 0, 0));
	}
//----- 05.06.14 Fukushiro M. _xZkqqHx_jFmPiNfIiPeJ_xHqqkZx_ ()-----
} // FCToolOleEdit::ResetEditHandleList.

