From 1af0df8e0173dca6f2256c68820c22747af356c1 Mon Sep 17 00:00:00 2001 From: Sergey Konovalov Date: Mon, 27 Jan 2025 18:35:35 +0300 Subject: [PATCH] [ve] Add print shortcut; Scroll by arrows; Fix bug 72817, 72690 --- visio/Drawing/HtmlPage.js | 1 + visio/api.js | 21 +++++++ visio/apiDefines.js | 4 ++ visio/model/VisioDocument.js | 109 +++++++++++++++++++++++++++++++++++ 4 files changed, 135 insertions(+) diff --git a/visio/Drawing/HtmlPage.js b/visio/Drawing/HtmlPage.js index 1db21fed7a..96d5530f0a 100644 --- a/visio/Drawing/HtmlPage.js +++ b/visio/Drawing/HtmlPage.js @@ -210,6 +210,7 @@ function CEditorPage(api) // thumbnails this.Thumbnails = new CThumbnailsManager();//todo override CThumbnailsManager this.Thumbnails.showContextMenu = function(bPosBySelect) {} + this.Thumbnails.onKeyDown = function(e) {return true;} // сплиттеры (для табнейлов и для заметок) this.Splitter1Pos = 0; diff --git a/visio/api.js b/visio/api.js index 0554930b7e..192b45f6b0 100644 --- a/visio/api.js +++ b/visio/api.js @@ -92,6 +92,15 @@ VisioEditorApi.prototype = Object.create(AscCommon.baseEditorsApi.prototype); VisioEditorApi.prototype.constructor = VisioEditorApi; + VisioEditorApi.prototype.initDefaultShortcuts = function() + { + // [[ActionType, KeyCode, Ctrl, Shift, Alt]] + var aShortcuts = + [ + [Asc.c_oAscDiagramShortcutType.Print, 80, true, false, false] + ]; + this.initShortcuts(aShortcuts, false) + }; VisioEditorApi.prototype.InitEditor = function(){ this.Document = new AscVisio.CVisioDocument(this, this.WordControl.m_oDrawingDocument); @@ -405,6 +414,18 @@ //todo return; } + VisioEditorApi.prototype.onKeyDown = function(e) + { + return this.WordControl.onKeyDown(e); + }; + VisioEditorApi.prototype.executeShortcut = function(type) + { + let logicDocument = this.private_GetLogicDocument(); + if (!logicDocument) + return false; + + return logicDocument.executeShortcut(type); + }; window["VisioEditorApi"] = VisioEditorApi; window["VisioEditorApi"].prototype["asc_nativeOpenFile"] = function(base64File, version) diff --git a/visio/apiDefines.js b/visio/apiDefines.js index deb68ec387..a337603ee7 100644 --- a/visio/apiDefines.js +++ b/visio/apiDefines.js @@ -36,7 +36,11 @@ var c_oSerFormat = { Version : 1, Signature : "VSDY" }; +const c_oAscDiagramShortcutType = { + Print : 1 +}; window['AscCommon'] = window['AscCommon'] || {}; window['AscCommon'].c_oSerFormat = c_oSerFormat; window['AscCommon'].CurFileVersion = c_oSerFormat.Version; +window['Asc']['c_oAscDiagramShortcutType'] = window['Asc'].c_oAscDiagramShortcutType = c_oAscDiagramShortcutType; diff --git a/visio/model/VisioDocument.js b/visio/model/VisioDocument.js index 92dcd75ed8..e170253d48 100644 --- a/visio/model/VisioDocument.js +++ b/visio/model/VisioDocument.js @@ -890,6 +890,9 @@ }; CVisioDocument.prototype.Document_UpdateRulersState = function () { }; + CVisioDocument.prototype.private_UpdateCursorXY = function (bUpdateX, bUpdateY) { + }; + CVisioDocument.prototype.OnMouseUp = function (e, X, Y, PageIndex) { }; CVisioDocument.prototype.OnMouseDown = function (e, X, Y, PageIndex) { @@ -921,6 +924,112 @@ CVisioDocument.prototype.shiftSlides = function (pos, array, bCopy) { //todo }; + CVisioDocument.prototype.executeShortcut = function(type) { + let result = false; + + switch (type) { + case Asc.c_oAscDiagramShortcutType.Print: { + this.api.onPrint(); + result = true; + break; + } + default: { + var oCustom = this.api.getCustomShortcutAction(type); + if (oCustom) { + if (AscCommon.c_oAscCustomShortcutType.Symbol === oCustom.Type) { + this.api["asc_insertSymbol"](oCustom.Font, oCustom.CharCode); + } + } + break; + } + } + return result; + } + CVisioDocument.prototype.OnKeyDown = function (e) { + this.api.sendEvent("asc_onBeforeKeyDown", e); + + var bUpdateSelection = true; + var bRetValue = keydownresult_PreventNothing; + let nStartHistoryIndex = this.History.Index; + + + // // Сбрасываем текущий элемент в поиске + // if (this.SearchEngine.Count > 0) + // this.SearchEngine.ResetCurrent(); + + let shortcutType = this.api.getShortcut(e); + if (this.executeShortcut(shortcutType)) + { + bRetValue = keydownresult_PreventAll; + bUpdateSelection = false; + } + else { + const bIsMacOs = AscCommon.AscBrowser.isMacOs; + let WordControl = this.api.WordControl; + if (e.KeyCode === 33) // PgUp + { + // + } + else if (e.KeyCode === 34) // PgDn + { + // + } + else if (e.KeyCode === 35) // клавиша End + { + if (true === e.CtrlKey) // Ctrl + End - переход в конец документа + { + WordControl.m_oScrollVerApi.scrollTo(WordControl.m_dScrollX_max, WordControl.m_dScrollY_max); + } + else + { + WordControl.m_oScrollVerApi.scrollTo(0, WordControl.m_dScrollY_max); + } + } + else if (e.KeyCode === 36) // клавиша Home + { + if (true === e.CtrlKey) // Ctrl + Home - переход в начало документа + { + WordControl.m_oScrollVerApi.scrollTo(WordControl.m_dScrollX_max, 0); + } + else + { + WordControl.m_oScrollVerApi.scrollTo(0, 0); + } + } + else if (e.KeyCode === 37) // Left Arrow + { + if (true || WordControl.m_bIsHorScrollVisible) + { + WordControl.m_oScrollHorApi.scrollBy(-30, 0, false); + } + } + else if (e.KeyCode === 38) // Top Arrow + { + WordControl.m_oScrollVerApi.scrollBy(0, -30, false); + } + else if (e.KeyCode === 39) // Right Arrow + { + if (true || WordControl.m_bIsHorScrollVisible) + { + WordControl.m_oScrollHorApi.scrollBy(30, 0, false); + } + } + else if (e.KeyCode === 40) // Bottom Arrow + { + WordControl.m_oScrollVerApi.scrollBy(0, 30, false); + } + } + + if (bRetValue & keydownflags_PreventKeyPress && true === bUpdateSelection) + this.Document_UpdateSelectionState(); + + if(nStartHistoryIndex === this.History.Index) { + this.private_UpdateCursorXY(true, true); + } + + this.api.sendEvent("asc_onKeyDown", e); + return bRetValue; + }; // CVisioDocument.prototype.getMasterByID = function(ID) { // // join Master_Type and MasterContents_Type // let masterFromMastersArray = this.masters.master;