// 34Document.cpp : _xZkqqHx_iDeDiDjDiDhGiDiKiDiBiDjDiDgFiBfLiDfGiDiHiDjD_xHqqkZx_ _xZkqqHx_iDhEiDeAiDeDiDiL_xHqqkZx_
//

#include "stdafx.h"
#include "3HeaderInf.h"		// For MC3HeaderInf.
#include "3App.h"				// For MC3App.
#include "3Env.h"				// For MC3Env.
#include "3ToolManager.h"		// For MC3ToolManager.
#include "3LayerManager.h"		// For MC3LayerManager.
#include "3SheetManager.h"		// For MC3SheetManager.
#include "3LinkManager.h"		// For MC3LinkManager.
#include "3Reg.h"				// For MC3Reg.
#include "3CanvasStat.h"		// For MC3CanvasStat.
#include "3Document.h"			// This header.

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

MC3Document* g_pDoc = NULL;

/////////////////////////////////////////////////////////////////////////////
// MC3Document

IMPLEMENT_DYNCREATE(MC3Document, COleServerDoc)

/////////////////////////////////////////////////////////////////////////////
// MC3Document _xZkqqHx_iDiGiBfLiDfFiKnGjAjEiBeC_xHqqkZx_

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	MC3Document::SetRootStorage
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDiLiBfLiDgHiDfIiDgHiDiMiBfLiDfHiCpAjChFiCkLiKlHiCkGiCoJiBeCiDeBiBfLiDeKiDeDiDhFiCkJiCoH_xHqqkZx_OLE_xZkqqHx_iCpAjDmHiCnNiNjOiCnOiClNiCnPiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	pStorage	:_xZkqqHx_jChFiCkLiKlHiCkGiCoJiDfIiDgHiDiMiBfLiDfHiCpAiOhHjCoIiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jFnEjCgM_xHqqkZx_>	_xZkqqHx_iCoAiCmGiCoAiCmGiCmMiDiLiBfLiDgHiDfIiDgHiDiMiBfLiDfHiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iJpAjAoA_xHqqkZx_>	_xZkqqHx_iDeBiBfLiDeKiDeDiDhFiCkJiCoH_xHqqkZx_OLE_xZkqqHx_iCpAjDmHiCnNiNjOiCnOiPoKiNiHiBeBjFkBiNiHiDhEiDeAiDeDiDiLiCmFiCkAiCoKiCmOiBeB_xHqqkZx_
 *			_xZkqqHx_iDiLiBfLiDgHiDfIiDgHiDiMiBfLiDfHiCmGiDeBiBfLiDeKiDeDiDhFiCmNiDfKiDgCiDgHiCmJiCmIiCmBiCmEiCkCiCoJiBeC_xHqqkZx_
 *			_xZkqqHx_jBkGiClPiBeBiDeBiBfLiDeKiDeDiDhFiCmMjDmHiCnNiNjOiCnNiImKjChFiCkKiClPiCoFiCkEiCmH_xHqqkZx_OLE_xZkqqHx_iDeJiDhFiDfHiDeGiDeOiDgHiCmM_xHqqkZx_
 *			_xZkqqHx_iImKjChFiCmJiCmIiCmBiClNiCmGiCkLiBeBjDmHiCnNiNjOiCnNjAoGiCmNiDeBiBfLiDeKiDeDiDhFiCmFiCmNiCmIiCkN_xHqqkZx_
 *			_xZkqqHx_iDiLiBfLiDgHiDfIiDgHiDiMiBfLiDfHiCmJiCmIiCmBiCmEiClFiCnMiCkEiBeC_xHqqkZx_
 *			_xZkqqHx_iClBiCmMiClNiCnPiBeBiDeBiBfLiDeKiDeDiDhFiCmGiDfKiDgCiDgHiCmJiCmIiCmBiClNiDiLiBfLiDgHiDfIiDgHiDiMiBfLiDfHiCpA_xHqqkZx_
 *			_xZkqqHx_iClBiCmMiDgIiDeMiDiFiDiBiDjDiDgHiCmJjDgOiClFiCmEiCoCiCoJjFeLjHhGiCkKiCkAiCoJiBeC_xHqqkZx_
 *			_xZkqqHx_iDhEiDiJiDgCiDgHiDhEiDeAiDeDiDiLiCmMiPoKiNiHiCmNiBeBiClBiCmMjFeLjHhGiCmNiCmIiCkCiBeC_xHqqkZx_
 *			_xZkqqHx_iClNiClOiClFiBeBiDhEiDiJiDgCiDgHiDhEiDeAiDeDiDiLiCmFiCkAiCmBiCmEiCoAiBeBjDmHiCnNiNjOiCnNiOjOiCmJ_xHqqkZx_
 *			OLE_xZkqqHx_iDeJiDhFiDfHiDeGiDeOiDgHiCkKjBlGiNnNiClHiCoJiPoKiNiHiBeBiImIiJlKiCmMiImKjChFiCmF_xHqqkZx_
 *			_xZkqqHx_iDiLiBfLiDgHiDfIiDgHiDiMiBfLiDfHiCmJ_xHqqkZx_OLE_xZkqqHx_iDeJiDhFiDfHiDeGiDeOiDgHiCpAiNoMjAkMiClFiCmJ_xHqqkZx_
 *			_xZkqqHx_iNhDiCmBiCmEiClFiCnMiCkEiBeC_xHqqkZx_
 *			_xZkqqHx_iClBiCmMiClNiCnPiBeBiDiLiBfLiDgHiDfIiDgHiDiMiBfLiDfHiCpA_xHqqkZx_(-1)_xZkqqHx_iCmFjChFiCkLiKlHiCkGiCoJiClBiCmGiCmN_xHqqkZx_
 *			_xZkqqHx_iClFiCmIiCkCiBeC_xHqqkZx_
 *			OLE_xZkqqHx_iDeJiDhFiDfHiDeGiDeOiDgHiCpAiDhEiDiJiDgCiDgHiDhEiDeAiDeDiDiLiCnGiPjBiCkLiPgPiClHiPoKiNiHiCmN_xHqqkZx_
 *			_xZkqqHx_iDiLiBfLiDgHiDfIiDgHiDiMiBfLiDfHiCpAjEePiCmMiClNiCnPiCmJ_xHqqkZx_(-1)_xZkqqHx_iCmJjChFiCkLiKlHiCkGiCmEiBeB_xHqqkZx_
 *			_xZkqqHx_iJlNiCoAiPiIjHjNiCkKiCmIiCkCiCoGiCkEiCmJiClFiCmEiCkIiCkNiBeC_xHqqkZx_
 *			
 *			void COleClientItem::ReadItemCompound(CArchive& ar)
 *			{
 *				:
 *				:
 *				GetItemStorageCompound();
 *				~~~~~~~~~~~~~~~~~~~~~~~~~_xZkqqHx_iClBiCmMiKnGjAjEjCiG_xHqqkZx_
 *
 *			void COleClientItem::GetItemStorageCompound()
 *			{
 *				:
 *				:
 *				SCODE sc = pDoc->m_lpRootStg->CreateStorage(T2COLE(szItemName),
 *					STGM_CREATE|STGM_READWRITE|STGM_TRANSACTED|STGM_SHARE_EXCLUSIVE,
 *					0, 0, &lpStorage);
 *				~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~_xZkqqHx_iClBiClB_xHqqkZx_
 *
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	03.06.05 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
LPSTORAGE MC3Document::SetRootStorage (LPSTORAGE pStorage)
{
	LPSTORAGE pStorageOld = m_lpRootStg;
	m_lpRootStg = pStorage;
	return pStorageOld;
} // MC3Document::SetRootStorage.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	MC3Document::SetFileType
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iPgPjHmNiClHiCoJiDhEiDeAiDeDiDiLiMfOiCpAjAnNjCoIiClHiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	df	:_xZkqqHx_iDhEiDeAiDeDiDiLiMfOiCpAiOhHjCoIiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	05.06.13 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
void MC3Document::SetFileType (FTDocumentFormat df)
{
	m_headerInf->SetFileType(df);
} // MC3Document::SetFileType.

void MC3Document::InStreamCore (CArchive& ar, BOOL bIsFcore)
{
	// _xZkqqHx_iDhHiDgCiDfPiPoOjFpBiCmMjDmHiCnNiNjOiCnNiBeC_xHqqkZx_
	m_headerInf->InStream(ar);
//----- 06.04.01 Fukushiro M. _xZkqqHx_jCmHiJmBiOgO_xHqqkZx_ ()-----
	// _xZkqqHx_iDhHiDgCiDfPjDmHiCnNiNjOiCnNiCmMiCnNiCmIiCoHjFjMiLeBiBeC_xHqqkZx_
	if (m_bHeaderLoadOnly) return;
//----- 06.04.01 Fukushiro M. _xZkqqHx_jCmHiJmBiPeJ_xHqqkZx_ ()-----
	if (bIsFcore)
	//----- _xZkqqHx_iDhEiDiJiDgCiDgHiDfCiDeBiCmMiPoKiNiH_xHqqkZx_ -----
	{
		// _xZkqqHx_jFlGiPjBiDhGiDiNiDhAiDgFiDeCiDfEiDeDiDfJiCpAjDmHiCnNiNjOiCnOiBeC_xHqqkZx_
		long lDocPropertySize;
		ar >> lDocPropertySize;
		ASSERT(lDocPropertySize == 0);
	}
	// _xZkqqHx_iDhGiDiKiDjDiDfOiPoOjFpBjDjJiCpAjDmHiCnNiNjOiCnOiBeC_xHqqkZx_
	m_app->InStream(ar);
	// _xZkqqHx_iKmCiLkLiPoOjFpBiCpAjDmHiCnNiNjOiCnOiBeC_xHqqkZx_
	m_env->InStream(ar);
	// _xZkqqHx_iDgDiBfLiDiLjAnNjCoIiPoOjFpBiCpAjDmHiCnNiNjOiCnOiBeC_xHqqkZx_
	m_toolManager->InStream(ar);
	// _xZkqqHx_iDfGiBfLiDgHiBeBjFjEjFgJiPoOjFpBiCpAjDmHiCnNiNjOiCnOiBeC_xHqqkZx_
	m_sheetManager->InStream(ar);
	// _xZkqqHx_iDiKiDjDiDeOiPoOjFpBiCpAjDpMjHmNiClHiCoJiBeC_xHqqkZx_
	m_linkManager->InStream(ar);
	// _xZkqqHx_iDiMiDfHiDfIiDgHiDiKiPoOjFpBiCpAjDpMjHmNiClHiCoJiBeC_xHqqkZx_
	m_reg->InStream(ar);
	// _xZkqqHx_iDeMiDiDiDjDiDgPiDfIiPoOjFpBiCpAjDmHiCnNiNjOiCnOiBeC_xHqqkZx_
	m_canvasStat->InStream(ar);
} // MC3Document::InStreamCore.

void MC3Document::OutStreamCore (CArchive& ar, BOOL bIsFcore)
{
	// _xZkqqHx_iDhHiDgCiDfPiPoOjFpBiCmMiPjBiCkLiPgPiClFiBeC_xHqqkZx_
	m_headerInf->OutStream(ar);
	if (bIsFcore)
	//----- _xZkqqHx_iDhEiDiJiDgCiDgHiDfCiDeBiCmMiPoKiNiH_xHqqkZx_ -----
	{
		// _xZkqqHx_jFlGiPjBiDhGiDiNiDhAiDgFiDeCiDfEiDeDiDfJiCpAiPjBiCkLiNjOiCnOiBeC_xHqqkZx_
		long lDocPropertySize = 0;
		ar << lDocPropertySize;
	}
	// _xZkqqHx_iDhGiDiKiDjDiDfOiPoOjFpBjDjJiCpAiPjBiCkLiPgPiClHiBeC_xHqqkZx_
	m_app->OutStream(ar);
	// _xZkqqHx_iKmCiLkLiPoOjFpBiCpAiPjBiCkLiPgPiClHiBeC_xHqqkZx_
	m_env->OutStream(ar);
	// _xZkqqHx_iDgDiBfLiDiLjAnNjCoIiPoOjFpBiCpAiPjBiCkLiPgPiClHiBeC_xHqqkZx_
	m_toolManager->OutStream(ar);
	// _xZkqqHx_iDfGiBfLiDgHiBeBjFjEjFgJiPoOjFpBiCpAiPgPjHmNiBeC_xHqqkZx_
	m_sheetManager->OutStream(ar);
	// _xZkqqHx_iDiKiDjDiDeOiPoOjFpBiCpAiPgPjHmNiClHiCoJiBeC_xHqqkZx_
	m_linkManager->OutStream(ar);
	// _xZkqqHx_iDiMiDfHiDfIiDgHiDiKiPoOjFpBiCpAiPgPjHmNiClHiCoJiBeC_xHqqkZx_
	m_reg->OutStream(ar);
	// _xZkqqHx_iDeMiDiDiDjDiDgPiDfIiCmMjFfMiOkGiPpDjBnEiCpAiDfIiDgHiDiKiBfLiDiAiCmJiPgPjHmNiClHiCoJiBeC_xHqqkZx_
	m_canvasStat->OutStream(ar);
} // MC3Document::OutStreamCore.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	MC3Document::LoadTemplate
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDgFiDjDiDhGiDiMiBfLiDgHiDhEiDeAiDeDiDiLiCpAjDmHiCnNiNjOiCnOiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	wcpFilePath	:_xZkqqHx_iDhEiDeAiDeDiDiLiDhAiDfIjGlMiCpAiOhHjCoIiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jFnEjCgM_xHqqkZx_>	_xZkqqHx_jAkMiMpHiClFiClNiPoKiNiHiCmN_xHqqkZx_TRUE_xZkqqHx_iBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	05.06.03 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
BOOL MC3Document::LoadTemplate (const wchar_t* wcpFilePath)
{
//----- 06.05.11 Fukushiro M. _xZkqqHx_jFmPiNfIjBeP_xHqqkZx_ ()-----
//	// _xZkqqHx_jFjEjFgJjBkOjAkLiDfIiDgHiDiKiBfLiDiAiCpAiOoGjDlOiBeC_xHqqkZx_
//	CArchive* ar = FFClassCreate((CArchive*)NULL);
//	ar->Initialize(wcpFilePath, FD_ARCHIVE_LOAD, this, TRUE);
//	// _xZkqqHx_iDgFiDjDiDhGiDiMiBfLiDgHiCmMiDhHiDgCiDfPiPoOjFpBiBeC_xHqqkZx_
//	m_headerInf->InStream(*ar);
//	// _xZkqqHx_iKmCiLkLjFnLjBlGjFmPjAjEiCpAjDmHiCnNiNjOiCnNiBeC_xHqqkZx_
//	m_env->InStream(*ar);
//	// _xZkqqHx_iDgDiBfLiDiLjAnNjCoIiPoOjFpBiCpAjDmHiCnNiNjOiCnOiBeC_xHqqkZx_
//	m_toolManager->InStream(*ar);
//	// _xZkqqHx_iDfGiBfLiDgHiBeBjFjEjFgJiPoOjFpBiCpAiPgPjHmNiBeC_xHqqkZx_
//	m_sheetManager->InStream(*ar);
//	// _xZkqqHx_iDiMiDfHiDfIiDgHiDiKiPoOjFpBiCpAjDpMjHmNiClHiCoJiBeC_xHqqkZx_
//	m_reg->InStream(*ar);
//	// _xZkqqHx_iDeBiBfLiDeKiDeDiDhFiCpAiNoNiPjMiBeC_xHqqkZx_
//	FFClassDelete(ar);
//----- 06.05.11 Fukushiro M. _xZkqqHx_jFmPiNfIiMoD_xHqqkZx_ ()-----
	// _xZkqqHx_iDeBiBfLiDeKiDeDiDhFiCpAiNoMjAkMiBeC_xHqqkZx_
	CFile file(WStrToTStr(wcpFilePath), CFile::modeRead | CFile::shareDenyNone);
	CArchive ar(&file, CArchive::load);
	ar.m_pDocument = this;
	// _xZkqqHx_iDgFiDjDiDhGiDiMiBfLiDgHiCmMiDhHiDgCiDfPiPoOjFpBiBeC_xHqqkZx_
	m_headerInf->InStream(ar);
	// _xZkqqHx_iKmCiLkLjFnLjBlGjFmPjAjEiCpAjDmHiCnNiNjOiCnNiBeC_xHqqkZx_
	m_env->InStream(ar);
	// _xZkqqHx_iDgDiBfLiDiLjAnNjCoIiPoOjFpBiCpAjDmHiCnNiNjOiCnOiBeC_xHqqkZx_
	m_toolManager->InStream(ar);
	// _xZkqqHx_iDfGiBfLiDgHiBeBjFjEjFgJiPoOjFpBiCpAiPgPjHmNiBeC_xHqqkZx_
	m_sheetManager->InStream(ar);
	// _xZkqqHx_iDiMiDfHiDfIiDgHiDiKiPoOjFpBiCpAjDpMjHmNiClHiCoJiBeC_xHqqkZx_
	m_reg->InStream(ar);
//----- 06.05.11 Fukushiro M. _xZkqqHx_jFmPiNfIiPeJ_xHqqkZx_ ()-----
	return TRUE;
} // MC3Document::LoadTemplate.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	MC3Document::SaveTemplate
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDgFiDjDiDhGiDiMiBfLiDgHiDhEiDeAiDeDiDiLiCpAiPjBiCkLiNjOiCnOiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	wcpFilePath	:_xZkqqHx_iDhEiDeAiDeDiDiLiDhAiDfIjGlMiCpAiOhHjCoIiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jFnEjCgM_xHqqkZx_>	_xZkqqHx_jAkMiMpHiClFiClNiPoKiNiHiCmN_xHqqkZx_TRUE_xZkqqHx_iBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	05.06.12 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
BOOL MC3Document::SaveTemplate (const wchar_t* wcpFilePath)
{
//----- 06.05.11 Fukushiro M. _xZkqqHx_jFmPiNfIjBeP_xHqqkZx_ ()-----
//	// _xZkqqHx_jFjEjFgJjBkOjAkLiDfIiDgHiDiKiBfLiDiAiCpAiOoGjDlOiBeC_xHqqkZx_
//	CArchive* ar = FFClassCreate((CArchive*)NULL);
//	ar->Initialize(wcpFilePath, FD_ARCHIVE_STORE, this, TRUE);
//	// _xZkqqHx_iDhHiDgCiDfPiPoOjFpBiCmMiPjBiCkLiPgPiClFiBeC_xHqqkZx_
//	m_headerInf->OutStream(*ar);
//	// _xZkqqHx_iKmCiLkLiPoOjFpBiCpAiPjBiCkLiPgPiClHiBeC_xHqqkZx_
//	m_env->OutStream(*ar);
//	// _xZkqqHx_iDgDiBfLiDiLjAnNjCoIiPoOjFpBiCpAiPjBiCkLiPgPiClHiBeC_xHqqkZx_
//	m_toolManager->OutStream(*ar);
//	// _xZkqqHx_iDfGiBfLiDgHiBeBjFjEjFgJiPoOjFpBiCpAiPgPjHmNiBeC_xHqqkZx_
//	m_sheetManager->OutStream(*ar);
//	// _xZkqqHx_iDiMiDfHiDfIiDgHiDiKiPoOjFpBiCpAiPgPjHmNiClHiCoJiBeC_xHqqkZx_
//	m_reg->OutStream(*ar);
//	// _xZkqqHx_iDeBiBfLiDeKiDeDiDhFiCpAiNoNiPjMiBeC_xHqqkZx_
//	FFClassDelete(ar);
//----- 06.05.11 Fukushiro M. _xZkqqHx_jFmPiNfIiMoD_xHqqkZx_ ()-----
	// _xZkqqHx_iDeBiBfLiDeKiDeDiDhFiCpAiNoMjAkMiBeC_xHqqkZx_
	CFile file(WStrToTStr(wcpFilePath), CFile::modeReadWrite | CFile::shareDenyWrite);
	CArchive ar(&file, CArchive::store);
	ar.m_pDocument = this;
	// _xZkqqHx_iDhHiDgCiDfPiPoOjFpBiCmMiPjBiCkLiPgPiClFiBeC_xHqqkZx_
	m_headerInf->OutStream(ar);
	// _xZkqqHx_iKmCiLkLiPoOjFpBiCpAiPjBiCkLiPgPiClHiBeC_xHqqkZx_
	m_env->OutStream(ar);
	// _xZkqqHx_iDgDiBfLiDiLjAnNjCoIiPoOjFpBiCpAiPjBiCkLiPgPiClHiBeC_xHqqkZx_
	m_toolManager->OutStream(ar);
	// _xZkqqHx_iDfGiBfLiDgHiBeBjFjEjFgJiPoOjFpBiCpAiPgPjHmNiBeC_xHqqkZx_
	m_sheetManager->OutStream(ar);
	// _xZkqqHx_iDiMiDfHiDfIiDgHiDiKiPoOjFpBiCpAiPgPjHmNiClHiCoJiBeC_xHqqkZx_
	m_reg->OutStream(ar);
//----- 06.05.11 Fukushiro M. _xZkqqHx_jFmPiNfIiPeJ_xHqqkZx_ ()-----
	return TRUE;
} // MC3Document::SaveTemplate.

void MC3Document::SetHeaderLoadOnly (BOOL bHeaderLoadOnly)
{
	// _xZkqqHx_iDhHiDgCiDfPjDmHiCnNiNjOiCnNiCmMiCnNiBeC_xHqqkZx_
	m_bHeaderLoadOnly = bHeaderLoadOnly;
} // MC3Document::SetHeaderLoadOnly.

const MC3HeaderInf* MC3Document::GetHeaderInfo () const
{
	return m_headerInf;
} // MC3Document::GetHeaderInfo.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	MC3Document::RegisterObject
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_jAfGiClFiCkNjAlGjAkMiClDiCoKiClNjFjEjFgJiCpAiOhHjCoIiClFiClN_xHqqkZx_ID_xZkqqHx_iCmFjDgPjIfOiClHiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	pObj	: _xZkqqHx_jDgPjIfOiClHiCoJjFjEjFgJ_xHqqkZx_
 *			dwID	: _xZkqqHx_jDgPjIfOiClHiCoJjFjEjFgJiCmM_xHqqkZx_ID
 *
 * <_xZkqqHx_jCiNiInD_xHqqkZx_>	ID_xZkqqHx_iCmMiPgEjFkBiCpAiDgAiDeGiDgCiDeOiClFiCmIiCkCiCmMiCmFiBeB_xHqqkZx_m_obppObjID2P_xZkqqHx_iCkKiClHiCnHiCmEiLpDiCmMiOjOiBeB_xHqqkZx_
 *			_xZkqqHx_iClHiCmIiCoNiClP_xHqqkZx_m_dwObjID2PNext = 0_xZkqqHx_iCmMiOjOiCmMiCnNiOgHjHhAiCmFiCkLiCoJiBeCjAfGiLeLiCmJiDhEiDeAiDeDiDiL_xHqqkZx_
 *			_xZkqqHx_iCpAiDiNiBfLiDgIiClHiCoJiOjOiCmMiCnNiCmGiNgMiCkGiCmEiCoGiCkCiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	98.11.14 Fukushiro M. _xZkqqHx_iDgFiBfLiDhFiDiLiCkK_xHqqkZx_NULL_xZkqqHx_iCmMiPiIjHjNiCpAjCmHiJmB_xHqqkZx_.ChipTbl::InStream_xZkqqHx_iCmMiInH_xHqqkZx_.
 *************************************************************************/
void MC3Document::RegisterObject (MC3ObjBase* pObj, DWORD dwID)
{
	ASSERT(m_mpIdToObj.find(dwID) == m_mpIdToObj.end());
	m_mpIdToObj[dwID] = pObj;
} // MC3Document::RegisterObject.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	MC3Document::UnregisterObject
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_jFjEjFgJiCpA_xHqqkZx_ID_xZkqqHx_jDgPjIfOiCkJiCoHiCmNiClIiClHiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	pObj	: _xZkqqHx_jFjEjFgJ_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	98.11.14 Fukushiro M. _xZkqqHx_iDgFiBfLiDhFiDiLiCkK_xHqqkZx_NULL_xZkqqHx_iCmMiPiIjHjNiCpAjCmHiJmB_xHqqkZx_.ChipTbl::InStream_xZkqqHx_iCmMiInH_xHqqkZx_.
 *************************************************************************/
void MC3Document::UnregisterObject (MC3ObjBase* pObj)
{
	// _xZkqqHx_jFjEjFgJ_xHqqkZx_ID_xZkqqHx_iDgFiBfLiDhFiDiLiCkJiCoHjFjEjFgJiCpAiPjMiCkNiBeC_xHqqkZx_
	ASSERT(m_mpIdToObj.find(pObj->GetObjID()) != m_mpIdToObj.end());
	m_mpIdToObj.erase(pObj->GetObjID());
} // MC3Document::UnregisterObject.

/////////////////////////////////////////////////////////////////////////////
// MC3Document


MC3Document::MC3Document ()
{
	// OLE _xZkqqHx_jFkBiNiHiDhEiDeAiDeDiDiLiCpAiOgHjHhAiClFiCnMiClHiBeC_xHqqkZx_
	EnableCompoundFile();
	// _xZkqqHx_iDhHiDgCiDfPjDmHiCnNiNjOiCnNiCmMiCnNiBeC_xHqqkZx_
	m_bHeaderLoadOnly = FALSE;
	// _xZkqqHx_iDhHiDgCiDfPiPoOjFpBiBeC_xHqqkZx_
	m_headerInf = new MC3HeaderInf;
	// _xZkqqHx_iDhGiDiKiDjDiDfOiPoOjFpBjDjJiBeC_xHqqkZx_
	m_app = new MC3App;
	// _xZkqqHx_iKmCiLkLiPoOjFpBiBeC_xHqqkZx_
	m_env = new MC3Env;
	// _xZkqqHx_iDgDiBfLiDiLjAnNjCoIiPoOjFpBiBeC_xHqqkZx_
	m_toolManager = new MC3ToolManager;
	// _xZkqqHx_iDfGiBfLiDgHiBeBjFjEjFgJiPoOjFpBiBeC_xHqqkZx_
	m_sheetManager = new MC3SheetManager;
	// _xZkqqHx_iDiKiDjDiDeOiPoOjFpBiBeC_xHqqkZx_
	m_linkManager = new MC3LinkManager;
	// _xZkqqHx_iDiMiDfHiDfIiDgHiDiKiPoOjFpBiBeC_xHqqkZx_
	m_reg = new MC3Reg;
	// _xZkqqHx_iDeMiDiDiDjDiDgPiDfIiPoOjFpBiBeC_xHqqkZx_
	m_canvasStat = new MC3CanvasStat;

//----- 05.06.01 Fukushiro M. _xZkqqHx_iNoNiPjMiOgO_xHqqkZx_ ()-----
//	// _xZkqqHx_iDgDiBfLiDiLiDhNiDgMiBfLiDfHiDiDiPiJiKpKiJlLiBeC_xHqqkZx_
//	m_toolManager->Initialize(this);
//----- 05.06.01 Fukushiro M. _xZkqqHx_iNoNiPjMiPeJ_xHqqkZx_ ()-----

} // MC3Document::MC3Document.

MC3Document::~MC3Document ()
{
	m_sheetManager->DeleteAll();

	// _xZkqqHx_iDeMiDiDiDjDiDgPiDfIiPoOjFpBiBeC_xHqqkZx_
	delete m_canvasStat;
	m_canvasStat = NULL;
	// _xZkqqHx_iDiMiDfHiDfIiDgHiDiKiPoOjFpBiBeC_xHqqkZx_
	delete m_reg;
	m_reg = NULL;
	// _xZkqqHx_iDiKiDjDiDeOiPoOjFpBiBeC_xHqqkZx_
	delete m_linkManager;
	m_linkManager = NULL;
	// _xZkqqHx_iDfGiBfLiDgHiBeBjFjEjFgJiPoOjFpBiBeC_xHqqkZx_
	delete m_sheetManager;
	m_sheetManager = NULL;
	// _xZkqqHx_iDgDiBfLiDiLjAnNjCoIiPoOjFpBiBeC_xHqqkZx_
	delete m_toolManager;
	m_toolManager = NULL;
	// _xZkqqHx_iKmCiLkLiPoOjFpBiBeC_xHqqkZx_
	delete m_env;
	m_env = NULL;
	// _xZkqqHx_iDhGiDiKiDjDiDfOiPoOjFpBjDjJiBeC_xHqqkZx_
	delete m_app;
	m_app = NULL;
	// _xZkqqHx_iDhHiDgCiDfPiPoOjFpBiBeC_xHqqkZx_
	delete m_headerInf;
	m_headerInf = NULL;
} // MC3Document::~MC3Document.

BOOL MC3Document::OnNewDocument ()
{
	if (!COleServerDoc::OnNewDocument())
		return FALSE;
	return TRUE;
} // MC3Document::OnNewDocument.

//----- 06.05.12 Fukushiro M. _xZkqqHx_iNoNiPjMiOgO_xHqqkZx_ ()-----
////----- 06.05.11 Fukushiro M. _xZkqqHx_jCmHiJmBiOgO_xHqqkZx_ ()-----
//// _xZkqqHx_iDgFiDfIiDgHiBeC_xHqqkZx_
//BOOL MC3Document::OnOpenDocument (LPCTSTR lpszPathName)
//{
//	ASSERT_VALID(this);
//
//	// always register the document before opening it
//	Revoke();
//	if (!RegisterIfServerAttached(lpszPathName, FALSE))
//	{
//		// always output a trace (it is just an FYI -- not generally fatal)
//		TRACE(traceOle, 0, _T("Warning: Unable to register moniker '%s' as running\n"), lpszPathName);
//	}
//
//	if (!COleDocument::OnOpenDocument(lpszPathName))
//	{
//		Revoke();
//		return FALSE;
//	}
//
//	// if the app was started only to print, don't set user control
//
////----- 06.05.11 Fukushiro M. _xZkqqHx_iNoNiPjMiOgO_xHqqkZx_ ()-----
////	CWinApp* pApp = AfxGetApp();
////	ASSERT(pApp != NULL);
////	if (pApp->m_pCmdInfo == NULL ||
////		(pApp->m_pCmdInfo->m_nShellCommand != CCommandLineInfo::FileDDE &&
////		 pApp->m_pCmdInfo->m_nShellCommand != CCommandLineInfo::FilePrint))
////	{
////		AfxOleSetUserCtrl(TRUE);
////	}
////----- 06.05.11 Fukushiro M. _xZkqqHx_iNoNiPjMiPeJ_xHqqkZx_ ()-----
//
//	return TRUE;
//}
////----- 06.05.11 Fukushiro M. _xZkqqHx_jCmHiJmBiPeJ_xHqqkZx_ ()-----
//----- 06.05.12 Fukushiro M. _xZkqqHx_iNoNiPjMiPeJ_xHqqkZx_ ()-----

COleServerItem* MC3Document::OnGetEmbeddedItem()
{
	// OnGetEmbeddedItem _xZkqqHx_iCmNiBeBiDgIiDeMiDiFiDiBiDjDiDgHiCmJiKnGjIeBjFhEiCkPiCoHiCoKiClN_xHqqkZx_ COleServerItem _xZkqqHx_iCpA_xHqqkZx_
	// _xZkqqHx_iOoGjDlOiClHiCoJiClNiCnPiCmJiDhEiDiMiBfLiDiAiDiPiBfLiDeOiCkJiCoHjFeLjHhGiCmIiPoKiNiHiCmJiCmMiCnNiMmEiCnBiPgPiClDiCoKiCnMiClHiBeC_xHqqkZx_

	// NULL _xZkqqHx_iCpAjFnEiClHjBoDiCoNiCoIiCmJiBeBiClBiCmMiDgIiDeMiDiFiDiBiDjDiDgHiCmJjIeBiMiLiClDiCoKiClN_xHqqkZx_ COleServerItem _xZkqqHx_iCmM_xHqqkZx_
	// _xZkqqHx_jEgIjAlGiDeOiDiJiDfIiCnGiCmMiDhMiDeDiDjDiDfOiCpAjFnEiClHiCoGiCkEiCmJjFmPiNfIiClFiCmEiJlKiClDiCkCiBeCiClLiCmMiMoDiBeBiImIiJlKiCmM_xHqqkZx_
	// ASSERT(FALSE) _xZkqqHx_iNhDiCpAiNoNiPjMiClFiCmEiJlKiClDiCkCiBeC_xHqqkZx_
	//  (_xZkqqHx_jHoB_xHqqkZx_: return new CMyServerItem)
	ASSERT(FALSE);			// _xZkqqHx_iPiIjHjNiLeMiPhBiMoDiBeBiNoNiPjMiClFiCmEiCkNiClOiClDiCkCiBeC_xHqqkZx_
	return NULL;
}


BEGIN_MESSAGE_MAP(MC3Document, COleServerDoc)
	//{{AFX_MSG_MAP(MC3Document)
		// _xZkqqHx_iDiBiDiC_xHqqkZx_ - ClassWizard _xZkqqHx_iCmNiClBiCmMiImKjChFiCmJiDhNiDgCiDhDiDjDiDePjHhAiCmMiDhNiDeOiDiNiCpAjCmHiJmBiCnMiClNiCmNiNoNiPjMiClFiCnMiClHiBeC_xHqqkZx_
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// MC3Document _xZkqqHx_jAgGjCgG_xHqqkZx_

#ifdef _DEBUG
void MC3Document::AssertValid() const
{
	COleServerDoc::AssertValid();
}

void MC3Document::Dump(CDumpContext& dc) const
{
	COleServerDoc::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// MC3Document _xZkqqHx_iDfGiDiKiDeBiDiJiDeDiDfJ_xHqqkZx_

void MC3Document::Serialize (CArchive& ar)
{
//----- 06.05.11 Fukushiro M. _xZkqqHx_jFmPiNfIjBeP_xHqqkZx_ ()-----
//	// _xZkqqHx_jFjEjFgJjBkOjAkLiDfIiDgHiDiKiBfLiDiAiCpAiOoGjDlOiBeC_xHqqkZx_
//	CArchive* udar = FFClassCreate((CArchive*)NULL);
//	udar->Initialize(ar);
//	if (ar.IsStoring())
//	{
//		OutStreamCore(*udar, FALSE);
//	}
//	else
//	{
//		InStreamCore(*udar, FALSE);
//	}
//	// _xZkqqHx_iDeBiBfLiDeKiDeDiDhFiCpAiNoNiPjMiBeC_xHqqkZx_
//	FFClassDelete(udar);
//----- 06.05.11 Fukushiro M. _xZkqqHx_jFmPiNfIiMoD_xHqqkZx_ ()-----
	if (ar.IsStoring())
	{
		OutStreamCore(ar, FALSE);
	}
	else
	{
		InStreamCore(ar, FALSE);
	}
//----- 06.05.11 Fukushiro M. _xZkqqHx_jFmPiNfIiPeJ_xHqqkZx_ ()-----
} // MC3Document::Serialize.

/////////////////////////////////////////////////////////////////////////////
// MC3Document _xZkqqHx_iDfCiDhNiDjDiDgI_xHqqkZx_
