Web:Viewer Removed unnecessary dependency

This commit is contained in:
Akmal Isomadinov 2023-05-08 14:51:34 +05:00
parent eb04443b44
commit bd7dbb44a3
21 changed files with 0 additions and 22962 deletions

View File

@ -17,8 +17,6 @@ import {
import { ToolbarActionType } from "../../helpers";
import { ToolbarItemType } from "../ImageViewerToolbar/ImageViewerToolbar.props";
// import "./lib";
// import { isDesktop } from "react-device-detect";?
const pdfViewerId = "pdf-viewer";

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,782 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
"use strict";
(function(window, document){
// Import
var g_fontApplication = AscFonts.g_fontApplication;
var CFontFileLoader = AscFonts.CFontFileLoader;
var FONT_TYPE_EMBEDDED = AscFonts.FONT_TYPE_EMBEDDED;
var CFontInfo = AscFonts.CFontInfo;
var ImageLoadStatus = AscFonts.ImageLoadStatus;
var CImage = AscFonts.CImage;
function CGlobalFontLoader()
{
// сначала хотел писать "вытеснение" из этого мапа.
// но тогда нужно хранить base64 строки. Это не круто. По памяти - даже
// выигрыш будет. Не особо то шрифты жмутся lzw или deflate
// поэтому лучше из памяти будем удалять base64 строки
this.fonts_streams = [];
// теперь вся информация о всех возможных шрифтах. Они во всех редакторах должны быть одни и те же
this.fontFilesPath = "../../../../fonts/";
this.fontFiles = AscFonts.g_font_files;
this.fontInfos = AscFonts.g_font_infos;
this.map_font_index = AscFonts.g_map_font_index;
// теперь вся информация о всех встроенных шрифтах. Они должны удаляться при подгрузке нового файла
this.embeddedFilesPath = "";
this.embeddedFontFiles = [];
this.embeddedFontInfos = [];
// динамическая подгрузка шрифтов
this.ThemeLoader = null;
this.Api = null;
this.fonts_loading = [];
this.fonts_loading_after_style = [];
this.bIsLoadDocumentFirst = false;
this.currentInfoLoaded = null;
this.loadFontCallBack = null;
this.loadFontCallBackArgs = null;
this.IsLoadDocumentFonts2 = false;
this.check_loaded_timer_id = -1;
this.endLoadingCallback = null;
this.perfStart = 0;
this.put_Api = function(_api)
{
this.Api = _api;
};
this.LoadEmbeddedFonts = function(url, _fonts)
{
this.embeddedFilesPath = url;
var _count = _fonts.length;
if (0 == _count)
return;
this.embeddedFontInfos = new Array(_count);
var map_files = {};
for (var i = 0; i < _count; i++)
map_files[_fonts[i].id] = _fonts[i].id;
var index = 0;
for (var i in map_files)
{
this.embeddedFontFiles[index] = new CFontFileLoader(map_files[i]);
this.embeddedFontFiles[index].CanUseOriginalFormat = false;
this.embeddedFontFiles[index].IsNeedAddJSToFontPath = false;
map_files[i] = index++;
}
for (var i = 0; i < _count; i++)
{
var lStyle = 0;//_fonts[i].Style;
if (0 == lStyle)
this.embeddedFontInfos[i] = new CFontInfo(_fonts[i].name, "", FONT_TYPE_EMBEDDED, map_files[_fonts[i].id], 0, -1, -1, -1, -1, -1, -1);
else if (2 == lStyle)
this.embeddedFontInfos[i] = new CFontInfo(_fonts[i].name, "", FONT_TYPE_EMBEDDED, -1, -1, map_files[_fonts[i].id], _fonts[i].faceindex, -1, -1, -1, -1);
else if (1 == lStyle)
this.embeddedFontInfos[i] = new CFontInfo(_fonts[i].name, "", FONT_TYPE_EMBEDDED, -1, -1, -1, -1, map_files[_fonts[i].id], _fonts[i].faceindex, -1, -1);
else
this.embeddedFontInfos[i] = new CFontInfo(_fonts[i].name, "", FONT_TYPE_EMBEDDED, -1, -1, -1, -1, -1, -1, map_files[_fonts[i].id], _fonts[i].faceindex);
}
var _count_infos_ = this.fontInfos.length;
for (var i = 0; i < _count; i++)
{
this.map_font_index[_fonts[i].name] = i + _count_infos_;
this.fontInfos[i + _count_infos_] = this.embeddedFontInfos[i];
}
};
this.SetStandartFonts = function()
{
//В стандартных шрифтах закоментированы те шрифты, которые были добавлены на docs.teamlab.com
var standarts = window["standarts"];
if (undefined == standarts)
{
standarts = [];
for (var i = 0; i < this.fontInfos.length; i++)
{
if (this.fontInfos[i].Name != "ASCW3")
standarts.push(this.fontInfos[i].Name);
}
}
var _count = standarts.length;
var _infos = this.fontInfos;
var _map = this.map_font_index;
for (var i = 0; i < _count; i++)
{
_infos[_map[standarts[i]]].Type = AscFonts.FONT_TYPE_STANDART;
}
};
this.AddLoadFonts = function(name, need_styles)
{
var fontinfo = g_fontApplication.GetFontInfo(name);
this.fonts_loading[this.fonts_loading.length] = fontinfo;
this.fonts_loading[this.fonts_loading.length - 1].NeedStyles = (need_styles == undefined) ? 0x0F : need_styles;
return fontinfo;
};
this.AddLoadFontsNotPick = function(info, need_styles)
{
this.fonts_loading[this.fonts_loading.length] = info;
this.fonts_loading[this.fonts_loading.length - 1].NeedStyles = (need_styles == undefined) ? 0x0F : need_styles;
};
this.LoadDocumentFonts = function(_fonts, is_default)
{
if (this.IsLoadDocumentFonts2)
return this.LoadDocumentFonts2(_fonts);
// в конце метода нужно отдать список шрифтов
var gui_fonts = [];
var gui_count = 0;
for (var i = 0; i < this.fontInfos.length; i++)
{
var info = this.fontInfos[i];
if (AscFonts.FONT_TYPE_STANDART == info.Type)
{
var __font = new AscFonts.CFont(info.Name, "", info.Type, info.Thumbnail);
gui_fonts[gui_count++] = __font;
}
}
// сначала заполняем массив this.fonts_loading объекстами fontinfo
for (var i in _fonts)
{
if (_fonts[i].type != FONT_TYPE_EMBEDDED)
{
var info = this.AddLoadFonts(_fonts[i].name, _fonts[i].NeedStyles);
if (info.Type == AscFonts.FONT_TYPE_ADDITIONAL)
{
if (info.name != "ASCW3")
{
var __font = new AscFonts.CFont(info.Name, "", info.Type, info.Thumbnail);
gui_fonts[gui_count++] = __font;
}
}
}
else
{
var ind = -1;
for (var j = 0; j < this.embeddedFontInfos.length; j++)
{
if (this.embeddedFontInfos[j].Name == _fonts[i].name)
{
this.AddLoadFontsNotPick(this.embeddedFontInfos[j], 0x0F);
break;
}
}
}
}
this.Api.sync_InitEditorFonts(gui_fonts);
// но только если редактор!!!
if (this.Api.IsNeedDefaultFonts())
{
// теперь добавим шрифты, без которых редактор как без рук (спецсимволы + дефолтовые стили документа)
this.AddLoadFonts("Arial", 0x0F);
this.AddLoadFonts("Symbol", 0x0F);
this.AddLoadFonts("Wingdings", 0x0F);
this.AddLoadFonts("Courier New", 0x0F);
this.AddLoadFonts("Times New Roman", 0x0F);
}
this.Api.asyncFontsDocumentStartLoaded();
this.bIsLoadDocumentFirst = true;
this.CheckFontsNeedLoadingLoad();
this._LoadFonts();
};
this.CheckFontsNeedLoadingLoad = function()
{
var _fonts = this.fonts_loading;
var _fonts_len = _fonts.length;
var _need = false;
for (var i = 0; i < _fonts_len; i++)
{
if (true == _fonts[i].CheckFontLoadStyles(this))
_need = true;
}
return _need;
};
this.CheckFontsNeedLoading = function(_fonts)
{
for (var i in _fonts)
{
var info = g_fontApplication.GetFontInfo(_fonts[i].name);
var _isNeed = info.CheckFontLoadStylesNoLoad(this);
if (_isNeed === true)
return true;
}
return false;
};
this.LoadDocumentFonts2 = function(_fonts, _blockType, _callback)
{
if (this.isWorking())
return;
this.endLoadingCallback = (undefined !== _callback) ? _callback : null;
this.BlockOperationType = _blockType;
// сначала заполняем массив this.fonts_loading объекстами fontinfo
for (var i in _fonts)
{
this.AddLoadFonts(_fonts[i].name, 0x0F);
}
if (null == this.ThemeLoader)
this.Api.asyncFontsDocumentStartLoaded(this.BlockOperationType);
else
this.ThemeLoader.asyncFontsStartLoaded();
this.CheckFontsNeedLoadingLoad();
this._LoadFonts();
};
var oThis = this;
this._LoadFonts = function()
{
if (this.bIsLoadDocumentFirst === true && 0 === this.perfStart && this.fonts_loading.length > 0) {
this.perfStart = performance.now();
}
if (0 == this.fonts_loading.length)
{
if (this.perfStart > 0) {
let perfEnd = performance.now();
AscCommon.sendClientLog("debug", AscCommon.getClientInfoString("onLoadFonts", perfEnd - this.perfStart), this.Api);
this.perfStart = 0;
}
if (null != this.endLoadingCallback)
{
this.endLoadingCallback.call(this.Api);
this.endLoadingCallback = null;
}
else if (null == this.ThemeLoader)
this.Api.asyncFontsDocumentEndLoaded(this.BlockOperationType);
else
this.ThemeLoader.asyncFontsEndLoaded();
this.BlockOperationType = undefined;
if (this.bIsLoadDocumentFirst === true)
{
var _count = this.fonts_loading_after_style.length;
for (var i = 0; i < _count; i++)
{
var _info = this.fonts_loading_after_style[i];
_info.NeedStyles = 0x0F;
_info.CheckFontLoadStyles(this);
}
this.fonts_loading_after_style.splice(0, this.fonts_loading_after_style.length);
this.bIsLoadDocumentFirst = false;
}
return;
}
var fontinfo = this.fonts_loading[0];
var IsNeed = fontinfo.CheckFontLoadStyles(this);
if (IsNeed)
{
this.check_loaded_timer_id = setTimeout(oThis._check_loaded, 50);
}
else
{
if (this.bIsLoadDocumentFirst === true)
{
this.Api.OpenDocumentProgress.CurrentFont++;
this.Api.SendOpenProgress();
}
this.fonts_loading_after_style[this.fonts_loading_after_style.length] = this.fonts_loading[0];
this.fonts_loading.shift();
this._LoadFonts();
}
};
this.isWorking = function()
{
return (this.check_loaded_timer_id !== -1) ? true : false;
};
this._check_loaded = function()
{
oThis.check_loaded_timer_id = -1;
if (0 == oThis.fonts_loading.length)
{
// значит асинхронно удалилось
oThis._LoadFonts();
return;
}
var current = oThis.fonts_loading[0];
var IsNeed = current.CheckFontLoadStyles(oThis);
if (true === IsNeed)
{
oThis.check_loaded_timer_id = setTimeout(oThis._check_loaded, 50);
}
else
{
if (oThis.bIsLoadDocumentFirst === true)
{
oThis.Api.OpenDocumentProgress.CurrentFont++;
oThis.Api.SendOpenProgress();
}
oThis.fonts_loading_after_style[oThis.fonts_loading_after_style.length] = oThis.fonts_loading[0];
oThis.fonts_loading.shift();
oThis._LoadFonts();
}
};
this.LoadFont = function(fontinfo, loadFontCallBack, loadFontCallBackArgs)
{
this.currentInfoLoaded = fontinfo;
this.currentInfoLoaded = fontinfo;
this.currentInfoLoaded.NeedStyles = 15; // все стили
var IsNeed = this.currentInfoLoaded.CheckFontLoadStyles(this);
if ( undefined === loadFontCallBack )
{
this.loadFontCallBack = this.Api.asyncFontEndLoaded;
this.loadFontCallBackArgs = this.currentInfoLoaded;
}
else
{
this.loadFontCallBack = loadFontCallBack;
this.loadFontCallBackArgs = loadFontCallBackArgs;
}
if (IsNeed)
{
this.Api.asyncFontStartLoaded();
setTimeout(this.check_loaded, 20);
return true;
}
else
{
this.currentInfoLoaded = null;
return false;
}
};
this.check_loaded = function()
{
var current = oThis.currentInfoLoaded;
if (null == current)
return;
var IsNeed = current.CheckFontLoadStyles(oThis);
if (IsNeed)
{
setTimeout(oThis.check_loaded, 50);
}
else
{
oThis.loadFontCallBack.call( oThis.Api, oThis.loadFontCallBackArgs );
oThis.currentInfoLoaded = null;
}
};
this.LoadFontsFromServer = function(_fonts)
{
var _count = _fonts.length;
for (var i = 0; i < _count; i++)
{
var _info = g_fontApplication.GetFontInfo(_fonts[i]);
if (undefined !== _info)
{
_info.LoadFontsFromServer(this);
}
}
}
}
CGlobalFontLoader.prototype.SetStreamIndexEmb = function(font_index, stream_index)
{
this.embeddedFontFiles[font_index].SetStreamIndex(stream_index);
};
function CGlobalImageLoader()
{
this.map_image_index = {};
// loading
this.Api = null;
this.ThemeLoader = null;
this.images_loading = null;
this.bIsLoadDocumentFirst = false;
this.bIsAsyncLoadDocumentImages = false;
this.bIsLoadDocumentImagesNoByOrder = true;
this.nNoByOrderCounter = 0;
this.isBlockchainSupport = false;
var oThis = this;
if (window["AscDesktopEditor"] &&
window["AscDesktopEditor"]["IsLocalFile"] &&
window["AscDesktopEditor"]["isBlockchainSupport"])
{
this.isBlockchainSupport = (window["AscDesktopEditor"]["isBlockchainSupport"]() && !window["AscDesktopEditor"]["IsLocalFile"]());
if (this.isBlockchainSupport)
{
Image.prototype.preload_crypto = function(_url)
{
window["crypto_images_map"] = window["crypto_images_map"] || {};
if (!window["crypto_images_map"][_url])
window["crypto_images_map"][_url] = [];
window["crypto_images_map"][_url].push(this);
window["AscDesktopEditor"]["PreloadCryptoImage"](_url, AscCommon.g_oDocumentUrls.getLocal(_url));
oThis.Api.sync_StartAction(Asc.c_oAscAsyncActionType.BlockInteraction, Asc.c_oAscAsyncAction.LoadImage);
};
Image.prototype["onload_crypto"] = function(_src, _crypto_data)
{
if (_crypto_data && AscCommon.EncryptionWorker && AscCommon.EncryptionWorker.isCryptoImages())
{
AscCommon.EncryptionWorker.decryptImage(_src, this, _crypto_data);
return;
}
this.crossOrigin = "";
this.src = _src;
oThis.Api.sync_EndAction(Asc.c_oAscAsyncActionType.BlockInteraction, Asc.c_oAscAsyncAction.LoadImage);
};
}
}
this.put_Api = function(_api)
{
this.Api = _api;
if (this.Api.IsAsyncOpenDocumentImages !== undefined)
{
this.bIsAsyncLoadDocumentImages = this.Api.IsAsyncOpenDocumentImages();
if (this.bIsAsyncLoadDocumentImages)
{
if (undefined === this.Api.asyncImageEndLoadedBackground)
this.bIsAsyncLoadDocumentImages = false;
}
}
};
this.LoadDocumentImages = function(_images, isCheckExists)
{
if (isCheckExists)
{
for (var i = _images.length - 1; i >= 0; i--)
{
var _id = AscCommon.getFullImageSrc2(_images[i]);
if (this.map_image_index[_id] && (this.map_image_index[_id].Status === ImageLoadStatus.Complete))
{
_images.splice(i, 1);
}
}
if (0 === _images.length)
return;
}
// сначала заполним массив
if (this.ThemeLoader == null)
this.Api.asyncImagesDocumentStartLoaded();
else
this.ThemeLoader.asyncImagesStartLoaded();
this.images_loading = [];
for (var id in _images)
{
this.images_loading[this.images_loading.length] = AscCommon.getFullImageSrc2(_images[id]);
}
if (!this.bIsAsyncLoadDocumentImages)
{
this.nNoByOrderCounter = 0;
this._LoadImages();
}
else
{
var _len = this.images_loading.length;
for (var i = 0; i < _len; i++)
{
this.LoadImageAsync(i);
}
this.images_loading.splice(0, _len);
if (this.ThemeLoader == null)
this.Api.asyncImagesDocumentEndLoaded();
else
this.ThemeLoader.asyncImagesEndLoaded();
}
};
this.loadImageByUrl = function(_image, _url, isDisableCrypto)
{
if (this.isBlockchainSupport && (true !== isDisableCrypto))
_image.preload_crypto(_url);
else
_image.src = _url;
};
this._LoadImages = function()
{
for (var i = 0; i < this.images_loading.length; i++)
{
var _id = this.images_loading[i];
if (this.map_image_index[_id] && (this.map_image_index[_id].Status === ImageLoadStatus.Complete))
{
this.images_loading.splice(i, 1);
}
}
var _count_images = this.images_loading.length;
if (0 == _count_images)
{
this.nNoByOrderCounter = 0;
if (this.ThemeLoader == null)
this.Api.asyncImagesDocumentEndLoaded();
else
this.ThemeLoader.asyncImagesEndLoaded();
return;
}
for (var i = 0; i < _count_images; i++)
{
var _id = this.images_loading[i];
var oImage = new CImage(_id);
oImage.Status = ImageLoadStatus.Loading;
oImage.Image = new Image();
oThis.map_image_index[oImage.src] = oImage;
oImage.Image.parentImage = oImage;
oImage.Image.onload = function ()
{
this.parentImage.Status = ImageLoadStatus.Complete;
oThis.nNoByOrderCounter++;
if (oThis.bIsLoadDocumentFirst === true)
{
oThis.Api.OpenDocumentProgress.CurrentImage++;
oThis.Api.SendOpenProgress();
}
if (!oThis.bIsLoadDocumentImagesNoByOrder)
{
oThis.images_loading.shift();
oThis._LoadImages();
}
else if (oThis.nNoByOrderCounter == oThis.images_loading.length)
{
oThis.images_loading = [];
oThis._LoadImages();
}
};
oImage.Image.onerror = function ()
{
this.parentImage.Status = ImageLoadStatus.Complete;
this.parentImage.Image = null;
oThis.nNoByOrderCounter++;
if (oThis.bIsLoadDocumentFirst === true)
{
oThis.Api.OpenDocumentProgress.CurrentImage++;
oThis.Api.SendOpenProgress();
}
if (!oThis.bIsLoadDocumentImagesNoByOrder)
{
oThis.images_loading.shift();
oThis._LoadImages();
}
else if (oThis.nNoByOrderCounter == oThis.images_loading.length)
{
oThis.images_loading = [];
oThis._LoadImages();
}
};
AscCommon.backoffOnErrorImg(oImage.Image, function(img) {
oThis.loadImageByUrl(img, img.src);
});
//oImage.Image.crossOrigin = 'anonymous';
oThis.loadImageByUrl(oImage.Image, oImage.src);
if (!oThis.bIsLoadDocumentImagesNoByOrder)
return;
}
};
this.LoadImage = function(src, Type)
{
var _image = this.map_image_index[src];
if (undefined != _image)
return _image;
this.Api.asyncImageStartLoaded();
var oImage = new CImage(src);
oImage.Type = Type;
oImage.Image = new Image();
oImage.Status = ImageLoadStatus.Loading;
oThis.map_image_index[oImage.src] = oImage;
oImage.Image.onload = function(){
oImage.Status = ImageLoadStatus.Complete;
oThis.Api.asyncImageEndLoaded(oImage);
};
oImage.Image.onerror = function(){
oImage.Image = null;
oImage.Status = ImageLoadStatus.Complete;
oThis.Api.asyncImageEndLoaded(oImage);
};
AscCommon.backoffOnErrorImg(oImage.Image, function(img) {
oThis.loadImageByUrl(img, img.src);
});
//oImage.Image.crossOrigin = 'anonymous';
this.loadImageByUrl(oImage.Image, oImage.src);
return null;
};
this.LoadImageAsync = function(i)
{
var _id = oThis.images_loading[i];
var oImage = new CImage(_id);
oImage.Status = ImageLoadStatus.Loading;
oImage.Image = new Image();
oThis.map_image_index[oImage.src] = oImage;
oImage.Image.onload = function(){
oImage.Status = ImageLoadStatus.Complete;
oThis.Api.asyncImageEndLoadedBackground(oImage);
};
oImage.Image.onerror = function(){
oImage.Status = ImageLoadStatus.Complete;
oImage.Image = null;
oThis.Api.asyncImageEndLoadedBackground(oImage);
};
AscCommon.backoffOnErrorImg(oImage.Image, function(img) {
oThis.loadImageByUrl(img, img.src);
});
//oImage.Image.crossOrigin = 'anonymous';
oThis.loadImageByUrl(oImage.Image, oImage.src);
};
this.LoadImagesWithCallback = function(arr, loadImageCallBack, loadImageCallBackArgs, isDisableCrypto)
{
var arrAsync = [];
var i = 0;
for (i = 0; i < arr.length; i++)
{
if (this.map_image_index[arr[i]] === undefined)
arrAsync.push(arr[i]);
}
if (arrAsync.length == 0)
{
loadImageCallBack.call(this.Api, loadImageCallBackArgs);
return;
}
let asyncImageCounter = arrAsync.length;
const callback = loadImageCallBack.bind(this.Api, loadImageCallBackArgs);
for (i = 0; i < arrAsync.length; i++)
{
var oImage = new CImage(arrAsync[i]);
oImage.Image = new Image();
oImage.Image.parentImage = oImage;
oImage.Status = ImageLoadStatus.Loading;
this.map_image_index[oImage.src] = oImage;
oImage.Image.onload = function ()
{
this.parentImage.Status = ImageLoadStatus.Complete;
asyncImageCounter--;
if (asyncImageCounter === 0)
callback();
};
oImage.Image.onerror = function ()
{
this.parentImage.Image = null;
this.parentImage.Status = ImageLoadStatus.Complete;
asyncImageCounter--;
if (asyncImageCounter === 0)
callback();
};
AscCommon.backoffOnErrorImg(oImage.Image, function(img) {
oThis.loadImageByUrl(img, img.src);
});
//oImage.Image.crossOrigin = 'anonymous';
this.loadImageByUrl(oImage.Image, oImage.src, isDisableCrypto);
}
};
}
//---------------------------------------------------------export---------------------------------------------------
window['AscCommon'] = window['AscCommon'] || {};
window['AscCommon'].CGlobalFontLoader = CGlobalFontLoader;
window['AscCommon'].g_font_loader = new CGlobalFontLoader();
window['AscCommon'].g_image_loader = new CGlobalImageLoader();
})(window, window.document);

View File

@ -1,769 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
"use strict";
(function(window, undefined)
{
AscCommon.isTouch = false;
AscCommon.isTouchMove = false;
AscCommon.TouchStartTime = -1;
// Import
var AscBrowser = AscCommon.AscBrowser;
// константы для мыши
var g_mouse_event_type_down = 0;
var g_mouse_event_type_move = 1;
var g_mouse_event_type_up = 2;
var g_mouse_event_type_wheel = 3;
var g_mouse_button_left = 0;
var g_mouse_button_center = 1;
var g_mouse_button_right = 2;
var MouseUpLock = {
MouseUpLockedSend : false
};
AscCommon.stopEvent = function(e)
{
if (!e)
return;
if (e.preventDefault)
e.preventDefault();
if (e.stopPropagation)
e.stopPropagation();
};
// для мозиллы пока отключаем, так как браузер не распознает это как "юзерское действие". (window.open, input[file].click)
var isUsePointerEvents = (AscBrowser.isChrome && (AscBrowser.chromeVersion > 70)/* || AscBrowser.isMozilla*/) ? true : false;
AscCommon.addMouseEvent = function(elem, type, handler)
{
var _type = (isUsePointerEvents ? "onpointer" : "onmouse") + type;
elem[_type] = handler;
};
AscCommon.removeMouseEvent = function(elem, type)
{
var _type = (isUsePointerEvents ? "onpointer" : "onmouse") + type;
if (elem[_type])
delete elem[_type];
};
AscCommon.getMouseEvent = function(elem, type)
{
var _type = (isUsePointerEvents ? "onpointer" : "onmouse") + type;
return elem[_type];
};
function CMouseEventHandler()
{
this.X = 0; // позиция курсора X
this.Y = 0; // позиция курсора Y
this.Button = g_mouse_button_left; // кнопка мыши
this.Type = g_mouse_event_type_move; // тип евента
this.AltKey = false; // нажата ли кнопка alt
this.CtrlKey = false; // нажата ли кнопка ctrl
this.ShiftKey = false; // нажата ли кнопка shift
this.Sender = null; // от какого html элемента пришел евент
this.LastClickTime = -1; // время последнего mousedown
this.ClickCount = 0; // количество кликов
this.WheelDelta = 0;
// координаты мышки при предыдущем mousedown (для mousemove)
this.IsPressed = false; // была ли зажата кнопка
this.LastX = 0;
this.LastY = 0;
this.KoefPixToMM = 1;
this.IsLocked = false;
this.IsLockedEvent = false;
this.buttonObject = null;
this.AscHitToHandlesEpsilon = 0;
this.LockMouse = function()
{
if (!this.IsLocked)
{
this.IsLocked = true;
if (window.captureEvents)
window.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP);
if (window.g_asc_plugins)
window.g_asc_plugins.disablePointerEvents();
/*
var parent = window;
while (true)
{
if (!parent)
break;
if (parent.captureEvents)
parent.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP);
if (parent == parent.parent)
break;
parent = parent.parent;
}
*/
return true;
}
return false;
};
this.UnLockMouse = function()
{
if (this.IsLocked)
{
this.IsLocked = false;
if (window.releaseEvents)
window.releaseEvents(Event.MOUSEMOVE);
if (window.g_asc_plugins)
window.g_asc_plugins.enablePointerEvents();
/*
var parent = window;
while (true)
{
if (!parent)
break;
if (parent.releaseEvents)
parent.releaseEvents(Event.MOUSEMOVE);
if (parent == parent.parent)
break;
parent = parent.parent;
}
*/
return true;
}
return false;
};
}
function CKeyboardEvent()
{
this.AltKey = false; // нажата ли кнопка alt
this.CtrlKey = false; // нажата ли кнопка ctrl
this.ShiftKey = false; // нажата ли кнопка shift
this.MacCmdKey = false;
this.AltGr = false;
this.Sender = null; // от какого html элемента пришел евент
this.CharCode = 0;
this.KeyCode = 0;
}
CKeyboardEvent.prototype.Up = function()
{
this.AltKey = false;
this.CtrlKey = false;
this.ShiftKey = false;
this.AltGr = false;
this.MacCmdKey = false;
};
CKeyboardEvent.prototype.IsCtrl = function()
{
return (this.CtrlKey || (this.AltKey && this.AltGr));
};
CKeyboardEvent.prototype.IsShift = function()
{
return this.ShiftKey;
};
CKeyboardEvent.prototype.IsAlt = function()
{
return this.AltKey;
};
CKeyboardEvent.prototype.GetKeyCode = function()
{
return this.KeyCode;
};
var global_mouseEvent = new CMouseEventHandler();
var global_keyboardEvent = new CKeyboardEvent();
function check_KeyboardEvent(e)
{
global_keyboardEvent.AltKey = e.altKey;
global_keyboardEvent.AltGr = AscCommon.getAltGr(e);
global_keyboardEvent.CtrlKey = !global_keyboardEvent.AltGr && (e.metaKey || e.ctrlKey);
global_keyboardEvent.MacCmdKey = AscCommon.AscBrowser.isMacOs && e.metaKey;
global_keyboardEvent.ShiftKey = e.shiftKey;
global_keyboardEvent.Sender = (e.srcElement) ? e.srcElement : e.target;
global_keyboardEvent.CharCode = e.charCode;
global_keyboardEvent.KeyCode = e.keyCode;
global_keyboardEvent.Which = e.which;
}
function check_KeyboardEvent2(e)
{
global_keyboardEvent.AltKey = e.altKey;
if (e.metaKey !== undefined)
global_keyboardEvent.CtrlKey = e.ctrlKey || e.metaKey;
else
global_keyboardEvent.CtrlKey = e.ctrlKey;
global_keyboardEvent.MacCmdKey = AscCommon.AscBrowser.isMacOs && e.metaKey;
global_keyboardEvent.ShiftKey = e.shiftKey;
global_keyboardEvent.AltGr = (global_keyboardEvent.CtrlKey && global_keyboardEvent.AltKey) ? true : false;
if (global_keyboardEvent.CtrlKey && global_keyboardEvent.AltKey)
global_keyboardEvent.CtrlKey = false;
}
function check_MouseMoveEvent(e)
{
// если мышь залочена, то евент придет от окна.
if (e.IsLocked && !e.IsLockedEvent)
return;
if (e.pageX || e.pageY)
{
global_mouseEvent.X = e.pageX;
global_mouseEvent.Y = e.pageY;
}
else if (e.clientX || e.clientY)
{
global_mouseEvent.X = e.clientX;
global_mouseEvent.Y = e.clientY;
}
global_mouseEvent.X = (global_mouseEvent.X * AscBrowser.zoom) >> 0;
global_mouseEvent.Y = (global_mouseEvent.Y * AscBrowser.zoom) >> 0;
global_mouseEvent.AltKey = e.altKey;
global_mouseEvent.ShiftKey = e.shiftKey;
global_mouseEvent.CtrlKey = e.ctrlKey || e.metaKey;
global_mouseEvent.Type = g_mouse_event_type_move;
if (!global_mouseEvent.IsLocked)
{
global_mouseEvent.Sender = (e.srcElement) ? e.srcElement : e.target;
}
var _eps = 3 * global_mouseEvent.KoefPixToMM;
if ((Math.abs(global_mouseEvent.X - global_mouseEvent.LastX) > _eps) || (Math.abs(global_mouseEvent.Y - global_mouseEvent.LastY) > _eps))
{
global_mouseEvent.LastClickTime = -1;
global_mouseEvent.ClickCount = 0;
}
}
function CreateMouseUpEventObject(x, y)
{
var e = {};
e.PageX = x;
e.PageY = y;
e.altKey = global_mouseEvent.AltKey;
e.shiftKey = global_mouseEvent.ShiftKey;
e.ctrlKey = global_mouseEvent.CtrlKey;
e.srcElement = global_mouseEvent.Sender;
e.button = 0;
return e;
}
function getMouseButton(e)
{
var res = e.button;
return (res && -1 !== res) ? res : 0;
}
function check_MouseUpEvent(e)
{
if (e.pageX || e.pageY)
{
global_mouseEvent.X = e.pageX;
global_mouseEvent.Y = e.pageY;
}
else if (e.clientX || e.clientY)
{
global_mouseEvent.X = e.clientX;
global_mouseEvent.Y = e.clientY;
}
global_mouseEvent.X = (global_mouseEvent.X * AscBrowser.zoom) >> 0;
global_mouseEvent.Y = (global_mouseEvent.Y * AscBrowser.zoom) >> 0;
global_mouseEvent.AltKey = e.altKey;
global_mouseEvent.ShiftKey = e.shiftKey;
global_mouseEvent.CtrlKey = e.ctrlKey || e.metaKey;
global_keyboardEvent.AltKey = global_mouseEvent.AltKey;
global_keyboardEvent.ShiftKey = global_mouseEvent.ShiftKey;
global_keyboardEvent.CtrlKey = global_mouseEvent.CtrlKey;
global_mouseEvent.Type = g_mouse_event_type_up;
global_mouseEvent.Button = getMouseButton(e);
var lockedElement = null;
var newSender = (e.srcElement) ? e.srcElement : e.target;
if (!newSender)
newSender = { id : "emulation_oo_id" };
if (global_mouseEvent.Sender && global_mouseEvent.Sender.id == newSender.id)
{
lockedElement = global_mouseEvent.Sender;
}
if (global_mouseEvent.IsLocked == true && global_mouseEvent.Sender != newSender && false === MouseUpLock.MouseUpLockedSend)
{
Window_OnMouseUp(e);
}
MouseUpLock.MouseUpLockedSend = true;
global_mouseEvent.Sender = newSender;
global_mouseEvent.UnLockMouse();
global_mouseEvent.IsPressed = false;
return lockedElement;
}
function check_MouseClickOnUp()
{
// call after check mouseUp
if (0 == global_mouseEvent.ClickCount)
return false;
var _eps = 3 * global_mouseEvent.KoefPixToMM;
if ((Math.abs(global_mouseEvent.X - global_mouseEvent.LastX) > _eps) || (Math.abs(global_mouseEvent.Y - global_mouseEvent.LastY) > _eps))
return false;
var CurTime = new Date().getTime();
if (500 < (CurTime - global_mouseEvent.LastClickTime))
return false;
return true;
}
function check_MouseDownEvent(e, isClicks)
{
if (e.pageX || e.pageY)
{
global_mouseEvent.X = e.pageX;
global_mouseEvent.Y = e.pageY;
}
else if (e.clientX || e.clientY)
{
global_mouseEvent.X = e.clientX;
global_mouseEvent.Y = e.clientY;
}
global_mouseEvent.X = (global_mouseEvent.X * AscBrowser.zoom) >> 0;
global_mouseEvent.Y = (global_mouseEvent.Y * AscBrowser.zoom) >> 0;
var _eps = 3 * global_mouseEvent.KoefPixToMM;
if ((Math.abs(global_mouseEvent.X - global_mouseEvent.LastX) > _eps) || (Math.abs(global_mouseEvent.Y - global_mouseEvent.LastY) > _eps))
{
// not only move!!! (touch - fast click in different places)
global_mouseEvent.LastClickTime = -1;
global_mouseEvent.ClickCount = 0;
}
global_mouseEvent.LastX = global_mouseEvent.X;
global_mouseEvent.LastY = global_mouseEvent.Y;
global_mouseEvent.AltKey = e.altKey;
global_mouseEvent.ShiftKey = e.shiftKey;
global_mouseEvent.CtrlKey = e.ctrlKey || e.metaKey;
global_keyboardEvent.AltKey = global_mouseEvent.AltKey;
global_keyboardEvent.ShiftKey = global_mouseEvent.ShiftKey;
global_keyboardEvent.CtrlKey = global_mouseEvent.CtrlKey;
global_mouseEvent.Type = g_mouse_event_type_down;
let oldButton = global_mouseEvent.Button;
global_mouseEvent.Button = getMouseButton(e);
if (!global_mouseEvent.IsLocked || !global_mouseEvent.Sender)
global_mouseEvent.Sender = (e.srcElement) ? e.srcElement : e.target;
if (isClicks)
{
var CurTime = new Date().getTime();
if (0 === global_mouseEvent.ClickCount)
{
global_mouseEvent.ClickCount = 1;
global_mouseEvent.LastClickTime = CurTime;
}
else
{
if ((500 > (CurTime - global_mouseEvent.LastClickTime)) && oldButton === global_mouseEvent.Button)
{
global_mouseEvent.LastClickTime = CurTime;
global_mouseEvent.ClickCount++;
}
else
{
global_mouseEvent.ClickCount = 1;
global_mouseEvent.LastClickTime = CurTime;
}
}
}
else
{
global_mouseEvent.LastClickTime = -1;
global_mouseEvent.ClickCount = 1;
}
MouseUpLock.MouseUpLockedSend = false;
}
function check_MouseDownEvent2(x, y)
{
global_mouseEvent.X = x;
global_mouseEvent.Y = y;
global_mouseEvent.LastX = global_mouseEvent.X;
global_mouseEvent.LastY = global_mouseEvent.Y;
global_mouseEvent.Type = g_mouse_event_type_down;
global_mouseEvent.Sender = editor.WordControl.m_oEditor.HtmlElement;
global_mouseEvent.LastClickTime = -1;
global_mouseEvent.ClickCount = 1;
MouseUpLock.MouseUpLockedSend = false;
}
function global_OnMouseWheel(e)
{
global_mouseEvent.AltKey = e.altKey;
global_mouseEvent.ShiftKey = e.shiftKey;
global_mouseEvent.CtrlKey = e.ctrlKey || e.metaKey;
if (undefined != e.wheelDelta)
global_mouseEvent.WheelDelta = (e.wheelDelta > 0) ? -45 : 45;
else
global_mouseEvent.WheelDelta = (e.detail > 0) ? 45 : -45;
global_mouseEvent.type = g_mouse_event_type_wheel;
global_mouseEvent.Sender = (e.srcElement) ? e.srcElement : e.target;
global_mouseEvent.LastClickTime = -1;
global_mouseEvent.ClickCount = 0;
}
function InitCaptureEvents()
{
AscCommon.addMouseEvent(window, "move", Window_OnMouseMove);
AscCommon.addMouseEvent(window, "up", Window_OnMouseUp);
}
function Window_OnMouseMove(e)
{
if (!global_mouseEvent.IsLocked || !global_mouseEvent.Sender)
return;
var types = isUsePointerEvents ? ["onpointermove", "onmousemove"] : ["onmousemove", "onpointermove"];
for (var i = 0; i < 2; i++)
{
if (global_mouseEvent.Sender[types[i]])
{
global_mouseEvent.IsLockedEvent = true;
global_mouseEvent.Sender[types[i]](e);
global_mouseEvent.IsLockedEvent = false;
break;
}
}
}
function Window_OnMouseUp(e)
{
if (false === MouseUpLock.MouseUpLockedSend)
{
MouseUpLock.MouseUpLockedSend = true;
if (global_mouseEvent.IsLocked && global_mouseEvent.Sender)
{
var types = isUsePointerEvents ? ["onpointerup", "onmouseup"] : ["onmouseup", "onpointerup"];
for (var i = 0; i < 2; i++)
{
if (global_mouseEvent.Sender[types[i]])
{
global_mouseEvent.Sender[types[i]](e, true);
if (global_mouseEvent.IsLocked)
global_mouseEvent.UnLockMouse();
break;
}
}
}
}
if (window.g_asc_plugins)
window.g_asc_plugins.onExternalMouseUp();
}
InitCaptureEvents();
function button_eventHandlers(disable_pos, norm_pos, over_pos, down_pos, control, click_func_delegate)
{
this.state_normal = norm_pos;
this.state_over = over_pos;
this.state_down = down_pos;
this.Click_func = click_func_delegate;
this.Control = control;
this.IsPressed = false;
var oThis = this;
this.Control.HtmlElement.onmouseover = function(e)
{
check_MouseMoveEvent(e);
if (global_mouseEvent.IsLocked)
{
if (global_mouseEvent.Sender.id != oThis.Control.HtmlElement.id)
{
// это не залоченная кнопка
return;
}
// залоченная кнопка
oThis.Control.HtmlElement.style.backgroundPosition = oThis.state_down;
return;
}
oThis.Control.HtmlElement.style.backgroundPosition = oThis.state_over;
}
this.Control.HtmlElement.onmouseout = function(e)
{
check_MouseMoveEvent(e);
if (global_mouseEvent.IsLocked)
{
if (global_mouseEvent.Sender.id != oThis.Control.HtmlElement.id)
{
// это не залоченная кнопка
return;
}
// залоченная кнопка
oThis.Control.HtmlElement.style.backgroundPosition = oThis.state_over;
return;
}
oThis.Control.HtmlElement.style.backgroundPosition = oThis.state_normal;
}
this.Control.HtmlElement.onmousedown = function(e)
{
check_MouseDownEvent(e);
global_mouseEvent.LockMouse();
global_mouseEvent.buttonObject = oThis;
AscCommon.stopEvent(e);
if (global_mouseEvent.IsLocked)
{
if (global_mouseEvent.Sender.id != oThis.Control.HtmlElement.id)
{
// это не залоченная кнопка
return;
}
// залоченная кнопка
oThis.Control.HtmlElement.style.backgroundPosition = oThis.state_down;
return;
}
oThis.Control.HtmlElement.style.backgroundPosition = oThis.state_down;
}
this.Control.HtmlElement.onmouseup = function(e)
{
var lockedElement = check_MouseUpEvent(e);
if (e.preventDefault)
e.preventDefault();
else
e.returnValue = false;
if (null != lockedElement && global_mouseEvent.buttonObject != null)
{
oThis.Click_func();
}
if (null != lockedElement)
{
oThis.Control.HtmlElement.style.backgroundPosition = oThis.state_over;
}
else
{
if (null != global_mouseEvent.buttonObject)
global_mouseEvent.buttonObject.Control.HtmlElement.style.backgroundPosition = global_mouseEvent.buttonObject.state_normal;
if ((global_mouseEvent.buttonObject == null) || (oThis.Control.HtmlElement.id != global_mouseEvent.buttonObject.Control.HtmlElement.id))
oThis.Control.HtmlElement.style.backgroundPosition = oThis.state_over;
}
global_mouseEvent.buttonObject = null;
}
// теперь touch
this.Control.HtmlElement.ontouchstart = function(e)
{
oThis.Control.HtmlElement.onmousedown(e.touches[0]);
return false;
}
this.Control.HtmlElement.ontouchend = function(e)
{
var lockedElement = check_MouseUpEvent(e.changedTouches[0]);
if (null != lockedElement)
{
oThis.Click_func();
oThis.Control.HtmlElement.style.backgroundPosition = oThis.state_normal;
}
else
{
if (null != global_mouseEvent.buttonObject)
global_mouseEvent.buttonObject.Control.HtmlElement.style.backgroundPosition = global_mouseEvent.buttonObject.state_normal;
if (oThis.Control.HtmlElement.id != global_mouseEvent.buttonObject.Control.HtmlElement.id)
oThis.Control.HtmlElement.style.backgroundPosition = oThis.state_normal;
}
global_mouseEvent.buttonObject = null;
return false;
}
}
function emulateKeyDown(_code, _element)
{
var oEvent = document.createEvent('KeyboardEvent');
// Chromium Hack
Object.defineProperty(oEvent, 'keyCode', {
get : function()
{
return this.keyCodeVal;
}
});
Object.defineProperty(oEvent, 'which', {
get : function()
{
return this.keyCodeVal;
}
});
Object.defineProperty(oEvent, 'shiftKey', {
get : function()
{
return false;
}
});
Object.defineProperty(oEvent, 'altKey', {
get : function()
{
return false;
}
});
Object.defineProperty(oEvent, 'metaKey', {
get : function()
{
return false;
}
});
Object.defineProperty(oEvent, 'ctrlKey', {
get : function()
{
return false;
}
});
if (AscCommon.AscBrowser.isIE)
{
oEvent.preventDefault = function () {
Object.defineProperty(this, "defaultPrevented", {get: function () {return true;}});
};
}
if (oEvent.initKeyboardEvent)
{
oEvent.initKeyboardEvent("keydown", true, true, window, false, false, false, false, _code, _code);
}
else
{
oEvent.initKeyEvent("keydown", true, true, window, false, false, false, false, _code, 0);
}
oEvent.keyCodeVal = _code;
_element.dispatchEvent(oEvent);
return oEvent.defaultPrevented;
}
//--------------------------------------------------------export----------------------------------------------------
window['AscCommon'] = window['AscCommon'] || {};
window['AscCommon'].g_mouse_event_type_down = g_mouse_event_type_down;
window['AscCommon'].g_mouse_event_type_move = g_mouse_event_type_move;
window['AscCommon'].g_mouse_event_type_up = g_mouse_event_type_up;
window['AscCommon'].g_mouse_button_left = g_mouse_button_left;
window['AscCommon'].g_mouse_button_center = g_mouse_button_center;
window['AscCommon'].g_mouse_button_right = g_mouse_button_right;
window['AscCommon'].MouseUpLock = MouseUpLock;
window['AscCommon'].CMouseEventHandler = CMouseEventHandler;
window['AscCommon'].CKeyboardEvent = CKeyboardEvent;
window['AscCommon'].global_mouseEvent = global_mouseEvent;
window['AscCommon'].global_keyboardEvent = global_keyboardEvent;
window['AscCommon'].check_KeyboardEvent = check_KeyboardEvent;
window['AscCommon'].check_KeyboardEvent2 = check_KeyboardEvent2;
window['AscCommon'].check_MouseMoveEvent = check_MouseMoveEvent;
window['AscCommon'].CreateMouseUpEventObject = CreateMouseUpEventObject;
window['AscCommon'].getMouseButton = getMouseButton;
window['AscCommon'].check_MouseUpEvent = check_MouseUpEvent;
window['AscCommon'].check_MouseDownEvent = check_MouseDownEvent;
window['AscCommon'].Window_OnMouseUp = Window_OnMouseUp;
window['AscCommon'].button_eventHandlers = button_eventHandlers;
window['AscCommon'].emulateKeyDown = emulateKeyDown;
window['AscCommon'].check_MouseClickOnUp = check_MouseClickOnUp;
})(window);

View File

@ -1,282 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
(function(){
function setCanvasSize(element, width, height, is_correction)
{
if (element.width === width && element.height === height)
return;
if (true !== is_correction)
{
element.width = width;
element.height = height;
return;
}
var data = element.getContext("2d").getImageData(0, 0, element.width, element.height);
element.width = width;
element.height = height;
element.getContext("2d").putImageData(data, 0, 0);
};
AscCommon.calculateCanvasSize = function(element, is_correction, is_wait_correction)
{
if (true !== is_correction && undefined !== element.correctionTimeout)
{
clearTimeout(element.correctionTimeout);
element.correctionTimeout = undefined;
}
var scale = AscCommon.AscBrowser.retinaPixelRatio;
if (Math.abs(scale - (scale >> 0)) < 0.001)
{
setCanvasSize(element,
scale * parseInt(element.style.width),
scale * parseInt(element.style.height),
is_correction);
return;
}
var rect = element.getBoundingClientRect();
var isCorrectRect = (rect.width === 0 && rect.height === 0) ? false : true;
if (is_wait_correction || !isCorrectRect)
{
var isNoVisibleElement = false;
if (element.style.display === "none")
isNoVisibleElement = true;
else if (element.parentNode && element.parentNode.style.display === "none")
isNoVisibleElement = true;
if (!isNoVisibleElement)
{
element.correctionTimeout = setTimeout(function (){
AscCommon.calculateCanvasSize(element, true);
}, 100);
}
if (!isCorrectRect)
{
var style_width = parseInt(element.style.width);
var style_height = parseInt(element.style.height);
rect = {
x: 0, left: 0,
y: 0, top: 0,
width: style_width, right: style_width,
height: style_height, bottom: style_height
};
}
}
setCanvasSize(element,
Math.round(scale * rect.right) - Math.round(scale * rect.left),
Math.round(scale * rect.bottom) - Math.round(scale * rect.top),
is_correction);
};
function loadScript(url, onSuccess, onError)
{
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
script.onload = onSuccess;
script.onerror = onError;
document.head.appendChild(script);
}
var documentScriptUrl = document.currentScript ? document.currentScript.src : "";
function CViewer(parent, options)
{
this.isLoadAllFonts = (AscFonts.g_font_files.length > 1) ? true : false;
this.allFontsUrl = "";
this.fontsErrorCounter = 0;
this.fontsErrorMax = 3;
this.options = options;
this.api = this.checkOptions();
this.viewer = new AscCommon.CViewer(parent, this.api);
}
CViewer.prototype.isInitFonts = false;
CViewer.prototype["open"] = function(data)
{
if (!this.isLoadAllFonts && this.allFontsUrl !== "")
{
this.data = data;
this.checkFonts();
return;
}
this.initFonts();
this.viewer.open(data);
};
CViewer.prototype["createThumbnails"] = function(parent)
{
var oThumbnails = new AscCommon.ThumbnailsControl(parent)
this.viewer.setThumbnailsControl(oThumbnails);
return oThumbnails;
};
CViewer.prototype["registerEvent"] = function(name, callback)
{
this.viewer.registerEvent(name, callback);
};
CViewer.prototype["resize"] = function()
{
this.viewer.resize();
};
CViewer.prototype["navigate"] = function(node)
{
return this.viewer.navigate(node);
};
CViewer.prototype["getEngine"] = function()
{
return this.viewer;
};
// private
CViewer.prototype.initFonts = function()
{
if (!this.isInitFonts)
{
this.isInitFonts = true;
AscFonts.checkAllFonts();
AscFonts.g_fontApplication.Init();
AscCommon.g_font_loader.fontFiles = AscFonts.g_font_files;
AscCommon.g_font_loader.fontInfos = AscFonts.g_font_infos;
AscCommon.g_font_loader.map_font_index = AscFonts.g_map_font_index;
}
};
CViewer.prototype.checkFonts = function()
{
var onSuccess = function() {
this.isLoadAllFonts = true;
this.open(this.data);
delete this.data;
};
var onError = function() {
this.fontsErrorCounter++;
if (this.fontsErrorCounter === this.fontsErrorMax)
{
console.error("cannot load AllFonts.js");
return;
}
this.checkFonts();
};
loadScript(this.allFontsUrl, onSuccess.bind(this), onError.bind(this));
};
CViewer.prototype.checkOptions = function()
{
if (this.options)
{
var sAllFontsUrl = "";
var sModuleUrl = "";
var sFontsPath = "";
if (this.options["sdkjsPath"])
{
sAllFontsUrl = this.options["sdkjsPath"] + "/common/AllFonts.js";
sModuleUrl = this.options["sdkjsPath"] + "/pdf/src/engine/";
sFontsPath = this.options["sdkjsPath"] + "/../fonts/"
}
if (this.options["enginePath"])
sModuleUrl = this.options["enginePath"];
if (this.options["fontsPath"])
sFontsPath = this.options["fontsPath"];
if (documentScriptUrl !== "")
{
var scriptDirectory = documentScriptUrl;
scriptDirectory = scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/") + 1);
if (sAllFontsUrl === "")
sAllFontsUrl = scriptDirectory + "../../../common/AllFonts.js";
if (sModuleUrl === "")
sModuleUrl = scriptDirectory;
if (sFontsPath === "")
sFontsPath = scriptDirectory + "../../../../fonts/";
}
this.allFontsUrl = sAllFontsUrl;
if (sModuleUrl !== "")
window["AscViewer"]["baseEngineUrl"] = sModuleUrl;
if (sFontsPath !== "")
AscCommon.g_font_loader.fontFilesPath = sFontsPath;
if (this.options["theme"])
AscCommon.updateGlobalSkin(this.options["theme"]);
}
return {
isMobileVersion : false,
isSeparateModule : true,
baseFontsPath : (this.options && this.options["fontsPath"]) ? this.options["fontsPath"] : undefined,
getPageBackgroundColor : function() {
// TODO: get color from theme
if (this.isDarkMode)
return [0x3A, 0x3A, 0x3A];
return [0xFF, 0xFF, 0xFF];
},
WordControl : {
NoneRepaintPages : false
},
sendEvent : function() {
}
};
};
window["AscViewer"] = window["AscViewer"] || {};
window["AscViewer"]["CViewer"] = CViewer;
window["AscViewer"]["checkApplicationScale"] = function()
{
var zoomValue = AscCommon.checkDeviceScale();
AscCommon.AscBrowser.retinaPixelRatio = zoomValue.applicationPixelRatio;
AscCommon.AscBrowser.zoom = zoomValue.zoom;
AscCommon.correctApplicationScale(zoomValue);
};
})();

View File

@ -1,91 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
window.AscInterface = window.AscInterface || {};
AscInterface.updateStructure = function(structure)
{
var elem = document.getElementById("bookmarksTree");
elem.innerHTML = "";
if (!structure)
return;
var jsonStructure = { children: [], parent: jsonStructure };
var currentLevel = 0;
var currentElement = jsonStructure;
var parent, newElem, item, level;
function makeFolder(obj) {
obj.open = false;
obj.type = Tree.FOLDER;
obj.selected = true;
}
for (var len = structure.length, index = 0; index < len; index++)
{
item = structure[index];
level = item.level;
if (currentLevel == level)
{
// такой же уровень - общий родитель
parent = currentElement.parent;
}
else if ((currentLevel + 1) == level)
{
// следующий уровень
parent = currentElement;
}
else
{
// возврат на нужный уровень
parent = currentElement;
while (level < parent.level)
parent = parent.parent;
parent = parent.parent;
}
newElem = { name: item.description, id: index, children : [], parent: parent, level : level };
parent.children.push(newElem);
makeFolder(parent);
currentLevel = item.level;
currentElement = newElem;
}
var treeElem = new Tree(elem, { navigate: true });
treeElem.json(jsonStructure.children);
// подписываемся после
treeElem.on('select', function(node) {
window.Viewer.navigate(parseInt(node.getAttribute("nodeId")));
});
};

View File

@ -1,203 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
"use strict";
(
/**
* @param {Window} window
* @param {undefined} undefined
*/
function (window, undefined) {
var AscBrowser = {
userAgent : "",
isIE : false,
isMacOs : false,
isSafariMacOs : false,
isAppleDevices : false,
isAndroid : false,
isMobile : false,
isGecko : false,
isChrome : false,
isOpera : false,
isOperaOld : false,
isWebkit : false,
isSafari : false,
isArm : false,
isMozilla : false,
isLinuxOS : false,
retinaPixelRatio : 1,
isVivaldiLinux : false,
isSailfish : false,
isEmulateDevicePixelRatio : false,
isNeedEmulateUpload : false,
chromeVersion : 70,
iosVersion : 13,
isAndroidNativeApp : false
};
// user agent lower case
AscBrowser.userAgent = navigator.userAgent.toLowerCase();
// ie detect
AscBrowser.isIE = (AscBrowser.userAgent.indexOf("msie") > -1 ||
AscBrowser.userAgent.indexOf("trident") > -1 ||
AscBrowser.userAgent.indexOf("edge") > -1);
AscBrowser.isIeEdge = (AscBrowser.userAgent.indexOf("edge/") > -1);
AscBrowser.isIE9 = (AscBrowser.userAgent.indexOf("msie9") > -1 || AscBrowser.userAgent.indexOf("msie 9") > -1);
AscBrowser.isIE10 = (AscBrowser.userAgent.indexOf("msie10") > -1 || AscBrowser.userAgent.indexOf("msie 10") > -1);
// macOs detect
AscBrowser.isMacOs = (AscBrowser.userAgent.indexOf('mac') > -1);
// chrome detect
AscBrowser.isChrome = !AscBrowser.isIE && (AscBrowser.userAgent.indexOf("chrome") > -1);
if (AscBrowser.isChrome)
{
var checkVersion = AscBrowser.userAgent.match(/chrom(e|ium)\/([0-9]+)\./);
if (checkVersion && checkVersion[2])
AscBrowser.chromeVersion = parseInt(checkVersion[2], 10);
}
// safari detect
AscBrowser.isSafari = !AscBrowser.isIE && !AscBrowser.isChrome && (AscBrowser.userAgent.indexOf("safari") > -1);
// macOs safari detect
AscBrowser.isSafariMacOs = (AscBrowser.isSafari && AscBrowser.isMacOs);
// apple devices detect
AscBrowser.isAppleDevices = (AscBrowser.userAgent.indexOf("ipad") > -1 ||
AscBrowser.userAgent.indexOf("iphone") > -1 ||
AscBrowser.userAgent.indexOf("ipod") > -1);
if (!AscBrowser.isAppleDevices && AscBrowser.isSafariMacOs && navigator.platform === "MacIntel" && (navigator.maxTouchPoints > 1))
AscBrowser.isAppleDevices = true;
if (AscBrowser.isAppleDevices)
{
var iosversion = AscBrowser.iosVersion;
try
{
var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
if (!v) v = (navigator.appVersion).match(/Version\/(\d+).(\d+)/);
//[parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)];
iosversion = parseInt(v[1], 10);
}
catch (err)
{
}
AscBrowser.iosVersion = iosversion;
}
// android devices detect
AscBrowser.isAndroid = (AscBrowser.userAgent.indexOf("android") > -1);
// mobile detect
AscBrowser.isMobile = /android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent || navigator.vendor || window.opera);
// gecko detect
AscBrowser.isGecko = (AscBrowser.userAgent.indexOf("gecko/") > -1);
// opera detect
AscBrowser.isOpera = (!!window.opera || AscBrowser.userAgent.indexOf("opr/") > -1);
AscBrowser.isOperaOld = (!!window.opera);
// webkit detect
AscBrowser.isWebkit = !AscBrowser.isIE && (AscBrowser.userAgent.indexOf("webkit") > -1);
// arm detect
AscBrowser.isArm = (AscBrowser.userAgent.indexOf("arm") > -1);
AscBrowser.isMozilla = !AscBrowser.isIE && (AscBrowser.userAgent.indexOf("firefox") > -1);
AscBrowser.isLinuxOS = (AscBrowser.userAgent.indexOf(" linux ") > -1);
AscBrowser.isVivaldiLinux = AscBrowser.isLinuxOS && (AscBrowser.userAgent.indexOf("vivaldi") > -1);
AscBrowser.isSailfish = (AscBrowser.userAgent.indexOf("sailfish") > -1);
AscBrowser.isEmulateDevicePixelRatio = (AscBrowser.userAgent.indexOf("emulatedevicepixelratio") > -1);
AscBrowser.isNeedEmulateUpload = (AscBrowser.userAgent.indexOf("needemulateupload") > -1);
AscBrowser.isAndroidNativeApp = (AscBrowser.userAgent.indexOf("ascandroidwebview") > -1);
AscBrowser.zoom = 1;
AscBrowser.isCustomScaling = function()
{
return (Math.abs(AscBrowser.retinaPixelRatio - 1) > 0.001) ? true : false;
};
AscBrowser.isCustomScalingAbove2 = function()
{
return (AscBrowser.retinaPixelRatio > 1.999) ? true : false;
};
AscBrowser.checkZoom = function()
{
if (AscBrowser.isSailfish && AscBrowser.isEmulateDevicePixelRatio)
{
var scale = 1;
if (screen.width <= 540)
scale = 1.5;
else if (screen.width > 540 && screen.width <= 768)
scale = 2;
else if (screen.width > 768)
scale = 3;
AscBrowser.retinaPixelRatio = scale;
window.devicePixelRatio = scale;
return;
}
var zoomValue = AscCommon.checkDeviceScale();
AscBrowser.retinaPixelRatio = zoomValue.applicationPixelRatio;
AscBrowser.zoom = zoomValue.zoom;
AscCommon.correctApplicationScale(zoomValue);
};
AscBrowser.checkZoom();
AscBrowser.convertToRetinaValue = function(value, isScale)
{
if (isScale === true)
return ((value * AscBrowser.retinaPixelRatio) + 0.5) >> 0;
else
return ((value / AscBrowser.retinaPixelRatio) + 0.5) >> 0;
};
//--------------------------------------------------------export----------------------------------------------------
window['AscCommon'] = window['AscCommon'] || {};
window['AscCommon'].AscBrowser = AscBrowser;
})(window);

View File

@ -1,119 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
"use strict";
(function (window, undefined) {
var supportedScaleValues = [1, 1.25, 1.5, 1.75, 2, 2.5, 3, 3.5, 4, 4.5, 5];
if (window["AscDesktopEditor"] && window["AscDesktopEditor"]["GetSupportedScaleValues"])
supportedScaleValues = window["AscDesktopEditor"]["GetSupportedScaleValues"]();
// uncomment to debug all scales
//supportedScaleValues = [];
var isCorrectApplicationScaleEnabled = (function(){
if (supportedScaleValues.length === 0)
return false;
var userAgent = navigator.userAgent.toLowerCase();
var isAndroid = (userAgent.indexOf("android") > -1);
var isIE = (userAgent.indexOf("msie") > -1 || userAgent.indexOf("trident") > -1 || userAgent.indexOf("edge") > -1);
var isChrome = !isIE && (userAgent.indexOf("chrome") > -1);
var isOperaOld = (!!window.opera);
var isMobile = /android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent || navigator.vendor || window.opera);
if (isAndroid || !isChrome || isOperaOld || isMobile || !document || !document.firstElementChild || !document.body)
return false;
return true;
})();
window['AscCommon'] = window['AscCommon'] || {};
window['AscCommon'].checkDeviceScale = function()
{
var retValue = {
zoom: 1,
devicePixelRatio: window.devicePixelRatio,
applicationPixelRatio: window.devicePixelRatio,
correct : false
};
if (!isCorrectApplicationScaleEnabled)
return retValue;
var systemScaling = window.devicePixelRatio;
var bestIndex = 0;
var bestDistance = Math.abs(supportedScaleValues[0] - systemScaling);
var currentDistance = 0;
for (var i = 1, len = supportedScaleValues.length; i < len; i++)
{
if (true)
{
// это "подстройка под интерфейс" - после убирания этого в общий код - удалить
if (Math.abs(supportedScaleValues[i] - systemScaling) > 0.0001)
{
if (supportedScaleValues[i] > (systemScaling - 0.0001))
break;
}
}
currentDistance = Math.abs(supportedScaleValues[i] - systemScaling);
if (currentDistance < (bestDistance - 0.0001))
{
bestDistance = currentDistance;
bestIndex = i;
}
}
retValue.applicationPixelRatio = supportedScaleValues[bestIndex];
if (Math.abs(retValue.devicePixelRatio - retValue.applicationPixelRatio) > 0.01)
{
retValue.zoom = retValue.devicePixelRatio / retValue.applicationPixelRatio;
retValue.correct = true;
}
return retValue;
};
var oldZoomValue = 1;
window['AscCommon'].correctApplicationScale = function(zoomValue)
{
if (!zoomValue.correct && Math.abs(zoomValue.zoom - oldZoomValue) < 0.0001)
return;
oldZoomValue = zoomValue.zoom;
var firstElemStyle = document.firstElementChild.style;
if (Math.abs(oldZoomValue - 1) < 0.001)
firstElemStyle.zoom = "normal";
else
firstElemStyle.zoom = 1.0 / oldZoomValue;
};
})(window);

View File

@ -1,339 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
"use strict";
(function (window, undefined)
{
/**
* @param {_start} start range value
* @param {_end} end range value
* @param {_name} not used range name
*/
function CSymbolRange(_start, _end, _name)
{
this.Start = _start;
this.End = _end;
this.Name = _name;
}
CSymbolRange.prototype["getStart"] = function() { return this.Start; };
CSymbolRange.prototype["getEnd"] = function() { return this.End; };
CSymbolRange.prototype["getName"] = function() { return this.Name; };
function CFontByCharacter()
{
this.Ranges = [];
this.UsedRanges = [];
this.LastRange = null;
this.FontsByRange = {};
this.FontsByRangeCount = 0;
this.ExtendFontsByRangeCount = 0;
this.IsUseNoSquaresMode = true;
this.CallbackObj = { _this : null, _callback : null };
}
CFontByCharacter.prototype =
{
init : function(infos)
{
var fonts = window["__fonts_ranges"];
if (!fonts)
return;
var index = 0;
var count = fonts.length / 3;
for (var i = 0; i < count; i++)
{
if (!infos[fonts[index + 2]])
{
this.Ranges.splice(0, this.Ranges.length);
return;
}
this.Ranges.push(new CSymbolRange(fonts[index], fonts[index + 1], infos[fonts[index + 2]][0]));
index += 3;
}
fonts = null;
delete window["__fonts_ranges"];
},
getRangeBySymbol : function(_char, _array)
{
// search range by symbol
var _start = 0;
var _end = _array.length - 1;
var _center = 0;
var _range = null;
if (_start > _end)
return null;
while (_start < _end)
{
_center = (_start + _end) >> 1;
_range = _array[_center];
if (_range.Start > _char)
_end = _center - 1;
else if (_range.End < _char)
_start = _center + 1;
else
return _array[_center];
}
if (_start > _end)
return null;
_range = _array[_start];
if (_range.Start > _char || _range.End < _char)
return null;
return _array[_start];
},
getFontBySymbol : function(_char)
{
if (!this.IsUseNoSquaresMode)
return "";
if (undefined === _char || 0 == _char)
return "";
if (this.LastRange)
{
if (this.LastRange.Start <= _char && _char <= this.LastRange.End)
return this.LastRange.Name;
}
// ищем среди уже найденных
var _range = this.getRangeBySymbol(_char, this.UsedRanges);
if (_range != null)
{
this.LastRange = _range;
return _range.Name;
}
_range = this.getRangeBySymbol(_char, this.Ranges);
if (!_range)
return "";
this.UsedRanges.push(_range);
this.LastRange = _range;
if (!this.FontsByRange[_range.Name])
{
this.FontsByRange[_range.Name] = _range.Name;
this.FontsByRangeCount++;
}
return _range.Name;
},
getFontsByString : function(_text)
{
if (!this.IsUseNoSquaresMode)
return false;
if (!_text)
return false;
var oldCount = this.FontsByRangeCount;
for (var i = _text.getUnicodeIterator(); i.check(); i.next())
{
AscFonts.FontPickerByCharacter.getFontBySymbol(i.value());
}
return (this.FontsByRangeCount != oldCount);
},
getFontsByString2 : function(_array)
{
if (!this.IsUseNoSquaresMode)
return false;
if (!_array)
return false;
var oldCount = this.FontsByRangeCount;
for (var i = 0; i < _array.length; ++i)
{
if (32 === _array[i])
continue;
AscFonts.FontPickerByCharacter.getFontBySymbol(_array[i]);
}
return (this.FontsByRangeCount != oldCount);
},
isExtendFonts : function()
{
return this.ExtendFontsByRangeCount != this.FontsByRangeCount;
},
extendFonts : function(fonts, isNoRealExtend)
{
if (this.ExtendFontsByRangeCount == this.FontsByRangeCount)
return;
var isFound;
for (var i in this.FontsByRange)
{
isFound = false;
for (var j in fonts)
{
if (fonts[j].name == this.FontsByRange[i])
{
isFound = true;
break;
}
}
if (!isFound)
fonts[fonts.length] = new AscFonts.CFont(this.FontsByRange[i], 0, "", 0, null);
}
if (true !== isNoRealExtend)
this.ExtendFontsByRangeCount = this.FontsByRangeCount;
},
checkTextLight : function(text, isCodes)
{
if (isCodes !== true)
{
if (!this.getFontsByString(text))
return false;
}
else
{
if (!this.getFontsByString2(text))
return false;
}
var fonts = [];
this.extendFonts(fonts, true);
if (false === AscCommon.g_font_loader.CheckFontsNeedLoading(fonts))
return false;
return true;
},
loadFonts : function(_this, _callback)
{
var fonts = [];
this.extendFonts(fonts);
this.CallbackObj._this = _this;
this.CallbackObj._callback = _callback;
var _editor = window["Asc"]["editor"] ? window["Asc"]["editor"] : window.editor;
_editor.asyncMethodCallback = function() {
var _t = AscFonts.FontPickerByCharacter.CallbackObj;
_t._callback.call(_t._this);
_t._this = null;
_t._callback = null;
};
AscCommon.g_font_loader.LoadDocumentFonts2(fonts);
return true;
},
checkText : function(text, _this, _callback, isCodes, isOnlyAsync, isCheckSymbols)
{
if(window["NATIVE_EDITOR_ENJINE"])
{
_callback.call(_this);
return false;
}
if (isCheckSymbols !== false)
{
if (isCodes !== true)
{
if (!this.getFontsByString(text))
{
if (!isOnlyAsync)
_callback.call(_this);
return false;
}
}
else
{
if (!this.getFontsByString2(text))
{
if (!isOnlyAsync)
_callback.call(_this);
return false;
}
}
}
var fonts = [];
this.extendFonts(fonts);
if (false === AscCommon.g_font_loader.CheckFontsNeedLoading(fonts))
{
if (!isOnlyAsync)
_callback.call(_this);
return false;
}
this.CallbackObj._this = _this;
this.CallbackObj._callback = _callback;
var _editor = window["Asc"]["editor"] ? window["Asc"]["editor"] : window.editor;
_editor.asyncMethodCallback = function() {
var _t = AscFonts.FontPickerByCharacter.CallbackObj;
_t._callback.call(_t._this);
_t._this = null;
_t._callback = null;
};
AscCommon.g_font_loader.LoadDocumentFonts2(fonts);
return true;
}
};
window['AscFonts'] = window['AscFonts'] || {};
window['AscFonts'].IsCheckSymbols = false;
window['AscFonts'].FontPickerByCharacter = new CFontByCharacter();
window['AscFonts']['getSymbolRanges'] = function() { return window['AscFonts'].FontPickerByCharacter.Ranges; };
})(window);

View File

@ -1,233 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
"use strict";
(function (window, undefined)
{
window['AscFonts'] = window['AscFonts'] || {};
window['AscFonts'].isEngineReady = false;
window['AscFonts'].api = null;
window['AscFonts'].onSuccess = null;
window['AscFonts'].onError = null;
window['AscFonts'].maxLoadingIndex = 2; // engine (1+1)
window['AscFonts'].curLoadingIndex = 0;
window['AscFonts'].allocate = function(size)
{
if (typeof(Uint8Array) != 'undefined' && !window.opera)
return new Uint8Array(size);
var arr = new Array(size);
for (var i=0;i<size;i++)
arr[i] = 0;
return arr;
};
window['AscFonts'].allocateData = function(size)
{
return { data : window['AscFonts'].allocate(size) };
};
window['AscFonts']['onLoadModule'] = function()
{
++window['AscFonts'].curLoadingIndex;
if (window['AscFonts'].curLoadingIndex === window['AscFonts'].maxLoadingIndex)
{
onLoadFontsModule(window, undefined);
window['AscFonts'].isEngineReady = true;
window['AscFonts'].onSuccess && window['AscFonts'].onSuccess.call(window['AscFonts'].api);
delete window['AscFonts'].curLoadingIndex;
delete window['AscFonts'].maxLoadingIndex;
delete window['AscFonts'].api;
delete window['AscFonts'].onSuccess;
delete window['AscFonts'].onError;
}
};
window['AscFonts'].load = function(api, onSuccess, onError)
{
window['AscFonts'].api = api;
window['AscFonts'].onSuccess = onSuccess;
window['AscFonts'].onError = onError;
if (window["NATIVE_EDITOR_ENJINE"] === true || window["IS_NATIVE_EDITOR"] === true || window["Native"] !== undefined)
{
window['AscFonts'].onSuccess && window['AscFonts'].onSuccess.call(window['AscFonts'].api);
return;
}
var url = "../../../../sdkjs/common/libfont/engine/";
var useWasm = false;
var webAsmObj = window["WebAssembly"];
if (typeof webAsmObj === "object")
{
if (typeof webAsmObj["Memory"] === "function")
{
if ((typeof webAsmObj["instantiateStreaming"] === "function") || (typeof webAsmObj["instantiate"] === "function"))
useWasm = true;
}
}
// отключаем wasm для мобильных
if (useWasm && (AscCommon.AscBrowser.isAppleDevices || AscCommon.AscBrowser.isAndroid))
useWasm = false;
var engine_name_ext = useWasm ? ".js" : "_ie.js";
var _onSuccess = function(){
};
var _onError = function(){
window['AscFonts'].onError();
};
AscCommon.loadScript(url + "fonts" + engine_name_ext, _onSuccess, _onError);
};
function FontStream(data, size)
{
this.data = data;
this.size = size;
}
window['AscFonts'].FontStream = FontStream;
window['AscFonts'].FT_Common = {
UintToInt : function(v)
{
return (v>2147483647)?v-4294967296:v;
},
UShort_To_Short : function(v)
{
return (v>32767)?v-65536:v;
},
IntToUInt : function(v)
{
return (v<0)?v+4294967296:v;
},
Short_To_UShort : function(v)
{
return (v<0)?v+65536:v;
}
};
function CPointer()
{
this.obj = null;
this.data = null;
this.pos = 0;
}
function FT_Memory()
{
this.canvas = document.createElement('canvas');
this.canvas.width = 1;
this.canvas.height = 1;
this.ctx = this.canvas.getContext('2d');
this.Alloc = function(size)
{
var p = new CPointer();
p.obj = this.ctx.createImageData(1, ((size + 3) >> 2));
p.data = p.obj.data;
p.pos = 0;
return p;
};
this.AllocHeap = function()
{
// TODO: нужно посмотреть, как эта память будет использоваться.
// нужно ли здесь делать стек, либо все время от нуля делать??
};
this.CreateStream = function(size)
{
var _size = ((size + 3) >> 2);
var obj = this.ctx.createImageData(1, _size);
return new FontStream(obj.data, _size);
};
}
window['AscFonts'].FT_Memory = FT_Memory;
window['AscFonts'].g_memory = new FT_Memory();
// память для растеризации буквы
function CRasterMemory()
{
this.width = 0;
this.height = 0;
this.pitch = 0;
this.m_oBuffer = null;
this.CheckSize = function(w, h)
{
if (this.width < (w + 1) || this.height < (h + 1))
{
this.width = Math.max(this.width, w + 1);
this.pitch = 4 * this.width;
this.height = Math.max(this.height, h + 1);
this.m_oBuffer = null;
this.m_oBuffer = window['AscFonts'].g_memory.ctx.createImageData(this.width, this.height);
}
};
}
window['AscFonts'].raster_memory = new CRasterMemory();
window['AscFonts'].registeredFontManagers = [];
window['AscFonts'].getDefaultBlitting = function()
{
var isUseMap = false;
if (AscCommon.AscBrowser.isAndroidNativeApp)
isUseMap = true;
else if (AscCommon.AscBrowser.isIE && !AscCommon.AscBrowser.isArm)
isUseMap = true;
return isUseMap;
};
window['AscFonts'].setDefaultBlitting = function(value)
{
var defaultValue = window['AscFonts'].getDefaultBlitting();
var newValue = value ? defaultValue : !defaultValue;
if (window['AscFonts'].use_map_blitting === newValue)
return;
window['AscFonts'].use_map_blitting = newValue;
var arrManagers = window['AscFonts'].registeredFontManagers;
for (var i = 0, count = arrManagers.length; i < count; i++)
{
arrManagers[i].ClearFontsRasterCache();
arrManagers[i].InitializeRasterMemory();
}
};
window['AscFonts'].use_map_blitting = window['AscFonts'].getDefaultBlitting();
})(window, undefined);

File diff suppressed because one or more lines are too long

View File

@ -1,23 +0,0 @@
import "./AllFonts.js";
import "./device_scale.js";
import "./browser.js";
import "./stringserialize.js";
import "./skin.js";
import "./font/loader.js";
import "./font/map.js";
import "./font/character.js";
import "./SerializeCommonWordExcel.js";
import "./Externals.js";
import "./GlobalLoaders.js";
import "./scroll.js";
import "./WorkEvents.js";
import "./Overlay.js";
// import "./bookmarks.js";
import "./thumbnails.js";
import "./file.js";
import "./api.js";

View File

@ -1,500 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
"use strict";
// не скрываем переменные, скин используется напрямую в sdk-all.js
// а экспорт в AscCommon - только для sdk-all-min.js
// если хочется скрыть - то везде GlobalSkin => AscCommon.GlobalSkin
var EditorSkins = {
"theme-light": {
Name: "theme-light",
Type: "light",
RulersButton: false,
NavigationButtons: false,
BackgroundColor: "#EEEEEE",
PageOutline: "#BBBEC2",
RulerDark: "#D9D9D9",
RulerLight: "#FFFFFF",
RulerOutline: "#CBCBCB",
RulerMarkersOutlineColor: "#555555",
RulerMarkersOutlineColorOld: "#AAAAAA",
RulerMarkersFillColor: "#FFFFFF",
RulerMarkersFillColorOld: "#FFFFFF",
RulerTextColor: "#555555",
RulerTabsColor: "#000000",
RulerTabsColorOld: "#828282",
RulerTableColor1: "#FFFFFF",
RulerTableColor2: "#555555",
ScrollBackgroundColor: "#EEEEEE",
ScrollOutlineColor: "#CBCBCB",
ScrollOutlineHoverColor: "#CBCBCB",
ScrollOutlineActiveColor: "#ADADAD",
ScrollerColor: "#F7F7F7",
ScrollerHoverColor: "#C0C0C0",
ScrollerActiveColor: "#ADADAD",
ScrollArrowColor: "#ADADAD",
ScrollArrowHoverColor: "#F7F7F7",
ScrollArrowActiveColor: "#F7F7F7",
ScrollerTargetColor: "#CFCFCF",
ScrollerTargetHoverColor: "#F1F1F1",
ScrollerTargetActiveColor: "#F1F1F1",
/* word */
STYLE_THUMBNAIL_WIDTH: 104,
STYLE_THUMBNAIL_HEIGHT: 40,
isNeedInvertOnActive: false,
ContentControlsBack: "#F1F1F1",
ContentControlsHover: "#D8DADC",
ContentControlsActive: "#7C838A",
ContentControlsText: "#444444",
ContentControlsTextActive: "#FFFFFF",
ContentControlsAnchorActive: "#CFCFCF",
FormsContentControlsOutlineHover: "rgba(0, 0, 0, 0.3)",
FormsContentControlsOutlineActive: "rgba(0, 0, 0, 0.3)",
FormsContentControlsOutlineBorderRadiusHover: 0,
FormsContentControlsOutlineBorderRadiusActive: 2,
FormsContentControlsMarkersBackground: "#FFFFFF",
FormsContentControlsMarkersBackgroundHover: "#E1E1E1",
FormsContentControlsMarkersBackgroundActive: "#CCCCCC",
FormsContentControlsOutlineMoverHover: "#444444",
FormsContentControlsOutlineMoverActive: "#444444",
/* presentations */
BackgroundColorThumbnails: "#F4F4F4",
BackgroundColorThumbnailsActive: "#F4F4F4",
BackgroundColorThumbnailsHover: "#F4F4F4",
ThumbnailsPageOutlineActive: "#848484",
ThumbnailsPageOutlineHover: "#CFCFCF",
ThumbnailsPageNumberText: "#000000",
ThumbnailsPageNumberTextActive: "#000000",
ThumbnailsPageNumberTextHover: "#000000",
ThumbnailsLockColor: "#D34F4F",
BackgroundColorNotes: "#F0F0F0",
THEMES_THUMBNAIL_WIDTH: 88,
THEMES_THUMBNAIL_HEIGHT: 40,
THEMES_LAYOUT_THUMBNAIL_HEIGHT: 68,
BorderSplitterColor: "#CBCBCB",
SupportNotes: true,
SplitterWidthMM: 1,
ThumbnailScrollWidthNullIfNoScrolling: false,
// demonstration
DemBackgroundColor: "#F0F0F0",
DemButtonBackgroundColor: "#FFFFFF",
DemButtonBackgroundColorHover: "#D8DADC",
DemButtonBackgroundColorActive: "#7D858C",
DemButtonBorderColor: "#CFCFCF",
DemButtonTextColor: "#444444",
DemButtonTextColorActive: "#FFFFFF",
DemSplitterColor: "#CBCBCB",
DemTextColor: "#666666",
/* spreadsheets */
//TODO названия не менял. использую такие же как и были ранее. пересмотреть!
Background: "#F0F0F0",
BackgroundActive: "#c1c1c1",
BackgroundHighlighted: "#dfdfdf",
Border: "#d5d5d5",
BorderActive: "#929292",
BorderHighlighted: "#afafaf",
Color: "#363636",
ColorActive: "#363636",
ColorHighlighted: "#6a6a70",
ColorFiltering: "#008636",
BackgroundDark: "#444444",
BackgroundDarkActive: "#111111",
BackgroundDarkHighlighted: "#666666",
ColorDark: "#ffffff",
ColorDarkActive: "#ffffff",
ColorDarkHighlighted: "#c1c1c1",
ColorDarkFiltering: "#7AFFAF",
GroupDataBorder: "#000000",
EditorBorder: "#cbcbcb",
},
"theme-dark": {
Name: "theme-dark",
Type: "dark",
RulersButton: false,
NavigationButtons: false,
BackgroundColor: "#666666",
PageOutline: "#BBBEC2",
RulerDark: "#373737",
RulerLight: "#555555",
RulerOutline: "#2A2A2A",
RulerMarkersOutlineColor: "#B6B6B6",
RulerMarkersOutlineColorOld: "#808080",
RulerMarkersFillColor: "#555555",
RulerMarkersFillColorOld: "#555555",
RulerTextColor: "#B6B6B6",
RulerTabsColor: "#FFFFFF",
RulerTabsColorOld: "#999999",
RulerTableColor1: "#FFFFFF",
RulerTableColor2: "#B2B2B2",
ScrollBackgroundColor: "#666666",
ScrollOutlineColor: "#2A2A2A",
ScrollOutlineHoverColor: "#999999",
ScrollOutlineActiveColor: "#ADADAD",
ScrollerColor: "#404040",
ScrollerHoverColor: "#999999",
ScrollerActiveColor: "#ADADAD",
ScrollArrowColor: "#999999",
ScrollArrowHoverColor: "#404040",
ScrollArrowActiveColor: "#404040",
ScrollerTargetColor: "#999999",
ScrollerTargetHoverColor: "#404040",
ScrollerTargetActiveColor: "#404040",
/* word */
STYLE_THUMBNAIL_WIDTH: 104,
STYLE_THUMBNAIL_HEIGHT: 40,
THEMES_LAYOUT_THUMBNAIL_HEIGHT: 68,
isNeedInvertOnActive: false,
ContentControlsBack: "#F1F1F1",
ContentControlsHover: "#D8DADC",
ContentControlsActive: "#7C838A",
ContentControlsText: "#444444",
ContentControlsTextActive: "#FFFFFF",
ContentControlsAnchorActive: "#CFCFCF",
FormsContentControlsOutlineHover: "rgba(0, 0, 0, 0.3)",
FormsContentControlsOutlineActive: "rgba(0, 0, 0, 0.3)",
FormsContentControlsOutlineBorderRadiusHover: 0,
FormsContentControlsOutlineBorderRadiusActive: 2,
FormsContentControlsMarkersBackground: "#FFFFFF",
FormsContentControlsMarkersBackgroundHover: "#E1E1E1",
FormsContentControlsMarkersBackgroundActive: "#CCCCCC",
FormsContentControlsOutlineMoverHover: "#444444",
FormsContentControlsOutlineMoverActive: "#444444",
/* presentations */
BackgroundColorThumbnails: "#404040",
BackgroundColorThumbnailsActive: "#404040",
BackgroundColorThumbnailsHover: "#404040",
ThumbnailsPageOutlineActive: "#848484",
ThumbnailsPageOutlineHover: "#CFCFCF",
ThumbnailsPageNumberText: "#FFFFFF",
ThumbnailsPageNumberTextActive: "#FFFFFF",
ThumbnailsPageNumberTextHover: "#FFFFFF",
ThumbnailsLockColor: "#D34F4F",
BackgroundColorNotes: "#666666",
THEMES_THUMBNAIL_WIDTH: 88,
THEMES_THUMBNAIL_HEIGHT: 40,
BorderSplitterColor: "#616161",
SupportNotes: true,
SplitterWidthMM: 1,
ThumbnailScrollWidthNullIfNoScrolling: false,
// demonstration
DemBackgroundColor: "#666666",
DemButtonBackgroundColor: "#333333",
DemButtonBackgroundColorHover: "#555555",
DemButtonBackgroundColorActive: "#DDDDDD",
DemButtonBorderColor: "#CFCFCF",
DemButtonTextColor: "#FFFFFF",
DemButtonTextColorActive: "#333333",
DemSplitterColor: "#CBCBCB",
DemTextColor: "#FFFFFF",
/* spreadsheets */
Background: "#666666",
BackgroundActive: "#939393",
BackgroundHighlighted: "#787878",
Border: "#757575",
BorderActive: "#9e9e9e",
BorderHighlighted: "#858585",
Color: "#d9d9d9",
ColorActive: "#d9d9d9",
ColorHighlighted: "#d9d9d9",
ColorFiltering: "#6BEC9F",
BackgroundDark: "#55B27B",
BackgroundDarkActive: "#7AFFAF",
BackgroundDarkHighlighted: "#6EE59F",
ColorDark: "#333",
ColorDarkActive: "#333",
ColorDarkHighlighted: "#333",
ColorDarkFiltering: "#ffffff",
GroupDataBorder: "#ffffff",
EditorBorder: "#2a2a2a",
},
};
/*
функция для генерации "else" updateGlobalSkin
function setter_from_interface(obj)
{
var code = "";
for (var i in obj) {
code += ("if (obj[\"" + i + "\"]) GlobalSkin." + i + " = obj[\"" + i + "\"];\n");
}
copy(code);
}
*/
export var GlobalSkin = EditorSkins["theme-light"];
function updateGlobalSkinColors(theme) {
var skin = GlobalSkin;
var correctColor = function (c) {
return AscCommon.RgbaTextToRgbaHex(c);
};
var colorMap = {
BackgroundColor: "canvas-background",
PageOutline: "canvas-page-border",
RulerDark: "canvas-ruler-margins-background",
RulerLight: "canvas-ruler-background",
RulerOutline: "canvas-ruler-border",
RulerMarkersOutlineColor: "canvas-ruler-handle-border",
RulerMarkersOutlineColorOld: "canvas-ruler-handle-border-disabled",
RulerMarkersFillColor: "background-normal",
RulerMarkersFillColorOld: "background-normal",
RulerTextColor: "canvas-ruler-mark",
RulerTabsColor: "canvas-high-contrast",
RulerTabsColorOld: "canvas-high-contrast-disabled",
RulerTableColor1: "background-normal",
RulerTableColor2: "canvas-ruler-handle-border",
ScrollBackgroundColor: "canvas-background",
ScrollOutlineColor: "canvas-scroll-thumb-border",
ScrollOutlineHoverColor: "canvas-scroll-thumb-border-hover",
ScrollOutlineActiveColor: "canvas-scroll-thumb-border-pressed",
ScrollerColor: "canvas-scroll-thumb",
ScrollerHoverColor: "canvas-scroll-thumb-hover",
ScrollerActiveColor: "canvas-scroll-thumb-pressed",
ScrollArrowColor: "canvas-scroll-arrow",
ScrollArrowHoverColor: "canvas-scroll-arrow-hover",
ScrollArrowActiveColor: "canvas-scroll-arrow-pressed",
ScrollerTargetColor: "canvas-scroll-thumb-target",
ScrollerTargetHoverColor: "canvas-scroll-thumb-target-hover",
ScrollerTargetActiveColor: "canvas-scroll-thumb-target-pressed",
/* presentations */
BackgroundColorThumbnails: "background-toolbar",
BackgroundColorThumbnailsActive: "background-toolbar",
BackgroundColorThumbnailsHover: "background-toolbar",
ThumbnailsPageOutlineActive: "border-preview-select",
ThumbnailsPageOutlineHover: "border-preview-hover",
ThumbnailsPageNumberText: "text-normal",
ThumbnailsPageNumberTextActive: "text-normal",
ThumbnailsPageNumberTextHover: "text-normal",
BackgroundColorNotes: "canvas-background",
BorderSplitterColor: "border-toolbar",
// demonstration
DemBackgroundColor: "background-toolbar",
DemButtonBackgroundColor: "background-normal",
DemButtonBackgroundColorHover: "highlight-buttin-hover",
DemButtonBackgroundColorActive: "highlight-button-pressed",
DemButtonBorderColor: "border-regular-control",
DemButtonTextColor: "text-normal",
DemButtonTextColorActive: "text-normal-pressed",
DemSplitterColor: "border-divider",
DemTextColor: "text-normal",
/* spreadsheets */
Background: "canvas-background",
BackgroundActive: "canvas-cell-title-selected",
BackgroundHighlighted: "canvas-cell-title-hover",
Border: "canvas-cell-title-border",
BorderActive: "canvas-cell-title-border-selected",
BorderHighlighted: "canvas-cell-title-border-hover",
Color: "canvas-cell-title",
ColorActive: "canvas-cell-title",
ColorHighlighted: "canvas-cell-title",
BackgroundDark: "canvas-dark-cell-title",
BackgroundDarkActive: "canvas-dark-cell-title-selected",
BackgroundDarkHighlighted: "canvas-dark-cell-title-hover",
ColorDark: "canvas-dark-cell-title-text",
ColorDarkActive: "canvas-dark-cell-title-text",
ColorDarkHighlighted: "canvas-dark-cell-title-text",
ColorDarkFiltering: "canvas-dark-cell-title-text-filtered",
GroupDataBorder: "canvas-high-contrast",
EditorBorder: "border-toolbar",
};
// корректируем цвета для старого хрома:
// в старых хромах (desktop windows XP)
// если начинается цвет с цифры (#0-9) - то помечается символом \3 (конец текста)
for (var item in theme) {
var testValue = theme[item];
if (typeof testValue !== "string") continue;
if (0 === testValue.indexOf("#\\3")) {
testValue = testValue.replace("\\3", "");
testValue = testValue.replace(" ", "");
theme[item] = testValue;
}
}
for (var color in colorMap) {
if (undefined === GlobalSkin[color]) continue;
if ("" === colorMap[color]) continue;
if (undefined === theme[colorMap[color]]) continue;
if (0 === GlobalSkin[color].indexOf("rgb"))
GlobalSkin[color] = theme[colorMap[color]];
else GlobalSkin[color] = correctColor(theme[colorMap[color]]);
}
}
function updateGlobalSkin(obj) {
if (!obj) return;
if (typeof obj === "string") {
var name = obj;
obj = {
name: name,
type: -1 !== name.indexOf("dark") ? "dark" : "light",
};
}
if (obj["name"] && undefined !== EditorSkins[obj["name"]])
GlobalSkin = EditorSkins[obj["name"]];
else if (obj["type"]) {
for (var item in EditorSkins) {
if (obj["type"] === EditorSkins[item].Type) {
GlobalSkin = EditorSkins[item];
break;
}
}
}
updateGlobalSkinColors(obj);
for (var item in obj) GlobalSkin[item] = obj[item];
if (window.g_asc_plugins) window.g_asc_plugins.onThemeChanged(GlobalSkin);
window["AscCommon"].GlobalSkin = GlobalSkin;
}
window["AscCommon"] = window["AscCommon"] || {};
window["AscCommon"].GlobalSkin = GlobalSkin;
window["AscCommon"].updateGlobalSkin = updateGlobalSkin;
window["AscCommon"].RgbaHexToRGBA = function (color) {
var index = 0;
if ("#".charCodeAt(0) === color.charCodeAt(0)) index++;
var ret = {
R: 0,
G: 0,
B: 0,
A: 255,
};
if (6 <= color.length) {
ret.R = parseInt(color.substring(index, index + 2), 16);
ret.G = parseInt(color.substring(index + 2, index + 4), 16);
ret.B = parseInt(color.substring(index + 4, index + 6), 16);
} else {
ret.R = parseInt(color.substring(index, index + 1), 16);
ret.G = parseInt(color.substring(index + 1, index + 2), 16);
ret.B = parseInt(color.substring(index + 2, index + 3), 16);
ret.R = (ret.R << 4) | ret.R;
ret.G = (ret.G << 4) | ret.G;
ret.B = (ret.B << 4) | ret.B;
}
return ret;
};
window["AscCommon"].RgbaTextToRgbaHex = function (color) {
var toHex = function (c) {
var res = Number(c).toString(16);
return res.length === 1 ? "0" + res : res;
};
if (0 !== color.indexOf("rgb")) {
if (color.length < 6) {
var rgba = AscCommon.RgbaHexToRGBA(color);
return "#" + toHex(rgba.R) + toHex(rgba.G) + toHex(rgba.B);
}
return color;
}
var start = color.indexOf("(");
var end = color.indexOf(")");
var tmp = color.substring(start + 1, end);
var colors = tmp.split(",");
for (var i in colors) colors[i] = colors[i].trim();
var r = colors[0] || 0;
var g = colors[1] || 0;
var b = colors[2] || 0;
var a = colors[3] === undefined ? 255 : colors[3];
return "#" + toHex(r) + toHex(g) + toHex(b);
};
if (
AscCommon.TEMP_STYLE_THUMBNAIL_WIDTH !== undefined &&
AscCommon.TEMP_STYLE_THUMBNAIL_HEIGHT !== undefined
) {
// TODO: переделать.
GlobalSkin.STYLE_THUMBNAIL_WIDTH = AscCommon.TEMP_STYLE_THUMBNAIL_WIDTH;
GlobalSkin.STYLE_THUMBNAIL_HEIGHT = AscCommon.TEMP_STYLE_THUMBNAIL_HEIGHT;
}

View File

@ -1,371 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
"use strict";
(function(window, undefined){
window["AscCommon"] = window.AscCommon = (window["AscCommon"] || {});
var charA = "A".charCodeAt(0);
var charZ = "Z".charCodeAt(0);
var chara = "a".charCodeAt(0);
var charz = "z".charCodeAt(0);
var char0 = "0".charCodeAt(0);
var char9 = "9".charCodeAt(0);
var charp = "+".charCodeAt(0);
var chars = "/".charCodeAt(0);
var char_break = ";".charCodeAt(0);
function decodeBase64Char(ch)
{
if (ch >= charA && ch <= charZ)
return ch - charA + 0;
if (ch >= chara && ch <= charz)
return ch - chara + 26;
if (ch >= char0 && ch <= char9)
return ch - char0 + 52;
if (ch == charp)
return 62;
if (ch == chars)
return 63;
return -1;
}
var stringBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var arrayBase64 = [];
for (var index64 = 0; index64 < stringBase64.length; index64++)
{
arrayBase64.push(stringBase64.charAt(index64));
}
window.AscCommon["Base64"] = window.AscCommon.Base64 = {};
/**
* Decode input base64 data to output array
* @memberof AscCommon.Base64
* @alias decodeData
* @param {string|Array|TypedArray} input input data
* @param {number} [input_offset = undefined] offset in input data. 0 by default
* @param {number} [input_len = undefined] length input data (not length of needed data, this value does not depend on the offset. input.length by default
* @param {Array|TypedArray} output output data
* @param {number} [output_offset = undefined] output data offset. 0 by default
* @return {number} offset in output data (output_offset + count_write_bytes)
*/
window.AscCommon.Base64.decodeData = window.AscCommon.Base64["decodeData"] = function(input, input_offset, input_len, output, output_offset)
{
var isBase64 = typeof input === "string";
if (undefined === input_len) input_len = input.length;
var writeIndex = (undefined === output_offset) ? 0 : output_offset;
var index = (undefined === input_offset) ? 0 : input_offset;
while (index < input_len)
{
var dwCurr = 0;
var i;
var nBits = 0;
for (i=0; i<4; i++)
{
if (index >= input_len)
break;
var nCh = decodeBase64Char(isBase64 ? input.charCodeAt(index) : input[index]);
index++;
if (nCh == -1)
{
i--;
continue;
}
dwCurr <<= 6;
dwCurr |= nCh;
nBits += 6;
}
dwCurr <<= 24-nBits;
for (i=0; i<(nBits>>3); i++)
{
output[writeIndex++] = ((dwCurr & 0x00ff0000) >>> 16);
dwCurr <<= 8;
}
}
return writeIndex;
};
/**
* Decode input base64 data to returned Uint8Array
* @memberof AscCommon.Base64
* @alias decode
* @param {string|Array|TypedArray} input input data
* @param {boolean} [isUsePrefix = undefined] is detect destination size by prefix. false by default
* @param {number} [dstlen = undefined] destination length
* @param {number} [offset] offset of input data
* @return {Uint8Array} decoded data
*/
window.AscCommon.Base64.decode = window.AscCommon.Base64["decode"] = function(input, isUsePrefix, dstlen, offset)
{
var srcLen = input.length;
var index = (undefined === offset) ? 0 : offset;
var dstLen = (undefined === dstlen) ? srcLen : dstlen;
var isBase64 = typeof input === "string";
if (isUsePrefix && isBase64)
{
// ищем длину
dstLen = 0;
var maxLen = Math.max(11, srcLen); // > 4 Gb
while (index < maxLen)
{
var c = input.charCodeAt(index++);
if (c == char_break)
break;
dstLen *= 10;
dstLen += (c - char0);
}
if (index == maxLen)
{
// длины нет
index = 0;
dstLen = srcLen;
}
}
var dst = new Uint8Array(dstLen);
var writeIndex = window.AscCommon.Base64.decodeData(input, index, srcLen, dst, 0);
if (writeIndex == dstLen)
return dst;
return new Uint8Array(dst.buffer, 0, writeIndex);
};
/**
* Encode input data to base64 string
* @memberof AscCommon.Base64
* @alias encode
* @param {Array|TypedArray} input input data
* @param {number} [offset = undefined] offset of input data. 0 by default
* @param {number} [length = undefined] length input data (last index: offset + length). input.length by default
* @param {boolean} [isUsePrefix = undefined] is add destination size by prefix. false by default
* @return {string} encoded data
*/
window.AscCommon.Base64.encode = window.AscCommon.Base64["encode"] = function(input, offset, length, isUsePrefix)
{
var srcLen = (undefined === length) ? input.length : length;
var index = (undefined === offset) ? 0 : offset;
var len1 = (((srcLen / 3) >> 0) * 4);
var len2 = (len1 / 76) >> 0;
var len3 = 19;
var dstArray = [];
var sTemp = "";
var dwCurr = 0;
for (var i = 0; i <= len2; i++)
{
if (i == len2)
len3 = ((len1 % 76) / 4) >> 0;
for (var j = 0; j < len3; j++)
{
dwCurr = 0;
for (var n = 0; n < 3; n++)
{
dwCurr |= input[index++];
dwCurr <<= 8;
}
sTemp = "";
for (var k = 0; k < 4; k++)
{
var b = (dwCurr >>> 26) & 0xFF;
sTemp += arrayBase64[b];
dwCurr <<= 6;
dwCurr &= 0xFFFFFFFF;
}
dstArray.push(sTemp);
}
}
len2 = (srcLen % 3 != 0) ? (srcLen % 3 + 1) : 0;
if (len2)
{
dwCurr = 0;
for (var n = 0; n < 3; n++)
{
if (n < (srcLen % 3))
dwCurr |= input[index++];
dwCurr <<= 8;
}
sTemp = "";
for (var k = 0; k < len2; k++)
{
var b = (dwCurr >>> 26) & 0xFF;
sTemp += arrayBase64[b];
dwCurr <<= 6;
}
len3 = (len2 != 0) ? 4 - len2 : 0;
for (var j = 0; j < len3; j++)
{
sTemp += '=';
}
dstArray.push(sTemp);
}
return isUsePrefix ? (("" + srcLen + ";") + dstArray.join("")) : dstArray.join("");
};
window.AscCommon["Hex"] = window.AscCommon.Hex = {};
/**
* Decode input hex data to Uint8Array
* @memberof AscCommon.Hex
* @alias decode
* @param {string} input input data
* @return {Uint8Array} decoded data
*/
window.AscCommon.Hex.decode = window.AscCommon.Hex["decode"] = function(input)
{
var hexToByte = function(c) {
if (c >= 48 && c <= 57) return c - 48; // 0..9
if (c >= 97 && c <= 102) return c - 87;
if (c >= 65 && c <= 70) return c - 55;
return 0;
};
var len = input.length;
if (len & 0x01) len -= 1;
var result = new Uint8Array(len >> 1);
var resIndex = 0;
for (var i = 0; i < len; i += 2)
{
result[resIndex++] = hexToByte(input.charCodeAt(i)) << 4 | hexToByte(input.charCodeAt(i + 1));
}
return result;
};
/**
* Encode Uint8Array to hex string
* @memberof AscCommon.Hex
* @alias encode
* @param {Array|TypedArray} input input data
* @param {boolean} [isUpperCase = false] is use upper case
* @return {string} encoded data
*/
window.AscCommon.Hex.encode = window.AscCommon.Hex["encode"] = function(input, isUpperCase)
{
var byteToHex = new Array(256);
for (var i = 0; i < 16; i++)
byteToHex[i] = "0" + (isUpperCase ? i.toString(16).toUpperCase() : i.toString(16));
for (var i = 16; i < 256; i++)
byteToHex[i] = isUpperCase ? i.toString(16).toUpperCase() : i.toString(16);
var result = "";
for (var i = 0, len = input.length; i < len; i++)
result += byteToHex[input[i]];
return result;
};
window.AscCommon["Base58"] = window.AscCommon.Base58 = {};
/**
* Encode data to base58 string
* @memberof AscCommon.Base58
* @alias encode
* @param {Array|TypedArray|string} input input data
* @return {string} encoded data
*/
window.AscCommon.Base58.encode = function(buf)
{
if(typeof buf === "string")
{
let old = buf;
buf = [];
for (let i = 0, len = old.length; i < len; i++)
buf.push(old.charCodeAt(i));
}
const chars = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
const chars_map = [
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, -1, -1, -1, -1, -1, -1,
-1, 9, 10, 11, 12, 13, 14, 15, 16, -1, 17, 18, 19, 20, 21, -1,
22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, -1, -1, -1, -1, -1,
-1, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, -1, 44, 45, 46,
47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
];
let result = [];
for (let i = 0, len = buf.length; i < len; i++)
{
let carry = buf[i];
for (let j = 0; j < result.length; ++j)
{
const x = (chars_map[result[j]] << 8) + carry;
result[j] = chars.charCodeAt(x % 58);
carry = (x / 58) >> 0;
}
while (carry)
{
result.push(chars.charCodeAt(carry % 58));
carry = (carry / 58) >> 0;
}
}
let char1 = "1".charCodeAt(0);
for (let i = 0, len = buf.length; i < len; i++)
{
if (buf[i])
break;
else
result.push(char1);
}
result.reverse();
return String.fromCharCode.apply(null, result);
};
})(window);

View File

@ -1,976 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
(function(){
// SKIN
var PageStyle = {
emptyColor : "#FFFFFF",
numberColor : "#000000",
numberFontSize : 10,
numberFont : "Arial",
numberFontOffset : 10,
outlineColor : "#D9D9D9",
outlineColorOffset : 0,
outlineColorWidth : 1,
hoverColor : "#BABABA",
hoverColorOffset : 3,
hoverColorWidth : 3,
selectColor : "#888888",
selectColorOffset : 3,
selectColorWidth : 3,
isDrawCurrentRect : true,
drawCurrentColor : "#888888",
drawCurrentWidth : 2
};
var ThumbnailsStyle = {
backgroundColor : "#F1F1F1"
};
PageStyle.numberFontHeight = (function(){
if (window["NATIVE_EDITOR_ENJINE"])
return 7;
var testCanvas = document.createElement("canvas");
var w = 100;
var h = 100;
testCanvas.width = w;
testCanvas.height = h;
var ctx = testCanvas.getContext("2d");
ctx.font = PageStyle.numberFont;
ctx.fillStyle = "#FFFFFF";
ctx.fillRect(0, 0, w, h);
ctx.fillStyle = "#000000";
ctx.font = PageStyle.numberFont;
ctx.fillText("123456789", 0, h);
var pixels = ctx.getImageData(0, 0, w, h).data;
var index = 0;
var indexLast = 4 * w * h;
while (index < indexLast)
{
if (pixels[index] !== 255 || pixels[index + 1] !== 255 || pixels[index + 2] !== 255)
break;
index += 4;
}
return h - ((index / (4 * w)) >> 0);
})();
PageStyle.font = function()
{
var size = AscCommon.AscBrowser.convertToRetinaValue(this.numberFontSize, true);
return "" + size + "px " + this.numberFont;
};
// LOGIC PAGE
function CPage(w, h)
{
this.width = w;
this.height = h;
this.image = null;
}
CPage.prototype.draw = function(ctx, x, y, w, h)
{
if (null === this.image)
{
ctx.fillStyle = PageStyle.emptyColor;
ctx.fillRect(x, y, w, h);
}
else
{
ctx.drawImage(this.image, x, y, w, h);
}
if (null !== PageStyle.outlineColor)
{
var lineW = Math.max(1, (PageStyle.outlineColorWidth * AscCommon.AscBrowser.retinaPixelRatio) >> 0);
var offsetW = PageStyle.outlineColorOffset + 0.5 * lineW;
ctx.lineWidth = lineW;
ctx.strokeStyle = PageStyle.outlineColor;
ctx.strokeRect(x - offsetW, y - offsetW, w + 2 * offsetW, h + 2 * offsetW);
}
};
// DRAWING PAGE
function CDrawingPage(num, page)
{
this.page = page;
this.pageRect = { x:0, y:0, w:0, h:0 };
this.numRect = { x:0, y:0, w:0, h:0 };
this.num = num;
}
CDrawingPage.prototype.draw = function(ctx, offsetV, doc)
{
this.page.draw(ctx, this.pageRect.x, this.pageRect.y - offsetV, this.pageRect.w, this.pageRect.h);
var lineW, offsetW, color = undefined;
if (this.num === doc.selectPage)
{
lineW = Math.max(1, (PageStyle.selectColorWidth * AscCommon.AscBrowser.retinaPixelRatio) >> 0);
offsetW = PageStyle.selectColorOffset + 0.5 * lineW;
color = PageStyle.selectColor;
}
else if (this.num === doc.hoverPage)
{
lineW = Math.max(1, (PageStyle.hoverColorWidth * AscCommon.AscBrowser.retinaPixelRatio) >> 0);
offsetW = PageStyle.hoverColorOffset + 0.5 * lineW;
color = PageStyle.hoverColor;
}
if (color)
{
ctx.lineWidth = lineW;
ctx.strokeStyle = color;
ctx.strokeRect(this.pageRect.x - offsetW, this.pageRect.y - offsetV - offsetW, this.pageRect.w + 2 * offsetW, this.pageRect.h + 2 * offsetW);
}
// currentRect
var currentRect = null;
if (PageStyle.isDrawCurrentRect && doc.selectPage === this.num)
currentRect = doc.selectPageRect;
if (currentRect)
{
var _x = currentRect.x;
var _y = currentRect.y;
var _r = currentRect.r;
var _b = currentRect.b;
if (_x < 0 || _x > 1 || _y < 0 || _y > 1 || _r < 0 || _r > 1 || _b < 0 || _b > 1)
return;
var pixX = (this.pageRect.x + _x * this.pageRect.w) >> 0;
var pixY = (this.pageRect.y - offsetV + _y * this.pageRect.h) >> 0;
var pixR = (this.pageRect.x + _r * this.pageRect.w) >> 0;
var pixB = (this.pageRect.y - offsetV + _b * this.pageRect.h) >> 0;
if (pixR <= pixX) return;
if (pixB <= pixY) return;
var lineW = Math.max(1, (PageStyle.drawCurrentWidth * AscCommon.AscBrowser.retinaPixelRatio) >> 0);
var offsetW = 0.5 * lineW;
ctx.lineWidth = lineW;
ctx.strokeStyle = PageStyle.drawCurrentColor;
ctx.strokeRect(pixX + offsetW, pixY + offsetW, pixR - pixX - 2 * offsetW, pixB - pixY - 2 * offsetW);
}
ctx.fillStyle = PageStyle.numberColor;
ctx.fillText("" + (this.num + 1), this.numRect.x + this.numRect.w / 2, this.numRect.y + this.numRect.h - offsetV);
};
// BLOCK OF DRAWING PAGES
function CBlock()
{
this.pages = [];
this.top;
this.bottom;
}
CBlock.prototype.getHeight = function(columnW, startOffset, betweenPages, zoom)
{
var maxPageHeight = 0;
for (var i = 0, len = this.pages.length; i < len; i++)
{
if (this.pages[i].page.height > maxPageHeight)
maxPageHeight = this.pages[i].page.height;
}
var blockHeight = (maxPageHeight * zoom) >> 0;
var numberBlockH = AscCommon.AscBrowser.convertToRetinaValue(PageStyle.numberFontOffset + PageStyle.numberFontHeight, true);
blockHeight += numberBlockH;
var currentPosX = startOffset;
for (var i = 0, len = this.pages.length; i < len; i++)
{
var drPage = this.pages[i];
var pW = (drPage.page.width * zoom) >> 0;
var pH = (drPage.page.height * zoom) >> 0;
var curPageHeight = pH + PageStyle.numberFontOffset + PageStyle.numberFontHeight;
drPage.pageRect.y = this.top + ((blockHeight - curPageHeight) >> 1);
drPage.pageRect.h = pH;
drPage.pageRect.x = currentPosX + ((columnW - pW) >> 1);
drPage.pageRect.w = pW;
drPage.numRect.y = (drPage.pageRect.y + drPage.pageRect.h);
drPage.numRect.h = numberBlockH;
drPage.numRect.x = drPage.pageRect.x;
drPage.numRect.w = drPage.pageRect.w;
currentPosX += (columnW + betweenPages);
}
return blockHeight;
};
CBlock.prototype.draw = function(ctx, offsetV, doc)
{
for (var i = 0, len = this.pages.length; i < len; i++)
{
this.pages[i].draw(ctx, offsetV, doc);
}
};
// ГЛАВНЫЙ КЛАСС
function CDocument(id)
{
this.id = id;
this.viewer = null;
this.isEnabled = true;
this.coordsOffset = {x: 0, y: 0};
this.pages = [];
this.countPagesInBlock = 1;
this.blocks = [];
this.settings = {
marginW : 20,
marginH : 10,
betweenW : 30,
betweenH : 20
};
this.marginW = 20;
this.marginH = 10;
this.betweenW = 30;
this.betweenH = 20;
this.startBlock = -1;
this.endBlock = -1;
this.documentWidth = 0;
this.documentHeight = 0;
this.panelWidth = 0;
this.panelHeight = 0;
this.scrollY = 0;
this.scrollMaxY = 0;
this.minSizePage = 20;
this.defaultPageW = 150;
this.zoomMin = 1;
this.zoomMax = 1;
this.zoom = 1;
this.canvas = null;
this.canvasOverlay = null;
this.isRepaint = false;
this.scrollWidth = 10;
this.m_oScrollVerApi = null;
this.selectPage = -1;
this.selectPageRect = null;
this.hoverPage = -1;
this.handlers = {};
this.createComponents();
}
// INTERFACE
CDocument.prototype.repaint = function()
{
this.isRepaint = true;
};
CDocument.prototype.setZoom = function(zoom)
{
this.zoom = this.zoomMin + zoom * (this.zoomMax - this.zoomMin);
this.resize(false);
};
CDocument.prototype.resize = function(isZoomUpdated)
{
this._resize(isZoomUpdated);
};
CDocument.prototype.setIsDrawCurrentRect = function(isDrawCurrentRect)
{
PageStyle.isDrawCurrentRect = isDrawCurrentRect;
this.repaint();
};
CDocument.prototype.setEnabled = function(isEnabled)
{
this.isEnabled = isEnabled;
if (this.isEnabled)
this.repaint();
};
CDocument.prototype.registerEvent = function(name, handler)
{
if (this.handlers[name] === undefined)
this.handlers[name] = [];
this.handlers[name].push(handler);
};
// HTML/INTERFACE
CDocument.prototype.createComponents = function()
{
this.updateSkin();
var parent = document.getElementById(this.id);
var elements = "";
elements += "<canvas id=\"id_viewer_th\" class=\"block_elem\" style=\"left:0px;top:0px;width:100;height:100;\"></canvas>";
elements += "<canvas id=\"id_overlay_th\" class=\"block_elem\" style=\"left:0px;top:0px;width:100;height:100;\"></canvas>";
elements += "<div id=\"id_vertical_scroll_th\" class=\"block_elem\" style=\"display:none;left:0px;top:0px;width:0px;height:0px;\"></div>";
parent.style.backgroundColor = ThumbnailsStyle.backgroundColor;
parent.innerHTML = elements;
this.canvas = document.getElementById("id_viewer_th");
this.canvas.backgroundColor = ThumbnailsStyle.backgroundColor;
this.canvasOverlay = document.getElementById("id_overlay_th");
this.canvasOverlay.style.pointerEvents = "none";
parent.onmousewheel = this.onMouseWhell.bind(this);
if (parent.addEventListener)
parent.addEventListener("DOMMouseScroll", this.onMouseWhell.bind(this), false);
AscCommon.addMouseEvent(this.canvas, "down", this.onMouseDown.bind(this));
AscCommon.addMouseEvent(this.canvas, "move", this.onMouseMove.bind(this));
AscCommon.addMouseEvent(this.canvas, "up", this.onMouseUp.bind(this));
};
CDocument.prototype.sendEvent = function()
{
var name = arguments[0];
if (this.handlers.hasOwnProperty(name))
{
for (var i = 0; i < this.handlers[name].length; ++i)
{
this.handlers[name][i].apply(this || window, Array.prototype.slice.call(arguments, 1));
}
return true;
}
};
// SCROLL
CDocument.prototype.CreateScrollSettings = function()
{
var settings = new AscCommon.ScrollSettings();
settings.screenW = this.panelWidth;
settings.screenH = this.panelHeight;
settings.vscrollStep = 45;
settings.hscrollStep = 45;
//settings.isNeedInvertOnActive = GlobalSkin.isNeedInvertOnActive;
settings.showArrows = false;
settings.cornerRadius = 1;
settings.slimScroll = true;
settings.scrollBackgroundColor = GlobalSkin.ScrollBackgroundColor;
settings.scrollBackgroundColorHover = GlobalSkin.ScrollBackgroundColor;
settings.scrollBackgroundColorActive = GlobalSkin.ScrollBackgroundColor;
settings.scrollerColor = GlobalSkin.ScrollerColor;
settings.scrollerHoverColor = GlobalSkin.ScrollerHoverColor;
settings.scrollerActiveColor = GlobalSkin.ScrollerActiveColor;
settings.arrowColor = GlobalSkin.ScrollArrowColor;
settings.arrowHoverColor = GlobalSkin.ScrollArrowHoverColor;
settings.arrowActiveColor = GlobalSkin.ScrollArrowActiveColor;
settings.strokeStyleNone = GlobalSkin.ScrollOutlineColor;
settings.strokeStyleOver = GlobalSkin.ScrollOutlineHoverColor;
settings.strokeStyleActive = GlobalSkin.ScrollOutlineActiveColor;
settings.targetColor = GlobalSkin.ScrollerTargetColor;
settings.targetHoverColor = GlobalSkin.ScrollerTargetHoverColor;
settings.targetActiveColor = GlobalSkin.ScrollerTargetActiveColor;
return settings;
};
CDocument.prototype.scrollVertical = function(pos, maxPos)
{
this.scrollY = pos;
this.scrollMaxY = maxPos;
this.calculateVisibleBlocks();
this.repaint();
};
CDocument.prototype.updateScroll = function(scrollV)
{
scrollV.style.display = (this.documentHeight > this.panelHeight) ? "block" : "none";
var settings = this.CreateScrollSettings();
settings.isHorizontalScroll = false;
settings.isVerticalScroll = true;
settings.contentH = this.documentHeight;
if (this.m_oScrollVerApi)
this.m_oScrollVerApi.Repos(settings, undefined, true);
else
{
this.m_oScrollVerApi = new AscCommon.ScrollObject("id_vertical_scroll_th", settings);
this.m_oScrollVerApi.onLockMouse = function(evt) {
AscCommon.check_MouseDownEvent(evt, true);
AscCommon.global_mouseEvent.LockMouse();
};
this.m_oScrollVerApi.offLockMouse = function(evt) {
AscCommon.check_MouseUpEvent(evt);
};
var _t = this;
this.m_oScrollVerApi.bind("scrollvertical", function(evt) {
_t.scrollVertical(evt.scrollD, evt.maxScrollY);
});
}
this.scrollMaxY = this.m_oScrollVerApi.getMaxScrolledY();
if (this.scrollY >= this.scrollMaxY)
this.scrollY = this.scrollMaxY;
};
// очередь задач - нужно ли перерисоваться и/или перерисовать страницу
CDocument.prototype.checkTasks = function(isViewerTask)
{
var isNeedTasks = false;
if (!this.isEnabled)
return isNeedTasks;
if (!isViewerTask && -1 != this.startBlock)
{
// смотрим, какие страницы нужно перерисовать.
// делаем это по одной, так как задачи вьюера важнее
var needPage = null;
var drPage, block;
for (var blockNum = this.startBlock; (blockNum <= this.endBlock) && !needPage; blockNum++)
{
block = this.blocks[blockNum];
for (var pageNum = 0, pagesCount = block.pages.length; pageNum < pagesCount; pageNum++)
{
drPage = block.pages[pageNum];
if (drPage.page.image === null ||
(drPage.page.image.requestWidth != drPage.pageRect.w || drPage.page.image.requestHeight != drPage.pageRect.h))
{
needPage = drPage;
break;
}
}
}
if (needPage)
{
isNeedTasks = true;
needPage.page.image = this.viewer.file.getPage(needPage.num, needPage.pageRect.w, needPage.pageRect.h, undefined, this.viewer.Api.isDarkMode ? 0x3A3A3A : 0xFFFFFF);
this.isRepaint = true;
}
}
// проверяем, нужна ли перерисовка
if (this.isRepaint)
{
this._paint();
this.isRepaint = false;
}
return isNeedTasks;
};
CDocument.prototype.updateCurrentPage = function(pageObject)
{
this.selectPageRect = pageObject;
if (this.selectPage != pageObject.num)
{
this.selectPage = pageObject.num;
var drPage = this.getDrawingPage(this.selectPage);
if (!drPage)
return;
// или подскролливаем, или просто перерисовываем
if (drPage.pageRect.y < this.scrollY)
this.m_oScrollVerApi.scrollToY(drPage.pageRect.y - this.betweenH);
else
{
var b = drPage.pageRect.y + drPage.pageRect.h + drPage.numRect.h;
if (b > (this.scrollY + this.panelHeight))
this.m_oScrollVerApi.scrollToY(b - this.panelHeight + this.betweenH);
else
this.repaint();
}
}
else if (PageStyle.isDrawCurrentRect)
this.repaint();
};
// сама отрисовка
CDocument.prototype._paint = function()
{
this.canvas.width = this.canvas.width;
var ctx = this.canvas.getContext("2d");
ctx.fillStyle = ThumbnailsStyle.backgroundColor;
ctx.fillRect(0, 0, this.panelWidth, this.panelHeight);
if (-1 == this.startBlock)
return;
ctx.font = PageStyle.font();
ctx.textAlign = "center";
for (var block = this.startBlock; block <= this.endBlock; block++)
{
this.blocks[block].draw(ctx, this.scrollY >> 0, this);
}
};
CDocument.prototype.init = function()
{
this.pages = [];
if (this.viewer.file && this.viewer.file.isValid())
{
var pages = this.viewer.file.pages;
let koef = 1;
for (let i = 0, len = pages.length; i < len; i++)
{
koef = 1;
if (pages[i].Dpi > 1)
koef = 100 / pages[i].Dpi;
this.pages.push(new CPage(koef * pages[i].W, koef * pages[i].H));
}
}
this.resize();
};
CDocument.prototype._resize = function(isZoomUpdated)
{
var element = document.getElementById(this.id);
if (0 === element.offsetWidth || !this.canvas)
return;
// размер панели
this.panelWidth = element.offsetWidth;
this.panelHeight = element.offsetHeight;
this.canvas.style.width = this.panelWidth + "px";
this.canvas.style.height = this.panelHeight + "px";
this.canvasOverlay.style.width = this.panelWidth + "px";
this.canvasOverlay.style.height = this.panelHeight + "px";
AscCommon.calculateCanvasSize(this.canvas);
AscCommon.calculateCanvasSize(this.canvasOverlay);
var canvasBounds = this.canvas.getBoundingClientRect();
this.coordsOffset.x = canvasBounds ? canvasBounds.left : 0;
this.coordsOffset.y = canvasBounds ? canvasBounds.top : 0;
var scrollV = document.getElementById("id_vertical_scroll_th");
scrollV.style.display = "none";
scrollV.style.left = this.panelWidth - this.scrollWidth + "px";
scrollV.style.top = "0px";
scrollV.style.width = this.scrollWidth + "px";
scrollV.style.height = this.panelHeight + "px";
this.panelWidth = AscCommon.AscBrowser.convertToRetinaValue(this.panelWidth, true);
this.panelHeight = AscCommon.AscBrowser.convertToRetinaValue(this.panelHeight, true);
this.marginW = AscCommon.AscBrowser.convertToRetinaValue(this.settings.marginW, true);
this.marginH = AscCommon.AscBrowser.convertToRetinaValue(this.settings.marginH, true);
this.betweenW = AscCommon.AscBrowser.convertToRetinaValue(this.settings.betweenW, true);
this.betweenH = AscCommon.AscBrowser.convertToRetinaValue(this.settings.betweenH, true);
if (this.pages.length == 0)
return;
// делим страницы на колонки одинаковой ширины (по максимальной странице)
var pageWidthMax = this.getMaxPageWidth();
var sizeMax = Math.max(pageWidthMax, this.getMaxPageHeight());
// максимальные/минимальные зумы
this.zoomMin = this.minSizePage / sizeMax;
this.zoomMax = (this.panelWidth - (2 * this.marginW)) / pageWidthMax;
if (this.defaultPageW != 0)
{
// зум "по умолчанию"
this.zoom = AscCommon.AscBrowser.convertToRetinaValue(this.defaultPageW, true) / pageWidthMax;
if (0 != this.panelWidth)
this.defaultPageW = 0;
}
// корректировка зумов
if (this.zoomMax < this.zoomMin)
this.zoomMax = this.zoomMin;
if (this.zoom < this.zoomMin)
this.zoom = this.zoomMin;
if (this.zoom > this.zoomMax)
this.zoom = this.zoomMax;
if (isZoomUpdated !== false)
{
var interfaceZoom = (this.zoomMax - this.zoomMin) < 0.001 ? 0 : (this.zoom - this.zoomMin) / (this.zoomMax - this.zoomMin);
this.sendEvent("onZoomChanged", interfaceZoom);
}
// смотрим, сколько столбцов влезает
// уравнение:
// (pageWidthMax * this.zoom) * x + this.betweenW * (x - 1) = this.panelWidth - 2 * this.marginW;
var blockW = (pageWidthMax * this.zoom) >> 0;
this.countPagesInBlock = (this.panelWidth - 2 * this.marginW + this.betweenW) / (blockW + this.betweenW);
this.countPagesInBlock >>= 0;
if (this.countPagesInBlock < 1)
this.countPagesInBlock = 1;
if (this.countPagesInBlock > this.pages.length)
this.countPagesInBlock = this.pages.length;
this.documentWidth = this.countPagesInBlock * blockW + 2 * this.marginW + this.betweenW * (this.countPagesInBlock - 1);
// теперь набиваем блоки
this.blocks = [];
var blocksCount = 0;
var countInCurrentBlock = this.countPagesInBlock;
for (let i = 0, len = this.pages.length; i < len; i++)
{
if (countInCurrentBlock == this.countPagesInBlock)
{
this.blocks[blocksCount++] = new CBlock();
countInCurrentBlock = 0;
}
this.blocks[blocksCount - 1].pages.push(new CDrawingPage(i, this.pages[i]));
++countInCurrentBlock;
}
// теперь считаем позиции страниц в блоке (координаты сквозные)
var blockTop = this.betweenH;
var startOffsetX = this.marginW + ((this.panelWidth - this.documentWidth) >> 1);
for (let i = 0, len = this.blocks.length; i < len; i++)
{
var block = this.blocks[i];
block.top = blockTop;
block.bottom = block.top + block.getHeight(blockW, startOffsetX, this.betweenW, this.zoom);
blockTop = block.bottom + this.betweenH;
}
this.documentHeight = blockTop;
this.updateScroll(scrollV);
this.calculateVisibleBlocks();
this.repaint();
};
CDocument.prototype.calculateVisibleBlocks = function()
{
this.startBlock = -1;
this.endBlock = -1;
var blocksCount = this.blocks.length;
var block;
for (var i = 0; i < blocksCount; i++)
{
block = this.blocks[i];
if (block.bottom > this.scrollY)
{
// первый видимый блок!
this.startBlock = i;
break;
}
else
{
// выкидываем страницу из кэша
for (var pageNum = 0, pagesCount = block.pages.length; pageNum < pagesCount; pageNum++)
{
this.pages[block.pages[pageNum].num].image = null;
}
}
}
if (this.startBlock != -1)
{
for (var i = this.startBlock; i < blocksCount; i++)
{
block = this.blocks[i];
if (block.top > (this.scrollY + this.panelHeight))
{
// уже невидимый блок!
this.endBlock = i - 1;
break;
}
}
}
// проверяем - могли дойти до конца
if (this.startBlock >= 0 && this.endBlock == -1)
this.endBlock = blocksCount - 1;
for (var i = this.endBlock + 1; i < blocksCount; i++)
{
block = this.blocks[i];
// выкидываем страницу из кэша
for (var pageNum = 0, pagesCount = block.pages.length; pageNum < pagesCount; pageNum++)
{
this.pages[block.pages[pageNum].num].image = null;
}
}
};
CDocument.prototype.getMaxPageWidth = function()
{
var size = 0, page = null;
for (var i = 0, count = this.pages.length; i < count; i++)
{
page = this.pages[i];
if (size < page.width)
size = page.width;
}
return size;
};
CDocument.prototype.getMaxPageHeight = function()
{
var size = 0, page = null;
for (var i = 0, count = this.pages.length; i < count; i++)
{
page = this.pages[i];
if (size < page.height)
size = page.height;
}
return size;
};
CDocument.prototype.getPageByCoords = function(x, y)
{
// тут ТОЛЬКО для попадания. поэтому смотрим только видимые блоки
if (-1 === this.startBlock || -1 === this.endBlock)
return null;
x -= this.coordsOffset.x;
y -= this.coordsOffset.y;
x = AscCommon.AscBrowser.convertToRetinaValue(x, true);
y = AscCommon.AscBrowser.convertToRetinaValue(y, true);
y += this.scrollY;
var pages = null;
for (var block = this.startBlock; block <= this.endBlock; block++)
{
if (y >= this.blocks[block].top && y <= this.blocks[block].bottom)
{
pages = this.blocks[block].pages;
break;
}
}
if (!pages)
return null;
var drPage;
for (var pageNum = 0, count = pages.length; pageNum < count; pageNum++)
{
drPage = pages[pageNum];
if (x >= drPage.pageRect.x && x <= (drPage.pageRect.x + drPage.pageRect.w) &&
y >= drPage.pageRect.y && y <= (drPage.pageRect.y + drPage.pageRect.h))
{
return drPage;
}
}
return null;
};
CDocument.prototype.getDrawingPage = function(pageNum)
{
if (pageNum < 0 || pageNum >= this.pages.length)
return null;
var block = (pageNum / this.countPagesInBlock) >> 0;
if (!this.blocks[block])
return null;
var pageInBlock = pageNum - block * this.countPagesInBlock;
return this.blocks[block].pages[pageInBlock];
};
// UI-EVENTS
CDocument.prototype.onMouseDown = function(e)
{
AscCommon.check_MouseDownEvent(e, true);
AscCommon.global_mouseEvent.LockMouse();
this.viewer.isFocusOnThumbnails = true;
var drPage = this.getPageByCoords(AscCommon.global_mouseEvent.X, AscCommon.global_mouseEvent.Y);
if (drPage && drPage.num !== this.selectPage)
{
this.viewer.navigateToPage(drPage.num);
}
AscCommon.stopEvent(e);
return false;
};
CDocument.prototype.onMouseUp = function(e)
{
AscCommon.check_MouseUpEvent(e);
if (e && e.preventDefault)
e.preventDefault();
return false;
};
CDocument.prototype.onMouseMove = function(e)
{
AscCommon.check_MouseMoveEvent(e);
if (AscCommon.global_mouseEvent.IsLocked &&
this.canvas != AscCommon.global_mouseEvent.Sender)
{
return;
}
if (!AscCommon.global_mouseEvent.IsLocked)
{
var drPage = this.getPageByCoords(AscCommon.global_mouseEvent.X, AscCommon.global_mouseEvent.Y);
var hoverNum = drPage ? drPage.num : -1;
if (hoverNum !== this.hoverPage)
{
this.hoverPage = hoverNum;
this._paint();
}
}
if (e && e.preventDefault)
e.preventDefault();
return false;
};
CDocument.prototype.onMouseWhell = function(e)
{
AscCommon.stopEvent(e);
if (this.scrollMaxY == 0)
return false;
var _ctrl = false;
if (e.metaKey !== undefined)
_ctrl = e.ctrlKey || e.metaKey;
else
_ctrl = e.ctrlKey;
if (true === _ctrl)
return false;
var delta = 0;
if (undefined != e.wheelDelta && e.wheelDelta != 0)
{
//delta = (e.wheelDelta > 0) ? -45 : 45;
delta = -45 * e.wheelDelta / 120;
}
else if (undefined != e.detail && e.detail != 0)
{
//delta = (e.detail > 0) ? 45 : -45;
delta = 45 * e.detail / 3;
}
delta = delta >> 0;
if (0 != delta)
this.m_oScrollVerApi.scrollBy(0, delta, false);
// здесь - имитируем моус мув ---------------------------
var _e = {};
_e.pageX = AscCommon.global_mouseEvent.X;
_e.pageY = AscCommon.global_mouseEvent.Y;
_e.clientX = AscCommon.global_mouseEvent.X;
_e.clientY = AscCommon.global_mouseEvent.Y;
_e.altKey = AscCommon.global_mouseEvent.AltKey;
_e.shiftKey = AscCommon.global_mouseEvent.ShiftKey;
_e.ctrlKey = AscCommon.global_mouseEvent.CtrlKey;
_e.metaKey = AscCommon.global_mouseEvent.CtrlKey;
_e.srcElement = AscCommon.global_mouseEvent.Sender;
this.onMouseMove(_e);
// ------------------------------------------------------
return false;
};
CDocument.prototype.updateSkin = function()
{
ThumbnailsStyle.backgroundColor = AscCommon.GlobalSkin.BackgroundColorThumbnails;
PageStyle.hoverColor = AscCommon.GlobalSkin.ThumbnailsPageOutlineHover;
PageStyle.selectColor = AscCommon.GlobalSkin.ThumbnailsPageOutlineActive;
PageStyle.numberColor = AscCommon.GlobalSkin.ThumbnailsPageNumberText;
if (this.canvas)
this.canvas.style.backgroundColor = ThumbnailsStyle.backgroundColor;
this.resize();
};
CDocument.prototype.checkPageEmptyStyle = function()
{
PageStyle.emptyColor = "#FFFFFF";
if (this.viewer)
{
var backColor = this.viewer.Api.getPageBackgroundColor();
PageStyle.emptyColor = "#" + backColor[0].toString(16) + backColor[1].toString(16) + backColor[2].toString(16);
}
}
CDocument.prototype.clearCachePages = function()
{
this.checkPageEmptyStyle();
for (var blockNum = 0, blocksCount = this.blocks.length; blockNum < blocksCount; blockNum++)
{
var block = this.blocks[blockNum];
for (var pageNum = 0, pagesCount = block.pages.length; pageNum < pagesCount; pageNum++)
{
var drPage = block.pages[pageNum];
if (drPage.page.image)
{
drPage.page.image = null;
}
}
}
};
// export
AscCommon.ThumbnailsControl = CDocument;
AscCommon["ThumbnailsControl"] = AscCommon.ThumbnailsControl;
var prot = AscCommon["ThumbnailsControl"].prototype;
prot["repaint"] = prot.repaint;
prot["setZoom"] = prot.setZoom;
prot["resize"] = prot.resize;
prot["setEnabled"] = prot.setEnabled;
prot["registerEvent"] = prot.registerEvent;
})();