Commit c847d995 authored by Oleg Korshul's avatar Oleg Korshul

watermark full support

parent 97651510
......@@ -167,6 +167,10 @@
this.signatures = [];
//config['watermark_on_draw'] = window.TEST_WATERMARK_STRING;
this.watermarkDraw = ((config['watermark_on_draw'] !== undefined) && (config['watermark_on_draw'] != "")) ?
new AscCommon.CWatermarkOnDraw(config['watermark_on_draw']) : null;
return this;
}
......@@ -272,6 +276,9 @@
//чтобы в versionHistory был один documentId для auth и open
this.CoAuthoringApi.setDocId(this.documentId);
if (this.watermarkDraw)
this.watermarkDraw.CheckParams(this);
}
if (undefined !== window["AscDesktopEditor"] && offlineMode != this.documentUrl)
......
......@@ -3136,7 +3136,7 @@
return this.Variants;
};
function CWatermarkOnDraw(htmlContent, api)
function CWatermarkOnDraw(htmlContent)
{
// example content:
/*
......@@ -3184,9 +3184,15 @@
this.width = 0;
this.height = 0;
this.transparent = 0.3;
this.zoom = 1;
this.Generate = function(w, h)
this.CheckParams = function(api)
{
this.replaceMap["%user_name%"] = api.User.userName;
};
this.Generate = function()
{
var content = this.inputContentSrc;
for (var key in this.replaceMap)
......@@ -3208,10 +3214,12 @@
}
this.transparent = (undefined == _obj['transparent']) ? 0.3 : _obj['transparent'];
this.privateGenerateShape(_obj);
var _data = this.image.toDataURL("image/png");
console.log(_data);
//var _data = this.image.toDataURL("image/png");
//console.log(_data);
};
this.Draw = function(context, w, h)
......@@ -3219,9 +3227,12 @@
if (!this.image)
return;
var x = (w - this.width) >> 2;
var y = (h - this.height) >> 2;
var x = (w - this.width) >> 1;
var y = (h - this.height) >> 1;
var oldGlobalAlpha = context.globalAlpha;
context.globalAlpha = this.transparent;
context.drawImage(this.image, x, y);
context.globalAlpha = oldGlobalAlpha;
};
this.privateGenerateShape = function(obj)
......@@ -3364,7 +3375,6 @@
editor.ShowParaMarks = false;
}
//
AscCommon.IsShapeToImageConverter = true;
var _bounds_cheker = new AscFormat.CSlideBoundsChecker();
......@@ -3417,46 +3427,46 @@
}, this, [obj]);
};
}
window.TEST_FUNCTION_WATERMARK = function()
{
var _json = "\
window.TEST_WATERMARK_STRING = "\
{\
\"transparent\" : 0.3,\
\"type\" : \"rect\",\
\"width\" : 100,\
\"height\" : 100,\
\"rotate\" : -45,\
\"margins\" : [ 10, 10, 10, 10 ],\
\"fill\" : [255, 0, 0],\
\"stroke-width\" : 1,\
\"stroke\" : [0, 0, 255],\
\"align\" : 1,\
\
\"paragraphs\" : [\
{\
\"type\" : \"rect\",\
\"width\" : 100,\
\"height\" : 100,\
\"rotate\" : -45,\
\"margins\" : [ 10, 10, 10, 10 ],\
\"align\" : 2,\
\"fill\" : [255, 0, 0],\
\"stroke-width\" : 1,\
\"stroke\" : [0, 0, 255],\
\"align\" : 1,\
\"linespacing\" : 0,\
\
\"paragraphs\" : [\
{\
\"align\" : 2,\
\"fill\" : [255, 0, 0],\
\"linespacing\" : 0,\
\
\"runs\" : [\
{\
\"text\" : \"some text\",\
\"fill\" : [0, 255, 0],\
\"font-family\" : \"Arial\",\
\"font-size\" : 24,\
\"bold\" : true,\
\"italic\" : false,\
\"strikeout\" : false,\
\"underline\" : false\
},\
{\
\"text\" : \"<%br%>\"\
}\
]\
}\
]\
}";
var _t = new CWatermarkOnDraw(_json, null);
\"runs\" : [\
{\
\"text\" : \"Do not steal, %user_name%!\",\
\"fill\" : [0, 0, 0],\
\"font-family\" : \"Arial\",\
\"font-size\" : 40,\
\"bold\" : true,\
\"italic\" : false,\
\"strikeout\" : false,\
\"underline\" : false\
},\
{\
\"text\" : \"<%br%>\"\
}\
]\
}\
]\
}";
window.TEST_FUNCTION_WATERMARK = function()
{
var _t = new CWatermarkOnDraw(window.TEST_WATERMARK_STRING, null);
_t.Generate(100, 100);
};
......@@ -4193,4 +4203,6 @@
prot["get_Word"] = prot.get_Word;
prot["get_Checked"] = prot.get_Checked;
prot["get_Variants"] = prot.get_Variants;
window["AscCommon"].CWatermarkOnDraw = CWatermarkOnDraw;
})(window);
......@@ -2553,6 +2553,9 @@ function CDrawingDocument()
context.beginPath();
}
if (this.m_oWordControl.m_oApi.watermarkDraw)
this.m_oWordControl.m_oApi.watermarkDraw.Draw(page.drawingPage.cachedImage.image.ctx, w, h);
//var EndTime = new Date().getTime();
//alert("" + ((EndTime - StartTime) / 1000));
......
......@@ -1001,6 +1001,12 @@ function CEditorPage(api)
if (this.MobileTouchManager)
this.MobileTouchManager.Resize_After();
if (this.m_oApi.watermarkDraw)
{
this.m_oApi.watermarkDraw.zoom = this.m_nZoomValue / 100;
this.m_oApi.watermarkDraw.Generate();
}
};
this.zoom_Out = function()
......
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