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
1e2fcf55
Commit
1e2fcf55
authored
Sep 28, 2016
by
konovalovsergey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
open/save math spreadsheet and presentation
parent
83dbff9a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
228 additions
and
117 deletions
+228
-117
common/Drawings/Format/Format.js
common/Drawings/Format/Format.js
+2
-1
common/Shapes/Serialize.js
common/Shapes/Serialize.js
+72
-0
common/Shapes/SerializeWriter.js
common/Shapes/SerializeWriter.js
+72
-0
word/Editor/Serialize2.js
word/Editor/Serialize2.js
+82
-116
No files found.
common/Drawings/Format/Format.js
View file @
1e2fcf55
...
...
@@ -12647,7 +12647,8 @@ function CorrectUniColor(asc_color, unicolor, flag)
window
[
'
AscFormat
'
].
PARRUN_TYPE_RUN
=
1
;
window
[
'
AscFormat
'
].
PARRUN_TYPE_FLD
=
2
;
window
[
'
AscFormat
'
].
PARRUN_TYPE_BR
=
3
;
window
[
'
AscFormat
'
].
PARRUN_TYPE_TEXT_MATH
=
4
;
window
[
'
AscFormat
'
].
PARRUN_TYPE_MATH
=
4
;
window
[
'
AscFormat
'
].
PARRUN_TYPE_MATHPARA
=
5
;
window
[
'
AscFormat
'
].
_weight_body
=
_weight_body
;
window
[
'
AscFormat
'
].
_weight_chart
=
_weight_chart
;
...
...
common/Shapes/Serialize.js
View file @
1e2fcf55
...
...
@@ -160,6 +160,7 @@ function BinaryPPTYLoader()
this
.
RebuildImages
=
[];
this
.
textBodyTextFit
=
[];
this
.
DocReadResult
=
null
;
this
.
Start_UseFullUrl
=
function
()
{
...
...
@@ -8062,6 +8063,42 @@ function BinaryPPTYLoader()
}
break
;
}
case
AscFormat
.
PARRUN_TYPE_MATHPARA
:
case
AscFormat
.
PARRUN_TYPE_MATH
:
{
var
_end
=
s
.
cur
+
s
.
GetULong
()
+
4
;
var
_stream
=
new
AscCommon
.
FT_Stream2
();
_stream
.
data
=
s
.
data
;
_stream
.
pos
=
s
.
pos
;
_stream
.
cur
=
s
.
cur
;
_stream
.
size
=
s
.
size
;
var
parContentOld
=
par
.
Content
.
length
;
var
oParStruct
=
new
OpenParStruct
(
par
,
par
);
if
(
!
this
.
DocReadResult
)
{
this
.
DocReadResult
=
new
AscCommonWord
.
DocReadResult
(
null
);
}
var
boMathr
=
new
Binary_oMathReader
(
_stream
,
this
.
DocReadResult
,
null
);
var
nDocLength
=
_stream
.
GetULongLE
();
if
(
AscFormat
.
PARRUN_TYPE_MATHPARA
==
_type
)
{
var
props
=
{};
boMathr
.
bcr
.
Read1
(
nDocLength
,
function
(
t
,
l
){
return
boMathr
.
ReadMathOMathPara
(
t
,
l
,
oParStruct
,
props
);
});
}
else
{
var
oMath
=
new
ParaMath
();
oParStruct
.
addToContent
(
oMath
);
boMathr
.
bcr
.
Read1
(
nDocLength
,
function
(
t
,
l
){
return
boMathr
.
ReadMathArg
(
t
,
l
,
oMath
.
Root
,
oParStruct
);
});
oMath
.
Root
.
Correct_Content
(
true
);
}
s
.
Seek2
(
_end
);
EndPos
+=
par
.
Content
.
length
-
parContentOld
;
break
;
}
default
:
break
;
}
...
...
@@ -8623,6 +8660,41 @@ function CPres()
return
oNewSpPr
;
};
this
.
ReadRunProperties
=
function
(
stream
,
type
)
{
if
(
this
.
Reader
==
null
)
this
.
Reader
=
new
AscCommon
.
BinaryPPTYLoader
();
var
oLogicDocument
=
this
.
LogicDocument
;
this
.
LogicDocument
=
null
;
this
.
Reader
.
ImageMapChecker
=
this
.
ImageMapChecker
;
if
(
null
==
this
.
stream
)
{
this
.
stream
=
new
AscCommon
.
FileStream
();
this
.
stream
.
obj
=
stream
.
obj
;
this
.
stream
.
data
=
stream
.
data
;
this
.
stream
.
size
=
stream
.
size
;
}
this
.
stream
.
pos
=
stream
.
pos
;
this
.
stream
.
cur
=
stream
.
cur
;
this
.
Reader
.
stream
=
this
.
stream
;
var
s
=
this
.
stream
;
var
_main_type
=
s
.
GetUChar
();
// 0!!!
var
oNewrPr
=
this
.
Reader
.
ReadRunProperties
();
stream
.
pos
=
s
.
pos
;
stream
.
cur
=
s
.
cur
;
this
.
LogicDocument
=
oLogicDocument
;
return
oNewrPr
;
};
this
.
ReadShape
=
function
()
{
var
s
=
this
.
stream
;
...
...
common/Shapes/SerializeWriter.js
View file @
1e2fcf55
...
...
@@ -122,6 +122,7 @@ function CBinaryFileWriter()
this
.
IsUseFullUrl
=
false
;
this
.
PresentationThemesOrigin
=
""
;
this
.
DocSaveParams
=
null
;
var
oThis
=
this
;
this
.
Start_UseFullUrl
=
function
()
...
...
@@ -2714,6 +2715,39 @@ function CBinaryFileWriter()
break
;
}
case
para_Math
:
{
if
(
null
!=
_elem
.
Root
)
{
oThis
.
StartRecord
(
0
);
// subtype
oThis
.
StartRecord
(
AscFormat
.
PARRUN_TYPE_MATHPARA
);
var
_memory
=
new
AscCommon
.
CMemory
(
true
);
_memory
.
ImData
=
oThis
.
ImData
;
_memory
.
data
=
oThis
.
data
;
_memory
.
len
=
oThis
.
len
;
_memory
.
pos
=
oThis
.
pos
;
oThis
.
UseContinueWriter
=
true
;
if
(
!
oThis
.
DocSaveParams
)
{
oThis
.
DocSaveParams
=
new
AscCommonWord
.
DocSaveParams
(
false
,
false
);
}
var
boMaths
=
new
Binary_oMathWriter
(
_memory
,
null
,
oThis
.
DocSaveParams
);
boMaths
.
bs
.
WriteItemWithLength
(
function
(){
boMaths
.
WriteOMathPara
(
_elem
)});
oThis
.
ImData
=
_memory
.
ImData
;
oThis
.
data
=
_memory
.
data
;
oThis
.
len
=
_memory
.
len
;
oThis
.
pos
=
_memory
.
pos
;
oThis
.
UseContinueWriter
=
false
;
_memory
.
ImData
=
null
;
_memory
.
data
=
null
;
oThis
.
EndRecord
();
oThis
.
EndRecord
();
_count
++
;
}
}
default
:
break
;
}
...
...
@@ -4491,6 +4525,44 @@ function CBinaryFileWriter()
_writer
.
WriteSpPr
(
spPr
);
_writer
.
EndRecord
();
if
(
this
.
BinaryFileWriter
.
UseContinueWriter
)
{
memory
.
ImData
=
this
.
BinaryFileWriter
.
ImData
;
memory
.
data
=
this
.
BinaryFileWriter
.
data
;
memory
.
len
=
this
.
BinaryFileWriter
.
len
;
memory
.
pos
=
this
.
BinaryFileWriter
.
pos
;
}
else
{
this
.
TreeDrawingIndex
--
;
var
oldPos
=
this
.
arrayStackStarts
[
this
.
arrayStackStarts
.
length
-
1
];
memory
.
WriteBuffer
(
this
.
BinaryFileWriter
.
data
,
oldPos
,
this
.
BinaryFileWriter
.
pos
-
oldPos
);
this
.
BinaryFileWriter
.
pos
=
oldPos
;
this
.
arrayStackStarts
.
splice
(
this
.
arrayStackStarts
.
length
-
1
,
1
);
}
}
this
.
WriteRunProperties
=
function
(
memory
,
rPr
)
{
if
(
this
.
BinaryFileWriter
.
UseContinueWriter
)
{
this
.
BinaryFileWriter
.
ImData
=
memory
.
ImData
;
this
.
BinaryFileWriter
.
data
=
memory
.
data
;
this
.
BinaryFileWriter
.
len
=
memory
.
len
;
this
.
BinaryFileWriter
.
pos
=
memory
.
pos
;
}
else
{
this
.
TreeDrawingIndex
++
;
this
.
arrayStackStarts
.
push
(
this
.
BinaryFileWriter
.
pos
);
}
var
_writer
=
this
.
BinaryFileWriter
;
_writer
.
StartRecord
(
0
);
_writer
.
WriteRunProperties
(
rPr
);
_writer
.
EndRecord
();
if
(
this
.
BinaryFileWriter
.
UseContinueWriter
)
{
memory
.
ImData
=
this
.
BinaryFileWriter
.
ImData
;
...
...
word/Editor/Serialize2.js
View file @
1e2fcf55
...
...
@@ -727,7 +727,8 @@ var c_oSer_OMathContentType = {
Run
:
61
,
Ins
:
62
,
Del
:
63
,
columnbreak
:
64
columnbreak
:
64
,
ARPr
:
65
};
var
c_oSer_HyperlinkType
=
{
Content
:
0
,
...
...
@@ -1064,13 +1065,7 @@ function BinaryFileWriter(doc, bMailMergeDocx, bMailMergeHtml)
nNumIdIndex
:
null
,
oUsedStyleMap
:
null
};
this
.
saveParams
=
{
bMailMergeDocx
:
bMailMergeDocx
,
bMailMergeHtml
:
bMailMergeHtml
,
trackRevisionId
:
0
,
footnotes
:
{},
footnotesIndex
:
0
};
this
.
saveParams
=
new
DocSaveParams
(
bMailMergeDocx
,
bMailMergeHtml
);
this
.
Write
=
function
()
{
pptx_content_writer
.
_Start
();
...
...
@@ -2466,6 +2461,11 @@ function Binary_oMathWriter(memory, oMathPara, saveParams)
this
.
bs
.
WriteItem
(
c_oSer_OMathContentType
.
RPr
,
function
(){
oThis
.
brPrs
.
Write_rPr
(
props
.
wRPrp
,
null
,
null
);});
// w:rPr
this
.
bs
.
WriteItem
(
c_oSer_OMathContentType
.
MRPr
,
function
(){
oThis
.
WriteMRPr
(
props
.
mathRPrp
);});
// m:rPr
// if (oMRun.ARPr) { // a:rPr
// this.bs.WriteItem(c_oSer_OMathContentType.ARPr, function(){
// pptx_content_writer.WriteRunProperties(oThis.memory, oMRun.ARPr);
// });
// }
this
.
bs
.
WriteItem
(
c_oSer_OMathContentType
.
MText
,
function
(){
oThis
.
WriteMText
(
oText
.
toString
());});
// m:t
}
this
.
WriteMText
=
function
(
sText
)
...
...
@@ -5372,34 +5372,7 @@ function BinaryFileReader(doc, openParams)
this
.
Document
=
doc
;
this
.
openParams
=
openParams
;
this
.
stream
;
this
.
oReadResult
=
{
logicDocument
:
doc
,
ImageMap
:
null
,
oComments
:
null
,
oCommentsPlaces
:
null
,
setting
:
null
,
numToNumClass
:
null
,
paraNumPrs
:
null
,
styles
:
null
,
runStyles
:
null
,
paraStyles
:
null
,
tableStyles
:
null
,
lvlStyles
:
null
,
styleLinks
:
null
,
numStyleLinks
:
null
,
DefpPr
:
null
,
DefrPr
:
null
,
DocumentContent
:
null
,
bLastRun
:
null
,
aPostOpenStyleNumCallbacks
:
null
,
headers
:
null
,
footers
:
null
,
trackRevisions
:
null
,
drawingToMath
:
null
,
aTableCorrect
:
null
,
footnotes
:
null
,
footnoteRefs
:
null
};
this
.
oReadResult
=
new
DocReadResult
(
doc
);
this
.
getbase64DecodedData
=
function
(
szSrc
)
{
...
...
@@ -5559,29 +5532,6 @@ function BinaryFileReader(doc, openParams)
}
this
.
ReadMainTable
=
function
()
{
this
.
oReadResult
.
ImageMap
=
{};
this
.
oReadResult
.
oComments
=
{};
this
.
oReadResult
.
oCommentsPlaces
=
{};
this
.
oReadResult
.
setting
=
{
titlePg
:
false
,
EvenAndOddHeaders
:
false
};
this
.
oReadResult
.
numToNumClass
=
{};
this
.
oReadResult
.
paraNumPrs
=
[];
this
.
oReadResult
.
styles
=
[];
this
.
oReadResult
.
runStyles
=
[];
this
.
oReadResult
.
paraStyles
=
[];
this
.
oReadResult
.
tableStyles
=
[];
this
.
oReadResult
.
lvlStyles
=
[];
this
.
oReadResult
.
styleLinks
=
[];
this
.
oReadResult
.
numStyleLinks
=
[];
this
.
oReadResult
.
DocumentContent
=
[];
this
.
oReadResult
.
bLastRun
=
null
;
this
.
oReadResult
.
aPostOpenStyleNumCallbacks
=
[];
this
.
oReadResult
.
headers
=
[];
this
.
oReadResult
.
footers
=
[];
this
.
oReadResult
.
drawingToMath
=
[];
this
.
oReadResult
.
aTableCorrect
=
[];
this
.
oReadResult
.
footnotes
=
{};
this
.
oReadResult
.
footnoteRefs
=
[];
var
res
=
c_oSerConstants
.
ReadOk
;
//mtLen
res
=
this
.
stream
.
EnterFrame
(
1
);
...
...
@@ -5967,6 +5917,7 @@ function BinaryFileReader(doc, openParams)
if
(
null
!=
this
.
oReadResult
.
DefrPr
)
this
.
Document
.
Styles
.
Default
.
TextPr
.
Merge
(
this
.
oReadResult
.
DefrPr
);
//Footnotes strict after style
if
(
this
.
oReadResult
.
logicDocument
)
{
this
.
oReadResult
.
logicDocument
.
Footnotes
.
ResetSpecialFootnotes
();
for
(
var
i
=
0
;
i
<
this
.
oReadResult
.
footnoteRefs
.
length
;
++
i
)
{
var
footnote
=
this
.
oReadResult
.
footnotes
[
this
.
oReadResult
.
footnoteRefs
[
i
]];
...
...
@@ -5978,6 +5929,7 @@ function BinaryFileReader(doc, openParams)
this
.
oReadResult
.
logicDocument
.
Footnotes
.
SetSeparator
(
footnote
.
content
);
}
}
}
var
setting
=
this
.
oReadResult
.
setting
;
var
fInitCommentData
=
function
(
comment
)
...
...
@@ -8610,7 +8562,7 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, curFoo
}
else
if
(
c_oSerParType
.
Content
===
type
)
{
var
oParStruct
=
new
OpenParStruct
(
paragraph
,
Content
,
paragraph
);
var
oParStruct
=
new
OpenParStruct
(
paragraph
,
paragraph
);
//для случая гиперссылок на несколько строк в конце параграфа завершаем начатые, а начале - продолжаем незавершенные
if
(
this
.
aFields
.
length
>
0
)
{
for
(
var
i
=
0
;
i
<
this
.
aFields
.
length
;
++
i
)
{
...
...
@@ -8788,7 +8740,7 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, curFoo
}
else
if
(
c_oSer_FldSimpleType
.
Content
===
type
)
{
if
(
null
!=
oFldSimpleObj
.
ParaField
)
{
var
oFldStruct
=
new
OpenParStruct
(
oFldSimpleObj
.
ParaField
,
oParStruct
.
Content
,
oParStruct
.
paragraph
);
var
oFldStruct
=
new
OpenParStruct
(
oFldSimpleObj
.
ParaField
,
oParStruct
.
paragraph
);
res
=
this
.
bcr
.
Read1
(
length
,
function
(
t
,
l
)
{
return
oThis
.
ReadParagraphContent
(
t
,
l
,
oFldStruct
);
});
...
...
@@ -8825,7 +8777,7 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, curFoo
oHyperlinkObj
.
TgtFrame
=
this
.
stream
.
GetString2LE
(
length
);
}
else
if
(
c_oSer_HyperlinkType
.
Content
===
type
)
{
var
oHypStruct
=
new
OpenParStruct
(
oNewHyperlink
,
oParStruct
.
Content
,
oParStruct
.
paragraph
);
var
oHypStruct
=
new
OpenParStruct
(
oNewHyperlink
,
oParStruct
.
paragraph
);
res
=
this
.
bcr
.
Read1
(
length
,
function
(
t
,
l
)
{
return
oThis
.
ReadParagraphContent
(
t
,
l
,
oHypStruct
);
});
...
...
@@ -8972,34 +8924,6 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, curFoo
if
(
null
!=
oDrawing
.
content
.
GraphicObj
)
oNewElem
=
oDrawing
.
content
;
}
else
if
(
c_oSerRunType
.
table
===
type
)
{
var
doc
=
this
.
Document
;
var
oNewTable
=
new
CTable
(
doc
.
DrawingDocument
,
doc
,
true
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
[]);
res
=
this
.
bcr
.
Read1
(
length
,
function
(
t
,
l
){
return
oThis
.
ReadDocTable
(
t
,
l
,
oNewTable
);
});
if
(
oNewTable
.
Content
.
length
>
0
)
{
oNewTable
.
ReIndexing
(
0
);
oNewTable
.
Correct_BadTable
();
if
(
2
==
AscCommon
.
CurFileVersion
&&
false
==
oNewTable
.
Inline
)
{
//делаем смещение левой границы
if
(
false
==
oNewTable
.
PositionH
.
Align
)
{
var
dx
=
Get_TableOffsetCorrection
(
oNewTable
);
oNewTable
.
PositionH
.
Value
+=
dx
;
}
}
if
(
null
!=
this
.
lastPar
)
{
oNewTable
.
Set_DocumentPrev
(
this
.
lastPar
);
this
.
lastPar
.
Set_DocumentNext
(
oNewTable
);
}
this
.
lastPar
=
oNewTable
;
oParStruct
.
DocContent
.
push
(
oNewTable
);
}
}
else
if
(
c_oSerRunType
.
fldstart
===
type
)
{
oRes
.
bRes
=
false
;
...
...
@@ -9069,7 +8993,7 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, curFoo
return
oThis
.
ReadFootnoteRef
(
t
,
l
,
ref
);
});
var
footnote
=
this
.
oReadResult
.
footnotes
[
ref
.
id
];
if
(
footnote
)
{
if
(
footnote
&&
this
.
oReadResult
.
logicDocument
)
{
this
.
oReadResult
.
logicDocument
.
Footnotes
.
AddFootnote
(
footnote
.
content
);
oNewElem
=
new
ParaFootnoteReference
(
footnote
.
content
,
ref
.
customMark
);
}
...
...
@@ -11440,6 +11364,11 @@ function Binary_oMathReader(stream, oReadResult, curFootnote)
return
oThis
.
ReadMathMRPr
(
t
,
l
,
mrPr
);
});
oMRun
.
Set_MathPr
(
mrPr
);
}
else
if
(
c_oSer_OMathContentType
.
ARPr
===
type
)
{
var
rPr
=
pptx_content_loader
.
ReadRunProperties
(
this
.
stream
);
//oMRun.ARPr = rPr;
}
else
if
(
c_oSer_OMathContentType
.
RPr
===
type
)
{
...
...
@@ -12604,6 +12533,7 @@ function Binary_SettingsTableReader(doc, oReadResult, stream)
res
=
this
.
bcr
.
Read1
(
length
,
function
(
t
,
l
)
{
return
oThis
.
bpPrr
.
ReadFootnotePr
(
t
,
l
,
props
);
});
if
(
this
.
oReadResult
.
logicDocument
)
{
var
footnotes
=
this
.
oReadResult
.
logicDocument
.
Footnotes
;
if
(
null
!=
props
.
fmt
)
{
footnotes
.
SetFootnotePrNumFormat
(
props
.
fmt
);
...
...
@@ -12618,6 +12548,7 @@ function Binary_SettingsTableReader(doc, oReadResult, stream)
footnotes
.
SetFootnotePrPos
(
props
.
pos
);
}
}
}
else
res
=
c_oSerConstants
.
ReadUnknown
;
return
res
;
...
...
@@ -13237,8 +13168,7 @@ function getStyleFirstRun(oField){
}
return
res
;
}
function
OpenParStruct
(
oContainer
,
Content
,
paragraph
)
{
this
.
DocContent
=
Content
;
function
OpenParStruct
(
oContainer
,
paragraph
)
{
this
.
paragraph
=
paragraph
;
this
.
cur
=
{
pos
:
0
,
elem
:
oContainer
};
this
.
stack
=
[
this
.
cur
];
...
...
@@ -13319,9 +13249,45 @@ OpenParStruct.prototype = {
return
this
.
cur
.
pos
;
}
}
function
DocSaveParams
(
bMailMergeDocx
,
bMailMergeHtml
)
{
this
.
bMailMergeDocx
=
bMailMergeDocx
;
this
.
bMailMergeHtml
=
bMailMergeHtml
;
this
.
trackRevisionId
=
0
;
this
.
footnotes
=
{};
this
.
footnotesIndex
=
0
;
};
function
DocReadResult
(
doc
)
{
this
.
logicDocument
=
doc
;
this
.
ImageMap
=
{};
this
.
oComments
=
{};
this
.
oCommentsPlaces
=
{};
this
.
setting
=
{
titlePg
:
false
,
EvenAndOddHeaders
:
false
};
this
.
numToNumClass
=
{};
this
.
paraNumPrs
=
[];
this
.
styles
=
[];
this
.
runStyles
=
[];
this
.
paraStyles
=
[];
this
.
tableStyles
=
[];
this
.
lvlStyles
=
[];
this
.
styleLinks
=
[];
this
.
numStyleLinks
=
[];
this
.
DefpPr
=
null
;
this
.
DefrPr
=
null
;
this
.
DocumentContent
=
[];
this
.
bLastRun
=
null
;
this
.
aPostOpenStyleNumCallbacks
=
[];
this
.
headers
=
[];
this
.
footers
=
[];
this
.
trackRevisions
=
null
;
this
.
drawingToMath
=
[];
this
.
aTableCorrect
=
[];
this
.
footnotes
=
{};
this
.
footnoteRefs
=
[]
};
//---------------------------------------------------------export---------------------------------------------------
window
[
'
AscCommonWord
'
]
=
window
[
'
AscCommonWord
'
]
||
{};
window
[
"
AscCommonWord
"
].
BinaryFileReader
=
BinaryFileReader
;
window
[
"
AscCommonWord
"
].
BinaryFileWriter
=
BinaryFileWriter
;
window
[
"
AscCommonWord
"
].
EThemeColor
=
EThemeColor
;
window
[
"
AscCommonWord
"
].
DocReadResult
=
DocReadResult
;
window
[
"
AscCommonWord
"
].
DocSaveParams
=
DocSaveParams
;
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