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

стили таблиц при copy/paste через бинарник.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@48753 954022d7-b5bf-4e40-9824-e11837661b57
parent b55ca34c
...@@ -2322,20 +2322,30 @@ PasteProcessor.prototype = ...@@ -2322,20 +2322,30 @@ PasteProcessor.prototype =
numPr.NumId = 0; numPr.NumId = 0;
} }
//обрабатываем стили //обрабатываем стили
for(var i = 0, length = oReadResult.paraStyles.length; i < length; ++i) var fParseStyle = function(aStyles, oDocumentStyles, oReadResult, bParaStyle)
{ {
var elem = oReadResult.paraStyles[i]; for(var i = 0, length = aStyles.length; i < length; ++i)
var stylePaste = oReadResult.styles[elem.style];
if(null != stylePaste && null != stylePaste.style)
{ {
for(var j in this.oDocument.Styles.Style) var elem = aStyles[i];
var stylePaste = oReadResult.styles[elem.style];
if(null != stylePaste && null != stylePaste.style)
{ {
var styleDoc = this.oDocument.Styles.Style[j]; for(var j in oDocumentStyles)
if(styleDoc.Name == stylePaste.style.Name) {
elem.pPr.PStyle = j; var styleDoc = oDocumentStyles[j];
if(styleDoc.Name == stylePaste.style.Name)
{
if(bParaStyle)
elem.pPr.PStyle = j;
else
elem.pPr.TableStyle = j;
}
}
} }
} }
} }
fParseStyle(oBinaryFileReader.oReadResult.paraStyles, this.oDocument.Styles.Style, oBinaryFileReader.oReadResult, true);
fParseStyle(oBinaryFileReader.oReadResult.tableStyles, this.oDocument.Styles.Style, oBinaryFileReader.oReadResult, false);
var aContent = oBinaryFileReader.oReadResult.DocumentContent; var aContent = oBinaryFileReader.oReadResult.DocumentContent;
if(aContent.length > 0) if(aContent.length > 0)
{ {
......
...@@ -628,8 +628,11 @@ function BinaryFileWriter(doc) ...@@ -628,8 +628,11 @@ function BinaryFileWriter(doc)
var oNumPr = Item.Numbering_Get(); var oNumPr = Item.Numbering_Get();
if(null != oNumPr && 0 != oNumPr.NumId) if(null != oNumPr && 0 != oNumPr.NumId)
{ {
this.copyParams.oUsedNumIdMap[oNumPr.NumId] = this.copyParams.nNumIdIndex; if(null == this.copyParams.oUsedNumIdMap[oNumPr.NumId])
this.copyParams.nNumIdIndex++; {
this.copyParams.oUsedNumIdMap[oNumPr.NumId] = this.copyParams.nNumIdIndex;
this.copyParams.nNumIdIndex++;
}
} }
this.bs.WriteItem(c_oSerParType.Par, function(){oThis.copyParams.bdtw.WriteParapraph(Item, bUseSelection);}); this.bs.WriteItem(c_oSerParType.Par, function(){oThis.copyParams.bdtw.WriteParapraph(Item, bUseSelection);});
this.copyParams.itemCount++; this.copyParams.itemCount++;
...@@ -637,6 +640,10 @@ function BinaryFileWriter(doc) ...@@ -637,6 +640,10 @@ function BinaryFileWriter(doc)
this.CopyTable = function(Item, oRowElems) this.CopyTable = function(Item, oRowElems)
{ {
var oThis = this; var oThis = this;
//анализируем используемые списки и стили
var sTableStyle = Item.Get_TableStyle();
if(null != sParaStyle)
this.copyParams.oUsedStyleMap[sTableStyle] = 1;
this.bs.WriteItem(c_oSerParType.Table, function(){oThis.copyParams.bdtw.WriteDocTable(Item);}); this.bs.WriteItem(c_oSerParType.Table, function(){oThis.copyParams.bdtw.WriteDocTable(Item);});
this.copyParams.itemCount++; this.copyParams.itemCount++;
} }
...@@ -2900,6 +2907,8 @@ function BinaryFileReader(doc, openParams) ...@@ -2900,6 +2907,8 @@ function BinaryFileReader(doc, openParams)
numToNumClass: null, numToNumClass: null,
paraNumPrs: null, paraNumPrs: null,
styles: null, styles: null,
paraStyles: null,
tableStyles: null,
DefpPr: null, DefpPr: null,
DefrPr: null, DefrPr: null,
DocumentContent: null DocumentContent: null
...@@ -3060,6 +3069,7 @@ function BinaryFileReader(doc, openParams) ...@@ -3060,6 +3069,7 @@ function BinaryFileReader(doc, openParams)
this.oReadResult.paraNumPrs = []; this.oReadResult.paraNumPrs = [];
this.oReadResult.styles = []; this.oReadResult.styles = [];
this.oReadResult.paraStyles = []; this.oReadResult.paraStyles = [];
this.oReadResult.tableStyles = [];
this.oReadResult.DocumentContent = []; this.oReadResult.DocumentContent = [];
var res = c_oSerConstants.ReadOk; var res = c_oSerConstants.ReadOk;
...@@ -3252,12 +3262,22 @@ function BinaryFileReader(doc, openParams) ...@@ -3252,12 +3262,22 @@ function BinaryFileReader(doc, openParams)
} }
styles[oNewId.id] = oNewStyle; styles[oNewId.id] = oNewStyle;
} }
for(var i = 0, length = this.oReadResult.paraStyles.length; i < length; ++i) var fParseStyle = function(aStyles, oDocumentStyles, bParaStyle)
{ {
var elem = this.oReadResult.paraStyles[i]; for(var i = 0, length = aStyles.length; i < length; ++i)
if(null != this.Document.Styles.Style[elem.style]) {
elem.pPr.PStyle = elem.style; var elem = aStyles[i];
if(null != oDocumentStyles[elem.style])
{
if(bParaStyle)
elem.pPr.PStyle = elem.style;
else
elem.pPr.TableStyle = elem.style;
}
}
} }
fParseStyle(this.oReadResult.paraStyles, this.Document.Styles.Style, true);
fParseStyle(this.oReadResult.tableStyles, this.Document.Styles.Style, false);
var stDefault = this.Document.Styles.Default; var stDefault = this.Document.Styles.Default;
var nStId = styles.length; var nStId = styles.length;
if(null == stDefault.Numbering) if(null == stDefault.Numbering)
...@@ -3543,11 +3563,9 @@ function BinaryStyleTableReader(doc, oReadResult, stream) ...@@ -3543,11 +3563,9 @@ function BinaryStyleTableReader(doc, oReadResult, stream)
} }
else if(c_oSer_sts.Style_TablePr == type) else if(c_oSer_sts.Style_TablePr == type)
{ {
var TablePr = 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, TablePr); return oThis.btblPrr.Read_tblPr(t,l, style.TablePr);
}); });
style.TablePr.Set_FromObject( TablePr );
} }
else if(c_oSer_sts.Style_RowPr == type) else if(c_oSer_sts.Style_RowPr == type)
{ {
...@@ -3638,11 +3656,9 @@ function BinaryStyleTableReader(doc, oReadResult, stream) ...@@ -3638,11 +3656,9 @@ function BinaryStyleTableReader(doc, oReadResult, stream)
} }
else if(c_oSerProp_tblStylePrType.TblPr == type) else if(c_oSerProp_tblStylePrType.TblPr == type)
{ {
var TablePr = {};
res = this.bcr.Read1(length, function(t, l){ res = this.bcr.Read1(length, function(t, l){
return oThis.btblPrr.Read_tblPr(t,l, TablePr); return oThis.btblPrr.Read_tblPr(t,l, oNewTableStylePr.TablePr);
}); });
oNewTableStylePr.TablePr.Set_FromObject( TablePr );
} }
else if(c_oSerProp_tblStylePrType.TrPr == type) else if(c_oSerProp_tblStylePrType.TrPr == type)
{ {
...@@ -4267,7 +4283,7 @@ Binary_tblPrReader.prototype = ...@@ -4267,7 +4283,7 @@ Binary_tblPrReader.prototype =
table.Set_TableLook(new CTableLook(bFC, bFR, bLC, bLR, !bBH, !bBV)); table.Set_TableLook(new CTableLook(bFC, bFR, bLC, bLR, !bBH, !bBV));
} }
else if( c_oSerProp_tblPrType.Style === type ) else if( c_oSerProp_tblPrType.Style === type )
table.TableStyle = this.stream.GetString2LE(length); this.oReadResult.tableStyles.push({pPr: table, style: this.stream.GetString2LE(length)});
else else
res = c_oSerConstants.ReadUnknown; res = c_oSerConstants.ReadUnknown;
} }
......
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