Commit 62e77403 authored by Sergey.Luzyanin's avatar Sergey.Luzyanin Committed by Alexander.Trofimov

удалены лишние файлы

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@55906 954022d7-b5bf-4e40-9824-e11837661b57
parent 1d0baa25
var cToRad = Math.PI/(60000*180);
var cToDeg = 1/cToRad;
function Cos(angle)
{
return Math.cos(cToRad*angle);
}
function Sin(angle)
{
return Math.sin(cToRad*angle);
}
function Tan(angle)
{
return Math.tan(cToRad*angle);
}
function ATan(x)
{
return cToDeg*Math.atan(x);
}
function ATan2(y, x)
{
return cToDeg*Math.atan2(y, x);
}
function CAt2(x, y, z)
{
return x*(Math.cos(Math.atan2(z, y)));
}
function SAt2(x, y, z)
{
return x*(Math.sin(Math.atan2(z, y)));
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
var LAYOUT_MODE_EDGE = 0x00;
var LAYOUT_MODE_FACTOR = 0x01;
var LAYOUT_TARGET_INNER = 0x00;
var LAYOUT_TARGET_OUTER = 0x01;
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;
// this.Id = g_oIdCounter.Get_NewId();
// g_oTableId.Add(this, this.Id, null)
}
CChartLayout.prototype =
{
setXMode: function(mode)
{
this.xMode = mode;
},
setYMode: function(mode)
{
this.yMode = mode;
},
setX: function(x)
{
this.x = x;
},
setY: function(y)
{
this.y = y;
},
setIsManual: function(isManual)
{
this.isManual = isManual;
},
createDuplicate: function()
{
var ret = new CChartLayout();
this.isManual = false;
ret.layoutTarget = this.layoutTarget;
ret.xMode = this.xMode;
ret.yMode = this.yMode;
ret.wMode = this.wMode;
ret.hMode = this.hMode;
ret.x = this.x;
ret.y = this.y;
ret.w = this.w;
ret.h = this.h;
return ret;
},
Write_ToBinary2: function(w)
{
w.WriteBool(isRealNumber(this.layoutTarget));
if(isRealNumber(this.layoutTarget))
w.WriteLong(this.layoutTarget);
w.WriteBool(isRealNumber(this.xMode));
if(isRealNumber(this.xMode))
w.WriteLong(this.xMode);
w.WriteBool(isRealNumber(this.yMode));
if(isRealNumber(this.yMode))
w.WriteLong(this.yMode);
w.WriteBool(isRealNumber(this.wMode));
if(isRealNumber(this.wMode))
w.WriteLong(this.wMode);
w.WriteBool(isRealNumber(this.hMode));
if(isRealNumber(this.hMode))
w.WriteLong(this.hMode);
w.WriteBool(isRealNumber(this.x));
if(isRealNumber(this.x))
w.WriteDouble(this.x);
w.WriteBool(isRealNumber(this.y));
if(isRealNumber(this.y))
w.WriteDouble(this.y);
w.WriteBool(isRealNumber(this.w));
if(isRealNumber(this.w))
w.WriteDouble(this.w);
w.WriteBool(isRealNumber(this.h));
if(isRealNumber(this.h))
w.WriteDouble(this.h);
},
Read_FromBinary2: function(r)
{
if(r.GetBool())
(this.layoutTarget) = r.GetLong();
if(r.GetBool())
(this.xMode) = r.GetLong();
if(r.GetBool())
(this.yMode) = r.GetLong();
if(r.GetBool())
(this.wMode) = r.GetLong();
if(r.GetBool())
(this.hMode) = r.GetLong();
if(r.GetBool())
(this.x) = r.GetDouble();
if(r.GetBool())
(this.y) = r.GetDouble();
if(r.GetBool())
(this.w) = r.GetDouble();
if(r.GetBool())
(this.h) = r.GetDouble();
},
Undo: function(type, data)
{
switch(type)
{
case historyitem_AutoShapes_Layout_Set_X_Mode:
{
this.xMode = data.oldValue;
break;
}
case historyitem_AutoShapes_Layout_Set_Y_Mode:
{
this.yMode = data.oldValue;
break;
}
case historyitem_AutoShapes_Layout_Set_X:
{
this.x = data.oldValue;
break;
}
case historyitem_AutoShapes_Layout_Set_Y:
{
this.y = data.oldValue;
break;
}
}
},
Redo: function(type, data)
{
switch(type)
{
case historyitem_AutoShapes_Layout_Set_X_Mode:
{
this.xMode = data.newValue;
break;
}
case historyitem_AutoShapes_Layout_Set_Y_Mode:
{
this.yMode = data.newValue;
break;
}
case historyitem_AutoShapes_Layout_Set_X:
{
this.x = data.newValue;
break;
}
case historyitem_AutoShapes_Layout_Set_Y:
{
this.y = data.newValue;
break;
}
}
},
copy: function()
{},
writeToBinary: function(w)
{
w.WriteBool(isRealNumber(this.layoutTarget));
if(isRealNumber(this.layoutTarget))
w.WriteLong(this.layoutTarget);
w.WriteBool(isRealNumber(this.xMode));
if(isRealNumber(this.xMode))
w.WriteLong(this.xMode);
w.WriteBool(isRealNumber(this.yMode));
if(isRealNumber(this.yMode))
w.WriteLong(this.yMode);
w.WriteBool(isRealNumber(this.wMode));
if(isRealNumber(this.wMode))
w.WriteLong(this.wMode);
w.WriteBool(isRealNumber(this.hMode));
if(isRealNumber(this.hMode))
w.WriteLong(this.hMode);
w.WriteBool(isRealNumber(this.x));
if(isRealNumber(this.x))
w.WriteDouble(this.x);
w.WriteBool(isRealNumber(this.y));
if(isRealNumber(this.y))
w.WriteDouble(this.y);
w.WriteBool(isRealNumber(this.w));
if(isRealNumber(this.w))
w.WriteDouble(this.w);
w.WriteBool(isRealNumber(this.h));
if(isRealNumber(this.h))
w.WriteDouble(this.h);
},
readFromBinary: function(r)
{
if(r.GetBool())
this.layoutTarget = r.GetLong();
if(r.GetBool())
this.xMode = r.GetLong();
if(r.GetBool())
this.yMode = r.GetLong();
if(r.GetBool())
this.wMode = r.GetLong();
if(r.GetBool())
this.hMode = r.GetLong();
if(r.GetBool())
this.x = r.GetDouble();
if(r.GetBool())
this.y = r.GetDouble();
if(r.GetBool())
this.w = r.GetDouble();
if(r.GetBool())
this.h = r.GetDouble();
}
};
\ No newline at end of file
var LEGEND_ELEMENT_TYPE_RECT = 0x00;
var LEGEND_ELEMENT_TYPE_LINE = 0x01;
function CLegendEntry()
{
this.bDelete = null;
this.idx = null;
this.txPr = null;
this.Id = g_oIdCounter.Get_NewId();
g_oTableId.Add(this, this.Id);
}
CLegendEntry.prototype =
{
Get_Id: function()
{
return this.Id;
},
getObjectType: function()
{
return CLASS_TYPE_LEGEND_ENTRY;
}
};
function CChartLegend()
{
this.chartGroup = null;
this.layout = null;
this.legendEntries = [];
this.legendPos = null;
this.overlay = false;
this.spPr = new CSpPr();
this.txPr = null;
this.x = null;
this.y = null;
this.extX = null;
this.extY = null;
this.calculatedEntry = [];
this.Id = g_oIdCounter.Get_NewId();
g_oTableId.Add(this, this.Id);
}
CChartLegend.prototype =
{
getObjectType: function()
{
return CLASS_TYPE_CHART_LEGEND;
},
Get_Id: function()
{
return this.Id;
},
getStyles: function(level)
{
var styles = new CStyles();
var default_legend_style = new CStyle("defaultLegendStyle", styles.Default, null, styletype_Paragraph);
default_legend_style.TextPr.FontSize = 10;
default_legend_style.TextPr.FontFamily.Name = "Calibri";
default_legend_style.TextPr.Bold = true;
// default_legend_style.TextPr.RFonts. = "Calibri";
//TODO:ParaPr: default_legend_style.ParaPr.Ind
var tx_pr;
if(isRealObject(this.txPr))
{
//TODO
}
styles.Style[styles.Id] = default_legend_style;
return styles;
},
init: function()
{
this.setStartValues();
return;
var chart = this.chartGroup.chart;
var chart_legend = chart.getLegendInfo();
if(chart_legend.length > 0)
{
var shape_type = chart_legend[0].marker === c_oAscLegendMarkerType.Line ? "line" : "rect";
for(var i = 0; i < chart_legend.length; ++i)
{
var legend_entry_obj = chart_legend[i];
var entry_string = legend_entry_obj.text;
var cur_legend_entry = new CLegendEntryGroup(this);
cur_legend_entry.marker = chart_legend[0].marker;
cur_legend_entry.drawingObjects = this.chartGroup.drawingObjects;
cur_legend_entry.textBody = new CTextBody(cur_legend_entry);
cur_legend_entry.idx = i;
for(var key in entry_string)
{
cur_legend_entry.textBody.paragraphAdd(new ParaText(entry_string[key]), false);
}
cur_legend_entry.textBody.content.Reset(0, 0, 30, 30);
cur_legend_entry.textBody.content.Recalculate_Page(0, true);
cur_legend_entry.geometry = CreateGeometry(shape_type);
cur_legend_entry.geometry.Init(5, 5);
cur_legend_entry.brush = new CUniFill();
cur_legend_entry.brush.fill = new CSolidFill();
cur_legend_entry.brush.fill.color.color = new CRGBColor();
cur_legend_entry.brush.fill.color.color.RGBA = {R:legend_entry_obj.color.R, G:legend_entry_obj.color.G, B:legend_entry_obj.color.B, A:255}
}
}
},
draw: function(graphics)
{
for(var i = 0; i < this.calculatedEntry.length; ++i)
{
this.calculatedEntry[i].draw(graphics);
}
},
setStartValues: function()
{
var is_on_history = History.Is_On();
var is_on_table_id = !g_oTableId.m_bTurnOff;
if(is_on_history)
History.TurnOff();
if(is_on_table_id)
g_oTableId.m_bTurnOff = true;
g_oTableId.m_bTurnOff = true;
var chart = this.chartGroup.chart;
var legend_info = chart.getLegendInfo();
this.calculatedEntry.length = 0;
if(legend_info.length > 0)
{
var bullet_type = legend_info[0].marker === c_oAscLegendMarkerType.Line ? "line" : "rect";
for(var i = 0; i < legend_info.length; ++i)
{
var cur_legend_info = legend_info[i];
var legend_entry = this.legendEntries[i];
if(isRealObject(legend_entry) && legend_entry.bDelete === true)
continue;
var entry = new CLegendEntryGroup(this);
entry.bullet = new CShape(null, this.chartGroup.drawingObjects, legend_entry);
var uni_fill = new CUniFill();
uni_fill.setFill(new CSolidFill());
uni_fill.fill.setColor(new CUniColor());
uni_fill.fill.color.setColor(new CRGBColor());
uni_fill.fill.color.setColor(cur_legend_info.color.R*16*16 + cur_legend_info.color.G*16 +cur_legend_info.color.B);
if(bullet_type === "line")
{
entry.bullet.setPresetGeometry("line");
entry.bullet.setUniFill(uni_fill);
}
else
{
entry.bullet.setPresetGeometry("rect");
var shape_fill = new CUniFill();
shape_fill.setFill(new CNoFill());
var shape_line = new CLn();
var line_fill = new CUniFill();
line_fill.setFill(new CNoFill());
shape_line.setFill(line_fill);
entry.bullet.setUniFill(shape_fill);
entry.bullet.setUniLine(shape_line);
entry.bullet.addTextBody(new CTextBody(entry.bullet));
entry.bullet.paragraphAdd(new ParaTextPr({unifill: uni_fill}));
entry.bullet.paragraphAdd(new ParaText(String.fromCharCode(0x00A7)));
}
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;
//default_style.ParaPr TODO
styles.Style[styles.Id] = default_style;
var legend_style = new CStyle("legend_style", styles.Id-1, null, styletype_Paragraph);
/*TODO*/
styles.Style[styles.Id] = legend_style;
var entry_style = new CStyle("entry_style", styles.Id - 1, null, styletype_Paragraph);
if(isRealObject(this.legendGroup.legendEntries[this.idx]) && isRealObject(this.legendGroup.legendEntries[this.idx].txPr))
{
//TODO
}
styles.Style[styles.Id] = entry_style;
return styles;
},
getBulletStyles: function()
{
},
getTitleStyles: function()
{},
recalculateInternalPosition: function()
{
},
draw: function(graphics)
{
if(isRealObject(this.bullet) && isRealObject(this.title))
{
this.bullet.draw(graphics);
this.title.draw(graphics);
}
}
};
var CHART_TITLE_TYPE_TITLE = 0x00;
var CHART_TITLE_TYPE_H_AXIS = 0x01;
var CHART_TITLE_TYPE_V_AXIS = 0x02;
var paraDrawing;
function CChartTitle(chartGroup, type)
{
this.layout = null;
this.overlay = false;
this.spPr = new CSpPr();
this.txPr = null;
this.isDefaultText = false;
this.txBody = null;
this.x = null;
this.y = null;
this.extX = null;
this.extY = null;
this.brush = null;
this.pen = null;
this.spPr.geometry = CreateGeometry("rect");
this.spPr.geometry.Init(5,5);
this.invertTransform = new CMatrix();
this.invertTransformText = new CMatrix();
this.transform = new CMatrix();
this.transformText = new CMatrix();
this.recalculateInfo =
{
recalculateTransform: true,
recalculateBrush: true,
recalculatePen: true
};
this.recalcInfo = {};
this.selected = false;
this.Id = g_oIdCounter.Get_NewId();
g_oTableId.Add(this, this.Id);
if(isRealObject(chartGroup))
{
this.setChartGroup(chartGroup);
this.addTextBody(new CTextBody(this));
}
if(isRealNumber(type))
{
this.setType(type);
}
}
CChartTitle.prototype =
{
getObjectType: function()
{
return CLASS_TYPE_CHART_TITLE;
},
setChartGroup: function(chartGroup)
{
var oldPr = this.chartGroup ;
var newPr = chartGroup ;
History.Add(this, {Type: historyitem_AutoShapes_SetChartGroup, oldPr: oldPr, newPr: newPr});
this.chartGroup = chartGroup;
},
getAllFonts: function(AllFonts)
{
if(this.txBody && this.txBody.content)
{
AllFonts["Calibri"] = true;
this.txBody.content.Document_Get_AllFontNames(AllFonts);
}
},
Get_Id: function()
{
return this.Id;
},
Is_DrawingShape : function()
{
return false;
},
getTitleType: function()
{
if(this === this.chartGroup.chartTitle)
return CHART_TITLE_TYPE_TITLE;
if(this === this.chartGroup.hAxisTitle)
return CHART_TITLE_TYPE_H_AXIS;
if(this === this.chartGroup.vAxisTitle)
return CHART_TITLE_TYPE_V_AXIS;
},
isEmpty: function()
{
return isRealObject(this.txBody) ? this.txBody.isEmpty() : true;
},
setType: function(type)
{
History.Add(this, {Type:historyitem_AutoShapes_SetChartTitleType, oldPr : this.type, newPr: type});
this.type = type;
},
Get_Styles: function()
{
return new CStyles();
},
select: function(pageIndex)
{
this.selected = true;
this.selectStartPage = pageIndex
},
deselect: function()
{
this.selected = false;
if(isRealObject(this.txBody) && isRealObject(this.txBody.content))
this.txBody.content.Selection_Remove();
this.selectStartPage = -1;
},
remove: function(Count, bOnlyText, bRemoveOnlySelection, bOnTextAdd)
{
this.txBody.content.Remove(Count, bOnlyText, bRemoveOnlySelection, bOnTextAdd);
this.recalculatePosExt();
this.txBody.recalculateCurPos();
},
getParagraphParaPr: function()
{
if(this.txBody)
{
var ret = this.txBody.content.Get_Paragraph_ParaPr();
ret.PStyle = undefined;
}
return null;
},
getParagraphTextPr: function()
{
if(this.txBody)
{
return this.txBody.content.Get_Paragraph_TextPr();
}
return null;
},
getStyles: function()
{
var styles = new CStyles();
var default_legend_style = new CStyle("defaultLegendStyle", styles.Default, null, styletype_Paragraph);
default_legend_style.TextPr.FontFamily = { Name : "Calibri", Index : -1 };
default_legend_style.TextPr.Bold = true;
default_legend_style.TextPr.RFonts = new CRFonts();
default_legend_style.TextPr.RFonts.Ascii = { Name : "Calibri", Index : -1 };
default_legend_style.TextPr.RFonts.EastAsia = { Name : "Calibri", Index : -1 };
default_legend_style.TextPr.RFonts.HAnsi = { Name : "Calibri", Index : -1 };
default_legend_style.TextPr.RFonts.CS = { Name : "Calibri", Index : -1 };
if(this.getTitleType() === CHART_TITLE_TYPE_TITLE)
default_legend_style.TextPr.FontSize = 18;
else
default_legend_style.TextPr.FontSize = 10;
default_legend_style.ParaPr.Spacing.After = 0;
default_legend_style.ParaPr.Spacing.Before = 0;
default_legend_style.ParaPr.Spacing.LineRule = linerule_AtLeast;
default_legend_style.ParaPr.Spacing.Line = 1;
default_legend_style.ParaPr.Jc = align_Center;
//TODO:ParaPr: default_legend_style.ParaPr.Ind
var tx_pr;
if(isRealObject(this.txPr))
{
//TODO
}
styles.Style[styles.Id] = default_legend_style;
return styles;
},
initFromString: function(title)
{
this.textBody.initFromString(title);
},
//recalculate
/*recalculateTransform: function()
{
this.recalculateAfterTextAdd();
this.transform.Reset();
global_MatrixTransformer.TranslateAppend(this.transform, this.x, this.y);
},*/
setDefaultText: function(val)
{
this.isDefaultText = val;
},
recalculateTransform: function()
{
this.transform.Reset();
global_MatrixTransformer.TranslateAppend(this.transform, this.x, this.y);
global_MatrixTransformer.MultiplyAppend(this.transform, this.chartGroup.getTransform());
this.invertTransform = global_MatrixTransformer.Invert(this.transform);
},
recalculateTransform2: function()
{
this.transform.Reset();
global_MatrixTransformer.TranslateAppend(this.transform, this.x, this.y);
global_MatrixTransformer.MultiplyAppend(this.transform, this.chartGroup.getTransform());
},
setTextBody: function(txBody)
{
this.txBody = txBody;
},
setLayoutX: function(x)
{
if(!isRealObject(this.layout))
this.layout = new CChartLayout();
this.layout.setX(x);
},
setLayoutY: function(y)
{
if(!isRealObject(this.layout))
this.layout = new CChartLayout();
this.layout.setY(y);
},
addTextBody: function(txBody)
{
var oldPr = this.txBody ;
var newPr = txBody ;
History.Add(this, {Type: historyitem_AutoShapes_SetChartTitleTxBody, oldPr: oldPr, newPr: newPr});
this.txBody = txBody;
},
paragraphAdd: function(paraItem, bRecalculate)
{
if(!isRealObject(this.txBody))
this.txBody = new CTextBody(this);
this.txBody.paragraphAdd(paraItem,true);
this.recalculatePosExt();
this.txBody.recalculateCurPos();
},
recalculatePosExt: function()
{
var old_cx = this.x + this.extX*0.5;
var old_cy = this.y + this.extY*0.5;
var bodyPr = this.txBody.getBodyPr();
switch (this.type)
{
case CHART_TITLE_TYPE_TITLE:
case CHART_TITLE_TYPE_H_AXIS:
{
var max_title_width = this.chartGroup.absExtX*0.8;
var title_width = this.txBody.getRectWidth(max_title_width);
this.extX = title_width;
this.extY = this.txBody.getRectHeight(this.chartGroup.absExtY, title_width - (bodyPr.rIns + bodyPr.lIns));
this.x = old_cx - this.extX*0.5;
if(this.x + this.extX > this.chartGroup.absExtX)
this.x = this.chartGroup.absExtX - this.extX;
if(this.x < 0)
this.x = 0;
this.y = old_cy - this.extY*0.5;
if(this.y + this.extY > this.chartGroup.absExtY)
this.y = this.chartGroup.absExtY - this.extY;
if(this.y < 0)
this.y = 0;
if(isRealObject(this.layout) && isRealNumber(this.layout.x))
this.layout.setX(this.x/this.chartGroup.absExtX);
break;
}
case CHART_TITLE_TYPE_V_AXIS:
{
var max_title_height = this.chartGroup.absExtY*0.8;
var body_pr = this.txBody.getBodyPr();
this.extY = this.txBody.getRectWidth(max_title_height) - body_pr.rIns - body_pr.lIns + body_pr.tIns + body_pr.bIns;
this.extX = this.txBody.getRectHeight(this.chartGroup.absExtX, this.extY) - (- body_pr.rIns - body_pr.lIns + body_pr.tIns + body_pr.bIns);
this.spPr.geometry.Recalculate(this.extX, this.extY);
this.x = old_cx - this.extX*0.5;
if(this.x + this.extX > this.chartGroup.absExtX)
this.x = this.chartGroup.absExtX - this.extX;
if(this.x < 0)
this.x = 0;
this.y = old_cy - this.extY*0.5;
if(this.y + this.extY > this.chartGroup.absExtY)
this.y = this.chartGroup.absExtY - this.extY;
if(this.y < 0)
this.y = 0;
if(isRealObject(this.layout) && isRealNumber(this.layout.y))
this.layout.setY(this.y/this.chartGroup.absExtY);
break;
}
}
this.spPr.geometry.Recalculate(this.extX, this.extY);
this.recalculateTransform();
this.calculateContent();
this.calculateTransformTextMatrix();
},
applyTextPr: function(paraItem, bRecalculate)
{
this.txBody.content.Set_ApplyToAll(true);
this.txBody.content.Paragraph_Add(paraItem, bRecalculate);
this.txBody.content.Set_ApplyToAll(false);
},
updateSelectionState: function(drawingDocument)
{
this.txBody.updateSelectionState(drawingDocument);
},
updateCursorType: function(e, x, y, pageIndex)
{
var invert = this.invertTransformText;
var tx = invert.TransformPointX(x, y, pageIndex);
var ty = invert.TransformPointY(x, y, pageIndex);
this.txBody.content.Update_CursorType(tx, ty, pageIndex);
},
recalculateCurPos: function()
{
if(this.txBody)
this.txBody.recalculateCurPos();
},
cursorMoveLeft: function(AddToSelect, Word)
{
if(isRealObject(this.txBody) && isRealObject(this.txBody.content))
{
this.txBody.content.Cursor_MoveLeft(AddToSelect, Word);
this.recalculateCurPos();
editor.WordControl.m_oLogicDocument.Document_UpdateSelectionState();
}
},
cursorMoveRight: function(AddToSelect, Word)
{
if(isRealObject(this.txBody) && isRealObject(this.txBody.content))
{
this.txBody.content.Cursor_MoveRight(AddToSelect, Word);
this.recalculateCurPos();
editor.WordControl.m_oLogicDocument.Document_UpdateSelectionState();
}
},
cursorMoveUp: function(AddToSelect)
{
if(isRealObject(this.txBody) && isRealObject(this.txBody.content))
{
this.txBody.content.Cursor_MoveUp(AddToSelect);
this.recalculateCurPos();
editor.WordControl.m_oLogicDocument.Document_UpdateSelectionState();
}
},
cursorMoveDown: function(AddToSelect)
{
if(isRealObject(this.txBody) && isRealObject(this.txBody.content))
{
this.txBody.content.Cursor_MoveDown(AddToSelect);
this.recalculateCurPos();
editor.WordControl.m_oLogicDocument.Document_UpdateSelectionState();
}
},
cursorMoveEndOfLine: function(AddToSelect)
{
if(isRealObject(this.txBody) && isRealObject(this.txBody.content))
{
this.txBody.content.Cursor_MoveEndOfLine(AddToSelect);
this.recalculateCurPos();
editor.WordControl.m_oLogicDocument.Document_UpdateSelectionState();
}
},
cursorMoveStartOfLine: function(AddToSelect)
{
if(isRealObject(this.txBody) && isRealObject(this.txBody.content))
{
this.txBody.content.Cursor_MoveStartOfLine(AddToSelect);
this.recalculateCurPos();
editor.WordControl.m_oLogicDocument.Document_UpdateSelectionState();
}
},
drawTextSelection: function()
{
if(isRealObject(this.txBody))
{
this.txBody.drawTextSelection();
}
},
calculateContent: function()
{
if(this.txBody)
this.txBody.calculateContent();
},
getColorMap: function()
{
return this.chartGroup.drawingObjects.controller.getColorMap();
},
getTheme: function()
{
return this.chartGroup.drawingObjects.getWorkbook().theme;
},
calculateTransformTextMatrix: function()
{
if(this.txBody === null)
return;
this.transformText.Reset();
var _text_transform = this.transformText;
var _shape_transform = this.transform;
var _body_pr = this.txBody.getBodyPr();
var _content_height = this.txBody.getSummaryHeight();
var _l, _t, _r, _b;
var _t_x_lt, _t_y_lt, _t_x_rt, _t_y_rt, _t_x_lb, _t_y_lb, _t_x_rb, _t_y_rb;
if(isRealObject(this.spPr.geometry) && isRealObject(this.spPr.geometry.rect))
{
var _rect = this.spPr.geometry.rect;
_l = _rect.l +_body_pr.lIns;
_t = _rect.t + _body_pr.tIns;
_r = _rect.r - _body_pr.rIns;
_b = _rect.b - _body_pr.bIns;
}
else
{
_l = _body_pr.lIns;
_t = _body_pr.tIns;
_r = this.extX - _body_pr.rIns;
_b = this.extY - _body_pr.bIns;
}
if(_l >= _r)
{
var _c = (_l + _r)*0.5;
_l = _c - 0.01;
_r = _c + 0.01;
}
if(_t >= _b)
{
_c = (_t + _b)*0.5;
_t = _c - 0.01;
_b = _c + 0.01;
}
_t_x_lt = _shape_transform.TransformPointX(_l, _t);
_t_y_lt = _shape_transform.TransformPointY(_l, _t);
_t_x_rt = _shape_transform.TransformPointX(_r, _t);
_t_y_rt = _shape_transform.TransformPointY(_r, _t);
_t_x_lb = _shape_transform.TransformPointX(_l, _b);
_t_y_lb = _shape_transform.TransformPointY(_l, _b);
_t_x_rb = _shape_transform.TransformPointX(_r, _b);
_t_y_rb = _shape_transform.TransformPointY(_r, _b);
var _dx_t, _dy_t;
_dx_t = _t_x_rt - _t_x_lt;
_dy_t = _t_y_rt - _t_y_lt;
var _dx_lt_rb, _dy_lt_rb;
_dx_lt_rb = _t_x_rb - _t_x_lt;
_dy_lt_rb = _t_y_rb - _t_y_lt;
var _vertical_shift;
var _text_rect_height = _b - _t;
var _text_rect_width = _r - _l;
if(_body_pr.upright === false)
{
if(!(_body_pr.vert === nVertTTvert || _body_pr.vert === nVertTTvert270))
{
if(_content_height < _text_rect_height)
{
switch (_body_pr.anchor)
{
case 0 ://b
{ // (Text Anchor Enum ( Bottom ))
_vertical_shift = _text_rect_height - _content_height;
break;
}
case 1 : //ctr
{// (Text Anchor Enum ( Center ))
_vertical_shift = (_text_rect_height - _content_height)*0.5;
break;
}
case 2 : //dist
{// (Text Anchor Enum ( Distributed )) TODO: пока выравнивание по центру. Переделать!
_vertical_shift = (_text_rect_height - _content_height)*0.5;
break;
}
case 3 ://just
{// (Text Anchor Enum ( Justified )) TODO: пока выравнивание по центру. Переделать!
_vertical_shift = (_text_rect_height - _content_height)*0.5;
break;
}
case 4 ://t
{//Top
_vertical_shift = 0;
break;
}
}
}
else
{
_vertical_shift = 0;
//_vertical_shift = _text_rect_height - _content_height;
/*if(_body_pr.anchor === 0)
{
_vertical_shift = _text_rect_height - _content_height;
}
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 ://b
{ // (Text Anchor Enum ( Bottom ))
_vertical_shift = _text_rect_width - _content_height;
break;
}
case 1 : //ctr
{// (Text Anchor Enum ( Center ))
_vertical_shift = (_text_rect_width - _content_height)*0.5;
break;
}
case 2 : //dist
{// (Text Anchor Enum ( Distributed ))
_vertical_shift = (_text_rect_width - _content_height)*0.5;
break;
}
case 3 ://just
{// (Text Anchor Enum ( Justified ))
_vertical_shift = (_text_rect_width - _content_height)*0.5;
break;
}
case 4 ://t
{//Top
_vertical_shift = 0;
break;
}
}
}
else
{
_vertical_shift = 0;
/*if(_body_pr.anchor === 0)
{
_vertical_shift = _text_rect_width - _content_height;
}
else
{
_vertical_shift = 0;
} */
}
global_MatrixTransformer.TranslateAppend(_text_transform, 0, _vertical_shift);
var _alpha;
_alpha = Math.atan2(_dy_t, _dx_t);
if(_body_pr.vert === nVertTTvert)
{
if(_dx_lt_rb*_dy_t - _dy_lt_rb*_dx_t <= 0)
{
global_MatrixTransformer.RotateRadAppend(_text_transform, -_alpha - Math.PI*0.5);
global_MatrixTransformer.TranslateAppend(_text_transform, _t_x_rt, _t_y_rt);
}
else
{
global_MatrixTransformer.RotateRadAppend(_text_transform, Math.PI*0.5-_alpha);
global_MatrixTransformer.TranslateAppend(_text_transform, _t_x_lt, _t_y_lt);
}
}
else
{
if(_dx_lt_rb*_dy_t - _dy_lt_rb*_dx_t <= 0)
{
global_MatrixTransformer.RotateRadAppend(_text_transform, -_alpha - Math.PI*1.5);
global_MatrixTransformer.TranslateAppend(_text_transform, _t_x_lb, _t_y_lb);
}
else
{
global_MatrixTransformer.RotateRadAppend(_text_transform, -Math.PI*0.5-_alpha);
global_MatrixTransformer.TranslateAppend(_text_transform, _t_x_rb, _t_y_rb);
}
}
}
if(isRealObject(this.spPr.geometry) && isRealObject(this.spPr.geometry.rect))
{
var rect = this.spPr.geometry.rect;
this.clipRect = {x: rect.l, y: rect.t, w: rect.r - rect.l, h: rect.b - rect.t};
}
else
{
this.clipRect = {x: 0, y: 0, w: this.absExtX, h: this.absExtY};
}
}
else
{
var _full_rotate = this.getFullRotate();
var _full_flip = this.getFullFlip();
var _hc = this.absExtX*0.5;
var _vc = this.absExtY*0.5;
var _transformed_shape_xc = this.transform.TransformPointX(_hc, _vc);
var _transformed_shape_yc = this.transform.TransformPointY(_hc, _vc);
var _content_width, content_height2;
if((_full_rotate >= 0 && _full_rotate < Math.PI*0.25)
|| (_full_rotate > 3*Math.PI*0.25 && _full_rotate < 5*Math.PI*0.25)
|| (_full_rotate > 7*Math.PI*0.25 && _full_rotate < 2*Math.PI))
{
if(!(_body_pr.vert === nVertTTvert || _body_pr.vert === nVertTTvert270))
{
_content_width = _r - _l;
content_height2 = _b - _t;
}
else
{
_content_width = _b - _t;
content_height2 = _r - _l;
}
}
else
{
if(!(_body_pr.vert === nVertTTvert || _body_pr.vert === nVertTTvert270))
{
_content_width = _b - _t;
content_height2 = _r - _l;
}
else
{
_content_width = _r - _l;
content_height2 = _b - _t;
}
}
if(_content_height < content_height2)
{
switch (_body_pr.anchor)
{
case 0 ://b
{ // (Text Anchor Enum ( Bottom ))
_vertical_shift = content_height2 - _content_height;
break;
}
case 1 : //ctr
{// (Text Anchor Enum ( Center ))
_vertical_shift = (content_height2 - _content_height)*0.5;
break;
}
case 2 : //dist
{// (Text Anchor Enum ( Distributed ))
_vertical_shift = (content_height2 - _content_height)*0.5;
break;
}
case 3 ://just
{// (Text Anchor Enum ( Justified ))
_vertical_shift = (content_height2 - _content_height)*0.5;
break;
}
case 4 ://t
{//Top
_vertical_shift = 0;
break;
}
}
}
else
{
_vertical_shift = 0;
/*if(_body_pr.anchor === 0)
{
_vertical_shift = content_height2 - _content_height;
}
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;//TODO
break;
}
}
},
recalculateBrush: function()
{},
recalculatePen: function()
{},
draw: function(graphics, pageIndex)
{
graphics.SetIntegerGrid(false);
graphics.transform3(this.transformText);
if (window.IsShapeToImageConverter)
{
pageIndex = 0;
}
if (graphics.CheckUseFonts2 !== undefined)
graphics.CheckUseFonts2(this.transformText);
this.txBody.draw(graphics, pageIndex);
if (graphics.UncheckUseFonts2 !== undefined)
graphics.UncheckUseFonts2();
graphics.reset();
graphics.SetIntegerGrid(true);
},
selectionSetStart: function(event, x, y, pageIndex)
{
var t_x, t_y;
t_x = this.invertTransformText.TransformPointX(x, y);
t_y = this.invertTransformText.TransformPointY(x, y);
if(typeof this.selectStartPage === "number" && this.selectStartPage > -1)
{
this.txBody.content.Set_StartPage(this.selectStartPage);
}
this.txBody.content.Selection_SetStart(t_x, t_y, typeof this.selectStartPage === "number" && this.selectStartPage > -1 ? this.selectStartPage : this.pageIndex, event);
},
selectionSetEnd: function(event, x, y, pageIndex)
{
var t_x, t_y;
t_x = this.invertTransformText.TransformPointX(x, y);
t_y = this.invertTransformText.TransformPointY(x, y);
if(typeof this.selectStartPage === "number" && this.selectStartPage > -1)
{
this.txBody.content.Set_StartPage(this.selectStartPage);
}
this.txBody.content.Selection_SetEnd(t_x, t_y, typeof this.selectStartPage === "number" && this.selectStartPage > -1 ? this.selectStartPage : this.pageIndex, event);
},
setPosition: function(x, y)
{
var layout = new CChartLayout();
layout.setIsManual(true);
layout.setXMode(LAYOUT_MODE_EDGE);
layout.setX(x/this.chartGroup.absExtX);
layout.setYMode(LAYOUT_MODE_EDGE);
layout.setY(y/this.chartGroup.absExtY);
this.setLayout(layout);
},
setLayout: function(layout)
{
var oldLayout = this.layout ? this.layout.createDuplicate() : null;
var newLayout = layout ? layout.createDuplicate() : null;
History.Add(this, {Type: historyitem_SetCahrtLayout, oldLayout: oldLayout, newLayout: newLayout});
this.layout = layout;
},
hit: function(x, y)
{
return this.hitInInnerArea(x, y) || this.hitInPath(x, y) || this.hitInTextRect(x, y);
},
hitInPath: function(x, y)
{
var invert_transform = this.getInvertTransform();
var x_t = invert_transform.TransformPointX(x, y);
var y_t = invert_transform.TransformPointY(x, y);
if(isRealObject(this.spPr.geometry))
return this.spPr.geometry.hitInPath(editor.WordControl.m_oLogicDocument.DrawingDocument.CanvasHitContext, x_t, y_t);
return false;
},
hitInInnerArea: function(x, y)
{
var invert_transform = this.getInvertTransform();
var x_t = invert_transform.TransformPointX(x, y);
var y_t = invert_transform.TransformPointY(x, y);
if(isRealObject(this.spPr.geometry))
return this.spPr.geometry.hitInInnerArea(editor.WordControl.m_oLogicDocument.DrawingDocument.CanvasHitContext, x_t, y_t);
return x_t > 0 && x_t < this.extX && y_t > 0 && y_t < this.extY;
},
hitInTextRect: function(x, y)
{
if(isRealObject(this.txBody))
{
var t_x, t_y;
t_x = this.invertTransformText.TransformPointX(x, y);
t_y = this.invertTransformText.TransformPointY(x, y);
return t_x > 0 && t_x < this.txBody.contentWidth && t_y > 0 && t_y < this.txBody.contentHeight;
}
return false;
},
hitInBoundingRect: function(x, y)
{
var invert_transform = this.getInvertTransform();
var x_t = invert_transform.TransformPointX(x, y);
var y_t = invert_transform.TransformPointY(x, y);
var _hit_context = editor.WordControl.m_oLogicDocument.DrawingDocument.CanvasHitContext;
return (HitInLine(_hit_context, x_t, y_t, 0, 0, this.extX, 0) ||
HitInLine(_hit_context, x_t, y_t, this.extX, 0, this.extX, this.extY)||
HitInLine(_hit_context, x_t, y_t, this.extX, this.extY, 0, this.extY)||
HitInLine(_hit_context, x_t, y_t, 0, this.extY, 0, 0) /*||
HitInLine(_hit_context, x_t, y_t, this.extX*0.5, 0, this.extX*0.5, -this.drawingDocument.GetMMPerDot(TRACK_DISTANCE_ROTATE))*/);
},
getInvertTransform: function()
{
return this.invertTransform;
},
writeToBinary: function(w)
{
w.WriteBool(isRealObject(this.layout));
if(isRealObject(this.layout))
this.layout.writeToBinary(w);
w.WriteBool(this.overlay);
this.spPr.Write_ToBinary2(w);
//w.WriteBool(isRealObject(this.txPr));
//if(isRealObject(this.txPr))
// this.txPr.writeToBinary(w);
w.WriteBool(isRealObject(this.txBody));
if(isRealObject(this.txBody))
this.txBody.writeToBinary(w);
},
readFromBinary: function(r)
{
if(r.GetBool())
{
var layout = new CChartLayout();
layout.Read_FromBinary2(r);
this.setLayout(layout);
}
this.overlay = r.GetBool();
this.spPr.Read_FromBinary2(r);
if(r.GetBool())
{
this.txBody.readFromBinary(r);
}
},
copy: function(chartGroup, type)
{
var c = new CChartTitle(chartGroup, type);
if(this.layout)
{
c.setLayout(this.layout.copy());
}
c.overlay = this.overlay;
c.txBody.copyFromOther(this.txBody);
return c;
},
setBodyPr: function(bodyPr)
{
var old_body_pr = this.txBody.bodyPr;
this.txBody.bodyPr = bodyPr;
var new_body_pr = this.txBody.bodyPr.createDuplicate();
History.Add(this, {Type: historyitem_SetShapeBodyPr, oldBodyPr: old_body_pr, newBodyPr: new_body_pr});
this.txBody.recalcInfo.recalculateBodyPr = true;
},
setOverlay: function(overlay)
{
var _overlay = overlay === true;
History.Add(this, {Type: historyitem_AutoShapes_SetChartTitleOverlay, oldPr: this.overlay === true, newPr: _overlay});
this.overlay = _overlay;
},
Undo: function(data)
{
switch(data.Type)
{
case historyitem_SetCahrtLayout:
{
if(isRealObject(data.oldLayout))
{
this.layout = data.oldLayout.createDuplicate();
}
else
{
this.layout = null;
}
break;
}
case historyitem_SetShapeBodyPr:
{
this.txBody.bodyPr = data.oldBodyPr.createDuplicate();
this.txBody.recalcInfo.recalculateBodyPr = true;
this.recalcInfo.recalculateContent = true;
this.recalcInfo.recalculateTransformText = true;
break;
}
case historyitem_AutoShapes_SetChartGroup:
{
this.chartGroup = data.oldPr;
break;
}
case historyitem_AutoShapes_SetChartTitleType:
{
this.type = data.oldPr;
break;
}
case historyitem_AutoShapes_SetChartTitleOverlay:
{
this.overlay = data.oldPr
break;
}
case historyitem_AutoShapes_SetChartTitleTxBody:
{
this.txBody = data.oldPr;
break;
}
}
},
Redo: function(data)
{
switch(data.Type)
{
case historyitem_SetCahrtLayout:
{
if(isRealObject(data.newLayout))
{
this.layout = data.newLayout.createDuplicate();
}
else
{
this.layout = null;
}
break;
}
case historyitem_SetShapeBodyPr:
{
this.txBody.bodyPr = data.newBodyPr.createDuplicate();
this.txBody.recalcInfo.recalculateBodyPr = true;
this.recalcInfo.recalculateContent = true;
this.recalcInfo.recalculateTransformText = true;
break;
}
case historyitem_AutoShapes_SetChartGroup:
{
this.chartGroup = data.newPr;
break;
}
case historyitem_AutoShapes_SetChartTitleType:
{
this.type = data.newPr;
break;
}
case historyitem_AutoShapes_SetChartTitleOverlay:
{
this.overlay = data.newPr
break;
}
case historyitem_AutoShapes_SetChartTitleTxBody:
{
this.txBody = data.newPr;
break;
}
}
},
Refresh_RecalcData: function()
{},
Write_ToBinary2: function(w)
{
w.WriteLong(historyitem_type_ChartTitle);
w.WriteString2(this.Id);
},
Read_FromBinary2: function(r)
{
this.Id = r.GetString2();
},
Save_Changes: function(data, w)
{
w.WriteLong(historyitem_type_ChartTitle);
w.WriteLong(data.Type);
switch(data.Type)
{
case historyitem_SetCahrtLayout:
{
w.WriteBool(isRealObject(data.newLayout));
if(isRealObject(data.newLayout))
{
data.newLayout.Write_ToBinary2(w);
}
break;
}
case historyitem_SetShapeBodyPr:
{
data.newBodyPr.Write_ToBinary2(w);
break;
}
case historyitem_AutoShapes_SetChartGroup:
{
w.WriteBool(isRealObject(data.newPr));
if(isRealObject(data.newPr))
{
w.WriteString2(data.newPr.Get_Id());
}
break;
}
case historyitem_AutoShapes_SetChartTitleType:
{
w.WriteBool(isRealNumber(data.newPr));
if(isRealNumber(data.newPr));
{
w.WriteLong(data.newPr);
}
break;
}
case historyitem_AutoShapes_SetChartTitleOverlay:
{
w.WriteBool(data.newPr);
break;
}
case historyitem_AutoShapes_SetChartTitleTxBody:
{
w.WriteBool(isRealObject(data.newPr));
if(isRealObject(data.newPr))
{
w.WriteString2(data.newPr.Get_Id());
}
break;
}
}
},
Load_Changes: function(r)
{
if(r.GetLong() === historyitem_type_ChartTitle)
{
switch(r.GetLong())
{
case historyitem_SetCahrtLayout:
{
if(r.GetBool())
{
this.layout = new CChartLayout();
this.layout.Read_FromBinary2(r);
}
else
{
this.layout = null;
}
break;
}
case historyitem_SetShapeBodyPr:
{
this.txBody.bodyPr = new CBodyPr();
this.txBody.bodyPr.Read_FromBinary2(r);
this.txBody.recalcInfo.recalculateBodyPr = true;
this.recalcInfo.recalculateContent = true;
this.recalcInfo.recalculateTransformText = true;
break;
}
case historyitem_AutoShapes_SetChartGroup:
{
if(r.GetBool())
{
this.chartGroup = g_oTableId.Get_ById(r.GetString2());
}
else
{
this.chartGroup = null;
}
break;
}
case historyitem_AutoShapes_SetChartTitleType:
{
if(r.GetBool())
{
this.type = r.GetLong();
}
else
{
this.type = null;
}
break;
}
case historyitem_AutoShapes_SetChartTitleOverlay:
{
this.overlay = r.GetBool();
break;
}
case historyitem_AutoShapes_SetChartTitleTxBody:
{
if(r.GetBool())
{
this.txBody = g_oTableId.Get_ById(r.GetString2());
}
else
{
this.txBody = null;
}
break;
}
}
}
},
OnContentReDraw: function()
{
if(this.chartGroup)
this.chartGroup.OnContentReDraw();
}
};
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
var FORMULA_TYPE_MULT_DIV = 0,
FORMULA_TYPE_PLUS_MINUS = 1,
FORMULA_TYPE_PLUS_DIV = 2,
FORMULA_TYPE_IF_ELSE =3,
FORMULA_TYPE_ABS = 4,
FORMULA_TYPE_AT2 = 5,
FORMULA_TYPE_CAT2 = 6,
FORMULA_TYPE_COS = 7,
FORMULA_TYPE_MAX = 8,
FORMULA_TYPE_MOD = 9,
FORMULA_TYPE_PIN = 10,
FORMULA_TYPE_SAT2 = 11,
FORMULA_TYPE_SIN = 12,
FORMULA_TYPE_SQRT = 13,
FORMULA_TYPE_TAN = 14,
FORMULA_TYPE_VALUE = 15,
FORMULA_TYPE_MIN = 16;
var APPROXIMATE_EPSILON = 1;
var APPROXIMATE_EPSILON2 = 3;
var APPROXIMATE_EPSILON3 = 5;
function clonePrototype(obj) {
if(obj == null || typeof(obj) != 'object') {
return obj;
}
if(obj.constructor == Array) {
var clonedArray=[];
for(var i=0; i < obj.length; ++i) {
clonedArray[i] = clone(obj[i]);
}
return clonedArray;
}
var clonedObj = {};
for( var key in obj ) {
clonedObj[key] = clonePrototype(obj[key]);
}
return clonedObj;
}
function CalculateGuideValue(name, formula, x, y, z, gdLst)
{
var xt, yt, zt;
xt=gdLst[x]; //TODO : возможно, что gdLst[x] еще не расчитан
if(xt===undefined)
xt=parseInt(x,10);
yt=gdLst[y];
if(yt===undefined)
yt=parseInt(y,10);
zt=gdLst[z];
if(zt===undefined)
zt=parseInt(z,10);
switch(formula)
{
case FORMULA_TYPE_MULT_DIV:
{
gdLst[name]=xt*yt/zt;
break;
}
case FORMULA_TYPE_PLUS_MINUS:
{
gdLst[name] = xt+yt-zt;
break;
}
case FORMULA_TYPE_PLUS_DIV:
{
gdLst[name] = (xt+yt)/zt;
break;
}
case FORMULA_TYPE_IF_ELSE:
{
if(xt>0)
gdLst[name] = yt;
else
gdLst[name] = zt;
break;
}
case FORMULA_TYPE_ABS:
{
gdLst[name] = Math.abs(xt);
break;
}
case FORMULA_TYPE_AT2:
{
gdLst[name] = ATan2(yt, xt);
break;
}
case FORMULA_TYPE_CAT2:
{
gdLst[name] = CAt2(xt,yt,zt);
break;
}
case FORMULA_TYPE_COS:
{
gdLst[name] = xt*Cos(yt);
break;
}
case FORMULA_TYPE_MAX:
{
gdLst[name] = Math.max(xt, yt);
break;
}
case FORMULA_TYPE_MOD:
{
gdLst[name] = Math.sqrt(xt*xt+yt*yt+zt*zt);
break;
}
case FORMULA_TYPE_PIN:
{
if (yt < xt)
gdLst[name] = xt;
else if (yt > zt)
gdLst[name] = zt;
else
gdLst[name] = yt;
break;
}
case FORMULA_TYPE_SAT2:
{
gdLst[name] = SAt2(xt,yt,zt);
break;
}
case FORMULA_TYPE_SIN:
{
gdLst[name] = xt*Sin(yt);
break;
}
case FORMULA_TYPE_SQRT:
{
gdLst[name] = Math.sqrt(xt);
break;
}
case FORMULA_TYPE_TAN:
{
gdLst[name] = xt*Tan(yt);
break;
}
case FORMULA_TYPE_VALUE:
{
gdLst[name] = xt;
break;
}
case FORMULA_TYPE_MIN:
{
gdLst[name] = Math.min(xt, yt);
}
}
}
function CalculateGuideLst(gdLstInfo, gdLst)
{
var info;
for(var i=0, n=gdLstInfo.length; i<n;i++)
{
info=gdLstInfo[i];
CalculateGuideValue(info.name, info.formula, info.x, info.y, info.z, gdLst);
}
}
function CalculateCnxLst(cnxLstInfo, cnxLst, gdLst)
{
var x_, y_, ang_;
for(var i=0, n=cnxLstInfo.length; i<n;i++)
{
ang_=parseInt(cnxLstInfo[i].ang);
if(isNaN(ang_))
ang_=gdLst[cnxLstInfo[i].ang];
x_=gdLst[cnxLstInfo[i].x];
if(x_===undefined)
x_=parseInt(cnxLstInfo[i].x);
y_=gdLst[cnxLstInfo[i].y];
if(y_===undefined)
y_=parseInt(cnxLstInfo[i].y);
if(cnxLst[i]==undefined)
cnxLst[i]={};
cnxLst[i].ang=ang_;
cnxLst[i].x=x_;
cnxLst[i].y=y_;
}
}
function CalculateAhXYList(ahXYListInfo, ahXYLst, gdLst)
{
var minX, maxX, minY, maxY, posX, posY;
for(var i=0, n=ahXYListInfo.length; i<n;i++)
{
minX=parseInt(ahXYListInfo[i].minX);
if(isNaN(minX))
minX=gdLst[ahXYListInfo[i].minX];
maxX=parseInt(ahXYListInfo[i].maxX);
if(isNaN(maxX))
maxX=gdLst[ahXYListInfo[i].maxX];
minY=parseInt(ahXYListInfo[i].minY);
if(isNaN(minY))
minY=gdLst[ahXYListInfo[i].minY];
maxY=parseInt(ahXYListInfo[i].maxY);
if(isNaN(maxY))
maxY=gdLst[ahXYListInfo[i].maxY];
posX=parseInt(ahXYListInfo[i].posX);
if(isNaN(posX))
{
posX=gdLst[ahXYListInfo[i].posX];
}
posY=parseInt(ahXYListInfo[i].posY);
if(isNaN(posY))
{
posY=gdLst[ahXYListInfo[i].posY];
}
if(ahXYLst[i]==undefined)
ahXYLst[i]={};
ahXYLst[i].gdRefX=ahXYListInfo[i].gdRefX;
ahXYLst[i].minX= minX;
ahXYLst[i].maxX= maxX;
ahXYLst[i].gdRefY=ahXYListInfo[i].gdRefY;
ahXYLst[i].minY= minY;
ahXYLst[i].maxY= maxY;
ahXYLst[i].posX= posX;
ahXYLst[i].posY= posY;
}
}
function CalculateAhPolarList(ahPolarListInfo, ahPolarLst, gdLst)
{
var minR, maxR, minAng, maxAng, posX, posY;
for(var i=0, n=ahPolarListInfo.length; i<n;i++)
{
minR=parseInt(ahPolarListInfo[i].minR);
if(isNaN(minR))
minR=gdLst[ahPolarListInfo[i].minR];
maxR=parseInt(ahPolarListInfo[i].maxR);
if(isNaN(maxR))
maxR=gdLst[ahPolarListInfo[i].maxR];
minAng=parseInt(ahPolarListInfo[i].minAng);
if(isNaN(minAng))
minAng=gdLst[ahPolarListInfo[i].minAng];
maxAng=parseInt(ahPolarListInfo[i].maxAng);
if(isNaN(maxAng))
maxAng=gdLst[ahPolarListInfo[i].maxAng];
posX=parseInt(ahPolarListInfo[i].posX);
if(isNaN(posX))
{
posX=gdLst[ahPolarListInfo[i].posX]
}
posY=parseInt(ahPolarListInfo[i].posY);
if(isNaN(posY))
{
posY=gdLst[ahPolarListInfo[i].posY];
}
if(ahPolarLst[i]==undefined)
{
ahPolarLst[i]={};
}
ahPolarLst[i].gdRefR=ahPolarListInfo[i].gdRefR;
ahPolarLst[i].minR = minR;
ahPolarLst[i].maxR = maxR;
ahPolarLst[i].gdRefAng = ahPolarListInfo[i].gdRefAng;
ahPolarLst[i].minAng = minAng;
ahPolarLst[i].maxAng = maxAng;
ahPolarLst[i].posX=posX;
ahPolarLst[i].posY=posY;
}
}
function CGeometry()
{
this.gdLstInfo=[];
this.gdLst={};
this.avLst = {};
this.cnxLstInfo=[];
this.cnxLst=[];
this.ahXYLstInfo=[];
this.ahXYLst=[];
this.ahPolarLstInfo=[];
this.ahPolarLst=[];
this.pathLst = [];
this.isLine = false;
this.preset = null;
this.createDuplicate = function()
{
var duplicate = new CGeometry();
for(var i = 0; i < this.gdLstInfo.length; ++i)
{
duplicate.gdLstInfo[i] = clonePrototype(this.gdLstInfo[i]);
}
duplicate.gdLst = clonePrototype(this.gdLst);
for(i = 0; i < this.cnxLstInfo.length; ++i)
{
duplicate.cnxLstInfo[i] = clonePrototype(this.cnxLstInfo[i]) ;
}
for(i = 0; i < this.cnxLst.length; ++i)
{
duplicate.cnxLst[i] = clonePrototype(this.cnxLst[i]);
}
for(i = 0; i < this.ahXYLstInfo.length; ++i)
{
duplicate.ahXYLstInfo[i] = clonePrototype(this.ahXYLstInfo[i]);
}
for(i = 0; i < this.ahXYLst.length; ++i)
{
duplicate.ahXYLst[i] = clonePrototype(this.ahXYLst[i]);
}
for(i = 0; i < this.ahPolarLstInfo.length; ++i)
{
duplicate.ahPolarLstInfo[i] = clonePrototype(this.ahPolarLstInfo[i]);
}
for(i = 0; i < this.ahPolarLst.length; ++i)
{
duplicate.ahPolarLst[i] = clonePrototype(this.ahPolarLst[i]);
}
for(i = 0; i < this.pathLst.length; ++i)
{
duplicate.pathLst[i] = this.pathLst[i].createDuplicate();
}
for (var i in this.avLst)
{
duplicate.avLst[i] = this.avLst[i];
}
duplicate.rectS = clonePrototype(this.rectS);
duplicate.rect = clonePrototype(this.rect);
duplicate.isLine = this.isLine;
duplicate.preset = this.preset;
return duplicate;
};
this.createDuplicateForTrack = function()
{
var _duplicate = new Geometry();
_duplicate.gdLst["_3cd4"] = 16200000;
_duplicate.gdLst["_3cd8"] = 8100000;
_duplicate.gdLst["_5cd8"] = 13500000;
_duplicate.gdLst["_7cd8"] = 18900000;
_duplicate.gdLst["cd2"] = 10800000;
_duplicate.gdLst["cd4"] = 5400000;
_duplicate.gdLst["cd8"] = 2700000;
_duplicate.gdLst["l"] = 0;
_duplicate.gdLst["t"] = 0;
var _adj_key;
for(_adj_key in this.avLst)
{
if(this.avLst[_adj_key] === true)
{
_duplicate.gdLst[_adj_key] = this.gdLst[_adj_key];
}
}
var _gd_index;
var _cur_guide;
var _duplicate_guide;
var _gd_count = this.gdLstInfo.length;
for(_gd_index = 0; _gd_index < _gd_count; ++_gd_index)
{
_cur_guide = this.gdLstInfo[_gd_index];
_duplicate_guide = {};
_duplicate_guide.name = _cur_guide.name;
_duplicate_guide.formula = _cur_guide.formula;
_duplicate_guide.x = _cur_guide.x;
_duplicate_guide.y = _cur_guide.y;
_duplicate_guide.z = _cur_guide.z;
_duplicate_guide.isAdj = _cur_guide.isAdj;
_duplicate.gdLstInfo.push(_duplicate_guide);
}
var _path_index;
for(_path_index = 0; _path_index < this.pathLst.length; ++_path_index)
{
_duplicate.pathLst[_path_index] = this.pathLst[_path_index].createDuplicate();
}
var _ah_index;
var _adjustment;
var _duplicate_adj;
for(_ah_index = 0; _ah_index < this.ahXYLstInfo.length; ++_ah_index)
{
_adjustment = this.ahXYLstInfo[_ah_index];
_duplicate_adj = {};
_duplicate_adj.gdRefX = _adjustment.gdRefX;
_duplicate_adj.gdRefY = _adjustment.gdRefY;
_duplicate_adj.maxX = _adjustment.maxX;
_duplicate_adj.minX = _adjustment.minX;
_duplicate_adj.maxY = _adjustment.maxY;
_duplicate_adj.minY = _adjustment.minY;
_duplicate_adj.posX = _adjustment.posX;
_duplicate_adj.posY = _adjustment.posY;
_duplicate.ahXYLstInfo.push(_duplicate_adj);
}
for(_ah_index = 0; _ah_index < this.ahPolarLstInfo.length; ++_ah_index)
{
_adjustment = this.ahPolarLstInfo[_ah_index];
_duplicate_adj = {};
_duplicate_adj.gdRefR = _adjustment.gdRefR;
_duplicate_adj.gdRefAng = _adjustment.gdRefAng;
_duplicate_adj.maxR = _adjustment.maxR;
_duplicate_adj.minR = _adjustment.minR;
_duplicate_adj.maxAng = _adjustment.maxAng;
_duplicate_adj.minAng = _adjustment.minAng;
_duplicate_adj.posX = _adjustment.posX;
_duplicate_adj.posY = _adjustment.posY;
_duplicate.ahPolarLstInfo.push(_duplicate_adj);
}
_duplicate.isLine = this.isLine;
return _duplicate;
};
}
CGeometry.prototype=
{
Write_ToBinary: function(Writer)
{
},
canFill: function()
{
if(this.preset === "line")
return false;
for(var i = 0; i < this.pathLst.length; ++i)
{
if(this.pathLst[i].fill !== "none")
return true;
}
return false;
},
Write_ToBinary2: function(Writer)
{
var w = Writer;
var count = 0;
for(var key in this.avLst)
{
++count;
}
w.WriteLong(count);
for(key in this.avLst)
{
w.WriteString2(key);
}
var gd_lst_info_count = this.gdLstInfo.length;
Writer.WriteLong(gd_lst_info_count);
var bool;
for(var index = 0; index < gd_lst_info_count; ++index)
{
var g = this.gdLstInfo[index];
w.WriteString2(g.name);
w.WriteLong(g.formula);
bool = typeof g.x === "string";
w.WriteBool(bool);
if(bool)
w.WriteString2(g.x);
bool = typeof g.y === "string";
w.WriteBool(bool);
if(bool)
w.WriteString2(g.y);
bool = typeof g.z === "string";
w.WriteBool(bool);
if(bool)
w.WriteString2(g.z);
}
WriteObjectLong(w, this.gdLst);
// for(key in this.avLst)
// {
// w.WriteString2(key);
//}
var cnx_lst_count = this.cnxLstInfo.length;
Writer.WriteLong(cnx_lst_count);
for(index = 0; index < cnx_lst_count; ++index)
{
WriteObjectString(Writer, this.cnxLstInfo[index]);
}
var ah_xy_count = this.ahXYLstInfo.length;
Writer.WriteLong(ah_xy_count);
for(index = 0; index < ah_xy_count; ++index)
{
var o = this.ahXYLstInfo[index];
bool = typeof o.gdRefX === "string";
w.WriteBool(bool);
if(bool)
w.WriteString2(o.gdRefX);
bool = typeof o.gdRefY === "string";
w.WriteBool(bool);
if(bool)
w.WriteString2(o.gdRefY);
bool = typeof o.minX === "string";
w.WriteBool(bool);
if(bool)
w.WriteString2(o.minX);
bool = typeof o.maxX === "string";
w.WriteBool(bool);
if(bool)
w.WriteString2(o.maxX);
bool = typeof o.minY === "string";
w.WriteBool(bool);
if(bool)
w.WriteString2(o.minY);
bool = typeof o.maxY === "string";
w.WriteBool(bool);
if(bool)
w.WriteString2(o.maxY);
bool = typeof o.posX === "string";
w.WriteBool(bool);
if(bool)
w.WriteString2(o.posX);
bool = typeof o.posY === "string";
w.WriteBool(bool);
if(bool)
w.WriteString2(o.posY);
}
var ah_polar_count = this.ahPolarLstInfo.length;
Writer.WriteLong(ah_polar_count);
for(index = 0; index < ah_polar_count; ++index)
{
o = this.ahPolarLstInfo[index];
bool = typeof o.gdRefR === "string";
w.WriteBool(bool);
if(bool)
w.WriteString2(o.gdRefR);
bool = typeof o.gdRefAng === "string";
w.WriteBool(bool);
if(bool)
w.WriteString2(o.gdRefAng);
bool = typeof o.minR === "string";
w.WriteBool(bool);
if(bool)
w.WriteString2(o.minR);
bool = typeof o.maxR === "string";
w.WriteBool(bool);
if(bool)
w.WriteString2(o.maxR);
bool = typeof o.minAng === "string";
w.WriteBool(bool);
if(bool)
w.WriteString2(o.minAng);
bool = typeof o.maxAng === "string";
w.WriteBool(bool);
if(bool)
w.WriteString2(o.maxAng);
bool = typeof o.posX === "string";
w.WriteBool(bool);
if(bool)
w.WriteString2(o.posX);
bool = typeof o.posY === "string";
w.WriteBool(bool);
if(bool)
w.WriteString2(o.posY);
}
var path_count = this.pathLst.length;
Writer.WriteLong(path_count);
for(index = 0; index < path_count; ++index)
{
this.pathLst[index].Write_ToBinary2(Writer);
}
Writer.WriteBool(typeof this.preset === "string");
if(typeof this.preset === "string")
{
Writer.WriteString2(this.preset);
}
var w = Writer;
w.WriteBool(isRealObject(this.rectS));
if(isRealObject(this.rectS))
{
w.WriteString2(this.rectS.l);
w.WriteString2(this.rectS.t);
w.WriteString2(this.rectS.r);
w.WriteString2(this.rectS.b);
}
},
Read_FromBinary2: function(Reader)
{
var r = Reader;
var count = r.GetLong();
for(index = 0; index < count; ++index)
{
this.avLst[r.GetString2()] = true;
}
var gd_lst_info_count = Reader.GetLong();
for(var index = 0; index < gd_lst_info_count; ++index)
{
var gd_info = {};
gd_info.name = r.GetString2();
gd_info.formula = r.GetLong();
if(r.GetBool())
gd_info.x = r.GetString2();
if(r.GetBool())
gd_info.y = r.GetString2();
if(r.GetBool())
gd_info.z = r.GetString2();
this.gdLstInfo.push(gd_info);
}
this.gdLst = ReadObjectLong(r);
var cnx_lst_count = Reader.GetLong();
for(index = 0; index < cnx_lst_count; ++index)
{
this.cnxLstInfo[index] = ReadObjectString(Reader);
}
var ah_xy_count = Reader.GetLong();
for(index = 0; index < ah_xy_count; ++index)
{
var o = {};
if(r.GetBool())
o.gdRefX = r.GetString2();
if(r.GetBool())
o.gdRefY = r.GetString2();
if(r.GetBool())
o.minX = r.GetString2();
if(r.GetBool())
o.maxX = r.GetString2();
if(r.GetBool())
o.minY = r.GetString2();
if(r.GetBool())
o.maxY = r.GetString2();
if(r.GetBool())
o.posX = r.GetString2();
if(r.GetBool())
o.posY = r.GetString2();
this.ahXYLstInfo.push(o);
}
var ah_polar_count = Reader.GetLong();
for(index = 0; index < ah_polar_count; ++index)
{
o = {};
if(r.GetBool())
o.gdRefR = r.GetString2();
if(r.GetBool())
o.gdRefAng = r.GetString2();
if(r.GetBool())
o.minR = r.GetString2();
if(r.GetBool())
o.maxR = r.GetString2();
if(r.GetBool())
o.minAng = r.GetString2();
if(r.GetBool())
o.maxAng = r.GetString2();
if(r.GetBool())
o.posX = r.GetString2();
if(r.GetBool())
o.posY = r.GetString2();
this.ahPolarLstInfo.push(o);
}
var path_count = Reader.GetLong();
for(index = 0; index < path_count; ++index)
{
this.pathLst[index] = new Path();
this.pathLst[index].Read_FromBinary2(Reader);
}
if(r.GetBool())
{
this.preset = r.GetString2();
}
if(r.GetBool())
{
this.rectS = {};
this.rectS.l = r.GetString2();
this.rectS.t = r.GetString2();
this.rectS.r = r.GetString2();
this.rectS.b = r.GetString2();
}
this.Init(5, 5);
},
AddAdj: function(name, formula, x, y, z)
{
this.gdLst[name] = parseInt(x);
this.avLst[name]=true;
},
AddGuide: function(name, formula, x, y, z)
{
this.gdLstInfo.push(
{
name: name,
formula: formula,
x: x,
y: y,
z: z,
isAdj: false
});
},
AddCnx: function(ang, x, y)
{
this.cnxLstInfo.push(
{
ang:ang,
x:x,
y:y
});
},
AddHandleXY: function(gdRefX, minX, maxX, gdRefY, minY, maxY, posX, posY)
{
this.ahXYLstInfo.push(
{
gdRefX:gdRefX,
minX:minX,
maxX:maxX,
gdRefY:gdRefY,
minY:minY,
maxY:maxY,
posX:posX,
posY:posY
});
},
AddHandlePolar: function(gdRefAng, minAng, maxAng, gdRefR, minR, maxR, posX, posY)
{
this.ahPolarLstInfo.push(
{
gdRefAng:gdRefAng,
minAng:minAng,
maxAng:maxAng,
gdRefR:gdRefR,
minR:minR,
maxR:maxR,
posX:posX,
posY:posY
})
},
AddPathCommand: function(command, x1, y1, x2, y2, x3, y3)
{
switch(command)
{
case 0:
{ /* extrusionOk, fill, stroke, w, h*/
this.pathLst[this.pathLst.length] = new Path(x1, y1, x2, y2, x3);
break;
}
case 1:
{
this.pathLst[this.pathLst.length-1].moveTo(x1, y1);
break;
}
case 2:
{
this.pathLst[this.pathLst.length-1].lnTo(x1, y1);
break;
}
case 3:
{
this.pathLst[this.pathLst.length-1].arcTo(x1/*wR*/, y1/*hR*/, x2/*stAng*/, y2/*swAng*/);
break;
}
case 4:
{
this.pathLst[this.pathLst.length-1].quadBezTo(x1, y1, x2, y2);
break;
}
case 5:
{
this.pathLst[this.pathLst.length-1].cubicBezTo(x1, y1, x2, y2, x3, y3);
break;
}
case 6:
{
this.pathLst[this.pathLst.length-1].close();
}
}
},
AddRect: function(l, t, r, b)
{
this.rectS = {};
this.rectS.l = l;
this.rectS.t = t;
this.rectS.r = r;
this.rectS.b = b;
},
canFill: function()
{
if(this.preset === "line")
return false;
for(var i = 0; i < this.pathLst.length; ++i)
{
if(this.pathLst[i].fill !== "none")
return true;
}
return false;
},
Init: function(w, h)
{
this.gdLst["_3cd4"]=16200000;
this.gdLst["_3cd8"]=8100000;
this.gdLst["_5cd8"]=13500000;
this.gdLst["_7cd8"]=18900000;
this.gdLst["cd2"]=10800000;
this.gdLst["cd4"]=5400000;
this.gdLst["cd8"]=2700000;
this.gdLst["l"]=0;
this.gdLst["t"]=0;
this.gdLst["h"]=h;
this.gdLst["b"]=h;
this.gdLst["hd2"]=h/2;
this.gdLst["hd3"]=h/3;
this.gdLst["hd4"]=h/4;
this.gdLst["hd5"]=h/5;
this.gdLst["hd6"]=h/6;
this.gdLst["hd8"]=h/8;
this.gdLst["hd10"]=h/10;
this.gdLst["hd12"]=h/12;
this.gdLst["hd32"]=h/32;
this.gdLst["vc"]=h/2;
this.gdLst["w"]=w;
this.gdLst["r"]=w;
this.gdLst["wd2"]=w/2;
this.gdLst["wd3"]=w/3;
this.gdLst["wd4"]=w/4;
this.gdLst["wd5"]=w/4;
this.gdLst["wd6"]=w/6;
this.gdLst["wd8"]=w/8;
this.gdLst["wd10"]=w/10;
this.gdLst["wd12"]=w/12;
this.gdLst["wd32"]=w/32;
this.gdLst["hc"]=w/2;
this.gdLst["ls"]=Math.max(w,h);
this.gdLst["ss"]=Math.min(w,h);
this.gdLst["ssd2"]=this.gdLst["ss"]/2;
this.gdLst["ssd4"]=this.gdLst["ss"]/4;
this.gdLst["ssd6"]=this.gdLst["ss"]/6;
this.gdLst["ssd8"]=this.gdLst["ss"]/8;
this.gdLst["ssd16"]=this.gdLst["ss"]/16;
this.gdLst["ssd32"]=this.gdLst["ss"]/32;
CalculateGuideLst(this.gdLstInfo, this.gdLst);
CalculateCnxLst(this.cnxLstInfo, this.cnxLst, this.gdLst);
CalculateAhXYList(this.ahXYLstInfo, this.ahXYLst, this.gdLst);
CalculateAhPolarList(this.ahPolarLstInfo, this.ahPolarLst, this.gdLst);
for(var i=0, n=this.pathLst.length; i<n; i++)
this.pathLst[i].init(this.gdLst);
if(this.rectS!=undefined)
{
this.rect={};
this.rect.l=this.gdLst[this.rectS.l];
if(this.rect.l===undefined)
{
this.rect.l=parseInt(this.rectS.l);
}
this.rect.t=this.gdLst[this.rectS.t];
if(this.rect.t===undefined)
{
this.rect.t=parseInt(this.rectS.t);
}
this.rect.r=this.gdLst[this.rectS.r];
if(this.rect.r===undefined)
{
this.rect.r=parseInt(this.rectS.r);
}
this.rect.b=this.gdLst[this.rectS.b];
if(this.rect.b===undefined)
{
this.rect.b=parseInt(this.rectS.b);
}
}
},
Recalculate: function(w, h)
{
this.gdLst["h"]=h;
this.gdLst["b"]=h;
this.gdLst["hd2"]=h*0.5;
this.gdLst["hd3"]=h*0.3333;
this.gdLst["hd4"]=h*0.25;
this.gdLst["hd5"]=h*0.2;
this.gdLst["hd6"]=h*0.1666666;
this.gdLst["hd8"]=h*0.125;
this.gdLst["hd10"]=h*0.1;
this.gdLst["hd12"]=h/12;
this.gdLst["hd32"]=h/32;
this.gdLst["vc"]=h*0.5;
this.gdLst["w"]=w;
this.gdLst["r"]=w;
this.gdLst["wd2"]=w*0.5;
this.gdLst["wd3"]=w/3;
this.gdLst["wd4"]=w*0.25;
this.gdLst["wd5"]=w*0.2;
this.gdLst["wd6"]=w*0.166666;
this.gdLst["wd8"]=w*0.125;
this.gdLst["wd10"]=w*0.1;
this.gdLst["wd12"]=w/12;
this.gdLst["wd32"]=w*0.03125;
this.gdLst["hc"]=w*0.5;
this.gdLst["ls"]=Math.max(w,h);
this.gdLst["ss"]=Math.min(w,h);
this.gdLst["ssd2"]=this.gdLst["ss"]*0.5;
this.gdLst["ssd4"]=this.gdLst["ss"]*0.25;
this.gdLst["ssd6"]=this.gdLst["ss"]*0.166666;
this.gdLst["ssd8"]=this.gdLst["ss"]*0.125;
this.gdLst["ssd16"]=this.gdLst["ss"]*0.0625;
this.gdLst["ssd32"]=this.gdLst["ss"]*0.03125;
CalculateGuideLst(this.gdLstInfo, this.gdLst);
CalculateCnxLst(this.cnxLstInfo, this.cnxLst, this.gdLst);
CalculateAhXYList(this.ahXYLstInfo, this.ahXYLst, this.gdLst);
CalculateAhPolarList(this.ahPolarLstInfo, this.ahPolarLst, this.gdLst);
for(var i=0, n=this.pathLst.length; i<n; i++)
this.pathLst[i].recalculate(this.gdLst);
if(this.rectS!=undefined)
{
this.rect={};
this.rect.l=this.gdLst[this.rectS.l];
if(this.rect.l===undefined)
{
this.rect.l=parseInt(this.rectS.l);
}
this.rect.t=this.gdLst[this.rectS.t];
if(this.rect.t===undefined)
{
this.rect.t=parseInt(this.rectS.t);
}
this.rect.r=this.gdLst[this.rectS.r];
if(this.rect.r===undefined)
{
this.rect.r=parseInt(this.rectS.r);
}
this.rect.b=this.gdLst[this.rectS.b];
if(this.rect.b===undefined)
{
this.rect.b=parseInt(this.rectS.b);
}
}
},
/*
draw: function(graphics, line_color, line_width, fill_color, alpha, fillAlpha, lineAlpha)
{
//graphics.m_oContext.shadowOffsetX = shadow.length*Math.cos(shadow.angle)*100/(g_dKoef_pix_to_mm*zoom);
//graphics.m_oContext.shadowOffsetY = shadow.length*Math.sin(shadow.angle)*100/(g_dKoef_pix_to_mm*zoom);
//graphics.m_oContext.shadowBlur = shadow.blur;
//graphics.m_oContext.shadowColor = shadow.color.norm(shadow.alpha);
graphics.p_width(line_width);
for(var i=0, n=this.pathLst.length; i<n;++i)
this.pathLst[i].draw(graphics, line_color, line_width, fill_color, alpha, fillAlpha*255, lineAlpha*255);
//if(shadow.length>0||shadow.blur>0)
//{
// graphics.m_oContext.shadowOffsetX = 0;
// graphics.m_oContext.shadowOffsetY = 0;
// graphics.m_oContext.shadowBlur = 0;
// graphics.m_oContext.shadowColor = 0;
// graphics.p_width(line_width*10000/(g_dKoef_pix_to_mm*zoom));
// for(i=0; i<n;++i)
// this.pathLst[i].draw(graphics, line_color, line_width, fill_color, alpha, fillAlpha*255, lineAlpha*255);
//}
},
*/
draw: function(shape_drawer)
{
for (var i=0, n=this.pathLst.length; i<n;++i)
this.pathLst[i].draw(shape_drawer);
},
check_bounds: function(checker)
{
for(var i=0, n=this.pathLst.length; i<n;++i)
this.pathLst[i].check_bounds(checker);
},
drawAdjustments: function(drawingDocument, transform)
{
var _adjustments = this.ahXYLst;
var _adj_count = _adjustments.length;
var _adj_index;
for(_adj_index = 0; _adj_index < _adj_count; ++_adj_index)
drawingDocument.DrawAdjustment(transform, _adjustments[_adj_index].posX, _adjustments[_adj_index].posY);
_adjustments = this.ahPolarLst;
_adj_count = _adjustments.length;
for(_adj_index = 0; _adj_index < _adj_count; ++_adj_index)
drawingDocument.DrawAdjustment(transform, _adjustments[_adj_index].posX, _adjustments[_adj_index].posY);
},
hitToPath: function(hitCanvasContext, x, y)
{
return false;
},
setPolarAdjustments: function(refR, rValue, refAng, angValue)
{
var history_data;
if(typeof refR === "string" && typeof this.gdLst[refR] === "number" && typeof rValue === "number")
{
history_data = {};
history_data.Type = historyitem_SetGuideValue;
history_data.guideName = refR;
history_data.oldGdValue = this.gdLst[refR];
history_data.newGdValue = rValue;
History.Add(this, history_data);
this.gdLst[refR] = rValue;
}
if( typeof refAng === "string" && typeof this.gdLst[refAng] === "number" && typeof angValue === "number")
{
history_data = {};
history_data.Type = historyitem_SetGuideValue;
history_data.guideName = refAng;
history_data.oldGdValue = this.gdLst[refAng];
history_data.newGdValue = angValue;
History.Add(this, history_data);
this.gdLst[refAng] = angValue;
}
},
setXYAdjustments: function(refX, xValue, refY, yValue)
{
var history_data;
if(typeof refX === "string" && typeof this.gdLst[refX] === "number" && typeof xValue === "number")
{
history_data = {};
history_data.Type = historyitem_SetGuideValue;
history_data.guideName = refX;
history_data.oldGdValue = this.gdLst[refX];
history_data.newGdValue = xValue;
History.Add(this, history_data);
this.gdLst[refX] = xValue;
}
if( typeof refY === "string" && typeof this.gdLst[refY] === "number" && typeof yValue === "number")
{
history_data = {};
history_data.Type = historyitem_SetGuideValue;
history_data.guideName = refY;
history_data.refAng = refY;
history_data.oldGdValue = this.gdLst[refY];
history_data.newGdValue = yValue;
History.Add(this, history_data);
this.gdLst[refY] = yValue;
}
},
setGuideValue: function(gdRef, gdValue, model_id)
{
if(isRealNumber(this.gdLst[gdRef]))
{
History.Add(g_oUndoRedoDrawingObject, historyitem_AutoShapes_SetGuideValue, model_id, null, {object: this, data:{ gdRef: gdRef, oldValue: this.gdLst[gdRef], newValue: gdValue}});
this.gdLst[gdRef] = gdValue;
}
},
Save_Changes: function(data, writer)
{
writer.WriteLong(historyitem_type_Geometry);
writer.WriteLong(data.Type);
switch (data.Type)
{
case historyitem_SetGuideValue:
{
writer.WriteString2(data.guideName);
writer.WriteDouble(data.newGdValue);
break;
}
}
},
Load_Changes: function(reader)
{
var type = reader.GetLong();
switch (type)
{
case historyitem_SetGuideValue:
{
var name = reader.GetString2();
this.gdLst[name] = reader.GetDouble();
break;
}
}
},
Undo: function(data)
{
switch(data.Type)
{
case historyitem_SetGuideValue:
{
this.gdLst[data.guideName] = data.oldValue;
break;
}
}
},
Redo: function(data)
{
switch(data.Type)
{
case historyitem_SetGuideValue:
{
this.gdLst[data.guideName] = data.newValue;
break;
}
}
},
Save_Changes: function(data, writer)
{},
hit: function(x, y)
{
},
hitInInnerArea: function(canvasContext, x, y)
{
var _path_list = this.pathLst;
var _path_count = _path_list.length;
var _path_index;
for(_path_index = 0; _path_index < _path_count; ++_path_index)
{
if(_path_list[_path_index].hitInInnerArea(canvasContext, x, y) === true)
return true;
}
return false;
},
hitInPath: function(canvasContext, x, y)
{
var _path_list = this.pathLst;
var _path_count = _path_list.length;
var _path_index;
for(_path_index = 0; _path_index < _path_count; ++_path_index)
{
if(_path_list[_path_index].hitInPath(canvasContext, x, y) === true)
return true;
}
return false;
},
hitToAdj: function(x, y, distanse)
{
var dx, dy;
for(var i=0; i<this.ahXYLst.length; i++)
{
dx=x-this.ahXYLst[i].posX;
dy=y-this.ahXYLst[i].posY;
if(Math.sqrt(dx*dx+dy*dy) < distanse)
{
return {hit: true, adjPolarFlag: false, adjNum: i};
}
}
for( i=0; i<this.ahPolarLst.length; i++)
{
dx=x-this.ahPolarLst[i].posX;
dy=y-this.ahPolarLst[i].posY;
if(Math.sqrt(dx*dx+dy*dy) < distanse)
{
return {hit: true, adjPolarFlag: true, adjNum: i};
}
}
return {hit: false, adjPolarFlag: null, adjNum: null};
},
getArrayPolygons: function(epsilon)
{
var used_epsilon;
if(typeof epsilon !== "number" || isNaN(epsilon))
used_epsilon = APPROXIMATE_EPSILON;
else
used_epsilon = epsilon;
var arr_polygons = [];
var cur_polygon = [];
for(var path_index = 0; path_index < this.pathLst.length; ++path_index)
{
var arr_cur_path_commands = this.pathLst[path_index].ArrPathCommand;
var last_command = null, last_point_x = null, last_point_y = null;
var first_point_x = null, first_point_y = null;
var bezier_polygon = null;
for(var command_index = 0; command_index < arr_cur_path_commands.length; ++command_index)
{
var cur_command = arr_cur_path_commands[command_index];
switch(cur_command.id)
{
case moveTo:
{
if(last_command === null || last_command.id === close)
{
cur_polygon.push({x: cur_command.X, y: cur_command.Y});
last_command = cur_command;
last_point_x = cur_command.X;
last_point_y = cur_command.Y;
first_point_x = cur_command.X;
first_point_y = cur_command.Y;
}
break;
}
case lineTo:
{
cur_polygon.push({x: cur_command.X, y: cur_command.Y});
last_command = cur_command;
last_point_x = cur_command.X;
last_point_y = cur_command.Y;
break;
}
case bezier3:
{
bezier_polygon = partition_bezier3(last_point_x, last_point_y, cur_command.X0, cur_command.Y0, cur_command.X1, cur_command.Y1, used_epsilon);
for(var point_index = 1; point_index < bezier_polygon.length; ++point_index)
{
cur_polygon.push(bezier_polygon[point_index]);
}
last_command = cur_command;
last_point_x = cur_command.X1;
last_point_y = cur_command.Y1;
break;
}
case bezier4:
{
bezier_polygon = partition_bezier4(last_point_x, last_point_y, cur_command.X0, cur_command.Y0, cur_command.X1, cur_command.Y1, cur_command.X2, cur_command.Y2, used_epsilon);
for(point_index = 1; point_index < bezier_polygon.length; ++point_index)
{
cur_polygon.push(bezier_polygon[point_index]);
}
last_command = cur_command;
last_point_x = cur_command.X2;
last_point_y = cur_command.Y2;
break;
}
case arcTo:
{
var path_accumulator = new PathAccumulator();
ArcToCurvers(path_accumulator, cur_command.stX, cur_command.stY, cur_command.wR, cur_command.hR, cur_command.stAng, cur_command.swAng);
var arc_to_path_commands = path_accumulator.pathCommand;
for(var arc_to_path_index = 0; arc_to_path_index < arc_to_path_commands.length; ++arc_to_path_index)
{
var cur_arc_to_command = arc_to_path_commands[arc_to_path_index];
switch (cur_arc_to_command.id)
{
case moveTo:
{
cur_polygon.push({x: cur_arc_to_command.X, y: cur_arc_to_command.Y});
last_command = cur_arc_to_command;
last_point_x = cur_arc_to_command.X;
last_point_y = cur_arc_to_command.Y;
break;
}
case bezier4:
{
bezier_polygon = partition_bezier4(last_point_x, last_point_y, cur_arc_to_command.X0, cur_arc_to_command.Y0, cur_arc_to_command.X1, cur_arc_to_command.Y1, cur_arc_to_command.X2, cur_arc_to_command.Y2, used_epsilon);
for(point_index = 0; point_index < bezier_polygon.length; ++point_index)
{
cur_polygon.push(bezier_polygon[point_index]);
}
last_command = cur_arc_to_command;
last_point_x = cur_arc_to_command.X2;
last_point_y = cur_arc_to_command.Y2;
break;
}
}
}
break;
}
case close:
{
if(last_command.id !== moveTo)
{
if(cur_polygon.length >= 2)
{
if(first_point_x !== null && first_point_y !== null)
{
cur_polygon.push({x: first_point_x, y: first_point_y});
}
arr_polygons.push(cur_polygon);
}
cur_polygon = [];
last_command = cur_command;
}
break;
}
}
}
if(cur_polygon.length >= 2)
{
/*if(first_point_x !== null && first_point_y !== null)
{
cur_polygon.push({x: first_point_x, y: first_point_y});
} */
arr_polygons.push(cur_polygon);
}
}
return arr_polygons;
},
getBounds: function()
{
}
};
function WriteGdInfo(Writer, gdInfo)
{
Writer.WriteString2(gdInfo.name);
Writer.WriteLong(gdInfo.formula);
var flag = typeof gdInfo.x === "string";
Writer.WriteBool(flag);
if(flag)
Writer.WriteString2(gdInfo.x);
else
return;
flag = typeof gdInfo.y === "string";
Writer.WriteBool(flag);
if(flag)
Writer.WriteString2(gdInfo.y);
else
return;
flag = typeof gdInfo.z === "string";
Writer.WriteBool(flag);
if(flag)
Writer.WriteString2(gdInfo.z);
}
function ReadGdInfo(Reader)
{
var ret = {};
ret.name = Reader.GetString2();
ret.formula = Reader.GetLong();
if(Reader.GetBool())
ret.x = Reader.GetString2();
else
return;
if(Reader.GetBool())
ret.y = Reader.GetString2();
else
return;
if(Reader.GetBool())
ret.z = Reader.GetString2();
}
function WriteObjectDouble(Writer, Object)
{
var field_count = 0;
for(var key in Object)
{
++field_count;
}
Writer.WriteLong(field_count);
for(key in Object)
{
Writer.WriteString2(key);
Writer.WriteDouble(Object[key]);
}
}
function ReadObjectDouble(Reader)
{
var ret = {};
var field_count = Reader.GetLong();
for(var index =0; index < field_count; ++index)
{
var key = Reader.GetString2();
ret[key] = Reader.GetDouble();
}
return ret;
}
function WriteObjectString(Writer, Object)
{
var field_count = 0;
for(var key in Object)
{
++field_count;
}
Writer.WriteLong(field_count);
for(key in Object)
{
Writer.WriteString2(key);
Writer.WriteString2(Object[key]);
}
}
function ReadObjectString(Reader)
{
var ret = {};
var field_count = Reader.GetLong();
for(var index = 0; index < field_count; ++index)
{
var key = Reader.GetString2();
ret[key] = Reader.GetString2();
}
return ret;
}
function WriteObjectBool(Writer, Object)
{
var field_count = 0;
for(var key in Object)
{
++field_count;
}
Writer.WriteLong(field_count);
for(key in Object)
{
Writer.WriteString2(key);
Writer.WriteBool(Object[key]);
}
}
function ReadObjectBool(Reader)
{
var ret = {};
var field_count = Reader.GetLong();
for(var index =0; index < field_count; ++index)
{
var key = Reader.GetString2();
ret[key] = Reader.GetBool();
}
return ret;
}
function PathAccumulator()
{
this.pathCommand = [];
}
PathAccumulator.prototype =
{
_m: function(x, y)
{
this.pathCommand.push({id: moveTo, X: x, Y: y});
},
_c: function(x0, y0, x1, y1, x2, y2)
{
this.pathCommand.push({id: bezier4, X0: x0, Y0: y0, X1: x1, Y1: y1, X2: x2, Y2: y2});
}
};
function GraphEdge(point1, point2)
{
if(point1.y <= point2.y)
{
this.point1 = point1;
this.point2 = point2;
}
else
{
this.point1 = point2;
this.point2 = point1;
}
}
GraphEdge.prototype =
{
getIntersectionPointX : function(y)
{
if(this.point2.y < y || this.point1.y > y)
{
return null;
}
var ret = { x1 : +0, x2 : +0, count : 1 | 0 };
if(this.point1.y === this.point2.y)
{
ret.count = 2;
if(this.point1.x <= this.point2.x)
{
ret.x1 = this.point1.x;
ret.x2 = this.point2.x;
return ret;
}
else
{
ret.x1 = this.point2.x;
ret.x2 = this.point1.x;
return ret;
}
}
else
{
if(!(this.point1.x === this.point2.x))
{
ret.x1 = this.point1.x + ((y - this.point1.y)/(this.point2.y - this.point1.y))*(this.point2.x - this.point1.x);
return ret;
}
else
{
ret.x1 = this.point1.x;
return ret;
}
}
}
};
function ComparisonEdgeByTopPoint(graphEdge1, graphEdge2)
{
return Math.min(graphEdge1.point1.y, graphEdge1.point2.y) - Math.min(graphEdge2.point1.y, graphEdge2.point2.y);
}
\ No newline at end of file
function MoveTrackGroup(originalGroup, majorOffsetX, majorOffsetY)
{
this.originalGroup = originalGroup;
this.posX = originalGroup.absOffsetX;
this.posY = originalGroup.absOffsetY;
this.pageIndex = originalGroup.pageIndex;
this.flipH = originalGroup.absFlipH;
this.flipV = originalGroup.absFlipV;
this.horCenter = originalGroup.absExtX*0.5;
this.verCenter = originalGroup.absExtY*0.5;
this.rot = originalGroup.absRot;
this.majorOffsetX = majorOffsetX;
this.majorOffsetY = majorOffsetY;
this.transformMatrix = originalGroup.transform.CreateDublicate();
this.graphicObjects = [];
for(var _shape_index = 0; _shape_index < originalGroup.arrGraphicObjects.length; ++_shape_index)
{
this.graphicObjects[_shape_index] = this.originalGroup.arrGraphicObjects[_shape_index].createObjectForDrawOnOverlayInGroup();
}
this.track = function(posX, posY, pageIndex)
{
this.posX = posX + this.majorOffsetX;
this.posY = posY + this.majorOffsetY;
this.pageIndex = pageIndex;
this.calculateTransformMatrix();
for(var _shape_index = 0; _shape_index < this.graphicObjects.length; ++_shape_index)
{
this.graphicObjects[_shape_index].pageIndex = pageIndex;
this.graphicObjects[_shape_index].calculateFullTransform(this.transformMatrix);
}
};
this.draw = function(overlay)
{
for(var _shape_index = 0; _shape_index < this.graphicObjects.length; ++_shape_index)
this.graphicObjects[_shape_index].draw(overlay);
};
this.getBounds = function()
{
var bounds_checker = new CSlideBoundsChecker();
bounds_checker.init(Page_Width, Page_Height, Page_Width, Page_Height);
this.draw(bounds_checker);
return {l: bounds_checker.Bounds.min_x, t: bounds_checker.Bounds.min_y, r: bounds_checker.Bounds.max_x , b: bounds_checker.Bounds.max_y};
};
this.getBoundsRect = function()
{
var t = this.transformMatrix;
var min_x, max_x, min_y, max_y;
min_x = t.TransformPointX(0, 0);
max_x = min_x;
min_y = t.TransformPointY(0, 0);
max_y = min_y;
var t_x, t_y;
var or_sp = this.originalGroup;
var arr = [{x: or_sp.absExtX, y: 0}, {x: or_sp.absExtX, y: or_sp.absExtY}, {x: 0, y: or_sp.absExtY}];
for(var i = 0; i < arr.length; ++i)
{
var p = arr[i];
t_x = t.TransformPointX(p.x, p.y);
t_y = t.TransformPointY(p.x, p.y);
if(t_x < min_x)
min_x = t_x;
if(t_x > max_x)
max_x = t_x;
if(t_y < min_y)
min_y = t_y;
if(t_y > max_y)
max_y = t_y;
}
return {l: min_x, t: min_y, r: max_x, b: max_y};
};
this.trackEnd = function()
{
this.boolChangePos = true;
this.originalGroup.updatePosition(this.posX, this.posY);
};
this.calculateTransformMatrix = function()
{
var _transform = this.transformMatrix;
_transform.Reset();
var _horizontal_center = this.horCenter;
var _vertical_center = this.verCenter;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.flipH)
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
if(this.flipV)
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
global_MatrixTransformer.RotateRadAppend(_transform, -this.rot);
global_MatrixTransformer.TranslateAppend(_transform, this.posX, this.posY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
};
}
function ResizeTrackGroup(originalGroup, numberHandle, pageIndex)
{
this.pageIndex = pageIndex;
this.originalGroup = originalGroup;
this.originalOffsetX = originalGroup.absOffsetX;
this.originalOffsetY = originalGroup.absOffsetY;
this.originalExtX = originalGroup.absExtX;
this.originalExtY = originalGroup.absExtY;
this.originalFlipH = originalGroup.absFlipH;
this.originalFlipV = originalGroup.absFlipV;
this.originalRot = originalGroup.absRot;
//--
this.resizedOffsetX = originalGroup.absOffsetX;
this.resizedOffsetY = originalGroup.absOffsetY;
this.resizedPosX = this.resizedOffsetX;
this.resizedPosY = this.resizedOffsetY;
this.resizedExtX = originalGroup.absExtX;
this.resizedExtY = originalGroup.absExtY;
this.usedExtX = this.originalExtX === 0 ? 0.01 : this.originalExtX;
this.usedExtY = this.originalExtY === 0 ? 0.01 : this.originalExtY;
this.resizedFlipH = originalGroup.absFlipH;
this.resizedFlipV = originalGroup.absFlipV;
this.resizedRot = originalGroup.absRot;
var _translated_num_handle;
if(!this.originalFlipH && !this.originalFlipV)
{
_translated_num_handle = numberHandle;
}
else if(this.originalFlipH && !this.originalFlipV)
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_H[numberHandle];
}
else if(!this.originalFlipH && this.originalFlipV)
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_V[numberHandle];
}
else
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[numberHandle];
}
this.translatetNumberHandle = _translated_num_handle;
this.bAspect = typeof numberHandle === "number" && numberHandle % 2 === 0;
this.aspect = this.bAspect === true ? this.originalGroup.getAspect(_translated_num_handle) : 0;
this.sin = Math.sin(this.originalRot);
this.cos = Math.cos(this.originalRot);
var _half_width = this.originalExtX*0.5;
var _half_height = this.originalExtY*0.5;
var _sin = this.sin;
var _cos = this.cos;
switch (_translated_num_handle)
{
case 0:
case 1:
{
this.fixedPointX = (_half_width*_cos - _half_height*_sin) + _half_width + this.originalOffsetX;
this.fixedPointY = (_half_width*_sin + _half_height*_cos) + _half_height + this.originalOffsetY;
break;
}
case 2:
case 3:
{
this.fixedPointX = (-_half_width*_cos - _half_height*_sin) + _half_width + this.originalOffsetX;
this.fixedPointY = (-_half_width*_sin + _half_height*_cos) + _half_height + this.originalOffsetY;
break;
}
case 4:
case 5:
{
this.fixedPointX = (-_half_width*_cos + _half_height*_sin) + _half_width + this.originalOffsetX;
this.fixedPointY = (-_half_width*_sin - _half_height*_cos) + _half_height + this.originalOffsetY;
break;
}
case 6:
case 7:
{
this.fixedPointX = (_half_width*_cos + _half_height*_sin) + _half_width + this.originalOffsetX;
this.fixedPointY = (_half_width*_sin - _half_height*_cos) + _half_height + this.originalOffsetY;
break;
}
}
this.mod = this.translatetNumberHandle % 4;
this.centerPointX = this.originalOffsetX + _half_width;
this.centerPointY = this.originalOffsetY + _half_height;
this.transformMatrix = originalGroup.transform.CreateDublicate();
this.bChangeCoef = this.translatetNumberHandle % 2 === 0 && this.originalFlipH !== this.originalFlipV;
this.childTracks = [];
var _original_sp_tree = originalGroup.spTree;
var _original_count = _original_sp_tree.length;
for(var _original_index = 0; _original_index < _original_count; ++_original_index)
{
this.childTracks.push(_original_sp_tree[_original_index].createObjectForResizeInGroup());
}
this.resize = function(kd1, kd2, shiftKey)
{
var _cos = this.cos;
var _sin = this.sin;
var _real_height, _real_width;
var _abs_height, _abs_width;
var _new_resize_half_width;
var _new_resize_half_height;
var _new_used_half_width;
var _new_used_half_height;
var _temp;
if(shiftKey === true && this.bAspect === true)
{
var _new_aspect = this.aspect*(Math.abs(kd1/ kd2));
if (_new_aspect >= this.aspect)
kd2 = Math.abs(kd1)*(kd2 >= 0 ? 1 : -1 );
else
kd1 = Math.abs(kd2)*(kd1 >= 0 ? 1 : -1);
}
if(this.bChangeCoef)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
switch (this.translatetNumberHandle)
{
case 0:
case 1:
{
if(this.translatetNumberHandle === 0)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedFlipH = !this.originalFlipH;
else
this.resizedFlipH = this.originalFlipH;
}
if(this.translatetNumberHandle === 1)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedFlipV = !this.originalFlipV;
else
this.resizedFlipV = this.originalFlipV;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedFlipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedFlipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (-_new_used_half_width*_cos + _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (-_new_used_half_width*_sin - _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 2:
case 3:
{
if(this.translatetNumberHandle === 2)
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedFlipV = !this.originalFlipV;
else
this.resizedFlipV = this.originalFlipV;
}
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedFlipH = !this.originalFlipH;
else
this.resizedFlipH = this.originalFlipH;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedFlipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedFlipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (_new_used_half_width*_cos + _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (_new_used_half_width*_sin - _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 4:
case 5:
{
if(this.translatetNumberHandle === 4)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedFlipH = !this.originalFlipH;
else
this.resizedFlipH = this.originalFlipH;
}
else
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedFlipV = !this.originalFlipV;
else
this.resizedFlipV = this.originalFlipV;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedFlipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedFlipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (_new_used_half_width*_cos - _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (_new_used_half_width*_sin + _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 6:
case 7:
{
if(this.translatetNumberHandle === 6)
{
_real_height = this.usedExtY*kd1;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedFlipV = !this.originalFlipV;
else
this.resizedFlipV = this.originalFlipV;
}
else
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
}
_real_width = this.usedExtX*kd2;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedFlipH = !this.originalFlipH;
else
this.resizedFlipH = this.originalFlipH;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedFlipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedFlipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (-_new_used_half_width*_cos - _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (-_new_used_half_width*_sin + _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
}
var _transform = this.transformMatrix;
_transform.Reset();
var _horizontal_center = this.resizedExtX*0.5;
var _vertical_center = this.resizedExtY*0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.resizedFlipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.resizedFlipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.resizedRot);
global_MatrixTransformer.TranslateAppend(_transform, this.resizedPosX, this.resizedPosY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
var _kw = this.resizedExtX/this.originalExtX;
var _kh = this.resizedExtY/this.originalExtY;
for(var _child_index = 0; _child_index < this.childTracks.length; ++_child_index)
{
this.childTracks[_child_index].changeSizes(_kw, _kh, _horizontal_center, _vertical_center);
this.childTracks[_child_index].calculateTransformMatrix(_transform);
}
};
this.resizeRelativeCenter = function(kd1, kd2, shiftKey)
{
kd1 = 2*kd1 - 1;
kd2 = 2*kd2 - 1;
var _real_height, _real_width;
var _abs_height, _abs_width;
if(shiftKey === true && this.bAspect === true)
{
var _new_aspect = this.aspect*(Math.abs(kd1/ kd2));
if (_new_aspect >= this.aspect)
kd2 = Math.abs(kd1)*(kd2 >= 0 ? 1 : -1 );
else
kd1 = Math.abs(kd2)*(kd1 >= 0 ? 1 : -1);
}
var _temp;
if(this.bChangeCoef)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
if(this.mod === 0 || this.mod === 1)
{
if(this.mod === 0)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
this.resizedFlipH = _real_width < 0 ? !this.originalFlipH : this.originalFlipH;
}
else
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
this.resizedFlipV = _real_height < 0 ? !this.originalFlipV : this.originalFlipV;
}
else
{
if(this.mod === 2)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
this.resizedFlipV = _real_height < 0 ? !this.originalFlipV : this.originalFlipV;
}
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
this.resizedFlipH = _real_width < 0 ? !this.originalFlipH : this.originalFlipH;
}
this.resizedPosX = this.centerPointX - this.resizedExtX*0.5;
this.resizedPosY = this.centerPointY - this.resizedExtY*0.5;
var _transform = this.transformMatrix;
_transform.Reset();
var _horizontal_center = this.resizedExtX*0.5;
var _vertical_center = this.resizedExtY*0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.resizedFlipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.resizedFlipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.resizedRot);
global_MatrixTransformer.TranslateAppend(_transform, this.resizedPosX, this.resizedPosY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
var _kw = this.resizedExtX/this.originalExtX;
var _kh = this.resizedExtY/this.originalExtY;
for(var _child_index = 0; _child_index < this.childTracks.length; ++_child_index)
{
this.childTracks[_child_index].changeSizes(_kw, _kh, _horizontal_center, _vertical_center);
this.childTracks[_child_index].calculateTransformMatrix(_transform);
}
};
this.draw = function(overlay)
{
overlay.SetCurrentPage(this.pageIndex);
for(var _child_index = 0; _child_index < this.childTracks.length; ++_child_index)
{
this.childTracks[_child_index].draw(overlay);
}
};
this.getBounds = function()
{
var bounds_checker = new CSlideBoundsChecker();
bounds_checker.init(Page_Width, Page_Height, Page_Width, Page_Height);
this.draw(bounds_checker);
return {l: bounds_checker.Bounds.min_x, t: bounds_checker.Bounds.min_y, r: bounds_checker.Bounds.max_x , b: bounds_checker.Bounds.max_y};
};
this.getBoundsRect = function()
{
var t = this.transformMatrix;
var min_x, max_x, min_y, max_y;
min_x = t.TransformPointX(0, 0);
max_x = min_x;
min_y = t.TransformPointY(0, 0);
max_y = min_y;
var arr = [{x: this.resizedPosX, y: 0}, {x: this.resizedPosX, y: this.resizedPosY}, {x: 0, y: this.resizedPosY}];
var t_x, t_y;
for(var i = 0; i < arr.length; ++i)
{
var p = arr[i];
t_x = t.TransformPointX(p.x, p.y);
t_y = t.TransformPointY(p.x, p.y);
if(t_x < min_x)
min_x = t_x;
if(t_x > max_x)
max_x = t_x;
if(t_y < min_y)
min_y = t_y;
if(t_y > max_y)
max_y = t_y;
}
return {l: min_x, t: min_y, r: max_x, b: max_y};
};
this.endTrack = function()
{
var bChange = this.resizedExtX !== this.originalGroup.absExtX || this.resizedExtY !== this.originalGroup.absExtY ||
this.resizedOffsetX !== this.resizedPosX || this.resizedOffsetY !== this.resizedPosY || this.resizedFlipH !== this.originalGroup.absFlipH ||
this.resizedFlipV !== this.originalGroup.absFlipV;
if(bChange)
{
this.boolChangePos = true;
this.originalGroup.setSizes(this.resizedPosX, this.resizedPosY, this.resizedExtX, this.resizedExtY, this.resizedFlipH, this.resizedFlipV, this.childTracks);
}
else
{
this.boolChangePos = false;
}
/*var _kw, _kh;
_kw = this.resizedExtX/this.originalGroup.absExtX;
_kh = this.resizedExtY/this.originalGroup.absExtY;
this.originalGroup.setSizes(this.resizedPosX, this.resizedPosY, this.resizedExtX, this.resizedExtY, this.resizedFlipH, this.resizedFlipV);
this.originalGroup.setAbsoluteTransform(this.resizedPosX, this.resizedPosY, this.resizedExtX, this.resizedExtY, null, this.resizedFlipH, this.resizedFlipV);
this.originalGroup.calculateTransformMatrix();
for(var _child_index = 0; _child_index < this.childTracks.length; ++_child_index)
this.childTracks[_child_index].endTrack();
this.originalGroup.startChangeChildSizes(_kw, _kh);
this.originalGroup.startCalculateAfterInternalResize();*/
};
}
function RotateTrackGroup(originalGroup, pageIndex)
{
this.originalGroup = originalGroup;
this.pageIndex = pageIndex;
this.originalRot = this.originalGroup.absRot;
this.rot = this.originalGroup.absRot;
this.transformMatrix = this.originalGroup.transform.CreateDublicate();
this.graphicObjects = [];
for(var _shape_index = 0; _shape_index < originalGroup.arrGraphicObjects.length; ++_shape_index)
{
this.graphicObjects[_shape_index] = this.originalGroup.arrGraphicObjects[_shape_index].createObjectForDrawOnOverlayInGroup();
}
this.track = function(angle, shiftKey)
{
var _new_rot = angle + this.originalRot;
while(_new_rot < 0)
_new_rot += 2*Math.PI;
while(_new_rot >= 2*Math.PI)
_new_rot -= 2*Math.PI;
if(_new_rot < MIN_ANGLE || _new_rot > 2*Math.PI - MIN_ANGLE)
{
_new_rot = 0;
}
if(Math.abs(_new_rot-Math.PI*0.5) < MIN_ANGLE)
{
_new_rot = Math.PI*0.5;
}
if(Math.abs(_new_rot-Math.PI) < MIN_ANGLE)
{
_new_rot = Math.PI;
}
if(Math.abs(_new_rot-1.5*Math.PI) < MIN_ANGLE)
{
_new_rot = 1.5*Math.PI;
}
if(shiftKey)
{
_new_rot = (Math.PI/12)*Math.floor(12*_new_rot/(Math.PI));
}
this.rot = _new_rot;
this.calculateTransformMatrix();
for(var _shape_index = 0; _shape_index < this.graphicObjects.length; ++_shape_index)
{
this.graphicObjects[_shape_index].pageIndex = pageIndex;
this.graphicObjects[_shape_index].calculateFullTransform(this.transformMatrix);
}
};
this.getBounds = function()
{
var bounds_checker = new CSlideBoundsChecker();
bounds_checker.init(Page_Width, Page_Height, Page_Width, Page_Height);
this.draw(bounds_checker);
return {l: bounds_checker.Bounds.min_x, t: bounds_checker.Bounds.min_y, r: bounds_checker.Bounds.max_x , b: bounds_checker.Bounds.max_y};
};
this.getBoundsRect = function()
{
var t = this.transformMatrix;
var max_x, min_x, max_y, min_y;
max_x = t.TransformPointX(0, 0);
min_x = max_x;
max_y = t.TransformPointY(0, 0);
min_y = max_y;
var or_sp = this.originalGroup;
var arr = [{x: or_sp.absExtX, y: 0}, {x: or_sp.absExtX, y: or_sp.absExtY}, {x: 0, y: or_sp.absExtY}];
for(var i = 0; i < arr.length; ++i)
{
var p = arr[i];
var t_x = t.TransformPointX(p.x, p.y);
var t_y = t.TransformPointY(p.x, p.y);
if(t_x < min_x)
min_x = t_x;
if(t_x > max_x)
max_x = t_x;
if(t_y < min_y)
min_y = t_y;
if(t_y > max_y)
max_y = t_y;
}
return {l: min_x, t: min_y, r: max_x, b: max_y};
};
this.calculateTransformMatrix = function()
{
var _transform = this.transformMatrix;
_transform.Reset();
var _horizontal_center = this.originalGroup.absExtX*0.5;
var _vertical_center = this.originalGroup.absExtY*0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.originalGroup.absFlipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.originalGroup.absFlipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.rot);
global_MatrixTransformer.TranslateAppend(_transform, this.originalGroup.absOffsetX, this.originalGroup.absOffsetY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
};
this.draw = function(overlay)
{
for(var _shape_index = 0; _shape_index < this.graphicObjects.length; ++_shape_index)
this.graphicObjects[_shape_index].draw(overlay);
};
this.getBounds = function()
{
var bounds_checker = new CSlideBoundsChecker();
bounds_checker.init(Page_Width, Page_Height, Page_Width, Page_Height);
this.draw(bounds_checker);
return {l: bounds_checker.Bounds.min_x, t: bounds_checker.Bounds.min_y, r: bounds_checker.Bounds.max_x , b: bounds_checker.Bounds.max_y};
};
this.trackEnd = function()
{
if(this.rot !== this.originalGroup.absRot)
{
this.originalGroup.setXfrm(null, null, null, null, this.rot, null, null);
this.originalGroup.setAbsoluteTransform(null, null, null, null, this.rot, null, null);
this.originalGroup.recalculate();
}
this.boolChangePos = true;
};
}
var moveTo=0,
lineTo=1,
arcTo=2,
bezier3=3,
bezier4=4,
close=5;
var PATH_COMMAND_START = 0x101;
var PATH_COMMAND_END = 0x102;
var cToRad = Math.PI / 10800000.0;
var cToDeg = 1/cToRad;
function Path(extrusionOk, fill, stroke, w, h)
{
if(stroke!=undefined)
this.stroke = stroke;
else
this.stroke = true;
this.extrusionOk = extrusionOk||false;
this.fill = fill||'norm';
this.pathW = w;
this.pathH = h;
if(this.pathW!=undefined)
{
this.divPW = 1/w;
}
if(this.pathH != undefined)
{
this.divPH = 1/h;
}
this.ArrPathCommandInfo = new Array();
this.ArrPathCommand = new Array();
this.createDuplicate = function()
{
var duplicate = new Path(this.extrusionOk, this.fill, this.stroke, this.pathW, this.pathH);
for(var i = 0; i<this.ArrPathCommandInfo.length; ++i)
{
duplicate.ArrPathCommandInfo[i] = clonePrototype(this.ArrPathCommandInfo[i]);
}
/*for (i = 0; i < this.ArrPathCommand.length; ++i)
{
duplicate.ArrPathCommand[i] = clonePrototype(this.ArrPathCommand[i]);
} */
return duplicate;
}
}
Path.prototype = {
Write_ToBinary2: function(writer)
{
writer.WriteBool(this.stroke);
writer.WriteBool(this.extrusionOk);
writer.WriteString2(this.fill);
var flag = this.pathW != undefined;
writer.WriteBool(flag);
if(flag)
writer.WriteLong(this.pathW);
flag = this.pathH != undefined;
writer.WriteBool(flag);
if(flag)
writer.WriteLong(this.pathH);
flag = this.divPW != undefined;
writer.WriteBool(flag);
if(flag)
writer.WriteDouble(this.divPW);
flag = this.divPH != undefined;
writer.WriteBool(flag);
if(flag)
writer.WriteDouble(this.divPH);
var path_command_count = this.ArrPathCommandInfo.length;
writer.WriteLong(path_command_count);
var write_function = /*typeof this.pathH === "number" ? writer.WriteLong :*/ writer.WriteString2;
for(var index = 0; index < path_command_count; ++index)
{
var c = this.ArrPathCommandInfo[index];
switch (c.id)
{
case moveTo:
case lineTo:
{
writer.WriteLong(c.id);
write_function.call(writer,c.X);
write_function.call(writer,c.Y);
break;
}
case bezier3:
{
writer.WriteLong(c.id);
write_function.call(writer,c.X0);
write_function.call(writer,c.Y0);
write_function.call(writer,c.X1);
write_function.call(writer,c.Y1);
break;
}
case bezier4:
{
writer.WriteLong(c.id);
write_function.call(writer,c.X0);
write_function.call(writer,c.Y0);
write_function.call(writer,c.X1);
write_function.call(writer,c.Y1);
write_function.call(writer,c.X2);
write_function.call(writer,c.Y2);
break;
}
case arcTo:
{
writer.WriteLong(c.id);
write_function.call(writer,c.hR);
write_function.call(writer,c.wR);
write_function.call(writer,c.stAng);
write_function.call(writer,c.swAng);
break;
}
case close:
{
writer.WriteLong(c.id);
break;
}
}
}
for(index = 0; index < path_command_count; ++index)
{
WriteObjectLong(writer, this.ArrPathCommand[index]);
}
},
Read_FromBinary2: function(Reader)
{
this.stroke = Reader.GetBool();
this.extrusionOk = Reader.GetBool();
this.fill = Reader.GetString2();
var flag = Reader.GetBool();
if(flag)
this.pathW = Reader.GetLong();
flag = Reader.GetBool();
if(flag)
this.pathH = Reader.GetLong();
flag = Reader.GetBool();
if(flag)
this.divPW = Reader.GetDouble();
flag = Reader.GetBool();
if(flag)
this.divPH = Reader.GetDouble();
if(typeof this.pathW === "number")
this.divPW = 1/this.pathW;
if(typeof this.pathH === "number")
this.divPH = 1/this.pathH;
var path_command_count = Reader.GetLong();
var read_function = /*typeof this.pathH === "number" ? Reader.GetLong :*/ Reader.GetString2;
for(var index = 0; index < path_command_count; ++index)
{
var c = {};
var id = Reader.GetLong();
c.id = id;
switch (id)
{
case moveTo:
case lineTo:
{
c.X = read_function.call(Reader);
c.Y = read_function.call(Reader);
break;
}
case bezier3:
{
c.X0 = read_function.call(Reader);
c.Y0 = read_function.call(Reader);
c.X1 = read_function.call(Reader);
c.Y1 = read_function.call(Reader);
break;
}
case bezier4:
{
c.X0 = read_function.call(Reader);
c.Y0 = read_function.call(Reader);
c.X1 = read_function.call(Reader);
c.Y1 = read_function.call(Reader);
c.X2 = read_function.call(Reader);
c.Y2 = read_function.call(Reader);
break;
}
case arcTo:
{
c.hR = read_function.call(Reader);
c.wR = read_function.call(Reader);
c.stAng = read_function.call(Reader);
c.swAng = read_function.call(Reader);
break;
}
case close:
{
break;
}
}
for(var key in c)
{
if(!isNaN(parseInt(c[key], 10)))
c[key] = parseInt(c[key], 10);
}
this.ArrPathCommandInfo.push(c);
}
for(index = 0; index < path_command_count; ++index)
{
this.ArrPathCommand[index] = ReadObjectLong(Reader);
}
},
moveTo: function(x, y)
{
if(!isNaN(parseInt(x,10)))
x=parseInt(x,10);
if(!isNaN(parseInt(y,10)))
y=parseInt(y,10);
this.ArrPathCommandInfo.push({id:moveTo, X:x, Y:y});
},
lnTo: function(x, y)
{
if(!isNaN(parseInt(x,10)))
x=parseInt(x,10);
if(!isNaN(parseInt(y,10)))
y=parseInt(y,10);
this.ArrPathCommandInfo.push({id:lineTo, X:x, Y:y});
},
arcTo: function(wR, hR, stAng, swAng)
{
if(!isNaN(parseInt(wR,10)))
wR=parseInt(wR,10);
if(!isNaN(parseInt(hR,10)))
hR=parseInt(hR,10);
if(!isNaN(parseInt(stAng,10)))
stAng=parseInt(stAng,10);
if(!isNaN(parseInt(swAng,10)))
swAng=parseInt(swAng,10);
this.ArrPathCommandInfo.push({id: arcTo, wR: wR, hR: hR, stAng: stAng, swAng: swAng});
},
quadBezTo: function(x0, y0, x1, y1)
{
if(!isNaN(parseInt(x0,10)))
x0=parseInt(x0,10);
if(!isNaN(parseInt(y0,10)))
y0=parseInt(y0,10);
if(!isNaN(parseInt(x1,10)))
x1=parseInt(x1,10);
if(!isNaN(parseInt(y1,10)))
y1=parseInt(y1,10);
this.ArrPathCommandInfo.push({id:bezier3, X0:x0, Y0:y0, X1:x1, Y1:y1});
},
cubicBezTo: function(x0, y0, x1, y1, x2, y2)
{
if(!isNaN(parseInt(x0,10)))
x0=parseInt(x0,10);
if(!isNaN(parseInt(y0,10)))
y0=parseInt(y0,10);
if(!isNaN(parseInt(x1,10)))
x1=parseInt(x1,10);
if(!isNaN(parseInt(y1,10)))
y1=parseInt(y1,10);
if(!isNaN(parseInt(x2,10)))
x2=parseInt(x2,10);
if(!isNaN(parseInt(y2,10)))
y2=parseInt(y2,10);
this.ArrPathCommandInfo.push({id:bezier4, X0:x0, Y0:y0, X1:x1, Y1:y1, X2:x2, Y2:y2});
},
close: function()
{
this.ArrPathCommandInfo.push({id:close});
},
init: function(gdLst)
{
if(this.ArrPathCommandInfo.length === this.ArrPathCommand.length)
{
this.ArrPathCommand.length = 0;
/*this.recalculate(gdLst);
return; */
}
var ch, cw;
if(this.pathW!=undefined)
{
cw = (gdLst["w"]/this.pathW);
}
else
{
cw=1;
}
if(this.pathH!=undefined)
{
ch = (gdLst["h"]/this.pathH);
}
else
{
ch=1;
}
var APCI=this.ArrPathCommandInfo, n = APCI.length, cmd;
var x0, y0, x1, y1, x2, y2, wR, hR, stAng, swAng, lastX, lastY;
for(var i=0; i<n; i++)
{
cmd=APCI[i];
switch(cmd.id)
{
case moveTo:
case lineTo:
{
x0=parseInt(cmd.X);
if(isNaN(x0))
{
x0=gdLst[cmd.X];
}
y0=parseInt(cmd.Y);
if(isNaN(y0))
{
y0=gdLst[cmd.Y];
}
this.ArrPathCommand.push({id:cmd.id, X:x0*cw, Y:y0*ch});
lastX=x0*cw;
lastY=y0*ch;
break;
}
case bezier3:
{
x0=parseInt(cmd.X0);
if(isNaN(x0))
{
x0=gdLst[cmd.X0];
}
y0=parseInt(cmd.Y0);
if(isNaN(y0))
{
y0=gdLst[cmd.Y0];
}
x1=parseInt(cmd.X1);
if(isNaN(x1))
{
x1=gdLst[cmd.X1];
}
y1=parseInt(cmd.Y1);
if(isNaN(y1))
{
y1=gdLst[cmd.Y1];
}
this.ArrPathCommand.push({id:bezier3, X0:x0*cw, Y0: y0*ch, X1:x1*cw, Y1:y1*ch});
lastX=x1*cw;
lastY=y1*ch;
break;
}
case bezier4:
{
x0=parseInt(cmd.X0);
if(isNaN(x0))
{
x0=gdLst[cmd.X0];
}
y0=parseInt(cmd.Y0);
if(isNaN(y0))
{
y0=gdLst[cmd.Y0];
}
x1=parseInt(cmd.X1);
if(isNaN(x1))
{
x1=gdLst[cmd.X1];
}
y1=parseInt(cmd.Y1);
if(isNaN(y1))
{
y1=gdLst[cmd.Y1];
}
x2=parseInt(cmd.X2);
if(isNaN(x2))
{
x2=gdLst[cmd.X2];
}
y2=parseInt(cmd.Y2);
if(isNaN(y2))
{
y2=gdLst[cmd.Y2];
}
this.ArrPathCommand.push({id:bezier4, X0:x0*cw, Y0: y0*ch, X1:x1*cw, Y1:y1*ch, X2:x2*cw, Y2:y2*ch});
lastX=x2*cw;
lastY=y2*ch;
break;
}
case arcTo:
{
hR=parseInt(cmd.hR);
if(isNaN(hR))
{
hR=gdLst[cmd.hR];
}
wR=parseInt(cmd.wR);
if(isNaN(wR))
{
wR=gdLst[cmd.wR];
}
stAng=parseInt(cmd.stAng);
if(isNaN(stAng))
{
stAng=gdLst[cmd.stAng];
}
swAng=parseInt(cmd.swAng);
if(isNaN(swAng))
{
swAng=gdLst[cmd.swAng];
}
var a1 = stAng;
var a2 = stAng + swAng;
var a3 = swAng;
stAng = Math.atan2(ch * Math.sin(a1 * cToRad), cw * Math.cos(a1 * cToRad)) / cToRad;
swAng = Math.atan2(ch * Math.sin(a2 * cToRad), cw * Math.cos(a2 * cToRad)) / cToRad - stAng;
if((swAng > 0) && (a3 < 0)) swAng -= 21600000;
if((swAng < 0) && (a3 > 0)) swAng += 21600000;
if(swAng == 0) swAng = 21600000;
var a = wR*cw;
var b = hR*ch;
var sin2 = Math.sin(stAng*cToRad);
var cos2 = Math.cos(stAng*cToRad);
var _xrad = cos2 / a;
var _yrad = sin2 / b;
var l = 1 / Math.sqrt(_xrad * _xrad + _yrad * _yrad);
var xc = lastX - l * cos2;
var yc = lastY - l * sin2;
var sin1 = Math.sin((stAng+swAng)*cToRad);
var cos1 = Math.cos((stAng+swAng)*cToRad);
var _xrad1 = cos1 / a;
var _yrad1 = sin1 / b;
var l1 = 1 / Math.sqrt(_xrad1 * _xrad1 + _yrad1 * _yrad1);
this.ArrPathCommand[i]={id: arcTo,
stX: lastX,
stY: lastY,
wR: wR*cw,
hR: hR*ch,
stAng: stAng*cToRad,
swAng: swAng*cToRad};
lastX = xc + l1 * cos1;
lastY = yc + l1 * sin1;
/*
var sin1 = Math.sin(stAng+swAng);
var cos1 = Math.cos(stAng+swAng);
var __x = cos1 / (wR*cw);
var __y = sin1 / (hR*ch);
var l = 1 / Math.sqrt(__x * __x + __y * __y);
var xc = lastX - l * cos1;
var yc = lastY - l * sin1;
lastX=xc+cw*wR*Math.cos(AngToEllPrm(stAng+swAng, wR, hR));
lastY=yc+ch*hR*Math.sin(AngToEllPrm(stAng+swAng, wR, hR));
*/
//lastX=lastX+wR*cw*(-Math.cos(stAng*cToRad)+Math.cos((stAng+swAng)*cToRad));
//lastY=lastY+hR*ch*(-Math.sin(stAng*cToRad)+Math.sin((stAng+swAng)*cToRad));
break;
}
case close:
{
this.ArrPathCommand.push({id: close});
break;
}
default:
{
break;
}
}
}
},
recalculate: function(gdLst)
{
var ch, cw;
if(this.pathW!=undefined)
{
cw = (gdLst["w"]/this.pathW);
}
else
{
cw=1;
}
if(this.pathH!=undefined)
{
ch = (gdLst["h"]/this.pathH);
}
else
{
ch=1;
}
var APCI=this.ArrPathCommandInfo, n = APCI.length, cmd;
var x0, y0, x1, y1, x2, y2, wR, hR, stAng, swAng, lastX, lastY;
for(var i=0; i<n; ++i)
{
cmd=APCI[i];
switch(cmd.id)
{
case moveTo:
case lineTo:
{
x0=gdLst[cmd.X];
if(x0===undefined)
{
x0=cmd.X;
}
y0=gdLst[cmd.Y];
if(y0===undefined)
{
y0=cmd.Y;
}
this.ArrPathCommand[i] ={id:cmd.id, X:x0*cw, Y:y0*ch};
lastX=x0*cw;
lastY=y0*ch;
break;
}
case bezier3:
{
x0=gdLst[cmd.X0];
if(x0===undefined)
{
x0=cmd.X0;
}
y0=gdLst[cmd.Y0];
if(y0===undefined)
{
y0=cmd.Y0;
}
x1=gdLst[cmd.X1];
if(x1===undefined)
{
x1=cmd.X1;
}
y1=gdLst[cmd.Y1];
if(y1===undefined)
{
y1=cmd.Y1;
}
this.ArrPathCommand[i]={id:bezier3, X0:x0*cw, Y0: y0*ch, X1:x1*cw, Y1:y1*ch};
lastX=x1*cw;
lastY=y1*ch;
break;
}
case bezier4:
{
x0=gdLst[cmd.X0];
if(x0===undefined)
{
x0=cmd.X0;
}
y0=gdLst[cmd.Y0];
if(y0===undefined)
{
y0=cmd.Y0;
}
x1=gdLst[cmd.X1];
if(x1===undefined)
{
x1=cmd.X1;
}
y1=gdLst[cmd.Y1];
if(y1===undefined)
{
y1=cmd.Y1;
}
x2=gdLst[cmd.X2];
if(x2===undefined)
{
x2=cmd.X2;
}
y2=gdLst[cmd.Y2];
if(y2===undefined)
{
y2=cmd.Y2;
}
this.ArrPathCommand[i]={id:bezier4, X0:x0*cw, Y0: y0*ch, X1:x1*cw, Y1:y1*ch, X2:x2*cw, Y2:y2*ch};
lastX=x2*cw;
lastY=y2*ch;
break;
}
case arcTo:
{
hR=gdLst[cmd.hR];
if(hR===undefined)
{
hR=cmd.hR;
}
wR=gdLst[cmd.wR];
if(wR===undefined)
{
wR=cmd.wR;
}
stAng=gdLst[cmd.stAng];
if(stAng===undefined)
{
stAng=cmd.stAng;
}
swAng=gdLst[cmd.swAng];
if(swAng===undefined)
{
swAng=cmd.swAng;
}
var a1 = stAng;
var a2 = stAng + swAng;
var a3 = swAng;
stAng = Math.atan2(ch * Math.sin(a1 * cToRad), cw * Math.cos(a1 * cToRad)) / cToRad;
swAng = Math.atan2(ch * Math.sin(a2 * cToRad), cw * Math.cos(a2 * cToRad)) / cToRad - stAng;
if((swAng > 0) && (a3 < 0)) swAng -= 21600000;
if((swAng < 0) && (a3 > 0)) swAng += 21600000;
if(swAng == 0) swAng = 21600000;
var a = wR*cw;
var b = hR*ch;
var sin2 = Math.sin(stAng*cToRad);
var cos2 = Math.cos(stAng*cToRad);
var _xrad = cos2 / a;
var _yrad = sin2 / b;
var l = 1 / Math.sqrt(_xrad * _xrad + _yrad * _yrad);
var xc = lastX - l * cos2;
var yc = lastY - l * sin2;
var sin1 = Math.sin((stAng+swAng)*cToRad);
var cos1 = Math.cos((stAng+swAng)*cToRad);
var _xrad1 = cos1 / a;
var _yrad1 = sin1 / b;
var l1 = 1 / Math.sqrt(_xrad1 * _xrad1 + _yrad1 * _yrad1);
this.ArrPathCommand[i]={id: arcTo,
stX: lastX,
stY: lastY,
wR: wR*cw,
hR: hR*ch,
stAng: stAng*cToRad,
swAng: swAng*cToRad};
lastX = xc + l1 * cos1;
lastY = yc + l1 * sin1;
break;
}
case close:
{
this.ArrPathCommand[i]={id: close};
break;
}
default:
{
break;
}
}
}
},
draw: function(shape_drawer)
{
if (shape_drawer.bIsCheckBounds === true && this.fill == "none")
{
// это для текстур
return;
}
var bIsDrawLast = false;
var path=this.ArrPathCommand;
shape_drawer._s();
for(var j=0, l=path.length; j<l; ++j)
{
var cmd=path[j];
switch(cmd.id)
{
case moveTo:
{
bIsDrawLast = true;
shape_drawer._m(cmd.X, cmd.Y);
break;
}
case lineTo:
{
bIsDrawLast = true;
shape_drawer._l(cmd.X, cmd.Y);
break;
}
case bezier3:
{
bIsDrawLast = true;
shape_drawer._c2(cmd.X0, cmd.Y0, cmd.X1, cmd.Y1);
break;
}
case bezier4:
{
bIsDrawLast = true;
shape_drawer._c(cmd.X0, cmd.Y0, cmd.X1, cmd.Y1, cmd.X2, cmd.Y2);
break;
}
case arcTo:
{
bIsDrawLast = true;
ArcToCurvers(shape_drawer, cmd.stX, cmd.stY, cmd.wR, cmd.hR, cmd.stAng, cmd.swAng);
break;
}
case close:
{
shape_drawer._z();
//shape_drawer.drawFillStroke(true, this.fill, this.stroke && !shape_drawer.bIsNoStrokeAttack);
//bIsDrawLast = false;
//if (j < (l-1))
// shape_drawer._s();
break;
}
}
}
if (bIsDrawLast)
{
shape_drawer.drawFillStroke(true, this.fill, this.stroke && !shape_drawer.bIsNoStrokeAttack);
}
shape_drawer._e();
/*
shape_drawer.df(this.fill);
if (this.stroke && !shape_drawer.bIsNoStrokeAttack)
{
shape_drawer.ds();
}
*/
},
check_bounds: function(checker)
{
var path=this.ArrPathCommand;
for(var j=0, l=path.length; j<l; ++j)
{
var cmd=path[j];
switch(cmd.id)
{
case moveTo:
{
checker._m(cmd.X, cmd.Y);
break;
}
case lineTo:
{
checker._l(cmd.X, cmd.Y);
break;
}
case bezier3:
{
checker._c2(cmd.X0, cmd.Y0, cmd.X1, cmd.Y1);
break;
}
case bezier4:
{
checker._c(cmd.X0, cmd.Y0, cmd.X1, cmd.Y1, cmd.X2, cmd.Y2);
break;
}
case arcTo:
{
ArcToCurvers(checker, cmd.stX, cmd.stY, cmd.wR, cmd.hR, cmd.stAng, cmd.swAng);
break;
}
case close:
{
checker._z();
break;
}
}
}
},
hitInInnerArea: function(canvasContext, x, y)
{
if(this.fill === "none")
return false;
var _arr_commands = this.ArrPathCommand;
var _commands_count = _arr_commands.length;
var _command_index;
var _command;
canvasContext.beginPath();
for(_command_index = 0; _command_index < _commands_count; ++_command_index)
{
_command = _arr_commands[_command_index];
switch(_command.id)
{
case moveTo:
{
canvasContext.moveTo(_command.X, _command.Y);
break;
}
case lineTo:
{
canvasContext.lineTo(_command.X, _command.Y);
break;
}
case arcTo:
{
ArcToOnCanvas(canvasContext, _command.stX, _command.stY, _command.wR, _command.hR, _command.stAng, _command.swAng);
break;
}
case bezier3:
{
canvasContext.quadraticCurveTo(_command.X0, _command.Y0, _command.X1, _command.Y1);
break;
}
case bezier4:
{
canvasContext.bezierCurveTo(_command.X0, _command.Y0, _command.X1, _command.Y1, _command.X2, _command.Y2);
break;
}
case close:
{
canvasContext.closePath();
if(canvasContext.isPointInPath(x, y))
{
return true;
}
}
}
}
return false;
},
hitInPath: function(canvasContext, x, y)
{
var _arr_commands = this.ArrPathCommand;
var _commands_count = _arr_commands.length;
var _command_index;
var _command;
var _last_x, _last_y;
var _begin_x, _begin_y;
for(_command_index = 0; _command_index< _commands_count; ++_command_index)
{
_command = _arr_commands[_command_index];
switch(_command.id)
{
case moveTo:
{
_last_x = _command.X;
_last_y = _command.Y;
_begin_x = _command.X;
_begin_y = _command.Y;
break;
}
case lineTo:
{
if(HitInLine(canvasContext, x, y, _last_x, _last_y, _command.X, _command.Y))
return true;
_last_x = _command.X;
_last_y = _command.Y;
break;
}
case arcTo:
{
if(HitToArc(canvasContext, x, y, _command.stX, _command.stY, _command.wR, _command.hR, _command.stAng, _command.swAng))
return true;
_last_x=(_command.stX-_command.wR*Math.cos(_command.stAng)+_command.wR*Math.cos(_command.swAng));
_last_y=(_command.stY-_command.hR*Math.sin(_command.stAng)+_command.hR*Math.sin(_command.swAng));
break;
}
case bezier3:
{
if(HitInBezier3(canvasContext, x, y, _last_x, _last_y, _command.X0, _command.Y0, _command.X1, _command.Y1))
return true;
_last_x=_command.X1;
_last_y=_command.Y1;
break;
}
case bezier4:
{
if(HitInBezier4(canvasContext, x, y, _last_x, _last_y, _command.X0, _command.Y0, _command.X1, _command.Y1, _command.X2, _command.Y2))
return true;
_last_x=_command.X2;
_last_y=_command.Y2;
break;
}
case close:
{
if(HitInLine(canvasContext, x, y, _last_x, _last_y, _begin_x, _begin_y))
return true;
}
}
}
return false;
},
calculateWrapPolygon: function(epsilon, graphics)
{
var arr_polygons = [];
var cur_polygon = [];
var path_commands = this.ArrPathCommand;
var path_commands_count = path_commands.length;
var last_x, last_y;
for(var index = 0; index < path_commands_count; ++index)
{
var cur_command = path_commands[index];
switch (cur_command.id)
{
case moveTo:
case lineTo:
{
cur_polygon.push({x: cur_command.X, y: cur_command.Y});
last_x = cur_command.X;
last_y = cur_command.Y;
break;
}
case bezier3:
{
cur_polygon = cur_polygon.concat(partition_bezier3(last_x, last_y, cur_command.X0, cur_command.Y0, cur_command.X1, cur_command.Y1, epsilon));
last_x = cur_command.X1;
last_y = cur_command.Y1;
break;
}
case bezier4:
{
cur_polygon = cur_polygon.concat(partition_bezier4(last_x, last_y, cur_command.X0, cur_command.Y0, cur_command.X1, cur_command.Y1, cur_command.X2, cur_command.Y2, epsilon));
last_x = cur_command.X2;
last_y = cur_command.Y2;
break;
}
case arcTo:
{
var arr_curve_bezier = getArrayPointsCurveBezierAtArcTo(last_x, last_y, cur_command.stX, cur_command.stY, cur_command.wR, cur_command.hR, cur_command.stAng, cur_command.swAng);
if(arr_curve_bezier.length > 0)
{
last_x = arr_curve_bezier[arr_curve_bezier.length - 1].x4;
last_y = arr_curve_bezier[arr_curve_bezier.length - 1].y4;
for(var i = 0; i < arr_curve_bezier.length; ++i)
{
var cur_curve_bezier = arr_curve_bezier[i];
cur_polygon = cur_polygon.concat(partition_bezier4(cur_curve_bezier.x0, cur_curve_bezier.y0, cur_curve_bezier.x1, cur_curve_bezier.y1, cur_curve_bezier.x2, cur_curve_bezier.y2, cur_curve_bezier.x3, cur_curve_bezier.y3, epsilon))
}
}
break;
}
case close:
{
arr_polygons.push(cur_polygon);
cur_polygon = [];
}
}
}
for(i = 0; i < arr_polygons.length; ++i)
{
var cur_polygon = arr_polygons[i];
graphics._m(cur_polygon[0].x, cur_polygon[0].y);
for(var j = 0; j < cur_polygon.length; ++j)
{
graphics._l(cur_polygon[j].x, cur_polygon[j].y);
}
graphics._z();
graphics.ds();
}
}
};
function partition_bezier3(x0, y0, x1, y1, x2, y2, epsilon)
{
var dx01 = x1 - x0;
var dy01 = y1 - y0;
var dx12 = x2 - x1;
var dy12 = y2 - y1;
var r01 = Math.sqrt(dx01*dx01 + dy01*dy01);
var r12 = Math.sqrt(dx12*dx12 + dy12*dy12);
if(Math.max(r01, r12) < epsilon)
return [{x: x0, y: y0}, {x: x1, y: y1}, {x: x2, y: y2}];
var x01 = (x0 + x1)*0.5;
var y01 = (y0 + y1)*0.5;
var x12 = (x1 + x2)*0.5;
var y12 = (y1 + y2)*0.5;
var x012 = (x01 + x12)*0.5;
var y012 = (y01 + y12)*0.5;
return partition_bezier3(x0, y0, x01, y01, x012, y012, epsilon).concat(partition_bezier3(x012, y012, x12, y12, x2, y2, epsilon));
}
function partition_bezier4(x0, y0, x1, y1, x2, y2, x3, y3, epsilon)
{
var dx01 = x1 - x0;
var dy01 = y1 - y0;
var dx12 = x2 - x1;
var dy12 = y2 - y1;
var dx23 = x3 - x2;
var dy23 = y3 - y2;
var r01 = Math.sqrt(dx01*dx01 + dy01*dy01);
var r12 = Math.sqrt(dx12*dx12 + dy12*dy12);
var r23 = Math.sqrt(dx23*dx23 + dy23*dy23);
if(Math.max(r01, r12, r23) < epsilon)
return [{x: x0, y: y0}, {x: x1, y: y1}, {x: x2, y: y2}, {x: x3, y: y3}];
var x01 = (x0 + x1)*0.5;
var y01 = (y0 + y1)*0.5;
var x12 = (x1 + x2)*0.5;
var y12 = (y1 + y2)*0.5;
var x23 = (x2 + x3)*0.5;
var y23 = (y2 + y3)*0.5;
var x012 = (x01 + x12)*0.5;
var y012 = (y01 + y12)*0.5;
var x123 = (x12 + x23)*0.5;
var y123 = (y12 + y23)*0.5;
var x0123 = (x012 + x123)*0.5;
var y0123 = (y012 + y123)*0.5;
return partition_bezier4(x0, y0, x01, y01, x012, y012, x0123, y0123, epsilon).concat(partition_bezier4(x0123, y0123, x123, y123, x23, y23, x3, y3, epsilon));
}
var TRANSLATE_HANDLE_NO_FLIP = [];
TRANSLATE_HANDLE_NO_FLIP[0] = 0;
TRANSLATE_HANDLE_NO_FLIP[1] = 1;
TRANSLATE_HANDLE_NO_FLIP[2] = 2;
TRANSLATE_HANDLE_NO_FLIP[3] = 3;
TRANSLATE_HANDLE_NO_FLIP[4] = 4;
TRANSLATE_HANDLE_NO_FLIP[5] = 5;
TRANSLATE_HANDLE_NO_FLIP[6] = 6;
TRANSLATE_HANDLE_NO_FLIP[7] = 7;
var TRANSLATE_HANDLE_FLIP_H = [];
TRANSLATE_HANDLE_FLIP_H[0] = 2;
TRANSLATE_HANDLE_FLIP_H[1] = 1;
TRANSLATE_HANDLE_FLIP_H[2] = 0;
TRANSLATE_HANDLE_FLIP_H[3] = 7;
TRANSLATE_HANDLE_FLIP_H[4] = 6;
TRANSLATE_HANDLE_FLIP_H[5] = 5;
TRANSLATE_HANDLE_FLIP_H[6] = 4;
TRANSLATE_HANDLE_FLIP_H[7] = 3;
var TRANSLATE_HANDLE_FLIP_V = [];
TRANSLATE_HANDLE_FLIP_V[0] = 6;
TRANSLATE_HANDLE_FLIP_V[1] = 5;
TRANSLATE_HANDLE_FLIP_V[2] = 4;
TRANSLATE_HANDLE_FLIP_V[3] = 3;
TRANSLATE_HANDLE_FLIP_V[4] = 2;
TRANSLATE_HANDLE_FLIP_V[5] = 1;
TRANSLATE_HANDLE_FLIP_V[6] = 0;
TRANSLATE_HANDLE_FLIP_V[7] = 7;
var TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V = [];
TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[0] = 4;
TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[1] = 5;
TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[2] = 6;
TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[3] = 7;
TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[4] = 0;
TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[5] = 1;
TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[6] = 2;
TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[7] = 3;
var SHAPE_ASPECTS = {};
SHAPE_ASPECTS["can"] = 3616635/4810125;
SHAPE_ASPECTS["moon"] = 0.5;
SHAPE_ASPECTS["leftBracket"] = 0.08;
SHAPE_ASPECTS["rightBracket"] = 0.08;
SHAPE_ASPECTS["leftBrace"] = 0.17;
SHAPE_ASPECTS["rightBrace"] = 0.17;
//TODO:
var MIN_SHAPE_SIZE = 1.27;//размер меньше которого нельзя уменшить автофигуру или картинку по горизонтали или вертикали
var MIN_SHAPE_SIZE_DIV2 = MIN_SHAPE_SIZE/2.0;
var MIN_ANGLE = 0.07;
function MoveTrackShape(originalShape, majorOffsetX, majorOffsetY, bChart)
{
this.originalShape = originalShape;
this.posX = originalShape.absOffsetX;
this.posY = originalShape.absOffsetY;
this.pageIndex = originalShape.pageIndex;
this.flipH = this.originalShape.absFlipH;
this.flipV = this.originalShape.absFlipV;
this.horCenter = this.originalShape.absExtX*0.5;
this.verCenter = this.originalShape.absExtY*0.5;
this.rot = this.originalShape.absRot;
this.majorOffsetX = majorOffsetX;
this.majorOffsetY = majorOffsetY;
this.transformMatrix = originalShape.transform.CreateDublicate();
this.geometry = originalShape.geometry;//копировать не будем, так как с геометрией во время движения ничего не происходит
this.brush = originalShape.brush;
this.pen = originalShape.pen;
if(bChart === true)
{
var brush = new CUniFill();
brush.fill = new CSolidFill();
brush.fill.color = new CUniColor();
brush.fill.color.RGBA = {R:255, G:255, B:255, A:255};
brush.fill.color.color = new CRGBColor();
brush.fill.color.color.RGBA = {R:255, G:255, B:255, A:255};
var pen = new CLn();
pen.Fill = new CUniFill();
pen.Fill.fill = new CSolidFill();
pen.Fill.fill.color = new CUniColor();
pen.Fill.fill.color.color = new CRGBColor();
this.brush = brush;
this.pen = pen;
}
this.objectForOverlay = new ObjectForShapeDrawer(this.geometry, this.originalShape.absExtX, this.originalShape.absExtY, this.brush, this.pen, this.transformMatrix);
this.track = function(posX, posY, pageIndex)
{
this.posX = posX + this.majorOffsetX;
this.posY = posY + this.majorOffsetY;
this.pageIndex = pageIndex;
this.calculateTransformMatrix();
};
this.draw = function(overlay)
{
overlay.SetCurrentPage(this.pageIndex);
overlay.transform3(this.transformMatrix);
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape2(this.objectForOverlay, overlay, this.originalShape.spPr.geometry);
shape_drawer.draw(this.originalShape.spPr.geometry);
overlay.reset();
};
this.getBounds = function()
{
var bounds_checker = new CSlideBoundsChecker();
bounds_checker.init(Page_Width, Page_Height, Page_Width, Page_Height);
this.draw(bounds_checker);
return {l: bounds_checker.Bounds.min_x, t: bounds_checker.Bounds.min_y, r: bounds_checker.Bounds.max_x , b: bounds_checker.Bounds.max_y};
};
this.getBoundsRect = function()
{
var or_sp = this.originalShape;
var t = this.transformMatrix;
var min_x, max_x, min_y, max_y;
min_x = t.TransformPointX(0, 0);
max_x = min_x;
min_y = t.TransformPointY(0, 0);
max_y = min_y;
var arr = [{x: or_sp.absExtX, y: 0}, {x: or_sp.absExtX, y: or_sp.absExtY}, {x: 0, y: or_sp.absExtY}];
var t_x, t_y;
for(var i = 0; i < arr.length; ++i)
{
var p = arr[i];
t_x = t.TransformPointX(p.x, p.y);
t_y = t.TransformPointY(p.x, p.y);
if(t_x < min_x)
min_x = t_x;
if(t_x > max_x)
max_x = t_x;
if(t_y < min_y)
min_y = t_y;
if(t_y > max_y)
max_y = t_y;
}
return {l: min_x, t: min_y, r: max_x, b: max_y};
};
this.trackEnd = function(e)
{
// var near_pos = this.originalShape.document.Get_NearestPos()
if(!e.CtrlKey)
{
this.boolChangePos = true;
this.originalShape.setAbsoluteTransform(this.posX, this.posY, null, null, null, null, null);
this.originalShape.calculateTransformMatrix();
this.originalShape.calculateTransformTextMatrix();
this.originalShape.calculateLeftTopPoint();
}
else
{
var parent = this.originalShape.parent;
var para_drawing = this.originalShape.parent.copy();
// if(this.originalShape.isShape())
{
this.originalShape = para_drawing.GraphicObj;
var near_pos = this.originalShape.document.Get_NearestPos(this.pageIndex, this.posX, this.posY);
para_drawing.Set_XYForAdd(this.posX, this.posY, near_pos, this.pageIndex);
para_drawing.Add_ToDocument(near_pos);
this.originalShape.setAbsoluteTransform(this.posX, this.posY, null, null, null, null, null);
this.originalShape.calculateTransformMatrix();
this.originalShape.calculateTransformTextMatrix();
this.originalShape.calculateLeftTopPoint();
}
}
};
this.calculateTransformMatrix = function()
{
var _transform = this.transformMatrix;
_transform.Reset();
var _horizontal_center = this.horCenter;
var _vertical_center = this.verCenter;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.flipH)
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
if(this.flipV)
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
global_MatrixTransformer.RotateRadAppend(_transform, -this.rot);
global_MatrixTransformer.TranslateAppend(_transform, this.posX, this.posY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
};
}
function ResizeTrackShape(originalShape, numberHandle, pageIndex, bChart)
{
this.originalShape = originalShape;
this.numberHandle = numberHandle;
this.pageIndex = pageIndex;
this.flipH = originalShape.absFlipH;
this.flipV = originalShape.absFlipV;
var _flip_h = originalShape.absFlipH;
var _flip_v = originalShape.absFlipV;
var _half_height = originalShape.absExtY*0.5;
var _half_width = originalShape.absExtX*0.5;
var _sin = Math.sin(originalShape.absRot);
var _cos = Math.cos(originalShape.absRot);
this.bChart = originalShape instanceof CChartAsGroup;
var _translated_num_handle;
if(!_flip_h && !_flip_v)
{
_translated_num_handle = numberHandle;
}
else if(_flip_h && !_flip_v)
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_H[numberHandle];
}
else if(!_flip_h && _flip_v)
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_V[numberHandle];
}
else
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[numberHandle];
}
this.bAspect = numberHandle % 2 === 0;
this.aspect = this.bAspect === true ? this.originalShape.getAspect(_translated_num_handle) : 0;
this.sin = _sin;
this.cos = _cos;
this.translatetNumberHandle = _translated_num_handle;
switch (_translated_num_handle)
{
case 0:
case 1:
{
this.fixedPointX = (_half_width*_cos - _half_height*_sin) + _half_width + originalShape.absOffsetX;
this.fixedPointY = (_half_width*_sin + _half_height*_cos) + _half_height + originalShape.absOffsetY;
break;
}
case 2:
case 3:
{
this.fixedPointX = (-_half_width*_cos - _half_height*_sin) + _half_width + originalShape.absOffsetX;
this.fixedPointY = (-_half_width*_sin + _half_height*_cos) + _half_height + originalShape.absOffsetY;
break;
}
case 4:
case 5:
{
this.fixedPointX = (-_half_width*_cos + _half_height*_sin) + _half_width + originalShape.absOffsetX;
this.fixedPointY = (-_half_width*_sin - _half_height*_cos) + _half_height + originalShape.absOffsetY;
break;
}
case 6:
case 7:
{
this.fixedPointX = (_half_width*_cos + _half_height*_sin) + _half_width + originalShape.absOffsetX;
this.fixedPointY = (_half_width*_sin - _half_height*_cos) + _half_height + originalShape.absOffsetY;
break;
}
}
this.mod = this.translatetNumberHandle % 4;
this.centerPointX = originalShape.absOffsetX + _half_width;
this.centerPointY = originalShape.absOffsetY + _half_height;
this.lineFlag = originalShape.checkLine();
this.originalExtX = originalShape.absExtX;
this.originalExtY = originalShape.absExtY;
this.originalFlipH = _flip_h;
this.originalFlipV = _flip_v;
this.usedExtX = this.originalExtX === 0 ? (/*this.lineFlag ? this.originalExtX :*/ 0.01) : this.originalExtX;
this.usedExtY = this.originalExtY === 0 ? (/*this.lineFlag ? this.originalExtY :*/ 0.01) : this.originalExtY;
this.resizedExtX = this.originalExtX;
this.resizedExtY = this.originalExtY;
this.resizedflipH = _flip_h;
this.resizedflipV = _flip_v;
this.resizedPosX = originalShape.absOffsetX;
this.resizedPosY = originalShape.absOffsetY;
this.resizedRot = originalShape.absRot;
this.transformMatrix = originalShape.transform.CreateDublicate();
this.geometry = originalShape.spPr.geometry.createDuplicate();
if(originalShape instanceof CChartAsGroup)
{
var brush = new CUniFill();
brush.fill = new CSolidFill();
brush.fill.color = new CUniColor();
brush.fill.color.RGBA = {R:255, G:255, B:255, A:255};
brush.fill.color.color = new CRGBColor();
brush.fill.color.color.RGBA = {R:255, G:255, B:255, A:255};
var pen = new CLn();
pen.Fill = new CUniFill();
pen.Fill.fill = new CSolidFill();
pen.Fill.fill.color = new CUniColor();
pen.Fill.fill.color.color = new CRGBColor();
this.pen = pen;
this.brush = brush;
}
else
{
this.pen = originalShape.pen;
this.brush = originalShape.brush;
}
this.bChangeCoef = this.translatetNumberHandle % 2 === 0 && this.originalFlipH !== this.originalFlipV;
this.objectForOverlay = new ObjectForShapeDrawer(this.geometry, this.resizedExtX, this.resizedExtY, this.brush, this.pen, this.transformMatrix);
this.textMatrix = null;
if(isRealObject(this.originalShape.parent))
{
if(this.originalShape.parent.Is_Inline())
{
if(this.originalShape.parent.DocumentContent instanceof CDocumentContent)
{
var cur_doc_content = this.originalShape.parent.DocumentContent;
while(cur_doc_content.Is_TableCellContent())
{
cur_doc_content = cur_doc_content.Parent.Row.Table.Parent;
}
if((cur_doc_content instanceof CDocumentContent && cur_doc_content.Parent instanceof WordShape))
{
this.textMatrix = cur_doc_content.Parent.transformText;
}
}
}
}
this.resize = function(kd1, kd2, shiftKey)
{
var _cos = this.cos;
var _sin = this.sin;
var _real_height, _real_width;
var _abs_height, _abs_width;
var _new_resize_half_width;
var _new_resize_half_height;
var _new_used_half_width;
var _new_used_half_height;
var _temp;
if(shiftKey === true && this.bAspect === true)
{
var _new_aspect = this.aspect*(Math.abs(kd1/ kd2));
if (_new_aspect >= this.aspect)
kd2 = Math.abs(kd1)*(kd2 >= 0 ? 1 : -1 );
else
kd1 = Math.abs(kd2)*(kd1 >= 0 ? 1 : -1);
}
if(this.bChangeCoef)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
switch (this.translatetNumberHandle)
{
case 0:
case 1:
{
if(this.translatetNumberHandle === 0)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
if(!this.bChart)
{
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
}
else
{
this.resizedExtX = _real_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
}
}
if(this.translatetNumberHandle === 1)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
if(!this.bChart)
{
this.resizedExtY = (_abs_height >= MIN_SHAPE_SIZE) || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
}
else
{
this.resizedExtY = _real_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
}
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (-_new_used_half_width*_cos + _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (-_new_used_half_width*_sin - _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 2:
case 3:
{
if(this.translatetNumberHandle === 2)
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
if(!this.bChart)
{
this.resizedExtY = (_abs_height >= MIN_SHAPE_SIZE) || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
}
else
{
this.resizedExtY = _real_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
}
}
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
if(!this.bChart)
{
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
}
else
{
this.resizedExtX = _real_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
}
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (_new_used_half_width*_cos + _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (_new_used_half_width*_sin - _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 4:
case 5:
{
if(this.translatetNumberHandle === 4)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
if(!this.bChart)
{
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
}
else
{
this.resizedExtX = _real_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
}
}
else
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
if(!this.bChart)
{
this.resizedExtY = (_abs_height >= MIN_SHAPE_SIZE) || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
}
else
{
this.resizedExtY = _real_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
}
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (_new_used_half_width*_cos - _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (_new_used_half_width*_sin + _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 6:
case 7:
{
if(this.translatetNumberHandle === 6)
{
_real_height = this.usedExtY*kd1;
_abs_height = Math.abs(_real_height);
if(!this.bChart)
{
this.resizedExtY = (_abs_height >= MIN_SHAPE_SIZE) || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
}
else
{
this.resizedExtY = _real_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
}
}
else
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
}
_real_width = this.usedExtX*kd2;
_abs_width = Math.abs(_real_width);
if(!this.bChart)
{
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
}
else
{
this.resizedExtX = _real_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
}
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (-_new_used_half_width*_cos - _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (-_new_used_half_width*_sin + _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
}
this.geometry.Recalculate(this.resizedExtX, this.resizedExtY);
var _transform = this.transformMatrix;
_transform.Reset();
var _horizontal_center = this.resizedExtX*0.5;
var _vertical_center = this.resizedExtY*0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.resizedflipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.resizedflipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.resizedRot);
global_MatrixTransformer.TranslateAppend(_transform, this.resizedPosX, this.resizedPosY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
if(this.originalShape.mainGroup !== null)
{
global_MatrixTransformer.MultiplyAppend(_transform, this.originalShape.mainGroup.getTransform());
}
if(this.textMatrix != null)
{
global_MatrixTransformer.MultiplyAppend(_transform, this.textMatrix);
}
};
this.resizeRelativeCenter = function(kd1, kd2, shiftKey)
{
kd1 = 2*kd1 - 1;
kd2 = 2*kd2 - 1;
var _real_height, _real_width;
var _abs_height, _abs_width;
if(shiftKey === true && this.bAspect === true)
{
var _new_aspect = this.aspect*(Math.abs(kd1/ kd2));
if (_new_aspect >= this.aspect)
kd2 = Math.abs(kd1)*(kd2 >= 0 ? 1 : -1 );
else
kd1 = Math.abs(kd2)*(kd1 >= 0 ? 1 : -1);
}
var _temp;
if(this.bChangeCoef)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
if(this.mod === 0 || this.mod === 1)
{
if(this.mod === 0)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
if(!this.bChart)
{
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
this.resizedflipH = _real_width < 0 ? !this.originalFlipH : this.originalFlipH;
}
else
{
this.resizedExtX = _real_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
}
}
else
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
if(!this.bChart)
{
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
this.resizedflipV = _real_height < 0 ? !this.originalFlipV : this.originalFlipV;
}
else
{
this.resizedExtY = _real_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
}
}
else
{
if(this.mod === 2)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
if(!this.bChart)
{
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
this.resizedflipV = _real_height < 0 ? !this.originalFlipV : this.originalFlipV;
}
else
{
this.resizedExtY = _real_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
}
}
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
if(!this.bChart)
{
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
this.resizedflipH = _real_width < 0 ? !this.originalFlipH : this.originalFlipH;
}
else
{
this.resizedExtX = _real_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
}
}
this.resizedPosX = this.centerPointX - this.resizedExtX*0.5;
this.resizedPosY = this.centerPointY - this.resizedExtY*0.5;
this.geometry.Recalculate(this.resizedExtX, this.resizedExtY);
var _transform = this.transformMatrix;
_transform.Reset();
var _horizontal_center = this.resizedExtX*0.5;
var _vertical_center = this.resizedExtY*0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.resizedflipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.resizedflipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.resizedRot);
global_MatrixTransformer.TranslateAppend(_transform, this.resizedPosX, this.resizedPosY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
if(this.originalShape.mainGroup !== null)
{
global_MatrixTransformer.MultiplyAppend(_transform, this.originalShape.mainGroup.getTransform());
}
if(this.textMatrix != null)
{
global_MatrixTransformer.MultiplyAppend(_transform, this.textMatrix);
}
};
this.draw = function(overlay)
{
overlay.SetCurrentPage(this.pageIndex);
overlay.transform3(this.transformMatrix);
this.objectForOverlay.updateTransform(this.resizedExtX, this.resizedExtY, this.transformMatrix);
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape2(this.objectForOverlay, overlay, this.geometry);
shape_drawer.draw(this.geometry);
};
this.getBounds = function()
{
var bounds_checker = new CSlideBoundsChecker();
bounds_checker.init(Page_Width, Page_Height, Page_Width, Page_Height);
this.draw(bounds_checker);
return {l: bounds_checker.Bounds.min_x, t: bounds_checker.Bounds.min_y, r: bounds_checker.Bounds.max_x , b: bounds_checker.Bounds.max_y};
};
this.getBoundsRect = function()
{
var t = this.transformMatrix;
var max_x, min_x, max_y, min_y;
min_x = t.TransformPointX(0, 0);
max_x = min_x;
min_y = t.TransformPointY(0, 0);
max_y = min_y;
var arr = [{x: this.resizedExtX, y: 0}, {x: this.resizedExtX, y: this.resizedExtY}, {x: 0, y: this.resizedExtY}];
var t_x, t_y;
for(var i = 0; i < arr.length; ++i)
{
var p = arr[i];
t_x = t.TransformPointX(p.x, p.y);
t_y = t.TransformPointY(p.x, p.y);
if(t_x < min_x)
min_x = t_x;
if(t_x > max_x)
max_x = t_x;
if(t_y < min_y)
min_y = t_y;
if(t_y > max_y)
max_y = t_y;
}
return {l: min_x, t: min_y, r: max_x, b: max_y};
};
this.endTrack = function()
{
var _b_group = this.originalShape.group !== null;
var _old_abs_xc;
var _old_abs_yc;
var _b_change_flip_h;
var _b_change_flip_v;
var _old_relative_xc;
var _old_relative_yc;
if(_b_group)
{
_b_change_flip_h = this.originalShape.absFlipH !== this.resizedflipH;
_b_change_flip_v = this.originalShape.absFlipV !== this.resizedflipV;
}
this.boolChangePos = this.originalShape.absOffsetX !== this.resizedPosX || this.originalShape.absOffsetY !== this.resizedPosY;
if(this.originalShape.group == null)
{
this.originalShape.setSizes(this.resizedPosX, this.resizedPosY, this.resizedExtX, this.resizedExtY, this.resizedflipH, this.resizedflipV);
if(this.originalShape.parent.wrappingPolygon.edited)
{
var kW = this.resizedExtX/this.originalExtX;
var kH = this.resizedExtY/this.originalExtY;
this.originalShape.parent.wrappingPolygon.updateSizes(kW, kH);
}
}
else
{
this.originalShape.setAbsoluteTransform(this.resizedPosX, this.resizedPosY, this.resizedExtX, this.resizedExtY, null, this.resizedflipH, this.resizedflipV);
this.originalShape.calculateAfterResize();
if(_b_group)
{
var _invert_group_transform = global_MatrixTransformer.Invert(this.originalShape.group.transform);
var _shape_transform = this.originalShape.transform;
var _global_xc = _shape_transform.TransformPointX(this.originalShape.absExtX*0.5, this.originalShape.absExtY*0.5);
var _global_yc = _shape_transform.TransformPointY(this.originalShape.absExtX*0.5, this.originalShape.absExtY*0.5);
var _xc_rel_group = _invert_group_transform.TransformPointX(_global_xc, _global_yc);
var _yc_rel_group = _invert_group_transform.TransformPointY(_global_xc, _global_yc);
var _rel_pos_x = _xc_rel_group - this.originalShape.absExtX*0.5;
var _rel_pos_y = _yc_rel_group - this.originalShape.absExtY*0.5;
var _new_rel_flip_h;
var _new_rel_flip_v;
if(_b_change_flip_h)
_new_rel_flip_h = !this.originalShape.spPr.xfrm.flipH;
else
_new_rel_flip_h = null;
if(_b_change_flip_v)
_new_rel_flip_v = !this.originalShape.spPr.xfrm.flipV;
else
_new_rel_flip_v = null;
this.originalShape.setXfrm(_rel_pos_x, _rel_pos_y, this.resizedExtX, this.resizedExtY, null, _new_rel_flip_h, _new_rel_flip_v);
}
else
{
if(this.originalShape.parent.wrappingPolygon.edited)
{
var kW = this.resizedExtX/this.originalExtX;
var kH = this.resizedExtY/this.originalExtY;
var arr_points = this.originalShape.parent.wrappingPolygon.relativeArrPoints;
for(var point_index = 0; point_index < arr_points.length; ++point_index)
{
arr_points[point_index].x*=kW;
arr_points[point_index].y*=kH;
}
this.originalShape.parent.wrappingPolygon.calculateRelToAbs(this.originalShape.parent.getTransformMatrix());
}
}
}
if(this.originalShape.isImage() && isRealObject(this.originalShape.chart))
{
var or_shp = this.originalShape;
or_shp.chart.width = or_shp.drawingDocument.GetDotsPerMM(this.resizedExtX);
or_shp.chart.height = or_shp.drawingDocument.GetDotsPerMM(this.resizedExtY);
var chartRender = new ChartRender();
var chartBase64 = chartRender.insertChart(or_shp.chart, null, or_shp.chart.width, or_shp.chart.height);
or_shp.chart.img = chartBase64;
or_shp.setRasterImage(or_shp.chart.img);
editor.WordControl.m_oLogicDocument.DrawingObjects.urlMap.push(or_shp.chart.img);
}
};
}
function NewTrackShape(originalShape, startPosX, startPosY, lineFlag, pageShapes, pageIndex)
{
this.originalShape = originalShape;
this.pageIndex = pageIndex;
this.propCoefficient = originalShape.spPr.geometry === null ? 1 : (typeof SHAPE_ASPECTS[originalShape.spPr.geometry.preset] === "number" ? SHAPE_ASPECTS[originalShape.spPr.geometry.preset] : 1);
this.invPropCoefficient = 1/this.propCoefficient;
this.lineFlag = lineFlag;
this.canZeroDimention = this.originalShape.canZeroDimension();
this.canFlip = this.originalShape.canFlipAtAddTrack();
this.pageShapes = pageShapes;
this.transformMatrix = originalShape.transform.CreateDublicate();
this.geometry = originalShape.spPr.geometry;
this.posX = originalShape.absOffsetX;
this.posY = originalShape.absOffsetY;
this.extX = originalShape.absExtX;
this.extY = originalShape.absExtY;
this.flipH = originalShape.absFlipH;
this.flipV = originalShape.absFlipV;
this.startPosX = startPosX;
this.startPosY = startPosY;
this.objectForOverlay = new ObjectForShapeDrawer(this.geometry, this.extX, this.extY, this.originalShape.brush, this.originalShape.pen, this.transformMatrix);
this.modify = function(x, y, ctrlKey, shiftKey)
{
var _finished_x = x, _finished_y = y;
var _real_dist_x = _finished_x - this.startPosX;
var _abs_dist_x = Math.abs(_real_dist_x);
var _real_dist_y = _finished_y - this.startPosY;
var _abs_dist_y = Math.abs(_real_dist_y);
if( (!ctrlKey && !shiftKey) || (this.lineFlag && !shiftKey))
{
if(_real_dist_x >= 0)
{
this.posX = this.startPosX;
this.flipH = false;
}
else
{
this.posX = _abs_dist_x >= MIN_SHAPE_SIZE || this.lineFlag ? x : this.startPosX - MIN_SHAPE_SIZE;
if(this.lineFlag)
{
this.flipH = true;
}
}
if(_real_dist_y >= 0)
{
this.posY = this.startPosY;
this.flipV = false;
}
else
{
this.posY = _abs_dist_y >= MIN_SHAPE_SIZE || this.lineFlag ? y : this.startPosY - MIN_SHAPE_SIZE;
if(this.lineFlag)
{
this.flipV = true;
}
}
this.extX = _abs_dist_x >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_dist_x : MIN_SHAPE_SIZE;
this.extY = _abs_dist_y >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_dist_y : MIN_SHAPE_SIZE;
//пересчет геометрии
this.geometry.Recalculate(this.extX, this.extY);
//TODO: пересчет матрицы трансформации
}
else if(ctrlKey && !shiftKey)
{
if(_abs_dist_x >= MIN_SHAPE_SIZE_DIV2)
{
this.posX = this.startPosX - _abs_dist_x;
this.extX = 2*_abs_dist_x;
}
else
{
this.posX = this.startPosX - MIN_SHAPE_SIZE_DIV2;
this.extX = MIN_SHAPE_SIZE;
}
if(_abs_dist_y >= MIN_SHAPE_SIZE_DIV2)
{
this.posY = this.startPosY - _abs_dist_y;
this.extY = 2*_abs_dist_y;
}
else
{
this.posY = this.startPosY - MIN_SHAPE_SIZE_DIV2;
this.extY = MIN_SHAPE_SIZE;
}
this.geometry.Recalculate(this.extX, this.extY);
}
else if(!ctrlKey && shiftKey)
{
var _new_aspect;
var _new_width, _new_height;
if(this.lineFlag)
{
//TODO
}
else
{
/* if(_abs_dist_x < MIN_SHAPE_SIZE || _abs_dist_y < MIN_SHAPE_SIZE)
{
if(this.propCoefficient >= 1)
{
this.extY = MIN_SHAPE_SIZE;
this.extX = MIN_SHAPE_SIZE*this.propCoefficient;
}
else
{
this.extX = MIN_SHAPE_SIZE;
this.extY = MIN_SHAPE_SIZE*this.invPropCoefficient;
}
} */
// else
{
_new_aspect = _abs_dist_x/_abs_dist_y;
if (_new_aspect >= this.propCoefficient)
{
_new_width = _abs_dist_x;
_new_height = _abs_dist_x*this.invPropCoefficient;
}
else
{
_new_height = _real_dist_y;
_new_width = _real_dist_y*this.propCoefficient;
}
// if(_new_width >= MIN_SHAPE_SIZE && _new_height >= MIN_SHAPE_SIZE)
{
this.extX = _new_width;
this.extY = _new_height;
}
/* else
{
if(this.propCoefficient >= 1)
{
this.extY = MIN_SHAPE_SIZE;
this.extX = MIN_SHAPE_SIZE;//*this.propCoefficient;
}
else
{
this.extX = MIN_SHAPE_SIZE;
this.extY = MIN_SHAPE_SIZE;//*this.invPropCoefficient;
}
} */
}
if(_real_dist_x >= 0)
{
this.posX = this.startPosX;
}
else
{
this.posX = this.startPosX - this.extX;
}
if(_real_dist_y >= 0)
{
this.posY = this.startPosY;
}
else
{
this.posY = this.startPosY - this.extY;
}
}
this.geometry.Recalculate(this.extX, this.extY);
}
else if(ctrlKey && shiftKey)
{
}
this.calculateTransform();
};
this.calculateTransform = function()
{
var _new_transform = this.transformMatrix;
_new_transform.Reset();
if(this.flipH || this.flipV)
{
var _horizontal_center = this.extX*0.5;
var _vertical_center = this.extY*0.5;
_new_transform.Translate(-_horizontal_center, -_vertical_center, MATRIX_ORDER_APPEND);
if(this.flipH)
_new_transform.Translate(-1, 1, MATRIX_ORDER_APPEND);
if(this.flipV)
_new_transform.Translate(1, -1, MATRIX_ORDER_APPEND);
_new_transform.Translate(_horizontal_center, _vertical_center, MATRIX_ORDER_APPEND);
}
_new_transform.Translate(this.posX, this.posY, MATRIX_ORDER_APPEND);
this.transformMatrix = _new_transform;
};
this.endTrack = function()
{
/*this.originalShape.setAbsoluteTransform(this.posX, this.posY, this.extX, this.extY, 0, this.flipH, this.flipV);
this.originalShape.calculateTransformMatrix();*/
this.originalShape.Track_End(this.pageIndex, this.posX, this.posY, this.extX, this.extY);
};
this.draw = function(overlay)
{
overlay.SetCurrentPage(this.pageIndex);
overlay.transform3(this.transformMatrix);
this.objectForOverlay.updateTransform(this.extX, this.extY, this.transformMatrix);
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape2(this.objectForOverlay, overlay, this.geometry);
shape_drawer.draw(this.geometry);
overlay.reset();
}
}
function RotateTrackShape(originalShape, pageIndex)
{
this.originalShape = originalShape;
this.pageIndex = pageIndex;
this.pen = this.originalShape.pen;
this.brush = this.originalShape.brush;
this.originalRot = this.originalShape.absRot;
this.rot = this.originalShape.absRot;
this.transformMatrix = this.originalShape.transform.CreateDublicate();
this.objectForOverlay = new ObjectForShapeDrawer(this.originalShape.spPr.geometry, this.originalShape.absExtX, this.originalShape.absExtY, this.brush, this.pen, this.transformMatrix);
this.textMatrix = null;
if(isRealObject(this.originalShape.parent))
{
if(this.originalShape.parent.Is_Inline())
{
if(this.originalShape.parent.DocumentContent instanceof CDocumentContent)
{
var cur_doc_content = this.originalShape.parent.DocumentContent;
while(cur_doc_content.Is_TableCellContent())
{
cur_doc_content = cur_doc_content.Parent.Row.Table.Parent;
}
if((cur_doc_content instanceof CDocumentContent && cur_doc_content.Parent instanceof WordShape))
{
this.textMatrix = cur_doc_content.Parent.transformText;
}
}
}
}
this.track = function(angle, shiftKey)
{
var _new_rot = angle + this.originalRot;
while(_new_rot < 0)
_new_rot += 2*Math.PI;
while(_new_rot >= 2*Math.PI)
_new_rot -= 2*Math.PI;
if(_new_rot < MIN_ANGLE || _new_rot > 2*Math.PI - MIN_ANGLE)
{
_new_rot = 0;
}
if(Math.abs(_new_rot-Math.PI*0.5) < MIN_ANGLE)
{
_new_rot = Math.PI*0.5;
}
if(Math.abs(_new_rot-Math.PI) < MIN_ANGLE)
{
_new_rot = Math.PI;
}
if(Math.abs(_new_rot-1.5*Math.PI) < MIN_ANGLE)
{
_new_rot = 1.5*Math.PI;
}
if(shiftKey)
{
_new_rot = (Math.PI/12)*Math.floor(12*_new_rot/(Math.PI));
}
this.rot = _new_rot;
this.calculateTransformMatrix();
};
this.calculateTransformMatrix = function()
{
var _transform = this.transformMatrix;
_transform.Reset();
var _horizontal_center = this.originalShape.absExtX*0.5;
var _vertical_center = this.originalShape.absExtY*0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.originalShape.absFlipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.originalShape.absFlipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.rot);
global_MatrixTransformer.TranslateAppend(_transform, this.originalShape.absOffsetX, this.originalShape.absOffsetY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
if(this.originalShape.mainGroup !== null)
{
global_MatrixTransformer.MultiplyAppend(_transform, this.originalShape.mainGroup.getTransform());
}
if( this.textMatrix != null)
{
global_MatrixTransformer.MultiplyAppend(_transform, this.textMatrix);
}
};
this.getBounds = function()
{
var bounds_checker = new CSlideBoundsChecker();
bounds_checker.init(Page_Width, Page_Height, Page_Width, Page_Height);
this.draw(bounds_checker);
return {l: bounds_checker.Bounds.min_x, t: bounds_checker.Bounds.min_y, r: bounds_checker.Bounds.max_x , b: bounds_checker.Bounds.max_y};
};
this.getBoundsRect = function()
{
var t = this.transformMatrix;
var min_x, max_x, min_y, max_y;
min_x = t.TransformPointX(0, 0);
max_x = min_x;
min_y = t.TransformPointY(0, 0);
max_y = min_y;
var or_sp = this.originalShape;
var arr = [{x: or_sp.absExtX, y: 0}, {x: or_sp.absExtX, y: or_sp.absExtY}, {x: 0, y: or_sp.absExtY}];
var t_x, t_y;
for(var i = 0; i < arr.length; ++i)
{
var p = arr[i];
t_x = t.TransformPointX(p.x, p.y);
t_y = t.TransformPointY(p.x, p.y);
if(t_x < min_x)
min_x = t_x;
if(t_x > max_x)
max_x = t_x;
if(t_y < min_y)
min_y = t_y;
if(t_y > max_y)
max_y = t_y;
}
return {l: min_x, t: min_y, r: max_x, b: max_y};
};
this.draw = function(overlay)
{
overlay.SetCurrentPage(this.pageIndex);
overlay.transform3(this.transformMatrix);
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape2(this.objectForOverlay, overlay, this.geometry);
shape_drawer.draw(this.originalShape.spPr.geometry);
overlay.reset();
};
this.trackEnd = function()
{
if(this.originalShape.absRot !== this.rot)
{
this.originalShape.setXfrm(null, null, null, null, this.rot, null, null);
this.originalShape.setAbsoluteTransform(null, null, null, null, this.rot, null, null);
this.originalShape.recalculate();
}
this.boolChangePos = true;
};
}
function ShapeForDrawOnOverlayInGroup(originalShape)
{
this.originalShape = originalShape;
var _transform = new CMatrix();
var _horizontal_center = originalShape.absExtX*0.5;
var _vertical_center = originalShape.absExtY*0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.originalShape.absFlipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.originalShape.absFlipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -originalShape.absRot);
global_MatrixTransformer.TranslateAppend(_transform, originalShape.absOffsetX, originalShape.absOffsetY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
this.localTransform = _transform;
this.fullTransform = new CMatrix();
this.pageIndex = originalShape.pageIndex;
this.objectForOverlay = new ObjectForShapeDrawer(originalShape.spPr.geometry, originalShape.absExtX, originalShape.absExtY, originalShape.brush, originalShape.pen, this.fullTransform);
this.draw = function(overlay)
{
overlay.SetCurrentPage(this.pageIndex);
overlay.transform3(this.fullTransform);
this.objectForOverlay.updateTransform(this.originalShape.absExtX, this.originalShape.absExtY, this.fullTransform);
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape2(this.objectForOverlay, overlay, this.geometry);
shape_drawer.draw(this.originalShape.spPr.geometry);
overlay.reset();
};
this.getBounds = function()
{
var bounds_checker = new CSlideBoundsChecker();
bounds_checker.init(Page_Width, Page_Height, Page_Width, Page_Height);
this.draw(bounds_checker);
return {l: bounds_checker.Bounds.min_x, t: bounds_checker.Bounds.min_y, r: bounds_checker.Bounds.max_x , b: bounds_checker.Bounds.max_y};
};
this.calculateFullTransform = function(parentTransform)
{
this.fullTransform = this.localTransform.CreateDublicate();
global_MatrixTransformer.MultiplyAppend(this.fullTransform, parentTransform);
}
}
function ShapeForTrackInResizeGroup(originalShape)
{
this.pageIndex = originalShape.pageIndex;
this.originalShape = originalShape;
this.originalOffsetX = originalShape.absOffsetX;
this.originalOffsetY = originalShape.absOffsetY;
this.originalExtX = originalShape.absExtX;
this.originalExtY = originalShape.absExtY;
this.originalRot = originalShape.absRot;
this.originalFlipH = originalShape.absFlipH;
this.originalFlipV = originalShape.absFlipV;
this.originalHalfHeight = this.originalExtY*0.5;
this.originalHalfWidht = this.originalExtX*0.5;
this.originalCenterPositionX = this.originalOffsetX + this.originalHalfWidht;
this.originalCenterPositionY = this.originalOffsetY + this.originalHalfHeight;
this.originalGroupHalfHeight = originalShape.mainGroup.absExtY*0.5;
this.originalGroupHalfWidth = originalShape.mainGroup.absExtX*0.5;
this.centerDistX = this.originalCenterPositionX - this.originalGroupHalfWidth;
this.centerDistY = this.originalCenterPositionY - this.originalGroupHalfHeight;
this.resizedOffsetX = originalShape.absOffsetX;
this.resizedOffsetY = originalShape.absOffsetY;
this.resizedExtX = originalShape.absExtX;
this.resizedExtY = originalShape.absExtY;
this.resizedRot = originalShape.absRot;
this.resizedFlipH = originalShape.absFlipH;
this.resizedFlipV = originalShape.absFlipV;
this.transformMatrix = originalShape.transform.CreateDublicate();
this.bSwapCoef = !(this.originalRot < Math.PI*0.25 || this.originalRot>Math.PI*1.75 || (this.originalRot>Math.PI*0.75 && this.originalRot<Math.PI*1.25));
this.geometry = originalShape.spPr.geometry !== null ? originalShape.spPr.geometry.createDuplicate() : null;
this.objectForOverlay = new ObjectForShapeDrawer(this.geometry, this.resizedExtX, this.resizedExtY, this.originalShape.brush, this.originalShape.pen, this.transformMatrix);
this.changeSizes = function(kw,kh, newHalfWidth, newHalfHeight)
{
var _sw_kw = kw;
var _sw_kh = kh;
if(this.bSwapCoef)
{
_sw_kw = kh;
_sw_kh = kw;
}
this.resizedExtX = this.originalExtX*_sw_kw;
this.resizedExtY = this.originalExtY*_sw_kh;
this.resizedOffsetX = this.centerDistX*kw + newHalfWidth - this.resizedExtX*0.5;
this.resizedOffsetY = this.centerDistY*kh + newHalfHeight - this.resizedExtY*0.5;
if(this.geometry !== null)
this.geometry.Recalculate(this.resizedExtX,this.resizedExtY);
};
this.calculateTransformMatrix = function(parentTransform)
{
var _transform = this.transformMatrix;
_transform.Reset();
var _horizontal_center = this.resizedExtX*0.5;
var _vertical_center = this.resizedExtY*0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.resizedFlipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.resizedFlipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.resizedRot);
global_MatrixTransformer.TranslateAppend(_transform, this.resizedOffsetX, this.resizedOffsetY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
global_MatrixTransformer.MultiplyAppend(_transform, parentTransform);
this.transformMatrix = _transform;
};
this.draw = function(overlay)
{
overlay.transform3(this.transformMatrix);
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape2(this.objectForOverlay, overlay, this.geometry);
shape_drawer.draw(this.geometry);
overlay.reset();
};
this.endTrack = function()
{
this.originalShape.setSizesInGroup(this.resizedOffsetX, this.resizedOffsetY, this.resizedExtX, this.resizedExtY);
};
this.getBounds = function()
{
var bounds_checker = new CSlideBoundsChecker();
bounds_checker.init(Page_Width, Page_Height, Page_Width, Page_Height);
this.draw(bounds_checker);
return {l: bounds_checker.Bounds.min_x, t: bounds_checker.Bounds.min_y, r: bounds_checker.Bounds.max_x , b: bounds_checker.Bounds.max_y};
};
}
function ShapeTrackForMoveInGroup(originalShape, majorOffsetX, majorOffsetY)
{
this.originalShape = originalShape;
this.originalOffsetX = originalShape.absOffsetX;
this.originalOffsetY = originalShape.absOffsetY;
this.originalExtX = originalShape.absExtX;
this.originalExtY = originalShape.absExtY;
this.originalHorC = this.originalExtX*0.5;
this.originalVerC = this.originalExtY*0.5;
this.originalRot = originalShape.absRot;
this.originalFlipH = originalShape.absFlipH;
this.originalFlipV = originalShape.absFlipV;
this.resizedPosX = originalShape.absOffsetX;
this.resizedPosY = originalShape.absOffsetY;
this.geometry = originalShape.spPr.geometry;
this.pen = originalShape.pen;
this.brush = originalShape.brush;
this.majorOffsetX = majorOffsetX;
this.majorOffsetY = majorOffsetY;
this.parentTransform = originalShape.mainGroup.transform;
this.fullTransform = originalShape.transform.CreateDublicate();
this.objectForOverlay = new ObjectForShapeDrawer(this.geometry, this.originalExtX, this.originalExtY, this.brush, this.pen, this.fullTransform);
this.track = function(posX, posY)
{
this.resizedPosX = posX + this.majorOffsetX;
this.resizedPosY = posY + this.majorOffsetY;
this.calculateTransform();
};
this.getBounds = function()
{
var bounds_checker = new CSlideBoundsChecker();
bounds_checker.init(Page_Width, Page_Height, Page_Width, Page_Height);
this.draw(bounds_checker);
return {l: bounds_checker.Bounds.min_x, t: bounds_checker.Bounds.min_y, r: bounds_checker.Bounds.max_x , b: bounds_checker.Bounds.max_y};
};
this.calculateTransform = function()
{
var _transform = this.fullTransform;
_transform.Reset();
var _horizontal_center = this.originalHorC;
var _vertical_center = this.originalVerC;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.originalFlipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.originalFlipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.originalRot);
global_MatrixTransformer.TranslateAppend(_transform, this.resizedPosX, this.resizedPosY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
global_MatrixTransformer.MultiplyAppend(_transform, this.parentTransform);
};
this.draw = function(overlay)
{
overlay.SetCurrentPage(this.originalShape.pageIndex);
overlay.transform3(this.fullTransform);
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape2(this.objectForOverlay, overlay, this.geometry);
shape_drawer.draw(this.geometry);
overlay.reset();
};
this.trackEnd = function()
{
this.originalShape.setAbsoluteTransform(this.resizedPosX, this.resizedPosY, null, null, null, null, null);
this.originalShape.calculateTransformMatrix();
this.originalShape.calculateTransformTextMatrix();
var _invert_group_transform = global_MatrixTransformer.Invert(this.originalShape.group.transform);
var _shape_transform = this.originalShape.transform;
var _global_xc = _shape_transform.TransformPointX(this.originalShape.absExtX*0.5, this.originalShape.absExtY*0.5);
var _global_yc = _shape_transform.TransformPointY(this.originalShape.absExtX*0.5, this.originalShape.absExtY*0.5);
var _xc_rel_group = _invert_group_transform.TransformPointX(_global_xc, _global_yc);
var _yc_rel_group = _invert_group_transform.TransformPointY(_global_xc, _global_yc);
var _rel_pos_x = _xc_rel_group - this.originalShape.absExtX*0.5;
var _rel_pos_y = _yc_rel_group - this.originalShape.absExtY*0.5;
this.originalShape.setXfrm(_rel_pos_x, _rel_pos_y, null, null, null, null, null);
}
}
function ShapeForResizeInGroup2(originalShape, numberHandle)
{
this.shape = originalShape;
this.pageIndex = originalShape.pageIndex;
this.originalShape = this.shape;
var xfrm = originalShape.spPr.xfrm;
this.flipH = xfrm.flipH == null ? false : xfrm.flipH;
this.flipV = xfrm.flipV == null ? false : xfrm.flipV;
var _flip_h = this.flipH;
var _flip_v = this.flipV;
var _half_height = xfrm.extY*0.5;
var _half_width = xfrm.extX*0.5;
var rot = xfrm.rot == null ? 0 : xfrm.rot;
var _sin = Math.sin(rot);
var _cos = Math.cos(rot);
var _translated_num_handle;
if(!_flip_h && !_flip_v)
{
_translated_num_handle = numberHandle;
}
else if(_flip_h && !_flip_v)
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_H[numberHandle];
}
else if(!_flip_h && _flip_v)
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_V[numberHandle];
}
else
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[numberHandle];
}
this.bAspect = numberHandle % 2 === 0;
this.aspect = this.bAspect === true ? this.originalShape.getAspect(_translated_num_handle) : 0;
this.sin = _sin;
this.cos = _cos;
this.translatetNumberHandle = _translated_num_handle;
switch (_translated_num_handle)
{
case 0:
case 1:
{
this.fixedPointX = (_half_width*_cos - _half_height*_sin) + _half_width + xfrm.offX;
this.fixedPointY = (_half_width*_sin + _half_height*_cos) + _half_height + xfrm.offY;
break;
}
case 2:
case 3:
{
this.fixedPointX = (-_half_width*_cos - _half_height*_sin) + _half_width + xfrm.offX;
this.fixedPointY = (-_half_width*_sin + _half_height*_cos) + _half_height + xfrm.offY;
break;
}
case 4:
case 5:
{
this.fixedPointX = (-_half_width*_cos + _half_height*_sin) + _half_width + xfrm.offX;
this.fixedPointY = (-_half_width*_sin - _half_height*_cos) + _half_height + xfrm.offY;
break;
}
case 6:
case 7:
{
this.fixedPointX = (_half_width*_cos + _half_height*_sin) + _half_width + xfrm.offX;
this.fixedPointY = (_half_width*_sin - _half_height*_cos) + _half_height + xfrm.offY;
break;
}
}
this.mod = this.translatetNumberHandle % 4;
this.centerPointX =xfrm.offX + _half_width;
this.centerPointY =xfrm.offY + _half_height;
this.lineFlag = originalShape.checkLine();
this.originalExtX = xfrm.extX;
this.originalExtY = xfrm.extY;
this.originalFlipH = _flip_h;
this.originalFlipV = _flip_v;
this.usedExtX = this.originalExtX === 0 ? (/*this.lineFlag ? this.originalExtX :*/ 0.01) : this.originalExtX;
this.usedExtY = this.originalExtY === 0 ? (/*this.lineFlag ? this.originalExtY :*/ 0.01) : this.originalExtY;
this.resizedExtX = this.originalExtX;
this.resizedExtY = this.originalExtY;
this.resizedflipH = _flip_h;
this.resizedflipV = _flip_v;
this.resizedPosX = xfrm.offX;
this.resizedPosY = xfrm.offY;
this.resizedRot = rot;
this.transformMatrix = originalShape.transform.CreateDublicate();
this.geometry = originalShape.spPr.geometry.createDuplicate();
var pen, brush;
if(originalShape instanceof CChartAsGroup)
{
brush = new CUniFill();
brush.fill = new CSolidFill();
brush.fill.color = new CUniColor();
brush.fill.color.RGBA = {R:255, G:255, B:255, A:255};
brush.fill.color.color = new CRGBColor();
brush.fill.color.color.RGBA = {R:255, G:255, B:255, A:255};
pen = new CLn();
pen.Fill = new CUniFill();
pen.Fill.fill = new CSolidFill();
pen.Fill.fill.color = new CUniColor();
pen.Fill.fill.color.color = new CRGBColor();
this.pen = pen;
this.brush = brush;
}
else
{
this.pen = originalShape.pen;
this.brush = originalShape.brush;
}
this.bChangeCoef = this.translatetNumberHandle % 2 === 0 && this.originalFlipH !== this.originalFlipV;
this.objectForOverlay = new ObjectForShapeDrawer(this.geometry, this.resizedExtX, this.resizedExtY, this.brush, this.pen, this.transformMatrix);
this.resize = function(kd1, kd2, shiftKey)
{
var _cos = this.cos;
var _sin = this.sin;
var _real_height, _real_width;
var _abs_height, _abs_width;
var _new_resize_half_width;
var _new_resize_half_height;
var _new_used_half_width;
var _new_used_half_height;
var _temp;
if(shiftKey === true && this.bAspect === true)
{
var _new_aspect = this.aspect*(Math.abs(kd1/ kd2));
if (_new_aspect >= this.aspect)
kd2 = Math.abs(kd1)*(kd2 >= 0 ? 1 : -1 );
else
kd1 = Math.abs(kd2)*(kd1 >= 0 ? 1 : -1);
}
if(this.bChangeCoef)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
switch (this.translatetNumberHandle)
{
case 0:
case 1:
{
if(this.translatetNumberHandle === 0)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
}
if(this.translatetNumberHandle === 1)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (-_new_used_half_width*_cos + _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (-_new_used_half_width*_sin - _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 2:
case 3:
{
if(this.translatetNumberHandle === 2)
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
}
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (_new_used_half_width*_cos + _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (_new_used_half_width*_sin - _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 4:
case 5:
{
if(this.translatetNumberHandle === 4)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
}
else
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (_new_used_half_width*_cos - _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (_new_used_half_width*_sin + _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 6:
case 7:
{
if(this.translatetNumberHandle === 6)
{
_real_height = this.usedExtY*kd1;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
}
else
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
}
_real_width = this.usedExtX*kd2;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (-_new_used_half_width*_cos - _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (-_new_used_half_width*_sin + _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
}
this.geometry.Recalculate(this.resizedExtX, this.resizedExtY);
var _transform = this.transformMatrix;
_transform.Reset();
var _horizontal_center = this.resizedExtX*0.5;
var _vertical_center = this.resizedExtY*0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.resizedflipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.resizedflipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.resizedRot);
global_MatrixTransformer.TranslateAppend(_transform, this.resizedPosX, this.resizedPosY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
global_MatrixTransformer.MultiplyAppend(_transform, this.originalShape.group.getTransform());
};
this.resizeRelativeCenter = function(kd1, kd2, shiftKey)
{
kd1 = 2*kd1 - 1;
kd2 = 2*kd2 - 1;
var _real_height, _real_width;
var _abs_height, _abs_width;
if(shiftKey === true && this.bAspect === true)
{
var _new_aspect = this.aspect*(Math.abs(kd1/ kd2));
if (_new_aspect >= this.aspect)
kd2 = Math.abs(kd1)*(kd2 >= 0 ? 1 : -1 );
else
kd1 = Math.abs(kd2)*(kd1 >= 0 ? 1 : -1);
}
var _temp;
if(this.bChangeCoef)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
if(this.mod === 0 || this.mod === 1)
{
if(this.mod === 0)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
this.resizedflipH = _real_width < 0 ? !this.originalFlipH : this.originalFlipH;
}
else
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
this.resizedflipV = _real_height < 0 ? !this.originalFlipV : this.originalFlipV;
}
else
{
if(this.mod === 2)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
this.resizedflipV = _real_height < 0 ? !this.originalFlipV : this.originalFlipV;
}
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
this.resizedflipH = _real_width < 0 ? !this.originalFlipH : this.originalFlipH;
}
this.resizedPosX = this.centerPointX - this.resizedExtX*0.5;
this.resizedPosY = this.centerPointY - this.resizedExtY*0.5;
this.geometry.Recalculate(this.resizedExtX, this.resizedExtY);
var _transform = this.transformMatrix;
_transform.Reset();
var _horizontal_center = this.resizedExtX*0.5;
var _vertical_center = this.resizedExtY*0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.resizedflipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.resizedflipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.resizedRot);
global_MatrixTransformer.TranslateAppend(_transform, this.resizedPosX, this.resizedPosY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
global_MatrixTransformer.MultiplyAppend(_transform, this.originalShape.group.getTransform());
};
this.draw = function(overlay)
{
overlay.SetCurrentPage(this.pageIndex);
overlay.transform3(this.transformMatrix);
this.objectForOverlay.updateTransform(this.resizedExtX, this.resizedExtY, this.transformMatrix);
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape2(this.objectForOverlay, overlay, this.geometry);
shape_drawer.draw(this.geometry);
};
this.getBounds = function()
{
var bounds_checker = new CSlideBoundsChecker();
bounds_checker.init(Page_Width, Page_Height, Page_Width, Page_Height);
this.draw(bounds_checker);
return {l: bounds_checker.Bounds.min_x, t: bounds_checker.Bounds.min_y, r: bounds_checker.Bounds.max_x , b: bounds_checker.Bounds.max_y};
};
this.getBoundsRect = function()
{
var t = this.transformMatrix;
var max_x, min_x, max_y, min_y;
min_x = t.TransformPointX(0, 0);
max_x = min_x;
min_y = t.TransformPointY(0, 0);
max_y = min_y;
var arr = [{x: this.resizedExtX, y: 0}, {x: this.resizedExtX, y: this.resizedExtY}, {x: 0, y: this.resizedExtY}];
var t_x, t_y;
for(var i = 0; i < arr.length; ++i)
{
var p = arr[i];
t_x = t.TransformPointX(p.x, p.y);
t_y = t.TransformPointY(p.x, p.y);
if(t_x < min_x)
min_x = t_x;
if(t_x > max_x)
max_x = t_x;
if(t_y < min_y)
min_y = t_y;
if(t_y > max_y)
max_y = t_y;
}
return {l: min_x, t: min_y, r: max_x, b: max_y};
};
this.endTrack = function()
{
/* var _b_group = this.originalShape.group !== null;
var _old_abs_xc;
var _old_abs_yc;
var _b_change_flip_h;
var _b_change_flip_v;
var _old_relative_xc;
var _old_relative_yc;
if(_b_group)
{
_b_change_flip_h = this.originalShape.absFlipH !== this.resizedflipH;
_b_change_flip_v = this.originalShape.absFlipV !== this.resizedflipV;
}
this.boolChangePos = this.originalShape.absOffsetX !== this.resizedPosX || this.originalShape.absOffsetY !== this.resizedPosY;
if(this.originalShape.group == null)
{
this.originalShape.setSizes(this.resizedPosX, this.resizedPosY, this.resizedExtX, this.resizedExtY, this.resizedflipH, this.resizedflipV);
if(this.originalShape.parent.wrappingPolygon.edited)
{
var kW = this.resizedExtX/this.originalExtX;
var kH = this.resizedExtY/this.originalExtY;
var arr_points = this.originalShape.parent.wrappingPolygon.relativeArrPoints;
for(var point_index = 0; point_index < arr_points.length; ++point_index)
{
arr_points[point_index].x*=kW;
arr_points[point_index].y*=kH;
}
this.originalShape.parent.wrappingPolygon.calculateRelToAbs(this.originalShape.parent.getTransformMatrix());
}
}
else
{
this.originalShape.setAbsoluteTransform(this.resizedPosX, this.resizedPosY, this.resizedExtX, this.resizedExtY, null, this.resizedflipH, this.resizedflipV);
this.originalShape.calculateAfterResize();
if(_b_group)
{
var _invert_group_transform = global_MatrixTransformer.Invert(this.originalShape.group.transform);
var _shape_transform = this.originalShape.transform;
var _global_xc = _shape_transform.TransformPointX(this.originalShape.absExtX*0.5, this.originalShape.absExtY*0.5);
var _global_yc = _shape_transform.TransformPointY(this.originalShape.absExtX*0.5, this.originalShape.absExtY*0.5);
var _xc_rel_group = _invert_group_transform.TransformPointX(_global_xc, _global_yc);
var _yc_rel_group = _invert_group_transform.TransformPointY(_global_xc, _global_yc);
var _rel_pos_x = _xc_rel_group - this.originalShape.absExtX*0.5;
var _rel_pos_y = _yc_rel_group - this.originalShape.absExtY*0.5;
var _new_rel_flip_h;
var _new_rel_flip_v;
if(_b_change_flip_h)
_new_rel_flip_h = !this.originalShape.spPr.xfrm.flipH;
else
_new_rel_flip_h = null;
if(_b_change_flip_v)
_new_rel_flip_v = !this.originalShape.spPr.xfrm.flipV;
else
_new_rel_flip_v = null;
this.originalShape.setXfrm(_rel_pos_x, _rel_pos_y, this.resizedExtX, this.resizedExtY, null, _new_rel_flip_h, _new_rel_flip_v);
}
else
{
if(this.originalShape.parent.wrappingPolygon.edited)
{
var kW = this.resizedExtX/this.originalExtX;
var kH = this.resizedExtY/this.originalExtY;
var arr_points = this.originalShape.parent.wrappingPolygon.relativeArrPoints;
for(var point_index = 0; point_index < arr_points.length; ++point_index)
{
arr_points[point_index].x*=kW;
arr_points[point_index].y*=kH;
}
this.originalShape.parent.wrappingPolygon.calculateRelToAbs(this.originalShape.parent.getTransformMatrix());
}
}
}
if(this.originalShape.isImage() && isRealObject(this.originalShape.chart))
{
this.originalShape.chart.width = this.originalShape.drawingDocument.GetDotsPerMM(this.resizedExtX);
this.originalShape.chart.height = this.originalShape.drawingDocument.GetDotsPerMM(this.resizedExtY);
var chartRender = new ChartRender();
var chartBase64 = chartRender.insertChart(this.originalShape.chart, null, this.originalShape.chart.width, this.originalShape.chart.height);
if ( !chartBase64 )
return;
var _image = editor.ImageLoader.LoadImage(_getFullImageSrc(chartBase64), 1);
var or_shp = this.originalShape;
if (null != _image)
{
this.originalShape.setRasterImage(chartBase64)
}
else
{
editor.sync_StartAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.LoadImage);
editor.asyncImageEndLoaded2 = function(_image)
{
or_shp.setRasterImage(_image.src);
editor.sync_EndAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.LoadImage);
if(or_shp.group == null)
{
var or_gr_obj = or_shp.parent;
var bounds_2 = or_gr_obj.getBounds();
if(!or_gr_obj.Is_Inline())
{
or_gr_obj.calculateOffset();
var pos_x = or_gr_obj.absOffsetX - or_gr_obj.boundsOffsetX;
var pos_y = or_gr_obj.absOffsetY - or_gr_obj.boundsOffsetY;
var near_pos = or_shp.document.Get_NearestPos(pageIndex, bounds_2.l, bounds_2.t, true, or_gr_obj);
var W = bounds_2.r - bounds_2.l;
var H = bounds_2.b - bounds_2.t;
or_gr_obj.OnEnd_ChangeFlow(pos_x, pos_y, or_gr_obj.pageIndex, W, H, near_pos, false, true);
}
else
{
or_gr_obj.OnEnd_ResizeInline(bounds_2.r - bounds_2.l, bounds_2.b - bounds_2.t);
}
}
}
}
} */
this.originalShape.setXfrm(this.resizedPosX, this.resizedPosY, this.resizedExtX, this.resizedExtY, null, this.resizedflipH, this.resizedflipV);
this.originalShape.setAbsoluteTransform(this.resizedPosX, this.resizedPosY, this.resizedExtX, this.resizedExtY, null, this.resizedflipH, this.resizedflipV);
if(this.originalShape.spPr.geometry)
this.originalShape.spPr.geometry.Recalculate(this.resizedExtX, this.resizedExtY);
};
}
function ShapeForRotateInGroup(originalShape)
{
this.original = originalShape;
var xfrm = this.original.spPr.xfrm;
this.pageIndex = this.original.pageIndex;
this.pen = this.original.pen;
this.brush = this.original.brush;
this.originalRot = xfrm.rot == null ? 0 : xfrm.rot;
this.rot = xfrm.rot == null ? 0 : xfrm.rot;
this.transformMatrix = this.original.transform.CreateDublicate();
this.objectForOverlay = new ObjectForShapeDrawer(this.original.spPr.geometry, xfrm.extX, xfrm.extY, this.brush, this.pen, this.transformMatrix);
this.track = function(angle, shiftKey)
{
var _new_rot = angle + this.originalRot;
while(_new_rot < 0)
_new_rot += 2*Math.PI;
while(_new_rot >= 2*Math.PI)
_new_rot -= 2*Math.PI;
if(_new_rot < MIN_ANGLE || _new_rot > 2*Math.PI - MIN_ANGLE)
{
_new_rot = 0;
}
if(Math.abs(_new_rot-Math.PI*0.5) < MIN_ANGLE)
{
_new_rot = Math.PI*0.5;
}
if(Math.abs(_new_rot-Math.PI) < MIN_ANGLE)
{
_new_rot = Math.PI;
}
if(Math.abs(_new_rot-1.5*Math.PI) < MIN_ANGLE)
{
_new_rot = 1.5*Math.PI;
}
if(shiftKey)
{
_new_rot = (Math.PI/12)*Math.floor(12*_new_rot/(Math.PI));
}
this.rot = _new_rot;
this.calculateTransformMatrix();
};
this.calculateTransformMatrix = function()
{
var _transform = this.transformMatrix;
_transform.Reset();
var _horizontal_center = this.original.absExtX*0.5;
var _vertical_center = this.original.absExtY*0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.original.absFlipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.original.absFlipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.rot);
global_MatrixTransformer.TranslateAppend(_transform, this.original.absOffsetX, this.original.absOffsetY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
global_MatrixTransformer.MultiplyAppend(_transform, this.original.group.getTransform());
};
this.getBounds = function()
{
var bounds_checker = new CSlideBoundsChecker();
bounds_checker.init(Page_Width, Page_Height, Page_Width, Page_Height);
this.draw(bounds_checker);
return {l: bounds_checker.Bounds.min_x, t: bounds_checker.Bounds.min_y, r: bounds_checker.Bounds.max_x , b: bounds_checker.Bounds.max_y};
};
this.getBoundsRect = function()
{
var t = this.transformMatrix;
var min_x, max_x, min_y, max_y;
min_x = t.TransformPointX(0, 0);
max_x = min_x;
min_y = t.TransformPointY(0, 0);
max_y = min_y;
var or_sp = this.originalShape;
var arr = [{x: or_sp.absExtX, y: 0}, {x: or_sp.absExtX, y: or_sp.absExtY}, {x: 0, y: or_sp.absExtY}];
var t_x, t_y;
for(var i = 0; i < arr.length; ++i)
{
var p = arr[i];
t_x = t.TransformPointX(p.x, p.y);
t_y = t.TransformPointY(p.x, p.y);
if(t_x < min_x)
min_x = t_x;
if(t_x > max_x)
max_x = t_x;
if(t_y < min_y)
min_y = t_y;
if(t_y > max_y)
max_y = t_y;
}
return {l: min_x, t: min_y, r: max_x, b: max_y};
};
this.draw = function(overlay)
{
overlay.SetCurrentPage(this.pageIndex);
overlay.transform3(this.transformMatrix);
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape2(this.objectForOverlay, overlay, this.original.spPr.geometry);
shape_drawer.draw(this.original.spPr.geometry);
overlay.reset();
};
this.trackEnd = function()
{
this.original.setXfrm(null, null, null, null, this.rot, null, null);
this.original.setAbsoluteTransform(null, null, null, null, this.rot, null, null);
};
}
\ No newline at end of file
function CTextBody(shape)
{
//this.shape = shape;
this.bodyPr = new CBodyPr();
this.bodyPr.setDefault();
this.lstStyle = null;
this.content = null;//new CDocumentContent(this, shape.drawingObjects.drawingDocument, 0, 0, 200, 20000, false, false);
this.contentWidth = 0;
this.contentHeight = 0;
this.styles = [];
this.recalcInfo =
{};
this.Id = g_oIdCounter.Get_NewId();
g_oTableId.Add(this, this.Id);
if(isRealObject(shape))
{
this.setShape(shape);
this.setDocContent(new CDocumentContent(this, editor.WordControl.m_oLogicDocument.DrawingDocument, 0, 0, 0, 20000, false, false));
}
}
CTextBody.prototype =
{
Get_TextBackGroundColor : function()
{
return undefined;
},
Get_Id: function()
{
return this.Id;
},
Write_ToBinary2: function(w)
{
w.WriteLong(historyitem_type_TextBody);
w.WriteString2(this.Id);
},
Read_FromBinary2: function(r)
{
this.Id = r.GetString2();
},
Is_TopDocument: function()
{
return false;
},
Is_HdrFtr: function()
{
return false;
},
getType: function()
{
return CLASS_TYPE_TEXT_BODY;
},
getObjectType: function()
{
return CLASS_TYPE_TEXT_BODY;
},
setLstStyle: function(lstStyle)
{
History.Add(this, {Type:historyitem_SetLstStyle, oldPr: this.lstStyle, newPr: lstStyle});
this.lstStyle = lstStyle;
},
setShape: function(shape)
{
History.Add(this, {Type:historyitem_SetShape, oldPr: this.shape, newPr: shape});
this.shape = shape;
},
setDocContent: function(docContent)
{
History.Add(this, {Type:historyitem_SetDocContent, oldPr: this.content, newPr: docContent});
this.content = docContent;
if(this.content && this.shape instanceof CChartTitle)
{
var is_on = History.Is_On();
if(is_on)
{
History.TurnOff();
}
var styles = new CStyles();
var default_legend_style = new CStyle("defaultLegendStyle", styles.Default, null, styletype_Paragraph);
var TextPr = {FontFamily:{}};
TextPr.FontFamily.Name = "Calibri";
TextPr.FontFamily.Index = -1;
TextPr.RFonts = {};
TextPr.RFonts.Ascii =
{
Name : "Calibri",
Index : -1
};
TextPr.RFonts.EastAsia =
{
Name : "Calibri",
Index : -1
};
TextPr.RFonts.HAnsi =
{
Name : "Calibri",
Index : -1
};
TextPr.RFonts.CS =
{
Name : "Calibri",
Index : -1
};
TextPr.Bold = true;
if(this.shape.getTitleType() === CHART_TITLE_TYPE_TITLE)
TextPr.FontSize = 18;
else
TextPr.FontSize = 10;
default_legend_style.TextPr.Set_FromObject(TextPr);
default_legend_style.ParaPr.Spacing.After = 0;
default_legend_style.ParaPr.Spacing.Before = 0;
default_legend_style.ParaPr.Spacing.LineRule = linerule_AtLeast;
default_legend_style.ParaPr.Spacing.Line = 1;
default_legend_style.ParaPr.Jc = align_Center;
//TODO:ParaPr: default_legend_style.ParaPr.Ind
var tx_pr;
if(isRealObject(this.txPr))
{
//TODO
}
styles.Style[default_legend_style.Id] = default_legend_style;
this.content.Styles = styles;
this.content.Content[0].Style_Add_Open(default_legend_style.Id);
if(is_on)
{
History.TurnOn();
}
}
},
Refresh_RecalcData: function()
{
if(isRealObject(this.content))
{
if(this.shape instanceof CChartTitle)
{
if(this.shape.chartGroup instanceof CChartAsGroup && this.shape.chartGroup.chart)
this.shape.chartGroup.Refresh_RecalcData();
}
else
this.content.Recalculate_Page(0, true);
}
},
draw: function(graphics, pageIndex)
{
if(!graphics.IsNoSupportTextDraw)
{
if(typeof pageIndex === "number")
{
var old_start_page = this.content.Get_StartPage_Relative();
this.content.Set_StartPage(pageIndex);
}
var result_page_index = typeof pageIndex === "number" ? pageIndex : this.shape.pageIndex;
this.content.Set_StartPage(result_page_index);
this.content.Draw(result_page_index, graphics);
if(typeof pageIndex === "number")
{
this.content.Set_StartPage(old_start_page);
}
// this.content.Draw(this.shape.pageIndex, graphics);
}
else
{
graphics.rect(0, 0, this.contentWidth, this.contentHeight);
}
},
Get_Styles: function(level)
{
if(this.shape && typeof this.shape.getStyles === "function")
return this.shape.getStyles();
return editor.WordControl.m_oLogicDocument.Get_Styles();
},
Get_Numbering: function()
{
return new CNumbering();
},
isEmpty: function()
{
return this.content.Is_Empty();
},
Get_TableStyleForPara: function()
{
return null;
},
initFromString: function(str)
{
for(var key in str)
{
this.content.Paragraph_Add(new ParaText(str[key]), false);
}
},
Is_ThisElementCurrent: function()
{
return false;
},
getColorMap: function()
{
return this.shape.getColorMap();
},
getTheme: function()
{
return this.shape.getTheme();
},
paragraphAdd: function(paraItem, noRecalc)
{
this.content.Paragraph_Add(paraItem);
if(!(noRecalc === true))
this.content.Recalculate_Page(0, true );
this.content.RecalculateCurPos();
if(this.bodyPr.anchor !== VERTICAL_ANCHOR_TYPE_TOP)
{
this.shape.calculateTransformTextMatrix();
}
},
addNewParagraph: function()
{
this.content.Add_NewParagraph();
this.content.Recalculate_Page(0, true );
this.content.RecalculateCurPos();
if(this.bodyPr.anchor !== VERTICAL_ANCHOR_TYPE_TOP)
{
this.shape.calculateTransformTextMatrix();
}
},
remove: function(direction, bOnlyText)
{
this.content.Remove(direction, bOnlyText);
this.content.Recalculate_Page(0, true );
this.content.RecalculateCurPos();
if(this.bodyPr.anchor !== VERTICAL_ANCHOR_TYPE_TOP)
{
this.shape.calculateTransformTextMatrix();
}
},
OnContentRecalculate: function()
{
if(isRealObject(this.shape) && typeof this.shape.OnContentRecalculate === "function")
this.shape.OnContentRecalculate();
},
recalculate: function()
{
},
getSummaryHeight: function()
{
return this.content.Get_SummaryHeight();
},
getBodyPr: function()
{
var res = new CBodyPr();
res.setDefault();
res.merge(this.bodyPr);
return res;
},
OnContentReDraw: function()
{
if(isRealObject(this.shape))
this.shape.OnContentReDraw();
},
calculateContent: function()
{
var _l, _t, _r, _b;
var _body_pr = this.getBodyPr();
var sp = this.shape;
if(isRealObject(sp.spPr.geometry) && isRealObject(sp.spPr.geometry.rect))
{
var _rect = sp.spPr.geometry.rect;
_l = _rect.l + _body_pr.lIns;
_t = _rect.t + _body_pr.tIns;
_r = _rect.r - _body_pr.rIns;
_b = _rect.b - _body_pr.bIns;
}
else
{
_l = _body_pr.lIns;
_t = _body_pr.tIns;
_r = sp.extX - _body_pr.rIns;
_b = sp.extY - _body_pr.bIns;
}
if(_body_pr.upright === false)
{
var _content_width;
if(!(_body_pr.vert === nVertTTvert || _body_pr.vert === nVertTTvert270))
{
_content_width = _r - _l;
this.contentWidth = _content_width;
this.contentHeight = _b - _t;
}
else
{
_content_width = _b - _t;
this.contentWidth = _content_width;
this.contentHeight = _r - _l;
}
}
else
{
var _full_rotate = sp.getFullRotate();
if((_full_rotate >= 0 && _full_rotate < Math.PI*0.25)
|| (_full_rotate > 3*Math.PI*0.25 && _full_rotate < 5*Math.PI*0.25)
|| (_full_rotate > 7*Math.PI*0.25 && _full_rotate < 2*Math.PI))
{
if(!(_body_pr.vert === nVertTTvert || _body_pr.vert === nVertTTvert270))
{
_content_width = _r - _l;
this.contentWidth = _content_width;
this.contentHeight = _b - _t;
}
else
{
_content_width = _b - _t;
this.contentWidth = _content_width;
this.contentHeight = _r - _l;
}
}
else
{
if(!(_body_pr.vert === nVertTTvert || _body_pr.vert === nVertTTvert270))
{
_content_width = _b - _t;
this.contentWidth = _content_width;
this.contentHeight = _r - _l;
}
else
{
_content_width = _r - _l;
this.contentWidth = _content_width;
this.contentHeight = _b - _t;
}
}
}
this.content.Reset(0, 0, _content_width, 20000);
this.content.Recalculate_Page(0, true );
},
OnEndRecalculate_Page: function()
{},
Is_Cell: function()
{
return false;
},
Get_StartPage_Absolute: function()
{
return 0;
},
selectionSetStart: function(e, x, y)
{
this.content.Selection_SetStart(x, y, 0, e);
},
selectionSetEnd: function(e, x, y)
{
this.content.Selection_SetEnd(x, y, 0, e);
},
updateSelectionState: function()
{
var Doc = this.content;
var DrawingDocument = editor.WordControl.m_oDrawingDocument;
if ( true === Doc.Is_SelectionUse() && !Doc.Selection_IsEmpty()) {
DrawingDocument.UpdateTargetTransform(this.shape.transformText);
DrawingDocument.TargetEnd();
DrawingDocument.SelectEnabled(true);
DrawingDocument.SelectClear();
DrawingDocument.SelectShow();
}
else
{
editor.WordControl.m_oLogicDocument.RecalculateCurPos();
DrawingDocument.UpdateTargetTransform(this.shape.transformText);
DrawingDocument.TargetShow();
DrawingDocument.SelectEnabled(false);
}
},
Get_PageContentStartPos: function(pageNum)
{
return {X: 0, Y: 0, XLimit: this.contentWidth, YLimit: 20000};
},
setVerticalAlign: function(align)
{
var anchor_num = null;
switch(align)
{
case "top":
{
anchor_num = VERTICAL_ANCHOR_TYPE_TOP;
break;
}
case "center":
{
anchor_num = VERTICAL_ANCHOR_TYPE_CENTER;
break;
}
case "bottom":
{
anchor_num = VERTICAL_ANCHOR_TYPE_BOTTOM;
break;
}
}
if(isRealNumber(anchor_num))
{
this.bodyPr.anchor = anchor_num;
}
},
setVert: function(angle)
{
var vert = null;
switch (angle)
{
case 0:
{
vert = nVertTThorz;
break;
}
case 90:
{
vert = nVertTTvert270;
break;
}
case -90:
{
vert = nVertTTvert;
break;
}
}
if(isRealNumber(vert))
{
this.bodyPr.vert = vert;
}
},
setTopInset: function(ins)
{
if(isRealNumber(ins))
{
this.bodyPr.tIns = ins;
}
},
setRightInset: function(ins)
{
if(isRealNumber(ins))
{
this.bodyPr.rIns = ins;
}
},
setLeftInset: function(ins)
{
if(isRealNumber(ins))
{
this.bodyPr.lIns = ins;
}
},
setBottomInset: function(ins)
{
if(isRealNumber(ins))
{
this.bodyPr.bIns = ins;
}
},
setPaddings: function(paddings)
{
if(isRealObject(paddings))
{
this.setBottomInset(paddings.Bottom);
this.setTopInset(paddings.Top);
this.setLeftInset(paddings.Left);
this.setRightInset(paddings.Right);
}
},
recalculateCurPos: function()
{
this.content.RecalculateCurPos();
},
drawTextSelection: function()
{
this.content.Selection_Draw_Page(0);
},
getRectWidth: function(maxWidth)
{
try
{
var body_pr = this.getBodyPr();
var r_ins = body_pr.rIns;
var l_ins = body_pr.lIns;
var max_content_width = maxWidth - r_ins - l_ins;
this.content.Reset(0, 0, max_content_width, 20000);
this.content.Recalculate_Page(0, true);
var max_width = 0;
for(var i = 0; i < this.content.Content.length; ++i)
{
var par = this.content.Content[i];
for(var j = 0; j < par.Lines.length; ++j)
{
if(par.Lines[j].Ranges[0].W > max_width)
{
max_width = par.Lines[j].Ranges[0].W;
}
}
}
return max_width + 2 + r_ins + l_ins;
}
catch(e)
{
return 0;
}
},
getRectHeight: function(maxHeight, width)
{
try
{
this.content.Reset(0, 0, width, 20000);
this.content.Recalculate_Page(0, true);
var content_height = this.getSummaryHeight();
var t_ins = isRealNumber(this.bodyPr.tIns) ? this.bodyPr.tIns : 1.27;
var b_ins = isRealNumber(this.bodyPr.bIns) ? this.bodyPr.bIns : 1.27;
return content_height + t_ins + b_ins;
}
catch(e)
{
return 0;
}
},
Refresh_RecalcData2: function()
{
if(isRealObject(this.content))
{
if(this.shape instanceof CChartTitle )
{
if(this.shape.chartGroup instanceof CChartAsGroup && this.shape.chartGroup.chart)
this.shape.chartGroup.Refresh_RecalcData2();
}
else
this.content.Recalculate_Page(0, true);
}
},
Undo: function(data)
{
switch(data.Type)
{
case historyitem_SetShape:
{
this.shape = data.oldPr;
break;
}
case historyitem_SetDocContent:
{
this.content = data.oldPr;
if(this.content && this.shape instanceof CChartTitle)
{
var is_on = History.Is_On();
if(is_on)
{
History.TurnOff();
}
var styles = new CStyles();
var default_legend_style = new CStyle("defaultLegendStyle", styles.Default, null, styletype_Paragraph);
default_legend_style.TextPr.themeFont = "Calibri";
default_legend_style.TextPr.Bold = true;
if(this.shape.getTitleType() === CHART_TITLE_TYPE_TITLE)
default_legend_style.TextPr.FontSize = 18;
else
default_legend_style.TextPr.FontSize = 10;
default_legend_style.ParaPr.Spacing.After = 0;
default_legend_style.ParaPr.Spacing.Before = 0;
default_legend_style.ParaPr.Spacing.LineRule = linerule_AtLeast;
default_legend_style.ParaPr.Spacing.Line = 1;
default_legend_style.ParaPr.Jc = align_Center;
//TODO:ParaPr: default_legend_style.ParaPr.Ind
var tx_pr;
if(isRealObject(this.txPr))
{
//TODO
}
styles.Style[styles.Id] = default_legend_style;
this.content.Styles = styles;
if(is_on)
{
History.TurnOn();
}
}
break;
}
case historyitem_SetLstStyle:
{
this.lstStyle = data.oldPr;
break;
}
}
},
Redo: function(data)
{
switch(data.Type)
{
case historyitem_SetShape:
{
this.shape = data.newPr;
break;
}
case historyitem_SetDocContent:
{
this.content = data.newPr;
if(this.content && this.shape instanceof CChartTitle)
{
var is_on = History.Is_On();
if(is_on)
{
History.TurnOff();
}
var styles = new CStyles();
var default_legend_style = new CStyle("defaultLegendStyle", styles.Default, null, styletype_Paragraph);
default_legend_style.TextPr.themeFont = "Calibri";
default_legend_style.TextPr.Bold = true;
if(this.shape.getTitleType() === CHART_TITLE_TYPE_TITLE)
default_legend_style.TextPr.FontSize = 18;
else
default_legend_style.TextPr.FontSize = 10;
default_legend_style.ParaPr.Spacing.After = 0;
default_legend_style.ParaPr.Spacing.Before = 0;
default_legend_style.ParaPr.Spacing.LineRule = linerule_AtLeast;
default_legend_style.ParaPr.Spacing.Line = 1;
default_legend_style.ParaPr.Jc = align_Center;
//TODO:ParaPr: default_legend_style.ParaPr.Ind
var tx_pr;
if(isRealObject(this.txPr))
{
//TODO
}
styles.Style[styles.Id] = default_legend_style;
this.content.Styles = styles;
if(is_on)
{
History.TurnOn();
}
}
break;
}
case historyitem_SetLstStyle:
{
this.lstStyle = data.newPr;
break;
}
}
},
Save_Changes: function(data, w)
{
w.WriteLong(historyitem_type_TextBody);
w.WriteLong(data.Type);
switch(data.Type)
{
case historyitem_SetShape:
case historyitem_SetDocContent:
{
w.WriteBool(isRealObject(data.newPr));
if(isRealObject(data.newPr))
{
w.WriteString2(data.newPr.Get_Id())
}
break;
}
case historyitem_SetLstStyle:
{
w.WriteBool(isRealObject(data.newPr));
if(isRealObject(data.newPr))
{
data.newPr.Write_ToBinary2(w);
}
break;
}
}
},
Load_Changes: function(r)
{
if(r.GetLong() === historyitem_type_TextBody)
{
var type = r.GetLong();
switch(type)
{
case historyitem_SetShape:
{
if(r.GetBool())
{
this.shape = g_oTableId.Get_ById(r.GetString2());
}
else
{
this.shape = null;
}
break;
}
case historyitem_SetDocContent:
{
if(r.GetBool())
{
this.content = g_oTableId.Get_ById(r.GetString2());
}
else
{
this.content = null;
}
if(this.content && this.shape instanceof CChartTitle)
{
var is_on = History.Is_On();
if(is_on)
{
History.TurnOff();
}
var styles = new CStyles();
var default_legend_style = new CStyle("defaultLegendStyle", styles.Default, null, styletype_Paragraph);
default_legend_style.TextPr.themeFont = "Calibri";
default_legend_style.TextPr.Bold = true;
if(this.shape.getTitleType() === CHART_TITLE_TYPE_TITLE)
default_legend_style.TextPr.FontSize = 18;
else
default_legend_style.TextPr.FontSize = 10;
default_legend_style.ParaPr.Spacing.After = 0;
default_legend_style.ParaPr.Spacing.Before = 0;
default_legend_style.ParaPr.Spacing.LineRule = linerule_AtLeast;
default_legend_style.ParaPr.Spacing.Line = 1;
default_legend_style.ParaPr.Jc = align_Center;
//TODO:ParaPr: default_legend_style.ParaPr.Ind
var tx_pr;
if(isRealObject(this.txPr))
{
//TODO
}
styles.Style[styles.Id] = default_legend_style;
this.content.Styles = styles;
if(is_on)
{
History.TurnOn();
}
}
break;
}
case historyitem_SetLstStyle:
{
if(r.GetBool())
{
this.lstStyle = new TextListStyle();
this.lstStyle.Read_FromBinary2(r);
}
else
{
this.lstStyle = null;
}
break;
}
}
}
},
writeToBinaryForCopyPaste: function(w)
{
this.bodyPr.Write_ToBinary2(w);
},
readFromBinaryForCopyPaste: function(r, drawingDocument)
{
this.bodyPr.Read_FromBinary2(r);
this.content = new CDocumentContent(this, drawingDocument, 0, 0, 0, 20000, false, false);
},
writeToBinary: function(w)
{
this.bodyPr.Write_ToBinary2(w);
writeToBinaryDocContent(this.content, w);
},
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 i = 0; i < par.Content.length; ++i)
{
if(!(par.Content[i] instanceof ParaEnd || par.Content[i] instanceof ParaEmpty || par.Content[i] instanceof ParaNumbering) && par.Content[i].Copy)
this.content.Paragraph_Add(par.Content[i].Copy());
}
}
},
getDocContentForCopyPaste: function()
{
var history_is_on = History.Is_On();
if(history_is_on)
History.TurnOff();
var ret = this.content.Copy(this);
ret.Styles = this.content.Styles;
ret.Recalculate_Page(0, true);
ret.CurPos = this.content.CurPos;
ret.Selection = this.content.Selection;
for(var i = 0; i < ret.Content.length; ++i)
{
var text_pr = ret.Content[i].Get_CompiledPr2().TextPr;
ret.Content[i].Style_Remove();
var start_pos = ret.Content[i].Internal_GetStartPos();
ret.Content[i].Internal_Content_Add(start_pos, new ParaTextPr(text_pr), true);
ret.Content[i].CurPos = this.content.Content[i].CurPos;
ret.Content[i].Selection = this.content.Content[i].Selection;
}
if(history_is_on)
History.TurnOn();
return ret;
},
copyFromOther: function(txBody)
{
if(isRealObject(this.parent) && this.parent.setBodyPr)
{
this.parent.setBodyPr(this.bodyPr.createDuplicate());
}
for(var i = 0; i < txBody.content.Content.length; ++i)
{
if(i > 0)
{
this.content.Add_NewParagraph()
}
var par = txBody.content.Content[i];
for(var i = 0; i < par.Content.length; ++i)
{
if(!(par.Content[i] instanceof ParaEnd || par.Content[i] instanceof ParaEmpty || par.Content[i] instanceof ParaNumbering) && par.Content[i].Copy)
this.content.Paragraph_Add(par.Content[i].Copy());
}
}
for(var i = 0; i < this.content.Content.length; ++i)
{
this.content.Content[i].Set_DocumentIndex(i);
}
}
};
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
function PolyLine (document, pageIndex)
{
this.document = document;
this.pageIndex = pageIndex;
this.arrPoint = [];
this.Matrix = new CMatrixL();
this.TransformMatrix = new CMatrixL();
this.style = CreateDefaultShapeStyle();
this.calculateLine = function()
{
var _calculated_line;
var _theme = this.document.theme;
var colorMap = this.document.clrSchemeMap.color_map;
if(colorMap==null)
colorMap = GenerateDefaultColorMap().color_map;
var RGBA = {R: 0, G: 0, B: 0, A: 255};
if(_theme !== null && typeof _theme === "object" && typeof _theme.getLnStyle === "function"
&& this.style !== null && typeof this.style === "object"
&& this.style.lnRef !== null && typeof this.style.lnRef === "object" && typeof this.style.lnRef.idx === "number"
&& this.style.lnRef.Color !== null && typeof this.style.lnRef.Color.Calculate === "function")
{
_calculated_line = _theme.getLnStyle(this.style.lnRef.idx);
this.style.lnRef.Color.Calculate(_theme, colorMap, {R: 0 , G: 0, B: 0, A: 255});
RGBA = this.style.lnRef.Color.RGBA;
}
else
{
_calculated_line = new CLn();
}
if(_calculated_line.Fill!=null)
{
_calculated_line.Fill.calculate(_theme, colorMap, RGBA) ;
}
this.pen = _calculated_line;
};
this.calculateLine();
this.Draw = function(graphics)
{
graphics.SetIntegerGrid(false);
graphics.transform3(this.Matrix);
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape(this, graphics);
shape_drawer.draw(this);
};
this.draw = function(g)
{
if(this.arrPoint.length < 2)
{
return;
}
g._m(this.arrPoint[0].x, this.arrPoint[0].y);
for(var i = 1; i < this.arrPoint.length; ++i)
{
g._l(this.arrPoint[i].x, this.arrPoint[i].y);
}
g.ds();
};
this.getLeftTopPoint = function()
{
if(this.arrPoint.length < 1)
return {x: 0, y: 0};
var xMax = this.arrPoint[0].x, yMax = this.arrPoint[0].y, xMin = xMax, yMin = yMax;
var i;
for( i = 1; i<this.arrPoint.length; ++i)
{
if(this.arrPoint[i].x > xMax)
{
xMax = this.arrPoint[i].x;
}
if(this.arrPoint[i].y > yMax)
{
yMax = this.arrPoint[i].y;
}
if(this.arrPoint[i].x < xMin)
{
xMin = this.arrPoint[i].x;
}
if(this.arrPoint[i].y < yMin)
{
yMin = this.arrPoint[i].y;
}
}
return {x: xMin, y: yMin};
};
this.createShape = function(document)
{
var xMax = this.arrPoint[0].x, yMax = this.arrPoint[0].y, xMin = xMax, yMin = yMax;
var i;
var bClosed = false;
if(this.arrPoint.length > 2)
{
var dx = this.arrPoint[0].x - this.arrPoint[this.arrPoint.length-1].x;
var dy = this.arrPoint[0].y - this.arrPoint[this.arrPoint.length-1].y;
if(Math.sqrt(dx*dx +dy*dy) < this.document.DrawingDocument.GetMMPerDot(3))
{
bClosed = true;
}
}
var _n = bClosed ? this.arrPoint.length - 1 : this.arrPoint.length;
for( i = 1; i<_n; ++i)
{
if(this.arrPoint[i].x > xMax)
{
xMax = this.arrPoint[i].x;
}
if(this.arrPoint[i].y > yMax)
{
yMax = this.arrPoint[i].y;
}
if(this.arrPoint[i].x < xMin)
{
xMin = this.arrPoint[i].x;
}
if(this.arrPoint[i].y < yMin)
{
yMin = this.arrPoint[i].y;
}
}
var wordGraphicObject = new ParaDrawing(null, null, null, document.DrawingDocument, null, document);
var wordShape = new WordShape(wordGraphicObject, document, document.DrawingDocument, null);
/*W, H, GraphicObj, Drawing*/
wordGraphicObject.Set_GraphicObject(wordShape);
wordShape.pageIndex = this.pageIndex;
wordShape.setAbsoluteTransform(xMin, yMin, xMax-xMin, yMax-yMin, 0, false, false);
wordShape.setXfrm(0, 0, xMax-xMin, yMax-yMin, 0, false, false);
wordShape.style = CreateDefaultShapeStyle();
var geometry = new CGeometry();
geometry.AddPathCommand(0, undefined, bClosed ? "norm": "none", undefined, xMax - xMin, yMax-yMin);
geometry.AddRect("l", "t", "r", "b");
geometry.AddPathCommand(1, (this.arrPoint[0].x - xMin) + "", (this.arrPoint[0].y - yMin) + "");
for(i = 1; i< _n; ++i)
{
geometry.AddPathCommand(2, (this.arrPoint[i].x - xMin) + "", (this.arrPoint[i].y - yMin) + "");
}
if(bClosed)
{
geometry.AddPathCommand(6);
}
geometry.Init( xMax-xMin, yMax-yMin);
wordShape.spPr.geometry = geometry;
wordShape.calculate();
wordShape.calculateTransformMatrix();
wordGraphicObject.setZIndex();
wordGraphicObject.setPageIndex(this.pageIndex);
var data = {Type:historyitem_CreatePolyine};
data.xMax = xMax;
data.xMin = xMin;
data.yMax = yMax;
data.yMin = yMin;
data.bClosed = bClosed;
data.commands = [];
data.commands.push({id: 1, x: (this.arrPoint[0].x - xMin) + "", y:(this.arrPoint[0].y - yMin) + ""});
for(i = 1; i< _n; ++i)
{
data.commands.push({id: 2, x: (this.arrPoint[i].x - xMin) + "", y:(this.arrPoint[i].y - yMin) + ""});
}
History.Add(wordShape, data);
History.Add(wordGraphicObject, {Type: historyitem_CalculateAfterPaste});
return wordGraphicObject;
}
}
\ No newline at end of file
var K=1/4;
var mt=0, lt=1, cb=2, cl=3;
function SplineCommandMoveTo(x, y)
{
this.id = 0;
this.x = x;
this.y = y;
}
function SplineCommandLineTo(x, y)
{
this.id = 1;
this.x = x;
this.y = y;
this.changePoint = function(x, y)
{
this.x = x;
this.y = y;
}
}
function SplineCommandBezier(x1, y1, x2, y2, x3, y3)
{
this.id = 2;
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
this.x3 = x3;
this.y3 = y3;
this.changeLastPoint = function(x, y)
{
this.x3 = x;
this.y3 = y;
this.x2 = this.x1 + (this.x3 - this.x1)*0.5;
this.y2 = this.y1 + (this.y3 - this.y1)*0.5;
}
}
function Spline(pageIndex, document)
{
this.path = [];
this.pageIndex = pageIndex;
this.document = document;
this.Matrix = new CMatrix();
this.TransformMatrix = new CMatrix();
this.style = CreateDefaultShapeStyle();
this.calculateLine = function()
{
var _calculated_line;
var _theme = this.document.theme;
var colorMap = this.document.clrSchemeMap.color_map;
if(colorMap==null)
colorMap = GenerateDefaultColorMap().color_map;
var RGBA = {R: 0, G: 0, B: 0, A: 255};
if(_theme !== null && typeof _theme === "object" && typeof _theme.getLnStyle === "function"
&& this.style !== null && typeof this.style === "object"
&& this.style.lnRef !== null && typeof this.style.lnRef === "object" && typeof this.style.lnRef.idx === "number"
&& this.style.lnRef.Color !== null && typeof this.style.lnRef.Color.Calculate === "function")
{
_calculated_line = _theme.getLnStyle(this.style.lnRef.idx);
this.style.lnRef.Color.Calculate(_theme, colorMap, {R: 0 , G: 0, B: 0, A: 255});
RGBA = this.style.lnRef.Color.RGBA;
}
else
{
_calculated_line = new CLn();
}
if(_calculated_line.Fill!=null)
{
_calculated_line.Fill.calculate(_theme, colorMap, RGBA) ;
}
this.pen = _calculated_line;
};
this.pen =null;
this.calculateLine();
this.Draw = function(graphics)
{
graphics.SetCurrentPage(this.pageIndex);
graphics.SetIntegerGrid(false);
graphics.transform3(this.Matrix);
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape(this, graphics);
shape_drawer.draw(this);
};
this.draw = function(g)
{
// g.transform3(this.Matrix);
for(var i = 0; i < this.path.length; ++i)
{
var lastX, lastY;
switch (this.path[i].id )
{
case 0 :
{
g._m(this.path[i].x, this.path[i].y);
lastX = this.path[i].x;
lastY = this.path[i].y;
break;
}
case 1 :
{
g._l(this.path[i].x, this.path[i].y);
lastX = this.path[i].x;
lastY = this.path[i].y;
break;
}
case 2 :
{
/*g._l(this.path[i].x1*100, this.path[i].y1*100);
g._l(this.path[i].x2*100, this.path[i].y2*100);
g._l(this.path[i].x3*100, this.path[i].y3*100);
g._m(lastX*100, lastY*100); */
g._c(this.path[i].x1, this.path[i].y1, this.path[i].x2, this.path[i].y2, this.path[i].x3, this.path[i].y3);
lastX = this.path[i].x3;
lastY = this.path[i].y3;
break;
}
}
}
g.ds();
};
this.getLeftTopPoint = function()
{
if(this.path.length < 1)
return {x: 0, y: 0};
var min_x = this.path[0].x;
var max_x = min_x;
var min_y = this.path[0].y;
var max_y = min_y;
var last_x = this.path[0].x, last_y = this.path[0].y;
for(var index = 1; index < this.path.length; ++index)
{
var path_command = this.path[index];
if(path_command.id === 1)
{
if(min_x > path_command.x)
min_x = path_command.x;
if(max_x < path_command.x)
max_x = path_command.x;
if(min_y > path_command.y)
min_y = path_command.y;
if(max_y < path_command.y)
max_y = path_command.y;
}
else
{
var bezier_polygon = partition_bezier4(last_x, last_y, path_command.x1, path_command.y1, path_command.x2, path_command.y2, path_command.x3, path_command.y3, APPROXIMATE_EPSILON);
for(var point_index = 1; point_index < bezier_polygon.length; ++point_index)
{
var cur_point = bezier_polygon[point_index];
if(min_x > cur_point.x)
min_x = cur_point.x;
if(max_x < cur_point.x)
max_x = cur_point.x;
if(min_y > cur_point.y)
min_y = cur_point.y;
if(max_y < cur_point.y)
max_y = cur_point.y;
}
}
}
return {x: min_x, y: min_y};
};
this.createShape = function(document)
{
var xMax = this.path[0].x, yMax = this.path[0].y, xMin = xMax, yMin = yMax;
var i;
var bClosed = false;
if(this.path.length > 2)
{
var dx = this.path[0].x - this.path[this.path.length-1].x3;
var dy = this.path[0].y - this.path[this.path.length-1].y3;
if(Math.sqrt(dx*dx +dy*dy) < 3)
{
bClosed = true;
this.path[this.path.length-1].x3 = this.path[0].x;
this.path[this.path.length-1].y3 = this.path[0].y;
if(this.path.length > 3)
{
var vx = (this.path[1].x3 - this.path[this.path.length-2].x3)/6;
var vy = (this.path[1].y3 - this.path[this.path.length-2].y3)/6;
}
else
{
vx = -(this.path[1].y3 - this.path[0].y)/6;
vy = (this.path[1].x3 - this.path[0].x)/6;
}
this.path[1].x1 = this.path[0].x +vx;
this.path[1].y1 = this.path[0].y +vy;
this.path[this.path.length-1].x2 = this.path[0].x -vx;
this.path[this.path.length-1].y2 = this.path[0].y -vy;
}
}
var min_x = this.path[0].x;
var max_x = min_x;
var min_y = this.path[0].y;
var max_y = min_y;
var last_x = this.path[0].x, last_y = this.path[0].y;
for(var index = 1; index < this.path.length; ++index)
{
var path_command = this.path[index];
if(path_command.id === 1)
{
if(min_x > path_command.x)
min_x = path_command.x;
if(max_x < path_command.x)
max_x = path_command.x;
if(min_y > path_command.y)
min_y = path_command.y;
if(max_y < path_command.y)
max_y = path_command.y;
last_x = path_command.x;
last_y = path_command.y;
}
else
{
var bezier_polygon = partition_bezier4(last_x, last_y, path_command.x1, path_command.y1, path_command.x2, path_command.y2, path_command.x3, path_command.y3, APPROXIMATE_EPSILON);
for(var point_index = 1; point_index < bezier_polygon.length; ++point_index)
{
var cur_point = bezier_polygon[point_index];
if(min_x > cur_point.x)
min_x = cur_point.x;
if(max_x < cur_point.x)
max_x = cur_point.x;
if(min_y > cur_point.y)
min_y = cur_point.y;
if(max_y < cur_point.y)
max_y = cur_point.y;
last_x = path_command.x3;
last_y = path_command.y3;
}
}
}
/*for( i = 1; i<this.path.length; ++i)
{
if(this.path[i].id == 1)
{
if(this.path[i].x > xMax)
{
xMax = this.path[i].x;
}
if(this.path[i].y > yMax)
{
yMax = this.path[i].y;
}
if(this.path[i].x < xMin)
{
xMin = this.path[i].x;
}
if(this.path[i].y < yMin)
{
yMin = this.path[i].y;
}
}
else
{
if(this.path[i].x1 > xMax)
{
xMax = this.path[i].x1;
}
if(this.path[i].y1 > yMax)
{
yMax = this.path[i].y1;
}
if(this.path[i].x1 < xMin)
{
xMin = this.path[i].x1;
}
if(this.path[i].y1 < yMin)
{
yMin = this.path[i].y1;
}
if(this.path[i].x2 > xMax)
{
xMax = this.path[i].x2;
}
if(this.path[i].y2 > yMax)
{
yMax = this.path[i].y2;
}
if(this.path[i].x2 < xMin)
{
xMin = this.path[i].x2;
}
if(this.path[i].y2 < yMin)
{
yMin = this.path[i].y2;
}
if(this.path[i].x3 > xMax)
{
xMax = this.path[i].x3;
}
if(this.path[i].y3 > yMax)
{
yMax = this.path[i].y3;
}
if(this.path[i].x3 < xMin)
{
xMin = this.path[i].x3;
}
if(this.path[i].y3 < yMin)
{
yMin = this.path[i].y3;
}
}
} */
xMin = min_x;
xMax = max_x;
yMin = min_y;
yMax = max_y;
var wordGraphicObject = new ParaDrawing(null, null, null, document.DrawingDocument, null, document);
var wordShape = new WordShape(wordGraphicObject, document, document.DrawingDocument, null);
/*W, H, GraphicObj, Drawing*/
wordGraphicObject.Set_GraphicObject(wordShape);
wordShape.pageIndex = this.pageIndex;
wordShape.setAbsoluteTransform(xMin, yMin, xMax-xMin, yMax-yMin, 0, false, false);
wordShape.setXfrm(0, 0, xMax-xMin, yMax-yMin, 0, false, false);
wordShape.style = CreateDefaultShapeStyle();
var geometry = new CGeometry();
geometry.AddPathCommand(0, undefined, bClosed ? "norm": "none", undefined, xMax - xMin, yMax-yMin);
geometry.AddRect("l", "t", "r", "b");
for(i = 0; i< this.path.length; ++i)
{
switch (this.path[i].id)
{
case 0 :
{
geometry.AddPathCommand(1, (this.path[i].x - xMin) + "", (this.path[i].y - yMin) + "");
break;
}
case 1 :
{
geometry.AddPathCommand(2, (this.path[i].x - xMin) + "", (this.path[i].y - yMin) + "");
break;
}
case 2:
{
geometry.AddPathCommand(5, (this.path[i].x1 - xMin) + "", (this.path[i].y1 - yMin) + "", (this.path[i].x2 - xMin) + "", (this.path[i].y2 - yMin) + "", (this.path[i].x3 - xMin) + "", (this.path[i].y3 - yMin) + "");
break;
}
}
}
if(bClosed)
{
geometry.AddPathCommand(6);
}
geometry.Init( xMax-xMin, yMax-yMin);
wordShape.spPr.geometry = geometry;
wordShape.calculate();
wordShape.calculateTransformMatrix();
wordGraphicObject.setZIndex();
wordGraphicObject.setPageIndex(this.pageIndex);
var data = {Type:historyitem_CreatePolyine};
data.xMax = xMax;
data.xMin = xMin;
data.yMax = yMax;
data.yMin = yMin;
data.bClosed = bClosed;
data.commands = [];
for(i = 0; i< this.path.length; ++i)
{
switch (this.path[i].id)
{
case 0 :
{
data.commands.push({id: 1, x: (this.path[i].x - xMin) + "", y:(this.path[i].y - yMin) + ""});
break;
}
case 1 :
{
data.commands.push({id: 2, x: (this.path[i].x - xMin) + "", y:(this.path[i].y - yMin) + ""});
break;
}
case 2:
{
data.commands.push({id: 5, x0: (this.path[i].x1 - xMin) + "", y0: (this.path[i].y1 - yMin) + "", x1:(this.path[i].x2 - xMin) + "", y1:(this.path[i].y2 - yMin) + "", x2:(this.path[i].x3 - xMin) + "", y2:(this.path[i].y3 - yMin) + ""});
break;
}
}
}
History.Add(wordShape, data);
History.Add(wordGraphicObject, {Type: historyitem_CalculateAfterPaste});
return wordGraphicObject;
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment