// mfclocauDoc.cpp : implementation of the CMfclocauDoc class
//

#include "stdafx.h"
#include "mfclocau.h"
#include "winnls.h"
#include "mfclocauDoc.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMfclocauDoc

IMPLEMENT_DYNCREATE(CMfclocauDoc, CDocument)

BEGIN_MESSAGE_MAP(CMfclocauDoc, CDocument)
	//{{AFX_MSG_MAP(CMfclocauDoc)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

BEGIN_DISPATCH_MAP(CMfclocauDoc, CDocument)
	//{{AFX_DISPATCH_MAP(CMfclocauDoc)
	DISP_FUNCTION(CMfclocauDoc, "Complain", Complain, VT_EMPTY, VTS_PBSTR VTS_PBSTR)
	//}}AFX_DISPATCH_MAP
END_DISPATCH_MAP()

// Note: we add support for IID_IMfcloc to support typesafe binding
//  from VBA.  This IID must match the GUID that is attached to the 
//  dispinterface in the .ODL file.

// {9C5242D2-B7F8-11CF-8A66-00AA00A58097}
static const IID IID_IMfcloc =
{ 0x9c5242d2, 0xb7f8, 0x11cf, { 0x8a, 0x66, 0x0, 0xaa, 0x0, 0xa5, 0x80, 0x97 } };

BEGIN_INTERFACE_MAP(CMfclocauDoc, CDocument)
	INTERFACE_PART(CMfclocauDoc, IID_IMfcloc, Dispatch)
END_INTERFACE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMfclocauDoc construction/destruction

CMfclocauDoc::CMfclocauDoc()
{
	// TODO: add one-time construction code here

	EnableAutomation();

	AfxOleLockApp();
}

CMfclocauDoc::~CMfclocauDoc()
{
	AfxOleUnlockApp();
}

BOOL CMfclocauDoc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;

	// TODO: add reinitialization code here
	// (SDI documents will reuse this document)

	return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CMfclocauDoc serialization

void CMfclocauDoc::Serialize(CArchive& ar)
{
	if (ar.IsStoring())
	{
		// TODO: add storing code here
	}
	else
	{
		// TODO: add loading code here
	}
}

/////////////////////////////////////////////////////////////////////////////
// CMfclocauDoc diagnostics

#ifdef _DEBUG
void CMfclocauDoc::AssertValid() const
{
	CDocument::AssertValid();
}

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

/////////////////////////////////////////////////////////////////////////////
// CMfclocauDoc commands

void Eliza (char *, char *) ;

void CMfclocauDoc::Complain(BSTR FAR* pIn, BSTR FAR* pOut) 
{
	if (*pIn != 0x00)
	{
		char in [256], out [256] ;
		WCHAR wOut [256] ;

		WideCharToMultiByte (CP_ACP, 0, *pIn, -1, in, sizeof(in), NULL, NULL) ;
		Eliza (in, out) ;
		MultiByteToWideChar (CP_ACP, 0, out, -1, wOut, 256) ;
		*pOut = SysAllocString (wOut) ;
	}
}
