Style cleanup.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37366 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Wim van der Meer
2010-07-03 08:11:37 +00:00
parent a6cd1edfaa
commit 6b176bef5b
5 changed files with 169 additions and 126 deletions
+72 -44
View File
@@ -4,19 +4,24 @@
* Copyright 2003 Michael Pfeiffer. * Copyright 2003 Michael Pfeiffer.
*/ */
#include "PCL5.h"
#include <memory>
#include <Alert.h> #include <Alert.h>
#include <Bitmap.h> #include <Bitmap.h>
#include <File.h> #include <File.h>
#include <memory>
#include "PCL5.h"
#include "UIDriver.h"
#include "JobData.h"
#include "PrinterData.h"
#include "PCL5Cap.h"
#include "PackBits.h"
#include "Halftone.h"
#include "ValidRect.h"
#include "DbgMsg.h" #include "DbgMsg.h"
#include "Halftone.h"
#include "JobData.h"
#include "PackBits.h"
#include "PCL5Cap.h"
#include "PrinterData.h"
#include "UIDriver.h"
#include "ValidRect.h"
#if (!__MWERKS__ || defined(MSIPL_USING_NAMESPACE)) #if (!__MWERKS__ || defined(MSIPL_USING_NAMESPACE))
using namespace std; using namespace std;
@@ -24,17 +29,24 @@ using namespace std;
#define std #define std
#endif #endif
PCL5Driver::PCL5Driver(BMessage *msg, PrinterData *printer_data, const PrinterCap *printer_cap)
: GraphicsDriver(msg, printer_data, printer_cap) PCL5Driver::PCL5Driver(BMessage* msg, PrinterData* printer_data,
const PrinterCap* printer_cap)
:
GraphicsDriver(msg, printer_data, printer_cap)
{ {
fHalftone = NULL; fHalftone = NULL;
} }
bool PCL5Driver::startDoc()
bool
PCL5Driver::startDoc()
{ {
try { try {
jobStart(); jobStart();
fHalftone = new Halftone(getJobData()->getSurfaceType(), getJobData()->getGamma(), getJobData()->getInkDensity(), getJobData()->getDitherType()); fHalftone = new Halftone(getJobData()->getSurfaceType(),
getJobData()->getGamma(), getJobData()->getInkDensity(),
getJobData()->getDitherType());
return true; return true;
} }
catch (TransportException& err) { catch (TransportException& err) {
@@ -42,12 +54,16 @@ bool PCL5Driver::startDoc()
} }
} }
bool PCL5Driver::startPage(int)
bool
PCL5Driver::startPage(int)
{ {
return true; return true;
} }
bool PCL5Driver::endPage(int)
bool
PCL5Driver::endPage(int)
{ {
try { try {
writeSpoolChar('\014'); writeSpoolChar('\014');
@@ -58,7 +74,9 @@ bool PCL5Driver::endPage(int)
} }
} }
bool PCL5Driver::endDoc(bool)
bool
PCL5Driver::endDoc(bool)
{ {
try { try {
if (fHalftone) { if (fHalftone) {
@@ -72,7 +90,9 @@ bool PCL5Driver::endDoc(bool)
} }
} }
bool PCL5Driver::nextBand(BBitmap *bitmap, BPoint *offset)
bool
PCL5Driver::nextBand(BBitmap* bitmap, BPoint* offset)
{ {
DBGMSG(("> nextBand\n")); DBGMSG(("> nextBand\n"));
@@ -92,9 +112,8 @@ bool PCL5Driver::nextBand(BBitmap *bitmap, BPoint *offset)
int page_height = getPageHeight(); int page_height = getPageHeight();
if (y + height > page_height) { if (y + height > page_height)
height = page_height - y; height = page_height - y;
}
rc.bottom = height - 1; rc.bottom = height - 1;
@@ -111,7 +130,8 @@ bool PCL5Driver::nextBand(BBitmap *bitmap, BPoint *offset)
y += rc.top; y += rc.top;
int width = rc.right - rc.left + 1; int width = rc.right - rc.left + 1;
int widthByte = (width + 7) / 8; /* byte boundary */ int widthByte = (width + 7) / 8;
// byte boundary
int height = rc.bottom - rc.top + 1; int height = rc.bottom - rc.top + 1;
int in_size = widthByte; int in_size = widthByte;
int out_size = (widthByte * 6 + 4) / 5; int out_size = (widthByte * 6 + 4) / 5;
@@ -125,7 +145,7 @@ bool PCL5Driver::nextBand(BBitmap *bitmap, BPoint *offset)
DBGMSG(("delta = %d\n", delta)); DBGMSG(("delta = %d\n", delta));
DBGMSG(("renderobj->get_pixel_depth() = %d\n", fHalftone->getPixelDepth())); DBGMSG(("renderobj->get_pixel_depth() = %d\n", fHalftone->getPixelDepth()));
uchar *ptr = (uchar *)bitmap->Bits() uchar* ptr = static_cast<uchar*>(bitmap->Bits())
+ rc.top * delta + rc.top * delta
+ (rc.left * fHalftone->getPixelDepth()) / 8; + (rc.left * fHalftone->getPixelDepth()) / 8;
@@ -160,7 +180,8 @@ bool PCL5Driver::nextBand(BBitmap *bitmap, BPoint *offset)
compressed_size = pack_bits(out_buffer, in_buffer, in_size); compressed_size = pack_bits(out_buffer, in_buffer, in_size);
if (compressed_size + bytesToEnterCompressionMethod(2) < in_size + bytesToEnterCompressionMethod(0)) { if (compressed_size + bytesToEnterCompressionMethod(2)
< in_size + bytesToEnterCompressionMethod(0)) {
compression_method = 2; // back bits compression_method = 2; // back bits
buffer = out_buffer; buffer = out_buffer;
} else { } else {
@@ -183,16 +204,14 @@ bool PCL5Driver::nextBand(BBitmap *bitmap, BPoint *offset)
endRasterGraphics(); endRasterGraphics();
} else { } else
DBGMSG(("band bitmap is clean.\n")); DBGMSG(("band bitmap is clean.\n"));
}
if (y >= page_height) { if (y >= page_height) {
offset->x = -1.0; offset->x = -1.0;
offset->y = -1.0; offset->y = -1.0;
} else { } else
offset->y += height; offset->y += height;
}
DBGMSG(("< nextBand\n")); DBGMSG(("< nextBand\n"));
return true; return true;
@@ -204,7 +223,9 @@ bool PCL5Driver::nextBand(BBitmap *bitmap, BPoint *offset)
} }
} }
void PCL5Driver::jobStart()
void
PCL5Driver::jobStart()
{ {
const bool color = getJobData()->getColor() == JobData::kColor; const bool color = getJobData()->getColor() == JobData::kColor;
// enter PCL5 // enter PCL5
@@ -233,7 +254,9 @@ void PCL5Driver::jobStart()
// writeSpoolString("\033&l%ldL", getJobData()->getCopies()); // writeSpoolString("\033&l%ldL", getJobData()->getCopies());
} }
void PCL5Driver::startRasterGraphics(int width, int height)
void
PCL5Driver::startRasterGraphics(int width, int height)
{ {
// width // width
writeSpoolString("\033*r%dS", width); writeSpoolString("\033*r%dS", width);
@@ -244,47 +267,52 @@ void PCL5Driver::startRasterGraphics(int width, int height)
fCompressionMethod = -1; fCompressionMethod = -1;
} }
void PCL5Driver::endRasterGraphics()
void
PCL5Driver::endRasterGraphics()
{ {
writeSpoolString("\033*rB"); writeSpoolString("\033*rB");
} }
void PCL5Driver::rasterGraphics(
int compression_method, void
const uchar *buffer, PCL5Driver::rasterGraphics(int compression_method, const uchar* buffer,
int size, int size, bool lastPlane)
bool lastPlane)
{ {
if (fCompressionMethod != compression_method) { if (fCompressionMethod != compression_method) {
writeSpoolString("\033*b%dM", compression_method); writeSpoolString("\033*b%dM", compression_method);
fCompressionMethod = compression_method; fCompressionMethod = compression_method;
} }
writeSpoolString("\033*b%d", size); writeSpoolString("\033*b%d", size);
if (lastPlane) { if (lastPlane)
writeSpoolString("W"); writeSpoolString("W");
} else { else
writeSpoolString("V"); writeSpoolString("V");
}
writeSpoolData(buffer, size); writeSpoolData(buffer, size);
} }
void PCL5Driver::jobEnd()
void
PCL5Driver::jobEnd()
{ {
writeSpoolString("\033&l1T"); writeSpoolString("\033&l1T");
writeSpoolString("\033E"); writeSpoolString("\033E");
} }
void PCL5Driver::move(int x, int y)
void
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)
int
PCL5Driver::bytesToEnterCompressionMethod(int compression_method)
{ {
if (fCompressionMethod == compression_method) { if (fCompressionMethod == compression_method)
return 0; return 0;
} else { else
return 5; return 5;
} }
}
+8 -8
View File
@@ -2,17 +2,20 @@
* PCL5.h * PCL5.h
* Copyright 1999-2000 Y.Takagi. All Rights Reserved. * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/ */
#ifndef __PCL5_H #ifndef __PCL5_H
#define __PCL5_H #define __PCL5_H
#include "GraphicsDriver.h" #include "GraphicsDriver.h"
class Halftone; class Halftone;
class PCL5Driver : public GraphicsDriver { class PCL5Driver : public GraphicsDriver {
public: public:
PCL5Driver(BMessage *msg, PrinterData *printer_data, const PrinterCap *printer_cap); PCL5Driver(BMessage* msg, PrinterData* printer_data,
const PrinterCap* printer_cap);
protected: protected:
virtual bool startDoc(); virtual bool startDoc();
@@ -26,11 +29,8 @@ private:
void jobStart(); void jobStart();
void startRasterGraphics(int width, int height); void startRasterGraphics(int width, int height);
void endRasterGraphics(); void endRasterGraphics();
void rasterGraphics( void rasterGraphics(int compression_method,
int compression_method, const uchar* buffer, int size, bool lastPlane);
const uchar *buffer,
int size,
bool lastPlane);
void jobEnd(); void jobEnd();
int bytesToEnterCompressionMethod(int compression_method); int bytesToEnterCompressionMethod(int compression_method);
@@ -38,4 +38,4 @@ private:
Halftone* fHalftone; Halftone* fHalftone;
}; };
#endif /* __PCL5_H */ #endif // __PCL5_H
+15 -5
View File
@@ -3,9 +3,11 @@
* Copyright 1999-2000 Y.Takagi. All Rights Reserved. * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/ */
#include "PrinterData.h"
#include "PCL5Cap.h" #include "PCL5Cap.h"
#include "PrinterData.h"
#define TO72DPI(a) (a * 72.0f / 600.0f) #define TO72DPI(a) (a * 72.0f / 600.0f)
const PaperCap a3( const PaperCap a3(
@@ -98,12 +100,16 @@ const ColorCap *colors[] = {
&monochrome &monochrome
}; };
PCL5Cap::PCL5Cap(const PrinterData* printer_data) PCL5Cap::PCL5Cap(const PrinterData* printer_data)
: PrinterCap(printer_data) :
PrinterCap(printer_data)
{ {
} }
int PCL5Cap::countCap(CapID capid) const
int
PCL5Cap::countCap(CapID capid) const
{ {
switch (capid) { switch (capid) {
case kPaper: case kPaper:
@@ -119,7 +125,9 @@ int PCL5Cap::countCap(CapID capid) const
} }
} }
const BaseCap **PCL5Cap::enumCap(CapID capid) const
const BaseCap**
PCL5Cap::enumCap(CapID capid) const
{ {
switch (capid) { switch (capid) {
case kPaper: case kPaper:
@@ -135,7 +143,9 @@ const BaseCap **PCL5Cap::enumCap(CapID capid) const
} }
} }
bool PCL5Cap::isSupport(CapID capid) const
bool
PCL5Cap::isSupport(CapID capid) const
{ {
switch (capid) { switch (capid) {
case kPaper: case kPaper:
+3 -2
View File
@@ -2,12 +2,13 @@
* PCL5Cap.h * PCL5Cap.h
* Copyright 1999-2000 Y.Takagi. All Rights Reserved. * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/ */
#ifndef __PCL5CAP_H #ifndef __PCL5CAP_H
#define __PCL5CAP_H #define __PCL5CAP_H
#include "PrinterCap.h" #include "PrinterCap.h"
class PCL5Cap : public PrinterCap { class PCL5Cap : public PrinterCap {
public: public:
PCL5Cap(const PrinterData* printer_data); PCL5Cap(const PrinterData* printer_data);
@@ -16,4 +17,4 @@ public:
virtual const BaseCap **enumCap(CapID) const; virtual const BaseCap **enumCap(CapID) const;
}; };
#endif /* __PCL5CAP_H */ #endif // __PCL5CAP_H
+5 -1
View File
@@ -4,10 +4,12 @@
* Copyright 2003 Michael Pfeiffer. * Copyright 2003 Michael Pfeiffer.
*/ */
#include "PCL5.h" #include "PCL5.h"
#include "PCL5Cap.h" #include "PCL5Cap.h"
#include "PrinterDriver.h" #include "PrinterDriver.h"
class PCL5PrinterDriver : public PrinterDriver class PCL5PrinterDriver : public PrinterDriver
{ {
public: public:
@@ -38,12 +40,14 @@ public:
return new PCL5Cap(printerData); return new PCL5Cap(printerData);
} }
GraphicsDriver* InstantiateGraphicsDriver(BMessage* settings, PrinterData* printerData, PrinterCap* printerCap) GraphicsDriver* InstantiateGraphicsDriver(BMessage* settings,
PrinterData* printerData, PrinterCap* printerCap)
{ {
return new PCL5Driver(settings, printerData, printerCap); return new PCL5Driver(settings, printerData, printerCap);
} }
}; };
PrinterDriver* instantiate_printer_driver(BNode* printerFolder) PrinterDriver* instantiate_printer_driver(BNode* printerFolder)
{ {
return new PCL5PrinterDriver(printerFolder); return new PCL5PrinterDriver(printerFolder);