Skip to content

Commit

Permalink
Block insert and change images in frame editor for 7.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Privezenov committed Sep 15, 2022
1 parent d27aa90 commit ba94bb7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
3 changes: 3 additions & 0 deletions cell/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)){
Expand Down
21 changes: 10 additions & 11 deletions cell/model/clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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++) {
Expand Down Expand Up @@ -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: []
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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;


Expand All @@ -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"];
Expand Down
2 changes: 1 addition & 1 deletion cell/view/WorksheetView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion common/apiBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ba94bb7

Please sign in to comment.