#include "pdf-document.h"
#include "ev-ps-exporter.h"
#include "ev-document-find.h"
+#include "ev-document-misc.h"
#include "gpdf-g-switch.h"
#include "ev-document-links.h"
-#include "ev-document-misc.h"
#include "ev-document-security.h"
#include "ev-document-thumbnails.h"
UnicodeMap *umap;
gchar *password;
- gboolean page_valid;
PdfDocumentSearch *search;
};
obj.free ();
}
-static gboolean
-document_validate_page (PdfDocument *pdf_document)
+static void
+document_display_page (PdfDocument *pdf_document)
{
- if (!pdf_document->page_valid) {
- pdf_document->doc->displayPage (pdf_document->out, pdf_document->page,
- 72 * pdf_document->scale,
- 72 * pdf_document->scale,
- 0, gTrue, gTrue);
-
- document_init_links (pdf_document);
+ pdf_document->doc->displayPage (pdf_document->out, pdf_document->page,
+ 72 * pdf_document->scale,
+ 72 * pdf_document->scale,
+ 0, gTrue, gTrue);
- pdf_document->page_valid = TRUE;
+ document_init_links (pdf_document);
- ev_document_changed (EV_DOCUMENT (pdf_document));
-
- /* Update the search results available to the app since
- * we only provide full results on the current page
- */
- if (pdf_document->search)
- pdf_document_search_page_changed (pdf_document->search);
- }
-
- return pdf_document->page_valid;
+ /* Update the search results available to the app since
+ * we only provide full results on the current page
+ */
+ if (pdf_document->search)
+ pdf_document_search_page_changed (pdf_document->search);
}
static gboolean
if (pdf_document->out)
pdf_document->out->startDoc(pdf_document->doc->getXRef());
- pdf_document->page_valid = FALSE;
-
g_object_notify (G_OBJECT (pdf_document), "title");
return TRUE;
if (page != pdf_document->page) {
pdf_document->page = page;
- pdf_document->page_valid = FALSE;
+ document_display_page (pdf_document);
+ ev_document_page_changed (EV_DOCUMENT (pdf_document));
}
}
}
- pdf_document->page_valid = FALSE;
+ /* FIXME we need to regenerate pages */
}
}
if (pdf_document->scale != scale) {
pdf_document->scale = scale;
- pdf_document->page_valid = FALSE;
+ document_display_page (pdf_document);
+ ev_document_scale_changed (EV_DOCUMENT (pdf_document));
}
}
static void
pdf_document_get_page_size (EvDocument *document,
+ int page,
int *width,
int *height)
{
PdfDocument *pdf_document = PDF_DOCUMENT (document);
+ Page *the_page;
- if (document_validate_page (pdf_document)) {
- if (width)
- *width = pdf_document->out->getBitmapWidth();
- if (height)
- *height = pdf_document->out->getBitmapHeight();
- } else {
- if (width)
- *width = 1;
- if (height)
- *height = 1;
+ /* set some default values */
+ if (width)
+ *width = 1;
+ if (height)
+ *height = 1;
+
+ if (page == -1)
+ page = pdf_document->page;
+
+ the_page = pdf_document->doc->getCatalog ()->getPage (page);
+ if (the_page) {
+ *width = (int) ((the_page->getWidth () * pdf_document->scale) + 0.5);
+ *height = (int) ((the_page->getHeight () * pdf_document->scale) + 0.5);
}
}
GdkRectangle page;
GdkRectangle draw;
- if (!document_validate_page (pdf_document) || !pdf_document->target)
+ if (!pdf_document->target)
return;
page.x = pdf_document->page_x_offset;
double
pdf_document_find_get_progress (EvDocumentFind *document_find)
{
- PdfDocumentSearch *search = PDF_DOCUMENT (document_find)->search;
+ PdfDocumentSearch *search;
int n_pages, pages_done;
-
+
+ search = PDF_DOCUMENT (document_find)->search;
+
+ if (search == NULL) {
+ return 0;
+ }
+
n_pages = ev_document_get_n_pages (EV_DOCUMENT (document_find));
if (search->search_page > search->start_page) {
- pages_done = search->search_page - search->start_page;
+ pages_done = search->search_page - search->start_page + 1;
} else if (search->search_page == search->start_page) {
pages_done = n_pages;
} else {
PdfDocumentSearch *search = pdf_document->search;
GdkRectangle r;
- if (search != NULL) {
+ if (search != NULL &&
+ n_result < search->current_page_results->len) {
r = g_array_index (search->current_page_results,
GdkRectangle, n_result);
current_page = pdf_document->page;
- if (!pdf_document->page_valid) {
- /* we can't do anything until displayPage() */
- search->current_page = -1;
- return;
- }
-
if (search->current_page == current_page)
return;
}
static void
-pdf_document_find_cancel (EvDocumentFind *document)
+pdf_document_find_cancel (EvDocumentFind *document)
{
PdfDocument *pdf_document = PDF_DOCUMENT (document);
{
EvLink *link = NULL;
- if (link_action == NULL) {
- link = ev_link_new_title (title);
+ if (link_action->getKind () == actionGoToR) {
+ g_warning ("actionGoToR links not implemented");
+ } else if (link_action->getKind () == actionLaunch) {
+ g_warning ("actionLaunch links not implemented");
+ } else if (link_action->getKind () == actionNamed) {
+ g_warning ("actionNamed links not implemented");
+ } else if (link_action->getKind () == actionMovie) {
+ g_warning ("actionMovie links not implemented");
} else if (link_action->getKind () == actionGoTo) {
LinkDest *link_dest;
LinkGoTo *link_goto;
link_uri = dynamic_cast <LinkURI *> (link_action);
link = ev_link_new_external
(title, link_uri->getURI()->getCString());
- } else if (link_action->getKind () == actionNamed) {
- /*Skip, for now */
+ } else if (link_action->getKind () == actionUnknown) {
+ LinkUnknown *link_unknown;
+
+ link_unknown = dynamic_cast <LinkUnknown *> (link_action);
+
+ g_warning ("Unknown link type %s",
+ link_unknown->getAction()->getCString());
+ }
+
+ if (link == NULL) {
+ link = ev_link_new_title (title);
}
return link;
const char *text;
int x1, y1, x2, y2;
- x1 = rect->x + pdf_document->page_x_offset;
- y1 = rect->y + pdf_document->page_y_offset;
- x2 = x1 + rect->width + pdf_document->page_x_offset;
- y2 = y1 + rect->height + pdf_document->page_y_offset;
+ x1 = rect->x - pdf_document->page_x_offset;
+ y1 = rect->y - pdf_document->page_y_offset;
+ x2 = x1 + rect->width;
+ y2 = y1 + rect->height;
sel_text = pdf_document->out->getText (x1, y1, x2, y2);
text = sel_text->getCString ();
iface->get_n_results = pdf_document_find_get_n_results;
iface->get_result = pdf_document_find_get_result;
iface->page_has_results = pdf_document_find_page_has_results;
+ iface->get_progress = pdf_document_find_get_progress;
iface->cancel = pdf_document_find_cancel;
}
Thumb *thumb = NULL;
gdouble page_ratio;
- /* getPage seems to want page + 1 for some reason; */
- the_page = pdf_document->doc->getCatalog ()->getPage (page + 1);
+ the_page = pdf_document->doc->getCatalog ()->getPage (page);
the_page->getThumb (&the_thumb);
if (!(the_thumb.isNull () || the_thumb.isNone())) {
pdf_document->page_y_offset = 0;
pdf_document->scale = 1.;
- pdf_document->page_valid = FALSE;
pdf_document->password = NULL;
}