From cef31eaac0e65aad71b1bda37d48245bb7ee9383 Mon Sep 17 00:00:00 2001 From: Johannes Buchner Date: Wed, 16 Jun 2010 03:38:10 +1200 Subject: [PATCH 1/2] sanitized formatting (tab/space) used indent with -kr --no-tabs --indent-level 2 --braces-on-func-def-line --honour-newlines --- poppler/TextOutputDev.cc | 216 +++++++++++++++++++++++----------------------- 1 files changed, 107 insertions(+), 109 deletions(-) diff --git a/poppler/TextOutputDev.cc b/poppler/TextOutputDev.cc index 87f6f08..dfa2c43 100644 --- a/poppler/TextOutputDev.cc +++ b/poppler/TextOutputDev.cc @@ -3379,12 +3379,12 @@ void TextPage::coalesce(GBool physLayout, GBool doHTML) { } } -GBool TextPage::findText(Unicode *s, int len, - GBool startAtTop, GBool stopAtBottom, - GBool startAtLast, GBool stopAtLast, - GBool caseSensitive, GBool backward, - double *xMin, double *yMin, - double *xMax, double *yMax) { +GBool TextPage::findText(Unicode * s, int len, + GBool startAtTop, GBool stopAtBottom, + GBool startAtLast, GBool stopAtLast, + GBool caseSensitive, GBool backward, + double *xMin, double *yMin, + double *xMax, double *yMax) { TextBlock *blk; TextLine *line; Unicode *s2, *txt; @@ -3400,7 +3400,6 @@ GBool TextPage::findText(Unicode *s, int len, if (rawOrder) { return gFalse; } - // convert the search string to uppercase if (!caseSensitive) { s2 = unicodeNormalizeNFKC(s, len, &len, NULL); @@ -3431,21 +3430,21 @@ GBool TextPage::findText(Unicode *s, int len, } found = gFalse; - xMin0 = xMax0 = yMin0 = yMax0 = 0; // make gcc happy - xMin1 = xMax1 = yMin1 = yMax1 = 0; // make gcc happy + xMin0 = xMax0 = yMin0 = yMax0 = 0; // make gcc happy + xMin1 = xMax1 = yMin1 = yMax1 = 0; // make gcc happy for (i = backward ? nBlocks - 1 : 0; - backward ? i >= 0 : i < nBlocks; - i += backward ? -1 : 1) { + backward ? i >= 0 : i < nBlocks; i += backward ? -1 : 1) { blk = blocks[i]; // check: is the block above the top limit? - if (!startAtTop && (backward ? blk->yMin > yStart : blk->yMax < yStart)) { + if (!startAtTop + && (backward ? blk->yMin > yStart : blk->yMax < yStart)) { continue; } - // check: is the block below the bottom limit? - if (!stopAtBottom && (backward ? blk->yMax < yStop : blk->yMin > yStop)) { + if (!stopAtBottom + && (backward ? blk->yMax < yStop : blk->yMin > yStop)) { break; } @@ -3453,119 +3452,118 @@ GBool TextPage::findText(Unicode *s, int len, // check: is the line above the top limit? if (!startAtTop && - (backward ? line->yMin > yStart : line->yMin < yStart)) { - continue; + (backward ? line->yMin > yStart : line->yMin < yStart)) { + continue; } - // check: is the line below the bottom limit? if (!stopAtBottom && - (backward ? line->yMin < yStop : line->yMin > yStop)) { - continue; + (backward ? line->yMin < yStop : line->yMin > yStop)) { + continue; } if (!line->normalized) - line->normalized = unicodeNormalizeNFKC(line->text, line->len, - &line->normalized_len, - &line->normalized_idx); + line->normalized = unicodeNormalizeNFKC(line->text, line->len, + &line->normalized_len, + &line->normalized_idx); // convert the line to uppercase m = line->normalized_len; if (!caseSensitive) { - if (m > txtSize) { - txt = (Unicode *)greallocn(txt, m, sizeof(Unicode)); - txtSize = m; - } - for (k = 0; k < m; ++k) { - txt[k] = unicodeToUpper(line->normalized[k]); - } - } else { - txt = line->normalized; - } + if (m > txtSize) { + txt = (Unicode *) greallocn(txt, m, sizeof(Unicode)); + txtSize = m; + } + for (k = 0; k < m; ++k) { + txt[k] = unicodeToUpper(line->normalized[k]); + } + } else { + txt = line->normalized; + } // search each position in this line j = backward ? m - len : 0; p = txt + j; while (backward ? j >= 0 : j <= m - len) { - // compare the strings - for (k = 0; k < len; ++k) { - if (p[k] != s2[k]) { - break; - } - } + // compare the strings + for (k = 0; k < len; ++k) { + if (p[k] != s2[k]) { + break; + } + } - // found it - if (k == len) { - // where s2 matches a subsequence of a compatibility equivalence - // decomposition, highlight the entire glyph, since we don't know - // the internal layout of subglyph components - int normStart = line->normalized_idx[j]; - int normAfterEnd = line->normalized_idx[j + len - 1] + 1; - switch (line->rot) { - case 0: - xMin1 = line->edge[normStart]; - xMax1 = line->edge[normAfterEnd]; - yMin1 = line->yMin; - yMax1 = line->yMax; - break; - case 1: - xMin1 = line->xMin; - xMax1 = line->xMax; - yMin1 = line->edge[normStart]; - yMax1 = line->edge[normAfterEnd]; - break; - case 2: - xMin1 = line->edge[normAfterEnd]; - xMax1 = line->edge[normStart]; - yMin1 = line->yMin; - yMax1 = line->yMax; - break; - case 3: - xMin1 = line->xMin; - xMax1 = line->xMax; - yMin1 = line->edge[normAfterEnd]; - yMax1 = line->edge[normStart]; - break; - } - if (backward) { - if ((startAtTop || - yMin1 < yStart || (yMin1 == yStart && xMin1 < xStart)) && - (stopAtBottom || - yMin1 > yStop || (yMin1 == yStop && xMin1 > xStop))) { - if (!found || - yMin1 > yMin0 || (yMin1 == yMin0 && xMin1 > xMin0)) { - xMin0 = xMin1; - xMax0 = xMax1; - yMin0 = yMin1; - yMax0 = yMax1; - found = gTrue; - } - } - } else { - if ((startAtTop || - yMin1 > yStart || (yMin1 == yStart && xMin1 > xStart)) && - (stopAtBottom || - yMin1 < yStop || (yMin1 == yStop && xMin1 < xStop))) { - if (!found || - yMin1 < yMin0 || (yMin1 == yMin0 && xMin1 < xMin0)) { - xMin0 = xMin1; - xMax0 = xMax1; - yMin0 = yMin1; - yMax0 = yMax1; - found = gTrue; - } - } - } - } - if (backward) { - --j; - --p; - } else { - ++j; - ++p; - } + // found it + if (k == len) { + // where s2 matches a subsequence of a compatibility equivalence + // decomposition, highlight the entire glyph, since we don't know + // the internal layout of subglyph components + int normStart = line->normalized_idx[j]; + int normAfterEnd = line->normalized_idx[j + len - 1] + 1; + switch (line->rot) { + case 0: + xMin1 = line->edge[normStart]; + xMax1 = line->edge[normAfterEnd]; + yMin1 = line->yMin; + yMax1 = line->yMax; + break; + case 1: + xMin1 = line->xMin; + xMax1 = line->xMax; + yMin1 = line->edge[normStart]; + yMax1 = line->edge[normAfterEnd]; + break; + case 2: + xMin1 = line->edge[normAfterEnd]; + xMax1 = line->edge[normStart]; + yMin1 = line->yMin; + yMax1 = line->yMax; + break; + case 3: + xMin1 = line->xMin; + xMax1 = line->xMax; + yMin1 = line->edge[normAfterEnd]; + yMax1 = line->edge[normStart]; + break; + } + if (backward) { + if ((startAtTop || + yMin1 < yStart || (yMin1 == yStart && xMin1 < xStart)) && + (stopAtBottom || + yMin1 > yStop || (yMin1 == yStop && xMin1 > xStop))) { + if (!found || + yMin1 > yMin0 || (yMin1 == yMin0 && xMin1 > xMin0)) { + xMin0 = xMin1; + xMax0 = xMax1; + yMin0 = yMin1; + yMax0 = yMax1; + found = gTrue; + } + } + } else { + if ((startAtTop || + yMin1 > yStart || (yMin1 == yStart && xMin1 > xStart)) && + (stopAtBottom || + yMin1 < yStop || (yMin1 == yStop && xMin1 < xStop))) { + if (!found || + yMin1 < yMin0 || (yMin1 == yMin0 && xMin1 < xMin0)) { + xMin0 = xMin1; + xMax0 = xMax1; + yMin0 = yMin1; + yMax0 = yMax1; + found = gTrue; + } + } + } + } + if (backward) { + --j; + --p; + } else { + ++j; + ++p; + } } } - } + } gfree(s2); if (!caseSensitive) { -- 1.6.4.4