Commit 97651510 authored by Oleg Korshul's avatar Oleg Korshul

.

parent 53cd1a45
......@@ -3149,11 +3149,11 @@
"fill" : [255, 0, 0], // [] => none
"stroke-width" : 1, // mm
"stroke" : [0, 0, 255], // [] => none
"align" : "1", // vertical text align (0 - top, 1 - center, 2 - bottom)
"align" : 1, // vertical text align (4 - top, 1 - center, 0 - bottom)
"paragraphs" : [
{
"align" : 4, // horizontal text align [0 - left, 1 - center, 2 - right, 3 - justify]
"align" : 4, // horizontal text align [1 - left, 2 - center, 0 - right, 3 - justify]
"fill" : [255, 0, 0], // paragraph highlight. [] => none
"linespacing" : 0,
......@@ -3183,25 +3183,11 @@
this.image = null;
this.width = 0;
this.height = 0;
this.zoom = 1;
this.shapeW = 100;
this.shapeH = 100;
this.zoom = 1;
this.Generate = function(w, h)
{
this.shapeW = w;
this.shapeH = h;
this.width = AscCommon.AscBrowser.convertToRetinaValue(w * g_dKoef_mm_to_pix * this.zoom, true);
this.height = AscCommon.AscBrowser.convertToRetinaValue(h * g_dKoef_mm_to_pix * this.zoom, true);
if (!this.image)
this.image = document.createElement("canvas");
this.image.width = this.width;
this.image.height = this.height;
var content = this.inputContentSrc;
for (var key in this.replaceMap)
{
......@@ -3275,7 +3261,7 @@
oShape.spPr.xfrm.setOffY(0);
oShape.spPr.xfrm.setExtX(obj['width']);
oShape.spPr.xfrm.setExtY(obj['height']);
oShape.spPr.xfrm.setRot(AscFormat.normalizeRotate(obj['rotate'] ? obj['rotate']*60000 : 0));
oShape.spPr.xfrm.setRot(AscFormat.normalizeRotate(obj['rotate'] ? (obj['rotate'] * Math.PI / 180) : 0));
oShape.spPr.setGeometry(AscFormat.CreateGeometry(obj['type']));
if(obj['fill'] && obj['fill'].length === 3){
oShape.spPr.setFill(AscFormat.CreteSolidFillRGB(obj['fill'][0], obj['fill'][1], obj['fill'][2]));
......@@ -3297,9 +3283,9 @@
else{
oShape.createTextBody();
}
var align = parseInt(obj['align'], 10);
if(!isNaN(align)){
oShape.setVerticalAlign();
var align = obj['align'];
if(undefined != align){
oShape.setVerticalAlign(align);
}
if(Array.isArray(obj['margins']) && obj['margins'].length === 4){
......@@ -3378,13 +3364,50 @@
editor.ShowParaMarks = false;
}
var graphics = new AscCommon.CGraphics();
graphics.m_oFontManager = AscCommon.g_fontManager;
//
AscCommon.IsShapeToImageConverter = true;
var _bounds_cheker = new AscFormat.CSlideBoundsChecker();
var w_mm = 210;
var h_mm = 297;
var w_px = AscCommon.AscBrowser.convertToRetinaValue(w_mm * g_dKoef_mm_to_pix * this.zoom, true);
var h_px = AscCommon.AscBrowser.convertToRetinaValue(h_mm * g_dKoef_mm_to_pix * this.zoom, true);
_bounds_cheker.init(w_px, h_px, w_mm, h_mm);
_bounds_cheker.transform(1,0,0,1,0,0);
_bounds_cheker.AutoCheckLineWidth = true;
_bounds_cheker.CheckLineWidth(oShape);
oShape.draw(_bounds_cheker, 0);
_bounds_cheker.CorrectBounds2();
var _need_pix_width = _bounds_cheker.Bounds.max_x - _bounds_cheker.Bounds.min_x + 1;
var _need_pix_height = _bounds_cheker.Bounds.max_y - _bounds_cheker.Bounds.min_y + 1;
if (_need_pix_width <= 0 || _need_pix_height <= 0)
return;
if (!this.image)
this.image = document.createElement("canvas");
this.image.width = _need_pix_width;
this.image.height = _need_pix_height;
this.width = _need_pix_width;
this.height = _need_pix_height;
var _ctx = this.image.getContext('2d');
var g = new AscCommon.CGraphics();
g.init(_ctx, w_px, h_px, w_mm, h_mm);
g.m_oFontManager = AscCommon.g_fontManager;
g.m_oCoordTransform.tx = -_bounds_cheker.Bounds.min_x;
g.m_oCoordTransform.ty = -_bounds_cheker.Bounds.min_y;
g.transform(1,0,0,1,0,0);
graphics.init(this.image.getContext('2d'), this.width, this.height, oShape.bounds.w, oShape.bounds.h);
graphics.transform(1,0,0,1,0,0);
oShape.draw(g, 0);
oShape.draw(graphics);
AscCommon.IsShapeToImageConverter = false;
if (window.editor)
{
......@@ -3406,18 +3429,18 @@
\"fill\" : [255, 0, 0],\
\"stroke-width\" : 1,\
\"stroke\" : [0, 0, 255],\
\"align\" : \"1\",\
\"align\" : 1,\
\
\"paragraphs\" : [\
{\
\"align\" : 4,\
\"align\" : 2,\
\"fill\" : [255, 0, 0],\
\"linespacing\" : 0,\
\
\"runs\" : [\
{\
\"text\" : \"some text\",\
\"fill\" : [255, 255, 255],\
\"fill\" : [0, 255, 0],\
\"font-family\" : \"Arial\",\
\"font-size\" : 24,\
\"bold\" : true,\
......
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