Commit 8f662306 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Поправил Undo|Redo (может понадобится перерассчет для отрисовки заголовков)

Реализовал Скрытие/Показ заголовков для листа

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47759 954022d7-b5bf-4e40-9824-e11837661b57
parent a7fca532
...@@ -148,6 +148,7 @@ CHistory.prototype = ...@@ -148,6 +148,7 @@ CHistory.prototype =
this.workbook.handlers.trigger("lockDraw"); this.workbook.handlers.trigger("lockDraw");
var isReInit = false;
var oCurWorksheet = this.workbook.getWorksheet(this.workbook.getActive()); var oCurWorksheet = this.workbook.getWorksheet(this.workbook.getActive());
if(null != Point.nLastSheetId && Point.nLastSheetId != oCurWorksheet.getId()) if(null != Point.nLastSheetId && Point.nLastSheetId != oCurWorksheet.getId())
this.workbook.handlers.trigger("showWorksheet", Point.nLastSheetId); this.workbook.handlers.trigger("showWorksheet", Point.nLastSheetId);
...@@ -163,6 +164,8 @@ CHistory.prototype = ...@@ -163,6 +164,8 @@ CHistory.prototype =
aStartTriggerAction[Item.SheetId] = ws; aStartTriggerAction[Item.SheetId] = ws;
} }
Item.Class.Undo( Item.Type, Item.Data, Item.SheetId ); Item.Class.Undo( Item.Type, Item.Data, Item.SheetId );
if (g_oUndoRedoWorksheet === Item.Class && historyitem_Worksheet_SetViewSettings === Item.Type)
isReInit = true;
} }
for(var i in aStartTriggerAction) for(var i in aStartTriggerAction)
aStartTriggerAction[i].onEndTriggerAction(); aStartTriggerAction[i].onEndTriggerAction();
...@@ -181,7 +184,9 @@ CHistory.prototype = ...@@ -181,7 +184,9 @@ CHistory.prototype =
this.workbook.handlers.trigger("setSelection", oSelectRange.clone(), /*validRange*/false); this.workbook.handlers.trigger("setSelection", oSelectRange.clone(), /*validRange*/false);
this._sendCanUndoRedo(); this._sendCanUndoRedo();
if (isReInit)
this.workbook.handlers.trigger("reInit");
this.workbook.handlers.trigger("drawWS"); this.workbook.handlers.trigger("drawWS");
/* возвращаем отрисовку. и перерисовываем ячейки с предварительным пересчетом */ /* возвращаем отрисовку. и перерисовываем ячейки с предварительным пересчетом */
...@@ -190,22 +195,17 @@ CHistory.prototype = ...@@ -190,22 +195,17 @@ CHistory.prototype =
if(bIsOn) if(bIsOn)
this.TurnOn(); this.TurnOn();
}, },
RedoPrepare : function() RedoPrepare : function (oRedoObjectParam) {
{ if (this.Is_On()) {
var bIsOn = false; oRedoObjectParam.bIsOn = true;
if(this.Is_On())
{
bIsOn = true;
this.TurnOff(); this.TurnOff();
} }
/* отключаем отрисовку на случай необходимости пересчета ячеек, заносим ячейку, при необходимости в список перерисовываемых */ /* отключаем отрисовку на случай необходимости пересчета ячеек, заносим ячейку, при необходимости в список перерисовываемых */
lockDraw(this.workbook); lockDraw(this.workbook);
this.workbook.handlers.trigger("lockDraw"); this.workbook.handlers.trigger("lockDraw");
return bIsOn;
}, },
RedoAdd : function(aStartTriggerAction, Class, Type, sheetid, range, Data, LocalChange) RedoAdd : function(oRedoObjectParam, Class, Type, sheetid, range, Data, LocalChange)
{ {
//todo сделать что-нибудь с Is_On //todo сделать что-нибудь с Is_On
var bNeedOff = false; var bNeedOff = false;
...@@ -217,30 +217,34 @@ CHistory.prototype = ...@@ -217,30 +217,34 @@ CHistory.prototype =
this.Add(Class, Type, sheetid, range, Data, LocalChange); this.Add(Class, Type, sheetid, range, Data, LocalChange);
if(bNeedOff) if(bNeedOff)
this.TurnOff(); this.TurnOff();
if(null != sheetid && null == aStartTriggerAction[sheetid]) if(null != sheetid && null == oRedoObjectParam.aStartTriggerAction[sheetid])
{ {
var ws = this.workbook.getWorksheetById(sheetid); var ws = this.workbook.getWorksheetById(sheetid);
ws.onStartTriggerAction(); ws.onStartTriggerAction();
aStartTriggerAction[sheetid] = ws; oRedoObjectParam.aStartTriggerAction[sheetid] = ws;
} }
Class.Redo( Type, Data, sheetid ); Class.Redo( Type, Data, sheetid );
if (g_oUndoRedoWorksheet === Class && historyitem_Worksheet_SetViewSettings === Type)
oRedoObjectParam.bIsReInit = true;
}, },
RedoExecute : function(Point, aStartTriggerAction) RedoExecute : function(Point, oRedoObjectParam)
{ {
// Выполняем все действия в прямом порядке // Выполняем все действия в прямом порядке
for ( var Index = 0; Index < Point.Items.length; Index++ ) for ( var Index = 0; Index < Point.Items.length; Index++ )
{ {
var Item = Point.Items[Index]; var Item = Point.Items[Index];
if(null != Item.SheetId && null == aStartTriggerAction[Item.SheetId]) if(null != Item.SheetId && null == oRedoObjectParam.aStartTriggerAction[Item.SheetId])
{ {
var ws = this.workbook.getWorksheetById(Item.SheetId); var ws = this.workbook.getWorksheetById(Item.SheetId);
ws.onStartTriggerAction(); ws.onStartTriggerAction();
aStartTriggerAction[Item.SheetId] = ws; oRedoObjectParam.aStartTriggerAction[Item.SheetId] = ws;
} }
Item.Class.Redo( Item.Type, Item.Data, Item.SheetId ); Item.Class.Redo( Item.Type, Item.Data, Item.SheetId );
if (g_oUndoRedoWorksheet === Item.Class && historyitem_Worksheet_SetViewSettings === Item.Type)
oRedoObjectParam.bIsReInit = true;
} }
}, },
RedoEnd : function(Point, bIsOn, aStartTriggerAction) RedoEnd : function(Point, oRedoObjectParam)
{ {
if(null == Point) if(null == Point)
{ {
...@@ -249,8 +253,8 @@ CHistory.prototype = ...@@ -249,8 +253,8 @@ CHistory.prototype =
} }
if(null == Point) if(null == Point)
return; return;
for(var i in aStartTriggerAction) for(var i in oRedoObjectParam.aStartTriggerAction)
aStartTriggerAction[i].onEndTriggerAction(); oRedoObjectParam.aStartTriggerAction[i].onEndTriggerAction();
for(var i in Point.Triggers) for(var i in Point.Triggers)
this.workbook.handlers.trigger.apply(this.workbook.handlers, Point.Triggers[i]); this.workbook.handlers.trigger.apply(this.workbook.handlers, Point.Triggers[i]);
var oSelectRange = null; var oSelectRange = null;
...@@ -268,13 +272,15 @@ CHistory.prototype = ...@@ -268,13 +272,15 @@ CHistory.prototype =
this.workbook.handlers.trigger("setSelection", oSelectRange.clone()); this.workbook.handlers.trigger("setSelection", oSelectRange.clone());
this._sendCanUndoRedo(); this._sendCanUndoRedo();
if (oRedoObjectParam.bIsReInit)
this.workbook.handlers.trigger("reInit");
this.workbook.handlers.trigger("drawWS"); this.workbook.handlers.trigger("drawWS");
/* возвращаем отрисовку. и перерисовываем ячейки с предварительным пересчетом */ /* возвращаем отрисовку. и перерисовываем ячейки с предварительным пересчетом */
helpFunction(this.workbook); helpFunction(this.workbook);
unLockDraw(this.workbook); unLockDraw(this.workbook);
if(bIsOn) if(oRedoObjectParam.bIsOn)
this.TurnOn(); this.TurnOn();
}, },
Redo : function() Redo : function()
...@@ -282,8 +288,9 @@ CHistory.prototype = ...@@ -282,8 +288,9 @@ CHistory.prototype =
// Проверяем можно ли сделать Redo // Проверяем можно ли сделать Redo
if ( true != this.Can_Redo() ) if ( true != this.Can_Redo() )
return null; return null;
var bIsOn = this.RedoPrepare(); var oRedoObjectParam = new Asc.RedoObjectParam();
this.RedoPrepare(oRedoObjectParam);
this.CurPoint = null; this.CurPoint = null;
var Point = this.Points[++this.Index]; var Point = this.Points[++this.Index];
...@@ -291,10 +298,9 @@ CHistory.prototype = ...@@ -291,10 +298,9 @@ CHistory.prototype =
var oCurWorksheet = this.workbook.getWorksheet(this.workbook.getActive()); var oCurWorksheet = this.workbook.getWorksheet(this.workbook.getActive());
if(null != Point.nLastSheetId && Point.nLastSheetId != oCurWorksheet.getId()) if(null != Point.nLastSheetId && Point.nLastSheetId != oCurWorksheet.getId())
this.workbook.handlers.trigger("showWorksheet", Point.nLastSheetId); this.workbook.handlers.trigger("showWorksheet", Point.nLastSheetId);
var aStartTriggerAction = new Object(); this.RedoExecute(Point, oRedoObjectParam);
this.RedoExecute(Point, aStartTriggerAction);
this.RedoEnd(Point, bIsOn, aStartTriggerAction); this.RedoEnd(Point, oRedoObjectParam);
}, },
Create_NewPoint : function() Create_NewPoint : function()
{ {
......
...@@ -2037,8 +2037,8 @@ Workbook.prototype.DeserializeHistory = function(aChanges, fCallback){ ...@@ -2037,8 +2037,8 @@ Workbook.prototype.DeserializeHistory = function(aChanges, fCallback){
window["Asc"]["editor"]._loadFonts(aFontMap, function(){ window["Asc"]["editor"]._loadFonts(aFontMap, function(){
var oHistoryPositions = null;//нужен самый последний historyitem_Workbook_SheetPositions var oHistoryPositions = null;//нужен самый последний historyitem_Workbook_SheetPositions
var bIsOn = History.RedoPrepare(); var oRedoObjectParam = new Asc.RedoObjectParam();
var aStartTriggerAction = new Object(); History.RedoPrepare(oRedoObjectParam);
for(var i = 0, length = aChanges.length; i < length; ++i) for(var i = 0, length = aChanges.length; i < length; ++i)
{ {
var sChange = aChanges[i]; var sChange = aChanges[i];
...@@ -2053,14 +2053,14 @@ Workbook.prototype.DeserializeHistory = function(aChanges, fCallback){ ...@@ -2053,14 +2053,14 @@ Workbook.prototype.DeserializeHistory = function(aChanges, fCallback){
if(g_oUndoRedoWorkbook == item.oClass && historyitem_Workbook_SheetPositions == item.nActionType) if(g_oUndoRedoWorkbook == item.oClass && historyitem_Workbook_SheetPositions == item.nActionType)
oHistoryPositions = item; oHistoryPositions = item;
else else
History.RedoAdd(aStartTriggerAction, item.oClass, item.nActionType, item.nSheetId, item.oRange, item.oData); History.RedoAdd(oRedoObjectParam, item.oClass, item.nActionType, item.nSheetId, item.oRange, item.oData);
} }
} }
} }
if(null != oHistoryPositions) if(null != oHistoryPositions)
History.RedoAdd(aStartTriggerAction, oHistoryPositions.oClass, oHistoryPositions.nActionType, oHistoryPositions.nSheetId, oHistoryPositions.oRange, oHistoryPositions.oData); History.RedoAdd(oRedoObjectParam, oHistoryPositions.oClass, oHistoryPositions.nActionType, oHistoryPositions.nSheetId, oHistoryPositions.oRange, oHistoryPositions.oData);
History.RedoEnd(null, bIsOn, aStartTriggerAction); History.RedoEnd(null, oRedoObjectParam);
this.bCollaborativeChanges = false; this.bCollaborativeChanges = false;
History.Clear(); History.Clear();
if(null != fCallback) if(null != fCallback)
...@@ -2578,7 +2578,7 @@ Woorksheet.prototype.setSheetViewSettings = function (options) { ...@@ -2578,7 +2578,7 @@ Woorksheet.prototype.setSheetViewSettings = function (options) {
History.Create_NewPoint(); History.Create_NewPoint();
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_SetViewSettings, this.getId(), null, new UndoRedoData_FromTo(current, options.clone())); History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_SetViewSettings, this.getId(), null, new UndoRedoData_FromTo(current, options.clone()));
this.sheetViews[0].set(options); this.sheetViews[0].setSettings(options);
}; };
Woorksheet.prototype.getRowsCount=function(){ Woorksheet.prototype.getRowsCount=function(){
return this.nRowsCount; return this.nRowsCount;
......
...@@ -658,7 +658,7 @@ ...@@ -658,7 +658,7 @@
return this.asc_getShowGridLines() === settings.asc_getShowGridLines() && return this.asc_getShowGridLines() === settings.asc_getShowGridLines() &&
this.asc_getShowRowColHeaders() === settings.asc_getShowRowColHeaders(); this.asc_getShowRowColHeaders() === settings.asc_getShowRowColHeaders();
}, },
set: function (settings) { setSettings: function (settings) {
this.showGridLines = settings.showGridLines; this.showGridLines = settings.showGridLines;
this.showRowColHeaders = settings.showRowColHeaders; this.showRowColHeaders = settings.showRowColHeaders;
}, },
...@@ -686,6 +686,16 @@ ...@@ -686,6 +686,16 @@
} }
}; };
function RedoObjectParam () {
if (!(this instanceof RedoObjectParam)) {
return new RedoObjectParam();
}
this.bIsOn = false;
this.aStartTriggerAction = {};
this.bIsReInit = false;
}
/* /*
* Export * Export
...@@ -722,6 +732,8 @@ ...@@ -722,6 +732,8 @@
prot.add = prot.add; prot.add = prot.add;
prot.remove = prot.remove; prot.remove = prot.remove;
window["Asc"].RedoObjectParam = RedoObjectParam;
window["Asc"]["asc_CMouseMoveData"] = window["Asc"].asc_CMouseMoveData = asc_CMouseMoveData; window["Asc"]["asc_CMouseMoveData"] = window["Asc"].asc_CMouseMoveData = asc_CMouseMoveData;
prot = asc_CMouseMoveData.prototype; prot = asc_CMouseMoveData.prototype;
prot["asc_getType"] = prot.asc_getType; prot["asc_getType"] = prot.asc_getType;
......
...@@ -232,6 +232,9 @@ ...@@ -232,6 +232,9 @@
this.model.handlers.add("setSelection", function () { this.model.handlers.add("setSelection", function () {
self._onSetSelection.apply(self, arguments); self._onSetSelection.apply(self, arguments);
}); });
this.model.handlers.add("reInit", function () {
self.reInit.apply(self, arguments);
});
this.model.handlers.add("drawWS", function () { this.model.handlers.add("drawWS", function () {
self.drawWS.apply(self, arguments); self.drawWS.apply(self, arguments);
}); });
...@@ -1380,7 +1383,13 @@ ...@@ -1380,7 +1383,13 @@
wsModel.aCommentsCoords = wsView.cellCommentator.aCommentCoords; wsModel.aCommentsCoords = wsView.cellCommentator.aCommentCoords;
} }
}, },
reInit: function () {
var ws = this.getWorksheet();
ws._initCellsArea(/*fullRecalc*/true);
ws._updateVisibleColsCount();
ws._updateVisibleRowsCount();
},
drawWS: function(){ drawWS: function(){
this._lockDraw = false; this._lockDraw = false;
this.getWorksheet().draw(this._lockDraw); this.getWorksheet().draw(this._lockDraw);
......
...@@ -1148,8 +1148,6 @@ ...@@ -1148,8 +1148,6 @@
this.maxRowHeight = asc_calcnpt( 409, this._getPPIY() ); this.maxRowHeight = asc_calcnpt( 409, this._getPPIY() );
this.defaultRowDescender = this._calcRowDescender(this.settings.cells.fontSize); this.defaultRowDescender = this._calcRowDescender(this.settings.cells.fontSize);
this.defaultRowHeight = asc_calcnpt( this.settings.cells.fontSize * this.vspRatio, this._getPPIY() ) + this.height_1px; this.defaultRowHeight = asc_calcnpt( this.settings.cells.fontSize * this.vspRatio, this._getPPIY() ) + this.height_1px;
this._calcHeaderRowHeight();
}, },
_initCellsArea: function (fullRecalc) { _initCellsArea: function (fullRecalc) {
this.width_1px = asc_calcnpt(0, this._getPPIX(), 1/*px*/); this.width_1px = asc_calcnpt(0, this._getPPIX(), 1/*px*/);
...@@ -1161,6 +1159,7 @@ ...@@ -1161,6 +1159,7 @@
this.height_3px = asc_calcnpt(0, this._getPPIY(), 3/*px*/); this.height_3px = asc_calcnpt(0, this._getPPIY(), 3/*px*/);
// calculate rows heights and visible rows // calculate rows heights and visible rows
this._calcHeaderRowHeight();
this._calcRowHeights(fullRecalc ? 1 : 0); this._calcRowHeights(fullRecalc ? 1 : 0);
this.visibleRange.r2 = 0; this.visibleRange.r2 = 0;
this._calcVisibleRows(); this._calcVisibleRows();
...@@ -1238,10 +1237,14 @@ ...@@ -1238,10 +1237,14 @@
/** Вычисляет ширину колонки заголовков (в pt) */ /** Вычисляет ширину колонки заголовков (в pt) */
_calcHeaderColumnWidth: function () { _calcHeaderColumnWidth: function () {
// Ширина колонки заголовков считается - max число знаков в строке - перевести в символы - перевести в пикселы if (false === this.model.sheetViews[0].asc_getShowRowColHeaders())
var numDigit = Math.max( calcDecades(this.visibleRange.r2 + 1), 3); this.headersWidth = 0;
var nCharCount = this._charCountToModelColWidth(numDigit); else {
this.headersWidth = this._modelColWidthToColWidth(nCharCount); // Ширина колонки заголовков считается - max число знаков в строке - перевести в символы - перевести в пикселы
var numDigit = Math.max( calcDecades(this.visibleRange.r2 + 1), 3);
var nCharCount = this._charCountToModelColWidth(numDigit);
this.headersWidth = this._modelColWidthToColWidth(nCharCount);
}
//var w = this.emSize * Math.max( calcDecades(this.visibleRange.r2 + 1), 3) * 1.25; //var w = this.emSize * Math.max( calcDecades(this.visibleRange.r2 + 1), 3) * 1.25;
//this.headersWidth = asc_calcnpt(w, this._getPPIX()); //this.headersWidth = asc_calcnpt(w, this._getPPIX());
...@@ -1251,7 +1254,10 @@ ...@@ -1251,7 +1254,10 @@
/** Вычисляет высоту строки заголовков (в pt) */ /** Вычисляет высоту строки заголовков (в pt) */
_calcHeaderRowHeight: function () { _calcHeaderRowHeight: function () {
this.headersHeight = this.model.getDefaultHeight() || this.defaultRowHeight; if (false === this.model.sheetViews[0].asc_getShowRowColHeaders())
this.headersHeight = 0;
else
this.headersHeight = this.model.getDefaultHeight() || this.defaultRowHeight;
//this.headersHeight = asc_calcnpt( this.settings.header.fontSize * this.vspRatio, this._getPPIY() ); //this.headersHeight = asc_calcnpt( this.settings.header.fontSize * this.vspRatio, this._getPPIY() );
this.cellsTop = this.headersTop + this.headersHeight; this.cellsTop = this.headersTop + this.headersHeight;
...@@ -1971,6 +1977,8 @@ ...@@ -1971,6 +1977,8 @@
}, },
_drawCorner: function () { _drawCorner: function () {
if (false === this.model.sheetViews[0].asc_getShowRowColHeaders())
return;
var x1 = this.headersLeft + this.headersWidth - this.headersHeight; var x1 = this.headersLeft + this.headersWidth - this.headersHeight;
var x2 = this.headersLeft + this.headersWidth; var x2 = this.headersLeft + this.headersWidth;
var y1 = this.headersTop; var y1 = this.headersTop;
...@@ -1996,6 +2004,8 @@ ...@@ -1996,6 +2004,8 @@
/** Рисует заголовки видимых колонок */ /** Рисует заголовки видимых колонок */
_drawColumnHeaders: function (drawingCtx, start, end, style, offsetXForDraw, offsetYForDraw) { _drawColumnHeaders: function (drawingCtx, start, end, style, offsetXForDraw, offsetYForDraw) {
if (undefined === drawingCtx && false === this.model.sheetViews[0].asc_getShowRowColHeaders())
return;
var hdr = this.settings.header; var hdr = this.settings.header;
var cells = this.settings.cells; var cells = this.settings.cells;
var vr = this.visibleRange; var vr = this.visibleRange;
...@@ -2021,6 +2031,8 @@ ...@@ -2021,6 +2031,8 @@
/** Рисует заголовки видимых строк */ /** Рисует заголовки видимых строк */
_drawRowHeaders: function (drawingCtx, start, end, style, offsetXForDraw, offsetYForDraw) { _drawRowHeaders: function (drawingCtx, start, end, style, offsetXForDraw, offsetYForDraw) {
if (undefined === drawingCtx && false === this.model.sheetViews[0].asc_getShowRowColHeaders())
return;
var hdr = this.settings.header; var hdr = this.settings.header;
var cells = this.settings.cells; var cells = this.settings.cells;
var vr = this.visibleRange; var vr = this.visibleRange;
...@@ -4885,8 +4897,8 @@ ...@@ -4885,8 +4897,8 @@
if (this.isCellEditMode && editor) {editor.move(-dx, 0);} if (this.isCellEditMode && editor) {editor.move(-dx, 0);}
vr.c1 = start; vr.c1 = start;
this._updateVisibleColsCount(); this._updateVisibleColsCount();
this.objectRender.setScrollOffset( dx * asc_getcvt(1, 0, this._getPPIX()), 0 ); this.objectRender.setScrollOffset( dx * asc_getcvt(1, 0, this._getPPIX()), 0 );
var oldW = ctxW - this.cellsLeft - Math.abs(dx); var oldW = ctxW - this.cellsLeft - Math.abs(dx);
...@@ -8288,7 +8300,7 @@ ...@@ -8288,7 +8300,7 @@
isUpdateCols = true; isUpdateCols = true;
isUpdateRows = true; isUpdateRows = true;
fullRecalc = false; fullRecalc = true;
}; };
return this._isLockedAll (onChangeWorksheetCallback); return this._isLockedAll (onChangeWorksheetCallback);
......
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