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 = ...@@ -409,17 +409,10 @@ CHistory.prototype =
isRedrawAll = false; isRedrawAll = false;
} }
gUndoInsDelCellsFlag = true; gUndoInsDelCellsFlag = true;
var oSelectRange = null;
if(null != Point.SelectRange)
oSelectRange = Point.SelectRange;
for(var i in Point.UpdateRigions) for(var i in Point.UpdateRigions)
{
this.workbook.handlers.trigger("cleanCellCache", i, Point.UpdateRigions[i]); this.workbook.handlers.trigger("cleanCellCache", i, Point.UpdateRigions[i]);
if(null != Point.nLastSheetId && i - 0 == Point.nLastSheetId && null == oSelectRange) if(null != Point.SelectRange)
oSelectRange = Point.UpdateRigions[i]; this.workbook.handlers.trigger("setSelection", Point.SelectRange.clone(), /*validRange*/false);
}
if(false == Point.bNoSelect && null != oSelectRange)
this.workbook.handlers.trigger("setSelection", oSelectRange.clone(), /*validRange*/false);
if ( Point.SelectionState != null ) if ( Point.SelectionState != null )
this.workbook.handlers.trigger("setSelectionState", Point.SelectionState); this.workbook.handlers.trigger("setSelectionState", Point.SelectionState);
...@@ -511,12 +504,8 @@ CHistory.prototype = ...@@ -511,12 +504,8 @@ CHistory.prototype =
else if(null != Point.SelectRange) else if(null != Point.SelectRange)
oSelectRange = Point.SelectRange; oSelectRange = Point.SelectRange;
for(var i in Point.UpdateRigions) for(var i in Point.UpdateRigions)
{
this.workbook.handlers.trigger("cleanCellCache", i, Point.UpdateRigions[i]); this.workbook.handlers.trigger("cleanCellCache", i, Point.UpdateRigions[i]);
if(null != Point.nLastSheetId && i - 0 == Point.nLastSheetId && null == oSelectRange) if(null != oSelectRange)
oSelectRange = Point.UpdateRigions[i];
}
if(false == Point.bNoSelect && null != oSelectRange)
this.workbook.handlers.trigger("setSelection", oSelectRange.clone()); this.workbook.handlers.trigger("setSelection", oSelectRange.clone());
//if (Point.SelectionState != null) //if (Point.SelectionState != null)
// this.workbook.handlers.trigger("setSelectionState", Point.SelectionState); // this.workbook.handlers.trigger("setSelectionState", Point.SelectionState);
...@@ -561,13 +550,13 @@ CHistory.prototype = ...@@ -561,13 +550,13 @@ CHistory.prototype =
var Items = new Array(); var Items = new Array();
var UpdateRigions = new Object(); var UpdateRigions = new Object();
var Time = new Date().getTime(); var Time = new Date().getTime();
var oSelectRange = this.workbook.handlers.trigger("getSelection");
this.CurPoint = { this.CurPoint = {
Items : Items, // Массив изменений, начиная с текущего момента Items : Items, // Массив изменений, начиная с текущего момента
UpdateRigions : UpdateRigions, UpdateRigions : UpdateRigions,
nLastSheetId : null, nLastSheetId : null,
SelectRange : null, SelectRange : oSelectRange,
SelectRangeRedo : null, SelectRangeRedo : oSelectRange,
bNoSelect : false,
Time : Time, // Текущее время Time : Time, // Текущее время
SelectionState : this.workbook.handlers.trigger("getSelectionState") SelectionState : this.workbook.handlers.trigger("getSelectionState")
}; };
...@@ -634,29 +623,38 @@ CHistory.prototype = ...@@ -634,29 +623,38 @@ CHistory.prototype =
this.CurPoint = null; this.CurPoint = null;
} }
}, },
SetSelection : function(range, bNoSelect) SetSelection : function(range)
{ {
if ( 0 !== this.TurnOffHistory || 0 !== this.Transaction ) if ( 0 !== this.TurnOffHistory )
return; return;
if ( null == this.CurPoint ) if ( null == this.CurPoint )
return; return;
this.CurPoint.SelectRange = range; 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; return;
if ( null == this.CurPoint ) if ( null == this.CurPoint )
return; return;
this.CurPoint.SelectRangeRedo = range; 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() TurnOff : function()
{ {
this.TurnOffHistory++; this.TurnOffHistory++;
......
This diff is collapsed.
...@@ -245,7 +245,6 @@ ...@@ -245,7 +245,6 @@
applyAutoFilter: function (type, autoFiltersObject, ar) { applyAutoFilter: function (type, autoFiltersObject, ar) {
History.Create_NewPoint(); History.Create_NewPoint();
History.SetSelection(new Asc.Range(ar.c1, ar.r1, ar.c2, ar.r2));
History.StartTransaction(); History.StartTransaction();
switch (type) { switch (type) {
case 'mainFilter': case 'mainFilter':
...@@ -302,9 +301,16 @@ ...@@ -302,9 +301,16 @@
if(isTurnOffHistory) if(isTurnOffHistory)
History.TurnOff(); History.TurnOff();
History.Create_NewPoint(); History.Create_NewPoint();
if(selectionTable) 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)); 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(); History.StartTransaction();
if(paramsForCallBack) if(paramsForCallBack)
{ {
...@@ -1523,7 +1529,6 @@ ...@@ -1523,7 +1529,6 @@
t._addHistoryObj(oldFilter, historyitem_AutoFilter_Sort, t._addHistoryObj(oldFilter, historyitem_AutoFilter_Sort,
{activeCells: activeCells, type: type, cellId: cellId}); {activeCells: activeCells, type: type, cellId: cellId});
History.EndTransaction(); History.EndTransaction();
History.SetSelection(selectionRange);
// ToDo может хватит просто почистить selectionRange или нужно делать полный "update" ? // ToDo может хватит просто почистить selectionRange или нужно делать полный "update" ?
ws._cleanCache(selectionRange); ws._cleanCache(selectionRange);
ws.isChanged = true; ws.isChanged = true;
...@@ -1546,7 +1551,6 @@ ...@@ -1546,7 +1551,6 @@
if(currentFilter.TableStyleInfo) if(currentFilter.TableStyleInfo)
t._setColorStyleTable(currentFilter.Ref.split(":")[0], currentFilter.Ref.split(":")[1], currentFilter); t._setColorStyleTable(currentFilter.Ref.split(":")[0], currentFilter.Ref.split(":")[1], currentFilter);
History.EndTransaction(); History.EndTransaction();
History.SetSelection(selectionRange);
ws._cleanCache(selectionRange); ws._cleanCache(selectionRange);
ws.isChanged = true; ws.isChanged = true;
ws.changeWorksheet("update"); ws.changeWorksheet("update");
......
...@@ -389,8 +389,13 @@ ...@@ -389,8 +389,13 @@
return this; return this;
}; };
ActiveRange.prototype._updateAdditionalData = function(){ 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 || // if(this.type == c_oAscSelectionType.RangeCells || this.type == c_oAscSelectionType.RangeCol ||
// this.type == c_oAscSelectionType.RangeRow || this.type == c_oAscSelectionType.RangeMax) // this.type == c_oAscSelectionType.RangeRow || this.type == c_oAscSelectionType.RangeMax)
......
...@@ -258,6 +258,9 @@ ...@@ -258,6 +258,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("getSelection", function () {
return self._onGetSelection.apply(self);
});
this.model.handlers.add("getSelectionState", function () { this.model.handlers.add("getSelectionState", function () {
return self._onGetSelectionState.apply(self); return self._onGetSelectionState.apply(self);
}); });
...@@ -477,13 +480,19 @@ ...@@ -477,13 +480,19 @@
_onSetSelection: function (range, validRange) { _onSetSelection: function (range, validRange) {
var ws = this.getWorksheet(); var ws = this.getWorksheet();
ws._checkSelectionShape(); ws._checkSelectionShape();
var d = ws.setSelection(range, validRange); ws.setActiveRangeObj(range);
var d = ws.setSelectionUndoRedo(range, validRange);
if (d) { if (d) {
if (d.deltaX) {this.controller.scrollHorizontal(d.deltaX);} if (d.deltaX) {this.controller.scrollHorizontal(d.deltaX);}
if (d.deltaY) {this.controller.scrollVertical(d.deltaY);} if (d.deltaY) {this.controller.scrollVertical(d.deltaY);}
} }
}, },
_onGetSelection: function () {
var ws = this.getWorksheet();
return ws.getActiveRangeObj();
},
_onGetSelectionState: function () { _onGetSelectionState: function () {
var ws = this.getWorksheet(); var ws = this.getWorksheet();
return ws.objectRender.controller.getSelectionState(); return ws.objectRender.controller.getSelectionState();
......
...@@ -809,7 +809,8 @@ ...@@ -809,7 +809,8 @@
return; return;
History.Create_NewPoint(); History.Create_NewPoint();
History.SetSelection(arHistorySelect); History.SetSelection(arHistorySelect.clone());
History.SetSelectionRedo(arCopy.clone());
History.StartTransaction(); History.StartTransaction();
if ($.isFunction(functionAction)) {functionAction();} if ($.isFunction(functionAction)) {functionAction();}
...@@ -3577,7 +3578,6 @@ ...@@ -3577,7 +3578,6 @@
self.cols[col].charCount = colw.charCount; self.cols[col].charCount = colw.charCount;
History.Create_NewPoint(); History.Create_NewPoint();
History.SetSelection(null, true);
History.StartTransaction(); History.StartTransaction();
// Выставляем, что это bestFit // Выставляем, что это bestFit
self.model.setColBestFit (true, modelw, col, col); self.model.setColBestFit (true, modelw, col, col);
...@@ -5799,7 +5799,12 @@ ...@@ -5799,7 +5799,12 @@
this._trigger("selectionNameChanged", this.getSelectionName()); this._trigger("selectionNameChanged", this.getSelectionName());
this._trigger("selectionChanged", this.getSelectionInfo()); this._trigger("selectionChanged", this.getSelectionInfo());
}, },
getActiveRangeObj: function(){
return this.activeRange.clone(true);
},
setActiveRangeObj: function(val){
this.activeRange = val.clone();
},
setSelection: function (range, validRange) { setSelection: function (range, validRange) {
// Проверка на валидность range. // Проверка на валидность range.
if (validRange && (range.c2 >= this.nColsCount || range.r2 >= this.nRowsCount)) { if (validRange && (range.c2 >= this.nColsCount || range.r2 >= this.nRowsCount)) {
...@@ -5837,6 +5842,31 @@ ...@@ -5837,6 +5842,31 @@
return this._calcActiveCellOffset(); 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) { changeSelectionStartPoint: function (x, y, isCoord, isSelectMode) {
var ar = (this.isFormulaEditMode) ? this.arrActiveFormulaRanges[this.arrActiveFormulaRanges.length - 1]: this.activeRange; var ar = (this.isFormulaEditMode) ? this.arrActiveFormulaRanges[this.arrActiveFormulaRanges.length - 1]: this.activeRange;
...@@ -7093,7 +7123,14 @@ ...@@ -7093,7 +7123,14 @@
} }
History.EndTransaction(); 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 () { var pasteNoLocal = function () {
...@@ -7235,7 +7272,6 @@ ...@@ -7235,7 +7272,6 @@
} }
History.EndTransaction(); History.EndTransaction();
History.SetSelection(selectionRange);
}; };
if ("paste" === prop) { if ("paste" === prop) {
// Для past свой диапазон // Для past свой диапазон
...@@ -8566,7 +8602,6 @@ ...@@ -8566,7 +8602,6 @@
functionModelAction = function () { functionModelAction = function () {
History.Create_NewPoint(); History.Create_NewPoint();
History.SetSelection(new asc_Range(_updateRangeDel.c1, 0, _updateRangeDel.c2, gc_nMaxRow0));
History.StartTransaction(); History.StartTransaction();
//t.autoFilters.isEmptyAutoFilters(arn); //t.autoFilters.isEmptyAutoFilters(arn);
if (range.deleteCellsShiftLeft()) { if (range.deleteCellsShiftLeft()) {
...@@ -8592,7 +8627,6 @@ ...@@ -8592,7 +8627,6 @@
functionModelAction = function () { functionModelAction = function () {
History.Create_NewPoint(); History.Create_NewPoint();
History.SetSelection(new asc_Range(_updateRangeDel.c1, _updateRangeDel.r1, _updateRangeDel.c2, _updateRangeDel.r2));
History.StartTransaction(); History.StartTransaction();
//t.autoFilters.isEmptyAutoFilters(arn); //t.autoFilters.isEmptyAutoFilters(arn);
if (range.deleteCellsShiftUp()) { if (range.deleteCellsShiftUp()) {
...@@ -8618,7 +8652,6 @@ ...@@ -8618,7 +8652,6 @@
functionModelAction = function () { functionModelAction = function () {
fullRecalc = true; fullRecalc = true;
History.Create_NewPoint(); History.Create_NewPoint();
History.SetSelection(new asc_Range(_updateRangeDel.c1, 0, _updateRangeDel.c2, gc_nMaxRow0));
History.StartTransaction(); History.StartTransaction();
t.model.removeCols(_updateRangeDel.c1, _updateRangeDel.c2); t.model.removeCols(_updateRangeDel.c1, _updateRangeDel.c2);
t.autoFilters.insertColumn(prop,_updateRangeDel, arn, c_oAscDeleteOptions.DeleteColumns); t.autoFilters.insertColumn(prop,_updateRangeDel, arn, c_oAscDeleteOptions.DeleteColumns);
...@@ -8641,7 +8674,6 @@ ...@@ -8641,7 +8674,6 @@
functionModelAction = function () { functionModelAction = function () {
fullRecalc = true; fullRecalc = true;
History.Create_NewPoint(); History.Create_NewPoint();
History.SetSelection(new asc_Range(0, _updateRangeDel.r1, gc_nMaxCol0, _updateRangeDel.r2));
History.StartTransaction(); History.StartTransaction();
t.model.removeRows(_updateRangeDel.r1, _updateRangeDel.r2); t.model.removeRows(_updateRangeDel.r1, _updateRangeDel.r2);
t.autoFilters.insertRows(prop,_updateRangeDel, arn, c_oAscDeleteOptions.DeleteRows); t.autoFilters.insertRows(prop,_updateRangeDel, arn, c_oAscDeleteOptions.DeleteRows);
...@@ -8847,7 +8879,15 @@ ...@@ -8847,7 +8879,15 @@
} }
History.Create_NewPoint(); 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(); History.StartTransaction();
// Выставляем, что это bestFit // Выставляем, что это bestFit
t.model.setColBestFit(true, cw, col, col); t.model.setColBestFit(true, cw, col, col);
...@@ -8886,7 +8926,15 @@ ...@@ -8886,7 +8926,15 @@
} }
History.Create_NewPoint(); 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(); History.StartTransaction();
// Выставляем, что это bestFit // Выставляем, что это bestFit
t.model.setRowBestFit (true, Math.min(height + t.height_1px, t.maxRowHeight), row, row); t.model.setRowBestFit (true, Math.min(height + t.height_1px, t.maxRowHeight), row, row);
...@@ -9114,7 +9162,6 @@ ...@@ -9114,7 +9162,6 @@
_replaceCellsText: function (aReplaceCells, valueForSearching, options) { _replaceCellsText: function (aReplaceCells, valueForSearching, options) {
var oSelectionHistory = this.activeRange.clone(); var oSelectionHistory = this.activeRange.clone();
History.Create_NewPoint(); History.Create_NewPoint();
History.SetSelection(oSelectionHistory);
History.StartTransaction(); History.StartTransaction();
options.indexInArray = 0; options.indexInArray = 0;
...@@ -9282,7 +9329,6 @@ ...@@ -9282,7 +9329,6 @@
if (!isNotHistory) { if (!isNotHistory) {
History.Create_NewPoint(); History.Create_NewPoint();
History.SetSelection(oCellEdit);
History.StartTransaction(); 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