~ubuntu-branches/ubuntu/jaunty/cups/jaunty

« back to all changes in this revision

Viewing changes to debian/local/filters/pdf-filters/pdftopdf/UGooString.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt, Till Kamppeter, Martin Pitt
  • Date: 2009-02-15 18:39:03 UTC
  • mfrom: (6.1.30 jaunty)
  • Revision ID: james.westby@ubuntu.com-20090215183903-i0nhvqyqj4vyn52a
Tags: 1.3.9-13
[ Till Kamppeter ]
* debian/local/filters/pdf-filters/filter/imagetopdf.c: Added support for
  the new "fit-to-page" option (new, more intuitive name for "fitplot").
* debian/filters/pstopdf: Only apply paper size if the "fitplot" or the
  "fit-to-page" option is set.
* debian/local/filters/cpdftocps: Only the last digit of the number of
  copies was used (LP: #309314).
* debian/local/filters/pdf-filters/pdftopdf/pdftopdf.cxx: Do not preceed the
  PDF output with a newline (LP: #303691). Only impose the page size from
  the PPD file to all pages if the "fitplot" or the "fit-to-page" option is 
  set. This prevented from automatic paper tray switching to the correct paper
  sizes when a multiple-page-size document is printed (partial fix for
  LP: #310575).
* debian/patches/pdftops-cups-1.4.dpatch: Updated from CUPS 1.4 SVN. Contains
  fixes for multiple-page-size document printing (partial fix for
  LP: #310575).
* debian/patches/pdftops-dont_fail_on_cancel.dpatch: Removed, should be
  fixed in the new upstream version of pdftops.

[ Martin Pitt ]
* debian/patches/pdftops-cups-1.4.dpatch: Add definition of
  HAVE_PDFTOPS and CUPS_PDFTOPS, so that the filter actually gets
  again built with pdftops support. (Fixes Till's change from above).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//========================================================================
 
2
//
 
3
// UGooString.cc
 
4
//
 
5
// Unicode string
 
6
//
 
7
// Copyright 2005 Albert Astals Cid <aacid@kde.org>
 
8
//
 
9
//========================================================================
 
10
 
 
11
#include <string.h>
 
12
 
 
13
#include "goo/gmem.h"
 
14
#include "goo/GooString.h"
 
15
#include "PDFDocEncoding.h"
 
16
#include "UGooString.h"
 
17
 
 
18
UGooString::UGooString(Unicode *u, int l)
 
19
{
 
20
  s = u;
 
21
  length = l;
 
22
}
 
23
 
 
24
UGooString::UGooString(GooString &str)
 
25
{
 
26
  if ((str.getChar(0) & 0xff) == 0xfe && (str.getChar(1) & 0xff) == 0xff)
 
27
  {
 
28
    length = (str.getLength() - 2) / 2;
 
29
    s = (Unicode *)gmallocn(length, sizeof(Unicode));
 
30
    for (int j = 0; j < length; ++j) {
 
31
      s[j] = ((str.getChar(2 + 2*j) & 0xff) << 8) | (str.getChar(3 + 2*j) & 0xff);
 
32
    }
 
33
  } else
 
34
    initChar(str);
 
35
}
 
36
 
 
37
UGooString::UGooString(const UGooString &str)
 
38
{
 
39
  length = str.length;
 
40
  s = (Unicode *)gmallocn(length, sizeof(Unicode));
 
41
  memcpy(s, str.s, length * sizeof(Unicode));
 
42
}
 
43
 
 
44
UGooString::UGooString(const char *str)
 
45
{
 
46
  GooString aux(str);
 
47
  initChar(aux);
 
48
}
 
49
 
 
50
void UGooString::initChar(GooString &str)
 
51
{
 
52
  length = str.getLength();
 
53
  s = (Unicode *)gmallocn(length, sizeof(Unicode));
 
54
  bool anyNonEncoded = false;
 
55
  for (int j = 0; j < length && !anyNonEncoded; ++j) {
 
56
    s[j] = pdfDocEncoding[str.getChar(j) & 0xff];
 
57
    if (!s[j]) anyNonEncoded = true;
 
58
  }
 
59
  if ( anyNonEncoded )
 
60
  {
 
61
    for (int j = 0; j < length; ++j) {
 
62
      s[j] = str.getChar(j);
 
63
    }
 
64
  }
 
65
}
 
66
 
 
67
UGooString::~UGooString()
 
68
{
 
69
  gfree(s);
 
70
}
 
71
 
 
72
int UGooString::cmp(UGooString *str) const
 
73
{
 
74
  int n1, n2, i, x;
 
75
  Unicode *p1, *p2;
 
76
 
 
77
  n1 = length;
 
78
  n2 = str->length;
 
79
  for (i = 0, p1 = s, p2 = str->s; i < n1 && i < n2; ++i, ++p1, ++p2) {
 
80
    x = *p1 - *p2;
 
81
    if (x != 0) {
 
82
      return x;
 
83
    }
 
84
  }
 
85
  return n1 - n2;
 
86
}
 
87
 
 
88
char *UGooString::getCString() const
 
89
{
 
90
  char *res = new char[length + 1];
 
91
  for (int i = 0; i < length; i++) res[i] = s[i];
 
92
  res[length] = '\0';
 
93
  return res;
 
94
}