]> www.fi.muni.cz Git - evince.git/blobdiff - pdf/xpdf/TextOutputDev.h
distribute gpdf-window-ui.xml
[evince.git] / pdf / xpdf / TextOutputDev.h
index f13a23a0503d106c01d36ffc7086e2e807e59d8c..daab3c4ebb93a05f669694d9f17b7b1f02a5d40a 100644 (file)
@@ -2,7 +2,7 @@
 //
 // TextOutputDev.h
 //
-// Copyright 1997 Derek B. Noonburg
+// Copyright 1997-2002 Glyph & Cog, LLC
 //
 //========================================================================
 
 class GfxState;
 class GString;
 
+//------------------------------------------------------------------------
+
+typedef void (*TextOutputFunc)(void *stream, char *text, int len);
+
 //------------------------------------------------------------------------
 // TextString
 //------------------------------------------------------------------------
@@ -29,31 +33,26 @@ class TextString {
 public:
 
   // Constructor.
-  TextString(GfxState *state, GBool hexCodes1);
+  TextString(GfxState *state, double fontSize);
 
   // Destructor.
   ~TextString();
 
   // Add a character to the string.
   void addChar(GfxState *state, double x, double y,
-              double dx, double dy,
-              Guchar c, GBool useASCII7);
-
-  // Add a 16-bit character to the string.
-  void addChar16(GfxState *state, double x, double y,
-                double dx, double dy,
-                int c, GfxFontCharSet16 charSet);
+              double dx, double dy, Unicode u);
 
 private:
 
   double xMin, xMax;           // bounding box x coordinates
   double yMin, yMax;           // bounding box y coordinates
   int col;                     // starting column
-  GString *text;               // the text
+  Unicode *text;               // the text
   double *xRight;              // right-hand x coord of each char
+  int len;                     // length of text and xRight
+  int size;                    // size of text and xRight arrays
   TextString *yxNext;          // next string in y-major order
   TextString *xyNext;          // next string in x-major order
-  GBool hexCodes;              // subsetted font with hex char codes
 
   friend class TextPage;
 };
@@ -66,22 +65,20 @@ class TextPage {
 public:
 
   // Constructor.
-  TextPage(GBool useASCII7, GBool rawOrder);
+  TextPage(GBool rawOrderA);
 
   // Destructor.
   ~TextPage();
 
+  // Update the current font.
+  void updateFont(GfxState *state);
+
   // Begin a new string.
-  void beginString(GfxState *state, GString *s, GBool hex1);
+  void beginString(GfxState *state);
 
   // Add a character to the current string.
   void addChar(GfxState *state, double x, double y,
-              double dx, double dy, Guchar c);
-
-  // Add a 16-bit character to the current string.
-  void addChar16(GfxState *state, double x, double y,
-                double dx, double dy, int c,
-                GfxFontCharSet16 charSet);
+              double dx, double dy, Unicode *u, int uLen);
 
   // End the current string, sorting it into the list of strings.
   void endString();
@@ -94,7 +91,8 @@ public:
   // stops looking at bottom of page; otherwise stops looking at
   // <xMax>,<yMax>.  If found, sets the text bounding rectange and
   // returns true; otherwise returns false.
-  GBool findText(char *s, GBool top, GBool bottom,
+  GBool findText(Unicode *s, int len,
+                GBool top, GBool bottom,
                 double *xMin, double *yMin,
                 double *xMax, double *yMax);
 
@@ -103,21 +101,23 @@ public:
                   double xMax, double yMax);
 
   // Dump contents of page to a file.
-  void dump(FILE *f);
+  void dump(void *outputStream, TextOutputFunc outputFunc);
 
   // Clear the page.
   void clear();
 
 private:
 
-  GBool useASCII7;             // use 7-bit ASCII?
   GBool rawOrder;              // keep strings in content stream order
 
   TextString *curStr;          // currently active string
+  double fontSize;             // current font size
 
   TextString *yxStrings;       // strings in y-major order
   TextString *xyStrings;       // strings in x-major order
   TextString *yxCur1, *yxCur2; // cursors for yxStrings list
+
+  int nest;                    // current nesting level (for Type 3 fonts)
 };
 
 //------------------------------------------------------------------------
@@ -127,13 +127,14 @@ private:
 class TextOutputDev: 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.
-  TextOutputDev(char *fileName, GBool useASCII7, GBool rawOrder);
+  // Open a text output file.  If <fileName> is NULL, no file is
+  // written (this is useful, e.g., for searching text).  If
+  // <rawOrder> is true, the text is kept in content stream order.
+  TextOutputDev(char *fileName, GBool rawOrderA, GBool append);
+
+  // Create a TextOutputDev which will write to a generic stream.  If
+  // <rawOrder> is true, the text is kept in content stream order.
+  TextOutputDev(TextOutputFunc func, void *stream, GBool rawOrderA);
 
   // Destructor.
   virtual ~TextOutputDev();
@@ -150,6 +151,13 @@ public:
   // 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.
@@ -165,9 +173,9 @@ public:
   virtual void beginString(GfxState *state, GString *s);
   virtual void endString(GfxState *state);
   virtual void drawChar(GfxState *state, double x, double y,
-                       double dx, double dy, Guchar c);
-  virtual void drawChar16(GfxState *state, double x, double y,
-                         double dx, double dy, int c);
+                       double dx, double dy,
+                       double originX, double originY,
+                       CharCode c, Unicode *u, int uLen);
 
   //----- special access
 
@@ -176,17 +184,19 @@ public:
   // stops looking at bottom of page; otherwise stops looking at
   // <xMax>,<yMax>.  If found, sets the text bounding rectange and
   // returns true; otherwise returns false.
-  GBool findText(char *s, GBool top, GBool bottom,
+  GBool findText(Unicode *s, int len,
+                GBool top, GBool bottom,
                 double *xMin, double *yMin,
                 double *xMax, double *yMax);
 
 private:
 
-  FILE *f;                     // text file
-  GBool needClose;             // need to close the file?
+  TextOutputFunc outputFunc;   // output function
+  void *outputStream;          // output stream
+  GBool needClose;             // need to close the output file?
+                               //   (only if outputStream is a FILE*)
   TextPage *text;              // text for the current page
   GBool rawOrder;              // keep text in content stream order
-  GBool hexCodes;              // subsetted font with hex char codes
   GBool ok;                    // set up ok?
 };