Skip to content

Commit

Permalink
Merge pull request '[pdf] Locks for markup annots' (#354) from fix/lo…
Browse files Browse the repository at this point in the history
…cks-pdf into develop

Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/sdkjs/pulls/354
  • Loading branch information
KhromovNikita committed Nov 26, 2024
2 parents 25ff4a2 + ca91f95 commit 9058a25
Show file tree
Hide file tree
Showing 5 changed files with 460 additions and 393 deletions.
4 changes: 3 additions & 1 deletion pdf/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,9 @@
let oFile = oViewer.file;
let oDoc = this.getPDFDoc();

let nPos = bBefore ? oViewer.currentPage : oViewer.currentPage + 1;
let oThumbnails = oViewer.thumbnails;
let aIndexes = oThumbnails.getSelectedPages();
let nPos = bBefore ? Math.min.apply(null, aIndexes) : Math.max.apply(null, aIndexes) + 1;

oDoc.DoAction(function() {
let oPageToClone = bBefore ? oFile.pages[oViewer.currentPage] : (oFile.pages[oViewer.currentPage + 1] || oFile.pages[oViewer.currentPage]);
Expand Down
24 changes: 18 additions & 6 deletions pdf/src/annotations/highlights.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,9 @@
y: aPoints[7]
}

let dx1 = oPoint2.x - oPoint1.x;
let dy1 = oPoint2.y - oPoint1.y;
let dx2 = oPoint4.x - oPoint3.x;
let dy2 = oPoint4.y - oPoint3.y;
let angle1 = Math.atan2(dy1, dx1);
let angle2 = Math.atan2(dy2, dx2);
let dx = oPoint2.x - oPoint1.x;
let dy = oPoint2.y - oPoint1.y;
let angle1 = Math.atan2(dy, dx);
let rotationAngle = angle1;

oGraphicsPDF.SetGlobalAlpha(this.GetOpacity());
Expand All @@ -237,6 +234,9 @@
oGraphicsPDF.Fill();
AscPDF.endMultiplyMode(oGraphicsPDF.GetContext());
}

let aUnitedRegion = this.GetUnitedRegion();
oGraphicsPDF.DrawLockObjectRect(this.Lock.Get_Type(), aUnitedRegion.regions);
};

/**
Expand Down Expand Up @@ -317,6 +317,9 @@

oGraphicsPDF.Stroke();
}

let aUnitedRegion = this.GetUnitedRegion();
oGraphicsPDF.DrawLockObjectRect(this.Lock.Get_Type(), aUnitedRegion.regions);
};

/**
Expand Down Expand Up @@ -391,6 +394,9 @@

oGraphicsPDF.Stroke();
}

let aUnitedRegion = this.GetUnitedRegion();
oGraphicsPDF.DrawLockObjectRect(this.Lock.Get_Type(), aUnitedRegion.regions);
};

/**
Expand Down Expand Up @@ -471,6 +477,9 @@

oGraphicsPDF.Stroke();
}

let aUnitedRegion = this.GetUnitedRegion();
oGraphicsPDF.DrawLockObjectRect(this.Lock.Get_Type(), aUnitedRegion.regions);
};

let CARET_SYMBOL = {
Expand Down Expand Up @@ -558,6 +567,9 @@

oGraphicsPDF.Stroke();
}

let aUnitedRegion = this.GetUnitedRegion();
oGraphicsPDF.DrawLockObjectRect(this.Lock.Get_Type(), aUnitedRegion.regions);
};
CAnnotationCaret.prototype.SetCaretSymbol = function(nType) {
this._caretSymbol = nType;
Expand Down
9 changes: 8 additions & 1 deletion pdf/src/annotations/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,14 @@

oCtx.restore();

oGraphics.DrawLockObjectRect(this.Lock.Get_Type(), nX, nY, 20 / oDoc.Viewer.zoom, 20 / oDoc.Viewer.zoom);
let aRegions = [[
[nX + nWidth, nY],
[nX, nY],
[nX, nY + nHeight],
[nX + nWidth, nY + nHeight]
]];

oGraphics.DrawLockObjectRect(this.Lock.Get_Type(), aRegions);
//// draw rect
// oGraphics.SetLineWidth(1);
// oGraphics.SetStrokeStyle(0, 255, 255);
Expand Down
10 changes: 8 additions & 2 deletions pdf/src/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -5804,10 +5804,13 @@ var CPresentation = CPresentation || function(){};
if (false == [AscCommon.c_oAscLockTypes.kLockTypeMine, AscCommon.c_oAscLockTypes.kLockTypeNone].includes(oCurPageInfo.Lock.Type))
return true;

let selected_objects = oController.selectedObjects;
let selected_objects = oController.selectedObjects.slice();
if (oController.selection.groupSelection) {
selected_objects.push(oController.selection.groupSelection);
}
if (this.mouseDownAnnot) {
selected_objects.push(this.mouseDownAnnot);
}

if (isRestrictionView) {
for (let i = 0; i < selected_objects.length; i++) {
Expand Down Expand Up @@ -5855,10 +5858,13 @@ var CPresentation = CPresentation || function(){};
case AscCommon.changestype_2_Comment: {
let sCommentId = AdditionalData;

let selected_objects = oController.selectedObjects;
let selected_objects = oController.selectedObjects.slice();
if (oController.selection.groupSelection) {
selected_objects.push(oController.selection.groupSelection);
}
if (this.mouseDownAnnot) {
selected_objects.push(this.mouseDownAnnot);
}

for (let i = 0; i < selected_objects.length; ++i) {
if (selected_objects[i].GetId() == sCommentId) {
Expand Down
Loading

0 comments on commit 9058a25

Please sign in to comment.