From 80339607f91ad4d70615ae16e645751270ab55ae Mon Sep 17 00:00:00 2001 From: Michael Pfeiffer Date: Sun, 23 Mar 2008 18:01:13 +0000 Subject: [PATCH] Get first and last page from job settings instead of print_file_header. In print_filer_header first_page is an offset into the spool file (the field is unused or reserved on BeOS R5 and is always -1) and page_count is the number of pages in the spool file. In the job settings first/last page is the page number of the first/last page as specified in the page setup dialog. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24536 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/print/PrintJobReader.h | 5 ++--- src/add-ons/print/shared/PrintJobReader.cpp | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/headers/private/print/PrintJobReader.h b/headers/private/print/PrintJobReader.h index 0263ac9ff3..1c5fd8ce67 100644 --- a/headers/private/print/PrintJobReader.h +++ b/headers/private/print/PrintJobReader.h @@ -57,7 +57,6 @@ public: class PrintJobReader { BFile fJobFile; // the job file int32 fNumberOfPages; // the number of pages in the job file - off_t fFirstPage; // the page number of the first page BMessage fJobSettings; // the settings extracted from the job file off_t* fPageIndex; // start positions of pages in the job file @@ -72,8 +71,8 @@ public: // accessors to informations from job file int32 NumberOfPages() const { return fNumberOfPages; } - int32 FirstPage() const { return fFirstPage; } - int32 LastPage() const { return fFirstPage + fNumberOfPages - 1; } + int32 FirstPage() const; + int32 LastPage() const; const BMessage* JobSettings() const { return &fJobSettings; } BRect PaperRect() const; BRect PrintableRect() const; diff --git a/src/add-ons/print/shared/PrintJobReader.cpp b/src/add-ons/print/shared/PrintJobReader.cpp index 19c1995f55..04bd665733 100644 --- a/src/add-ons/print/shared/PrintJobReader.cpp +++ b/src/add-ons/print/shared/PrintJobReader.cpp @@ -135,7 +135,6 @@ PrintJobReader::PrintJobReader(BFile* jobFile) if (fJobFile.Read(&header, sizeof(header)) == sizeof(header)) { if (fJobSettings.Unflatten(&fJobFile) == B_OK) { fNumberOfPages = header.page_count; - fFirstPage = header.first_page; fPageIndex = new off_t[fNumberOfPages]; BuildPageIndex(); @@ -189,6 +188,22 @@ status_t PrintJobReader::GetPage(int32 page, PrintJobPage& pjp) } +int32 PrintJobReader::FirstPage() const +{ + int32 firstPage = -1; + fJobSettings.FindInt32("first_page", &firstPage); + return firstPage; +} + + +int32 PrintJobReader::LastPage() const +{ + int32 lastPage = -1; + fJobSettings.FindInt32("last_page", &lastPage); + return lastPage; +} + + BRect PrintJobReader::PaperRect() const { BRect r; @@ -211,6 +226,7 @@ void PrintJobReader::GetResolution(int32 *xdpi, int32 *ydpi) const fJobSettings.FindInt32("yres", ydpi); } + float PrintJobReader::GetScale() const { float scale = 1.0;