X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=pdf%2Fxpdf%2FTextOutputDev.h;h=daab3c4ebb93a05f669694d9f17b7b1f02a5d40a;hb=f08fe47c41d7b8393c93c14395ef25a0acb57fef;hp=a041e23b5df6d75bc8356f2b0702a68e5b73aee0;hpb=7aac8dc8533347e21311b15186e0af82f1b22fd6;p=evince.git diff --git a/pdf/xpdf/TextOutputDev.h b/pdf/xpdf/TextOutputDev.h index a041e23b..daab3c4e 100644 --- a/pdf/xpdf/TextOutputDev.h +++ b/pdf/xpdf/TextOutputDev.h @@ -2,7 +2,7 @@ // // 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 @@ -38,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, 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 - 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; }; @@ -75,22 +65,20 @@ class TextPage { public: // Constructor. - TextPage(TextOutputCharSet charSet, 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(); @@ -103,7 +91,8 @@ public: // stops looking at bottom of page; otherwise stops looking at // ,. 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); @@ -112,17 +101,17 @@ 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: - TextOutputCharSet charSet; // character set 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 @@ -139,12 +128,13 @@ class TextOutputDev: public OutputDev { public: // Open a text output file. If is NULL, no file is - // written (this is useful, e.g., for searching text). Text is - // converted to the character set specified by . This - // should be set to textOutASCII7 for Japanese (EUC-JP) text. If + // written (this is useful, e.g., for searching text). If // 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 + // is true, the text is kept in content stream order. + TextOutputDev(TextOutputFunc func, void *stream, GBool rawOrderA); // Destructor. virtual ~TextOutputDev(); @@ -161,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. @@ -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, - 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 @@ -187,17 +184,19 @@ public: // stops looking at bottom of page; otherwise stops looking at // ,. 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? };