Commit 3df50592 authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander.Trofimov

Создан класс ActiveRange для хранения selection в sheet

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@52212 954022d7-b5bf-4e40-9824-e11837661b57
parent 9172c8d2
...@@ -296,6 +296,111 @@ ...@@ -296,6 +296,111 @@
} }
}; };
function ActiveRange(){
if(1 == arguments.length)
{
var range = arguments[0];
ActiveRange.superclass.constructor.call(this, range.c1, range.r1, range.c2, range.r2);
}
else if(arguments.length > 1)
ActiveRange.superclass.constructor.apply(this, arguments);
else
ActiveRange.superclass.constructor.call(this, 0, 0, 0, 0);
this.type = c_oAscSelectionType.RangeCells;
this.startCol = 0; // Активная ячейка в выделении
this.startRow = 0; // Активная ячейка в выделении
this._updateAdditionalData();
}
extendClass(ActiveRange, Range);
ActiveRange.prototype.assign = function () {
ActiveRange.superclass.assign.apply(this, arguments);
this._updateAdditionalData();
return this;
};
ActiveRange.prototype.clone = function(){
var oRes = new ActiveRange(ActiveRange.superclass.clone.apply(this, arguments));
oRes.type = this.type;
oRes.startCol = this.startCol;
oRes.startRow = this.startRow;
return oRes;
};
ActiveRange.prototype.normalize = function () {
ActiveRange.superclass.normalize.apply(this, arguments);
this._updateAdditionalData();
return this;
};
ActiveRange.prototype.isEqual = function () {
var bRes = ActiveRange.superclass.isEqual.apply(this, arguments);
if(bRes && arguments.length > 0)
{
var range = arguments[0];
bRes = this.type == range.type && this.startCol == range.startCol && this.startRow == range.startRow;
}
return bRes;
};
ActiveRange.prototype.contains = function () {
return ActiveRange.superclass.contains.apply(this, arguments);
};
ActiveRange.prototype.containsRange = function () {
return ActiveRange.superclass.containsRange.apply(this, arguments);
};
ActiveRange.prototype.intersection = function () {
var oRes = new ActiveRange(ActiveRange.superclass.intersection.apply(this, arguments));
oRes._updateAdditionalData();
return oRes;
};
ActiveRange.prototype.intersectionSimple = function () {
var oRes = ActiveRange.superclass.intersectionSimple.apply(this, arguments);
if(null != oRes)
{
var oRes = new ActiveRange(oRes);
oRes._updateAdditionalData();
}
return oRes;
};
ActiveRange.prototype.union = function () {
var oRes = new ActiveRange(ActiveRange.superclass.union.apply(this, arguments));
oRes._updateAdditionalData();
return oRes;
};
ActiveRange.prototype.union2 = function () {
ActiveRange.superclass.union2.apply(this, arguments);
this._updateAdditionalData();
return this;
};
ActiveRange.prototype.setOffset = function(offset){
this.setOffsetFirst(offset);
this.setOffsetLast(offset);
};
ActiveRange.prototype.setOffsetFirst = function(offset){
ActiveRange.superclass.setOffsetFirst.apply(this, arguments);
this._updateAdditionalData();
return this;
};
ActiveRange.prototype.setOffsetLast = function(offset){
ActiveRange.superclass.setOffsetLast.apply(this, arguments);
this._updateAdditionalData();
return this;
};
ActiveRange.prototype._updateAdditionalData = function(){
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)
// {
// if(0 == this.r1 && 0 == this.c1 && gc_nMaxRow0 == this.r2 && gc_nMaxCol0 == this.c2)
// this.type = c_oAscSelectionType.RangeMax;
// else if(0 == this.r1 && gc_nMaxRow0 == this.r2)
// this.type = c_oAscSelectionType.RangeCol;
// else if(0 == this.c1 && gc_nMaxCol0 == this.c2)
// this.type = c_oAscSelectionType.RangeRow;
// else
// this.type = c_oAscSelectionType.RangeCells;
// }
};
/** /**
...@@ -443,6 +548,15 @@ ...@@ -443,6 +548,15 @@
return val.replace(/^\s+|\s+$/g,''); return val.replace(/^\s+|\s+$/g,'');
} }
function extendClass(Child, Parent){
var F = function() { };
F.prototype = Parent.prototype;
Child.prototype = new F();
Child.prototype.constructor = Child;
Child.superclass = Parent.prototype;
}
function isNumber(val) { function isNumber(val) {
var valTrim = trim(val); var valTrim = trim(val);
return (valTrim - 0) == valTrim && valTrim.length > 0; return (valTrim - 0) == valTrim && valTrim.length > 0;
...@@ -921,8 +1035,10 @@ ...@@ -921,8 +1035,10 @@
window["Asc"].profileTime = profileTime; window["Asc"].profileTime = profileTime;
window["Asc"].isNumber = isNumber; window["Asc"].isNumber = isNumber;
window["Asc"].trim = trim; window["Asc"].trim = trim;
window["Asc"].extendClass = extendClass;
window["Asc"].Range = Range; window["Asc"].Range = Range;
window["Asc"].ActiveRange = ActiveRange;
window["Asc"].HandlersList = HandlersList; window["Asc"].HandlersList = HandlersList;
......
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
this.Api = Api; this.Api = Api;
this.collaborativeEditing = collaborativeEditing; this.collaborativeEditing = collaborativeEditing;
this.lastSendInfoRange = null; this.lastSendInfoRange = null;
this.lastSendInfoIsSelectOnShape = null;
this.canUpdateAfterShiftUp = false; // Нужно ли обновлять информацию после отпускания Shift this.canUpdateAfterShiftUp = false; // Нужно ли обновлять информацию после отпускания Shift
//----- declaration ----- //----- declaration -----
...@@ -425,19 +426,14 @@ ...@@ -425,19 +426,14 @@
if (null === this.lastSendInfoRange) if (null === this.lastSendInfoRange)
return false; return false;
return (this.lastSendInfoRange.isEqual(range) && return this.lastSendInfoRange.isEqual(range) && this.lastSendInfoRangeIsSelectOnShape === isSelectOnShape;
this.lastSendInfoRange.startCol === range.startCol &&
this.lastSendInfoRange.startRow === range.startRow &&
this.lastSendInfoRange.isSelectOnShape === isSelectOnShape);
}, },
_onWSSelectionChanged: function (info) { _onWSSelectionChanged: function (info) {
var ws = this.getWorksheet(); var ws = this.getWorksheet();
var ar = ws.activeRange; var ar = ws.activeRange;
this.lastSendInfoRange = ar.clone(true); this.lastSendInfoRange = ar.clone(true);
this.lastSendInfoRange.startCol = ar.startCol; this.lastSendInfoRangeIsSelectOnShape = ws.getSelectionShape();
this.lastSendInfoRange.startRow = ar.startRow;
this.lastSendInfoRange.isSelectOnShape = ws.getSelectionShape();
if (null === info) { if (null === info) {
info = ws.getSelectionInfo(); info = ws.getSelectionInfo();
...@@ -445,7 +441,7 @@ ...@@ -445,7 +441,7 @@
// При редактировании ячейки не нужно пересылать изменения // При редактировании ячейки не нужно пересылать изменения
if (false === ws.getCellEditMode()) { if (false === ws.getCellEditMode()) {
// Сами запретим заходить в строку формул, когда выделен shape // Сами запретим заходить в строку формул, когда выделен shape
if (this.lastSendInfoRange.isSelectOnShape) if (this.lastSendInfoRangeIsSelectOnShape)
this.input.prop("disabled", true); this.input.prop("disabled", true);
else else
this.input.prop("disabled", false); this.input.prop("disabled", false);
...@@ -821,9 +817,6 @@ ...@@ -821,9 +817,6 @@
var ws = t.getWorksheet(); var ws = t.getWorksheet();
var activeCellRange = ws.getActiveCell(x, y, isCoord); var activeCellRange = ws.getActiveCell(x, y, isCoord);
var arn = ws.activeRange.clone(true); var arn = ws.activeRange.clone(true);
arn.startCol = ws.activeRange.startCol;
arn.startRow = ws.activeRange.startRow;
arn.type = ws.activeRange.type;
var editFunction = function() { var editFunction = function() {
t.controller.setCellEditMode(true); t.controller.setCellEditMode(true);
...@@ -1259,9 +1252,6 @@ ...@@ -1259,9 +1252,6 @@
return false; return false;
var arn = ws.activeRange.clone(true); var arn = ws.activeRange.clone(true);
arn.startCol = ws.activeRange.startCol;
arn.startRow = ws.activeRange.startRow;
arn.type = ws.activeRange.type;
function openEditor(res) { function openEditor(res) {
if (res) { if (res) {
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
var asc_incDecFonSize = asc.incDecFonSize; var asc_incDecFonSize = asc.incDecFonSize;
var asc_debug = asc.outputDebugStr; var asc_debug = asc.outputDebugStr;
var asc_Range = asc.Range; var asc_Range = asc.Range;
var asc_ActiveRange = asc.ActiveRange;
var asc_FP = asc.FontProperties; var asc_FP = asc.FontProperties;
var asc_parsecolor = asc.parseColor; var asc_parsecolor = asc.parseColor;
var asc_clone = asc.clone; var asc_clone = asc.clone;
...@@ -342,10 +343,7 @@ ...@@ -342,10 +343,7 @@
this.highlightedCol = -1; this.highlightedCol = -1;
this.highlightedRow = -1; this.highlightedRow = -1;
this.visibleRange = asc_Range(0, 0, 0, 0); this.visibleRange = asc_Range(0, 0, 0, 0);
this.activeRange = asc_Range(0, 0, 0, 0); this.activeRange = new asc_ActiveRange(0, 0, 0, 0);
this.activeRange.type = c_oAscSelectionType.RangeCells;
this.activeRange.startCol = 0; // Активная ячейка в выделении
this.activeRange.startRow = 0; // Активная ячейка в выделении
this.isChanged = false; this.isChanged = false;
this.isCellEditMode = false; this.isCellEditMode = false;
this.isFormulaEditMode = false; this.isFormulaEditMode = false;
...@@ -5825,7 +5823,7 @@ ...@@ -5825,7 +5823,7 @@
range.r2 = this.rows.length - 1; range.r2 = this.rows.length - 1;
} }
this.activeRange = range; this.activeRange = new asc_ActiveRange(range);
this.activeRange.type = c_oAscSelectionType.RangeCells; this.activeRange.type = c_oAscSelectionType.RangeCells;
this.activeRange.startCol = range.c1; this.activeRange.startCol = range.c1;
this.activeRange.startRow = range.r1; this.activeRange.startRow = range.r1;
...@@ -6454,8 +6452,6 @@ ...@@ -6454,8 +6452,6 @@
if (2 === this.fillHandleArea) { if (2 === this.fillHandleArea) {
// Мы внутри, будет удаление, нормируем и cбрасываем первую ячейку // Мы внутри, будет удаление, нормируем и cбрасываем первую ячейку
this.activeRange.normalize(); this.activeRange.normalize();
this.activeRange.startCol = this.activeRange.c1;
this.activeRange.startRow = this.activeRange.r1;
// Проверяем, удалили ли мы все (если да, то область не меняется) // Проверяем, удалили ли мы все (если да, то область не меняется)
if (arn.c1 !== this.activeFillHandle.c2 || if (arn.c1 !== this.activeFillHandle.c2 ||
arn.r1 !== this.activeFillHandle.r2) { arn.r1 !== this.activeFillHandle.r2) {
...@@ -6810,8 +6806,6 @@ ...@@ -6810,8 +6806,6 @@
t._updateCellsRange(arnTo); t._updateCellsRange(arnTo);
t.cleanSelection(); t.cleanSelection();
t.activeRange = arnTo.clone(true); t.activeRange = arnTo.clone(true);
t.activeRange.startRow = t.activeRange.r1;
t.activeRange.startCol = t.activeRange.c1;
t.cellCommentator.moveRangeComments(arnFrom, arnTo); t.cellCommentator.moveRangeComments(arnFrom, arnTo);
t.objectRender.moveRangeDrawingObject(arnFrom, arnTo, false); t.objectRender.moveRangeDrawingObject(arnFrom, arnTo, false);
t.autoFilters._moveAutoFilters(arnTo, arnFrom); t.autoFilters._moveAutoFilters(arnTo, arnFrom);
...@@ -6844,9 +6838,6 @@ ...@@ -6844,9 +6838,6 @@
var t = this; var t = this;
var checkRange = null; var checkRange = null;
var arn = t.activeRange.clone(true); var arn = t.activeRange.clone(true);
arn.startCol = t.activeRange.startCol;
arn.startRow = t.activeRange.startRow;
arn.type = t.activeRange.type;
if (onlyActive) { if (onlyActive) {
checkRange = new asc_Range(arn.startCol, arn.startRow, arn.startCol, arn.startRow); checkRange = new asc_Range(arn.startCol, arn.startRow, arn.startCol, arn.startRow);
} else { } else {
...@@ -9069,8 +9060,6 @@ ...@@ -9069,8 +9060,6 @@
valueForSearching = new RegExp(valueForSearching, findFlags); valueForSearching = new RegExp(valueForSearching, findFlags);
var t = this; var t = this;
var ar = this.activeRange.clone(); var ar = this.activeRange.clone();
ar.startCol = this.activeRange.startCol;
ar.startRow = this.activeRange.startRow;
var aReplaceCells = []; var aReplaceCells = [];
if (options.isReplaceAll) { if (options.isReplaceAll) {
// На ReplaceAll ставим медленную операцию // На ReplaceAll ставим медленную операцию
...@@ -9235,23 +9224,19 @@ ...@@ -9235,23 +9224,19 @@
if (false === this.isSelectionDialogMode) { if (false === this.isSelectionDialogMode) {
if (null !== this.copyOfActiveRange) { if (null !== this.copyOfActiveRange) {
this.activeRange = this.copyOfActiveRange.clone(true); this.activeRange = this.copyOfActiveRange.clone(true);
this.activeRange.startCol = this.copyOfActiveRange.startCol;
this.activeRange.startRow = this.copyOfActiveRange.startRow;
} }
this.copyOfActiveRange = null; this.copyOfActiveRange = null;
} else { } else {
this.copyOfActiveRange = this.activeRange.clone(true); this.copyOfActiveRange = this.activeRange.clone(true);
this.copyOfActiveRange.startCol = this.activeRange.startCol;
this.copyOfActiveRange.startRow = this.activeRange.startRow;
if (selectRange) { if (selectRange) {
selectRange = parserHelp.parse3DRef(selectRange); selectRange = parserHelp.parse3DRef(selectRange);
if (selectRange) { if (selectRange) {
// ToDo стоит менять и лист // ToDo стоит менять и лист
selectRange = this.model.getRange2(selectRange.range); selectRange = this.model.getRange2(selectRange.range);
if (null !== selectRange) { if (null !== selectRange)
this.activeRange = selectRange.getBBox0(); {
this.activeRange.startCol = this.activeRange.c1; var bbox = selectRange.getBBox0();
this.activeRange.startRow = this.activeRange.r1; this.activeRange.assign(bbox.c1, bbox.r1, bbox.c2, bbox.r2);
} }
} }
} }
...@@ -9350,15 +9335,8 @@ ...@@ -9350,15 +9335,8 @@
isHideCursor, activeRange) { isHideCursor, activeRange) {
var t = this, vr = t.visibleRange, tc = t.cols, tr = t.rows, col, row, c, fl, mc, bg; var t = this, vr = t.visibleRange, tc = t.cols, tr = t.rows, col, row, c, fl, mc, bg;
var ar = t.activeRange; var ar = t.activeRange;
if (activeRange) { if (activeRange)
t.activeRange.c1 = activeRange.c1; t.activeRange = activeRange.clone();
t.activeRange.c2 = activeRange.c2;
t.activeRange.r1 = activeRange.r1;
t.activeRange.r2 = activeRange.r2;
t.activeRange.startCol = activeRange.startCol;
t.activeRange.startRow = activeRange.startRow;
t.activeRange.type = activeRange.type;
}
if ( t.objectRender.checkCursorDrawingObject(x, y) ) if ( t.objectRender.checkCursorDrawingObject(x, y) )
return false; return false;
......
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