1/*
2
3PrintJobReader
4
5Copyright (c) 2002 Haiku.
6
7Author:
8	Michael Pfeiffer
9
10Permission is hereby granted, free of charge, to any person obtaining a copy of
11this software and associated documentation files (the "Software"), to deal in
12the Software without restriction, including without limitation the rights to
13use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
14of the Software, and to permit persons to whom the Software is furnished to do
15so, subject to the following conditions:
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26THE 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
37class PrintJobPage {
38public:
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
51private:
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
60class PrintJobReader {
61public:
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
81private:
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