Commit 6993b04b authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander.Trofimov

ActiveRange запоминается в историю при создании новой точки, функциями...

ActiveRange запоминается в историю при создании новой точки, функциями SetSelection, SetSelectionRedo можно изменить этот диапазон.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@52290 954022d7-b5bf-4e40-9824-e11837661b57
parent 222b175b
......@@ -409,17 +409,10 @@ CHistory.prototype =
isRedrawAll = false;
}
gUndoInsDelCellsFlag = true;
var oSelectRange = null;
if(null != Point.SelectRange)
oSelectRange = Point.SelectRange;
for(var i in Point.UpdateRigions)
{
this.workbook.handlers.trigger("cleanCellCache", i, Point.UpdateRigions[i]);
if(null != Point.nLastSheetId && i - 0 == Point.nLastSheetId && null == oSelectRange)
oSelectRange = Point.UpdateRigions[i];
}
if(false == Point.bNoSelect && null != oSelectRange)
this.workbook.handlers.trigger("setSelection", oSelectRange.clone(), /*validRange*/false);
if(null != Point.SelectRange)
this.workbook.handlers.trigger("setSelection", Point.SelectRange.clone(), /*validRange*/false);
if ( Point.SelectionState != null )
this.workbook.handlers.trigger("setSelectionState", Point.SelectionState);
......@@ -511,12 +504,8 @@ CHistory.prototype =
else if(null != Point.SelectRange)
oSelectRange = Point.SelectRange;
for(var i in Point.UpdateRigions)
{
this.workbook.handlers.trigger("cleanCellCache", i, Point.UpdateRigions[i]);
if(null != Point.nLastSheetId && i - 0 == Point.nLastSheetId && null == oSelectRange)
oSelectRange = Point.UpdateRigions[i];
}
if(false == Point.bNoSelect && null != oSelectRange)
if(null != oSelectRange)
this.workbook.handlers.trigger("setSelection", oSelectRange.clone());
//if (Point.SelectionState != null)
// this.workbook.handlers.trigger("setSelectionState", Point.SelectionState);
......@@ -561,13 +550,13 @@ CHistory.prototype =
var Items = new Array();
var UpdateRigions = new Object();
var Time = new Date().getTime();
var oSelectRange = this.workbook.handlers.trigger("getSelection");
this.CurPoint = {
Items : Items, // Массив изменений, начиная с текущего момента
UpdateRigions : UpdateRigions,
nLastSheetId : null,
SelectRange : null,
SelectRangeRedo : null,
bNoSelect : false,
SelectRange : oSelectRange,
SelectRangeRedo : oSelectRange,
Time : Time, // Текущее время
SelectionState : this.workbook.handlers.trigger("getSelectionState")
};
......@@ -634,29 +623,38 @@ CHistory.prototype =
this.CurPoint = null;
}
},
SetSelection : function(range, bNoSelect)
SetSelection : function(range)
{
if ( 0 !== this.TurnOffHistory || 0 !== this.Transaction )
if ( 0 !== this.TurnOffHistory )
return;
if ( null == this.CurPoint )
return;
this.CurPoint.SelectRange = range;
if(null != bNoSelect)
this.CurPoint.bNoSelect = bNoSelect
},
SetSelectionRedo : function(range, bNoSelect)
SetSelectionRedo : function(range)
{
if ( 0 !== this.TurnOffHistory || 0 !== this.Transaction )
if ( 0 !== this.TurnOffHistory )
return;
if ( null == this.CurPoint )
return;
this.CurPoint.SelectRangeRedo = range;
if(null != bNoSelect)
this.CurPoint.bNoSelect = bNoSelect
},
GetSelection : function(range)
{
var oRes = null;
if(null != this.CurPoint)
oRes = this.CurPoint.SelectRange;
return oRes;
},
GetSelectionRedo : function(range)
{
var oRes = null;
if(null != this.CurPoint)
oRes = this.CurPoint.SelectRangeRedo;
return oRes;
},
TurnOff : function()
{
this.TurnOffHistory++;
......
......@@ -2106,7 +2106,8 @@ Workbook.prototype.DeserializeHistory = function(aChanges, fCallback){
window["Asc"]["editor"]._loadFonts(aFontMap, function(){
History.Clear();
History.Create_NewPoint();
History.SetSelection(null, true);
History.SetSelection(null);
History.SetSelectionRedo(null);
var oHistoryPositions = null;//нужен самый последний historyitem_Workbook_SheetPositions
var oRedoObjectParam = new Asc.RedoObjectParam();
History.RedoPrepare(oRedoObjectParam);
......@@ -2686,7 +2687,6 @@ Woorksheet.prototype.removeRows=function(start, stop){
Woorksheet.prototype._removeRows=function(start, stop){
lockDraw(this.workbook);
History.Create_NewPoint();
History.SetSelection(null, true);
//start, stop 0 based
var nDif = -(stop - start + 1);
var aIndexes = new Array();
......@@ -2747,7 +2747,6 @@ Woorksheet.prototype._insertRowsBefore=function(index, count){
lockDraw(this.workbook);
var oActualRange = {r1: index, c1: 0, r2: index + count - 1, c2: gc_nMaxCol0};
History.Create_NewPoint();
History.SetSelection(null, true);
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_AddRows, this.getId(), new Asc.Range(0, index, gc_nMaxCol0, gc_nMaxRow0), new UndoRedoData_FromToRowCol(true, index, index + count - 1));
History.TurnOff();
//index 0 based
......@@ -2811,7 +2810,6 @@ Woorksheet.prototype.removeCols=function(start, stop){
Woorksheet.prototype._removeCols=function(start, stop){
lockDraw(this.workbook);
History.Create_NewPoint();
History.SetSelection(null, true);
//start, stop 0 based
var nDif = -(stop - start + 1);
for(var i in this.aGCells)
......@@ -2880,7 +2878,6 @@ Woorksheet.prototype._insertColsBefore=function(index, count){
lockDraw(this.workbook);
var oActualRange = {r1: 0, c1: index, r2: gc_nMaxRow0, c2: index + count - 1};
History.Create_NewPoint();
History.SetSelection(null, true);
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_AddCols, this.getId(), new Asc.Range(0, 0, gc_nMaxCol0, gc_nMaxRow0), new UndoRedoData_FromToRowCol(false, index, index + count - 1));
History.TurnOff();
//index 0 based
......@@ -2967,7 +2964,15 @@ Woorksheet.prototype.setColWidth=function(width, start, stop){
if(null == stop)
stop = start;
History.Create_NewPoint();
History.SetSelection(null, true);
var oSelection = History.GetSelection();
if(null != oSelection)
{
oSelection = oSelection.clone();
oSelection.assign(start, 0, stop, gc_nMaxRow0);
oSelection.type = c_oAscSelectionType.RangeCol;
History.SetSelection(oSelection);
History.SetSelectionRedo(oSelection);
}
var oThis = this;
var fProcessCol = function(col){
if(col.width != width)
......@@ -3002,7 +3007,6 @@ Woorksheet.prototype.setColHidden=function(bHidden, start, stop){
if(null == stop)
stop = start;
History.Create_NewPoint();
History.SetSelection(null, true);
var oThis = this;
var fProcessCol = function(col){
if(col.hd != bHidden)
......@@ -3057,7 +3061,6 @@ Woorksheet.prototype.setColBestFit=function(bBestFit, width, start, stop){
if(null == stop)
stop = start;
History.Create_NewPoint();
History.SetSelection(null, true);
var oThis = this;
var fProcessCol = function(col){
var oOldProps = col.getWidthProp();
......@@ -3116,7 +3119,15 @@ Woorksheet.prototype.setRowHeight=function(height, start, stop){
if(null == stop)
stop = start;
History.Create_NewPoint();
History.SetSelection(null, true);
var oSelection = History.GetSelection();
if(null != oSelection)
{
oSelection = oSelection.clone();
oSelection.assign(0, start, gc_nMaxCol0, stop);
oSelection.type = c_oAscSelectionType.RangeRow;
History.SetSelection(oSelection);
History.SetSelectionRedo(oSelection);
}
for(var i = start;i <= stop; i++){
var oCurRow = this._getRow(i);
if(oCurRow.h != height)
......@@ -3138,7 +3149,6 @@ Woorksheet.prototype.setRowHidden=function(bHidden, start, stop){
if(null == stop)
stop = start;
History.Create_NewPoint();
History.SetSelection(null, true);
for(var i = start;i <= stop; i++){
var oCurRow = null;
if(false == bHidden)
......@@ -3165,7 +3175,6 @@ Woorksheet.prototype.setRowBestFit=function(bBestFit, height, start, stop){
if(null == stop)
stop = start;
History.Create_NewPoint();
History.SetSelection(null, true);
for(var i = start;i <= stop; i++){
var oCurRow = null;
if(true == bBestFit && gc_dDefaultRowHeightAttribute == height)
......@@ -3566,8 +3575,6 @@ Woorksheet.prototype._moveRange=function(oBBoxFrom, oBBoxTo){
return;
var oThis = this;
History.Create_NewPoint();
History.SetSelection(new Asc.Range(oBBoxFrom.c1, oBBoxFrom.r1, oBBoxFrom.c2, oBBoxFrom.r2));
History.SetSelectionRedo(new Asc.Range(oBBoxTo.c1, oBBoxTo.r1, oBBoxTo.c2, oBBoxTo.r2));
History.StartTransaction();
var offset = { offsetRow : oBBoxTo.r1 - oBBoxFrom.r1, offsetCol : oBBoxTo.c1 - oBBoxFrom.c1 };
......@@ -5116,7 +5123,6 @@ Range.prototype.getCells=function(){
Range.prototype.setValue=function(val,callback){
History.Create_NewPoint();
var oBBox = this.bbox;
History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2));
History.StartTransaction();
var oThis = this;
this._foreach(function(cell){
......@@ -5129,7 +5135,6 @@ Range.prototype.setValue=function(val,callback){
Range.prototype.setValue2=function(array){
History.Create_NewPoint();
var oBBox = this.bbox;
History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2));
History.StartTransaction();
var wb = this.worksheet.workbook, ws = this.worksheet, needRecalc = false, ar =[];
//[{"text":"qwe","format":{"b":true, "i":false, "u":"none", "s":false, "fn":"Arial", "fs": 12, "c": 0xff00ff, "va": "subscript" }},{}...]
......@@ -5147,7 +5152,6 @@ Range.prototype.setValue2=function(array){
Range.prototype.setCellStyle=function(val){
History.Create_NewPoint();
var oBBox = this.bbox;
History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2));
this.createCellOnRowColCross();
var fSetProperty = this._setProperty;
var nRangeType = this._getRangeType();
......@@ -5192,7 +5196,6 @@ Range.prototype.setTableStyle=function(val){
Range.prototype.setNumFormat=function(val){
History.Create_NewPoint();
var oBBox = this.bbox;
History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2));
this.createCellOnRowColCross();
var fSetProperty = this._setProperty;
var nRangeType = this._getRangeType();
......@@ -5216,7 +5219,6 @@ Range.prototype.setNumFormat=function(val){
Range.prototype.shiftNumFormat=function(nShift, aDigitsCount){
History.Create_NewPoint();
var oBBox = this.bbox;
History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2));
var bRes = false;
var oThis = this;
this._setPropertyNoEmpty(null, null, function(cell, nRow0, nCol0, nRowStart, nColStart){
......@@ -5226,7 +5228,6 @@ Range.prototype.shiftNumFormat=function(nShift, aDigitsCount){
}
Range.prototype.setFont=function(val){
History.Create_NewPoint();
History.SetSelection(this.bbox.clone());
this.createCellOnRowColCross();
var fSetProperty = this._setProperty;
var nRangeType = this._getRangeType();
......@@ -5250,7 +5251,6 @@ Range.prototype.setFont=function(val){
Range.prototype.setFontname=function(val){
History.Create_NewPoint();
var oBBox = this.bbox;
History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2));
this.createCellOnRowColCross();
var fSetProperty = this._setProperty;
var nRangeType = this._getRangeType();
......@@ -5274,7 +5274,6 @@ Range.prototype.setFontname=function(val){
Range.prototype.setFontsize=function(val){
History.Create_NewPoint();
var oBBox = this.bbox;
History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2));
this.createCellOnRowColCross();
var fSetProperty = this._setProperty;
var nRangeType = this._getRangeType();
......@@ -5298,7 +5297,6 @@ Range.prototype.setFontsize=function(val){
Range.prototype.setFontcolor=function(val){
History.Create_NewPoint();
var oBBox = this.bbox;
History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2));
this.createCellOnRowColCross();
var fSetProperty = this._setProperty;
var nRangeType = this._getRangeType();
......@@ -5322,7 +5320,6 @@ Range.prototype.setFontcolor=function(val){
Range.prototype.setBold=function(val){
History.Create_NewPoint();
var oBBox = this.bbox;
History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2));
this.createCellOnRowColCross();
var fSetProperty = this._setProperty;
var nRangeType = this._getRangeType();
......@@ -5346,7 +5343,6 @@ Range.prototype.setBold=function(val){
Range.prototype.setItalic=function(val){
History.Create_NewPoint();
var oBBox = this.bbox;
History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2));
this.createCellOnRowColCross();
var fSetProperty = this._setProperty;
var nRangeType = this._getRangeType();
......@@ -5370,7 +5366,6 @@ Range.prototype.setItalic=function(val){
Range.prototype.setUnderline=function(val){
History.Create_NewPoint();
var oBBox = this.bbox;
History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2));
this.createCellOnRowColCross();
var fSetProperty = this._setProperty;
var nRangeType = this._getRangeType();
......@@ -5394,7 +5389,6 @@ Range.prototype.setUnderline=function(val){
Range.prototype.setStrikeout=function(val){
History.Create_NewPoint();
var oBBox = this.bbox;
History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2));
this.createCellOnRowColCross();
var fSetProperty = this._setProperty;
var nRangeType = this._getRangeType();
......@@ -5418,7 +5412,6 @@ Range.prototype.setStrikeout=function(val){
Range.prototype.setFontAlign=function(val){
History.Create_NewPoint();
var oBBox = this.bbox;
History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2));
this.createCellOnRowColCross();
var fSetProperty = this._setProperty;
var nRangeType = this._getRangeType();
......@@ -5442,7 +5435,6 @@ Range.prototype.setFontAlign=function(val){
Range.prototype.setAlignVertical=function(val){
History.Create_NewPoint();
var oBBox = this.bbox;
History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2));
if("none" == val)
val = null;
this.createCellOnRowColCross();
......@@ -5468,7 +5460,6 @@ Range.prototype.setAlignVertical=function(val){
Range.prototype.setAlignHorizontal=function(val){
History.Create_NewPoint();
var oBBox = this.bbox;
History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2));
this.createCellOnRowColCross();
var fSetProperty = this._setProperty;
var nRangeType = this._getRangeType();
......@@ -5492,7 +5483,6 @@ Range.prototype.setAlignHorizontal=function(val){
Range.prototype.setFill=function(val){
History.Create_NewPoint();
var oBBox = this.bbox;
History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2));
this.createCellOnRowColCross();
var fSetProperty = this._setProperty;
var nRangeType = this._getRangeType();
......@@ -5516,7 +5506,6 @@ Range.prototype.setFill=function(val){
Range.prototype.setBorderSrc=function(border){
History.Create_NewPoint();
var oBBox = this.bbox;
History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2));
History.StartTransaction();
if (null == border)
border = new Border();
......@@ -5546,7 +5535,6 @@ Range.prototype.setBorder=function(border){
//border = null очисть border
//"ih" - внутренние горизонтальные, "iv" - внутренние вертикальные
var oBBox = this.bbox;
History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2));
var nRangeType = this._getRangeType();
var oThis = this;
var fSetBorder = function(nRow, nCol, oNewBorder)
......@@ -6131,7 +6119,6 @@ Range.prototype.setBorder=function(border){
Range.prototype.setShrinkToFit=function(val){
History.Create_NewPoint();
var oBBox = this.bbox;
History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2));
this.createCellOnRowColCross();
var fSetProperty = this._setProperty;
var nRangeType = this._getRangeType();
......@@ -6155,7 +6142,6 @@ Range.prototype.setShrinkToFit=function(val){
Range.prototype.setWrap=function(val){
History.Create_NewPoint();
var oBBox = this.bbox;
History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2));
this.createCellOnRowColCross();
var fSetProperty = this._setProperty;
var nRangeType = this._getRangeType();
......@@ -6179,7 +6165,6 @@ Range.prototype.setWrap=function(val){
Range.prototype.setAngle=function(val){
History.Create_NewPoint();
var oBBox = this.bbox;
History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2));
this.createCellOnRowColCross();
var fSetProperty = this._setProperty;
var nRangeType = this._getRangeType();
......@@ -6203,7 +6188,6 @@ Range.prototype.setAngle=function(val){
Range.prototype.setVerticalText=function(val){
History.Create_NewPoint();
var oBBox = this.bbox;
History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2));
this.createCellOnRowColCross();
var fSetProperty = this._setProperty;
var nRangeType = this._getRangeType();
......@@ -6888,7 +6872,6 @@ Range.prototype.merge=function(type){
if(oBBox.r1 == oBBox.r2 && oBBox.c1 == oBBox.c2)
return;
History.Create_NewPoint();
History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2));
History.StartTransaction();
if(this.hasMerged())
{
......@@ -7193,7 +7176,6 @@ Range.prototype.merge=function(type){
};
Range.prototype.unmerge=function(bOnlyInRange){
History.Create_NewPoint();
History.SetSelection(this.bbox.clone());
History.StartTransaction();
if(false == this.worksheet.workbook.bUndoChanges && false == this.worksheet.workbook.bRedoChanges)
this.worksheet.mergeManager.remove(this.bbox, null);
......@@ -7290,7 +7272,6 @@ Range.prototype.setHyperlink=function(val, bWithoutStyle){
{
var oThis = this;
History.Create_NewPoint();
History.SetSelection(this.bbox.clone());
History.StartTransaction();
if(false == this.worksheet.workbook.bUndoChanges && false == this.worksheet.workbook.bRedoChanges)
{
......@@ -7326,7 +7307,6 @@ Range.prototype.removeHyperlink=function(val){
elem = new RangeDataManagerElem(bbox, val);
}
History.Create_NewPoint();
History.SetSelection(bbox.clone());
History.StartTransaction();
if(false == this.worksheet.workbook.bUndoChanges && false == this.worksheet.workbook.bRedoChanges)
this.worksheet.hyperlinkManager.remove(bbox, elem);
......@@ -7354,7 +7334,6 @@ Range.prototype._shiftLeftRight=function(bLeft){
var mergeManager = this.worksheet.mergeManager;
//todo вставить предупреждение, что будет unmerge
History.Create_NewPoint();
History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2));
History.StartTransaction();
if(false == this.worksheet.workbook.bUndoChanges && false == this.worksheet.workbook.bRedoChanges)
{
......@@ -7410,7 +7389,6 @@ Range.prototype._shiftUpDown=function(bUp){
var mergeManager = this.worksheet.mergeManager;
//todo вставить предупреждение, что будет unmerge
History.Create_NewPoint();
History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2));
History.StartTransaction();
if(false == this.worksheet.workbook.bUndoChanges && false == this.worksheet.workbook.bRedoChanges)
{
......@@ -7508,7 +7486,6 @@ Range.prototype.cleanCache=function(){
Range.prototype.cleanFormat=function(){
History.Create_NewPoint();
var oBBox = this.bbox;
History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2));
History.StartTransaction();
this.unmerge();
var oThis = this;
......@@ -7530,7 +7507,6 @@ Range.prototype.cleanFormat=function(){
Range.prototype.cleanText=function(){
History.Create_NewPoint();
var oBBox = this.bbox;
History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2));
History.StartTransaction();
var oThis = this;
this._setPropertyNoEmpty(null, null,
......@@ -7544,7 +7520,6 @@ Range.prototype.cleanText=function(){
Range.prototype.cleanAll=function(){
History.Create_NewPoint();
var oBBox = this.bbox;
History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2));
History.StartTransaction();
this.unmerge();
//удаляем только гиперссылки, которые полностью лежат в области
......@@ -7725,7 +7700,14 @@ Range.prototype.sort=function(nOption, nStartCol){
}
}
History.Create_NewPoint();
History.SetSelection(new Asc.Range(nColFirst0, nRowFirst0, nLastCol0, nLastRow0));
var oSelection = History.GetSelection();
if(null != oSelection)
{
oSelection = oSelection.clone();
oSelection.assign(nColFirst0, nRowFirst0, nLastCol0, nLastRow0);
History.SetSelection(oSelection);
History.SetSelectionRedo(oSelection);
}
var oUndoRedoBBox = new UndoRedoData_BBox({r1:nRowFirst0, c1:nColFirst0, r2:nLastRow0, c2:nLastCol0});
oRes = new UndoRedoData_SortData(oUndoRedoBBox, aSortData);
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_Sort, this.worksheet.getId(), new Asc.Range(0, nRowFirst0, gc_nMaxCol0, nLastRow0), oRes);
......@@ -7873,25 +7855,55 @@ Range.prototype.promote=function(bCtrl, bVertical, nIndex){
if(bVertical)
{
if(nHeight < nIndex)
oPromoteRange = this.worksheet.getRange3(oBBox.r2 + 1, oBBox.c1, oBBox.r2 + nIndex - nHeight, oBBox.c2);
oPromoteRange = this.worksheet.getRange3(oBBox.r2 + 1, oBBox.c1, oBBox.r1 + nIndex, oBBox.c2);
else if(nIndex < 0)
oPromoteRange = this.worksheet.getRange3(oBBox.r1 - 1, oBBox.c1, oBBox.r1 + nIndex, oBBox.c2);
oPromoteRange = this.worksheet.getRange3(oBBox.r1 + nIndex, oBBox.c1, oBBox.r1 - 1, oBBox.c2);
}
else
{
if(nWidth < nIndex)
oPromoteRange = this.worksheet.getRange3(oBBox.r1, oBBox.c2 + 1, oBBox.r2, oBBox.c2 + nIndex - nWidth);
oPromoteRange = this.worksheet.getRange3(oBBox.r1, oBBox.c2 + 1, oBBox.r2, oBBox.c1 + nIndex);
else if(nIndex < 0)
oPromoteRange = this.worksheet.getRange3(oBBox.r1, oBBox.c1 - 1, oBBox.r2, oBBox.c1 + nIndex);
oPromoteRange = this.worksheet.getRange3(oBBox.r1, oBBox.c1 + nIndex, oBBox.r2, oBBox.c1 - 1);
}
if(null != oPromoteRange && oPromoteRange.hasMerged())
return;
lockDraw(this.worksheet.workbook);
History.Create_NewPoint();
var recalcArr = [];
History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2));
History.StartTransaction();
History.Create_NewPoint();
var oSelection = History.GetSelection();
if(null != oSelection)
{
oSelection = oSelection.clone();
oSelection.assign(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2);
History.SetSelection(oSelection);
}
var oSelectionRedo = History.GetSelectionRedo();
if(null != oSelectionRedo)
{
oSelectionRedo = oSelectionRedo.clone();
if(0 == nIndex)
oSelectionRedo.assign(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2);
else
{
if(bVertical)
{
if(nIndex > 0)
oSelectionRedo.assign(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r1 + nIndex);
else if(nIndex < 0)
oSelectionRedo.assign(oBBox.c1, oBBox.r1 + nIndex, oBBox.c2, oBBox.r2);
}
else
{
if(nIndex > 0)
oSelectionRedo.assign(oBBox.c1, oBBox.r1, oBBox.c1 + nIndex, oBBox.r2);
else if(nIndex < 0)
oSelectionRedo.assign(oBBox.c1 + nIndex, oBBox.r1, oBBox.c2, oBBox.r2);
}
}
History.SetSelectionRedo(oSelectionRedo);
}
History.StartTransaction();
if((true == bVertical && 1 == nHeight) || (false == bVertical && 1 == nWidth))
bCtrl = !bCtrl;
var fFinishSection = function(param, oPromoteHelper)
......
......@@ -245,7 +245,6 @@
applyAutoFilter: function (type, autoFiltersObject, ar) {
History.Create_NewPoint();
History.SetSelection(new Asc.Range(ar.c1, ar.r1, ar.c2, ar.r2));
History.StartTransaction();
switch (type) {
case 'mainFilter':
......@@ -302,9 +301,16 @@
if(isTurnOffHistory)
History.TurnOff();
History.Create_NewPoint();
if(selectionTable)
History.SetSelectionRedo(new Asc.Range(selectionTable.c1, selectionTable.r1, selectionTable.c2, selectionTable.r2));
History.SetSelection(new Asc.Range(ar.c1, ar.r1, ar.c2, ar.r2));
if(selectionTable)
{
var oSelection = History.GetSelection();
if(null != oSelection)
{
oSelection = oSelection.clone();
oSelection.assign(selectionTable.c1, selectionTable.r1, selectionTable.c2, selectionTable.r2);
History.SetSelectionRedo(oSelection);
}
}
History.StartTransaction();
if(paramsForCallBack)
{
......@@ -1523,7 +1529,6 @@
t._addHistoryObj(oldFilter, historyitem_AutoFilter_Sort,
{activeCells: activeCells, type: type, cellId: cellId});
History.EndTransaction();
History.SetSelection(selectionRange);
// ToDo может хватит просто почистить selectionRange или нужно делать полный "update" ?
ws._cleanCache(selectionRange);
ws.isChanged = true;
......@@ -1546,7 +1551,6 @@
if(currentFilter.TableStyleInfo)
t._setColorStyleTable(currentFilter.Ref.split(":")[0], currentFilter.Ref.split(":")[1], currentFilter);
History.EndTransaction();
History.SetSelection(selectionRange);
ws._cleanCache(selectionRange);
ws.isChanged = true;
ws.changeWorksheet("update");
......
......@@ -389,8 +389,13 @@
return this;
};
ActiveRange.prototype._updateAdditionalData = function(){
this.startCol = this.c1;
this.startRow = this.r1;
//меняем выделеную ячейку, если она не входит в диапазон
//возможно, в будующем придется пределать логику, пока нет примеров, когда это работает плохо
if(!this.contains(this.startCol, this.startRow))
{
this.startCol = this.c1;
this.startRow = this.r1;
}
//не меняем тип выделения, если это не выделение ячееек
// if(this.type == c_oAscSelectionType.RangeCells || this.type == c_oAscSelectionType.RangeCol ||
// this.type == c_oAscSelectionType.RangeRow || this.type == c_oAscSelectionType.RangeMax)
......
......@@ -258,6 +258,9 @@
this.model.handlers.add("setSelection", function () {
self._onSetSelection.apply(self, arguments);
});
this.model.handlers.add("getSelection", function () {
return self._onGetSelection.apply(self);
});
this.model.handlers.add("getSelectionState", function () {
return self._onGetSelectionState.apply(self);
});
......@@ -477,13 +480,19 @@
_onSetSelection: function (range, validRange) {
var ws = this.getWorksheet();
ws._checkSelectionShape();
var d = ws.setSelection(range, validRange);
ws.setActiveRangeObj(range);
var d = ws.setSelectionUndoRedo(range, validRange);
if (d) {
if (d.deltaX) {this.controller.scrollHorizontal(d.deltaX);}
if (d.deltaY) {this.controller.scrollVertical(d.deltaY);}
}
},
_onGetSelection: function () {
var ws = this.getWorksheet();
return ws.getActiveRangeObj();
},
_onGetSelectionState: function () {
var ws = this.getWorksheet();
return ws.objectRender.controller.getSelectionState();
......
......@@ -809,7 +809,8 @@
return;
History.Create_NewPoint();
History.SetSelection(arHistorySelect);
History.SetSelection(arHistorySelect.clone());
History.SetSelectionRedo(arCopy.clone());
History.StartTransaction();
if ($.isFunction(functionAction)) {functionAction();}
......@@ -3577,7 +3578,6 @@
self.cols[col].charCount = colw.charCount;
History.Create_NewPoint();
History.SetSelection(null, true);
History.StartTransaction();
// Выставляем, что это bestFit
self.model.setColBestFit (true, modelw, col, col);
......@@ -5799,7 +5799,12 @@
this._trigger("selectionNameChanged", this.getSelectionName());
this._trigger("selectionChanged", this.getSelectionInfo());
},
getActiveRangeObj: function(){
return this.activeRange.clone(true);
},
setActiveRangeObj: function(val){
this.activeRange = val.clone();
},
setSelection: function (range, validRange) {
// Проверка на валидность range.
if (validRange && (range.c2 >= this.nColsCount || range.r2 >= this.nRowsCount)) {
......@@ -5837,6 +5842,31 @@
return this._calcActiveCellOffset();
},
setSelectionUndoRedo: function (range, validRange) {
// Проверка на валидность range.
if (validRange && (range.c2 >= this.nColsCount || range.r2 >= this.nRowsCount)) {
if (range.c2 >= this.nColsCount)
this.expandColsOnScroll(false, true, range.c2 + 1);
if (range.r2 >= this.nRowsCount)
this.expandRowsOnScroll(false, true, range.r2 + 1);
}
var oRes = null;
var type = this.activeRange.type;
if(type == c_oAscSelectionType.RangeCells || type == c_oAscSelectionType.RangeCol ||
type == c_oAscSelectionType.RangeRow || type == c_oAscSelectionType.RangeMax)
{
this.cleanSelection();
this._drawSelection();
this._trigger("selectionNameChanged", this.getSelectionName(/*bRangeText*/false));
this._trigger("selectionChanged", this.getSelectionInfo());
oRes = this._calcActiveCellOffset();
}
return oRes;
},
changeSelectionStartPoint: function (x, y, isCoord, isSelectMode) {
var ar = (this.isFormulaEditMode) ? this.arrActiveFormulaRanges[this.arrActiveFormulaRanges.length - 1]: this.activeRange;
......@@ -7093,7 +7123,14 @@
}
History.EndTransaction();
History.SetSelection(selectionRange);
var oSelection = History.GetSelection();
if(null != oSelection)
{
oSelection = oSelection.clone();
oSelection.assign(selectionRange.c1, selectionRange.r1, selectionRange.c2, selectionRange.r2);
History.SetSelection(oSelection);
History.SetSelectionRedo(oSelection);
}
};
var pasteNoLocal = function () {
......@@ -7235,7 +7272,6 @@
}
History.EndTransaction();
History.SetSelection(selectionRange);
};
if ("paste" === prop) {
// Для past свой диапазон
......@@ -8566,7 +8602,6 @@
functionModelAction = function () {
History.Create_NewPoint();
History.SetSelection(new asc_Range(_updateRangeDel.c1, 0, _updateRangeDel.c2, gc_nMaxRow0));
History.StartTransaction();
//t.autoFilters.isEmptyAutoFilters(arn);
if (range.deleteCellsShiftLeft()) {
......@@ -8592,7 +8627,6 @@
functionModelAction = function () {
History.Create_NewPoint();
History.SetSelection(new asc_Range(_updateRangeDel.c1, _updateRangeDel.r1, _updateRangeDel.c2, _updateRangeDel.r2));
History.StartTransaction();
//t.autoFilters.isEmptyAutoFilters(arn);
if (range.deleteCellsShiftUp()) {
......@@ -8618,7 +8652,6 @@
functionModelAction = function () {
fullRecalc = true;
History.Create_NewPoint();
History.SetSelection(new asc_Range(_updateRangeDel.c1, 0, _updateRangeDel.c2, gc_nMaxRow0));
History.StartTransaction();
t.model.removeCols(_updateRangeDel.c1, _updateRangeDel.c2);
t.autoFilters.insertColumn(prop,_updateRangeDel, arn, c_oAscDeleteOptions.DeleteColumns);
......@@ -8641,7 +8674,6 @@
functionModelAction = function () {
fullRecalc = true;
History.Create_NewPoint();
History.SetSelection(new asc_Range(0, _updateRangeDel.r1, gc_nMaxCol0, _updateRangeDel.r2));
History.StartTransaction();
t.model.removeRows(_updateRangeDel.r1, _updateRangeDel.r2);
t.autoFilters.insertRows(prop,_updateRangeDel, arn, c_oAscDeleteOptions.DeleteRows);
......@@ -8847,7 +8879,15 @@
}
History.Create_NewPoint();
History.SetSelection(null, true);
var oSelection = History.GetSelection();
if(null != oSelection)
{
oSelection = oSelection.clone();
oSelection.assign(col, 0, col, gc_nMaxRow0);
oSelection.type = c_oAscSelectionType.RangeCol;
History.SetSelection(oSelection);
History.SetSelectionRedo(oSelection);
}
History.StartTransaction();
// Выставляем, что это bestFit
t.model.setColBestFit(true, cw, col, col);
......@@ -8886,7 +8926,15 @@
}
History.Create_NewPoint();
History.SetSelection(null, true);
var oSelection = History.GetSelection();
if(null != oSelection)
{
oSelection = oSelection.clone();
oSelection.assign(0, row, gc_nMaxCol0, row);
oSelection.type = c_oAscSelectionType.RangeRow;
History.SetSelection(oSelection);
History.SetSelectionRedo(oSelection);
}
History.StartTransaction();
// Выставляем, что это bestFit
t.model.setRowBestFit (true, Math.min(height + t.height_1px, t.maxRowHeight), row, row);
......@@ -9114,7 +9162,6 @@
_replaceCellsText: function (aReplaceCells, valueForSearching, options) {
var oSelectionHistory = this.activeRange.clone();
History.Create_NewPoint();
History.SetSelection(oSelectionHistory);
History.StartTransaction();
options.indexInArray = 0;
......@@ -9282,7 +9329,6 @@
if (!isNotHistory) {
History.Create_NewPoint();
History.SetSelection(oCellEdit);
History.StartTransaction();
}
......
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