Commit e9af6664 authored by Alexey.Musinov's avatar Alexey.Musinov Committed by Alexander.Trofimov

[ios] tables

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@62970 954022d7-b5bf-4e40-9824-e11837661b57
parent 7b7f2625
window["Asc"].WorksheetView = WorksheetView;
WorksheetView.prototype._drawColumnHeaders_Local = function (drawingCtx, start, end, style, offsetXForDraw, offsetYForDraw) {
if (undefined === drawingCtx && false === this.model.sheetViews[0].asc_getShowRowColHeaders())
return;
var vr = this.visibleRange;
var c = this.cols;
var offsetX = (undefined !== offsetXForDraw) ? offsetXForDraw : c[vr.c1].left - this.cellsLeft;
var offsetY = (undefined !== offsetYForDraw) ? offsetYForDraw : this.headersTop;
if (undefined === drawingCtx && this.topLeftFrozenCell && undefined === offsetXForDraw) {
var cFrozen = this.topLeftFrozenCell.getCol0();
if (start < vr.c1)
offsetX = c[0].left - this.cellsLeft;
else
offsetX -= c[cFrozen].left - c[0].left;
}
if (asc_typeof(start) !== "number") {start = vr.c1;}
if (asc_typeof(end) !== "number") {end = vr.c2;}
if (style === undefined) {style = kHeaderDefault;}
this._setFont(drawingCtx, this.model.getDefaultFontName(), this.model.getDefaultFontSize());
var ctx = (drawingCtx) ? drawingCtx : this.drawingCtx;
var st = this.settings.header.style[style];
ctx.setFillStyle(st.border)
.fillRect( - offsetX, offsetY, c[end].left - c[start].left, this.headersHeight * 2);
// draw column headers
for (var i = start; i <= end; ++i) {
this._drawHeader(drawingCtx, c[i].left - c[start].left - offsetX, offsetY,
c[i].width, this.headersHeight, style, true, i);
}
};
WorksheetView.prototype._drawRowHeaders_Local = function (drawingCtx, start, end, style, offsetXForDraw, offsetYForDraw) {
if (undefined === drawingCtx && false === this.model.sheetViews[0].asc_getShowRowColHeaders())
return;
var vr = this.visibleRange;
var r = this.rows;
var offsetX = (undefined !== offsetXForDraw) ? offsetXForDraw : this.headersLeft;
var offsetY = (undefined !== offsetYForDraw) ? offsetYForDraw : r[vr.r1].top - this.cellsTop;
if (undefined === drawingCtx && this.topLeftFrozenCell && undefined === offsetYForDraw) {
var rFrozen = this.topLeftFrozenCell.getRow0();
if (start < vr.r1)
offsetY = r[0].top - this.cellsTop;
else
offsetY -= r[rFrozen].top - r[0].top;
}
if (asc_typeof(start) !== "number") {start = vr.r1;}
if (asc_typeof(end) !== "number") {end = vr.r2;}
if (style === undefined) {style = kHeaderDefault;}
this._setFont(drawingCtx, this.model.getDefaultFontName(), this.model.getDefaultFontSize());
var ctx = (drawingCtx) ? drawingCtx : this.drawingCtx;
var st = this.settings.header.style[style];
ctx.setFillStyle(st.border)
.fillRect(offsetX, -offsetY, this.headersWidth * 2, r[end].top - r[start].top);
// draw row headers
for (var i = start; i <= end; ++i) {
this._drawHeader(drawingCtx, offsetX, r[i].top - r[start].top - offsetY,
this.headersWidth, r[i].height, style, false, i);
}
};
WorksheetView.prototype._drawGrid_Local = function (drawingCtx, c1, r1, c2, r2, leftFieldInPt, topFieldInPt, width, height) {
this._drawGrid(drawingCtx, new asc_Range(c1, r1, c2, r2), leftFieldInPt, topFieldInPt, width, height);
};
WorksheetView.prototype._drawCellsAndBorders_Local = function (drawingCtx, c1, r1, c2, r2, offsetXForDraw, offsetYForDraw) {
this._drawCellsAndBorders(drawingCtx, new asc_Range(c1, r1, c2, r2), offsetXForDraw, offsetYForDraw);
};
...@@ -1219,6 +1219,36 @@ function _FT_Common() ...@@ -1219,6 +1219,36 @@ function _FT_Common()
} }
var FT_Common = new _FT_Common(); var FT_Common = new _FT_Common();
//========================================================================================
function drawColumnHeaders (sheet, drawingCtx, start, end, style, offsetXForDraw, offsetYForDraw) {
if (undefined === drawingCtx && false === sheet.model.sheetViews[0].asc_getShowRowColHeaders())
return;
var vr = sheet.visibleRange;
var c = sheet.cols;
var offsetX = (undefined !== offsetXForDraw) ? offsetXForDraw : c[vr.c1].left - sheet.cellsLeft;
var offsetY = (undefined !== offsetYForDraw) ? offsetYForDraw : sheet.headersTop;
if (undefined === drawingCtx && sheet.topLeftFrozenCell && undefined === offsetXForDraw) {
var cFrozen = sheet.topLeftFrozenCell.getCol0();
if (start < vr.c1)
offsetX = c[0].left - sheet.cellsLeft;
else
offsetX -= c[cFrozen].left - c[0].left;
}
if (asc_typeof(start) !== "number") {start = vr.c1;}
if (asc_typeof(end) !== "number") {end = vr.c2;}
if (style === undefined) {style = kHeaderDefault;}
sheet._setFont(drawingCtx, sheet.model.getDefaultFontName(), sheet.model.getDefaultFontSize());
// draw column headers
for (var i = start; i <= end; ++i) {
sheet._drawHeader(drawingCtx, c[i].left - c[start].left, offsetY,
c[i].width, sheet.headersHeight, style, true, i);
}
}
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// internal invoke // internal invoke
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
...@@ -1226,25 +1256,25 @@ var FT_Common = new _FT_Common(); ...@@ -1226,25 +1256,25 @@ var FT_Common = new _FT_Common();
function internal_drawWorksheet(sheet, corner, frozenPaneLines, selection) { function internal_drawWorksheet(sheet, corner, frozenPaneLines, selection) {
//sheet._clean(); //sheet._clean();
if (corner) sheet._drawCorner(); // if (corner) sheet._drawCorner();
sheet._drawColumnHeaders(); //sheet._drawColumnHeaders();
sheet._drawRowHeaders(); //sheet._drawRowHeaders();
sheet._drawGrid(); sheet._drawGrid();
sheet._drawCellsAndBorders(); sheet._drawCellsAndBorders();
sheet._drawFrozenPane(); //sheet._drawFrozenPane();
if (frozenPaneLines) sheet._drawFrozenPaneLines(); //if (frozenPaneLines) sheet._drawFrozenPaneLines();
sheet._fixSelectionOfMergedCells(); //sheet._fixSelectionOfMergedCells();
sheet._drawAutoF(); //sheet._drawAutoF();
sheet.cellCommentator.drawCommentCells(); // sheet.cellCommentator.drawCommentCells();
// sheet.objectRender.showDrawingObjectsEx(true); // sheet.objectRender.showDrawingObjectsEx(true);
if (selection && sheet.overlayCtx) { //if (selection && sheet.overlayCtx) {
sheet._drawSelection(); // sheet._drawSelection();
} //}
} }
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
...@@ -1278,219 +1308,158 @@ function napi_openFile() { ...@@ -1278,219 +1308,158 @@ function napi_openFile() {
function napi_drawWorksheet(x, y, width, height, xind, yind) { function napi_drawWorksheet(x, y, width, height, xind, yind) {
if (_api) { if (_api) {
_null_object.width = width; _null_object.width = width * 1.5;
_null_object.height = height; _null_object.height = height * 1.5;
var worksheet = _api.wb.getWorksheet(0), indX = 0, indY = 0, offX = 0, offY = 0, i = 0;
x = x / deviceScale * (72.0 / 96.0) + worksheet.headersWidth; var worksheet = _api.wb.getWorksheet(0);
y = y / deviceScale * (72.0 / 96.0) + worksheet.headersHeight; var region = updateRegion(worksheet, x, y, width * 1.5, height * 1.5);
// сброс текущего отступа по ячейке (пока через костыль делаем скроллы) worksheet._drawGrid_Local(undefined,
region.columnBeg, region.rowBeg, region.columnEnd, region.rowEnd ,
worksheet.cols[region.columnBeg].left + region.columnOff, worksheet.rows[region.rowBeg].top + region.rowOff,
width + region.columnOff, height + region.rowOff);
if (undefined == cellsLeft) { worksheet._drawCellsAndBorders_Local(undefined,
cellsLeft = worksheet.cellsLeft; //console.log('left: ' + cellsLeft); region.columnBeg, region.rowBeg, region.columnEnd + 1, region.rowEnd + 1,
worksheet.cols[region.columnBeg].left + region.columnOff, worksheet.rows[region.rowBeg].top + region.rowOff);
} }
if (undefined == cellsTop) { }
cellsTop = worksheet.cellsTop; //console.log('top: ' + cellsTop); function napi_drawWorksheetHeader(x, y, width, height, xind, yind, type) {
}
worksheet.cellsLeft = cellsLeft;
worksheet.cellsTop = cellsTop;
if (0 == xind && scrollIndX != 0) if (_api) {
{ _null_object.width = width * 1.5;
for (i = scrollIndX; i >= 0; --i) _null_object.height = height * 1.5;
worksheet.scrollHorizontal(-1);
scrollIndX = 0; var worksheet = _api.wb.getWorksheet(0);
} var region = updateRegion(worksheet, x, y, width * 1.5, height * 1.5);
if (0 == yind && scrollIndY != 0) var isColumn = type == PageType.PageTopType || type == PageType.PageCornerType;
{ var isRow = type == PageType.PageLeftType || type == PageType.PageCornerType;
for (i = scrollIndY; i >= 0; --i)
worksheet.scrollVertical(-1);
scrollIndY = 0; if (!isColumn && isRow)
worksheet._drawRowHeaders_Local(undefined, region.rowBeg, region.rowEnd, undefined, 0, region.rowOff);
else if (isColumn && !isRow)
worksheet._drawColumnHeaders_Local(undefined, region.columnBeg, region.columnEnd, undefined, region.columnOff, 0);
else if (isColumn && isRow)
worksheet._drawCorner();
} }
}
// ищем ячейку для начальной точки отрисовки
for (i = 0; i < worksheet.cols.length; ++i) {
if (worksheet.cols[i].left <= x && x < worksheet.cols[i].left + worksheet.cols[i].width) {
// if (xind == 1 && yind == 1) {
// console.log('x: ' + x +
// ' worksheet.cols[i].left: ' + worksheet.cols[i].left+
// ' worksheet.cols[i].width: ' + worksheet.cols[i].width
// );
// }
indX = i;
offX = x - worksheet.cols[i].left;
break;
}
}
for (i = 0; i < worksheet.rows.length; ++i) { function napi_getContentMaxSizeX() {
// if ((xind == 1 || xind == 0)&& yind == 1)
// console.log('top-height: ' + worksheet.rows[i].top + ',' + worksheet.rows[i].height);
if (worksheet.rows[i].top <= y && y < worksheet.rows[i].top + worksheet.rows[i].height) {
// if ((xind == 1 || xind == 0)&& yind == 1) {
// console.log('y: ' + y +
// ' worksheet.rows[i].top: ' + worksheet.rows[i].top +
// ' worksheet.rows[i].height: ' + worksheet.rows[i].height +
// ' bottom: ' + ( worksheet.rows[i].top + worksheet.rows[i].height) +
// ' indY: ' + i + ' offY: ' + offY
// );
// //}
indY = i;
offY = y - worksheet.rows[i].top;
break;
}
}
// ширина таблицы с учетом размеров ячеек
// var gc_nMaxRow = 1048576;
// var gc_nMaxCol = 16384;
// for (var i = 0; i < worksheet.rows.length; ++i) return 50000;
// console.log(xind + ',' + yind + ' before top-height: ' + worksheet.rows[i].top + ',' + worksheet.rows[i].height); }
// function napi_getContentMaxSizeY() {
//
if (indX - scrollIndX > 0) {
for (i = scrollIndX; i < indX; ++i) // высота таблицы с учетом размеров ячеек
worksheet.scrollHorizontal(1);
scrollIndX = indX; //var gc_nMaxRow = 1048576;
} //var gc_nMaxCol = 16384;
if (indY - scrollIndY > 0) { return 50000;
}
for (i = scrollIndY; i < indY; ++i) function napi_setZoom(zoom) {
worksheet.scrollVertical(1); _api.asc_setZoom(zoom);
}
scrollIndY = indY; /////////////////
}
//
// for (var i = 0; i < worksheet.rows.length; ++i)
// console.log(xind + ',' + yind + ' after top-height: ' + worksheet.rows[i].top + ',' + worksheet.rows[i].height);
worksheet.cellsLeft = -offX; function updateRegion(worksheet, x, y, width, height) {
worksheet.cellsTop = -offY;
internal_drawWorksheet(worksheet); var indX = 0, indY = 0, offX = 0, offY = 0, i = 0;
}
}
function napi_drawWorksheetHeader(x, y, width, height, xind, yind, type) {
if (_api) { var nativeToEditor = 1.0 / deviceScale * (72.0 / 96.0);
_null_object.width = width;
_null_object.height = height;
var worksheet = _api.wb.getWorksheet(0), indX = 0, indY = 0, offX = 0, offY = 0, i = 0; // координаты в СО редактора
x = x / deviceScale * (72.0 / 96.0) + worksheet.headersWidth; var logicX = x * nativeToEditor + worksheet.headersWidth;
y = y / deviceScale * (72.0 / 96.0) + worksheet.headersHeight; var logicY = y * nativeToEditor + worksheet.headersHeight;
var logicToX = ( x + width ) * nativeToEditor + worksheet.headersWidth;
var logicToY = ( y + height ) * nativeToEditor + worksheet.headersHeight;
// сброс текущего отступа по ячейке (пока через костыль делаем скроллы) var columnBeg = -1;
var columnEnd = -1;
var columnOff = 0;
var rowBeg = -1;
var rowEnd = -1;
var rowOff = 0;
if (undefined == cellsLeft) { // добавляем отсутствующие колонки
cellsLeft = worksheet.cellsLeft; //console.log('left: ' + cellsLeft);
}
if (undefined == cellsTop) {
cellsTop = worksheet.cellsTop; //console.log('top: ' + cellsTop);
}
worksheet.cellsLeft = cellsLeft; if (logicToX >= worksheet.cols[worksheet.cols.length - 1].left) {
worksheet.cellsTop = cellsTop;
if (0 == xind && scrollIndX != 0) do {
{ worksheet.nColsCount = worksheet.cols.length + 1;
for (i = scrollIndX; i >= 0; --i) worksheet._calcWidthColumns(2); // fullRecalc
worksheet.scrollHorizontal(-1);
scrollIndX = 0; if (logicToX < worksheet.cols[worksheet.cols.length - 1].left) {
break
} }
} while (1);
if (0 == yind && scrollIndY != 0)
{
for (i = scrollIndY; i >= 0; --i)
worksheet.scrollVertical(-1);
scrollIndY = 0;
} }
// ищем ячейку для начальной точки отрисовки
if (logicX < worksheet.cols[worksheet.cols.length - 1].left) {
for (i = 0; i < worksheet.cols.length; ++i) { for (i = 0; i < worksheet.cols.length; ++i) {
if (worksheet.cols[i].left <= x && x < worksheet.cols[i].left + worksheet.cols[i].width) { if (-1 === columnBeg) {
indX = i; if (worksheet.cols[i].left <= logicX && logicX < worksheet.cols[i].left + worksheet.cols[i].width) {
offX = x - worksheet.cols[i].left; columnBeg = i;
break; columnOff = logicX - worksheet.cols[i].left;
} }
} }
for (i = 0; i < worksheet.rows.length; ++i) { if (worksheet.cols[i].left <= logicToX && logicToX < worksheet.cols[i].left + worksheet.cols[i].width) {
if (worksheet.rows[i].top <= y && y < worksheet.rows[i].top + worksheet.rows[i].height) { columnEnd = i;
indY = i;
offY = y - worksheet.rows[i].top;
break; break;
} }
} }
if (indX - scrollIndX > 0) {
for (i = scrollIndX; i < indX; ++i)
worksheet.scrollHorizontal(1);
scrollIndX = indX;
} }
if (indY - scrollIndY > 0) { // добавляем отсутствующие строки
if (logicToY >= worksheet.rows[worksheet.rows.length - 1].top) {
for (i = scrollIndY; i < indY; ++i) do {
worksheet.scrollVertical(1); worksheet.nRowsCount = worksheet.rows.length + 1;
worksheet._calcHeightRows(2); // fullRecalc
scrollIndY = indY; if (logicToY < worksheet.rows[worksheet.rows.length - 1].top) {
break
}
} while (1);
} }
worksheet.cellsLeft = -offX;
worksheet.cellsTop = -offY;
if ((0 == yind && type == PageType.PageTopType) || type == PageType.PageCornerType) { if (logicY < worksheet.rows[worksheet.rows.length - 1].top) {
worksheet.cellsTop += worksheet.headersHeight; for (i = 0; i < worksheet.rows.length; ++i) {
if (-1 === rowBeg) {
if (worksheet.rows[i].top <= logicY && logicY < worksheet.rows[i].top + worksheet.rows[i].height) {
rowBeg = i;
rowOff = logicY - worksheet.rows[i].top;
} }
if ((0 == xind && type == PageType.PageLeftType) || type == PageType.PageCornerType) {
worksheet.cellsLeft += worksheet.headersWidth;
} }
internal_drawWorksheet(worksheet, true); if (worksheet.rows[i].top <= logicToY && logicToY < worksheet.rows[i].top + worksheet.rows[i].height) {
rowEnd = i;
break;
}
}
} }
}
function napi_getContentMaxSizeX() {
// ширина таблицы с учетом размеров ячеек
// var gc_nMaxRow = 1048576;
// var gc_nMaxCol = 16384;
return 50000;
}
function napi_getContentMaxSizeY() {
// высота таблицы с учетом размеров ячеек
//var gc_nMaxRow = 1048576;
//var gc_nMaxCol = 16384;
return 50000;
}
function napi_setZoom(zoom) { return {
_api.asc_setZoom(zoom); columnBeg: columnBeg,
columnEnd: columnEnd,
columnOff: columnOff,
rowBeg: rowBeg,
rowEnd: rowEnd,
rowOff: rowOff
};
} }
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