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
6b15d21a
Commit
6b15d21a
authored
May 24, 2017
by
Oleg Korshul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
e5fd50c3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
4 deletions
+91
-4
common/Overlay.js
common/Overlay.js
+70
-0
common/editorscommon.js
common/editorscommon.js
+21
-4
No files found.
common/Overlay.js
View file @
6b15d21a
...
...
@@ -2617,10 +2617,80 @@ CAutoshapeTrack.prototype =
}
};
function
DrawTextByCenter
()
// this!
{
var
shape
=
new
AscFormat
.
CShape
();
shape
.
setTxBody
(
AscFormat
.
CreateTextBodyFromString
(
""
,
this
,
shape
));
var
par
=
shape
.
txBody
.
content
.
Content
[
0
];
par
.
Reset
(
0
,
0
,
1000
,
1000
,
0
);
par
.
MoveCursorToStartPos
();
var
_paraPr
=
new
CParaPr
();
par
.
Pr
=
_paraPr
;
var
_textPr
=
new
CTextPr
();
_textPr
.
FontFamily
=
{
Name
:
this
.
Font
,
Index
:
-
1
};
_textPr
.
RFonts
.
Ascii
=
{
Name
:
this
.
Font
,
Index
:
-
1
};
_textPr
.
RFonts
.
EastAsia
=
{
Name
:
this
.
Font
,
Index
:
-
1
};
_textPr
.
RFonts
.
CS
=
{
Name
:
this
.
Font
,
Index
:
-
1
};
_textPr
.
RFonts
.
HAnsi
=
{
Name
:
this
.
Font
,
Index
:
-
1
};
_textPr
.
Bold
=
this
.
Bold
;
_textPr
.
Italic
=
this
.
Italic
;
_textPr
.
FontSize
=
this
.
Size
;
_textPr
.
FontSizeCS
=
this
.
Size
;
var
parRun
=
new
ParaRun
(
par
);
var
Pos
=
0
;
parRun
.
Set_Pr
(
_textPr
);
var
_len
=
this
.
Text
.
length
;
for
(
var
i
=
0
;
i
<
_len
;
i
++
)
{
if
(
this
.
Text
.
charAt
(
i
)
==
"
"
)
parRun
.
Add_ToContent
(
Pos
++
,
new
ParaSpace
(
1
),
false
);
else
parRun
.
Add_ToContent
(
Pos
++
,
new
ParaText
(
this
.
Text
.
charAt
(
i
)),
false
);
}
par
.
Add_ToContent
(
0
,
parRun
);
par
.
Recalculate_Page
(
0
);
par
.
Recalculate_Page
(
0
);
var
baseLineOffset
=
par
.
Lines
[
0
].
Y
;
var
_bounds
=
par
.
Get_PageBounds
(
0
);
var
ctx
=
this
.
Canvas
.
getContext
(
'
2d
'
);
var
_wPx
=
this
.
Canvas
.
width
;
var
_hPx
=
this
.
Canvas
.
height
;
var
_wMm
=
_wPx
*
g_dKoef_pix_to_mm
;
var
_hMm
=
_hPx
*
g_dKoef_pix_to_mm
;
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
_pxBoundsH
=
(
_bounds
.
Bottom
-
_bounds
.
Top
)
*
g_dKoef_mm_to_pix
;
var
_yOffset
=
(
_hPx
-
_pxBoundsH
)
>>
1
;
var
_xOffset
=
(
_wPx
-
_pxBoundsW
)
>>
1
;
var
graphics
=
new
AscCommon
.
CGraphics
();
graphics
.
init
(
ctx
,
_wPx
,
_hPx
,
_wMm
,
_hMm
);
graphics
.
m_oFontManager
=
AscCommon
.
g_fontManager
;
graphics
.
m_oCoordTransform
.
tx
=
_xOffset
;
graphics
.
m_oCoordTransform
.
ty
=
_yOffset
;
graphics
.
transform
(
1
,
0
,
0
,
1
,
0
,
0
);
par
.
Draw
(
0
,
graphics
);
}
//--------------------------------------------------------export----------------------------------------------------
window
[
'
AscCommon
'
]
=
window
[
'
AscCommon
'
]
||
{};
window
[
'
AscCommon
'
].
TRACK_CIRCLE_RADIUS
=
TRACK_CIRCLE_RADIUS
;
window
[
'
AscCommon
'
].
TRACK_DISTANCE_ROTATE
=
TRACK_DISTANCE_ROTATE
;
window
[
'
AscCommon
'
].
COverlay
=
COverlay
;
window
[
'
AscCommon
'
].
CAutoshapeTrack
=
CAutoshapeTrack
;
window
[
'
AscCommon
'
].
DrawTextByCenter
=
DrawTextByCenter
;
})(
window
);
common/editorscommon.js
View file @
6b15d21a
...
...
@@ -2870,10 +2870,27 @@
this
.
Image
=
""
;
this
.
ImageHtml
=
null
;
var
_w
=
_drawer
.
Canvas
.
width
;
var
_h
=
_drawer
.
Canvas
.
heigth
;
var
_ctx
=
_drawer
.
Canvas
.
getContext
(
"
2d
"
);
_ctx
.
clearRect
(
0
,
0
,
w
,
h
);
this
.
Text
=
text
;
this
.
Font
=
font
;
this
.
Size
=
size
;
this
.
Italic
=
isItalic
;
this
.
Bold
=
isBold
;
var
loader
=
AscCommon
.
g_font_loader
;
var
fontinfo
=
AscFonts
.
g_fontApplication
.
GetFontInfo
(
font
);
var
isasync
=
loader
.
LoadFont
(
fontinfo
,
function
()
{
window
.
Asc
.
g_signature_drawer
.
drawText
();
});
if
(
false
===
isasync
)
{
this
.
drawText
();
}
};
CSignatureDrawer
.
prototype
.
drawText
=
function
()
{
AscFormat
.
ExecuteNoHistory
(
AscCommon
.
DrawTextByCenter
,
this
,
[]);
};
CSignatureDrawer
.
prototype
.
selectImage
=
CSignatureDrawer
.
prototype
[
"
selectImage
"
]
=
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