Commit 6716b957 authored by Sergey.Konovalov's avatar Sergey.Konovalov

двигались кооментарии при вставке и открытии из-за удаления элементов в Paragraph.Correct_Content

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@60416 954022d7-b5bf-4e40-9824-e11837661b57
parent a5c8bd73
...@@ -5146,63 +5146,41 @@ function BinaryFileReader(doc, openParams) ...@@ -5146,63 +5146,41 @@ function BinaryFileReader(doc, openParams)
for(var i in this.oReadResult.oCommentsPlaces) for(var i in this.oReadResult.oCommentsPlaces)
{ {
var item = this.oReadResult.oCommentsPlaces[i]; var item = this.oReadResult.oCommentsPlaces[i];
if((null != item.Start && null != item.End) || (null != item.Ref && null == item.Start && null == item.End)) var bToDelete = true;
{ if(null != item.Start && null != item.End){
var oStart = null; var oCommentObj = oCommentsNewId[item.Start.Id];
var oEnd = null;
var bRef = false;
if(null != item.Start && null != item.End)
{
oStart = item.Start;
oEnd = item.End;
}
else if(null != item.Ref)
{
bRef = true;
oStart = oEnd = item.Ref;
}
if(null != oStart || null != oEnd)
{
var nId = oStart.Id;
var oCommentObj = oCommentsNewId[nId];
if(oCommentObj) if(oCommentObj)
{ {
bToDelete = false;
if(null != item.QuoteText) if(null != item.QuoteText)
oCommentObj.Data.m_sQuoteText = item.QuoteText; oCommentObj.Data.m_sQuoteText = item.QuoteText;
var fInsert = function(bStart, bRef, oCommentPosition) item.Start.oParaComment.Set_CommentId(oCommentObj.Get_Id());
{ item.End.oParaComment.Set_CommentId(oCommentObj.Get_Id());
var index = 0;
var oParent = oCommentPosition.oParent;
if(null != oParent)
{
if(bRef)
{
if(bStart)
index = 0;
else
index = OpenParStruct.prototype._GetContentLength(oParent) - 1;
} }
else if(oCommentPosition.oAfter) }
{ if(bToDelete){
for (var j = 0, length2 = OpenParStruct.prototype._GetContentLength(oParent) ; j < length2; ++j) if(null != item.Start && null != item.Start.oParent)
{ {
if (OpenParStruct.prototype._GetFromContent(oParent, j) == oCommentPosition.oAfter) var oParent = item.Start.oParent;
var oParaComment = item.Start.oParaComment;
for (var i = OpenParStruct.prototype._GetContentLength(oParent) - 1; i >= 0; --i)
{ {
index = j + 1; if (oParaComment == OpenParStruct.prototype._GetFromContent(oParent, i)){
OpenParStruct.prototype._removeFromContent(oParent, i, 1);
break; break;
} }
} }
} }
var oParaCommentElem; if(null != item.End && null != item.End.oParent)
if(bStart) {
oParaCommentElem = new ParaComment(true, oCommentObj.Get_Id()); var oParent = item.End.oParent;
else var oParaComment = item.End.oParaComment;
oParaCommentElem = new ParaComment(false, oCommentObj.Get_Id()); for (var i = OpenParStruct.prototype._GetContentLength(oParent) - 1; i >= 0; --i)
OpenParStruct.prototype._addToContent(oParent, index, oParaCommentElem); {
} if (oParaComment == OpenParStruct.prototype._GetFromContent(oParent, i)){
OpenParStruct.prototype._removeFromContent(oParent, i, 1);
break;
} }
fInsert(false, bRef, oEnd);
fInsert(true, bRef, oStart);
} }
} }
} }
...@@ -5405,64 +5383,41 @@ function BinaryFileReader(doc, openParams) ...@@ -5405,64 +5383,41 @@ function BinaryFileReader(doc, openParams)
for(var i in this.oReadResult.oCommentsPlaces) for(var i in this.oReadResult.oCommentsPlaces)
{ {
var item = this.oReadResult.oCommentsPlaces[i]; var item = this.oReadResult.oCommentsPlaces[i];
if((null != item.Start && null != item.End) || (null != item.Ref && null == item.Start && null == item.End)) var bToDelete = true;
{ if(null != item.Start && null != item.End){
var oStart = null; var oCommentObj = oCommentsNewId[item.Start.Id];
var oEnd = null;
var bRef = false;
if(null != item.Start && null != item.End)
{
oStart = item.Start;
oEnd = item.End;
}
else if(null != item.Ref)
{
bRef = true;
oStart = oEnd = item.Ref;
}
if(null != oStart || null != oEnd)
{
var nId = oStart.Id;
var oCommentObj = oCommentsNewId[nId];
if(oCommentObj) if(oCommentObj)
{ {
bToDelete = false;
if(null != item.QuoteText) if(null != item.QuoteText)
oCommentObj.Data.m_sQuoteText = item.QuoteText; oCommentObj.Data.m_sQuoteText = item.QuoteText;
var fInsert = function(bStart, bRef, oCommentPosition) item.Start.oParaComment.Set_CommentId(oCommentObj.Get_Id());
{ item.End.oParaComment.Set_CommentId(oCommentObj.Get_Id());
var index = 0;
var oParent = oCommentPosition.oParent;
if(null != oParent)
{
if(bRef)
{
if(bStart)
index = 0;
else
index = OpenParStruct.prototype._GetContentLength(oParent) - 1;
} }
else if(oCommentPosition.oAfter) }
{ if(bToDelete){
for (var j = 0, length2 = OpenParStruct.prototype._GetContentLength(oParent) ; j < length2; ++j) if(null != item.Start && null != item.Start.oParent)
{ {
if (OpenParStruct.prototype._GetFromContent(oParent, j) == oCommentPosition.oAfter) var oParent = item.Start.oParent;
var oParaComment = item.Start.oParaComment;
for (var i = OpenParStruct.prototype._GetContentLength(oParent) - 1; i >= 0; --i)
{ {
index = j + 1; if (oParaComment == OpenParStruct.prototype._GetFromContent(oParent, i)){
OpenParStruct.prototype._removeFromContent(oParent, i, 1);
break; break;
} }
} }
} }
var oParaCommentElem; if(null != item.End && null != item.End.oParent)
if(bStart) {
oParaCommentElem = new ParaComment(true, oCommentObj.Get_Id()); var oParent = item.End.oParent;
else var oParaComment = item.End.oParaComment;
oParaCommentElem = new ParaComment(false, oCommentObj.Get_Id()); for (var i = OpenParStruct.prototype._GetContentLength(oParent) - 1; i >= 0; --i)
OpenParStruct.prototype._addToContent(oParent, index, oParaCommentElem); {
} if (oParaComment == OpenParStruct.prototype._GetFromContent(oParent, i)){
OpenParStruct.prototype._removeFromContent(oParent, i, 1);
break;
} }
fInsert(false, bRef, oEnd);
fInsert(true, bRef, oStart);
} }
} }
} }
...@@ -7466,9 +7421,6 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow ...@@ -7466,9 +7421,6 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
res = this.bcr.Read1(length, function(t, l){ res = this.bcr.Read1(length, function(t, l){
return oThis.ReadComment(t,l, oCommon); return oThis.ReadComment(t,l, oCommon);
}); });
if (oParStruct.GetContentLength() > 0)
oCommon.oAfter = oParStruct.GetFromContent(oParStruct.cur.pos - 1);
if(null != oCommon.Id) if(null != oCommon.Id)
{ {
oCommon.oParent = oCurContainer; oCommon.oParent = oCurContainer;
...@@ -7482,6 +7434,8 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow ...@@ -7482,6 +7434,8 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
this.nCurCommentsCount++; this.nCurCommentsCount++;
this.oCurComments[oCommon.Id] = ""; this.oCurComments[oCommon.Id] = "";
} }
oCommon.oParaComment = new ParaComment(true, oCommon.Id);
oParStruct.addToContent(oCommon.oParaComment);
} }
} }
else if (c_oSerParType.CommentEnd === type) else if (c_oSerParType.CommentEnd === type)
...@@ -7490,8 +7444,6 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow ...@@ -7490,8 +7444,6 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
res = this.bcr.Read1(length, function(t, l){ res = this.bcr.Read1(length, function(t, l){
return oThis.ReadComment(t,l, oCommon); return oThis.ReadComment(t,l, oCommon);
}); });
if (oParStruct.GetContentLength() > 0)
oCommon.oAfter = oParStruct.GetFromContent(oParStruct.cur.pos - 1);
if(null != oCommon.Id) if(null != oCommon.Id)
{ {
oCommon.oParent = oCurContainer; oCommon.oParent = oCurContainer;
...@@ -7509,6 +7461,8 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow ...@@ -7509,6 +7461,8 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
this.nCurCommentsCount--; this.nCurCommentsCount--;
delete this.oCurComments[oCommon.Id]; delete this.oCurComments[oCommon.Id];
} }
oCommon.oParaComment = new ParaComment(false, oCommon.Id);
oParStruct.addToContent(oCommon.oParaComment);
} }
} }
else if ( c_oSerParType.OMathPara == type ) else if ( c_oSerParType.OMathPara == type )
...@@ -7758,24 +7712,6 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow ...@@ -7758,24 +7712,6 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
oParStruct.commitElem(); oParStruct.commitElem();
this.aFields.pop(); this.aFields.pop();
} }
else if (c_oSerRunType.CommentReference === type)
{
var oCommon = {};
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadComment(t,l, oCommon);
});
if (oParStruct.GetContentLength() > 0)
oCommon.oAfter = oParStruct.GetFromContent(oParStruct.cur.pos - 1);
if(null != oCommon.Id)
{
oCommon.oParent = oParStruct.cur.elem;
var item = this.oComments[oCommon.Id];
if(item)
item.Ref = oCommon;
else
this.oComments[oCommon.Id] = {Ref: oCommon};
}
}
else if (c_oSerRunType._LastRun === type) else if (c_oSerRunType._LastRun === type)
this.oReadResult.bLastRun = true; this.oReadResult.bLastRun = true;
else if (c_oSerRunType.object === type) else if (c_oSerRunType.object === type)
...@@ -11649,6 +11585,10 @@ OpenParStruct.prototype = { ...@@ -11649,6 +11585,10 @@ OpenParStruct.prototype = {
}, },
_GetContentLength: function (elem) { _GetContentLength: function (elem) {
return elem.Content.length; return elem.Content.length;
},
_removeFromContent: function (elem, pos, count) {
if (elem.Remove_FromContent)
elem.Remove_FromContent(pos, count);
}, },
addToContent: function (oItem) { addToContent: function (oItem) {
this.cur.pos = this._addToContent(this.cur.elem, this.cur.pos, oItem); this.cur.pos = this._addToContent(this.cur.elem, this.cur.pos, oItem);
......
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