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) {
var asc_applyFunction = asc.applyFunction;
var _t = this;
_t.bLock = true;
var aObjectId = [];
var worksheet = ws;
_t.reset = function() {
_t.bLock = true;
aObjectId = [];
};
......@@ -5354,7 +5356,8 @@ function ObjectLocker(ws) {
_t.checkObjects = function(callback) {
function callbackEx(result) {
worksheet._drawCollaborativeElements(true);
//if ( worksheet )
// worksheet._drawCollaborativeElements(true);
if ( callback )
callback(result);
}
......@@ -5385,10 +5388,13 @@ function ObjectLocker(ws) {
asc_applyFunction(callbackEx, false);
return;
}
worksheet.collaborativeEditing.addCheckLock(lockInfo);
if ( _t.bLock )
worksheet.collaborativeEditing.addCheckLock(lockInfo);
}
worksheet.collaborativeEditing.onEndCheckLock(callbackEx);
if ( _t.bLock )
worksheet.collaborativeEditing.onEndCheckLock(callbackEx);
else
asc_applyFunction(callbackEx, true);
}
}
......
......@@ -960,8 +960,8 @@ var historyitem_Comments_Add = 1; // Добавили новый коммен
var historyitem_Comments_Remove = 2; // Удалили комментарий
// Типы изменений в классе СComment
var historyitem_Comment_Change = 1; // Изменили комментарий
var historyitem_Comment_TypeInfo = 2; // Изменили информацию о типе комментария
var historyitem_Comment_Change = 3; // Изменили комментарий
var historyitem_Comment_TypeInfo = 4; // Изменили информацию о типе комментария
// Типы изменений в классе CParaHyperlinkStart
var historyitem_Hyperlink_Value = 1; // Изменяем значение гиперссылки
......
......@@ -36,6 +36,10 @@ var historyitem_Worksheet_SetViewSettings = 23;
var historyitem_Worksheet_RemoveCellFormula = 24;
var historyitem_Worksheet_ChangeMerge = 25;
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_Fontsize = 2;
......
......@@ -358,7 +358,8 @@ var UndoRedoDataTypes = new function() {
this.DocContentParaItemId = 66;
this.ParagraphAddParaItem = 67;
this.ParagraphParaItemAdd = 68;
this.FrozenCell = 69;
this.CompositeFrozenCell = 70;
this.Create = function(nType)
{
......@@ -429,11 +430,78 @@ var UndoRedoDataTypes = new function() {
case this.GOSetAdjustmentValue: return new UndoRedoDataSetAdjustmentValue();
case this.ParagraphAddParaItem: return new UndoRedoDataAddParaItem();
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;
};
};
//
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){
this.Properties = {
Row: 0,
......@@ -2942,6 +3010,7 @@ UndoRedoWoorksheet.prototype = {
},
UndoRedo : function(Type, Data, nSheetId, bUndo)
{
var api = window["Asc"]["editor"];
var ws = this.wb.getWorksheetById(nSheetId);
if(null == ws)
return;
......@@ -3369,6 +3438,54 @@ UndoRedoWoorksheet.prototype = {
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 @@
}
};
WorksheetView.prototype._drawFrozenAnchor = function(canvas) {
WorksheetView.prototype._drawFrozenAnchor = function() {
if (false === this.model.sheetViews[0].asc_getShowRowColHeaders())
return;
......@@ -3014,10 +3014,22 @@
var frozenCell = this.topLeftFrozenCell ? this.topLeftFrozenCell : new CellAddress(0, 0, 0);
function drawAnchor(x, y, w, h) {
_this.drawingCtx.beginPath()
.rect(_x, _y, w, h)
.setFillStyle(_this.settings.activeCellBorderColor)
.fill();
var callback = function(result) {
var color = _this.settings.activeCellBorderColor;
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
......@@ -3104,9 +3116,9 @@
}
else {
if ( _this.topLeftFrozenCell )
_this.setFrozenCell(col, _this.topLeftFrozenCell.getRow0(), true);
_this.setFrozenCell(col, _this.topLeftFrozenCell.getRow0(), false, true);
else
_this.setFrozenCell(col, 0, true);
_this.setFrozenCell(col, 0, true, true);
}
}
break;
......@@ -3121,24 +3133,59 @@
}
else {
if ( _this.topLeftFrozenCell )
_this.setFrozenCell(_this.topLeftFrozenCell.getCol0(), row, true);
_this.setFrozenCell(_this.topLeftFrozenCell.getCol0(), row, false, true);
else
_this.setFrozenCell(0, row, true);
_this.setFrozenCell(0, row, true, true);
}
}
break;
}
};
WorksheetView.prototype.setFrozenCell = function(col, row, bRedraw) {
this.topLeftFrozenCell = new CellAddress(row, col, 0);
this.visibleRange.c1 = col;
this.visibleRange.r1 = row;
this.objectRender.drawingArea.init();
if ( bRedraw )
this.draw();
WorksheetView.prototype.setFrozenCell = function(col, row, bNew, bRedraw) {
var _this = this;
var callback = function(result) {
if ( result ) {
if ( bNew ) {
History.Create_NewPoint();
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() {
this.topLeftFrozenCell = null;
this.visibleRange.c1 = 0;
......@@ -3148,17 +3195,19 @@
}
WorksheetView.prototype.setSelectedFrozenCell = function() {
this.setFrozenCell(this.getSelectedColumnIndex(), this.getSelectedRowIndex(), true);
this.setFrozenCell(this.getSelectedColumnIndex(), this.getSelectedRowIndex(), true, true);
}
WorksheetView.prototype.setFirstFrozenCol = function() {
this.setFrozenCell(1, 0, true);
this.setFrozenCell(1, 0, true, true);
}
WorksheetView.prototype.setFirstFrozenRow = function() {
this.setFrozenCell(0, 1, true);
this.setFrozenCell(0, 1, true, true);
}
/** */
WorksheetView.prototype._drawSelectionElement = function (visibleRange, offsetX, offsetY, args) {
var range = args[0], isDashLine = args[1], lineWidth = args[2], strokeColor = args[3],
fillColor = args[4], isAllRange = args[5];
......@@ -3604,9 +3653,10 @@
WorksheetView.prototype._drawCollaborativeElements = function (bIsDrawObjects) {
if (this.collaborativeEditing.getCollaborativeEditing()) {
this._drawCollaborativeElementsMeOther (c_oAscLockTypes.kLockTypeMine, bIsDrawObjects);
this._drawCollaborativeElementsMeOther (c_oAscLockTypes.kLockTypeOther, bIsDrawObjects);
this._drawCollaborativeElementsAllLock ();
this._drawCollaborativeElementsMeOther(c_oAscLockTypes.kLockTypeMine, bIsDrawObjects);
this._drawCollaborativeElementsMeOther(c_oAscLockTypes.kLockTypeOther, bIsDrawObjects);
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