1
//========================================================================
5
// Copyright 2006-2007 Jauco Noordzij <jauco@jauco.nl>
6
// Copyright (C) 2009 Kovid Goyal <kovid@kovidgoyal.net>
8
//========================================================================
10
#ifndef ABWOUTPUTDEV_H
11
#define ABWOUTPUTDEV_H
18
#include "goo/gtypes.h"
19
#include "goo/GooList.h"
21
#include "OutputDev.h"
23
#include "UnicodeMap.h"
26
#include <libxml/parser.h>
27
#include <libxml/tree.h>
28
#include <libxml/xpath.h>
29
#include <libxml/xpathInternals.h>
37
#define xoutRound(x) ((int)(x + 0.5))
42
//------------------------------------------------------------------------
44
//------------------------------------------------------------------------
46
class ABWOutputDev: public OutputDev {
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
55
ABWOutputDev(xmlDocPtr ext_doc);
58
virtual ~ABWOutputDev();
60
// Check if file was successfully created.
61
virtual GBool isOk() { return gTrue; }
63
//---- get info about output device
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; }
69
// Does this device use drawChar() or drawString()?
70
virtual GBool useDrawChar() { return gTrue; }
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; }
76
// Does this device need non-text content?
77
virtual GBool needNonText() { return gFalse; }
79
//----- initialization and control
82
virtual void startPage(int pageNum, GfxState *state);
85
virtual void endPage();
87
//----- update text state
88
virtual void updateFont(GfxState *state);
92
virtual int DevType() {return 1234;}
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);
107
void beginTextBlock(GfxState *state, double x, double y);
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);
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.
127
double wordSpace, charSpace;
128
double X1,X2,Y1,Y2,horDist, verDist, curDx, curDy;
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;
139
int xmlLsCountNode(xmlNodePtr node);