~ubuntu-branches/debian/experimental/cups-filters/experimental

« back to all changes in this revision

Viewing changes to pdftoopvp/oprs/OPVPWrapper_0_2.cxx

Tags: upstream-1.0.20
ImportĀ upstreamĀ versionĀ 1.0.20

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
  OPVPWrapper_0_2.cc
3
 
*/
4
 
 
5
 
 
6
 
#include <config.h>
7
 
#include "OPVPWrapper_0_2.h"
8
 
#include <string.h>
9
 
 
10
 
/* color space mapping 0.2 to 1.0 */
11
 
opvp_cspace_t OPVPWrapper_0_2::cspace_0_2_to_1_0[] = {
12
 
    OPVP_CSPACE_BW,
13
 
    OPVP_CSPACE_DEVICEGRAY,
14
 
    OPVP_CSPACE_DEVICECMY,
15
 
    OPVP_CSPACE_DEVICECMYK,
16
 
    OPVP_CSPACE_DEVICERGB,
17
 
    OPVP_CSPACE_STANDARDRGB,
18
 
    OPVP_CSPACE_STANDARDRGB64
19
 
};
20
 
 
21
 
/* color space mapping 1.0 to 0.2 */
22
 
OPVP_ColorSpace OPVPWrapper_0_2::cspace_1_0_to_0_2[] = {
23
 
    OPVP_cspaceBW,
24
 
    OPVP_cspaceDeviceGray,
25
 
    OPVP_cspaceDeviceCMY,
26
 
    OPVP_cspaceDeviceCMYK,
27
 
    OPVP_cspaceDeviceRGB,
28
 
    (OPVP_ColorSpace)0, /* 0.2 doesn't have OPVP_CSPACE_DEVICEKRGB */
29
 
    OPVP_cspaceStandardRGB,
30
 
    OPVP_cspaceStandardRGB64,
31
 
};
32
 
 
33
 
/* image format mapping 1.0 to 0.2 */
34
 
OPVP_ImageFormat OPVPWrapper_0_2::iformat_1_0_to_0_2[] = {
35
 
    OPVP_iformatRaw,
36
 
    /* OPVP_IFORMAT_MASK use iformat raw in 0.2 */
37
 
    OPVP_iformatRaw,
38
 
    OPVP_iformatRLE,
39
 
    OPVP_iformatJPEG,
40
 
    OPVP_iformatPNG,
41
 
};
42
 
 
43
 
/* image colorDepth needed in 0.2 */
44
 
int OPVPWrapper_0_2::colorDepth_0_2[] = {
45
 
    1, /* OPVP_CSPACE_BW */
46
 
    8, /* OPVP_CSPACE_DEVICEGRAY */
47
 
    24, /* OPVP_CSPACE_DEVICECMY */
48
 
    32, /* OPVP_CSPACE_DEVICECMYK */
49
 
    24, /* OPVP_CSPACE_DEVICERGB */
50
 
    32, /* OPVP_CSPACE_DEVICEKRGB */
51
 
    24, /* OPVP_CSPACE_STANDARDRGB */
52
 
    64, /* OPVP_CSPACE_STANDARDRGB64 */
53
 
};
54
 
 
55
 
OPVPWrapper_0_2::OPVPWrapper_0_2(void *opvpHandleA, int *opvpErrorNoA,
56
 
  OPVP_api_procs *procsA, int printerContextA)
57
 
{
58
 
    procs_0_2 = procsA;
59
 
    opvpHandle = opvpHandleA;
60
 
    opvpErrorNo_0_2 = opvpErrorNoA;
61
 
    printerContext_0_2 = printerContextA;
62
 
    version[0] = 0;
63
 
    version[1] = 2;
64
 
    supportClosePrinter = (procs_0_2->ClosePrinter != 0);
65
 
    supportStartJob = (procs_0_2->StartJob != 0);
66
 
    supportEndJob = (procs_0_2->EndJob != 0);
67
 
    supportAbortJob = false;
68
 
    supportStartDoc = (procs_0_2->StartDoc != 0);
69
 
    supportEndDoc = (procs_0_2->EndDoc != 0);
70
 
    supportStartPage = (procs_0_2->StartPage != 0);
71
 
    supportEndPage = (procs_0_2->EndPage != 0);
72
 
    supportResetCTM = (procs_0_2->ResetCTM != 0);
73
 
    supportSetCTM = (procs_0_2->SetCTM != 0);
74
 
    supportGetCTM = (procs_0_2->GetCTM != 0);
75
 
    supportInitGS = (procs_0_2->InitGS != 0);
76
 
    supportSaveGS = (procs_0_2->SaveGS != 0);
77
 
    supportRestoreGS = (procs_0_2->RestoreGS != 0);
78
 
    supportQueryColorSpace = (procs_0_2->QueryColorSpace != 0);
79
 
    supportSetColorSpace = (procs_0_2->SetColorSpace != 0);
80
 
    supportGetColorSpace = (procs_0_2->GetColorSpace != 0);
81
 
    supportSetFillMode = (procs_0_2->SetFillMode != 0);
82
 
    supportGetFillMode = (procs_0_2->GetFillMode != 0);
83
 
    supportSetAlphaConstant = (procs_0_2->SetAlphaConstant != 0);
84
 
    supportGetAlphaConstant = (procs_0_2->GetAlphaConstant != 0);
85
 
    supportSetLineWidth = (procs_0_2->SetLineWidth != 0);
86
 
    supportGetLineWidth = (procs_0_2->GetLineWidth != 0);
87
 
    supportSetLineDash = (procs_0_2->SetLineDash != 0);
88
 
    supportGetLineDash = (procs_0_2->GetLineDash != 0);
89
 
    supportSetLineDashOffset = (procs_0_2->SetLineDashOffset != 0);
90
 
    supportGetLineDashOffset = (procs_0_2->GetLineDashOffset != 0);
91
 
    supportSetLineStyle = (procs_0_2->SetLineStyle != 0);
92
 
    supportGetLineStyle = (procs_0_2->GetLineStyle != 0);
93
 
    supportSetLineCap = (procs_0_2->SetLineCap != 0);
94
 
    supportGetLineCap = (procs_0_2->GetLineCap != 0);
95
 
    supportSetLineJoin = (procs_0_2->SetLineJoin != 0);
96
 
    supportGetLineJoin = (procs_0_2->GetLineJoin != 0);
97
 
    supportSetMiterLimit = (procs_0_2->SetMiterLimit != 0);
98
 
    supportGetMiterLimit = (procs_0_2->GetMiterLimit != 0);
99
 
    supportSetPaintMode = (procs_0_2->SetPaintMode != 0);
100
 
    supportGetPaintMode = (procs_0_2->GetPaintMode != 0);
101
 
    supportSetStrokeColor = (procs_0_2->SetStrokeColor != 0);
102
 
    supportSetFillColor = (procs_0_2->SetFillColor != 0);
103
 
    supportSetBgColor = (procs_0_2->SetBgColor != 0);
104
 
    supportNewPath = (procs_0_2->NewPath != 0);
105
 
    supportEndPath = (procs_0_2->EndPath != 0);
106
 
    supportStrokePath = (procs_0_2->StrokePath != 0);
107
 
    supportFillPath = (procs_0_2->FillPath != 0);
108
 
    supportStrokeFillPath = (procs_0_2->StrokeFillPath != 0);
109
 
    supportSetClipPath = (procs_0_2->SetClipPath != 0);
110
 
    supportSetCurrentPoint = (procs_0_2->SetCurrentPoint != 0);
111
 
    supportLinePath = (procs_0_2->LinePath != 0);
112
 
    supportPolygonPath = (procs_0_2->PolygonPath != 0);
113
 
    supportRectanglePath = (procs_0_2->RectanglePath != 0);
114
 
    supportRoundRectanglePath = (procs_0_2->RoundRectanglePath != 0);
115
 
    supportBezierPath = (procs_0_2->BezierPath != 0);
116
 
    supportArcPath = (procs_0_2->ArcPath != 0);
117
 
    supportDrawImage = (procs_0_2->DrawImage != 0);
118
 
    supportStartDrawImage = (procs_0_2->StartDrawImage != 0);
119
 
    supportTransferDrawImage = (procs_0_2->TransferDrawImage != 0);
120
 
    supportEndDrawImage = (procs_0_2->EndDrawImage != 0);
121
 
    supportStartScanline = (procs_0_2->StartScanline != 0);
122
 
    supportScanline = (procs_0_2->Scanline != 0);
123
 
    supportEndScanline = (procs_0_2->EndScanline != 0);
124
 
    supportStartRaster = (procs_0_2->StartRaster != 0);
125
 
    supportTransferRasterData = (procs_0_2->TransferRasterData != 0);
126
 
    supportSkipRaster = (procs_0_2->SkipRaster != 0);
127
 
    supportEndRaster = (procs_0_2->EndRaster != 0);
128
 
    supportStartStream = (procs_0_2->StartStream != 0);
129
 
    supportTransferStreamData = (procs_0_2->TransferStreamData != 0);
130
 
    supportEndStream = (procs_0_2->EndStream != 0);
131
 
    supportQueryDeviceCapability = (procs_0_2->QueryDeviceCapability != 0);
132
 
    supportQueryDeviceInfo = (procs_0_2->QueryDeviceInfo != 0);
133
 
    supportResetClipPath = (procs_0_2->ResetClipPath != 0);
134
 
    colorSpace = OPVP_CSPACE_STANDARDRGB;
135
 
    if (supportGetColorSpace) {
136
 
        if (GetColorSpace(&colorSpace) != OPVP_OK) {
137
 
            colorSpace = OPVP_CSPACE_STANDARDRGB;
138
 
        }
139
 
    }
140
 
}
141
 
 
142
 
OPVPWrapper_0_2::~OPVPWrapper_0_2()
143
 
{
144
 
}
145
 
 
146
 
opvp_result_t OPVPWrapper_0_2::ClosePrinter()
147
 
{
148
 
    if (!supportClosePrinter) {
149
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
150
 
        return -1;
151
 
    }
152
 
    return (opvp_result_t)procs_0_2->ClosePrinter(printerContext_0_2);
153
 
}
154
 
 
155
 
opvp_result_t OPVPWrapper_0_2::StartJob(
156
 
  const opvp_char_t *jobInfo)
157
 
{
158
 
    if (!supportStartJob) {
159
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
160
 
        return -1;
161
 
    }
162
 
    return (opvp_result_t)procs_0_2->StartJob(printerContext_0_2,
163
 
      (char *)jobInfo);
164
 
}
165
 
 
166
 
opvp_result_t OPVPWrapper_0_2::EndJob()
167
 
{
168
 
    if (!supportEndJob) {
169
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
170
 
        return -1;
171
 
    }
172
 
    return (opvp_result_t)procs_0_2->EndJob(printerContext_0_2);
173
 
}
174
 
 
175
 
opvp_result_t OPVPWrapper_0_2::AbortJob()
176
 
{
177
 
    *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
178
 
    return -1;
179
 
}
180
 
 
181
 
opvp_result_t OPVPWrapper_0_2::StartDoc(
182
 
  const opvp_char_t *docInfo)
183
 
{
184
 
    if (!supportStartDoc) {
185
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
186
 
        return -1;
187
 
    }
188
 
    return (opvp_result_t)procs_0_2->StartDoc(printerContext_0_2,
189
 
      (char *)docInfo);
190
 
}
191
 
 
192
 
opvp_result_t OPVPWrapper_0_2::EndDoc()
193
 
{
194
 
    if (!supportEndDoc) {
195
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
196
 
        return -1;
197
 
    }
198
 
    return (opvp_result_t)procs_0_2->EndDoc(printerContext_0_2);
199
 
}
200
 
 
201
 
opvp_result_t OPVPWrapper_0_2::StartPage(
202
 
  const opvp_char_t *pageInfo)
203
 
{
204
 
    int r;
205
 
 
206
 
    if (!supportStartPage) {
207
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
208
 
        return -1;
209
 
    }
210
 
    if ((r = procs_0_2->StartPage(printerContext_0_2,
211
 
           /* discard const */(char *)pageInfo)) != OPVP_OK) {
212
 
          /* error */
213
 
        return (opvp_result_t)r;
214
 
    }
215
 
    /* initialize ROP */
216
 
    if (procs_0_2->SetROP != 0) {
217
 
        procs_0_2->SetROP(printerContext_0_2,
218
 
          OPVP_0_2_ROP_P);
219
 
    }
220
 
    return OPVP_OK;
221
 
}
222
 
 
223
 
opvp_result_t OPVPWrapper_0_2::EndPage()
224
 
{
225
 
    if (!supportEndPage) {
226
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
227
 
        return -1;
228
 
    }
229
 
    return (opvp_result_t)procs_0_2->EndPage(printerContext_0_2);
230
 
}
231
 
 
232
 
opvp_result_t OPVPWrapper_0_2::QueryDeviceCapability(
233
 
  opvp_flag_t queryflag, opvp_int_t *buflen, opvp_byte_t *infoBuf)
234
 
{
235
 
    if (!supportQueryDeviceCapability) {
236
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
237
 
        return -1;
238
 
    }
239
 
    return (opvp_result_t)procs_0_2->
240
 
      QueryDeviceCapability(printerContext_0_2,queryflag,*buflen,
241
 
      (char *)infoBuf);
242
 
}
243
 
 
244
 
opvp_result_t OPVPWrapper_0_2::QueryDeviceInfo(
245
 
  opvp_flag_t queryflag, opvp_int_t *buflen, opvp_byte_t *infoBuf)
246
 
{
247
 
    if (!supportQueryDeviceInfo) {
248
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
249
 
        return -1;
250
 
    }
251
 
    if (queryflag & OPVP_QF_MEDIACOPY) {
252
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
253
 
        return -1;
254
 
    }
255
 
    if (queryflag & OPVP_QF_PRINTREGION) {
256
 
        queryflag &= ~OPVP_QF_PRINTREGION;
257
 
        queryflag |= 0x0020000;
258
 
    }
259
 
    return (opvp_result_t)procs_0_2->QueryDeviceInfo(printerContext_0_2,
260
 
      queryflag,*buflen,(char *)infoBuf);
261
 
}
262
 
 
263
 
opvp_result_t OPVPWrapper_0_2::ResetCTM()
264
 
{
265
 
    if (!supportResetCTM) {
266
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
267
 
        return -1;
268
 
    }
269
 
    return (opvp_result_t)procs_0_2->ResetCTM(printerContext_0_2);
270
 
}
271
 
 
272
 
opvp_result_t OPVPWrapper_0_2::SetCTM(const opvp_ctm_t *pCTM)
273
 
{
274
 
    if (!supportSetCTM) {
275
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
276
 
        return -1;
277
 
    }
278
 
    return (opvp_result_t)procs_0_2->SetCTM(printerContext_0_2,
279
 
      (OPVP_CTM *)pCTM);
280
 
}
281
 
 
282
 
opvp_result_t OPVPWrapper_0_2::GetCTM(opvp_ctm_t *pCTM)
283
 
{
284
 
    if (!supportGetCTM) {
285
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
286
 
        return -1;
287
 
    }
288
 
    return (opvp_result_t)procs_0_2->GetCTM(printerContext_0_2,
289
 
      (OPVP_CTM *)pCTM);
290
 
}
291
 
 
292
 
opvp_result_t OPVPWrapper_0_2::InitGS()
293
 
{
294
 
    int r;
295
 
 
296
 
    if (!supportInitGS) {
297
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
298
 
        return -1;
299
 
    }
300
 
    if ((r = procs_0_2->InitGS(printerContext_0_2)) != OPVP_OK) {
301
 
          /* error */
302
 
        return (opvp_result_t)r;
303
 
    }
304
 
    /* initialize ROP */
305
 
    if (procs_0_2->SetROP != 0) {
306
 
        procs_0_2->SetROP(printerContext_0_2,
307
 
          OPVP_0_2_ROP_P);
308
 
    }
309
 
    return OPVP_OK;
310
 
}
311
 
 
312
 
opvp_result_t OPVPWrapper_0_2::SaveGS()
313
 
{
314
 
    if (!supportSaveGS) {
315
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
316
 
        return -1;
317
 
    }
318
 
    return (opvp_result_t)procs_0_2->SaveGS(printerContext_0_2);
319
 
}
320
 
 
321
 
opvp_result_t OPVPWrapper_0_2::RestoreGS()
322
 
{
323
 
    if (!supportRestoreGS) {
324
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
325
 
        return -1;
326
 
    }
327
 
    return (opvp_result_t)procs_0_2->RestoreGS(printerContext_0_2);
328
 
}
329
 
 
330
 
opvp_result_t OPVPWrapper_0_2::QueryColorSpace(
331
 
  opvp_int_t *pnum, opvp_cspace_t *pcspace)
332
 
{
333
 
    int r;
334
 
    int i;
335
 
 
336
 
    if (!supportQueryColorSpace) {
337
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
338
 
        return -1;
339
 
    }
340
 
    if ((r = procs_0_2->QueryColorSpace(printerContext_0_2,
341
 
         (OPVP_ColorSpace *)pcspace,pnum)) != OPVP_OK) {
342
 
        /* error */
343
 
        return (opvp_result_t)r;
344
 
    }
345
 
    /* translate cspaces */
346
 
    for (i = 0;i < *pnum;i++) {
347
 
        if ((unsigned int)pcspace[i] 
348
 
             > sizeof(cspace_0_2_to_1_0)/sizeof(opvp_cspace_t)) {
349
 
            /* unknown color space */
350
 
            /* set DEVICERGB instead */
351
 
            pcspace[i] = OPVP_CSPACE_DEVICERGB;
352
 
        } else {
353
 
            pcspace[i] = cspace_0_2_to_1_0[pcspace[i]];
354
 
        }
355
 
    }
356
 
    return OPVP_OK;
357
 
}
358
 
 
359
 
opvp_result_t OPVPWrapper_0_2::SetColorSpace(
360
 
  opvp_cspace_t cspace)
361
 
{
362
 
    int r;
363
 
 
364
 
    if (!supportSetColorSpace) {
365
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
366
 
        return -1;
367
 
    }
368
 
    if (cspace == OPVP_CSPACE_DEVICEKRGB) {
369
 
        /* 0.2 doesn't have OPVP_CSPACE_DEVICEKRGB */
370
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
371
 
        return -1;
372
 
    }
373
 
    if ((unsigned int)cspace
374
 
         > sizeof(cspace_1_0_to_0_2)/sizeof(OPVP_ColorSpace)) {
375
 
        /* unknown color space */
376
 
        *opvpErrorNo_0_2 = OPVP_PARAMERROR_0_2;
377
 
        return -1;
378
 
    }
379
 
    r =  procs_0_2->SetColorSpace(printerContext_0_2,
380
 
      cspace_1_0_to_0_2[cspace]);
381
 
    if (r == OPVP_OK) {
382
 
        colorSpace = cspace;
383
 
    }
384
 
    return (opvp_result_t)r;
385
 
}
386
 
 
387
 
opvp_result_t OPVPWrapper_0_2::GetColorSpace(
388
 
  opvp_cspace_t *pcspace)
389
 
{
390
 
    int r;
391
 
 
392
 
    if (!supportGetColorSpace) {
393
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
394
 
        return -1;
395
 
    }
396
 
    if ((r = procs_0_2->GetColorSpace(printerContext_0_2,
397
 
      (OPVP_ColorSpace *)pcspace)) != OPVP_OK) {
398
 
        /* error */
399
 
        return (opvp_result_t)r;
400
 
    }
401
 
    if ((unsigned int)*pcspace
402
 
         > sizeof(cspace_0_2_to_1_0)/sizeof(opvp_cspace_t)) {
403
 
        /* unknown color space */
404
 
        /* set DEVICERGB instead */
405
 
        *pcspace = OPVP_CSPACE_DEVICERGB;
406
 
    } else {
407
 
        *pcspace = cspace_0_2_to_1_0[*pcspace];
408
 
    }
409
 
    return (opvp_result_t)r;
410
 
}
411
 
 
412
 
opvp_result_t OPVPWrapper_0_2::SetFillMode(
413
 
  opvp_fillmode_t fillmode)
414
 
{
415
 
    if (!supportSetFillMode) {
416
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
417
 
        return -1;
418
 
    }
419
 
    /* OPVP_FillMode is comaptible with opvp_fillmode_t */
420
 
    return (opvp_result_t)procs_0_2->SetFillMode(printerContext_0_2,
421
 
      (OPVP_FillMode)fillmode);
422
 
}
423
 
 
424
 
opvp_result_t OPVPWrapper_0_2::GetFillMode(
425
 
  opvp_fillmode_t *pfillmode)
426
 
{
427
 
    if (!supportGetFillMode) {
428
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
429
 
        return -1;
430
 
    }
431
 
    /* OPVP_FillMode is comaptible with opvp_fillmode_t */
432
 
    return (opvp_result_t)procs_0_2->GetFillMode(printerContext_0_2,
433
 
      (OPVP_FillMode *)pfillmode);
434
 
}
435
 
 
436
 
opvp_result_t OPVPWrapper_0_2::SetAlphaConstant(
437
 
  opvp_float_t alpha)
438
 
{
439
 
    if (!supportSetAlphaConstant) {
440
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
441
 
        return -1;
442
 
    }
443
 
    return (opvp_result_t)procs_0_2->SetAlphaConstant(printerContext_0_2,alpha);
444
 
}
445
 
 
446
 
opvp_result_t OPVPWrapper_0_2::GetAlphaConstant(
447
 
  opvp_float_t *palpha)
448
 
{
449
 
    if (!supportGetAlphaConstant) {
450
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
451
 
        return -1;
452
 
    }
453
 
    return (opvp_result_t)procs_0_2->GetAlphaConstant(printerContext_0_2,palpha);
454
 
}
455
 
 
456
 
opvp_result_t OPVPWrapper_0_2::SetLineWidth(
457
 
  opvp_fix_t width)
458
 
{
459
 
    if (!supportSetLineWidth) {
460
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
461
 
        return -1;
462
 
    }
463
 
    return (opvp_result_t)procs_0_2->SetLineWidth(printerContext_0_2,width);
464
 
}
465
 
 
466
 
opvp_result_t OPVPWrapper_0_2::GetLineWidth(
467
 
  opvp_fix_t *pwidth)
468
 
{
469
 
    if (!supportGetLineWidth) {
470
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
471
 
        return -1;
472
 
    }
473
 
    return (opvp_result_t)procs_0_2->GetLineWidth(printerContext_0_2,pwidth);
474
 
}
475
 
 
476
 
opvp_result_t OPVPWrapper_0_2::SetLineDash(opvp_int_t num,
477
 
  const opvp_fix_t *pdash)
478
 
{
479
 
    if (!supportSetLineDash) {
480
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
481
 
        return -1;
482
 
    }
483
 
    return (opvp_result_t)procs_0_2->SetLineDash(printerContext_0_2,
484
 
      /* remove const */ (OPVP_Fix *)pdash,num);
485
 
}
486
 
 
487
 
opvp_result_t OPVPWrapper_0_2::GetLineDash(
488
 
  opvp_int_t *pnum, opvp_fix_t *pdash)
489
 
{
490
 
    if (!supportGetLineDash) {
491
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
492
 
        return -1;
493
 
    }
494
 
    return (opvp_result_t)procs_0_2->GetLineDash(printerContext_0_2,
495
 
      pdash,pnum);
496
 
}
497
 
 
498
 
opvp_result_t OPVPWrapper_0_2::SetLineDashOffset(
499
 
  opvp_fix_t offset)
500
 
{
501
 
    if (!supportSetLineDashOffset) {
502
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
503
 
        return -1;
504
 
    }
505
 
    return (opvp_result_t)procs_0_2->SetLineDashOffset(printerContext_0_2,offset);
506
 
}
507
 
 
508
 
opvp_result_t OPVPWrapper_0_2::GetLineDashOffset(
509
 
  opvp_fix_t *poffset)
510
 
{
511
 
    if (!supportGetLineDashOffset) {
512
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
513
 
        return -1;
514
 
    }
515
 
    return (opvp_result_t)procs_0_2->GetLineDashOffset(printerContext_0_2,poffset);
516
 
}
517
 
 
518
 
opvp_result_t OPVPWrapper_0_2::SetLineStyle(
519
 
  opvp_linestyle_t linestyle)
520
 
{
521
 
    if (!supportSetLineStyle) {
522
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
523
 
        return -1;
524
 
    }
525
 
    /* OPVP_LineStyle is compatible with opvp_linestyle_t */
526
 
    return (opvp_result_t)procs_0_2->SetLineStyle(printerContext_0_2,
527
 
      (OPVP_LineStyle)linestyle);
528
 
}
529
 
 
530
 
opvp_result_t OPVPWrapper_0_2::GetLineStyle(
531
 
  opvp_linestyle_t *plinestyle)
532
 
{
533
 
    if (!supportGetLineStyle) {
534
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
535
 
        return -1;
536
 
    }
537
 
    /* OPVP_LineStyle is compatible with opvp_linestyle_t */
538
 
    return (opvp_result_t)procs_0_2->GetLineStyle(printerContext_0_2,
539
 
      (OPVP_LineStyle *)plinestyle);
540
 
}
541
 
 
542
 
opvp_result_t OPVPWrapper_0_2::SetLineCap(
543
 
  opvp_linecap_t linecap)
544
 
{
545
 
    if (!supportSetLineCap) {
546
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
547
 
        return -1;
548
 
    }
549
 
    /* OPVP_LineCap is compatible with opvp_cap_t */
550
 
    return (opvp_result_t)procs_0_2->SetLineCap(printerContext_0_2,
551
 
      (OPVP_LineCap)linecap);
552
 
}
553
 
 
554
 
opvp_result_t OPVPWrapper_0_2::GetLineCap(
555
 
  opvp_linecap_t *plinecap)
556
 
{
557
 
    if (!supportGetLineCap) {
558
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
559
 
        return -1;
560
 
    }
561
 
    /* OPVP_LineCap is compatible with opvp_cap_t */
562
 
    return (opvp_result_t)procs_0_2->GetLineCap(printerContext_0_2,
563
 
      (OPVP_LineCap *)plinecap);
564
 
}
565
 
 
566
 
opvp_result_t OPVPWrapper_0_2::SetLineJoin(
567
 
  opvp_linejoin_t linejoin)
568
 
{
569
 
    if (!supportSetLineJoin) {
570
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
571
 
        return -1;
572
 
    }
573
 
    /* OPVP_LineJoin is compatible with opvp_linejoin_t */
574
 
    return (opvp_result_t)procs_0_2->SetLineJoin(printerContext_0_2,
575
 
      (OPVP_LineJoin)linejoin);
576
 
}
577
 
 
578
 
opvp_result_t OPVPWrapper_0_2::GetLineJoin(
579
 
  opvp_linejoin_t *plinejoin)
580
 
{
581
 
    if (!supportGetLineJoin) {
582
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
583
 
        return -1;
584
 
    }
585
 
    /* OPVP_LineJoin is compatible with opvp_linejoin_t */
586
 
    return (opvp_result_t)procs_0_2->GetLineJoin(printerContext_0_2,
587
 
      (OPVP_LineJoin *)plinejoin);
588
 
}
589
 
 
590
 
opvp_result_t OPVPWrapper_0_2::SetMiterLimit(
591
 
  opvp_fix_t miterlimit)
592
 
{
593
 
    if (!supportSetMiterLimit) {
594
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
595
 
        return -1;
596
 
    }
597
 
    /* OPVP_Fix is compatible with opvp_fix_t */
598
 
    return (opvp_result_t)procs_0_2->SetMiterLimit(printerContext_0_2,
599
 
      (OPVP_Fix)miterlimit);
600
 
}
601
 
 
602
 
opvp_result_t OPVPWrapper_0_2::GetMiterLimit(
603
 
  opvp_fix_t *pmiterlimit)
604
 
{
605
 
    if (!supportGetMiterLimit) {
606
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
607
 
        return -1;
608
 
    }
609
 
    /* OPVP_Fix is compatible with opvp_fix_t */
610
 
    return (opvp_result_t)procs_0_2->GetMiterLimit(printerContext_0_2,
611
 
      (OPVP_Fix *)pmiterlimit);
612
 
}
613
 
 
614
 
opvp_result_t OPVPWrapper_0_2::SetPaintMode(
615
 
  opvp_paintmode_t paintmode)
616
 
{
617
 
    if (!supportSetPaintMode) {
618
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
619
 
        return -1;
620
 
    }
621
 
    /* OPVP_PaintMode is compatible with opvp_paintmode_t */
622
 
    return (opvp_result_t)procs_0_2->SetPaintMode(printerContext_0_2,
623
 
      (OPVP_PaintMode)paintmode);
624
 
}
625
 
 
626
 
opvp_result_t OPVPWrapper_0_2::GetPaintMode(
627
 
  opvp_paintmode_t *ppaintmode)
628
 
{
629
 
    if (!supportGetPaintMode) {
630
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
631
 
        return -1;
632
 
    }
633
 
    /* OPVP_PaintMode is compatible with opvp_paintmode_t */
634
 
    return (opvp_result_t)procs_0_2->GetPaintMode(printerContext_0_2,
635
 
      (OPVP_PaintMode *)ppaintmode);
636
 
}
637
 
 
638
 
opvp_result_t OPVPWrapper_0_2::SetStrokeColor(
639
 
  const opvp_brush_t *brush)
640
 
{
641
 
    OPVP_Brush brush_0_2;
642
 
 
643
 
    if (!supportSetStrokeColor) {
644
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
645
 
        return -1;
646
 
    }
647
 
    if (brush == 0) {
648
 
        *opvpErrorNo_0_2 = OPVP_PARAMERROR_0_2;
649
 
        return -1;
650
 
    }
651
 
    if (brush->colorSpace == OPVP_CSPACE_DEVICEKRGB) {
652
 
        /* 0.2 doesn't have OPVP_CSPACE_DEVICEKRGB */
653
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
654
 
        return -1;
655
 
    }
656
 
    if ((unsigned int)brush->colorSpace
657
 
         > sizeof(cspace_1_0_to_0_2)/sizeof(OPVP_ColorSpace)) {
658
 
        /* unknown color space */
659
 
        *opvpErrorNo_0_2 = OPVP_PARAMERROR_0_2;
660
 
        return -1;
661
 
    }
662
 
    brush_0_2.colorSpace = cspace_1_0_to_0_2[brush->colorSpace];
663
 
    brush_0_2.xorg = brush->xorg;
664
 
    brush_0_2.yorg = brush->yorg;
665
 
    brush_0_2.pbrush = (OPVP_BrushData *)brush->pbrush;
666
 
    memcpy(brush_0_2.color,brush->color,sizeof(brush_0_2.color));
667
 
    return (opvp_result_t)procs_0_2->SetStrokeColor(printerContext_0_2,
668
 
      &brush_0_2);
669
 
}
670
 
 
671
 
opvp_result_t OPVPWrapper_0_2::SetFillColor(
672
 
  const opvp_brush_t *brush)
673
 
{
674
 
    OPVP_Brush brush_0_2;
675
 
 
676
 
    if (!supportSetFillColor) {
677
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
678
 
        return -1;
679
 
    }
680
 
    if (brush == 0) {
681
 
        *opvpErrorNo_0_2 = OPVP_PARAMERROR_0_2;
682
 
        return -1;
683
 
    }
684
 
    if (brush->colorSpace == OPVP_CSPACE_DEVICEKRGB) {
685
 
        /* 0.2 doesn't have OPVP_CSPACE_DEVICEKRGB */
686
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
687
 
        return -1;
688
 
    }
689
 
    if ((unsigned int)brush->colorSpace
690
 
         > sizeof(cspace_1_0_to_0_2)/sizeof(OPVP_ColorSpace)) {
691
 
        /* unknown color space */
692
 
        *opvpErrorNo_0_2 = OPVP_PARAMERROR_0_2;
693
 
        return -1;
694
 
    }
695
 
    brush_0_2.colorSpace = cspace_1_0_to_0_2[brush->colorSpace];
696
 
    brush_0_2.xorg = brush->xorg;
697
 
    brush_0_2.yorg = brush->yorg;
698
 
    brush_0_2.pbrush = (OPVP_BrushData *)brush->pbrush;
699
 
    memcpy(brush_0_2.color,brush->color,sizeof(brush_0_2.color));
700
 
    return (opvp_result_t)procs_0_2->SetFillColor(printerContext_0_2,
701
 
      &brush_0_2);
702
 
}
703
 
 
704
 
opvp_result_t OPVPWrapper_0_2::SetBgColor(
705
 
  const opvp_brush_t *brush)
706
 
{
707
 
    OPVP_Brush brush_0_2;
708
 
 
709
 
    if (!supportSetBgColor) {
710
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
711
 
        return -1;
712
 
    }
713
 
    if (brush == 0) {
714
 
        *opvpErrorNo_0_2 = OPVP_PARAMERROR_0_2;
715
 
        return -1;
716
 
    }
717
 
    if (brush->colorSpace == OPVP_CSPACE_DEVICEKRGB) {
718
 
        /* 0.2 doesn't have OPVP_CSPACE_DEVICEKRGB */
719
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
720
 
        return -1;
721
 
    }
722
 
    if ((unsigned int)brush->colorSpace
723
 
         > sizeof(cspace_1_0_to_0_2)/sizeof(OPVP_ColorSpace)) {
724
 
        /* unknown color space */
725
 
        *opvpErrorNo_0_2 = OPVP_PARAMERROR_0_2;
726
 
        return -1;
727
 
    }
728
 
    brush_0_2.colorSpace = cspace_1_0_to_0_2[brush->colorSpace];
729
 
    brush_0_2.xorg = brush->xorg;
730
 
    brush_0_2.yorg = brush->yorg;
731
 
    brush_0_2.pbrush = (OPVP_BrushData *)brush->pbrush;
732
 
    memcpy(brush_0_2.color,brush->color,sizeof(brush_0_2.color));
733
 
    return (opvp_result_t)procs_0_2->SetBgColor(printerContext_0_2,
734
 
      &brush_0_2);
735
 
}
736
 
 
737
 
opvp_result_t OPVPWrapper_0_2::NewPath()
738
 
{
739
 
    if (!supportNewPath) {
740
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
741
 
        return -1;
742
 
    }
743
 
    return (opvp_result_t)procs_0_2->NewPath(printerContext_0_2);
744
 
}
745
 
 
746
 
opvp_result_t OPVPWrapper_0_2::EndPath()
747
 
{
748
 
    if (!supportEndPath) {
749
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
750
 
        return -1;
751
 
    }
752
 
    return (opvp_result_t)procs_0_2->EndPath(printerContext_0_2);
753
 
}
754
 
 
755
 
opvp_result_t OPVPWrapper_0_2::StrokePath()
756
 
{
757
 
    if (!supportStrokePath) {
758
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
759
 
        return -1;
760
 
    }
761
 
    return (opvp_result_t)procs_0_2->StrokePath(printerContext_0_2);
762
 
}
763
 
 
764
 
opvp_result_t OPVPWrapper_0_2::FillPath()
765
 
{
766
 
    if (!supportFillPath) {
767
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
768
 
        return -1;
769
 
    }
770
 
    return (opvp_result_t)procs_0_2->FillPath(printerContext_0_2);
771
 
}
772
 
 
773
 
opvp_result_t OPVPWrapper_0_2::StrokeFillPath()
774
 
{
775
 
    if (!supportStrokeFillPath) {
776
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
777
 
        return -1;
778
 
    }
779
 
    return (opvp_result_t)procs_0_2->StrokeFillPath(printerContext_0_2);
780
 
}
781
 
 
782
 
opvp_result_t OPVPWrapper_0_2::SetClipPath(
783
 
  opvp_cliprule_t clipRule)
784
 
{
785
 
    if (!supportSetClipPath) {
786
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
787
 
        return -1;
788
 
    }
789
 
    /* OPVP_ClipRule is compatible with opvp_cliprule_t */
790
 
    return (opvp_result_t)procs_0_2->SetClipPath(printerContext_0_2,
791
 
      (OPVP_ClipRule)clipRule);
792
 
}
793
 
 
794
 
opvp_result_t OPVPWrapper_0_2::SetCurrentPoint(
795
 
  opvp_fix_t x, opvp_fix_t y)
796
 
{
797
 
    if (!supportSetCurrentPoint) {
798
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
799
 
        return -1;
800
 
    }
801
 
    return (opvp_result_t)procs_0_2->SetCurrentPoint(printerContext_0_2,x,y);
802
 
}
803
 
 
804
 
opvp_result_t OPVPWrapper_0_2::LinePath(
805
 
  opvp_pathmode_t flag, opvp_int_t npoints, const opvp_point_t *points)
806
 
{
807
 
    if (!supportLinePath) {
808
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
809
 
        return -1;
810
 
    }
811
 
    /* OPVP_Point is compatible with opvp_point_t */
812
 
    return (opvp_result_t)procs_0_2->LinePath(printerContext_0_2,flag,npoints,
813
 
      (OPVP_Point *)points);
814
 
}
815
 
 
816
 
opvp_result_t OPVPWrapper_0_2::PolygonPath(
817
 
  opvp_int_t npolygons, const opvp_int_t *nvertexes,
818
 
  const opvp_point_t *points)
819
 
{
820
 
    if (!supportPolygonPath) {
821
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
822
 
        return -1;
823
 
    }
824
 
    /* OPVP_Point is compatible with opvp_point_t */
825
 
    return (opvp_result_t)procs_0_2->PolygonPath(printerContext_0_2,
826
 
      (int)npolygons,(int *)nvertexes,(OPVP_Point *)points);
827
 
}
828
 
 
829
 
opvp_result_t OPVPWrapper_0_2::RectanglePath(
830
 
  opvp_int_t nrectangles, const opvp_rectangle_t *rectangles)
831
 
{
832
 
    if (!supportRectanglePath) {
833
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
834
 
        return -1;
835
 
    }
836
 
    /* OPVP_Rectangle is compatible with opvp_rectangle_t */
837
 
    return (opvp_result_t)procs_0_2->RectanglePath(printerContext_0_2,
838
 
      (int)nrectangles,(OPVP_Rectangle *)rectangles);
839
 
}
840
 
 
841
 
opvp_result_t OPVPWrapper_0_2::RoundRectanglePath(
842
 
  opvp_int_t nrectangles, const opvp_roundrectangle_t *rectangles)
843
 
{
844
 
    if (!supportRoundRectanglePath) {
845
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
846
 
        return -1;
847
 
    }
848
 
    /* OPVP_RoundRectangle is compatible with opvp_roundrectangle_t */
849
 
    return (opvp_result_t)procs_0_2->RoundRectanglePath(printerContext_0_2,
850
 
      (int)nrectangles,(OPVP_RoundRectangle *)rectangles);
851
 
}
852
 
 
853
 
opvp_result_t OPVPWrapper_0_2::BezierPath(opvp_int_t npoints,
854
 
    const opvp_point_t *points)
855
 
{
856
 
    if (!supportBezierPath) {
857
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
858
 
        return -1;
859
 
    }
860
 
    /* OPVP_Point is compatible with opvp_point_t */
861
 
    return (opvp_result_t)procs_0_2->BezierPath(printerContext_0_2,(int)npoints,
862
 
      (OPVP_Point *)points);
863
 
}
864
 
 
865
 
opvp_result_t OPVPWrapper_0_2::ArcPath(opvp_arcmode_t kind, opvp_arcdir_t dir,
866
 
  opvp_fix_t bbx0, opvp_fix_t bby0, opvp_fix_t bbx1,
867
 
  opvp_fix_t bby1, opvp_fix_t x0, opvp_fix_t y0, opvp_fix_t x1, opvp_fix_t y1)
868
 
{
869
 
    if (!supportArcPath) {
870
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
871
 
        return -1;
872
 
    }
873
 
    /* opvp_arcmode_t is compatible with int */
874
 
    /* opvp_arcdir_t is compatible with int */
875
 
    return (opvp_result_t)procs_0_2->ArcPath(printerContext_0_2,
876
 
      (int)kind,(int)dir,bbx0,bby0,
877
 
       bbx1,bby1,x0,y0,x1,y1);
878
 
}
879
 
 
880
 
opvp_result_t OPVPWrapper_0_2::DrawImage(opvp_int_t sourceWidth,
881
 
    opvp_int_t sourceHeight, opvp_int_t sourcePitch,
882
 
    opvp_imageformat_t imageFormat, opvp_int_t destinationWidth,
883
 
    opvp_int_t destinationHeight, const void *imagedata)
884
 
{
885
 
    int r;
886
 
    OPVP_Rectangle rect;
887
 
    OPVP_ImageFormat iformat_0_2;
888
 
    OPVP_PaintMode paintmode_0_2 = OPVP_paintModeTransparent;
889
 
    int depth;
890
 
 
891
 
    if (!supportDrawImage) {
892
 
      int result;
893
 
 
894
 
      if ((result = StartDrawImage(sourceWidth,
895
 
        sourceHeight,sourcePitch,imageFormat,destinationWidth,
896
 
        destinationHeight)) < 0) {
897
 
        return result;
898
 
      }
899
 
      if ((result = TransferDrawImage(sourcePitch*sourceHeight,
900
 
        imagedata)) < 0) {
901
 
        return result;
902
 
      }
903
 
      return EndDrawImage();
904
 
    }
905
 
 
906
 
    if (imageFormat == OPVP_IFORMAT_MASK) {
907
 
        if (procs_0_2->GetPaintMode != 0) {
908
 
            procs_0_2->GetPaintMode(printerContext_0_2,
909
 
              &paintmode_0_2);
910
 
        }
911
 
        if (paintmode_0_2 != OPVP_paintModeTransparent) {
912
 
            if (procs_0_2->SetROP != 0) {
913
 
                procs_0_2->SetROP(printerContext_0_2,
914
 
                    OPVP_0_2_ROP_S);
915
 
            }
916
 
        }
917
 
        else {
918
 
            if (procs_0_2->SetROP != 0) {
919
 
                procs_0_2->SetROP(printerContext_0_2,
920
 
                    OPVP_0_2_ROP_OR);
921
 
            }
922
 
        }
923
 
        depth = 1;
924
 
    } else {
925
 
        if (procs_0_2->SetROP != 0) {
926
 
            procs_0_2->SetROP(printerContext_0_2,OPVP_0_2_ROP_S);
927
 
        }
928
 
        depth = colorDepth_0_2[colorSpace];
929
 
    }
930
 
 
931
 
    OPVP_I2FIX(0,rect.p0.x);
932
 
    OPVP_I2FIX(0,rect.p0.y);
933
 
    OPVP_I2FIX(destinationWidth,rect.p1.x);
934
 
    OPVP_I2FIX(destinationHeight,rect.p1.y);
935
 
    if ((unsigned int)imageFormat 
936
 
      > sizeof(iformat_1_0_to_0_2)/sizeof(OPVP_ImageFormat)) {
937
 
        /* illegal image format */
938
 
        *opvpErrorNo_0_2 = OPVP_PARAMERROR_0_2;
939
 
        return -1;
940
 
    }
941
 
    iformat_0_2 = iformat_1_0_to_0_2[imageFormat];
942
 
    r = procs_0_2->DrawImage(printerContext_0_2,sourceWidth,sourceHeight,
943
 
            depth,iformat_0_2,rect,
944
 
            sourcePitch*sourceHeight,
945
 
            /* remove const */ (void *)imagedata);
946
 
 
947
 
    if (procs_0_2->SetROP != 0) {
948
 
        procs_0_2->SetROP(printerContext_0_2,OPVP_0_2_ROP_P);
949
 
    }
950
 
 
951
 
    return (opvp_result_t)r;
952
 
}
953
 
 
954
 
opvp_result_t OPVPWrapper_0_2::StartDrawImage(opvp_int_t sourceWidth,
955
 
    opvp_int_t sourceHeight, opvp_int_t sourcePitch,
956
 
    opvp_imageformat_t imageFormat, opvp_int_t destinationWidth,
957
 
    opvp_int_t destinationHeight)
958
 
{
959
 
    int r;
960
 
    OPVP_Rectangle rect;
961
 
    OPVP_ImageFormat iformat_0_2;
962
 
    OPVP_PaintMode paintmode_0_2 = OPVP_paintModeTransparent;
963
 
    int depth;
964
 
 
965
 
    if (!supportStartDrawImage) {
966
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
967
 
        return -1;
968
 
    }
969
 
    if (imageFormat == OPVP_IFORMAT_MASK) {
970
 
        if (procs_0_2->GetPaintMode != 0) {
971
 
            procs_0_2->GetPaintMode(printerContext_0_2,
972
 
              &paintmode_0_2);
973
 
        }
974
 
        if (paintmode_0_2 != OPVP_paintModeTransparent) {
975
 
            if (procs_0_2->SetROP != 0) {
976
 
                procs_0_2->SetROP(printerContext_0_2,OPVP_0_2_ROP_S);
977
 
            }
978
 
        }
979
 
        else {
980
 
            if (procs_0_2->SetROP != 0) {
981
 
                procs_0_2->SetROP(printerContext_0_2,OPVP_0_2_ROP_OR);
982
 
            }
983
 
        }
984
 
        depth = 1;
985
 
    } else {
986
 
        if (procs_0_2->SetROP != 0) {
987
 
            procs_0_2->SetROP(printerContext_0_2,OPVP_0_2_ROP_S);
988
 
        }
989
 
        depth = colorDepth_0_2[colorSpace];
990
 
    }
991
 
 
992
 
    OPVP_I2FIX(0,rect.p0.x);
993
 
    OPVP_I2FIX(0,rect.p0.y);
994
 
    OPVP_I2FIX(destinationWidth,rect.p1.x);
995
 
    OPVP_I2FIX(destinationHeight,rect.p1.y);
996
 
    if ((unsigned int)imageFormat
997
 
      > sizeof(iformat_1_0_to_0_2)/sizeof(OPVP_ImageFormat)) {
998
 
        /* illegal image format */
999
 
        *opvpErrorNo_0_2 = OPVP_PARAMERROR_0_2;
1000
 
        return -1;
1001
 
    }
1002
 
    iformat_0_2 = iformat_1_0_to_0_2[imageFormat];
1003
 
    r = procs_0_2->StartDrawImage(printerContext_0_2,
1004
 
            sourceWidth,sourceHeight,
1005
 
            depth,iformat_0_2,rect);
1006
 
 
1007
 
    return (opvp_result_t)r;
1008
 
}
1009
 
 
1010
 
opvp_result_t OPVPWrapper_0_2::TransferDrawImage(opvp_int_t count,
1011
 
    const void *imagedata)
1012
 
{
1013
 
    if (!supportTransferDrawImage) {
1014
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
1015
 
        return -1;
1016
 
    }
1017
 
    return (opvp_result_t)procs_0_2->TransferDrawImage(printerContext_0_2,
1018
 
      count,(void *)imagedata);
1019
 
}
1020
 
 
1021
 
opvp_result_t OPVPWrapper_0_2::EndDrawImage()
1022
 
{
1023
 
    int r;
1024
 
 
1025
 
    if (!supportEndDrawImage) {
1026
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
1027
 
        return -1;
1028
 
    }
1029
 
    r = procs_0_2->EndDrawImage(printerContext_0_2);
1030
 
 
1031
 
    /* make sure rop is pattern copy */
1032
 
    if (procs_0_2->SetROP != 0) {
1033
 
        procs_0_2->SetROP(printerContext_0_2,OPVP_0_2_ROP_P);
1034
 
    }
1035
 
 
1036
 
    return (opvp_result_t)r;
1037
 
}
1038
 
 
1039
 
opvp_result_t OPVPWrapper_0_2::StartScanline(opvp_int_t yposition)
1040
 
{
1041
 
    if (!supportStartScanline) {
1042
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
1043
 
        return -1;
1044
 
    }
1045
 
    return (opvp_result_t)procs_0_2->StartScanline(printerContext_0_2,yposition);
1046
 
}
1047
 
 
1048
 
opvp_result_t OPVPWrapper_0_2::Scanline(opvp_int_t nscanpairs,
1049
 
  const opvp_int_t *scanpairs)
1050
 
{
1051
 
    if (!supportScanline) {
1052
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
1053
 
        return -1;
1054
 
    }
1055
 
    return (opvp_result_t)procs_0_2->Scanline(printerContext_0_2,
1056
 
      (int)nscanpairs,(int *)scanpairs);
1057
 
}
1058
 
 
1059
 
opvp_result_t OPVPWrapper_0_2::EndScanline()
1060
 
{
1061
 
    if (!supportEndScanline) {
1062
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
1063
 
        return -1;
1064
 
    }
1065
 
    return (opvp_result_t)procs_0_2->EndScanline(printerContext_0_2);
1066
 
}
1067
 
 
1068
 
opvp_result_t OPVPWrapper_0_2::StartRaster(opvp_int_t rasterWidth)
1069
 
{
1070
 
    if (!supportStartRaster) {
1071
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
1072
 
        return -1;
1073
 
    }
1074
 
    return (opvp_result_t)procs_0_2->StartRaster(printerContext_0_2,rasterWidth);
1075
 
}
1076
 
 
1077
 
opvp_result_t OPVPWrapper_0_2::TransferRasterData(opvp_int_t count,
1078
 
    const opvp_byte_t *data)
1079
 
{
1080
 
    if (!supportTransferRasterData) {
1081
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
1082
 
        return -1;
1083
 
    }
1084
 
    return (opvp_result_t)procs_0_2->TransferRasterData(printerContext_0_2,
1085
 
      (int)count, (unsigned char *)data);
1086
 
}
1087
 
 
1088
 
opvp_result_t OPVPWrapper_0_2::SkipRaster(opvp_int_t count)
1089
 
{
1090
 
    if (!supportSkipRaster) {
1091
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
1092
 
        return -1;
1093
 
    }
1094
 
    return (opvp_result_t)procs_0_2->SkipRaster(printerContext_0_2,count);
1095
 
}
1096
 
 
1097
 
opvp_result_t OPVPWrapper_0_2::EndRaster()
1098
 
{
1099
 
    if (!supportEndRaster) {
1100
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
1101
 
        return -1;
1102
 
    }
1103
 
    return (opvp_result_t)procs_0_2->EndRaster(printerContext_0_2);
1104
 
}
1105
 
 
1106
 
opvp_result_t OPVPWrapper_0_2::StartStream()
1107
 
{
1108
 
    if (!supportStartStream) {
1109
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
1110
 
        return -1;
1111
 
    }
1112
 
    return (opvp_result_t)procs_0_2->StartStream(printerContext_0_2);
1113
 
}
1114
 
 
1115
 
opvp_result_t OPVPWrapper_0_2::TransferStreamData(opvp_int_t count,
1116
 
  const void *data)
1117
 
{
1118
 
    if (!supportTransferStreamData) {
1119
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
1120
 
        return -1;
1121
 
    }
1122
 
    return (opvp_result_t)procs_0_2->TransferStreamData(printerContext_0_2,
1123
 
      count,(void *)data);
1124
 
}
1125
 
 
1126
 
opvp_result_t OPVPWrapper_0_2::EndStream()
1127
 
{
1128
 
    if (!supportEndStream) {
1129
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
1130
 
        return -1;
1131
 
    }
1132
 
    return (opvp_result_t)procs_0_2->EndStream(printerContext_0_2);
1133
 
}
1134
 
 
1135
 
opvp_result_t OPVPWrapper_0_2::ResetClipPath()
1136
 
{
1137
 
    if (!supportResetClipPath) {
1138
 
        *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
1139
 
        return -1;
1140
 
    }
1141
 
    return (opvp_result_t)procs_0_2->ResetClipPath(printerContext_0_2);
1142
 
}
1143
 
 
1144
 
/* translate error code */
1145
 
opvp_int_t OPVPWrapper_0_2::getErrorNo()
1146
 
{
1147
 
    switch(*opvpErrorNo_0_2) {
1148
 
    case OPVP_FATALERROR_0_2:
1149
 
        return OPVP_FATALERROR; 
1150
 
        break;
1151
 
    case OPVP_BADREQUEST_0_2:
1152
 
        return OPVP_BADREQUEST; 
1153
 
        break;
1154
 
    case OPVP_BADCONTEXT_0_2:
1155
 
        return OPVP_BADCONTEXT; 
1156
 
        break;
1157
 
    case OPVP_NOTSUPPORTED_0_2:
1158
 
        return OPVP_NOTSUPPORTED; 
1159
 
        break;
1160
 
    case OPVP_JOBCANCELED_0_2:
1161
 
        return OPVP_JOBCANCELED; 
1162
 
        break;
1163
 
    case OPVP_PARAMERROR_0_2:
1164
 
        return OPVP_PARAMERROR; 
1165
 
        break;
1166
 
    default:
1167
 
        break;
1168
 
    }
1169
 
    /* unknown error no */
1170
 
    /* return FATALERROR instead */
1171
 
    return OPVP_FATALERROR;
1172
 
}