Commit 65583c6e authored by Igor.Zotov's avatar Igor.Zotov Committed by Alexander.Trofimov

включил copy/paste, где используются бинарные данные

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@48780 954022d7-b5bf-4e40-9824-e11837661b57
parent a4d4887d
...@@ -26,6 +26,7 @@ window.USER_AGENT_SAFARI_MACOS = (navigator.userAgent.toLowerCase().indexOf('saf ...@@ -26,6 +26,7 @@ window.USER_AGENT_SAFARI_MACOS = (navigator.userAgent.toLowerCase().indexOf('saf
var COPY_ELEMENT_ID = "SelectId"; var COPY_ELEMENT_ID = "SelectId";
var PASTE_ELEMENT_ID = "wrd_pastebin"; var PASTE_ELEMENT_ID = "wrd_pastebin";
var ELEMENT_DISPAY_STYLE = "none"; var ELEMENT_DISPAY_STYLE = "none";
var copyPasteUseBinery = true;
if (window.USER_AGENT_SAFARI_MACOS) if (window.USER_AGENT_SAFARI_MACOS)
{ {
...@@ -1610,10 +1611,11 @@ CopyProcessor.prototype = ...@@ -1610,10 +1611,11 @@ CopyProcessor.prototype =
} }
} }
this.oBinaryFileWriter.CopyEnd(); this.oBinaryFileWriter.CopyEnd();
if(this.oBinaryFileWriter.copyParams.itemCount > 0) if(copyPasteUseBinery && this.oBinaryFileWriter.copyParams.itemCount > 0)
{ {
var sBase64 = this.oBinaryFileWriter.GetResult(); var sBase64 = this.oBinaryFileWriter.GetResult();
//this.ElemToSelect.innerHTML = sBase64; if(this.ElemToSelect.children[0])
$(this.ElemToSelect.children[0]).addClass("docData;" + sBase64);
} }
} }
}; };
...@@ -2310,7 +2312,25 @@ PasteProcessor.prototype = ...@@ -2310,7 +2312,25 @@ PasteProcessor.prototype =
for(var i in oReadResult.numToNumClass) for(var i in oReadResult.numToNumClass)
{ {
var oNumClass = oReadResult.numToNumClass[i]; var oNumClass = oReadResult.numToNumClass[i];
this.oDocument.Numbering.Add_AbstractNum(oNumClass); var documentANum = this.oDocument.Numbering.AbstractNum;
//проверка на уже существующий такой же AbstractNum
var isUsuallyContains = false;
for(var n in documentANum)
{
var isEqual = documentANum[n].isEqual(oNumClass);
if(isEqual == true)
{
isUsuallyContains = true;
break;
}
}
if(!isUsuallyContains)
{
this.oDocument.Numbering.Add_AbstractNum(oNumClass);
}
else
oReadResult.numToNumClass[i] = documentANum[n];
} }
for(var i = 0, length = oReadResult.paraNumPrs.length; i < length; ++i) for(var i = 0, length = oReadResult.paraNumPrs.length; i < length; ++i)
{ {
...@@ -2322,6 +2342,7 @@ PasteProcessor.prototype = ...@@ -2322,6 +2342,7 @@ PasteProcessor.prototype =
numPr.NumId = 0; numPr.NumId = 0;
} }
//обрабатываем стили //обрабатываем стили
var isUsuallyContainsStyle;
var fParseStyle = function(aStyles, oDocumentStyles, oReadResult, bParaStyle) var fParseStyle = function(aStyles, oDocumentStyles, oReadResult, bParaStyle)
{ {
for(var i = 0, length = aStyles.length; i < length; ++i) for(var i = 0, length = aStyles.length; i < length; ++i)
...@@ -2333,12 +2354,14 @@ PasteProcessor.prototype = ...@@ -2333,12 +2354,14 @@ PasteProcessor.prototype =
for(var j in oDocumentStyles) for(var j in oDocumentStyles)
{ {
var styleDoc = oDocumentStyles[j]; var styleDoc = oDocumentStyles[j];
if(styleDoc.Name == stylePaste.style.Name) isUsuallyContainsStyle = styleDoc.isEqual(stylePaste.style);
if(isUsuallyContainsStyle)
{ {
if(bParaStyle) if(bParaStyle)
elem.pPr.PStyle = j; elem.pPr.PStyle = j;
else else
elem.pPr.TableStyle = j; elem.pPr.TableStyle = j;
break;
} }
} }
} }
...@@ -2379,8 +2402,44 @@ PasteProcessor.prototype = ...@@ -2379,8 +2402,44 @@ PasteProcessor.prototype =
// } // }
// }); // });
// return; // return;
this.oRootNode = node; if(copyPasteUseBinery)
{
var base64 = null;
var classNode;
if(node.children[0] && node.children[0].getAttribute("class") != null)
classNode = node.children[0].getAttribute("class");
else if(node.children[0] && node.children[0].children[0] && node.children[0].children[0].getAttribute("class") != null)
classNode = node.children[0].children[0].getAttribute("class");
if( classNode != null ){
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;
if(base64 != null)
aContent = this.ReadFromBinary(base64);
if(aContent)
{
this.aContent = aContent.content;
this.api.pre_Paste(aContent.fonts, aContent.images,
function() {
if(false == oThis.bNested)
{
oThis.InsertInDocument();
node.blur();
node.style.display = ELEMENT_DISPAY_STYLE;
}
});
return;
}
}
this.oRootNode = node;
this._Prepeare(node, this._Prepeare(node,
function(){ function(){
oThis.aContent = new Array(); oThis.aContent = new Array();
......
...@@ -1646,7 +1646,40 @@ CAbstractNum.prototype = ...@@ -1646,7 +1646,40 @@ CAbstractNum.prototype =
Load_LinkData : function(LinkData) Load_LinkData : function(LinkData)
{ {
} },
//сравниваем abstractNum
isEqual: function(abstractNum)
{
var lvlUsuallyAdd = this.Lvl;
var lvlNew = abstractNum.Lvl;
for(var lvl = 0; lvl < lvlUsuallyAdd.length; lvl++)
{
var LvlTextEqual;
var ParaPrEqual;
var TextPrEqual;
if(lvlUsuallyAdd[lvl].Format == lvlNew[lvl].Format && lvlUsuallyAdd[lvl].Jc == lvlNew[lvl].Jc && lvlUsuallyAdd[lvl].PStyle == lvlNew[lvl].PStyle && lvlUsuallyAdd[lvl].Restart == lvlNew[lvl].Restart && lvlUsuallyAdd[lvl].Start == lvlNew[lvl].Start && lvlUsuallyAdd[lvl].Suff == lvlNew[lvl].Suff)
{
LvlTextEqual = this._isEqualLvlText(lvlUsuallyAdd[lvl].LvlText, lvlNew[lvl].LvlText);
ParaPrEqual = lvlUsuallyAdd[lvl].ParaPr.isEqual(lvlUsuallyAdd[lvl].ParaPr, lvlNew[lvl].ParaPr);
TextPrEqual = lvlUsuallyAdd[lvl].TextPr.isEqual(lvlUsuallyAdd[lvl].TextPr, lvlNew[lvl].TextPr);
}
if(!LvlTextEqual || !ParaPrEqual || !TextPrEqual)
return false;
}
return true;
},
_isEqualLvlText: function(LvlTextOld, LvlTextNew)
{
for(var LvlText = 0; LvlText < LvlTextOld.length; LvlText++)
{
if(LvlTextOld[LvlText].Type != LvlTextNew[LvlText].Type || LvlTextOld[LvlText].Value != LvlTextNew[LvlText].Value)
return false;
}
return true;
}
}; };
function CNumbering() function CNumbering()
......
...@@ -1884,7 +1884,23 @@ CStyle.prototype = ...@@ -1884,7 +1884,23 @@ CStyle.prototype =
this.TableBand2Horz.TableCellPr.Shd = new CDocumentShd(); this.TableBand2Horz.TableCellPr.Shd = new CDocumentShd();
this.TableBand2Horz.TableCellPr.Shd.Value = shd_Clear; this.TableBand2Horz.TableCellPr.Shd.Value = shd_Clear;
this.TableBand2Horz.TableCellPr.Shd.Color.Set( Color3.r, Color3.g, Color3.b ); this.TableBand2Horz.TableCellPr.Shd.Color.Set( Color3.r, Color3.g, Color3.b );
} },
isEqual: function(cStyles)
{
var result = false;
if(this.BasedOn == cStyles.BasedOn && this.Name == cStyles.Name && this.Next == cStyles.Next && this.Type == cStyles.Type && this.hidden == cStyles.hidden)
{
if(this.qFormat == cStyles.qFormat && this.semiHidden == cStyles.semiHidden && this.uiPriority == cStyles.uiPriority && this.unhideWhenUsed == cStyles.unhideWhenUsed)
{
var isEqualParaPr = this.ParaPr.isEqual(this.ParaPr, cStyles.ParaPr);
var isEqualTextPr = this.TextPr.isEqual(this.TextPr, cStyles.TextPr);
if(isEqualParaPr && isEqualTextPr)
result = true;
}
}
return result;
}
}; };
function CStyles() function CStyles()
...@@ -5146,7 +5162,36 @@ CTextPr.prototype = ...@@ -5146,7 +5162,36 @@ CTextPr.prototype =
Size : SizeCS Size : SizeCS
}; };
} }
} },
isEqual: function(TextPrOld, TextPrNew)
{
if(TextPrOld == undefined || TextPrNew == undefined)
return false;
for(var TextPr in TextPrOld)
{
if(typeof TextPrOld[TextPr] == 'object')
{
/*for(var cpPr in TextPrOld[TextPr])
{
if(TextPrOld[TextPr][cpPr] != TextPrNew[TextPr][cpPr])
return false;
}*/
this.isEqual(TextPrOld[TextPr],TextPrNew[TextPr]);
}
else
{
if(typeof TextPrOld[TextPr] == "number" && typeof TextPrNew[TextPr] == "number")
{
if(Math.abs(TextPrOld[TextPr] - TextPrNew[TextPr]) > 0.001)
return false;
}
else if(TextPrOld[TextPr] != TextPrNew[TextPr])
return false;
}
}
return true;
}
} }
function CParaTab(Value, Pos) function CParaTab(Value, Pos)
...@@ -6467,7 +6512,32 @@ CParaPr.prototype = ...@@ -6467,7 +6512,32 @@ CParaPr.prototype =
this.FramePr = new CFramePr(); this.FramePr = new CFramePr();
this.FramePr.Read_FromBinary( Reader ); this.FramePr.Read_FromBinary( Reader );
} }
} },
isEqual: function(ParaPrUOld,ParaPrNew)
{
if(ParaPrUOld == undefined || ParaPrNew == undefined)
return false;
for(var pPr in ParaPrUOld)
{
if(typeof ParaPrUOld[pPr] == 'object')
{
if(!this.isEqual(ParaPrUOld[pPr],ParaPrNew[pPr]))
return false
}
else
{
if(typeof ParaPrUOld[pPr] == "number" && typeof ParaPrNew[pPr] == "number")
{
if(Math.abs(ParaPrUOld[pPr] - ParaPrNew[pPr]) > 0.001)
return false;
}
else if(ParaPrUOld[pPr] != ParaPrNew[pPr])
return false;
}
}
return true;
}
} }
function Copy_Bounds(Bounds) function Copy_Bounds(Bounds)
......
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