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;
......@@ -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 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
nUnicode = nCharCode;
if (null != nUnicode) {
var Item;
if(32 == Code || 160 == Code) //160 - nbsp
Item = new ParaSpace();
if (0x20 != nUnicode && 0xA0 != nUnicode) {
Item = new ParaText();
Item.Value = nUnicode;
}
else
Item = new ParaText( value[i] );
this._Paragraph_Add( Item );
Item = new ParaSpace();
this._Paragraph_Add(Item);
}
}
}
}
......@@ -5968,15 +5981,28 @@ PasteProcessor.prototype =
}
for(var i = 0, length = value.length; i < length; i++)
{
var Char = value.charAt(i);
var Code = value.charCodeAt(i);
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
nUnicode = nCharCode;
if (null != nUnicode) {
var Item;
if(32 == Code || 160 == Code) //160 - nbsp
Item = new ParaSpace();
if (0x20 != nUnicode && 0xA0 != nUnicode) {
Item = new ParaText();
Item.Value = nUnicode;
}
else
Item = new ParaText( value[i] );
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 += " ";
......@@ -7543,13 +7543,31 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
}
for (var i = 0; i < text.length; ++i)
{
if (text[i] != ' ')
oPos.run.Add_ToContent(oPos.pos, new ParaText(text[i]), false);
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)
{
oNewElem = new ParaTab();
......
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