document.h 9.89 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 DOCUMENT_H
#define DOCUMENT_H

#include <stdbool.h>
7
#include <girara/types.h>
8

Moritz Lipp's avatar
Moritz Lipp committed
9
#include "types.h"
10

Moritz Lipp's avatar
Moritz Lipp committed
11 12 13
/**
 * Open the document
 *
14
 * @param plugin_manager The plugin manager
Moritz Lipp's avatar
Moritz Lipp committed
15 16
 * @param path Path to the document
 * @param password Password of the document or NULL
17
 * @param error Optional error parameter
18
 * @return The document object and NULL if an error occurs
Moritz Lipp's avatar
Moritz Lipp committed
19
 */
20 21 22
zathura_document_t* zathura_document_open(zathura_plugin_manager_t*
    plugin_manager, const char* path, const char* password, zathura_error_t*
    error);
Moritz Lipp's avatar
Moritz Lipp committed
23

24 25 26 27 28 29 30 31 32
/**
 * Free the document
 *
 * @param document
 * @return ZATHURA_ERROR_OK when no error occured, otherwise see
 *    zathura_error_t
 */
zathura_error_t zathura_document_free(zathura_document_t* document);

33 34 35 36 37 38 39 40
/**
 * Returns the path of the document
 *
 * @param document The document
 * @return The file path of the document
 */
const char* zathura_document_get_path(zathura_document_t* document);

41 42 43 44 45 46 47 48
/**
 * Returns the basename of the document
 *
 * @param document The document
 * @return The basename of the document
 */
const char* zathura_document_get_basename(zathura_document_t* document);

49 50 51 52 53 54 55 56
/**
 * Returns the password of the document
 *
 * @param document The document
 * @return Returns the password of the document
 */
const char* zathura_document_get_password(zathura_document_t* document);

Moritz Lipp's avatar
Moritz Lipp committed
57
/**
58
 * Returns the page at the given index
59 60
 *
 * @param document The document
61 62
 * @param index The index of the page
 * @return The page or NULL if an error occured
63
 */
64
zathura_page_t* zathura_document_get_page(zathura_document_t* document, unsigned int index);
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88

/**
 * Returns the number of pages
 *
 * @param document The document
 * @return Number of pages
 */
unsigned int zathura_document_get_number_of_pages(zathura_document_t* document);

/**
 * Sets the number of pages
 *
 * @param document The document
 * @param number_of_pages Number of pages
 */
void zathura_document_set_number_of_pages(zathura_document_t* document, unsigned
    int number_of_pages);

/**
 * Returns the current page number
 *
 * @param document The document
 * @return Current page
 */
89
unsigned int zathura_document_get_current_page_number(zathura_document_t* document);
90 91 92 93 94 95 96

/**
 * Sets the number of pages
 *
 * @param document The document
 * @param current_page The current page number
 */
97
void zathura_document_set_current_page_number(zathura_document_t* document, unsigned
98 99
    int current_page);

100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
/**
 * Returns the X position, as a value relative to the document width (0=left,
 * 1=right).
 *
 * @param document The document
 * @return X adjustment
 */
double zathura_document_get_position_x(zathura_document_t* document);

/**
 * Returns the Y position as value relative to the document height (0=top,
 * 1=bottom)
 *
 * @param document The document
 * @return Y adjustment
 */
double zathura_document_get_position_y(zathura_document_t* document);

/**
 * Sets the X position as a value relative to the document width (0=left,
 * 1=right)
 *
 * @param document The document
 * @param position_x the X adjustment
 */
void zathura_document_set_position_x(zathura_document_t* document, double position_x);

/**
 * Sets the Y position as a value relative to the document height (0=top,
 * 1=bottom)
 *
 * @param document The document
 * @param position_y the Y adjustment
 */
void zathura_document_set_position_y(zathura_document_t* document, double position_y);

136 137 138 139
/**
 * Returns the current scale value of the document
 *
 * @param document The document
140
 * @return The current scale value
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
 */
double zathura_document_get_scale(zathura_document_t* document);

/**
 * Sets the new scale value of the document
 *
 * @param document The document
 * @param scale The new scale value
 */
void zathura_document_set_scale(zathura_document_t* document, double scale);

/**
 * Returns the rotation value of zathura (0..360)
 *
 * @param document The document
 * @return The current rotation value
 */
unsigned int zathura_document_get_rotation(zathura_document_t* document);

/**
 * Sets the new rotation value
 *
 * @param document The document
 * @param rotation The new rotation value
 */
void zathura_document_set_rotation(zathura_document_t* document, unsigned int rotation);

/**
 * Returns the adjust mode of the document
 *
 * @param document The document
172
 * @return The adjust mode
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
 */
zathura_adjust_mode_t zathura_document_get_adjust_mode(zathura_document_t* document);

/**
 * Sets the new adjust mode of the document
 *
 * @param document The document
 * @param mode The new adjust mode
 */
void zathura_document_set_adjust_mode(zathura_document_t* document, zathura_adjust_mode_t mode);

/**
 * Returns the page offset of the document
 *
 * @param document The document
 * @return The page offset
 */
Moritz Lipp's avatar
Moritz Lipp committed
190
int zathura_document_get_page_offset(zathura_document_t* document);
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207

/**
 * Sets the new page offset of the document
 *
 * @param document The document
 * @param page_offset The new page offset
 */
void zathura_document_set_page_offset(zathura_document_t* document, unsigned int page_offset);

/**
 * Returns the private data of the document
 *
 * @param document The document
 * @return The private data or NULL
 */
void* zathura_document_get_data(zathura_document_t* document);

208 209 210 211 212 213 214 215
/**
 * Sets the private data of the document
 *
 * @param document The document
 * @param data The new private data
 */
void zathura_document_set_data(zathura_document_t* document, void* data);

216
/**
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247
 * Sets the width of the viewport in pixels.
 *
 * @param[in] document     The document instance
 * @param[in] width        The width of the viewport
 */
void
zathura_document_set_viewport_width(zathura_document_t* document, unsigned int width);

/**
 * Sets the height of the viewport in pixels.
 *
 * @param[in] document     The document instance
 * @param[in] height       The height of the viewport
 */
void
zathura_document_set_viewport_height(zathura_document_t* document, unsigned int height);

/**
 * Return the size of the viewport in pixels.
 *
 * @param[in]  document     The document instance
 * @param[out] height,width The width and height of the viewport
 */
void
zathura_document_get_viewport_size(zathura_document_t* document,
                                   unsigned int *height, unsigned int* width);

/**
 * Return the size of a cell from the document's layout table in pixels. Assumes
 * that the table is homogeneous (i.e. every cell has the same dimensions). It
 * takes the current scale into account.
248 249 250 251 252 253 254
 *
 * @param[in]  document     The document instance
 * @param[out] height,width The computed height and width of the cell
 */
void zathura_document_get_cell_size(zathura_document_t* document,
                                    unsigned int* height, unsigned int* width);

255
/**
256 257 258
 * Compute the size of the entire document to be displayed in pixels. Takes into
 * account the scale, the layout of the pages, and the padding between them. It
 * should be equal to the allocation of zathura->ui.page_widget once it's shown.
259 260 261 262 263 264 265
 *
 * @param[in]  document               The document
 * @param[out] height,width           The height and width of the document
 */
void zathura_document_get_document_size(zathura_document_t* document,
                                        unsigned int* height, unsigned int* width);

266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
/**
 * Sets the layout of the pages in the document
 *
 * @param[in]  document          The document instance
 * @param[in]  page_padding      pixels of padding between pages
 * @param[in]  pages_per_row     number of pages per row
 * @param[in]  first_page_column column of the first page (first column is 1)
 */
void zathura_document_set_page_layout(zathura_document_t* document, unsigned int page_padding,
                                      unsigned int pages_per_row, unsigned int first_page_column);

/**
 * Returns the padding in pixels betwen pages
 *
 * @param document The document
 * @return The padding in pixels between pages
 */
unsigned int zathura_document_get_page_padding(zathura_document_t* document);

/**
 * Returns the number of pages per row
 *
 * @param document The document
 * @return The number of pages per row
 */
unsigned int zathura_document_get_pages_per_row(zathura_document_t* document);

/**
 * Returns the column for the first page (first column = 1)
 *
 * @param document The document
 * @return The column for the first page
 */
unsigned int zathura_document_get_first_page_column(zathura_document_t* document);

Moritz Lipp's avatar
Moritz Lipp committed
301 302 303 304 305
/**
 * Save the document
 *
 * @param document The document object
 * @param path Path for the saved file
306 307
 * @return ZATHURA_ERROR_OK when no error occured, otherwise see
 *    zathura_error_t
Moritz Lipp's avatar
Moritz Lipp committed
308
 */
309
zathura_error_t zathura_document_save_as(zathura_document_t* document, const char* path);
Moritz Lipp's avatar
Moritz Lipp committed
310 311 312 313 314

/**
 * Generate the document index
 *
 * @param document The document object
315
 * @param error Set to an error value (see \ref zathura_error_t) if an
Moritz Lipp's avatar
Moritz Lipp committed
316
 *   error occured
Moritz Lipp's avatar
Moritz Lipp committed
317 318 319
 * @return Generated index
 */

320
girara_tree_node_t* zathura_document_index_generate(zathura_document_t* document, zathura_error_t* error);
Moritz Lipp's avatar
Moritz Lipp committed
321 322 323 324 325

/**
 * Get list of attachments
 *
 * @param document The document object
326
 * @param error Set to an error value (see \ref zathura_error_t) if an
Moritz Lipp's avatar
Moritz Lipp committed
327
 *   error occured
Moritz Lipp's avatar
Moritz Lipp committed
328 329
 * @return List of attachments
 */
330
girara_list_t* zathura_document_attachments_get(zathura_document_t* document, zathura_error_t* error);
Moritz Lipp's avatar
Moritz Lipp committed
331 332

/**
333
 * Save document attachment
Moritz Lipp's avatar
Moritz Lipp committed
334
 *
Sebastian Ramacher's avatar
Sebastian Ramacher committed
335 336 337
 * @param document The document objects
 * @param attachment name of the attachment
 * @param file the target filename
338 339
 * @return ZATHURA_ERROR_OK when no error occured, otherwise see
 *    zathura_error_t
Moritz Lipp's avatar
Moritz Lipp committed
340
 */
341
zathura_error_t zathura_document_attachment_save(zathura_document_t* document, const char* attachment, const char* file);
Moritz Lipp's avatar
Moritz Lipp committed
342

Moritz Lipp's avatar
Moritz Lipp committed
343 344 345 346
/**
 * Returns a string of the requested information
 *
 * @param document The zathura document
347
 * @param error Set to an error value (see \ref zathura_error_t) if an
Moritz Lipp's avatar
Moritz Lipp committed
348
 *   error occured
349
 * @return List of document information entries or NULL if information could not be retreived
Moritz Lipp's avatar
Moritz Lipp committed
350
 */
351
girara_list_t* zathura_document_get_information(zathura_document_t* document, zathura_error_t* error);
352

Moritz Lipp's avatar
Moritz Lipp committed
353
#endif // DOCUMENT_H