~mimose/+junk/hplip-3.16.11

« back to all changes in this revision

Viewing changes to prnt/hpijs/ljcolor.cpp

  • Committer: guoyalong
  • Date: 2017-09-20 10:13:05 UTC
  • Revision ID: guoyalong@kylinos.cn-20170920101305-82zaolzpv1qghz29
Modified debian/control & debian/rules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************************\
 
2
  ljcolor.cpp : Implimentation for the LJColor class
 
3
 
 
4
  Copyright (c) 1996 - 2015, HP Co.
 
5
  All rights reserved.
 
6
 
 
7
  Redistribution and use in source and binary forms, with or without
 
8
  modification, are permitted provided that the following conditions
 
9
  are met:
 
10
  1. Redistributions of source code must retain the above copyright
 
11
     notice, this list of conditions and the following disclaimer.
 
12
  2. Redistributions in binary form must reproduce the above copyright
 
13
     notice, this list of conditions and the following disclaimer in the
 
14
     documentation and/or other materials provided with the distribution.
 
15
  3. Neither the name of HP nor the names of its
 
16
     contributors may be used to endorse or promote products derived
 
17
     from this software without specific prior written permission.
 
18
 
 
19
  THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
 
20
  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 
21
  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
 
22
  NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 
23
  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
 
24
  TO, PATENT INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 
25
  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 
26
  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
27
  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 
28
  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
29
\*****************************************************************************/
 
30
 
 
31
 
 
32
#ifdef APDK_LJCOLOR
 
33
 
 
34
#include "header.h"
 
35
#include "io_defs.h"
 
36
#include "ljcolor.h"
 
37
#include "printerproxy.h"
 
38
#include "resources.h"
 
39
 
 
40
APDK_BEGIN_NAMESPACE
 
41
 
 
42
extern uint32_t ulMapDJ600_CCM_K[ 9 * 9 * 9 ];
 
43
extern uint32_t ulMapGRAY_K_6x6x1[9 * 9 * 9];
 
44
 
 
45
LJColor::LJColor (SystemServices* pSS, int numfonts, BOOL proto)
 
46
    : Printer(pSS, numfonts, proto)
 
47
{
 
48
 
 
49
    if ((!proto) && (IOMode.bDevID))
 
50
    {
 
51
        constructor_error = VerifyPenInfo();
 
52
        CERRCHECK;
 
53
    }
 
54
    else ePen = BOTH_PENS;    // matches default mode
 
55
 
 
56
    pMode[GRAYMODE_INDEX]      = new LJColorGrayMode ();
 
57
    pMode[DEFAULTMODE_INDEX]   = new LJColor300DPIMode ();
 
58
    pMode[SPECIALMODE_INDEX]   = new LJColor600DPIMode ();
 
59
    pMode[SPECIALMODE_INDEX+1] = new LJColor150DPIMode ();
 
60
    pMode[SPECIALMODE_INDEX+2] = new LJColorKDraftMode ();
 
61
    ModeCount = 5;
 
62
 
 
63
 
 
64
    CMYMap = NULL;
 
65
    m_bJobStarted = FALSE;
 
66
#ifdef  APDK_AUTODUPLEX
 
67
    m_bRotateBackPage = FALSE;  // Lasers don't require back side image to be rotated
 
68
#endif
 
69
#ifdef APDK_EXTENDED_MEDIASIZE
 
70
    pMode[SPECIALMODE_INDEX+3] = new LJColorPlainBestMode ();
 
71
    ModeCount = 6;
 
72
#endif
 
73
    m_pCompressor = NULL;
 
74
    m_iYPos = 0;
 
75
 
 
76
    DBG1("LJColor created\n");
 
77
}
 
78
 
 
79
LJColor::~LJColor ()
 
80
{
 
81
    DISPLAY_STATUS  eDispStatus;
 
82
    if (IOMode.bStatus && m_bJobStarted)
 
83
    {
 
84
        for (int i = 0; i < 5; i++)
 
85
        {
 
86
            pSS->BusyWait (2000);
 
87
            eDispStatus = ParseError (0);
 
88
            if (eDispStatus == DISPLAY_PRINTING_COMPLETE)
 
89
            {
 
90
                pSS->DisplayPrinterStatus (eDispStatus);
 
91
                break;
 
92
            }
 
93
        }
 
94
    }
 
95
}
 
96
 
 
97
LJColorKDraftMode::LJColorKDraftMode ()
 
98
: GrayMode (ulMapDJ600_CCM_K)
 
99
{
 
100
    theQuality = qualityDraft;
 
101
    pmQuality  = QUALITY_DRAFT;
 
102
    pmColor    = GREY_K;
 
103
#ifdef APDK_AUTODUPLEX
 
104
    bDuplexCapable = TRUE;
 
105
#endif
 
106
}
 
107
 
 
108
LJColorGrayMode::LJColorGrayMode () : GrayMode (ulMapGRAY_K_6x6x1)
 
109
{
 
110
        ResolutionX[0] = 
 
111
        ResolutionY[0] = 
 
112
        BaseResX =
 
113
        BaseResY = 600;
 
114
    pmColor = GREY_K;
 
115
#ifdef APDK_AUTODUPLEX
 
116
    bDuplexCapable = TRUE;
 
117
#endif
 
118
}
 
119
 
 
120
LJColor150DPIMode::LJColor150DPIMode ()
 
121
: PrintMode (NULL)
 
122
{
 
123
    ResolutionX[0] = ResolutionY[0] = 150;
 
124
    BaseResX = BaseResY = 150;
 
125
        TextRes = 150;
 
126
        Config.bColorImage = FALSE;
 
127
        theQuality = qualityDraft;
 
128
        pmQuality  = QUALITY_DRAFT;
 
129
#ifdef APDK_AUTODUPLEX
 
130
    bDuplexCapable = TRUE;
 
131
#endif
 
132
}
 
133
 
 
134
LJColor300DPIMode::LJColor300DPIMode ()
 
135
: PrintMode (NULL)
 
136
{
 
137
    ResolutionX[0] = 300;
 
138
    ResolutionY[0] = 300;
 
139
    BaseResX = BaseResY = 300;
 
140
 
 
141
    Config.bColorImage = FALSE;
 
142
        theQuality = qualityNormal;
 
143
 
 
144
    bFontCapable = TRUE;
 
145
    pmQuality = QUALITY_NORMAL;
 
146
        Config.bColorImage = FALSE;
 
147
#ifdef APDK_AUTODUPLEX
 
148
    bDuplexCapable = TRUE;
 
149
#endif
 
150
}
 
151
 
 
152
LJColor600DPIMode::LJColor600DPIMode ()
 
153
: PrintMode (NULL)
 
154
{
 
155
    ResolutionX[0] = 600;
 
156
    ResolutionY[0] = 600;
 
157
    BaseResX = BaseResY = 600;
 
158
    Config.bColorImage = FALSE;
 
159
        theQuality = qualityPresentation;
 
160
    bFontCapable = TRUE;
 
161
    pmQuality   = QUALITY_BEST;
 
162
    pmMediaType = MEDIA_PHOTO;
 
163
#ifdef APDK_AUTODUPLEX
 
164
    bDuplexCapable = TRUE;
 
165
#endif
 
166
}
 
167
 
 
168
#ifdef  APDK_EXTENDED_MEDIASIZE
 
169
LJColorPlainBestMode::LJColorPlainBestMode ()
 
170
: PrintMode (NULL)
 
171
{
 
172
    ResolutionX[0] = 600;
 
173
    ResolutionY[0] = 600;
 
174
    BaseResX = BaseResY = 600;
 
175
 
 
176
    Config.bColorImage = FALSE;
 
177
        theQuality = qualityPresentation;
 
178
    bFontCapable = TRUE;
 
179
    pmQuality   = QUALITY_BEST;
 
180
#ifdef APDK_AUTODUPLEX
 
181
    bDuplexCapable = TRUE;
 
182
#endif
 
183
}
 
184
#endif
 
185
 
 
186
HeaderLJColor::HeaderLJColor (Printer* p, PrintContext* pc)
 
187
    : Header(p,pc)
 
188
{ }
 
189
 
 
190
DRIVER_ERROR HeaderLJColor::Send ()
 
191
{
 
192
    DRIVER_ERROR err;
 
193
    char    uom[12];
 
194
 
 
195
    COLORMODE       eC = COLOR;
 
196
    MEDIATYPE       eM;
 
197
    QUALITY_MODE    eQ;
 
198
    BOOL            bD;
 
199
 
 
200
    ((LJColor *)thePrinter)->bGrey_K = FALSE;
 
201
    if ((thePrintContext->GetPrintModeSettings (eQ, eM, eC, bD)) == NO_ERROR &&
 
202
        eC == GREY_K)
 
203
    {
 
204
        ((LJColor *)thePrinter)->bGrey_K = TRUE;
 
205
    }
 
206
 
 
207
    StartSend ();
 
208
 
 
209
    if (eC != GREY_K)
 
210
    {
 
211
 
 
212
/*
 
213
 *      Configure image data - ESC*v#W - # = 6 bytes
 
214
 *      02 - RGB colorspace (00 - Device RGB)
 
215
 *      03 - Direct pixel
 
216
 *      08 - bits per index - ignored for direct pixel
 
217
 *      08, 08, 08 - bits per primary each
 
218
 */
 
219
 
 
220
        err = thePrinter->Send ((const BYTE *) "\033*v6W\00\03\010\010\010\010", 11);
 
221
        ERRCHECK;
 
222
 
 
223
//      Continues tone dither
 
224
//      Logical operation - 0
 
225
 
 
226
//      err = thePrinter->Send ((const BYTE *) "\033*t18J\033*l204O", 13);
 
227
        err = thePrinter->Send ((const BYTE *) "\033*t18J", 6);
 
228
 
 
229
        ERRCHECK;
 
230
 
 
231
/*
 
232
 *      Driver Configuration Command - ESC*#W - # = 3 bytes
 
233
 *      device id - 6 = color HP LaserJet Printer
 
234
 *      func index - 4 = Select Colormap
 
235
 *      argument - 2   = Vivid Graphics
 
236
 */
 
237
 
 
238
        err = thePrinter->Send ((const BYTE *) "\033*o3W\06\04\06", 8);
 
239
        ERRCHECK;
 
240
 
 
241
/*
 
242
 *      Program color palette entries
 
243
 */
 
244
        err = thePrinter->Send ((const BYTE *) "\033*v255A\033*v255B\033*v255C\033*v0I", 26);
 
245
        ERRCHECK;
 
246
 
 
247
        err = thePrinter->Send ((const BYTE *) "\033*v255A\033*v0B\033*v0C\033*v6I", 22);
 
248
        ERRCHECK;
 
249
        err = thePrinter->Send ((const BYTE *) "\033*v0A\033*v255B\033*v0C\033*v5I", 22);
 
250
        ERRCHECK;
 
251
        err = thePrinter->Send ((const BYTE *) "\033*v0A\033*v0B\033*v255C\033*v3I", 22);
 
252
        ERRCHECK;
 
253
        err = thePrinter->Send ((const BYTE *) "\033*v255A\033*v255B\033*v0C\033*v4I", 24);
 
254
        ERRCHECK;
 
255
        err = thePrinter->Send ((const BYTE *) "\033*v255A\033*v0B\033*v255C\033*v2I", 24);
 
256
        ERRCHECK;
 
257
        err = thePrinter->Send ((const BYTE *) "\033*v0A\033*v255B\033*v255C\033*v1I", 24);
 
258
        ERRCHECK;
 
259
        err = thePrinter->Send ((const BYTE *) "\033*v0A\033*v0B\033*v0C\033*v7I", 20);
 
260
        ERRCHECK;
 
261
    }
 
262
 
 
263
    sprintf (uom, "\033*r%dS", thePrintContext->OutputPixelsPerRow ());
 
264
    err = thePrinter->Send ((const BYTE*)uom, strlen (uom));
 
265
    ERRCHECK;
 
266
 
 
267
    err = Graphics ();     // start raster graphics and set compression mode
 
268
 
 
269
    return err;
 
270
}
 
271
 
 
272
DRIVER_ERROR HeaderLJColor::StartSend ()
 
273
{
 
274
    DRIVER_ERROR err;
 
275
    char    res[72];
 
276
    int     iRes;
 
277
 
 
278
    iRes = thePrintContext->EffectiveResolutionY ();
 
279
 
 
280
    err = thePrinter->Send ((const BYTE*)UEL,sizeof(UEL));
 
281
    ERRCHECK;
 
282
 
 
283
    sprintf (res, "@PJL SET PAGEPROTECT=AUTO@PJL SET RESOLUTION=%d\015\012", iRes);
 
284
    err = thePrinter->Send ((const BYTE *) res, strlen (res));
 
285
    ERRCHECK;
 
286
 
 
287
    if (thePrinter->IOMode.bStatus)
 
288
    {
 
289
        sprintf (res, "@PJL JOB NAME = \"%ld\"\015\012", (long) (thePrinter));
 
290
        err = thePrinter->Send ((const BYTE *) res, strlen (res));
 
291
        ERRCHECK;
 
292
    }
 
293
 
 
294
    QUALITY_MODE    eQ = QUALITY_NORMAL;
 
295
    COLORMODE       eC;
 
296
    MEDIATYPE       eM;
 
297
    BOOL            bD;
 
298
 
 
299
    thePrintContext->GetPrintModeSettings (eQ, eM, eC, bD);
 
300
 
 
301
    if (eQ == QUALITY_DRAFT)
 
302
    {
 
303
        strcpy (res, "@PJL SET RET=OFF\015\012@PJL SET ECONOMODE=ON\015\012");
 
304
        err = thePrinter->Send ((const BYTE *) res, strlen (res));
 
305
        ERRCHECK;
 
306
    }
 
307
 
 
308
    if (thePrinter->IOMode.bStatus)
 
309
    {
 
310
        strcpy (res, "@PJL USTATUSOFF\015\012@PJL USTATUS DEVICE = ON\015\012@PJL USTATUS JOB = ON\015\012");
 
311
        err = thePrinter->Send ((const BYTE *) res, strlen (res));
 
312
        ERRCHECK;
 
313
    }
 
314
 
 
315
//  Duplexing directive
 
316
 
 
317
    strcpy (res, "@PJL SET DUPLEX=OFF\015\012");
 
318
 
 
319
#ifdef APDK_AUTODUPLEX
 
320
    DUPLEXMODE  dupmode = thePrintContext->QueryDuplexMode ();
 
321
    if (dupmode != DUPLEXMODE_NONE)
 
322
    {
 
323
        strcpy (res, "@PJL SET DUPLEX=ON\015\012@PJL SET BINDING=");
 
324
        if (dupmode == DUPLEXMODE_BOOK)
 
325
            strcat (res, "LONGEDGE\015\012");
 
326
        else
 
327
            strcat (res, "SHORTEDGE\015\012");
 
328
    }
 
329
#endif
 
330
 
 
331
    err = thePrinter->Send ((const BYTE *) res, strlen (res));
 
332
 
 
333
//  Binding directive
 
334
 
 
335
    strcpy (res, "@PJL SET BINDING=LONGEDGE\015\012");
 
336
 
 
337
#ifdef APDK_AUTODUPLEX
 
338
    if (thePrintContext->QueryDuplexMode () == DUPLEXMODE_TABLET)
 
339
    {
 
340
        strcpy (res, "@PJL SET BINDING=SHORTEDGE\015\012");
 
341
    }
 
342
#endif
 
343
 
 
344
    err = thePrinter->Send ((const BYTE *) res, strlen (res));
 
345
 
 
346
 
 
347
    err = thePrinter->Send ((const BYTE*) EnterLanguage, sizeof (EnterLanguage));
 
348
    ERRCHECK;
 
349
 
 
350
    err = thePrinter->Send ((const BYTE*) "PCL\015\012", 5);
 
351
    ERRCHECK;
 
352
 
 
353
    err = thePrinter->Send ((const BYTE*) Reset,sizeof (Reset));
 
354
    ERRCHECK;
 
355
 
 
356
    sprintf (res, "\033&l%dH", thePrintContext->GetMediaSource ());
 
357
    err = thePrinter->Send ((const BYTE *) res, strlen (res));          // Source
 
358
    ERRCHECK;
 
359
 
 
360
//  Media size, vertical spacing between lines and top margin
 
361
 
 
362
    memcpy (res, mediasize, mscount - 1);
 
363
    strcpy (res+mscount-1, "a8c0E");
 
364
    err = thePrinter->Send ((const BYTE *) res, strlen (res));
 
365
    ERRCHECK;
 
366
 
 
367
        sprintf (res, "\033*t%dR\033&u%dD", iRes, iRes);
 
368
    err=thePrinter->Send ((const BYTE*) res, strlen (res));
 
369
    ERRCHECK;
 
370
 
 
371
    err = Margins ();
 
372
    ERRCHECK;
 
373
    CAPy = 0;
 
374
 
 
375
//  Default is single sided printing
 
376
 
 
377
    strcpy (res, "\033&l0S");
 
378
 
 
379
#ifdef APDK_AUTODUPLEX
 
380
    DUPLEXMODE  eDupMode = thePrintContext->QueryDuplexMode ();
 
381
    if (eDupMode != DUPLEXMODE_NONE)
 
382
    {
 
383
        sprintf (res, "\033&l%dS", (eDupMode == DUPLEXMODE_BOOK) ? 1 : 2);
 
384
    }
 
385
#endif
 
386
    err = thePrinter->Send ((const BYTE *) res, strlen (res));
 
387
    ERRCHECK;
 
388
 
 
389
/*
 
390
 *  Set orientation to Portrait. APDK supports printing in Portrait mode only.
 
391
 *  If users desire Landscape printing, application/gluecode will have to
 
392
 *  rearrange the rasters appropriately.
 
393
 */
 
394
 
 
395
    err = thePrinter->Send ((const BYTE *) "\033&l0O", 5);
 
396
 
 
397
    // Number of copies
 
398
    sprintf (res, "\033&l%dX", thePrintContext->GetCopyCount ());
 
399
    err = thePrinter->Send ((const BYTE *) res, strlen (res));
 
400
    ERRCHECK;
 
401
 
 
402
    return err;
 
403
}
 
404
 
 
405
DRIVER_ERROR HeaderLJColor::Graphics ()
 
406
{
 
407
 
 
408
    DRIVER_ERROR err;
 
409
    err = thePrinter->Send ((const BYTE*) grafStart, sizeof (grafStart));
 
410
    ERRCHECK;
 
411
 
 
412
    if (((LJColor *) thePrinter)->bGrey_K)
 
413
    {
 
414
        err = thePrinter->Send ((const BYTE*) "\033*b2M", 5);
 
415
        ERRCHECK;
 
416
    }
 
417
    else
 
418
    {
 
419
        err = thePrinter->Send ((const BYTE*) "\033*b3M", 5);
 
420
    }
 
421
 
 
422
    return err;
 
423
}
 
424
 
 
425
DRIVER_ERROR HeaderLJColor::EndJob ()
 
426
{
 
427
    char    szBuff[128];
 
428
    DRIVER_ERROR    err = NO_ERROR;
 
429
    if (thePrinter->IOMode.bStatus)
 
430
    {
 
431
        sprintf (szBuff, "\033E\033%%-12345X@PJL EOJ NAME = \"%ld\"\015\012@PJL RESET\015\012",
 
432
                 (long) (thePrinter));
 
433
        err = thePrinter->Send ((const BYTE *) szBuff, strlen (szBuff));
 
434
        ERRCHECK;
 
435
    }
 
436
    strcpy (szBuff, "\033%-12345X");
 
437
    err = thePrinter->Send ((const BYTE *) szBuff, strlen (szBuff));
 
438
 
 
439
    return err;
 
440
}
 
441
 
 
442
DRIVER_ERROR HeaderLJColor::FormFeed ()
 
443
{
 
444
    ((LJColor *)thePrinter)->bFGColorSet = FALSE;
 
445
    ((LJColor *)thePrinter)->m_iYPos = 0;
 
446
 
 
447
    return (thePrinter->Send ((const BYTE *) "\014", 1));
 
448
}
 
449
 
 
450
DRIVER_ERROR HeaderLJColor::SendCAPy (unsigned int iAbsY)
 
451
{
 
452
    if (iAbsY == 0)
 
453
    {
 
454
        return thePrinter->Send ((const BYTE *) "\033*p0Y", 5);
 
455
    }
 
456
    return NO_ERROR;
 
457
}
 
458
 
 
459
DRIVER_ERROR LJColor::Encapsulate (const RASTERDATA* InputRaster, BOOL bLastPlane)
 
460
{
 
461
    char    szScratchStr[16];
 
462
    DRIVER_ERROR    err;
 
463
    m_iYPos++;
 
464
    if (bFGColorSet == FALSE)
 
465
    {
 
466
        Send ((const BYTE *) "\033*v7S", 5);
 
467
        bFGColorSet = TRUE;
 
468
    }
 
469
    sprintf (szScratchStr, "\033*b%uW", InputRaster->rastersize[COLORTYPE_COLOR]);
 
470
    err = Send ((const BYTE *) szScratchStr, strlen (szScratchStr));
 
471
    if (err == NO_ERROR)
 
472
    {
 
473
        err = Send (InputRaster->rasterdata[COLORTYPE_COLOR], InputRaster->rastersize[COLORTYPE_COLOR]);
 
474
    }
 
475
 
 
476
/*
 
477
 *  Printers with low memory (64 MB or less) can run out of memory during decompressing
 
478
 *  the image data and will abort the job. To prevent this, restart raster command.
 
479
 *  Raghu
 
480
 */
 
481
 
 
482
    if (!bGrey_K &&
 
483
        m_iYResolution == 600 &&
 
484
        m_iYPos % 1200 == 0)
 
485
    {
 
486
        SkipRasters (0);
 
487
        err = Send ((const BYTE *) "\033*rC\033*r1A\033*b3M", 14);
 
488
    }
 
489
 
 
490
    return err;
 
491
}
 
492
 
 
493
DRIVER_ERROR LJColor::SkipRasters (int nBlankRasters)
 
494
{
 
495
    char    szScratchStr[16];
 
496
    DRIVER_ERROR    err = NO_ERROR;
 
497
    if (m_pCompressor)
 
498
    {
 
499
        m_pCompressor->Flush ();
 
500
    }
 
501
    if (nBlankRasters > 0)
 
502
    {
 
503
        m_iYPos += nBlankRasters;
 
504
        sprintf (szScratchStr, "\033*p%dY", m_iYPos);
 
505
        err = Send ((const BYTE *) szScratchStr, strlen (szScratchStr));
 
506
    }
 
507
    return err;
 
508
}
 
509
 
 
510
 
 
511
Header* LJColor::SelectHeader (PrintContext *pc)
 
512
{
 
513
    m_iYResolution = pc->EffectiveResolutionY ();
 
514
    return new HeaderLJColor (this, pc);
 
515
}
 
516
 
 
517
DRIVER_ERROR LJColor::VerifyPenInfo()
 
518
{
 
519
 
 
520
    DRIVER_ERROR err = NO_ERROR;
 
521
 
 
522
    if(IOMode.bDevID == FALSE)
 
523
    {
 
524
        return err;
 
525
    }
 
526
 
 
527
    ePen = BOTH_PENS;
 
528
    return NO_ERROR;
 
529
}
 
530
 
 
531
DRIVER_ERROR LJColor::ParsePenInfo(PEN_TYPE& ePen, BOOL QueryPrinter)
 
532
{
 
533
//    char* str;
 
534
//    DRIVER_ERROR err = SetPenInfo(str, QueryPrinter);
 
535
//    ERRCHECK;
 
536
 
 
537
    ePen = BOTH_PENS;
 
538
 
 
539
    return NO_ERROR;
 
540
}
 
541
 
 
542
Compressor* LJColor::CreateCompressor (unsigned int RasterSize)
 
543
{
 
544
    bFGColorSet = FALSE;
 
545
    if (bGrey_K)
 
546
        return new Mode2 (pSS, RasterSize);
 
547
 
 
548
    m_pCompressor = new Mode3 (pSS, this, RasterSize);
 
549
    return m_pCompressor;
 
550
}
 
551
 
 
552
/*
 
553
 *  Function name: ParseError
 
554
 *
 
555
 *  Owner: Darrell Walker
 
556
 *
 
557
 *  Purpose:  To determine what error state the printer is in.
 
558
 *
 
559
 *  Called by: Send()
 
560
 *
 
561
 *  Parameters on entry: status_reg is the contents of the centronics
 
562
 *                      status register (at the time the error was
 
563
 *                      detected)
 
564
 *
 
565
 *  Parameters on exit: unchanged
 
566
 *
 
567
 *  Return Values: The proper DISPLAY_STATUS to reflect the printer
 
568
 *              error state.
 
569
 *
 
570
 */
 
571
 
 
572
/*  We have to override the base class's (Printer) ParseError function due
 
573
    to the fact that the 8XX series returns a status byte of F8 when it's out of
 
574
    paper.  Unfortunately, the 600 series returns F8 when they're turned off.
 
575
    The way things are structured in Printer::ParseError, we used to check only
 
576
    for DEVICE_IS_OOP.  This would return true even if we were connected to a
 
577
    600 series printer that was turned off, causing the Out of paper status
 
578
    message to be displayed.  This change also reflects a corresponding change
 
579
    in IO_defs.h, where I split DEVICE_IS_OOP into DEVICE_IS_OOP, DJ400_IS_OOP, and
 
580
    DJ8XX_IS_OOP and we now check for DJ8XX_IS_OOP in the DJ8xx class's
 
581
    ParseError function below.  05/11/99 DGC.
 
582
*/
 
583
 
 
584
DISPLAY_STATUS LJColor::ParseError(BYTE status_reg)
 
585
{
 
586
    DBG1("LJColor: parsing error info\n");
 
587
 
 
588
    DRIVER_ERROR err = NO_ERROR;
 
589
    BYTE    szReadBuff[256];
 
590
    DWORD   iReadCount = 256;
 
591
    DISPLAY_STATUS  eStatus = (DISPLAY_STATUS) status_reg;
 
592
    char    *tmpStr;
 
593
    int     iErrorCode;
 
594
 
 
595
    if (!IOMode.bDevID)
 
596
        return eStatus;
 
597
 
 
598
    memset (szReadBuff, 0, 256);
 
599
    err = pSS->FromDevice (szReadBuff, &iReadCount);
 
600
    if (err == NO_ERROR && iReadCount == 0)
 
601
        return eStatus;
 
602
 
 
603
    if (strstr ((char *) szReadBuff, "JOB"))
 
604
    {
 
605
        if (!(tmpStr = strstr ((char *) szReadBuff, "NAME")))
 
606
            return DISPLAY_PRINTING;
 
607
        tmpStr += 6;
 
608
        while (*tmpStr < '0' || *tmpStr > '9')
 
609
            tmpStr++;
 
610
        sscanf (tmpStr, "%d", &iErrorCode);
 
611
        if (iErrorCode != (long) (this))
 
612
            return DISPLAY_PRINTING;
 
613
    }
 
614
 
 
615
    if (strstr ((char *) szReadBuff, "END"))
 
616
    {
 
617
        return DISPLAY_PRINTING_COMPLETE;
 
618
    }
 
619
 
 
620
 
 
621
    if (strstr ((char *) szReadBuff, "CANCEL"))
 
622
        return DISPLAY_PRINTING_CANCELED;
 
623
 
 
624
    if (!(tmpStr = strstr ((char *) szReadBuff, "CODE")))
 
625
        return eStatus;
 
626
 
 
627
    tmpStr += 4;
 
628
    while (*tmpStr < '0' || *tmpStr > '9')
 
629
        tmpStr++;
 
630
    sscanf (tmpStr, "%d", &iErrorCode);
 
631
 
 
632
    if (iErrorCode < 32000)
 
633
        return DISPLAY_PRINTING;
 
634
 
 
635
    if (iErrorCode == 40010 || iErrorCode == 40020)
 
636
        return DISPLAY_NO_PENS;     // Actually, out of toner
 
637
 
 
638
    if (iErrorCode == 40021)
 
639
        return DISPLAY_TOP_COVER_OPEN;
 
640
 
 
641
    if ((iErrorCode / 100) == 419)
 
642
        return DISPLAY_OUT_OF_PAPER;
 
643
 
 
644
    if ((iErrorCode / 1000) == 42 || iErrorCode == 40022)
 
645
    {
 
646
        DBG1("Paper Jammed\n");
 
647
        return DISPLAY_PAPER_JAMMED;
 
648
    }
 
649
 
 
650
    if (iErrorCode > 40049 && iErrorCode < 41000)
 
651
    {
 
652
        DBG1("IO trap\n");
 
653
        return DISPLAY_ERROR_TRAP;
 
654
    }
 
655
 
 
656
    if (iErrorCode == 40079)
 
657
        return DISPLAY_OFFLINE;
 
658
 
 
659
    return DISPLAY_ERROR_TRAP;
 
660
}
 
661
 
 
662
APDK_END_NAMESPACE
 
663
 
 
664
#endif  // defined APDK_LJCOLOR