~ubuntu-branches/ubuntu/hardy/ghostscript/hardy

« back to all changes in this revision

Viewing changes to src/gdevpdfu.c

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2007-11-22 12:17:43 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20071122121743-cd70s3ypq0r243mp
Tags: 8.61.dfsg.1-0ubtuntu1
* New upstream release
  o Final 8.61 release
* debian/patches/09_ijs_krgb_support.dpatch: Adapted to upstream changes.
* debian/rules: Updated CUPS-related variables for "make install" calls.
* debian/rules: Remove /usr/include/ghostscript from the ghostscript
  package, they go into lings-dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
   San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
12
12
*/
13
13
 
14
 
/* $Id: gdevpdfu.c 8050 2007-06-13 23:21:11Z leonardo $ */
 
14
/* $Id: gdevpdfu.c 8360 2007-11-13 10:01:55Z ken $ */
15
15
/* Output utilities for PDF-writing driver */
16
16
#include "memory_.h"
17
17
#include "jpeglib_.h"           /* for sdct.h */
84
84
 * Note that this may store into the string.
85
85
 */
86
86
/* This function copied from geninit.c . */
87
 
private char *
 
87
static char *
88
88
doit(char *line, bool intact)
89
89
{
90
90
    char *str = line;
152
152
}
153
153
 
154
154
 
155
 
private int
 
155
static int
156
156
copy_ps_file_stripping(stream *s, const char *fname, bool HaveTrueTypes)
157
157
{
158
158
    FILE *f;
225
225
    return 0;
226
226
}
227
227
 
228
 
private int
 
228
static int
229
229
copy_procsets(stream *s, const gs_param_string *path, bool HaveTrueTypes)
230
230
{
231
231
    char fname[gp_file_name_sizeof];
270
270
    return 0;
271
271
}
272
272
 
273
 
private int
 
273
static int
274
274
encode(stream **s, const stream_template *t, gs_memory_t *mem)
275
275
{
276
276
    stream_state *st = s_alloc_state(mem, t->stype, "pdf_open_document.encode");
350
350
/* ------ Objects ------ */
351
351
 
352
352
/* Allocate an object ID. */
353
 
private long
 
353
static long
354
354
pdf_next_id(gx_device_pdf * pdev)
355
355
{
356
356
    return (pdev->next_id)++;
423
423
/* ------ Page contents ------ */
424
424
 
425
425
/* Handle transitions between contexts. */
426
 
private int
 
426
static int
427
427
    none_to_stream(gx_device_pdf *), stream_to_text(gx_device_pdf *),
428
428
    string_to_text(gx_device_pdf *), text_to_stream(gx_device_pdf *),
429
429
    stream_to_none(gx_device_pdf *);
430
430
typedef int (*context_proc) (gx_device_pdf *);
431
 
private const context_proc context_procs[4][4] =
 
431
static const context_proc context_procs[4][4] =
432
432
{
433
433
    {0, none_to_stream, none_to_stream, none_to_stream},
434
434
    {stream_to_none, 0, stream_to_text, stream_to_text},
437
437
};
438
438
 
439
439
/* Compute an object encryption key. */
440
 
private int
 
440
static int
441
441
pdf_object_key(const gx_device_pdf * pdev, gs_id object_id, byte key[16])
442
442
{
443
443
    gs_md5_state_t md5;
511
511
}
512
512
 
513
513
/* Enter stream context. */
514
 
private int
 
514
static int
515
515
none_to_stream(gx_device_pdf * pdev)
516
516
{
517
517
    stream *s;
613
613
    return PDF_IN_STREAM;
614
614
}
615
615
/* Enter text context from stream context. */
616
 
private int
 
616
static int
617
617
stream_to_text(gx_device_pdf * pdev)
618
618
{
619
619
    int code;
636
636
    return (code < 0 ? code : PDF_IN_TEXT);
637
637
}
638
638
/* Exit string context to text context. */
639
 
private int
 
639
static int
640
640
string_to_text(gx_device_pdf * pdev)
641
641
{
642
642
    int code = pdf_from_string_to_text(pdev);
644
644
    return (code < 0 ? code : PDF_IN_TEXT);
645
645
}
646
646
/* Exit text context to stream context. */
647
 
private int
 
647
static int
648
648
text_to_stream(gx_device_pdf * pdev)
649
649
{
650
650
    int code;
657
657
    return PDF_IN_STREAM;
658
658
}
659
659
/* Exit stream context. */
660
 
private int
 
660
static int
661
661
stream_to_none(gx_device_pdf * pdev)
662
662
{
663
663
    stream *s = pdev->strm;
787
787
    }
788
788
}
789
789
 
790
 
private int 
 
790
static int 
791
791
nocheck(gx_device_pdf * pdev, pdf_resource_t *pres0, pdf_resource_t *pres1)
792
792
{
793
793
    return 1;
1001
1001
    } else
1002
1002
        pdf_reserve_object_id(pdev, pres, id);
1003
1003
    pres->next = *plist;
 
1004
    pres->rid = 0;
1004
1005
    *plist = pres;
1005
1006
    pres->prev = pdev->last_resource;
1006
1007
    pdev->last_resource = pres;
1424
1425
 * null <00>, and the machinery for selecting the put_name_chars procedure
1425
1426
 * depending on CompatibilityLevel is no longer needed.
1426
1427
 */
1427
 
private int
 
1428
static int
1428
1429
pdf_put_name_chars_1_2(stream *s, const byte *nstr, uint size)
1429
1430
{
1430
1431
    uint i;
1474
1475
}
1475
1476
 
1476
1477
/* Write an encoded string with encryption. */
1477
 
private int
 
1478
static int
1478
1479
pdf_encrypt_encoded_string(const gx_device_pdf *pdev, const byte *str, uint size, gs_id object_id)
1479
1480
{
1480
1481
    stream sinp, sstr, sout;
1518
1519
}
1519
1520
 
1520
1521
/* Write an encoded string with possible encryption. */
1521
 
private int
 
1522
static int
1522
1523
pdf_put_encoded_string(const gx_device_pdf *pdev, const byte *str, uint size, gs_id object_id)
1523
1524
{
1524
1525
    if (!pdev->KeyLength || object_id == (gs_id)-1) {
1528
1529
        return pdf_encrypt_encoded_string(pdev, str, size, object_id);
1529
1530
}
1530
1531
/* Write an encoded hexadecimal string with possible encryption. */
1531
 
private int
 
1532
static int
1532
1533
pdf_put_encoded_hex_string(const gx_device_pdf *pdev, const byte *str, uint size, gs_id object_id)
1533
1534
{
1534
1535
    eprintf("Unimplemented function : pdf_put_encoded_hex_string\n");
1542
1543
    Other items are passed identically.
1543
1544
    Note we don't reconstruct the nesting of arrays|dictionaries.
1544
1545
*/
1545
 
private int
 
1546
static int
1546
1547
pdf_scan_item(const gx_device_pdf * pdev, const byte * p, uint l, gs_id object_id)
1547
1548
{
1548
1549
    const byte *q = p;
1561
1562
}
1562
1563
 
1563
1564
/* Write a serialized array or dictionary with possible encryption. */
1564
 
private int
 
1565
static int
1565
1566
pdf_put_composite(const gx_device_pdf * pdev, const byte * vstr, uint size, gs_id object_id)
1566
1567
{
1567
1568
    if (!pdev->KeyLength || object_id == (gs_id)-1) {
1726
1727
}
1727
1728
 
1728
1729
/* Add a Flate compression filter to a binary writer. */
1729
 
private int
 
1730
static int
1730
1731
pdf_flate_binary(gx_device_pdf *pdev, psdf_binary_writer *pbw)
1731
1732
{
1732
1733
    const stream_template *template = (pdev->CompatibilityLevel < 1.3 ? 
1850
1851
}
1851
1852
 
1852
1853
/* Create a Function object. */
1853
 
private int pdf_function_array(gx_device_pdf *pdev, cos_array_t *pca,
 
1854
static int pdf_function_array(gx_device_pdf *pdev, cos_array_t *pca,
1854
1855
                               const gs_function_info_t *pinfo);
1855
1856
int
1856
1857
pdf_function_scaled(gx_device_pdf *pdev, const gs_function_t *pfn,
1890
1891
        return code;
1891
1892
    }
1892
1893
}
1893
 
private int
 
1894
static int
1894
1895
pdf_function_aux(gx_device_pdf *pdev, const gs_function_t *pfn,
1895
1896
             pdf_resource_t **ppres)
1896
1897
{
1986
1987
        return code;
1987
1988
    return gs_function_get_params(pfn, (gs_param_list *)&rlist);
1988
1989
}
1989
 
private int 
 
1990
static int 
1990
1991
functions_equal(gx_device_pdf * pdev, pdf_resource_t *pres0, pdf_resource_t *pres1)
1991
1992
{
1992
1993
    return true;
2005
2006
    COS_OBJECT_VALUE(pvalue, pres->object);
2006
2007
    return 0;
2007
2008
}
2008
 
private int pdf_function_array(gx_device_pdf *pdev, cos_array_t *pca,
 
2009
static int pdf_function_array(gx_device_pdf *pdev, cos_array_t *pca,
2009
2010
                               const gs_function_info_t *pinfo)
2010
2011
{
2011
2012
    int i, code = 0;
2053
2054
             pbox->p.x, pbox->p.y, x, y);
2054
2055
    return 0;
2055
2056
}
 
2057
 
 
2058
/* Write a FontBBox dictionary element using floats for the values. */
 
2059
int
 
2060
pdf_write_font_bbox_float(gx_device_pdf *pdev, const gs_rect *pbox)
 
2061
{
 
2062
    stream *s = pdev->strm;
 
2063
    /*
 
2064
     * AR 4 doesn't like fonts with empty FontBBox, which
 
2065
     * happens when the font contains only space characters.
 
2066
     * Small bbox causes AR 4 to display a hairline. So we use
 
2067
     * the full BBox.
 
2068
     */ 
 
2069
    float x = pbox->q.x + ((pbox->p.x == pbox->q.x) ? 1000 : 0);
 
2070
    float y = pbox->q.y + ((pbox->p.y == pbox->q.y) ? 1000 : 0);
 
2071
 
 
2072
    pprintg4(s, "/FontBBox[%f %f %f %f]",
 
2073
             pbox->p.x, pbox->p.y, x, y);
 
2074
    return 0;
 
2075
}