Source code of Windows XP (NT5)
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.

416 lines
12 KiB

  1. /*++
  2. Copyright (c) 1996-1999 Microsoft Corporation
  3. Module Name:
  4. ppd.h
  5. Abstract:
  6. PPD parser specific header file
  7. Environment:
  8. Windows NT PostScript driver
  9. Revision History:
  10. 10/11/96 -davidx-
  11. Make CustomPageSize feature an option of PageSize.
  12. 08/16/96 -davidx-
  13. Created it.
  14. --*/
  15. #ifndef _PPD_H_
  16. #define _PPD_H_
  17. //
  18. // We need to include <printoem.h> for its definition of CUSTOMPARAM_xxx
  19. // constants and CUSTOMSIZEPARAM structure.
  20. //
  21. #ifndef KERNEL_MODE
  22. #include <winddiui.h>
  23. #endif
  24. #include <printoem.h>
  25. //
  26. // PPD parser version number
  27. //
  28. #define PRIVATE_PARSER_VERSION 0x0017
  29. #define PPD_PARSER_VERSION MAKELONG(PRIVATE_PARSER_VERSION, SHARED_PARSER_VERSION)
  30. //
  31. // Current PPD spec version
  32. //
  33. #define PPD_SPECVERSION_43 0x00040003
  34. //
  35. // Binary printer description filename extension
  36. //
  37. #ifndef ADOBE
  38. #define BPD_FILENAME_EXT TEXT(".BPD")
  39. #else
  40. #define BPD_FILENAME_EXT TEXT(".ABD")
  41. #endif
  42. //
  43. // Given a pointer to raw printer description data, initialize pointers
  44. // to INFOHEADER and UIINFO structures
  45. //
  46. #define PPD_GET_UIINFO_FROM_RAWDATA(pRawData, pInfoHdr, pUIInfo) { \
  47. ASSERT((pRawData) != NULL && (pRawData) == (pRawData)->pvPrivateData); \
  48. (pInfoHdr) = (PINFOHEADER) (pRawData); \
  49. (pUIInfo) = GET_UIINFO_FROM_INFOHEADER(pInfoHdr); \
  50. }
  51. //
  52. // Given a pointer to raw printer description data, initialize pointers
  53. // to INFOHEADER and PPDDATA structures
  54. //
  55. #define PPD_GET_PPDDATA_FROM_RAWDATA(pRawData, pInfoHdr, pPpdData) { \
  56. ASSERT((pRawData) != NULL && (pRawData) == (pRawData)->pvPrivateData); \
  57. (pInfoHdr) = (PINFOHEADER) (pRawData); \
  58. (pPpdData) = GET_DRIVER_INFO_FROM_INFOHEADER(pInfoHdr); \
  59. }
  60. //
  61. // Constants for PPDDATA.dwCustomSizeFlags
  62. //
  63. #define CUSTOMSIZE_CUTSHEET 0x0001 // device supports cut-sheet
  64. #define CUSTOMSIZE_ROLLFED 0x0002 // device supports roll-feed
  65. #define CUSTOMSIZE_DEFAULTCUTSHEET 0x0004 // default to cut-sheet
  66. #define CUSTOMSIZE_SHORTEDGEFEED 0x0008 // default to short edge feed
  67. #define CUSTOMSIZE_CENTERREG 0x0010 // center-registered
  68. #define CUSTOMORDER(pPpdData, csindex) \
  69. ((pPpdData)->CustomSizeParams[csindex].dwOrder)
  70. #define MINCUSTOMPARAM(pPpdData, csindex) \
  71. ((pPpdData)->CustomSizeParams[csindex].lMinVal)
  72. #define MAXCUSTOMPARAM(pPpdData, csindex) \
  73. ((pPpdData)->CustomSizeParams[csindex].lMaxVal)
  74. #define MAXCUSTOMPARAM_WIDTH(pPpdData) MAXCUSTOMPARAM(pPpdData, CUSTOMPARAM_WIDTH)
  75. #define MAXCUSTOMPARAM_HEIGHT(pPpdData) MAXCUSTOMPARAM(pPpdData, CUSTOMPARAM_HEIGHT)
  76. #define MAXCUSTOMPARAM_WIDTHOFFSET(pPpdData) MAXCUSTOMPARAM(pPpdData, CUSTOMPARAM_WIDTHOFFSET)
  77. #define MAXCUSTOMPARAM_HEIGHTOFFSET(pPpdData) MAXCUSTOMPARAM(pPpdData, CUSTOMPARAM_HEIGHTOFFSET)
  78. #define MAXCUSTOMPARAM_ORIENTATION(pPpdData) MAXCUSTOMPARAM(pPpdData, CUSTOMPARAM_ORIENTATION)
  79. #define MINCUSTOMPARAM_WIDTH(pPpdData) MINCUSTOMPARAM(pPpdData, CUSTOMPARAM_WIDTH)
  80. #define MINCUSTOMPARAM_HEIGHT(pPpdData) MINCUSTOMPARAM(pPpdData, CUSTOMPARAM_HEIGHT)
  81. #define MINCUSTOMPARAM_WIDTHOFFSET(pPpdData) MINCUSTOMPARAM(pPpdData, CUSTOMPARAM_WIDTHOFFSET)
  82. #define MINCUSTOMPARAM_HEIGHTOFFSET(pPpdData) MINCUSTOMPARAM(pPpdData, CUSTOMPARAM_HEIGHTOFFSET)
  83. #define MINCUSTOMPARAM_ORIENTATION(pPpdData) MINCUSTOMPARAM(pPpdData, CUSTOMPARAM_ORIENTATION)
  84. //
  85. // This structure contains the information parsed from the PPD file that's
  86. // not stored in UIINFO structure.
  87. //
  88. typedef struct _PPDDATA {
  89. DWORD dwSizeOfStruct; // size of this structure
  90. DWORD dwFlags; // misc. flags
  91. DWORD dwExtensions; // language extensions
  92. DWORD dwSetResType; // how to set resolution
  93. DWORD dwPpdFilever; // PPD file version
  94. DWORD dwPSVersion; // PostScript interpreter version number
  95. INVOCATION PSVersion; // PSVersion string
  96. INVOCATION Product; // Product string
  97. DWORD dwOutputOrderIndex; // index of feature "OutputOrder"
  98. DWORD dwCustomSizeFlags; // custom page size flags and parameters
  99. DWORD dwLeadingEdgeLong; // option index for *LeadingEdge Long
  100. DWORD dwLeadingEdgeShort; // option index for *LeadingEdge Short
  101. DWORD dwUseHWMarginsTrue; // option index for *UseHWMargins True
  102. DWORD dwUseHWMarginsFalse;// option index for *UseHWMargins False
  103. CUSTOMSIZEPARAM CustomSizeParams[CUSTOMPARAM_MAX];
  104. DWORD dwNt4Checksum; // NT4 PPD checksum
  105. DWORD dwNt4DocFeatures; // NT4 number of doc-sticky features
  106. DWORD dwNt4PrnFeatures; // NT4 number of printer-sticky features
  107. ARRAYREF Nt4Mapping; // feature index mapping from NT4 to NT5
  108. INVOCATION PatchFile; // PatchFile invocation string
  109. INVOCATION JclBegin; // JCLBegin invocation string
  110. INVOCATION JclEnterPS; // JCLEnterLanguage invocation string
  111. INVOCATION JclEnd; // JCLEnd invocation string
  112. INVOCATION ManualFeedFalse; // *ManualFeed False invocation string
  113. PTRREF loDefaultFont; // byte-offset to the default device font
  114. ARRAYREF DeviceFonts; // array of DEVFONT structures
  115. ARRAYREF OrderDeps; // array of ORDERDEPEND structures
  116. ARRAYREF QueryOrderDeps; // array of ORDERDEPEND structures for query order dependency
  117. ARRAYREF JobPatchFiles; // array of JobPatchFile invocation strings
  118. DWORD dwUserDefUILangID; // user's default UI language ID when .bpd is generated
  119. } PPDDATA, *PPPDDATA;
  120. //
  121. // Constants for PPDDATA.dwFlags field
  122. //
  123. #define PPDFLAG_REQEEXEC 0x0001 // requires eexec-encoded Type1 font
  124. #define PPDFLAG_PRINTPSERROR 0x0002 // print PS error page
  125. #define PPDFLAG_HAS_JCLBEGIN 0x0004 // JCLBegin entry is present
  126. #define PPDFLAG_HAS_JCLENTERPS 0x0008 // JCLToPSInterpreter entry is present
  127. #define PPDFLAG_HAS_JCLEND 0x0010 // JCLEnd entry is present
  128. //
  129. // Decide if the printer can fully support custom page size feature:
  130. // PPD4.3 device (cut-sheet or roll-fed)
  131. // pre-PPD4.3 roll-fed device
  132. //
  133. #define SUPPORT_FULL_CUSTOMSIZE_FEATURES(pUIInfo, pPpdData) \
  134. ((pUIInfo)->dwSpecVersion >= PPD_SPECVERSION_43 || \
  135. ((pPpdData)->dwCustomSizeFlags & CUSTOMSIZE_ROLLFED))
  136. //
  137. // PPD spec says if *CustomPageSize is present, *LeadingEdge should also be
  138. // present. But there are some PPD files that don't have *LeadingEdge statements,
  139. // in which case we assume the device supports both Long and Short leading edges.
  140. //
  141. // Also, there are PPD files that specify neither Long nor Short option for
  142. // *LeadingEdge, in which case we also assume the device supports both Long and
  143. // Short leading edges.
  144. //
  145. #define SKIP_LEADINGEDGE_CHECK(pUIInfo, pPpdData) \
  146. ((GET_PREDEFINED_FEATURE((pUIInfo), GID_LEADINGEDGE) == NULL) || \
  147. ((pPpdData)->dwLeadingEdgeLong == OPTION_INDEX_ANY && \
  148. (pPpdData)->dwLeadingEdgeShort == OPTION_INDEX_ANY))
  149. #define LONGEDGEFIRST_SUPPORTED(pUIInfo, pPpdData) \
  150. (SKIP_LEADINGEDGE_CHECK(pUIInfo, pPpdData) || \
  151. ((pPpdData)->dwLeadingEdgeLong != OPTION_INDEX_ANY))
  152. #define SHORTEDGEFIRST_SUPPORTED(pUIInfo, pPpdData) \
  153. (SKIP_LEADINGEDGE_CHECK(pUIInfo, pPpdData) || \
  154. ((pPpdData)->dwLeadingEdgeShort != OPTION_INDEX_ANY))
  155. //
  156. // Minimum amount of free VM for Level1 and Level2 printer
  157. //
  158. #define MIN_FREEMEM_L1 (172*KBYTES)
  159. #define MIN_FREEMEM_L2 (249*KBYTES)
  160. //
  161. // Default job timeout and wait timeout measured in seconds
  162. //
  163. #define DEFAULT_JOB_TIMEOUT 0
  164. #define DEFAULT_WAIT_TIMEOUT 300
  165. //
  166. // Landscape orientation options
  167. //
  168. #define LSO_ANY 0
  169. #define LSO_PLUS90 90
  170. #define LSO_MINUS90 270
  171. //
  172. // How to set resolution
  173. //
  174. #define RESTYPE_NORMAL 0
  175. #define RESTYPE_JCL 1
  176. #define RESTYPE_EXITSERVER 2
  177. //
  178. // Language extensions
  179. //
  180. #define LANGEXT_DPS 0x0001
  181. #define LANGEXT_CMYK 0x0002
  182. #define LANGEXT_COMPOSITE 0x0004
  183. #define LANGEXT_FILESYSTEM 0x0008
  184. //
  185. // Default resolution when no information is provided in the PPD file
  186. //
  187. #define DEFAULT_RESOLUTION 300
  188. //
  189. // Data structure for storing information about device fonts
  190. //
  191. typedef struct _DEVFONT {
  192. PTRREF loFontName; // byte offset to font name (ANSI string)
  193. PTRREF loDisplayName; // byte offset to translation string (Unicode string)
  194. PTRREF loEncoding; // encoding (ANSI string)
  195. PTRREF loCharset; // charset (ANSI string)
  196. PTRREF loVersion; // version (ANSI string)
  197. DWORD dwStatus; // status
  198. } DEVFONT, *PDEVFONT;
  199. #define FONTSTATUS_UNKNOWN 0
  200. #define FONTSTATUS_ROM 1
  201. #define FONTSTATUS_DISK 2
  202. //
  203. // Data structure for storing information about order dependencies
  204. //
  205. typedef struct _ORDERDEPEND {
  206. LONG lOrder; // order value from *OrderDependency entry
  207. DWORD dwSection; // in which section should the code appear
  208. DWORD dwPPDSection; // orignal section specified in PPD (no parser conversion)
  209. DWORD dwFeatureIndex; // index of the feature involved
  210. DWORD dwOptionIndex; // index of the option involved (if any)
  211. DWORD dwNextOrderDep; // points to the list of order dependencies
  212. // related to a feature; always starts with
  213. // the entry whose dwOptionIndex = OPTION_INDEX_ANY
  214. } ORDERDEPEND, *PORDERDEPEND;
  215. #define NULL_ORDERDEP 0xffffffff
  216. #define INVALID_FEATURE_INDEX 0xffffffff
  217. //
  218. // Constants for ORDERDEPENDENCY.section field
  219. //
  220. #define SECTION_JCLSETUP 0x0001
  221. #define SECTION_EXITSERVER 0x0002
  222. #define SECTION_PROLOG 0x0004
  223. #define SECTION_UNASSIGNED 0x0008
  224. //
  225. // Change SECTION_ANYSETUP to be smaller than SECTION_DOCSETUP/SECTION_PAGESETUP
  226. // so that in the ascending order dependency list, for nodes with the same order value,
  227. // SECTION_ANYSETUP nodes will be in front of SECTION_DOCSETUP/SECTION_PAGESETUP nodes.
  228. //
  229. #define SECTION_ANYSETUP 0x0010
  230. #define SECTION_DOCSETUP 0x0020
  231. #define SECTION_PAGESETUP 0x0040
  232. //
  233. // Load cached binary PPD data file into memory
  234. //
  235. PRAWBINARYDATA
  236. PpdLoadCachedBinaryData(
  237. IN PTSTR ptstrPpdFilename
  238. );
  239. //
  240. // Parse the ASCII text PPD file and cached the resulting binary data
  241. //
  242. PRAWBINARYDATA
  243. PpdParseTextFile(
  244. IN PTSTR ptstrPpdFilename
  245. );
  246. //
  247. // Generate a filename for the cached binary PPD data given a PPD filename
  248. //
  249. PTSTR
  250. GenerateBpdFilename(
  251. IN PTSTR ptstrPpdFilename
  252. );
  253. //
  254. // Validate the specified custom page size parameters and
  255. // Fix up any inconsistencies found.
  256. //
  257. BOOL
  258. BValidateCustomPageSizeData(
  259. IN PRAWBINARYDATA pRawData,
  260. IN OUT PCUSTOMSIZEDATA pCSData
  261. );
  262. //
  263. // Initialize custom page size parameters to their default values
  264. //
  265. VOID
  266. VFillDefaultCustomPageSizeData(
  267. IN PRAWBINARYDATA pRawData,
  268. OUT PCUSTOMSIZEDATA pCSData,
  269. IN BOOL bMetric
  270. );
  271. //
  272. // Return the valid ranges for custom page size width, height,
  273. // and offset parameters based on the specifed paper feed direction
  274. //
  275. typedef struct _CUSTOMSIZERANGE {
  276. DWORD dwMin;
  277. DWORD dwMax;
  278. } CUSTOMSIZERANGE, *PCUSTOMSIZERANGE;
  279. VOID
  280. VGetCustomSizeParamRange(
  281. IN PRAWBINARYDATA pRawData,
  282. IN PCUSTOMSIZEDATA pCSData,
  283. OUT PCUSTOMSIZERANGE pCSRange
  284. );
  285. //
  286. // Convert NT4 feature/option selections to NT5 format
  287. //
  288. VOID
  289. VConvertOptSelectArray(
  290. PRAWBINARYDATA pRawData,
  291. POPTSELECT pNt5Options,
  292. DWORD dwNt5MaxCount,
  293. PBYTE pubNt4Options,
  294. DWORD dwNt4MaxCount,
  295. INT iMode
  296. );
  297. //
  298. // Return a copy of the default font substitution table
  299. //
  300. PTSTR
  301. PtstrGetDefaultTTSubstTable(
  302. PUIINFO pUIInfo
  303. );
  304. //
  305. // Check whether a form is supported through custom paper size, and if yes
  306. // which direction the paper is fed. pwFeedDirection can be NULL
  307. //
  308. BOOL
  309. BFormSupportedThruCustomSize(
  310. PRAWBINARYDATA pRawData,
  311. DWORD dwX,
  312. DWORD dwY,
  313. PWORD pwFeedDirection
  314. );
  315. #endif // !_PPD_H_