Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sdkjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
sdkjs
Commits
c847d995
Commit
c847d995
authored
Jul 19, 2017
by
Oleg Korshul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
watermark full support
parent
97651510
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
44 deletions
+72
-44
common/apiBase.js
common/apiBase.js
+7
-0
common/apiCommon.js
common/apiCommon.js
+56
-44
word/Drawing/DrawingDocument.js
word/Drawing/DrawingDocument.js
+3
-0
word/Drawing/HtmlPage.js
word/Drawing/HtmlPage.js
+6
-0
No files found.
common/apiBase.js
View file @
c847d995
...
...
@@ -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
)
...
...
common/apiCommon.js
View file @
c847d995
...
...
@@ -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
);
word/Drawing/DrawingDocument.js
View file @
c847d995
...
...
@@ -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));
...
...
word/Drawing/HtmlPage.js
View file @
c847d995
...
...
@@ -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
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment