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

[ios] tables (opengl render)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@63234 954022d7-b5bf-4e40-9824-e11837661b57
parent 7c75c150
......@@ -75,3 +75,346 @@ WorksheetView.prototype._drawCellsAndBorders_Local = function (drawingCtx, c1,
this._drawCellsAndBorders(drawingCtx, new asc_Range(c1, r1, c2, r2), offsetXForDraw, offsetYForDraw);
};
WorksheetView.prototype._getDrawSelection_Local = function (c1, r1, c2, r2, isFrozen) {
var range = undefined;
this.visibleRange = new asc_Range(c1, r1, c2, r2);
isFrozen = !!isFrozen;
if (asc["editor"].isStartAddShape || this.objectRender.selectedGraphicObjectsExists()) {
if (this.isChartAreaEditMode) {
this._drawFormulaRanges(this.arrActiveChartsRanges);
}
return;
}
if (c_oAscSelectionType.RangeMax === this.activeRange.type) {
this.activeRange.c2 = this.cols.length - 1;
this.activeRange.r2 = this.rows.length - 1;
} else if (c_oAscSelectionType.RangeCol === this.activeRange.type) {
this.activeRange.r2 = this.rows.length - 1;
} else if (c_oAscSelectionType.RangeRow === this.activeRange.type) {
this.activeRange.c2 = this.cols.length - 1;
}
var diffWidth = 0, diffHeight = 0;
if (this.topLeftFrozenCell) {
//var cFrozen = this.topLeftFrozenCell.getCol0();
//var rFrozen = this.topLeftFrozenCell.getRow0();
//diffWidth = this.cols[cFrozen].left - this.cols[0].left;
//diffHeight = this.rows[rFrozen].top - this.rows[0].top;
//
//if (!isFrozen) {
// var oFrozenRange;
// cFrozen -= 1; rFrozen -= 1;
// if (0 <= cFrozen && 0 <= rFrozen) {
// oFrozenRange = new asc_Range(0, 0, cFrozen, rFrozen);
// this._drawSelectionRange(oFrozenRange, true);
// }
// if (0 <= cFrozen) {
// oFrozenRange = new asc_Range(0, this.visibleRange.r1, cFrozen, this.visibleRange.r2);
// this._drawSelectionRange(oFrozenRange, true);
// }
// if (0 <= rFrozen) {
// oFrozenRange = new asc_Range(this.visibleRange.c1, 0, this.visibleRange.c2, rFrozen);
// this._drawSelectionRange(oFrozenRange, true);
// }
//}
}
//console.log('this.visibleRange c1: ' + this.visibleRange.c1 + ' r1: ' + this.visibleRange.r1 + ' c2: ' + this.visibleRange.c2 + ' r2: ' + this.visibleRange.r2);
//console.log('this.activeRange c1: ' + this.activeRange.c1 + ' r1: ' + this.activeRange.r1 + ' c2: ' + this.activeRange.c2 + ' r2: ' + this.activeRange.r2);
var tmpRange = range;
if (!this.isSelectionDialogMode)
range = this.activeRange.intersection(range !== undefined ? range : this.visibleRange);
else
range = this.copyActiveRange.intersection(range !== undefined ? range : this.visibleRange);
// Copy fill Handle
var aFH = null;
// Вхождение range
var aFHIntersection = null;
if (this.activeFillHandle !== null) {
// Мы в режиме автозаполнения
aFH = this.activeFillHandle.clone(true);
aFHIntersection = this.activeFillHandle.intersection(tmpRange !== undefined ? tmpRange : this.visibleRange);
}
//if (!range && !aFHIntersection && !this.isFormulaEditMode && !this.activeMoveRange && !this.isChartAreaEditMode) {
// if (!isFrozen) {
// //this._drawActiveHeaders();
// if (this.isSelectionDialogMode) {
// this._drawSelectRange(this.activeRange.clone(true));
// }
// }
// return;
//}
var ctx = this.overlayCtx;
var opt = this.settings;
var offsetX, offsetY;
if (isFrozen) {
if (tmpRange.c1 !== this.visibleRange.c1)
diffWidth = 0;
if (tmpRange.r1 !== this.visibleRange.r1)
diffHeight = 0;
offsetX = this.cols[tmpRange.c1].left - this.cellsLeft - diffWidth;
offsetY = this.rows[tmpRange.r1].top - this.cellsTop - diffHeight;
} else {
offsetX = this.cols[this.visibleRange.c1].left - this.cellsLeft - diffWidth;
offsetY = this.rows[this.visibleRange.r1].top - this.cellsTop - diffHeight;
}
//console.log('range c1: ' + range.c1 + ' r1: ' + range.r1 + ' c2: ' + range.c2 + ' r2: ' + range.r2);
var arn = (!this.isSelectionDialogMode) ? this.activeRange.clone(true) : this.copyActiveRange.clone(true);
var x1 = (range) ? (this.cols[range.c1].left - offsetX - this.width_1px) : 0;
var x2 = (range) ? (this.cols[range.c2].left + this.cols[range.c2].width - offsetX - this.width_1px) : 0;
var y1 = (range) ? (this.rows[range.r1].top - offsetY) : 0;
var y2 = (range) ? (this.rows[range.r2].top + this.rows[range.r2].height - offsetY - this.height_1px) : 0;
var drawLeftSide = (range) ? (range.c1 === arn.c1) : false;
var drawRightSide = (range) ? (range.c2 === arn.c2) : false;
var drawTopSide = (range) ? (range.r1 === arn.r1) : false;
var drawBottomSide = (range) ? (range.r2 === arn.r2) : false;
var l, t, r, b, cr;
// Размеры "квадрата" автозаполнения
var fillHandleWidth = 2 * this.width_2px + this.width_1px;
var fillHandleHeight = 2 * this.height_2px + this.height_1px;
// Координаты выделения для автозаполнения
var xFH1 = 0;
var xFH2 = 0;
var yFH1 = 0;
var yFH2 = 0;
// Рисуем ли мы стороны автозаполнения
var drawLeftFillHandle;
var drawRightFillHandle;
var drawTopFillHandle;
var drawBottomFillHandle;
// set clipping rect to cells area
//ctx.save()
// .beginPath()
// .rect(this.cellsLeft, this.cellsTop, ctx.getWidth() - this.cellsLeft, ctx.getHeight() - this.cellsTop)
// .clip();
// draw frame around cells range
l = drawLeftSide ? -this.width_1px : 0;
r = drawRightSide ? this.width_1px : 0;
t = drawTopSide ? -this.height_1px : 0;
b = drawBottomSide ? this.height_2px : 0;
//ctx.setStrokeStyle(opt.activeCellBorderColor)
// .setLineWidth(3)
// .beginPath();
if (aFHIntersection) {
//// Считаем координаты автозаполнения
//xFH1 = this.cols[aFHIntersection.c1].left - offsetX - this.width_1px;
//xFH2 = this.cols[aFHIntersection.c2].left + this.cols[aFHIntersection.c2].width - offsetX - this.width_1px;
//yFH1 = this.rows[aFHIntersection.r1].top - offsetY;
//yFH2 = this.rows[aFHIntersection.r2].top + this.rows[aFHIntersection.r2].height - offsetY - this.height_1px;
//drawLeftFillHandle = aFHIntersection.c1 === aFH.c1;
//drawRightFillHandle = aFHIntersection.c2 === aFH.c2;
//drawTopFillHandle = aFHIntersection.r1 === aFH.r1;
//drawBottomFillHandle = aFHIntersection.r2 === aFH.r2;
//
//// Если мы не в нулевом состоянии, то рисуем обводку автозаполнения (толстой линией)
//if (aFHIntersection.c1 !== aFHIntersection.c2 || aFHIntersection.r1 !== aFHIntersection.r2 || 2 !== this.fillHandleArea) {
// if (drawTopFillHandle) {ctx.lineHor(xFH1 + l, yFH1 - this.height_1px, xFH2 + this.width_1px + r);}
// if (drawBottomFillHandle) {ctx.lineHor(xFH1 + l, yFH2, xFH2 + this.width_1px + r);}
// if (drawLeftFillHandle) {ctx.lineVer(xFH1, yFH1 + t, yFH2 + b);}
// if (drawRightFillHandle) {ctx.lineVer(xFH2, yFH1 + t, yFH2 + b);}
//}
//
//// Для некоторых вариантов областей нужно дорисовывать обводку для выделенной области
//switch (this.fillHandleArea){
// case 1:
// switch(this.fillHandleDirection){
// case 0:
// // Горизонтальный
// if (drawLeftSide) {ctx.lineVer(x1, y1 + t, y2 + b);}
// break;
// case 1:
// // Вертикальный
// if (drawTopSide) {ctx.lineHor(x1 + l, y1 - this.height_1px, x2 + this.width_1px + r);}
// break;
// }
// break;
// case 2:
// // Для внутренней области нужны все обводки
// if (drawTopSide) {ctx.lineHor(x1 + l, y1 - this.height_1px, x2 + this.width_1px + r);}
// if (drawBottomSide) {ctx.lineHor(x1 + l, y2, x2 + this.width_1px + r);}
// if (drawLeftSide) {ctx.lineVer(x1, y1 + t, y2 + b);}
// if (drawRightSide) {ctx.lineVer(x2, y1 + t, y2 + b);}
// break;
// case 3:
// switch(this.fillHandleDirection){
// case 0:
// // Горизонтальный
// if (range && aFH.c2 !== range.c2){
// if (drawRightSide) {ctx.lineVer(x2, y1 + t, y2 + b);}
// }
// break;
// case 1:
// // Вертикальный
// if (range && aFH.r2 !== range.r2){
// if (drawBottomSide) {ctx.lineHor(x1 + l, y2, x2 + this.width_1px + r);}
// }
// break;
// }
// break;
//}
//ctx.stroke();
} else {
// Автозаполнения нет, просто рисуем обводку
//if (drawTopSide) {ctx.lineHor(x1 + l, y1 - this.height_1px, x2 + this.width_1px + r);}
//if (drawBottomSide) {
// if (isFrozen && !drawRightSide)
// fillHandleWidth = 0;
// ctx.lineHor(x1 + l, y2, x2 + this.width_1px + r - fillHandleWidth);
//}
//if (drawLeftSide) {ctx.lineVer(x1, y1 + t, y2 + b);}
//if (drawRightSide) {
// if (isFrozen && !drawBottomSide)
// fillHandleHeight = 0;
// //ctx.lineVer(x2, y1 + t, y2 + b - fillHandleHeight);
//}
return [x1, y1, x2, y2, this.activeRange.type];
}
return null;
//ctx.stroke();
// draw cells overlay
if (range) {
//var lRect = x1 + (drawLeftSide ? this.width_3px : this.width_1px),
// rRect = x2 - (drawRightSide ? this.width_2px : 0),
// tRect = y1 + (drawTopSide ? this.height_2px : 0),
// bRect = y2 - (drawBottomSide ? this.width_2px : 0);
//ctx.setFillStyle( opt.activeCellBackground )
// .fillRect(lRect, tRect, rRect - lRect, bRect - tRect);
//
//var lRect2 = x1 + (drawLeftSide ? this.width_2px : this.width_1px),
// rRect2 = x2 - (drawRightSide ? this.width_2px : 0),
// tRect2 = y1 + (drawTopSide ? this.height_1px : 0),
// bRect2 = y2 - (drawBottomSide ? this.width_2px : 0);
//ctx.setStrokeStyle(opt.activeCellBorderColor2).setLineWidth(1).beginPath()
// .strokeRect(lRect2, tRect2, rRect2 - lRect2, bRect2 - tRect2);
//
//var firstCell = (!this.isSelectionDialogMode) ? this.activeRange : this.copyActiveRange;
//cr = this.model.getMergedByCell(firstCell.startRow, firstCell.startCol);
//// Получаем активную ячейку в выделении
//cr = range.intersection(null !== cr ? cr : new asc_Range(firstCell.startCol, firstCell.startRow, firstCell.startCol, firstCell.startRow));
//if (cr !== null) {
// ctx.save().beginPath().rect(lRect, tRect, rRect - lRect, bRect - tRect).clip();
// var _l = this.cols[cr.c1].left - offsetX - this.width_1px,
// _r = this.cols[cr.c2].left + this.cols[cr.c2].width - offsetX,
// _t = this.rows[cr.r1].top - offsetY - this.height_1px,
// _b = this.rows[cr.r2].top + this.rows[cr.r2].height - offsetY;
// ctx.clearRect(_l, _t, _r - _l, _b - _t).restore();
//}
//
//if (!(isFrozen && (!drawRightSide || !drawBottomSide))) {
// // Рисуем "квадрат" для автозаполнения (располагается "квадрат" в правом нижнем углу последней ячейки выделения)
// cr = range.intersection(new asc_Range(range.c2, range.r2, range.c2, range.r2));
// if (cr !== null) {
// this.fillHandleL = this.cols[cr.c1].left - offsetX + this.cols[cr.c1].width - this.width_1px - this.width_2px;
// this.fillHandleR = this.fillHandleL + fillHandleWidth;
// this.fillHandleT = this.rows[cr.r1].top - offsetY + this.rows[cr.r1].height - this.height_1px - this.height_2px;
// this.fillHandleB = this.fillHandleT + fillHandleHeight;
//
// ctx.setFillStyle(opt.activeCellBorderColor).fillRect(this.fillHandleL, this.fillHandleT, this.fillHandleR - this.fillHandleL, this.fillHandleB - this.fillHandleT);
//
// ctx.setStrokeStyle(opt.activeCellBorderColor2).setLineWidth(1).beginPath();
// ctx.lineHorPrevPx(this.fillHandleL, this.fillHandleT, this.fillHandleR);
// ctx.lineVerPrevPx(this.fillHandleL, this.fillHandleT, this.fillHandleB);
// ctx.stroke();
// }
//}
}
// draw fill handle select
if (this.activeFillHandle !== null) {
//if (2 === this.fillHandleArea && (aFH.c1 !== aFH.c2 || aFH.r1 !== aFH.r2)){
// // Для внутренней области мы должны "залить" еще и область автозаполнения
// var lFH = xFH1 + (drawLeftFillHandle ? this.width_3px : this.width_1px),
// rFH = xFH2 - (drawRightFillHandle ? this.width_2px : 0),
// tFH = yFH1 + (drawTopFillHandle ? this.height_2px : 0),
// bFH = yFH2 - (drawBottomFillHandle ? this.width_2px : 0);
// ctx.setFillStyle( opt.activeCellBackground )
// .fillRect(lFH, tFH, rFH - lFH, bFH - tFH);
//}
//
//ctx.setStrokeStyle(opt.fillHandleBorderColorSelect).setLineWidth(1).beginPath();
//
//if (aFH.c1 !== aFH.c2 || aFH.r1 !== aFH.r2 || 2 !== this.fillHandleArea) {
// // Рисуем обводку для области автозаполнения, если мы выделили что-то
// if (drawTopFillHandle) {ctx.lineHor(xFH1 + l + this.width_1px, yFH1 - this.height_1px, xFH2 + r);}
// if (drawBottomFillHandle) {ctx.lineHor(xFH1 + l + this.width_1px, yFH2, xFH2 + r);}
// if (drawLeftFillHandle) {ctx.lineVer(xFH1, yFH1 + t + this.height_1px, yFH2 + b - this.height_1px);}
// if (drawRightFillHandle) {ctx.lineVer(xFH2, yFH1 + t + this.height_1px, yFH2 + b - this.height_1px);}
//}
//
//if (2 === this.fillHandleArea){
// // Если мы внутри, еще рисуем обводку для выделенной области
// if (drawTopSide) {ctx.lineHor(x1 + l + this.width_1px, y1 - this.height_1px, x2 + r - this.width_1px);}
// if (drawBottomSide) {ctx.lineHor(x1 + l + this.width_1px, y2, x2 + r - this.width_1px);}
// if (drawLeftSide) {ctx.lineVer(x1, y1 + t + this.height_1px, y2 + b - this.height_1px);}
// if (drawRightSide) {ctx.lineVer(x2, y1 + t + this.height_1px, y2 + b - this.height_1px);}
//}
//
//ctx.stroke();
}
if (!isFrozen && this.isFormulaEditMode) {
// this._drawFormulaRanges(this.arrActiveFormulaRanges);
}
if (!isFrozen && this.isChartAreaEditMode) {
// this._drawFormulaRanges(this.arrActiveChartsRanges);
}
if (!isFrozen && this.isSelectionDialogMode) {
// this._drawSelectRange(this.activeRange.clone(true));
}
if (!isFrozen && this.stateFormatPainter) {
// this._drawFormatPainterRange();
}
if (null !== this.activeMoveRange) {
// ctx.setStrokeStyle(new CColor(0, 0, 0))
// .setLineWidth(1)
// .beginPath();
// var aActiveMoveRangeIntersection = this.activeMoveRange.intersection(tmpRange !== undefined ? tmpRange : this.visibleRange);
// if (aActiveMoveRangeIntersection) {
// var drawLeftSideMoveRange = aActiveMoveRangeIntersection.c1 === this.activeMoveRange.c1;
// var drawRightSideMoveRange = aActiveMoveRangeIntersection.c2 === this.activeMoveRange.c2;
// var drawTopSideMoveRange = aActiveMoveRangeIntersection.r1 === this.activeMoveRange.r1;
// var drawBottomSideMoveRange = aActiveMoveRangeIntersection.r2 === this.activeMoveRange.r2;
//
// var xMoveRange1 = this.cols[aActiveMoveRangeIntersection.c1].left - offsetX - this.width_1px;
// var xMoveRange2 = this.cols[aActiveMoveRangeIntersection.c2].left + this.cols[aActiveMoveRangeIntersection.c2].width - offsetX - this.width_1px;
// var yMoveRange1 = this.rows[aActiveMoveRangeIntersection.r1].top - offsetY;
// var yMoveRange2 = this.rows[aActiveMoveRangeIntersection.r2].top + this.rows[aActiveMoveRangeIntersection.r2].height - offsetY - this.height_1px;
//
// if (drawTopSideMoveRange) {ctx.lineHor(xMoveRange1, yMoveRange1 - this.height_1px, xMoveRange2 + this.width_1px);}
// if (drawBottomSideMoveRange) {ctx.lineHor(xMoveRange1, yMoveRange2, xMoveRange2 + this.width_1px);}
// if (drawLeftSideMoveRange) {ctx.lineVer(xMoveRange1, yMoveRange1, yMoveRange2);}
// if (drawRightSideMoveRange) {ctx.lineVer(xMoveRange2, yMoveRange1, yMoveRange2);}
// }
// ctx.stroke();
}
// restore canvas' original clipping range
//ctx.restore();
//if (!isFrozen) {
// this._drawActiveHeaders();
//}
};
......@@ -283,8 +283,7 @@ var native = CreateNativeEngine();
window.native = native;
window["native"] = native;
function GetNativeEngine()
{
function GetNativeEngine() {
return window.native;
}
......@@ -355,18 +354,6 @@ function NativeOpenFile2(_params)
}
}
// open file
function SEOpenFile()
{
window["CreateMainTextMeasurerWrapper"]();
window.g_file_path = "native_open_file";
window.NATIVE_DOCUMENT_TYPE = window.native.GetEditorType();
_api = new window["Asc"]["spreadsheet_api"]();
_api.asc_nativeOpenFile(window.native["GetFileString"]());
}
function NativeCalculateFile()
{
_api.asc_nativeCalculateFile();
......@@ -777,31 +764,25 @@ var EGlyphState =
glyphstateMiss: 2
};
function CPoint1()
{
function CPoint1() {
this.fX = 0;
this.fY = 0;
this.fWidth = 0;
this.fHeight = 0;
};
function CPoint2()
{
}
function CPoint2() {
this.fLeft = 0;
this.fTop = 0;
this.fRight = 0;
this.fBottom = 0;
};
function CFontManager()
{
}
function CFontManager() {
this.m_oLibrary = {};
this.Initialize = function(){};
this.ClearFontsRasterCache = function(){};
};
}
function CStylesPainter()
{
function CStylesPainter() {
this.STYLE_THUMBNAIL_WIDTH = GlobalSkin.STYLE_THUMBNAIL_WIDTH;
this.STYLE_THUMBNAIL_HEIGHT = GlobalSkin.STYLE_THUMBNAIL_HEIGHT;
......@@ -812,8 +793,7 @@ function CStylesPainter()
this.docStyles = [];
this.mergedStyles = [];
}
CStylesPainter.prototype =
{
CStylesPainter.prototype = {
GenerateStyles: function(_api, ds)
{
if (_api.WordControl.bIsRetinaSupport)
......@@ -1103,7 +1083,7 @@ CStylesPainter.prototype =
_api.WordControl.m_oDrawingDocument.Native["DD_EndNativeDraw"](_stream);
graphics.ClearParams();
}
};
}
window["use_native_fonts_only"] = true;
......@@ -1113,8 +1093,7 @@ window["use_native_fonts_only"] = true;
window["ftm"] = FT_Memory;
// FT_Common
function _FT_Common()
{
function _FT_Common() {
this.UintToInt = function(v)
{
return (v>2147483647)?v-4294967296:v;
......@@ -1219,121 +1198,87 @@ function _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
// defines
//--------------------------------------------------------------------------------
function internal_drawWorksheet(sheet, corner, frozenPaneLines, selection) {
//sheet._clean();
var PageType = {
PageDefaultType: 0,
PageTopType: 1,
PageLeftType: 2,
PageCornerType: 3
};
// if (corner) sheet._drawCorner();
//sheet._drawColumnHeaders();
//sheet._drawRowHeaders();
var deviceScale = 1;
sheet._drawGrid();
sheet._drawCellsAndBorders();
//--------------------------------------------------------------------------------
// OfflineEditor
//--------------------------------------------------------------------------------
//sheet._drawFrozenPane();
//if (frozenPaneLines) sheet._drawFrozenPaneLines();
function OfflineEditor () {
//sheet._fixSelectionOfMergedCells();
//sheet._drawAutoF();
// sheet.cellCommentator.drawCommentCells();
this.contentX = 16384;
this.contextY = 1048576;
this.zoom = 1.0;
// sheet.objectRender.showDrawingObjectsEx(true);
// main
//if (selection && sheet.overlayCtx) {
// sheet._drawSelection();
//}
}
this.openFile = function () {
window["CreateMainTextMeasurerWrapper"]();
//--------------------------------------------------------------------------------
// native invoke
//--------------------------------------------------------------------------------
deviceScale = window.native["GetDeviceScale"]();
var PageType = {
PageDefaultType: 0,
PageTopType: 1,
PageLeftType: 2,
PageCornerType: 3
};
var scrollIndX = 0;
var scrollIndY = 0;
var deviceScale = 1;
window.g_file_path = "native_open_file";
window.NATIVE_DOCUMENT_TYPE = window.native.GetEditorType();
_api = new window["Asc"]["spreadsheet_api"]();
_api.asc_nativeOpenFile(window.native["GetFileString"]());
};
var cellsLeft = undefined;
var cellsTop = undefined;
// prop
function napi_openFile() {
window["CreateMainTextMeasurerWrapper"]();
this.getMaxSizeX = function () {
return this.contentX;
};
this.getMaxSizeY = function () {
return this.contextY;
};
this.getSelection = function(x, y, width, height) {
_null_object.width = width;
_null_object.height = height;
deviceScale = window.native["GetDeviceScale"]();
var worksheet = _api.wb.getWorksheet(0);
var region = this._updateRegion(worksheet, x, y, width, height);
window.g_file_path = "native_open_file";
window.NATIVE_DOCUMENT_TYPE = window.native.GetEditorType();
_api = new window["Asc"]["spreadsheet_api"]();
_api.asc_nativeOpenFile(window.native["GetFileString"]());
}
return _api.wb.getWorksheet(0)._getDrawSelection_Local(region.columnBeg, region.rowBeg, region.columnEnd, region.rowEnd);
};
function napi_drawWorksheet(x, y, width, height, xind, yind) {
// render
if (_api) {
_null_object.width = width * 1.5;
_null_object.height = height * 1.5;
this.drawSheet = function (x, y, width, height, ratio) {
_null_object.width = width * ratio;
_null_object.height = height * ratio;
var worksheet = _api.wb.getWorksheet(0);
var region = updateRegion(worksheet, x, y, width * 1.5, height * 1.5);
var region = this._updateRegion(worksheet, x, y, width * ratio, height * ratio);
worksheet._drawGrid_Local(undefined,
region.columnBeg, region.rowBeg, region.columnEnd, region.rowEnd ,
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);
worksheet._drawCellsAndBorders_Local(undefined,
region.columnBeg, region.rowBeg, region.columnEnd + 1, region.rowEnd + 1,
region.columnBeg, region.rowBeg, region.columnEnd, region.rowEnd,
worksheet.cols[region.columnBeg].left + region.columnOff, worksheet.rows[region.rowBeg].top + region.rowOff);
}
}
function napi_drawWorksheetHeader(x, y, width, height, xind, yind, type) {
};
this.drawHeader = function (x, y, width, height, type, ratio) {
if (_api) {
_null_object.width = width * 1.5;
_null_object.height = height * 1.5;
_null_object.width = width * ratio;
_null_object.height = height * ratio;
var worksheet = _api.wb.getWorksheet(0);
var region = updateRegion(worksheet, x, y, width * 1.5, height * 1.5);
var region = this._updateRegion(worksheet, x, y, width * ratio, height * ratio);
var isColumn = type == PageType.PageTopType || type == PageType.PageCornerType;
var isColumn = type == PageType.PageTopType || type == PageType.PageCornerType;
var isRow = type == PageType.PageLeftType || type == PageType.PageCornerType;
if (!isColumn && isRow)
......@@ -1342,124 +1287,137 @@ function napi_drawWorksheetHeader(x, y, width, height, xind, yind, type) {
worksheet._drawColumnHeaders_Local(undefined, region.columnBeg, region.columnEnd, undefined, region.columnOff, 0);
else if (isColumn && isRow)
worksheet._drawCorner();
}
}
};
// internal
function napi_getContentMaxSizeX() {
this._updateRegion = function (worksheet, x, y, width, height) {
// ширина таблицы с учетом размеров ячеек
var i = 0;
var nativeToEditor = 1.0 / deviceScale * (72.0 / 96.0);
// var gc_nMaxRow = 1048576;
// var gc_nMaxCol = 16384;
// координаты в СО редактора
return 50000;
}
function napi_getContentMaxSizeY() {
var logicX = x * nativeToEditor + worksheet.headersWidth;
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;
var count = 0;
//var gc_nMaxRow = 1048576;
//var gc_nMaxCol = 16384;
// добавляем отсутствующие колонки ( с небольшим зазором )
return 50000;
}
function napi_setZoom(zoom) {
_api.asc_setZoom(zoom);
}
var logicToXMAX = 10000 * (1 + Math.floor(logicToX / 10000));
/////////////////
if (logicToXMAX >= worksheet.cols[worksheet.cols.length - 1].left) {
function updateRegion(worksheet, x, y, width, height) {
do {
worksheet.nColsCount = worksheet.cols.length + 1;
worksheet._calcWidthColumns(2); // fullRecalc
var indX = 0, indY = 0, offX = 0, offY = 0, i = 0;
if (logicToXMAX < worksheet.cols[worksheet.cols.length - 1].left) {
break
}
} while (1);
}
var nativeToEditor = 1.0 / deviceScale * (72.0 / 96.0);
// координаты в СО редактора
if (logicX < worksheet.cols[worksheet.cols.length - 1].left) {
count = worksheet.cols.length;
for (i = 0; i < count; ++i) {
if (-1 === columnBeg) {
if (worksheet.cols[i].left <= logicX && logicX < worksheet.cols[i].left + worksheet.cols[i].width) {
columnBeg = i;
columnOff = logicX - worksheet.cols[i].left;
}
}
var logicX = x * nativeToEditor + worksheet.headersWidth;
var logicY = y * nativeToEditor + worksheet.headersHeight;
var logicToX = ( x + width ) * nativeToEditor + worksheet.headersWidth;
var logicToY = ( y + height ) * nativeToEditor + worksheet.headersHeight;
if (worksheet.cols[i].left <= logicToX && logicToX < worksheet.cols[i].left + worksheet.cols[i].width) {
columnEnd = i;
break;
}
}
}
var columnBeg = -1;
var columnEnd = -1;
var columnOff = 0;
var rowBeg = -1;
var rowEnd = -1;
var rowOff = 0;
// добавляем отсутствующие строки ( с небольшим зазором )
// добавляем отсутствующие колонки
var logicToYMAX = 10000 * (1 + Math.floor(logicToY / 10000));
if (logicToX >= worksheet.cols[worksheet.cols.length - 1].left) {
if (logicToYMAX >= worksheet.rows[worksheet.rows.length - 1].top) {
do {
worksheet.nColsCount = worksheet.cols.length + 1;
worksheet._calcWidthColumns(2); // fullRecalc
do {
worksheet.nRowsCount = worksheet.rows.length + 1;
worksheet._calcHeightRows(2); // fullRecalc
if (logicToX < worksheet.cols[worksheet.cols.length - 1].left) {
break
}
} while (1);
}
if (logicToYMAX < worksheet.rows[worksheet.rows.length - 1].top) {
break
}
} while (1);
}
if (logicX < worksheet.cols[worksheet.cols.length - 1].left) {
for (i = 0; i < worksheet.cols.length; ++i) {
if (-1 === columnBeg) {
if (worksheet.cols[i].left <= logicX && logicX < worksheet.cols[i].left + worksheet.cols[i].width) {
columnBeg = i;
columnOff = logicX - worksheet.cols[i].left;
if (logicY < worksheet.rows[worksheet.rows.length - 1].top) {
count = worksheet.rows.length;
for (i = 0; i < count; ++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 (worksheet.cols[i].left <= logicToX && logicToX < worksheet.cols[i].left + worksheet.cols[i].width) {
columnEnd = i;
break;
if (worksheet.rows[i].top <= logicToY && logicToY < worksheet.rows[i].top + worksheet.rows[i].height) {
rowEnd = i;
break;
}
}
}
}
// добавляем отсутствующие строки
return {
columnBeg: columnBeg,
columnEnd: columnEnd,
columnOff: columnOff,
rowBeg: rowBeg,
rowEnd: rowEnd,
rowOff: rowOff
};
};
if (logicToY >= worksheet.rows[worksheet.rows.length - 1].top) {
this._updateContentSize = function (isColumnRecalc, isRowRecalc) {
do {
worksheet.nRowsCount = worksheet.rows.length + 1;
worksheet._calcHeightRows(2); // fullRecalc
// сделать пересчет по надобности
if (logicToY < worksheet.rows[worksheet.rows.length - 1].top) {
break
}
} while (1);
//var gc_nMaxRow = 1048576;
//var gc_nMaxCol = 16384;
}
}
var _s = new OfflineEditor();
//--------------------------------------------------------------------------------
// ios
//--------------------------------------------------------------------------------
if (logicY < worksheet.rows[worksheet.rows.length - 1].top) {
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 (worksheet.rows[i].top <= logicToY && logicToY < worksheet.rows[i].top + worksheet.rows[i].height) {
rowEnd = i;
break;
}
}
}
return {
columnBeg: columnBeg,
columnEnd: columnEnd,
columnOff: columnOff,
rowBeg: rowBeg,
rowEnd: rowEnd,
rowOff: rowOff
};
function offline_of() {_s.openFile();}
function offline_sx() {_s.getMaxSizeX();}
function offline_sy() {_s.getMaxSizeY();}
function offline_stz(v) {_s.zoom = v; _api.asc_setZoom(v);}
function offline_ds(x, y, width, height, ratio) {_s.drawSheet(x, y, width, height, ratio);}
function offline_dh(x, y, width, height, type, ratio) {_s.drawHeader(x, y, width, height, type, ratio);}
function offline_mouse_down(x, y) {
_api.wb.getWorksheet(0).changeSelectionStartPoint(x, y, true, true);
}
function offline_mouse_move(x, y) {
_api.wb.getWorksheet(0).changeSelectionEndPoint(x, y, true, true);
}
function offline_mouse_up(x, y) {
_api.wb.getWorksheet(0).changeSelectionDone();
}
function offline_get_selection(x, y, width, height) {
return _s.getSelection(x, y, width, height);
}
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