From 6495312d30d9c558810d557b366d1e45bca8bc0e Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Thu, 21 Nov 2024 16:49:06 +0300 Subject: [PATCH] [de] Remove all permission range marks when copying selected content --- word/Editor/Paragraph.js | 12 ++++++++++++ word/Editor/ParagraphContentBase.js | 17 +++++++++++++++++ word/Editor/SelectedContent.js | 15 +++++++++++++++ word/Editor/annotations/paragraph-perm.js | 4 ++++ 4 files changed, 48 insertions(+) diff --git a/word/Editor/Paragraph.js b/word/Editor/Paragraph.js index 285a462f3b..84445246fd 100644 --- a/word/Editor/Paragraph.js +++ b/word/Editor/Paragraph.js @@ -611,6 +611,18 @@ Paragraph.prototype.GetAllParaMaths = function(arrParaMaths) return arrParaMaths; }; +Paragraph.prototype.GetAllPermRangeMarks = function(marks) +{ + if (!marks) + marks = []; + + for (let i = 0, count = this.Content.length; i < count; ++i) + { + this.Content[i].GetAllPermRangeMarks(marks); + } + + return marks; +}; Paragraph.prototype.GetAllSeqFieldsByType = function(sType, aFields) { diff --git a/word/Editor/ParagraphContentBase.js b/word/Editor/ParagraphContentBase.js index d6f3aeb564..48e770e9d0 100644 --- a/word/Editor/ParagraphContentBase.js +++ b/word/Editor/ParagraphContentBase.js @@ -966,6 +966,11 @@ CParagraphContentBase.prototype.createDuplicateForSmartArt = function(oPr) */ CParagraphContentBase.prototype.CalculateTextToTable = function(oEngine){}; +CParagraphContentBase.prototype.GetAllPermRangeMarks = function(marks) +{ + return []; +}; + /** * Это базовый класс для элементов содержимого(контент) параграфа, у которых есть свое содержимое. * @constructor @@ -2409,6 +2414,18 @@ CParagraphContentWithParagraphLikeContent.prototype.Get_Text = function(Text) this.Content[CurPos].Get_Text( Text ); } }; +CParagraphContentWithParagraphLikeContent.prototype.GetAllPermRangeMarks = function(marks) +{ + if (!marks) + marks = []; + + for (let i = 0, count = this.Content.length; i < count; ++i) + { + this.Content[i].GetAllPermRangeMarks(marks); + } + + return marks; +}; CParagraphContentWithParagraphLikeContent.prototype.GetAllParagraphs = function(Props, ParaArray) { var ContentLen = this.Content.length; diff --git a/word/Editor/SelectedContent.js b/word/Editor/SelectedContent.js index cd18ef0d75..c8e3befa1b 100644 --- a/word/Editor/SelectedContent.js +++ b/word/Editor/SelectedContent.js @@ -52,6 +52,7 @@ this.Comments = []; this.CommentsMarks = {}; this.Maths = []; + this.PermRangeMarks = []; this.LogicDocument = null; @@ -91,6 +92,7 @@ this.DrawingObjects = []; this.Comments = []; this.Maths = []; + this.PermRangeMarks = []; this.MoveDrawing = false; @@ -104,6 +106,7 @@ this.private_CollectObjects(); this.private_CheckComments(oLogicDocument); this.private_CheckTrackMove(oLogicDocument); + this.private_CheckPermRangeMarks(oLogicDocument); }; CSelectedContent.prototype.SetNewCommentsGuid = function(isNew) { @@ -534,6 +537,7 @@ oParagraph.GetAllDrawingObjects(this.DrawingObjects); oParagraph.GetAllComments(this.Comments); oParagraph.GetAllMaths(this.Maths); + oParagraph.GetAllPermRangeMarks(this.PermRangeMarks); } if (oElement.IsParagraph() && nCount > 1) @@ -678,6 +682,17 @@ oLogicDocument.TrackMoveId = null; } }; + CSelectedContent.prototype.private_CheckPermRangeMarks = function(logicDocument) + { + // TODO: Пока мы удаляем все метки. В будущем надо сделать, что если скопированы начало и конец, то мы + // приписываем им новый id диапазона, а если скопировано только начала или конец, то удаляем такие метки + + for (let markIndex = 0, markCount = this.PermRangeMarks.length; markIndex < markCount; ++markIndex) + { + let mark = this.PermRangeMarks[markIndex]; + mark.removeMark(); + } + }; CSelectedContent.prototype.private_CreateNewCommentsGuid = function() { let oManager = this.LogicDocument.GetCommentsManager(); diff --git a/word/Editor/annotations/paragraph-perm.js b/word/Editor/annotations/paragraph-perm.js index 915c49259e..93eb989e7f 100644 --- a/word/Editor/annotations/paragraph-perm.js +++ b/word/Editor/annotations/paragraph-perm.js @@ -75,6 +75,10 @@ CParagraphContentBase.prototype.SetParagraph.call(this, p); AscWord.registerPermRangeMark(this); }; + ParagraphPermBase.prototype.GetAllPermRangeMarks = function(marks) + { + marks.push(this); + }; ParagraphPermBase.prototype.isPermMark = function() { return true;