- gboolean swap, uniform, dual_even_left;
- int i;
- double uniform_height, page_height, next_page_height;
- double saved_height;
- gdouble u_width, u_height;
- gint n_pages;
-
- swap = (page_cache->rotation == 90 ||
- page_cache->rotation == 270);
-
- uniform = ev_document_is_page_size_uniform (page_cache->document);
- n_pages = ev_document_get_n_pages (page_cache->document);
- dual_even_left = (n_pages > 2);
-
- g_free (page_cache->height_to_page);
- g_free (page_cache->dual_height_to_page);
-
- page_cache->height_to_page = g_new0 (double, n_pages + 1);
- page_cache->dual_height_to_page = g_new0 (double, n_pages + 2);
-
- if (uniform)
- ev_document_get_page_size (page_cache->document, 0, &u_width, &u_height);
-
- saved_height = 0;
- for (i = 0; i <= n_pages; i++) {
- if (uniform) {
- uniform_height = swap ? u_width : u_height;
- page_cache->height_to_page[i] = i * uniform_height;
- } else {
- if (i < n_pages) {
- gdouble w, h;
-
- ev_document_get_page_size (page_cache->document, i, &w, &h);
- page_height = swap ? w : h;
- } else {
- page_height = 0;
- }
- page_cache->height_to_page[i] = saved_height;
- saved_height += page_height;
- }
- }