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

Bug 21864 - [Copy&Paste] Таблица в автофигуре копируется без сохранения стиля шаблона

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@51453 954022d7-b5bf-4e40-9824-e11837661b57
parent 80537326
...@@ -1512,7 +1512,7 @@ CopyProcessor.prototype = ...@@ -1512,7 +1512,7 @@ CopyProcessor.prototype =
else if ( type_Paragraph === Item.GetType() ) else if ( type_Paragraph === Item.GetType() )
{ {
//todo ����� ������ ��� �������� ������ ���� Index == End //todo ����� ������ ��� �������� ������ ���� Index == End
this.oBinaryFileWriter.CopyParagraph(Item, bUseSelection); this.oBinaryFileWriter.CopyParagraph(Item);
this.CopyParagraph(oDomTarget, Item, Index == End, bUseSelection, oDocument.Content, Index); this.CopyParagraph(oDomTarget, Item, Index == End, bUseSelection, oDocument.Content, Index);
} }
} }
...@@ -1643,7 +1643,7 @@ CopyProcessor.prototype = ...@@ -1643,7 +1643,7 @@ CopyProcessor.prototype =
tempParagraph.Selection.StartPos = index; tempParagraph.Selection.StartPos = index;
tempParagraph.Selection.Use = true; tempParagraph.Selection.Use = true;
this.oBinaryFileWriter.CopyParagraph(tempParagraph, true); this.oBinaryFileWriter.CopyParagraph(tempParagraph);
} }
var src = this.getSrc(base64_img); var src = this.getSrc(base64_img);
...@@ -1711,7 +1711,7 @@ CopyProcessor.prototype = ...@@ -1711,7 +1711,7 @@ CopyProcessor.prototype =
parent.Selection.StartPos = inIndex; parent.Selection.StartPos = inIndex;
parent.Selection.Use = true; parent.Selection.Use = true;
this.oBinaryFileWriter.CopyParagraph(parent, true); this.oBinaryFileWriter.CopyParagraph(parent);
//возвращаем Selection //возвращаем Selection
parent.Selection.StartPos = selectionTrue.StartPos; parent.Selection.StartPos = selectionTrue.StartPos;
......
...@@ -719,7 +719,7 @@ function BinaryFileWriter(doc) ...@@ -719,7 +719,7 @@ function BinaryFileWriter(doc)
this.WriteTable(c_oSerTableTypes.HdrFtr, new BinaryHeaderFooterTableWriter(this.memory, this.Document, oNumIdMap)); this.WriteTable(c_oSerTableTypes.HdrFtr, new BinaryHeaderFooterTableWriter(this.memory, this.Document, oNumIdMap));
//Write DocumentTable //Write DocumentTable
//DocumentTable всегда пишем последней, чтобы сначала заполнить все вспомогательные структуры, а при заполении документа, вызывать методы типа Style_Add... //DocumentTable всегда пишем последней, чтобы сначала заполнить все вспомогательные структуры, а при заполении документа, вызывать методы типа Style_Add...
this.WriteTable(c_oSerTableTypes.Document, new BinaryDocumentTableWriter(this.memory, this.Document, oMapCommentId, oNumIdMap)); this.WriteTable(c_oSerTableTypes.Document, new BinaryDocumentTableWriter(this.memory, this.Document, oMapCommentId, oNumIdMap, null));
//Write OtherTable //Write OtherTable
var oBinaryOtherTableWriter = new BinaryOtherTableWriter(this.memory, this.Document) var oBinaryOtherTableWriter = new BinaryOtherTableWriter(this.memory, this.Document)
this.WriteTable(c_oSerTableTypes.Other, oBinaryOtherTableWriter); this.WriteTable(c_oSerTableTypes.Other, oBinaryOtherTableWriter);
...@@ -743,8 +743,7 @@ function BinaryFileWriter(doc) ...@@ -743,8 +743,7 @@ function BinaryFileWriter(doc)
this.copyParams.oUsedNumIdMap = new Object(); this.copyParams.oUsedNumIdMap = new Object();
this.copyParams.nNumIdIndex = 1; this.copyParams.nNumIdIndex = 1;
this.copyParams.oUsedStyleMap = new Object(); this.copyParams.oUsedStyleMap = new Object();
this.copyParams.bdtw = new BinaryDocumentTableWriter(this.memory, this.Document, null, this.copyParams.oUsedNumIdMap); this.copyParams.bdtw = new BinaryDocumentTableWriter(this.memory, this.Document, null, this.copyParams.oUsedNumIdMap, this.copyParams);
this.copyParams.bdtw.bCopyPasteMode = true;
this.copyParams.nDocumentWriterTablePos = 0; this.copyParams.nDocumentWriterTablePos = 0;
this.copyParams.nDocumentWriterPos = 0; this.copyParams.nDocumentWriterPos = 0;
...@@ -753,49 +752,21 @@ function BinaryFileWriter(doc) ...@@ -753,49 +752,21 @@ function BinaryFileWriter(doc)
this.copyParams.nDocumentWriterTablePos = this.WriteTableStart(c_oSerTableTypes.Document); this.copyParams.nDocumentWriterTablePos = this.WriteTableStart(c_oSerTableTypes.Document);
this.copyParams.nDocumentWriterPos = this.bs.WriteItemWithLengthStart(); this.copyParams.nDocumentWriterPos = this.bs.WriteItemWithLengthStart();
} }
this.CopyParagraph = function(Item, bUseSelection) this.CopyParagraph = function(Item)
{ {
var oThis = this;
//анализируем используемые списки и стили
var sParaStyle = Item.Style_Get();
if(null != sParaStyle)
this.copyParams.oUsedStyleMap[sParaStyle] = 1;
var oNumPr = Item.Numbering_Get();
if(null != oNumPr && null != oNumPr.NumId && 0 != oNumPr.NumId)
{
if(null == this.copyParams.oUsedNumIdMap[oNumPr.NumId])
{
this.copyParams.oUsedNumIdMap[oNumPr.NumId] = this.copyParams.nNumIdIndex;
this.copyParams.nNumIdIndex++;
//проверяем PStyle уровней списка
var aNum = this.Document.Numbering.Get_AbstractNum(oNumPr.NumId);
if(null != aNum)
{
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, нужно только проанализировать стили //сами параграфы скопируются в методе CopyTable, нужно только проанализировать стили
if(this.copyParams.bLockCopyElems > 0) if(this.copyParams.bLockCopyElems > 0)
return; return;
this.bs.WriteItem(c_oSerParType.Par, function(){oThis.copyParams.bdtw.WriteParapraph(Item, bUseSelection);}); var oThis = this;
this.bs.WriteItem(c_oSerParType.Par, function(){oThis.copyParams.bdtw.WriteParapraph(Item, true);});
this.copyParams.itemCount++; this.copyParams.itemCount++;
} }
this.CopyTable = function(Item, aRowElems, nMinGrid, nMaxGrid) this.CopyTable = function(Item, aRowElems, nMinGrid, nMaxGrid)
{ {
var oThis = this;
//анализируем используемые списки и стили
var sTableStyle = Item.Get_TableStyle();
if(null != sTableStyle)
this.copyParams.oUsedStyleMap[sTableStyle] = 1;
//сама таблица скопируются в методе CopyTable у родительской таблицы, нужно только проанализировать стили //сама таблица скопируются в методе CopyTable у родительской таблицы, нужно только проанализировать стили
if(this.copyParams.bLockCopyElems > 0) if(this.copyParams.bLockCopyElems > 0)
return; return;
var oThis = this;
this.bs.WriteItem(c_oSerParType.Table, function(){oThis.copyParams.bdtw.WriteDocTable(Item, aRowElems, nMinGrid, nMaxGrid);}); this.bs.WriteItem(c_oSerParType.Table, function(){oThis.copyParams.bdtw.WriteDocTable(Item, aRowElems, nMinGrid, nMaxGrid);});
this.copyParams.itemCount++; this.copyParams.itemCount++;
} }
...@@ -1976,7 +1947,7 @@ function BinaryHeaderFooterTableWriter(memory, doc, oNumIdMap) ...@@ -1976,7 +1947,7 @@ function BinaryHeaderFooterTableWriter(memory, doc, oNumIdMap)
//BoundY2 //BoundY2
this.bs.WriteItem(c_oSerHdrFtrTypes.HdrFtr_Y2, function(){oThis.memory.WriteDouble(item.BoundY2);}); this.bs.WriteItem(c_oSerHdrFtrTypes.HdrFtr_Y2, function(){oThis.memory.WriteDouble(item.BoundY2);});
//Content //Content
var dtw = new BinaryDocumentTableWriter(this.memory, this.Document, null, this.oNumIdMap); var dtw = new BinaryDocumentTableWriter(this.memory, this.Document, null, this.oNumIdMap, null);
this.bs.WriteItem(c_oSerHdrFtrTypes.HdrFtr_Content, function(){dtw.WriteDocumentContent(item.Content);}); this.bs.WriteItem(c_oSerHdrFtrTypes.HdrFtr_Content, function(){dtw.WriteDocumentContent(item.Content);});
}; };
}; };
...@@ -2180,7 +2151,7 @@ function BinaryNumberingTableWriter(memory, doc, oNumIdMap, oUsedNumIdMap) ...@@ -2180,7 +2151,7 @@ function BinaryNumberingTableWriter(memory, doc, oNumIdMap, oUsedNumIdMap)
} }
}; };
}; };
function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap) function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap, copyParams)
{ {
this.memory = memory; this.memory = memory;
this.Document = doc; this.Document = doc;
...@@ -2192,7 +2163,7 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap) ...@@ -2192,7 +2163,7 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap)
this.sCurText = ""; this.sCurText = "";
this.oCur_rPr = null; this.oCur_rPr = null;
this.oMapCommentId = oMapCommentId; this.oMapCommentId = oMapCommentId;
this.bCopyPasteMode = false; this.copyParams = copyParams;
this.Write = function() this.Write = function()
{ {
var oThis = this; var oThis = this;
...@@ -2227,6 +2198,36 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap) ...@@ -2227,6 +2198,36 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap)
var oThis = this; var oThis = this;
var ParaStart = 0; var ParaStart = 0;
var ParaEnd = par.Content.length - 1; var ParaEnd = par.Content.length - 1;
if(null != this.copyParams)
{
//анализируем используемые списки и стили
var sParaStyle = par.Style_Get();
if(null != sParaStyle)
this.copyParams.oUsedStyleMap[sParaStyle] = 1;
var oNumPr = par.Numbering_Get();
if(null != oNumPr && null != oNumPr.NumId && 0 != oNumPr.NumId)
{
if(null == this.copyParams.oUsedNumIdMap[oNumPr.NumId])
{
this.copyParams.oUsedNumIdMap[oNumPr.NumId] = this.copyParams.nNumIdIndex;
this.copyParams.nNumIdIndex++;
//проверяем PStyle уровней списка
var Numbering = par.Parent.Get_Numbering();
var aNum = null;
if(null != Numbering)
aNum = Numbering.Get_AbstractNum(oNumPr.NumId);
if(null != aNum)
{
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;
}
}
}
}
}
if(true == bUseSelection) if(true == bUseSelection)
{ {
ParaStart = par.Selection.StartPos; ParaStart = par.Selection.StartPos;
...@@ -2483,7 +2484,7 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap) ...@@ -2483,7 +2484,7 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap)
{ {
this.memory.WriteByte(c_oSerImageType2.PptxData); this.memory.WriteByte(c_oSerImageType2.PptxData);
this.memory.WriteByte(c_oSerPropLenType.Variable); this.memory.WriteByte(c_oSerPropLenType.Variable);
this.bs.WriteItemWithLength(function(){window.global_pptx_content_writer.WriteDrawing(oThis.memory, img.GraphicObj, oThis.Document, oThis.oMapCommentId, oThis.oNumIdMap);}); this.bs.WriteItemWithLength(function(){window.global_pptx_content_writer.WriteDrawing(oThis.memory, img.GraphicObj, oThis.Document, oThis.oMapCommentId, oThis.oNumIdMap, oThis.copyParams);});
} }
} }
else else
...@@ -2617,7 +2618,7 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap) ...@@ -2617,7 +2618,7 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap)
{ {
this.memory.WriteByte(c_oSerImageType2.PptxData); this.memory.WriteByte(c_oSerImageType2.PptxData);
this.memory.WriteByte(c_oSerPropLenType.Variable); this.memory.WriteByte(c_oSerPropLenType.Variable);
this.bs.WriteItemWithLength(function(){window.global_pptx_content_writer.WriteDrawing(oThis.memory, img.GraphicObj, oThis.Document, oThis.oMapCommentId, oThis.oNumIdMap);}); this.bs.WriteItemWithLength(function(){window.global_pptx_content_writer.WriteDrawing(oThis.memory, img.GraphicObj, oThis.Document, oThis.oMapCommentId, oThis.oNumIdMap, oThis.copyParams);});
} }
} }
}; };
...@@ -2755,6 +2756,13 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap) ...@@ -2755,6 +2756,13 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap)
this.WriteDocTable = function(table, aRowElems, nMinGrid, nMaxGrid) this.WriteDocTable = function(table, aRowElems, nMinGrid, nMaxGrid)
{ {
var oThis = this; var oThis = this;
if(null != this.copyParams)
{
//анализируем используемые списки и стили
var sTableStyle = table.Get_TableStyle();
if(null != sTableStyle)
this.copyParams.oUsedStyleMap[sTableStyle] = 1;
}
//tblPr //tblPr
//tblPr должна идти раньше Content //tblPr должна идти раньше Content
if(null != table.Pr) if(null != table.Pr)
...@@ -2876,7 +2884,7 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap) ...@@ -2876,7 +2884,7 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap)
//Content //Content
if(null != cell.Content) if(null != cell.Content)
{ {
var oInnerDocument = new BinaryDocumentTableWriter(this.memory, this.Document, this.oMapCommentId, this.oNumIdMap); var oInnerDocument = new BinaryDocumentTableWriter(this.memory, this.Document, this.oMapCommentId, this.oNumIdMap, this.copyParams);
this.bs.WriteItem(c_oSerDocTableType.Cell_Content, function(){oInnerDocument.WriteDocumentContent(cell.Content);}); this.bs.WriteItem(c_oSerDocTableType.Cell_Content, function(){oInnerDocument.WriteDocumentContent(cell.Content);});
} }
}; };
......
...@@ -730,7 +730,7 @@ function CPPTXContentWriter() ...@@ -730,7 +730,7 @@ function CPPTXContentWriter()
this.arrayStackStarts.splice(this.arrayStackStarts.length - 1, 1); this.arrayStackStarts.splice(this.arrayStackStarts.length - 1, 1);
} }
this.WriteDrawing = function(memory, grObject, Document, oMapCommentId, oNumIdMap) this.WriteDrawing = function(memory, grObject, Document, oMapCommentId, oNumIdMap, copyParams)
{ {
this.TreeDrawingIndex++; this.TreeDrawingIndex++;
...@@ -741,11 +741,11 @@ function CPPTXContentWriter() ...@@ -741,11 +741,11 @@ function CPPTXContentWriter()
if ("undefined" !== typeof(WordShape) && grObject instanceof WordShape) if ("undefined" !== typeof(WordShape) && grObject instanceof WordShape)
{ {
this.WriteShape(grObject, Document, oMapCommentId, oNumIdMap); this.WriteShape(grObject, Document, oMapCommentId, oNumIdMap, copyParams);
} }
else if ("undefined" !== typeof(CShape) && grObject instanceof CShape) else if ("undefined" !== typeof(CShape) && grObject instanceof CShape)
{ {
this.WriteShape2(grObject, Document, oMapCommentId, oNumIdMap); this.WriteShape2(grObject, Document, oMapCommentId, oNumIdMap, copyParams);
} }
else if (("undefined" !== typeof(WordImage) && grObject instanceof WordImage) || ("undefined" !== typeof(CImageShape) && grObject instanceof CImageShape)) else if (("undefined" !== typeof(WordImage) && grObject instanceof WordImage) || ("undefined" !== typeof(CImageShape) && grObject instanceof CImageShape))
{ {
...@@ -753,7 +753,7 @@ function CPPTXContentWriter() ...@@ -753,7 +753,7 @@ function CPPTXContentWriter()
} }
else if (("undefined" !== typeof(WordGroupShapes) && grObject instanceof WordGroupShapes) || ("undefined" !== typeof(CGroupShape) && grObject instanceof CGroupShape)) else if (("undefined" !== typeof(WordGroupShapes) && grObject instanceof WordGroupShapes) || ("undefined" !== typeof(CGroupShape) && grObject instanceof CGroupShape))
{ {
this.WriteGroup(grObject, Document, oMapCommentId, oNumIdMap); this.WriteGroup(grObject, Document, oMapCommentId, oNumIdMap, copyParams);
} }
this.BinaryFileWriter.EndRecord(); this.BinaryFileWriter.EndRecord();
...@@ -768,13 +768,13 @@ function CPPTXContentWriter() ...@@ -768,13 +768,13 @@ function CPPTXContentWriter()
this.arrayStackStarts.splice(this.arrayStackStarts.length - 1, 1); this.arrayStackStarts.splice(this.arrayStackStarts.length - 1, 1);
} }
this.WriteShape2 = function(shape, Document, oMapCommentId, oNumIdMap) this.WriteShape2 = function(shape, Document, oMapCommentId, oNumIdMap, copyParams)
{ {
var _writer = this.BinaryFileWriter; var _writer = this.BinaryFileWriter;
_writer.WriteShape(shape); _writer.WriteShape(shape);
} }
this.WriteShape = function(shape, Document, oMapCommentId, oNumIdMap) this.WriteShape = function(shape, Document, oMapCommentId, oNumIdMap, copyParams)
{ {
var _writer = this.BinaryFileWriter; var _writer = this.BinaryFileWriter;
_writer.StartRecord(1); _writer.StartRecord(1);
...@@ -815,7 +815,7 @@ function CPPTXContentWriter() ...@@ -815,7 +815,7 @@ function CPPTXContentWriter()
this.arrayStackStartsTextBoxContent.push(memory.pos); this.arrayStackStartsTextBoxContent.push(memory.pos);
var bdtw = new BinaryDocumentTableWriter(memory, Document, oMapCommentId, oNumIdMap); var bdtw = new BinaryDocumentTableWriter(memory, Document, oMapCommentId, oNumIdMap, copyParams);
var bcw = new BinaryCommonWriter(memory); var bcw = new BinaryCommonWriter(memory);
bcw.WriteItemWithLength(function(){bdtw.WriteDocumentContent(shape.textBoxContent);}); bcw.WriteItemWithLength(function(){bdtw.WriteDocumentContent(shape.textBoxContent);});
...@@ -919,7 +919,7 @@ function CPPTXContentWriter() ...@@ -919,7 +919,7 @@ function CPPTXContentWriter()
this.arrayStackStarts.splice(this.arrayStackStarts.length - 1, 1); this.arrayStackStarts.splice(this.arrayStackStarts.length - 1, 1);
} }
this.WriteGroup = function(group, Document, oMapCommentId, oNumIdMap) this.WriteGroup = function(group, Document, oMapCommentId, oNumIdMap, copyParams)
{ {
var _writer = this.BinaryFileWriter; var _writer = this.BinaryFileWriter;
...@@ -953,11 +953,11 @@ function CPPTXContentWriter() ...@@ -953,11 +953,11 @@ function CPPTXContentWriter()
var elem = spTree[i]; var elem = spTree[i];
if ("undefined" !== typeof(WordShape) && elem instanceof WordShape) if ("undefined" !== typeof(WordShape) && elem instanceof WordShape)
{ {
this.WriteShape(elem, Document, oMapCommentId, oNumIdMap); this.WriteShape(elem, Document, oMapCommentId, oNumIdMap, copyParams);
} }
else if ("undefined" !== typeof(CShape) && elem instanceof CShape) else if ("undefined" !== typeof(CShape) && elem instanceof CShape)
{ {
this.WriteShape2(elem, Document, oMapCommentId, oNumIdMap); this.WriteShape2(elem, Document, oMapCommentId, oNumIdMap, copyParams);
} }
else if (("undefined" !== typeof(WordImage) && elem instanceof WordImage) || ("undefined" !== typeof(CImageShape) && elem instanceof CImageShape)) else if (("undefined" !== typeof(WordImage) && elem instanceof WordImage) || ("undefined" !== typeof(CImageShape) && elem instanceof CImageShape))
{ {
...@@ -965,7 +965,7 @@ function CPPTXContentWriter() ...@@ -965,7 +965,7 @@ function CPPTXContentWriter()
} }
else if (("undefined" !== typeof(WordGroupShapes) && elem instanceof WordGroupShapes) || ("undefined" !== typeof(CGroupShape) && elem instanceof CGroupShape)) else if (("undefined" !== typeof(WordGroupShapes) && elem instanceof WordGroupShapes) || ("undefined" !== typeof(CGroupShape) && elem instanceof CGroupShape))
{ {
this.WriteGroup(elem, Document, oMapCommentId, oNumIdMap); this.WriteGroup(elem, Document, oMapCommentId, oNumIdMap, copyParams);
} }
_writer.EndRecord(0); _writer.EndRecord(0);
......
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