vfs: check userland buffers before reading them.
[haiku.git] / headers / libs / print / libprint / JobData.h
blob55be2b3f3a952dfd486fe50d5700b57b53448c1a
1 /*
2 * JobData.h
3 * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
4 */
6 #ifndef __JOBDATA_H
7 #define __JOBDATA_H
9 #include <SupportDefs.h>
10 #include <GraphicsDefs.h>
11 #include <Rect.h>
13 #include <map>
14 #include <string>
16 #include "Halftone.h"
17 #include "MarginView.h" // for MarginUnit
19 class BMessage;
20 class PrinterCap;
23 using namespace std;
25 class DriverSpecificSettings
27 public:
28 DriverSpecificSettings();
29 DriverSpecificSettings(const DriverSpecificSettings& Settings);
31 DriverSpecificSettings &operator=(const DriverSpecificSettings &Settings);
33 void MakeEmpty();
35 bool HasString(const char* key) const;
36 const char* GetString(const char* key) const;
37 void SetString(const char* key, const char* value);
39 bool HasBoolean(const char* ekey) const;
40 bool GetBoolean(const char* key) const;
41 void SetBoolean(const char* key, bool value);
43 bool HasInt(const char* ekey) const;
44 int32 GetInt(const char* key) const;
45 void SetInt(const char* key, int32 value);
47 bool HasDouble(const char* ekey) const;
48 double GetDouble(const char* key) const;
49 void SetDouble(const char* key, double value);
51 BMessage& Message();
53 private:
54 BMessage fSettings;
58 class JobData {
59 public:
60 enum Orientation {
61 kPortrait,
62 kLandscape
65 enum Paper {
66 kLetter = 1, // 1 Letter 8 1/2 x 11 in
67 kLetterSmall, // 2 Letter Small 8 1/2 x 11 in
68 kTabloid, // 3 Tabloid 11 x 17 in
69 kLedger, // 4 Ledger 17 x 11 in
70 kLegal, // 5 Legal 8 1/2 x 14 in
71 kStatement, // 6 Statement 5 1/2 x 8 1/2 in
72 kExecutive, // 7 Executive 7 1/4 x 10 1/2 in
73 kA3, // 8 A3 297 x 420 mm
74 kA4, // 9 A4 210 x 297 mm
75 kA4Small, // 10 A4 Small 210 x 297 mm
76 kA5, // 11 A5 148 x 210 mm
77 kB4, // 12 B4 (JIS) 250 x 354
78 kB5, // 13 B5 (JIS) 182 x 257 mm
79 kFolio, // 14 Folio 8 1/2 x 13 in
80 kQuarto, // 15 Quarto 215 x 275 mm
81 k10X14, // 16 10x14 in
82 k11X17, // 17 11x17 in
83 kNote, // 18 Note 8 1/2 x 11 in
84 kEnv9, // 19 Envelope #9 3 7/8 x 8 7/8
85 kEnv10, // 20 Envelope #10 4 1/8 x 9 1/2
86 kEnv11, // 21 Envelope #11 4 1/2 x 10 3/8
87 kEnv12, // 22 Envelope #12 4 \276 x 11
88 kEnv14, // 23 Envelope #14 5 x 11 1/2
89 kCSheet, // 24 C size sheet
90 kDSheet, // 25 D size sheet
91 kESheet, // 26 E size sheet
92 kEnvDL, // 27 Envelope DL 110 x 220mm
93 kEnvC5, // 28 Envelope C5 162 x 229 mm
94 kEnvC3, // 29 Envelope C3 324 x 458 mm
95 kEnvC4, // 30 Envelope C4 229 x 324 mm
96 kEnvC6, // 31 Envelope C6 114 x 162 mm
97 kEnvC65, // 32 Envelope C65 114 x 229 mm
98 kEnvB4, // 33 Envelope B4 250 x 353 mm
99 kEnvB5, // 34 Envelope B5 176 x 250 mm
100 kEnvB6, // 35 Envelope B6 176 x 125 mm
101 kEnvItaly, // 36 Envelope 110 x 230 mm
102 kEnvMonarch, // 37 Envelope Monarch 3.875 x 7.5 in
103 kEnvPersonal, // 38 6 3/4 Envelope 3 5/8 x 6 1/2 in
104 kFanFoldUS, // 39 US Std Fanfold 14 7/8 x 11 in
105 kFanFoldStdGerman, // 40 German Std Fanfold 8 1/2 x 12 in
106 kFanFoldLglGerman, // 41 German Legal Fanfold 8 1/2 x 13 in
107 kIsoB4, // 42 B4 (ISO) 250 x 353 mm
108 kJapanesePostcard, // 43 Japanese Postcard 100 x 148 mm
109 k9X11, // 44 9 x 11 in
110 k10X11, // 45 10 x 11 in
111 k15X11, // 46 15 x 11 in
112 kEnvInvite, // 47 Envelope Invite 220 x 220 mm
113 kReserved48, // 48 RESERVED--DO NOT USE
114 kReserved49, // 49 RESERVED--DO NOT USE
115 kLetterExtra, // 50 Letter Extra 9 \275 x 12 in
116 kLegalExtra, // 51 Legal Extra 9 \275 x 15 in
117 kTabloidExtra, // 52 Tabloid Extra 11.69 x 18 in
118 kA4Extra, // 53 A4 Extra 9.27 x 12.69 in
119 kLetterTransverse, // 54 Letter Transverse 8 \275 x 11 in
120 kA4Transverse, // 55 A4 Transverse 210 x 297 mm
121 kLetterExtraTransverse, // 56 Letter Extra Transverse 9\275 x 12 in
122 kAPlus, // 57 SuperA/SuperA/A4 227 x 356 mm
123 kBPlus, // 58 SuperB/SuperB/A3 305 x 487 mm
124 kLetterPlus, // 59 Letter Plus 8.5 x 12.69 in
125 kA4Plus, // 60 A4 Plus 210 x 330 mm
126 kA5Transverse, // 61 A5 Transverse 148 x 210 mm
127 kB5Transverse, // 62 B5 (JIS) Transverse 182 x 257 mm
128 kA3Extra, // 63 A3 Extra 322 x 445 mm
129 kA5Extra, // 64 A5 Extra 174 x 235 mm
130 kB5Extra, // 65 B5 (ISO) Extra 201 x 276 mm
131 kA2, // 66 A2 420 x 594 mm
132 kA3Transverse, // 67 A3 Transverse 297 x 420 mm
133 kA3ExtraTransverse, // 68 A3 Extra Transverse 322 x 445 mm
134 kDBLJapanesePostcard, // 69 Japanese Double Postcard 200 x 148 mm
135 kA6, // 70 A6 105 x 148 mm
136 kJEnvKaku2, // 71 Japanese Envelope Kaku #2
137 kJEnvKaku3, // 72 Japanese Envelope Kaku #3
138 kJEnvChou3, // 73 Japanese Envelope Chou #3
139 kJEnvChou4, // 74 Japanese Envelope Chou #4
140 kLetterRotated, // 75 Letter Rotated 11 x 8 1/2 11 in
141 kA3Rotated, // 76 A3 Rotated 420 x 297 mm
142 kA4Rotated, // 77 A4 Rotated 297 x 210 mm
143 kA5Rotated, // 78 A5 Rotated 210 x 148 mm
144 kB4JISRotated, // 79 B4 (JIS) Rotated 364 x 257 mm
145 kB5JISRotated, // 80 B5 (JIS) Rotated 257 x 182 mm
146 kJapanesePostcardRotated, // 81 Japanese Postcard Rotated 148 x 100 mm
147 kDBLJapanesePostcardRotated, // 82 Double Japanese Postcard Rotated 148 x 200 mm
148 kA6Rotated, // 83 A6 Rotated 148 x 105 mm
149 kJEnvKaku2Rotated, // 84 Japanese Envelope Kaku #2 Rotated
150 kJEnvKaku3Rotated, // 85 Japanese Envelope Kaku #3 Rotated
151 kJEnvChou3Rotated, // 86 Japanese Envelope Chou #3 Rotated
152 kJEnvChou4Rotated, // 87 Japanese Envelope Chou #4 Rotated
153 kB6JIS, // 88 B6 (JIS) 128 x 182 mm
154 kB6JISRotated, // 89 B6 (JIS) Rotated 182 x 128 mm
155 k12X11, // 90 12 x 11 in
156 kJEnvYou4, // 91 Japanese Envelope You #4
157 kJEnvYou4Rotated, // 92 Japanese Envelope You #4 Rotated
158 kP16K, // 93 PRC 16K 146 x 215 mm
159 kP32K, // 94 PRC 32K 97 x 151 mm
160 kP32KBig, // 95 PRC 32K(Big) 97 x 151 mm
161 kPEnv1, // 96 PRC Envelope #1 102 x 165 mm
162 kPEnv2, // 97 PRC Envelope #2 102 x 176 mm
163 kPEnv3, // 98 PRC Envelope #3 125 x 176 mm
164 kPEnv4, // 99 PRC Envelope #4 110 x 208 mm
165 kPEnv5, // 100 PRC Envelope #5 110 x 220 mm
166 kPEnv6, // 101 PRC Envelope #6 120 x 230 mm
167 kPEnv7, // 102 PRC Envelope #7 160 x 230 mm
168 kPEnv8, // 103 PRC Envelope #8 120 x 309 mm
169 kPEnv9, // 104 PRC Envelope #9 229 x 324 mm
170 kPEnv10, // 105 PRC Envelope #10 324 x 458 mm
171 kP16KRotated, // 106 PRC 16K Rotated
172 kP32KRotated, // 107 PRC 32K Rotated
173 kP32KBIGRotated, // 108 PRC 32K(Big) Rotated
174 kPEnv1Rotated, // 109 PRC Envelope #1 Rotated 165 x 102 mm
175 kPEnv2Rotated, // 110 PRC Envelope #2 Rotated 176 x 102 mm
176 kPEnv3Rotated, // 111 PRC Envelope #3 Rotated 176 x 125 mm
177 kPEnv4Rotated, // 112 PRC Envelope #4 Rotated 208 x 110 mm
178 kPEnv5Rotated, // 113 PRC Envelope #5 Rotated 220 x 110 mm
179 kPEnv6Rotated, // 114 PRC Envelope #6 Rotated 230 x 120 mm
180 kPEnv7Rotated, // 115 PRC Envelope #7 Rotated 230 x 160 mm
181 kPEnv8Rotated, // 116 PRC Envelope #8 Rotated 309 x 120 mm
182 kPEnv9Rotated, // 117 PRC Envelope #9 Rotated 324 x 229 mm
183 kPEnv10Rotated, // 118 PRC Envelope #10 Rotated 458 x 324 mm
184 kUserDefined = 256
187 enum PaperSource {
188 kAuto, // 7 o
189 kManual, // 4 o
190 kUpper, // 1 o
191 kMiddle, // 3 o
192 kLower, // 2 o
193 // kOnlyOne, // 1 x
194 // kEnvelope, // 5 o
195 // kEnvManual, // 6 x
196 // kTractor, // 8 x
197 // kSmallFmt, // 9 x
198 // kLargeFmt, // 10 x
199 // kLargeCapacity, // 11 x
200 // kCassette, // 14 x
201 // kFormSource, // 15 x
202 kCassette1 = 21,
203 kCassette2,
204 kCassette3,
205 kCassette4,
206 kCassette5,
207 kCassette6,
208 kCassette7,
209 kCassette8,
210 kCassette9,
211 kUser = 256 // device specific bins start here
214 enum PrintStyle {
215 kSimplex,
216 kDuplex,
217 kBooklet
220 enum BindingLocation {
221 kLongEdgeLeft,
222 kLongEdgeRight,
223 kShortEdgeTop,
224 kShortEdgeBottom,
225 kLongEdge = kLongEdgeLeft,
226 kShortEdge = kShortEdgeTop
229 enum PageOrder {
230 kAcrossFromLeft,
231 kDownFromLeft,
232 kAcrossFromRight,
233 kDownFromRight,
234 kLeftToRight = kAcrossFromLeft,
235 kRightToLeft = kAcrossFromRight
239 enum Quality {
240 kDraft = -1,
241 kLow = -2,
242 kMedium = -3,
243 kHigh = -4
246 enum Color {
247 kMonochrome = 1,
248 kColor,
249 // Some PCL6 printers do not support compressed data
250 // in color mode.
251 kColorCompressionDisabled
254 enum SettingType {
255 kPageSettings,
256 kJobSettings
259 enum PageSelection {
260 kAllPages,
261 kOddNumberedPages,
262 kEvenNumberedPages
265 JobData(BMessage* message, const PrinterCap* printerCap,
266 SettingType type);
267 ~JobData();
269 JobData(const JobData& jobData);
270 JobData& operator=(const JobData& jobData);
272 void Load(BMessage* message, const PrinterCap* printerCap,
273 SettingType type);
274 void Save(BMessage* message = NULL);
276 bool GetShowPreview() const;
277 void SetShowPreview(bool showPreview);
279 Paper GetPaper() const;
280 void SetPaper(Paper paper);
282 int32 GetResolutionID() const;
283 void SetResolutionID(int32 resolution);
285 int32 GetXres() const;
286 void SetXres(int32 xres);
288 int32 GetYres() const;
289 void SetYres(int32 yres);
291 Orientation GetOrientation() const;
292 void SetOrientation(Orientation orientation);
294 float GetScaling() const;
295 void SetScaling(float scaling);
297 const BRect& GetPaperRect() const;
298 void SetPaperRect(const BRect& paperRect);
300 const BRect& GetScaledPaperRect() const;
301 void SetScaledPaperRect(const BRect& paperRect);
303 const BRect& GetPrintableRect() const;
304 void SetPrintableRect(const BRect& printableRect);
306 const BRect& GetScaledPrintableRect() const;
307 void SetScaledPrintableRect(const BRect& printableRect);
309 const BRect& GetPhysicalRect() const;
310 void SetPhysicalRect(const BRect& PhysicalRect);
312 const BRect& GetScaledPhysicalRect() const;
313 void SetScaledPhysicalRect(const BRect& PhysicalRect);
315 int32 GetNup() const;
316 void SetNup(int32 nup);
318 bool GetReverse() const;
319 void SetReverse(bool reverse);
321 int32 GetFirstPage() const;
322 void SetFirstPage(int32 firstPage);
324 int32 GetLastPage() const;
325 void SetLastPage(int32 lastPage);
327 // libprint supports only B_RGB32
328 color_space GetSurfaceType() const;
330 float GetGamma() const;
331 void SetGamma(float gamma);
333 float GetInkDensity() const;
334 void SetInkDensity(float inkDensity);
336 PaperSource GetPaperSource() const;
337 void SetPaperSource(PaperSource paperSource);
339 int32 GetCopies() const;
340 void SetCopies(int32 copies);
342 bool GetCollate() const;
343 void SetCollate(bool collate);
345 PrintStyle GetPrintStyle() const;
346 void SetPrintStyle(PrintStyle printStyle);
348 BindingLocation GetBindingLocation() const;
349 void SetBindingLocation(BindingLocation bindingLocation);
351 PageOrder GetPageOrder() const;
352 void SetPageOrder(PageOrder pageOrder);
354 Color GetColor() const;
355 void SetColor(Color color);
357 Halftone::DitherType GetDitherType() const;
358 void SetDitherType(Halftone::DitherType ditherType);
360 PageSelection GetPageSelection() const;
361 void SetPageSelection(PageSelection pageSelection);
363 MarginUnit GetMarginUnit() const;
364 void SetMarginUnit(MarginUnit marginUnit);
366 DriverSpecificSettings& Settings();
367 const DriverSpecificSettings& Settings() const;
369 private:
370 bool fShowPreview;
371 Paper fPaper;
372 int32 fResolutionID;
373 int32 fXRes;
374 int32 fYRes;
375 Orientation fOrientation;
376 float fScaling;
377 BRect fPaperRect;
378 BRect fScaledPaperRect;
379 BRect fPrintableRect;
380 BRect fScaledPrintableRect;
381 BRect fPhysicalRect;
382 BRect fScaledPhysicalRect;
383 int32 fNup;
384 int32 fFirstPage;
385 int32 fLastPage;
386 float fGamma; // 1 identiy, < 1 brigther, > 1 darker
387 float fInkDensity; // [0, 255] lower means higher density
388 PaperSource fPaperSource;
389 int32 fCopies;
390 bool fCollate;
391 bool fReverse;
392 PrintStyle fPrintStyle;
393 BindingLocation fBindingLocation;
394 PageOrder fPageOrder;
395 SettingType fSettingType;
396 BMessage *fMsg;
397 Color fColor;
398 Halftone::DitherType fDitherType;
399 PageSelection fPageSelection;
400 MarginUnit fMarginUnit;
401 DriverSpecificSettings fDriverSpecificSettings;
405 inline bool
406 JobData::GetShowPreview() const
408 return fShowPreview;
411 inline void
412 JobData::SetShowPreview(bool showPreview)
414 fShowPreview = showPreview;
418 inline JobData::Paper
419 JobData::GetPaper() const
421 return fPaper;
425 inline void
426 JobData::SetPaper(Paper paper)
428 fPaper = paper;
432 inline int32
433 JobData::GetResolutionID() const
435 return fResolutionID;
439 inline void
440 JobData::SetResolutionID(int32 resolution)
442 fResolutionID = resolution;
446 inline int32
447 JobData::GetXres() const
449 return fXRes;
453 inline void
454 JobData::SetXres(int32 xres)
456 fXRes = xres;
460 inline int32
461 JobData::GetYres() const
463 return fYRes;
467 inline void
468 JobData::SetYres(int32 yres)
470 fYRes = yres;
474 inline JobData::Orientation
475 JobData::GetOrientation() const
477 return fOrientation;
481 inline void
482 JobData::SetOrientation(Orientation orientation)
484 fOrientation = orientation;
488 inline float
489 JobData::GetScaling() const
491 return fScaling;
495 inline void
496 JobData::SetScaling(float scaling)
498 fScaling = scaling;
502 inline const BRect&
503 JobData::GetPaperRect() const
505 return fPaperRect;
509 inline void
510 JobData::SetPaperRect(const BRect &rect)
512 fPaperRect = rect;
516 inline const BRect&
517 JobData::GetScaledPaperRect() const
519 return fScaledPaperRect;
523 inline void
524 JobData::SetScaledPaperRect(const BRect &rect)
526 fScaledPaperRect = rect;
530 inline const BRect &
531 JobData::GetPrintableRect() const
533 return fPrintableRect;
537 inline void
538 JobData::SetPrintableRect(const BRect &rect)
540 fPrintableRect = rect;
544 inline const BRect&
545 JobData::GetScaledPrintableRect() const
547 return fScaledPrintableRect;
551 inline void
552 JobData::SetScaledPrintableRect(const BRect &rect)
554 fScaledPrintableRect = rect;
558 inline const BRect&
559 JobData::GetPhysicalRect() const
561 return fPhysicalRect;
565 inline void
566 JobData::SetPhysicalRect(const BRect &rect)
568 fPhysicalRect = rect;
572 inline const BRect&
573 JobData::GetScaledPhysicalRect() const
575 return fScaledPhysicalRect;
580 inline void
581 JobData::SetScaledPhysicalRect(const BRect &rect)
583 fScaledPhysicalRect = rect;
587 inline int32
588 JobData::GetNup() const
590 return fNup;
594 inline void
595 JobData::SetNup(int32 nup)
597 fNup = nup;
601 inline bool
602 JobData::GetReverse() const
604 return fReverse;
608 inline void
609 JobData::SetReverse(bool reverse)
611 fReverse = reverse;
615 inline int32
616 JobData::GetFirstPage() const
618 return fFirstPage;
622 inline void
623 JobData::SetFirstPage(int32 firstPage)
625 fFirstPage = firstPage;
629 inline int32
630 JobData::GetLastPage() const
632 return fLastPage;
636 inline void
637 JobData::SetLastPage(int32 lastPage)
639 fLastPage = lastPage;
643 color_space
644 inline JobData::GetSurfaceType() const
646 return B_RGB32;
650 inline float
651 JobData::GetGamma() const
653 return fGamma;
657 inline void
658 JobData::SetGamma(float gamma)
660 fGamma = gamma;
664 inline float
665 JobData::GetInkDensity() const
667 return fInkDensity;
671 inline void
672 JobData::SetInkDensity(float inkDensity)
674 fInkDensity = inkDensity;
678 inline JobData::PaperSource
679 JobData::GetPaperSource() const
681 return fPaperSource;
685 inline void
686 JobData::SetPaperSource(PaperSource paperSource)
688 fPaperSource = paperSource;
692 inline int32
693 JobData::GetCopies() const
695 return fCopies;
699 inline void
700 JobData::SetCopies(int32 copies)
702 fCopies = copies;
706 inline bool
707 JobData::GetCollate() const
709 return fCollate;
713 inline void
714 JobData::SetCollate(bool collate)
716 fCollate = collate;
720 inline JobData::PrintStyle
721 JobData::GetPrintStyle() const
723 return fPrintStyle;
727 inline void
728 JobData::SetPrintStyle(PrintStyle print_style)
730 fPrintStyle = print_style;
734 inline JobData::BindingLocation
735 JobData::GetBindingLocation() const
737 return fBindingLocation;
741 inline void
742 JobData::SetBindingLocation(BindingLocation binding_location)
744 fBindingLocation = binding_location;
748 inline JobData::PageOrder
749 JobData::GetPageOrder() const { return fPageOrder; }
752 inline void
753 JobData::SetPageOrder(PageOrder page_order)
755 fPageOrder = page_order;
759 inline JobData::Color
760 JobData::GetColor() const
762 return fColor;
766 inline void
767 JobData::SetColor(Color color)
769 fColor = color;
773 inline Halftone::DitherType
774 JobData::GetDitherType() const
776 return fDitherType;
780 inline void
781 JobData::SetDitherType(Halftone::DitherType dither_type)
783 fDitherType = dither_type;
787 inline JobData::PageSelection
788 JobData::GetPageSelection() const
790 return fPageSelection;
794 inline void
795 JobData::SetPageSelection(PageSelection pageSelection)
797 fPageSelection = pageSelection;
801 inline MarginUnit
802 JobData::GetMarginUnit() const
804 return fMarginUnit;
808 inline void
809 JobData::SetMarginUnit(MarginUnit marginUnit)
811 fMarginUnit = marginUnit;
814 #endif /* __JOBDATA_H */