From bfd570038dd8a8745f958c48f78cd9929ab23ccd Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Fri, 17 Sep 2021 19:35:00 +0200 Subject: [PATCH] JS - Implement few possibilities with app.execMenuItem (bug 1724399) - it aims to fix: https://bugzilla.mozilla.org/show_bug.cgi?id=1724399. --- src/scripting_api/app.js | 20 ++++++++++++++++++-- web/pdf_scripting_manager.js | 27 +++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/scripting_api/app.js b/src/scripting_api/app.js index 53418eb4f..555d965ac 100644 --- a/src/scripting_api/app.js +++ b/src/scripting_api/app.js @@ -479,8 +479,24 @@ class App extends PDFObject { /* Not implemented */ } - execMenuItem() { - /* Not implemented */ + execMenuItem(item) { + switch (item) { + case "SaveAs": + case "FirstPage": + case "LastPage": + case "NextPage": + case "PrevPage": + case "ZoomViewIn": + case "ZoomViewOut": + this._send({ command: item }); + break; + case "FitPage": + this._send({ command: "zoom", value: "page-fit" }); + break; + case "Print": + this._send({ command: "print" }); + break; + } } getNthPlugInName() { diff --git a/web/pdf_scripting_manager.js b/web/pdf_scripting_manager.js index 85ac55cd4..ce21ac7eb 100644 --- a/web/pdf_scripting_manager.js +++ b/web/pdf_scripting_manager.js @@ -305,6 +305,33 @@ class PDFScriptingManager { } this._pdfViewer.currentScaleValue = value; break; + case "SaveAs": + this._eventBus.dispatch("save", { source: this }); + break; + case "FirstPage": + this._pdfViewer.currentPageNumber = 1; + break; + case "LastPage": + this._pdfViewer.currentPageNumber = this._pdfViewer.pagesCount; + break; + case "NextPage": + this._pdfViewer.nextPage(); + break; + case "PrevPage": + this._pdfViewer.previousPage(); + break; + case "ZoomViewIn": + if (isInPresentationMode) { + return; + } + this._eventBus.dispatch("zoomin", { source: this }); + break; + case "ZoomViewOut": + if (isInPresentationMode) { + return; + } + this._eventBus.dispatch("zoomout", { source: this }); + break; } return; }