// 23.cpp : DLL _xZkqqHx_jHhAiCmMiPiJiKpKiJlLiPiIjHjNiCmMjCoIiLgAiCpAiNhDiCkCiCnMiClHiBeC_xHqqkZx_
//

#include "stdafx.h"
#include "resource.h"	// For IDR_MAINFRAME.
#include "2Document.h"	// For MC2Document.
#include "2.h"			// This header.

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

//----- 06.05.12 Fukushiro M. _xZkqqHx_iNoNiPjMiOgO_xHqqkZx_ ()-----
//class FC2File : public CFile
//{
//public:
//	FC2File (MfcFile* pFile = NULL) : m_pMfcFile(pFile) {}
//	virtual ULONGLONG GetPosition() const { return m_pMfcFile->GetPosition(); }
//	virtual CString GetFileName() const { return (LPCTSTR)m_pMfcFile->GetFileName(); }
//	virtual CString GetFileTitle() const { return (LPCTSTR)m_pMfcFile->GetFileTitle(); }
//	virtual CString GetFilePath() const { return (LPCTSTR)m_pMfcFile->GetFilePath(); }
//	virtual void SetFilePath(LPCTSTR lpszNewName) { m_pMfcFile->SetFilePath(lpszNewName); }
//
//// Operations
//	virtual BOOL Open(LPCTSTR lpszFileName, UINT nOpenFlags, CFileException* pError = NULL)
//				{ return m_pMfcFile->Open(lpszFileName, nOpenFlags, NULL); }
//
////	virtual CFile* Duplicate() const { return m_pMfcFile->Duplicate(); }
//
//	virtual ULONGLONG Seek(LONGLONG lOff, UINT nFrom) { return m_pMfcFile->Seek((LONG)lOff, nFrom); }
//	virtual void SetLength(ULONGLONG dwNewLen) { m_pMfcFile->SetLength((DWORD)dwNewLen); }
//	virtual ULONGLONG GetLength() const { return m_pMfcFile->GetLength(); }
//
//	virtual UINT Read(void* lpBuf, UINT nCount) { return m_pMfcFile->Read(lpBuf, nCount); }
//	virtual void Write(const void* lpBuf, UINT nCount) { m_pMfcFile->Write(lpBuf, nCount); }
//
//	virtual void LockRange(ULONGLONG dwPos, ULONGLONG dwCount) { m_pMfcFile->LockRange((DWORD)dwPos, (DWORD)dwCount); }
//	virtual void UnlockRange(ULONGLONG dwPos, ULONGLONG dwCount) { m_pMfcFile->UnlockRange((DWORD)dwPos, (DWORD)dwCount); }
//
//	virtual void Abort() { m_pMfcFile->Abort(); }
//	virtual void Flush() { m_pMfcFile->Flush(); }
//	virtual void Close() { m_pMfcFile->Close(); }
//
//// Implementation
//public:
//	virtual ~FC2File() {}
//	virtual UINT GetBufferPtr(UINT nCommand, UINT nCount = 0, void** ppBufStart = NULL, void** ppBufMax = NULL)
//		{ return m_pMfcFile->GetBufferPtr(nCommand, nCount, ppBufStart, ppBufMax); }
//
//protected:
//	MfcFile*	m_pMfcFile;
//};
//----- 06.05.12 Fukushiro M. _xZkqqHx_iNoNiPjMiPeJ_xHqqkZx_ ()-----

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	Convert2To3
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDhEiDiJiDgCiDgHiDfCiDeBiCfB_xHqqkZx_ -> _xZkqqHx_iDhEiDiJiDgCiDgHiDfCiDeBiCfC_xHqqkZx_ _xZkqqHx_iCmMjFmPiKlHiCpAiNhDiCkEiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	fileFrom	:_xZkqqHx_jDmHiCnNiPgPiClFiMlDiCmMiDeBiBfLiDeKiDeDiDhFiCpAiOhHjCoIiBeC_xHqqkZx_
 *			fileTo		:_xZkqqHx_iPjBiCkLiNjOiCnNjAoGiCmMiDeBiBfLiDeKiDeDiDhFiCpAiOhHjCoIiBeC_xHqqkZx_
 *			formTo		:_xZkqqHx_iPjBiCkLiNjOiCnNiCmMiDhHiDgCiDfPiCmJiLeMiPhBiClDiCoKiCoJjFlGiPjBiMfOiCpAiOhHjCoIiBeC_xHqqkZx_FD_DTP_NONE _xZkqqHx_iCkK_xHqqkZx_
 *						 _xZkqqHx_iOhHjCoIiClDiCoKiClNiPoKiNiHiCmNjDmHiCnNiPgPiClFiMlDiCmMjFlGiPjBiMfOiCmJiPiHiClIiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	05.06.13 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
void Convert2To3 (MfcFile* fileFrom, MfcFile* fileTo, FTDocumentFormat formTo)
{
	// _xZkqqHx_jAfGiClFiCkCiDgIiDeMiDiFiDiBiDjDiDgHiCpAiNoMjAkMiBeC_xHqqkZx_
	g_pDoc = (MC2Document*)RUNTIME_CLASS(MC2Document)->CreateObject();
	CSingleDocTemplate docTemplate(	IDR_MAINFRAME,
									RUNTIME_CLASS(MC2Document),
									RUNTIME_CLASS(CFrameWnd),
									RUNTIME_CLASS(CView));
	docTemplate.AddDocument(g_pDoc);
	COleTemplateServer server;
	static const CLSID clsid = DYNAMIC_DRAW_CLSID;
	server.ConnectTemplate(clsid, &docTemplate, TRUE);
	// _xZkqqHx_iDgIiDeMiDiFiDiBiDjDiDgHiCpAiPiJiKpKiJlLiBeC_xHqqkZx_
	g_pDoc->OnNewDocument();

	CFCMfcFile fileFrom2(fileFrom);
	CArchive arFrom(&fileFrom2, CArchive::load);
	arFrom.m_pDocument = g_pDoc;

	// _xZkqqHx_iDfIiDgHiDiKiBfLiDiAiCpAjDmHiCnNiPgPiClHiBeC_xHqqkZx_
	g_pDoc->InStreamCore(arFrom);

	// _xZkqqHx_iDhEiDeAiDeDiDiLiMfOiCpAiOhHjCoIiBeC_xHqqkZx_
	if (formTo != FD_DTP_NONE) g_pDoc->SetFileType(formTo);

	CFCMfcFile fileTo2(fileTo);
	CArchive arTo(&fileTo2, CArchive::store);
	arTo.m_pDocument = g_pDoc;
	// _xZkqqHx_iDfIiDgHiDiKiBfLiDiAiCpAiPjBiCkLiNjOiCnOiBeC_xHqqkZx_
	g_pDoc->OutStreamCore(arTo);

	// _xZkqqHx_iNoMjAkMiClFiClNiDgIiDeMiDiFiDiBiDjDiDgHiCpAiNoNiPjMiBeC_xHqqkZx_
	delete g_pDoc;
	g_pDoc = NULL;
} // Convert2To3.

