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

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

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@51984 954022d7-b5bf-4e40-9824-e11837661b57
parent aecb346b
...@@ -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];
...@@ -4441,6 +4442,35 @@ function BinaryFileReader(doc, openParams) ...@@ -4441,6 +4442,35 @@ function BinaryFileReader(doc, openParams)
{ {
var stId = oStartDocStyle.Get_Id(); var stId = oStartDocStyle.Get_Id();
oNewStyle.Name = oStartDocStyle.Name; oNewStyle.Name = oStartDocStyle.Name;
oIdRenameMap[stId] = {id: oNewId.id, def: oNewId.def, type: oNewStyle.Type, newName: sNewStyleName};
delete styles[stId];
}
var oCollisionStyle = styles[oNewId.id];
if(oCollisionStyle)
{
var sOldId = oCollisionStyle.Get_Id();
var nCounter = 1;
var sNewId = sOldId + "_" + nCounter;
while(null != styles[sNewId] || null != this.oReadResult.styles[sNewId])
{
nCounter++;
sNewId = sOldId + "_" + nCounter;
}
var oNewId = {id: sNewId, def: false, type: oCollisionStyle.Type, newName: sNewStyleName};
oIdRenameMap[sOldId] = oNewId;
if(stDefault.Numbering == sOldId || stDefault.Paragraph == sOldId || stDefault.Table == sOldId)
oNewId.def = true;
oCollisionStyle.Set_Id(sNewId);
delete styles[sOldId];
styles[sNewId] = oCollisionStyle;
}
}
//меняем старые id
for(var sOldId in oIdRenameMap)
{
var oNewId = oIdRenameMap[sOldId];
var sNewStyleName = oNewId.newName;
var stId = sOldId;
for(var stId2 in styles) for(var stId2 in styles)
{ {
var stObj2 = styles[stId2]; var stObj2 = styles[stId2];
...@@ -4463,23 +4493,15 @@ function BinaryFileReader(doc, openParams) ...@@ -4463,23 +4493,15 @@ function BinaryFileReader(doc, openParams)
} }
if(stDefault.ParaList == stId) if(stDefault.ParaList == stId)
stDefault.ParaList = oNewId.id; stDefault.ParaList = oNewId.id;
if(stDefault.Header == stId) if(stDefault.Header == stId || "header" == sNewStyleName)
stDefault.Header = oNewId.id; stDefault.Header = oNewId.id;
if(stDefault.Footer == stId) if(stDefault.Footer == stId || "footer" == sNewStyleName)
stDefault.Footer = oNewId.id; stDefault.Footer = oNewId.id;
if(stDefault.Hyperlink == stId) if(stDefault.Hyperlink == stId || "hyperlink" == sNewStyleName)
stDefault.Hyperlink = oNewId.id;
delete styles[stId];
}
if("header" == sNewStyleName)
stDefault.Header = oNewId.id;
if("footer" == sNewStyleName)
stDefault.Footer = oNewId.id;
if("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,6 +4509,13 @@ function BinaryFileReader(doc, openParams) ...@@ -4487,6 +4509,13 @@ function BinaryFileReader(doc, openParams)
case styletype_Table:stDefault.Table = oNewId.id;break; case styletype_Table:stDefault.Table = oNewId.id;break;
} }
} }
}
//добавляем новые стили
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; styles[oNewId.id] = oNewStyle;
} }
var oStyleTypes = {par: 1, table: 2, lvl: 3}; var oStyleTypes = {par: 1, table: 2, lvl: 3};
...@@ -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