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

копирование части таблиц через бинарник, Bug 19642 - [Copy&Paste] Таблица не...

копирование части таблиц через бинарник, Bug 19642 - [Copy&Paste] Таблица не копируются в колонтитул, стили списков в бинарнике для копирования.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@48802 954022d7-b5bf-4e40-9824-e11837661b57
parent 3306f88e
......@@ -1176,7 +1176,7 @@ CopyProcessor.prototype =
oDomTarget.appendChild(tr);
},
CopyTable : function(oDomTarget, table, oRowElems)
CopyTable : function(oDomTarget, table, aRowElems)
{
this.CommitList(oDomTarget);
var DomTable = document.createElement( "table" );
......@@ -1257,7 +1257,7 @@ CopyProcessor.prototype =
DomTable.setAttribute("style", tblStyle);
//rows
if(null == oRowElems)
if(null == aRowElems)
{
for(var i = 0, length = table.Content.length; i < length; i++)
this.CopyRow(DomTable, table, i , null, table.Content.length - 1);
......@@ -1265,14 +1265,17 @@ CopyProcessor.prototype =
else
{
var nMaxRow = 0;
for(var i in oRowElems)
for(var i = 0, length = aRowElems.length; i < length; ++i)
{
var nCurRow = i - 0;
if(nCurRow > nMaxRow)
nMaxRow = nCurRow;
var elem = aRowElems[i];
if(elem.row > nMaxRow)
nMaxRow = elem.row;
}
for(var i = 0, length = aRowElems.length; i < length; ++i)
{
var elem = aRowElems[i];
this.CopyRow(DomTable, table, elem.row, elem, nMaxRow);
}
for(var i in oRowElems)
this.CopyRow(DomTable, table, i - 0, oRowElems[i], nMaxRow);
}
oDomTarget.appendChild(DomTable);
......@@ -1350,9 +1353,9 @@ CopyProcessor.prototype =
var rowElem = oRowElems[elem.Row];
if(null == rowElem)
{
rowElem = {gridStart: null, gridEnd: null, indexStart: null, indexEnd: null, after: null, before: null, cells: {}};
rowElem = {row: elem.Row, gridStart: null, gridEnd: null, indexStart: null, indexEnd: null, after: null, before: null, cells: {}};
oRowElems[elem.Row] = rowElem;
aSelectedRows.push(elem.Row);
aSelectedRows.push(rowElem);
}
if(null == rowElem.indexEnd || elem.Cell > rowElem.indexEnd)
rowElem.indexEnd = elem.Cell;
......@@ -1361,7 +1364,9 @@ CopyProcessor.prototype =
rowElem.cells[elem.Cell] = 1;
}
}
aSelectedRows.sort(fSortAscending);
aSelectedRows.sort(function(a,b){
return a.row - b.row;
});
var nMinGrid = null;
var nMaxGrid = null;
var nPrevStartGrid = null;
......@@ -1369,7 +1374,8 @@ CopyProcessor.prototype =
var nPrevRowIndex = null;
for(var i = 0, length = aSelectedRows.length; i < length; ++i)
{
var nRowIndex = aSelectedRows[i];
var elem = aSelectedRows[i];
var nRowIndex = elem.row;
if(null != nPrevRowIndex)
{
if(nPrevRowIndex + 1 != nRowIndex)
......@@ -1380,7 +1386,6 @@ CopyProcessor.prototype =
}
}
nPrevRowIndex = nRowIndex;
var elem = oRowElems[nRowIndex];
var row = Item.Content[nRowIndex];
var cellFirst = row.Get_Cell(elem.indexStart);
var cellLast = row.Get_Cell(elem.indexEnd);
......@@ -1398,7 +1403,10 @@ CopyProcessor.prototype =
{
var nCurGridCol = cellCur.Metrics.StartGridCol;
if(nCurGridCol >= nPrevStartGrid)
{
nCurStartGrid = nCurGridCol;
elem.indexStart = j;
}
else
break;
}
......@@ -1415,7 +1423,10 @@ CopyProcessor.prototype =
{
var nCurGridCol = cellCur.Metrics.StartGridCol + cellCur.Get_GridSpan() - 1;
if(nCurGridCol <= nPrevEndGrid)
{
nCurEndGrid = nCurGridCol;
elem.indexEnd = j;
}
else
break;
}
......@@ -1434,15 +1445,15 @@ CopyProcessor.prototype =
if(null != nMinGrid && null != nMaxGrid)
{
//выставляем after, before
for(var i in oRowElems)
for(var i = 0 ,length = aSelectedRows.length; i < length; ++i)
{
var elem = oRowElems[i];
var elem = aSelectedRows[i];
elem.before = elem.gridStart - nMinGrid;
elem.after = nMaxGrid - elem.gridEnd;
}
this.oBinaryFileWriter.CopyTable(Item, oRowElems);
this.oBinaryFileWriter.CopyTable(Item, aSelectedRows, nMinGrid, nMaxGrid);
this.oBinaryFileWriter.copyParams.bLockCopyPar = true;
this.CopyTable(oDomTarget, Item, oRowElems);
this.CopyTable(oDomTarget, Item, aSelectedRows);
this.oBinaryFileWriter.copyParams.bLockCopyPar = null;
}
}
......@@ -2343,7 +2354,8 @@ PasteProcessor.prototype =
}
//обрабатываем стили
var isUsuallyContainsStyle;
var fParseStyle = function(aStyles, oDocumentStyles, oReadResult, bParaStyle)
var oStyleTypes = {par: 1, table: 2, lvl: 3};
var fParseStyle = function(aStyles, oDocumentStyles, oReadResult, nStyleType)
{
for(var i = 0, length = aStyles.length; i < length; ++i)
{
......@@ -2357,18 +2369,21 @@ PasteProcessor.prototype =
isUsuallyContainsStyle = styleDoc.isEqual(stylePaste.style);
if(isUsuallyContainsStyle)
{
if(bParaStyle)
if(oStyleTypes.par == nStyleType)
elem.pPr.PStyle = j;
else
else if(oStyleTypes.table == nStyleType)
elem.pPr.TableStyle = j;
else
elem.pPr.PStyle = j;
break;
}
}
}
}
}
fParseStyle(oBinaryFileReader.oReadResult.paraStyles, this.oDocument.Styles.Style, oBinaryFileReader.oReadResult, true);
fParseStyle(oBinaryFileReader.oReadResult.tableStyles, this.oDocument.Styles.Style, oBinaryFileReader.oReadResult, false);
fParseStyle(oBinaryFileReader.oReadResult.paraStyles, this.oDocument.Styles.Style, oBinaryFileReader.oReadResult, oStyleTypes.par);
fParseStyle(oBinaryFileReader.oReadResult.tableStyles, this.oDocument.Styles.Style, oBinaryFileReader.oReadResult, oStyleTypes.table);
fParseStyle(oBinaryFileReader.oReadResult.lvlStyles, this.oDocument.Styles.Style, oBinaryFileReader.oReadResult, oStyleTypes.lvl);
var aContent = oBinaryFileReader.oReadResult.DocumentContent;
if(aContent.length > 0)
{
......@@ -2391,6 +2406,7 @@ PasteProcessor.prototype =
Start : function(node)
{
var oThis = this;
this.oDocument = this._GetTargetDocument(this.oDocument);
// var oPasteContent = this.ReadFromBinary(node.innerText);
// this.aContent = oPasteContent.content;
// oThis.api.pre_Paste(oPasteContent.fonts, oPasteContent.images, function(){
......@@ -2443,7 +2459,6 @@ PasteProcessor.prototype =
this._Prepeare(node,
function(){
oThis.aContent = new Array();
oThis.oDocument = oThis._GetTargetDocument(oThis.oDocument);
//�� ����� ���������� �������� ��� ������� ��������� �������
oThis._Execute(node, {}, true, true, false);
......
......@@ -630,6 +630,14 @@ function BinaryFileWriter(doc)
{
this.copyParams.oUsedNumIdMap[oNumPr.NumId] = this.copyParams.nNumIdIndex;
this.copyParams.nNumIdIndex++;
//проверяем PStyle уровней списка
var aNum = this.Document.Numbering.Get_AbstractNum(oNumPr.NumId);
for(var i = 0, length = aNum.Lvl.length; i < length; ++i)
{
var oLvl = aNum.Lvl[i];
if(null != oLvl.PStyle)
this.copyParams.oUsedStyleMap[oLvl.PStyle] = 1;
}
}
}
//сами параграфы скопируются в методе CopyTable, нужно только проанализировать стили
......@@ -638,14 +646,14 @@ function BinaryFileWriter(doc)
this.bs.WriteItem(c_oSerParType.Par, function(){oThis.copyParams.bdtw.WriteParapraph(Item, bUseSelection);});
this.copyParams.itemCount++;
}
this.CopyTable = function(Item, oRowElems)
this.CopyTable = function(Item, aRowElems, nMinGrid, nMaxGrid)
{
var oThis = this;
//анализируем используемые списки и стили
var sTableStyle = Item.Get_TableStyle();
if(null != sTableStyle)
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, aRowElems, nMinGrid, nMaxGrid);});
this.copyParams.itemCount++;
}
this.CopyEnd = function()
......@@ -2549,7 +2557,7 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap)
this.memory.WriteDouble(oPoint.y);
}
}
this.WriteDocTable = function(table)
this.WriteDocTable = function(table, aRowElems, nMinGrid, nMaxGrid)
{
var oThis = this;
//tblPr
......@@ -2558,10 +2566,15 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap)
this.bs.WriteItem(c_oSerDocTableType.tblPr, function(){oThis.btblPrs.WriteTbl(table);});
//tblGrid
if(null != table.TableGrid)
this.bs.WriteItem(c_oSerDocTableType.tblGrid, function(){oThis.WriteTblGrid(table.TableGrid);});
{
var aGrid = table.TableGrid;
if(null != nMinGrid && null != nMaxGrid && 0 != nMinGrid && aGrid.length - 1 != nMaxGrid)
aGrid = aGrid.slice( nMinGrid, nMaxGrid + 1);
this.bs.WriteItem(c_oSerDocTableType.tblGrid, function(){oThis.WriteTblGrid(aGrid);});
}
//Content
if(null != table.Content && table.Content.length > 0)
this.bs.WriteItem(c_oSerDocTableType.Content, function(){oThis.WriteTableContent(table.Content);});
this.bs.WriteItem(c_oSerDocTableType.Content, function(){oThis.WriteTableContent(table.Content, aRowElems);});
};
this.WriteTblGrid = function(grid)
{
......@@ -2573,30 +2586,64 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap)
this.memory.WriteDouble(grid[i]);
}
};
this.WriteTableContent = function(Content)
this.WriteTableContent = function(Content, aRowElems)
{
var oThis = this;
for(var i = 0, length = Content.length; i < length; ++i)
this.bs.WriteItem(c_oSerDocTableType.Row, function(){oThis.WriteRow(Content[i], i);});
var nStart = 0;
var nEnd = Content.length - 1;
if(null != aRowElems && aRowElems.length > 0)
{
nStart = aRowElems[0].row;
nEnd = aRowElems[aRowElems.length - 1].row;
}
for(var i = nStart; i <= nEnd; ++i)
{
var oRowElem = null;
if(null != aRowElems)
oRowElem = aRowElems[i - nStart];
this.bs.WriteItem(c_oSerDocTableType.Row, function(){oThis.WriteRow(Content[i], i, oRowElem);});
}
};
this.WriteRow = function(Row, nRowIndex)
this.WriteRow = function(Row, nRowIndex, oRowElem)
{
var oThis = this;
//Pr
if(null != Row.Pr)
{
this.bs.WriteItem(c_oSerDocTableType.Row_Pr, function(){oThis.btblPrs.WriteRowPr(Row.Pr);});
var oRowPr = Row.Pr;
if(null != oRowElem)
{
oRowPr = oRowPr.Copy();
oRowPr.WAfter = null;
oRowPr.WBefore = null;
if(null != oRowElem.after)
oRowPr.GridAfter = oRowElem.after;
else
oRowPr.GridAfter = null;
if(null != oRowElem.before)
oRowPr.GridBefore = oRowElem.before;
else
oRowPr.GridBefore = null;
}
this.bs.WriteItem(c_oSerDocTableType.Row_Pr, function(){oThis.btblPrs.WriteRowPr(oRowPr);});
}
//Content
if(null != Row.Content)
{
this.bs.WriteItem(c_oSerDocTableType.Row_Content, function(){oThis.WriteRowContent(Row.Content, nRowIndex);});
this.bs.WriteItem(c_oSerDocTableType.Row_Content, function(){oThis.WriteRowContent(Row.Content, nRowIndex, oRowElem);});
}
};
this.WriteRowContent = function(Content, nRowIndex)
this.WriteRowContent = function(Content, nRowIndex, oRowElem)
{
var oThis = this;
for(var i = 0, length = Content.length; i < length; i++)
var nStart = 0;
var nEnd = Content.length - 1;
if(null != oRowElem)
{
nStart = oRowElem.indexStart;
nEnd = oRowElem.indexEnd;
}
for(var i = nStart; i <= nEnd; i++)
{
this.bs.WriteItem(c_oSerDocTableType.Cell, function(){oThis.WriteCell(Content[i], nRowIndex, i);});
}
......@@ -2910,6 +2957,7 @@ function BinaryFileReader(doc, openParams)
styles: null,
paraStyles: null,
tableStyles: null,
lvlStyles: null,
DefpPr: null,
DefrPr: null,
DocumentContent: null
......@@ -3071,6 +3119,7 @@ function BinaryFileReader(doc, openParams)
this.oReadResult.styles = [];
this.oReadResult.paraStyles = [];
this.oReadResult.tableStyles = [];
this.oReadResult.lvlStyles = [];
this.oReadResult.DocumentContent = [];
var res = c_oSerConstants.ReadOk;
......@@ -3263,22 +3312,26 @@ function BinaryFileReader(doc, openParams)
}
styles[oNewId.id] = oNewStyle;
}
var fParseStyle = function(aStyles, oDocumentStyles, bParaStyle)
var oStyleTypes = {par: 1, table: 2, lvl: 3};
var fParseStyle = function(aStyles, oDocumentStyles, nStyleType)
{
for(var i = 0, length = aStyles.length; i < length; ++i)
{
var elem = aStyles[i];
if(null != oDocumentStyles[elem.style])
{
if(bParaStyle)
if(oStyleTypes.par == nStyleType)
elem.pPr.PStyle = elem.style;
else
else if(oStyleTypes.table == nStyleType)
elem.pPr.TableStyle = elem.style;
else
elem.pPr.PStyle = elem.style;
}
}
}
fParseStyle(this.oReadResult.paraStyles, this.Document.Styles.Style, true);
fParseStyle(this.oReadResult.tableStyles, this.Document.Styles.Style, false);
fParseStyle(this.oReadResult.paraStyles, this.Document.Styles.Style, oStyleTypes.par);
fParseStyle(this.oReadResult.tableStyles, this.Document.Styles.Style, oStyleTypes.table);
fParseStyle(this.oReadResult.lvlStyles, this.Document.Styles.Style, oStyleTypes.lvl);
var stDefault = this.Document.Styles.Default;
var nStId = styles.length;
if(null == stDefault.Numbering)
......@@ -4848,7 +4901,7 @@ function Binary_NumberingTableReader(doc, oReadResult, stream)
}
else if ( c_oSerNumTypes.lvl_PStyle === type )
{
oNewLvl.PStyle = this.stream.GetString2LE(length);
this.oReadResult.lvlStyles.push({pPr: oNewLvl, style: this.stream.GetString2LE(length)});
}
else if ( c_oSerNumTypes.lvl_ParaPr === type )
{
......
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