init repo
This commit is contained in:
2229
OfficeWeb/sdk/PowerPoint/Editor/Format/Chart.js
vendored
Normal file
2229
OfficeWeb/sdk/PowerPoint/Editor/Format/Chart.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
145
OfficeWeb/sdk/PowerPoint/Editor/Format/ChartLayout.js
Normal file
145
OfficeWeb/sdk/PowerPoint/Editor/Format/ChartLayout.js
Normal file
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* (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 = {
|
||||
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();
|
||||
}
|
||||
},
|
||||
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;
|
||||
}
|
||||
};
|
||||
238
OfficeWeb/sdk/PowerPoint/Editor/Format/ChartLegend.js
Normal file
238
OfficeWeb/sdk/PowerPoint/Editor/Format/ChartLegend.js
Normal file
@@ -0,0 +1,238 @@
|
||||
/*
|
||||
* (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.themeFont = "Calibri";
|
||||
var tx_pr;
|
||||
if (isRealObject(this.txPr)) {}
|
||||
styles.Style[styles.Id] = default_legend_style;
|
||||
++styles.Id;
|
||||
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;
|
||||
++styles.Id;
|
||||
var legend_style = new CStyle("legend_style", styles.Id - 1, null, styletype_Paragraph);
|
||||
styles.Style[styles.Id] = legend_style;
|
||||
++styles.Id;
|
||||
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;
|
||||
++styles.Id;
|
||||
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);
|
||||
}
|
||||
}
|
||||
};
|
||||
955
OfficeWeb/sdk/PowerPoint/Editor/Format/ChartTitle.js
Normal file
955
OfficeWeb/sdk/PowerPoint/Editor/Format/ChartTitle.js
Normal file
@@ -0,0 +1,955 @@
|
||||
/*
|
||||
* (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.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.recalcInfo = {
|
||||
recalculateTransform: true,
|
||||
recalculateBrush: true,
|
||||
recalculatePen: true
|
||||
};
|
||||
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;
|
||||
},
|
||||
Get_Id: function () {
|
||||
return this.Id;
|
||||
},
|
||||
setType: function (type) {
|
||||
History.Add(this, {
|
||||
Type: historyitem_AutoShapes_SetChartTitleType,
|
||||
oldPr: this.type,
|
||||
newPr: type
|
||||
});
|
||||
this.type = type;
|
||||
},
|
||||
setChartGroup: function (chartGroup) {
|
||||
var oldPr = this.chartGroup;
|
||||
var newPr = chartGroup;
|
||||
History.Add(this, {
|
||||
Type: historyitem_AutoShapes_SetChartGroup,
|
||||
oldPr: oldPr,
|
||||
newPr: newPr
|
||||
});
|
||||
this.chartGroup = chartGroup;
|
||||
},
|
||||
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;
|
||||
}
|
||||
},
|
||||
getParentObjects: function () {
|
||||
return this.chartGroup.getParentObjects();
|
||||
},
|
||||
updateInterfaceTextState: function () {
|
||||
var _b_no_change_indent;
|
||||
_b_no_change_indent = false;
|
||||
if (this.txBody !== null && typeof this.txBody === "object") {
|
||||
if (this.txBody.content !== null && typeof this.txBody.content === "object") {
|
||||
var _content = this.txBody.content;
|
||||
if (typeof _content.Document_UpdateInterfaceState === "function") {
|
||||
_content.Document_UpdateInterfaceState();
|
||||
}
|
||||
}
|
||||
}
|
||||
editor.asc_fireCallback("asc_canIncreaseIndent", false);
|
||||
editor.asc_fireCallback("asc_canDecreaseIndent", false);
|
||||
},
|
||||
isPlaceholder: function () {
|
||||
return false;
|
||||
},
|
||||
isEmptyPlaceholder: function () {
|
||||
return false;
|
||||
},
|
||||
isEmpty: function () {
|
||||
return isRealObject(this.txBody) ? this.txBody.isEmpty() : true;
|
||||
},
|
||||
getTextSelectionState: function () {
|
||||
if (this.txBody) {
|
||||
return this.txBody.content.Get_SelectionState();
|
||||
}
|
||||
return [];
|
||||
},
|
||||
setTextSelectionState: function (s) {
|
||||
if (this.txBody) {
|
||||
this.txBody.content.Set_SelectionState(s, s.length - 1);
|
||||
}
|
||||
},
|
||||
Get_Styles: function () {
|
||||
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;
|
||||
default_legend_style.TextPr.FontFamily = {
|
||||
Name: "Calibri",
|
||||
Index: -1
|
||||
};
|
||||
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.Jc = align_Center;
|
||||
var tx_pr;
|
||||
if (isRealObject(this.txPr)) {}
|
||||
styles.Style[styles.Id] = default_legend_style;
|
||||
++styles.Id;
|
||||
return styles;
|
||||
},
|
||||
select: function () {
|
||||
this.selected = true;
|
||||
},
|
||||
deselect: function () {
|
||||
this.selected = false;
|
||||
if (isRealObject(this.txBody) && isRealObject(this.txBody.content)) {
|
||||
this.txBody.content.Selection_Remove();
|
||||
}
|
||||
},
|
||||
getStyles: function () {
|
||||
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.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.Jc = align_Center;
|
||||
var tx_pr;
|
||||
if (isRealObject(this.txPr)) {}
|
||||
styles.Style[styles.Id] = default_legend_style;
|
||||
++styles.Id;
|
||||
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.content.Paragraph_Add(paraItem, false);
|
||||
this.recalculatePosExt();
|
||||
this.txBody.content.RecalculateCurPos();
|
||||
},
|
||||
recalculatePosExt: function () {
|
||||
var old_cx = this.x + this.extX * 0.5;
|
||||
var old_cy = this.y + this.extY * 0.5;
|
||||
var body_pr = this.txBody.getBodyPr();
|
||||
switch (this.type) {
|
||||
case CHART_TITLE_TYPE_TITLE:
|
||||
case CHART_TITLE_TYPE_H_AXIS:
|
||||
var max_title_width = this.chartGroup.extX * 0.8;
|
||||
var title_width = this.txBody.getRectWidth(max_title_width);
|
||||
this.extX = title_width;
|
||||
this.extY = this.txBody.getRectHeight(this.chartGroup.extY, title_width - (body_pr.rIns + body_pr.lIns));
|
||||
this.x = old_cx - this.extX * 0.5;
|
||||
if (this.x + this.extX > this.chartGroup.extX) {
|
||||
this.x = this.chartGroup.extX - this.extX;
|
||||
}
|
||||
if (this.x < 0) {
|
||||
this.x = 0;
|
||||
}
|
||||
this.y = old_cy - this.extY * 0.5;
|
||||
if (this.y + this.extY > this.chartGroup.extY) {
|
||||
this.y = this.chartGroup.extY - this.extY;
|
||||
}
|
||||
if (this.y < 0) {
|
||||
this.y = 0;
|
||||
}
|
||||
if (isRealObject(this.layout) && isRealNumber(this.layout.x)) {
|
||||
this.layout.setX(this.x / this.chartGroup.extX);
|
||||
}
|
||||
break;
|
||||
case CHART_TITLE_TYPE_V_AXIS:
|
||||
var max_title_height = this.chartGroup.extY * 0.8;
|
||||
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.extX, 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.extX) {
|
||||
this.x = this.chartGroup.extX - this.extX;
|
||||
}
|
||||
if (this.x < 0) {
|
||||
this.x = 0;
|
||||
}
|
||||
this.y = old_cy - this.extY * 0.5;
|
||||
if (this.y + this.extY > this.chartGroup.extY) {
|
||||
this.y = this.chartGroup.extY - this.extY;
|
||||
}
|
||||
if (this.y < 0) {
|
||||
this.y = 0;
|
||||
}
|
||||
if (isRealObject(this.layout) && isRealNumber(this.layout.y)) {
|
||||
this.layout.setY(this.y / this.chartGroup.extY);
|
||||
}
|
||||
break;
|
||||
}
|
||||
this.spPr.geometry.Recalculate(this.extX, this.extY);
|
||||
this.recalculateTransform();
|
||||
this.calculateTransformTextMatrix();
|
||||
this.calculateContent();
|
||||
},
|
||||
remove: function (Count, bOnlyText, bRemoveOnlySelection) {
|
||||
this.txBody.content.Remove(Count, bOnlyText, bRemoveOnlySelection);
|
||||
var old_cx = this.x + this.extX * 0.5;
|
||||
var old_cy = this.y + this.extY * 0.5;
|
||||
switch (this.type) {
|
||||
case CHART_TITLE_TYPE_TITLE:
|
||||
case CHART_TITLE_TYPE_H_AXIS:
|
||||
var max_title_width = this.chartGroup.extX * 0.8;
|
||||
var title_width = this.txBody.getRectWidth(max_title_width);
|
||||
this.extX = title_width;
|
||||
this.extY = this.txBody.getRectHeight(this.extY, title_width);
|
||||
this.x = old_cx - this.extX * 0.5;
|
||||
if (this.x + this.extX > this.chartGroup.extX) {
|
||||
this.x = this.chartGroup.extX - this.extX;
|
||||
}
|
||||
if (this.x < 0) {
|
||||
this.x = 0;
|
||||
}
|
||||
this.y = old_cy - this.extY * 0.5;
|
||||
if (this.y + this.extY > this.chartGroup.extY) {
|
||||
this.y = this.chartGroup.extY - this.extY;
|
||||
}
|
||||
if (this.y < 0) {
|
||||
this.y = 0;
|
||||
}
|
||||
if (isRealObject(this.layout) && isRealNumber(this.layout.x)) {
|
||||
this.layout.setX(this.x / this.chartGroup.extX);
|
||||
}
|
||||
break;
|
||||
case CHART_TITLE_TYPE_V_AXIS:
|
||||
var max_title_height = this.chartGroup.extY * 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.extX, 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.extX) {
|
||||
this.x = this.chartGroup.extX - this.extX;
|
||||
}
|
||||
if (this.x < 0) {
|
||||
this.x = 0;
|
||||
}
|
||||
this.y = old_cy - this.extY * 0.5;
|
||||
if (this.y + this.extY > this.chartGroup.extY) {
|
||||
this.y = this.chartGroup.extY - this.extY;
|
||||
}
|
||||
if (this.y < 0) {
|
||||
this.y = 0;
|
||||
}
|
||||
if (isRealObject(this.layout) && isRealNumber(this.layout.y)) {
|
||||
this.layout.setY(this.y / this.chartGroup.extY);
|
||||
}
|
||||
break;
|
||||
}
|
||||
this.spPr.geometry.Recalculate(this.extX, this.extY);
|
||||
this.recalculateTransform();
|
||||
this.calculateTransformTextMatrix();
|
||||
return;
|
||||
},
|
||||
updateSelectionState: function () {
|
||||
this.txBody.updateSelectionState(editor.WordControl.m_oLogicDocument.DrawingDocument);
|
||||
},
|
||||
recalculateCurPos: function () {
|
||||
if (isRealObject(this.txBody)) {
|
||||
this.txBody.content.RecalculateCurPos();
|
||||
}
|
||||
},
|
||||
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 {
|
||||
var _full_rotate = this.getFullRotate();
|
||||
var _full_flip = this.getFullFlip();
|
||||
var _hc = this.extX * 0.5;
|
||||
var _vc = this.extY * 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) {
|
||||
graphics.SetIntegerGrid(false);
|
||||
graphics.transform3(this.transformText);
|
||||
this.txBody.draw(graphics);
|
||||
graphics.reset();
|
||||
graphics.SetIntegerGrid(true);
|
||||
},
|
||||
selectionSetStart: function (e, x, y, slideIndex) {
|
||||
if (isRealObject(this.txBody)) {
|
||||
var tx, ty;
|
||||
tx = this.invertTransformText.TransformPointX(x, y);
|
||||
ty = this.invertTransformText.TransformPointY(x, y);
|
||||
this.txBody.content.Selection_SetStart(tx, ty, 0, e);
|
||||
}
|
||||
},
|
||||
selectionSetEnd: function (e, x, y, slideIndex) {
|
||||
if (isRealObject(this.txBody)) {
|
||||
var tx, ty;
|
||||
tx = this.invertTransformText.TransformPointX(x, y);
|
||||
ty = this.invertTransformText.TransformPointY(x, y);
|
||||
this.txBody.content.Selection_SetEnd(tx, ty, 0, e);
|
||||
}
|
||||
},
|
||||
setPosition: function (x, y) {
|
||||
var layout = new CChartLayout();
|
||||
layout.setIsManual(true);
|
||||
layout.setXMode(LAYOUT_MODE_EDGE);
|
||||
layout.setX(x / this.chartGroup.extX);
|
||||
layout.setYMode(LAYOUT_MODE_EDGE);
|
||||
layout.setY(y / this.chartGroup.extY);
|
||||
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;
|
||||
if (this.chartGroup) {
|
||||
editor.WordControl.m_oLogicDocument.recalcMap[this.chartGroup.Id] = this.chartGroup;
|
||||
}
|
||||
},
|
||||
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_oDrawingDocument.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_oDrawingDocument.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_oDrawingDocument.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;
|
||||
},
|
||||
recalcAll: function () {},
|
||||
recalcAllColors: function () {},
|
||||
onParagraphChanged: function () {
|
||||
if (this.chartGroup) {
|
||||
editor.WordControl.m_oLogicDocument.recalcMap[this.chartGroup.Id] = this.chartGroup;
|
||||
}
|
||||
},
|
||||
writeToBinary: function (w) {
|
||||
w.WriteBool(isRealObject(this.layout));
|
||||
if (isRealObject(this.layout)) {
|
||||
this.layout.Write_ToBinary2(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);
|
||||
}
|
||||
},
|
||||
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;
|
||||
}
|
||||
if (this.chartGroup) {
|
||||
editor.WordControl.m_oLogicDocument.recalcMap[this.chartGroup.Id] = this.chartGroup;
|
||||
}
|
||||
},
|
||||
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;
|
||||
}
|
||||
if (this.chartGroup) {
|
||||
editor.WordControl.m_oLogicDocument.recalcMap[this.chartGroup.Id] = this.chartGroup;
|
||||
}
|
||||
},
|
||||
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;
|
||||
}
|
||||
if (this.chartGroup) {
|
||||
editor.WordControl.m_oLogicDocument.recalcMap[this.chartGroup.Id] = this.chartGroup;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
1070
OfficeWeb/sdk/PowerPoint/Editor/Format/CollaborativeEditing.js
Normal file
1070
OfficeWeb/sdk/PowerPoint/Editor/Format/CollaborativeEditing.js
Normal file
File diff suppressed because it is too large
Load Diff
777
OfficeWeb/sdk/PowerPoint/Editor/Format/Comments.js
Normal file
777
OfficeWeb/sdk/PowerPoint/Editor/Format/Comments.js
Normal file
@@ -0,0 +1,777 @@
|
||||
/*
|
||||
* (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 CWriteCommentData() {
|
||||
this.Data = null;
|
||||
this.WriteAuthorId = 0;
|
||||
this.WriteCommentId = 0;
|
||||
this.WriteParentAuthorId = 0;
|
||||
this.WriteParentCommentId = 0;
|
||||
this.WriteTime = "";
|
||||
this.WriteText = "";
|
||||
this.AdditionalData = "";
|
||||
this.x = 0;
|
||||
this.y = 0;
|
||||
}
|
||||
CWriteCommentData.prototype = {
|
||||
DateToISO8601: function (d) {
|
||||
function pad(n) {
|
||||
return n < 10 ? "0" + n : n;
|
||||
}
|
||||
return d.getUTCFullYear() + "-" + pad(d.getUTCMonth() + 1) + "-" + pad(d.getUTCDate()) + "T" + pad(d.getUTCHours()) + ":" + pad(d.getUTCMinutes()) + ":" + pad(d.getUTCSeconds()) + "Z";
|
||||
},
|
||||
Iso8601ToDate: function (sDate) {
|
||||
var numericKeys = [1, 4, 5, 6, 7, 10, 11];
|
||||
var minutesOffset = 0;
|
||||
if ((struct = /^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/.exec(sDate))) {
|
||||
for (var i = 0, k;
|
||||
(k = numericKeys[i]); ++i) {
|
||||
struct[k] = +struct[k] || 0;
|
||||
}
|
||||
struct[2] = (+struct[2] || 1) - 1;
|
||||
struct[3] = +struct[3] || 1;
|
||||
if (struct[8] !== "Z" && struct[9] !== undefined) {
|
||||
minutesOffset = struct[10] * 60 + struct[11];
|
||||
if (struct[9] === "+") {
|
||||
minutesOffset = 0 - minutesOffset;
|
||||
}
|
||||
}
|
||||
var _ret = new Date(Date.UTC(struct[1], struct[2], struct[3], struct[4], struct[5] + minutesOffset, struct[6], struct[7]));
|
||||
return "" + _ret.getTime();
|
||||
}
|
||||
return "1";
|
||||
},
|
||||
Calculate: function () {
|
||||
var d = new Date(this.Data.m_sTime - 0);
|
||||
this.WriteTime = this.DateToISO8601(d);
|
||||
this.CalculateAdditionalData();
|
||||
},
|
||||
Calculate2: function () {
|
||||
var _time = this.Iso8601ToDate(this.WriteTime);
|
||||
this.WriteTime = _time;
|
||||
},
|
||||
CalculateAdditionalData: function () {
|
||||
if (null == this.Data) {
|
||||
this.AdditionalData = "";
|
||||
} else {
|
||||
this.AdditionalData = "teamlab_data:";
|
||||
this.AdditionalData += ("0;" + this.Data.m_sUserId.length + ";" + this.Data.m_sUserId + ";");
|
||||
this.AdditionalData += ("1;" + this.Data.m_sUserName.length + ";" + this.Data.m_sUserName + ";");
|
||||
this.AdditionalData += ("2;1;" + (this.Data.m_bSolved ? "1;" : "0;"));
|
||||
}
|
||||
},
|
||||
ReadNextInteger: function (_parsed) {
|
||||
var _len = _parsed.data.length;
|
||||
var _found = -1;
|
||||
var _Found = ";".charCodeAt(0);
|
||||
for (var i = _parsed.pos; i < _len; i++) {
|
||||
if (_Found == _parsed.data.charCodeAt(i)) {
|
||||
_found = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (-1 == _found) {
|
||||
return -1;
|
||||
}
|
||||
var _ret = parseInt(_parsed.data.substr(_parsed.pos, _found - _parsed.pos));
|
||||
if (isNaN(_ret)) {
|
||||
return -1;
|
||||
}
|
||||
_parsed.pos = _found + 1;
|
||||
return _ret;
|
||||
},
|
||||
ParceAdditionalData: function (_comment_data) {
|
||||
if (this.AdditionalData.indexOf("teamlab_data:") != 0) {
|
||||
return;
|
||||
}
|
||||
var _parsed = {
|
||||
data: this.AdditionalData,
|
||||
pos: "teamlab_data:".length
|
||||
};
|
||||
while (true) {
|
||||
var _attr = this.ReadNextInteger(_parsed);
|
||||
if (-1 == _attr) {
|
||||
break;
|
||||
}
|
||||
var _len = this.ReadNextInteger(_parsed);
|
||||
if (-1 == _len) {
|
||||
break;
|
||||
}
|
||||
var _value = _parsed.data.substr(_parsed.pos, _len);
|
||||
_parsed.pos += (_len + 1);
|
||||
if (0 == _attr) {
|
||||
_comment_data.m_sUserId = _value;
|
||||
} else {
|
||||
if (1 == _attr) {
|
||||
_comment_data.m_sUserName = _value;
|
||||
} else {
|
||||
if (2 == _attr) {
|
||||
_comment_data.m_bSolved = ("1" == _value) ? true : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
function CCommentAuthor() {
|
||||
this.Name = "";
|
||||
this.Id = 0;
|
||||
this.LastId = 0;
|
||||
this.Initials = "";
|
||||
}
|
||||
CCommentAuthor.prototype = {
|
||||
Calculate: function () {
|
||||
var arr = this.Name.split(" ");
|
||||
this.Initials = "";
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
if (arr[i].length > 0) {
|
||||
this.Initials += (arr[i].substring(0, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
function CCommentData() {
|
||||
this.m_sText = "";
|
||||
this.m_sTime = "";
|
||||
this.m_sUserId = "";
|
||||
this.m_sUserName = "";
|
||||
this.m_sQuoteText = null;
|
||||
this.m_bSolved = false;
|
||||
this.m_aReplies = new Array();
|
||||
this.Add_Reply = function (CommentData) {
|
||||
this.m_aReplies.push(CommentData);
|
||||
};
|
||||
this.Set_Text = function (Text) {
|
||||
this.m_sText = Text;
|
||||
};
|
||||
this.Get_Text = function () {
|
||||
return this.m_sText;
|
||||
};
|
||||
this.Get_QuoteText = function () {
|
||||
return this.m_sQuoteText;
|
||||
};
|
||||
this.Set_QuoteText = function (Quote) {
|
||||
this.m_sQuoteText = Quote;
|
||||
};
|
||||
this.Get_Solved = function () {
|
||||
return this.m_bSolved;
|
||||
};
|
||||
this.Set_Solved = function (Solved) {
|
||||
this.m_bSolved = Solved;
|
||||
};
|
||||
this.Set_Name = function (Name) {
|
||||
this.m_sUserName = Name;
|
||||
};
|
||||
this.Get_Name = function () {
|
||||
return this.m_sUserName;
|
||||
};
|
||||
this.Get_RepliesCount = function () {
|
||||
return this.m_aReplies.length;
|
||||
};
|
||||
this.Get_Reply = function (Index) {
|
||||
if (Index < 0 || Index >= this.m_aReplies.length) {
|
||||
return null;
|
||||
}
|
||||
return this.m_aReplies[Index];
|
||||
};
|
||||
this.Read_FromAscCommentData = function (AscCommentData) {
|
||||
this.m_sText = AscCommentData.asc_getText();
|
||||
this.m_sTime = AscCommentData.asc_getTime();
|
||||
this.m_sUserId = AscCommentData.asc_getUserId();
|
||||
this.m_sQuoteText = AscCommentData.asc_getQuoteText();
|
||||
this.m_bSolved = AscCommentData.asc_getSolved();
|
||||
this.m_sUserName = AscCommentData.asc_getUserName();
|
||||
var RepliesCount = AscCommentData.asc_getRepliesCount();
|
||||
for (var Index = 0; Index < RepliesCount; Index++) {
|
||||
var Reply = new CCommentData();
|
||||
Reply.Read_FromAscCommentData(AscCommentData.asc_getReply(Index));
|
||||
this.m_aReplies.push(Reply);
|
||||
}
|
||||
};
|
||||
this.Write_ToBinary2 = function (Writer) {
|
||||
var Count = this.m_aReplies.length;
|
||||
Writer.WriteString2(this.m_sText);
|
||||
Writer.WriteString2(this.m_sTime);
|
||||
Writer.WriteString2(this.m_sUserId);
|
||||
Writer.WriteString2(this.m_sUserName);
|
||||
if (null === this.m_sQuoteText) {
|
||||
Writer.WriteBool(true);
|
||||
} else {
|
||||
Writer.WriteBool(false);
|
||||
Writer.WriteString2(this.m_sQuoteText);
|
||||
}
|
||||
Writer.WriteBool(this.m_bSolved);
|
||||
Writer.WriteLong(Count);
|
||||
for (var Index = 0; Index < Count; Index++) {
|
||||
this.m_aReplies[Index].Write_ToBinary2(Writer);
|
||||
}
|
||||
};
|
||||
this.Read_FromBinary2 = function (Reader) {
|
||||
this.m_sText = Reader.GetString2();
|
||||
this.m_sTime = Reader.GetString2();
|
||||
this.m_sUserId = Reader.GetString2();
|
||||
this.m_sUserName = Reader.GetString2();
|
||||
var bNullQuote = Reader.GetBool();
|
||||
if (true != bNullQuote) {
|
||||
this.m_sQuoteText = Reader.GetString2();
|
||||
} else {
|
||||
this.m_sQuoteText = null;
|
||||
}
|
||||
this.m_bSolved = Reader.GetBool();
|
||||
var Count = Reader.GetLong();
|
||||
this.m_aReplies.length = 0;
|
||||
for (var Index = 0; Index < Count; Index++) {
|
||||
var oReply = new CCommentData();
|
||||
oReply.Read_FromBinary2(Reader);
|
||||
this.m_aReplies.push(oReply);
|
||||
}
|
||||
};
|
||||
}
|
||||
var comment_type_Common = 1;
|
||||
var comment_type_HdrFtr = 2;
|
||||
function CComment(Parent, Data) {
|
||||
this.Id = g_oIdCounter.Get_NewId();
|
||||
this.Parent = Parent;
|
||||
this.Data = Data;
|
||||
this.x = null;
|
||||
this.y = null;
|
||||
this.selected = false;
|
||||
this.m_oTypeInfo = {
|
||||
Type: comment_type_Common,
|
||||
Data: null
|
||||
};
|
||||
this.m_oStartInfo = {
|
||||
X: 0,
|
||||
Y: 0,
|
||||
H: 0,
|
||||
PageNum: 0,
|
||||
ParaId: null
|
||||
};
|
||||
this.m_oEndInfo = {
|
||||
X: 0,
|
||||
Y: 0,
|
||||
H: 0,
|
||||
PageNum: 0,
|
||||
ParaId: null
|
||||
};
|
||||
this.Lock = new CLock();
|
||||
if (false === g_oIdCounter.m_bLoad) {
|
||||
this.Lock.Set_Type(locktype_Mine, false);
|
||||
CollaborativeEditing.Add_Unlock2(this);
|
||||
}
|
||||
this.hit = function (x, y) {
|
||||
var Flags = 0;
|
||||
if (this.selected) {
|
||||
Flags |= 1;
|
||||
}
|
||||
if (this.Data.m_aReplies.length > 0) {
|
||||
Flags |= 2;
|
||||
}
|
||||
var dd = editor.WordControl.m_oDrawingDocument;
|
||||
return x > this.x && x < this.x + dd.GetCommentWidth(Flags) && y > this.y && y < this.y + dd.GetCommentHeight(Flags);
|
||||
};
|
||||
this.setPosition = function (x, y) {
|
||||
History.Add(this, {
|
||||
Type: historyitem_Comment_Position,
|
||||
oldOffsetX: this.x,
|
||||
newOffsetX: x,
|
||||
oldOffsetY: this.y,
|
||||
newOffsetY: y
|
||||
});
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
};
|
||||
this.draw = function (graphics) {
|
||||
var Flags = 0;
|
||||
if (this.selected) {
|
||||
Flags |= 1;
|
||||
}
|
||||
if (this.Data.m_aReplies.length > 0) {
|
||||
Flags |= 2;
|
||||
}
|
||||
var dd = editor.WordControl.m_oDrawingDocument;
|
||||
graphics.DrawPresentationComment(Flags, this.x, this.y, dd.GetCommentWidth(), dd.GetCommentHeight());
|
||||
};
|
||||
this.Set_StartInfo = function (PageNum, X, Y, H, ParaId) {
|
||||
this.m_oStartInfo.X = X;
|
||||
this.m_oStartInfo.Y = Y;
|
||||
this.m_oStartInfo.H = H;
|
||||
this.m_oStartInfo.ParaId = ParaId;
|
||||
if (comment_type_Common === this.m_oTypeInfo.Type) {
|
||||
this.m_oStartInfo.PageNum = PageNum;
|
||||
}
|
||||
};
|
||||
this.Set_EndInfo = function (PageNum, X, Y, H, ParaId) {
|
||||
this.m_oEndInfo.X = X;
|
||||
this.m_oEndInfo.Y = Y;
|
||||
this.m_oEndInfo.H = H;
|
||||
this.m_oEndInfo.ParaId = ParaId;
|
||||
if (comment_type_Common === this.m_oTypeInfo.Type) {
|
||||
this.m_oEndInfo.PageNum = PageNum;
|
||||
}
|
||||
};
|
||||
this.Check_ByXY = function (PageNum, X, Y, Type) {
|
||||
if (this.m_oTypeInfo.Type != Type) {
|
||||
return false;
|
||||
}
|
||||
if (comment_type_Common === Type) {
|
||||
if (PageNum < this.m_oStartInfo.PageNum || PageNum > this.m_oEndInfo.PageNum) {
|
||||
return false;
|
||||
}
|
||||
if (PageNum === this.m_oStartInfo.PageNum && (Y < this.m_oStartInfo.Y || (Y < (this.m_oStartInfo.Y + this.m_oStartInfo.H) && X < this.m_oStartInfo.X))) {
|
||||
return false;
|
||||
}
|
||||
if (PageNum === this.m_oEndInfo.PageNum && (Y > this.m_oEndInfo.Y + this.m_oEndInfo.H || (Y > this.m_oEndInfo.Y && X > this.m_oEndInfo.X))) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (comment_type_HdrFtr === Type) {
|
||||
var HdrFtr = this.m_oTypeInfo.Data;
|
||||
if (null === HdrFtr || false === HdrFtr.Check_Page(PageNum)) {
|
||||
return false;
|
||||
}
|
||||
if (Y < this.m_oStartInfo.Y || (Y < (this.m_oStartInfo.Y + this.m_oStartInfo.H) && X < this.m_oStartInfo.X)) {
|
||||
return false;
|
||||
}
|
||||
if (Y > this.m_oEndInfo.Y + this.m_oEndInfo.H || (Y > this.m_oEndInfo.Y && X > this.m_oEndInfo.X)) {
|
||||
return false;
|
||||
}
|
||||
this.m_oStartInfo.PageNum = PageNum;
|
||||
this.m_oEndInfo.PageNum = PageNum;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
this.Set_Data = function (Data) {
|
||||
History.Add(this, {
|
||||
Type: historyitem_Comment_Change,
|
||||
New: Data,
|
||||
Old: this.Data
|
||||
});
|
||||
this.Data = Data;
|
||||
};
|
||||
this.Remove_Marks = function () {
|
||||
var Para_start = g_oTableId.Get_ById(this.m_oStartInfo.ParaId);
|
||||
var Para_end = g_oTableId.Get_ById(this.m_oEndInfo.ParaId);
|
||||
if (Para_start === Para_end) {
|
||||
if (null != Para_start) {
|
||||
Para_start.Remove_CommentMarks(this.Id);
|
||||
}
|
||||
} else {
|
||||
if (null != Para_start) {
|
||||
Para_start.Remove_CommentMarks(this.Id);
|
||||
}
|
||||
if (null != Para_end) {
|
||||
Para_end.Remove_CommentMarks(this.Id);
|
||||
}
|
||||
}
|
||||
};
|
||||
this.Set_TypeInfo = function (Type, Data) {
|
||||
var New = {
|
||||
Type: Type,
|
||||
Data: Data
|
||||
};
|
||||
History.Add(this, {
|
||||
Type: historyitem_Comment_TypeInfo,
|
||||
New: New,
|
||||
Old: this.m_oTypeInfo
|
||||
});
|
||||
this.m_oTypeInfo = New;
|
||||
if (comment_type_HdrFtr === Type) {
|
||||
var PageNum = Data.Content.Get_StartPage_Absolute();
|
||||
this.m_oStartInfo.PageNum = PageNum;
|
||||
this.m_oEndInfo.PageNum = PageNum;
|
||||
}
|
||||
};
|
||||
this.Get_TypeInfo = function () {
|
||||
return this.m_oTypeInfo;
|
||||
};
|
||||
this.Undo = function (Data) {
|
||||
var Type = Data.Type;
|
||||
switch (Type) {
|
||||
case historyitem_Comment_Change:
|
||||
this.Data = Data.Old;
|
||||
editor.sync_ChangeCommentData(this.Id, this.Data);
|
||||
break;
|
||||
case historyitem_Comment_TypeInfo:
|
||||
this.m_oTypeInfo = Data.Old;
|
||||
break;
|
||||
case historyitem_Comment_Position:
|
||||
this.x = Data.oldOffsetX;
|
||||
this.y = Data.oldOffsetY;
|
||||
break;
|
||||
}
|
||||
};
|
||||
this.Redo = function (Data) {
|
||||
var Type = Data.Type;
|
||||
switch (Type) {
|
||||
case historyitem_Comment_Change:
|
||||
this.Data = Data.New;
|
||||
editor.sync_ChangeCommentData(this.Id, this.Data);
|
||||
break;
|
||||
case historyitem_Comment_TypeInfo:
|
||||
this.m_oTypeInfo = Data.New;
|
||||
break;
|
||||
case historyitem_Comment_Position:
|
||||
this.x = Data.newOffsetX;
|
||||
this.y = Data.newOffsetY;
|
||||
break;
|
||||
}
|
||||
};
|
||||
this.Refresh_RecalcData = function (Data) {};
|
||||
this.Save_Changes = function (Data, Writer) {
|
||||
Writer.WriteLong(historyitem_type_Comment);
|
||||
var Type = Data.Type;
|
||||
Writer.WriteLong(Type);
|
||||
switch (Type) {
|
||||
case historyitem_Comment_Change:
|
||||
Data.New.Write_ToBinary2(Writer);
|
||||
break;
|
||||
case historyitem_Comment_TypeInfo:
|
||||
var Type = Data.New.Type;
|
||||
Writer.WriteLong(Type);
|
||||
if (comment_type_HdrFtr === Type) {
|
||||
var HdrFtr = Data.New.Data;
|
||||
Writer.WriteString2(HdrFtr.Get_Id());
|
||||
}
|
||||
break;
|
||||
case historyitem_Comment_Position:
|
||||
Writer.WriteBool(isRealNumber(Data.newOffsetX) && isRealNumber(Data.newOffsetY));
|
||||
if (isRealNumber(Data.newOffsetX) && isRealNumber(Data.newOffsetY)) {
|
||||
Writer.WriteDouble(Data.newOffsetX);
|
||||
Writer.WriteDouble(Data.newOffsetY);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return Writer;
|
||||
};
|
||||
this.Save_Changes2 = function (Data, Writer) {
|
||||
var bRetValue = false;
|
||||
var Type = Data.Type;
|
||||
switch (Type) {
|
||||
case historyitem_Comment_Change:
|
||||
break;
|
||||
case historyitem_Comment_TypeInfo:
|
||||
break;
|
||||
}
|
||||
return bRetValue;
|
||||
};
|
||||
this.Load_Changes = function (Reader, Reader2) {
|
||||
var ClassType = Reader.GetLong();
|
||||
if (historyitem_type_Comment != ClassType) {
|
||||
return;
|
||||
}
|
||||
var Type = Reader.GetLong();
|
||||
switch (Type) {
|
||||
case historyitem_Comment_Change:
|
||||
this.Data.Read_FromBinary2(Reader);
|
||||
editor.sync_ChangeCommentData(this.Id, this.Data);
|
||||
break;
|
||||
case historyitem_Comment_TypeInfo:
|
||||
this.m_oTypeInfo.Type = Reader.GetLong();
|
||||
if (comment_type_HdrFtr === this.m_oTypeInfo.Type) {
|
||||
var HdrFtrId = Reader.GetString2();
|
||||
this.m_oTypeInfo.Data = g_oTableId.Get_ById(HdrFtrId);
|
||||
}
|
||||
break;
|
||||
case historyitem_Comment_Position:
|
||||
if (Reader.GetBool()) {
|
||||
this.x = Reader.GetDouble();
|
||||
this.y = Reader.GetDouble();
|
||||
} else {
|
||||
this.x = null;
|
||||
this.y = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
this.Get_Id = function () {
|
||||
return this.Id;
|
||||
};
|
||||
this.Set_Id = function (newId) {
|
||||
g_oTableId.Reset_Id(this, newId, this.Id);
|
||||
this.Id = newId;
|
||||
};
|
||||
this.Write_ToBinary2 = function (Writer) {
|
||||
Writer.WriteLong(historyitem_type_Comment);
|
||||
Writer.WriteString2(this.Id);
|
||||
this.Data.Write_ToBinary2(Writer);
|
||||
Writer.WriteLong(this.m_oTypeInfo.Type);
|
||||
if (comment_type_HdrFtr === this.m_oTypeInfo.Type) {
|
||||
Writer.WriteString2(this.m_oTypeInfo.Data.Get_Id());
|
||||
}
|
||||
};
|
||||
this.Read_FromBinary2 = function (Reader) {
|
||||
this.Id = Reader.GetString2();
|
||||
this.Data = new CCommentData();
|
||||
this.Data.Read_FromBinary2(Reader);
|
||||
this.m_oTypeInfo.Type = Reader.GetLong();
|
||||
if (comment_type_HdrFtr === this.m_oTypeInfo.Type) {
|
||||
this.m_oTypeInfo.Data = g_oTableId.Get_ById(Reader.GetString2());
|
||||
}
|
||||
};
|
||||
this.Check_MergeData = function () {
|
||||
var bUse = true;
|
||||
if (null != this.m_oStartInfo.ParaId) {
|
||||
var Para_start = g_oTableId.Get_ById(this.m_oStartInfo.ParaId);
|
||||
if (true != Para_start.Is_UseInDocument()) {
|
||||
bUse = false;
|
||||
}
|
||||
}
|
||||
if (true === bUse && null != this.m_oEndInfo.ParaId) {
|
||||
var Para_end = g_oTableId.Get_ById(this.m_oEndInfo.ParaId);
|
||||
if (true != Para_end.Is_UseInDocument()) {
|
||||
bUse = false;
|
||||
}
|
||||
}
|
||||
if (false === bUse) {
|
||||
editor.WordControl.m_oLogicDocument.Remove_Comment(this.Id, true);
|
||||
}
|
||||
};
|
||||
g_oTableId.Add(this, this.Id);
|
||||
}
|
||||
var comments_NoComment = 0;
|
||||
var comments_NonActiveComment = 1;
|
||||
var comments_ActiveComment = 2;
|
||||
function CComments() {
|
||||
this.Id = g_oIdCounter.Get_NewId();
|
||||
this.m_bUse = false;
|
||||
this.m_aComments = {};
|
||||
this.m_sCurrent = null;
|
||||
this.m_aCurrentDraw = new Array();
|
||||
this.Get_Id = function () {
|
||||
return this.Id;
|
||||
};
|
||||
this.Set_Id = function (newId) {
|
||||
g_oTableId.Reset_Id(this, newId, this.Id);
|
||||
this.Id = newId;
|
||||
};
|
||||
this.Set_Use = function (Use) {
|
||||
this.m_bUse = Use;
|
||||
};
|
||||
this.Is_Use = function () {
|
||||
return this.m_bUse;
|
||||
};
|
||||
this.Add = function (Comment) {
|
||||
var Id = Comment.Get_Id();
|
||||
History.Add(this, {
|
||||
Type: historyitem_Comments_Add,
|
||||
Id: Id,
|
||||
Comment: Comment
|
||||
});
|
||||
this.m_aComments[Id] = Comment;
|
||||
};
|
||||
this.Get_ById = function (Id) {
|
||||
if ("undefined" != typeof(this.m_aComments[Id])) {
|
||||
return this.m_aComments[Id];
|
||||
}
|
||||
return null;
|
||||
};
|
||||
this.Remove_ById = function (Id) {
|
||||
if ("undefined" != typeof(this.m_aComments[Id])) {
|
||||
History.Add(this, {
|
||||
Type: historyitem_Comments_Remove,
|
||||
Id: Id,
|
||||
Comment: this.m_aComments[Id]
|
||||
});
|
||||
var Comment = this.m_aComments[Id];
|
||||
delete this.m_aComments[Id];
|
||||
Comment.Remove_Marks();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
this.Reset_CurrentDraw = function (PageNum) {
|
||||
this.m_aCurrentDraw.length = 0;
|
||||
for (var Id in this.m_aComments) {
|
||||
var Comment = this.m_aComments[Id];
|
||||
if (PageNum > Comment.m_oStartInfo.PageNum && PageNum <= Comment.m_oEndInfo.PageNum) {
|
||||
this.m_aCurrentDraw.push(Comment.Get_Id());
|
||||
}
|
||||
}
|
||||
};
|
||||
this.Add_CurrentDraw = function (Id) {
|
||||
if (null != this.Get_ById(Id)) {
|
||||
this.m_aCurrentDraw.push(Id);
|
||||
}
|
||||
};
|
||||
this.Remove_CurrentDraw = function (Id) {
|
||||
var Count = this.m_aCurrentDraw.length;
|
||||
for (var Index = 0; Index < Count; Index++) {
|
||||
if (Id === this.m_aCurrentDraw[Index]) {
|
||||
this.m_aCurrentDraw.splice(Index, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
this.Check_CurrentDraw = function () {
|
||||
var Flag = comments_NoComment;
|
||||
var Count = this.m_aCurrentDraw.length;
|
||||
if (Count > 0) {
|
||||
Flag = comments_NonActiveComment;
|
||||
}
|
||||
for (var Index = 0; Index < Count; Index++) {
|
||||
if (this.m_aCurrentDraw[Index] === this.m_sCurrent) {
|
||||
Flag = comments_ActiveComment;
|
||||
return Flag;
|
||||
}
|
||||
}
|
||||
return Flag;
|
||||
};
|
||||
this.Set_Current = function (Id) {
|
||||
this.m_sCurrent = Id;
|
||||
};
|
||||
this.Set_StartInfo = function (Id, PageNum, X, Y, H, ParaId) {
|
||||
var Comment = this.Get_ById(Id);
|
||||
if (null != Comment) {
|
||||
Comment.Set_StartInfo(PageNum, X, Y, H, ParaId);
|
||||
}
|
||||
};
|
||||
this.Set_EndInfo = function (Id, PageNum, X, Y, H, ParaId) {
|
||||
var Comment = this.Get_ById(Id);
|
||||
if (null != Comment) {
|
||||
Comment.Set_EndInfo(PageNum, X, Y, H, ParaId);
|
||||
}
|
||||
};
|
||||
this.Get_ByXY = function (PageNum, X, Y, Type) {
|
||||
for (var Id in this.m_aComments) {
|
||||
var Comment = this.m_aComments[Id];
|
||||
if (true === Comment.Check_ByXY(PageNum, X, Y, Type)) {
|
||||
return Comment;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
this.Get_Current = function () {
|
||||
if (null != this.m_sCurrent) {
|
||||
var Comment = this.Get_ById(this.m_sCurrent);
|
||||
if (null != Comment) {
|
||||
return Comment;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
this.Get_CurrentId = function () {
|
||||
return this.m_sCurrent;
|
||||
};
|
||||
this.Set_CommentData = function (Id, CommentData) {
|
||||
var Comment = this.Get_ById(Id);
|
||||
if (null != Comment) {
|
||||
Comment.Set_Data(CommentData);
|
||||
}
|
||||
};
|
||||
this.Check_MergeData = function () {
|
||||
for (var Id in this.m_aComments) {
|
||||
this.m_aComments[Id].Check_MergeData();
|
||||
}
|
||||
};
|
||||
this.Undo = function (Data) {
|
||||
var Type = Data.Type;
|
||||
switch (Type) {
|
||||
case historyitem_Comments_Add:
|
||||
delete this.m_aComments[Data.Id];
|
||||
editor.sync_RemoveComment(Data.Id);
|
||||
break;
|
||||
case historyitem_Comments_Remove:
|
||||
this.m_aComments[Data.Id] = Data.Comment;
|
||||
editor.sync_AddComment(Data.Id, Data.Comment.Data);
|
||||
break;
|
||||
}
|
||||
};
|
||||
this.Redo = function (Data) {
|
||||
var Type = Data.Type;
|
||||
switch (Type) {
|
||||
case historyitem_Comments_Add:
|
||||
this.m_aComments[Data.Id] = Data.Comment;
|
||||
editor.sync_AddComment(Data.Id, Data.Comment.Data);
|
||||
break;
|
||||
case historyitem_Comments_Remove:
|
||||
delete this.m_aComments[Data.Id];
|
||||
editor.sync_RemoveComment(Data.Id);
|
||||
break;
|
||||
}
|
||||
};
|
||||
this.Refresh_RecalcData = function (Data) {};
|
||||
this.Document_Is_SelectionLocked = function (Id) {
|
||||
var Comment = this.Get_ById(Id);
|
||||
if (null != Comment) {
|
||||
Comment.Lock.Check(Comment.Get_Id());
|
||||
}
|
||||
};
|
||||
this.Save_Changes = function (Data, Writer) {
|
||||
Writer.WriteLong(historyitem_type_Comments);
|
||||
var Type = Data.Type;
|
||||
Writer.WriteLong(Type);
|
||||
switch (Type) {
|
||||
case historyitem_Comments_Add:
|
||||
Writer.WriteString2(Data.Id);
|
||||
break;
|
||||
case historyitem_Comments_Remove:
|
||||
Writer.WriteString2(Data.Id);
|
||||
break;
|
||||
}
|
||||
return Writer;
|
||||
};
|
||||
this.Save_Changes2 = function (Data, Writer) {
|
||||
var bRetValue = false;
|
||||
var Type = Data.Type;
|
||||
switch (Type) {
|
||||
case historyitem_Comments_Add:
|
||||
break;
|
||||
case historyitem_Comments_Remove:
|
||||
break;
|
||||
}
|
||||
return bRetValue;
|
||||
};
|
||||
this.Load_Changes = function (Reader, Reader2) {
|
||||
var ClassType = Reader.GetLong();
|
||||
if (historyitem_type_Comments != ClassType) {
|
||||
return;
|
||||
}
|
||||
var Type = Reader.GetLong();
|
||||
switch (Type) {
|
||||
case historyitem_Comments_Add:
|
||||
var CommentId = Reader.GetString2();
|
||||
var Comment = g_oTableId.Get_ById(CommentId);
|
||||
this.m_aComments[CommentId] = Comment;
|
||||
editor.sync_AddComment(CommentId, Comment.Data);
|
||||
break;
|
||||
case historyitem_Comments_Remove:
|
||||
var CommentId = Reader.GetString2();
|
||||
delete this.m_aComments[CommentId];
|
||||
editor.sync_RemoveComment(CommentId);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
g_oTableId.Add(this, this.Id);
|
||||
}
|
||||
6139
OfficeWeb/sdk/PowerPoint/Editor/Format/DocumentContent.js
Normal file
6139
OfficeWeb/sdk/PowerPoint/Editor/Format/DocumentContent.js
Normal file
File diff suppressed because it is too large
Load Diff
814
OfficeWeb/sdk/PowerPoint/Editor/Format/FontClassification.js
Normal file
814
OfficeWeb/sdk/PowerPoint/Editor/Format/FontClassification.js
Normal file
File diff suppressed because one or more lines are too long
2144
OfficeWeb/sdk/PowerPoint/Editor/Format/GraphicFrame.js
Normal file
2144
OfficeWeb/sdk/PowerPoint/Editor/Format/GraphicFrame.js
Normal file
File diff suppressed because it is too large
Load Diff
1781
OfficeWeb/sdk/PowerPoint/Editor/Format/GroupShape.js
Normal file
1781
OfficeWeb/sdk/PowerPoint/Editor/Format/GroupShape.js
Normal file
File diff suppressed because it is too large
Load Diff
1434
OfficeWeb/sdk/PowerPoint/Editor/Format/Image.js
Normal file
1434
OfficeWeb/sdk/PowerPoint/Editor/Format/Image.js
Normal file
File diff suppressed because it is too large
Load Diff
1029
OfficeWeb/sdk/PowerPoint/Editor/Format/Layout.js
Normal file
1029
OfficeWeb/sdk/PowerPoint/Editor/Format/Layout.js
Normal file
File diff suppressed because it is too large
Load Diff
9627
OfficeWeb/sdk/PowerPoint/Editor/Format/Paragraph.js
Normal file
9627
OfficeWeb/sdk/PowerPoint/Editor/Format/Paragraph.js
Normal file
File diff suppressed because it is too large
Load Diff
4838
OfficeWeb/sdk/PowerPoint/Editor/Format/ParagraphContent.js
Normal file
4838
OfficeWeb/sdk/PowerPoint/Editor/Format/ParagraphContent.js
Normal file
File diff suppressed because it is too large
Load Diff
5078
OfficeWeb/sdk/PowerPoint/Editor/Format/Presentation.js
Normal file
5078
OfficeWeb/sdk/PowerPoint/Editor/Format/Presentation.js
Normal file
File diff suppressed because it is too large
Load Diff
3542
OfficeWeb/sdk/PowerPoint/Editor/Format/Shape.js
Normal file
3542
OfficeWeb/sdk/PowerPoint/Editor/Format/Shape.js
Normal file
File diff suppressed because it is too large
Load Diff
1344
OfficeWeb/sdk/PowerPoint/Editor/Format/Slide.js
Normal file
1344
OfficeWeb/sdk/PowerPoint/Editor/Format/Slide.js
Normal file
File diff suppressed because it is too large
Load Diff
845
OfficeWeb/sdk/PowerPoint/Editor/Format/SlideMaster.js
Normal file
845
OfficeWeb/sdk/PowerPoint/Editor/Format/SlideMaster.js
Normal file
@@ -0,0 +1,845 @@
|
||||
/*
|
||||
* (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 MasterSlide(presentation, theme) {
|
||||
this.cSld = new CSld();
|
||||
this.clrMap = new ClrMap();
|
||||
this.hf = new HF();
|
||||
this.sldLayoutLst = [];
|
||||
this.txStyles = null;
|
||||
this.preserve = false;
|
||||
this.ImageBase64 = "";
|
||||
this.Width64 = 0;
|
||||
this.Height64 = 0;
|
||||
this.ThemeIndex = 0;
|
||||
this.Theme = null;
|
||||
this.TableStyles = null;
|
||||
this.Vml = null;
|
||||
this.Width = 254;
|
||||
this.Height = 190.5;
|
||||
this.recalcInfo = {};
|
||||
this.DrawingDocument = editor.WordControl.m_oDrawingDocument;
|
||||
this.maxId = 1000;
|
||||
this.changeProportions = function (kW, kH) {
|
||||
var _graphic_objects = this.cSld.spTree;
|
||||
var _object_index;
|
||||
var _objects_count = _graphic_objects.length;
|
||||
for (_object_index = 0; _object_index < _objects_count; ++_object_index) {
|
||||
_graphic_objects[_object_index].changeProportions(kW, kH);
|
||||
}
|
||||
};
|
||||
this.draw = function (graphics) {
|
||||
for (var i = 0; i < this.cSld.spTree.length; ++i) {
|
||||
if (!this.cSld.spTree[i].isPlaceholder()) {
|
||||
this.cSld.spTree[i].draw(graphics);
|
||||
}
|
||||
}
|
||||
};
|
||||
this.setSize = function (width, height) {
|
||||
var _k_h = height / this.Height;
|
||||
var _k_w = width / this.Width;
|
||||
this.Width = width;
|
||||
this.Height = height;
|
||||
var _graphic_objects = this.cSld.spTree;
|
||||
var _objects_count = _graphic_objects.length;
|
||||
var _object_index;
|
||||
for (_object_index = 0; _object_index < _objects_count; ++_object_index) {
|
||||
_graphic_objects[_object_index].updateProportions(_k_w, _k_h);
|
||||
}
|
||||
var _layouts = this.sldLayoutLst;
|
||||
var _layout_count = _layouts.length;
|
||||
var _layout_index;
|
||||
for (_layout_index = 0; _layout_index < _layout_count; ++_layout_index) {
|
||||
_layouts[_layout_index].setSize(width, height);
|
||||
}
|
||||
};
|
||||
this.calculateColors = function () {
|
||||
var _shapes = this.cSld.spTree;
|
||||
var _shapes_count = _shapes.length;
|
||||
var _shape_index;
|
||||
for (_shape_index = 0; _shape_index < _shapes_count; ++_shape_index) {
|
||||
if (_shapes[_shape_index].calculateColors) {
|
||||
_shapes[_shape_index].calculateColors();
|
||||
}
|
||||
}
|
||||
};
|
||||
this.getMatchingLayout = function (type, matchingName, cSldName, themeFlag) {
|
||||
var layoutType = type;
|
||||
var _layoutName = null,
|
||||
_layout_index, _layout;
|
||||
if (type === nSldLtTTitle && !(themeFlag === true)) {
|
||||
layoutType = nSldLtTObj;
|
||||
}
|
||||
if (layoutType != null) {
|
||||
for (var i = 0; i < this.sldLayoutLst.length; ++i) {
|
||||
if (this.sldLayoutLst[i].type == layoutType) {
|
||||
return this.sldLayoutLst[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (type === nSldLtTTitle && !(themeFlag === true)) {
|
||||
layoutType = nSldLtTTx;
|
||||
for (i = 0; i < this.sldLayoutLst.length; ++i) {
|
||||
if (this.sldLayoutLst[i].type == layoutType) {
|
||||
return this.sldLayoutLst[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (matchingName != "" && matchingName != null) {
|
||||
_layoutName = matchingName;
|
||||
} else {
|
||||
if (cSldName != "" && cSldName != null) {
|
||||
_layoutName = cSldName;
|
||||
}
|
||||
}
|
||||
if (_layoutName != null) {
|
||||
var _layout_name;
|
||||
for (_layout_index = 0; _layout_index < this.sldLayoutLst.length; ++_layout_index) {
|
||||
_layout = this.sldLayoutLst[_layout_index];
|
||||
_layout_name = null;
|
||||
if (_layout.matchingName != null && _layout.matchingName != "") {
|
||||
_layout_name = _layout.matchingName;
|
||||
} else {
|
||||
if (_layout.cSld.name != null && _layout.cSld.name != "") {
|
||||
_layout_name = _layout.cSld.name;
|
||||
}
|
||||
}
|
||||
if (_layout_name == _layoutName) {
|
||||
return _layout;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (_layout_index = 0; _layout_index < this.sldLayoutLst.length; ++_layout_index) {
|
||||
_layout = this.sldLayoutLst[_layout_index];
|
||||
_layout_name = null;
|
||||
if (_layout.type != nSldLtTTitle) {
|
||||
return _layout;
|
||||
}
|
||||
}
|
||||
return this.sldLayoutLst[0];
|
||||
};
|
||||
this.Calculate = function () {
|
||||
var titleStyles = this.txStyles.titleStyle;
|
||||
};
|
||||
this.presentation = editor.WordControl.m_oLogicDocument;
|
||||
this.theme = theme;
|
||||
this.kind = MASTER_KIND;
|
||||
this.getMatchingShape = function (type, idx, bSingleBody) {
|
||||
var _input_reduced_type;
|
||||
if (type == null) {
|
||||
_input_reduced_type = phType_body;
|
||||
} else {
|
||||
if (type == phType_ctrTitle) {
|
||||
_input_reduced_type = phType_title;
|
||||
} else {
|
||||
_input_reduced_type = type;
|
||||
}
|
||||
}
|
||||
var _input_reduced_index;
|
||||
if (idx == null) {
|
||||
_input_reduced_index = 0;
|
||||
} else {
|
||||
_input_reduced_index = idx;
|
||||
}
|
||||
var _sp_tree = this.cSld.spTree;
|
||||
var _shape_index;
|
||||
var _index, _type;
|
||||
var _final_index, _final_type;
|
||||
var _glyph;
|
||||
var body_count = 0;
|
||||
var last_body;
|
||||
for (_shape_index = 0; _shape_index < _sp_tree.length; ++_shape_index) {
|
||||
_glyph = _sp_tree[_shape_index];
|
||||
if (_glyph.isPlaceholder()) {
|
||||
if (_glyph instanceof CShape) {
|
||||
_index = _glyph.nvSpPr.nvPr.ph.idx;
|
||||
_type = _glyph.nvSpPr.nvPr.ph.type;
|
||||
}
|
||||
if (_glyph instanceof CImageShape) {
|
||||
_index = _glyph.nvPicPr.nvPr.ph.idx;
|
||||
_type = _glyph.nvPicPr.nvPr.ph.type;
|
||||
}
|
||||
if (_glyph instanceof CGroupShape) {
|
||||
_index = _glyph.nvGrpSpPr.nvPr.ph.idx;
|
||||
_type = _glyph.nvGrpSpPr.nvPr.ph.type;
|
||||
}
|
||||
if (_type == null) {
|
||||
_final_type = phType_body;
|
||||
} else {
|
||||
if (_type == phType_ctrTitle) {
|
||||
_final_type = phType_title;
|
||||
} else {
|
||||
_final_type = _type;
|
||||
}
|
||||
}
|
||||
if (_index == null) {
|
||||
_final_index = 0;
|
||||
} else {
|
||||
_final_index = _index;
|
||||
}
|
||||
if (_input_reduced_type == _final_type && _input_reduced_index == _final_index) {
|
||||
return _glyph;
|
||||
}
|
||||
if (_input_reduced_type == phType_title && _input_reduced_type == _final_type) {
|
||||
return _glyph;
|
||||
}
|
||||
if (phType_body === _type) {
|
||||
++body_count;
|
||||
last_body = _glyph;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_input_reduced_type == phType_sldNum || _input_reduced_type == phType_dt || _input_reduced_type == phType_ftr || _input_reduced_type == phType_hdr) {
|
||||
for (_shape_index = 0; _shape_index < _sp_tree.length; ++_shape_index) {
|
||||
_glyph = _sp_tree[_shape_index];
|
||||
if (_glyph.isPlaceholder()) {
|
||||
if (_glyph instanceof CShape) {
|
||||
_type = _glyph.nvSpPr.nvPr.ph.type;
|
||||
}
|
||||
if (_glyph instanceof CImageShape) {
|
||||
_type = _glyph.nvPicPr.nvPr.ph.type;
|
||||
}
|
||||
if (_glyph instanceof CGroupShape) {
|
||||
_type = _glyph.nvGrpSpPr.nvPr.ph.type;
|
||||
}
|
||||
if (_input_reduced_type == _type) {
|
||||
return _glyph;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (body_count === 1 && type === phType_body && bSingleBody) {
|
||||
return last_body;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
this.recalculate = function () {
|
||||
try {
|
||||
var _shapes = this.cSld.spTree;
|
||||
var _shape_index;
|
||||
var _shape_count = _shapes.length;
|
||||
for (_shape_index = 0; _shape_index < _shape_count; ++_shape_index) {
|
||||
if (!_shapes[_shape_index].isPlaceholder()) {
|
||||
_shapes[_shape_index].recalculate();
|
||||
}
|
||||
}
|
||||
} catch(e) {}
|
||||
};
|
||||
this.setNewSizes = function (width, height) {
|
||||
if (! (typeof width === "number" && width > 0 && typeof height === "number" && height > 0)) {
|
||||
return;
|
||||
}
|
||||
var _k_w = width / this.Width;
|
||||
var _k_h = height / this.Height;
|
||||
var _graphic_objects = this.cSld.spTree;
|
||||
var _object_count = _graphic_objects.length;
|
||||
var _object_index;
|
||||
for (_object_index = 0; _object_index < _object_count; ++_object_index) {
|
||||
_graphic_objects[_object_index].updateProportions(_k_w, _k_h);
|
||||
}
|
||||
};
|
||||
this.Id = g_oIdCounter.Get_NewId();
|
||||
g_oTableId.Add(this, this.Id);
|
||||
}
|
||||
MasterSlide.prototype = {
|
||||
addLayout: function (layout) {
|
||||
this.sldLayoutLst.push(layout);
|
||||
},
|
||||
setTheme: function (theme) {
|
||||
History.Add(this, {
|
||||
Type: historyitem_SetMasterTheme,
|
||||
oldPr: this.Theme,
|
||||
newPr: theme
|
||||
});
|
||||
this.Theme = theme;
|
||||
},
|
||||
changeSize: function (kw, kh) {
|
||||
this.Width *= kw;
|
||||
this.Height *= kh;
|
||||
for (var i = 0; i < this.cSld.spTree.length; ++i) {
|
||||
this.cSld.spTree[i].changeSize(kw, kh);
|
||||
}
|
||||
this.recalcAll();
|
||||
},
|
||||
shapeAdd: function (pos, item) {
|
||||
History.Add(this, {
|
||||
Type: historyitem_ShapeAdd,
|
||||
pos: pos,
|
||||
item: item
|
||||
});
|
||||
this.cSld.spTree.splice(pos, 0, item);
|
||||
},
|
||||
changeBackground: function (bg) {
|
||||
History.Add(this, {
|
||||
Type: historyitem_ChangeBg,
|
||||
oldBg: this.cSld.Bg ? this.cSld.Bg.createFullCopy() : null,
|
||||
newBg: bg
|
||||
});
|
||||
this.cSld.Bg = bg;
|
||||
this.recalcInfo.recalculateBackground = true;
|
||||
editor.WordControl.m_oLogicDocument.recalcMap[this.Id] = this;
|
||||
},
|
||||
setTxStyles: function (txStyles) {
|
||||
History.Add(this, {
|
||||
Type: historyitem_SetTxStyles,
|
||||
oldPr: this.txStyles,
|
||||
newPr: txStyles
|
||||
});
|
||||
this.txStyles = txStyles;
|
||||
},
|
||||
setCSldName: function (name) {
|
||||
History.Add(this, {
|
||||
Type: historyitem_SetCSldName,
|
||||
oldName: this.cSld.name,
|
||||
newName: name
|
||||
});
|
||||
this.cSld.name = name;
|
||||
},
|
||||
recalcAll: function () {
|
||||
for (var i = 0; i < this.cSld.spTree.length; ++i) {
|
||||
this.cSld.spTree[i].recalcAll();
|
||||
}
|
||||
},
|
||||
setClMapOverride: function (clrMap) {
|
||||
History.Add(this, {
|
||||
Type: historyitem_SetClrMapOverride,
|
||||
oldClrMap: this.clrMap,
|
||||
newClrMap: clrMap
|
||||
});
|
||||
this.clrMap = clrMap;
|
||||
},
|
||||
addToSldLayoutLstToPos: function (pos, obj) {
|
||||
History.Add(this, {
|
||||
Type: historyitem_AddLayout,
|
||||
objectId: obj.Get_Id(),
|
||||
pos: pos
|
||||
});
|
||||
this.sldLayoutLst.splice(pos, 0, obj);
|
||||
},
|
||||
getAllImages: function (images) {
|
||||
if (this.cSld.Bg && this.cSld.Bg.bgPr && this.cSld.Bg.bgPr.Fill && this.cSld.Bg.bgPr.Fill.fill instanceof CBlipFill && typeof this.cSld.Bg.bgPr.Fill.fill.RasterImageId === "string") {
|
||||
images[_getFullImageSrc(this.cSld.Bg.bgPr.Fill.fill.RasterImageId)] = true;
|
||||
}
|
||||
for (var i = 0; i < this.cSld.spTree.length; ++i) {
|
||||
if (typeof this.cSld.spTree[i].getAllImages === "function") {
|
||||
this.cSld.spTree[i].getAllImages(images);
|
||||
}
|
||||
}
|
||||
},
|
||||
Get_Id: function () {
|
||||
return this.Id;
|
||||
},
|
||||
Refresh_RecalcData: function () {},
|
||||
Undo: function (data) {
|
||||
switch (data.Type) {
|
||||
case historyitem_SetMasterTheme:
|
||||
break;
|
||||
case historyitem_SetTxStyles:
|
||||
this.txStyles = data.oldPr;
|
||||
break;
|
||||
case historyitem_AddComment:
|
||||
this.comments.splice(data.pos, 1);
|
||||
editor.sync_RemoveComment(data.objectId);
|
||||
break;
|
||||
case historyitem_RemoveComment:
|
||||
this.comments.splice(data.index, 0, g_oTableId.Get_ById(data.id));
|
||||
editor.sync_AddComment(this.comments[data.index].Get_Id(), this.comments[data.index].Data);
|
||||
break;
|
||||
case historyitem_RemoveFromSpTree:
|
||||
this.cSld.spTree.splice(data.index, 0, g_oTableId.Get_ById(data.id));
|
||||
break;
|
||||
case historyitem_AddToSlideSpTree:
|
||||
this.cSld.spTree.splice(data.pos, 1);
|
||||
break;
|
||||
case historyitem_AddLayout:
|
||||
break;
|
||||
case historyitem_AddSlideLocks:
|
||||
this.deleteLock = null;
|
||||
this.backgroundLock = null;
|
||||
this.timingLock = null;
|
||||
this.transitionLock = null;
|
||||
this.layoutLock = null;
|
||||
break;
|
||||
case historyitem_ChangeBg:
|
||||
this.cSld.Bg = data.oldBg;
|
||||
this.recalcInfo.recalculateBackground = true;
|
||||
editor.WordControl.m_oLogicDocument.recalcMap[this.Id] = this;
|
||||
break;
|
||||
case historyitem_ChangeTiming:
|
||||
this.timing = data.oldTiming.createDuplicate();
|
||||
break;
|
||||
case historyitem_SetLayout:
|
||||
this.Layout = data.oldLayout;
|
||||
if (this.Layout != null) {
|
||||
this.recalcAll();
|
||||
}
|
||||
break;
|
||||
case historyitem_SetSlideNum:
|
||||
this.num = data.oldNum;
|
||||
break;
|
||||
case historyitem_ShapeAdd:
|
||||
this.cSld.spTree.splice(data.pos, 1);
|
||||
break;
|
||||
case historyitem_SetCSldName:
|
||||
this.cSld.name = data.oldName;
|
||||
break;
|
||||
case historyitem_SetClrMapOverride:
|
||||
this.clrMap = data.oldClrMap;
|
||||
break;
|
||||
case historyitem_SetShow:
|
||||
this.show = data.oldPr;
|
||||
break;
|
||||
case historyitem_SetShowPhAnim:
|
||||
this.showMasterPhAnim = data.oldPr;
|
||||
break;
|
||||
case historyitem_SetShowMasterSp:
|
||||
this.showMasterSp = data.oldPr;
|
||||
break;
|
||||
}
|
||||
},
|
||||
Redo: function (data) {
|
||||
switch (data.Type) {
|
||||
case historyitem_SetMasterTheme:
|
||||
break;
|
||||
case historyitem_SetTxStyles:
|
||||
this.txStyles = data.newPr;
|
||||
break;
|
||||
case historyitem_AddComment:
|
||||
this.comments.splice(data.pos, 0, g_oTableId.Get_ById(data.objectId));
|
||||
editor.sync_AddComment(data.objectId, this.comments[data.pos].Data);
|
||||
break;
|
||||
case historyitem_RemoveComment:
|
||||
this.comments.splice(data.index, 1);
|
||||
editor.sync_RemoveComment(data.id);
|
||||
break;
|
||||
case historyitem_RemoveFromSpTree:
|
||||
this.cSld.spTree.splice(data.index, 1);
|
||||
break;
|
||||
case historyitem_AddToSlideSpTree:
|
||||
this.cSld.spTree.splice(data.pos, 0, g_oTableId.Get_ById(data.objectId));
|
||||
break;
|
||||
case historyitem_AddLayout:
|
||||
break;
|
||||
case historyitem_AddSlideLocks:
|
||||
this.deleteLock = g_oTableId.Get_ById(data.deleteLock);
|
||||
this.backgroundLock = g_oTableId.Get_ById(data.backgroundLock);
|
||||
this.timingLock = g_oTableId.Get_ById(data.timingLock);
|
||||
this.transitionLock = g_oTableId.Get_ById(data.transitionLock);
|
||||
this.layoutLock = g_oTableId.Get_ById(data.layoutLock);
|
||||
break;
|
||||
case historyitem_ChangeBg:
|
||||
this.cSld.Bg = data.newBg;
|
||||
this.recalcInfo.recalculateBackground = true;
|
||||
editor.WordControl.m_oLogicDocument.recalcMap[this.Id] = this;
|
||||
break;
|
||||
case historyitem_ChangeTiming:
|
||||
this.timing = data.newTiming.createDuplicate();
|
||||
break;
|
||||
case historyitem_SetLayout:
|
||||
this.Layout = data.newLayout;
|
||||
this.recalcAll();
|
||||
break;
|
||||
case historyitem_SetSlideNum:
|
||||
this.num = data.newNum;
|
||||
break;
|
||||
case historyitem_ShapeAdd:
|
||||
this.cSld.spTree.splice(data.pos, 0, data.item);
|
||||
break;
|
||||
case historyitem_SetCSldName:
|
||||
this.cSld.name = data.newName;
|
||||
break;
|
||||
case historyitem_SetClrMapOverride:
|
||||
this.clrMap = data.newClrMap;
|
||||
break;
|
||||
case historyitem_SetShow:
|
||||
this.show = data.newPr;
|
||||
break;
|
||||
case historyitem_SetShowPhAnim:
|
||||
this.showMasterPhAnim = data.newPr;
|
||||
break;
|
||||
case historyitem_SetShowMasterSp:
|
||||
this.showMasterSp = data.newPr;
|
||||
break;
|
||||
}
|
||||
},
|
||||
Write_ToBinary2: function (w) {
|
||||
w.WriteLong(historyitem_type_SlideMaster);
|
||||
w.WriteString2(this.Id);
|
||||
},
|
||||
Read_FromBinary2: function (r) {
|
||||
this.Id = r.GetString2();
|
||||
},
|
||||
getAllFonts: function (fonts) {
|
||||
for (var i = 0; i < this.cSld.spTree.length; ++i) {
|
||||
if (typeof this.cSld.spTree[i].getAllFonts === "function") {
|
||||
this.cSld.spTree[i].getAllFonts(fonts);
|
||||
}
|
||||
}
|
||||
},
|
||||
Save_Changes: function (data, w) {
|
||||
w.WriteLong(data.Type);
|
||||
switch (data.Type) {
|
||||
case historyitem_SetMasterTheme:
|
||||
w.WriteString2(data.newPr.Get_Id());
|
||||
break;
|
||||
case historyitem_SetTxStyles:
|
||||
MASTER_STYLES = true;
|
||||
data.newPr.Write_ToBinary2(w);
|
||||
MASTER_STYLES = false;
|
||||
break;
|
||||
case historyitem_AddComment:
|
||||
w.WriteLong(data.pos);
|
||||
w.WriteString2(data.objectId);
|
||||
break;
|
||||
case historyitem_RemoveComment:
|
||||
w.WriteLong(data.index);
|
||||
break;
|
||||
case historyitem_RemoveFromSpTree:
|
||||
w.WriteLong(data.index);
|
||||
break;
|
||||
case historyitem_AddToSlideSpTree:
|
||||
w.WriteLong(data.pos);
|
||||
w.WriteString2(data.objectId);
|
||||
break;
|
||||
case historyitem_AddLayout:
|
||||
w.WriteLong(data.pos);
|
||||
w.WriteString2(data.objectId);
|
||||
break;
|
||||
case historyitem_AddSlideLocks:
|
||||
w.WriteString2(data.deleteLock);
|
||||
w.WriteString2(data.backgroundLock);
|
||||
w.WriteString2(data.timingLock);
|
||||
w.WriteString2(data.transitionLock);
|
||||
w.WriteString2(data.layoutLock);
|
||||
break;
|
||||
case historyitem_ChangeBg:
|
||||
data.newBg.Write_ToBinary2(w);
|
||||
break;
|
||||
case historyitem_ChangeTiming:
|
||||
data.newTiming.Write_ToBinary2(w);
|
||||
break;
|
||||
case historyitem_SetLayout:
|
||||
w.WriteBool(isRealObject(data.newLayout));
|
||||
if (isRealObject(data.newLayout)) {
|
||||
w.WriteString2(data.newLayout.Get_Id());
|
||||
}
|
||||
break;
|
||||
case historyitem_SetSlideNum:
|
||||
w.WriteBool(isRealNumber(data.newNum));
|
||||
if (isRealNumber(data.newNum)) {
|
||||
w.WriteLong(data.newNum);
|
||||
}
|
||||
break;
|
||||
case historyitem_ShapeAdd:
|
||||
w.WriteLong(data.pos);
|
||||
w.WriteString2(data.item.Get_Id());
|
||||
break;
|
||||
case historyitem_SetCSldName:
|
||||
w.WriteBool(typeof data.newName === "string");
|
||||
if (typeof data.newName === "string") {
|
||||
w.WriteString2(data.newName);
|
||||
}
|
||||
break;
|
||||
case historyitem_SetClrMapOverride:
|
||||
w.WriteBool(isRealObject(data.newClrMap));
|
||||
if (isRealObject(data.newClrMap)) {
|
||||
data.newClrMap.Write_ToBinary2(w);
|
||||
}
|
||||
break;
|
||||
case historyitem_SetShow:
|
||||
w.WriteBool(data.newPr);
|
||||
break;
|
||||
case historyitem_SetShowPhAnim:
|
||||
w.WriteBool(data.newPr);
|
||||
break;
|
||||
case historyitem_SetShowMasterSp:
|
||||
w.WriteBool(data.newPr);
|
||||
break;
|
||||
}
|
||||
},
|
||||
Load_Changes: function (r) {
|
||||
var type = r.GetLong();
|
||||
switch (type) {
|
||||
case historyitem_SetMasterTheme:
|
||||
this.Theme = g_oTableId.Get_ById(r.GetString2());
|
||||
break;
|
||||
case historyitem_SetTxStyles:
|
||||
this.txStyles = new CTextStyles();
|
||||
this.txStyles.Read_FromBinary2(r);
|
||||
break;
|
||||
case historyitem_AddComment:
|
||||
var pos = r.GetLong();
|
||||
var id = r.GetString2();
|
||||
this.comments.splice(pos, 0, g_oTableId.Get_ById(id));
|
||||
editor.sync_AddComment(id, this.comments[pos].Data);
|
||||
break;
|
||||
case historyitem_RemoveComment:
|
||||
var comment = this.comments.splice(r.GetLong(), 1)[0];
|
||||
editor.sync_RemoveComment(comment.Id);
|
||||
break;
|
||||
case historyitem_RemoveFromSpTree:
|
||||
this.cSld.spTree.splice(r.GetLong(), 1);
|
||||
break;
|
||||
case historyitem_AddToSlideSpTree:
|
||||
var pos = r.GetLong();
|
||||
var id = r.GetString2();
|
||||
this.cSld.spTree.splice(pos, 0, g_oTableId.Get_ById(id));
|
||||
break;
|
||||
case historyitem_AddLayout:
|
||||
var pos = r.GetLong();
|
||||
var id = r.GetString2();
|
||||
this.sldLayoutLst.splice(pos, 0, g_oTableId.Get_ById(id));
|
||||
break;
|
||||
case historyitem_AddSlideLocks:
|
||||
this.deleteLock = g_oTableId.Get_ById(r.GetString2());
|
||||
this.backgroundLock = g_oTableId.Get_ById(r.GetString2());
|
||||
this.timingLock = g_oTableId.Get_ById(r.GetString2());
|
||||
this.transitionLock = g_oTableId.Get_ById(r.GetString2());
|
||||
this.layoutLock = g_oTableId.Get_ById(r.GetString2());
|
||||
break;
|
||||
case historyitem_ChangeBg:
|
||||
this.cSld.Bg = new CBg();
|
||||
this.cSld.Bg.Read_FromBinary2(r);
|
||||
this.recalcInfo.recalculateBackground = true;
|
||||
editor.WordControl.m_oLogicDocument.recalcMap[this.Id] = this;
|
||||
if (this.cSld.Bg && this.cSld.Bg.bgPr && this.cSld.Bg.bgPr.Fill && this.cSld.Bg.bgPr.Fill.fill instanceof CBlipFill) {
|
||||
CollaborativeEditing.Add_NewImage(this.cSld.Bg.bgPr.Fill.fill.RasterImageId);
|
||||
}
|
||||
break;
|
||||
case historyitem_ChangeTiming:
|
||||
this.timing = new CAscSlideTiming();
|
||||
this.timing.Read_FromBinary2(r);
|
||||
break;
|
||||
case historyitem_SetLayout:
|
||||
if (r.GetBool()) {
|
||||
this.Layout = g_oTableId.Get_ById(r.GetString2());
|
||||
} else {
|
||||
this.Layout = null;
|
||||
}
|
||||
this.recalcAll();
|
||||
break;
|
||||
case historyitem_SetSlideNum:
|
||||
if (r.GetBool()) {
|
||||
this.num = r.GetLong();
|
||||
} else {
|
||||
this.num = null;
|
||||
}
|
||||
break;
|
||||
case historyitem_ShapeAdd:
|
||||
var pos = r.GetLong();
|
||||
var item = g_oTableId.Get_ById(r.GetString2());
|
||||
this.cSld.spTree.splice(pos, 0, item);
|
||||
break;
|
||||
case historyitem_SetCSldName:
|
||||
if (r.GetBool()) {
|
||||
this.cSld.name = r.GetString2();
|
||||
} else {
|
||||
this.cSld.name = null;
|
||||
}
|
||||
break;
|
||||
case historyitem_SetClrMapOverride:
|
||||
if (r.GetBool()) {
|
||||
this.clrMap = new ClrMap();
|
||||
this.clrMap.Read_FromBinary2(r);
|
||||
}
|
||||
break;
|
||||
case historyitem_SetShow:
|
||||
this.show = r.GetBool();
|
||||
break;
|
||||
case historyitem_SetShowPhAnim:
|
||||
this.showMasterPhAnim = r.GetBool();
|
||||
break;
|
||||
case historyitem_SetShowMasterSp:
|
||||
this.showMasterSp = r.GetBool();
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
function CMasterThumbnailDrawer() {
|
||||
this.CanvasImage = null;
|
||||
this.IsRetina = false;
|
||||
this.WidthMM = 0;
|
||||
this.HeightMM = 0;
|
||||
this.WidthPx = 0;
|
||||
this.HeightPx = 0;
|
||||
this.DrawingDocument = null;
|
||||
this.GetThumbnail = function (_master, use_background, use_master_shapes) {
|
||||
var h_px = 40;
|
||||
var w_px = (this.WidthMM * h_px / this.HeightMM) >> 0;
|
||||
this.WidthPx = w_px;
|
||||
this.HeightPx = h_px;
|
||||
if (this.CanvasImage == null) {
|
||||
this.CanvasImage = document.createElement("canvas");
|
||||
}
|
||||
this.CanvasImage.width = w_px;
|
||||
this.CanvasImage.height = h_px;
|
||||
var _ctx = this.CanvasImage.getContext("2d");
|
||||
var g = new CGraphics();
|
||||
g.init(_ctx, w_px, h_px, this.WidthMM, this.HeightMM);
|
||||
g.m_oFontManager = g_fontManager;
|
||||
g.transform(1, 0, 0, 1, 0, 0);
|
||||
var _back_fill = null;
|
||||
var RGBA = {
|
||||
R: 0,
|
||||
G: 0,
|
||||
B: 0,
|
||||
A: 255
|
||||
};
|
||||
var _layout = null;
|
||||
for (var i = 0; i < _master.sldLayoutLst.length; i++) {
|
||||
if (_master.sldLayoutLst[i].type == nSldLtTTitle) {
|
||||
_layout = _master.sldLayoutLst[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
var _theme = _master.Theme;
|
||||
if (_layout != null && _layout.cSld.Bg != null) {
|
||||
if (null != _layout.cSld.Bg.bgPr) {
|
||||
_back_fill = _layout.cSld.Bg.bgPr.Fill;
|
||||
} else {
|
||||
if (_layout.cSld.Bg.bgRef != null) {
|
||||
_layout.cSld.Bg.bgRef.Color.Calculate(_theme, null, _layout, _master, RGBA);
|
||||
RGBA = _layout.cSld.Bg.bgRef.Color.RGBA;
|
||||
_back_fill = _theme.themeElements.fmtScheme.GetFillStyle(_layout.cSld.Bg.bgRef.idx);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (_master != null) {
|
||||
if (_master.cSld.Bg != null) {
|
||||
if (null != _master.cSld.Bg.bgPr) {
|
||||
_back_fill = _master.cSld.Bg.bgPr.Fill;
|
||||
} else {
|
||||
if (_master.cSld.Bg.bgRef != null) {
|
||||
_master.cSld.Bg.bgRef.Color.Calculate(_theme, null, _layout, _master, RGBA);
|
||||
RGBA = _master.cSld.Bg.bgRef.Color.RGBA;
|
||||
_back_fill = _theme.themeElements.fmtScheme.GetFillStyle(_master.cSld.Bg.bgRef.idx);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_back_fill = new CUniFill();
|
||||
_back_fill.fill = new CSolidFill();
|
||||
_back_fill.fill.color.color = new CRGBColor();
|
||||
_back_fill.fill.color.color.RGBA = {
|
||||
R: 255,
|
||||
G: 255,
|
||||
B: 255,
|
||||
A: 255
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_back_fill != null) {
|
||||
_back_fill.calculate(_theme, null, _layout, _master, RGBA);
|
||||
}
|
||||
if (use_background !== false) {
|
||||
DrawBackground(g, _back_fill, this.WidthMM, this.HeightMM);
|
||||
}
|
||||
var _sx = g.m_oCoordTransform.sx;
|
||||
var _sy = g.m_oCoordTransform.sy;
|
||||
if (use_master_shapes !== false) {
|
||||
if (null == _layout) {
|
||||
_master.draw(g);
|
||||
} else {
|
||||
if (_layout.showMasterSp == true || _layout.showMasterSp == undefined) {
|
||||
_master.draw(g);
|
||||
}
|
||||
_layout.draw(g);
|
||||
}
|
||||
}
|
||||
g.reset();
|
||||
g.SetIntegerGrid(true);
|
||||
var _color_w = (7 * w_px / 75) >> 0;
|
||||
var _color_h = (6 * h_px / 55) >> 0;
|
||||
var _color_x = (5 * w_px / 75) >> 0;
|
||||
var _text_x = _color_x / _sx;
|
||||
var _text_y = (22 * h_px / (40 * _sy));
|
||||
var _color_y = (42 * h_px / 55) >> 0;
|
||||
var _color_delta = 1;
|
||||
var _color = new CSchemeColor();
|
||||
for (var i = 0; i < 6; i++) {
|
||||
_ctx.beginPath();
|
||||
_color.id = i;
|
||||
_color.Calculate(_theme, null, null, _master, RGBA);
|
||||
g.b_color1(_color.RGBA.R, _color.RGBA.G, _color.RGBA.B, 255);
|
||||
_ctx.fillRect(_color_x, _color_y, _color_w, _color_h);
|
||||
_color_x += (_color_w + _color_delta);
|
||||
}
|
||||
_ctx.beginPath();
|
||||
var _api = this.DrawingDocument.m_oWordControl.m_oApi;
|
||||
History.TurnOff();
|
||||
var _oldTurn = _api.isViewMode;
|
||||
_api.isViewMode = true;
|
||||
var par = new Paragraph(this.DrawingDocument, _api.WordControl.m_oLogicDocument, 0, _text_x, _text_y, 1000, 1000);
|
||||
par.Cursor_MoveToStartPos();
|
||||
_color.id = 15;
|
||||
_color.Calculate(_theme, null, null, _master, RGBA);
|
||||
var _paraPr = new CParaPr();
|
||||
par.Pr = _paraPr;
|
||||
var _textPr1 = new CTextPr();
|
||||
_textPr1.FontFamily = {
|
||||
Name: _theme.themeElements.fontScheme.majorFont.latin,
|
||||
Index: -1
|
||||
};
|
||||
_textPr1.FontSize = 250;
|
||||
_textPr1.Color = new CDocumentColor(_color.RGBA.R, _color.RGBA.G, _color.RGBA.B);
|
||||
var _textPr2 = new CTextPr();
|
||||
_textPr2.FontFamily = {
|
||||
Name: _theme.themeElements.fontScheme.minorFont.latin,
|
||||
Index: -1
|
||||
};
|
||||
_textPr2.FontSize = 250;
|
||||
par.Add(new ParaTextPr(_textPr1));
|
||||
par.Add(new ParaText("A"));
|
||||
par.Add(new ParaTextPr(_textPr2));
|
||||
par.Add(new ParaText("a"));
|
||||
par.Recalculate_Page(0);
|
||||
par.Lines[0].Y = 0;
|
||||
var old_marks = _api.ShowParaMarks;
|
||||
_api.ShowParaMarks = false;
|
||||
par.Draw(0, g);
|
||||
_api.ShowParaMarks = old_marks;
|
||||
History.TurnOn();
|
||||
_api.isViewMode = _oldTurn;
|
||||
try {
|
||||
return this.CanvasImage.toDataURL("image/png");
|
||||
} catch(err) {
|
||||
this.CanvasImage = null;
|
||||
if (undefined === use_background && undefined === use_master_shapes) {
|
||||
return this.GetThumbnail(_master, true, false);
|
||||
} else {
|
||||
if (use_background && !use_master_shapes) {
|
||||
return this.GetThumbnail(_master, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
};
|
||||
}
|
||||
520
OfficeWeb/sdk/PowerPoint/Editor/Format/Spelling.js
Normal file
520
OfficeWeb/sdk/PowerPoint/Editor/Format/Spelling.js
Normal file
@@ -0,0 +1,520 @@
|
||||
/*
|
||||
* (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 CDocumentSpelling() {
|
||||
this.Paragraphs = new Object();
|
||||
this.Words = new Object();
|
||||
this.CheckPara = new Object();
|
||||
this.CurPara = new Object();
|
||||
}
|
||||
CDocumentSpelling.prototype = {
|
||||
Add_Paragraph: function (Id, Para) {
|
||||
this.Paragraphs[Id] = Para;
|
||||
},
|
||||
Remove_Paragraph: function (Id) {
|
||||
delete this.Paragraphs[Id];
|
||||
},
|
||||
Check_Word: function (Word) {
|
||||
if (undefined != this.Words[Word]) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
Add_Word: function (Word) {
|
||||
this.Words[Word] = true;
|
||||
for (var Id in this.Paragraphs) {
|
||||
var Para = this.Paragraphs[Id];
|
||||
Para.SpellChecker.Ignore(Word);
|
||||
}
|
||||
},
|
||||
Add_ParagraphToCheck: function (Id, Para) {
|
||||
this.CheckPara[Id] = Para;
|
||||
},
|
||||
Continue_CheckSpelling: function () {
|
||||
var Counter = 0;
|
||||
for (var Id in this.CheckPara) {
|
||||
var Para = this.CheckPara[Id];
|
||||
Para.Continue_CheckSpelling();
|
||||
delete this.CheckPara[Id];
|
||||
Counter++;
|
||||
if (Counter > 20) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (var Id in this.CurPara) {
|
||||
var Para = this.CurPara[Id];
|
||||
delete this.CurPara[Id];
|
||||
Para.SpellChecker.Reset_ElementsWithCurPos();
|
||||
Para.SpellChecker.Check();
|
||||
}
|
||||
},
|
||||
Add_CurPara: function (Id, Para) {
|
||||
this.CurPara[Id] = Para;
|
||||
}
|
||||
};
|
||||
function CParaSpellChecker() {
|
||||
this.Elements = new Array();
|
||||
this.RecalcId = -1;
|
||||
this.ParaId = -1;
|
||||
}
|
||||
CParaSpellChecker.prototype = {
|
||||
Clear: function () {
|
||||
this.Elements = new Array();
|
||||
},
|
||||
Add: function (StartPos, EndPos, Word, Lang) {
|
||||
this.Elements.push(new CParaSpellCheckerElement(StartPos, EndPos, Word, Lang));
|
||||
},
|
||||
Check: function () {
|
||||
var Paragraph = g_oTableId.Get_ById(this.ParaId);
|
||||
var bCurrent = Paragraph.Is_ThisElementCurrent();
|
||||
var CurPos = -1;
|
||||
if (true === bCurrent && false === Paragraph.Selection.Use) {
|
||||
CurPos = Paragraph.CurPos.ContentPos;
|
||||
}
|
||||
var usrWords = new Array();
|
||||
var usrLang = new Array();
|
||||
var Count = this.Elements.length;
|
||||
for (var Index = 0; Index < Count; Index++) {
|
||||
var Element = this.Elements[Index];
|
||||
Element.CurPos = false;
|
||||
if (1 >= Element.Word.length) {
|
||||
Element.Checked = true;
|
||||
} else {
|
||||
if (null === Element.Checked && -1 != CurPos && Element.EndPos >= CurPos - 1 && Element.StartPos <= CurPos) {
|
||||
Element.Checked = true;
|
||||
Element.CurPos = true;
|
||||
editor.WordControl.m_oLogicDocument.Spelling.Add_CurPara(this.ParaId, g_oTableId.Get_ById(this.ParaId));
|
||||
}
|
||||
}
|
||||
if (null === Element.Checked) {
|
||||
usrWords.push(this.Elements[Index].Word);
|
||||
usrLang.push(this.Elements[Index].Lang);
|
||||
}
|
||||
}
|
||||
if (0 < usrWords.length) {
|
||||
spellCheck(editor, {
|
||||
"type": "spell",
|
||||
"ParagraphId": this.ParaId,
|
||||
"RecalcId": this.RecalcId,
|
||||
"ElementId": 0,
|
||||
"usrWords": usrWords,
|
||||
"usrLang": usrLang
|
||||
});
|
||||
}
|
||||
},
|
||||
Check_CallBack: function (RecalcId, UsrCorrect) {
|
||||
if (RecalcId == this.RecalcId) {
|
||||
var DocumentSpelling = editor.WordControl.m_oLogicDocument.Spelling;
|
||||
var Count = this.Elements.length;
|
||||
var Index2 = 0;
|
||||
for (var Index = 0; Index < Count; Index++) {
|
||||
var Element = this.Elements[Index];
|
||||
if (null === Element.Checked && true != Element.Checked) {
|
||||
if (true === DocumentSpelling.Check_Word(Element.Word)) {
|
||||
Element.Checked = true;
|
||||
} else {
|
||||
Element.Checked = UsrCorrect[Index2];
|
||||
}
|
||||
Index2++;
|
||||
}
|
||||
}
|
||||
this.Internal_UpdateParagraphState();
|
||||
}
|
||||
},
|
||||
Internal_UpdateParagraphState: function () {
|
||||
var DocumentSpelling = editor.WordControl.m_oLogicDocument.Spelling;
|
||||
var bMisspeled = false;
|
||||
var Count = this.Elements.length;
|
||||
for (var Index = 0; Index < Count; Index++) {
|
||||
if (false === this.Elements[Index].Checked) {
|
||||
bMisspeled = true;
|
||||
}
|
||||
}
|
||||
if (true === bMisspeled) {
|
||||
DocumentSpelling.Add_Paragraph(this.ParaId, g_oTableId.Get_ById(this.ParaId));
|
||||
} else {
|
||||
DocumentSpelling.Remove_Paragraph(this.ParaId);
|
||||
}
|
||||
},
|
||||
Check_Spelling: function (Pos) {
|
||||
var Count = this.Elements.length;
|
||||
for (var Index = 0; Index < Count; Index++) {
|
||||
var Element = this.Elements[Index];
|
||||
if (Element.StartPos > Pos) {
|
||||
break;
|
||||
} else {
|
||||
if (Element.EndPos < Pos) {
|
||||
continue;
|
||||
} else {
|
||||
return (Element.Checked === null ? true : Element.Checked);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
Document_UpdateInterfaceState: function (StartPos, EndPos) {
|
||||
var Count = this.Elements.length;
|
||||
var FoundElement = null;
|
||||
var FoundIndex = -1;
|
||||
for (var Index = 0; Index < Count; Index++) {
|
||||
var Element = this.Elements[Index];
|
||||
if (Element.StartPos <= EndPos && Element.EndPos >= StartPos && false === Element.Checked) {
|
||||
if (null != FoundElement) {
|
||||
FoundElement = null;
|
||||
break;
|
||||
} else {
|
||||
FoundIndex = Index;
|
||||
FoundElement = Element;
|
||||
}
|
||||
}
|
||||
}
|
||||
var Word = "";
|
||||
var Variants = null;
|
||||
var Checked = null;
|
||||
if (null != FoundElement) {
|
||||
Word = FoundElement.Word;
|
||||
Variants = FoundElement.Variants;
|
||||
Checked = FoundElement.Checked;
|
||||
if (null === Variants) {
|
||||
spellCheck(editor, {
|
||||
"type": "suggest",
|
||||
"ParagraphId": this.ParaId,
|
||||
"RecalcId": this.RecalcId,
|
||||
"ElementId": FoundIndex,
|
||||
"usrWords": [Word],
|
||||
"usrLang": [FoundElement.Lang]
|
||||
});
|
||||
}
|
||||
}
|
||||
if (null === Checked) {
|
||||
Checked = true;
|
||||
}
|
||||
editor.sync_SpellCheckCallback(Word, Checked, Variants, this.ParaId, FoundIndex);
|
||||
},
|
||||
Check_CallBack2: function (RecalcId, ElementId, usrVariants) {
|
||||
if (RecalcId == this.RecalcId) {
|
||||
this.Elements[ElementId].Variants = usrVariants[0];
|
||||
}
|
||||
},
|
||||
Ignore: function (Word) {
|
||||
var Count = this.Elements.length;
|
||||
for (var Index = 0; Index < Count; Index++) {
|
||||
var Element = this.Elements[Index];
|
||||
if (false === Element.Checked && Word === Element.Word) {
|
||||
Element.Checked = true;
|
||||
}
|
||||
}
|
||||
this.Internal_UpdateParagraphState();
|
||||
},
|
||||
Update_OnAdd: function (Paragraph, Pos, Item) {
|
||||
var ItemType = Item.Type;
|
||||
var Left = null;
|
||||
var Right = null;
|
||||
var Count = this.Elements.length;
|
||||
for (var Index = 0; Index < Count; Index++) {
|
||||
var Element = this.Elements[Index];
|
||||
if (Element.StartPos > Pos) {
|
||||
if (null == Right) {
|
||||
Right = Element;
|
||||
}
|
||||
Element.StartPos++;
|
||||
}
|
||||
if (Element.EndPos >= Pos) {
|
||||
Element.EndPos++;
|
||||
} else {
|
||||
Left = Element;
|
||||
}
|
||||
}
|
||||
var RecalcInfo = Paragraph.RecalcInfo;
|
||||
RecalcInfo.Update_Spell_OnChange(Pos, 1, true);
|
||||
if (para_TextPr != ItemType) {
|
||||
var StartPos = (null === Left ? 0 : Left.StartPos);
|
||||
var EndPos = (null === Right ? Paragraph.Content.length - 1 : Right.EndPos);
|
||||
RecalcInfo.Set_Type_0_Spell(pararecalc_0_Spell_Pos, StartPos, EndPos);
|
||||
} else {
|
||||
if (undefined != Item.Value.Caps) {
|
||||
RecalcInfo.Set_Type_0_Spell(pararecalc_0_Spell_All);
|
||||
} else {
|
||||
if (para_TextPr === ItemType) {
|
||||
RecalcInfo.Set_Type_0_Spell(pararecalc_0_Spell_Lang);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
Update_OnRemove: function (Paragraph, Pos, Count) {
|
||||
var Left = null;
|
||||
var Right = null;
|
||||
var _Count = this.Elements.length;
|
||||
for (var Index = 0; Index < _Count; Index++) {
|
||||
var Element = this.Elements[Index];
|
||||
if (Element.StartPos > Pos) {
|
||||
if (null == Right) {
|
||||
Right = Element;
|
||||
}
|
||||
if (Element.StartPos > Pos + Count) {
|
||||
Element.StartPos -= Count;
|
||||
} else {
|
||||
Element.StartPos = Pos;
|
||||
}
|
||||
}
|
||||
if (Element.EndPos >= Pos) {
|
||||
if (Element.EndPos >= Pos + Count) {
|
||||
Element.EndPos -= Count;
|
||||
} else {
|
||||
Element.EndPos = Math.max(0, Pos - 1);
|
||||
}
|
||||
} else {
|
||||
Left = Element;
|
||||
}
|
||||
}
|
||||
var StartPos = (null === Left ? 0 : Left.StartPos);
|
||||
var EndPos = (null === Right ? Paragraph.Content.length - 1 : Right.EndPos);
|
||||
var RecalcInfo = Paragraph.RecalcInfo;
|
||||
RecalcInfo.Update_Spell_OnChange(Pos, Count, false);
|
||||
RecalcInfo.Set_Type_0_Spell(pararecalc_0_Spell_Pos, StartPos, EndPos);
|
||||
},
|
||||
Get_ElementsBeforeAfterPos: function (StartPos, EndPos) {
|
||||
var Before = new Array();
|
||||
var After = new Array();
|
||||
var Count = this.Elements.length;
|
||||
for (var Index = 0; Index < Count; Index++) {
|
||||
var Element = this.Elements[Index];
|
||||
if (Element.EndPos < StartPos) {
|
||||
Before.push(Element);
|
||||
} else {
|
||||
if (Element.StartPos >= EndPos) {
|
||||
After.push(Element);
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
Before: Before,
|
||||
After: After
|
||||
};
|
||||
},
|
||||
Reset_ElementsWithCurPos: function () {
|
||||
var Count = this.Elements.length;
|
||||
for (var Index = 0; Index < Count; Index++) {
|
||||
var Element = this.Elements[Index];
|
||||
if (true === Element.CurPos) {
|
||||
Element.Checked = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
function CParaSpellCheckerElement(StartPos, EndPos, Word, Lang) {
|
||||
this.StartPos = StartPos;
|
||||
this.EndPos = EndPos;
|
||||
this.Word = Word;
|
||||
this.Lang = Lang;
|
||||
this.Checked = null;
|
||||
this.CurPos = false;
|
||||
this.Variants = null;
|
||||
}
|
||||
function SpellCheck_CallBack(Obj) {
|
||||
if (undefined != Obj && undefined != Obj["ParagraphId"]) {
|
||||
var ParaId = Obj["ParagraphId"];
|
||||
var Paragraph = g_oTableId.Get_ById(ParaId);
|
||||
var Type = Obj["type"];
|
||||
if (null != Paragraph) {
|
||||
if ("spell" === Type) {
|
||||
Paragraph.SpellChecker.Check_CallBack(Obj["RecalcId"], Obj["usrCorrect"]);
|
||||
Paragraph.ReDraw();
|
||||
} else {
|
||||
if ("suggest" === Type) {
|
||||
Paragraph.SpellChecker.Check_CallBack2(Obj["RecalcId"], Obj["ElementId"], Obj["usrSuggest"]);
|
||||
editor.sync_SpellCheckVariantsFound();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
CTable.prototype.Restart_CheckSpelling = function () {
|
||||
var RowsCount = this.Content.length;
|
||||
for (var CurRow = 0; CurRow < RowsCount; CurRow++) {
|
||||
var Row = this.Content[CurRow];
|
||||
var CellsCount = Row.Get_CellsCount();
|
||||
for (var CurCell = 0; CurCell < CellsCount; CurCell++) {
|
||||
Row.Get_Cell(CurCell).Content.Restart_CheckSpelling();
|
||||
}
|
||||
}
|
||||
};
|
||||
Paragraph.prototype.Restart_CheckSpelling = function () {
|
||||
this.RecalcInfo.Set_Type_0_Spell(pararecalc_0_Spell_All);
|
||||
this.CompiledPr.NeedRecalc = true;
|
||||
this.LogicDocument.Spelling.Add_ParagraphToCheck(this.Get_Id(), this);
|
||||
};
|
||||
Paragraph.prototype.Internal_CheckSpelling = function () {
|
||||
if (pararecalc_0_Spell_None !== this.RecalcInfo.Recalc_0_Spell.Type) {
|
||||
if (null != g_oTableId.Get_ById(this.Get_Id())) {
|
||||
this.LogicDocument.Spelling.Add_ParagraphToCheck(this.Get_Id(), this);
|
||||
}
|
||||
}
|
||||
};
|
||||
Paragraph.prototype.Continue_CheckSpelling = function () {
|
||||
var CheckLang = false;
|
||||
if (pararecalc_0_Spell_None === this.RecalcInfo.Recalc_0_Spell.Type) {
|
||||
return;
|
||||
} else {
|
||||
if (pararecalc_0_Spell_All === this.RecalcInfo.Recalc_0_Spell.Type) {
|
||||
this.SpellChecker.Clear();
|
||||
var Pr = this.Get_CompiledPr();
|
||||
var CurTextPr = Pr.TextPr;
|
||||
var CurLcid = CurTextPr.Lang.Val;
|
||||
var bWord = false;
|
||||
var sWord = "";
|
||||
var nWordStart = 0;
|
||||
var nWordEnd = 0;
|
||||
var ContentLength = this.Content.length;
|
||||
for (var Pos = 0; Pos < ContentLength; Pos++) {
|
||||
var Item = this.Content[Pos];
|
||||
if (para_TextPr === Item.Type) {
|
||||
CurTextPr = this.Internal_CalculateTextPr(Pos);
|
||||
if (true === bWord && CurLcid != CurTextPr.Lang.Val) {
|
||||
bWord = false;
|
||||
this.SpellChecker.Add(nWordStart, nWordEnd, sWord, CurLcid);
|
||||
}
|
||||
CurLcid = CurTextPr.Lang.Val;
|
||||
continue;
|
||||
} else {
|
||||
if (para_Text === Item.Type && false === Item.Is_Punctuation() && false === Item.Is_NBSP() && false === Item.Is_Number() && false === Item.Is_SpecialSymbol()) {
|
||||
if (false === bWord) {
|
||||
bWord = true;
|
||||
nWordStart = Pos;
|
||||
nWordEnd = Pos;
|
||||
if (true != CurTextPr.Caps) {
|
||||
sWord = Item.Value;
|
||||
} else {
|
||||
sWord = Item.Value.toUpperCase();
|
||||
}
|
||||
} else {
|
||||
if (true != CurTextPr.Caps) {
|
||||
sWord += Item.Value;
|
||||
} else {
|
||||
sWord += Item.Value.toUpperCase();
|
||||
}
|
||||
nWordEnd = Pos;
|
||||
}
|
||||
} else {
|
||||
if (true === bWord) {
|
||||
bWord = false;
|
||||
this.SpellChecker.Add(nWordStart, nWordEnd, sWord, CurLcid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
CheckLang = false;
|
||||
} else {
|
||||
if (pararecalc_0_Spell_Pos === this.RecalcInfo.Recalc_0_Spell.Type) {
|
||||
var StartPos = this.RecalcInfo.Recalc_0_Spell.StartPos;
|
||||
var EndPos = Math.min(this.RecalcInfo.Recalc_0_Spell.EndPos, this.Content.length - 1);
|
||||
var BoundElements = this.SpellChecker.Get_ElementsBeforeAfterPos(StartPos, EndPos);
|
||||
this.SpellChecker.Clear();
|
||||
var CountBefore = BoundElements.Before.length;
|
||||
for (var Pos = 0; Pos < CountBefore; Pos++) {
|
||||
this.SpellChecker.Elements.push(BoundElements.Before[Pos]);
|
||||
}
|
||||
var Pr = this.Get_CompiledPr();
|
||||
var CurTextPr = Pr.TextPr;
|
||||
var CurLcid = CurTextPr.Lang.Val;
|
||||
var bWord = false;
|
||||
var sWord = "";
|
||||
var nWordStart = 0;
|
||||
var nWordEnd = 0;
|
||||
for (var Pos = StartPos; Pos <= EndPos; Pos++) {
|
||||
var Item = this.Content[Pos];
|
||||
if (para_TextPr === Item.Type) {
|
||||
CurTextPr = this.Internal_CalculateTextPr(Pos);
|
||||
if (true === bWord && CurLcid != CurTextPr.Lang.Val) {
|
||||
bWord = false;
|
||||
this.SpellChecker.Add(nWordStart, nWordEnd, sWord, CurLcid);
|
||||
}
|
||||
CurLcid = CurTextPr.Lang.Val;
|
||||
continue;
|
||||
} else {
|
||||
if (para_Text === Item.Type && false === Item.Is_Punctuation() && false === Item.Is_NBSP()) {
|
||||
if (false === bWord) {
|
||||
bWord = true;
|
||||
nWordStart = Pos;
|
||||
nWordEnd = Pos;
|
||||
if (true != CurTextPr.Caps) {
|
||||
sWord = Item.Value;
|
||||
} else {
|
||||
sWord = Item.Value.toUpperCase();
|
||||
}
|
||||
} else {
|
||||
if (true != CurTextPr.Caps) {
|
||||
sWord += Item.Value;
|
||||
} else {
|
||||
sWord += Item.Value.toUpperCase();
|
||||
}
|
||||
nWordEnd = Pos;
|
||||
}
|
||||
} else {
|
||||
if (true === bWord) {
|
||||
bWord = false;
|
||||
this.SpellChecker.Add(nWordStart, nWordEnd, sWord, CurLcid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (true === bWord) {
|
||||
this.SpellChecker.Add(nWordStart, nWordEnd, sWord, CurLcid);
|
||||
}
|
||||
var CountAfter = BoundElements.After.length;
|
||||
for (var Pos = 0; Pos < CountAfter; Pos++) {
|
||||
this.SpellChecker.Elements.push(BoundElements.After[Pos]);
|
||||
}
|
||||
CheckLang = true;
|
||||
} else {
|
||||
if (pararecalc_0_Spell_Lang === this.RecalcInfo.Recalc_0_Spell.Type) {
|
||||
CheckLang = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (true === CheckLang) {
|
||||
var WordsCount = this.SpellChecker.Elements.length;
|
||||
for (var ElemId = 0; ElemId < WordsCount; ElemId++) {
|
||||
var Element = this.SpellChecker.Elements[ElemId];
|
||||
var CurLang = Element.Lang;
|
||||
var Lang = this.Internal_GetLang(Element.EndPos);
|
||||
if (CurLang != Lang.Val) {
|
||||
Element.Lang = Lang.Val;
|
||||
Element.Checked = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.SpellChecker.RecalcId = this.LogicDocument.RecalcId;
|
||||
this.SpellChecker.ParaId = this.Get_Id();
|
||||
this.SpellChecker.Check();
|
||||
this.RecalcInfo.Recalc_0_Spell.Type = pararecalc_0_Spell_None;
|
||||
};
|
||||
15680
OfficeWeb/sdk/PowerPoint/Editor/Format/Table.js
Normal file
15680
OfficeWeb/sdk/PowerPoint/Editor/Format/Table.js
Normal file
File diff suppressed because it is too large
Load Diff
782
OfficeWeb/sdk/PowerPoint/Editor/Format/TextBody.js
Normal file
782
OfficeWeb/sdk/PowerPoint/Editor/Format/TextBody.js
Normal file
@@ -0,0 +1,782 @@
|
||||
/*
|
||||
* (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 field_type_slidenum = 0;
|
||||
var field_type_datetime = 1;
|
||||
var field_type_datetime1 = 2;
|
||||
var field_type_datetime2 = 3;
|
||||
var field_type_datetime3 = 4;
|
||||
var field_type_datetime4 = 5;
|
||||
var field_type_datetime5 = 6;
|
||||
var field_type_datetime6 = 7;
|
||||
var field_type_datetime7 = 8;
|
||||
var field_type_datetime8 = 9;
|
||||
var field_type_datetime9 = 10;
|
||||
var field_type_datetime10 = 11;
|
||||
var field_type_datetime11 = 12;
|
||||
var field_type_datetime12 = 13;
|
||||
var field_type_datetime13 = 14;
|
||||
var pHText = [];
|
||||
pHText[0] = [];
|
||||
pHText[0][phType_body] = "Slide text";
|
||||
pHText[0][phType_chart] = "Chart";
|
||||
pHText[0][phType_clipArt] = "ClipArt";
|
||||
pHText[0][phType_ctrTitle] = "Slide title";
|
||||
pHText[0][phType_dgm] = "Diagram";
|
||||
pHText[0][phType_dt] = "Date and time";
|
||||
pHText[0][phType_ftr] = "Footer";
|
||||
pHText[0][phType_hdr] = "Header";
|
||||
pHText[0][phType_media] = "Media";
|
||||
pHText[0][phType_obj] = "Slide text";
|
||||
pHText[0][phType_pic] = "Picture";
|
||||
pHText[0][phType_sldImg] = "Image";
|
||||
pHText[0][phType_sldNum] = "Slide number";
|
||||
pHText[0][phType_subTitle] = "Slide subtitle";
|
||||
pHText[0][phType_tbl] = "Table";
|
||||
pHText[0][phType_title] = "Slide title";
|
||||
var field_months = [];
|
||||
field_months[0] = [];
|
||||
field_months[0][0] = "января";
|
||||
field_months[0][1] = "февраля";
|
||||
field_months[0][2] = "марта";
|
||||
field_months[0][3] = "апреля";
|
||||
field_months[0][4] = "мая";
|
||||
field_months[0][5] = "июня";
|
||||
field_months[0][6] = "июля";
|
||||
field_months[0][7] = "августа";
|
||||
field_months[0][8] = "сентября";
|
||||
field_months[0][9] = "октября";
|
||||
field_months[0][10] = "ноября";
|
||||
field_months[0][11] = "декабря";
|
||||
var nOTClip = 0;
|
||||
var nOTEllipsis = 1;
|
||||
var nOTOwerflow = 2;
|
||||
var nTextATB = 0;
|
||||
var nTextATCtr = 1;
|
||||
var nTextATDist = 2;
|
||||
var nTextATJust = 3;
|
||||
var nTextATT = 4;
|
||||
var nVertTTeaVert = 0;
|
||||
var nVertTThorz = 1;
|
||||
var nVertTTmongolianVert = 2;
|
||||
var nVertTTvert = 3;
|
||||
var nVertTTvert270 = 4;
|
||||
var nVertTTwordArtVert = 5;
|
||||
var nVertTTwordArtVertRtl = 6;
|
||||
var nTWTNone = 0;
|
||||
var nTWTSquare = 1;
|
||||
function CTextBody(shape) {
|
||||
this.bodyPr = new CBodyPr();
|
||||
this.lstStyle = new TextListStyle();
|
||||
this.content2 = null;
|
||||
this.compiledBodyPr = new CBodyPr();
|
||||
this.recalcInfo = {
|
||||
recalculateBodyPr: true,
|
||||
recalculateContent2: true
|
||||
};
|
||||
this.textPropsForRecalc = [];
|
||||
this.bRecalculateNumbering = true;
|
||||
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 = {
|
||||
getSearchResults: function (str) {
|
||||
return this.content != null ? this.content.getSearchResults(str) : [];
|
||||
},
|
||||
Get_Id: function () {
|
||||
return this.Id;
|
||||
},
|
||||
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;
|
||||
},
|
||||
Write_ToBinary2: function (w) {
|
||||
w.WriteLong(historyitem_type_TextBody);
|
||||
w.WriteString2(this.Id);
|
||||
},
|
||||
Read_FromBinary2: function (r) {
|
||||
this.Id = r.GetString2();
|
||||
},
|
||||
recalculate: function () {},
|
||||
recalcAll: function () {
|
||||
this.recalcInfo = {
|
||||
recalculateBodyPr: true,
|
||||
recalculateContent2: true
|
||||
};
|
||||
this.bRecalculateNumbering = true;
|
||||
var content = this.content;
|
||||
for (var i = 0; i < content.Content.length; ++i) {
|
||||
content.Content[i].Recalc_CompiledPr();
|
||||
content.Content[i].RecalcInfo.Recalc_0_Type = pararecalc_0_All;
|
||||
}
|
||||
this.arrStyles = [];
|
||||
content.arrStyles = [];
|
||||
},
|
||||
recalcColors: function () {
|
||||
this.content.recalcColors();
|
||||
},
|
||||
recalculateBodyPr: function () {
|
||||
if (this.recalcInfo.recalculateBodyPr) {
|
||||
this.compiledBodyPr.setDefault();
|
||||
if (this.shape.isPlaceholder()) {
|
||||
var hierarchy = this.shape.getHierarchy();
|
||||
for (var i = hierarchy.length - 1; i > -1; --i) {
|
||||
if (isRealObject(hierarchy[i]) && isRealObject(hierarchy[i].txBody) && isRealObject(hierarchy[i].txBody.bodyPr)) {
|
||||
this.compiledBodyPr.merge(hierarchy[i].txBody.bodyPr);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isRealObject(this.bodyPr)) {
|
||||
this.compiledBodyPr.merge(this.bodyPr);
|
||||
}
|
||||
}
|
||||
},
|
||||
Refresh_RecalcData: function () {},
|
||||
updateSelectionState: function (drawingDocument) {
|
||||
var Doc = this.content;
|
||||
if (true === Doc.Is_SelectionUse() && !Doc.Selection_IsEmpty()) {
|
||||
drawingDocument.UpdateTargetTransform(this.shape.transformText);
|
||||
drawingDocument.TargetEnd();
|
||||
drawingDocument.SelectEnabled(true);
|
||||
drawingDocument.SelectClear();
|
||||
this.content.Selection_Draw_Page(this.shape.parent ? this.shape.parent.num : this.shape.chartGroup.parent.num);
|
||||
drawingDocument.SelectShow();
|
||||
} else {
|
||||
drawingDocument.UpdateTargetTransform(this.shape.transformText);
|
||||
drawingDocument.TargetShow();
|
||||
drawingDocument.SelectEnabled(false);
|
||||
}
|
||||
},
|
||||
isEmpty: function () {
|
||||
return this.content.Is_Empty();
|
||||
},
|
||||
OnContentReDraw: function () {},
|
||||
calculateContent: function () {
|
||||
var parent_object = this.shape.getParentObjects();
|
||||
for (var i = 0; i < this.textPropsForRecalc.length; ++i) {
|
||||
var props = this.textPropsForRecalc[i].Value;
|
||||
if (props && props.FontFamily && typeof props.FontFamily.Name === "string" && isThemeFont(props.FontFamily.Name)) {
|
||||
props.FontFamily.themeFont = props.FontFamily.Name;
|
||||
props.FontFamily.Name = getFontInfo(props.FontFamily.Name)(parent_object.theme.themeElements.fontScheme);
|
||||
}
|
||||
var TextPr = props;
|
||||
var parents = parent_object;
|
||||
if (isRealObject(TextPr) && isRealObject(TextPr.unifill) && isRealObject(TextPr.unifill.fill)) {
|
||||
TextPr.unifill.calculate(parents.theme, parents.slide, parents.layout, parents.master, {
|
||||
R: 0,
|
||||
G: 0,
|
||||
B: 0,
|
||||
A: 255
|
||||
});
|
||||
var _rgba = TextPr.unifill.getRGBAColor();
|
||||
TextPr.Color = new CDocumentColor(_rgba.R, _rgba.G, _rgba.B);
|
||||
}
|
||||
if (isRealObject(props.FontFamily) && typeof props.FontFamily.Name === "string") {
|
||||
TextPr.RFonts.Ascii = {
|
||||
Name: TextPr.FontFamily.Name,
|
||||
Index: -1
|
||||
};
|
||||
TextPr.RFonts.CS = {
|
||||
Name: TextPr.FontFamily.Name,
|
||||
Index: -1
|
||||
};
|
||||
TextPr.RFonts.HAnsi = {
|
||||
Name: TextPr.FontFamily.Name,
|
||||
Index: -1
|
||||
};
|
||||
}
|
||||
}
|
||||
this.textPropsForRecalc.length = 0;
|
||||
if (this.bRecalculateNumbering) {
|
||||
this.content.RecalculateNumbering();
|
||||
this.bRecalculateNumbering = false;
|
||||
}
|
||||
this.content.Set_StartPage(0);
|
||||
if (this.textFieldFlag) {
|
||||
this.textFieldFlag = false;
|
||||
if (this.shape && this.shape.isPlaceholder()) {
|
||||
var _ph_type = this.shape.getPlaceholderType();
|
||||
switch (_ph_type) {
|
||||
case phType_dt:
|
||||
var _cur_date = new Date();
|
||||
var _cur_year = _cur_date.getFullYear();
|
||||
var _cur_month = _cur_date.getMonth();
|
||||
var _cur_month_day = _cur_date.getDate();
|
||||
var _cur_week_day = _cur_date.getDay();
|
||||
var _cur_hour = _cur_date.getHours();
|
||||
var _cur_minute = _cur_date.getMinutes();
|
||||
var _cur_second = _cur_date.getSeconds();
|
||||
var _text_string = "";
|
||||
switch (this.fieldType) {
|
||||
default:
|
||||
_text_string += (_cur_month_day > 9 ? _cur_month_day : "0" + _cur_month_day) + "." + ((_cur_month + 1) > 9 ? (_cur_month + 1) : "0" + (_cur_month + 1)) + "." + _cur_year;
|
||||
break;
|
||||
}
|
||||
var par = this.content.Content[0];
|
||||
var EndPos = par.Internal_GetEndPos();
|
||||
var _history_status = History.Is_On();
|
||||
if (_history_status) {
|
||||
History.TurnOff();
|
||||
}
|
||||
for (var _text_index = 0; _text_index < _text_string.length; ++_text_index) {
|
||||
if (_text_string[_text_index] != " ") {
|
||||
par.Internal_Content_Add(EndPos, new ParaText(_text_string[_text_index]));
|
||||
} else {
|
||||
par.Internal_Content_Add(EndPos, new ParaSpace(1));
|
||||
}++EndPos;
|
||||
}
|
||||
if (_history_status) {
|
||||
History.TurnOn();
|
||||
}
|
||||
this.calculateContent();
|
||||
break;
|
||||
case phType_sldNum:
|
||||
if (this.shape.parent instanceof Slide) {
|
||||
var _text_string = "" + (this.shape.parent.num + 1);
|
||||
par = this.content.Content[0];
|
||||
EndPos = par.Internal_GetEndPos();
|
||||
_history_status = History.Is_On();
|
||||
if (_history_status) {
|
||||
History.TurnOff();
|
||||
}
|
||||
for (_text_index = 0; _text_index < _text_string.length; ++_text_index) {
|
||||
if (_text_string[_text_index] != " ") {
|
||||
par.Internal_Content_Add(EndPos, new ParaText(_text_string[_text_index]));
|
||||
} else {
|
||||
par.Internal_Content_Add(EndPos, new ParaSpace(1));
|
||||
}++EndPos;
|
||||
}
|
||||
if (_history_status) {
|
||||
History.TurnOn();
|
||||
}
|
||||
this.calculateContent();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.bodyPr.textFit !== null && typeof this.bodyPr.textFit === "object") {
|
||||
if (this.bodyPr.textFit.type === text_fit_NormAuto) {
|
||||
var text_fit = this.bodyPr.textFit;
|
||||
var font_scale, spacing_scale;
|
||||
if (!isNaN(text_fit.fontScale) && typeof text_fit.fontScale === "number") {
|
||||
font_scale = text_fit.fontScale / 100000;
|
||||
}
|
||||
if (!isNaN(text_fit.lnSpcReduction) && typeof text_fit.lnSpcReduction === "number") {
|
||||
spacing_scale = text_fit.lnSpcReduction / 100000;
|
||||
}
|
||||
if (!isNaN(font_scale) && typeof font_scale === "number" || !isNaN(spacing_scale) && typeof spacing_scale === "number") {
|
||||
var pars = this.content.Content;
|
||||
for (var index = 0; index < pars.length; ++index) {
|
||||
var parg = pars[index];
|
||||
if (!isNaN(spacing_scale) && typeof spacing_scale === "number") {
|
||||
var spacing = parg.Pr.Spacing;
|
||||
var spacing2 = parg.Get_CompiledPr(false).ParaPr;
|
||||
parg.Recalc_CompiledPr();
|
||||
var spc = (spacing2.Line * spacing_scale);
|
||||
if (!isNaN(spc) && typeof spc === "number") {
|
||||
spacing.Line = spc;
|
||||
}
|
||||
spc = (spacing2.Before * spacing_scale);
|
||||
if (!isNaN(spc) && typeof spc === "number") {
|
||||
spacing.Before = spc;
|
||||
}
|
||||
spc = (spacing2.After * spacing_scale);
|
||||
if (!isNaN(spc) && typeof spc === "number") {
|
||||
spacing.After = spc;
|
||||
}
|
||||
}
|
||||
if (!isNaN(font_scale) && typeof font_scale === "number") {
|
||||
var par_font_size = parg.Get_CompiledPr(false).TextPr.FontSize;
|
||||
parg.Recalc_CompiledPr();
|
||||
for (var r = 0; r < parg.Content.length; ++r) {
|
||||
var item = parg.Content[r];
|
||||
if (item.Type === para_TextPr) {
|
||||
var value = item.Value;
|
||||
if (!isNaN(value.FontSize) && typeof value.FontSize === "number") {
|
||||
value.FontSize = (value.FontSize * font_scale) >> 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
var result_par_text_pr_font_size = (par_font_size * font_scale) >> 0;
|
||||
if (!isNaN(result_par_text_pr_font_size) && typeof result_par_text_pr_font_size === "number") {
|
||||
var b_insert_text_pr = false,
|
||||
pos = -1;
|
||||
for (var p = 0; p < parg.Content.length; ++p) {
|
||||
if (parg.Content[p].Type === para_TextPr) {
|
||||
if (! (!isNaN(parg.Content[p].Value.FontSize) && typeof parg.Content[p].Value.FontSize === "number")) {
|
||||
parg.Content[p].Value.FontSize = result_par_text_pr_font_size;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (parg.Content[p].Type === para_Text) {
|
||||
b_insert_text_pr = true;
|
||||
pos = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (b_insert_text_pr) {
|
||||
var history_is_on = History.Is_On();
|
||||
if (history_is_on) {
|
||||
History.TurnOff();
|
||||
}
|
||||
parg.Internal_Content_Add(p, new ParaTextPr({
|
||||
FontSize: result_par_text_pr_font_size
|
||||
}));
|
||||
if (history_is_on) {
|
||||
History.TurnOn();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.bodyPr.textFit = null;
|
||||
this.calculateContent();
|
||||
return;
|
||||
}
|
||||
this.bodyPr.normAutofit = false;
|
||||
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);
|
||||
this.contentHeight = this.getSummaryHeight();
|
||||
if (this.recalcInfo.recalculateContent2) {
|
||||
var _history_is_on = History.Is_On();
|
||||
if (_history_is_on) {
|
||||
History.TurnOff();
|
||||
}
|
||||
if (this.shape.isPlaceholder()) {
|
||||
var text = pHText[0][this.shape.nvSpPr.nvPr.ph.type] != undefined ? pHText[0][this.shape.nvSpPr.nvPr.ph.type] : pHText[0][phType_body];
|
||||
this.content2 = new CDocumentContent(this, editor.WordControl.m_oDrawingDocument, 0, 0, 0, 0, false, false);
|
||||
this.content2.Content.length = 0;
|
||||
var par = new Paragraph(editor.WordControl.m_oDrawingDocument, this.content2, 0, 0, 0, 0, 0);
|
||||
var EndPos = 0;
|
||||
for (var key = 0; key < text.length; ++key) {
|
||||
par.Internal_Content_Add(EndPos++, CreateParaContentFromString(text[key]));
|
||||
}
|
||||
if (this.content && this.content.Content[0]) {
|
||||
if (this.content.Content[0].Pr) {
|
||||
par.Pr = this.content.Content[0].Pr.Copy();
|
||||
}
|
||||
if (this.content.Content[0].rPr) {
|
||||
par.rPr = clone(this.content.Content[0].rPr);
|
||||
}
|
||||
}
|
||||
this.content2.Internal_Content_Add(0, par);
|
||||
this.content2.RecalculateNumbering();
|
||||
this.content2.Set_StartPage(0);
|
||||
if (_body_pr.upright === false) {
|
||||
var _content_width;
|
||||
if (! (_body_pr.vert === nVertTTvert || _body_pr.vert === nVertTTvert270)) {
|
||||
_content_width = _r - _l;
|
||||
this.contentWidth2 = _content_width;
|
||||
this.contentHeight2 = _b - _t;
|
||||
} else {
|
||||
_content_width = _b - _t;
|
||||
this.contentWidth2 = _content_width;
|
||||
this.contentHeight2 = _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.contentWidth2 = _content_width;
|
||||
this.contentHeight2 = _b - _t;
|
||||
} else {
|
||||
_content_width = _b - _t;
|
||||
this.contentWidth2 = _content_width;
|
||||
this.contentHeight2 = _r - _l;
|
||||
}
|
||||
} else {
|
||||
if (! (_body_pr.vert === nVertTTvert || _body_pr.vert === nVertTTvert270)) {
|
||||
_content_width = _b - _t;
|
||||
this.contentWidth2 = _content_width;
|
||||
this.contentHeight2 = _r - _l;
|
||||
} else {
|
||||
_content_width = _r - _l;
|
||||
this.contentWidth2 = _content_width;
|
||||
this.contentHeight2 = _b - _t;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.content2.Reset(0, 0, _content_width, 20000);
|
||||
this.content2.Recalculate_Page(0, true);
|
||||
this.contentHeight2 = this.getSummaryHeight2();
|
||||
}
|
||||
if (_history_is_on) {
|
||||
History.TurnOn();
|
||||
}
|
||||
this.recalcInfo.recalculateContent2 = false;
|
||||
}
|
||||
},
|
||||
copy: function (txBody) {
|
||||
txBody.setDocContent(this.content.Copy(txBody));
|
||||
},
|
||||
updateCursorType: function (x, y, e) {
|
||||
if (this.shape && this.shape.invertTransformText) {
|
||||
var tx = this.shape.invertTransformText.TransformPointX(x, y);
|
||||
var ty = this.shape.invertTransformText.TransformPointY(x, y);
|
||||
this.content.Update_CursorType(tx, ty, 0);
|
||||
}
|
||||
},
|
||||
Get_StartPage_Absolute: function () {
|
||||
return isRealObject(this.shape) && isRealObject(this.shape.parent) && isRealNumber(this.shape.parent.num) ? this.shape.parent.num : (this.shape.chartGroup ? this.shape.chartGroup.parent.num : 0);
|
||||
},
|
||||
Is_HdrFtr: function () {
|
||||
return false;
|
||||
},
|
||||
Get_PageContentStartPos: function (pageNum) {
|
||||
return {
|
||||
X: 0,
|
||||
Y: 0,
|
||||
XLimit: this.contentWidth,
|
||||
YLimit: 20000
|
||||
};
|
||||
},
|
||||
Get_Numbering: function () {
|
||||
return new CNumbering();
|
||||
},
|
||||
getBodyPr: function () {
|
||||
if (this.recalcInfo.recalculateBodyPr) {
|
||||
this.recalculateBodyPr();
|
||||
this.recalcInfo.recalculateBodyPr = false;
|
||||
}
|
||||
return this.compiledBodyPr;
|
||||
},
|
||||
onParagraphChanged: function () {
|
||||
if (this.shape) {
|
||||
this.shape.onParagraphChanged();
|
||||
}
|
||||
},
|
||||
getSummaryHeight: function () {
|
||||
return this.content.Get_SummaryHeight();
|
||||
},
|
||||
getSummaryHeight2: function () {
|
||||
return this.content2 ? this.content2.Get_SummaryHeight() : 0;
|
||||
},
|
||||
getCompiledBodyPr: function () {
|
||||
this.recalculateBodyPr();
|
||||
return this.compiledBodyPr;
|
||||
},
|
||||
addPhContent: function (phType) {},
|
||||
Get_TableStyleForPara: function () {
|
||||
return null;
|
||||
},
|
||||
draw: function (graphics) {
|
||||
if ((!this.content || this.content.Is_Empty()) && this.content2 != null && !this.shape.addTextFlag && (this.shape.isEmptyPlaceholder ? this.shape.isEmptyPlaceholder() : false)) {
|
||||
if (graphics.IsNoDrawingEmptyPlaceholder !== true && graphics.IsNoDrawingEmptyPlaceholderText !== true) {
|
||||
if (graphics.IsNoSupportTextDraw) {
|
||||
var _w2 = this.content2.XLimit;
|
||||
var _h2 = this.content2.Get_SummaryHeight();
|
||||
graphics.rect(this.content2.X, this.content2.Y, _w2, _h2);
|
||||
}
|
||||
this.content2.Draw(0, graphics);
|
||||
}
|
||||
} else {
|
||||
if (this.content) {
|
||||
if (graphics.IsNoSupportTextDraw) {
|
||||
var _w = this.content.XLimit;
|
||||
var _h = this.content.Get_SummaryHeight();
|
||||
graphics.rect(this.content.X, this.content.Y, _w, _h);
|
||||
}
|
||||
this.content.Draw(0, graphics);
|
||||
}
|
||||
}
|
||||
},
|
||||
Get_Styles: function (level) {
|
||||
return this.shape.Get_Styles(level);
|
||||
},
|
||||
Is_Cell: function () {
|
||||
return false;
|
||||
},
|
||||
OnContentRecalculate: function () {},
|
||||
Set_CurrentElement: function () {},
|
||||
writeToBinary: function (w) {
|
||||
this.bodyPr.Write_ToBinary2(w);
|
||||
writeToBinaryDocContent(this.content, w);
|
||||
},
|
||||
getMargins: function () {
|
||||
var _parent_transform = this.shape.transform;
|
||||
var _l;
|
||||
var _r;
|
||||
var _b;
|
||||
var _t;
|
||||
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;
|
||||
}
|
||||
var x_lt, y_lt, x_rb, y_rb;
|
||||
x_lt = _parent_transform.TransformPointX(_l, _t);
|
||||
y_lt = _parent_transform.TransformPointY(_l, _t);
|
||||
x_rb = _parent_transform.TransformPointX(_r, _b);
|
||||
y_rb = _parent_transform.TransformPointY(_r, _b);
|
||||
var hc = (_r - _l) / 2;
|
||||
var vc = (_b - _t) / 2;
|
||||
var xc = (x_lt + x_rb) / 2;
|
||||
var yc = (y_lt + y_rb) / 2;
|
||||
var tx = xc - hc;
|
||||
var ty = yc - vc;
|
||||
return {
|
||||
L: xc - hc,
|
||||
T: yc - vc,
|
||||
R: xc + hc,
|
||||
B: yc + vc,
|
||||
textMatrix: this.shape.transform
|
||||
};
|
||||
},
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
Undo: function (data) {
|
||||
switch (data.Type) {
|
||||
case historyitem_SetShape:
|
||||
this.shape = data.oldPr;
|
||||
break;
|
||||
case historyitem_SetDocContent:
|
||||
this.content = data.oldPr;
|
||||
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;
|
||||
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());
|
||||
}
|
||||
break;
|
||||
case historyitem_SetDocContent:
|
||||
if (r.GetBool()) {
|
||||
this.content = g_oTableId.Get_ById(r.GetString2());
|
||||
}
|
||||
break;
|
||||
case historyitem_SetLstStyle:
|
||||
if (r.GetBool()) {
|
||||
this.lstStyle = new TextListStyle();
|
||||
this.lstStyle.Read_FromBinary2(r);
|
||||
} else {
|
||||
this.lstStyle = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
getSelectedTextHtml: function () {},
|
||||
Refresh_RecalcData2: function () {},
|
||||
getRectWidth: function (maxWidth) {
|
||||
var body_pr = this.getBodyPr();
|
||||
var r_ins = body_pr.rIns;
|
||||
var l_ins = body_pr.lIns;
|
||||
var max_content_width = maxWidth - r_ins - l_ins;
|
||||
this.content.RecalculateNumbering();
|
||||
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;
|
||||
},
|
||||
getRectHeight: function (maxHeight, width) {
|
||||
this.content.RecalculateNumbering();
|
||||
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;
|
||||
}
|
||||
};
|
||||
function CreateParaContentFromString(str) {
|
||||
if (str == "\t") {
|
||||
return new ParaTab();
|
||||
} else {
|
||||
if (str == "\n") {
|
||||
return new ParaNewLine(break_Line);
|
||||
} else {
|
||||
if (str != " ") {
|
||||
return new ParaText(str);
|
||||
} else {
|
||||
return new ParaSpace(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user