[haiku-commits] r37370 - haiku/trunk/src/add-ons/print/drivers/pcl6

Author: wim
Date: 2010-07-03 12:23:04 +0200 (Sat, 03 Jul 2010)
New Revision: 37370
Changeset: http://dev.haiku-os.org/changeset/37370/haiku

Modified:
   haiku/trunk/src/add-ons/print/drivers/pcl6/DeltaRowCompression.cpp
   haiku/trunk/src/add-ons/print/drivers/pcl6/DeltaRowCompression.h
   haiku/trunk/src/add-ons/print/drivers/pcl6/PCL6.cpp
   haiku/trunk/src/add-ons/print/drivers/pcl6/PCL6.h
   haiku/trunk/src/add-ons/print/drivers/pcl6/PCL6Cap.cpp
   haiku/trunk/src/add-ons/print/drivers/pcl6/PCL6Cap.h
   haiku/trunk/src/add-ons/print/drivers/pcl6/PCL6Config.h
   haiku/trunk/src/add-ons/print/drivers/pcl6/PCL6Entry.cpp
   haiku/trunk/src/add-ons/print/drivers/pcl6/PCL6Rasterizer.cpp
   haiku/trunk/src/add-ons/print/drivers/pcl6/PCL6Rasterizer.h
   haiku/trunk/src/add-ons/print/drivers/pcl6/PCL6Writer.cpp
   haiku/trunk/src/add-ons/print/drivers/pcl6/PCL6Writer.h
   haiku/trunk/src/add-ons/print/drivers/pcl6/Rasterizer.cpp
   haiku/trunk/src/add-ons/print/drivers/pcl6/Rasterizer.h
Log:
Style cleanup.

Modified: haiku/trunk/src/add-ons/print/drivers/pcl6/DeltaRowCompression.cpp
===================================================================
--- haiku/trunk/src/add-ons/print/drivers/pcl6/DeltaRowCompression.cpp  
2010-07-03 09:34:59 UTC (rev 37369)
+++ haiku/trunk/src/add-ons/print/drivers/pcl6/DeltaRowCompression.cpp  
2010-07-03 10:23:04 UTC (rev 37370)
@@ -1,45 +1,57 @@
 /* 
 ** DeltaRowCompression.cpp
-** Copyright 2005, Michael Pfeiffer, laplace@xxxxxxxxxxxxxxxxxxxxxx All rights 
reserved.
+** Copyright 2005, Michael Pfeiffer, laplace@xxxxxxxxxxxxxxxxxxxxxx
+** All rights reserved.
 ** Distributed under the terms of the OpenBeOS License.
 */
+
+
 #include "DeltaRowCompression.h"
 
+#include <memory.h>
+
 #include <SupportDefs.h>
 
-#include <memory.h>
 
-AbstractDeltaRowCompressor::AbstractDeltaRowCompressor(int rowSize, uchar 
initialSeed)
-       : fSeedRow(new uchar[rowSize])
-       , fSize(rowSize)
-       , fInitialSeed(initialSeed)
+AbstractDeltaRowCompressor::AbstractDeltaRowCompressor(int rowSize,
+       uchar initialSeed)
+       :
+       fSeedRow(new uchar[rowSize]),
+       fSize(rowSize),
+       fInitialSeed(initialSeed)
 {
        Reset();
 }
 
+
 AbstractDeltaRowCompressor::~AbstractDeltaRowCompressor()
 {
        delete fSeedRow;
        fSeedRow = NULL;
 }
 
-status_t AbstractDeltaRowCompressor::InitCheck()
+
+status_t
+AbstractDeltaRowCompressor::InitCheck()
 {
-       if (fSeedRow != NULL) {
+       if (fSeedRow != NULL)
                return B_OK;
-       } else {
+       else
                return B_NO_MEMORY;
-       }
 }
 
-void AbstractDeltaRowCompressor::Reset()
+
+void
+AbstractDeltaRowCompressor::Reset()
 {
-       if (fSeedRow != NULL) {
+       if (fSeedRow != NULL)
                memset(fSeedRow, fInitialSeed, fSize);
-       }
 }
 
-int AbstractDeltaRowCompressor::CompressRaw(const uchar* row, bool 
updateSeedRow, bool updateDeltaRow)
+
+int
+AbstractDeltaRowCompressor::CompressRaw(const uchar* row, bool updateSeedRow,
+       bool updateDeltaRow)
 {
        int index = DiffersIndex(row, 0);
        if (index == -1) {
@@ -56,24 +68,21 @@
                
                // delta starts at index and contains length bytes
                do {
-                       
                        // control byte limits data bytes to 8 bytes
                        int deltaBytes = length;
-                       if (length > 8) {
+                       if (length > 8)
                                deltaBytes = 8;
-                       }
-                       
+
                        // calculate offset
                        int totalOffset = index - seedRowIndex;
                        bool needsOffsetBytes = totalOffset > 30;
                        int offset = totalOffset;
                        // control byte limits offset value to 31
-                       if (needsOffsetBytes) {
+                       if (needsOffsetBytes)
                                offset = 31;
-                       }
                        
                        // write control byte (delta bytes bits 5-7; offset 
bits 0-4)
-                       Put(((deltaBytes-1) << 5) | offset);
+                       Put(((deltaBytes - 1) << 5) | offset);
                        
                        if (needsOffsetBytes) {
                                // write additional offset bytes after control 
byte     
@@ -112,18 +121,25 @@
        return fDeltaRowIndex;
 }
 
-int AbstractDeltaRowCompressor::CalculateSize(const uchar* row, bool 
updateSeedRow)
+
+int
+AbstractDeltaRowCompressor::CalculateSize(const uchar* row, bool updateSeedRow)
 {
        return CompressRaw(row, updateSeedRow, false);
 }
 
-void AbstractDeltaRowCompressor::Compress(const uchar* row)
+
+void
+AbstractDeltaRowCompressor::Compress(const uchar* row)
 {
        CompressRaw(row, true, true);
 }
 
+
 #ifdef TEST_DELTA_ROW_COMPRESSION
-void test(AbstractDeltaRowCompressor* compressor, uchar* row) {
+
+void
+test(AbstractDeltaRowCompressor* compressor, uchar* row) {
        int size = compressor->CalculateSize(row);
        printf("size %d\n", size);
 
@@ -139,7 +155,9 @@
        printf("\n");
 }
 
-int main(int argc, char *argv[])
+
+int
+main(int argc, char* argv[])
 {
        int n = 5;
        uchar row1[] = {0, 0, 0, 0, 0};
@@ -152,4 +170,4 @@
        test(&compressor, row3);
 }
 
-#endif
+#endif // TEST_DELTA_ROW_COMPRESSION

Modified: haiku/trunk/src/add-ons/print/drivers/pcl6/DeltaRowCompression.h
===================================================================
--- haiku/trunk/src/add-ons/print/drivers/pcl6/DeltaRowCompression.h    
2010-07-03 09:34:59 UTC (rev 37369)
+++ haiku/trunk/src/add-ons/print/drivers/pcl6/DeltaRowCompression.h    
2010-07-03 10:23:04 UTC (rev 37370)
@@ -1,118 +1,123 @@
 /* 
 ** DeltaRowCompression.h
-** Copyright 2005, Michael Pfeiffer, laplace@xxxxxxxxxxxxxxxxxxxxxx All rights 
reserved.
+** Copyright 2005, Michael Pfeiffer, laplace@xxxxxxxxxxxxxxxxxxxxxx
+** All rights reserved.
 ** Distributed under the terms of the OpenBeOS License.
 */
 #ifndef _DELTA_ROW_COMPRESSION_H
 #define _DELTA_ROW_COMPRESSION_H
 
+
 #include <Debug.h>
 
+
 class AbstractDeltaRowCompressor {
 public:
-       AbstractDeltaRowCompressor(int rowSize, uchar initialSeed);
-       virtual ~AbstractDeltaRowCompressor();
+                                               AbstractDeltaRowCompressor(int 
rowSize,
+                                                       uchar initialSeed);
+       virtual                         ~AbstractDeltaRowCompressor();
        
        // InitCheck returns B_OK on successful construction of this object or 
        // B_NO_MEMORY if the buffer for the seed row could not be allocated.
-       status_t InitCheck();
+                       status_t        InitCheck();
        
        // Clears the seed row to the initial seed specified in the constructor
-       void Reset();
+                       void            Reset();
        
        // Returns the size of the delta row. 
        // The size is 0 if the row is equal to the seed row (previous row).
        // The seed row is updated only if updateSeedRow is true.
-       int CalculateSize(const uchar* row, bool updateSeedRow = false);
+                       int                     CalculateSize(const uchar* row,
+                                                       bool updateSeedRow = 
false);
        
        // Compresses the row using the delta row compression algorithm.
        // The seed row is updated.
-       void Compress(const uchar* row);
+                       void            Compress(const uchar* row);
 
 protected:
        // append byte to delta row
-       virtual void AppendByteToDeltaRow(uchar byte) = 0;
+       virtual void            AppendByteToDeltaRow(uchar byte) = 0;
        
        // returns the current size of the delta row
-       inline int CurrentDeltaRowSize() {
-               return fDeltaRowIndex;
-       }
+       inline  int                     CurrentDeltaRowSize()
+                                               {
+                                                       return fDeltaRowIndex;
+                                               }
 
 private:
        // Returns the index where seed row and row differ 
        // or -1 if both arrays are equal.
-       inline int DiffersIndex(const uchar* row, int index)
-       {
-               while (index < fSize) {
-                       if (fSeedRow[index] != row[index]) {
-                               return index;
-                       }
-       
-                       index ++;
-               }
-               
-               return -1;
-       }
+       inline  int                     DiffersIndex(const uchar* row, int 
index)
+                                               {
+                                                       while (index < fSize) {
+                                                               if 
(fSeedRow[index] != row[index])
+                                                                       return 
index;
+                                                               index ++;
+                                                       }
+                                                       return -1;
+                                               }
 
        // Returns the number of bytes that row differs from seed row 
        // starting at the specified index.
-       inline int DiffersLength(const uchar* row, int index)
-       {
-               int startIndex = index;
-               
-               while (index < fSize) {
-                       if (fSeedRow[index] == row[index]) {
-                               break;
-                       }
-                       
-                       index ++;
-               }
-               return index - startIndex;
-       }
+       inline  int                     DiffersLength(const uchar* row, int 
index)
+                                               {
+                                                       int startIndex = index;
+                                                       while (index < fSize) {
+                                                               if 
(fSeedRow[index] == row[index])
+                                                                       break;
+                                                               index ++;
+                                                       }
+                                                       return index - 
startIndex;
+                                               }
 
        // Compresses row with delta row compression algorithm.
        // The seed row is updated only if updateSeedRow is true.
        // If updateDeltaRow is true the method AppendByteToDeltaRow is called.
-       int CompressRaw(const uchar* row, bool updateSeedRow, bool 
updateDeltaRow);
+                       int             CompressRaw(const uchar* row, bool 
updateSeedRow,
+                                                       bool updateDeltaRow);
 
        // write byte to delta row and calculate size of delta row
-       void Put(uchar byte) {
-               if (fUpdateDeltaRow) {
-                       AppendByteToDeltaRow(byte);
-               }
-               fDeltaRowIndex ++;
-       }
+                       void            Put(uchar byte)
+                                               {
+                                                       if (fUpdateDeltaRow)
+                                                               
AppendByteToDeltaRow(byte);
+                                                       fDeltaRowIndex ++;
+                                               }
 
-       uchar*  fSeedRow;     // the seed row
-       int     fSize;        // the size of the seed row in bytes
-       uchar   fInitialSeed; // the value to initialize the seed row with
+                       uchar*          fSeedRow; // the seed row
+                       int                     fSize; // the size of the seed 
row in bytes
+                       uchar           fInitialSeed;
+                                                       // the value to 
initialize the seed row with
 
-       int     fDeltaRowIndex;  // the index of the next byte to be written 
into the delta row
-       bool    fUpdateDeltaRow; // write delta row
+                       int                     fDeltaRowIndex;
+                                                       // the index of the 
next byte to be written into
+                                                       // the delta row
+                       bool            fUpdateDeltaRow; // write delta row
 };
 
+
 class DeltaRowCompressor : public AbstractDeltaRowCompressor
 {
 public:
-       DeltaRowCompressor(int rowSize, uchar initialSeed)
-               : AbstractDeltaRowCompressor(rowSize, initialSeed)
-       {
-               // nothing to do
-       }
+                                               DeltaRowCompressor(int rowSize, 
uchar initialSeed)
+                                               :
+                                               
AbstractDeltaRowCompressor(rowSize, initialSeed)
+                                               {}
        
        // The delta row to be written to.
-       void SetDeltaRow(uchar* deltaRow) {
-               fDeltaRow = deltaRow;
-       }
+                       void            SetDeltaRow(uchar* deltaRow)
+                                               {
+                                                       fDeltaRow = deltaRow;
+                                               }
        
 protected:
-       virtual void AppendByteToDeltaRow(uchar byte) {
-               fDeltaRow[CurrentDeltaRowSize()] = byte;
-       }       
+       virtual void            AppendByteToDeltaRow(uchar byte)
+                                               {
+                                                       
fDeltaRow[CurrentDeltaRowSize()] = byte;
+                                               }       
 
 private:
-       uchar* fDeltaRow; // the delta row
+                       uchar*          fDeltaRow; // the delta row
 };
 
 #endif
-

Modified: haiku/trunk/src/add-ons/print/drivers/pcl6/PCL6.cpp
===================================================================
--- haiku/trunk/src/add-ons/print/drivers/pcl6/PCL6.cpp 2010-07-03 09:34:59 UTC 
(rev 37369)
+++ haiku/trunk/src/add-ons/print/drivers/pcl6/PCL6.cpp 2010-07-03 10:23:04 UTC 
(rev 37370)
@@ -4,22 +4,24 @@
  * Copyright 2003 Michael Pfeiffer.
  */
 
+
+#include "PCL6.h"
+
+#include <memory.h>
+
 #include <Alert.h>
 #include <Bitmap.h>
 #include <File.h>
-#include <memory>
 
-
 #include "DbgMsg.h"
 #include "DeltaRowCompression.h"
 #include "Halftone.h"
 #include "JobData.h"
 #include "PackBits.h"
-#include "PCL6.h"
 #include "PCL6Cap.h"
 #include "PCL6Config.h"
+#include "PCL6Rasterizer.h"
 #include "PrinterData.h"
-#include "PCL6Rasterizer.h"
 #include "UIDriver.h"
 #include "ValidRect.h"
 
@@ -29,74 +31,87 @@
 #define std
 #endif
 
+
 // DeltaRowStreamCompressor writes the delta row directly to the 
 // in the contructor specified stream.
 class DeltaRowStreamCompressor : public AbstractDeltaRowCompressor
 {
 public:
-       DeltaRowStreamCompressor(int rowSize, uchar initialSeed, PCL6Writer 
*writer)
-               : AbstractDeltaRowCompressor(rowSize, initialSeed)
-               , fWriter(writer)
-       {
-               // nothing to do
-       }
+                               DeltaRowStreamCompressor(int rowSize, uchar 
initialSeed,
+                                       PCL6Writer* writer)
+                               :
+                               AbstractDeltaRowCompressor(rowSize, 
initialSeed),
+                               fWriter(writer)
+                               {}
        
 protected:
-       void AppendByteToDeltaRow(uchar byte) {
-               fWriter->Append(byte);
-       }
+       void            AppendByteToDeltaRow(uchar byte)
+                               {
+                                       fWriter->Append(byte);
+                               }
        
 private:
-       PCL6Writer *fWriter;    
+       PCL6Writer*     fWriter;        
 };
 
 
-PCL6Driver::PCL6Driver(BMessage *msg, PrinterData *printer_data, const 
PrinterCap *printer_cap)
-       : GraphicsDriver(msg, printer_data, printer_cap)
+PCL6Driver::PCL6Driver(BMessage* msg, PrinterData* printer_data,
+       const PrinterCap* printer_cap)
+       :
+       GraphicsDriver(msg, printer_data, printer_cap)
 {
        fHalftone = NULL;
        fWriter = NULL;
 }
 
-void PCL6Driver::write(const uint8 *data, uint32 size)
+
+void
+PCL6Driver::write(const uint8* data, uint32 size)
 {
        writeSpoolData(data, size);
 }
 
-bool PCL6Driver::startDoc()
+
+bool
+PCL6Driver::startDoc()
 {
        try {
                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;
        }
-       catch (TransportException &err) {
+       catch (TransportException& err) {
                return false;
        } 
 }
 
-bool PCL6Driver::endDoc(bool)
+
+bool
+PCL6Driver::endDoc(bool)
 {
        try {
-               if (fHalftone) {
+               if (fHalftone)
                        delete fHalftone;
-               }
                jobEnd();
                return true;
        }
-       catch (TransportException &err) {
+       catch (TransportException& err) {
                return false;
        } 
 }
 
-bool PCL6Driver::nextBand(BBitmap *bitmap, BPoint *offset)
+
+bool
+PCL6Driver::nextBand(BBitmap* bitmap, BPoint* offset)
 {
        DBGMSG(("> nextBand\n"));
 
        try {
                int y = (int)offset->y;
        
-               PCL6Rasterizer *rasterizer;
+               PCL6Rasterizer* rasterizer;
                if (useColorMode()) {
                        #if COLOR_DEPTH == 8
                                rasterizer = new ColorRGBRasterizer(fHalftone);
@@ -105,25 +120,27 @@
                        #else
                                #error COLOR_DEPTH must be either 1 or 8!       
        
                        #endif
-               } else {
+               } else
                        rasterizer = new MonochromeRasterizer(fHalftone);
-               }
+
                auto_ptr<Rasterizer> _rasterizer(rasterizer);
-               bool valid = rasterizer->SetBitmap((int)offset->x, 
(int)offset->y, bitmap, getPageHeight());
+               bool valid = rasterizer->SetBitmap((int)offset->x, 
(int)offset->y,
+                       bitmap, getPageHeight());
                
                if (valid) {
                        rasterizer->InitializeBuffer();
                        
                        // Use compressor to calculate delta row size
-                       DeltaRowCompressor *deltaRowCompressor = NULL;
+                       DeltaRowCompressor* deltaRowCompressor = NULL;
                        if (supportsDeltaRowCompression()) {
-                               deltaRowCompressor = new 
DeltaRowCompressor(rasterizer->GetOutRowSize(), 0);
+                               deltaRowCompressor = 
+                                       new 
DeltaRowCompressor(rasterizer->GetOutRowSize(), 0);
                                if (deltaRowCompressor->InitCheck() != B_OK) {
                                        delete deltaRowCompressor;
                                        return false;
                                }
                        }
-                       auto_ptr<DeltaRowCompressor> 
_deltaRowCompressor(deltaRowCompressor);
+                       
auto_ptr<DeltaRowCompressor>_deltaRowCompressor(deltaRowCompressor);
                        int deltaRowSize = 0;
                
                        // remember position            
@@ -131,22 +148,26 @@
                        int yPage = rasterizer->GetY();
                        
                        while (rasterizer->HasNextLine()) {
-                               const uchar *rowBuffer = 
(uchar*)rasterizer->RasterizeNextLine();
+                               const uchar* rowBuffer = 
+                                       static_cast<const 
uchar*>(rasterizer->RasterizeNextLine());
                                
                                if (deltaRowCompressor != NULL) {
-                                       int size = 
deltaRowCompressor->CalculateSize(rowBuffer, true);
-                                       deltaRowSize += size + 2; // two bytes 
for the row byte count
+                                       int size =
+                                               
deltaRowCompressor->CalculateSize(rowBuffer, true);
+                                       deltaRowSize += size + 2;
+                                               // two bytes for the row byte 
count
                                }
                        }
        
                        y = rasterizer->GetY();
        
-                       uchar *outBuffer = rasterizer->GetOutBuffer();
+                       uchar* outBuffer = rasterizer->GetOutBuffer();
                        int outBufferSize = rasterizer->GetOutBufferSize();
                        int outRowSize = rasterizer->GetOutRowSize();
                        int width = rasterizer->GetWidth();
                        int height = rasterizer->GetHeight();
-                       writeBitmap(outBuffer, outBufferSize, outRowSize, 
xPage, yPage, width, height, deltaRowSize);
+                       writeBitmap(outBuffer, outBufferSize, outRowSize, 
xPage, yPage,
+                               width, height, deltaRowSize);
                }
 
                if (y >= getPageHeight()) {
@@ -158,14 +179,17 @@
 
                return true;
        }
-       catch (TransportException &err) {
-               BAlert *alert = new BAlert("", err.what(), "OK");
+       catch (TransportException& err) {
+               BAlert* alert = new BAlert("", err.what(), "OK");
                alert->Go();
                return false;
        } 
 }
 
-void PCL6Driver::writeBitmap(const uchar* buffer, int outSize, int rowSize, 
int x, int y, int width, int height, int deltaRowSize)
+
+void
+PCL6Driver::writeBitmap(const uchar* buffer, int outSize, int rowSize, int x,
+       int y, int width, int height, int deltaRowSize)
 {
        // choose the best compression method
        PCL6Writer::Compression compressionMethod = PCL6Writer::kNoCompression;
@@ -193,43 +217,55 @@
        
        startRasterGraphics(x, y, width, height, compressionMethod);
 
-       rasterGraphics(buffer, outSize, dataSize, rowSize, height, 
compressionMethod);
+       rasterGraphics(buffer, outSize, dataSize, rowSize, height,
+               compressionMethod);
 
        endRasterGraphics();
        
 #if DISPLAY_COMPRESSION_STATISTICS
        fprintf(stderr, "Out Size       %d %2.2f\n", (int)outSize, 100.0);
 #if ENABLE_RLE_COMPRESSION
-       fprintf(stderr, "RLE Size       %d %2.2f\n", (int)rleSize, 100.0 * 
rleSize / outSize);
+       fprintf(stderr, "RLE Size       %d %2.2f\n", (int)rleSize,
+               100.0 * rleSize / outSize);
 #endif
 #if ENABLE_DELTA_ROW_COMPRESSION
-       fprintf(stderr, "Delta Row Size %d %2.2f\n", (int)deltaRowSize, 100.0 * 
deltaRowSize / outSize);
+       fprintf(stderr, "Delta Row Size %d %2.2f\n", (int)deltaRowSize,
+               100.0 * deltaRowSize / outSize);
 #endif
-       fprintf(stderr, "Data Size      %d %2.2f\n", (int)dataSize, 100.0 * 
dataSize / outSize);
+       fprintf(stderr, "Data Size      %d %2.2f\n", (int)dataSize,
+               100.0 * dataSize / outSize);
 #endif
 }
 
 
-void PCL6Driver::jobStart()
+void
+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::kInch, PCL6Writer::kBackChAndErrPage);
+       PCL6Writer::ProtocolClass pc =
+               (PCL6Writer::ProtocolClass)getProtocolClass();
+       fWriter->PJLHeader(pc, getJobData()->getXres(),
+               "Copyright (c) 2003, 2004 Haiku");
+       fWriter->BeginSession(getJobData()->getXres(), getJobData()->getYres(),
+               PCL6Writer::kInch, PCL6Writer::kBackChAndErrPage);
        fWriter->OpenDataSource();
        fMediaSide = PCL6Writer::kFrontMediaSide;
 }
 
-bool PCL6Driver::startPage(int)
+
+bool
+PCL6Driver::startPage(int)
 {
        PCL6Writer::Orientation orientation = PCL6Writer::kPortrait;
        if (getJobData()->getOrientation() == JobData::kLandscape) {
                orientation = PCL6Writer::kLandscape;
        }
        
-       PCL6Writer::MediaSize mediaSize = 
PCL6Driver::mediaSize(getJobData()->getPaper());
-       PCL6Writer::MediaSource mediaSource = 
PCL6Driver::mediaSource(getJobData()->getPaperSource());
+       PCL6Writer::MediaSize mediaSize = 
+               PCL6Driver::mediaSize(getJobData()->getPaper());
+       PCL6Writer::MediaSource mediaSource = 
+               PCL6Driver::mediaSource(getJobData()->getPaperSource());
        if (getJobData()->getPrintStyle() == JobData::kSimplex) {
                fWriter->BeginPage(orientation, mediaSize, mediaSource);
        } else if (getJobData()->getPrintStyle() == JobData::kDuplex) {
@@ -237,27 +273,29 @@
                fWriter->BeginPage(orientation, mediaSize, mediaSource, 
                        PCL6Writer::kDuplexVerticalBinding, fMediaSide);
 
-               if (fMediaSide == PCL6Writer::kFrontMediaSide) {
+               if (fMediaSide == PCL6Writer::kFrontMediaSide)
                        fMediaSide = PCL6Writer::kBackMediaSide;
-               } else {
+               else
                        fMediaSide = PCL6Writer::kFrontMediaSide;
-               }
-       } else {
+       } else
                return false;
-       }
        
        // PageOrigin from Windows NT printer driver
        int x = 142 * getJobData()->getXres() / 600;
        int y = 100 * getJobData()->getYres() / 600;
        fWriter->SetPageOrigin(x, y);
-       fWriter->SetColorSpace(useColorMode() ? PCL6Writer::kRGB : 
PCL6Writer::kGray);
+       fWriter->SetColorSpace(useColorMode() ? PCL6Writer::kRGB 
+               : PCL6Writer::kGray);
        fWriter->SetPaintTxMode(PCL6Writer::kOpaque);
        fWriter->SetSourceTxMode(PCL6Writer::kOpaque);
        fWriter->SetROP(204);
        return true;
 }
 
-void PCL6Driver::startRasterGraphics(int x, int y, int width, int height, 
PCL6Writer::Compression compressionMethod)
+
+void
+PCL6Driver::startRasterGraphics(int x, int y, int width, int height,
+       PCL6Writer::Compression compressionMethod)
 {
        PCL6Writer::ColorDepth colorDepth;
        if (useColorMode()) {
@@ -268,26 +306,25 @@
                #else
                        #error COLOR_DEPTH must be either 1 or 8!               
                #endif
-       } else {
+       } else
                colorDepth = PCL6Writer::k1Bit;
-       }
-       fWriter->BeginImage(PCL6Writer::kDirectPixel, colorDepth, width, 
height, width, height);
+
+       fWriter->BeginImage(PCL6Writer::kDirectPixel, colorDepth, width, height,
+               width, height);
        fWriter->ReadImage(compressionMethod, 0, height);
 }
 
-void PCL6Driver::endRasterGraphics()
+
+void
+PCL6Driver::endRasterGraphics()
 {
        fWriter->EndImage();
 }
 
-void PCL6Driver::rasterGraphics(
-       const uchar *buffer,
-       int bufferSize,
-       int dataSize,
-       int rowSize,
-       int height,
-       int compressionMethod
-)
+
+void
+PCL6Driver::rasterGraphics(const uchar* buffer, int bufferSize, int dataSize,
+       int rowSize, int height, int compressionMethod)
 {
        // write bitmap byte size
        fWriter->EmbeddedDataPrefix32(dataSize);
@@ -295,7 +332,7 @@
        // write data
        if (compressionMethod == PCL6Writer::kRLECompression) {
                // use RLE compression
-               uchar *outBuffer = new uchar[dataSize];
+               uchar* outBuffer = new uchar[dataSize];
                pack_bits(outBuffer, buffer, bufferSize);
                fWriter->Append(outBuffer, dataSize);
                delete[] outBuffer;
@@ -326,18 +363,22 @@
        }
 }
 
-bool PCL6Driver::endPage(int)
+
+bool
+PCL6Driver::endPage(int)
 {
        try {
                fWriter->EndPage(getJobData()->getCopies());
                return true;
        }
-       catch (TransportException &err) {
+       catch (TransportException& err) {
                return false;
        } 
 }
 
-void PCL6Driver::jobEnd()
+
+void
+PCL6Driver::jobEnd()
 {
        fWriter->CloseDataSource();
        fWriter->EndSession();
@@ -347,44 +388,60 @@
        fWriter = NULL;
 }
 
-void PCL6Driver::move(int x, int y)
+
+void
+PCL6Driver::move(int x, int y)
 {
        fWriter->SetCursor(x, y);
 }
 
+
 bool
 PCL6Driver::supportsRLECompression()
 {
        return getJobData()->getColor() != JobData::kColorCompressionDisabled;
 }
 
+
 bool
 PCL6Driver::supportsDeltaRowCompression()
 {
-       return getProtocolClass() >= PCL6Writer::kProtocolClass2_1 &&
-               getJobData()->getColor() != JobData::kColorCompressionDisabled;
+       return getProtocolClass() >= PCL6Writer::kProtocolClass2_1
+               && getJobData()->getColor() != 
JobData::kColorCompressionDisabled;
 }
 
+
 bool
 PCL6Driver::useColorMode()
 {
        return getJobData()->getColor() != JobData::kMonochrome;
 }
 
-PCL6Writer::MediaSize PCL6Driver::mediaSize(JobData::Paper paper)
+
+PCL6Writer::MediaSize
+PCL6Driver::mediaSize(JobData::Paper paper)
 {
        switch (paper) {
-               case JobData::kLetter:    return PCL6Writer::kLetterPaper;
-               case JobData::kLegal:     return PCL6Writer::kLegalPaper;
-               case JobData::kA4:        return PCL6Writer::kA4Paper;
-               case JobData::kExecutive: return PCL6Writer::kExecPaper;
-               case JobData::kLedger:    return PCL6Writer::kLedgerPaper;
-               case JobData::kA3:        return PCL6Writer::kA3Paper;
-               case JobData::kB5:        return PCL6Writer::kB5Paper;
-               case JobData::kJapanesePostcard:  
-                                  return PCL6Writer::kJPostcard;
-               case JobData::kA5:        return PCL6Writer::kA5Paper;
-               case JobData::kB4:        return PCL6Writer::kJB4Paper;
+               case JobData::kLetter:
+                       return PCL6Writer::kLetterPaper;
+               case JobData::kLegal:
+                       return PCL6Writer::kLegalPaper;
+               case JobData::kA4:
+                       return PCL6Writer::kA4Paper;
+               case JobData::kExecutive:
+                       return PCL6Writer::kExecPaper;
+               case JobData::kLedger:
+                       return PCL6Writer::kLedgerPaper;
+               case JobData::kA3:
+                       return PCL6Writer::kA3Paper;
+               case JobData::kB5:
+                       return PCL6Writer::kB5Paper;
+               case JobData::kJapanesePostcard:
+                       return PCL6Writer::kJPostcard;
+               case JobData::kA5:
+                       return PCL6Writer::kA5Paper;
+               case JobData::kB4:
+                       return PCL6Writer::kJB4Paper;
 /*
                case : return PCL6Writer::kCOM10Envelope;
                case : return PCL6Writer::kMonarchEnvelope;
@@ -407,20 +464,28 @@
        }
 }
 
-PCL6Writer::MediaSource PCL6Driver::mediaSource(JobData::PaperSource source)
+
+PCL6Writer::MediaSource
+PCL6Driver::mediaSource(JobData::PaperSource source)
 {
        switch (source) {
-               case JobData::kAuto:       return PCL6Writer::kAutoSelect;
-               case JobData::kCassette1:  return PCL6Writer::kDefaultSource;
-               case JobData::kCassette2:  return PCL6Writer::kEnvelopeTray;
-               case JobData::kLower:      return PCL6Writer::kLowerCassette;
-               case JobData::kUpper:      return PCL6Writer::kUpperCassette;
-               case JobData::kMiddle:     return PCL6Writer::kThirdCassette;
-               case JobData::kManual:     return PCL6Writer::kManualFeed;
-               case JobData::kCassette3:  return PCL6Writer::kMultiPurposeTray;
-               
+               case JobData::kAuto:
+                       return PCL6Writer::kAutoSelect;
+               case JobData::kCassette1:
+                       return PCL6Writer::kDefaultSource;
+               case JobData::kCassette2:
+                       return PCL6Writer::kEnvelopeTray;
+               case JobData::kLower:
+                       return PCL6Writer::kLowerCassette;
+               case JobData::kUpper:
+                       return PCL6Writer::kUpperCassette;
+               case JobData::kMiddle:
+                       return PCL6Writer::kThirdCassette;
+               case JobData::kManual:
+                       return PCL6Writer::kManualFeed;
+               case JobData::kCassette3:
+                       return PCL6Writer::kMultiPurposeTray;
                default:
                        return PCL6Writer::kAutoSelect;
        }
 }
-

Modified: haiku/trunk/src/add-ons/print/drivers/pcl6/PCL6.h
===================================================================
--- haiku/trunk/src/add-ons/print/drivers/pcl6/PCL6.h   2010-07-03 09:34:59 UTC 
(rev 37369)
+++ haiku/trunk/src/add-ons/print/drivers/pcl6/PCL6.h   2010-07-03 10:23:04 UTC 
(rev 37370)
@@ -3,7 +3,6 @@
  * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
  * Copyright 2003 Michael Pfeiffer.
  */
-
 #ifndef __PCL6_H
 #define __PCL6_H
 
@@ -12,45 +11,46 @@
 #include "PCL6Cap.h"
 #include "PCL6Writer.h"
 
+
 class Halftone;
 
-class PCL6Driver : public GraphicsDriver, public PCL6WriterStream 
+
+class PCL6Driver : public GraphicsDriver, public PCL6WriterStream
 {
 public:
-       PCL6Driver(BMessage *msg, PrinterData *printer_data, const PrinterCap 
*printer_cap);
+                                       PCL6Driver(BMessage* msg, PrinterData* 
printer_data,
+                                               const PrinterCap* printer_cap);
 
-       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    startDoc();
+       virtual bool    startPage(int page);
+       virtual bool    nextBand(BBitmap* bitmap, BPoint* offset);
+       virtual bool    endPage(int page);
+       virtual bool    endDoc(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, int x, 
int y, int width, int height, int deltaRowSize);
-       void startRasterGraphics(int x, int y, int width, int height, 
PCL6Writer::Compression compressionMethod);
-       void endRasterGraphics();
-       void rasterGraphics(
-               const uchar *buffer,
-               int bufferSize,
-               int dataSize,
-               int rowSize,
-               int height,
-               int compression_method);
-       void jobEnd();
+                       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,
+                                               PCL6Writer::Compression 
compressionMethod);
+                       void    endRasterGraphics();
+                       void    rasterGraphics(const uchar* buffer, int 
bufferSize,
+                                               int dataSize, int rowSize, int 
height,
+                                               int compression_method);
+                       void    jobEnd();
 
-       PCL6Writer            *fWriter;
-       PCL6Writer::MediaSide fMediaSide; // side if in duplex mode
-       Halftone              *fHalftone;
+                       PCL6Writer*     fWriter;
+                       PCL6Writer::MediaSide fMediaSide; // side if in duplex 
mode
+                       Halftone*       fHalftone;
 };
 
-#endif /* __PCL6_H */
+#endif // __PCL6_H

Modified: haiku/trunk/src/add-ons/print/drivers/pcl6/PCL6Cap.cpp
===================================================================
--- haiku/trunk/src/add-ons/print/drivers/pcl6/PCL6Cap.cpp      2010-07-03 
09:34:59 UTC (rev 37369)
+++ haiku/trunk/src/add-ons/print/drivers/pcl6/PCL6Cap.cpp      2010-07-03 
10:23:04 UTC (rev 37370)
@@ -3,8 +3,8 @@
  * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
  * Copyright 2003-2007 Michael Pfeiffer.
  */
+#include "PCL6Cap.h"
 
-#include "PCL6Cap.h"
 #include "PCL6Config.h"
 #include "PCL6Writer.h"
 #include "PrinterData.h"
@@ -133,58 +133,65 @@
 // since 2.1
 
 // since 1.1
-const PaperSourceCap defaultSource("Default",  false,  JobData::kCassette1);
-const PaperSourceCap autobin("Auto",  true,  JobData::kAuto);
-const PaperSourceCap manualFeed("Manual Feed",  false,  JobData::kManual);
-const PaperSourceCap multiPurposeTray("Multi Purpose Tray",  false,  
JobData::kCassette3);
-const PaperSourceCap upperCassette("Upper Cassette",  false,  JobData::kUpper);
-const PaperSourceCap lowerCassette("Lower Cassette",  false,  JobData::kLower);
-const PaperSourceCap envelopeTray("Envelope Tray",  false,  
JobData::kCassette2);
+const PaperSourceCap defaultSource("Default", false, JobData::kCassette1);
+const PaperSourceCap autobin("Auto", true, JobData::kAuto);
+const PaperSourceCap manualFeed("Manual Feed", false, JobData::kManual);
+const PaperSourceCap multiPurposeTray("Multi Purpose Tray", false,
+       JobData::kCassette3);
+const PaperSourceCap upperCassette("Upper Cassette", false, JobData::kUpper);
+const PaperSourceCap lowerCassette("Lower Cassette", false, JobData::kLower);
+const PaperSourceCap envelopeTray("Envelope Tray", false,
+       JobData::kCassette2);
 // since 2.0:
 const PaperSourceCap thridCassette("Thrid Cassette",  false,  
JobData::kMiddle);
 
-const ResolutionCap dpi150("150dpi",   false, 150,  150);
-const ResolutionCap dpi300("300dpi",   true, 300,  300);
-const ResolutionCap dpi600("600dpi",  false, 600,  600);
+const ResolutionCap dpi150("150dpi", false, 150, 150);
+const ResolutionCap dpi300("300dpi", true, 300, 300);
+const ResolutionCap dpi600("600dpi", false, 600, 600);
 const ResolutionCap dpi1200("1200dpi", false, 1200, 1200);

[... truncated: 2487 lines follow ...]

Other related posts:

  • » [haiku-commits] r37370 - haiku/trunk/src/add-ons/print/drivers/pcl6 - wpjvandermeer