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.

121 lines
2.9 KiB

  1. // ncbrowseDoc.cpp : implementation of the CNcbrowseDoc class
  2. //
  3. #include "stdafx.h"
  4. #include "ncbrowse.h"
  5. #include "ncbrowseDoc.h"
  6. #include "nceditview.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CNcbrowseDoc
  14. IMPLEMENT_DYNCREATE(CNcbrowseDoc, CDocument)
  15. BEGIN_MESSAGE_MAP(CNcbrowseDoc, CDocument)
  16. //{{AFX_MSG_MAP(CNcbrowseDoc)
  17. // NOTE - the ClassWizard will add and remove mapping macros here.
  18. // DO NOT EDIT what you see in these blocks of generated code!
  19. //}}AFX_MSG_MAP
  20. END_MESSAGE_MAP()
  21. /////////////////////////////////////////////////////////////////////////////
  22. // CNcbrowseDoc construction/destruction
  23. CNcbrowseDoc::CNcbrowseDoc()
  24. {
  25. // TODO: add one-time construction code here
  26. m_pNCSpewFile = NULL;
  27. }
  28. CNcbrowseDoc::~CNcbrowseDoc()
  29. {
  30. }
  31. CNCSpewFile &CNcbrowseDoc::GetSpewFile()
  32. {
  33. return *m_pNCSpewFile;
  34. }
  35. BOOL CNcbrowseDoc::OnNewDocument()
  36. {
  37. if (!CDocument::OnNewDocument())
  38. return FALSE;
  39. // TODO: add reinitialization code here
  40. // (SDI documents will reuse this document)
  41. return FALSE;
  42. }
  43. /////////////////////////////////////////////////////////////////////////////
  44. // CNcbrowseDoc serialization
  45. void CNcbrowseDoc::Serialize(CArchive& ar)
  46. {
  47. if (ar.IsStoring())
  48. {
  49. // TODO: add storing code here
  50. ASSERT(FALSE);
  51. }
  52. else
  53. {
  54. m_pNCSpewFile = new CNCSpewFile(ar);
  55. // TODO: add loading code here
  56. ar.GetFile()->SeekToBegin();
  57. POSITION p = m_viewList.GetHeadPosition();
  58. CView *pView;
  59. while (p)
  60. {
  61. pView = (CView*)m_viewList.GetNext(p);
  62. if (pView->IsKindOf(RUNTIME_CLASS(CEditView)))
  63. {
  64. if (ar.GetFile()->GetLength() <= CEditView::nMaxSize)
  65. {
  66. ((CNCEditView *)pView)->SerializeRaw(ar);
  67. }
  68. else
  69. {
  70. ((CNCEditView *)pView)->GetEditCtrl().Clear();
  71. ((CNCEditView *)pView)->GetEditCtrl().SetSel(-1);
  72. ((CNCEditView *)pView)->GetEditCtrl().ReplaceSel(_T("File is too large for this puny little MFC CEditView"));
  73. }
  74. }
  75. }
  76. }
  77. }
  78. /////////////////////////////////////////////////////////////////////////////
  79. // CNcbrowseDoc diagnostics
  80. #ifdef _DEBUG
  81. void CNcbrowseDoc::AssertValid() const
  82. {
  83. CDocument::AssertValid();
  84. }
  85. void CNcbrowseDoc::Dump(CDumpContext& dc) const
  86. {
  87. CDocument::Dump(dc);
  88. }
  89. #endif //_DEBUG
  90. /////////////////////////////////////////////////////////////////////////////
  91. // CNcbrowseDoc commands
  92. void CNcbrowseDoc::OnCloseDocument()
  93. {
  94. // TODO: Add your specialized code here and/or call the base class
  95. delete m_pNCSpewFile;
  96. CDocument::OnCloseDocument();
  97. }