Commit 24276cfb authored by Sergey.Konovalov's avatar Sergey.Konovalov

проблема с merge default стилей и стилей из файла.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@51984 954022d7-b5bf-4e40-9824-e11837661b57
parent f947db01
...@@ -4424,7 +4424,8 @@ function BinaryFileReader(doc, openParams) ...@@ -4424,7 +4424,8 @@ function BinaryFileReader(doc, openParams)
if(style && style.Name) if(style && style.Name)
aStartDocStylesNames[style.Name.toLowerCase().replace(/\s/g,"")] = style; aStartDocStylesNames[style.Name.toLowerCase().replace(/\s/g,"")] = style;
} }
//стили //запоминаем стили которые надо заменить
var oIdRenameMap = {};
for(var i in this.oReadResult.styles) for(var i in this.oReadResult.styles)
{ {
var elem = this.oReadResult.styles[i]; var elem = this.oReadResult.styles[i];
...@@ -4440,46 +4441,67 @@ function BinaryFileReader(doc, openParams) ...@@ -4440,46 +4441,67 @@ function BinaryFileReader(doc, openParams)
if(oStartDocStyle) if(oStartDocStyle)
{ {
var stId = oStartDocStyle.Get_Id(); var stId = oStartDocStyle.Get_Id();
oNewStyle.Name = oStartDocStyle.Name; oNewStyle.Name = oStartDocStyle.Name;
for(var stId2 in styles) oIdRenameMap[stId] = {id: oNewId.id, def: oNewId.def, type: oNewStyle.Type, newName: sNewStyleName};
{ delete styles[stId];
var stObj2 = styles[stId2]; }
if (stObj2.BasedOn == stId) var oCollisionStyle = styles[oNewId.id];
stObj2.BasedOn = oNewId.id; if(oCollisionStyle)
if (stObj2.Next == stId) {
stObj2.Next = oNewId.id; var sOldId = oCollisionStyle.Get_Id();
} var nCounter = 1;
if(stDefault.Paragraph == stId) var sNewId = sOldId + "_" + nCounter;
stDefault.Paragraph = oNewId.id; while(null != styles[sNewId] || null != this.oReadResult.styles[sNewId])
if(stDefault.Numbering == stId) {
stDefault.Numbering = oNewId.id; nCounter++;
if(stDefault.Table == stId) sNewId = sOldId + "_" + nCounter;
stDefault.Table = oNewId.id; }
for(var j = 0, length2 = stDefault.Headings.length; j < length2; ++j) var oNewId = {id: sNewId, def: false, type: oCollisionStyle.Type, newName: sNewStyleName};
{ oIdRenameMap[sOldId] = oNewId;
var sHeading = stDefault.Headings[j]; if(stDefault.Numbering == sOldId || stDefault.Paragraph == sOldId || stDefault.Table == sOldId)
if(sHeading == stId) oNewId.def = true;
stDefault.Headings[j] = oNewId.id; oCollisionStyle.Set_Id(sNewId);
} delete styles[sOldId];
if(stDefault.ParaList == stId) styles[sNewId] = oCollisionStyle;
stDefault.ParaList = oNewId.id; }
if(stDefault.Header == stId) }
stDefault.Header = oNewId.id; //меняем старые id
if(stDefault.Footer == stId) for(var sOldId in oIdRenameMap)
stDefault.Footer = oNewId.id; {
if(stDefault.Hyperlink == stId) var oNewId = oIdRenameMap[sOldId];
stDefault.Hyperlink = oNewId.id; var sNewStyleName = oNewId.newName;
delete styles[stId]; var stId = sOldId;
for(var stId2 in styles)
{
var stObj2 = styles[stId2];
if (stObj2.BasedOn == stId)
stObj2.BasedOn = oNewId.id;
if (stObj2.Next == stId)
stObj2.Next = oNewId.id;
}
if(stDefault.Paragraph == stId)
stDefault.Paragraph = oNewId.id;
if(stDefault.Numbering == stId)
stDefault.Numbering = oNewId.id;
if(stDefault.Table == stId)
stDefault.Table = oNewId.id;
for(var j = 0, length2 = stDefault.Headings.length; j < length2; ++j)
{
var sHeading = stDefault.Headings[j];
if(sHeading == stId)
stDefault.Headings[j] = oNewId.id;
} }
if("header" == sNewStyleName) if(stDefault.ParaList == stId)
stDefault.ParaList = oNewId.id;
if(stDefault.Header == stId || "header" == sNewStyleName)
stDefault.Header = oNewId.id; stDefault.Header = oNewId.id;
if("footer" == sNewStyleName) if(stDefault.Footer == stId || "footer" == sNewStyleName)
stDefault.Footer = oNewId.id; stDefault.Footer = oNewId.id;
if("hyperlink" == sNewStyleName) if(stDefault.Hyperlink == stId || "hyperlink" == sNewStyleName)
stDefault.Hyperlink = oNewId.id; stDefault.Hyperlink = oNewId.id;
if(true == oNewId.def) if(true == oNewId.def)
{ {
switch(oNewStyle.Type) switch(oNewId.type)
{ {
case styletype_Character:break; case styletype_Character:break;
case styletype_Numbering:stDefault.Numbering = oNewId.id;break; case styletype_Numbering:stDefault.Numbering = oNewId.id;break;
...@@ -4487,7 +4509,14 @@ function BinaryFileReader(doc, openParams) ...@@ -4487,7 +4509,14 @@ function BinaryFileReader(doc, openParams)
case styletype_Table:stDefault.Table = oNewId.id;break; case styletype_Table:stDefault.Table = oNewId.id;break;
} }
} }
styles[oNewId.id] = oNewStyle; }
//добавляем новые стили
for(var i in this.oReadResult.styles)
{
var elem = this.oReadResult.styles[i];
var oNewStyle = elem.style;
var oNewId = elem.param;
styles[oNewId.id] = oNewStyle;
} }
var oStyleTypes = {par: 1, table: 2, lvl: 3}; var oStyleTypes = {par: 1, table: 2, lvl: 3};
var fParseStyle = function(aStyles, oDocumentStyles, nStyleType) var fParseStyle = function(aStyles, oDocumentStyles, nStyleType)
...@@ -4506,11 +4535,9 @@ function BinaryFileReader(doc, openParams) ...@@ -4506,11 +4535,9 @@ function BinaryFileReader(doc, openParams)
} }
} }
} }
fParseStyle(this.oReadResult.paraStyles, this.Document.Styles.Style, oStyleTypes.par); fParseStyle(this.oReadResult.paraStyles, styles, oStyleTypes.par);
fParseStyle(this.oReadResult.tableStyles, this.Document.Styles.Style, oStyleTypes.table); fParseStyle(this.oReadResult.tableStyles, styles, oStyleTypes.table);
fParseStyle(this.oReadResult.lvlStyles, this.Document.Styles.Style, oStyleTypes.lvl); fParseStyle(this.oReadResult.lvlStyles, styles, oStyleTypes.lvl);
var stDefault = this.Document.Styles.Default;
var styles = this.Document.Styles.Style;
var nStId = styles.length; var nStId = styles.length;
if(null == stDefault.Numbering) if(null == stDefault.Numbering)
{ {
......
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