Commit 726680eb authored by Oleg Korshul's avatar Oleg Korshul

.

parent d3d5be5b
...@@ -10749,20 +10749,22 @@ function ApplyPresetToChartSpace(oChartSpace, aPreset, bCreate){ ...@@ -10749,20 +10749,22 @@ function ApplyPresetToChartSpace(oChartSpace, aPreset, bCreate){
oXfrm.setOffX(0); oXfrm.setOffX(0);
oXfrm.setOffY(0); oXfrm.setOffY(0);
if(AscFormat.isRealNumber(Width) && AscFormat.isRealNumber(Height)){ if(AscFormat.isRealNumber(Width) && AscFormat.isRealNumber(Height)){
oXfrm.setExtX(1828800/36000); oXfrm.setExtX(Width);
oXfrm.setExtY(1828800/36000); oXfrm.setExtY(Height);
} }
else{ else{
oXfrm.setExtX(Width); oXfrm.setExtX(1828800/36000);
oXfrm.setExtY(Height); oXfrm.setExtY(1828800/36000);
} }
if(typeof sImgUrl === "string" && sImgUrl.length > 0){ if(typeof sImgUrl === "string" && sImgUrl.length > 0){
var oBlipFillUnifill = AscFormat.CreateBlipFillUniFillFromUrl(sImgUrl); var oBlipFillUnifill = AscFormat.CreateBlipFillUniFillFromUrl(sImgUrl);
oSpPr.setFill(oBlipFillUnifill); oSpPr.setFill(oBlipFillUnifill);
} }
else {
oSpPr.setFill(AscFormat.CreateNoFillUniFill());
}
oSpPr.setXfrm(oXfrm); oSpPr.setXfrm(oXfrm);
oXfrm.setParent(oSpPr); oXfrm.setParent(oSpPr);
oSpPr.setFill(AscFormat.CreateNoFillUniFill());
oSpPr.setLn(AscFormat.CreateNoFillLine()); oSpPr.setLn(AscFormat.CreateNoFillLine());
oSpPr.setGeometry(AscFormat.CreateGeometry("rect")); oSpPr.setGeometry(AscFormat.CreateGeometry("rect"));
oShape.setSpPr(oSpPr); oShape.setSpPr(oSpPr);
......
...@@ -438,6 +438,9 @@ ...@@ -438,6 +438,9 @@
this.bIsLoadDocumentImagesNoByOrder = true; this.bIsLoadDocumentImagesNoByOrder = true;
this.nNoByOrderCounter = 0; this.nNoByOrderCounter = 0;
this.loadFontCallBack = null;
this.loadFontCallBackArgs = null;
var oThis = this; var oThis = this;
this.put_Api = function(_api) this.put_Api = function(_api)
...@@ -615,7 +618,40 @@ ...@@ -615,7 +618,40 @@
}; };
//oImage.Image.crossOrigin = 'anonymous'; //oImage.Image.crossOrigin = 'anonymous';
oImage.Image.src = oImage.src; oImage.Image.src = oImage.src;
} };
this.LoadImageWithCallback = function(src, loadFontCallBack, loadFontCallBackArgs)
{
if (this.map_image_index[src])
{
loadFontCallBack.call(this.Api, loadFontCallBackArgs);
return;
}
this.loadFontCallBack = loadFontCallBack;
this.loadFontCallBackArgs = loadFontCallBackArgs;
var oImage = new CImage(src);
oImage.Image = new Image();
oImage.Status = ImageLoadStatus.Loading;
this.map_image_index[oImage.src] = oImage;
oImage.Image.onload = function(){
oImage.Status = ImageLoadStatus.Complete;
oThis.loadFontCallBack.call(oThis.Api, oThis.loadFontCallBackArgs);
oThis.loadFontCallBack = null;
oThis.loadFontCallBackArgs = null;
};
oImage.Image.onerror = function(){
oImage.Image = null;
oImage.Status = ImageLoadStatus.Complete;
oThis.loadFontCallBack.call(oThis.Api, oThis.loadFontCallBackArgs);
oThis.loadFontCallBack = null;
oThis.loadFontCallBackArgs = null;
};
//oImage.Image.crossOrigin = 'anonymous';
oImage.Image.src = oImage.src;
};
} }
var g_flow_anchor = new Image(); var g_flow_anchor = new Image();
......
...@@ -2655,17 +2655,17 @@ CAutoshapeTrack.prototype = ...@@ -2655,17 +2655,17 @@ CAutoshapeTrack.prototype =
par.Recalculate_Page(0); par.Recalculate_Page(0);
par.Recalculate_Page(0); par.Recalculate_Page(0);
var baseLineOffset = par.Lines[0].Y;
var _bounds = par.Get_PageBounds(0); var _bounds = par.Get_PageBounds(0);
var ctx = this.Canvas.getContext('2d'); var _canvas = this.getCanvas();
var _wPx = this.Canvas.width; var _ctx = _canvas.getContext('2d');
var _hPx = this.Canvas.height; var _wPx = _canvas.width;
var _hPx = _canvas.height;
var _wMm = _wPx * g_dKoef_pix_to_mm; var _wMm = _wPx * g_dKoef_pix_to_mm;
var _hMm = _hPx * g_dKoef_pix_to_mm; var _hMm = _hPx * g_dKoef_pix_to_mm;
ctx.clearRect(0, 0, _wPx, _hPx); _ctx.clearRect(0, 0, _wPx, _hPx);
var _pxBoundsW = par.Lines[0].Ranges[0].W * g_dKoef_mm_to_pix;//(_bounds.Right - _bounds.Left) * g_dKoef_mm_to_pix; var _pxBoundsW = par.Lines[0].Ranges[0].W * g_dKoef_mm_to_pix;//(_bounds.Right - _bounds.Left) * g_dKoef_mm_to_pix;
var _pxBoundsH = (_bounds.Bottom - _bounds.Top) * g_dKoef_mm_to_pix; var _pxBoundsH = (_bounds.Bottom - _bounds.Top) * g_dKoef_mm_to_pix;
...@@ -2674,7 +2674,7 @@ CAutoshapeTrack.prototype = ...@@ -2674,7 +2674,7 @@ CAutoshapeTrack.prototype =
var _xOffset = (_wPx - _pxBoundsW) >> 1; var _xOffset = (_wPx - _pxBoundsW) >> 1;
var graphics = new AscCommon.CGraphics(); var graphics = new AscCommon.CGraphics();
graphics.init(ctx, _wPx, _hPx, _wMm, _hMm); graphics.init(_ctx, _wPx, _hPx, _wMm, _hMm);
graphics.m_oFontManager = AscCommon.g_fontManager; graphics.m_oFontManager = AscCommon.g_fontManager;
graphics.m_oCoordTransform.tx = _xOffset; graphics.m_oCoordTransform.tx = _xOffset;
......
...@@ -1266,10 +1266,40 @@ ...@@ -1266,10 +1266,40 @@
// signatures // signatures
baseEditorsApi.prototype.asc_AddSignatureLine2 = function(_obj) baseEditorsApi.prototype.asc_AddSignatureLine2 = function(_obj)
{ {
var _w = 50;
var _h = 50;
var _w_pix = (_w * AscCommon.g_dKoef_mm_to_pix) >> 0;
var _h_pix = (_h * AscCommon.g_dKoef_mm_to_pix) >> 0;
var _canvas = document.createElement("canvas");
_canvas.width = _w_pix;
_canvas.height = _h_pix;
var _ctx = _canvas.getContext("2d");
_ctx.fillStyle = "#000000";
_ctx.strokeStyle = "#000000";
_ctx.font = "10pt 'Courier New'";
_ctx.lineWidth = 3;
_ctx.beginPath();
var _y_line = (_h_pix >> 1) + 0.5;
_ctx.moveTo(0, _y_line);
_ctx.lineTo(_w_pix, _y_line);
_ctx.stroke();
_ctx.beginPath();
_ctx.fillText(_obj.asc_getSigner1(), 10, _y_line + 20);
_ctx.fillText(_obj.asc_getSigner2(), 10, _y_line + 35);
_ctx.fillText(_obj.asc_getEmail(), 10, _y_line + 50);
var _url = _canvas.toDataURL("image/png");
_canvas = null;
function s4() { return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1); } function s4() { return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1); }
function guid() { return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4(); } function guid() { return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4(); }
return this.asc_addSignatureLine(guid(), _obj.asc_getSigner1(), _obj.asc_getSigner2(), _obj.asc_getEmail()); var _args = [guid(), _obj.asc_getSigner1(), _obj.asc_getSigner2(), _obj.asc_getEmail(), _w, _h, _url];
this.ImageLoader.LoadImageWithCallback(_url, function(_args) {
this.asc_addSignatureLine(_args[0], _args[1], _args[2], _args[3], _args[4], _args[5], _args[6]);
}, _args);
}; };
baseEditorsApi.prototype.asc_getRequestSignatures = function() baseEditorsApi.prototype.asc_getRequestSignatures = function()
......
...@@ -2811,7 +2811,7 @@ ...@@ -2811,7 +2811,7 @@
}; };
window.Asc.g_signature_drawer = null; window.Asc.g_signature_drawer = null;
function CSignatureDrawer(id, api) function CSignatureDrawer(id, api, w, h)
{ {
window.Asc.g_signature_drawer = this; window.Asc.g_signature_drawer = this;
...@@ -2843,25 +2843,49 @@ ...@@ -2843,25 +2843,49 @@
this.Size = 10; this.Size = 10;
this.Italic = true; this.Italic = true;
this.Bold = false; this.Bold = false;
this.Width = w;
this.Height = h;
this.CanvasReturn = null;
} }
CSignatureDrawer.prototype.getCanvas = function()
{
return (this.CanvasReturn != null) ? this.Canvas : this.CanvasReturn;
};
CSignatureDrawer.prototype.getImages = function() CSignatureDrawer.prototype.getImages = function()
{ {
if (!this.isValid())
return ["", ""];
this.CanvasReturn = document.createElement("canvas");
this.CanvasReturn.width = (this.Width * AscCommon.g_dKoef_mm_to_pix);
this.CanvasReturn.height = (this.Height * AscCommon.g_dKoef_mm_to_pix);
if (this.Text != "")
this.drawText();
else
this.drawImage();
var _ret = []; var _ret = [];
_ret.push(this.Canvas.toDataURL("image/png")); _ret.push(this.CanvasReturn.toDataURL("image/png"));
var _ctx = this.Canvas.getContext("2d"); var _ctx = this.CanvasReturn.getContext("2d");
_ctx.strokeStyle = "#FF0000"; _ctx.strokeStyle = "#FF0000";
_ctx.lineWidth = 2; _ctx.lineWidth = 2;
_ctx.moveTo(0, 0); _ctx.moveTo(0, 0);
_ctx.lineTo(this.Canvas.width, this.Canvas.height); _ctx.lineTo(this.CanvasReturn.width, this.CanvasReturn.height);
_ctx.moveTo(0, this.Canvas.height); _ctx.moveTo(0, this.CanvasReturn.height);
_ctx.lineTo(this.Canvas.width, 0); _ctx.lineTo(this.CanvasReturn.width, 0);
_ctx.stroke(); _ctx.stroke();
_ret.push(this.Canvas.toDataURL("image/png")); _ret.push(this.CanvasReturn.toDataURL("image/png"));
this.CanvasReturn = null;
return _ret; return _ret;
}; };
...@@ -2893,6 +2917,43 @@ ...@@ -2893,6 +2917,43 @@
AscFormat.ExecuteNoHistory(AscCommon.DrawTextByCenter, this, []); AscFormat.ExecuteNoHistory(AscCommon.DrawTextByCenter, this, []);
}; };
CSignatureDrawer.prototype.drawImage = function()
{
var _canvas = this.getCanvas();
var w = _canvas.width;
var h = _canvas.height;
var _ctx = _canvas.getContext("2d");
_ctx.clearRect(0, 0, w, h);
var im_w = this.ImageHtml.width;
var im_h = this.ImageHtml.height;
var _x = 0;
var _y = 0;
var _w = 0;
var _h = 0;
var koef1 = w / h;
var koef2 = im_w / im_h;
if (koef1 > koef2)
{
_h = h;
_w = (koef2 * _h) >> 0;
_y = 0;
_x = (w - _w) >> 1;
}
else
{
_w = w;
_h = (_w / koef2) >> 0;
_x = 0;
_y = (h - _h) >> 1;
}
_ctx.drawImage(this.ImageHtml, _x, _y, _w, _h);
};
CSignatureDrawer.prototype.selectImage = CSignatureDrawer.prototype["selectImage"] = function() CSignatureDrawer.prototype.selectImage = CSignatureDrawer.prototype["selectImage"] = function()
{ {
this.Text = ""; this.Text = "";
...@@ -2907,13 +2968,7 @@ ...@@ -2907,13 +2968,7 @@
_drawer.ImageHtml = new Image(); _drawer.ImageHtml = new Image();
_drawer.ImageHtml.onload = function() _drawer.ImageHtml.onload = function()
{ {
var _drawer = window.Asc.g_signature_drawer; window.Asc.g_signature_drawer.drawImage();
var w = _drawer.Canvas.width;
var h = _drawer.Canvas.height;
var _ctx = _drawer.Canvas.getContext("2d");
_ctx.clearRect(0, 0, w, h);
_ctx.drawImage(this, 0, 0, w, h);
_drawer = null;
}; };
_drawer.ImageHtml.src = _drawer.Image; _drawer.ImageHtml.src = _drawer.Image;
_drawer = null; _drawer = null;
...@@ -2932,6 +2987,44 @@ ...@@ -2932,6 +2987,44 @@
delete window.Asc.g_signature_drawer; delete window.Asc.g_signature_drawer;
}; };
function CSignatureImage()
{
this.ImageValidBase64 = "";
this.ImageInvalidBase64 = "";
this.ImageValid = null;
this.ImageInvalid = null;
this.Valid = false;
this.Loading = 0;
this.Remove = function()
{
this.ImageValidBase64 = "";
this.ImageInvalidBase64 = "";
this.ImageValid = null;
this.ImageInvalid = null;
this.Valid = false;
this.Loading = 0;
};
this.Register = function(_api, _guid)
{
if (_api.ImageLoader.map_image_index[_guid])
return;
var _obj = { Image : (this.Valid ? this.ImageValid : this.ImageInvalid), Status : ImageLoadStatus.Complete, src : _guid };
_api.ImageLoader.map_image_index[_guid] = _obj;
};
this.Unregister = function(api, _guid)
{
if (_api.ImageLoader.map_image_index[_guid])
delete _api.ImageLoader.map_image_index[_guid];
};
}
//------------------------------------------------------------export--------------------------------------------------- //------------------------------------------------------------export---------------------------------------------------
window['AscCommon'] = window['AscCommon'] || {}; window['AscCommon'] = window['AscCommon'] || {};
window["AscCommon"].getBaseUrl = getBaseUrl; window["AscCommon"].getBaseUrl = getBaseUrl;
...@@ -2989,6 +3082,7 @@ ...@@ -2989,6 +3082,7 @@
window["AscCommon"].parserHelp = parserHelp; window["AscCommon"].parserHelp = parserHelp;
window["AscCommon"].g_oIdCounter = g_oIdCounter; window["AscCommon"].g_oIdCounter = g_oIdCounter;
window["AscCommon"].CDocumentSignatureImages = CDocumentSignatureImages;
window["AscCommon"].CSignatureDrawer = window["AscCommon"]["CSignatureDrawer"] = CSignatureDrawer; window["AscCommon"].CSignatureDrawer = window["AscCommon"]["CSignatureDrawer"] = CSignatureDrawer;
var prot = CSignatureDrawer.prototype; var prot = CSignatureDrawer.prototype;
prot["getImages"] = prot.getImages; prot["getImages"] = prot.getImages;
......
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