Commit 9b485a6e authored by Dmitry.Vikulov's avatar Dmitry.Vikulov Committed by Alexander.Trofimov

- Сделал Undo/Redo для закреплённых областей(ЗО)

- Совместное редактирование ЗО
- Исправил баг с редактированием комментариев(перетирались дефайны из-за подключения Constants.js)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@54886 954022d7-b5bf-4e40-9824-e11837661b57
parent b0ec3f86
...@@ -5339,10 +5339,12 @@ function ObjectLocker(ws) { ...@@ -5339,10 +5339,12 @@ function ObjectLocker(ws) {
var asc_applyFunction = asc.applyFunction; var asc_applyFunction = asc.applyFunction;
var _t = this; var _t = this;
_t.bLock = true;
var aObjectId = []; var aObjectId = [];
var worksheet = ws; var worksheet = ws;
_t.reset = function() { _t.reset = function() {
_t.bLock = true;
aObjectId = []; aObjectId = [];
}; };
...@@ -5354,7 +5356,8 @@ function ObjectLocker(ws) { ...@@ -5354,7 +5356,8 @@ function ObjectLocker(ws) {
_t.checkObjects = function(callback) { _t.checkObjects = function(callback) {
function callbackEx(result) { function callbackEx(result) {
worksheet._drawCollaborativeElements(true); //if ( worksheet )
// worksheet._drawCollaborativeElements(true);
if ( callback ) if ( callback )
callback(result); callback(result);
} }
...@@ -5385,10 +5388,13 @@ function ObjectLocker(ws) { ...@@ -5385,10 +5388,13 @@ function ObjectLocker(ws) {
asc_applyFunction(callbackEx, false); asc_applyFunction(callbackEx, false);
return; return;
} }
worksheet.collaborativeEditing.addCheckLock(lockInfo); if ( _t.bLock )
worksheet.collaborativeEditing.addCheckLock(lockInfo);
} }
if ( _t.bLock )
worksheet.collaborativeEditing.onEndCheckLock(callbackEx); worksheet.collaborativeEditing.onEndCheckLock(callbackEx);
else
asc_applyFunction(callbackEx, true);
} }
} }
......
...@@ -960,8 +960,8 @@ var historyitem_Comments_Add = 1; // Добавили новый коммен ...@@ -960,8 +960,8 @@ var historyitem_Comments_Add = 1; // Добавили новый коммен
var historyitem_Comments_Remove = 2; // Удалили комментарий var historyitem_Comments_Remove = 2; // Удалили комментарий
// Типы изменений в классе СComment // Типы изменений в классе СComment
var historyitem_Comment_Change = 1; // Изменили комментарий var historyitem_Comment_Change = 3; // Изменили комментарий
var historyitem_Comment_TypeInfo = 2; // Изменили информацию о типе комментария var historyitem_Comment_TypeInfo = 4; // Изменили информацию о типе комментария
// Типы изменений в классе CParaHyperlinkStart // Типы изменений в классе CParaHyperlinkStart
var historyitem_Hyperlink_Value = 1; // Изменяем значение гиперссылки var historyitem_Hyperlink_Value = 1; // Изменяем значение гиперссылки
......
...@@ -36,6 +36,10 @@ var historyitem_Worksheet_SetViewSettings = 23; ...@@ -36,6 +36,10 @@ var historyitem_Worksheet_SetViewSettings = 23;
var historyitem_Worksheet_RemoveCellFormula = 24; var historyitem_Worksheet_RemoveCellFormula = 24;
var historyitem_Worksheet_ChangeMerge = 25; var historyitem_Worksheet_ChangeMerge = 25;
var historyitem_Worksheet_ChangeHyperlink = 26; var historyitem_Worksheet_ChangeHyperlink = 26;
// Frozen cell
var historyitem_Worksheet_AddFrozenCell = 30;
var historyitem_Worksheet_ChangeFrozenCell = 31;
var historyitem_Worksheet_RemoveFrozenCell = 32;
var historyitem_RowCol_Fontname = 1; var historyitem_RowCol_Fontname = 1;
var historyitem_RowCol_Fontsize = 2; var historyitem_RowCol_Fontsize = 2;
......
...@@ -358,7 +358,8 @@ var UndoRedoDataTypes = new function() { ...@@ -358,7 +358,8 @@ var UndoRedoDataTypes = new function() {
this.DocContentParaItemId = 66; this.DocContentParaItemId = 66;
this.ParagraphAddParaItem = 67; this.ParagraphAddParaItem = 67;
this.ParagraphParaItemAdd = 68; this.ParagraphParaItemAdd = 68;
this.FrozenCell = 69;
this.CompositeFrozenCell = 70;
this.Create = function(nType) this.Create = function(nType)
{ {
...@@ -429,11 +430,78 @@ var UndoRedoDataTypes = new function() { ...@@ -429,11 +430,78 @@ var UndoRedoDataTypes = new function() {
case this.GOSetAdjustmentValue: return new UndoRedoDataSetAdjustmentValue(); case this.GOSetAdjustmentValue: return new UndoRedoDataSetAdjustmentValue();
case this.ParagraphAddParaItem: return new UndoRedoDataAddParaItem(); case this.ParagraphAddParaItem: return new UndoRedoDataAddParaItem();
case this.ParagraphParaItemAdd: return new UndoRedoData_historyitem_Paragraph_AddItem(); case this.ParagraphParaItemAdd: return new UndoRedoData_historyitem_Paragraph_AddItem();
case this.FrozenCell: return new UndoRedoData_FrozenCell();
case this.CompositeFrozenCell: return new UndoRedoData_CompositeFrozenCell();
} }
return null; return null;
}; };
}; };
//
function UndoRedoData_FrozenCell(nRow, nCol) {
this.Properties = {
Row: 0,
Col: 1
};
this.nRow = nRow;
this.nCol = nCol;
}
UndoRedoData_FrozenCell.prototype = {
getType : function() {
return UndoRedoDataTypes.FrozenCell;
},
getProperties : function() {
return this.Properties;
},
getProperty : function(nType) {
switch(nType) {
case this.Properties.Row: return this.nRow; break;
case this.Properties.Col: return this.nCol; break;
}
return null;
},
setProperty : function(nType, value) {
switch(nType) {
case this.Properties.Row: this.nRow = value; break;
case this.Properties.Col: this.nCol = value; break;
}
}
};
function UndoRedoData_CompositeFrozenCell(frozenBefore, frozenAfter) {
this.frozenBefore = frozenBefore;
this.frozenAfter = frozenAfter;
this.Properties = {
frozenBefore: 0,
frozenAfter: 1
};
}
UndoRedoData_CompositeFrozenCell.prototype = {
getType: function() {
return UndoRedoDataTypes.CompositeFrozenCell;
},
getProperties: function() {
return this.Properties;
},
getProperty: function(nType) {
switch (nType) {
case this.Properties.frozenBefore: return this.frozenBefore; break;
case this.Properties.frozenAfter: return this.frozenAfter; break;
}
},
setProperty: function(nType, value) {
switch (nType) {
case this.Properties.frozenBefore: this.frozenBefore = value; break;
case this.Properties.frozenAfter: this.frozenAfter = value; break;
}
}
}
//
function UndoRedoData_CellSimpleData(nRow, nCol, oOldVal, oNewVal, sFormula){ function UndoRedoData_CellSimpleData(nRow, nCol, oOldVal, oNewVal, sFormula){
this.Properties = { this.Properties = {
Row: 0, Row: 0,
...@@ -2942,6 +3010,7 @@ UndoRedoWoorksheet.prototype = { ...@@ -2942,6 +3010,7 @@ UndoRedoWoorksheet.prototype = {
}, },
UndoRedo : function(Type, Data, nSheetId, bUndo) UndoRedo : function(Type, Data, nSheetId, bUndo)
{ {
var api = window["Asc"]["editor"];
var ws = this.wb.getWorksheetById(nSheetId); var ws = this.wb.getWorksheetById(nSheetId);
if(null == ws) if(null == ws)
return; return;
...@@ -3369,6 +3438,54 @@ UndoRedoWoorksheet.prototype = { ...@@ -3369,6 +3438,54 @@ UndoRedoWoorksheet.prototype = {
ws.hyperlinkManager.add(to, data); ws.hyperlinkManager.add(to, data);
} }
} }
// Frozen anchor
else if (historyitem_Worksheet_AddFrozenCell === Type) {
if ( !api.wb )
return;
var wsView = api.wb.getWorksheetById(nSheetId);
if ( bUndo ) {
wsView.topLeftFrozenCell = null;
wsView.visibleRange.c1 = 0;
wsView.visibleRange.r1 = 0;
}
else {
wsView.topLeftFrozenCell = new CellAddress(Data.nRow, Data.nCol, 0);
wsView.visibleRange.c1 = Data.nCol;
wsView.visibleRange.r1 = Data.nRow;
}
wsView.objectRender.drawingArea.init();
}
else if (historyitem_Worksheet_ChangeFrozenCell === Type) {
if ( !api.wb )
return;
var wsView = api.wb.getWorksheetById(nSheetId);
if ( bUndo ) {
wsView.topLeftFrozenCell = new CellAddress(Data.frozenBefore.nRow, Data.frozenBefore.nCol, 0);
wsView.visibleRange.c1 = Data.frozenBefore.nCol;
wsView.visibleRange.r1 = Data.frozenBefore.nRow;
}
else {
wsView.topLeftFrozenCell = new CellAddress(Data.frozenAfter.nRow, Data.frozenAfter.nCol, 0);
wsView.visibleRange.c1 = Data.frozenAfter.nCol;
wsView.visibleRange.r1 = Data.frozenAfter.nRow;
}
wsView.objectRender.drawingArea.init();
}
else if (historyitem_Worksheet_RemoveFrozenCell === Type) {
if ( bUndo ) {
wsView.topLeftFrozenCell = new CellAddress(Data.nRow, Data.nCol, 0);
wsView.visibleRange.c1 = Data.nCol;
wsView.visibleRange.r1 = Data.nRow;
}
else {
wsView.topLeftFrozenCell = null;
wsView.visibleRange.c1 = 0;
wsView.visibleRange.r1 = 0;
}
wsView.objectRender.drawingArea.init();
}
} }
}; };
......
...@@ -3004,7 +3004,7 @@ ...@@ -3004,7 +3004,7 @@
} }
}; };
WorksheetView.prototype._drawFrozenAnchor = function(canvas) { WorksheetView.prototype._drawFrozenAnchor = function() {
if (false === this.model.sheetViews[0].asc_getShowRowColHeaders()) if (false === this.model.sheetViews[0].asc_getShowRowColHeaders())
return; return;
...@@ -3014,10 +3014,22 @@ ...@@ -3014,10 +3014,22 @@
var frozenCell = this.topLeftFrozenCell ? this.topLeftFrozenCell : new CellAddress(0, 0, 0); var frozenCell = this.topLeftFrozenCell ? this.topLeftFrozenCell : new CellAddress(0, 0, 0);
function drawAnchor(x, y, w, h) { function drawAnchor(x, y, w, h) {
_this.drawingCtx.beginPath()
.rect(_x, _y, w, h) var callback = function(result) {
.setFillStyle(_this.settings.activeCellBorderColor) var color = _this.settings.activeCellBorderColor;
.fill(); if ( !result )
color = c_oAscCoAuthoringOtherBorderColor;
_this.drawingCtx.beginPath()
.rect(_x, _y, w, h)
.setFillStyle(color)
.fill();
}
_this.objectRender.objectLocker.reset();
_this.objectRender.objectLocker.bLock = false;
_this.objectRender.objectLocker.addObjectId(_this.getFrozenCellId());
_this.objectRender.objectLocker.checkObjects(callback);
} }
// vertical // vertical
...@@ -3104,9 +3116,9 @@ ...@@ -3104,9 +3116,9 @@
} }
else { else {
if ( _this.topLeftFrozenCell ) if ( _this.topLeftFrozenCell )
_this.setFrozenCell(col, _this.topLeftFrozenCell.getRow0(), true); _this.setFrozenCell(col, _this.topLeftFrozenCell.getRow0(), false, true);
else else
_this.setFrozenCell(col, 0, true); _this.setFrozenCell(col, 0, true, true);
} }
} }
break; break;
...@@ -3121,24 +3133,59 @@ ...@@ -3121,24 +3133,59 @@
} }
else { else {
if ( _this.topLeftFrozenCell ) if ( _this.topLeftFrozenCell )
_this.setFrozenCell(_this.topLeftFrozenCell.getCol0(), row, true); _this.setFrozenCell(_this.topLeftFrozenCell.getCol0(), row, false, true);
else else
_this.setFrozenCell(0, row, true); _this.setFrozenCell(0, row, true, true);
} }
} }
break; break;
} }
}; };
WorksheetView.prototype.setFrozenCell = function(col, row, bRedraw) { WorksheetView.prototype.setFrozenCell = function(col, row, bNew, bRedraw) {
this.topLeftFrozenCell = new CellAddress(row, col, 0); var _this = this;
this.visibleRange.c1 = col; var callback = function(result) {
this.visibleRange.r1 = row; if ( result ) {
this.objectRender.drawingArea.init(); if ( bNew ) {
if ( bRedraw ) History.Create_NewPoint();
this.draw(); History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_AddFrozenCell, _this.model.getId(), null, new UndoRedoData_FrozenCell(row, col));
_this.topLeftFrozenCell = new CellAddress(row, col, 0);
_this.visibleRange.c1 = col;
_this.visibleRange.r1 = row;
}
else {
var compositeFroze = new UndoRedoData_CompositeFrozenCell(new UndoRedoData_FrozenCell(_this.topLeftFrozenCell.getRow0(), _this.topLeftFrozenCell.getCol0()), new UndoRedoData_FrozenCell(row, col));
History.Create_NewPoint();
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_ChangeFrozenCell, _this.model.getId(), null, compositeFroze);
_this.topLeftFrozenCell = new CellAddress(row, col, 0);
_this.visibleRange.c1 = col;
_this.visibleRange.r1 = row;
}
_this.objectRender.drawingArea.init();
if ( bRedraw )
_this.draw();
}
else {
_this.overlayCtx.clear();
_this._drawSelection();
}
}
_this.objectRender.objectLocker.reset();
_this.objectRender.objectLocker.addObjectId(_this.getFrozenCellId());
_this.objectRender.objectLocker.checkObjects(callback);
} }
WorksheetView.prototype.getFrozenCellId = function() {
return "frozenCell_" + this.model.Id;
}
/** Для api закрепленных областей */
WorksheetView.prototype.clearFrozenCell = function() { WorksheetView.prototype.clearFrozenCell = function() {
this.topLeftFrozenCell = null; this.topLeftFrozenCell = null;
this.visibleRange.c1 = 0; this.visibleRange.c1 = 0;
...@@ -3148,17 +3195,19 @@ ...@@ -3148,17 +3195,19 @@
} }
WorksheetView.prototype.setSelectedFrozenCell = function() { WorksheetView.prototype.setSelectedFrozenCell = function() {
this.setFrozenCell(this.getSelectedColumnIndex(), this.getSelectedRowIndex(), true); this.setFrozenCell(this.getSelectedColumnIndex(), this.getSelectedRowIndex(), true, true);
} }
WorksheetView.prototype.setFirstFrozenCol = function() { WorksheetView.prototype.setFirstFrozenCol = function() {
this.setFrozenCell(1, 0, true); this.setFrozenCell(1, 0, true, true);
} }
WorksheetView.prototype.setFirstFrozenRow = function() { WorksheetView.prototype.setFirstFrozenRow = function() {
this.setFrozenCell(0, 1, true); this.setFrozenCell(0, 1, true, true);
} }
/** */
WorksheetView.prototype._drawSelectionElement = function (visibleRange, offsetX, offsetY, args) { WorksheetView.prototype._drawSelectionElement = function (visibleRange, offsetX, offsetY, args) {
var range = args[0], isDashLine = args[1], lineWidth = args[2], strokeColor = args[3], var range = args[0], isDashLine = args[1], lineWidth = args[2], strokeColor = args[3],
fillColor = args[4], isAllRange = args[5]; fillColor = args[4], isAllRange = args[5];
...@@ -3604,9 +3653,10 @@ ...@@ -3604,9 +3653,10 @@
WorksheetView.prototype._drawCollaborativeElements = function (bIsDrawObjects) { WorksheetView.prototype._drawCollaborativeElements = function (bIsDrawObjects) {
if (this.collaborativeEditing.getCollaborativeEditing()) { if (this.collaborativeEditing.getCollaborativeEditing()) {
this._drawCollaborativeElementsMeOther (c_oAscLockTypes.kLockTypeMine, bIsDrawObjects); this._drawCollaborativeElementsMeOther(c_oAscLockTypes.kLockTypeMine, bIsDrawObjects);
this._drawCollaborativeElementsMeOther (c_oAscLockTypes.kLockTypeOther, bIsDrawObjects); this._drawCollaborativeElementsMeOther(c_oAscLockTypes.kLockTypeOther, bIsDrawObjects);
this._drawCollaborativeElementsAllLock (); this._drawCollaborativeElementsAllLock();
this._drawFrozenAnchor();
} }
}; };
......
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