summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2010-04-24 18:59:04 +0200
committerTor Andersson <tor@ghostscript.com>2010-04-24 18:59:04 +0200
commit6c9882818e4afc1502c6200f082794811d394b1c (patch)
tree1f6b17076972d85383d5a7f79f040e59306cd5b0
parent3f705395e393735af12553a2499632d5106d7fa8 (diff)
downloadmupdf-6c9882818e4afc1502c6200f082794811d394b1c.tar.xz
Fix pdfapp_oncopy logic for inserting newlines.
-rw-r--r--apps/pdfapp.c55
1 files changed, 27 insertions, 28 deletions
diff --git a/apps/pdfapp.c b/apps/pdfapp.c
index 2eb3e395..414d44e7 100644
--- a/apps/pdfapp.c
+++ b/apps/pdfapp.c
@@ -620,10 +620,10 @@ void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int sta
void pdfapp_oncopy(pdfapp_t *app, unsigned short *ucsbuf, int ucslen)
{
- ucsbuf[0] = 0;
- fz_textspan *ln;
- int y, c;
- int i, p;
+ int bx0, bx1, by0, by1;
+ fz_textspan *span;
+ int c, i, p;
+ int seen;
int x0 = app->image->x + app->selr.x0 - app->panx;
int x1 = app->image->x + app->selr.x1 - app->panx;
@@ -631,37 +631,36 @@ void pdfapp_oncopy(pdfapp_t *app, unsigned short *ucsbuf, int ucslen)
int y1 = app->image->y + app->selr.y1 - app->pany;
p = 0;
- for (ln = app->text; ln; ln = ln->next)
+ for (span = app->text; span; span = span->next)
{
- if (ln->len > 0)
+ seen = 0;
+
+ for (i = 0; i < span->len; i++)
{
- y = y0 - 1;
- for (i = 0; i < ln->len; i++)
+ bx0 = span->text[i].bbox.x0;
+ bx1 = span->text[i].bbox.x1;
+ by0 = span->text[i].bbox.y0;
+ by1 = span->text[i].bbox.y1;
+
+ c = span->text[i].c;
+ if (c < 32)
+ c = '?';
+ if (bx1 >= x0 && bx0 <= x1 && by1 >= y0 && by0 <= y1)
{
- int bx0, bx1, by0, by1;
-
- bx0 = ln->text[i].bbox.x0;
- bx1 = ln->text[i].bbox.x1;
- by0 = ln->text[i].bbox.y0;
- by1 = ln->text[i].bbox.y1;
-
- c = ln->text[i].c;
- if (c < 32)
- c = '?';
- if (bx1 >= x0 && bx0 <= x1 && by1 >= y0 && by0 <= y1)
- if (p < ucslen - 1)
- ucsbuf[p++] = c;
+ if (p < ucslen - 1)
+ ucsbuf[p++] = c;
+ seen = 1;
}
+ }
- if (y >= y0 && y <= y1)
- {
+ if (seen)
+ {
#ifdef _WIN32
- if (p < ucslen - 1)
- ucsbuf[p++] = '\r';
+ if (p < ucslen - 1)
+ ucsbuf[p++] = '\r';
#endif
- if (p < ucslen - 1)
- ucsbuf[p++] = '\n';
- }
+ if (p < ucslen - 1)
+ ucsbuf[p++] = '\n';
}
}