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.

238 lines
7.7 KiB

  1. /******************************************************************************
  2. Header File: Model Data.H
  3. This defines a C++ class that manipulates (or at lest initially, understands)
  4. the GPC data file used in earlier versions of the Mini-Driver technology.
  5. Copyright (c) 1997 by Microsoft Corporation. All Rights Resreved.
  6. A Pretty Penny Enterprises Production
  7. Change History:
  8. 02-19-97 Bob_Kjelgaard@Prodgy.Net Created it
  9. ******************************************************************************/
  10. #if !defined(GPD_FILE_INFORMATION)
  11. #define GPD_FILE_INFORMATION
  12. class CStringTable ;
  13. class COldMiniDriverData { // comdd
  14. CWordArray m_cwaidModel; // Model names of the printers
  15. CWordArray m_cwaidCTT; // Default CTTs for each model
  16. CByteArray m_cbaImage; // Image of the GPC file
  17. CSafeObArray m_csoaFonts; // Font list per model as CWordArrays
  18. CUIntArray m_cuaSplitCodes;// Contains multiple GPC codes. See
  19. // SplitMultiGPCs() and SplitCodes.
  20. CStringArray m_csaSplitNames; // Correct model names for split GPC entries
  21. public:
  22. COldMiniDriverData() {}
  23. ~COldMiniDriverData() ;
  24. BOOL Load(CFile& cfImage);
  25. // Attributes
  26. unsigned ModelCount() { return (unsigned) m_cwaidModel.GetSize(); }
  27. WORD ModelName(unsigned u) const { return m_cwaidModel[u]; }
  28. WORD DefaultCTT(unsigned u) const { return m_cwaidCTT[u]; }
  29. CMapWordToDWord& FontMap(unsigned u) const;
  30. PCSTR Image() const { return (PCSTR) m_cbaImage.GetData(); }
  31. // The following codes are used to indicate if a GPC manages multiple
  32. // printer models so its "name" must split into individual model names
  33. // and its data copied into multiple GPCs.
  34. enum SplitCodes {
  35. NoSplit, // GPC represents one model so no splitting occurs
  36. FirstSplit, // First model of a multiple model GPC
  37. OtherSplit // One of the other models of a multiple model GPC
  38. } ;
  39. // Get, set or insert a model's split code
  40. SplitCodes GetSplitCode(unsigned u) {
  41. return ((SplitCodes) m_cuaSplitCodes[u]) ;
  42. }
  43. void SetSplitCode(unsigned u, SplitCodes sc) {
  44. m_cuaSplitCodes[u] = (unsigned) sc ;
  45. }
  46. void InsertSplitCode(unsigned u, SplitCodes sc) {
  47. m_cuaSplitCodes.InsertAt(u, (unsigned) sc) ;
  48. }
  49. // Get a split entry's correct model name
  50. CString& SplitModelName(unsigned u) { return m_csaSplitNames[u] ; }
  51. // Operations
  52. void NoteTranslation(unsigned uModel, unsigned uFont,
  53. unsigned uNewFont);
  54. bool SplitMultiGPCs(CStringTable& cstdriversstrings) ;
  55. };
  56. /******************************************************************************
  57. CModelData class
  58. This class handles the model data in GPD format.
  59. ******************************************************************************/
  60. class CModelData : public CProjectNode {
  61. CStringArray m_csaGPD, m_csaConvertLog; // GPD and error log
  62. // Private syntax checking support
  63. void SetLog();
  64. void EndLog();
  65. // Private view support
  66. CByteArray m_cbaBuffer; // Stream I/O buffer
  67. CString m_csBuffer; // Stream I/O buffer (partial lines)
  68. int m_iLine; // Currently GPD line number to load/store
  69. static DWORD CALLBACK FillViewer(DWORD_PTR dwCookie, LPBYTE lpBuff, LONG lcb,
  70. LONG *plcb);
  71. static DWORD CALLBACK FromViewer(DWORD_PTR dwCookie, LPBYTE lpBuff, LONG lcb,
  72. LONG *plcb);
  73. DWORD Fill(LPBYTE lpBuff, LONG lcb, LONG *plcb);
  74. DWORD UpdateFrom(LPBYTE lpBuff, LONG lcb, LONG *plcb);
  75. // Workspace completeness and tidiness checking related variables
  76. bool m_bTCUpdateNeeded ; // True iff IDs need to be updated
  77. int* m_pnUFMRCIDs ; // Ptr to UFM RC IDs in the GPD
  78. int m_nNumUFMsInGPD ; // Number if UFMs in the GPD
  79. int* m_pnStringRCIDs ; // Ptr to string RC IDs in the GPD
  80. int m_nNumStringsInGPD ;// Number if strings in the GPD
  81. PVOID m_pvRawData ; // Ptr to GPD Parser data
  82. DECLARE_SERIAL(CModelData)
  83. public:
  84. void SetKeywordValue(CString csfile, CString csKeyword, CString csValue,bool bSource = false);
  85. CString GetKeywordValue(CString csfile, CString csKeyword);
  86. CModelData();
  87. ~CModelData();
  88. // Attributes
  89. BOOL HasErrors() const { return !!m_csaConvertLog.GetSize(); }
  90. unsigned Errors() const {
  91. return (unsigned) m_csaConvertLog.GetSize();
  92. }
  93. const CString Error(unsigned u) const { return m_csaConvertLog[u]; }
  94. const int LineCount() const { return (int)m_csaGPD.GetSize(); }
  95. // Operations - Document support
  96. BOOL Load(PCSTR pcstr, CString csResource, unsigned uidModel,
  97. CMapWordToDWord& cmw2dFontMap, WORD wfGPDConvert);
  98. BOOL Load(CStdioFile& csiofGPD);
  99. BOOL Load();
  100. BOOL Store(LPCTSTR lpstrPath = NULL);
  101. BOOL BkupStore();
  102. BOOL Restore();
  103. void UpdateEditor() {
  104. if (m_pcmcwEdit)
  105. m_pcmcwEdit -> GetActiveDocument() -> UpdateAllViews(NULL);
  106. }
  107. // Operations- syntax and error checking support
  108. BOOL Parse(int nerrorlevel = 0);
  109. void RemoveError(unsigned u);
  110. // View support- it's easier done from here
  111. void Fill(CRichEditCtrl& crec);
  112. void UpdateFrom(CRichEditCtrl& crec);
  113. // Framework support operations
  114. virtual CMDIChildWnd* CreateEditor();
  115. virtual void Import();
  116. virtual void Serialize(CArchive& car);
  117. // Workspace completeness checking support routines
  118. bool UpdateResIDs(bool bufmids) ;
  119. int GetUFMRCID(unsigned urcidx) { return *(m_pnUFMRCIDs + urcidx) ; }
  120. int GetStringRCID(unsigned urcidx) { return *(m_pnStringRCIDs + urcidx) ; }
  121. unsigned NumUFMsInGPD() { return m_nNumUFMsInGPD ; }
  122. unsigned NumStringsInGPD() { return m_nNumStringsInGPD ; }
  123. };
  124. /******************************************************************************
  125. CGPDContainer class
  126. This class, derived from CDocument, contains the contents of a single GPD
  127. file in a conatiner suitable for the MFC document/view architecture.
  128. ******************************************************************************/
  129. class CGPDContainer : public CDocument {
  130. // TRUE iff the GPD Editor was started from the Workspace View. FALSE if
  131. // the GPD Editor was started from the File Open command.
  132. BOOL m_bEmbedded;
  133. CModelData *m_pcmd;
  134. protected:
  135. CGPDContainer(); // protected constructor used by dynamic creation
  136. DECLARE_DYNCREATE(CGPDContainer)
  137. // Attributes
  138. public:
  139. CModelData* ModelData() { return m_pcmd; }
  140. BOOL GetEmbedded() { return m_bEmbedded ; }
  141. // Operations
  142. public:
  143. // First a constructor for the Driver viewer to use to launch a GPD
  144. // editor...
  145. CGPDContainer(CModelData *pcmd, CString csPath);
  146. void OnFileSave() { CDocument::OnFileSave(); }
  147. void OnFileSaveAs() { CDocument::OnFileSaveAs(); }
  148. // Overrides
  149. // ClassWizard generated virtual function overrides
  150. //{{AFX_VIRTUAL(CGPDContainer)
  151. public:
  152. virtual void Serialize(CArchive& ar); // overridden for document i/o
  153. virtual BOOL OnSaveDocument(LPCTSTR lpszPathName);
  154. virtual BOOL OnOpenDocument(LPCTSTR lpszPathName);
  155. protected:
  156. virtual BOOL OnNewDocument();
  157. //}}AFX_VIRTUAL
  158. // Implementation
  159. public:
  160. virtual ~CGPDContainer();
  161. #ifdef _DEBUG
  162. virtual void AssertValid() const;
  163. virtual void Dump(CDumpContext& dc) const;
  164. #endif
  165. // Generated message map functions
  166. protected:
  167. //{{AFX_MSG(CGPDContainer)
  168. // NOTE - the ClassWizard will add and remove member functions here.
  169. //}}AFX_MSG
  170. DECLARE_MESSAGE_MAP()
  171. };
  172. #endif
  173.