Skip to content

Commit

Permalink
Merge pull request 'fix/pdf-bugs' (#89) from fix/pdf-bugs into releas…
Browse files Browse the repository at this point in the history
…e/v8.2.0
  • Loading branch information
KirillovIlya committed Sep 27, 2024
2 parents 612fc37 + 77d4857 commit dbe54a1
Show file tree
Hide file tree
Showing 13 changed files with 690 additions and 349 deletions.
2 changes: 1 addition & 1 deletion common/Drawings/TrackObjects/ResizeTracks.js
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ function ResizeTrackShapeImage(originalObject, cardDirection, drawingsController
this.resizedflipV = false;
}

if (Asc.editor.isPdfEditor() && (Asc.editor.getPDFDoc().IsViewerObject(this.originalObject))) {
if (Asc.editor.isPdfEditor() && this.originalObject.IsAnnot()) {
let xMin = this.resizedPosX;
let xMax = this.resizedPosX + this.resizedExtX;
let yMin = this.resizedPosY;
Expand Down
46 changes: 23 additions & 23 deletions common/HistoryCommon.js
Original file line number Diff line number Diff line change
Expand Up @@ -4325,23 +4325,22 @@
AscDFH.historyitem_Pdf_Annot_Pos = AscDFH.historyitem_type_Pdf_Annot | 2;
AscDFH.historyitem_Pdf_Annot_Contents = AscDFH.historyitem_type_Pdf_Annot | 3;
AscDFH.historyitem_Pdf_Annot_Page = AscDFH.historyitem_type_Pdf_Annot | 4;
AscDFH.historyitem_Pdf_Annot_Replies = AscDFH.historyitem_type_Pdf_Annot | 5;
AscDFH.historyitem_Pdf_Annot_RD = AscDFH.historyitem_type_Pdf_Annot | 6;
AscDFH.historyitem_Pdf_Annot_Vertices = AscDFH.historyitem_type_Pdf_Annot | 7;
AscDFH.historyitem_Pdf_Annot_Creation_Date = AscDFH.historyitem_type_Pdf_Annot | 8;
AscDFH.historyitem_Pdf_Annot_Mod_Date = AscDFH.historyitem_type_Pdf_Annot | 9;
AscDFH.historyitem_Pdf_Annot_Author = AscDFH.historyitem_type_Pdf_Annot | 10;
AscDFH.historyitem_Pdf_Annot_Display = AscDFH.historyitem_type_Pdf_Annot | 11;
AscDFH.historyitem_Pdf_Annot_Name = AscDFH.historyitem_type_Pdf_Annot | 12;
AscDFH.historyitem_Pdf_Annot_File_Idx = AscDFH.historyitem_type_Pdf_Annot | 13;
AscDFH.historyitem_Pdf_Annot_Document = AscDFH.historyitem_type_Pdf_Annot | 14;
AscDFH.historyitem_Pdf_Annot_Stroke = AscDFH.historyitem_type_Pdf_Annot | 15;
AscDFH.historyitem_Pdf_Annot_StrokeWidth = AscDFH.historyitem_type_Pdf_Annot | 16;
AscDFH.historyitem_Pdf_Annot_Fill = AscDFH.historyitem_type_Pdf_Annot | 17;
AscDFH.historyitem_Pdf_Annot_Opacity = AscDFH.historyitem_type_Pdf_Annot | 18;
AscDFH.historyitem_Pdf_Annot_Quads = AscDFH.historyitem_type_Pdf_Annot | 19;
AscDFH.historyitem_Pdf_Annot_Intent = AscDFH.historyitem_type_Pdf_Annot | 20;
AscDFH.historyitem_Pdf_Annot_WasChanged = AscDFH.historyitem_type_Pdf_Annot | 21;
AscDFH.historyitem_Pdf_Annot_RD = AscDFH.historyitem_type_Pdf_Annot | 5;
AscDFH.historyitem_Pdf_Annot_Vertices = AscDFH.historyitem_type_Pdf_Annot | 6;
AscDFH.historyitem_Pdf_Annot_Creation_Date = AscDFH.historyitem_type_Pdf_Annot | 7;
AscDFH.historyitem_Pdf_Annot_Mod_Date = AscDFH.historyitem_type_Pdf_Annot | 8;
AscDFH.historyitem_Pdf_Annot_Author = AscDFH.historyitem_type_Pdf_Annot | 9;
AscDFH.historyitem_Pdf_Annot_Display = AscDFH.historyitem_type_Pdf_Annot | 10;
AscDFH.historyitem_Pdf_Annot_Name = AscDFH.historyitem_type_Pdf_Annot | 11;
AscDFH.historyitem_Pdf_Annot_File_Idx = AscDFH.historyitem_type_Pdf_Annot | 12;
AscDFH.historyitem_Pdf_Annot_Document = AscDFH.historyitem_type_Pdf_Annot | 13;
AscDFH.historyitem_Pdf_Annot_Stroke = AscDFH.historyitem_type_Pdf_Annot | 14;
AscDFH.historyitem_Pdf_Annot_StrokeWidth = AscDFH.historyitem_type_Pdf_Annot | 15;
AscDFH.historyitem_Pdf_Annot_Fill = AscDFH.historyitem_type_Pdf_Annot | 16;
AscDFH.historyitem_Pdf_Annot_Opacity = AscDFH.historyitem_type_Pdf_Annot | 17;
AscDFH.historyitem_Pdf_Annot_Quads = AscDFH.historyitem_type_Pdf_Annot | 18;
AscDFH.historyitem_Pdf_Annot_Intent = AscDFH.historyitem_type_Pdf_Annot | 19;
AscDFH.historyitem_Pdf_Annot_WasChanged = AscDFH.historyitem_type_Pdf_Annot | 20;

// Comment
AscDFH.historyitem_Pdf_Comment_Data = AscDFH.historyitem_type_Pdf_Comment | 1;
Expand Down Expand Up @@ -4370,12 +4369,13 @@
//------------------------------------------------------------------------------------------------------------------
// Типы изменений в классе CPDFDoc
//------------------------------------------------------------------------------------------------------------------
window['AscDFH'].historyitem_PDF_Document_AddItem = window['AscDFH'].historyitem_type_PDF_Document | 1;
window['AscDFH'].historyitem_PDF_Document_RemoveItem = window['AscDFH'].historyitem_type_PDF_Document | 2;
window['AscDFH'].historyitem_PDF_Document_AddPage = window['AscDFH'].historyitem_type_PDF_Document | 3;
window['AscDFH'].historyitem_PDF_Document_RemovePage = window['AscDFH'].historyitem_type_PDF_Document | 4;
window['AscDFH'].historyitem_PDF_Document_RotatePage = window['AscDFH'].historyitem_type_PDF_Document | 5;
window['AscDFH'].historyitem_PDF_Document_RecognizePage = window['AscDFH'].historyitem_type_PDF_Document | 6;
window['AscDFH'].historyitem_PDF_Document_AnnotsContent = window['AscDFH'].historyitem_type_PDF_Document | 1;
window['AscDFH'].historyitem_PDF_Document_DrawingsContent = window['AscDFH'].historyitem_type_PDF_Document | 2;
window['AscDFH'].historyitem_PDF_Document_FormsContent = window['AscDFH'].historyitem_type_PDF_Document | 3;
window['AscDFH'].historyitem_PDF_Document_AddPage = window['AscDFH'].historyitem_type_PDF_Document | 4;
window['AscDFH'].historyitem_PDF_Document_RemovePage = window['AscDFH'].historyitem_type_PDF_Document | 5;
window['AscDFH'].historyitem_PDF_Document_RotatePage = window['AscDFH'].historyitem_type_PDF_Document | 6;
window['AscDFH'].historyitem_PDF_Document_RecognizePage = window['AscDFH'].historyitem_type_PDF_Document | 7;


AscDFH.historyitem_CustomPropertiesAddProperty = AscDFH.historyitem_type_CustomProperties | 0;
Expand Down
3 changes: 2 additions & 1 deletion pdf/src/GraphicObjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -975,9 +975,10 @@
if(ret.cursorType !== "text")
{
let oApi = Asc.editor || editor;
let oDoc = this.document;
let isDrawHandles = oApi ? oApi.isShowShapeAdjustments() : true;

let oObject = AscCommon.g_oTableId.Get_ById(ret.objectId);
let oObject = AscCommon.g_oTableId.Get_ById(ret.objectId) || oDoc.GetShapeBasedAnnotById(ret.objectId);
let isViewerObj = this.document.IsViewerObject(oObject);

if (!isDrawHandles && isViewerObj) {
Expand Down
41 changes: 30 additions & 11 deletions pdf/src/annotations/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -708,15 +708,6 @@
// oGraphicsPDF.Rect(X, Y, nWidth, nHeight);
// oGraphicsPDF.Stroke();
};
CAnnotationBase.prototype.SetReplies = function(aReplies) {
let oDoc = this.GetDocument();
let oViewer = editor.getDocumentRenderer();

if (oDoc.History.UndoRedoInProgress == false && oViewer.IsOpenAnnotsInProgress == false) {
oDoc.History.Add(new CChangesPDFAnnotReplies(this, this._replies, aReplies));
}
this._replies = aReplies;
};
CAnnotationBase.prototype.GetReplies = function() {
return this._replies;
};
Expand All @@ -725,9 +716,23 @@
};
CAnnotationBase.prototype.RemoveComment = function() {
this.SetContents(null);
this.SetReplies([]);
this.EditCommentData(undefined);
};
CAnnotationBase.prototype.EditCommentData = function(oCommentData) {
let oDoc = this.GetDocument();

let oCurAscCommData = this.GetAscCommentData();
let oCurData = oCurAscCommData ? new AscCommon.CCommentData() : undefined;
oCurData && oCurData.Read_FromAscCommentData(oCurAscCommData);

AscCommon.History.Add(new CChangesPDFCommentData(this, oCurData, oCommentData));

if (oCommentData == null) {
this._replies.length = 0;
Asc.editor.sync_RemoveComment(this.GetId());
return;
}

let oFirstCommToEdit;
if (this.GetApIdx() == oCommentData.m_sUserData)
oFirstCommToEdit = this;
Expand All @@ -737,6 +742,13 @@
});
}

AscCommon.History.StartNoHistoryMode();
if (null == oFirstCommToEdit) {
AscPDF.CAnnotationText.prototype.AddReply.call(this, oCommentData);
oFirstCommToEdit = this.GetReply(0);
oDoc.CheckComment(this);
}

if (oFirstCommToEdit.GetContents() != oCommentData.m_sText) {
oFirstCommToEdit.SetContents(oCommentData.m_sText);
oFirstCommToEdit.SetModDate(oCommentData.m_sOOTime);
Expand Down Expand Up @@ -770,9 +782,10 @@
if (!this._replies.find(function(reply) {
return oReplyCommentData.m_sUserData == reply.GetApIdx();
})) {
AscPDF.CAnnotationText.prototype.AddReply.call(this, oReplyCommentData);
AscPDF.CAnnotationText.prototype.AddReply.call(this, oReplyCommentData, i);
}
}
AscCommon.History.EndNoHistoryMode();

if (this.IsComment()) {
if (oCommentData.m_bSolved) {
Expand All @@ -791,9 +804,15 @@
this._replies[i].SetState(AscPDF.TEXT_ANNOT_STATE.Unknown);
}
}

Asc.editor.sync_ChangeCommentData(this.GetId(), oCommentData);
};
CAnnotationBase.prototype.GetAscCommentData = function() {
let oAscCommData = new Asc.asc_CCommentDataWord(null);
if (null == this.GetContents()) {
return undefined;
}

oAscCommData.asc_putText(this.GetContents());
let sModDate = this.GetModDate();
if (sModDate)
Expand Down
29 changes: 6 additions & 23 deletions pdf/src/annotations/freeText.js
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@
this.recalcInfo.recalculateGeometry = true;
};
CAnnotationFreeText.prototype.RemoveComment = function() {
this.SetReplies([]);
this.EditCommentData(undefined);
};
CAnnotationFreeText.prototype.SetContents = function(contents) {
if (this.GetContents() == contents)
Expand Down Expand Up @@ -638,7 +638,8 @@
return true;
}

for (let key of curKeys) {
for (let i = 0; i < curKeys.length; i++) {
let key = curKeys[i];
if (curRC[key] !== calcedRC[key]) {
return true;
}
Expand Down Expand Up @@ -747,7 +748,8 @@
return false;
}

for (let key of keys1) {
for (let i = 0; i < keys1.length; i++) {
let key = keys1[i];
if (obj1[key] !== obj2[key]) {
return false;
}
Expand Down Expand Up @@ -802,25 +804,6 @@

return aRCInfo;
};
CAnnotationFreeText.prototype.SetReplies = function(aReplies) {
let oDoc = this.GetDocument();
let oViewer = editor.getDocumentRenderer();

if (oDoc.History.UndoRedoInProgress == false && oViewer.IsOpenAnnotsInProgress == false) {
oDoc.History.Add(new CChangesPDFAnnotReplies(this, this._replies, aReplies));
}
this._replies = aReplies;

let oThis = this;
aReplies.forEach(function(reply) {
reply.SetReplyTo(oThis);
});

if (aReplies.length != 0)
oDoc.CheckComment(this);
else
editor.sync_RemoveComment(this.GetId());
};
CAnnotationFreeText.prototype.GetAllFonts = function(fontMap) {
let aRCInfo = this.GetRichContents();
fontMap = fontMap || {};
Expand Down Expand Up @@ -870,7 +853,7 @@
CAnnotationFreeText.prototype.GetAscCommentData = function() {
let oAscCommData = new Asc.asc_CCommentDataWord(null);
if (this._replies.length == 0)
return oAscCommData;
return undefined;

let oMainComm = this._replies[0];
oAscCommData.asc_putText(oMainComm.GetContents());
Expand Down
8 changes: 0 additions & 8 deletions pdf/src/annotations/line.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,14 +455,6 @@
AscPDF.CAnnotationBase.prototype.SetContents.call(this, contents);
}
};
CAnnotationLine.prototype.SetReplies = function(aReplies) {
if (!this.IsUseContentAsComment()) {
AscPDF.CAnnotationFreeText.prototype.SetReplies.call(this, aReplies);
}
else {
AscPDF.CAnnotationBase.prototype.SetReplies.call(this, aReplies);
}
};
CAnnotationLine.prototype.GetAscCommentData = function() {
if (!this.IsUseContentAsComment()) {
return AscPDF.CAnnotationFreeText.prototype.GetAscCommentData.call(this);
Expand Down
22 changes: 18 additions & 4 deletions pdf/src/annotations/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@
CAnnotationText.prototype.ClearReplies = function() {
this._replies = [];
};
CAnnotationText.prototype.AddReply = function(CommentData) {
CAnnotationText.prototype.AddReply = function(CommentData, nPos) {
let oReply = new CAnnotationText(AscCommon.CreateGUID(), this.GetPage(), this.GetOrigRect().slice(), this.GetDocument());
let sUserData = CommentData.GetUserData();

oReply.SetContents(CommentData.m_sText);
oReply.SetCreationDate(CommentData.m_sOOTime);
Expand All @@ -118,13 +119,26 @@
oReply.SetDisplay(window["AscPDF"].Api.Objects.display["visible"]);
oReply.SetReplyTo(this.GetReplyTo() || this);

oReply.SetApIdx(this.GetDocument().GetMaxApIdx() + 2);
CommentData.m_sUserData = oReply.GetApIdx();
if (sUserData) {
oReply.SetApIdx(sUserData);
}
else {
oReply.SetApIdx(this.GetDocument().GetMaxApIdx() + 2);
CommentData.SetUserData(oReply.GetApIdx());
}

if (!nPos) {
nPos = this._replies.length;
}

this._replies.push(oReply);
this._replies.splice(nPos, 0, oReply);
};
CAnnotationText.prototype.GetAscCommentData = function() {
let oAscCommData = new Asc.asc_CCommentDataWord(null);
if (null == this.GetContents()) {
return undefined;
}

oAscCommData.asc_putText(this.GetContents());
let sModDate = this.GetModDate();
if (sModDate)
Expand Down
Loading

0 comments on commit dbe54a1

Please sign in to comment.