Commit 00e903fe authored by Igor.Zotov's avatar Igor.Zotov Committed by Alexander.Trofimov

вставка html в автофигуру, добавлен wordcopypaste.js в excel, переименованы функции

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@56322 954022d7-b5bf-4e40-9824-e11837661b57
parent 37b07bc7
...@@ -2566,7 +2566,7 @@ function Editor_Paste_Exec(api, pastebin, nodeDisplay) ...@@ -2566,7 +2566,7 @@ function Editor_Paste_Exec(api, pastebin, nodeDisplay)
function trimString( str ){ function trimString( str ){
return str.replace(/^\s+|\s+$/g, '') ; return str.replace(/^\s+|\s+$/g, '') ;
}; };
function PasteProcessor(api, bUploadImage, bUploadFonts, bNested) function PasteProcessor(api, bUploadImage, bUploadFonts, bNested, pasteInExcel)
{ {
this.oRootNode = null; this.oRootNode = null;
this.api = api; this.api = api;
...@@ -2582,6 +2582,8 @@ function PasteProcessor(api, bUploadImage, bUploadFonts, bNested) ...@@ -2582,6 +2582,8 @@ function PasteProcessor(api, bUploadImage, bUploadFonts, bNested)
this.oImages = {}; this.oImages = {};
this.aContent = []; this.aContent = [];
this.pasteInExcel = pasteInExcel;
//��� ������� ������ � ������, ��� ����������� �� word � chrome ���������� ������ ������� ��� <p> //��� ������� ������ � ������, ��� ����������� �� word � chrome ���������� ������ ������� ��� <p>
this.bIgnoreNoBlockText = false; this.bIgnoreNoBlockText = false;
...@@ -4464,7 +4466,7 @@ PasteProcessor.prototype = ...@@ -4464,7 +4466,7 @@ PasteProcessor.prototype =
} }
var oDocument = this.oDocument; var oDocument = this.oDocument;
//Heading //Heading
if(null != pNoHtmlPr.hLevel) if(null != pNoHtmlPr.hLevel && oDocument.Styles)
Para.Style_Add(oDocument.Styles.Get_Default_Heading(pNoHtmlPr.hLevel)); Para.Style_Add(oDocument.Styles.Get_Default_Heading(pNoHtmlPr.hLevel));
var pPr = Para.Pr; var pPr = Para.Pr;
...@@ -4684,7 +4686,7 @@ PasteProcessor.prototype = ...@@ -4684,7 +4686,7 @@ PasteProcessor.prototype =
NumId = PrevNumPr.NumId; NumId = PrevNumPr.NumId;
} }
} }
if(null == NumId) if(null == NumId && this.pasteInExcel !== true)
{ {
//������� ����� ������ //������� ����� ������
NumId = this.oLogicDocument.Numbering.Create_AbstractNum(); NumId = this.oLogicDocument.Numbering.Create_AbstractNum();
...@@ -4744,7 +4746,8 @@ PasteProcessor.prototype = ...@@ -4744,7 +4746,8 @@ PasteProcessor.prototype =
} }
} }
} }
Para.Numbering_Add( NumId, 0 ); if(this.pasteInExcel !== true)
Para.Numbering_Add( NumId, 0 );
} }
else else
{ {
...@@ -5701,7 +5704,7 @@ PasteProcessor.prototype = ...@@ -5701,7 +5704,7 @@ PasteProcessor.prototype =
return bAddParagraph; return bAddParagraph;
} }
var sNodeName = node.nodeName.toLowerCase(); var sNodeName = node.nodeName.toLowerCase();
if("table" == sNodeName) if("table" == sNodeName && this.pasteInExcel !== true)
{ {
if(g_bIsDocumentCopyPaste) if(g_bIsDocumentCopyPaste)
{ {
...@@ -5749,7 +5752,7 @@ PasteProcessor.prototype = ...@@ -5749,7 +5752,7 @@ PasteProcessor.prototype =
} }
} }
if("img" == sNodeName) if("img" == sNodeName && this.pasteInExcel !== true)
{ {
if(g_bIsDocumentCopyPaste) if(g_bIsDocumentCopyPaste)
{ {
......
...@@ -1346,12 +1346,12 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -1346,12 +1346,12 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
// Какая-то непонятная заглушка, чтобы не падало в ipad // Какая-то непонятная заглушка, чтобы не падало в ipad
if (this.isMobileVersion) { if (this.isMobileVersion) {
window.USER_AGENT_SAFARI_MACOS = false; window.USER_AGENT_SAFARI_MACOS = false;
PASTE_ELEMENT_ID = "wrd_pastebin"; PASTE_ELEMENT_ID2 = "wrd_pastebin";
ELEMENT_DISPAY_STYLE = "none"; ELEMENT_DISPAY_STYLE2 = "none";
} }
if (window.USER_AGENT_SAFARI_MACOS) if (window.USER_AGENT_SAFARI_MACOS)
setInterval(SafariIntervalFocus, 10); setInterval(SafariIntervalFocus2, 10);
}, },
_onGetEditorPermissions: function(response) { _onGetEditorPermissions: function(response) {
......
...@@ -96,6 +96,8 @@ ...@@ -96,6 +96,8 @@
<script type="text/javascript" src="../../../../OfficeWeb/Common/FontsFreeType/font_engine.js"></script> <script type="text/javascript" src="../../../../OfficeWeb/Common/FontsFreeType/font_engine.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/FontsFreeType/FontFile.js"></script> <script type="text/javascript" src="../../../../OfficeWeb/Common/FontsFreeType/FontFile.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/FontsFreeType/FontManager.js"></script> <script type="text/javascript" src="../../../../OfficeWeb/Common/FontsFreeType/FontManager.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/wordcopypaste.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/Drawing/HatchPattern.js"></script> <script type="text/javascript" src="../../../../OfficeWeb/Word/Drawing/HatchPattern.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/Drawing/WorkEvents.js"></script> <script type="text/javascript" src="../../../../OfficeWeb/Word/Drawing/WorkEvents.js"></script>
......
...@@ -187,11 +187,11 @@ ...@@ -187,11 +187,11 @@
var found = true; var found = true;
if (!t.element) { if (!t.element) {
t.element = doc.getElementById(COPY_ELEMENT_ID); t.element = doc.getElementById(COPY_ELEMENT_ID2);
if (!t.element) {found = false; t.element = doc.createElement("DIV");} if (!t.element) {found = false; t.element = doc.createElement("DIV");}
} }
t.element.id = COPY_ELEMENT_ID; t.element.id = COPY_ELEMENT_ID2;
t.element.setAttribute("class", COPYPASTE_ELEMENT_CLASS); t.element.setAttribute("class", COPYPASTE_ELEMENT_CLASS);
t.element.style.position = "absolute"; t.element.style.position = "absolute";
// Если сделать width маленьким, то параграф будет постоянно переноситься по span // Если сделать width маленьким, то параграф будет постоянно переноситься по span
...@@ -202,7 +202,7 @@ ...@@ -202,7 +202,7 @@
t.element.style.height = '100px'; t.element.style.height = '100px';
t.element.style.overflow = 'hidden'; t.element.style.overflow = 'hidden';
t.element.style.zIndex = -1000; t.element.style.zIndex = -1000;
t.element.style.display = ELEMENT_DISPAY_STYLE; t.element.style.display = ELEMENT_DISPAY_STYLE2;
t.element.setAttribute("contentEditable", true); t.element.setAttribute("contentEditable", true);
if (!found) {doc.body.appendChild(t.element);} if (!found) {doc.body.appendChild(t.element);}
...@@ -228,7 +228,7 @@ ...@@ -228,7 +228,7 @@
t.elementText.style.overflow = 'hidden'; t.elementText.style.overflow = 'hidden';
t.elementText.style.zIndex = -1000; t.elementText.style.zIndex = -1000;
//if(AscBrowser.isIE) //if(AscBrowser.isIE)
t.elementText.style.display = ELEMENT_DISPAY_STYLE; t.elementText.style.display = ELEMENT_DISPAY_STYLE2;
t.elementText.setAttribute("contentEditable", true); t.elementText.setAttribute("contentEditable", true);
if (!foundText) {doc.body.appendChild(t.elementText);} if (!foundText) {doc.body.appendChild(t.elementText);}
...@@ -290,8 +290,8 @@ ...@@ -290,8 +290,8 @@
this.lStorage.htmlInShape = text; this.lStorage.htmlInShape = text;
else else
{ {
var fullUrl = this._getUseFullUrl(); var fullUrl = this._getUseFullUrl();
window.global_pptx_content_writer.Start_UseFullUrl(fullUrl); window.global_pptx_content_writer.Start_UseFullUrl(fullUrl);
var oBinaryFileWriter = new Asc.BinaryFileWriter(worksheet.model.workbook, worksheet.activeRange); var oBinaryFileWriter = new Asc.BinaryFileWriter(worksheet.model.workbook, worksheet.activeRange);
var sBase64 = oBinaryFileWriter.Write(); var sBase64 = oBinaryFileWriter.Write();
...@@ -304,7 +304,7 @@ ...@@ -304,7 +304,7 @@
$(this.element.children[0]).addClass("xslData;" + sBase64); $(this.element.children[0]).addClass("xslData;" + sBase64);
//for buttons copy/paste //for buttons copy/paste
this.lStorage = sBase64; this.lStorage = sBase64;
window.global_pptx_content_writer.End_UseFullUrl() window.global_pptx_content_writer.End_UseFullUrl()
} }
...@@ -621,7 +621,7 @@ ...@@ -621,7 +621,7 @@
window.setTimeout( window.setTimeout(
function() { function() {
// отменяем возможность выделения // отменяем возможность выделения
t.element.style.display = ELEMENT_DISPAY_STYLE; t.element.style.display = ELEMENT_DISPAY_STYLE2;
doc.body.style.MozUserSelect = "none"; doc.body.style.MozUserSelect = "none";
doc.body.style["-khtml-user-select"] = "none"; doc.body.style["-khtml-user-select"] = "none";
doc.body.style["-o-user-select"] = "none"; doc.body.style["-o-user-select"] = "none";
...@@ -636,7 +636,7 @@ ...@@ -636,7 +636,7 @@
} }
} }
t.elementText.style.display = ELEMENT_DISPAY_STYLE; t.elementText.style.display = ELEMENT_DISPAY_STYLE2;
var textInsert = t.elementText.value; var textInsert = t.elementText.value;
if(isOnlyLocalBufferSafari && navigator.userAgent.toLowerCase().indexOf('safari') > -1 && navigator.userAgent.toLowerCase().indexOf('mac') && t.lStorageText) if(isOnlyLocalBufferSafari && navigator.userAgent.toLowerCase().indexOf('safari') > -1 && navigator.userAgent.toLowerCase().indexOf('mac') && t.lStorageText)
textInsert = t.lStorageText; textInsert = t.lStorageText;
...@@ -848,10 +848,10 @@ ...@@ -848,10 +848,10 @@
if(!isTruePaste) if(!isTruePaste)
t._editorPasteExec(worksheet, pastebin); t._editorPasteExec(worksheet, pastebin);
pastebin.style.display = ELEMENT_DISPAY_STYLE; pastebin.style.display = ELEMENT_DISPAY_STYLE2;
if(AscBrowser.isIE) if(AscBrowser.isIE)
pastebin.style.display = ELEMENT_DISPAY_STYLE; pastebin.style.display = ELEMENT_DISPAY_STYLE2;
if (callback && callback.call) {callback();} if (callback && callback.call) {callback();}
}; };
...@@ -866,10 +866,10 @@ ...@@ -866,10 +866,10 @@
{ {
//var oWordControl = api.WordControl; //var oWordControl = api.WordControl;
var t = this; var t = this;
var pastebin = document.getElementById(PASTE_ELEMENT_ID); var pastebin = document.getElementById(PASTE_ELEMENT_ID2);
if(!pastebin){ if(!pastebin){
pastebin = document.createElement("div"); pastebin = document.createElement("div");
pastebin.setAttribute( 'id', PASTE_ELEMENT_ID ); pastebin.setAttribute( 'id', PASTE_ELEMENT_ID2 );
pastebin.setAttribute( 'class', COPYPASTE_ELEMENT_CLASS ); pastebin.setAttribute( 'class', COPYPASTE_ELEMENT_CLASS );
pastebin.style.position = 'absolute'; pastebin.style.position = 'absolute';
pastebin.style.top = '100px'; pastebin.style.top = '100px';
...@@ -1118,7 +1118,7 @@ ...@@ -1118,7 +1118,7 @@
bExist = true; bExist = true;
} }
ifr.style.display = ELEMENT_DISPAY_STYLE; ifr.style.display = ELEMENT_DISPAY_STYLE2;
} }
if(bExist) if(bExist)
{ {
...@@ -1433,7 +1433,7 @@ ...@@ -1433,7 +1433,7 @@
_IsBlockElem : function(name) _IsBlockElem : function(name)
{ {
if( "p" == name || "div" == name || "ul" == name || "ol" == name || "li" == name || "table" == name || if( "p" == name || "div" == name || "ul" == name || "ol" == name || "li" == name || "table" == name || "tbody" == name || "tr" == name || "td" == name || "th" == name ||
"h1" == name || "h2" == name || "h3" == name || "h4" == name || "h5" == name || "h6" == name || "center" == name) "h1" == name || "h2" == name || "h3" == name || "h4" == name || "h5" == name || "h6" == name || "center" == name)
return true; return true;
return false; return false;
...@@ -1679,15 +1679,22 @@ ...@@ -1679,15 +1679,22 @@
return false; return false;
}, },
_pasteInShape: function(worksheet, node, onlyFromLocalStorage) _pasteInShape: function(worksheet, node, onlyFromLocalStorage, targetDocContent)
{ {
if(onlyFromLocalStorage) var oPasteProcessor = new PasteProcessor({WordControl:{m_oLogicDocument: targetDocContent}, FontLoader: {}}, false, false, true, true);
oPasteProcessor._Execute(node, {}, true, true, false);
oPasteProcessor.InsertInPlace(targetDocContent , oPasteProcessor.aContent);
//targetDocContent.Parent.parent.recalculate();
/*if(onlyFromLocalStorage)
{ {
if(t.lStorage && t.lStorage.htmlInShape) if(t.lStorage && t.lStorage.htmlInShape)
worksheet.objectRender.controller.curState.textObject.txBody.insertHtml(t.lStorage.htmlInShape); worksheet.objectRender.controller.curState.textObject.txBody.insertHtml(t.lStorage.htmlInShape);
} }
else else
worksheet.objectRender.controller.curState.textObject.txBody.insertHtml(node); worksheet.objectRender.controller.curState.textObject.txBody.insertHtml(node);*/
window.GlobalPasteFlag = false; window.GlobalPasteFlag = false;
window.GlobalPasteFlagCounter = 0; window.GlobalPasteFlagCounter = 0;
}, },
...@@ -1706,7 +1713,7 @@ ...@@ -1706,7 +1713,7 @@
var isIntoShape = worksheet.objectRender.controller.getTargetDocContent(); var isIntoShape = worksheet.objectRender.controller.getTargetDocContent();
if(isIntoShape) if(isIntoShape)
{ {
this._pasteInShape(worksheet, node, onlyFromLocalStorage); this._pasteInShape(worksheet, node, onlyFromLocalStorage, isIntoShape);
return; return;
}; };
...@@ -2342,7 +2349,7 @@ ...@@ -2342,7 +2349,7 @@
window.setTimeout( window.setTimeout(
function() { function() {
// отменяем возможность выделения // отменяем возможность выделения
t.element.style.display = ELEMENT_DISPAY_STYLE; t.element.style.display = ELEMENT_DISPAY_STYLE2;
doc.body.style.MozUserSelect = "none"; doc.body.style.MozUserSelect = "none";
doc.body.style["-khtml-user-select"] = "none"; doc.body.style["-khtml-user-select"] = "none";
doc.body.style["-o-user-select"] = "none"; doc.body.style["-o-user-select"] = "none";
...@@ -5104,9 +5111,9 @@ window.USER_AGENT_WEBKIT = AscBrowser.isWebkit; ...@@ -5104,9 +5111,9 @@ window.USER_AGENT_WEBKIT = AscBrowser.isWebkit;
window.GlobalPasteFlag = false; window.GlobalPasteFlag = false;
window.GlobalPasteFlagCounter = 0; window.GlobalPasteFlagCounter = 0;
var COPY_ELEMENT_ID = "clipboard-helper"; var COPY_ELEMENT_ID2 = "clipboard-helper";
var PASTE_ELEMENT_ID = "wrd_pastebin"; var PASTE_ELEMENT_ID2 = "wrd_pastebin";
var ELEMENT_DISPAY_STYLE = "none"; var ELEMENT_DISPAY_STYLE2 = "none";
var COPYPASTE_ELEMENT_CLASS = "sdk-element"; var COPYPASTE_ELEMENT_CLASS = "sdk-element";
var kElementTextId = "clipboard-helper-text"; var kElementTextId = "clipboard-helper-text";
var isNeedEmptyAfterCut = false; var isNeedEmptyAfterCut = false;
...@@ -5129,17 +5136,17 @@ function CopyPasteCorrectString(str) ...@@ -5129,17 +5136,17 @@ function CopyPasteCorrectString(str)
if (window.USER_AGENT_SAFARI_MACOS) if (window.USER_AGENT_SAFARI_MACOS)
{ {
var PASTE_ELEMENT_ID = "clipboard-helper"; var PASTE_ELEMENT_ID2 = "clipboard-helper";
var ELEMENT_DISPAY_STYLE = "block"; var ELEMENT_DISPAY_STYLE2 = "block";
} }
function SafariIntervalFocus() function SafariIntervalFocus2()
{ {
var api = window["Asc"]["editor"]; var api = window["Asc"]["editor"];
if (api) if (api)
{ {
if((api.wb && api.wb.cellEditor && api.wb.cellEditor != null && api.wb.cellEditor.isTopLineActive) || (api.wb && api.wb.getWorksheet() && api.wb.getWorksheet().isSelectionDialogMode)) if((api.wb && api.wb.cellEditor && api.wb.cellEditor != null && api.wb.cellEditor.isTopLineActive) || (api.wb && api.wb.getWorksheet() && api.wb.getWorksheet().isSelectionDialogMode))
return; return;
var pastebin = document.getElementById(COPY_ELEMENT_ID); var pastebin = document.getElementById(COPY_ELEMENT_ID2);
var pastebinText = document.getElementById(kElementTextId); var pastebinText = document.getElementById(kElementTextId);
if(pastebinText && (api.wb && api.wb.getWorksheet() && api.wb.getWorksheet().isCellEditMode) && api.IsFocus) if(pastebinText && (api.wb && api.wb.getWorksheet() && api.wb.getWorksheet().isCellEditMode) && api.IsFocus)
{ {
...@@ -5150,15 +5157,15 @@ function SafariIntervalFocus() ...@@ -5150,15 +5157,15 @@ function SafariIntervalFocus()
else if(!pastebin || !pastebinText) else if(!pastebin || !pastebinText)
{ {
// create // create
Editor_CopyPaste_Create(api); Editor_CopyPaste_Create2(api);
} }
} }
} }
function Editor_CopyPaste_Create(api) function Editor_CopyPaste_Create2(api)
{ {
var ElemToSelect = document.createElement("div"); var ElemToSelect = document.createElement("div");
ElemToSelect.id = COPY_ELEMENT_ID; ElemToSelect.id = COPY_ELEMENT_ID2;
ElemToSelect.setAttribute("class", COPYPASTE_ELEMENT_CLASS); ElemToSelect.setAttribute("class", COPYPASTE_ELEMENT_CLASS);
ElemToSelect.style.left = '0px'; ElemToSelect.style.left = '0px';
...@@ -5224,7 +5231,7 @@ function Editor_CopyPaste_Create(api) ...@@ -5224,7 +5231,7 @@ function Editor_CopyPaste_Create(api)
elementText.style.top = '-100px'; elementText.style.top = '-100px';
elementText.style.overflow = 'hidden'; elementText.style.overflow = 'hidden';
elementText.style.zIndex = -1000; elementText.style.zIndex = -1000;
elementText.style.display = ELEMENT_DISPAY_STYLE; elementText.style.display = ELEMENT_DISPAY_STYLE2;
elementText.setAttribute("contentEditable", true); elementText.setAttribute("contentEditable", true);
elementText.setAttribute("class", COPYPASTE_ELEMENT_CLASS); elementText.setAttribute("class", COPYPASTE_ELEMENT_CLASS);
...@@ -5347,3 +5354,38 @@ function CreateBinaryReader(szSrc, offset, srcLen) ...@@ -5347,3 +5354,38 @@ function CreateBinaryReader(szSrc, offset, srcLen)
return stream; return stream;
} }
function Common_CmpObj2(Obj1, Obj2)
{
if(!Obj1 || !Obj2 || typeof(Obj1) != typeof(Obj2))
return false;
var p, v1, v2;
//проверяем чтобы Obj1 имел теже свойства что и Obj2
for(p in Obj2)
{
if(!Obj1.hasOwnProperty(p))
return false;
}
//проверяем чтобы Obj2 имел теже свойства что и Obj1 и сравниваем их
for(p in Obj1)
{
if(Obj2.hasOwnProperty(p))
{
v1 = Obj1[p];
v2 = Obj2[p];
if(v1 && v2 && 'object' === typeof(v1) && 'object' === typeof(v2) )
{
if( false == Common_CmpObj2(v1, v2))
return false;
}
else
{
if(v1 != v2)
return false;
}
}
else
return false;
}
return true;
};
...@@ -918,7 +918,7 @@ ...@@ -918,7 +918,7 @@
{ {
if (0 === window.GlobalPasteFlagCounter) if (0 === window.GlobalPasteFlagCounter)
{ {
SafariIntervalFocus(); SafariIntervalFocus2();
window.GlobalPasteFlag = true; window.GlobalPasteFlag = true;
t.handlers.trigger("paste"); t.handlers.trigger("paste");
} }
......
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