Commit d09cf42e authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Поправил конструктор ActiveRange (если мы вызываем от Range, то копируем свойства абсолютности)

Поправил вызовы moveResize для формул.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@56078 954022d7-b5bf-4e40-9824-e11837661b57
parent 14fbdeb0
...@@ -3476,7 +3476,7 @@ Woorksheet.prototype._BuildDependencies=function(cellRange){ ...@@ -3476,7 +3476,7 @@ Woorksheet.prototype._BuildDependencies=function(cellRange){
oNewElem = new cArea(ref, elem.ws); oNewElem = new cArea(ref, elem.ws);
} }
if ( ref.indexOf( "$" ) > -1 ) if ( ref.indexOf( "$" ) > -1 )
oNewElem.isAbsolute = true; oNewElem.isAbsolute = true; // ToDo - пересмотреть этот параметр (есть в Range информация о абсолютной ссылке)
oNewFormula.outStack[pos.index] = oNewElem; oNewFormula.outStack[pos.index] = oNewElem;
} }
else else
......
...@@ -364,6 +364,11 @@ ...@@ -364,6 +364,11 @@
{ {
var range = arguments[0]; var range = arguments[0];
ActiveRange.superclass.constructor.call(this, range.c1, range.r1, range.c2, range.r2); ActiveRange.superclass.constructor.call(this, range.c1, range.r1, range.c2, range.r2);
// ToDo стоит пересмотреть конструкторы.
this.r1Abs = range.r1Abs;
this.c1Abs = range.c1Abs;
this.r2Abs = range.r2Abs;
this.c2Abs = range.c2Abs;
} }
else if(arguments.length > 1) else if(arguments.length > 1)
ActiveRange.superclass.constructor.apply(this, arguments); ActiveRange.superclass.constructor.apply(this, arguments);
......
...@@ -419,11 +419,11 @@ ...@@ -419,11 +419,11 @@
t._addChars(rangeStr, undefined, /*isRange*/true); t._addChars(rangeStr, undefined, /*isRange*/true);
}; };
CellEditor.prototype.changeCellRange = function(range,rangeStr){ CellEditor.prototype.changeCellRange = function (range) {
var t = this; var t = this;
t._moveCursor(kPosition, range.cursorePos/* -length */); t._moveCursor(kPosition, range.cursorePos/* -length */);
t._selectChars(kPositionLength, range.formulaRangeLength); t._selectChars(kPositionLength, range.formulaRangeLength);
t._addChars(rangeStr, undefined, /*isRange*/true); t._addChars(range.getName(), undefined, /*isRange*/true);
t._moveCursor(kEndOfText); t._moveCursor(kEndOfText);
}; };
...@@ -688,9 +688,6 @@ ...@@ -688,9 +688,6 @@
range = this._parseRangeStr(m[1]); range = this._parseRangeStr(m[1]);
if (range) { if (range) {
ret = true; ret = true;
if (m[1].indexOf("$") > -1) {
range.isAbsolute = m[1];
}
range.cursorePos = m.input.indexOf(m[0])+1; range.cursorePos = m.input.indexOf(m[0])+1;
range.formulaRangeLength = m[1].length; range.formulaRangeLength = m[1].length;
this.handlers.trigger("newRange", range); this.handlers.trigger("newRange", range);
......
...@@ -243,7 +243,6 @@ ...@@ -243,7 +243,6 @@
return ret; return ret;
}, },
"enterCellRange": function () {self.cellEditor.setFocus(false); self.getWorksheet().enterCellRange(self.cellEditor);}, "enterCellRange": function () {self.cellEditor.setFocus(false); self.getWorksheet().enterCellRange(self.cellEditor);},
"changeCellRange": function () {self.getWorksheet().changeCellRange(self.cellEditor)},
"copy": function () {self.copyToClipboard.apply(self, arguments);}, "copy": function () {self.copyToClipboard.apply(self, arguments);},
"paste": function () {self.pasteFromClipboard.apply(self, arguments);}, "paste": function () {self.pasteFromClipboard.apply(self, arguments);},
"cut": function () {self.cutToClipboard.apply(self, arguments);}, "cut": function () {self.cutToClipboard.apply(self, arguments);},
...@@ -819,17 +818,13 @@ ...@@ -819,17 +818,13 @@
WorkbookView.prototype._onMoveResizeRangeHandle = function (x, y, target, callback) { WorkbookView.prototype._onMoveResizeRangeHandle = function (x, y, target, callback) {
var ws = this.getWorksheet(); var ws = this.getWorksheet();
var res = ws.changeSelectionMoveResizeRangeHandle(x, y, target); var d = ws.changeSelectionMoveResizeRangeHandle(x, y, target, this.cellEditor);
if(res){ asc_applyFunction(callback, d);
if(0 == target.targetArr)
ws.changeCellRange(this.cellEditor,res.ar);
asc_applyFunction(callback, res.d);
}
}; };
WorkbookView.prototype._onMoveResizeRangeHandleDone = function (target, callback) { WorkbookView.prototype._onMoveResizeRangeHandleDone = function (target) {
var ws = this.getWorksheet(); var ws = this.getWorksheet();
var d = ws.applyMoveResizeRangeHandle(target); ws.applyMoveResizeRangeHandle(target);
}; };
// Frozen anchor // Frozen anchor
......
...@@ -7363,15 +7363,16 @@ ...@@ -7363,15 +7363,16 @@
return d; return d;
}; };
WorksheetView.prototype.changeSelectionMoveResizeRangeHandle = function (x, y, targetInfo) { WorksheetView.prototype.changeSelectionMoveResizeRangeHandle = function (x, y, targetInfo, editor) {
// Возвращаемый результат // Возвращаемый результат
if( !targetInfo ) if (!targetInfo)
return null; return null;
var indexFormulaRange = targetInfo.indexFormulaRange, d, ret; var indexFormulaRange = targetInfo.indexFormulaRange, d, newFormulaRange = null;
// Пересчитываем координаты // Пересчитываем координаты
x *= asc_getcvt( 0/*px*/, 1/*pt*/, this._getPPIX() ); x *= asc_getcvt( 0/*px*/, 1/*pt*/, this._getPPIX() );
y *= asc_getcvt( 0/*px*/, 1/*pt*/, this._getPPIY() ); y *= asc_getcvt( 0/*px*/, 1/*pt*/, this._getPPIY() );
var ar = 0 == targetInfo.targetArr ? this.arrActiveFormulaRanges[indexFormulaRange].clone(true) : this.arrActiveChartsRanges[indexFormulaRange].clone(true); var ar = 0 == targetInfo.targetArr ? this.arrActiveFormulaRanges[indexFormulaRange].clone(true) :
this.arrActiveChartsRanges[indexFormulaRange].clone(true);
// Колонка по X и строка по Y // Колонка по X и строка по Y
var colByX = this._findColUnderCursor (x, /*canReturnNull*/false, /*dX*/false).col; var colByX = this._findColUnderCursor (x, /*canReturnNull*/false, /*dX*/false).col;
...@@ -7379,12 +7380,11 @@ ...@@ -7379,12 +7380,11 @@
// Если мы только первый раз попали сюда, то копируем выделенную область // Если мы только первый раз попали сюда, то копируем выделенную область
if (null === this.startCellMoveResizeRange) { if (null === this.startCellMoveResizeRange) {
if( (targetInfo.cursor == kCurNEResize || targetInfo.cursor == kCurSEResize) /* && 0 == targetInfo.targetArr */ ){ if ((targetInfo.cursor == kCurNEResize || targetInfo.cursor == kCurSEResize)) {
this.startCellMoveResizeRange = ar.clone(true); this.startCellMoveResizeRange = ar.clone(true);
// this.startCellMoveResizeRange2 = asc_Range(this.startCellMoveResizeRange.c1, this.startCellMoveResizeRange.r1, this.startCellMoveResizeRange.c1, this.startCellMoveResizeRange.r1,true); this.startCellMoveResizeRange2 = asc_Range(targetInfo.col, targetInfo.row,
this.startCellMoveResizeRange2 = asc_Range(targetInfo.col, targetInfo.row, targetInfo.col, targetInfo.row,true); targetInfo.col, targetInfo.row, true);
} } else {
else{
this.startCellMoveResizeRange = ar.clone(true); this.startCellMoveResizeRange = ar.clone(true);
if (colByX < ar.c1) { colByX = ar.c1; } if (colByX < ar.c1) { colByX = ar.c1; }
else if (colByX > ar.c2) { colByX = ar.c2; } else if (colByX > ar.c2) { colByX = ar.c2; }
...@@ -7399,80 +7399,75 @@ ...@@ -7399,80 +7399,75 @@
// this.cleanSelection(); // this.cleanSelection();
this.overlayCtx.clear(); this.overlayCtx.clear();
if( targetInfo.cursor == kCurNEResize || targetInfo.cursor == kCurSEResize ){ if (targetInfo.cursor == kCurNEResize || targetInfo.cursor == kCurSEResize) {
if( colByX < this.startCellMoveResizeRange2.c1 ){ if (colByX < this.startCellMoveResizeRange2.c1) {
ar.c2 = this.startCellMoveResizeRange2.c1; ar.c2 = this.startCellMoveResizeRange2.c1;
ar.c1 = colByX; ar.c1 = colByX;
} } else if (colByX > this.startCellMoveResizeRange2.c1) {
else if( colByX > this.startCellMoveResizeRange2.c1 ){
ar.c1 = this.startCellMoveResizeRange2.c1; ar.c1 = this.startCellMoveResizeRange2.c1;
ar.c2 = colByX; ar.c2 = colByX;
} } else {
else{
ar.c1 = this.startCellMoveResizeRange2.c1; ar.c1 = this.startCellMoveResizeRange2.c1;
ar.c2 = this.startCellMoveResizeRange2.c1 ar.c2 = this.startCellMoveResizeRange2.c1
} }
if( rowByY < this.startCellMoveResizeRange2.r1 ){ if (rowByY < this.startCellMoveResizeRange2.r1) {
if(this.visibleRange.r2 > ar.r2) if (this.visibleRange.r2 > ar.r2)
ar.r2 = this.startCellMoveResizeRange2.r2; ar.r2 = this.startCellMoveResizeRange2.r2;
ar.r1 = rowByY; ar.r1 = rowByY;
} } else if (rowByY > this.startCellMoveResizeRange2.r1) {
else if( rowByY > this.startCellMoveResizeRange2.r1 ){ if (this.visibleRange.r1 < ar.r1)
if(this.visibleRange.r1 < ar.r1)
ar.r1 = this.startCellMoveResizeRange2.r1; ar.r1 = this.startCellMoveResizeRange2.r1;
if(this.visibleRange.r2 > ar.r2) if (this.visibleRange.r2 > ar.r2)
ar.r2 = rowByY; ar.r2 = rowByY;
} } else {
else{
ar.r1 = this.startCellMoveResizeRange2.r1; ar.r1 = this.startCellMoveResizeRange2.r1;
ar.r2 = this.startCellMoveResizeRange2.r1; ar.r2 = this.startCellMoveResizeRange2.r1;
} }
} } else {
else{
this.startCellMoveResizeRange.normalize(); this.startCellMoveResizeRange.normalize();
var colDelta = colByX - this.startCellMoveResizeRange2.c1; var colDelta = colByX - this.startCellMoveResizeRange2.c1;
var rowDelta = rowByY - this.startCellMoveResizeRange2.r1; var rowDelta = rowByY - this.startCellMoveResizeRange2.r1;
ar.c1 = this.startCellMoveResizeRange.c1+colDelta; ar.c1 = this.startCellMoveResizeRange.c1 + colDelta;
if (0 > ar.c1) { if (0 > ar.c1) {
colDelta -= ar.c1; colDelta -= ar.c1;
ar.c1 = 0; ar.c1 = 0;
} }
ar.c2 = this.startCellMoveResizeRange.c2+colDelta; ar.c2 = this.startCellMoveResizeRange.c2 + colDelta;
ar.r1 = this.startCellMoveResizeRange.r1+rowDelta; ar.r1 = this.startCellMoveResizeRange.r1 + rowDelta;
if (0 > ar.r1) { if (0 > ar.r1) {
rowDelta -= ar.r1; rowDelta -= ar.r1;
ar.r1 = 0; ar.r1 = 0;
} }
ar.r2 = this.startCellMoveResizeRange.r2+rowDelta; ar.r2 = this.startCellMoveResizeRange.r2 + rowDelta;
d = { deltaX : ar.c1 <= this.visibleRange.c1 ? ar.c1-this.visibleRange.c1 : d = {
ar.c2>=this.visibleRange.c2 ? ar.c2-this.visibleRange.c2 : 0, deltaX : ar.c1 <= this.visibleRange.c1 ? ar.c1 - this.visibleRange.c1 :
deltaY : ar.r1 <= this.visibleRange.r1 ? ar.r1-this.visibleRange.r1 : ar.c2 >= this.visibleRange.c2 ? ar.c2 - this.visibleRange.c2 : 0,
ar.r2>=this.visibleRange.r2 ? ar.r2-this.visibleRange.r2 : 0 deltaY : ar.r1 <= this.visibleRange.r1 ? ar.r1 - this.visibleRange.r1 :
} ar.r2 >= this.visibleRange.r2 ? ar.r2 - this.visibleRange.r2 : 0};
} }
if( 0 == targetInfo.targetArr ){ if (0 == targetInfo.targetArr) {
var _p = this.arrActiveFormulaRanges[indexFormulaRange].cursorePos, var _p = this.arrActiveFormulaRanges[indexFormulaRange].cursorePos,
_l = this.arrActiveFormulaRanges[indexFormulaRange].formulaRangeLength, _l = this.arrActiveFormulaRanges[indexFormulaRange].formulaRangeLength;
_a = this.arrActiveFormulaRanges[indexFormulaRange].isAbsolute;
this.arrActiveFormulaRanges[indexFormulaRange] = ar.clone(true); this.arrActiveFormulaRanges[indexFormulaRange] = ar.clone(true);
this.arrActiveFormulaRanges[indexFormulaRange].cursorePos = _p; this.arrActiveFormulaRanges[indexFormulaRange].cursorePos = _p;
this.arrActiveFormulaRanges[indexFormulaRange].formulaRangeLength = _l; this.arrActiveFormulaRanges[indexFormulaRange].formulaRangeLength = _l;
this.arrActiveFormulaRanges[indexFormulaRange].isAbsolute = _a; newFormulaRange = this.arrActiveFormulaRanges[indexFormulaRange];
ret = this.arrActiveFormulaRanges[indexFormulaRange]; } else {
}
else{
this.arrActiveChartsRanges[indexFormulaRange] = ar.clone(true); this.arrActiveChartsRanges[indexFormulaRange] = ar.clone(true);
this.moveRangeDrawingObjectTo = ar; this.moveRangeDrawingObjectTo = ar;
} }
this._drawSelection(); this._drawSelection();
return { ar: ret, d:d }; if (newFormulaRange)
editor.changeCellRange(newFormulaRange);
return d;
}; };
/* Функция для применения перемещения диапазона */ /* Функция для применения перемещения диапазона */
...@@ -10429,37 +10424,6 @@ ...@@ -10429,37 +10424,6 @@
editor.enterCellRange(s); editor.enterCellRange(s);
}; };
WorksheetView.prototype.changeCellRange = function (editor, range){
var s = this.getActiveRange(range);
if( range.isAbsolute ){
var ra = range.isAbsolute.split(":"), _s;
if( ra.length >= 1 ){
var sa = s.split(":");
for( var ind = 0; ind < sa.length; ind++ ){
if( ra[ra.length>1?ind:0].indexOf("$") == 0 ){
sa[ind] = "$"+sa[ind];
}
if( ra[ra.length>1?ind:0].lastIndexOf("$") != 0 ){
for(var i = 0; i< sa[ind].length; i++){
if(sa[ind].charAt(i).match(/[0-9]/gi)){
_s = i;
break;
}
}
sa[ind] = sa[ind].substr(0,_s) + "$" +sa[ind].substr(_s,sa[ind].length);
}
}
s = "";
sa.forEach(function(e,i){
s += (i!=0?":":"");
s += e;
})
}
}
editor.changeCellRange(range, s);
return true;
};
WorksheetView.prototype.getActiveRange = function (ar) { WorksheetView.prototype.getActiveRange = function (ar) {
if (ar.c1 === ar.c2 && ar.r1 === ar.r2) {return this._getCellTitle(ar.c1, ar.r1);} if (ar.c1 === ar.c2 && ar.r1 === ar.r2) {return this._getCellTitle(ar.c1, ar.r1);}
if (ar.c1 === ar.c2 && ar.r1 === 0 && ar.r2 === this.rows.length -1) {var ct = this._getColumnTitle(ar.c1); return ct + ":" + ct;} if (ar.c1 === ar.c2 && ar.r1 === 0 && ar.r2 === this.rows.length -1) {var ct = this._getColumnTitle(ar.c1); return ct + ":" + ct;}
......
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