Skip to content

Commit

Permalink
[de] Improve check for deleted permission range marks
Browse files Browse the repository at this point in the history
  • Loading branch information
KirillovIlya committed Nov 20, 2024
1 parent 14a1018 commit 982fb39
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 13 deletions.
4 changes: 4 additions & 0 deletions common/CollaborativeEditingBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,10 @@
CCollaborativeEditingBase.prototype.Add_DocumentPosition = function(DocumentPos){
this.m_aDocumentPositions.Add_DocumentPosition(DocumentPos);
};
CCollaborativeEditingBase.prototype.Remove_DocumentPosition = function(docPos)
{
this.m_aDocumentPositions.Remove_DocumentPosition(docPos);
};
CCollaborativeEditingBase.prototype.Add_ForeignCursor = function(UserId, DocumentPos, UserShortId){
this.m_aForeignCursorsPos.Remove_DocumentPosition(this.m_aCursorsToUpdate[UserId]);
this.m_aForeignCursors[UserId] = DocumentPos;
Expand Down
35 changes: 33 additions & 2 deletions word/Editor/Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -3252,9 +3252,40 @@ CDocument.prototype.private_FinalizeDeletingAnnotationsMarks = function()
{
let info = permMarks[rangeId];
if (info.start && info.end)
{
this.CollaborativeEditing.Remove_DocumentPosition(info.start.docPos);
this.CollaborativeEditing.Remove_DocumentPosition(info.end.docPos);
this.PermRangesManager.checkRange(rangeId);
continue;
}

let docPos = info.start ? info.start.docPos : info.end.docPos;
let mark = info.start ? info.start.mark : info.end.mark;

let actualMark = info.start ? this.PermRangesManager.getStartMark(rangeId) : this.PermRangesManager.getEndMark(rangeId);
if ((actualMark && actualMark !== mark) || mark.isUseInDocument())
{
this.CollaborativeEditing.Remove_DocumentPosition(docPos);
this.PermRangesManager.checkRange(rangeId);
continue;
}

this.CollaborativeEditing.Update_DocumentPosition(docPos);
let lastClass = docPos[docPos.length - 1].Class;

if (lastClass instanceof AscWord.Paragraph || lastClass instanceof AscWord.ParagraphContentWithParagraphLikeContent)
{
let newPosition = Math.min(lastClass.GetElementsCount(), Math.max(docPos[docPos.length - 1].Position, 0));
lastClass.AddToContent(newPosition, mark);
}
else
{
// TODO: Сделать ветку, если последний элемент Document/DocumentContent
// Ничего не делаем, отрезок должен удалиться на PermRangesManager.checkRange
}

this.CollaborativeEditing.Remove_DocumentPosition(docPos);
this.PermRangesManager.checkRange(rangeId);
}

this.LoadDocumentState(docState);
Expand Down Expand Up @@ -25822,11 +25853,11 @@ CDocument.prototype.OnDeleteAnnotationMark = function(mark)
if (!this.Action.Additional.DeletedAnnotationMarks)
this.Action.Additional.DeletedAnnotationMarks = {perm : {}, comments : {}, bookmarks : {}};

if (mark.isPerm())
if (mark.isPermMark())
{
let permMarks = this.Action.Additional.DeletedAnnotationMarks.perm;
let rangeId = mark.getRangeId();
if (permMarks[rangeId])
if (!permMarks[rangeId])
permMarks[rangeId] = {};

let docPos = mark.GetDocumentPositionFromObject();
Expand Down
8 changes: 4 additions & 4 deletions word/Editor/Paragraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -13599,15 +13599,15 @@ Paragraph.prototype.Split = function(oNewParagraph, oContentPos, isNoDuplicate)
// добавляем в начало нового параграфа.

var NewContent = this.Content.slice(nCurPos + 1);


this.Internal_Content_Remove2(nCurPos + 1, this.Content.length - nCurPos - 1);
this.CheckParaEnd();

// Очищаем новый параграф и добавляем в него Right элемент и NewContent
oNewParagraph.Internal_Content_Remove2(0, oNewParagraph.Content.length);
oNewParagraph.ConcatContent(NewContent);
oNewParagraph.Internal_Content_Add(0, NewElement);
oNewParagraph.CorrectContent();

this.Internal_Content_Remove2(nCurPos + 1, this.Content.length - nCurPos - 1);
this.CheckParaEnd();
}

if (false !== localTrack)
Expand Down
3 changes: 3 additions & 0 deletions word/Editor/ParagraphContentBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -4965,3 +4965,6 @@ function private_ParagraphContentChangesCheckLock(lockData)
lockData.lock();
}
}
//--------------------------------------------------------export----------------------------------------------------
AscWord.ParagraphContentBase = CParagraphContentBase;
AscWord.ParagraphContentWithParagraphLikeContent = CParagraphContentWithParagraphLikeContent;
27 changes: 21 additions & 6 deletions word/Editor/Serialize2.js
Original file line number Diff line number Diff line change
Expand Up @@ -12908,8 +12908,13 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, curNot
res = readMoveRangeStart(length, this.bcr, this.stream, this.oReadResult, null, false);
} else if (c_oSerDocTableType.MoveToRangeEnd === type && this.oReadResult.checkReadRevisions()) {
res = readMoveRangeEnd(length, this.bcr, this.stream, this.oReadResult, this.oReadResult.lastPar, true);
} else
res = c_oSerConstants.ReadUnknown;
} else if (c_oSerParType.PermStart === type) {
res = this.ReadPermStart(length, null);
} else if (c_oSerParType.PermEnd === type) {
res = this.ReadPermEnd(length, this.oReadResult.lastPar);
} else {
res = c_oSerConstants.ReadUnknown;
}
return res;
};
this.Read_Row = function(type, length, Row)
Expand Down Expand Up @@ -12961,8 +12966,13 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, curNot
res = readMoveRangeStart(length, this.bcr, this.stream, this.oReadResult, null, false);
} else if (c_oSerDocTableType.MoveToRangeEnd === type && this.oReadResult.checkReadRevisions()) {
res = readMoveRangeEnd(length, this.bcr, this.stream, this.oReadResult, this.oReadResult.lastPar, true);
} else
res = c_oSerConstants.ReadUnknown;
} else if (c_oSerParType.PermStart === type) {
res = this.ReadPermStart(length, null);
} else if (c_oSerParType.PermEnd === type) {
res = this.ReadPermEnd(length, this.oReadResult.lastPar);
} else {
res = c_oSerConstants.ReadUnknown;
}
return res;
};
this.ReadCell = function(type, length, cell)
Expand Down Expand Up @@ -13895,8 +13905,13 @@ function Binary_oMathReader(stream, oReadResult, curNote, openParams)
res = readMoveRangeStart(length, this.bcr, this.stream, this.oReadResult, paragraphContent, false);
} else if (c_oSer_OMathContentType.MoveToRangeEnd === type && this.oReadResult.checkReadRevisions()) {
res = readMoveRangeEnd(length, this.bcr, this.stream, this.oReadResult, paragraphContent);
} else
res = c_oSerConstants.ReadUnknown;
} else if (c_oSerParType.PermStart === type) {
res = this.ReadPermStart(length, null);
} else if (c_oSerParType.PermEnd === type) {
res = this.ReadPermEnd(length, this.oReadResult.lastPar);
} else {
res = c_oSerConstants.ReadUnknown;
}

if (oElem && bLast)
oElem.Correct_Content(false);
Expand Down
2 changes: 1 addition & 1 deletion word/Editor/annotations/annotation-mark-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
if (!paragraph)
return false;

return paragraph.IsUseInDocument();
return (paragraph && !!paragraph.Get_PosByElement(this));
};
AnnotationMarkBase.prototype.getParagraph = function()
{
Expand Down
8 changes: 8 additions & 0 deletions word/Editor/annotations/perm-ranges-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@

marksToCheck.length = 0;
};
/**
* Проверяем заданный отрезок, если он невалидный или пустой, тогда удаляем его из документа
* @param {number} rangeId
*/
PermRangesManager.prototype.checkRange = function(rangeId)
{
// TODO: implement
};

function registerPermRangeMark(mark)
{
Expand Down

0 comments on commit 982fb39

Please sign in to comment.