Commit 92ad517f authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Переделал отрисовку и добавление закрепленных областей.

asc_freezePane с параметром c_oAscFreezePane
Переделал хранение в истории для закрепленных областей.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@55181 954022d7-b5bf-4e40-9824-e11837661b57
parent b8c4234d
......@@ -2676,31 +2676,9 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
},
// Frozen pane
asc_clearFrozenCell: function() {
if ( this.wb ) {
var ws = this.wb.getWorksheet();
ws.clearFrozenCell();
}
},
asc_setSelectedFrozenCell: function() {
if ( this.wb ) {
var ws = this.wb.getWorksheet();
ws.setSelectedFrozenCell();
}
},
asc_setFirstFrozenCol: function() {
if ( this.wb ) {
var ws = this.wb.getWorksheet();
ws.setFirstFrozenCol();
}
},
asc_setFirstFrozenRow: function() {
if ( this.wb ) {
var ws = this.wb.getWorksheet();
ws.setFirstFrozenRow();
asc_freezePane: function (type) {
if (this.wb) {
this.wb.getWorksheet().freezePane(type);
}
},
......@@ -3717,10 +3695,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
prot["asc_changeShapeImageFromFile"] = prot.asc_changeShapeImageFromFile;
// Frozen pane
prot["asc_clearFrozenCell"] = prot.asc_clearFrozenCell;
prot["asc_setSelectedFrozenCell"] = prot.asc_setSelectedFrozenCell;
prot["asc_setFirstFrozenCol"] = prot.asc_setFirstFrozenCol;
prot["asc_setFirstFrozenRow"] = prot.asc_setFirstFrozenRow;
prot["asc_freezePane"] = prot.asc_freezePane;
// Cell interface
prot["asc_getCellInfo"] = prot.asc_getCellInfo;
......
......@@ -477,6 +477,13 @@ var c_oAscPaneState = {
FrozenSplit : "frozenSplit"
};
var c_oAscFreezePane = {
FreezeSheetPanes : 1,
FreezeTopRow : 2,
FreezeFirstColumn : 3,
FreezeClean : 4
};
var c_oAscCoAuthoringMeBorderColor = new window.CColor(22, 156, 0);
var c_oAscCoAuthoringOtherBorderColor = new window.CColor(238, 53, 37);
var c_oAscCoAuthoringLockTablePropertiesBorderColor = new window.CColor(255, 144, 0);
......
......@@ -922,19 +922,19 @@
break;
}
case "td_set_fixed_area":{
api.asc_setSelectedFrozenCell();
api.asc_freezePane(c_oAscFreezePane.FreezeSheetPanes);
break;
}
case "td_clean_fixed_area":{
api.asc_clearFrozenCell();
api.asc_freezePane(c_oAscFreezePane.FreezeClean);
break;
}
case "td_set_fixed_col":{
api.asc_setFirstFrozenCol();
api.asc_freezePane(c_oAscFreezePane.FreezeFirstColumn);
break;
}
case "td_set_fixed_row":{
api.asc_setFirstFrozenRow();
api.asc_freezePane(c_oAscFreezePane.FreezeTopRow);
break;
}
}
......
......@@ -37,9 +37,7 @@ 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_Worksheet_ChangeFrozenCell = 30;
var historyitem_RowCol_Fontname = 1;
var historyitem_RowCol_Fontsize = 2;
......
......@@ -357,8 +357,6 @@ var UndoRedoDataTypes = new function() {
this.DocContentParaItemId = 66;
this.ParagraphAddParaItem = 67;
this.ParagraphParaItemAdd = 68;
this.FrozenCell = 69;
this.CompositeFrozenCell = 70;
this.Create = function(nType)
{
......@@ -429,79 +427,11 @@ 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;
}
return null;
},
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,
......@@ -2992,20 +2922,20 @@ UndoRedoWoorksheet.prototype = {
},
UndoRedo : function(Type, Data, nSheetId, bUndo)
{
var api = window["Asc"]["editor"];
var worksheetView, nRow, nCol, oLockInfo, cell, index, from, to, range, r1, c1, r2, c2, temp, i, length, data;
var ws = this.wb.getWorksheetById(nSheetId);
if(null == ws)
return;
var collaborativeEditing = this.wb.oApi.collaborativeEditing;
if(historyitem_Worksheet_RemoveCell == Type)
{
var nRow = Data.nRow;
var nCol = Data.nCol;
nRow = Data.nRow;
nCol = Data.nCol;
if(false != this.wb.bCollaborativeChanges)
{
nRow = collaborativeEditing.getLockOtherRow2(nSheetId, nRow);
nCol = collaborativeEditing.getLockOtherColumn2(nSheetId, nCol);
var oLockInfo = new Asc.asc_CLockInfo();
oLockInfo = new Asc.asc_CLockInfo();
oLockInfo["sheetId"] = nSheetId;
oLockInfo["type"] = c_oAscLockTypeElem.Range;
oLockInfo["rangeOrObjectId"] = new Asc.Range(nCol, nRow, nCol, nRow);
......@@ -3015,7 +2945,7 @@ UndoRedoWoorksheet.prototype = {
{
var oValue = Data.oOldVal.value;
var oStyle = Data.oOldVal.style;
var cell = ws._getCell(nRow, nCol);
cell = ws._getCell(nRow, nCol);
cell.setValueData(oValue);
if(null != oStyle)
cell.setStyle(oStyle);
......@@ -3026,11 +2956,11 @@ UndoRedoWoorksheet.prototype = {
ws._removeCell(nRow, nCol);
}
else if(historyitem_Worksheet_RemoveCellFormula == Type){
var nRow = Data.nRow;
var nCol = Data.nCol;
nRow = Data.nRow;
nCol = Data.nCol;
if(bUndo)
{
var cell = ws._getCellNoEmpty(nRow, nCol);
cell = ws._getCellNoEmpty(nRow, nCol);
if(cell)
{
var node = ws.workbook.dependencyFormulas.getNode(ws.getId(), cell.getName());
......@@ -3041,11 +2971,11 @@ UndoRedoWoorksheet.prototype = {
}
else if(historyitem_Worksheet_ColProp == Type)
{
var index = Data.index;
index = Data.index;
if(false != this.wb.bCollaborativeChanges)
{
index = collaborativeEditing.getLockOtherColumn2(nSheetId, index);
var oLockInfo = new Asc.asc_CLockInfo();
oLockInfo = new Asc.asc_CLockInfo();
oLockInfo["sheetId"] = nSheetId;
oLockInfo["type"] = c_oAscLockTypeElem.Range;
oLockInfo["rangeOrObjectId"] = new Asc.Range(index, 0, index, gc_nMaxRow0);
......@@ -3059,11 +2989,11 @@ UndoRedoWoorksheet.prototype = {
}
else if(historyitem_Worksheet_RowProp == Type)
{
var index = Data.index;
index = Data.index;
if(false != this.wb.bCollaborativeChanges)
{
index = collaborativeEditing.getLockOtherRow2(nSheetId, index);
var oLockInfo = new Asc.asc_CLockInfo();
oLockInfo = new Asc.asc_CLockInfo();
oLockInfo["sheetId"] = nSheetId;
oLockInfo["type"] = c_oAscLockTypeElem.Range;
oLockInfo["rangeOrObjectId"] = new Asc.Range(0, index, gc_nMaxCol0, index);
......@@ -3077,22 +3007,22 @@ UndoRedoWoorksheet.prototype = {
}
else if(historyitem_Worksheet_AddRows == Type || historyitem_Worksheet_RemoveRows == Type)
{
var from = Data.from;
var to = Data.to;
from = Data.from;
to = Data.to;
if(false != this.wb.bCollaborativeChanges)
{
from = collaborativeEditing.getLockOtherRow2(nSheetId, from);
to = collaborativeEditing.getLockOtherRow2(nSheetId, to);
if(false == ((true == bUndo && historyitem_Worksheet_AddRows == Type) || (false == bUndo && historyitem_Worksheet_RemoveRows == Type)))
{
var oLockInfo = new Asc.asc_CLockInfo();
oLockInfo = new Asc.asc_CLockInfo();
oLockInfo["sheetId"] = nSheetId;
oLockInfo["type"] = c_oAscLockTypeElem.Range;
oLockInfo["rangeOrObjectId"] = new Asc.Range(0, from, gc_nMaxCol0, to);
this.wb.aCollaborativeChangeElements.push(oLockInfo);
}
}
var range = Asc.Range(0, from, gc_nMaxCol0, to);
range = Asc.Range(0, from, gc_nMaxCol0, to);
if((true == bUndo && historyitem_Worksheet_AddRows == Type) || (false == bUndo && historyitem_Worksheet_RemoveRows == Type))
ws.workbook.handlers.trigger("deleteCell", nSheetId, c_oAscDeleteOptions.DeleteRows, range);
else
......@@ -3104,15 +3034,15 @@ UndoRedoWoorksheet.prototype = {
}
else if(historyitem_Worksheet_AddCols == Type || historyitem_Worksheet_RemoveCols == Type)
{
var from = Data.from;
var to = Data.to;
from = Data.from;
to = Data.to;
if(false != this.wb.bCollaborativeChanges)
{
from = collaborativeEditing.getLockOtherColumn2(nSheetId, from);
to = collaborativeEditing.getLockOtherColumn2(nSheetId, to);
if(false == ((true == bUndo && historyitem_Worksheet_AddCols == Type) || (false == bUndo && historyitem_Worksheet_RemoveCols == Type)))
{
var oLockInfo = new Asc.asc_CLockInfo();
oLockInfo = new Asc.asc_CLockInfo();
oLockInfo["sheetId"] = nSheetId;
oLockInfo["type"] = c_oAscLockTypeElem.Range;
oLockInfo["rangeOrObjectId"] = new Asc.Range(from, 0, to, gc_nMaxRow0);
......@@ -3120,7 +3050,7 @@ UndoRedoWoorksheet.prototype = {
}
}
var range = Asc.Range(from, 0, to, gc_nMaxRow0);
range = Asc.Range(from, 0, to, gc_nMaxRow0);
if((true == bUndo && historyitem_Worksheet_AddCols == Type) || (false == bUndo && historyitem_Worksheet_RemoveCols == Type))
ws.workbook.handlers.trigger("deleteCell", nSheetId, c_oAscDeleteOptions.DeleteColumns, range);
else
......@@ -3132,10 +3062,10 @@ UndoRedoWoorksheet.prototype = {
}
else if(historyitem_Worksheet_ShiftCellsLeft == Type || historyitem_Worksheet_ShiftCellsRight == Type)
{
var r1 = Data.r1;
var c1 = Data.c1;
var r2 = Data.r2;
var c2 = Data.c2;
r1 = Data.r1;
c1 = Data.c1;
r2 = Data.r2;
c2 = Data.c2;
if(false != this.wb.bCollaborativeChanges)
{
r1 = collaborativeEditing.getLockOtherRow2(nSheetId, r1);
......@@ -3144,7 +3074,7 @@ UndoRedoWoorksheet.prototype = {
c2 = collaborativeEditing.getLockOtherColumn2(nSheetId, c2);
if(false == ((true == bUndo && historyitem_Worksheet_ShiftCellsLeft == Type) || (false == bUndo && historyitem_Worksheet_ShiftCellsRight == Type)))
{
var oLockInfo = new Asc.asc_CLockInfo();
oLockInfo = new Asc.asc_CLockInfo();
oLockInfo["sheetId"] = nSheetId;
oLockInfo["type"] = c_oAscLockTypeElem.Range;
oLockInfo["rangeOrObjectId"] = new Asc.Range(c1, r1, c2, r2);
......@@ -3158,10 +3088,10 @@ UndoRedoWoorksheet.prototype = {
}
else if(historyitem_Worksheet_ShiftCellsTop == Type || historyitem_Worksheet_ShiftCellsBottom == Type)
{
var r1 = Data.r1;
var c1 = Data.c1;
var r2 = Data.r2;
var c2 = Data.c2;
r1 = Data.r1;
c1 = Data.c1;
r2 = Data.r2;
c2 = Data.c2;
if(false != this.wb.bCollaborativeChanges)
{
r1 = collaborativeEditing.getLockOtherRow2(nSheetId, r1);
......@@ -3170,7 +3100,7 @@ UndoRedoWoorksheet.prototype = {
c2 = collaborativeEditing.getLockOtherColumn2(nSheetId, c2);
if(false == ((true == bUndo && historyitem_Worksheet_ShiftCellsTop == Type) || (false == bUndo && historyitem_Worksheet_ShiftCellsBottom == Type)))
{
var oLockInfo = new Asc.asc_CLockInfo();
oLockInfo = new Asc.asc_CLockInfo();
oLockInfo["sheetId"] = nSheetId;
oLockInfo["type"] = c_oAscLockTypeElem.Range;
oLockInfo["rangeOrObjectId"] = new Asc.Range(c1, r1, c2, r2);
......@@ -3192,31 +3122,31 @@ UndoRedoWoorksheet.prototype = {
bbox.c1 = collaborativeEditing.getLockOtherColumn2(nSheetId, bbox.c1);
bbox.r2 = collaborativeEditing.getLockOtherRow2(nSheetId, bbox.r2);
bbox.c2 = collaborativeEditing.getLockOtherColumn2(nSheetId, bbox.c2);
for(var i = 0, length = Data.places.length; i < length; ++i)
for(i = 0, length = Data.places.length; i < length; ++i)
{
var place = Data.places[i];
place.from = collaborativeEditing.getLockOtherRow2(nSheetId, place.from);
place.to = collaborativeEditing.getLockOtherRow2(nSheetId, place.to);
var oLockInfo = new Asc.asc_CLockInfo();
oLockInfo = new Asc.asc_CLockInfo();
oLockInfo["sheetId"] = nSheetId;
oLockInfo["type"] = c_oAscLockTypeElem.Range;
oLockInfo["rangeOrObjectId"] = new Asc.Range(bbox.c1, place.from, bbox.c2, place.from);
this.wb.aCollaborativeChangeElements.push(oLockInfo);
}
}
var range = ws.getRange(new CellAddress(bbox.r1, bbox.c1, 0), new CellAddress(bbox.r2, bbox.c2, 0));
range = ws.getRange(new CellAddress(bbox.r1, bbox.c1, 0), new CellAddress(bbox.r2, bbox.c2, 0));
range._sortByArray(bbox, places);
}
else if(historyitem_Worksheet_MoveRange == Type)
{
//todo worksheetView.autoFilters._moveAutoFilters(worksheetView ,null, null, g_oUndoRedoAutoFiltersMoveData);
var from = Asc.Range(Data.from.c1, Data.from.r1, Data.from.c2, Data.from.r2);
var to = Asc.Range(Data.to.c1, Data.to.r1, Data.to.c2, Data.to.r2);
from = Asc.Range(Data.from.c1, Data.from.r1, Data.from.c2, Data.from.r2);
to = Asc.Range(Data.to.c1, Data.to.r1, Data.to.c2, Data.to.r2);
var copyRange = Data.copyRange;
if(bUndo)
{
var temp = from;
temp = from;
from = to;
to = temp;
}
......@@ -3240,7 +3170,7 @@ UndoRedoWoorksheet.prototype = {
else{
ws._moveRange(from, to, copyRange);
}
var worksheetView = this.wb.oApi.wb.getWorksheetById(nSheetId);
worksheetView = this.wb.oApi.wb.getWorksheetById(nSheetId);
if(bUndo)//если на Undo перемещается диапазон из форматированной таблицы - стиль форматированной таблицы не должен цепляться
{
worksheetView.autoFilters._clearFormatTableStyle(to);
......@@ -3260,10 +3190,10 @@ UndoRedoWoorksheet.prototype = {
{
if(historyitem_Worksheet_Unmerge == Type)
bUndo = !bUndo;
var r1 = Data.r1;
var c1 = Data.c1;
var r2 = Data.r2;
var c2 = Data.c2;
r1 = Data.r1;
c1 = Data.c1;
r2 = Data.r2;
c2 = Data.c2;
if(false != this.wb.bCollaborativeChanges)
{
r1 = collaborativeEditing.getLockOtherRow2(nSheetId, r1);
......@@ -3271,7 +3201,7 @@ UndoRedoWoorksheet.prototype = {
r2 = collaborativeEditing.getLockOtherRow2(nSheetId, r2);
c2 = collaborativeEditing.getLockOtherColumn2(nSheetId, c2);
}
var range = ws.getRange(new CellAddress(r1, c1, 0), new CellAddress(r2, c2, 0));
range = ws.getRange(new CellAddress(r1, c1, 0), new CellAddress(r2, c2, 0));
if(bUndo)
range.unmerge();
else
......@@ -3285,10 +3215,10 @@ UndoRedoWoorksheet.prototype = {
if(false != this.wb.bCollaborativeChanges)
{
var bboxRef = Data.Ref.getBBox0();
var r1 = collaborativeEditing.getLockOtherRow2(nSheetId, bboxRef.r1);
var c1 = collaborativeEditing.getLockOtherColumn2(nSheetId, bboxRef.c1);
var r2 = collaborativeEditing.getLockOtherRow2(nSheetId, bboxRef.r2);
var c2 = collaborativeEditing.getLockOtherColumn2(nSheetId, bboxRef.c2);
r1 = collaborativeEditing.getLockOtherRow2(nSheetId, bboxRef.r1);
c1 = collaborativeEditing.getLockOtherColumn2(nSheetId, bboxRef.c1);
r2 = collaborativeEditing.getLockOtherRow2(nSheetId, bboxRef.r2);
c2 = collaborativeEditing.getLockOtherColumn2(nSheetId, bboxRef.c2);
Ref.setOffsetFirst({offsetCol: c1 - bboxRef.c1, offsetRow: r1 - bboxRef.r1});
Ref.setOffsetLast({offsetCol: c2 - bboxRef.c2, offsetRow: r2 - bboxRef.r2});
}
......@@ -3350,22 +3280,22 @@ UndoRedoWoorksheet.prototype = {
ws.setSheetViewSettings(bUndo ? Data.from : Data.to);
}
else if(historyitem_Worksheet_ChangeMerge === Type){
var from = null;
from = null;
if(null != Data.from)
from = new Asc.Range(Data.from.c1, Data.from.r1, Data.from.c2, Data.from.r2);
var to = null;
to = null;
if(null != Data.to)
to = new Asc.Range(Data.to.c1, Data.to.r1, Data.to.c2, Data.to.r2);
if(bUndo)
{
var temp = from;
temp = from;
from = to;
to = temp;
}
if(null != from && null != from.r1 && null != from.c1 && null != from.r2 && null != from.c2)
{
var aMerged = ws.mergeManager.get(from);
for(var i in aMerged.inner)
for(i in aMerged.inner)
{
var merged = aMerged.inner[i];
if(merged.bbox.isEqual(from))
......@@ -3375,29 +3305,29 @@ UndoRedoWoorksheet.prototype = {
}
}
}
var data = 1;
data = 1;
if(null != to && null != to.r1 && null != to.c1 && null != to.r2 && null != to.c2)
ws.mergeManager.add(to, data);
}
else if(historyitem_Worksheet_ChangeHyperlink === Type){
var from = null;
from = null;
if(null != Data.from)
from = new Asc.Range(Data.from.c1, Data.from.r1, Data.from.c2, Data.from.r2);
var to = null;
to = null;
if(null != Data.to)
to = new Asc.Range(Data.to.c1, Data.to.r1, Data.to.c2, Data.to.r2);
if(bUndo)
{
var temp = from;
temp = from;
from = to;
to = temp;
}
//не делаем clone потому что предполагаем, что здесь могут быть только операции изменения рзмеров, перемещение или удаления одной ссылки
var data = null;
data = null;
if(null != from && null != from.r1 && null != from.c1 && null != from.r2 && null != from.c2)
{
var aHyperlinks = ws.hyperlinkManager.get(from);
for(var i in aHyperlinks.inner)
for(i in aHyperlinks.inner)
{
var hyp = aHyperlinks.inner[i];
if(hyp.bbox.isEqual(from))
......@@ -3415,54 +3345,10 @@ UndoRedoWoorksheet.prototype = {
data.Ref = ws.getRange3(to.r1, to.c1, to.r2, to.c2);
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();
} else if (historyitem_Worksheet_ChangeFrozenCell === Type) {
worksheetView = this.wb.oApi.wb.getWorksheetById(nSheetId);
var updateData = bUndo ? Data.from : Data.to;
worksheetView._updateFreezePane(updateData.c1, updateData.r1, /*lockDraw*/true);
}
}
};
......
......@@ -1020,7 +1020,8 @@
var res = new asc_CPane();
res.state = this.state;
res.topLeftCell = this.topLeftCell;
res.topLeftFrozenCell = this.topLeftFrozenCell ? new CellAddress(this.topLeftFrozenCell.id) : null;
res.topLeftFrozenCell = this.topLeftFrozenCell ?
new CellAddress(this.topLeftFrozenCell.row, this.topLeftFrozenCell.col) : null;
return res;
};
asc_CPane.prototype.init = function() {
......
......@@ -768,15 +768,13 @@
// Frozen anchor
WorkbookView.prototype._onMoveFrozenAnchorHandle = function (x, y, targetInfo) {
var ws = this.getWorksheet();
if ( ws )
ws._applyFrozenAnchor(x, y, targetInfo, true);
ws.drawFrozenGuides(x, y, targetInfo);
};
WorkbookView.prototype._onMoveFrozenAnchorHandleDone = function (x, y, targetInfo) {
// Закрепляем область
var ws = this.getWorksheet();
if ( ws )
ws._applyFrozenAnchor(x, y, targetInfo, false);
ws.applyFrozenAnchor(x, y, targetInfo);
};
WorkbookView.prototype._onAutoFiltersClick = function (idFilter) {
......
......@@ -159,8 +159,7 @@
var kNewLine = "\n";
var kPaneStateFrozen = "frozen";
var kPaneStateFrozenSplit = "frozenSplit";
var klockNameFrozenPane = "frozenPane";
function calcDecades(num) {
return Math.abs(num) < 10 ? 1 : 1 + calcDecades( asc_floor(num * 0.1) );
......@@ -228,7 +227,7 @@
this.fillHandleBorderColorSelect = new CColor(255, 255, 255, 1);
// Цвет закрепленных областей
this.frozenColor = new CColor(0, 0, 0, 1);
this.frozenColor = new CColor(105, 119, 62, 1);
return this;
}
......@@ -2979,60 +2978,58 @@
/** Рисует закрепление областей */
WorksheetView.prototype._drawFrozenPaneLines = function (canvas) {
var _this = this;
var callback = function(result) {
var color = _this.settings.activeCellBorderColor;
if ( !result )
color = c_oAscCoAuthoringOtherBorderColor;
function drawAnchor(x, y, w, h, bVertical) {
_this.drawingCtx.beginPath().setStrokeStyle(color);
if ( bVertical )
_this.drawingCtx.dashLineCleverVer(x, y, y + h);
else
_this.drawingCtx.dashLineCleverHor(x, y, x + w);
_this.drawingCtx.stroke();
// ToDo заделать отрисовку lock области
if (this.topLeftFrozenCell) {
var ctx = canvas ? canvas : this.drawingCtx;
var row = this.topLeftFrozenCell.getRow0();
var col = this.topLeftFrozenCell.getCol0();
ctx.setLineWidth(1).setStrokeStyle(this.settings.frozenColor).beginPath();
if (0 < row) {
ctx.lineHor(0, this.rows[row].top - this.height_1px, ctx.getWidth());
}
if (0 < col) {
ctx.lineVer(this.cols[col].left - this.width_1px, 0, ctx.getHeight());
}
ctx.stroke();
}
};
// Anchor
if ( _this.model.sheetViews[0].asc_getShowRowColHeaders() ) {
var frozenCell = _this.topLeftFrozenCell ? _this.topLeftFrozenCell : new CellAddress(0, 0, 0);
WorksheetView.prototype.drawFrozenGuides = function (x, y, targetInfo) {
if (!targetInfo)
return;
// vertical
var _x = _this.getCellLeft(frozenCell.getCol0(), 1) - 0.5;
var _y = _this.headersTop;
var w = 0;
var h = _this.headersHeight;
drawAnchor(_x, _y, w, h, true);
var data, offsetFrozen;
var ctx = this.overlayCtx;
// horizontal
_x = _this.headersLeft;
_y = _this.getCellTop(frozenCell.getRow0(), 1) - 0.5;
w = _this.headersWidth - 0.5;
h = 0;
drawAnchor(_x, _y, w, h, false);
}
ctx.clear();
this._drawSelection();
// Lines
if (_this.topLeftFrozenCell) {
var ctx = canvas ? canvas : _this.drawingCtx;
var row = _this.topLeftFrozenCell.getRow0();
var col = _this.topLeftFrozenCell.getCol0();
ctx.setLineWidth(1).setStrokeStyle(color).beginPath();
if (0 < row) {
ctx.dashLineCleverHor(0, _this.rows[row].top - _this.height_1px, ctx.getWidth());
}
if (0 < col) {
ctx.dashLineCleverVer(_this.cols[col].left - _this.width_1px, 0, ctx.getHeight());
switch (targetInfo.target) {
case "frozenAnchorV":
x *= asc_getcvt(0/*px*/, 1/*pt*/, this._getPPIX());
data = this._findColUnderCursor(x, true);
if (data && 0 <= data.col) {
var h = ctx.getHeight();
var offsetX = this.cols[this.visibleRange.c1].left - this.cellsLeft;
offsetFrozen = this.getFrozenPaneOffset(false, true);
offsetX -= offsetFrozen.offsetX;
ctx.setFillPattern(this.ptrnLineDotted1)
.fillRect(this.cols[data.col].left - offsetX - this.width_1px, 0, this.width_1px, h);
}
ctx.stroke();
break;
case "frozenAnchorH":
y *= asc_getcvt(0/*px*/, 1/*pt*/, this._getPPIY());
data = this._findRowUnderCursor(y, true);
if (data && 0 <= data.row) {
var w = ctx.getWidth();
var offsetY = this.rows[this.visibleRange.r1].top - this.cellsTop;
offsetFrozen = this.getFrozenPaneOffset(true, false);
offsetY -= offsetFrozen.offsetY;
ctx.setFillPattern(this.ptrnLineDotted1)
.fillRect(0, this.rows[data.row].top - offsetY - this.height_1px, w, this.height_1px);
}
break;
}
_this.objectRender.objectLocker.reset();
_this.objectRender.objectLocker.bLock = false;
_this.objectRender.objectLocker.addObjectId(_this.getFrozenCellId());
_this.objectRender.objectLocker.checkObjects(callback);
};
WorksheetView.prototype._isFrozenAnchor = function(x, y) {
......@@ -3078,121 +3075,101 @@
return result;
};
WorksheetView.prototype._applyFrozenAnchor = function(x, y, targetInfo, bMove) {
if ( !targetInfo )
WorksheetView.prototype.applyFrozenAnchor = function(x, y, targetInfo) {
if (!targetInfo)
return;
var _this = this;
var col = 0, row = 0;
var ctx = _this.overlayCtx;
if ( bMove )
ctx.clear();
x *= asc_getcvt(0/*px*/, 1/*pt*/, this._getPPIX());
y *= asc_getcvt(0/*px*/, 1/*pt*/, this._getPPIY());
switch (targetInfo.target) {
case "frozenAnchorV":
var _col = _this._findColUnderCursor(x, true);
if ( _col && (_col.col >= 0) ) {
col = _col.col;
if ( bMove ) {
ctx.setLineWidth(1).setStrokeStyle(_this.settings.activeCellBorderColor).beginPath();
ctx.dashLineCleverVer(_this.cols[col].left - _this.width_1px, 0, ctx.getHeight());
ctx.stroke();
}
else {
if ( _this.topLeftFrozenCell )
_this.setFrozenCell(col, _this.topLeftFrozenCell.getRow0(), false, true);
else
_this.setFrozenCell(col, 0, true, true);
var t = this;
var onChangeFrozenCallback = function (isSuccess) {
if (false === isSuccess) {
t.overlayCtx.clear();
t._drawSelection();
return;
}
var lastCol = 0, lastRow = 0, data;
if (t.topLeftFrozenCell) {
lastCol = t.topLeftFrozenCell.getCol0();
lastRow = t.topLeftFrozenCell.getRow0();
}
switch (targetInfo.target) {
case "frozenAnchorV":
x *= asc_getcvt(0/*px*/, 1/*pt*/, t._getPPIX());
data = t._findColUnderCursor(x, true);
if (data && 0 <= data.col)
lastCol = data.col;
break;
case "frozenAnchorH":
var _row = _this._findRowUnderCursor(y, true);
if ( _row && (_row.row >= 0) ) {
row = _row.row;
if ( bMove ) {
ctx.setLineWidth(1).setStrokeStyle(_this.settings.activeCellBorderColor).beginPath();
ctx.dashLineCleverHor(0, _this.rows[row].top - _this.height_1px, ctx.getWidth());
ctx.stroke();
}
else {
if ( _this.topLeftFrozenCell )
_this.setFrozenCell(_this.topLeftFrozenCell.getCol0(), row, false, true);
else
_this.setFrozenCell(0, row, true, true);
}
}
y *= asc_getcvt(0/*px*/, 1/*pt*/, t._getPPIY());
data = t._findRowUnderCursor(y, true);
if (data && 0 <= data.row)
lastRow = data.row;
break;
}
t._updateFreezePane(lastCol, lastRow);
};
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._isLockedFrozenPane (onChangeFrozenCallback);
};
_this.topLeftFrozenCell = new CellAddress(row, col, 0);
_this.visibleRange.c1 = col;
_this.visibleRange.r1 = row;
}
/** Для api закрепленных областей */
_this.objectRender.drawingArea.init();
if ( bRedraw )
_this.draw();
}
else {
_this.overlayCtx.clear();
_this._drawSelection();
}
WorksheetView.prototype.freezePane = function (type) {
var t = this;
var onChangeFreezePane = function (isSuccess) {
if (false === isSuccess)
return;
var col, row;
switch(type) {
case c_oAscFreezePane.FreezeSheetPanes:
col = t.getSelectedColumnIndex();
row = t.getSelectedRowIndex();
break;
case c_oAscFreezePane.FreezeFirstColumn:
col = 1;
row = 0;
break;
case c_oAscFreezePane.FreezeTopRow:
col = 0;
row = 1;
break;
case c_oAscFreezePane.FreezeClean:
col = 0;
row = 0;
break;
}
_this.objectRender.objectLocker.reset();
_this.objectRender.objectLocker.addObjectId(_this.getFrozenCellId());
_this.objectRender.objectLocker.checkObjects(callback);
t._updateFreezePane(col, row);
};
WorksheetView.prototype.getFrozenCellId = function() {
return "frozenCell_" + this.model.Id;
return this._isLockedFrozenPane(onChangeFreezePane);
};
/** Для api закрепленных областей */
WorksheetView.prototype._updateFreezePane = function(col, row, lockDraw) {
var lastCol = 0, lastRow = 0;
if (this.topLeftFrozenCell) {
lastCol = this.topLeftFrozenCell.getCol0();
lastRow = this.topLeftFrozenCell.getRow0();
}
History.Create_NewPoint();
var oData = new UndoRedoData_FromTo(new UndoRedoData_BBox(new asc_Range(lastCol, lastRow, lastCol, lastRow)),
new UndoRedoData_BBox(new asc_Range(col, row, col, row)), null);
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_ChangeFrozenCell, this.model.getId(), null, oData);
if (0 === col && 0 === row) {
// Очистка
this.topLeftFrozenCell = this.model.sheetViews[0].pane = null;
} else {
// Создание
var pane = this.model.sheetViews[0].pane = new asc.asc_CPane();
this.topLeftFrozenCell = pane.topLeftFrozenCell = new CellAddress(row, col, 0);
}
this.visibleRange.c1 = col;
this.visibleRange.r1 = row;
WorksheetView.prototype.clearFrozenCell = function() {
this.topLeftFrozenCell = null;
this.visibleRange.c1 = 0;
this.visibleRange.r1 = 0;
this.objectRender.drawingArea.init();
if (!lockDraw)
this.draw();
};
WorksheetView.prototype.setSelectedFrozenCell = function() {
this.setFrozenCell(this.getSelectedColumnIndex(), this.getSelectedRowIndex(), true, true);
};
WorksheetView.prototype.setFirstFrozenCol = function() {
this.setFrozenCell(1, 0, true, true);
};
WorksheetView.prototype.setFirstFrozenRow = function() {
this.setFrozenCell(0, 1, true, true);
};
/** */
WorksheetView.prototype._drawSelectionElement = function (visibleRange, offsetX, offsetY, args) {
......@@ -5477,7 +5454,7 @@
var frozenCursor = this._isFrozenAnchor(x, y);
if (frozenCursor.result) {
lockInfo = this.collaborativeEditing.getLockInfo(c_oAscLockTypeElem.Object, null, sheetId, this.getFrozenCellId());
lockInfo = this.collaborativeEditing.getLockInfo(c_oAscLockTypeElem.Object, null, sheetId, klockNameFrozenPane);
isLocked = this.collaborativeEditing.getLockIntersection(lockInfo, c_oAscLockTypes.kLockTypeOther, false);
if (false !== isLocked) {
// Кто-то сделал lock
......@@ -8773,6 +8750,38 @@
return arnFor;
};
// Залочена ли панель для закрепления
WorksheetView.prototype._isLockedFrozenPane = function (callback) {
if (false === this.collaborativeEditing.isCoAuthoringExcellEnable()) {
// Запрещено совместное редактирование
asc_applyFunction(callback, true);
return;
}
var sheetId = this.model.getId();
var lockInfo = this.collaborativeEditing.getLockInfo(c_oAscLockTypeElem.Object, null, sheetId, klockNameFrozenPane);
if (false === this.collaborativeEditing.getCollaborativeEditing()) {
// Пользователь редактирует один: не ждем ответа, а сразу продолжаем редактирование
asc_applyFunction(callback, true);
callback = undefined;
}
if (false !== this.collaborativeEditing.getLockIntersection(lockInfo,
c_oAscLockTypes.kLockTypeMine, /*bCheckOnlyLockAll*/false)) {
// Редактируем сами
asc_applyFunction(callback, true);
return;
} else if (false !== this.collaborativeEditing.getLockIntersection(lockInfo,
c_oAscLockTypes.kLockTypeOther, /*bCheckOnlyLockAll*/false)) {
// Уже ячейку кто-то редактирует
asc_applyFunction(callback, false);
return;
}
this.collaborativeEditing.onStartCheckLock();
this.collaborativeEditing.addCheckLock(lockInfo);
this.collaborativeEditing.onEndCheckLock(callback);
};
// Залочен ли весь лист
WorksheetView.prototype._isLockedAll = function (callback) {
if (false === this.collaborativeEditing.isCoAuthoringExcellEnable()) {
......
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