Commit 65b4c9b0 authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander.Trofimov

Bug 19646 - [Copy&Paste] Изменяется стиль таблицы после redo отмены вставки таблицы

Bug 19674 - [Copy&Paste] Пропадают маркеры текста при копировании таблицы
Переделано открытие, чтобы его можно было использовать для копирования через бинарник(все свойства выставлялись через методы). Поправились баги с копирование через бинарник и undo/redo, и пересылкой изменений в совместном редактировании.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@49722 954022d7-b5bf-4e40-9824-e11837661b57
parent a8ce35b3
...@@ -1484,19 +1484,19 @@ CopyProcessor.prototype = ...@@ -1484,19 +1484,19 @@ CopyProcessor.prototype =
elem.before = elem.gridStart - nMinGrid; elem.before = elem.gridStart - nMinGrid;
elem.after = nMaxGrid - elem.gridEnd; elem.after = nMaxGrid - elem.gridEnd;
} }
this.oBinaryFileWriter.CopyTable(Item, aSelectedRows, nMinGrid, nMaxGrid);
this.oBinaryFileWriter.copyParams.bLockCopyElems++; this.oBinaryFileWriter.copyParams.bLockCopyElems++;
this.CopyTable(oDomTarget, Item, aSelectedRows); this.CopyTable(oDomTarget, Item, aSelectedRows);
this.oBinaryFileWriter.copyParams.bLockCopyElems--; this.oBinaryFileWriter.copyParams.bLockCopyElems--;
this.oBinaryFileWriter.CopyTable(Item, aSelectedRows, nMinGrid, nMaxGrid);
} }
} }
} }
else else
{ {
this.oBinaryFileWriter.CopyTable(Item, null);
this.oBinaryFileWriter.copyParams.bLockCopyElems++; this.oBinaryFileWriter.copyParams.bLockCopyElems++;
this.CopyTable(oDomTarget, Item, null); this.CopyTable(oDomTarget, Item, null);
this.oBinaryFileWriter.copyParams.bLockCopyElems--; this.oBinaryFileWriter.copyParams.bLockCopyElems--;
this.oBinaryFileWriter.CopyTable(Item, null);
} }
} }
else if ( type_Paragraph === Item.GetType() ) else if ( type_Paragraph === Item.GetType() )
...@@ -2525,7 +2525,6 @@ PasteProcessor.prototype = ...@@ -2525,7 +2525,6 @@ PasteProcessor.prototype =
} }
//обрабатываем стили //обрабатываем стили
var isAlreadyContainsStyle; var isAlreadyContainsStyle;
var addStyles = [];
var api = this.api; var api = this.api;
var oStyleTypes = {par: 1, table: 2, lvl: 3}; var oStyleTypes = {par: 1, table: 2, lvl: 3};
var addNewStyles = false; var addNewStyles = false;
...@@ -2540,9 +2539,9 @@ PasteProcessor.prototype = ...@@ -2540,9 +2539,9 @@ PasteProcessor.prototype =
var isEqualName = null; var isEqualName = null;
if(null != stylePaste && null != stylePaste.style) if(null != stylePaste && null != stylePaste.style)
{ {
for(var j in oDocumentStyles) for(var j in oDocumentStyles.Style)
{ {
var styleDoc = oDocumentStyles[j]; var styleDoc = oDocumentStyles.Style[j];
isAlreadyContainsStyle = styleDoc.isEqual(stylePaste.style); isAlreadyContainsStyle = styleDoc.isEqual(stylePaste.style);
if(styleDoc.Name == stylePaste.style.Name) if(styleDoc.Name == stylePaste.style.Name)
isEqualName = j; isEqualName = j;
...@@ -2551,7 +2550,7 @@ PasteProcessor.prototype = ...@@ -2551,7 +2550,7 @@ PasteProcessor.prototype =
if(oStyleTypes.par == nStyleType) if(oStyleTypes.par == nStyleType)
elem.pPr.PStyle = j; elem.pPr.PStyle = j;
else if(oStyleTypes.table == nStyleType) else if(oStyleTypes.table == nStyleType)
elem.pPr.TableStyle = j; elem.pPr.Set_TableStyle2(j);
else else
elem.pPr.PStyle = j; elem.pPr.PStyle = j;
break; break;
...@@ -2562,58 +2561,36 @@ PasteProcessor.prototype = ...@@ -2562,58 +2561,36 @@ PasteProcessor.prototype =
if(nStyleType == oStyleTypes.par || nStyleType == oStyleTypes.lvl) if(nStyleType == oStyleTypes.par || nStyleType == oStyleTypes.lvl)
elem.pPr.PStyle = isEqualName; elem.pPr.PStyle = isEqualName;
else if (nStyleType == oStyleTypes.table) else if (nStyleType == oStyleTypes.table)
elem.pPr.TableStyle = isEqualName; elem.pPr.Set_TableStyle2(isEqualName);
addStyles[addStyles.length] = isEqualName;
} }
else if(!isAlreadyContainsStyle && isEqualName == null)//нужно добавить новый стиль else if(!isAlreadyContainsStyle && isEqualName == null)//нужно добавить новый стиль
{ {
oDocumentStyles[stylePaste.style.Name] = stylePaste.style; //todo править и BaseOn
var nStyleId = oDocumentStyles.Add(stylePaste.style);
if(nStyleType == oStyleTypes.par || nStyleType == oStyleTypes.lvl) if(nStyleType == oStyleTypes.par || nStyleType == oStyleTypes.lvl)
elem.pPr.PStyle = stylePaste.style.Name; elem.pPr.PStyle = nStyleId;
else if (nStyleType == oStyleTypes.table) else if (nStyleType == oStyleTypes.table)
elem.pPr.TableStyle = stylePaste.style.Name; elem.pPr.Set_TableStyle2(nStyleId);
addStyles[addStyles.length] = stylePaste.style.Name;
addNewStyles = true; addNewStyles = true;
} }
} }
} }
//добавляем картинки стилей в меню
if(addNewStyles)
api.GenerateStyles();
} }
fParseStyle(oBinaryFileReader.oReadResult.paraStyles, this.oDocument.Styles.Style, oBinaryFileReader.oReadResult, oStyleTypes.par); fParseStyle(oBinaryFileReader.oReadResult.paraStyles, this.oDocument.Styles, oBinaryFileReader.oReadResult, oStyleTypes.par);
fParseStyle(oBinaryFileReader.oReadResult.tableStyles, this.oDocument.Styles.Style, oBinaryFileReader.oReadResult, oStyleTypes.table); fParseStyle(oBinaryFileReader.oReadResult.tableStyles, this.oDocument.Styles, oBinaryFileReader.oReadResult, oStyleTypes.table);
fParseStyle(oBinaryFileReader.oReadResult.lvlStyles, this.oDocument.Styles.Style, oBinaryFileReader.oReadResult, oStyleTypes.lvl); fParseStyle(oBinaryFileReader.oReadResult.lvlStyles, this.oDocument.Styles, oBinaryFileReader.oReadResult, oStyleTypes.lvl);
var aContent = oBinaryFileReader.oReadResult.DocumentContent; var aContent = oBinaryFileReader.oReadResult.DocumentContent;
//добавляем во вставляемые параграфы стили(если уже данные стили присутcтвуют) for(var i = 0, length = oBinaryFileReader.oReadResult.aPostOpenStyleNumCallbacks.length; i < length; ++i)
var styleName; oBinaryFileReader.oReadResult.aPostOpenStyleNumCallbacks[i].call();
if(addStyles && addStyles.length != 0)
{
for(var i in aContent)
{
if(aContent[i].GetType() != oStyleTypes.table)
{
styleName = aContent[i].Style_Get();
for(var k = 0; k < addStyles.length; k++)
{
if(styleName == addStyles[k])
{
aContent[i].Style_Add(styleName);
break;
}
}
}
}
}
if(oReadResult.bLastRun) if(oReadResult.bLastRun)
this.bInBlock = false; this.bInBlock = false;
else else
this.bInBlock = true; this.bInBlock = true;
//создаем список используемых шрифтов //создаем список используемых шрифтов
var AllFonts = new Object(); var AllFonts = new Object();
this.oDocument.Numbering.Document_Get_AllFontNames(AllFonts);
this.oDocument.Styles.Document_Get_AllFontNames(AllFonts);
for ( var Index = 0, Count = aContent.length; Index < Count; Index++ ) for ( var Index = 0, Count = aContent.length; Index < Count; Index++ )
aContent[Index].Document_Get_AllFontNames( AllFonts ); aContent[Index].Document_Get_AllFontNames( AllFonts );
var aPrepeareFonts = []; var aPrepeareFonts = [];
...@@ -2623,7 +2600,7 @@ PasteProcessor.prototype = ...@@ -2623,7 +2600,7 @@ PasteProcessor.prototype =
var aPrepeareImages = []; var aPrepeareImages = [];
for(var i in window.global_pptx_content_loader.ImageMapChecker) for(var i in window.global_pptx_content_loader.ImageMapChecker)
aPrepeareImages.push(i); aPrepeareImages.push(i);
return {content: aContent, fonts: aPrepeareFonts, images: aPrepeareImages}; return {content: aContent, fonts: aPrepeareFonts, images: aPrepeareImages, bAddNewStyles: addNewStyles};
}, },
Start : function(node) Start : function(node)
{ {
...@@ -2671,6 +2648,8 @@ PasteProcessor.prototype = ...@@ -2671,6 +2648,8 @@ PasteProcessor.prototype =
oThis.InsertInDocument(); oThis.InsertInDocument();
node.blur(); node.blur();
node.style.display = ELEMENT_DISPAY_STYLE; node.style.display = ELEMENT_DISPAY_STYLE;
if(aContent.bAddNewStyles)
oThis.api.GenerateStyles();
} }
}); });
return; return;
......
...@@ -1927,9 +1927,6 @@ function BinaryNumberingTableWriter(memory, doc, oNumIdMap, oUsedNumIdMap) ...@@ -1927,9 +1927,6 @@ function BinaryNumberingTableWriter(memory, doc, oNumIdMap, oUsedNumIdMap)
//Id //Id
if(null != num.Id) if(null != num.Id)
this.bs.WriteItem(c_oSerNumTypes.AbstractNum_Id, function(){oThis.memory.WriteLong(index);}); this.bs.WriteItem(c_oSerNumTypes.AbstractNum_Id, function(){oThis.memory.WriteLong(index);});
//Type
if(null != num.Type)
this.bs.WriteItem(c_oSerNumTypes.AbstractNum_Type, function(){oThis.memory.WriteByte(num.Type);});
//Lvl //Lvl
if(null != num.Lvl) if(null != num.Lvl)
this.bs.WriteItem(c_oSerNumTypes.AbstractNum_Lvls, function(){oThis.WriteLevels(num.Lvl);}); this.bs.WriteItem(c_oSerNumTypes.AbstractNum_Lvls, function(){oThis.WriteLevels(num.Lvl);});
...@@ -2156,7 +2153,18 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap) ...@@ -2156,7 +2153,18 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap)
var item = Content[i]; var item = Content[i];
//если параграф копируется не сначала, то вычисляем текстовые настройки //если параграф копируется не сначала, то вычисляем текстовые настройки
if( bUseSelection && ParaStart == i && para_TextPr != item.Type) if( bUseSelection && ParaStart == i && para_TextPr != item.Type)
this.oCur_rPr = par.Internal_CalculateTextPr(ParaStart); {
//ищем предыдущие TextPr
for ( var j = ParaStart - 1; j >= 0; --j )
{
var oCurElem = Content[j];
if(para_TextPr != oCurElem.Type)
{
this.oCur_rPr = oCurElem;
break;
}
}
}
switch ( item.Type ) switch ( item.Type )
{ {
case para_Text: case para_Text:
...@@ -2370,12 +2378,12 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap) ...@@ -2370,12 +2378,12 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap)
this.memory.WriteByte(c_oSerPropLenType.Double); this.memory.WriteByte(c_oSerPropLenType.Double);
this.memory.WriteDouble(img.Distance.B); this.memory.WriteDouble(img.Distance.B);
} }
if(null != img.LayoutInCell) // if(null != img.LayoutInCell)
{ // {
this.memory.WriteByte(c_oSerImageType2.LayoutInCell); // this.memory.WriteByte(c_oSerImageType2.LayoutInCell);
this.memory.WriteByte(c_oSerPropLenType.Byte); // this.memory.WriteByte(c_oSerPropLenType.Byte);
this.memory.WriteBool(img.LayoutInCell); // this.memory.WriteBool(img.LayoutInCell);
} // }
if(null != img.RelativeHeight) if(null != img.RelativeHeight)
{ {
this.memory.WriteByte(c_oSerImageType2.RelativeHeight); this.memory.WriteByte(c_oSerImageType2.RelativeHeight);
...@@ -3004,7 +3012,8 @@ function BinaryFileReader(doc, openParams) ...@@ -3004,7 +3012,8 @@ function BinaryFileReader(doc, openParams)
DefpPr: null, DefpPr: null,
DefrPr: null, DefrPr: null,
DocumentContent: null, DocumentContent: null,
bLastRun: null bLastRun: null,
aPostOpenStyleNumCallbacks: null
}; };
this.getbase64DecodedData = function(szSrc) this.getbase64DecodedData = function(szSrc)
{ {
...@@ -3163,6 +3172,7 @@ function BinaryFileReader(doc, openParams) ...@@ -3163,6 +3172,7 @@ function BinaryFileReader(doc, openParams)
this.oReadResult.lvlStyles = []; this.oReadResult.lvlStyles = [];
this.oReadResult.DocumentContent = []; this.oReadResult.DocumentContent = [];
this.oReadResult.bLastRun = null; this.oReadResult.bLastRun = null;
this.oReadResult.aPostOpenStyleNumCallbacks = [];
var res = c_oSerConstants.ReadOk; var res = c_oSerConstants.ReadOk;
//mtLen //mtLen
...@@ -3545,6 +3555,8 @@ function BinaryFileReader(doc, openParams) ...@@ -3545,6 +3555,8 @@ function BinaryFileReader(doc, openParams)
var oNewParagraph = new Paragraph(this.Document.DrawingDocument, this.Document, 0, 50, 50, X_Right_Field, Y_Bottom_Field ); var oNewParagraph = new Paragraph(this.Document.DrawingDocument, this.Document, 0, 50, 50, X_Right_Field, Y_Bottom_Field );
this.Document.Content.push(oNewParagraph); this.Document.Content.push(oNewParagraph);
} }
// for(var i = 0, length = this.oReadResult.aPostOpenStyleNumCallbacks.length; i < length; ++i)
// this.oReadResult.aPostOpenStyleNumCallbacks[i].call();
}; };
}; };
function BinaryStyleTableReader(doc, oReadResult, stream) function BinaryStyleTableReader(doc, oReadResult, stream)
...@@ -3614,7 +3626,7 @@ function BinaryStyleTableReader(doc, oReadResult, stream) ...@@ -3614,7 +3626,7 @@ function BinaryStyleTableReader(doc, oReadResult, stream)
var res = c_oSerConstants.ReadOk; var res = c_oSerConstants.ReadOk;
var oThis = this; var oThis = this;
if(c_oSer_sts.Style_Name == type) if(c_oSer_sts.Style_Name == type)
style.Name = this.stream.GetString2LE(length); style.Set_Name(this.stream.GetString2LE(length));
else if(c_oSer_sts.Style_Id == type) else if(c_oSer_sts.Style_Id == type)
oId.id = this.stream.GetString2LE(length); oId.id = this.stream.GetString2LE(length);
else if(c_oSer_sts.Style_Type == type) else if(c_oSer_sts.Style_Type == type)
...@@ -3630,66 +3642,65 @@ function BinaryStyleTableReader(doc, oReadResult, stream) ...@@ -3630,66 +3642,65 @@ function BinaryStyleTableReader(doc, oReadResult, stream)
style.Set_Type(nStyleType); style.Set_Type(nStyleType);
} }
else if(c_oSer_sts.Style_Default == type) else if(c_oSer_sts.Style_Default == type)
oId.def = (this.stream.GetUChar() != 0); oId.def = this.stream.GetBool();
else if(c_oSer_sts.Style_BasedOn == type) else if(c_oSer_sts.Style_BasedOn == type)
style.BasedOn = this.stream.GetString2LE(length); style.Set_BasedOn(this.stream.GetString2LE(length));
else if(c_oSer_sts.Style_Next == type) else if(c_oSer_sts.Style_Next == type)
style.Next = this.stream.GetString2LE(length); style.Set_Next(this.stream.GetString2LE(length));
else if(c_oSer_sts.Style_qFormat == type) else if(c_oSer_sts.Style_qFormat == type)
style.qFormat = (this.stream.GetUChar() != 0); style.Set_QFormat(this.stream.GetBool());
else if(c_oSer_sts.Style_uiPriority == type) else if(c_oSer_sts.Style_uiPriority == type)
style.uiPriority = this.stream.GetULongLE(); style.Set_UiPriority(this.stream.GetULongLE());
else if(c_oSer_sts.Style_hidden == type) else if(c_oSer_sts.Style_hidden == type)
style.hidden = (this.stream.GetUChar() != 0); style.Set_Hidden(this.stream.GetBool());
else if(c_oSer_sts.Style_semiHidden == type) else if(c_oSer_sts.Style_semiHidden == type)
style.semiHidden = (this.stream.GetUChar() != 0); style.Set_SemiHidden(this.stream.GetBool());
else if(c_oSer_sts.Style_unhideWhenUsed == type) else if(c_oSer_sts.Style_unhideWhenUsed == type)
style.unhideWhenUsed = (this.stream.GetUChar() != 0); style.Set_UnhideWhenUsed(this.stream.GetBool());
else if(c_oSer_sts.Style_TextPr == type) else if(c_oSer_sts.Style_TextPr == type)
{ {
res = this.brPrr.Read(length, style.TextPr); var oNewTextPr = new CTextPr();
if(c_oSerConstants.ReadOk != res) res = this.brPrr.Read(length, oNewTextPr);
return res; style.Set_TextPr(oNewTextPr);
} }
else if(c_oSer_sts.Style_ParaPr == type) else if(c_oSer_sts.Style_ParaPr == type)
{ {
res = this.bpPrr.Read(length, style.ParaPr, null); var oNewParaPr = new CParaPr();
if(c_oSerConstants.ReadOk != res) res = this.bpPrr.Read(length, oNewParaPr, null);
return res; style.ParaPr = oNewParaPr;
this.oReadResult.aPostOpenStyleNumCallbacks.push(function(){
style.Set_ParaPr(oNewParaPr);
});
} }
else if(c_oSer_sts.Style_TablePr == type) else if(c_oSer_sts.Style_TablePr == type)
{ {
var oNewTablePr = new CTablePr();
res = this.bcr.Read1(length, function(t, l){ res = this.bcr.Read1(length, function(t, l){
return oThis.btblPrr.Read_tblPr(t,l, style.TablePr); return oThis.btblPrr.Read_tblPr(t,l, oNewTablePr);
}); });
style.Set_TablePr(oNewTablePr);
} }
else if(c_oSer_sts.Style_RowPr == type) else if(c_oSer_sts.Style_RowPr == type)
{ {
var TableRowPr = {}; var oNewTableRowPr = new CTableRowPr();
res = this.bcr.Read2(length, function(t, l){ res = this.bcr.Read2(length, function(t, l){
return oThis.btblPrr.Read_RowPr(t,l, TableRowPr); return oThis.btblPrr.Read_RowPr(t,l, oNewTableRowPr);
}); });
style.TableRowPr.Set_FromObject( TableRowPr ); style.Set_TableRowPr(oNewTableRowPr);
if(c_oSerConstants.ReadOk != res)
return res;
} }
else if(c_oSer_sts.Style_CellPr == type) else if(c_oSer_sts.Style_CellPr == type)
{ {
var TableCellPr = {}; var oNewTableCellPr = new CTableCellPr();
res = this.bcr.Read2(length, function(t, l){ res = this.bcr.Read2(length, function(t, l){
return oThis.btblPrr.Read_CellPr(t,l, TableCellPr); return oThis.btblPrr.Read_CellPr(t,l, oNewTableCellPr);
}); });
style.TableCellPr.Set_FromObject( TableCellPr ); style.Set_TableRowPr(oNewTableCellPr);
if(c_oSerConstants.ReadOk != res)
return res;
} }
else if(c_oSer_sts.Style_TblStylePr == type) else if(c_oSer_sts.Style_TblStylePr == type)
{ {
res = this.bcr.Read1(length, function(t, l){ res = this.bcr.Read1(length, function(t, l){
return oThis.ReadTblStylePr(t,l, style); return oThis.ReadTblStylePr(t,l, style);
}); });
if(c_oSerConstants.ReadOk != res)
return res;
} }
else else
res = c_oSerConstants.ReadUnknown; res = c_oSerConstants.ReadUnknown;
...@@ -3701,7 +3712,7 @@ function BinaryStyleTableReader(doc, oReadResult, stream) ...@@ -3701,7 +3712,7 @@ function BinaryStyleTableReader(doc, oReadResult, stream)
var oThis = this; var oThis = this;
if(c_oSerProp_tblStylePrType.TblStylePr == type) if(c_oSerProp_tblStylePrType.TblStylePr == type)
{ {
var oRes = new Object(); var oRes = {nType: null};
var oNewTableStylePr = new CTableStylePr() var oNewTableStylePr = new CTableStylePr()
res = this.bcr.Read1(length, function(t, l){ res = this.bcr.Read1(length, function(t, l){
return oThis.ReadTblStyleProperty(t, l, oNewTableStylePr, oRes); return oThis.ReadTblStyleProperty(t, l, oNewTableStylePr, oRes);
...@@ -3725,6 +3736,27 @@ function BinaryStyleTableReader(doc, oReadResult, stream) ...@@ -3725,6 +3736,27 @@ function BinaryStyleTableReader(doc, oReadResult, stream)
case ETblStyleOverrideType.tblstyleoverridetypeWholeTable: style.TableWholeTable = oNewTableStylePr;break; case ETblStyleOverrideType.tblstyleoverridetypeWholeTable: style.TableWholeTable = oNewTableStylePr;break;
} }
} }
this.oReadResult.aPostOpenStyleNumCallbacks.push(function(){
if(null != oRes.nType)
{
switch(oRes.nType)
{
case ETblStyleOverrideType.tblstyleoverridetypeBand1Horz: style.Set_TableBand1Horz(oNewTableStylePr);break;
case ETblStyleOverrideType.tblstyleoverridetypeBand1Vert: style.Set_TableBand1Vert(oNewTableStylePr);break;
case ETblStyleOverrideType.tblstyleoverridetypeBand2Horz: style.Set_TableBand2Horz(oNewTableStylePr);break;
case ETblStyleOverrideType.tblstyleoverridetypeBand2Vert: style.Set_TableBand2Vert(oNewTableStylePr);break;
case ETblStyleOverrideType.tblstyleoverridetypeFirstCol: style.Set_TableFirstCol(oNewTableStylePr);break;
case ETblStyleOverrideType.tblstyleoverridetypeFirstRow: style.Set_TableFirstRow(oNewTableStylePr);break;
case ETblStyleOverrideType.tblstyleoverridetypeLastCol: style.Set_TableLastCol(oNewTableStylePr);break;
case ETblStyleOverrideType.tblstyleoverridetypeLastRow: style.Set_TableLastRow(oNewTableStylePr);break;
case ETblStyleOverrideType.tblstyleoverridetypeNeCell: style.Set_TableTLCell(oNewTableStylePr);break;
case ETblStyleOverrideType.tblstyleoverridetypeNwCell: style.Set_TableTRCell(oNewTableStylePr);break;
case ETblStyleOverrideType.tblstyleoverridetypeSeCell: style.Set_TableBLCell(oNewTableStylePr);break;
case ETblStyleOverrideType.tblstyleoverridetypeSwCell: style.Set_TableBRCell(oNewTableStylePr);break;
case ETblStyleOverrideType.tblstyleoverridetypeWholeTable: style.Set_TableWholeTable(oNewTableStylePr);break;
}
}
});
if(c_oSerConstants.ReadOk != res) if(c_oSerConstants.ReadOk != res)
return res; return res;
} }
...@@ -3741,14 +3773,10 @@ function BinaryStyleTableReader(doc, oReadResult, stream) ...@@ -3741,14 +3773,10 @@ function BinaryStyleTableReader(doc, oReadResult, stream)
else if(c_oSerProp_tblStylePrType.RunPr == type) else if(c_oSerProp_tblStylePrType.RunPr == type)
{ {
res = this.brPrr.Read(length, oNewTableStylePr.TextPr); res = this.brPrr.Read(length, oNewTableStylePr.TextPr);
if(c_oSerConstants.ReadOk != res)
return res;
} }
else if(c_oSerProp_tblStylePrType.ParPr == type) else if(c_oSerProp_tblStylePrType.ParPr == type)
{ {
res = this.bpPrr.Read(length, oNewTableStylePr.ParaPr, null); res = this.bpPrr.Read(length, oNewTableStylePr.ParaPr, null);
if(c_oSerConstants.ReadOk != res)
return res;
} }
else if(c_oSerProp_tblStylePrType.TblPr == type) else if(c_oSerProp_tblStylePrType.TblPr == type)
{ {
...@@ -3758,23 +3786,15 @@ function BinaryStyleTableReader(doc, oReadResult, stream) ...@@ -3758,23 +3786,15 @@ function BinaryStyleTableReader(doc, oReadResult, stream)
} }
else if(c_oSerProp_tblStylePrType.TrPr == type) else if(c_oSerProp_tblStylePrType.TrPr == type)
{ {
var TableRowPr = {};
res = this.bcr.Read2(length, function(t, l){ res = this.bcr.Read2(length, function(t, l){
return oThis.btblPrr.Read_RowPr(t,l, TableRowPr); return oThis.btblPrr.Read_RowPr(t,l, oNewTableStylePr.TableRowPr);
}); });
oNewTableStylePr.TableRowPr.Set_FromObject( TableRowPr );
if(c_oSerConstants.ReadOk != res)
return res;
} }
else if(c_oSerProp_tblStylePrType.TcPr == type) else if(c_oSerProp_tblStylePrType.TcPr == type)
{ {
var TableCellPr = {};
res = this.bcr.Read2(length, function(t, l){ res = this.bcr.Read2(length, function(t, l){
return oThis.btblPrr.Read_CellPr(t,l, TableCellPr); return oThis.btblPrr.Read_CellPr(t,l, oNewTableStylePr.TableCellPr);
}); });
oNewTableStylePr.TableCellPr.Set_FromObject( TableCellPr );
if(c_oSerConstants.ReadOk != res)
return res;
} }
else else
res = c_oSerConstants.ReadUnknown; res = c_oSerConstants.ReadUnknown;
...@@ -3807,11 +3827,9 @@ function Binary_pPrReader(doc, oReadResult, stream) ...@@ -3807,11 +3827,9 @@ function Binary_pPrReader(doc, oReadResult, stream)
switch(type) switch(type)
{ {
case c_oSerProp_pPrType.contextualSpacing: case c_oSerProp_pPrType.contextualSpacing:
pPr.ContextualSpacing = (this.stream.GetUChar() != 0); pPr.ContextualSpacing = this.stream.GetBool();
break; break;
case c_oSerProp_pPrType.Ind: case c_oSerProp_pPrType.Ind:
if(null == pPr.Ind)
pPr.Ind = new CParaInd();
res = this.bcr.Read2(length, function(t, l){ res = this.bcr.Read2(length, function(t, l){
return oThis.ReadInd(t, l, pPr.Ind); return oThis.ReadInd(t, l, pPr.Ind);
}); });
...@@ -3820,30 +3838,27 @@ function Binary_pPrReader(doc, oReadResult, stream) ...@@ -3820,30 +3838,27 @@ function Binary_pPrReader(doc, oReadResult, stream)
pPr.Jc = this.stream.GetUChar(); pPr.Jc = this.stream.GetUChar();
break; break;
case c_oSerProp_pPrType.KeepLines: case c_oSerProp_pPrType.KeepLines:
pPr.KeepLines = (this.stream.GetUChar() != 0); pPr.KeepLines = this.stream.GetBool();
break; break;
case c_oSerProp_pPrType.KeepNext: case c_oSerProp_pPrType.KeepNext:
pPr.KeepNext = (this.stream.GetUChar() != 0); pPr.KeepNext = this.stream.GetBool();
break; break;
case c_oSerProp_pPrType.PageBreakBefore: case c_oSerProp_pPrType.PageBreakBefore:
pPr.PageBreakBefore = (this.stream.GetUChar() != 0); pPr.PageBreakBefore = this.stream.GetBool();
break; break;
case c_oSerProp_pPrType.Spacing: case c_oSerProp_pPrType.Spacing:
if(null == pPr.Spacing)
pPr.Spacing = new CParaSpacing();
res = this.bcr.Read2(length, function(t, l){ res = this.bcr.Read2(length, function(t, l){
return oThis.ReadSpacing(t, l, pPr.Spacing); return oThis.ReadSpacing(t, l, pPr.Spacing);
}); });
break; break;
case c_oSerProp_pPrType.Shd: case c_oSerProp_pPrType.Shd:
if(null == pPr.Shd)
pPr.Shd = new CDocumentShd(); pPr.Shd = new CDocumentShd();
res = this.bcr.Read2(length, function(t, l){ res = this.bcr.Read2(length, function(t, l){
return oThis.bcr.ReadShd(t, l, pPr.Shd); return oThis.bcr.ReadShd(t, l, pPr.Shd);
}); });
break; break;
case c_oSerProp_pPrType.WidowControl: case c_oSerProp_pPrType.WidowControl:
pPr.WidowControl = (this.stream.GetUChar() != 0); pPr.WidowControl = this.stream.GetBool();
break; break;
case c_oSerProp_pPrType.Tab: case c_oSerProp_pPrType.Tab:
pPr.Tabs = new CParaTabs(); pPr.Tabs = new CParaTabs();
...@@ -3870,15 +3885,17 @@ function Binary_pPrReader(doc, oReadResult, stream) ...@@ -3870,15 +3885,17 @@ function Binary_pPrReader(doc, oReadResult, stream)
} }
break; break;
case c_oSerProp_pPrType.pBdr: case c_oSerProp_pPrType.pBdr:
if(null == pPr.Brd)
pPr.Brd = { Top : undefined, Left : undefined, Bottom: undefined, Between: undefined, Right : undefined };
res = this.bcr.Read1(length, function(t, l){ res = this.bcr.Read1(length, function(t, l){
return oThis.ReadBorders(t, l, pPr.Brd); return oThis.ReadBorders(t, l, pPr.Brd);
}); });
break; break;
case c_oSerProp_pPrType.pPr_rPr: case c_oSerProp_pPrType.pPr_rPr:
if(null != this.paragraph) if(null != this.paragraph)
res = this.brPrr.Read(length, this.paragraph.TextPr.Value); {
var oNewParaTextPr = new CTextPr();
res = this.brPrr.Read(length, oNewParaTextPr);
this.paragraph.TextPr.Apply_TextPr(oNewParaTextPr);
}
else else
res = c_oSerConstants.ReadUnknown; res = c_oSerConstants.ReadUnknown;
break; break;
...@@ -4340,32 +4357,37 @@ Binary_tblPrReader.prototype = ...@@ -4340,32 +4357,37 @@ Binary_tblPrReader.prototype =
{ {
if( c_oSerProp_tblPrType.tblpPr === type ) if( c_oSerProp_tblPrType.tblpPr === type )
{ {
table.Inline = false; table.Set_Inline(false);
var oAdditionalPr = {PageNum: null, X: null, Y: null, Paddings: null}; var oAdditionalPr = {PageNum: null, X: null, Y: null, Paddings: null};
res = this.bcr.Read2(length, function(t, l){ res = this.bcr.Read2(length, function(t, l){
return oThis.Read_tblpPr(t, l, oAdditionalPr); return oThis.Read_tblpPr(t, l, oAdditionalPr);
}); });
if(null != oAdditionalPr.X) if(null != oAdditionalPr.X)
{ table.Set_PositionH(c_oAscHAnchor.Page, false, oAdditionalPr.X);
table.PositionH.RelativeFrom = c_oAscHAnchor.Page;
table.PositionH.Align = false;
table.PositionH.Value = oAdditionalPr.X;
}
if(null != oAdditionalPr.Y) if(null != oAdditionalPr.Y)
table.Set_PositionV(c_oAscVAnchor.Page, false, oAdditionalPr.Y);
if(null != oAdditionalPr.Paddings)
{ {
table.PositionV.RelativeFrom = c_oAscVAnchor.Page; var Paddings = oAdditionalPr.Paddings;
table.PositionV.Align = false; table.Set_Distance(Paddings.L, Paddings.T, Paddings.R, Paddings.B);
table.PositionV.Value = oAdditionalPr.Y;
} }
if(null != oAdditionalPr.Paddings)
table.Distance = oAdditionalPr.Paddings;
} }
else if( c_oSerProp_tblPrType.tblpPr2 === type ) else if( c_oSerProp_tblPrType.tblpPr2 === type )
{ {
table.Inline = false; table.Set_Inline(false);
var oAdditionalPr = {HRelativeFrom: null, HAlign: null, HValue: null, VRelativeFrom: null, VAlign: null, VValue: null, Distance: null};
res = this.bcr.Read2(length, function(t, l){ res = this.bcr.Read2(length, function(t, l){
return oThis.Read_tblpPr2(t, l, table); return oThis.Read_tblpPr2(t, l, oAdditionalPr);
}); });
if(null != oAdditionalPr.HRelativeFrom && null != oAdditionalPr.HAlign && null != oAdditionalPr.HValue)
table.Set_PositionH(oAdditionalPr.HRelativeFrom, oAdditionalPr.HAlign, oAdditionalPr.HValue);
if(null != oAdditionalPr.VRelativeFrom && null != oAdditionalPr.VAlign && null != oAdditionalPr.VValue)
table.Set_PositionV(oAdditionalPr.VRelativeFrom, oAdditionalPr.VAlign, oAdditionalPr.VValue);
if(null != oAdditionalPr.Paddings)
{
var Paddings = oAdditionalPr.Paddings;
table.Set_Distance(Paddings.L, Paddings.T, Paddings.R, Paddings.B);
}
} }
else if( c_oSerProp_tblPrType.Look === type ) else if( c_oSerProp_tblPrType.Look === type )
{ {
...@@ -4499,38 +4521,39 @@ Binary_tblPrReader.prototype = ...@@ -4499,38 +4521,39 @@ Binary_tblPrReader.prototype =
res = c_oSerConstants.ReadUnknown; res = c_oSerConstants.ReadUnknown;
return res; return res;
}, },
Read_tblpPr2: function(type, length, table) Read_tblpPr2: function(type, length, oAdditionalPr)
{ {
var res = c_oSerConstants.ReadOk; var res = c_oSerConstants.ReadOk;
var oThis = this; var oThis = this;
if( c_oSer_tblpPrType2.HorzAnchor === type ) if( c_oSer_tblpPrType2.HorzAnchor === type )
table.PositionH.RelativeFrom = this.stream.GetUChar(); oAdditionalPr.HRelativeFrom = this.stream.GetUChar();
else if( c_oSer_tblpPrType2.TblpX === type ) else if( c_oSer_tblpPrType2.TblpX === type )
{ {
table.PositionH.Align = false; oAdditionalPr.HAlign = false;
table.PositionH.Value = this.bcr.ReadDouble(); oAdditionalPr.HValue = this.bcr.ReadDouble();
} }
else if( c_oSer_tblpPrType2.TblpXSpec === type ) else if( c_oSer_tblpPrType2.TblpXSpec === type )
{ {
table.PositionH.Align = true; oAdditionalPr.HAlign = true;
table.PositionH.Value = this.stream.GetUChar(); oAdditionalPr.HValue = this.stream.GetUChar();
} }
else if( c_oSer_tblpPrType2.VertAnchor === type ) else if( c_oSer_tblpPrType2.VertAnchor === type )
table.PositionV.RelativeFrom = this.stream.GetUChar(); oAdditionalPr.VRelativeFrom = this.stream.GetUChar();
else if( c_oSer_tblpPrType2.TblpY === type ) else if( c_oSer_tblpPrType2.TblpY === type )
{ {
table.PositionV.Align = false; oAdditionalPr.VAlign = false;
table.PositionV.Value = this.bcr.ReadDouble(); oAdditionalPr.VValue = this.bcr.ReadDouble();
} }
else if( c_oSer_tblpPrType2.TblpYSpec === type ) else if( c_oSer_tblpPrType2.TblpYSpec === type )
{ {
table.PositionV.Align = true; oAdditionalPr.VAlign = true;
table.PositionV.Value = this.stream.GetUChar(); oAdditionalPr.VValue = this.stream.GetUChar();
} }
else if( c_oSer_tblpPrType2.Paddings === type ) else if( c_oSer_tblpPrType2.Paddings === type )
{ {
oAdditionalPr.Distance = {L: 0, T: 0, R: 0, B:0};
res = this.bcr.Read2(length, function(t, l){ res = this.bcr.Read2(length, function(t, l){
return oThis.ReadPaddings2(t, l, table.Distance); return oThis.ReadPaddings2(t, l, oAdditionalPr.Distance);
}); });
} }
else else
...@@ -4823,48 +4846,14 @@ function Binary_NumberingTableReader(doc, oReadResult, stream) ...@@ -4823,48 +4846,14 @@ function Binary_NumberingTableReader(doc, oReadResult, stream)
if ( c_oSerNumTypes.AbstractNum === type ) if ( c_oSerNumTypes.AbstractNum === type )
{ {
var oNewAbstractNum = new CAbstractNum(); var oNewAbstractNum = new CAbstractNum();
this.PrepareANumPre(oNewAbstractNum);
res = this.bcr.Read1(length, function(t, l){ res = this.bcr.Read1(length, function(t, l){
return oThis.ReadAbstractNum(t, l, oNewAbstractNum); return oThis.ReadAbstractNum(t, l, oNewAbstractNum);
}); });
this.PrepareANumPost(oNewAbstractNum);
} }
else else
res = c_oSerConstants.ReadUnknown; res = c_oSerConstants.ReadUnknown;
return res; return res;
}, },
this.PrepareANumPre = function(num)
{
if(null != num)
{
for(var i = 0, length = num.Lvl.length; i < length; ++i)
{
var lvl = num.Lvl[i];
//сбрасываем FirstLine indent
if(null != lvl.ParaPr && null != lvl.ParaPr.Ind)
lvl.ParaPr.Ind.FirstLine = 0;
//пустые текстовые настройки
lvl.TextPr = new CTextPr();
}
}
},
this.PrepareANumPost = function(num)
{
//выставляем шрифт Times New Roman для всех не bullet списков
if(null != num)
{
for(var i = 0, length = num.Lvl.length; i < length; ++i)
{
var lvl = num.Lvl[i];
var lvl_TextPr = lvl.TextPr;
if(numbering_numfmt_Bullet == lvl.Format && null == lvl_TextPr.FontFamily)
{
//для bullet списков надо выставлять шрифт, для number шрифт возьмется из символа параграфа.
lvl_TextPr.FontFamily = { Name : "Symbol", Index : -1 };
}
}
}
},
this.ReadAbstractNum = function(type, length, oNewNum) this.ReadAbstractNum = function(type, length, oNewNum)
{ {
var oThis = this; var oThis = this;
...@@ -4873,9 +4862,7 @@ function Binary_NumberingTableReader(doc, oReadResult, stream) ...@@ -4873,9 +4862,7 @@ function Binary_NumberingTableReader(doc, oReadResult, stream)
{ {
var nLevelNum = 0; var nLevelNum = 0;
res = this.bcr.Read1(length, function(t, l){ res = this.bcr.Read1(length, function(t, l){
var resres = oThis.ReadLevels(t, l, oNewNum.Lvl, nLevelNum); return oThis.ReadLevels(t, l, nLevelNum++, oNewNum);
nLevelNum++;
return resres;
}); });
} }
else if ( c_oSerNumTypes.AbstractNum_Id === type ) else if ( c_oSerNumTypes.AbstractNum_Id === type )
...@@ -4883,28 +4870,36 @@ function Binary_NumberingTableReader(doc, oReadResult, stream) ...@@ -4883,28 +4870,36 @@ function Binary_NumberingTableReader(doc, oReadResult, stream)
this.m_oANumToNumClass[this.stream.GetULongLE()] = oNewNum; this.m_oANumToNumClass[this.stream.GetULongLE()] = oNewNum;
//oNewNum.Id = this.stream.GetULongLE(); //oNewNum.Id = this.stream.GetULongLE();
} }
else if ( c_oSerNumTypes.AbstractNum_Type === type )
{
oNewNum.Type = this.stream.GetUChar();
}
else else
res = c_oSerConstants.ReadUnknown; res = c_oSerConstants.ReadUnknown;
return res; return res;
} }
this.ReadLevels = function(type, length, aLvls, nLevelNum) this.ReadLevels = function(type, length, nLevelNum, oNewNum)
{ {
var oThis = this; var oThis = this;
var res = c_oSerConstants.ReadOk; var res = c_oSerConstants.ReadOk;
if ( c_oSerNumTypes.Lvl === type ) if ( c_oSerNumTypes.Lvl === type )
{ {
if(nLevelNum >= aLvls.length) if(nLevelNum < oNewNum.Lvl.length)
aLvls[nLevelNum] = new Object(); {
oNewLvl = aLvls[nLevelNum]; var oOldLvl = oNewNum.Lvl[nLevelNum];
//обнуляем свойства var oNewLvl = oNewNum.Internal_CopyLvl( oOldLvl );
//сбрасываем свойства
oNewLvl.ParaPr = new CParaPr(); oNewLvl.ParaPr = new CParaPr();
oNewLvl.TextPr = new CTextPr();
res = this.bcr.Read2(length, function(t, l){ res = this.bcr.Read2(length, function(t, l){
return oThis.ReadLevel(t, l, oNewLvl); return oThis.ReadLevel(t, l, oNewLvl);
}); });
//для bullet списков надо выставлять шрифт, для number шрифт возьмется из символа параграфа.
if(numbering_numfmt_Bullet == oNewLvl.Format && null == oNewLvl.TextPr.RFonts.Ascii)
oNewLvl.TextPr.RFonts.Set_All( "Symbol", -1 );
oNewNum.Lvl[nLevelNum] = oNewLvl;
this.oReadResult.aPostOpenStyleNumCallbacks.push(function(){
oNewNum.Set_Lvl(nLevelNum, oNewLvl);
});
}
else
res = c_oSerConstants.ReadUnknown;
} }
else else
res = c_oSerConstants.ReadUnknown; res = c_oSerConstants.ReadUnknown;
...@@ -4947,14 +4942,10 @@ function Binary_NumberingTableReader(doc, oReadResult, stream) ...@@ -4947,14 +4942,10 @@ function Binary_NumberingTableReader(doc, oReadResult, stream)
} }
else if ( c_oSerNumTypes.lvl_ParaPr === type ) else if ( c_oSerNumTypes.lvl_ParaPr === type )
{ {
if(null == oNewLvl.ParaPr)
oNewLvl.ParaPr = new CParaPr();
res = this.bpPrr.Read(length, oNewLvl.ParaPr, null); res = this.bpPrr.Read(length, oNewLvl.ParaPr, null);
} }
else if ( c_oSerNumTypes.lvl_TextPr === type ) else if ( c_oSerNumTypes.lvl_TextPr === type )
{ {
if(null == oNewLvl.TextPr)
oNewLvl.TextPr = new CTextPr();
res = this.brPrr.Read(length, oNewLvl.TextPr); res = this.brPrr.Read(length, oNewLvl.TextPr);
} }
else else
...@@ -5147,11 +5138,11 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow ...@@ -5147,11 +5138,11 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
res = this.bcr.Read1(length, function(t, l){ res = this.bcr.Read1(length, function(t, l){
return oThis.ReadParagraph(t,l, oNewParagraph, oNewObject, Content); return oThis.ReadParagraph(t,l, oNewParagraph, oNewObject, Content);
}); });
if(null != oNewParagraph.TextPr) for(var i = oNewObject.Content.length - 1; i >= 0; --i)
oNewObject.Content.push(new ParaTextPr(oNewParagraph.TextPr.Value)); {
else if(true == oNewObject.bExistrPr) var elem = oNewObject.Content[i];
oNewObject.Content.push(new ParaTextPr()); oNewParagraph.Internal_Content_Add(0, elem);
oNewParagraph.Content = oNewObject.Content.concat(oNewParagraph.Content); }
//Prev/Next //Prev/Next
if(null != this.lastPar) if(null != this.lastPar)
{ {
...@@ -5164,7 +5155,7 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow ...@@ -5164,7 +5155,7 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
else if ( c_oSerParType.Table === type ) else if ( c_oSerParType.Table === type )
{ {
var doc = this.Document; var doc = this.Document;
var oNewTable = new CTable(doc.DrawingDocument, doc, true, 0, 0, 0, X_Left_Field, Y_Bottom_Field, 1, 1, []); var oNewTable = new CTable(doc.DrawingDocument, doc, true, 0, 0, 0, X_Left_Field, Y_Bottom_Field, 0, 0, []);
res = this.bcr.Read1(length, function(t, l){ res = this.bcr.Read1(length, function(t, l){
return oThis.ReadDocTable(t, l, oNewTable); return oThis.ReadDocTable(t, l, oNewTable);
}); });
...@@ -5263,29 +5254,23 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow ...@@ -5263,29 +5254,23 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
res = c_oSerConstants.ReadUnknown; res = c_oSerConstants.ReadUnknown;
return res; return res;
}; };
this.AddPages = function(doc, startIndex, endIndex)
{
var PageNum = startIndex;
while (endIndex >= PageNum)
{
doc.Pages.push({FlowObjects:new FlowObjects(doc, PageNum),Pos:0,X:0,Y:0,XLimit:0,YLimit:0,Bounds:{Left:0,Top:0,Right:0,Bottom:0}});
PageNum++;
}
}
this.ReadParagraph = function(type, length, paragraph, oNewObject, Content) this.ReadParagraph = function(type, length, paragraph, oNewObject, Content)
{ {
var res = c_oSerConstants.ReadOk; var res = c_oSerConstants.ReadOk;
var oThis = this; var oThis = this;
if ( c_oSerParType.pPr === type ) if ( c_oSerParType.pPr === type )
{ {
res = this.bpPrr.Read(length, paragraph.Pr, paragraph); var oNewParaPr = new CParaPr();
res = this.bpPrr.Read(length, oNewParaPr, paragraph);
paragraph.Pr = oNewParaPr;
this.oReadResult.aPostOpenStyleNumCallbacks.push(function(){
paragraph.Set_Pr(oNewParaPr);
});
} }
else if ( c_oSerParType.Content === type ) else if ( c_oSerParType.Content === type )
{ {
var oThisParagraph = paragraph;
var oThisNewObject = oNewObject;
res = this.bcr.Read1(length, function(t, l){ res = this.bcr.Read1(length, function(t, l){
return oThis.ReadParagraphContent(t,l,oThisNewObject, oThisParagraph, Content); return oThis.ReadParagraphContent(t,l,oNewObject, paragraph, Content);
}); });
} }
else else
...@@ -5305,9 +5290,7 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow ...@@ -5305,9 +5290,7 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
if(null != oRunObject.rPr) if(null != oRunObject.rPr)
{ {
oNewObject.bExistrPr = true; oNewObject.bExistrPr = true;
var oNewParaTextPr = new ParaTextPr(); oNewObject.Content.push(new ParaTextPr(oRunObject.rPr));
oNewParaTextPr.Value = oRunObject.rPr;
oNewObject.Content.push(oNewParaTextPr);
} }
else if(oNewObject.bExistrPr) else if(oNewObject.bExistrPr)
oNewObject.Content.push(new ParaTextPr()); oNewObject.Content.push(new ParaTextPr());
...@@ -5370,7 +5353,6 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow ...@@ -5370,7 +5353,6 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
{ {
oRunObject.rPr = new CTextPr(); oRunObject.rPr = new CTextPr();
res = this.brPrr.Read(length, oRunObject.rPr); res = this.brPrr.Read(length, oRunObject.rPr);
//Content.push( new ParaTextPr( oNew_rPr ) );
} }
else if (c_oSerRunType.Content === type) else if (c_oSerRunType.Content === type)
{ {
...@@ -5422,7 +5404,7 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow ...@@ -5422,7 +5404,7 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
else if(c_oSerRunType.image === type) else if(c_oSerRunType.image === type)
{ {
var oThis = this; var oThis = this;
var image = new Object(); var image = {page: null, Type: null, MediaId: null, W: null, H: null, X: null, Y: null, Paddings: null};
res = this.bcr.Read2(length, function(t, l){ res = this.bcr.Read2(length, function(t, l){
return oThis.ReadImage(t,l, image); return oThis.ReadImage(t,l, image);
}); });
...@@ -5436,20 +5418,11 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow ...@@ -5436,20 +5418,11 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
Image.init( src, image.W, image.H, null ); Image.init( src, image.W, image.H, null );
if(c_oAscWrapStyle.Flow == image.Type) if(c_oAscWrapStyle.Flow == image.Type)
{ {
drawing.DrawingType = drawing_Anchor; drawing.Set_DrawingType(drawing_Anchor);
drawing.PositionH.RelativeFrom = c_oAscRelativeFromH.Page; drawing.Set_PositionH(c_oAscRelativeFromH.Page, false, image.X);
drawing.PositionH.Align = false; drawing.Set_PositionV(c_oAscRelativeFromV.Page, false, image.Y);
drawing.PositionH.Value = image.X;
drawing.PositionV.RelativeFrom = c_oAscRelativeFromV.Page;
drawing.PositionV.Align = false;
drawing.PositionV.Value = image.Y;
if(image.Paddings) if(image.Paddings)
{ drawing.Set_Distance(image.Paddings.Left, image.Paddings.Top, image.Paddings.Right, image.Paddings.Bottom);
drawing.Distance.L = image.Paddings.Left;
drawing.Distance.T = image.Paddings.Top;
drawing.Distance.R = image.Paddings.Right;
drawing.Distance.B = image.Paddings.Bottom;
}
History.RecalcData_Add( { Type : historyrecalctype_Flow, Data : drawing}); History.RecalcData_Add( { Type : historyrecalctype_Flow, Data : drawing});
} }
//Copy вызывется только, потому что обьект создавался по пустому конструктору, а в нем могли совершаться какие-то операции над членами. //Copy вызывется только, потому что обьект создавался по пустому конструктору, а в нем могли совершаться какие-то операции над членами.
...@@ -5466,20 +5439,15 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow ...@@ -5466,20 +5439,15 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
{ {
var doc = this.Document; var doc = this.Document;
var oParaDrawing = new ParaDrawing(null, null, null, doc.DrawingDocument, doc, paragraph); var oParaDrawing = new ParaDrawing(null, null, null, doc.DrawingDocument, doc, paragraph);
var oChartObject = {chart: null};
res = this.bcr.Read2(length, function(t, l){ res = this.bcr.Read2(length, function(t, l){
return oThis.ReadPptxDrawing(t, l, oParaDrawing, oChartObject); return oThis.ReadPptxDrawing(t, l, oParaDrawing);
}); });
if(null != oParaDrawing.chart && null != oParaDrawing.Extent.W && null != oParaDrawing.Extent.H) if(null != oParaDrawing.SimplePos)
{ oParaDrawing.setSimplePos(oParaDrawing.SimplePos.Use, oParaDrawing.SimplePos.X, oParaDrawing.SimplePos.Y);
oParaDrawing.chart.width = oParaDrawing.Extent.W * g_dKoef_mm_to_pix; if(null != oParaDrawing.Extent)
oParaDrawing.chart.height = oParaDrawing.Extent.H * g_dKoef_mm_to_pix; oParaDrawing.setExtent(oParaDrawing.Extent.W, oParaDrawing.Extent.H);
var doc = this.Document; if(null != oParaDrawing.wrappingPolygon)
/*var Image = new WordImage( oParaDrawing, doc, doc.DrawingDocument, null ); oParaDrawing.addWrapPolygon(oParaDrawing.wrappingPolygon);
Image.init( null, oParaDrawing.Extent.W, oParaDrawing.Extent.H, oChartObject.chart );*/
window.global_pptx_content_loader.ImageMapChecker[oParaDrawing.chart.img] = true;
}
//Copy вызывется только, потому что обьект создавался по пустому конструктору, а в нем могли совершаться какие-то операции над членами.
editor.WordControl.m_oLogicDocument.DrawingObjects.arrForCalculateAfterOpen.push(oParaDrawing); editor.WordControl.m_oLogicDocument.DrawingObjects.arrForCalculateAfterOpen.push(oParaDrawing);
oParaDrawing.init(); oParaDrawing.init();
if(drawing_Anchor == oParaDrawing.DrawingType) if(drawing_Anchor == oParaDrawing.DrawingType)
...@@ -5490,7 +5458,7 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow ...@@ -5490,7 +5458,7 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
else if(c_oSerRunType.table === type) else if(c_oSerRunType.table === type)
{ {
var doc = this.Document; var doc = this.Document;
var oNewTable = new CTable(doc.DrawingDocument, doc, true, 0, 0, 0, X_Left_Field, Y_Bottom_Field, 1, 1, []); var oNewTable = new CTable(doc.DrawingDocument, doc, true, 0, 0, 0, X_Left_Field, Y_Bottom_Field, 0, 0, []);
res = this.bcr.Read1(length, function(t, l){ res = this.bcr.Read1(length, function(t, l){
return oThis.ReadDocTable(t, l, oNewTable); return oThis.ReadDocTable(t, l, oNewTable);
}); });
...@@ -5657,36 +5625,43 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow ...@@ -5657,36 +5625,43 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
res = c_oSerConstants.ReadUnknown; res = c_oSerConstants.ReadUnknown;
return res; return res;
}; };
this.ReadPptxDrawing = function(type, length, oParaDrawing, oChartObject) this.ReadPptxDrawing = function(type, length, oParaDrawing)
{ {
var res = c_oSerConstants.ReadOk; var res = c_oSerConstants.ReadOk;
var oThis = this; var oThis = this;
if( c_oSerImageType2.Type === type ) if( c_oSerImageType2.Type === type )
{ {
var nDrawingType = null;
switch(this.stream.GetUChar()) switch(this.stream.GetUChar())
{ {
case c_oAscWrapStyle.Inline: oParaDrawing.DrawingType = drawing_Inline;break; case c_oAscWrapStyle.Inline: nDrawingType = drawing_Inline;break;
case c_oAscWrapStyle.Flow: oParaDrawing.DrawingType = drawing_Anchor;break; case c_oAscWrapStyle.Flow: nDrawingType = drawing_Anchor;break;
} }
if(null != nDrawingType)
oParaDrawing.Set_DrawingType(nDrawingType);
} }
else if( c_oSerImageType2.PptxData === type ) else if( c_oSerImageType2.PptxData === type )
{ {
var grObject = window.global_pptx_content_loader.ReadDrawing(this, this.stream, this.Document, oParaDrawing); var grObject = window.global_pptx_content_loader.ReadDrawing(this, this.stream, this.Document, oParaDrawing);
oParaDrawing.GraphicObj = grObject; oParaDrawing.Set_GraphicObject(grObject);
} }
else if( c_oSerImageType2.Chart === type ) else if( c_oSerImageType2.Chart === type )
{ {
oParaDrawing.GraphicObj = new CChartAsGroup(); var oNewGraphicObj = new CChartAsGroup();
var chart = oParaDrawing.GraphicObj.chart; var chart = new asc_CChart();;
var oBinary_ChartReader = new Binary_ChartReader(this.stream, chart, oParaDrawing.GraphicObj); var oBinary_ChartReader = new Binary_ChartReader(this.stream, chart, oNewGraphicObj);
oBinary_ChartReader.ReadExternal(length); oBinary_ChartReader.ReadExternal(length);
if(null != chart.range.interval) if(null != chart.range.interval)
oChartObject.chart = chart; {
oNewGraphicObj.chart = chart;
//oNewGraphicObj.setChart(chart, true);
oParaDrawing.Set_GraphicObject(oNewGraphicObj);
}
} }
else if( c_oSerImageType2.AllowOverlap === type ) else if( c_oSerImageType2.AllowOverlap === type )
var AllowOverlap = this.stream.GetBool(); var AllowOverlap = this.stream.GetBool();
else if( c_oSerImageType2.BehindDoc === type ) else if( c_oSerImageType2.BehindDoc === type )
oParaDrawing.behindDoc = this.stream.GetBool(); oParaDrawing.Set_BehindDoc(this.stream.GetBool());
else if( c_oSerImageType2.DistL === type ) else if( c_oSerImageType2.DistL === type )
oParaDrawing.Distance.L = this.bcr.ReadDouble(); oParaDrawing.Distance.L = this.bcr.ReadDouble();
else if( c_oSerImageType2.DistT === type ) else if( c_oSerImageType2.DistT === type )
...@@ -5697,12 +5672,14 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow ...@@ -5697,12 +5672,14 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
oParaDrawing.Distance.B = this.bcr.ReadDouble(); oParaDrawing.Distance.B = this.bcr.ReadDouble();
else if( c_oSerImageType2.Hidden === type ) else if( c_oSerImageType2.Hidden === type )
var Hidden = this.stream.GetBool(); var Hidden = this.stream.GetBool();
else if( c_oSerImageType2.LayoutInCell === type ) // else if( c_oSerImageType2.LayoutInCell === type )
oParaDrawing.LayoutInCell = this.stream.GetBool(); // {
// oParaDrawing.LayoutInCell = this.stream.GetBool();
// }
else if( c_oSerImageType2.Locked === type ) else if( c_oSerImageType2.Locked === type )
var Locked = this.stream.GetBool(); var Locked = this.stream.GetBool();
else if( c_oSerImageType2.RelativeHeight === type ) else if( c_oSerImageType2.RelativeHeight === type )
oParaDrawing.RelativeHeight = this.stream.GetULongLE(); oParaDrawing.setZIndex2(this.stream.GetULongLE());
else if( c_oSerImageType2.BSimplePos === type ) else if( c_oSerImageType2.BSimplePos === type )
oParaDrawing.SimplePos.Use = this.stream.GetBool(); oParaDrawing.SimplePos.Use = this.stream.GetBool();
else if( c_oSerImageType2.EffectExtent === type ) else if( c_oSerImageType2.EffectExtent === type )
...@@ -5720,15 +5697,27 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow ...@@ -5720,15 +5697,27 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
} }
else if( c_oSerImageType2.PositionH === type ) else if( c_oSerImageType2.PositionH === type )
{ {
var oNewPositionH = {
RelativeFrom : c_oAscRelativeFromH.Column, // Относительно чего вычисляем координаты
Align : false, // true : В поле Value лежит тип прилегания, false - в поле Value лежит точное значени
Value : 0 //
};
res = this.bcr.Read2(length, function(t, l){ res = this.bcr.Read2(length, function(t, l){
return oThis.ReadPositionHV(t, l, oParaDrawing.PositionH); return oThis.ReadPositionHV(t, l, oNewPositionH);
}); });
oParaDrawing.Set_PositionH(oNewPositionH.RelativeFrom , oNewPositionH.Align , oNewPositionH.Value);
} }
else if( c_oSerImageType2.PositionV === type ) else if( c_oSerImageType2.PositionV === type )
{ {
var oNewPositionV = {
RelativeFrom : c_oAscRelativeFromV.Paragraph, // Относительно чего вычисляем координаты
Align : false, // true : В поле Value лежит тип прилегания, false - в поле Value лежит точное значени
Value : 0 //
};
res = this.bcr.Read2(length, function(t, l){ res = this.bcr.Read2(length, function(t, l){
return oThis.ReadPositionHV(t, l, oParaDrawing.PositionV); return oThis.ReadPositionHV(t, l, oNewPositionV);
}); });
oParaDrawing.Set_PositionV(oNewPositionV.RelativeFrom , oNewPositionV.Align , oNewPositionV.Value);
} }
else if( c_oSerImageType2.SimplePos === type ) else if( c_oSerImageType2.SimplePos === type )
{ {
...@@ -5738,32 +5727,32 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow ...@@ -5738,32 +5727,32 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
} }
else if( c_oSerImageType2.WrapNone === type ) else if( c_oSerImageType2.WrapNone === type )
{ {
oParaDrawing.wrappingType = WRAPPING_TYPE_NONE; oParaDrawing.Set_WrappingType(WRAPPING_TYPE_NONE);
} }
else if( c_oSerImageType2.WrapSquare === type ) else if( c_oSerImageType2.WrapSquare === type )
{ {
oParaDrawing.wrappingType = WRAPPING_TYPE_SQUARE; oParaDrawing.Set_WrappingType(WRAPPING_TYPE_SQUARE);
res = this.bcr.Read2(length, function(t, l){ res = this.bcr.Read2(length, function(t, l){
return oThis.ReadWrapSquare(t, l, oParaDrawing.wrappingPolygon); return oThis.ReadWrapSquare(t, l, oParaDrawing.wrappingPolygon);
}); });
} }
else if( c_oSerImageType2.WrapThrough === type ) else if( c_oSerImageType2.WrapThrough === type )
{ {
oParaDrawing.wrappingType = WRAPPING_TYPE_THROUGH; oParaDrawing.Set_WrappingType(WRAPPING_TYPE_THROUGH);
res = this.bcr.Read2(length, function(t, l){ res = this.bcr.Read2(length, function(t, l){
return oThis.ReadWrapThroughTight(t, l, oParaDrawing.wrappingPolygon); return oThis.ReadWrapThroughTight(t, l, oParaDrawing.wrappingPolygon);
}); });
} }
else if( c_oSerImageType2.WrapTight === type ) else if( c_oSerImageType2.WrapTight === type )
{ {
oParaDrawing.wrappingType = WRAPPING_TYPE_TIGHT; oParaDrawing.Set_WrappingType(WRAPPING_TYPE_TIGHT);
res = this.bcr.Read2(length, function(t, l){ res = this.bcr.Read2(length, function(t, l){
return oThis.ReadWrapThroughTight(t, l, oParaDrawing.wrappingPolygon); return oThis.ReadWrapThroughTight(t, l, oParaDrawing.wrappingPolygon);
}); });
} }
else if( c_oSerImageType2.WrapTopAndBottom === type ) else if( c_oSerImageType2.WrapTopAndBottom === type )
{ {
oParaDrawing.wrappingType = WRAPPING_TYPE_TOP_AND_BOTTOM; oParaDrawing.Set_WrappingType(WRAPPING_TYPE_TOP_AND_BOTTOM);
res = this.bcr.Read2(length, function(t, l){ res = this.bcr.Read2(length, function(t, l){
return oThis.ReadWrapThroughTight(t, l, oParaDrawing.wrappingPolygon); return oThis.ReadWrapThroughTight(t, l, oParaDrawing.wrappingPolygon);
}); });
...@@ -5956,24 +5945,31 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow ...@@ -5956,24 +5945,31 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
var oThis = this; var oThis = this;
if( c_oSerDocTableType.tblPr === type ) if( c_oSerDocTableType.tblPr === type )
{ {
table.Set_TableStyle(null); table.Set_TableStyle2(null);
var oNewTablePr = new CTablePr();
res = this.bcr.Read1(length, function(t, l){ res = this.bcr.Read1(length, function(t, l){
return oThis.btblPrr.Read_tblPr(t,l, table.Pr, table); return oThis.btblPrr.Read_tblPr(t,l, oNewTablePr, table);
});
table.Pr = oNewTablePr;
this.oReadResult.aPostOpenStyleNumCallbacks.push(function(){
table.Set_Pr(oNewTablePr);
}); });
} }
else if( c_oSerDocTableType.tblGrid === type ) else if( c_oSerDocTableType.tblGrid === type )
{ {
table.TableGrid = new Array(); var aNewGrid = [];
res = this.bcr.Read2(length, function(t, l){ res = this.bcr.Read2(length, function(t, l){
return oThis.Read_tblGrid(t,l, table.TableGrid); return oThis.Read_tblGrid(t,l, aNewGrid);
}); });
table.Internal_SaveTableGridInHistory(aNewGrid, table.TableGrid);
table.TableGrid = aNewGrid;
} }
else if( c_oSerDocTableType.Content === type ) else if( c_oSerDocTableType.Content === type )
{ {
table.Content = new Array();
res = this.bcr.Read1(length, function(t, l){ res = this.bcr.Read1(length, function(t, l){
return oThis.Read_TableContent(t, l, table); return oThis.Read_TableContent(t, l, table);
}); });
if(table.Content.length > 0)
table.CurCell = table.Content[0].Get_Cell( 0 ); table.CurCell = table.Content[0].Get_Cell( 0 );
} }
else else
...@@ -5998,11 +5994,10 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow ...@@ -5998,11 +5994,10 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
var Content = table.Content; var Content = table.Content;
if( c_oSerDocTableType.Row === type ) if( c_oSerDocTableType.Row === type )
{ {
var oRow = new CTableRow( table, 0 ); var row = table.Internal_Add_Row(table.Content.length, 0);
res = this.bcr.Read1(length, function(t, l){ res = this.bcr.Read1(length, function(t, l){
return oThis.Read_Row(t, l, oRow); return oThis.Read_Row(t, l, row);
}); });
Content.push(oRow);
} }
else else
res = c_oSerConstants.ReadUnknown; res = c_oSerConstants.ReadUnknown;
...@@ -6014,15 +6009,14 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow ...@@ -6014,15 +6009,14 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
var oThis = this; var oThis = this;
if( c_oSerDocTableType.Row_Pr === type ) if( c_oSerDocTableType.Row_Pr === type )
{ {
if(null == Row.Pr) var oNewRowPr = new CTableRowPr();
Row.Pr = new Object();
res = this.bcr.Read2(length, function(t, l){ res = this.bcr.Read2(length, function(t, l){
return oThis.btblPrr.Read_RowPr(t, l, Row.Pr); return oThis.btblPrr.Read_RowPr(t, l, oNewRowPr);
}); });
Row.Set_Pr(oNewRowPr);
} }
else if( c_oSerDocTableType.Row_Content === type ) else if( c_oSerDocTableType.Row_Content === type )
{ {
Row.Content = new Array();
res = this.bcr.Read1(length, function(t, l){ res = this.bcr.Read1(length, function(t, l){
return oThis.ReadRowContent(t, l, Row); return oThis.ReadRowContent(t, l, Row);
}); });
...@@ -6038,11 +6032,10 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow ...@@ -6038,11 +6032,10 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
var Content = row.Content; var Content = row.Content;
if( c_oSerDocTableType.Cell === type ) if( c_oSerDocTableType.Cell === type )
{ {
var oCell = new CTableCell( row ); var oCell = row.Add_Cell(row.Get_CellsCount(), row, null, false);
res = this.bcr.Read1(length, function(t, l){ res = this.bcr.Read1(length, function(t, l){
return oThis.ReadCell(t, l, oCell); return oThis.ReadCell(t, l, oCell);
}); });
Content.push(oCell);
} }
else else
res = c_oSerConstants.ReadUnknown; res = c_oSerConstants.ReadUnknown;
...@@ -6054,15 +6047,22 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow ...@@ -6054,15 +6047,22 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
var oThis = this; var oThis = this;
if( c_oSerDocTableType.Cell_Pr === type ) if( c_oSerDocTableType.Cell_Pr === type )
{ {
var oNewCellPr = new CTableCellPr();
res = this.bcr.Read2(length, function(t, l){ res = this.bcr.Read2(length, function(t, l){
return oThis.btblPrr.Read_CellPr(t, l, cell.Pr); return oThis.btblPrr.Read_CellPr(t, l, oNewCellPr);
}); });
cell.Set_Pr(oNewCellPr);
} }
else if( c_oSerDocTableType.Cell_Content === type ) else if( c_oSerDocTableType.Cell_Content === type )
{ {
cell.Content.Content = new Array(); var oCellContent = new Array();
var oCellContentReader = new Binary_DocumentTableReader(cell.Content, this.oReadResult, this.openParams, this.stream, false, this.oComments); var oCellContentReader = new Binary_DocumentTableReader(cell.Content, this.oReadResult, this.openParams, this.stream, false, this.oComments);
oCellContentReader.Read(length, cell.Content.Content); oCellContentReader.Read(length, oCellContent);
for(var i = 0, length = oCellContent.length; i < length; ++i)
cell.Content.Internal_Content_Add(i + 1, oCellContent[i]);
cell.Content.Internal_Content_Remove(0, 1);
} }
else else
res = c_oSerConstants.ReadUnknown; res = c_oSerConstants.ReadUnknown;
......
...@@ -19705,7 +19705,7 @@ CTableCell.prototype = ...@@ -19705,7 +19705,7 @@ CTableCell.prototype =
Set_Pr : function(CellPr) Set_Pr : function(CellPr)
{ {
History.Add( this, { Type : historyitem_TableCell_Pr, Old : this.Pr, New : RowPr } ); History.Add( this, { Type : historyitem_TableCell_Pr, Old : this.Pr, New : CellPr } );
this.Pr = CellPr; this.Pr = CellPr;
this.Recalc_CompiledPr(); this.Recalc_CompiledPr();
}, },
......
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