3.0 source code

This commit is contained in:
agolybev
2015-04-28 17:59:00 +03:00
parent c69fd34bdd
commit 7b3b2248e5
16311 changed files with 1445974 additions and 3108429 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,481 @@
/*
* (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 getChartTranslateManager() {
return editor.chartTranslate;
}
CChartSpace.prototype.recalculateTransform = CShape.prototype.recalculateTransform;
CChartSpace.prototype.recalculateBounds = function () {
var t = this.localTransform;
var arr_p_x = [];
var arr_p_y = [];
arr_p_x.push(t.TransformPointX(0, 0));
arr_p_y.push(t.TransformPointY(0, 0));
arr_p_x.push(t.TransformPointX(this.extX, 0));
arr_p_y.push(t.TransformPointY(this.extX, 0));
arr_p_x.push(t.TransformPointX(this.extX, this.extY));
arr_p_y.push(t.TransformPointY(this.extX, this.extY));
arr_p_x.push(t.TransformPointX(0, this.extY));
arr_p_y.push(t.TransformPointY(0, this.extY));
this.bounds.x = Math.min.apply(Math, arr_p_x);
this.bounds.y = Math.min.apply(Math, arr_p_y);
this.bounds.l = this.bounds.x;
this.bounds.t = this.bounds.y;
this.bounds.r = Math.max.apply(Math, arr_p_x);
this.bounds.b = Math.max.apply(Math, arr_p_y);
this.bounds.w = this.bounds.r - this.bounds.l;
this.bounds.h = this.bounds.b - this.bounds.t;
};
CChartSpace.prototype.deselect = CShape.prototype.deselect;
CChartSpace.prototype.hitToHandles = CShape.prototype.hitToHandles;
CChartSpace.prototype.hitInBoundingRect = CShape.prototype.hitInBoundingRect;
CChartSpace.prototype.getRotateAngle = CShape.prototype.getRotateAngle;
CChartSpace.prototype.getInvertTransform = CShape.prototype.getInvertTransform;
CChartSpace.prototype.hit = CShape.prototype.hit;
CChartSpace.prototype.hitInInnerArea = CShape.prototype.hitInInnerArea;
CChartSpace.prototype.hitInPath = CShape.prototype.hitInPath;
CChartSpace.prototype.hitInTextRect = function () {
return false;
};
CChartSpace.prototype.getNumByCardDirection = CShape.prototype.getNumByCardDirection;
CChartSpace.prototype.getCardDirectionByNum = CShape.prototype.getCardDirectionByNum;
CChartSpace.prototype.getResizeCoefficients = CShape.prototype.getResizeCoefficients;
CChartSpace.prototype.check_bounds = CShape.prototype.check_bounds;
CChartSpace.prototype.normalize = CShape.prototype.normalize;
CChartSpace.prototype.getFullFlipH = CShape.prototype.getFullFlipH;
CChartSpace.prototype.getFullFlipV = CShape.prototype.getFullFlipV;
CChartSpace.prototype.Get_Theme = CShape.prototype.Get_Theme;
CChartSpace.prototype.Get_ColorMap = CShape.prototype.Get_ColorMap;
CChartSpace.prototype.handleUpdateFill = function () {
this.recalcInfo.recalculatePenBrush = true;
this.recalcInfo.recalculateBrush = true;
this.recalcInfo.recalculateChart = true;
this.addToRecalculate();
};
CChartSpace.prototype.handleUpdateLn = function () {
this.recalcInfo.recalculatePenBrush = true;
this.recalcInfo.recalculatePen = true;
this.recalcInfo.recalculateChart = true;
this.addToRecalculate();
};
CChartSpace.prototype.setRecalculateInfo = function () {
this.recalcInfo = {
recalcTitle: null,
recalculateTransform: true,
recalculateBounds: true,
recalculateChart: true,
recalculateBaseColors: true,
recalculateSeriesColors: true,
recalculateMarkers: true,
recalculateGridLines: true,
recalculateDLbls: true,
recalculateAxisLabels: true,
dataLbls: [],
axisLabels: [],
recalculateAxisVal: true,
recalculateAxisCat: true,
recalculateAxisTickMark: true,
recalculateBrush: true,
recalculatePen: true,
recalculatePlotAreaBrush: true,
recalculatePlotAreaPen: true,
recalculateHiLowLines: true,
recalculateUpDownBars: true,
recalculateLegend: true,
recalculateWrapPolygon: true,
recalculatePenBrush: true,
recalculateTextPr: true
};
this.baseColors = [];
this.chartObj = null;
this.localTransform = new CMatrix();
this.snapArrayX = [];
this.snapArrayY = [];
this.rectGeometry = ExecuteNoHistory(function () {
return CreateGeometry("rect");
},
this, []);
this.bNeedUpdatePosition = true;
};
CChartSpace.prototype.recalcTransform = function () {
this.recalcInfo.recalculateTransform = true;
};
CChartSpace.prototype.recalcBounds = function () {
this.recalcInfo.recalculateBounds = true;
};
CChartSpace.prototype.recalcWrapPolygon = function () {
this.recalcInfo.recalculateWrapPolygon = true;
};
CChartSpace.prototype.recalcChart = function () {
this.recalcInfo.recalculateChart = true;
};
CChartSpace.prototype.recalcBaseColors = function () {
this.recalcInfo.recalculateBaseColors = true;
};
CChartSpace.prototype.recalcSeriesColors = function () {
this.recalcInfo.recalculateSeriesColors = true;
};
CChartSpace.prototype.recalcDLbls = function () {
this.recalcInfo.recalculateDLbls = true;
};
CChartSpace.prototype.addToSetPosition = function (dLbl) {
if (dLbl instanceof CDLbl) {
this.recalcInfo.dataLbls.push(dLbl);
} else {
if (dLbl instanceof CTitle) {
this.recalcInfo.axisLabels.push(dLbl);
}
}
};
CChartSpace.prototype.addToRecalculate = CShape.prototype.addToRecalculate;
CChartSpace.prototype.handleUpdatePosition = function () {
this.recalcTransform();
this.recalcBounds();
this.addToRecalculate();
};
CChartSpace.prototype.handleUpdateExtents = function () {
this.recalcChart();
this.recalcBounds();
this.recalcTransform();
this.recalcWrapPolygon();
this.recalcTitles();
this.handleUpdateInternalChart();
};
CChartSpace.prototype.handleUpdateFlip = function () {
this.handleUpdateExtents();
};
CChartSpace.prototype.handleUpdateChart = function () {
this.recalcChart();
this.setRecalculateInfo();
this.addToRecalculate();
};
CChartSpace.prototype.handleUpdateStyle = function () {
this.recalcInfo.recalculateSeriesColors = true;
this.recalcInfo.recalculateLegend = true;
this.recalcInfo.recalculatePlotAreaBrush = true;
this.recalcInfo.recalculatePlotAreaPen = true;
this.recalcInfo.recalculateBrush = true;
this.recalcInfo.recalculatePen = true;
this.recalcInfo.recalculateHiLowLines = true;
this.recalcInfo.recalculateUpDownBars = true;
this.handleTitlesAfterChangeTheme();
this.recalcInfo.recalculateAxisLabels = true;
this.recalcInfo.recalculateAxisVal = true;
this.addToRecalculate();
};
CChartSpace.prototype.canGroup = CShape.prototype.canGroup;
CChartSpace.prototype.convertPixToMM = CShape.prototype.convertPixToMM;
CChartSpace.prototype.getCanvasContext = CShape.prototype.getCanvasContext;
CChartSpace.prototype.getHierarchy = CShape.prototype.getHierarchy;
CChartSpace.prototype.getParentObjects = CShape.prototype.getParentObjects;
CChartSpace.prototype.recalculateTransform = CShape.prototype.recalculateTransform;
CChartSpace.prototype.recalculateChart = function () {
if (this.chartObj == null) {
this.chartObj = new CChartsDrawer();
}
this.chartObj.reCalculate(this);
};
CChartSpace.prototype.canResize = CShape.prototype.canResize;
CChartSpace.prototype.canMove = CShape.prototype.canMove;
CChartSpace.prototype.recalcText = function () {
this.recalcInfo.recalculateAxisLabels = true;
this.recalcTitles2();
this.handleUpdateInternalChart();
};
CChartSpace.prototype.setStartPage = function (pageIndex) {
this.selectStartPage = pageIndex;
var title, content;
if (this.chart && this.chart.title) {
title = this.chart.title;
content = title.getDocContent();
content && content.Set_StartPage(pageIndex);
}
if (this.chart && this.chart.plotArea) {
var hor_axis = this.chart.plotArea.getHorizontalAxis();
if (hor_axis && hor_axis.title) {
title = hor_axis.title;
content = title.getDocContent();
content && content.Set_StartPage(pageIndex);
}
var vert_axis = this.chart.plotArea.getVerticalAxis();
if (vert_axis && vert_axis.title) {
title = vert_axis.title;
content = title.getDocContent();
content && content.Set_StartPage(pageIndex);
}
}
};
CChartSpace.prototype.getRecalcObject = CShape.prototype.getRecalcObject;
CChartSpace.prototype.setRecalcObject = CShape.prototype.setRecalcObject;
CChartSpace.prototype.canRotate = function () {
return false;
};
CChartSpace.prototype.createResizeTrack = CShape.prototype.createResizeTrack;
CChartSpace.prototype.createMoveTrack = CShape.prototype.createMoveTrack;
CChartSpace.prototype.getAspect = CShape.prototype.getAspect;
CChartSpace.prototype.getRectBounds = CShape.prototype.getRectBounds;
CChartSpace.prototype.recalculate = function () {
if (this.bDeleted) {
return;
}
ExecuteNoHistory(function () {
this.updateLinks();
if (this.recalcInfo.recalcTitle) {
this.recalculateChartTitleEditMode(true);
this.recalcInfo.recalcTitle = null;
this.recalcInfo.bRecalculatedTitle = true;
} else {}
if (this.recalcInfo.recalculateTransform) {
this.recalculateTransform();
this.rectGeometry.Recalculate(this.extX, this.extY);
this.recalcInfo.recalculateTransform = false;
}
if (this.recalcInfo.recalculateBaseColors) {
this.recalculateBaseColors();
this.recalcInfo.recalculateBaseColors = false;
}
if (this.recalcInfo.recalculateMarkers) {
this.recalculateMarkers();
this.recalcInfo.recalculateMarkers = false;
}
if (this.recalcInfo.recalculateSeriesColors) {
this.recalculateSeriesColors();
this.recalcInfo.recalculateSeriesColors = false;
}
if (this.recalcInfo.recalculateGridLines) {
this.recalculateGridLines();
this.recalcInfo.recalculateGridLines = false;
}
if (this.recalcInfo.recalculateAxisTickMark) {
this.recalculateAxisTickMark();
this.recalcInfo.recalculateAxisTickMark = false;
}
if (this.recalcInfo.recalculateDLbls) {
this.recalculateDLbls();
this.recalcInfo.recalculateDLbls = false;
}
if (this.recalcInfo.recalculateBrush) {
this.recalculateChartBrush();
this.recalcInfo.recalculateBrush = false;
}
if (this.recalcInfo.recalculatePen) {
this.recalculateChartPen();
this.recalcInfo.recalculatePen = false;
}
if (this.recalcInfo.recalculateHiLowLines) {
this.recalculateHiLowLines();
this.recalcInfo.recalculateHiLowLines = false;
}
if (this.recalcInfo.recalculatePlotAreaBrush) {
this.recalculatePlotAreaChartBrush();
this.recalcInfo.recalculatePlotAreaBrush = false;
}
if (this.recalcInfo.recalculatePlotAreaPen) {
this.recalculatePlotAreaChartPen();
this.recalcInfo.recalculatePlotAreaPen = false;
}
if (this.recalcInfo.recalculateUpDownBars) {
this.recalculateUpDownBars();
this.recalcInfo.recalculateUpDownBars = false;
}
var b_recalc_legend = false;
if (this.recalcInfo.recalculateLegend) {
this.recalculateLegend();
this.recalcInfo.recalculateLegend = false;
b_recalc_legend = true;
}
var b_recalc_labels = false;
if (this.recalcInfo.recalculateAxisLabels) {
this.recalculateAxisLabels();
this.recalcInfo.recalculateAxisLabels = false;
b_recalc_labels = true;
}
if (this.recalcInfo.recalculateAxisVal) {
this.recalculateAxis();
this.recalcInfo.recalculateAxisVal = false;
}
if (this.recalcInfo.recalculatePenBrush) {
this.recalculatePenBrush();
this.recalcInfo.recalculatePenBrush = false;
}
if (this.recalcInfo.recalculateChart) {
this.recalculateChart();
this.recalcInfo.recalculateChart = false;
}
for (var i = 0; i < this.recalcInfo.dataLbls.length; ++i) {
var series = this.chart.plotArea.chart.series;
if (this.recalcInfo.dataLbls[i].series && this.recalcInfo.dataLbls[i].pt) {
var ser_idx = this.recalcInfo.dataLbls[i].series.idx;
for (var j = 0; j < series.length; ++j) {
if (series[j].idx === this.recalcInfo.dataLbls[i].series.idx) {
var pos = this.chartObj.reCalculatePositionText("dlbl", this, j, this.recalcInfo.dataLbls[i].pt.idx);
this.recalcInfo.dataLbls[i].setPosition(pos.x, pos.y);
break;
}
}
}
}
this.recalcInfo.dataLbls.length = 0;
if (b_recalc_labels) {
if (this.chart && this.chart.title) {
var pos = this.chartObj.reCalculatePositionText("title", this, this.chart.title);
this.chart.title.setPosition(pos.x, pos.y);
}
if (this.chart && this.chart.plotArea && this.chart.plotArea) {
var hor_axis = this.chart.plotArea.getHorizontalAxis();
if (hor_axis && hor_axis.title) {
var old_cat_ax = this.chart.plotArea.catAx;
this.chart.plotArea.catAx = hor_axis;
var pos = this.chartObj.reCalculatePositionText("catAx", this, hor_axis.title);
hor_axis.title.setPosition(pos.x, pos.y);
this.chart.plotArea.catAx = old_cat_ax;
}
var vert_axis = this.chart.plotArea.getVerticalAxis();
if (vert_axis && vert_axis.title) {
var old_val_ax = this.chart.plotArea.valAx;
this.chart.plotArea.valAx = vert_axis;
var pos = this.chartObj.reCalculatePositionText("valAx", this, vert_axis.title);
vert_axis.title.setPosition(pos.x, pos.y);
this.chart.plotArea.valAx = old_val_ax;
}
}
}
if (b_recalc_legend && this.chart && this.chart.legend) {
var pos = this.chartObj.reCalculatePositionText("legend", this, this.chart.legend);
this.chart.legend.setPosition(pos.x, pos.y);
}
if (this.recalcInfo.recalculateTextPr) {
this.recalculateTextPr();
this.recalcInfo.recalculateTextPr = false;
}
if (this.recalcInfo.recalculateBounds) {
this.recalculateBounds();
this.recalcInfo.recalculateBounds = false;
}
if (this.recalcInfo.recalculateWrapPolygon) {
this.recalculateWrapPolygon();
this.recalcInfo.recalculateWrapPolygon = false;
}
this.recalcInfo.axisLabels.length = 0;
this.bNeedUpdatePosition = true;
if (isRealNumber(this.posX) && isRealNumber(this.posY)) {
this.updatePosition(this.posX, this.posY);
}
},
this, []);
};
CChartSpace.prototype.deselect = CShape.prototype.deselect;
CChartSpace.prototype.getDrawingDocument = CShape.prototype.getDrawingDocument;
CChartSpace.prototype.updatePosition = CShape.prototype.updatePosition;
CChartSpace.prototype.recalculateWrapPolygon = CShape.prototype.recalculateWrapPolygon;
CChartSpace.prototype.getArrayWrapPolygons = function () {
return this.rectGeometry.getArrayPolygons();
};
CChartSpace.prototype.checkContentDrawings = function () {};
CChartSpace.prototype.checkShapeChildTransform = function () {
if (this.parent) {
var parent_shape = this.parent.isShapeChild(true);
if (parent_shape) {
var transform_text = parent_shape.transformText;
global_MatrixTransformer.MultiplyAppend(this.transform, transform_text);
this.invertTransform = global_MatrixTransformer.Invert(this.transform);
if (this.chart) {
if (this.chart.plotArea) {
if (this.chart.plotArea.chart && this.chart.plotArea.chart.series) {
var series = this.chart.plotArea.chart.series;
for (var i = 0; i < series.length; ++i) {
var ser = series[i];
var pts = getPtsFromSeries(ser);
for (var j = 0; j < pts.length; ++j) {
if (pts[j].compiledDlb) {
pts[j].compiledDlb.checkShapeChildTransform(transform_text);
}
}
}
}
if (this.chart.plotArea.catAx) {
if (this.chart.plotArea.catAx.title) {
this.chart.plotArea.catAx.title.checkShapeChildTransform(transform_text);
}
if (this.chart.plotArea.catAx.labels) {
this.chart.plotArea.catAx.labels.checkShapeChildTransform(transform_text);
}
}
if (this.chart.plotArea.valAx) {
if (this.chart.plotArea.valAx.title) {
this.chart.plotArea.valAx.title.checkShapeChildTransform(transform_text);
}
if (this.chart.plotArea.valAx.labels) {
this.chart.plotArea.valAx.labels.checkShapeChildTransform(transform_text);
}
}
}
if (this.chart.title) {
this.chart.title.checkShapeChildTransform(transform_text);
}
if (this.chart.legend) {
this.chart.legend.checkShapeChildTransform(transform_text);
}
}
}
}
};
CChartSpace.prototype.recalculateLocalTransform = CShape.prototype.recalculateLocalTransform;
CChartSpace.prototype.updateTransformMatrix = function () {
var posX = this.localTransform.tx + this.posX;
var posY = this.localTransform.ty + this.posY;
this.transform = this.localTransform.CreateDublicate();
global_MatrixTransformer.TranslateAppend(this.transform, this.posX, this.posY);
this.invertTransform = global_MatrixTransformer.Invert(this.transform);
this.updateChildLabelsTransform(posX, posY);
this.checkShapeChildTransform();
};
CChartSpace.prototype.getArrayWrapIntervals = CShape.prototype.getArrayWrapIntervals;
CChartSpace.prototype.select = CShape.prototype.select;
function CreateUnifillSolidFillSchemeColor(colorId, tintOrShade) {
var unifill = new CUniFill();
unifill.setFill(new CSolidFill());
unifill.fill.setColor(new CUniColor());
unifill.fill.color.setColor(new CSchemeColor());
unifill.fill.color.color.setId(colorId);
return CreateUniFillSolidFillWidthTintOrShade(unifill, tintOrShade);
}
function CreateNoFillLine() {
var ret = new CLn();
ret.setFill(CreateNoFillUniFill());
return ret;
}
function CreateNoFillUniFill() {
var ret = new CUniFill();
ret.setFill(new CNoFill());
return ret;
}

View File

@@ -0,0 +1,332 @@
/*
* (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
*
*/
CGroupShape.prototype.addToRecalculate = CShape.prototype.addToRecalculate;
CGroupShape.prototype.Get_Theme = CShape.prototype.Get_Theme;
CGroupShape.prototype.setStartPage = CShape.prototype.setStartPage;
CGroupShape.prototype.handleUpdateFill = function () {
for (var i = 0; i < this.spTree.length; ++i) {
this.spTree[i].handleUpdateFill();
}
};
CGroupShape.prototype.recalcText = function () {
if (this.spTree) {
for (var i = 0; i < this.spTree.length; ++i) {
if (this.spTree[i].recalcText) {
this.spTree[i].recalcText();
}
}
}
};
CGroupShape.prototype.handleUpdateLn = function () {
for (var i = 0; i < this.spTree.length; ++i) {
this.spTree[i].handleUpdateLn();
}
};
CGroupShape.prototype.getRecalcObject = CShape.prototype.getRecalcObject;
CGroupShape.prototype.setRecalcObject = CShape.prototype.setRecalcObject;
CGroupShape.prototype.Get_ColorMap = CShape.prototype.Get_ColorMap;
CGroupShape.prototype.getTargetDocContent = DrawingObjectsController.prototype.getTargetDocContent;
CGroupShape.prototype.documentUpdateInterfaceState = function () {
if (this.selection.textSelection) {
this.selection.textSelection.getDocContent().Document_UpdateInterfaceState();
} else {
if (this.selection.chartSelection && this.selection.chartSelection.selection.textSelection) {
this.selection.chartSelection.selection.textSelection.getDocContent().Document_UpdateInterfaceState();
} else {
var para_pr = DrawingObjectsController.prototype.getParagraphParaPr.call(this);
var text_pr = DrawingObjectsController.prototype.getParagraphTextPr.call(this);
if (!para_pr) {
para_pr = new CParaPr();
}
if (!text_pr) {
text_pr = new CTextPr();
}
editor.UpdateParagraphProp(para_pr);
editor.UpdateTextPr(text_pr);
}
}
};
CGroupShape.prototype.setRecalculateInfo = function () {
this.recalcInfo = {
recalculateBrush: true,
recalculatePen: true,
recalculateTransform: true,
recalculateArrGraphicObjects: true,
recalculateBounds: true,
recalculateScaleCoefficients: true,
recalculateWrapPolygon: true
};
this.localTransform = new CMatrix();
this.bounds = {
l: 0,
t: 0,
r: 0,
b: 0,
w: 0,
h: 0
};
this.posX = null;
this.posY = null;
this.snapArrayX = [];
this.snapArrayY = [];
this.bNeedUpdatePosition = true;
};
CGroupShape.prototype.recalcTransform = function () {
this.recalcInfo.recalculateScaleCoefficients = true;
this.recalcInfo.recalculateTransform = true;
for (var i = 0; i < this.spTree.length; ++i) {
this.spTree[i].recalcTransform();
}
};
CGroupShape.prototype.recalculate = function () {
if (this.bDeleted) {
return;
}
ExecuteNoHistory(function () {
if (this.recalcInfo.recalculateBrush) {
this.recalculateBrush();
this.recalcInfo.recalculateBrush = false;
}
if (this.recalcInfo.recalculatePen) {
this.recalculatePen();
this.recalcInfo.recalculatePen = false;
}
if (this.recalcInfo.recalculateTransform) {
this.recalculateTransform();
this.recalcInfo.recalculateTransform = false;
}
if (this.recalcInfo.recalculateArrGraphicObjects) {
this.recalculateArrGraphicObjects();
this.recalcInfo.recalculateArrGraphicObjects = false;
}
if (this.recalcInfo.recalculateWrapPolygon) {
this.recalculateWrapPolygon();
this.recalcInfo.recalculateWrapPolygon = false;
}
for (var i = 0; i < this.spTree.length; ++i) {
this.spTree[i].recalculate();
}
if (this.recalcInfo.recalculateBounds) {
this.recalculateBounds();
this.recalcInfo.recalculateBounds = false;
}
},
this, []);
};
CGroupShape.prototype.recalcBounds = function () {
this.recalcInfo.recalculateBounds = true;
for (var i = 0; i < this.spTree.length; ++i) {
this.spTree[i].recalcBounds();
}
};
CGroupShape.prototype.addToDrawingObjects = CShape.prototype.addToDrawingObjects;
CGroupShape.prototype.setDrawingObjects = CShape.prototype.setDrawingObjects;
CGroupShape.prototype.setDrawingBase = CShape.prototype.setDrawingBase;
CGroupShape.prototype.deleteDrawingBase = CShape.prototype.deleteDrawingBase;
CGroupShape.prototype.addToRecalculate = CShape.prototype.addToRecalculate;
CGroupShape.prototype.convertPixToMM = CShape.prototype.convertPixToMM;
CGroupShape.prototype.getCanvasContext = CShape.prototype.getCanvasContext;
CGroupShape.prototype.getHierarchy = CShape.prototype.getHierarchy;
CGroupShape.prototype.getParentObjects = CShape.prototype.getParentObjects;
CGroupShape.prototype.recalculateTransform = CShape.prototype.recalculateTransform;
CGroupShape.prototype.deselect = CShape.prototype.deselect;
CGroupShape.prototype.hitToHandles = CShape.prototype.hitToHandles;
CGroupShape.prototype.hitInBoundingRect = CShape.prototype.hitInBoundingRect;
CGroupShape.prototype.getRotateAngle = CShape.prototype.getRotateAngle;
CGroupShape.prototype.getDrawingDocument = CShape.prototype.getDrawingDocument;
CGroupShape.prototype.handleUpdatePosition = function () {
this.recalcBounds();
this.recalcTransform();
this.addToRecalculate();
for (var i = 0; i < this.spTree.length; ++i) {
if (this.spTree[i].recalcTransform) {
this.spTree[i].recalcTransform();
}
}
};
CGroupShape.prototype.handleUpdateRot = function () {
this.recalcTransform();
this.recalcBounds();
this.recalcWrapPolygon();
this.addToRecalculate();
};
CGroupShape.prototype.recalcWrapPolygon = function () {
this.recalcInfo.recalculateWrapPolygon = true;
};
CGroupShape.prototype.handleUpdateFlip = function () {
this.recalcTransform();
this.recalcBounds();
this.recalcWrapPolygon();
this.addToRecalculate();
};
CGroupShape.prototype.handleUpdateChildOffset = function () {
this.recalcTransform();
this.recalcBounds();
this.recalcWrapPolygon();
this.addToRecalculate();
};
CGroupShape.prototype.handleUpdateChildExtents = function () {
this.recalcTransform();
this.recalcBounds();
this.recalcWrapPolygon();
this.addToRecalculate();
};
CGroupShape.prototype.recalculateWrapPolygon = CShape.prototype.recalculateWrapPolygon;
CGroupShape.prototype.getArrayWrapPolygons = function () {
var arr_wrap_polygons = [];
for (var i = 0; i < this.spTree.length; ++i) {
arr_wrap_polygons = arr_wrap_polygons.concat(this.spTree[i].getArrayWrapPolygons());
}
return arr_wrap_polygons;
};
CGroupShape.prototype.recalculateTransform = CShape.prototype.recalculateTransform;
CGroupShape.prototype.updatePosition = CShape.prototype.updatePosition;
CGroupShape.prototype.checkShapeChild = function () {
return false;
};
CGroupShape.prototype.checkShapeChildTransform = function () {
for (var i = 0; i < this.spTree.length; ++i) {
this.spTree[i].updatePosition(this.posX, this.posY);
}
};
CGroupShape.prototype.getArrayWrapIntervals = CShape.prototype.getArrayWrapIntervals;
CGroupShape.prototype.updateTransformMatrix = CShape.prototype.updateTransformMatrix;
CGroupShape.prototype.recalculateLocalTransform = CShape.prototype.recalculateLocalTransform;
CGroupShape.prototype.checkContentDrawings = function () {};
CGroupShape.prototype.applyParentTransform = function (transform) {};
CGroupShape.prototype.Refresh_RecalcData = function (data) {
switch (data.Type) {
case historyitem_GroupShapeAddToSpTree:
case historyitem_GroupShapeRemoveFromSpTree:
if (!this.group) {
this.recalcInfo.recalculateArrGraphicObjects = true;
this.addToRecalculate();
} else {
this.group.handleUpdateSpTree();
}
}
this.Refresh_RecalcData2();
};
CGroupShape.prototype.Refresh_RecalcData2 = function () {
this.addToRecalculate();
};
CGroupShape.prototype.documentStatistics = function (stat) {
for (var i = 0; i < this.spTree.length; ++i) {
if (this.spTree[i].documentStatistics) {
this.spTree[i].documentStatistics(stat);
}
}
};
CGroupShape.prototype.recalculateText = function () {
for (var i = 0; i < this.spTree.length; ++i) {
if (this.spTree[i].recalculateText) {
this.spTree[i].recalculateText();
}
}
};
CGroupShape.prototype.recalculateBounds = function () {
var sp_tree = this.spTree;
var x_arr_max = [],
y_arr_max = [],
x_arr_min = [],
y_arr_min = [];
for (var i = 0; i < sp_tree.length; ++i) {
sp_tree[i].recalculate();
}
var tr = this.localTransform;
var arr_p_x = [];
var arr_p_y = [];
arr_p_x.push(tr.TransformPointX(0, 0));
arr_p_y.push(tr.TransformPointY(0, 0));
arr_p_x.push(tr.TransformPointX(this.extX, 0));
arr_p_y.push(tr.TransformPointY(this.extX, 0));
arr_p_x.push(tr.TransformPointX(this.extX, this.extY));
arr_p_y.push(tr.TransformPointY(this.extX, this.extY));
arr_p_x.push(tr.TransformPointX(0, this.extY));
arr_p_y.push(tr.TransformPointY(0, this.extY));
x_arr_max = x_arr_max.concat(arr_p_x);
x_arr_min = x_arr_min.concat(arr_p_x);
y_arr_max = y_arr_max.concat(arr_p_y);
y_arr_min = y_arr_min.concat(arr_p_y);
this.bounds.x = Math.min.apply(Math, x_arr_min);
this.bounds.y = Math.min.apply(Math, y_arr_min);
this.bounds.l = this.bounds.x;
this.bounds.t = this.bounds.y;
this.bounds.r = Math.max.apply(Math, x_arr_max);
this.bounds.b = Math.max.apply(Math, y_arr_max);
this.bounds.w = this.bounds.r - this.bounds.l;
this.bounds.h = this.bounds.b - this.bounds.t;
};
CGroupShape.prototype.getBoundsPos = function () {
var sp_tree = this.spTree;
var x_arr_max = [],
y_arr_max = [],
x_arr_min = [],
y_arr_min = [];
for (var i = 0; i < sp_tree.length; ++i) {
var bounds = sp_tree[i].bounds;
var l = sp_tree[i].x;
var r = sp_tree[i].x + sp_tree[i].extX;
var t = sp_tree[i].y;
var b = sp_tree[i].y + sp_tree[i].extY;
x_arr_max.push(r);
x_arr_min.push(l);
y_arr_max.push(b);
y_arr_min.push(t);
}
return {
x: Math.min.apply(Math, x_arr_min),
y: Math.min.apply(Math, y_arr_min)
};
};
CGroupShape.prototype.getAbsolutePos = function () {
var sp_tree = this.spTree;
var x_arr_max = [],
y_arr_max = [],
x_arr_min = [],
y_arr_min = [];
for (var i = 0; i < sp_tree.length; ++i) {
var bounds = sp_tree[i].bounds;
var l = sp_tree[i].x;
var r = sp_tree[i].x + sp_tree[i].extX;
var t = sp_tree[i].y;
var b = sp_tree[i].y + sp_tree[i].extY;
x_arr_max.push(r);
x_arr_min.push(l);
y_arr_max.push(b);
y_arr_min.push(t);
}
return {
x: Math.min.apply(Math, x_arr_min),
y: Math.min.apply(Math, y_arr_min)
};
};

View File

@@ -0,0 +1,209 @@
/*
* (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";
CImageShape.prototype.Get_Theme = CShape.prototype.Get_Theme;
CImageShape.prototype.Get_ColorMap = CShape.prototype.Get_ColorMap;
CImageShape.prototype.addToRecalculate = CShape.prototype.addToRecalculate;
CImageShape.prototype.convertPixToMM = CShape.prototype.convertPixToMM;
CImageShape.prototype.getCanvasContext = CShape.prototype.getCanvasContext;
CImageShape.prototype.getHierarchy = CShape.prototype.getHierarchy;
CImageShape.prototype.getParentObjects = CShape.prototype.getParentObjects;
CImageShape.prototype.recalculateTransform = CShape.prototype.recalculateTransform;
CImageShape.prototype.recalculateBounds = CShape.prototype.recalculateBounds;
CImageShape.prototype.deselect = CShape.prototype.deselect;
CImageShape.prototype.getArrayWrapPolygons = CShape.prototype.getArrayWrapPolygons;
CImageShape.prototype.hitToHandles = CShape.prototype.hitToHandles;
CImageShape.prototype.hitInBoundingRect = CShape.prototype.hitInBoundingRect;
CImageShape.prototype.getRotateAngle = CShape.prototype.getRotateAngle;
CImageShape.prototype.recalculateWrapPolygon = CShape.prototype.recalculateWrapPolygon;
CImageShape.prototype.setRecalculateInfo = function () {
this.recalcInfo = {
recalculateBrush: true,
recalculatePen: true,
recalculateTransform: true,
recalculateBounds: true,
recalculateGeometry: true,
recalculateFill: true,
recalculateLine: true,
recalculateTransparent: true,
recalculateWrapPolygon: true
};
this.bNeedUpdatePosition = true;
this.bounds = {
l: 0,
t: 0,
r: 0,
b: 0,
w: 0,
h: 0
};
this.posX = null;
this.posY = null;
this.snapArrayX = [];
this.snapArrayY = [];
this.localTransform = new CMatrix();
this.localTransformText = new CMatrix();
};
CImageShape.prototype.recalcBrush = function () {
this.recalcInfo.recalculateBrush = true;
};
CImageShape.prototype.recalcPen = function () {
this.recalcInfo.recalculatePen = true;
};
CImageShape.prototype.recalcTransform = function () {
this.recalcInfo.recalculateTransform = true;
};
CImageShape.prototype.recalcBounds = function () {
this.recalcInfo.recalculateBounds = true;
};
CImageShape.prototype.recalcGeometry = function () {
this.recalcInfo.recalculateGeometry = true;
};
CImageShape.prototype.recalcStyle = function () {
this.recalcInfo.recalculateStyle = true;
};
CImageShape.prototype.recalcFill = function () {
this.recalcInfo.recalculateFill = true;
};
CImageShape.prototype.recalcLine = function () {
this.recalcInfo.recalculateLine = true;
};
CImageShape.prototype.recalcTransparent = function () {
this.recalcInfo.recalculateTransparent = true;
};
CImageShape.prototype.recalcWrapPolygon = function () {
this.recalcInfo.recalculateWrapPolygon = true;
};
CImageShape.prototype.handleUpdatePosition = function () {
this.recalcTransform();
this.recalcBounds();
this.addToRecalculate();
};
CImageShape.prototype.handleUpdateExtents = function () {
this.recalcGeometry();
this.recalcBounds();
this.recalcTransform();
this.recalcWrapPolygon();
this.addToRecalculate();
};
CImageShape.prototype.handleUpdateRot = function () {
this.recalcTransform();
this.recalcBounds();
this.recalcWrapPolygon();
this.addToRecalculate();
};
CImageShape.prototype.handleUpdateFlip = function () {
this.recalcTransform();
this.recalcWrapPolygon();
this.addToRecalculate();
};
CImageShape.prototype.handleUpdateFill = function () {
this.recalcBrush();
this.addToRecalculate();
};
CImageShape.prototype.handleUpdateLn = function () {
this.recalcLine();
this.addToRecalculate();
};
CImageShape.prototype.handleUpdateGeometry = function () {
this.recalcBounds();
this.recalcGeometry();
this.addToRecalculate();
};
CImageShape.prototype.recalculateLocalTransform = CShape.prototype.recalculateLocalTransform;
CImageShape.prototype.convertPixToMM = CShape.prototype.convertPixToMM;
CImageShape.prototype.getCanvasContext = CShape.prototype.getCanvasContext;
CImageShape.prototype.getCompiledStyle = CShape.prototype.getCompiledStyle;
CImageShape.prototype.getHierarchy = CShape.prototype.getHierarchy;
CImageShape.prototype.getParentObjects = CShape.prototype.getParentObjects;
CImageShape.prototype.recalculate = function () {
if (this.bDeleted) {
return;
}
ExecuteNoHistory(function () {
if (this.recalcInfo.recalculateBrush) {
this.recalculateBrush();
this.recalcInfo.recalculateBrush = false;
}
if (this.recalcInfo.recalculatePen) {
this.recalculatePen();
this.recalcInfo.recalculatePen = false;
}
if (this.recalcInfo.recalculateTransform) {
this.recalculateTransform();
this.recalcInfo.recalculateTransform = false;
}
if (this.recalcInfo.recalculateGeometry) {
this.recalculateGeometry();
this.recalcInfo.recalculateGeometry = false;
}
if (this.recalcInfo.recalculateBounds) {
this.recalculateBounds();
this.recalcInfo.recalculateBounds = false;
}
if (this.recalcInfo.recalculateWrapPolygon) {
this.recalculateWrapPolygon();
this.recalcInfo.recalculateWrapPolygon = false;
}
this.bNeedUpdatePosition = true;
},
this, []);
};
CImageShape.prototype.canChangeWrapPolygon = CShape.prototype.canChangeWrapPolygon;
CImageShape.prototype.hitInInnerArea = CShape.prototype.hitInInnerArea;
CImageShape.prototype.hitInPath = CShape.prototype.hitInPath;
CImageShape.prototype.hitToHandles = CShape.prototype.hitToHandles;
CImageShape.prototype.hitInBoundingRect = CShape.prototype.hitInBoundingRect;
CImageShape.prototype.getNumByCardDirection = CShape.prototype.getNumByCardDirection;
CImageShape.prototype.getCardDirectionByNum = CShape.prototype.getCardDirectionByNum;
CImageShape.prototype.getResizeCoefficients = CShape.prototype.getResizeCoefficients;
CImageShape.prototype.check_bounds = CShape.prototype.check_bounds;
CImageShape.prototype.normalize = CShape.prototype.normalize;
CImageShape.prototype.updatePosition = CShape.prototype.updatePosition;
CImageShape.prototype.updateTransformMatrix = CShape.prototype.updateTransformMatrix;
CImageShape.prototype.getDrawingDocument = CShape.prototype.getDrawingDocument;
CImageShape.prototype.getArrayWrapIntervals = CShape.prototype.getArrayWrapIntervals;
CImageShape.prototype.getBounds = CShape.prototype.getBounds;
CImageShape.prototype.setStartPage = CShape.prototype.setStartPage;
CImageShape.prototype.getRecalcObject = CShape.prototype.getRecalcObject;
CImageShape.prototype.setRecalcObject = CShape.prototype.setRecalcObject;
CImageShape.prototype.checkContentDrawings = function () {};
CImageShape.prototype.hit = CShape.prototype.hit;
CImageShape.prototype.checkShapeChildTransform = function () {
if (this.parent) {
var parent_shape = this.parent.isShapeChild(true);
if (parent_shape) {
global_MatrixTransformer.MultiplyAppend(this.transform, parent_shape.transformText);
this.invertTransform = global_MatrixTransformer.Invert(this.transform);
}
}
};

View File

@@ -0,0 +1,773 @@
/*
* (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
*
*/
CShape.prototype.setRecalculateInfo = function () {
this.recalcInfo = {
recalculateContent: true,
recalculateTxBoxContent: true,
recalculateBrush: true,
recalculatePen: true,
recalculateTransform: true,
recalculateTransformText: true,
recalculateBounds: true,
recalculateGeometry: true,
recalculateStyle: true,
recalculateFill: true,
recalculateLine: true,
recalculateTransparent: true,
recalculateTextStyles: [true, true, true, true, true, true, true, true, true],
recalculateShapeStyleForParagraph: true,
recalculateWrapPolygon: true
};
this.bNeedUpdatePosition = true;
this.textStyleForParagraph = null;
this.contentWidth = null;
this.contentHeight = null;
this.compiledStyles = [];
this.bounds = {
l: 0,
t: 0,
r: 0,
b: 0,
w: 0,
h: 0
};
this.posX = null;
this.posY = null;
this.snapArrayX = [];
this.snapArrayY = [];
this.localTransform = new CMatrix();
this.localTransformText = new CMatrix();
};
CShape.prototype.recalcContent = function () {
if (this.bWordShape) {
this.recalcInfo.recalculateTxBoxContent = true;
} else {
this.recalcInfo.recalculateContent = true;
}
};
CShape.prototype.getDrawingDocument = function () {
return editor.WordControl.m_oLogicDocument.DrawingDocument;
};
CShape.prototype.recalcBrush = function () {
this.recalcInfo.recalculateBrush = true;
};
CShape.prototype.recalcPen = function () {
this.recalcInfo.recalculatePen = true;
};
CShape.prototype.recalcTransform = function () {
this.recalcInfo.recalculateTransform = true;
this.snapArrayX.length = 0;
this.snapArrayY.length = 0;
};
CShape.prototype.recalcTransformText = function () {
this.recalcInfo.recalculateTransformText = true;
};
CShape.prototype.recalcBounds = function () {
this.recalcInfo.recalculateBounds = true;
};
CShape.prototype.recalcGeometry = function () {
this.recalcInfo.recalculateGeometry = true;
};
CShape.prototype.recalcStyle = function () {
this.recalcInfo.recalculateStyle = true;
};
CShape.prototype.recalcFill = function () {
this.recalcInfo.recalculateFill = true;
};
CShape.prototype.recalcLine = function () {
this.recalcInfo.recalculateLine = true;
};
CShape.prototype.recalcTransparent = function () {
this.recalcInfo.recalculateTransparent = true;
};
CShape.prototype.recalcTextStyles = function () {
this.recalcInfo.recalculateTextStyles = true;
};
CShape.prototype.recalcTxBoxContent = function () {
this.recalcInfo.recalculateTxBoxContent = true;
};
CShape.prototype.recalcWrapPolygon = function () {
this.recalcInfo.recalculateWrapPolygon = true;
};
CShape.prototype.addToRecalculate = function () {
editor.WordControl.m_oLogicDocument.DrawingObjects.addToRecalculate(this);
};
CShape.prototype.handleUpdatePosition = function () {
this.recalcTransform();
this.recalcBounds();
this.recalcTransformText();
this.addToRecalculate();
};
CShape.prototype.handleUpdateExtents = function () {
this.recalcContent();
this.recalcGeometry();
this.recalcBounds();
this.recalcWrapPolygon();
this.recalcContent();
this.recalcTxBoxContent();
this.recalcTransform();
this.recalcTransformText();
this.addToRecalculate();
};
CShape.prototype.handleUpdateRot = function () {
this.recalcTransform();
if (this.txBody && this.txBody.bodyPr && this.txBody.bodyPr.upright) {
this.recalcContent();
}
this.recalcTransformText();
this.recalcBounds();
this.recalcWrapPolygon();
this.addToRecalculate();
};
CShape.prototype.handleUpdateFlip = function () {
this.recalcTransform();
this.recalcTransformText();
this.recalcContent();
this.recalcWrapPolygon();
this.addToRecalculate();
};
CShape.prototype.handleUpdateFill = function () {
this.recalcBrush();
this.recalcFill();
this.recalcTransparent();
this.addToRecalculate();
};
CShape.prototype.handleUpdateLn = function () {
this.recalcLine();
this.recalcPen();
this.addToRecalculate();
};
CShape.prototype.handleUpdateGeometry = function () {
this.recalcGeometry();
this.recalcBounds();
this.recalcWrapPolygon();
this.addToRecalculate();
};
CShape.prototype.convertPixToMM = function (pix) {
return this.getDrawingDocument().GetMMPerDot(pix);
};
CShape.prototype.getCanvasContext = function () {
return this.getDrawingDocument().CanvasHitContext;
};
CShape.prototype.getCompiledStyle = function () {
return this.style;
};
CShape.prototype.getHierarchy = function () {
return [];
};
CShape.prototype.getParentObjects = function () {
return {
slide: null,
layout: null,
master: null,
theme: editor.WordControl.m_oLogicDocument.theme
};
};
CShape.prototype.recalculateTxBoxContent = function () {
if (this.textBoxContent === null || this.textBoxContent.Parent !== this) {
return;
}
var _l, _t, _r, _b;
var body_pr = this.getBodyPr();
var l_ins = typeof body_pr.lIns === "number" ? body_pr.lIns : 2.54;
var t_ins = typeof body_pr.tIns === "number" ? body_pr.tIns : 1.27;
var r_ins = typeof body_pr.rIns === "number" ? body_pr.rIns : 2.54;
var b_ins = typeof body_pr.bIns === "number" ? body_pr.bIns : 1.27;
var _body_pr = this.getBodyPr();
if (this.spPr && isRealObject(this.spPr.geometry) && isRealObject(this.spPr.geometry.rect)) {
var _rect = this.spPr.geometry.rect;
_l = _rect.l + l_ins;
_t = _rect.t + t_ins;
_r = _rect.r - r_ins;
_b = _rect.b - b_ins;
} else {
_l = l_ins;
_t = t_ins;
_r = this.extX - r_ins;
_b = this.extY - b_ins;
}
if (!_body_pr.upright) {
var _content_width;
if (! (_body_pr.vert === nVertTTvert || _body_pr.vert === nVertTTvert270)) {
_content_width = _r - _l;
this.contentWidth = _content_width;
this.contentHeight = _b - _t;
} else {
_content_width = _b - _t;
this.contentWidth = _content_width;
this.contentHeight = _r - _l;
}
} else {
var _full_rotate = this.getFullRotate();
if (checkNormalRotate(_full_rotate)) {
if (! (_body_pr.vert === nVertTTvert || _body_pr.vert === nVertTTvert270)) {
_content_width = _r - _l;
this.contentWidth = _content_width;
this.contentHeight = _b - _t;
} else {
_content_width = _b - _t;
this.contentWidth = _content_width;
this.contentHeight = _r - _l;
}
} else {
if (! (_body_pr.vert === nVertTTvert || _body_pr.vert === nVertTTvert270)) {
_content_width = _b - _t;
this.contentWidth = _content_width;
this.contentHeight = _r - _l;
} else {
_content_width = _r - _l;
this.contentWidth = _content_width;
this.contentHeight = _b - _t;
}
}
}
this.textBoxContent.Reset(0, 0, _content_width, 20000);
var CurPage = 0;
var RecalcResult = recalcresult2_NextPage;
while (recalcresult2_End != RecalcResult) {
RecalcResult = this.textBoxContent.Recalculate_Page(CurPage++, true);
}
};
CShape.prototype.recalculate = function () {
if (this.bDeleted || !this.bWordShape) {
return;
}
ExecuteNoHistory(function () {
if (this.recalcInfo.recalculateBrush) {
this.recalculateBrush();
this.recalcInfo.recalculateBrush = false;
}
if (this.recalcInfo.recalculatePen) {
this.recalculatePen();
this.recalcInfo.recalculatePen = false;
}
if (this.recalcInfo.recalculateTransform) {
this.recalculateTransform();
this.recalcInfo.recalculateTransform = false;
}
if (this.recalcInfo.recalculateGeometry) {
this.recalculateGeometry();
this.recalcInfo.recalculateGeometry = false;
}
if (this.recalcInfo.recalculateBounds) {
this.recalculateBounds();
this.recalcInfo.recalculateBounds = false;
}
if (this.recalcInfo.recalculateWrapPolygon) {
this.recalculateWrapPolygon();
this.recalcInfo.recalculateWrapPolygon = false;
}
this.bNeedUpdatePosition = true;
},
this, []);
};
CShape.prototype.recalculateText = function () {
if (!this.bWordShape) {
return;
}
ExecuteNoHistory(function () {
if (this.bWordShape) {
if (this.recalcInfo.recalculateTxBoxContent) {
this.recalculateTxBoxContent();
this.recalcInfo.recalculateTxBoxContent = false;
}
} else {
if (this.recalcInfo.recalculateContent) {
this.recalculateContent();
this.recalcInfo.recalculateContent = false;
}
}
if (this.recalcInfo.recalculateTransformText) {
this.recalculateTransformText();
}
},
this, []);
};
CShape.prototype.recalculateWrapPolygon = function () {
if (this.parent) {
var wrapping_polygon = this.parent.wrappingPolygon;
if (!wrapping_polygon.edited) {
if (this.spTree) {
for (var i = 0; i < this.spTree.length; ++i) {
this.spTree[i].recalculate();
}
}
wrapping_polygon.calculate(this);
} else {
wrapping_polygon.calculateRelToAbs(this.localTransform, this);
}
}
};
CShape.prototype.getArrayWrapPolygons = function () {
var ret;
if (this.spPr && this.spPr.geometry) {
ret = this.spPr.geometry.getArrayPolygons();
} else {
ret = [];
}
var t = this.localTransform;
for (var i = 0; i < ret.length; ++i) {
var polygon = ret[i];
for (var j = 0; j < polygon.length; ++j) {
var p = polygon[j];
var x = t.TransformPointX(p.x, p.y);
var y = t.TransformPointY(p.x, p.y);
p.x = x;
p.y = y;
}
}
return ret;
};
CShape.prototype.recalculateContent = function () {
var content = this.getDocContent();
if (content) {
var w, h;
var l_ins, t_ins, r_ins, b_ins;
var body_pr = this.getBodyPr();
if (body_pr) {
l_ins = isRealNumber(body_pr.lIns) ? body_pr.lIns : 2.54;
r_ins = isRealNumber(body_pr.rIns) ? body_pr.rIns : 2.54;
t_ins = isRealNumber(body_pr.tIns) ? body_pr.tIns : 1.27;
b_ins = isRealNumber(body_pr.bIns) ? body_pr.bIns : 1.27;
} else {
l_ins = 2.54;
r_ins = 2.54;
t_ins = 1.27;
b_ins = 1.27;
}
if (this.spPr && this.spPr.geometry && this.spPr.geometry.rect && isRealNumber(this.spPr.geometry.rect.l) && isRealNumber(this.spPr.geometry.rect.t) && isRealNumber(this.spPr.geometry.rect.r) && isRealNumber(this.spPr.geometry.rect.r)) {
w = this.spPr.geometry.rect.r - this.spPr.geometry.rect.l - (l_ins + r_ins);
h = this.spPr.geometry.rect.b - this.spPr.geometry.rect.t - (t_ins + b_ins);
} else {
w = this.extX - (l_ins + r_ins);
h = this.extY - (t_ins + b_ins);
}
content.Reset(0, 0, w, h);
content.Recalculate_Page(content.StartPage, true);
}
};
CShape.prototype.recalculateTransform = function () {
this.recalculateLocalTransform(this.localTransform);
};
CShape.prototype.updatePosition = function (x, y) {
this.posX = x;
this.posY = y;
if (!this.group) {
this.x = this.localX + x;
this.y = this.localY + y;
} else {
this.x = this.localX;
this.y = this.localY;
}
this.updateTransformMatrix();
};
CShape.prototype.checkShapeChild = function () {
return false;
};
CShape.prototype.checkShapeChildTransform = function () {};
CShape.prototype.getArrayWrapIntervals = function (x0, y0, x1, y1, Y0Sp, Y1Sp, LeftField, RightField, arr_intervals) {
return this.parent.getArrayWrapIntervals(x0, y0, x1, y1, Y0Sp, Y1Sp, LeftField, RightField, arr_intervals);
};
CShape.prototype.updateTransformMatrix = function () {
this.transform = this.localTransform.CreateDublicate();
global_MatrixTransformer.TranslateAppend(this.transform, this.posX, this.posY);
this.invertTransform = global_MatrixTransformer.Invert(this.transform);
if (this.localTransformText) {
this.transformText = this.localTransformText.CreateDublicate();
global_MatrixTransformer.TranslateAppend(this.transformText, this.posX, this.posY);
this.invertTransformText = global_MatrixTransformer.Invert(this.transformText);
}
this.checkShapeChildTransform();
this.checkContentDrawings();
};
CShape.prototype.checkContentDrawings = function () {
if (this.textBoxContent) {
var all_drawings = this.textBoxContent.Get_AllDrawingObjects([]);
for (var i = 0; i < all_drawings.length; ++i) {
all_drawings[i].GraphicObj.updateTransformMatrix();
}
}
};
CShape.prototype.applyParentTransform = function (transform) {
global_MatrixTransformer.MultiplyAppend(this.transform, transform);
global_MatrixTransformer.MultiplyAppend(this.transformText, transform);
this.invertTransform = global_MatrixTransformer.Invert(this.transform);
this.invertTransformText = global_MatrixTransformer.Invert(this.transformText);
};
CShape.prototype.recalculateShapeStyleForParagraph = function () {
var styles = editor.WordControl.m_oLogicDocument.Styles;
this.textStyleForParagraph = {
TextPr: styles.Default.TextPr.Copy(),
ParaPr: styles.Default.ParaPr.Copy()
};
var DefId = styles.Default.Paragraph;
var DefaultStyle = styles.Style[DefId];
if (DefaultStyle) {
this.textStyleForParagraph.ParaPr.Merge(DefaultStyle.ParaPr);
this.textStyleForParagraph.TextPr.Merge(DefaultStyle.TextPr);
}
if (this.style && this.style.fontRef) {
this.textStyleForParagraph.TextPr.Color.Auto = false;
var shape_text_pr = new CTextPr();
if (this.style.fontRef.Color) {
shape_text_pr.Unifill = CreateUniFillByUniColorCopy(this.style.fontRef.Color);
}
if (this.style.fontRef.idx === fntStyleInd_major) {
shape_text_pr.RFonts.Ascii = {
Name: "+mj-lt",
Index: -1
};
shape_text_pr.RFonts.EastAsia = {
Name: "+mj-ea",
Index: -1
};
shape_text_pr.RFonts.CS = {
Name: "+mj-cs",
Index: -1
};
} else {
if (this.style.fontRef.idx === fntStyleInd_minor) {
shape_text_pr.RFonts.Ascii = {
Name: "+mn-lt",
Index: -1
};
shape_text_pr.RFonts.EastAsia = {
Name: "+mn-ea",
Index: -1
};
shape_text_pr.RFonts.CS = {
Name: "+mn-cs",
Index: -1
};
}
}
this.textStyleForParagraph.TextPr.Merge(shape_text_pr);
}
};
CShape.prototype.Get_ShapeStyleForPara = function () {
if (this.recalcInfo.recalculateShapeStyleForParagraph) {
this.recalculateShapeStyleForParagraph();
this.recalcInfo.recalculateShapeStyleForParagraph = false;
}
return this.textStyleForParagraph;
};
CShape.prototype.Refresh_RecalcData = function (data) {
this.recalcTxBoxContent();
this.recalcTransformText();
this.Refresh_RecalcData2();
};
CShape.prototype.Refresh_RecalcData2 = function () {
this.recalcTxBoxContent();
this.recalcTransformText();
this.addToRecalculate();
var HdrFtr = this.Is_HdrFtr(true);
if (HdrFtr) {
HdrFtr.Refresh_RecalcData2();
}
};
CShape.prototype.getStartPageAbsolute = function () {
return 0;
};
CShape.prototype.Get_StartPage_Absolute = function () {
return 0;
};
CShape.prototype.Get_Numbering = function () {
return editor.WordControl.m_oLogicDocument.Numbering;
};
CShape.prototype.Get_TableStyleForPara = function () {
return null;
};
CShape.prototype.Is_Cell = function () {
return false;
};
CShape.prototype.hitInTextRect = function (x, y) {
var content = this.getDocContent && this.getDocContent();
if (content) {
var t_x, t_y;
t_x = this.invertTransform.TransformPointX(x, y);
t_y = this.invertTransform.TransformPointY(x, y);
var w, h, x, y;
if (this.spPr && this.spPr.geometry && this.spPr.geometry.rect && isRealNumber(this.spPr.geometry.rect.l) && isRealNumber(this.spPr.geometry.rect.t) && isRealNumber(this.spPr.geometry.rect.r) && isRealNumber(this.spPr.geometry.rect.r)) {
x = this.spPr.geometry.rect.l;
y = this.spPr.geometry.rect.t;
w = this.spPr.geometry.rect.r - this.spPr.geometry.rect.l;
h = this.spPr.geometry.rect.b - this.spPr.geometry.rect.t;
} else {
x = 0;
y = 0;
w = this.extX;
h = this.extY;
}
return t_x > x && t_x < x + w && t_y > y && t_y < y + h;
}
return false;
};
CShape.prototype.Set_CurrentElement = function (bUpdate, pageIndex) {
var drawing_objects = editor.WordControl.m_oLogicDocument.DrawingObjects;
drawing_objects.resetSelection(true);
var para_drawing;
if (this.group) {
var main_group = this.group.getMainGroup();
drawing_objects.selectObject(main_group, pageIndex);
main_group.selectObject(this, pageIndex);
main_group.selection.textSelection = this;
drawing_objects.selection.groupSelection = main_group;
para_drawing = main_group.parent;
} else {
drawing_objects.selectObject(this, pageIndex);
drawing_objects.selection.textSelection = this;
para_drawing = this.parent;
}
var hdr_ftr = para_drawing.DocumentContent.Is_HdrFtr(true);
if (hdr_ftr) {
hdr_ftr.Content.CurPos.Type = docpostype_DrawingObjects;
hdr_ftr.Set_CurrentElement(bUpdate);
} else {
drawing_objects.document.CurPos.Type = docpostype_DrawingObjects;
drawing_objects.document.Selection.Use = true;
if (true === bUpdate) {
drawing_objects.document.Document_UpdateInterfaceState();
drawing_objects.document.Document_UpdateRulersState();
drawing_objects.document.Document_UpdateSelectionState();
}
}
};
CShape.prototype.GetParaDrawing = function () {
if (this.group) {
var cur_group = this.group;
while (cur_group.group) {
cur_group = cur_group.group;
}
if (cur_group.parent) {
return cur_group.parent;
}
} else {
if (this.parent) {
return this.parent;
}
}
return null;
};
CShape.prototype.Get_StartPage_Relative = function () {
return 0;
};
CShape.prototype.Check_TableCoincidence = function (table) {
var para_drawing = this.GetParaDrawing();
if (para_drawing && para_drawing.DocumentContent) {
return para_drawing.DocumentContent.Check_TableCoincidence(table);
}
return false;
};
CShape.prototype.Get_PrevElementEndInfo = function (CurElement) {
var para_drawing = this.GetParaDrawing();
if (isRealObject(para_drawing) && isRealObject(para_drawing.DocumentContent) && (para_drawing.DocumentContent.Get_PrevElementEndInfo)) {
var parent_paragraph = para_drawing.Get_ParentParagraph();
if (parent_paragraph) {
return para_drawing.DocumentContent.Get_PrevElementEndInfo(parent_paragraph);
}
}
return null;
};
CShape.prototype.Is_ThisElementCurrent = function (CurElement) {
return editor.WordControl.m_oLogicDocument.DrawingObjects.getTargetDocContent() === this.getDocContent();
};
CShape.prototype.Is_UseInDocument = function () {
return !this.bDeleted;
};
CShape.prototype.Is_HdrFtr = function (bool) {
if (!this.group) {
if (isRealObject(this.parent) && isRealObject(this.parent.DocumentContent)) {
return this.parent.DocumentContent.Is_HdrFtr(bool);
}
} else {
var cur_group = this.group;
while (cur_group.group) {
cur_group = cur_group.group;
}
if (isRealObject(cur_group.parent) && isRealObject(cur_group.parent.DocumentContent)) {
return cur_group.parent.DocumentContent.Is_HdrFtr(bool);
}
}
return bool ? null : false;
};
CShape.prototype.OnContentReDraw = function () {
if (!isRealObject(this.group)) {
if (isRealObject(this.parent)) {
this.parent.OnContentReDraw();
}
} else {
var cur_group = this.group;
while (isRealObject(cur_group.group)) {
cur_group = cur_group.group;
}
if (isRealObject(cur_group) && isRealObject(cur_group.parent)) {
cur_group.parent.OnContentReDraw();
}
}
};
CShape.prototype.Get_TextBackGroundColor = function () {
return undefined;
};
CShape.prototype.documentStatistics = function (stats) {
var content = this.getDocContent();
return content && content.DocumentStatistics(stats);
};
CShape.prototype.checkPosTransformText = function () {
if (isRealNumber(this.posX) && isRealNumber(this.posY)) {
this.transformText = this.localTransformText.CreateDublicate();
global_MatrixTransformer.TranslateAppend(this.transformText, this.posX, this.posY);
this.invertTransformText = global_MatrixTransformer.Invert(this.transformText);
}
};
CShape.prototype.getNearestPos = function (x, y, pageIndex) {
if (isRealObject(this.textBoxContent)) {
var t_x = this.invertTransformText.TransformPointX(x, y);
var t_y = this.invertTransformText.TransformPointY(x, y);
var nearest_pos = this.textBoxContent.Get_NearestPos(pageIndex, t_x, t_y, false);
nearest_pos.transform = this.transformText;
return nearest_pos;
}
return null;
};
CShape.prototype.cursorGetPos = function () {
var content = this.getDocContent();
if (isRealObject(content)) {
var pos = content.Cursor_GetPos();
var transform = this.transformText;
var x = transform.TransformPointX(pos.X, pos.Y);
var y = transform.TransformPointY(pos.X, pos.Y);
return {
X: x,
Y: y
};
}
return {
X: 0,
Y: 0
};
};
CShape.prototype.cursorMoveAt = function (X, Y, AddToSelect) {
var content = this.getDocContent();
if (isRealObject(content)) {
var t_x = this.invertTransformText.TransformPointX(X, Y);
var t_y = this.invertTransformText.TransformPointY(X, Y);
content.Cursor_MoveAt(t_x, t_y, AddToSelect, undefined, isRealNumber(this.selectStartPage) ? this.selectStartPage : 0);
}
};
CShape.prototype.Get_Styles = function () {
return editor.WordControl.m_oLogicDocument.Styles;
};
CShape.prototype.Is_InTable = function (bReturnTopTable) {
if (true === bReturnTopTable) {
return null;
}
return false;
};
CShape.prototype.Get_Numbering = function () {
return editor.WordControl.m_oLogicDocument.Get_Numbering();
};
CShape.prototype.Get_TableStyleForPara = function () {
return editor.WordControl.m_oLogicDocument.Get_TableStyleForPara();
};
CShape.prototype.Is_Cell = function () {
return false;
};
CShape.prototype.Is_DrawingShape = function () {
return true;
};
CShape.prototype.Is_InTable = function (bReturnTopTable) {
if (true === bReturnTopTable) {
return null;
}
return false;
};
CShape.prototype.canChangeWrapPolygon = function (bReturnTopTable) {
return true;
};
CShape.prototype.Get_ColorMap = function () {
return editor.WordControl.m_oLogicDocument.Get_ColorMap();
};
CShape.prototype.Is_TopDocument = function () {
return false;
};
CShape.prototype.recalcText = function () {
if (this.recalculateText && this.recalcTxBoxContent && this.recalculateText) {
this.recalcTxBoxContent();
this.recalcTransformText();
}
};
CShape.prototype.getRecalcObject = function () {
var content = this.getDocContent && this.getDocContent();
if (content) {
return content.Save_RecalculateObject();
}
if (this.spTree) {
var ret = [];
for (var i = 0; i < this.spTree.length; ++i) {
ret.push(this.spTree[i].getRecalcObject());
}
return ret;
}
return null;
};
CShape.prototype.setRecalcObject = function (object) {
if (!object) {
return;
}
var content = this.getDocContent && this.getDocContent();
if (content) {
content.Load_RecalculateObject(object);
}
if (Array.isArray(object) && this.spTree && this.spTree.length === object.length) {
for (var i = 0; i < this.spTree.length; ++i) {
this.spTree[i].setRecalcObject(object[i]);
}
}
};
CShape.prototype.setStartPage = function (pageIndex, bNoResetSelectPage) {
if (! (bNoResetSelectPage === true)) {
this.selectStartPage = pageIndex;
}
var content = this.getDocContent && this.getDocContent();
content && content.Set_StartPage(pageIndex);
if (Array.isArray(this.spTree)) {
for (var i = 0; i < this.spTree.length; ++i) {
this.spTree[i].setStartPage && this.spTree[i].setStartPage(pageIndex);
}
}
};
CShape.prototype.getStyles = function () {
return {
styles: editor.WordControl.m_oLogicDocument.Styles,
styleId: null
};
};

File diff suppressed because it is too large Load Diff

View File

@@ -1,445 +1,409 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
var DRAWING_ARRAY_TYPE_INLINE = 0;
var DRAWING_ARRAY_TYPE_BEHIND = 1;
var DRAWING_ARRAY_TYPE_WRAPPING = 2;
var DRAWING_ARRAY_TYPE_BEFORE = 3;
function CGraphicPage(pageIndex, graphicObjects) {
this.pageIndex = pageIndex;
this.graphicObjects = graphicObjects;
this.drawingDocument = graphicObjects.drawingDocument;
this.arrGraphicObjects = [];
this.selectionInfo = {
selectionArray: []
};
this.objectsMap = {};
this.inlineObjects = [];
this.behindDocObjects = [];
this.wrappingObjects = [];
this.beforeTextObjects = [];
this.wrapManager = new CWrapManager(this);
this.flowTables = [];
}
CGraphicPage.prototype = {
redrawCharts: function () {
var arr = [this.inlineObjects, this.behindDocObjects, this.wrappingObjects, this.beforeTextObjects];
for (var i = 0; i < arr.length; ++i) {
var cur_arr = arr[i];
for (var j = 0; j < cur_arr.length; ++j) {
if (typeof CChartAsGroup != "undefined" && cur_arr[j].GraphicObj instanceof CChartAsGroup) {
cur_arr[j].GraphicObj.recalculate();
}
}
}
},
addFloatTable: function (table) {
this.flowTables.push(table);
},
CheckRange: function (X0, Y0, X1, Y1, Y0sp, Y1Ssp, LeftField, RightField, HdrFtrRanges, docContent) {
return this.wrapManager.checkRanges(X0, Y0, X1, Y1, Y0sp, Y1Ssp, LeftField, RightField, HdrFtrRanges, docContent);
},
removeFloatTableById: function (id) {
for (var index = 0; index < this.flowTables.length; ++index) {
if (this.flowTables[index].Id === id) {
this.flowTables.splice(index, 1);
return;
}
}
},
documentStatistics: function (Statistics) {
var cur_array = this.inlineObjects;
for (var i = 0; i < cur_array.length; ++i) {
cur_array[i].documentStatistics(Statistics);
}
cur_array = this.behindDocObjects;
for (i = 0; i < cur_array.length; ++i) {
cur_array[i].documentStatistics(Statistics);
}
cur_array = this.wrappingObjects;
for (i = 0; i < cur_array.length; ++i) {
cur_array[i].documentStatistics(Statistics);
}
cur_array = this.beforeTextObjects;
for (i = 0; i < cur_array.length; ++i) {
cur_array[i].documentStatistics(Statistics);
}
},
getObjectByXY: function (x, y) {
for (var index = this.flowTables.length - 1; index > -1; - index) {
var flow_table = this.flowTables[index];
if (x >= flow_table.X && x <= flow_table.X + flow_table.W && y >= flow_table.Y && y <= flow_table.Y + flow_table.H) {
return flow_table;
}
}
for (index = this.beforeTextObjects.length; index > -1; --index) {
if (this.beforeTextObjects[index].hit(x, y)) {
return this.beforeTextObjects[index];
}
}
for (index = this.wrappingObjects.length; index > -1; --index) {
if (this.wrappingObjects[index].hit(x, y)) {
return this.wrappingObjects[index];
}
}
for (index = this.inlineObjects.length; index > -1; --index) {
if (this.inlineObjects[index].hit(x, y)) {
return this.inlineObjects[index];
}
}
return null;
},
getTableByXY: function (x, y, documentContent) {
for (var index = this.flowTables.length - 1; index > -1; --index) {
if (this.flowTables[index].IsPointIn(x, y) && this.flowTables[index].Table.Parent === documentContent) {
return this.flowTables[index];
}
}
return null;
},
getObjectById: function (id, type) {
if (!isNaN(type) && typeof type === "number") {
var drawing_array;
switch (type) {
case DRAWING_ARRAY_TYPE_BEFORE:
drawing_array = this.beforeTextObjects;
break;
case DRAWING_ARRAY_TYPE_BEHIND:
drawing_array = this.behindDocObjects;
break;
case DRAWING_ARRAY_TYPE_INLINE:
drawing_array = this.inlineObjects;
break;
case DRAWING_ARRAY_TYPE_WRAPPING:
drawing_array = this.wrappingObjects;
break;
}
if (Array.isArray(drawing_array)) {
for (var index = 0; index < drawing_array.length; ++index) {
if (drawing_array[index].Get_Id() === id) {
return drawing_array[index];
}
}
}
} else {
drawing_array = this.beforeTextObjects;
for (index = 0; index < drawing_array.length; ++index) {
if (drawing_array[index].Get_Id() === id) {
return drawing_array[index];
}
}
drawing_array = this.behindDocObjects;
for (index = 0; index < drawing_array.length; ++index) {
if (drawing_array[index].Get_Id() === id) {
return drawing_array[index];
}
}
drawing_array = this.inlineObjects;
for (index = 0; index < drawing_array.length; ++index) {
if (drawing_array[index].Get_Id() === id) {
return drawing_array[index];
}
}
drawing_array = this.wrappingObjects;
for (index = 0; index < drawing_array.length; ++index) {
if (drawing_array[index].Get_Id() === id) {
return drawing_array[index];
}
}
}
return null;
},
delObjectById: function (id, type) {
if (!isNaN(type) && typeof type === "number") {
var drawing_array;
switch (type) {
case DRAWING_ARRAY_TYPE_BEFORE:
drawing_array = this.beforeTextObjects;
break;
case DRAWING_ARRAY_TYPE_BEHIND:
drawing_array = this.behindDocObjects;
break;
case DRAWING_ARRAY_TYPE_INLINE:
drawing_array = this.inlineObjects;
break;
case DRAWING_ARRAY_TYPE_WRAPPING:
drawing_array = this.wrappingObjects;
break;
}
if (Array.isArray(drawing_array)) {
for (var index = 0; index < drawing_array.length; ++index) {
if (drawing_array[index].Get_Id() === id) {
return drawing_array.splice(index, 1);
}
}
}
} else {
drawing_array = this.beforeTextObjects;
for (index = 0; index < drawing_array.length; ++index) {
if (drawing_array[index].Get_Id() === id) {
return drawing_array.splice(index, 1);
}
}
drawing_array = this.behindDocObjects;
for (index = 0; index < drawing_array.length; ++index) {
if (drawing_array[index].Get_Id() === id) {
return drawing_array.splice(index, 1);
}
}
drawing_array = this.inlineObjects;
for (index = 0; index < drawing_array.length; ++index) {
if (drawing_array[index].Get_Id() === id) {
return drawing_array.splice(index, 1);
}
}
drawing_array = this.wrappingObjects;
for (index = 0; index < drawing_array.length; ++index) {
if (drawing_array[index].Get_Id() === id) {
return drawing_array.splice(index, 1);
}
}
}
return null;
},
resetDrawingArrays: function (docContent) {
if (!isRealObject(docContent) || docContent === editor.WordControl.m_oLogicDocument) {}
if (isRealObject(docContent)) {
if (docContent.Is_TopDocument()) {
if (!docContent.Is_HdrFtr()) {
this.objectsMap = {};
this.inlineObjects.length = 0;
this.behindDocObjects.length = 0;
this.wrappingObjects.length = 0;
this.beforeTextObjects.length = 0;
this.flowTables.length = 0;
} else {
var hdr_ftr;
if (this.pageIndex === 0) {
if (isRealObject(this.graphicObjects.firstPage)) {
hdr_ftr = this.graphicObjects.firstPage;
}
} else {
if (this.pageIndex % 2 === 1) {
hdr_ftr = this.graphicObjects.evenPage;
} else {
hdr_ftr = this.graphicObjects.oddPage;
}
}
if (isRealObject(hdr_ftr)) {
var arr = [hdr_ftr.behindDocArray, hdr_ftr.inlineArray, hdr_ftr.wrappingArray, hdr_ftr.beforeTextArray];
if (isRealObject(arr)) {
for (var i = 0; i < 4; ++i) {
var a = arr[i];
for (var j = a.length - 1; j > -1; --j) {
o = a[j];
if (isRealObject(o) && isRealObject(o.Parent) && isRealObject(o.Parent.Parent) && o.Parent.Parent === docContent) {
a.splice(j, 1);
}
}
}
a = hdr_ftr.floatTables;
for (var j = a.length - 1; j > -1; --j) {
o = a[j];
if (isRealObject(o) && isRealObject(o.Table) && isRealObject(o.Table.Parent) && o.Table.Parent === docContent) {
a.splice(j, 1);
}
}
}
}
}
} else {
for (var key in this.objectsMap) {
var o = this.objectsMap[key];
if (isRealObject(o) && isRealObject(o.Parent) && isRealObject(o.Parent.Parent)) {
if (o.Parent.Parent === docContent) {
delete this.objectsMap[key];
}
}
}
if (!docContent.Is_HdrFtr()) {
arr = [this.inlineObjects, this.behindDocObjects, this.wrappingObjects, this.beforeTextObjects];
} else {
var hdr_ftr = null;
if (this.pageIndex === 0) {
hdr_ftr = this.graphicObjects.firstPage;
} else {
if (this.pageIndex % 2 === 1) {
hdr_ftr = this.graphicObjects.evenPage;
} else {
hdr_ftr = this.graphicObjects.oddPage;
}
}
if (isRealObject(hdr_ftr)) {
arr = [hdr_ftr.behindDocArray, hdr_ftr.inlineArray, hdr_ftr.wrappingArray, hdr_ftr.beforeTextArray];
}
}
if (isRealObject(arr)) {
for (var i = 0; i < 4; ++i) {
var a = arr[i];
for (var j = a.length - 1; j > -1; --j) {
o = a[j];
if (isRealObject(o) && isRealObject(o.Parent) && isRealObject(o.Parent.Parent) && o.Parent.Parent === docContent) {
a.splice(j, 1);
}
}
}
a = [];
if (!docContent.Is_HdrFtr()) {
a = this.flowTables;
} else {
if (isRealObject(hdr_ftr)) {
a = hdr_ftr.floatTables;
}
}
for (var j = a.length - 1; j > -1; --j) {
o = a[j];
if (isRealObject(o) && isRealObject(o.Table) && isRealObject(o.Table.Parent) && o.Table.Parent === docContent) {
a.splice(j, 1);
}
}
}
}
}
},
draw: function (graphics) {
for (var _object_index = 0; _object_index < this.inlineObjects.length; ++_object_index) {
this.inlineObjects[_object_index].draw(graphics);
}
for (_object_index = 0; _object_index < this.wrappingObjects.length; ++_object_index) {
this.wrappingObjects[_object_index].draw(graphics);
}
for (_object_index = 0; _object_index < this.beforeTextObjects.length; ++_object_index) {
this.beforeTextObjects[_object_index].draw(graphics);
}
for (_object_index = 0; _object_index < this.behindDocObjects.length; ++_object_index) {
this.behindDocObjects[_object_index].draw(graphics);
}
},
drawSelect: function () {
var _graphic_objects = this.selectionInfo.selectionArray;
var _object_index;
var _objects_count = _graphic_objects.length;
var _graphic_object;
for (_object_index = 0; _object_index < _objects_count; ++_object_index) {
_graphic_object = _graphic_objects[_object_index].graphicObject;
var _transform = _graphic_object.getTransformMatrix();
if (_transform === null) {
_transform = new CMatrix();
}
var _extensions = _graphic_object.getExtensions();
if (_extensions === null) {
_extensions = {
extX: 0,
extY: 0
};
}
this.drawingDocument.DrawTrack(TYPE_TRACK_SHAPE, _transform, 0, 0, _extensions.extX, _extensions.extY, false);
}
},
selectionCheck: function (x, y) {},
documentSearch: function (String, search_Common) {
var hdr_ftr;
if (this.pageIndex === 0) {
hdr_ftr = this.graphicObjects.firstPage;
} else {
if (this.pageIndex % 2 === 1) {
hdr_ftr = this.graphicObjects.evenPage;
} else {
hdr_ftr = this.graphicObjects.oddPage;
}
}
var search_array = [];
if (isRealObject(hdr_ftr)) {
search_array = search_array.concat(hdr_ftr.behindDocArray);
search_array = search_array.concat(hdr_ftr.wrappingArray);
search_array = search_array.concat(hdr_ftr.inlineArray);
search_array = search_array.concat(hdr_ftr.beforeTextArray);
}
search_array = search_array.concat(this.behindDocObjects);
search_array = search_array.concat(this.wrappingObjects);
search_array = search_array.concat(this.inlineObjects);
search_array = search_array.concat(this.beforeTextObjects);
for (var i = 0; i < search_array.length; ++i) {
search_array[i].documentSearch(String, search_Common);
}
},
addGraphicObject: function (graphicObject) {
switch (graphicObject.getDrawingArrayType()) {
case DRAWING_ARRAY_TYPE_INLINE:
this.inlineObjects.push(graphicObject);
break;
case DRAWING_ARRAY_TYPE_BEHIND:
this.behindDocObjects.push(graphicObject);
this.behindDocObjects.sort(ComparisonByZIndexSimple);
break;
case DRAWING_ARRAY_TYPE_WRAPPING:
this.wrappingObjects.push(graphicObject);
this.wrappingObjects.sort(ComparisonByZIndexSimple);
break;
case DRAWING_ARRAY_TYPE_BEFORE:
this.beforeTextObjects.push(graphicObject);
this.beforeTextObjects.sort(ComparisonByZIndexSimple);
break;
}
},
drawBehindDoc: function (graphics) {
for (var _object_index = 0; _object_index < this.behindDocObjects.length; ++_object_index) {
this.behindDocObjects[_object_index].draw(graphics);
}
graphics.SetIntegerGrid(true);
},
drawWrappingObjects: function (graphics) {
for (var _object_index = 0; _object_index < this.wrappingObjects.length; ++_object_index) {
this.wrappingObjects[_object_index].draw(graphics);
}
graphics.SetIntegerGrid(true);
},
drawBeforeObjects: function (graphics) {
for (var _object_index = 0; _object_index < this.beforeTextObjects.length; ++_object_index) {
this.beforeTextObjects[_object_index].draw(graphics);
}
graphics.SetIntegerGrid(true);
},
drawInlineObjects: function (graphics) {
for (var _object_index = 0; _object_index < this.inlineObjects.length; ++_object_index) {
this.inlineObjects[_object_index].draw(graphics);
}
graphics.SetIntegerGrid(true);
}
};
function ComparisonByZIndex(grObj1, grObj2) {
if (grObj1 !== null && grObj2 !== null && typeof grObj1 === "object" && typeof grObj2 === "object") {
if (typeof grObj1.RelativeHeight === "number" && typeof grObj2.RelativeHeight === "number") {
return grObj1.RelativeHeight - grObj2.RelativeHeight;
}
}
return 0;
}
/*
* (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
*
*/
var DRAWING_ARRAY_TYPE_INLINE = 0;
var DRAWING_ARRAY_TYPE_BEHIND = 1;
var DRAWING_ARRAY_TYPE_WRAPPING = 2;
var DRAWING_ARRAY_TYPE_BEFORE = 3;
function CGraphicPage(pageIndex, graphicObjects) {
this.pageIndex = pageIndex;
this.graphicObjects = graphicObjects;
this.drawingDocument = editor.WordControl.m_oDrawingDocument;
this.arrGraphicObjects = [];
this.selectionInfo = {
selectionArray: []
};
this.objectsMap = {};
this.inlineObjects = [];
this.behindDocObjects = [];
this.wrappingObjects = [];
this.beforeTextObjects = [];
this.flowTables = [];
this.hdrFtrPage = null;
this.wrapManager = null;
if (graphicObjects) {
this.hdrFtrPage = new CGraphicPage(pageIndex, null);
this.wrapManager = new CWrapManager(this);
}
}
CGraphicPage.prototype = {
addFloatTable: function (table) {
for (var i = 0; i < this.flowTables.length; ++i) {
if (this.flowTables[i] === table) {
return;
}
}
this.flowTables.push(table);
},
addObject: function (object) {
var array_type = object.parent.getDrawingArrayType();
var drawing_array, need_sort = true;
switch (array_type) {
case DRAWING_ARRAY_TYPE_INLINE:
drawing_array = this.inlineObjects;
need_sort = false;
break;
case DRAWING_ARRAY_TYPE_BEHIND:
drawing_array = this.behindDocObjects;
break;
case DRAWING_ARRAY_TYPE_BEFORE:
drawing_array = this.beforeTextObjects;
break;
case DRAWING_ARRAY_TYPE_WRAPPING:
drawing_array = this.wrappingObjects;
break;
}
if (Array.isArray(drawing_array)) {
for (var i = 0; i < drawing_array.length; ++i) {
if (drawing_array[i] === object) {
break;
}
}
if (i === drawing_array.length) {
drawing_array.push(object);
if (need_sort) {
drawing_array.sort(ComparisonByZIndexSimpleParent);
}
}
}
},
concatPage: function (page) {
this.inlineObjects = this.inlineObjects.concat(page.inlineObjects);
this.behindDocObjects = this.behindDocObjects.concat(page.behindDocObjects);
this.wrappingObjects = this.wrappingObjects.concat(page.wrappingObjects);
this.beforeTextObjects = this.beforeTextObjects.concat(page.beforeTextObjects);
this.flowTables = this.flowTables.concat(page.flowTables);
},
mergePages: function (page1, page2) {
if (page1) {
this.concatPage(page1);
}
if (page2) {
this.concatPage(page2);
}
this.behindDocObjects.sort(ComparisonByZIndexSimpleParent);
this.wrappingObjects.sort(ComparisonByZIndexSimpleParent);
this.beforeTextObjects.sort(ComparisonByZIndexSimpleParent);
},
clear: function () {
this.inlineObjects = [];
this.behindDocObjects = [];
this.wrappingObjects = [];
this.beforeTextObjects = [];
this.flowTables = [];
},
CheckRange: function (X0, Y0, X1, Y1, Y0sp, Y1Ssp, LeftField, RightField, HdrFtrRanges, docContent) {
return this.wrapManager.checkRanges(X0, Y0, X1, Y1, Y0sp, Y1Ssp, LeftField, RightField, HdrFtrRanges, docContent);
},
removeFloatTableById: function (id) {
for (var index = 0; index < this.flowTables.length; ++index) {
if (this.flowTables[index].Id === id) {
this.flowTables.splice(index, 1);
return;
}
}
},
documentStatistics: function (Statistics) {
var cur_array = this.inlineObjects.concat(this.behindDocObjects).concat(this.wrappingObjects).concat(this.beforeTextObjects);
for (var i = 0; i < cur_array.length; ++i) {
if (cur_array[i].documentStatistics) {
cur_array[i].documentStatistics(Statistics);
}
}
},
getTableByXY: function (x, y, documentContent) {
for (var index = this.flowTables.length - 1; index > -1; --index) {
if (this.flowTables[index].IsPointIn(x, y) && this.flowTables[index].Table.Parent === documentContent) {
return this.flowTables[index];
}
}
return null;
},
getObjectById: function (id, type) {
if (!isNaN(type) && typeof type === "number") {
var drawing_array;
switch (type) {
case DRAWING_ARRAY_TYPE_BEFORE:
drawing_array = this.beforeTextObjects;
break;
case DRAWING_ARRAY_TYPE_BEHIND:
drawing_array = this.behindDocObjects;
break;
case DRAWING_ARRAY_TYPE_INLINE:
drawing_array = this.inlineObjects;
break;
case DRAWING_ARRAY_TYPE_WRAPPING:
drawing_array = this.wrappingObjects;
break;
}
if (Array.isArray(drawing_array)) {
for (var index = 0; index < drawing_array.length; ++index) {
if (drawing_array[index].Get_Id() === id) {
return drawing_array[index];
}
}
}
} else {
drawing_array = this.beforeTextObjects;
for (index = 0; index < drawing_array.length; ++index) {
if (drawing_array[index].Get_Id() === id) {
return drawing_array[index];
}
}
drawing_array = this.behindDocObjects;
for (index = 0; index < drawing_array.length; ++index) {
if (drawing_array[index].Get_Id() === id) {
return drawing_array[index];
}
}
drawing_array = this.inlineObjects;
for (index = 0; index < drawing_array.length; ++index) {
if (drawing_array[index].Get_Id() === id) {
return drawing_array[index];
}
}
drawing_array = this.wrappingObjects;
for (index = 0; index < drawing_array.length; ++index) {
if (drawing_array[index].Get_Id() === id) {
return drawing_array[index];
}
}
}
return null;
},
delObjectById: function (id, type) {
if (!isNaN(type) && typeof type === "number") {
var drawing_array;
switch (type) {
case DRAWING_ARRAY_TYPE_BEFORE:
drawing_array = this.beforeTextObjects;
break;
case DRAWING_ARRAY_TYPE_BEHIND:
drawing_array = this.behindDocObjects;
break;
case DRAWING_ARRAY_TYPE_INLINE:
drawing_array = this.inlineObjects;
break;
case DRAWING_ARRAY_TYPE_WRAPPING:
drawing_array = this.wrappingObjects;
break;
}
if (Array.isArray(drawing_array)) {
for (var index = 0; index < drawing_array.length; ++index) {
if (drawing_array[index].parent && drawing_array[index].parent.Get_Id() === id) {
return drawing_array.splice(index, 1);
}
}
}
} else {
drawing_array = this.beforeTextObjects;
for (index = 0; index < drawing_array.length; ++index) {
if (drawing_array[index].parent && drawing_array[index].parent.Get_Id() === id) {
return drawing_array.splice(index, 1);
}
}
drawing_array = this.behindDocObjects;
for (index = 0; index < drawing_array.length; ++index) {
if (drawing_array[index].parent && drawing_array[index].parent.Get_Id() === id) {
return drawing_array.splice(index, 1);
}
}
drawing_array = this.inlineObjects;
for (index = 0; index < drawing_array.length; ++index) {
if (drawing_array[index].parent && drawing_array[index].parent.Get_Id() === id) {
return drawing_array.splice(index, 1);
}
}
drawing_array = this.wrappingObjects;
for (index = 0; index < drawing_array.length; ++index) {
if (drawing_array[index].parent && drawing_array[index].parent.Get_Id() === id) {
return drawing_array.splice(index, 1);
}
}
}
return null;
},
resetDrawingArrays: function (docContent) {
function findInArrayAndRemove(drawingArray, docContent, document) {
if (docContent === document) {
drawingArray.length = 0;
return;
}
var b_is_top_doc = docContent.Is_TopDocument();
for (var i = drawingArray.length - 1; i > -1; --i) {
if (!drawingArray[i].parent || drawingArray[i].parent.DocumentContent === docContent || (b_is_top_doc && drawingArray[i].parent.DocumentContent.Is_TopDocument(true) === docContent)) {
drawingArray.splice(i, 1);
}
}
}
function findTableInArrayAndRemove(drawingArray, docContent, document) {
if (!docContent === document) {
drawingArray.length = 0;
return;
}
for (var i = drawingArray.length - 1; i > -1; --i) {
if (drawingArray[i].Table.Parent === docContent) {
drawingArray.splice(i, 1);
}
}
}
function findInArrayAndRemoveFromDrawingPage(drawingPage, docContent, document) {
if (!drawingPage) {
return;
}
if (Array.isArray(drawingPage.inlineObjects)) {
findInArrayAndRemove(drawingPage.inlineObjects, docContent, document);
findInArrayAndRemove(drawingPage.behindDocObjects, docContent, document);
findInArrayAndRemove(drawingPage.wrappingObjects, docContent, document);
findInArrayAndRemove(drawingPage.beforeTextObjects, docContent, document);
findTableInArrayAndRemove(drawingPage.flowTables, docContent, document);
}
}
if (!isRealObject(docContent)) {
docContent = this.graphicObjects.document;
}
findInArrayAndRemoveFromDrawingPage(this, docContent, editor.WordControl.m_oLogicDocument);
},
draw: function (graphics) {
for (var _object_index = 0; _object_index < this.inlineObjects.length; ++_object_index) {
this.inlineObjects[_object_index].draw(graphics);
}
for (_object_index = 0; _object_index < this.wrappingObjects.length; ++_object_index) {
this.wrappingObjects[_object_index].draw(graphics);
}
for (_object_index = 0; _object_index < this.beforeTextObjects.length; ++_object_index) {
this.beforeTextObjects[_object_index].draw(graphics);
}
for (_object_index = 0; _object_index < this.behindDocObjects.length; ++_object_index) {
this.behindDocObjects[_object_index].draw(graphics);
}
},
drawSelect: function () {
var _graphic_objects = this.selectionInfo.selectionArray;
var _object_index;
var _objects_count = _graphic_objects.length;
var _graphic_object;
for (_object_index = 0; _object_index < _objects_count; ++_object_index) {
_graphic_object = _graphic_objects[_object_index].graphicObject;
var _transform = _graphic_object.getTransformMatrix();
if (_transform === null) {
_transform = new CMatrix();
}
var _extensions = _graphic_object.getExtensions();
if (_extensions === null) {
_extensions = {
extX: 0,
extY: 0
};
}
this.drawingDocument.DrawTrack(TYPE_TRACK_SHAPE, _transform, 0, 0, _extensions.extX, _extensions.extY, false);
}
},
selectionCheck: function (x, y) {},
documentSearch: function (String, search_Common) {
var search_array = [];
search_array = search_array.concat(this.behindDocObjects);
search_array = search_array.concat(this.wrappingObjects);
search_array = search_array.concat(this.inlineObjects);
search_array = search_array.concat(this.beforeTextObjects);
for (var i = 0; i < search_array.length; ++i) {
if (search_array[i].documentSearch) {
search_array[i].documentSearch(String, search_Common);
}
}
},
addGraphicObject: function (graphicObject) {
switch (graphicObject.getDrawingArrayType()) {
case DRAWING_ARRAY_TYPE_INLINE:
this.inlineObjects.push(graphicObject);
break;
case DRAWING_ARRAY_TYPE_BEHIND:
this.behindDocObjects.push(graphicObject);
this.behindDocObjects.sort(ComparisonByZIndexSimpleParent);
break;
case DRAWING_ARRAY_TYPE_WRAPPING:
this.wrappingObjects.push(graphicObject);
this.wrappingObjects.sort(ComparisonByZIndexSimpleParent);
break;
case DRAWING_ARRAY_TYPE_BEFORE:
this.beforeTextObjects.push(graphicObject);
this.beforeTextObjects.sort(ComparisonByZIndexSimpleParent);
break;
}
},
sortDrawingArrays: function () {
this.behindDocObjects.sort(ComparisonByZIndexSimpleParent);
this.wrappingObjects.sort(ComparisonByZIndexSimpleParent);
this.beforeTextObjects.sort(ComparisonByZIndexSimpleParent);
if (this.hdrFtrPage) {
this.hdrFtrPage.sortDrawingArrays();
}
},
drawBehindDoc: function (graphics) {
for (var _object_index = 0; _object_index < this.behindDocObjects.length; ++_object_index) {
this.behindDocObjects[_object_index].draw(graphics);
}
graphics.SetIntegerGrid(true);
},
drawWrappingObjects: function (graphics) {
var drawing;
for (var _object_index = 0; _object_index < this.wrappingObjects.length; ++_object_index) {
drawing = this.wrappingObjects[_object_index];
if (! (drawing.parent && drawing.parent.DocumentContent && drawing.parent.DocumentContent.Is_TableCellContent())) {
drawing.draw(graphics);
}
}
graphics.SetIntegerGrid(true);
},
drawWrappingObjectsByContent: function (graphics, content) {
var bIntegerGrid = graphics.m_bIntegerGrid;
var drawing;
for (var _object_index = 0; _object_index < this.wrappingObjects.length; ++_object_index) {
drawing = this.wrappingObjects[_object_index];
if (drawing.parent && drawing.parent.DocumentContent && drawing.parent.DocumentContent === content) {
drawing.draw(graphics);
}
}
graphics.SetIntegerGrid(bIntegerGrid);
},
drawBeforeObjects: function (graphics) {
for (var _object_index = 0; _object_index < this.beforeTextObjects.length; ++_object_index) {
this.beforeTextObjects[_object_index].draw(graphics);
}
graphics.SetIntegerGrid(true);
},
drawInlineObjects: function (graphics) {
for (var _object_index = 0; _object_index < this.inlineObjects.length; ++_object_index) {
this.inlineObjects[_object_index].draw(graphics);
}
graphics.SetIntegerGrid(true);
}
};

View File

@@ -1,54 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
var cToRad = Math.PI / (60000 * 180);
var cToDeg = 1 / cToRad;
function Cos(angle) {
return Math.cos(cToRad * angle);
}
function Sin(angle) {
return Math.sin(cToRad * angle);
}
function Tan(angle) {
return Math.tan(cToRad * angle);
}
function ATan(x) {
return cToDeg * Math.atan(x);
}
function ATan2(y, x) {
return cToDeg * Math.atan2(y, x);
}
function CAt2(x, y, z) {
return x * (Math.cos(Math.atan2(z, y)));
}
function SAt2(x, y, z) {
return x * (Math.sin(Math.atan2(z, y)));
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,245 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
var LAYOUT_MODE_EDGE = 0;
var LAYOUT_MODE_FACTOR = 1;
var LAYOUT_TARGET_INNER = 0;
var LAYOUT_TARGET_OUTER = 1;
function CChartLayout() {
this.isManual = false;
this.layoutTarget = null;
this.xMode = null;
this.yMode = null;
this.wMode = null;
this.hMode = null;
this.x = null;
this.y = null;
this.w = null;
this.h = null;
}
CChartLayout.prototype = {
setXMode: function (mode) {
this.xMode = mode;
},
setYMode: function (mode) {
this.yMode = mode;
},
setX: function (x) {
this.x = x;
},
setY: function (y) {
this.y = y;
},
setIsManual: function (isManual) {
this.isManual = isManual;
},
createDuplicate: function () {
var ret = new CChartLayout();
this.isManual = false;
ret.layoutTarget = this.layoutTarget;
ret.xMode = this.xMode;
ret.yMode = this.yMode;
ret.wMode = this.wMode;
ret.hMode = this.hMode;
ret.x = this.x;
ret.y = this.y;
ret.w = this.w;
ret.h = this.h;
return ret;
},
Write_ToBinary2: function (w) {
w.WriteBool(isRealNumber(this.layoutTarget));
if (isRealNumber(this.layoutTarget)) {
w.WriteLong(this.layoutTarget);
}
w.WriteBool(isRealNumber(this.xMode));
if (isRealNumber(this.xMode)) {
w.WriteLong(this.xMode);
}
w.WriteBool(isRealNumber(this.yMode));
if (isRealNumber(this.yMode)) {
w.WriteLong(this.yMode);
}
w.WriteBool(isRealNumber(this.wMode));
if (isRealNumber(this.wMode)) {
w.WriteLong(this.wMode);
}
w.WriteBool(isRealNumber(this.hMode));
if (isRealNumber(this.hMode)) {
w.WriteLong(this.hMode);
}
w.WriteBool(isRealNumber(this.x));
if (isRealNumber(this.x)) {
w.WriteDouble(this.x);
}
w.WriteBool(isRealNumber(this.y));
if (isRealNumber(this.y)) {
w.WriteDouble(this.y);
}
w.WriteBool(isRealNumber(this.w));
if (isRealNumber(this.w)) {
w.WriteDouble(this.w);
}
w.WriteBool(isRealNumber(this.h));
if (isRealNumber(this.h)) {
w.WriteDouble(this.h);
}
},
Read_FromBinary2: function (r) {
if (r.GetBool()) {
(this.layoutTarget) = r.GetLong();
}
if (r.GetBool()) {
(this.xMode) = r.GetLong();
}
if (r.GetBool()) {
(this.yMode) = r.GetLong();
}
if (r.GetBool()) {
(this.wMode) = r.GetLong();
}
if (r.GetBool()) {
(this.hMode) = r.GetLong();
}
if (r.GetBool()) {
(this.x) = r.GetDouble();
}
if (r.GetBool()) {
(this.y) = r.GetDouble();
}
if (r.GetBool()) {
(this.w) = r.GetDouble();
}
if (r.GetBool()) {
(this.h) = r.GetDouble();
}
},
Undo: function (type, data) {
switch (type) {
case historyitem_AutoShapes_Layout_Set_X_Mode:
this.xMode = data.oldValue;
break;
case historyitem_AutoShapes_Layout_Set_Y_Mode:
this.yMode = data.oldValue;
break;
case historyitem_AutoShapes_Layout_Set_X:
this.x = data.oldValue;
break;
case historyitem_AutoShapes_Layout_Set_Y:
this.y = data.oldValue;
break;
}
},
Redo: function (type, data) {
switch (type) {
case historyitem_AutoShapes_Layout_Set_X_Mode:
this.xMode = data.newValue;
break;
case historyitem_AutoShapes_Layout_Set_Y_Mode:
this.yMode = data.newValue;
break;
case historyitem_AutoShapes_Layout_Set_X:
this.x = data.newValue;
break;
case historyitem_AutoShapes_Layout_Set_Y:
this.y = data.newValue;
break;
}
},
copy: function () {},
writeToBinary: function (w) {
w.WriteBool(isRealNumber(this.layoutTarget));
if (isRealNumber(this.layoutTarget)) {
w.WriteLong(this.layoutTarget);
}
w.WriteBool(isRealNumber(this.xMode));
if (isRealNumber(this.xMode)) {
w.WriteLong(this.xMode);
}
w.WriteBool(isRealNumber(this.yMode));
if (isRealNumber(this.yMode)) {
w.WriteLong(this.yMode);
}
w.WriteBool(isRealNumber(this.wMode));
if (isRealNumber(this.wMode)) {
w.WriteLong(this.wMode);
}
w.WriteBool(isRealNumber(this.hMode));
if (isRealNumber(this.hMode)) {
w.WriteLong(this.hMode);
}
w.WriteBool(isRealNumber(this.x));
if (isRealNumber(this.x)) {
w.WriteDouble(this.x);
}
w.WriteBool(isRealNumber(this.y));
if (isRealNumber(this.y)) {
w.WriteDouble(this.y);
}
w.WriteBool(isRealNumber(this.w));
if (isRealNumber(this.w)) {
w.WriteDouble(this.w);
}
w.WriteBool(isRealNumber(this.h));
if (isRealNumber(this.h)) {
w.WriteDouble(this.h);
}
},
readFromBinary: function (r) {
if (r.GetBool()) {
this.layoutTarget = r.GetLong();
}
if (r.GetBool()) {
this.xMode = r.GetLong();
}
if (r.GetBool()) {
this.yMode = r.GetLong();
}
if (r.GetBool()) {
this.wMode = r.GetLong();
}
if (r.GetBool()) {
this.hMode = r.GetLong();
}
if (r.GetBool()) {
this.x = r.GetDouble();
}
if (r.GetBool()) {
this.y = r.GetDouble();
}
if (r.GetBool()) {
this.w = r.GetDouble();
}
if (r.GetBool()) {
this.h = r.GetDouble();
}
}
};

View File

@@ -1,235 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
var LEGEND_ELEMENT_TYPE_RECT = 0;
var LEGEND_ELEMENT_TYPE_LINE = 1;
function CLegendEntry() {
this.bDelete = null;
this.idx = null;
this.txPr = null;
this.Id = g_oIdCounter.Get_NewId();
g_oTableId.Add(this, this.Id);
}
CLegendEntry.prototype = {
Get_Id: function () {
return this.Id;
},
getObjectType: function () {
return CLASS_TYPE_LEGEND_ENTRY;
}
};
function CChartLegend() {
this.chartGroup = null;
this.layout = null;
this.legendEntries = [];
this.legendPos = null;
this.overlay = false;
this.spPr = new CSpPr();
this.txPr = null;
this.x = null;
this.y = null;
this.extX = null;
this.extY = null;
this.calculatedEntry = [];
this.Id = g_oIdCounter.Get_NewId();
g_oTableId.Add(this, this.Id);
}
CChartLegend.prototype = {
getObjectType: function () {
return CLASS_TYPE_CHART_LEGEND;
},
Get_Id: function () {
return this.Id;
},
getStyles: function (level) {
var styles = new CStyles();
var default_legend_style = new CStyle("defaultLegendStyle", styles.Default, null, styletype_Paragraph);
default_legend_style.TextPr.FontSize = 10;
default_legend_style.TextPr.FontFamily.Name = "Calibri";
default_legend_style.TextPr.Bold = true;
var tx_pr;
if (isRealObject(this.txPr)) {}
styles.Style[styles.Id] = default_legend_style;
return styles;
},
init: function () {
this.setStartValues();
return;
var chart = this.chartGroup.chart;
var chart_legend = chart.getLegendInfo();
if (chart_legend.length > 0) {
var shape_type = chart_legend[0].marker === c_oAscLegendMarkerType.Line ? "line" : "rect";
for (var i = 0; i < chart_legend.length; ++i) {
var legend_entry_obj = chart_legend[i];
var entry_string = legend_entry_obj.text;
var cur_legend_entry = new CLegendEntryGroup(this);
cur_legend_entry.marker = chart_legend[0].marker;
cur_legend_entry.drawingObjects = this.chartGroup.drawingObjects;
cur_legend_entry.textBody = new CTextBody(cur_legend_entry);
cur_legend_entry.idx = i;
for (var key in entry_string) {
cur_legend_entry.textBody.paragraphAdd(new ParaText(entry_string[key]), false);
}
cur_legend_entry.textBody.content.Reset(0, 0, 30, 30);
cur_legend_entry.textBody.content.Recalculate_Page(0, true);
cur_legend_entry.geometry = CreateGeometry(shape_type);
cur_legend_entry.geometry.Init(5, 5);
cur_legend_entry.brush = new CUniFill();
cur_legend_entry.brush.fill = new CSolidFill();
cur_legend_entry.brush.fill.color.color = new CRGBColor();
cur_legend_entry.brush.fill.color.color.RGBA = {
R: legend_entry_obj.color.R,
G: legend_entry_obj.color.G,
B: legend_entry_obj.color.B,
A: 255
};
}
}
},
draw: function (graphics) {
for (var i = 0; i < this.calculatedEntry.length; ++i) {
this.calculatedEntry[i].draw(graphics);
}
},
setStartValues: function () {
var is_on_history = History.Is_On();
var is_on_table_id = !g_oTableId.m_bTurnOff;
if (is_on_history) {
History.TurnOff();
}
if (is_on_table_id) {
g_oTableId.m_bTurnOff = true;
}
g_oTableId.m_bTurnOff = true;
var chart = this.chartGroup.chart;
var legend_info = chart.getLegendInfo();
this.calculatedEntry.length = 0;
if (legend_info.length > 0) {
var bullet_type = legend_info[0].marker === c_oAscLegendMarkerType.Line ? "line" : "rect";
for (var i = 0; i < legend_info.length; ++i) {
var cur_legend_info = legend_info[i];
var legend_entry = this.legendEntries[i];
if (isRealObject(legend_entry) && legend_entry.bDelete === true) {
continue;
}
var entry = new CLegendEntryGroup(this);
entry.bullet = new CShape(null, this.chartGroup.drawingObjects, legend_entry);
var uni_fill = new CUniFill();
uni_fill.setFill(new CSolidFill());
uni_fill.fill.setColor(new CUniColor());
uni_fill.fill.color.setColor(new CRGBColor());
uni_fill.fill.color.setColor(cur_legend_info.color.R * 16 * 16 + cur_legend_info.color.G * 16 + cur_legend_info.color.B);
if (bullet_type === "line") {
entry.bullet.setPresetGeometry("line");
entry.bullet.setUniFill(uni_fill);
} else {
entry.bullet.setPresetGeometry("rect");
var shape_fill = new CUniFill();
shape_fill.setFill(new CNoFill());
var shape_line = new CLn();
var line_fill = new CUniFill();
line_fill.setFill(new CNoFill());
shape_line.setFill(line_fill);
entry.bullet.setUniFill(shape_fill);
entry.bullet.setUniLine(shape_line);
entry.bullet.addTextBody(new CTextBody(entry.bullet));
entry.bullet.paragraphAdd(new ParaTextPr({
unifill: uni_fill
}));
entry.bullet.paragraphAdd(new ParaText(String.fromCharCode(167)));
}
entry.title = new CShape(null, this.chartGroup.drawingObjects);
entry.title.addTextBody(new CTextBody(entry.title));
for (var i in cur_legend_info.text) {
entry.title.paragraphAdd(new ParaText(cur_legend_info.text[i]));
}
this.calculatedEntry.push(entry);
}
}
if (is_on_history) {
History.TurnOn();
}
if (is_on_table_id) {
g_oTableId.m_bTurnOff = false;
}
},
setChartGroup: function (chartGroup) {
this.chartGroup = chartGroup;
},
recalculateInternalPositionsAndExtents: function () {
this.extX = null;
this.extY = null;
if (isRealObject(this.layout) && isRealNumber(this.layout.w) && isRealNumber(this.layout.h)) {
this.extX = this.chartGroup.extX * this.layout.w;
this.extY = this.chartGroup.extY * this.layout.h;
} else {
switch (this.legendPos) {
case c_oAscChartLegend.right:
case c_oAscChartLegend.left:
for (var i = 0; i < this.calculatedEntry.length; ++i) {
var cur_legend_entry = this.calculatedEntry[i];
}
break;
}
}
},
recalculateWithoutLayout: function () {}
};
function CLegendEntryGroup(legend) {
this.legend = legend;
this.bullet = null;
this.title = null;
}
CLegendEntryGroup.prototype = {
setLegendGroup: function (legendGroup) {},
getStyles: function () {
var styles = new CStyles();
var default_style = new CStyle("defaultEntryStyle", null, null, styletype_Paragraph);
default_style.TextPr.themeFont = "Calibri";
default_style.TextPr.FontSize = 10;
styles.Style[styles.Id] = default_style;
var legend_style = new CStyle("legend_style", styles.Id - 1, null, styletype_Paragraph);
styles.Style[styles.Id] = legend_style;
var entry_style = new CStyle("entry_style", styles.Id - 1, null, styletype_Paragraph);
if (isRealObject(this.legendGroup.legendEntries[this.idx]) && isRealObject(this.legendGroup.legendEntries[this.idx].txPr)) {}
styles.Style[styles.Id] = entry_style;
return styles;
},
getBulletStyles: function () {},
getTitleStyles: function () {},
recalculateInternalPosition: function () {},
draw: function (graphics) {
if (isRealObject(this.bullet) && isRealObject(this.title)) {
this.bullet.draw(graphics);
this.title.draw(graphics);
}
}
};

View File

@@ -1,941 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
var CHART_TITLE_TYPE_TITLE = 0;
var CHART_TITLE_TYPE_H_AXIS = 1;
var CHART_TITLE_TYPE_V_AXIS = 2;
var paraDrawing;
function CChartTitle(chartGroup, type) {
this.layout = null;
this.overlay = false;
this.spPr = new CSpPr();
this.txPr = null;
this.isDefaultText = false;
this.txBody = null;
this.x = null;
this.y = null;
this.extX = null;
this.extY = null;
this.brush = null;
this.pen = null;
this.spPr.geometry = CreateGeometry("rect");
this.spPr.geometry.Init(5, 5);
this.invertTransform = new CMatrix();
this.invertTransformText = new CMatrix();
this.transform = new CMatrix();
this.transformText = new CMatrix();
this.recalculateInfo = {
recalculateTransform: true,
recalculateBrush: true,
recalculatePen: true
};
this.recalcInfo = {};
this.selected = false;
this.Id = g_oIdCounter.Get_NewId();
g_oTableId.Add(this, this.Id);
if (isRealObject(chartGroup)) {
this.setChartGroup(chartGroup);
this.addTextBody(new CTextBody(this));
}
if (isRealNumber(type)) {
this.setType(type);
}
}
CChartTitle.prototype = {
getObjectType: function () {
return CLASS_TYPE_CHART_TITLE;
},
setChartGroup: function (chartGroup) {
var oldPr = this.chartGroup;
var newPr = chartGroup;
History.Add(this, {
Type: historyitem_AutoShapes_SetChartGroup,
oldPr: oldPr,
newPr: newPr
});
this.chartGroup = chartGroup;
},
getAllFonts: function (AllFonts) {
if (this.txBody && this.txBody.content) {
AllFonts["Calibri"] = true;
this.txBody.content.Document_Get_AllFontNames(AllFonts);
}
},
Get_Id: function () {
return this.Id;
},
getTitleType: function () {
if (this === this.chartGroup.chartTitle) {
return CHART_TITLE_TYPE_TITLE;
}
if (this === this.chartGroup.hAxisTitle) {
return CHART_TITLE_TYPE_H_AXIS;
}
if (this === this.chartGroup.vAxisTitle) {
return CHART_TITLE_TYPE_V_AXIS;
}
},
isEmpty: function () {
return isRealObject(this.txBody) ? this.txBody.isEmpty() : true;
},
setType: function (type) {
History.Add(this, {
Type: historyitem_AutoShapes_SetChartTitleType,
oldPr: this.type,
newPr: type
});
this.type = type;
},
Get_Styles: function () {
return new CStyles();
},
select: function (pageIndex) {
this.selected = true;
this.selectStartPage = pageIndex;
},
deselect: function () {
this.selected = false;
if (isRealObject(this.txBody) && isRealObject(this.txBody.content)) {
this.txBody.content.Selection_Remove();
}
this.selectStartPage = -1;
},
remove: function (Count, bOnlyText, bRemoveOnlySelection, bOnTextAdd) {
this.txBody.content.Remove(Count, bOnlyText, bRemoveOnlySelection, bOnTextAdd);
this.recalculatePosExt();
this.txBody.recalculateCurPos();
},
getParagraphParaPr: function () {
if (this.txBody) {
var ret = this.txBody.content.Get_Paragraph_ParaPr();
ret.PStyle = undefined;
}
return null;
},
getParagraphTextPr: function () {
if (this.txBody) {
return this.txBody.content.Get_Paragraph_TextPr();
}
return null;
},
getStyles: function () {
var styles = new CStyles();
var default_legend_style = new CStyle("defaultLegendStyle", styles.Default, null, styletype_Paragraph);
default_legend_style.TextPr.FontFamily = {
Name: "Calibri",
Index: -1
};
default_legend_style.TextPr.Bold = true;
default_legend_style.TextPr.RFonts = new CRFonts();
default_legend_style.TextPr.RFonts.Ascii = {
Name: "Calibri",
Index: -1
};
default_legend_style.TextPr.RFonts.EastAsia = {
Name: "Calibri",
Index: -1
};
default_legend_style.TextPr.RFonts.HAnsi = {
Name: "Calibri",
Index: -1
};
default_legend_style.TextPr.RFonts.CS = {
Name: "Calibri",
Index: -1
};
if (this.getTitleType() === CHART_TITLE_TYPE_TITLE) {
default_legend_style.TextPr.FontSize = 18;
} else {
default_legend_style.TextPr.FontSize = 10;
}
default_legend_style.ParaPr.Spacing.After = 0;
default_legend_style.ParaPr.Spacing.Before = 0;
default_legend_style.ParaPr.Spacing.LineRule = linerule_AtLeast;
default_legend_style.ParaPr.Spacing.Line = 1;
default_legend_style.ParaPr.Jc = align_Center;
var tx_pr;
if (isRealObject(this.txPr)) {}
styles.Style[styles.Id] = default_legend_style;
return styles;
},
initFromString: function (title) {
this.textBody.initFromString(title);
},
setDefaultText: function (val) {
this.isDefaultText = val;
},
recalculateTransform: function () {
this.transform.Reset();
global_MatrixTransformer.TranslateAppend(this.transform, this.x, this.y);
global_MatrixTransformer.MultiplyAppend(this.transform, this.chartGroup.getTransform());
this.invertTransform = global_MatrixTransformer.Invert(this.transform);
},
recalculateTransform2: function () {
this.transform.Reset();
global_MatrixTransformer.TranslateAppend(this.transform, this.x, this.y);
global_MatrixTransformer.MultiplyAppend(this.transform, this.chartGroup.getTransform());
},
setTextBody: function (txBody) {
this.txBody = txBody;
},
setLayoutX: function (x) {
if (!isRealObject(this.layout)) {
this.layout = new CChartLayout();
}
this.layout.setX(x);
},
setLayoutY: function (y) {
if (!isRealObject(this.layout)) {
this.layout = new CChartLayout();
}
this.layout.setY(y);
},
addTextBody: function (txBody) {
var oldPr = this.txBody;
var newPr = txBody;
History.Add(this, {
Type: historyitem_AutoShapes_SetChartTitleTxBody,
oldPr: oldPr,
newPr: newPr
});
this.txBody = txBody;
},
paragraphAdd: function (paraItem, bRecalculate) {
if (!isRealObject(this.txBody)) {
this.txBody = new CTextBody(this);
}
this.txBody.paragraphAdd(paraItem, true);
this.recalculatePosExt();
this.txBody.recalculateCurPos();
},
recalculatePosExt: function () {
var old_cx = this.x + this.extX * 0.5;
var old_cy = this.y + this.extY * 0.5;
var bodyPr = this.txBody.getBodyPr();
switch (this.type) {
case CHART_TITLE_TYPE_TITLE:
case CHART_TITLE_TYPE_H_AXIS:
var max_title_width = this.chartGroup.absExtX * 0.8;
var title_width = this.txBody.getRectWidth(max_title_width);
this.extX = title_width;
this.extY = this.txBody.getRectHeight(this.chartGroup.absExtY, title_width - (bodyPr.rIns + bodyPr.lIns));
this.x = old_cx - this.extX * 0.5;
if (this.x + this.extX > this.chartGroup.absExtX) {
this.x = this.chartGroup.absExtX - this.extX;
}
if (this.x < 0) {
this.x = 0;
}
this.y = old_cy - this.extY * 0.5;
if (this.y + this.extY > this.chartGroup.absExtY) {
this.y = this.chartGroup.absExtY - this.extY;
}
if (this.y < 0) {
this.y = 0;
}
if (isRealObject(this.layout) && isRealNumber(this.layout.x)) {
this.layout.setX(this.x / this.chartGroup.absExtX);
}
break;
case CHART_TITLE_TYPE_V_AXIS:
var max_title_height = this.chartGroup.absExtY * 0.8;
var body_pr = this.txBody.getBodyPr();
this.extY = this.txBody.getRectWidth(max_title_height) - body_pr.rIns - body_pr.lIns + body_pr.tIns + body_pr.bIns;
this.extX = this.txBody.getRectHeight(this.chartGroup.absExtX, this.extY) - (-body_pr.rIns - body_pr.lIns + body_pr.tIns + body_pr.bIns);
this.spPr.geometry.Recalculate(this.extX, this.extY);
this.x = old_cx - this.extX * 0.5;
if (this.x + this.extX > this.chartGroup.absExtX) {
this.x = this.chartGroup.absExtX - this.extX;
}
if (this.x < 0) {
this.x = 0;
}
this.y = old_cy - this.extY * 0.5;
if (this.y + this.extY > this.chartGroup.absExtY) {
this.y = this.chartGroup.absExtY - this.extY;
}
if (this.y < 0) {
this.y = 0;
}
if (isRealObject(this.layout) && isRealNumber(this.layout.y)) {
this.layout.setY(this.y / this.chartGroup.absExtY);
}
break;
}
this.spPr.geometry.Recalculate(this.extX, this.extY);
this.recalculateTransform();
this.calculateContent();
this.calculateTransformTextMatrix();
},
applyTextPr: function (paraItem, bRecalculate) {
this.txBody.content.Set_ApplyToAll(true);
this.txBody.content.Paragraph_Add(paraItem, bRecalculate);
this.txBody.content.Set_ApplyToAll(false);
},
updateSelectionState: function (drawingDocument) {
this.txBody.updateSelectionState(drawingDocument);
},
updateCursorType: function (e, x, y, pageIndex) {
var invert = this.invertTransformText;
var tx = invert.TransformPointX(x, y, pageIndex);
var ty = invert.TransformPointY(x, y, pageIndex);
this.txBody.content.Update_CursorType(tx, ty, pageIndex);
},
recalculateCurPos: function () {
if (this.txBody) {
this.txBody.recalculateCurPos();
}
},
cursorMoveLeft: function (AddToSelect, Word) {
if (isRealObject(this.txBody) && isRealObject(this.txBody.content)) {
this.txBody.content.Cursor_MoveLeft(AddToSelect, Word);
this.recalculateCurPos();
editor.WordControl.m_oLogicDocument.Document_UpdateSelectionState();
}
},
cursorMoveRight: function (AddToSelect, Word) {
if (isRealObject(this.txBody) && isRealObject(this.txBody.content)) {
this.txBody.content.Cursor_MoveRight(AddToSelect, Word);
this.recalculateCurPos();
editor.WordControl.m_oLogicDocument.Document_UpdateSelectionState();
}
},
cursorMoveUp: function (AddToSelect) {
if (isRealObject(this.txBody) && isRealObject(this.txBody.content)) {
this.txBody.content.Cursor_MoveUp(AddToSelect);
this.recalculateCurPos();
editor.WordControl.m_oLogicDocument.Document_UpdateSelectionState();
}
},
cursorMoveDown: function (AddToSelect) {
if (isRealObject(this.txBody) && isRealObject(this.txBody.content)) {
this.txBody.content.Cursor_MoveDown(AddToSelect);
this.recalculateCurPos();
editor.WordControl.m_oLogicDocument.Document_UpdateSelectionState();
}
},
cursorMoveEndOfLine: function (AddToSelect) {
if (isRealObject(this.txBody) && isRealObject(this.txBody.content)) {
this.txBody.content.Cursor_MoveEndOfLine(AddToSelect);
this.recalculateCurPos();
editor.WordControl.m_oLogicDocument.Document_UpdateSelectionState();
}
},
cursorMoveStartOfLine: function (AddToSelect) {
if (isRealObject(this.txBody) && isRealObject(this.txBody.content)) {
this.txBody.content.Cursor_MoveStartOfLine(AddToSelect);
this.recalculateCurPos();
editor.WordControl.m_oLogicDocument.Document_UpdateSelectionState();
}
},
drawTextSelection: function () {
if (isRealObject(this.txBody)) {
this.txBody.drawTextSelection();
}
},
calculateContent: function () {
if (this.txBody) {
this.txBody.calculateContent();
}
},
getColorMap: function () {
return this.chartGroup.drawingObjects.controller.getColorMap();
},
getTheme: function () {
return this.chartGroup.drawingObjects.getWorkbook().theme;
},
calculateTransformTextMatrix: function () {
if (this.txBody === null) {
return;
}
this.transformText.Reset();
var _text_transform = this.transformText;
var _shape_transform = this.transform;
var _body_pr = this.txBody.getBodyPr();
var _content_height = this.txBody.getSummaryHeight();
var _l, _t, _r, _b;
var _t_x_lt, _t_y_lt, _t_x_rt, _t_y_rt, _t_x_lb, _t_y_lb, _t_x_rb, _t_y_rb;
if (isRealObject(this.spPr.geometry) && isRealObject(this.spPr.geometry.rect)) {
var _rect = this.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 = this.extX - _body_pr.rIns;
_b = this.extY - _body_pr.bIns;
}
if (_l >= _r) {
var _c = (_l + _r) * 0.5;
_l = _c - 0.01;
_r = _c + 0.01;
}
if (_t >= _b) {
_c = (_t + _b) * 0.5;
_t = _c - 0.01;
_b = _c + 0.01;
}
_t_x_lt = _shape_transform.TransformPointX(_l, _t);
_t_y_lt = _shape_transform.TransformPointY(_l, _t);
_t_x_rt = _shape_transform.TransformPointX(_r, _t);
_t_y_rt = _shape_transform.TransformPointY(_r, _t);
_t_x_lb = _shape_transform.TransformPointX(_l, _b);
_t_y_lb = _shape_transform.TransformPointY(_l, _b);
_t_x_rb = _shape_transform.TransformPointX(_r, _b);
_t_y_rb = _shape_transform.TransformPointY(_r, _b);
var _dx_t, _dy_t;
_dx_t = _t_x_rt - _t_x_lt;
_dy_t = _t_y_rt - _t_y_lt;
var _dx_lt_rb, _dy_lt_rb;
_dx_lt_rb = _t_x_rb - _t_x_lt;
_dy_lt_rb = _t_y_rb - _t_y_lt;
var _vertical_shift;
var _text_rect_height = _b - _t;
var _text_rect_width = _r - _l;
if (_body_pr.upright === false) {
if (! (_body_pr.vert === nVertTTvert || _body_pr.vert === nVertTTvert270)) {
if (_content_height < _text_rect_height) {
switch (_body_pr.anchor) {
case 0:
_vertical_shift = _text_rect_height - _content_height;
break;
case 1:
_vertical_shift = (_text_rect_height - _content_height) * 0.5;
break;
case 2:
_vertical_shift = (_text_rect_height - _content_height) * 0.5;
break;
case 3:
_vertical_shift = (_text_rect_height - _content_height) * 0.5;
break;
case 4:
_vertical_shift = 0;
break;
}
} else {
_vertical_shift = 0;
}
global_MatrixTransformer.TranslateAppend(_text_transform, 0, _vertical_shift);
if (_dx_lt_rb * _dy_t - _dy_lt_rb * _dx_t <= 0) {
var alpha = Math.atan2(_dy_t, _dx_t);
global_MatrixTransformer.RotateRadAppend(_text_transform, -alpha);
global_MatrixTransformer.TranslateAppend(_text_transform, _t_x_lt, _t_y_lt);
} else {
alpha = Math.atan2(_dy_t, _dx_t);
global_MatrixTransformer.RotateRadAppend(_text_transform, Math.PI - alpha);
global_MatrixTransformer.TranslateAppend(_text_transform, _t_x_rt, _t_y_rt);
}
} else {
if (_content_height < _text_rect_width) {
switch (_body_pr.anchor) {
case 0:
_vertical_shift = _text_rect_width - _content_height;
break;
case 1:
_vertical_shift = (_text_rect_width - _content_height) * 0.5;
break;
case 2:
_vertical_shift = (_text_rect_width - _content_height) * 0.5;
break;
case 3:
_vertical_shift = (_text_rect_width - _content_height) * 0.5;
break;
case 4:
_vertical_shift = 0;
break;
}
} else {
_vertical_shift = 0;
}
global_MatrixTransformer.TranslateAppend(_text_transform, 0, _vertical_shift);
var _alpha;
_alpha = Math.atan2(_dy_t, _dx_t);
if (_body_pr.vert === nVertTTvert) {
if (_dx_lt_rb * _dy_t - _dy_lt_rb * _dx_t <= 0) {
global_MatrixTransformer.RotateRadAppend(_text_transform, -_alpha - Math.PI * 0.5);
global_MatrixTransformer.TranslateAppend(_text_transform, _t_x_rt, _t_y_rt);
} else {
global_MatrixTransformer.RotateRadAppend(_text_transform, Math.PI * 0.5 - _alpha);
global_MatrixTransformer.TranslateAppend(_text_transform, _t_x_lt, _t_y_lt);
}
} else {
if (_dx_lt_rb * _dy_t - _dy_lt_rb * _dx_t <= 0) {
global_MatrixTransformer.RotateRadAppend(_text_transform, -_alpha - Math.PI * 1.5);
global_MatrixTransformer.TranslateAppend(_text_transform, _t_x_lb, _t_y_lb);
} else {
global_MatrixTransformer.RotateRadAppend(_text_transform, -Math.PI * 0.5 - _alpha);
global_MatrixTransformer.TranslateAppend(_text_transform, _t_x_rb, _t_y_rb);
}
}
}
if (isRealObject(this.spPr.geometry) && isRealObject(this.spPr.geometry.rect)) {
var rect = this.spPr.geometry.rect;
this.clipRect = {
x: rect.l,
y: rect.t,
w: rect.r - rect.l,
h: rect.b - rect.t
};
} else {
this.clipRect = {
x: 0,
y: 0,
w: this.absExtX,
h: this.absExtY
};
}
} else {
var _full_rotate = this.getFullRotate();
var _full_flip = this.getFullFlip();
var _hc = this.absExtX * 0.5;
var _vc = this.absExtY * 0.5;
var _transformed_shape_xc = this.transform.TransformPointX(_hc, _vc);
var _transformed_shape_yc = this.transform.TransformPointY(_hc, _vc);
var _content_width, content_height2;
if ((_full_rotate >= 0 && _full_rotate < Math.PI * 0.25) || (_full_rotate > 3 * Math.PI * 0.25 && _full_rotate < 5 * Math.PI * 0.25) || (_full_rotate > 7 * Math.PI * 0.25 && _full_rotate < 2 * Math.PI)) {
if (! (_body_pr.vert === nVertTTvert || _body_pr.vert === nVertTTvert270)) {
_content_width = _r - _l;
content_height2 = _b - _t;
} else {
_content_width = _b - _t;
content_height2 = _r - _l;
}
} else {
if (! (_body_pr.vert === nVertTTvert || _body_pr.vert === nVertTTvert270)) {
_content_width = _b - _t;
content_height2 = _r - _l;
} else {
_content_width = _r - _l;
content_height2 = _b - _t;
}
}
if (_content_height < content_height2) {
switch (_body_pr.anchor) {
case 0:
_vertical_shift = content_height2 - _content_height;
break;
case 1:
_vertical_shift = (content_height2 - _content_height) * 0.5;
break;
case 2:
_vertical_shift = (content_height2 - _content_height) * 0.5;
break;
case 3:
_vertical_shift = (content_height2 - _content_height) * 0.5;
break;
case 4:
_vertical_shift = 0;
break;
}
} else {
_vertical_shift = 0;
}
var _text_rect_xc = _l + (_r - _l) * 0.5;
var _text_rect_yc = _t + (_b - _t) * 0.5;
var _vx = _text_rect_xc - _hc;
var _vy = _text_rect_yc - _vc;
var _transformed_text_xc, _transformed_text_yc;
if (!_full_flip.flipH) {
_transformed_text_xc = _transformed_shape_xc + _vx;
} else {
_transformed_text_xc = _transformed_shape_xc - _vx;
}
if (!_full_flip.flipV) {
_transformed_text_yc = _transformed_shape_yc + _vy;
} else {
_transformed_text_yc = _transformed_shape_yc - _vy;
}
global_MatrixTransformer.TranslateAppend(_text_transform, 0, _vertical_shift);
if (_body_pr.vert === nVertTTvert) {
global_MatrixTransformer.TranslateAppend(_text_transform, -_content_width * 0.5, -content_height2 * 0.5);
global_MatrixTransformer.RotateRadAppend(_text_transform, -Math.PI * 0.5);
global_MatrixTransformer.TranslateAppend(_text_transform, _content_width * 0.5, content_height2 * 0.5);
}
if (_body_pr.vert === nVertTTvert270) {
global_MatrixTransformer.TranslateAppend(_text_transform, -_content_width * 0.5, -content_height2 * 0.5);
global_MatrixTransformer.RotateRadAppend(_text_transform, -Math.PI * 1.5);
global_MatrixTransformer.TranslateAppend(_text_transform, _content_width * 0.5, content_height2 * 0.5);
}
global_MatrixTransformer.TranslateAppend(_text_transform, _transformed_text_xc - _content_width * 0.5, _transformed_text_yc - content_height2 * 0.5);
var body_pr = this.bodyPr;
var l_ins = typeof body_pr.lIns === "number" ? body_pr.lIns : 1;
var t_ins = typeof body_pr.tIns === "number" ? body_pr.tIns : 0.5;
var r_ins = typeof body_pr.rIns === "number" ? body_pr.rIns : 0.5;
var b_ins = typeof body_pr.bIns === "number" ? body_pr.bIns : 0.5;
this.clipRect = {
x: -l_ins,
y: -_vertical_shift - t_ins,
w: this.contentWidth + (r_ins + l_ins),
h: this.contentHeight + (b_ins + t_ins)
};
}
this.invertTransformText = global_MatrixTransformer.Invert(this.transformText);
},
recalculateAfterTextAdd: function () {
switch (this.type) {
case CHART_TITLE_TYPE_TITLE:
var body_pr = this.txBody.bodyPr;
var r_ins = isRealNumber(body_pr.rIns) ? body_pr.rIns : 1.27;
var l_ins = isRealNumber(body_pr.lIns) ? body_pr.lIns : 2.54;
var t_ins = isRealNumber(body_pr.tIns) ? body_pr.tIns : 1.27;
var b_ins = isRealNumber(body_pr.bIns) ? body_pr.bIns : 1.27;
var max_width = this.chartGroup.extX * 0.8 - r_ins - l_ins;
var title_content = this.txBody.content;
title_content.Reset(0, 0, max_width, 20000);
title_content.Recalculate_Page(0);
var result_width;
if (! (title_content.Content.length > 1 || title_content.Content[0].Lines.length > 1)) {
if (title_content.Content[0].Lines[0].Ranges[0].W < max_width) {
title_content.Reset(0, 0, title_content.Content[0].Lines[0].Ranges[0].W, 20000);
title_content.Recalculate_Page(0);
}
result_width = title_content.Content[0].Lines[0].Ranges[0].W + r_ins + l_ins;
} else {
var width = 0;
for (var i = 0; i < title_content.Content.length; ++i) {
var par = title_content.Content[i];
for (var j = 0; j < par.Lines.length; ++j) {
if (par.Lines[j].Ranges[0].W > width) {
width = par.Lines[j].Ranges[0].W;
}
}
}
result_width = width + r_ins + l_ins;
}
this.extX = result_width;
this.extY = title_content.Get_SummaryHeight() + r_ins + l_ins;
this.x = this.chartGroup.extX - this.extX * 0.5;
this.y = 2.5;
break;
}
},
recalculateBrush: function () {},
recalculatePen: function () {},
draw: function (graphics, pageIndex) {
graphics.SetIntegerGrid(false);
graphics.transform3(this.transformText);
if (window.IsShapeToImageConverter) {
pageIndex = 0;
}
if (graphics.CheckUseFonts2 !== undefined) {
graphics.CheckUseFonts2(this.transformText);
}
this.txBody.draw(graphics, pageIndex);
if (graphics.UncheckUseFonts2 !== undefined) {
graphics.UncheckUseFonts2();
}
graphics.reset();
graphics.SetIntegerGrid(true);
},
selectionSetStart: function (event, x, y, pageIndex) {
var t_x, t_y;
t_x = this.invertTransformText.TransformPointX(x, y);
t_y = this.invertTransformText.TransformPointY(x, y);
if (typeof this.selectStartPage === "number" && this.selectStartPage > -1) {
this.txBody.content.Set_StartPage(this.selectStartPage);
}
this.txBody.content.Selection_SetStart(t_x, t_y, typeof this.selectStartPage === "number" && this.selectStartPage > -1 ? this.selectStartPage : this.pageIndex, event);
},
selectionSetEnd: function (event, x, y, pageIndex) {
var t_x, t_y;
t_x = this.invertTransformText.TransformPointX(x, y);
t_y = this.invertTransformText.TransformPointY(x, y);
if (typeof this.selectStartPage === "number" && this.selectStartPage > -1) {
this.txBody.content.Set_StartPage(this.selectStartPage);
}
this.txBody.content.Selection_SetEnd(t_x, t_y, typeof this.selectStartPage === "number" && this.selectStartPage > -1 ? this.selectStartPage : this.pageIndex, event);
},
setPosition: function (x, y) {
var layout = new CChartLayout();
layout.setIsManual(true);
layout.setXMode(LAYOUT_MODE_EDGE);
layout.setX(x / this.chartGroup.absExtX);
layout.setYMode(LAYOUT_MODE_EDGE);
layout.setY(y / this.chartGroup.absExtY);
this.setLayout(layout);
},
setLayout: function (layout) {
var oldLayout = this.layout ? this.layout.createDuplicate() : null;
var newLayout = layout ? layout.createDuplicate() : null;
History.Add(this, {
Type: historyitem_SetCahrtLayout,
oldLayout: oldLayout,
newLayout: newLayout
});
this.layout = layout;
},
hit: function (x, y) {
return this.hitInInnerArea(x, y) || this.hitInPath(x, y) || this.hitInTextRect(x, y);
},
hitInPath: function (x, y) {
var invert_transform = this.getInvertTransform();
var x_t = invert_transform.TransformPointX(x, y);
var y_t = invert_transform.TransformPointY(x, y);
if (isRealObject(this.spPr.geometry)) {
return this.spPr.geometry.hitInPath(editor.WordControl.m_oLogicDocument.DrawingDocument.CanvasHitContext, x_t, y_t);
}
return false;
},
hitInInnerArea: function (x, y) {
var invert_transform = this.getInvertTransform();
var x_t = invert_transform.TransformPointX(x, y);
var y_t = invert_transform.TransformPointY(x, y);
if (isRealObject(this.spPr.geometry)) {
return this.spPr.geometry.hitInInnerArea(editor.WordControl.m_oLogicDocument.DrawingDocument.CanvasHitContext, x_t, y_t);
}
return x_t > 0 && x_t < this.extX && y_t > 0 && y_t < this.extY;
},
hitInTextRect: function (x, y) {
if (isRealObject(this.txBody)) {
var t_x, t_y;
t_x = this.invertTransformText.TransformPointX(x, y);
t_y = this.invertTransformText.TransformPointY(x, y);
return t_x > 0 && t_x < this.txBody.contentWidth && t_y > 0 && t_y < this.txBody.contentHeight;
}
return false;
},
hitInBoundingRect: function (x, y) {
var invert_transform = this.getInvertTransform();
var x_t = invert_transform.TransformPointX(x, y);
var y_t = invert_transform.TransformPointY(x, y);
var _hit_context = editor.WordControl.m_oLogicDocument.DrawingDocument.CanvasHitContext;
return (HitInLine(_hit_context, x_t, y_t, 0, 0, this.extX, 0) || HitInLine(_hit_context, x_t, y_t, this.extX, 0, this.extX, this.extY) || HitInLine(_hit_context, x_t, y_t, this.extX, this.extY, 0, this.extY) || HitInLine(_hit_context, x_t, y_t, 0, this.extY, 0, 0));
},
getInvertTransform: function () {
return this.invertTransform;
},
writeToBinary: function (w) {
w.WriteBool(isRealObject(this.layout));
if (isRealObject(this.layout)) {
this.layout.writeToBinary(w);
}
w.WriteBool(this.overlay);
this.spPr.Write_ToBinary2(w);
w.WriteBool(isRealObject(this.txBody));
if (isRealObject(this.txBody)) {
this.txBody.writeToBinary(w);
}
},
readFromBinary: function (r) {
if (r.GetBool()) {
var layout = new CChartLayout();
layout.Read_FromBinary2(r);
this.setLayout(layout);
}
this.overlay = r.GetBool();
this.spPr.Read_FromBinary2(r);
if (r.GetBool()) {
this.txBody.readFromBinary(r);
}
},
copy: function (chartGroup, type) {
var c = new CChartTitle(chartGroup, type);
if (this.layout) {
c.setLayout(this.layout.copy());
}
c.overlay = this.overlay;
c.txBody.copyFromOther(this.txBody);
return c;
},
setBodyPr: function (bodyPr) {
var old_body_pr = this.txBody.bodyPr;
this.txBody.bodyPr = bodyPr;
var new_body_pr = this.txBody.bodyPr.createDuplicate();
History.Add(this, {
Type: historyitem_SetShapeBodyPr,
oldBodyPr: old_body_pr,
newBodyPr: new_body_pr
});
this.txBody.recalcInfo.recalculateBodyPr = true;
},
setOverlay: function (overlay) {
var _overlay = overlay === true;
History.Add(this, {
Type: historyitem_AutoShapes_SetChartTitleOverlay,
oldPr: this.overlay === true,
newPr: _overlay
});
this.overlay = _overlay;
},
Undo: function (data) {
switch (data.Type) {
case historyitem_SetCahrtLayout:
if (isRealObject(data.oldLayout)) {
this.layout = data.oldLayout.createDuplicate();
} else {
this.layout = null;
}
break;
case historyitem_SetShapeBodyPr:
this.txBody.bodyPr = data.oldBodyPr.createDuplicate();
this.txBody.recalcInfo.recalculateBodyPr = true;
this.recalcInfo.recalculateContent = true;
this.recalcInfo.recalculateTransformText = true;
break;
case historyitem_AutoShapes_SetChartGroup:
this.chartGroup = data.oldPr;
break;
case historyitem_AutoShapes_SetChartTitleType:
this.type = data.oldPr;
break;
case historyitem_AutoShapes_SetChartTitleOverlay:
this.overlay = data.oldPr;
break;
case historyitem_AutoShapes_SetChartTitleTxBody:
this.txBody = data.oldPr;
break;
}
},
Redo: function (data) {
switch (data.Type) {
case historyitem_SetCahrtLayout:
if (isRealObject(data.newLayout)) {
this.layout = data.newLayout.createDuplicate();
} else {
this.layout = null;
}
break;
case historyitem_SetShapeBodyPr:
this.txBody.bodyPr = data.newBodyPr.createDuplicate();
this.txBody.recalcInfo.recalculateBodyPr = true;
this.recalcInfo.recalculateContent = true;
this.recalcInfo.recalculateTransformText = true;
break;
case historyitem_AutoShapes_SetChartGroup:
this.chartGroup = data.newPr;
break;
case historyitem_AutoShapes_SetChartTitleType:
this.type = data.newPr;
break;
case historyitem_AutoShapes_SetChartTitleOverlay:
this.overlay = data.newPr;
break;
case historyitem_AutoShapes_SetChartTitleTxBody:
this.txBody = data.newPr;
break;
}
},
Refresh_RecalcData: function () {},
Write_ToBinary2: function (w) {
w.WriteLong(historyitem_type_ChartTitle);
w.WriteString2(this.Id);
},
Read_FromBinary2: function (r) {
this.Id = r.GetString2();
},
Save_Changes: function (data, w) {
w.WriteLong(historyitem_type_ChartTitle);
w.WriteLong(data.Type);
switch (data.Type) {
case historyitem_SetCahrtLayout:
w.WriteBool(isRealObject(data.newLayout));
if (isRealObject(data.newLayout)) {
data.newLayout.Write_ToBinary2(w);
}
break;
case historyitem_SetShapeBodyPr:
data.newBodyPr.Write_ToBinary2(w);
break;
case historyitem_AutoShapes_SetChartGroup:
w.WriteBool(isRealObject(data.newPr));
if (isRealObject(data.newPr)) {
w.WriteString2(data.newPr.Get_Id());
}
break;
case historyitem_AutoShapes_SetChartTitleType:
w.WriteBool(isRealNumber(data.newPr));
if (isRealNumber(data.newPr)) {}
w.WriteLong(data.newPr);
break;
case historyitem_AutoShapes_SetChartTitleOverlay:
w.WriteBool(data.newPr);
break;
case historyitem_AutoShapes_SetChartTitleTxBody:
w.WriteBool(isRealObject(data.newPr));
if (isRealObject(data.newPr)) {
w.WriteString2(data.newPr.Get_Id());
}
break;
}
},
Load_Changes: function (r) {
if (r.GetLong() === historyitem_type_ChartTitle) {
switch (r.GetLong()) {
case historyitem_SetCahrtLayout:
if (r.GetBool()) {
this.layout = new CChartLayout();
this.layout.Read_FromBinary2(r);
} else {
this.layout = null;
}
break;
case historyitem_SetShapeBodyPr:
this.txBody.bodyPr = new CBodyPr();
this.txBody.bodyPr.Read_FromBinary2(r);
this.txBody.recalcInfo.recalculateBodyPr = true;
this.recalcInfo.recalculateContent = true;
this.recalcInfo.recalculateTransformText = true;
break;
case historyitem_AutoShapes_SetChartGroup:
if (r.GetBool()) {
this.chartGroup = g_oTableId.Get_ById(r.GetString2());
} else {
this.chartGroup = null;
}
break;
case historyitem_AutoShapes_SetChartTitleType:
if (r.GetBool()) {
this.type = r.GetLong();
} else {
this.type = null;
}
break;
case historyitem_AutoShapes_SetChartTitleOverlay:
this.overlay = r.GetBool();
break;
case historyitem_AutoShapes_SetChartTitleTxBody:
if (r.GetBool()) {
this.txBody = g_oTableId.Get_ById(r.GetString2());
} else {
this.txBody = null;
}
break;
}
}
},
OnContentReDraw: function () {
if (this.chartGroup) {
this.chartGroup.OnContentReDraw();
}
}
};

File diff suppressed because it is too large Load Diff

View File

@@ -1,698 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
function MoveTrackGroup(originalGroup, majorOffsetX, majorOffsetY) {
this.originalGroup = originalGroup;
this.posX = originalGroup.absOffsetX;
this.posY = originalGroup.absOffsetY;
this.pageIndex = originalGroup.pageIndex;
this.flipH = originalGroup.absFlipH;
this.flipV = originalGroup.absFlipV;
this.horCenter = originalGroup.absExtX * 0.5;
this.verCenter = originalGroup.absExtY * 0.5;
this.rot = originalGroup.absRot;
this.majorOffsetX = majorOffsetX;
this.majorOffsetY = majorOffsetY;
this.transformMatrix = originalGroup.transform.CreateDublicate();
this.graphicObjects = [];
for (var _shape_index = 0; _shape_index < originalGroup.arrGraphicObjects.length; ++_shape_index) {
this.graphicObjects[_shape_index] = this.originalGroup.arrGraphicObjects[_shape_index].createObjectForDrawOnOverlayInGroup();
}
this.track = function (posX, posY, pageIndex) {
this.posX = posX + this.majorOffsetX;
this.posY = posY + this.majorOffsetY;
this.pageIndex = pageIndex;
this.calculateTransformMatrix();
for (var _shape_index = 0; _shape_index < this.graphicObjects.length; ++_shape_index) {
this.graphicObjects[_shape_index].pageIndex = pageIndex;
this.graphicObjects[_shape_index].calculateFullTransform(this.transformMatrix);
}
};
this.draw = function (overlay) {
for (var _shape_index = 0; _shape_index < this.graphicObjects.length; ++_shape_index) {
this.graphicObjects[_shape_index].draw(overlay);
}
};
this.getBounds = function () {
var bounds_checker = new CSlideBoundsChecker();
bounds_checker.init(Page_Width, Page_Height, Page_Width, Page_Height);
this.draw(bounds_checker);
return {
l: bounds_checker.Bounds.min_x,
t: bounds_checker.Bounds.min_y,
r: bounds_checker.Bounds.max_x,
b: bounds_checker.Bounds.max_y
};
};
this.getBoundsRect = function () {
var t = this.transformMatrix;
var min_x, max_x, min_y, max_y;
min_x = t.TransformPointX(0, 0);
max_x = min_x;
min_y = t.TransformPointY(0, 0);
max_y = min_y;
var t_x, t_y;
var or_sp = this.originalGroup;
var arr = [{
x: or_sp.absExtX,
y: 0
},
{
x: or_sp.absExtX,
y: or_sp.absExtY
},
{
x: 0,
y: or_sp.absExtY
}];
for (var i = 0; i < arr.length; ++i) {
var p = arr[i];
t_x = t.TransformPointX(p.x, p.y);
t_y = t.TransformPointY(p.x, p.y);
if (t_x < min_x) {
min_x = t_x;
}
if (t_x > max_x) {
max_x = t_x;
}
if (t_y < min_y) {
min_y = t_y;
}
if (t_y > max_y) {
max_y = t_y;
}
}
return {
l: min_x,
t: min_y,
r: max_x,
b: max_y
};
};
this.trackEnd = function () {
this.boolChangePos = true;
this.originalGroup.updatePosition(this.posX, this.posY);
};
this.calculateTransformMatrix = function () {
var _transform = this.transformMatrix;
_transform.Reset();
var _horizontal_center = this.horCenter;
var _vertical_center = this.verCenter;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if (this.flipH) {
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if (this.flipV) {
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.rot);
global_MatrixTransformer.TranslateAppend(_transform, this.posX, this.posY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
};
}
function ResizeTrackGroup(originalGroup, numberHandle, pageIndex) {
this.pageIndex = pageIndex;
this.originalGroup = originalGroup;
this.originalOffsetX = originalGroup.absOffsetX;
this.originalOffsetY = originalGroup.absOffsetY;
this.originalExtX = originalGroup.absExtX;
this.originalExtY = originalGroup.absExtY;
this.originalFlipH = originalGroup.absFlipH;
this.originalFlipV = originalGroup.absFlipV;
this.originalRot = originalGroup.absRot;
this.resizedOffsetX = originalGroup.absOffsetX;
this.resizedOffsetY = originalGroup.absOffsetY;
this.resizedPosX = this.resizedOffsetX;
this.resizedPosY = this.resizedOffsetY;
this.resizedExtX = originalGroup.absExtX;
this.resizedExtY = originalGroup.absExtY;
this.usedExtX = this.originalExtX === 0 ? 0.01 : this.originalExtX;
this.usedExtY = this.originalExtY === 0 ? 0.01 : this.originalExtY;
this.resizedFlipH = originalGroup.absFlipH;
this.resizedFlipV = originalGroup.absFlipV;
this.resizedRot = originalGroup.absRot;
var _translated_num_handle;
if (!this.originalFlipH && !this.originalFlipV) {
_translated_num_handle = numberHandle;
} else {
if (this.originalFlipH && !this.originalFlipV) {
_translated_num_handle = TRANSLATE_HANDLE_FLIP_H[numberHandle];
} else {
if (!this.originalFlipH && this.originalFlipV) {
_translated_num_handle = TRANSLATE_HANDLE_FLIP_V[numberHandle];
} else {
_translated_num_handle = TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[numberHandle];
}
}
}
this.translatetNumberHandle = _translated_num_handle;
this.bAspect = typeof numberHandle === "number" && numberHandle % 2 === 0;
this.aspect = this.bAspect === true ? this.originalGroup.getAspect(_translated_num_handle) : 0;
this.sin = Math.sin(this.originalRot);
this.cos = Math.cos(this.originalRot);
var _half_width = this.originalExtX * 0.5;
var _half_height = this.originalExtY * 0.5;
var _sin = this.sin;
var _cos = this.cos;
switch (_translated_num_handle) {
case 0:
case 1:
this.fixedPointX = (_half_width * _cos - _half_height * _sin) + _half_width + this.originalOffsetX;
this.fixedPointY = (_half_width * _sin + _half_height * _cos) + _half_height + this.originalOffsetY;
break;
case 2:
case 3:
this.fixedPointX = (-_half_width * _cos - _half_height * _sin) + _half_width + this.originalOffsetX;
this.fixedPointY = (-_half_width * _sin + _half_height * _cos) + _half_height + this.originalOffsetY;
break;
case 4:
case 5:
this.fixedPointX = (-_half_width * _cos + _half_height * _sin) + _half_width + this.originalOffsetX;
this.fixedPointY = (-_half_width * _sin - _half_height * _cos) + _half_height + this.originalOffsetY;
break;
case 6:
case 7:
this.fixedPointX = (_half_width * _cos + _half_height * _sin) + _half_width + this.originalOffsetX;
this.fixedPointY = (_half_width * _sin - _half_height * _cos) + _half_height + this.originalOffsetY;
break;
}
this.mod = this.translatetNumberHandle % 4;
this.centerPointX = this.originalOffsetX + _half_width;
this.centerPointY = this.originalOffsetY + _half_height;
this.transformMatrix = originalGroup.transform.CreateDublicate();
this.bChangeCoef = this.translatetNumberHandle % 2 === 0 && this.originalFlipH !== this.originalFlipV;
this.childTracks = [];
var _original_sp_tree = originalGroup.spTree;
var _original_count = _original_sp_tree.length;
for (var _original_index = 0; _original_index < _original_count; ++_original_index) {
this.childTracks.push(_original_sp_tree[_original_index].createObjectForResizeInGroup());
}
this.resize = function (kd1, kd2, shiftKey) {
var _cos = this.cos;
var _sin = this.sin;
var _real_height, _real_width;
var _abs_height, _abs_width;
var _new_resize_half_width;
var _new_resize_half_height;
var _new_used_half_width;
var _new_used_half_height;
var _temp;
if (shiftKey === true && this.bAspect === true) {
var _new_aspect = this.aspect * (Math.abs(kd1 / kd2));
if (_new_aspect >= this.aspect) {
kd2 = Math.abs(kd1) * (kd2 >= 0 ? 1 : -1);
} else {
kd1 = Math.abs(kd2) * (kd1 >= 0 ? 1 : -1);
}
}
if (this.bChangeCoef) {
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
switch (this.translatetNumberHandle) {
case 0:
case 1:
if (this.translatetNumberHandle === 0) {
_real_width = this.usedExtX * kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
if (_real_width < 0) {
this.resizedFlipH = !this.originalFlipH;
} else {
this.resizedFlipH = this.originalFlipH;
}
}
if (this.translatetNumberHandle === 1) {
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
_real_height = this.usedExtY * kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
if (_real_height < 0) {
this.resizedFlipV = !this.originalFlipV;
} else {
this.resizedFlipV = this.originalFlipV;
}
_new_resize_half_width = this.resizedExtX * 0.5;
_new_resize_half_height = this.resizedExtY * 0.5;
if (this.resizedFlipH !== this.originalFlipH) {
_new_used_half_width = -_new_resize_half_width;
} else {
_new_used_half_width = _new_resize_half_width;
}
if (this.resizedFlipV !== this.originalFlipV) {
_new_used_half_height = -_new_resize_half_height;
} else {
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (-_new_used_half_width * _cos + _new_used_half_height * _sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (-_new_used_half_width * _sin - _new_used_half_height * _cos) - _new_resize_half_height;
break;
case 2:
case 3:
if (this.translatetNumberHandle === 2) {
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
_real_height = this.usedExtY * kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
if (_real_height < 0) {
this.resizedFlipV = !this.originalFlipV;
} else {
this.resizedFlipV = this.originalFlipV;
}
}
_real_width = this.usedExtX * kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
if (_real_width < 0) {
this.resizedFlipH = !this.originalFlipH;
} else {
this.resizedFlipH = this.originalFlipH;
}
_new_resize_half_width = this.resizedExtX * 0.5;
_new_resize_half_height = this.resizedExtY * 0.5;
if (this.resizedFlipH !== this.originalFlipH) {
_new_used_half_width = -_new_resize_half_width;
} else {
_new_used_half_width = _new_resize_half_width;
}
if (this.resizedFlipV !== this.originalFlipV) {
_new_used_half_height = -_new_resize_half_height;
} else {
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (_new_used_half_width * _cos + _new_used_half_height * _sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (_new_used_half_width * _sin - _new_used_half_height * _cos) - _new_resize_half_height;
break;
case 4:
case 5:
if (this.translatetNumberHandle === 4) {
_real_width = this.usedExtX * kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
if (_real_width < 0) {
this.resizedFlipH = !this.originalFlipH;
} else {
this.resizedFlipH = this.originalFlipH;
}
} else {
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
}
_real_height = this.usedExtY * kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
if (_real_height < 0) {
this.resizedFlipV = !this.originalFlipV;
} else {
this.resizedFlipV = this.originalFlipV;
}
_new_resize_half_width = this.resizedExtX * 0.5;
_new_resize_half_height = this.resizedExtY * 0.5;
if (this.resizedFlipH !== this.originalFlipH) {
_new_used_half_width = -_new_resize_half_width;
} else {
_new_used_half_width = _new_resize_half_width;
}
if (this.resizedFlipV !== this.originalFlipV) {
_new_used_half_height = -_new_resize_half_height;
} else {
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (_new_used_half_width * _cos - _new_used_half_height * _sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (_new_used_half_width * _sin + _new_used_half_height * _cos) - _new_resize_half_height;
break;
case 6:
case 7:
if (this.translatetNumberHandle === 6) {
_real_height = this.usedExtY * kd1;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
if (_real_height < 0) {
this.resizedFlipV = !this.originalFlipV;
} else {
this.resizedFlipV = this.originalFlipV;
}
} else {
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
}
_real_width = this.usedExtX * kd2;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
if (_real_width < 0) {
this.resizedFlipH = !this.originalFlipH;
} else {
this.resizedFlipH = this.originalFlipH;
}
_new_resize_half_width = this.resizedExtX * 0.5;
_new_resize_half_height = this.resizedExtY * 0.5;
if (this.resizedFlipH !== this.originalFlipH) {
_new_used_half_width = -_new_resize_half_width;
} else {
_new_used_half_width = _new_resize_half_width;
}
if (this.resizedFlipV !== this.originalFlipV) {
_new_used_half_height = -_new_resize_half_height;
} else {
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (-_new_used_half_width * _cos - _new_used_half_height * _sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (-_new_used_half_width * _sin + _new_used_half_height * _cos) - _new_resize_half_height;
break;
}
var _transform = this.transformMatrix;
_transform.Reset();
var _horizontal_center = this.resizedExtX * 0.5;
var _vertical_center = this.resizedExtY * 0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if (this.resizedFlipH) {
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if (this.resizedFlipV) {
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.resizedRot);
global_MatrixTransformer.TranslateAppend(_transform, this.resizedPosX, this.resizedPosY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
var _kw = this.resizedExtX / this.originalExtX;
var _kh = this.resizedExtY / this.originalExtY;
for (var _child_index = 0; _child_index < this.childTracks.length; ++_child_index) {
this.childTracks[_child_index].changeSizes(_kw, _kh, _horizontal_center, _vertical_center);
this.childTracks[_child_index].calculateTransformMatrix(_transform);
}
};
this.resizeRelativeCenter = function (kd1, kd2, shiftKey) {
kd1 = 2 * kd1 - 1;
kd2 = 2 * kd2 - 1;
var _real_height, _real_width;
var _abs_height, _abs_width;
if (shiftKey === true && this.bAspect === true) {
var _new_aspect = this.aspect * (Math.abs(kd1 / kd2));
if (_new_aspect >= this.aspect) {
kd2 = Math.abs(kd1) * (kd2 >= 0 ? 1 : -1);
} else {
kd1 = Math.abs(kd2) * (kd1 >= 0 ? 1 : -1);
}
}
var _temp;
if (this.bChangeCoef) {
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
if (this.mod === 0 || this.mod === 1) {
if (this.mod === 0) {
_real_width = this.usedExtX * kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
this.resizedFlipH = _real_width < 0 ? !this.originalFlipH : this.originalFlipH;
} else {
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
_real_height = this.usedExtY * kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
this.resizedFlipV = _real_height < 0 ? !this.originalFlipV : this.originalFlipV;
} else {
if (this.mod === 2) {
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
_real_height = this.usedExtY * kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
this.resizedFlipV = _real_height < 0 ? !this.originalFlipV : this.originalFlipV;
}
_real_width = this.usedExtX * kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
this.resizedFlipH = _real_width < 0 ? !this.originalFlipH : this.originalFlipH;
}
this.resizedPosX = this.centerPointX - this.resizedExtX * 0.5;
this.resizedPosY = this.centerPointY - this.resizedExtY * 0.5;
var _transform = this.transformMatrix;
_transform.Reset();
var _horizontal_center = this.resizedExtX * 0.5;
var _vertical_center = this.resizedExtY * 0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if (this.resizedFlipH) {
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if (this.resizedFlipV) {
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.resizedRot);
global_MatrixTransformer.TranslateAppend(_transform, this.resizedPosX, this.resizedPosY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
var _kw = this.resizedExtX / this.originalExtX;
var _kh = this.resizedExtY / this.originalExtY;
for (var _child_index = 0; _child_index < this.childTracks.length; ++_child_index) {
this.childTracks[_child_index].changeSizes(_kw, _kh, _horizontal_center, _vertical_center);
this.childTracks[_child_index].calculateTransformMatrix(_transform);
}
};
this.draw = function (overlay) {
overlay.SetCurrentPage(this.pageIndex);
for (var _child_index = 0; _child_index < this.childTracks.length; ++_child_index) {
this.childTracks[_child_index].draw(overlay);
}
};
this.getBounds = function () {
var bounds_checker = new CSlideBoundsChecker();
bounds_checker.init(Page_Width, Page_Height, Page_Width, Page_Height);
this.draw(bounds_checker);
return {
l: bounds_checker.Bounds.min_x,
t: bounds_checker.Bounds.min_y,
r: bounds_checker.Bounds.max_x,
b: bounds_checker.Bounds.max_y
};
};
this.getBoundsRect = function () {
var t = this.transformMatrix;
var min_x, max_x, min_y, max_y;
min_x = t.TransformPointX(0, 0);
max_x = min_x;
min_y = t.TransformPointY(0, 0);
max_y = min_y;
var arr = [{
x: this.resizedPosX,
y: 0
},
{
x: this.resizedPosX,
y: this.resizedPosY
},
{
x: 0,
y: this.resizedPosY
}];
var t_x, t_y;
for (var i = 0; i < arr.length; ++i) {
var p = arr[i];
t_x = t.TransformPointX(p.x, p.y);
t_y = t.TransformPointY(p.x, p.y);
if (t_x < min_x) {
min_x = t_x;
}
if (t_x > max_x) {
max_x = t_x;
}
if (t_y < min_y) {
min_y = t_y;
}
if (t_y > max_y) {
max_y = t_y;
}
}
return {
l: min_x,
t: min_y,
r: max_x,
b: max_y
};
};
this.endTrack = function () {
var bChange = this.resizedExtX !== this.originalGroup.absExtX || this.resizedExtY !== this.originalGroup.absExtY || this.resizedOffsetX !== this.resizedPosX || this.resizedOffsetY !== this.resizedPosY || this.resizedFlipH !== this.originalGroup.absFlipH || this.resizedFlipV !== this.originalGroup.absFlipV;
if (bChange) {
this.boolChangePos = true;
this.originalGroup.setSizes(this.resizedPosX, this.resizedPosY, this.resizedExtX, this.resizedExtY, this.resizedFlipH, this.resizedFlipV, this.childTracks);
} else {
this.boolChangePos = false;
}
};
}
function RotateTrackGroup(originalGroup, pageIndex) {
this.originalGroup = originalGroup;
this.pageIndex = pageIndex;
this.originalRot = this.originalGroup.absRot;
this.rot = this.originalGroup.absRot;
this.transformMatrix = this.originalGroup.transform.CreateDublicate();
this.graphicObjects = [];
for (var _shape_index = 0; _shape_index < originalGroup.arrGraphicObjects.length; ++_shape_index) {
this.graphicObjects[_shape_index] = this.originalGroup.arrGraphicObjects[_shape_index].createObjectForDrawOnOverlayInGroup();
}
this.track = function (angle, shiftKey) {
var _new_rot = angle + this.originalRot;
while (_new_rot < 0) {
_new_rot += 2 * Math.PI;
}
while (_new_rot >= 2 * Math.PI) {
_new_rot -= 2 * Math.PI;
}
if (_new_rot < MIN_ANGLE || _new_rot > 2 * Math.PI - MIN_ANGLE) {
_new_rot = 0;
}
if (Math.abs(_new_rot - Math.PI * 0.5) < MIN_ANGLE) {
_new_rot = Math.PI * 0.5;
}
if (Math.abs(_new_rot - Math.PI) < MIN_ANGLE) {
_new_rot = Math.PI;
}
if (Math.abs(_new_rot - 1.5 * Math.PI) < MIN_ANGLE) {
_new_rot = 1.5 * Math.PI;
}
if (shiftKey) {
_new_rot = (Math.PI / 12) * Math.floor(12 * _new_rot / (Math.PI));
}
this.rot = _new_rot;
this.calculateTransformMatrix();
for (var _shape_index = 0; _shape_index < this.graphicObjects.length; ++_shape_index) {
this.graphicObjects[_shape_index].pageIndex = pageIndex;
this.graphicObjects[_shape_index].calculateFullTransform(this.transformMatrix);
}
};
this.getBounds = function () {
var bounds_checker = new CSlideBoundsChecker();
bounds_checker.init(Page_Width, Page_Height, Page_Width, Page_Height);
this.draw(bounds_checker);
return {
l: bounds_checker.Bounds.min_x,
t: bounds_checker.Bounds.min_y,
r: bounds_checker.Bounds.max_x,
b: bounds_checker.Bounds.max_y
};
};
this.getBoundsRect = function () {
var t = this.transformMatrix;
var max_x, min_x, max_y, min_y;
max_x = t.TransformPointX(0, 0);
min_x = max_x;
max_y = t.TransformPointY(0, 0);
min_y = max_y;
var or_sp = this.originalGroup;
var arr = [{
x: or_sp.absExtX,
y: 0
},
{
x: or_sp.absExtX,
y: or_sp.absExtY
},
{
x: 0,
y: or_sp.absExtY
}];
for (var i = 0; i < arr.length; ++i) {
var p = arr[i];
var t_x = t.TransformPointX(p.x, p.y);
var t_y = t.TransformPointY(p.x, p.y);
if (t_x < min_x) {
min_x = t_x;
}
if (t_x > max_x) {
max_x = t_x;
}
if (t_y < min_y) {
min_y = t_y;
}
if (t_y > max_y) {
max_y = t_y;
}
}
return {
l: min_x,
t: min_y,
r: max_x,
b: max_y
};
};
this.calculateTransformMatrix = function () {
var _transform = this.transformMatrix;
_transform.Reset();
var _horizontal_center = this.originalGroup.absExtX * 0.5;
var _vertical_center = this.originalGroup.absExtY * 0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if (this.originalGroup.absFlipH) {
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if (this.originalGroup.absFlipV) {
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.rot);
global_MatrixTransformer.TranslateAppend(_transform, this.originalGroup.absOffsetX, this.originalGroup.absOffsetY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
};
this.draw = function (overlay) {
for (var _shape_index = 0; _shape_index < this.graphicObjects.length; ++_shape_index) {
this.graphicObjects[_shape_index].draw(overlay);
}
};
this.getBounds = function () {
var bounds_checker = new CSlideBoundsChecker();
bounds_checker.init(Page_Width, Page_Height, Page_Width, Page_Height);
this.draw(bounds_checker);
return {
l: bounds_checker.Bounds.min_x,
t: bounds_checker.Bounds.min_y,
r: bounds_checker.Bounds.max_x,
b: bounds_checker.Bounds.max_y
};
};
this.trackEnd = function () {
if (this.rot !== this.originalGroup.absRot) {
this.originalGroup.setXfrm(null, null, null, null, this.rot, null, null);
this.originalGroup.setAbsoluteTransform(null, null, null, null, this.rot, null, null);
this.originalGroup.recalculate();
}
this.boolChangePos = true;
};
}

View File

@@ -1,929 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
var moveTo = 0,
lineTo = 1,
arcTo = 2,
bezier3 = 3,
bezier4 = 4,
close = 5;
var PATH_COMMAND_START = 257;
var PATH_COMMAND_END = 258;
var cToRad = Math.PI / 10800000;
var cToDeg = 1 / cToRad;
function Path(extrusionOk, fill, stroke, w, h) {
if (stroke != undefined) {
this.stroke = stroke;
} else {
this.stroke = true;
}
this.extrusionOk = extrusionOk || false;
this.fill = fill || "norm";
this.pathW = w;
this.pathH = h;
if (this.pathW != undefined) {
this.divPW = 1 / w;
}
if (this.pathH != undefined) {
this.divPH = 1 / h;
}
this.ArrPathCommandInfo = new Array();
this.ArrPathCommand = new Array();
this.createDuplicate = function () {
var duplicate = new Path(this.extrusionOk, this.fill, this.stroke, this.pathW, this.pathH);
for (var i = 0; i < this.ArrPathCommandInfo.length; ++i) {
duplicate.ArrPathCommandInfo[i] = clonePrototype(this.ArrPathCommandInfo[i]);
}
return duplicate;
};
}
Path.prototype = {
Write_ToBinary2: function (writer) {
writer.WriteBool(this.stroke);
writer.WriteBool(this.extrusionOk);
writer.WriteString2(this.fill);
var flag = this.pathW != undefined;
writer.WriteBool(flag);
if (flag) {
writer.WriteLong(this.pathW);
}
flag = this.pathH != undefined;
writer.WriteBool(flag);
if (flag) {
writer.WriteLong(this.pathH);
}
flag = this.divPW != undefined;
writer.WriteBool(flag);
if (flag) {
writer.WriteDouble(this.divPW);
}
flag = this.divPH != undefined;
writer.WriteBool(flag);
if (flag) {
writer.WriteDouble(this.divPH);
}
var path_command_count = this.ArrPathCommandInfo.length;
writer.WriteLong(path_command_count);
var write_function = writer.WriteString2;
for (var index = 0; index < path_command_count; ++index) {
var c = this.ArrPathCommandInfo[index];
switch (c.id) {
case moveTo:
case lineTo:
writer.WriteLong(c.id);
write_function.call(writer, c.X);
write_function.call(writer, c.Y);
break;
case bezier3:
writer.WriteLong(c.id);
write_function.call(writer, c.X0);
write_function.call(writer, c.Y0);
write_function.call(writer, c.X1);
write_function.call(writer, c.Y1);
break;
case bezier4:
writer.WriteLong(c.id);
write_function.call(writer, c.X0);
write_function.call(writer, c.Y0);
write_function.call(writer, c.X1);
write_function.call(writer, c.Y1);
write_function.call(writer, c.X2);
write_function.call(writer, c.Y2);
break;
case arcTo:
writer.WriteLong(c.id);
write_function.call(writer, c.hR);
write_function.call(writer, c.wR);
write_function.call(writer, c.stAng);
write_function.call(writer, c.swAng);
break;
case close:
writer.WriteLong(c.id);
break;
}
}
for (index = 0; index < path_command_count; ++index) {
WriteObjectLong(writer, this.ArrPathCommand[index]);
}
},
Read_FromBinary2: function (Reader) {
this.stroke = Reader.GetBool();
this.extrusionOk = Reader.GetBool();
this.fill = Reader.GetString2();
var flag = Reader.GetBool();
if (flag) {
this.pathW = Reader.GetLong();
}
flag = Reader.GetBool();
if (flag) {
this.pathH = Reader.GetLong();
}
flag = Reader.GetBool();
if (flag) {
this.divPW = Reader.GetDouble();
}
flag = Reader.GetBool();
if (flag) {
this.divPH = Reader.GetDouble();
}
if (typeof this.pathW === "number") {
this.divPW = 1 / this.pathW;
}
if (typeof this.pathH === "number") {
this.divPH = 1 / this.pathH;
}
var path_command_count = Reader.GetLong();
var read_function = Reader.GetString2;
for (var index = 0; index < path_command_count; ++index) {
var c = {};
var id = Reader.GetLong();
c.id = id;
switch (id) {
case moveTo:
case lineTo:
c.X = read_function.call(Reader);
c.Y = read_function.call(Reader);
break;
case bezier3:
c.X0 = read_function.call(Reader);
c.Y0 = read_function.call(Reader);
c.X1 = read_function.call(Reader);
c.Y1 = read_function.call(Reader);
break;
case bezier4:
c.X0 = read_function.call(Reader);
c.Y0 = read_function.call(Reader);
c.X1 = read_function.call(Reader);
c.Y1 = read_function.call(Reader);
c.X2 = read_function.call(Reader);
c.Y2 = read_function.call(Reader);
break;
case arcTo:
c.hR = read_function.call(Reader);
c.wR = read_function.call(Reader);
c.stAng = read_function.call(Reader);
c.swAng = read_function.call(Reader);
break;
case close:
break;
}
for (var key in c) {
if (!isNaN(parseInt(c[key], 10))) {
c[key] = parseInt(c[key], 10);
}
}
this.ArrPathCommandInfo.push(c);
}
for (index = 0; index < path_command_count; ++index) {
this.ArrPathCommand[index] = ReadObjectLong(Reader);
}
},
moveTo: function (x, y) {
if (!isNaN(parseInt(x, 10))) {
x = parseInt(x, 10);
}
if (!isNaN(parseInt(y, 10))) {
y = parseInt(y, 10);
}
this.ArrPathCommandInfo.push({
id: moveTo,
X: x,
Y: y
});
},
lnTo: function (x, y) {
if (!isNaN(parseInt(x, 10))) {
x = parseInt(x, 10);
}
if (!isNaN(parseInt(y, 10))) {
y = parseInt(y, 10);
}
this.ArrPathCommandInfo.push({
id: lineTo,
X: x,
Y: y
});
},
arcTo: function (wR, hR, stAng, swAng) {
if (!isNaN(parseInt(wR, 10))) {
wR = parseInt(wR, 10);
}
if (!isNaN(parseInt(hR, 10))) {
hR = parseInt(hR, 10);
}
if (!isNaN(parseInt(stAng, 10))) {
stAng = parseInt(stAng, 10);
}
if (!isNaN(parseInt(swAng, 10))) {
swAng = parseInt(swAng, 10);
}
this.ArrPathCommandInfo.push({
id: arcTo,
wR: wR,
hR: hR,
stAng: stAng,
swAng: swAng
});
},
quadBezTo: function (x0, y0, x1, y1) {
if (!isNaN(parseInt(x0, 10))) {
x0 = parseInt(x0, 10);
}
if (!isNaN(parseInt(y0, 10))) {
y0 = parseInt(y0, 10);
}
if (!isNaN(parseInt(x1, 10))) {
x1 = parseInt(x1, 10);
}
if (!isNaN(parseInt(y1, 10))) {
y1 = parseInt(y1, 10);
}
this.ArrPathCommandInfo.push({
id: bezier3,
X0: x0,
Y0: y0,
X1: x1,
Y1: y1
});
},
cubicBezTo: function (x0, y0, x1, y1, x2, y2) {
if (!isNaN(parseInt(x0, 10))) {
x0 = parseInt(x0, 10);
}
if (!isNaN(parseInt(y0, 10))) {
y0 = parseInt(y0, 10);
}
if (!isNaN(parseInt(x1, 10))) {
x1 = parseInt(x1, 10);
}
if (!isNaN(parseInt(y1, 10))) {
y1 = parseInt(y1, 10);
}
if (!isNaN(parseInt(x2, 10))) {
x2 = parseInt(x2, 10);
}
if (!isNaN(parseInt(y2, 10))) {
y2 = parseInt(y2, 10);
}
this.ArrPathCommandInfo.push({
id: bezier4,
X0: x0,
Y0: y0,
X1: x1,
Y1: y1,
X2: x2,
Y2: y2
});
},
close: function () {
this.ArrPathCommandInfo.push({
id: close
});
},
init: function (gdLst) {
if (this.ArrPathCommandInfo.length === this.ArrPathCommand.length) {
this.ArrPathCommand.length = 0;
}
var ch, cw;
if (this.pathW != undefined) {
cw = (gdLst["w"] / this.pathW);
} else {
cw = 1;
}
if (this.pathH != undefined) {
ch = (gdLst["h"] / this.pathH);
} else {
ch = 1;
}
var APCI = this.ArrPathCommandInfo,
n = APCI.length,
cmd;
var x0, y0, x1, y1, x2, y2, wR, hR, stAng, swAng, lastX, lastY;
for (var i = 0; i < n; i++) {
cmd = APCI[i];
switch (cmd.id) {
case moveTo:
case lineTo:
x0 = parseInt(cmd.X);
if (isNaN(x0)) {
x0 = gdLst[cmd.X];
}
y0 = parseInt(cmd.Y);
if (isNaN(y0)) {
y0 = gdLst[cmd.Y];
}
this.ArrPathCommand.push({
id: cmd.id,
X: x0 * cw,
Y: y0 * ch
});
lastX = x0 * cw;
lastY = y0 * ch;
break;
case bezier3:
x0 = parseInt(cmd.X0);
if (isNaN(x0)) {
x0 = gdLst[cmd.X0];
}
y0 = parseInt(cmd.Y0);
if (isNaN(y0)) {
y0 = gdLst[cmd.Y0];
}
x1 = parseInt(cmd.X1);
if (isNaN(x1)) {
x1 = gdLst[cmd.X1];
}
y1 = parseInt(cmd.Y1);
if (isNaN(y1)) {
y1 = gdLst[cmd.Y1];
}
this.ArrPathCommand.push({
id: bezier3,
X0: x0 * cw,
Y0: y0 * ch,
X1: x1 * cw,
Y1: y1 * ch
});
lastX = x1 * cw;
lastY = y1 * ch;
break;
case bezier4:
x0 = parseInt(cmd.X0);
if (isNaN(x0)) {
x0 = gdLst[cmd.X0];
}
y0 = parseInt(cmd.Y0);
if (isNaN(y0)) {
y0 = gdLst[cmd.Y0];
}
x1 = parseInt(cmd.X1);
if (isNaN(x1)) {
x1 = gdLst[cmd.X1];
}
y1 = parseInt(cmd.Y1);
if (isNaN(y1)) {
y1 = gdLst[cmd.Y1];
}
x2 = parseInt(cmd.X2);
if (isNaN(x2)) {
x2 = gdLst[cmd.X2];
}
y2 = parseInt(cmd.Y2);
if (isNaN(y2)) {
y2 = gdLst[cmd.Y2];
}
this.ArrPathCommand.push({
id: bezier4,
X0: x0 * cw,
Y0: y0 * ch,
X1: x1 * cw,
Y1: y1 * ch,
X2: x2 * cw,
Y2: y2 * ch
});
lastX = x2 * cw;
lastY = y2 * ch;
break;
case arcTo:
hR = parseInt(cmd.hR);
if (isNaN(hR)) {
hR = gdLst[cmd.hR];
}
wR = parseInt(cmd.wR);
if (isNaN(wR)) {
wR = gdLst[cmd.wR];
}
stAng = parseInt(cmd.stAng);
if (isNaN(stAng)) {
stAng = gdLst[cmd.stAng];
}
swAng = parseInt(cmd.swAng);
if (isNaN(swAng)) {
swAng = gdLst[cmd.swAng];
}
var a1 = stAng;
var a2 = stAng + swAng;
var a3 = swAng;
stAng = Math.atan2(ch * Math.sin(a1 * cToRad), cw * Math.cos(a1 * cToRad)) / cToRad;
swAng = Math.atan2(ch * Math.sin(a2 * cToRad), cw * Math.cos(a2 * cToRad)) / cToRad - stAng;
if ((swAng > 0) && (a3 < 0)) {
swAng -= 21600000;
}
if ((swAng < 0) && (a3 > 0)) {
swAng += 21600000;
}
if (swAng == 0) {
swAng = 21600000;
}
var a = wR * cw;
var b = hR * ch;
var sin2 = Math.sin(stAng * cToRad);
var cos2 = Math.cos(stAng * cToRad);
var _xrad = cos2 / a;
var _yrad = sin2 / b;
var l = 1 / Math.sqrt(_xrad * _xrad + _yrad * _yrad);
var xc = lastX - l * cos2;
var yc = lastY - l * sin2;
var sin1 = Math.sin((stAng + swAng) * cToRad);
var cos1 = Math.cos((stAng + swAng) * cToRad);
var _xrad1 = cos1 / a;
var _yrad1 = sin1 / b;
var l1 = 1 / Math.sqrt(_xrad1 * _xrad1 + _yrad1 * _yrad1);
this.ArrPathCommand[i] = {
id: arcTo,
stX: lastX,
stY: lastY,
wR: wR * cw,
hR: hR * ch,
stAng: stAng * cToRad,
swAng: swAng * cToRad
};
lastX = xc + l1 * cos1;
lastY = yc + l1 * sin1;
break;
case close:
this.ArrPathCommand.push({
id: close
});
break;
default:
break;
}
}
},
recalculate: function (gdLst) {
var ch, cw;
if (this.pathW != undefined) {
cw = (gdLst["w"] / this.pathW);
} else {
cw = 1;
}
if (this.pathH != undefined) {
ch = (gdLst["h"] / this.pathH);
} else {
ch = 1;
}
var APCI = this.ArrPathCommandInfo,
n = APCI.length,
cmd;
var x0, y0, x1, y1, x2, y2, wR, hR, stAng, swAng, lastX, lastY;
for (var i = 0; i < n; ++i) {
cmd = APCI[i];
switch (cmd.id) {
case moveTo:
case lineTo:
x0 = gdLst[cmd.X];
if (x0 === undefined) {
x0 = cmd.X;
}
y0 = gdLst[cmd.Y];
if (y0 === undefined) {
y0 = cmd.Y;
}
this.ArrPathCommand[i] = {
id: cmd.id,
X: x0 * cw,
Y: y0 * ch
};
lastX = x0 * cw;
lastY = y0 * ch;
break;
case bezier3:
x0 = gdLst[cmd.X0];
if (x0 === undefined) {
x0 = cmd.X0;
}
y0 = gdLst[cmd.Y0];
if (y0 === undefined) {
y0 = cmd.Y0;
}
x1 = gdLst[cmd.X1];
if (x1 === undefined) {
x1 = cmd.X1;
}
y1 = gdLst[cmd.Y1];
if (y1 === undefined) {
y1 = cmd.Y1;
}
this.ArrPathCommand[i] = {
id: bezier3,
X0: x0 * cw,
Y0: y0 * ch,
X1: x1 * cw,
Y1: y1 * ch
};
lastX = x1 * cw;
lastY = y1 * ch;
break;
case bezier4:
x0 = gdLst[cmd.X0];
if (x0 === undefined) {
x0 = cmd.X0;
}
y0 = gdLst[cmd.Y0];
if (y0 === undefined) {
y0 = cmd.Y0;
}
x1 = gdLst[cmd.X1];
if (x1 === undefined) {
x1 = cmd.X1;
}
y1 = gdLst[cmd.Y1];
if (y1 === undefined) {
y1 = cmd.Y1;
}
x2 = gdLst[cmd.X2];
if (x2 === undefined) {
x2 = cmd.X2;
}
y2 = gdLst[cmd.Y2];
if (y2 === undefined) {
y2 = cmd.Y2;
}
this.ArrPathCommand[i] = {
id: bezier4,
X0: x0 * cw,
Y0: y0 * ch,
X1: x1 * cw,
Y1: y1 * ch,
X2: x2 * cw,
Y2: y2 * ch
};
lastX = x2 * cw;
lastY = y2 * ch;
break;
case arcTo:
hR = gdLst[cmd.hR];
if (hR === undefined) {
hR = cmd.hR;
}
wR = gdLst[cmd.wR];
if (wR === undefined) {
wR = cmd.wR;
}
stAng = gdLst[cmd.stAng];
if (stAng === undefined) {
stAng = cmd.stAng;
}
swAng = gdLst[cmd.swAng];
if (swAng === undefined) {
swAng = cmd.swAng;
}
var a1 = stAng;
var a2 = stAng + swAng;
var a3 = swAng;
stAng = Math.atan2(ch * Math.sin(a1 * cToRad), cw * Math.cos(a1 * cToRad)) / cToRad;
swAng = Math.atan2(ch * Math.sin(a2 * cToRad), cw * Math.cos(a2 * cToRad)) / cToRad - stAng;
if ((swAng > 0) && (a3 < 0)) {
swAng -= 21600000;
}
if ((swAng < 0) && (a3 > 0)) {
swAng += 21600000;
}
if (swAng == 0) {
swAng = 21600000;
}
var a = wR * cw;
var b = hR * ch;
var sin2 = Math.sin(stAng * cToRad);
var cos2 = Math.cos(stAng * cToRad);
var _xrad = cos2 / a;
var _yrad = sin2 / b;
var l = 1 / Math.sqrt(_xrad * _xrad + _yrad * _yrad);
var xc = lastX - l * cos2;
var yc = lastY - l * sin2;
var sin1 = Math.sin((stAng + swAng) * cToRad);
var cos1 = Math.cos((stAng + swAng) * cToRad);
var _xrad1 = cos1 / a;
var _yrad1 = sin1 / b;
var l1 = 1 / Math.sqrt(_xrad1 * _xrad1 + _yrad1 * _yrad1);
this.ArrPathCommand[i] = {
id: arcTo,
stX: lastX,
stY: lastY,
wR: wR * cw,
hR: hR * ch,
stAng: stAng * cToRad,
swAng: swAng * cToRad
};
lastX = xc + l1 * cos1;
lastY = yc + l1 * sin1;
break;
case close:
this.ArrPathCommand[i] = {
id: close
};
break;
default:
break;
}
}
},
draw: function (shape_drawer) {
if (shape_drawer.bIsCheckBounds === true && this.fill == "none") {
return;
}
var bIsDrawLast = false;
var path = this.ArrPathCommand;
shape_drawer._s();
for (var j = 0, l = path.length; j < l; ++j) {
var cmd = path[j];
switch (cmd.id) {
case moveTo:
bIsDrawLast = true;
shape_drawer._m(cmd.X, cmd.Y);
break;
case lineTo:
bIsDrawLast = true;
shape_drawer._l(cmd.X, cmd.Y);
break;
case bezier3:
bIsDrawLast = true;
shape_drawer._c2(cmd.X0, cmd.Y0, cmd.X1, cmd.Y1);
break;
case bezier4:
bIsDrawLast = true;
shape_drawer._c(cmd.X0, cmd.Y0, cmd.X1, cmd.Y1, cmd.X2, cmd.Y2);
break;
case arcTo:
bIsDrawLast = true;
ArcToCurvers(shape_drawer, cmd.stX, cmd.stY, cmd.wR, cmd.hR, cmd.stAng, cmd.swAng);
break;
case close:
shape_drawer._z();
break;
}
}
if (bIsDrawLast) {
shape_drawer.drawFillStroke(true, this.fill, this.stroke && !shape_drawer.bIsNoStrokeAttack);
}
shape_drawer._e();
},
check_bounds: function (checker) {
var path = this.ArrPathCommand;
for (var j = 0, l = path.length; j < l; ++j) {
var cmd = path[j];
switch (cmd.id) {
case moveTo:
checker._m(cmd.X, cmd.Y);
break;
case lineTo:
checker._l(cmd.X, cmd.Y);
break;
case bezier3:
checker._c2(cmd.X0, cmd.Y0, cmd.X1, cmd.Y1);
break;
case bezier4:
checker._c(cmd.X0, cmd.Y0, cmd.X1, cmd.Y1, cmd.X2, cmd.Y2);
break;
case arcTo:
ArcToCurvers(checker, cmd.stX, cmd.stY, cmd.wR, cmd.hR, cmd.stAng, cmd.swAng);
break;
case close:
checker._z();
break;
}
}
},
hitInInnerArea: function (canvasContext, x, y) {
if (this.fill === "none") {
return false;
}
var _arr_commands = this.ArrPathCommand;
var _commands_count = _arr_commands.length;
var _command_index;
var _command;
canvasContext.beginPath();
for (_command_index = 0; _command_index < _commands_count; ++_command_index) {
_command = _arr_commands[_command_index];
switch (_command.id) {
case moveTo:
canvasContext.moveTo(_command.X, _command.Y);
break;
case lineTo:
canvasContext.lineTo(_command.X, _command.Y);
break;
case arcTo:
ArcToOnCanvas(canvasContext, _command.stX, _command.stY, _command.wR, _command.hR, _command.stAng, _command.swAng);
break;
case bezier3:
canvasContext.quadraticCurveTo(_command.X0, _command.Y0, _command.X1, _command.Y1);
break;
case bezier4:
canvasContext.bezierCurveTo(_command.X0, _command.Y0, _command.X1, _command.Y1, _command.X2, _command.Y2);
break;
case close:
canvasContext.closePath();
if (canvasContext.isPointInPath(x, y)) {
return true;
}
}
}
return false;
},
hitInPath: function (canvasContext, x, y) {
var _arr_commands = this.ArrPathCommand;
var _commands_count = _arr_commands.length;
var _command_index;
var _command;
var _last_x, _last_y;
var _begin_x, _begin_y;
for (_command_index = 0; _command_index < _commands_count; ++_command_index) {
_command = _arr_commands[_command_index];
switch (_command.id) {
case moveTo:
_last_x = _command.X;
_last_y = _command.Y;
_begin_x = _command.X;
_begin_y = _command.Y;
break;
case lineTo:
if (HitInLine(canvasContext, x, y, _last_x, _last_y, _command.X, _command.Y)) {
return true;
}
_last_x = _command.X;
_last_y = _command.Y;
break;
case arcTo:
if (HitToArc(canvasContext, x, y, _command.stX, _command.stY, _command.wR, _command.hR, _command.stAng, _command.swAng)) {
return true;
}
_last_x = (_command.stX - _command.wR * Math.cos(_command.stAng) + _command.wR * Math.cos(_command.swAng));
_last_y = (_command.stY - _command.hR * Math.sin(_command.stAng) + _command.hR * Math.sin(_command.swAng));
break;
case bezier3:
if (HitInBezier3(canvasContext, x, y, _last_x, _last_y, _command.X0, _command.Y0, _command.X1, _command.Y1)) {
return true;
}
_last_x = _command.X1;
_last_y = _command.Y1;
break;
case bezier4:
if (HitInBezier4(canvasContext, x, y, _last_x, _last_y, _command.X0, _command.Y0, _command.X1, _command.Y1, _command.X2, _command.Y2)) {
return true;
}
_last_x = _command.X2;
_last_y = _command.Y2;
break;
case close:
if (HitInLine(canvasContext, x, y, _last_x, _last_y, _begin_x, _begin_y)) {
return true;
}
}
}
return false;
},
calculateWrapPolygon: function (epsilon, graphics) {
var arr_polygons = [];
var cur_polygon = [];
var path_commands = this.ArrPathCommand;
var path_commands_count = path_commands.length;
var last_x, last_y;
for (var index = 0; index < path_commands_count; ++index) {
var cur_command = path_commands[index];
switch (cur_command.id) {
case moveTo:
case lineTo:
cur_polygon.push({
x: cur_command.X,
y: cur_command.Y
});
last_x = cur_command.X;
last_y = cur_command.Y;
break;
case bezier3:
cur_polygon = cur_polygon.concat(partition_bezier3(last_x, last_y, cur_command.X0, cur_command.Y0, cur_command.X1, cur_command.Y1, epsilon));
last_x = cur_command.X1;
last_y = cur_command.Y1;
break;
case bezier4:
cur_polygon = cur_polygon.concat(partition_bezier4(last_x, last_y, cur_command.X0, cur_command.Y0, cur_command.X1, cur_command.Y1, cur_command.X2, cur_command.Y2, epsilon));
last_x = cur_command.X2;
last_y = cur_command.Y2;
break;
case arcTo:
var arr_curve_bezier = getArrayPointsCurveBezierAtArcTo(last_x, last_y, cur_command.stX, cur_command.stY, cur_command.wR, cur_command.hR, cur_command.stAng, cur_command.swAng);
if (arr_curve_bezier.length > 0) {
last_x = arr_curve_bezier[arr_curve_bezier.length - 1].x4;
last_y = arr_curve_bezier[arr_curve_bezier.length - 1].y4;
for (var i = 0; i < arr_curve_bezier.length; ++i) {
var cur_curve_bezier = arr_curve_bezier[i];
cur_polygon = cur_polygon.concat(partition_bezier4(cur_curve_bezier.x0, cur_curve_bezier.y0, cur_curve_bezier.x1, cur_curve_bezier.y1, cur_curve_bezier.x2, cur_curve_bezier.y2, cur_curve_bezier.x3, cur_curve_bezier.y3, epsilon));
}
}
break;
case close:
arr_polygons.push(cur_polygon);
cur_polygon = [];
}
}
for (i = 0; i < arr_polygons.length; ++i) {
var cur_polygon = arr_polygons[i];
graphics._m(cur_polygon[0].x, cur_polygon[0].y);
for (var j = 0; j < cur_polygon.length; ++j) {
graphics._l(cur_polygon[j].x, cur_polygon[j].y);
}
graphics._z();
graphics.ds();
}
}
};
function partition_bezier3(x0, y0, x1, y1, x2, y2, epsilon) {
var dx01 = x1 - x0;
var dy01 = y1 - y0;
var dx12 = x2 - x1;
var dy12 = y2 - y1;
var r01 = Math.sqrt(dx01 * dx01 + dy01 * dy01);
var r12 = Math.sqrt(dx12 * dx12 + dy12 * dy12);
if (Math.max(r01, r12) < epsilon) {
return [{
x: x0,
y: y0
},
{
x: x1,
y: y1
},
{
x: x2,
y: y2
}];
}
var x01 = (x0 + x1) * 0.5;
var y01 = (y0 + y1) * 0.5;
var x12 = (x1 + x2) * 0.5;
var y12 = (y1 + y2) * 0.5;
var x012 = (x01 + x12) * 0.5;
var y012 = (y01 + y12) * 0.5;
return partition_bezier3(x0, y0, x01, y01, x012, y012, epsilon).concat(partition_bezier3(x012, y012, x12, y12, x2, y2, epsilon));
}
function partition_bezier4(x0, y0, x1, y1, x2, y2, x3, y3, epsilon) {
var dx01 = x1 - x0;
var dy01 = y1 - y0;
var dx12 = x2 - x1;
var dy12 = y2 - y1;
var dx23 = x3 - x2;
var dy23 = y3 - y2;
var r01 = Math.sqrt(dx01 * dx01 + dy01 * dy01);
var r12 = Math.sqrt(dx12 * dx12 + dy12 * dy12);
var r23 = Math.sqrt(dx23 * dx23 + dy23 * dy23);
if (Math.max(r01, r12, r23) < epsilon) {
return [{
x: x0,
y: y0
},
{
x: x1,
y: y1
},
{
x: x2,
y: y2
},
{
x: x3,
y: y3
}];
}
var x01 = (x0 + x1) * 0.5;
var y01 = (y0 + y1) * 0.5;
var x12 = (x1 + x2) * 0.5;
var y12 = (y1 + y2) * 0.5;
var x23 = (x2 + x3) * 0.5;
var y23 = (y2 + y3) * 0.5;
var x012 = (x01 + x12) * 0.5;
var y012 = (y01 + y12) * 0.5;
var x123 = (x12 + x23) * 0.5;
var y123 = (y12 + y23) * 0.5;
var x0123 = (x012 + x123) * 0.5;
var y0123 = (y012 + y123) * 0.5;
return partition_bezier4(x0, y0, x01, y01, x012, y012, x0123, y0123, epsilon).concat(partition_bezier4(x0123, y0123, x123, y123, x23, y23, x3, y3, epsilon));
}

View File

@@ -1,700 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
function CTextBody(shape) {
this.bodyPr = new CBodyPr();
this.bodyPr.setDefault();
this.lstStyle = null;
this.content = null;
this.contentWidth = 0;
this.contentHeight = 0;
this.styles = [];
this.recalcInfo = {};
this.Id = g_oIdCounter.Get_NewId();
g_oTableId.Add(this, this.Id);
if (isRealObject(shape)) {
this.setShape(shape);
this.setDocContent(new CDocumentContent(this, editor.WordControl.m_oLogicDocument.DrawingDocument, 0, 0, 0, 20000, false, false));
}
}
CTextBody.prototype = {
Get_Id: function () {
return this.Id;
},
Write_ToBinary2: function (w) {
w.WriteLong(historyitem_type_TextBody);
w.WriteString2(this.Id);
},
Read_FromBinary2: function (r) {
this.Id = r.GetString2();
},
Is_TopDocument: function () {
return false;
},
Is_HdrFtr: function () {
return false;
},
getType: function () {
return CLASS_TYPE_TEXT_BODY;
},
getObjectType: function () {
return CLASS_TYPE_TEXT_BODY;
},
setLstStyle: function (lstStyle) {
History.Add(this, {
Type: historyitem_SetLstStyle,
oldPr: this.lstStyle,
newPr: lstStyle
});
this.lstStyle = lstStyle;
},
setShape: function (shape) {
History.Add(this, {
Type: historyitem_SetShape,
oldPr: this.shape,
newPr: shape
});
this.shape = shape;
},
setDocContent: function (docContent) {
History.Add(this, {
Type: historyitem_SetDocContent,
oldPr: this.content,
newPr: docContent
});
this.content = docContent;
if (this.content && this.shape instanceof CChartTitle) {
var is_on = History.Is_On();
if (is_on) {
History.TurnOff();
}
var styles = new CStyles();
var default_legend_style = new CStyle("defaultLegendStyle", styles.Default, null, styletype_Paragraph);
var TextPr = {
FontFamily: {}
};
TextPr.FontFamily.Name = "Calibri";
TextPr.FontFamily.Index = -1;
TextPr.RFonts = {};
TextPr.RFonts.Ascii = {
Name: "Calibri",
Index: -1
};
TextPr.RFonts.EastAsia = {
Name: "Calibri",
Index: -1
};
TextPr.RFonts.HAnsi = {
Name: "Calibri",
Index: -1
};
TextPr.RFonts.CS = {
Name: "Calibri",
Index: -1
};
TextPr.Bold = true;
if (this.shape.getTitleType() === CHART_TITLE_TYPE_TITLE) {
TextPr.FontSize = 18;
} else {
TextPr.FontSize = 10;
}
default_legend_style.TextPr.Set_FromObject(TextPr);
default_legend_style.ParaPr.Spacing.After = 0;
default_legend_style.ParaPr.Spacing.Before = 0;
default_legend_style.ParaPr.Spacing.LineRule = linerule_AtLeast;
default_legend_style.ParaPr.Spacing.Line = 1;
default_legend_style.ParaPr.Jc = align_Center;
var tx_pr;
if (isRealObject(this.txPr)) {}
styles.Style[default_legend_style.Id] = default_legend_style;
this.content.Styles = styles;
this.content.Content[0].Style_Add_Open(default_legend_style.Id);
if (is_on) {
History.TurnOn();
}
}
},
Refresh_RecalcData: function () {
if (isRealObject(this.content)) {
if (this.shape instanceof CChartTitle) {
if (this.shape.chartGroup instanceof CChartAsGroup && this.shape.chartGroup.chart) {
this.shape.chartGroup.Refresh_RecalcData();
}
} else {
this.content.Recalculate_Page(0, true);
}
}
},
draw: function (graphics, pageIndex) {
if (!graphics.IsNoSupportTextDraw) {
if (typeof pageIndex === "number") {
var old_start_page = this.content.Get_StartPage_Relative();
this.content.Set_StartPage(pageIndex);
}
var result_page_index = typeof pageIndex === "number" ? pageIndex : this.shape.pageIndex;
this.content.Set_StartPage(result_page_index);
this.content.Draw(result_page_index, graphics);
if (typeof pageIndex === "number") {
this.content.Set_StartPage(old_start_page);
}
} else {
graphics.rect(0, 0, this.contentWidth, this.contentHeight);
}
},
Get_Styles: function (level) {
if (this.shape && typeof this.shape.getStyles === "function") {
return this.shape.getStyles();
}
return editor.WordControl.m_oLogicDocument.Get_Styles();
},
Get_Numbering: function () {
return new CNumbering();
},
isEmpty: function () {
return this.content.Is_Empty();
},
Get_TableStyleForPara: function () {
return null;
},
initFromString: function (str) {
for (var key in str) {
this.content.Paragraph_Add(new ParaText(str[key]), false);
}
},
Is_ThisElementCurrent: function () {
return false;
},
getColorMap: function () {
return this.shape.getColorMap();
},
getTheme: function () {
return this.shape.getTheme();
},
paragraphAdd: function (paraItem, noRecalc) {
this.content.Paragraph_Add(paraItem);
if (! (noRecalc === true)) {
this.content.Recalculate_Page(0, true);
}
this.content.RecalculateCurPos();
if (this.bodyPr.anchor !== VERTICAL_ANCHOR_TYPE_TOP) {
this.shape.calculateTransformTextMatrix();
}
},
addNewParagraph: function () {
this.content.Add_NewParagraph();
this.content.Recalculate_Page(0, true);
this.content.RecalculateCurPos();
if (this.bodyPr.anchor !== VERTICAL_ANCHOR_TYPE_TOP) {
this.shape.calculateTransformTextMatrix();
}
},
remove: function (direction, bOnlyText) {
this.content.Remove(direction, bOnlyText);
this.content.Recalculate_Page(0, true);
this.content.RecalculateCurPos();
if (this.bodyPr.anchor !== VERTICAL_ANCHOR_TYPE_TOP) {
this.shape.calculateTransformTextMatrix();
}
},
OnContentRecalculate: function () {
if (isRealObject(this.shape) && typeof this.shape.OnContentRecalculate === "function") {
this.shape.OnContentRecalculate();
}
},
recalculate: function () {},
getSummaryHeight: function () {
return this.content.Get_SummaryHeight();
},
getBodyPr: function () {
var res = new CBodyPr();
res.setDefault();
res.merge(this.bodyPr);
return res;
},
OnContentReDraw: function () {
if (isRealObject(this.shape)) {
this.shape.OnContentReDraw();
}
},
calculateContent: function () {
var _l, _t, _r, _b;
var _body_pr = this.getBodyPr();
var sp = this.shape;
if (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;
}
if (_body_pr.upright === false) {
var _content_width;
if (! (_body_pr.vert === nVertTTvert || _body_pr.vert === nVertTTvert270)) {
_content_width = _r - _l;
this.contentWidth = _content_width;
this.contentHeight = _b - _t;
} else {
_content_width = _b - _t;
this.contentWidth = _content_width;
this.contentHeight = _r - _l;
}
} else {
var _full_rotate = sp.getFullRotate();
if ((_full_rotate >= 0 && _full_rotate < Math.PI * 0.25) || (_full_rotate > 3 * Math.PI * 0.25 && _full_rotate < 5 * Math.PI * 0.25) || (_full_rotate > 7 * Math.PI * 0.25 && _full_rotate < 2 * Math.PI)) {
if (! (_body_pr.vert === nVertTTvert || _body_pr.vert === nVertTTvert270)) {
_content_width = _r - _l;
this.contentWidth = _content_width;
this.contentHeight = _b - _t;
} else {
_content_width = _b - _t;
this.contentWidth = _content_width;
this.contentHeight = _r - _l;
}
} else {
if (! (_body_pr.vert === nVertTTvert || _body_pr.vert === nVertTTvert270)) {
_content_width = _b - _t;
this.contentWidth = _content_width;
this.contentHeight = _r - _l;
} else {
_content_width = _r - _l;
this.contentWidth = _content_width;
this.contentHeight = _b - _t;
}
}
}
this.content.Reset(0, 0, _content_width, 20000);
this.content.Recalculate_Page(0, true);
},
OnEndRecalculate_Page: function () {},
Is_Cell: function () {
return false;
},
Get_StartPage_Absolute: function () {
return 0;
},
selectionSetStart: function (e, x, y) {
this.content.Selection_SetStart(x, y, 0, e);
},
selectionSetEnd: function (e, x, y) {
this.content.Selection_SetEnd(x, y, 0, e);
},
updateSelectionState: function () {
var Doc = this.content;
var DrawingDocument = editor.WordControl.m_oDrawingDocument;
if (true === Doc.Is_SelectionUse() && !Doc.Selection_IsEmpty()) {
DrawingDocument.UpdateTargetTransform(this.shape.transformText);
DrawingDocument.TargetEnd();
DrawingDocument.SelectEnabled(true);
DrawingDocument.SelectClear();
DrawingDocument.SelectShow();
} else {
editor.WordControl.m_oLogicDocument.RecalculateCurPos();
DrawingDocument.UpdateTargetTransform(this.shape.transformText);
DrawingDocument.TargetShow();
DrawingDocument.SelectEnabled(false);
}
},
Get_PageContentStartPos: function (pageNum) {
return {
X: 0,
Y: 0,
XLimit: this.contentWidth,
YLimit: 20000
};
},
setVerticalAlign: function (align) {
var anchor_num = null;
switch (align) {
case "top":
anchor_num = VERTICAL_ANCHOR_TYPE_TOP;
break;
case "center":
anchor_num = VERTICAL_ANCHOR_TYPE_CENTER;
break;
case "bottom":
anchor_num = VERTICAL_ANCHOR_TYPE_BOTTOM;
break;
}
if (isRealNumber(anchor_num)) {
this.bodyPr.anchor = anchor_num;
}
},
setVert: function (angle) {
var vert = null;
switch (angle) {
case 0:
vert = nVertTThorz;
break;
case 90:
vert = nVertTTvert270;
break;
case -90:
vert = nVertTTvert;
break;
}
if (isRealNumber(vert)) {
this.bodyPr.vert = vert;
}
},
setTopInset: function (ins) {
if (isRealNumber(ins)) {
this.bodyPr.tIns = ins;
}
},
setRightInset: function (ins) {
if (isRealNumber(ins)) {
this.bodyPr.rIns = ins;
}
},
setLeftInset: function (ins) {
if (isRealNumber(ins)) {
this.bodyPr.lIns = ins;
}
},
setBottomInset: function (ins) {
if (isRealNumber(ins)) {
this.bodyPr.bIns = ins;
}
},
setPaddings: function (paddings) {
if (isRealObject(paddings)) {
this.setBottomInset(paddings.Bottom);
this.setTopInset(paddings.Top);
this.setLeftInset(paddings.Left);
this.setRightInset(paddings.Right);
}
},
recalculateCurPos: function () {
this.content.RecalculateCurPos();
},
drawTextSelection: function () {
this.content.Selection_Draw_Page(0);
},
getRectWidth: function (maxWidth) {
try {
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;
} catch(e) {
return 0;
}
},
getRectHeight: function (maxHeight, width) {
try {
this.content.Reset(0, 0, width, 20000);
this.content.Recalculate_Page(0, true);
var content_height = this.getSummaryHeight();
var t_ins = isRealNumber(this.bodyPr.tIns) ? this.bodyPr.tIns : 1.27;
var b_ins = isRealNumber(this.bodyPr.bIns) ? this.bodyPr.bIns : 1.27;
return content_height + t_ins + b_ins;
} catch(e) {
return 0;
}
},
Refresh_RecalcData2: function () {
if (isRealObject(this.content)) {
if (this.shape instanceof CChartTitle) {
if (this.shape.chartGroup instanceof CChartAsGroup && this.shape.chartGroup.chart) {
this.shape.chartGroup.Refresh_RecalcData2();
}
} else {
this.content.Recalculate_Page(0, true);
}
}
},
Undo: function (data) {
switch (data.Type) {
case historyitem_SetShape:
this.shape = data.oldPr;
break;
case historyitem_SetDocContent:
this.content = data.oldPr;
if (this.content && this.shape instanceof CChartTitle) {
var is_on = History.Is_On();
if (is_on) {
History.TurnOff();
}
var styles = new CStyles();
var default_legend_style = new CStyle("defaultLegendStyle", styles.Default, null, styletype_Paragraph);
default_legend_style.TextPr.themeFont = "Calibri";
default_legend_style.TextPr.Bold = true;
if (this.shape.getTitleType() === CHART_TITLE_TYPE_TITLE) {
default_legend_style.TextPr.FontSize = 18;
} else {
default_legend_style.TextPr.FontSize = 10;
}
default_legend_style.ParaPr.Spacing.After = 0;
default_legend_style.ParaPr.Spacing.Before = 0;
default_legend_style.ParaPr.Spacing.LineRule = linerule_AtLeast;
default_legend_style.ParaPr.Spacing.Line = 1;
default_legend_style.ParaPr.Jc = align_Center;
var tx_pr;
if (isRealObject(this.txPr)) {}
styles.Style[styles.Id] = default_legend_style;
this.content.Styles = styles;
if (is_on) {
History.TurnOn();
}
}
break;
case historyitem_SetLstStyle:
this.lstStyle = data.oldPr;
break;
}
},
Redo: function (data) {
switch (data.Type) {
case historyitem_SetShape:
this.shape = data.newPr;
break;
case historyitem_SetDocContent:
this.content = data.newPr;
if (this.content && this.shape instanceof CChartTitle) {
var is_on = History.Is_On();
if (is_on) {
History.TurnOff();
}
var styles = new CStyles();
var default_legend_style = new CStyle("defaultLegendStyle", styles.Default, null, styletype_Paragraph);
default_legend_style.TextPr.themeFont = "Calibri";
default_legend_style.TextPr.Bold = true;
if (this.shape.getTitleType() === CHART_TITLE_TYPE_TITLE) {
default_legend_style.TextPr.FontSize = 18;
} else {
default_legend_style.TextPr.FontSize = 10;
}
default_legend_style.ParaPr.Spacing.After = 0;
default_legend_style.ParaPr.Spacing.Before = 0;
default_legend_style.ParaPr.Spacing.LineRule = linerule_AtLeast;
default_legend_style.ParaPr.Spacing.Line = 1;
default_legend_style.ParaPr.Jc = align_Center;
var tx_pr;
if (isRealObject(this.txPr)) {}
styles.Style[styles.Id] = default_legend_style;
this.content.Styles = styles;
if (is_on) {
History.TurnOn();
}
}
break;
case historyitem_SetLstStyle:
this.lstStyle = data.newPr;
break;
}
},
Save_Changes: function (data, w) {
w.WriteLong(historyitem_type_TextBody);
w.WriteLong(data.Type);
switch (data.Type) {
case historyitem_SetShape:
case historyitem_SetDocContent:
w.WriteBool(isRealObject(data.newPr));
if (isRealObject(data.newPr)) {
w.WriteString2(data.newPr.Get_Id());
}
break;
case historyitem_SetLstStyle:
w.WriteBool(isRealObject(data.newPr));
if (isRealObject(data.newPr)) {
data.newPr.Write_ToBinary2(w);
}
break;
}
},
Load_Changes: function (r) {
if (r.GetLong() === historyitem_type_TextBody) {
var type = r.GetLong();
switch (type) {
case historyitem_SetShape:
if (r.GetBool()) {
this.shape = g_oTableId.Get_ById(r.GetString2());
} else {
this.shape = null;
}
break;
case historyitem_SetDocContent:
if (r.GetBool()) {
this.content = g_oTableId.Get_ById(r.GetString2());
} else {
this.content = null;
}
if (this.content && this.shape instanceof CChartTitle) {
var is_on = History.Is_On();
if (is_on) {
History.TurnOff();
}
var styles = new CStyles();
var default_legend_style = new CStyle("defaultLegendStyle", styles.Default, null, styletype_Paragraph);
default_legend_style.TextPr.themeFont = "Calibri";
default_legend_style.TextPr.Bold = true;
if (this.shape.getTitleType() === CHART_TITLE_TYPE_TITLE) {
default_legend_style.TextPr.FontSize = 18;
} else {
default_legend_style.TextPr.FontSize = 10;
}
default_legend_style.ParaPr.Spacing.After = 0;
default_legend_style.ParaPr.Spacing.Before = 0;
default_legend_style.ParaPr.Spacing.LineRule = linerule_AtLeast;
default_legend_style.ParaPr.Spacing.Line = 1;
default_legend_style.ParaPr.Jc = align_Center;
var tx_pr;
if (isRealObject(this.txPr)) {}
styles.Style[styles.Id] = default_legend_style;
this.content.Styles = styles;
if (is_on) {
History.TurnOn();
}
}
break;
case historyitem_SetLstStyle:
if (r.GetBool()) {
this.lstStyle = new TextListStyle();
this.lstStyle.Read_FromBinary2(r);
} else {
this.lstStyle = null;
}
break;
}
}
},
writeToBinaryForCopyPaste: function (w) {
this.bodyPr.Write_ToBinary2(w);
},
readFromBinaryForCopyPaste: function (r, drawingDocument) {
this.bodyPr.Read_FromBinary2(r);
this.content = new CDocumentContent(this, drawingDocument, 0, 0, 0, 20000, false, false);
},
writeToBinary: function (w) {
this.bodyPr.Write_ToBinary2(w);
writeToBinaryDocContent(this.content, w);
},
createCopyDocContentForCopyPaste: function () {
var b_history_is_on = History.Is_On();
if (b_history_is_on) {
History.TurnOff();
}
var ret = this.content.Copy(this);
for (var i = 0; i < ret.Content.length; ++i) {
ret.Content[i].Style_Add_Open(null);
}
if (b_history_is_on) {
History.TurnOn();
}
return ret;
},
readFromBinary: function (r, drawingDocument) {
var bodyPr = new CBodyPr();
bodyPr.Read_FromBinary2(r);
if (isRealObject(this.parent) && this.parent.setBodyPr) {
this.parent.setBodyPr(bodyPr);
}
var is_on = History.Is_On();
if (is_on) {
History.TurnOff();
}
var dc = new CDocumentContent(this, editor.WordControl.m_oDrawingDocument, 0, 0, 0, 0, false, false);
readFromBinaryDocContent(dc, r);
if (is_on) {
History.TurnOn();
}
for (var i = 0; i < dc.Content.length; ++i) {
if (i > 0) {
this.content.Add_NewParagraph();
}
var par = dc.Content[i];
for (var j = 0; j < par.Content.length; ++j) {
if (! (par.Content[j] instanceof ParaEnd || par.Content[j] instanceof ParaEmpty || par.Content[j] instanceof ParaNumbering) && par.Content[j].Copy) {
this.content.Paragraph_Add(par.Content[j].Copy());
}
}
}
},
getDocContentForCopyPaste: function () {
var history_is_on = History.Is_On();
if (history_is_on) {
History.TurnOff();
}
var ret = this.content.Copy(this);
ret.Styles = this.content.Styles;
ret.Recalculate_Page(0, true);
ret.CurPos = this.content.CurPos;
ret.Selection = this.content.Selection;
for (var i = 0; i < ret.Content.length; ++i) {
var text_pr = ret.Content[i].Get_CompiledPr2().TextPr;
ret.Content[i].Style_Remove();
var start_pos = ret.Content[i].Internal_GetStartPos();
ret.Content[i].Internal_Content_Add(start_pos, new ParaTextPr(text_pr), true);
ret.Content[i].CurPos = this.content.Content[i].CurPos;
ret.Content[i].Selection = this.content.Content[i].Selection;
}
if (history_is_on) {
History.TurnOn();
}
return ret;
},
copyFromOther: function (txBody) {
if (isRealObject(this.parent) && this.parent.setBodyPr) {
this.parent.setBodyPr(this.bodyPr.createDuplicate());
}
for (var i = 0; i < txBody.content.Content.length; ++i) {
if (i > 0) {
this.content.Add_NewParagraph();
}
var par = txBody.content.Content[i];
for (var i = 0; i < par.Content.length; ++i) {
if (! (par.Content[i] instanceof ParaEnd || par.Content[i] instanceof ParaEmpty || par.Content[i] instanceof ParaNumbering) && par.Content[i].Copy) {
this.content.Paragraph_Add(par.Content[i].Copy());
}
}
}
for (var i = 0; i < this.content.Content.length; ++i) {
this.content.Content[i].Set_DocumentIndex(i);
}
}
};

View File

@@ -1,197 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
function PolyLine(document, pageIndex) {
this.document = document;
this.pageIndex = pageIndex;
this.arrPoint = [];
this.Matrix = new CMatrixL();
this.TransformMatrix = new CMatrixL();
this.style = CreateDefaultShapeStyle();
this.calculateLine = function () {
var _calculated_line;
var _theme = this.document.theme;
var colorMap = this.document.clrSchemeMap.color_map;
if (colorMap == null) {
colorMap = GenerateDefaultColorMap().color_map;
}
var RGBA = {
R: 0,
G: 0,
B: 0,
A: 255
};
if (_theme !== null && typeof _theme === "object" && typeof _theme.getLnStyle === "function" && this.style !== null && typeof this.style === "object" && this.style.lnRef !== null && typeof this.style.lnRef === "object" && typeof this.style.lnRef.idx === "number" && this.style.lnRef.Color !== null && typeof this.style.lnRef.Color.Calculate === "function") {
_calculated_line = _theme.getLnStyle(this.style.lnRef.idx);
this.style.lnRef.Color.Calculate(_theme, colorMap, {
R: 0,
G: 0,
B: 0,
A: 255
});
RGBA = this.style.lnRef.Color.RGBA;
} else {
_calculated_line = new CLn();
}
if (_calculated_line.Fill != null) {
_calculated_line.Fill.calculate(_theme, colorMap, RGBA);
}
this.pen = _calculated_line;
};
this.calculateLine();
this.Draw = function (graphics) {
graphics.SetIntegerGrid(false);
graphics.transform3(this.Matrix);
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape(this, graphics);
shape_drawer.draw(this);
};
this.draw = function (g) {
if (this.arrPoint.length < 2) {
return;
}
g._m(this.arrPoint[0].x, this.arrPoint[0].y);
for (var i = 1; i < this.arrPoint.length; ++i) {
g._l(this.arrPoint[i].x, this.arrPoint[i].y);
}
g.ds();
};
this.getLeftTopPoint = function () {
if (this.arrPoint.length < 1) {
return {
x: 0,
y: 0
};
}
var xMax = this.arrPoint[0].x,
yMax = this.arrPoint[0].y,
xMin = xMax,
yMin = yMax;
var i;
for (i = 1; i < this.arrPoint.length; ++i) {
if (this.arrPoint[i].x > xMax) {
xMax = this.arrPoint[i].x;
}
if (this.arrPoint[i].y > yMax) {
yMax = this.arrPoint[i].y;
}
if (this.arrPoint[i].x < xMin) {
xMin = this.arrPoint[i].x;
}
if (this.arrPoint[i].y < yMin) {
yMin = this.arrPoint[i].y;
}
}
return {
x: xMin,
y: yMin
};
};
this.createShape = function (document) {
var xMax = this.arrPoint[0].x,
yMax = this.arrPoint[0].y,
xMin = xMax,
yMin = yMax;
var i;
var bClosed = false;
if (this.arrPoint.length > 2) {
var dx = this.arrPoint[0].x - this.arrPoint[this.arrPoint.length - 1].x;
var dy = this.arrPoint[0].y - this.arrPoint[this.arrPoint.length - 1].y;
if (Math.sqrt(dx * dx + dy * dy) < this.document.DrawingDocument.GetMMPerDot(3)) {
bClosed = true;
}
}
var _n = bClosed ? this.arrPoint.length - 1 : this.arrPoint.length;
for (i = 1; i < _n; ++i) {
if (this.arrPoint[i].x > xMax) {
xMax = this.arrPoint[i].x;
}
if (this.arrPoint[i].y > yMax) {
yMax = this.arrPoint[i].y;
}
if (this.arrPoint[i].x < xMin) {
xMin = this.arrPoint[i].x;
}
if (this.arrPoint[i].y < yMin) {
yMin = this.arrPoint[i].y;
}
}
var wordGraphicObject = new ParaDrawing(null, null, null, document.DrawingDocument, null, document);
var wordShape = new WordShape(wordGraphicObject, document, document.DrawingDocument, null);
wordGraphicObject.Set_GraphicObject(wordShape);
wordShape.pageIndex = this.pageIndex;
wordShape.setAbsoluteTransform(xMin, yMin, xMax - xMin, yMax - yMin, 0, false, false);
wordShape.setXfrm(0, 0, xMax - xMin, yMax - yMin, 0, false, false);
wordShape.style = CreateDefaultShapeStyle();
var geometry = new CGeometry();
geometry.AddPathCommand(0, undefined, bClosed ? "norm" : "none", undefined, xMax - xMin, yMax - yMin);
geometry.AddRect("l", "t", "r", "b");
geometry.AddPathCommand(1, (this.arrPoint[0].x - xMin) + "", (this.arrPoint[0].y - yMin) + "");
for (i = 1; i < _n; ++i) {
geometry.AddPathCommand(2, (this.arrPoint[i].x - xMin) + "", (this.arrPoint[i].y - yMin) + "");
}
if (bClosed) {
geometry.AddPathCommand(6);
}
geometry.Init(xMax - xMin, yMax - yMin);
wordShape.spPr.geometry = geometry;
wordShape.calculate();
wordShape.calculateTransformMatrix();
wordGraphicObject.setZIndex();
wordGraphicObject.setPageIndex(this.pageIndex);
var data = {
Type: historyitem_CreatePolyine
};
data.xMax = xMax;
data.xMin = xMin;
data.yMax = yMax;
data.yMin = yMin;
data.bClosed = bClosed;
data.commands = [];
data.commands.push({
id: 1,
x: (this.arrPoint[0].x - xMin) + "",
y: (this.arrPoint[0].y - yMin) + ""
});
for (i = 1; i < _n; ++i) {
data.commands.push({
id: 2,
x: (this.arrPoint[i].x - xMin) + "",
y: (this.arrPoint[i].y - yMin) + ""
});
}
History.Add(wordShape, data);
History.Add(wordGraphicObject, {
Type: historyitem_CalculateAfterPaste
});
return wordGraphicObject;
};
}

View File

@@ -1,339 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
var K = 1 / 4;
var mt = 0,
lt = 1,
cb = 2,
cl = 3;
function SplineCommandMoveTo(x, y) {
this.id = 0;
this.x = x;
this.y = y;
}
function SplineCommandLineTo(x, y) {
this.id = 1;
this.x = x;
this.y = y;
this.changePoint = function (x, y) {
this.x = x;
this.y = y;
};
}
function SplineCommandBezier(x1, y1, x2, y2, x3, y3) {
this.id = 2;
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
this.x3 = x3;
this.y3 = y3;
this.changeLastPoint = function (x, y) {
this.x3 = x;
this.y3 = y;
this.x2 = this.x1 + (this.x3 - this.x1) * 0.5;
this.y2 = this.y1 + (this.y3 - this.y1) * 0.5;
};
}
function Spline(pageIndex, document) {
this.path = [];
this.pageIndex = pageIndex;
this.document = document;
this.Matrix = new CMatrix();
this.TransformMatrix = new CMatrix();
this.style = CreateDefaultShapeStyle();
this.calculateLine = function () {
var _calculated_line;
var _theme = this.document.theme;
var colorMap = this.document.clrSchemeMap.color_map;
if (colorMap == null) {
colorMap = GenerateDefaultColorMap().color_map;
}
var RGBA = {
R: 0,
G: 0,
B: 0,
A: 255
};
if (_theme !== null && typeof _theme === "object" && typeof _theme.getLnStyle === "function" && this.style !== null && typeof this.style === "object" && this.style.lnRef !== null && typeof this.style.lnRef === "object" && typeof this.style.lnRef.idx === "number" && this.style.lnRef.Color !== null && typeof this.style.lnRef.Color.Calculate === "function") {
_calculated_line = _theme.getLnStyle(this.style.lnRef.idx);
this.style.lnRef.Color.Calculate(_theme, colorMap, {
R: 0,
G: 0,
B: 0,
A: 255
});
RGBA = this.style.lnRef.Color.RGBA;
} else {
_calculated_line = new CLn();
}
if (_calculated_line.Fill != null) {
_calculated_line.Fill.calculate(_theme, colorMap, RGBA);
}
this.pen = _calculated_line;
};
this.pen = null;
this.calculateLine();
this.Draw = function (graphics) {
graphics.SetCurrentPage(this.pageIndex);
graphics.SetIntegerGrid(false);
graphics.transform3(this.Matrix);
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape(this, graphics);
shape_drawer.draw(this);
};
this.draw = function (g) {
for (var i = 0; i < this.path.length; ++i) {
var lastX, lastY;
switch (this.path[i].id) {
case 0:
g._m(this.path[i].x, this.path[i].y);
lastX = this.path[i].x;
lastY = this.path[i].y;
break;
case 1:
g._l(this.path[i].x, this.path[i].y);
lastX = this.path[i].x;
lastY = this.path[i].y;
break;
case 2:
g._c(this.path[i].x1, this.path[i].y1, this.path[i].x2, this.path[i].y2, this.path[i].x3, this.path[i].y3);
lastX = this.path[i].x3;
lastY = this.path[i].y3;
break;
}
}
g.ds();
};
this.getLeftTopPoint = function () {
if (this.path.length < 1) {
return {
x: 0,
y: 0
};
}
var min_x = this.path[0].x;
var max_x = min_x;
var min_y = this.path[0].y;
var max_y = min_y;
var last_x = this.path[0].x,
last_y = this.path[0].y;
for (var index = 1; index < this.path.length; ++index) {
var path_command = this.path[index];
if (path_command.id === 1) {
if (min_x > path_command.x) {
min_x = path_command.x;
}
if (max_x < path_command.x) {
max_x = path_command.x;
}
if (min_y > path_command.y) {
min_y = path_command.y;
}
if (max_y < path_command.y) {
max_y = path_command.y;
}
} else {
var bezier_polygon = partition_bezier4(last_x, last_y, path_command.x1, path_command.y1, path_command.x2, path_command.y2, path_command.x3, path_command.y3, APPROXIMATE_EPSILON);
for (var point_index = 1; point_index < bezier_polygon.length; ++point_index) {
var cur_point = bezier_polygon[point_index];
if (min_x > cur_point.x) {
min_x = cur_point.x;
}
if (max_x < cur_point.x) {
max_x = cur_point.x;
}
if (min_y > cur_point.y) {
min_y = cur_point.y;
}
if (max_y < cur_point.y) {
max_y = cur_point.y;
}
}
}
}
return {
x: min_x,
y: min_y
};
};
this.createShape = function (document) {
var xMax = this.path[0].x,
yMax = this.path[0].y,
xMin = xMax,
yMin = yMax;
var i;
var bClosed = false;
if (this.path.length > 2) {
var dx = this.path[0].x - this.path[this.path.length - 1].x3;
var dy = this.path[0].y - this.path[this.path.length - 1].y3;
if (Math.sqrt(dx * dx + dy * dy) < 3) {
bClosed = true;
this.path[this.path.length - 1].x3 = this.path[0].x;
this.path[this.path.length - 1].y3 = this.path[0].y;
if (this.path.length > 3) {
var vx = (this.path[1].x3 - this.path[this.path.length - 2].x3) / 6;
var vy = (this.path[1].y3 - this.path[this.path.length - 2].y3) / 6;
} else {
vx = -(this.path[1].y3 - this.path[0].y) / 6;
vy = (this.path[1].x3 - this.path[0].x) / 6;
}
this.path[1].x1 = this.path[0].x + vx;
this.path[1].y1 = this.path[0].y + vy;
this.path[this.path.length - 1].x2 = this.path[0].x - vx;
this.path[this.path.length - 1].y2 = this.path[0].y - vy;
}
}
var min_x = this.path[0].x;
var max_x = min_x;
var min_y = this.path[0].y;
var max_y = min_y;
var last_x = this.path[0].x,
last_y = this.path[0].y;
for (var index = 1; index < this.path.length; ++index) {
var path_command = this.path[index];
if (path_command.id === 1) {
if (min_x > path_command.x) {
min_x = path_command.x;
}
if (max_x < path_command.x) {
max_x = path_command.x;
}
if (min_y > path_command.y) {
min_y = path_command.y;
}
if (max_y < path_command.y) {
max_y = path_command.y;
}
last_x = path_command.x;
last_y = path_command.y;
} else {
var bezier_polygon = partition_bezier4(last_x, last_y, path_command.x1, path_command.y1, path_command.x2, path_command.y2, path_command.x3, path_command.y3, APPROXIMATE_EPSILON);
for (var point_index = 1; point_index < bezier_polygon.length; ++point_index) {
var cur_point = bezier_polygon[point_index];
if (min_x > cur_point.x) {
min_x = cur_point.x;
}
if (max_x < cur_point.x) {
max_x = cur_point.x;
}
if (min_y > cur_point.y) {
min_y = cur_point.y;
}
if (max_y < cur_point.y) {
max_y = cur_point.y;
}
last_x = path_command.x3;
last_y = path_command.y3;
}
}
}
xMin = min_x;
xMax = max_x;
yMin = min_y;
yMax = max_y;
var wordGraphicObject = new ParaDrawing(null, null, null, document.DrawingDocument, null, document);
var wordShape = new WordShape(wordGraphicObject, document, document.DrawingDocument, null);
wordGraphicObject.Set_GraphicObject(wordShape);
wordShape.pageIndex = this.pageIndex;
wordShape.setAbsoluteTransform(xMin, yMin, xMax - xMin, yMax - yMin, 0, false, false);
wordShape.setXfrm(0, 0, xMax - xMin, yMax - yMin, 0, false, false);
wordShape.style = CreateDefaultShapeStyle();
var geometry = new CGeometry();
geometry.AddPathCommand(0, undefined, bClosed ? "norm" : "none", undefined, xMax - xMin, yMax - yMin);
geometry.AddRect("l", "t", "r", "b");
for (i = 0; i < this.path.length; ++i) {
switch (this.path[i].id) {
case 0:
geometry.AddPathCommand(1, (this.path[i].x - xMin) + "", (this.path[i].y - yMin) + "");
break;
case 1:
geometry.AddPathCommand(2, (this.path[i].x - xMin) + "", (this.path[i].y - yMin) + "");
break;
case 2:
geometry.AddPathCommand(5, (this.path[i].x1 - xMin) + "", (this.path[i].y1 - yMin) + "", (this.path[i].x2 - xMin) + "", (this.path[i].y2 - yMin) + "", (this.path[i].x3 - xMin) + "", (this.path[i].y3 - yMin) + "");
break;
}
}
if (bClosed) {
geometry.AddPathCommand(6);
}
geometry.Init(xMax - xMin, yMax - yMin);
wordShape.spPr.geometry = geometry;
wordShape.calculate();
wordShape.calculateTransformMatrix();
wordGraphicObject.setZIndex();
wordGraphicObject.setPageIndex(this.pageIndex);
var data = {
Type: historyitem_CreatePolyine
};
data.xMax = xMax;
data.xMin = xMin;
data.yMax = yMax;
data.yMin = yMin;
data.bClosed = bClosed;
data.commands = [];
for (i = 0; i < this.path.length; ++i) {
switch (this.path[i].id) {
case 0:
data.commands.push({
id: 1,
x: (this.path[i].x - xMin) + "",
y: (this.path[i].y - yMin) + ""
});
break;
case 1:
data.commands.push({
id: 2,
x: (this.path[i].x - xMin) + "",
y: (this.path[i].y - yMin) + ""
});
break;
case 2:
data.commands.push({
id: 5,
x0: (this.path[i].x1 - xMin) + "",
y0: (this.path[i].y1 - yMin) + "",
x1: (this.path[i].x2 - xMin) + "",
y1: (this.path[i].y2 - yMin) + "",
x2: (this.path[i].x3 - xMin) + "",
y2: (this.path[i].y3 - yMin) + ""
});
break;
}
}
History.Add(wordShape, data);
History.Add(wordGraphicObject, {
Type: historyitem_CalculateAfterPaste
});
return wordGraphicObject;
};
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,902 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
function CTrackPolarAdjObject(originalShape, adjIndex, pageIndex) {
this.originalShape = originalShape;
this.adjIndex = adjIndex;
this.pageIndex = pageIndex;
this.transformMatrix = originalShape.transformMatrix;
this.geometry = originalShape.spPr.geometry.createDuplicate();
this.adjastment = this.geometry.ahPolarLst[adjIndex];
this.shapeWidth = this.originalShape.absExtX;
this.shapeHeight = this.originalShape.absExtY;
this.shapeCentrX = this.shapeWidth * 0.5;
this.shapeCentrY = this.shapeHeight * 0.5;
this.flipH = this.originalShape.absFlipH;
this.flipV = this.originalShape.absFlipV;
this.sin = Math.sin(this.originalShape.absRot);
this.cos = Math.cos(this.originalShape.absRot);
this.xLT = -this.shapeCentrX * this.cos + this.shapeCentrY * this.sin + this.originalShape.absOffsetX + this.shapeCentrX;
this.yLT = -this.shapeCentrX * this.sin - this.shapeCentrY * this.cos + this.originalShape.absOffsetY + this.shapeCentrY;
this.radiusFlag = false;
this.angleFlag = false;
this.refR = null;
this.refAng = null;
if (this.adjastment !== null && typeof this.adjastment === "object") {
var _ref_r = this.adjastment.gdRefR;
var _gd_lst = this.geometry.gdLst;
if (typeof _ref_r === "string" && typeof _gd_lst[_ref_r] === "number" && typeof this.adjastment.minR === "number" && typeof this.adjastment.maxR === "number") {
_gd_lst[_ref_r] = this.adjastment.minR;
this.geometry.Recalculate(this.shapeWidth, this.shapeHeight);
var _dx = this.adjastment.posX - this.shapeCentrX;
var _dy = this.adjastment.posY - this.shapeCentrY;
this.minRealR = Math.sqrt(_dx * _dx + _dy * _dy);
_gd_lst[_ref_r] = this.adjastment.maxR;
this.geometry.Recalculate(this.shapeWidth, this.shapeHeight);
_dx = this.adjastment.posX - this.shapeCentrX;
_dy = this.adjastment.posY - this.shapeCentrY;
this.maxRealR = Math.sqrt(_dx * _dx + _dy * _dy);
this.maximalRealRadius = Math.max(this.maxRealR, this.minRealR);
this.minimalRealRadius = Math.min(this.maxRealR, this.minRealR);
this.minimalRealativeRadius = Math.min(this.adjastment.minR, this.adjastment.maxR);
this.maximalRealativeRadius = Math.max(this.adjastment.minR, this.adjastment.maxR);
if (this.maximalRealRadius - this.minimalRealRadius > 0) {
this.coeffR = (this.adjastment.maxR - this.adjastment.minR) / (this.maxRealR - this.minRealR);
this.radiusFlag = true;
}
}
var _ref_ang = this.adjastment.gdRefAng;
if (typeof _ref_ang === "string" && typeof _gd_lst[_ref_ang] === "number" && typeof this.adjastment.minAng === "number" && typeof this.adjastment.maxAng === "number") {
this.angleFlag = true;
this.minimalAngle = Math.min(this.adjastment.minAng, this.adjastment.maxAng);
this.maximalAngle = Math.max(this.adjastment.minAng, this.adjastment.maxAng);
}
if (this.radiusFlag) {
this.refR = _ref_r;
}
if (this.angleFlag) {
this.refAng = _ref_ang;
}
}
this.objectForOverlay = new ObjectForShapeDrawer(this.geometry, this.originalShape.absExtX, this.originalShape.absExtY, this.originalShape.brush, this.originalShape.pen, this.originalShape.transform);
this.draw = function (overlay) {
overlay.SetCurrentPage(this.pageIndex);
overlay.transform3(this.originalShape.transform);
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape2(this.objectForOverlay, overlay, this.geometry);
shape_drawer.draw(this.geometry);
};
this.getBounds = function () {
var bounds_checker = new CSlideBoundsChecker();
bounds_checker.init(Page_Width, Page_Height, Page_Width, Page_Height);
this.draw(bounds_checker);
return {
l: bounds_checker.Bounds.min_x,
t: bounds_checker.Bounds.min_y,
r: bounds_checker.Bounds.max_x,
b: bounds_checker.Bounds.max_y
};
};
this.track = function (posX, posY) {
var _temp_x = posX - this.xLT;
var _temp_y = posY - this.yLT;
var _sin = this.sin;
var _cos = this.cos;
var _relative_x = _temp_x * _cos + _temp_y * _sin;
var _relative_y = -_temp_x * _sin + _temp_y * _cos;
if (this.flipH) {
_relative_x = this.shapeWidth - _relative_x;
}
if (this.flipV) {
_relative_y = this.shapeHeight - _relative_y;
}
var _pos_x_relative_center = _relative_x - this.shapeCentrX;
var _pos_y_relative_center = _relative_y - this.shapeCentrY;
var bRecalculate = false;
if (this.radiusFlag) {
var _radius = Math.sqrt(_pos_x_relative_center * _pos_x_relative_center + _pos_y_relative_center * _pos_y_relative_center);
var _new_radius = this.adjastment.minR + this.coeffR * (_radius - this.minRealR);
if (_new_radius <= this.maximalRealativeRadius && _new_radius >= this.minimalRealativeRadius) {
this.geometry.gdLst[this.adjastment.gdRefR] = _new_radius;
} else {
if (_new_radius > this.maximalRealativeRadius) {
this.geometry.gdLst[this.adjastment.gdRefR] = this.maximalRealativeRadius;
} else {
this.geometry.gdLst[this.adjastment.gdRefR] = this.minimalRealativeRadius;
}
}
}
if (this.angleFlag) {
var _angle = Math.atan2(_pos_y_relative_center, _pos_x_relative_center);
while (_angle < 0) {
_angle += 2 * Math.PI;
}
while (_angle >= 2 * Math.PI) {
_angle -= 2 * Math.PI;
}
_angle *= cToDeg;
if (_angle >= this.minimalAngle && _angle <= this.maximalAngle) {
this.geometry.gdLst[this.adjastment.gdRefAng] = _angle;
} else {
if (_angle >= this.maximalAngle) {
this.geometry.gdLst[this.adjastment.gdRefAng] = this.maximalAngle;
} else {
if (_angle <= this.minimalAngle) {
this.geometry.gdLst[this.adjastment.gdRefAng] = this.minimalAngle;
}
}
}
}
this.geometry.Recalculate(this.shapeWidth, this.shapeHeight);
};
this.trackEnd = function () {
this.originalShape.setAdjustmentValue(this.refR, this.geometry.gdLst[this.adjastment.gdRefR], this.refAng, this.geometry.gdLst[this.adjastment.gdRefAng]);
};
}
function CTrackXYAdjObject(originalShape, adjIndex, pageIndex) {
this.originalShape = originalShape;
this.adjIndex = adjIndex;
this.pageIndex = pageIndex;
this.transformMatrix = originalShape.transformMatrix;
this.geometry = originalShape.spPr.geometry.createDuplicate();
this.adjastment = this.geometry.ahXYLst[adjIndex];
this.shapeWidth = this.originalShape.absExtX;
this.shapeHeight = this.originalShape.absExtY;
this.shapeCentrX = this.shapeWidth * 0.5;
this.shapeCentrY = this.shapeHeight * 0.5;
this.flipH = this.originalShape.absFlipH;
this.flipV = this.originalShape.absFlipV;
this.sin = Math.sin(this.originalShape.absRot);
this.cos = Math.cos(this.originalShape.absRot);
this.xLT = -this.shapeCentrX * this.cos + this.shapeCentrY * this.sin + this.originalShape.absOffsetX + this.shapeCentrX;
this.yLT = -this.shapeCentrX * this.sin - this.shapeCentrY * this.cos + this.originalShape.absOffsetY + this.shapeCentrY;
this.xFlag = false;
this.yFlag = false;
this.refX = null;
this.refY = null;
if (this.adjastment !== null && typeof this.adjastment === "object") {
var _ref_x = this.adjastment.gdRefX;
var _gd_lst = this.geometry.gdLst;
if (typeof _ref_x === "string" && typeof _gd_lst[_ref_x] === "number" && typeof this.adjastment.minX === "number" && typeof this.adjastment.maxX === "number") {
_gd_lst[_ref_x] = this.adjastment.minX;
this.geometry.Recalculate(this.shapeWidth, this.shapeHeight);
this.minRealX = this.adjastment.posX;
_gd_lst[_ref_x] = this.adjastment.maxX;
this.geometry.Recalculate(this.shapeWidth, this.shapeHeight);
this.maxRealX = this.adjastment.posX;
this.maximalRealX = Math.max(this.maxRealX, this.minRealX);
this.minimalRealX = Math.min(this.maxRealX, this.minRealX);
this.minimalRealativeX = Math.min(this.adjastment.minX, this.adjastment.maxX);
this.maximalRealativeX = Math.max(this.adjastment.minX, this.adjastment.maxX);
if (this.maximalRealX - this.minimalRealX > 0) {
this.coeffX = (this.adjastment.maxX - this.adjastment.minX) / (this.maxRealX - this.minRealX);
this.xFlag = true;
}
}
var _ref_y = this.adjastment.gdRefY;
if (typeof _ref_y === "string" && typeof _gd_lst[_ref_y] === "number" && typeof this.adjastment.minY === "number" && typeof this.adjastment.maxY === "number") {
_gd_lst[_ref_y] = this.adjastment.minY;
this.geometry.Recalculate(this.shapeWidth, this.shapeHeight);
this.minRealY = this.adjastment.posY;
_gd_lst[_ref_y] = this.adjastment.maxY;
this.geometry.Recalculate(this.shapeWidth, this.shapeHeight);
this.maxRealY = this.adjastment.posY;
this.maximalRealY = Math.max(this.maxRealY, this.minRealY);
this.minimalRealY = Math.min(this.maxRealY, this.minRealY);
this.minimalRealativeY = Math.min(this.adjastment.minY, this.adjastment.maxY);
this.maximalRealativeY = Math.max(this.adjastment.minY, this.adjastment.maxY);
if (this.maximalRealY - this.minimalRealY > 0) {
this.coeffY = (this.adjastment.maxY - this.adjastment.minY) / (this.maxRealY - this.minRealY);
this.yFlag = true;
}
}
if (this.xFlag) {
this.refX = _ref_x;
}
if (this.yFlag) {
this.refY = _ref_y;
}
}
this.objectForOverlay = new ObjectForShapeDrawer(this.geometry, this.originalShape.absExtX, this.originalShape.absExtY, this.originalShape.brush, this.originalShape.pen, this.originalShape.transform);
this.draw = function (overlay) {
overlay.SetCurrentPage(this.pageIndex);
overlay.transform3(this.originalShape.transform);
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape2(this.objectForOverlay, overlay, this.geometry);
shape_drawer.draw(this.geometry);
};
this.getBounds = function () {
var bounds_checker = new CSlideBoundsChecker();
bounds_checker.init(Page_Width, Page_Height, Page_Width, Page_Height);
this.draw(bounds_checker);
return {
l: bounds_checker.Bounds.min_x,
t: bounds_checker.Bounds.min_y,
r: bounds_checker.Bounds.max_x,
b: bounds_checker.Bounds.max_y
};
};
this.track = function (posX, posY) {
var _temp_x = posX - this.xLT;
var _temp_y = posY - this.yLT;
var _sin = this.sin;
var _cos = this.cos;
var _relative_x = _temp_x * _cos + _temp_y * _sin;
var _relative_y = -_temp_x * _sin + _temp_y * _cos;
if (this.flipH) {
_relative_x = this.shapeWidth - _relative_x;
}
if (this.flipV) {
_relative_y = this.shapeHeight - _relative_y;
}
var bRecalculate = false;
if (this.xFlag) {
var _new_x = this.adjastment.minX + this.coeffX * (_relative_x - this.minRealX);
if (_new_x <= this.maximalRealativeX && _new_x >= this.minimalRealativeX) {
if (this.geometry.gdLst[this.adjastment.gdRefX] !== _new_x) {
bRecalculate = true;
}
this.geometry.gdLst[this.adjastment.gdRefX] = _new_x;
} else {
if (_new_x > this.maximalRealativeX) {
if (this.geometry.gdLst[this.adjastment.gdRefX] !== this.maximalRealativeX) {
bRecalculate = true;
}
this.geometry.gdLst[this.adjastment.gdRefX] = this.maximalRealativeX;
} else {
if (this.geometry.gdLst[this.adjastment.gdRefX] !== this.minimalRealativeX) {
bRecalculate = true;
}
this.geometry.gdLst[this.adjastment.gdRefX] = this.minimalRealativeX;
}
}
}
if (this.yFlag) {
var _new_y = this.adjastment.minY + this.coeffY * (_relative_y - this.minRealY);
if (_new_y <= this.maximalRealativeY && _new_y >= this.minimalRealativeY) {
if (this.geometry.gdLst[this.adjastment.gdRefY] !== _new_y) {
bRecalculate = true;
}
this.geometry.gdLst[this.adjastment.gdRefY] = _new_y;
} else {
if (_new_y > this.maximalRealativeY) {
if (this.geometry.gdLst[this.adjastment.gdRefY] !== this.maximalRealativeY) {
bRecalculate = true;
}
this.geometry.gdLst[this.adjastment.gdRefY] = this.maximalRealativeY;
} else {
if (this.geometry.gdLst[this.adjastment.gdRefY] !== this.minimalRealativeY) {
bRecalculate = true;
}
this.geometry.gdLst[this.adjastment.gdRefY] = this.minimalRealativeY;
}
}
}
if (bRecalculate) {
this.geometry.Recalculate(this.shapeWidth, this.shapeHeight);
}
};
this.trackEnd = function () {
this.originalShape.setAdjustmentValue(this.refX, this.geometry.gdLst[this.adjastment.gdRefX], this.refY, this.geometry.gdLst[this.adjastment.gdRefY]);
};
}
function CTrackHandleObject(originalGraphicObject, cardDirection, pageIndex) {
this.originalGraphicObject = originalGraphicObject;
this.cardDirection = cardDirection;
this.pageIndex = pageIndex;
this.init = function () {
this.handleNum = this.originalGraphicObject.cardDirectionToNumber(this.cardDirection);
this.trackGraphicObject = this.originalGraphicObject.createTrackObjectForResize(this.handleNum, this.pageIndex);
};
this.track = function (kd1, kd2, event) {
if (!event.CtrlKey) {
this.trackGraphicObject.resize(kd1, kd2, event.ShiftKey);
} else {
this.trackGraphicObject.resizeRelativeCenter(kd1, kd2, event.ShiftKey);
}
};
this.getBounds = function () {
return this.trackGraphicObject.getBounds();
};
this.getBoundsRect = function () {
return this.trackGraphicObject.getBoundsRect();
};
this.draw = function (graphics) {
this.trackGraphicObject.draw(graphics);
};
this.trackEnd = function () {
this.trackGraphicObject.endTrack();
};
}
function CTrackRotateObject(graphicObject, pageIndex) {
this.originalGraphicObject = graphicObject;
this.trackObject = null;
this.pageIndex = pageIndex;
this.init = function () {
this.trackObject = this.originalGraphicObject.createTrackObjectForRotate(this.pageIndex);
};
this.modify = function (angle, shiftKey) {
this.trackObject.track(angle, shiftKey);
};
this.draw = function (overlay) {
this.trackObject.draw(overlay);
};
this.getBounds = function () {
return this.trackObject.getBounds();
};
this.getBoundsRect = function () {
return this.trackObject.getBoundsRect();
};
this.trackEnd = function () {
this.trackObject.trackEnd();
};
}
function CTrackMoveObject(originalGraphicObject, majorOffsetX, majorOffsetY, graphicObjects, startPageIndex) {
this.originalGraphicObject = originalGraphicObject;
this.majorOffsetX = majorOffsetX;
this.majorOffsetY = majorOffsetY;
this.graphicObjects = graphicObjects;
this.curPageIndex = startPageIndex;
this.trackGraphicObject = null;
this.init = function () {
this.trackGraphicObject = this.originalGraphicObject.createTrackObjectForMove(this.majorOffsetX, this.majorOffsetY);
};
this.track = function (x, y, pageIndex) {
this.curPageIndex = pageIndex;
this.trackGraphicObject.track(x, y, pageIndex);
};
this.draw = function (overlay) {
overlay.SetCurrentPage(this.curPageIndex);
this.trackGraphicObject.draw(overlay);
};
this.getBounds = function () {
return this.trackGraphicObject.getBounds();
};
this.getBoundsRect = function () {
return this.trackGraphicObject.getBoundsRect();
};
this.trackEnd = function (e, pageIndex) {
this.trackGraphicObject.trackEnd(e, true);
if (e.CtrlKey && isRealObject(this.trackGraphicObject.originalShape)) {
this.originalGraphicObject = this.trackGraphicObject.originalShape.parent;
} else {
if (e.CtrlKey && isRealObject(this.trackGraphicObject.original)) {
this.originalGraphicObject = this.trackGraphicObject.original.parent;
}
}
if (this.originalGraphicObject.selected) {
this.originalGraphicObject.select(pageIndex);
}
};
}
function CTrackNewObject(shape, isLinePreset, startX, startY, pageShapes, pageIndex) {
this.originalShape = shape;
this.isLinePreset = isLinePreset;
this.startPosX = startX;
this.startPosY = startY;
this.pageShapes = pageShapes;
this.pageIndex = pageIndex;
this.trackShape = null;
this.init = function () {
this.trackShape = new NewTrackShape(this.originalShape, this.startPosX, this.startPosY, this.isLinePreset, this.pageShapes, this.pageIndex);
};
this.draw = function (overlay) {
this.trackShape.draw(overlay);
};
this.modify = function (x, y, ctrlKey, shiftKey) {
this.trackShape.modify(x, y, ctrlKey, shiftKey);
};
this.endTrack = function () {
this.trackShape.endTrack();
};
this.getBounds = function () {
return this.trackShape.getBounds();
};
}
function CTrackNewObject2(presetGeom, pen, brush, startX, startY, pageIndex) {
this.presetGeom = presetGeom;
this.startPosX = startX;
this.startPosY = startY;
this.pageIndex = pageIndex;
this.geometry = null;
this.checkLine = CheckLinePreset(presetGeom);
this.objectForOverlay = null;
this.pen = pen;
this.brush = brush;
this.flipH = null;
this.flipV = null;
this.posX = null;
this.posY = null;
this.absExtX = null;
this.absExtY = null;
this.transformMatrix = null;
this.presetGeom = presetGeom;
this.propCoefficient = typeof SHAPE_ASPECTS[presetGeom] === "number" ? SHAPE_ASPECTS[presetGeom] : 1;
this.invPropCoefficient = 1 / this.propCoefficient;
this.init = function (x, y) {
if (this.startX < x) {
this.posX = this.startPosX;
if (x - this.startX > MIN_SHAPE_SIZE || this.checkLine) {
this.absExtX = x - this.startX;
} else {
this.absExtX = MIN_SHAPE_SIZE;
}
this.flipH = false;
} else {
if (this.startX - x > MIN_SHAPE_SIZE || this.checkLine) {
this.absExtX = this.startX - x;
} else {
this.absExtX = MIN_SHAPE_SIZE;
}
this.posX = this.startX - this.absExtX;
this.flipH = this.checkLine;
}
if (this.startY < y) {
this.posY = this.startPosY;
if (y - this.startY > MIN_SHAPE_SIZE || this.checkLine) {
this.absExtY = y - this.startY;
} else {
this.absExtY = MIN_SHAPE_SIZE;
}
this.flipV = false;
} else {
if (this.startY - y > MIN_SHAPE_SIZE || this.checkLine) {
this.absExtY = this.startY - y;
} else {
this.absExtY = MIN_SHAPE_SIZE;
}
this.posY = this.startY - this.absExtY;
this.flipV = this.checkLine;
}
this.geometry = CreateGeometry(this.presetGeom);
this.geometry.Init(this.absExtX, this.absExtY);
this.transformMatrix = new CMatrix();
this.calculateTransform();
this.objectForOverlay = new ObjectForShapeDrawer(this.geometry, this.absExtX, this.absExtY, this.brush, this.pen, this.transformMatrix);
};
this.modify = function (x, y, ctrlKey, shiftKey) {
var _finished_x = x,
_finished_y = y;
var _real_dist_x = _finished_x - this.startPosX;
var _abs_dist_x = Math.abs(_real_dist_x);
var _real_dist_y = _finished_y - this.startPosY;
var _abs_dist_y = Math.abs(_real_dist_y);
if ((!ctrlKey && !shiftKey) || (this.checkLine && !shiftKey)) {
if (_real_dist_x >= 0) {
this.posX = this.startPosX;
this.flipH = false;
} else {
this.posX = _abs_dist_x >= MIN_SHAPE_SIZE || this.checkLine ? x : this.startPosX - MIN_SHAPE_SIZE;
if (this.checkLine) {
this.flipH = true;
}
}
if (_real_dist_y >= 0) {
this.posY = this.startPosY;
this.flipV = false;
} else {
this.posY = _abs_dist_y >= MIN_SHAPE_SIZE || this.checkLine ? y : this.startPosY - MIN_SHAPE_SIZE;
if (this.checkLine) {
this.flipV = true;
}
}
this.absExtX = _abs_dist_x >= MIN_SHAPE_SIZE || this.checkLine ? _abs_dist_x : MIN_SHAPE_SIZE;
this.absExtY = _abs_dist_y >= MIN_SHAPE_SIZE || this.checkLine ? _abs_dist_y : MIN_SHAPE_SIZE;
this.geometry.Recalculate(this.absExtX, this.absExtY);
} else {
if (ctrlKey && !shiftKey) {
if (_abs_dist_x >= MIN_SHAPE_SIZE_DIV2) {
this.posX = this.startPosX - _abs_dist_x;
this.absExtX = 2 * _abs_dist_x;
} else {
this.posX = this.startPosX - MIN_SHAPE_SIZE_DIV2;
this.absExtX = MIN_SHAPE_SIZE;
}
if (_abs_dist_y >= MIN_SHAPE_SIZE_DIV2) {
this.posY = this.startPosY - _abs_dist_y;
this.absExtY = 2 * _abs_dist_y;
} else {
this.posY = this.startPosY - MIN_SHAPE_SIZE_DIV2;
this.absExtY = MIN_SHAPE_SIZE;
}
this.geometry.Recalculate(this.absExtX, this.absExtY);
} else {
if (!ctrlKey && shiftKey) {
var _new_aspect;
var _new_width, _new_height;
if (this.checkLine) {} else {
_new_aspect = _abs_dist_x / _abs_dist_y;
if (_new_aspect >= this.propCoefficient) {
_new_width = _abs_dist_x;
_new_height = _abs_dist_x * this.invPropCoefficient;
} else {
_new_height = _real_dist_y;
_new_width = _real_dist_y * this.propCoefficient;
}
this.absExtX = _new_width;
this.absExtY = _new_height;
if (_real_dist_x >= 0) {
this.posX = this.startPosX;
} else {
this.posX = this.startPosX - this.absExtX;
}
if (_real_dist_y >= 0) {
this.posY = this.startPosY;
} else {
this.posY = this.startPosY - this.absExtY;
}
}
this.geometry.Recalculate(this.absExtX, this.absExtY);
} else {
if (ctrlKey && shiftKey) {}
}
}
}
this.extX = this.absExtX;
this.extY = this.absExtY;
this.calculateTransform();
};
this.calculateTransform = function () {
var _new_transform = this.transformMatrix;
_new_transform.Reset();
if (this.flipH || this.flipV) {
var _horizontal_center = this.absExtX * 0.5;
var _vertical_center = this.absExtY * 0.5;
_new_transform.Translate(-_horizontal_center, -_vertical_center, MATRIX_ORDER_APPEND);
if (this.flipH) {
global_MatrixTransformer.ScaleAppend(_new_transform, -1, 1);
}
if (this.flipV) {
global_MatrixTransformer.ScaleAppend(_new_transform, 1, -1);
}
_new_transform.Translate(_horizontal_center, _vertical_center, MATRIX_ORDER_APPEND);
}
_new_transform.Translate(this.posX, this.posY, MATRIX_ORDER_APPEND);
this.transformMatrix = _new_transform;
};
this.endTrack = function () {};
this.draw = function (overlay) {
overlay.SetCurrentPage(this.pageIndex);
overlay.transform3(this.transformMatrix);
this.objectForOverlay.updateTransform(this.absExtX, this.absExtY, this.transformMatrix);
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape2(this.objectForOverlay, overlay, this.geometry);
shape_drawer.draw(this.geometry);
};
this.getBounds = function () {
var bounds_checker = new CSlideBoundsChecker();
bounds_checker.init(Page_Width, Page_Height, Page_Width, Page_Height);
this.draw(bounds_checker);
return {
l: bounds_checker.Bounds.min_x,
t: bounds_checker.Bounds.min_y,
r: bounds_checker.Bounds.max_x,
b: bounds_checker.Bounds.max_y
};
};
}
function CTrackMoveObjectInGroup(originalObject, majorOffsetX, majorOffsetY) {
this.originalObject = originalObject;
this.majorOffsetX = -majorOffsetX;
this.majorOffsetY = -majorOffsetY;
this.trackObject = null;
this.init = function () {
this.trackObject = this.originalObject.createTrackObjectForMoveInGroup(this.majorOffsetX, this.majorOffsetY);
};
this.track = function (posX, posY) {
this.trackObject.track(posX, posY);
};
this.draw = function (overlay) {
this.trackObject.draw(overlay);
};
this.trackEnd = function () {
this.trackObject.trackEnd();
};
this.getBounds = function () {
return this.trackObject.getBounds();
};
}
function MoveTrackInGroup(original) {
this.original = original;
var xfrm = original.spPr.xfrm;
this.x = xfrm.absExtX;
this.y = xfrm.absExtY;
this.startX = xfrm.offX;
this.startY = xfrm.offY;
this.transform = original.transform.CreateDublicate();
this.geometry = original.spPr.geometry;
if (typeof CChartAsGroup != "undefined" && original instanceof CChartAsGroup) {
var brush = new CUniFill();
brush.fill = new CSolidFill();
brush.fill.color = new CUniColor();
brush.fill.color.RGBA = {
R: 255,
G: 255,
B: 255,
A: 255
};
brush.fill.color.color = new CRGBColor();
brush.fill.color.color.RGBA = {
R: 255,
G: 255,
B: 255,
A: 255
};
var pen = new CLn();
pen.Fill = new CUniFill();
pen.Fill.fill = new CSolidFill();
pen.Fill.fill.color = new CUniColor();
pen.Fill.fill.color.color = new CRGBColor();
this.pen = pen;
this.brush = brush;
} else {
this.pen = original.pen;
this.brush = original.brush;
}
this.objectForOverlay = new ObjectForShapeDrawer(this.geometry, xfrm.absExtX, xfrm.absExtY, this.brush, this.pen, this.transform);
this.inv = global_MatrixTransformer.Invert(original.group.transform);
this.draw = function (overlay) {
overlay.SetCurrentPage(this.original.pageIndex);
overlay.transform3(this.transform);
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape2(this.objectForOverlay, overlay, this.geometry);
shape_drawer.draw(this.geometry);
};
this.track = function (stX, stY, x, y) {
var st_x_t = this.inv.TransformPointX(stX, stY);
var st_y_t = this.inv.TransformPointY(stX, stY);
var x_t = this.inv.TransformPointX(x, y);
var y_t = this.inv.TransformPointY(x, y);
this.x = this.startX + x_t - st_x_t;
this.y = this.startY + y_t - st_y_t;
this.calculateTransform();
};
this.calculateTransform = function () {
var t = this.transform;
t.Reset();
var xfrm = this.original.spPr.xfrm;
global_MatrixTransformer.TranslateAppend(t, -xfrm.extX * 0.5, -xfrm.extY * 0.5);
if (xfrm.flipH == null ? false : xfrm.flipH) {
global_MatrixTransformer.ScaleAppend(t, -1, 1);
}
if (xfrm.flipV == null ? false : xfrm.flipV) {
global_MatrixTransformer.ScaleAppend(t, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(t, xfrm.rot == null ? 0 : -xfrm.rot);
global_MatrixTransformer.TranslateAppend(t, this.x + xfrm.extX * 0.5, this.y + xfrm.extY * 0.5);
global_MatrixTransformer.MultiplyAppend(t, this.original.group.transform);
};
this.trackEnd = function (e) {
if (isRealObject(e) && e.CtrlKey) {
var para_drawing = new ParaDrawing(10, 10, null, editor.WordControl.m_oLogicDocument.DrawingDocument, null, null);
var copy = this.original.copy(null, this.original.group);
History.Add(copy, {
Type: historyitem_CalculateAfterCopyInGroup
});
this.original.group.addGraphicObject(copy);
copy.calculateAfterOpen();
copy.setXfrm(this.x, this.y, null, null, null, null, null);
copy.setAbsoluteTransform(this.x, this.y, null, null, null, null, null);
para_drawing.Set_GraphicObject(copy);
} else {
this.original.setXfrm(this.x, this.y, null, null, null, null, null);
this.original.setAbsoluteTransform(this.x, this.y, null, null, null, null, null);
}
};
}
function ObjectForShapeDrawer(geometry, extX, extY, brush, pen, transform) {
this.geometry = geometry;
this.ext = {};
this.ext.cx = extX;
this.ext.cy = extY;
this.brush = brush;
this.pen = pen;
this.TransformMatrix = transform;
this.updateTransform = function (extX, extY, transform) {
this.ext.cx = extX;
this.ext.cy = extY;
this.transform = transform;
};
this.check_bounds = function (boundsChecker) {
if (this.geometry) {
this.geometry.check_bounds(boundsChecker);
} else {
boundsChecker._s();
boundsChecker._m(0, 0);
boundsChecker._l(this.ext.cx, 0);
boundsChecker._l(this.ext.cx, this.ext.cy);
boundsChecker._l(0, this.ext.cy);
boundsChecker._z();
boundsChecker._e();
}
};
}
function MoveTitleInChart(originalObject) {
this.originalObject = originalObject;
this.x = null;
this.y = null;
this.transform = new CMatrix();
var pen = new CLn();
pen.Fill = new CUniFill();
pen.Fill.fill = new CSolidFill();
pen.Fill.fill.color = new CUniColor();
pen.Fill.fill.color.color = new CRGBColor();
this.overlayObject = new OverlayObject(this.originalObject.spPr.geometry, this.originalObject.extX, this.originalObject.extY, this.originalObject.brush, pen, this.transform);
this.inv = global_MatrixTransformer.Invert(originalObject.chartGroup.transform);
this.inv.tx = 0;
this.inv.ty = 0;
this.pageIndex = 0;
this.draw = function (overlay) {
this.overlayObject.draw(overlay, this.pageIndex);
};
this.track = function (dx, dy, pageIndex) {
var dx_t = this.inv.TransformPointX(dx, dy);
var dy_t = this.inv.TransformPointY(dx, dy);
this.x = this.originalObject.x + dx_t;
this.y = this.originalObject.y + dy_t;
if (this.x + this.originalObject.extX > this.originalObject.chartGroup.absExtX) {
this.x = this.originalObject.chartGroup.absExtX - this.originalObject.extX;
}
if (this.x < 0) {
this.x = 0;
}
if (this.y + this.originalObject.extY > this.originalObject.chartGroup.absExtY) {
this.y = this.originalObject.chartGroup.absExtY - this.originalObject.extY;
}
if (this.y < 0) {
this.y = 0;
}
this.pageIndex = pageIndex;
this.calculateTransform();
};
this.getOriginalBoundsRect = function () {
return this.originalObject.getRectBounds();
};
this.calculateTransform = function () {
var t = this.transform;
t.Reset();
global_MatrixTransformer.TranslateAppend(t, -this.originalObject.extX * 0.5, -this.originalObject.extY * 0.5);
global_MatrixTransformer.TranslateAppend(t, this.x + this.originalObject.extX * 0.5, this.y + this.originalObject.extY * 0.5);
global_MatrixTransformer.MultiplyAppend(t, this.originalObject.chartGroup.getTransform());
};
this.trackEnd = function () {
History.Add(this.originalObject.chartGroup, {
Type: historyitem_AutoShapes_RecalculateChartUndo
});
this.originalObject.setPosition(this.x, this.y);
this.originalObject.chartGroup.recalculate();
History.Add(this.originalObject.chartGroup, {
Type: historyitem_AutoShapes_RecalculateChartRedo
});
};
}
function MoveTrackChart(originalObject) {
this.originalObject = originalObject;
this.transform = new CMatrix();
this.x = null;
this.y = null;
var geometry = CreateGeometry("rect");
geometry.Init(this.originalObject.absExtX, this.originalObject.absExtY);
geometry.Recalculate(this.originalObject.absExtX, this.originalObject.absExtY);
var brush = new CUniFill();
brush.fill = new CSolidFill();
brush.fill.color = new CUniColor();
brush.fill.color.RGBA = {
R: 255,
G: 255,
B: 255,
A: 255
};
brush.fill.color.color = new CRGBColor();
brush.fill.color.color.RGBA = {
R: 255,
G: 255,
B: 255,
A: 255
};
var pen = new CLn();
pen.Fill = new CUniFill();
pen.Fill.fill = new CSolidFill();
pen.Fill.fill.color = new CUniColor();
pen.Fill.fill.color.color = new CRGBColor();
this.overlayObject = new OverlayObject(this.originalObject.spPr.geometry, this.originalObject.absExtX, this.originalObject.absExtY, brush, pen, this.transform);
this.getOriginalBoundsRect = function () {
return this.originalObject.getRectBounds();
};
this.track = function (dx, dy) {
var original = this.originalObject;
this.x = original.x + dx;
this.y = original.y + dy;
this.transform.Reset();
var hc = original.absExtX * 0.5;
var vc = original.absExtY * 0.5;
global_MatrixTransformer.TranslateAppend(this.transform, -hc, -vc);
global_MatrixTransformer.TranslateAppend(this.transform, this.x + hc, this.y + vc);
};
this.draw = function (overlay) {
this.overlayObject.draw(overlay);
};
this.trackEnd = function () {
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateTransformUndo, null, null, new UndoRedoDataGraphicObjects(this.originalObject.Id, new UndoRedoDataShapeRecalc()), null);
this.originalObject.x = this.x;
this.originalObject.y = this.y;
this.originalObject.updateDrawingBaseCoordinates();
this.originalObject.setPosition(this.x, this.y);
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateTransformRedo, null, null, new UndoRedoDataGraphicObjects(this.originalObject.Id, new UndoRedoDataShapeRecalc()), null);
this.originalObject.recalculateTransform();
this.originalObject.calculateTransformTextMatrix();
};
}
function OverlayObject(geometry, extX, extY, brush, pen, transform) {
this.geometry = geometry;
this.ext = {};
this.ext.cx = extX;
this.ext.cy = extY;
this.brush = brush;
this.pen = pen;
this.TransformMatrix = transform;
this.shapeDrawer = new CShapeDrawer();
this.updateTransform = function (extX, extY, transform) {
this.ext.cx = extX;
this.ext.cy = extY;
this.transform = transform;
};
this.updateExtents = function (extX, extY) {
this.ext.cx = extX;
this.ext.cy = extY;
this.geometry.Recalculate(extX, extY);
};
this.updateTransformMatrix = function (transform) {
this.TransformMatrix = transform;
};
this.draw = function (overlay, pageIndex) {
overlay.SetCurrentPage(pageIndex);
overlay.SaveGrState();
overlay.SetIntegerGrid(false);
overlay.transform3(this.TransformMatrix, false);
this.shapeDrawer.fromShape2(this, overlay, this.geometry);
this.shapeDrawer.draw(this.geometry);
overlay.RestoreGrState();
};
this.check_bounds = function (boundsChecker) {
if (this.geometry) {
this.geometry.check_bounds(boundsChecker);
} else {
boundsChecker._s();
boundsChecker._m(0, 0);
boundsChecker._l(this.ext.cx, 0);
boundsChecker._l(this.ext.cx, this.ext.cy);
boundsChecker._l(0, this.ext.cy);
boundsChecker._z();
boundsChecker._e();
}
};
}

File diff suppressed because it is too large Load Diff