Commit 7b71afd2 authored by Alexander.Trofimov's avatar Alexander.Trofimov

fix bug 33377

add copy comments with move range
parent 23e9cd4f
...@@ -357,40 +357,45 @@ asc_CCommentData.prototype = { ...@@ -357,40 +357,45 @@ asc_CCommentData.prototype = {
} }
}; };
function CompositeCommentData() { function CompositeCommentData() {
this.commentBefore = null; this.commentBefore = null;
this.commentAfter = null; this.commentAfter = null;
this.Properties = { this.Properties = {
commentBefore: 0, commentBefore: 0, commentAfter: 1
commentAfter: 1
}; };
} }
CompositeCommentData.prototype = {
// For collaborative editing CompositeCommentData.prototype.getType = function () {
getType: function() {
return AscCommonExcel.UndoRedoDataTypes.CompositeCommentData; return AscCommonExcel.UndoRedoDataTypes.CompositeCommentData;
}, };
getProperties: function() { CompositeCommentData.prototype.getProperties = function () {
return this.Properties; return this.Properties;
}, };
getProperty: function(nType) { CompositeCommentData.prototype.getProperty = function (nType) {
switch (nType) { switch (nType) {
case this.Properties.commentBefore: return this.commentBefore; break; case this.Properties.commentBefore:
case this.Properties.commentAfter: return this.commentAfter; break; return this.commentBefore;
break;
case this.Properties.commentAfter:
return this.commentAfter;
break;
} }
return null; return null;
}, };
setProperty: function(nType, value) { CompositeCommentData.prototype.setProperty = function (nType, value) {
switch (nType) { switch (nType) {
case this.Properties.commentBefore: this.commentBefore = value; break; case this.Properties.commentBefore:
case this.Properties.commentAfter: this.commentAfter = value; break; this.commentBefore = value;
} break;
case this.Properties.commentAfter:
this.commentAfter = value;
break;
} }
}; };
/** @constructor */ /** @constructor */
function CCellCommentator(currentSheet) { function CCellCommentator(currentSheet) {
...@@ -419,7 +424,6 @@ CCellCommentator.sStartCommentId = 'comment_'; ...@@ -419,7 +424,6 @@ CCellCommentator.sStartCommentId = 'comment_';
CCellCommentator.prototype.isViewerMode = function () { CCellCommentator.prototype.isViewerMode = function () {
return this.worksheet.handlers.trigger("getViewerMode"); return this.worksheet.handlers.trigger("getViewerMode");
}; };
CCellCommentator.prototype.isLockedComment = function(oComment, callbackFunc) { CCellCommentator.prototype.isLockedComment = function(oComment, callbackFunc) {
var objectGuid = oComment.asc_getId(); var objectGuid = oComment.asc_getId();
if (objectGuid) { if (objectGuid) {
...@@ -454,8 +458,8 @@ CCellCommentator.prototype.isLockedComment = function(oComment, callbackFunc) { ...@@ -454,8 +458,8 @@ CCellCommentator.prototype.isLockedComment = function(oComment, callbackFunc) {
} }
}; };
CCellCommentator.prototype.moveRangeComments = function(rangeFrom, rangeTo) { CCellCommentator.prototype.moveRangeComments = function (rangeFrom, rangeTo, copy) {
if ( rangeFrom && rangeTo ) { if (rangeFrom && rangeTo) {
var colOffset = rangeTo.c1 - rangeFrom.c1; var colOffset = rangeTo.c1 - rangeFrom.c1;
var rowOffset = rangeTo.r1 - rangeFrom.r1; var rowOffset = rangeTo.r1 - rangeFrom.r1;
...@@ -464,11 +468,15 @@ CCellCommentator.prototype.moveRangeComments = function(rangeFrom, rangeTo) { ...@@ -464,11 +468,15 @@ CCellCommentator.prototype.moveRangeComments = function(rangeFrom, rangeTo) {
for (var i = 0; i < aComments.length; i++) { for (var i = 0; i < aComments.length; i++) {
var comment = aComments[i]; var comment = aComments[i];
if (rangeFrom.contains(comment.nCol, comment.nRow)) { if (rangeFrom.contains(comment.nCol, comment.nRow)) {
if (copy) {
var newComment = new asc_CCommentData(comment);
newComment.nCol += colOffset;
newComment.nRow += rowOffset;
newComment.setId();
this.addComment(newComment, true);
} else {
var commentBefore = new asc_CCommentData(comment); var commentBefore = new asc_CCommentData(comment);
comment.nCol += colOffset; comment.nCol += colOffset;
comment.nRow += rowOffset; comment.nRow += rowOffset;
this.model.workbook.handlers.trigger("asc_onChangeCommentData", comment.asc_getId(), comment); this.model.workbook.handlers.trigger("asc_onChangeCommentData", comment.asc_getId(), comment);
...@@ -480,11 +488,13 @@ CCellCommentator.prototype.moveRangeComments = function(rangeFrom, rangeTo) { ...@@ -480,11 +488,13 @@ CCellCommentator.prototype.moveRangeComments = function(rangeFrom, rangeTo) {
compositeComment.commentAfter = commentAfter; compositeComment.commentAfter = commentAfter;
History.Create_NewPoint(); History.Create_NewPoint();
History.Add(AscCommonExcel.g_oUndoRedoComment, AscCH.historyitem_Comment_Change, this.model.getId(), null, compositeComment); History.Add(AscCommonExcel.g_oUndoRedoComment, AscCH.historyitem_Comment_Change, this.model.getId(),
null, compositeComment);
} }
} }
} }
}; }
};
CCellCommentator.prototype.deleteCommentsRange = function(range) { CCellCommentator.prototype.deleteCommentsRange = function(range) {
if ( range ) { if ( range ) {
......
...@@ -8331,9 +8331,9 @@ ...@@ -8331,9 +8331,9 @@
} }
}; };
WorksheetView.prototype.applyMoveResizeRangeHandle = function ( target ) { WorksheetView.prototype.applyMoveResizeRangeHandle = function (target) {
if ( -1 == target.targetArr && !this.startCellMoveResizeRange.isEqual( this.moveRangeDrawingObjectTo ) ) { if (-1 == target.targetArr && !this.startCellMoveResizeRange.isEqual(this.moveRangeDrawingObjectTo)) {
this.objectRender.moveRangeDrawingObject( this.startCellMoveResizeRange, this.moveRangeDrawingObjectTo ); this.objectRender.moveRangeDrawingObject(this.startCellMoveResizeRange, this.moveRangeDrawingObjectTo);
} }
this.startCellMoveResizeRange = null; this.startCellMoveResizeRange = null;
...@@ -8367,7 +8367,7 @@ ...@@ -8367,7 +8367,7 @@
t.model.autoFilters._preMoveAutoFilters(arnFrom, arnTo, copyRange); t.model.autoFilters._preMoveAutoFilters(arnFrom, arnTo, copyRange);
t.model._moveRange(arnFrom, arnTo, copyRange); t.model._moveRange(arnFrom, arnTo, copyRange);
t.cellCommentator.moveRangeComments(arnFrom, arnTo); t.cellCommentator.moveRangeComments(arnFrom, arnTo, copyRange);
t.objectRender.moveRangeDrawingObject(arnFrom, arnTo); t.objectRender.moveRangeDrawingObject(arnFrom, arnTo);
// Вызываем функцию пересчета для заголовков форматированной таблицы // Вызываем функцию пересчета для заголовков форматированной таблицы
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment