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.

137 lines
4.3 KiB

  1. class CMSInfoFile;
  2. //=============================================================================
  3. // CMSInfoPrintHelper is used to manage pagination and GDI resources used in printing
  4. //=============================================================================
  5. class CMSInfoPrintHelper
  6. {
  7. public:
  8. void PrintHeader();
  9. HDC m_hDC;
  10. int m_nEndPage;
  11. int m_nStartPage;
  12. HDC GetHDC(){return m_hDC;};
  13. CMSInfoPrintHelper(HDC hDC,int nStartPage, int nEndPage);
  14. void PrintLine(CString strLine);
  15. ~CMSInfoPrintHelper();
  16. protected:
  17. BOOL IsInPageRange(int nPageNumber);
  18. void Paginate();
  19. int GetVerticalPos(int nLineIndex,CSize csLinecaps);
  20. int GetHeaderMargin();
  21. int GetFooterMargin();
  22. //Used to manage the positioning of text on the printer Device Context
  23. CDC* m_pPrintDC;
  24. int m_nCurrentLineIndex;
  25. CFont* m_pOldFont;
  26. CFont* m_pCurrentFont;
  27. int m_nPageNumber;
  28. BOOL m_bNeedsEndPage;
  29. };
  30. //=============================================================================
  31. // CMSInfo5Category is used to load MSInfo 5 and 6 NFO files
  32. //=============================================================================
  33. class CMSInfo5Category : public CMSInfoCategory
  34. {
  35. public:
  36. enum NodeType { FIRST = 0x6000, CHILD = 0x8000, NEXT = 0x4000, END = 0x2000, PARENT = 0x1000,
  37. MASK = 0xf000 };
  38. CMSInfo5Category();
  39. virtual ~CMSInfo5Category();
  40. DataSourceType GetDataSourceType() { return NFO_500; };
  41. // Functions specific to the subclass:
  42. virtual BOOL LoadFromNFO(CMSInfoFile* pFile);
  43. static HRESULT ReadMSI5NFO(HANDLE hFile,CMSInfo5Category** ppRootCat, LPCTSTR szFilename = NULL);
  44. BOOL Refresh();
  45. protected:
  46. HANDLE GetFileFromCab(CString strFileName);
  47. void SetParent(CMSInfo5Category* pParent){m_pParent = pParent;};
  48. void SetNextSibling(CMSInfo5Category* pSib)
  49. {
  50. m_pNextSibling = pSib;
  51. };
  52. void SetPrevSibling(CMSInfo5Category* pPrev)
  53. {
  54. m_pPrevSibling = pPrev;
  55. };
  56. void SetFirstChild(CMSInfo5Category* pChild){m_pFirstChild = pChild;};
  57. };
  58. //=============================================================================
  59. // CMSInfo7Category is used to load MSInfo 7 NFO files
  60. //=============================================================================
  61. class CMSInfo7Category : public CMSInfoCategory
  62. {
  63. public:
  64. CMSInfo7Category();
  65. virtual ~CMSInfo7Category();
  66. DataSourceType GetDataSourceType() { return NFO_700; };
  67. void GetErrorText(CString * pstrTitle, CString * pstrMessage);
  68. // Functions specific to the subclass:
  69. static HRESULT ReadMSI7NFO(CMSInfo7Category** ppRootCat, LPCTSTR szFilename = NULL);
  70. virtual BOOL LoadFromXML(LPCTSTR szFilename);
  71. HRESULT WalkTree(IXMLDOMNode* node, BOOL bCreateCategory);
  72. // Adding this to fix the lack of sorting in opened NFO files. It's safer at this point to
  73. // not add anything to the NFO file (sorting information isn't saved). Instead, we'll
  74. // make the assumption that every column should sort. However, if the category has only
  75. // two columns, AND there is a blank line in the data followed by more data, it means that
  76. // sorting shouldn't be allowed (as for WinSock).
  77. BOOL GetColumnInfo(int iColumn, CString * pstrCaption, UINT * puiWidth, BOOL * pfSorts, BOOL * pfLexical)
  78. {
  79. BOOL fReturn = CMSInfoCategory::GetColumnInfo(iColumn, pstrCaption, puiWidth, pfSorts, pfLexical);
  80. if (fReturn)
  81. {
  82. if (pfLexical != NULL)
  83. *pfLexical = TRUE;
  84. if (pfSorts != NULL)
  85. {
  86. *pfSorts = TRUE;
  87. // If there are two columns, and a blank line with more data to follow, don't
  88. // allow the sorting.
  89. if (2 == m_iColCount)
  90. {
  91. CString * pstrData;
  92. for (int iRow = 0; iRow < m_iRowCount && *pfSorts; iRow++)
  93. if (GetData(iRow, 0, &pstrData, NULL) && pstrData != NULL && pstrData->IsEmpty() && (iRow + 1 < m_iRowCount))
  94. *pfSorts = FALSE;
  95. }
  96. }
  97. }
  98. return fReturn;
  99. }
  100. protected:
  101. void SetParent(CMSInfo7Category* pParent){m_pParent = pParent;};
  102. void SetNextSibling(CMSInfo7Category* pSib)
  103. {
  104. m_pNextSibling = pSib;
  105. };
  106. void SetPrevSibling(CMSInfo7Category* pPrev)
  107. {
  108. m_pPrevSibling = pPrev;
  109. };
  110. void SetFirstChild(CMSInfo7Category* pChild){m_pFirstChild = pChild;};
  111. };