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