Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
2.1 KiB

  1. // SimpDoc.cpp : implementation of the CSimpsonsDoc class
  2. //
  3. #include "stdafx.h"
  4. #include "simpsons.h"
  5. #include "SimpDoc.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CSimpsonsDoc
  13. IMPLEMENT_DYNCREATE(CSimpsonsDoc, CDocument)
  14. BEGIN_MESSAGE_MAP(CSimpsonsDoc, CDocument)
  15. //{{AFX_MSG_MAP(CSimpsonsDoc)
  16. // NOTE - the ClassWizard will add and remove mapping macros here.
  17. // DO NOT EDIT what you see in these blocks of generated code!
  18. //}}AFX_MSG_MAP
  19. END_MESSAGE_MAP()
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CSimpsonsDoc construction/destruction
  22. CSimpsonsDoc::CSimpsonsDoc()
  23. {
  24. m_bNoRenderFile = true;
  25. m_pCmds = NULL;
  26. m_bNeverRendered = true;
  27. }
  28. CSimpsonsDoc::~CSimpsonsDoc()
  29. {
  30. }
  31. #define szDEFFILENAME "Simpsons.ai"
  32. BOOL
  33. CSimpsonsDoc::OnNewDocument()
  34. {
  35. HRESULT hr;
  36. if (!CDocument::OnNewDocument())
  37. return FALSE;
  38. if (m_bNoRenderFile) {
  39. m_bNoRenderFile = false;
  40. if (FAILED(hr = ParseAIFile(szDEFFILENAME, &m_pCmds))) {
  41. strcpy(m_szFileName, "invalid file");
  42. return TRUE;
  43. }
  44. strcpy(m_szFileName, szDEFFILENAME);
  45. m_bNeverRendered = true;
  46. }
  47. return TRUE;
  48. }
  49. /////////////////////////////////////////////////////////////////////////////
  50. // CSimpsonsDoc serialization
  51. void
  52. CSimpsonsDoc::Serialize(CArchive& ar)
  53. {
  54. if (ar.IsStoring())
  55. {
  56. // TODO: add storing code here
  57. }
  58. else
  59. {
  60. HRESULT hr = S_OK;
  61. hr = ParseAIFile(ar.m_strFileName, &m_pCmds);
  62. strcpy(m_szFileName, ar.m_strFileName);
  63. m_bNoRenderFile = FAILED(hr);
  64. m_bNeverRendered = true;
  65. }
  66. }
  67. /////////////////////////////////////////////////////////////////////////////
  68. // CSimpsonsDoc diagnostics
  69. #ifdef _DEBUG
  70. void CSimpsonsDoc::AssertValid() const
  71. {
  72. CDocument::AssertValid();
  73. }
  74. void CSimpsonsDoc::Dump(CDumpContext& dc) const
  75. {
  76. CDocument::Dump(dc);
  77. }
  78. #endif //_DEBUG
  79. /////////////////////////////////////////////////////////////////////////////
  80. // CSimpsonsDoc commands