Implemented copy number of pages for printers that do not support page copy command. Check if PrintToFile dialog was canceled and return without an error.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7072 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Pfeiffer 2004-03-27 07:08:38 +00:00
parent d3befe5f8a
commit 2c973bd1fc
4 changed files with 48 additions and 21 deletions

View File

@ -88,7 +88,10 @@ public:
kOrientation, kOrientation,
kPrintStyle, kPrintStyle,
kBindingLocation, kBindingLocation,
kColor kColor,
// Static boolean settings follow.
// For them isSupport() has to be implemented only.
kCopyCommand // supports printer page copy command?
}; };
virtual int countCap(CapID) const = 0; virtual int countCap(CapID) const = 0;

View File

@ -37,6 +37,7 @@ public:
~Transport(); ~Transport();
void write(const void *buffer, size_t size) throw(TransportException); void write(const void *buffer, size_t size) throw(TransportException);
bool check_abort() const; bool check_abort() const;
bool is_print_to_file_canceled() const;
const string &last_error() const; const string &last_error() const;
protected: protected:

View File

@ -421,31 +421,45 @@ bool GraphicsDriver::printDocument(SpoolData *spool_data)
PageData *page_data; PageData *page_data;
int page_index; int page_index;
int nup; int nup;
int copy;
int copies;
more = false; more = true;
success = true; success = true;
page_index = 0; page_index = 0;
if (fPrinterCap->isSupport(PrinterCap::kCopyCommand)) {
copies = 1;
} else {
copies = fRealJobData->getCopies();
}
if (spool_data->startEnum()) { if (spool_data->startEnum()) {
nup = fOrgJobData->getNup();
do { do {
DBGMSG(("page index = %d\n", page_index)); DBGMSG(("page index = %d\n", page_index));
if (!(success = startPage(page_index)))
break;
nup = fOrgJobData->getNup();
PageDataList pages; PageDataList pages;
do { do {
more = spool_data->enumObject(&page_data); more = spool_data->enumObject(&page_data);
pages.push_back(page_data); pages.push_back(page_data);
} while (more && --nup); } while (more && --nup);
// print each physical page "copies" of times
for (copy = 0; success && copy < copies; copy ++) {
success = startPage(page_index);
if (!success)
break;
fView->Window()->Lock(); fView->Window()->Lock();
success = printPage(&pages); success = printPage(&pages);
fView->Window()->Unlock(); fView->Window()->Unlock();
if (!success)
break; if (success) {
if (!(success = endPage(page_index))) success = endPage(page_index);
break; }
}
page_index++; page_index++;
} while (more); } while (success && more);
} }
#ifndef USE_PREVIEW_FOR_DEBUG #ifndef USE_PREVIEW_FOR_DEBUG
@ -454,12 +468,12 @@ bool GraphicsDriver::printDocument(SpoolData *spool_data)
&& (fOrgJobData->getPrintStyle() != JobData::kSimplex) && (fOrgJobData->getPrintStyle() != JobData::kSimplex)
&& (((page_index + fOrgJobData->getNup() - 1) / fOrgJobData->getNup()) % 2)) && (((page_index + fOrgJobData->getNup() - 1) / fOrgJobData->getNup()) % 2))
{ {
success = startPage(page_index); // print each physical page "copies" of times
if (success) { for (copy = 0; success && copy < copies; copy ++) {
success = printPage(NULL); success =
if (success) { startPage(page_index) &&
success = endPage(page_index); printPage(NULL) &&
} endPage(page_index);
} }
} }
#endif #endif
@ -487,7 +501,7 @@ bool GraphicsDriver::printJob(BFile *spool_file)
if (fTransport->check_abort()) { if (fTransport->check_abort()) {
success = false; success = false;
} else { } else if (!fTransport->is_print_to_file_canceled()) {
setupData(spool_file, pfh.page_count); setupData(spool_file, pfh.page_count);
setupBitmap(); setupBitmap();
SpoolData spool_data(spool_file, pfh.page_count, fOrgJobData->getNup(), fOrgJobData->getReverse()); SpoolData spool_data(spool_file, pfh.page_count, fOrgJobData->getNup(), fOrgJobData->getReverse());

View File

@ -7,6 +7,7 @@
#include <Message.h> #include <Message.h>
#include <Directory.h> #include <Directory.h>
#include <DataIO.h> #include <DataIO.h>
#include <File.h>
#include <Path.h> #include <Path.h>
#include <image.h> #include <image.h>
@ -93,6 +94,14 @@ const string &Transport::last_error() const
return fLastErrorString; return fLastErrorString;
} }
bool Transport::is_print_to_file_canceled() const
{
// The BeOS "Print To File" transport add-on returns a non-NULL BDataIO *
// even after user filepanel cancellation!
BFile* file = dynamic_cast<BFile*>(fDataStream);
return file != NULL && file->InitCheck() != B_OK;
}
void Transport::set_last_error(const char *e) void Transport::set_last_error(const char *e)
{ {
fLastErrorString = e; fLastErrorString = e;