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 ) {
function fSortDescending( a, b ) {
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
......
......@@ -560,7 +560,7 @@ CopyProcessor.prototype =
{
case para_Text:
//���������� �����������
var sValue = String.fromCharCode(ParaItem.Value);
var sValue = encodeSurrogateChar(ParaItem.Value);
if(sValue)
sRes += CopyPasteCorrectString(sValue);
break;
......@@ -4813,9 +4813,9 @@ PasteProcessor.prototype =
if(text_decoration)
{
if(-1 != text_decoration.indexOf("underline"))
underline = true;
else if(-1 != text_decoration.indexOf("none") && node.parentElement && node.parentElement.nodeName.toLowerCase() == "a")
underline = false;
underline = true;
else if(-1 != text_decoration.indexOf("none") && node.parentElement && node.parentElement.nodeName.toLowerCase() == "a")
underline = false;
if(-1 != text_decoration.indexOf("line-through"))
Strikeout = true;
......@@ -5602,14 +5602,27 @@ PasteProcessor.prototype =
this._commit_rPr(oTargetNode, bUseOnlyInherit);
for(var i = 0, length = value.length; i < length; i++)
{
var Char = value.charAt(i);
var Code = value.charCodeAt(i);
var Item;
if(32 == Code || 160 == Code) //160 - nbsp
Item = new ParaSpace();
var nUnicode = null;
var nCharCode = value.charCodeAt(i);
if (isLeadingSurrogateChar(nCharCode)) {
if (i + 1 < length) {
i++;
var nTrailingChar = value.charCodeAt(i);
nUnicode = decodeSurrogateChar(nCharCode, nTrailingChar);
}
}
else
Item = new ParaText( value[i] );
this._Paragraph_Add( Item );
nUnicode = nCharCode;
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 =
TextPr.Unifill = CreateUniFillSchemeColorWidthTint(11, 0);
TextPr.Underline = true;
oHyperlink.Apply_TextPr( TextPr, undefined, true );
}
//проставляем rStyle
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)
{
var hyperLinkStyle = this.oLogicDocument.Styles.Default.Hyperlink;
for(var k = 0; k < oHyperlink.Content.length; k++)
{
if(oHyperlink.Content[k].Type == para_Run)
oHyperlink.Content[k].Set_RStyle(hyperLinkStyle);
}
}
}
}
//проставляем rStyle
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)
{
var hyperLinkStyle = this.oLogicDocument.Styles.Default.Hyperlink;
for(var k = 0; k < oHyperlink.Content.length; k++)
{
if(oHyperlink.Content[k].Type == para_Run)
oHyperlink.Content[k].Set_RStyle(hyperLinkStyle);
}
}
}
this._Paragraph_Add(oHyperlink);
}
......@@ -5968,14 +5981,27 @@ PasteProcessor.prototype =
}
for(var i = 0, length = value.length; i < length; i++)
{
var Char = value.charAt(i);
var Code = value.charCodeAt(i);
var Item;
if(32 == Code || 160 == Code) //160 - nbsp
Item = new ParaSpace();
var nUnicode = null;
var nCharCode = value.charCodeAt(i);
if (isLeadingSurrogateChar(nCharCode)) {
if (i + 1 < length) {
i++;
var nTrailingChar = value.charCodeAt(i);
nUnicode = decodeSurrogateChar(nCharCode, nTrailingChar);
}
}
else
Item = new ParaText( value[i] );
shape.paragraphAdd(Item);
nUnicode = nCharCode;
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
switch ( item.Type )
{
case para_Text:
sCurText += String.fromCharCode(item.Value);
sCurText += encodeSurrogateChar(item.Value);
break;
case para_Space:
sCurText += " ";
......@@ -7542,12 +7542,30 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
this.oCurComments[i] += text;
}
for (var i = 0; i < text.length; ++i)
{
if (text[i] != ' ')
oPos.run.Add_ToContent(oPos.pos, new ParaText(text[i]), false);
else
oPos.run.Add_ToContent(oPos.pos, new ParaSpace(), false);
oPos.pos++;
{
var nUnicode = null;
var nCharCode = text.charCodeAt(i);
if (isLeadingSurrogateChar(nCharCode))
{
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)
......
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