~ubuntu-branches/ubuntu/raring/cups-filters/raring-proposed

« back to all changes in this revision

Viewing changes to filter/pdftopdf/P2PForm.cxx

  • Committer: Package Import Robot
  • Author(s): Till Kamppeter
  • Date: 2012-07-22 18:57:32 UTC
  • mfrom: (1.1.17)
  • Revision ID: package-import@ubuntu.com-20120722185732-26kkte5p1lth3rt5
Tags: 1.0.20-0bzr1
* 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.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 
 
3
Copyright (c) 2006-2010, 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
 P2PForm.h
 
27
 pdftopdf form
 
28
 Note: Only use this for Forms without Resource entry.
 
29
*/
 
30
#include "P2PDoc.h"
 
31
#include "P2PGfx.h"
 
32
#include "P2PXRef.h"
 
33
#include "P2PForm.h"
 
34
 
 
35
P2PForm::P2PForm(Object *orgFormA, P2PResources *resourcesA,
 
36
  P2PResourceMap *mapA)
 
37
{
 
38
  /* assumed orgFormA is Reference */
 
39
  orgFormA->copy(&orgForm);
 
40
  resources = resourcesA;
 
41
  mappingTable = mapA;
 
42
}
 
43
 
 
44
P2PForm::~P2PForm()
 
45
{
 
46
  /* resources and mappingTable are deleted in other class.
 
47
     Don't delete them here */
 
48
  orgForm.free();
 
49
}
 
50
 
 
51
void P2PForm::output(P2POutputStream *str, XRef *xref)
 
52
{
 
53
  int i;
 
54
  int n;
 
55
  Dict *dict;
 
56
  int len;
 
57
  Object lenobj;
 
58
  P2PObj *pobj = new P2PObj();
 
59
 
 
60
  outputBegin(str);
 
61
 
 
62
  str->puts("<< /Length ");
 
63
  P2PXRef::put(pobj);
 
64
  pobj->outputRef(str);
 
65
  if (P2PDoc::options.contentsCompress && str->canDeflate()) {
 
66
    str->puts(" /Filter /FlateDecode ");
 
67
  }
 
68
 
 
69
  dict = orgForm.streamGetDict();
 
70
  n = dict->getLength();
 
71
  for (i = 0;i < n;i++) {
 
72
#ifdef HAVE_UGOOSTRING_H
 
73
    char *key = dict->getKey(i)->getCString();
 
74
#else
 
75
    char *key = dict->getKey(i);
 
76
#endif
 
77
    Object obj;
 
78
 
 
79
    if (strcmp(key,"Filter") == 0 || strcmp(key,"Length") == 0) continue;
 
80
    P2POutput::outputName(key,str);
 
81
    str->putchar(' ');
 
82
    dict->getValNF(i,&obj);
 
83
    P2POutput::outputObject(&obj,str,xref);
 
84
    obj.free();
 
85
    str->putchar('\n');
 
86
#ifdef HAVE_UGOOSTRING_H
 
87
    delete[] key;
 
88
#endif
 
89
  }
 
90
  str->puts("/Resources ");
 
91
  resources->output(str);
 
92
  str->puts(" >>\n");
 
93
 
 
94
 
 
95
  /* output contents */
 
96
  P2PGfx output(xref,str,resources->getP2PFontResource(),resources);
 
97
  int start;
 
98
 
 
99
  str->puts("stream\n");
 
100
  start = str->getPosition();
 
101
  if (P2PDoc::options.contentsCompress) str->startDeflate();
 
102
 
 
103
  P2PMatrix identMatrix;
 
104
 
 
105
  output.outputContents(&orgForm,mappingTable,0,&identMatrix);
 
106
 
 
107
  if (P2PDoc::options.contentsCompress) str->endDeflate();
 
108
  len = str->getPosition()-start;
 
109
  str->puts("\nendstream\n");
 
110
 
 
111
  outputEnd(str);
 
112
 
 
113
  /* set length object value */
 
114
  lenobj.initInt(len);
 
115
  pobj->setObj(&lenobj);
 
116
  lenobj.free();
 
117
  pobj->output(str,xref);
 
118
}