djvu.h 3.93 KB
Newer Older
Moritz Lipp's avatar
Moritz Lipp committed
1
2
3
4
5
6
/* See LICENSE file for license and copyright information */

#ifndef DJVU_H
#define DJVU_H

#include <stdbool.h>
Moritz Lipp's avatar
Moritz Lipp committed
7
#include <zathura/plugin-api.h>
Moritz Lipp's avatar
Moritz Lipp committed
8
#include <libdjvu/ddjvuapi.h>
9
#include <cairo.h>
Moritz Lipp's avatar
Moritz Lipp committed
10

11
12
13
/**
 * DjVu document
 */
Moritz Lipp's avatar
Moritz Lipp committed
14
15
typedef struct djvu_document_s
{
16
17
18
  ddjvu_context_t*  context; /**< Document context */
  ddjvu_document_t* document; /**< Document */
  ddjvu_format_t*   format; /**< Format */
Moritz Lipp's avatar
Moritz Lipp committed
19
20
} djvu_document_t;

21
22
23
24
/**
 * Open a DjVU document
 *
 * @param document Zathura document
25
 * @return ZATHURA_ERROR_OK when no error occurred, otherwise see
Moritz Lipp's avatar
Moritz Lipp committed
26
 *    zathura_error_t
27
 */
Sebastian Ramacher's avatar
Sebastian Ramacher committed
28
GIRARA_HIDDEN zathura_error_t djvu_document_open(zathura_document_t* document);
29
30
31
32
33

/**
 * Closes and frees the internal document structure
 *
 * @param document Zathura document
34
 * @return ZATHURA_ERROR_OK when no error occurred, otherwise see
Moritz Lipp's avatar
Moritz Lipp committed
35
 *    zathura_error_t
36
 */
Sebastian Ramacher's avatar
Sebastian Ramacher committed
37
GIRARA_HIDDEN zathura_error_t djvu_document_free(zathura_document_t* document, djvu_document_t* djvu_document);
38

Moritz Lipp's avatar
Moritz Lipp committed
39
40
41
42
43
/**
 * Generates the index of the document
 *
 * @param document Zathura document
 * @param error Set to an error value (see zathura_error_t) if an
44
 *   error occurred
Moritz Lipp's avatar
Moritz Lipp committed
45
46
47
 * @return Tree node object or NULL if an error occurred (e.g.: the document has
 *   no index)
 */
Sebastian Ramacher's avatar
Sebastian Ramacher committed
48
GIRARA_HIDDEN girara_tree_node_t* djvu_document_index_generate(zathura_document_t* document,
Moritz Lipp's avatar
Moritz Lipp committed
49
50
    djvu_document_t* djvu_document, zathura_error_t* error);

51
52
53
54
55
/**
 * Saves the document to the given path
 *
 * @param document Zathura document
 * @param path File path
56
 * @return ZATHURA_ERROR_OK when no error occurred, otherwise see
Moritz Lipp's avatar
Moritz Lipp committed
57
 *    zathura_error_t
58
 */
Sebastian Ramacher's avatar
Sebastian Ramacher committed
59
GIRARA_HIDDEN zathura_error_t djvu_document_save_as(zathura_document_t* document, djvu_document_t* djvu_document, const char* path);
60
61

/**
Moritz Lipp's avatar
Moritz Lipp committed
62
 * Initializes the page
63
 *
Moritz Lipp's avatar
Moritz Lipp committed
64
 * @param page The page object
65
 * @return ZATHURA_ERROR_OK when no error occurred, otherwise see
Moritz Lipp's avatar
Moritz Lipp committed
66
 *    zathura_error_t
67
 */
Sebastian Ramacher's avatar
Sebastian Ramacher committed
68
GIRARA_HIDDEN zathura_error_t djvu_page_init(zathura_page_t* page, void* data);
69
70
71
72
73

/**
 * Frees a DjVu page
 *
 * @param page Page
74
 * @return ZATHURA_ERROR_OK when no error occurred, otherwise see
Moritz Lipp's avatar
Moritz Lipp committed
75
 *    zathura_error_t
76
 */
Sebastian Ramacher's avatar
Sebastian Ramacher committed
77
GIRARA_HIDDEN zathura_error_t djvu_page_clear(zathura_page_t* page, void* data);
78

Moritz Lipp's avatar
Moritz Lipp committed
79
80
81
82
83
/**
 * Searches for a specific text on a page and returns a list of results
 *
 * @param page Page
 * @param text Search item
Moritz Lipp's avatar
Moritz Lipp committed
84
 * @param error Set to an error value (see zathura_error_t) if an
85
 *   error occurred
Moritz Lipp's avatar
Moritz Lipp committed
86
87
 * @return List of search results or NULL if an error occurred
 */
Sebastian Ramacher's avatar
Sebastian Ramacher committed
88
GIRARA_HIDDEN girara_list_t* djvu_page_search_text(zathura_page_t* page, void* data, const char* text, zathura_error_t* error);
Moritz Lipp's avatar
Moritz Lipp committed
89

90
91
92
93
94
/**
 * Get text for selection
 *
 * @param page Page
 * @param rectangle Selection
Moritz Lipp's avatar
Moritz Lipp committed
95
 * @error Set to an error value (see \ref zathura_error_t) if an error
96
 * occurred
97
98
 * @return The selected text (needs to be deallocated with g_free)
 */
Sebastian Ramacher's avatar
Sebastian Ramacher committed
99
GIRARA_HIDDEN char* djvu_page_get_text(zathura_page_t* page, void* data, zathura_rectangle_t rectangle, zathura_error_t* error);
100

Moritz Lipp's avatar
Moritz Lipp committed
101
102
103
104
105
106
/**
 * Returns list of links
 *
 * @param page The page
 * @param data Unused page data
 * @param error Error code
107
 * @return List of links or NULL if an error occurred
Moritz Lipp's avatar
Moritz Lipp committed
108
 */
Sebastian Ramacher's avatar
Sebastian Ramacher committed
109
GIRARA_HIDDEN girara_list_t* djvu_page_links_get(zathura_page_t* page, void* data,
Moritz Lipp's avatar
Moritz Lipp committed
110
111
    zathura_error_t* error);

112
113
114
115
116
/**
 * Renders a page and returns a allocated image buffer which has to be freed
 * with zathura_image_buffer_free
 *
 * @param page Page
Moritz Lipp's avatar
Moritz Lipp committed
117
 * @param error Set to an error value (see zathura_error_t) if an
118
 *   error occurred
119
120
 * @return Image buffer or NULL if an error occurred
 */
Sebastian Ramacher's avatar
Sebastian Ramacher committed
121
GIRARA_HIDDEN zathura_image_buffer_t* djvu_page_render(zathura_page_t* page, void* data, zathura_error_t* error);
122
123
124
125
126
127
128

/**
 * Renders a page onto a cairo object
 *
 * @param page Page
 * @param cairo Cairo object
 * @param printing Set to true if page should be rendered for printing
129
 * @return ZATHURA_ERROR_OK when no error occurred, otherwise see
Moritz Lipp's avatar
Moritz Lipp committed
130
 *    zathura_error_t
131
 */
Sebastian Ramacher's avatar
Sebastian Ramacher committed
132
GIRARA_HIDDEN zathura_error_t djvu_page_render_cairo(zathura_page_t* page, void* data, cairo_t* cairo, bool printing);
Moritz Lipp's avatar
Moritz Lipp committed
133
134

#endif // DJVU_H