Commit 65de99f7 authored by konovalovsergey's avatar konovalovsergey

open/save oleObj

parent 885d3717
...@@ -4205,6 +4205,70 @@ function BinaryPPTYLoader() ...@@ -4205,6 +4205,70 @@ function BinaryPPTYLoader()
return def; return def;
} }
this.ReadOleInfo = function(ole)
{
var s = this.stream;
var _rec_start = s.cur;
var _end_rec = _rec_start + s.GetLong() + 4;
s.Skip2(1); // start attributes
var dxaOrig = 0;
var dyaOrig = 0;
while (true)
{
var _at = s.GetUChar();
if (_at == g_nodeAttributeEnd)
break;
switch (_at)
{
case 0:
{
ole.setApplicationId(s.GetString2());
break;
}
case 1:
{
ole.setData(s.GetString2());
break;
}
case 2:
{
dxaOrig = s.GetULong();
break;
}
case 3:
{
dyaOrig = s.GetULong();
break;
}
case 4:
{
s.GetUChar();
break;
}
case 5:
{
s.GetUChar();
break;
}
case 6:
{
s.GetUChar();
break;
}
default:
break;
}
}
if (dxaOrig > 0 && dyaOrig > 0) {
var ratio = 4 / 3 / 20;//twips to px
ole.setPixSizes(ratio * dxaOrig, ratio * dyaOrig);
}
s.Seek2(_end_rec);
}
this.ReadGeometry = function(_xfrm) this.ReadGeometry = function(_xfrm)
{ {
var geom = null; var geom = null;
...@@ -4677,9 +4741,10 @@ function BinaryPPTYLoader() ...@@ -4677,9 +4741,10 @@ function BinaryPPTYLoader()
_object = this.ReadShape(); _object = this.ReadShape();
break; break;
} }
case 6:
case 2: case 2:
{ {
_object = this.ReadPic(); _object = this.ReadPic(6 === _type);
break; break;
} }
case 3: case 3:
...@@ -4832,9 +4897,10 @@ function BinaryPPTYLoader() ...@@ -4832,9 +4897,10 @@ function BinaryPPTYLoader()
} }
break; break;
} }
case 6:
case 2: case 2:
{ {
_object = this.ReadPic(); _object = this.ReadPic(6 === _type);
if (!IsHiddenObj(_object)) if (!IsHiddenObj(_object))
{ {
shape.addToSpTree(shape.spTree.length,_object); shape.addToSpTree(shape.spTree.length,_object);
...@@ -4948,9 +5014,10 @@ function BinaryPPTYLoader() ...@@ -4948,9 +5014,10 @@ function BinaryPPTYLoader()
} }
break; break;
} }
case 6:
case 2: case 2:
{ {
var _object = this.ReadPic(); var _object = this.ReadPic(6 === _type);
if (!IsHiddenObj(_object)) if (!IsHiddenObj(_object))
{ {
shapes[shapes.length] = _object; shapes[shapes.length] = _object;
...@@ -5006,11 +5073,11 @@ function BinaryPPTYLoader() ...@@ -5006,11 +5073,11 @@ function BinaryPPTYLoader()
} }
this.ReadPic = function() this.ReadPic = function(isOle)
{ {
var s = this.stream; var s = this.stream;
var pic = new AscFormat.CImageShape(this.TempMainObject); var pic = isOle ? new AscFormat.COleObject(this.TempMainObject) : new AscFormat.CImageShape(this.TempMainObject);
pic.setBDeleted(false); pic.setBDeleted(false);
...@@ -5046,6 +5113,15 @@ function BinaryPPTYLoader() ...@@ -5046,6 +5113,15 @@ function BinaryPPTYLoader()
pic.setStyle(this.ReadShapeStyle()); pic.setStyle(this.ReadShapeStyle());
break; break;
} }
case 4:
{
if(isOle) {
this.ReadOleInfo(pic);
} else {
s.SkipRecord();
}
break;
}
default: default:
{ {
break; break;
...@@ -7986,9 +8062,10 @@ function CPres() ...@@ -7986,9 +8062,10 @@ function CPres()
GrObject = this.ReadShape(); GrObject = this.ReadShape();
break; break;
} }
case 6:
case 2: case 2:
{ {
GrObject = this.ReadPic(); GrObject = this.ReadPic(6 == _type);
break; break;
} }
case 3: case 3:
...@@ -8349,11 +8426,11 @@ function CPres() ...@@ -8349,11 +8426,11 @@ function CPres()
s.Seek2(_end_rec); s.Seek2(_end_rec);
return shape; return shape;
} }
this.ReadPic = function() this.ReadPic = function(isOle)
{ {
var s = this.stream; var s = this.stream;
var pic = new AscFormat.CImageShape(); var pic = isOle ? new AscFormat.COleObject() : new AscFormat.CImageShape();
pic.setBDeleted(false); pic.setBDeleted(false);
pic.setParent(this.TempMainObject == null ? this.ParaDrawing : null); pic.setParent(this.TempMainObject == null ? this.ParaDrawing : null);
...@@ -8394,6 +8471,15 @@ function CPres() ...@@ -8394,6 +8471,15 @@ function CPres()
pic.setStyle(this.Reader.ReadShapeStyle()); pic.setStyle(this.Reader.ReadShapeStyle());
break; break;
} }
case 4:
{
if(isOle) {
this.ReadOleInfo(pic);
} else {
s.SkipRecord();
}
break;
}
default: default:
{ {
break; break;
...@@ -8404,6 +8490,69 @@ function CPres() ...@@ -8404,6 +8490,69 @@ function CPres()
s.Seek2(_end_rec); s.Seek2(_end_rec);
return pic; return pic;
} }
this.ReadOleInfo = function(ole)
{
var s = this.stream;
var _rec_start = s.cur;
var _end_rec = _rec_start + s.GetLong() + 4;
s.Skip2(1); // start attributes
var dxaOrig = 0;
var dyaOrig = 0;
while (true)
{
var _at = s.GetUChar();
if (_at == g_nodeAttributeEnd)
break;
switch (_at)
{
case 0:
{
ole.setApplicationId(s.GetString2());
break;
}
case 1:
{
ole.setData(s.GetString2());
break;
}
case 2:
{
dxaOrig = s.GetULong();
break;
}
case 3:
{
dyaOrig = s.GetULong();
break;
}
case 4:
{
s.GetUChar();
break;
}
case 5:
{
s.GetUChar();
break;
}
case 6:
{
s.GetUChar();
break;
}
default:
break;
}
}
if (dxaOrig > 0 && dyaOrig > 0) {
var ratio = 4 / 3 / 20;//twips to px
ole.setPixSizes(ratio * dxaOrig, ratio * dyaOrig);
}
s.Seek2(_end_rec);
}
this.ReadGroupShape = function() this.ReadGroupShape = function()
{ {
var s = this.stream; var s = this.stream;
...@@ -8461,9 +8610,10 @@ function CPres() ...@@ -8461,9 +8610,10 @@ function CPres()
shape.addToSpTree(shape.spTree.length, sp); shape.addToSpTree(shape.spTree.length, sp);
break; break;
} }
case 6:
case 2: case 2:
{ {
sp = this.ReadPic(); sp = this.ReadPic(6 == _type);
sp.setGroup(shape); sp.setGroup(shape);
shape.addToSpTree(shape.spTree.length, sp); shape.addToSpTree(shape.spTree.length, sp);
break; break;
......
...@@ -1515,6 +1515,7 @@ function CBinaryFileWriter() ...@@ -1515,6 +1515,7 @@ function CBinaryFileWriter()
oThis.WriteShape(spTree[i]); oThis.WriteShape(spTree[i]);
break; break;
} }
case AscDFH.historyitem_type_OleObject:
case AscDFH.historyitem_type_ImageShape: case AscDFH.historyitem_type_ImageShape:
{ {
oThis.WriteImage(spTree[i]); oThis.WriteImage(spTree[i]);
...@@ -2818,7 +2819,14 @@ function CBinaryFileWriter() ...@@ -2818,7 +2819,14 @@ function CBinaryFileWriter()
this.WriteImage = function(image) this.WriteImage = function(image)
{ {
oThis.StartRecord(2); var isOle = AscDFH.historyitem_type_OleObject == image.getObjectType();
if(isOle){
oThis.StartRecord(6);
//важно писать в начале
oThis.WriteRecord1(4, image, oThis.WriteOleInfo);
} else {
oThis.StartRecord(2);
}
oThis.WriteRecord1(0, image.nvPicPr, this.WriteUniNvPr); oThis.WriteRecord1(0, image.nvPicPr, this.WriteUniNvPr);
...@@ -2840,7 +2848,18 @@ function CBinaryFileWriter() ...@@ -2840,7 +2848,18 @@ function CBinaryFileWriter()
oThis.EndRecord(); oThis.EndRecord();
} }
this.WriteOleInfo = function(ole)
{
var ratio = 20 * 3 / 4;//px to twips
oThis.WriteUChar(g_nodeAttributeStart);
oThis._WriteString2(0, ole.m_sApplicationId);
oThis._WriteString2(1, ole.m_sData);
oThis._WriteInt2(2, ratio * ole.m_nPixWidth);
oThis._WriteInt2(3, ratio * ole.m_nPixHeight);
oThis._WriteUChar2(4, 0);
oThis._WriteUChar2(5, 0);
oThis.WriteUChar(g_nodeAttributeEnd);
}
this.WriteTable = function(grObj) this.WriteTable = function(grObj)
{ {
oThis.StartRecord(5); oThis.StartRecord(5);
...@@ -3247,6 +3266,7 @@ function CBinaryFileWriter() ...@@ -3247,6 +3266,7 @@ function CBinaryFileWriter()
oThis.WriteShape(spTree[i]); oThis.WriteShape(spTree[i]);
break; break;
} }
case AscDFH.historyitem_type_OleObject:
case AscDFH.historyitem_type_ImageShape: case AscDFH.historyitem_type_ImageShape:
{ {
oThis.WriteImage(spTree[i]); oThis.WriteImage(spTree[i]);
...@@ -4275,6 +4295,7 @@ function CBinaryFileWriter() ...@@ -4275,6 +4295,7 @@ function CBinaryFileWriter()
} }
break; break;
} }
case AscDFH.historyitem_type_OleObject:
case AscDFH.historyitem_type_ImageShape: case AscDFH.historyitem_type_ImageShape:
{ {
this.WriteImage(grObject); this.WriteImage(grObject);
...@@ -4376,7 +4397,14 @@ function CBinaryFileWriter() ...@@ -4376,7 +4397,14 @@ function CBinaryFileWriter()
{ {
var _writer = this.BinaryFileWriter; var _writer = this.BinaryFileWriter;
_writer.StartRecord(2); var isOle = AscDFH.historyitem_type_OleObject == image.getObjectType();
if(isOle){
_writer.StartRecord(6);
//важно писать в начале
_writer.WriteRecord1(4, image, _writer.WriteOleInfo);
} else {
_writer.StartRecord(2);
}
//_writer.WriteRecord1(0, image.nvPicPr, _writer.WriteUniNvPr); //_writer.WriteRecord1(0, image.nvPicPr, _writer.WriteUniNvPr);
image.spPr.WriteXfrm = image.spPr.xfrm; image.spPr.WriteXfrm = image.spPr.xfrm;
...@@ -4408,6 +4436,19 @@ function CBinaryFileWriter() ...@@ -4408,6 +4436,19 @@ function CBinaryFileWriter()
_writer.EndRecord(); _writer.EndRecord();
} }
this.WriteOleInfo = function(ole)
{
var ratio = 20 * 3 / 4;//px to twips
var _writer = this.BinaryFileWriter;
_writer.WriteUChar(g_nodeAttributeStart);
_writer._WriteString2(0, ole.m_sApplicationId);
_writer._WriteString2(1, ole.m_sData);
_writer._WriteInt2(2, ratio * ole.m_nPixWidth);
_writer._WriteInt2(3, ratio * ole.m_nPixHeight);
_writer._WriteUChar2(4, 0);
_writer._WriteUChar2(5, 0);
_writer.WriteUChar(g_nodeAttributeEnd);
}
this.WriteImageBySrc = function(memory, src, w, h) this.WriteImageBySrc = function(memory, src, w, h)
{ {
...@@ -4495,6 +4536,7 @@ function CBinaryFileWriter() ...@@ -4495,6 +4536,7 @@ function CBinaryFileWriter()
} }
break; break;
} }
case AscDFH.historyitem_type_OleObject:
case AscDFH.historyitem_type_ImageShape: case AscDFH.historyitem_type_ImageShape:
{ {
this.WriteImage(elem); this.WriteImage(elem);
......
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