Esempio n. 1
0
/**
 * djvu_text_page_selection:
 * @page: #DjvuTextPage instance
 * @p: tree to append
 * @delimit: character/word/... delimiter
 * 
 * Walks the tree in @p and appends the text with
 * djvu_text_page_selection_process() for all s-expressions 
 * between the start and end fields.
 * 
 * Returns: whether the end was not reached in this subtree
 */
static gboolean
djvu_text_page_selection (DjvuTextPage *page, 
		          miniexp_t     p,
		          int           delimit)
{
	g_return_val_if_fail (miniexp_consp (p) && miniexp_symbolp
			      (miniexp_car (p)), FALSE);

	if (miniexp_car (p) != page->char_symbol) 
		delimit |= miniexp_car (p) == page->word_symbol ? 1 : 2;
		
	miniexp_t deeper = miniexp_cddr (miniexp_cdddr (p));
	while (deeper != miniexp_nil) {
		miniexp_t str = miniexp_car (deeper);
		if (miniexp_stringp (str)) {
			if (!djvu_text_page_selection_process
			    (page, p, delimit))
				return FALSE;
		} else {
			if (!djvu_text_page_selection
			    (page, str, delimit))
				return FALSE;
		}
		delimit = 0;
		deeper = miniexp_cdr (deeper);
	}
	return TRUE;
}
Esempio n. 2
0
/**
 * djvu_text_page_get_selection:
 * @page: #DjvuTextPage instance
 * @rectangle: #EvRectangle of the selection
 *
 * Returns: The bounding boxes of the selection
 */
GList *
djvu_text_page_get_selection_region (DjvuTextPage *page,
                                     EvRectangle  *rectangle)
{
	page->start = miniexp_nil;
	page->end = miniexp_nil;

	/* Get page->start and page->end filled from selection rectangle */
	djvu_text_page_limits (page, page->text_structure, rectangle);
	/* Fills page->results with the bouding boxes */
	djvu_text_page_selection (DJVU_SELECTION_BOX,
	                          page, page->text_structure, 0);

	return g_list_reverse (page->results);
}
Esempio n. 3
0
char *
djvu_text_page_copy (DjvuTextPage *page, 
		     EvRectangle  *rectangle)
{
	char* text;
	
	page->start = miniexp_nil;
	page->end = miniexp_nil;
	djvu_text_page_limits (page, page->text_structure, rectangle);
	djvu_text_page_selection (page, page->text_structure, 0);
	
	/* Do not free the string */	  
	text = page->text;
	page->text = NULL;
	
	return text;
}