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

utf-16 символы на открытие и copy/paste

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@58546 954022d7-b5bf-4e40-9824-e11837661b57
parent 15189e6f
...@@ -14,6 +14,28 @@ function fSortAscending( a, b ) { ...@@ -14,6 +14,28 @@ function fSortAscending( a, b ) {
function fSortDescending( a, b ) { function fSortDescending( a, b ) {
return b - a; return b - a;
} }
function isLeadingSurrogateChar(nCharCode) {
return (nCharCode >= 0xD800 && nCharCode <= 0xDFFF);
}
function decodeSurrogateChar(nLeadingChar, nTrailingChar) {
if (nLeadingChar < 0xDC00 && nTrailingChar >= 0xDC00 && nTrailingChar <= 0xDFFF)
return 0x10000 + ((nLeadingChar & 0x3FF) << 10) | (nTrailingChar & 0x3FF);
else
return null;
}
function encodeSurrogateChar(nUnicode) {
if(nUnicode < 0x10000)
{
return String.fromCharCode(nUnicode);
}
else
{
nUnicode = nUnicode - 0x10000;
var nLeadingChar = 0xD800 | (nUnicode >> 10);
var nTrailingChar = 0xDC00 | (nUnicode & 0x3FF);
return String.fromCharCode(nLeadingChar) + String.fromCharCode(nTrailingChar);
}
}
/** /**
* @constructor * @constructor
......
...@@ -560,7 +560,7 @@ CopyProcessor.prototype = ...@@ -560,7 +560,7 @@ CopyProcessor.prototype =
{ {
case para_Text: case para_Text:
//���������� ����������� //���������� �����������
var sValue = String.fromCharCode(ParaItem.Value); var sValue = encodeSurrogateChar(ParaItem.Value);
if(sValue) if(sValue)
sRes += CopyPasteCorrectString(sValue); sRes += CopyPasteCorrectString(sValue);
break; break;
...@@ -4813,9 +4813,9 @@ PasteProcessor.prototype = ...@@ -4813,9 +4813,9 @@ PasteProcessor.prototype =
if(text_decoration) if(text_decoration)
{ {
if(-1 != text_decoration.indexOf("underline")) if(-1 != text_decoration.indexOf("underline"))
underline = true; underline = true;
else if(-1 != text_decoration.indexOf("none") && node.parentElement && node.parentElement.nodeName.toLowerCase() == "a") else if(-1 != text_decoration.indexOf("none") && node.parentElement && node.parentElement.nodeName.toLowerCase() == "a")
underline = false; underline = false;
if(-1 != text_decoration.indexOf("line-through")) if(-1 != text_decoration.indexOf("line-through"))
Strikeout = true; Strikeout = true;
...@@ -5602,14 +5602,27 @@ PasteProcessor.prototype = ...@@ -5602,14 +5602,27 @@ PasteProcessor.prototype =
this._commit_rPr(oTargetNode, bUseOnlyInherit); this._commit_rPr(oTargetNode, bUseOnlyInherit);
for(var i = 0, length = value.length; i < length; i++) for(var i = 0, length = value.length; i < length; i++)
{ {
var Char = value.charAt(i); var nUnicode = null;
var Code = value.charCodeAt(i); var nCharCode = value.charCodeAt(i);
var Item; if (isLeadingSurrogateChar(nCharCode)) {
if(32 == Code || 160 == Code) //160 - nbsp if (i + 1 < length) {
Item = new ParaSpace(); i++;
var nTrailingChar = value.charCodeAt(i);
nUnicode = decodeSurrogateChar(nCharCode, nTrailingChar);
}
}
else else
Item = new ParaText( value[i] ); nUnicode = nCharCode;
this._Paragraph_Add( Item ); if (null != nUnicode) {
var Item;
if (0x20 != nUnicode && 0xA0 != nUnicode) {
Item = new ParaText();
Item.Value = nUnicode;
}
else
Item = new ParaSpace();
this._Paragraph_Add(Item);
}
} }
} }
} }
...@@ -5877,22 +5890,22 @@ PasteProcessor.prototype = ...@@ -5877,22 +5890,22 @@ PasteProcessor.prototype =
TextPr.Unifill = CreateUniFillSchemeColorWidthTint(11, 0); TextPr.Unifill = CreateUniFillSchemeColorWidthTint(11, 0);
TextPr.Underline = true; TextPr.Underline = true;
oHyperlink.Apply_TextPr( TextPr, undefined, true ); oHyperlink.Apply_TextPr( TextPr, undefined, true );
} }
//проставляем rStyle //проставляем rStyle
if(oHyperlink.Content && oHyperlink.Content.length) if(oHyperlink.Content && oHyperlink.Content.length)
{ {
if(this.oLogicDocument && this.oLogicDocument.Styles && this.oLogicDocument.Styles.Default && this.oLogicDocument.Styles.Default.Hyperlink && this.oLogicDocument.Styles.Style) if(this.oLogicDocument && this.oLogicDocument.Styles && this.oLogicDocument.Styles.Default && this.oLogicDocument.Styles.Default.Hyperlink && this.oLogicDocument.Styles.Style)
{ {
var hyperLinkStyle = this.oLogicDocument.Styles.Default.Hyperlink; var hyperLinkStyle = this.oLogicDocument.Styles.Default.Hyperlink;
for(var k = 0; k < oHyperlink.Content.length; k++) for(var k = 0; k < oHyperlink.Content.length; k++)
{ {
if(oHyperlink.Content[k].Type == para_Run) if(oHyperlink.Content[k].Type == para_Run)
oHyperlink.Content[k].Set_RStyle(hyperLinkStyle); oHyperlink.Content[k].Set_RStyle(hyperLinkStyle);
} }
} }
} }
this._Paragraph_Add(oHyperlink); this._Paragraph_Add(oHyperlink);
} }
...@@ -5968,14 +5981,27 @@ PasteProcessor.prototype = ...@@ -5968,14 +5981,27 @@ PasteProcessor.prototype =
} }
for(var i = 0, length = value.length; i < length; i++) for(var i = 0, length = value.length; i < length; i++)
{ {
var Char = value.charAt(i); var nUnicode = null;
var Code = value.charCodeAt(i); var nCharCode = value.charCodeAt(i);
var Item; if (isLeadingSurrogateChar(nCharCode)) {
if(32 == Code || 160 == Code) //160 - nbsp if (i + 1 < length) {
Item = new ParaSpace(); i++;
var nTrailingChar = value.charCodeAt(i);
nUnicode = decodeSurrogateChar(nCharCode, nTrailingChar);
}
}
else else
Item = new ParaText( value[i] ); nUnicode = nCharCode;
shape.paragraphAdd(Item); if (null != nUnicode) {
var Item;
if (0x20 != nUnicode && 0xA0 != nUnicode) {
Item = new ParaText();
Item.Value = nUnicode;
}
else
Item = new ParaSpace();
shape.paragraphAdd(Item);
}
} }
} }
......
...@@ -3748,7 +3748,7 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap, copyPa ...@@ -3748,7 +3748,7 @@ function BinaryDocumentTableWriter(memory, doc, oMapCommentId, oNumIdMap, copyPa
switch ( item.Type ) switch ( item.Type )
{ {
case para_Text: case para_Text:
sCurText += String.fromCharCode(item.Value); sCurText += encodeSurrogateChar(item.Value);
break; break;
case para_Space: case para_Space:
sCurText += " "; sCurText += " ";
...@@ -7542,12 +7542,30 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow ...@@ -7542,12 +7542,30 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
this.oCurComments[i] += text; this.oCurComments[i] += text;
} }
for (var i = 0; i < text.length; ++i) for (var i = 0; i < text.length; ++i)
{ {
if (text[i] != ' ') var nUnicode = null;
oPos.run.Add_ToContent(oPos.pos, new ParaText(text[i]), false); var nCharCode = text.charCodeAt(i);
else if (isLeadingSurrogateChar(nCharCode))
oPos.run.Add_ToContent(oPos.pos, new ParaSpace(), false); {
oPos.pos++; if(i + 1 < text.length)
{
i++;
var nTrailingChar = text.charCodeAt(i);
nUnicode = decodeSurrogateChar(nCharCode, nTrailingChar);
}
}
else
nUnicode = nCharCode;
if (null != nUnicode) {
if (0x20 != nUnicode) {
var oNewParaText = new ParaText();
oNewParaText.Value = nUnicode;
oPos.run.Add_ToContent(oPos.pos, oNewParaText, false);
}
else
oPos.run.Add_ToContent(oPos.pos, new ParaSpace(), false);
oPos.pos++;
}
} }
} }
else if (c_oSerRunType.tab === type) else if (c_oSerRunType.tab === type)
......
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