mirror of
https://github.com/ONLYOFFICE/sdkjs.git
synced 2026-04-07 14:09:12 +08:00
[pdf] Fix bug #80316
This commit is contained in:
14
pdf/api.js
14
pdf/api.js
@ -1430,6 +1430,18 @@
|
||||
PDFEditorApi.prototype.IsRedactTool = function() {
|
||||
return !!this.isRedactTool;
|
||||
};
|
||||
PDFEditorApi.prototype.SetRedactDelForm = function(bDel) {
|
||||
this.bRedactDelForms = bDel;
|
||||
};
|
||||
PDFEditorApi.prototype.IsRedactDelForms = function() {
|
||||
return !!this.bRedactDelForms;
|
||||
};
|
||||
PDFEditorApi.prototype.SetRedactDelAnnots = function(bDel) {
|
||||
this.bRedactDelAnnots = bDel;
|
||||
};
|
||||
PDFEditorApi.prototype.IsRedactDelAnnots = function() {
|
||||
return !!this.bRedactDelAnnots;
|
||||
};
|
||||
PDFEditorApi.prototype.RedactPages = function(aIdxs) {
|
||||
let oDoc = this.getPDFDoc();
|
||||
let oFile = oDoc.Viewer.file;
|
||||
@ -5397,6 +5409,8 @@
|
||||
// redact
|
||||
PDFEditorApi.prototype['SetRedactTool'] = PDFEditorApi.prototype.SetRedactTool;
|
||||
PDFEditorApi.prototype['IsRedactTool'] = PDFEditorApi.prototype.IsRedactTool;
|
||||
PDFEditorApi.prototype['SetRedactDelForm'] = PDFEditorApi.prototype.SetRedactDelForm;
|
||||
PDFEditorApi.prototype['SetRedactDelAnnots']= PDFEditorApi.prototype.SetRedactDelAnnots;
|
||||
PDFEditorApi.prototype['RedactPages'] = PDFEditorApi.prototype.RedactPages;
|
||||
PDFEditorApi.prototype['ApplyRedact'] = PDFEditorApi.prototype.ApplyRedact;
|
||||
PDFEditorApi.prototype['HasRedact'] = PDFEditorApi.prototype.HasRedact;
|
||||
|
||||
@ -7664,6 +7664,7 @@ var CPresentation = CPresentation || function(){};
|
||||
CPDFDoc.prototype.ApplyRedact = function(sRedactId, nPage) {
|
||||
let oFile = this.Viewer.file;
|
||||
let oNativeFile = oFile.nativeFile;
|
||||
let _t = this;
|
||||
|
||||
this.BlurActiveObject();
|
||||
|
||||
@ -7675,6 +7676,33 @@ var CPresentation = CPresentation || function(){};
|
||||
isOnMerge = true;
|
||||
}
|
||||
|
||||
function isIntersectingRects(quads, rect) {
|
||||
let xCoords = [quads[0], quads[2], quads[4], quads[6]];
|
||||
let yCoords = [quads[1], quads[3], quads[5], quads[7]];
|
||||
|
||||
let r1 = {
|
||||
left: Math.min.apply(null, xCoords),
|
||||
right: Math.max.apply(null, xCoords),
|
||||
top: Math.min.apply(null, yCoords),
|
||||
bottom: Math.max.apply(null, yCoords)
|
||||
};
|
||||
|
||||
let r2 = {
|
||||
left: rect[0],
|
||||
top: rect[1],
|
||||
right: rect[2],
|
||||
bottom: rect[3]
|
||||
};
|
||||
|
||||
let isOutside =
|
||||
r1.left > r2.right ||
|
||||
r1.right < r2.left ||
|
||||
r1.top > r2.bottom ||
|
||||
r1.bottom < r2.top;
|
||||
|
||||
return !isOutside;
|
||||
}
|
||||
|
||||
function applyForPage(pageIdx) {
|
||||
if (!isOnMerge) {
|
||||
sRedactId = AscCommon.g_oIdCounter.GetNewIdForPdfRedact();
|
||||
@ -7746,6 +7774,34 @@ var CPresentation = CPresentation || function(){};
|
||||
|
||||
this.SetRedactData(sRedactId, oPageInfo.GetId(), aQuadsFlat, oRender);
|
||||
}
|
||||
|
||||
if (Asc.editor.IsRedactDelForms()) {
|
||||
oPageInfo.fields.slice().forEach(function(field) {
|
||||
let aRect = field.GetRect();
|
||||
|
||||
for (let i = 0, count = aQuadsFlat.length / 8; i < count; i++) {
|
||||
if (isIntersectingRects(aQuadsFlat.slice(i, i + 8), aRect)) {
|
||||
_t.RemoveField(field.GetId());
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if (Asc.editor.IsRedactDelAnnots()) {
|
||||
oPageInfo.annots.slice().forEach(function(annot) {
|
||||
if (annot.IsRedact()) {
|
||||
return;
|
||||
}
|
||||
|
||||
let aRect = annot.GetRect();
|
||||
for (let i = 0, count = aQuadsFlat.length / 8; i < count; i++) {
|
||||
if (isIntersectingRects(aQuadsFlat.slice(i, i + 8), aRect)) {
|
||||
_t.RemoveAnnot(annot.GetId());
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (nPage != undefined) {
|
||||
|
||||
Reference in New Issue
Block a user