1 /* 2 * Copyright 2010, Haiku. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Michael Pfeiffer 7 */ 8 #ifndef GP_JOB_H 9 #define GP_JOB_H 10 11 #include<gutenprint/gutenprint.h> 12 13 #include<list> 14 15 #include<String.h> 16 17 #include "GPBand.h" 18 #include "GPJobConfiguration.h" 19 #include "OutputStream.h" 20 #include "Rectangle.h" 21 22 23 class GPJob 24 { 25 public: 26 GPJob(); 27 ~GPJob(); 28 29 void SetApplicationName(const BString& applicationName); 30 void SetConfiguration(GPJobConfiguration* configuration); 31 void SetOutputStream(OutputStream* outputStream); 32 33 status_t Begin(); 34 void End(); 35 36 status_t PrintPage(list<GPBand*>& bands); 37 38 void GetErrorMessage(BString& message); 39 40 private: 41 RectInt32 GetPrintRectangle(list<GPBand*>& bands); 42 GPBand* FindBand(int line); 43 void FillRow(GPBand* band, unsigned char* data, size_t size, 44 int line); 45 void FillWhite(unsigned char* data, size_t size); 46 47 void Init(); 48 void Reset(); 49 int Width(); 50 int Height(); 51 stp_image_status_t GetRow(unsigned char* data, size_t size, int row); 52 const char* GetAppname(); 53 void Conclude(); 54 void Write(const char* data, size_t size); 55 void ReportError(const char* data, size_t size); 56 57 static void ImageInit(stp_image_t* image); 58 static void ImageReset(stp_image_t* image); 59 static int ImageWidth(stp_image_t* image); 60 static int ImageHeight(stp_image_t *image); 61 static stp_image_status_t ImageGetRow(stp_image_t* image, 62 unsigned char* data, size_t size, int row); 63 static const char* ImageGetAppname(stp_image_t* image); 64 static void ImageConclude(stp_image_t *image); 65 static void OutputFunction(void *cookie, const char *data, 66 size_t size); 67 static void ErrorFunction(void *cookie, const char *data, 68 size_t size); 69 70 BString fApplicationName; 71 OutputStream* fOutputStream; 72 GPJobConfiguration* fConfiguration; 73 74 bool fHasPages; 75 stp_image_t fImage; 76 stp_vars_t* fVariables; 77 const stp_printer_t* fPrinter; 78 RectInt32 fPrintRect; 79 list<GPBand*>* fBands; 80 GPBand* fCachedBand; 81 status_t fStatus; 82 BString fErrorMessage; 83 }; 84 #endif 85