mirror of
https://github.com/ONLYOFFICE/sdkjs.git
synced 2026-02-10 18:15:19 +08:00
Merge branch 'release/v9.2.0' into fix/data-binding
This commit is contained in:
@ -7620,10 +7620,6 @@ var CPresentation = CPresentation || function(){};
|
||||
|
||||
annot.AddToRedraw();
|
||||
|
||||
if (!isOrigPage) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!oMemory) {
|
||||
oMemory = new AscCommon.CMemory(true);
|
||||
oMemory.Init(24);
|
||||
@ -7654,14 +7650,16 @@ var CPresentation = CPresentation || function(){};
|
||||
if (aQuadsFlat.length != 0) {
|
||||
let oRender = new Uint8Array(oMemory.data.buffer, 0, oMemory.GetCurPosition());
|
||||
|
||||
// Apply redact to the page
|
||||
oNativeFile["RedactPage"](
|
||||
nOrigPageIdx,
|
||||
aQuadsFlat,
|
||||
oRender
|
||||
);
|
||||
if (isOrigPage) {
|
||||
// Apply redact to the page
|
||||
oNativeFile["RedactPage"](
|
||||
nOrigPageIdx,
|
||||
aQuadsFlat,
|
||||
oRender
|
||||
);
|
||||
}
|
||||
|
||||
this.SetRedactData(sRedactId, pageIdx, aQuadsFlat, oRender);
|
||||
this.SetRedactData(sRedactId, oPageInfo.GetId(), aQuadsFlat, oRender);
|
||||
}
|
||||
}
|
||||
|
||||
@ -7686,7 +7684,7 @@ var CPresentation = CPresentation || function(){};
|
||||
}, AscDFH.historydescription_Pdf_Apply_Redact, this);
|
||||
};
|
||||
|
||||
CPDFDoc.prototype.SetRedactData = function(sRedactId, nPage, aQuadsFlat, oRenderMemory) {
|
||||
CPDFDoc.prototype.SetRedactData = function(sRedactId, sPageId, aQuadsFlat, oRenderMemory) {
|
||||
let aUint8Array = oRenderMemory;
|
||||
|
||||
const BINARY_PART_HISTORY_LIMIT = 1048576;
|
||||
@ -7703,10 +7701,10 @@ var CPresentation = CPresentation || function(){};
|
||||
AscCommon.History.Add(new CChangesPDFDocumentPartRedact(this, [], binaryParts[i]));
|
||||
}
|
||||
|
||||
AscCommon.History.Add(new CChangesPDFDocumentEndRedact(this, sRedactId, nPage, aQuadsFlat));
|
||||
AscCommon.History.Add(new CChangesPDFDocumentEndRedact(this, sRedactId, sPageId, aQuadsFlat));
|
||||
|
||||
this.appliedRedactsData.push({
|
||||
page: nPage,
|
||||
pageId: sPageId,
|
||||
quads: aQuadsFlat,
|
||||
redactId: sRedactId,
|
||||
binary: aUint8Array
|
||||
@ -8192,6 +8190,11 @@ var CPresentation = CPresentation || function(){};
|
||||
CPDFDoc.prototype.GetPageInfo = function(nPage) {
|
||||
return this.Viewer.pagesInfo.pages[nPage];
|
||||
};
|
||||
CPDFDoc.prototype.GetPageInfoById = function(sId) {
|
||||
return this.Viewer.pagesInfo.pages.find(function(pageInfo) {
|
||||
return pageInfo.GetId() == sId;
|
||||
});
|
||||
};
|
||||
CPDFDoc.prototype.GetThumbnails = function() {
|
||||
return this.Viewer.thumbnails;
|
||||
};
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -1229,6 +1229,10 @@ void main() {\n\
|
||||
CFile.prototype.drawSelection = function(pageIndex, overlay, x, y)
|
||||
{
|
||||
if (Asc.editor.isRedactTool && this.Selection.startPoint && this.Selection.endPoint) {
|
||||
if (pageIndex < this.Selection.startPoint.page || pageIndex > this.Selection.endPoint.page) {
|
||||
return;
|
||||
}
|
||||
|
||||
let width = AscCommon.AscBrowser.convertToRetinaValue(this.viewer.drawingPages[pageIndex].W, true) >> 0;
|
||||
let height = AscCommon.AscBrowser.convertToRetinaValue(this.viewer.drawingPages[pageIndex].H, true) >> 0;
|
||||
|
||||
|
||||
@ -1441,11 +1441,11 @@ CChangesPDFDocumentPartRedact.prototype.ReadFromBinary = function(Reader) {
|
||||
* @constructor
|
||||
* @extends {AscDFH.CChangesBaseProperty}
|
||||
*/
|
||||
function CChangesPDFDocumentEndRedact(Class, sRedactId, nPage, aQuadsFlat)
|
||||
function CChangesPDFDocumentEndRedact(Class, sRedactId, sPageId, aQuadsFlat)
|
||||
{
|
||||
AscDFH.CChangesBaseProperty.call(this, Class, undefined, undefined);
|
||||
this.RedactId = sRedactId;
|
||||
this.Page = nPage;
|
||||
this.PageId = sPageId;
|
||||
this.QuadsFlat = aQuadsFlat;
|
||||
}
|
||||
CChangesPDFDocumentEndRedact.prototype = Object.create(AscDFH.CChangesBaseProperty.prototype);
|
||||
@ -1458,14 +1458,15 @@ CChangesPDFDocumentEndRedact.prototype.Undo = function() {
|
||||
// clear united binary
|
||||
delete oDoc.unitedBinary;
|
||||
|
||||
let oRedactData = oDoc.appliedRedactsData.pop();
|
||||
oDoc.appliedRedactsData.pop();
|
||||
oFile.nativeFile["UndoRedact"]();
|
||||
|
||||
let oPageInfo = oDoc.GetPageInfo(this.Page);
|
||||
let oPageInfo = oDoc.GetPageInfoById(this.PageId);
|
||||
let nIndex = oPageInfo.GetIndex();
|
||||
let nOriginIndex = oPageInfo.GetOriginIndex();
|
||||
|
||||
oFile.pages[this.Page].text = oFile.getText(nOriginIndex);
|
||||
oDoc.Viewer.onUpdatePages([oRedactData.page]);
|
||||
oFile.pages[nIndex].text = oFile.getText(nOriginIndex);
|
||||
oDoc.Viewer.onUpdatePages([nIndex]);
|
||||
};
|
||||
CChangesPDFDocumentEndRedact.prototype.Redo = function()
|
||||
{
|
||||
@ -1494,13 +1495,14 @@ CChangesPDFDocumentEndRedact.prototype.Redo = function()
|
||||
|
||||
delete oDoc.partsOfBinaryData;
|
||||
|
||||
let oPageInfo = oDoc.GetPageInfo(this.Page);
|
||||
let oPageInfo = oDoc.GetPageInfoById(this.PageId);
|
||||
let nIndex = oPageInfo.GetIndex();
|
||||
let nOriginIndex = oPageInfo.GetOriginIndex();
|
||||
|
||||
oFile.nativeFile["RedactPage"](nOriginIndex, this.QuadsFlat, oDoc.unitedBinary);
|
||||
|
||||
oDoc.appliedRedactsData.push({
|
||||
page: this.Page,
|
||||
pageId: this.PageId,
|
||||
quads: this.QuadsFlat,
|
||||
redactId: this.RedactId,
|
||||
binary: oDoc.unitedBinary
|
||||
@ -1513,8 +1515,8 @@ CChangesPDFDocumentEndRedact.prototype.Redo = function()
|
||||
AscCommon.g_oIdCounter.m_nPdfRedactCounter = nRedactIdx;
|
||||
}
|
||||
|
||||
oFile.pages[this.Page].text = oFile.getText(nOriginIndex);
|
||||
oDoc.Viewer.onUpdatePages([this.Page]);
|
||||
oFile.pages[nIndex].text = oFile.getText(nOriginIndex);
|
||||
oDoc.Viewer.onUpdatePages([nIndex]);
|
||||
};
|
||||
CChangesPDFDocumentEndRedact.prototype.WriteToBinary = function(Writer)
|
||||
{
|
||||
@ -1523,7 +1525,7 @@ CChangesPDFDocumentEndRedact.prototype.WriteToBinary = function(Writer)
|
||||
if (undefined === this.RedactId)
|
||||
nFlags |= 1;
|
||||
|
||||
if (undefined === this.Page)
|
||||
if (undefined === this.PageId)
|
||||
nFlags |= 2;
|
||||
|
||||
if (undefined === this.QuadsFlat)
|
||||
@ -1534,8 +1536,8 @@ CChangesPDFDocumentEndRedact.prototype.WriteToBinary = function(Writer)
|
||||
if (undefined !== this.RedactId)
|
||||
Writer.WriteString2(this.RedactId);
|
||||
|
||||
if (undefined !== this.Page)
|
||||
Writer.WriteLong(this.Page);
|
||||
if (undefined !== this.PageId)
|
||||
Writer.WriteString2(this.PageId);
|
||||
|
||||
if (undefined !== this.QuadsFlat) {
|
||||
// write points array
|
||||
@ -1557,9 +1559,9 @@ CChangesPDFDocumentEndRedact.prototype.ReadFromBinary = function(Reader)
|
||||
this.RedactId = Reader.GetString2();
|
||||
|
||||
if (nFlags & 2)
|
||||
this.Page = undefined;
|
||||
this.PageId = undefined;
|
||||
else
|
||||
this.Page = Reader.GetLong();
|
||||
this.PageId = Reader.GetString2();
|
||||
|
||||
if (nFlags & 4)
|
||||
this.QuadsFlat = undefined;
|
||||
@ -1571,5 +1573,5 @@ CChangesPDFDocumentEndRedact.prototype.ReadFromBinary = function(Reader)
|
||||
}
|
||||
};
|
||||
CChangesPDFDocumentEndRedact.prototype.CreateReverseChange = function() {
|
||||
return new this.constructor(this.Class, this.RedactId, this.Page, this.QuadsFlat);
|
||||
return new this.constructor(this.Class, this.RedactId, this.PageId, this.QuadsFlat);
|
||||
};
|
||||
|
||||
@ -4680,9 +4680,9 @@
|
||||
let nStartPos = oMemory.GetCurPosition();
|
||||
oMemory.Skip(4);
|
||||
|
||||
let nPage = oPageInfo.GetIndex();
|
||||
let sPageId = oPageInfo.GetId();
|
||||
let aPageRedactsData = oDoc.appliedRedactsData.filter(function(data) {
|
||||
return nPage == data.page;
|
||||
return sPageId == data.pageId;
|
||||
});
|
||||
|
||||
oMemory.WriteLong(aPageRedactsData.length);
|
||||
@ -5019,9 +5019,9 @@
|
||||
let nStartPos = oMemory.GetCurPosition();
|
||||
oMemory.Skip(4);
|
||||
|
||||
let nPage = oPageInfo.GetIndex();
|
||||
let sPageId = oPageInfo.GetId();
|
||||
let aPageRedactsData = oDoc.appliedRedactsData.filter(function(data) {
|
||||
return nPage == data.page;
|
||||
return sPageId == data.pageId;
|
||||
});
|
||||
|
||||
oMemory.WriteLong(aPageRedactsData.length);
|
||||
|
||||
@ -1282,11 +1282,41 @@ Paragraph.prototype.private_RecalculateLineMetrics = function(CurLine, CurPa
|
||||
// текста, на котором закончилась данная строка.
|
||||
if ( true === PRS.EmptyLine || (PRS.LineAscent < 0.001 && PRS.LineDescent < 0.001) || (true === PRS.End && true !== PRS.TextOnLine))
|
||||
{
|
||||
var LastItem = (true === PRS.End ? this.Content[this.Content.length - 1] : this.Content[this.Lines[CurLine].Ranges[this.Lines[CurLine].Ranges.length - 1].EndPos]);
|
||||
|
||||
if (true === PRS.End)
|
||||
let useParaEnd = true;
|
||||
if (true !== PRS.End)
|
||||
{
|
||||
let lastRange = this.Lines[CurLine].Ranges.length - 1;
|
||||
let lastItem = this.Content[this.Lines[CurLine].Ranges[lastRange].EndPos];
|
||||
let lastRun = lastItem.Get_LastRunInRange(CurLine, lastRange);
|
||||
if (lastRun && lastRun instanceof AscWord.CRun)
|
||||
{
|
||||
let metrics = lastRun.getTextMetrics(true);
|
||||
|
||||
let textDescent = metrics.Descent;
|
||||
let textAscent = metrics.Ascent + metrics.LineGap;
|
||||
let textAscent2 = metrics.Ascent;
|
||||
|
||||
if (PRS.LineTextAscent < textAscent)
|
||||
PRS.LineTextAscent = textAscent;
|
||||
|
||||
if (PRS.LineTextAscent2 < textAscent2)
|
||||
PRS.LineTextAscent2 = textAscent2;
|
||||
|
||||
if (PRS.LineTextDescent < textDescent)
|
||||
PRS.LineTextDescent = textDescent;
|
||||
|
||||
if (PRS.LineAscent < textAscent)
|
||||
PRS.LineAscent = textAscent;
|
||||
|
||||
if (PRS.LineDescent < textDescent)
|
||||
PRS.LineDescent = textDescent;
|
||||
|
||||
useParaEnd = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (useParaEnd || (PRS.LineAscent < 0.001 && PRS.LineDescent < 0.001))
|
||||
{
|
||||
// TODO: Как только переделаем para_End переделать тут
|
||||
let oTextPr = this.GetParaEndCompiledPr();
|
||||
let oMetrics = oTextPr.GetTextMetrics(oTextPr.CS || oTextPr.RTL ? AscWord.fontslot_CS : AscWord.fontslot_ASCII, this.GetTheme());
|
||||
|
||||
@ -1304,33 +1334,6 @@ Paragraph.prototype.private_RecalculateLineMetrics = function(CurLine, CurPa
|
||||
if (PRS.LineDescent < EndTextDescent)
|
||||
PRS.LineDescent = EndTextDescent;
|
||||
}
|
||||
else if (undefined !== LastItem)
|
||||
{
|
||||
let lastRun = LastItem.Get_LastRunInRange(PRS.Line, PRS.Range);
|
||||
if (lastRun && lastRun instanceof AscWord.CRun)
|
||||
{
|
||||
let metrics = lastRun.getTextMetrics();
|
||||
|
||||
let textDescent = metrics.Descent;
|
||||
let textAscent = metrics.Ascent + metrics.LineGap;
|
||||
let textAscent2 = metrics.Ascent;
|
||||
|
||||
if (PRS.LineTextAscent < textAscent)
|
||||
PRS.LineTextAscent = textAscent;
|
||||
|
||||
if (PRS.LineTextAscent2 < textAscent2)
|
||||
PRS.LineTextAscent2 = textAscent2;
|
||||
|
||||
if (PRS.LineTextDescent < textDescent)
|
||||
PRS.LineTextDescent = textDescent;
|
||||
|
||||
if (PRS.LineAscent < textAscent)
|
||||
PRS.LineAscent = textAscent;
|
||||
|
||||
if (PRS.LineDescent < textDescent)
|
||||
PRS.LineDescent = textDescent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Рассчитаем метрики строки
|
||||
|
||||
@ -2224,7 +2224,7 @@ ParaRun.prototype.Get_ParaPosByContentPos = function(ContentPos, Depth)
|
||||
}
|
||||
}
|
||||
|
||||
return new CParaPos((LinesCount === 1 ? this.protected_GetRangesCount(0) - 1 + this.StartRange : this.protected_GetRangesCount(0) - 1), LinesCount - 1 + this.StartLine, 0, 0);
|
||||
return new CParaPos((LinesCount === 1 ? this.protected_GetRangesCount(0) - 1 + this.StartRange : this.protected_GetRangesCount(LinesCount - 1) - 1), LinesCount - 1 + this.StartLine, 0, 0);
|
||||
};
|
||||
|
||||
ParaRun.prototype.recalculateCursorPosition = function(positionCalculator, isCurrent)
|
||||
@ -3437,7 +3437,7 @@ ParaRun.prototype.Recalculate_MeasureContent = function()
|
||||
this.RecalcInfo.Recalc = true;
|
||||
this.RecalcInfo.ResetMeasure();
|
||||
};
|
||||
ParaRun.prototype.getTextMetrics = function()
|
||||
ParaRun.prototype.getTextMetrics = function(isForceEmpty)
|
||||
{
|
||||
let textPr = this.Get_CompiledPr(false);
|
||||
if (this.IsUseAscFont(textPr))
|
||||
@ -3453,7 +3453,7 @@ ParaRun.prototype.getTextMetrics = function()
|
||||
fontSlot |= this.Content[nPos].GetFontSlot(textPr);
|
||||
}
|
||||
|
||||
if (AscWord.fontslot_Unknown === fontSlot)
|
||||
if ((AscWord.fontslot_Unknown === fontSlot) || (AscWord.fontslot_None === fontSlot && isForceEmpty))
|
||||
fontSlot = textPr.CS || textPr.RTL ? AscWord.fontslot_CS : AscWord.fontslot_ASCII;
|
||||
|
||||
return textPr.GetTextMetrics(fontSlot, this.Paragraph.GetTheme());
|
||||
|
||||
@ -112,7 +112,7 @@
|
||||
{
|
||||
let inverted = transform.CreateDublicate().Invert();
|
||||
let _x = inverted.TransformPointX(x, y);
|
||||
let _y = inverted.TransformPointX(x, y);
|
||||
let _y = inverted.TransformPointY(x, y);
|
||||
x = _x;
|
||||
y = _y;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user