Commit c4732a8c authored by SergeyLuzyanin's avatar SergeyLuzyanin

media

parent 81c0f08e
......@@ -148,6 +148,7 @@ var asc_CShapeProperty = Asc.asc_CShapeProperty;
drawingsChangesMap[AscDFH.historyitem_HF_SetHdr ] = function (oClass, value){oClass.hdr = value;};
drawingsChangesMap[AscDFH.historyitem_HF_SetSldNum ] = function (oClass, value){oClass.sldNum = value;};
drawingsChangesMap[AscDFH.historyitem_UniNvPr_SetUniSpPr] = function (oClass, value){oClass.nvUniSpPr = value;};
drawingsChangesMap[AscDFH.historyitem_NvPr_SetUniMedia] = function (oClass, value){oClass.unimedia = value;};
drawingContentChanges[AscDFH.historyitem_ClrMap_SetClr] = function(oClass){return oClass.color_map};
......@@ -179,6 +180,7 @@ var asc_CShapeProperty = Asc.asc_CShapeProperty;
AscDFH.changesFactory[AscDFH.historyitem_NvPr_SetIsPhoto] = CChangesDrawingsBool;
AscDFH.changesFactory[AscDFH.historyitem_NvPr_SetUserDrawn] = CChangesDrawingsBool;
AscDFH.changesFactory[AscDFH.historyitem_NvPr_SetPh] = CChangesDrawingsObject;
AscDFH.changesFactory[AscDFH.historyitem_NvPr_SetUniMedia] = CChangesDrawingsObjectNoId;
AscDFH.changesFactory[AscDFH.historyitem_Ph_SetHasCustomPrompt] = CChangesDrawingsBool;
AscDFH.changesFactory[AscDFH.historyitem_Ph_SetIdx] = CChangesDrawingsString;
AscDFH.changesFactory[AscDFH.historyitem_Ph_SetOrient] = CChangesDrawingsLong;
......@@ -4689,11 +4691,54 @@ CNvPr.prototype =
}
};
var AUDIO_CD = 0;
var WAV_AUDIO_FILE = 1;
var AUDIO_FILE = 2;
var VIDEO_FILE = 3;
var QUICK_TIME_FILE = 4;
function UniMedia() {
this.type = null;
this.media = null;
}
UniMedia.prototype.Write_ToBinary = function(w){
var bType = this.type !== null && this.type !== undefined;
var bMedia = typeof this.media === 'string';
var nFlags = 0;
bType && (nFlags |= 1);
bMedia && (nFlags |= 2);
w.WriteLong(nFlags);
bType && w.WriteLong(this.type);
bMedia && w.WriteString2(this.media);
};
UniMedia.prototype.Read_FromBinary = function(r){
var nFlags = r.GetLong();
if(nFlags & 1){
this.type = r.GetLong();
}
if(nFlags & 2){
this.media = r.GetString2();
}
};
UniMedia.prototype.createDuplicate = function(r){
var _ret = new UniMedia();
_ret.type = this.type;
_ret.media = this.media;
return _ret;
};
drawingConstructorsMap[AscDFH.historyitem_NvPr_SetUniMedia ] = UniMedia;
function NvPr()
{
this.isPhoto = false;
this.userDrawn = false;
this.ph = null;
this.unimedia = null;
this.Id = g_oIdCounter.Get_NewId();
......@@ -4732,6 +4777,10 @@ NvPr.prototype =
this.ph = ph;
},
setUniMedia: function(pr){
History.Add(new CChangesDrawingsObjectNoId(this, AscDFH.historyitem_NvPr_SetUniMedia, this.unimedia, pr));
this.unimedia = pr;
},
createDuplicate: function()
{
......@@ -10628,6 +10677,7 @@ function CorrectUniColor(asc_color, unicolor, flag)
window['AscFormat'].CorrectUniColor = CorrectUniColor;
window['AscFormat'].deleteDrawingBase = deleteDrawingBase;
window['AscFormat'].CNvUniSpPr = CNvUniSpPr;
window['AscFormat'].UniMedia = UniMedia;
window['AscFormat'].builder_CreateShape = builder_CreateShape;
......@@ -10776,5 +10826,13 @@ function CorrectUniColor(asc_color, unicolor, flag)
window['AscFormat'].BULLET_TYPE_BULLET_AUTONUM = BULLET_TYPE_BULLET_AUTONUM;
window['AscFormat'].BULLET_TYPE_BULLET_BLIP = BULLET_TYPE_BULLET_BLIP;
window['AscFormat'].AUDIO_CD = AUDIO_CD;
window['AscFormat'].WAV_AUDIO_FILE = WAV_AUDIO_FILE;
window['AscFormat'].AUDIO_FILE = AUDIO_FILE;
window['AscFormat'].VIDEO_FILE = VIDEO_FILE;
window['AscFormat'].QUICK_TIME_FILE = QUICK_TIME_FILE;
window['AscFormat'].DEFAULT_COLOR_MAP = GenerateDefaultColorMap();
})(window);
......@@ -1797,6 +1797,7 @@
window['AscDFH'].historyitem_NvPr_SetIsPhoto = window['AscDFH'].historyitem_type_NvPr | 1;
window['AscDFH'].historyitem_NvPr_SetUserDrawn = window['AscDFH'].historyitem_type_NvPr | 2;
window['AscDFH'].historyitem_NvPr_SetPh = window['AscDFH'].historyitem_type_NvPr | 3;
window['AscDFH'].historyitem_NvPr_SetUniMedia = window['AscDFH'].historyitem_type_NvPr | 4;
window['AscDFH'].historyitem_Ph_SetHasCustomPrompt = window['AscDFH'].historyitem_type_Ph | 1;
window['AscDFH'].historyitem_Ph_SetIdx = window['AscDFH'].historyitem_type_Ph | 2;
......
......@@ -5177,11 +5177,12 @@ function BinaryPPTYLoader()
_object = this.ReadShape();
break;
}
case 6:
case 2:
case 7:
case 2://pic
case 6://ole
case 7://video
case 8://audio
{
_object = this.ReadPic(6 === _type);
_object = this.ReadPic(_type);
break;
}
case 3:
......@@ -5377,8 +5378,9 @@ function BinaryPPTYLoader()
case 6:
case 2:
case 7:
case 8:
{
_object = this.ReadPic(6 === _type);
_object = this.ReadPic(_type);
if (!IsHiddenObj(_object) && _object.spPr && _object.spPr.xfrm)
{
shape.addToSpTree(shape.spTree.length,_object);
......@@ -5499,8 +5501,9 @@ function BinaryPPTYLoader()
case 6:
case 2:
case 7:
case 8:
{
var _object = this.ReadPic(6 === _type);
var _object = this.ReadPic(_type);
if (!IsHiddenObj(_object))
{
shapes[shapes.length] = _object;
......@@ -5560,10 +5563,11 @@ function BinaryPPTYLoader()
}
this.ReadPic = function(isOle)
this.ReadPic = function(type)
{
var s = this.stream;
var isOle = (type === 6);
var pic = isOle ? new AscFormat.COleObject(this.TempMainObject) : new AscFormat.CImageShape(this.TempMainObject);
pic.setBDeleted(false);
......@@ -5571,6 +5575,7 @@ function BinaryPPTYLoader()
var _rec_start = s.cur;
var _end_rec = _rec_start + s.GetULong() + 4;
var sMaskFileName;
while (s.cur < _end_rec)
{
var _at = s.GetUChar();
......@@ -5613,6 +5618,30 @@ function BinaryPPTYLoader()
}
break;
}
case 5:
{
if(type === 7 || type === 8){//video or audio
s.GetLong();
s.GetUChar();//start attributes
while(true)
{
var _at2 = s.GetUChar();
if (_at2 == g_nodeAttributeEnd)
break;
switch (_at2) {
case 0:
{
sMaskFileName = s.GetString2();
break;
}
}
}
}
else{
s.SkipRecord();
}
break;
}
default:
{
this.stream.SkipRecord();
......@@ -5621,6 +5650,15 @@ function BinaryPPTYLoader()
}
}
if(type === 7 || type === 8){//video or audio
if(typeof sMaskFileName === "string" && sMaskFileName.length > 0 &&
pic.nvPicPr && pic.nvPicPr.nvPr && pic.nvPicPr.nvPr.unimedia){
var oUniMedia = new AscFormat.UniMedia();
oUniMedia.type = type;
oUniMedia.media = sMaskFileName;
pic.nvPicPr.nvPr.setUniMedia(oUniMedia);
}
}
s.Seek2(_end_rec);
return pic;
}
......@@ -6996,6 +7034,13 @@ function BinaryPPTYLoader()
nvPr.setPh(this.ReadPH());
break;
}
case 1:
{
nvPr.setUniMedia(new AscFormat.UniMedia());
var _len = s.GetULong();
s.Skip2(_len);
break;
}
default:
{
var _len = s.GetULong();
......@@ -9018,8 +9063,10 @@ function CPres()
}
case 6:
case 2:
case 7:
case 8:
{
GrObject = this.ReadPic(6 == _type);
GrObject = this.ReadPic(_type);
break;
}
case 3:
......@@ -9487,10 +9534,11 @@ function CPres()
s.Seek2(_end_rec);
return shape;
}
this.ReadPic = function(isOle)
this.ReadPic = function(type)
{
var s = this.stream;
var isOle = (type === 6);
var pic = isOle ? new AscFormat.COleObject() : new AscFormat.CImageShape();
pic.setBDeleted(false);
pic.setParent(this.TempMainObject == null ? this.ParaDrawing : null);
......@@ -9498,6 +9546,7 @@ function CPres()
var _rec_start = s.cur;
var _end_rec = _rec_start + s.GetULong() + 4;
var sMaskFileName = "";
while (s.cur < _end_rec)
{
var _at = s.GetUChar();
......@@ -9546,6 +9595,29 @@ function CPres()
}
break;
}
case 5:
{
if(type === 7 || type === 8){//video or audio
s.GetLong();
s.GetUChar();//start attributes
while(true){
var _at2 = s.GetUChar();
if (_at2 == g_nodeAttributeEnd)
break;
switch (_at2) {
case 0:
{
sMaskFileName = s.GetString2();
break;
}
}
}
}
else{
s.SkipRecord();
}
break;
}
default:
{
s.SkipRecord();
......@@ -9554,6 +9626,16 @@ function CPres()
}
}
if(type === 7 || type === 8){//video or audio
if(typeof sMaskFileName === "string" && sMaskFileName.length > 0 &&
pic.nvPicPr && pic.nvPicPr.nvPr && pic.nvPicPr.nvPr.unimedia){
var oUniMedia = new AscFormat.UniMedia();
oUniMedia.type = type;
oUniMedia.media = sMaskFileName;
pic.nvPicPr.nvPr.setUniMedia(oUniMedia);
}
}
s.Seek2(_end_rec);
return pic;
}
......@@ -9687,8 +9769,9 @@ function CPres()
case 6:
case 2:
case 7:
case 8:
{
sp = this.ReadPic(6 == _type);
sp = this.ReadPic(_type);
if(sp.spPr && sp.spPr.xfrm){
sp.setGroup(shape);
shape.addToSpTree(shape.spTree.length, sp);
......
......@@ -3067,7 +3067,26 @@ function CBinaryFileWriter()
//важно писать в начале
oThis.WriteRecord1(4, image, oThis.WriteOleInfo);
} else {
oThis.StartRecord(2);
var _type;
var bMedia = false, _fileMask;
if(image.nvPicPr && image.nvPicPr.nvPr && image.nvPicPr.nvPr.unimedia && image.nvPicPr.nvPr.unimedia.type !== null
&& typeof image.nvPicPr.nvPr.unimedia.media === "string" && image.nvPicPr.nvPr.unimedia.media.length > 0){
_type = image.nvPicPr.nvPr.unimedia.type;
_fileMask = image.nvPicPr.nvPr.unimedia.media;
bMedia = true;
}
else{
_type = 2;
}
oThis.StartRecord(_type);
if(bMedia){
oThis.WriteRecord1(5, null, function(){
oThis.WriteUChar(g_nodeAttributeStart);
oThis._WriteString1(0, _fileMask);
oThis.WriteUChar(g_nodeAttributeEnd);
});
}
}
......@@ -4971,12 +4990,31 @@ function CBinaryFileWriter()
var _writer = this.BinaryFileWriter;
var isOle = AscDFH.historyitem_type_OleObject == image.getObjectType();
var _type, _fileMask;
if(isOle){
_writer.StartRecord(6);
//важно писать в начале
_writer.WriteRecord1(4, image, _writer.WriteOleInfo);
} else {
_writer.StartRecord(2);
var _type;
var bMedia = false;
if(image.nvPicPr && image.nvPicPr.nvPr && image.nvPicPr.nvPr.unimedia && image.nvPicPr.nvPr.unimedia.type !== null
&& typeof image.nvPicPr.nvPr.unimedia.media === "string" && image.nvPicPr.nvPr.unimedia.media.length > 0){
_type = image.nvPicPr.nvPr.unimedia.type;
_fileMask = image.nvPicPr.nvPr.unimedia.media;
bMedia = true;
}
else{
_type = 2;
}
_writer.StartRecord(_type);
if(bMedia){
_writer.WriteRecord1(5, null, function(){
_writer.WriteUChar(g_nodeAttributeStart);
_writer._WriteString2(0, _fileMask);
_writer.WriteUChar(g_nodeAttributeEnd);
});
}
}
_writer.WriteRecord1(0, {locks: image.locks, objectType: image.getObjectType()}, _writer.WriteUniNvPr);
......
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