From ba94bb7313f6c67c87574cfd57487176dbc8ca2f Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Thu, 15 Sep 2022 17:31:45 +0300 Subject: [PATCH] Block insert and change images in frame editor for 7.2.0 --- cell/api.js | 3 +++ cell/model/clipboard.js | 21 ++++++++++----------- cell/view/WorksheetView.js | 2 +- common/apiBase.js | 3 ++- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/cell/api.js b/cell/api.js index 88451ed94c..26db5275e3 100644 --- a/cell/api.js +++ b/cell/api.js @@ -4508,6 +4508,9 @@ var editor; if (!this.canEdit()) { return; } + if (this.isFrameEditor() && !AscCommon.isNullOrEmptyString(props.ImageUrl)) { + props.ImageUrl = null; + } var ws = this.wb.getWorksheet(); var fReplaceCallback = null, sImageUrl = null, sToken = undefined; if(!AscCommon.isNullOrEmptyString(props.ImageUrl)){ diff --git a/cell/model/clipboard.js b/cell/model/clipboard.js index 17db747c22..754ba769a4 100644 --- a/cell/model/clipboard.js +++ b/cell/model/clipboard.js @@ -867,7 +867,7 @@ }, _generateHtmlImg: function (isSelectedImages, worksheet) { - if (window["Asc"]["editor"] && window["Asc"]["editor"].isChartEditor) { + if (window["Asc"]["editor"] && window["Asc"]["editor"].isFrameEditor()) { return false; } let objectRender = worksheet.objectRender; @@ -1705,7 +1705,7 @@ if(isPasteAll) { doPasteData(); } - } else if (!(window["Asc"]["editor"] && window["Asc"]["editor"].isChartEditor)) { + } else if (!(window["Asc"]["editor"] && (window["Asc"]["editor"].isChartEditor || window["Asc"]["editor"].isEditOleMode && aPastedImages && aPastedImages.length))) { newFonts = {}; for (var i = 0; i < pasteData.Drawings.length; i++) { @@ -2012,7 +2012,7 @@ } var arr_shapes = content.Drawings; - if (arr_shapes && arr_shapes.length && !(window["Asc"]["editor"] && window["Asc"]["editor"].isChartEditor)) { + if (arr_shapes && arr_shapes.length && !(window["Asc"]["editor"] && (window["Asc"]["editor"].isChartEditor || window["Asc"]["editor"].isEditOleMode && arr_Images.length !== 0))) { if (!bSlideObjects && content.Drawings.length === selectedContent2[1].content.Drawings.length) { var oEndContent = { Drawings: [] @@ -2744,10 +2744,10 @@ var aImagesToDownload = this._getImageFromHtml(node, true); var specialPasteProps = window['AscCommon'].g_specialPasteHelper.specialPasteProps; - if (aImagesToDownload !== null && + var api = Asc["editor"]; + if (!api.isFrameEditor() && aImagesToDownload !== null && (!specialPasteProps || (specialPasteProps && specialPasteProps.images)))//load to server { - var api = Asc["editor"]; AscCommon.sendImgUrls(api, aImagesToDownload, function (data) { for (var i = 0, length = Math.min(data.length, aImagesToDownload.length); i < length; ++i) { var elem = data[i]; @@ -3383,7 +3383,7 @@ } } var aResult = this._getTableFromText(text, textImport); - if (aResult && !(aResult.onlyImages && window["Asc"]["editor"] && window["Asc"]["editor"].isChartEditor)) { + if (aResult && !(aResult.onlyImages && window["Asc"]["editor"] && window["Asc"]["editor"].isFrameEditor())) { if (textImport) { var arn = worksheet.model.selectionRange.getLast().clone(); var width = aResult.content && aResult.content[0] ? aResult.content[0].length - 1 : 0; @@ -3802,10 +3802,11 @@ var documentContentBounds = new DocumentContentBounds(); var coverDocument = documentContentBounds.getBounds(0, 0, documentContent); this._parseChildren(coverDocument); + var aImagesToDownload = pasteData.images && pasteData.images.length ? pasteData.images : this.aResult.props._images; //не вставляем графику в редактор диаграмм //если кроме графики есть ещё данные, то убираем только графику - if (window["Asc"]["editor"] && window["Asc"]["editor"].isChartEditor) { + if (window["Asc"]["editor"] && (window["Asc"]["editor"].isChartEditor || window["Asc"]["editor"].isEditOleMode && aImagesToDownload && aImagesToDownload.length)) { if (this.aResult.props && this.aResult.props.addImagesFromWord && this.aResult.props.addImagesFromWord.length === 1 && this.aResult.content) { if (1 === this.aResult.content.length && 1 === this.aResult.content[0].length && this.aResult.content[0][0].content && this.aResult.content[0][0].content.length === 0) { window['AscCommon'].g_specialPasteHelper.Paste_Process_End(); @@ -3824,11 +3825,10 @@ newFonts[pasteData.fonts[i].name] = 1; } } - this.aResult.props.fontsNew = newFonts; this.aResult.props.rowSpanSpCount = 0; this.aResult.props.cellCount = this.maxCellCount + 1 > coverDocument.width ? this.maxCellCount + 1 : coverDocument.width; - this.aResult.props._images = pasteData.images && pasteData.images.length ? pasteData.images : this.aResult.props._images; + this.aResult.props._images = aImagesToDownload; this.aResult.props._aPastedImages = pasteData.aPastedImages && pasteData.aPastedImages.length ? pasteData.aPastedImages : this.aResult.props._aPastedImages; @@ -3837,8 +3837,7 @@ //грузим картинки для вствки из документов(если это необходимо) //в данный момент в worksheetView не грузятся изображения var specialPasteProps = window['AscCommon'].g_specialPasteHelper.specialPasteProps; - var aImagesToDownload = this.aResult.props._images; - if (!this.clipboard.alreadyLoadImagesOnServer && aImagesToDownload && (!specialPasteProps || (specialPasteProps && specialPasteProps.images)))//load to server + if (!this.clipboard.alreadyLoadImagesOnServer && aImagesToDownload && aImagesToDownload.length && (!specialPasteProps || (specialPasteProps && specialPasteProps.images)))//load to server { var oObjectsForDownload = AscCommon.GetObjectsForImageDownload(t.aResult.props._aPastedImages); var api = window["Asc"]["editor"]; diff --git a/cell/view/WorksheetView.js b/cell/view/WorksheetView.js index eef0a62618..29e730504f 100644 --- a/cell/view/WorksheetView.js +++ b/cell/view/WorksheetView.js @@ -13071,7 +13071,7 @@ }); } else { var imagesFromWord = pasteContent.props.addImagesFromWord; - if (imagesFromWord && imagesFromWord.length !== 0 && !(window["Asc"]["editor"] && window["Asc"]["editor"].isChartEditor) && specialPasteProps.images) { + if (imagesFromWord && imagesFromWord.length !== 0 && !(window["Asc"]["editor"] && window["Asc"]["editor"].isFrameEditor()) && specialPasteProps.images) { var oObjectsForDownload = AscCommon.GetObjectsForImageDownload(pasteContent.props._aPastedImages); var oImageMap; diff --git a/common/apiBase.js b/common/apiBase.js index e9bce56532..ff42c6ba78 100644 --- a/common/apiBase.js +++ b/common/apiBase.js @@ -395,7 +395,7 @@ return null; }; baseEditorsApi.prototype.isFrameEditor = function () { - return !!(this.isChartEditor || this.isOleEditor); + return !!(this.isChartEditor || this.isEditOleMode); // TODO: solve the confusion }; baseEditorsApi.prototype.asc_setCoreProps = function(oProps) { @@ -1955,6 +1955,7 @@ }; baseEditorsApi.prototype.asc_addImage = function(obj) { + if (this.isFrameEditor()) return; //TODO: Fix in 7.2.1 var t = this; if (this.WordControl) // после показа диалога может не прийти mouseUp this.WordControl.m_bIsMouseLock = false;