Commit 208dba78 authored by Ilya Kirillov's avatar Ilya Kirillov

Implemented receiving a report about all comments in the document.

parent 2bc86d04
......@@ -210,6 +210,26 @@ function CCommentData()
}
};
}
CCommentData.prototype.GetUserName = function()
{
return this.m_sUserName;
};
CCommentData.prototype.GetDateTime = function()
{
var nTime = parseInt(this.m_sTime);
if (isNaN(nTime))
nTime = 0;
return nTime;
};
CCommentData.prototype.GetRepliesCount = function()
{
return this.Get_RepliesCount();
};
CCommentData.prototype.GetReply = function(nIndex)
{
return this.Get_Reply(nIndex);
};
function CCommentDrawingRect(X, Y, W, H, CommentId, InvertTransform)
{
......@@ -410,6 +430,10 @@ function CComment(Parent, Data)
// Добавляем данный класс в таблицу Id (обязательно в конце конструктора)
g_oTableId.Add( this, this.Id );
}
CComment.prototype.GetData = function()
{
return this.Data;
};
var comments_NoComment = 0;
var comments_NonActiveComment = 1;
......@@ -561,6 +585,10 @@ function CComments()
// Добавляем данный класс в таблицу Id (обязательно в конце конструктора)
g_oTableId.Add( this, this.Id );
}
CComments.prototype.GetAllComments = function()
{
return this.m_aComments;
};
//----------------------------------------------------------------------------------------------------------------------
// Класс для работы внутри параграфа
......
......@@ -140,20 +140,21 @@ Asc['asc_docs_api'].prototype.asc_GetTrackRevisionsReportByAuthors = function()
return oResult;
};
Asc['asc_docs_api'].prototype['asc_SetTrackRevisions'] = Asc['asc_docs_api'].prototype.asc_SetTrackRevisions;
Asc['asc_docs_api'].prototype['asc_IsTrackRevisions'] = Asc['asc_docs_api'].prototype.asc_IsTrackRevisions;
Asc['asc_docs_api'].prototype['sync_BeginCatchRevisionsChanges'] = Asc['asc_docs_api'].prototype.sync_BeginCatchRevisionsChanges;
Asc['asc_docs_api'].prototype['sync_EndCatchRevisionsChanges'] = Asc['asc_docs_api'].prototype.sync_EndCatchRevisionsChanges;
Asc['asc_docs_api'].prototype['sync_AddRevisionsChange'] = Asc['asc_docs_api'].prototype.sync_AddRevisionsChange;
Asc['asc_docs_api'].prototype['asc_AcceptChanges'] = Asc['asc_docs_api'].prototype.asc_AcceptChanges;
Asc['asc_docs_api'].prototype['asc_RejectChanges'] = Asc['asc_docs_api'].prototype.asc_RejectChanges;
Asc['asc_docs_api'].prototype['asc_HaveRevisionsChanges'] = Asc['asc_docs_api'].prototype.asc_HaveRevisionsChanges;
Asc['asc_docs_api'].prototype['asc_HaveNewRevisionsChanges'] = Asc['asc_docs_api'].prototype.asc_HaveNewRevisionsChanges;
Asc['asc_docs_api'].prototype['asc_GetNextRevisionsChange'] = Asc['asc_docs_api'].prototype.asc_GetNextRevisionsChange;
Asc['asc_docs_api'].prototype['asc_GetPrevRevisionsChange'] = Asc['asc_docs_api'].prototype.asc_GetPrevRevisionsChange;
Asc['asc_docs_api'].prototype['sync_UpdateRevisionsChangesPosition'] = Asc['asc_docs_api'].prototype.sync_UpdateRevisionsChangesPosition;
Asc['asc_docs_api'].prototype['asc_AcceptAllChanges'] = Asc['asc_docs_api'].prototype.asc_AcceptAllChanges;
Asc['asc_docs_api'].prototype['asc_RejectAllChanges'] = Asc['asc_docs_api'].prototype.asc_RejectAllChanges;
Asc['asc_docs_api'].prototype['asc_SetTrackRevisions'] = Asc['asc_docs_api'].prototype.asc_SetTrackRevisions;
Asc['asc_docs_api'].prototype['asc_IsTrackRevisions'] = Asc['asc_docs_api'].prototype.asc_IsTrackRevisions;
Asc['asc_docs_api'].prototype['sync_BeginCatchRevisionsChanges'] = Asc['asc_docs_api'].prototype.sync_BeginCatchRevisionsChanges;
Asc['asc_docs_api'].prototype['sync_EndCatchRevisionsChanges'] = Asc['asc_docs_api'].prototype.sync_EndCatchRevisionsChanges;
Asc['asc_docs_api'].prototype['sync_AddRevisionsChange'] = Asc['asc_docs_api'].prototype.sync_AddRevisionsChange;
Asc['asc_docs_api'].prototype['asc_AcceptChanges'] = Asc['asc_docs_api'].prototype.asc_AcceptChanges;
Asc['asc_docs_api'].prototype['asc_RejectChanges'] = Asc['asc_docs_api'].prototype.asc_RejectChanges;
Asc['asc_docs_api'].prototype['asc_HaveRevisionsChanges'] = Asc['asc_docs_api'].prototype.asc_HaveRevisionsChanges;
Asc['asc_docs_api'].prototype['asc_HaveNewRevisionsChanges'] = Asc['asc_docs_api'].prototype.asc_HaveNewRevisionsChanges;
Asc['asc_docs_api'].prototype['asc_GetNextRevisionsChange'] = Asc['asc_docs_api'].prototype.asc_GetNextRevisionsChange;
Asc['asc_docs_api'].prototype['asc_GetPrevRevisionsChange'] = Asc['asc_docs_api'].prototype.asc_GetPrevRevisionsChange;
Asc['asc_docs_api'].prototype['sync_UpdateRevisionsChangesPosition'] = Asc['asc_docs_api'].prototype.sync_UpdateRevisionsChangesPosition;
Asc['asc_docs_api'].prototype['asc_AcceptAllChanges'] = Asc['asc_docs_api'].prototype.asc_AcceptAllChanges;
Asc['asc_docs_api'].prototype['asc_RejectAllChanges'] = Asc['asc_docs_api'].prototype.asc_RejectAllChanges;
Asc['asc_docs_api'].prototype['asc_GetTrackRevisionsReportByAuthors'] = Asc['asc_docs_api'].prototype.asc_GetTrackRevisionsReportByAuthors;
//----------------------------------------------------------------------------------------------------------------------
// CDocument
//----------------------------------------------------------------------------------------------------------------------
......
......@@ -32,27 +32,79 @@
"use strict";
Asc['asc_docs_api'].prototype.asc_addComment = function(AscCommentData) {
if (true === AscCommon.CollaborativeEditing.Get_GlobalLock()) {
return;
}
if (null == this.WordControl.m_oLogicDocument) {
return;
}
// Комментарий без цитаты позволяем добавить всегда
if (true !== this.can_AddQuotedComment() || false === this.WordControl.m_oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_Paragraph_Content)) {
var CommentData = new CCommentData();
CommentData.Read_FromAscCommentData(AscCommentData);
this.WordControl.m_oLogicDocument.Create_NewHistoryPoint(AscDFH.historydescription_Document_AddComment);
var Comment = this.WordControl.m_oLogicDocument.Add_Comment(CommentData);
if (null != Comment) {
this.sync_AddComment(Comment.Get_Id(), CommentData);
}
return Comment.Get_Id();
}
Asc['asc_docs_api'].prototype.asc_addComment = function(AscCommentData)
{
if (true === AscCommon.CollaborativeEditing.Get_GlobalLock())
{
return;
}
if (null == this.WordControl.m_oLogicDocument)
{
return;
}
// Комментарий без цитаты позволяем добавить всегда
if (true !== this.can_AddQuotedComment() || false === this.WordControl.m_oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_Paragraph_Content))
{
var CommentData = new CCommentData();
CommentData.Read_FromAscCommentData(AscCommentData);
this.WordControl.m_oLogicDocument.Create_NewHistoryPoint(AscDFH.historydescription_Document_AddComment);
var Comment = this.WordControl.m_oLogicDocument.Add_Comment(CommentData);
if (null != Comment)
{
this.sync_AddComment(Comment.Get_Id(), CommentData);
}
return Comment.Get_Id();
}
};
Asc['asc_docs_api'].prototype.asc_GetCommentsReportByAuthors = function()
{
var oReport = {};
function privateProcessCommentData(isTopComment, oCommentData)
{
var sUserName = oCommentData.GetUserName();
var nDateTime = oCommentData.GetDateTime();
if (!oReport[sUserName])
oReport[sUserName] = [];
var arrUserComments = oReport[sUserName];
var nPos = 0;
var nLen = arrUserComments.length;
while (nPos < nLen)
{
if (nDateTime < arrUserComments[nPos].Data.GetDateTime())
break;
nPos++;
}
arrUserComments.splice(nPos, 0, {Top : isTopComment, Data : oCommentData});
for (var nIndex = 0, nCount = oCommentData.GetRepliesCount(); nIndex < nCount; ++nIndex)
{
privateProcessCommentData(false, oCommentData.GetReply(nIndex))
}
}
var oLogicDocument = this.WordControl.m_oLogicDocument;
if (!oLogicDocument)
return oReport;
var oAllComments = oLogicDocument.Comments.GetAllComments();
for (var sId in oAllComments)
{
var oComment = oAllComments[sId];
privateProcessCommentData(true, oComment.GetData());
}
return oReport;
};
Asc['asc_docs_api'].prototype['asc_addComment'] = Asc['asc_docs_api'].prototype.asc_addComment;
\ No newline at end of file
Asc['asc_docs_api'].prototype['asc_addComment'] = Asc['asc_docs_api'].prototype.asc_addComment;
Asc['asc_docs_api'].prototype['asc_GetCommentsReportByAuthors'] = Asc['asc_docs_api'].prototype.asc_GetCommentsReportByAuthors;
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