~ubuntu-branches/ubuntu/quantal/cups-filters/quantal-updates

« back to all changes in this revision

Viewing changes to pdftopdf/P2PXRef.cxx

  • Committer: Package Import Robot
  • Author(s): Till Kamppeter
  • Date: 2012-07-28 11:54:32 UTC
  • mfrom: (1.1.17) (22 sid)
  • mto: This revision was merged to the branch mainline in revision 28.
  • Revision ID: package-import@ubuntu.com-20120728115432-p5fgn9hv6du22cqa
* New upstream release
   - pdftops: Added another workaround for Kyocera printers: Some
     models get very slow on images which request interpolation,
     so now we remove the image interpolation requests by additional
     PostScript code only inserted for Kyocera printers (LP: #1026974).
   - Made the Poppler-based filters pdftopdf and pdftoopvp build with
     both Poppler 0.18.x and 0.20.x (Upstream bug #1055).
   - Fixes according to Coverity scan results (Upstream bug #1054).
   - Switched build system to autotools. This especially fixes several
     build problems in Gentoo. Also build-tested with CUPS 1.6.0b1.
   - Fixes for compatibility with clang/gcc-4.7.
   - textonly: Filter did not work as a pipe with copies=1 (Upstream bug
     #1032).
   - texttopdf: Avoid trimming the results of FcFontSort(), as this may
     miss some reasonable candidates under certain circumstances. BTW,
     fix passing a non-pointer as a pointer to "result" (Closes: #670055).
   - Corrected documentation. The option for the maximum image rendering
     resolution in pdftops is "pdftops-max-image-resolution", not
     "pdftops-max-image-resolution-default".
* debian/patches/fcfontsort-no-trim.patch: Removed, fixed upstream.
* debian/rules: Updated options for ./configure and make for the new autotools
  build system.
* debian/watch: Switched to bz2 upstream packages.
* debian/rules, debian/copyright, debian/cups-filters.docs: Updated for
  renamed documentation files.
* debian/control, debian/libfontembed1.install,
  debian/libfontembed-dev.install: Added new binary packages for libfontembed.
* debian/copyright: Updated for recent file additions, and rearrangement of
  directories.
* debian/control: Added missing build dependency on libpoppler-cpp-dev.
* debian/copyright: Corrections (Closes: #682752).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 
3
 
Copyright (c) 2006-2007, BBR Inc.  All rights reserved.
4
 
 
5
 
Permission is hereby granted, free of charge, to any person obtaining
6
 
a copy of this software and associated documentation files (the
7
 
"Software"), to deal in the Software without restriction, including
8
 
without limitation the rights to use, copy, modify, merge, publish,
9
 
distribute, sublicense, and/or sell copies of the Software, and to
10
 
permit persons to whom the Software is furnished to do so, subject to
11
 
the following conditions:
12
 
 
13
 
The above copyright notice and this permission notice shall be included
14
 
in all copies or substantial portions of the Software.
15
 
 
16
 
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
 
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
 
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
 
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
 
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
 
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
 
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
 
 
24
 
*/
25
 
/*
26
 
 P2PXRef.cc
27
 
 pdftopdf cross reference
28
 
*/
29
 
 
30
 
#include <config.h>
31
 
#include <string.h>
32
 
#include "goo/gmem.h"
33
 
#include "P2PXRef.h"
34
 
#include "P2PObject.h"
35
 
#include "Error.h"
36
 
 
37
 
/* increment size for object table */
38
 
#define INCSIZE 1024
39
 
 
40
 
P2PObject **P2PXRef::objects = 0;
41
 
int P2PXRef::objectsSize = 0;
42
 
int P2PXRef::currentNum = 1;
43
 
 
44
 
void P2PXRef::put(P2PObject *obj)
45
 
{
46
 
  int num, gen;
47
 
 
48
 
  obj->getNum(&num,&gen);
49
 
  if (num > 0) return; /* already registered */
50
 
  if (objectsSize == 0) {
51
 
    /* first time, alloc table */
52
 
    objects = new P2PObject *[INCSIZE];
53
 
    objectsSize = INCSIZE;
54
 
    memset(objects,0,objectsSize*sizeof(P2PObject *));
55
 
  } else if (++currentNum >= objectsSize) {
56
 
    /* enlarge table */
57
 
    P2PObject **oldp = objects;
58
 
    objectsSize += INCSIZE;
59
 
    objects = new P2PObject *[objectsSize];
60
 
    memcpy(objects,oldp,(objectsSize-INCSIZE)*sizeof(P2PObject *));
61
 
    delete[] oldp;
62
 
  }
63
 
  obj->setNum(currentNum,0);
64
 
  objects[currentNum] = obj;
65
 
}
66
 
 
67
 
void P2PXRef::put(P2PObject *obj, P2POutputStream *str)
68
 
{
69
 
  put(obj);
70
 
  obj->setOffset(str);
71
 
}
72
 
 
73
 
void P2PXRef::remove(P2PObject *obj)
74
 
{
75
 
  int num, gen;
76
 
 
77
 
  obj->getNum(&num,&gen);
78
 
  if (num > 0) {
79
 
    objects[num] = 0;
80
 
  }
81
 
}
82
 
 
83
 
void P2PXRef::flush(P2POutputStream *str, XRef *xref)
84
 
{
85
 
  int i;
86
 
  int n;
87
 
  GBool f;
88
 
 
89
 
  /* first phase */
90
 
  do {
91
 
    f = gFalse;
92
 
    n = getNObjects();
93
 
    for (i = 1;i < n;i++) {
94
 
      if (objects[i] != 0 && objects[i]->getOffset() < 0
95
 
         && !objects[i]->isSecondPhase()) {
96
 
        objects[i]->output(str,xref);
97
 
        f = gTrue;
98
 
      }
99
 
    }
100
 
  } while (f);
101
 
  /* second phase */
102
 
  do {
103
 
    f = gFalse;
104
 
    n = getNObjects();
105
 
    for (i = 1;i < n;i++) {
106
 
      if (objects[i] != 0 && objects[i]->getOffset() < 0) {
107
 
        objects[i]->output(str,xref);
108
 
        f = gTrue;
109
 
      }
110
 
    }
111
 
  } while (f);
112
 
}
113
 
 
114
 
int P2PXRef::output(P2POutputStream *str)
115
 
{
116
 
  int xrefOffset = str->getPosition();
117
 
  int i;
118
 
  int n = getNObjects();
119
 
 
120
 
  str->puts("xref\n");
121
 
  str->printf("0 %d\n", n);
122
 
  str->puts("0000000000 65535 f \n");
123
 
  for (i = 1;i < n;i++) {
124
 
    int num, gen;
125
 
    int offset;
126
 
 
127
 
    if (objects[i] == 0) {
128
 
      /* freed object */
129
 
      /* this situation is error. */
130
 
      /* but continue */
131
 
      str->puts("0000000000 00000 f \n");
132
 
      error(-1,const_cast<char *>("freed object:%d found\n"),i);
133
 
    } else {
134
 
      objects[i]->getNum(&num,&gen);
135
 
      offset = objects[i]->getOffset();
136
 
 
137
 
      if (offset < 0) {
138
 
        /* not output yet. error */
139
 
        error(-1,const_cast<char *>("not output object:%d found\n"),i);
140
 
      } else {
141
 
        str->printf("%010d %05d n \n",offset,gen);
142
 
      }
143
 
    }
144
 
  }
145
 
  return xrefOffset;
146
 
}
147
 
 
148
 
void P2PXRef::clean()
149
 
{
150
 
  int i;
151
 
  int n = getNObjects();
152
 
 
153
 
  for (i = 1;i < n;i++) {
154
 
    if (objects[i] != 0) {
155
 
      delete objects[i];
156
 
      objects[i] = 0;
157
 
    }
158
 
  }
159
 
}