Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KhromovNikita committed Feb 6, 2025
1 parent 87f5ee6 commit e96f51d
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 13 deletions.
15 changes: 14 additions & 1 deletion pdf/src/annotations/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,21 @@
return null;

oApInfoTmp = oApearanceInfo["N"];
oSavedView = this._originView.normal;

// for stamp save info in stamp
if (this.GetCopyOfApIdx() != -1 && !this.IsStamp()) {
let _t = this;
let oDoc = this.GetDocument();
let oCopyOf = oDoc.annots.find(function(annot) {
return annot.GetApIdx() == _t.GetCopyOfApIdx();
});

if (oCopyOf) {
this._originView.normal = oCopyOf._originView.normal;
}
}

oSavedView = this._originView.normal;
if (oSavedView) {
if (oSavedView.width == oApearanceInfo["w"] && oSavedView.height == oApearanceInfo["h"]) {
return oSavedView;
Expand Down
6 changes: 4 additions & 2 deletions pdf/src/annotations/circle.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
let aFillColor = this.GetFillColor();
let aRD = this.GetRectangleDiff();

oCircle._copyApIdx = this._copyApIdx;
oCircle._apIdx = this._apIdx;
oCircle._originView = this._originView;
oCircle.SetOriginPage(this.GetOriginPage());
Expand Down Expand Up @@ -123,10 +124,11 @@

this.FillCommentsDataTo(oCircle);

if (this.IsNeedDrawFromStream()) {
if ((this.IsUseInDocument() && this.IsNeedDrawFromStream()) || !this.IsChanged() || this.GetCopyOfApIdx() != -1) {
oCircle.SetCopyOfApIdx(this.GetCopyOfApIdx() != -1 ? this.GetCopyOfApIdx() : this.GetApIdx());
oCircle.SetDrawFromStream(true);
}

return oCircle;
};
CAnnotationCircle.prototype.RefillGeometry = function(oGeometry, aShapeRectInMM) {
Expand Down
6 changes: 6 additions & 0 deletions pdf/src/annotations/freeText.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@
let aCallout = this.GetCallout();
let aRD = this.GetRectangleDiff();

oFreeText._copyApIdx = this._copyApIdx;
oFreeText._apIdx = this._apIdx;
oFreeText._originView = this._originView;
oFreeText.SetOriginPage(this.GetOriginPage());
Expand Down Expand Up @@ -541,6 +542,11 @@

this.FillCommentsDataTo(oFreeText);

if ((this.IsUseInDocument() && this.IsNeedDrawFromStream()) || !this.IsChanged() || this.GetCopyOfApIdx() != -1) {
oFreeText.SetCopyOfApIdx(this.GetCopyOfApIdx() != -1 ? this.GetCopyOfApIdx() : this.GetApIdx());
oFreeText.SetDrawFromStream(true);
}

return oFreeText;
};
CAnnotationFreeText.prototype.Recalculate = function() {
Expand Down
6 changes: 6 additions & 0 deletions pdf/src/annotations/ink.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@

let aStrokeColor = this.GetStrokeColor();

oNewInk._copyApIdx = this._copyApIdx;
oNewInk._apIdx = this._apIdx;
oNewInk._originView = this._originView;
oNewInk.SetOriginPage(this.GetOriginPage());
Expand Down Expand Up @@ -391,6 +392,11 @@

this.FillCommentsDataTo(oNewInk);

if ((this.IsUseInDocument() && this.IsNeedDrawFromStream()) || !this.IsChanged() || this.GetCopyOfApIdx() != -1) {
oNewInk.SetCopyOfApIdx(this.GetCopyOfApIdx() != -1 ? this.GetCopyOfApIdx() : this.GetApIdx());
oNewInk.SetDrawFromStream(true);
}

return oNewInk;
};
CAnnotationInk.prototype.GetRelativePaths = function() {
Expand Down
7 changes: 7 additions & 0 deletions pdf/src/annotations/line.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
let aFillColor = this.GetFillColor();
let aLinePoints = this.GetLinePoints();

oLine._copyApIdx = this._copyApIdx;
oLine._apIdx = this._apIdx;
oLine._originView = this._originView;
oLine.SetOriginPage(this.GetOriginPage());
Expand Down Expand Up @@ -253,6 +254,12 @@
oLine.recalculate();

this.FillCommentsDataTo(oLine);

if ((this.IsUseInDocument() && this.IsNeedDrawFromStream()) || !this.IsChanged() || this.GetCopyOfApIdx() != -1) {
oLine.SetCopyOfApIdx(this.GetCopyOfApIdx() != -1 ? this.GetCopyOfApIdx() : this.GetApIdx());
oLine.SetDrawFromStream(true);
}

return oLine;
};
CAnnotationLine.prototype.IsLine = function() {
Expand Down
8 changes: 7 additions & 1 deletion pdf/src/annotations/polyLine.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
let aFillColor = this.GetFillColor();
let aVertices = this.GetVertices();

oPolyline._copyApIdx = this._copyApIdx;
oPolyline._apIdx = this._apIdx;
oPolyline._originView = this._originView;
oPolyline.SetOriginPage(this.GetOriginPage());
Expand Down Expand Up @@ -181,7 +182,6 @@
let aFillColor = this.GetFillColor();
let aVertices = this.GetVertices();

oPolyline.SetCopyOfApIdx(this.GetCopyOfApIdx() != -1 ? this.GetCopyOfApIdx() : this.GetApIdx());
oPolyline.SetOriginPage(this.GetOriginPage());
oPolyline.SetAuthor(AscCommon.UserInfoParser.getCurrentName());
oPolyline.SetModDate(sDate);
Expand All @@ -198,6 +198,12 @@
oPolyline.recalcInfo.recalculateGeometry = true;

this.FillCommentsDataTo(oPolyline);

if ((this.IsUseInDocument() && this.IsNeedDrawFromStream()) || !this.IsChanged() || this.GetCopyOfApIdx() != -1) {
oPolyline.SetCopyOfApIdx(this.GetCopyOfApIdx() != -1 ? this.GetCopyOfApIdx() : this.GetApIdx());
oPolyline.SetDrawFromStream(true);
}

return oPolyline;
};
CAnnotationPolyLine.prototype.onMouseDown = function(x, y, e) {
Expand Down
7 changes: 7 additions & 0 deletions pdf/src/annotations/polygon.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
let aFillColor = this.GetFillColor();
let aVertices = this.GetVertices();

oPolygon._copyApIdx = this._copyApIdx;
oPolygon._apIdx = this._apIdx;
oPolygon._originView = this._originView;
oPolygon.SetOriginPage(this.GetOriginPage());
Expand Down Expand Up @@ -207,6 +208,12 @@
oPolygon.recalculate();

this.FillCommentsDataTo(oPolygon);

if ((this.IsUseInDocument() && this.IsNeedDrawFromStream()) || !this.IsChanged() || this.GetCopyOfApIdx() != -1) {
oPolygon.SetCopyOfApIdx(this.GetCopyOfApIdx() != -1 ? this.GetCopyOfApIdx() : this.GetApIdx());
oPolygon.SetDrawFromStream(true);
}

return oPolygon;
};
CAnnotationPolygon.prototype.onMouseDown = function(x, y, e) {
Expand Down
6 changes: 6 additions & 0 deletions pdf/src/annotations/square.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
let aFillColor = this.GetFillColor();
let aRD = this.GetRectangleDiff();

oSquare._copyApIdx = this._copyApIdx;
oSquare._apIdx = this._apIdx;
oSquare._originView = this._originView;
oSquare.SetOriginPage(this.GetOriginPage());
Expand Down Expand Up @@ -116,6 +117,11 @@
oSquare.Recalculate(true);

this.FillCommentsDataTo(oSquare);

if ((this.IsUseInDocument() && this.IsNeedDrawFromStream()) || !this.IsChanged() || this.GetCopyOfApIdx() != -1) {
oSquare.SetCopyOfApIdx(this.GetCopyOfApIdx() != -1 ? this.GetCopyOfApIdx() : this.GetApIdx());
oSquare.SetDrawFromStream(true);
}
return oSquare;
};
CAnnotationSquare.prototype.RefillGeometry = function(oGeometry, aShapeRectInMM) {
Expand Down
29 changes: 20 additions & 9 deletions pdf/src/annotations/stamp.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,11 @@
let oViewer = editor.getDocumentRenderer();
let oFile = oViewer.file;
let nPage = this.GetOriginPage();
let nApIdx = this.GetCopyOfApIdx() != -1 ? this.GetCopyOfApIdx() : this.GetApIdx();

if (this.APInfo == null || this.APInfo.size.w != nPageW || this.APInfo.size.h != nPageH) {
this.APInfo = {
info: oFile.nativeFile["getAnnotationsAP"](nPage, nPageW, nPageH, undefined, this.GetApIdx()),
info: oFile.nativeFile["getAnnotationsAP"](nPage, nPageW, nPageH, undefined, nApIdx),
size: {
w: nPageW,
h: nPageH
Expand All @@ -257,7 +258,7 @@
}

for (let i = 0; i < this.APInfo.info.length; i++) {
if (this.APInfo.info[i]["i"] == this._apIdx)
if (this.APInfo.info[i]["i"] == nApIdx)
return this.APInfo.info[i];
}

Expand Down Expand Up @@ -379,6 +380,7 @@
let aStrokeColor = this.GetStrokeColor();
let aFillColor = this.GetFillColor();

oNewStamp._copyApIdx = this._copyApIdx;
oNewStamp._apIdx = this._apIdx;
oNewStamp._originView = this._originView;
oNewStamp.SetOriginPage(this.GetOriginPage());
Expand Down Expand Up @@ -419,8 +421,14 @@
oNewStamp.SetWidth(this.GetWidth());
oNewStamp.SetOpacity(this.GetOpacity());
oNewStamp.SetIconType(this.GetIconType());
oNewStamp.SetRotate(this.GetRotate());
oNewStamp.Recalculate(true);

if ((this.IsUseInDocument() && this.IsNeedDrawFromStream()) || !this.IsChanged() || this.GetCopyOfApIdx() != -1) {
oNewStamp.SetCopyOfApIdx(this.GetCopyOfApIdx() != -1 ? this.GetCopyOfApIdx() : this.GetApIdx());
oNewStamp.SetDrawFromStream(true, true);
}

return oNewStamp;
};
CAnnotationStamp.prototype.IsSelected = function() {
Expand Down Expand Up @@ -500,15 +508,18 @@
// original rect
if (memory.docRenderer) {
memory.WriteDouble(aInRect[0] - nBorderW / 2); // x1
memory.WriteDouble(aInRect[1] + nBorderW / 2); // y2
memory.WriteDouble(aInRect[0] - nBorderW / 2); // x1
memory.WriteDouble(aInRect[3] - nBorderW / 2); // y1
memory.WriteDouble(aInRect[4] + nBorderW / 2); // x2
memory.WriteDouble(aInRect[3] - nBorderW / 2); // y1
memory.WriteDouble(aInRect[4] + nBorderW / 2); // x2
memory.WriteDouble(aInRect[1] + nBorderW / 2); // y2
}
else {
memory.WriteDouble(aInRect[0]); // x1
memory.WriteDouble(aInRect[3]); // y1
memory.WriteDouble(aInRect[4]); // x2
memory.WriteDouble(aInRect[1]); // y2
aInRect.forEach(function(measure) {
memory.WriteDouble(measure);
});
}


Expand All @@ -524,10 +535,10 @@
(reply.IsChanged() || !memory.docRenderer) && reply.WriteToBinary(memory);
});
};
CAnnotationStamp.prototype.SetDrawFromStream = function() {
CAnnotationStamp.prototype.SetDrawFromStream = function(bDraw, bForce) {
let oViewer = editor.getDocumentRenderer();
if (oViewer.IsOpenAnnotsInProgress) {
this._bDrawFromStream = true;
if (oViewer.IsOpenAnnotsInProgress || bForce) {
this._bDrawFromStream = bDraw;
}
};
CAnnotationStamp.prototype.WriteRenderToBinary = function(memory) {
Expand Down
3 changes: 3 additions & 0 deletions pdf/src/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -6976,6 +6976,9 @@ var CPresentation = CPresentation || function(){};
uid: annotJson["OUserID"]
}, oDoc);

if (annotJson["AP"]["Copy"]) {
oAnnot.SetCopyOfApIdx(annotJson["AP"]["Copy"]);
}
oAnnot.SetDrawFromStream(Boolean(annotJson["AP"]["have"]));
oAnnot.SetOriginPage(annotJson["page"]);

Expand Down

0 comments on commit e96f51d

Please sign in to comment.