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

- Добавлен ShapeDrawer.js в Excel/model/DrawingObjects

- getFullImageSrc(были конфликты в сборке ворда)
- При открытии таблицы картинки класса CImage
- Добавление DrawingBase в глобальную таблицу id


git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47933 954022d7-b5bf-4e40-9824-e11837661b57
parent e9aa4412
......@@ -77,7 +77,6 @@
"../Excel/model/DrawingObjects/Format/Geometry.js",
"../Excel/model/DrawingObjects/Format/Path.js",
"../Word/Editor/GraphicObjects/Math.js",
"../Word/Drawing/ShapeDrawer.js",
"../Word/Drawing/ArcTo.js",
"../Word/Drawing/ColorArray.js",
"../Common/Shapes/Serialize.js",
......@@ -130,6 +129,7 @@
"../Excel/model/DrawingObjects/Overlay.js",
"../Excel/model/DrawingObjects/GlobalCounters.js",
"../Excel/model/DrawingObjects/DrawingDocument.js",
"../Excel/model/DrawingObjects/ShapeDrawer.js",
"../Word/apiCommon.js",
"../Excel/.build/Log/apiCommonExport.js",
"../Excel/api.js",
......
......@@ -39,7 +39,7 @@ function convertFormula(formula, ws) {
return range;
}
function _getFullImageSrc(src) {
function getFullImageSrc(src) {
var start = src.substring(0, 6);
if ( 0 != src.indexOf("http:") && 0 != src.indexOf("data:") && 0 != src.indexOf("https:") && 0 != src.indexOf("ftp:") && 0 != src.indexOf("file:") ) {
var api = window["Asc"]["editor"];
......@@ -2071,16 +2071,15 @@ function DrawingObjects() {
var minChartHeight = 160;
var undoRedoObject = null;
var shiftKey = false;
var userId = null;
var documentId = null;
var lastObjectIndex = null;
// Все изменения, связанные с image.src прогоняем через этот класс
var imageLoader = new ImageLoader();
//var imageLoader = new ImageLoader();
_this.drawingDocument = null;
_this.asyncImageLoadedEvent = null;
_this.asyncImageLoadedBackgroundEvent = null;
//-----------------------------------------------------------------------------------
// Public methods
......@@ -2089,10 +2088,6 @@ function DrawingObjects() {
_this.init = function(currentSheet) {
userId = api.User.asc_getId();
g_oIdCounter = new CIdCounter();
g_oTableId = new CTableId();
g_oIdCounter.Set_UserId(userId);
documentId = api.documentId;
worksheet = currentSheet;
......@@ -2114,19 +2109,55 @@ function DrawingObjects() {
isViewerMode = function() { return worksheet._trigger("getViewerMode"); };
aObjects = [];
aImagesSync = [];
aObjectsSync = [];
for (var i = 0; currentSheet.model.Drawings && (i < currentSheet.model.Drawings.length); i++) {
currentSheet.model.Drawings[i].worksheet = worksheet;
aObjects[i] = _this.cloneDrawingObject(currentSheet.model.Drawings[i]);
if (aObjects[i].isChart()) {
_this.calcChartInterval(aObjects[i].chart);
aObjects[i].chart.worksheet = worksheet;
var clone = _this.cloneDrawingObject(currentSheet.model.Drawings[i]);
if ( currentSheet.model.Drawings[i].isChart() ) {
_this.calcChartInterval(clone.chart);
clone.chart.worksheet = worksheet;
aObjects.push( clone );
}
if (aObjects[i].isImage())
imageLoader.addImage(aObjects[i].image.src);
if ( currentSheet.model.Drawings[i].isImage() ) {
aImagesSync[aImagesSync.length] = currentSheet.model.Drawings[i].imageUrl;
aObjectsSync[aObjectsSync.length] = currentSheet.model.Drawings[i];
}
}
// Загружаем все картинки листа
api.ImageLoader.bIsAsyncLoadDocumentImages = true;
api.ImageLoader.LoadDocumentImages(aImagesSync);
api.ImageLoader.bIsAsyncLoadDocumentImages = false;
for (var i = 0; i < aObjectsSync.length; i++) {
var clone = aObjectsSync[i];
var image = api.ImageLoader.LoadImage(aImagesSync[i], 1); // Должна быть в мапе
if ( image != null ) {
var headerTop = worksheet.getCellTop(0, 0);
var headerLeft = worksheet.getCellLeft(0, 0);
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);
}
}
lastObjectIndex = aObjects.length;
// Upload event
......@@ -2293,10 +2324,6 @@ function DrawingObjects() {
return aObjects;
}
_this.setShiftKey = function(bShiftKey) {
shiftKey = bShiftKey;
}
_this.getWorksheet = function() {
return worksheet;
}
......@@ -2448,14 +2475,14 @@ function DrawingObjects() {
_this.clearDrawingObjects();
}
if ( !imageLoader.isReady() ) {
/*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++) {
......@@ -2513,8 +2540,8 @@ function DrawingObjects() {
if ( !chartBase64 )
continue;
imageLoader.addImage(chartBase64);
imageLoader.setReadyCallback(_this.showDrawingObjects);
//imageLoader.addImage(chartBase64);
//imageLoader.setReadyCallback(_this.showDrawingObjects);
obj.image.onload = function() {
obj.flags.currentCursor = null;
......@@ -2646,12 +2673,9 @@ function DrawingObjects() {
_this.getDrawingAreaMetrics = function() {
/*
* Объект, определяющий max колонку и строчку для отрисовки объектов листа. Если объектов нет, то null
* Объект, определяющий max колонку и строчку для отрисовки объектов листа
*/
if (!_this.countDrawingObjects())
return null;
var metrics = {
maxCol: 0,
maxRow: 0
......@@ -2701,7 +2725,7 @@ function DrawingObjects() {
ChartData: 22
};
_t.id = null;
_t.id = g_oIdCounter ? g_oIdCounter.Get_NewId() : null;
_t.image = new Image();
_t.imageUrl = "";
_t.Type = c_oAscCellAnchorType.cellanchorTwoCell;
......@@ -2749,6 +2773,9 @@ function DrawingObjects() {
// Считаем 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);
......@@ -2989,6 +3016,9 @@ function DrawingObjects() {
_t.getHeightCoeff = function() {
return _t.image.height / _t.getHeightFromTo();
}
if ( g_oTableId )
g_oTableId.Add( _t, _t.Id );
}
DrawingBase.prototype = {
......@@ -3145,7 +3175,7 @@ function DrawingObjects() {
drawing.chart.range.intervalObject = function() {
return worksheet ? worksheet.getSelectedRange() : null;
}();
return drawing;
}
......@@ -3259,7 +3289,6 @@ function DrawingObjects() {
}
else {
var obj = _this.createDrawingObject();
obj.id = generateId();
obj.worksheet = worksheet;
obj.from.col = isOption ? options.cell.col : worksheet.getSelectedColumnIndex();
......@@ -3294,6 +3323,7 @@ function DrawingObjects() {
worksheet.autoFilters.drawAutoF(worksheet);
worksheet.cellCommentator.drawCommentCells(false);
_this.showDrawingObjects(false);
// History.Create_NewPoint();
......@@ -3425,11 +3455,10 @@ function DrawingObjects() {
if ( !chartBase64 )
return false;
imageLoader.addImage(chartBase64);
//imageLoader.addImage(chartBase64);
// draw
var obj = _this.createDrawingObject();
obj.id = generateId();
obj.chart = chart;
obj.flags.redrawChart = true;
......@@ -4007,25 +4036,17 @@ function DrawingObjects() {
_this.addGraphicObject = function(graphic) {
var obj = _this.createDrawingObject();
obj.id = generateId();
obj.graphicObject = graphic;
graphic.setDrawingBase(obj);
function callbackFunc(result) {
if ( result ) {
//History.Create_NewPoint();
//History.Add(g_oUndoRedoDrawingObject, historyitem_DrawingObject_Add, worksheet.model.getId(), null, obj);
//History.Create_NewPoint();
//History.Add(g_oUndoRedoDrawingObject, historyitem_DrawingObject_Add, worksheet.model.getId(), null, obj);
obj.graphicObject.select(_this.controller);
aObjects.push(obj);
_this.showDrawingObjects(false);
worksheet.model.workbook.handlers.trigger("asc_onEndAddShape");
}
}
_this.lockDrawingObject(obj.id, true, true, callbackFunc);
obj.graphicObject.select(_this.controller);
aObjects.push(obj);
_this.showDrawingObjects(false);
worksheet.model.workbook.handlers.trigger("asc_onEndAddShape");
_this.lockDrawingObject(obj.id, true, true);
}
_this.groupGraphicObjects = function() {
......@@ -4033,7 +4054,6 @@ function DrawingObjects() {
if ( _this.controller.canGroup() ) {
var obj = _this.createDrawingObject();
obj.id = generateId();
var group = _this.controller.createGroup(obj);
if ( group ) {
obj.graphicObject = group;
......@@ -4059,7 +4079,6 @@ function DrawingObjects() {
for (var i = 0; i < aGraphics.length; i++) {
var obj = _this.createDrawingObject();
obj.id = generateId();
obj.graphicObject = aGraphics[i];
aGraphics[i].setDrawingBase(obj);
obj.graphicObject.select(_this.controller);
......@@ -4640,7 +4659,7 @@ function DrawingObjects() {
_this.getSelectedDrawingObjectIndex = function() {
for (var i = 0; (i < _this.countDrawingObjects()) && !shiftKey; i++) {
for (var i = 0; i < _this.countDrawingObjects(); i++) {
if (aObjects[i].flags.selected == true)
return i;
}
......@@ -5299,7 +5318,7 @@ function DrawingObjects() {
}
function ascCvtRatio(fromUnits, toUnits) {
return window["Asc"].getCvtRatio( fromUnits, toUnits, drawingCtx.getPPIX() );
return window["Asc"].getCvtRatio( fromUnits, toUnits, drawingCtx ? drawingCtx.getPPIX() : 96 );
}
function setCanvasZIndex(canvas, value) {
......
......@@ -112,13 +112,8 @@
<script type="text/javascript" src="../Excel/model/DrawingObjects/Format/Geometry.js"></script>
<script type="text/javascript" src="../Excel/model/DrawingObjects/Format/Path.js"></script>
<script type="text/javascript" src="../Word/Editor/GraphicObjects/Math.js"></script>
<script type="text/javascript" src="../Word/Drawing/ShapeDrawer.js"></script>
<script type="text/javascript" src="../Word/Drawing/ArcTo.js"></script>
<script type="text/javascript" src="../Word/Drawing/ColorArray.js"></script>
<script type="text/javascript" src="../Word/apiCommon.js"></script>
<!--for chart-->
......@@ -164,6 +159,7 @@
<script src="model/DrawingObjects/States.js"></script>
<script src="model/DrawingObjects/GlobalLoaders.js"></script>
<script src="model/DrawingObjects/GlobalCounters.js"></script>
<script src="model/DrawingObjects/ShapeDrawer.js"></script>
<script src="model/DrawingObjects/Format/GroupShape.js"></script>
<script src="model/DrawingObjects/Format/Image.js"></script>
......
......@@ -114,6 +114,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
this.addShapePreset = "";
this.ImageLoader = window.g_image_loader;
this.ImageLoader.put_Api(this);
/**************************************/
this.OpenDocumentProgress = {
......@@ -2096,7 +2097,12 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
},
asyncImageStartLoaded: function() {
// здесь прокинуть евент о заморозке меню
},
asyncImagesDocumentStartLoaded: function() {
},
asyncImagesDocumentEndLoaded: function() {
},
asyncImageEndLoaded: function(_image) {
......@@ -2105,6 +2111,12 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
ws.objectRender.asyncImageLoadedEvent(_image);
},
asyncImageEndLoadedBackground: function(_image) {
var ws = this.wb.getWorksheet();
if ( ws.objectRender.asyncImageLoadedBackgroundEvent )
ws.objectRender.asyncImageLoadedBackgroundEvent(_image);
},
// Cell interface
asc_getCellInfo: function (bExt) {
return this.wb.getWorksheet().getSelectionInfo(!!bExt);
......
......@@ -180,10 +180,8 @@
<script type="text/javascript" src="../../../../OfficeWeb/Excel/model/DrawingObjects/Format/Geometry.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Excel/model/DrawingObjects/Format/Path.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/Editor/GraphicObjects/Math.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/Drawing/ShapeDrawer.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/Drawing/ArcTo.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/Drawing/ColorArray.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/apiCommon.js"></script>
<!--for chart-->
......@@ -228,6 +226,7 @@
<script src="../../../../OfficeWeb/Excel/model/DrawingObjects/DrawingDocument.js"></script>
<script src="../../../../OfficeWeb/Excel/model/DrawingObjects/States.js"></script>
<script src="../../../../OfficeWeb/Excel/model/DrawingObjects/GlobalLoaders.js"></script>
<script src="../../../../OfficeWeb/Excel/model/DrawingObjects/ShapeDrawer.js"></script>
<script src="../../../../OfficeWeb/Excel/model/DrawingObjects/Format/GroupShape.js"></script>
<script src="../../../../OfficeWeb/Excel/model/DrawingObjects/Format/Image.js"></script>
......
......@@ -2293,7 +2293,7 @@ function CDrawingDocument(drawingObjects)
var _len = _imgs.length;
for (var j = 0; j < _len; j++)
{
if (_getFullImageSrc(_imgs[j]) == src)
if (getFullImageSrc(_imgs[j]) == src)
{
this.StopRenderingPage(i);
bIsRaster = true;
......@@ -4497,7 +4497,7 @@ function CDrawingDocument(drawingObjects)
if (null == this.LastDrawingUrl)
return;
var _img = this.m_oWordControl.m_oApi.ImageLoader.map_image_index[_getFullImageSrc(this.LastDrawingUrl)];
var _img = this.m_oWordControl.m_oApi.ImageLoader.map_image_index[getFullImageSrc(this.LastDrawingUrl)];
if (_img != undefined && _img.Image != null || _img.Status == ImageLoadStatus.Loading)
{
var _x = 0;
......
......@@ -1129,7 +1129,7 @@ CBlipFill.prototype =
Writer.WriteBool(flag);
if(flag)
{
var string_to_write = _getFullImageSrc(this.RasterImageId);
var string_to_write = getFullImageSrc(this.RasterImageId);
if(string_to_write.indexOf(documentOrigin) !== 0
&& string_to_write.indexOf("http:") !== 0
&& string_to_write.indexOf("https:") !== 0
......
......@@ -56,9 +56,9 @@ var ASC_DOCS_API_USE_OPEN_SOURCE_FONTS_ONLY = false;
if (isUrl === false)
this.images_loading[this.images_loading.length] = _images[id];
else
this.images_loading[this.images_loading.length] = _getFullImageSrc(_images[id]);
this.images_loading[this.images_loading.length] = getFullImageSrc(_images[id]);
*/
this.images_loading[this.images_loading.length] = _getFullImageSrc(_images[id]);
this.images_loading[this.images_loading.length] = getFullImageSrc(_images[id]);
}
if (!this.bIsAsyncLoadDocumentImages)
......
This diff is collapsed.
......@@ -1067,8 +1067,6 @@
_onMouseDown: function (event) {
var t = this;
var coord = t._getCoordinates(event);
this.handlers.trigger("setShiftKey", event.shiftKey);
if (t.handlers.trigger("isGlobalLockEditCell"))
return;
......
......@@ -87,6 +87,11 @@
this.overlayCtx = undefined;
this.stringRender = undefined;
this.drawingCtxCharts = undefined;
// Global counters
g_oIdCounter = new CIdCounter();
g_oTableId = new CTableId();
g_oIdCounter.Set_UserId(this.Api.User.asc_getId());
// Максимальная ширина числа из 0,1,2...,9, померенная в нормальном шрифте(дефалтовый для книги) в px(целое)
// Ecma-376 Office Open XML Part 1, пункт 18.3.1.13
......@@ -158,7 +163,6 @@
"reinitializeScroll": function () {self._onScrollReinitialize.apply(self, arguments);},
"scrollY": function () {self._onScrollY.apply(self, arguments);},
"scrollX": function () {self._onScrollX.apply(self, arguments);},
"setShiftKey": function () {self._onSetShiftKey.apply(self, arguments);},
"changeSelection": function () {self._onChangeSelection.apply(self, arguments);},
"changeSelectionDone": function () {self._onChangeSelectionDone.apply(self, arguments);},
"changeSelectionRightClick":function () {self._onChangeSelectionRightClick.apply(self, arguments);},
......@@ -427,11 +431,6 @@
}
},
_onSetShiftKey: function (bShiftKey) {
var ws = this.getWorksheet();
ws.objectRender.setShiftKey(bShiftKey);
},
_onChangeSelection: function (isStartPoint, dc, dr, isCoord, isSelectMode, callback) {
var ws = this.getWorksheet();
var d = isStartPoint ?
......
......@@ -458,7 +458,12 @@
//------------------------
this.collaborativeEditing = collaborativeEditing;
//auto filters
this.autoFilters = new asc_AF();
this._init();
/**
* pictures, charts render
* @type DrawingObjects
......@@ -472,11 +477,6 @@
this.objectRender = this.settings.objectRender;
this.cellCommentator = new asc_CCellCommentator(this);
//auto filters
this.autoFilters = new asc_AF();
this._init();
return this;
}
......@@ -1274,7 +1274,7 @@
_calcColumnWidths: function (fullRecalc) {
var x = this.cellsLeft;
var visibleW = this.drawingCtx.getWidth();
var obr = this.objectRender.getDrawingAreaMetrics() || {maxCol: 0, maxRow: 0};
var obr = this.objectRender ? this.objectRender.getDrawingAreaMetrics() : {maxCol: 0, maxRow: 0};
var l = Math.max(this.model.getColsCount(), this.nColsCount, obr.maxCol);
var i = 0, w, column, isBestFit, hiddenW = 0;
......@@ -1317,7 +1317,7 @@
_calcRowHeights: function (fullRecalc) {
var y = this.cellsTop;
var visibleH = this.drawingCtx.getHeight();
var obr = this.objectRender.getDrawingAreaMetrics() || {maxCol: 0, maxRow: 0};
var obr = this.objectRender ? this.objectRender.getDrawingAreaMetrics() : {maxCol: 0, maxRow: 0};
var l = Math.max(this.model.getRowsCount() , this.nRowsCount, obr.maxRow);
var defaultH = this.model.getDefaultHeight() || this.defaultRowHeight;
var i = 0, h, isCustomHeight, row, hiddenH = 0;
......@@ -4682,7 +4682,7 @@
}
function findEOT() {
var obr = t.objectRender.getDrawingAreaMetrics() || {maxCol: 0, maxRow: 0};
var obr = t.objectRender ? t.objectRender.getDrawingAreaMetrics() : {maxCol: 0, maxRow: 0};
var maxCols = t.model.getColsCount();
var maxRows = t.model.getRowsCount();
var lastC = -1, lastR = -1;
......@@ -8366,7 +8366,7 @@
var t = this;
var arn;
var bIsMaxCols = false;
var obr = this.objectRender.getDrawingAreaMetrics() || {maxCol: 0, maxRow: 0};
var obr = this.objectRender ? this.objectRender.getDrawingAreaMetrics() : {maxCol: 0, maxRow: 0};
var maxc = Math.max(this.model.getColsCount(), this.cols.length, obr.maxCol);
if (newColsCount) {
maxc = Math.max(maxc, newColsCount);
......@@ -8405,7 +8405,7 @@
var t = this;
var arn;
var bIsMaxRows = false;
var obr = this.objectRender.getDrawingAreaMetrics() || {maxCol: 0, maxRow: 0};
var obr = this.objectRender ? this.objectRender.getDrawingAreaMetrics() : {maxCol: 0, maxRow: 0};
var maxr = Math.max(this.model.getRowsCount() , this.rows.length, obr.maxRow);
if (newRowsCount) {
maxr = Math.max(maxr, newRowsCount);
......
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