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

У Range добавил isEmptyText и isEmptyTextString

Для проверки пустоты использую эти функции (поправил баги: при переходе на следующую не пустую ячейку, мы не учитывали ячейку с формулой, в которой нет текста. Также поправил баг с наслоением текста, выходящего за границу на такую "пустую" ячейку)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@55306 954022d7-b5bf-4e40-9824-e11837661b57
parent d2eb7418
......@@ -2845,7 +2845,7 @@ Woorksheet.prototype.getRange3=function(r1, c1, r2, c2){
nColMin = c2;
}
return new Range(this, nRowMin, nColMin, nRowMax, nColMax);
}
};
Woorksheet.prototype._getRows=function(){
return this.aGCells;
};
......@@ -2916,7 +2916,6 @@ Woorksheet.prototype._getCell2=function(cellId){
};
Woorksheet.prototype._getCellNoEmpty=function(row, col){
//0-based
var oCurCell;
var oCurRow = this.aGCells[row];
if(oCurRow)
{
......@@ -5345,6 +5344,14 @@ Range.prototype.getType=function(){
else
return null;
};
Range.prototype.isEmptyText=function(){
var cell = this.worksheet._getCellNoEmpty(this.bbox.r1,this.bbox.c1);
return (null != cell) ? cell.isEmptyText() : true;
};
Range.prototype.isEmptyTextString=function(){
var cell = this.worksheet._getCellNoEmpty(this.bbox.r1,this.bbox.c1);
return (null != cell) ? cell.isEmptyTextString() : true;
};
Range.prototype.getFormula=function(){
var cell = this.worksheet._getCellNoEmpty(this.bbox.r1,this.bbox.c1);
if(null != cell)
......
......@@ -860,9 +860,9 @@
ct.target === "colresize" ? ws.optimizeColWidth(ct.col) : ws.optimizeRowHeight(ct.row);
asc_applyFunction(callback);
} else {
if (ct.col >=0 && ct.row >= 0) {
this.controller.setStrictClose( !ws._isCellEmpty(ct.col, ct.row) );
}
if (ct.col >=0 && ct.row >= 0)
this.controller.setStrictClose(!ws._isCellEmptyText(ct.col, ct.row));
// Для нажатия на колонку/строку/all обрабатывать dblClick не нужно
if ("colheader" === ct.target || "rowheader" === ct.target || "corner" === ct.target) {
asc_applyFunction(callback);
......
......@@ -2656,7 +2656,7 @@
ctx.setFillStyle(this.settings.cells.defaultState.background);
for (var col = colBeg; col < colEnd; ++col) {
var c = this._getCell(col, row);
var bg = c !== undefined ? c.getFill() : null;
var bg = null !== c ? c.getFill() : null;
if (bg !== null) {continue;}
ctx.fillRect(
this.cols[col].left + this.cols[col].width - offsetX - this.width_1px,
......@@ -4166,7 +4166,7 @@
}
var c = this._getCell(col, row);
if (c === undefined) {return col;}
if (null === c) {return col;}
var bUpdateScrollX = false;
var bUpdateScrollY = false;
......@@ -4199,7 +4199,7 @@
fMergedRows = true;
}
if (this._isCellEmpty(c)) {return mc ? mc.c2 : col;}
if (this._isCellEmptyTextString(c)) {return mc ? mc.c2 : col;}
var dDigitsCount = 0;
var colWidth = 0;
......@@ -4513,9 +4513,9 @@
WorksheetView.prototype._getCell = function (col, row) {
this.nRowsCount = Math.max(this.model.getRowsCount() , this.rows.length);
this.nColsCount = Math.max(this.model.getColsCount(), this.cols.length);
if ( col < 0 || col >= this.nColsCount || row < 0 || row >= this.nRowsCount ) {
return undefined;
}
if (col < 0 || col >= this.nColsCount || row < 0 || row >= this.nRowsCount)
return null;
return this.model.getCell3(row, col);
};
......@@ -4526,7 +4526,7 @@
WorksheetView.prototype._getCellFlags = function (col, row) {
var c = row !== undefined ? this._getCell(col, row) : col;
var fl = new CellFlags();
if (c !== undefined) {
if (null !== c) {
fl.wrapText = c.getWrap();
fl.shrinkToFit = c.getShrinkToFit();
fl.isMerged = c.hasMerged() !== null;
......@@ -4535,35 +4535,39 @@
return fl;
};
WorksheetView.prototype._isCellEmpty = function (col, row) {
WorksheetView.prototype._isCellEmptyText = function (col, row) {
var c = row !== undefined ? this._getCell(col, row) : col;
return null === c || c.isEmptyText();
};
WorksheetView.prototype._isCellEmptyTextString = function (col, row) {
var c = row !== undefined ? this._getCell(col, row) : col;
return c === undefined || c.getValue().search(/[^ ]/) < 0;
return null === c || c.isEmptyTextString();
};
WorksheetView.prototype._isCellEmptyOrMerged = function (col, row) {
var c = row !== undefined ? this._getCell(col, row) : col;
if (undefined === c)
if (null === c)
return true;
if (null !== c.hasMerged())
if (!c.isEmptyText())
return false;
return c.getValue().search(/[^ ]/) < 0;
return (null === c.hasMerged());
};
WorksheetView.prototype._isCellEmptyOrMergedOrBackgroundColorOrBorders = function (col, row) {
var c = row !== undefined ? this._getCell(col, row) : col;
if (undefined === c)
if (null === c)
return true;
if (!c.isEmptyTextString())
return false;
if (null !== c.hasMerged())
return false;
var bg = c.getFill();
if (null !== bg)
return false;
var cb = c.getBorder();
if ((cb.l && c_oAscBorderStyles.None !== cb.l.s) || (cb.r && c_oAscBorderStyles.None !== cb.r.s) ||
return !((cb.l && c_oAscBorderStyles.None !== cb.l.s) || (cb.r && c_oAscBorderStyles.None !== cb.r.s) ||
(cb.t && c_oAscBorderStyles.None !== cb.t.s) || (cb.b && c_oAscBorderStyles.None !== cb.b.s) ||
(cb.dd && c_oAscBorderStyles.None !== cb.dd.s) || (cb.du && c_oAscBorderStyles.None !== cb.du.s))
return false;
return c.getValue().search(/[^ ]/) < 0;
(cb.dd && c_oAscBorderStyles.None !== cb.dd.s) || (cb.du && c_oAscBorderStyles.None !== cb.du.s));
};
WorksheetView.prototype._getRange = function (c1, r1, c2, r2) {
......@@ -4917,11 +4921,11 @@
var vr = t.visibleRange;
function findNextCell(col, row, dx, dy) {
var state = t._isCellEmpty(col, row);
var state = t._isCellEmptyText(col, row);
var i = col + dx;
var j = row + dy;
while (i >= 0 && i < t.cols.length && j >= 0 && j < t.rows.length) {
var newState = t._isCellEmpty(i, j);
var newState = t._isCellEmptyText(i, j);
if (newState !== state) {
var ret = {};
ret.col = state ? i : i - dx;
......@@ -4957,7 +4961,7 @@
for (var col = 0; col < maxCols; ++col) {
for (var row = 0; row < maxRows; ++row) {
if (!t._isCellEmpty(col, row)) {
if (!t._isCellEmptyText(col, row)) {
lastC = Math.max(lastC, col);
lastR = Math.max(lastR, row);
}
......@@ -6074,7 +6078,7 @@
case c_oAscMergeOptions.MergeCenter:
for (r = arn.r1; r <= arn.r2; ++r) {
for (c = arn.c1; c <= arn.c2; ++c) {
if (false === this._isCellEmpty(c, r)) {
if (false === this._isCellEmptyText(c, r)) {
if (notEmpty)
return true;
notEmpty = true;
......@@ -6086,7 +6090,7 @@
for (r = arn.r1; r <= arn.r2; ++r) {
notEmpty = false;
for (c = arn.c1; c <= arn.c2; ++c) {
if (false === this._isCellEmpty(c, r)) {
if (false === this._isCellEmptyText(c, r)) {
if (notEmpty)
return true;
notEmpty = true;
......
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