Commit 2fda0124 authored by Sergey.Luzyanin's avatar Sergey.Luzyanin Committed by Alexander.Trofimov

git-svn-id:...

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47547 954022d7-b5bf-4e40-9824-e11837661b57
parent 7a57b3ea
......@@ -10,14 +10,14 @@
//-----------------------------------------------------------------------------------
var DrawingObject = null;
var DrawingObjectLayer = null;
var DrawingObjectLayer = null;
if ( !window["Asc"] ) { // Для вставки диаграмм в Word
window["Asc"] = {};
}
function isObject(what) {
return ( what && (typeof(what) == "object") );
function isObject(what) {
return ( what && (typeof(what) == "object") );
}
function convertFormula(formula, ws) {
......@@ -37,11 +37,11 @@ function convertFormula(formula, ws) {
}
}
return range;
}
//-----------------------------------------------------------------------------------
// Интерфейс < Excel - Word >
//-----------------------------------------------------------------------------------
}
//-----------------------------------------------------------------------------------
// Интерфейс < Excel - Word >
//-----------------------------------------------------------------------------------
function CChartData(bWordContext, chart) {
......@@ -864,10 +864,10 @@ function CChartData(bWordContext, chart) {
if ( bWordContext )
g_oTableId.Add( _this, _this.Id );
}
//-----------------------------------------------------------------------------------
// Chart style
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
// Chart style
//-----------------------------------------------------------------------------------
function asc_CChartStyle() {
this.style = null;
......@@ -881,7 +881,7 @@ asc_CChartStyle.prototype = {
asc_getImageUrl: function() { return this.imageUrl; },
asc_setImageUrl: function(imageUrl) { this.imageUrl = imageUrl; }
}
//{ asc_CChartStyle export
window["Asc"].asc_CChartStyle = asc_CChartStyle;
window["Asc"]["asc_CChartStyle"] = asc_CChartStyle;
......@@ -891,17 +891,17 @@ prot["asc_getStyle"] = prot.asc_getStyle;
prot["asc_setStyle"] = prot.asc_setStyle;
prot["asc_getImageUrl"] = prot.asc_getImageUrl;
prot["asc_setImageUrl"] = prot.asc_setImageUrl;
prot["asc_setImageUrl"] = prot.asc_setImageUrl;
//}
//-----------------------------------------------------------------------------------
// Chart
//-----------------------------------------------------------------------------------
function asc_CChart(object) {
//-----------------------------------------------------------------------------------
// Chart
//-----------------------------------------------------------------------------------
function asc_CChart(object) {
var bCopy = isObject(object);
this.bChartEditor = bCopy ? object.bChartEditor : false;
this.type = bCopy ? object.type : null;
this.subType = bCopy ? object.subType : null;
......@@ -1169,7 +1169,7 @@ asc_CChart.prototype = {
}
}
}
//{ asc_CChart export
window["Asc"].asc_CChart = asc_CChart;
window["Asc"]["asc_CChart"] = asc_CChart;
......@@ -1210,15 +1210,15 @@ prot["asc_setSeria"] = prot.asc_setSeria;
prot["asc_removeSeries"] = prot.asc_removeSeries;
prot["asc_getChartEditorFlag"] = prot.asc_getChartEditorFlag;
prot["asc_setChartEditorFlag"] = prot.asc_setChartEditorFlag;
prot["asc_setChartEditorFlag"] = prot.asc_setChartEditorFlag;
//}
//-----------------------------------------------------------------------------------
// Chart range
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
// Chart range
//-----------------------------------------------------------------------------------
function asc_CChartRange(object) {
var bCopy = isObject(object);
this.interval = bCopy ? object.interval : "";
......@@ -1275,7 +1275,7 @@ asc_CChartRange.prototype = {
}
}
}
//{ asc_CChartRange export
window["Asc"].asc_CChartRange = asc_CChartRange;
window["Asc"]["asc_CChartRange"] = asc_CChartRange;
......@@ -1288,12 +1288,12 @@ prot["asc_getRowsFlag"] = prot.asc_getRowsFlag;
prot["asc_setRowsFlag"] = prot.asc_setRowsFlag;
prot["asc_getColumnsFlag"] = prot.asc_getColumnsFlag;
prot["asc_setColumnsFlag"] = prot.asc_setColumnsFlag;
prot["asc_setColumnsFlag"] = prot.asc_setColumnsFlag;
//}
//-----------------------------------------------------------------------------------
// Chart title
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
// Chart title
//-----------------------------------------------------------------------------------
function asc_CChartHeader(object) {
......@@ -1357,7 +1357,7 @@ asc_CChartHeader.prototype = {
}
}
}
//{ asc_CChartHeader export
window["Asc"].asc_CChartHeader = asc_CChartHeader;
window["Asc"]["asc_CChartHeader"] = asc_CChartHeader;
......@@ -1373,16 +1373,16 @@ prot["asc_getDefaultTitleFlag"] = prot.asc_getDefaultTitleFlag;
prot["asc_setDefaultTitleFlag"] = prot.asc_setDefaultTitleFlag;
prot["asc_getFont"] = prot.asc_getFont;
prot["asc_setFont"] = prot.asc_setFont;
prot["asc_setFont"] = prot.asc_setFont;
//}
//-----------------------------------------------------------------------------------
// Chart axis X
//-----------------------------------------------------------------------------------
function asc_CChartAxisX(object) {
var bCopy = isObject(object);
//-----------------------------------------------------------------------------------
// Chart axis X
//-----------------------------------------------------------------------------------
function asc_CChartAxisX(object) {
var bCopy = isObject(object);
this.title = bCopy ? object.title : "";
this.bDefaultTitle = bCopy ? object.bDefaultTitle : false;
......@@ -1456,7 +1456,7 @@ asc_CChartAxisX.prototype = {
}
}
}
//{ asc_CChartAxisX export
window["Asc"].asc_CChartAxisX = asc_CChartAxisX;
window["Asc"]["asc_CChartAxisX"] = asc_CChartAxisX;
......@@ -1478,11 +1478,11 @@ prot["asc_getTitleFont"] = prot.asc_getTitleFont;
prot["asc_setTitleFont"] = prot.asc_setTitleFont;
prot["asc_getLabelFont"] = prot.asc_getLabelFont;
prot["asc_setLabelFont"] = prot.asc_setLabelFont;
prot["asc_setLabelFont"] = prot.asc_setLabelFont;
//}
//-----------------------------------------------------------------------------------
// Chart axis Y
//-----------------------------------------------------------------------------------
// Chart axis Y
//-----------------------------------------------------------------------------------
function asc_CChartAxisY(object) {
......@@ -1561,7 +1561,7 @@ asc_CChartAxisY.prototype = {
}
}
}
//{ asc_CChartAxisY export
window["Asc"].asc_CChartAxisY = asc_CChartAxisY;
window["Asc"]["asc_CChartAxisY"] = asc_CChartAxisY;
......@@ -1583,17 +1583,17 @@ prot["asc_getTitleFont"] = prot.asc_getTitleFont;
prot["asc_setTitleFont"] = prot.asc_setTitleFont;
prot["asc_getLabelFont"] = prot.asc_getLabelFont;
prot["asc_setLabelFont"] = prot.asc_setLabelFont;
prot["asc_setLabelFont"] = prot.asc_setLabelFont;
//}
//-----------------------------------------------------------------------------------
// Chart legend
//-----------------------------------------------------------------------------------
// Chart legend
//-----------------------------------------------------------------------------------
function asc_CChartLegend(object) {
var bCopy = isObject(object);
function asc_CChartLegend(object) {
var bCopy = isObject(object);
this.position = bCopy ? object.position : c_oAscChartLegend.right;
this.bShow = bCopy ? object.bShow : true;
this.bOverlay = bCopy ? object.bOverlay : false;
......@@ -1647,7 +1647,7 @@ asc_CChartLegend.prototype = {
}
}
}
//{ asc_CChartLegend export
window["Asc"].asc_CChartLegend = asc_CChartLegend;
window["Asc"]["asc_CChartLegend"] = asc_CChartLegend;
......@@ -1663,12 +1663,12 @@ prot["asc_getOverlayFlag"] = prot.asc_getOverlayFlag;
prot["asc_setOverlayFlag"] = prot.asc_setOverlayFlag;
prot["asc_getFont"] = prot.asc_getFont;
prot["asc_setFont"] = prot.asc_setFont;
prot["asc_setFont"] = prot.asc_setFont;
//}
//-----------------------------------------------------------------------------------
// Chart series
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
// Chart series
//-----------------------------------------------------------------------------------
function asc_CChartSeria() {
this.Val = { Formula: null, NumCache: [] };
......@@ -1755,7 +1755,7 @@ asc_CChartSeria.prototype = {
}
}
}
//{ asc_CChartSeria export
window["Asc"].asc_CChartSeria = asc_CChartSeria;
window["Asc"]["asc_CChartSeria"] = asc_CChartSeria;
......@@ -1780,16 +1780,16 @@ prot["asc_getOutlineColor"] = prot.asc_getOutlineColor;
prot["asc_setOutlineColor"] = prot.asc_setOutlineColor;
prot["asc_getFormatCode"] = prot.asc_getFormatCode;
prot["asc_setFormatCode"] = prot.asc_setFormatCode;
prot["asc_setFormatCode"] = prot.asc_setFormatCode;
//}
//-----------------------------------------------------------------------------------
// Chart font
//-----------------------------------------------------------------------------------
// Chart font
//-----------------------------------------------------------------------------------
function asc_CChartFont(object) {
var bCopy = isObject(object);
function asc_CChartFont(object) {
var bCopy = isObject(object);
this.name = bCopy ? object.name : "Calibri";
this.size = bCopy ? object.size : 10;
......@@ -1861,7 +1861,7 @@ asc_CChartFont.prototype = {
}
}
}
//{ asc_CChartFont export
window["Asc"].asc_CChartFont = asc_CChartFont;
window["Asc"]["asc_CChartFont"] = asc_CChartFont;
......@@ -1883,12 +1883,12 @@ asc_CChartFont.prototype = {
prot["asc_setItalic"] = prot.asc_setItalic;
prot["asc_getUnderline"] = prot.asc_getUnderline;
prot["asc_setUnderline"] = prot.asc_setUnderline;
prot["asc_setUnderline"] = prot.asc_setUnderline;
//}
//-----------------------------------------------------------------------------------
// Undo/Redo
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
// Undo/Redo
//-----------------------------------------------------------------------------------
DrawingObjects.prototype = {
......@@ -1987,9 +1987,9 @@ function DrawingObjects() {
var shiftKey = false;
var userId = null;
var documentId = null;
var lastObjectIndex = null;
// Все изменения, связанные с image.src прогоняем через этот класс
var lastObjectIndex = null;
// Все изменения, связанные с image.src прогоняем через этот класс
var imageLoader = new ImageLoader();
//-----------------------------------------------------------------------------------
......@@ -2016,12 +2016,12 @@ function DrawingObjects() {
currentSheet.model.Drawings[i].worksheet = worksheet;
aObjects[i] = _this.cloneDrawingObject(currentSheet.model.Drawings[i]);
if (aObjects[i].isChart()) {
if (aObjects[i].isChart()) {
_this.calcChartInterval(aObjects[i].chart);
aObjects[i].chart.worksheet = worksheet;
}
if (aObjects[i].isImage())
}
if (aObjects[i].isImage())
imageLoader.addImage(aObjects[i].image.src);
}
lastObjectIndex = aObjects.length;
......@@ -2196,15 +2196,15 @@ function DrawingObjects() {
// всё чистим
if (clearCanvas)
_this.clearDrawingObjects();
if ( !imageLoader.isReady() ) {
//console.log("imageLoader - False");
imageLoader.setReadyCallback(_this.showDrawingObjects);
}
else {
//console.log("imageLoader - Ok");
imageLoader.removeReadyCallback();
_this.clearDrawingObjects();
if ( !imageLoader.isReady() ) {
//console.log("imageLoader - False");
imageLoader.setReadyCallback(_this.showDrawingObjects);
}
else {
//console.log("imageLoader - Ok");
imageLoader.removeReadyCallback();
}
for (var i = 0; i < _this.countDrawingObjects(); i++) {
......@@ -2224,7 +2224,7 @@ function DrawingObjects() {
if (!obj.flags.anchorUpdated)
obj.updateAnchorPosition();
// History
if (obj.move.inAction && undoRedoObject && (undoRedoObject.id == obj.id)) {
......@@ -2260,9 +2260,9 @@ function DrawingObjects() {
obj.chart.rebuildSeries();
var chartBase64 = chartRender.insertChart(obj.chart, null, obj.getWidthFromTo(), obj.getHeightFromTo());
if ( !chartBase64 )
continue;
imageLoader.addImage(chartBase64);
continue;
imageLoader.addImage(chartBase64);
imageLoader.setReadyCallback(_this.showDrawingObjects);
obj.image.onload = function() {
......@@ -2270,7 +2270,7 @@ function DrawingObjects() {
}
obj.image.src = chartBase64;
obj.flags.redrawChart = false;
obj.flags.redrawChart = false;
continue;
}
......@@ -2412,68 +2412,68 @@ function DrawingObjects() {
//-----------------------------------------------------------------------------------
// Create drawing
//-----------------------------------------------------------------------------------
var DrawingBase = function(ws) {
var _t = this;
var DrawingBase = function(ws) {
var _t = this;
_t.worksheet = ws;
_t.Properties = {
Id: 1,
Type: 2,
PosX: 3,
PosY: 4,
ExtCx: 5,
ExtCy: 6,
ImageSrc: 7,
FlagCurrentCursor: 8,
FlagsTransactionState: 9,
_t.Properties = {
Id: 1,
Type: 2,
PosX: 3,
PosY: 4,
ExtCx: 5,
ExtCy: 6,
ImageSrc: 7,
FlagCurrentCursor: 8,
FlagsTransactionState: 9,
ImageUrl: 10,
FromCol: 11,
FromColOff: 12,
FromRow: 13,
FromCol: 11,
FromColOff: 12,
FromRow: 13,
FromRowOff: 14,
ToCol: 15,
ToColOff: 16,
ToRow: 17,
ToRowOff: 18,
MoveX: 19,
MoveY: 20,
SizeCoeff: 21,
ChartData: 22
};
_t.id = null;
_t.image = new Image();
_t.imageUrl = "";
_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.ext = { cx: 0, cy: 0 };
_t.size = { width: 0, height: 0, coeff: 1 };
_t.move = { x: 0, y: 0, inAction: false };
ToCol: 15,
ToColOff: 16,
ToRow: 17,
ToRowOff: 18,
MoveX: 19,
MoveY: 20,
SizeCoeff: 21,
ChartData: 22
};
_t.id = null;
_t.image = new Image();
_t.imageUrl = "";
_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.ext = { cx: 0, cy: 0 };
_t.size = { width: 0, height: 0, coeff: 1 };
_t.move = { x: 0, y: 0, inAction: false };
_t.chart = new asc_CChart();
_t.graphicObject = null; // CShape or GroupShape
_t.flags = {
selected: false,
anchorUpdated: false,
lockState: c_oAscObjectLockState.No,
currentCursor: null,
_t.graphicObject = null; // CShape or GroupShape
_t.flags = {
selected: false,
anchorUpdated: false,
lockState: c_oAscObjectLockState.No,
currentCursor: null,
transactionState: c_oAscTransactionState.No,
redrawChart: false
};
// Свойства
_t.isImage = function() {
return !_t.isChart();
}
_t.isChart = function() {
return _t.chart.type ? true : false;
redrawChart: false
};
// Свойства
_t.isImage = function() {
return !_t.isChart();
}
_t.isChart = function() {
return _t.chart.type ? true : false;
}
_t.isGraphicObject = function() {
......@@ -2482,219 +2482,223 @@ function DrawingObjects() {
_t.getWorkbook = function() {
return (_t.worksheet ? _t.worksheet.model.workbook : null);
}
// Проверяет выход за границы
_t.canDraw = function() {
var result = true;
if (!_t.image.src ||
(_t.worksheet.getCellLeft(_t.worksheet.getFirstVisibleCol(), 0) > _t.worksheet.getCellLeft(_t.to.col, 0) + mmToPx(_t.to.colOff)) ||
(_t.worksheet.getCellTop(_t.worksheet.getFirstVisibleRow(), 0) > _t.worksheet.getCellTop(_t.to.row, 0) + mmToPx(_t.to.rowOff)))
{ result = false; }
return result;
}
_t.canResize = function(width, height) {
var result = true;
if (_t.flags.currentCursor != "move") {
if (_t.isChart()) {
if (width == minChartWidth) {
switch (_t.flags.currentCursor) {
case "w-resize": case "e-resize": case "ne-resize":
case "nw-resize": case "se-resize": case "sw-resize":
result = false;
}
}
else if (height == minChartHeight) {
switch (_t.flags.currentCursor) {
case "n-resize": case "s-resize": case "ne-resize":
case "nw-resize": case "se-resize": case "sw-resize":
result = false;
}
}
}
else { // Image
if (width == minImageWidth) {
switch (_t.flags.currentCursor) {
case "w-resize": case "e-resize": case "ne-resize":
case "nw-resize": case "se-resize": case "sw-resize":
result = false;
}
}
else if (height == minImageHeight) {
switch (_t.flags.currentCursor) {
case "n-resize": case "s-resize": case "ne-resize":
case "nw-resize": case "se-resize": case "sw-resize":
result = false;
}
}
}
}
return result;
}
_t.updateAnchorPosition = function() {
switch (_t.Type) {
case c_oAscCellAnchorType.cellanchorOneCell:
{
var _left = _t.getRealLeftOffset();
var _top = _t.getRealTopOffset();
var foundCol = _t.worksheet._findColUnderCursor(pxToPt(_left + mmToPx(_t.ext.cx)), true);
while (foundCol == null) {
_t.worksheet.expandColsOnScroll(true);
_t.worksheet._trigger("reinitializeScrollX");
foundCol = _t.worksheet._findColUnderCursor(pxToPt(_left + mmToPx(_t.ext.cx)), true);
}
_t.to.col = foundCol.col;
_t.to.colOff = pxToMm(_left + mmToPx(_t.ext.cx) - _t.worksheet.getCellLeft(_t.to.col, 0));
var foundRow = _t.worksheet._findRowUnderCursor(pxToPt(_top + mmToPx(_t.ext.cy)), true);
while (foundRow == null) {
_t.worksheet.expandRowsOnScroll(true);
_t.worksheet._trigger("reinitializeScrollY");
foundRow = _t.worksheet._findRowUnderCursor(pxToPt(_top + mmToPx(_t.ext.cy)), true);
}
_t.to.row = foundRow.row;
_t.to.rowOff = pxToMm(_top + mmToPx(_t.ext.cy) - _t.worksheet.getCellTop(_t.to.row, 0));
}
break;
case c_oAscCellAnchorType.cellanchorAbsolute:
{
if ( _t.Pos.X < 0 )
_t.Pos.X = 0;
if ( _t.Pos.Y < 0 )
_t.Pos.Y = 0;
_t.from.col = _t.worksheet._findColUnderCursor(pxToPt(mmToPx(_t.Pos.X) + _t.worksheet.getCellLeft(0, 0)), true).col;
_t.from.colOff = pxToMm(mmToPx(_t.Pos.X) + _t.worksheet.getCellLeft(0, 0) - _t.worksheet.getCellLeft(_t.from.col, 0));
_t.from.row = _t.worksheet._findRowUnderCursor(pxToPt(mmToPx(_t.Pos.Y) + _t.worksheet.getCellTop(0, 0)), true).row;
_t.from.rowOff = pxToMm(mmToPx(_t.Pos.Y) + _t.worksheet.getCellTop(0, 0) - _t.worksheet.getCellTop(_t.from.row, 0));
var _left = _t.getRealLeftOffset();
var _top = _t.getRealTopOffset();
var foundCol = _t.worksheet._findColUnderCursor(pxToPt(_left + mmToPx(_t.ext.cx)), true);
while (foundCol == null) {
_t.worksheet.expandColsOnScroll(true);
_t.worksheet._trigger("reinitializeScrollX");
foundCol = _t.worksheet._findColUnderCursor(pxToPt(_left + mmToPx(_t.ext.cx)), true);
}
_t.to.col = foundCol.col;
_t.to.colOff = pxToMm(_left + mmToPx(_t.ext.cx) - _t.worksheet.getCellLeft(_t.to.col, 0));
var foundRow = _t.worksheet._findRowUnderCursor(pxToPt(_top + mmToPx(_t.ext.cy)), true);
while (foundRow == null) {
_t.worksheet.expandRowsOnScroll(true);
_t.worksheet._trigger("reinitializeScrollY");
foundRow = _t.worksheet._findRowUnderCursor(pxToPt(_top + mmToPx(_t.ext.cy)), true);
}
_t.to.row = foundRow.row;
_t.to.rowOff = pxToMm(_top + mmToPx(_t.ext.cy) - _t.worksheet.getCellTop(_t.to.row, 0));
}
break;
}
_t.flags.anchorUpdated = true;
}
_t.normalizeMetrics = function() {
var width = _t.getWidthFromTo();
var height = _t.getHeightFromTo();
if ( width < 2 )
_t.to.colOff = _t.from.colOff + 4;
if ( height < 2 )
_t.to.rowOff = _t.from.rowOff + 4;
}
// Реальное смещение по высоте
_t.getRealTopOffset = function() {
var val = _t.worksheet.getCellTop(_t.from.row, 0) + mmToPx(_t.from.rowOff);
return Asc.round(val);
}
// Реальное смещение по ширине
_t.getRealLeftOffset = function() {
var val = _t.worksheet.getCellLeft(_t.from.col, 0) + mmToPx(_t.from.colOff);
return Asc.round(val);
}
// Ширина по координатам
_t.getWidthFromTo = function(withoutRound) {
var val = _t.worksheet.getCellLeft(_t.to.col, 0) + mmToPx(_t.to.colOff) - _t.worksheet.getCellLeft(_t.from.col, 0) - mmToPx(_t.from.colOff);
return withoutRound ? val : Asc.round(val);
}
// Высота по координатам
_t.getHeightFromTo = function(withoutRound) {
var val = _t.worksheet.getCellTop(_t.to.row, 0) + mmToPx(_t.to.rowOff) - _t.worksheet.getCellTop(_t.from.row, 0) - mmToPx(_t.from.rowOff);
return withoutRound ? val : Asc.round(val);
}
// Видимая ширина при скролах
_t.getVisibleWidth = function() {
var fvc = _t.worksheet.getCellLeft(_t.worksheet.getFirstVisibleCol(), 0);
var off = _t.getRealLeftOffset() - fvc;
off = (off >= 0) ? 0 : Math.abs(off);
return _t.getWidthFromTo() - off;
}
// Видимая высота при скролах
_t.getVisibleHeight = function() {
var fvr = _t.worksheet.getCellTop(_t.worksheet.getFirstVisibleRow(), 0);
var off = _t.getRealTopOffset() - fvr;
off = (off >= 0) ? 0 : Math.abs(off);
return _t.getHeightFromTo() - off;
}
// Видимое смещение объекта от первой видимой строки
_t.getVisibleTopOffset = function(withHeader) {
var headerRowOff = _t.worksheet.getCellTop(0, 0);
var fvr = _t.worksheet.getCellTop(_t.worksheet.getFirstVisibleRow(), 0);
var off = _t.getRealTopOffset() - fvr;
var off = (off > 0) ? off : 0;
return withHeader ? headerRowOff + off : off;
}
// Видимое смещение объекта от первой видимой колонки
_t.getVisibleLeftOffset = function(withHeader) {
var headerColOff = _t.worksheet.getCellLeft(0, 0);
var fvc = _t.worksheet.getCellLeft(_t.worksheet.getFirstVisibleCol(), 0);
var off = _t.getRealLeftOffset() - fvc;
var off = (off > 0) ? off : 0;
return withHeader ? headerColOff + off : off;
}
// смещение по высоте внутри объекта
_t.getInnerOffsetTop = function() {
var fvr = _t.worksheet.getCellTop(_t.worksheet.getFirstVisibleRow(), 0);
var off = _t.getRealTopOffset() - fvr;
return (off > 0) ? 0 : Asc.round(Math.abs(off) * _t.getHeightCoeff());
}
// смещение по ширине внутри объекта
_t.getInnerOffsetLeft = function() {
var fvc = _t.worksheet.getCellLeft(_t.worksheet.getFirstVisibleCol(), 0);
var off = _t.getRealLeftOffset() - fvc;
return (off > 0) ? 0 : Asc.round(Math.abs(off) * _t.getWidthCoeff());
}
// коэффициент по ширине если несоответствие с реальным размером
_t.getWidthCoeff = function() {
return _t.image.width / _t.getWidthFromTo();
}
// коэффициент по высоте если несоответствие с реальным размером
_t.getHeightCoeff = function() {
return _t.image.height / _t.getHeightFromTo();
}
}
}
_t.getCanvasContext = function() {
return shapeCtx.m_oContext;
}
// Проверяет выход за границы
_t.canDraw = function() {
var result = true;
if (!_t.image.src ||
(_t.worksheet.getCellLeft(_t.worksheet.getFirstVisibleCol(), 0) > _t.worksheet.getCellLeft(_t.to.col, 0) + mmToPx(_t.to.colOff)) ||
(_t.worksheet.getCellTop(_t.worksheet.getFirstVisibleRow(), 0) > _t.worksheet.getCellTop(_t.to.row, 0) + mmToPx(_t.to.rowOff)))
{ result = false; }
return result;
}
_t.canResize = function(width, height) {
var result = true;
if (_t.flags.currentCursor != "move") {
if (_t.isChart()) {
if (width == minChartWidth) {
switch (_t.flags.currentCursor) {
case "w-resize": case "e-resize": case "ne-resize":
case "nw-resize": case "se-resize": case "sw-resize":
result = false;
}
}
else if (height == minChartHeight) {
switch (_t.flags.currentCursor) {
case "n-resize": case "s-resize": case "ne-resize":
case "nw-resize": case "se-resize": case "sw-resize":
result = false;
}
}
}
else { // Image
if (width == minImageWidth) {
switch (_t.flags.currentCursor) {
case "w-resize": case "e-resize": case "ne-resize":
case "nw-resize": case "se-resize": case "sw-resize":
result = false;
}
}
else if (height == minImageHeight) {
switch (_t.flags.currentCursor) {
case "n-resize": case "s-resize": case "ne-resize":
case "nw-resize": case "se-resize": case "sw-resize":
result = false;
}
}
}
}
return result;
}
_t.updateAnchorPosition = function() {
switch (_t.Type) {
case c_oAscCellAnchorType.cellanchorOneCell:
{
var _left = _t.getRealLeftOffset();
var _top = _t.getRealTopOffset();
var foundCol = _t.worksheet._findColUnderCursor(pxToPt(_left + mmToPx(_t.ext.cx)), true);
while (foundCol == null) {
_t.worksheet.expandColsOnScroll(true);
_t.worksheet._trigger("reinitializeScrollX");
foundCol = _t.worksheet._findColUnderCursor(pxToPt(_left + mmToPx(_t.ext.cx)), true);
}
_t.to.col = foundCol.col;
_t.to.colOff = pxToMm(_left + mmToPx(_t.ext.cx) - _t.worksheet.getCellLeft(_t.to.col, 0));
var foundRow = _t.worksheet._findRowUnderCursor(pxToPt(_top + mmToPx(_t.ext.cy)), true);
while (foundRow == null) {
_t.worksheet.expandRowsOnScroll(true);
_t.worksheet._trigger("reinitializeScrollY");
foundRow = _t.worksheet._findRowUnderCursor(pxToPt(_top + mmToPx(_t.ext.cy)), true);
}
_t.to.row = foundRow.row;
_t.to.rowOff = pxToMm(_top + mmToPx(_t.ext.cy) - _t.worksheet.getCellTop(_t.to.row, 0));
}
break;
case c_oAscCellAnchorType.cellanchorAbsolute:
{
if ( _t.Pos.X < 0 )
_t.Pos.X = 0;
if ( _t.Pos.Y < 0 )
_t.Pos.Y = 0;
_t.from.col = _t.worksheet._findColUnderCursor(pxToPt(mmToPx(_t.Pos.X) + _t.worksheet.getCellLeft(0, 0)), true).col;
_t.from.colOff = pxToMm(mmToPx(_t.Pos.X) + _t.worksheet.getCellLeft(0, 0) - _t.worksheet.getCellLeft(_t.from.col, 0));
_t.from.row = _t.worksheet._findRowUnderCursor(pxToPt(mmToPx(_t.Pos.Y) + _t.worksheet.getCellTop(0, 0)), true).row;
_t.from.rowOff = pxToMm(mmToPx(_t.Pos.Y) + _t.worksheet.getCellTop(0, 0) - _t.worksheet.getCellTop(_t.from.row, 0));
var _left = _t.getRealLeftOffset();
var _top = _t.getRealTopOffset();
var foundCol = _t.worksheet._findColUnderCursor(pxToPt(_left + mmToPx(_t.ext.cx)), true);
while (foundCol == null) {
_t.worksheet.expandColsOnScroll(true);
_t.worksheet._trigger("reinitializeScrollX");
foundCol = _t.worksheet._findColUnderCursor(pxToPt(_left + mmToPx(_t.ext.cx)), true);
}
_t.to.col = foundCol.col;
_t.to.colOff = pxToMm(_left + mmToPx(_t.ext.cx) - _t.worksheet.getCellLeft(_t.to.col, 0));
var foundRow = _t.worksheet._findRowUnderCursor(pxToPt(_top + mmToPx(_t.ext.cy)), true);
while (foundRow == null) {
_t.worksheet.expandRowsOnScroll(true);
_t.worksheet._trigger("reinitializeScrollY");
foundRow = _t.worksheet._findRowUnderCursor(pxToPt(_top + mmToPx(_t.ext.cy)), true);
}
_t.to.row = foundRow.row;
_t.to.rowOff = pxToMm(_top + mmToPx(_t.ext.cy) - _t.worksheet.getCellTop(_t.to.row, 0));
}
break;
}
_t.flags.anchorUpdated = true;
}
_t.normalizeMetrics = function() {
var width = _t.getWidthFromTo();
var height = _t.getHeightFromTo();
if ( width < 2 )
_t.to.colOff = _t.from.colOff + 4;
if ( height < 2 )
_t.to.rowOff = _t.from.rowOff + 4;
}
// Реальное смещение по высоте
_t.getRealTopOffset = function() {
var val = _t.worksheet.getCellTop(_t.from.row, 0) + mmToPx(_t.from.rowOff);
return Asc.round(val);
}
// Реальное смещение по ширине
_t.getRealLeftOffset = function() {
var val = _t.worksheet.getCellLeft(_t.from.col, 0) + mmToPx(_t.from.colOff);
return Asc.round(val);
}
// Ширина по координатам
_t.getWidthFromTo = function(withoutRound) {
var val = _t.worksheet.getCellLeft(_t.to.col, 0) + mmToPx(_t.to.colOff) - _t.worksheet.getCellLeft(_t.from.col, 0) - mmToPx(_t.from.colOff);
return withoutRound ? val : Asc.round(val);
}
// Высота по координатам
_t.getHeightFromTo = function(withoutRound) {
var val = _t.worksheet.getCellTop(_t.to.row, 0) + mmToPx(_t.to.rowOff) - _t.worksheet.getCellTop(_t.from.row, 0) - mmToPx(_t.from.rowOff);
return withoutRound ? val : Asc.round(val);
}
// Видимая ширина при скролах
_t.getVisibleWidth = function() {
var fvc = _t.worksheet.getCellLeft(_t.worksheet.getFirstVisibleCol(), 0);
var off = _t.getRealLeftOffset() - fvc;
off = (off >= 0) ? 0 : Math.abs(off);
return _t.getWidthFromTo() - off;
}
// Видимая высота при скролах
_t.getVisibleHeight = function() {
var fvr = _t.worksheet.getCellTop(_t.worksheet.getFirstVisibleRow(), 0);
var off = _t.getRealTopOffset() - fvr;
off = (off >= 0) ? 0 : Math.abs(off);
return _t.getHeightFromTo() - off;
}
// Видимое смещение объекта от первой видимой строки
_t.getVisibleTopOffset = function(withHeader) {
var headerRowOff = _t.worksheet.getCellTop(0, 0);
var fvr = _t.worksheet.getCellTop(_t.worksheet.getFirstVisibleRow(), 0);
var off = _t.getRealTopOffset() - fvr;
var off = (off > 0) ? off : 0;
return withHeader ? headerRowOff + off : off;
}
// Видимое смещение объекта от первой видимой колонки
_t.getVisibleLeftOffset = function(withHeader) {
var headerColOff = _t.worksheet.getCellLeft(0, 0);
var fvc = _t.worksheet.getCellLeft(_t.worksheet.getFirstVisibleCol(), 0);
var off = _t.getRealLeftOffset() - fvc;
var off = (off > 0) ? off : 0;
return withHeader ? headerColOff + off : off;
}
// смещение по высоте внутри объекта
_t.getInnerOffsetTop = function() {
var fvr = _t.worksheet.getCellTop(_t.worksheet.getFirstVisibleRow(), 0);
var off = _t.getRealTopOffset() - fvr;
return (off > 0) ? 0 : Asc.round(Math.abs(off) * _t.getHeightCoeff());
}
// смещение по ширине внутри объекта
_t.getInnerOffsetLeft = function() {
var fvc = _t.worksheet.getCellLeft(_t.worksheet.getFirstVisibleCol(), 0);
var off = _t.getRealLeftOffset() - fvc;
return (off > 0) ? 0 : Asc.round(Math.abs(off) * _t.getWidthCoeff());
}
// коэффициент по ширине если несоответствие с реальным размером
_t.getWidthCoeff = function() {
return _t.image.width / _t.getWidthFromTo();
}
// коэффициент по высоте если несоответствие с реальным размером
_t.getHeightCoeff = function() {
return _t.image.height / _t.getHeightFromTo();
}
}
DrawingBase.prototype = {
......@@ -2943,8 +2947,8 @@ function DrawingObjects() {
_this.addImageDrawingObject = function(imageUrl, bPackage, options) {
if (imageUrl && !isViewerMode()) {
if (imageUrl && !isViewerMode()) {
imageLoader.addImage(imageUrl);
var obj = _this.createDrawingObject();
......@@ -3128,8 +3132,8 @@ function DrawingObjects() {
chart.worksheet = worksheet; // Для формул серий
var chartBase64 = chartRender.insertChart(chart, null, bWordChart ? wordChart.width : c_oAscChartDefines.defaultChartWidth, bWordChart ? wordChart.height : c_oAscChartDefines.defaultChartHeight, isNewChart);
if ( !chartBase64 )
return false;
return false;
imageLoader.addImage(chartBase64);
// draw
......@@ -3256,7 +3260,7 @@ function DrawingObjects() {
_this.addGraphicObject = function(x, y, extX, extY, flipH, flipV, presetGeom) {
var obj = _this.createDrawingObject();
obj.graphicObject = new CShape(_this);
obj.graphicObject = new CShape(obj);
obj.graphicObject.initDefault(x, y, extX, extY, flipH, flipV, presetGeom);
aObjects.push(obj);
_this.showDrawingObjects(false);
......@@ -4848,53 +4852,53 @@ function DrawingObjects() {
var tmp = val * ascCvtRatio(0, 3);
return tmp;
}
}
//-----------------------------------------------------------------------------------
// Image loader
//-----------------------------------------------------------------------------------
function ImageLoader() {
var _this = this;
var readyCallback = null;
var ImageObject = function() {
var _t = this;
_t.bReady = false;
_t.image = new Image();
_t.image.onload = function() {
_t.bReady = true;
if ( _this.isReady() && readyCallback )
readyCallback(false, null, false);
}
};
var container = []; // array of ImageObject
_this.isReady = function() {
for (var i = 0; i < container.length; i++) {
if ( !container[i].bReady )
return false;
}
return true;
}
_this.addImage = function(imageSrc) {
if ( imageSrc ) {
var imageObject = new ImageObject();
imageObject.image.src = imageSrc;
container.push(imageObject);
}
}
_this.setReadyCallback = function(callback) {
if ( callback && (typeof(callback) == "function") )
readyCallback = callback;
}
_this.removeReadyCallback = function(callback) {
}
//-----------------------------------------------------------------------------------
// Image loader
//-----------------------------------------------------------------------------------
function ImageLoader() {
var _this = this;
var readyCallback = null;
var ImageObject = function() {
var _t = this;
_t.bReady = false;
_t.image = new Image();
_t.image.onload = function() {
_t.bReady = true;
if ( _this.isReady() && readyCallback )
readyCallback(false, null, false);
}
};
var container = []; // array of ImageObject
_this.isReady = function() {
for (var i = 0; i < container.length; i++) {
if ( !container[i].bReady )
return false;
}
return true;
}
_this.addImage = function(imageSrc) {
if ( imageSrc ) {
var imageObject = new ImageObject();
imageObject.image.src = imageSrc;
container.push(imageObject);
}
}
_this.setReadyCallback = function(callback) {
if ( callback && (typeof(callback) == "function") )
readyCallback = callback;
}
_this.removeReadyCallback = function(callback) {
readyCallback = null;
container = [];
}
container = [];
}
}
\ No newline at end of file
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