From fe1e736ae4de790862221424e0d8c659aea0c322 Mon Sep 17 00:00:00 2001 From: Oleg Korshul Date: Fri, 27 May 2022 11:51:14 +0300 Subject: [PATCH 01/36] For bug 57315 --- .../main/lib/component/ComboBoxFonts.js | 117 +++++++++++++++--- 1 file changed, 97 insertions(+), 20 deletions(-) diff --git a/apps/common/main/lib/component/ComboBoxFonts.js b/apps/common/main/lib/component/ComboBoxFonts.js index 46fbea563..b20cee6b7 100644 --- a/apps/common/main/lib/component/ComboBoxFonts.js +++ b/apps/common/main/lib/component/ComboBoxFonts.js @@ -90,6 +90,7 @@ define([ function CThumbnailLoader() { this.supportBinaryFormat = (window['AscDesktopEditor'] && !window['AscDesktopEditor']['isSupportBinaryFontsSprite']) ? false : true; + // наш формат - альфамаска с сжатием типа rle для полностью прозрачных пикселов this.image = null; this.binaryFormat = null; @@ -97,7 +98,8 @@ define([ this.width = 0; this.height = 0; this.heightOne = 0; - this.count = 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(); }; @@ -135,38 +137,74 @@ define([ //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; - while (binaryIndex < binaryLen) { - tmpValue = binaryAlpha[binaryIndex++]; - if (0 == tmpValue) { - len0 = binaryAlpha[binaryIndex++]; - while (len0 > 0) { - len0--; - imagePixels[index] = imagePixels[index + 1] = imagePixels[index + 2] = 255; - imagePixels[index + 3] = 0; // this value is already 0. + + if (!isOffsets) { + var imagePixels = this.data; + while (binaryIndex < binaryLen) { + tmpValue = binaryAlpha[binaryIndex++]; + if (0 == tmpValue) { + len0 = binaryAlpha[binaryIndex++]; + while (len0 > 0) { + len0--; + imagePixels[index] = imagePixels[index + 1] = imagePixels[index + 2] = 255; + imagePixels[index + 3] = 0; // this value is already 0. + index += 4; + } + } else { + imagePixels[index] = imagePixels[index + 1] = imagePixels[index + 2] = 255 - tmpValue; + imagePixels[index + 3] = tmpValue; index += 4; } - } else { - imagePixels[index] = imagePixels[index + 1] = imagePixels[index + 2] = 255 - tmpValue; - imagePixels[index + 3] = tmpValue; - 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); }; @@ -186,14 +224,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; - dataTmp.data.set(new Uint8ClampedArray(this.data.buffer, index * sizeImage, sizeImage)); + + 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); From 98c2b08ec94b1d515506c65ee6378c1974ab77f7 Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Fri, 27 May 2022 20:36:24 +0300 Subject: [PATCH 02/36] [mobile] fix bug 57315 --- .../mobile/src/store/textSettings.js | 174 ++++++++++++------ .../mobile/src/store/textSettings.js | 165 +++++++++++------ .../mobile/src/store/textSettings.js | 165 ++++++++++++----- 3 files changed, 343 insertions(+), 161 deletions(-) diff --git a/apps/documenteditor/mobile/src/store/textSettings.js b/apps/documenteditor/mobile/src/store/textSettings.js index 156f40702..fd6df3bf0 100644 --- a/apps/documenteditor/mobile/src/store/textSettings.js +++ b/apps/documenteditor/mobile/src/store/textSettings.js @@ -130,84 +130,104 @@ export class storeTextSettings { loadSprite() { function CThumbnailLoader() { - this.supportBinaryFormat = (window['AscDesktopEditor'] && !window['AscDesktopEditor']['isSupportBinaryFontsSprite']) ? false : true; - this.image = null; this.binaryFormat = null; this.data = null; this.width = 0; - this.height = 0; this.heightOne = 0; - this.count = 0; + this.offsets = null; this.load = function(url, callback) { if (!callback) return; - if (!this.supportBinaryFormat) { - this.width = thumbs[thumbIdx].width; - this.heightOne = thumbs[thumbIdx].height; + var xhr = new XMLHttpRequest(); + xhr.open('GET', url + ".bin", true); + xhr.responseType = 'arraybuffer'; - this.image = new Image(); - this.image.onload = callback; - this.image.src = thumbs[thumbIdx].path; - } else { - var me = this; - var xhr = new XMLHttpRequest(); - xhr.open('GET', url + ".bin", true); - xhr.responseType = 'arraybuffer'; + if (xhr.overrideMimeType) + xhr.overrideMimeType('text/plain; charset=x-user-defined'); + else xhr.setRequestHeader('Accept-Charset', 'x-user-defined'); - if (xhr.overrideMimeType) - xhr.overrideMimeType('text/plain; charset=x-user-defined'); - else - xhr.setRequestHeader('Accept-Charset', 'x-user-defined'); + xhr.onload = e => { + // TODO: check errors + this.binaryFormat = new Uint8Array(e.target.response); + callback(); + }; - xhr.onload = function() { - // TODO: check errors - me.binaryFormat = this.response; - callback(); - }; - - xhr.send(null); - } + xhr.send(null); }; this.openBinary = function(arrayBuffer) { - //var t1 = performance.now(); - var 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); - this.count = (binaryAlpha[8] << 24) | (binaryAlpha[9] << 16) | (binaryAlpha[10] << 8) | (binaryAlpha[11] << 0); - this.height = this.count * this.heightOne; + 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 * this.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 binaryLen = binaryAlpha.length; - var imagePixels = this.data; var index = 0; var len0 = 0; var tmpValue = 0; - while (binaryIndex < binaryLen) { - tmpValue = binaryAlpha[binaryIndex++]; - if (0 == tmpValue) { - len0 = binaryAlpha[binaryIndex++]; - while (len0 > 0) { - len0--; - imagePixels[index] = imagePixels[index + 1] = imagePixels[index + 2] = 255; - imagePixels[index + 3] = 0; // this value is already 0. + + if (!isOffsets) { + var imagePixels = this.data; + while (binaryIndex < binaryLen) { + tmpValue = binaryAlpha[binaryIndex++]; + if (0 == tmpValue) { + len0 = binaryAlpha[binaryIndex++]; + while (len0 > 0) { + len0--; + imagePixels[index] = imagePixels[index + 1] = imagePixels[index + 2] = 255; + imagePixels[index + 3] = 0; // this value is already 0. + index += 4; + } + } else { + imagePixels[index] = imagePixels[index + 1] = imagePixels[index + 2] = 255 - tmpValue; + imagePixels[index + 3] = tmpValue; index += 4; } - } else { - imagePixels[index] = imagePixels[index + 1] = imagePixels[index + 2] = 255 - tmpValue; - imagePixels[index + 3] = tmpValue; - 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); }; @@ -226,21 +246,55 @@ export class storeTextSettings { ctx = canvas.getContext("2d"); } - if (this.supportBinaryFormat) { - if (!this.data) { - this.openBinary(this.binaryFormat); - delete this.binaryFormat; - } - - var dataTmp = ctx.createImageData(this.width, this.heightOne); - var sizeImage = 4 * this.width * this.heightOne; - dataTmp.data.set(new Uint8ClampedArray(this.data.buffer, index * sizeImage, sizeImage)); - ctx.putImageData(dataTmp, 0, 0); - } else { - ctx.clearRect(0, 0, this.width, this.heightOne); - ctx.drawImage(this.image, 0, -this.heightOne * index); + if (!this.data && !this.offsets) { + this.openBinary(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 { + 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(); //console.log(t2 - t1); @@ -251,6 +305,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); + } }); } diff --git a/apps/presentationeditor/mobile/src/store/textSettings.js b/apps/presentationeditor/mobile/src/store/textSettings.js index ccf03a07b..5f1b1857b 100644 --- a/apps/presentationeditor/mobile/src/store/textSettings.js +++ b/apps/presentationeditor/mobile/src/store/textSettings.js @@ -134,8 +134,6 @@ export class storeTextSettings { loadSprite() { function CThumbnailLoader() { - this.supportBinaryFormat = (window['AscDesktopEditor'] && !window['AscDesktopEditor']['isSupportBinaryFontsSprite']) ? false : true; - this.image = null; this.binaryFormat = null; this.data = null; @@ -143,37 +141,27 @@ export class storeTextSettings { this.height = 0; this.heightOne = 0; this.count = 0; + this.offsets = null; this.load = function(url, callback) { if (!callback) return; - if (!this.supportBinaryFormat) { - this.width = thumbs[thumbIdx].width; - this.heightOne = thumbs[thumbIdx].height; + var xhr = new XMLHttpRequest(); + xhr.open('GET', url + ".bin", true); + xhr.responseType = 'arraybuffer'; - this.image = new Image(); - this.image.onload = callback; - this.image.src = thumbs[thumbIdx].path; - } else { - var me = this; - var xhr = new XMLHttpRequest(); - xhr.open('GET', url + ".bin", true); - xhr.responseType = 'arraybuffer'; + if (xhr.overrideMimeType) + xhr.overrideMimeType('text/plain; charset=x-user-defined'); + else xhr.setRequestHeader('Accept-Charset', 'x-user-defined'); - if (xhr.overrideMimeType) - xhr.overrideMimeType('text/plain; charset=x-user-defined'); - else - xhr.setRequestHeader('Accept-Charset', 'x-user-defined'); + xhr.onload = e => { + // TODO: check errors + this.binaryFormat = new Uint8Array(e.target.response); + callback(); + }; - xhr.onload = function() { - // TODO: check errors - me.binaryFormat = this.response; - callback(); - }; - - xhr.send(null); - } + xhr.send(null); }; this.openBinary = function(arrayBuffer) { @@ -186,32 +174,67 @@ export class storeTextSettings { 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); + const MAX_MEMORY_SIZE = 100000000; + const memorySize = 4 * this.width * this.height; + const isOffsets = memorySize > MAX_MEMORY_SIZE; + + 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; - while (binaryIndex < binaryLen) { - tmpValue = binaryAlpha[binaryIndex++]; - if (0 == tmpValue) { - len0 = binaryAlpha[binaryIndex++]; - while (len0 > 0) { - len0--; - imagePixels[index] = imagePixels[index + 1] = imagePixels[index + 2] = 255; - imagePixels[index + 3] = 0; // this value is already 0. + + if (!isOffsets) { + var imagePixels = this.data; + while (binaryIndex < binaryLen) { + tmpValue = binaryAlpha[binaryIndex++]; + if (0 == tmpValue) { + len0 = binaryAlpha[binaryIndex++]; + while (len0 > 0) { + len0--; + imagePixels[index] = imagePixels[index + 1] = imagePixels[index + 2] = 255; + imagePixels[index + 3] = 0; // this value is already 0. + index += 4; + } + } else { + imagePixels[index] = imagePixels[index + 1] = imagePixels[index + 2] = 255 - tmpValue; + imagePixels[index + 3] = tmpValue; index += 4; } - } else { - imagePixels[index] = imagePixels[index + 1] = imagePixels[index + 2] = 255 - tmpValue; - imagePixels[index + 3] = tmpValue; - 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); }; @@ -230,21 +253,55 @@ export class storeTextSettings { ctx = canvas.getContext("2d"); } - if (this.supportBinaryFormat) { - if (!this.data) { - this.openBinary(this.binaryFormat); - delete this.binaryFormat; - } - - var dataTmp = ctx.createImageData(this.width, this.heightOne); - var sizeImage = 4 * this.width * this.heightOne; - dataTmp.data.set(new Uint8ClampedArray(this.data.buffer, index * sizeImage, sizeImage)); - ctx.putImageData(dataTmp, 0, 0); - } else { - ctx.clearRect(0, 0, this.width, this.heightOne); - ctx.drawImage(this.image, 0, -this.heightOne * index); + if (!this.data && !this.offsets) { + this.openBinary(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 { + 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(); //console.log(t2 - t1); @@ -255,6 +312,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); + } }); } diff --git a/apps/spreadsheeteditor/mobile/src/store/textSettings.js b/apps/spreadsheeteditor/mobile/src/store/textSettings.js index 25d7c1d46..8df7c95fd 100644 --- a/apps/spreadsheeteditor/mobile/src/store/textSettings.js +++ b/apps/spreadsheeteditor/mobile/src/store/textSettings.js @@ -134,7 +134,7 @@ export class storeTextSettings { loadSprite() { function CThumbnailLoader() { - this.supportBinaryFormat = (window['AscDesktopEditor'] && !window['AscDesktopEditor']['isSupportBinaryFontsSprite']) ? false : true; + this.supportBinaryFormat = true; this.image = null; this.binaryFormat = null; @@ -143,37 +143,27 @@ export class storeTextSettings { this.height = 0; this.heightOne = 0; this.count = 0; + this.offsets = null; this.load = function(url, callback) { if (!callback) return; - if (!this.supportBinaryFormat) { - this.width = thumbs[thumbIdx].width; - this.heightOne = thumbs[thumbIdx].height; + var xhr = new XMLHttpRequest(); + xhr.open('GET', url + ".bin", true); + xhr.responseType = 'arraybuffer'; - this.image = new Image(); - this.image.onload = callback; - this.image.src = thumbs[thumbIdx].path; - } else { - var me = this; - var xhr = new XMLHttpRequest(); - xhr.open('GET', url + ".bin", true); - xhr.responseType = 'arraybuffer'; + if (xhr.overrideMimeType) + xhr.overrideMimeType('text/plain; charset=x-user-defined'); + else xhr.setRequestHeader('Accept-Charset', 'x-user-defined'); - if (xhr.overrideMimeType) - xhr.overrideMimeType('text/plain; charset=x-user-defined'); - else - xhr.setRequestHeader('Accept-Charset', 'x-user-defined'); + xhr.onload = e => { + // TODO: check errors + this.binaryFormat = new Uint8Array(e.target.response); + callback(); + }; - xhr.onload = function() { - // TODO: check errors - me.binaryFormat = this.response; - callback(); - }; - - xhr.send(null); - } + xhr.send(null); }; this.openBinary = function(arrayBuffer) { @@ -186,32 +176,67 @@ export class storeTextSettings { 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); + const MAX_MEMORY_SIZE = 100000000; + const memorySize = 4 * this.width * this.height; + const isOffsets = memorySize > MAX_MEMORY_SIZE; + + 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; - while (binaryIndex < binaryLen) { - tmpValue = binaryAlpha[binaryIndex++]; - if (0 == tmpValue) { - len0 = binaryAlpha[binaryIndex++]; - while (len0 > 0) { - len0--; - imagePixels[index] = imagePixels[index + 1] = imagePixels[index + 2] = 255; - imagePixels[index + 3] = 0; // this value is already 0. + + if (!isOffsets) { + var imagePixels = this.data; + while (binaryIndex < binaryLen) { + tmpValue = binaryAlpha[binaryIndex++]; + if (0 == tmpValue) { + len0 = binaryAlpha[binaryIndex++]; + while (len0 > 0) { + len0--; + imagePixels[index] = imagePixels[index + 1] = imagePixels[index + 2] = 255; + imagePixels[index + 3] = 0; // this value is already 0. + index += 4; + } + } else { + imagePixels[index] = imagePixels[index + 1] = imagePixels[index + 2] = 255 - tmpValue; + imagePixels[index + 3] = tmpValue; index += 4; } - } else { - imagePixels[index] = imagePixels[index + 1] = imagePixels[index + 2] = 255 - tmpValue; - imagePixels[index + 3] = tmpValue; - 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); }; @@ -230,21 +255,55 @@ export class storeTextSettings { ctx = canvas.getContext("2d"); } - if (this.supportBinaryFormat) { - if (!this.data) { - this.openBinary(this.binaryFormat); - delete this.binaryFormat; - } - - var dataTmp = ctx.createImageData(this.width, this.heightOne); - var sizeImage = 4 * this.width * this.heightOne; - dataTmp.data.set(new Uint8ClampedArray(this.data.buffer, index * sizeImage, sizeImage)); - ctx.putImageData(dataTmp, 0, 0); - } else { - ctx.clearRect(0, 0, this.width, this.heightOne); - ctx.drawImage(this.image, 0, -this.heightOne * index); + if (!this.data && !this.offsets) { + this.openBinary(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 { + 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(); //console.log(t2 - t1); @@ -255,6 +314,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); + } }); } From f17c824f1ed62922c2cdd1710cdad6526e620911 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 3 Jun 2022 18:59:19 +0300 Subject: [PATCH 03/36] [PE] Fix Bug 57473 (#1780) --- apps/presentationeditor/main/locale/ru.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/presentationeditor/main/locale/ru.json b/apps/presentationeditor/main/locale/ru.json index c87e6efdf..9803e1757 100644 --- a/apps/presentationeditor/main/locale/ru.json +++ b/apps/presentationeditor/main/locale/ru.json @@ -114,7 +114,7 @@ "Common.define.effectData.textFloatIn": "Плавное приближение", "Common.define.effectData.textFloatOut": "Плавное удаление", "Common.define.effectData.textFloatUp": "Плавное перемещение вверх", - "Common.define.effectData.textFlyIn": "Влет", + "Common.define.effectData.textFlyIn": "Вылет", "Common.define.effectData.textFlyOut": "Вылет за край листа", "Common.define.effectData.textFontColor": "Цвет шрифта", "Common.define.effectData.textFootball": "Овал", From a0be79bdee3bc5dcdef3fd0c5c27a2bd036d3f0b Mon Sep 17 00:00:00 2001 From: JuliaSvinareva <49390479+JuliaSvinareva@users.noreply.github.com> Date: Tue, 7 Jun 2022 10:27:50 +0300 Subject: [PATCH 04/36] [SSE] Bug 57488 (#1786) --- apps/spreadsheeteditor/main/app/controller/Main.js | 2 +- apps/spreadsheeteditor/main/app/controller/Print.js | 7 +++++++ apps/spreadsheeteditor/main/app/view/FileMenuPanels.js | 9 ++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index ff03322fe..2d970bec7 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -1387,7 +1387,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); } diff --git a/apps/spreadsheeteditor/main/app/controller/Print.js b/apps/spreadsheeteditor/main/app/controller/Print.js index 4bbaaedf4..d2a21bd82 100644 --- a/apps/spreadsheeteditor/main/app/controller/Print.js +++ b/apps/spreadsheeteditor/main/app/controller/Print.js @@ -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() { diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index 67626ca3f..d3c755a61 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -2317,7 +2317,7 @@ define([ '', '', '', - '', + '', //'', '', '', '', '', '