From db002b8b1592bfdcd0b9dd871e08f27a0676a686 Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Mon, 17 Feb 2025 16:24:17 +0300 Subject: [PATCH] Fix bug #72219 Fix loading of required fonts when executing InsertAndReplaceContentControls plugin method --- cell/api_plugins.js | 8 +------- common/macros.js | 19 +++++++++++++++++-- common/plugins.js | 22 ++-------------------- word/api.js | 9 +-------- 4 files changed, 21 insertions(+), 37 deletions(-) diff --git a/cell/api_plugins.js b/cell/api_plugins.js index e29fa05266..0545b64ec2 100644 --- a/cell/api_plugins.js +++ b/cell/api_plugins.js @@ -179,13 +179,7 @@ { for (let i = 0, len = arr.length; i < len; i++) { - try - { - AscCommon.safePluginEval(arr[i]["value"]); - } - catch (err) - { - } + AscCommon.safePluginEval(arr[i]["value"]); } } diff --git a/common/macros.js b/common/macros.js index 21d6331383..d1d1542959 100644 --- a/common/macros.js +++ b/common/macros.js @@ -438,7 +438,7 @@ function (window, undefined) window['AscCommon'].VbaProject = VbaProject; var _safe_eval_closure = new Function("Function", "Api", "window", "AscDesktopEditor", "alert", "document", "XMLHttpRequest", "self", "globalThis", "setTimeout", "setInterval", "value", "return eval(\"\\\"use strict\\\";\\r\\n\" + value)"); - window['AscCommon'].safePluginEval = function(value) { + function _safePluginEval(value) { let protoFunc = Object.getPrototypeOf(function(){}); // for minimization we use eval!!! let protoFuncGen = null; @@ -484,6 +484,21 @@ function (window, undefined) protoFuncGen.prototype.next = generatorNext; return result; }; - + window['AscCommon'].safePluginEval = function(value){ + let result; + let isCheckSymbols = AscFonts.IsCheckSymbols; + AscFonts.IsCheckSymbols = true; + try + { + result = _safePluginEval(value); + } + catch (err) + { + result = undefined; + console.error(err); + } + AscFonts.IsCheckSymbols = isCheckSymbols; + return result; + }; })(window); diff --git a/common/plugins.js b/common/plugins.js index 6b659de175..a8d9264f46 100644 --- a/common/plugins.js +++ b/common/plugins.js @@ -1459,33 +1459,15 @@ if (task.interface) { - try - { - AscCommon.safePluginEval(value); - } - catch (err) - { - console.error(err); - } + AscCommon.safePluginEval(value); } else if (!this.api.isLongAction() && (task.resize || this.api.canRunBuilderScript())) { this.api._beforeEvalCommand(); - AscFonts.IsCheckSymbols = true; - try - { - commandReturnValue = AscCommon.safePluginEval(value); - } - catch (err) - { - commandReturnValue = undefined; - console.error(err); - } + commandReturnValue = AscCommon.safePluginEval(value); if (!checkReturnCommand(commandReturnValue)) commandReturnValue = undefined; - - AscFonts.IsCheckSymbols = false; let _t = this; function onEndScript() diff --git a/word/api.js b/word/api.js index 898ac27d9d..4160fd2f8d 100644 --- a/word/api.js +++ b/word/api.js @@ -655,14 +655,7 @@ return; } - try - { - AscCommon.safePluginEval(_current["Script"]); - } - catch (err) - { - console.error(err); - } + AscCommon.safePluginEval(_current["Script"]); if (_isReplaced) _blockStd.MoveCursorToContentControl(false);