#include <config.h>
#include <string.h>
#include <glib.h>
#include <libdjvu/miniexp.h>
#include "djvu-text-page.h"
Go to the source code of this file.
|
static void | djvu_text_page_union (EvRectangle *target, EvRectangle *source) |
|
static gboolean | djvu_text_page_selection_process_box (DjvuTextPage *page, miniexp_t p, int delimit) |
|
static gboolean | djvu_text_page_selection_process_text (DjvuTextPage *page, miniexp_t p, int delimit) |
|
static gboolean | djvu_text_page_selection (DjvuSelectionType type, DjvuTextPage *page, miniexp_t p, int delimit) |
|
static void | djvu_text_page_limits_process (DjvuTextPage *page, miniexp_t p, EvRectangle *rect) |
|
static void | djvu_text_page_limits (DjvuTextPage *page, miniexp_t p, EvRectangle *rect) |
|
GList * | djvu_text_page_get_selection_region (DjvuTextPage *page, EvRectangle *rectangle) |
|
char * | djvu_text_page_copy (DjvuTextPage *page, EvRectangle *rectangle) |
|
static miniexp_t | djvu_text_page_position (DjvuTextPage *page, int position) |
|
static gboolean | djvu_text_page_sexpr_process (DjvuTextPage *page, miniexp_t p, miniexp_t start, miniexp_t end) |
|
static gboolean | djvu_text_page_sexpr (DjvuTextPage *page, miniexp_t p, miniexp_t start, miniexp_t end) |
|
static EvRectangle * | djvu_text_page_box (DjvuTextPage *page, miniexp_t start, miniexp_t end) |
|
static void | djvu_text_page_append_text (DjvuTextPage *page, miniexp_t p, gboolean case_sensitive, gboolean delimit) |
|
void | djvu_text_page_search (DjvuTextPage *page, const char *text) |
|
void | djvu_text_page_index_text (DjvuTextPage *page, gboolean case_sensitive) |
|
DjvuTextPage * | djvu_text_page_new (miniexp_t text) |
|
void | djvu_text_page_free (DjvuTextPage *page) |
|
static void djvu_text_page_append_text |
( |
DjvuTextPage * |
page, |
|
|
miniexp_t |
p, |
|
|
gboolean |
case_sensitive, |
|
|
gboolean |
delimit |
|
) |
| |
|
static |
Definition at line 393 of file djvu-text-page.c.
401 g_return_if_fail (miniexp_consp (p) &&
402 miniexp_symbolp (miniexp_car (p)));
406 deeper = miniexp_cddr (miniexp_cdddr (p));
407 while (deeper != miniexp_nil) {
408 miniexp_t data = miniexp_car (deeper);
409 if (miniexp_stringp (data)) {
414 g_array_append_val (page->
links, link);
416 token_text = (
char *) miniexp_to_str (data);
418 token_text = g_utf8_casefold (token_text, -1);
419 if (page->
text == NULL)
420 page->
text = g_strdup (token_text);
423 g_strjoin (delimit ?
" " : NULL,
424 page->
text, token_text,
427 page->
text = new_text;
433 case_sensitive, delimit);
435 deeper = miniexp_cdr (deeper);
void djvu_text_page_index_text |
( |
DjvuTextPage * |
page, |
|
|
gboolean |
case_sensitive |
|
) |
| |
Definition at line 189 of file djvu-text-page.c.
195 g_return_if_fail (miniexp_consp (p) &&
196 miniexp_symbolp (miniexp_car (p)));
198 deeper = miniexp_cddr (miniexp_cdddr (p));
199 while (deeper != miniexp_nil) {
200 miniexp_t str = miniexp_car (deeper);
201 if (miniexp_stringp (str))
206 deeper = miniexp_cdr (deeper);
Definition at line 169 of file djvu-text-page.c.
175 current.
x1 = miniexp_to_int (miniexp_nth (1, p));
176 current.
y1 = miniexp_to_int (miniexp_nth (2, p));
177 current.
x2 = miniexp_to_int (miniexp_nth (3, p));
178 current.
y2 = miniexp_to_int (miniexp_nth (4, p));
179 if (current.
x2 >= rect->
x1 && current.
y1 <= rect->
y2 &&
180 current.
x1 <= rect->
x2 && current.
y2 >= rect->
y1) {
181 if (page->
start == miniexp_nil)
djvu_text_page_new: : S-expression of the page text
Creates a new page to search.
Returns: new DjvuTextPage instance
Definition at line 496 of file djvu-text-page.c.
static miniexp_t djvu_text_page_position |
( |
DjvuTextPage * |
page, |
|
|
int |
position |
|
) |
| |
|
static |
Definition at line 263 of file djvu-text-page.c.
266 GArray *links = page->
links;
268 int hi = links->len - 1;
271 g_return_val_if_fail (hi >= 0, miniexp_nil);
277 mid = (low + hi) >> 1;
void djvu_text_page_search |
( |
DjvuTextPage * |
page, |
|
|
const char * |
text |
|
) |
| |
Definition at line 448 of file djvu-text-page.c.
451 char *haystack = page->
text;
454 if (page->
links->len == 0)
457 search_len = strlen (text);
458 while ((haystack = strstr (haystack, text)) != NULL) {
459 int start_p = haystack - page->
text;
461 int end_p = start_p + search_len - 1;
466 haystack = haystack + search_len;
Definition at line 134 of file djvu-text-page.c.
141 g_return_val_if_fail (miniexp_consp (p) && miniexp_symbolp
142 (miniexp_car (p)),
FALSE);
145 delimit |= miniexp_car (p) == page->
word_symbol ? 1 : 2;
147 deeper = miniexp_cddr (miniexp_cdddr (p));
148 while (deeper != miniexp_nil) {
149 miniexp_t str = miniexp_car (deeper);
150 if (miniexp_stringp (str)) {
163 deeper = miniexp_cdr (deeper);
static gboolean djvu_text_page_selection_process_box |
( |
DjvuTextPage * |
page, |
|
|
miniexp_t |
p, |
|
|
int |
delimit |
|
) |
| |
|
static |
Definition at line 60 of file djvu-text-page.c.
67 box.
x1 = miniexp_to_int (miniexp_nth (1, p));
68 box.
y1 = miniexp_to_int (miniexp_nth (2, p));
69 box.
x2 = miniexp_to_int (miniexp_nth (3, p));
70 box.
y2 = miniexp_to_int (miniexp_nth (4, p));
72 if (!(delimit & 2) && page->
results != NULL) {
static gboolean djvu_text_page_selection_process_text |
( |
DjvuTextPage * |
page, |
|
|
miniexp_t |
p, |
|
|
int |
delimit |
|
) |
| |
|
static |
Definition at line 99 of file djvu-text-page.c.
104 char *token_text = (
char *) miniexp_to_str (miniexp_nth (5, p));
107 g_strjoin (delimit & 2 ?
"\n" :
108 delimit & 1 ?
" " : NULL,
109 page->
text, token_text,
112 page->
text = new_text;
114 page->
text = g_strdup (token_text);
static gboolean djvu_text_page_sexpr |
( |
DjvuTextPage * |
page, |
|
|
miniexp_t |
p, |
|
|
miniexp_t |
start, |
|
|
miniexp_t |
end |
|
) |
| |
|
static |
Definition at line 338 of file djvu-text-page.c.
345 g_return_val_if_fail (miniexp_consp (p) && miniexp_symbolp
346 (miniexp_car (p)),
FALSE);
348 deeper = miniexp_cddr (miniexp_cdddr (p));
349 while (deeper != miniexp_nil) {
350 miniexp_t str = miniexp_car (deeper);
351 if (miniexp_stringp (str)) {
353 (page, p, start, end))
357 (page, str, start, end))
360 deeper = miniexp_cdr (deeper);
static gboolean djvu_text_page_sexpr_process |
( |
DjvuTextPage * |
page, |
|
|
miniexp_t |
p, |
|
|
miniexp_t |
start, |
|
|
miniexp_t |
end |
|
) |
| |
|
static |
Definition at line 302 of file djvu-text-page.c.
309 new_rectangle->
x1 = miniexp_to_int (miniexp_nth (1, p));
310 new_rectangle->
y1 = miniexp_to_int (miniexp_nth (2, p));
311 new_rectangle->
x2 = miniexp_to_int (miniexp_nth (3, p));
312 new_rectangle->
y2 = miniexp_to_int (miniexp_nth (4, p));
316 g_free (new_rectangle);
djvu_text_page_union: : first rectangle and result : second rectangle
Calculates the bounding box of two rectangles and stores the result in the first.
Definition at line 36 of file djvu-text-page.c.
39 if (source->
x1 < target->
x1)
40 target->
x1 = source->
x1;
41 if (source->
x2 > target->
x2)
42 target->
x2 = source->
x2;
43 if (source->
y1 < target->
y1)
44 target->
y1 = source->
y1;
45 if (source->
y2 > target->
y2)
46 target->
y2 = source->
y2;