Beispiel #1
0
girara_tree_node_t*
pdf_document_index_generate(zathura_document_t* document, void* data, zathura_error_t* error)
{
  mupdf_document_t* mupdf_document = data;

  if (document == NULL || mupdf_document == NULL) {
    if (error != NULL) {
      *error = ZATHURA_ERROR_INVALID_ARGUMENTS;
    }
    return NULL;
  }

  /* get outline */
  fz_outline* outline = fz_load_outline(mupdf_document->ctx, mupdf_document->document);
  if (outline == NULL) {
    if (error != NULL) {
      *error = ZATHURA_ERROR_UNKNOWN;
    }
    return NULL;
  }

  /* generate index */
  girara_tree_node_t* root = girara_node_new(zathura_index_element_new("ROOT"));
  build_index(mupdf_document->ctx, mupdf_document->document, outline, root);

  /* free outline */
  fz_drop_outline(mupdf_document->ctx, outline);

  return root;
}
Beispiel #2
0
girara_tree_node_t*
cb_document_index_generate(zathura_document_t* document,
                           cb_document_t* cb_document, zathura_error_t* error)
{
  if (document == NULL || cb_document == NULL) {
    if (error != NULL) {
      *error = ZATHURA_ERROR_INVALID_ARGUMENTS;
    }
    return NULL;
  }

  girara_tree_node_t* root = girara_node_new(zathura_index_element_new("ROOT"));
  unsigned int page_number = 0;
  GIRARA_LIST_FOREACH(cb_document->pages, cb_document_page_meta_t*, iter, page)
  {
    gchar* markup = g_markup_escape_text(page->file, -1);
    zathura_index_element_t* index_element = zathura_index_element_new(markup);
    g_free(markup);

    if (index_element != NULL) {
      zathura_rectangle_t rect = { 0, 0, 0, 0 };
      zathura_link_target_t target = { ZATHURA_LINK_DESTINATION_XYZ, NULL,
        page_number, -1, -1, -1, -1, 0 };

      index_element->link = zathura_link_new(ZATHURA_LINK_GOTO_DEST, rect,
          target);
      girara_node_append_data(root, index_element);
    }
    ++page_number;
  }
  GIRARA_LIST_FOREACH_END(cb_document->pages, cb_document_page_meta_t*, iter, page);

  return root;
}
Beispiel #3
0
girara_tree_node_t*
djvu_document_index_generate(zathura_document_t* document, djvu_document_t*
    djvu_document, zathura_error_t* error)
{
  if (document == NULL || djvu_document == NULL) {
    if (error != NULL) {
      *error = ZATHURA_ERROR_INVALID_ARGUMENTS;
    }
    return NULL;
  }

  miniexp_t outline = miniexp_dummy;
  while ((outline = ddjvu_document_get_outline(djvu_document->document)) ==
      miniexp_dummy) {
    handle_messages(djvu_document, true);
  }

  if (outline == miniexp_dummy) {
    return NULL;
  }

  if (miniexp_consp(outline) == 0 || miniexp_car(outline) != miniexp_symbol("bookmarks")) {
    ddjvu_miniexp_release(djvu_document->document, outline);
    return NULL;
  }

  girara_tree_node_t* root = girara_node_new(zathura_index_element_new("ROOT"));
  build_index(djvu_document, miniexp_cdr(outline), root);

  ddjvu_miniexp_release(djvu_document->document, outline);

  return root;
}