Commit 049f8e8e authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

добавил findCellByXY - ищет ячейку и отступы в ней по координатам

добавил класс CCellObjectInfo

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@56179 954022d7-b5bf-4e40-9824-e11837661b57
parent a19f00ce
......@@ -528,8 +528,7 @@ function FrozenPlace(ws, type) {
_this.calculateCell = function(x, y) {
var cell = { col: 0, colOff: 0, colOffPx: 0,
row: 0, rowOff: 0, rowOffPx: 0 };
var cell = new CCellObjectInfo();
if ( _this.isPointInside(x, y) ) {
......@@ -770,8 +769,7 @@ function DrawingArea(ws) {
};
_this.calculateCell = function(x, y) {
var cell = { col: 0, colOff: 0, colOffPx: 0,
row: 0, rowOff: 0, rowOffPx: 0 };
var cell = null;
for ( var i = 0; i < _this.frozenPlaces.length; i++ ) {
if ( _this.frozenPlaces[i].isPointInside(x, y) ) {
......@@ -779,7 +777,7 @@ function DrawingArea(ws) {
break;
}
}
return cell;
return null !== cell ? cell : new CCellObjectInfo();
};
_this.calculateCoords = function(cell) {
......
......@@ -58,6 +58,16 @@ function roundPlus(x, n) { //x - число, n - количество знако
return Math.round(x * m) / m;
}
// Класс для информации о ячейке для объектов ToDo возможно стоит поправить
function CCellObjectInfo () {
this.col = 0;
this.row = 0;
this.colOff = 0;
this.rowOff = 0;
this.colOffPx = 0;
this.rowOffPx = 0;
}
//{ ASC Classes
......@@ -2663,8 +2673,8 @@ function DrawingObjects() {
_t.Type = c_oAscCellAnchorType.cellanchorTwoCell;
_t.Pos = { X: 0, Y: 0 };
_t.from = { col: 0, colOff: 0, row: 0, rowOff: 0 };
_t.to = { col: 0, colOff: 0, row: 0, rowOff: 0 };
_t.from = new CCellObjectInfo();
_t.to = new CCellObjectInfo();
_t.ext = { cx: 0, cy: 0 };
_t.size = { width: 0, height: 0 };
......@@ -5196,7 +5206,7 @@ function DrawingObjects() {
_this.getPositionInfo = function(x, y) {
var info = { col: 0, colOff: 0, row: 0, rowOff: 0 };
var info = new CCellObjectInfo();
var tmp = worksheet._findColUnderCursor(pxToPt(x), true);
if (tmp) {
......@@ -5443,8 +5453,7 @@ function CoordsManager(ws, bLog) {
_t.calculateCell = function(x, y) {
var cell = { col: 0, colOff: 0, colOffPx: 0,
row: 0, rowOff: 0, rowOffPx: 0 };
var cell = new CCellObjectInfo();
var _x = x + worksheet.getCellLeft(0, 0);
var _y = y + worksheet.getCellTop(0, 0);
......
......@@ -1080,7 +1080,7 @@ Workbook.prototype.init=function(){
Workbook.prototype.rebuildColors=function(){
g_oColorManager.rebuildColors();
for(var i = 0 , length = this.aWorksheets.length; i < length; ++i)
this.aWorksheets[i].rebuildColors();;
this.aWorksheets[i].rebuildColors();
};
Workbook.prototype.getDefaultFont=function(){
return g_oDefaultFont.fn;
......
......@@ -5351,6 +5351,31 @@
// ----- Selection -----
// x,y - абсолютные координаты относительно листа (без учета заголовков)
WorksheetView.prototype.findCellByXY = function (x, y) {
var r = 0, c = 0, result = new CCellObjectInfo();
x += this.cellsLeft;
y += this.cellsTop;
while (c < this.cols.length) {
if (x >= this.cols[c].left && this.width_1px <= this.cols[c].width) {
result.col = c;
break;
}
++c;
}
while (r < this.rows.length && y < this.rows[r].top) {
if (y >= this.rows[r].top && this.height_1px <= this.rows[r].height) {
result.row = r;
break;
}
++r;
}
result.colOff = this.cols[result.col].left - x;
result.rowOff = this.rows[result.row].top - y;
return result;
};
// dX = true - считать с половиной следующей ячейки
WorksheetView.prototype._findColUnderCursor = function (x, canReturnNull, dX) {
var c = this.visibleRange.c1,
......
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