]> www.fi.muni.cz Git - evince.git/blobdiff - pdf/xpdf/TextOutputDev.h
copy from ggv.
[evince.git] / pdf / xpdf / TextOutputDev.h
index a041e23b5df6d75bc8356f2b0702a68e5b73aee0..daab3c4ebb93a05f669694d9f17b7b1f02a5d40a 100644 (file)
@@ -2,7 +2,7 @@
 //
 // TextOutputDev.h
 //
 //
 // TextOutputDev.h
 //
-// Copyright 1997 Derek B. Noonburg
+// Copyright 1997-2002 Glyph & Cog, LLC
 //
 //========================================================================
 
 //
 //========================================================================
 
@@ -23,12 +23,7 @@ class GString;
 
 //------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------
 
-enum TextOutputCharSet {
-  textOutASCII7,
-  textOutLatin1,
-  textOutLatin2,
-  textOutLatin5
-};
+typedef void (*TextOutputFunc)(void *stream, char *text, int len);
 
 //------------------------------------------------------------------------
 // TextString
 
 //------------------------------------------------------------------------
 // TextString
@@ -38,31 +33,26 @@ class TextString {
 public:
 
   // Constructor.
 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,
 
   // Destructor.
   ~TextString();
 
   // Add a character to the string.
   void addChar(GfxState *state, double x, double y,
-              double dx, double dy,
-              Guchar c, TextOutputCharSet charSet);
-
-  // 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
 
 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
   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
   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;
 };
 
   friend class TextPage;
 };
@@ -75,22 +65,20 @@ class TextPage {
 public:
 
   // Constructor.
 public:
 
   // Constructor.
-  TextPage(TextOutputCharSet charSet, GBool rawOrder);
+  TextPage(GBool rawOrderA);
 
   // Destructor.
   ~TextPage();
 
 
   // Destructor.
   ~TextPage();
 
+  // Update the current font.
+  void updateFont(GfxState *state);
+
   // Begin a new string.
   // 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,
 
   // 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();
 
   // End the current string, sorting it into the list of strings.
   void endString();
@@ -103,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.
   // 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);
 
                 double *xMin, double *yMin,
                 double *xMax, double *yMax);
 
@@ -112,17 +101,17 @@ public:
                   double xMax, double yMax);
 
   // Dump contents of page to a file.
                   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:
 
 
   // Clear the page.
   void clear();
 
 private:
 
-  TextOutputCharSet charSet;   // character set
   GBool rawOrder;              // keep strings in content stream order
 
   TextString *curStr;          // currently active string
   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 *yxStrings;       // strings in y-major order
   TextString *xyStrings;       // strings in x-major order
@@ -139,12 +128,13 @@ class TextOutputDev: public OutputDev {
 public:
 
   // Open a text output file.  If <fileName> is NULL, no file is
 public:
 
   // Open a text output file.  If <fileName> is NULL, no file is
-  // written (this is useful, e.g., for searching text).  Text is
-  // converted to the character set specified by <charSet>.  This
-  // should be set to textOutASCII7 for Japanese (EUC-JP) text.  If
+  // written (this is useful, e.g., for searching text).  If
   // <rawOrder> is true, the text is kept in content stream order.
   // <rawOrder> is true, the text is kept in content stream order.
-  TextOutputDev(char *fileName, TextOutputCharSet charSet,
-               GBool rawOrder);
+  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();
 
   // Destructor.
   virtual ~TextOutputDev();
@@ -161,6 +151,13 @@ public:
   // Does this device use drawChar() or drawString()?
   virtual GBool useDrawChar() { 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.
   //----- initialization and control
 
   // Start a page.
@@ -176,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,
   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
 
 
   //----- special access
 
@@ -187,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.
   // 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:
 
                 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
   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?
 };
 
   GBool ok;                    // set up ok?
 };