~ubuntu-branches/ubuntu/dapper/poppler/dapper-security

« back to all changes in this revision

Viewing changes to poppler/UGooString.cc

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2006-03-06 18:42:44 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060306184244-oomqyiqr7cgncp2c
Tags: 0.5.1-0ubuntu1
* New upstream version:
  - Support for embedded files.
  - Handle 0-width lines correctly.
  - Avoid external file use when opening fonts.
  - Only use vector fonts returned from fontconfig (#5758).
  - Fix scaled 1x1 pixmaps use for drawing lines (#3387).
  - drawSoftMaskedImage support in cairo backend.
  - Misc bug fixes: #5922, #5946, #5749, #5952, #4030, #5420.
* debian/control.in, debian/libpoppler0c2.dirs, 
  debian/libpoppler0c2-glib.dirs, debian/libpoppler0c2-glib.install,
  debian/libpoppler0c2.install, debian/libpoppler0c2-qt.dirs,
  debian/libpoppler0c2-qt.install, debian/rules:
  - updated for the soname change
* debian/patches/000_splash_build_fix.patch:
  - fix build when using splash
* debian/patches/001_fixes_for_fonts_selection.patch:
  - fix with the new version

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
  for (int j = 0; j < length; ++j) {
 
55
    s[j] = pdfDocEncoding[str.getChar(j) & 0xff];
 
56
  }
 
57
}
 
58
 
 
59
UGooString::~UGooString()
 
60
{
 
61
  gfree(s);
 
62
}
 
63
 
 
64
int UGooString::cmp(UGooString *str) const
 
65
{
 
66
  int n1, n2, i, x;
 
67
  Unicode *p1, *p2;
 
68
 
 
69
  n1 = length;
 
70
  n2 = str->length;
 
71
  for (i = 0, p1 = s, p2 = str->s; i < n1 && i < n2; ++i, ++p1, ++p2) {
 
72
    x = *p1 - *p2;
 
73
    if (x != 0) {
 
74
      return x;
 
75
    }
 
76
  }
 
77
  return n1 - n2;
 
78
}
 
79
 
 
80
char *UGooString::getCString() const
 
81
{
 
82
  char *res = new char[length + 1];
 
83
  for (int i = 0; i < length; i++) res[i] = s[i];
 
84
  res[length] = '\0';
 
85
  return res;
 
86
}