Commit 2c9c7315 authored by Igor.Zotov's avatar Igor.Zotov Committed by Alexander.Trofimov

copy / paste для графики из excel в word,подключил скрипты в word из excel

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@56201 954022d7-b5bf-4e40-9824-e11837661b57
parent 892b6202
......@@ -3042,31 +3042,40 @@ PasteProcessor.prototype =
if(copyPasteUseBinery)
{
var base64 = null;
var classNode;
if(node.children[0] && node.children[0].getAttribute("class") != null && node.children[0].getAttribute("class").indexOf("docData;") > -1)
var base64 = null, base64FromExcel = null,classNode, aContent, aContentExcel;
if(node.children[0] && node.children[0].getAttribute("class") != null && (node.children[0].getAttribute("class").indexOf("xslData;") > -1 || node.children[0].getAttribute("class").indexOf("docData;") > -1))
classNode = node.children[0].getAttribute("class");
else if(node.children[0] && node.children[0].children[0] && node.children[0].children[0].getAttribute("class") != null && node.children[0].children[0].getAttribute("class").indexOf("docData;") > -1)
else if(node.children[0] && node.children[0].children[0] && node.children[0].children[0].getAttribute("class") != null && (node.children[0].children[0].getAttribute("class").indexOf("xslData;") > -1 || node.children[0].children[0].getAttribute("class").indexOf("docData;") > -1))
classNode = node.children[0].children[0].getAttribute("class");
else if(node.children[0] && node.children[0].children[0] && node.children[0].children[0].children[0] && node.children[0].children[0].children[0].getAttribute("class") != null && node.children[0].children[0].children[0].getAttribute("class").indexOf("docData;") > -1)
classNode = node.children[0].children[0].children[0].getAttribute("class");
else if(node.children[0] && node.children[0].children[0] && node.children[0].children[0].children[0] && node.children[0].children[0].children[0].getAttribute("class") != null && (node.children[0].children[0].children[0].getAttribute("class").indexOf("xslData;") > -1 || node.children[0].children[0].children[0].getAttribute("class").indexOf("docData;") > -1))
classNode = node.children[0].children[0].children[0].getAttribute("class");
if( classNode != null ){
var cL = classNode.split(" ");
for (var i = 0; i < cL.length; i++){
if(cL[i].indexOf("xslData;") > -1)
{
base64FromExcel = cL[i].split('xslData;')[1];
}
else if(cL[i].indexOf("docData;") > -1)
{
base64 = cL[i].split('docData;')[1];
}
}
};
if( classNode != null ){
var cL = classNode.split(" ");
for (var i = 0; i < cL.length; i++){
if(cL[i].indexOf("docData;") > -1)
{
base64 = cL[i].split('docData;')[1];
}
}
}
var aContent;
//если находимся внутри шейп, вставляем html
if(this.oDocument.Parent && this.oDocument.Parent instanceof CShape)
base64 = null;
if(base64 != null)
aContent = this.ReadFromBinary(base64);
else if(base64FromExcel != null)
aContentExcel = this._readFromBinaryExcel(base64FromExcel);
if(aContentExcel)
aContent = this._convertExcelBinary(aContentExcel);
if(aContent)
{
......@@ -3126,8 +3135,8 @@ PasteProcessor.prototype =
else
oThis.api.pre_Paste(aContent.fonts, aContent.images, fPrepasteCallback);
return;
}
}
};
};
var presentation = editor.WordControl.m_oLogicDocument;
this.oRootNode = node;
......@@ -3849,8 +3858,58 @@ PasteProcessor.prototype =
}
},
_convertExcelBinary: function(aContentExcel)
{
//пока только распознаём только графические объекты
var aContent = null;
var drawings = aContentExcel.aWorksheets[0].Drawings;
if(drawings)
{
var drawing, graphicObj, paraRun, tempParaRun;
//var wrappingType = this.oDocument.DrawingObjects.selection.groupSelection.parent.wrappingType;
//var DrawingType = this.oDocument.DrawingObjects.selection.groupSelection.parent.DrawingType;
var tempParagraph = new Paragraph(this.oDocument, this.oDocument, 0, 0, 0, 0, 0);
//из excel в word они вставляются в один параграф
for(var i = 0; i < drawings.length; i++)
{
drawing = drawings[i];
graphicObj = drawing.graphicObject.convertToWord(this.oLogicDocument.DrawingDocument);
tempParaRun = new ParaRun();
tempParaRun.Content.unshift(new ParaDrawing());
//paraRun.Content[index].wrappingType = wrappingType;
//paraRun.Content[index].DrawingType = DrawingType;
tempParaRun.Content[0].GraphicObj = graphicObj;
tempParaRun.Content[0].GraphicObj.parent = tempParaRun.Content[0];
tempParagraph.Content.unshift(tempParaRun);
};
aContent = [];
aContent[0] = tempParagraph;
};
return {content: aContent, aPastedImages: []};
},
_readFromBinaryExcel: function(base64)
{
var oBinaryFileReader = new Asc.BinaryFileReader(null, true);
var tempWorkbook = new Workbook;
tempWorkbook.theme = this.oDocument.theme;
Asc.getBinaryOtherTableGVar(tempWorkbook);
oBinaryFileReader.Read(base64, tempWorkbook);
return tempWorkbook;
},
ReadPresentationText: function(stream)
{
var loader = new BinaryPPTYLoader();
......
......@@ -5068,6 +5068,10 @@
this.aMerged = [];
this.aHyperlinks = [];
var oNewWorksheet = new Woorksheet(this.wb, wb.aWorksheets.length);
//TODO при copy/paste в word из excel необходимо подменить DrawingDocument из word - пересмотреть правку!
if(editor && editor.WordControl && editor.WordControl.m_oLogicDocument && editor.WordControl.m_oLogicDocument.DrawingDocument)
oNewWorksheet.DrawingDocument = editor.WordControl.m_oLogicDocument.DrawingDocument;
this.curWorksheet = oNewWorksheet;
res = this.bcr.Read1(length, function(t,l){
return oThis.ReadWorksheet(t,l, oNewWorksheet);
......@@ -5632,7 +5636,9 @@
oNewDrawing.Type = ECellAnchorType.cellanchorAbsolute;
if(oNewDrawing.graphicObject)
{
oNewDrawing.graphicObject.setWorksheet(ws);
//TODO при copy/paste в word из excel пропадает метод setWorksheet
if(typeof oNewDrawing.graphicObject.setWorksheet != "undefined")
oNewDrawing.graphicObject.setWorksheet(ws);
}
aDrawings.push(oNewDrawing);
}
......@@ -5701,7 +5707,9 @@
if(null != oGraphicObject)
{
oDrawing.graphicObject = oGraphicObject;
oGraphicObject.setDrawingBase(oDrawing);
//TODO при copy/paste в word из excel пропадает метод setDrawingBase
if(typeof oGraphicObject.setDrawingBase != "undefined")
oGraphicObject.setDrawingBase(oDrawing);
}
}
else
......@@ -6277,49 +6285,9 @@
this.wb.clrSchemeMap = GenerateDefaultColorMap();
if(null == this.wb.theme)
this.wb.theme = GenerateDefaultTheme(this.wb);
g_oColorManager.setTheme(this.wb.theme);
var sMinorFont = null;
if(null != this.wb.theme.themeElements && null != this.wb.theme.themeElements.fontScheme && null != this.wb.theme.themeElements.fontScheme.minorFont)
sMinorFont = this.wb.theme.themeElements.fontScheme.minorFont.latin;
var sDefFont = "Calibri";
if(null != sMinorFont && "" != sMinorFont)
sDefFont = sMinorFont;
g_oDefaultFont = g_oDefaultFontAbs = new Font({
fn : sDefFont,
scheme : EFontScheme.fontschemeNone,
fs : 11,
b : false,
i : false,
u : EUnderline.underlineNone,
s : false,
c : g_oColorManager.getThemeColor(g_nColorTextDefault),
va : "baseline",
skip : false,
repeat : false
});
g_oDefaultFill = g_oDefaultFillAbs = new Fill({bg : null});
g_oDefaultBorder = g_oDefaultBorderAbs = new Border({
l : new BorderProp(),
t : new BorderProp(),
r : new BorderProp(),
b : new BorderProp(),
d : new BorderProp(),
ih : new BorderProp(),
iv : new BorderProp(),
dd : false,
du : false
});
g_oDefaultNum = g_oDefaultNumAbs = new Num({f : "General"});
g_oDefaultAlign = g_oDefaultAlignAbs = new Align({
hor : "none",
indent : 0,
RelativeIndent : 0,
shrink : false,
angle : 0,
ver : "bottom",
wrap : false
});
Asc.getBinaryOtherTableGVar(this.wb);
return oRes;
};
this.ReadOtherContent = function(type, length)
......@@ -6432,6 +6400,57 @@
return res;
};
}
function getBinaryOtherTableGVar(workbook)
{
var wb = this.wb ? this.wb : workbook;
g_oColorManager.setTheme(wb.theme);
var sMinorFont = null;
if(null != wb.theme.themeElements && null != wb.theme.themeElements.fontScheme && null != wb.theme.themeElements.fontScheme.minorFont)
sMinorFont = wb.theme.themeElements.fontScheme.minorFont.latin;
var sDefFont = "Calibri";
if(null != sMinorFont && "" != sMinorFont)
sDefFont = sMinorFont;
g_oDefaultFont = g_oDefaultFontAbs = new Font({
fn : sDefFont,
scheme : EFontScheme.fontschemeNone,
fs : 11,
b : false,
i : false,
u : EUnderline.underlineNone,
s : false,
c : g_oColorManager.getThemeColor(g_nColorTextDefault),
va : "baseline",
skip : false,
repeat : false
});
g_oDefaultFill = g_oDefaultFillAbs = new Fill({bg : null});
g_oDefaultBorder = g_oDefaultBorderAbs = new Border({
l : new BorderProp(),
t : new BorderProp(),
r : new BorderProp(),
b : new BorderProp(),
d : new BorderProp(),
ih : new BorderProp(),
iv : new BorderProp(),
dd : false,
du : false
});
g_oDefaultNum = g_oDefaultNumAbs = new Num({f : "General"});
g_oDefaultAlign = g_oDefaultAlignAbs = new Align({
hor : "none",
indent : 0,
RelativeIndent : 0,
shrink : false,
angle : 0,
ver : "bottom",
wrap : false
});
}
/** @constructor */
function BinaryFileReader(sUrlPath, isCopyPaste)
{
......@@ -7595,5 +7614,7 @@
window["Asc"].CTableStyleElement = CTableStyleElement;
window["Asc"].BinaryFileReader = BinaryFileReader;
window["Asc"].BinaryFileWriter = BinaryFileWriter;
window["Asc"].getBinaryOtherTableGVar = getBinaryOtherTableGVar;
}
)(jQuery, window);
\ No newline at end of file
......@@ -236,7 +236,19 @@
<script type="text/javascript" src="../../../../OfficeWeb/Word/Math/accent.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/Math/borderBox.js"></script>
<!--for copy/paste from excel-->
<script type="text/javascript" src="../../../vendor/jquery/jquery.min.js"></script>
<!--<script type="text/javascript" src="../../../../OfficeWeb/Excel/apiDefines.js"></script>-->
<script type="text/javascript" src="../../../../OfficeWeb/Excel/utils/utils.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Excel/model/CellComment.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Excel/model/Serialize.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Excel/model/WorkbookElems.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Excel/model/Workbook.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Excel/model/CellInfo.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Excel/model/AdvancedOptions.js"></script>
<!-- application -->
<script type="text/javascript" src="../../../sdk/Common/docscoapisettings.js"></script>
<script data-main="app" src="../../../vendor/requirejs/require.js"></script>
......
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