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++;
......
This diff is collapsed.
......@@ -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