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
2bdd99a4
Commit
2bdd99a4
authored
Jul 19, 2017
by
SergeyLuzyanin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
privateGenerateShape
parent
f1852a86
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
125 additions
and
81 deletions
+125
-81
common/apiCommon.js
common/apiCommon.js
+121
-78
slide/Editor/Format/Presentation.js
slide/Editor/Format/Presentation.js
+4
-3
No files found.
common/apiCommon.js
View file @
2bdd99a4
...
...
@@ -3238,89 +3238,132 @@
context
.
drawImage
(
this
.
image
,
x
,
y
);
};
this
.
privateGe
t
Shape
=
function
(
obj
)
this
.
privateGe
nerate
Shape
=
function
(
obj
)
{
AscFormat
.
ExecuteNoHistory
(
function
(
obj
)
{
var
oShape
=
new
AscFormat
.
CShape
();
var
oParent
=
null
,
oWorkSheet
=
null
;
var
bWord
=
true
;
if
(
Asc
[
'
editor
'
]
&&
AscCommon
.
c_oEditorId
.
Spreadsheet
===
Asc
[
'
editor
'
].
getEditorId
())
{
var
api_sheet
=
Asc
[
'
editor
'
];
oShape
.
setWorksheet
(
api_sheet
.
wb
.
getWorksheet
().
model
);
oWorkSheet
=
api_sheet
.
wb
.
getWorksheet
().
model
;
bWord
=
false
;
var
bWord
=
false
;
var
oApi
=
Asc
[
'
editor
'
]
||
editor
;
if
(
!
oApi
){
return
null
;
}
else
{
if
(
editor
&&
editor
.
WordControl
&&
Array
.
isArray
(
editor
.
WordControl
.
m_oLogicDocument
.
Slides
))
{
if
(
editor
.
WordControl
.
m_oLogicDocument
.
Slides
[
editor
.
WordControl
.
m_oLogicDocument
.
CurPage
])
{
oShape
.
setParent
(
editor
.
WordControl
.
m_oLogicDocument
.
Slides
[
editor
.
WordControl
.
m_oLogicDocument
.
CurPage
]);
oParent
=
editor
.
WordControl
.
m_oLogicDocument
.
Slides
[
editor
.
WordControl
.
m_oLogicDocument
.
CurPage
];
bWord
=
false
;
switch
(
oApi
.
getEditorId
()){
case
AscCommon
.
c_oEditorId
.
Word
:{
oShape
.
setWordShape
(
true
);
bWord
=
true
;
break
;
}
else
{
return
null
;
case
AscCommon
.
c_oEditorId
.
Presentation
:{
oShape
.
setWordShape
(
false
);
oShape
.
setParent
(
oApi
.
WordControl
.
m_oLogicDocument
.
Slides
[
oApi
.
WordControl
.
m_oLogicDocument
.
CurPage
]);
break
;
}
case
AscCommon
.
c_oEditorId
.
Spreadsheet
:{
oShape
.
setWordShape
(
false
);
oShape
.
setWorksheet
(
oApi
.
wb
.
getWorksheet
().
model
);
break
;
}
}
var
oParentObjects
=
oShape
.
getParentObjects
();
var
oTrack
=
new
AscFormat
.
NewShapeTrack
(
"
textRect
"
,
0
,
0
,
oParentObjects
.
theme
,
oParentObjects
.
master
,
oParentObjects
.
layout
,
oParentObjects
.
slide
,
0
);
oTrack
.
track
({},
this
.
shapeW
,
this
.
shapeH
);
oShape
=
oTrack
.
getShape
(
bWord
,
oShape
.
getDrawingDocument
(),
oShape
.
drawingObjects
);
oShape
.
setStyle
(
null
);
oShape
.
spPr
.
setFill
(
AscFormat
.
CreateUnfilFromRGB
(
255
,
0
,
0
));
var
oBodypr
=
oShape
.
getBodyPr
().
createDuplicate
();
oBodypr
.
lIns
=
0
;
oBodypr
.
tIns
=
0
;
oBodypr
.
rIns
=
0
;
oBodypr
.
bIns
=
0
;
oBodypr
.
anchor
=
1
;
if
(
!
bWord
)
{
oShape
.
txBody
.
setBodyPr
(
oBodypr
);
}
else
{
oShape
.
setBodyPr
(
oBodypr
);
oShape
.
setBDeleted
(
false
);
oShape
.
spPr
=
new
AscFormat
.
CSpPr
();
oShape
.
spPr
.
setParent
(
oShape
);
oShape
.
spPr
.
setXfrm
(
new
AscFormat
.
CXfrm
());
oShape
.
spPr
.
xfrm
.
setParent
(
oShape
.
spPr
);
oShape
.
spPr
.
xfrm
.
setOffX
(
0
);
oShape
.
spPr
.
xfrm
.
setOffY
(
0
);
oShape
.
spPr
.
xfrm
.
setExtX
(
obj
[
'
width
'
]);
oShape
.
spPr
.
xfrm
.
setExtY
(
obj
[
'
height
'
]);
oShape
.
spPr
.
xfrm
.
setRot
(
AscFormat
.
normalizeRotate
(
obj
[
'
rotate
'
]
?
obj
[
'
rotate
'
]
*
60000
:
0
));
oShape
.
spPr
.
setGeometry
(
AscFormat
.
CreateGeometry
(
obj
[
'
type
'
]));
if
(
obj
[
'
fill
'
]
&&
obj
[
'
fill
'
].
length
===
3
){
oShape
.
spPr
.
setFill
(
AscFormat
.
CreteSolidFillRGB
(
obj
[
'
fill
'
][
0
],
obj
[
'
fill
'
][
1
],
obj
[
'
fill
'
][
2
]));
}
if
(
AscFormat
.
isRealNumber
(
obj
[
'
stroke-width
'
])
||
Array
.
isArray
(
obj
[
'
stroke
'
])
&&
obj
[
'
stroke
'
].
length
===
3
){
var
oUnifill
;
if
(
Array
.
isArray
(
obj
[
'
stroke
'
])
&&
obj
[
'
stroke
'
].
length
===
3
){
oUnifill
=
AscFormat
.
CreteSolidFillRGB
(
obj
[
'
stroke
'
][
0
],
obj
[
'
stroke
'
][
1
],
obj
[
'
stroke
'
][
2
]);
}
oShape
.
spPr
.
setLn
(
AscFormat
.
CreatePenFromParams
(
CreateNoFillUniFill
(),
null
,
null
,
null
,
2
,
null
));
if
(
oWorkSheet
)
{
oShape
.
setWorksheet
(
oWorkSheet
);
else
{
oUnifill
=
AscFormat
.
CreteSolidFillRGB
(
0
,
0
,
0
);
}
if
(
oParent
)
{
oShape
.
setParent
(
oParent
);
oShape
.
spPr
.
setLn
(
AscFormat
.
CreatePenFromParams
(
oUnifill
,
undefined
,
undefined
,
undefined
,
undefined
,
AscFormat
.
isRealNumber
(
obj
[
'
stroke-width
'
])
?
obj
[
'
stroke-width
'
]
:
12700.0
/
36000.0
))
}
oShape
.
spPr
.
xfrm
.
setOffX
(
0
);
oShape
.
spPr
.
xfrm
.
setOffY
(
0
);
oShape
.
spPr
.
xfrm
.
setExtX
(
this
.
shapeW
);
oShape
.
spPr
.
xfrm
.
setExtY
(
this
.
shapeH
);
return
oShape
;
};
this
.
privateGenerateShape
=
function
(
obj
)
{
AscFormat
.
ExecuteNoHistory
(
function
(
obj
)
{
if
(
bWord
){
oShape
.
createTextBoxContent
();
}
else
{
oShape
.
createTextBody
();
}
var
align
=
parseInt
(
obj
[
'
align
'
],
10
);
if
(
!
isNaN
(
align
)){
oShape
.
setVerticalAlign
();
}
var
oShape
=
this
.
privateGetShape
();
if
(
Array
.
isArray
(
obj
[
'
margins
'
])
&&
obj
[
'
margins
'
].
length
===
4
){
oShape
.
setPaddings
({
Left
:
obj
[
'
margins
'
][
0
],
Top
:
obj
[
'
margins
'
][
1
],
Right
:
obj
[
'
margins
'
][
2
],
Bottom
:
obj
[
'
margins
'
][
3
]});
}
var
oContent
=
oShape
.
getDocContent
();
var
sText
=
"
Oleg
"
;
var
oParagraph
=
oContent
.
Content
[
0
];
for
(
var
i
=
0
;
i
<
sText
.
length
;
++
i
)
var
aParagraphsS
=
obj
[
'
paragraphs
'
];
for
(
var
i
=
0
;
i
<
aParagraphsS
.
length
;
++
i
){
var
oCurParS
=
aParagraphsS
[
i
];
var
oNewParagraph
=
new
Paragraph
(
oContent
.
DrawingDocument
,
oContent
);
if
(
AscFormat
.
isRealNumber
(
oCurParS
[
'
align
'
])){
oNewParagraph
.
Set_Align
(
oCurParS
[
'
align
'
])
}
if
(
Array
.
isArray
(
oCurParS
[
'
fill
'
])
&&
oCurParS
[
'
fill
'
].
length
===
3
){
var
oShd
=
new
CDocumentShd
();
oShd
.
Value
=
Asc
.
c_oAscShdClear
;
oShd
.
Color
.
r
=
oCurParS
[
'
fill
'
][
0
];
oShd
.
Color
.
g
=
oCurParS
[
'
fill
'
][
1
];
oShd
.
Color
.
b
=
oCurParS
[
'
fill
'
][
2
];
oNewParagraph
.
Set_Shd
(
oShd
,
true
);
}
if
(
AscFormat
.
isRealNumber
(
oCurParS
[
'
linespacing
'
])){
oNewParagraph
.
Set_Spacing
({
Line
:
oCurParS
[
'
linespacing
'
],
LineRule
:
Asc
.
linerule_Exact
});
}
var
aRunsS
=
oCurParS
[
'
runs
'
];
for
(
var
j
=
0
;
j
<
aRunsS
.
length
;
++
j
){
var
oRunS
=
aRunsS
[
j
];
var
oRun
=
new
ParaRun
(
oNewParagraph
,
false
);
if
(
Array
.
isArray
(
oRunS
[
'
fill
'
])
&&
oRunS
[
'
fill
'
].
length
===
3
){
oRun
.
Set_Unifill
(
AscFormat
.
CreteSolidFillRGB
(
oRunS
[
'
fill
'
][
0
],
oRunS
[
'
fill
'
][
1
],
oRunS
[
'
fill
'
][
2
]));
}
if
(
oRunS
[
'
font-family
'
]){
oRun
.
Set_RFonts_Ascii
({
Name
:
oRunS
[
'
font-family
'
],
Index
:
-
1
});
oRun
.
Set_RFonts_CS
({
Name
:
oRunS
[
'
font-family
'
],
Index
:
-
1
});
oRun
.
Set_RFonts_EastAsia
({
Name
:
oRunS
[
'
font-family
'
],
Index
:
-
1
});
oRun
.
Set_RFonts_HAnsi
({
Name
:
oRunS
[
'
font-family
'
],
Index
:
-
1
});
}
if
(
oRunS
[
'
font-size
'
]){
oRun
.
Set_FontSize
(
oRunS
[
'
font-size
'
]);
}
oRun
.
Set_Bold
(
oRunS
[
'
bold
'
]
===
true
);
oRun
.
Set_Italic
(
oRunS
[
'
italic
'
]
===
true
);
oRun
.
Set_Strikeout
(
oRunS
[
'
strikeout
'
]
===
true
);
oRun
.
Set_Underline
(
oRunS
[
'
underline
'
]
===
true
);
var
sCustomText
=
oRunS
[
'
text
'
];
if
(
sCustomText
===
"
<%br%>
"
){
oRun
.
Add_ToContent
(
0
,
new
ParaNewLine
(
AscCommonWord
.
break_Line
),
false
);
}
else
{
for
(
var
nIndex
=
0
,
nLen
=
sCustomText
.
length
;
nIndex
<
nLen
;
++
nIndex
)
{
oContent
.
AddToParagraph
(
new
ParaText
(
sText
[
i
]),
false
);
var
nChar
=
sCustomText
.
charAt
(
nIndex
);
if
(
"
"
===
nChar
)
oRun
.
Add_ToContent
(
nIndex
,
new
ParaSpace
(),
true
);
else
oRun
.
Add_ToContent
(
nIndex
,
new
ParaText
(
nChar
),
true
);
}
}
oNewParagraph
.
Internal_Content_Add
(
i
,
oRun
,
false
);
}
oContent
.
Internal_Content_Add
(
oContent
.
Content
.
length
,
oNewParagraph
);
}
oContent
.
Set_ApplyToAll
(
true
);
oContent
.
AddToParagraph
(
new
ParaTextPr
({
FontSize
:
20
,
RFonts
:
{
Ascii
:
{
Name
:
"
Arial
"
,
Index
:
-
1
}}}));
oContent
.
SetParagraphAlign
(
AscCommon
.
align_Center
);
oContent
.
SetParagraphIndent
({
FirstLine
:
0
,
Left
:
0
,
Right
:
0
});
oContent
.
Set_ApplyToAll
(
false
);
oShape
.
recalculate
();
if
(
oShape
.
bWordShape
)
...
...
@@ -3338,7 +3381,7 @@
var
graphics
=
new
AscCommon
.
CGraphics
();
graphics
.
m_oFontManager
=
AscCommon
.
g_fontManager
;
graphics
.
init
(
this
.
image
.
getContext
(
'
2d
'
),
this
.
width
,
this
.
height
,
this
.
shapeW
,
this
.
shapeH
);
graphics
.
init
(
this
.
image
.
getContext
(
'
2d
'
),
this
.
width
,
this
.
height
,
oShape
.
bounds
.
w
,
oShape
.
bounds
.
h
);
graphics
.
transform
(
1
,
0
,
0
,
1
,
0
,
0
);
oShape
.
draw
(
graphics
);
...
...
slide/Editor/Format/Presentation.js
View file @
2bdd99a4
...
...
@@ -297,7 +297,7 @@ CShowPr.prototype.Write_ToBinary = function(w){
w
.
Seek
(
nStartPos
);
w
.
WriteLong
(
Flags
);
w
.
Seek
(
nEndPos
);
}
}
;
CShowPr
.
prototype
.
Read_FromBinary
=
function
(
r
){
var
Flags
=
r
.
GetLong
();
...
...
@@ -339,7 +339,7 @@ CShowPr.prototype.Read_FromBinary = function(r){
if
(
Flags
&
1024
){
this
.
useTimings
=
r
.
GetBool
();
}
}
}
;
CShowPr
.
prototype
.
Copy
=
function
(){
var
oCopy
=
new
CShowPr
();
...
...
@@ -369,7 +369,8 @@ CShowPr.prototype.Copy = function(){
oCopy
.
showNarration
=
this
.
showNarration
;
oCopy
.
useTimings
=
this
.
useTimings
;
return
oCopy
;
}
};
...
...
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