xref: /haiku/headers/libs/print/libprint/PrintJobReader.h (revision 4c8e85b316c35a9161f5a1c50ad70bc91c83a76f)
1 /*
2 
3 PrintJobReader
4 
5 Copyright (c) 2002 Haiku.
6 
7 Author:
8 	Michael Pfeiffer
9 
10 Permission is hereby granted, free of charge, to any person obtaining a copy of
11 this software and associated documentation files (the "Software"), to deal in
12 the Software without restriction, including without limitation the rights to
13 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
14 of the Software, and to permit persons to whom the Software is furnished to do
15 so, subject to the following conditions:
16 
17 The above copyright notice and this permission notice shall be included in all
18 copies or substantial portions of the Software.
19 
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 THE SOFTWARE.
27 
28 */
29 
30 #ifndef _PRINT_JOB_READER_H
31 #define _PRINT_JOB_READER_H
32 
33 #include <File.h>
34 #include <Message.h>
35 #include <Picture.h>
36 
37 class PrintJobPage {
38 public:
39 					PrintJobPage();
40 					PrintJobPage(const PrintJobPage& copy);
41 					PrintJobPage(BFile* jobFile, off_t start);
42 
43 	status_t		InitCheck() const;
44 
45 	int32			NumberOfPictures() const { return fNumberOfPictures; }
46 
47 	status_t		NextPicture(BPicture& picture, BPoint& p, BRect& r);
48 
49 	PrintJobPage& operator=(const PrintJobPage& copy);
50 
51 private:
52 	BFile		fJobFile;			// the job file
53 	off_t		fNextPicture;		// offset to first picture
54 	int32		fNumberOfPictures;	// of this page
55 	int32		fPicture;			// the picture returned by NextPicture()
56 	status_t	fStatus;
57 };
58 
59 
60 class PrintJobReader {
61 public:
62 					PrintJobReader(BFile* jobFile);
63 	virtual			~PrintJobReader();
64 
65 			// test after construction if this is a valid job file
66 			status_t	InitCheck() const;
67 
68 			// accessors to informations from job file
69 			int32		NumberOfPages() const { return fNumberOfPages; }
70 			int32		FirstPage() const;
71 			int32		LastPage() const;
72 			const BMessage*	JobSettings() const { return &fJobSettings; }
73 			BRect		PaperRect() const;
74 			BRect		PrintableRect() const;
75 			void		GetResolution(int32* xdpi, int32* ydpi) const;
76 			float		GetScale() const;
77 
78 			// retrieve page
79 			status_t	GetPage(int32 no, PrintJobPage& pjp);
80 
81 private:
82 			void		_BuildPageIndex();
83 
84 	BFile		fJobFile;		// the job file
85 	int32		fNumberOfPages;	// the number of pages in the job file
86 	BMessage	fJobSettings;	// the settings extracted from the job file
87 	off_t*		fPageIndex;		// start positions of pages in the job file
88 
89 };
90 
91 #endif
92 
93