~ubuntu-branches/ubuntu/vivid/emscripten/vivid

« back to all changes in this revision

Viewing changes to tests/poppler/poppler/ABWOutputDev.h

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-02 13:11:51 UTC
  • Revision ID: package-import@ubuntu.com-20130502131151-q8dvteqr1ef2x7xz
Tags: upstream-1.4.1~20130504~adb56cb
ImportĀ upstreamĀ versionĀ 1.4.1~20130504~adb56cb

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//========================================================================
 
2
//
 
3
// ABWOutputDev.h
 
4
//
 
5
// Copyright 2006-2007 Jauco Noordzij <jauco@jauco.nl>
 
6
// Copyright (C) 2009 Kovid Goyal <kovid@kovidgoyal.net>
 
7
//
 
8
//========================================================================
 
9
 
 
10
#ifndef ABWOUTPUTDEV_H
 
11
#define ABWOUTPUTDEV_H
 
12
 
 
13
#ifdef __GNUC__
 
14
#pragma interface
 
15
#endif
 
16
 
 
17
#include <stdio.h>
 
18
#include "goo/gtypes.h"
 
19
#include "goo/GooList.h"
 
20
#include "GfxFont.h"
 
21
#include "OutputDev.h"
 
22
#include "Catalog.h"
 
23
#include "UnicodeMap.h"
 
24
#include "PDFDoc.h"
 
25
 
 
26
#include <libxml/parser.h>
 
27
#include <libxml/tree.h>
 
28
#include <libxml/xpath.h>
 
29
#include <libxml/xpathInternals.h>
 
30
 
 
31
#ifdef _WIN32
 
32
#  define SLASH '\\'
 
33
#else
 
34
#  define SLASH '/'
 
35
#endif
 
36
 
 
37
#define xoutRound(x) ((int)(x + 0.5))
 
38
 
 
39
class GfxState;
 
40
class GooString;
 
41
 
 
42
//------------------------------------------------------------------------
 
43
// ABWOutputDev
 
44
//------------------------------------------------------------------------
 
45
 
 
46
class ABWOutputDev: public OutputDev {
 
47
public:
 
48
 
 
49
  // Open a text output file.  If <fileName> is NULL, no file is written
 
50
  // (this is useful, e.g., for searching text).  If <useASCII7> is true,
 
51
  // text is converted to 7-bit ASCII; otherwise, text is converted to
 
52
  // 8-bit ISO Latin-1.  <useASCII7> should also be set for Japanese
 
53
  // (EUC-JP) text.  If <rawOrder> is true, the text is kept in content
 
54
  // stream order.
 
55
  ABWOutputDev(xmlDocPtr ext_doc);
 
56
 
 
57
  // Destructor.
 
58
  virtual ~ABWOutputDev();
 
59
 
 
60
  // Check if file was successfully created.
 
61
  virtual GBool isOk() { return gTrue; }
 
62
 
 
63
  //---- get info about output device
 
64
 
 
65
  // Does this device use upside-down coordinates?
 
66
  // (Upside-down means (0,0) is the top left corner of the page.)
 
67
  virtual GBool upsideDown() { return gTrue; }
 
68
 
 
69
  // Does this device use drawChar() or drawString()?
 
70
  virtual GBool useDrawChar() { return gTrue; }
 
71
 
 
72
  // Does this device use beginType3Char/endType3Char?  Otherwise,
 
73
  // text in Type 3 fonts will be drawn with drawChar/drawString.
 
74
  virtual GBool interpretType3Chars() { return gFalse; }
 
75
 
 
76
  // Does this device need non-text content?
 
77
  virtual GBool needNonText() { return gFalse; }
 
78
 
 
79
  //----- initialization and control
 
80
 
 
81
  // Start a page.
 
82
  virtual void startPage(int pageNum, GfxState *state);
 
83
 
 
84
  // End a page.
 
85
  virtual void endPage();
 
86
 
 
87
  //----- update text state
 
88
  virtual void updateFont(GfxState *state);
 
89
 
 
90
  //----- text drawing
 
91
  //new feature    
 
92
  virtual int DevType() {return 1234;}
 
93
 
 
94
  int getPageWidth() { return maxPageWidth; }
 
95
  int getPageHeight() { return maxPageHeight; }
 
96
  float getBiggestSeperator(xmlNodePtr N_set, unsigned int direction, float * C1, float * C2);
 
97
  void recursiveXYC(xmlNodePtr nodeset);
 
98
  void splitNodes(float splitValue, unsigned int direction, xmlNodePtr N_parent, double extravalue);
 
99
  virtual void beginString(GfxState *state, GooString *s);
 
100
  virtual void endString(GfxState *state);
 
101
  virtual void drawChar(GfxState *state, double x, double y,
 
102
                        double dx, double dy,
 
103
                        double originX, double originY,
 
104
                        CharCode code, int nBytes, Unicode *u, int uLen);
 
105
  void beginWord(GfxState *state, double x, double y);
 
106
  void endWord();
 
107
  void beginTextBlock(GfxState *state, double x, double y);
 
108
  void endTextBlock();
 
109
  void interpretXYTree();
 
110
  void ATP_recursive(xmlNodePtr N_cur);
 
111
  void cleanUpNode(xmlNodePtr N_parent, bool aggregateInfo);
 
112
  void transformPage(xmlNodePtr N_parent);
 
113
  void generateParagraphs();
 
114
  void addAlignment(xmlNodePtr N_parent);
 
115
  void setPDFDoc(PDFDoc *priv_pdfdoc);
 
116
  void createABW();
 
117
 
 
118
private:
 
119
  int maxPageWidth;
 
120
  int maxPageHeight;
 
121
  int G_pageNum;
 
122
  int Style, maxStyle;
 
123
  //A lot of values are nice to have around. I think that declaring some 
 
124
  //global variables that contain these values is faster & easier than reading
 
125
  //them from the xml tree every time.
 
126
  double height;
 
127
  double wordSpace, charSpace;
 
128
  double X1,X2,Y1,Y2,horDist, verDist, curDx, curDy;
 
129
  bool mightBreak;
 
130
  xmlDocPtr doc;
 
131
  /* node pointers */
 
132
  xmlNodePtr N_root, N_content, N_page, N_style, N_text, N_styleset, N_Block, N_word, N_column, N_colset;
 
133
  xmlNodePtr outputDoc;
 
134
  xmlXPathContextPtr xpathCtx;
 
135
  static const unsigned int HORIZONTAL = 0;
 
136
  static const unsigned int VERTICAL = 1;
 
137
  UnicodeMap *uMap;
 
138
  PDFDoc *pdfdoc;
 
139
  int xmlLsCountNode(xmlNodePtr node);
 
140
};
 
141
#endif