mirror of
https://github.com/ONLYOFFICE/sdkjs.git
synced 2026-04-07 14:09:12 +08:00
Merge pull request 'fix/pdf-bugs' (#1007) from fix/pdf-bugs into release/v9.0.0
This commit is contained in:
@ -681,7 +681,7 @@
|
||||
let startPos = paragraph.getCurrentPos();
|
||||
let endPos = startPos;
|
||||
|
||||
let paraSearchPos = new CParagraphSearchPos();
|
||||
let paraSearchPos = new AscWord.CParagraphSearchPos();
|
||||
|
||||
let maxShifts = oldCodePoints.length;
|
||||
let selectedText;
|
||||
|
||||
@ -204,6 +204,51 @@ var CPresentation = CPresentation || function(){};
|
||||
this.checkDefaultFonts();
|
||||
}
|
||||
|
||||
Object.defineProperties(CPDFDoc.prototype, {
|
||||
widgets: {
|
||||
get: function () {
|
||||
let aWidgets = [];
|
||||
|
||||
let nPages = this.GetPagesCount();
|
||||
for (let i = 0; i < nPages; i++) {
|
||||
let oPageInfo = this.GetPageInfo(i);
|
||||
|
||||
aWidgets = aWidgets.concat(oPageInfo.fields);
|
||||
}
|
||||
|
||||
return aWidgets;
|
||||
}
|
||||
},
|
||||
annots: {
|
||||
get: function () {
|
||||
let aAnnots = [];
|
||||
|
||||
let nPages = this.GetPagesCount();
|
||||
for (let i = 0; i < nPages; i++) {
|
||||
let oPageInfo = this.GetPageInfo(i);
|
||||
|
||||
aAnnots = aAnnots.concat(oPageInfo.annots);
|
||||
}
|
||||
|
||||
return aAnnots;
|
||||
}
|
||||
},
|
||||
drawings: {
|
||||
get: function () {
|
||||
let aDrawings = [];
|
||||
|
||||
let nPages = this.GetPagesCount();
|
||||
for (let i = 0; i < nPages; i++) {
|
||||
let oPageInfo = this.GetPageInfo(i);
|
||||
|
||||
aDrawings = aDrawings.concat(oPageInfo.drawings);
|
||||
}
|
||||
|
||||
return aDrawings;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
CPDFDoc.prototype.RecalculateAll = function() {
|
||||
let fontMap = {};
|
||||
|
||||
@ -2619,7 +2664,7 @@ var CPresentation = CPresentation || function(){};
|
||||
* @param {number} [nPos = 0]
|
||||
* @returns {boolean}
|
||||
*/
|
||||
CPDFDoc.prototype.RemovePage = function(nPos, isOnMove) {
|
||||
CPDFDoc.prototype.RemovePage = function(nPos) {
|
||||
let oThis = this;
|
||||
let oViewer = editor.getDocumentRenderer();
|
||||
let oFile = oViewer.file;
|
||||
@ -2632,23 +2677,21 @@ var CPresentation = CPresentation || function(){};
|
||||
|
||||
oFile.removeSelection();
|
||||
|
||||
if (true !== isOnMove) {
|
||||
// сначала удаляем все объекты со страницы
|
||||
if (oViewer.pagesInfo.pages[nPos].fields) {
|
||||
oViewer.pagesInfo.pages[nPos].fields.slice().forEach(function(field) {
|
||||
oThis.RemoveField(field.GetId());
|
||||
});
|
||||
}
|
||||
if (oViewer.pagesInfo.pages[nPos].annots) {
|
||||
oViewer.pagesInfo.pages[nPos].annots.slice().forEach(function(annot) {
|
||||
oThis.RemoveAnnot(annot.GetId());
|
||||
});
|
||||
}
|
||||
if (oViewer.pagesInfo.pages[nPos].drawings) {
|
||||
oViewer.pagesInfo.pages[nPos].drawings.slice().forEach(function(drawing) {
|
||||
oThis.RemoveDrawing(drawing.GetId());
|
||||
});
|
||||
}
|
||||
// сначала удаляем все объекты со страницы
|
||||
if (oViewer.pagesInfo.pages[nPos].fields) {
|
||||
oViewer.pagesInfo.pages[nPos].fields.slice().forEach(function(field) {
|
||||
oThis.RemoveField(field.GetId());
|
||||
});
|
||||
}
|
||||
if (oViewer.pagesInfo.pages[nPos].annots) {
|
||||
oViewer.pagesInfo.pages[nPos].annots.slice().forEach(function(annot) {
|
||||
oThis.RemoveAnnot(annot.GetId());
|
||||
});
|
||||
}
|
||||
if (oViewer.pagesInfo.pages[nPos].drawings) {
|
||||
oViewer.pagesInfo.pages[nPos].drawings.slice().forEach(function(drawing) {
|
||||
oThis.RemoveDrawing(drawing.GetId());
|
||||
});
|
||||
}
|
||||
|
||||
// убираем информацию о странице
|
||||
@ -2725,7 +2768,7 @@ var CPresentation = CPresentation || function(){};
|
||||
});
|
||||
|
||||
aLowerIndexes.forEach(function(oldIndex, i) {
|
||||
let oPage = _t.RemovePage(oldIndex, true);
|
||||
let oPage = _t.RemovePage(oldIndex);
|
||||
_t.AddPage(nNewPos - i, oPage);
|
||||
});
|
||||
}
|
||||
@ -2738,7 +2781,7 @@ var CPresentation = CPresentation || function(){};
|
||||
let nOffset = aLowerIndexes.length > 0 ? 1 : 0;
|
||||
|
||||
aHigherIndexes.forEach(function(oldIndex, i) {
|
||||
let oPage = _t.RemovePage(oldIndex, true);
|
||||
let oPage = _t.RemovePage(oldIndex);
|
||||
_t.AddPage(nNewPos + nOffset + i, oPage);
|
||||
});
|
||||
}
|
||||
@ -2819,7 +2862,6 @@ var CPresentation = CPresentation || function(){};
|
||||
|
||||
oField._origRect = aCoords;
|
||||
|
||||
this.widgets.push(oField);
|
||||
oField.SetNeedRecalc(true);
|
||||
|
||||
oPageInfo.fields.push(oField);
|
||||
@ -2910,8 +2952,6 @@ var CPresentation = CPresentation || function(){};
|
||||
oField.SetPosition(oPos.x, oPos.y)
|
||||
}
|
||||
|
||||
this.widgets.push(oField);
|
||||
|
||||
oField.SetDocument(this);
|
||||
oPagesInfo.AddField(oField);
|
||||
|
||||
@ -2950,7 +2990,6 @@ var CPresentation = CPresentation || function(){};
|
||||
oAnnot.SetNeedRecalc(true);
|
||||
oAnnot.SetDisplay(this.IsAnnotsHidden() ? window["AscPDF"].Api.Types.display["hidden"] : window["AscPDF"].Api.Types.display["visible"]);
|
||||
|
||||
this.annots.push(oAnnot);
|
||||
oPageInfo.AddAnnot(oAnnot);
|
||||
|
||||
return oAnnot;
|
||||
@ -2960,8 +2999,6 @@ var CPresentation = CPresentation || function(){};
|
||||
if (!oPagesInfo)
|
||||
return;
|
||||
|
||||
this.annots.push(oAnnot);
|
||||
|
||||
oAnnot.SetDocument(this);
|
||||
oPagesInfo.AddAnnot(oAnnot);
|
||||
};
|
||||
@ -3564,9 +3601,6 @@ var CPresentation = CPresentation || function(){};
|
||||
if (!oAnnot)
|
||||
return;
|
||||
|
||||
let nPos = this.annots.indexOf(oAnnot);
|
||||
this.annots.splice(nPos, 1);
|
||||
|
||||
let oPage = oAnnot.GetParentPage();
|
||||
oPage.RemoveAnnot(Id);
|
||||
|
||||
@ -3592,9 +3626,6 @@ var CPresentation = CPresentation || function(){};
|
||||
if (!oDrawing)
|
||||
return;
|
||||
|
||||
let nPos = this.drawings.indexOf(oDrawing);
|
||||
this.drawings.splice(nPos, 1);
|
||||
|
||||
let oPage = oDrawing.GetParentPage();
|
||||
oPage.RemoveDrawing(Id);
|
||||
|
||||
@ -3620,10 +3651,6 @@ var CPresentation = CPresentation || function(){};
|
||||
if (!oForm || !oForm.IsWidget())
|
||||
return;
|
||||
|
||||
// удаляем поле из виджетов и со страницы
|
||||
let nPos = this.widgets.indexOf(oForm);
|
||||
this.widgets.splice(nPos, 1);
|
||||
|
||||
let oPage = oForm.GetParentPage();
|
||||
oPage.RemoveField(oForm.GetId());
|
||||
|
||||
@ -5341,8 +5368,6 @@ var CPresentation = CPresentation || function(){};
|
||||
if (!oPagesInfo)
|
||||
return;
|
||||
|
||||
this.drawings.push(oDrawing);
|
||||
|
||||
oDrawing.SetDocument(this);
|
||||
oPagesInfo.AddDrawing(oDrawing, nPosInTree);
|
||||
this.ClearSearch();
|
||||
@ -5374,7 +5399,6 @@ var CPresentation = CPresentation || function(){};
|
||||
oXfrm.setOffX(oPos.x);
|
||||
oXfrm.setOffY(oPos.y);
|
||||
|
||||
this.drawings.push(oTextArt);
|
||||
oPagesInfo.AddDrawing(oTextArt);
|
||||
oTextArt.SetNeedRecalc(true);
|
||||
|
||||
|
||||
@ -92,6 +92,9 @@
|
||||
this.DrawLocks(oGraphicsPDF);
|
||||
this.DrawEdit(oGraphicsWord);
|
||||
};
|
||||
CListBoxField.prototype._isCenterAlign = function() {
|
||||
return false;
|
||||
};
|
||||
CListBoxField.prototype.Recalculate = function() {
|
||||
if (this.IsNeedRecalc() == false)
|
||||
return;
|
||||
@ -112,12 +115,20 @@
|
||||
let X = aOrigRect[0];
|
||||
let Y = aOrigRect[1];
|
||||
let nWidth = (aOrigRect[2] - aOrigRect[0]);
|
||||
let nHeight = (aOrigRect[3] - aOrigRect[1]);
|
||||
|
||||
let oMargins = this.GetMarginsFromBorders();
|
||||
|
||||
let contentX = (X + oMargins.left) * g_dKoef_pt_to_mm;
|
||||
let contentY = (Y + oMargins.top) * g_dKoef_pt_to_mm;
|
||||
let contentXLimit = (X + nWidth - oMargins.left) * g_dKoef_pt_to_mm;
|
||||
let contentYLimit = (Y + nHeight - oMargins.bottom) * g_dKoef_pt_to_mm;
|
||||
|
||||
let rot = this.GetRotate();
|
||||
if (90 === rot || 270 === rot){
|
||||
let contentW = contentYLimit - contentY;
|
||||
contentXLimit = contentX + contentW;
|
||||
}
|
||||
|
||||
if (contentX != this.content.X || contentY != this.content.Y ||
|
||||
contentXLimit != this.content.XLimit) {
|
||||
@ -655,9 +666,18 @@
|
||||
let oContentRect = this.getFormRelRect();
|
||||
let aOrigRect = this.GetOrigRect();
|
||||
|
||||
let nFormRotAngle = this.GetRotate();
|
||||
let dFrmW = oContentRect.W;
|
||||
let dFrmH = oContentRect.H;
|
||||
if (nFormRotAngle === 90 || nFormRotAngle === 270) {
|
||||
let tmp = dFrmW;
|
||||
dFrmW = dFrmH;
|
||||
dFrmH = tmp;
|
||||
}
|
||||
|
||||
let nContentH = oContentBounds.Bottom - oContentBounds.Top;
|
||||
let oScrollInfo = this.GetScrollInfo();
|
||||
if (bShow == false || nContentH < oContentRect.H) {
|
||||
if (bShow == false || nContentH < dFrmH) {
|
||||
if (oScrollInfo) {
|
||||
oScrollInfo.docElem.style.display = "none";
|
||||
}
|
||||
@ -669,38 +689,88 @@
|
||||
let nPage = this.GetPage();
|
||||
let oTransform = oDoc.pagesTransform[nPage].invert;
|
||||
let oViewer = oDoc.Viewer;
|
||||
let isLandscape = oViewer.isLandscapePage(nPage);
|
||||
let nRotAngle = oViewer.getPageRotate(nPage);
|
||||
let nPageAngle = oViewer.getPageRotate(nPage);
|
||||
let nRotAngle = nPageAngle - nFormRotAngle;
|
||||
let isLandscapePage = [90, -90, 270, -270].includes(nPageAngle);
|
||||
let isLandscape = [90, -90, 270, -270].includes(nRotAngle);
|
||||
let bInvertScroll = false;
|
||||
|
||||
let oGlobalCoords1 = oTransform.TransformPoint(aOrigRect[0], aOrigRect[1]);
|
||||
let oGlobalCoords2 = oTransform.TransformPoint(aOrigRect[2], aOrigRect[3]);
|
||||
if (nRotAngle === 0 && nPageAngle === 180 && nFormRotAngle === 180) {
|
||||
nRotAngle = 180;
|
||||
}
|
||||
|
||||
let X1 = aOrigRect[0];
|
||||
let Y1 = aOrigRect[1];
|
||||
let X2 = aOrigRect[2];
|
||||
let Y2 = aOrigRect[3];
|
||||
|
||||
switch (nFormRotAngle) {
|
||||
case 90: {
|
||||
Y2 = aOrigRect[1];
|
||||
break;
|
||||
}
|
||||
case 180: {
|
||||
if (isLandscapePage) {
|
||||
Y1 = aOrigRect[3];
|
||||
Y2 = aOrigRect[1];
|
||||
}
|
||||
|
||||
X2 = aOrigRect[0];
|
||||
break;
|
||||
}
|
||||
case 270: {
|
||||
if (nPageAngle != 90) {
|
||||
X1 = aOrigRect[2];
|
||||
X2 = aOrigRect[0];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let oGlobalCoords1 = oTransform.TransformPoint(X1, Y1);
|
||||
let oGlobalCoords2 = oTransform.TransformPoint(X2, Y2);
|
||||
|
||||
let nLeftPos;
|
||||
let nTopPos;
|
||||
|
||||
let bInvertScroll = false;
|
||||
switch (nRotAngle) {
|
||||
case 0:
|
||||
nLeftPos = Math.round(oGlobalCoords2.x);
|
||||
nLeftPos = nFormRotAngle == 180 ? Math.round(oGlobalCoords2.x) - 14 : Math.round(oGlobalCoords2.x);
|
||||
nTopPos = Math.round(oGlobalCoords1.y);
|
||||
break;
|
||||
case -180:
|
||||
nLeftPos = nFormRotAngle == 180 || isLandscapePage ? Math.round(oGlobalCoords2.x) - 14 : Math.round(oGlobalCoords2.x);
|
||||
nTopPos = Math.round(oGlobalCoords1.y);
|
||||
|
||||
bInvertScroll = true;
|
||||
break
|
||||
case 90:
|
||||
nLeftPos = Math.round(oGlobalCoords2.x);
|
||||
nTopPos = nFormRotAngle == 180 ? Math.round(oGlobalCoords2.y) - 14 : Math.round(oGlobalCoords2.y);
|
||||
|
||||
bInvertScroll = true;
|
||||
case -270:
|
||||
nLeftPos = Math.round(oGlobalCoords2.x);
|
||||
nTopPos = Math.round(oGlobalCoords2.y);
|
||||
|
||||
bInvertScroll = true;
|
||||
break;
|
||||
case 180:
|
||||
nLeftPos = Math.round(oGlobalCoords2.x) - 14;
|
||||
nLeftPos = nFormRotAngle == 180 || (nRotAngle < 0 && isLandscapePage) && nPageAngle !== nFormRotAngle ? Math.round(oGlobalCoords2.x) : Math.round(oGlobalCoords2.x) - 14;
|
||||
nTopPos = Math.round(oGlobalCoords2.y);
|
||||
bInvertScroll = true;
|
||||
if (nPageAngle != nFormRotAngle) {
|
||||
bInvertScroll = true;
|
||||
}
|
||||
|
||||
break;
|
||||
case 270:
|
||||
case -90:
|
||||
nLeftPos = Math.round(oGlobalCoords1.x);
|
||||
nTopPos = Math.round(oGlobalCoords2.y) - 14;
|
||||
break;
|
||||
}
|
||||
|
||||
if (oContentBounds.Bottom - oContentBounds.Top > oContentRect.H) {
|
||||
if (oContentBounds.Bottom - oContentBounds.Top > dFrmH) {
|
||||
let oScrollDocElm;
|
||||
if (oScrollInfo == null) {
|
||||
oViewer.scrollCount++;
|
||||
@ -720,7 +790,7 @@
|
||||
oScrollDocElm.style.height = isLandscape ? "14px" : Math.round(Math.abs(oGlobalCoords2.y - oGlobalCoords1.y)) + "px";
|
||||
oScrollDocElm.style.zIndex = 0;
|
||||
|
||||
let nMaxShift = oContentRect.H - nContentH;
|
||||
let nMaxShift = dFrmH - nContentH;
|
||||
|
||||
let oScrollSettings = Asc.editor.WordControl.CreateScrollSettings();
|
||||
oScrollSettings.isHorizontalScroll = isLandscape;
|
||||
|
||||
@ -1045,6 +1045,9 @@
|
||||
|
||||
this.SetNeedRecalc(false);
|
||||
};
|
||||
CTextField.prototype._isCenterAlign = function() {
|
||||
return false == this.IsMultiline();
|
||||
};
|
||||
CTextField.prototype.RecalculateContentRect = function() {
|
||||
let aOrigRect = this.GetOrigRect();
|
||||
|
||||
@ -1237,9 +1240,19 @@
|
||||
let oContentRect = this.getFormRelRect();
|
||||
let aOrigRect = this.GetOrigRect();
|
||||
|
||||
let nFormRotAngle = this.GetRotate();
|
||||
let dFrmW = oContentRect.W;
|
||||
let dFrmH = oContentRect.H;
|
||||
if (nFormRotAngle === 90 || nFormRotAngle === 270) {
|
||||
let tmp = dFrmW;
|
||||
dFrmW = dFrmH;
|
||||
dFrmH = tmp;
|
||||
}
|
||||
|
||||
|
||||
let nContentH = oContentBounds.Bottom - oContentBounds.Top;
|
||||
let oScrollInfo = this.GetScrollInfo();
|
||||
if ((bShow == false || nContentH < oContentRect.H || this.IsDoNotScroll())) {
|
||||
if ((bShow == false || nContentH < dFrmH || this.IsDoNotScroll())) {
|
||||
if (oScrollInfo) {
|
||||
oScrollInfo.docElem.style.display = "none";
|
||||
}
|
||||
@ -1251,38 +1264,88 @@
|
||||
let nPage = this.GetPage();
|
||||
let oTransform = oDoc.pagesTransform[nPage].invert;
|
||||
let oViewer = oDoc.Viewer;
|
||||
let isLandscape = oViewer.isLandscapePage(nPage);
|
||||
let nRotAngle = oViewer.getPageRotate(nPage);
|
||||
let nPageAngle = oViewer.getPageRotate(nPage);
|
||||
let nRotAngle = nPageAngle - nFormRotAngle;
|
||||
let isLandscapePage = [90, -90, 270, -270].includes(nPageAngle);
|
||||
let isLandscape = [90, -90, 270, -270].includes(nRotAngle);
|
||||
let bInvertScroll = false;
|
||||
|
||||
let oGlobalCoords1 = oTransform.TransformPoint(aOrigRect[0], aOrigRect[1]);
|
||||
let oGlobalCoords2 = oTransform.TransformPoint(aOrigRect[2], aOrigRect[3]);
|
||||
if (nRotAngle === 0 && nPageAngle === 180 && nFormRotAngle === 180) {
|
||||
nRotAngle = 180;
|
||||
}
|
||||
|
||||
let X1 = aOrigRect[0];
|
||||
let Y1 = aOrigRect[1];
|
||||
let X2 = aOrigRect[2];
|
||||
let Y2 = aOrigRect[3];
|
||||
|
||||
switch (nFormRotAngle) {
|
||||
case 90: {
|
||||
Y2 = aOrigRect[1];
|
||||
break;
|
||||
}
|
||||
case 180: {
|
||||
if (isLandscapePage) {
|
||||
Y1 = aOrigRect[3];
|
||||
Y2 = aOrigRect[1];
|
||||
}
|
||||
|
||||
X2 = aOrigRect[0];
|
||||
break;
|
||||
}
|
||||
case 270: {
|
||||
if (nPageAngle != 90) {
|
||||
X1 = aOrigRect[2];
|
||||
X2 = aOrigRect[0];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let oGlobalCoords1 = oTransform.TransformPoint(X1, Y1);
|
||||
let oGlobalCoords2 = oTransform.TransformPoint(X2, Y2);
|
||||
|
||||
let nLeftPos;
|
||||
let nTopPos;
|
||||
|
||||
let bInvertScroll = false;
|
||||
switch (nRotAngle) {
|
||||
case 0:
|
||||
nLeftPos = Math.round(oGlobalCoords2.x);
|
||||
nLeftPos = nFormRotAngle == 180 ? Math.round(oGlobalCoords2.x) - 14 : Math.round(oGlobalCoords2.x);
|
||||
nTopPos = Math.round(oGlobalCoords1.y);
|
||||
break;
|
||||
case -180:
|
||||
nLeftPos = nFormRotAngle == 180 || isLandscapePage ? Math.round(oGlobalCoords2.x) - 14 : Math.round(oGlobalCoords2.x);
|
||||
nTopPos = Math.round(oGlobalCoords1.y);
|
||||
|
||||
bInvertScroll = true;
|
||||
break
|
||||
case 90:
|
||||
nLeftPos = Math.round(oGlobalCoords2.x);
|
||||
nTopPos = nFormRotAngle == 180 ? Math.round(oGlobalCoords2.y) - 14 : Math.round(oGlobalCoords2.y);
|
||||
|
||||
bInvertScroll = true;
|
||||
case -270:
|
||||
nLeftPos = Math.round(oGlobalCoords2.x);
|
||||
nTopPos = Math.round(oGlobalCoords2.y);
|
||||
|
||||
bInvertScroll = true;
|
||||
break;
|
||||
case 180:
|
||||
nLeftPos = Math.round(oGlobalCoords2.x) - 14;
|
||||
nLeftPos = nFormRotAngle == 180 || (nRotAngle < 0 && isLandscapePage) && nPageAngle !== nFormRotAngle ? Math.round(oGlobalCoords2.x) : Math.round(oGlobalCoords2.x) - 14;
|
||||
nTopPos = Math.round(oGlobalCoords2.y);
|
||||
bInvertScroll = true;
|
||||
if (nPageAngle != nFormRotAngle) {
|
||||
bInvertScroll = true;
|
||||
}
|
||||
|
||||
break;
|
||||
case 270:
|
||||
case -90:
|
||||
nLeftPos = Math.round(oGlobalCoords1.x);
|
||||
nTopPos = Math.round(oGlobalCoords2.y) - 14;
|
||||
break;
|
||||
}
|
||||
|
||||
if (oContentBounds.Bottom - oContentBounds.Top > oContentRect.H) {
|
||||
if (oContentBounds.Bottom - oContentBounds.Top > dFrmH) {
|
||||
let oScrollDocElm;
|
||||
if (oScrollInfo == null) {
|
||||
oViewer.scrollCount++;
|
||||
@ -1302,7 +1365,7 @@
|
||||
oScrollDocElm.style.height = isLandscape ? "14px" : Math.round(Math.abs(oGlobalCoords2.y - oGlobalCoords1.y)) + "px";
|
||||
oScrollDocElm.style.zIndex = 0;
|
||||
|
||||
let nMaxShift = oContentRect.H - nContentH;
|
||||
let nMaxShift = dFrmH - nContentH;
|
||||
|
||||
let oScrollSettings = Asc.editor.WordControl.CreateScrollSettings();
|
||||
oScrollSettings.isHorizontalScroll = isLandscape;
|
||||
|
||||
@ -214,7 +214,6 @@ CChangesPDFDocumentAnnotsContent.prototype.Undo = function()
|
||||
{
|
||||
let oItem = this.Items[nIndex];
|
||||
oItem.AddToRedraw();
|
||||
oDocument.annots.splice(oDocument.annots.indexOf(oItem), 1);
|
||||
oPage.annots.splice(this.Pos, 1);
|
||||
|
||||
oItem.parentPage = null;
|
||||
@ -231,7 +230,6 @@ CChangesPDFDocumentAnnotsContent.prototype.Undo = function()
|
||||
{
|
||||
let oItem = this.Items[nIndex];
|
||||
oItem.AddToRedraw();
|
||||
oDocument.annots.push(oItem);
|
||||
oPage.annots.splice(this.Pos, 0, oItem);
|
||||
|
||||
oItem.parentPage = oPage;
|
||||
@ -260,7 +258,6 @@ CChangesPDFDocumentAnnotsContent.prototype.Redo = function()
|
||||
{
|
||||
let oItem = this.Items[nIndex];
|
||||
oItem.AddToRedraw();
|
||||
oDocument.annots.push(oItem);
|
||||
oPage.annots.splice(this.Pos, 0, oItem);
|
||||
|
||||
oItem.parentPage = oPage;
|
||||
@ -278,7 +275,6 @@ CChangesPDFDocumentAnnotsContent.prototype.Redo = function()
|
||||
{
|
||||
let oItem = this.Items[nIndex];
|
||||
oItem.AddToRedraw();
|
||||
oDocument.annots.splice(oDocument.annots.indexOf(oItem), 1);
|
||||
oPage.annots.splice(this.Pos, 1);
|
||||
|
||||
oItem.parentPage = null;
|
||||
@ -319,12 +315,6 @@ CChangesPDFDocumentAnnotsContent.prototype.private_InsertInArrayLoad = function(
|
||||
let nPos = oContentChanges.Check(AscCommon.contentchanges_Add, true !== this.UseArray ? this.Pos + i : this.PosArray[i]);
|
||||
if (nPos === false) continue;
|
||||
|
||||
// Ensure position is within bounds
|
||||
nPos = Math.min(nPos, oDocument.annots.length);
|
||||
|
||||
// Insert into document annots array
|
||||
oDocument.annots.splice(nPos, 0, oItem);
|
||||
|
||||
// Insert into viewer annots array
|
||||
let annotsArray = oPage.annots;
|
||||
nPos = Math.min(nPos, annotsArray.length);
|
||||
@ -363,10 +353,6 @@ CChangesPDFDocumentAnnotsContent.prototype.private_RemoveInArrayLoad = function(
|
||||
if (nPos === false) continue;
|
||||
|
||||
oItem.AddToRedraw();
|
||||
// Remove from document annots array
|
||||
let indexInAnnots = oDocument.annots.indexOf(oItem);
|
||||
if (indexInAnnots !== -1)
|
||||
oDocument.annots.splice(indexInAnnots, 1);
|
||||
|
||||
// Remove from viewer annots array
|
||||
let annotsArray = oPage.annots;
|
||||
@ -453,7 +439,6 @@ CChangesPDFDocumentFieldsContent.prototype.Undo = function()
|
||||
for (let nIndex = 0, nCount = this.Items.length; nIndex < nCount; ++nIndex) {
|
||||
let oItem = this.Items[nIndex];
|
||||
oItem.AddToRedraw();
|
||||
oDocument.widgets.splice(oDocument.widgets.indexOf(oItem), 1);
|
||||
oPage.fields.splice(this.Pos, 1);
|
||||
|
||||
oItem.parentPage = null;
|
||||
@ -469,7 +454,6 @@ CChangesPDFDocumentFieldsContent.prototype.Undo = function()
|
||||
let oItem = this.Items[nIndex];
|
||||
oItem.AddToRedraw();
|
||||
oPage.fields.splice(this.Pos, 0, oItem);
|
||||
oDocument.widgets.push(oItem);
|
||||
|
||||
oItem.parentPage = oPage;
|
||||
oItem._page = oPage.GetIndex();
|
||||
@ -492,7 +476,6 @@ CChangesPDFDocumentFieldsContent.prototype.Redo = function()
|
||||
{
|
||||
let oItem = this.Items[nIndex];
|
||||
oItem.AddToRedraw();
|
||||
oDocument.widgets.push(oItem);
|
||||
oPage.fields.splice(this.Pos, 0, oItem);
|
||||
|
||||
oItem.parentPage = oPage;
|
||||
@ -508,7 +491,6 @@ CChangesPDFDocumentFieldsContent.prototype.Redo = function()
|
||||
{
|
||||
let oItem = this.Items[nIndex];
|
||||
oItem.AddToRedraw();
|
||||
oDocument.widgets.splice(oDocument.widgets.indexOf(oItem), 1);
|
||||
oPage.fields.splice(this.Pos, 1);
|
||||
|
||||
oItem.parentPage = null;
|
||||
@ -544,10 +526,6 @@ CChangesPDFDocumentFieldsContent.prototype.private_InsertInArrayLoad = function(
|
||||
let nPos = oContentChanges.Check(AscCommon.contentchanges_Add, true !== this.UseArray ? this.Pos + i : this.PosArray[i]);
|
||||
if (nPos === false) continue;
|
||||
|
||||
// Insert into document widgets array
|
||||
nPos = Math.min(nPos, oDocument.widgets.length);
|
||||
oDocument.widgets.splice(nPos, 0, oItem);
|
||||
|
||||
// Insert into viewer fields array
|
||||
let fieldsArray = oPage.fields;
|
||||
nPos = Math.min(nPos, fieldsArray.length);
|
||||
@ -580,11 +558,6 @@ CChangesPDFDocumentFieldsContent.prototype.private_RemoveInArrayLoad = function(
|
||||
|
||||
oItem.AddToRedraw();
|
||||
|
||||
// Remove from document widgets array
|
||||
let indexInWidgets = oDocument.widgets.indexOf(oItem);
|
||||
if (indexInWidgets !== -1)
|
||||
oDocument.widgets.splice(indexInWidgets, 1);
|
||||
|
||||
// Remove from viewer fields array
|
||||
let fieldsArray = oPage.fields;
|
||||
let indexInFields = fieldsArray.indexOf(oItem);
|
||||
@ -664,7 +637,6 @@ CChangesPDFDocumentDrawingsContent.prototype.Undo = function()
|
||||
{
|
||||
let oItem = this.Items[nIndex];
|
||||
oItem.AddToRedraw();
|
||||
oDocument.drawings.splice(oDocument.drawings.indexOf(oItem), 1);
|
||||
oPage.drawings.splice(this.Pos, 1);
|
||||
|
||||
oItem.parent = oPage;
|
||||
@ -679,7 +651,6 @@ CChangesPDFDocumentDrawingsContent.prototype.Undo = function()
|
||||
{
|
||||
let oItem = this.Items[nIndex];
|
||||
oItem.AddToRedraw();
|
||||
oDocument.drawings.push(oItem);
|
||||
oPage.drawings.splice(this.Pos, 0, oItem);
|
||||
|
||||
oItem.parent = oPage;
|
||||
@ -706,7 +677,6 @@ CChangesPDFDocumentDrawingsContent.prototype.Redo = function()
|
||||
let oItem = this.Items[nIndex];
|
||||
|
||||
oItem.AddToRedraw();
|
||||
oDocument.drawings.push(oItem);
|
||||
oPage.drawings.splice(this.Pos, 0, oItem);
|
||||
|
||||
oItem.parent = oPage;
|
||||
@ -722,7 +692,6 @@ CChangesPDFDocumentDrawingsContent.prototype.Redo = function()
|
||||
let oItem = this.Items[nIndex];
|
||||
|
||||
oItem.AddToRedraw();
|
||||
oDocument.drawings.splice(oDocument.drawings.indexOf(oItem), 1);
|
||||
oPage.drawings.splice(this.Pos, 1);
|
||||
|
||||
oItem.parent = null;
|
||||
@ -761,12 +730,6 @@ CChangesPDFDocumentDrawingsContent.prototype.private_InsertInArrayLoad = functio
|
||||
let nPos = oContentChanges.Check(AscCommon.contentchanges_Add, true !== this.UseArray ? this.Pos + i : this.PosArray[i]);
|
||||
if (nPos === false) continue;
|
||||
|
||||
// Ensure position is within bounds
|
||||
nPos = Math.min(nPos, oDocument.drawings.length);
|
||||
|
||||
// Insert into document drawings array
|
||||
oDocument.drawings.splice(nPos, 0, oItem);
|
||||
|
||||
// Insert into viewer drawings array
|
||||
let drawingsArray = oPage.drawings;
|
||||
nPos = Math.min(nPos, drawingsArray.length);
|
||||
@ -800,10 +763,6 @@ CChangesPDFDocumentDrawingsContent.prototype.private_RemoveInArrayLoad = functio
|
||||
if (nPos === false) continue;
|
||||
|
||||
oItem.AddToRedraw();
|
||||
// Remove from document drawings array
|
||||
let indexInDrawings = oDocument.drawings.indexOf(oItem);
|
||||
if (indexInDrawings !== -1)
|
||||
oDocument.drawings.splice(indexInDrawings, 1);
|
||||
|
||||
// Remove from viewer drawings array
|
||||
let drawingsArray = oPage.drawings;
|
||||
|
||||
@ -7264,6 +7264,10 @@ CDocumentContent.prototype.Internal_GetContentPosByXY = function(X, Y, PageNum)
|
||||
if (!this.IsRecalculated())
|
||||
return;
|
||||
|
||||
let point = this.TransformPoint(X, Y);
|
||||
X = point.x;
|
||||
Y = point.y;
|
||||
|
||||
if (undefined === PageNum || null === PageNum)
|
||||
PageNum = this.CurPage;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user