[poppler] poppler/poppler: ABWOutputDev.cc, NONE, 1.1 ABWOutputDev.h, NONE, 1.1 Makefile.am, 1.29, 1.30

Jeff Muizelaar jrmuizel at kemper.freedesktop.org
Tue Apr 3 19:42:31 PDT 2007


Update of /cvs/poppler/poppler/poppler
In directory kemper:/tmp/cvs-serv6395/poppler

Modified Files:
	Makefile.am 
Added Files:
	ABWOutputDev.cc ABWOutputDev.h 
Log Message:
2007-04-03  Jeff Muizelaar  <jeff at infidigm.net>

	* configure.ac:
	* poppler/ABWOutputDev.cc:
	* poppler/ABWOutputDev.h:
	* poppler/Makefile.am:
	* utils/Makefile.am:
	* utils/pdftoabw.cc: Add AbiWord output device and pdftoabw program.
	Patch by Jauco Noordzij. Autotools stuff by Dominic Lachowicz.


--- NEW FILE: ABWOutputDev.cc ---
//========================================================================
//
// ABWOutputDev.cc
//
// Jauco Noordzij
//
// Based somewhat on HtmlOutputDev.cc
//
//========================================================================

#ifdef __GNUC__
#pragma implementation
#endif

#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stddef.h>
[...1247 lines suppressed...]
    //fprintf(stderr,"Found a column\n");
    for (N_cur = N_parent->children; N_cur; N_cur = N_cur->next){
      transformPage(N_cur);
    }
    xmlNewChild(N_text, NULL, BAD_CAST "cbr", NULL);
  }
  if (xmlStrcasecmp(N_parent->name,BAD_CAST "colset") == 0){
    //fprintf(stderr,"Found a colset\n");
    //create new section columns: count childNodes of N_cur
    //recurse through chunks and create textNodes
    N_Block = xmlNewChild(N_root, NULL, BAD_CAST "section", NULL);
    sprintf(buf,"columns:%d",xmlLsCountNode(N_parent));
    xmlNewProp(N_Block, BAD_CAST "props", BAD_CAST buf);
    for (N_cur = N_parent->children; N_cur; N_cur = N_cur->next){
      transformPage(N_cur);
    }
    N_Block = xmlNewChild(N_root, NULL, BAD_CAST "section", NULL);
  }
  //fprintf(stderr,"at the end\n");
}

--- NEW FILE: ABWOutputDev.h ---
//========================================================================
//
// ABWOutputDev.h
//
// Copyright 2006 Jauco Noordzij
//
//========================================================================

#ifndef ABWOUTPUTDEV_H
#define ABWOUTPUTDEV_H

#ifdef __GNUC__
#pragma interface
#endif

#include <stdio.h>
#include "goo/gtypes.h"
#include "goo/GooList.h"
#include "GfxFont.h"
#include "OutputDev.h"
#include "Link.h"
#include "Catalog.h"
#include "UnicodeMap.h"
#include "PDFDoc.h"

#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>

#ifdef WIN32
#  define SLASH '\\'
#else
#  define SLASH '/'
#endif

#define xoutRound(x) ((int)(x + 0.5))

class GfxState;
class GooString;

//------------------------------------------------------------------------
// ABWOutputDev
//------------------------------------------------------------------------

class ABWOutputDev: public OutputDev {
public:

  // Open a text output file.  If <fileName> is NULL, no file is written
  // (this is useful, e.g., for searching text).  If <useASCII7> is true,
  // text is converted to 7-bit ASCII; otherwise, text is converted to
  // 8-bit ISO Latin-1.  <useASCII7> should also be set for Japanese
  // (EUC-JP) text.  If <rawOrder> is true, the text is kept in content
  // stream order.
  ABWOutputDev(xmlDocPtr ext_doc);

  // Destructor.
  virtual ~ABWOutputDev();

  // Check if file was successfully created.
  virtual GBool isOk() { return gTrue; }

  //---- get info about output device

  // Does this device use upside-down coordinates?
  // (Upside-down means (0,0) is the top left corner of the page.)
  virtual GBool upsideDown() { return gTrue; }

  // Does this device use drawChar() or drawString()?
  virtual GBool useDrawChar() { return gTrue; }

  // Does this device use beginType3Char/endType3Char?  Otherwise,
  // text in Type 3 fonts will be drawn with drawChar/drawString.
  virtual GBool interpretType3Chars() { return gFalse; }

  // Does this device need non-text content?
  virtual GBool needNonText() { return gFalse; }

  //----- initialization and control

  // Start a page.
  virtual void startPage(int pageNum, GfxState *state);

  // End a page.
  virtual void endPage();

  //----- update text state
  virtual void updateFont(GfxState *state);

  //----- text drawing
  //new feature    
  virtual int DevType() {return 1234;}

  int getPageWidth() { return maxPageWidth; }
  int getPageHeight() { return maxPageHeight; }
  float getBiggestSeperator(xmlNodePtr N_set, unsigned int direction, float * C1, float * C2);
  void recursiveXYC(xmlNodePtr nodeset);
  void splitNodes(float splitValue, unsigned int direction, xmlNodePtr N_parent, double extravalue);
  virtual void beginString(GfxState *state, GooString *s);
  virtual void endString(GfxState *state);
  virtual void drawChar(GfxState *state, double x, double y,
			double dx, double dy,
			double originX, double originY,
			CharCode code, int nBytes, Unicode *u, int uLen);
  void beginWord(GfxState *state, double x, double y);
  void endWord();
  void beginTextBlock(GfxState *state, double x, double y);
  void endTextBlock();
  void interpretXYTree();
  void ATP_recursive(xmlNodePtr N_cur);
  void cleanUpNode(xmlNodePtr N_parent, bool aggregateInfo);
  void transformPage(xmlNodePtr N_parent);
  void generateParagraphs();
  void addAlignment(xmlNodePtr N_parent);
  void setPDFDoc(PDFDoc *priv_pdfdoc);
  void createABW();

private:
  int maxPageWidth;
  int maxPageHeight;
  int G_pageNum;
  int Style, maxStyle;
  //A lot of values are nice to have around. I think that declaring some 
  //global variables that contain these values is faster & easier than reading
  //them from the xml tree every time.
  double height;
  double wordSpace, charSpace;
  double X1,X2,Y1,Y2,horDist, verDist, curDx, curDy;
  bool mightBreak;
  xmlDocPtr doc;
  /* node pointers */
  xmlNodePtr N_root, N_content, N_page, N_style, N_text, N_styleset, N_Block, N_word, N_column, N_colset;
  xmlNodePtr outputDoc;
  xmlXPathContextPtr xpathCtx;
  static const unsigned int HORIZONTAL = 0;
  static const unsigned int VERTICAL = 1;
  UnicodeMap *uMap;
  PDFDoc *pdfdoc;
};
#endif

Index: Makefile.am
===================================================================
RCS file: /cvs/poppler/poppler/poppler/Makefile.am,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- Makefile.am	4 Mar 2007 07:30:31 -0000	1.29
+++ Makefile.am	4 Apr 2007 02:42:29 -0000	1.30
@@ -73,12 +73,27 @@
 
 endif
 
+if BUILD_ABIWORD_OUTPUT
+
+abiword_sources =				\
+	ABWOutputDev.h				\
+	ABWOutputDev.cc
+
+abiword_includes =				\
+	$(ABIWORD_CFLAGS)
+
+abiword_libs =					\
+	$(ABIWORD_LIBS)
+
+endif
+
 INCLUDES =					\
 	-I$(top_srcdir)				\
 	-I$(top_srcdir)/goo			\
 	$(splash_includes)			\
 	$(cairo_includes)			\
 	$(arthur_includes)			\
+	$(abiword_includes)			\
 	$(FREETYPE_CFLAGS)			\
 	$(FONTCONFIG_CFLAGS)
 
@@ -94,6 +109,7 @@
 	$(cairo_libs)				\
 	$(libjpeg_libs)				\
 	$(zlib_libs)				\
+	$(abiword_libs)				\
 	$(FREETYPE_LIBS)			\
 	$(FONTCONFIG_LIBS)
 
@@ -169,6 +185,7 @@
 	$(arthur_sources)	\
 	$(libjpeg_sources)	\
 	$(zlib_sources)		\
+	$(abiword_sources)	\
 	Annot.cc		\
 	Array.cc 		\
 	BuiltinFont.cc		\



More information about the poppler mailing list