www.pudn.com > xtable2.zip > XMLTableDoc.cpp
// XMLTableDoc.cpp : implementation of the CXMLTableDoc class
//
#include "stdafx.h"
#include "XMLTable.h"
#include "XMLTableDoc.h"
#include "XMLTableView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CXMLTableDoc
IMPLEMENT_DYNCREATE(CXMLTableDoc, CDocument)
BEGIN_MESSAGE_MAP(CXMLTableDoc, CDocument)
END_MESSAGE_MAP()
// CXMLTableDoc construction/destruction
CXMLTableDoc::CXMLTableDoc()
{
// TODO: add one-time construction code here
}
CXMLTableDoc::~CXMLTableDoc()
{
}
BOOL CXMLTableDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
/*
markup.SetDoc( _T("\r\n"
"\r\n"
"\r\n"
" \r\n"
" \r\n"
" \r\n"
" \r\n"
" \r\n"
" \r\n"
" \r\n"
" \r\n"
" \r\n"
" \r\n"
" \r\n"
"
\r\n"
" \r\n" ));
*/
return TRUE;
}
// CXMLTableDoc serialization
void CXMLTableDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}
}
// CXMLTableDoc diagnostics
#ifdef _DEBUG
void CXMLTableDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CXMLTableDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
// CXMLTableDoc commands
BOOL CXMLTableDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
markup.Load (lpszPathName);
SetModifiedFlag( FALSE );
return TRUE;
}
BOOL CXMLTableDoc::OnSaveDocument(LPCTSTR lpszPathName)
{
POSITION pos = GetFirstViewPosition();
CXMLTableView* pView = (CXMLTableView*)GetNextView(pos);
if ( pos )
pView = (CXMLTableView*)GetNextView(pos);
if (!pView)
return FALSE;
markup.SetDoc ("\r\n"); //清除原先数据
markup.AddElem("xml");
pView->m_table.ToXML (markup);
markup.Save(lpszPathName);
SetModifiedFlag (FALSE);
return TRUE;
}