* Code style changed in class GraphicsDriver and and

child classes
* Removed namespace handling for Metrowerks compiler
* Initialize all fields in constructor


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39765 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Pfeiffer
2010-12-08 10:22:40 +00:00
parent 9028c687fb
commit fefd3ba588
18 changed files with 871 additions and 793 deletions
+105 -71
View File
@@ -6,6 +6,7 @@
#ifndef __GRAPHICSDRIVER_H
#define __GRAPHICSDRIVER_H
#include "JobData.h"
#include "PrinterData.h"
#include "PrintProcess.h"
@@ -13,137 +14,170 @@
#include "Transport.h"
#include "StatusWindow.h"
class BView;
class BBitmap;
class BMessage;
class PrinterData;
class PrinterCap;
enum {
kGDFRotateBandBitmap = 1
};
class GraphicsDriver {
public:
GraphicsDriver(BMessage *, PrinterData *, const PrinterCap *);
virtual ~GraphicsDriver();
const JobData *getJobData(BFile *spoolFile);
BMessage *takeJob(BFile *spoolFile, uint32 flags = 0);
static BPoint getScale(int32 nup, BRect physicalRect, float scaling);
static BPoint getOffset(int32 nup, int index, JobData::Orientation orientation, const BPoint *scale,
BRect scaledPhysicalRect, BRect scaledPrintableRect, BRect physicalRect);
GraphicsDriver(BMessage* message, PrinterData* printerData,
const PrinterCap *printerCap);
virtual ~GraphicsDriver();
const JobData* GetJobData(BFile* spoolFile);
BMessage* TakeJob(BFile* spoolFile, uint32 flags = 0);
static BPoint GetScale(int32 nup, BRect physicalRect, float scaling);
static BPoint GetOffset(int32 nup, int index,
JobData::Orientation orientation, const BPoint* scale,
BRect scaledPhysicalRect, BRect scaledPrintableRect,
BRect physicalRect);
protected:
virtual bool startDoc();
virtual bool startPage(int page_number);
virtual bool nextBand(BBitmap *bitmap, BPoint *offset);
virtual bool endPage(int page_number);
virtual bool endDoc(bool success);
GraphicsDriver(const GraphicsDriver &);
void writeSpoolData(const void *buffer, size_t size) throw(TransportException);
void writeSpoolString(const char *buffer, ...) throw(TransportException);
void writeSpoolChar(char c) throw(TransportException);
GraphicsDriver& operator = (const GraphicsDriver &);
static void convert_to_rgb24(void* src, void* dst, int width, color_space cs);
static void convert_to_gray(void* src, void* dst, int width, color_space cs);
virtual bool StartDocument();
virtual bool StartPage(int page_number);
virtual bool NextBand(BBitmap* bitmap, BPoint* offset);
virtual bool EndPage(int page_number);
virtual bool EndDocument(bool success);
const JobData *getJobData() const;
const PrinterData *getPrinterData() const;
const PrinterCap *getPrinterCap() const;
const SpoolMetaData *getSpoolMetaData() const;
int getProtocolClass() const;
void WriteSpoolData(const void* buffer, size_t size)
throw (TransportException);
void WriteSpoolString(const char* buffer, ...)
throw (TransportException);
void WriteSpoolChar(char c)
throw (TransportException);
int getPageWidth() const;
int getPageHeight() const;
int getBandWidth() const;
int getBandHeight() const;
int getPixelDepth() const;
static void ConvertToRGB24(const void* src, void* dst, int width,
color_space cs);
static void ConvertToGray(const void* src, void* dst, int width,
color_space cs);
GraphicsDriver(const GraphicsDriver &);
GraphicsDriver &operator = (const GraphicsDriver &);
const JobData* GetJobData() const;
const PrinterData* GetPrinterData() const;
const PrinterCap* GetPrinterCap() const;
const SpoolMetaData* GetSpoolMetaData() const;
int GetProtocolClass() const;
int GetPageWidth() const;
int GetPageHeight() const;
int GetBandWidth() const;
int GetBandHeight() const;
int GetPixelDepth() const;
private:
bool setupData(BFile *file);
void setupBitmap();
void cleanupData();
void cleanupBitmap();
bool printPage(PageDataList *pages);
bool collectPages(SpoolData *spool_data, PageDataList *pages);
bool skipPages(SpoolData *spool_data);
bool printDocument(SpoolData *spool_data);
bool printJob(BFile *file);
static void rgb32_to_rgb24(void* src, void* dst, int width);
static void cmap8_to_rgb24(void* src, void* dst, int width);
static uint8 gray(uint8 r, uint8 g, uint8 b);
static void rgb32_to_gray(void* src, void* dst, int width);
static void cmap8_to_gray(void* src, void* dst, int width);
bool _SetupData(BFile* file);
void _SetupBitmap();
void _CleanupData();
void _CleanupBitmap();
bool _PrintPage(PageDataList* pages);
bool _CollectPages(SpoolData* spoolData, PageDataList* pages);
bool _SkipPages(SpoolData* spoolData);
bool _PrintDocument(SpoolData* spoolData);
bool PrintJob(BFile* file);
static void _ConvertRGB32ToRGB24(const void* src, void* dst, int width);
static void _ConvertCMAP8ToRGB24(const void* src, void* dst, int width);
static uint8 _ConvertToGray(uint8 r, uint8 g, uint8 b);
static void _ConvertRGB32ToGray(const void* src, void* dst, int width);
static void _ConvertCMAP8ToGray(const void* src, void* dst, int width);
uint32 fFlags;
BMessage *fMsg;
BView *fView;
BBitmap *fBitmap;
Transport *fTransport;
JobData *fOrgJobData;
JobData *fRealJobData;
PrinterData *fPrinterData;
const PrinterCap *fPrinterCap;
SpoolMetaData *fSpoolMetaData;
uint32 fFlags;
BMessage* fMessage;
BView* fView;
BBitmap* fBitmap;
Transport* fTransport;
JobData* fOrgJobData;
JobData* fRealJobData;
PrinterData* fPrinterData;
const PrinterCap* fPrinterCap;
SpoolMetaData* fSpoolMetaData;
int fPageWidth;
int fPageHeight;
int fBandWidth;
int fBandHeight;
int fPixelDepth;
int fBandCount;
int fInternalCopies;
int fPageWidth;
int fPageHeight;
int fBandWidth;
int fBandHeight;
int fPixelDepth;
int fBandCount;
int fInternalCopies;
uint32 fPageCount;
uint32 fPageCount;
StatusWindow *fStatusWindow;
StatusWindow* fStatusWindow;
};
inline const JobData *GraphicsDriver::getJobData() const
inline const JobData*
GraphicsDriver::GetJobData() const
{
return fRealJobData;
}
inline const PrinterData *GraphicsDriver::getPrinterData() const
inline const PrinterData*
GraphicsDriver::GetPrinterData() const
{
return fPrinterData;
}
inline const PrinterCap *GraphicsDriver::getPrinterCap() const
inline const PrinterCap*
GraphicsDriver::GetPrinterCap() const
{
return fPrinterCap;
}
inline const SpoolMetaData *GraphicsDriver::getSpoolMetaData() const
inline const SpoolMetaData*
GraphicsDriver::GetSpoolMetaData() const
{
return fSpoolMetaData;
}
inline int GraphicsDriver::getProtocolClass() const
inline int
GraphicsDriver::GetProtocolClass() const
{
return fPrinterData->getProtocolClass();
}
inline int GraphicsDriver::getPageWidth() const
inline int
GraphicsDriver::GetPageWidth() const
{
return fPageWidth;
}
inline int GraphicsDriver::getPageHeight() const
inline int
GraphicsDriver::GetPageHeight() const
{
return fPageHeight;
}
inline int GraphicsDriver::getBandWidth() const
inline int
GraphicsDriver::GetBandWidth() const
{
return fBandWidth;
}
inline int GraphicsDriver::getBandHeight() const
inline int
GraphicsDriver::GetBandHeight() const
{
return fBandHeight;
}
#endif /* __GRAPHICSDRIVER_H */
@@ -22,38 +22,31 @@
#include "ValidRect.h"
#if (!__MWERKS__ || defined(MSIPL_USING_NAMESPACE))
using namespace std;
#else
#define std
#endif
LIPS3Driver::LIPS3Driver(BMessage *msg, PrinterData *printer_data,
const PrinterCap *printer_cap)
LIPS3Driver::LIPS3Driver(BMessage* message, PrinterData* printerData,
const PrinterCap* printerCap)
:
GraphicsDriver(msg, printer_data, printer_cap)
GraphicsDriver(message, printerData, printerCap),
fHalftone(NULL)
{
fHalftone = NULL;
}
bool
LIPS3Driver::startDoc()
LIPS3Driver::StartDocument()
{
try {
beginTextMode();
jobStart();
softReset();
sizeUnitMode();
selectSizeUnit();
selectPageFormat();
paperFeedMode();
disableAutoFF();
setNumberOfCopies();
fHalftone = new Halftone(getJobData()->getSurfaceType(),
getJobData()->getGamma(), getJobData()->getInkDensity(),
getJobData()->getDitherType());
_BeginTextMode();
_JobStart();
_SoftReset();
_SizeUnitMode();
_SelectSizeUnit();
_SelectPageFormat();
_PaperFeedMode();
_DisableAutoFF();
_SetNumberOfCopies();
fHalftone = new Halftone(GetJobData()->getSurfaceType(),
GetJobData()->getGamma(), GetJobData()->getInkDensity(),
GetJobData()->getDitherType());
return true;
}
catch (TransportException& err) {
@@ -63,12 +56,12 @@ LIPS3Driver::startDoc()
bool
LIPS3Driver::startPage(int)
LIPS3Driver::StartPage(int)
{
try {
fCurrentX = 0;
fCurrentY = 0;
memorizedPosition();
_MemorizedPosition();
return true;
}
catch (TransportException& err) {
@@ -78,10 +71,10 @@ LIPS3Driver::startPage(int)
bool
LIPS3Driver::endPage(int)
LIPS3Driver::EndPage(int)
{
try {
formFeed();
_FormFeed();
return true;
}
catch (TransportException& err) {
@@ -91,13 +84,13 @@ LIPS3Driver::endPage(int)
bool
LIPS3Driver::endDoc(bool)
LIPS3Driver::EndDocument(bool)
{
try {
if (fHalftone) {
if (fHalftone)
delete fHalftone;
}
jobEnd();
_JobEnd();
return true;
}
catch (TransportException& err) {
@@ -107,7 +100,7 @@ LIPS3Driver::endDoc(bool)
bool
LIPS3Driver::nextBand(BBitmap* bitmap, BPoint* offset)
LIPS3Driver::NextBand(BBitmap* bitmap, BPoint* offset)
{
DBGMSG(("> nextBand\n"));
@@ -125,7 +118,7 @@ LIPS3Driver::nextBand(BBitmap* bitmap, BPoint* offset)
int x = (int)offset->x;
int y = (int)offset->y;
int page_height = getPageHeight();
int page_height = GetPageHeight();
if (y + height > page_height)
height = page_height - y;
@@ -165,8 +158,8 @@ LIPS3Driver::nextBand(BBitmap* bitmap, BPoint* offset)
+ rc.top * delta
+ (rc.left * fHalftone->getPixelDepth()) / 8;
int compression_method;
int compressed_size;
int compressionMethod;
int compressedSize;
const uchar* buffer;
uchar* in_buffer = new uchar[in_size];
@@ -179,7 +172,7 @@ LIPS3Driver::nextBand(BBitmap* bitmap, BPoint* offset)
DBGMSG(("move\n"));
move(x, y);
_Move(x, y);
for (int i = rc.top; i <= rc.bottom; i++) {
fHalftone->dither(ptr2, ptr, x, y, width);
@@ -188,33 +181,33 @@ LIPS3Driver::nextBand(BBitmap* bitmap, BPoint* offset)
y++;
}
compressed_size = compress3(out_buffer, in_buffer, in_size);
compressedSize = compress3(out_buffer, in_buffer, in_size);
if (compressed_size < in_size) {
compression_method = 9;
if (compressedSize < in_size) {
compressionMethod = 9;
// compress3
buffer = out_buffer;
} else if (compressed_size > out_size) {
} else if (compressedSize > out_size) {
BAlert* alert = new BAlert("memory overrun!!!", "warning",
"OK");
alert->Go();
return false;
} else {
compression_method = 0;
compressionMethod = 0;
buffer = in_buffer;
compressed_size = in_size;
compressedSize = in_size;
}
DBGMSG(("compressed_size = %d\n", compressed_size));
DBGMSG(("compressedSize = %d\n", compressedSize));
DBGMSG(("widthByte = %d\n", widthByte));
DBGMSG(("height = %d\n", height));
DBGMSG(("compression_method = %d\n", compression_method));
DBGMSG(("compression_method = %d\n", compressionMethod));
rasterGraphics(
compressed_size, // size,
_RasterGraphics(
compressedSize, // size,
widthByte, // widthByte
height, // height,
compression_method,
compressionMethod,
buffer);
} else
@@ -238,48 +231,48 @@ LIPS3Driver::nextBand(BBitmap* bitmap, BPoint* offset)
void
LIPS3Driver::beginTextMode()
LIPS3Driver::_BeginTextMode()
{
writeSpoolString("\033%%@");
WriteSpoolString("\033%%@");
}
void
LIPS3Driver::jobStart()
LIPS3Driver::_JobStart()
{
writeSpoolString("\033P31;300;1J\033\\");
WriteSpoolString("\033P31;300;1J\033\\");
}
void
LIPS3Driver::softReset()
LIPS3Driver::_SoftReset()
{
writeSpoolString("\033<");
WriteSpoolString("\033<");
}
void
LIPS3Driver::sizeUnitMode()
LIPS3Driver::_SizeUnitMode()
{
writeSpoolString("\033[11h");
WriteSpoolString("\033[11h");
}
void
LIPS3Driver::selectSizeUnit()
LIPS3Driver::_SelectSizeUnit()
{
writeSpoolString("\033[7 I");
WriteSpoolString("\033[7 I");
}
void
LIPS3Driver::selectPageFormat()
LIPS3Driver::_SelectPageFormat()
{
int i;
int width = 0;
int height = 0;
switch (getJobData()->getPaper()) {
switch (GetJobData()->getPaper()) {
case JobData::kA3:
i = 12;
break;
@@ -326,23 +319,23 @@ LIPS3Driver::selectPageFormat()
//
default:
i = 80;
width = getJobData()->getPaperRect().IntegerWidth();
height = getJobData()->getPaperRect().IntegerHeight();
width = GetJobData()->getPaperRect().IntegerWidth();
height = GetJobData()->getPaperRect().IntegerHeight();
break;
}
if (JobData::kLandscape == getJobData()->getOrientation())
if (JobData::kLandscape == GetJobData()->getOrientation())
i++;
if (i < 80)
writeSpoolString("\033[%d;;p", i);
WriteSpoolString("\033[%d;;p", i);
else
writeSpoolString("\033[%d;%d;%dp", i, height, width);
WriteSpoolString("\033[%d;%d;%dp", i, height, width);
}
void
LIPS3Driver::paperFeedMode()
LIPS3Driver::_PaperFeedMode()
{
// 0 auto
// --------------
@@ -361,7 +354,7 @@ LIPS3Driver::paperFeedMode()
int i;
switch (getJobData()->getPaperSource()) {
switch (GetJobData()->getPaperSource()) {
case JobData::kManual:
i = 1;
break;
@@ -377,93 +370,93 @@ LIPS3Driver::paperFeedMode()
break;
}
writeSpoolString("\033[%dq", i);
WriteSpoolString("\033[%dq", i);
}
void
LIPS3Driver::disableAutoFF()
LIPS3Driver::_DisableAutoFF()
{
writeSpoolString("\033[?2h");
WriteSpoolString("\033[?2h");
}
void
LIPS3Driver::setNumberOfCopies()
LIPS3Driver::_SetNumberOfCopies()
{
writeSpoolString("\033[%ldv", getJobData()->getCopies());
WriteSpoolString("\033[%ldv", GetJobData()->getCopies());
}
void
LIPS3Driver::memorizedPosition()
LIPS3Driver::_MemorizedPosition()
{
writeSpoolString("\033[0;1;0x");
WriteSpoolString("\033[0;1;0x");
}
void
LIPS3Driver::moveAbsoluteHorizontal(int x)
LIPS3Driver::_MoveAbsoluteHorizontal(int x)
{
writeSpoolString("\033[%d`", x);
WriteSpoolString("\033[%d`", x);
}
void
LIPS3Driver::carriageReturn()
LIPS3Driver::_CarriageReturn()
{
writeSpoolChar('\x0d');
WriteSpoolChar('\x0d');
}
void
LIPS3Driver::moveDown(int dy)
LIPS3Driver::_MoveDown(int dy)
{
writeSpoolString("\033[%de", dy);
WriteSpoolString("\033[%de", dy);
}
void
LIPS3Driver::rasterGraphics( int compression_size, int widthbyte, int height,
int compression_method, const uchar *buffer)
LIPS3Driver::_RasterGraphics( int compressionSize, int widthbyte, int height,
int compressionMethod, const uchar* buffer)
{
// 0 RAW
// 9 compress-3
writeSpoolString("\033[%d;%d;%d;%d;%d.r", compression_size, widthbyte,
getJobData()->getXres(), compression_method, height);
WriteSpoolString("\033[%d;%d;%d;%d;%d.r", compressionSize, widthbyte,
GetJobData()->getXres(), compressionMethod, height);
writeSpoolData(buffer, compression_size);
WriteSpoolData(buffer, compressionSize);
}
void
LIPS3Driver::formFeed()
LIPS3Driver::_FormFeed()
{
writeSpoolChar('\014');
WriteSpoolChar('\014');
}
void
LIPS3Driver::jobEnd()
LIPS3Driver::_JobEnd()
{
writeSpoolString("\033P0J\033\\");
WriteSpoolString("\033P0J\033\\");
}
void
LIPS3Driver::move(int x, int y)
LIPS3Driver::_Move(int x, int y)
{
if (fCurrentX != x) {
if (x)
moveAbsoluteHorizontal(x);
_MoveAbsoluteHorizontal(x);
else
carriageReturn();
_CarriageReturn();
fCurrentX = x;
}
if (fCurrentY != y) {
int dy = y - fCurrentY;
moveDown(dy);
_MoveDown(dy);
fCurrentY = y;
}
}
@@ -18,31 +18,31 @@ public:
const PrinterCap* printer_cap);
protected:
virtual bool startDoc();
virtual bool startPage(int page);
virtual bool nextBand(BBitmap *bitmap, BPoint *offset);
virtual bool endPage(int page);
virtual bool endDoc(bool success);
virtual bool StartDocument();
virtual bool StartPage(int page);
virtual bool NextBand(BBitmap *bitmap, BPoint *offset);
virtual bool EndPage(int page);
virtual bool EndDocument(bool success);
private:
void move(int x, int y);
void beginTextMode();
void jobStart();
void softReset();
void sizeUnitMode();
void selectSizeUnit();
void paperFeedMode();
void selectPageFormat();
void disableAutoFF();
void setNumberOfCopies();
void memorizedPosition();
void moveAbsoluteHorizontal(int x);
void carriageReturn();
void moveDown(int dy);
void rasterGraphics(int size, int widthbyte, int height,
void _Move(int x, int y);
void _BeginTextMode();
void _JobStart();
void _SoftReset();
void _SizeUnitMode();
void _SelectSizeUnit();
void _PaperFeedMode();
void _SelectPageFormat();
void _DisableAutoFF();
void _SetNumberOfCopies();
void _MemorizedPosition();
void _MoveAbsoluteHorizontal(int x);
void _CarriageReturn();
void _MoveDown(int dy);
void _RasterGraphics(int size, int widthbyte, int height,
int compression_method, const uchar* buffer);
void formFeed();
void jobEnd();
void _FormFeed();
void _JobEnd();
int fCurrentX;
int fCurrentY;
@@ -20,41 +20,35 @@
#include "PrinterData.h"
#include "ValidRect.h"
#if (!__MWERKS__ || defined(MSIPL_USING_NAMESPACE))
using namespace std;
#else
#define std
#endif
LIPS4Driver::LIPS4Driver(BMessage* msg, PrinterData* printer_data,
const PrinterCap *printer_cap)
LIPS4Driver::LIPS4Driver(BMessage* message, PrinterData* printerData,
const PrinterCap* printerCap)
:
GraphicsDriver(msg, printer_data, printer_cap)
GraphicsDriver(message, printerData, printerCap),
fHalftone(NULL)
{
fHalftone = NULL;
}
bool
LIPS4Driver::startDoc()
LIPS4Driver::StartDocument()
{
try {
beginTextMode();
jobStart();
colorModeDeclaration();
softReset();
sizeUnitMode();
selectSizeUnit();
paperFeedMode();
selectPageFormat();
disableAutoFF();
setNumberOfCopies();
sidePrintingControl();
setBindingMargin();
fHalftone = new Halftone(getJobData()->getSurfaceType(),
getJobData()->getGamma(), getJobData()->getInkDensity(),
getJobData()->getDitherType());
_BeginTextMode();
_JobStart();
_ColorModeDeclaration();
_SoftReset();
_SizeUnitMode();
_SelectSizeUnit();
_PaperFeedMode();
_SelectPageFormat();
_DisableAutoFF();
_SetNumberOfCopies();
_SidePrintingControl();
_SetBindingMargin();
fHalftone = new Halftone(GetJobData()->getSurfaceType(),
GetJobData()->getGamma(), GetJobData()->getInkDensity(),
GetJobData()->getDitherType());
return true;
}
catch (TransportException& err) {
@@ -64,12 +58,12 @@ LIPS4Driver::startDoc()
bool
LIPS4Driver::startPage(int)
LIPS4Driver::StartPage(int)
{
try {
fCurrentX = 0;
fCurrentY = 0;
memorizedPosition();
_MemorizedPosition();
return true;
}
catch (TransportException& err) {
@@ -79,10 +73,10 @@ LIPS4Driver::startPage(int)
bool
LIPS4Driver::endPage(int)
LIPS4Driver::EndPage(int)
{
try {
formFeed();
_FormFeed();
return true;
}
catch (TransportException& err) {
@@ -92,13 +86,13 @@ LIPS4Driver::endPage(int)
bool
LIPS4Driver::endDoc(bool)
LIPS4Driver::EndDocument(bool)
{
try {
if (fHalftone)
delete fHalftone;
jobEnd();
_JobEnd();
return true;
}
catch (TransportException& err) {
@@ -108,7 +102,7 @@ LIPS4Driver::endDoc(bool)
bool
LIPS4Driver::nextBand(BBitmap* bitmap, BPoint* offset)
LIPS4Driver::NextBand(BBitmap* bitmap, BPoint* offset)
{
DBGMSG(("> nextBand\n"));
@@ -117,7 +111,7 @@ LIPS4Driver::nextBand(BBitmap* bitmap, BPoint* offset)
if (bitmap == NULL) {
uchar dummy[1];
dummy[0] = '\0';
rasterGraphics(1, 1, 1, 0, dummy);
_RasterGraphics(1, 1, 1, 0, dummy);
DBGMSG(("< next_band\n"));
return true;
}
@@ -135,7 +129,7 @@ LIPS4Driver::nextBand(BBitmap* bitmap, BPoint* offset)
int x = (int)offset->x;
int y = (int)offset->y;
int page_height = getPageHeight();
int page_height = GetPageHeight();
if (y + height > page_height)
height = page_height - y;
@@ -188,7 +182,7 @@ LIPS4Driver::nextBand(BBitmap* bitmap, BPoint* offset)
DBGMSG(("move\n"));
move(x, y);
_Move(x, y);
for (int i = rc.top; i <= rc.bottom; i++) {
fHalftone->dither(ptr2, ptr, x, y, width);
@@ -219,7 +213,7 @@ LIPS4Driver::nextBand(BBitmap* bitmap, BPoint* offset)
DBGMSG(("height = %d\n", height));
DBGMSG(("compression_method = %d\n", compression_method));
rasterGraphics(
_RasterGraphics(
compressed_size, // size,
widthByte, // widthByte
height, // height,
@@ -247,52 +241,52 @@ LIPS4Driver::nextBand(BBitmap* bitmap, BPoint* offset)
void
LIPS4Driver::beginTextMode()
LIPS4Driver::_BeginTextMode()
{
writeSpoolString("\033%%@");
WriteSpoolString("\033%%@");
}
void
LIPS4Driver::jobStart()
LIPS4Driver::_JobStart()
{
writeSpoolString("\033P41;%d;1J\033\\", getJobData()->getXres());
WriteSpoolString("\033P41;%d;1J\033\\", GetJobData()->getXres());
}
void
LIPS4Driver::colorModeDeclaration()
LIPS4Driver::_ColorModeDeclaration()
{
// if (color)
// writeSpoolString("\033[1\"p");
// WriteSpoolString("\033[1\"p");
// else
writeSpoolString("\033[0\"p");
WriteSpoolString("\033[0\"p");
}
void
LIPS4Driver::softReset()
LIPS4Driver::_SoftReset()
{
writeSpoolString("\033<");
WriteSpoolString("\033<");
}
void
LIPS4Driver::sizeUnitMode()
LIPS4Driver::_SizeUnitMode()
{
writeSpoolString("\033[11h");
WriteSpoolString("\033[11h");
}
void
LIPS4Driver::selectSizeUnit()
LIPS4Driver::_SelectSizeUnit()
{
writeSpoolString("\033[?7;%d I", getJobData()->getXres());
WriteSpoolString("\033[?7;%d I", GetJobData()->getXres());
}
void
LIPS4Driver::paperFeedMode()
LIPS4Driver::_PaperFeedMode()
{
// 0 auto
// --------------
@@ -311,7 +305,7 @@ LIPS4Driver::paperFeedMode()
int i;
switch (getJobData()->getPaperSource()) {
switch (GetJobData()->getPaperSource()) {
case JobData::kManual:
i = 10;
break;
@@ -330,16 +324,16 @@ LIPS4Driver::paperFeedMode()
break;
}
writeSpoolString("\033[%dq", i);
WriteSpoolString("\033[%dq", i);
}
void
LIPS4Driver::selectPageFormat()
LIPS4Driver::_SelectPageFormat()
{
int i;
switch (getJobData()->getPaper()) {
switch (GetJobData()->getPaper()) {
case JobData::kA3:
i = 12;
break;
@@ -389,41 +383,41 @@ LIPS4Driver::selectPageFormat()
break;
}
if (JobData::kLandscape == getJobData()->getOrientation())
if (JobData::kLandscape == GetJobData()->getOrientation())
i++;
writeSpoolString("\033[%d;;p", i);
WriteSpoolString("\033[%d;;p", i);
}
void
LIPS4Driver::disableAutoFF()
LIPS4Driver::_DisableAutoFF()
{
writeSpoolString("\033[?2h");
WriteSpoolString("\033[?2h");
}
void
LIPS4Driver::setNumberOfCopies()
LIPS4Driver::_SetNumberOfCopies()
{
writeSpoolString("\033[%ldv", getJobData()->getCopies());
WriteSpoolString("\033[%ldv", GetJobData()->getCopies());
}
void
LIPS4Driver::sidePrintingControl()
LIPS4Driver::_SidePrintingControl()
{
if (getJobData()->getPrintStyle() == JobData::kSimplex)
writeSpoolString("\033[0#x");
if (GetJobData()->getPrintStyle() == JobData::kSimplex)
WriteSpoolString("\033[0#x");
else
writeSpoolString("\033[2;0#x");
WriteSpoolString("\033[2;0#x");
}
void
LIPS4Driver::setBindingMargin()
LIPS4Driver::_SetBindingMargin()
{
if (getJobData()->getPrintStyle() == JobData::kDuplex) {
if (GetJobData()->getPrintStyle() == JobData::kDuplex) {
int i;
// switch (job_data()->binding_location()) {
// case kLongEdgeLeft:
@@ -439,87 +433,87 @@ LIPS4Driver::setBindingMargin()
// i = 3;
// break;
// }
writeSpoolString("\033[%d;0#w", i);
WriteSpoolString("\033[%d;0#w", i);
}
}
void
LIPS4Driver::memorizedPosition()
LIPS4Driver::_MemorizedPosition()
{
writeSpoolString("\033[0;1;0x");
WriteSpoolString("\033[0;1;0x");
}
void
LIPS4Driver::moveAbsoluteHorizontal(int x)
LIPS4Driver::_MoveAbsoluteHorizontal(int x)
{
writeSpoolString("\033[%ld`", x);
WriteSpoolString("\033[%ld`", x);
}
void
LIPS4Driver::carriageReturn()
LIPS4Driver::_CarriageReturn()
{
writeSpoolChar('\x0d');
WriteSpoolChar('\x0d');
}
void
LIPS4Driver::moveDown(int dy)
LIPS4Driver::_MoveDown(int dy)
{
writeSpoolString("\033[%lde", dy);
WriteSpoolString("\033[%lde", dy);
}
void
LIPS4Driver::rasterGraphics(int compression_size, int widthbyte, int height,
LIPS4Driver::_RasterGraphics(int compression_size, int widthbyte, int height,
int compression_method, const uchar* buffer)
{
// 0 RAW
// 10 RLE
// 11 packbits
writeSpoolString(
WriteSpoolString(
"\033[%ld;%ld;%d;%ld;%ld.r",
compression_size,
widthbyte,
getJobData()->getXres(),
GetJobData()->getXres(),
compression_method,
height);
writeSpoolData(buffer, compression_size);
WriteSpoolData(buffer, compression_size);
}
void
LIPS4Driver::formFeed()
LIPS4Driver::_FormFeed()
{
writeSpoolChar('\014');
WriteSpoolChar('\014');
}
void
LIPS4Driver::jobEnd()
LIPS4Driver::_JobEnd()
{
writeSpoolString("\033P0J\033\\");
WriteSpoolString("\033P0J\033\\");
}
void
LIPS4Driver::move(int x, int y)
LIPS4Driver::_Move(int x, int y)
{
if (fCurrentX != x) {
if (x) {
moveAbsoluteHorizontal(x);
_MoveAbsoluteHorizontal(x);
} else {
carriageReturn();
_CarriageReturn();
}
fCurrentX = x;
}
if (fCurrentY != y) {
int dy = y - fCurrentY;
moveDown(dy);
_MoveDown(dy);
fCurrentY = y;
}
}
@@ -14,37 +14,39 @@ class Halftone;
class LIPS4Driver : public GraphicsDriver {
public:
LIPS4Driver(BMessage *msg, PrinterData *printer_data, const PrinterCap *cap);
LIPS4Driver(BMessage* message,
PrinterData* printerData,
const PrinterCap* printerCap);
protected:
virtual bool startDoc();
virtual bool startPage(int page);
virtual bool nextBand(BBitmap *bitmap, BPoint *offset);
virtual bool endPage(int page);
virtual bool endDoc(bool success);
virtual bool StartDocument();
virtual bool StartPage(int page);
virtual bool NextBand(BBitmap* bitmap, BPoint* offset);
virtual bool EndPage(int page);
virtual bool EndDocument(bool success);
private:
void move(int x, int y);
void beginTextMode();
void jobStart();
void colorModeDeclaration();
void softReset();
void sizeUnitMode();
void selectSizeUnit();
void paperFeedMode();
void selectPageFormat();
void disableAutoFF();
void setNumberOfCopies();
void sidePrintingControl();
void setBindingMargin();
void memorizedPosition();
void moveAbsoluteHorizontal(int x);
void carriageReturn();
void moveDown(int dy);
void rasterGraphics(int size, int widthbyte, int height,
int compression_method, const uchar* buffer);
void formFeed();
void jobEnd();
void _Move(int x, int y);
void _BeginTextMode();
void _JobStart();
void _ColorModeDeclaration();
void _SoftReset();
void _SizeUnitMode();
void _SelectSizeUnit();
void _PaperFeedMode();
void _SelectPageFormat();
void _DisableAutoFF();
void _SetNumberOfCopies();
void _SidePrintingControl();
void _SetBindingMargin();
void _MemorizedPosition();
void _MoveAbsoluteHorizontal(int x);
void _CarriageReturn();
void _MoveDown(int dy);
void _RasterGraphics(int size, int widthbyte, int height,
int compressionMethod, const uchar* buffer);
void _FormFeed();
void _JobEnd();
int fCurrentX;
int fCurrentY;
@@ -28,44 +28,44 @@
using namespace std;
GPDriver::GPDriver(BMessage* msg, PrinterData* printer_data,
const PrinterCap* printer_cap)
GPDriver::GPDriver(BMessage* message, PrinterData* printerData,
const PrinterCap* printerCap)
:
GraphicsDriver(msg, printer_data, printer_cap)
GraphicsDriver(message, printerData, printerCap)
{
}
void
GPDriver::Write(const void *buffer, size_t size)
throw(TransportException)
GPDriver::Write(const void* buffer, size_t size)
throw (TransportException)
{
writeSpoolData(buffer, size);
WriteSpoolData(buffer, size);
}
bool
GPDriver::startDoc()
GPDriver::StartDocument()
{
try {
const GPData* data = dynamic_cast<const GPData*>(getPrinterData());
const GPData* data = dynamic_cast<const GPData*>(GetPrinterData());
ASSERT(data != NULL);
fConfiguration.fDriver = data->fGutenprintDriverName;
SetParameter(fConfiguration.fPageSize, PrinterCap::kPaper,
getJobData()->getPaper());
GetJobData()->getPaper());
SetParameter(fConfiguration.fResolution, PrinterCap::kResolution,
getJobData()->getResolutionID());
GetJobData()->getResolutionID());
fConfiguration.fXDPI = getJobData()->getXres();
fConfiguration.fYDPI = getJobData()->getYres();
fConfiguration.fXDPI = GetJobData()->getXres();
fConfiguration.fYDPI = GetJobData()->getYres();
SetParameter(fConfiguration.fInputSlot, PrinterCap::kPaperSource,
getJobData()->getPaperSource());
GetJobData()->getPaperSource());
SetParameter(fConfiguration.fPrintingMode, PrinterCap::kColor,
getJobData()->getColor());
GetJobData()->getColor());
if (getPrinterCap()->isSupport(PrinterCap::kDriverSpecificCapabilities))
if (GetPrinterCap()->isSupport(PrinterCap::kDriverSpecificCapabilities))
SetDriverSpecificSettings();
fprintf(stderr, "Driver: %s\n", fConfiguration.fDriver.String());
@@ -87,7 +87,7 @@ GPDriver::SetParameter(BString& parameter, PrinterCap::CapID category,
int value)
{
const EnumCap* capability;
capability = getPrinterCap()->findCap(category, value);
capability = GetPrinterCap()->findCap(category, value);
if (capability != NULL && capability->fKey != "")
parameter = capability->Key();
}
@@ -97,8 +97,8 @@ void
GPDriver::SetDriverSpecificSettings()
{
PrinterCap::CapID category = PrinterCap::kDriverSpecificCapabilities;
int count = getPrinterCap()->countCap(category);
const BaseCap** capabilities = getPrinterCap()->enumCap(category);
int count = GetPrinterCap()->countCap(category);
const BaseCap** capabilities = GetPrinterCap()->enumCap(category);
for (int i = 0; i < count; i++) {
const DriverSpecificCap* capability =
dynamic_cast<const DriverSpecificCap*>(capabilities[i]);
@@ -134,16 +134,16 @@ GPDriver::SetDriverSpecificSettings()
void
GPDriver::AddDriverSpecificSetting(PrinterCap::CapID category, const char* key) {
const EnumCap* capability = NULL;
if (getJobData()->Settings().HasString(key))
if (GetJobData()->Settings().HasString(key))
{
const string& value = getJobData()->Settings().GetString(key);
capability = getPrinterCap()->findCapWithKey(category, value.c_str());
const string& value = GetJobData()->Settings().GetString(key);
capability = GetPrinterCap()->findCapWithKey(category, value.c_str());
}
if (capability == NULL) {
// job data should contain a value;
// try to use the default value anyway
capability = getPrinterCap()->getDefaultCap(category);
capability = GetPrinterCap()->getDefaultCap(category);
}
if (capability == NULL) {
@@ -158,41 +158,41 @@ GPDriver::AddDriverSpecificSetting(PrinterCap::CapID category, const char* key)
void
GPDriver::AddDriverSpecificBooleanSetting(PrinterCap::CapID category,
const char* key) {
if (getJobData()->Settings().HasBoolean(key))
if (GetJobData()->Settings().HasBoolean(key))
fConfiguration.fBooleanSettings[key] =
getJobData()->Settings().GetBoolean(key);
GetJobData()->Settings().GetBoolean(key);
}
void
GPDriver::AddDriverSpecificIntSetting(PrinterCap::CapID category,
const char* key) {
if (getJobData()->Settings().HasInt(key))
if (GetJobData()->Settings().HasInt(key))
fConfiguration.fIntSettings[key] =
getJobData()->Settings().GetInt(key);
GetJobData()->Settings().GetInt(key);
}
void
GPDriver::AddDriverSpecificDimensionSetting(PrinterCap::CapID category,
const char* key) {
if (getJobData()->Settings().HasInt(key))
if (GetJobData()->Settings().HasInt(key))
fConfiguration.fDimensionSettings[key] =
getJobData()->Settings().GetInt(key);
GetJobData()->Settings().GetInt(key);
}
void
GPDriver::AddDriverSpecificDoubleSetting(PrinterCap::CapID category,
const char* key) {
if (getJobData()->Settings().HasDouble(key))
if (GetJobData()->Settings().HasDouble(key))
fConfiguration.fDoubleSettings[key] =
getJobData()->Settings().GetDouble(key);
GetJobData()->Settings().GetDouble(key);
}
bool
GPDriver::startPage(int)
GPDriver::StartPage(int)
{
fBinding.BeginPage();
return true;
@@ -200,7 +200,7 @@ GPDriver::startPage(int)
bool
GPDriver::endPage(int)
GPDriver::EndPage(int)
{
try {
fBinding.EndPage();
@@ -214,7 +214,7 @@ GPDriver::endPage(int)
bool
GPDriver::endDoc(bool)
GPDriver::EndDocument(bool)
{
try {
fBinding.EndJob();
@@ -228,7 +228,7 @@ GPDriver::endDoc(bool)
bool
GPDriver::nextBand(BBitmap* bitmap, BPoint* offset)
GPDriver::NextBand(BBitmap* bitmap, BPoint* offset)
{
DBGMSG(("> nextBand\n"));
try {
@@ -245,10 +245,10 @@ GPDriver::nextBand(BBitmap* bitmap, BPoint* offset)
int x = (int)offset->x;
int y = (int)offset->y;
int page_height = getPageHeight();
int pageHeight = GetPageHeight();
if (y + height > page_height)
height = page_height - y;
if (y + height > pageHeight)
height = pageHeight - y;
rc.bottom = height - 1;
@@ -284,7 +284,7 @@ GPDriver::nextBand(BBitmap* bitmap, BPoint* offset)
DBGMSG(("band bitmap is empty.\n"));
}
if (y >= page_height) {
if (y >= pageHeight) {
offset->x = -1.0;
offset->y = -1.0;
} else
@@ -24,7 +24,7 @@ public:
throw(TransportException);
protected:
bool startDoc();
bool StartDocument();
void SetParameter(BString& parameter, PrinterCap::CapID category,
int value);
void SetDriverSpecificSettings();
@@ -38,10 +38,10 @@ protected:
const char* key);
void AddDriverSpecificDoubleSetting(PrinterCap::CapID category,
const char* key);
bool startPage(int page);
bool nextBand(BBitmap* bitmap, BPoint* offset);
bool endPage(int page);
bool endDoc(bool success);
bool StartPage(int page);
bool NextBand(BBitmap* bitmap, BPoint* offset);
bool EndPage(int page);
bool EndDocument(bool success);
void ShowError(const char* message);
private:
+71 -76
View File
@@ -23,30 +23,24 @@
#include "ValidRect.h"
#if (!__MWERKS__ || defined(MSIPL_USING_NAMESPACE))
using namespace std;
#else
#define std
#endif
PCL5Driver::PCL5Driver(BMessage* msg, PrinterData* printer_data,
const PrinterCap* printer_cap)
PCL5Driver::PCL5Driver(BMessage* message, PrinterData* printerData,
const PrinterCap* printerCap)
:
GraphicsDriver(msg, printer_data, printer_cap)
GraphicsDriver(message, printerData, printerCap),
fCompressionMethod(0),
fHalftone(NULL)
{
fHalftone = NULL;
}
bool
PCL5Driver::startDoc()
PCL5Driver::StartDocument()
{
try {
jobStart();
fHalftone = new Halftone(getJobData()->getSurfaceType(),
getJobData()->getGamma(), getJobData()->getInkDensity(),
getJobData()->getDitherType());
_JobStart();
fHalftone = new Halftone(GetJobData()->getSurfaceType(),
GetJobData()->getGamma(), GetJobData()->getInkDensity(),
GetJobData()->getDitherType());
return true;
}
catch (TransportException& err) {
@@ -56,17 +50,17 @@ PCL5Driver::startDoc()
bool
PCL5Driver::startPage(int)
PCL5Driver::StartPage(int)
{
return true;
}
bool
PCL5Driver::endPage(int)
PCL5Driver::EndPage(int)
{
try {
writeSpoolChar('\014');
WriteSpoolChar('\014');
return true;
}
catch (TransportException& err) {
@@ -76,13 +70,14 @@ PCL5Driver::endPage(int)
bool
PCL5Driver::endDoc(bool)
PCL5Driver::EndDocument(bool)
{
try {
if (fHalftone) {
if (fHalftone != NULL) {
delete fHalftone;
fHalftone = NULL;
}
jobEnd();
_JobEnd();
return true;
}
catch (TransportException& err) {
@@ -92,7 +87,7 @@ PCL5Driver::endDoc(bool)
bool
PCL5Driver::nextBand(BBitmap* bitmap, BPoint* offset)
PCL5Driver::NextBand(BBitmap* bitmap, BPoint* offset)
{
DBGMSG(("> nextBand\n"));
@@ -110,10 +105,10 @@ PCL5Driver::nextBand(BBitmap* bitmap, BPoint* offset)
int x = (int)offset->x;
int y = (int)offset->y;
int page_height = getPageHeight();
int pageHeight = GetPageHeight();
if (y + height > page_height)
height = page_height - y;
if (y + height > pageHeight)
height = pageHeight - y;
rc.bottom = height - 1;
@@ -149,8 +144,8 @@ PCL5Driver::nextBand(BBitmap* bitmap, BPoint* offset)
+ rc.top * delta
+ (rc.left * fHalftone->getPixelDepth()) / 8;
int compression_method;
int compressed_size;
int compressionMethod;
int compressedSize;
const uchar* buffer;
uchar* in_buffer = new uchar[in_size];
@@ -161,10 +156,10 @@ PCL5Driver::nextBand(BBitmap* bitmap, BPoint* offset)
DBGMSG(("move\n"));
move(x, y);
startRasterGraphics(width, height);
_Move(x, y);
_StartRasterGraphics(width, height);
const bool color = getJobData()->getColor() == JobData::kColor;
const bool color = GetJobData()->getColor() == JobData::kColor;
const int num_planes = color ? 3 : 1;
if (color) {
@@ -178,22 +173,22 @@ PCL5Driver::nextBand(BBitmap* bitmap, BPoint* offset)
fHalftone->dither(in_buffer, ptr, x, y, width);
compressed_size = pack_bits(out_buffer, in_buffer, in_size);
compressedSize = pack_bits(out_buffer, in_buffer, in_size);
if (compressed_size + bytesToEnterCompressionMethod(2)
< in_size + bytesToEnterCompressionMethod(0)) {
compression_method = 2; // back bits
if (compressedSize + _BytesToEnterCompressionMethod(2)
< in_size + _BytesToEnterCompressionMethod(0)) {
compressionMethod = 2; // back bits
buffer = out_buffer;
} else {
compression_method = 0; // uncompressed
compressionMethod = 0; // uncompressed
buffer = in_buffer;
compressed_size = in_size;
compressedSize = in_size;
}
rasterGraphics(
compression_method,
_RasterGraphics(
compressionMethod,
buffer,
compressed_size,
compressedSize,
plane == num_planes - 1);
}
@@ -202,12 +197,12 @@ PCL5Driver::nextBand(BBitmap* bitmap, BPoint* offset)
y++;
}
endRasterGraphics();
_EndRasterGraphics();
} else
DBGMSG(("band bitmap is clean.\n"));
if (y >= page_height) {
if (y >= pageHeight) {
offset->x = -1.0;
offset->y = -1.0;
} else
@@ -225,93 +220,93 @@ PCL5Driver::nextBand(BBitmap* bitmap, BPoint* offset)
void
PCL5Driver::jobStart()
PCL5Driver::_JobStart()
{
const bool color = getJobData()->getColor() == JobData::kColor;
const bool color = GetJobData()->getColor() == JobData::kColor;
// enter PCL5
writeSpoolString("\033%%-12345X@PJL ENTER LANGUAGE=PCL\n");
WriteSpoolString("\033%%-12345X@PJL ENTER LANGUAGE=PCL\n");
// reset
writeSpoolString("\033E");
WriteSpoolString("\033E");
// dpi
writeSpoolString("\033*t%dR", getJobData()->getXres());
WriteSpoolString("\033*t%dR", GetJobData()->getXres());
// unit of measure
writeSpoolString("\033&u%dD", getJobData()->getXres());
WriteSpoolString("\033&u%dD", GetJobData()->getXres());
// page size
writeSpoolString("\033&l0A");
WriteSpoolString("\033&l0A");
// page orientation
writeSpoolString("\033&l0O");
WriteSpoolString("\033&l0O");
if (color) {
// 3 color planes (red, green, blue)
writeSpoolString("\033*r3U");
WriteSpoolString("\033*r3U");
}
// raster presentation
writeSpoolString("\033*r0F");
WriteSpoolString("\033*r0F");
// top maring and perforation skip
writeSpoolString("\033&l0e0L");
WriteSpoolString("\033&l0e0L");
// clear horizontal margins
writeSpoolString("\0339");
WriteSpoolString("\0339");
// number of copies
// writeSpoolString("\033&l%ldL", getJobData()->getCopies());
// WriteSpoolString("\033&l%ldL", GetJobData()->getCopies());
}
void
PCL5Driver::startRasterGraphics(int width, int height)
PCL5Driver::_StartRasterGraphics(int width, int height)
{
// width
writeSpoolString("\033*r%dS", width);
WriteSpoolString("\033*r%dS", width);
// height
writeSpoolString("\033*r%dT", height);
WriteSpoolString("\033*r%dT", height);
// start raster graphics
writeSpoolString("\033*r1A");
WriteSpoolString("\033*r1A");
fCompressionMethod = -1;
}
void
PCL5Driver::endRasterGraphics()
PCL5Driver::_EndRasterGraphics()
{
writeSpoolString("\033*rB");
WriteSpoolString("\033*rB");
}
void
PCL5Driver::rasterGraphics(int compression_method, const uchar* buffer,
PCL5Driver::_RasterGraphics(int compressionMethod, const uchar* buffer,
int size, bool lastPlane)
{
if (fCompressionMethod != compression_method) {
writeSpoolString("\033*b%dM", compression_method);
fCompressionMethod = compression_method;
if (fCompressionMethod != compressionMethod) {
WriteSpoolString("\033*b%dM", compressionMethod);
fCompressionMethod = compressionMethod;
}
writeSpoolString("\033*b%d", size);
WriteSpoolString("\033*b%d", size);
if (lastPlane)
writeSpoolString("W");
WriteSpoolString("W");
else
writeSpoolString("V");
WriteSpoolString("V");
writeSpoolData(buffer, size);
WriteSpoolData(buffer, size);
}
void
PCL5Driver::jobEnd()
PCL5Driver::_JobEnd()
{
writeSpoolString("\033&l1T");
writeSpoolString("\033E");
WriteSpoolString("\033&l1T");
WriteSpoolString("\033E");
}
void
PCL5Driver::move(int x, int y)
PCL5Driver::_Move(int x, int y)
{
writeSpoolString("\033*p%dx%dY", x, y + 75);
WriteSpoolString("\033*p%dx%dY", x, y + 75);
}
int
PCL5Driver::bytesToEnterCompressionMethod(int compression_method)
PCL5Driver::_BytesToEnterCompressionMethod(int compressionMethod)
{
if (fCompressionMethod == compression_method)
if (fCompressionMethod == compressionMethod)
return 0;
else
return 5;
+14 -14
View File
@@ -14,25 +14,25 @@ class Halftone;
class PCL5Driver : public GraphicsDriver {
public:
PCL5Driver(BMessage* msg, PrinterData* printer_data,
const PrinterCap* printer_cap);
PCL5Driver(BMessage* message, PrinterData* printerData,
const PrinterCap* printerCap);
protected:
virtual bool startDoc();
virtual bool startPage(int page);
virtual bool nextBand(BBitmap* bitmap, BPoint* offset);
virtual bool endPage(int page);
virtual bool endDoc(bool success);
virtual bool StartDocument();
virtual bool StartPage(int page);
virtual bool NextBand(BBitmap* bitmap, BPoint* offset);
virtual bool EndPage(int page);
virtual bool EndDocument(bool success);
private:
void move(int x, int y);
void jobStart();
void startRasterGraphics(int width, int height);
void endRasterGraphics();
void rasterGraphics(int compression_method,
void _Move(int x, int y);
void _JobStart();
void _StartRasterGraphics(int width, int height);
void _EndRasterGraphics();
void _RasterGraphics(int compression_method,
const uchar* buffer, int size, bool lastPlane);
void jobEnd();
int bytesToEnterCompressionMethod(int compression_method);
void _JobEnd();
int _BytesToEnterCompressionMethod(int compression_method);
int fCompressionMethod;
Halftone* fHalftone;
+59 -64
View File
@@ -25,12 +25,6 @@
#include "UIDriver.h"
#include "ValidRect.h"
#if (!__MWERKS__ || defined(MSIPL_USING_NAMESPACE))
using namespace std;
#else
#define std
#endif
// DeltaRowStreamCompressor writes the delta row directly to the
// in the contructor specified stream.
@@ -55,31 +49,32 @@ private:
};
PCL6Driver::PCL6Driver(BMessage* msg, PrinterData* printer_data,
const PrinterCap* printer_cap)
PCL6Driver::PCL6Driver(BMessage* message, PrinterData* printerData,
const PrinterCap* printerCap)
:
GraphicsDriver(msg, printer_data, printer_cap)
GraphicsDriver(message, printerData, printerCap),
fWriter(NULL),
fMediaSide(PCL6Writer::kFrontMediaSide),
fHalftone(NULL)
{
fHalftone = NULL;
fWriter = NULL;
}
void
PCL6Driver::write(const uint8* data, uint32 size)
PCL6Driver::Write(const uint8* data, uint32 size)
{
writeSpoolData(data, size);
WriteSpoolData(data, size);
}
bool
PCL6Driver::startDoc()
PCL6Driver::StartDocument()
{
try {
jobStart();
fHalftone = new Halftone(getJobData()->getSurfaceType(),
getJobData()->getGamma(), getJobData()->getInkDensity(),
getJobData()->getDitherType());
_JobStart();
fHalftone = new Halftone(GetJobData()->getSurfaceType(),
GetJobData()->getGamma(), GetJobData()->getInkDensity(),
GetJobData()->getDitherType());
return true;
}
catch (TransportException& err) {
@@ -89,12 +84,12 @@ PCL6Driver::startDoc()
bool
PCL6Driver::endDoc(bool)
PCL6Driver::EndDocument(bool)
{
try {
if (fHalftone)
delete fHalftone;
jobEnd();
_JobEnd();
return true;
}
catch (TransportException& err) {
@@ -104,7 +99,7 @@ PCL6Driver::endDoc(bool)
bool
PCL6Driver::nextBand(BBitmap* bitmap, BPoint* offset)
PCL6Driver::NextBand(BBitmap* bitmap, BPoint* offset)
{
DBGMSG(("> nextBand\n"));
@@ -112,7 +107,7 @@ PCL6Driver::nextBand(BBitmap* bitmap, BPoint* offset)
int y = (int)offset->y;
PCL6Rasterizer* rasterizer;
if (useColorMode()) {
if (_UseColorMode()) {
#if COLOR_DEPTH == 8
rasterizer = new ColorRGBRasterizer(fHalftone);
#elif COLOR_DEPTH == 1
@@ -125,14 +120,14 @@ PCL6Driver::nextBand(BBitmap* bitmap, BPoint* offset)
auto_ptr<Rasterizer> _rasterizer(rasterizer);
bool valid = rasterizer->SetBitmap((int)offset->x, (int)offset->y,
bitmap, getPageHeight());
bitmap, GetPageHeight());
if (valid) {
rasterizer->InitializeBuffer();
// Use compressor to calculate delta row size
DeltaRowCompressor* deltaRowCompressor = NULL;
if (supportsDeltaRowCompression()) {
if (_SupportsDeltaRowCompression()) {
deltaRowCompressor =
new DeltaRowCompressor(rasterizer->GetOutRowSize(), 0);
if (deltaRowCompressor->InitCheck() != B_OK) {
@@ -166,11 +161,11 @@ PCL6Driver::nextBand(BBitmap* bitmap, BPoint* offset)
int outRowSize = rasterizer->GetOutRowSize();
int width = rasterizer->GetWidth();
int height = rasterizer->GetHeight();
writeBitmap(outBuffer, outBufferSize, outRowSize, xPage, yPage,
_WriteBitmap(outBuffer, outBufferSize, outRowSize, xPage, yPage,
width, height, deltaRowSize);
}
if (y >= getPageHeight()) {
if (y >= GetPageHeight()) {
offset->x = -1.0;
offset->y = -1.0;
} else {
@@ -188,7 +183,7 @@ PCL6Driver::nextBand(BBitmap* bitmap, BPoint* offset)
void
PCL6Driver::writeBitmap(const uchar* buffer, int outSize, int rowSize, int x,
PCL6Driver::_WriteBitmap(const uchar* buffer, int outSize, int rowSize, int x,
int y, int width, int height, int deltaRowSize)
{
// choose the best compression method
@@ -196,14 +191,14 @@ PCL6Driver::writeBitmap(const uchar* buffer, int outSize, int rowSize, int x,
int dataSize = outSize;
#if ENABLE_DELTA_ROW_COMPRESSION
if (supportsDeltaRowCompression() && deltaRowSize < dataSize) {
if (_SupportsDeltaRowCompression() && deltaRowSize < dataSize) {
compressionMethod = PCL6Writer::kDeltaRowCompression;
dataSize = deltaRowSize;
}
#endif
#if ENABLE_RLE_COMPRESSION
if (supportsRLECompression()) {
if (_SupportsRLECompression()) {
int rleSize = pack_bits_size(buffer, outSize);
if (rleSize < dataSize) {
compressionMethod = PCL6Writer::kRLECompression;
@@ -213,14 +208,14 @@ PCL6Driver::writeBitmap(const uchar* buffer, int outSize, int rowSize, int x,
#endif
// write bitmap
move(x, y);
_Move(x, y);
startRasterGraphics(x, y, width, height, compressionMethod);
_StartRasterGraphics(x, y, width, height, compressionMethod);
rasterGraphics(buffer, outSize, dataSize, rowSize, height,
_RasterGraphics(buffer, outSize, dataSize, rowSize, height,
compressionMethod);
endRasterGraphics();
_EndRasterGraphics();
#if DISPLAY_COMPRESSION_STATISTICS
fprintf(stderr, "Out Size %d %2.2f\n", (int)outSize, 100.0);
@@ -239,15 +234,15 @@ PCL6Driver::writeBitmap(const uchar* buffer, int outSize, int rowSize, int x,
void
PCL6Driver::jobStart()
PCL6Driver::_JobStart()
{
// PCL6 begin
fWriter = new PCL6Writer(this);
PCL6Writer::ProtocolClass pc =
(PCL6Writer::ProtocolClass)getProtocolClass();
fWriter->PJLHeader(pc, getJobData()->getXres(),
"Copyright (c) 2003, 2004 Haiku");
fWriter->BeginSession(getJobData()->getXres(), getJobData()->getYres(),
(PCL6Writer::ProtocolClass)GetProtocolClass();
fWriter->PJLHeader(pc, GetJobData()->getXres(),
"Copyright (c) 2003 - 2010 Haiku");
fWriter->BeginSession(GetJobData()->getXres(), GetJobData()->getYres(),
PCL6Writer::kInch, PCL6Writer::kBackChAndErrPage);
fWriter->OpenDataSource();
fMediaSide = PCL6Writer::kFrontMediaSide;
@@ -255,20 +250,20 @@ PCL6Driver::jobStart()
bool
PCL6Driver::startPage(int)
PCL6Driver::StartPage(int)
{
PCL6Writer::Orientation orientation = PCL6Writer::kPortrait;
if (getJobData()->getOrientation() == JobData::kLandscape) {
if (GetJobData()->getOrientation() == JobData::kLandscape) {
orientation = PCL6Writer::kLandscape;
}
PCL6Writer::MediaSize mediaSize =
PCL6Driver::mediaSize(getJobData()->getPaper());
_MediaSize(GetJobData()->getPaper());
PCL6Writer::MediaSource mediaSource =
PCL6Driver::mediaSource(getJobData()->getPaperSource());
if (getJobData()->getPrintStyle() == JobData::kSimplex) {
_MediaSource(GetJobData()->getPaperSource());
if (GetJobData()->getPrintStyle() == JobData::kSimplex) {
fWriter->BeginPage(orientation, mediaSize, mediaSource);
} else if (getJobData()->getPrintStyle() == JobData::kDuplex) {
} else if (GetJobData()->getPrintStyle() == JobData::kDuplex) {
// TODO move duplex binding option to UI
fWriter->BeginPage(orientation, mediaSize, mediaSource,
PCL6Writer::kDuplexVerticalBinding, fMediaSide);
@@ -281,10 +276,10 @@ PCL6Driver::startPage(int)
return false;
// PageOrigin from Windows NT printer driver
int x = 142 * getJobData()->getXres() / 600;
int y = 100 * getJobData()->getYres() / 600;
int x = 142 * GetJobData()->getXres() / 600;
int y = 100 * GetJobData()->getYres() / 600;
fWriter->SetPageOrigin(x, y);
fWriter->SetColorSpace(useColorMode() ? PCL6Writer::kRGB
fWriter->SetColorSpace(_UseColorMode() ? PCL6Writer::kRGB
: PCL6Writer::kGray);
fWriter->SetPaintTxMode(PCL6Writer::kOpaque);
fWriter->SetSourceTxMode(PCL6Writer::kOpaque);
@@ -294,11 +289,11 @@ PCL6Driver::startPage(int)
void
PCL6Driver::startRasterGraphics(int x, int y, int width, int height,
PCL6Driver::_StartRasterGraphics(int x, int y, int width, int height,
PCL6Writer::Compression compressionMethod)
{
PCL6Writer::ColorDepth colorDepth;
if (useColorMode()) {
if (_UseColorMode()) {
#if COLOR_DEPTH == 8
colorDepth = PCL6Writer::k8Bit;
#elif COLOR_DEPTH == 1
@@ -316,14 +311,14 @@ PCL6Driver::startRasterGraphics(int x, int y, int width, int height,
void
PCL6Driver::endRasterGraphics()
PCL6Driver::_EndRasterGraphics()
{
fWriter->EndImage();
}
void
PCL6Driver::rasterGraphics(const uchar* buffer, int bufferSize, int dataSize,
PCL6Driver::_RasterGraphics(const uchar* buffer, int bufferSize, int dataSize,
int rowSize, int height, int compressionMethod)
{
// write bitmap byte size
@@ -365,10 +360,10 @@ PCL6Driver::rasterGraphics(const uchar* buffer, int bufferSize, int dataSize,
bool
PCL6Driver::endPage(int)
PCL6Driver::EndPage(int)
{
try {
fWriter->EndPage(getJobData()->getCopies());
fWriter->EndPage(GetJobData()->getCopies());
return true;
}
catch (TransportException& err) {
@@ -378,7 +373,7 @@ PCL6Driver::endPage(int)
void
PCL6Driver::jobEnd()
PCL6Driver::_JobEnd()
{
fWriter->CloseDataSource();
fWriter->EndSession();
@@ -390,36 +385,36 @@ PCL6Driver::jobEnd()
void
PCL6Driver::move(int x, int y)
PCL6Driver::_Move(int x, int y)
{
fWriter->SetCursor(x, y);
}
bool
PCL6Driver::supportsRLECompression()
PCL6Driver::_SupportsRLECompression()
{
return getJobData()->getColor() != JobData::kColorCompressionDisabled;
return GetJobData()->getColor() != JobData::kColorCompressionDisabled;
}
bool
PCL6Driver::supportsDeltaRowCompression()
PCL6Driver::_SupportsDeltaRowCompression()
{
return getProtocolClass() >= PCL6Writer::kProtocolClass2_1
&& getJobData()->getColor() != JobData::kColorCompressionDisabled;
return GetProtocolClass() >= PCL6Writer::kProtocolClass2_1
&& GetJobData()->getColor() != JobData::kColorCompressionDisabled;
}
bool
PCL6Driver::useColorMode()
PCL6Driver::_UseColorMode()
{
return getJobData()->getColor() != JobData::kMonochrome;
return GetJobData()->getColor() != JobData::kMonochrome;
}
PCL6Writer::MediaSize
PCL6Driver::mediaSize(JobData::Paper paper)
PCL6Driver::_MediaSize(JobData::Paper paper)
{
switch (paper) {
case JobData::kLetter:
@@ -466,7 +461,7 @@ PCL6Driver::mediaSize(JobData::Paper paper)
PCL6Writer::MediaSource
PCL6Driver::mediaSource(JobData::PaperSource source)
PCL6Driver::_MediaSource(JobData::PaperSource source)
{
switch (source) {
case JobData::kAuto:
+20 -20
View File
@@ -18,35 +18,35 @@ class Halftone;
class PCL6Driver : public GraphicsDriver, public PCL6WriterStream
{
public:
PCL6Driver(BMessage* msg, PrinterData* printer_data,
const PrinterCap* printer_cap);
PCL6Driver(BMessage* message, PrinterData* printerData,
const PrinterCap* printerCap);
void write(const uint8* data, uint32 size);
void Write(const uint8* data, uint32 size);
protected:
virtual bool startDoc();
virtual bool startPage(int page);
virtual bool nextBand(BBitmap* bitmap, BPoint* offset);
virtual bool endPage(int page);
virtual bool endDoc(bool success);
virtual bool StartDocument();
virtual bool StartPage(int page);
virtual bool NextBand(BBitmap* bitmap, BPoint* offset);
virtual bool EndPage(int page);
virtual bool EndDocument(bool success);
private:
bool supportsRLECompression();
bool supportsDeltaRowCompression();
bool useColorMode();
PCL6Writer::MediaSize mediaSize(JobData::Paper paper);
PCL6Writer::MediaSource mediaSource(JobData::PaperSource source);
void move(int x, int y);
void jobStart();
void writeBitmap(const uchar* buffer, int outSize, int rowSize,
bool _SupportsRLECompression();
bool _SupportsDeltaRowCompression();
bool _UseColorMode();
PCL6Writer::MediaSize _MediaSize(JobData::Paper paper);
PCL6Writer::MediaSource _MediaSource(JobData::PaperSource source);
void _Move(int x, int y);
void _JobStart();
void _WriteBitmap(const uchar* buffer, int outSize, int rowSize,
int x, int y, int width, int height, int deltaRowSize);
void startRasterGraphics(int x, int y, int width, int height,
void _StartRasterGraphics(int x, int y, int width, int height,
PCL6Writer::Compression compressionMethod);
void endRasterGraphics();
void rasterGraphics(const uchar* buffer, int bufferSize,
void _EndRasterGraphics();
void _RasterGraphics(const uchar* buffer, int bufferSize,
int dataSize, int rowSize, int height,
int compression_method);
void jobEnd();
void _JobEnd();
PCL6Writer* fWriter;
PCL6Writer::MediaSide fMediaSide; // side if in duplex mode
@@ -46,7 +46,7 @@ void
PCL6Writer::Flush()
{
if (fIndex > 0) {
fStream->write(fBuffer, fIndex);
fStream->Write(fBuffer, fIndex);
fIndex = 0;
}
}
+1 -1
View File
@@ -17,7 +17,7 @@ class PCL6Driver;
class PCL6WriterStream {
public:
virtual ~PCL6WriterStream() {}
virtual void write(const uint8* data, uint32 size) = 0;
virtual void Write(const uint8* data, uint32 size) = 0;
};
+97 -103
View File
@@ -29,28 +29,23 @@
#include "UIDriver.h"
#include "ValidRect.h"
#if (!__MWERKS__ || defined(MSIPL_USING_NAMESPACE))
using namespace std;
#else
#define std
#endif
PSDriver::PSDriver(BMessage* msg, PrinterData* printer_data,
const PrinterCap* printer_cap)
PSDriver::PSDriver(BMessage* message, PrinterData* printerData,
const PrinterCap* printerCap)
:
GraphicsDriver(msg, printer_data, printer_cap)
GraphicsDriver(message, printerData, printerCap),
fPrintedPages(0),
fCompressionMethod(0),
fHalftone(NULL),
fFilterIO(NULL)
{
fPrintedPages = 0;
fHalftone = NULL;
fFilterIO = NULL;
}
void
PSDriver::StartFilterIfNeeded()
PSDriver::_StartFilterIfNeeded()
{
const PSData* data = dynamic_cast<const PSData*>(getPrinterData());
const PSData* data = dynamic_cast<const PSData*>(GetPrinterData());
PPDParser parser(BPath(data->fPPD.String()));
if (parser.InitCheck() == B_OK) {
BString param = parser.GetParameter("FoomaticRIPCommandLine");
@@ -72,20 +67,20 @@ PSDriver::StartFilterIfNeeded()
void
PSDriver::FlushFilterIfNeeded()
PSDriver::_FlushFilterIfNeeded()
{
if (fFilterIO) {
char buffer[1024];
ssize_t len;
while ((len = fFilterIO->Read(buffer, sizeof(buffer))) > 0)
writeSpoolData(buffer, len);
WriteSpoolData(buffer, len);
}
}
void
PSDriver::writePSString(const char* format, ...)
PSDriver::_WritePSString(const char* format, ...)
{
char str[256];
va_list ap;
@@ -95,32 +90,32 @@ PSDriver::writePSString(const char* format, ...)
if (fFilterIO)
fFilterIO->Write(str, strlen(str));
else
writeSpoolData(str, strlen(str));
WriteSpoolData(str, strlen(str));
va_end(ap);
}
void
PSDriver::writePSData(const void* data, size_t size)
PSDriver::_WritePSData(const void* data, size_t size)
{
if (fFilterIO)
fFilterIO->Write(data, size);
else
writeSpoolData(data, size);
WriteSpoolData(data, size);
}
bool
PSDriver::startDoc()
PSDriver::StartDocument()
{
try {
StartFilterIfNeeded();
_StartFilterIfNeeded();
jobStart();
fHalftone = new Halftone(getJobData()->getSurfaceType(),
getJobData()->getGamma(), getJobData()->getInkDensity(),
getJobData()->getDitherType());
_JobStart();
fHalftone = new Halftone(GetJobData()->getSurfaceType(),
GetJobData()->getGamma(), GetJobData()->getInkDensity(),
GetJobData()->getDitherType());
return true;
}
catch (TransportException& err) {
@@ -130,25 +125,25 @@ PSDriver::startDoc()
bool
PSDriver::startPage(int page)
PSDriver::StartPage(int page)
{
page ++;
writePSString("%%%%Page: %d %d\n", page, page);
writePSString("gsave\n");
setupCTM();
_WritePSString("%%%%Page: %d %d\n", page, page);
_WritePSString("gsave\n");
_SetupCTM();
return true;
}
bool
PSDriver::endPage(int)
PSDriver::EndPage(int)
{
try {
fPrintedPages ++;
writePSString("grestore\n");
writePSString("showpage\n");
_WritePSString("grestore\n");
_WritePSString("showpage\n");
FlushFilterIfNeeded();
_FlushFilterIfNeeded();
return true;
}
@@ -159,37 +154,38 @@ PSDriver::endPage(int)
void
PSDriver::setupCTM()
PSDriver::_SetupCTM()
{
const float leftMargin = getJobData()->getPrintableRect().left;
const float topMargin = getJobData()->getPrintableRect().top;
if (getJobData()->getOrientation() == JobData::kPortrait) {
const float leftMargin = GetJobData()->getPrintableRect().left;
const float topMargin = GetJobData()->getPrintableRect().top;
if (GetJobData()->getOrientation() == JobData::kPortrait) {
// move origin from bottom left to top left
// and set margin
writePSString("%f %f translate\n", leftMargin,
getJobData()->getPaperRect().Height()-topMargin);
_WritePSString("%f %f translate\n", leftMargin,
GetJobData()->getPaperRect().Height()-topMargin);
} else {
// landscape:
// move origin from bottom left to margin top and left
// and rotate page contents
writePSString("%f %f translate\n", topMargin, leftMargin);
writePSString("90 rotate\n");
_WritePSString("%f %f translate\n", topMargin, leftMargin);
_WritePSString("90 rotate\n");
}
// y values increase from top to bottom
// units of measure is dpi
writePSString("72 %d div 72 -%d div scale\n", getJobData()->getXres(),
getJobData()->getYres());
_WritePSString("72 %d div 72 -%d div scale\n", GetJobData()->getXres(),
GetJobData()->getYres());
}
bool
PSDriver::endDoc(bool)
PSDriver::EndDocument(bool)
{
try {
if (fHalftone) {
delete fHalftone;
fHalftone = NULL;
}
jobEnd();
_JobEnd();
return true;
}
catch (TransportException& err) {
@@ -198,8 +194,8 @@ PSDriver::endDoc(bool)
}
inline uchar
hex_digit(uchar value)
static inline uchar
ToHexDigit(uchar value)
{
if (value <= 9) return '0' + value;
else return 'a' + (value - 10);
@@ -207,7 +203,7 @@ hex_digit(uchar value)
bool
PSDriver::nextBand(BBitmap* bitmap, BPoint* offset)
PSDriver::NextBand(BBitmap* bitmap, BPoint* offset)
{
DBGMSG(("> nextBand\n"));
@@ -225,7 +221,7 @@ PSDriver::nextBand(BBitmap* bitmap, BPoint* offset)
int x = (int)offset->x;
int y = (int)offset->y;
int page_height = getPageHeight();
int page_height = GetPageHeight();
if (y + height > page_height) {
height = page_height - y;
@@ -245,7 +241,7 @@ PSDriver::nextBand(BBitmap* bitmap, BPoint* offset)
x = rc.left;
y += rc.top;
bool color = getJobData()->getColor() == JobData::kColor;
bool color = GetJobData()->getColor() == JobData::kColor;
int width = rc.right - rc.left + 1;
int widthByte = (width + 7) / 8;
// byte boundary
@@ -281,19 +277,19 @@ PSDriver::nextBand(BBitmap* bitmap, BPoint* offset)
DBGMSG(("move\n"));
int size = color ? width * 3 : in_size;
startRasterGraphics(x, y, width, height, size);
_StartRasterGraphics(x, y, width, height, size);
for (int i = rc.top; i <= rc.bottom; i++) {
if (color) {
uchar* out = out_buffer;
uchar* in = ptr;
for (int w = width; w > 0; w --) {
*out++ = hex_digit((in[2]) >> 4);
*out++ = hex_digit((in[2]) & 15);
*out++ = hex_digit((in[1]) >> 4);
*out++ = hex_digit((in[1]) & 15);
*out++ = hex_digit((in[0]) >> 4);
*out++ = hex_digit((in[0]) & 15);
*out++ = ToHexDigit((in[2]) >> 4);
*out++ = ToHexDigit((in[2]) & 15);
*out++ = ToHexDigit((in[1]) >> 4);
*out++ = ToHexDigit((in[1]) & 15);
*out++ = ToHexDigit((in[0]) >> 4);
*out++ = ToHexDigit((in[0]) & 15);
in += 4;
}
} else {
@@ -304,8 +300,8 @@ PSDriver::nextBand(BBitmap* bitmap, BPoint* offset)
for (int w = in_size; w > 0; w --, in ++) {
*in = ~*in; // invert pixels
*out++ = hex_digit((*in) >> 4);
*out++ = hex_digit((*in) & 15);
*out++ = ToHexDigit((*in) >> 4);
*out++ = ToHexDigit((*in) & 15);
}
}
@@ -315,7 +311,7 @@ PSDriver::nextBand(BBitmap* bitmap, BPoint* offset)
compressed_size = out_size;
}
rasterGraphics(
_RasterGraphics(
compression_method,
buffer,
compressed_size);
@@ -324,7 +320,7 @@ PSDriver::nextBand(BBitmap* bitmap, BPoint* offset)
y++;
}
endRasterGraphics();
_EndRasterGraphics();
} else
DBGMSG(("band bitmap is clean.\n"));
@@ -347,79 +343,77 @@ PSDriver::nextBand(BBitmap* bitmap, BPoint* offset)
void
PSDriver::jobStart()
PSDriver::_JobStart()
{
// PostScript header
writePSString("%%!PS-Adobe-3.0\n");
writePSString("%%%%LanguageLevel: 1\n");
writePSString("%%%%Title: %s\n",
getSpoolMetaData()->getDescription().c_str());
writePSString("%%%%Creator: %s\n",
getSpoolMetaData()->getMimeType().c_str());
writePSString("%%%%CreationDate: %s",
getSpoolMetaData()->getCreationTime().c_str());
writePSString("%%%%DocumentMedia: Plain %d %d white 0 ( )\n",
getJobData()->getPaperRect().IntegerWidth(),
getJobData()->getPaperRect().IntegerHeight());
writePSString("%%%%Pages: (atend)\n");
writePSString("%%%%EndComments\n");
_WritePSString("%%!PS-Adobe-3.0\n");
_WritePSString("%%%%LanguageLevel: 1\n");
_WritePSString("%%%%Title: %s\n",
GetSpoolMetaData()->getDescription().c_str());
_WritePSString("%%%%Creator: %s\n",
GetSpoolMetaData()->getMimeType().c_str());
_WritePSString("%%%%CreationDate: %s",
GetSpoolMetaData()->getCreationTime().c_str());
_WritePSString("%%%%DocumentMedia: Plain %d %d white 0 ( )\n",
GetJobData()->getPaperRect().IntegerWidth(),
GetJobData()->getPaperRect().IntegerHeight());
_WritePSString("%%%%Pages: (atend)\n");
_WritePSString("%%%%EndComments\n");
writePSString("%%%%BeginDefaults\n");
writePSString("%%%%PageMedia: Plain\n");
writePSString("%%%%EndDefaults\n");
_WritePSString("%%%%BeginDefaults\n");
_WritePSString("%%%%PageMedia: Plain\n");
_WritePSString("%%%%EndDefaults\n");
}
void
PSDriver::startRasterGraphics(int x, int y, int width, int height,
PSDriver::_StartRasterGraphics(int x, int y, int width, int height,
int widthByte)
{
bool color = getJobData()->getColor() == JobData::kColor;
bool color = GetJobData()->getColor() == JobData::kColor;
fCompressionMethod = -1;
writePSString("gsave\n");
writePSString("/s %d string def\n", widthByte);
writePSString("%d %d translate\n", x, y);
writePSString("%d %d scale\n", width, height);
_WritePSString("gsave\n");
_WritePSString("/s %d string def\n", widthByte);
_WritePSString("%d %d translate\n", x, y);
_WritePSString("%d %d scale\n", width, height);
if (color)
writePSString("%d %d 8\n", width, height); // 8 bpp
_WritePSString("%d %d 8\n", width, height); // 8 bpp
else
writePSString("%d %d 1\n", width, height); // 1 bpp
writePSString("[%d 0 0 %d 0 0]\n", width, height);
writePSString("{ currentfile s readhexstring pop }\n");
_WritePSString("%d %d 1\n", width, height); // 1 bpp
_WritePSString("[%d 0 0 %d 0 0]\n", width, height);
_WritePSString("{ currentfile s readhexstring pop }\n");
if (color) {
writePSString("false 3\n"); // single data source, 3 color components
writePSString("colorimage\n");
_WritePSString("false 3\n"); // single data source, 3 color components
_WritePSString("colorimage\n");
} else
writePSString("image\n\n");
_WritePSString("image\n\n");
}
void
PSDriver::endRasterGraphics()
PSDriver::_EndRasterGraphics()
{
writePSString("grestore\n");
_WritePSString("grestore\n");
}
void
PSDriver::rasterGraphics(
int compression_method,
const uchar* buffer,
PSDriver::_RasterGraphics(int compression_method, const uchar* buffer,
int size)
{
if (fCompressionMethod != compression_method) {
fCompressionMethod = compression_method;
}
writePSData(buffer, size);
writePSString("\n");
_WritePSData(buffer, size);
_WritePSString("\n");
}
void
PSDriver::jobEnd()
PSDriver::_JobEnd()
{
writePSString("%%%%Pages: %d\n", fPrintedPages);
writePSString("%%%%EOF\n");
_WritePSString("%%%%Pages: %d\n", fPrintedPages);
_WritePSString("%%%%EOF\n");
FlushFilterIfNeeded();
_FlushFilterIfNeeded();
}
+17 -17
View File
@@ -15,30 +15,30 @@ class Halftone;
class PSDriver : public GraphicsDriver {
public:
PSDriver(BMessage* msg, PrinterData* printer_data,
const PrinterCap* printer_cap);
PSDriver(BMessage* message, PrinterData* printerData,
const PrinterCap* printerCap);
protected:
virtual bool startDoc();
virtual bool startPage(int page);
virtual bool nextBand(BBitmap* bitmap, BPoint* offset);
virtual bool endPage(int page);
virtual bool endDoc(bool success);
virtual bool StartDocument();
virtual bool StartPage(int page);
virtual bool NextBand(BBitmap* bitmap, BPoint* offset);
virtual bool EndPage(int page);
virtual bool EndDocument(bool success);
private:
void setupCTM();
void jobStart();
void startRasterGraphics(int x, int y, int width,
void _SetupCTM();
void _JobStart();
void _StartRasterGraphics(int x, int y, int width,
int height, int widthByte);
void endRasterGraphics();
void rasterGraphics(int compression_method,
void _EndRasterGraphics();
void _RasterGraphics(int compression_method,
const uchar* buffer, int size);
void jobEnd();
void _JobEnd();
void StartFilterIfNeeded();
void FlushFilterIfNeeded();
void writePSString(const char* format, ...);
void writePSData(const void* data, size_t size);
void _StartFilterIfNeeded();
void _FlushFilterIfNeeded();
void _WritePSString(const char* format, ...);
void _WritePSData(const void* data, size_t size);
int fPrintedPages;
int fCompressionMethod;
+216 -146
View File
@@ -36,36 +36,53 @@ using namespace std;
// Measure printJob() time. Either true or false.
#define MEASURE_PRINT_JOB_TIME false
enum {
kMaxMemorySize = (4 *1024 *1024)
kMaxMemorySize = 4 * 1024 * 1024
};
GraphicsDriver::GraphicsDriver(BMessage *msg, PrinterData *printer_data, const PrinterCap *printer_cap)
: fMsg(msg)
, fPrinterData(printer_data)
, fPrinterCap(printer_cap)
GraphicsDriver::GraphicsDriver(BMessage* message, PrinterData* printerData,
const PrinterCap* printerCap)
:
fFlags(0),
fMessage(message),
fView(NULL),
fBitmap(NULL),
fTransport(NULL),
fOrgJobData(NULL),
fRealJobData(NULL),
fPrinterData(printerData),
fPrinterCap(printerCap),
fSpoolMetaData(NULL),
fPageWidth(0),
fPageHeight(0),
fBandWidth(0),
fBandHeight(0),
fPixelDepth(0),
fBandCount(0),
fInternalCopies(0),
fPageCount(0),
fStatusWindow(NULL)
{
fView = NULL;
fBitmap = NULL;
fTransport = NULL;
fOrgJobData = NULL;
fRealJobData = NULL;
fSpoolMetaData = NULL;
}
GraphicsDriver::~GraphicsDriver()
{
}
static BRect RotateRect(BRect rect)
static BRect
RotateRect(BRect rect)
{
BRect rotated(rect.top, rect.left, rect.bottom, rect.right);
return rotated;
}
bool
GraphicsDriver::setupData(BFile *spoolFile)
GraphicsDriver::_SetupData(BFile* spoolFile)
{
if (fOrgJobData != NULL) {
// already initialized
@@ -103,10 +120,15 @@ GraphicsDriver::setupData(BFile *spoolFile)
case 8:
case 32:
case 128:
fRealJobData->setPrintableRect(RotateRect(fOrgJobData->getPrintableRect()));
fRealJobData->setScaledPrintableRect(RotateRect(fOrgJobData->getScaledPrintableRect()));
fRealJobData->setPhysicalRect(RotateRect(fOrgJobData->getPhysicalRect()));
fRealJobData->setScaledPhysicalRect(RotateRect(fOrgJobData->getScaledPhysicalRect()));
fRealJobData->setPrintableRect(
RotateRect(fOrgJobData->getPrintableRect()));
fRealJobData->setScaledPrintableRect(
RotateRect(fOrgJobData->getScaledPrintableRect()));
fRealJobData->setPhysicalRect(
RotateRect(fOrgJobData->getPhysicalRect()));
fRealJobData->setScaledPhysicalRect(
RotateRect(fOrgJobData->getScaledPhysicalRect()));
if (JobData::kPortrait == fOrgJobData->getOrientation())
fRealJobData->setOrientation(JobData::kLandscape);
else
@@ -125,8 +147,9 @@ GraphicsDriver::setupData(BFile *spoolFile)
return true;
}
void
GraphicsDriver::cleanupData()
GraphicsDriver::_CleanupData()
{
delete fRealJobData;
delete fOrgJobData;
@@ -136,13 +159,16 @@ GraphicsDriver::cleanupData()
fSpoolMetaData = NULL;
}
void
GraphicsDriver::setupBitmap()
GraphicsDriver::_SetupBitmap()
{
fPixelDepth = color_space2pixel_depth(fOrgJobData->getSurfaceType());
fPageWidth = (fRealJobData->getPhysicalRect().IntegerWidth() * fOrgJobData->getXres() + 71) / 72;
fPageHeight = (fRealJobData->getPhysicalRect().IntegerHeight() * fOrgJobData->getYres() + 71) / 72;
fPageWidth = (fRealJobData->getPhysicalRect().IntegerWidth()
* fOrgJobData->getXres() + 71) / 72;
fPageHeight = (fRealJobData->getPhysicalRect().IntegerHeight()
* fOrgJobData->getYres() + 71) / 72;
int widthByte = (fPageWidth * fPixelDepth + 7) / 8;
int size = widthByte * fPageHeight;
@@ -156,7 +182,8 @@ GraphicsDriver::setupBitmap()
fBandHeight = fPageHeight;
} else {
fBandCount = (size + kMaxMemorySize - 1) / kMaxMemorySize;
if ((JobData::kLandscape == fRealJobData->getOrientation()) && (fFlags & kGDFRotateBandBitmap)) {
if ((JobData::kLandscape == fRealJobData->getOrientation())
&& (fFlags & kGDFRotateBandBitmap)) {
fBandWidth = (fPageWidth + fBandCount - 1) / fBandCount;
fBandHeight = fPageHeight;
} else {
@@ -179,16 +206,18 @@ GraphicsDriver::setupBitmap()
fBitmap->AddChild(fView);
}
void
GraphicsDriver::cleanupBitmap()
GraphicsDriver::_CleanupBitmap()
{
delete fBitmap;
fBitmap = NULL;
fView = NULL;
}
BPoint
GraphicsDriver::getScale(int32 nup, BRect physicalRect, float scaling)
GraphicsDriver::GetScale(int32 nup, BRect physicalRect, float scaling)
{
float width;
float height;
@@ -271,9 +300,11 @@ GraphicsDriver::getScale(int32 nup, BRect physicalRect, float scaling)
return scale;
}
BPoint
GraphicsDriver::getOffset(int32 nup, int index, JobData::Orientation orientation,
const BPoint *scale, BRect scaledPhysicalRect, BRect scaledPrintableRect,
GraphicsDriver::GetOffset(int32 nup, int index,
JobData::Orientation orientation, const BPoint* scale,
BRect scaledPhysicalRect, BRect scaledPrintableRect,
BRect physicalRect)
{
BPoint offset;
@@ -368,9 +399,10 @@ GraphicsDriver::getOffset(int32 nup, int index, JobData::Orientation orientation
return offset;
}
// print the specified pages on a physical page
bool
GraphicsDriver::printPage(PageDataList *pages)
GraphicsDriver::_PrintPage(PageDataList* pages)
{
BPoint offset;
offset.x = 0.0f;
@@ -387,23 +419,34 @@ GraphicsDriver::printPage(PageDataList *pages)
fView->ConstrainClippingRegion(NULL);
fView->FillRect(fView->Bounds());
BPoint scale = getScale(fOrgJobData->getNup(), fOrgJobData->getPhysicalRect(), fOrgJobData->getScaling());
float real_scale = min(scale.x, scale.y) * fOrgJobData->getXres() / 72.0f;
BPoint scale = GetScale(fOrgJobData->getNup(),
fOrgJobData->getPhysicalRect(), fOrgJobData->getScaling());
float real_scale = min(scale.x, scale.y) * fOrgJobData->getXres()
/ 72.0f;
fView->SetScale(real_scale);
float x = offset.x / real_scale;
float y = offset.y / real_scale;
int page_index = 0;
for (PageDataList::iterator it = pages->begin(); it != pages->end(); it++) {
BPoint left_top(getOffset(fOrgJobData->getNup(), page_index++, fOrgJobData->getOrientation(), &scale, fOrgJobData->getScaledPhysicalRect(), fOrgJobData->getScaledPrintableRect(), fOrgJobData->getPhysicalRect()));
for (PageDataList::iterator it = pages->begin(); it != pages->end();
it++) {
BPoint left_top(GetOffset(fOrgJobData->getNup(), page_index++,
fOrgJobData->getOrientation(), &scale,
fOrgJobData->getScaledPhysicalRect(),
fOrgJobData->getScaledPrintableRect(),
fOrgJobData->getPhysicalRect()));
left_top.x -= x;
left_top.y -= y;
BRect clip(fOrgJobData->getScaledPrintableRect());
clip.OffsetTo(left_top);
BRegion *region = new BRegion();
region->Set(clip);
fView->ConstrainClippingRegion(region);
delete region;
if ((*it)->startEnum()) {
bool more;
do {
@@ -416,39 +459,42 @@ GraphicsDriver::printPage(PageDataList *pages)
} while (more);
}
}
if (!nextBand(fBitmap, &offset)) {
if (!NextBand(fBitmap, &offset))
return false;
}
} while (offset.x >= 0.0f && offset.y >= 0.0f);
return true;
}
bool
GraphicsDriver::collectPages(SpoolData *spool_data, PageDataList *pages)
GraphicsDriver::_CollectPages(SpoolData* spoolData, PageDataList* pages)
{
// collect the pages to be printed on the physical page
PageData *page_data;
int nup = fOrgJobData->getNup();
bool more;
do {
more = spool_data->enumObject(&page_data);
if (pages != NULL) {
more = spoolData->enumObject(&page_data);
if (pages != NULL)
pages->push_back(page_data);
}
} while (more && --nup);
return more;
}
bool
GraphicsDriver::skipPages(SpoolData *spool_data)
{
return collectPages(spool_data, NULL);
}
bool
GraphicsDriver::printDocument(SpoolData *spool_data)
GraphicsDriver::_SkipPages(SpoolData* spoolData)
{
return _CollectPages(spoolData, NULL);
}
bool
GraphicsDriver::_PrintDocument(SpoolData* spoolData)
{
bool more;
bool success;
@@ -460,41 +506,41 @@ GraphicsDriver::printDocument(SpoolData *spool_data)
success = true;
page_index = 0;
if (fPrinterCap->isSupport(PrinterCap::kCopyCommand)) {
if (fPrinterCap->isSupport(PrinterCap::kCopyCommand))
// let the printer perform the copy operation
copies = 1;
} else {
else
// send the page multiple times to the printer
copies = fRealJobData->getCopies();
}
fStatusWindow -> SetPageCopies(copies); // inform fStatusWindow about number of copies
fStatusWindow -> SetPageCopies(copies);
// inform fStatusWindow about number of copies
// printing of even/odd numbered pages only is valid in simplex mode
bool simplex = fRealJobData->getPrintStyle() == JobData::kSimplex;
if (spool_data->startEnum()) {
if (spoolData->startEnum()) {
do {
DBGMSG(("page index = %d\n", page_index));
if (simplex &&
fRealJobData->getPageSelection() == JobData::kEvenNumberedPages) {
if (simplex
&& fRealJobData->getPageSelection()
== JobData::kEvenNumberedPages)
// skip odd numbered page
more = skipPages(spool_data);
}
more = _SkipPages(spoolData);
if (!more) {
if (!more)
// end reached
break;
}
PageDataList pages;
more = collectPages(spool_data, &pages);
more = _CollectPages(spoolData, &pages);
if (more && simplex &&
fRealJobData->getPageSelection() == JobData::kOddNumberedPages) {
if (more && simplex
&& fRealJobData->getPageSelection()
== JobData::kOddNumberedPages)
// skip even numbered page
more = skipPages(spool_data);
}
more = _SkipPages(spoolData);
// print each physical page "copies" of times
for (copy = 0; success && copy < copies; copy ++) {
@@ -503,17 +549,17 @@ GraphicsDriver::printDocument(SpoolData *spool_data)
if (fStatusWindow->UpdateStatusBar(page_index, copy))
return false;
success = startPage(page_index);
success = StartPage(page_index);
if (!success)
break;
// print the pages on the physical page
fView->Window()->Lock();
success = printPage(&pages);
success = _PrintPage(&pages);
fView->Window()->Unlock();
if (success) {
success = endPage(page_index);
success = EndPage(page_index);
}
}
@@ -525,31 +571,34 @@ GraphicsDriver::printDocument(SpoolData *spool_data)
if (success
&& fPrinterCap->isSupport(PrinterCap::kPrintStyle)
&& (fOrgJobData->getPrintStyle() != JobData::kSimplex)
&& (((page_index + fOrgJobData->getNup() - 1) / fOrgJobData->getNup()) % 2))
{
// append an empty page on the back side of the page in duplex or booklet mode
&& (((page_index + fOrgJobData->getNup() - 1) / fOrgJobData->getNup())
% 2)) {
// append an empty page on the back side of the page in duplex or
// booklet mode
success =
startPage(page_index) &&
printPage(NULL) &&
endPage(page_index);
StartPage(page_index) &&
_PrintPage(NULL) &&
EndPage(page_index);
}
#endif
return success;
}
const JobData*
GraphicsDriver::getJobData(BFile *spoolFile)
GraphicsDriver::GetJobData(BFile* spoolFile)
{
setupData(spoolFile);
_SetupData(spoolFile);
return fOrgJobData;
}
bool
GraphicsDriver::printJob(BFile *spoolFile)
GraphicsDriver::PrintJob(BFile* spoolFile)
{
bool success = true;
if (!setupData(spoolFile)) {
if (!_SetupData(spoolFile)) {
// silently exit if there is nothing to print
return true;
}
@@ -560,9 +609,10 @@ GraphicsDriver::printJob(BFile *spoolFile)
success = false;
} else if (!fTransport->is_print_to_file_canceled()) {
BStopWatch stopWatch("printJob", !MEASURE_PRINT_JOB_TIME);
setupBitmap();
SpoolData spool_data(spoolFile, fPageCount, fOrgJobData->getNup(), fOrgJobData->getReverse());
success = startDoc();
_SetupBitmap();
SpoolData spoolData(spoolFile, fPageCount, fOrgJobData->getNup(),
fOrgJobData->getReverse());
success = StartDocument();
if (success) {
fStatusWindow = new StatusWindow(
fRealJobData->getPageSelection() == JobData::kOddNumberedPages,
@@ -572,27 +622,26 @@ GraphicsDriver::printJob(BFile *spoolFile)
fInternalCopies,fRealJobData->getNup());
while (fInternalCopies--) {
success = printDocument(&spool_data);
success = _PrintDocument(&spoolData);
if (success == false) {
break;
}
}
endDoc(success);
EndDocument(success);
fStatusWindow->Lock();
fStatusWindow->Quit();
}
cleanupBitmap();
cleanupData();
_CleanupBitmap();
_CleanupData();
}
if (success == false) {
BAlert *alert;
if (fTransport->check_abort()) {
if (fTransport->check_abort())
alert = new BAlert("", fTransport->last_error().c_str(), "OK");
} else {
else
alert = new BAlert("", "Printer not responding.", "OK");
}
alert->Go();
}
@@ -602,83 +651,97 @@ GraphicsDriver::printJob(BFile *spoolFile)
return success;
}
BMessage *
GraphicsDriver::takeJob(BFile* spoolFile, uint32 flags)
BMessage*
GraphicsDriver::TakeJob(BFile* spoolFile, uint32 flags)
{
fFlags = flags;
BMessage *msg;
if (printJob(spoolFile)) {
if (PrintJob(spoolFile))
msg = new BMessage('okok');
} else {
else
msg = new BMessage('baad');
}
return msg;
}
bool
GraphicsDriver::startDoc()
GraphicsDriver::StartDocument()
{
return true;
}
bool
GraphicsDriver::startPage(int)
GraphicsDriver::StartPage(int)
{
return true;
}
bool
GraphicsDriver::nextBand(BBitmap *, BPoint *)
GraphicsDriver::NextBand(BBitmap*, BPoint*)
{
return true;
}
bool
GraphicsDriver::endPage(int)
GraphicsDriver::EndPage(int)
{
return true;
}
bool
GraphicsDriver::endDoc(bool)
GraphicsDriver::EndDocument(bool)
{
return true;
}
void
GraphicsDriver::writeSpoolData(const void *buffer, size_t size) throw(TransportException)
{
if (fTransport) {
fTransport->write(buffer, size);
}
}
void
GraphicsDriver::writeSpoolString(const char *format, ...) throw(TransportException)
{
if (fTransport) {
char buffer[256];
va_list ap;
va_start(ap, format);
vsprintf(buffer, format, ap);
fTransport->write(buffer, strlen(buffer));
va_end(ap);
}
}
void
GraphicsDriver::writeSpoolChar(char c) throw(TransportException)
{
if (fTransport) {
fTransport->write(&c, 1);
}
}
void
GraphicsDriver::rgb32_to_rgb24(void* src, void* dst, int width) {
GraphicsDriver::WriteSpoolData(const void* buffer, size_t size)
throw (TransportException)
{
if (fTransport == NULL)
return
fTransport->write(buffer, size);
}
void
GraphicsDriver::WriteSpoolString(const char* format, ...)
throw (TransportException)
{
if (fTransport == NULL)
return;
char buffer[256];
va_list ap;
va_start(ap, format);
vsprintf(buffer, format, ap);
fTransport->write(buffer, strlen(buffer));
va_end(ap);
}
void
GraphicsDriver::WriteSpoolChar(char c)
throw (TransportException)
{
if (fTransport == NULL)
return;
fTransport->write(&c, 1);
}
void
GraphicsDriver::_ConvertRGB32ToRGB24(const void* src, void* dst, int width) {
uint8* d = (uint8*)dst;
rgb_color* s = (rgb_color*)src;
const rgb_color* s = static_cast<const rgb_color*>(src);
for (int i = width; i > 0; i --) {
*d ++ = s->red;
*d ++ = s->green;
@@ -687,10 +750,11 @@ GraphicsDriver::rgb32_to_rgb24(void* src, void* dst, int width) {
}
}
void
GraphicsDriver::cmap8_to_rgb24(void* src, void* dst, int width) {
GraphicsDriver::_ConvertCMAP8ToRGB24(const void* src, void* dst, int width) {
uint8* d = (uint8*)dst;
uint8* s = (uint8*)src;
const uint8* s = static_cast<const uint8*>(src);
const color_map* cmap = system_colors();
for (int i = width; i > 0; i --) {
const rgb_color* rgb = &cmap->color_list[*s];
@@ -701,51 +765,57 @@ GraphicsDriver::cmap8_to_rgb24(void* src, void* dst, int width) {
}
}
void
GraphicsDriver::convert_to_rgb24(void* src, void* dst, int width, color_space cs) {
if (cs == B_RGB32) rgb32_to_rgb24(src, dst, width);
else if (cs == B_CMAP8) cmap8_to_rgb24(src, dst, width);
GraphicsDriver::ConvertToRGB24(const void* src, void* dst, int width,
color_space cs) {
if (cs == B_RGB32)
_ConvertRGB32ToRGB24(src, dst, width);
else if (cs == B_CMAP8)
_ConvertCMAP8ToRGB24(src, dst, width);
else {
DBGMSG(("color_space %d not supported", cs));
}
}
uint8
GraphicsDriver::gray(uint8 r, uint8 g, uint8 b) {
if (r == g && g == b) {
GraphicsDriver::_ConvertToGray(uint8 r, uint8 g, uint8 b) {
if (r == g && g == b)
return r;
} else {
else
return (r * 3 + g * 6 + b) / 10;
}
}
void
GraphicsDriver::rgb32_to_gray(void* src, void* dst, int width) {
GraphicsDriver::_ConvertRGB32ToGray(const void* src, void* dst, int width) {
uint8* d = (uint8*)dst;
rgb_color* s = (rgb_color*)src;
for (int i = width; i > 0; i --) {
*d ++ = gray(s->red, s->green, s->blue);
s++;
}
const rgb_color* s = static_cast<const rgb_color*>(src);
for (int i = width; i > 0; i--, s++, d++)
*d = _ConvertToGray(s->red, s->green, s->blue);
}
void
GraphicsDriver::cmap8_to_gray(void* src, void* dst, int width) {
GraphicsDriver::_ConvertCMAP8ToGray(const void* src, void* dst, int width) {
uint8* d = (uint8*)dst;
uint8* s = (uint8*)src;
const uint8* s = static_cast<const uint8*>(src);
const color_map* cmap = system_colors();
for (int i = width; i > 0; i --) {
for (int i = width; i > 0; i--, s++, d++) {
const rgb_color* rgb = &cmap->color_list[*s];
*d ++ = gray(rgb->red, rgb->green, rgb->blue);
s ++;
*d = _ConvertToGray(rgb->red, rgb->green, rgb->blue);
}
}
void
GraphicsDriver::convert_to_gray(void* src, void* dst, int width, color_space cs) {
if (cs == B_RGB32) rgb32_to_gray(src, dst, width);
else if (cs == B_CMAP8) cmap8_to_gray(src, dst, width);
GraphicsDriver::ConvertToGray(const void* src, void* dst, int width,
color_space cs) {
if (cs == B_RGB32)
_ConvertRGB32ToGray(src, dst, width);
else if (cs == B_CMAP8)
_ConvertCMAP8ToGray(src, dst, width);
else {
DBGMSG(("color_space %d not supported", cs));
}
+1 -1
View File
@@ -680,7 +680,7 @@ void PreviewView::_DrawPage(BRect rect)
}
printRect.OffsetBy(_ContentRect().LeftTop());
BPoint scalingXY = GraphicsDriver::getScale(fNumberOfPagesPerPage, printRect, 100.0);
BPoint scalingXY = GraphicsDriver::GetScale(fNumberOfPagesPerPage, printRect, 100.0);
float scaling = min_c(scalingXY.x, scalingXY.y);
printRect = ScaleDown(printRect, _ZoomFactor() * scaling);
+7 -6
View File
@@ -30,10 +30,11 @@
// Implementation of PrinterDriver
PrinterDriver::PrinterDriver(BNode* spoolFolder)
: fSpoolFolder(spoolFolder)
, fPrinterData(NULL)
, fPrinterCap(NULL)
, fGraphicsDriver(NULL)
:
fSpoolFolder(spoolFolder),
fPrinterData(NULL),
fPrinterCap(NULL),
fGraphicsDriver(NULL)
{
}
@@ -152,7 +153,7 @@ PrinterDriver::TakeJob(BFile* printJob, BMessage* settings)
DUMP_BNODE(fSpoolFolder);
fGraphicsDriver = InstantiateGraphicsDriver(settings, fPrinterData, fPrinterCap);
const JobData* jobData = fGraphicsDriver->getJobData(printJob);
const JobData* jobData = fGraphicsDriver->GetJobData(printJob);
if (jobData != NULL && jobData->getShowPreview()) {
off_t offset = printJob->Position();
PreviewWindow *preview = new PreviewWindow(printJob, true);
@@ -161,7 +162,7 @@ PrinterDriver::TakeJob(BFile* printJob, BMessage* settings)
}
printJob->Seek(offset, SEEK_SET);
}
BMessage *result = fGraphicsDriver->takeJob(printJob);
BMessage *result = fGraphicsDriver->TakeJob(printJob);
DUMP_BMESSAGE(result);
DBGMSG(("<%s: take_job\n", GetDriverName()));