~ubuntu-branches/ubuntu/oneiric/poppler/oneiric-security

« back to all changes in this revision

Viewing changes to poppler/Annot.cc

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2010-08-13 10:58:05 UTC
  • mfrom: (1.1.32 upstream)
  • Revision ID: james.westby@ubuntu.com-20100813105805-v6ybtufexxiska06
Tags: 0.14.2.is.0.14.1-0ubuntu1
* Revert previous upstream update. It bumped SONAME, but the packaging
  wasn't updated along with it, so we now have a broken libpoppler6. Provide
  a fixed one with this reversion until we can do the transition properly.
* debian/control: Update Breaks/Provides: to account for xpdf-utils now
  being a transitional package. Change forward ported from Debian's
  0.12.4-1.1 package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
90
90
// = (4 * (sqrt(2) - 1) / 3) * r
91
91
#define bezierCircle 0.55228475
92
92
 
93
 
// Ensures that x is between the limits set by low and high.
94
 
// If low is greater than high the result is undefined.
95
 
#define CLAMP(x, low, high)  (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
96
 
 
97
93
AnnotLineEndingStyle parseAnnotLineEndingStyle(GooString *string) {
98
94
  if (string != NULL) {
99
95
    if (!string->cmp("Square")) {
324
320
  quadrilateralsLength = 0;
325
321
 
326
322
  if ((arrayLength % 8) == 0) {
327
 
    int i;
 
323
    int i = 0;
328
324
 
329
325
    quadsLength = arrayLength / 8;
330
326
    quads = (AnnotQuadrilateral **) gmallocn
331
327
        ((quadsLength), sizeof(AnnotQuadrilateral *));
332
328
    memset(quads, 0, quadsLength * sizeof(AnnotQuadrilateral *));
333
329
 
334
 
    for (i = 0; i < quadsLength; i++) {
335
 
      for (int j = 0; j < 8; j++) {
 
330
    while (i < (quadsLength) && correct) {
 
331
      for (int j = 0; j < 8 && correct; j++) {
336
332
        Object obj;
337
333
        if (array->get(i * 8 + j, &obj)->isNum()) {
338
 
          if (j % 2 == 1)
339
 
            quadArray[j] = CLAMP (obj.getNum(), rect->y1, rect->y2);
340
 
          else
341
 
            quadArray[j] = CLAMP (obj.getNum(), rect->x1, rect->x2);
 
334
          quadArray[j] = obj.getNum();
 
335
          if (j % 2 == 1) {
 
336
              if (quadArray[j] < rect->y1 || quadArray[j] > rect->y2)
 
337
                  correct = gFalse;
 
338
          } else {
 
339
              if (quadArray[j] < rect->x1 || quadArray[j] > rect->x2)
 
340
                  correct = gFalse;
 
341
          }
342
342
        } else {
343
343
            correct = gFalse;
344
 
            obj.free();
345
 
            error (-1, "Invalid QuadPoint in annot");
346
 
            break;
347
344
        }
348
345
        obj.free();
349
346
      }
350
347
 
351
 
      if (!correct)
352
 
        break;
353
 
 
354
 
      quads[i] = new AnnotQuadrilateral(quadArray[0], quadArray[1],
355
 
                                        quadArray[2], quadArray[3],
356
 
                                        quadArray[4], quadArray[5],
357
 
                                        quadArray[6], quadArray[7]);
 
348
      if (correct)
 
349
        quads[i] = new AnnotQuadrilateral(quadArray[0], quadArray[1],
 
350
                                          quadArray[2], quadArray[3],
 
351
                                          quadArray[4], quadArray[5],
 
352
                                          quadArray[6], quadArray[7]);
 
353
      i++;
358
354
    }
359
355
 
360
356
    if (correct) {
1246
1242
  appearBuf->append("S\n");
1247
1243
}
1248
1244
 
1249
 
void Annot::createForm(double *bbox, GBool transparencyGroup, Object *resDict, Object *aStream) {
1250
 
  Object obj1, obj2;
1251
 
  Object appearDict;
1252
 
 
1253
 
  appearDict.initDict(xref);
1254
 
  appearDict.dictSet("Length", obj1.initInt(appearBuf->getLength()));
1255
 
  appearDict.dictSet("Subtype", obj1.initName("Form"));
1256
 
  obj1.initArray(xref);
1257
 
  obj1.arrayAdd(obj2.initReal(bbox[0]));
1258
 
  obj1.arrayAdd(obj2.initReal(bbox[1]));
1259
 
  obj1.arrayAdd(obj2.initReal(bbox[2]));
1260
 
  obj1.arrayAdd(obj2.initReal(bbox[3]));
1261
 
  appearDict.dictSet("BBox", &obj1);
1262
 
  if (transparencyGroup) {
1263
 
    Object transDict;
1264
 
    transDict.initDict(xref);
1265
 
    transDict.dictSet("S", obj1.initName("Transparency"));
1266
 
    appearDict.dictSet("Group", &transDict);
1267
 
  }
1268
 
  if (resDict)
1269
 
    appearDict.dictSet("Resources", resDict);
1270
 
 
1271
 
  MemStream *mStream = new MemStream(copyString(appearBuf->getCString()), 0,
1272
 
                                     appearBuf->getLength(), &appearDict);
1273
 
  mStream->setNeedFree(gTrue);
1274
 
  aStream->initStream(mStream);
1275
 
}
1276
 
 
1277
 
void Annot::createResourcesDict(char *formName, Object *formStream,
1278
 
                                char *stateName,
1279
 
                                double opacity, char *blendMode,
1280
 
                                Object *resDict) {
1281
 
  Object gsDict, stateDict, formDict, obj1;
1282
 
 
1283
 
  gsDict.initDict(xref);
1284
 
  if (opacity != 1) {
1285
 
    gsDict.dictSet("CA", obj1.initReal(opacity));
1286
 
    gsDict.dictSet("ca", obj1.initReal(opacity));
1287
 
  }
1288
 
  if (blendMode)
1289
 
    gsDict.dictSet("BM", obj1.initName(blendMode));
1290
 
  stateDict.initDict(xref);
1291
 
  stateDict.dictSet(stateName, &gsDict);
1292
 
  formDict.initDict(xref);
1293
 
  formDict.dictSet(formName, formStream);
1294
 
 
1295
 
  resDict->initDict(xref);
1296
 
  resDict->dictSet("ExtGState", &stateDict);
1297
 
  resDict->dictSet("XObject", &formDict);
1298
 
}
1299
 
 
1300
1245
GBool Annot::isVisible(GBool printing) {
1301
1246
  // check the flags
1302
1247
  if ((flags & flagHidden) ||
1322
1267
 
1323
1268
  // draw the appearance stream
1324
1269
  appearance.fetch(xref, &obj);
1325
 
  gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color,
 
1270
  gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, 1,
1326
1271
      rect->x1, rect->y1, rect->x2, rect->y2);
1327
1272
  obj.free();
1328
1273
}
1934
1879
      appearBuf->append (ANNOT_TEXT_AP_CIRCLE);
1935
1880
    appearBuf->append ("Q\n");
1936
1881
 
1937
 
    double bbox[4];
1938
 
    bbox[0] = bbox[1] = 0;
1939
 
    bbox[2] = bbox[3] = 24;
1940
 
    if (ca == 1) {
1941
 
      createForm(bbox, gFalse, NULL, &appearance);
1942
 
    } else {
1943
 
      Object aStream, resDict;
1944
 
 
1945
 
      createForm(bbox, gTrue, NULL, &aStream);
1946
 
      delete appearBuf;
1947
 
 
1948
 
      appearBuf = new GooString ("/GS0 gs\n/Fm0 Do");
1949
 
      createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict);
1950
 
      createForm(bbox, gFalse, &resDict, &appearance);
1951
 
    }
 
1882
    Object appearDict, obj1, obj2;
 
1883
 
 
1884
    appearDict.initDict(xref);
 
1885
    appearDict.dictSet("Length", obj1.initInt(appearBuf->getLength()));
 
1886
    appearDict.dictSet("Subtype", obj1.initName("Form"));
 
1887
    obj1.initArray(xref);
 
1888
    obj1.arrayAdd(obj2.initReal(0));
 
1889
    obj1.arrayAdd(obj2.initReal(0));
 
1890
    obj1.arrayAdd(obj2.initReal(24));
 
1891
    obj1.arrayAdd(obj2.initReal(24));
 
1892
    appearDict.dictSet("BBox", &obj1);
 
1893
 
 
1894
    MemStream *appearStream = new MemStream(copyString(appearBuf->getCString()), 0,
 
1895
                                            appearBuf->getLength(), &appearDict);
 
1896
    appearStream->setNeedFree(gTrue);
 
1897
    appearance.initStream(appearStream);
1952
1898
    delete appearBuf;
1953
1899
 
1954
1900
    rectx2 = rect->x1 + 24;
1957
1903
 
1958
1904
  // draw the appearance stream
1959
1905
  appearance.fetch(xref, &obj);
1960
 
  gfx->drawAnnot(&obj, border, color,
 
1906
  gfx->drawAnnot(&obj, border, color, ca,
1961
1907
                 rect->x1, rect->y1, rectx2, recty2);
1962
1908
  obj.free();
1963
1909
}
2049
1995
 
2050
1996
  // draw the appearance stream
2051
1997
  appearance.fetch(xref, &obj);
2052
 
  gfx->drawAnnot(&obj, border, color,
 
1998
  gfx->drawAnnot(&obj, border, color, 1,
2053
1999
                 rect->x1, rect->y1, rect->x2, rect->y2);
2054
2000
  obj.free();
2055
2001
}
2418
2364
    appearBuf->append ("S\n");
2419
2365
    appearBuf->append ("Q\n");
2420
2366
 
2421
 
    double bbox[4];
2422
 
    bbox[0] = bbox[1] = 0;
2423
 
    bbox[2] = rect->x2 - rect->x1;
2424
 
    bbox[3] = rect->y2 - rect->y1;
2425
 
    if (ca == 1) {
2426
 
      createForm(bbox, gFalse, NULL, &appearance);
2427
 
    } else {
2428
 
      Object aStream, resDict;
2429
 
 
2430
 
      createForm(bbox, gTrue, NULL, &aStream);
2431
 
      delete appearBuf;
2432
 
 
2433
 
      appearBuf = new GooString ("/GS0 gs\n/Fm0 Do");
2434
 
      createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict);
2435
 
      createForm(bbox, gFalse, &resDict, &appearance);
2436
 
    }
 
2367
    Object appearDict, obj1, obj2;
 
2368
 
 
2369
    appearDict.initDict(xref);
 
2370
    appearDict.dictSet("Length", obj1.initInt(appearBuf->getLength()));
 
2371
    appearDict.dictSet("Subtype", obj1.initName("Form"));
 
2372
    obj1.initArray(xref);
 
2373
    obj1.arrayAdd(obj2.initReal(0));
 
2374
    obj1.arrayAdd(obj2.initReal(0));
 
2375
    obj1.arrayAdd(obj2.initReal(rect->x2 - rect->x1));
 
2376
    obj1.arrayAdd(obj2.initReal(rect->y2 - rect->y1));
 
2377
    appearDict.dictSet("BBox", &obj1);
 
2378
 
 
2379
    MemStream *appearStream = new MemStream(copyString(appearBuf->getCString()), 0,
 
2380
                                              appearBuf->getLength(), &appearDict);
 
2381
    appearStream->setNeedFree(gTrue);
 
2382
    appearance.initStream(appearStream);
2437
2383
    delete appearBuf;
2438
2384
  }
2439
2385
 
2440
2386
  // draw the appearance stream
2441
2387
  appearance.fetch(xref, &obj);
2442
 
  gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color,
 
2388
  gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, ca,
2443
2389
                 rect->x1, rect->y1, rect->x2, rect->y2);
2444
2390
  obj.free();
2445
2391
}
2530
2476
  }
2531
2477
}
2532
2478
 
2533
 
 
2534
 
 
2535
2479
void AnnotTextMarkup::draw(Gfx *gfx, GBool printing) {
2536
2480
  Object obj;
2537
2481
  double ca = 1;
2538
2482
  int i;
2539
2483
  Object obj1, obj2;
 
2484
  Object formDict, resDict;
 
2485
  MemStream *mStream;
2540
2486
 
2541
2487
  if (!isVisible (printing))
2542
2488
    return;
2631
2577
        appearBuf->append ("f\n");
2632
2578
      }
2633
2579
 
2634
 
      Object aStream, resDict;
2635
 
      double bbox[4];
2636
 
      bbox[0] = rect->x1;
2637
 
      bbox[1] = rect->y1;
2638
 
      bbox[2] = rect->x2;
2639
 
      bbox[3] = rect->y2;
2640
 
      createForm(bbox, gTrue, NULL, &aStream);
2641
 
      delete appearBuf;
2642
 
 
2643
 
      appearBuf = new GooString ("/GS0 gs\n/Fm0 Do");
2644
 
      createResourcesDict("Fm0", &aStream, "GS0", 1, "Multiply", &resDict);
2645
 
      if (ca == 1) {
2646
 
        createForm(bbox, gFalse, &resDict, &appearance);
2647
 
      } else {
2648
 
        createForm(bbox, gTrue, &resDict, &aStream);
2649
 
        delete appearBuf;
2650
 
 
2651
 
        appearBuf = new GooString ("/GS0 gs\n/Fm0 Do");
2652
 
        createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict);
2653
 
        createForm(bbox, gFalse, &resDict, &appearance);
2654
 
      }
2655
 
      delete appearBuf;
 
2580
      Object appearDict;
 
2581
      appearDict.initDict(xref);
 
2582
      appearDict.dictSet("Length", obj1.initInt(appearBuf->getLength()));
 
2583
      appearDict.dictSet("Subtype", obj1.initName("Form"));
 
2584
      obj1.initArray(xref);
 
2585
      obj1.arrayAdd(obj2.initReal(rect->x1));
 
2586
      obj1.arrayAdd(obj2.initReal(rect->y1));
 
2587
      obj1.arrayAdd(obj2.initReal(rect->x2));
 
2588
      obj1.arrayAdd(obj2.initReal(rect->y2));
 
2589
      appearDict.dictSet("BBox", &obj1);
 
2590
      obj1.initArray(xref);
 
2591
      obj1.arrayAdd(obj2.initReal(1));
 
2592
      obj1.arrayAdd(obj2.initReal(0));
 
2593
      obj1.arrayAdd(obj2.initReal(0));
 
2594
      obj1.arrayAdd(obj2.initReal(1));
 
2595
      obj1.arrayAdd(obj2.initReal(-rect->x1));
 
2596
      obj1.arrayAdd(obj2.initReal(-rect->y1));
 
2597
      appearDict.dictSet("Matrix", &obj1);
 
2598
 
 
2599
      Object aStream;
 
2600
      mStream = new MemStream(copyString(appearBuf->getCString()), 0,
 
2601
                              appearBuf->getLength(), &appearDict);
 
2602
      mStream->setNeedFree(gTrue);
 
2603
      aStream.initStream(mStream);
 
2604
      delete appearBuf;
 
2605
 
 
2606
      Object transDict;
 
2607
      formDict.initDict(xref);
 
2608
      formDict.dictSet ("Form", &aStream);
 
2609
      resDict.initDict(xref);
 
2610
      resDict.dictSet ("XObject", &formDict);
 
2611
 
 
2612
      transDict.initDict(xref);
 
2613
      transDict.dictSet ("S", obj1.initName("Transparency"));
 
2614
 
 
2615
      appearBuf = new GooString ("/Form Do");
 
2616
 
 
2617
      formDict.initDict(xref);
 
2618
      formDict.dictSet("Length", obj1.initInt(appearBuf->getLength()));
 
2619
      formDict.dictSet("Subtype", obj1.initName("Form"));
 
2620
      formDict.dictSet("Group", &transDict);
 
2621
      formDict.dictSet("Resources", &resDict);
 
2622
      obj1.initArray(xref);
 
2623
      obj1.arrayAdd(obj2.initReal(0));
 
2624
      obj1.arrayAdd(obj2.initReal(0));
 
2625
      obj1.arrayAdd(obj2.initReal(rect->x2 - rect->x1));
 
2626
      obj1.arrayAdd(obj2.initReal(rect->y2 - rect->y1));
 
2627
      formDict.dictSet("BBox", &obj1);
 
2628
 
 
2629
      mStream = new MemStream(copyString(appearBuf->getCString()), 0,
 
2630
                              appearBuf->getLength(), &formDict);
 
2631
      mStream->setNeedFree(gTrue);
 
2632
      aStream.initStream(mStream);
 
2633
      delete appearBuf;
 
2634
 
 
2635
      Object stateDict;
 
2636
 
 
2637
      formDict.initDict(xref);
 
2638
      formDict.dictSet ("HAForm", &aStream);
 
2639
      transDict.initDict(xref);
 
2640
      transDict.dictSet ("BM", obj1.initName("Multiply"));
 
2641
      stateDict.initDict(xref);
 
2642
      stateDict.dictSet ("R0", &transDict);
 
2643
      resDict.initDict(xref);
 
2644
      resDict.dictSet ("XObject", &formDict);
 
2645
      resDict.dictSet ("ExtGState", &stateDict);
 
2646
 
 
2647
      appearBuf = new GooString ("/R0 gs\n/HAForm Do");
 
2648
 
2656
2649
      break;
2657
2650
    }
 
2651
 
 
2652
    formDict.initDict(xref);
 
2653
    formDict.dictSet("Length", obj1.initInt(appearBuf->getLength()));
 
2654
    formDict.dictSet("Subtype", obj1.initName("Form"));
 
2655
    if (type == typeHighlight)
 
2656
      formDict.dictSet("Resources", &resDict);
 
2657
    obj1.initArray(xref);
 
2658
    obj1.arrayAdd(obj2.initReal(0));
 
2659
    obj1.arrayAdd(obj2.initReal(0));
 
2660
    obj1.arrayAdd(obj2.initReal(rect->x2 - rect->x1));
 
2661
    obj1.arrayAdd(obj2.initReal(rect->y2 - rect->y1));
 
2662
    formDict.dictSet("BBox", &obj1);
 
2663
 
 
2664
    mStream = new MemStream(copyString(appearBuf->getCString()), 0,
 
2665
                            appearBuf->getLength(), &formDict);
 
2666
    mStream->setNeedFree(gTrue);
 
2667
    appearance.initStream(mStream);
 
2668
    delete appearBuf;
2658
2669
  }
2659
2670
 
2660
2671
  // draw the appearance stream
2661
2672
  appearance.fetch(xref, &obj);
2662
 
  gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color,
 
2673
  gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, ca,
2663
2674
                 rect->x1, rect->y1, rect->x2, rect->y2);
2664
2675
  obj.free();
2665
2676
}
4021
4032
    gfx->pushResources(dict);
4022
4033
    delete dict;
4023
4034
  }
4024
 
  gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color,
 
4035
  gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, 1,
4025
4036
                 rect->x1, rect->y1, rect->x2, rect->y2);
4026
4037
  if (addDingbatsResource) {
4027
4038
    gfx->popResources();
4163
4174
      appearBuf->append ("Q\n");
4164
4175
      appearBuf->append ("Q\n");
4165
4176
 
4166
 
      double bbox[4];
4167
 
      bbox[0] = bbox[1] = 0;
4168
 
      bbox[2] = width;
4169
 
      bbox[3] = height;
4170
 
      createForm(bbox, gFalse, &resDict, &appearance);
 
4177
      Object appearDict;
 
4178
      appearDict.initDict(xref);
 
4179
      appearDict.dictSet("Length", obj1.initInt(appearBuf->getLength()));
 
4180
      appearDict.dictSet("Subtype", obj1.initName("Form"));
 
4181
      appearDict.dictSet("Resources", &resDict);
 
4182
      obj1.initArray(xref);
 
4183
      obj1.arrayAdd(obj2.initInt(0));
 
4184
      obj1.arrayAdd(obj2.initInt(0));
 
4185
      obj1.arrayAdd(obj2.initInt(width));
 
4186
      obj1.arrayAdd(obj2.initInt(height));
 
4187
      appearDict.dictSet("BBox", &obj1);
 
4188
 
 
4189
      MemStream *appearStream = new MemStream(copyString(appearBuf->getCString()), 0,
 
4190
                                              appearBuf->getLength(), &appearDict);
 
4191
      appearStream->setNeedFree(gTrue);
 
4192
      appearance.initStream(appearStream);
4171
4193
      delete appearBuf;
4172
4194
    }
4173
4195
    poster.free();
4175
4197
 
4176
4198
  // draw the appearance stream
4177
4199
  appearance.fetch(xref, &obj);
4178
 
  gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color,
 
4200
  gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, 1,
4179
4201
                 rect->x1, rect->y1, rect->x2, rect->y2);
4180
4202
  obj.free();
4181
4203
}
4441
4463
      appearBuf->append ("S\n");
4442
4464
    appearBuf->append ("Q\n");
4443
4465
 
4444
 
    double bbox[4];
4445
 
    bbox[0] = bbox[1] = 0;
4446
 
    bbox[2] = rect->x2 - rect->x1;
4447
 
    bbox[3] = rect->y2 - rect->y1;
4448
 
    if (ca == 1) {
4449
 
      createForm(bbox, gFalse, NULL, &appearance);
4450
 
    } else {
4451
 
      Object aStream;
4452
 
 
4453
 
      createForm(bbox, gTrue, NULL, &aStream);
4454
 
      delete appearBuf;
4455
 
 
4456
 
      Object resDict;
4457
 
      appearBuf = new GooString ("/GS0 gs\n/Fm0 Do");
4458
 
      createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict);
4459
 
      createForm(bbox, gFalse, &resDict, &appearance);
4460
 
    }
 
4466
    Object appearDict, obj1, obj2;
 
4467
 
 
4468
    appearDict.initDict(xref);
 
4469
    appearDict.dictSet("Length", obj1.initInt(appearBuf->getLength()));
 
4470
    appearDict.dictSet("Subtype", obj1.initName("Form"));
 
4471
    obj1.initArray(xref);
 
4472
    obj1.arrayAdd(obj2.initReal(0));
 
4473
    obj1.arrayAdd(obj2.initReal(0));
 
4474
    obj1.arrayAdd(obj2.initReal(rect->x2 - rect->x1));
 
4475
    obj1.arrayAdd(obj2.initReal(rect->y2 - rect->y1));
 
4476
    appearDict.dictSet("BBox", &obj1);
 
4477
 
 
4478
    MemStream *appearStream = new MemStream(copyString(appearBuf->getCString()), 0,
 
4479
                                            appearBuf->getLength(), &appearDict);
 
4480
    appearStream->setNeedFree(gTrue);
 
4481
    appearance.initStream(appearStream);
4461
4482
    delete appearBuf;
4462
4483
  }
4463
4484
 
4464
4485
  // draw the appearance stream
4465
4486
  appearance.fetch(xref, &obj);
4466
 
  gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color,
 
4487
  gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, ca,
4467
4488
                 rect->x1, rect->y1, rect->x2, rect->y2);
4468
4489
  obj.free();
4469
4490
}
4898
4919
      appearBuf->append (ANNOT_FILE_ATTACHMENT_AP_TAG);
4899
4920
    appearBuf->append ("Q\n");
4900
4921
 
4901
 
    double bbox[4];
4902
 
    bbox[0] = bbox[1] = 0;
4903
 
    bbox[2] = bbox[3] = 24;
4904
 
    if (ca == 1) {
4905
 
      createForm (bbox, gFalse, NULL, &appearance);
4906
 
    } else {
4907
 
      Object aStream;
4908
 
 
4909
 
      createForm (bbox, gTrue, NULL, &aStream);
4910
 
      delete appearBuf;
4911
 
 
4912
 
      Object resDict;
4913
 
      appearBuf = new GooString ("/GS0 gs\n/Fm0 Do");
4914
 
      createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict);
4915
 
      createForm(bbox, gFalse, &resDict, &appearance);
4916
 
    }
 
4922
    Object appearDict, obj1, obj2;
 
4923
 
 
4924
    appearDict.initDict(xref);
 
4925
    appearDict.dictSet("Length", obj1.initInt(appearBuf->getLength()));
 
4926
    appearDict.dictSet("Subtype", obj1.initName("Form"));
 
4927
    obj1.initArray(xref);
 
4928
    obj1.arrayAdd(obj2.initReal(0));
 
4929
    obj1.arrayAdd(obj2.initReal(0));
 
4930
    obj1.arrayAdd(obj2.initReal(24));
 
4931
    obj1.arrayAdd(obj2.initReal(24));
 
4932
    appearDict.dictSet("BBox", &obj1);
 
4933
 
 
4934
    MemStream *appearStream = new MemStream(copyString(appearBuf->getCString()), 0,
 
4935
                                            appearBuf->getLength(), &appearDict);
 
4936
    appearStream->setNeedFree(gTrue);
 
4937
    appearance.initStream(appearStream);
4917
4938
    delete appearBuf;
4918
4939
  }
4919
4940
 
4920
4941
  // draw the appearance stream
4921
4942
  appearance.fetch(xref, &obj);
4922
 
  gfx->drawAnnot(&obj, border, color,
 
4943
  gfx->drawAnnot(&obj, border, color, ca,
4923
4944
                 rect->x1, rect->y1, rect->x2, rect->y2);
4924
4945
  obj.free();
4925
4946
}
5060
5081
      appearBuf->append (ANNOT_SOUND_AP_MIC);
5061
5082
    appearBuf->append ("Q\n");
5062
5083
 
5063
 
    double bbox[4];
5064
 
    bbox[0] = bbox[1] = 0;
5065
 
    bbox[2] = bbox[3] = 24;
5066
 
    if (ca == 1) {
5067
 
      createForm(bbox, gFalse, NULL, &appearance);
5068
 
    } else {
5069
 
      Object aStream, resDict;
5070
 
 
5071
 
      createForm(bbox, gTrue, NULL, &aStream);
5072
 
      delete appearBuf;
5073
 
 
5074
 
      appearBuf = new GooString ("/GS0 gs\n/Fm0 Do");
5075
 
      createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict);
5076
 
      createForm(bbox, gFalse, &resDict, &appearance);
5077
 
    }
 
5084
    Object appearDict, obj1, obj2;
 
5085
 
 
5086
    appearDict.initDict(xref);
 
5087
    appearDict.dictSet("Length", obj1.initInt(appearBuf->getLength()));
 
5088
    appearDict.dictSet("Subtype", obj1.initName("Form"));
 
5089
    obj1.initArray(xref);
 
5090
    obj1.arrayAdd(obj2.initReal(0));
 
5091
    obj1.arrayAdd(obj2.initReal(0));
 
5092
    obj1.arrayAdd(obj2.initReal(24));
 
5093
    obj1.arrayAdd(obj2.initReal(24));
 
5094
    appearDict.dictSet("BBox", &obj1);
 
5095
 
 
5096
    MemStream *appearStream = new MemStream(copyString(appearBuf->getCString()), 0,
 
5097
                                            appearBuf->getLength(), &appearDict);
 
5098
    appearStream->setNeedFree(gTrue);
 
5099
    appearance.initStream(appearStream);
5078
5100
    delete appearBuf;
5079
5101
  }
5080
5102
 
5081
5103
  // draw the appearance stream
5082
5104
  appearance.fetch(xref, &obj);
5083
 
  gfx->drawAnnot(&obj, border, color,
 
5105
  gfx->drawAnnot(&obj, border, color, ca,
5084
5106
                 rect->x1, rect->y1, rect->x2, rect->y2);
5085
5107
  obj.free();
5086
5108
}