Merge pull request #1810 from ONLYOFFICE/fix/merge-hotfix
Fix/merge hotfix
This commit is contained in:
commit
df94b96b72
|
@ -90,6 +90,7 @@ define([
|
|||
|
||||
function CThumbnailLoader() {
|
||||
this.supportBinaryFormat = !(Common.Controllers.Desktop.isActive() && !Common.Controllers.Desktop.isFeatureAvailable('isSupportBinaryFontsSprite'));
|
||||
// наш формат - альфамаска с сжатием типа rle для полностью прозрачных пикселов
|
||||
|
||||
this.image = null;
|
||||
this.binaryFormat = null;
|
||||
|
@ -98,6 +99,7 @@ define([
|
|||
this.height = 0;
|
||||
this.heightOne = 0;
|
||||
this.count = 0;
|
||||
this.offsets = null;
|
||||
|
||||
this.load = function(url, callback) {
|
||||
if (!callback)
|
||||
|
@ -123,7 +125,7 @@ define([
|
|||
|
||||
xhr.onload = function() {
|
||||
// TODO: check errors
|
||||
me.binaryFormat = this.response;
|
||||
me.binaryFormat = new Uint8Array(this.response);
|
||||
callback();
|
||||
};
|
||||
|
||||
|
@ -134,21 +136,30 @@ define([
|
|||
this.openBinary = function(arrayBuffer) {
|
||||
//var t1 = performance.now();
|
||||
|
||||
var binaryAlpha = new Uint8Array(arrayBuffer);
|
||||
var binaryAlpha = this.binaryFormat;
|
||||
this.width = (binaryAlpha[0] << 24) | (binaryAlpha[1] << 16) | (binaryAlpha[2] << 8) | (binaryAlpha[3] << 0);
|
||||
this.heightOne = (binaryAlpha[4] << 24) | (binaryAlpha[5] << 16) | (binaryAlpha[6] << 8) | (binaryAlpha[7] << 0);
|
||||
this.count = (binaryAlpha[8] << 24) | (binaryAlpha[9] << 16) | (binaryAlpha[10] << 8) | (binaryAlpha[11] << 0);
|
||||
this.height = this.count * this.heightOne;
|
||||
|
||||
this.data = new Uint8ClampedArray(4 * this.width * this.height);
|
||||
var MAX_MEMORY_SIZE = 50000000;
|
||||
var memorySize = 4 * this.width * this.height;
|
||||
var isOffsets = (memorySize > MAX_MEMORY_SIZE) ? true : false;
|
||||
|
||||
if (!isOffsets)
|
||||
this.data = new Uint8ClampedArray(memorySize);
|
||||
else
|
||||
this.offsets = new Array(this.count);
|
||||
|
||||
var binaryIndex = 12;
|
||||
var binaryLen = binaryAlpha.length;
|
||||
var imagePixels = this.data;
|
||||
var index = 0;
|
||||
|
||||
var len0 = 0;
|
||||
var tmpValue = 0;
|
||||
|
||||
if (!isOffsets) {
|
||||
var imagePixels = this.data;
|
||||
while (binaryIndex < binaryLen) {
|
||||
tmpValue = binaryAlpha[binaryIndex++];
|
||||
if (0 == tmpValue) {
|
||||
|
@ -165,6 +176,33 @@ define([
|
|||
index += 4;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var module = this.width * this.heightOne;
|
||||
var moduleCur = module - 1;
|
||||
while (binaryIndex < binaryLen) {
|
||||
tmpValue = binaryAlpha[binaryIndex++];
|
||||
if (0 == tmpValue) {
|
||||
len0 = binaryAlpha[binaryIndex++];
|
||||
while (len0 > 0) {
|
||||
len0--;
|
||||
moduleCur++;
|
||||
if (moduleCur === module) {
|
||||
this.offsets[index++] = { pos : binaryIndex, len : len0 + 1 };
|
||||
moduleCur = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
moduleCur++;
|
||||
if (moduleCur === module) {
|
||||
this.offsets[index++] = { pos : binaryIndex - 1, len : -1 };
|
||||
moduleCur = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.offsets)
|
||||
delete this.binaryFormat;
|
||||
|
||||
//var t2 = performance.now();
|
||||
//console.log(t2 - t1);
|
||||
|
@ -185,14 +223,53 @@ define([
|
|||
}
|
||||
|
||||
if (this.supportBinaryFormat) {
|
||||
if (!this.data) {
|
||||
if (!this.data && !this.offsets) {
|
||||
this.openBinary(this.binaryFormat);
|
||||
delete this.binaryFormat;
|
||||
}
|
||||
|
||||
var dataTmp = ctx.createImageData(this.width, this.heightOne);
|
||||
var sizeImage = 4 * this.width * this.heightOne;
|
||||
|
||||
if (!this.offsets) {
|
||||
dataTmp.data.set(new Uint8ClampedArray(this.data.buffer, index * sizeImage, sizeImage));
|
||||
} else {
|
||||
var binaryAlpha = this.binaryFormat;
|
||||
var binaryIndex = this.offsets[index].pos;
|
||||
var alphaChannel = 0;
|
||||
var pixelsCount = this.width * this.heightOne;
|
||||
var tmpValue = 0, len0 = 0;
|
||||
var imagePixels = dataTmp.data;
|
||||
if (-1 != this.offsets[index].len) {
|
||||
/*
|
||||
// this values is already 0.
|
||||
for (var i = 0; i < this.offsets[index].len; i++) {
|
||||
pixels[alphaChannel] = 0;
|
||||
alphaChannel += 4;
|
||||
}
|
||||
*/
|
||||
alphaChannel += 4 * this.offsets[index].len;
|
||||
}
|
||||
while (pixelsCount > 0) {
|
||||
tmpValue = binaryAlpha[binaryIndex++];
|
||||
if (0 == tmpValue) {
|
||||
len0 = binaryAlpha[binaryIndex++];
|
||||
if (len0 > pixelsCount)
|
||||
len0 = pixelsCount;
|
||||
while (len0 > 0) {
|
||||
len0--;
|
||||
imagePixels[alphaChannel] = imagePixels[alphaChannel + 1] = imagePixels[alphaChannel + 2] = 255;
|
||||
imagePixels[alphaChannel + 3] = 0; // this value is already 0.
|
||||
alphaChannel += 4;
|
||||
pixelsCount--;
|
||||
}
|
||||
} else {
|
||||
imagePixels[alphaChannel] = imagePixels[alphaChannel + 1] = imagePixels[alphaChannel + 2] = 255 - tmpValue;
|
||||
imagePixels[alphaChannel + 3] = tmpValue;
|
||||
alphaChannel += 4;
|
||||
pixelsCount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
ctx.putImageData(dataTmp, 0, 0);
|
||||
} else {
|
||||
ctx.clearRect(0, 0, this.width, this.heightOne);
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
|
||||
class CThumbnailLoader {
|
||||
constructor() {
|
||||
this.image = null;
|
||||
this.binaryFormat = null;
|
||||
this.data = null;
|
||||
this.width = 0;
|
||||
this.heightOne = 0;
|
||||
this.offsets = null;
|
||||
}
|
||||
|
||||
load(url, callback) {
|
||||
|
@ -21,31 +23,40 @@ class CThumbnailLoader {
|
|||
|
||||
xhr.onload = e => {
|
||||
// TODO: check errors
|
||||
this.binaryFormat = e.target.response;
|
||||
this.binaryFormat = new Uint8Array(e.target.response);
|
||||
callback();
|
||||
};
|
||||
|
||||
xhr.send(null);
|
||||
}
|
||||
|
||||
_openBinary(arrayBuffer) {
|
||||
openBinary(arrayBuffer) {
|
||||
//var t1 = performance.now();
|
||||
|
||||
const binaryAlpha = new Uint8Array(arrayBuffer);
|
||||
const binaryAlpha = this.binaryFormat;
|
||||
this.width = (binaryAlpha[0] << 24) | (binaryAlpha[1] << 16) | (binaryAlpha[2] << 8) | (binaryAlpha[3] << 0);
|
||||
this.heightOne = (binaryAlpha[4] << 24) | (binaryAlpha[5] << 16) | (binaryAlpha[6] << 8) | (binaryAlpha[7] << 0);
|
||||
const count = (binaryAlpha[8] << 24) | (binaryAlpha[9] << 16) | (binaryAlpha[10] << 8) | (binaryAlpha[11] << 0);
|
||||
const height = count * this.heightOne;
|
||||
|
||||
this.data = new Uint8ClampedArray(4 * this.width * height);
|
||||
const MAX_MEMORY_SIZE = 100000000;
|
||||
const memorySize = 4 * this.width * height;
|
||||
const isOffsets = memorySize > MAX_MEMORY_SIZE;
|
||||
|
||||
if (!isOffsets)
|
||||
this.data = new Uint8ClampedArray(memorySize);
|
||||
else this.offsets = new Array(count);
|
||||
|
||||
var binaryIndex = 12;
|
||||
var imagePixels = this.data;
|
||||
var binaryLen = binaryAlpha.length;
|
||||
var index = 0;
|
||||
|
||||
var len0 = 0;
|
||||
var tmpValue = 0;
|
||||
while (binaryIndex < binaryAlpha.length) {
|
||||
|
||||
if (!isOffsets) {
|
||||
var imagePixels = this.data;
|
||||
while (binaryIndex < binaryLen) {
|
||||
tmpValue = binaryAlpha[binaryIndex++];
|
||||
if (0 == tmpValue) {
|
||||
len0 = binaryAlpha[binaryIndex++];
|
||||
|
@ -61,13 +72,39 @@ class CThumbnailLoader {
|
|||
index += 4;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var module = this.width * this.heightOne;
|
||||
var moduleCur = module - 1;
|
||||
while (binaryIndex < binaryLen) {
|
||||
tmpValue = binaryAlpha[binaryIndex++];
|
||||
if (0 == tmpValue) {
|
||||
len0 = binaryAlpha[binaryIndex++];
|
||||
while (len0 > 0) {
|
||||
len0--;
|
||||
moduleCur++;
|
||||
if (moduleCur === module) {
|
||||
this.offsets[index++] = { pos : binaryIndex, len : len0 + 1 };
|
||||
moduleCur = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
moduleCur++;
|
||||
if (moduleCur === module) {
|
||||
this.offsets[index++] = { pos : binaryIndex - 1, len : -1 };
|
||||
moduleCur = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !this.offsets )
|
||||
delete this.binaryFormat;
|
||||
|
||||
//var t2 = performance.now();
|
||||
//console.log(t2 - t1);
|
||||
};
|
||||
|
||||
getImage = function(index, canvas, ctx) {
|
||||
//var t1 = performance.now();
|
||||
if (!canvas) {
|
||||
canvas = document.createElement("canvas");
|
||||
canvas.width = this.width;
|
||||
|
@ -78,14 +115,53 @@ class CThumbnailLoader {
|
|||
ctx = canvas.getContext("2d");
|
||||
}
|
||||
|
||||
if (!this.data) {
|
||||
this._openBinary(this.binaryFormat);
|
||||
delete this.binaryFormat;
|
||||
if (!this.data && !this.offsets) {
|
||||
this.openBinary(this.binaryFormat);
|
||||
}
|
||||
|
||||
let dataTmp = ctx.createImageData(this.width, this.heightOne);
|
||||
const sizeImage = 4 * this.width * this.heightOne;
|
||||
|
||||
if (!this.offsets) {
|
||||
dataTmp.data.set(new Uint8ClampedArray(this.data.buffer, index * sizeImage, sizeImage));
|
||||
} else {
|
||||
const binaryAlpha = this.binaryFormat;
|
||||
var binaryIndex = this.offsets[index].pos;
|
||||
var alphaChannel = 0;
|
||||
var pixelsCount = this.width * this.heightOne;
|
||||
var tmpValue = 0, len0 = 0;
|
||||
let imagePixels = dataTmp.data;
|
||||
if (-1 != this.offsets[index].len) {
|
||||
/*
|
||||
// this values is already 0.
|
||||
for (var i = 0; i < this.offsets[index].len; i++) {
|
||||
pixels[alphaChannel] = 0;
|
||||
alphaChannel += 4;
|
||||
}
|
||||
*/
|
||||
alphaChannel += 4 * this.offsets[index].len;
|
||||
}
|
||||
while (pixelsCount > 0) {
|
||||
tmpValue = binaryAlpha[binaryIndex++];
|
||||
if (0 == tmpValue) {
|
||||
len0 = binaryAlpha[binaryIndex++];
|
||||
if (len0 > pixelsCount)
|
||||
len0 = pixelsCount;
|
||||
while (len0 > 0) {
|
||||
len0--;
|
||||
imagePixels[alphaChannel] = imagePixels[alphaChannel + 1] = imagePixels[alphaChannel + 2] = 255;
|
||||
imagePixels[alphaChannel + 3] = 0; // this value is already 0.
|
||||
alphaChannel += 4;
|
||||
pixelsCount--;
|
||||
}
|
||||
} else {
|
||||
imagePixels[alphaChannel] = imagePixels[alphaChannel + 1] = imagePixels[alphaChannel + 2] = 255 - tmpValue;
|
||||
imagePixels[alphaChannel + 3] = tmpValue;
|
||||
alphaChannel += 4;
|
||||
pixelsCount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
ctx.putImageData(dataTmp, 0, 0);
|
||||
|
||||
//var t2 = performance.now();
|
||||
|
|
|
@ -86,6 +86,7 @@ export class storeAppOptions {
|
|||
&& (!!(config.customization.goback.url) || config.customization.goback.requestClose && this.canRequestClose);
|
||||
this.canBack = this.canBackToFolder === true;
|
||||
this.canPlugins = false;
|
||||
this.canFeatureForms = !!Common.EditorApi.get().asc_isSupportFeature("forms");
|
||||
|
||||
AscCommon.UserInfoParser.setParser(true);
|
||||
AscCommon.UserInfoParser.setCurrentName(this.user.fullname);
|
||||
|
|
|
@ -133,6 +133,10 @@ export class storeTextSettings {
|
|||
this.spriteThumbs = new CThumbnailLoader();
|
||||
this.spriteThumbs.load(this.thumbs[this.thumbIdx].path, () => {
|
||||
this.spriteCols = Math.floor(this.spriteThumbs.width / (this.thumbs[this.thumbIdx].width)) || 1;
|
||||
|
||||
if (!this.spriteThumbs.data && !this.spriteThumbs.offsets) {
|
||||
this.spriteThumbs.openBinary(this.spriteThumbs.binaryFormat);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ const Download = props => {
|
|||
const _t = t("Settings", { returnObjects: true });
|
||||
const storeDocumentInfo = props.storeDocumentInfo;
|
||||
const dataDoc = storeDocumentInfo.dataDoc;
|
||||
const canFeatureForms = props.storeAppOptions.canFeatureForms;
|
||||
|
||||
return (
|
||||
<Page>
|
||||
|
@ -17,7 +18,7 @@ const Download = props => {
|
|||
<ListItem title="DOCX" onClick={() => props.onSaveFormat(Asc.c_oAscFileType.DOCX)}>
|
||||
<Icon slot="media" icon="icon-format-docx"></Icon>
|
||||
</ListItem>
|
||||
{dataDoc.fileType === 'docxf' || dataDoc.fileType === 'docx' ? [
|
||||
{canFeatureForms && (dataDoc.fileType === 'docxf' || dataDoc.fileType === 'docx') ? [
|
||||
<ListItem title="DOCXF" key="DOCXF" onClick={() => props.onSaveFormat(Asc.c_oAscFileType.DOCXF)}>
|
||||
<Icon slot="media" icon="icon-format-docxf"></Icon>
|
||||
</ListItem>,
|
||||
|
@ -58,4 +59,4 @@ const Download = props => {
|
|||
)
|
||||
}
|
||||
|
||||
export default inject('storeDocumentInfo')(observer(Download));
|
||||
export default inject('storeDocumentInfo', 'storeAppOptions')(observer(Download));
|
|
@ -137,6 +137,10 @@ export class storeTextSettings {
|
|||
this.spriteThumbs = new CThumbnailLoader();
|
||||
this.spriteThumbs.load(this.thumbs[this.thumbIdx].path, () => {
|
||||
this.spriteCols = Math.floor(this.spriteThumbs.width / (this.thumbs[this.thumbIdx].width)) || 1;
|
||||
|
||||
if (!this.spriteThumbs.data && !this.spriteThumbs.offsets) {
|
||||
this.spriteThumbs.openBinary(this.spriteThumbs.binaryFormat);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1427,7 +1427,7 @@ define([
|
|||
this.api.asc_registerCallback('asc_onDocumentModifiedChanged', _.bind(this.onDocumentModifiedChanged, this));
|
||||
|
||||
var printController = app.getController('Print');
|
||||
printController && this.api && printController.setApi(this.api);
|
||||
printController && this.api && printController.setApi(this.api).setMode(this.appOptions);
|
||||
} else if (this.appOptions.isEditOle)
|
||||
this.api.asc_registerCallback('asc_onSendThemeColors', _.bind(this.onSendThemeColors, this));
|
||||
|
||||
|
|
|
@ -119,12 +119,19 @@ define([
|
|||
this.printSettings.$previewBox.on(eventname, _.bind(this.onPreviewWheel, this));
|
||||
},
|
||||
|
||||
setMode: function (mode) {
|
||||
this.mode = mode;
|
||||
this.printSettings && this.printSettings.setMode(mode);
|
||||
},
|
||||
|
||||
setApi: function(o) {
|
||||
this.api = o;
|
||||
this.api.asc_registerCallback('asc_onSheetsChanged', _.bind(this.updateSheetsInfo, this));
|
||||
this.api.asc_registerCallback('asc_onPrintPreviewSheetChanged', _.bind(this.onApiChangePreviewSheet, this));
|
||||
this.api.asc_registerCallback('asc_onPrintPreviewPageChanged', _.bind(this.onApiChangePreviewPage, this));
|
||||
this.api.asc_registerCallback('asc_onPrintPreviewSheetDataChanged', _.bind(this.onApiPreviewSheetDataChanged, this));
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
updateSheetsInfo: function() {
|
||||
|
|
|
@ -2247,7 +2247,7 @@ SSE.Views.FileMenuPanels.RecentFiles = Common.UI.BaseView.extend({
|
|||
'<tr><td class="padding-small"><label class="header"><%= scope.txtGridlinesAndHeadings %></label></td></tr>',
|
||||
'<tr><td class="padding-small"><div id="print-chb-grid" style="width: 248px;"></div></td></tr>',
|
||||
'<tr><td class="padding-large"><div id="print-chb-rows" style="width: 248px;"></div></td></tr>',
|
||||
'<tr><td class="padding-large"><label class="link" id="print-header-footer-settings" data-hint="2" data-hint-direction="bottom" data-hint-offset="medium"><%= scope.txtHeaderFooterSettings %></label></td></tr>',
|
||||
'<tr class="header-settings"><td class="padding-large"><label class="link" id="print-header-footer-settings" data-hint="2" data-hint-direction="bottom" data-hint-offset="medium"><%= scope.txtHeaderFooterSettings %></label></td></tr>',
|
||||
//'<tr><td class="padding-large"><button type="button" class="btn btn-text-default" id="print-apply-all" style="width: 118px;" data-hint="2" data-hint-direction="bottom" data-hint-offset="medium"><%= scope.txtApplyToAllSheets %></button></td></tr>',
|
||||
'<tr class="fms-btn-apply"><td>',
|
||||
'<div class="footer justify">',
|
||||
|
@ -2578,8 +2578,11 @@ SSE.Views.FileMenuPanels.RecentFiles = Common.UI.BaseView.extend({
|
|||
|
||||
this.$el = $(node).html($markup);
|
||||
|
||||
if (!this.mode.isEdit) {
|
||||
$markup.find('.header-settings').hide();
|
||||
} else {
|
||||
this.$el.on('click', '#print-header-footer-settings', _.bind(this.openHeaderSettings, this));
|
||||
this.$headerSettings = $('#print-header-footer-settings');
|
||||
}
|
||||
|
||||
this.$previewBox = $('#print-preview-box');
|
||||
this.$previewEmpty = $('#print-preview-empty');
|
||||
|
|
|
@ -137,6 +137,10 @@ export class storeTextSettings {
|
|||
this.spriteThumbs = new CThumbnailLoader();
|
||||
this.spriteThumbs.load(this.thumbs[this.thumbIdx].path, () => {
|
||||
this.spriteCols = Math.floor(this.spriteThumbs.width / (this.thumbs[this.thumbIdx].width)) || 1;
|
||||
|
||||
if (!this.spriteThumbs.data && !this.spriteThumbs.offsets) {
|
||||
this.spriteThumbs.openBinary(this.spriteThumbs.binaryFormat);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue