Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for mupdf 1.23 #831

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions pdf_viewer/document_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ std::vector<DocumentPos> DocumentView::find_line_definitions() {

std::optional<PdfLink> pdf_link = current_document->get_link_in_page_rect(get_center_page_number(), line_rects[line_index]);
if (pdf_link.has_value()) {
auto parsed_uri = parse_uri(mupdf_context, pdf_link.value().uri);
auto parsed_uri = parse_uri(mupdf_context, current_document->doc, pdf_link.value().uri);
result.push_back({ parsed_uri.page - 1, parsed_uri.x, parsed_uri.y });
return result;
}
Expand Down Expand Up @@ -1217,7 +1217,7 @@ void DocumentView::get_visible_links(std::vector<std::pair<int, fz_link*>>& visi
for (auto page : visible_pages) {
fz_link* link = get_document()->get_page_links(page);
while (link) {
ParsedUri parsed_uri = parse_uri(mupdf_context, link->uri);
ParsedUri parsed_uri = parse_uri(mupdf_context, get_document()->doc, link->uri);
fz_rect window_rect = document_to_window_rect(page, link->rect);
if ((window_rect.x0 >= -1) && (window_rect.x0 <= 1) && (window_rect.y0 >= -1) && (window_rect.y0 <= 1)) {
visible_page_links.push_back(std::make_pair(page, link));
Expand Down
8 changes: 4 additions & 4 deletions pdf_viewer/main_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void MainWidget::set_overview_position(int page, float offset) {

void MainWidget::set_overview_link(PdfLink link) {

auto [page, offset_x, offset_y] = parse_uri(mupdf_context, link.uri);
auto [page, offset_x, offset_y] = parse_uri(mupdf_context, doc()->doc, link.uri);
if (page >= 1) {
set_overview_position(page - 1, offset_y);
}
Expand Down Expand Up @@ -2771,7 +2771,7 @@ void MainWidget::handle_link_click(const PdfLink& link) {
return;
}

auto [page, offset_x, offset_y] = parse_uri(mupdf_context, link.uri);
auto [page, offset_x, offset_y] = parse_uri(mupdf_context, doc()->doc, link.uri);

// convert one indexed page to zero indexed page
page--;
Expand Down Expand Up @@ -3920,7 +3920,7 @@ void MainWidget::handle_portal_to_link(const std::wstring& text) {
PdfLink pdf_link;
pdf_link.rect = link->rect;
pdf_link.uri = link->uri;
ParsedUri parsed_uri = parse_uri(mupdf_context, pdf_link.uri);
ParsedUri parsed_uri = parse_uri(mupdf_context, doc()->doc, pdf_link.uri);

//AbsoluteDocumentPos abspos = doc()->document_to_absolute_pos(defpos[0], true);
DocumentPos link_source_document_pos;
Expand Down Expand Up @@ -3959,7 +3959,7 @@ void MainWidget::handle_open_link(const std::wstring& text, bool copy) {
open_web_url(utf8_decode(selected_link->uri));
}
else {
auto [page, offset_x, offset_y] = parse_uri(mupdf_context, selected_link->uri);
auto [page, offset_x, offset_y] = parse_uri(mupdf_context, doc()->doc, selected_link->uri);
long_jump_to_destination(page - 1, offset_y);
}
}
Expand Down
5 changes: 3 additions & 2 deletions pdf_viewer/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ bool rects_intersect(fz_rect rect1, fz_rect rect2) {
return range_intersects(rect1.x0, rect1.x1, rect2.x0, rect2.x1) && range_intersects(rect1.y0, rect1.y1, rect2.y0, rect2.y1);
}

ParsedUri parse_uri(fz_context* mupdf_context, std::string uri) {
fz_link_dest dest = pdf_parse_link_uri(mupdf_context, uri.c_str());
ParsedUri parse_uri(fz_context* mupdf_context, fz_document* fz_doc, std::string uri) {
pdf_document* doc = pdf_document_from_fz_document(mupdf_context, fz_doc);
fz_link_dest dest = pdf_resolve_link_dest(mupdf_context, doc, uri.c_str());
return { dest.loc.page + 1, dest.x, dest.y };
}

Expand Down
2 changes: 1 addition & 1 deletion pdf_viewer/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void get_flat_toc(const std::vector<TocNode*>& roots, std::vector<std::wstring>&
int mod(int a, int b);
bool range_intersects(float range1_start, float range1_end, float range2_start, float range2_end);
bool rects_intersect(fz_rect rect1, fz_rect rect2);
ParsedUri parse_uri(fz_context* mupdf_context, std::string uri);
ParsedUri parse_uri(fz_context* mupdf_context, fz_document* fz_doc, std::string uri);
char get_symbol(int key, bool is_shift_pressed, const std::vector<char>&special_symbols);

template<typename T>
Expand Down