[evince] djvu: Ignore text regions that are missing text
- From: Jason Crain <jcrain src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince] djvu: Ignore text regions that are missing text
- Date: Tue, 11 Sep 2018 06:51:35 +0000 (UTC)
commit 2a297354efffafbd52ff3c4ed9a191534bbeff8d
Author: Jason Crain <jcrain src gnome org>
Date: Sat Aug 25 19:08:30 2018 -0600
djvu: Ignore text regions that are missing text
The DjVu document in issue #948 has text regions that cover the entire
page but only contain an empty string. This makes selecting text with
either the mouse or the Control+A shortcut difficult because the entire
page gets selected. Fix this by ignoring empty strings when determining
the selection region.
backend/djvu/djvu-text-page.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
---
diff --git a/backend/djvu/djvu-text-page.c b/backend/djvu/djvu-text-page.c
index 243bd3e0..af858cf2 100644
--- a/backend/djvu/djvu-text-page.c
+++ b/backend/djvu/djvu-text-page.c
@@ -63,20 +63,24 @@ djvu_text_page_selection_process_box (DjvuTextPage *page,
{
if (page->results || p == page->start) {
EvRectangle box;
+ const char *text;
box.x1 = miniexp_to_int (miniexp_nth (1, p));
box.y1 = miniexp_to_int (miniexp_nth (2, p));
box.x2 = miniexp_to_int (miniexp_nth (3, p));
box.y2 = miniexp_to_int (miniexp_nth (4, p));
+ text = miniexp_to_str (miniexp_nth (5, p));
- if (!(delimit & 2) && page->results != NULL) {
- EvRectangle *union_box = (EvRectangle *)page->results->data;
+ if (text != NULL && text[0] != '\0') {
+ if (!(delimit & 2) && page->results != NULL) {
+ EvRectangle *union_box = (EvRectangle *)page->results->data;
- /* If still on the same line, add box to union */
- djvu_text_page_union (union_box, &box);
- } else {
- /* A new line, a new box */
- page->results = g_list_prepend (page->results, ev_rectangle_copy (&box));
+ /* If still on the same line, add box to union */
+ djvu_text_page_union (union_box, &box);
+ } else {
+ /* A new line, a new box */
+ page->results = g_list_prepend (page->results, ev_rectangle_copy (&box));
+ }
}
if (p == page->end)
@@ -171,13 +175,16 @@ djvu_text_page_limits_process (DjvuTextPage *page,
EvRectangle *rect)
{
EvRectangle current;
+ const char *text;
current.x1 = miniexp_to_int (miniexp_nth (1, p));
current.y1 = miniexp_to_int (miniexp_nth (2, p));
current.x2 = miniexp_to_int (miniexp_nth (3, p));
current.y2 = miniexp_to_int (miniexp_nth (4, p));
+ text = miniexp_to_str (miniexp_nth (5, p));
if (current.x2 >= rect->x1 && current.y1 <= rect->y2 &&
- current.x1 <= rect->x2 && current.y2 >= rect->y1) {
+ current.x1 <= rect->x2 && current.y2 >= rect->y1 &&
+ text != NULL && text[0] != '\0') {
if (page->start == miniexp_nil)
page->start = p;
page->end = p;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]