Commit c847d995 authored by Oleg Korshul's avatar Oleg Korshul

watermark full support

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