|
From: <doc...@us...> - 2007-07-23 23:38:12
|
Revision: 113
http://openpcl.svn.sourceforge.net/openpcl/?rev=113&view=rev
Author: documentsystems
Date: 2007-07-23 16:38:14 -0700 (Mon, 23 Jul 2007)
Log Message:
-----------
For PCL Direct (not Windows Print), implemented the print "Legal first, then Letter" and "Letter first, then Legal".
Modified Paths:
--------------
openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java
Modified: openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java
===================================================================
--- openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java 2007-07-23 23:08:15 UTC (rev 112)
+++ openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java 2007-07-23 23:38:14 UTC (rev 113)
@@ -64,9 +64,8 @@
private PriModifyPclBytes mPriModifyPclBytes = null;
private PclParser mPclParser = null;
private StringBuffer mIndexNumbersStringBuffer = null;
- private int mNumberOfPrintPasses = 1;
- private int mCurrentPrintPassNumber = 1;
-
+ private int mNumberOfCopies = 1;
+
/**
* Constructor
* @author howard 6/1/06
@@ -278,19 +277,21 @@
PriDebug.releaseln(tMsgStringBuffer.toString());
// The number of additional copies has already been validated and is guaranteed to be 0 to 3 at this point
- mNumberOfPrintPasses = 1 + mPosPrintSetupDialogChoices.getNumAdditionalCopies();
+ mNumberOfCopies = 1 + mPosPrintSetupDialogChoices.getNumAdditionalCopies();
// Call the print of the all/selected/remaining/changed pages "N" times depending on Additional Copies field
- for (int i = 1; i <= mNumberOfPrintPasses; i++) {
+ for (int tNumCopies = 1; tNumCopies <= mNumberOfCopies; tNumCopies++) {
+
// Call "Use Windows Print" or "Print PCL Direct"
- if (mPosPrintSetupDialogChoices.isPrintFormatPclDirect()) {
- mPrintedOkReturn = printPclDirect(mPagesToPrintArrayList, mPosPrintSetupDialogChoices,
+ if (mPosPrintSetupDialogChoices.isPrintFormatWindowsPrint()) {
+ mPrintedOkReturn = imagePrint(mPagesToPrintArrayList, mPosPrintSetupDialogChoices,
mPrintingProgressBar, mPrintRequestAttributeSet);
} else {
- mPrintedOkReturn = imagePrint(mPagesToPrintArrayList, mPosPrintSetupDialogChoices,
+ mPrintedOkReturn = printPclDirect(mPagesToPrintArrayList, mPosPrintSetupDialogChoices,
mPrintingProgressBar, mPrintRequestAttributeSet);
}
- }
+
+ } // end "for (int tNumCopies = 1; tNumCopies <= mNumberOfCopies; tNumCopies++)"
return null;
}
@@ -331,6 +332,7 @@
ByteArrayInputStream tByteArrayInputStream = null;
ByteArrayOutputStream tByteArrayOutputStream =null;
int tPageNumber = 0;
+ int tLegalLetterPassesToDo = 1;
String tProgressBarBaseString = "Generating page: ";
byte[] tPclBytes = null;
byte[] tLetterlSizePaperBytes = new byte[] {sbESC, '&', 'l', '2', 'A'};
@@ -344,67 +346,111 @@
// by allocating a new bigger byte array then doing a memcopy to the new one.
tByteArrayOutputStream = new ByteArrayOutputStream(20 * 1024);
- // Get the PCL bytes for each page that the user selected in the tree (could be one page or multi page)
- for (tPageNumber = 0; tPageNumber < pPagesToPrintArrayList.size(); tPageNumber++) {
- // return if the passed in page number is less than 0 or greater than the number of current pages to print
- if (tPageNumber < 0 || tPageNumber >= mPagesToPrintArrayList.size()) { return false; }
- // Get the tree node user object for this print page by indexing into the print ArrayList to get the passed in page number
- tPrintThisTreeNode = mPagesToPrintArrayList.get(tPageNumber);
- // null pointer protection due to tree node user object got assigned to null from the ArrayList.get() above
- if (tPrintThisTreeNode == null) { continue; }
-
- // Get the actual PCL bytes to send to the printer
- tPclBytes = mPosView.getOpenPCLViewer().getPclBytesForTreeNode(tPrintThisTreeNode);
-
- // If no bytes on this page then continue to the next page
- if (tPclBytes == null || tPclBytes.length < 1) { continue; }
-
- // Modify the PCL bytes
- mPriModifyPclBytes.initializeState();
- mPclParser = new PclParser(tPclBytes, mPriModifyPclBytes);
- mPclParser.ParsePCL();
-
- byte[] tModifiedPclBytes = mPriModifyPclBytes.getModifiedPclBytes();
-
- // PriDebug.releaseln("Pcl page before, after bytes: " + tPclBytes.length + ", " + tModifiedPclBytes.length);
-
- try {
- if (pPosPrintSetupDialogChoices != null && pPosPrintSetupDialogChoices.isPaperSizePrintAllOnLegal()) {
- // The user has a check in the Print Setup dialog box for "Print all on Legal paper"
- // so FORCE ALL PAGES TO LEGAL SIZE no matter if LTR in the Blockument DSP values
- // or if this is a PCL file with a letter size PCL command
- tByteArrayOutputStream.write(tLegalSizePaperBytes);
-
- } else {
- // Pick the paper size by calling the below method which may be subclassed by a plugin.
- // The below uses polymorphism because the method isTreeNodePageLetterSize() is one of the subclassed
- // methods specified in the interface IPluginHooksOpenPCL
+ // Set the int variable that controls the "Legal first, then Letter", and "Letter first, then Legal"
+ if (mPosPrintSetupDialogChoices.isPaperSizeLegalFirstThenLetter() ||
+ mPosPrintSetupDialogChoices.isPaperSizeLetterFirstThenLegal()) {
+ tLegalLetterPassesToDo = 2;
+ } else {
+ tLegalLetterPassesToDo = 1;
+ }
+
+ // If doing "Legal first, then Letter" or doing "Letter first, then Legal", make 2 inner print passes here
+ for (int tLglLtrPassCount = 1; tLglLtrPassCount <= tLegalLetterPassesToDo; tLglLtrPassCount++) {
+
+ // for each page that the user selected in the tree (could be one page or multi page), get the PCL bytes
+ for (tPageNumber = 0; tPageNumber < pPagesToPrintArrayList.size(); tPageNumber++) {
+ // Get the tree node user object for this print page by indexing into the print ArrayList to get the passed in page number
+ tPrintThisTreeNode = mPagesToPrintArrayList.get(tPageNumber);
+ // null pointer protection to avoid stack dump
+ if (tPrintThisTreeNode == null) { continue; }
+
+ // If doing "Legal first, then Letter" or doing "Letter first, then Legal" then skip Letter or Legal pages depending
+ if (tLegalLetterPassesToDo > 1) {
if (mPosView.getOpenPCLViewer().isTreeNodePageLetterSize(tPrintThisTreeNode)) {
- // Letter size
- tByteArrayOutputStream.write(tLetterlSizePaperBytes);
+ // This page is Letter size
+ if (mPosPrintSetupDialogChoices.isPaperSizeLegalFirstThenLetter()) {
+ // Print dialog setting is "Legal first, then Letter"
+ if (tLglLtrPassCount == 1) {
+ // and this is the 1st pass, so skip Letter pages
+ continue;
+ }
+ } else if (mPosPrintSetupDialogChoices.isPaperSizeLetterFirstThenLegal()) {
+ // Print dialog setting is "Letter first, then Legal "
+ if (tLglLtrPassCount == 2) {
+ // and this is the 2nd pass, so skip Letter pages
+ continue;
+ }
+ }
} else {
- // Legal size
+ // This page is Legal size
+ if (mPosPrintSetupDialogChoices.isPaperSizeLetterFirstThenLegal()) {
+ // Print dialog setting is "Letter first, then Legal"
+ if (tLglLtrPassCount == 1) {
+ // and this is the 1st pass, so skip Legal pages
+ continue;
+ }
+ } else if (mPosPrintSetupDialogChoices.isPaperSizeLegalFirstThenLetter()) {
+ // Print dialog setting is "Legal first, then Letter"
+ if (tLglLtrPassCount == 2) {
+ // and this is the 2nd pass, so skip Legal pages
+ continue;
+ }
+ }
+ }
+ } // end "if (tLegalLetterPassesToDo > 1)"
+
+ // Get the actual PCL bytes to send to the printer
+ tPclBytes = mPosView.getOpenPCLViewer().getPclBytesForTreeNode(tPrintThisTreeNode);
+
+ // If no bytes on this page then continue to the next page
+ if (tPclBytes == null || tPclBytes.length < 1) { continue; }
+
+ // Modify the PCL bytes
+ mPriModifyPclBytes.initializeState();
+ mPclParser = new PclParser(tPclBytes, mPriModifyPclBytes);
+ mPclParser.ParsePCL();
+
+ byte[] tModifiedPclBytes = mPriModifyPclBytes.getModifiedPclBytes();
+ // PriDebug.releaseln("Pcl page before, after bytes: " + tPclBytes.length + ", " + tModifiedPclBytes.length);
+ try {
+ if (pPosPrintSetupDialogChoices != null && pPosPrintSetupDialogChoices.isPaperSizePrintAllOnLegal()) {
+ // The user has a check in the Print Setup dialog box for "Print all on Legal paper"
+ // so FORCE ALL PAGES TO LEGAL SIZE no matter if LTR in the Blockument DSP values
+ // or if this is a PCL file with a letter size PCL command
tByteArrayOutputStream.write(tLegalSizePaperBytes);
+
+ } else {
+ // Pick the paper size by calling the below method which may be subclassed by a plugin.
+ // The below uses polymorphism because the method isTreeNodePageLetterSize() is one of the subclassed
+ // methods specified in the interface IPluginHooksOpenPCL
+ if (mPosView.getOpenPCLViewer().isTreeNodePageLetterSize(tPrintThisTreeNode)) {
+ // Letter size
+ tByteArrayOutputStream.write(tLetterlSizePaperBytes);
+ } else {
+ // Legal size
+ tByteArrayOutputStream.write(tLegalSizePaperBytes);
+ }
}
+ } catch (IOException e) {
+ return false;
}
- } catch (IOException e) {
- return false;
- }
- // Write the current page bytes
- try {
- tByteArrayOutputStream.write(tModifiedPclBytes);
- if (mShouldOutputFormFeedBetweenPages) { tByteArrayOutputStream.write(sbFF); }
- } catch (IOException e) {
- return false;
- }
-
- // Update the progress bar at each page
- if (mPrintingProgressBar != null) {
- mPrintingProgressBar.setValue(tPageNumber + 1);
- mPrintingProgressBar.setString(tProgressBarBaseString + (tPageNumber + 1) + " of " + pPagesToPrintArrayList.size());
- }
- } // end of for loop
+ // Write the current page bytes
+ try {
+ tByteArrayOutputStream.write(tModifiedPclBytes);
+ if (mShouldOutputFormFeedBetweenPages) { tByteArrayOutputStream.write(sbFF); }
+ } catch (IOException e) {
+ return false;
+ }
+
+ // Update the progress bar at each page
+ if (mPrintingProgressBar != null) {
+ mPrintingProgressBar.setValue(tPageNumber + 1);
+ mPrintingProgressBar.setString(tProgressBarBaseString + (tPageNumber + 1) + " of " + pPagesToPrintArrayList.size());
+ }
+ } // end for (tPageNumber = 0; tPageNumber < pPagesToPrintArrayList.size(); tPageNumber++)
+ } // end "for (int tLglLtrPassCount = 0; tLglLtrPassCount < mLegalLetterPassesToDo; tLglLtrPassCount++)"
+
// The input stream for the DocPrintJob
if (tByteArrayOutputStream == null || tByteArrayOutputStream.size() < 1) { return false; }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|