3.0 source code
This commit is contained in:
18736
OfficeWeb/sdk/Common/Drawings/Format/ChartFormat.js
Normal file
18736
OfficeWeb/sdk/Common/Drawings/Format/ChartFormat.js
Normal file
File diff suppressed because it is too large
Load Diff
9101
OfficeWeb/sdk/Common/Drawings/Format/ChartSpace.js
Normal file
9101
OfficeWeb/sdk/Common/Drawings/Format/ChartSpace.js
Normal file
File diff suppressed because it is too large
Load Diff
2349
OfficeWeb/sdk/Common/Drawings/Format/Constants.js
Normal file
2349
OfficeWeb/sdk/Common/Drawings/Format/Constants.js
Normal file
File diff suppressed because it is too large
Load Diff
8859
OfficeWeb/sdk/Common/Drawings/Format/CreateGeometry.js
Normal file
8859
OfficeWeb/sdk/Common/Drawings/Format/CreateGeometry.js
Normal file
File diff suppressed because it is too large
Load Diff
8753
OfficeWeb/sdk/Common/Drawings/Format/Format.js
Normal file
8753
OfficeWeb/sdk/Common/Drawings/Format/Format.js
Normal file
File diff suppressed because it is too large
Load Diff
1221
OfficeWeb/sdk/Common/Drawings/Format/Geometry.js
Normal file
1221
OfficeWeb/sdk/Common/Drawings/Format/Geometry.js
Normal file
File diff suppressed because it is too large
Load Diff
1500
OfficeWeb/sdk/Common/Drawings/Format/GroupShape.js
Normal file
1500
OfficeWeb/sdk/Common/Drawings/Format/GroupShape.js
Normal file
File diff suppressed because it is too large
Load Diff
797
OfficeWeb/sdk/Common/Drawings/Format/Image.js
Normal file
797
OfficeWeb/sdk/Common/Drawings/Format/Image.js
Normal file
@@ -0,0 +1,797 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2015
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
"use strict";
|
||||
function CImageShape() {
|
||||
this.nvPicPr = null;
|
||||
this.spPr = new CSpPr();
|
||||
this.blipFill = null;
|
||||
this.style = null;
|
||||
this.parent = null;
|
||||
this.group = null;
|
||||
this.x = null;
|
||||
this.y = null;
|
||||
this.extX = null;
|
||||
this.extY = null;
|
||||
this.rot = null;
|
||||
this.flipH = null;
|
||||
this.flipV = null;
|
||||
this.transform = new CMatrix();
|
||||
this.invertTransform = null;
|
||||
this.cursorTypes = [];
|
||||
this.brush = null;
|
||||
this.pen = null;
|
||||
this.bDeleted = true;
|
||||
this.selected = false;
|
||||
this.snapArrayX = [];
|
||||
this.snapArrayY = [];
|
||||
this.setRecalculateInfo();
|
||||
this.Lock = new CLock();
|
||||
this.Id = g_oIdCounter.Get_NewId();
|
||||
g_oTableId.Add(this, this.Id);
|
||||
}
|
||||
CImageShape.prototype = {
|
||||
Get_Id: function () {
|
||||
return this.Id;
|
||||
},
|
||||
getObjectType: function () {
|
||||
return historyitem_type_ImageShape;
|
||||
},
|
||||
Write_ToBinary2: function (w) {
|
||||
w.WriteLong(this.getObjectType());
|
||||
w.WriteString2(this.Get_Id());
|
||||
},
|
||||
Read_FromBinary2: function (r) {
|
||||
this.Id = r.GetString2();
|
||||
},
|
||||
setBDeleted: function (pr) {
|
||||
History.Add(this, {
|
||||
Type: historyitem_ShapeSetBDeleted,
|
||||
oldPr: this.bDeleted,
|
||||
newPr: pr
|
||||
});
|
||||
this.bDeleted = pr;
|
||||
},
|
||||
setNvPicPr: function (pr) {
|
||||
History.Add(this, {
|
||||
Type: historyitem_ImageShapeSetNvPicPr,
|
||||
oldPr: this.nvPicPr,
|
||||
newPr: pr
|
||||
});
|
||||
this.nvPicPr = pr;
|
||||
},
|
||||
setSpPr: function (pr) {
|
||||
History.Add(this, {
|
||||
Type: historyitem_ImageShapeSetSpPr,
|
||||
oldPr: this.spPr,
|
||||
newPr: pr
|
||||
});
|
||||
this.spPr = pr;
|
||||
},
|
||||
setBlipFill: function (pr) {
|
||||
History.Add(this, {
|
||||
Type: historyitem_ImageShapeSetBlipFill,
|
||||
oldPr: this.blipFill,
|
||||
newPr: pr
|
||||
});
|
||||
this.blipFill = pr;
|
||||
},
|
||||
setParent: function (pr) {
|
||||
History.Add(this, {
|
||||
Type: historyitem_ImageShapeSetParent,
|
||||
oldPr: this.parent,
|
||||
newPr: pr
|
||||
});
|
||||
this.parent = pr;
|
||||
},
|
||||
setGroup: function (pr) {
|
||||
History.Add(this, {
|
||||
Type: historyitem_ImageShapeSetGroup,
|
||||
oldPr: this.group,
|
||||
newPr: pr
|
||||
});
|
||||
this.group = pr;
|
||||
},
|
||||
setStyle: function (pr) {
|
||||
History.Add(this, {
|
||||
Type: historyitem_ImageShapeSetStyle,
|
||||
oldPr: this.style,
|
||||
newPr: pr
|
||||
});
|
||||
this.style = pr;
|
||||
},
|
||||
copy: function () {
|
||||
var copy = new CImageShape();
|
||||
if (this.nvPicPr) {
|
||||
copy.setNvPicPr(this.nvPicPr.createDuplicate());
|
||||
}
|
||||
if (this.spPr) {
|
||||
copy.setSpPr(this.spPr.createDuplicate());
|
||||
copy.spPr.setParent(copy);
|
||||
}
|
||||
if (this.blipFill) {
|
||||
copy.setBlipFill(this.blipFill.createDuplicate());
|
||||
}
|
||||
if (this.style) {
|
||||
copy.setStyle(this.style.createDuplicate());
|
||||
}
|
||||
copy.setBDeleted(this.bDeleted);
|
||||
copy.cachedImage = this.getBase64Img();
|
||||
return copy;
|
||||
},
|
||||
getImageUrl: function () {
|
||||
if (isRealObject(this.blipFill)) {
|
||||
return this.blipFill.RasterImageId;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
isSimpleObject: function () {
|
||||
return true;
|
||||
},
|
||||
getSnapArrays: function (snapX, snapY) {
|
||||
var transform = this.getTransformMatrix();
|
||||
snapX.push(transform.tx);
|
||||
snapX.push(transform.tx + this.extX * 0.5);
|
||||
snapX.push(transform.tx + this.extX);
|
||||
snapY.push(transform.ty);
|
||||
snapY.push(transform.ty + this.extY * 0.5);
|
||||
snapY.push(transform.ty + this.extY);
|
||||
},
|
||||
getBoundsInGroup: function () {
|
||||
return getBoundsInGroup(this);
|
||||
},
|
||||
normalize: CShape.prototype.normalize,
|
||||
checkHitToBounds: CShape.prototype.checkHitToBounds,
|
||||
calculateSnapArrays: CShape.prototype.calculateSnapArrays,
|
||||
checkDrawingBaseCoords: CShape.prototype.checkDrawingBaseCoords,
|
||||
setDrawingBaseCoords: CShape.prototype.setDrawingBaseCoords,
|
||||
sendMouseData: function () {
|
||||
if (true === this.Lock.Is_Locked()) {
|
||||
var MMData = new CMouseMoveData();
|
||||
var Coords = editor.WordControl.m_oLogicDocument.DrawingDocument.ConvertCoordsToCursorWR(this.x, this.y, this.parent.num, null);
|
||||
MMData.X_abs = Coords.X - 5;
|
||||
MMData.Y_abs = Coords.Y;
|
||||
MMData.Type = c_oAscMouseMoveDataTypes.LockedObject;
|
||||
MMData.UserId = this.Lock.Get_UserId();
|
||||
MMData.HaveChanges = this.Lock.Have_Changes();
|
||||
MMData.LockedObjectType = 0;
|
||||
editor.sync_MouseMoveCallback(MMData);
|
||||
}
|
||||
},
|
||||
isPlaceholder: function () {
|
||||
return this.nvPicPr != null && this.nvPicPr.nvPr != undefined && this.nvPicPr.nvPr.ph != undefined;
|
||||
},
|
||||
isEmptyPlaceholder: function () {
|
||||
return false;
|
||||
},
|
||||
isShape: function () {
|
||||
return false;
|
||||
},
|
||||
isImage: function () {
|
||||
return true;
|
||||
},
|
||||
isChart: function () {
|
||||
return false;
|
||||
},
|
||||
isGroup: function () {
|
||||
return false;
|
||||
},
|
||||
hitToAdj: function (x, y) {
|
||||
return {
|
||||
hit: false,
|
||||
num: -1,
|
||||
polar: false
|
||||
};
|
||||
},
|
||||
getParentObjects: CShape.prototype.getParentObjects,
|
||||
hitInPath: CShape.prototype.hitInPath,
|
||||
hitInInnerArea: CShape.prototype.hitInInnerArea,
|
||||
getRotateAngle: CShape.prototype.getRotateAngle,
|
||||
changeSize: CShape.prototype.changeSize,
|
||||
getFullFlipH: function () {
|
||||
if (!isRealObject(this.group)) {
|
||||
return this.flipH;
|
||||
}
|
||||
return this.group.getFullFlipH() ? !this.flipH : this.flipH;
|
||||
},
|
||||
getFullFlipV: function () {
|
||||
if (!isRealObject(this.group)) {
|
||||
return this.flipV;
|
||||
}
|
||||
return this.group.getFullFlipV() ? !this.flipV : this.flipV;
|
||||
},
|
||||
getAspect: function (num) {
|
||||
var _tmp_x = this.extX != 0 ? this.extX : 0.1;
|
||||
var _tmp_y = this.extY != 0 ? this.extY : 0.1;
|
||||
return num === 0 || num === 4 ? _tmp_x / _tmp_y : _tmp_y / _tmp_x;
|
||||
},
|
||||
getFullRotate: function () {
|
||||
return !isRealObject(this.group) ? this.rot : this.rot + this.group.getFullRotate();
|
||||
},
|
||||
getRectBounds: function () {
|
||||
var transform = this.getTransformMatrix();
|
||||
var w = this.extX;
|
||||
var h = this.extY;
|
||||
var rect_points = [{
|
||||
x: 0,
|
||||
y: 0
|
||||
},
|
||||
{
|
||||
x: w,
|
||||
y: 0
|
||||
},
|
||||
{
|
||||
x: w,
|
||||
y: h
|
||||
},
|
||||
{
|
||||
x: 0,
|
||||
y: h
|
||||
}];
|
||||
var min_x, max_x, min_y, max_y;
|
||||
min_x = transform.TransformPointX(rect_points[0].x, rect_points[0].y);
|
||||
min_y = transform.TransformPointY(rect_points[0].x, rect_points[0].y);
|
||||
max_x = min_x;
|
||||
max_y = min_y;
|
||||
var cur_x, cur_y;
|
||||
for (var i = 1; i < 4; ++i) {
|
||||
cur_x = transform.TransformPointX(rect_points[i].x, rect_points[i].y);
|
||||
cur_y = transform.TransformPointY(rect_points[i].x, rect_points[i].y);
|
||||
if (cur_x < min_x) {
|
||||
min_x = cur_x;
|
||||
}
|
||||
if (cur_x > max_x) {
|
||||
max_x = cur_x;
|
||||
}
|
||||
if (cur_y < min_y) {
|
||||
min_y = cur_y;
|
||||
}
|
||||
if (cur_y > max_y) {
|
||||
max_y = cur_y;
|
||||
}
|
||||
}
|
||||
return {
|
||||
minX: min_x,
|
||||
maxX: max_x,
|
||||
minY: min_y,
|
||||
maxY: max_y
|
||||
};
|
||||
},
|
||||
canRotate: function () {
|
||||
return true;
|
||||
},
|
||||
canResize: function () {
|
||||
return true;
|
||||
},
|
||||
canMove: function () {
|
||||
return true;
|
||||
},
|
||||
canGroup: function () {
|
||||
return true;
|
||||
},
|
||||
canChangeAdjustments: function () {
|
||||
return true;
|
||||
},
|
||||
createRotateTrack: function () {
|
||||
return new RotateTrackShapeImage(this);
|
||||
},
|
||||
createResizeTrack: function (cardDirection) {
|
||||
return new ResizeTrackShapeImage(this, cardDirection);
|
||||
},
|
||||
createMoveTrack: function () {
|
||||
return new MoveShapeImageTrack(this);
|
||||
},
|
||||
createRotateInGroupTrack: function () {
|
||||
return new RotateTrackShapeImageInGroup(this);
|
||||
},
|
||||
createResizeInGroupTrack: function (cardDirection) {
|
||||
return new ResizeTrackShapeImageInGroup(this, cardDirection);
|
||||
},
|
||||
createMoveInGroupTrack: function () {
|
||||
return new MoveShapeImageTrackInGroup(this);
|
||||
},
|
||||
getInvertTransform: function () {
|
||||
if (this.recalcInfo.recalculateTransform) {
|
||||
this.recalculateTransform();
|
||||
this.recalcInfo.recalculateTransform = true;
|
||||
}
|
||||
return this.invertTransform;
|
||||
},
|
||||
hitInTextRect: function (x, y) {
|
||||
return false;
|
||||
},
|
||||
getBase64Img: CShape.prototype.getBase64Img,
|
||||
convertToWord: function (document) {
|
||||
this.setBDeleted(true);
|
||||
var oCopy = this.copy();
|
||||
oCopy.setBDeleted(false);
|
||||
return oCopy;
|
||||
},
|
||||
convertToPPTX: function (drawingDocument, worksheet) {
|
||||
var ret = this.copy();
|
||||
ret.setWorksheet(worksheet);
|
||||
ret.setParent(null);
|
||||
ret.setBDeleted(false);
|
||||
return ret;
|
||||
},
|
||||
recalculateBrush: function () {
|
||||
var is_on = History.Is_On();
|
||||
if (is_on) {
|
||||
History.TurnOff();
|
||||
}
|
||||
this.brush = new CUniFill();
|
||||
this.brush.setFill(this.blipFill);
|
||||
if (is_on) {
|
||||
History.TurnOn();
|
||||
}
|
||||
},
|
||||
recalculatePen: function () {},
|
||||
getAllRasterImages: function (images) {
|
||||
this.blipFill && typeof this.blipFill.RasterImageId === "string" && this.blipFill.RasterImageId.length > 0 && images.push(this.blipFill.RasterImageId);
|
||||
},
|
||||
getHierarchy: function () {
|
||||
if (this.recalcInfo.recalculateShapeHierarchy) {
|
||||
this.compiledHierarchy.length = 0;
|
||||
var hierarchy = this.compiledHierarchy;
|
||||
if (this.isPlaceholder()) {
|
||||
var ph_type = this.getPlaceholderType();
|
||||
var ph_index = this.getPlaceholderIndex();
|
||||
var b_is_single_body = this.getIsSingleBody();
|
||||
switch (this.parent.kind) {
|
||||
case SLIDE_KIND:
|
||||
hierarchy.push(this.parent.Layout.getMatchingShape(ph_type, ph_index, b_is_single_body));
|
||||
hierarchy.push(this.parent.Layout.Master.getMatchingShape(ph_type, ph_index, b_is_single_body));
|
||||
break;
|
||||
case LAYOUT_KIND:
|
||||
hierarchy.push(this.parent.Master.getMatchingShape(ph_type, ph_index, b_is_single_body));
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.recalcInfo.recalculateShapeHierarchy = true;
|
||||
}
|
||||
return this.compiledHierarchy;
|
||||
},
|
||||
recalculateTransform: function () {
|
||||
this.cachedImage = null;
|
||||
if (!isRealObject(this.group)) {
|
||||
if (this.spPr.xfrm.isNotNull()) {
|
||||
var xfrm = this.spPr.xfrm;
|
||||
this.x = xfrm.offX;
|
||||
this.y = xfrm.offY;
|
||||
this.extX = xfrm.extX;
|
||||
this.extY = xfrm.extY;
|
||||
this.rot = isRealNumber(xfrm.rot) ? xfrm.rot : 0;
|
||||
this.flipH = xfrm.flipH === true;
|
||||
this.flipV = xfrm.flipV === true;
|
||||
} else {
|
||||
if (this.isPlaceholder()) {
|
||||
var hierarchy = this.getHierarchy();
|
||||
for (var i = 0; i < hierarchy.length; ++i) {
|
||||
var hierarchy_sp = hierarchy[i];
|
||||
if (isRealObject(hierarchy_sp) && hierarchy_sp.spPr.xfrm.isNotNull()) {
|
||||
var xfrm = hierarchy_sp.spPr.xfrm;
|
||||
this.x = xfrm.offX;
|
||||
this.y = xfrm.offY;
|
||||
this.extX = xfrm.extX;
|
||||
this.extY = xfrm.extY;
|
||||
this.rot = isRealNumber(xfrm.rot) ? xfrm.rot : 0;
|
||||
this.flipH = xfrm.flipH === true;
|
||||
this.flipV = xfrm.flipV === true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i === hierarchy.length) {
|
||||
this.x = 0;
|
||||
this.y = 0;
|
||||
this.extX = 5;
|
||||
this.extY = 5;
|
||||
this.rot = 0;
|
||||
this.flipH = false;
|
||||
this.flipV = false;
|
||||
}
|
||||
} else {
|
||||
this.x = 0;
|
||||
this.y = 0;
|
||||
this.extX = 5;
|
||||
this.extY = 5;
|
||||
this.rot = 0;
|
||||
this.flipH = false;
|
||||
this.flipV = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var xfrm;
|
||||
if (this.spPr.xfrm.isNotNull()) {
|
||||
xfrm = this.spPr.xfrm;
|
||||
} else {
|
||||
if (this.isPlaceholder()) {
|
||||
var hierarchy = this.getHierarchy();
|
||||
for (var i = 0; i < hierarchy.length; ++i) {
|
||||
var hierarchy_sp = hierarchy[i];
|
||||
if (isRealObject(hierarchy_sp) && hierarchy_sp.spPr.xfrm.isNotNull()) {
|
||||
xfrm = hierarchy_sp.spPr.xfrm;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i === hierarchy.length) {
|
||||
xfrm = new CXfrm();
|
||||
xfrm.offX = 0;
|
||||
xfrm.offX = 0;
|
||||
xfrm.extX = 5;
|
||||
xfrm.extY = 5;
|
||||
}
|
||||
} else {
|
||||
xfrm = new CXfrm();
|
||||
xfrm.offX = 0;
|
||||
xfrm.offY = 0;
|
||||
xfrm.extX = 5;
|
||||
xfrm.extY = 5;
|
||||
}
|
||||
}
|
||||
var scale_scale_coefficients = this.group.getResultScaleCoefficients();
|
||||
this.x = scale_scale_coefficients.cx * (xfrm.offX - this.group.spPr.xfrm.chOffX);
|
||||
this.y = scale_scale_coefficients.cy * (xfrm.offY - this.group.spPr.xfrm.chOffY);
|
||||
this.extX = scale_scale_coefficients.cx * xfrm.extX;
|
||||
this.extY = scale_scale_coefficients.cy * xfrm.extY;
|
||||
this.rot = isRealNumber(xfrm.rot) ? xfrm.rot : 0;
|
||||
this.flipH = xfrm.flipH === true;
|
||||
this.flipV = xfrm.flipV === true;
|
||||
}
|
||||
this.transform.Reset();
|
||||
var hc = this.extX * 0.5;
|
||||
var vc = this.extY * 0.5;
|
||||
global_MatrixTransformer.TranslateAppend(this.transform, -hc, -vc);
|
||||
if (this.flipH) {
|
||||
global_MatrixTransformer.ScaleAppend(this.transform, -1, 1);
|
||||
}
|
||||
if (this.flipV) {
|
||||
global_MatrixTransformer.ScaleAppend(this.transform, 1, -1);
|
||||
}
|
||||
global_MatrixTransformer.RotateRadAppend(this.transform, -this.rot);
|
||||
global_MatrixTransformer.TranslateAppend(this.transform, this.x + hc, this.y + vc);
|
||||
if (isRealObject(this.group)) {
|
||||
global_MatrixTransformer.MultiplyAppend(this.transform, this.group.getTransformMatrix());
|
||||
}
|
||||
this.invertTransform = global_MatrixTransformer.Invert(this.transform);
|
||||
if (this.drawingBase && !this.group) {
|
||||
this.drawingBase.setGraphicObjectCoords();
|
||||
}
|
||||
},
|
||||
Refresh_RecalcData: function (data) {
|
||||
switch (data.Type) {
|
||||
case historyitem_ImageShapeSetBlipFill:
|
||||
this.recalcBrush();
|
||||
this.recalcFill();
|
||||
this.addToRecalculate();
|
||||
break;
|
||||
}
|
||||
},
|
||||
recalculateGeometry: function () {
|
||||
if (isRealObject(this.spPr.geometry)) {
|
||||
var transform = this.getTransform();
|
||||
this.spPr.geometry.Recalculate(transform.extX, transform.extY);
|
||||
}
|
||||
},
|
||||
getTransformMatrix: function () {
|
||||
if (this.recalcInfo.recalculateTransform) {
|
||||
this.recalculateTransform();
|
||||
this.recalcInfo.recalculateTransform = false;
|
||||
}
|
||||
return this.transform;
|
||||
},
|
||||
getTransform: function () {
|
||||
if (this.recalcInfo.recalculateTransform) {
|
||||
this.recalculateTransform();
|
||||
this.recalcInfo.recalculateTransform = false;
|
||||
}
|
||||
return {
|
||||
x: this.x,
|
||||
y: this.y,
|
||||
extX: this.extX,
|
||||
extY: this.extY,
|
||||
rot: this.rot,
|
||||
flipH: this.flipH,
|
||||
flipV: this.flipV
|
||||
};
|
||||
},
|
||||
draw: function (graphics, transform) {
|
||||
if (graphics.updatedRect) {
|
||||
var rect = graphics.updatedRect;
|
||||
var bounds = this.bounds;
|
||||
if (bounds.x > rect.x + rect.w || bounds.y > rect.y + rect.h || bounds.x + bounds.w < rect.x || bounds.y + bounds.h < rect.y) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
var _transform = transform ? transform : this.transform;
|
||||
graphics.SetIntegerGrid(false);
|
||||
graphics.transform3(_transform, false);
|
||||
var shape_drawer = new CShapeDrawer();
|
||||
shape_drawer.fromShape2(this, graphics, this.spPr.geometry);
|
||||
shape_drawer.draw(this.spPr.geometry);
|
||||
if (locktype_None != this.Lock.Get_Type() && !this.group) {
|
||||
graphics.DrawLockObjectRect(this.Lock.Get_Type(), 0, 0, this.extX, this.extY);
|
||||
}
|
||||
graphics.reset();
|
||||
graphics.SetIntegerGrid(true);
|
||||
},
|
||||
select: CShape.prototype.select,
|
||||
recalculateLocalTransform: CShape.prototype.recalculateLocalTransform,
|
||||
deselect: function (drawingObjectsController) {
|
||||
this.selected = false;
|
||||
var selected_objects;
|
||||
if (!isRealObject(this.group)) {
|
||||
selected_objects = drawingObjectsController.selectedObjects;
|
||||
} else {
|
||||
selected_objects = this.group.getMainGroup().selectedObjects;
|
||||
}
|
||||
for (var i = 0; i < selected_objects.length; ++i) {
|
||||
if (selected_objects[i] === this) {
|
||||
selected_objects.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
},
|
||||
getMainGroup: function () {
|
||||
if (!isRealObject(this.group)) {
|
||||
return null;
|
||||
}
|
||||
var cur_group = this.group;
|
||||
while (isRealObject(cur_group.group)) {
|
||||
cur_group = cur_group.group;
|
||||
}
|
||||
return cur_group;
|
||||
},
|
||||
drawAdjustments: function (drawingDocument) {},
|
||||
hitToAdjustment: function () {
|
||||
return {
|
||||
hit: false
|
||||
};
|
||||
},
|
||||
getPlaceholderType: function () {
|
||||
return this.isPlaceholder() ? this.nvPicPr.nvPr.ph.type : null;
|
||||
},
|
||||
getPlaceholderIndex: function () {
|
||||
return this.isPlaceholder() ? this.nvPicPr.nvPr.ph.idx : null;
|
||||
},
|
||||
getPhType: function () {
|
||||
return this.isPlaceholder() ? this.nvPicPr.nvPr.ph.type : null;
|
||||
},
|
||||
getPhIndex: function () {
|
||||
return this.isPlaceholder() ? this.nvPicPr.nvPr.ph.idx : null;
|
||||
},
|
||||
setNvSpPr: function (pr) {
|
||||
History.Add(this, {
|
||||
Type: historyitem_ImageShapeSetNvPicPr,
|
||||
oldPr: this.nvPicPr,
|
||||
newPr: pr
|
||||
});
|
||||
this.nvPicPr = pr;
|
||||
},
|
||||
getAllImages: function (images) {
|
||||
if (this.blipFill instanceof CBlipFill && typeof this.blipFill.RasterImageId === "string") {
|
||||
images[_getFullImageSrc(this.blipFill.RasterImageId)] = true;
|
||||
}
|
||||
},
|
||||
Undo: function (data) {
|
||||
switch (data.Type) {
|
||||
case historyitem_AutoShapes_RemoveFromDrawingObjects:
|
||||
addToDrawings(this.worksheet, this, data.Pos);
|
||||
break;
|
||||
case historyitem_AutoShapes_AddToDrawingObjects:
|
||||
deleteDrawingBase(this.worksheet.Drawings, this.Get_Id());
|
||||
break;
|
||||
case historyitem_AutoShapes_SetWorksheet:
|
||||
this.worksheet = data.oldPr;
|
||||
break;
|
||||
case historyitem_ShapeSetBDeleted:
|
||||
this.bDeleted = data.oldPr;
|
||||
break;
|
||||
case historyitem_ImageShapeSetNvPicPr:
|
||||
this.nvPicPr = data.oldPr;
|
||||
break;
|
||||
case historyitem_ImageShapeSetSpPr:
|
||||
this.spPr = data.oldPr;
|
||||
break;
|
||||
case historyitem_ImageShapeSetBlipFill:
|
||||
this.blipFill = data.oldPr;
|
||||
break;
|
||||
case historyitem_ImageShapeSetParent:
|
||||
this.parent = data.oldPr;
|
||||
break;
|
||||
case historyitem_ImageShapeSetGroup:
|
||||
this.group = data.oldPr;
|
||||
break;
|
||||
case historyitem_ImageShapeSetStyle:
|
||||
this.style = data.oldPr;
|
||||
break;
|
||||
}
|
||||
},
|
||||
Redo: function (data) {
|
||||
switch (data.Type) {
|
||||
case historyitem_AutoShapes_RemoveFromDrawingObjects:
|
||||
deleteDrawingBase(this.worksheet.Drawings, this.Get_Id());
|
||||
break;
|
||||
case historyitem_AutoShapes_AddToDrawingObjects:
|
||||
addToDrawings(this.worksheet, this, data.Pos);
|
||||
break;
|
||||
case historyitem_AutoShapes_SetWorksheet:
|
||||
this.worksheet = data.newPr;
|
||||
break;
|
||||
case historyitem_ShapeSetBDeleted:
|
||||
this.bDeleted = data.newPr;
|
||||
break;
|
||||
case historyitem_ImageShapeSetNvPicPr:
|
||||
this.nvPicPr = data.newPr;
|
||||
break;
|
||||
case historyitem_ImageShapeSetSpPr:
|
||||
this.spPr = data.newPr;
|
||||
break;
|
||||
case historyitem_ImageShapeSetBlipFill:
|
||||
this.blipFill = data.newPr;
|
||||
break;
|
||||
case historyitem_ImageShapeSetParent:
|
||||
this.parent = data.newPr;
|
||||
break;
|
||||
case historyitem_ImageShapeSetGroup:
|
||||
this.group = data.newPr;
|
||||
break;
|
||||
case historyitem_ImageShapeSetStyle:
|
||||
this.style = data.newPr;
|
||||
break;
|
||||
}
|
||||
},
|
||||
Save_Changes: function (data, w) {
|
||||
w.WriteLong(data.Type);
|
||||
switch (data.Type) {
|
||||
case historyitem_AutoShapes_SetDrawingBaseCoors:
|
||||
writeDouble(w, data.fromCol);
|
||||
writeDouble(w, data.fromColOff);
|
||||
writeDouble(w, data.fromRow);
|
||||
writeDouble(w, data.fromRowOff);
|
||||
writeDouble(w, data.toCol);
|
||||
writeDouble(w, data.toColOff);
|
||||
writeDouble(w, data.toRow);
|
||||
writeDouble(w, data.toRowOff);
|
||||
writeDouble(w, data.posX);
|
||||
writeDouble(w, data.posY);
|
||||
writeDouble(w, data.cx);
|
||||
writeDouble(w, data.cy);
|
||||
break;
|
||||
case historyitem_AutoShapes_RemoveFromDrawingObjects:
|
||||
break;
|
||||
case historyitem_AutoShapes_AddToDrawingObjects:
|
||||
var Pos = data.UseArray ? data.PosArray[0] : data.Pos;
|
||||
writeLong(w, Pos);
|
||||
break;
|
||||
case historyitem_AutoShapes_SetWorksheet:
|
||||
writeBool(w, isRealObject(data.newPr));
|
||||
if (isRealObject(data.newPr)) {
|
||||
writeString(w, data.newPr.getId());
|
||||
}
|
||||
break;
|
||||
case historyitem_ImageShapeSetNvPicPr:
|
||||
case historyitem_ImageShapeSetSpPr:
|
||||
case historyitem_ImageShapeSetParent:
|
||||
case historyitem_ImageShapeSetGroup:
|
||||
case historyitem_ImageShapeSetStyle:
|
||||
writeObject(w, data.newPr);
|
||||
break;
|
||||
case historyitem_ShapeSetBDeleted:
|
||||
writeBool(w, data.newPr);
|
||||
break;
|
||||
case historyitem_ImageShapeSetBlipFill:
|
||||
w.WriteBool(isRealObject(data.newPr));
|
||||
if (isRealObject(data.newPr)) {
|
||||
data.newPr.Write_ToBinary(w);
|
||||
}
|
||||
break;
|
||||
}
|
||||
},
|
||||
Load_Changes: function (r) {
|
||||
var type = r.GetLong();
|
||||
switch (type) {
|
||||
case historyitem_AutoShapes_SetDrawingBaseCoors:
|
||||
if (this.drawingBase) {
|
||||
this.drawingBase.from.col = readDouble(r);
|
||||
this.drawingBase.from.colOff = readDouble(r);
|
||||
this.drawingBase.from.row = readDouble(r);
|
||||
this.drawingBase.from.rowOff = readDouble(r);
|
||||
this.drawingBase.to.col = readDouble(r);
|
||||
this.drawingBase.to.colOff = readDouble(r);
|
||||
this.drawingBase.to.row = readDouble(r);
|
||||
this.drawingBase.to.rowOff = readDouble(r);
|
||||
this.drawingBase.Pos.X = readDouble(r);
|
||||
this.drawingBase.Pos.Y = readDouble(r);
|
||||
this.drawingBase.ext.cx = readDouble(r);
|
||||
this.drawingBase.ext.cy = readDouble(r);
|
||||
}
|
||||
break;
|
||||
case historyitem_AutoShapes_RemoveFromDrawingObjects:
|
||||
deleteDrawingBase(this.worksheet.Drawings, this.Get_Id());
|
||||
break;
|
||||
case historyitem_AutoShapes_AddToDrawingObjects:
|
||||
var pos = readLong(r);
|
||||
if (this.worksheet) {
|
||||
pos = this.worksheet.contentChanges.Check(contentchanges_Add, pos);
|
||||
}
|
||||
addToDrawings(this.worksheet, this, pos);
|
||||
break;
|
||||
case historyitem_AutoShapes_SetWorksheet:
|
||||
ReadWBModel(this, r);
|
||||
break;
|
||||
case historyitem_ShapeSetBDeleted:
|
||||
this.bDeleted = readBool(r);
|
||||
break;
|
||||
case historyitem_ImageShapeSetNvPicPr:
|
||||
this.nvPicPr = readObject(r);
|
||||
break;
|
||||
case historyitem_ImageShapeSetSpPr:
|
||||
this.spPr = readObject(r);
|
||||
break;
|
||||
case historyitem_ImageShapeSetBlipFill:
|
||||
if (r.GetBool()) {
|
||||
this.blipFill = new CBlipFill();
|
||||
r.GetLong();
|
||||
this.blipFill.Read_FromBinary(r);
|
||||
if (typeof CollaborativeEditing !== "undefined") {
|
||||
if (typeof this.blipFill.RasterImageId === "string" && this.blipFill.RasterImageId.length > 0) {
|
||||
var full_image_src_func;
|
||||
if ((!editor || !editor.isDocumentEditor && !editor.isPresentationEditor) && typeof getFullImageSrc === "function") {
|
||||
full_image_src_func = getFullImageSrc;
|
||||
} else {
|
||||
if (typeof _getFullImageSrc === "function") {
|
||||
full_image_src_func = _getFullImageSrc;
|
||||
}
|
||||
}
|
||||
if (full_image_src_func) {
|
||||
CollaborativeEditing.Add_NewImage(full_image_src_func(this.blipFill.RasterImageId));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.blipFill = null;
|
||||
}
|
||||
this.handleUpdateFill();
|
||||
break;
|
||||
case historyitem_ImageShapeSetParent:
|
||||
this.parent = readObject(r);
|
||||
break;
|
||||
case historyitem_ImageShapeSetGroup:
|
||||
this.group = readObject(r);
|
||||
break;
|
||||
case historyitem_ImageShapeSetStyle:
|
||||
this.style = readObject(r);
|
||||
break;
|
||||
}
|
||||
},
|
||||
Load_LinkData: function (linkData) {}
|
||||
};
|
||||
1034
OfficeWeb/sdk/Common/Drawings/Format/Path.js
Normal file
1034
OfficeWeb/sdk/Common/Drawings/Format/Path.js
Normal file
File diff suppressed because it is too large
Load Diff
3338
OfficeWeb/sdk/Common/Drawings/Format/Shape.js
Normal file
3338
OfficeWeb/sdk/Common/Drawings/Format/Shape.js
Normal file
File diff suppressed because it is too large
Load Diff
619
OfficeWeb/sdk/Common/Drawings/Format/TextBody.js
Normal file
619
OfficeWeb/sdk/Common/Drawings/Format/TextBody.js
Normal file
@@ -0,0 +1,619 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2015
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
"use strict";
|
||||
var field_type_slidenum = 0;
|
||||
var field_type_datetime = 1;
|
||||
var field_type_datetime1 = 2;
|
||||
var field_type_datetime2 = 3;
|
||||
var field_type_datetime3 = 4;
|
||||
var field_type_datetime4 = 5;
|
||||
var field_type_datetime5 = 6;
|
||||
var field_type_datetime6 = 7;
|
||||
var field_type_datetime7 = 8;
|
||||
var field_type_datetime8 = 9;
|
||||
var field_type_datetime9 = 10;
|
||||
var field_type_datetime10 = 11;
|
||||
var field_type_datetime11 = 12;
|
||||
var field_type_datetime12 = 13;
|
||||
var field_type_datetime13 = 14;
|
||||
var pHText = [];
|
||||
pHText[0] = [];
|
||||
pHText[0][phType_body] = "Slide text";
|
||||
pHText[0][phType_chart] = "Chart";
|
||||
pHText[0][phType_clipArt] = "ClipArt";
|
||||
pHText[0][phType_ctrTitle] = "Slide title";
|
||||
pHText[0][phType_dgm] = "Diagram";
|
||||
pHText[0][phType_dt] = "Date and time";
|
||||
pHText[0][phType_ftr] = "Footer";
|
||||
pHText[0][phType_hdr] = "Header";
|
||||
pHText[0][phType_media] = "Media";
|
||||
pHText[0][phType_obj] = "Slide text";
|
||||
pHText[0][phType_pic] = "Picture";
|
||||
pHText[0][phType_sldImg] = "Image";
|
||||
pHText[0][phType_sldNum] = "Slide number";
|
||||
pHText[0][phType_subTitle] = "Slide subtitle";
|
||||
pHText[0][phType_tbl] = "Table";
|
||||
pHText[0][phType_title] = "Slide title";
|
||||
var field_months = [];
|
||||
field_months[0] = [];
|
||||
field_months[0][0] = "января";
|
||||
field_months[0][1] = "февраля";
|
||||
field_months[0][2] = "марта";
|
||||
field_months[0][3] = "апреля";
|
||||
field_months[0][4] = "мая";
|
||||
field_months[0][5] = "июня";
|
||||
field_months[0][6] = "июля";
|
||||
field_months[0][7] = "августа";
|
||||
field_months[0][8] = "сентября";
|
||||
field_months[0][9] = "октября";
|
||||
field_months[0][10] = "ноября";
|
||||
field_months[0][11] = "декабря";
|
||||
var nOTClip = 0;
|
||||
var nOTEllipsis = 1;
|
||||
var nOTOwerflow = 2;
|
||||
var nTextATB = 0;
|
||||
var nTextATCtr = 1;
|
||||
var nTextATDist = 2;
|
||||
var nTextATJust = 3;
|
||||
var nTextATT = 4;
|
||||
var nVertTTeaVert = 0;
|
||||
var nVertTThorz = 1;
|
||||
var nVertTTmongolianVert = 2;
|
||||
var nVertTTvert = 3;
|
||||
var nVertTTvert270 = 4;
|
||||
var nVertTTwordArtVert = 5;
|
||||
var nVertTTwordArtVertRtl = 6;
|
||||
var nTWTNone = 0;
|
||||
var nTWTSquare = 1;
|
||||
function CTextBody() {
|
||||
this.bodyPr = null;
|
||||
this.lstStyle = null;
|
||||
this.content = null;
|
||||
this.parent = null;
|
||||
this.content2 = null;
|
||||
this.compiledBodyPr = null;
|
||||
this.parent = null;
|
||||
this.recalcInfo = {
|
||||
recalculateBodyPr: true,
|
||||
recalculateContent2: true
|
||||
};
|
||||
this.textPropsForRecalc = [];
|
||||
this.bRecalculateNumbering = true;
|
||||
this.Id = g_oIdCounter.Get_NewId();
|
||||
g_oTableId.Add(this, this.Id);
|
||||
}
|
||||
CTextBody.prototype = {
|
||||
createDuplicate: function () {
|
||||
var ret = new CTextBody();
|
||||
if (this.bodyPr) {
|
||||
ret.setBodyPr(this.bodyPr.createDuplicate());
|
||||
}
|
||||
if (this.lstStyle) {
|
||||
ret.setLstStyle(this.lstStyle.createDuplicate());
|
||||
}
|
||||
if (this.content) {
|
||||
ret.setContent(this.content.Copy(ret, NEW_WORKSHEET_DRAWING_DOCUMENT));
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
createDuplicate2: function () {
|
||||
var ret = new CTextBody();
|
||||
if (this.bodyPr) {
|
||||
ret.setBodyPr(this.bodyPr.createDuplicate());
|
||||
}
|
||||
if (this.lstStyle) {
|
||||
ret.setLstStyle(this.lstStyle.createDuplicate());
|
||||
}
|
||||
if (this.content) {
|
||||
ret.setContent(this.content.Copy3(ret));
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
Get_Id: function () {
|
||||
return this.Id;
|
||||
},
|
||||
Is_TopDocument: function () {
|
||||
return false;
|
||||
},
|
||||
Is_DrawingShape: function () {
|
||||
return true;
|
||||
},
|
||||
Get_Theme: function () {
|
||||
return this.parent.Get_Theme();
|
||||
},
|
||||
Get_ColorMap: function () {
|
||||
return this.parent.Get_ColorMap();
|
||||
},
|
||||
setParent: function (pr) {
|
||||
History.Add(this, {
|
||||
Type: historyitem_TextBodySetParent,
|
||||
oldPr: this.parent,
|
||||
newPr: pr
|
||||
});
|
||||
this.parent = pr;
|
||||
},
|
||||
setBodyPr: function (pr) {
|
||||
History.Add(this, {
|
||||
Type: historyitem_TextBodySetBodyPr,
|
||||
oldPr: this.bodyPr,
|
||||
newPr: pr
|
||||
});
|
||||
this.bodyPr = pr;
|
||||
if (this.parent && this.parent.recalcInfo) {
|
||||
this.parent.recalcInfo.recalcContent = true;
|
||||
this.parent.recalcInfo.recalcTransformText = true;
|
||||
if (this.parent.addToRecalculate) {
|
||||
this.parent.addToRecalculate();
|
||||
}
|
||||
}
|
||||
if (this.parent && this.parent.parent && this.parent.parent.parent && this.parent.parent.parent.parent && this.parent.parent.parent.parent.parent && this.parent.parent.parent.parent.parent.handleUpdateInternalChart && History && History.Is_On && History.Is_On()) {
|
||||
this.parent.parent.parent.parent.parent.handleUpdateInternalChart();
|
||||
}
|
||||
},
|
||||
setContent: function (pr) {
|
||||
History.Add(this, {
|
||||
Type: historyitem_TextBodySetContent,
|
||||
oldPr: this.content,
|
||||
newPr: pr
|
||||
});
|
||||
this.content = pr;
|
||||
},
|
||||
setLstStyle: function (lstStyle) {
|
||||
History.Add(this, {
|
||||
Type: historyitem_TextBodySetLstStyle,
|
||||
oldPr: this.lstStyle,
|
||||
newPr: lstStyle
|
||||
});
|
||||
this.lstStyle = lstStyle;
|
||||
},
|
||||
getObjectType: function () {
|
||||
return historyitem_type_TextBody;
|
||||
},
|
||||
Undo: function (data) {
|
||||
switch (data.Type) {
|
||||
case historyitem_TextBodySetParent:
|
||||
this.parent = data.oldPr;
|
||||
break;
|
||||
case historyitem_TextBodySetBodyPr:
|
||||
this.bodyPr = data.oldPr;
|
||||
if (this.parent && this.parent.parent && this.parent.parent.parent && this.parent.parent.parent.parent && this.parent.parent.parent.parent.parent && this.parent.parent.parent.parent.parent.handleUpdateInternalChart) {
|
||||
this.parent.parent.parent.parent.parent.handleUpdateInternalChart();
|
||||
}
|
||||
break;
|
||||
case historyitem_TextBodySetContent:
|
||||
this.content = data.oldPr;
|
||||
break;
|
||||
case historyitem_TextBodySetLstStyle:
|
||||
this.lstStyle = data.oldPr;
|
||||
break;
|
||||
}
|
||||
},
|
||||
Redo: function (data) {
|
||||
switch (data.Type) {
|
||||
case historyitem_TextBodySetParent:
|
||||
this.parent = data.newPr;
|
||||
break;
|
||||
case historyitem_TextBodySetBodyPr:
|
||||
this.bodyPr = data.newPr;
|
||||
if (this.parent && this.parent.parent && this.parent.parent.parent && this.parent.parent.parent.parent && this.parent.parent.parent.parent.parent && this.parent.parent.parent.parent.parent.handleUpdateInternalChart) {
|
||||
this.parent.parent.parent.parent.parent.handleUpdateInternalChart();
|
||||
}
|
||||
break;
|
||||
case historyitem_TextBodySetContent:
|
||||
this.content = data.newPr;
|
||||
break;
|
||||
case historyitem_TextBodySetLstStyle:
|
||||
this.lstStyle = data.newPr;
|
||||
break;
|
||||
}
|
||||
},
|
||||
Save_Changes: function (data, w) {
|
||||
w.WriteLong(historyitem_type_TextBody);
|
||||
w.WriteLong(data.Type);
|
||||
switch (data.Type) {
|
||||
case historyitem_TextBodySetParent:
|
||||
case historyitem_TextBodySetContent:
|
||||
writeObject(w, data.newPr);
|
||||
break;
|
||||
case historyitem_TextBodySetBodyPr:
|
||||
case historyitem_TextBodySetLstStyle:
|
||||
w.WriteBool(isRealObject(data.newPr));
|
||||
if (isRealObject(data.newPr)) {
|
||||
data.newPr.Write_ToBinary(w);
|
||||
}
|
||||
break;
|
||||
}
|
||||
},
|
||||
Load_Changes: function (r) {
|
||||
if (r.GetLong() === historyitem_type_TextBody) {
|
||||
var type = r.GetLong();
|
||||
switch (type) {
|
||||
case historyitem_TextBodySetParent:
|
||||
this.parent = readObject(r);
|
||||
break;
|
||||
case historyitem_TextBodySetBodyPr:
|
||||
if (r.GetBool()) {
|
||||
this.bodyPr = new CBodyPr();
|
||||
this.bodyPr.Read_FromBinary(r);
|
||||
} else {
|
||||
this.bodyPr = null;
|
||||
}
|
||||
if (this.parent && this.parent.parent && this.parent.parent.parent && this.parent.parent.parent.parent && this.parent.parent.parent.parent.parent && this.parent.parent.parent.parent.parent.handleUpdateInternalChart) {
|
||||
this.parent.parent.parent.parent.parent.handleUpdateInternalChart();
|
||||
}
|
||||
break;
|
||||
case historyitem_TextBodySetContent:
|
||||
this.content = readObject(r);
|
||||
break;
|
||||
case historyitem_TextBodySetLstStyle:
|
||||
if (r.GetBool()) {
|
||||
this.lstStyle = new TextListStyle();
|
||||
this.lstStyle.Read_FromBinary(r);
|
||||
} else {
|
||||
this.bodyPr = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
Write_ToBinary2: function (w) {
|
||||
w.WriteLong(historyitem_type_TextBody);
|
||||
w.WriteString2(this.Id);
|
||||
},
|
||||
Read_FromBinary2: function (r) {
|
||||
this.Id = r.GetString2();
|
||||
},
|
||||
recalculate: function () {},
|
||||
getFieldText: function (fieldType, slide, firstSlideNum) {
|
||||
var ret = "";
|
||||
if (this.parent && this.parent.isPlaceholder()) {
|
||||
var _ph_type = this.parent.getPlaceholderType();
|
||||
switch (_ph_type) {
|
||||
case phType_dt:
|
||||
var _cur_date = new Date();
|
||||
var _cur_year = _cur_date.getFullYear();
|
||||
var _cur_month = _cur_date.getMonth();
|
||||
var _cur_month_day = _cur_date.getDate();
|
||||
ret += (_cur_month_day > 9 ? _cur_month_day : "0" + _cur_month_day) + "." + ((_cur_month + 1) > 9 ? (_cur_month + 1) : "0" + (_cur_month + 1)) + "." + _cur_year;
|
||||
break;
|
||||
case phType_sldNum:
|
||||
var _firstSlideNum = isRealNumber(firstSlideNum) ? firstSlideNum : 1;
|
||||
if (slide instanceof Slide) {
|
||||
ret += "" + (slide.num + _firstSlideNum);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
recalculateBodyPr: function () {
|
||||
ExecuteNoHistory(function () {
|
||||
if (!this.compiledBodyPr) {
|
||||
this.compiledBodyPr = new CBodyPr();
|
||||
}
|
||||
this.compiledBodyPr.setDefault();
|
||||
if (this.parent && this.parent.isPlaceholder && this.parent.isPlaceholder()) {
|
||||
var hierarchy = this.parent.getHierarchy();
|
||||
for (var i = hierarchy.length - 1; i > -1; --i) {
|
||||
if (isRealObject(hierarchy[i]) && isRealObject(hierarchy[i].txBody) && isRealObject(hierarchy[i].txBody.bodyPr)) {
|
||||
this.compiledBodyPr.merge(hierarchy[i].txBody.bodyPr);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isRealObject(this.bodyPr)) {
|
||||
this.compiledBodyPr.merge(this.bodyPr);
|
||||
}
|
||||
},
|
||||
this, []);
|
||||
},
|
||||
checkTextFit: function () {
|
||||
if (this.parent && this.parent.parent && this.parent.parent instanceof Slide) {
|
||||
if (isRealObject(this.bodyPr.textFit)) {
|
||||
if (this.bodyPr.textFit.type === text_fit_NormAuto) {
|
||||
var text_fit = this.bodyPr.textFit;
|
||||
var font_scale, spacing_scale;
|
||||
if (isRealNumber(text_fit.fontScale)) {
|
||||
font_scale = text_fit.fontScale / 100000;
|
||||
}
|
||||
if (isRealNumber(text_fit.lnSpcReduction)) {
|
||||
spacing_scale = text_fit.lnSpcReduction / 100000;
|
||||
}
|
||||
if (isRealNumber(font_scale) || isRealNumber(spacing_scale)) {
|
||||
var pars = this.content.Content;
|
||||
for (var index = 0; index < pars.length; ++index) {
|
||||
var parg = pars[index];
|
||||
if (isRealNumber(spacing_scale)) {
|
||||
var spacing2 = parg.Get_CompiledPr(false).ParaPr.Spacing;
|
||||
var new_spacing = {};
|
||||
var spc = spacing2.Line * spacing_scale;
|
||||
new_spacing.LineRule = spacing2.LineRule;
|
||||
if (isRealNumber(spc)) {
|
||||
if (spacing2.LineRule === linerule_Auto) {
|
||||
new_spacing.Line = spacing2.Line - spacing_scale;
|
||||
} else {
|
||||
new_spacing.Line = spc;
|
||||
}
|
||||
}
|
||||
spc = spacing2.Before * spacing_scale;
|
||||
if (isRealNumber(spc)) {
|
||||
new_spacing.Before = spc;
|
||||
}
|
||||
spc = spacing2.After * spacing_scale;
|
||||
if (isRealNumber(spc)) {
|
||||
new_spacing.After = spc;
|
||||
}
|
||||
parg.Set_Spacing(new_spacing);
|
||||
}
|
||||
if (isRealNumber(font_scale)) {
|
||||
var redFontSize = Math.round(parg.Get_CompiledPr(false).TextPr.FontSize * font_scale);
|
||||
this.checkParagraphContent(parg, font_scale, true, redFontSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.bodyPr.textFit = null;
|
||||
},
|
||||
checkParagraphContent: function (parg, fontScale, bParagraph, paragrRedFontSize) {
|
||||
for (var r = 0; r < parg.Content.length; ++r) {
|
||||
var item = parg.Content[r];
|
||||
switch (item.Type) {
|
||||
case para_Run:
|
||||
if (isRealNumber(item.Pr.FontSize)) {
|
||||
item.Set_FontSize(Math.round(item.Pr.FontSize * fontScale));
|
||||
} else {
|
||||
item.Set_FontSize(paragrRedFontSize);
|
||||
}
|
||||
break;
|
||||
case para_Hyperlink:
|
||||
this.checkParagraphContent(item, fontScale, false, paragrRedFontSize);
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
Refresh_RecalcData: function () {
|
||||
if (this.parent && this.parent.recalcInfo) {
|
||||
this.parent.recalcInfo.recalcContent = true;
|
||||
this.parent.recalcInfo.recalcTransformText = true;
|
||||
this.parent.recalcInfo.recalculateContent = true;
|
||||
this.parent.recalcInfo.recalculateTransformText = true;
|
||||
if (this.parent.addToRecalculate) {
|
||||
this.parent.addToRecalculate();
|
||||
}
|
||||
}
|
||||
},
|
||||
isEmpty: function () {
|
||||
return this.content.Is_Empty();
|
||||
},
|
||||
OnContentReDraw: function () {},
|
||||
Get_StartPage_Absolute: function () {
|
||||
return 0;
|
||||
},
|
||||
Get_TextBackGroundColor: function () {
|
||||
return undefined;
|
||||
},
|
||||
Is_HdrFtr: function () {
|
||||
return false;
|
||||
},
|
||||
Get_PageContentStartPos: function (pageNum) {
|
||||
return {
|
||||
X: 0,
|
||||
Y: 0,
|
||||
XLimit: this.contentWidth,
|
||||
YLimit: 20000
|
||||
};
|
||||
},
|
||||
Get_Numbering: function () {
|
||||
return new CNumbering();
|
||||
},
|
||||
Set_CurrentElement: function (bUpdate, pageIndex) {
|
||||
if (this.parent.Set_CurrentElement) {
|
||||
this.parent.Set_CurrentElement(bUpdate, pageIndex);
|
||||
}
|
||||
},
|
||||
checkDocContent: function () {
|
||||
this.parent && this.parent.checkDocContent && this.parent.checkDocContent();
|
||||
},
|
||||
getBodyPr: function () {
|
||||
if (this.recalcInfo.recalculateBodyPr) {
|
||||
this.recalculateBodyPr();
|
||||
this.recalcInfo.recalculateBodyPr = false;
|
||||
}
|
||||
return this.compiledBodyPr;
|
||||
},
|
||||
getSummaryHeight: function () {
|
||||
return this.content.Get_SummaryHeight();
|
||||
},
|
||||
getSummaryHeight2: function () {
|
||||
return this.content2 ? this.content2.Get_SummaryHeight() : 0;
|
||||
},
|
||||
getCompiledBodyPr: function () {
|
||||
this.recalculateBodyPr();
|
||||
return this.compiledBodyPr;
|
||||
},
|
||||
Get_TableStyleForPara: function () {
|
||||
return null;
|
||||
},
|
||||
checkCurrentPlaceholder: function () {
|
||||
return false;
|
||||
},
|
||||
draw: function (graphics) {
|
||||
if ((!this.content || this.content.Is_Empty()) && this.parent.isEmptyPlaceholder() && !this.checkCurrentPlaceholder()) {
|
||||
if (graphics.IsNoDrawingEmptyPlaceholder !== true && graphics.IsNoDrawingEmptyPlaceholderText !== true && this.content2) {
|
||||
if (graphics.IsNoSupportTextDraw) {
|
||||
var _w2 = this.content2.XLimit;
|
||||
var _h2 = this.content2.Get_SummaryHeight();
|
||||
graphics.rect(this.content2.X, this.content2.Y, _w2, _h2);
|
||||
}
|
||||
this.content2.Set_StartPage(0);
|
||||
this.content2.Draw(0, graphics);
|
||||
}
|
||||
} else {
|
||||
if (this.content) {
|
||||
if (graphics.IsNoSupportTextDraw) {
|
||||
var _w = this.content.XLimit;
|
||||
var _h = this.content.Get_SummaryHeight();
|
||||
graphics.rect(this.content.X, this.content.Y, _w, _h);
|
||||
}
|
||||
var old_start_page = this.content.StartPage;
|
||||
this.content.Set_StartPage(0);
|
||||
this.content.Draw(0, graphics);
|
||||
this.content.Set_StartPage(old_start_page);
|
||||
}
|
||||
}
|
||||
},
|
||||
Get_Styles: function (level) {
|
||||
return this.parent.getStyles(level);
|
||||
},
|
||||
Is_Cell: function () {
|
||||
return false;
|
||||
},
|
||||
OnContentRecalculate: function () {},
|
||||
getMargins: function () {
|
||||
var _parent_transform = this.parent.transform;
|
||||
var _l;
|
||||
var _r;
|
||||
var _b;
|
||||
var _t;
|
||||
var _body_pr = this.getBodyPr();
|
||||
var sp = this.parent;
|
||||
if (isRealObject(sp.spPr) && isRealObject(sp.spPr.geometry) && isRealObject(sp.spPr.geometry.rect)) {
|
||||
var _rect = sp.spPr.geometry.rect;
|
||||
_l = _rect.l + _body_pr.lIns;
|
||||
_t = _rect.t + _body_pr.tIns;
|
||||
_r = _rect.r - _body_pr.rIns;
|
||||
_b = _rect.b - _body_pr.bIns;
|
||||
} else {
|
||||
_l = _body_pr.lIns;
|
||||
_t = _body_pr.tIns;
|
||||
_r = sp.extX - _body_pr.rIns;
|
||||
_b = sp.extY - _body_pr.bIns;
|
||||
}
|
||||
var x_lt, y_lt, x_rb, y_rb;
|
||||
x_lt = _parent_transform.TransformPointX(_l, _t);
|
||||
y_lt = _parent_transform.TransformPointY(_l, _t);
|
||||
x_rb = _parent_transform.TransformPointX(_r, _b);
|
||||
y_rb = _parent_transform.TransformPointY(_r, _b);
|
||||
var hc = (_r - _l) / 2;
|
||||
var vc = (_b - _t) / 2;
|
||||
var xc = (x_lt + x_rb) / 2;
|
||||
var yc = (y_lt + y_rb) / 2;
|
||||
return {
|
||||
L: xc - hc,
|
||||
T: yc - vc,
|
||||
R: xc + hc,
|
||||
B: yc + vc,
|
||||
textMatrix: this.parent.transform
|
||||
};
|
||||
},
|
||||
Refresh_RecalcData2: function (pageIndex) {
|
||||
this.parent && this.parent.Refresh_RecalcData2 && this.parent.Refresh_RecalcData2(pageIndex, this);
|
||||
},
|
||||
getContentOneStringSizes: function () {
|
||||
this.content.Reset(0, 0, 20000, 20000);
|
||||
this.content.Recalculate_Page(0, true);
|
||||
return {
|
||||
w: this.content.Content[0].Lines[0].Ranges[0].W + 0.1,
|
||||
h: this.content.Get_SummaryHeight() + 0.1
|
||||
};
|
||||
},
|
||||
recalculateByMaxWord: function () {
|
||||
var max_content = this.content.Recalculate_MinMaxContentWidth().Max;
|
||||
this.content.Set_ApplyToAll(true);
|
||||
this.content.Set_ParagraphAlign(align_Center);
|
||||
this.content.Set_ApplyToAll(false);
|
||||
this.content.Reset(0, 0, max_content, 20000);
|
||||
this.content.Recalculate_Page(0, true);
|
||||
return {
|
||||
w: max_content,
|
||||
h: this.content.Get_SummaryHeight()
|
||||
};
|
||||
},
|
||||
getRectWidth: function (maxWidth) {
|
||||
var body_pr = this.getBodyPr();
|
||||
var r_ins = body_pr.rIns;
|
||||
var l_ins = body_pr.lIns;
|
||||
var max_content_width = maxWidth - r_ins - l_ins;
|
||||
this.content.Reset(0, 0, max_content_width, 20000);
|
||||
this.content.Recalculate_Page(0, true);
|
||||
var max_width = 0;
|
||||
for (var i = 0; i < this.content.Content.length; ++i) {
|
||||
var par = this.content.Content[i];
|
||||
for (var j = 0; j < par.Lines.length; ++j) {
|
||||
if (par.Lines[j].Ranges[0].W > max_width) {
|
||||
max_width = par.Lines[j].Ranges[0].W;
|
||||
}
|
||||
}
|
||||
}
|
||||
return max_width + 2 + r_ins + l_ins;
|
||||
},
|
||||
getMaxContentWidth: function (maxWidth, bLeft) {
|
||||
this.content.Reset(0, 0, maxWidth - 0.01, 20000);
|
||||
if (bLeft) {
|
||||
this.content.Set_ApplyToAll(true);
|
||||
this.content.Set_ParagraphAlign(align_Left);
|
||||
this.content.Set_ApplyToAll(false);
|
||||
}
|
||||
this.content.Recalculate_Page(0, true);
|
||||
var max_width = 0,
|
||||
arr_content = this.content.Content,
|
||||
paragraph_lines, i, j;
|
||||
for (i = 0; i < arr_content.length; ++i) {
|
||||
paragraph_lines = arr_content[i].Lines;
|
||||
for (j = 0; j < paragraph_lines.length; ++j) {
|
||||
if (paragraph_lines[j].Ranges[0].W > max_width) {
|
||||
max_width = paragraph_lines[j].Ranges[0].W;
|
||||
}
|
||||
}
|
||||
}
|
||||
return max_width + 0.01;
|
||||
},
|
||||
Get_PrevElementEndInfo: function (CurElement) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
function CreateParaContentFromString(str) {
|
||||
if (str == "\t") {
|
||||
return new ParaTab();
|
||||
} else {
|
||||
if (str == "\n") {
|
||||
return new ParaNewLine(break_Line);
|
||||
} else {
|
||||
if (str != " ") {
|
||||
return new ParaText(str);
|
||||
} else {
|
||||
return new ParaSpace(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user