Commit 2bdd99a4 authored by SergeyLuzyanin's avatar SergeyLuzyanin

privateGenerateShape

parent f1852a86
...@@ -3238,89 +3238,132 @@ ...@@ -3238,89 +3238,132 @@
context.drawImage(this.image, x, y); context.drawImage(this.image, x, y);
}; };
this.privateGetShape = function(obj) this.privateGenerateShape = function(obj)
{ {
AscFormat.ExecuteNoHistory(function(obj) {
var oShape = new AscFormat.CShape(); var oShape = new AscFormat.CShape();
var oParent = null, oWorkSheet = null; var bWord = false;
var bWord = true; var oApi = Asc['editor'] || editor;
if (Asc['editor'] && AscCommon.c_oEditorId.Spreadsheet === Asc['editor'].getEditorId()) if(!oApi){
{ return null;
var api_sheet = Asc['editor'];
oShape.setWorksheet(api_sheet.wb.getWorksheet().model);
oWorkSheet = api_sheet.wb.getWorksheet().model;
bWord = false;
} }
else switch(oApi.getEditorId()){
{ case AscCommon.c_oEditorId.Word:{
if (editor && editor.WordControl && Array.isArray(editor.WordControl.m_oLogicDocument.Slides)) oShape.setWordShape(true);
{ bWord = true;
if (editor.WordControl.m_oLogicDocument.Slides[editor.WordControl.m_oLogicDocument.CurPage]) break;
{
oShape.setParent(editor.WordControl.m_oLogicDocument.Slides[editor.WordControl.m_oLogicDocument.CurPage]);
oParent = editor.WordControl.m_oLogicDocument.Slides[editor.WordControl.m_oLogicDocument.CurPage];
bWord = false;
} }
else case AscCommon.c_oEditorId.Presentation:{
{ oShape.setWordShape(false);
return null; oShape.setParent(oApi.WordControl.m_oLogicDocument.Slides[oApi.WordControl.m_oLogicDocument.CurPage]);
break;
} }
case AscCommon.c_oEditorId.Spreadsheet:{
oShape.setWordShape(false);
oShape.setWorksheet(oApi.wb.getWorksheet().model);
break;
} }
} }
var oParentObjects = oShape.getParentObjects(); oShape.setBDeleted(false);
var oTrack = new AscFormat.NewShapeTrack("textRect", 0, 0, oParentObjects.theme, oParentObjects.master, oParentObjects.layout, oParentObjects.slide, 0); oShape.spPr = new AscFormat.CSpPr();
oTrack.track({}, this.shapeW, this.shapeH); oShape.spPr.setParent(oShape);
oShape = oTrack.getShape(bWord, oShape.getDrawingDocument(), oShape.drawingObjects); oShape.spPr.setXfrm(new AscFormat.CXfrm());
oShape.spPr.xfrm.setParent(oShape.spPr);
oShape.setStyle(null); oShape.spPr.xfrm.setOffX(0);
oShape.spPr.setFill(AscFormat.CreateUnfilFromRGB(255, 0, 0)); oShape.spPr.xfrm.setOffY(0);
var oBodypr = oShape.getBodyPr().createDuplicate(); oShape.spPr.xfrm.setExtX(obj['width']);
oBodypr.lIns = 0; oShape.spPr.xfrm.setExtY(obj['height']);
oBodypr.tIns = 0; oShape.spPr.xfrm.setRot(AscFormat.normalizeRotate(obj['rotate'] ? obj['rotate']*60000 : 0));
oBodypr.rIns = 0; oShape.spPr.setGeometry(AscFormat.CreateGeometry(obj['type']));
oBodypr.bIns = 0; if(obj['fill'] && obj['fill'].length === 3){
oBodypr.anchor = 1; oShape.spPr.setFill(AscFormat.CreteSolidFillRGB(obj['fill'][0], obj['fill'][1], obj['fill'][2]));
if(!bWord) }
{ if(AscFormat.isRealNumber(obj['stroke-width']) || Array.isArray(obj['stroke']) && obj['stroke'].length === 3){
oShape.txBody.setBodyPr(oBodypr); var oUnifill;
} if(Array.isArray(obj['stroke']) && obj['stroke'].length === 3){
else oUnifill = AscFormat.CreteSolidFillRGB(obj['stroke'][0], obj['stroke'][1], obj['stroke'][2]);
{
oShape.setBodyPr(oBodypr);
} }
oShape.spPr.setLn(AscFormat.CreatePenFromParams(CreateNoFillUniFill(), null, null, null, 2, null)); else{
if(oWorkSheet) oUnifill = AscFormat.CreteSolidFillRGB(0, 0, 0);
{
oShape.setWorksheet(oWorkSheet);
} }
if(oParent) oShape.spPr.setLn(AscFormat.CreatePenFromParams(oUnifill, undefined, undefined, undefined, undefined, AscFormat.isRealNumber(obj['stroke-width']) ? obj['stroke-width'] : 12700.0/36000.0))
{
oShape.setParent(oParent);
} }
oShape.spPr.xfrm.setOffX(0);
oShape.spPr.xfrm.setOffY(0);
oShape.spPr.xfrm.setExtX(this.shapeW);
oShape.spPr.xfrm.setExtY(this.shapeH);
return oShape;
};
this.privateGenerateShape = function(obj) if(bWord){
{ oShape.createTextBoxContent();
AscFormat.ExecuteNoHistory(function(obj) { }
else{
oShape.createTextBody();
}
var align = parseInt(obj['align'], 10);
if(!isNaN(align)){
oShape.setVerticalAlign();
}
var oShape = this.privateGetShape(); if(Array.isArray(obj['margins']) && obj['margins'].length === 4){
oShape.setPaddings({Left: obj['margins'][0], Top: obj['margins'][1], Right: obj['margins'][2], Bottom: obj['margins'][3]});
}
var oContent = oShape.getDocContent(); var oContent = oShape.getDocContent();
var sText = "Oleg"; var aParagraphsS = obj['paragraphs'];
var oParagraph = oContent.Content[0]; for(var i = 0; i < aParagraphsS.length; ++i){
for(var i = 0; i < sText.length; ++i) var oCurParS = aParagraphsS[i];
var oNewParagraph = new Paragraph(oContent.DrawingDocument, oContent);
if(AscFormat.isRealNumber(oCurParS['align'])){
oNewParagraph.Set_Align(oCurParS['align'])
}
if(Array.isArray(oCurParS['fill']) && oCurParS['fill'].length === 3){
var oShd = new CDocumentShd();
oShd.Value = Asc.c_oAscShdClear;
oShd.Color.r = oCurParS['fill'][0];
oShd.Color.g = oCurParS['fill'][1];
oShd.Color.b = oCurParS['fill'][2];
oNewParagraph.Set_Shd(oShd, true);
}
if(AscFormat.isRealNumber(oCurParS['linespacing'])){
oNewParagraph.Set_Spacing({Line: oCurParS['linespacing'], LineRule: Asc.linerule_Exact});
}
var aRunsS = oCurParS['runs'];
for(var j = 0; j < aRunsS.length; ++j){
var oRunS = aRunsS[j];
var oRun = new ParaRun(oNewParagraph, false);
if(Array.isArray(oRunS['fill']) && oRunS['fill'].length === 3){
oRun.Set_Unifill(AscFormat.CreteSolidFillRGB(oRunS['fill'][0], oRunS['fill'][1], oRunS['fill'][2]));
}
if(oRunS['font-family']){
oRun.Set_RFonts_Ascii({Name : oRunS['font-family'], Index : -1});
oRun.Set_RFonts_CS({Name : oRunS['font-family'], Index : -1});
oRun.Set_RFonts_EastAsia({Name : oRunS['font-family'], Index : -1});
oRun.Set_RFonts_HAnsi({Name : oRunS['font-family'], Index : -1});
}
if(oRunS['font-size']){
oRun.Set_FontSize(oRunS['font-size']);
}
oRun.Set_Bold(oRunS['bold'] === true);
oRun.Set_Italic(oRunS['italic'] === true);
oRun.Set_Strikeout(oRunS['strikeout'] === true);
oRun.Set_Underline(oRunS['underline'] === true);
var sCustomText = oRunS['text'];
if(sCustomText === "<%br%>"){
oRun.Add_ToContent(0, new ParaNewLine(AscCommonWord.break_Line), false);
}
else{
for (var nIndex = 0, nLen = sCustomText.length; nIndex < nLen; ++nIndex)
{ {
oContent.AddToParagraph(new ParaText(sText[i]), false); var nChar = sCustomText.charAt(nIndex);
if (" " === nChar)
oRun.Add_ToContent(nIndex, new ParaSpace(), true);
else
oRun.Add_ToContent(nIndex, new ParaText(nChar), true);
}
}
oNewParagraph.Internal_Content_Add(i, oRun, false);
}
oContent.Internal_Content_Add(oContent.Content.length, oNewParagraph);
} }
oContent.Set_ApplyToAll(true);
oContent.AddToParagraph(new ParaTextPr({FontSize: 20, RFonts: {Ascii : {Name: "Arial", Index: -1}}}));
oContent.SetParagraphAlign(AscCommon.align_Center);
oContent.SetParagraphIndent({FirstLine: 0, Left: 0, Right: 0});
oContent.Set_ApplyToAll(false);
oShape.recalculate(); oShape.recalculate();
if (oShape.bWordShape) if (oShape.bWordShape)
...@@ -3338,7 +3381,7 @@ ...@@ -3338,7 +3381,7 @@
var graphics = new AscCommon.CGraphics(); var graphics = new AscCommon.CGraphics();
graphics.m_oFontManager = AscCommon.g_fontManager; graphics.m_oFontManager = AscCommon.g_fontManager;
graphics.init(this.image.getContext('2d'), this.width, this.height, this.shapeW, this.shapeH); graphics.init(this.image.getContext('2d'), this.width, this.height, oShape.bounds.w, oShape.bounds.h);
graphics.transform(1,0,0,1,0,0); graphics.transform(1,0,0,1,0,0);
oShape.draw(graphics); oShape.draw(graphics);
......
...@@ -297,7 +297,7 @@ CShowPr.prototype.Write_ToBinary = function(w){ ...@@ -297,7 +297,7 @@ CShowPr.prototype.Write_ToBinary = function(w){
w.Seek(nStartPos); w.Seek(nStartPos);
w.WriteLong(Flags); w.WriteLong(Flags);
w.Seek(nEndPos); w.Seek(nEndPos);
} };
CShowPr.prototype.Read_FromBinary = function(r){ CShowPr.prototype.Read_FromBinary = function(r){
var Flags = r.GetLong(); var Flags = r.GetLong();
...@@ -339,7 +339,7 @@ CShowPr.prototype.Read_FromBinary = function(r){ ...@@ -339,7 +339,7 @@ CShowPr.prototype.Read_FromBinary = function(r){
if(Flags & 1024){ if(Flags & 1024){
this.useTimings = r.GetBool(); this.useTimings = r.GetBool();
} }
} };
CShowPr.prototype.Copy = function(){ CShowPr.prototype.Copy = function(){
var oCopy = new CShowPr(); var oCopy = new CShowPr();
...@@ -369,7 +369,8 @@ CShowPr.prototype.Copy = function(){ ...@@ -369,7 +369,8 @@ CShowPr.prototype.Copy = function(){
oCopy.showNarration = this.showNarration; oCopy.showNarration = this.showNarration;
oCopy.useTimings = this.useTimings; oCopy.useTimings = this.useTimings;
return oCopy; return oCopy;
} };
......
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