summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2011-12-14 22:50:39 +0100
committerAlbert Astals Cid <aacid@kde.org>2011-12-14 22:50:39 +0100
commit7bedab6d8f3800540606eb2522e4aadab332a17a (patch)
tree927a0d4a31c8321591571efb5030281afb44a8b1
parent93f14db821bcc31076c58dee05591fa8d6fc1e9c (diff)
some xpdf303 stuff merged [c5ce129]
-rw-r--r--ALL_DIFF402
1 files changed, 0 insertions, 402 deletions
diff --git a/ALL_DIFF b/ALL_DIFF
index 05161a0..c2f2f8f 100644
--- a/ALL_DIFF
+++ b/ALL_DIFF
@@ -18608,288 +18608,6 @@ diff -ru xpdf-3.02/xpdf/SplashOutputDev.h xpdf-3.03/xpdf/SplashOutputDev.h
diff -ru xpdf-3.02/xpdf/TextOutputDev.cc xpdf-3.03/xpdf/TextOutputDev.cc
--- xpdf-3.02/xpdf/TextOutputDev.cc 2007-02-27 23:05:52.000000000 +0100
+++ xpdf-3.03/xpdf/TextOutputDev.cc 2011-08-15 23:08:53.000000000 +0200
-@@ -196,73 +195,102 @@
- //------------------------------------------------------------------------
-
- TextWord::TextWord(GfxState *state, int rotA, double x0, double y0,
-- int charPosA, TextFontInfo *fontA, double fontSizeA) {
-+ TextFontInfo *fontA, double fontSizeA) {
- GfxFont *gfxFont;
- double x, y, ascent, descent;
-+ int wMode;
-
- rot = rotA;
-- charPos = charPosA;
-- charLen = 0;
- font = fontA;
- fontSize = fontSizeA;
- state->transform(x0, y0, &x, &y);
- if ((gfxFont = font->gfxFont)) {
- ascent = gfxFont->getAscent() * fontSize;
- descent = gfxFont->getDescent() * fontSize;
-+ wMode = gfxFont->getWMode();
- } else {
- // this means that the PDF file draws text without a current font,
- // which should never happen
- ascent = 0.95 * fontSize;
- descent = -0.35 * fontSize;
-+ wMode = 0;
- }
-- switch (rot) {
-- case 0:
-- yMin = y - ascent;
-- yMax = y - descent;
-- if (yMin == yMax) {
-- // this is a sanity check for a case that shouldn't happen -- but
-- // if it does happen, we want to avoid dividing by zero later
-- yMin = y;
-- yMax = y + 1;
-- }
-- base = y;
-- break;
-- case 1:
-- xMin = x + descent;
-- xMax = x + ascent;
-- if (xMin == xMax) {
-- // this is a sanity check for a case that shouldn't happen -- but
-- // if it does happen, we want to avoid dividing by zero later
-+ if (wMode) { // vertical writing mode
-+ // NB: the rotation value has been incremented by 1 (in
-+ // TextPage::beginWord()) for vertical writing mode
-+ switch (rot) {
-+ case 0:
-+ yMin = y - fontSize;
-+ yMax = y;
-+ base = y;
-+ break;
-+ case 1:
- xMin = x;
-- xMax = x + 1;
-- }
-- base = x;
-- break;
-- case 2:
-- yMin = y + descent;
-- yMax = y + ascent;
-- if (yMin == yMax) {
-- // this is a sanity check for a case that shouldn't happen -- but
-- // if it does happen, we want to avoid dividing by zero later
-+ xMax = x + fontSize;
-+ base = x;
-+ break;
-+ case 2:
- yMin = y;
-- yMax = y + 1;
-+ yMax = y + fontSize;
-+ base = y;
-+ break;
-+ case 3:
-+ xMin = x - fontSize;
-+ xMax = x;
-+ base = x;
-+ break;
- }
-- base = y;
-- break;
-- case 3:
-- xMin = x - ascent;
-- xMax = x - descent;
-- if (xMin == xMax) {
-- // this is a sanity check for a case that shouldn't happen -- but
-- // if it does happen, we want to avoid dividing by zero later
-- xMin = x;
-- xMax = x + 1;
-+ } else { // horizontal writing mode
-+ switch (rot) {
-+ case 0:
-+ yMin = y - ascent;
-+ yMax = y - descent;
-+ if (yMin == yMax) {
-+ // this is a sanity check for a case that shouldn't happen -- but
-+ // if it does happen, we want to avoid dividing by zero later
-+ yMin = y;
-+ yMax = y + 1;
-+ }
-+ base = y;
-+ break;
-+ case 1:
-+ xMin = x + descent;
-+ xMax = x + ascent;
-+ if (xMin == xMax) {
-+ // this is a sanity check for a case that shouldn't happen -- but
-+ // if it does happen, we want to avoid dividing by zero later
-+ xMin = x;
-+ xMax = x + 1;
-+ }
-+ base = x;
-+ break;
-+ case 2:
-+ yMin = y + descent;
-+ yMax = y + ascent;
-+ if (yMin == yMax) {
-+ // this is a sanity check for a case that shouldn't happen -- but
-+ // if it does happen, we want to avoid dividing by zero later
-+ yMin = y;
-+ yMax = y + 1;
-+ }
-+ base = y;
-+ break;
-+ case 3:
-+ xMin = x - ascent;
-+ xMax = x - descent;
-+ if (xMin == xMax) {
-+ // this is a sanity check for a case that shouldn't happen -- but
-+ // if it does happen, we want to avoid dividing by zero later
-+ xMin = x;
-+ xMax = x + 1;
-+ }
-+ base = x;
-+ break;
- }
-- base = x;
-- break;
- }
- text = NULL;
- edge = NULL;
-+ charPos = NULL;
- len = size = 0;
- spaceAfter = gFalse;
- next = NULL;
-@@ -287,45 +315,88 @@
- TextWord::~TextWord() {
- gfree(text);
- gfree(edge);
-+ gfree(charPos);
- }
-
- void TextWord::addChar(GfxState *state, double x, double y,
-- double dx, double dy, Unicode u) {
-+ double dx, double dy, int charPosA, int charLen,
-+ Unicode u) {
-+ int wMode;
-+
- if (len == size) {
- size += 16;
- text = (Unicode *)greallocn(text, size, sizeof(Unicode));
- edge = (double *)greallocn(edge, size + 1, sizeof(double));
-+ charPos = (int *)greallocn(charPos, size + 1, sizeof(int));
- }
- text[len] = u;
-- switch (rot) {
-- case 0:
-- if (len == 0) {
-- xMin = x;
-- }
-- edge[len] = x;
-- xMax = edge[len+1] = x + dx;
-- break;
-- case 1:
-- if (len == 0) {
-- yMin = y;
-- }
-- edge[len] = y;
-- yMax = edge[len+1] = y + dy;
-- break;
-- case 2:
-- if (len == 0) {
-- xMax = x;
-+ charPos[len] = charPosA;
-+ charPos[len + 1] = charPosA + charLen;
-+ wMode = font->gfxFont ? font->gfxFont->getWMode() : 0;
-+ if (wMode) { // vertical writing mode
-+ // NB: the rotation value has been incremented by 1 (in
-+ // TextPage::beginWord()) for vertical writing mode
-+ switch (rot) {
-+ case 0:
-+ if (len == 0) {
-+ xMin = x - fontSize;
-+ }
-+ edge[len] = x - fontSize;
-+ xMax = edge[len+1] = x;
-+ break;
-+ case 1:
-+ if (len == 0) {
-+ yMin = y - fontSize;
-+ }
-+ edge[len] = y - fontSize;
-+ yMax = edge[len+1] = y;
-+ break;
-+ case 2:
-+ if (len == 0) {
-+ xMax = x + fontSize;
-+ }
-+ edge[len] = x + fontSize;
-+ xMin = edge[len+1] = x;
-+ break;
-+ case 3:
-+ if (len == 0) {
-+ yMax = y + fontSize;
-+ }
-+ edge[len] = y + fontSize;
-+ yMin = edge[len+1] = y;
-+ break;
- }
-- edge[len] = x;
-- xMin = edge[len+1] = x + dx;
-- break;
-- case 3:
-- if (len == 0) {
-- yMax = y;
-+ } else { // horizontal writing mode
-+ switch (rot) {
-+ case 0:
-+ if (len == 0) {
-+ xMin = x;
-+ }
-+ edge[len] = x;
-+ xMax = edge[len+1] = x + dx;
-+ break;
-+ case 1:
-+ if (len == 0) {
-+ yMin = y;
-+ }
-+ edge[len] = y;
-+ yMax = edge[len+1] = y + dy;
-+ break;
-+ case 2:
-+ if (len == 0) {
-+ xMax = x;
-+ }
-+ edge[len] = x;
-+ xMin = edge[len+1] = x + dx;
-+ break;
-+ case 3:
-+ if (len == 0) {
-+ yMax = y;
-+ }
-+ edge[len] = y;
-+ yMin = edge[len+1] = y + dy;
-+ break;
- }
-- edge[len] = y;
-- yMin = edge[len+1] = y + dy;
-- break;
- }
- ++len;
- }
-@@ -349,14 +420,16 @@
- size = len + word->len;
- text = (Unicode *)greallocn(text, size, sizeof(Unicode));
- edge = (double *)greallocn(edge, size + 1, sizeof(double));
-+ charPos = (int *)greallocn(charPos, size + 1, sizeof(int));
- }
- for (i = 0; i < word->len; ++i) {
- text[len + i] = word->text[i];
- edge[len + i] = word->edge[i];
-+ charPos[len + i] = word->charPos[i];
- }
- edge[len + word->len] = word->edge[word->len];
-+ charPos[len + word->len] = word->charPos[word->len];
- len += word->len;
-- charLen += word->charLen;
- }
-
- inline int TextWord::primaryCmp(TextWord *word) {
@@ -545,7 +618,7 @@
// insert the new word
@@ -18899,15 +18617,6 @@ diff -ru xpdf-3.02/xpdf/TextOutputDev.cc xpdf-3.03/xpdf/TextOutputDev.cc
w0 = cursor;
w1 = cursor->next;
} else {
-@@ -741,7 +814,7 @@
- word0->underlined == word1->underlined &&
- fabs(word0->fontSize - word1->fontSize) <
- maxWordFontSizeDelta * words->fontSize &&
-- word1->charPos == word0->charPos + word0->charLen) {
-+ word1->charPos[0] == word0->charPos[word0->len]) {
- word0->merge(word1);
- word0->next = word1->next;
- delete word1;
@@ -928,7 +1001,7 @@
xMax = blk->xMin + d1 * (blk->xMax - blk->xMin);
yMin = blk->yMin + d2 * (blk->yMax - blk->yMin);
@@ -19170,37 +18879,6 @@ diff -ru xpdf-3.02/xpdf/TextOutputDev.cc xpdf-3.03/xpdf/TextOutputDev.cc
}
void TextPage::updateFont(GfxState *state) {
-@@ -1931,12 +2046,18 @@
- m[3] = m2[3];
- }
- if (fabs(m[0] * m[3]) > fabs(m[1] * m[2])) {
-- rot = (m[3] < 0) ? 0 : 2;
-+ rot = (m[0] > 0 || m[3] < 0) ? 0 : 2;
- } else {
- rot = (m[2] > 0) ? 1 : 3;
- }
-
-- curWord = new TextWord(state, rot, x0, y0, charPos, curFont, curFontSize);
-+ // for vertical writing mode, the lines are effectively rotated 90
-+ // degrees
-+ if (state->getFont()->getWMode()) {
-+ rot = (rot + 1) & 3;
-+ }
-+
-+ curWord = new TextWord(state, rot, x0, y0, curFont, curFontSize);
- }
-
- void TextPage::addChar(GfxState *state, double x, double y,
-@@ -1977,9 +2111,6 @@
-
- // break words at space character
- if (uLen == 1 && u[0] == (Unicode)0x20) {
-- if (curWord) {
-- ++curWord->charLen;
-- }
- charPos += nBytes;
- endWord();
- return;
@@ -1993,7 +2124,7 @@
// (2) this character overlaps the previous one (duplicated text), or
// (3) the previous character was an overlap (we want each duplicated
@@ -19219,17 +18897,8 @@ diff -ru xpdf-3.02/xpdf/TextOutputDev.cc xpdf-3.03/xpdf/TextOutputDev.cc
endWord();
}
@@ -2057,15 +2189,46 @@
- w1 /= uLen;
- h1 /= uLen;
- for (i = 0; i < uLen; ++i) {
-- curWord->addChar(state, x1 + i*w1, y1 + i*h1, w1, h1, u[i]);
-+ curWord->addChar(state, x1 + i*w1, y1 + i*h1, w1, h1,
-+ charPos, nBytes, u[i]);
}
}
-- if (curWord) {
-- curWord->charLen += nBytes;
-- }
charPos += nBytes;
}
@@ -19647,31 +19316,6 @@ diff -ru xpdf-3.02/xpdf/TextOutputDev.cc xpdf-3.03/xpdf/TextOutputDev.cc
first = gTrue;
xMin0 = xMax0 = yMin0 = yMax0 = 0; // make gcc happy
xMin1 = xMax1 = yMin1 = yMax1 = 0; // make gcc happy
-@@ -3378,16 +3588,14 @@
- blk = blocks[i];
- for (line = blk->lines; line; line = line->next) {
- for (word = line->words; word; word = word->next) {
-- if (pos < word->charPos + word->charLen &&
-- word->charPos < pos + length) {
-- j0 = pos - word->charPos;
-- if (j0 < 0) {
-- j0 = 0;
-- }
-- j1 = pos + length - 1 - word->charPos;
-- if (j1 >= word->len) {
-- j1 = word->len - 1;
-- }
-+ if (pos < word->charPos[word->len] &&
-+ pos + length > word->charPos[0]) {
-+ for (j0 = 0;
-+ j0 < word->len && pos >= word->charPos[j0 + 1];
-+ ++j0) ;
-+ for (j1 = word->len - 1;
-+ j1 > j0 && pos + length <= word->charPos[j1];
-+ --j1) ;
- switch (line->rot) {
- case 0:
- xMin1 = word->edge[j0];
@@ -3491,7 +3699,9 @@
delete s;
if (word->next &&
@@ -19798,52 +19442,6 @@ diff -ru xpdf-3.02/xpdf/TextOutputDev.cc xpdf-3.03/xpdf/TextOutputDev.cc
diff -ru xpdf-3.02/xpdf/TextOutputDev.h xpdf-3.03/xpdf/TextOutputDev.h
--- xpdf-3.02/xpdf/TextOutputDev.h 2007-02-27 23:05:52.000000000 +0100
+++ xpdf-3.03/xpdf/TextOutputDev.h 2011-08-15 23:08:53.000000000 +0200
-@@ -85,14 +85,15 @@
-
- // Constructor.
- TextWord(GfxState *state, int rotA, double x0, double y0,
-- int charPosA, TextFontInfo *fontA, double fontSize);
-+ TextFontInfo *fontA, double fontSize);
-
- // Destructor.
- ~TextWord();
-
- // Add a character to the word.
- void addChar(GfxState *state, double x, double y,
-- double dx, double dy, Unicode u);
-+ double dx, double dy, int charPosA, int charLen,
-+ Unicode u);
-
- // Merge <word> onto the end of <this>.
- void merge(TextWord *word);
-@@ -126,8 +127,8 @@
- double *xMaxA, double *yMaxA);
- double getFontSize() { return fontSize; }
- int getRotation() { return rot; }
-- int getCharPos() { return charPos; }
-- int getCharLen() { return charLen; }
-+ int getCharPos() { return charPos[0]; }
-+ int getCharLen() { return charPos[len] - charPos[0]; }
- GBool getSpaceAfter() { return spaceAfter; }
- #endif
-
-@@ -144,11 +145,11 @@
- Unicode *text; // the text
- double *edge; // "near" edge x or y coord of each char
- // (plus one extra entry for the last char)
-- int len; // length of text and edge arrays
-- int size; // size of text and edge arrays
-- int charPos; // character position (within content stream)
-- int charLen; // number of content stream characters in
-- // this word
-+ int *charPos; // character position (within content stream)
-+ // of each char (plus one extra entry for
-+ // the last char)
-+ int len; // length of text/edge/charPos arrays
-+ int size; // size of text/edge/charPos arrays
- TextFontInfo *font; // font information
- double fontSize; // font size
- GBool spaceAfter; // set if there is a space between this
@@ -280,7 +281,7 @@
void addWord(TextWord *word);