Commit 1e2fcf55 authored by konovalovsergey's avatar konovalovsergey

open/save math spreadsheet and presentation

parent 83dbff9a
......@@ -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;
......
......@@ -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;
}
......@@ -8622,6 +8659,41 @@ function CPres()
this.LogicDocument = oLogicDocument;
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()
{
......
......@@ -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;
}
......@@ -4509,6 +4543,44 @@ function CBinaryFileWriter()
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;
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.WriteDrawing = function(memory, grObject, Document, oMapCommentId, oNumIdMap, copyParams, saveParams)
{
this.TreeDrawingIndex++;
......
This diff is collapsed.
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