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

для mailmerge: сохранение в docx с CachedImage и без field

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@62742 954022d7-b5bf-4e40-9824-e11837661b57
parent f8a1a2b6
...@@ -329,7 +329,8 @@ var c_oSerImageType2 = { ...@@ -329,7 +329,8 @@ var c_oSerImageType2 = {
WrapTopAndBottom: 22, WrapTopAndBottom: 22,
Chart: 23, Chart: 23,
ChartImg: 24, ChartImg: 24,
Chart2: 25 Chart2: 25,
CachedImage: 26
}; };
var c_oSerEffectExtent = { var c_oSerEffectExtent = {
Left: 0, Left: 0,
...@@ -753,7 +754,7 @@ function CreateThemeUnifill(color, tint, shade){ ...@@ -753,7 +754,7 @@ function CreateThemeUnifill(color, tint, shade){
return ret; return ret;
} }
function BinaryFileWriter(doc) function BinaryFileWriter(doc, bMailMergeDocx, bMailMergeHtml)
{ {
this.memory = new CMemory(); this.memory = new CMemory();
this.Document = doc; this.Document = doc;
...@@ -769,6 +770,10 @@ function BinaryFileWriter(doc) ...@@ -769,6 +770,10 @@ function BinaryFileWriter(doc)
nNumIdIndex: null, nNumIdIndex: null,
oUsedStyleMap: null oUsedStyleMap: null
}; };
this.saveParams = {
bMailMergeDocx: bMailMergeDocx,
bMailMergeHtml: bMailMergeHtml
};
this.Write = function() this.Write = function()
{ {
window.global_pptx_content_writer._Start(); window.global_pptx_content_writer._Start();
...@@ -824,8 +829,8 @@ function BinaryFileWriter(doc) ...@@ -824,8 +829,8 @@ function BinaryFileWriter(doc)
//Write StyleTable //Write StyleTable
this.WriteTable(c_oSerTableTypes.Style, new BinaryStyleTableWriter(this.memory, this.Document, oNumIdMap)); this.WriteTable(c_oSerTableTypes.Style, new BinaryStyleTableWriter(this.memory, this.Document, oNumIdMap));
//Write DocumentTable //Write DocumentTable
var oBinaryHeaderFooterTableWriter = new BinaryHeaderFooterTableWriter(this.memory, this.Document, oNumIdMap, oMapCommentId); var oBinaryHeaderFooterTableWriter = new BinaryHeaderFooterTableWriter(this.memory, this.Document, oNumIdMap, oMapCommentId, this.saveParams);
this.WriteTable(c_oSerTableTypes.Document, new BinaryDocumentTableWriter(this.memory, this.Document, oMapCommentId, oNumIdMap, null, oBinaryHeaderFooterTableWriter)); this.WriteTable(c_oSerTableTypes.Document, new BinaryDocumentTableWriter(this.memory, this.Document, oMapCommentId, oNumIdMap, null, this.saveParams, oBinaryHeaderFooterTableWriter));
//Write HeaderFooter //Write HeaderFooter
this.WriteTable(c_oSerTableTypes.HdrFtr, oBinaryHeaderFooterTableWriter); this.WriteTable(c_oSerTableTypes.HdrFtr, oBinaryHeaderFooterTableWriter);
//Write OtherTable //Write OtherTable
...@@ -852,7 +857,7 @@ function BinaryFileWriter(doc) ...@@ -852,7 +857,7 @@ function BinaryFileWriter(doc)
this.copyParams.oUsedNumIdMap = {}; this.copyParams.oUsedNumIdMap = {};
this.copyParams.nNumIdIndex = 1; this.copyParams.nNumIdIndex = 1;
this.copyParams.oUsedStyleMap = {}; this.copyParams.oUsedStyleMap = {};
this.copyParams.bdtw = new BinaryDocumentTableWriter(this.memory, this.Document, null, this.copyParams.oUsedNumIdMap, this.copyParams, null); this.copyParams.bdtw = new BinaryDocumentTableWriter(this.memory, this.Document, null, this.copyParams.oUsedNumIdMap, this.copyParams, this.saveParams, null);
this.copyParams.nDocumentWriterTablePos = 0; this.copyParams.nDocumentWriterTablePos = 0;
this.copyParams.nDocumentWriterPos = 0; this.copyParams.nDocumentWriterPos = 0;
...@@ -3208,7 +3213,7 @@ Binary_tblPrWriter.prototype = ...@@ -3208,7 +3213,7 @@ Binary_tblPrWriter.prototype =
} }
} }
}; };
function BinaryHeaderFooterTableWriter(memory, doc, oNumIdMap, oMapCommentId) function BinaryHeaderFooterTableWriter(memory, doc, oNumIdMap, oMapCommentId, saveParams)
{ {
this.memory = memory; this.memory = memory;
this.Document = doc; this.Document = doc;
...@@ -3216,6 +3221,7 @@ function BinaryHeaderFooterTableWriter(memory, doc, oNumIdMap, oMapCommentId) ...@@ -3216,6 +3221,7 @@ function BinaryHeaderFooterTableWriter(memory, doc, oNumIdMap, oMapCommentId)
this.oMapCommentId = oMapCommentId; this.oMapCommentId = oMapCommentId;
this.aHeaders = []; this.aHeaders = [];
this.aFooters = []; this.aFooters = [];
this.saveParams = saveParams;
this.bs = new BinaryCommonWriter(this.memory); this.bs = new BinaryCommonWriter(this.memory);
this.Write = function() this.Write = function()
{ {
...@@ -3245,7 +3251,7 @@ function BinaryHeaderFooterTableWriter(memory, doc, oNumIdMap, oMapCommentId) ...@@ -3245,7 +3251,7 @@ function BinaryHeaderFooterTableWriter(memory, doc, oNumIdMap, oMapCommentId)
{ {
var oThis = this; var oThis = this;
//Content //Content
var dtw = new BinaryDocumentTableWriter(this.memory, this.Document, this.oMapCommentId, this.oNumIdMap, null, null); var dtw = new BinaryDocumentTableWriter(this.memory, this.Document, this.oMapCommentId, this.oNumIdMap, null, this.saveParams, 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);});
}; };
}; };
...@@ -3449,7 +3455,7 @@ function BinaryNumberingTableWriter(memory, doc, oNumIdMap, oUsedNumIdMap) ...@@ -3449,7 +3455,7 @@ function BinaryNumberingTableWriter(memory, doc, oNumIdMap, oUsedNumIdMap)
} }
}; };
}; };
function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap, copyParams, oBinaryHeaderFooterTableWriter) function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap, copyParams, saveParams, oBinaryHeaderFooterTableWriter)
{ {
this.memory = memory; this.memory = memory;
this.Document = doc; this.Document = doc;
...@@ -3461,6 +3467,7 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap, copyPa ...@@ -3461,6 +3467,7 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap, copyPa
this.boMaths = new Binary_oMathWriter(this.memory); this.boMaths = new Binary_oMathWriter(this.memory);
this.oMapCommentId = oMapCommentId; this.oMapCommentId = oMapCommentId;
this.copyParams = copyParams; this.copyParams = copyParams;
this.saveParams = saveParams;
this.Write = function() this.Write = function()
{ {
var oThis = this; var oThis = this;
...@@ -3585,19 +3592,24 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap, copyPa ...@@ -3585,19 +3592,24 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap, copyPa
break; break;
case para_Field: case para_Field:
if(fieldtype_MERGEFIELD == item.FieldType){ if(fieldtype_MERGEFIELD == item.FieldType){
var Instr = "MERGEFIELD"; if(this.saveParams && this.saveParams.bMailMergeDocx)
for(var j = 0; j < item.Arguments.length; ++j){ oThis.WriteParagraphContent(item, bUseSelection, false);
var argument = item.Arguments[j]; else
argument = argument.replace(/(\\|")/g, "\\$1"); {
if(-1 != argument.indexOf(' ')) var Instr = "MERGEFIELD";
argument = "\"" + argument + "\""; for(var j = 0; j < item.Arguments.length; ++j){
Instr += " " + argument; var argument = item.Arguments[j];
argument = argument.replace(/(\\|")/g, "\\$1");
if(-1 != argument.indexOf(' '))
argument = "\"" + argument + "\"";
Instr += " " + argument;
}
for(var j = 0; j < item.Switches.length; ++j)
Instr += " \\" + item.Switches[j];
this.bs.WriteItem(c_oSerParType.FldSimple, function () {
oThis.WriteFldSimple(Instr, function(){oThis.WriteParagraphContent(item, bUseSelection, false);});
});
} }
for(var j = 0; j < item.Switches.length; ++j)
Instr += " \\" + item.Switches[j];
this.bs.WriteItem(c_oSerParType.FldSimple, function () {
oThis.WriteFldSimple(Instr, function(){oThis.WriteParagraphContent(item, bUseSelection, false);});
});
} }
break; break;
case para_Hyperlink: case para_Hyperlink:
...@@ -3848,7 +3860,7 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap, copyPa ...@@ -3848,7 +3860,7 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap, copyPa
{ {
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, oThis.copyParams);}); this.bs.WriteItemWithLength(function(){window.global_pptx_content_writer.WriteDrawing(oThis.memory, img.GraphicObj, oThis.Document, oThis.oMapCommentId, oThis.oNumIdMap, oThis.copyParams, oThis.saveParams);});
} }
} }
else else
...@@ -3973,9 +3985,15 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap, copyPa ...@@ -3973,9 +3985,15 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap, copyPa
{ {
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, oThis.copyParams);}); this.bs.WriteItemWithLength(function(){window.global_pptx_content_writer.WriteDrawing(oThis.memory, img.GraphicObj, oThis.Document, oThis.oMapCommentId, oThis.oNumIdMap, oThis.copyParams, oThis.saveParams);});
} }
} }
if(this.saveParams && this.saveParams.bMailMergeHtml)
{
this.memory.WriteByte(c_oSerImageType2.CachedImage);
this.memory.WriteByte(c_oSerPropLenType.Variable);
this.memory.WriteString2(img.getBase64Img());
}
}; };
this.WriteEffectExtent = function(EffectExtent) this.WriteEffectExtent = function(EffectExtent)
{ {
...@@ -4239,7 +4257,7 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap, copyPa ...@@ -4239,7 +4257,7 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap, copyPa
//Content //Content
if(null != cell.Content) if(null != cell.Content)
{ {
var oInnerDocument = new BinaryDocumentTableWriter(this.memory, this.Document, this.oMapCommentId, this.oNumIdMap, this.copyParams, this.oBinaryHeaderFooterTableWriter); var oInnerDocument = new BinaryDocumentTableWriter(this.memory, this.Document, this.oMapCommentId, this.oNumIdMap, this.copyParams, this.saveParams, this.oBinaryHeaderFooterTableWriter);
this.bs.WriteItem(c_oSerDocTableType.Cell_Content, function(){oInnerDocument.WriteDocumentContent(cell.Content);}); this.bs.WriteItem(c_oSerDocTableType.Cell_Content, function(){oInnerDocument.WriteDocumentContent(cell.Content);});
} }
}; };
...@@ -8105,6 +8123,13 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow ...@@ -8105,6 +8123,13 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
return oThis.ReadWrapThroughTight(t, l, oParaDrawing.wrappingPolygon); return oThis.ReadWrapThroughTight(t, l, oParaDrawing.wrappingPolygon);
}); });
} }
else if( c_oSerImageType2.CachedImage === type )
{
if(null != oParaDrawing.GraphicObj)
oParaDrawing.GraphicObj.cachedImage = this.stream.GetString2LE(length);
else
res = c_oSerConstants.ReadUnknown;
}
else else
res = c_oSerConstants.ReadUnknown; res = c_oSerConstants.ReadUnknown;
return res; return res;
......
...@@ -851,7 +851,7 @@ function CPPTXContentWriter() ...@@ -851,7 +851,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, copyParams) this.WriteDrawing = function(memory, grObject, Document, oMapCommentId, oNumIdMap, copyParams, saveParams)
{ {
this.TreeDrawingIndex++; this.TreeDrawingIndex++;
...@@ -865,11 +865,11 @@ function CPPTXContentWriter() ...@@ -865,11 +865,11 @@ function CPPTXContentWriter()
{ {
if(grObject.bWordShape) if(grObject.bWordShape)
{ {
this.WriteShape(grObject, Document, oMapCommentId, oNumIdMap, copyParams); this.WriteShape(grObject, Document, oMapCommentId, oNumIdMap, copyParams, saveParams);
} }
else else
{ {
this.WriteShape2(grObject, Document, oMapCommentId, oNumIdMap, copyParams); this.WriteShape2(grObject, Document, oMapCommentId, oNumIdMap, copyParams, saveParams);
} }
break; break;
} }
...@@ -880,7 +880,7 @@ function CPPTXContentWriter() ...@@ -880,7 +880,7 @@ function CPPTXContentWriter()
} }
case historyitem_type_GroupShape: case historyitem_type_GroupShape:
{ {
this.WriteGroup(grObject, Document, oMapCommentId, oNumIdMap, copyParams); this.WriteGroup(grObject, Document, oMapCommentId, oNumIdMap, copyParams, saveParams);
break; break;
} }
} }
...@@ -896,13 +896,13 @@ function CPPTXContentWriter() ...@@ -896,13 +896,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, copyParams) this.WriteShape2 = function(shape, Document, oMapCommentId, oNumIdMap, copyParams, saveParams)
{ {
var _writer = this.BinaryFileWriter; var _writer = this.BinaryFileWriter;
_writer.WriteShape(shape); _writer.WriteShape(shape);
} }
this.WriteShape = function(shape, Document, oMapCommentId, oNumIdMap, copyParams) this.WriteShape = function(shape, Document, oMapCommentId, oNumIdMap, copyParams, saveParams)
{ {
var _writer = this.BinaryFileWriter; var _writer = this.BinaryFileWriter;
_writer.StartRecord(1); _writer.StartRecord(1);
...@@ -943,7 +943,7 @@ function CPPTXContentWriter() ...@@ -943,7 +943,7 @@ function CPPTXContentWriter()
this.arrayStackStartsTextBoxContent.push(memory.pos); this.arrayStackStartsTextBoxContent.push(memory.pos);
var bdtw = new BinaryDocumentTableWriter(memory, Document, oMapCommentId, oNumIdMap, copyParams); var bdtw = new BinaryDocumentTableWriter(memory, Document, oMapCommentId, oNumIdMap, copyParams, saveParams);
var bcw = new BinaryCommonWriter(memory); var bcw = new BinaryCommonWriter(memory);
bcw.WriteItemWithLength(function(){bdtw.WriteDocumentContent(shape.textBoxContent);}); bcw.WriteItemWithLength(function(){bdtw.WriteDocumentContent(shape.textBoxContent);});
...@@ -1047,7 +1047,7 @@ function CPPTXContentWriter() ...@@ -1047,7 +1047,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, copyParams) this.WriteGroup = function(group, Document, oMapCommentId, oNumIdMap, copyParams, saveParams)
{ {
var _writer = this.BinaryFileWriter; var _writer = this.BinaryFileWriter;
...@@ -1085,11 +1085,11 @@ function CPPTXContentWriter() ...@@ -1085,11 +1085,11 @@ function CPPTXContentWriter()
{ {
if(elem.bWordShape) if(elem.bWordShape)
{ {
this.WriteShape(elem, Document, oMapCommentId, oNumIdMap, copyParams); this.WriteShape(elem, Document, oMapCommentId, oNumIdMap, copyParams, saveParams);
} }
else else
{ {
this.WriteShape2(elem, Document, oMapCommentId, oNumIdMap, copyParams); this.WriteShape2(elem, Document, oMapCommentId, oNumIdMap, copyParams, saveParams);
} }
break; break;
} }
...@@ -1100,7 +1100,7 @@ function CPPTXContentWriter() ...@@ -1100,7 +1100,7 @@ function CPPTXContentWriter()
} }
case historyitem_type_GroupShape: case historyitem_type_GroupShape:
{ {
this.WriteGroup(elem, Document, oMapCommentId, oNumIdMap, copyParams); this.WriteGroup(elem, Document, oMapCommentId, oNumIdMap, copyParams, saveParams);
break; break;
} }
case historyitem_type_ChartSpace: case historyitem_type_ChartSpace:
......
...@@ -7151,7 +7151,11 @@ function _downloadAs(editor, command, oDocumentMailMerge, oMailMergeSendData, fi ...@@ -7151,7 +7151,11 @@ function _downloadAs(editor, command, oDocumentMailMerge, oMailMergeSendData, fi
oLogicDocument = oDocumentMailMerge; oLogicDocument = oDocumentMailMerge;
else else
oLogicDocument = editor.WordControl.m_oLogicDocument; oLogicDocument = editor.WordControl.m_oLogicDocument;
var oBinaryFileWriter = new BinaryFileWriter(oLogicDocument); var oBinaryFileWriter;
if(null != oMailMergeSendData && c_oAscFileType.HTML == oMailMergeSendData.get_MailFormat())
oBinaryFileWriter = new BinaryFileWriter(oLogicDocument, false, true);
else
oBinaryFileWriter = new BinaryFileWriter(oLogicDocument, true, true);
oAdditionalData["data"] = oBinaryFileWriter.Write(); oAdditionalData["data"] = oBinaryFileWriter.Write();
} }
if(null != oMailMergeSendData){ if(null != oMailMergeSendData){
......
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