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.

293 lines
4.5 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. page.c
  5. Abstract:
  6. Implementation of document and page related DDI entry points:
  7. DrvStartDoc
  8. DrvEndDoc
  9. DrvStartPage
  10. DrvSendPage
  11. Environment:
  12. Fax driver, kernel mode
  13. Revision History:
  14. 01/09/96 -davidx-
  15. Created it.
  16. mm/dd/yy -author-
  17. description
  18. --*/
  19. #include "faxdrv.h"
  20. BOOL
  21. DrvStartDoc(
  22. SURFOBJ *pso,
  23. PWSTR pDocName,
  24. DWORD jobId
  25. )
  26. /*++
  27. Routine Description:
  28. Implementation of DDI entry point DrvStartDoc.
  29. Please refer to DDK documentation for more details.
  30. Arguments:
  31. pso - Defines the surface object
  32. pDocName - Specifies a Unicode document name
  33. jobId - Identifies the print job
  34. Return Value:
  35. TRUE if successful, FALSE if there is an error
  36. --*/
  37. {
  38. PDEVDATA pdev;
  39. Verbose(("Entering DrvStartDoc...\n"));
  40. //
  41. // Verify input parameters
  42. //
  43. Assert(pso != NULL);
  44. pdev = (PDEVDATA) pso->dhpdev;
  45. if (! ValidDevData(pdev)) {
  46. Error(("ValidDevData failed\n"));
  47. SetLastError(ERROR_INVALID_PARAMETER);
  48. return FALSE;
  49. }
  50. //
  51. // Initialize page count and other information
  52. //
  53. if (! (pdev->flags & PDEV_RESETPDEV)) {
  54. pdev->pageCount = 0;
  55. pdev->jobId = jobId;
  56. }
  57. return TRUE;
  58. }
  59. BOOL
  60. DrvStartPage(
  61. SURFOBJ *pso
  62. )
  63. /*++
  64. Routine Description:
  65. Implementation of DDI entry point DrvStartPage.
  66. Please refer to DDK documentation for more details.
  67. Arguments:
  68. pso - Defines the surface object
  69. Return Value:
  70. TRUE if successful, FALSE if there is an error
  71. --*/
  72. {
  73. PDEVDATA pdev;
  74. RECTL pageRect;
  75. Verbose(("Entering DrvStartPage...\n"));
  76. //
  77. // Verify input parameters
  78. //
  79. Assert(pso != NULL);
  80. pdev = (PDEVDATA) pso->dhpdev;
  81. if (! ValidDevData(pdev)) {
  82. Error(("ValidDevData failed\n"));
  83. SetLastError(ERROR_INVALID_PARAMETER);
  84. return FALSE;
  85. }
  86. if (pdev->flags & PDEV_CANCELLED)
  87. return FALSE;
  88. //
  89. // Ignore nested calls to DrvStartPage
  90. //
  91. if (pdev->flags & PDEV_WITHINPAGE) {
  92. Error(("Nested call to DrvStartPage\n"));
  93. return TRUE;
  94. }
  95. pdev->flags |= PDEV_WITHINPAGE;
  96. //
  97. // Erase the page to all white
  98. //
  99. pageRect.left = pageRect.top = 0;
  100. pageRect.right = pdev->imageSize.cx;
  101. pageRect.bottom = pdev->imageSize.cy;
  102. EngEraseSurface(pso, &pageRect, WHITE_INDEX);
  103. pdev->pageCount++;
  104. return TRUE;
  105. }
  106. BOOL
  107. DrvSendPage(
  108. SURFOBJ *pso
  109. )
  110. /*++
  111. Routine Description:
  112. Implementation of DDI entry point DrvSendPage.
  113. Please refer to DDK documentation for more details.
  114. Arguments:
  115. pso - Defines the surface object
  116. Return Value:
  117. TRUE if successful, FALSE if there is an error
  118. --*/
  119. {
  120. PDEVDATA pdev;
  121. Verbose(("Entering DrvSendPage...\n"));
  122. //
  123. // Verify input parameters
  124. //
  125. Assert(pso != NULL);
  126. pdev = (PDEVDATA) pso->dhpdev;
  127. if (! ValidDevData(pdev)) {
  128. Error(("ValidDevData failed\n"));
  129. SetLastError(ERROR_INVALID_PARAMETER);
  130. return FALSE;
  131. }
  132. Assert(pdev->flags & PDEV_WITHINPAGE);
  133. pdev->flags &= ~PDEV_WITHINPAGE;
  134. if (pdev->flags & PDEV_CANCELLED)
  135. return FALSE;
  136. //
  137. // Output code to end a page
  138. //
  139. Assert(pso->lDelta == pdev->lineOffset);
  140. Assert(pso->fjBitmap & BMF_TOPDOWN);
  141. return OutputPageBitmap(pdev, pso->pvBits);
  142. }
  143. BOOL
  144. DrvEndDoc(
  145. SURFOBJ *pso,
  146. FLONG flags
  147. )
  148. /*++
  149. Routine Description:
  150. Implementation of DDI entry point DrvEndDoc.
  151. Please refer to DDK documentation for more details.
  152. Arguments:
  153. pso - Defines the surface object
  154. flags - A set of flag bits
  155. Return Value:
  156. TRUE if successful, FALSE if there is an error
  157. --*/
  158. {
  159. PDEVDATA pdev;
  160. Verbose(("Entering DrvEndDoc...\n"));
  161. //
  162. // Verify input parameters
  163. //
  164. Assert(pso != NULL);
  165. pdev = (PDEVDATA) pso->dhpdev;
  166. if (! ValidDevData(pdev)) {
  167. Error(("ValidDevData failed\n"));
  168. SetLastError(ERROR_INVALID_PARAMETER);
  169. return FALSE;
  170. }
  171. if ((pdev->flags & PDEV_CANCELLED) || (flags & ED_ABORTDOC)) {
  172. Error(("Print job was cancelled\n"));
  173. } else if (pdev->pageCount) {
  174. //
  175. // Perform any necessary work at the end of a document
  176. //
  177. Verbose(("Number of pages printed: %d\n", pdev->pageCount));
  178. OutputDocTrailer(pdev);
  179. }
  180. //
  181. // Clean up
  182. //
  183. pdev->pageCount = 0;
  184. pdev->flags = 0;
  185. return TRUE;
  186. }