Commit 8c274ce3 authored by Dmitry.Vikulov's avatar Dmitry.Vikulov Committed by Alexander.Trofimov

- Поправлен селект объектов

- Исправлен баг с построением диаграммы по одной ячейке
- Уровни для автофигур


git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47977 954022d7-b5bf-4e40-9824-e11837661b57
parent 6d043b6c
......@@ -1105,7 +1105,7 @@ asc_CChart.prototype = {
var cell = _t.range.intervalObject.worksheet.getCell( new CellAddress(i, bbox.c1, 0) );
var value = cell.getValue();
if ( !isNumber(value) )
if ( !isNumber(value) && (value != "") )
cntLeft++;
}
if ( (cntLeft > 0) && (cntLeft >= bbox.r2 - bbox.r1) )
......@@ -1115,7 +1115,7 @@ asc_CChart.prototype = {
var cell = _t.range.intervalObject.worksheet.getCell( new CellAddress(bbox.r1, i, 0) );
var value = cell.getValue();
if ( !isNumber(value) )
if ( !isNumber(value) && (value != "") )
cntTop++;
}
if ( (cntTop > 0) && (cntTop >= bbox.c2 - bbox.c1) )
......@@ -2082,1152 +2082,1159 @@ function DrawingObjects() {
_this.asyncImageLoadedBackgroundEvent = null;
//-----------------------------------------------------------------------------------
// Public methods
// Create drawing
//-----------------------------------------------------------------------------------
_this.init = function(currentSheet) {
userId = api.User.asc_getId();
documentId = api.documentId;
worksheet = currentSheet;
drawingCtx = currentSheet.drawingCtx;
overlayCtx = currentSheet.overlayCtx;
shapeCtx = currentSheet.shapeCtx;
shapeOverlayCtx = currentSheet.shapeOverlayCtx;
trackOverlay = new COverlay();
trackOverlay.init( shapeOverlayCtx.m_oContext, "ws-canvas-overlay", 0, 0, shapeOverlayCtx.m_lWidthPix, shapeOverlayCtx.m_lHeightPix, shapeOverlayCtx.m_dWidthMM, shapeOverlayCtx.m_dHeightMM );
var DrawingBase = function(ws) {
autoShapeTrack = new CAutoshapeTrack();
autoShapeTrack.init( trackOverlay, 0, 0, shapeOverlayCtx.m_lWidthPix, shapeOverlayCtx.m_lHeightPix, shapeOverlayCtx.m_dWidthMM, shapeOverlayCtx.m_dHeightMM );
var _t = this;
_t.worksheet = ws;
_this.drawingDocument = new CDrawingDocument(this);
_this.drawingDocument.AutoShapesTrack = autoShapeTrack;
_this.drawingDocument.TargetHtmlElement = document.getElementById('id_target_cursor');
_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,
FromRowOff: 14,
ToCol: 15,
ToColOff: 16,
ToRow: 17,
ToRowOff: 18,
MoveX: 19,
MoveY: 20,
SizeCoeff: 21,
ChartData: 22,
GraphicObject: 23
};
isViewerMode = function() { return worksheet._trigger("getViewerMode"); };
_t.id = g_oIdCounter ? g_oIdCounter.Get_NewId() : null;
_t.image = new Image();
_t.imageUrl = "";
_t.Type = c_oAscCellAnchorType.cellanchorTwoCell;
_t.Pos = { X: 0, Y: 0 };
aObjects = [];
aImagesSync = [];
aObjectsSync = [];
_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 };
for (var i = 0; currentSheet.model.Drawings && (i < currentSheet.model.Drawings.length); i++) {
_t.chart = new asc_CChart();
_t.graphicObject = null; // CShape or GroupShape
currentSheet.model.Drawings[i].worksheet = worksheet;
var clone = _this.cloneDrawingObject(currentSheet.model.Drawings[i]);
_t.flags = {
selected: false,
anchorUpdated: false,
lockState: c_oAscObjectLockState.No,
currentCursor: null,
transactionState: c_oAscTransactionState.No,
redrawChart: false
};
if ( currentSheet.model.Drawings[i].isChart() ) {
// Свойства
_t.isImage = function() {
return !_t.isChart();
}
_this.calcChartInterval(clone.chart);
clone.chart.worksheet = worksheet;
aObjects.push( clone );
_t.isChart = function() {
return _t.chart.type ? true : false;
}
if ( currentSheet.model.Drawings[i].isImage() ) {
_t.isGraphicObject = function() {
return _t.graphicObject != null;
}
aImagesSync[aImagesSync.length] = currentSheet.model.Drawings[i].imageUrl;
aObjectsSync[aObjectsSync.length] = currentSheet.model.Drawings[i];
_t.getWorkbook = function() {
return (_t.worksheet ? _t.worksheet.model.workbook : null);
}
_t.getCanvasContext = function() {
return _this.drawingDocument.CanvasHitContext;
}
// Загружаем все картинки листа
api.ImageLoader.bIsAsyncLoadDocumentImages = true;
api.ImageLoader.LoadDocumentImages(aImagesSync);
api.ImageLoader.bIsAsyncLoadDocumentImages = false;
// Считаем From/To исходя из graphicObject
_t.setGraphicObjectCoords = function() {
if ( _t.isGraphicObject() ) {
for (var i = 0; i < aObjectsSync.length; i++) {
if ( (_t.graphicObject.x < 0) || (_t.graphicObject.y < 0) || (_t.graphicObject.extX <= 0) || (_t.graphicObject.extY <= 0) )
return;
var clone = aObjectsSync[i];
var image = api.ImageLoader.LoadImage(aImagesSync[i], 1); // Должна быть в мапе
_t.from.col = _t.worksheet._findColUnderCursor( mmToPt(_t.graphicObject.x) /*+ _t.worksheet.getCellLeft(0, 1)*/, true).col;
_t.from.colOff = _t.graphicObject.x /*+ _t.worksheet.getCellLeft(0, 3)*/ - _t.worksheet.getCellLeft(_t.from.col, 3);
if ( image != null ) {
_t.from.row = _t.worksheet._findRowUnderCursor( mmToPt(_t.graphicObject.y) /*+ _t.worksheet.getCellTop(0, 1)*/, true).row;
_t.from.rowOff = _t.graphicObject.y /*+ _t.worksheet.getCellTop(0, 3)*/ - _t.worksheet.getCellTop(_t.from.row, 3);
var headerTop = worksheet.getCellTop(0, 0);
var headerLeft = worksheet.getCellLeft(0, 0);
var _left = _t.getRealLeftOffset();
var _top = _t.getRealTopOffset();
var x = pxToMm(clone.getVisibleLeftOffset() + headerLeft);
var y = pxToMm(clone.getVisibleTopOffset() + headerTop);
var w = pxToMm(clone.getWidthFromTo());
var h = pxToMm(clone.getHeightFromTo());
var foundCol = _t.worksheet._findColUnderCursor(pxToPt(_left + mmToPx(_t.graphicObject.extX)), true);
while (foundCol == null) {
_t.worksheet.expandColsOnScroll(true);
_t.worksheet._trigger("reinitializeScrollX");
foundCol = _t.worksheet._findColUnderCursor(pxToPt(_left + mmToPx(_t.graphicObject.extX)), true);
}
_t.to.col = foundCol.col;
_t.to.colOff = pxToMm(_left + mmToPx(_t.graphicObject.extX) - _t.worksheet.getCellLeft(_t.to.col, 0));
// CImage
clone.graphicObject = new CImage(clone, _this);
clone.graphicObject.initDefault( x, y, w, h, image.src );
aObjects.push(clone);
var foundRow = _t.worksheet._findRowUnderCursor(pxToPt(_top + mmToPx(_t.graphicObject.extY)), true);
while (foundRow == null) {
_t.worksheet.expandRowsOnScroll(true);
_t.worksheet._trigger("reinitializeScrollY");
foundRow = _t.worksheet._findRowUnderCursor(pxToPt(_top + mmToPx(_t.graphicObject.extY)), true);
}
_t.to.row = foundRow.row;
_t.to.rowOff = pxToMm(_top + mmToPx(_t.graphicObject.extY) - _t.worksheet.getCellTop(_t.to.row, 0));
}
}
lastObjectIndex = aObjects.length;
// Проверяет выход за границы
_t.canDraw = function() {
var result = true;
// Upload event
if (window.addEventListener) {
window.addEventListener("message", this._uploadMessage, false);
if ( (_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;
}
else {
if (window.attachEvent) {
window.attachEvent("onmessage", this._uploadMessage);
}
}
}
_this.getOverlay = function() {
return trackOverlay;
};
return result;
}
_this.OnUpdateOverlay = function() {
/*if (this.IsUpdateOverlayOnlyEnd)
_t.updateAnchorPosition = function() {
switch (_t.Type) {
case c_oAscCellAnchorType.cellanchorOneCell:
{
this.IsUpdateOverlayOnEndCheck = true;
return false;
} */
//console.log("update_overlay");
var overlay = trackOverlay;
//if (!overlay.m_bIsShow)
// return;
var _left = _t.getRealLeftOffset();
var _top = _t.getRealTopOffset();
overlay.Clear();
var ctx = overlay.m_oContext;
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 drDoc = this.drawingDocument;
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;
/* if (drDoc.m_bIsSearching)
case c_oAscCellAnchorType.cellanchorAbsolute:
{
ctx.fillStyle = "rgba(255,200,0,1)";
ctx.beginPath();
if ( _t.Pos.X < 0 )
_t.Pos.X = 0;
if ( _t.Pos.Y < 0 )
_t.Pos.Y = 0;
var drDoc = this.drawingDocument;
for (var i = drDoc.m_lDrawingFirst; i <= drDoc.m_lDrawingEnd; i++)
{
var drawPage = drDoc.m_arrPages[i].drawingPage;
drDoc.m_arrPages[i].pageIndex = i;
drDoc.m_arrPages[i].DrawSearch(overlay, drawPage.left, drawPage.top, drawPage.right - drawPage.left, drawPage.bottom - drawPage.top, drDoc);
}
_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));
ctx.globalAlpha = 0.5;
ctx.fill();
ctx.beginPath();
ctx.globalAlpha = 1.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));
if (null != drDoc.CurrentSearchNavi)
{
ctx.globalAlpha = 0.2;
ctx.fillStyle = "rgba(51,102,204,255)";
var _left = _t.getRealLeftOffset();
var _top = _t.getRealTopOffset();
var places = drDoc.CurrentSearchNavi.Place;
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));
switch ((drDoc.CurrentSearchNavi.Type & 0xFF))
{
case search_HdrFtr_All:
case search_HdrFtr_All_no_First:
case search_HdrFtr_First:
case search_HdrFtr_Even:
case search_HdrFtr_Odd:
case search_HdrFtr_Odd_no_First:
{
var _page_num = drDoc.CurrentSearchNavi.PageNum;
for (var i = 0; i < places.length; i++)
{
var place = places[i];
if (drDoc.m_lDrawingFirst <= _page_num && _page_num <= drDoc.m_lDrawingEnd)
{
var drawPage = drDoc.m_arrPages[_page_num].drawingPage;
drDoc.m_arrPages[place.PageNum].DrawSearchCur1(overlay, drawPage.left, drawPage.top, drawPage.right - drawPage.left, drawPage.bottom - drawPage.top, place);
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;
}
default:
{
for (var i = 0; i < places.length; i++)
{
var place = places[i];
if (drDoc.m_lDrawingFirst <= place.PageNum && place.PageNum <= drDoc.m_lDrawingEnd)
{
var drawPage = drDoc.m_arrPages[place.PageNum].drawingPage;
drDoc.m_arrPages[place.PageNum].DrawSearchCur1(overlay, drawPage.left, drawPage.top, drawPage.right - drawPage.left, drawPage.bottom - drawPage.top, place);
_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;
}
break;
// Реальное смещение по высоте
_t.getRealTopOffset = function() {
var val = _t.worksheet.getCellTop(_t.from.row, 0) + mmToPx(_t.from.rowOff);
return window["Asc"].round(val);
}
// Реальное смещение по ширине
_t.getRealLeftOffset = function() {
var val = _t.worksheet.getCellLeft(_t.from.col, 0) + mmToPx(_t.from.colOff);
return window["Asc"].round(val);
}
ctx.fill();
ctx.globalAlpha = 1.0;
// Ширина по координатам
_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 : window["Asc"].round(val);
}
} */
if (null == drDoc.m_oDocumentRenderer)
{
if (drDoc.m_bIsSelection)
{
if (drDoc.m_bIsSelection )
{
// Высота по координатам
_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 : window["Asc"].round(val);
}
overlay.m_oControl.HtmlElement.style.display = "block";
// Видимая ширина при скролах
_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;
}
if (null == overlay.m_oContext)
overlay.m_oContext = overlay.m_oControl.HtmlElement.getContext('2d');
// Видимая высота при скролах
_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;
}
drDoc.private_StartDrawSelection(overlay);
// Видимое смещение объекта от первой видимой строки
_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;
}
this.controller.drawTextSelection();
drDoc.private_EndDrawSelection();
// Видимое смещение объекта от первой видимой колонки
_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 : window["Asc"].round(Math.abs(off) * _t.getHeightCoeff());
}
ctx.globalAlpha = 1.0;
// смещение по ширине внутри объекта
_t.getInnerOffsetLeft = function() {
var fvc = _t.worksheet.getCellLeft(_t.worksheet.getFirstVisibleCol(), 0);
var off = _t.getRealLeftOffset() - fvc;
return (off > 0) ? 0 : window["Asc"].round(Math.abs(off) * _t.getWidthCoeff());
}
this.controller.drawSelection(drDoc);
if (_this.controller.needUpdateOverlay())
{
overlay.Show();
this.drawingDocument.AutoShapesTrack.PageIndex = -1;
this.controller.drawTracks(this.m_oDrawingDocument.AutoShapesTrack);
this.drawingDocument.AutoShapesTrack.CorrectOverlayBounds();
// коэффициент по ширине если несоответствие с реальным размером
_t.getWidthCoeff = function() {
return _t.image.width / _t.getWidthFromTo();
}
// коэффициент по высоте если несоответствие с реальным размером
_t.getHeightCoeff = function() {
return _t.image.height / _t.getHeightFromTo();
}
else
{
ctx.fillStyle = "rgba(51,102,204,255)";
ctx.beginPath();
for (var i = drDoc.m_lDrawingFirst; i <= drDoc.m_lDrawingEnd; i++)
{
var drawPage = drDoc.m_arrPages[i].drawingPage;
drDoc.m_oDocumentRenderer.DrawSelection(i, overlay, drawPage.left, drawPage.top, drawPage.right - drawPage.left, drawPage.bottom - drawPage.top);
//if ( g_oTableId )
// g_oTableId.Add( _t, _t.id );
}
ctx.globalAlpha = 0.2;
ctx.fill();
ctx.beginPath();
ctx.globalAlpha = 1.0;
}
DrawingBase.prototype = {
getObjectType: function() {
return CLASS_TYPE_DRAWING_BASE;
},
getType: function() {
return UndoRedoDataTypes.DrawingObjectData;
},
getProperties: function() {
return this.Properties;
},
getProperty: function(nType) {
switch (nType) {
case this.Properties.Id: return this.id; break;
case this.Properties.Type: return this.Type; break;
case this.Properties.PosX: return this.Pos.X; break;
case this.Properties.PosY: return this.Pos.Y; break;
case this.Properties.ExtCx: return this.ext.cx; break;
case this.Properties.ExtCy: return this.ext.cy; break;
case this.Properties.ImageSrc: return this.image.src; break;
case this.Properties.FlagCurrentCursor: return this.flags.currentCursor; break;
case this.Properties.FlagsTransactionState: return this.flags.transactionState; break;
case this.Properties.ImageUrl: return this.imageUrl; break;
case this.Properties.FromCol: return this.from.col; break;
case this.Properties.FromColOff: return this.from.colOff; break;
case this.Properties.FromRow: return this.from.row; break;
case this.Properties.FromRowOff: return this.from.rowOff; break;
case this.Properties.ToCol: return this.to.col; break;
case this.Properties.ToColOff: return this.to.colOff; break;
case this.Properties.ToRow: return this.to.row; break;
case this.Properties.ToRowOff: return this.to.rowOff; break;
return true;
};
case this.Properties.MoveX: return this.move.x; break;
case this.Properties.MoveY: return this.move.y; break;
_this.changeZoom = function(factor) {
case this.Properties.SizeCoeff: return this.size.coeff; break;
case this.Properties.ChartData: return this.chart; break;
case this.Properties.GraphicObject: return this.graphicObject; break;
}
},
_this.getWorkbook = function() {
return (worksheet ? worksheet.model.workbook : null);
}
setProperty: function(nType, value) {
switch (nType) {
case this.Properties.Id: this.id = value; break;
case this.Properties.Type: this.Type = value; break;
case this.Properties.PosX: this.Pos.X = value; break;
case this.Properties.PosY: this.Pos.Y = value; break;
case this.Properties.ExtCx: this.ext.cx = value; break;
case this.Properties.ExtCy: this.ext.cy = value; break;
_this.getCanvasContext = function() {
return _this.drawingDocument.CanvasHitContext;
}
case this.Properties.ImageSrc: this.image.src = value; break;
_this.getDrawingObjects = function() {
return aObjects;
}
case this.Properties.FlagCurrentCursor: this.flags.currentCursor = value; break;
case this.Properties.FlagsTransactionState: this.flags.transactionState = value; break;
_this.getWorksheet = function() {
return worksheet;
}
case this.Properties.ImageUrl: this.imageUrl = value; break;
_this.initGlobalDrawingPointer = function() {
DrawingObject = DrawingBase;
DrawingObjectLayer = DrawingLayer;
}
case this.Properties.FromCol: this.from.col = value; break;
case this.Properties.FromColOff: this.from.colOff = value; break;
case this.Properties.FromRow: this.from.row = value; break;
case this.Properties.FromRowOff: this.from.rowOff = value; break;
_this._uploadMessage = function(event) {
if ( null != event && null != event.data ) {
case this.Properties.ToCol: this.to.col = value; break;
case this.Properties.ToColOff: this.to.colOff = value; break;
case this.Properties.ToRow: this.to.row = value; break;
case this.Properties.ToRowOff: this.to.rowOff = value; break;
var data = JSON.parse(event.data);
if ( null != data && null != data.type )
{
if ( PostMessageType.UploadImage == data.type ) {
if(c_oAscServerError.NoError == data.error) {
var sheetId = null;
if(null != data.input)
sheetId = data.input.sheetId;
var url = data.url;
case this.Properties.MoveX: this.move.x = value; break;
case this.Properties.MoveY: this.move.y = value; break;
if (sheetId == worksheet.model.getId())
_this.addImageDrawingObject(url, false, null);
else
worksheet.model.workbook.handlers.trigger("asc_onEndAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadImage);
}
else {
worksheet.model.workbook.handlers.trigger("asc_onError", _mapAscServerErrorToAscError(data.error), c_oAscError.Level.NoCritical);
worksheet.model.workbook.handlers.trigger("asc_onEndAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadImage);
}
case this.Properties.SizeCoeff: this.size.coeff = value; break;
case this.Properties.ChartData: this.chart = value; break;
case this.Properties.GraphicObject: this.graphicObject = value; break;
}
}
}
//-----------------------------------------------------------------------------------
// Create drawing layer
//-----------------------------------------------------------------------------------
var DrawingLayer = function() {
this.Properties = {
aLayerBefore: 1,
aLayerAfter: 2
}
_this.clearDrawingObjects = function() {
worksheet._clean();
worksheet._drawCorner();
worksheet._drawColumnHeaders();
worksheet._drawRowHeaders();
worksheet._drawGrid();
worksheet._drawCells();
worksheet._drawCellsBorders();
worksheet.cellCommentator.drawCommentCells(false);
worksheet.autoFilters.drawAutoF(worksheet);
this.aLayerBefore = [];
this.aLayerAfter = [];
}
_this.raiseLayerDrawingObjects = function(bSelect) {
// слой c объектами должен быть выше селекта
for (var i = 0; i < _this.countDrawingObjects(); i++) {
var obj = aObjects[i];
var width = obj.getVisibleWidth();
var height = obj.getVisibleHeight();
if ( (width > 0) && (height > 0) ) {
DrawingLayer.prototype = {
overlayCtx.clearRect(pxToPt(obj.getVisibleLeftOffset(true)), pxToPt(obj.getVisibleTopOffset(true)),
pxToPt(obj.getVisibleWidth()), pxToPt(obj.getVisibleHeight()));
getType: function() {
return UndoRedoDataTypes.DrawingObjectLayer;
},
if ( bSelect ) {
if (obj.flags.selected)
_this.selectDrawingObject(i);
getProperties: function() {
return this.Properties;
},
if (obj.flags.lockState != c_oAscObjectLockState.No)
_this.selectLockedDrawingObject(obj.id, obj.flags.lockState);
}
}
}
getProperty: function(nType) {
switch (nType) {
case this.Properties.aLayerBefore: return this.aLayerBefore; break;
case this.Properties.aLayerAfter: return this.aLayerAfter; break;
}
},
_this.countDrawingObjects = function() {
return aObjects ? aObjects.length : 0;
setProperty: function(nType, value) {
switch (nType) {
case this.Properties.aLayerBefore: this.aLayerBefore = value; break;
case this.Properties.aLayerAfter: this.aLayerAfter = value; break;
}
}
_this.checkDrawingObjectIndex = function(index) {
if (_this.countDrawingObjects() && (index >= 0) && (index < _this.countDrawingObjects()))
return true;
else
return false;
}
//-----------------------------------------------------------------------------------
// Optimization of drawing
// Constructor
//-----------------------------------------------------------------------------------
_this.needDrawingObjects = function() {
var result = false;
var fvr = worksheet.getFirstVisibleRow();
var fvc = worksheet.getFirstVisibleCol();
for (var i = 0; i < _this.countDrawingObjects(); i++) {
if ((fvr < aObjects[i].to.row + 1) && (fvc < aObjects[i].to.col + 1)) {
result = true;
break;
}
}
return result;
}
_this.createDrawingObject = function() {
_this.showOverlayDrawingObject = function(index) {
if (_this.checkDrawingObjectIndex(index)) {
var obj = aObjects[index];
if ( !obj.image.complete ) // complete - дополнительная проверка в случае base64
return;
var drawing = new DrawingBase(worksheet);
if (obj.image.width && obj.image.height) {
var sWidth = obj.image.width - obj.getInnerOffsetLeft();
var sHeight = obj.image.height - obj.getInnerOffsetTop();
drawing.chart.range.interval = function() {
var result = "";
if (worksheet) {
var selectedRange = worksheet.getSelectedRange();
if (selectedRange) {
var box = selectedRange.getBBox0();
var startCell = new CellAddress(box.r1, box.c1, 0);
var endCell = new CellAddress(box.r2, box.c2, 0);
// Проверка для IE
var dWidth = obj.getVisibleWidth();
var dHeight = obj.getVisibleHeight();
if ((dWidth <= 0) || (dHeight <= 0))
return;
if (startCell && endCell) {
var wsName = worksheet.model.sName;
if ( !rx_test_ws_name.test(wsName) )
wsName = "'" + wsName + "'";
overlayCtx.drawImage(obj.image,
// обрезаем
pxToPt(obj.getInnerOffsetLeft()), pxToPt(obj.getInnerOffsetTop()),
pxToPt(sWidth), pxToPt(sHeight),
// вставляем
pxToPt(obj.getVisibleLeftOffset(true)), pxToPt(obj.getVisibleTopOffset(true)),
pxToPt(dWidth), pxToPt(dHeight));
if (startCell.getID() == endCell.getID())
result = wsName + "!" + startCell.getID();
else
result = wsName + "!" + startCell.getID() + ":" + endCell.getID();
}
}
}
return result;
}();
_this.showDrawingObjects = function(clearCanvas, printOptions, bUpdateCharts) {
drawing.chart.range.intervalObject = function() {
return worksheet ? worksheet.getSelectedRange() : null;
}();
/*********** Print Options ***************
printOptions : {
ctx,
margin : {
left: 0, // pt
right: 0, // pt
top: 0, // pt
button: 0 // pt
}
return drawing;
}
*****************************************/
if (!_this.countDrawingObjects())
return;
_this.cloneDrawingObject = function(obj) {
worksheet.model.Drawings = aObjects;
var copyObject = _this.createDrawingObject();
if (drawingCtx && _this.needDrawingObjects()) {
copyObject.worksheet = obj.worksheet;
copyObject.id = obj.id;
// всё чистим
if (clearCanvas) {
_this.clearDrawingObjects();
}
copyObject.Type = obj.Type;
copyObject.Pos.X = obj.Pos.X;
copyObject.Pos.Y = obj.Pos.Y;
copyObject.ext.cx = obj.ext.cx;
copyObject.ext.cy = obj.ext.cy;
if ( !imageLoader.isReady() ) {
//console.log("imageLoader - False");
imageLoader.setReadyCallback(_this.showDrawingObjects);
}
else {
//console.log("imageLoader - Ok");
imageLoader.removeReadyCallback();
}
var img = new Image();
img.src = obj.image.src;
copyObject.image = img;
for (var i = 0; i < _this.countDrawingObjects(); i++) {
copyObject.flags.currentCursor = obj.flags.currentCursor;
copyObject.flags.transactionState = obj.flags.transactionState;
copyObject.flags.redrawChart = obj.flags.redrawChart;
var index = i;
var obj = aObjects[i];
copyObject.imageUrl = obj.imageUrl;
copyObject.from.col = obj.from.col;
copyObject.from.colOff = obj.from.colOff;
copyObject.from.row = obj.from.row;
copyObject.from.rowOff = obj.from.rowOff;
copyObject.to.col = obj.to.col;
copyObject.to.colOff = obj.to.colOff;
copyObject.to.row = obj.to.row;
copyObject.to.rowOff = obj.to.rowOff;
// Shape render
if ( obj.isGraphicObject() ) {
obj.graphicObject.draw(shapeCtx);
continue;
}
copyObject.move.x = obj.move.x;
copyObject.move.y = obj.move.y;
copyObject.size.coeff = obj.size.coeff;
obj.normalizeMetrics();
copyObject.chart = new asc_CChart(obj.chart);
copyObject.graphicObject = obj.graphicObject;
copyObject.chart.worksheet = obj.chart.worksheet;
obj.size.coeff = obj.getHeightFromTo(true) / obj.getWidthFromTo(true);
return copyObject;
}
if (!obj.flags.anchorUpdated)
obj.updateAnchorPosition();
//-----------------------------------------------------------------------------------
// Public methods
//-----------------------------------------------------------------------------------
// History
if (obj.move.inAction && undoRedoObject && (undoRedoObject.id == obj.id)) {
_this.init = function(currentSheet) {
History.Create_NewPoint();
History.StartTransaction();
userId = api.User.asc_getId();
documentId = api.documentId;
worksheet = currentSheet;
undoRedoObject.flags.transactionState = c_oAscTransactionState.Start;
History.Add(g_oUndoRedoDrawingObject, historyitem_DrawingObject_Edit, worksheet.model.getId(), null, undoRedoObject);
undoRedoObject = null;
drawingCtx = currentSheet.drawingCtx;
overlayCtx = currentSheet.overlayCtx;
shapeCtx = currentSheet.shapeCtx;
shapeOverlayCtx = currentSheet.shapeOverlayCtx;
History.Create_NewPoint();
var urObj = _this.cloneDrawingObject(obj);
urObj.flags.transactionState = c_oAscTransactionState.Stop;
History.Add(g_oUndoRedoDrawingObject, historyitem_DrawingObject_Edit, worksheet.model.getId(), null, urObj);
trackOverlay = new COverlay();
trackOverlay.init( shapeOverlayCtx.m_oContext, "ws-canvas-overlay", 0, 0, shapeOverlayCtx.m_lWidthPix, shapeOverlayCtx.m_lHeightPix, shapeOverlayCtx.m_dWidthMM, shapeOverlayCtx.m_dHeightMM );
History.EndTransaction();
}
autoShapeTrack = new CAutoshapeTrack();
autoShapeTrack.init( trackOverlay, 0, 0, shapeOverlayCtx.m_lWidthPix, shapeOverlayCtx.m_lHeightPix, shapeOverlayCtx.m_dWidthMM, shapeOverlayCtx.m_dHeightMM );
var srcForPrint;
_this.drawingDocument = new CDrawingDocument(this);
_this.drawingDocument.AutoShapesTrack = autoShapeTrack;
_this.drawingDocument.TargetHtmlElement = document.getElementById('id_target_cursor');
// Выход за границы
while (worksheet.nColsCount < obj.to.col + 1) {
worksheet.expandColsOnScroll(true);
}
while (worksheet.nRowsCount < obj.to.row + 1) {
worksheet.expandRowsOnScroll(true);
}
isViewerMode = function() { return worksheet._trigger("getViewerMode"); };
if ( obj.isChart() && (obj.flags.redrawChart || bUpdateCharts) ) {
if ( !obj.chart.range.intervalObject )
_this.intervalToIntervalObject(obj.chart);
aObjects = [];
aImagesSync = [];
aObjectsSync = [];
obj.chart.rebuildSeries();
obj.chart.worksheet = worksheet;
var chartBase64 = chartRender.insertChart(obj.chart, null, obj.getWidthFromTo(), obj.getHeightFromTo());
if ( !chartBase64 )
continue;
for (var i = 0; currentSheet.model.Drawings && (i < currentSheet.model.Drawings.length); i++) {
imageLoader.addImage(chartBase64);
imageLoader.setReadyCallback(_this.showDrawingObjects);
currentSheet.model.Drawings[i].worksheet = worksheet;
var clone = _this.cloneDrawingObject(currentSheet.model.Drawings[i]);
obj.image.onload = function() {
obj.flags.currentCursor = null;
}
if ( currentSheet.model.Drawings[i].isChart() ) {
obj.image.src = chartBase64;
obj.flags.redrawChart = false;
continue;
_this.calcChartInterval(clone.chart);
clone.chart.worksheet = worksheet;
aObjects.push( clone );
}
if ( !obj.canDraw() )
continue;
var sWidth = obj.image.width - obj.getInnerOffsetLeft();
var sHeight = obj.image.height - obj.getInnerOffsetTop();
if ( currentSheet.model.Drawings[i].isImage() ) {
if ( printOptions ) {
if ( obj.isChart() ) {
srcForPrint = obj.image.src; // base64
aImagesSync[aImagesSync.length] = currentSheet.model.Drawings[i].imageUrl;
aObjectsSync[aObjectsSync.length] = currentSheet.model.Drawings[i];
}
else {
srcForPrint = obj.imageUrl;
}
var marginRight = 0;
if (worksheet.getCellLeft(worksheet.getLastVisibleCol(), 0) + worksheet.getColumnWidth(worksheet.getLastVisibleCol()) < obj.getRealLeftOffset() + obj.getVisibleWidth())
marginRight = printOptions.margin.right;
// Загружаем все картинки листа
api.ImageLoader.bIsAsyncLoadDocumentImages = true;
api.ImageLoader.LoadDocumentImages(aImagesSync);
api.ImageLoader.bIsAsyncLoadDocumentImages = false;
printOptions.ctx.drawImage(srcForPrint,
// обрезаем
pxToPt(obj.getInnerOffsetLeft()), pxToPt(obj.getInnerOffsetTop()),
pxToPt(sWidth) - marginRight, pxToPt(sHeight),
// вставляем
pxToPt(obj.getVisibleLeftOffset(true)) + printOptions.margin.left, pxToPt(obj.getVisibleTopOffset(true)) + printOptions.margin.top,
pxToPt(obj.getVisibleWidth()), pxToPt(obj.getVisibleHeight()),
pxToPt(obj.image.width), pxToPt(obj.image.height));
}
else {
if ( !obj.image.width || !obj.image.height )
continue;
for (var i = 0; i < aObjectsSync.length; i++) {
// Проверка для IE
var dWidth = obj.getVisibleWidth();
var dHeight = obj.getVisibleHeight();
if ( (dWidth <= 0) || (dHeight <= 0) )
continue;
var clone = aObjectsSync[i];
var image = api.ImageLoader.LoadImage(aImagesSync[i], 1); // Должна быть в мапе
drawingCtx.drawImage(obj.image,
// обрезаем
pxToPt(obj.getInnerOffsetLeft()), pxToPt(obj.getInnerOffsetTop()),
pxToPt(sWidth), pxToPt(sHeight),
// вставляем
pxToPt(obj.getVisibleLeftOffset(true)), pxToPt(obj.getVisibleTopOffset(true)),
pxToPt(dWidth), pxToPt(dHeight));
}
if ( image != null ) {
if ( obj.flags.selected && !printOptions )
_this.selectDrawingObject(index);
if ( obj.flags.lockState != c_oAscObjectLockState.No )
_this.selectLockedDrawingObject(obj.id, obj.flags.lockState);
var headerTop = worksheet.getCellTop(0, 0);
var headerLeft = worksheet.getCellLeft(0, 0);
obj.move.inAction = false;
var x = pxToMm(clone.getVisibleLeftOffset() + headerLeft);
var y = pxToMm(clone.getVisibleTopOffset() + headerTop);
var w = pxToMm(clone.getWidthFromTo());
var h = pxToMm(clone.getHeightFromTo());
// CImage
clone.graphicObject = new CImage(clone, _this);
clone.graphicObject.initDefault( x, y, w, h, image.src );
aObjects.push(clone);
}
}
if ( !printOptions ) {
worksheet._drawCollaborativeElements();
if ( _this.getSelectedDrawingObjectIndex() < 0 ) {
worksheet.cleanSelection();
worksheet._drawSelectionRange();
_this.raiseLayerDrawingObjects(true);
lastObjectIndex = aObjects.length;
// Upload event
if (window.addEventListener) {
window.addEventListener("message", this._uploadMessage, false);
}
else {
if (window.attachEvent) {
window.attachEvent("onmessage", this._uploadMessage);
}
}
_this.showOverlayGraphicObjects = function() {
shapeOverlayCtx.put_GlobalAlpha(true, 0.5);
shapeOverlayCtx.m_oContext.clearRect(0, 0, shapeOverlayCtx.m_lWidthPix, shapeOverlayCtx.m_lHeightPix);
_this.controller.drawTracks(shapeOverlayCtx);
shapeOverlayCtx.put_GlobalAlpha(true, 1);
}
_this.showOverlayDrawingObjects = function() {
_this.getOverlay = function() {
return trackOverlay;
};
if (overlayCtx) {
_this.OnUpdateOverlay = function() {
/*if (this.IsUpdateOverlayOnlyEnd)
{
this.IsUpdateOverlayOnEndCheck = true;
return false;
} */
//console.log("update_overlay");
var overlay = trackOverlay;
//if (!overlay.m_bIsShow)
// return;
overlayCtx.clear();
var index = _this.getSelectedDrawingObjectIndex();
var obj = aObjects[index];
if (!obj.flags.currentCursor)
return;
overlay.Clear();
var ctx = overlay.m_oContext;
// выход за границы
if (!obj.canDraw())
return;
var drDoc = this.drawingDocument;
var sWidth = obj.image.width - obj.getInnerOffsetLeft();
var sHeight = obj.image.height - obj.getInnerOffsetTop();
/* if (drDoc.m_bIsSearching)
{
ctx.fillStyle = "rgba(255,200,0,1)";
ctx.beginPath();
setCanvasZIndex(overlayCtx.ctx, 0.5);
var drDoc = this.drawingDocument;
for (var i = drDoc.m_lDrawingFirst; i <= drDoc.m_lDrawingEnd; i++)
{
var drawPage = drDoc.m_arrPages[i].drawingPage;
drDoc.m_arrPages[i].pageIndex = i;
drDoc.m_arrPages[i].DrawSearch(overlay, drawPage.left, drawPage.top, drawPage.right - drawPage.left, drawPage.bottom - drawPage.top, drDoc);
}
if (obj.isImage()) {
ctx.globalAlpha = 0.5;
ctx.fill();
ctx.beginPath();
ctx.globalAlpha = 1.0;
// Проверка для IE
var dWidth = obj.getVisibleWidth();
var dHeight = obj.getVisibleHeight();
if ((dWidth <= 0) || (dHeight <= 0))
return;
if (null != drDoc.CurrentSearchNavi)
{
ctx.globalAlpha = 0.2;
ctx.fillStyle = "rgba(51,102,204,255)";
overlayCtx.drawImage(obj.image,
/* обрезаем */pxToPt(obj.getInnerOffsetLeft()), pxToPt(obj.getInnerOffsetTop()),
pxToPt(sWidth), pxToPt(sHeight),
var places = drDoc.CurrentSearchNavi.Place;
/* вставляем */pxToPt(obj.getVisibleLeftOffset(true)), pxToPt(obj.getVisibleTopOffset(true)),
pxToPt(dWidth), pxToPt(dHeight));
switch ((drDoc.CurrentSearchNavi.Type & 0xFF))
{
case search_HdrFtr_All:
case search_HdrFtr_All_no_First:
case search_HdrFtr_First:
case search_HdrFtr_Even:
case search_HdrFtr_Odd:
case search_HdrFtr_Odd_no_First:
{
var _page_num = drDoc.CurrentSearchNavi.PageNum;
for (var i = 0; i < places.length; i++)
{
var place = places[i];
if (drDoc.m_lDrawingFirst <= _page_num && _page_num <= drDoc.m_lDrawingEnd)
{
var drawPage = drDoc.m_arrPages[_page_num].drawingPage;
drDoc.m_arrPages[place.PageNum].DrawSearchCur1(overlay, drawPage.left, drawPage.top, drawPage.right - drawPage.left, drawPage.bottom - drawPage.top, place);
}
else {
overlayCtx.beginPath();
overlayCtx.rect(pxToPt(obj.getVisibleLeftOffset(true)), pxToPt(obj.getVisibleTopOffset(true)), pxToPt(obj.getVisibleWidth()), pxToPt(obj.getVisibleHeight()));
overlayCtx.setLineWidth(1);
overlayCtx.setStrokeStyle("#000000");
overlayCtx.setFillStyle("#ffffff");
overlayCtx.fillRect(pxToPt(obj.getVisibleLeftOffset(true)), pxToPt(obj.getVisibleTopOffset(true)), pxToPt(obj.getVisibleWidth()), pxToPt(obj.getVisibleHeight()));
overlayCtx.stroke();
}
break;
}
default:
{
for (var i = 0; i < places.length; i++)
{
var place = places[i];
if (drDoc.m_lDrawingFirst <= place.PageNum && place.PageNum <= drDoc.m_lDrawingEnd)
{
var drawPage = drDoc.m_arrPages[place.PageNum].drawingPage;
drDoc.m_arrPages[place.PageNum].DrawSearchCur1(overlay, drawPage.left, drawPage.top, drawPage.right - drawPage.left, drawPage.bottom - drawPage.top, place);
}
}
break;
}
_this.getDrawingAreaMetrics = function() {
/*
* Объект, определяющий max колонку и строчку для отрисовки объектов листа
*/
var metrics = {
maxCol: 0,
maxRow: 0
}
for (var i = 0; i < _this.countDrawingObjects(); i++) {
if (aObjects[i].to.col >= metrics.maxCol)
metrics.maxCol = aObjects[i].to.col + 1; // учитываем colOff
if (aObjects[i].to.row >= metrics.maxRow)
metrics.maxRow = aObjects[i].to.row + 1; // учитываем rowOff
ctx.fill();
ctx.globalAlpha = 1.0;
}
} */
return metrics;
}
if (null == drDoc.m_oDocumentRenderer)
{
if (drDoc.m_bIsSelection)
{
if (drDoc.m_bIsSelection )
{
//-----------------------------------------------------------------------------------
// Create drawing
//-----------------------------------------------------------------------------------
overlay.m_oControl.HtmlElement.style.display = "block";
var DrawingBase = function(ws) {
if (null == overlay.m_oContext)
overlay.m_oContext = overlay.m_oControl.HtmlElement.getContext('2d');
}
drDoc.private_StartDrawSelection(overlay);
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,
ImageUrl: 10,
FromCol: 11,
FromColOff: 12,
FromRow: 13,
FromRowOff: 14,
ToCol: 15,
ToColOff: 16,
ToRow: 17,
ToRowOff: 18,
MoveX: 19,
MoveY: 20,
SizeCoeff: 21,
ChartData: 22,
GraphicObject: 23
};
this.controller.drawTextSelection();
drDoc.private_EndDrawSelection();
_t.id = g_oIdCounter ? g_oIdCounter.Get_NewId() : 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 };
ctx.globalAlpha = 1.0;
_t.chart = new asc_CChart();
_t.graphicObject = null; // CShape or GroupShape
this.controller.drawSelection(drDoc);
if (_this.controller.needUpdateOverlay())
{
overlay.Show();
this.drawingDocument.AutoShapesTrack.PageIndex = -1;
this.controller.drawTracks(this.m_oDrawingDocument.AutoShapesTrack);
this.drawingDocument.AutoShapesTrack.CorrectOverlayBounds();
}
_t.flags = {
selected: false,
anchorUpdated: false,
lockState: c_oAscObjectLockState.No,
currentCursor: null,
transactionState: c_oAscTransactionState.No,
redrawChart: false
};
}
else
{
ctx.fillStyle = "rgba(51,102,204,255)";
ctx.beginPath();
// Свойства
_t.isImage = function() {
return !_t.isChart();
for (var i = drDoc.m_lDrawingFirst; i <= drDoc.m_lDrawingEnd; i++)
{
var drawPage = drDoc.m_arrPages[i].drawingPage;
drDoc.m_oDocumentRenderer.DrawSelection(i, overlay, drawPage.left, drawPage.top, drawPage.right - drawPage.left, drawPage.bottom - drawPage.top);
}
_t.isChart = function() {
return _t.chart.type ? true : false;
ctx.globalAlpha = 0.2;
ctx.fill();
ctx.beginPath();
ctx.globalAlpha = 1.0;
}
_t.isGraphicObject = function() {
return _t.graphicObject != null;
return true;
};
_this.changeZoom = function(factor) {
}
_t.getWorkbook = function() {
return (_t.worksheet ? _t.worksheet.model.workbook : null);
_this.getWorkbook = function() {
return (worksheet ? worksheet.model.workbook : null);
}
_t.getCanvasContext = function() {
_this.getCanvasContext = function() {
return _this.drawingDocument.CanvasHitContext;
}
// Считаем From/To исходя из graphicObject
_t.setGraphicObjectCoords = function() {
if ( _t.isGraphicObject() ) {
if ( (_t.graphicObject.x < 0) || (_t.graphicObject.y < 0) || (_t.graphicObject.extX <= 0) || (_t.graphicObject.extY <= 0) )
return;
_t.from.col = _t.worksheet._findColUnderCursor( mmToPt(_t.graphicObject.x) /*+ _t.worksheet.getCellLeft(0, 1)*/, true).col;
_t.from.colOff = _t.graphicObject.x /*+ _t.worksheet.getCellLeft(0, 3)*/ - _t.worksheet.getCellLeft(_t.from.col, 3);
_t.from.row = _t.worksheet._findRowUnderCursor( mmToPt(_t.graphicObject.y) /*+ _t.worksheet.getCellTop(0, 1)*/, true).row;
_t.from.rowOff = _t.graphicObject.y /*+ _t.worksheet.getCellTop(0, 3)*/ - _t.worksheet.getCellTop(_t.from.row, 3);
var _left = _t.getRealLeftOffset();
var _top = _t.getRealTopOffset();
var foundCol = _t.worksheet._findColUnderCursor(pxToPt(_left + mmToPx(_t.graphicObject.extX)), true);
while (foundCol == null) {
_t.worksheet.expandColsOnScroll(true);
_t.worksheet._trigger("reinitializeScrollX");
foundCol = _t.worksheet._findColUnderCursor(pxToPt(_left + mmToPx(_t.graphicObject.extX)), true);
_this.getDrawingObjects = function() {
return aObjects;
}
_t.to.col = foundCol.col;
_t.to.colOff = pxToMm(_left + mmToPx(_t.graphicObject.extX) - _t.worksheet.getCellLeft(_t.to.col, 0));
var foundRow = _t.worksheet._findRowUnderCursor(pxToPt(_top + mmToPx(_t.graphicObject.extY)), true);
while (foundRow == null) {
_t.worksheet.expandRowsOnScroll(true);
_t.worksheet._trigger("reinitializeScrollY");
foundRow = _t.worksheet._findRowUnderCursor(pxToPt(_top + mmToPx(_t.graphicObject.extY)), true);
}
_t.to.row = foundRow.row;
_t.to.rowOff = pxToMm(_top + mmToPx(_t.graphicObject.extY) - _t.worksheet.getCellTop(_t.to.row, 0));
}
_this.getWorksheet = function() {
return worksheet;
}
// Проверяет выход за границы
_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;
_this.initGlobalDrawingPointer = function() {
DrawingObject = DrawingBase;
DrawingObjectLayer = DrawingLayer;
}
_t.canResize = function(width, height) {
var result = true;
_this._uploadMessage = function(event) {
if ( null != event && null != event.data ) {
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;
}
var data = JSON.parse(event.data);
if ( null != data && null != data.type )
{
if ( PostMessageType.UploadImage == data.type ) {
if(c_oAscServerError.NoError == data.error) {
var sheetId = null;
if(null != data.input)
sheetId = data.input.sheetId;
var url = data.url;
if (sheetId == worksheet.model.getId())
_this.addImageDrawingObject(url, false, null);
else
worksheet.model.workbook.handlers.trigger("asc_onEndAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadImage);
}
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;
else {
worksheet.model.workbook.handlers.trigger("asc_onError", _mapAscServerErrorToAscError(data.error), c_oAscError.Level.NoCritical);
worksheet.model.workbook.handlers.trigger("asc_onEndAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadImage);
}
}
}
}
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);
_this.clearDrawingObjects = function() {
worksheet._clean();
worksheet._drawCorner();
worksheet._drawColumnHeaders();
worksheet._drawRowHeaders();
worksheet._drawGrid();
worksheet._drawCells();
worksheet._drawCellsBorders();
worksheet.cellCommentator.drawCommentCells(false);
worksheet.autoFilters.drawAutoF(worksheet);
}
_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;
_this.raiseLayerDrawingObjects = function(bSelect) {
case c_oAscCellAnchorType.cellanchorAbsolute:
{
if ( _t.Pos.X < 0 )
_t.Pos.X = 0;
if ( _t.Pos.Y < 0 )
_t.Pos.Y = 0;
// слой c объектами должен быть выше селекта
var range = worksheet.getSelectedRange().bbox;
for (var i = 0; i < _this.countDrawingObjects(); i++) {
_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));
var obj = aObjects[i];
_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 width = obj.getVisibleWidth();
var height = obj.getVisibleHeight();
if ( (width > 0) && (height > 0) ) {
var _left = _t.getRealLeftOffset();
var _top = _t.getRealTopOffset();
overlayCtx.clearRect(pxToPt(obj.getVisibleLeftOffset(true)), pxToPt(obj.getVisibleTopOffset(true)),
pxToPt(obj.getVisibleWidth()), pxToPt(obj.getVisibleHeight()));
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));
if ( bSelect ) {
if (obj.flags.selected)
_this.selectDrawingObject(i);
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;
if (obj.flags.lockState != c_oAscObjectLockState.No)
_this.selectLockedDrawingObject(obj.id, obj.flags.lockState);
}
}*/
_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;
/*if ( (range.c1 >= obj.from.col) && (range.c1 <= obj.to.col) && (range.r1 >= obj.from.row) && (range.r1 <= obj.to.row) ) {
obj.graphicObject.draw(shapeCtx);
}*/
}
// Реальное смещение по высоте
_t.getRealTopOffset = function() {
var val = _t.worksheet.getCellTop(_t.from.row, 0) + mmToPx(_t.from.rowOff);
return window["Asc"].round(val);
}
// Реальное смещение по ширине
_t.getRealLeftOffset = function() {
var val = _t.worksheet.getCellLeft(_t.from.col, 0) + mmToPx(_t.from.colOff);
return window["Asc"].round(val);
_this.countDrawingObjects = function() {
return aObjects ? aObjects.length : 0;
}
// Ширина по координатам
_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 : window["Asc"].round(val);
_this.checkDrawingObjectIndex = function(index) {
if (_this.countDrawingObjects() && (index >= 0) && (index < _this.countDrawingObjects()))
return true;
else
return false;
}
// Высота по координатам
_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 : window["Asc"].round(val);
}
//-----------------------------------------------------------------------------------
// Optimization of drawing
//-----------------------------------------------------------------------------------
// Видимая ширина при скролах
_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;
_this.needDrawingObjects = function() {
var result = false;
var fvr = worksheet.getFirstVisibleRow();
var fvc = worksheet.getFirstVisibleCol();
for (var i = 0; i < _this.countDrawingObjects(); i++) {
if ((fvr < aObjects[i].to.row + 1) && (fvc < aObjects[i].to.col + 1)) {
result = true;
break;
}
// Видимая высота при скролах
_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;
return result;
}
// Видимое смещение объекта от первой видимой колонки
_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;
}
_this.showOverlayDrawingObject = function(index) {
if (_this.checkDrawingObjectIndex(index)) {
var obj = aObjects[index];
if ( !obj.image.complete ) // complete - дополнительная проверка в случае base64
return;
// смещение по высоте внутри объекта
_t.getInnerOffsetTop = function() {
var fvr = _t.worksheet.getCellTop(_t.worksheet.getFirstVisibleRow(), 0);
var off = _t.getRealTopOffset() - fvr;
return (off > 0) ? 0 : window["Asc"].round(Math.abs(off) * _t.getHeightCoeff());
}
if (obj.image.width && obj.image.height) {
var sWidth = obj.image.width - obj.getInnerOffsetLeft();
var sHeight = obj.image.height - obj.getInnerOffsetTop();
// смещение по ширине внутри объекта
_t.getInnerOffsetLeft = function() {
var fvc = _t.worksheet.getCellLeft(_t.worksheet.getFirstVisibleCol(), 0);
var off = _t.getRealLeftOffset() - fvc;
return (off > 0) ? 0 : window["Asc"].round(Math.abs(off) * _t.getWidthCoeff());
}
// Проверка для IE
var dWidth = obj.getVisibleWidth();
var dHeight = obj.getVisibleHeight();
if ((dWidth <= 0) || (dHeight <= 0))
return;
// коэффициент по ширине если несоответствие с реальным размером
_t.getWidthCoeff = function() {
return _t.image.width / _t.getWidthFromTo();
overlayCtx.drawImage(obj.image,
// обрезаем
pxToPt(obj.getInnerOffsetLeft()), pxToPt(obj.getInnerOffsetTop()),
pxToPt(sWidth), pxToPt(sHeight),
// вставляем
pxToPt(obj.getVisibleLeftOffset(true)), pxToPt(obj.getVisibleTopOffset(true)),
pxToPt(dWidth), pxToPt(dHeight));
}
// коэффициент по высоте если несоответствие с реальным размером
_t.getHeightCoeff = function() {
return _t.image.height / _t.getHeightFromTo();
}
if ( g_oTableId )
g_oTableId.Add( _t, _t.id );
}
DrawingBase.prototype = {
_this.showDrawingObjects = function(clearCanvas, printOptions, bUpdateCharts) {
getObjectType: function() {
return CLASS_TYPE_DRAWING_BASE;
},
/*********** Print Options ***************
printOptions : {
ctx,
margin : {
left: 0, // pt
right: 0, // pt
top: 0, // pt
button: 0 // pt
}
}
*****************************************/
getType: function() {
return UndoRedoDataTypes.DrawingObjectData;
},
if (!_this.countDrawingObjects())
return;
getProperties: function() {
return this.Properties;
},
worksheet.model.Drawings = aObjects;
getProperty: function(nType) {
switch (nType) {
case this.Properties.Id: return this.id; break;
case this.Properties.Type: return this.Type; break;
case this.Properties.PosX: return this.Pos.X; break;
case this.Properties.PosY: return this.Pos.Y; break;
case this.Properties.ExtCx: return this.ext.cx; break;
case this.Properties.ExtCy: return this.ext.cy; break;
if (drawingCtx && _this.needDrawingObjects()) {
case this.Properties.ImageSrc: return this.image.src; break;
// всё чистим
if (clearCanvas) {
_this.clearDrawingObjects();
}
case this.Properties.FlagCurrentCursor: return this.flags.currentCursor; break;
case this.Properties.FlagsTransactionState: return this.flags.transactionState; break;
if ( !imageLoader.isReady() ) {
//console.log("imageLoader - False");
imageLoader.setReadyCallback(_this.showDrawingObjects);
}
else {
//console.log("imageLoader - Ok");
imageLoader.removeReadyCallback();
}
case this.Properties.ImageUrl: return this.imageUrl; break;
for (var i = 0; i < _this.countDrawingObjects(); i++) {
case this.Properties.FromCol: return this.from.col; break;
case this.Properties.FromColOff: return this.from.colOff; break;
case this.Properties.FromRow: return this.from.row; break;
case this.Properties.FromRowOff: return this.from.rowOff; break;
var index = i;
var obj = aObjects[i];
case this.Properties.ToCol: return this.to.col; break;
case this.Properties.ToColOff: return this.to.colOff; break;
case this.Properties.ToRow: return this.to.row; break;
case this.Properties.ToRowOff: return this.to.rowOff; break;
// Shape render
if ( obj.isGraphicObject() ) {
obj.graphicObject.draw(shapeCtx);
continue;
}
case this.Properties.MoveX: return this.move.x; break;
case this.Properties.MoveY: return this.move.y; break;
obj.normalizeMetrics();
case this.Properties.SizeCoeff: return this.size.coeff; break;
case this.Properties.ChartData: return this.chart; break;
case this.Properties.GraphicObject: return this.graphicObject; break;
}
},
obj.size.coeff = obj.getHeightFromTo(true) / obj.getWidthFromTo(true);
setProperty: function(nType, value) {
switch (nType) {
case this.Properties.Id: this.id = value; break;
case this.Properties.Type: this.Type = value; break;
case this.Properties.PosX: this.Pos.X = value; break;
case this.Properties.PosY: this.Pos.Y = value; break;
case this.Properties.ExtCx: this.ext.cx = value; break;
case this.Properties.ExtCy: this.ext.cy = value; break;
if (!obj.flags.anchorUpdated)
obj.updateAnchorPosition();
case this.Properties.ImageSrc: this.image.src = value; break;
// History
if (obj.move.inAction && undoRedoObject && (undoRedoObject.id == obj.id)) {
case this.Properties.FlagCurrentCursor: this.flags.currentCursor = value; break;
case this.Properties.FlagsTransactionState: this.flags.transactionState = value; break;
History.Create_NewPoint();
History.StartTransaction();
case this.Properties.ImageUrl: this.imageUrl = value; break;
undoRedoObject.flags.transactionState = c_oAscTransactionState.Start;
History.Add(g_oUndoRedoDrawingObject, historyitem_DrawingObject_Edit, worksheet.model.getId(), null, undoRedoObject);
undoRedoObject = null;
case this.Properties.FromCol: this.from.col = value; break;
case this.Properties.FromColOff: this.from.colOff = value; break;
case this.Properties.FromRow: this.from.row = value; break;
case this.Properties.FromRowOff: this.from.rowOff = value; break;
History.Create_NewPoint();
var urObj = _this.cloneDrawingObject(obj);
urObj.flags.transactionState = c_oAscTransactionState.Stop;
History.Add(g_oUndoRedoDrawingObject, historyitem_DrawingObject_Edit, worksheet.model.getId(), null, urObj);
case this.Properties.ToCol: this.to.col = value; break;
case this.Properties.ToColOff: this.to.colOff = value; break;
case this.Properties.ToRow: this.to.row = value; break;
case this.Properties.ToRowOff: this.to.rowOff = value; break;
History.EndTransaction();
}
case this.Properties.MoveX: this.move.x = value; break;
case this.Properties.MoveY: this.move.y = value; break;
var srcForPrint;
case this.Properties.SizeCoeff: this.size.coeff = value; break;
case this.Properties.ChartData: this.chart = value; break;
case this.Properties.GraphicObject: this.graphicObject = value; break;
}
// Выход за границы
while (worksheet.nColsCount < obj.to.col + 1) {
worksheet.expandColsOnScroll(true);
}
while (worksheet.nRowsCount < obj.to.row + 1) {
worksheet.expandRowsOnScroll(true);
}
//-----------------------------------------------------------------------------------
// Create drawing layer
//-----------------------------------------------------------------------------------
if ( obj.isChart() && (obj.flags.redrawChart || bUpdateCharts) ) {
if ( !obj.chart.range.intervalObject )
_this.intervalToIntervalObject(obj.chart);
var DrawingLayer = function() {
obj.chart.rebuildSeries();
obj.chart.worksheet = worksheet;
var chartBase64 = chartRender.insertChart(obj.chart, null, obj.getWidthFromTo(), obj.getHeightFromTo());
if ( !chartBase64 )
continue;
this.Properties = {
aLayerBefore: 1,
aLayerAfter: 2
}
imageLoader.addImage(chartBase64);
imageLoader.setReadyCallback(_this.showDrawingObjects);
this.aLayerBefore = [];
this.aLayerAfter = [];
obj.image.onload = function() {
obj.flags.currentCursor = null;
}
DrawingLayer.prototype = {
getType: function() {
return UndoRedoDataTypes.DrawingObjectLayer;
},
obj.image.src = chartBase64;
obj.flags.redrawChart = false;
continue;
}
getProperties: function() {
return this.Properties;
},
if ( !obj.canDraw() )
continue;
getProperty: function(nType) {
switch (nType) {
case this.Properties.aLayerBefore: return this.aLayerBefore; break;
case this.Properties.aLayerAfter: return this.aLayerAfter; break;
}
},
var sWidth = obj.image.width - obj.getInnerOffsetLeft();
var sHeight = obj.image.height - obj.getInnerOffsetTop();
setProperty: function(nType, value) {
switch (nType) {
case this.Properties.aLayerBefore: this.aLayerBefore = value; break;
case this.Properties.aLayerAfter: this.aLayerAfter = value; break;
}
if ( printOptions ) {
if ( obj.isChart() ) {
srcForPrint = obj.image.src; // base64
}
else {
srcForPrint = obj.imageUrl;
}
//-----------------------------------------------------------------------------------
// Constructor
//-----------------------------------------------------------------------------------
var marginRight = 0;
if (worksheet.getCellLeft(worksheet.getLastVisibleCol(), 0) + worksheet.getColumnWidth(worksheet.getLastVisibleCol()) < obj.getRealLeftOffset() + obj.getVisibleWidth())
marginRight = printOptions.margin.right;
_this.createDrawingObject = function() {
printOptions.ctx.drawImage(srcForPrint,
// обрезаем
pxToPt(obj.getInnerOffsetLeft()), pxToPt(obj.getInnerOffsetTop()),
pxToPt(sWidth) - marginRight, pxToPt(sHeight),
// вставляем
pxToPt(obj.getVisibleLeftOffset(true)) + printOptions.margin.left, pxToPt(obj.getVisibleTopOffset(true)) + printOptions.margin.top,
pxToPt(obj.getVisibleWidth()), pxToPt(obj.getVisibleHeight()),
pxToPt(obj.image.width), pxToPt(obj.image.height));
}
else {
if ( !obj.image.width || !obj.image.height )
continue;
var drawing = new DrawingBase(worksheet);
// Проверка для IE
var dWidth = obj.getVisibleWidth();
var dHeight = obj.getVisibleHeight();
if ( (dWidth <= 0) || (dHeight <= 0) )
continue;
drawing.chart.range.interval = function() {
var result = "";
if (worksheet) {
var selectedRange = worksheet.getSelectedRange();
if (selectedRange) {
var box = selectedRange.getBBox0();
var startCell = new CellAddress(box.r1, box.c1, 0);
var endCell = new CellAddress(box.r2, box.c2, 0);
drawingCtx.drawImage(obj.image,
// обрезаем
pxToPt(obj.getInnerOffsetLeft()), pxToPt(obj.getInnerOffsetTop()),
pxToPt(sWidth), pxToPt(sHeight),
// вставляем
pxToPt(obj.getVisibleLeftOffset(true)), pxToPt(obj.getVisibleTopOffset(true)),
pxToPt(dWidth), pxToPt(dHeight));
}
if (startCell && endCell) {
var wsName = worksheet.model.sName;
if ( !rx_test_ws_name.test(wsName) )
wsName = "'" + wsName + "'";
if ( obj.flags.selected && !printOptions )
_this.selectDrawingObject(index);
if ( obj.flags.lockState != c_oAscObjectLockState.No )
_this.selectLockedDrawingObject(obj.id, obj.flags.lockState);
if (startCell.getID() == endCell.getID())
result = wsName + "!" + startCell.getID();
else
result = wsName + "!" + startCell.getID() + ":" + endCell.getID();
}
obj.move.inAction = false;
}
}
return result;
}();
if ( !printOptions ) {
worksheet._drawCollaborativeElements();
drawing.chart.range.intervalObject = function() {
return worksheet ? worksheet.getSelectedRange() : null;
}();
if ( _this.getSelectedDrawingObjectIndex() < 0 ) {
worksheet.cleanSelection();
worksheet._drawSelectionRange();
_this.raiseLayerDrawingObjects(true);
}
}
}
return drawing;
_this.showOverlayGraphicObjects = function() {
shapeOverlayCtx.put_GlobalAlpha(true, 0.5);
shapeOverlayCtx.m_oContext.clearRect(0, 0, shapeOverlayCtx.m_lWidthPix, shapeOverlayCtx.m_lHeightPix);
_this.controller.drawTracks(shapeOverlayCtx);
shapeOverlayCtx.put_GlobalAlpha(true, 1);
}
_this.cloneDrawingObject = function(obj) {
_this.showOverlayDrawingObjects = function() {
var copyObject = _this.createDrawingObject();
if (overlayCtx) {
copyObject.worksheet = obj.worksheet;
copyObject.id = obj.id;
overlayCtx.clear();
var index = _this.getSelectedDrawingObjectIndex();
var obj = aObjects[index];
if (!obj.flags.currentCursor)
return;
copyObject.Type = obj.Type;
copyObject.Pos.X = obj.Pos.X;
copyObject.Pos.Y = obj.Pos.Y;
copyObject.ext.cx = obj.ext.cx;
copyObject.ext.cy = obj.ext.cy;
// выход за границы
if (!obj.canDraw())
return;
var img = new Image();
img.src = obj.image.src;
copyObject.image = img;
var sWidth = obj.image.width - obj.getInnerOffsetLeft();
var sHeight = obj.image.height - obj.getInnerOffsetTop();
copyObject.flags.currentCursor = obj.flags.currentCursor;
copyObject.flags.transactionState = obj.flags.transactionState;
copyObject.flags.redrawChart = obj.flags.redrawChart;
setCanvasZIndex(overlayCtx.ctx, 0.5);
copyObject.imageUrl = obj.imageUrl;
if (obj.isImage()) {
copyObject.from.col = obj.from.col;
copyObject.from.colOff = obj.from.colOff;
copyObject.from.row = obj.from.row;
copyObject.from.rowOff = obj.from.rowOff;
// Проверка для IE
var dWidth = obj.getVisibleWidth();
var dHeight = obj.getVisibleHeight();
if ((dWidth <= 0) || (dHeight <= 0))
return;
copyObject.to.col = obj.to.col;
copyObject.to.colOff = obj.to.colOff;
copyObject.to.row = obj.to.row;
copyObject.to.rowOff = obj.to.rowOff;
overlayCtx.drawImage(obj.image,
/* обрезаем */pxToPt(obj.getInnerOffsetLeft()), pxToPt(obj.getInnerOffsetTop()),
pxToPt(sWidth), pxToPt(sHeight),
copyObject.move.x = obj.move.x;
copyObject.move.y = obj.move.y;
copyObject.size.coeff = obj.size.coeff;
/* вставляем */pxToPt(obj.getVisibleLeftOffset(true)), pxToPt(obj.getVisibleTopOffset(true)),
pxToPt(dWidth), pxToPt(dHeight));
}
else {
overlayCtx.beginPath();
overlayCtx.rect(pxToPt(obj.getVisibleLeftOffset(true)), pxToPt(obj.getVisibleTopOffset(true)), pxToPt(obj.getVisibleWidth()), pxToPt(obj.getVisibleHeight()));
overlayCtx.setLineWidth(1);
overlayCtx.setStrokeStyle("#000000");
overlayCtx.setFillStyle("#ffffff");
overlayCtx.fillRect(pxToPt(obj.getVisibleLeftOffset(true)), pxToPt(obj.getVisibleTopOffset(true)), pxToPt(obj.getVisibleWidth()), pxToPt(obj.getVisibleHeight()));
overlayCtx.stroke();
}
}
}
copyObject.chart = new asc_CChart(obj.chart);
copyObject.graphicObject = obj.graphicObject;
copyObject.chart.worksheet = obj.chart.worksheet;
_this.getDrawingAreaMetrics = function() {
return copyObject;
/*
* Объект, определяющий max колонку и строчку для отрисовки объектов листа
*/
var metrics = {
maxCol: 0,
maxRow: 0
}
for (var i = 0; i < _this.countDrawingObjects(); i++) {
if (aObjects[i].to.col >= metrics.maxCol)
metrics.maxCol = aObjects[i].to.col + 1; // учитываем colOff
if (aObjects[i].to.row >= metrics.maxRow)
metrics.maxRow = aObjects[i].to.row + 1; // учитываем rowOff
}
return metrics;
}
//-----------------------------------------------------------------------------------
......@@ -4277,6 +4284,11 @@ function DrawingObjects() {
if (!obj.canDraw())
return bResult;
if ( obj.isGraphicObject() ) {
_this.selectGraphicObject();
return;
}
if ( !lockState ) {
obj.flags.selected = true;
}
......@@ -4665,7 +4677,7 @@ function DrawingObjects() {
_this.getSelectedDrawingObjectIndex = function() {
for (var i = 0; i < _this.countDrawingObjects(); i++) {
if (aObjects[i].flags.selected == true)
if (aObjects[i].flags.selected || (aObjects[i].graphicObject && aObjects[i].graphicObject.selected) )
return i;
}
return -1;
......@@ -4782,7 +4794,7 @@ function DrawingObjects() {
_this.getSelectedDrawingObjectId = function() {
for (var i = 0; i < _this.countDrawingObjects(); i++) {
if (aObjects[i].flags.selected == true)
if (aObjects[i].flags.selected || (aObjects[i].graphicObject && aObjects[i].graphicObject.selected) )
return aObjects[i].id;
}
return null;
......
......@@ -1088,6 +1088,11 @@
t.handlers.trigger("graphicObjectMouseDown", event, coord.x, coord.y);
if ( t.isCellEditMode )
t.handlers.trigger("stopCellEditing");
if (2 === event.button)
t.handlers.trigger("changeSelectionRightClick", coord.x, coord.y);
else
t.handlers.trigger("changeSelection", /*isStartPoint*/true, coord.x, coord.y, /*isCoord*/true, /*isSelectMode*/true);
return;
}
else
......
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