Merge branch 'staging' into soon

pull/1/head
ansuz 4 years ago
commit d2e3a1a69a

@ -780,94 +780,95 @@ nQuotient){sGroup+=arrChinese[nQuotient]+arrChinese[1E3];isPrevZero=false}else i
true;if(nTTRemainder<=0){sResult=sGroup+sResult;if(nRemValue<=0)break;continue}var nQuotient=nTTRemainder/1E3|0;var nRemainder=nTTRemainder-nQuotient*1E3;if(0!==nQuotient){sGroup+=arrChinese[nQuotient]+arrChinese[1E3];isPrevZero=false}else if(nTTQuotient>0){sGroup+=arrChinese[0];isPrevZero=true}if(nRemainder<=0){sResult=sGroup+sResult;if(nRemValue<=0)break;continue}nQuotient=nRemainder/100|0;nRemainder=nRemainder-nQuotient*100;if(0!==nQuotient){sGroup+=arrChinese[nQuotient]+arrChinese[100];isPrevZero=
false}else if(!isPrevZero){sGroup+=arrChinese[0];isPrevZero=true}if(nRemainder<=0){sResult=sGroup+sResult;if(nRemValue<=0)break;continue}nQuotient=nRemainder/10|0;nRemainder=nRemainder-nQuotient*10;if(0!==nQuotient){sGroup+=arrChinese[nQuotient]+arrChinese[10];isPrevZero=false}else if(!isPrevZero){sGroup+=arrChinese[0];isPrevZero=true}if(0!==nRemainder)sGroup+=arrChinese[nRemainder];sResult=sGroup+sResult;if(nRemValue<=0)break}break}}return sResult}var c_oAscSpaces=[];c_oAscSpaces[10]=1;c_oAscSpaces[32]=
1;c_oAscSpaces[8194]=1;c_oAscSpaces[8195]=1;c_oAscSpaces[8197]=1;c_oAscSpaces[12288]=1;function IsSpace(nUnicode){return!!c_oAscSpaces[nUnicode]}function private_IsAbbreviation(sWord){if(sWord.toUpperCase()===sWord){for(var nPos=0,nLen=sWord.length;nPos<nLen;++nPos){var nCharCode=sWord.charCodeAt(nPos);if(44032<=nCharCode&&nCharCode<=55203||4352<=nCharCode&&nCharCode<=4607||12592<=nCharCode&&nCharCode<=12687||43360<=nCharCode&&nCharCode<=43391||55216<=nCharCode&&nCharCode<=55295||19968<=nCharCode&&
nCharCode<=40959||13312<=nCharCode&&nCharCode<=19903||131072<=nCharCode&&nCharCode<=173791||173824<=nCharCode&&nCharCode<=177983||177984<=nCharCode&&nCharCode<=178207||178208<=nCharCode&&nCharCode<=183983||63744<=nCharCode&&nCharCode<=64255||194560<=nCharCode&&nCharCode<=195103)return false}return true}return false}var g_oUserColorById={},g_oUserNextColorIndex=0;function getUserColorById(userId,userName,isDark,isNumericValue){if((!userId||""===userId)&&(!userName||""===userName))return new CColor(0,
0,0,255);var res;if(g_oUserColorById.hasOwnProperty(userId))res=g_oUserColorById[userId];else if(g_oUserColorById.hasOwnProperty(userName))res=g_oUserColorById[userName];else{var nColor=Asc.c_oAscArrUserColors[g_oUserNextColorIndex%Asc.c_oAscArrUserColors.length];++g_oUserNextColorIndex;res=g_oUserColorById[userId||userName]=new CUserCacheColor(nColor)}if(!res)return new CColor(0,0,0,255);var oColor=true===isDark?res.Dark:res.Light;return true===isNumericValue?oColor.r<<16&16711680|oColor.g<<8&65280|
oColor.b&255:oColor}function isNullOrEmptyString(str){return str==undefined||str==null||str==""}function unleakString(s){return(" "+s).substr(1)}function readValAttr(attr){if(attr()){var val=attr()["val"];return val?val:null}return null}function getNumFromXml(val){return val?val-0:null}function getColorFromXml(attr){if(attr()){var vals=attr();if(null!=vals["theme"])return AscCommonExcel.g_oColorManager.getThemeColor(getNumFromXml(vals["theme"]),getNumFromXml(vals["tint"]));else if(null!=vals["rgb"])return new AscCommonExcel.RgbColor(16777215&
getNumFromXml(vals["rgb"]))}return null}function getBoolFromXml(val){return"0"!==val&&"false"!==val&&"off"!==val}function CUserCacheColor(nColor){this.Light=null;this.Dark=null;this.init(nColor)}CUserCacheColor.prototype.init=function(nColor){var r=nColor>>16&255;var g=nColor>>8&255;var b=nColor&255;var Y=Math.max(0,Math.min(255,.299*r+.587*g+.114*b));var Cb=Math.max(0,Math.min(255,128-.168736*r-.331264*g+.5*b));var Cr=Math.max(0,Math.min(255,128+.5*r-.418688*g-.081312*b));if(Y>63)Y=63;var R=Math.max(0,
Math.min(255,Y+1.402*(Cr-128)))|0;var G=Math.max(0,Math.min(255,Y-.34414*(Cb-128)-.71414*(Cr-128)))|0;var B=Math.max(0,Math.min(255,Y+1.772*(Cb-128)))|0;this.Light=new CColor(r,g,b,255);this.Dark=new CColor(R,G,B,255)};function loadScript(url,onSuccess,onError){if(window["NATIVE_EDITOR_ENJINE"]===true||window["Native"]!==undefined){onSuccess();return}if(window["AscDesktopEditor"]&&window["local_load_add"]){var _context={"completeLoad":function(){return onSuccess()}};window["local_load_add"](_context,
"sdk-all-from-min",url);var _ret_param=window["AscDesktopEditor"]["LoadJS"](url);if(2!=_ret_param)window["local_load_remove"](url);if(_ret_param==1){setTimeout(onSuccess,1);return}else if(_ret_param==2)return}var backoff=new AscCommon.Backoff(AscCommon.g_oBackoffDefaults);loadScriptWithBackoff(backoff,url,onSuccess,onError)}function loadScriptWithBackoff(backoff,url,onSuccess,onError){var script=document.createElement("script");script.type="text/javascript";script.src=url;script.onload=onSuccess;
script.onerror=function(){backoff.attempt(onError,function(){loadScriptWithBackoff(backoff,url,onSuccess,onError)})};document.head.appendChild(script)}function loadSdk(sdkName,onSuccess,onError){if(window["AscNotLoadAllScript"])onSuccess();else{var urlArgs=window.parent&&window.parent.APP&&window.parent.APP.urlArgs||"";loadScript("./../../../../sdkjs/"+sdkName+"/sdk-all.js?"+urlArgs,onSuccess,onError)}}function getAltGr(e){var ctrlKey=e.metaKey||e.ctrlKey;var altKey=e.altKey;return altKey&&(AscBrowser.isMacOs?
!ctrlKey:ctrlKey)}function getColorSchemeByName(sName){for(var i=0;i<AscCommon.g_oUserColorScheme.length;++i){var tmp=AscCommon.g_oUserColorScheme[i];if(tmp&&tmp.name===sName)return getColorSchemeByIdx(i)}return null}function getColorSchemeByIdx(idx){var tmp=AscCommon.g_oUserColorScheme[idx];if(tmp){var scheme=new AscFormat.ClrScheme,_c;scheme.name=tmp.name;_c=tmp.get_dk1();scheme.colors[8]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_lt1();scheme.colors[12]=AscFormat.CreateUniColorRGB(_c.r,
_c.g,_c.b);_c=tmp.get_dk2();scheme.colors[9]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_lt2();scheme.colors[13]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent1();scheme.colors[0]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent2();scheme.colors[1]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent3();scheme.colors[2]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent4();scheme.colors[3]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent5();
scheme.colors[4]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent6();scheme.colors[5]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_hlink();scheme.colors[11]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_folHlink();scheme.colors[10]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);return scheme}return null}function getAscColorScheme(_scheme,theme){var elem,_c;var _rgba={R:0,G:0,B:0,A:255};elem=new AscCommon.CAscColorScheme;elem.scheme=_scheme;elem.name=_scheme.name;_scheme.colors[8].Calculate(theme,
null,null,null,_rgba);_c=_scheme.colors[8].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[12].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[12].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[9].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[9].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[13].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[13].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));
_scheme.colors[0].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[0].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[1].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[1].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[2].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[2].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[3].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[3].RGBA;elem.putColor(new AscCommon.CColor(_c.R,
_c.G,_c.B));_scheme.colors[4].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[4].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[5].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[5].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[11].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[11].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[10].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[10].RGBA;elem.putColor(new AscCommon.CColor(_c.R,
_c.G,_c.B));return elem}function getIndexColorSchemeInArray(result,asc_color_scheme){for(var j=0;j<result.length;++j)if(result[j].isEqual(asc_color_scheme))return j;return-1}function checkAddColorScheme(result,asc_color_scheme,nStartIndex){var nIndex=getIndexColorSchemeInArray(result,asc_color_scheme);if(nIndex>-1)return nIndex;var nStartIndex_=nStartIndex;if(nStartIndex===null)nStartIndex_=result.length;result.splice(nStartIndex_,0,asc_color_scheme);return nStartIndex_}function isEastAsianScript(value){return 12544<=
value&&value<=12591||12704<=value&&value<=12735||19968<=value&&value<=40938||13312<=value&&value<=19893||131072<=value&&value<=173782||173824<=value&&value<=177972||177984<=value&&value<=178205||178208<=value&&value<=183969||183984<=value&&value<=191456||63744<=value&&value<=64255||194560<=value&&value<=195103||12032<=value&&value<=12255||11904<=value&&value<=12031||12736<=value&&value<=12783||12272<=value&&value<=12287||4352<=value&&value<=4607||43360<=value&&value<=43391||55216<=value&&value<=55295||
12592<=value&&value<=12687||65280<=value&&value<=65519||44032<=value&&value<=55215||12352<=value&&value<=12447||110848<=value&&value<=110895||110592<=value&&value<=110847||12688<=value&&value<=12703||12448<=value&&value<=12543||12784<=value&&value<=12799||42192<=value&&value<=42239||93952<=value&&value<=94111||110960<=value&&value<=111359||94208<=value&&value<=100332||100352<=value&&value<=101119||40960<=value&&value<=42127||42128<=value&&value<=42191}var g_oIdCounter=new CIdCounter;window.Asc.g_signature_drawer=
null;function CSignatureDrawer(id,api,w,h){window.Asc.g_signature_drawer=this;this.Api=api;this.CanvasParent=document.getElementById(id);this.Canvas=document.createElement("canvas");this.Canvas.style.position="absolute";this.Canvas.style.left="0px";this.Canvas.style.top="0px";var _width=parseInt(this.CanvasParent.offsetWidth);var _height=parseInt(this.CanvasParent.offsetHeight);if(0==_width)_width=300;if(0==_height)_height=80;this.Canvas.width=_width;this.Canvas.height=_height;this.CanvasParent.appendChild(this.Canvas);
this.Image="";this.ImageHtml=null;this.Text="";this.Font="Arial";this.Size=10;this.Italic=true;this.Bold=false;this.Width=w;this.Height=h;this.CanvasReturn=null;this.IsAsync=false}CSignatureDrawer.prototype.getCanvas=function(){return this.CanvasReturn==null?this.Canvas:this.CanvasReturn};CSignatureDrawer.prototype.getImages=function(){if(!this.isValid())return["",""];this.CanvasReturn=document.createElement("canvas");this.CanvasReturn.width=this.Width*AscCommon.g_dKoef_mm_to_pix;this.CanvasReturn.height=
this.Height*AscCommon.g_dKoef_mm_to_pix;if(this.Text!="")this.drawText();else this.drawImage();var _ret=[];_ret.push(this.CanvasReturn.toDataURL("image/png"));var _ctx=this.CanvasReturn.getContext("2d");_ctx.strokeStyle="#FF0000";_ctx.lineWidth=2;_ctx.moveTo(0,0);_ctx.lineTo(this.CanvasReturn.width,this.CanvasReturn.height);_ctx.moveTo(0,this.CanvasReturn.height);_ctx.lineTo(this.CanvasReturn.width,0);_ctx.stroke();_ret.push(this.CanvasReturn.toDataURL("image/png"));this.CanvasReturn=null;return _ret};
CSignatureDrawer.prototype.setText=function(text,font,size,isItalic,isBold){if(this.IsAsync){this.Text=text;return}this.Image="";this.ImageHtml=null;this.Text=text;this.Font=font;this.Size=size;this.Italic=isItalic;this.Bold=isBold;this.IsAsync=true;AscFonts.FontPickerByCharacter.checkText(this.Text,this,function(){this.IsAsync=false;var loader=AscCommon.g_font_loader;var fontinfo=AscFonts.g_fontApplication.GetFontInfo(font);var isasync=loader.LoadFont(fontinfo,function(){window.Asc.g_signature_drawer.Api.sync_EndAction(Asc.c_oAscAsyncActionType.Information,
Asc.c_oAscAsyncAction.LoadFont);window.Asc.g_signature_drawer.drawText()});if(false===isasync)this.drawText()})};CSignatureDrawer.prototype.drawText=function(){var _oldTurn=this.Api.isViewMode;var _oldMarks=this.Api.ShowParaMarks;this.Api.isViewMode=true;this.Api.ShowParaMarks=false;AscFormat.ExecuteNoHistory(AscCommon.DrawTextByCenter,this,[]);this.Api.isViewMode=_oldTurn;this.Api.ShowParaMarks=_oldMarks};CSignatureDrawer.prototype.drawImage=function(){var _canvas=this.getCanvas();var w=_canvas.width;
var h=_canvas.height;var _ctx=_canvas.getContext("2d");_ctx.clearRect(0,0,w,h);var im_w=this.ImageHtml.width;var im_h=this.ImageHtml.height;var _x=0;var _y=0;var _w=0;var _h=0;var koef1=w/h;var koef2=im_w/im_h;if(koef1>koef2){_h=h;_w=koef2*_h>>0;_y=0;_x=w-_w>>1}else{_w=w;_h=_w/koef2>>0;_x=0;_y=h-_h>>1}_ctx.drawImage(this.ImageHtml,_x,_y,_w,_h)};CSignatureDrawer.prototype.selectImage=CSignatureDrawer.prototype["selectImage"]=function(){this.Text="";window["AscDesktopEditor"]["OpenFilenameDialog"]("images",
false,function(_file){var file=_file;if(Array.isArray(file))file=file[0];if(!file)return;var _drawer=window.Asc.g_signature_drawer;_drawer.Image=window["AscDesktopEditor"]["GetImageBase64"](file);_drawer.ImageHtml=new Image;_drawer.ImageHtml.onload=function(){window.Asc.g_signature_drawer.drawImage()};_drawer.ImageHtml.src=_drawer.Image;_drawer=null})};CSignatureDrawer.prototype.isValid=function(){return this.Image!=""||this.Text!=""};CSignatureDrawer.prototype.destroy=function(){window.Asc.g_signature_drawer.CanvasParent.removeChild(this.Canvas);
delete window.Asc.g_signature_drawer};function CSignatureImage(){this.ImageValidBase64="";this.ImageInvalidBase64="";this.ImageValid=null;this.ImageInvalid=null;this.Valid=false;this.Loading=0;this.Remove=function(){this.ImageValidBase64="";this.ImageInvalidBase64="";this.ImageValid=null;this.ImageInvalid=null;this.Valid=false;this.Loading=0};this.Register=function(_api,_guid){if(_api.ImageLoader.map_image_index[_guid])return;var _obj={Image:this.Valid?this.ImageValid:this.ImageInvalid,Status:AscFonts.ImageLoadStatus.Complete,
src:_guid};_api.ImageLoader.map_image_index[_guid]=_obj};this.Unregister=function(_api,_guid){if(_api.ImageLoader.map_image_index[_guid])delete _api.ImageLoader.map_image_index[_guid]}}function CShortcuts(){this.List={};this.CustomCounter=0;this.CustomActions={}}CShortcuts.prototype.Add=function(nType,nCode,isCtrl,isShift,isAlt){this.List[this.private_GetIndex(nCode,isCtrl,isShift,isAlt)]=nType};CShortcuts.prototype.Get=function(nCode,isCtrl,isShift,isAlt){var nType=this.List[this.private_GetIndex(nCode,
isCtrl,isShift,isAlt)];return undefined!==nType?nType:0};CShortcuts.prototype.private_GetIndex=function(nCode,isCtrl,isShift,isAlt){return nCode<<8|(isCtrl?4:0)|(isShift?2:0)|(isAlt?1:0)};CShortcuts.prototype.CheckType=function(nType){for(var nIndex in this.List)if(this.List[nIndex]===nType)return{KeyCode:nIndex>>>8,CtrlKey:!!(nIndex&4),ShiftKey:!!(nIndex&2),AltKey:!!(nIndex&1)};return null};CShortcuts.prototype.Remove=function(nCode,isCtrl,isShift,isAlt){delete this.List[this.private_GetIndex(nCode,
isCtrl,isShift,isAlt)]};CShortcuts.prototype.RemoveByType=function(nType){for(var nIndex in this.List)if(this.List[nIndex]===nType)delete this.List[nIndex]};CShortcuts.prototype.GetNewCustomType=function(){return 16711680|this.CustomCounter++};CShortcuts.prototype.IsCustomType=function(nType){return nType>=16711680};CShortcuts.prototype.GetCustomAction=function(nType){return this.CustomActions[nType]};CShortcuts.prototype.AddCustomActionSymbol=function(nCharCode,sFont){var nType=this.GetNewCustomType();
this.CustomActions[nType]=new CCustomShortcutActionSymbol(nCharCode,sFont);return nType};function CCustomShortcutActionSymbol(nCharCode,sFont){this.CharCode=nCharCode;this.Font=sFont}CCustomShortcutActionSymbol.prototype.Type=AscCommon.c_oAscCustomShortcutType.Symbol;AscCommon.EncryptionMessageType={Encrypt:0,Decrypt:1};function CEncryptionData(){this._init=false;this.arrData=[];this.arrImages=[];this.handleChangesCallback=null;this.isChangesHandled=false;this.cryptoMode=0;this.isChartEditor=false;
this.isExistDecryptedChanges=false;this.cryptoPrefix=window["AscDesktopEditor"]&&window["AscDesktopEditor"]["GetEncryptedHeader"]?window["AscDesktopEditor"]["GetEncryptedHeader"]():"ENCRYPTED;";this.cryptoPrefixLen=this.cryptoPrefix.length;this.editorId=null;this.nextChangesTimeoutId=-1;this.isPasswordCryptoPresent=false;this.init=function(){this._init=true};this.isInit=function(){return this._init};this.isNeedCrypt=function(){if(window.g_asc_plugins)if(!window.g_asc_plugins.isRunnedEncryption())return false;
if(!window["AscDesktopEditor"])return false;if(this.isChartEditor)return false;if(2==this.cryptoMode)return true;if(0===window["AscDesktopEditor"]["CryptoMode"])return false;return true};this.isCryptoImages=function(){return this.isNeedCrypt()&&this.isPasswordCryptoPresent};this.addCryproImagesFromDialog=function(callback){var _this=this;window["AscDesktopEditor"]["OpenFilenameDialog"]("images",true,function(files){if(!files)return;if(!Array.isArray(files))files=[files];if(0===files.length)return;
var _files=[];var _options={isImageCrypt:true,callback:callback,ext:[]};for(var i=0;i<files.length;i++){_files.push(window["AscDesktopEditor"]["GetImageBase64"](files[i],true));_options.ext.push(AscCommon.GetFileExtension(files[i]))}_this.sendChanges(this,_files,AscCommon.EncryptionMessageType.Encrypt,_options)})};this.addCryproImagesFromUrls=function(urls,callback){var _editor=window["Asc"]["editor"]?window["Asc"]["editor"]:window.editor;_editor.sync_StartAction(Asc.c_oAscAsyncActionType.BlockInteraction,
Asc.c_oAscAsyncAction.LoadImage);var _this=this;window["AscDesktopEditor"]["DownloadFiles"](urls,[],function(files){_editor.sync_EndAction(Asc.c_oAscAsyncActionType.BlockInteraction,Asc.c_oAscAsyncAction.LoadImage);_editor.sync_StartAction(Asc.c_oAscAsyncActionType.BlockInteraction,Asc.c_oAscAsyncAction.UploadImage);var _files=[];var _options={isImageCrypt:true,isUrls:true,callback:callback,ext:[],api:_editor};for(var elem in files){_files.push(window["AscDesktopEditor"]["GetImageBase64"](files[elem],
true));_options.ext.push(window["AscDesktopEditor"]["GetImageFormat"](files[elem]));window["AscDesktopEditor"]["RemoveFile"](files[elem])}_this.sendChanges(this,_files,AscCommon.EncryptionMessageType.Encrypt,_options)})};this.onDecodeError=function(){var _editor=window["Asc"]["editor"]?window["Asc"]["editor"]:window.editor;_editor.sendEvent("asc_onError",Asc.c_oAscError.ID.DataEncrypted,Asc.c_oAscError.Level.Critical)};this.checkEditorId=function(){if(null==this.editorId){var _editor=window["Asc"]["editor"]?
window["Asc"]["editor"]:window.editor;this.editorId=_editor.editorId}};this.decryptImage=function(src,img,data){this.sendChanges(this,[data],AscCommon.EncryptionMessageType.Decrypt,{isImageDecrypt:true,src:src,img:img})};this.nextChanges=function(){this.nextChangesTimeoutId=setTimeout(function(){AscCommon.EncryptionWorker.sendChanges(undefined,undefined);this.nextChangesTimeoutId=-1},10)};this.sendChanges=function(sender,data,type,options){if(!this.isNeedCrypt()){if(AscCommon.EncryptionMessageType.Encrypt==
type)sender._send(data,true);else if(AscCommon.EncryptionMessageType.Decrypt==type){if(this.isExistEncryptedChanges(data["changes"])){this.onDecodeError();return}sender._onSaveChanges(data,true)}return}if(undefined!==type)this.arrData.push({sender:sender,type:type,data:data,options:options});if(this.arrData.length==0)return;if(undefined!==type&&(1!=this.arrData.length||!this.isChangesHandled))return;if(undefined!==type&&-1!=this.nextChangesTimeoutId){clearTimeout(this.nextChangesTimeoutId);this.nextChangesTimeoutId=
-1}if(AscCommon.EncryptionMessageType.Encrypt==this.arrData[0].type)if(this.arrData[0].options&&this.arrData[0].options.isImageCrypt)window.g_asc_plugins.sendToEncryption({"type":"encryptData","data":this.arrData[0].data});else window.g_asc_plugins.sendToEncryption({"type":"encryptData","data":JSON.parse(this.arrData[0].data["changes"])});else if(AscCommon.EncryptionMessageType.Decrypt==this.arrData[0].type)if(this.arrData[0].options&&this.arrData[0].options.isImageDecrypt)window.g_asc_plugins.sendToEncryption({"type":"decryptData",
"data":this.arrData[0].data});else window.g_asc_plugins.sendToEncryption({"type":"decryptData","data":this.arrData[0].data["changes"]})};this.receiveChanges=function(obj){var data=obj["data"];var check=obj["check"];if(!check){this.onDecodeError();return}if(this.handleChangesCallback){this.isExistDecryptedChanges=true;this.checkEditorId();if(this.editorId==AscCommon.c_oEditorId.Spreadsheet)for(var i=data.length-1;i>=0;i--)this.handleChangesCallback.changesBase[i]=data[i];else for(var i=data.length-
1;i>=0;i--)this.handleChangesCallback.changesBase[i].m_pData=data[i];this.isChangesHandled=true;this.handleChangesCallback.callback.call(this.handleChangesCallback.sender);this.handleChangesCallback=null;this.nextChanges();return}var obj=this.arrData[0];this.arrData.splice(0,1);if(AscCommon.EncryptionMessageType.Encrypt==obj.type)if(obj.options&&obj.options.isImageCrypt){for(var i=0;i<data.length;i++)if(this.cryptoPrefix==data[i].substr(0,this.cryptoPrefixLen))data[i]=this.cryptoPrefix+obj.options.ext[i]+
";"+data[i].substr(this.cryptoPrefixLen);if(!obj.options.isUrls)obj.options.callback(Asc.c_oAscError.ID.No,data);else AscCommon.UploadImageUrls(data,obj.options.api.documentId,obj.options.api.documentUserId,obj.options.api.CoAuthoringApi.get_jwt(),function(urls){obj.options.api.sync_EndAction(Asc.c_oAscAsyncActionType.BlockInteraction,Asc.c_oAscAsyncAction.UploadImage);obj.options.callback(urls)})}else{obj.data["changes"]=JSON.stringify(data);obj.sender._send(obj.data,true)}else if(AscCommon.EncryptionMessageType.Decrypt==
obj.type)if(obj.options&&obj.options.isImageDecrypt){window["AscDesktopEditor"]["ResaveFile"](obj.options.src,data[0]);obj.options.img["onload_crypto"](obj.options.src)}else{this.isExistDecryptedChanges=true;obj.data["changes"]=data;obj.sender._onSaveChanges(obj.data,true)}this.nextChanges()};this.isExistEncryptedChanges=function(_array){if(0==_array.length)return false;this.checkEditorId();var isChangesMode=_array[0]["change"]?true:false;var _prefix="";var _checkPrefixLen=this.cryptoPrefixLen+1;
if(isChangesMode){for(var i=_array.length-1;i>=0;i--)if(_array[i]["change"].length>_checkPrefixLen){_prefix=_array[i]["change"].substr(0,_checkPrefixLen);if(-1!=_prefix.indexOf(this.cryptoPrefix)){isCrypted=true;break}}return isCrypted}var isCrypted=false;if(this.editorId==AscCommon.c_oEditorId.Spreadsheet)for(var i=_array.length-1;i>=0;i--){if(_array[i].length>_checkPrefixLen){_prefix=_array[i].substr(0,_checkPrefixLen);if(-1!=_prefix.indexOf(this.cryptoPrefix)){isCrypted=true;break}}}else for(var i=
_array.length-1;i>=0;i--)if(_array[i].m_pData.length>_checkPrefixLen){_prefix=_array[i].m_pData.substr(0,_checkPrefixLen);if(-1!=_prefix.indexOf(this.cryptoPrefix)){isCrypted=true;break}}return isCrypted};this.handleChanges=function(_array,_sender,_callback){if(0==_array.length||!this.isNeedCrypt()){if(this.isExistEncryptedChanges(_array)){this.onDecodeError();return}this.isChangesHandled=true;_callback.call(_sender);return}this.handleChangesCallback={changesBase:_array,changes:[],sender:_sender,
callback:_callback};this.checkEditorId();if(this.editorId==AscCommon.c_oEditorId.Spreadsheet)for(var i=_array.length-1;i>=0;i--)this.handleChangesCallback.changes[i]=_array[i];else for(var i=_array.length-1;i>=0;i--)this.handleChangesCallback.changes[i]=_array[i].m_pData;window.g_asc_plugins.sendToEncryption({"type":"decryptData","data":this.handleChangesCallback.changes})};this.asc_setAdvancedOptions=function(api,idOption,option){if(window.isNativeOpenPassword){window["AscDesktopEditor"]["NativeViewerOpen"](option.asc_getPassword());
return}if(window.isCloudCryptoDownloadAs)return false;if(!this.isNeedCrypt())return false;window.checkPasswordFromPlugin=true;if(window["Asc"].c_oAscAdvancedOptionsID.TXT===idOption){var _param="<m_nCsvTxtEncoding>"+option.asc_getCodePage()+"</m_nCsvTxtEncoding>";window["AscDesktopEditor"]["SetAdvancedOptions"](_param)}else if(window["Asc"].c_oAscAdvancedOptionsID.CSV===idOption){var delimiter=option.asc_getDelimiter();var delimiterChar=option.asc_getDelimiterChar();var _param="";_param+="<m_nCsvTxtEncoding>"+
option.asc_getCodePage()+"</m_nCsvTxtEncoding>";if(null!=delimiter)_param+="<m_nCsvDelimiter>"+delimiter+"</m_nCsvDelimiter>";if(null!=delimiterChar)_param+="<m_nCsvDelimiterChar>"+delimiterChar+"</m_nCsvDelimiterChar>";window["AscDesktopEditor"]["SetAdvancedOptions"](_param)}else if(window["Asc"].c_oAscAdvancedOptionsID.DRM===idOption){var _param="<m_sPassword>"+AscCommon.CopyPasteCorrectString(option.asc_getPassword())+"</m_sPassword>";api.currentPassword=option.asc_getPassword();window["AscDesktopEditor"]["SetAdvancedOptions"](_param)}return true}}
AscCommon.EncryptionWorker=new CEncryptionData;function CMouseSmoothWheelCorrector(t,scrollFunction){this._deltaX=0;this._deltaY=0;this._isBreakX=false;this._isBreakY=false;this._timeoutCorrector=-1;this._api=t;this._scrollFunction=scrollFunction;this._normalDelta=120;this._isNormalDeltaActive=false;this.setNormalDeltaActive=function(value){this._isNormalDeltaActive=true;this._normalDelta=value};this.isBreakX=function(){return this._isBreakX};this.isBreakY=function(){return this._isBreakY};this.get_DeltaX=
function(wheelDeltaX){this._isBreakX=false;if(!AscCommon.AscBrowser.isMacOs)return wheelDeltaX;this._deltaX+=wheelDeltaX;if(Math.abs(this._deltaX)>=this._normalDelta)return this._isNormalDeltaActive?this._deltaX>0?this._normalDelta:-this._normalDelta:this._deltaX;this._isBreakX=true;return 0};this.get_DeltaY=function(wheelDeltaY){this._isBreakY=false;if(!AscCommon.AscBrowser.isMacOs)return wheelDeltaY;this._deltaY+=wheelDeltaY;if(Math.abs(this._deltaY)>=this._normalDelta)return this._isNormalDeltaActive?
this._deltaY>0?this._normalDelta:-this._normalDelta:this._deltaY;this._isBreakY=true;return 0};this.checkBreak=function(){if(-1!=this._timeoutCorrector){clearTimeout(this._timeoutCorrector);this._timeoutCorrector=-1}if((this._isBreakX||this._isBreakY)&&this._scrollFunction){var obj={t:this,x:this._isBreakX?this._deltaX:0,y:this._isBreakY?this._deltaY:0};this._timeoutCorrector=setTimeout(function(){var t=obj.t;t._scrollFunction.call(t._api,obj.x,obj.y);t._timeoutCorrector=-1;t._deltaX=0;t._deltaY=
0},100)}if(!this._isBreakX)this._deltaX=0;if(!this._isBreakY)this._deltaY=0;this._isBreakX=false;this._isBreakY=false}}AscCommon.CMouseSmoothWheelCorrector=CMouseSmoothWheelCorrector;function CTranslateManager(){this.mapTranslate={}}CTranslateManager.prototype.init=function(map){this.mapTranslate=map||{}};CTranslateManager.prototype.getValue=function(key){return this.mapTranslate.hasOwnProperty(key)?this.mapTranslate[key]:key};function CPolygonPoint2(X,Y){this.X=X;this.Y=Y}function CPolygonVectors(){this.Page=
-1;this.VX=[];this.VY=[]}function CPolygonPath(precision){this.Page=-1;this.Direction=1;this.precision=precision;this.Points=[]}CPolygonPath.prototype.PushPoint=function(x,y){this.Points.push(new CPolygonPoint2(x/this.precision,y/this.precision))};CPolygonPath.prototype.CorrectExtremePoints=function(){var Lng=this.Points.length;this.Points[0].X=this.Points[Lng-1].X;this.Points[Lng-1].Y=this.Points[0].Y};function CPolygon(){this.Vectors=[];this.precision=1E3}CPolygon.prototype.fill=function(arrBounds){this.Vectors.length=
0;if(arrBounds.length<=0)return;var nStartLineIndex=0,nStartIndex=0,CountLines=arrBounds.length,CountBounds;while(nStartLineIndex<arrBounds.length){CountBounds=arrBounds[nStartLineIndex].length;while(nStartIndex<CountBounds)if(arrBounds[nStartLineIndex][nStartIndex].W<.001)nStartIndex++;else break;if(nStartIndex<CountBounds)break;nStartLineIndex++;nStartIndex=0}if(nStartLineIndex>=arrBounds.length)return;var CurrentPage=arrBounds[nStartLineIndex][nStartIndex].Page,CurrentVectors=new CPolygonVectors,
VectorsX=CurrentVectors.VX,VectorsY=CurrentVectors.VY;CurrentVectors.Page=CurrentPage;this.Vectors.push(CurrentVectors);for(var LineIndex=nStartLineIndex;LineIndex<CountLines;nStartIndex=0,LineIndex++){if(arrBounds[LineIndex][nStartIndex].Page!==CurrentPage){CurrentPage=arrBounds[LineIndex][nStartIndex].Page;CurrentVectors=new CPolygonVectors;VectorsX=CurrentVectors.VX;VectorsY=CurrentVectors.VY;CurrentVectors.Page=CurrentPage;this.Vectors.push(CurrentVectors)}for(var Index=nStartIndex;Index<arrBounds[LineIndex].length;Index++){var oBound=
arrBounds[LineIndex][Index];if(oBound.W<.001)continue;var x1=Math.round(oBound.X*this.precision),x2=Math.round((oBound.X+oBound.W)*this.precision),y1=Math.round(oBound.Y*this.precision),y2=Math.round((oBound.Y+oBound.H)*this.precision);if(VectorsX[y1]==undefined)VectorsX[y1]={};this.IntersectionX(VectorsX,x2,x1,y1);if(VectorsY[x1]==undefined)VectorsY[x1]={};this.IntersectionY(VectorsY,y1,y2,x1);if(VectorsX[y2]==undefined)VectorsX[y2]={};this.IntersectionX(VectorsX,x1,x2,y2);if(VectorsY[x2]==undefined)VectorsY[x2]=
{};this.IntersectionY(VectorsY,y2,y1,x2)}}};CPolygon.prototype.IntersectionX=function(VectorsX,BeginX,EndX,Y){var CurrentVector={};CurrentVector[BeginX]=EndX;var VX=VectorsX[Y];if(BeginX>EndX)while(true==this.IntersectVectorX(CurrentVector,VX));else while(true==this.IntersectVectorX(VX,CurrentVector));for(var X in CurrentVector){var VBeginX=parseInt(X);var VEndX=CurrentVector[VBeginX];if(VBeginX!==VEndX||VX[VBeginX]===undefined)VX[VBeginX]=VEndX}};CPolygon.prototype.IntersectVectorX=function(VectorOpp,
VectorClW){for(var X in VectorOpp){var VBeginX=parseInt(X);var VEndX=VectorOpp[VBeginX];if(VEndX==VBeginX)continue;for(var ClwX in VectorClW){var ClwBeginX=parseInt(ClwX);var ClwEndX=VectorClW[ClwBeginX];var bIntersection=false;if(ClwBeginX==ClwEndX)continue;if(ClwBeginX<=VEndX&&VBeginX<=ClwEndX){VectorOpp[VBeginX]=VBeginX;VectorClW[ClwBeginX]=VEndX;VectorClW[VBeginX]=ClwEndX;bIntersection=true}else if(VEndX<=ClwBeginX&&ClwEndX<=VBeginX){VectorClW[ClwBeginX]=ClwBeginX;VectorOpp[VBeginX]=ClwEndX;VectorOpp[ClwBeginX]=
VEndX;bIntersection=true}else if(ClwBeginX<VEndX&&VEndX<ClwEndX){VectorClW[ClwBeginX]=VEndX;VectorOpp[VBeginX]=ClwEndX;bIntersection=true}else if(ClwBeginX<VBeginX&&VBeginX<ClwEndX){VectorOpp[ClwBeginX]=VEndX;VectorClW[VBeginX]=ClwEndX;delete VectorOpp[VBeginX];delete VectorClW[ClwBeginX];bIntersection=true}if(bIntersection==true)return true}}return false};CPolygon.prototype.IntersectionY=function(VectorsY,BeginY,EndY,X){var bIntersect=false;for(var y in VectorsY[X]){var CurBeginY=parseInt(y);var CurEndY=
VectorsY[X][CurBeginY];var minY,maxY;if(CurBeginY<CurEndY){minY=CurBeginY;maxY=CurEndY}else{minY=CurEndY;maxY=CurBeginY}var bInterSection=!(maxY<=BeginY&&maxY<=EndY||minY>=BeginY&&minY>=EndY),bDirection=(CurBeginY-CurEndY)*(BeginY-EndY)<0;if(bInterSection&&bDirection){VectorsY[X][CurBeginY]=EndY;VectorsY[X][BeginY]=CurEndY;bIntersect=true}}if(bIntersect==false)VectorsY[X][BeginY]=EndY};CPolygon.prototype.GetPaths=function(shift){var Paths=[];shift*=this.precision;for(var PageIndex=0;PageIndex<this.Vectors.length;PageIndex++){var y,
x1,x2,x,y1,y2;var VectorsX=this.Vectors[PageIndex].VX,VectorsY=this.Vectors[PageIndex].VY,Page=this.Vectors[PageIndex].Page;for(var LineIndex in VectorsX)for(var Index in VectorsX[LineIndex]){var Polygon=new CPolygonPath(this.precision);Polygon.Page=Page;y=parseInt(LineIndex);x1=parseInt(Index);x2=VectorsX[y][x1];VectorsX[y][x1]=-1;var Direction=x1>x2?1:-1;var minY=y;var SignRightLeft,SignDownUp;var X,Y;if(x2!==-1){SignRightLeft=x1>x2?1:-1;Y=y-SignRightLeft*shift;Polygon.PushPoint(x1,Y);while(true){x=
x2;y1=y;y2=VectorsY[x][y1];if(y2==-1)break;else if(y2==undefined)return[];VectorsY[x][y1]=-1;SignDownUp=y1>y2?1:-1;X=x+SignDownUp*shift;Polygon.PushPoint(X,Y);y=y2;x1=x;x2=VectorsX[y][x1];if(x2==-1)break;else if(x2==undefined)return[];VectorsX[y][x1]=-1;SignRightLeft=x1>x2?1:-1;Y=y-SignRightLeft*shift;Polygon.PushPoint(X,Y);if(y<minY){minY=y;Direction=x1>x2?1:-1}}Polygon.PushPoint(X,Y);Polygon.CorrectExtremePoints();Polygon.Direction=Direction;Paths.push(Polygon)}}}return Paths};function CMathTrack(){this.MathRect=
{IsActive:false,Bounds:[],ContentSelection:null};this.MathPolygons=[];this.MathSelectPolygons=[]}CMathTrack.prototype.Update=function(IsActive,IsContentActive,oMath,PixelError){this.MathRect.IsActive=IsActive;if(true===IsActive&&null!==oMath){var selectBounds=true===IsContentActive?oMath.Get_ContentSelection():null;if(selectBounds!=null){var SelectPolygon=new CPolygon;SelectPolygon.fill(selectBounds);this.MathSelectPolygons=SelectPolygon.GetPaths(0)}else this.MathSelectPolygons.length=0;var arrBounds=
oMath.Get_Bounds();if(arrBounds.length<=0)return;var MPolygon=new CPolygon;MPolygon.fill(arrBounds);this.MathPolygons=MPolygon.GetPaths(PixelError)}};CMathTrack.prototype.Draw=function(overlay,oPath,shift,color,dKoefX,dKoefY,left,top){var ctx=overlay.m_oContext;ctx.strokeStyle=color;ctx.lineWidth=1;ctx.beginPath();var Points=oPath.Points;var nCount=Points.length;var PrevX=Points[nCount-2].X,PrevY=Points[nCount-2].Y;var _x=left+dKoefX*Points[nCount-2].X,_y=top+dKoefY*Points[nCount-2].Y;var StartX,
StartY;for(var nIndex=0;nIndex<nCount;nIndex++){if(PrevX>Points[nIndex].X)_y=top+dKoefY*Points[nIndex].Y-shift;else if(PrevX<Points[nIndex].X)_y=top+dKoefY*Points[nIndex].Y+shift;if(PrevY<Points[nIndex].Y)_x=left+dKoefX*Points[nIndex].X-shift;else if(PrevY>Points[nIndex].Y)_x=left+dKoefX*Points[nIndex].X+shift;PrevX=Points[nIndex].X;PrevY=Points[nIndex].Y;if(nIndex>0){overlay.CheckPoint(_x,_y);if(1==nIndex){StartX=_x;StartY=_y;overlay.m_oContext.moveTo((_x>>0)+.5,(_y>>0)+.5)}else overlay.m_oContext.lineTo((_x>>
0)+.5,(_y>>0)+.5)}}overlay.m_oContext.lineTo((StartX>>0)+.5,(StartY>>0)+.5);ctx.closePath();ctx.stroke();ctx.beginPath()};CMathTrack.prototype.DrawWithMatrix=function(overlay,oPath,ShiftX,ShiftY,color,dKoefX,dKoefY,left,top,m){var ctx=overlay.m_oContext;ctx.strokeStyle=color;ctx.lineWidth=1;ctx.beginPath();var Points=oPath.Points;var nCount=Points.length;var x=Points[nCount-2].X,y=Points[nCount-2].Y;var _x,_y;var PrevX=Points[nCount-2].X,PrevY=Points[nCount-2].Y;var StartX,StartY;for(var nIndex=0;nIndex<
nCount;nIndex++){if(PrevX>Points[nIndex].X)y=Points[nIndex].Y-ShiftY;else if(PrevX<Points[nIndex].X)y=Points[nIndex].Y+ShiftY;if(PrevY<Points[nIndex].Y)x=Points[nIndex].X-ShiftX;else if(PrevY>Points[nIndex].Y)x=Points[nIndex].X+ShiftX;PrevX=Points[nIndex].X;PrevY=Points[nIndex].Y;if(nIndex>0){_x=left+dKoefX*m.TransformPointX(x,y);_y=top+dKoefY*m.TransformPointY(x,y);overlay.CheckPoint(_x,_y);if(1==nIndex){StartX=_x;StartY=_y;overlay.m_oContext.moveTo((_x>>0)+.5,(_y>>0)+.5)}else overlay.m_oContext.lineTo((_x>>
0)+.5,(_y>>0)+.5)}}overlay.m_oContext.lineTo((StartX>>0)+.5,(StartY>>0)+.5);ctx.closePath();ctx.stroke();ctx.beginPath()};CMathTrack.prototype.DrawSelectPolygon=function(overlay,oPath,dKoefX,dKoefY,left,top,m){var ctx=overlay.m_oContext;ctx.fillStyle="#375082";ctx.beginPath();var Points=oPath.Points;var nPointIndex;var _x,_y,x,y,p;for(nPointIndex=0;nPointIndex<Points.length-1;nPointIndex++){p=Points[nPointIndex];if(!m){_x=left+dKoefX*p.X;_y=top+dKoefY*p.Y}else{x=p.X;y=p.Y;_x=left+dKoefX*m.TransformPointX(x,
y);_y=top+dKoefY*m.TransformPointY(x,y)}overlay.CheckPoint(_x,_y);if(0==nPointIndex)ctx.moveTo((_x>>0)+.5,(_y>>0)+.5);else ctx.lineTo((_x>>0)+.5,(_y>>0)+.5)}ctx.globalAlpha=.2;ctx.fill();ctx.globalAlpha=1};CMathTrack.prototype.IsActive=function(){return this.MathRect.IsActive};CMathTrack.prototype.GetPolygonsCount=function(){return this.MathPolygons.length};CMathTrack.prototype.GetPolygon=function(nIndex){return this.MathPolygons[nIndex]};CMathTrack.prototype.GetSelectPathsCount=function(){return this.MathSelectPolygons.length};
CMathTrack.prototype.GetSelectPath=function(nIndex){return this.MathSelectPolygons[nIndex]};if(!Array.prototype.findIndex)Object.defineProperty(Array.prototype,"findIndex",{value:function(predicate){if(this==null)throw new TypeError("Array.prototype.findIndex called on null or undefined");if(typeof predicate!=="function")throw new TypeError("predicate must be a function");var list=Object(this);var length=list.length>>>0;var thisArg=arguments[1];var value;for(var i=0;i<length;i++){value=list[i];if(predicate.call(thisArg,
value,i,list))return i}return-1}});if(!Array.prototype.fill)Object.defineProperty(Array.prototype,"fill",{value:function(value){if(this==null)throw new TypeError("this is null or not defined");var O=Object(this);var len=O.length>>>0;var start=arguments[1];var relativeStart=start>>0;var k=relativeStart<0?Math.max(len+relativeStart,0):Math.min(relativeStart,len);var end=arguments[2];var relativeEnd=end===undefined?len:end>>0;var final=relativeEnd<0?Math.max(len+relativeEnd,0):Math.min(relativeEnd,len);
while(k<final){O[k]=value;k++}return O}});if(typeof Int8Array!=="undefined"&&!Int8Array.prototype.fill)Int8Array.prototype.fill=Array.prototype.fill;if(typeof Uint8Array!=="undefined"&&!Uint8Array.prototype.fill)Uint8Array.prototype.fill=Array.prototype.fill;if(typeof Uint8ClampedArray!=="undefined"&&!Uint8ClampedArray.prototype.fill)Uint8ClampedArray.prototype.fill=Array.prototype.fill;if(typeof Int16Array!=="undefined"&&!Int16Array.prototype.fill)Int16Array.prototype.fill=Array.prototype.fill;if(typeof Uint16Array!==
"undefined"&&!Uint16Array.prototype.fill)Uint16Array.prototype.fill=Array.prototype.fill;if(typeof Int32Array!=="undefined"&&!Int32Array.prototype.fill)Int32Array.prototype.fill=Array.prototype.fill;if(typeof Uint32Array!=="undefined"&&!Uint32Array.prototype.fill)Uint32Array.prototype.fill=Array.prototype.fill;if(typeof Float32Array!=="undefined"&&!Float32Array.prototype.fill)Float32Array.prototype.fill=Array.prototype.fill;if(typeof Float64Array!=="undefined"&&!Float64Array.prototype.fill)Float64Array.prototype.fill=
Array.prototype.fill;if(typeof Uint8Array!=="undefined"&&!Uint8Array.prototype.slice)Uint8Array.prototype.slice=Array.prototype.slice;function parseText(text,options,bTrimSpaces){var delimiterChar;if(options.asc_getDelimiterChar())delimiterChar=options.asc_getDelimiterChar();else switch(options.asc_getDelimiter()){case AscCommon.c_oAscCsvDelimiter.None:delimiterChar=undefined;break;case AscCommon.c_oAscCsvDelimiter.Tab:delimiterChar="\t";break;case AscCommon.c_oAscCsvDelimiter.Semicolon:delimiterChar=
";";break;case AscCommon.c_oAscCsvDelimiter.Colon:delimiterChar=":";break;case AscCommon.c_oAscCsvDelimiter.Comma:delimiterChar=",";break;case AscCommon.c_oAscCsvDelimiter.Space:delimiterChar=" ";break}var matrix=[];var rows=text.split(/\r?\n/);for(var i=0;i<rows.length;++i){var row=rows[i];if(" "===delimiterChar&&bTrimSpaces){var addSpace=false;if(row[0]===delimiterChar)addSpace=true;row=addSpace?delimiterChar+row.trim():row.trim()}matrix.push(row.split(delimiterChar))}return matrix}function getTimeISO8601(dateStr){if(dateStr)if(dateStr.endsWith("Z"))return Date.parse(dateStr);
else return Date.parse(dateStr+"Z");return NaN}function valueToMmType(value){var oVal=parseFloat(value);var oType;if(!isNaN(oVal)){if(-1!==value.indexOf("%")){oType="%";oVal/=100}else if(-1!==value.indexOf("px")){oType="px";oVal*=AscCommon.g_dKoef_pix_to_mm}else if(-1!==value.indexOf("in")){oType="in";oVal*=AscCommonWord.g_dKoef_in_to_mm}else if(-1!==value.indexOf("cm")){oType="cm";oVal*=10}else if(-1!==value.indexOf("mm"))oType="mm";else if(-1!==value.indexOf("pt")){oType="pt";oVal*=AscCommonWord.g_dKoef_pt_to_mm}else if(-1!==
value.indexOf("pc")){oType="pc";oVal*=AscCommonWord.g_dKoef_pc_to_mm}else oType="none";return{val:oVal,type:oType}}return null}function valueToMm(value){var obj=valueToMmType(value);if(obj&&"%"!==obj.type&&"none"!==obj.type)return obj.val;return null}function arrayMove(array,from,to){array.splice(to,0,array.splice(from,1)[0])}function getRangeArray(start,stop){var res=new Array(stop-start);for(var i=start;i<stop;++i)res[i-start]=i;return res}var g_oBackoffDefaults={retries:2,factor:2,minTimeout:100,
maxTimeout:2E3,randomize:true};function Backoff(opts){this.attempts=0;this.opts=opts}Backoff.prototype.attempt=function(fError,fRetry){var timeout=this.nextTimeout();if(timeout>0)setTimeout(function(){fRetry()},timeout);else fError()};Backoff.prototype.nextTimeout=function(){var timeout=-1;if(this.attempts<this.opts.retries){timeout=this.createTimeout(this.attempts,this.opts);this.attempts++}return timeout};Backoff.prototype.createTimeout=function(attempt,opts){var random=opts.randomize?Math.random()+
1:1;var timeout=Math.round(random*opts.minTimeout*Math.pow(opts.factor,attempt));timeout=Math.min(timeout,opts.maxTimeout);return timeout};function backoffOnError(obj,onError,onRetry){if(!onRetry)return onError;var backoff=new Backoff(g_oBackoffDefaults);return function(){var timeout=backoff.nextTimeout();if(timeout>0)setTimeout(function(){onRetry.call(obj,obj)},timeout);else if(onError)onError.apply(obj,arguments)}}function backoffOnErrorImg(img,onRetry){if(!onRetry)onRetry=function(img){img.setAttribute("src",
img.getAttribute("src"))};img.onerror=backoffOnError(img,img.onerror,onRetry)}function isEmptyObject(obj){for(var name in obj)return false;return true}window["AscCommon"]=window["AscCommon"]||{};window["AscCommon"].getSockJs=getSockJs;window["AscCommon"].getJSZipUtils=getJSZipUtils;window["AscCommon"].getJSZip=getJSZip;window["AscCommon"].getBaseUrl=getBaseUrl;window["AscCommon"].getEncodingParams=getEncodingParams;window["AscCommon"].getEncodingByBOM=getEncodingByBOM;window["AscCommon"].saveWithParts=
saveWithParts;window["AscCommon"].loadFileContent=loadFileContent;window["AscCommon"].getImageFromChanges=getImageFromChanges;window["AscCommon"].openFileCommand=openFileCommand;window["AscCommon"].sendCommand=sendCommand;window["AscCommon"].sendSaveFile=sendSaveFile;window["AscCommon"].mapAscServerErrorToAscError=mapAscServerErrorToAscError;window["AscCommon"].joinUrls=joinUrls;window["AscCommon"].getFullImageSrc2=getFullImageSrc2;window["AscCommon"].fSortAscending=fSortAscending;window["AscCommon"].fSortDescending=
fSortDescending;window["AscCommon"].isLeadingSurrogateChar=isLeadingSurrogateChar;window["AscCommon"].decodeSurrogateChar=decodeSurrogateChar;window["AscCommon"].encodeSurrogateChar=encodeSurrogateChar;window["AscCommon"].convertUnicodeToUTF16=convertUnicodeToUTF16;window["AscCommon"].convertUTF16toUnicode=convertUTF16toUnicode;window["AscCommon"].build_local_rx=build_local_rx;window["AscCommon"].GetFileName=GetFileName;window["AscCommon"].GetFileExtension=GetFileExtension;window["AscCommon"].changeFileExtention=
changeFileExtention;window["AscCommon"].getExtentionByFormat=getExtentionByFormat;window["AscCommon"].InitOnMessage=InitOnMessage;window["AscCommon"].ShowImageFileDialog=ShowImageFileDialog;window["AscCommon"].ShowDocumentFileDialog=ShowDocumentFileDialog;window["AscCommon"].InitDragAndDrop=InitDragAndDrop;window["AscCommon"].UploadImageFiles=UploadImageFiles;window["AscCommon"].UploadImageUrls=UploadImageUrls;window["AscCommon"].CanDropFiles=CanDropFiles;window["AscCommon"].getUrlType=getUrlType;
window["AscCommon"].prepareUrl=prepareUrl;window["AscCommon"].getUserColorById=getUserColorById;window["AscCommon"].isNullOrEmptyString=isNullOrEmptyString;window["AscCommon"].unleakString=unleakString;window["AscCommon"].readValAttr=readValAttr;window["AscCommon"].getNumFromXml=getNumFromXml;window["AscCommon"].getColorFromXml=getColorFromXml;window["AscCommon"].getBoolFromXml=getBoolFromXml;window["AscCommon"].initStreamFromResponse=initStreamFromResponse;window["AscCommon"].checkStreamSignature=
checkStreamSignature;window["AscCommon"].DocumentUrls=DocumentUrls;window["AscCommon"].OpenFileResult=OpenFileResult;window["AscCommon"].CLock=CLock;window["AscCommon"].CContentChanges=CContentChanges;window["AscCommon"].CContentChangesElement=CContentChangesElement;window["AscCommon"].CorrectMMToTwips=CorrectMMToTwips;window["AscCommon"].TwipsToMM=TwipsToMM;window["AscCommon"].MMToTwips=MMToTwips;window["AscCommon"].RomanToInt=RomanToInt;window["AscCommon"].LatinNumberingToInt=LatinNumberingToInt;
window["AscCommon"].IntToNumberFormat=IntToNumberFormat;window["AscCommon"].IsSpace=IsSpace;window["AscCommon"].loadSdk=loadSdk;window["AscCommon"].loadScript=loadScript;window["AscCommon"].getAltGr=getAltGr;window["AscCommon"].getColorSchemeByName=getColorSchemeByName;window["AscCommon"].getColorSchemeByIdx=getColorSchemeByIdx;window["AscCommon"].getAscColorScheme=getAscColorScheme;window["AscCommon"].checkAddColorScheme=checkAddColorScheme;window["AscCommon"].getIndexColorSchemeInArray=getIndexColorSchemeInArray;
window["AscCommon"].isEastAsianScript=isEastAsianScript;window["AscCommon"].CMathTrack=CMathTrack;window["AscCommon"].CPolygon=CPolygon;window["AscCommon"].JSZipWrapper=JSZipWrapper;window["AscCommon"].g_oDocumentUrls=g_oDocumentUrls;window["AscCommon"].FormulaTablePartInfo=FormulaTablePartInfo;window["AscCommon"].cBoolLocal=cBoolLocal;window["AscCommon"].cErrorOrigin=cErrorOrigin;window["AscCommon"].cErrorLocal=cErrorLocal;window["AscCommon"].FormulaSeparators=FormulaSeparators;window["AscCommon"].rx_space_g=
rx_space_g;window["AscCommon"].rx_space=rx_space;window["AscCommon"].rx_defName=rx_defName;window["AscCommon"].kCurFormatPainterWord=kCurFormatPainterWord;window["AscCommon"].parserHelp=parserHelp;window["AscCommon"].g_oIdCounter=g_oIdCounter;window["AscCommon"].g_oHtmlCursor=g_oHtmlCursor;window["AscCommon"].g_oBackoffDefaults=g_oBackoffDefaults;window["AscCommon"].Backoff=Backoff;window["AscCommon"].backoffOnErrorImg=backoffOnErrorImg;window["AscCommon"].isEmptyObject=isEmptyObject;window["AscCommon"].CSignatureDrawer=
window["AscCommon"]["CSignatureDrawer"]=CSignatureDrawer;var prot=CSignatureDrawer.prototype;prot["getImages"]=prot.getImages;prot["setText"]=prot.setText;prot["selectImage"]=prot.selectImage;prot["isValid"]=prot.isValid;prot["destroy"]=prot.destroy;window["AscCommon"].translateManager=new CTranslateManager;window["AscCommon"].parseText=parseText;window["AscCommon"].getTimeISO8601=getTimeISO8601;window["AscCommon"].valueToMm=valueToMm;window["AscCommon"].valueToMmType=valueToMmType;window["AscCommon"].arrayMove=
arrayMove;window["AscCommon"].getRangeArray=getRangeArray;window["AscCommon"].CUnicodeStringEmulator=CUnicodeStringEmulator;window["AscCommon"].private_IsAbbreviation=private_IsAbbreviation;window["AscCommon"].rx_test_ws_name=rx_test_ws_name;window["AscCommon"].CShortcuts=window["AscCommon"]["CShortcuts"]=CShortcuts;prot=CShortcuts.prototype;prot["Add"]=prot.Add;prot["Get"]=prot.Get;prot["CheckType"]=prot.CheckType;prot["Remove"]=prot.Remove;prot["RemoveByType"]=prot.RemoveByType;prot["GetNewCustomType"]=
prot.GetNewCustomType;prot["IsCustomType"]=prot.IsCustomType;prot["GetCustomAction"]=prot.GetCustomAction;prot["AddCustomActionSymbol"]=prot.AddCustomActionSymbol;window["AscCommon"].CCustomShortcutActionSymbol=window["AscCommon"]["CCustomShortcutActionSymbol"]=CCustomShortcutActionSymbol})(window);
nCharCode<=40959||13312<=nCharCode&&nCharCode<=19903||131072<=nCharCode&&nCharCode<=173791||173824<=nCharCode&&nCharCode<=177983||177984<=nCharCode&&nCharCode<=178207||178208<=nCharCode&&nCharCode<=183983||63744<=nCharCode&&nCharCode<=64255||194560<=nCharCode&&nCharCode<=195103)return false}return true}return false}var g_oUserColorById={},g_oUserNextColorIndex=0;function getUserColorById(userId,userName,isDark,isNumericValue){if(window.parent.APP&&window.parent.APP.getUserColor)try{var CPColor=window.parent.APP.getUserColor(userId);
if(CPColor)return true===isNumericValue?CPColor.r<<16&16711680|CPColor.g<<8&65280|CPColor.b&255:CPColor}catch(e){}if((!userId||""===userId)&&(!userName||""===userName))return new CColor(0,0,0,255);var res;if(g_oUserColorById.hasOwnProperty(userId))res=g_oUserColorById[userId];else if(g_oUserColorById.hasOwnProperty(userName))res=g_oUserColorById[userName];else{var nColor=Asc.c_oAscArrUserColors[g_oUserNextColorIndex%Asc.c_oAscArrUserColors.length];++g_oUserNextColorIndex;res=g_oUserColorById[userId||
userName]=new CUserCacheColor(nColor)}if(!res)return new CColor(0,0,0,255);var oColor=true===isDark?res.Dark:res.Light;return true===isNumericValue?oColor.r<<16&16711680|oColor.g<<8&65280|oColor.b&255:oColor}function isNullOrEmptyString(str){return str==undefined||str==null||str==""}function unleakString(s){return(" "+s).substr(1)}function readValAttr(attr){if(attr()){var val=attr()["val"];return val?val:null}return null}function getNumFromXml(val){return val?val-0:null}function getColorFromXml(attr){if(attr()){var vals=
attr();if(null!=vals["theme"])return AscCommonExcel.g_oColorManager.getThemeColor(getNumFromXml(vals["theme"]),getNumFromXml(vals["tint"]));else if(null!=vals["rgb"])return new AscCommonExcel.RgbColor(16777215&getNumFromXml(vals["rgb"]))}return null}function getBoolFromXml(val){return"0"!==val&&"false"!==val&&"off"!==val}function CUserCacheColor(nColor){this.Light=null;this.Dark=null;this.init(nColor)}CUserCacheColor.prototype.init=function(nColor){var r=nColor>>16&255;var g=nColor>>8&255;var b=nColor&
255;var Y=Math.max(0,Math.min(255,.299*r+.587*g+.114*b));var Cb=Math.max(0,Math.min(255,128-.168736*r-.331264*g+.5*b));var Cr=Math.max(0,Math.min(255,128+.5*r-.418688*g-.081312*b));if(Y>63)Y=63;var R=Math.max(0,Math.min(255,Y+1.402*(Cr-128)))|0;var G=Math.max(0,Math.min(255,Y-.34414*(Cb-128)-.71414*(Cr-128)))|0;var B=Math.max(0,Math.min(255,Y+1.772*(Cb-128)))|0;this.Light=new CColor(r,g,b,255);this.Dark=new CColor(R,G,B,255)};function loadScript(url,onSuccess,onError){if(window["NATIVE_EDITOR_ENJINE"]===
true||window["Native"]!==undefined){onSuccess();return}if(window["AscDesktopEditor"]&&window["local_load_add"]){var _context={"completeLoad":function(){return onSuccess()}};window["local_load_add"](_context,"sdk-all-from-min",url);var _ret_param=window["AscDesktopEditor"]["LoadJS"](url);if(2!=_ret_param)window["local_load_remove"](url);if(_ret_param==1){setTimeout(onSuccess,1);return}else if(_ret_param==2)return}var backoff=new AscCommon.Backoff(AscCommon.g_oBackoffDefaults);loadScriptWithBackoff(backoff,
url,onSuccess,onError)}function loadScriptWithBackoff(backoff,url,onSuccess,onError){var script=document.createElement("script");script.type="text/javascript";script.src=url;script.onload=onSuccess;script.onerror=function(){backoff.attempt(onError,function(){loadScriptWithBackoff(backoff,url,onSuccess,onError)})};document.head.appendChild(script)}function loadSdk(sdkName,onSuccess,onError){if(window["AscNotLoadAllScript"])onSuccess();else{var urlArgs=window.parent&&window.parent.APP&&window.parent.APP.urlArgs||
"";loadScript("./../../../../sdkjs/"+sdkName+"/sdk-all.js?"+urlArgs,onSuccess,onError)}}function getAltGr(e){var ctrlKey=e.metaKey||e.ctrlKey;var altKey=e.altKey;return altKey&&(AscBrowser.isMacOs?!ctrlKey:ctrlKey)}function getColorSchemeByName(sName){for(var i=0;i<AscCommon.g_oUserColorScheme.length;++i){var tmp=AscCommon.g_oUserColorScheme[i];if(tmp&&tmp.name===sName)return getColorSchemeByIdx(i)}return null}function getColorSchemeByIdx(idx){var tmp=AscCommon.g_oUserColorScheme[idx];if(tmp){var scheme=
new AscFormat.ClrScheme,_c;scheme.name=tmp.name;_c=tmp.get_dk1();scheme.colors[8]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_lt1();scheme.colors[12]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_dk2();scheme.colors[9]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_lt2();scheme.colors[13]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent1();scheme.colors[0]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent2();scheme.colors[1]=AscFormat.CreateUniColorRGB(_c.r,
_c.g,_c.b);_c=tmp.get_accent3();scheme.colors[2]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent4();scheme.colors[3]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent5();scheme.colors[4]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent6();scheme.colors[5]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_hlink();scheme.colors[11]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_folHlink();scheme.colors[10]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);
return scheme}return null}function getAscColorScheme(_scheme,theme){var elem,_c;var _rgba={R:0,G:0,B:0,A:255};elem=new AscCommon.CAscColorScheme;elem.scheme=_scheme;elem.name=_scheme.name;_scheme.colors[8].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[8].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[12].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[12].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[9].Calculate(theme,null,null,
null,_rgba);_c=_scheme.colors[9].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[13].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[13].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[0].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[0].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[1].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[1].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[2].Calculate(theme,
null,null,null,_rgba);_c=_scheme.colors[2].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[3].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[3].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[4].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[4].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[5].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[5].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));
_scheme.colors[11].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[11].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[10].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[10].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));return elem}function getIndexColorSchemeInArray(result,asc_color_scheme){for(var j=0;j<result.length;++j)if(result[j].isEqual(asc_color_scheme))return j;return-1}function checkAddColorScheme(result,asc_color_scheme,nStartIndex){var nIndex=
getIndexColorSchemeInArray(result,asc_color_scheme);if(nIndex>-1)return nIndex;var nStartIndex_=nStartIndex;if(nStartIndex===null)nStartIndex_=result.length;result.splice(nStartIndex_,0,asc_color_scheme);return nStartIndex_}function isEastAsianScript(value){return 12544<=value&&value<=12591||12704<=value&&value<=12735||19968<=value&&value<=40938||13312<=value&&value<=19893||131072<=value&&value<=173782||173824<=value&&value<=177972||177984<=value&&value<=178205||178208<=value&&value<=183969||183984<=
value&&value<=191456||63744<=value&&value<=64255||194560<=value&&value<=195103||12032<=value&&value<=12255||11904<=value&&value<=12031||12736<=value&&value<=12783||12272<=value&&value<=12287||4352<=value&&value<=4607||43360<=value&&value<=43391||55216<=value&&value<=55295||12592<=value&&value<=12687||65280<=value&&value<=65519||44032<=value&&value<=55215||12352<=value&&value<=12447||110848<=value&&value<=110895||110592<=value&&value<=110847||12688<=value&&value<=12703||12448<=value&&value<=12543||
12784<=value&&value<=12799||42192<=value&&value<=42239||93952<=value&&value<=94111||110960<=value&&value<=111359||94208<=value&&value<=100332||100352<=value&&value<=101119||40960<=value&&value<=42127||42128<=value&&value<=42191}var g_oIdCounter=new CIdCounter;window.Asc.g_signature_drawer=null;function CSignatureDrawer(id,api,w,h){window.Asc.g_signature_drawer=this;this.Api=api;this.CanvasParent=document.getElementById(id);this.Canvas=document.createElement("canvas");this.Canvas.style.position="absolute";
this.Canvas.style.left="0px";this.Canvas.style.top="0px";var _width=parseInt(this.CanvasParent.offsetWidth);var _height=parseInt(this.CanvasParent.offsetHeight);if(0==_width)_width=300;if(0==_height)_height=80;this.Canvas.width=_width;this.Canvas.height=_height;this.CanvasParent.appendChild(this.Canvas);this.Image="";this.ImageHtml=null;this.Text="";this.Font="Arial";this.Size=10;this.Italic=true;this.Bold=false;this.Width=w;this.Height=h;this.CanvasReturn=null;this.IsAsync=false}CSignatureDrawer.prototype.getCanvas=
function(){return this.CanvasReturn==null?this.Canvas:this.CanvasReturn};CSignatureDrawer.prototype.getImages=function(){if(!this.isValid())return["",""];this.CanvasReturn=document.createElement("canvas");this.CanvasReturn.width=this.Width*AscCommon.g_dKoef_mm_to_pix;this.CanvasReturn.height=this.Height*AscCommon.g_dKoef_mm_to_pix;if(this.Text!="")this.drawText();else this.drawImage();var _ret=[];_ret.push(this.CanvasReturn.toDataURL("image/png"));var _ctx=this.CanvasReturn.getContext("2d");_ctx.strokeStyle=
"#FF0000";_ctx.lineWidth=2;_ctx.moveTo(0,0);_ctx.lineTo(this.CanvasReturn.width,this.CanvasReturn.height);_ctx.moveTo(0,this.CanvasReturn.height);_ctx.lineTo(this.CanvasReturn.width,0);_ctx.stroke();_ret.push(this.CanvasReturn.toDataURL("image/png"));this.CanvasReturn=null;return _ret};CSignatureDrawer.prototype.setText=function(text,font,size,isItalic,isBold){if(this.IsAsync){this.Text=text;return}this.Image="";this.ImageHtml=null;this.Text=text;this.Font=font;this.Size=size;this.Italic=isItalic;
this.Bold=isBold;this.IsAsync=true;AscFonts.FontPickerByCharacter.checkText(this.Text,this,function(){this.IsAsync=false;var loader=AscCommon.g_font_loader;var fontinfo=AscFonts.g_fontApplication.GetFontInfo(font);var isasync=loader.LoadFont(fontinfo,function(){window.Asc.g_signature_drawer.Api.sync_EndAction(Asc.c_oAscAsyncActionType.Information,Asc.c_oAscAsyncAction.LoadFont);window.Asc.g_signature_drawer.drawText()});if(false===isasync)this.drawText()})};CSignatureDrawer.prototype.drawText=function(){var _oldTurn=
this.Api.isViewMode;var _oldMarks=this.Api.ShowParaMarks;this.Api.isViewMode=true;this.Api.ShowParaMarks=false;AscFormat.ExecuteNoHistory(AscCommon.DrawTextByCenter,this,[]);this.Api.isViewMode=_oldTurn;this.Api.ShowParaMarks=_oldMarks};CSignatureDrawer.prototype.drawImage=function(){var _canvas=this.getCanvas();var w=_canvas.width;var h=_canvas.height;var _ctx=_canvas.getContext("2d");_ctx.clearRect(0,0,w,h);var im_w=this.ImageHtml.width;var im_h=this.ImageHtml.height;var _x=0;var _y=0;var _w=0;
var _h=0;var koef1=w/h;var koef2=im_w/im_h;if(koef1>koef2){_h=h;_w=koef2*_h>>0;_y=0;_x=w-_w>>1}else{_w=w;_h=_w/koef2>>0;_x=0;_y=h-_h>>1}_ctx.drawImage(this.ImageHtml,_x,_y,_w,_h)};CSignatureDrawer.prototype.selectImage=CSignatureDrawer.prototype["selectImage"]=function(){this.Text="";window["AscDesktopEditor"]["OpenFilenameDialog"]("images",false,function(_file){var file=_file;if(Array.isArray(file))file=file[0];if(!file)return;var _drawer=window.Asc.g_signature_drawer;_drawer.Image=window["AscDesktopEditor"]["GetImageBase64"](file);
_drawer.ImageHtml=new Image;_drawer.ImageHtml.onload=function(){window.Asc.g_signature_drawer.drawImage()};_drawer.ImageHtml.src=_drawer.Image;_drawer=null})};CSignatureDrawer.prototype.isValid=function(){return this.Image!=""||this.Text!=""};CSignatureDrawer.prototype.destroy=function(){window.Asc.g_signature_drawer.CanvasParent.removeChild(this.Canvas);delete window.Asc.g_signature_drawer};function CSignatureImage(){this.ImageValidBase64="";this.ImageInvalidBase64="";this.ImageValid=null;this.ImageInvalid=
null;this.Valid=false;this.Loading=0;this.Remove=function(){this.ImageValidBase64="";this.ImageInvalidBase64="";this.ImageValid=null;this.ImageInvalid=null;this.Valid=false;this.Loading=0};this.Register=function(_api,_guid){if(_api.ImageLoader.map_image_index[_guid])return;var _obj={Image:this.Valid?this.ImageValid:this.ImageInvalid,Status:AscFonts.ImageLoadStatus.Complete,src:_guid};_api.ImageLoader.map_image_index[_guid]=_obj};this.Unregister=function(_api,_guid){if(_api.ImageLoader.map_image_index[_guid])delete _api.ImageLoader.map_image_index[_guid]}}
function CShortcuts(){this.List={};this.CustomCounter=0;this.CustomActions={}}CShortcuts.prototype.Add=function(nType,nCode,isCtrl,isShift,isAlt){this.List[this.private_GetIndex(nCode,isCtrl,isShift,isAlt)]=nType};CShortcuts.prototype.Get=function(nCode,isCtrl,isShift,isAlt){var nType=this.List[this.private_GetIndex(nCode,isCtrl,isShift,isAlt)];return undefined!==nType?nType:0};CShortcuts.prototype.private_GetIndex=function(nCode,isCtrl,isShift,isAlt){return nCode<<8|(isCtrl?4:0)|(isShift?2:0)|(isAlt?
1:0)};CShortcuts.prototype.CheckType=function(nType){for(var nIndex in this.List)if(this.List[nIndex]===nType)return{KeyCode:nIndex>>>8,CtrlKey:!!(nIndex&4),ShiftKey:!!(nIndex&2),AltKey:!!(nIndex&1)};return null};CShortcuts.prototype.Remove=function(nCode,isCtrl,isShift,isAlt){delete this.List[this.private_GetIndex(nCode,isCtrl,isShift,isAlt)]};CShortcuts.prototype.RemoveByType=function(nType){for(var nIndex in this.List)if(this.List[nIndex]===nType)delete this.List[nIndex]};CShortcuts.prototype.GetNewCustomType=
function(){return 16711680|this.CustomCounter++};CShortcuts.prototype.IsCustomType=function(nType){return nType>=16711680};CShortcuts.prototype.GetCustomAction=function(nType){return this.CustomActions[nType]};CShortcuts.prototype.AddCustomActionSymbol=function(nCharCode,sFont){var nType=this.GetNewCustomType();this.CustomActions[nType]=new CCustomShortcutActionSymbol(nCharCode,sFont);return nType};function CCustomShortcutActionSymbol(nCharCode,sFont){this.CharCode=nCharCode;this.Font=sFont}CCustomShortcutActionSymbol.prototype.Type=
AscCommon.c_oAscCustomShortcutType.Symbol;AscCommon.EncryptionMessageType={Encrypt:0,Decrypt:1};function CEncryptionData(){this._init=false;this.arrData=[];this.arrImages=[];this.handleChangesCallback=null;this.isChangesHandled=false;this.cryptoMode=0;this.isChartEditor=false;this.isExistDecryptedChanges=false;this.cryptoPrefix=window["AscDesktopEditor"]&&window["AscDesktopEditor"]["GetEncryptedHeader"]?window["AscDesktopEditor"]["GetEncryptedHeader"]():"ENCRYPTED;";this.cryptoPrefixLen=this.cryptoPrefix.length;
this.editorId=null;this.nextChangesTimeoutId=-1;this.isPasswordCryptoPresent=false;this.init=function(){this._init=true};this.isInit=function(){return this._init};this.isNeedCrypt=function(){if(window.g_asc_plugins)if(!window.g_asc_plugins.isRunnedEncryption())return false;if(!window["AscDesktopEditor"])return false;if(this.isChartEditor)return false;if(2==this.cryptoMode)return true;if(0===window["AscDesktopEditor"]["CryptoMode"])return false;return true};this.isCryptoImages=function(){return this.isNeedCrypt()&&
this.isPasswordCryptoPresent};this.addCryproImagesFromDialog=function(callback){var _this=this;window["AscDesktopEditor"]["OpenFilenameDialog"]("images",true,function(files){if(!files)return;if(!Array.isArray(files))files=[files];if(0===files.length)return;var _files=[];var _options={isImageCrypt:true,callback:callback,ext:[]};for(var i=0;i<files.length;i++){_files.push(window["AscDesktopEditor"]["GetImageBase64"](files[i],true));_options.ext.push(AscCommon.GetFileExtension(files[i]))}_this.sendChanges(this,
_files,AscCommon.EncryptionMessageType.Encrypt,_options)})};this.addCryproImagesFromUrls=function(urls,callback){var _editor=window["Asc"]["editor"]?window["Asc"]["editor"]:window.editor;_editor.sync_StartAction(Asc.c_oAscAsyncActionType.BlockInteraction,Asc.c_oAscAsyncAction.LoadImage);var _this=this;window["AscDesktopEditor"]["DownloadFiles"](urls,[],function(files){_editor.sync_EndAction(Asc.c_oAscAsyncActionType.BlockInteraction,Asc.c_oAscAsyncAction.LoadImage);_editor.sync_StartAction(Asc.c_oAscAsyncActionType.BlockInteraction,
Asc.c_oAscAsyncAction.UploadImage);var _files=[];var _options={isImageCrypt:true,isUrls:true,callback:callback,ext:[],api:_editor};for(var elem in files){_files.push(window["AscDesktopEditor"]["GetImageBase64"](files[elem],true));_options.ext.push(window["AscDesktopEditor"]["GetImageFormat"](files[elem]));window["AscDesktopEditor"]["RemoveFile"](files[elem])}_this.sendChanges(this,_files,AscCommon.EncryptionMessageType.Encrypt,_options)})};this.onDecodeError=function(){var _editor=window["Asc"]["editor"]?
window["Asc"]["editor"]:window.editor;_editor.sendEvent("asc_onError",Asc.c_oAscError.ID.DataEncrypted,Asc.c_oAscError.Level.Critical)};this.checkEditorId=function(){if(null==this.editorId){var _editor=window["Asc"]["editor"]?window["Asc"]["editor"]:window.editor;this.editorId=_editor.editorId}};this.decryptImage=function(src,img,data){this.sendChanges(this,[data],AscCommon.EncryptionMessageType.Decrypt,{isImageDecrypt:true,src:src,img:img})};this.nextChanges=function(){this.nextChangesTimeoutId=
setTimeout(function(){AscCommon.EncryptionWorker.sendChanges(undefined,undefined);this.nextChangesTimeoutId=-1},10)};this.sendChanges=function(sender,data,type,options){if(!this.isNeedCrypt()){if(AscCommon.EncryptionMessageType.Encrypt==type)sender._send(data,true);else if(AscCommon.EncryptionMessageType.Decrypt==type){if(this.isExistEncryptedChanges(data["changes"])){this.onDecodeError();return}sender._onSaveChanges(data,true)}return}if(undefined!==type)this.arrData.push({sender:sender,type:type,
data:data,options:options});if(this.arrData.length==0)return;if(undefined!==type&&(1!=this.arrData.length||!this.isChangesHandled))return;if(undefined!==type&&-1!=this.nextChangesTimeoutId){clearTimeout(this.nextChangesTimeoutId);this.nextChangesTimeoutId=-1}if(AscCommon.EncryptionMessageType.Encrypt==this.arrData[0].type)if(this.arrData[0].options&&this.arrData[0].options.isImageCrypt)window.g_asc_plugins.sendToEncryption({"type":"encryptData","data":this.arrData[0].data});else window.g_asc_plugins.sendToEncryption({"type":"encryptData",
"data":JSON.parse(this.arrData[0].data["changes"])});else if(AscCommon.EncryptionMessageType.Decrypt==this.arrData[0].type)if(this.arrData[0].options&&this.arrData[0].options.isImageDecrypt)window.g_asc_plugins.sendToEncryption({"type":"decryptData","data":this.arrData[0].data});else window.g_asc_plugins.sendToEncryption({"type":"decryptData","data":this.arrData[0].data["changes"]})};this.receiveChanges=function(obj){var data=obj["data"];var check=obj["check"];if(!check){this.onDecodeError();return}if(this.handleChangesCallback){this.isExistDecryptedChanges=
true;this.checkEditorId();if(this.editorId==AscCommon.c_oEditorId.Spreadsheet)for(var i=data.length-1;i>=0;i--)this.handleChangesCallback.changesBase[i]=data[i];else for(var i=data.length-1;i>=0;i--)this.handleChangesCallback.changesBase[i].m_pData=data[i];this.isChangesHandled=true;this.handleChangesCallback.callback.call(this.handleChangesCallback.sender);this.handleChangesCallback=null;this.nextChanges();return}var obj=this.arrData[0];this.arrData.splice(0,1);if(AscCommon.EncryptionMessageType.Encrypt==
obj.type)if(obj.options&&obj.options.isImageCrypt){for(var i=0;i<data.length;i++)if(this.cryptoPrefix==data[i].substr(0,this.cryptoPrefixLen))data[i]=this.cryptoPrefix+obj.options.ext[i]+";"+data[i].substr(this.cryptoPrefixLen);if(!obj.options.isUrls)obj.options.callback(Asc.c_oAscError.ID.No,data);else AscCommon.UploadImageUrls(data,obj.options.api.documentId,obj.options.api.documentUserId,obj.options.api.CoAuthoringApi.get_jwt(),function(urls){obj.options.api.sync_EndAction(Asc.c_oAscAsyncActionType.BlockInteraction,
Asc.c_oAscAsyncAction.UploadImage);obj.options.callback(urls)})}else{obj.data["changes"]=JSON.stringify(data);obj.sender._send(obj.data,true)}else if(AscCommon.EncryptionMessageType.Decrypt==obj.type)if(obj.options&&obj.options.isImageDecrypt){window["AscDesktopEditor"]["ResaveFile"](obj.options.src,data[0]);obj.options.img["onload_crypto"](obj.options.src)}else{this.isExistDecryptedChanges=true;obj.data["changes"]=data;obj.sender._onSaveChanges(obj.data,true)}this.nextChanges()};this.isExistEncryptedChanges=
function(_array){if(0==_array.length)return false;this.checkEditorId();var isChangesMode=_array[0]["change"]?true:false;var _prefix="";var _checkPrefixLen=this.cryptoPrefixLen+1;if(isChangesMode){for(var i=_array.length-1;i>=0;i--)if(_array[i]["change"].length>_checkPrefixLen){_prefix=_array[i]["change"].substr(0,_checkPrefixLen);if(-1!=_prefix.indexOf(this.cryptoPrefix)){isCrypted=true;break}}return isCrypted}var isCrypted=false;if(this.editorId==AscCommon.c_oEditorId.Spreadsheet)for(var i=_array.length-
1;i>=0;i--){if(_array[i].length>_checkPrefixLen){_prefix=_array[i].substr(0,_checkPrefixLen);if(-1!=_prefix.indexOf(this.cryptoPrefix)){isCrypted=true;break}}}else for(var i=_array.length-1;i>=0;i--)if(_array[i].m_pData.length>_checkPrefixLen){_prefix=_array[i].m_pData.substr(0,_checkPrefixLen);if(-1!=_prefix.indexOf(this.cryptoPrefix)){isCrypted=true;break}}return isCrypted};this.handleChanges=function(_array,_sender,_callback){if(0==_array.length||!this.isNeedCrypt()){if(this.isExistEncryptedChanges(_array)){this.onDecodeError();
return}this.isChangesHandled=true;_callback.call(_sender);return}this.handleChangesCallback={changesBase:_array,changes:[],sender:_sender,callback:_callback};this.checkEditorId();if(this.editorId==AscCommon.c_oEditorId.Spreadsheet)for(var i=_array.length-1;i>=0;i--)this.handleChangesCallback.changes[i]=_array[i];else for(var i=_array.length-1;i>=0;i--)this.handleChangesCallback.changes[i]=_array[i].m_pData;window.g_asc_plugins.sendToEncryption({"type":"decryptData","data":this.handleChangesCallback.changes})};
this.asc_setAdvancedOptions=function(api,idOption,option){if(window.isNativeOpenPassword){window["AscDesktopEditor"]["NativeViewerOpen"](option.asc_getPassword());return}if(window.isCloudCryptoDownloadAs)return false;if(!this.isNeedCrypt())return false;window.checkPasswordFromPlugin=true;if(window["Asc"].c_oAscAdvancedOptionsID.TXT===idOption){var _param="<m_nCsvTxtEncoding>"+option.asc_getCodePage()+"</m_nCsvTxtEncoding>";window["AscDesktopEditor"]["SetAdvancedOptions"](_param)}else if(window["Asc"].c_oAscAdvancedOptionsID.CSV===
idOption){var delimiter=option.asc_getDelimiter();var delimiterChar=option.asc_getDelimiterChar();var _param="";_param+="<m_nCsvTxtEncoding>"+option.asc_getCodePage()+"</m_nCsvTxtEncoding>";if(null!=delimiter)_param+="<m_nCsvDelimiter>"+delimiter+"</m_nCsvDelimiter>";if(null!=delimiterChar)_param+="<m_nCsvDelimiterChar>"+delimiterChar+"</m_nCsvDelimiterChar>";window["AscDesktopEditor"]["SetAdvancedOptions"](_param)}else if(window["Asc"].c_oAscAdvancedOptionsID.DRM===idOption){var _param="<m_sPassword>"+
AscCommon.CopyPasteCorrectString(option.asc_getPassword())+"</m_sPassword>";api.currentPassword=option.asc_getPassword();window["AscDesktopEditor"]["SetAdvancedOptions"](_param)}return true}}AscCommon.EncryptionWorker=new CEncryptionData;function CMouseSmoothWheelCorrector(t,scrollFunction){this._deltaX=0;this._deltaY=0;this._isBreakX=false;this._isBreakY=false;this._timeoutCorrector=-1;this._api=t;this._scrollFunction=scrollFunction;this._normalDelta=120;this._isNormalDeltaActive=false;this.setNormalDeltaActive=
function(value){this._isNormalDeltaActive=true;this._normalDelta=value};this.isBreakX=function(){return this._isBreakX};this.isBreakY=function(){return this._isBreakY};this.get_DeltaX=function(wheelDeltaX){this._isBreakX=false;if(!AscCommon.AscBrowser.isMacOs)return wheelDeltaX;this._deltaX+=wheelDeltaX;if(Math.abs(this._deltaX)>=this._normalDelta)return this._isNormalDeltaActive?this._deltaX>0?this._normalDelta:-this._normalDelta:this._deltaX;this._isBreakX=true;return 0};this.get_DeltaY=function(wheelDeltaY){this._isBreakY=
false;if(!AscCommon.AscBrowser.isMacOs)return wheelDeltaY;this._deltaY+=wheelDeltaY;if(Math.abs(this._deltaY)>=this._normalDelta)return this._isNormalDeltaActive?this._deltaY>0?this._normalDelta:-this._normalDelta:this._deltaY;this._isBreakY=true;return 0};this.checkBreak=function(){if(-1!=this._timeoutCorrector){clearTimeout(this._timeoutCorrector);this._timeoutCorrector=-1}if((this._isBreakX||this._isBreakY)&&this._scrollFunction){var obj={t:this,x:this._isBreakX?this._deltaX:0,y:this._isBreakY?
this._deltaY:0};this._timeoutCorrector=setTimeout(function(){var t=obj.t;t._scrollFunction.call(t._api,obj.x,obj.y);t._timeoutCorrector=-1;t._deltaX=0;t._deltaY=0},100)}if(!this._isBreakX)this._deltaX=0;if(!this._isBreakY)this._deltaY=0;this._isBreakX=false;this._isBreakY=false}}AscCommon.CMouseSmoothWheelCorrector=CMouseSmoothWheelCorrector;function CTranslateManager(){this.mapTranslate={}}CTranslateManager.prototype.init=function(map){this.mapTranslate=map||{}};CTranslateManager.prototype.getValue=
function(key){return this.mapTranslate.hasOwnProperty(key)?this.mapTranslate[key]:key};function CPolygonPoint2(X,Y){this.X=X;this.Y=Y}function CPolygonVectors(){this.Page=-1;this.VX=[];this.VY=[]}function CPolygonPath(precision){this.Page=-1;this.Direction=1;this.precision=precision;this.Points=[]}CPolygonPath.prototype.PushPoint=function(x,y){this.Points.push(new CPolygonPoint2(x/this.precision,y/this.precision))};CPolygonPath.prototype.CorrectExtremePoints=function(){var Lng=this.Points.length;
this.Points[0].X=this.Points[Lng-1].X;this.Points[Lng-1].Y=this.Points[0].Y};function CPolygon(){this.Vectors=[];this.precision=1E3}CPolygon.prototype.fill=function(arrBounds){this.Vectors.length=0;if(arrBounds.length<=0)return;var nStartLineIndex=0,nStartIndex=0,CountLines=arrBounds.length,CountBounds;while(nStartLineIndex<arrBounds.length){CountBounds=arrBounds[nStartLineIndex].length;while(nStartIndex<CountBounds)if(arrBounds[nStartLineIndex][nStartIndex].W<.001)nStartIndex++;else break;if(nStartIndex<
CountBounds)break;nStartLineIndex++;nStartIndex=0}if(nStartLineIndex>=arrBounds.length)return;var CurrentPage=arrBounds[nStartLineIndex][nStartIndex].Page,CurrentVectors=new CPolygonVectors,VectorsX=CurrentVectors.VX,VectorsY=CurrentVectors.VY;CurrentVectors.Page=CurrentPage;this.Vectors.push(CurrentVectors);for(var LineIndex=nStartLineIndex;LineIndex<CountLines;nStartIndex=0,LineIndex++){if(arrBounds[LineIndex][nStartIndex].Page!==CurrentPage){CurrentPage=arrBounds[LineIndex][nStartIndex].Page;CurrentVectors=
new CPolygonVectors;VectorsX=CurrentVectors.VX;VectorsY=CurrentVectors.VY;CurrentVectors.Page=CurrentPage;this.Vectors.push(CurrentVectors)}for(var Index=nStartIndex;Index<arrBounds[LineIndex].length;Index++){var oBound=arrBounds[LineIndex][Index];if(oBound.W<.001)continue;var x1=Math.round(oBound.X*this.precision),x2=Math.round((oBound.X+oBound.W)*this.precision),y1=Math.round(oBound.Y*this.precision),y2=Math.round((oBound.Y+oBound.H)*this.precision);if(VectorsX[y1]==undefined)VectorsX[y1]={};this.IntersectionX(VectorsX,
x2,x1,y1);if(VectorsY[x1]==undefined)VectorsY[x1]={};this.IntersectionY(VectorsY,y1,y2,x1);if(VectorsX[y2]==undefined)VectorsX[y2]={};this.IntersectionX(VectorsX,x1,x2,y2);if(VectorsY[x2]==undefined)VectorsY[x2]={};this.IntersectionY(VectorsY,y2,y1,x2)}}};CPolygon.prototype.IntersectionX=function(VectorsX,BeginX,EndX,Y){var CurrentVector={};CurrentVector[BeginX]=EndX;var VX=VectorsX[Y];if(BeginX>EndX)while(true==this.IntersectVectorX(CurrentVector,VX));else while(true==this.IntersectVectorX(VX,CurrentVector));
for(var X in CurrentVector){var VBeginX=parseInt(X);var VEndX=CurrentVector[VBeginX];if(VBeginX!==VEndX||VX[VBeginX]===undefined)VX[VBeginX]=VEndX}};CPolygon.prototype.IntersectVectorX=function(VectorOpp,VectorClW){for(var X in VectorOpp){var VBeginX=parseInt(X);var VEndX=VectorOpp[VBeginX];if(VEndX==VBeginX)continue;for(var ClwX in VectorClW){var ClwBeginX=parseInt(ClwX);var ClwEndX=VectorClW[ClwBeginX];var bIntersection=false;if(ClwBeginX==ClwEndX)continue;if(ClwBeginX<=VEndX&&VBeginX<=ClwEndX){VectorOpp[VBeginX]=
VBeginX;VectorClW[ClwBeginX]=VEndX;VectorClW[VBeginX]=ClwEndX;bIntersection=true}else if(VEndX<=ClwBeginX&&ClwEndX<=VBeginX){VectorClW[ClwBeginX]=ClwBeginX;VectorOpp[VBeginX]=ClwEndX;VectorOpp[ClwBeginX]=VEndX;bIntersection=true}else if(ClwBeginX<VEndX&&VEndX<ClwEndX){VectorClW[ClwBeginX]=VEndX;VectorOpp[VBeginX]=ClwEndX;bIntersection=true}else if(ClwBeginX<VBeginX&&VBeginX<ClwEndX){VectorOpp[ClwBeginX]=VEndX;VectorClW[VBeginX]=ClwEndX;delete VectorOpp[VBeginX];delete VectorClW[ClwBeginX];bIntersection=
true}if(bIntersection==true)return true}}return false};CPolygon.prototype.IntersectionY=function(VectorsY,BeginY,EndY,X){var bIntersect=false;for(var y in VectorsY[X]){var CurBeginY=parseInt(y);var CurEndY=VectorsY[X][CurBeginY];var minY,maxY;if(CurBeginY<CurEndY){minY=CurBeginY;maxY=CurEndY}else{minY=CurEndY;maxY=CurBeginY}var bInterSection=!(maxY<=BeginY&&maxY<=EndY||minY>=BeginY&&minY>=EndY),bDirection=(CurBeginY-CurEndY)*(BeginY-EndY)<0;if(bInterSection&&bDirection){VectorsY[X][CurBeginY]=EndY;
VectorsY[X][BeginY]=CurEndY;bIntersect=true}}if(bIntersect==false)VectorsY[X][BeginY]=EndY};CPolygon.prototype.GetPaths=function(shift){var Paths=[];shift*=this.precision;for(var PageIndex=0;PageIndex<this.Vectors.length;PageIndex++){var y,x1,x2,x,y1,y2;var VectorsX=this.Vectors[PageIndex].VX,VectorsY=this.Vectors[PageIndex].VY,Page=this.Vectors[PageIndex].Page;for(var LineIndex in VectorsX)for(var Index in VectorsX[LineIndex]){var Polygon=new CPolygonPath(this.precision);Polygon.Page=Page;y=parseInt(LineIndex);
x1=parseInt(Index);x2=VectorsX[y][x1];VectorsX[y][x1]=-1;var Direction=x1>x2?1:-1;var minY=y;var SignRightLeft,SignDownUp;var X,Y;if(x2!==-1){SignRightLeft=x1>x2?1:-1;Y=y-SignRightLeft*shift;Polygon.PushPoint(x1,Y);while(true){x=x2;y1=y;y2=VectorsY[x][y1];if(y2==-1)break;else if(y2==undefined)return[];VectorsY[x][y1]=-1;SignDownUp=y1>y2?1:-1;X=x+SignDownUp*shift;Polygon.PushPoint(X,Y);y=y2;x1=x;x2=VectorsX[y][x1];if(x2==-1)break;else if(x2==undefined)return[];VectorsX[y][x1]=-1;SignRightLeft=x1>x2?
1:-1;Y=y-SignRightLeft*shift;Polygon.PushPoint(X,Y);if(y<minY){minY=y;Direction=x1>x2?1:-1}}Polygon.PushPoint(X,Y);Polygon.CorrectExtremePoints();Polygon.Direction=Direction;Paths.push(Polygon)}}}return Paths};function CMathTrack(){this.MathRect={IsActive:false,Bounds:[],ContentSelection:null};this.MathPolygons=[];this.MathSelectPolygons=[]}CMathTrack.prototype.Update=function(IsActive,IsContentActive,oMath,PixelError){this.MathRect.IsActive=IsActive;if(true===IsActive&&null!==oMath){var selectBounds=
true===IsContentActive?oMath.Get_ContentSelection():null;if(selectBounds!=null){var SelectPolygon=new CPolygon;SelectPolygon.fill(selectBounds);this.MathSelectPolygons=SelectPolygon.GetPaths(0)}else this.MathSelectPolygons.length=0;var arrBounds=oMath.Get_Bounds();if(arrBounds.length<=0)return;var MPolygon=new CPolygon;MPolygon.fill(arrBounds);this.MathPolygons=MPolygon.GetPaths(PixelError)}};CMathTrack.prototype.Draw=function(overlay,oPath,shift,color,dKoefX,dKoefY,left,top){var ctx=overlay.m_oContext;
ctx.strokeStyle=color;ctx.lineWidth=1;ctx.beginPath();var Points=oPath.Points;var nCount=Points.length;var PrevX=Points[nCount-2].X,PrevY=Points[nCount-2].Y;var _x=left+dKoefX*Points[nCount-2].X,_y=top+dKoefY*Points[nCount-2].Y;var StartX,StartY;for(var nIndex=0;nIndex<nCount;nIndex++){if(PrevX>Points[nIndex].X)_y=top+dKoefY*Points[nIndex].Y-shift;else if(PrevX<Points[nIndex].X)_y=top+dKoefY*Points[nIndex].Y+shift;if(PrevY<Points[nIndex].Y)_x=left+dKoefX*Points[nIndex].X-shift;else if(PrevY>Points[nIndex].Y)_x=
left+dKoefX*Points[nIndex].X+shift;PrevX=Points[nIndex].X;PrevY=Points[nIndex].Y;if(nIndex>0){overlay.CheckPoint(_x,_y);if(1==nIndex){StartX=_x;StartY=_y;overlay.m_oContext.moveTo((_x>>0)+.5,(_y>>0)+.5)}else overlay.m_oContext.lineTo((_x>>0)+.5,(_y>>0)+.5)}}overlay.m_oContext.lineTo((StartX>>0)+.5,(StartY>>0)+.5);ctx.closePath();ctx.stroke();ctx.beginPath()};CMathTrack.prototype.DrawWithMatrix=function(overlay,oPath,ShiftX,ShiftY,color,dKoefX,dKoefY,left,top,m){var ctx=overlay.m_oContext;ctx.strokeStyle=
color;ctx.lineWidth=1;ctx.beginPath();var Points=oPath.Points;var nCount=Points.length;var x=Points[nCount-2].X,y=Points[nCount-2].Y;var _x,_y;var PrevX=Points[nCount-2].X,PrevY=Points[nCount-2].Y;var StartX,StartY;for(var nIndex=0;nIndex<nCount;nIndex++){if(PrevX>Points[nIndex].X)y=Points[nIndex].Y-ShiftY;else if(PrevX<Points[nIndex].X)y=Points[nIndex].Y+ShiftY;if(PrevY<Points[nIndex].Y)x=Points[nIndex].X-ShiftX;else if(PrevY>Points[nIndex].Y)x=Points[nIndex].X+ShiftX;PrevX=Points[nIndex].X;PrevY=
Points[nIndex].Y;if(nIndex>0){_x=left+dKoefX*m.TransformPointX(x,y);_y=top+dKoefY*m.TransformPointY(x,y);overlay.CheckPoint(_x,_y);if(1==nIndex){StartX=_x;StartY=_y;overlay.m_oContext.moveTo((_x>>0)+.5,(_y>>0)+.5)}else overlay.m_oContext.lineTo((_x>>0)+.5,(_y>>0)+.5)}}overlay.m_oContext.lineTo((StartX>>0)+.5,(StartY>>0)+.5);ctx.closePath();ctx.stroke();ctx.beginPath()};CMathTrack.prototype.DrawSelectPolygon=function(overlay,oPath,dKoefX,dKoefY,left,top,m){var ctx=overlay.m_oContext;ctx.fillStyle=
"#375082";ctx.beginPath();var Points=oPath.Points;var nPointIndex;var _x,_y,x,y,p;for(nPointIndex=0;nPointIndex<Points.length-1;nPointIndex++){p=Points[nPointIndex];if(!m){_x=left+dKoefX*p.X;_y=top+dKoefY*p.Y}else{x=p.X;y=p.Y;_x=left+dKoefX*m.TransformPointX(x,y);_y=top+dKoefY*m.TransformPointY(x,y)}overlay.CheckPoint(_x,_y);if(0==nPointIndex)ctx.moveTo((_x>>0)+.5,(_y>>0)+.5);else ctx.lineTo((_x>>0)+.5,(_y>>0)+.5)}ctx.globalAlpha=.2;ctx.fill();ctx.globalAlpha=1};CMathTrack.prototype.IsActive=function(){return this.MathRect.IsActive};
CMathTrack.prototype.GetPolygonsCount=function(){return this.MathPolygons.length};CMathTrack.prototype.GetPolygon=function(nIndex){return this.MathPolygons[nIndex]};CMathTrack.prototype.GetSelectPathsCount=function(){return this.MathSelectPolygons.length};CMathTrack.prototype.GetSelectPath=function(nIndex){return this.MathSelectPolygons[nIndex]};if(!Array.prototype.findIndex)Object.defineProperty(Array.prototype,"findIndex",{value:function(predicate){if(this==null)throw new TypeError("Array.prototype.findIndex called on null or undefined");
if(typeof predicate!=="function")throw new TypeError("predicate must be a function");var list=Object(this);var length=list.length>>>0;var thisArg=arguments[1];var value;for(var i=0;i<length;i++){value=list[i];if(predicate.call(thisArg,value,i,list))return i}return-1}});if(!Array.prototype.fill)Object.defineProperty(Array.prototype,"fill",{value:function(value){if(this==null)throw new TypeError("this is null or not defined");var O=Object(this);var len=O.length>>>0;var start=arguments[1];var relativeStart=
start>>0;var k=relativeStart<0?Math.max(len+relativeStart,0):Math.min(relativeStart,len);var end=arguments[2];var relativeEnd=end===undefined?len:end>>0;var final=relativeEnd<0?Math.max(len+relativeEnd,0):Math.min(relativeEnd,len);while(k<final){O[k]=value;k++}return O}});if(typeof Int8Array!=="undefined"&&!Int8Array.prototype.fill)Int8Array.prototype.fill=Array.prototype.fill;if(typeof Uint8Array!=="undefined"&&!Uint8Array.prototype.fill)Uint8Array.prototype.fill=Array.prototype.fill;if(typeof Uint8ClampedArray!==
"undefined"&&!Uint8ClampedArray.prototype.fill)Uint8ClampedArray.prototype.fill=Array.prototype.fill;if(typeof Int16Array!=="undefined"&&!Int16Array.prototype.fill)Int16Array.prototype.fill=Array.prototype.fill;if(typeof Uint16Array!=="undefined"&&!Uint16Array.prototype.fill)Uint16Array.prototype.fill=Array.prototype.fill;if(typeof Int32Array!=="undefined"&&!Int32Array.prototype.fill)Int32Array.prototype.fill=Array.prototype.fill;if(typeof Uint32Array!=="undefined"&&!Uint32Array.prototype.fill)Uint32Array.prototype.fill=
Array.prototype.fill;if(typeof Float32Array!=="undefined"&&!Float32Array.prototype.fill)Float32Array.prototype.fill=Array.prototype.fill;if(typeof Float64Array!=="undefined"&&!Float64Array.prototype.fill)Float64Array.prototype.fill=Array.prototype.fill;if(typeof Uint8Array!=="undefined"&&!Uint8Array.prototype.slice)Uint8Array.prototype.slice=Array.prototype.slice;function parseText(text,options,bTrimSpaces){var delimiterChar;if(options.asc_getDelimiterChar())delimiterChar=options.asc_getDelimiterChar();
else switch(options.asc_getDelimiter()){case AscCommon.c_oAscCsvDelimiter.None:delimiterChar=undefined;break;case AscCommon.c_oAscCsvDelimiter.Tab:delimiterChar="\t";break;case AscCommon.c_oAscCsvDelimiter.Semicolon:delimiterChar=";";break;case AscCommon.c_oAscCsvDelimiter.Colon:delimiterChar=":";break;case AscCommon.c_oAscCsvDelimiter.Comma:delimiterChar=",";break;case AscCommon.c_oAscCsvDelimiter.Space:delimiterChar=" ";break}var matrix=[];var rows=text.split(/\r?\n/);for(var i=0;i<rows.length;++i){var row=
rows[i];if(" "===delimiterChar&&bTrimSpaces){var addSpace=false;if(row[0]===delimiterChar)addSpace=true;row=addSpace?delimiterChar+row.trim():row.trim()}matrix.push(row.split(delimiterChar))}return matrix}function getTimeISO8601(dateStr){if(dateStr)if(dateStr.endsWith("Z"))return Date.parse(dateStr);else return Date.parse(dateStr+"Z");return NaN}function valueToMmType(value){var oVal=parseFloat(value);var oType;if(!isNaN(oVal)){if(-1!==value.indexOf("%")){oType="%";oVal/=100}else if(-1!==value.indexOf("px")){oType=
"px";oVal*=AscCommon.g_dKoef_pix_to_mm}else if(-1!==value.indexOf("in")){oType="in";oVal*=AscCommonWord.g_dKoef_in_to_mm}else if(-1!==value.indexOf("cm")){oType="cm";oVal*=10}else if(-1!==value.indexOf("mm"))oType="mm";else if(-1!==value.indexOf("pt")){oType="pt";oVal*=AscCommonWord.g_dKoef_pt_to_mm}else if(-1!==value.indexOf("pc")){oType="pc";oVal*=AscCommonWord.g_dKoef_pc_to_mm}else oType="none";return{val:oVal,type:oType}}return null}function valueToMm(value){var obj=valueToMmType(value);if(obj&&
"%"!==obj.type&&"none"!==obj.type)return obj.val;return null}function arrayMove(array,from,to){array.splice(to,0,array.splice(from,1)[0])}function getRangeArray(start,stop){var res=new Array(stop-start);for(var i=start;i<stop;++i)res[i-start]=i;return res}var g_oBackoffDefaults={retries:2,factor:2,minTimeout:100,maxTimeout:2E3,randomize:true};function Backoff(opts){this.attempts=0;this.opts=opts}Backoff.prototype.attempt=function(fError,fRetry){var timeout=this.nextTimeout();if(timeout>0)setTimeout(function(){fRetry()},
timeout);else fError()};Backoff.prototype.nextTimeout=function(){var timeout=-1;if(this.attempts<this.opts.retries){timeout=this.createTimeout(this.attempts,this.opts);this.attempts++}return timeout};Backoff.prototype.createTimeout=function(attempt,opts){var random=opts.randomize?Math.random()+1:1;var timeout=Math.round(random*opts.minTimeout*Math.pow(opts.factor,attempt));timeout=Math.min(timeout,opts.maxTimeout);return timeout};function backoffOnError(obj,onError,onRetry){if(!onRetry)return onError;
var backoff=new Backoff(g_oBackoffDefaults);return function(){var timeout=backoff.nextTimeout();if(timeout>0)setTimeout(function(){onRetry.call(obj,obj)},timeout);else if(onError)onError.apply(obj,arguments)}}function backoffOnErrorImg(img,onRetry){if(!onRetry)onRetry=function(img){img.setAttribute("src",img.getAttribute("src"))};img.onerror=backoffOnError(img,img.onerror,onRetry)}function isEmptyObject(obj){for(var name in obj)return false;return true}window["AscCommon"]=window["AscCommon"]||{};
window["AscCommon"].getSockJs=getSockJs;window["AscCommon"].getJSZipUtils=getJSZipUtils;window["AscCommon"].getJSZip=getJSZip;window["AscCommon"].getBaseUrl=getBaseUrl;window["AscCommon"].getEncodingParams=getEncodingParams;window["AscCommon"].getEncodingByBOM=getEncodingByBOM;window["AscCommon"].saveWithParts=saveWithParts;window["AscCommon"].loadFileContent=loadFileContent;window["AscCommon"].getImageFromChanges=getImageFromChanges;window["AscCommon"].openFileCommand=openFileCommand;window["AscCommon"].sendCommand=
sendCommand;window["AscCommon"].sendSaveFile=sendSaveFile;window["AscCommon"].mapAscServerErrorToAscError=mapAscServerErrorToAscError;window["AscCommon"].joinUrls=joinUrls;window["AscCommon"].getFullImageSrc2=getFullImageSrc2;window["AscCommon"].fSortAscending=fSortAscending;window["AscCommon"].fSortDescending=fSortDescending;window["AscCommon"].isLeadingSurrogateChar=isLeadingSurrogateChar;window["AscCommon"].decodeSurrogateChar=decodeSurrogateChar;window["AscCommon"].encodeSurrogateChar=encodeSurrogateChar;
window["AscCommon"].convertUnicodeToUTF16=convertUnicodeToUTF16;window["AscCommon"].convertUTF16toUnicode=convertUTF16toUnicode;window["AscCommon"].build_local_rx=build_local_rx;window["AscCommon"].GetFileName=GetFileName;window["AscCommon"].GetFileExtension=GetFileExtension;window["AscCommon"].changeFileExtention=changeFileExtention;window["AscCommon"].getExtentionByFormat=getExtentionByFormat;window["AscCommon"].InitOnMessage=InitOnMessage;window["AscCommon"].ShowImageFileDialog=ShowImageFileDialog;
window["AscCommon"].ShowDocumentFileDialog=ShowDocumentFileDialog;window["AscCommon"].InitDragAndDrop=InitDragAndDrop;window["AscCommon"].UploadImageFiles=UploadImageFiles;window["AscCommon"].UploadImageUrls=UploadImageUrls;window["AscCommon"].CanDropFiles=CanDropFiles;window["AscCommon"].getUrlType=getUrlType;window["AscCommon"].prepareUrl=prepareUrl;window["AscCommon"].getUserColorById=getUserColorById;window["AscCommon"].isNullOrEmptyString=isNullOrEmptyString;window["AscCommon"].unleakString=
unleakString;window["AscCommon"].readValAttr=readValAttr;window["AscCommon"].getNumFromXml=getNumFromXml;window["AscCommon"].getColorFromXml=getColorFromXml;window["AscCommon"].getBoolFromXml=getBoolFromXml;window["AscCommon"].initStreamFromResponse=initStreamFromResponse;window["AscCommon"].checkStreamSignature=checkStreamSignature;window["AscCommon"].DocumentUrls=DocumentUrls;window["AscCommon"].OpenFileResult=OpenFileResult;window["AscCommon"].CLock=CLock;window["AscCommon"].CContentChanges=CContentChanges;
window["AscCommon"].CContentChangesElement=CContentChangesElement;window["AscCommon"].CorrectMMToTwips=CorrectMMToTwips;window["AscCommon"].TwipsToMM=TwipsToMM;window["AscCommon"].MMToTwips=MMToTwips;window["AscCommon"].RomanToInt=RomanToInt;window["AscCommon"].LatinNumberingToInt=LatinNumberingToInt;window["AscCommon"].IntToNumberFormat=IntToNumberFormat;window["AscCommon"].IsSpace=IsSpace;window["AscCommon"].loadSdk=loadSdk;window["AscCommon"].loadScript=loadScript;window["AscCommon"].getAltGr=
getAltGr;window["AscCommon"].getColorSchemeByName=getColorSchemeByName;window["AscCommon"].getColorSchemeByIdx=getColorSchemeByIdx;window["AscCommon"].getAscColorScheme=getAscColorScheme;window["AscCommon"].checkAddColorScheme=checkAddColorScheme;window["AscCommon"].getIndexColorSchemeInArray=getIndexColorSchemeInArray;window["AscCommon"].isEastAsianScript=isEastAsianScript;window["AscCommon"].CMathTrack=CMathTrack;window["AscCommon"].CPolygon=CPolygon;window["AscCommon"].JSZipWrapper=JSZipWrapper;
window["AscCommon"].g_oDocumentUrls=g_oDocumentUrls;window["AscCommon"].FormulaTablePartInfo=FormulaTablePartInfo;window["AscCommon"].cBoolLocal=cBoolLocal;window["AscCommon"].cErrorOrigin=cErrorOrigin;window["AscCommon"].cErrorLocal=cErrorLocal;window["AscCommon"].FormulaSeparators=FormulaSeparators;window["AscCommon"].rx_space_g=rx_space_g;window["AscCommon"].rx_space=rx_space;window["AscCommon"].rx_defName=rx_defName;window["AscCommon"].kCurFormatPainterWord=kCurFormatPainterWord;window["AscCommon"].parserHelp=
parserHelp;window["AscCommon"].g_oIdCounter=g_oIdCounter;window["AscCommon"].g_oHtmlCursor=g_oHtmlCursor;window["AscCommon"].g_oBackoffDefaults=g_oBackoffDefaults;window["AscCommon"].Backoff=Backoff;window["AscCommon"].backoffOnErrorImg=backoffOnErrorImg;window["AscCommon"].isEmptyObject=isEmptyObject;window["AscCommon"].CSignatureDrawer=window["AscCommon"]["CSignatureDrawer"]=CSignatureDrawer;var prot=CSignatureDrawer.prototype;prot["getImages"]=prot.getImages;prot["setText"]=prot.setText;prot["selectImage"]=
prot.selectImage;prot["isValid"]=prot.isValid;prot["destroy"]=prot.destroy;window["AscCommon"].translateManager=new CTranslateManager;window["AscCommon"].parseText=parseText;window["AscCommon"].getTimeISO8601=getTimeISO8601;window["AscCommon"].valueToMm=valueToMm;window["AscCommon"].valueToMmType=valueToMmType;window["AscCommon"].arrayMove=arrayMove;window["AscCommon"].getRangeArray=getRangeArray;window["AscCommon"].CUnicodeStringEmulator=CUnicodeStringEmulator;window["AscCommon"].private_IsAbbreviation=
private_IsAbbreviation;window["AscCommon"].rx_test_ws_name=rx_test_ws_name;window["AscCommon"].CShortcuts=window["AscCommon"]["CShortcuts"]=CShortcuts;prot=CShortcuts.prototype;prot["Add"]=prot.Add;prot["Get"]=prot.Get;prot["CheckType"]=prot.CheckType;prot["Remove"]=prot.Remove;prot["RemoveByType"]=prot.RemoveByType;prot["GetNewCustomType"]=prot.GetNewCustomType;prot["IsCustomType"]=prot.IsCustomType;prot["GetCustomAction"]=prot.GetCustomAction;prot["AddCustomActionSymbol"]=prot.AddCustomActionSymbol;
window["AscCommon"].CCustomShortcutActionSymbol=window["AscCommon"]["CCustomShortcutActionSymbol"]=CCustomShortcutActionSymbol})(window);
window["asc_initAdvancedOptions"]=function(_code,_file_hash,_docInfo){if(window.isNativeOpenPassword)return window["NativeFileOpen_error"](window.isNativeOpenPassword,_file_hash,_docInfo);var _editor=window["Asc"]["editor"]?window["Asc"]["editor"]:window.editor;if(_code==90||_code==91){if(window["AscDesktopEditor"]&&0!==window["AscDesktopEditor"]["CryptoMode"]&&!_editor.isLoadFullApi){_editor.asc_initAdvancedOptions_params=[];_editor.asc_initAdvancedOptions_params.push(_code);_editor.asc_initAdvancedOptions_params.push(_file_hash);
_editor.asc_initAdvancedOptions_params.push(_docInfo);return}if(AscCommon.EncryptionWorker.isNeedCrypt()&&!window.checkPasswordFromPlugin){window.checkPasswordFromPlugin=true;window.g_asc_plugins.sendToEncryption({"type":"getPasswordByFile","hash":_file_hash,"docinfo":_docInfo});return}}window.checkPasswordFromPlugin=false;_editor._onNeedParams(undefined,_code==90||_code==91?true:undefined)};
window["asc_IsNeedBuildCryptedFile"]=function(){if(!window["AscDesktopEditor"]||!window["AscDesktopEditor"]["CryptoMode"])return false;var _api=window["Asc"]["editor"]?window["Asc"]["editor"]:window.editor;var _returnValue=false;var _users=null;if(_api.CoAuthoringApi&&_api.CoAuthoringApi._CoAuthoringApi&&_api.CoAuthoringApi._CoAuthoringApi._participants)_users=_api.CoAuthoringApi._CoAuthoringApi._participants;var _usersCount=0;for(var _user in _users)_usersCount++;var isOne=1>=_usersCount?true:false;

@ -8412,18 +8412,18 @@ function(font_index,stream_index){this.embeddedFontFiles[font_index].SetStreamIn
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.LoadDocumentImagesCallback=function(){if(this.ThemeLoader==null)this.Api.asyncImagesDocumentEndLoaded();else this.ThemeLoader.asyncImagesEndLoaded()};this.LoadDocumentImages=
function(_images){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);var that=this;setTimeout(function(){that.LoadDocumentImagesCallback()},
3E3)}};this.loadImageByUrl=function(_image,_url){if(this.isBlockchainSupport)_image.preload_crypto(_url);else _image.src=_url};this._LoadImages=function(){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)});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)});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;var oThat=oThis;oImage.Image.onload=
function(){oImage.Status=ImageLoadStatus.Complete;oThat.Api.asyncImageEndLoadedBackground(oImage)};oImage.Image.onerror=function(){oImage.Status=ImageLoadStatus.Complete;oImage.Image=null;oThat.Api.asyncImageEndLoadedBackground(oImage)};AscCommon.backoffOnErrorImg(oImage.Image,function(img){oThis.loadImageByUrl(img,img.src)});console.log("Loading image "+i);console.log(oImage);window.parent.APP.getImageURL(oImage.src,function(url){if(url=="")oThis.loadImageByUrl(oImage.Image,oImage.src);else{oThis.loadImageByUrl(oImage.Image,
url);oThis.map_image_index[url]=oImage}})};this.LoadImagesWithCallback=function(arr,loadImageCallBack,loadImageCallBackArgs){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}this.loadImageCallBackCounter=0;this.loadImageCallBackCounterMax=arrAsync.length;this.loadImageCallBack=loadImageCallBack;this.loadImageCallBackArgs=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;oThis.loadImageCallBackCounter++;if(oThis.loadImageCallBackCounter==oThis.loadImageCallBackCounterMax)oThis.LoadImagesWithCallbackEnd()};oImage.Image.onerror=function(){this.parentImage.Image=null;this.parentImage.Status=ImageLoadStatus.Complete;
oThis.loadImageCallBackCounter++;if(oThis.loadImageCallBackCounter==oThis.loadImageCallBackCounterMax)oThis.LoadImagesWithCallbackEnd()};AscCommon.backoffOnErrorImg(oImage.Image,function(img){oThis.loadImageByUrl(img,img.src)});this.loadImageByUrl(oImage.Image,oImage.src)}};this.LoadImagesWithCallbackEnd=function(){this.loadImageCallBack.call(this.Api,this.loadImageCallBackArgs);this.loadImageCallBack=null;this.loadImageCallBackArgs=null;this.loadImageCallBackCounterMax=0;this.loadImageCallBackCounter=
0}}var g_flow_anchor=new Image;g_flow_anchor.asc_complete=false;g_flow_anchor.onload=function(){g_flow_anchor.asc_complete=true};g_flow_anchor.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPBAMAAADNDVhEAAAAIVBMVEUAAAANDQ0NDQ0NDQ0NDQ0NDQ0AAAANDQ0NDQ0NDQ0NDQ1jk7YPAAAACnRSTlMAGkD4mb9c5s9TDghpXQAAAFZJREFUCNdjYGBgW8YABlxcIBLBZ1gAEfZa5QWiGRkWMAIpAaA4iHQE0YwODEtANMsChkIwv4BBWQBICyswMC1iWADEDAzKoUuDFUAGNC9uABvIaQkkABpxD6lFb9lRAAAAAElFTkSuQmCC";var g_flow_anchor2=new Image;g_flow_anchor2.asc_complete=
false;g_flow_anchor2.onload=function(){g_flow_anchor2.asc_complete=true};g_flow_anchor2.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAeCAMAAAAFBf7qAAAAOVBMVEUAAAAAAAAAAAAAAAAJCQkAAAAJCQkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJCQknI0ZQAAAAEnRSTlMAx9ITlAfyPHxn68yecTAl5qt6y0BvAAAAt0lEQVQoz8WS0QrDIAxFk0ajtlXb+/8fuzAprltg7Gnn4aIcvAgJTSSoBiGPoIAGV60qoquvIIL110IJgPONmKIlMI73MiwGRoZvahbKVSizcDKU8QeVPDXEIr6ShVB9VUEn2FOMkwL8VwjUtuypvDWiHeVTFeyWkZHfVQZHGm4XMhKQyJB9GKMxuHQSBlioF7u2q7kzgO2AcWwW3F8mWRmGKgyu91mK1Tzh4ixVVkBzJI/EnGjyACbfCaO3eIWRAAAAAElFTkSuQmCC";
function(_images){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;if(_len===0)return void this.LoadDocumentImagesCallback();var todo=_len;var that=this;var done=function(){todo--;
if(todo===0){that.images_loading.splice(0,_len);setTimeout(function(){that.LoadDocumentImagesCallback()},100);done=function(){}}};for(var i=0;i<_len;i++)this.LoadImageAsync(i,done);return;this.images_loading.splice(0,_len);var that=this;setTimeout(function(){that.LoadDocumentImagesCallback()},3E3)}};this.loadImageByUrl=function(_image,_url){if(this.isBlockchainSupport)_image.preload_crypto(_url);else _image.src=_url};this._LoadImages=function(){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)});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)});this.loadImageByUrl(oImage.Image,oImage.src);return null};this.LoadImageAsync=function(i,
cb){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;var oThat=oThis;oImage.Image.onload=function(){oImage.Status=ImageLoadStatus.Complete;oThat.Api.asyncImageEndLoadedBackground(oImage)};oImage.Image.onerror=function(){oImage.Status=ImageLoadStatus.Complete;oImage.Image=null;oThat.Api.asyncImageEndLoadedBackground(oImage)};AscCommon.backoffOnErrorImg(oImage.Image,function(img){oThis.loadImageByUrl(img,
img.src)});console.log("Loading image "+i);console.log(oImage);window.parent.APP.getImageURL(oImage.src,function(url){if(url=="")oThis.loadImageByUrl(oImage.Image,oImage.src);else{oThis.loadImageByUrl(oImage.Image,url);oThis.map_image_index[url]=oImage}if(typeof cb==="function")cb()})};this.LoadImagesWithCallback=function(arr,loadImageCallBack,loadImageCallBackArgs){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}this.loadImageCallBackCounter=0;this.loadImageCallBackCounterMax=arrAsync.length;this.loadImageCallBack=loadImageCallBack;this.loadImageCallBackArgs=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;
oThis.loadImageCallBackCounter++;if(oThis.loadImageCallBackCounter==oThis.loadImageCallBackCounterMax)oThis.LoadImagesWithCallbackEnd()};oImage.Image.onerror=function(){this.parentImage.Image=null;this.parentImage.Status=ImageLoadStatus.Complete;oThis.loadImageCallBackCounter++;if(oThis.loadImageCallBackCounter==oThis.loadImageCallBackCounterMax)oThis.LoadImagesWithCallbackEnd()};AscCommon.backoffOnErrorImg(oImage.Image,function(img){oThis.loadImageByUrl(img,img.src)});this.loadImageByUrl(oImage.Image,
oImage.src)}};this.LoadImagesWithCallbackEnd=function(){this.loadImageCallBack.call(this.Api,this.loadImageCallBackArgs);this.loadImageCallBack=null;this.loadImageCallBackArgs=null;this.loadImageCallBackCounterMax=0;this.loadImageCallBackCounter=0}}var g_flow_anchor=new Image;g_flow_anchor.asc_complete=false;g_flow_anchor.onload=function(){g_flow_anchor.asc_complete=true};g_flow_anchor.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPBAMAAADNDVhEAAAAIVBMVEUAAAANDQ0NDQ0NDQ0NDQ0NDQ0AAAANDQ0NDQ0NDQ0NDQ1jk7YPAAAACnRSTlMAGkD4mb9c5s9TDghpXQAAAFZJREFUCNdjYGBgW8YABlxcIBLBZ1gAEfZa5QWiGRkWMAIpAaA4iHQE0YwODEtANMsChkIwv4BBWQBICyswMC1iWADEDAzKoUuDFUAGNC9uABvIaQkkABpxD6lFb9lRAAAAAElFTkSuQmCC";
var g_flow_anchor2=new Image;g_flow_anchor2.asc_complete=false;g_flow_anchor2.onload=function(){g_flow_anchor2.asc_complete=true};g_flow_anchor2.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAeCAMAAAAFBf7qAAAAOVBMVEUAAAAAAAAAAAAAAAAJCQkAAAAJCQkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJCQknI0ZQAAAAEnRSTlMAx9ITlAfyPHxn68yecTAl5qt6y0BvAAAAt0lEQVQoz8WS0QrDIAxFk0ajtlXb+/8fuzAprltg7Gnn4aIcvAgJTSSoBiGPoIAGV60qoquvIIL110IJgPONmKIlMI73MiwGRoZvahbKVSizcDKU8QeVPDXEIr6ShVB9VUEn2FOMkwL8VwjUtuypvDWiHeVTFeyWkZHfVQZHGm4XMhKQyJB9GKMxuHQSBlioF7u2q7kzgO2AcWwW3F8mWRmGKgyu91mK1Tzh4ixVVkBzJI/EnGjyACbfCaO3eIWRAAAAAElFTkSuQmCC";
window["AscCommon"]=window["AscCommon"]||{};window["AscCommon"].g_font_loader=new CGlobalFontLoader;window["AscCommon"].g_image_loader=new CGlobalImageLoader;window["AscCommon"].g_flow_anchor=g_flow_anchor;window["AscCommon"].g_flow_anchor2=g_flow_anchor2})(window,window.document);"use strict";(function(window,undefined){var FOREIGN_CURSOR_LABEL_HIDETIME=1500;function CCollaborativeChanges(){this.m_pData=null;this.m_oColor=null}CCollaborativeChanges.prototype.Set_Data=function(pData){this.m_pData=
pData};CCollaborativeChanges.prototype.Set_Color=function(oColor){this.m_oColor=oColor};CCollaborativeChanges.prototype.Set_FromUndoRedo=function(Class,Data,Binary){if(!Class.Get_Id)return false;this.m_pData=this.private_SaveData(Binary);return true};CCollaborativeChanges.prototype.Apply_Data=function(){var CollaborativeEditing=AscCommon.CollaborativeEditing;var Reader=this.private_LoadData(this.m_pData);var ClassId=Reader.GetString2();var Class=AscCommon.g_oTableId.Get_ById(ClassId);if(!Class)return false;
var nReaderPos=Reader.GetCurPos();var nChangesType=Reader.GetLong();var fChangesClass=AscDFH.changesFactory[nChangesType];if(fChangesClass){var oChange=new fChangesClass(Class);oChange.ReadFromBinary(Reader);if(true===CollaborativeEditing.private_AddOverallChange(oChange))oChange.Load(this.m_oColor);return true}else{CollaborativeEditing.private_AddOverallChange(this.m_pData);Reader.Seek2(nReaderPos);if(!Class.Load_Changes)return false;return Class.Load_Changes(Reader,null,this.m_oColor)}};CCollaborativeChanges.prototype.private_LoadData=
@ -20067,59 +20067,59 @@ this.CheckFootnote(X,Y,CurPage);if(isInText&&null!=oHyperlink&&(Y<=this.Pages[Cu
Asc.c_oAscMouseMoveDataTypes.Common;if(isInText&&(null!=oHyperlink||bPageRefLink)&&true===AscCommon.global_keyboardEvent.CtrlKey)this.DrawingDocument.SetCursorType("pointer",MMData);else this.DrawingDocument.SetCursorType("text",MMData);var Bounds=this.Pages[CurPage].Bounds;if(true===this.Lock.Is_Locked()&&X<Bounds.Right&&X>Bounds.Left&&Y>Bounds.Top&&Y<Bounds.Bottom&&this.LogicDocument&&!this.LogicDocument.IsViewModeInReview()){var _X=this.Pages[CurPage].X;var _Y=this.Pages[CurPage].Y;var MMData=
new AscCommon.CMouseMoveData;var Coords=this.DrawingDocument.ConvertCoordsToCursorWR(_X,_Y,this.Get_AbsolutePage(CurPage),text_transform);MMData.X_abs=Coords.X-5;MMData.Y_abs=Coords.Y;MMData.Type=Asc.c_oAscMouseMoveDataTypes.LockedObject;MMData.UserId=this.Lock.Get_UserId();MMData.HaveChanges=this.Lock.Have_Changes();MMData.LockedObjectType=c_oAscMouseMoveLockedObjectType.Common;editor.sync_MouseMoveCallback(MMData)}};Paragraph.prototype.Document_CreateFontMap=function(FontMap){if(true===this.FontMap.NeedRecalc){this.FontMap.Map=
{};this.private_CompileParaPr();var FontScheme=this.Get_Theme().themeElements.fontScheme;var CurTextPr=this.CompiledPr.Pr.TextPr.Copy();CurTextPr.Document_CreateFontMap(this.FontMap.Map,FontScheme);CurTextPr.Merge(this.TextPr.Value);CurTextPr.Document_CreateFontMap(this.FontMap.Map,FontScheme);var Count=this.Content.length;for(var Index=0;Index<Count;Index++)this.Content[Index].Create_FontMap(this.FontMap.Map);this.FontMap.NeedRecalc=false}for(var Key in this.FontMap.Map)FontMap[Key]=this.FontMap.Map[Key]};
Paragraph.prototype.Document_CreateFontCharMap=function(FontCharMap){};Paragraph.prototype.Document_Get_AllFontNames=function(AllFonts){this.TextPr.Value.Document_Get_AllFontNames(AllFonts);if(this.Pr.Bullet)this.Pr.Bullet.Get_AllFontNames(AllFonts);if(this.Pr.DefaultRunPr)this.Pr.DefaultRunPr.Document_Get_AllFontNames(AllFonts);var Count=this.Content.length;for(var Index=0;Index<Count;Index++)this.Content[Index].Get_AllFontNames(AllFonts)};Paragraph.prototype.Document_UpdateRulersState=function(){if(this.CalculatedFrame){var oFrame=
this.CalculatedFrame;this.Parent.DrawingDocument.Set_RulerState_Paragraph({L:oFrame.L2,T:oFrame.T2,R:oFrame.L2+oFrame.W2,B:oFrame.T2+oFrame.H2,PageIndex:this.GetStartPageAbsolute(),Frame:this},false)}else if(this.Parent instanceof CDocument)if(this.LogicDocument)this.LogicDocument.Document_UpdateRulersStateBySection()};Paragraph.prototype.Document_UpdateInterfaceState=function(){var StartPos,EndPos;if(true===this.Selection.Use){StartPos=this.Get_ParaContentPos(true,true);EndPos=this.Get_ParaContentPos(true,
false)}else{var CurPos=this.Get_ParaContentPos(false,false);StartPos=CurPos;EndPos=CurPos}if(this.LogicDocument&&true===this.LogicDocument.Spelling.Use&&(selectionflag_Numbering!==this.Selection.Flag&&selectionflag_NumberingCur!==this.Selection.Flag))this.SpellChecker.Document_UpdateInterfaceState(StartPos,EndPos);if(true===this.Selection.Use){var StartPos=this.Selection.StartPos;var EndPos=this.Selection.EndPos;if(StartPos>EndPos){StartPos=this.Selection.EndPos;EndPos=this.Selection.StartPos}for(var CurPos=
StartPos;CurPos<=EndPos;CurPos++){var Element=this.Content[CurPos];if(true!==Element.IsSelectionEmpty()&&Element.Document_UpdateInterfaceState)Element.Document_UpdateInterfaceState()}}else{var CurType=this.Content[this.CurPos.ContentPos].Type;if(this.Content[this.CurPos.ContentPos].Document_UpdateInterfaceState)this.Content[this.CurPos.ContentPos].Document_UpdateInterfaceState()}var arrComplexFields=this.GetCurrentComplexFields();for(var nIndex=0,nCount=arrComplexFields.length;nIndex<nCount;++nIndex){var oInstruction=
arrComplexFields[nIndex].GetInstruction();if(oInstruction&&fieldtype_HYPERLINK===oInstruction.GetType()){var oHyperProps=new Asc.CHyperlinkProperty;oHyperProps.put_ToolTip(oInstruction.GetToolTip());oHyperProps.put_Value(oInstruction.GetValue());oHyperProps.put_Text(this.LogicDocument?this.LogicDocument.GetComplexFieldTextValue(arrComplexFields[nIndex]):null);oHyperProps.put_InternalHyperlink(oInstruction);editor.sync_HyperlinkPropCallback(oHyperProps)}}if(editor&&this.bFromDocument){if(!this.LogicDocument)return;
var TrackManager=this.LogicDocument.GetTrackRevisionsManager();if(this.Pages.length<=0&&this.Lines.length<=0)return;var ContentPos=this.Get_ParaContentPos(this.Selection.Use,true);var ParaPos=this.Get_ParaPosByContentPos(ContentPos);if(this.Pages.length<=ParaPos.Page||this.Lines.length<=ParaPos.Line)return;var Page_abs=this.Get_AbsolutePage(ParaPos.Page);var _Y=this.Pages[ParaPos.Page].Y+this.Lines[ParaPos.Line].Top;var TextTransform=this.Get_ParentTextTransform();var _X=this.LogicDocument?this.LogicDocument.Get_PageLimits(Page_abs).XLimit:
0;var Coords=this.DrawingDocument.ConvertCoordsToCursorWR(_X,_Y,Page_abs,TextTransform);if(false===this.Selection.Use){var Changes=TrackManager.GetElementChanges(this.GetId());if(Changes.length>0)for(var ChangeIndex=0,ChangesCount=Changes.length;ChangeIndex<ChangesCount;ChangeIndex++){var Change=Changes[ChangeIndex];var Type=Change.get_Type();if(c_oAscRevisionsChangeType.TextAdd!==Type&&c_oAscRevisionsChangeType.TextRem!==Type&&c_oAscRevisionsChangeType.TextPr!==Type||StartPos.Compare(Change.get_StartPos())>=
0&&StartPos.Compare(Change.get_EndPos())<=0){Change.put_InternalPos(_X,_Y,Page_abs);TrackManager.AddVisibleChange(Change)}}}}};Paragraph.prototype.PreDelete=function(){for(var Index=0;Index<this.Content.length;Index++){var Item=this.Content[Index];if(Item.PreDelete)Item.PreDelete();if(this.LogicDocument)if(para_Comment===Item.Type&&true===this.LogicDocument.RemoveCommentsOnPreDelete)this.LogicDocument.RemoveComment(Item.CommentId,true,false);else if(para_Bookmark===Item.Type)this.LogicDocument.GetBookmarksManager().SetNeedUpdate(true)}this.RemoveSelection();
this.UpdateDocumentOutline();if(undefined!==this.Get_SectionPr()&&this.LogicDocument)this.Set_SectionPr(undefined)};Paragraph.prototype.Document_SetThisElementCurrent=function(bUpdateStates){this.Parent.Update_ContentIndexing();this.Parent.Set_CurrentElement(this.Index,bUpdateStates)};Paragraph.prototype.Is_ThisElementCurrent=function(){var Parent=this.Parent;Parent.Update_ContentIndexing();if(docpostype_Content===Parent.GetDocPosType()&&false===Parent.Selection.Use&&this.Index===Parent.CurPos.ContentPos&&
Parent.Content[this.Index]===this)return this.Parent.Is_ThisElementCurrent();return false};Paragraph.prototype.Is_Inline=function(){if(this.bFromDocument===false)return true;var PrevElement=this.Get_DocumentPrev();if(true===this.Is_Empty()&&undefined!==this.Get_SectionPr()&&null!==PrevElement&&(type_Paragraph!==PrevElement.Get_Type()||undefined===PrevElement.Get_SectionPr()))return true;if(undefined===this.Parent||!(this.Parent instanceof CDocument)&&(undefined===this.Parent.Parent||!(this.Parent.Parent instanceof
CHeaderFooter)))return true;if(undefined!=this.Pr.FramePr&&Asc.c_oAscYAlign.Inline!==this.Pr.FramePr.YAlign)return false;return true};Paragraph.prototype.IsInline=function(){return this.Is_Inline()};Paragraph.prototype.GetFramePr=function(){return this.Get_CompiledPr2(false).ParaPr.FramePr};Paragraph.prototype.Get_FramePr=function(){return this.GetFramePr()};Paragraph.prototype.Set_FramePr=function(FramePr,bDelete){var FramePr_old=this.Pr.FramePr;if(undefined===bDelete)bDelete=false;if(true===bDelete){this.Pr.FramePr=
undefined;this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,FramePr_old,undefined));this.CompiledPr.NeedRecalc=true;this.private_UpdateTrackRevisionOnChangeParaPr(true);return}var FrameParas=this.Internal_Get_FrameParagraphs();if(true===FramePr.FromDropCapMenu&&1===FrameParas.length){var NewFramePr=FramePr_old?FramePr_old.Copy():new CFramePr;if(undefined!=FramePr.DropCap){var OldLines=NewFramePr.Lines;NewFramePr.Init_Default_DropCap(FramePr.DropCap===Asc.c_oAscDropCap.Drop?
true:false);NewFramePr.Lines=OldLines}if(undefined!=FramePr.Lines){var AnchorPara=this.Get_FrameAnchorPara();if(null===AnchorPara||AnchorPara.Lines.length<=0)return;var Before=AnchorPara.Get_CompiledPr().ParaPr.Spacing.Before;var LineH=AnchorPara.Lines[0].Bottom-AnchorPara.Lines[0].Top-Before;var LineTA=AnchorPara.Lines[0].Metrics.TextAscent2;var LineTD=AnchorPara.Lines[0].Metrics.TextDescent+AnchorPara.Lines[0].Metrics.LineGap;this.Set_Spacing({LineRule:linerule_Exact,Line:FramePr.Lines*LineH},false);
this.Update_DropCapByLines(this.Internal_CalculateTextPr(this.Internal_GetStartPos()),FramePr.Lines,LineH,LineTA,LineTD,Before);NewFramePr.Lines=FramePr.Lines}if(undefined!=FramePr.FontFamily){var FF=new ParaTextPr({RFonts:{Ascii:{Name:FramePr.FontFamily.Name,Index:-1}}});this.SelectAll();this.Add(FF);this.RemoveSelection()}if(undefined!=FramePr.HSpace)NewFramePr.HSpace=FramePr.HSpace;this.Pr.FramePr=NewFramePr}else{var NewFramePr=FramePr_old?FramePr_old.Copy():new CFramePr;if(undefined!=FramePr.H)NewFramePr.H=
FramePr.H;if(undefined!=FramePr.HAnchor)NewFramePr.HAnchor=FramePr.HAnchor;if(undefined!=FramePr.HRule)NewFramePr.HRule=FramePr.HRule;if(undefined!=FramePr.HSpace)NewFramePr.HSpace=FramePr.HSpace;if(undefined!=FramePr.Lines)NewFramePr.Lines=FramePr.Lines;if(undefined!=FramePr.VAnchor)NewFramePr.VAnchor=FramePr.VAnchor;if(undefined!=FramePr.VSpace)NewFramePr.VSpace=FramePr.VSpace;NewFramePr.W=FramePr.W;if(undefined!=FramePr.X){NewFramePr.X=FramePr.X;NewFramePr.XAlign=undefined}if(undefined!=FramePr.XAlign){NewFramePr.XAlign=
FramePr.XAlign;NewFramePr.X=undefined}if(undefined!=FramePr.Y){NewFramePr.Y=FramePr.Y;NewFramePr.YAlign=undefined}if(undefined!=FramePr.YAlign){NewFramePr.YAlign=FramePr.YAlign;NewFramePr.Y=undefined}if(undefined!==FramePr.Wrap)if(false===FramePr.Wrap)NewFramePr.Wrap=wrap_NotBeside;else if(true===FramePr.Wrap)NewFramePr.Wrap=wrap_Around;else NewFramePr.Wrap=FramePr.Wrap;this.Pr.FramePr=NewFramePr}if(undefined!=FramePr.Brd){var Count=FrameParas.length;for(var Index=0;Index<Count;Index++)FrameParas[Index].Set_Borders(FramePr.Brd)}if(undefined!=
FramePr.Shd){var Count=FrameParas.length;for(var Index=0;Index<Count;Index++)FrameParas[Index].Set_Shd(FramePr.Shd)}this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,FramePr_old,this.Pr.FramePr));this.CompiledPr.NeedRecalc=true;this.private_UpdateTrackRevisionOnChangeParaPr(true)};Paragraph.prototype.Set_FramePr2=function(FramePr){this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,this.Pr.FramePr,FramePr));this.Pr.FramePr=FramePr;this.CompiledPr.NeedRecalc=
true;this.private_UpdateTrackRevisionOnChangeParaPr(true)};Paragraph.prototype.Set_FrameParaPr=function(Para){Para.CopyPr(this);Para.Set_Ind({FirstLine:0},false);this.Set_Spacing({After:0},false);this.Set_Ind({Right:0},false);this.RemoveNumPr()};Paragraph.prototype.Get_FrameBounds=function(FrameX,FrameY,FrameW,FrameH){var X0=FrameX,Y0=FrameY,X1=FrameX+FrameW,Y1=FrameY+FrameH;var Paras=this.Internal_Get_FrameParagraphs();var Count=Paras.length;var FramePr=this.Get_FramePr();if(0>=Count)return{X:X0,
Y:Y0,W:X1-X0,H:Y1-Y0};for(var Index=0;Index<Count;Index++){var Para=Paras[Index];var ParaPr=Para.Get_CompiledPr2(false).ParaPr;var Brd=ParaPr.Brd;var _X0=FrameX;if(undefined!==Brd.Left&&border_None!==Brd.Left.Value)_X0-=Brd.Left.Size+Brd.Left.Space+1;if(_X0<X0)X0=_X0;var _X1=FrameX+FrameW;if(undefined!==Brd.Right&&border_None!==Brd.Right.Value){_X1=Math.max(_X1,_X1-ParaPr.Ind.Right);_X1+=Brd.Right.Size+Brd.Right.Space+1}if(_X1>X1)X1=_X1}var _Y1=Y1;var BottomBorder=Paras[Count-1].Get_CompiledPr2(false).ParaPr.Brd.Bottom;
if(undefined!==BottomBorder&&border_None!==BottomBorder.Value)_Y1+=BottomBorder.Size+BottomBorder.Space;if(_Y1>Y1&&(Asc.linerule_Auto===FramePr.HRule||Asc.linerule_AtLeast===FramePr.HRule&&FrameH>=FramePr.H))Y1=_Y1;return{X:X0,Y:Y0,W:X1-X0,H:Y1-Y0}};Paragraph.prototype.SetCalculatedFrame=function(oFrame){this.CalculatedFrame=oFrame;oFrame.AddParagraph(this)};Paragraph.prototype.GetCalculatedFrame=function(){return this.CalculatedFrame};Paragraph.prototype.Internal_Get_FrameParagraphs=function(){if(this.CalculatedFrame&&
this.CalculatedFrame.GetParagraphs().length>0)return this.CalculatedFrame.GetParagraphs();var FrameParas=[];var FramePr=this.Get_FramePr();if(undefined===FramePr)return FrameParas;FrameParas.push(this);var Prev=this.Get_DocumentPrev();while(null!=Prev)if(type_Paragraph===Prev.GetType()){var PrevFramePr=Prev.Get_FramePr();if(undefined!=PrevFramePr&&true===FramePr.Compare(PrevFramePr)){FrameParas.push(Prev);Prev=Prev.Get_DocumentPrev()}else break}else break;var Next=this.Get_DocumentNext();while(null!=
Next)if(type_Paragraph===Next.GetType()){var NextFramePr=Next.Get_FramePr();if(undefined!=NextFramePr&&true===FramePr.Compare(NextFramePr)){FrameParas.push(Next);Next=Next.Get_DocumentNext()}else break}else break;return FrameParas};Paragraph.prototype.Is_LineDropCap=function(){var FrameParas=this.Internal_Get_FrameParagraphs();if(1!==FrameParas.length||1!==this.Lines.length)return false;return true};Paragraph.prototype.Get_LineDropCapWidth=function(){var W=this.Lines[0].Ranges[0].W;var ParaPr=this.Get_CompiledPr2(false).ParaPr;
W+=ParaPr.Ind.Left+ParaPr.Ind.FirstLine;return W};Paragraph.prototype.Change_Frame=function(X,Y,W,H,PageIndex){if(!this.LogicDocument||!this.CalculatedFrame||!this.CalculatedFrame.GetFramePr())return;var FramePr=this.CalculatedFrame.GetFramePr();if(Math.abs(Y-this.CalculatedFrame.T2)<.001&&Math.abs(X-this.CalculatedFrame.L2)<.001&&Math.abs(W-this.CalculatedFrame.W2)<.001&&Math.abs(H-this.CalculatedFrame.H2)<.001&&PageIndex===this.CalculatedFrame.PageIndex)return;var FrameParas=this.Internal_Get_FrameParagraphs();
if(false===this.LogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_None,{Type:AscCommon.changestype_2_ElementsArray_and_Type,Elements:FrameParas,CheckType:AscCommon.changestype_Paragraph_Content})){this.LogicDocument.StartAction(AscDFH.historydescription_Document_ParagraphChangeFrame);var NewFramePr=FramePr.Copy();if(Math.abs(X-this.CalculatedFrame.L2)>.001){NewFramePr.X=X+(this.CalculatedFrame.L-this.CalculatedFrame.L2);NewFramePr.XAlign=undefined;NewFramePr.HAnchor=Asc.c_oAscHAnchor.Page}if(Math.abs(Y-
this.CalculatedFrame.T2)>.001){NewFramePr.Y=Y+(this.CalculatedFrame.T-this.CalculatedFrame.T2);NewFramePr.YAlign=undefined;NewFramePr.VAnchor=Asc.c_oAscVAnchor.Page}if(Math.abs(W-this.CalculatedFrame.W2)>.001)NewFramePr.W=W-Math.abs(this.CalculatedFrame.W2-this.CalculatedFrame.W);if(Math.abs(H-this.CalculatedFrame.H2)>.001)if(undefined!=FramePr.DropCap&&Asc.c_oAscDropCap.None!=FramePr.DropCap&&1===FrameParas.length){var PageH=this.LogicDocument.Get_PageLimits(PageIndex).YLimit;var _H=Math.min(H,PageH);
NewFramePr.Lines=this.Update_DropCapByHeight(_H);NewFramePr.HRule=linerule_Exact;NewFramePr.H=H-Math.abs(this.CalculatedFrame.H2-this.CalculatedFrame.H)}else{if(H<=this.CalculatedFrame.H2)NewFramePr.HRule=linerule_Exact;else NewFramePr.HRule=Asc.linerule_AtLeast;NewFramePr.H=H}var Count=FrameParas.length;for(var Index=0;Index<Count;Index++){var Para=FrameParas[Index];Para.Set_FramePr(NewFramePr,false)}this.LogicDocument.Recalculate();this.LogicDocument.UpdateInterface();this.LogicDocument.UpdateRulers();
this.LogicDocument.UpdateTracks();this.LogicDocument.FinalizeAction()}};Paragraph.prototype.Supplement_FramePr=function(FramePr){if(undefined!=FramePr.DropCap&&Asc.c_oAscDropCap.None!=FramePr.DropCap){var _FramePr=this.Get_FramePr();var FirstFramePara=this;var Prev=FirstFramePara.Get_DocumentPrev();while(null!=Prev)if(type_Paragraph===Prev.GetType()){var PrevFramePr=Prev.Get_FramePr();if(undefined!=PrevFramePr&&true===_FramePr.Compare(PrevFramePr)){FirstFramePara=Prev;Prev=Prev.Get_DocumentPrev()}else break}else break;
var TextPr=FirstFramePara.GetFirstRunPr();if(undefined===TextPr.RFonts||undefined===TextPr.RFonts.Ascii)TextPr=this.Get_CompiledPr2(false).TextPr;FramePr.FontFamily={Name:TextPr.RFonts.Ascii.Name,Index:TextPr.RFonts.Ascii.Index}}var FrameParas=this.Internal_Get_FrameParagraphs();var Count=FrameParas.length;var ParaPr=FrameParas[0].Get_CompiledPr2(false).ParaPr.Copy();for(var Index=1;Index<Count;Index++){var TempPr=FrameParas[Index].Get_CompiledPr2(false).ParaPr;ParaPr=ParaPr.Compare(TempPr)}FramePr.Brd=
ParaPr.Brd;FramePr.Shd=ParaPr.Shd};Paragraph.prototype.CanAddDropCap=function(){for(var nPos=0,nCount=this.Content.length;nPos<nCount;++nPos){var bResult=this.Content[nPos].CanAddDropCap();if(null!==bResult)return bResult}return false};Paragraph.prototype.Get_TextForDropCap=function(DropCapText,UseContentPos,ContentPos,Depth){var EndPos=true===UseContentPos?ContentPos.Get(Depth):this.Content.length-1;for(var Pos=0;Pos<=EndPos;Pos++){this.Content[Pos].Get_TextForDropCap(DropCapText,true===UseContentPos&&
Pos===EndPos?true:false,ContentPos,Depth+1);if(true===DropCapText.Mixed&&(true===DropCapText.Check||DropCapText.Runs.length>0))return}};Paragraph.prototype.Split_DropCap=function(NewParagraph){var DropCapText=new CParagraphGetDropCapText;if(true==this.Selection.Use&&this.Parent.IsSelectedSingleElement()){var SelSP=this.Get_ParaContentPos(true,true);var SelEP=this.Get_ParaContentPos(true,false);if(0<=SelSP.Compare(SelEP))SelEP=SelSP;DropCapText.Check=true;this.Get_TextForDropCap(DropCapText,true,SelEP,
0);DropCapText.Check=false;this.Get_TextForDropCap(DropCapText,true,SelEP,0)}else{DropCapText.Mixed=true;DropCapText.Check=false;this.Get_TextForDropCap(DropCapText,false)}var Count=DropCapText.Text.length;var PrevRun=null;var CurrRun=null;for(var Pos=0,ParaPos=0,RunPos=0;Pos<Count;Pos++){if(PrevRun!==DropCapText.Runs[Pos]){PrevRun=DropCapText.Runs[Pos];CurrRun=new ParaRun(NewParagraph);CurrRun.Set_Pr(DropCapText.Runs[Pos].Pr.Copy());NewParagraph.Internal_Content_Add(ParaPos++,CurrRun,false);RunPos=
0}CurrRun.Add_ToContent(RunPos++,DropCapText.Text[Pos],false)}if(Count>0)return DropCapText.Runs[Count-1].Get_CompiledPr(true);return null};Paragraph.prototype.SelectFirstLetter=function(){var oStartPos=new CParagraphContentPos;var oEndPos=new CParagraphContentPos;for(var nPos=0,nCount=this.Content.length;nPos<nCount;++nPos){oStartPos.Update(nPos,0);oEndPos.Update(nPos,0);if(this.Content[nPos].GetFirstRunElementPos(para_Text,oStartPos,oEndPos,1)){this.StartSelectionFromCurPos();this.SetSelectionContentPos(oStartPos,
oEndPos,false);this.Document_SetThisElementCurrent();return true}}return false};Paragraph.prototype.CheckSelectionForDropCap=function(){var oSelectionStart=this.Get_ParaContentPos(true,true);var oSelectionEnd=this.Get_ParaContentPos(true,false);if(0<=oSelectionStart.Compare(oSelectionEnd))oSelectionEnd=oSelectionStart;var nEndPos=oSelectionEnd.Get(0);for(var nPos=0;nPos<=nEndPos;++nPos)if(!this.Content[nPos].CheckSelectionForDropCap(nPos===nEndPos,oSelectionEnd,1))return false;return true};Paragraph.prototype.Update_DropCapByLines=
function(TextPr,Count,LineH,LineTA,LineTD,Before){if(null===TextPr)return;this.Set_Spacing({Before:Before,After:0,LineRule:linerule_Exact,Line:Count*LineH-.001},false);var FontSize=72;TextPr.FontSize=FontSize;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TMetrics);var TDescent=TMetrics.Descent;var TAscent=TMetrics.Ascent;var THeight=0;if(null===TAscent||null===TDescent)THeight=
g_oTextMeasurer.GetHeight();else THeight=-TDescent+TAscent;var EmHeight=THeight;var NewEmHeight=(Count-1)*LineH+LineTA;var Koef=NewEmHeight/EmHeight;var NewFontSize=TextPr.FontSize*Koef;TextPr.FontSize=parseInt(NewFontSize*2)/2;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TNewMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TNewMetrics);var TNewDescent=TNewMetrics.Descent;var TNewAscent=TNewMetrics.Ascent;var TNewHeight=
0;if(null===TNewAscent||null===TNewDescent)TNewHeight=g_oTextMeasurer.GetHeight();else TNewHeight=-TNewDescent+TNewAscent;var Descent=g_oTextMeasurer.GetDescender();var Ascent=g_oTextMeasurer.GetAscender();var Dy=Descent*(LineH*Count)/(Ascent-Descent)+TNewHeight-TNewAscent+LineTD;var PTextPr=new ParaTextPr({RFonts:{Ascii:{Name:TextPr.RFonts.Ascii.Name,Index:-1}},FontSize:TextPr.FontSize,Position:Dy});this.SelectAll();this.Add(PTextPr);this.RemoveSelection()};Paragraph.prototype.Update_DropCapByHeight=
function(_Height){var AnchorPara=this.Get_FrameAnchorPara();if(null===AnchorPara||AnchorPara.Lines.length<=0)return 1;var Before=AnchorPara.Get_CompiledPr().ParaPr.Spacing.Before;var LineH=AnchorPara.Lines[0].Bottom-AnchorPara.Lines[0].Top-Before;var LineTA=AnchorPara.Lines[0].Metrics.TextAscent2;var LineTD=AnchorPara.Lines[0].Metrics.TextDescent+AnchorPara.Lines[0].Metrics.LineGap;var Height=_Height-Before;this.Set_Spacing({LineRule:linerule_Exact,Line:Height},false);var LinesCount=Math.ceil(Height/
LineH);var TextPr=this.Internal_CalculateTextPr(this.Internal_GetStartPos());g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TMetrics);var TDescent=TMetrics.Descent;var TAscent=TMetrics.Ascent;var THeight=0;if(null===TAscent||null===TDescent)THeight=g_oTextMeasurer.GetHeight();else THeight=-TDescent+TAscent;var Koef=(Height-LineTD)/THeight;var NewFontSize=TextPr.FontSize*Koef;
TextPr.FontSize=parseInt(NewFontSize*2)/2;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TNewMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TNewMetrics);var TNewDescent=TNewMetrics.Descent;var TNewAscent=TNewMetrics.Ascent;var TNewHeight=0;if(null===TNewAscent||null===TNewDescent)TNewHeight=g_oTextMeasurer.GetHeight();else TNewHeight=-TNewDescent+TNewAscent;var Descent=g_oTextMeasurer.GetDescender();var Ascent=g_oTextMeasurer.GetAscender();
var Dy=Descent*Height/(Ascent-Descent)+TNewHeight-TNewAscent+LineTD;var PTextPr=new ParaTextPr({RFonts:{Ascii:{Name:TextPr.RFonts.Ascii.Name,Index:-1}},FontSize:TextPr.FontSize,Position:Dy});this.SelectAll();this.Add(PTextPr);this.RemoveSelection();return LinesCount};Paragraph.prototype.Get_FrameAnchorPara=function(){var FramePr=this.Get_FramePr();if(undefined===FramePr)return null;var Next=this.Get_DocumentNext();while(null!=Next){if(type_Paragraph===Next.GetType()){var NextFramePr=Next.Get_FramePr();
if(undefined===NextFramePr||false===FramePr.Compare(NextFramePr))return Next}Next=Next.Get_DocumentNext()}return Next};Paragraph.prototype.Split=function(NewParagraph){if(!NewParagraph)NewParagraph=new Paragraph(this.DrawingDocument,this.Parent);NewParagraph.DeleteCommentOnRemove=false;this.DeleteCommentOnRemove=false;this.RemoveSelection();NewParagraph.RemoveSelection();var ContentPos=this.Get_ParaContentPos(false,false);var CurPos=ContentPos.Get(0);var TextPr=this.Get_TextPr(ContentPos);var oLogicDocument=
this.GetLogicDocument();var oStyles=oLogicDocument&&oLogicDocument.GetStyles?oLogicDocument.GetStyles():null;if(oStyles&&(TextPr.RStyle===oStyles.GetDefaultEndnoteReference()||TextPr.RStyle===oStyles.GetDefaultFootnoteReference())){TextPr=TextPr.Copy();TextPr.RStyle=undefined}var NewElement=this.Content[CurPos].Split(ContentPos,1);if(null===NewElement){NewElement=new ParaRun(NewParagraph);NewElement.Set_Pr(TextPr.Copy())}var NewContent=this.Content.slice(CurPos+1);this.Internal_Content_Remove2(CurPos+
1,this.Content.length-CurPos-1);var EndRun=new ParaRun(this);EndRun.Add_ToContent(0,new ParaEnd);this.Internal_Content_Add(this.Content.length,EndRun);NewParagraph.Internal_Content_Remove2(0,NewParagraph.Content.length);NewParagraph.Internal_Content_Concat(NewContent);NewParagraph.Internal_Content_Add(0,NewElement);NewParagraph.Correct_Content();this.CopyPr(NewParagraph);this.TextPr.Clear_Style();this.TextPr.Apply_TextPr(TextPr);var SectPr=this.Get_SectionPr();if(undefined!==SectPr){this.Set_SectionPr(undefined);
NewParagraph.Set_SectionPr(SectPr)}this.MoveCursorToEndPos(false,false);NewParagraph.MoveCursorToStartPos(false);NewParagraph.DeleteCommentOnRemove=true;this.DeleteCommentOnRemove=true;return NewParagraph};Paragraph.prototype.Concat=function(Para,isUseConcatedStyle){this.DeleteCommentOnRemove=false;Para.DeleteCommentOnRemove=false;this.Remove_ParaEnd();var NearPosCount=Para.NearPosArray.length;for(var Pos=0;Pos<NearPosCount;Pos++){var ParaNearPos=Para.NearPosArray[Pos];ParaNearPos.Classes[0]=this;
ParaNearPos.NearPos.Paragraph=this;ParaNearPos.NearPos.ContentPos.Data[0]+=this.Content.length;this.NearPosArray.push(ParaNearPos)}this.Internal_Content_Concat(Para.Content);Para.ClearContent();this.Set_SectionPr(undefined);var SectPr=Para.Get_SectionPr();if(undefined!==SectPr){Para.Set_SectionPr(undefined);this.Set_SectionPr(SectPr)}this.DeleteCommentOnRemove=true;Para.DeleteCommentOnRemove=true;if(true===isUseConcatedStyle)Para.CopyPr(this)};Paragraph.prototype.ConcatBefore=function(oPara){this.DeleteCommentOnRemove=
false;oPara.DeleteCommentOnRemove=false;oPara.Remove_ParaEnd();for(var nPos=0,nCount=this.NearPosArray.length;nPos<nCount;++nPos){var oParaNearPos=this.NearPosArray[nPos];oParaNearPos.NearPos.ContentPos.Data[0]+=oPara.Content.length}for(var nPos=0,nCount=oPara.NearPosArray.length;nPos<nCount;++nPos){var oParaNearPos=oPara.NearPosArray[nPos];oParaNearPos.Classes[0]=this;oParaNearPos.NearPos.Paragraph=this;this.NearPosArray.push(oParaNearPos)}for(var nPos=0,nCount=oPara.Content.length;nPos<nCount;++nPos)this.AddToContent(nPos,
oPara.Content[nPos]);oPara.ClearContent();oPara.Set_SectionPr(undefined);this.DeleteCommentOnRemove=true;oPara.DeleteCommentOnRemove=true;oPara.CopyPr(this)};Paragraph.prototype.Continue=function(NewParagraph){var TextPr;if(this.IsEmpty())TextPr=this.TextPr.Value.Copy();else{var EndPos=this.Get_EndPos2(false);var CurPos=this.Get_ParaContentPos(false,false);this.Set_ParaContentPos(EndPos,true,-1,-1);TextPr=this.Get_TextPr(this.Get_ParaContentPos(false,false)).Copy();this.Set_ParaContentPos(CurPos,
false,-1,-1,false);TextPr.HighLight=highlight_None;var oStyles;if(this.bFromDocument&&this.LogicDocument&&(oStyles=this.LogicDocument.GetStyles())&&(TextPr.RStyle===oStyles.GetDefaultFootnoteReference()||TextPr.RStyle===oStyles.GetDefaultEndnoteReference()))TextPr.RStyle=undefined}this.CopyPr(NewParagraph);if(!this.HaveNumbering()&&!this.Lock.Is_Locked()){this.TextPr.Clear_Style();this.TextPr.Apply_TextPr(TextPr)}NewParagraph.Internal_Content_Add(0,new ParaRun(NewParagraph));NewParagraph.Correct_Content();
NewParagraph.MoveCursorToStartPos(false);for(var Pos=0,Count=NewParagraph.Content.length;Pos<Count;Pos++)if(para_Run===NewParagraph.Content[Pos].Type)NewParagraph.Content[Pos].Set_Pr(TextPr.Copy())};Paragraph.prototype.GetSelectionState=function(){var ParaState={};ParaState.CurPos={X:this.CurPos.X,Y:this.CurPos.Y,Line:this.CurPos.Line,ContentPos:this.Get_ParaContentPos(false,false),RealX:this.CurPos.RealX,RealY:this.CurPos.RealY,PagesPos:this.CurPos.PagesPos};ParaState.Selection={Start:this.Selection.Start,
Use:this.Selection.Use,StartPos:0,EndPos:0,Flag:this.Selection.Flag};if(true===this.Selection.Use){ParaState.Selection.StartPos=this.Get_ParaContentPos(true,true);ParaState.Selection.EndPos=this.Get_ParaContentPos(true,false)}return[ParaState]};Paragraph.prototype.SetSelectionState=function(State,StateIndex){if(State.length<=0)return;var ParaState=State[StateIndex];this.CurPos.X=ParaState.CurPos.X;this.CurPos.Y=ParaState.CurPos.Y;this.CurPos.Line=ParaState.CurPos.Line;this.CurPos.RealX=ParaState.CurPos.RealX;
this.CurPos.RealY=ParaState.CurPos.RealY;this.CurPos.PagesPos=ParaState.CurPos.PagesPos;this.Set_ParaContentPos(ParaState.CurPos.ContentPos,true,-1,-1);this.RemoveSelection();this.Selection.Start=ParaState.Selection.Start;this.Selection.Use=ParaState.Selection.Use;this.Selection.Flag=ParaState.Selection.Flag;if(true===this.Selection.Use)this.Set_SelectionContentPos(ParaState.Selection.StartPos,ParaState.Selection.EndPos)};Paragraph.prototype.Get_ParentObject_or_DocumentPos=function(){this.Parent.Update_ContentIndexing();
return this.Parent.Get_ParentObject_or_DocumentPos(this.Index)};Paragraph.prototype.Refresh_RecalcData=function(Data){var Type=Data.Type;var bNeedRecalc=false;var CurPage=0;switch(Type){case AscDFH.historyitem_Paragraph_AddItem:case AscDFH.historyitem_Paragraph_RemoveItem:{for(CurPage=this.Pages.length-1;CurPage>0;CurPage--)if(Data.Pos>this.Lines[this.Pages[CurPage].StartLine].Get_StartPos())break;this.RecalcInfo.Set_Type_0(pararecalc_0_All);bNeedRecalc=true;break}case AscDFH.historyitem_Paragraph_Numbering:case AscDFH.historyitem_Paragraph_PStyle:case AscDFH.historyitem_Paragraph_Pr:case AscDFH.historyitem_Paragraph_PresentationPr_Bullet:case AscDFH.historyitem_Paragraph_PresentationPr_Level:{this.RecalcInfo.Set_Type_0(pararecalc_0_All);
bNeedRecalc=true;this.CompiledPr.NeedRecalc=true;this.Recalc_RunsCompiledPr();break}case AscDFH.historyitem_Paragraph_Align:case AscDFH.historyitem_Paragraph_DefaultTabSize:case AscDFH.historyitem_Paragraph_Ind_First:case AscDFH.historyitem_Paragraph_Ind_Left:case AscDFH.historyitem_Paragraph_Ind_Right:case AscDFH.historyitem_Paragraph_ContextualSpacing:case AscDFH.historyitem_Paragraph_KeepLines:case AscDFH.historyitem_Paragraph_KeepNext:case AscDFH.historyitem_Paragraph_PageBreakBefore:case AscDFH.historyitem_Paragraph_Spacing_Line:case AscDFH.historyitem_Paragraph_Spacing_LineRule:case AscDFH.historyitem_Paragraph_Spacing_Before:case AscDFH.historyitem_Paragraph_Spacing_After:case AscDFH.historyitem_Paragraph_Spacing_AfterAutoSpacing:case AscDFH.historyitem_Paragraph_Spacing_BeforeAutoSpacing:case AscDFH.historyitem_Paragraph_WidowControl:case AscDFH.historyitem_Paragraph_Tabs:case AscDFH.historyitem_Paragraph_Borders_Between:case AscDFH.historyitem_Paragraph_Borders_Bottom:case AscDFH.historyitem_Paragraph_Borders_Left:case AscDFH.historyitem_Paragraph_Borders_Right:case AscDFH.historyitem_Paragraph_Borders_Top:case AscDFH.historyitem_Paragraph_FramePr:{bNeedRecalc=
Paragraph.prototype.Document_CreateFontCharMap=function(FontCharMap){};Paragraph.prototype.Document_Get_AllFontNames=function(AllFonts){this.TextPr.Value.Document_Get_AllFontNames(AllFonts);if(this.Pr.Bullet)this.Pr.Bullet.Get_AllFontNames(AllFonts);if(this.Pr.DefaultRunPr)this.Pr.DefaultRunPr.Document_Get_AllFontNames(AllFonts);var Count=this.Content.length;for(var Index=0;Index<Count;Index++)if(this.Content[Index]&&typeof this.Content[Index].Get_AllFontNames==="function")this.Content[Index].Get_AllFontNames(AllFonts)};
Paragraph.prototype.Document_UpdateRulersState=function(){if(this.CalculatedFrame){var oFrame=this.CalculatedFrame;this.Parent.DrawingDocument.Set_RulerState_Paragraph({L:oFrame.L2,T:oFrame.T2,R:oFrame.L2+oFrame.W2,B:oFrame.T2+oFrame.H2,PageIndex:this.GetStartPageAbsolute(),Frame:this},false)}else if(this.Parent instanceof CDocument)if(this.LogicDocument)this.LogicDocument.Document_UpdateRulersStateBySection()};Paragraph.prototype.Document_UpdateInterfaceState=function(){var StartPos,EndPos;if(true===
this.Selection.Use){StartPos=this.Get_ParaContentPos(true,true);EndPos=this.Get_ParaContentPos(true,false)}else{var CurPos=this.Get_ParaContentPos(false,false);StartPos=CurPos;EndPos=CurPos}if(this.LogicDocument&&true===this.LogicDocument.Spelling.Use&&(selectionflag_Numbering!==this.Selection.Flag&&selectionflag_NumberingCur!==this.Selection.Flag))this.SpellChecker.Document_UpdateInterfaceState(StartPos,EndPos);if(true===this.Selection.Use){var StartPos=this.Selection.StartPos;var EndPos=this.Selection.EndPos;
if(StartPos>EndPos){StartPos=this.Selection.EndPos;EndPos=this.Selection.StartPos}for(var CurPos=StartPos;CurPos<=EndPos;CurPos++){var Element=this.Content[CurPos];if(true!==Element.IsSelectionEmpty()&&Element.Document_UpdateInterfaceState)Element.Document_UpdateInterfaceState()}}else{var CurType=this.Content[this.CurPos.ContentPos].Type;if(this.Content[this.CurPos.ContentPos].Document_UpdateInterfaceState)this.Content[this.CurPos.ContentPos].Document_UpdateInterfaceState()}var arrComplexFields=this.GetCurrentComplexFields();
for(var nIndex=0,nCount=arrComplexFields.length;nIndex<nCount;++nIndex){var oInstruction=arrComplexFields[nIndex].GetInstruction();if(oInstruction&&fieldtype_HYPERLINK===oInstruction.GetType()){var oHyperProps=new Asc.CHyperlinkProperty;oHyperProps.put_ToolTip(oInstruction.GetToolTip());oHyperProps.put_Value(oInstruction.GetValue());oHyperProps.put_Text(this.LogicDocument?this.LogicDocument.GetComplexFieldTextValue(arrComplexFields[nIndex]):null);oHyperProps.put_InternalHyperlink(oInstruction);editor.sync_HyperlinkPropCallback(oHyperProps)}}if(editor&&
this.bFromDocument){if(!this.LogicDocument)return;var TrackManager=this.LogicDocument.GetTrackRevisionsManager();if(this.Pages.length<=0&&this.Lines.length<=0)return;var ContentPos=this.Get_ParaContentPos(this.Selection.Use,true);var ParaPos=this.Get_ParaPosByContentPos(ContentPos);if(this.Pages.length<=ParaPos.Page||this.Lines.length<=ParaPos.Line)return;var Page_abs=this.Get_AbsolutePage(ParaPos.Page);var _Y=this.Pages[ParaPos.Page].Y+this.Lines[ParaPos.Line].Top;var TextTransform=this.Get_ParentTextTransform();
var _X=this.LogicDocument?this.LogicDocument.Get_PageLimits(Page_abs).XLimit:0;var Coords=this.DrawingDocument.ConvertCoordsToCursorWR(_X,_Y,Page_abs,TextTransform);if(false===this.Selection.Use){var Changes=TrackManager.GetElementChanges(this.GetId());if(Changes.length>0)for(var ChangeIndex=0,ChangesCount=Changes.length;ChangeIndex<ChangesCount;ChangeIndex++){var Change=Changes[ChangeIndex];var Type=Change.get_Type();if(c_oAscRevisionsChangeType.TextAdd!==Type&&c_oAscRevisionsChangeType.TextRem!==
Type&&c_oAscRevisionsChangeType.TextPr!==Type||StartPos.Compare(Change.get_StartPos())>=0&&StartPos.Compare(Change.get_EndPos())<=0){Change.put_InternalPos(_X,_Y,Page_abs);TrackManager.AddVisibleChange(Change)}}}}};Paragraph.prototype.PreDelete=function(){for(var Index=0;Index<this.Content.length;Index++){var Item=this.Content[Index];if(Item.PreDelete)Item.PreDelete();if(this.LogicDocument)if(para_Comment===Item.Type&&true===this.LogicDocument.RemoveCommentsOnPreDelete)this.LogicDocument.RemoveComment(Item.CommentId,
true,false);else if(para_Bookmark===Item.Type)this.LogicDocument.GetBookmarksManager().SetNeedUpdate(true)}this.RemoveSelection();this.UpdateDocumentOutline();if(undefined!==this.Get_SectionPr()&&this.LogicDocument)this.Set_SectionPr(undefined)};Paragraph.prototype.Document_SetThisElementCurrent=function(bUpdateStates){this.Parent.Update_ContentIndexing();this.Parent.Set_CurrentElement(this.Index,bUpdateStates)};Paragraph.prototype.Is_ThisElementCurrent=function(){var Parent=this.Parent;Parent.Update_ContentIndexing();
if(docpostype_Content===Parent.GetDocPosType()&&false===Parent.Selection.Use&&this.Index===Parent.CurPos.ContentPos&&Parent.Content[this.Index]===this)return this.Parent.Is_ThisElementCurrent();return false};Paragraph.prototype.Is_Inline=function(){if(this.bFromDocument===false)return true;var PrevElement=this.Get_DocumentPrev();if(true===this.Is_Empty()&&undefined!==this.Get_SectionPr()&&null!==PrevElement&&(type_Paragraph!==PrevElement.Get_Type()||undefined===PrevElement.Get_SectionPr()))return true;
if(undefined===this.Parent||!(this.Parent instanceof CDocument)&&(undefined===this.Parent.Parent||!(this.Parent.Parent instanceof CHeaderFooter)))return true;if(undefined!=this.Pr.FramePr&&Asc.c_oAscYAlign.Inline!==this.Pr.FramePr.YAlign)return false;return true};Paragraph.prototype.IsInline=function(){return this.Is_Inline()};Paragraph.prototype.GetFramePr=function(){return this.Get_CompiledPr2(false).ParaPr.FramePr};Paragraph.prototype.Get_FramePr=function(){return this.GetFramePr()};Paragraph.prototype.Set_FramePr=
function(FramePr,bDelete){var FramePr_old=this.Pr.FramePr;if(undefined===bDelete)bDelete=false;if(true===bDelete){this.Pr.FramePr=undefined;this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,FramePr_old,undefined));this.CompiledPr.NeedRecalc=true;this.private_UpdateTrackRevisionOnChangeParaPr(true);return}var FrameParas=this.Internal_Get_FrameParagraphs();if(true===FramePr.FromDropCapMenu&&1===FrameParas.length){var NewFramePr=FramePr_old?FramePr_old.Copy():new CFramePr;if(undefined!=
FramePr.DropCap){var OldLines=NewFramePr.Lines;NewFramePr.Init_Default_DropCap(FramePr.DropCap===Asc.c_oAscDropCap.Drop?true:false);NewFramePr.Lines=OldLines}if(undefined!=FramePr.Lines){var AnchorPara=this.Get_FrameAnchorPara();if(null===AnchorPara||AnchorPara.Lines.length<=0)return;var Before=AnchorPara.Get_CompiledPr().ParaPr.Spacing.Before;var LineH=AnchorPara.Lines[0].Bottom-AnchorPara.Lines[0].Top-Before;var LineTA=AnchorPara.Lines[0].Metrics.TextAscent2;var LineTD=AnchorPara.Lines[0].Metrics.TextDescent+
AnchorPara.Lines[0].Metrics.LineGap;this.Set_Spacing({LineRule:linerule_Exact,Line:FramePr.Lines*LineH},false);this.Update_DropCapByLines(this.Internal_CalculateTextPr(this.Internal_GetStartPos()),FramePr.Lines,LineH,LineTA,LineTD,Before);NewFramePr.Lines=FramePr.Lines}if(undefined!=FramePr.FontFamily){var FF=new ParaTextPr({RFonts:{Ascii:{Name:FramePr.FontFamily.Name,Index:-1}}});this.SelectAll();this.Add(FF);this.RemoveSelection()}if(undefined!=FramePr.HSpace)NewFramePr.HSpace=FramePr.HSpace;this.Pr.FramePr=
NewFramePr}else{var NewFramePr=FramePr_old?FramePr_old.Copy():new CFramePr;if(undefined!=FramePr.H)NewFramePr.H=FramePr.H;if(undefined!=FramePr.HAnchor)NewFramePr.HAnchor=FramePr.HAnchor;if(undefined!=FramePr.HRule)NewFramePr.HRule=FramePr.HRule;if(undefined!=FramePr.HSpace)NewFramePr.HSpace=FramePr.HSpace;if(undefined!=FramePr.Lines)NewFramePr.Lines=FramePr.Lines;if(undefined!=FramePr.VAnchor)NewFramePr.VAnchor=FramePr.VAnchor;if(undefined!=FramePr.VSpace)NewFramePr.VSpace=FramePr.VSpace;NewFramePr.W=
FramePr.W;if(undefined!=FramePr.X){NewFramePr.X=FramePr.X;NewFramePr.XAlign=undefined}if(undefined!=FramePr.XAlign){NewFramePr.XAlign=FramePr.XAlign;NewFramePr.X=undefined}if(undefined!=FramePr.Y){NewFramePr.Y=FramePr.Y;NewFramePr.YAlign=undefined}if(undefined!=FramePr.YAlign){NewFramePr.YAlign=FramePr.YAlign;NewFramePr.Y=undefined}if(undefined!==FramePr.Wrap)if(false===FramePr.Wrap)NewFramePr.Wrap=wrap_NotBeside;else if(true===FramePr.Wrap)NewFramePr.Wrap=wrap_Around;else NewFramePr.Wrap=FramePr.Wrap;
this.Pr.FramePr=NewFramePr}if(undefined!=FramePr.Brd){var Count=FrameParas.length;for(var Index=0;Index<Count;Index++)FrameParas[Index].Set_Borders(FramePr.Brd)}if(undefined!=FramePr.Shd){var Count=FrameParas.length;for(var Index=0;Index<Count;Index++)FrameParas[Index].Set_Shd(FramePr.Shd)}this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,FramePr_old,this.Pr.FramePr));this.CompiledPr.NeedRecalc=true;this.private_UpdateTrackRevisionOnChangeParaPr(true)};Paragraph.prototype.Set_FramePr2=
function(FramePr){this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,this.Pr.FramePr,FramePr));this.Pr.FramePr=FramePr;this.CompiledPr.NeedRecalc=true;this.private_UpdateTrackRevisionOnChangeParaPr(true)};Paragraph.prototype.Set_FrameParaPr=function(Para){Para.CopyPr(this);Para.Set_Ind({FirstLine:0},false);this.Set_Spacing({After:0},false);this.Set_Ind({Right:0},false);this.RemoveNumPr()};Paragraph.prototype.Get_FrameBounds=function(FrameX,FrameY,FrameW,FrameH){var X0=FrameX,
Y0=FrameY,X1=FrameX+FrameW,Y1=FrameY+FrameH;var Paras=this.Internal_Get_FrameParagraphs();var Count=Paras.length;var FramePr=this.Get_FramePr();if(0>=Count)return{X:X0,Y:Y0,W:X1-X0,H:Y1-Y0};for(var Index=0;Index<Count;Index++){var Para=Paras[Index];var ParaPr=Para.Get_CompiledPr2(false).ParaPr;var Brd=ParaPr.Brd;var _X0=FrameX;if(undefined!==Brd.Left&&border_None!==Brd.Left.Value)_X0-=Brd.Left.Size+Brd.Left.Space+1;if(_X0<X0)X0=_X0;var _X1=FrameX+FrameW;if(undefined!==Brd.Right&&border_None!==Brd.Right.Value){_X1=
Math.max(_X1,_X1-ParaPr.Ind.Right);_X1+=Brd.Right.Size+Brd.Right.Space+1}if(_X1>X1)X1=_X1}var _Y1=Y1;var BottomBorder=Paras[Count-1].Get_CompiledPr2(false).ParaPr.Brd.Bottom;if(undefined!==BottomBorder&&border_None!==BottomBorder.Value)_Y1+=BottomBorder.Size+BottomBorder.Space;if(_Y1>Y1&&(Asc.linerule_Auto===FramePr.HRule||Asc.linerule_AtLeast===FramePr.HRule&&FrameH>=FramePr.H))Y1=_Y1;return{X:X0,Y:Y0,W:X1-X0,H:Y1-Y0}};Paragraph.prototype.SetCalculatedFrame=function(oFrame){this.CalculatedFrame=
oFrame;oFrame.AddParagraph(this)};Paragraph.prototype.GetCalculatedFrame=function(){return this.CalculatedFrame};Paragraph.prototype.Internal_Get_FrameParagraphs=function(){if(this.CalculatedFrame&&this.CalculatedFrame.GetParagraphs().length>0)return this.CalculatedFrame.GetParagraphs();var FrameParas=[];var FramePr=this.Get_FramePr();if(undefined===FramePr)return FrameParas;FrameParas.push(this);var Prev=this.Get_DocumentPrev();while(null!=Prev)if(type_Paragraph===Prev.GetType()){var PrevFramePr=
Prev.Get_FramePr();if(undefined!=PrevFramePr&&true===FramePr.Compare(PrevFramePr)){FrameParas.push(Prev);Prev=Prev.Get_DocumentPrev()}else break}else break;var Next=this.Get_DocumentNext();while(null!=Next)if(type_Paragraph===Next.GetType()){var NextFramePr=Next.Get_FramePr();if(undefined!=NextFramePr&&true===FramePr.Compare(NextFramePr)){FrameParas.push(Next);Next=Next.Get_DocumentNext()}else break}else break;return FrameParas};Paragraph.prototype.Is_LineDropCap=function(){var FrameParas=this.Internal_Get_FrameParagraphs();
if(1!==FrameParas.length||1!==this.Lines.length)return false;return true};Paragraph.prototype.Get_LineDropCapWidth=function(){var W=this.Lines[0].Ranges[0].W;var ParaPr=this.Get_CompiledPr2(false).ParaPr;W+=ParaPr.Ind.Left+ParaPr.Ind.FirstLine;return W};Paragraph.prototype.Change_Frame=function(X,Y,W,H,PageIndex){if(!this.LogicDocument||!this.CalculatedFrame||!this.CalculatedFrame.GetFramePr())return;var FramePr=this.CalculatedFrame.GetFramePr();if(Math.abs(Y-this.CalculatedFrame.T2)<.001&&Math.abs(X-
this.CalculatedFrame.L2)<.001&&Math.abs(W-this.CalculatedFrame.W2)<.001&&Math.abs(H-this.CalculatedFrame.H2)<.001&&PageIndex===this.CalculatedFrame.PageIndex)return;var FrameParas=this.Internal_Get_FrameParagraphs();if(false===this.LogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_None,{Type:AscCommon.changestype_2_ElementsArray_and_Type,Elements:FrameParas,CheckType:AscCommon.changestype_Paragraph_Content})){this.LogicDocument.StartAction(AscDFH.historydescription_Document_ParagraphChangeFrame);
var NewFramePr=FramePr.Copy();if(Math.abs(X-this.CalculatedFrame.L2)>.001){NewFramePr.X=X+(this.CalculatedFrame.L-this.CalculatedFrame.L2);NewFramePr.XAlign=undefined;NewFramePr.HAnchor=Asc.c_oAscHAnchor.Page}if(Math.abs(Y-this.CalculatedFrame.T2)>.001){NewFramePr.Y=Y+(this.CalculatedFrame.T-this.CalculatedFrame.T2);NewFramePr.YAlign=undefined;NewFramePr.VAnchor=Asc.c_oAscVAnchor.Page}if(Math.abs(W-this.CalculatedFrame.W2)>.001)NewFramePr.W=W-Math.abs(this.CalculatedFrame.W2-this.CalculatedFrame.W);
if(Math.abs(H-this.CalculatedFrame.H2)>.001)if(undefined!=FramePr.DropCap&&Asc.c_oAscDropCap.None!=FramePr.DropCap&&1===FrameParas.length){var PageH=this.LogicDocument.Get_PageLimits(PageIndex).YLimit;var _H=Math.min(H,PageH);NewFramePr.Lines=this.Update_DropCapByHeight(_H);NewFramePr.HRule=linerule_Exact;NewFramePr.H=H-Math.abs(this.CalculatedFrame.H2-this.CalculatedFrame.H)}else{if(H<=this.CalculatedFrame.H2)NewFramePr.HRule=linerule_Exact;else NewFramePr.HRule=Asc.linerule_AtLeast;NewFramePr.H=
H}var Count=FrameParas.length;for(var Index=0;Index<Count;Index++){var Para=FrameParas[Index];Para.Set_FramePr(NewFramePr,false)}this.LogicDocument.Recalculate();this.LogicDocument.UpdateInterface();this.LogicDocument.UpdateRulers();this.LogicDocument.UpdateTracks();this.LogicDocument.FinalizeAction()}};Paragraph.prototype.Supplement_FramePr=function(FramePr){if(undefined!=FramePr.DropCap&&Asc.c_oAscDropCap.None!=FramePr.DropCap){var _FramePr=this.Get_FramePr();var FirstFramePara=this;var Prev=FirstFramePara.Get_DocumentPrev();
while(null!=Prev)if(type_Paragraph===Prev.GetType()){var PrevFramePr=Prev.Get_FramePr();if(undefined!=PrevFramePr&&true===_FramePr.Compare(PrevFramePr)){FirstFramePara=Prev;Prev=Prev.Get_DocumentPrev()}else break}else break;var TextPr=FirstFramePara.GetFirstRunPr();if(undefined===TextPr.RFonts||undefined===TextPr.RFonts.Ascii)TextPr=this.Get_CompiledPr2(false).TextPr;FramePr.FontFamily={Name:TextPr.RFonts.Ascii.Name,Index:TextPr.RFonts.Ascii.Index}}var FrameParas=this.Internal_Get_FrameParagraphs();
var Count=FrameParas.length;var ParaPr=FrameParas[0].Get_CompiledPr2(false).ParaPr.Copy();for(var Index=1;Index<Count;Index++){var TempPr=FrameParas[Index].Get_CompiledPr2(false).ParaPr;ParaPr=ParaPr.Compare(TempPr)}FramePr.Brd=ParaPr.Brd;FramePr.Shd=ParaPr.Shd};Paragraph.prototype.CanAddDropCap=function(){for(var nPos=0,nCount=this.Content.length;nPos<nCount;++nPos){var bResult=this.Content[nPos].CanAddDropCap();if(null!==bResult)return bResult}return false};Paragraph.prototype.Get_TextForDropCap=
function(DropCapText,UseContentPos,ContentPos,Depth){var EndPos=true===UseContentPos?ContentPos.Get(Depth):this.Content.length-1;for(var Pos=0;Pos<=EndPos;Pos++){this.Content[Pos].Get_TextForDropCap(DropCapText,true===UseContentPos&&Pos===EndPos?true:false,ContentPos,Depth+1);if(true===DropCapText.Mixed&&(true===DropCapText.Check||DropCapText.Runs.length>0))return}};Paragraph.prototype.Split_DropCap=function(NewParagraph){var DropCapText=new CParagraphGetDropCapText;if(true==this.Selection.Use&&this.Parent.IsSelectedSingleElement()){var SelSP=
this.Get_ParaContentPos(true,true);var SelEP=this.Get_ParaContentPos(true,false);if(0<=SelSP.Compare(SelEP))SelEP=SelSP;DropCapText.Check=true;this.Get_TextForDropCap(DropCapText,true,SelEP,0);DropCapText.Check=false;this.Get_TextForDropCap(DropCapText,true,SelEP,0)}else{DropCapText.Mixed=true;DropCapText.Check=false;this.Get_TextForDropCap(DropCapText,false)}var Count=DropCapText.Text.length;var PrevRun=null;var CurrRun=null;for(var Pos=0,ParaPos=0,RunPos=0;Pos<Count;Pos++){if(PrevRun!==DropCapText.Runs[Pos]){PrevRun=
DropCapText.Runs[Pos];CurrRun=new ParaRun(NewParagraph);CurrRun.Set_Pr(DropCapText.Runs[Pos].Pr.Copy());NewParagraph.Internal_Content_Add(ParaPos++,CurrRun,false);RunPos=0}CurrRun.Add_ToContent(RunPos++,DropCapText.Text[Pos],false)}if(Count>0)return DropCapText.Runs[Count-1].Get_CompiledPr(true);return null};Paragraph.prototype.SelectFirstLetter=function(){var oStartPos=new CParagraphContentPos;var oEndPos=new CParagraphContentPos;for(var nPos=0,nCount=this.Content.length;nPos<nCount;++nPos){oStartPos.Update(nPos,
0);oEndPos.Update(nPos,0);if(this.Content[nPos].GetFirstRunElementPos(para_Text,oStartPos,oEndPos,1)){this.StartSelectionFromCurPos();this.SetSelectionContentPos(oStartPos,oEndPos,false);this.Document_SetThisElementCurrent();return true}}return false};Paragraph.prototype.CheckSelectionForDropCap=function(){var oSelectionStart=this.Get_ParaContentPos(true,true);var oSelectionEnd=this.Get_ParaContentPos(true,false);if(0<=oSelectionStart.Compare(oSelectionEnd))oSelectionEnd=oSelectionStart;var nEndPos=
oSelectionEnd.Get(0);for(var nPos=0;nPos<=nEndPos;++nPos)if(!this.Content[nPos].CheckSelectionForDropCap(nPos===nEndPos,oSelectionEnd,1))return false;return true};Paragraph.prototype.Update_DropCapByLines=function(TextPr,Count,LineH,LineTA,LineTD,Before){if(null===TextPr)return;this.Set_Spacing({Before:Before,After:0,LineRule:linerule_Exact,Line:Count*LineH-.001},false);var FontSize=72;TextPr.FontSize=FontSize;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,
1);var TMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TMetrics);var TDescent=TMetrics.Descent;var TAscent=TMetrics.Ascent;var THeight=0;if(null===TAscent||null===TDescent)THeight=g_oTextMeasurer.GetHeight();else THeight=-TDescent+TAscent;var EmHeight=THeight;var NewEmHeight=(Count-1)*LineH+LineTA;var Koef=NewEmHeight/EmHeight;var NewFontSize=TextPr.FontSize*Koef;TextPr.FontSize=parseInt(NewFontSize*2)/2;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,
1);var TNewMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TNewMetrics);var TNewDescent=TNewMetrics.Descent;var TNewAscent=TNewMetrics.Ascent;var TNewHeight=0;if(null===TNewAscent||null===TNewDescent)TNewHeight=g_oTextMeasurer.GetHeight();else TNewHeight=-TNewDescent+TNewAscent;var Descent=g_oTextMeasurer.GetDescender();var Ascent=g_oTextMeasurer.GetAscender();var Dy=Descent*(LineH*Count)/(Ascent-Descent)+TNewHeight-TNewAscent+LineTD;var PTextPr=new ParaTextPr({RFonts:{Ascii:{Name:TextPr.RFonts.Ascii.Name,
Index:-1}},FontSize:TextPr.FontSize,Position:Dy});this.SelectAll();this.Add(PTextPr);this.RemoveSelection()};Paragraph.prototype.Update_DropCapByHeight=function(_Height){var AnchorPara=this.Get_FrameAnchorPara();if(null===AnchorPara||AnchorPara.Lines.length<=0)return 1;var Before=AnchorPara.Get_CompiledPr().ParaPr.Spacing.Before;var LineH=AnchorPara.Lines[0].Bottom-AnchorPara.Lines[0].Top-Before;var LineTA=AnchorPara.Lines[0].Metrics.TextAscent2;var LineTD=AnchorPara.Lines[0].Metrics.TextDescent+
AnchorPara.Lines[0].Metrics.LineGap;var Height=_Height-Before;this.Set_Spacing({LineRule:linerule_Exact,Line:Height},false);var LinesCount=Math.ceil(Height/LineH);var TextPr=this.Internal_CalculateTextPr(this.Internal_GetStartPos());g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TMetrics);var TDescent=TMetrics.Descent;var TAscent=TMetrics.Ascent;var THeight=0;if(null===TAscent||
null===TDescent)THeight=g_oTextMeasurer.GetHeight();else THeight=-TDescent+TAscent;var Koef=(Height-LineTD)/THeight;var NewFontSize=TextPr.FontSize*Koef;TextPr.FontSize=parseInt(NewFontSize*2)/2;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TNewMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TNewMetrics);var TNewDescent=TNewMetrics.Descent;var TNewAscent=TNewMetrics.Ascent;var TNewHeight=0;if(null===TNewAscent||null===TNewDescent)TNewHeight=
g_oTextMeasurer.GetHeight();else TNewHeight=-TNewDescent+TNewAscent;var Descent=g_oTextMeasurer.GetDescender();var Ascent=g_oTextMeasurer.GetAscender();var Dy=Descent*Height/(Ascent-Descent)+TNewHeight-TNewAscent+LineTD;var PTextPr=new ParaTextPr({RFonts:{Ascii:{Name:TextPr.RFonts.Ascii.Name,Index:-1}},FontSize:TextPr.FontSize,Position:Dy});this.SelectAll();this.Add(PTextPr);this.RemoveSelection();return LinesCount};Paragraph.prototype.Get_FrameAnchorPara=function(){var FramePr=this.Get_FramePr();
if(undefined===FramePr)return null;var Next=this.Get_DocumentNext();while(null!=Next){if(type_Paragraph===Next.GetType()){var NextFramePr=Next.Get_FramePr();if(undefined===NextFramePr||false===FramePr.Compare(NextFramePr))return Next}Next=Next.Get_DocumentNext()}return Next};Paragraph.prototype.Split=function(NewParagraph){if(!NewParagraph)NewParagraph=new Paragraph(this.DrawingDocument,this.Parent);NewParagraph.DeleteCommentOnRemove=false;this.DeleteCommentOnRemove=false;this.RemoveSelection();NewParagraph.RemoveSelection();
var ContentPos=this.Get_ParaContentPos(false,false);var CurPos=ContentPos.Get(0);var TextPr=this.Get_TextPr(ContentPos);var oLogicDocument=this.GetLogicDocument();var oStyles=oLogicDocument&&oLogicDocument.GetStyles?oLogicDocument.GetStyles():null;if(oStyles&&(TextPr.RStyle===oStyles.GetDefaultEndnoteReference()||TextPr.RStyle===oStyles.GetDefaultFootnoteReference())){TextPr=TextPr.Copy();TextPr.RStyle=undefined}var NewElement=this.Content[CurPos].Split(ContentPos,1);if(null===NewElement){NewElement=
new ParaRun(NewParagraph);NewElement.Set_Pr(TextPr.Copy())}var NewContent=this.Content.slice(CurPos+1);this.Internal_Content_Remove2(CurPos+1,this.Content.length-CurPos-1);var EndRun=new ParaRun(this);EndRun.Add_ToContent(0,new ParaEnd);this.Internal_Content_Add(this.Content.length,EndRun);NewParagraph.Internal_Content_Remove2(0,NewParagraph.Content.length);NewParagraph.Internal_Content_Concat(NewContent);NewParagraph.Internal_Content_Add(0,NewElement);NewParagraph.Correct_Content();this.CopyPr(NewParagraph);
this.TextPr.Clear_Style();this.TextPr.Apply_TextPr(TextPr);var SectPr=this.Get_SectionPr();if(undefined!==SectPr){this.Set_SectionPr(undefined);NewParagraph.Set_SectionPr(SectPr)}this.MoveCursorToEndPos(false,false);NewParagraph.MoveCursorToStartPos(false);NewParagraph.DeleteCommentOnRemove=true;this.DeleteCommentOnRemove=true;return NewParagraph};Paragraph.prototype.Concat=function(Para,isUseConcatedStyle){this.DeleteCommentOnRemove=false;Para.DeleteCommentOnRemove=false;this.Remove_ParaEnd();var NearPosCount=
Para.NearPosArray.length;for(var Pos=0;Pos<NearPosCount;Pos++){var ParaNearPos=Para.NearPosArray[Pos];ParaNearPos.Classes[0]=this;ParaNearPos.NearPos.Paragraph=this;ParaNearPos.NearPos.ContentPos.Data[0]+=this.Content.length;this.NearPosArray.push(ParaNearPos)}this.Internal_Content_Concat(Para.Content);Para.ClearContent();this.Set_SectionPr(undefined);var SectPr=Para.Get_SectionPr();if(undefined!==SectPr){Para.Set_SectionPr(undefined);this.Set_SectionPr(SectPr)}this.DeleteCommentOnRemove=true;Para.DeleteCommentOnRemove=
true;if(true===isUseConcatedStyle)Para.CopyPr(this)};Paragraph.prototype.ConcatBefore=function(oPara){this.DeleteCommentOnRemove=false;oPara.DeleteCommentOnRemove=false;oPara.Remove_ParaEnd();for(var nPos=0,nCount=this.NearPosArray.length;nPos<nCount;++nPos){var oParaNearPos=this.NearPosArray[nPos];oParaNearPos.NearPos.ContentPos.Data[0]+=oPara.Content.length}for(var nPos=0,nCount=oPara.NearPosArray.length;nPos<nCount;++nPos){var oParaNearPos=oPara.NearPosArray[nPos];oParaNearPos.Classes[0]=this;
oParaNearPos.NearPos.Paragraph=this;this.NearPosArray.push(oParaNearPos)}for(var nPos=0,nCount=oPara.Content.length;nPos<nCount;++nPos)this.AddToContent(nPos,oPara.Content[nPos]);oPara.ClearContent();oPara.Set_SectionPr(undefined);this.DeleteCommentOnRemove=true;oPara.DeleteCommentOnRemove=true;oPara.CopyPr(this)};Paragraph.prototype.Continue=function(NewParagraph){var TextPr;if(this.IsEmpty())TextPr=this.TextPr.Value.Copy();else{var EndPos=this.Get_EndPos2(false);var CurPos=this.Get_ParaContentPos(false,
false);this.Set_ParaContentPos(EndPos,true,-1,-1);TextPr=this.Get_TextPr(this.Get_ParaContentPos(false,false)).Copy();this.Set_ParaContentPos(CurPos,false,-1,-1,false);TextPr.HighLight=highlight_None;var oStyles;if(this.bFromDocument&&this.LogicDocument&&(oStyles=this.LogicDocument.GetStyles())&&(TextPr.RStyle===oStyles.GetDefaultFootnoteReference()||TextPr.RStyle===oStyles.GetDefaultEndnoteReference()))TextPr.RStyle=undefined}this.CopyPr(NewParagraph);if(!this.HaveNumbering()&&!this.Lock.Is_Locked()){this.TextPr.Clear_Style();
this.TextPr.Apply_TextPr(TextPr)}NewParagraph.Internal_Content_Add(0,new ParaRun(NewParagraph));NewParagraph.Correct_Content();NewParagraph.MoveCursorToStartPos(false);for(var Pos=0,Count=NewParagraph.Content.length;Pos<Count;Pos++)if(para_Run===NewParagraph.Content[Pos].Type)NewParagraph.Content[Pos].Set_Pr(TextPr.Copy())};Paragraph.prototype.GetSelectionState=function(){var ParaState={};ParaState.CurPos={X:this.CurPos.X,Y:this.CurPos.Y,Line:this.CurPos.Line,ContentPos:this.Get_ParaContentPos(false,
false),RealX:this.CurPos.RealX,RealY:this.CurPos.RealY,PagesPos:this.CurPos.PagesPos};ParaState.Selection={Start:this.Selection.Start,Use:this.Selection.Use,StartPos:0,EndPos:0,Flag:this.Selection.Flag};if(true===this.Selection.Use){ParaState.Selection.StartPos=this.Get_ParaContentPos(true,true);ParaState.Selection.EndPos=this.Get_ParaContentPos(true,false)}return[ParaState]};Paragraph.prototype.SetSelectionState=function(State,StateIndex){if(State.length<=0)return;var ParaState=State[StateIndex];
this.CurPos.X=ParaState.CurPos.X;this.CurPos.Y=ParaState.CurPos.Y;this.CurPos.Line=ParaState.CurPos.Line;this.CurPos.RealX=ParaState.CurPos.RealX;this.CurPos.RealY=ParaState.CurPos.RealY;this.CurPos.PagesPos=ParaState.CurPos.PagesPos;this.Set_ParaContentPos(ParaState.CurPos.ContentPos,true,-1,-1);this.RemoveSelection();this.Selection.Start=ParaState.Selection.Start;this.Selection.Use=ParaState.Selection.Use;this.Selection.Flag=ParaState.Selection.Flag;if(true===this.Selection.Use)this.Set_SelectionContentPos(ParaState.Selection.StartPos,
ParaState.Selection.EndPos)};Paragraph.prototype.Get_ParentObject_or_DocumentPos=function(){this.Parent.Update_ContentIndexing();return this.Parent.Get_ParentObject_or_DocumentPos(this.Index)};Paragraph.prototype.Refresh_RecalcData=function(Data){var Type=Data.Type;var bNeedRecalc=false;var CurPage=0;switch(Type){case AscDFH.historyitem_Paragraph_AddItem:case AscDFH.historyitem_Paragraph_RemoveItem:{for(CurPage=this.Pages.length-1;CurPage>0;CurPage--)if(Data.Pos>this.Lines[this.Pages[CurPage].StartLine].Get_StartPos())break;
this.RecalcInfo.Set_Type_0(pararecalc_0_All);bNeedRecalc=true;break}case AscDFH.historyitem_Paragraph_Numbering:case AscDFH.historyitem_Paragraph_PStyle:case AscDFH.historyitem_Paragraph_Pr:case AscDFH.historyitem_Paragraph_PresentationPr_Bullet:case AscDFH.historyitem_Paragraph_PresentationPr_Level:{this.RecalcInfo.Set_Type_0(pararecalc_0_All);bNeedRecalc=true;this.CompiledPr.NeedRecalc=true;this.Recalc_RunsCompiledPr();break}case AscDFH.historyitem_Paragraph_Align:case AscDFH.historyitem_Paragraph_DefaultTabSize:case AscDFH.historyitem_Paragraph_Ind_First:case AscDFH.historyitem_Paragraph_Ind_Left:case AscDFH.historyitem_Paragraph_Ind_Right:case AscDFH.historyitem_Paragraph_ContextualSpacing:case AscDFH.historyitem_Paragraph_KeepLines:case AscDFH.historyitem_Paragraph_KeepNext:case AscDFH.historyitem_Paragraph_PageBreakBefore:case AscDFH.historyitem_Paragraph_Spacing_Line:case AscDFH.historyitem_Paragraph_Spacing_LineRule:case AscDFH.historyitem_Paragraph_Spacing_Before:case AscDFH.historyitem_Paragraph_Spacing_After:case AscDFH.historyitem_Paragraph_Spacing_AfterAutoSpacing:case AscDFH.historyitem_Paragraph_Spacing_BeforeAutoSpacing:case AscDFH.historyitem_Paragraph_WidowControl:case AscDFH.historyitem_Paragraph_Tabs:case AscDFH.historyitem_Paragraph_Borders_Between:case AscDFH.historyitem_Paragraph_Borders_Bottom:case AscDFH.historyitem_Paragraph_Borders_Left:case AscDFH.historyitem_Paragraph_Borders_Right:case AscDFH.historyitem_Paragraph_Borders_Top:case AscDFH.historyitem_Paragraph_FramePr:{bNeedRecalc=
true;break}case AscDFH.historyitem_Paragraph_Shd_Value:case AscDFH.historyitem_Paragraph_Shd_Color:case AscDFH.historyitem_Paragraph_Shd_Unifill:case AscDFH.historyitem_Paragraph_Shd:{if(this.Parent){var oDrawingShape=this.Parent.Is_DrawingShape(true);if(oDrawingShape&&oDrawingShape.getObjectType&&oDrawingShape.getObjectType()===AscDFH.historyitem_type_Shape)if(oDrawingShape.chekBodyPrTransform(oDrawingShape.getBodyPr())||oDrawingShape.checkContentWordArt(oDrawingShape.getDocContent()))bNeedRecalc=
true;if(this.Parent.IsTableHeader())bNeedRecalc=true}break}case AscDFH.historyitem_Paragraph_SectionPr:{if(this.Parent instanceof CDocument){this.Parent.UpdateContentIndexing();var nSectionIndex=this.Parent.GetSectionIndexByElementIndex(this.GetIndex());var oFirstElement=this.Parent.GetFirstElementInSection(nSectionIndex);if(oFirstElement)this.Parent.Refresh_RecalcData2(oFirstElement.GetIndex(),oFirstElement.private_GetRelativePageIndex(0))}break}case AscDFH.historyitem_Paragraph_PrChange:{if(Data instanceof
CChangesParagraphPrChange&&Data.IsChangedNumbering())bNeedRecalc=true;break}case AscDFH.historyitem_Paragraph_SuppressLineNumbers:{History.AddLineNumbersToRecalculateData();break}}if(true===bNeedRecalc){var Prev=this.Get_DocumentPrev();if(0===CurPage&&null!=Prev&&type_Paragraph===Prev.GetType()&&true===Prev.Get_CompiledPr2(false).ParaPr.KeepNext)Prev.Refresh_RecalcData2(Prev.Pages.length-1);return this.Refresh_RecalcData2(CurPage)}};Paragraph.prototype.Refresh_RecalcData2=function(CurPage){if(!CurPage)CurPage=

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 KiB

@ -778,94 +778,95 @@ nQuotient){sGroup+=arrChinese[nQuotient]+arrChinese[1E3];isPrevZero=false}else i
true;if(nTTRemainder<=0){sResult=sGroup+sResult;if(nRemValue<=0)break;continue}var nQuotient=nTTRemainder/1E3|0;var nRemainder=nTTRemainder-nQuotient*1E3;if(0!==nQuotient){sGroup+=arrChinese[nQuotient]+arrChinese[1E3];isPrevZero=false}else if(nTTQuotient>0){sGroup+=arrChinese[0];isPrevZero=true}if(nRemainder<=0){sResult=sGroup+sResult;if(nRemValue<=0)break;continue}nQuotient=nRemainder/100|0;nRemainder=nRemainder-nQuotient*100;if(0!==nQuotient){sGroup+=arrChinese[nQuotient]+arrChinese[100];isPrevZero=
false}else if(!isPrevZero){sGroup+=arrChinese[0];isPrevZero=true}if(nRemainder<=0){sResult=sGroup+sResult;if(nRemValue<=0)break;continue}nQuotient=nRemainder/10|0;nRemainder=nRemainder-nQuotient*10;if(0!==nQuotient){sGroup+=arrChinese[nQuotient]+arrChinese[10];isPrevZero=false}else if(!isPrevZero){sGroup+=arrChinese[0];isPrevZero=true}if(0!==nRemainder)sGroup+=arrChinese[nRemainder];sResult=sGroup+sResult;if(nRemValue<=0)break}break}}return sResult}var c_oAscSpaces=[];c_oAscSpaces[10]=1;c_oAscSpaces[32]=
1;c_oAscSpaces[8194]=1;c_oAscSpaces[8195]=1;c_oAscSpaces[8197]=1;c_oAscSpaces[12288]=1;function IsSpace(nUnicode){return!!c_oAscSpaces[nUnicode]}function private_IsAbbreviation(sWord){if(sWord.toUpperCase()===sWord){for(var nPos=0,nLen=sWord.length;nPos<nLen;++nPos){var nCharCode=sWord.charCodeAt(nPos);if(44032<=nCharCode&&nCharCode<=55203||4352<=nCharCode&&nCharCode<=4607||12592<=nCharCode&&nCharCode<=12687||43360<=nCharCode&&nCharCode<=43391||55216<=nCharCode&&nCharCode<=55295||19968<=nCharCode&&
nCharCode<=40959||13312<=nCharCode&&nCharCode<=19903||131072<=nCharCode&&nCharCode<=173791||173824<=nCharCode&&nCharCode<=177983||177984<=nCharCode&&nCharCode<=178207||178208<=nCharCode&&nCharCode<=183983||63744<=nCharCode&&nCharCode<=64255||194560<=nCharCode&&nCharCode<=195103)return false}return true}return false}var g_oUserColorById={},g_oUserNextColorIndex=0;function getUserColorById(userId,userName,isDark,isNumericValue){if((!userId||""===userId)&&(!userName||""===userName))return new CColor(0,
0,0,255);var res;if(g_oUserColorById.hasOwnProperty(userId))res=g_oUserColorById[userId];else if(g_oUserColorById.hasOwnProperty(userName))res=g_oUserColorById[userName];else{var nColor=Asc.c_oAscArrUserColors[g_oUserNextColorIndex%Asc.c_oAscArrUserColors.length];++g_oUserNextColorIndex;res=g_oUserColorById[userId||userName]=new CUserCacheColor(nColor)}if(!res)return new CColor(0,0,0,255);var oColor=true===isDark?res.Dark:res.Light;return true===isNumericValue?oColor.r<<16&16711680|oColor.g<<8&65280|
oColor.b&255:oColor}function isNullOrEmptyString(str){return str==undefined||str==null||str==""}function unleakString(s){return(" "+s).substr(1)}function readValAttr(attr){if(attr()){var val=attr()["val"];return val?val:null}return null}function getNumFromXml(val){return val?val-0:null}function getColorFromXml(attr){if(attr()){var vals=attr();if(null!=vals["theme"])return AscCommonExcel.g_oColorManager.getThemeColor(getNumFromXml(vals["theme"]),getNumFromXml(vals["tint"]));else if(null!=vals["rgb"])return new AscCommonExcel.RgbColor(16777215&
getNumFromXml(vals["rgb"]))}return null}function getBoolFromXml(val){return"0"!==val&&"false"!==val&&"off"!==val}function CUserCacheColor(nColor){this.Light=null;this.Dark=null;this.init(nColor)}CUserCacheColor.prototype.init=function(nColor){var r=nColor>>16&255;var g=nColor>>8&255;var b=nColor&255;var Y=Math.max(0,Math.min(255,.299*r+.587*g+.114*b));var Cb=Math.max(0,Math.min(255,128-.168736*r-.331264*g+.5*b));var Cr=Math.max(0,Math.min(255,128+.5*r-.418688*g-.081312*b));if(Y>63)Y=63;var R=Math.max(0,
Math.min(255,Y+1.402*(Cr-128)))|0;var G=Math.max(0,Math.min(255,Y-.34414*(Cb-128)-.71414*(Cr-128)))|0;var B=Math.max(0,Math.min(255,Y+1.772*(Cb-128)))|0;this.Light=new CColor(r,g,b,255);this.Dark=new CColor(R,G,B,255)};function loadScript(url,onSuccess,onError){if(window["NATIVE_EDITOR_ENJINE"]===true||window["Native"]!==undefined){onSuccess();return}if(window["AscDesktopEditor"]&&window["local_load_add"]){var _context={"completeLoad":function(){return onSuccess()}};window["local_load_add"](_context,
"sdk-all-from-min",url);var _ret_param=window["AscDesktopEditor"]["LoadJS"](url);if(2!=_ret_param)window["local_load_remove"](url);if(_ret_param==1){setTimeout(onSuccess,1);return}else if(_ret_param==2)return}var backoff=new AscCommon.Backoff(AscCommon.g_oBackoffDefaults);loadScriptWithBackoff(backoff,url,onSuccess,onError)}function loadScriptWithBackoff(backoff,url,onSuccess,onError){var script=document.createElement("script");script.type="text/javascript";script.src=url;script.onload=onSuccess;
script.onerror=function(){backoff.attempt(onError,function(){loadScriptWithBackoff(backoff,url,onSuccess,onError)})};document.head.appendChild(script)}function loadSdk(sdkName,onSuccess,onError){if(window["AscNotLoadAllScript"])onSuccess();else{var urlArgs=window.parent&&window.parent.APP&&window.parent.APP.urlArgs||"";loadScript("./../../../../sdkjs/"+sdkName+"/sdk-all.js?"+urlArgs,onSuccess,onError)}}function getAltGr(e){var ctrlKey=e.metaKey||e.ctrlKey;var altKey=e.altKey;return altKey&&(AscBrowser.isMacOs?
!ctrlKey:ctrlKey)}function getColorSchemeByName(sName){for(var i=0;i<AscCommon.g_oUserColorScheme.length;++i){var tmp=AscCommon.g_oUserColorScheme[i];if(tmp&&tmp.name===sName)return getColorSchemeByIdx(i)}return null}function getColorSchemeByIdx(idx){var tmp=AscCommon.g_oUserColorScheme[idx];if(tmp){var scheme=new AscFormat.ClrScheme,_c;scheme.name=tmp.name;_c=tmp.get_dk1();scheme.colors[8]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_lt1();scheme.colors[12]=AscFormat.CreateUniColorRGB(_c.r,
_c.g,_c.b);_c=tmp.get_dk2();scheme.colors[9]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_lt2();scheme.colors[13]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent1();scheme.colors[0]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent2();scheme.colors[1]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent3();scheme.colors[2]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent4();scheme.colors[3]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent5();
scheme.colors[4]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent6();scheme.colors[5]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_hlink();scheme.colors[11]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_folHlink();scheme.colors[10]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);return scheme}return null}function getAscColorScheme(_scheme,theme){var elem,_c;var _rgba={R:0,G:0,B:0,A:255};elem=new AscCommon.CAscColorScheme;elem.scheme=_scheme;elem.name=_scheme.name;_scheme.colors[8].Calculate(theme,
null,null,null,_rgba);_c=_scheme.colors[8].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[12].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[12].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[9].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[9].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[13].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[13].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));
_scheme.colors[0].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[0].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[1].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[1].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[2].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[2].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[3].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[3].RGBA;elem.putColor(new AscCommon.CColor(_c.R,
_c.G,_c.B));_scheme.colors[4].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[4].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[5].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[5].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[11].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[11].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[10].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[10].RGBA;elem.putColor(new AscCommon.CColor(_c.R,
_c.G,_c.B));return elem}function getIndexColorSchemeInArray(result,asc_color_scheme){for(var j=0;j<result.length;++j)if(result[j].isEqual(asc_color_scheme))return j;return-1}function checkAddColorScheme(result,asc_color_scheme,nStartIndex){var nIndex=getIndexColorSchemeInArray(result,asc_color_scheme);if(nIndex>-1)return nIndex;var nStartIndex_=nStartIndex;if(nStartIndex===null)nStartIndex_=result.length;result.splice(nStartIndex_,0,asc_color_scheme);return nStartIndex_}function isEastAsianScript(value){return 12544<=
value&&value<=12591||12704<=value&&value<=12735||19968<=value&&value<=40938||13312<=value&&value<=19893||131072<=value&&value<=173782||173824<=value&&value<=177972||177984<=value&&value<=178205||178208<=value&&value<=183969||183984<=value&&value<=191456||63744<=value&&value<=64255||194560<=value&&value<=195103||12032<=value&&value<=12255||11904<=value&&value<=12031||12736<=value&&value<=12783||12272<=value&&value<=12287||4352<=value&&value<=4607||43360<=value&&value<=43391||55216<=value&&value<=55295||
12592<=value&&value<=12687||65280<=value&&value<=65519||44032<=value&&value<=55215||12352<=value&&value<=12447||110848<=value&&value<=110895||110592<=value&&value<=110847||12688<=value&&value<=12703||12448<=value&&value<=12543||12784<=value&&value<=12799||42192<=value&&value<=42239||93952<=value&&value<=94111||110960<=value&&value<=111359||94208<=value&&value<=100332||100352<=value&&value<=101119||40960<=value&&value<=42127||42128<=value&&value<=42191}var g_oIdCounter=new CIdCounter;window.Asc.g_signature_drawer=
null;function CSignatureDrawer(id,api,w,h){window.Asc.g_signature_drawer=this;this.Api=api;this.CanvasParent=document.getElementById(id);this.Canvas=document.createElement("canvas");this.Canvas.style.position="absolute";this.Canvas.style.left="0px";this.Canvas.style.top="0px";var _width=parseInt(this.CanvasParent.offsetWidth);var _height=parseInt(this.CanvasParent.offsetHeight);if(0==_width)_width=300;if(0==_height)_height=80;this.Canvas.width=_width;this.Canvas.height=_height;this.CanvasParent.appendChild(this.Canvas);
this.Image="";this.ImageHtml=null;this.Text="";this.Font="Arial";this.Size=10;this.Italic=true;this.Bold=false;this.Width=w;this.Height=h;this.CanvasReturn=null;this.IsAsync=false}CSignatureDrawer.prototype.getCanvas=function(){return this.CanvasReturn==null?this.Canvas:this.CanvasReturn};CSignatureDrawer.prototype.getImages=function(){if(!this.isValid())return["",""];this.CanvasReturn=document.createElement("canvas");this.CanvasReturn.width=this.Width*AscCommon.g_dKoef_mm_to_pix;this.CanvasReturn.height=
this.Height*AscCommon.g_dKoef_mm_to_pix;if(this.Text!="")this.drawText();else this.drawImage();var _ret=[];_ret.push(this.CanvasReturn.toDataURL("image/png"));var _ctx=this.CanvasReturn.getContext("2d");_ctx.strokeStyle="#FF0000";_ctx.lineWidth=2;_ctx.moveTo(0,0);_ctx.lineTo(this.CanvasReturn.width,this.CanvasReturn.height);_ctx.moveTo(0,this.CanvasReturn.height);_ctx.lineTo(this.CanvasReturn.width,0);_ctx.stroke();_ret.push(this.CanvasReturn.toDataURL("image/png"));this.CanvasReturn=null;return _ret};
CSignatureDrawer.prototype.setText=function(text,font,size,isItalic,isBold){if(this.IsAsync){this.Text=text;return}this.Image="";this.ImageHtml=null;this.Text=text;this.Font=font;this.Size=size;this.Italic=isItalic;this.Bold=isBold;this.IsAsync=true;AscFonts.FontPickerByCharacter.checkText(this.Text,this,function(){this.IsAsync=false;var loader=AscCommon.g_font_loader;var fontinfo=AscFonts.g_fontApplication.GetFontInfo(font);var isasync=loader.LoadFont(fontinfo,function(){window.Asc.g_signature_drawer.Api.sync_EndAction(Asc.c_oAscAsyncActionType.Information,
Asc.c_oAscAsyncAction.LoadFont);window.Asc.g_signature_drawer.drawText()});if(false===isasync)this.drawText()})};CSignatureDrawer.prototype.drawText=function(){var _oldTurn=this.Api.isViewMode;var _oldMarks=this.Api.ShowParaMarks;this.Api.isViewMode=true;this.Api.ShowParaMarks=false;AscFormat.ExecuteNoHistory(AscCommon.DrawTextByCenter,this,[]);this.Api.isViewMode=_oldTurn;this.Api.ShowParaMarks=_oldMarks};CSignatureDrawer.prototype.drawImage=function(){var _canvas=this.getCanvas();var w=_canvas.width;
var h=_canvas.height;var _ctx=_canvas.getContext("2d");_ctx.clearRect(0,0,w,h);var im_w=this.ImageHtml.width;var im_h=this.ImageHtml.height;var _x=0;var _y=0;var _w=0;var _h=0;var koef1=w/h;var koef2=im_w/im_h;if(koef1>koef2){_h=h;_w=koef2*_h>>0;_y=0;_x=w-_w>>1}else{_w=w;_h=_w/koef2>>0;_x=0;_y=h-_h>>1}_ctx.drawImage(this.ImageHtml,_x,_y,_w,_h)};CSignatureDrawer.prototype.selectImage=CSignatureDrawer.prototype["selectImage"]=function(){this.Text="";window["AscDesktopEditor"]["OpenFilenameDialog"]("images",
false,function(_file){var file=_file;if(Array.isArray(file))file=file[0];if(!file)return;var _drawer=window.Asc.g_signature_drawer;_drawer.Image=window["AscDesktopEditor"]["GetImageBase64"](file);_drawer.ImageHtml=new Image;_drawer.ImageHtml.onload=function(){window.Asc.g_signature_drawer.drawImage()};_drawer.ImageHtml.src=_drawer.Image;_drawer=null})};CSignatureDrawer.prototype.isValid=function(){return this.Image!=""||this.Text!=""};CSignatureDrawer.prototype.destroy=function(){window.Asc.g_signature_drawer.CanvasParent.removeChild(this.Canvas);
delete window.Asc.g_signature_drawer};function CSignatureImage(){this.ImageValidBase64="";this.ImageInvalidBase64="";this.ImageValid=null;this.ImageInvalid=null;this.Valid=false;this.Loading=0;this.Remove=function(){this.ImageValidBase64="";this.ImageInvalidBase64="";this.ImageValid=null;this.ImageInvalid=null;this.Valid=false;this.Loading=0};this.Register=function(_api,_guid){if(_api.ImageLoader.map_image_index[_guid])return;var _obj={Image:this.Valid?this.ImageValid:this.ImageInvalid,Status:AscFonts.ImageLoadStatus.Complete,
src:_guid};_api.ImageLoader.map_image_index[_guid]=_obj};this.Unregister=function(_api,_guid){if(_api.ImageLoader.map_image_index[_guid])delete _api.ImageLoader.map_image_index[_guid]}}function CShortcuts(){this.List={};this.CustomCounter=0;this.CustomActions={}}CShortcuts.prototype.Add=function(nType,nCode,isCtrl,isShift,isAlt){this.List[this.private_GetIndex(nCode,isCtrl,isShift,isAlt)]=nType};CShortcuts.prototype.Get=function(nCode,isCtrl,isShift,isAlt){var nType=this.List[this.private_GetIndex(nCode,
isCtrl,isShift,isAlt)];return undefined!==nType?nType:0};CShortcuts.prototype.private_GetIndex=function(nCode,isCtrl,isShift,isAlt){return nCode<<8|(isCtrl?4:0)|(isShift?2:0)|(isAlt?1:0)};CShortcuts.prototype.CheckType=function(nType){for(var nIndex in this.List)if(this.List[nIndex]===nType)return{KeyCode:nIndex>>>8,CtrlKey:!!(nIndex&4),ShiftKey:!!(nIndex&2),AltKey:!!(nIndex&1)};return null};CShortcuts.prototype.Remove=function(nCode,isCtrl,isShift,isAlt){delete this.List[this.private_GetIndex(nCode,
isCtrl,isShift,isAlt)]};CShortcuts.prototype.RemoveByType=function(nType){for(var nIndex in this.List)if(this.List[nIndex]===nType)delete this.List[nIndex]};CShortcuts.prototype.GetNewCustomType=function(){return 16711680|this.CustomCounter++};CShortcuts.prototype.IsCustomType=function(nType){return nType>=16711680};CShortcuts.prototype.GetCustomAction=function(nType){return this.CustomActions[nType]};CShortcuts.prototype.AddCustomActionSymbol=function(nCharCode,sFont){var nType=this.GetNewCustomType();
this.CustomActions[nType]=new CCustomShortcutActionSymbol(nCharCode,sFont);return nType};function CCustomShortcutActionSymbol(nCharCode,sFont){this.CharCode=nCharCode;this.Font=sFont}CCustomShortcutActionSymbol.prototype.Type=AscCommon.c_oAscCustomShortcutType.Symbol;AscCommon.EncryptionMessageType={Encrypt:0,Decrypt:1};function CEncryptionData(){this._init=false;this.arrData=[];this.arrImages=[];this.handleChangesCallback=null;this.isChangesHandled=false;this.cryptoMode=0;this.isChartEditor=false;
this.isExistDecryptedChanges=false;this.cryptoPrefix=window["AscDesktopEditor"]&&window["AscDesktopEditor"]["GetEncryptedHeader"]?window["AscDesktopEditor"]["GetEncryptedHeader"]():"ENCRYPTED;";this.cryptoPrefixLen=this.cryptoPrefix.length;this.editorId=null;this.nextChangesTimeoutId=-1;this.isPasswordCryptoPresent=false;this.init=function(){this._init=true};this.isInit=function(){return this._init};this.isNeedCrypt=function(){if(window.g_asc_plugins)if(!window.g_asc_plugins.isRunnedEncryption())return false;
if(!window["AscDesktopEditor"])return false;if(this.isChartEditor)return false;if(2==this.cryptoMode)return true;if(0===window["AscDesktopEditor"]["CryptoMode"])return false;return true};this.isCryptoImages=function(){return this.isNeedCrypt()&&this.isPasswordCryptoPresent};this.addCryproImagesFromDialog=function(callback){var _this=this;window["AscDesktopEditor"]["OpenFilenameDialog"]("images",true,function(files){if(!files)return;if(!Array.isArray(files))files=[files];if(0===files.length)return;
var _files=[];var _options={isImageCrypt:true,callback:callback,ext:[]};for(var i=0;i<files.length;i++){_files.push(window["AscDesktopEditor"]["GetImageBase64"](files[i],true));_options.ext.push(AscCommon.GetFileExtension(files[i]))}_this.sendChanges(this,_files,AscCommon.EncryptionMessageType.Encrypt,_options)})};this.addCryproImagesFromUrls=function(urls,callback){var _editor=window["Asc"]["editor"]?window["Asc"]["editor"]:window.editor;_editor.sync_StartAction(Asc.c_oAscAsyncActionType.BlockInteraction,
Asc.c_oAscAsyncAction.LoadImage);var _this=this;window["AscDesktopEditor"]["DownloadFiles"](urls,[],function(files){_editor.sync_EndAction(Asc.c_oAscAsyncActionType.BlockInteraction,Asc.c_oAscAsyncAction.LoadImage);_editor.sync_StartAction(Asc.c_oAscAsyncActionType.BlockInteraction,Asc.c_oAscAsyncAction.UploadImage);var _files=[];var _options={isImageCrypt:true,isUrls:true,callback:callback,ext:[],api:_editor};for(var elem in files){_files.push(window["AscDesktopEditor"]["GetImageBase64"](files[elem],
true));_options.ext.push(window["AscDesktopEditor"]["GetImageFormat"](files[elem]));window["AscDesktopEditor"]["RemoveFile"](files[elem])}_this.sendChanges(this,_files,AscCommon.EncryptionMessageType.Encrypt,_options)})};this.onDecodeError=function(){var _editor=window["Asc"]["editor"]?window["Asc"]["editor"]:window.editor;_editor.sendEvent("asc_onError",Asc.c_oAscError.ID.DataEncrypted,Asc.c_oAscError.Level.Critical)};this.checkEditorId=function(){if(null==this.editorId){var _editor=window["Asc"]["editor"]?
window["Asc"]["editor"]:window.editor;this.editorId=_editor.editorId}};this.decryptImage=function(src,img,data){this.sendChanges(this,[data],AscCommon.EncryptionMessageType.Decrypt,{isImageDecrypt:true,src:src,img:img})};this.nextChanges=function(){this.nextChangesTimeoutId=setTimeout(function(){AscCommon.EncryptionWorker.sendChanges(undefined,undefined);this.nextChangesTimeoutId=-1},10)};this.sendChanges=function(sender,data,type,options){if(!this.isNeedCrypt()){if(AscCommon.EncryptionMessageType.Encrypt==
type)sender._send(data,true);else if(AscCommon.EncryptionMessageType.Decrypt==type){if(this.isExistEncryptedChanges(data["changes"])){this.onDecodeError();return}sender._onSaveChanges(data,true)}return}if(undefined!==type)this.arrData.push({sender:sender,type:type,data:data,options:options});if(this.arrData.length==0)return;if(undefined!==type&&(1!=this.arrData.length||!this.isChangesHandled))return;if(undefined!==type&&-1!=this.nextChangesTimeoutId){clearTimeout(this.nextChangesTimeoutId);this.nextChangesTimeoutId=
-1}if(AscCommon.EncryptionMessageType.Encrypt==this.arrData[0].type)if(this.arrData[0].options&&this.arrData[0].options.isImageCrypt)window.g_asc_plugins.sendToEncryption({"type":"encryptData","data":this.arrData[0].data});else window.g_asc_plugins.sendToEncryption({"type":"encryptData","data":JSON.parse(this.arrData[0].data["changes"])});else if(AscCommon.EncryptionMessageType.Decrypt==this.arrData[0].type)if(this.arrData[0].options&&this.arrData[0].options.isImageDecrypt)window.g_asc_plugins.sendToEncryption({"type":"decryptData",
"data":this.arrData[0].data});else window.g_asc_plugins.sendToEncryption({"type":"decryptData","data":this.arrData[0].data["changes"]})};this.receiveChanges=function(obj){var data=obj["data"];var check=obj["check"];if(!check){this.onDecodeError();return}if(this.handleChangesCallback){this.isExistDecryptedChanges=true;this.checkEditorId();if(this.editorId==AscCommon.c_oEditorId.Spreadsheet)for(var i=data.length-1;i>=0;i--)this.handleChangesCallback.changesBase[i]=data[i];else for(var i=data.length-
1;i>=0;i--)this.handleChangesCallback.changesBase[i].m_pData=data[i];this.isChangesHandled=true;this.handleChangesCallback.callback.call(this.handleChangesCallback.sender);this.handleChangesCallback=null;this.nextChanges();return}var obj=this.arrData[0];this.arrData.splice(0,1);if(AscCommon.EncryptionMessageType.Encrypt==obj.type)if(obj.options&&obj.options.isImageCrypt){for(var i=0;i<data.length;i++)if(this.cryptoPrefix==data[i].substr(0,this.cryptoPrefixLen))data[i]=this.cryptoPrefix+obj.options.ext[i]+
";"+data[i].substr(this.cryptoPrefixLen);if(!obj.options.isUrls)obj.options.callback(Asc.c_oAscError.ID.No,data);else AscCommon.UploadImageUrls(data,obj.options.api.documentId,obj.options.api.documentUserId,obj.options.api.CoAuthoringApi.get_jwt(),function(urls){obj.options.api.sync_EndAction(Asc.c_oAscAsyncActionType.BlockInteraction,Asc.c_oAscAsyncAction.UploadImage);obj.options.callback(urls)})}else{obj.data["changes"]=JSON.stringify(data);obj.sender._send(obj.data,true)}else if(AscCommon.EncryptionMessageType.Decrypt==
obj.type)if(obj.options&&obj.options.isImageDecrypt){window["AscDesktopEditor"]["ResaveFile"](obj.options.src,data[0]);obj.options.img["onload_crypto"](obj.options.src)}else{this.isExistDecryptedChanges=true;obj.data["changes"]=data;obj.sender._onSaveChanges(obj.data,true)}this.nextChanges()};this.isExistEncryptedChanges=function(_array){if(0==_array.length)return false;this.checkEditorId();var isChangesMode=_array[0]["change"]?true:false;var _prefix="";var _checkPrefixLen=this.cryptoPrefixLen+1;
if(isChangesMode){for(var i=_array.length-1;i>=0;i--)if(_array[i]["change"].length>_checkPrefixLen){_prefix=_array[i]["change"].substr(0,_checkPrefixLen);if(-1!=_prefix.indexOf(this.cryptoPrefix)){isCrypted=true;break}}return isCrypted}var isCrypted=false;if(this.editorId==AscCommon.c_oEditorId.Spreadsheet)for(var i=_array.length-1;i>=0;i--){if(_array[i].length>_checkPrefixLen){_prefix=_array[i].substr(0,_checkPrefixLen);if(-1!=_prefix.indexOf(this.cryptoPrefix)){isCrypted=true;break}}}else for(var i=
_array.length-1;i>=0;i--)if(_array[i].m_pData.length>_checkPrefixLen){_prefix=_array[i].m_pData.substr(0,_checkPrefixLen);if(-1!=_prefix.indexOf(this.cryptoPrefix)){isCrypted=true;break}}return isCrypted};this.handleChanges=function(_array,_sender,_callback){if(0==_array.length||!this.isNeedCrypt()){if(this.isExistEncryptedChanges(_array)){this.onDecodeError();return}this.isChangesHandled=true;_callback.call(_sender);return}this.handleChangesCallback={changesBase:_array,changes:[],sender:_sender,
callback:_callback};this.checkEditorId();if(this.editorId==AscCommon.c_oEditorId.Spreadsheet)for(var i=_array.length-1;i>=0;i--)this.handleChangesCallback.changes[i]=_array[i];else for(var i=_array.length-1;i>=0;i--)this.handleChangesCallback.changes[i]=_array[i].m_pData;window.g_asc_plugins.sendToEncryption({"type":"decryptData","data":this.handleChangesCallback.changes})};this.asc_setAdvancedOptions=function(api,idOption,option){if(window.isNativeOpenPassword){window["AscDesktopEditor"]["NativeViewerOpen"](option.asc_getPassword());
return}if(window.isCloudCryptoDownloadAs)return false;if(!this.isNeedCrypt())return false;window.checkPasswordFromPlugin=true;if(window["Asc"].c_oAscAdvancedOptionsID.TXT===idOption){var _param="<m_nCsvTxtEncoding>"+option.asc_getCodePage()+"</m_nCsvTxtEncoding>";window["AscDesktopEditor"]["SetAdvancedOptions"](_param)}else if(window["Asc"].c_oAscAdvancedOptionsID.CSV===idOption){var delimiter=option.asc_getDelimiter();var delimiterChar=option.asc_getDelimiterChar();var _param="";_param+="<m_nCsvTxtEncoding>"+
option.asc_getCodePage()+"</m_nCsvTxtEncoding>";if(null!=delimiter)_param+="<m_nCsvDelimiter>"+delimiter+"</m_nCsvDelimiter>";if(null!=delimiterChar)_param+="<m_nCsvDelimiterChar>"+delimiterChar+"</m_nCsvDelimiterChar>";window["AscDesktopEditor"]["SetAdvancedOptions"](_param)}else if(window["Asc"].c_oAscAdvancedOptionsID.DRM===idOption){var _param="<m_sPassword>"+AscCommon.CopyPasteCorrectString(option.asc_getPassword())+"</m_sPassword>";api.currentPassword=option.asc_getPassword();window["AscDesktopEditor"]["SetAdvancedOptions"](_param)}return true}}
AscCommon.EncryptionWorker=new CEncryptionData;function CMouseSmoothWheelCorrector(t,scrollFunction){this._deltaX=0;this._deltaY=0;this._isBreakX=false;this._isBreakY=false;this._timeoutCorrector=-1;this._api=t;this._scrollFunction=scrollFunction;this._normalDelta=120;this._isNormalDeltaActive=false;this.setNormalDeltaActive=function(value){this._isNormalDeltaActive=true;this._normalDelta=value};this.isBreakX=function(){return this._isBreakX};this.isBreakY=function(){return this._isBreakY};this.get_DeltaX=
function(wheelDeltaX){this._isBreakX=false;if(!AscCommon.AscBrowser.isMacOs)return wheelDeltaX;this._deltaX+=wheelDeltaX;if(Math.abs(this._deltaX)>=this._normalDelta)return this._isNormalDeltaActive?this._deltaX>0?this._normalDelta:-this._normalDelta:this._deltaX;this._isBreakX=true;return 0};this.get_DeltaY=function(wheelDeltaY){this._isBreakY=false;if(!AscCommon.AscBrowser.isMacOs)return wheelDeltaY;this._deltaY+=wheelDeltaY;if(Math.abs(this._deltaY)>=this._normalDelta)return this._isNormalDeltaActive?
this._deltaY>0?this._normalDelta:-this._normalDelta:this._deltaY;this._isBreakY=true;return 0};this.checkBreak=function(){if(-1!=this._timeoutCorrector){clearTimeout(this._timeoutCorrector);this._timeoutCorrector=-1}if((this._isBreakX||this._isBreakY)&&this._scrollFunction){var obj={t:this,x:this._isBreakX?this._deltaX:0,y:this._isBreakY?this._deltaY:0};this._timeoutCorrector=setTimeout(function(){var t=obj.t;t._scrollFunction.call(t._api,obj.x,obj.y);t._timeoutCorrector=-1;t._deltaX=0;t._deltaY=
0},100)}if(!this._isBreakX)this._deltaX=0;if(!this._isBreakY)this._deltaY=0;this._isBreakX=false;this._isBreakY=false}}AscCommon.CMouseSmoothWheelCorrector=CMouseSmoothWheelCorrector;function CTranslateManager(){this.mapTranslate={}}CTranslateManager.prototype.init=function(map){this.mapTranslate=map||{}};CTranslateManager.prototype.getValue=function(key){return this.mapTranslate.hasOwnProperty(key)?this.mapTranslate[key]:key};function CPolygonPoint2(X,Y){this.X=X;this.Y=Y}function CPolygonVectors(){this.Page=
-1;this.VX=[];this.VY=[]}function CPolygonPath(precision){this.Page=-1;this.Direction=1;this.precision=precision;this.Points=[]}CPolygonPath.prototype.PushPoint=function(x,y){this.Points.push(new CPolygonPoint2(x/this.precision,y/this.precision))};CPolygonPath.prototype.CorrectExtremePoints=function(){var Lng=this.Points.length;this.Points[0].X=this.Points[Lng-1].X;this.Points[Lng-1].Y=this.Points[0].Y};function CPolygon(){this.Vectors=[];this.precision=1E3}CPolygon.prototype.fill=function(arrBounds){this.Vectors.length=
0;if(arrBounds.length<=0)return;var nStartLineIndex=0,nStartIndex=0,CountLines=arrBounds.length,CountBounds;while(nStartLineIndex<arrBounds.length){CountBounds=arrBounds[nStartLineIndex].length;while(nStartIndex<CountBounds)if(arrBounds[nStartLineIndex][nStartIndex].W<.001)nStartIndex++;else break;if(nStartIndex<CountBounds)break;nStartLineIndex++;nStartIndex=0}if(nStartLineIndex>=arrBounds.length)return;var CurrentPage=arrBounds[nStartLineIndex][nStartIndex].Page,CurrentVectors=new CPolygonVectors,
VectorsX=CurrentVectors.VX,VectorsY=CurrentVectors.VY;CurrentVectors.Page=CurrentPage;this.Vectors.push(CurrentVectors);for(var LineIndex=nStartLineIndex;LineIndex<CountLines;nStartIndex=0,LineIndex++){if(arrBounds[LineIndex][nStartIndex].Page!==CurrentPage){CurrentPage=arrBounds[LineIndex][nStartIndex].Page;CurrentVectors=new CPolygonVectors;VectorsX=CurrentVectors.VX;VectorsY=CurrentVectors.VY;CurrentVectors.Page=CurrentPage;this.Vectors.push(CurrentVectors)}for(var Index=nStartIndex;Index<arrBounds[LineIndex].length;Index++){var oBound=
arrBounds[LineIndex][Index];if(oBound.W<.001)continue;var x1=Math.round(oBound.X*this.precision),x2=Math.round((oBound.X+oBound.W)*this.precision),y1=Math.round(oBound.Y*this.precision),y2=Math.round((oBound.Y+oBound.H)*this.precision);if(VectorsX[y1]==undefined)VectorsX[y1]={};this.IntersectionX(VectorsX,x2,x1,y1);if(VectorsY[x1]==undefined)VectorsY[x1]={};this.IntersectionY(VectorsY,y1,y2,x1);if(VectorsX[y2]==undefined)VectorsX[y2]={};this.IntersectionX(VectorsX,x1,x2,y2);if(VectorsY[x2]==undefined)VectorsY[x2]=
{};this.IntersectionY(VectorsY,y2,y1,x2)}}};CPolygon.prototype.IntersectionX=function(VectorsX,BeginX,EndX,Y){var CurrentVector={};CurrentVector[BeginX]=EndX;var VX=VectorsX[Y];if(BeginX>EndX)while(true==this.IntersectVectorX(CurrentVector,VX));else while(true==this.IntersectVectorX(VX,CurrentVector));for(var X in CurrentVector){var VBeginX=parseInt(X);var VEndX=CurrentVector[VBeginX];if(VBeginX!==VEndX||VX[VBeginX]===undefined)VX[VBeginX]=VEndX}};CPolygon.prototype.IntersectVectorX=function(VectorOpp,
VectorClW){for(var X in VectorOpp){var VBeginX=parseInt(X);var VEndX=VectorOpp[VBeginX];if(VEndX==VBeginX)continue;for(var ClwX in VectorClW){var ClwBeginX=parseInt(ClwX);var ClwEndX=VectorClW[ClwBeginX];var bIntersection=false;if(ClwBeginX==ClwEndX)continue;if(ClwBeginX<=VEndX&&VBeginX<=ClwEndX){VectorOpp[VBeginX]=VBeginX;VectorClW[ClwBeginX]=VEndX;VectorClW[VBeginX]=ClwEndX;bIntersection=true}else if(VEndX<=ClwBeginX&&ClwEndX<=VBeginX){VectorClW[ClwBeginX]=ClwBeginX;VectorOpp[VBeginX]=ClwEndX;VectorOpp[ClwBeginX]=
VEndX;bIntersection=true}else if(ClwBeginX<VEndX&&VEndX<ClwEndX){VectorClW[ClwBeginX]=VEndX;VectorOpp[VBeginX]=ClwEndX;bIntersection=true}else if(ClwBeginX<VBeginX&&VBeginX<ClwEndX){VectorOpp[ClwBeginX]=VEndX;VectorClW[VBeginX]=ClwEndX;delete VectorOpp[VBeginX];delete VectorClW[ClwBeginX];bIntersection=true}if(bIntersection==true)return true}}return false};CPolygon.prototype.IntersectionY=function(VectorsY,BeginY,EndY,X){var bIntersect=false;for(var y in VectorsY[X]){var CurBeginY=parseInt(y);var CurEndY=
VectorsY[X][CurBeginY];var minY,maxY;if(CurBeginY<CurEndY){minY=CurBeginY;maxY=CurEndY}else{minY=CurEndY;maxY=CurBeginY}var bInterSection=!(maxY<=BeginY&&maxY<=EndY||minY>=BeginY&&minY>=EndY),bDirection=(CurBeginY-CurEndY)*(BeginY-EndY)<0;if(bInterSection&&bDirection){VectorsY[X][CurBeginY]=EndY;VectorsY[X][BeginY]=CurEndY;bIntersect=true}}if(bIntersect==false)VectorsY[X][BeginY]=EndY};CPolygon.prototype.GetPaths=function(shift){var Paths=[];shift*=this.precision;for(var PageIndex=0;PageIndex<this.Vectors.length;PageIndex++){var y,
x1,x2,x,y1,y2;var VectorsX=this.Vectors[PageIndex].VX,VectorsY=this.Vectors[PageIndex].VY,Page=this.Vectors[PageIndex].Page;for(var LineIndex in VectorsX)for(var Index in VectorsX[LineIndex]){var Polygon=new CPolygonPath(this.precision);Polygon.Page=Page;y=parseInt(LineIndex);x1=parseInt(Index);x2=VectorsX[y][x1];VectorsX[y][x1]=-1;var Direction=x1>x2?1:-1;var minY=y;var SignRightLeft,SignDownUp;var X,Y;if(x2!==-1){SignRightLeft=x1>x2?1:-1;Y=y-SignRightLeft*shift;Polygon.PushPoint(x1,Y);while(true){x=
x2;y1=y;y2=VectorsY[x][y1];if(y2==-1)break;else if(y2==undefined)return[];VectorsY[x][y1]=-1;SignDownUp=y1>y2?1:-1;X=x+SignDownUp*shift;Polygon.PushPoint(X,Y);y=y2;x1=x;x2=VectorsX[y][x1];if(x2==-1)break;else if(x2==undefined)return[];VectorsX[y][x1]=-1;SignRightLeft=x1>x2?1:-1;Y=y-SignRightLeft*shift;Polygon.PushPoint(X,Y);if(y<minY){minY=y;Direction=x1>x2?1:-1}}Polygon.PushPoint(X,Y);Polygon.CorrectExtremePoints();Polygon.Direction=Direction;Paths.push(Polygon)}}}return Paths};function CMathTrack(){this.MathRect=
{IsActive:false,Bounds:[],ContentSelection:null};this.MathPolygons=[];this.MathSelectPolygons=[]}CMathTrack.prototype.Update=function(IsActive,IsContentActive,oMath,PixelError){this.MathRect.IsActive=IsActive;if(true===IsActive&&null!==oMath){var selectBounds=true===IsContentActive?oMath.Get_ContentSelection():null;if(selectBounds!=null){var SelectPolygon=new CPolygon;SelectPolygon.fill(selectBounds);this.MathSelectPolygons=SelectPolygon.GetPaths(0)}else this.MathSelectPolygons.length=0;var arrBounds=
oMath.Get_Bounds();if(arrBounds.length<=0)return;var MPolygon=new CPolygon;MPolygon.fill(arrBounds);this.MathPolygons=MPolygon.GetPaths(PixelError)}};CMathTrack.prototype.Draw=function(overlay,oPath,shift,color,dKoefX,dKoefY,left,top){var ctx=overlay.m_oContext;ctx.strokeStyle=color;ctx.lineWidth=1;ctx.beginPath();var Points=oPath.Points;var nCount=Points.length;var PrevX=Points[nCount-2].X,PrevY=Points[nCount-2].Y;var _x=left+dKoefX*Points[nCount-2].X,_y=top+dKoefY*Points[nCount-2].Y;var StartX,
StartY;for(var nIndex=0;nIndex<nCount;nIndex++){if(PrevX>Points[nIndex].X)_y=top+dKoefY*Points[nIndex].Y-shift;else if(PrevX<Points[nIndex].X)_y=top+dKoefY*Points[nIndex].Y+shift;if(PrevY<Points[nIndex].Y)_x=left+dKoefX*Points[nIndex].X-shift;else if(PrevY>Points[nIndex].Y)_x=left+dKoefX*Points[nIndex].X+shift;PrevX=Points[nIndex].X;PrevY=Points[nIndex].Y;if(nIndex>0){overlay.CheckPoint(_x,_y);if(1==nIndex){StartX=_x;StartY=_y;overlay.m_oContext.moveTo((_x>>0)+.5,(_y>>0)+.5)}else overlay.m_oContext.lineTo((_x>>
0)+.5,(_y>>0)+.5)}}overlay.m_oContext.lineTo((StartX>>0)+.5,(StartY>>0)+.5);ctx.closePath();ctx.stroke();ctx.beginPath()};CMathTrack.prototype.DrawWithMatrix=function(overlay,oPath,ShiftX,ShiftY,color,dKoefX,dKoefY,left,top,m){var ctx=overlay.m_oContext;ctx.strokeStyle=color;ctx.lineWidth=1;ctx.beginPath();var Points=oPath.Points;var nCount=Points.length;var x=Points[nCount-2].X,y=Points[nCount-2].Y;var _x,_y;var PrevX=Points[nCount-2].X,PrevY=Points[nCount-2].Y;var StartX,StartY;for(var nIndex=0;nIndex<
nCount;nIndex++){if(PrevX>Points[nIndex].X)y=Points[nIndex].Y-ShiftY;else if(PrevX<Points[nIndex].X)y=Points[nIndex].Y+ShiftY;if(PrevY<Points[nIndex].Y)x=Points[nIndex].X-ShiftX;else if(PrevY>Points[nIndex].Y)x=Points[nIndex].X+ShiftX;PrevX=Points[nIndex].X;PrevY=Points[nIndex].Y;if(nIndex>0){_x=left+dKoefX*m.TransformPointX(x,y);_y=top+dKoefY*m.TransformPointY(x,y);overlay.CheckPoint(_x,_y);if(1==nIndex){StartX=_x;StartY=_y;overlay.m_oContext.moveTo((_x>>0)+.5,(_y>>0)+.5)}else overlay.m_oContext.lineTo((_x>>
0)+.5,(_y>>0)+.5)}}overlay.m_oContext.lineTo((StartX>>0)+.5,(StartY>>0)+.5);ctx.closePath();ctx.stroke();ctx.beginPath()};CMathTrack.prototype.DrawSelectPolygon=function(overlay,oPath,dKoefX,dKoefY,left,top,m){var ctx=overlay.m_oContext;ctx.fillStyle="#375082";ctx.beginPath();var Points=oPath.Points;var nPointIndex;var _x,_y,x,y,p;for(nPointIndex=0;nPointIndex<Points.length-1;nPointIndex++){p=Points[nPointIndex];if(!m){_x=left+dKoefX*p.X;_y=top+dKoefY*p.Y}else{x=p.X;y=p.Y;_x=left+dKoefX*m.TransformPointX(x,
y);_y=top+dKoefY*m.TransformPointY(x,y)}overlay.CheckPoint(_x,_y);if(0==nPointIndex)ctx.moveTo((_x>>0)+.5,(_y>>0)+.5);else ctx.lineTo((_x>>0)+.5,(_y>>0)+.5)}ctx.globalAlpha=.2;ctx.fill();ctx.globalAlpha=1};CMathTrack.prototype.IsActive=function(){return this.MathRect.IsActive};CMathTrack.prototype.GetPolygonsCount=function(){return this.MathPolygons.length};CMathTrack.prototype.GetPolygon=function(nIndex){return this.MathPolygons[nIndex]};CMathTrack.prototype.GetSelectPathsCount=function(){return this.MathSelectPolygons.length};
CMathTrack.prototype.GetSelectPath=function(nIndex){return this.MathSelectPolygons[nIndex]};if(!Array.prototype.findIndex)Object.defineProperty(Array.prototype,"findIndex",{value:function(predicate){if(this==null)throw new TypeError("Array.prototype.findIndex called on null or undefined");if(typeof predicate!=="function")throw new TypeError("predicate must be a function");var list=Object(this);var length=list.length>>>0;var thisArg=arguments[1];var value;for(var i=0;i<length;i++){value=list[i];if(predicate.call(thisArg,
value,i,list))return i}return-1}});if(!Array.prototype.fill)Object.defineProperty(Array.prototype,"fill",{value:function(value){if(this==null)throw new TypeError("this is null or not defined");var O=Object(this);var len=O.length>>>0;var start=arguments[1];var relativeStart=start>>0;var k=relativeStart<0?Math.max(len+relativeStart,0):Math.min(relativeStart,len);var end=arguments[2];var relativeEnd=end===undefined?len:end>>0;var final=relativeEnd<0?Math.max(len+relativeEnd,0):Math.min(relativeEnd,len);
while(k<final){O[k]=value;k++}return O}});if(typeof Int8Array!=="undefined"&&!Int8Array.prototype.fill)Int8Array.prototype.fill=Array.prototype.fill;if(typeof Uint8Array!=="undefined"&&!Uint8Array.prototype.fill)Uint8Array.prototype.fill=Array.prototype.fill;if(typeof Uint8ClampedArray!=="undefined"&&!Uint8ClampedArray.prototype.fill)Uint8ClampedArray.prototype.fill=Array.prototype.fill;if(typeof Int16Array!=="undefined"&&!Int16Array.prototype.fill)Int16Array.prototype.fill=Array.prototype.fill;if(typeof Uint16Array!==
"undefined"&&!Uint16Array.prototype.fill)Uint16Array.prototype.fill=Array.prototype.fill;if(typeof Int32Array!=="undefined"&&!Int32Array.prototype.fill)Int32Array.prototype.fill=Array.prototype.fill;if(typeof Uint32Array!=="undefined"&&!Uint32Array.prototype.fill)Uint32Array.prototype.fill=Array.prototype.fill;if(typeof Float32Array!=="undefined"&&!Float32Array.prototype.fill)Float32Array.prototype.fill=Array.prototype.fill;if(typeof Float64Array!=="undefined"&&!Float64Array.prototype.fill)Float64Array.prototype.fill=
Array.prototype.fill;if(typeof Uint8Array!=="undefined"&&!Uint8Array.prototype.slice)Uint8Array.prototype.slice=Array.prototype.slice;function parseText(text,options,bTrimSpaces){var delimiterChar;if(options.asc_getDelimiterChar())delimiterChar=options.asc_getDelimiterChar();else switch(options.asc_getDelimiter()){case AscCommon.c_oAscCsvDelimiter.None:delimiterChar=undefined;break;case AscCommon.c_oAscCsvDelimiter.Tab:delimiterChar="\t";break;case AscCommon.c_oAscCsvDelimiter.Semicolon:delimiterChar=
";";break;case AscCommon.c_oAscCsvDelimiter.Colon:delimiterChar=":";break;case AscCommon.c_oAscCsvDelimiter.Comma:delimiterChar=",";break;case AscCommon.c_oAscCsvDelimiter.Space:delimiterChar=" ";break}var matrix=[];var rows=text.split(/\r?\n/);for(var i=0;i<rows.length;++i){var row=rows[i];if(" "===delimiterChar&&bTrimSpaces){var addSpace=false;if(row[0]===delimiterChar)addSpace=true;row=addSpace?delimiterChar+row.trim():row.trim()}matrix.push(row.split(delimiterChar))}return matrix}function getTimeISO8601(dateStr){if(dateStr)if(dateStr.endsWith("Z"))return Date.parse(dateStr);
else return Date.parse(dateStr+"Z");return NaN}function valueToMmType(value){var oVal=parseFloat(value);var oType;if(!isNaN(oVal)){if(-1!==value.indexOf("%")){oType="%";oVal/=100}else if(-1!==value.indexOf("px")){oType="px";oVal*=AscCommon.g_dKoef_pix_to_mm}else if(-1!==value.indexOf("in")){oType="in";oVal*=AscCommonWord.g_dKoef_in_to_mm}else if(-1!==value.indexOf("cm")){oType="cm";oVal*=10}else if(-1!==value.indexOf("mm"))oType="mm";else if(-1!==value.indexOf("pt")){oType="pt";oVal*=AscCommonWord.g_dKoef_pt_to_mm}else if(-1!==
value.indexOf("pc")){oType="pc";oVal*=AscCommonWord.g_dKoef_pc_to_mm}else oType="none";return{val:oVal,type:oType}}return null}function valueToMm(value){var obj=valueToMmType(value);if(obj&&"%"!==obj.type&&"none"!==obj.type)return obj.val;return null}function arrayMove(array,from,to){array.splice(to,0,array.splice(from,1)[0])}function getRangeArray(start,stop){var res=new Array(stop-start);for(var i=start;i<stop;++i)res[i-start]=i;return res}var g_oBackoffDefaults={retries:2,factor:2,minTimeout:100,
maxTimeout:2E3,randomize:true};function Backoff(opts){this.attempts=0;this.opts=opts}Backoff.prototype.attempt=function(fError,fRetry){var timeout=this.nextTimeout();if(timeout>0)setTimeout(function(){fRetry()},timeout);else fError()};Backoff.prototype.nextTimeout=function(){var timeout=-1;if(this.attempts<this.opts.retries){timeout=this.createTimeout(this.attempts,this.opts);this.attempts++}return timeout};Backoff.prototype.createTimeout=function(attempt,opts){var random=opts.randomize?Math.random()+
1:1;var timeout=Math.round(random*opts.minTimeout*Math.pow(opts.factor,attempt));timeout=Math.min(timeout,opts.maxTimeout);return timeout};function backoffOnError(obj,onError,onRetry){if(!onRetry)return onError;var backoff=new Backoff(g_oBackoffDefaults);return function(){var timeout=backoff.nextTimeout();if(timeout>0)setTimeout(function(){onRetry.call(obj,obj)},timeout);else if(onError)onError.apply(obj,arguments)}}function backoffOnErrorImg(img,onRetry){if(!onRetry)onRetry=function(img){img.setAttribute("src",
img.getAttribute("src"))};img.onerror=backoffOnError(img,img.onerror,onRetry)}function isEmptyObject(obj){for(var name in obj)return false;return true}window["AscCommon"]=window["AscCommon"]||{};window["AscCommon"].getSockJs=getSockJs;window["AscCommon"].getJSZipUtils=getJSZipUtils;window["AscCommon"].getJSZip=getJSZip;window["AscCommon"].getBaseUrl=getBaseUrl;window["AscCommon"].getEncodingParams=getEncodingParams;window["AscCommon"].getEncodingByBOM=getEncodingByBOM;window["AscCommon"].saveWithParts=
saveWithParts;window["AscCommon"].loadFileContent=loadFileContent;window["AscCommon"].getImageFromChanges=getImageFromChanges;window["AscCommon"].openFileCommand=openFileCommand;window["AscCommon"].sendCommand=sendCommand;window["AscCommon"].sendSaveFile=sendSaveFile;window["AscCommon"].mapAscServerErrorToAscError=mapAscServerErrorToAscError;window["AscCommon"].joinUrls=joinUrls;window["AscCommon"].getFullImageSrc2=getFullImageSrc2;window["AscCommon"].fSortAscending=fSortAscending;window["AscCommon"].fSortDescending=
fSortDescending;window["AscCommon"].isLeadingSurrogateChar=isLeadingSurrogateChar;window["AscCommon"].decodeSurrogateChar=decodeSurrogateChar;window["AscCommon"].encodeSurrogateChar=encodeSurrogateChar;window["AscCommon"].convertUnicodeToUTF16=convertUnicodeToUTF16;window["AscCommon"].convertUTF16toUnicode=convertUTF16toUnicode;window["AscCommon"].build_local_rx=build_local_rx;window["AscCommon"].GetFileName=GetFileName;window["AscCommon"].GetFileExtension=GetFileExtension;window["AscCommon"].changeFileExtention=
changeFileExtention;window["AscCommon"].getExtentionByFormat=getExtentionByFormat;window["AscCommon"].InitOnMessage=InitOnMessage;window["AscCommon"].ShowImageFileDialog=ShowImageFileDialog;window["AscCommon"].ShowDocumentFileDialog=ShowDocumentFileDialog;window["AscCommon"].InitDragAndDrop=InitDragAndDrop;window["AscCommon"].UploadImageFiles=UploadImageFiles;window["AscCommon"].UploadImageUrls=UploadImageUrls;window["AscCommon"].CanDropFiles=CanDropFiles;window["AscCommon"].getUrlType=getUrlType;
window["AscCommon"].prepareUrl=prepareUrl;window["AscCommon"].getUserColorById=getUserColorById;window["AscCommon"].isNullOrEmptyString=isNullOrEmptyString;window["AscCommon"].unleakString=unleakString;window["AscCommon"].readValAttr=readValAttr;window["AscCommon"].getNumFromXml=getNumFromXml;window["AscCommon"].getColorFromXml=getColorFromXml;window["AscCommon"].getBoolFromXml=getBoolFromXml;window["AscCommon"].initStreamFromResponse=initStreamFromResponse;window["AscCommon"].checkStreamSignature=
checkStreamSignature;window["AscCommon"].DocumentUrls=DocumentUrls;window["AscCommon"].OpenFileResult=OpenFileResult;window["AscCommon"].CLock=CLock;window["AscCommon"].CContentChanges=CContentChanges;window["AscCommon"].CContentChangesElement=CContentChangesElement;window["AscCommon"].CorrectMMToTwips=CorrectMMToTwips;window["AscCommon"].TwipsToMM=TwipsToMM;window["AscCommon"].MMToTwips=MMToTwips;window["AscCommon"].RomanToInt=RomanToInt;window["AscCommon"].LatinNumberingToInt=LatinNumberingToInt;
window["AscCommon"].IntToNumberFormat=IntToNumberFormat;window["AscCommon"].IsSpace=IsSpace;window["AscCommon"].loadSdk=loadSdk;window["AscCommon"].loadScript=loadScript;window["AscCommon"].getAltGr=getAltGr;window["AscCommon"].getColorSchemeByName=getColorSchemeByName;window["AscCommon"].getColorSchemeByIdx=getColorSchemeByIdx;window["AscCommon"].getAscColorScheme=getAscColorScheme;window["AscCommon"].checkAddColorScheme=checkAddColorScheme;window["AscCommon"].getIndexColorSchemeInArray=getIndexColorSchemeInArray;
window["AscCommon"].isEastAsianScript=isEastAsianScript;window["AscCommon"].CMathTrack=CMathTrack;window["AscCommon"].CPolygon=CPolygon;window["AscCommon"].JSZipWrapper=JSZipWrapper;window["AscCommon"].g_oDocumentUrls=g_oDocumentUrls;window["AscCommon"].FormulaTablePartInfo=FormulaTablePartInfo;window["AscCommon"].cBoolLocal=cBoolLocal;window["AscCommon"].cErrorOrigin=cErrorOrigin;window["AscCommon"].cErrorLocal=cErrorLocal;window["AscCommon"].FormulaSeparators=FormulaSeparators;window["AscCommon"].rx_space_g=
rx_space_g;window["AscCommon"].rx_space=rx_space;window["AscCommon"].rx_defName=rx_defName;window["AscCommon"].kCurFormatPainterWord=kCurFormatPainterWord;window["AscCommon"].parserHelp=parserHelp;window["AscCommon"].g_oIdCounter=g_oIdCounter;window["AscCommon"].g_oHtmlCursor=g_oHtmlCursor;window["AscCommon"].g_oBackoffDefaults=g_oBackoffDefaults;window["AscCommon"].Backoff=Backoff;window["AscCommon"].backoffOnErrorImg=backoffOnErrorImg;window["AscCommon"].isEmptyObject=isEmptyObject;window["AscCommon"].CSignatureDrawer=
window["AscCommon"]["CSignatureDrawer"]=CSignatureDrawer;var prot=CSignatureDrawer.prototype;prot["getImages"]=prot.getImages;prot["setText"]=prot.setText;prot["selectImage"]=prot.selectImage;prot["isValid"]=prot.isValid;prot["destroy"]=prot.destroy;window["AscCommon"].translateManager=new CTranslateManager;window["AscCommon"].parseText=parseText;window["AscCommon"].getTimeISO8601=getTimeISO8601;window["AscCommon"].valueToMm=valueToMm;window["AscCommon"].valueToMmType=valueToMmType;window["AscCommon"].arrayMove=
arrayMove;window["AscCommon"].getRangeArray=getRangeArray;window["AscCommon"].CUnicodeStringEmulator=CUnicodeStringEmulator;window["AscCommon"].private_IsAbbreviation=private_IsAbbreviation;window["AscCommon"].rx_test_ws_name=rx_test_ws_name;window["AscCommon"].CShortcuts=window["AscCommon"]["CShortcuts"]=CShortcuts;prot=CShortcuts.prototype;prot["Add"]=prot.Add;prot["Get"]=prot.Get;prot["CheckType"]=prot.CheckType;prot["Remove"]=prot.Remove;prot["RemoveByType"]=prot.RemoveByType;prot["GetNewCustomType"]=
prot.GetNewCustomType;prot["IsCustomType"]=prot.IsCustomType;prot["GetCustomAction"]=prot.GetCustomAction;prot["AddCustomActionSymbol"]=prot.AddCustomActionSymbol;window["AscCommon"].CCustomShortcutActionSymbol=window["AscCommon"]["CCustomShortcutActionSymbol"]=CCustomShortcutActionSymbol})(window);
nCharCode<=40959||13312<=nCharCode&&nCharCode<=19903||131072<=nCharCode&&nCharCode<=173791||173824<=nCharCode&&nCharCode<=177983||177984<=nCharCode&&nCharCode<=178207||178208<=nCharCode&&nCharCode<=183983||63744<=nCharCode&&nCharCode<=64255||194560<=nCharCode&&nCharCode<=195103)return false}return true}return false}var g_oUserColorById={},g_oUserNextColorIndex=0;function getUserColorById(userId,userName,isDark,isNumericValue){if(window.parent.APP&&window.parent.APP.getUserColor)try{var CPColor=window.parent.APP.getUserColor(userId);
if(CPColor)return true===isNumericValue?CPColor.r<<16&16711680|CPColor.g<<8&65280|CPColor.b&255:CPColor}catch(e){}if((!userId||""===userId)&&(!userName||""===userName))return new CColor(0,0,0,255);var res;if(g_oUserColorById.hasOwnProperty(userId))res=g_oUserColorById[userId];else if(g_oUserColorById.hasOwnProperty(userName))res=g_oUserColorById[userName];else{var nColor=Asc.c_oAscArrUserColors[g_oUserNextColorIndex%Asc.c_oAscArrUserColors.length];++g_oUserNextColorIndex;res=g_oUserColorById[userId||
userName]=new CUserCacheColor(nColor)}if(!res)return new CColor(0,0,0,255);var oColor=true===isDark?res.Dark:res.Light;return true===isNumericValue?oColor.r<<16&16711680|oColor.g<<8&65280|oColor.b&255:oColor}function isNullOrEmptyString(str){return str==undefined||str==null||str==""}function unleakString(s){return(" "+s).substr(1)}function readValAttr(attr){if(attr()){var val=attr()["val"];return val?val:null}return null}function getNumFromXml(val){return val?val-0:null}function getColorFromXml(attr){if(attr()){var vals=
attr();if(null!=vals["theme"])return AscCommonExcel.g_oColorManager.getThemeColor(getNumFromXml(vals["theme"]),getNumFromXml(vals["tint"]));else if(null!=vals["rgb"])return new AscCommonExcel.RgbColor(16777215&getNumFromXml(vals["rgb"]))}return null}function getBoolFromXml(val){return"0"!==val&&"false"!==val&&"off"!==val}function CUserCacheColor(nColor){this.Light=null;this.Dark=null;this.init(nColor)}CUserCacheColor.prototype.init=function(nColor){var r=nColor>>16&255;var g=nColor>>8&255;var b=nColor&
255;var Y=Math.max(0,Math.min(255,.299*r+.587*g+.114*b));var Cb=Math.max(0,Math.min(255,128-.168736*r-.331264*g+.5*b));var Cr=Math.max(0,Math.min(255,128+.5*r-.418688*g-.081312*b));if(Y>63)Y=63;var R=Math.max(0,Math.min(255,Y+1.402*(Cr-128)))|0;var G=Math.max(0,Math.min(255,Y-.34414*(Cb-128)-.71414*(Cr-128)))|0;var B=Math.max(0,Math.min(255,Y+1.772*(Cb-128)))|0;this.Light=new CColor(r,g,b,255);this.Dark=new CColor(R,G,B,255)};function loadScript(url,onSuccess,onError){if(window["NATIVE_EDITOR_ENJINE"]===
true||window["Native"]!==undefined){onSuccess();return}if(window["AscDesktopEditor"]&&window["local_load_add"]){var _context={"completeLoad":function(){return onSuccess()}};window["local_load_add"](_context,"sdk-all-from-min",url);var _ret_param=window["AscDesktopEditor"]["LoadJS"](url);if(2!=_ret_param)window["local_load_remove"](url);if(_ret_param==1){setTimeout(onSuccess,1);return}else if(_ret_param==2)return}var backoff=new AscCommon.Backoff(AscCommon.g_oBackoffDefaults);loadScriptWithBackoff(backoff,
url,onSuccess,onError)}function loadScriptWithBackoff(backoff,url,onSuccess,onError){var script=document.createElement("script");script.type="text/javascript";script.src=url;script.onload=onSuccess;script.onerror=function(){backoff.attempt(onError,function(){loadScriptWithBackoff(backoff,url,onSuccess,onError)})};document.head.appendChild(script)}function loadSdk(sdkName,onSuccess,onError){if(window["AscNotLoadAllScript"])onSuccess();else{var urlArgs=window.parent&&window.parent.APP&&window.parent.APP.urlArgs||
"";loadScript("./../../../../sdkjs/"+sdkName+"/sdk-all.js?"+urlArgs,onSuccess,onError)}}function getAltGr(e){var ctrlKey=e.metaKey||e.ctrlKey;var altKey=e.altKey;return altKey&&(AscBrowser.isMacOs?!ctrlKey:ctrlKey)}function getColorSchemeByName(sName){for(var i=0;i<AscCommon.g_oUserColorScheme.length;++i){var tmp=AscCommon.g_oUserColorScheme[i];if(tmp&&tmp.name===sName)return getColorSchemeByIdx(i)}return null}function getColorSchemeByIdx(idx){var tmp=AscCommon.g_oUserColorScheme[idx];if(tmp){var scheme=
new AscFormat.ClrScheme,_c;scheme.name=tmp.name;_c=tmp.get_dk1();scheme.colors[8]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_lt1();scheme.colors[12]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_dk2();scheme.colors[9]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_lt2();scheme.colors[13]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent1();scheme.colors[0]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent2();scheme.colors[1]=AscFormat.CreateUniColorRGB(_c.r,
_c.g,_c.b);_c=tmp.get_accent3();scheme.colors[2]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent4();scheme.colors[3]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent5();scheme.colors[4]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent6();scheme.colors[5]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_hlink();scheme.colors[11]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_folHlink();scheme.colors[10]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);
return scheme}return null}function getAscColorScheme(_scheme,theme){var elem,_c;var _rgba={R:0,G:0,B:0,A:255};elem=new AscCommon.CAscColorScheme;elem.scheme=_scheme;elem.name=_scheme.name;_scheme.colors[8].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[8].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[12].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[12].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[9].Calculate(theme,null,null,
null,_rgba);_c=_scheme.colors[9].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[13].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[13].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[0].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[0].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[1].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[1].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[2].Calculate(theme,
null,null,null,_rgba);_c=_scheme.colors[2].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[3].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[3].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[4].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[4].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[5].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[5].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));
_scheme.colors[11].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[11].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[10].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[10].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));return elem}function getIndexColorSchemeInArray(result,asc_color_scheme){for(var j=0;j<result.length;++j)if(result[j].isEqual(asc_color_scheme))return j;return-1}function checkAddColorScheme(result,asc_color_scheme,nStartIndex){var nIndex=
getIndexColorSchemeInArray(result,asc_color_scheme);if(nIndex>-1)return nIndex;var nStartIndex_=nStartIndex;if(nStartIndex===null)nStartIndex_=result.length;result.splice(nStartIndex_,0,asc_color_scheme);return nStartIndex_}function isEastAsianScript(value){return 12544<=value&&value<=12591||12704<=value&&value<=12735||19968<=value&&value<=40938||13312<=value&&value<=19893||131072<=value&&value<=173782||173824<=value&&value<=177972||177984<=value&&value<=178205||178208<=value&&value<=183969||183984<=
value&&value<=191456||63744<=value&&value<=64255||194560<=value&&value<=195103||12032<=value&&value<=12255||11904<=value&&value<=12031||12736<=value&&value<=12783||12272<=value&&value<=12287||4352<=value&&value<=4607||43360<=value&&value<=43391||55216<=value&&value<=55295||12592<=value&&value<=12687||65280<=value&&value<=65519||44032<=value&&value<=55215||12352<=value&&value<=12447||110848<=value&&value<=110895||110592<=value&&value<=110847||12688<=value&&value<=12703||12448<=value&&value<=12543||
12784<=value&&value<=12799||42192<=value&&value<=42239||93952<=value&&value<=94111||110960<=value&&value<=111359||94208<=value&&value<=100332||100352<=value&&value<=101119||40960<=value&&value<=42127||42128<=value&&value<=42191}var g_oIdCounter=new CIdCounter;window.Asc.g_signature_drawer=null;function CSignatureDrawer(id,api,w,h){window.Asc.g_signature_drawer=this;this.Api=api;this.CanvasParent=document.getElementById(id);this.Canvas=document.createElement("canvas");this.Canvas.style.position="absolute";
this.Canvas.style.left="0px";this.Canvas.style.top="0px";var _width=parseInt(this.CanvasParent.offsetWidth);var _height=parseInt(this.CanvasParent.offsetHeight);if(0==_width)_width=300;if(0==_height)_height=80;this.Canvas.width=_width;this.Canvas.height=_height;this.CanvasParent.appendChild(this.Canvas);this.Image="";this.ImageHtml=null;this.Text="";this.Font="Arial";this.Size=10;this.Italic=true;this.Bold=false;this.Width=w;this.Height=h;this.CanvasReturn=null;this.IsAsync=false}CSignatureDrawer.prototype.getCanvas=
function(){return this.CanvasReturn==null?this.Canvas:this.CanvasReturn};CSignatureDrawer.prototype.getImages=function(){if(!this.isValid())return["",""];this.CanvasReturn=document.createElement("canvas");this.CanvasReturn.width=this.Width*AscCommon.g_dKoef_mm_to_pix;this.CanvasReturn.height=this.Height*AscCommon.g_dKoef_mm_to_pix;if(this.Text!="")this.drawText();else this.drawImage();var _ret=[];_ret.push(this.CanvasReturn.toDataURL("image/png"));var _ctx=this.CanvasReturn.getContext("2d");_ctx.strokeStyle=
"#FF0000";_ctx.lineWidth=2;_ctx.moveTo(0,0);_ctx.lineTo(this.CanvasReturn.width,this.CanvasReturn.height);_ctx.moveTo(0,this.CanvasReturn.height);_ctx.lineTo(this.CanvasReturn.width,0);_ctx.stroke();_ret.push(this.CanvasReturn.toDataURL("image/png"));this.CanvasReturn=null;return _ret};CSignatureDrawer.prototype.setText=function(text,font,size,isItalic,isBold){if(this.IsAsync){this.Text=text;return}this.Image="";this.ImageHtml=null;this.Text=text;this.Font=font;this.Size=size;this.Italic=isItalic;
this.Bold=isBold;this.IsAsync=true;AscFonts.FontPickerByCharacter.checkText(this.Text,this,function(){this.IsAsync=false;var loader=AscCommon.g_font_loader;var fontinfo=AscFonts.g_fontApplication.GetFontInfo(font);var isasync=loader.LoadFont(fontinfo,function(){window.Asc.g_signature_drawer.Api.sync_EndAction(Asc.c_oAscAsyncActionType.Information,Asc.c_oAscAsyncAction.LoadFont);window.Asc.g_signature_drawer.drawText()});if(false===isasync)this.drawText()})};CSignatureDrawer.prototype.drawText=function(){var _oldTurn=
this.Api.isViewMode;var _oldMarks=this.Api.ShowParaMarks;this.Api.isViewMode=true;this.Api.ShowParaMarks=false;AscFormat.ExecuteNoHistory(AscCommon.DrawTextByCenter,this,[]);this.Api.isViewMode=_oldTurn;this.Api.ShowParaMarks=_oldMarks};CSignatureDrawer.prototype.drawImage=function(){var _canvas=this.getCanvas();var w=_canvas.width;var h=_canvas.height;var _ctx=_canvas.getContext("2d");_ctx.clearRect(0,0,w,h);var im_w=this.ImageHtml.width;var im_h=this.ImageHtml.height;var _x=0;var _y=0;var _w=0;
var _h=0;var koef1=w/h;var koef2=im_w/im_h;if(koef1>koef2){_h=h;_w=koef2*_h>>0;_y=0;_x=w-_w>>1}else{_w=w;_h=_w/koef2>>0;_x=0;_y=h-_h>>1}_ctx.drawImage(this.ImageHtml,_x,_y,_w,_h)};CSignatureDrawer.prototype.selectImage=CSignatureDrawer.prototype["selectImage"]=function(){this.Text="";window["AscDesktopEditor"]["OpenFilenameDialog"]("images",false,function(_file){var file=_file;if(Array.isArray(file))file=file[0];if(!file)return;var _drawer=window.Asc.g_signature_drawer;_drawer.Image=window["AscDesktopEditor"]["GetImageBase64"](file);
_drawer.ImageHtml=new Image;_drawer.ImageHtml.onload=function(){window.Asc.g_signature_drawer.drawImage()};_drawer.ImageHtml.src=_drawer.Image;_drawer=null})};CSignatureDrawer.prototype.isValid=function(){return this.Image!=""||this.Text!=""};CSignatureDrawer.prototype.destroy=function(){window.Asc.g_signature_drawer.CanvasParent.removeChild(this.Canvas);delete window.Asc.g_signature_drawer};function CSignatureImage(){this.ImageValidBase64="";this.ImageInvalidBase64="";this.ImageValid=null;this.ImageInvalid=
null;this.Valid=false;this.Loading=0;this.Remove=function(){this.ImageValidBase64="";this.ImageInvalidBase64="";this.ImageValid=null;this.ImageInvalid=null;this.Valid=false;this.Loading=0};this.Register=function(_api,_guid){if(_api.ImageLoader.map_image_index[_guid])return;var _obj={Image:this.Valid?this.ImageValid:this.ImageInvalid,Status:AscFonts.ImageLoadStatus.Complete,src:_guid};_api.ImageLoader.map_image_index[_guid]=_obj};this.Unregister=function(_api,_guid){if(_api.ImageLoader.map_image_index[_guid])delete _api.ImageLoader.map_image_index[_guid]}}
function CShortcuts(){this.List={};this.CustomCounter=0;this.CustomActions={}}CShortcuts.prototype.Add=function(nType,nCode,isCtrl,isShift,isAlt){this.List[this.private_GetIndex(nCode,isCtrl,isShift,isAlt)]=nType};CShortcuts.prototype.Get=function(nCode,isCtrl,isShift,isAlt){var nType=this.List[this.private_GetIndex(nCode,isCtrl,isShift,isAlt)];return undefined!==nType?nType:0};CShortcuts.prototype.private_GetIndex=function(nCode,isCtrl,isShift,isAlt){return nCode<<8|(isCtrl?4:0)|(isShift?2:0)|(isAlt?
1:0)};CShortcuts.prototype.CheckType=function(nType){for(var nIndex in this.List)if(this.List[nIndex]===nType)return{KeyCode:nIndex>>>8,CtrlKey:!!(nIndex&4),ShiftKey:!!(nIndex&2),AltKey:!!(nIndex&1)};return null};CShortcuts.prototype.Remove=function(nCode,isCtrl,isShift,isAlt){delete this.List[this.private_GetIndex(nCode,isCtrl,isShift,isAlt)]};CShortcuts.prototype.RemoveByType=function(nType){for(var nIndex in this.List)if(this.List[nIndex]===nType)delete this.List[nIndex]};CShortcuts.prototype.GetNewCustomType=
function(){return 16711680|this.CustomCounter++};CShortcuts.prototype.IsCustomType=function(nType){return nType>=16711680};CShortcuts.prototype.GetCustomAction=function(nType){return this.CustomActions[nType]};CShortcuts.prototype.AddCustomActionSymbol=function(nCharCode,sFont){var nType=this.GetNewCustomType();this.CustomActions[nType]=new CCustomShortcutActionSymbol(nCharCode,sFont);return nType};function CCustomShortcutActionSymbol(nCharCode,sFont){this.CharCode=nCharCode;this.Font=sFont}CCustomShortcutActionSymbol.prototype.Type=
AscCommon.c_oAscCustomShortcutType.Symbol;AscCommon.EncryptionMessageType={Encrypt:0,Decrypt:1};function CEncryptionData(){this._init=false;this.arrData=[];this.arrImages=[];this.handleChangesCallback=null;this.isChangesHandled=false;this.cryptoMode=0;this.isChartEditor=false;this.isExistDecryptedChanges=false;this.cryptoPrefix=window["AscDesktopEditor"]&&window["AscDesktopEditor"]["GetEncryptedHeader"]?window["AscDesktopEditor"]["GetEncryptedHeader"]():"ENCRYPTED;";this.cryptoPrefixLen=this.cryptoPrefix.length;
this.editorId=null;this.nextChangesTimeoutId=-1;this.isPasswordCryptoPresent=false;this.init=function(){this._init=true};this.isInit=function(){return this._init};this.isNeedCrypt=function(){if(window.g_asc_plugins)if(!window.g_asc_plugins.isRunnedEncryption())return false;if(!window["AscDesktopEditor"])return false;if(this.isChartEditor)return false;if(2==this.cryptoMode)return true;if(0===window["AscDesktopEditor"]["CryptoMode"])return false;return true};this.isCryptoImages=function(){return this.isNeedCrypt()&&
this.isPasswordCryptoPresent};this.addCryproImagesFromDialog=function(callback){var _this=this;window["AscDesktopEditor"]["OpenFilenameDialog"]("images",true,function(files){if(!files)return;if(!Array.isArray(files))files=[files];if(0===files.length)return;var _files=[];var _options={isImageCrypt:true,callback:callback,ext:[]};for(var i=0;i<files.length;i++){_files.push(window["AscDesktopEditor"]["GetImageBase64"](files[i],true));_options.ext.push(AscCommon.GetFileExtension(files[i]))}_this.sendChanges(this,
_files,AscCommon.EncryptionMessageType.Encrypt,_options)})};this.addCryproImagesFromUrls=function(urls,callback){var _editor=window["Asc"]["editor"]?window["Asc"]["editor"]:window.editor;_editor.sync_StartAction(Asc.c_oAscAsyncActionType.BlockInteraction,Asc.c_oAscAsyncAction.LoadImage);var _this=this;window["AscDesktopEditor"]["DownloadFiles"](urls,[],function(files){_editor.sync_EndAction(Asc.c_oAscAsyncActionType.BlockInteraction,Asc.c_oAscAsyncAction.LoadImage);_editor.sync_StartAction(Asc.c_oAscAsyncActionType.BlockInteraction,
Asc.c_oAscAsyncAction.UploadImage);var _files=[];var _options={isImageCrypt:true,isUrls:true,callback:callback,ext:[],api:_editor};for(var elem in files){_files.push(window["AscDesktopEditor"]["GetImageBase64"](files[elem],true));_options.ext.push(window["AscDesktopEditor"]["GetImageFormat"](files[elem]));window["AscDesktopEditor"]["RemoveFile"](files[elem])}_this.sendChanges(this,_files,AscCommon.EncryptionMessageType.Encrypt,_options)})};this.onDecodeError=function(){var _editor=window["Asc"]["editor"]?
window["Asc"]["editor"]:window.editor;_editor.sendEvent("asc_onError",Asc.c_oAscError.ID.DataEncrypted,Asc.c_oAscError.Level.Critical)};this.checkEditorId=function(){if(null==this.editorId){var _editor=window["Asc"]["editor"]?window["Asc"]["editor"]:window.editor;this.editorId=_editor.editorId}};this.decryptImage=function(src,img,data){this.sendChanges(this,[data],AscCommon.EncryptionMessageType.Decrypt,{isImageDecrypt:true,src:src,img:img})};this.nextChanges=function(){this.nextChangesTimeoutId=
setTimeout(function(){AscCommon.EncryptionWorker.sendChanges(undefined,undefined);this.nextChangesTimeoutId=-1},10)};this.sendChanges=function(sender,data,type,options){if(!this.isNeedCrypt()){if(AscCommon.EncryptionMessageType.Encrypt==type)sender._send(data,true);else if(AscCommon.EncryptionMessageType.Decrypt==type){if(this.isExistEncryptedChanges(data["changes"])){this.onDecodeError();return}sender._onSaveChanges(data,true)}return}if(undefined!==type)this.arrData.push({sender:sender,type:type,
data:data,options:options});if(this.arrData.length==0)return;if(undefined!==type&&(1!=this.arrData.length||!this.isChangesHandled))return;if(undefined!==type&&-1!=this.nextChangesTimeoutId){clearTimeout(this.nextChangesTimeoutId);this.nextChangesTimeoutId=-1}if(AscCommon.EncryptionMessageType.Encrypt==this.arrData[0].type)if(this.arrData[0].options&&this.arrData[0].options.isImageCrypt)window.g_asc_plugins.sendToEncryption({"type":"encryptData","data":this.arrData[0].data});else window.g_asc_plugins.sendToEncryption({"type":"encryptData",
"data":JSON.parse(this.arrData[0].data["changes"])});else if(AscCommon.EncryptionMessageType.Decrypt==this.arrData[0].type)if(this.arrData[0].options&&this.arrData[0].options.isImageDecrypt)window.g_asc_plugins.sendToEncryption({"type":"decryptData","data":this.arrData[0].data});else window.g_asc_plugins.sendToEncryption({"type":"decryptData","data":this.arrData[0].data["changes"]})};this.receiveChanges=function(obj){var data=obj["data"];var check=obj["check"];if(!check){this.onDecodeError();return}if(this.handleChangesCallback){this.isExistDecryptedChanges=
true;this.checkEditorId();if(this.editorId==AscCommon.c_oEditorId.Spreadsheet)for(var i=data.length-1;i>=0;i--)this.handleChangesCallback.changesBase[i]=data[i];else for(var i=data.length-1;i>=0;i--)this.handleChangesCallback.changesBase[i].m_pData=data[i];this.isChangesHandled=true;this.handleChangesCallback.callback.call(this.handleChangesCallback.sender);this.handleChangesCallback=null;this.nextChanges();return}var obj=this.arrData[0];this.arrData.splice(0,1);if(AscCommon.EncryptionMessageType.Encrypt==
obj.type)if(obj.options&&obj.options.isImageCrypt){for(var i=0;i<data.length;i++)if(this.cryptoPrefix==data[i].substr(0,this.cryptoPrefixLen))data[i]=this.cryptoPrefix+obj.options.ext[i]+";"+data[i].substr(this.cryptoPrefixLen);if(!obj.options.isUrls)obj.options.callback(Asc.c_oAscError.ID.No,data);else AscCommon.UploadImageUrls(data,obj.options.api.documentId,obj.options.api.documentUserId,obj.options.api.CoAuthoringApi.get_jwt(),function(urls){obj.options.api.sync_EndAction(Asc.c_oAscAsyncActionType.BlockInteraction,
Asc.c_oAscAsyncAction.UploadImage);obj.options.callback(urls)})}else{obj.data["changes"]=JSON.stringify(data);obj.sender._send(obj.data,true)}else if(AscCommon.EncryptionMessageType.Decrypt==obj.type)if(obj.options&&obj.options.isImageDecrypt){window["AscDesktopEditor"]["ResaveFile"](obj.options.src,data[0]);obj.options.img["onload_crypto"](obj.options.src)}else{this.isExistDecryptedChanges=true;obj.data["changes"]=data;obj.sender._onSaveChanges(obj.data,true)}this.nextChanges()};this.isExistEncryptedChanges=
function(_array){if(0==_array.length)return false;this.checkEditorId();var isChangesMode=_array[0]["change"]?true:false;var _prefix="";var _checkPrefixLen=this.cryptoPrefixLen+1;if(isChangesMode){for(var i=_array.length-1;i>=0;i--)if(_array[i]["change"].length>_checkPrefixLen){_prefix=_array[i]["change"].substr(0,_checkPrefixLen);if(-1!=_prefix.indexOf(this.cryptoPrefix)){isCrypted=true;break}}return isCrypted}var isCrypted=false;if(this.editorId==AscCommon.c_oEditorId.Spreadsheet)for(var i=_array.length-
1;i>=0;i--){if(_array[i].length>_checkPrefixLen){_prefix=_array[i].substr(0,_checkPrefixLen);if(-1!=_prefix.indexOf(this.cryptoPrefix)){isCrypted=true;break}}}else for(var i=_array.length-1;i>=0;i--)if(_array[i].m_pData.length>_checkPrefixLen){_prefix=_array[i].m_pData.substr(0,_checkPrefixLen);if(-1!=_prefix.indexOf(this.cryptoPrefix)){isCrypted=true;break}}return isCrypted};this.handleChanges=function(_array,_sender,_callback){if(0==_array.length||!this.isNeedCrypt()){if(this.isExistEncryptedChanges(_array)){this.onDecodeError();
return}this.isChangesHandled=true;_callback.call(_sender);return}this.handleChangesCallback={changesBase:_array,changes:[],sender:_sender,callback:_callback};this.checkEditorId();if(this.editorId==AscCommon.c_oEditorId.Spreadsheet)for(var i=_array.length-1;i>=0;i--)this.handleChangesCallback.changes[i]=_array[i];else for(var i=_array.length-1;i>=0;i--)this.handleChangesCallback.changes[i]=_array[i].m_pData;window.g_asc_plugins.sendToEncryption({"type":"decryptData","data":this.handleChangesCallback.changes})};
this.asc_setAdvancedOptions=function(api,idOption,option){if(window.isNativeOpenPassword){window["AscDesktopEditor"]["NativeViewerOpen"](option.asc_getPassword());return}if(window.isCloudCryptoDownloadAs)return false;if(!this.isNeedCrypt())return false;window.checkPasswordFromPlugin=true;if(window["Asc"].c_oAscAdvancedOptionsID.TXT===idOption){var _param="<m_nCsvTxtEncoding>"+option.asc_getCodePage()+"</m_nCsvTxtEncoding>";window["AscDesktopEditor"]["SetAdvancedOptions"](_param)}else if(window["Asc"].c_oAscAdvancedOptionsID.CSV===
idOption){var delimiter=option.asc_getDelimiter();var delimiterChar=option.asc_getDelimiterChar();var _param="";_param+="<m_nCsvTxtEncoding>"+option.asc_getCodePage()+"</m_nCsvTxtEncoding>";if(null!=delimiter)_param+="<m_nCsvDelimiter>"+delimiter+"</m_nCsvDelimiter>";if(null!=delimiterChar)_param+="<m_nCsvDelimiterChar>"+delimiterChar+"</m_nCsvDelimiterChar>";window["AscDesktopEditor"]["SetAdvancedOptions"](_param)}else if(window["Asc"].c_oAscAdvancedOptionsID.DRM===idOption){var _param="<m_sPassword>"+
AscCommon.CopyPasteCorrectString(option.asc_getPassword())+"</m_sPassword>";api.currentPassword=option.asc_getPassword();window["AscDesktopEditor"]["SetAdvancedOptions"](_param)}return true}}AscCommon.EncryptionWorker=new CEncryptionData;function CMouseSmoothWheelCorrector(t,scrollFunction){this._deltaX=0;this._deltaY=0;this._isBreakX=false;this._isBreakY=false;this._timeoutCorrector=-1;this._api=t;this._scrollFunction=scrollFunction;this._normalDelta=120;this._isNormalDeltaActive=false;this.setNormalDeltaActive=
function(value){this._isNormalDeltaActive=true;this._normalDelta=value};this.isBreakX=function(){return this._isBreakX};this.isBreakY=function(){return this._isBreakY};this.get_DeltaX=function(wheelDeltaX){this._isBreakX=false;if(!AscCommon.AscBrowser.isMacOs)return wheelDeltaX;this._deltaX+=wheelDeltaX;if(Math.abs(this._deltaX)>=this._normalDelta)return this._isNormalDeltaActive?this._deltaX>0?this._normalDelta:-this._normalDelta:this._deltaX;this._isBreakX=true;return 0};this.get_DeltaY=function(wheelDeltaY){this._isBreakY=
false;if(!AscCommon.AscBrowser.isMacOs)return wheelDeltaY;this._deltaY+=wheelDeltaY;if(Math.abs(this._deltaY)>=this._normalDelta)return this._isNormalDeltaActive?this._deltaY>0?this._normalDelta:-this._normalDelta:this._deltaY;this._isBreakY=true;return 0};this.checkBreak=function(){if(-1!=this._timeoutCorrector){clearTimeout(this._timeoutCorrector);this._timeoutCorrector=-1}if((this._isBreakX||this._isBreakY)&&this._scrollFunction){var obj={t:this,x:this._isBreakX?this._deltaX:0,y:this._isBreakY?
this._deltaY:0};this._timeoutCorrector=setTimeout(function(){var t=obj.t;t._scrollFunction.call(t._api,obj.x,obj.y);t._timeoutCorrector=-1;t._deltaX=0;t._deltaY=0},100)}if(!this._isBreakX)this._deltaX=0;if(!this._isBreakY)this._deltaY=0;this._isBreakX=false;this._isBreakY=false}}AscCommon.CMouseSmoothWheelCorrector=CMouseSmoothWheelCorrector;function CTranslateManager(){this.mapTranslate={}}CTranslateManager.prototype.init=function(map){this.mapTranslate=map||{}};CTranslateManager.prototype.getValue=
function(key){return this.mapTranslate.hasOwnProperty(key)?this.mapTranslate[key]:key};function CPolygonPoint2(X,Y){this.X=X;this.Y=Y}function CPolygonVectors(){this.Page=-1;this.VX=[];this.VY=[]}function CPolygonPath(precision){this.Page=-1;this.Direction=1;this.precision=precision;this.Points=[]}CPolygonPath.prototype.PushPoint=function(x,y){this.Points.push(new CPolygonPoint2(x/this.precision,y/this.precision))};CPolygonPath.prototype.CorrectExtremePoints=function(){var Lng=this.Points.length;
this.Points[0].X=this.Points[Lng-1].X;this.Points[Lng-1].Y=this.Points[0].Y};function CPolygon(){this.Vectors=[];this.precision=1E3}CPolygon.prototype.fill=function(arrBounds){this.Vectors.length=0;if(arrBounds.length<=0)return;var nStartLineIndex=0,nStartIndex=0,CountLines=arrBounds.length,CountBounds;while(nStartLineIndex<arrBounds.length){CountBounds=arrBounds[nStartLineIndex].length;while(nStartIndex<CountBounds)if(arrBounds[nStartLineIndex][nStartIndex].W<.001)nStartIndex++;else break;if(nStartIndex<
CountBounds)break;nStartLineIndex++;nStartIndex=0}if(nStartLineIndex>=arrBounds.length)return;var CurrentPage=arrBounds[nStartLineIndex][nStartIndex].Page,CurrentVectors=new CPolygonVectors,VectorsX=CurrentVectors.VX,VectorsY=CurrentVectors.VY;CurrentVectors.Page=CurrentPage;this.Vectors.push(CurrentVectors);for(var LineIndex=nStartLineIndex;LineIndex<CountLines;nStartIndex=0,LineIndex++){if(arrBounds[LineIndex][nStartIndex].Page!==CurrentPage){CurrentPage=arrBounds[LineIndex][nStartIndex].Page;CurrentVectors=
new CPolygonVectors;VectorsX=CurrentVectors.VX;VectorsY=CurrentVectors.VY;CurrentVectors.Page=CurrentPage;this.Vectors.push(CurrentVectors)}for(var Index=nStartIndex;Index<arrBounds[LineIndex].length;Index++){var oBound=arrBounds[LineIndex][Index];if(oBound.W<.001)continue;var x1=Math.round(oBound.X*this.precision),x2=Math.round((oBound.X+oBound.W)*this.precision),y1=Math.round(oBound.Y*this.precision),y2=Math.round((oBound.Y+oBound.H)*this.precision);if(VectorsX[y1]==undefined)VectorsX[y1]={};this.IntersectionX(VectorsX,
x2,x1,y1);if(VectorsY[x1]==undefined)VectorsY[x1]={};this.IntersectionY(VectorsY,y1,y2,x1);if(VectorsX[y2]==undefined)VectorsX[y2]={};this.IntersectionX(VectorsX,x1,x2,y2);if(VectorsY[x2]==undefined)VectorsY[x2]={};this.IntersectionY(VectorsY,y2,y1,x2)}}};CPolygon.prototype.IntersectionX=function(VectorsX,BeginX,EndX,Y){var CurrentVector={};CurrentVector[BeginX]=EndX;var VX=VectorsX[Y];if(BeginX>EndX)while(true==this.IntersectVectorX(CurrentVector,VX));else while(true==this.IntersectVectorX(VX,CurrentVector));
for(var X in CurrentVector){var VBeginX=parseInt(X);var VEndX=CurrentVector[VBeginX];if(VBeginX!==VEndX||VX[VBeginX]===undefined)VX[VBeginX]=VEndX}};CPolygon.prototype.IntersectVectorX=function(VectorOpp,VectorClW){for(var X in VectorOpp){var VBeginX=parseInt(X);var VEndX=VectorOpp[VBeginX];if(VEndX==VBeginX)continue;for(var ClwX in VectorClW){var ClwBeginX=parseInt(ClwX);var ClwEndX=VectorClW[ClwBeginX];var bIntersection=false;if(ClwBeginX==ClwEndX)continue;if(ClwBeginX<=VEndX&&VBeginX<=ClwEndX){VectorOpp[VBeginX]=
VBeginX;VectorClW[ClwBeginX]=VEndX;VectorClW[VBeginX]=ClwEndX;bIntersection=true}else if(VEndX<=ClwBeginX&&ClwEndX<=VBeginX){VectorClW[ClwBeginX]=ClwBeginX;VectorOpp[VBeginX]=ClwEndX;VectorOpp[ClwBeginX]=VEndX;bIntersection=true}else if(ClwBeginX<VEndX&&VEndX<ClwEndX){VectorClW[ClwBeginX]=VEndX;VectorOpp[VBeginX]=ClwEndX;bIntersection=true}else if(ClwBeginX<VBeginX&&VBeginX<ClwEndX){VectorOpp[ClwBeginX]=VEndX;VectorClW[VBeginX]=ClwEndX;delete VectorOpp[VBeginX];delete VectorClW[ClwBeginX];bIntersection=
true}if(bIntersection==true)return true}}return false};CPolygon.prototype.IntersectionY=function(VectorsY,BeginY,EndY,X){var bIntersect=false;for(var y in VectorsY[X]){var CurBeginY=parseInt(y);var CurEndY=VectorsY[X][CurBeginY];var minY,maxY;if(CurBeginY<CurEndY){minY=CurBeginY;maxY=CurEndY}else{minY=CurEndY;maxY=CurBeginY}var bInterSection=!(maxY<=BeginY&&maxY<=EndY||minY>=BeginY&&minY>=EndY),bDirection=(CurBeginY-CurEndY)*(BeginY-EndY)<0;if(bInterSection&&bDirection){VectorsY[X][CurBeginY]=EndY;
VectorsY[X][BeginY]=CurEndY;bIntersect=true}}if(bIntersect==false)VectorsY[X][BeginY]=EndY};CPolygon.prototype.GetPaths=function(shift){var Paths=[];shift*=this.precision;for(var PageIndex=0;PageIndex<this.Vectors.length;PageIndex++){var y,x1,x2,x,y1,y2;var VectorsX=this.Vectors[PageIndex].VX,VectorsY=this.Vectors[PageIndex].VY,Page=this.Vectors[PageIndex].Page;for(var LineIndex in VectorsX)for(var Index in VectorsX[LineIndex]){var Polygon=new CPolygonPath(this.precision);Polygon.Page=Page;y=parseInt(LineIndex);
x1=parseInt(Index);x2=VectorsX[y][x1];VectorsX[y][x1]=-1;var Direction=x1>x2?1:-1;var minY=y;var SignRightLeft,SignDownUp;var X,Y;if(x2!==-1){SignRightLeft=x1>x2?1:-1;Y=y-SignRightLeft*shift;Polygon.PushPoint(x1,Y);while(true){x=x2;y1=y;y2=VectorsY[x][y1];if(y2==-1)break;else if(y2==undefined)return[];VectorsY[x][y1]=-1;SignDownUp=y1>y2?1:-1;X=x+SignDownUp*shift;Polygon.PushPoint(X,Y);y=y2;x1=x;x2=VectorsX[y][x1];if(x2==-1)break;else if(x2==undefined)return[];VectorsX[y][x1]=-1;SignRightLeft=x1>x2?
1:-1;Y=y-SignRightLeft*shift;Polygon.PushPoint(X,Y);if(y<minY){minY=y;Direction=x1>x2?1:-1}}Polygon.PushPoint(X,Y);Polygon.CorrectExtremePoints();Polygon.Direction=Direction;Paths.push(Polygon)}}}return Paths};function CMathTrack(){this.MathRect={IsActive:false,Bounds:[],ContentSelection:null};this.MathPolygons=[];this.MathSelectPolygons=[]}CMathTrack.prototype.Update=function(IsActive,IsContentActive,oMath,PixelError){this.MathRect.IsActive=IsActive;if(true===IsActive&&null!==oMath){var selectBounds=
true===IsContentActive?oMath.Get_ContentSelection():null;if(selectBounds!=null){var SelectPolygon=new CPolygon;SelectPolygon.fill(selectBounds);this.MathSelectPolygons=SelectPolygon.GetPaths(0)}else this.MathSelectPolygons.length=0;var arrBounds=oMath.Get_Bounds();if(arrBounds.length<=0)return;var MPolygon=new CPolygon;MPolygon.fill(arrBounds);this.MathPolygons=MPolygon.GetPaths(PixelError)}};CMathTrack.prototype.Draw=function(overlay,oPath,shift,color,dKoefX,dKoefY,left,top){var ctx=overlay.m_oContext;
ctx.strokeStyle=color;ctx.lineWidth=1;ctx.beginPath();var Points=oPath.Points;var nCount=Points.length;var PrevX=Points[nCount-2].X,PrevY=Points[nCount-2].Y;var _x=left+dKoefX*Points[nCount-2].X,_y=top+dKoefY*Points[nCount-2].Y;var StartX,StartY;for(var nIndex=0;nIndex<nCount;nIndex++){if(PrevX>Points[nIndex].X)_y=top+dKoefY*Points[nIndex].Y-shift;else if(PrevX<Points[nIndex].X)_y=top+dKoefY*Points[nIndex].Y+shift;if(PrevY<Points[nIndex].Y)_x=left+dKoefX*Points[nIndex].X-shift;else if(PrevY>Points[nIndex].Y)_x=
left+dKoefX*Points[nIndex].X+shift;PrevX=Points[nIndex].X;PrevY=Points[nIndex].Y;if(nIndex>0){overlay.CheckPoint(_x,_y);if(1==nIndex){StartX=_x;StartY=_y;overlay.m_oContext.moveTo((_x>>0)+.5,(_y>>0)+.5)}else overlay.m_oContext.lineTo((_x>>0)+.5,(_y>>0)+.5)}}overlay.m_oContext.lineTo((StartX>>0)+.5,(StartY>>0)+.5);ctx.closePath();ctx.stroke();ctx.beginPath()};CMathTrack.prototype.DrawWithMatrix=function(overlay,oPath,ShiftX,ShiftY,color,dKoefX,dKoefY,left,top,m){var ctx=overlay.m_oContext;ctx.strokeStyle=
color;ctx.lineWidth=1;ctx.beginPath();var Points=oPath.Points;var nCount=Points.length;var x=Points[nCount-2].X,y=Points[nCount-2].Y;var _x,_y;var PrevX=Points[nCount-2].X,PrevY=Points[nCount-2].Y;var StartX,StartY;for(var nIndex=0;nIndex<nCount;nIndex++){if(PrevX>Points[nIndex].X)y=Points[nIndex].Y-ShiftY;else if(PrevX<Points[nIndex].X)y=Points[nIndex].Y+ShiftY;if(PrevY<Points[nIndex].Y)x=Points[nIndex].X-ShiftX;else if(PrevY>Points[nIndex].Y)x=Points[nIndex].X+ShiftX;PrevX=Points[nIndex].X;PrevY=
Points[nIndex].Y;if(nIndex>0){_x=left+dKoefX*m.TransformPointX(x,y);_y=top+dKoefY*m.TransformPointY(x,y);overlay.CheckPoint(_x,_y);if(1==nIndex){StartX=_x;StartY=_y;overlay.m_oContext.moveTo((_x>>0)+.5,(_y>>0)+.5)}else overlay.m_oContext.lineTo((_x>>0)+.5,(_y>>0)+.5)}}overlay.m_oContext.lineTo((StartX>>0)+.5,(StartY>>0)+.5);ctx.closePath();ctx.stroke();ctx.beginPath()};CMathTrack.prototype.DrawSelectPolygon=function(overlay,oPath,dKoefX,dKoefY,left,top,m){var ctx=overlay.m_oContext;ctx.fillStyle=
"#375082";ctx.beginPath();var Points=oPath.Points;var nPointIndex;var _x,_y,x,y,p;for(nPointIndex=0;nPointIndex<Points.length-1;nPointIndex++){p=Points[nPointIndex];if(!m){_x=left+dKoefX*p.X;_y=top+dKoefY*p.Y}else{x=p.X;y=p.Y;_x=left+dKoefX*m.TransformPointX(x,y);_y=top+dKoefY*m.TransformPointY(x,y)}overlay.CheckPoint(_x,_y);if(0==nPointIndex)ctx.moveTo((_x>>0)+.5,(_y>>0)+.5);else ctx.lineTo((_x>>0)+.5,(_y>>0)+.5)}ctx.globalAlpha=.2;ctx.fill();ctx.globalAlpha=1};CMathTrack.prototype.IsActive=function(){return this.MathRect.IsActive};
CMathTrack.prototype.GetPolygonsCount=function(){return this.MathPolygons.length};CMathTrack.prototype.GetPolygon=function(nIndex){return this.MathPolygons[nIndex]};CMathTrack.prototype.GetSelectPathsCount=function(){return this.MathSelectPolygons.length};CMathTrack.prototype.GetSelectPath=function(nIndex){return this.MathSelectPolygons[nIndex]};if(!Array.prototype.findIndex)Object.defineProperty(Array.prototype,"findIndex",{value:function(predicate){if(this==null)throw new TypeError("Array.prototype.findIndex called on null or undefined");
if(typeof predicate!=="function")throw new TypeError("predicate must be a function");var list=Object(this);var length=list.length>>>0;var thisArg=arguments[1];var value;for(var i=0;i<length;i++){value=list[i];if(predicate.call(thisArg,value,i,list))return i}return-1}});if(!Array.prototype.fill)Object.defineProperty(Array.prototype,"fill",{value:function(value){if(this==null)throw new TypeError("this is null or not defined");var O=Object(this);var len=O.length>>>0;var start=arguments[1];var relativeStart=
start>>0;var k=relativeStart<0?Math.max(len+relativeStart,0):Math.min(relativeStart,len);var end=arguments[2];var relativeEnd=end===undefined?len:end>>0;var final=relativeEnd<0?Math.max(len+relativeEnd,0):Math.min(relativeEnd,len);while(k<final){O[k]=value;k++}return O}});if(typeof Int8Array!=="undefined"&&!Int8Array.prototype.fill)Int8Array.prototype.fill=Array.prototype.fill;if(typeof Uint8Array!=="undefined"&&!Uint8Array.prototype.fill)Uint8Array.prototype.fill=Array.prototype.fill;if(typeof Uint8ClampedArray!==
"undefined"&&!Uint8ClampedArray.prototype.fill)Uint8ClampedArray.prototype.fill=Array.prototype.fill;if(typeof Int16Array!=="undefined"&&!Int16Array.prototype.fill)Int16Array.prototype.fill=Array.prototype.fill;if(typeof Uint16Array!=="undefined"&&!Uint16Array.prototype.fill)Uint16Array.prototype.fill=Array.prototype.fill;if(typeof Int32Array!=="undefined"&&!Int32Array.prototype.fill)Int32Array.prototype.fill=Array.prototype.fill;if(typeof Uint32Array!=="undefined"&&!Uint32Array.prototype.fill)Uint32Array.prototype.fill=
Array.prototype.fill;if(typeof Float32Array!=="undefined"&&!Float32Array.prototype.fill)Float32Array.prototype.fill=Array.prototype.fill;if(typeof Float64Array!=="undefined"&&!Float64Array.prototype.fill)Float64Array.prototype.fill=Array.prototype.fill;if(typeof Uint8Array!=="undefined"&&!Uint8Array.prototype.slice)Uint8Array.prototype.slice=Array.prototype.slice;function parseText(text,options,bTrimSpaces){var delimiterChar;if(options.asc_getDelimiterChar())delimiterChar=options.asc_getDelimiterChar();
else switch(options.asc_getDelimiter()){case AscCommon.c_oAscCsvDelimiter.None:delimiterChar=undefined;break;case AscCommon.c_oAscCsvDelimiter.Tab:delimiterChar="\t";break;case AscCommon.c_oAscCsvDelimiter.Semicolon:delimiterChar=";";break;case AscCommon.c_oAscCsvDelimiter.Colon:delimiterChar=":";break;case AscCommon.c_oAscCsvDelimiter.Comma:delimiterChar=",";break;case AscCommon.c_oAscCsvDelimiter.Space:delimiterChar=" ";break}var matrix=[];var rows=text.split(/\r?\n/);for(var i=0;i<rows.length;++i){var row=
rows[i];if(" "===delimiterChar&&bTrimSpaces){var addSpace=false;if(row[0]===delimiterChar)addSpace=true;row=addSpace?delimiterChar+row.trim():row.trim()}matrix.push(row.split(delimiterChar))}return matrix}function getTimeISO8601(dateStr){if(dateStr)if(dateStr.endsWith("Z"))return Date.parse(dateStr);else return Date.parse(dateStr+"Z");return NaN}function valueToMmType(value){var oVal=parseFloat(value);var oType;if(!isNaN(oVal)){if(-1!==value.indexOf("%")){oType="%";oVal/=100}else if(-1!==value.indexOf("px")){oType=
"px";oVal*=AscCommon.g_dKoef_pix_to_mm}else if(-1!==value.indexOf("in")){oType="in";oVal*=AscCommonWord.g_dKoef_in_to_mm}else if(-1!==value.indexOf("cm")){oType="cm";oVal*=10}else if(-1!==value.indexOf("mm"))oType="mm";else if(-1!==value.indexOf("pt")){oType="pt";oVal*=AscCommonWord.g_dKoef_pt_to_mm}else if(-1!==value.indexOf("pc")){oType="pc";oVal*=AscCommonWord.g_dKoef_pc_to_mm}else oType="none";return{val:oVal,type:oType}}return null}function valueToMm(value){var obj=valueToMmType(value);if(obj&&
"%"!==obj.type&&"none"!==obj.type)return obj.val;return null}function arrayMove(array,from,to){array.splice(to,0,array.splice(from,1)[0])}function getRangeArray(start,stop){var res=new Array(stop-start);for(var i=start;i<stop;++i)res[i-start]=i;return res}var g_oBackoffDefaults={retries:2,factor:2,minTimeout:100,maxTimeout:2E3,randomize:true};function Backoff(opts){this.attempts=0;this.opts=opts}Backoff.prototype.attempt=function(fError,fRetry){var timeout=this.nextTimeout();if(timeout>0)setTimeout(function(){fRetry()},
timeout);else fError()};Backoff.prototype.nextTimeout=function(){var timeout=-1;if(this.attempts<this.opts.retries){timeout=this.createTimeout(this.attempts,this.opts);this.attempts++}return timeout};Backoff.prototype.createTimeout=function(attempt,opts){var random=opts.randomize?Math.random()+1:1;var timeout=Math.round(random*opts.minTimeout*Math.pow(opts.factor,attempt));timeout=Math.min(timeout,opts.maxTimeout);return timeout};function backoffOnError(obj,onError,onRetry){if(!onRetry)return onError;
var backoff=new Backoff(g_oBackoffDefaults);return function(){var timeout=backoff.nextTimeout();if(timeout>0)setTimeout(function(){onRetry.call(obj,obj)},timeout);else if(onError)onError.apply(obj,arguments)}}function backoffOnErrorImg(img,onRetry){if(!onRetry)onRetry=function(img){img.setAttribute("src",img.getAttribute("src"))};img.onerror=backoffOnError(img,img.onerror,onRetry)}function isEmptyObject(obj){for(var name in obj)return false;return true}window["AscCommon"]=window["AscCommon"]||{};
window["AscCommon"].getSockJs=getSockJs;window["AscCommon"].getJSZipUtils=getJSZipUtils;window["AscCommon"].getJSZip=getJSZip;window["AscCommon"].getBaseUrl=getBaseUrl;window["AscCommon"].getEncodingParams=getEncodingParams;window["AscCommon"].getEncodingByBOM=getEncodingByBOM;window["AscCommon"].saveWithParts=saveWithParts;window["AscCommon"].loadFileContent=loadFileContent;window["AscCommon"].getImageFromChanges=getImageFromChanges;window["AscCommon"].openFileCommand=openFileCommand;window["AscCommon"].sendCommand=
sendCommand;window["AscCommon"].sendSaveFile=sendSaveFile;window["AscCommon"].mapAscServerErrorToAscError=mapAscServerErrorToAscError;window["AscCommon"].joinUrls=joinUrls;window["AscCommon"].getFullImageSrc2=getFullImageSrc2;window["AscCommon"].fSortAscending=fSortAscending;window["AscCommon"].fSortDescending=fSortDescending;window["AscCommon"].isLeadingSurrogateChar=isLeadingSurrogateChar;window["AscCommon"].decodeSurrogateChar=decodeSurrogateChar;window["AscCommon"].encodeSurrogateChar=encodeSurrogateChar;
window["AscCommon"].convertUnicodeToUTF16=convertUnicodeToUTF16;window["AscCommon"].convertUTF16toUnicode=convertUTF16toUnicode;window["AscCommon"].build_local_rx=build_local_rx;window["AscCommon"].GetFileName=GetFileName;window["AscCommon"].GetFileExtension=GetFileExtension;window["AscCommon"].changeFileExtention=changeFileExtention;window["AscCommon"].getExtentionByFormat=getExtentionByFormat;window["AscCommon"].InitOnMessage=InitOnMessage;window["AscCommon"].ShowImageFileDialog=ShowImageFileDialog;
window["AscCommon"].ShowDocumentFileDialog=ShowDocumentFileDialog;window["AscCommon"].InitDragAndDrop=InitDragAndDrop;window["AscCommon"].UploadImageFiles=UploadImageFiles;window["AscCommon"].UploadImageUrls=UploadImageUrls;window["AscCommon"].CanDropFiles=CanDropFiles;window["AscCommon"].getUrlType=getUrlType;window["AscCommon"].prepareUrl=prepareUrl;window["AscCommon"].getUserColorById=getUserColorById;window["AscCommon"].isNullOrEmptyString=isNullOrEmptyString;window["AscCommon"].unleakString=
unleakString;window["AscCommon"].readValAttr=readValAttr;window["AscCommon"].getNumFromXml=getNumFromXml;window["AscCommon"].getColorFromXml=getColorFromXml;window["AscCommon"].getBoolFromXml=getBoolFromXml;window["AscCommon"].initStreamFromResponse=initStreamFromResponse;window["AscCommon"].checkStreamSignature=checkStreamSignature;window["AscCommon"].DocumentUrls=DocumentUrls;window["AscCommon"].OpenFileResult=OpenFileResult;window["AscCommon"].CLock=CLock;window["AscCommon"].CContentChanges=CContentChanges;
window["AscCommon"].CContentChangesElement=CContentChangesElement;window["AscCommon"].CorrectMMToTwips=CorrectMMToTwips;window["AscCommon"].TwipsToMM=TwipsToMM;window["AscCommon"].MMToTwips=MMToTwips;window["AscCommon"].RomanToInt=RomanToInt;window["AscCommon"].LatinNumberingToInt=LatinNumberingToInt;window["AscCommon"].IntToNumberFormat=IntToNumberFormat;window["AscCommon"].IsSpace=IsSpace;window["AscCommon"].loadSdk=loadSdk;window["AscCommon"].loadScript=loadScript;window["AscCommon"].getAltGr=
getAltGr;window["AscCommon"].getColorSchemeByName=getColorSchemeByName;window["AscCommon"].getColorSchemeByIdx=getColorSchemeByIdx;window["AscCommon"].getAscColorScheme=getAscColorScheme;window["AscCommon"].checkAddColorScheme=checkAddColorScheme;window["AscCommon"].getIndexColorSchemeInArray=getIndexColorSchemeInArray;window["AscCommon"].isEastAsianScript=isEastAsianScript;window["AscCommon"].CMathTrack=CMathTrack;window["AscCommon"].CPolygon=CPolygon;window["AscCommon"].JSZipWrapper=JSZipWrapper;
window["AscCommon"].g_oDocumentUrls=g_oDocumentUrls;window["AscCommon"].FormulaTablePartInfo=FormulaTablePartInfo;window["AscCommon"].cBoolLocal=cBoolLocal;window["AscCommon"].cErrorOrigin=cErrorOrigin;window["AscCommon"].cErrorLocal=cErrorLocal;window["AscCommon"].FormulaSeparators=FormulaSeparators;window["AscCommon"].rx_space_g=rx_space_g;window["AscCommon"].rx_space=rx_space;window["AscCommon"].rx_defName=rx_defName;window["AscCommon"].kCurFormatPainterWord=kCurFormatPainterWord;window["AscCommon"].parserHelp=
parserHelp;window["AscCommon"].g_oIdCounter=g_oIdCounter;window["AscCommon"].g_oHtmlCursor=g_oHtmlCursor;window["AscCommon"].g_oBackoffDefaults=g_oBackoffDefaults;window["AscCommon"].Backoff=Backoff;window["AscCommon"].backoffOnErrorImg=backoffOnErrorImg;window["AscCommon"].isEmptyObject=isEmptyObject;window["AscCommon"].CSignatureDrawer=window["AscCommon"]["CSignatureDrawer"]=CSignatureDrawer;var prot=CSignatureDrawer.prototype;prot["getImages"]=prot.getImages;prot["setText"]=prot.setText;prot["selectImage"]=
prot.selectImage;prot["isValid"]=prot.isValid;prot["destroy"]=prot.destroy;window["AscCommon"].translateManager=new CTranslateManager;window["AscCommon"].parseText=parseText;window["AscCommon"].getTimeISO8601=getTimeISO8601;window["AscCommon"].valueToMm=valueToMm;window["AscCommon"].valueToMmType=valueToMmType;window["AscCommon"].arrayMove=arrayMove;window["AscCommon"].getRangeArray=getRangeArray;window["AscCommon"].CUnicodeStringEmulator=CUnicodeStringEmulator;window["AscCommon"].private_IsAbbreviation=
private_IsAbbreviation;window["AscCommon"].rx_test_ws_name=rx_test_ws_name;window["AscCommon"].CShortcuts=window["AscCommon"]["CShortcuts"]=CShortcuts;prot=CShortcuts.prototype;prot["Add"]=prot.Add;prot["Get"]=prot.Get;prot["CheckType"]=prot.CheckType;prot["Remove"]=prot.Remove;prot["RemoveByType"]=prot.RemoveByType;prot["GetNewCustomType"]=prot.GetNewCustomType;prot["IsCustomType"]=prot.IsCustomType;prot["GetCustomAction"]=prot.GetCustomAction;prot["AddCustomActionSymbol"]=prot.AddCustomActionSymbol;
window["AscCommon"].CCustomShortcutActionSymbol=window["AscCommon"]["CCustomShortcutActionSymbol"]=CCustomShortcutActionSymbol})(window);
window["asc_initAdvancedOptions"]=function(_code,_file_hash,_docInfo){if(window.isNativeOpenPassword)return window["NativeFileOpen_error"](window.isNativeOpenPassword,_file_hash,_docInfo);var _editor=window["Asc"]["editor"]?window["Asc"]["editor"]:window.editor;if(_code==90||_code==91){if(window["AscDesktopEditor"]&&0!==window["AscDesktopEditor"]["CryptoMode"]&&!_editor.isLoadFullApi){_editor.asc_initAdvancedOptions_params=[];_editor.asc_initAdvancedOptions_params.push(_code);_editor.asc_initAdvancedOptions_params.push(_file_hash);
_editor.asc_initAdvancedOptions_params.push(_docInfo);return}if(AscCommon.EncryptionWorker.isNeedCrypt()&&!window.checkPasswordFromPlugin){window.checkPasswordFromPlugin=true;window.g_asc_plugins.sendToEncryption({"type":"getPasswordByFile","hash":_file_hash,"docinfo":_docInfo});return}}window.checkPasswordFromPlugin=false;_editor._onNeedParams(undefined,_code==90||_code==91?true:undefined)};
window["asc_IsNeedBuildCryptedFile"]=function(){if(!window["AscDesktopEditor"]||!window["AscDesktopEditor"]["CryptoMode"])return false;var _api=window["Asc"]["editor"]?window["Asc"]["editor"]:window.editor;var _returnValue=false;var _users=null;if(_api.CoAuthoringApi&&_api.CoAuthoringApi._CoAuthoringApi&&_api.CoAuthoringApi._CoAuthoringApi._participants)_users=_api.CoAuthoringApi._CoAuthoringApi._participants;var _usersCount=0;for(var _user in _users)_usersCount++;var isOne=1>=_usersCount?true:false;

@ -8402,18 +8402,18 @@ function(font_index,stream_index){this.embeddedFontFiles[font_index].SetStreamIn
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.LoadDocumentImagesCallback=function(){if(this.ThemeLoader==null)this.Api.asyncImagesDocumentEndLoaded();else this.ThemeLoader.asyncImagesEndLoaded()};this.LoadDocumentImages=
function(_images){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);var that=this;setTimeout(function(){that.LoadDocumentImagesCallback()},
3E3)}};this.loadImageByUrl=function(_image,_url){if(this.isBlockchainSupport)_image.preload_crypto(_url);else _image.src=_url};this._LoadImages=function(){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)});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)});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;var oThat=oThis;oImage.Image.onload=
function(){oImage.Status=ImageLoadStatus.Complete;oThat.Api.asyncImageEndLoadedBackground(oImage)};oImage.Image.onerror=function(){oImage.Status=ImageLoadStatus.Complete;oImage.Image=null;oThat.Api.asyncImageEndLoadedBackground(oImage)};AscCommon.backoffOnErrorImg(oImage.Image,function(img){oThis.loadImageByUrl(img,img.src)});console.log("Loading image "+i);console.log(oImage);window.parent.APP.getImageURL(oImage.src,function(url){if(url=="")oThis.loadImageByUrl(oImage.Image,oImage.src);else{oThis.loadImageByUrl(oImage.Image,
url);oThis.map_image_index[url]=oImage}})};this.LoadImagesWithCallback=function(arr,loadImageCallBack,loadImageCallBackArgs){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}this.loadImageCallBackCounter=0;this.loadImageCallBackCounterMax=arrAsync.length;this.loadImageCallBack=loadImageCallBack;this.loadImageCallBackArgs=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;oThis.loadImageCallBackCounter++;if(oThis.loadImageCallBackCounter==oThis.loadImageCallBackCounterMax)oThis.LoadImagesWithCallbackEnd()};oImage.Image.onerror=function(){this.parentImage.Image=null;this.parentImage.Status=ImageLoadStatus.Complete;
oThis.loadImageCallBackCounter++;if(oThis.loadImageCallBackCounter==oThis.loadImageCallBackCounterMax)oThis.LoadImagesWithCallbackEnd()};AscCommon.backoffOnErrorImg(oImage.Image,function(img){oThis.loadImageByUrl(img,img.src)});this.loadImageByUrl(oImage.Image,oImage.src)}};this.LoadImagesWithCallbackEnd=function(){this.loadImageCallBack.call(this.Api,this.loadImageCallBackArgs);this.loadImageCallBack=null;this.loadImageCallBackArgs=null;this.loadImageCallBackCounterMax=0;this.loadImageCallBackCounter=
0}}var g_flow_anchor=new Image;g_flow_anchor.asc_complete=false;g_flow_anchor.onload=function(){g_flow_anchor.asc_complete=true};g_flow_anchor.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPBAMAAADNDVhEAAAAIVBMVEUAAAANDQ0NDQ0NDQ0NDQ0NDQ0AAAANDQ0NDQ0NDQ0NDQ1jk7YPAAAACnRSTlMAGkD4mb9c5s9TDghpXQAAAFZJREFUCNdjYGBgW8YABlxcIBLBZ1gAEfZa5QWiGRkWMAIpAaA4iHQE0YwODEtANMsChkIwv4BBWQBICyswMC1iWADEDAzKoUuDFUAGNC9uABvIaQkkABpxD6lFb9lRAAAAAElFTkSuQmCC";var g_flow_anchor2=new Image;g_flow_anchor2.asc_complete=
false;g_flow_anchor2.onload=function(){g_flow_anchor2.asc_complete=true};g_flow_anchor2.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAeCAMAAAAFBf7qAAAAOVBMVEUAAAAAAAAAAAAAAAAJCQkAAAAJCQkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJCQknI0ZQAAAAEnRSTlMAx9ITlAfyPHxn68yecTAl5qt6y0BvAAAAt0lEQVQoz8WS0QrDIAxFk0ajtlXb+/8fuzAprltg7Gnn4aIcvAgJTSSoBiGPoIAGV60qoquvIIL110IJgPONmKIlMI73MiwGRoZvahbKVSizcDKU8QeVPDXEIr6ShVB9VUEn2FOMkwL8VwjUtuypvDWiHeVTFeyWkZHfVQZHGm4XMhKQyJB9GKMxuHQSBlioF7u2q7kzgO2AcWwW3F8mWRmGKgyu91mK1Tzh4ixVVkBzJI/EnGjyACbfCaO3eIWRAAAAAElFTkSuQmCC";
function(_images){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;if(_len===0)return void this.LoadDocumentImagesCallback();var todo=_len;var that=this;var done=function(){todo--;
if(todo===0){that.images_loading.splice(0,_len);setTimeout(function(){that.LoadDocumentImagesCallback()},100);done=function(){}}};for(var i=0;i<_len;i++)this.LoadImageAsync(i,done);return;this.images_loading.splice(0,_len);var that=this;setTimeout(function(){that.LoadDocumentImagesCallback()},3E3)}};this.loadImageByUrl=function(_image,_url){if(this.isBlockchainSupport)_image.preload_crypto(_url);else _image.src=_url};this._LoadImages=function(){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)});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)});this.loadImageByUrl(oImage.Image,oImage.src);return null};this.LoadImageAsync=function(i,
cb){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;var oThat=oThis;oImage.Image.onload=function(){oImage.Status=ImageLoadStatus.Complete;oThat.Api.asyncImageEndLoadedBackground(oImage)};oImage.Image.onerror=function(){oImage.Status=ImageLoadStatus.Complete;oImage.Image=null;oThat.Api.asyncImageEndLoadedBackground(oImage)};AscCommon.backoffOnErrorImg(oImage.Image,function(img){oThis.loadImageByUrl(img,
img.src)});console.log("Loading image "+i);console.log(oImage);window.parent.APP.getImageURL(oImage.src,function(url){if(url=="")oThis.loadImageByUrl(oImage.Image,oImage.src);else{oThis.loadImageByUrl(oImage.Image,url);oThis.map_image_index[url]=oImage}if(typeof cb==="function")cb()})};this.LoadImagesWithCallback=function(arr,loadImageCallBack,loadImageCallBackArgs){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}this.loadImageCallBackCounter=0;this.loadImageCallBackCounterMax=arrAsync.length;this.loadImageCallBack=loadImageCallBack;this.loadImageCallBackArgs=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;
oThis.loadImageCallBackCounter++;if(oThis.loadImageCallBackCounter==oThis.loadImageCallBackCounterMax)oThis.LoadImagesWithCallbackEnd()};oImage.Image.onerror=function(){this.parentImage.Image=null;this.parentImage.Status=ImageLoadStatus.Complete;oThis.loadImageCallBackCounter++;if(oThis.loadImageCallBackCounter==oThis.loadImageCallBackCounterMax)oThis.LoadImagesWithCallbackEnd()};AscCommon.backoffOnErrorImg(oImage.Image,function(img){oThis.loadImageByUrl(img,img.src)});this.loadImageByUrl(oImage.Image,
oImage.src)}};this.LoadImagesWithCallbackEnd=function(){this.loadImageCallBack.call(this.Api,this.loadImageCallBackArgs);this.loadImageCallBack=null;this.loadImageCallBackArgs=null;this.loadImageCallBackCounterMax=0;this.loadImageCallBackCounter=0}}var g_flow_anchor=new Image;g_flow_anchor.asc_complete=false;g_flow_anchor.onload=function(){g_flow_anchor.asc_complete=true};g_flow_anchor.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPBAMAAADNDVhEAAAAIVBMVEUAAAANDQ0NDQ0NDQ0NDQ0NDQ0AAAANDQ0NDQ0NDQ0NDQ1jk7YPAAAACnRSTlMAGkD4mb9c5s9TDghpXQAAAFZJREFUCNdjYGBgW8YABlxcIBLBZ1gAEfZa5QWiGRkWMAIpAaA4iHQE0YwODEtANMsChkIwv4BBWQBICyswMC1iWADEDAzKoUuDFUAGNC9uABvIaQkkABpxD6lFb9lRAAAAAElFTkSuQmCC";
var g_flow_anchor2=new Image;g_flow_anchor2.asc_complete=false;g_flow_anchor2.onload=function(){g_flow_anchor2.asc_complete=true};g_flow_anchor2.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAeCAMAAAAFBf7qAAAAOVBMVEUAAAAAAAAAAAAAAAAJCQkAAAAJCQkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJCQknI0ZQAAAAEnRSTlMAx9ITlAfyPHxn68yecTAl5qt6y0BvAAAAt0lEQVQoz8WS0QrDIAxFk0ajtlXb+/8fuzAprltg7Gnn4aIcvAgJTSSoBiGPoIAGV60qoquvIIL110IJgPONmKIlMI73MiwGRoZvahbKVSizcDKU8QeVPDXEIr6ShVB9VUEn2FOMkwL8VwjUtuypvDWiHeVTFeyWkZHfVQZHGm4XMhKQyJB9GKMxuHQSBlioF7u2q7kzgO2AcWwW3F8mWRmGKgyu91mK1Tzh4ixVVkBzJI/EnGjyACbfCaO3eIWRAAAAAElFTkSuQmCC";
window["AscCommon"]=window["AscCommon"]||{};window["AscCommon"].g_font_loader=new CGlobalFontLoader;window["AscCommon"].g_image_loader=new CGlobalImageLoader;window["AscCommon"].g_flow_anchor=g_flow_anchor;window["AscCommon"].g_flow_anchor2=g_flow_anchor2})(window,window.document);"use strict";(function(window,undefined){var g_dKoef_mm_to_pix=AscCommon.g_dKoef_mm_to_pix;function CBounds(){this.L=0;this.T=0;this.R=0;this.B=0;this.isAbsL=false;this.isAbsT=false;this.isAbsR=false;this.isAbsB=false;this.AbsW=
-1;this.AbsH=-1;this.SetParams=function(_l,_t,_r,_b,abs_l,abs_t,abs_r,abs_b,absW,absH){this.L=_l;this.T=_t;this.R=_r;this.B=_b;this.isAbsL=abs_l;this.isAbsT=abs_t;this.isAbsR=abs_r;this.isAbsB=abs_b;this.AbsW=absW;this.AbsH=absH}}function CAbsolutePosition(){this.L=0;this.T=0;this.R=0;this.B=0}var g_anchor_left=1;var g_anchor_top=2;var g_anchor_right=4;var g_anchor_bottom=8;function CControl(){this.Bounds=new CBounds;this.Anchor=g_anchor_left|g_anchor_top;this.Name=null;this.Parent=null;this.TabIndex=
null;this.HtmlElement=null;this.AbsolutePosition=new CBounds;this.Resize=function(_width,_height,api){if(null==this.Parent||null==this.HtmlElement)return;var _x=0;var _y=0;var _r=0;var _b=0;var hor_anchor=this.Anchor&5;var ver_anchor=this.Anchor&10;if(g_anchor_left==hor_anchor){if(this.Bounds.isAbsL)_x=this.Bounds.L;else _x=this.Bounds.L*_width/1E3;if(-1!=this.Bounds.AbsW)_r=_x+this.Bounds.AbsW;else if(this.Bounds.isAbsR)_r=_width-this.Bounds.R;else _r=this.Bounds.R*_width/1E3}else if(g_anchor_right==
@ -19395,59 +19395,59 @@ this.CheckFootnote(X,Y,CurPage);if(isInText&&null!=oHyperlink&&(Y<=this.Pages[Cu
Asc.c_oAscMouseMoveDataTypes.Common;if(isInText&&(null!=oHyperlink||bPageRefLink)&&true===AscCommon.global_keyboardEvent.CtrlKey)this.DrawingDocument.SetCursorType("pointer",MMData);else this.DrawingDocument.SetCursorType("text",MMData);var Bounds=this.Pages[CurPage].Bounds;if(true===this.Lock.Is_Locked()&&X<Bounds.Right&&X>Bounds.Left&&Y>Bounds.Top&&Y<Bounds.Bottom&&this.LogicDocument&&!this.LogicDocument.IsViewModeInReview()){var _X=this.Pages[CurPage].X;var _Y=this.Pages[CurPage].Y;var MMData=
new AscCommon.CMouseMoveData;var Coords=this.DrawingDocument.ConvertCoordsToCursorWR(_X,_Y,this.Get_AbsolutePage(CurPage),text_transform);MMData.X_abs=Coords.X-5;MMData.Y_abs=Coords.Y;MMData.Type=Asc.c_oAscMouseMoveDataTypes.LockedObject;MMData.UserId=this.Lock.Get_UserId();MMData.HaveChanges=this.Lock.Have_Changes();MMData.LockedObjectType=c_oAscMouseMoveLockedObjectType.Common;editor.sync_MouseMoveCallback(MMData)}};Paragraph.prototype.Document_CreateFontMap=function(FontMap){if(true===this.FontMap.NeedRecalc){this.FontMap.Map=
{};this.private_CompileParaPr();var FontScheme=this.Get_Theme().themeElements.fontScheme;var CurTextPr=this.CompiledPr.Pr.TextPr.Copy();CurTextPr.Document_CreateFontMap(this.FontMap.Map,FontScheme);CurTextPr.Merge(this.TextPr.Value);CurTextPr.Document_CreateFontMap(this.FontMap.Map,FontScheme);var Count=this.Content.length;for(var Index=0;Index<Count;Index++)this.Content[Index].Create_FontMap(this.FontMap.Map);this.FontMap.NeedRecalc=false}for(var Key in this.FontMap.Map)FontMap[Key]=this.FontMap.Map[Key]};
Paragraph.prototype.Document_CreateFontCharMap=function(FontCharMap){};Paragraph.prototype.Document_Get_AllFontNames=function(AllFonts){this.TextPr.Value.Document_Get_AllFontNames(AllFonts);if(this.Pr.Bullet)this.Pr.Bullet.Get_AllFontNames(AllFonts);if(this.Pr.DefaultRunPr)this.Pr.DefaultRunPr.Document_Get_AllFontNames(AllFonts);var Count=this.Content.length;for(var Index=0;Index<Count;Index++)this.Content[Index].Get_AllFontNames(AllFonts)};Paragraph.prototype.Document_UpdateRulersState=function(){if(this.CalculatedFrame){var oFrame=
this.CalculatedFrame;this.Parent.DrawingDocument.Set_RulerState_Paragraph({L:oFrame.L2,T:oFrame.T2,R:oFrame.L2+oFrame.W2,B:oFrame.T2+oFrame.H2,PageIndex:this.GetStartPageAbsolute(),Frame:this},false)}else if(this.Parent instanceof CDocument)if(this.LogicDocument)this.LogicDocument.Document_UpdateRulersStateBySection()};Paragraph.prototype.Document_UpdateInterfaceState=function(){var StartPos,EndPos;if(true===this.Selection.Use){StartPos=this.Get_ParaContentPos(true,true);EndPos=this.Get_ParaContentPos(true,
false)}else{var CurPos=this.Get_ParaContentPos(false,false);StartPos=CurPos;EndPos=CurPos}if(this.LogicDocument&&true===this.LogicDocument.Spelling.Use&&(selectionflag_Numbering!==this.Selection.Flag&&selectionflag_NumberingCur!==this.Selection.Flag))this.SpellChecker.Document_UpdateInterfaceState(StartPos,EndPos);if(true===this.Selection.Use){var StartPos=this.Selection.StartPos;var EndPos=this.Selection.EndPos;if(StartPos>EndPos){StartPos=this.Selection.EndPos;EndPos=this.Selection.StartPos}for(var CurPos=
StartPos;CurPos<=EndPos;CurPos++){var Element=this.Content[CurPos];if(true!==Element.IsSelectionEmpty()&&Element.Document_UpdateInterfaceState)Element.Document_UpdateInterfaceState()}}else{var CurType=this.Content[this.CurPos.ContentPos].Type;if(this.Content[this.CurPos.ContentPos].Document_UpdateInterfaceState)this.Content[this.CurPos.ContentPos].Document_UpdateInterfaceState()}var arrComplexFields=this.GetCurrentComplexFields();for(var nIndex=0,nCount=arrComplexFields.length;nIndex<nCount;++nIndex){var oInstruction=
arrComplexFields[nIndex].GetInstruction();if(oInstruction&&fieldtype_HYPERLINK===oInstruction.GetType()){var oHyperProps=new Asc.CHyperlinkProperty;oHyperProps.put_ToolTip(oInstruction.GetToolTip());oHyperProps.put_Value(oInstruction.GetValue());oHyperProps.put_Text(this.LogicDocument?this.LogicDocument.GetComplexFieldTextValue(arrComplexFields[nIndex]):null);oHyperProps.put_InternalHyperlink(oInstruction);editor.sync_HyperlinkPropCallback(oHyperProps)}}if(editor&&this.bFromDocument){if(!this.LogicDocument)return;
var TrackManager=this.LogicDocument.GetTrackRevisionsManager();if(this.Pages.length<=0&&this.Lines.length<=0)return;var ContentPos=this.Get_ParaContentPos(this.Selection.Use,true);var ParaPos=this.Get_ParaPosByContentPos(ContentPos);if(this.Pages.length<=ParaPos.Page||this.Lines.length<=ParaPos.Line)return;var Page_abs=this.Get_AbsolutePage(ParaPos.Page);var _Y=this.Pages[ParaPos.Page].Y+this.Lines[ParaPos.Line].Top;var TextTransform=this.Get_ParentTextTransform();var _X=this.LogicDocument?this.LogicDocument.Get_PageLimits(Page_abs).XLimit:
0;var Coords=this.DrawingDocument.ConvertCoordsToCursorWR(_X,_Y,Page_abs,TextTransform);if(false===this.Selection.Use){var Changes=TrackManager.GetElementChanges(this.GetId());if(Changes.length>0)for(var ChangeIndex=0,ChangesCount=Changes.length;ChangeIndex<ChangesCount;ChangeIndex++){var Change=Changes[ChangeIndex];var Type=Change.get_Type();if(c_oAscRevisionsChangeType.TextAdd!==Type&&c_oAscRevisionsChangeType.TextRem!==Type&&c_oAscRevisionsChangeType.TextPr!==Type||StartPos.Compare(Change.get_StartPos())>=
0&&StartPos.Compare(Change.get_EndPos())<=0){Change.put_InternalPos(_X,_Y,Page_abs);TrackManager.AddVisibleChange(Change)}}}}};Paragraph.prototype.PreDelete=function(){for(var Index=0;Index<this.Content.length;Index++){var Item=this.Content[Index];if(Item.PreDelete)Item.PreDelete();if(this.LogicDocument)if(para_Comment===Item.Type&&true===this.LogicDocument.RemoveCommentsOnPreDelete)this.LogicDocument.RemoveComment(Item.CommentId,true,false);else if(para_Bookmark===Item.Type)this.LogicDocument.GetBookmarksManager().SetNeedUpdate(true)}this.RemoveSelection();
this.UpdateDocumentOutline();if(undefined!==this.Get_SectionPr()&&this.LogicDocument)this.Set_SectionPr(undefined)};Paragraph.prototype.Document_SetThisElementCurrent=function(bUpdateStates){this.Parent.Update_ContentIndexing();this.Parent.Set_CurrentElement(this.Index,bUpdateStates)};Paragraph.prototype.Is_ThisElementCurrent=function(){var Parent=this.Parent;Parent.Update_ContentIndexing();if(docpostype_Content===Parent.GetDocPosType()&&false===Parent.Selection.Use&&this.Index===Parent.CurPos.ContentPos&&
Parent.Content[this.Index]===this)return this.Parent.Is_ThisElementCurrent();return false};Paragraph.prototype.Is_Inline=function(){if(this.bFromDocument===false)return true;var PrevElement=this.Get_DocumentPrev();if(true===this.Is_Empty()&&undefined!==this.Get_SectionPr()&&null!==PrevElement&&(type_Paragraph!==PrevElement.Get_Type()||undefined===PrevElement.Get_SectionPr()))return true;if(undefined===this.Parent||!(this.Parent instanceof CDocument)&&(undefined===this.Parent.Parent||!(this.Parent.Parent instanceof
CHeaderFooter)))return true;if(undefined!=this.Pr.FramePr&&Asc.c_oAscYAlign.Inline!==this.Pr.FramePr.YAlign)return false;return true};Paragraph.prototype.IsInline=function(){return this.Is_Inline()};Paragraph.prototype.GetFramePr=function(){return this.Get_CompiledPr2(false).ParaPr.FramePr};Paragraph.prototype.Get_FramePr=function(){return this.GetFramePr()};Paragraph.prototype.Set_FramePr=function(FramePr,bDelete){var FramePr_old=this.Pr.FramePr;if(undefined===bDelete)bDelete=false;if(true===bDelete){this.Pr.FramePr=
undefined;this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,FramePr_old,undefined));this.CompiledPr.NeedRecalc=true;this.private_UpdateTrackRevisionOnChangeParaPr(true);return}var FrameParas=this.Internal_Get_FrameParagraphs();if(true===FramePr.FromDropCapMenu&&1===FrameParas.length){var NewFramePr=FramePr_old?FramePr_old.Copy():new CFramePr;if(undefined!=FramePr.DropCap){var OldLines=NewFramePr.Lines;NewFramePr.Init_Default_DropCap(FramePr.DropCap===Asc.c_oAscDropCap.Drop?
true:false);NewFramePr.Lines=OldLines}if(undefined!=FramePr.Lines){var AnchorPara=this.Get_FrameAnchorPara();if(null===AnchorPara||AnchorPara.Lines.length<=0)return;var Before=AnchorPara.Get_CompiledPr().ParaPr.Spacing.Before;var LineH=AnchorPara.Lines[0].Bottom-AnchorPara.Lines[0].Top-Before;var LineTA=AnchorPara.Lines[0].Metrics.TextAscent2;var LineTD=AnchorPara.Lines[0].Metrics.TextDescent+AnchorPara.Lines[0].Metrics.LineGap;this.Set_Spacing({LineRule:linerule_Exact,Line:FramePr.Lines*LineH},false);
this.Update_DropCapByLines(this.Internal_CalculateTextPr(this.Internal_GetStartPos()),FramePr.Lines,LineH,LineTA,LineTD,Before);NewFramePr.Lines=FramePr.Lines}if(undefined!=FramePr.FontFamily){var FF=new ParaTextPr({RFonts:{Ascii:{Name:FramePr.FontFamily.Name,Index:-1}}});this.SelectAll();this.Add(FF);this.RemoveSelection()}if(undefined!=FramePr.HSpace)NewFramePr.HSpace=FramePr.HSpace;this.Pr.FramePr=NewFramePr}else{var NewFramePr=FramePr_old?FramePr_old.Copy():new CFramePr;if(undefined!=FramePr.H)NewFramePr.H=
FramePr.H;if(undefined!=FramePr.HAnchor)NewFramePr.HAnchor=FramePr.HAnchor;if(undefined!=FramePr.HRule)NewFramePr.HRule=FramePr.HRule;if(undefined!=FramePr.HSpace)NewFramePr.HSpace=FramePr.HSpace;if(undefined!=FramePr.Lines)NewFramePr.Lines=FramePr.Lines;if(undefined!=FramePr.VAnchor)NewFramePr.VAnchor=FramePr.VAnchor;if(undefined!=FramePr.VSpace)NewFramePr.VSpace=FramePr.VSpace;NewFramePr.W=FramePr.W;if(undefined!=FramePr.X){NewFramePr.X=FramePr.X;NewFramePr.XAlign=undefined}if(undefined!=FramePr.XAlign){NewFramePr.XAlign=
FramePr.XAlign;NewFramePr.X=undefined}if(undefined!=FramePr.Y){NewFramePr.Y=FramePr.Y;NewFramePr.YAlign=undefined}if(undefined!=FramePr.YAlign){NewFramePr.YAlign=FramePr.YAlign;NewFramePr.Y=undefined}if(undefined!==FramePr.Wrap)if(false===FramePr.Wrap)NewFramePr.Wrap=wrap_NotBeside;else if(true===FramePr.Wrap)NewFramePr.Wrap=wrap_Around;else NewFramePr.Wrap=FramePr.Wrap;this.Pr.FramePr=NewFramePr}if(undefined!=FramePr.Brd){var Count=FrameParas.length;for(var Index=0;Index<Count;Index++)FrameParas[Index].Set_Borders(FramePr.Brd)}if(undefined!=
FramePr.Shd){var Count=FrameParas.length;for(var Index=0;Index<Count;Index++)FrameParas[Index].Set_Shd(FramePr.Shd)}this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,FramePr_old,this.Pr.FramePr));this.CompiledPr.NeedRecalc=true;this.private_UpdateTrackRevisionOnChangeParaPr(true)};Paragraph.prototype.Set_FramePr2=function(FramePr){this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,this.Pr.FramePr,FramePr));this.Pr.FramePr=FramePr;this.CompiledPr.NeedRecalc=
true;this.private_UpdateTrackRevisionOnChangeParaPr(true)};Paragraph.prototype.Set_FrameParaPr=function(Para){Para.CopyPr(this);Para.Set_Ind({FirstLine:0},false);this.Set_Spacing({After:0},false);this.Set_Ind({Right:0},false);this.RemoveNumPr()};Paragraph.prototype.Get_FrameBounds=function(FrameX,FrameY,FrameW,FrameH){var X0=FrameX,Y0=FrameY,X1=FrameX+FrameW,Y1=FrameY+FrameH;var Paras=this.Internal_Get_FrameParagraphs();var Count=Paras.length;var FramePr=this.Get_FramePr();if(0>=Count)return{X:X0,
Y:Y0,W:X1-X0,H:Y1-Y0};for(var Index=0;Index<Count;Index++){var Para=Paras[Index];var ParaPr=Para.Get_CompiledPr2(false).ParaPr;var Brd=ParaPr.Brd;var _X0=FrameX;if(undefined!==Brd.Left&&border_None!==Brd.Left.Value)_X0-=Brd.Left.Size+Brd.Left.Space+1;if(_X0<X0)X0=_X0;var _X1=FrameX+FrameW;if(undefined!==Brd.Right&&border_None!==Brd.Right.Value){_X1=Math.max(_X1,_X1-ParaPr.Ind.Right);_X1+=Brd.Right.Size+Brd.Right.Space+1}if(_X1>X1)X1=_X1}var _Y1=Y1;var BottomBorder=Paras[Count-1].Get_CompiledPr2(false).ParaPr.Brd.Bottom;
if(undefined!==BottomBorder&&border_None!==BottomBorder.Value)_Y1+=BottomBorder.Size+BottomBorder.Space;if(_Y1>Y1&&(Asc.linerule_Auto===FramePr.HRule||Asc.linerule_AtLeast===FramePr.HRule&&FrameH>=FramePr.H))Y1=_Y1;return{X:X0,Y:Y0,W:X1-X0,H:Y1-Y0}};Paragraph.prototype.SetCalculatedFrame=function(oFrame){this.CalculatedFrame=oFrame;oFrame.AddParagraph(this)};Paragraph.prototype.GetCalculatedFrame=function(){return this.CalculatedFrame};Paragraph.prototype.Internal_Get_FrameParagraphs=function(){if(this.CalculatedFrame&&
this.CalculatedFrame.GetParagraphs().length>0)return this.CalculatedFrame.GetParagraphs();var FrameParas=[];var FramePr=this.Get_FramePr();if(undefined===FramePr)return FrameParas;FrameParas.push(this);var Prev=this.Get_DocumentPrev();while(null!=Prev)if(type_Paragraph===Prev.GetType()){var PrevFramePr=Prev.Get_FramePr();if(undefined!=PrevFramePr&&true===FramePr.Compare(PrevFramePr)){FrameParas.push(Prev);Prev=Prev.Get_DocumentPrev()}else break}else break;var Next=this.Get_DocumentNext();while(null!=
Next)if(type_Paragraph===Next.GetType()){var NextFramePr=Next.Get_FramePr();if(undefined!=NextFramePr&&true===FramePr.Compare(NextFramePr)){FrameParas.push(Next);Next=Next.Get_DocumentNext()}else break}else break;return FrameParas};Paragraph.prototype.Is_LineDropCap=function(){var FrameParas=this.Internal_Get_FrameParagraphs();if(1!==FrameParas.length||1!==this.Lines.length)return false;return true};Paragraph.prototype.Get_LineDropCapWidth=function(){var W=this.Lines[0].Ranges[0].W;var ParaPr=this.Get_CompiledPr2(false).ParaPr;
W+=ParaPr.Ind.Left+ParaPr.Ind.FirstLine;return W};Paragraph.prototype.Change_Frame=function(X,Y,W,H,PageIndex){if(!this.LogicDocument||!this.CalculatedFrame||!this.CalculatedFrame.GetFramePr())return;var FramePr=this.CalculatedFrame.GetFramePr();if(Math.abs(Y-this.CalculatedFrame.T2)<.001&&Math.abs(X-this.CalculatedFrame.L2)<.001&&Math.abs(W-this.CalculatedFrame.W2)<.001&&Math.abs(H-this.CalculatedFrame.H2)<.001&&PageIndex===this.CalculatedFrame.PageIndex)return;var FrameParas=this.Internal_Get_FrameParagraphs();
if(false===this.LogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_None,{Type:AscCommon.changestype_2_ElementsArray_and_Type,Elements:FrameParas,CheckType:AscCommon.changestype_Paragraph_Content})){this.LogicDocument.StartAction(AscDFH.historydescription_Document_ParagraphChangeFrame);var NewFramePr=FramePr.Copy();if(Math.abs(X-this.CalculatedFrame.L2)>.001){NewFramePr.X=X+(this.CalculatedFrame.L-this.CalculatedFrame.L2);NewFramePr.XAlign=undefined;NewFramePr.HAnchor=Asc.c_oAscHAnchor.Page}if(Math.abs(Y-
this.CalculatedFrame.T2)>.001){NewFramePr.Y=Y+(this.CalculatedFrame.T-this.CalculatedFrame.T2);NewFramePr.YAlign=undefined;NewFramePr.VAnchor=Asc.c_oAscVAnchor.Page}if(Math.abs(W-this.CalculatedFrame.W2)>.001)NewFramePr.W=W-Math.abs(this.CalculatedFrame.W2-this.CalculatedFrame.W);if(Math.abs(H-this.CalculatedFrame.H2)>.001)if(undefined!=FramePr.DropCap&&Asc.c_oAscDropCap.None!=FramePr.DropCap&&1===FrameParas.length){var PageH=this.LogicDocument.Get_PageLimits(PageIndex).YLimit;var _H=Math.min(H,PageH);
NewFramePr.Lines=this.Update_DropCapByHeight(_H);NewFramePr.HRule=linerule_Exact;NewFramePr.H=H-Math.abs(this.CalculatedFrame.H2-this.CalculatedFrame.H)}else{if(H<=this.CalculatedFrame.H2)NewFramePr.HRule=linerule_Exact;else NewFramePr.HRule=Asc.linerule_AtLeast;NewFramePr.H=H}var Count=FrameParas.length;for(var Index=0;Index<Count;Index++){var Para=FrameParas[Index];Para.Set_FramePr(NewFramePr,false)}this.LogicDocument.Recalculate();this.LogicDocument.UpdateInterface();this.LogicDocument.UpdateRulers();
this.LogicDocument.UpdateTracks();this.LogicDocument.FinalizeAction()}};Paragraph.prototype.Supplement_FramePr=function(FramePr){if(undefined!=FramePr.DropCap&&Asc.c_oAscDropCap.None!=FramePr.DropCap){var _FramePr=this.Get_FramePr();var FirstFramePara=this;var Prev=FirstFramePara.Get_DocumentPrev();while(null!=Prev)if(type_Paragraph===Prev.GetType()){var PrevFramePr=Prev.Get_FramePr();if(undefined!=PrevFramePr&&true===_FramePr.Compare(PrevFramePr)){FirstFramePara=Prev;Prev=Prev.Get_DocumentPrev()}else break}else break;
var TextPr=FirstFramePara.GetFirstRunPr();if(undefined===TextPr.RFonts||undefined===TextPr.RFonts.Ascii)TextPr=this.Get_CompiledPr2(false).TextPr;FramePr.FontFamily={Name:TextPr.RFonts.Ascii.Name,Index:TextPr.RFonts.Ascii.Index}}var FrameParas=this.Internal_Get_FrameParagraphs();var Count=FrameParas.length;var ParaPr=FrameParas[0].Get_CompiledPr2(false).ParaPr.Copy();for(var Index=1;Index<Count;Index++){var TempPr=FrameParas[Index].Get_CompiledPr2(false).ParaPr;ParaPr=ParaPr.Compare(TempPr)}FramePr.Brd=
ParaPr.Brd;FramePr.Shd=ParaPr.Shd};Paragraph.prototype.CanAddDropCap=function(){for(var nPos=0,nCount=this.Content.length;nPos<nCount;++nPos){var bResult=this.Content[nPos].CanAddDropCap();if(null!==bResult)return bResult}return false};Paragraph.prototype.Get_TextForDropCap=function(DropCapText,UseContentPos,ContentPos,Depth){var EndPos=true===UseContentPos?ContentPos.Get(Depth):this.Content.length-1;for(var Pos=0;Pos<=EndPos;Pos++){this.Content[Pos].Get_TextForDropCap(DropCapText,true===UseContentPos&&
Pos===EndPos?true:false,ContentPos,Depth+1);if(true===DropCapText.Mixed&&(true===DropCapText.Check||DropCapText.Runs.length>0))return}};Paragraph.prototype.Split_DropCap=function(NewParagraph){var DropCapText=new CParagraphGetDropCapText;if(true==this.Selection.Use&&this.Parent.IsSelectedSingleElement()){var SelSP=this.Get_ParaContentPos(true,true);var SelEP=this.Get_ParaContentPos(true,false);if(0<=SelSP.Compare(SelEP))SelEP=SelSP;DropCapText.Check=true;this.Get_TextForDropCap(DropCapText,true,SelEP,
0);DropCapText.Check=false;this.Get_TextForDropCap(DropCapText,true,SelEP,0)}else{DropCapText.Mixed=true;DropCapText.Check=false;this.Get_TextForDropCap(DropCapText,false)}var Count=DropCapText.Text.length;var PrevRun=null;var CurrRun=null;for(var Pos=0,ParaPos=0,RunPos=0;Pos<Count;Pos++){if(PrevRun!==DropCapText.Runs[Pos]){PrevRun=DropCapText.Runs[Pos];CurrRun=new ParaRun(NewParagraph);CurrRun.Set_Pr(DropCapText.Runs[Pos].Pr.Copy());NewParagraph.Internal_Content_Add(ParaPos++,CurrRun,false);RunPos=
0}CurrRun.Add_ToContent(RunPos++,DropCapText.Text[Pos],false)}if(Count>0)return DropCapText.Runs[Count-1].Get_CompiledPr(true);return null};Paragraph.prototype.SelectFirstLetter=function(){var oStartPos=new CParagraphContentPos;var oEndPos=new CParagraphContentPos;for(var nPos=0,nCount=this.Content.length;nPos<nCount;++nPos){oStartPos.Update(nPos,0);oEndPos.Update(nPos,0);if(this.Content[nPos].GetFirstRunElementPos(para_Text,oStartPos,oEndPos,1)){this.StartSelectionFromCurPos();this.SetSelectionContentPos(oStartPos,
oEndPos,false);this.Document_SetThisElementCurrent();return true}}return false};Paragraph.prototype.CheckSelectionForDropCap=function(){var oSelectionStart=this.Get_ParaContentPos(true,true);var oSelectionEnd=this.Get_ParaContentPos(true,false);if(0<=oSelectionStart.Compare(oSelectionEnd))oSelectionEnd=oSelectionStart;var nEndPos=oSelectionEnd.Get(0);for(var nPos=0;nPos<=nEndPos;++nPos)if(!this.Content[nPos].CheckSelectionForDropCap(nPos===nEndPos,oSelectionEnd,1))return false;return true};Paragraph.prototype.Update_DropCapByLines=
function(TextPr,Count,LineH,LineTA,LineTD,Before){if(null===TextPr)return;this.Set_Spacing({Before:Before,After:0,LineRule:linerule_Exact,Line:Count*LineH-.001},false);var FontSize=72;TextPr.FontSize=FontSize;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TMetrics);var TDescent=TMetrics.Descent;var TAscent=TMetrics.Ascent;var THeight=0;if(null===TAscent||null===TDescent)THeight=
g_oTextMeasurer.GetHeight();else THeight=-TDescent+TAscent;var EmHeight=THeight;var NewEmHeight=(Count-1)*LineH+LineTA;var Koef=NewEmHeight/EmHeight;var NewFontSize=TextPr.FontSize*Koef;TextPr.FontSize=parseInt(NewFontSize*2)/2;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TNewMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TNewMetrics);var TNewDescent=TNewMetrics.Descent;var TNewAscent=TNewMetrics.Ascent;var TNewHeight=
0;if(null===TNewAscent||null===TNewDescent)TNewHeight=g_oTextMeasurer.GetHeight();else TNewHeight=-TNewDescent+TNewAscent;var Descent=g_oTextMeasurer.GetDescender();var Ascent=g_oTextMeasurer.GetAscender();var Dy=Descent*(LineH*Count)/(Ascent-Descent)+TNewHeight-TNewAscent+LineTD;var PTextPr=new ParaTextPr({RFonts:{Ascii:{Name:TextPr.RFonts.Ascii.Name,Index:-1}},FontSize:TextPr.FontSize,Position:Dy});this.SelectAll();this.Add(PTextPr);this.RemoveSelection()};Paragraph.prototype.Update_DropCapByHeight=
function(_Height){var AnchorPara=this.Get_FrameAnchorPara();if(null===AnchorPara||AnchorPara.Lines.length<=0)return 1;var Before=AnchorPara.Get_CompiledPr().ParaPr.Spacing.Before;var LineH=AnchorPara.Lines[0].Bottom-AnchorPara.Lines[0].Top-Before;var LineTA=AnchorPara.Lines[0].Metrics.TextAscent2;var LineTD=AnchorPara.Lines[0].Metrics.TextDescent+AnchorPara.Lines[0].Metrics.LineGap;var Height=_Height-Before;this.Set_Spacing({LineRule:linerule_Exact,Line:Height},false);var LinesCount=Math.ceil(Height/
LineH);var TextPr=this.Internal_CalculateTextPr(this.Internal_GetStartPos());g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TMetrics);var TDescent=TMetrics.Descent;var TAscent=TMetrics.Ascent;var THeight=0;if(null===TAscent||null===TDescent)THeight=g_oTextMeasurer.GetHeight();else THeight=-TDescent+TAscent;var Koef=(Height-LineTD)/THeight;var NewFontSize=TextPr.FontSize*Koef;
TextPr.FontSize=parseInt(NewFontSize*2)/2;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TNewMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TNewMetrics);var TNewDescent=TNewMetrics.Descent;var TNewAscent=TNewMetrics.Ascent;var TNewHeight=0;if(null===TNewAscent||null===TNewDescent)TNewHeight=g_oTextMeasurer.GetHeight();else TNewHeight=-TNewDescent+TNewAscent;var Descent=g_oTextMeasurer.GetDescender();var Ascent=g_oTextMeasurer.GetAscender();
var Dy=Descent*Height/(Ascent-Descent)+TNewHeight-TNewAscent+LineTD;var PTextPr=new ParaTextPr({RFonts:{Ascii:{Name:TextPr.RFonts.Ascii.Name,Index:-1}},FontSize:TextPr.FontSize,Position:Dy});this.SelectAll();this.Add(PTextPr);this.RemoveSelection();return LinesCount};Paragraph.prototype.Get_FrameAnchorPara=function(){var FramePr=this.Get_FramePr();if(undefined===FramePr)return null;var Next=this.Get_DocumentNext();while(null!=Next){if(type_Paragraph===Next.GetType()){var NextFramePr=Next.Get_FramePr();
if(undefined===NextFramePr||false===FramePr.Compare(NextFramePr))return Next}Next=Next.Get_DocumentNext()}return Next};Paragraph.prototype.Split=function(NewParagraph){if(!NewParagraph)NewParagraph=new Paragraph(this.DrawingDocument,this.Parent);NewParagraph.DeleteCommentOnRemove=false;this.DeleteCommentOnRemove=false;this.RemoveSelection();NewParagraph.RemoveSelection();var ContentPos=this.Get_ParaContentPos(false,false);var CurPos=ContentPos.Get(0);var TextPr=this.Get_TextPr(ContentPos);var oLogicDocument=
this.GetLogicDocument();var oStyles=oLogicDocument&&oLogicDocument.GetStyles?oLogicDocument.GetStyles():null;if(oStyles&&(TextPr.RStyle===oStyles.GetDefaultEndnoteReference()||TextPr.RStyle===oStyles.GetDefaultFootnoteReference())){TextPr=TextPr.Copy();TextPr.RStyle=undefined}var NewElement=this.Content[CurPos].Split(ContentPos,1);if(null===NewElement){NewElement=new ParaRun(NewParagraph);NewElement.Set_Pr(TextPr.Copy())}var NewContent=this.Content.slice(CurPos+1);this.Internal_Content_Remove2(CurPos+
1,this.Content.length-CurPos-1);var EndRun=new ParaRun(this);EndRun.Add_ToContent(0,new ParaEnd);this.Internal_Content_Add(this.Content.length,EndRun);NewParagraph.Internal_Content_Remove2(0,NewParagraph.Content.length);NewParagraph.Internal_Content_Concat(NewContent);NewParagraph.Internal_Content_Add(0,NewElement);NewParagraph.Correct_Content();this.CopyPr(NewParagraph);this.TextPr.Clear_Style();this.TextPr.Apply_TextPr(TextPr);var SectPr=this.Get_SectionPr();if(undefined!==SectPr){this.Set_SectionPr(undefined);
NewParagraph.Set_SectionPr(SectPr)}this.MoveCursorToEndPos(false,false);NewParagraph.MoveCursorToStartPos(false);NewParagraph.DeleteCommentOnRemove=true;this.DeleteCommentOnRemove=true;return NewParagraph};Paragraph.prototype.Concat=function(Para,isUseConcatedStyle){this.DeleteCommentOnRemove=false;Para.DeleteCommentOnRemove=false;this.Remove_ParaEnd();var NearPosCount=Para.NearPosArray.length;for(var Pos=0;Pos<NearPosCount;Pos++){var ParaNearPos=Para.NearPosArray[Pos];ParaNearPos.Classes[0]=this;
ParaNearPos.NearPos.Paragraph=this;ParaNearPos.NearPos.ContentPos.Data[0]+=this.Content.length;this.NearPosArray.push(ParaNearPos)}this.Internal_Content_Concat(Para.Content);Para.ClearContent();this.Set_SectionPr(undefined);var SectPr=Para.Get_SectionPr();if(undefined!==SectPr){Para.Set_SectionPr(undefined);this.Set_SectionPr(SectPr)}this.DeleteCommentOnRemove=true;Para.DeleteCommentOnRemove=true;if(true===isUseConcatedStyle)Para.CopyPr(this)};Paragraph.prototype.ConcatBefore=function(oPara){this.DeleteCommentOnRemove=
false;oPara.DeleteCommentOnRemove=false;oPara.Remove_ParaEnd();for(var nPos=0,nCount=this.NearPosArray.length;nPos<nCount;++nPos){var oParaNearPos=this.NearPosArray[nPos];oParaNearPos.NearPos.ContentPos.Data[0]+=oPara.Content.length}for(var nPos=0,nCount=oPara.NearPosArray.length;nPos<nCount;++nPos){var oParaNearPos=oPara.NearPosArray[nPos];oParaNearPos.Classes[0]=this;oParaNearPos.NearPos.Paragraph=this;this.NearPosArray.push(oParaNearPos)}for(var nPos=0,nCount=oPara.Content.length;nPos<nCount;++nPos)this.AddToContent(nPos,
oPara.Content[nPos]);oPara.ClearContent();oPara.Set_SectionPr(undefined);this.DeleteCommentOnRemove=true;oPara.DeleteCommentOnRemove=true;oPara.CopyPr(this)};Paragraph.prototype.Continue=function(NewParagraph){var TextPr;if(this.IsEmpty())TextPr=this.TextPr.Value.Copy();else{var EndPos=this.Get_EndPos2(false);var CurPos=this.Get_ParaContentPos(false,false);this.Set_ParaContentPos(EndPos,true,-1,-1);TextPr=this.Get_TextPr(this.Get_ParaContentPos(false,false)).Copy();this.Set_ParaContentPos(CurPos,
false,-1,-1,false);TextPr.HighLight=highlight_None;var oStyles;if(this.bFromDocument&&this.LogicDocument&&(oStyles=this.LogicDocument.GetStyles())&&(TextPr.RStyle===oStyles.GetDefaultFootnoteReference()||TextPr.RStyle===oStyles.GetDefaultEndnoteReference()))TextPr.RStyle=undefined}this.CopyPr(NewParagraph);if(!this.HaveNumbering()&&!this.Lock.Is_Locked()){this.TextPr.Clear_Style();this.TextPr.Apply_TextPr(TextPr)}NewParagraph.Internal_Content_Add(0,new ParaRun(NewParagraph));NewParagraph.Correct_Content();
NewParagraph.MoveCursorToStartPos(false);for(var Pos=0,Count=NewParagraph.Content.length;Pos<Count;Pos++)if(para_Run===NewParagraph.Content[Pos].Type)NewParagraph.Content[Pos].Set_Pr(TextPr.Copy())};Paragraph.prototype.GetSelectionState=function(){var ParaState={};ParaState.CurPos={X:this.CurPos.X,Y:this.CurPos.Y,Line:this.CurPos.Line,ContentPos:this.Get_ParaContentPos(false,false),RealX:this.CurPos.RealX,RealY:this.CurPos.RealY,PagesPos:this.CurPos.PagesPos};ParaState.Selection={Start:this.Selection.Start,
Use:this.Selection.Use,StartPos:0,EndPos:0,Flag:this.Selection.Flag};if(true===this.Selection.Use){ParaState.Selection.StartPos=this.Get_ParaContentPos(true,true);ParaState.Selection.EndPos=this.Get_ParaContentPos(true,false)}return[ParaState]};Paragraph.prototype.SetSelectionState=function(State,StateIndex){if(State.length<=0)return;var ParaState=State[StateIndex];this.CurPos.X=ParaState.CurPos.X;this.CurPos.Y=ParaState.CurPos.Y;this.CurPos.Line=ParaState.CurPos.Line;this.CurPos.RealX=ParaState.CurPos.RealX;
this.CurPos.RealY=ParaState.CurPos.RealY;this.CurPos.PagesPos=ParaState.CurPos.PagesPos;this.Set_ParaContentPos(ParaState.CurPos.ContentPos,true,-1,-1);this.RemoveSelection();this.Selection.Start=ParaState.Selection.Start;this.Selection.Use=ParaState.Selection.Use;this.Selection.Flag=ParaState.Selection.Flag;if(true===this.Selection.Use)this.Set_SelectionContentPos(ParaState.Selection.StartPos,ParaState.Selection.EndPos)};Paragraph.prototype.Get_ParentObject_or_DocumentPos=function(){this.Parent.Update_ContentIndexing();
return this.Parent.Get_ParentObject_or_DocumentPos(this.Index)};Paragraph.prototype.Refresh_RecalcData=function(Data){var Type=Data.Type;var bNeedRecalc=false;var CurPage=0;switch(Type){case AscDFH.historyitem_Paragraph_AddItem:case AscDFH.historyitem_Paragraph_RemoveItem:{for(CurPage=this.Pages.length-1;CurPage>0;CurPage--)if(Data.Pos>this.Lines[this.Pages[CurPage].StartLine].Get_StartPos())break;this.RecalcInfo.Set_Type_0(pararecalc_0_All);bNeedRecalc=true;break}case AscDFH.historyitem_Paragraph_Numbering:case AscDFH.historyitem_Paragraph_PStyle:case AscDFH.historyitem_Paragraph_Pr:case AscDFH.historyitem_Paragraph_PresentationPr_Bullet:case AscDFH.historyitem_Paragraph_PresentationPr_Level:{this.RecalcInfo.Set_Type_0(pararecalc_0_All);
bNeedRecalc=true;this.CompiledPr.NeedRecalc=true;this.Recalc_RunsCompiledPr();break}case AscDFH.historyitem_Paragraph_Align:case AscDFH.historyitem_Paragraph_DefaultTabSize:case AscDFH.historyitem_Paragraph_Ind_First:case AscDFH.historyitem_Paragraph_Ind_Left:case AscDFH.historyitem_Paragraph_Ind_Right:case AscDFH.historyitem_Paragraph_ContextualSpacing:case AscDFH.historyitem_Paragraph_KeepLines:case AscDFH.historyitem_Paragraph_KeepNext:case AscDFH.historyitem_Paragraph_PageBreakBefore:case AscDFH.historyitem_Paragraph_Spacing_Line:case AscDFH.historyitem_Paragraph_Spacing_LineRule:case AscDFH.historyitem_Paragraph_Spacing_Before:case AscDFH.historyitem_Paragraph_Spacing_After:case AscDFH.historyitem_Paragraph_Spacing_AfterAutoSpacing:case AscDFH.historyitem_Paragraph_Spacing_BeforeAutoSpacing:case AscDFH.historyitem_Paragraph_WidowControl:case AscDFH.historyitem_Paragraph_Tabs:case AscDFH.historyitem_Paragraph_Borders_Between:case AscDFH.historyitem_Paragraph_Borders_Bottom:case AscDFH.historyitem_Paragraph_Borders_Left:case AscDFH.historyitem_Paragraph_Borders_Right:case AscDFH.historyitem_Paragraph_Borders_Top:case AscDFH.historyitem_Paragraph_FramePr:{bNeedRecalc=
Paragraph.prototype.Document_CreateFontCharMap=function(FontCharMap){};Paragraph.prototype.Document_Get_AllFontNames=function(AllFonts){this.TextPr.Value.Document_Get_AllFontNames(AllFonts);if(this.Pr.Bullet)this.Pr.Bullet.Get_AllFontNames(AllFonts);if(this.Pr.DefaultRunPr)this.Pr.DefaultRunPr.Document_Get_AllFontNames(AllFonts);var Count=this.Content.length;for(var Index=0;Index<Count;Index++)if(this.Content[Index]&&typeof this.Content[Index].Get_AllFontNames==="function")this.Content[Index].Get_AllFontNames(AllFonts)};
Paragraph.prototype.Document_UpdateRulersState=function(){if(this.CalculatedFrame){var oFrame=this.CalculatedFrame;this.Parent.DrawingDocument.Set_RulerState_Paragraph({L:oFrame.L2,T:oFrame.T2,R:oFrame.L2+oFrame.W2,B:oFrame.T2+oFrame.H2,PageIndex:this.GetStartPageAbsolute(),Frame:this},false)}else if(this.Parent instanceof CDocument)if(this.LogicDocument)this.LogicDocument.Document_UpdateRulersStateBySection()};Paragraph.prototype.Document_UpdateInterfaceState=function(){var StartPos,EndPos;if(true===
this.Selection.Use){StartPos=this.Get_ParaContentPos(true,true);EndPos=this.Get_ParaContentPos(true,false)}else{var CurPos=this.Get_ParaContentPos(false,false);StartPos=CurPos;EndPos=CurPos}if(this.LogicDocument&&true===this.LogicDocument.Spelling.Use&&(selectionflag_Numbering!==this.Selection.Flag&&selectionflag_NumberingCur!==this.Selection.Flag))this.SpellChecker.Document_UpdateInterfaceState(StartPos,EndPos);if(true===this.Selection.Use){var StartPos=this.Selection.StartPos;var EndPos=this.Selection.EndPos;
if(StartPos>EndPos){StartPos=this.Selection.EndPos;EndPos=this.Selection.StartPos}for(var CurPos=StartPos;CurPos<=EndPos;CurPos++){var Element=this.Content[CurPos];if(true!==Element.IsSelectionEmpty()&&Element.Document_UpdateInterfaceState)Element.Document_UpdateInterfaceState()}}else{var CurType=this.Content[this.CurPos.ContentPos].Type;if(this.Content[this.CurPos.ContentPos].Document_UpdateInterfaceState)this.Content[this.CurPos.ContentPos].Document_UpdateInterfaceState()}var arrComplexFields=this.GetCurrentComplexFields();
for(var nIndex=0,nCount=arrComplexFields.length;nIndex<nCount;++nIndex){var oInstruction=arrComplexFields[nIndex].GetInstruction();if(oInstruction&&fieldtype_HYPERLINK===oInstruction.GetType()){var oHyperProps=new Asc.CHyperlinkProperty;oHyperProps.put_ToolTip(oInstruction.GetToolTip());oHyperProps.put_Value(oInstruction.GetValue());oHyperProps.put_Text(this.LogicDocument?this.LogicDocument.GetComplexFieldTextValue(arrComplexFields[nIndex]):null);oHyperProps.put_InternalHyperlink(oInstruction);editor.sync_HyperlinkPropCallback(oHyperProps)}}if(editor&&
this.bFromDocument){if(!this.LogicDocument)return;var TrackManager=this.LogicDocument.GetTrackRevisionsManager();if(this.Pages.length<=0&&this.Lines.length<=0)return;var ContentPos=this.Get_ParaContentPos(this.Selection.Use,true);var ParaPos=this.Get_ParaPosByContentPos(ContentPos);if(this.Pages.length<=ParaPos.Page||this.Lines.length<=ParaPos.Line)return;var Page_abs=this.Get_AbsolutePage(ParaPos.Page);var _Y=this.Pages[ParaPos.Page].Y+this.Lines[ParaPos.Line].Top;var TextTransform=this.Get_ParentTextTransform();
var _X=this.LogicDocument?this.LogicDocument.Get_PageLimits(Page_abs).XLimit:0;var Coords=this.DrawingDocument.ConvertCoordsToCursorWR(_X,_Y,Page_abs,TextTransform);if(false===this.Selection.Use){var Changes=TrackManager.GetElementChanges(this.GetId());if(Changes.length>0)for(var ChangeIndex=0,ChangesCount=Changes.length;ChangeIndex<ChangesCount;ChangeIndex++){var Change=Changes[ChangeIndex];var Type=Change.get_Type();if(c_oAscRevisionsChangeType.TextAdd!==Type&&c_oAscRevisionsChangeType.TextRem!==
Type&&c_oAscRevisionsChangeType.TextPr!==Type||StartPos.Compare(Change.get_StartPos())>=0&&StartPos.Compare(Change.get_EndPos())<=0){Change.put_InternalPos(_X,_Y,Page_abs);TrackManager.AddVisibleChange(Change)}}}}};Paragraph.prototype.PreDelete=function(){for(var Index=0;Index<this.Content.length;Index++){var Item=this.Content[Index];if(Item.PreDelete)Item.PreDelete();if(this.LogicDocument)if(para_Comment===Item.Type&&true===this.LogicDocument.RemoveCommentsOnPreDelete)this.LogicDocument.RemoveComment(Item.CommentId,
true,false);else if(para_Bookmark===Item.Type)this.LogicDocument.GetBookmarksManager().SetNeedUpdate(true)}this.RemoveSelection();this.UpdateDocumentOutline();if(undefined!==this.Get_SectionPr()&&this.LogicDocument)this.Set_SectionPr(undefined)};Paragraph.prototype.Document_SetThisElementCurrent=function(bUpdateStates){this.Parent.Update_ContentIndexing();this.Parent.Set_CurrentElement(this.Index,bUpdateStates)};Paragraph.prototype.Is_ThisElementCurrent=function(){var Parent=this.Parent;Parent.Update_ContentIndexing();
if(docpostype_Content===Parent.GetDocPosType()&&false===Parent.Selection.Use&&this.Index===Parent.CurPos.ContentPos&&Parent.Content[this.Index]===this)return this.Parent.Is_ThisElementCurrent();return false};Paragraph.prototype.Is_Inline=function(){if(this.bFromDocument===false)return true;var PrevElement=this.Get_DocumentPrev();if(true===this.Is_Empty()&&undefined!==this.Get_SectionPr()&&null!==PrevElement&&(type_Paragraph!==PrevElement.Get_Type()||undefined===PrevElement.Get_SectionPr()))return true;
if(undefined===this.Parent||!(this.Parent instanceof CDocument)&&(undefined===this.Parent.Parent||!(this.Parent.Parent instanceof CHeaderFooter)))return true;if(undefined!=this.Pr.FramePr&&Asc.c_oAscYAlign.Inline!==this.Pr.FramePr.YAlign)return false;return true};Paragraph.prototype.IsInline=function(){return this.Is_Inline()};Paragraph.prototype.GetFramePr=function(){return this.Get_CompiledPr2(false).ParaPr.FramePr};Paragraph.prototype.Get_FramePr=function(){return this.GetFramePr()};Paragraph.prototype.Set_FramePr=
function(FramePr,bDelete){var FramePr_old=this.Pr.FramePr;if(undefined===bDelete)bDelete=false;if(true===bDelete){this.Pr.FramePr=undefined;this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,FramePr_old,undefined));this.CompiledPr.NeedRecalc=true;this.private_UpdateTrackRevisionOnChangeParaPr(true);return}var FrameParas=this.Internal_Get_FrameParagraphs();if(true===FramePr.FromDropCapMenu&&1===FrameParas.length){var NewFramePr=FramePr_old?FramePr_old.Copy():new CFramePr;if(undefined!=
FramePr.DropCap){var OldLines=NewFramePr.Lines;NewFramePr.Init_Default_DropCap(FramePr.DropCap===Asc.c_oAscDropCap.Drop?true:false);NewFramePr.Lines=OldLines}if(undefined!=FramePr.Lines){var AnchorPara=this.Get_FrameAnchorPara();if(null===AnchorPara||AnchorPara.Lines.length<=0)return;var Before=AnchorPara.Get_CompiledPr().ParaPr.Spacing.Before;var LineH=AnchorPara.Lines[0].Bottom-AnchorPara.Lines[0].Top-Before;var LineTA=AnchorPara.Lines[0].Metrics.TextAscent2;var LineTD=AnchorPara.Lines[0].Metrics.TextDescent+
AnchorPara.Lines[0].Metrics.LineGap;this.Set_Spacing({LineRule:linerule_Exact,Line:FramePr.Lines*LineH},false);this.Update_DropCapByLines(this.Internal_CalculateTextPr(this.Internal_GetStartPos()),FramePr.Lines,LineH,LineTA,LineTD,Before);NewFramePr.Lines=FramePr.Lines}if(undefined!=FramePr.FontFamily){var FF=new ParaTextPr({RFonts:{Ascii:{Name:FramePr.FontFamily.Name,Index:-1}}});this.SelectAll();this.Add(FF);this.RemoveSelection()}if(undefined!=FramePr.HSpace)NewFramePr.HSpace=FramePr.HSpace;this.Pr.FramePr=
NewFramePr}else{var NewFramePr=FramePr_old?FramePr_old.Copy():new CFramePr;if(undefined!=FramePr.H)NewFramePr.H=FramePr.H;if(undefined!=FramePr.HAnchor)NewFramePr.HAnchor=FramePr.HAnchor;if(undefined!=FramePr.HRule)NewFramePr.HRule=FramePr.HRule;if(undefined!=FramePr.HSpace)NewFramePr.HSpace=FramePr.HSpace;if(undefined!=FramePr.Lines)NewFramePr.Lines=FramePr.Lines;if(undefined!=FramePr.VAnchor)NewFramePr.VAnchor=FramePr.VAnchor;if(undefined!=FramePr.VSpace)NewFramePr.VSpace=FramePr.VSpace;NewFramePr.W=
FramePr.W;if(undefined!=FramePr.X){NewFramePr.X=FramePr.X;NewFramePr.XAlign=undefined}if(undefined!=FramePr.XAlign){NewFramePr.XAlign=FramePr.XAlign;NewFramePr.X=undefined}if(undefined!=FramePr.Y){NewFramePr.Y=FramePr.Y;NewFramePr.YAlign=undefined}if(undefined!=FramePr.YAlign){NewFramePr.YAlign=FramePr.YAlign;NewFramePr.Y=undefined}if(undefined!==FramePr.Wrap)if(false===FramePr.Wrap)NewFramePr.Wrap=wrap_NotBeside;else if(true===FramePr.Wrap)NewFramePr.Wrap=wrap_Around;else NewFramePr.Wrap=FramePr.Wrap;
this.Pr.FramePr=NewFramePr}if(undefined!=FramePr.Brd){var Count=FrameParas.length;for(var Index=0;Index<Count;Index++)FrameParas[Index].Set_Borders(FramePr.Brd)}if(undefined!=FramePr.Shd){var Count=FrameParas.length;for(var Index=0;Index<Count;Index++)FrameParas[Index].Set_Shd(FramePr.Shd)}this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,FramePr_old,this.Pr.FramePr));this.CompiledPr.NeedRecalc=true;this.private_UpdateTrackRevisionOnChangeParaPr(true)};Paragraph.prototype.Set_FramePr2=
function(FramePr){this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,this.Pr.FramePr,FramePr));this.Pr.FramePr=FramePr;this.CompiledPr.NeedRecalc=true;this.private_UpdateTrackRevisionOnChangeParaPr(true)};Paragraph.prototype.Set_FrameParaPr=function(Para){Para.CopyPr(this);Para.Set_Ind({FirstLine:0},false);this.Set_Spacing({After:0},false);this.Set_Ind({Right:0},false);this.RemoveNumPr()};Paragraph.prototype.Get_FrameBounds=function(FrameX,FrameY,FrameW,FrameH){var X0=FrameX,
Y0=FrameY,X1=FrameX+FrameW,Y1=FrameY+FrameH;var Paras=this.Internal_Get_FrameParagraphs();var Count=Paras.length;var FramePr=this.Get_FramePr();if(0>=Count)return{X:X0,Y:Y0,W:X1-X0,H:Y1-Y0};for(var Index=0;Index<Count;Index++){var Para=Paras[Index];var ParaPr=Para.Get_CompiledPr2(false).ParaPr;var Brd=ParaPr.Brd;var _X0=FrameX;if(undefined!==Brd.Left&&border_None!==Brd.Left.Value)_X0-=Brd.Left.Size+Brd.Left.Space+1;if(_X0<X0)X0=_X0;var _X1=FrameX+FrameW;if(undefined!==Brd.Right&&border_None!==Brd.Right.Value){_X1=
Math.max(_X1,_X1-ParaPr.Ind.Right);_X1+=Brd.Right.Size+Brd.Right.Space+1}if(_X1>X1)X1=_X1}var _Y1=Y1;var BottomBorder=Paras[Count-1].Get_CompiledPr2(false).ParaPr.Brd.Bottom;if(undefined!==BottomBorder&&border_None!==BottomBorder.Value)_Y1+=BottomBorder.Size+BottomBorder.Space;if(_Y1>Y1&&(Asc.linerule_Auto===FramePr.HRule||Asc.linerule_AtLeast===FramePr.HRule&&FrameH>=FramePr.H))Y1=_Y1;return{X:X0,Y:Y0,W:X1-X0,H:Y1-Y0}};Paragraph.prototype.SetCalculatedFrame=function(oFrame){this.CalculatedFrame=
oFrame;oFrame.AddParagraph(this)};Paragraph.prototype.GetCalculatedFrame=function(){return this.CalculatedFrame};Paragraph.prototype.Internal_Get_FrameParagraphs=function(){if(this.CalculatedFrame&&this.CalculatedFrame.GetParagraphs().length>0)return this.CalculatedFrame.GetParagraphs();var FrameParas=[];var FramePr=this.Get_FramePr();if(undefined===FramePr)return FrameParas;FrameParas.push(this);var Prev=this.Get_DocumentPrev();while(null!=Prev)if(type_Paragraph===Prev.GetType()){var PrevFramePr=
Prev.Get_FramePr();if(undefined!=PrevFramePr&&true===FramePr.Compare(PrevFramePr)){FrameParas.push(Prev);Prev=Prev.Get_DocumentPrev()}else break}else break;var Next=this.Get_DocumentNext();while(null!=Next)if(type_Paragraph===Next.GetType()){var NextFramePr=Next.Get_FramePr();if(undefined!=NextFramePr&&true===FramePr.Compare(NextFramePr)){FrameParas.push(Next);Next=Next.Get_DocumentNext()}else break}else break;return FrameParas};Paragraph.prototype.Is_LineDropCap=function(){var FrameParas=this.Internal_Get_FrameParagraphs();
if(1!==FrameParas.length||1!==this.Lines.length)return false;return true};Paragraph.prototype.Get_LineDropCapWidth=function(){var W=this.Lines[0].Ranges[0].W;var ParaPr=this.Get_CompiledPr2(false).ParaPr;W+=ParaPr.Ind.Left+ParaPr.Ind.FirstLine;return W};Paragraph.prototype.Change_Frame=function(X,Y,W,H,PageIndex){if(!this.LogicDocument||!this.CalculatedFrame||!this.CalculatedFrame.GetFramePr())return;var FramePr=this.CalculatedFrame.GetFramePr();if(Math.abs(Y-this.CalculatedFrame.T2)<.001&&Math.abs(X-
this.CalculatedFrame.L2)<.001&&Math.abs(W-this.CalculatedFrame.W2)<.001&&Math.abs(H-this.CalculatedFrame.H2)<.001&&PageIndex===this.CalculatedFrame.PageIndex)return;var FrameParas=this.Internal_Get_FrameParagraphs();if(false===this.LogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_None,{Type:AscCommon.changestype_2_ElementsArray_and_Type,Elements:FrameParas,CheckType:AscCommon.changestype_Paragraph_Content})){this.LogicDocument.StartAction(AscDFH.historydescription_Document_ParagraphChangeFrame);
var NewFramePr=FramePr.Copy();if(Math.abs(X-this.CalculatedFrame.L2)>.001){NewFramePr.X=X+(this.CalculatedFrame.L-this.CalculatedFrame.L2);NewFramePr.XAlign=undefined;NewFramePr.HAnchor=Asc.c_oAscHAnchor.Page}if(Math.abs(Y-this.CalculatedFrame.T2)>.001){NewFramePr.Y=Y+(this.CalculatedFrame.T-this.CalculatedFrame.T2);NewFramePr.YAlign=undefined;NewFramePr.VAnchor=Asc.c_oAscVAnchor.Page}if(Math.abs(W-this.CalculatedFrame.W2)>.001)NewFramePr.W=W-Math.abs(this.CalculatedFrame.W2-this.CalculatedFrame.W);
if(Math.abs(H-this.CalculatedFrame.H2)>.001)if(undefined!=FramePr.DropCap&&Asc.c_oAscDropCap.None!=FramePr.DropCap&&1===FrameParas.length){var PageH=this.LogicDocument.Get_PageLimits(PageIndex).YLimit;var _H=Math.min(H,PageH);NewFramePr.Lines=this.Update_DropCapByHeight(_H);NewFramePr.HRule=linerule_Exact;NewFramePr.H=H-Math.abs(this.CalculatedFrame.H2-this.CalculatedFrame.H)}else{if(H<=this.CalculatedFrame.H2)NewFramePr.HRule=linerule_Exact;else NewFramePr.HRule=Asc.linerule_AtLeast;NewFramePr.H=
H}var Count=FrameParas.length;for(var Index=0;Index<Count;Index++){var Para=FrameParas[Index];Para.Set_FramePr(NewFramePr,false)}this.LogicDocument.Recalculate();this.LogicDocument.UpdateInterface();this.LogicDocument.UpdateRulers();this.LogicDocument.UpdateTracks();this.LogicDocument.FinalizeAction()}};Paragraph.prototype.Supplement_FramePr=function(FramePr){if(undefined!=FramePr.DropCap&&Asc.c_oAscDropCap.None!=FramePr.DropCap){var _FramePr=this.Get_FramePr();var FirstFramePara=this;var Prev=FirstFramePara.Get_DocumentPrev();
while(null!=Prev)if(type_Paragraph===Prev.GetType()){var PrevFramePr=Prev.Get_FramePr();if(undefined!=PrevFramePr&&true===_FramePr.Compare(PrevFramePr)){FirstFramePara=Prev;Prev=Prev.Get_DocumentPrev()}else break}else break;var TextPr=FirstFramePara.GetFirstRunPr();if(undefined===TextPr.RFonts||undefined===TextPr.RFonts.Ascii)TextPr=this.Get_CompiledPr2(false).TextPr;FramePr.FontFamily={Name:TextPr.RFonts.Ascii.Name,Index:TextPr.RFonts.Ascii.Index}}var FrameParas=this.Internal_Get_FrameParagraphs();
var Count=FrameParas.length;var ParaPr=FrameParas[0].Get_CompiledPr2(false).ParaPr.Copy();for(var Index=1;Index<Count;Index++){var TempPr=FrameParas[Index].Get_CompiledPr2(false).ParaPr;ParaPr=ParaPr.Compare(TempPr)}FramePr.Brd=ParaPr.Brd;FramePr.Shd=ParaPr.Shd};Paragraph.prototype.CanAddDropCap=function(){for(var nPos=0,nCount=this.Content.length;nPos<nCount;++nPos){var bResult=this.Content[nPos].CanAddDropCap();if(null!==bResult)return bResult}return false};Paragraph.prototype.Get_TextForDropCap=
function(DropCapText,UseContentPos,ContentPos,Depth){var EndPos=true===UseContentPos?ContentPos.Get(Depth):this.Content.length-1;for(var Pos=0;Pos<=EndPos;Pos++){this.Content[Pos].Get_TextForDropCap(DropCapText,true===UseContentPos&&Pos===EndPos?true:false,ContentPos,Depth+1);if(true===DropCapText.Mixed&&(true===DropCapText.Check||DropCapText.Runs.length>0))return}};Paragraph.prototype.Split_DropCap=function(NewParagraph){var DropCapText=new CParagraphGetDropCapText;if(true==this.Selection.Use&&this.Parent.IsSelectedSingleElement()){var SelSP=
this.Get_ParaContentPos(true,true);var SelEP=this.Get_ParaContentPos(true,false);if(0<=SelSP.Compare(SelEP))SelEP=SelSP;DropCapText.Check=true;this.Get_TextForDropCap(DropCapText,true,SelEP,0);DropCapText.Check=false;this.Get_TextForDropCap(DropCapText,true,SelEP,0)}else{DropCapText.Mixed=true;DropCapText.Check=false;this.Get_TextForDropCap(DropCapText,false)}var Count=DropCapText.Text.length;var PrevRun=null;var CurrRun=null;for(var Pos=0,ParaPos=0,RunPos=0;Pos<Count;Pos++){if(PrevRun!==DropCapText.Runs[Pos]){PrevRun=
DropCapText.Runs[Pos];CurrRun=new ParaRun(NewParagraph);CurrRun.Set_Pr(DropCapText.Runs[Pos].Pr.Copy());NewParagraph.Internal_Content_Add(ParaPos++,CurrRun,false);RunPos=0}CurrRun.Add_ToContent(RunPos++,DropCapText.Text[Pos],false)}if(Count>0)return DropCapText.Runs[Count-1].Get_CompiledPr(true);return null};Paragraph.prototype.SelectFirstLetter=function(){var oStartPos=new CParagraphContentPos;var oEndPos=new CParagraphContentPos;for(var nPos=0,nCount=this.Content.length;nPos<nCount;++nPos){oStartPos.Update(nPos,
0);oEndPos.Update(nPos,0);if(this.Content[nPos].GetFirstRunElementPos(para_Text,oStartPos,oEndPos,1)){this.StartSelectionFromCurPos();this.SetSelectionContentPos(oStartPos,oEndPos,false);this.Document_SetThisElementCurrent();return true}}return false};Paragraph.prototype.CheckSelectionForDropCap=function(){var oSelectionStart=this.Get_ParaContentPos(true,true);var oSelectionEnd=this.Get_ParaContentPos(true,false);if(0<=oSelectionStart.Compare(oSelectionEnd))oSelectionEnd=oSelectionStart;var nEndPos=
oSelectionEnd.Get(0);for(var nPos=0;nPos<=nEndPos;++nPos)if(!this.Content[nPos].CheckSelectionForDropCap(nPos===nEndPos,oSelectionEnd,1))return false;return true};Paragraph.prototype.Update_DropCapByLines=function(TextPr,Count,LineH,LineTA,LineTD,Before){if(null===TextPr)return;this.Set_Spacing({Before:Before,After:0,LineRule:linerule_Exact,Line:Count*LineH-.001},false);var FontSize=72;TextPr.FontSize=FontSize;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,
1);var TMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TMetrics);var TDescent=TMetrics.Descent;var TAscent=TMetrics.Ascent;var THeight=0;if(null===TAscent||null===TDescent)THeight=g_oTextMeasurer.GetHeight();else THeight=-TDescent+TAscent;var EmHeight=THeight;var NewEmHeight=(Count-1)*LineH+LineTA;var Koef=NewEmHeight/EmHeight;var NewFontSize=TextPr.FontSize*Koef;TextPr.FontSize=parseInt(NewFontSize*2)/2;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,
1);var TNewMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TNewMetrics);var TNewDescent=TNewMetrics.Descent;var TNewAscent=TNewMetrics.Ascent;var TNewHeight=0;if(null===TNewAscent||null===TNewDescent)TNewHeight=g_oTextMeasurer.GetHeight();else TNewHeight=-TNewDescent+TNewAscent;var Descent=g_oTextMeasurer.GetDescender();var Ascent=g_oTextMeasurer.GetAscender();var Dy=Descent*(LineH*Count)/(Ascent-Descent)+TNewHeight-TNewAscent+LineTD;var PTextPr=new ParaTextPr({RFonts:{Ascii:{Name:TextPr.RFonts.Ascii.Name,
Index:-1}},FontSize:TextPr.FontSize,Position:Dy});this.SelectAll();this.Add(PTextPr);this.RemoveSelection()};Paragraph.prototype.Update_DropCapByHeight=function(_Height){var AnchorPara=this.Get_FrameAnchorPara();if(null===AnchorPara||AnchorPara.Lines.length<=0)return 1;var Before=AnchorPara.Get_CompiledPr().ParaPr.Spacing.Before;var LineH=AnchorPara.Lines[0].Bottom-AnchorPara.Lines[0].Top-Before;var LineTA=AnchorPara.Lines[0].Metrics.TextAscent2;var LineTD=AnchorPara.Lines[0].Metrics.TextDescent+
AnchorPara.Lines[0].Metrics.LineGap;var Height=_Height-Before;this.Set_Spacing({LineRule:linerule_Exact,Line:Height},false);var LinesCount=Math.ceil(Height/LineH);var TextPr=this.Internal_CalculateTextPr(this.Internal_GetStartPos());g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TMetrics);var TDescent=TMetrics.Descent;var TAscent=TMetrics.Ascent;var THeight=0;if(null===TAscent||
null===TDescent)THeight=g_oTextMeasurer.GetHeight();else THeight=-TDescent+TAscent;var Koef=(Height-LineTD)/THeight;var NewFontSize=TextPr.FontSize*Koef;TextPr.FontSize=parseInt(NewFontSize*2)/2;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TNewMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TNewMetrics);var TNewDescent=TNewMetrics.Descent;var TNewAscent=TNewMetrics.Ascent;var TNewHeight=0;if(null===TNewAscent||null===TNewDescent)TNewHeight=
g_oTextMeasurer.GetHeight();else TNewHeight=-TNewDescent+TNewAscent;var Descent=g_oTextMeasurer.GetDescender();var Ascent=g_oTextMeasurer.GetAscender();var Dy=Descent*Height/(Ascent-Descent)+TNewHeight-TNewAscent+LineTD;var PTextPr=new ParaTextPr({RFonts:{Ascii:{Name:TextPr.RFonts.Ascii.Name,Index:-1}},FontSize:TextPr.FontSize,Position:Dy});this.SelectAll();this.Add(PTextPr);this.RemoveSelection();return LinesCount};Paragraph.prototype.Get_FrameAnchorPara=function(){var FramePr=this.Get_FramePr();
if(undefined===FramePr)return null;var Next=this.Get_DocumentNext();while(null!=Next){if(type_Paragraph===Next.GetType()){var NextFramePr=Next.Get_FramePr();if(undefined===NextFramePr||false===FramePr.Compare(NextFramePr))return Next}Next=Next.Get_DocumentNext()}return Next};Paragraph.prototype.Split=function(NewParagraph){if(!NewParagraph)NewParagraph=new Paragraph(this.DrawingDocument,this.Parent);NewParagraph.DeleteCommentOnRemove=false;this.DeleteCommentOnRemove=false;this.RemoveSelection();NewParagraph.RemoveSelection();
var ContentPos=this.Get_ParaContentPos(false,false);var CurPos=ContentPos.Get(0);var TextPr=this.Get_TextPr(ContentPos);var oLogicDocument=this.GetLogicDocument();var oStyles=oLogicDocument&&oLogicDocument.GetStyles?oLogicDocument.GetStyles():null;if(oStyles&&(TextPr.RStyle===oStyles.GetDefaultEndnoteReference()||TextPr.RStyle===oStyles.GetDefaultFootnoteReference())){TextPr=TextPr.Copy();TextPr.RStyle=undefined}var NewElement=this.Content[CurPos].Split(ContentPos,1);if(null===NewElement){NewElement=
new ParaRun(NewParagraph);NewElement.Set_Pr(TextPr.Copy())}var NewContent=this.Content.slice(CurPos+1);this.Internal_Content_Remove2(CurPos+1,this.Content.length-CurPos-1);var EndRun=new ParaRun(this);EndRun.Add_ToContent(0,new ParaEnd);this.Internal_Content_Add(this.Content.length,EndRun);NewParagraph.Internal_Content_Remove2(0,NewParagraph.Content.length);NewParagraph.Internal_Content_Concat(NewContent);NewParagraph.Internal_Content_Add(0,NewElement);NewParagraph.Correct_Content();this.CopyPr(NewParagraph);
this.TextPr.Clear_Style();this.TextPr.Apply_TextPr(TextPr);var SectPr=this.Get_SectionPr();if(undefined!==SectPr){this.Set_SectionPr(undefined);NewParagraph.Set_SectionPr(SectPr)}this.MoveCursorToEndPos(false,false);NewParagraph.MoveCursorToStartPos(false);NewParagraph.DeleteCommentOnRemove=true;this.DeleteCommentOnRemove=true;return NewParagraph};Paragraph.prototype.Concat=function(Para,isUseConcatedStyle){this.DeleteCommentOnRemove=false;Para.DeleteCommentOnRemove=false;this.Remove_ParaEnd();var NearPosCount=
Para.NearPosArray.length;for(var Pos=0;Pos<NearPosCount;Pos++){var ParaNearPos=Para.NearPosArray[Pos];ParaNearPos.Classes[0]=this;ParaNearPos.NearPos.Paragraph=this;ParaNearPos.NearPos.ContentPos.Data[0]+=this.Content.length;this.NearPosArray.push(ParaNearPos)}this.Internal_Content_Concat(Para.Content);Para.ClearContent();this.Set_SectionPr(undefined);var SectPr=Para.Get_SectionPr();if(undefined!==SectPr){Para.Set_SectionPr(undefined);this.Set_SectionPr(SectPr)}this.DeleteCommentOnRemove=true;Para.DeleteCommentOnRemove=
true;if(true===isUseConcatedStyle)Para.CopyPr(this)};Paragraph.prototype.ConcatBefore=function(oPara){this.DeleteCommentOnRemove=false;oPara.DeleteCommentOnRemove=false;oPara.Remove_ParaEnd();for(var nPos=0,nCount=this.NearPosArray.length;nPos<nCount;++nPos){var oParaNearPos=this.NearPosArray[nPos];oParaNearPos.NearPos.ContentPos.Data[0]+=oPara.Content.length}for(var nPos=0,nCount=oPara.NearPosArray.length;nPos<nCount;++nPos){var oParaNearPos=oPara.NearPosArray[nPos];oParaNearPos.Classes[0]=this;
oParaNearPos.NearPos.Paragraph=this;this.NearPosArray.push(oParaNearPos)}for(var nPos=0,nCount=oPara.Content.length;nPos<nCount;++nPos)this.AddToContent(nPos,oPara.Content[nPos]);oPara.ClearContent();oPara.Set_SectionPr(undefined);this.DeleteCommentOnRemove=true;oPara.DeleteCommentOnRemove=true;oPara.CopyPr(this)};Paragraph.prototype.Continue=function(NewParagraph){var TextPr;if(this.IsEmpty())TextPr=this.TextPr.Value.Copy();else{var EndPos=this.Get_EndPos2(false);var CurPos=this.Get_ParaContentPos(false,
false);this.Set_ParaContentPos(EndPos,true,-1,-1);TextPr=this.Get_TextPr(this.Get_ParaContentPos(false,false)).Copy();this.Set_ParaContentPos(CurPos,false,-1,-1,false);TextPr.HighLight=highlight_None;var oStyles;if(this.bFromDocument&&this.LogicDocument&&(oStyles=this.LogicDocument.GetStyles())&&(TextPr.RStyle===oStyles.GetDefaultFootnoteReference()||TextPr.RStyle===oStyles.GetDefaultEndnoteReference()))TextPr.RStyle=undefined}this.CopyPr(NewParagraph);if(!this.HaveNumbering()&&!this.Lock.Is_Locked()){this.TextPr.Clear_Style();
this.TextPr.Apply_TextPr(TextPr)}NewParagraph.Internal_Content_Add(0,new ParaRun(NewParagraph));NewParagraph.Correct_Content();NewParagraph.MoveCursorToStartPos(false);for(var Pos=0,Count=NewParagraph.Content.length;Pos<Count;Pos++)if(para_Run===NewParagraph.Content[Pos].Type)NewParagraph.Content[Pos].Set_Pr(TextPr.Copy())};Paragraph.prototype.GetSelectionState=function(){var ParaState={};ParaState.CurPos={X:this.CurPos.X,Y:this.CurPos.Y,Line:this.CurPos.Line,ContentPos:this.Get_ParaContentPos(false,
false),RealX:this.CurPos.RealX,RealY:this.CurPos.RealY,PagesPos:this.CurPos.PagesPos};ParaState.Selection={Start:this.Selection.Start,Use:this.Selection.Use,StartPos:0,EndPos:0,Flag:this.Selection.Flag};if(true===this.Selection.Use){ParaState.Selection.StartPos=this.Get_ParaContentPos(true,true);ParaState.Selection.EndPos=this.Get_ParaContentPos(true,false)}return[ParaState]};Paragraph.prototype.SetSelectionState=function(State,StateIndex){if(State.length<=0)return;var ParaState=State[StateIndex];
this.CurPos.X=ParaState.CurPos.X;this.CurPos.Y=ParaState.CurPos.Y;this.CurPos.Line=ParaState.CurPos.Line;this.CurPos.RealX=ParaState.CurPos.RealX;this.CurPos.RealY=ParaState.CurPos.RealY;this.CurPos.PagesPos=ParaState.CurPos.PagesPos;this.Set_ParaContentPos(ParaState.CurPos.ContentPos,true,-1,-1);this.RemoveSelection();this.Selection.Start=ParaState.Selection.Start;this.Selection.Use=ParaState.Selection.Use;this.Selection.Flag=ParaState.Selection.Flag;if(true===this.Selection.Use)this.Set_SelectionContentPos(ParaState.Selection.StartPos,
ParaState.Selection.EndPos)};Paragraph.prototype.Get_ParentObject_or_DocumentPos=function(){this.Parent.Update_ContentIndexing();return this.Parent.Get_ParentObject_or_DocumentPos(this.Index)};Paragraph.prototype.Refresh_RecalcData=function(Data){var Type=Data.Type;var bNeedRecalc=false;var CurPage=0;switch(Type){case AscDFH.historyitem_Paragraph_AddItem:case AscDFH.historyitem_Paragraph_RemoveItem:{for(CurPage=this.Pages.length-1;CurPage>0;CurPage--)if(Data.Pos>this.Lines[this.Pages[CurPage].StartLine].Get_StartPos())break;
this.RecalcInfo.Set_Type_0(pararecalc_0_All);bNeedRecalc=true;break}case AscDFH.historyitem_Paragraph_Numbering:case AscDFH.historyitem_Paragraph_PStyle:case AscDFH.historyitem_Paragraph_Pr:case AscDFH.historyitem_Paragraph_PresentationPr_Bullet:case AscDFH.historyitem_Paragraph_PresentationPr_Level:{this.RecalcInfo.Set_Type_0(pararecalc_0_All);bNeedRecalc=true;this.CompiledPr.NeedRecalc=true;this.Recalc_RunsCompiledPr();break}case AscDFH.historyitem_Paragraph_Align:case AscDFH.historyitem_Paragraph_DefaultTabSize:case AscDFH.historyitem_Paragraph_Ind_First:case AscDFH.historyitem_Paragraph_Ind_Left:case AscDFH.historyitem_Paragraph_Ind_Right:case AscDFH.historyitem_Paragraph_ContextualSpacing:case AscDFH.historyitem_Paragraph_KeepLines:case AscDFH.historyitem_Paragraph_KeepNext:case AscDFH.historyitem_Paragraph_PageBreakBefore:case AscDFH.historyitem_Paragraph_Spacing_Line:case AscDFH.historyitem_Paragraph_Spacing_LineRule:case AscDFH.historyitem_Paragraph_Spacing_Before:case AscDFH.historyitem_Paragraph_Spacing_After:case AscDFH.historyitem_Paragraph_Spacing_AfterAutoSpacing:case AscDFH.historyitem_Paragraph_Spacing_BeforeAutoSpacing:case AscDFH.historyitem_Paragraph_WidowControl:case AscDFH.historyitem_Paragraph_Tabs:case AscDFH.historyitem_Paragraph_Borders_Between:case AscDFH.historyitem_Paragraph_Borders_Bottom:case AscDFH.historyitem_Paragraph_Borders_Left:case AscDFH.historyitem_Paragraph_Borders_Right:case AscDFH.historyitem_Paragraph_Borders_Top:case AscDFH.historyitem_Paragraph_FramePr:{bNeedRecalc=
true;break}case AscDFH.historyitem_Paragraph_Shd_Value:case AscDFH.historyitem_Paragraph_Shd_Color:case AscDFH.historyitem_Paragraph_Shd_Unifill:case AscDFH.historyitem_Paragraph_Shd:{if(this.Parent){var oDrawingShape=this.Parent.Is_DrawingShape(true);if(oDrawingShape&&oDrawingShape.getObjectType&&oDrawingShape.getObjectType()===AscDFH.historyitem_type_Shape)if(oDrawingShape.chekBodyPrTransform(oDrawingShape.getBodyPr())||oDrawingShape.checkContentWordArt(oDrawingShape.getDocContent()))bNeedRecalc=
true;if(this.Parent.IsTableHeader())bNeedRecalc=true}break}case AscDFH.historyitem_Paragraph_SectionPr:{if(this.Parent instanceof CDocument){this.Parent.UpdateContentIndexing();var nSectionIndex=this.Parent.GetSectionIndexByElementIndex(this.GetIndex());var oFirstElement=this.Parent.GetFirstElementInSection(nSectionIndex);if(oFirstElement)this.Parent.Refresh_RecalcData2(oFirstElement.GetIndex(),oFirstElement.private_GetRelativePageIndex(0))}break}case AscDFH.historyitem_Paragraph_PrChange:{if(Data instanceof
CChangesParagraphPrChange&&Data.IsChangedNumbering())bNeedRecalc=true;break}case AscDFH.historyitem_Paragraph_SuppressLineNumbers:{History.AddLineNumbersToRecalculateData();break}}if(true===bNeedRecalc){var Prev=this.Get_DocumentPrev();if(0===CurPage&&null!=Prev&&type_Paragraph===Prev.GetType()&&true===Prev.Get_CompiledPr2(false).ParaPr.KeepNext)Prev.Refresh_RecalcData2(Prev.Pages.length-1);return this.Refresh_RecalcData2(CurPage)}};Paragraph.prototype.Refresh_RecalcData2=function(CurPage){if(!CurPage)CurPage=

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 504 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 357 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -0,0 +1 @@
AscCommon.g_defaultThemes = ["Blank","Basic","Classic","Official","Green leaf","Lines","Office","Safari","Dotted","Corner","Turtle"];

@ -778,94 +778,95 @@ nQuotient){sGroup+=arrChinese[nQuotient]+arrChinese[1E3];isPrevZero=false}else i
true;if(nTTRemainder<=0){sResult=sGroup+sResult;if(nRemValue<=0)break;continue}var nQuotient=nTTRemainder/1E3|0;var nRemainder=nTTRemainder-nQuotient*1E3;if(0!==nQuotient){sGroup+=arrChinese[nQuotient]+arrChinese[1E3];isPrevZero=false}else if(nTTQuotient>0){sGroup+=arrChinese[0];isPrevZero=true}if(nRemainder<=0){sResult=sGroup+sResult;if(nRemValue<=0)break;continue}nQuotient=nRemainder/100|0;nRemainder=nRemainder-nQuotient*100;if(0!==nQuotient){sGroup+=arrChinese[nQuotient]+arrChinese[100];isPrevZero=
false}else if(!isPrevZero){sGroup+=arrChinese[0];isPrevZero=true}if(nRemainder<=0){sResult=sGroup+sResult;if(nRemValue<=0)break;continue}nQuotient=nRemainder/10|0;nRemainder=nRemainder-nQuotient*10;if(0!==nQuotient){sGroup+=arrChinese[nQuotient]+arrChinese[10];isPrevZero=false}else if(!isPrevZero){sGroup+=arrChinese[0];isPrevZero=true}if(0!==nRemainder)sGroup+=arrChinese[nRemainder];sResult=sGroup+sResult;if(nRemValue<=0)break}break}}return sResult}var c_oAscSpaces=[];c_oAscSpaces[10]=1;c_oAscSpaces[32]=
1;c_oAscSpaces[8194]=1;c_oAscSpaces[8195]=1;c_oAscSpaces[8197]=1;c_oAscSpaces[12288]=1;function IsSpace(nUnicode){return!!c_oAscSpaces[nUnicode]}function private_IsAbbreviation(sWord){if(sWord.toUpperCase()===sWord){for(var nPos=0,nLen=sWord.length;nPos<nLen;++nPos){var nCharCode=sWord.charCodeAt(nPos);if(44032<=nCharCode&&nCharCode<=55203||4352<=nCharCode&&nCharCode<=4607||12592<=nCharCode&&nCharCode<=12687||43360<=nCharCode&&nCharCode<=43391||55216<=nCharCode&&nCharCode<=55295||19968<=nCharCode&&
nCharCode<=40959||13312<=nCharCode&&nCharCode<=19903||131072<=nCharCode&&nCharCode<=173791||173824<=nCharCode&&nCharCode<=177983||177984<=nCharCode&&nCharCode<=178207||178208<=nCharCode&&nCharCode<=183983||63744<=nCharCode&&nCharCode<=64255||194560<=nCharCode&&nCharCode<=195103)return false}return true}return false}var g_oUserColorById={},g_oUserNextColorIndex=0;function getUserColorById(userId,userName,isDark,isNumericValue){if((!userId||""===userId)&&(!userName||""===userName))return new CColor(0,
0,0,255);var res;if(g_oUserColorById.hasOwnProperty(userId))res=g_oUserColorById[userId];else if(g_oUserColorById.hasOwnProperty(userName))res=g_oUserColorById[userName];else{var nColor=Asc.c_oAscArrUserColors[g_oUserNextColorIndex%Asc.c_oAscArrUserColors.length];++g_oUserNextColorIndex;res=g_oUserColorById[userId||userName]=new CUserCacheColor(nColor)}if(!res)return new CColor(0,0,0,255);var oColor=true===isDark?res.Dark:res.Light;return true===isNumericValue?oColor.r<<16&16711680|oColor.g<<8&65280|
oColor.b&255:oColor}function isNullOrEmptyString(str){return str==undefined||str==null||str==""}function unleakString(s){return(" "+s).substr(1)}function readValAttr(attr){if(attr()){var val=attr()["val"];return val?val:null}return null}function getNumFromXml(val){return val?val-0:null}function getColorFromXml(attr){if(attr()){var vals=attr();if(null!=vals["theme"])return AscCommonExcel.g_oColorManager.getThemeColor(getNumFromXml(vals["theme"]),getNumFromXml(vals["tint"]));else if(null!=vals["rgb"])return new AscCommonExcel.RgbColor(16777215&
getNumFromXml(vals["rgb"]))}return null}function getBoolFromXml(val){return"0"!==val&&"false"!==val&&"off"!==val}function CUserCacheColor(nColor){this.Light=null;this.Dark=null;this.init(nColor)}CUserCacheColor.prototype.init=function(nColor){var r=nColor>>16&255;var g=nColor>>8&255;var b=nColor&255;var Y=Math.max(0,Math.min(255,.299*r+.587*g+.114*b));var Cb=Math.max(0,Math.min(255,128-.168736*r-.331264*g+.5*b));var Cr=Math.max(0,Math.min(255,128+.5*r-.418688*g-.081312*b));if(Y>63)Y=63;var R=Math.max(0,
Math.min(255,Y+1.402*(Cr-128)))|0;var G=Math.max(0,Math.min(255,Y-.34414*(Cb-128)-.71414*(Cr-128)))|0;var B=Math.max(0,Math.min(255,Y+1.772*(Cb-128)))|0;this.Light=new CColor(r,g,b,255);this.Dark=new CColor(R,G,B,255)};function loadScript(url,onSuccess,onError){if(window["NATIVE_EDITOR_ENJINE"]===true||window["Native"]!==undefined){onSuccess();return}if(window["AscDesktopEditor"]&&window["local_load_add"]){var _context={"completeLoad":function(){return onSuccess()}};window["local_load_add"](_context,
"sdk-all-from-min",url);var _ret_param=window["AscDesktopEditor"]["LoadJS"](url);if(2!=_ret_param)window["local_load_remove"](url);if(_ret_param==1){setTimeout(onSuccess,1);return}else if(_ret_param==2)return}var backoff=new AscCommon.Backoff(AscCommon.g_oBackoffDefaults);loadScriptWithBackoff(backoff,url,onSuccess,onError)}function loadScriptWithBackoff(backoff,url,onSuccess,onError){var script=document.createElement("script");script.type="text/javascript";script.src=url;script.onload=onSuccess;
script.onerror=function(){backoff.attempt(onError,function(){loadScriptWithBackoff(backoff,url,onSuccess,onError)})};document.head.appendChild(script)}function loadSdk(sdkName,onSuccess,onError){if(window["AscNotLoadAllScript"])onSuccess();else{var urlArgs=window.parent&&window.parent.APP&&window.parent.APP.urlArgs||"";loadScript("./../../../../sdkjs/"+sdkName+"/sdk-all.js?"+urlArgs,onSuccess,onError)}}function getAltGr(e){var ctrlKey=e.metaKey||e.ctrlKey;var altKey=e.altKey;return altKey&&(AscBrowser.isMacOs?
!ctrlKey:ctrlKey)}function getColorSchemeByName(sName){for(var i=0;i<AscCommon.g_oUserColorScheme.length;++i){var tmp=AscCommon.g_oUserColorScheme[i];if(tmp&&tmp.name===sName)return getColorSchemeByIdx(i)}return null}function getColorSchemeByIdx(idx){var tmp=AscCommon.g_oUserColorScheme[idx];if(tmp){var scheme=new AscFormat.ClrScheme,_c;scheme.name=tmp.name;_c=tmp.get_dk1();scheme.colors[8]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_lt1();scheme.colors[12]=AscFormat.CreateUniColorRGB(_c.r,
_c.g,_c.b);_c=tmp.get_dk2();scheme.colors[9]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_lt2();scheme.colors[13]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent1();scheme.colors[0]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent2();scheme.colors[1]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent3();scheme.colors[2]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent4();scheme.colors[3]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent5();
scheme.colors[4]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent6();scheme.colors[5]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_hlink();scheme.colors[11]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_folHlink();scheme.colors[10]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);return scheme}return null}function getAscColorScheme(_scheme,theme){var elem,_c;var _rgba={R:0,G:0,B:0,A:255};elem=new AscCommon.CAscColorScheme;elem.scheme=_scheme;elem.name=_scheme.name;_scheme.colors[8].Calculate(theme,
null,null,null,_rgba);_c=_scheme.colors[8].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[12].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[12].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[9].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[9].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[13].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[13].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));
_scheme.colors[0].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[0].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[1].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[1].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[2].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[2].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[3].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[3].RGBA;elem.putColor(new AscCommon.CColor(_c.R,
_c.G,_c.B));_scheme.colors[4].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[4].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[5].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[5].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[11].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[11].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[10].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[10].RGBA;elem.putColor(new AscCommon.CColor(_c.R,
_c.G,_c.B));return elem}function getIndexColorSchemeInArray(result,asc_color_scheme){for(var j=0;j<result.length;++j)if(result[j].isEqual(asc_color_scheme))return j;return-1}function checkAddColorScheme(result,asc_color_scheme,nStartIndex){var nIndex=getIndexColorSchemeInArray(result,asc_color_scheme);if(nIndex>-1)return nIndex;var nStartIndex_=nStartIndex;if(nStartIndex===null)nStartIndex_=result.length;result.splice(nStartIndex_,0,asc_color_scheme);return nStartIndex_}function isEastAsianScript(value){return 12544<=
value&&value<=12591||12704<=value&&value<=12735||19968<=value&&value<=40938||13312<=value&&value<=19893||131072<=value&&value<=173782||173824<=value&&value<=177972||177984<=value&&value<=178205||178208<=value&&value<=183969||183984<=value&&value<=191456||63744<=value&&value<=64255||194560<=value&&value<=195103||12032<=value&&value<=12255||11904<=value&&value<=12031||12736<=value&&value<=12783||12272<=value&&value<=12287||4352<=value&&value<=4607||43360<=value&&value<=43391||55216<=value&&value<=55295||
12592<=value&&value<=12687||65280<=value&&value<=65519||44032<=value&&value<=55215||12352<=value&&value<=12447||110848<=value&&value<=110895||110592<=value&&value<=110847||12688<=value&&value<=12703||12448<=value&&value<=12543||12784<=value&&value<=12799||42192<=value&&value<=42239||93952<=value&&value<=94111||110960<=value&&value<=111359||94208<=value&&value<=100332||100352<=value&&value<=101119||40960<=value&&value<=42127||42128<=value&&value<=42191}var g_oIdCounter=new CIdCounter;window.Asc.g_signature_drawer=
null;function CSignatureDrawer(id,api,w,h){window.Asc.g_signature_drawer=this;this.Api=api;this.CanvasParent=document.getElementById(id);this.Canvas=document.createElement("canvas");this.Canvas.style.position="absolute";this.Canvas.style.left="0px";this.Canvas.style.top="0px";var _width=parseInt(this.CanvasParent.offsetWidth);var _height=parseInt(this.CanvasParent.offsetHeight);if(0==_width)_width=300;if(0==_height)_height=80;this.Canvas.width=_width;this.Canvas.height=_height;this.CanvasParent.appendChild(this.Canvas);
this.Image="";this.ImageHtml=null;this.Text="";this.Font="Arial";this.Size=10;this.Italic=true;this.Bold=false;this.Width=w;this.Height=h;this.CanvasReturn=null;this.IsAsync=false}CSignatureDrawer.prototype.getCanvas=function(){return this.CanvasReturn==null?this.Canvas:this.CanvasReturn};CSignatureDrawer.prototype.getImages=function(){if(!this.isValid())return["",""];this.CanvasReturn=document.createElement("canvas");this.CanvasReturn.width=this.Width*AscCommon.g_dKoef_mm_to_pix;this.CanvasReturn.height=
this.Height*AscCommon.g_dKoef_mm_to_pix;if(this.Text!="")this.drawText();else this.drawImage();var _ret=[];_ret.push(this.CanvasReturn.toDataURL("image/png"));var _ctx=this.CanvasReturn.getContext("2d");_ctx.strokeStyle="#FF0000";_ctx.lineWidth=2;_ctx.moveTo(0,0);_ctx.lineTo(this.CanvasReturn.width,this.CanvasReturn.height);_ctx.moveTo(0,this.CanvasReturn.height);_ctx.lineTo(this.CanvasReturn.width,0);_ctx.stroke();_ret.push(this.CanvasReturn.toDataURL("image/png"));this.CanvasReturn=null;return _ret};
CSignatureDrawer.prototype.setText=function(text,font,size,isItalic,isBold){if(this.IsAsync){this.Text=text;return}this.Image="";this.ImageHtml=null;this.Text=text;this.Font=font;this.Size=size;this.Italic=isItalic;this.Bold=isBold;this.IsAsync=true;AscFonts.FontPickerByCharacter.checkText(this.Text,this,function(){this.IsAsync=false;var loader=AscCommon.g_font_loader;var fontinfo=AscFonts.g_fontApplication.GetFontInfo(font);var isasync=loader.LoadFont(fontinfo,function(){window.Asc.g_signature_drawer.Api.sync_EndAction(Asc.c_oAscAsyncActionType.Information,
Asc.c_oAscAsyncAction.LoadFont);window.Asc.g_signature_drawer.drawText()});if(false===isasync)this.drawText()})};CSignatureDrawer.prototype.drawText=function(){var _oldTurn=this.Api.isViewMode;var _oldMarks=this.Api.ShowParaMarks;this.Api.isViewMode=true;this.Api.ShowParaMarks=false;AscFormat.ExecuteNoHistory(AscCommon.DrawTextByCenter,this,[]);this.Api.isViewMode=_oldTurn;this.Api.ShowParaMarks=_oldMarks};CSignatureDrawer.prototype.drawImage=function(){var _canvas=this.getCanvas();var w=_canvas.width;
var h=_canvas.height;var _ctx=_canvas.getContext("2d");_ctx.clearRect(0,0,w,h);var im_w=this.ImageHtml.width;var im_h=this.ImageHtml.height;var _x=0;var _y=0;var _w=0;var _h=0;var koef1=w/h;var koef2=im_w/im_h;if(koef1>koef2){_h=h;_w=koef2*_h>>0;_y=0;_x=w-_w>>1}else{_w=w;_h=_w/koef2>>0;_x=0;_y=h-_h>>1}_ctx.drawImage(this.ImageHtml,_x,_y,_w,_h)};CSignatureDrawer.prototype.selectImage=CSignatureDrawer.prototype["selectImage"]=function(){this.Text="";window["AscDesktopEditor"]["OpenFilenameDialog"]("images",
false,function(_file){var file=_file;if(Array.isArray(file))file=file[0];if(!file)return;var _drawer=window.Asc.g_signature_drawer;_drawer.Image=window["AscDesktopEditor"]["GetImageBase64"](file);_drawer.ImageHtml=new Image;_drawer.ImageHtml.onload=function(){window.Asc.g_signature_drawer.drawImage()};_drawer.ImageHtml.src=_drawer.Image;_drawer=null})};CSignatureDrawer.prototype.isValid=function(){return this.Image!=""||this.Text!=""};CSignatureDrawer.prototype.destroy=function(){window.Asc.g_signature_drawer.CanvasParent.removeChild(this.Canvas);
delete window.Asc.g_signature_drawer};function CSignatureImage(){this.ImageValidBase64="";this.ImageInvalidBase64="";this.ImageValid=null;this.ImageInvalid=null;this.Valid=false;this.Loading=0;this.Remove=function(){this.ImageValidBase64="";this.ImageInvalidBase64="";this.ImageValid=null;this.ImageInvalid=null;this.Valid=false;this.Loading=0};this.Register=function(_api,_guid){if(_api.ImageLoader.map_image_index[_guid])return;var _obj={Image:this.Valid?this.ImageValid:this.ImageInvalid,Status:AscFonts.ImageLoadStatus.Complete,
src:_guid};_api.ImageLoader.map_image_index[_guid]=_obj};this.Unregister=function(_api,_guid){if(_api.ImageLoader.map_image_index[_guid])delete _api.ImageLoader.map_image_index[_guid]}}function CShortcuts(){this.List={};this.CustomCounter=0;this.CustomActions={}}CShortcuts.prototype.Add=function(nType,nCode,isCtrl,isShift,isAlt){this.List[this.private_GetIndex(nCode,isCtrl,isShift,isAlt)]=nType};CShortcuts.prototype.Get=function(nCode,isCtrl,isShift,isAlt){var nType=this.List[this.private_GetIndex(nCode,
isCtrl,isShift,isAlt)];return undefined!==nType?nType:0};CShortcuts.prototype.private_GetIndex=function(nCode,isCtrl,isShift,isAlt){return nCode<<8|(isCtrl?4:0)|(isShift?2:0)|(isAlt?1:0)};CShortcuts.prototype.CheckType=function(nType){for(var nIndex in this.List)if(this.List[nIndex]===nType)return{KeyCode:nIndex>>>8,CtrlKey:!!(nIndex&4),ShiftKey:!!(nIndex&2),AltKey:!!(nIndex&1)};return null};CShortcuts.prototype.Remove=function(nCode,isCtrl,isShift,isAlt){delete this.List[this.private_GetIndex(nCode,
isCtrl,isShift,isAlt)]};CShortcuts.prototype.RemoveByType=function(nType){for(var nIndex in this.List)if(this.List[nIndex]===nType)delete this.List[nIndex]};CShortcuts.prototype.GetNewCustomType=function(){return 16711680|this.CustomCounter++};CShortcuts.prototype.IsCustomType=function(nType){return nType>=16711680};CShortcuts.prototype.GetCustomAction=function(nType){return this.CustomActions[nType]};CShortcuts.prototype.AddCustomActionSymbol=function(nCharCode,sFont){var nType=this.GetNewCustomType();
this.CustomActions[nType]=new CCustomShortcutActionSymbol(nCharCode,sFont);return nType};function CCustomShortcutActionSymbol(nCharCode,sFont){this.CharCode=nCharCode;this.Font=sFont}CCustomShortcutActionSymbol.prototype.Type=AscCommon.c_oAscCustomShortcutType.Symbol;AscCommon.EncryptionMessageType={Encrypt:0,Decrypt:1};function CEncryptionData(){this._init=false;this.arrData=[];this.arrImages=[];this.handleChangesCallback=null;this.isChangesHandled=false;this.cryptoMode=0;this.isChartEditor=false;
this.isExistDecryptedChanges=false;this.cryptoPrefix=window["AscDesktopEditor"]&&window["AscDesktopEditor"]["GetEncryptedHeader"]?window["AscDesktopEditor"]["GetEncryptedHeader"]():"ENCRYPTED;";this.cryptoPrefixLen=this.cryptoPrefix.length;this.editorId=null;this.nextChangesTimeoutId=-1;this.isPasswordCryptoPresent=false;this.init=function(){this._init=true};this.isInit=function(){return this._init};this.isNeedCrypt=function(){if(window.g_asc_plugins)if(!window.g_asc_plugins.isRunnedEncryption())return false;
if(!window["AscDesktopEditor"])return false;if(this.isChartEditor)return false;if(2==this.cryptoMode)return true;if(0===window["AscDesktopEditor"]["CryptoMode"])return false;return true};this.isCryptoImages=function(){return this.isNeedCrypt()&&this.isPasswordCryptoPresent};this.addCryproImagesFromDialog=function(callback){var _this=this;window["AscDesktopEditor"]["OpenFilenameDialog"]("images",true,function(files){if(!files)return;if(!Array.isArray(files))files=[files];if(0===files.length)return;
var _files=[];var _options={isImageCrypt:true,callback:callback,ext:[]};for(var i=0;i<files.length;i++){_files.push(window["AscDesktopEditor"]["GetImageBase64"](files[i],true));_options.ext.push(AscCommon.GetFileExtension(files[i]))}_this.sendChanges(this,_files,AscCommon.EncryptionMessageType.Encrypt,_options)})};this.addCryproImagesFromUrls=function(urls,callback){var _editor=window["Asc"]["editor"]?window["Asc"]["editor"]:window.editor;_editor.sync_StartAction(Asc.c_oAscAsyncActionType.BlockInteraction,
Asc.c_oAscAsyncAction.LoadImage);var _this=this;window["AscDesktopEditor"]["DownloadFiles"](urls,[],function(files){_editor.sync_EndAction(Asc.c_oAscAsyncActionType.BlockInteraction,Asc.c_oAscAsyncAction.LoadImage);_editor.sync_StartAction(Asc.c_oAscAsyncActionType.BlockInteraction,Asc.c_oAscAsyncAction.UploadImage);var _files=[];var _options={isImageCrypt:true,isUrls:true,callback:callback,ext:[],api:_editor};for(var elem in files){_files.push(window["AscDesktopEditor"]["GetImageBase64"](files[elem],
true));_options.ext.push(window["AscDesktopEditor"]["GetImageFormat"](files[elem]));window["AscDesktopEditor"]["RemoveFile"](files[elem])}_this.sendChanges(this,_files,AscCommon.EncryptionMessageType.Encrypt,_options)})};this.onDecodeError=function(){var _editor=window["Asc"]["editor"]?window["Asc"]["editor"]:window.editor;_editor.sendEvent("asc_onError",Asc.c_oAscError.ID.DataEncrypted,Asc.c_oAscError.Level.Critical)};this.checkEditorId=function(){if(null==this.editorId){var _editor=window["Asc"]["editor"]?
window["Asc"]["editor"]:window.editor;this.editorId=_editor.editorId}};this.decryptImage=function(src,img,data){this.sendChanges(this,[data],AscCommon.EncryptionMessageType.Decrypt,{isImageDecrypt:true,src:src,img:img})};this.nextChanges=function(){this.nextChangesTimeoutId=setTimeout(function(){AscCommon.EncryptionWorker.sendChanges(undefined,undefined);this.nextChangesTimeoutId=-1},10)};this.sendChanges=function(sender,data,type,options){if(!this.isNeedCrypt()){if(AscCommon.EncryptionMessageType.Encrypt==
type)sender._send(data,true);else if(AscCommon.EncryptionMessageType.Decrypt==type){if(this.isExistEncryptedChanges(data["changes"])){this.onDecodeError();return}sender._onSaveChanges(data,true)}return}if(undefined!==type)this.arrData.push({sender:sender,type:type,data:data,options:options});if(this.arrData.length==0)return;if(undefined!==type&&(1!=this.arrData.length||!this.isChangesHandled))return;if(undefined!==type&&-1!=this.nextChangesTimeoutId){clearTimeout(this.nextChangesTimeoutId);this.nextChangesTimeoutId=
-1}if(AscCommon.EncryptionMessageType.Encrypt==this.arrData[0].type)if(this.arrData[0].options&&this.arrData[0].options.isImageCrypt)window.g_asc_plugins.sendToEncryption({"type":"encryptData","data":this.arrData[0].data});else window.g_asc_plugins.sendToEncryption({"type":"encryptData","data":JSON.parse(this.arrData[0].data["changes"])});else if(AscCommon.EncryptionMessageType.Decrypt==this.arrData[0].type)if(this.arrData[0].options&&this.arrData[0].options.isImageDecrypt)window.g_asc_plugins.sendToEncryption({"type":"decryptData",
"data":this.arrData[0].data});else window.g_asc_plugins.sendToEncryption({"type":"decryptData","data":this.arrData[0].data["changes"]})};this.receiveChanges=function(obj){var data=obj["data"];var check=obj["check"];if(!check){this.onDecodeError();return}if(this.handleChangesCallback){this.isExistDecryptedChanges=true;this.checkEditorId();if(this.editorId==AscCommon.c_oEditorId.Spreadsheet)for(var i=data.length-1;i>=0;i--)this.handleChangesCallback.changesBase[i]=data[i];else for(var i=data.length-
1;i>=0;i--)this.handleChangesCallback.changesBase[i].m_pData=data[i];this.isChangesHandled=true;this.handleChangesCallback.callback.call(this.handleChangesCallback.sender);this.handleChangesCallback=null;this.nextChanges();return}var obj=this.arrData[0];this.arrData.splice(0,1);if(AscCommon.EncryptionMessageType.Encrypt==obj.type)if(obj.options&&obj.options.isImageCrypt){for(var i=0;i<data.length;i++)if(this.cryptoPrefix==data[i].substr(0,this.cryptoPrefixLen))data[i]=this.cryptoPrefix+obj.options.ext[i]+
";"+data[i].substr(this.cryptoPrefixLen);if(!obj.options.isUrls)obj.options.callback(Asc.c_oAscError.ID.No,data);else AscCommon.UploadImageUrls(data,obj.options.api.documentId,obj.options.api.documentUserId,obj.options.api.CoAuthoringApi.get_jwt(),function(urls){obj.options.api.sync_EndAction(Asc.c_oAscAsyncActionType.BlockInteraction,Asc.c_oAscAsyncAction.UploadImage);obj.options.callback(urls)})}else{obj.data["changes"]=JSON.stringify(data);obj.sender._send(obj.data,true)}else if(AscCommon.EncryptionMessageType.Decrypt==
obj.type)if(obj.options&&obj.options.isImageDecrypt){window["AscDesktopEditor"]["ResaveFile"](obj.options.src,data[0]);obj.options.img["onload_crypto"](obj.options.src)}else{this.isExistDecryptedChanges=true;obj.data["changes"]=data;obj.sender._onSaveChanges(obj.data,true)}this.nextChanges()};this.isExistEncryptedChanges=function(_array){if(0==_array.length)return false;this.checkEditorId();var isChangesMode=_array[0]["change"]?true:false;var _prefix="";var _checkPrefixLen=this.cryptoPrefixLen+1;
if(isChangesMode){for(var i=_array.length-1;i>=0;i--)if(_array[i]["change"].length>_checkPrefixLen){_prefix=_array[i]["change"].substr(0,_checkPrefixLen);if(-1!=_prefix.indexOf(this.cryptoPrefix)){isCrypted=true;break}}return isCrypted}var isCrypted=false;if(this.editorId==AscCommon.c_oEditorId.Spreadsheet)for(var i=_array.length-1;i>=0;i--){if(_array[i].length>_checkPrefixLen){_prefix=_array[i].substr(0,_checkPrefixLen);if(-1!=_prefix.indexOf(this.cryptoPrefix)){isCrypted=true;break}}}else for(var i=
_array.length-1;i>=0;i--)if(_array[i].m_pData.length>_checkPrefixLen){_prefix=_array[i].m_pData.substr(0,_checkPrefixLen);if(-1!=_prefix.indexOf(this.cryptoPrefix)){isCrypted=true;break}}return isCrypted};this.handleChanges=function(_array,_sender,_callback){if(0==_array.length||!this.isNeedCrypt()){if(this.isExistEncryptedChanges(_array)){this.onDecodeError();return}this.isChangesHandled=true;_callback.call(_sender);return}this.handleChangesCallback={changesBase:_array,changes:[],sender:_sender,
callback:_callback};this.checkEditorId();if(this.editorId==AscCommon.c_oEditorId.Spreadsheet)for(var i=_array.length-1;i>=0;i--)this.handleChangesCallback.changes[i]=_array[i];else for(var i=_array.length-1;i>=0;i--)this.handleChangesCallback.changes[i]=_array[i].m_pData;window.g_asc_plugins.sendToEncryption({"type":"decryptData","data":this.handleChangesCallback.changes})};this.asc_setAdvancedOptions=function(api,idOption,option){if(window.isNativeOpenPassword){window["AscDesktopEditor"]["NativeViewerOpen"](option.asc_getPassword());
return}if(window.isCloudCryptoDownloadAs)return false;if(!this.isNeedCrypt())return false;window.checkPasswordFromPlugin=true;if(window["Asc"].c_oAscAdvancedOptionsID.TXT===idOption){var _param="<m_nCsvTxtEncoding>"+option.asc_getCodePage()+"</m_nCsvTxtEncoding>";window["AscDesktopEditor"]["SetAdvancedOptions"](_param)}else if(window["Asc"].c_oAscAdvancedOptionsID.CSV===idOption){var delimiter=option.asc_getDelimiter();var delimiterChar=option.asc_getDelimiterChar();var _param="";_param+="<m_nCsvTxtEncoding>"+
option.asc_getCodePage()+"</m_nCsvTxtEncoding>";if(null!=delimiter)_param+="<m_nCsvDelimiter>"+delimiter+"</m_nCsvDelimiter>";if(null!=delimiterChar)_param+="<m_nCsvDelimiterChar>"+delimiterChar+"</m_nCsvDelimiterChar>";window["AscDesktopEditor"]["SetAdvancedOptions"](_param)}else if(window["Asc"].c_oAscAdvancedOptionsID.DRM===idOption){var _param="<m_sPassword>"+AscCommon.CopyPasteCorrectString(option.asc_getPassword())+"</m_sPassword>";api.currentPassword=option.asc_getPassword();window["AscDesktopEditor"]["SetAdvancedOptions"](_param)}return true}}
AscCommon.EncryptionWorker=new CEncryptionData;function CMouseSmoothWheelCorrector(t,scrollFunction){this._deltaX=0;this._deltaY=0;this._isBreakX=false;this._isBreakY=false;this._timeoutCorrector=-1;this._api=t;this._scrollFunction=scrollFunction;this._normalDelta=120;this._isNormalDeltaActive=false;this.setNormalDeltaActive=function(value){this._isNormalDeltaActive=true;this._normalDelta=value};this.isBreakX=function(){return this._isBreakX};this.isBreakY=function(){return this._isBreakY};this.get_DeltaX=
function(wheelDeltaX){this._isBreakX=false;if(!AscCommon.AscBrowser.isMacOs)return wheelDeltaX;this._deltaX+=wheelDeltaX;if(Math.abs(this._deltaX)>=this._normalDelta)return this._isNormalDeltaActive?this._deltaX>0?this._normalDelta:-this._normalDelta:this._deltaX;this._isBreakX=true;return 0};this.get_DeltaY=function(wheelDeltaY){this._isBreakY=false;if(!AscCommon.AscBrowser.isMacOs)return wheelDeltaY;this._deltaY+=wheelDeltaY;if(Math.abs(this._deltaY)>=this._normalDelta)return this._isNormalDeltaActive?
this._deltaY>0?this._normalDelta:-this._normalDelta:this._deltaY;this._isBreakY=true;return 0};this.checkBreak=function(){if(-1!=this._timeoutCorrector){clearTimeout(this._timeoutCorrector);this._timeoutCorrector=-1}if((this._isBreakX||this._isBreakY)&&this._scrollFunction){var obj={t:this,x:this._isBreakX?this._deltaX:0,y:this._isBreakY?this._deltaY:0};this._timeoutCorrector=setTimeout(function(){var t=obj.t;t._scrollFunction.call(t._api,obj.x,obj.y);t._timeoutCorrector=-1;t._deltaX=0;t._deltaY=
0},100)}if(!this._isBreakX)this._deltaX=0;if(!this._isBreakY)this._deltaY=0;this._isBreakX=false;this._isBreakY=false}}AscCommon.CMouseSmoothWheelCorrector=CMouseSmoothWheelCorrector;function CTranslateManager(){this.mapTranslate={}}CTranslateManager.prototype.init=function(map){this.mapTranslate=map||{}};CTranslateManager.prototype.getValue=function(key){return this.mapTranslate.hasOwnProperty(key)?this.mapTranslate[key]:key};function CPolygonPoint2(X,Y){this.X=X;this.Y=Y}function CPolygonVectors(){this.Page=
-1;this.VX=[];this.VY=[]}function CPolygonPath(precision){this.Page=-1;this.Direction=1;this.precision=precision;this.Points=[]}CPolygonPath.prototype.PushPoint=function(x,y){this.Points.push(new CPolygonPoint2(x/this.precision,y/this.precision))};CPolygonPath.prototype.CorrectExtremePoints=function(){var Lng=this.Points.length;this.Points[0].X=this.Points[Lng-1].X;this.Points[Lng-1].Y=this.Points[0].Y};function CPolygon(){this.Vectors=[];this.precision=1E3}CPolygon.prototype.fill=function(arrBounds){this.Vectors.length=
0;if(arrBounds.length<=0)return;var nStartLineIndex=0,nStartIndex=0,CountLines=arrBounds.length,CountBounds;while(nStartLineIndex<arrBounds.length){CountBounds=arrBounds[nStartLineIndex].length;while(nStartIndex<CountBounds)if(arrBounds[nStartLineIndex][nStartIndex].W<.001)nStartIndex++;else break;if(nStartIndex<CountBounds)break;nStartLineIndex++;nStartIndex=0}if(nStartLineIndex>=arrBounds.length)return;var CurrentPage=arrBounds[nStartLineIndex][nStartIndex].Page,CurrentVectors=new CPolygonVectors,
VectorsX=CurrentVectors.VX,VectorsY=CurrentVectors.VY;CurrentVectors.Page=CurrentPage;this.Vectors.push(CurrentVectors);for(var LineIndex=nStartLineIndex;LineIndex<CountLines;nStartIndex=0,LineIndex++){if(arrBounds[LineIndex][nStartIndex].Page!==CurrentPage){CurrentPage=arrBounds[LineIndex][nStartIndex].Page;CurrentVectors=new CPolygonVectors;VectorsX=CurrentVectors.VX;VectorsY=CurrentVectors.VY;CurrentVectors.Page=CurrentPage;this.Vectors.push(CurrentVectors)}for(var Index=nStartIndex;Index<arrBounds[LineIndex].length;Index++){var oBound=
arrBounds[LineIndex][Index];if(oBound.W<.001)continue;var x1=Math.round(oBound.X*this.precision),x2=Math.round((oBound.X+oBound.W)*this.precision),y1=Math.round(oBound.Y*this.precision),y2=Math.round((oBound.Y+oBound.H)*this.precision);if(VectorsX[y1]==undefined)VectorsX[y1]={};this.IntersectionX(VectorsX,x2,x1,y1);if(VectorsY[x1]==undefined)VectorsY[x1]={};this.IntersectionY(VectorsY,y1,y2,x1);if(VectorsX[y2]==undefined)VectorsX[y2]={};this.IntersectionX(VectorsX,x1,x2,y2);if(VectorsY[x2]==undefined)VectorsY[x2]=
{};this.IntersectionY(VectorsY,y2,y1,x2)}}};CPolygon.prototype.IntersectionX=function(VectorsX,BeginX,EndX,Y){var CurrentVector={};CurrentVector[BeginX]=EndX;var VX=VectorsX[Y];if(BeginX>EndX)while(true==this.IntersectVectorX(CurrentVector,VX));else while(true==this.IntersectVectorX(VX,CurrentVector));for(var X in CurrentVector){var VBeginX=parseInt(X);var VEndX=CurrentVector[VBeginX];if(VBeginX!==VEndX||VX[VBeginX]===undefined)VX[VBeginX]=VEndX}};CPolygon.prototype.IntersectVectorX=function(VectorOpp,
VectorClW){for(var X in VectorOpp){var VBeginX=parseInt(X);var VEndX=VectorOpp[VBeginX];if(VEndX==VBeginX)continue;for(var ClwX in VectorClW){var ClwBeginX=parseInt(ClwX);var ClwEndX=VectorClW[ClwBeginX];var bIntersection=false;if(ClwBeginX==ClwEndX)continue;if(ClwBeginX<=VEndX&&VBeginX<=ClwEndX){VectorOpp[VBeginX]=VBeginX;VectorClW[ClwBeginX]=VEndX;VectorClW[VBeginX]=ClwEndX;bIntersection=true}else if(VEndX<=ClwBeginX&&ClwEndX<=VBeginX){VectorClW[ClwBeginX]=ClwBeginX;VectorOpp[VBeginX]=ClwEndX;VectorOpp[ClwBeginX]=
VEndX;bIntersection=true}else if(ClwBeginX<VEndX&&VEndX<ClwEndX){VectorClW[ClwBeginX]=VEndX;VectorOpp[VBeginX]=ClwEndX;bIntersection=true}else if(ClwBeginX<VBeginX&&VBeginX<ClwEndX){VectorOpp[ClwBeginX]=VEndX;VectorClW[VBeginX]=ClwEndX;delete VectorOpp[VBeginX];delete VectorClW[ClwBeginX];bIntersection=true}if(bIntersection==true)return true}}return false};CPolygon.prototype.IntersectionY=function(VectorsY,BeginY,EndY,X){var bIntersect=false;for(var y in VectorsY[X]){var CurBeginY=parseInt(y);var CurEndY=
VectorsY[X][CurBeginY];var minY,maxY;if(CurBeginY<CurEndY){minY=CurBeginY;maxY=CurEndY}else{minY=CurEndY;maxY=CurBeginY}var bInterSection=!(maxY<=BeginY&&maxY<=EndY||minY>=BeginY&&minY>=EndY),bDirection=(CurBeginY-CurEndY)*(BeginY-EndY)<0;if(bInterSection&&bDirection){VectorsY[X][CurBeginY]=EndY;VectorsY[X][BeginY]=CurEndY;bIntersect=true}}if(bIntersect==false)VectorsY[X][BeginY]=EndY};CPolygon.prototype.GetPaths=function(shift){var Paths=[];shift*=this.precision;for(var PageIndex=0;PageIndex<this.Vectors.length;PageIndex++){var y,
x1,x2,x,y1,y2;var VectorsX=this.Vectors[PageIndex].VX,VectorsY=this.Vectors[PageIndex].VY,Page=this.Vectors[PageIndex].Page;for(var LineIndex in VectorsX)for(var Index in VectorsX[LineIndex]){var Polygon=new CPolygonPath(this.precision);Polygon.Page=Page;y=parseInt(LineIndex);x1=parseInt(Index);x2=VectorsX[y][x1];VectorsX[y][x1]=-1;var Direction=x1>x2?1:-1;var minY=y;var SignRightLeft,SignDownUp;var X,Y;if(x2!==-1){SignRightLeft=x1>x2?1:-1;Y=y-SignRightLeft*shift;Polygon.PushPoint(x1,Y);while(true){x=
x2;y1=y;y2=VectorsY[x][y1];if(y2==-1)break;else if(y2==undefined)return[];VectorsY[x][y1]=-1;SignDownUp=y1>y2?1:-1;X=x+SignDownUp*shift;Polygon.PushPoint(X,Y);y=y2;x1=x;x2=VectorsX[y][x1];if(x2==-1)break;else if(x2==undefined)return[];VectorsX[y][x1]=-1;SignRightLeft=x1>x2?1:-1;Y=y-SignRightLeft*shift;Polygon.PushPoint(X,Y);if(y<minY){minY=y;Direction=x1>x2?1:-1}}Polygon.PushPoint(X,Y);Polygon.CorrectExtremePoints();Polygon.Direction=Direction;Paths.push(Polygon)}}}return Paths};function CMathTrack(){this.MathRect=
{IsActive:false,Bounds:[],ContentSelection:null};this.MathPolygons=[];this.MathSelectPolygons=[]}CMathTrack.prototype.Update=function(IsActive,IsContentActive,oMath,PixelError){this.MathRect.IsActive=IsActive;if(true===IsActive&&null!==oMath){var selectBounds=true===IsContentActive?oMath.Get_ContentSelection():null;if(selectBounds!=null){var SelectPolygon=new CPolygon;SelectPolygon.fill(selectBounds);this.MathSelectPolygons=SelectPolygon.GetPaths(0)}else this.MathSelectPolygons.length=0;var arrBounds=
oMath.Get_Bounds();if(arrBounds.length<=0)return;var MPolygon=new CPolygon;MPolygon.fill(arrBounds);this.MathPolygons=MPolygon.GetPaths(PixelError)}};CMathTrack.prototype.Draw=function(overlay,oPath,shift,color,dKoefX,dKoefY,left,top){var ctx=overlay.m_oContext;ctx.strokeStyle=color;ctx.lineWidth=1;ctx.beginPath();var Points=oPath.Points;var nCount=Points.length;var PrevX=Points[nCount-2].X,PrevY=Points[nCount-2].Y;var _x=left+dKoefX*Points[nCount-2].X,_y=top+dKoefY*Points[nCount-2].Y;var StartX,
StartY;for(var nIndex=0;nIndex<nCount;nIndex++){if(PrevX>Points[nIndex].X)_y=top+dKoefY*Points[nIndex].Y-shift;else if(PrevX<Points[nIndex].X)_y=top+dKoefY*Points[nIndex].Y+shift;if(PrevY<Points[nIndex].Y)_x=left+dKoefX*Points[nIndex].X-shift;else if(PrevY>Points[nIndex].Y)_x=left+dKoefX*Points[nIndex].X+shift;PrevX=Points[nIndex].X;PrevY=Points[nIndex].Y;if(nIndex>0){overlay.CheckPoint(_x,_y);if(1==nIndex){StartX=_x;StartY=_y;overlay.m_oContext.moveTo((_x>>0)+.5,(_y>>0)+.5)}else overlay.m_oContext.lineTo((_x>>
0)+.5,(_y>>0)+.5)}}overlay.m_oContext.lineTo((StartX>>0)+.5,(StartY>>0)+.5);ctx.closePath();ctx.stroke();ctx.beginPath()};CMathTrack.prototype.DrawWithMatrix=function(overlay,oPath,ShiftX,ShiftY,color,dKoefX,dKoefY,left,top,m){var ctx=overlay.m_oContext;ctx.strokeStyle=color;ctx.lineWidth=1;ctx.beginPath();var Points=oPath.Points;var nCount=Points.length;var x=Points[nCount-2].X,y=Points[nCount-2].Y;var _x,_y;var PrevX=Points[nCount-2].X,PrevY=Points[nCount-2].Y;var StartX,StartY;for(var nIndex=0;nIndex<
nCount;nIndex++){if(PrevX>Points[nIndex].X)y=Points[nIndex].Y-ShiftY;else if(PrevX<Points[nIndex].X)y=Points[nIndex].Y+ShiftY;if(PrevY<Points[nIndex].Y)x=Points[nIndex].X-ShiftX;else if(PrevY>Points[nIndex].Y)x=Points[nIndex].X+ShiftX;PrevX=Points[nIndex].X;PrevY=Points[nIndex].Y;if(nIndex>0){_x=left+dKoefX*m.TransformPointX(x,y);_y=top+dKoefY*m.TransformPointY(x,y);overlay.CheckPoint(_x,_y);if(1==nIndex){StartX=_x;StartY=_y;overlay.m_oContext.moveTo((_x>>0)+.5,(_y>>0)+.5)}else overlay.m_oContext.lineTo((_x>>
0)+.5,(_y>>0)+.5)}}overlay.m_oContext.lineTo((StartX>>0)+.5,(StartY>>0)+.5);ctx.closePath();ctx.stroke();ctx.beginPath()};CMathTrack.prototype.DrawSelectPolygon=function(overlay,oPath,dKoefX,dKoefY,left,top,m){var ctx=overlay.m_oContext;ctx.fillStyle="#375082";ctx.beginPath();var Points=oPath.Points;var nPointIndex;var _x,_y,x,y,p;for(nPointIndex=0;nPointIndex<Points.length-1;nPointIndex++){p=Points[nPointIndex];if(!m){_x=left+dKoefX*p.X;_y=top+dKoefY*p.Y}else{x=p.X;y=p.Y;_x=left+dKoefX*m.TransformPointX(x,
y);_y=top+dKoefY*m.TransformPointY(x,y)}overlay.CheckPoint(_x,_y);if(0==nPointIndex)ctx.moveTo((_x>>0)+.5,(_y>>0)+.5);else ctx.lineTo((_x>>0)+.5,(_y>>0)+.5)}ctx.globalAlpha=.2;ctx.fill();ctx.globalAlpha=1};CMathTrack.prototype.IsActive=function(){return this.MathRect.IsActive};CMathTrack.prototype.GetPolygonsCount=function(){return this.MathPolygons.length};CMathTrack.prototype.GetPolygon=function(nIndex){return this.MathPolygons[nIndex]};CMathTrack.prototype.GetSelectPathsCount=function(){return this.MathSelectPolygons.length};
CMathTrack.prototype.GetSelectPath=function(nIndex){return this.MathSelectPolygons[nIndex]};if(!Array.prototype.findIndex)Object.defineProperty(Array.prototype,"findIndex",{value:function(predicate){if(this==null)throw new TypeError("Array.prototype.findIndex called on null or undefined");if(typeof predicate!=="function")throw new TypeError("predicate must be a function");var list=Object(this);var length=list.length>>>0;var thisArg=arguments[1];var value;for(var i=0;i<length;i++){value=list[i];if(predicate.call(thisArg,
value,i,list))return i}return-1}});if(!Array.prototype.fill)Object.defineProperty(Array.prototype,"fill",{value:function(value){if(this==null)throw new TypeError("this is null or not defined");var O=Object(this);var len=O.length>>>0;var start=arguments[1];var relativeStart=start>>0;var k=relativeStart<0?Math.max(len+relativeStart,0):Math.min(relativeStart,len);var end=arguments[2];var relativeEnd=end===undefined?len:end>>0;var final=relativeEnd<0?Math.max(len+relativeEnd,0):Math.min(relativeEnd,len);
while(k<final){O[k]=value;k++}return O}});if(typeof Int8Array!=="undefined"&&!Int8Array.prototype.fill)Int8Array.prototype.fill=Array.prototype.fill;if(typeof Uint8Array!=="undefined"&&!Uint8Array.prototype.fill)Uint8Array.prototype.fill=Array.prototype.fill;if(typeof Uint8ClampedArray!=="undefined"&&!Uint8ClampedArray.prototype.fill)Uint8ClampedArray.prototype.fill=Array.prototype.fill;if(typeof Int16Array!=="undefined"&&!Int16Array.prototype.fill)Int16Array.prototype.fill=Array.prototype.fill;if(typeof Uint16Array!==
"undefined"&&!Uint16Array.prototype.fill)Uint16Array.prototype.fill=Array.prototype.fill;if(typeof Int32Array!=="undefined"&&!Int32Array.prototype.fill)Int32Array.prototype.fill=Array.prototype.fill;if(typeof Uint32Array!=="undefined"&&!Uint32Array.prototype.fill)Uint32Array.prototype.fill=Array.prototype.fill;if(typeof Float32Array!=="undefined"&&!Float32Array.prototype.fill)Float32Array.prototype.fill=Array.prototype.fill;if(typeof Float64Array!=="undefined"&&!Float64Array.prototype.fill)Float64Array.prototype.fill=
Array.prototype.fill;if(typeof Uint8Array!=="undefined"&&!Uint8Array.prototype.slice)Uint8Array.prototype.slice=Array.prototype.slice;function parseText(text,options,bTrimSpaces){var delimiterChar;if(options.asc_getDelimiterChar())delimiterChar=options.asc_getDelimiterChar();else switch(options.asc_getDelimiter()){case AscCommon.c_oAscCsvDelimiter.None:delimiterChar=undefined;break;case AscCommon.c_oAscCsvDelimiter.Tab:delimiterChar="\t";break;case AscCommon.c_oAscCsvDelimiter.Semicolon:delimiterChar=
";";break;case AscCommon.c_oAscCsvDelimiter.Colon:delimiterChar=":";break;case AscCommon.c_oAscCsvDelimiter.Comma:delimiterChar=",";break;case AscCommon.c_oAscCsvDelimiter.Space:delimiterChar=" ";break}var matrix=[];var rows=text.split(/\r?\n/);for(var i=0;i<rows.length;++i){var row=rows[i];if(" "===delimiterChar&&bTrimSpaces){var addSpace=false;if(row[0]===delimiterChar)addSpace=true;row=addSpace?delimiterChar+row.trim():row.trim()}matrix.push(row.split(delimiterChar))}return matrix}function getTimeISO8601(dateStr){if(dateStr)if(dateStr.endsWith("Z"))return Date.parse(dateStr);
else return Date.parse(dateStr+"Z");return NaN}function valueToMmType(value){var oVal=parseFloat(value);var oType;if(!isNaN(oVal)){if(-1!==value.indexOf("%")){oType="%";oVal/=100}else if(-1!==value.indexOf("px")){oType="px";oVal*=AscCommon.g_dKoef_pix_to_mm}else if(-1!==value.indexOf("in")){oType="in";oVal*=AscCommonWord.g_dKoef_in_to_mm}else if(-1!==value.indexOf("cm")){oType="cm";oVal*=10}else if(-1!==value.indexOf("mm"))oType="mm";else if(-1!==value.indexOf("pt")){oType="pt";oVal*=AscCommonWord.g_dKoef_pt_to_mm}else if(-1!==
value.indexOf("pc")){oType="pc";oVal*=AscCommonWord.g_dKoef_pc_to_mm}else oType="none";return{val:oVal,type:oType}}return null}function valueToMm(value){var obj=valueToMmType(value);if(obj&&"%"!==obj.type&&"none"!==obj.type)return obj.val;return null}function arrayMove(array,from,to){array.splice(to,0,array.splice(from,1)[0])}function getRangeArray(start,stop){var res=new Array(stop-start);for(var i=start;i<stop;++i)res[i-start]=i;return res}var g_oBackoffDefaults={retries:2,factor:2,minTimeout:100,
maxTimeout:2E3,randomize:true};function Backoff(opts){this.attempts=0;this.opts=opts}Backoff.prototype.attempt=function(fError,fRetry){var timeout=this.nextTimeout();if(timeout>0)setTimeout(function(){fRetry()},timeout);else fError()};Backoff.prototype.nextTimeout=function(){var timeout=-1;if(this.attempts<this.opts.retries){timeout=this.createTimeout(this.attempts,this.opts);this.attempts++}return timeout};Backoff.prototype.createTimeout=function(attempt,opts){var random=opts.randomize?Math.random()+
1:1;var timeout=Math.round(random*opts.minTimeout*Math.pow(opts.factor,attempt));timeout=Math.min(timeout,opts.maxTimeout);return timeout};function backoffOnError(obj,onError,onRetry){if(!onRetry)return onError;var backoff=new Backoff(g_oBackoffDefaults);return function(){var timeout=backoff.nextTimeout();if(timeout>0)setTimeout(function(){onRetry.call(obj,obj)},timeout);else if(onError)onError.apply(obj,arguments)}}function backoffOnErrorImg(img,onRetry){if(!onRetry)onRetry=function(img){img.setAttribute("src",
img.getAttribute("src"))};img.onerror=backoffOnError(img,img.onerror,onRetry)}function isEmptyObject(obj){for(var name in obj)return false;return true}window["AscCommon"]=window["AscCommon"]||{};window["AscCommon"].getSockJs=getSockJs;window["AscCommon"].getJSZipUtils=getJSZipUtils;window["AscCommon"].getJSZip=getJSZip;window["AscCommon"].getBaseUrl=getBaseUrl;window["AscCommon"].getEncodingParams=getEncodingParams;window["AscCommon"].getEncodingByBOM=getEncodingByBOM;window["AscCommon"].saveWithParts=
saveWithParts;window["AscCommon"].loadFileContent=loadFileContent;window["AscCommon"].getImageFromChanges=getImageFromChanges;window["AscCommon"].openFileCommand=openFileCommand;window["AscCommon"].sendCommand=sendCommand;window["AscCommon"].sendSaveFile=sendSaveFile;window["AscCommon"].mapAscServerErrorToAscError=mapAscServerErrorToAscError;window["AscCommon"].joinUrls=joinUrls;window["AscCommon"].getFullImageSrc2=getFullImageSrc2;window["AscCommon"].fSortAscending=fSortAscending;window["AscCommon"].fSortDescending=
fSortDescending;window["AscCommon"].isLeadingSurrogateChar=isLeadingSurrogateChar;window["AscCommon"].decodeSurrogateChar=decodeSurrogateChar;window["AscCommon"].encodeSurrogateChar=encodeSurrogateChar;window["AscCommon"].convertUnicodeToUTF16=convertUnicodeToUTF16;window["AscCommon"].convertUTF16toUnicode=convertUTF16toUnicode;window["AscCommon"].build_local_rx=build_local_rx;window["AscCommon"].GetFileName=GetFileName;window["AscCommon"].GetFileExtension=GetFileExtension;window["AscCommon"].changeFileExtention=
changeFileExtention;window["AscCommon"].getExtentionByFormat=getExtentionByFormat;window["AscCommon"].InitOnMessage=InitOnMessage;window["AscCommon"].ShowImageFileDialog=ShowImageFileDialog;window["AscCommon"].ShowDocumentFileDialog=ShowDocumentFileDialog;window["AscCommon"].InitDragAndDrop=InitDragAndDrop;window["AscCommon"].UploadImageFiles=UploadImageFiles;window["AscCommon"].UploadImageUrls=UploadImageUrls;window["AscCommon"].CanDropFiles=CanDropFiles;window["AscCommon"].getUrlType=getUrlType;
window["AscCommon"].prepareUrl=prepareUrl;window["AscCommon"].getUserColorById=getUserColorById;window["AscCommon"].isNullOrEmptyString=isNullOrEmptyString;window["AscCommon"].unleakString=unleakString;window["AscCommon"].readValAttr=readValAttr;window["AscCommon"].getNumFromXml=getNumFromXml;window["AscCommon"].getColorFromXml=getColorFromXml;window["AscCommon"].getBoolFromXml=getBoolFromXml;window["AscCommon"].initStreamFromResponse=initStreamFromResponse;window["AscCommon"].checkStreamSignature=
checkStreamSignature;window["AscCommon"].DocumentUrls=DocumentUrls;window["AscCommon"].OpenFileResult=OpenFileResult;window["AscCommon"].CLock=CLock;window["AscCommon"].CContentChanges=CContentChanges;window["AscCommon"].CContentChangesElement=CContentChangesElement;window["AscCommon"].CorrectMMToTwips=CorrectMMToTwips;window["AscCommon"].TwipsToMM=TwipsToMM;window["AscCommon"].MMToTwips=MMToTwips;window["AscCommon"].RomanToInt=RomanToInt;window["AscCommon"].LatinNumberingToInt=LatinNumberingToInt;
window["AscCommon"].IntToNumberFormat=IntToNumberFormat;window["AscCommon"].IsSpace=IsSpace;window["AscCommon"].loadSdk=loadSdk;window["AscCommon"].loadScript=loadScript;window["AscCommon"].getAltGr=getAltGr;window["AscCommon"].getColorSchemeByName=getColorSchemeByName;window["AscCommon"].getColorSchemeByIdx=getColorSchemeByIdx;window["AscCommon"].getAscColorScheme=getAscColorScheme;window["AscCommon"].checkAddColorScheme=checkAddColorScheme;window["AscCommon"].getIndexColorSchemeInArray=getIndexColorSchemeInArray;
window["AscCommon"].isEastAsianScript=isEastAsianScript;window["AscCommon"].CMathTrack=CMathTrack;window["AscCommon"].CPolygon=CPolygon;window["AscCommon"].JSZipWrapper=JSZipWrapper;window["AscCommon"].g_oDocumentUrls=g_oDocumentUrls;window["AscCommon"].FormulaTablePartInfo=FormulaTablePartInfo;window["AscCommon"].cBoolLocal=cBoolLocal;window["AscCommon"].cErrorOrigin=cErrorOrigin;window["AscCommon"].cErrorLocal=cErrorLocal;window["AscCommon"].FormulaSeparators=FormulaSeparators;window["AscCommon"].rx_space_g=
rx_space_g;window["AscCommon"].rx_space=rx_space;window["AscCommon"].rx_defName=rx_defName;window["AscCommon"].kCurFormatPainterWord=kCurFormatPainterWord;window["AscCommon"].parserHelp=parserHelp;window["AscCommon"].g_oIdCounter=g_oIdCounter;window["AscCommon"].g_oHtmlCursor=g_oHtmlCursor;window["AscCommon"].g_oBackoffDefaults=g_oBackoffDefaults;window["AscCommon"].Backoff=Backoff;window["AscCommon"].backoffOnErrorImg=backoffOnErrorImg;window["AscCommon"].isEmptyObject=isEmptyObject;window["AscCommon"].CSignatureDrawer=
window["AscCommon"]["CSignatureDrawer"]=CSignatureDrawer;var prot=CSignatureDrawer.prototype;prot["getImages"]=prot.getImages;prot["setText"]=prot.setText;prot["selectImage"]=prot.selectImage;prot["isValid"]=prot.isValid;prot["destroy"]=prot.destroy;window["AscCommon"].translateManager=new CTranslateManager;window["AscCommon"].parseText=parseText;window["AscCommon"].getTimeISO8601=getTimeISO8601;window["AscCommon"].valueToMm=valueToMm;window["AscCommon"].valueToMmType=valueToMmType;window["AscCommon"].arrayMove=
arrayMove;window["AscCommon"].getRangeArray=getRangeArray;window["AscCommon"].CUnicodeStringEmulator=CUnicodeStringEmulator;window["AscCommon"].private_IsAbbreviation=private_IsAbbreviation;window["AscCommon"].rx_test_ws_name=rx_test_ws_name;window["AscCommon"].CShortcuts=window["AscCommon"]["CShortcuts"]=CShortcuts;prot=CShortcuts.prototype;prot["Add"]=prot.Add;prot["Get"]=prot.Get;prot["CheckType"]=prot.CheckType;prot["Remove"]=prot.Remove;prot["RemoveByType"]=prot.RemoveByType;prot["GetNewCustomType"]=
prot.GetNewCustomType;prot["IsCustomType"]=prot.IsCustomType;prot["GetCustomAction"]=prot.GetCustomAction;prot["AddCustomActionSymbol"]=prot.AddCustomActionSymbol;window["AscCommon"].CCustomShortcutActionSymbol=window["AscCommon"]["CCustomShortcutActionSymbol"]=CCustomShortcutActionSymbol})(window);
nCharCode<=40959||13312<=nCharCode&&nCharCode<=19903||131072<=nCharCode&&nCharCode<=173791||173824<=nCharCode&&nCharCode<=177983||177984<=nCharCode&&nCharCode<=178207||178208<=nCharCode&&nCharCode<=183983||63744<=nCharCode&&nCharCode<=64255||194560<=nCharCode&&nCharCode<=195103)return false}return true}return false}var g_oUserColorById={},g_oUserNextColorIndex=0;function getUserColorById(userId,userName,isDark,isNumericValue){if(window.parent.APP&&window.parent.APP.getUserColor)try{var CPColor=window.parent.APP.getUserColor(userId);
if(CPColor)return true===isNumericValue?CPColor.r<<16&16711680|CPColor.g<<8&65280|CPColor.b&255:CPColor}catch(e){}if((!userId||""===userId)&&(!userName||""===userName))return new CColor(0,0,0,255);var res;if(g_oUserColorById.hasOwnProperty(userId))res=g_oUserColorById[userId];else if(g_oUserColorById.hasOwnProperty(userName))res=g_oUserColorById[userName];else{var nColor=Asc.c_oAscArrUserColors[g_oUserNextColorIndex%Asc.c_oAscArrUserColors.length];++g_oUserNextColorIndex;res=g_oUserColorById[userId||
userName]=new CUserCacheColor(nColor)}if(!res)return new CColor(0,0,0,255);var oColor=true===isDark?res.Dark:res.Light;return true===isNumericValue?oColor.r<<16&16711680|oColor.g<<8&65280|oColor.b&255:oColor}function isNullOrEmptyString(str){return str==undefined||str==null||str==""}function unleakString(s){return(" "+s).substr(1)}function readValAttr(attr){if(attr()){var val=attr()["val"];return val?val:null}return null}function getNumFromXml(val){return val?val-0:null}function getColorFromXml(attr){if(attr()){var vals=
attr();if(null!=vals["theme"])return AscCommonExcel.g_oColorManager.getThemeColor(getNumFromXml(vals["theme"]),getNumFromXml(vals["tint"]));else if(null!=vals["rgb"])return new AscCommonExcel.RgbColor(16777215&getNumFromXml(vals["rgb"]))}return null}function getBoolFromXml(val){return"0"!==val&&"false"!==val&&"off"!==val}function CUserCacheColor(nColor){this.Light=null;this.Dark=null;this.init(nColor)}CUserCacheColor.prototype.init=function(nColor){var r=nColor>>16&255;var g=nColor>>8&255;var b=nColor&
255;var Y=Math.max(0,Math.min(255,.299*r+.587*g+.114*b));var Cb=Math.max(0,Math.min(255,128-.168736*r-.331264*g+.5*b));var Cr=Math.max(0,Math.min(255,128+.5*r-.418688*g-.081312*b));if(Y>63)Y=63;var R=Math.max(0,Math.min(255,Y+1.402*(Cr-128)))|0;var G=Math.max(0,Math.min(255,Y-.34414*(Cb-128)-.71414*(Cr-128)))|0;var B=Math.max(0,Math.min(255,Y+1.772*(Cb-128)))|0;this.Light=new CColor(r,g,b,255);this.Dark=new CColor(R,G,B,255)};function loadScript(url,onSuccess,onError){if(window["NATIVE_EDITOR_ENJINE"]===
true||window["Native"]!==undefined){onSuccess();return}if(window["AscDesktopEditor"]&&window["local_load_add"]){var _context={"completeLoad":function(){return onSuccess()}};window["local_load_add"](_context,"sdk-all-from-min",url);var _ret_param=window["AscDesktopEditor"]["LoadJS"](url);if(2!=_ret_param)window["local_load_remove"](url);if(_ret_param==1){setTimeout(onSuccess,1);return}else if(_ret_param==2)return}var backoff=new AscCommon.Backoff(AscCommon.g_oBackoffDefaults);loadScriptWithBackoff(backoff,
url,onSuccess,onError)}function loadScriptWithBackoff(backoff,url,onSuccess,onError){var script=document.createElement("script");script.type="text/javascript";script.src=url;script.onload=onSuccess;script.onerror=function(){backoff.attempt(onError,function(){loadScriptWithBackoff(backoff,url,onSuccess,onError)})};document.head.appendChild(script)}function loadSdk(sdkName,onSuccess,onError){if(window["AscNotLoadAllScript"])onSuccess();else{var urlArgs=window.parent&&window.parent.APP&&window.parent.APP.urlArgs||
"";loadScript("./../../../../sdkjs/"+sdkName+"/sdk-all.js?"+urlArgs,onSuccess,onError)}}function getAltGr(e){var ctrlKey=e.metaKey||e.ctrlKey;var altKey=e.altKey;return altKey&&(AscBrowser.isMacOs?!ctrlKey:ctrlKey)}function getColorSchemeByName(sName){for(var i=0;i<AscCommon.g_oUserColorScheme.length;++i){var tmp=AscCommon.g_oUserColorScheme[i];if(tmp&&tmp.name===sName)return getColorSchemeByIdx(i)}return null}function getColorSchemeByIdx(idx){var tmp=AscCommon.g_oUserColorScheme[idx];if(tmp){var scheme=
new AscFormat.ClrScheme,_c;scheme.name=tmp.name;_c=tmp.get_dk1();scheme.colors[8]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_lt1();scheme.colors[12]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_dk2();scheme.colors[9]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_lt2();scheme.colors[13]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent1();scheme.colors[0]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent2();scheme.colors[1]=AscFormat.CreateUniColorRGB(_c.r,
_c.g,_c.b);_c=tmp.get_accent3();scheme.colors[2]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent4();scheme.colors[3]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent5();scheme.colors[4]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_accent6();scheme.colors[5]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_hlink();scheme.colors[11]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);_c=tmp.get_folHlink();scheme.colors[10]=AscFormat.CreateUniColorRGB(_c.r,_c.g,_c.b);
return scheme}return null}function getAscColorScheme(_scheme,theme){var elem,_c;var _rgba={R:0,G:0,B:0,A:255};elem=new AscCommon.CAscColorScheme;elem.scheme=_scheme;elem.name=_scheme.name;_scheme.colors[8].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[8].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[12].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[12].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[9].Calculate(theme,null,null,
null,_rgba);_c=_scheme.colors[9].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[13].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[13].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[0].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[0].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[1].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[1].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[2].Calculate(theme,
null,null,null,_rgba);_c=_scheme.colors[2].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[3].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[3].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[4].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[4].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[5].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[5].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));
_scheme.colors[11].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[11].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));_scheme.colors[10].Calculate(theme,null,null,null,_rgba);_c=_scheme.colors[10].RGBA;elem.putColor(new AscCommon.CColor(_c.R,_c.G,_c.B));return elem}function getIndexColorSchemeInArray(result,asc_color_scheme){for(var j=0;j<result.length;++j)if(result[j].isEqual(asc_color_scheme))return j;return-1}function checkAddColorScheme(result,asc_color_scheme,nStartIndex){var nIndex=
getIndexColorSchemeInArray(result,asc_color_scheme);if(nIndex>-1)return nIndex;var nStartIndex_=nStartIndex;if(nStartIndex===null)nStartIndex_=result.length;result.splice(nStartIndex_,0,asc_color_scheme);return nStartIndex_}function isEastAsianScript(value){return 12544<=value&&value<=12591||12704<=value&&value<=12735||19968<=value&&value<=40938||13312<=value&&value<=19893||131072<=value&&value<=173782||173824<=value&&value<=177972||177984<=value&&value<=178205||178208<=value&&value<=183969||183984<=
value&&value<=191456||63744<=value&&value<=64255||194560<=value&&value<=195103||12032<=value&&value<=12255||11904<=value&&value<=12031||12736<=value&&value<=12783||12272<=value&&value<=12287||4352<=value&&value<=4607||43360<=value&&value<=43391||55216<=value&&value<=55295||12592<=value&&value<=12687||65280<=value&&value<=65519||44032<=value&&value<=55215||12352<=value&&value<=12447||110848<=value&&value<=110895||110592<=value&&value<=110847||12688<=value&&value<=12703||12448<=value&&value<=12543||
12784<=value&&value<=12799||42192<=value&&value<=42239||93952<=value&&value<=94111||110960<=value&&value<=111359||94208<=value&&value<=100332||100352<=value&&value<=101119||40960<=value&&value<=42127||42128<=value&&value<=42191}var g_oIdCounter=new CIdCounter;window.Asc.g_signature_drawer=null;function CSignatureDrawer(id,api,w,h){window.Asc.g_signature_drawer=this;this.Api=api;this.CanvasParent=document.getElementById(id);this.Canvas=document.createElement("canvas");this.Canvas.style.position="absolute";
this.Canvas.style.left="0px";this.Canvas.style.top="0px";var _width=parseInt(this.CanvasParent.offsetWidth);var _height=parseInt(this.CanvasParent.offsetHeight);if(0==_width)_width=300;if(0==_height)_height=80;this.Canvas.width=_width;this.Canvas.height=_height;this.CanvasParent.appendChild(this.Canvas);this.Image="";this.ImageHtml=null;this.Text="";this.Font="Arial";this.Size=10;this.Italic=true;this.Bold=false;this.Width=w;this.Height=h;this.CanvasReturn=null;this.IsAsync=false}CSignatureDrawer.prototype.getCanvas=
function(){return this.CanvasReturn==null?this.Canvas:this.CanvasReturn};CSignatureDrawer.prototype.getImages=function(){if(!this.isValid())return["",""];this.CanvasReturn=document.createElement("canvas");this.CanvasReturn.width=this.Width*AscCommon.g_dKoef_mm_to_pix;this.CanvasReturn.height=this.Height*AscCommon.g_dKoef_mm_to_pix;if(this.Text!="")this.drawText();else this.drawImage();var _ret=[];_ret.push(this.CanvasReturn.toDataURL("image/png"));var _ctx=this.CanvasReturn.getContext("2d");_ctx.strokeStyle=
"#FF0000";_ctx.lineWidth=2;_ctx.moveTo(0,0);_ctx.lineTo(this.CanvasReturn.width,this.CanvasReturn.height);_ctx.moveTo(0,this.CanvasReturn.height);_ctx.lineTo(this.CanvasReturn.width,0);_ctx.stroke();_ret.push(this.CanvasReturn.toDataURL("image/png"));this.CanvasReturn=null;return _ret};CSignatureDrawer.prototype.setText=function(text,font,size,isItalic,isBold){if(this.IsAsync){this.Text=text;return}this.Image="";this.ImageHtml=null;this.Text=text;this.Font=font;this.Size=size;this.Italic=isItalic;
this.Bold=isBold;this.IsAsync=true;AscFonts.FontPickerByCharacter.checkText(this.Text,this,function(){this.IsAsync=false;var loader=AscCommon.g_font_loader;var fontinfo=AscFonts.g_fontApplication.GetFontInfo(font);var isasync=loader.LoadFont(fontinfo,function(){window.Asc.g_signature_drawer.Api.sync_EndAction(Asc.c_oAscAsyncActionType.Information,Asc.c_oAscAsyncAction.LoadFont);window.Asc.g_signature_drawer.drawText()});if(false===isasync)this.drawText()})};CSignatureDrawer.prototype.drawText=function(){var _oldTurn=
this.Api.isViewMode;var _oldMarks=this.Api.ShowParaMarks;this.Api.isViewMode=true;this.Api.ShowParaMarks=false;AscFormat.ExecuteNoHistory(AscCommon.DrawTextByCenter,this,[]);this.Api.isViewMode=_oldTurn;this.Api.ShowParaMarks=_oldMarks};CSignatureDrawer.prototype.drawImage=function(){var _canvas=this.getCanvas();var w=_canvas.width;var h=_canvas.height;var _ctx=_canvas.getContext("2d");_ctx.clearRect(0,0,w,h);var im_w=this.ImageHtml.width;var im_h=this.ImageHtml.height;var _x=0;var _y=0;var _w=0;
var _h=0;var koef1=w/h;var koef2=im_w/im_h;if(koef1>koef2){_h=h;_w=koef2*_h>>0;_y=0;_x=w-_w>>1}else{_w=w;_h=_w/koef2>>0;_x=0;_y=h-_h>>1}_ctx.drawImage(this.ImageHtml,_x,_y,_w,_h)};CSignatureDrawer.prototype.selectImage=CSignatureDrawer.prototype["selectImage"]=function(){this.Text="";window["AscDesktopEditor"]["OpenFilenameDialog"]("images",false,function(_file){var file=_file;if(Array.isArray(file))file=file[0];if(!file)return;var _drawer=window.Asc.g_signature_drawer;_drawer.Image=window["AscDesktopEditor"]["GetImageBase64"](file);
_drawer.ImageHtml=new Image;_drawer.ImageHtml.onload=function(){window.Asc.g_signature_drawer.drawImage()};_drawer.ImageHtml.src=_drawer.Image;_drawer=null})};CSignatureDrawer.prototype.isValid=function(){return this.Image!=""||this.Text!=""};CSignatureDrawer.prototype.destroy=function(){window.Asc.g_signature_drawer.CanvasParent.removeChild(this.Canvas);delete window.Asc.g_signature_drawer};function CSignatureImage(){this.ImageValidBase64="";this.ImageInvalidBase64="";this.ImageValid=null;this.ImageInvalid=
null;this.Valid=false;this.Loading=0;this.Remove=function(){this.ImageValidBase64="";this.ImageInvalidBase64="";this.ImageValid=null;this.ImageInvalid=null;this.Valid=false;this.Loading=0};this.Register=function(_api,_guid){if(_api.ImageLoader.map_image_index[_guid])return;var _obj={Image:this.Valid?this.ImageValid:this.ImageInvalid,Status:AscFonts.ImageLoadStatus.Complete,src:_guid};_api.ImageLoader.map_image_index[_guid]=_obj};this.Unregister=function(_api,_guid){if(_api.ImageLoader.map_image_index[_guid])delete _api.ImageLoader.map_image_index[_guid]}}
function CShortcuts(){this.List={};this.CustomCounter=0;this.CustomActions={}}CShortcuts.prototype.Add=function(nType,nCode,isCtrl,isShift,isAlt){this.List[this.private_GetIndex(nCode,isCtrl,isShift,isAlt)]=nType};CShortcuts.prototype.Get=function(nCode,isCtrl,isShift,isAlt){var nType=this.List[this.private_GetIndex(nCode,isCtrl,isShift,isAlt)];return undefined!==nType?nType:0};CShortcuts.prototype.private_GetIndex=function(nCode,isCtrl,isShift,isAlt){return nCode<<8|(isCtrl?4:0)|(isShift?2:0)|(isAlt?
1:0)};CShortcuts.prototype.CheckType=function(nType){for(var nIndex in this.List)if(this.List[nIndex]===nType)return{KeyCode:nIndex>>>8,CtrlKey:!!(nIndex&4),ShiftKey:!!(nIndex&2),AltKey:!!(nIndex&1)};return null};CShortcuts.prototype.Remove=function(nCode,isCtrl,isShift,isAlt){delete this.List[this.private_GetIndex(nCode,isCtrl,isShift,isAlt)]};CShortcuts.prototype.RemoveByType=function(nType){for(var nIndex in this.List)if(this.List[nIndex]===nType)delete this.List[nIndex]};CShortcuts.prototype.GetNewCustomType=
function(){return 16711680|this.CustomCounter++};CShortcuts.prototype.IsCustomType=function(nType){return nType>=16711680};CShortcuts.prototype.GetCustomAction=function(nType){return this.CustomActions[nType]};CShortcuts.prototype.AddCustomActionSymbol=function(nCharCode,sFont){var nType=this.GetNewCustomType();this.CustomActions[nType]=new CCustomShortcutActionSymbol(nCharCode,sFont);return nType};function CCustomShortcutActionSymbol(nCharCode,sFont){this.CharCode=nCharCode;this.Font=sFont}CCustomShortcutActionSymbol.prototype.Type=
AscCommon.c_oAscCustomShortcutType.Symbol;AscCommon.EncryptionMessageType={Encrypt:0,Decrypt:1};function CEncryptionData(){this._init=false;this.arrData=[];this.arrImages=[];this.handleChangesCallback=null;this.isChangesHandled=false;this.cryptoMode=0;this.isChartEditor=false;this.isExistDecryptedChanges=false;this.cryptoPrefix=window["AscDesktopEditor"]&&window["AscDesktopEditor"]["GetEncryptedHeader"]?window["AscDesktopEditor"]["GetEncryptedHeader"]():"ENCRYPTED;";this.cryptoPrefixLen=this.cryptoPrefix.length;
this.editorId=null;this.nextChangesTimeoutId=-1;this.isPasswordCryptoPresent=false;this.init=function(){this._init=true};this.isInit=function(){return this._init};this.isNeedCrypt=function(){if(window.g_asc_plugins)if(!window.g_asc_plugins.isRunnedEncryption())return false;if(!window["AscDesktopEditor"])return false;if(this.isChartEditor)return false;if(2==this.cryptoMode)return true;if(0===window["AscDesktopEditor"]["CryptoMode"])return false;return true};this.isCryptoImages=function(){return this.isNeedCrypt()&&
this.isPasswordCryptoPresent};this.addCryproImagesFromDialog=function(callback){var _this=this;window["AscDesktopEditor"]["OpenFilenameDialog"]("images",true,function(files){if(!files)return;if(!Array.isArray(files))files=[files];if(0===files.length)return;var _files=[];var _options={isImageCrypt:true,callback:callback,ext:[]};for(var i=0;i<files.length;i++){_files.push(window["AscDesktopEditor"]["GetImageBase64"](files[i],true));_options.ext.push(AscCommon.GetFileExtension(files[i]))}_this.sendChanges(this,
_files,AscCommon.EncryptionMessageType.Encrypt,_options)})};this.addCryproImagesFromUrls=function(urls,callback){var _editor=window["Asc"]["editor"]?window["Asc"]["editor"]:window.editor;_editor.sync_StartAction(Asc.c_oAscAsyncActionType.BlockInteraction,Asc.c_oAscAsyncAction.LoadImage);var _this=this;window["AscDesktopEditor"]["DownloadFiles"](urls,[],function(files){_editor.sync_EndAction(Asc.c_oAscAsyncActionType.BlockInteraction,Asc.c_oAscAsyncAction.LoadImage);_editor.sync_StartAction(Asc.c_oAscAsyncActionType.BlockInteraction,
Asc.c_oAscAsyncAction.UploadImage);var _files=[];var _options={isImageCrypt:true,isUrls:true,callback:callback,ext:[],api:_editor};for(var elem in files){_files.push(window["AscDesktopEditor"]["GetImageBase64"](files[elem],true));_options.ext.push(window["AscDesktopEditor"]["GetImageFormat"](files[elem]));window["AscDesktopEditor"]["RemoveFile"](files[elem])}_this.sendChanges(this,_files,AscCommon.EncryptionMessageType.Encrypt,_options)})};this.onDecodeError=function(){var _editor=window["Asc"]["editor"]?
window["Asc"]["editor"]:window.editor;_editor.sendEvent("asc_onError",Asc.c_oAscError.ID.DataEncrypted,Asc.c_oAscError.Level.Critical)};this.checkEditorId=function(){if(null==this.editorId){var _editor=window["Asc"]["editor"]?window["Asc"]["editor"]:window.editor;this.editorId=_editor.editorId}};this.decryptImage=function(src,img,data){this.sendChanges(this,[data],AscCommon.EncryptionMessageType.Decrypt,{isImageDecrypt:true,src:src,img:img})};this.nextChanges=function(){this.nextChangesTimeoutId=
setTimeout(function(){AscCommon.EncryptionWorker.sendChanges(undefined,undefined);this.nextChangesTimeoutId=-1},10)};this.sendChanges=function(sender,data,type,options){if(!this.isNeedCrypt()){if(AscCommon.EncryptionMessageType.Encrypt==type)sender._send(data,true);else if(AscCommon.EncryptionMessageType.Decrypt==type){if(this.isExistEncryptedChanges(data["changes"])){this.onDecodeError();return}sender._onSaveChanges(data,true)}return}if(undefined!==type)this.arrData.push({sender:sender,type:type,
data:data,options:options});if(this.arrData.length==0)return;if(undefined!==type&&(1!=this.arrData.length||!this.isChangesHandled))return;if(undefined!==type&&-1!=this.nextChangesTimeoutId){clearTimeout(this.nextChangesTimeoutId);this.nextChangesTimeoutId=-1}if(AscCommon.EncryptionMessageType.Encrypt==this.arrData[0].type)if(this.arrData[0].options&&this.arrData[0].options.isImageCrypt)window.g_asc_plugins.sendToEncryption({"type":"encryptData","data":this.arrData[0].data});else window.g_asc_plugins.sendToEncryption({"type":"encryptData",
"data":JSON.parse(this.arrData[0].data["changes"])});else if(AscCommon.EncryptionMessageType.Decrypt==this.arrData[0].type)if(this.arrData[0].options&&this.arrData[0].options.isImageDecrypt)window.g_asc_plugins.sendToEncryption({"type":"decryptData","data":this.arrData[0].data});else window.g_asc_plugins.sendToEncryption({"type":"decryptData","data":this.arrData[0].data["changes"]})};this.receiveChanges=function(obj){var data=obj["data"];var check=obj["check"];if(!check){this.onDecodeError();return}if(this.handleChangesCallback){this.isExistDecryptedChanges=
true;this.checkEditorId();if(this.editorId==AscCommon.c_oEditorId.Spreadsheet)for(var i=data.length-1;i>=0;i--)this.handleChangesCallback.changesBase[i]=data[i];else for(var i=data.length-1;i>=0;i--)this.handleChangesCallback.changesBase[i].m_pData=data[i];this.isChangesHandled=true;this.handleChangesCallback.callback.call(this.handleChangesCallback.sender);this.handleChangesCallback=null;this.nextChanges();return}var obj=this.arrData[0];this.arrData.splice(0,1);if(AscCommon.EncryptionMessageType.Encrypt==
obj.type)if(obj.options&&obj.options.isImageCrypt){for(var i=0;i<data.length;i++)if(this.cryptoPrefix==data[i].substr(0,this.cryptoPrefixLen))data[i]=this.cryptoPrefix+obj.options.ext[i]+";"+data[i].substr(this.cryptoPrefixLen);if(!obj.options.isUrls)obj.options.callback(Asc.c_oAscError.ID.No,data);else AscCommon.UploadImageUrls(data,obj.options.api.documentId,obj.options.api.documentUserId,obj.options.api.CoAuthoringApi.get_jwt(),function(urls){obj.options.api.sync_EndAction(Asc.c_oAscAsyncActionType.BlockInteraction,
Asc.c_oAscAsyncAction.UploadImage);obj.options.callback(urls)})}else{obj.data["changes"]=JSON.stringify(data);obj.sender._send(obj.data,true)}else if(AscCommon.EncryptionMessageType.Decrypt==obj.type)if(obj.options&&obj.options.isImageDecrypt){window["AscDesktopEditor"]["ResaveFile"](obj.options.src,data[0]);obj.options.img["onload_crypto"](obj.options.src)}else{this.isExistDecryptedChanges=true;obj.data["changes"]=data;obj.sender._onSaveChanges(obj.data,true)}this.nextChanges()};this.isExistEncryptedChanges=
function(_array){if(0==_array.length)return false;this.checkEditorId();var isChangesMode=_array[0]["change"]?true:false;var _prefix="";var _checkPrefixLen=this.cryptoPrefixLen+1;if(isChangesMode){for(var i=_array.length-1;i>=0;i--)if(_array[i]["change"].length>_checkPrefixLen){_prefix=_array[i]["change"].substr(0,_checkPrefixLen);if(-1!=_prefix.indexOf(this.cryptoPrefix)){isCrypted=true;break}}return isCrypted}var isCrypted=false;if(this.editorId==AscCommon.c_oEditorId.Spreadsheet)for(var i=_array.length-
1;i>=0;i--){if(_array[i].length>_checkPrefixLen){_prefix=_array[i].substr(0,_checkPrefixLen);if(-1!=_prefix.indexOf(this.cryptoPrefix)){isCrypted=true;break}}}else for(var i=_array.length-1;i>=0;i--)if(_array[i].m_pData.length>_checkPrefixLen){_prefix=_array[i].m_pData.substr(0,_checkPrefixLen);if(-1!=_prefix.indexOf(this.cryptoPrefix)){isCrypted=true;break}}return isCrypted};this.handleChanges=function(_array,_sender,_callback){if(0==_array.length||!this.isNeedCrypt()){if(this.isExistEncryptedChanges(_array)){this.onDecodeError();
return}this.isChangesHandled=true;_callback.call(_sender);return}this.handleChangesCallback={changesBase:_array,changes:[],sender:_sender,callback:_callback};this.checkEditorId();if(this.editorId==AscCommon.c_oEditorId.Spreadsheet)for(var i=_array.length-1;i>=0;i--)this.handleChangesCallback.changes[i]=_array[i];else for(var i=_array.length-1;i>=0;i--)this.handleChangesCallback.changes[i]=_array[i].m_pData;window.g_asc_plugins.sendToEncryption({"type":"decryptData","data":this.handleChangesCallback.changes})};
this.asc_setAdvancedOptions=function(api,idOption,option){if(window.isNativeOpenPassword){window["AscDesktopEditor"]["NativeViewerOpen"](option.asc_getPassword());return}if(window.isCloudCryptoDownloadAs)return false;if(!this.isNeedCrypt())return false;window.checkPasswordFromPlugin=true;if(window["Asc"].c_oAscAdvancedOptionsID.TXT===idOption){var _param="<m_nCsvTxtEncoding>"+option.asc_getCodePage()+"</m_nCsvTxtEncoding>";window["AscDesktopEditor"]["SetAdvancedOptions"](_param)}else if(window["Asc"].c_oAscAdvancedOptionsID.CSV===
idOption){var delimiter=option.asc_getDelimiter();var delimiterChar=option.asc_getDelimiterChar();var _param="";_param+="<m_nCsvTxtEncoding>"+option.asc_getCodePage()+"</m_nCsvTxtEncoding>";if(null!=delimiter)_param+="<m_nCsvDelimiter>"+delimiter+"</m_nCsvDelimiter>";if(null!=delimiterChar)_param+="<m_nCsvDelimiterChar>"+delimiterChar+"</m_nCsvDelimiterChar>";window["AscDesktopEditor"]["SetAdvancedOptions"](_param)}else if(window["Asc"].c_oAscAdvancedOptionsID.DRM===idOption){var _param="<m_sPassword>"+
AscCommon.CopyPasteCorrectString(option.asc_getPassword())+"</m_sPassword>";api.currentPassword=option.asc_getPassword();window["AscDesktopEditor"]["SetAdvancedOptions"](_param)}return true}}AscCommon.EncryptionWorker=new CEncryptionData;function CMouseSmoothWheelCorrector(t,scrollFunction){this._deltaX=0;this._deltaY=0;this._isBreakX=false;this._isBreakY=false;this._timeoutCorrector=-1;this._api=t;this._scrollFunction=scrollFunction;this._normalDelta=120;this._isNormalDeltaActive=false;this.setNormalDeltaActive=
function(value){this._isNormalDeltaActive=true;this._normalDelta=value};this.isBreakX=function(){return this._isBreakX};this.isBreakY=function(){return this._isBreakY};this.get_DeltaX=function(wheelDeltaX){this._isBreakX=false;if(!AscCommon.AscBrowser.isMacOs)return wheelDeltaX;this._deltaX+=wheelDeltaX;if(Math.abs(this._deltaX)>=this._normalDelta)return this._isNormalDeltaActive?this._deltaX>0?this._normalDelta:-this._normalDelta:this._deltaX;this._isBreakX=true;return 0};this.get_DeltaY=function(wheelDeltaY){this._isBreakY=
false;if(!AscCommon.AscBrowser.isMacOs)return wheelDeltaY;this._deltaY+=wheelDeltaY;if(Math.abs(this._deltaY)>=this._normalDelta)return this._isNormalDeltaActive?this._deltaY>0?this._normalDelta:-this._normalDelta:this._deltaY;this._isBreakY=true;return 0};this.checkBreak=function(){if(-1!=this._timeoutCorrector){clearTimeout(this._timeoutCorrector);this._timeoutCorrector=-1}if((this._isBreakX||this._isBreakY)&&this._scrollFunction){var obj={t:this,x:this._isBreakX?this._deltaX:0,y:this._isBreakY?
this._deltaY:0};this._timeoutCorrector=setTimeout(function(){var t=obj.t;t._scrollFunction.call(t._api,obj.x,obj.y);t._timeoutCorrector=-1;t._deltaX=0;t._deltaY=0},100)}if(!this._isBreakX)this._deltaX=0;if(!this._isBreakY)this._deltaY=0;this._isBreakX=false;this._isBreakY=false}}AscCommon.CMouseSmoothWheelCorrector=CMouseSmoothWheelCorrector;function CTranslateManager(){this.mapTranslate={}}CTranslateManager.prototype.init=function(map){this.mapTranslate=map||{}};CTranslateManager.prototype.getValue=
function(key){return this.mapTranslate.hasOwnProperty(key)?this.mapTranslate[key]:key};function CPolygonPoint2(X,Y){this.X=X;this.Y=Y}function CPolygonVectors(){this.Page=-1;this.VX=[];this.VY=[]}function CPolygonPath(precision){this.Page=-1;this.Direction=1;this.precision=precision;this.Points=[]}CPolygonPath.prototype.PushPoint=function(x,y){this.Points.push(new CPolygonPoint2(x/this.precision,y/this.precision))};CPolygonPath.prototype.CorrectExtremePoints=function(){var Lng=this.Points.length;
this.Points[0].X=this.Points[Lng-1].X;this.Points[Lng-1].Y=this.Points[0].Y};function CPolygon(){this.Vectors=[];this.precision=1E3}CPolygon.prototype.fill=function(arrBounds){this.Vectors.length=0;if(arrBounds.length<=0)return;var nStartLineIndex=0,nStartIndex=0,CountLines=arrBounds.length,CountBounds;while(nStartLineIndex<arrBounds.length){CountBounds=arrBounds[nStartLineIndex].length;while(nStartIndex<CountBounds)if(arrBounds[nStartLineIndex][nStartIndex].W<.001)nStartIndex++;else break;if(nStartIndex<
CountBounds)break;nStartLineIndex++;nStartIndex=0}if(nStartLineIndex>=arrBounds.length)return;var CurrentPage=arrBounds[nStartLineIndex][nStartIndex].Page,CurrentVectors=new CPolygonVectors,VectorsX=CurrentVectors.VX,VectorsY=CurrentVectors.VY;CurrentVectors.Page=CurrentPage;this.Vectors.push(CurrentVectors);for(var LineIndex=nStartLineIndex;LineIndex<CountLines;nStartIndex=0,LineIndex++){if(arrBounds[LineIndex][nStartIndex].Page!==CurrentPage){CurrentPage=arrBounds[LineIndex][nStartIndex].Page;CurrentVectors=
new CPolygonVectors;VectorsX=CurrentVectors.VX;VectorsY=CurrentVectors.VY;CurrentVectors.Page=CurrentPage;this.Vectors.push(CurrentVectors)}for(var Index=nStartIndex;Index<arrBounds[LineIndex].length;Index++){var oBound=arrBounds[LineIndex][Index];if(oBound.W<.001)continue;var x1=Math.round(oBound.X*this.precision),x2=Math.round((oBound.X+oBound.W)*this.precision),y1=Math.round(oBound.Y*this.precision),y2=Math.round((oBound.Y+oBound.H)*this.precision);if(VectorsX[y1]==undefined)VectorsX[y1]={};this.IntersectionX(VectorsX,
x2,x1,y1);if(VectorsY[x1]==undefined)VectorsY[x1]={};this.IntersectionY(VectorsY,y1,y2,x1);if(VectorsX[y2]==undefined)VectorsX[y2]={};this.IntersectionX(VectorsX,x1,x2,y2);if(VectorsY[x2]==undefined)VectorsY[x2]={};this.IntersectionY(VectorsY,y2,y1,x2)}}};CPolygon.prototype.IntersectionX=function(VectorsX,BeginX,EndX,Y){var CurrentVector={};CurrentVector[BeginX]=EndX;var VX=VectorsX[Y];if(BeginX>EndX)while(true==this.IntersectVectorX(CurrentVector,VX));else while(true==this.IntersectVectorX(VX,CurrentVector));
for(var X in CurrentVector){var VBeginX=parseInt(X);var VEndX=CurrentVector[VBeginX];if(VBeginX!==VEndX||VX[VBeginX]===undefined)VX[VBeginX]=VEndX}};CPolygon.prototype.IntersectVectorX=function(VectorOpp,VectorClW){for(var X in VectorOpp){var VBeginX=parseInt(X);var VEndX=VectorOpp[VBeginX];if(VEndX==VBeginX)continue;for(var ClwX in VectorClW){var ClwBeginX=parseInt(ClwX);var ClwEndX=VectorClW[ClwBeginX];var bIntersection=false;if(ClwBeginX==ClwEndX)continue;if(ClwBeginX<=VEndX&&VBeginX<=ClwEndX){VectorOpp[VBeginX]=
VBeginX;VectorClW[ClwBeginX]=VEndX;VectorClW[VBeginX]=ClwEndX;bIntersection=true}else if(VEndX<=ClwBeginX&&ClwEndX<=VBeginX){VectorClW[ClwBeginX]=ClwBeginX;VectorOpp[VBeginX]=ClwEndX;VectorOpp[ClwBeginX]=VEndX;bIntersection=true}else if(ClwBeginX<VEndX&&VEndX<ClwEndX){VectorClW[ClwBeginX]=VEndX;VectorOpp[VBeginX]=ClwEndX;bIntersection=true}else if(ClwBeginX<VBeginX&&VBeginX<ClwEndX){VectorOpp[ClwBeginX]=VEndX;VectorClW[VBeginX]=ClwEndX;delete VectorOpp[VBeginX];delete VectorClW[ClwBeginX];bIntersection=
true}if(bIntersection==true)return true}}return false};CPolygon.prototype.IntersectionY=function(VectorsY,BeginY,EndY,X){var bIntersect=false;for(var y in VectorsY[X]){var CurBeginY=parseInt(y);var CurEndY=VectorsY[X][CurBeginY];var minY,maxY;if(CurBeginY<CurEndY){minY=CurBeginY;maxY=CurEndY}else{minY=CurEndY;maxY=CurBeginY}var bInterSection=!(maxY<=BeginY&&maxY<=EndY||minY>=BeginY&&minY>=EndY),bDirection=(CurBeginY-CurEndY)*(BeginY-EndY)<0;if(bInterSection&&bDirection){VectorsY[X][CurBeginY]=EndY;
VectorsY[X][BeginY]=CurEndY;bIntersect=true}}if(bIntersect==false)VectorsY[X][BeginY]=EndY};CPolygon.prototype.GetPaths=function(shift){var Paths=[];shift*=this.precision;for(var PageIndex=0;PageIndex<this.Vectors.length;PageIndex++){var y,x1,x2,x,y1,y2;var VectorsX=this.Vectors[PageIndex].VX,VectorsY=this.Vectors[PageIndex].VY,Page=this.Vectors[PageIndex].Page;for(var LineIndex in VectorsX)for(var Index in VectorsX[LineIndex]){var Polygon=new CPolygonPath(this.precision);Polygon.Page=Page;y=parseInt(LineIndex);
x1=parseInt(Index);x2=VectorsX[y][x1];VectorsX[y][x1]=-1;var Direction=x1>x2?1:-1;var minY=y;var SignRightLeft,SignDownUp;var X,Y;if(x2!==-1){SignRightLeft=x1>x2?1:-1;Y=y-SignRightLeft*shift;Polygon.PushPoint(x1,Y);while(true){x=x2;y1=y;y2=VectorsY[x][y1];if(y2==-1)break;else if(y2==undefined)return[];VectorsY[x][y1]=-1;SignDownUp=y1>y2?1:-1;X=x+SignDownUp*shift;Polygon.PushPoint(X,Y);y=y2;x1=x;x2=VectorsX[y][x1];if(x2==-1)break;else if(x2==undefined)return[];VectorsX[y][x1]=-1;SignRightLeft=x1>x2?
1:-1;Y=y-SignRightLeft*shift;Polygon.PushPoint(X,Y);if(y<minY){minY=y;Direction=x1>x2?1:-1}}Polygon.PushPoint(X,Y);Polygon.CorrectExtremePoints();Polygon.Direction=Direction;Paths.push(Polygon)}}}return Paths};function CMathTrack(){this.MathRect={IsActive:false,Bounds:[],ContentSelection:null};this.MathPolygons=[];this.MathSelectPolygons=[]}CMathTrack.prototype.Update=function(IsActive,IsContentActive,oMath,PixelError){this.MathRect.IsActive=IsActive;if(true===IsActive&&null!==oMath){var selectBounds=
true===IsContentActive?oMath.Get_ContentSelection():null;if(selectBounds!=null){var SelectPolygon=new CPolygon;SelectPolygon.fill(selectBounds);this.MathSelectPolygons=SelectPolygon.GetPaths(0)}else this.MathSelectPolygons.length=0;var arrBounds=oMath.Get_Bounds();if(arrBounds.length<=0)return;var MPolygon=new CPolygon;MPolygon.fill(arrBounds);this.MathPolygons=MPolygon.GetPaths(PixelError)}};CMathTrack.prototype.Draw=function(overlay,oPath,shift,color,dKoefX,dKoefY,left,top){var ctx=overlay.m_oContext;
ctx.strokeStyle=color;ctx.lineWidth=1;ctx.beginPath();var Points=oPath.Points;var nCount=Points.length;var PrevX=Points[nCount-2].X,PrevY=Points[nCount-2].Y;var _x=left+dKoefX*Points[nCount-2].X,_y=top+dKoefY*Points[nCount-2].Y;var StartX,StartY;for(var nIndex=0;nIndex<nCount;nIndex++){if(PrevX>Points[nIndex].X)_y=top+dKoefY*Points[nIndex].Y-shift;else if(PrevX<Points[nIndex].X)_y=top+dKoefY*Points[nIndex].Y+shift;if(PrevY<Points[nIndex].Y)_x=left+dKoefX*Points[nIndex].X-shift;else if(PrevY>Points[nIndex].Y)_x=
left+dKoefX*Points[nIndex].X+shift;PrevX=Points[nIndex].X;PrevY=Points[nIndex].Y;if(nIndex>0){overlay.CheckPoint(_x,_y);if(1==nIndex){StartX=_x;StartY=_y;overlay.m_oContext.moveTo((_x>>0)+.5,(_y>>0)+.5)}else overlay.m_oContext.lineTo((_x>>0)+.5,(_y>>0)+.5)}}overlay.m_oContext.lineTo((StartX>>0)+.5,(StartY>>0)+.5);ctx.closePath();ctx.stroke();ctx.beginPath()};CMathTrack.prototype.DrawWithMatrix=function(overlay,oPath,ShiftX,ShiftY,color,dKoefX,dKoefY,left,top,m){var ctx=overlay.m_oContext;ctx.strokeStyle=
color;ctx.lineWidth=1;ctx.beginPath();var Points=oPath.Points;var nCount=Points.length;var x=Points[nCount-2].X,y=Points[nCount-2].Y;var _x,_y;var PrevX=Points[nCount-2].X,PrevY=Points[nCount-2].Y;var StartX,StartY;for(var nIndex=0;nIndex<nCount;nIndex++){if(PrevX>Points[nIndex].X)y=Points[nIndex].Y-ShiftY;else if(PrevX<Points[nIndex].X)y=Points[nIndex].Y+ShiftY;if(PrevY<Points[nIndex].Y)x=Points[nIndex].X-ShiftX;else if(PrevY>Points[nIndex].Y)x=Points[nIndex].X+ShiftX;PrevX=Points[nIndex].X;PrevY=
Points[nIndex].Y;if(nIndex>0){_x=left+dKoefX*m.TransformPointX(x,y);_y=top+dKoefY*m.TransformPointY(x,y);overlay.CheckPoint(_x,_y);if(1==nIndex){StartX=_x;StartY=_y;overlay.m_oContext.moveTo((_x>>0)+.5,(_y>>0)+.5)}else overlay.m_oContext.lineTo((_x>>0)+.5,(_y>>0)+.5)}}overlay.m_oContext.lineTo((StartX>>0)+.5,(StartY>>0)+.5);ctx.closePath();ctx.stroke();ctx.beginPath()};CMathTrack.prototype.DrawSelectPolygon=function(overlay,oPath,dKoefX,dKoefY,left,top,m){var ctx=overlay.m_oContext;ctx.fillStyle=
"#375082";ctx.beginPath();var Points=oPath.Points;var nPointIndex;var _x,_y,x,y,p;for(nPointIndex=0;nPointIndex<Points.length-1;nPointIndex++){p=Points[nPointIndex];if(!m){_x=left+dKoefX*p.X;_y=top+dKoefY*p.Y}else{x=p.X;y=p.Y;_x=left+dKoefX*m.TransformPointX(x,y);_y=top+dKoefY*m.TransformPointY(x,y)}overlay.CheckPoint(_x,_y);if(0==nPointIndex)ctx.moveTo((_x>>0)+.5,(_y>>0)+.5);else ctx.lineTo((_x>>0)+.5,(_y>>0)+.5)}ctx.globalAlpha=.2;ctx.fill();ctx.globalAlpha=1};CMathTrack.prototype.IsActive=function(){return this.MathRect.IsActive};
CMathTrack.prototype.GetPolygonsCount=function(){return this.MathPolygons.length};CMathTrack.prototype.GetPolygon=function(nIndex){return this.MathPolygons[nIndex]};CMathTrack.prototype.GetSelectPathsCount=function(){return this.MathSelectPolygons.length};CMathTrack.prototype.GetSelectPath=function(nIndex){return this.MathSelectPolygons[nIndex]};if(!Array.prototype.findIndex)Object.defineProperty(Array.prototype,"findIndex",{value:function(predicate){if(this==null)throw new TypeError("Array.prototype.findIndex called on null or undefined");
if(typeof predicate!=="function")throw new TypeError("predicate must be a function");var list=Object(this);var length=list.length>>>0;var thisArg=arguments[1];var value;for(var i=0;i<length;i++){value=list[i];if(predicate.call(thisArg,value,i,list))return i}return-1}});if(!Array.prototype.fill)Object.defineProperty(Array.prototype,"fill",{value:function(value){if(this==null)throw new TypeError("this is null or not defined");var O=Object(this);var len=O.length>>>0;var start=arguments[1];var relativeStart=
start>>0;var k=relativeStart<0?Math.max(len+relativeStart,0):Math.min(relativeStart,len);var end=arguments[2];var relativeEnd=end===undefined?len:end>>0;var final=relativeEnd<0?Math.max(len+relativeEnd,0):Math.min(relativeEnd,len);while(k<final){O[k]=value;k++}return O}});if(typeof Int8Array!=="undefined"&&!Int8Array.prototype.fill)Int8Array.prototype.fill=Array.prototype.fill;if(typeof Uint8Array!=="undefined"&&!Uint8Array.prototype.fill)Uint8Array.prototype.fill=Array.prototype.fill;if(typeof Uint8ClampedArray!==
"undefined"&&!Uint8ClampedArray.prototype.fill)Uint8ClampedArray.prototype.fill=Array.prototype.fill;if(typeof Int16Array!=="undefined"&&!Int16Array.prototype.fill)Int16Array.prototype.fill=Array.prototype.fill;if(typeof Uint16Array!=="undefined"&&!Uint16Array.prototype.fill)Uint16Array.prototype.fill=Array.prototype.fill;if(typeof Int32Array!=="undefined"&&!Int32Array.prototype.fill)Int32Array.prototype.fill=Array.prototype.fill;if(typeof Uint32Array!=="undefined"&&!Uint32Array.prototype.fill)Uint32Array.prototype.fill=
Array.prototype.fill;if(typeof Float32Array!=="undefined"&&!Float32Array.prototype.fill)Float32Array.prototype.fill=Array.prototype.fill;if(typeof Float64Array!=="undefined"&&!Float64Array.prototype.fill)Float64Array.prototype.fill=Array.prototype.fill;if(typeof Uint8Array!=="undefined"&&!Uint8Array.prototype.slice)Uint8Array.prototype.slice=Array.prototype.slice;function parseText(text,options,bTrimSpaces){var delimiterChar;if(options.asc_getDelimiterChar())delimiterChar=options.asc_getDelimiterChar();
else switch(options.asc_getDelimiter()){case AscCommon.c_oAscCsvDelimiter.None:delimiterChar=undefined;break;case AscCommon.c_oAscCsvDelimiter.Tab:delimiterChar="\t";break;case AscCommon.c_oAscCsvDelimiter.Semicolon:delimiterChar=";";break;case AscCommon.c_oAscCsvDelimiter.Colon:delimiterChar=":";break;case AscCommon.c_oAscCsvDelimiter.Comma:delimiterChar=",";break;case AscCommon.c_oAscCsvDelimiter.Space:delimiterChar=" ";break}var matrix=[];var rows=text.split(/\r?\n/);for(var i=0;i<rows.length;++i){var row=
rows[i];if(" "===delimiterChar&&bTrimSpaces){var addSpace=false;if(row[0]===delimiterChar)addSpace=true;row=addSpace?delimiterChar+row.trim():row.trim()}matrix.push(row.split(delimiterChar))}return matrix}function getTimeISO8601(dateStr){if(dateStr)if(dateStr.endsWith("Z"))return Date.parse(dateStr);else return Date.parse(dateStr+"Z");return NaN}function valueToMmType(value){var oVal=parseFloat(value);var oType;if(!isNaN(oVal)){if(-1!==value.indexOf("%")){oType="%";oVal/=100}else if(-1!==value.indexOf("px")){oType=
"px";oVal*=AscCommon.g_dKoef_pix_to_mm}else if(-1!==value.indexOf("in")){oType="in";oVal*=AscCommonWord.g_dKoef_in_to_mm}else if(-1!==value.indexOf("cm")){oType="cm";oVal*=10}else if(-1!==value.indexOf("mm"))oType="mm";else if(-1!==value.indexOf("pt")){oType="pt";oVal*=AscCommonWord.g_dKoef_pt_to_mm}else if(-1!==value.indexOf("pc")){oType="pc";oVal*=AscCommonWord.g_dKoef_pc_to_mm}else oType="none";return{val:oVal,type:oType}}return null}function valueToMm(value){var obj=valueToMmType(value);if(obj&&
"%"!==obj.type&&"none"!==obj.type)return obj.val;return null}function arrayMove(array,from,to){array.splice(to,0,array.splice(from,1)[0])}function getRangeArray(start,stop){var res=new Array(stop-start);for(var i=start;i<stop;++i)res[i-start]=i;return res}var g_oBackoffDefaults={retries:2,factor:2,minTimeout:100,maxTimeout:2E3,randomize:true};function Backoff(opts){this.attempts=0;this.opts=opts}Backoff.prototype.attempt=function(fError,fRetry){var timeout=this.nextTimeout();if(timeout>0)setTimeout(function(){fRetry()},
timeout);else fError()};Backoff.prototype.nextTimeout=function(){var timeout=-1;if(this.attempts<this.opts.retries){timeout=this.createTimeout(this.attempts,this.opts);this.attempts++}return timeout};Backoff.prototype.createTimeout=function(attempt,opts){var random=opts.randomize?Math.random()+1:1;var timeout=Math.round(random*opts.minTimeout*Math.pow(opts.factor,attempt));timeout=Math.min(timeout,opts.maxTimeout);return timeout};function backoffOnError(obj,onError,onRetry){if(!onRetry)return onError;
var backoff=new Backoff(g_oBackoffDefaults);return function(){var timeout=backoff.nextTimeout();if(timeout>0)setTimeout(function(){onRetry.call(obj,obj)},timeout);else if(onError)onError.apply(obj,arguments)}}function backoffOnErrorImg(img,onRetry){if(!onRetry)onRetry=function(img){img.setAttribute("src",img.getAttribute("src"))};img.onerror=backoffOnError(img,img.onerror,onRetry)}function isEmptyObject(obj){for(var name in obj)return false;return true}window["AscCommon"]=window["AscCommon"]||{};
window["AscCommon"].getSockJs=getSockJs;window["AscCommon"].getJSZipUtils=getJSZipUtils;window["AscCommon"].getJSZip=getJSZip;window["AscCommon"].getBaseUrl=getBaseUrl;window["AscCommon"].getEncodingParams=getEncodingParams;window["AscCommon"].getEncodingByBOM=getEncodingByBOM;window["AscCommon"].saveWithParts=saveWithParts;window["AscCommon"].loadFileContent=loadFileContent;window["AscCommon"].getImageFromChanges=getImageFromChanges;window["AscCommon"].openFileCommand=openFileCommand;window["AscCommon"].sendCommand=
sendCommand;window["AscCommon"].sendSaveFile=sendSaveFile;window["AscCommon"].mapAscServerErrorToAscError=mapAscServerErrorToAscError;window["AscCommon"].joinUrls=joinUrls;window["AscCommon"].getFullImageSrc2=getFullImageSrc2;window["AscCommon"].fSortAscending=fSortAscending;window["AscCommon"].fSortDescending=fSortDescending;window["AscCommon"].isLeadingSurrogateChar=isLeadingSurrogateChar;window["AscCommon"].decodeSurrogateChar=decodeSurrogateChar;window["AscCommon"].encodeSurrogateChar=encodeSurrogateChar;
window["AscCommon"].convertUnicodeToUTF16=convertUnicodeToUTF16;window["AscCommon"].convertUTF16toUnicode=convertUTF16toUnicode;window["AscCommon"].build_local_rx=build_local_rx;window["AscCommon"].GetFileName=GetFileName;window["AscCommon"].GetFileExtension=GetFileExtension;window["AscCommon"].changeFileExtention=changeFileExtention;window["AscCommon"].getExtentionByFormat=getExtentionByFormat;window["AscCommon"].InitOnMessage=InitOnMessage;window["AscCommon"].ShowImageFileDialog=ShowImageFileDialog;
window["AscCommon"].ShowDocumentFileDialog=ShowDocumentFileDialog;window["AscCommon"].InitDragAndDrop=InitDragAndDrop;window["AscCommon"].UploadImageFiles=UploadImageFiles;window["AscCommon"].UploadImageUrls=UploadImageUrls;window["AscCommon"].CanDropFiles=CanDropFiles;window["AscCommon"].getUrlType=getUrlType;window["AscCommon"].prepareUrl=prepareUrl;window["AscCommon"].getUserColorById=getUserColorById;window["AscCommon"].isNullOrEmptyString=isNullOrEmptyString;window["AscCommon"].unleakString=
unleakString;window["AscCommon"].readValAttr=readValAttr;window["AscCommon"].getNumFromXml=getNumFromXml;window["AscCommon"].getColorFromXml=getColorFromXml;window["AscCommon"].getBoolFromXml=getBoolFromXml;window["AscCommon"].initStreamFromResponse=initStreamFromResponse;window["AscCommon"].checkStreamSignature=checkStreamSignature;window["AscCommon"].DocumentUrls=DocumentUrls;window["AscCommon"].OpenFileResult=OpenFileResult;window["AscCommon"].CLock=CLock;window["AscCommon"].CContentChanges=CContentChanges;
window["AscCommon"].CContentChangesElement=CContentChangesElement;window["AscCommon"].CorrectMMToTwips=CorrectMMToTwips;window["AscCommon"].TwipsToMM=TwipsToMM;window["AscCommon"].MMToTwips=MMToTwips;window["AscCommon"].RomanToInt=RomanToInt;window["AscCommon"].LatinNumberingToInt=LatinNumberingToInt;window["AscCommon"].IntToNumberFormat=IntToNumberFormat;window["AscCommon"].IsSpace=IsSpace;window["AscCommon"].loadSdk=loadSdk;window["AscCommon"].loadScript=loadScript;window["AscCommon"].getAltGr=
getAltGr;window["AscCommon"].getColorSchemeByName=getColorSchemeByName;window["AscCommon"].getColorSchemeByIdx=getColorSchemeByIdx;window["AscCommon"].getAscColorScheme=getAscColorScheme;window["AscCommon"].checkAddColorScheme=checkAddColorScheme;window["AscCommon"].getIndexColorSchemeInArray=getIndexColorSchemeInArray;window["AscCommon"].isEastAsianScript=isEastAsianScript;window["AscCommon"].CMathTrack=CMathTrack;window["AscCommon"].CPolygon=CPolygon;window["AscCommon"].JSZipWrapper=JSZipWrapper;
window["AscCommon"].g_oDocumentUrls=g_oDocumentUrls;window["AscCommon"].FormulaTablePartInfo=FormulaTablePartInfo;window["AscCommon"].cBoolLocal=cBoolLocal;window["AscCommon"].cErrorOrigin=cErrorOrigin;window["AscCommon"].cErrorLocal=cErrorLocal;window["AscCommon"].FormulaSeparators=FormulaSeparators;window["AscCommon"].rx_space_g=rx_space_g;window["AscCommon"].rx_space=rx_space;window["AscCommon"].rx_defName=rx_defName;window["AscCommon"].kCurFormatPainterWord=kCurFormatPainterWord;window["AscCommon"].parserHelp=
parserHelp;window["AscCommon"].g_oIdCounter=g_oIdCounter;window["AscCommon"].g_oHtmlCursor=g_oHtmlCursor;window["AscCommon"].g_oBackoffDefaults=g_oBackoffDefaults;window["AscCommon"].Backoff=Backoff;window["AscCommon"].backoffOnErrorImg=backoffOnErrorImg;window["AscCommon"].isEmptyObject=isEmptyObject;window["AscCommon"].CSignatureDrawer=window["AscCommon"]["CSignatureDrawer"]=CSignatureDrawer;var prot=CSignatureDrawer.prototype;prot["getImages"]=prot.getImages;prot["setText"]=prot.setText;prot["selectImage"]=
prot.selectImage;prot["isValid"]=prot.isValid;prot["destroy"]=prot.destroy;window["AscCommon"].translateManager=new CTranslateManager;window["AscCommon"].parseText=parseText;window["AscCommon"].getTimeISO8601=getTimeISO8601;window["AscCommon"].valueToMm=valueToMm;window["AscCommon"].valueToMmType=valueToMmType;window["AscCommon"].arrayMove=arrayMove;window["AscCommon"].getRangeArray=getRangeArray;window["AscCommon"].CUnicodeStringEmulator=CUnicodeStringEmulator;window["AscCommon"].private_IsAbbreviation=
private_IsAbbreviation;window["AscCommon"].rx_test_ws_name=rx_test_ws_name;window["AscCommon"].CShortcuts=window["AscCommon"]["CShortcuts"]=CShortcuts;prot=CShortcuts.prototype;prot["Add"]=prot.Add;prot["Get"]=prot.Get;prot["CheckType"]=prot.CheckType;prot["Remove"]=prot.Remove;prot["RemoveByType"]=prot.RemoveByType;prot["GetNewCustomType"]=prot.GetNewCustomType;prot["IsCustomType"]=prot.IsCustomType;prot["GetCustomAction"]=prot.GetCustomAction;prot["AddCustomActionSymbol"]=prot.AddCustomActionSymbol;
window["AscCommon"].CCustomShortcutActionSymbol=window["AscCommon"]["CCustomShortcutActionSymbol"]=CCustomShortcutActionSymbol})(window);
window["asc_initAdvancedOptions"]=function(_code,_file_hash,_docInfo){if(window.isNativeOpenPassword)return window["NativeFileOpen_error"](window.isNativeOpenPassword,_file_hash,_docInfo);var _editor=window["Asc"]["editor"]?window["Asc"]["editor"]:window.editor;if(_code==90||_code==91){if(window["AscDesktopEditor"]&&0!==window["AscDesktopEditor"]["CryptoMode"]&&!_editor.isLoadFullApi){_editor.asc_initAdvancedOptions_params=[];_editor.asc_initAdvancedOptions_params.push(_code);_editor.asc_initAdvancedOptions_params.push(_file_hash);
_editor.asc_initAdvancedOptions_params.push(_docInfo);return}if(AscCommon.EncryptionWorker.isNeedCrypt()&&!window.checkPasswordFromPlugin){window.checkPasswordFromPlugin=true;window.g_asc_plugins.sendToEncryption({"type":"getPasswordByFile","hash":_file_hash,"docinfo":_docInfo});return}}window.checkPasswordFromPlugin=false;_editor._onNeedParams(undefined,_code==90||_code==91?true:undefined)};
window["asc_IsNeedBuildCryptedFile"]=function(){if(!window["AscDesktopEditor"]||!window["AscDesktopEditor"]["CryptoMode"])return false;var _api=window["Asc"]["editor"]?window["Asc"]["editor"]:window.editor;var _returnValue=false;var _users=null;if(_api.CoAuthoringApi&&_api.CoAuthoringApi._CoAuthoringApi&&_api.CoAuthoringApi._CoAuthoringApi._participants)_users=_api.CoAuthoringApi._CoAuthoringApi._participants;var _usersCount=0;for(var _user in _users)_usersCount++;var isOne=1>=_usersCount?true:false;

@ -8371,18 +8371,18 @@ function(font_index,stream_index){this.embeddedFontFiles[font_index].SetStreamIn
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.LoadDocumentImagesCallback=function(){if(this.ThemeLoader==null)this.Api.asyncImagesDocumentEndLoaded();else this.ThemeLoader.asyncImagesEndLoaded()};this.LoadDocumentImages=
function(_images){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);var that=this;setTimeout(function(){that.LoadDocumentImagesCallback()},
3E3)}};this.loadImageByUrl=function(_image,_url){if(this.isBlockchainSupport)_image.preload_crypto(_url);else _image.src=_url};this._LoadImages=function(){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)});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)});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;var oThat=oThis;oImage.Image.onload=
function(){oImage.Status=ImageLoadStatus.Complete;oThat.Api.asyncImageEndLoadedBackground(oImage)};oImage.Image.onerror=function(){oImage.Status=ImageLoadStatus.Complete;oImage.Image=null;oThat.Api.asyncImageEndLoadedBackground(oImage)};AscCommon.backoffOnErrorImg(oImage.Image,function(img){oThis.loadImageByUrl(img,img.src)});console.log("Loading image "+i);console.log(oImage);window.parent.APP.getImageURL(oImage.src,function(url){if(url=="")oThis.loadImageByUrl(oImage.Image,oImage.src);else{oThis.loadImageByUrl(oImage.Image,
url);oThis.map_image_index[url]=oImage}})};this.LoadImagesWithCallback=function(arr,loadImageCallBack,loadImageCallBackArgs){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}this.loadImageCallBackCounter=0;this.loadImageCallBackCounterMax=arrAsync.length;this.loadImageCallBack=loadImageCallBack;this.loadImageCallBackArgs=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;oThis.loadImageCallBackCounter++;if(oThis.loadImageCallBackCounter==oThis.loadImageCallBackCounterMax)oThis.LoadImagesWithCallbackEnd()};oImage.Image.onerror=function(){this.parentImage.Image=null;this.parentImage.Status=ImageLoadStatus.Complete;
oThis.loadImageCallBackCounter++;if(oThis.loadImageCallBackCounter==oThis.loadImageCallBackCounterMax)oThis.LoadImagesWithCallbackEnd()};AscCommon.backoffOnErrorImg(oImage.Image,function(img){oThis.loadImageByUrl(img,img.src)});this.loadImageByUrl(oImage.Image,oImage.src)}};this.LoadImagesWithCallbackEnd=function(){this.loadImageCallBack.call(this.Api,this.loadImageCallBackArgs);this.loadImageCallBack=null;this.loadImageCallBackArgs=null;this.loadImageCallBackCounterMax=0;this.loadImageCallBackCounter=
0}}var g_flow_anchor=new Image;g_flow_anchor.asc_complete=false;g_flow_anchor.onload=function(){g_flow_anchor.asc_complete=true};g_flow_anchor.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPBAMAAADNDVhEAAAAIVBMVEUAAAANDQ0NDQ0NDQ0NDQ0NDQ0AAAANDQ0NDQ0NDQ0NDQ1jk7YPAAAACnRSTlMAGkD4mb9c5s9TDghpXQAAAFZJREFUCNdjYGBgW8YABlxcIBLBZ1gAEfZa5QWiGRkWMAIpAaA4iHQE0YwODEtANMsChkIwv4BBWQBICyswMC1iWADEDAzKoUuDFUAGNC9uABvIaQkkABpxD6lFb9lRAAAAAElFTkSuQmCC";var g_flow_anchor2=new Image;g_flow_anchor2.asc_complete=
false;g_flow_anchor2.onload=function(){g_flow_anchor2.asc_complete=true};g_flow_anchor2.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAeCAMAAAAFBf7qAAAAOVBMVEUAAAAAAAAAAAAAAAAJCQkAAAAJCQkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJCQknI0ZQAAAAEnRSTlMAx9ITlAfyPHxn68yecTAl5qt6y0BvAAAAt0lEQVQoz8WS0QrDIAxFk0ajtlXb+/8fuzAprltg7Gnn4aIcvAgJTSSoBiGPoIAGV60qoquvIIL110IJgPONmKIlMI73MiwGRoZvahbKVSizcDKU8QeVPDXEIr6ShVB9VUEn2FOMkwL8VwjUtuypvDWiHeVTFeyWkZHfVQZHGm4XMhKQyJB9GKMxuHQSBlioF7u2q7kzgO2AcWwW3F8mWRmGKgyu91mK1Tzh4ixVVkBzJI/EnGjyACbfCaO3eIWRAAAAAElFTkSuQmCC";
function(_images){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;if(_len===0)return void this.LoadDocumentImagesCallback();var todo=_len;var that=this;var done=function(){todo--;
if(todo===0){that.images_loading.splice(0,_len);setTimeout(function(){that.LoadDocumentImagesCallback()},100);done=function(){}}};for(var i=0;i<_len;i++)this.LoadImageAsync(i,done);return;this.images_loading.splice(0,_len);var that=this;setTimeout(function(){that.LoadDocumentImagesCallback()},3E3)}};this.loadImageByUrl=function(_image,_url){if(this.isBlockchainSupport)_image.preload_crypto(_url);else _image.src=_url};this._LoadImages=function(){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)});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)});this.loadImageByUrl(oImage.Image,oImage.src);return null};this.LoadImageAsync=function(i,
cb){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;var oThat=oThis;oImage.Image.onload=function(){oImage.Status=ImageLoadStatus.Complete;oThat.Api.asyncImageEndLoadedBackground(oImage)};oImage.Image.onerror=function(){oImage.Status=ImageLoadStatus.Complete;oImage.Image=null;oThat.Api.asyncImageEndLoadedBackground(oImage)};AscCommon.backoffOnErrorImg(oImage.Image,function(img){oThis.loadImageByUrl(img,
img.src)});console.log("Loading image "+i);console.log(oImage);window.parent.APP.getImageURL(oImage.src,function(url){if(url=="")oThis.loadImageByUrl(oImage.Image,oImage.src);else{oThis.loadImageByUrl(oImage.Image,url);oThis.map_image_index[url]=oImage}if(typeof cb==="function")cb()})};this.LoadImagesWithCallback=function(arr,loadImageCallBack,loadImageCallBackArgs){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}this.loadImageCallBackCounter=0;this.loadImageCallBackCounterMax=arrAsync.length;this.loadImageCallBack=loadImageCallBack;this.loadImageCallBackArgs=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;
oThis.loadImageCallBackCounter++;if(oThis.loadImageCallBackCounter==oThis.loadImageCallBackCounterMax)oThis.LoadImagesWithCallbackEnd()};oImage.Image.onerror=function(){this.parentImage.Image=null;this.parentImage.Status=ImageLoadStatus.Complete;oThis.loadImageCallBackCounter++;if(oThis.loadImageCallBackCounter==oThis.loadImageCallBackCounterMax)oThis.LoadImagesWithCallbackEnd()};AscCommon.backoffOnErrorImg(oImage.Image,function(img){oThis.loadImageByUrl(img,img.src)});this.loadImageByUrl(oImage.Image,
oImage.src)}};this.LoadImagesWithCallbackEnd=function(){this.loadImageCallBack.call(this.Api,this.loadImageCallBackArgs);this.loadImageCallBack=null;this.loadImageCallBackArgs=null;this.loadImageCallBackCounterMax=0;this.loadImageCallBackCounter=0}}var g_flow_anchor=new Image;g_flow_anchor.asc_complete=false;g_flow_anchor.onload=function(){g_flow_anchor.asc_complete=true};g_flow_anchor.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPBAMAAADNDVhEAAAAIVBMVEUAAAANDQ0NDQ0NDQ0NDQ0NDQ0AAAANDQ0NDQ0NDQ0NDQ1jk7YPAAAACnRSTlMAGkD4mb9c5s9TDghpXQAAAFZJREFUCNdjYGBgW8YABlxcIBLBZ1gAEfZa5QWiGRkWMAIpAaA4iHQE0YwODEtANMsChkIwv4BBWQBICyswMC1iWADEDAzKoUuDFUAGNC9uABvIaQkkABpxD6lFb9lRAAAAAElFTkSuQmCC";
var g_flow_anchor2=new Image;g_flow_anchor2.asc_complete=false;g_flow_anchor2.onload=function(){g_flow_anchor2.asc_complete=true};g_flow_anchor2.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAeCAMAAAAFBf7qAAAAOVBMVEUAAAAAAAAAAAAAAAAJCQkAAAAJCQkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJCQknI0ZQAAAAEnRSTlMAx9ITlAfyPHxn68yecTAl5qt6y0BvAAAAt0lEQVQoz8WS0QrDIAxFk0ajtlXb+/8fuzAprltg7Gnn4aIcvAgJTSSoBiGPoIAGV60qoquvIIL110IJgPONmKIlMI73MiwGRoZvahbKVSizcDKU8QeVPDXEIr6ShVB9VUEn2FOMkwL8VwjUtuypvDWiHeVTFeyWkZHfVQZHGm4XMhKQyJB9GKMxuHQSBlioF7u2q7kzgO2AcWwW3F8mWRmGKgyu91mK1Tzh4ixVVkBzJI/EnGjyACbfCaO3eIWRAAAAAElFTkSuQmCC";
window["AscCommon"]=window["AscCommon"]||{};window["AscCommon"].g_font_loader=new CGlobalFontLoader;window["AscCommon"].g_image_loader=new CGlobalImageLoader;window["AscCommon"].g_flow_anchor=g_flow_anchor;window["AscCommon"].g_flow_anchor2=g_flow_anchor2})(window,window.document);"use strict";(function(window,undefined){var g_dKoef_mm_to_pix=AscCommon.g_dKoef_mm_to_pix;function CBounds(){this.L=0;this.T=0;this.R=0;this.B=0;this.isAbsL=false;this.isAbsT=false;this.isAbsR=false;this.isAbsB=false;this.AbsW=
-1;this.AbsH=-1;this.SetParams=function(_l,_t,_r,_b,abs_l,abs_t,abs_r,abs_b,absW,absH){this.L=_l;this.T=_t;this.R=_r;this.B=_b;this.isAbsL=abs_l;this.isAbsT=abs_t;this.isAbsR=abs_r;this.isAbsB=abs_b;this.AbsW=absW;this.AbsH=absH}}function CAbsolutePosition(){this.L=0;this.T=0;this.R=0;this.B=0}var g_anchor_left=1;var g_anchor_top=2;var g_anchor_right=4;var g_anchor_bottom=8;function CControl(){this.Bounds=new CBounds;this.Anchor=g_anchor_left|g_anchor_top;this.Name=null;this.Parent=null;this.TabIndex=
null;this.HtmlElement=null;this.AbsolutePosition=new CBounds;this.Resize=function(_width,_height,api){if(null==this.Parent||null==this.HtmlElement)return;var _x=0;var _y=0;var _r=0;var _b=0;var hor_anchor=this.Anchor&5;var ver_anchor=this.Anchor&10;if(g_anchor_left==hor_anchor){if(this.Bounds.isAbsL)_x=this.Bounds.L;else _x=this.Bounds.L*_width/1E3;if(-1!=this.Bounds.AbsW)_r=_x+this.Bounds.AbsW;else if(this.Bounds.isAbsR)_r=_width-this.Bounds.R;else _r=this.Bounds.R*_width/1E3}else if(g_anchor_right==
@ -14733,59 +14733,59 @@ this.CheckFootnote(X,Y,CurPage);if(isInText&&null!=oHyperlink&&(Y<=this.Pages[Cu
Asc.c_oAscMouseMoveDataTypes.Common;if(isInText&&(null!=oHyperlink||bPageRefLink)&&true===AscCommon.global_keyboardEvent.CtrlKey)this.DrawingDocument.SetCursorType("pointer",MMData);else this.DrawingDocument.SetCursorType("text",MMData);var Bounds=this.Pages[CurPage].Bounds;if(true===this.Lock.Is_Locked()&&X<Bounds.Right&&X>Bounds.Left&&Y>Bounds.Top&&Y<Bounds.Bottom&&this.LogicDocument&&!this.LogicDocument.IsViewModeInReview()){var _X=this.Pages[CurPage].X;var _Y=this.Pages[CurPage].Y;var MMData=
new AscCommon.CMouseMoveData;var Coords=this.DrawingDocument.ConvertCoordsToCursorWR(_X,_Y,this.Get_AbsolutePage(CurPage),text_transform);MMData.X_abs=Coords.X-5;MMData.Y_abs=Coords.Y;MMData.Type=Asc.c_oAscMouseMoveDataTypes.LockedObject;MMData.UserId=this.Lock.Get_UserId();MMData.HaveChanges=this.Lock.Have_Changes();MMData.LockedObjectType=c_oAscMouseMoveLockedObjectType.Common;editor.sync_MouseMoveCallback(MMData)}};Paragraph.prototype.Document_CreateFontMap=function(FontMap){if(true===this.FontMap.NeedRecalc){this.FontMap.Map=
{};this.private_CompileParaPr();var FontScheme=this.Get_Theme().themeElements.fontScheme;var CurTextPr=this.CompiledPr.Pr.TextPr.Copy();CurTextPr.Document_CreateFontMap(this.FontMap.Map,FontScheme);CurTextPr.Merge(this.TextPr.Value);CurTextPr.Document_CreateFontMap(this.FontMap.Map,FontScheme);var Count=this.Content.length;for(var Index=0;Index<Count;Index++)this.Content[Index].Create_FontMap(this.FontMap.Map);this.FontMap.NeedRecalc=false}for(var Key in this.FontMap.Map)FontMap[Key]=this.FontMap.Map[Key]};
Paragraph.prototype.Document_CreateFontCharMap=function(FontCharMap){};Paragraph.prototype.Document_Get_AllFontNames=function(AllFonts){this.TextPr.Value.Document_Get_AllFontNames(AllFonts);if(this.Pr.Bullet)this.Pr.Bullet.Get_AllFontNames(AllFonts);if(this.Pr.DefaultRunPr)this.Pr.DefaultRunPr.Document_Get_AllFontNames(AllFonts);var Count=this.Content.length;for(var Index=0;Index<Count;Index++)this.Content[Index].Get_AllFontNames(AllFonts)};Paragraph.prototype.Document_UpdateRulersState=function(){if(this.CalculatedFrame){var oFrame=
this.CalculatedFrame;this.Parent.DrawingDocument.Set_RulerState_Paragraph({L:oFrame.L2,T:oFrame.T2,R:oFrame.L2+oFrame.W2,B:oFrame.T2+oFrame.H2,PageIndex:this.GetStartPageAbsolute(),Frame:this},false)}else if(this.Parent instanceof CDocument)if(this.LogicDocument)this.LogicDocument.Document_UpdateRulersStateBySection()};Paragraph.prototype.Document_UpdateInterfaceState=function(){var StartPos,EndPos;if(true===this.Selection.Use){StartPos=this.Get_ParaContentPos(true,true);EndPos=this.Get_ParaContentPos(true,
false)}else{var CurPos=this.Get_ParaContentPos(false,false);StartPos=CurPos;EndPos=CurPos}if(this.LogicDocument&&true===this.LogicDocument.Spelling.Use&&(selectionflag_Numbering!==this.Selection.Flag&&selectionflag_NumberingCur!==this.Selection.Flag))this.SpellChecker.Document_UpdateInterfaceState(StartPos,EndPos);if(true===this.Selection.Use){var StartPos=this.Selection.StartPos;var EndPos=this.Selection.EndPos;if(StartPos>EndPos){StartPos=this.Selection.EndPos;EndPos=this.Selection.StartPos}for(var CurPos=
StartPos;CurPos<=EndPos;CurPos++){var Element=this.Content[CurPos];if(true!==Element.IsSelectionEmpty()&&Element.Document_UpdateInterfaceState)Element.Document_UpdateInterfaceState()}}else{var CurType=this.Content[this.CurPos.ContentPos].Type;if(this.Content[this.CurPos.ContentPos].Document_UpdateInterfaceState)this.Content[this.CurPos.ContentPos].Document_UpdateInterfaceState()}var arrComplexFields=this.GetCurrentComplexFields();for(var nIndex=0,nCount=arrComplexFields.length;nIndex<nCount;++nIndex){var oInstruction=
arrComplexFields[nIndex].GetInstruction();if(oInstruction&&fieldtype_HYPERLINK===oInstruction.GetType()){var oHyperProps=new Asc.CHyperlinkProperty;oHyperProps.put_ToolTip(oInstruction.GetToolTip());oHyperProps.put_Value(oInstruction.GetValue());oHyperProps.put_Text(this.LogicDocument?this.LogicDocument.GetComplexFieldTextValue(arrComplexFields[nIndex]):null);oHyperProps.put_InternalHyperlink(oInstruction);editor.sync_HyperlinkPropCallback(oHyperProps)}}if(editor&&this.bFromDocument){if(!this.LogicDocument)return;
var TrackManager=this.LogicDocument.GetTrackRevisionsManager();if(this.Pages.length<=0&&this.Lines.length<=0)return;var ContentPos=this.Get_ParaContentPos(this.Selection.Use,true);var ParaPos=this.Get_ParaPosByContentPos(ContentPos);if(this.Pages.length<=ParaPos.Page||this.Lines.length<=ParaPos.Line)return;var Page_abs=this.Get_AbsolutePage(ParaPos.Page);var _Y=this.Pages[ParaPos.Page].Y+this.Lines[ParaPos.Line].Top;var TextTransform=this.Get_ParentTextTransform();var _X=this.LogicDocument?this.LogicDocument.Get_PageLimits(Page_abs).XLimit:
0;var Coords=this.DrawingDocument.ConvertCoordsToCursorWR(_X,_Y,Page_abs,TextTransform);if(false===this.Selection.Use){var Changes=TrackManager.GetElementChanges(this.GetId());if(Changes.length>0)for(var ChangeIndex=0,ChangesCount=Changes.length;ChangeIndex<ChangesCount;ChangeIndex++){var Change=Changes[ChangeIndex];var Type=Change.get_Type();if(c_oAscRevisionsChangeType.TextAdd!==Type&&c_oAscRevisionsChangeType.TextRem!==Type&&c_oAscRevisionsChangeType.TextPr!==Type||StartPos.Compare(Change.get_StartPos())>=
0&&StartPos.Compare(Change.get_EndPos())<=0){Change.put_InternalPos(_X,_Y,Page_abs);TrackManager.AddVisibleChange(Change)}}}}};Paragraph.prototype.PreDelete=function(){for(var Index=0;Index<this.Content.length;Index++){var Item=this.Content[Index];if(Item.PreDelete)Item.PreDelete();if(this.LogicDocument)if(para_Comment===Item.Type&&true===this.LogicDocument.RemoveCommentsOnPreDelete)this.LogicDocument.RemoveComment(Item.CommentId,true,false);else if(para_Bookmark===Item.Type)this.LogicDocument.GetBookmarksManager().SetNeedUpdate(true)}this.RemoveSelection();
this.UpdateDocumentOutline();if(undefined!==this.Get_SectionPr()&&this.LogicDocument)this.Set_SectionPr(undefined)};Paragraph.prototype.Document_SetThisElementCurrent=function(bUpdateStates){this.Parent.Update_ContentIndexing();this.Parent.Set_CurrentElement(this.Index,bUpdateStates)};Paragraph.prototype.Is_ThisElementCurrent=function(){var Parent=this.Parent;Parent.Update_ContentIndexing();if(docpostype_Content===Parent.GetDocPosType()&&false===Parent.Selection.Use&&this.Index===Parent.CurPos.ContentPos&&
Parent.Content[this.Index]===this)return this.Parent.Is_ThisElementCurrent();return false};Paragraph.prototype.Is_Inline=function(){if(this.bFromDocument===false)return true;var PrevElement=this.Get_DocumentPrev();if(true===this.Is_Empty()&&undefined!==this.Get_SectionPr()&&null!==PrevElement&&(type_Paragraph!==PrevElement.Get_Type()||undefined===PrevElement.Get_SectionPr()))return true;if(undefined===this.Parent||!(this.Parent instanceof CDocument)&&(undefined===this.Parent.Parent||!(this.Parent.Parent instanceof
CHeaderFooter)))return true;if(undefined!=this.Pr.FramePr&&Asc.c_oAscYAlign.Inline!==this.Pr.FramePr.YAlign)return false;return true};Paragraph.prototype.IsInline=function(){return this.Is_Inline()};Paragraph.prototype.GetFramePr=function(){return this.Get_CompiledPr2(false).ParaPr.FramePr};Paragraph.prototype.Get_FramePr=function(){return this.GetFramePr()};Paragraph.prototype.Set_FramePr=function(FramePr,bDelete){var FramePr_old=this.Pr.FramePr;if(undefined===bDelete)bDelete=false;if(true===bDelete){this.Pr.FramePr=
undefined;this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,FramePr_old,undefined));this.CompiledPr.NeedRecalc=true;this.private_UpdateTrackRevisionOnChangeParaPr(true);return}var FrameParas=this.Internal_Get_FrameParagraphs();if(true===FramePr.FromDropCapMenu&&1===FrameParas.length){var NewFramePr=FramePr_old?FramePr_old.Copy():new CFramePr;if(undefined!=FramePr.DropCap){var OldLines=NewFramePr.Lines;NewFramePr.Init_Default_DropCap(FramePr.DropCap===Asc.c_oAscDropCap.Drop?
true:false);NewFramePr.Lines=OldLines}if(undefined!=FramePr.Lines){var AnchorPara=this.Get_FrameAnchorPara();if(null===AnchorPara||AnchorPara.Lines.length<=0)return;var Before=AnchorPara.Get_CompiledPr().ParaPr.Spacing.Before;var LineH=AnchorPara.Lines[0].Bottom-AnchorPara.Lines[0].Top-Before;var LineTA=AnchorPara.Lines[0].Metrics.TextAscent2;var LineTD=AnchorPara.Lines[0].Metrics.TextDescent+AnchorPara.Lines[0].Metrics.LineGap;this.Set_Spacing({LineRule:linerule_Exact,Line:FramePr.Lines*LineH},false);
this.Update_DropCapByLines(this.Internal_CalculateTextPr(this.Internal_GetStartPos()),FramePr.Lines,LineH,LineTA,LineTD,Before);NewFramePr.Lines=FramePr.Lines}if(undefined!=FramePr.FontFamily){var FF=new ParaTextPr({RFonts:{Ascii:{Name:FramePr.FontFamily.Name,Index:-1}}});this.SelectAll();this.Add(FF);this.RemoveSelection()}if(undefined!=FramePr.HSpace)NewFramePr.HSpace=FramePr.HSpace;this.Pr.FramePr=NewFramePr}else{var NewFramePr=FramePr_old?FramePr_old.Copy():new CFramePr;if(undefined!=FramePr.H)NewFramePr.H=
FramePr.H;if(undefined!=FramePr.HAnchor)NewFramePr.HAnchor=FramePr.HAnchor;if(undefined!=FramePr.HRule)NewFramePr.HRule=FramePr.HRule;if(undefined!=FramePr.HSpace)NewFramePr.HSpace=FramePr.HSpace;if(undefined!=FramePr.Lines)NewFramePr.Lines=FramePr.Lines;if(undefined!=FramePr.VAnchor)NewFramePr.VAnchor=FramePr.VAnchor;if(undefined!=FramePr.VSpace)NewFramePr.VSpace=FramePr.VSpace;NewFramePr.W=FramePr.W;if(undefined!=FramePr.X){NewFramePr.X=FramePr.X;NewFramePr.XAlign=undefined}if(undefined!=FramePr.XAlign){NewFramePr.XAlign=
FramePr.XAlign;NewFramePr.X=undefined}if(undefined!=FramePr.Y){NewFramePr.Y=FramePr.Y;NewFramePr.YAlign=undefined}if(undefined!=FramePr.YAlign){NewFramePr.YAlign=FramePr.YAlign;NewFramePr.Y=undefined}if(undefined!==FramePr.Wrap)if(false===FramePr.Wrap)NewFramePr.Wrap=wrap_NotBeside;else if(true===FramePr.Wrap)NewFramePr.Wrap=wrap_Around;else NewFramePr.Wrap=FramePr.Wrap;this.Pr.FramePr=NewFramePr}if(undefined!=FramePr.Brd){var Count=FrameParas.length;for(var Index=0;Index<Count;Index++)FrameParas[Index].Set_Borders(FramePr.Brd)}if(undefined!=
FramePr.Shd){var Count=FrameParas.length;for(var Index=0;Index<Count;Index++)FrameParas[Index].Set_Shd(FramePr.Shd)}this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,FramePr_old,this.Pr.FramePr));this.CompiledPr.NeedRecalc=true;this.private_UpdateTrackRevisionOnChangeParaPr(true)};Paragraph.prototype.Set_FramePr2=function(FramePr){this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,this.Pr.FramePr,FramePr));this.Pr.FramePr=FramePr;this.CompiledPr.NeedRecalc=
true;this.private_UpdateTrackRevisionOnChangeParaPr(true)};Paragraph.prototype.Set_FrameParaPr=function(Para){Para.CopyPr(this);Para.Set_Ind({FirstLine:0},false);this.Set_Spacing({After:0},false);this.Set_Ind({Right:0},false);this.RemoveNumPr()};Paragraph.prototype.Get_FrameBounds=function(FrameX,FrameY,FrameW,FrameH){var X0=FrameX,Y0=FrameY,X1=FrameX+FrameW,Y1=FrameY+FrameH;var Paras=this.Internal_Get_FrameParagraphs();var Count=Paras.length;var FramePr=this.Get_FramePr();if(0>=Count)return{X:X0,
Y:Y0,W:X1-X0,H:Y1-Y0};for(var Index=0;Index<Count;Index++){var Para=Paras[Index];var ParaPr=Para.Get_CompiledPr2(false).ParaPr;var Brd=ParaPr.Brd;var _X0=FrameX;if(undefined!==Brd.Left&&border_None!==Brd.Left.Value)_X0-=Brd.Left.Size+Brd.Left.Space+1;if(_X0<X0)X0=_X0;var _X1=FrameX+FrameW;if(undefined!==Brd.Right&&border_None!==Brd.Right.Value){_X1=Math.max(_X1,_X1-ParaPr.Ind.Right);_X1+=Brd.Right.Size+Brd.Right.Space+1}if(_X1>X1)X1=_X1}var _Y1=Y1;var BottomBorder=Paras[Count-1].Get_CompiledPr2(false).ParaPr.Brd.Bottom;
if(undefined!==BottomBorder&&border_None!==BottomBorder.Value)_Y1+=BottomBorder.Size+BottomBorder.Space;if(_Y1>Y1&&(Asc.linerule_Auto===FramePr.HRule||Asc.linerule_AtLeast===FramePr.HRule&&FrameH>=FramePr.H))Y1=_Y1;return{X:X0,Y:Y0,W:X1-X0,H:Y1-Y0}};Paragraph.prototype.SetCalculatedFrame=function(oFrame){this.CalculatedFrame=oFrame;oFrame.AddParagraph(this)};Paragraph.prototype.GetCalculatedFrame=function(){return this.CalculatedFrame};Paragraph.prototype.Internal_Get_FrameParagraphs=function(){if(this.CalculatedFrame&&
this.CalculatedFrame.GetParagraphs().length>0)return this.CalculatedFrame.GetParagraphs();var FrameParas=[];var FramePr=this.Get_FramePr();if(undefined===FramePr)return FrameParas;FrameParas.push(this);var Prev=this.Get_DocumentPrev();while(null!=Prev)if(type_Paragraph===Prev.GetType()){var PrevFramePr=Prev.Get_FramePr();if(undefined!=PrevFramePr&&true===FramePr.Compare(PrevFramePr)){FrameParas.push(Prev);Prev=Prev.Get_DocumentPrev()}else break}else break;var Next=this.Get_DocumentNext();while(null!=
Next)if(type_Paragraph===Next.GetType()){var NextFramePr=Next.Get_FramePr();if(undefined!=NextFramePr&&true===FramePr.Compare(NextFramePr)){FrameParas.push(Next);Next=Next.Get_DocumentNext()}else break}else break;return FrameParas};Paragraph.prototype.Is_LineDropCap=function(){var FrameParas=this.Internal_Get_FrameParagraphs();if(1!==FrameParas.length||1!==this.Lines.length)return false;return true};Paragraph.prototype.Get_LineDropCapWidth=function(){var W=this.Lines[0].Ranges[0].W;var ParaPr=this.Get_CompiledPr2(false).ParaPr;
W+=ParaPr.Ind.Left+ParaPr.Ind.FirstLine;return W};Paragraph.prototype.Change_Frame=function(X,Y,W,H,PageIndex){if(!this.LogicDocument||!this.CalculatedFrame||!this.CalculatedFrame.GetFramePr())return;var FramePr=this.CalculatedFrame.GetFramePr();if(Math.abs(Y-this.CalculatedFrame.T2)<.001&&Math.abs(X-this.CalculatedFrame.L2)<.001&&Math.abs(W-this.CalculatedFrame.W2)<.001&&Math.abs(H-this.CalculatedFrame.H2)<.001&&PageIndex===this.CalculatedFrame.PageIndex)return;var FrameParas=this.Internal_Get_FrameParagraphs();
if(false===this.LogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_None,{Type:AscCommon.changestype_2_ElementsArray_and_Type,Elements:FrameParas,CheckType:AscCommon.changestype_Paragraph_Content})){this.LogicDocument.StartAction(AscDFH.historydescription_Document_ParagraphChangeFrame);var NewFramePr=FramePr.Copy();if(Math.abs(X-this.CalculatedFrame.L2)>.001){NewFramePr.X=X+(this.CalculatedFrame.L-this.CalculatedFrame.L2);NewFramePr.XAlign=undefined;NewFramePr.HAnchor=Asc.c_oAscHAnchor.Page}if(Math.abs(Y-
this.CalculatedFrame.T2)>.001){NewFramePr.Y=Y+(this.CalculatedFrame.T-this.CalculatedFrame.T2);NewFramePr.YAlign=undefined;NewFramePr.VAnchor=Asc.c_oAscVAnchor.Page}if(Math.abs(W-this.CalculatedFrame.W2)>.001)NewFramePr.W=W-Math.abs(this.CalculatedFrame.W2-this.CalculatedFrame.W);if(Math.abs(H-this.CalculatedFrame.H2)>.001)if(undefined!=FramePr.DropCap&&Asc.c_oAscDropCap.None!=FramePr.DropCap&&1===FrameParas.length){var PageH=this.LogicDocument.Get_PageLimits(PageIndex).YLimit;var _H=Math.min(H,PageH);
NewFramePr.Lines=this.Update_DropCapByHeight(_H);NewFramePr.HRule=linerule_Exact;NewFramePr.H=H-Math.abs(this.CalculatedFrame.H2-this.CalculatedFrame.H)}else{if(H<=this.CalculatedFrame.H2)NewFramePr.HRule=linerule_Exact;else NewFramePr.HRule=Asc.linerule_AtLeast;NewFramePr.H=H}var Count=FrameParas.length;for(var Index=0;Index<Count;Index++){var Para=FrameParas[Index];Para.Set_FramePr(NewFramePr,false)}this.LogicDocument.Recalculate();this.LogicDocument.UpdateInterface();this.LogicDocument.UpdateRulers();
this.LogicDocument.UpdateTracks();this.LogicDocument.FinalizeAction()}};Paragraph.prototype.Supplement_FramePr=function(FramePr){if(undefined!=FramePr.DropCap&&Asc.c_oAscDropCap.None!=FramePr.DropCap){var _FramePr=this.Get_FramePr();var FirstFramePara=this;var Prev=FirstFramePara.Get_DocumentPrev();while(null!=Prev)if(type_Paragraph===Prev.GetType()){var PrevFramePr=Prev.Get_FramePr();if(undefined!=PrevFramePr&&true===_FramePr.Compare(PrevFramePr)){FirstFramePara=Prev;Prev=Prev.Get_DocumentPrev()}else break}else break;
var TextPr=FirstFramePara.GetFirstRunPr();if(undefined===TextPr.RFonts||undefined===TextPr.RFonts.Ascii)TextPr=this.Get_CompiledPr2(false).TextPr;FramePr.FontFamily={Name:TextPr.RFonts.Ascii.Name,Index:TextPr.RFonts.Ascii.Index}}var FrameParas=this.Internal_Get_FrameParagraphs();var Count=FrameParas.length;var ParaPr=FrameParas[0].Get_CompiledPr2(false).ParaPr.Copy();for(var Index=1;Index<Count;Index++){var TempPr=FrameParas[Index].Get_CompiledPr2(false).ParaPr;ParaPr=ParaPr.Compare(TempPr)}FramePr.Brd=
ParaPr.Brd;FramePr.Shd=ParaPr.Shd};Paragraph.prototype.CanAddDropCap=function(){for(var nPos=0,nCount=this.Content.length;nPos<nCount;++nPos){var bResult=this.Content[nPos].CanAddDropCap();if(null!==bResult)return bResult}return false};Paragraph.prototype.Get_TextForDropCap=function(DropCapText,UseContentPos,ContentPos,Depth){var EndPos=true===UseContentPos?ContentPos.Get(Depth):this.Content.length-1;for(var Pos=0;Pos<=EndPos;Pos++){this.Content[Pos].Get_TextForDropCap(DropCapText,true===UseContentPos&&
Pos===EndPos?true:false,ContentPos,Depth+1);if(true===DropCapText.Mixed&&(true===DropCapText.Check||DropCapText.Runs.length>0))return}};Paragraph.prototype.Split_DropCap=function(NewParagraph){var DropCapText=new CParagraphGetDropCapText;if(true==this.Selection.Use&&this.Parent.IsSelectedSingleElement()){var SelSP=this.Get_ParaContentPos(true,true);var SelEP=this.Get_ParaContentPos(true,false);if(0<=SelSP.Compare(SelEP))SelEP=SelSP;DropCapText.Check=true;this.Get_TextForDropCap(DropCapText,true,SelEP,
0);DropCapText.Check=false;this.Get_TextForDropCap(DropCapText,true,SelEP,0)}else{DropCapText.Mixed=true;DropCapText.Check=false;this.Get_TextForDropCap(DropCapText,false)}var Count=DropCapText.Text.length;var PrevRun=null;var CurrRun=null;for(var Pos=0,ParaPos=0,RunPos=0;Pos<Count;Pos++){if(PrevRun!==DropCapText.Runs[Pos]){PrevRun=DropCapText.Runs[Pos];CurrRun=new ParaRun(NewParagraph);CurrRun.Set_Pr(DropCapText.Runs[Pos].Pr.Copy());NewParagraph.Internal_Content_Add(ParaPos++,CurrRun,false);RunPos=
0}CurrRun.Add_ToContent(RunPos++,DropCapText.Text[Pos],false)}if(Count>0)return DropCapText.Runs[Count-1].Get_CompiledPr(true);return null};Paragraph.prototype.SelectFirstLetter=function(){var oStartPos=new CParagraphContentPos;var oEndPos=new CParagraphContentPos;for(var nPos=0,nCount=this.Content.length;nPos<nCount;++nPos){oStartPos.Update(nPos,0);oEndPos.Update(nPos,0);if(this.Content[nPos].GetFirstRunElementPos(para_Text,oStartPos,oEndPos,1)){this.StartSelectionFromCurPos();this.SetSelectionContentPos(oStartPos,
oEndPos,false);this.Document_SetThisElementCurrent();return true}}return false};Paragraph.prototype.CheckSelectionForDropCap=function(){var oSelectionStart=this.Get_ParaContentPos(true,true);var oSelectionEnd=this.Get_ParaContentPos(true,false);if(0<=oSelectionStart.Compare(oSelectionEnd))oSelectionEnd=oSelectionStart;var nEndPos=oSelectionEnd.Get(0);for(var nPos=0;nPos<=nEndPos;++nPos)if(!this.Content[nPos].CheckSelectionForDropCap(nPos===nEndPos,oSelectionEnd,1))return false;return true};Paragraph.prototype.Update_DropCapByLines=
function(TextPr,Count,LineH,LineTA,LineTD,Before){if(null===TextPr)return;this.Set_Spacing({Before:Before,After:0,LineRule:linerule_Exact,Line:Count*LineH-.001},false);var FontSize=72;TextPr.FontSize=FontSize;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TMetrics);var TDescent=TMetrics.Descent;var TAscent=TMetrics.Ascent;var THeight=0;if(null===TAscent||null===TDescent)THeight=
g_oTextMeasurer.GetHeight();else THeight=-TDescent+TAscent;var EmHeight=THeight;var NewEmHeight=(Count-1)*LineH+LineTA;var Koef=NewEmHeight/EmHeight;var NewFontSize=TextPr.FontSize*Koef;TextPr.FontSize=parseInt(NewFontSize*2)/2;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TNewMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TNewMetrics);var TNewDescent=TNewMetrics.Descent;var TNewAscent=TNewMetrics.Ascent;var TNewHeight=
0;if(null===TNewAscent||null===TNewDescent)TNewHeight=g_oTextMeasurer.GetHeight();else TNewHeight=-TNewDescent+TNewAscent;var Descent=g_oTextMeasurer.GetDescender();var Ascent=g_oTextMeasurer.GetAscender();var Dy=Descent*(LineH*Count)/(Ascent-Descent)+TNewHeight-TNewAscent+LineTD;var PTextPr=new ParaTextPr({RFonts:{Ascii:{Name:TextPr.RFonts.Ascii.Name,Index:-1}},FontSize:TextPr.FontSize,Position:Dy});this.SelectAll();this.Add(PTextPr);this.RemoveSelection()};Paragraph.prototype.Update_DropCapByHeight=
function(_Height){var AnchorPara=this.Get_FrameAnchorPara();if(null===AnchorPara||AnchorPara.Lines.length<=0)return 1;var Before=AnchorPara.Get_CompiledPr().ParaPr.Spacing.Before;var LineH=AnchorPara.Lines[0].Bottom-AnchorPara.Lines[0].Top-Before;var LineTA=AnchorPara.Lines[0].Metrics.TextAscent2;var LineTD=AnchorPara.Lines[0].Metrics.TextDescent+AnchorPara.Lines[0].Metrics.LineGap;var Height=_Height-Before;this.Set_Spacing({LineRule:linerule_Exact,Line:Height},false);var LinesCount=Math.ceil(Height/
LineH);var TextPr=this.Internal_CalculateTextPr(this.Internal_GetStartPos());g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TMetrics);var TDescent=TMetrics.Descent;var TAscent=TMetrics.Ascent;var THeight=0;if(null===TAscent||null===TDescent)THeight=g_oTextMeasurer.GetHeight();else THeight=-TDescent+TAscent;var Koef=(Height-LineTD)/THeight;var NewFontSize=TextPr.FontSize*Koef;
TextPr.FontSize=parseInt(NewFontSize*2)/2;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TNewMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TNewMetrics);var TNewDescent=TNewMetrics.Descent;var TNewAscent=TNewMetrics.Ascent;var TNewHeight=0;if(null===TNewAscent||null===TNewDescent)TNewHeight=g_oTextMeasurer.GetHeight();else TNewHeight=-TNewDescent+TNewAscent;var Descent=g_oTextMeasurer.GetDescender();var Ascent=g_oTextMeasurer.GetAscender();
var Dy=Descent*Height/(Ascent-Descent)+TNewHeight-TNewAscent+LineTD;var PTextPr=new ParaTextPr({RFonts:{Ascii:{Name:TextPr.RFonts.Ascii.Name,Index:-1}},FontSize:TextPr.FontSize,Position:Dy});this.SelectAll();this.Add(PTextPr);this.RemoveSelection();return LinesCount};Paragraph.prototype.Get_FrameAnchorPara=function(){var FramePr=this.Get_FramePr();if(undefined===FramePr)return null;var Next=this.Get_DocumentNext();while(null!=Next){if(type_Paragraph===Next.GetType()){var NextFramePr=Next.Get_FramePr();
if(undefined===NextFramePr||false===FramePr.Compare(NextFramePr))return Next}Next=Next.Get_DocumentNext()}return Next};Paragraph.prototype.Split=function(NewParagraph){if(!NewParagraph)NewParagraph=new Paragraph(this.DrawingDocument,this.Parent);NewParagraph.DeleteCommentOnRemove=false;this.DeleteCommentOnRemove=false;this.RemoveSelection();NewParagraph.RemoveSelection();var ContentPos=this.Get_ParaContentPos(false,false);var CurPos=ContentPos.Get(0);var TextPr=this.Get_TextPr(ContentPos);var oLogicDocument=
this.GetLogicDocument();var oStyles=oLogicDocument&&oLogicDocument.GetStyles?oLogicDocument.GetStyles():null;if(oStyles&&(TextPr.RStyle===oStyles.GetDefaultEndnoteReference()||TextPr.RStyle===oStyles.GetDefaultFootnoteReference())){TextPr=TextPr.Copy();TextPr.RStyle=undefined}var NewElement=this.Content[CurPos].Split(ContentPos,1);if(null===NewElement){NewElement=new ParaRun(NewParagraph);NewElement.Set_Pr(TextPr.Copy())}var NewContent=this.Content.slice(CurPos+1);this.Internal_Content_Remove2(CurPos+
1,this.Content.length-CurPos-1);var EndRun=new ParaRun(this);EndRun.Add_ToContent(0,new ParaEnd);this.Internal_Content_Add(this.Content.length,EndRun);NewParagraph.Internal_Content_Remove2(0,NewParagraph.Content.length);NewParagraph.Internal_Content_Concat(NewContent);NewParagraph.Internal_Content_Add(0,NewElement);NewParagraph.Correct_Content();this.CopyPr(NewParagraph);this.TextPr.Clear_Style();this.TextPr.Apply_TextPr(TextPr);var SectPr=this.Get_SectionPr();if(undefined!==SectPr){this.Set_SectionPr(undefined);
NewParagraph.Set_SectionPr(SectPr)}this.MoveCursorToEndPos(false,false);NewParagraph.MoveCursorToStartPos(false);NewParagraph.DeleteCommentOnRemove=true;this.DeleteCommentOnRemove=true;return NewParagraph};Paragraph.prototype.Concat=function(Para,isUseConcatedStyle){this.DeleteCommentOnRemove=false;Para.DeleteCommentOnRemove=false;this.Remove_ParaEnd();var NearPosCount=Para.NearPosArray.length;for(var Pos=0;Pos<NearPosCount;Pos++){var ParaNearPos=Para.NearPosArray[Pos];ParaNearPos.Classes[0]=this;
ParaNearPos.NearPos.Paragraph=this;ParaNearPos.NearPos.ContentPos.Data[0]+=this.Content.length;this.NearPosArray.push(ParaNearPos)}this.Internal_Content_Concat(Para.Content);Para.ClearContent();this.Set_SectionPr(undefined);var SectPr=Para.Get_SectionPr();if(undefined!==SectPr){Para.Set_SectionPr(undefined);this.Set_SectionPr(SectPr)}this.DeleteCommentOnRemove=true;Para.DeleteCommentOnRemove=true;if(true===isUseConcatedStyle)Para.CopyPr(this)};Paragraph.prototype.ConcatBefore=function(oPara){this.DeleteCommentOnRemove=
false;oPara.DeleteCommentOnRemove=false;oPara.Remove_ParaEnd();for(var nPos=0,nCount=this.NearPosArray.length;nPos<nCount;++nPos){var oParaNearPos=this.NearPosArray[nPos];oParaNearPos.NearPos.ContentPos.Data[0]+=oPara.Content.length}for(var nPos=0,nCount=oPara.NearPosArray.length;nPos<nCount;++nPos){var oParaNearPos=oPara.NearPosArray[nPos];oParaNearPos.Classes[0]=this;oParaNearPos.NearPos.Paragraph=this;this.NearPosArray.push(oParaNearPos)}for(var nPos=0,nCount=oPara.Content.length;nPos<nCount;++nPos)this.AddToContent(nPos,
oPara.Content[nPos]);oPara.ClearContent();oPara.Set_SectionPr(undefined);this.DeleteCommentOnRemove=true;oPara.DeleteCommentOnRemove=true;oPara.CopyPr(this)};Paragraph.prototype.Continue=function(NewParagraph){var TextPr;if(this.IsEmpty())TextPr=this.TextPr.Value.Copy();else{var EndPos=this.Get_EndPos2(false);var CurPos=this.Get_ParaContentPos(false,false);this.Set_ParaContentPos(EndPos,true,-1,-1);TextPr=this.Get_TextPr(this.Get_ParaContentPos(false,false)).Copy();this.Set_ParaContentPos(CurPos,
false,-1,-1,false);TextPr.HighLight=highlight_None;var oStyles;if(this.bFromDocument&&this.LogicDocument&&(oStyles=this.LogicDocument.GetStyles())&&(TextPr.RStyle===oStyles.GetDefaultFootnoteReference()||TextPr.RStyle===oStyles.GetDefaultEndnoteReference()))TextPr.RStyle=undefined}this.CopyPr(NewParagraph);if(!this.HaveNumbering()&&!this.Lock.Is_Locked()){this.TextPr.Clear_Style();this.TextPr.Apply_TextPr(TextPr)}NewParagraph.Internal_Content_Add(0,new ParaRun(NewParagraph));NewParagraph.Correct_Content();
NewParagraph.MoveCursorToStartPos(false);for(var Pos=0,Count=NewParagraph.Content.length;Pos<Count;Pos++)if(para_Run===NewParagraph.Content[Pos].Type)NewParagraph.Content[Pos].Set_Pr(TextPr.Copy())};Paragraph.prototype.GetSelectionState=function(){var ParaState={};ParaState.CurPos={X:this.CurPos.X,Y:this.CurPos.Y,Line:this.CurPos.Line,ContentPos:this.Get_ParaContentPos(false,false),RealX:this.CurPos.RealX,RealY:this.CurPos.RealY,PagesPos:this.CurPos.PagesPos};ParaState.Selection={Start:this.Selection.Start,
Use:this.Selection.Use,StartPos:0,EndPos:0,Flag:this.Selection.Flag};if(true===this.Selection.Use){ParaState.Selection.StartPos=this.Get_ParaContentPos(true,true);ParaState.Selection.EndPos=this.Get_ParaContentPos(true,false)}return[ParaState]};Paragraph.prototype.SetSelectionState=function(State,StateIndex){if(State.length<=0)return;var ParaState=State[StateIndex];this.CurPos.X=ParaState.CurPos.X;this.CurPos.Y=ParaState.CurPos.Y;this.CurPos.Line=ParaState.CurPos.Line;this.CurPos.RealX=ParaState.CurPos.RealX;
this.CurPos.RealY=ParaState.CurPos.RealY;this.CurPos.PagesPos=ParaState.CurPos.PagesPos;this.Set_ParaContentPos(ParaState.CurPos.ContentPos,true,-1,-1);this.RemoveSelection();this.Selection.Start=ParaState.Selection.Start;this.Selection.Use=ParaState.Selection.Use;this.Selection.Flag=ParaState.Selection.Flag;if(true===this.Selection.Use)this.Set_SelectionContentPos(ParaState.Selection.StartPos,ParaState.Selection.EndPos)};Paragraph.prototype.Get_ParentObject_or_DocumentPos=function(){this.Parent.Update_ContentIndexing();
return this.Parent.Get_ParentObject_or_DocumentPos(this.Index)};Paragraph.prototype.Refresh_RecalcData=function(Data){var Type=Data.Type;var bNeedRecalc=false;var CurPage=0;switch(Type){case AscDFH.historyitem_Paragraph_AddItem:case AscDFH.historyitem_Paragraph_RemoveItem:{for(CurPage=this.Pages.length-1;CurPage>0;CurPage--)if(Data.Pos>this.Lines[this.Pages[CurPage].StartLine].Get_StartPos())break;this.RecalcInfo.Set_Type_0(pararecalc_0_All);bNeedRecalc=true;break}case AscDFH.historyitem_Paragraph_Numbering:case AscDFH.historyitem_Paragraph_PStyle:case AscDFH.historyitem_Paragraph_Pr:case AscDFH.historyitem_Paragraph_PresentationPr_Bullet:case AscDFH.historyitem_Paragraph_PresentationPr_Level:{this.RecalcInfo.Set_Type_0(pararecalc_0_All);
bNeedRecalc=true;this.CompiledPr.NeedRecalc=true;this.Recalc_RunsCompiledPr();break}case AscDFH.historyitem_Paragraph_Align:case AscDFH.historyitem_Paragraph_DefaultTabSize:case AscDFH.historyitem_Paragraph_Ind_First:case AscDFH.historyitem_Paragraph_Ind_Left:case AscDFH.historyitem_Paragraph_Ind_Right:case AscDFH.historyitem_Paragraph_ContextualSpacing:case AscDFH.historyitem_Paragraph_KeepLines:case AscDFH.historyitem_Paragraph_KeepNext:case AscDFH.historyitem_Paragraph_PageBreakBefore:case AscDFH.historyitem_Paragraph_Spacing_Line:case AscDFH.historyitem_Paragraph_Spacing_LineRule:case AscDFH.historyitem_Paragraph_Spacing_Before:case AscDFH.historyitem_Paragraph_Spacing_After:case AscDFH.historyitem_Paragraph_Spacing_AfterAutoSpacing:case AscDFH.historyitem_Paragraph_Spacing_BeforeAutoSpacing:case AscDFH.historyitem_Paragraph_WidowControl:case AscDFH.historyitem_Paragraph_Tabs:case AscDFH.historyitem_Paragraph_Borders_Between:case AscDFH.historyitem_Paragraph_Borders_Bottom:case AscDFH.historyitem_Paragraph_Borders_Left:case AscDFH.historyitem_Paragraph_Borders_Right:case AscDFH.historyitem_Paragraph_Borders_Top:case AscDFH.historyitem_Paragraph_FramePr:{bNeedRecalc=
Paragraph.prototype.Document_CreateFontCharMap=function(FontCharMap){};Paragraph.prototype.Document_Get_AllFontNames=function(AllFonts){this.TextPr.Value.Document_Get_AllFontNames(AllFonts);if(this.Pr.Bullet)this.Pr.Bullet.Get_AllFontNames(AllFonts);if(this.Pr.DefaultRunPr)this.Pr.DefaultRunPr.Document_Get_AllFontNames(AllFonts);var Count=this.Content.length;for(var Index=0;Index<Count;Index++)if(this.Content[Index]&&typeof this.Content[Index].Get_AllFontNames==="function")this.Content[Index].Get_AllFontNames(AllFonts)};
Paragraph.prototype.Document_UpdateRulersState=function(){if(this.CalculatedFrame){var oFrame=this.CalculatedFrame;this.Parent.DrawingDocument.Set_RulerState_Paragraph({L:oFrame.L2,T:oFrame.T2,R:oFrame.L2+oFrame.W2,B:oFrame.T2+oFrame.H2,PageIndex:this.GetStartPageAbsolute(),Frame:this},false)}else if(this.Parent instanceof CDocument)if(this.LogicDocument)this.LogicDocument.Document_UpdateRulersStateBySection()};Paragraph.prototype.Document_UpdateInterfaceState=function(){var StartPos,EndPos;if(true===
this.Selection.Use){StartPos=this.Get_ParaContentPos(true,true);EndPos=this.Get_ParaContentPos(true,false)}else{var CurPos=this.Get_ParaContentPos(false,false);StartPos=CurPos;EndPos=CurPos}if(this.LogicDocument&&true===this.LogicDocument.Spelling.Use&&(selectionflag_Numbering!==this.Selection.Flag&&selectionflag_NumberingCur!==this.Selection.Flag))this.SpellChecker.Document_UpdateInterfaceState(StartPos,EndPos);if(true===this.Selection.Use){var StartPos=this.Selection.StartPos;var EndPos=this.Selection.EndPos;
if(StartPos>EndPos){StartPos=this.Selection.EndPos;EndPos=this.Selection.StartPos}for(var CurPos=StartPos;CurPos<=EndPos;CurPos++){var Element=this.Content[CurPos];if(true!==Element.IsSelectionEmpty()&&Element.Document_UpdateInterfaceState)Element.Document_UpdateInterfaceState()}}else{var CurType=this.Content[this.CurPos.ContentPos].Type;if(this.Content[this.CurPos.ContentPos].Document_UpdateInterfaceState)this.Content[this.CurPos.ContentPos].Document_UpdateInterfaceState()}var arrComplexFields=this.GetCurrentComplexFields();
for(var nIndex=0,nCount=arrComplexFields.length;nIndex<nCount;++nIndex){var oInstruction=arrComplexFields[nIndex].GetInstruction();if(oInstruction&&fieldtype_HYPERLINK===oInstruction.GetType()){var oHyperProps=new Asc.CHyperlinkProperty;oHyperProps.put_ToolTip(oInstruction.GetToolTip());oHyperProps.put_Value(oInstruction.GetValue());oHyperProps.put_Text(this.LogicDocument?this.LogicDocument.GetComplexFieldTextValue(arrComplexFields[nIndex]):null);oHyperProps.put_InternalHyperlink(oInstruction);editor.sync_HyperlinkPropCallback(oHyperProps)}}if(editor&&
this.bFromDocument){if(!this.LogicDocument)return;var TrackManager=this.LogicDocument.GetTrackRevisionsManager();if(this.Pages.length<=0&&this.Lines.length<=0)return;var ContentPos=this.Get_ParaContentPos(this.Selection.Use,true);var ParaPos=this.Get_ParaPosByContentPos(ContentPos);if(this.Pages.length<=ParaPos.Page||this.Lines.length<=ParaPos.Line)return;var Page_abs=this.Get_AbsolutePage(ParaPos.Page);var _Y=this.Pages[ParaPos.Page].Y+this.Lines[ParaPos.Line].Top;var TextTransform=this.Get_ParentTextTransform();
var _X=this.LogicDocument?this.LogicDocument.Get_PageLimits(Page_abs).XLimit:0;var Coords=this.DrawingDocument.ConvertCoordsToCursorWR(_X,_Y,Page_abs,TextTransform);if(false===this.Selection.Use){var Changes=TrackManager.GetElementChanges(this.GetId());if(Changes.length>0)for(var ChangeIndex=0,ChangesCount=Changes.length;ChangeIndex<ChangesCount;ChangeIndex++){var Change=Changes[ChangeIndex];var Type=Change.get_Type();if(c_oAscRevisionsChangeType.TextAdd!==Type&&c_oAscRevisionsChangeType.TextRem!==
Type&&c_oAscRevisionsChangeType.TextPr!==Type||StartPos.Compare(Change.get_StartPos())>=0&&StartPos.Compare(Change.get_EndPos())<=0){Change.put_InternalPos(_X,_Y,Page_abs);TrackManager.AddVisibleChange(Change)}}}}};Paragraph.prototype.PreDelete=function(){for(var Index=0;Index<this.Content.length;Index++){var Item=this.Content[Index];if(Item.PreDelete)Item.PreDelete();if(this.LogicDocument)if(para_Comment===Item.Type&&true===this.LogicDocument.RemoveCommentsOnPreDelete)this.LogicDocument.RemoveComment(Item.CommentId,
true,false);else if(para_Bookmark===Item.Type)this.LogicDocument.GetBookmarksManager().SetNeedUpdate(true)}this.RemoveSelection();this.UpdateDocumentOutline();if(undefined!==this.Get_SectionPr()&&this.LogicDocument)this.Set_SectionPr(undefined)};Paragraph.prototype.Document_SetThisElementCurrent=function(bUpdateStates){this.Parent.Update_ContentIndexing();this.Parent.Set_CurrentElement(this.Index,bUpdateStates)};Paragraph.prototype.Is_ThisElementCurrent=function(){var Parent=this.Parent;Parent.Update_ContentIndexing();
if(docpostype_Content===Parent.GetDocPosType()&&false===Parent.Selection.Use&&this.Index===Parent.CurPos.ContentPos&&Parent.Content[this.Index]===this)return this.Parent.Is_ThisElementCurrent();return false};Paragraph.prototype.Is_Inline=function(){if(this.bFromDocument===false)return true;var PrevElement=this.Get_DocumentPrev();if(true===this.Is_Empty()&&undefined!==this.Get_SectionPr()&&null!==PrevElement&&(type_Paragraph!==PrevElement.Get_Type()||undefined===PrevElement.Get_SectionPr()))return true;
if(undefined===this.Parent||!(this.Parent instanceof CDocument)&&(undefined===this.Parent.Parent||!(this.Parent.Parent instanceof CHeaderFooter)))return true;if(undefined!=this.Pr.FramePr&&Asc.c_oAscYAlign.Inline!==this.Pr.FramePr.YAlign)return false;return true};Paragraph.prototype.IsInline=function(){return this.Is_Inline()};Paragraph.prototype.GetFramePr=function(){return this.Get_CompiledPr2(false).ParaPr.FramePr};Paragraph.prototype.Get_FramePr=function(){return this.GetFramePr()};Paragraph.prototype.Set_FramePr=
function(FramePr,bDelete){var FramePr_old=this.Pr.FramePr;if(undefined===bDelete)bDelete=false;if(true===bDelete){this.Pr.FramePr=undefined;this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,FramePr_old,undefined));this.CompiledPr.NeedRecalc=true;this.private_UpdateTrackRevisionOnChangeParaPr(true);return}var FrameParas=this.Internal_Get_FrameParagraphs();if(true===FramePr.FromDropCapMenu&&1===FrameParas.length){var NewFramePr=FramePr_old?FramePr_old.Copy():new CFramePr;if(undefined!=
FramePr.DropCap){var OldLines=NewFramePr.Lines;NewFramePr.Init_Default_DropCap(FramePr.DropCap===Asc.c_oAscDropCap.Drop?true:false);NewFramePr.Lines=OldLines}if(undefined!=FramePr.Lines){var AnchorPara=this.Get_FrameAnchorPara();if(null===AnchorPara||AnchorPara.Lines.length<=0)return;var Before=AnchorPara.Get_CompiledPr().ParaPr.Spacing.Before;var LineH=AnchorPara.Lines[0].Bottom-AnchorPara.Lines[0].Top-Before;var LineTA=AnchorPara.Lines[0].Metrics.TextAscent2;var LineTD=AnchorPara.Lines[0].Metrics.TextDescent+
AnchorPara.Lines[0].Metrics.LineGap;this.Set_Spacing({LineRule:linerule_Exact,Line:FramePr.Lines*LineH},false);this.Update_DropCapByLines(this.Internal_CalculateTextPr(this.Internal_GetStartPos()),FramePr.Lines,LineH,LineTA,LineTD,Before);NewFramePr.Lines=FramePr.Lines}if(undefined!=FramePr.FontFamily){var FF=new ParaTextPr({RFonts:{Ascii:{Name:FramePr.FontFamily.Name,Index:-1}}});this.SelectAll();this.Add(FF);this.RemoveSelection()}if(undefined!=FramePr.HSpace)NewFramePr.HSpace=FramePr.HSpace;this.Pr.FramePr=
NewFramePr}else{var NewFramePr=FramePr_old?FramePr_old.Copy():new CFramePr;if(undefined!=FramePr.H)NewFramePr.H=FramePr.H;if(undefined!=FramePr.HAnchor)NewFramePr.HAnchor=FramePr.HAnchor;if(undefined!=FramePr.HRule)NewFramePr.HRule=FramePr.HRule;if(undefined!=FramePr.HSpace)NewFramePr.HSpace=FramePr.HSpace;if(undefined!=FramePr.Lines)NewFramePr.Lines=FramePr.Lines;if(undefined!=FramePr.VAnchor)NewFramePr.VAnchor=FramePr.VAnchor;if(undefined!=FramePr.VSpace)NewFramePr.VSpace=FramePr.VSpace;NewFramePr.W=
FramePr.W;if(undefined!=FramePr.X){NewFramePr.X=FramePr.X;NewFramePr.XAlign=undefined}if(undefined!=FramePr.XAlign){NewFramePr.XAlign=FramePr.XAlign;NewFramePr.X=undefined}if(undefined!=FramePr.Y){NewFramePr.Y=FramePr.Y;NewFramePr.YAlign=undefined}if(undefined!=FramePr.YAlign){NewFramePr.YAlign=FramePr.YAlign;NewFramePr.Y=undefined}if(undefined!==FramePr.Wrap)if(false===FramePr.Wrap)NewFramePr.Wrap=wrap_NotBeside;else if(true===FramePr.Wrap)NewFramePr.Wrap=wrap_Around;else NewFramePr.Wrap=FramePr.Wrap;
this.Pr.FramePr=NewFramePr}if(undefined!=FramePr.Brd){var Count=FrameParas.length;for(var Index=0;Index<Count;Index++)FrameParas[Index].Set_Borders(FramePr.Brd)}if(undefined!=FramePr.Shd){var Count=FrameParas.length;for(var Index=0;Index<Count;Index++)FrameParas[Index].Set_Shd(FramePr.Shd)}this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,FramePr_old,this.Pr.FramePr));this.CompiledPr.NeedRecalc=true;this.private_UpdateTrackRevisionOnChangeParaPr(true)};Paragraph.prototype.Set_FramePr2=
function(FramePr){this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,this.Pr.FramePr,FramePr));this.Pr.FramePr=FramePr;this.CompiledPr.NeedRecalc=true;this.private_UpdateTrackRevisionOnChangeParaPr(true)};Paragraph.prototype.Set_FrameParaPr=function(Para){Para.CopyPr(this);Para.Set_Ind({FirstLine:0},false);this.Set_Spacing({After:0},false);this.Set_Ind({Right:0},false);this.RemoveNumPr()};Paragraph.prototype.Get_FrameBounds=function(FrameX,FrameY,FrameW,FrameH){var X0=FrameX,
Y0=FrameY,X1=FrameX+FrameW,Y1=FrameY+FrameH;var Paras=this.Internal_Get_FrameParagraphs();var Count=Paras.length;var FramePr=this.Get_FramePr();if(0>=Count)return{X:X0,Y:Y0,W:X1-X0,H:Y1-Y0};for(var Index=0;Index<Count;Index++){var Para=Paras[Index];var ParaPr=Para.Get_CompiledPr2(false).ParaPr;var Brd=ParaPr.Brd;var _X0=FrameX;if(undefined!==Brd.Left&&border_None!==Brd.Left.Value)_X0-=Brd.Left.Size+Brd.Left.Space+1;if(_X0<X0)X0=_X0;var _X1=FrameX+FrameW;if(undefined!==Brd.Right&&border_None!==Brd.Right.Value){_X1=
Math.max(_X1,_X1-ParaPr.Ind.Right);_X1+=Brd.Right.Size+Brd.Right.Space+1}if(_X1>X1)X1=_X1}var _Y1=Y1;var BottomBorder=Paras[Count-1].Get_CompiledPr2(false).ParaPr.Brd.Bottom;if(undefined!==BottomBorder&&border_None!==BottomBorder.Value)_Y1+=BottomBorder.Size+BottomBorder.Space;if(_Y1>Y1&&(Asc.linerule_Auto===FramePr.HRule||Asc.linerule_AtLeast===FramePr.HRule&&FrameH>=FramePr.H))Y1=_Y1;return{X:X0,Y:Y0,W:X1-X0,H:Y1-Y0}};Paragraph.prototype.SetCalculatedFrame=function(oFrame){this.CalculatedFrame=
oFrame;oFrame.AddParagraph(this)};Paragraph.prototype.GetCalculatedFrame=function(){return this.CalculatedFrame};Paragraph.prototype.Internal_Get_FrameParagraphs=function(){if(this.CalculatedFrame&&this.CalculatedFrame.GetParagraphs().length>0)return this.CalculatedFrame.GetParagraphs();var FrameParas=[];var FramePr=this.Get_FramePr();if(undefined===FramePr)return FrameParas;FrameParas.push(this);var Prev=this.Get_DocumentPrev();while(null!=Prev)if(type_Paragraph===Prev.GetType()){var PrevFramePr=
Prev.Get_FramePr();if(undefined!=PrevFramePr&&true===FramePr.Compare(PrevFramePr)){FrameParas.push(Prev);Prev=Prev.Get_DocumentPrev()}else break}else break;var Next=this.Get_DocumentNext();while(null!=Next)if(type_Paragraph===Next.GetType()){var NextFramePr=Next.Get_FramePr();if(undefined!=NextFramePr&&true===FramePr.Compare(NextFramePr)){FrameParas.push(Next);Next=Next.Get_DocumentNext()}else break}else break;return FrameParas};Paragraph.prototype.Is_LineDropCap=function(){var FrameParas=this.Internal_Get_FrameParagraphs();
if(1!==FrameParas.length||1!==this.Lines.length)return false;return true};Paragraph.prototype.Get_LineDropCapWidth=function(){var W=this.Lines[0].Ranges[0].W;var ParaPr=this.Get_CompiledPr2(false).ParaPr;W+=ParaPr.Ind.Left+ParaPr.Ind.FirstLine;return W};Paragraph.prototype.Change_Frame=function(X,Y,W,H,PageIndex){if(!this.LogicDocument||!this.CalculatedFrame||!this.CalculatedFrame.GetFramePr())return;var FramePr=this.CalculatedFrame.GetFramePr();if(Math.abs(Y-this.CalculatedFrame.T2)<.001&&Math.abs(X-
this.CalculatedFrame.L2)<.001&&Math.abs(W-this.CalculatedFrame.W2)<.001&&Math.abs(H-this.CalculatedFrame.H2)<.001&&PageIndex===this.CalculatedFrame.PageIndex)return;var FrameParas=this.Internal_Get_FrameParagraphs();if(false===this.LogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_None,{Type:AscCommon.changestype_2_ElementsArray_and_Type,Elements:FrameParas,CheckType:AscCommon.changestype_Paragraph_Content})){this.LogicDocument.StartAction(AscDFH.historydescription_Document_ParagraphChangeFrame);
var NewFramePr=FramePr.Copy();if(Math.abs(X-this.CalculatedFrame.L2)>.001){NewFramePr.X=X+(this.CalculatedFrame.L-this.CalculatedFrame.L2);NewFramePr.XAlign=undefined;NewFramePr.HAnchor=Asc.c_oAscHAnchor.Page}if(Math.abs(Y-this.CalculatedFrame.T2)>.001){NewFramePr.Y=Y+(this.CalculatedFrame.T-this.CalculatedFrame.T2);NewFramePr.YAlign=undefined;NewFramePr.VAnchor=Asc.c_oAscVAnchor.Page}if(Math.abs(W-this.CalculatedFrame.W2)>.001)NewFramePr.W=W-Math.abs(this.CalculatedFrame.W2-this.CalculatedFrame.W);
if(Math.abs(H-this.CalculatedFrame.H2)>.001)if(undefined!=FramePr.DropCap&&Asc.c_oAscDropCap.None!=FramePr.DropCap&&1===FrameParas.length){var PageH=this.LogicDocument.Get_PageLimits(PageIndex).YLimit;var _H=Math.min(H,PageH);NewFramePr.Lines=this.Update_DropCapByHeight(_H);NewFramePr.HRule=linerule_Exact;NewFramePr.H=H-Math.abs(this.CalculatedFrame.H2-this.CalculatedFrame.H)}else{if(H<=this.CalculatedFrame.H2)NewFramePr.HRule=linerule_Exact;else NewFramePr.HRule=Asc.linerule_AtLeast;NewFramePr.H=
H}var Count=FrameParas.length;for(var Index=0;Index<Count;Index++){var Para=FrameParas[Index];Para.Set_FramePr(NewFramePr,false)}this.LogicDocument.Recalculate();this.LogicDocument.UpdateInterface();this.LogicDocument.UpdateRulers();this.LogicDocument.UpdateTracks();this.LogicDocument.FinalizeAction()}};Paragraph.prototype.Supplement_FramePr=function(FramePr){if(undefined!=FramePr.DropCap&&Asc.c_oAscDropCap.None!=FramePr.DropCap){var _FramePr=this.Get_FramePr();var FirstFramePara=this;var Prev=FirstFramePara.Get_DocumentPrev();
while(null!=Prev)if(type_Paragraph===Prev.GetType()){var PrevFramePr=Prev.Get_FramePr();if(undefined!=PrevFramePr&&true===_FramePr.Compare(PrevFramePr)){FirstFramePara=Prev;Prev=Prev.Get_DocumentPrev()}else break}else break;var TextPr=FirstFramePara.GetFirstRunPr();if(undefined===TextPr.RFonts||undefined===TextPr.RFonts.Ascii)TextPr=this.Get_CompiledPr2(false).TextPr;FramePr.FontFamily={Name:TextPr.RFonts.Ascii.Name,Index:TextPr.RFonts.Ascii.Index}}var FrameParas=this.Internal_Get_FrameParagraphs();
var Count=FrameParas.length;var ParaPr=FrameParas[0].Get_CompiledPr2(false).ParaPr.Copy();for(var Index=1;Index<Count;Index++){var TempPr=FrameParas[Index].Get_CompiledPr2(false).ParaPr;ParaPr=ParaPr.Compare(TempPr)}FramePr.Brd=ParaPr.Brd;FramePr.Shd=ParaPr.Shd};Paragraph.prototype.CanAddDropCap=function(){for(var nPos=0,nCount=this.Content.length;nPos<nCount;++nPos){var bResult=this.Content[nPos].CanAddDropCap();if(null!==bResult)return bResult}return false};Paragraph.prototype.Get_TextForDropCap=
function(DropCapText,UseContentPos,ContentPos,Depth){var EndPos=true===UseContentPos?ContentPos.Get(Depth):this.Content.length-1;for(var Pos=0;Pos<=EndPos;Pos++){this.Content[Pos].Get_TextForDropCap(DropCapText,true===UseContentPos&&Pos===EndPos?true:false,ContentPos,Depth+1);if(true===DropCapText.Mixed&&(true===DropCapText.Check||DropCapText.Runs.length>0))return}};Paragraph.prototype.Split_DropCap=function(NewParagraph){var DropCapText=new CParagraphGetDropCapText;if(true==this.Selection.Use&&this.Parent.IsSelectedSingleElement()){var SelSP=
this.Get_ParaContentPos(true,true);var SelEP=this.Get_ParaContentPos(true,false);if(0<=SelSP.Compare(SelEP))SelEP=SelSP;DropCapText.Check=true;this.Get_TextForDropCap(DropCapText,true,SelEP,0);DropCapText.Check=false;this.Get_TextForDropCap(DropCapText,true,SelEP,0)}else{DropCapText.Mixed=true;DropCapText.Check=false;this.Get_TextForDropCap(DropCapText,false)}var Count=DropCapText.Text.length;var PrevRun=null;var CurrRun=null;for(var Pos=0,ParaPos=0,RunPos=0;Pos<Count;Pos++){if(PrevRun!==DropCapText.Runs[Pos]){PrevRun=
DropCapText.Runs[Pos];CurrRun=new ParaRun(NewParagraph);CurrRun.Set_Pr(DropCapText.Runs[Pos].Pr.Copy());NewParagraph.Internal_Content_Add(ParaPos++,CurrRun,false);RunPos=0}CurrRun.Add_ToContent(RunPos++,DropCapText.Text[Pos],false)}if(Count>0)return DropCapText.Runs[Count-1].Get_CompiledPr(true);return null};Paragraph.prototype.SelectFirstLetter=function(){var oStartPos=new CParagraphContentPos;var oEndPos=new CParagraphContentPos;for(var nPos=0,nCount=this.Content.length;nPos<nCount;++nPos){oStartPos.Update(nPos,
0);oEndPos.Update(nPos,0);if(this.Content[nPos].GetFirstRunElementPos(para_Text,oStartPos,oEndPos,1)){this.StartSelectionFromCurPos();this.SetSelectionContentPos(oStartPos,oEndPos,false);this.Document_SetThisElementCurrent();return true}}return false};Paragraph.prototype.CheckSelectionForDropCap=function(){var oSelectionStart=this.Get_ParaContentPos(true,true);var oSelectionEnd=this.Get_ParaContentPos(true,false);if(0<=oSelectionStart.Compare(oSelectionEnd))oSelectionEnd=oSelectionStart;var nEndPos=
oSelectionEnd.Get(0);for(var nPos=0;nPos<=nEndPos;++nPos)if(!this.Content[nPos].CheckSelectionForDropCap(nPos===nEndPos,oSelectionEnd,1))return false;return true};Paragraph.prototype.Update_DropCapByLines=function(TextPr,Count,LineH,LineTA,LineTD,Before){if(null===TextPr)return;this.Set_Spacing({Before:Before,After:0,LineRule:linerule_Exact,Line:Count*LineH-.001},false);var FontSize=72;TextPr.FontSize=FontSize;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,
1);var TMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TMetrics);var TDescent=TMetrics.Descent;var TAscent=TMetrics.Ascent;var THeight=0;if(null===TAscent||null===TDescent)THeight=g_oTextMeasurer.GetHeight();else THeight=-TDescent+TAscent;var EmHeight=THeight;var NewEmHeight=(Count-1)*LineH+LineTA;var Koef=NewEmHeight/EmHeight;var NewFontSize=TextPr.FontSize*Koef;TextPr.FontSize=parseInt(NewFontSize*2)/2;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,
1);var TNewMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TNewMetrics);var TNewDescent=TNewMetrics.Descent;var TNewAscent=TNewMetrics.Ascent;var TNewHeight=0;if(null===TNewAscent||null===TNewDescent)TNewHeight=g_oTextMeasurer.GetHeight();else TNewHeight=-TNewDescent+TNewAscent;var Descent=g_oTextMeasurer.GetDescender();var Ascent=g_oTextMeasurer.GetAscender();var Dy=Descent*(LineH*Count)/(Ascent-Descent)+TNewHeight-TNewAscent+LineTD;var PTextPr=new ParaTextPr({RFonts:{Ascii:{Name:TextPr.RFonts.Ascii.Name,
Index:-1}},FontSize:TextPr.FontSize,Position:Dy});this.SelectAll();this.Add(PTextPr);this.RemoveSelection()};Paragraph.prototype.Update_DropCapByHeight=function(_Height){var AnchorPara=this.Get_FrameAnchorPara();if(null===AnchorPara||AnchorPara.Lines.length<=0)return 1;var Before=AnchorPara.Get_CompiledPr().ParaPr.Spacing.Before;var LineH=AnchorPara.Lines[0].Bottom-AnchorPara.Lines[0].Top-Before;var LineTA=AnchorPara.Lines[0].Metrics.TextAscent2;var LineTD=AnchorPara.Lines[0].Metrics.TextDescent+
AnchorPara.Lines[0].Metrics.LineGap;var Height=_Height-Before;this.Set_Spacing({LineRule:linerule_Exact,Line:Height},false);var LinesCount=Math.ceil(Height/LineH);var TextPr=this.Internal_CalculateTextPr(this.Internal_GetStartPos());g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TMetrics);var TDescent=TMetrics.Descent;var TAscent=TMetrics.Ascent;var THeight=0;if(null===TAscent||
null===TDescent)THeight=g_oTextMeasurer.GetHeight();else THeight=-TDescent+TAscent;var Koef=(Height-LineTD)/THeight;var NewFontSize=TextPr.FontSize*Koef;TextPr.FontSize=parseInt(NewFontSize*2)/2;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TNewMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TNewMetrics);var TNewDescent=TNewMetrics.Descent;var TNewAscent=TNewMetrics.Ascent;var TNewHeight=0;if(null===TNewAscent||null===TNewDescent)TNewHeight=
g_oTextMeasurer.GetHeight();else TNewHeight=-TNewDescent+TNewAscent;var Descent=g_oTextMeasurer.GetDescender();var Ascent=g_oTextMeasurer.GetAscender();var Dy=Descent*Height/(Ascent-Descent)+TNewHeight-TNewAscent+LineTD;var PTextPr=new ParaTextPr({RFonts:{Ascii:{Name:TextPr.RFonts.Ascii.Name,Index:-1}},FontSize:TextPr.FontSize,Position:Dy});this.SelectAll();this.Add(PTextPr);this.RemoveSelection();return LinesCount};Paragraph.prototype.Get_FrameAnchorPara=function(){var FramePr=this.Get_FramePr();
if(undefined===FramePr)return null;var Next=this.Get_DocumentNext();while(null!=Next){if(type_Paragraph===Next.GetType()){var NextFramePr=Next.Get_FramePr();if(undefined===NextFramePr||false===FramePr.Compare(NextFramePr))return Next}Next=Next.Get_DocumentNext()}return Next};Paragraph.prototype.Split=function(NewParagraph){if(!NewParagraph)NewParagraph=new Paragraph(this.DrawingDocument,this.Parent);NewParagraph.DeleteCommentOnRemove=false;this.DeleteCommentOnRemove=false;this.RemoveSelection();NewParagraph.RemoveSelection();
var ContentPos=this.Get_ParaContentPos(false,false);var CurPos=ContentPos.Get(0);var TextPr=this.Get_TextPr(ContentPos);var oLogicDocument=this.GetLogicDocument();var oStyles=oLogicDocument&&oLogicDocument.GetStyles?oLogicDocument.GetStyles():null;if(oStyles&&(TextPr.RStyle===oStyles.GetDefaultEndnoteReference()||TextPr.RStyle===oStyles.GetDefaultFootnoteReference())){TextPr=TextPr.Copy();TextPr.RStyle=undefined}var NewElement=this.Content[CurPos].Split(ContentPos,1);if(null===NewElement){NewElement=
new ParaRun(NewParagraph);NewElement.Set_Pr(TextPr.Copy())}var NewContent=this.Content.slice(CurPos+1);this.Internal_Content_Remove2(CurPos+1,this.Content.length-CurPos-1);var EndRun=new ParaRun(this);EndRun.Add_ToContent(0,new ParaEnd);this.Internal_Content_Add(this.Content.length,EndRun);NewParagraph.Internal_Content_Remove2(0,NewParagraph.Content.length);NewParagraph.Internal_Content_Concat(NewContent);NewParagraph.Internal_Content_Add(0,NewElement);NewParagraph.Correct_Content();this.CopyPr(NewParagraph);
this.TextPr.Clear_Style();this.TextPr.Apply_TextPr(TextPr);var SectPr=this.Get_SectionPr();if(undefined!==SectPr){this.Set_SectionPr(undefined);NewParagraph.Set_SectionPr(SectPr)}this.MoveCursorToEndPos(false,false);NewParagraph.MoveCursorToStartPos(false);NewParagraph.DeleteCommentOnRemove=true;this.DeleteCommentOnRemove=true;return NewParagraph};Paragraph.prototype.Concat=function(Para,isUseConcatedStyle){this.DeleteCommentOnRemove=false;Para.DeleteCommentOnRemove=false;this.Remove_ParaEnd();var NearPosCount=
Para.NearPosArray.length;for(var Pos=0;Pos<NearPosCount;Pos++){var ParaNearPos=Para.NearPosArray[Pos];ParaNearPos.Classes[0]=this;ParaNearPos.NearPos.Paragraph=this;ParaNearPos.NearPos.ContentPos.Data[0]+=this.Content.length;this.NearPosArray.push(ParaNearPos)}this.Internal_Content_Concat(Para.Content);Para.ClearContent();this.Set_SectionPr(undefined);var SectPr=Para.Get_SectionPr();if(undefined!==SectPr){Para.Set_SectionPr(undefined);this.Set_SectionPr(SectPr)}this.DeleteCommentOnRemove=true;Para.DeleteCommentOnRemove=
true;if(true===isUseConcatedStyle)Para.CopyPr(this)};Paragraph.prototype.ConcatBefore=function(oPara){this.DeleteCommentOnRemove=false;oPara.DeleteCommentOnRemove=false;oPara.Remove_ParaEnd();for(var nPos=0,nCount=this.NearPosArray.length;nPos<nCount;++nPos){var oParaNearPos=this.NearPosArray[nPos];oParaNearPos.NearPos.ContentPos.Data[0]+=oPara.Content.length}for(var nPos=0,nCount=oPara.NearPosArray.length;nPos<nCount;++nPos){var oParaNearPos=oPara.NearPosArray[nPos];oParaNearPos.Classes[0]=this;
oParaNearPos.NearPos.Paragraph=this;this.NearPosArray.push(oParaNearPos)}for(var nPos=0,nCount=oPara.Content.length;nPos<nCount;++nPos)this.AddToContent(nPos,oPara.Content[nPos]);oPara.ClearContent();oPara.Set_SectionPr(undefined);this.DeleteCommentOnRemove=true;oPara.DeleteCommentOnRemove=true;oPara.CopyPr(this)};Paragraph.prototype.Continue=function(NewParagraph){var TextPr;if(this.IsEmpty())TextPr=this.TextPr.Value.Copy();else{var EndPos=this.Get_EndPos2(false);var CurPos=this.Get_ParaContentPos(false,
false);this.Set_ParaContentPos(EndPos,true,-1,-1);TextPr=this.Get_TextPr(this.Get_ParaContentPos(false,false)).Copy();this.Set_ParaContentPos(CurPos,false,-1,-1,false);TextPr.HighLight=highlight_None;var oStyles;if(this.bFromDocument&&this.LogicDocument&&(oStyles=this.LogicDocument.GetStyles())&&(TextPr.RStyle===oStyles.GetDefaultFootnoteReference()||TextPr.RStyle===oStyles.GetDefaultEndnoteReference()))TextPr.RStyle=undefined}this.CopyPr(NewParagraph);if(!this.HaveNumbering()&&!this.Lock.Is_Locked()){this.TextPr.Clear_Style();
this.TextPr.Apply_TextPr(TextPr)}NewParagraph.Internal_Content_Add(0,new ParaRun(NewParagraph));NewParagraph.Correct_Content();NewParagraph.MoveCursorToStartPos(false);for(var Pos=0,Count=NewParagraph.Content.length;Pos<Count;Pos++)if(para_Run===NewParagraph.Content[Pos].Type)NewParagraph.Content[Pos].Set_Pr(TextPr.Copy())};Paragraph.prototype.GetSelectionState=function(){var ParaState={};ParaState.CurPos={X:this.CurPos.X,Y:this.CurPos.Y,Line:this.CurPos.Line,ContentPos:this.Get_ParaContentPos(false,
false),RealX:this.CurPos.RealX,RealY:this.CurPos.RealY,PagesPos:this.CurPos.PagesPos};ParaState.Selection={Start:this.Selection.Start,Use:this.Selection.Use,StartPos:0,EndPos:0,Flag:this.Selection.Flag};if(true===this.Selection.Use){ParaState.Selection.StartPos=this.Get_ParaContentPos(true,true);ParaState.Selection.EndPos=this.Get_ParaContentPos(true,false)}return[ParaState]};Paragraph.prototype.SetSelectionState=function(State,StateIndex){if(State.length<=0)return;var ParaState=State[StateIndex];
this.CurPos.X=ParaState.CurPos.X;this.CurPos.Y=ParaState.CurPos.Y;this.CurPos.Line=ParaState.CurPos.Line;this.CurPos.RealX=ParaState.CurPos.RealX;this.CurPos.RealY=ParaState.CurPos.RealY;this.CurPos.PagesPos=ParaState.CurPos.PagesPos;this.Set_ParaContentPos(ParaState.CurPos.ContentPos,true,-1,-1);this.RemoveSelection();this.Selection.Start=ParaState.Selection.Start;this.Selection.Use=ParaState.Selection.Use;this.Selection.Flag=ParaState.Selection.Flag;if(true===this.Selection.Use)this.Set_SelectionContentPos(ParaState.Selection.StartPos,
ParaState.Selection.EndPos)};Paragraph.prototype.Get_ParentObject_or_DocumentPos=function(){this.Parent.Update_ContentIndexing();return this.Parent.Get_ParentObject_or_DocumentPos(this.Index)};Paragraph.prototype.Refresh_RecalcData=function(Data){var Type=Data.Type;var bNeedRecalc=false;var CurPage=0;switch(Type){case AscDFH.historyitem_Paragraph_AddItem:case AscDFH.historyitem_Paragraph_RemoveItem:{for(CurPage=this.Pages.length-1;CurPage>0;CurPage--)if(Data.Pos>this.Lines[this.Pages[CurPage].StartLine].Get_StartPos())break;
this.RecalcInfo.Set_Type_0(pararecalc_0_All);bNeedRecalc=true;break}case AscDFH.historyitem_Paragraph_Numbering:case AscDFH.historyitem_Paragraph_PStyle:case AscDFH.historyitem_Paragraph_Pr:case AscDFH.historyitem_Paragraph_PresentationPr_Bullet:case AscDFH.historyitem_Paragraph_PresentationPr_Level:{this.RecalcInfo.Set_Type_0(pararecalc_0_All);bNeedRecalc=true;this.CompiledPr.NeedRecalc=true;this.Recalc_RunsCompiledPr();break}case AscDFH.historyitem_Paragraph_Align:case AscDFH.historyitem_Paragraph_DefaultTabSize:case AscDFH.historyitem_Paragraph_Ind_First:case AscDFH.historyitem_Paragraph_Ind_Left:case AscDFH.historyitem_Paragraph_Ind_Right:case AscDFH.historyitem_Paragraph_ContextualSpacing:case AscDFH.historyitem_Paragraph_KeepLines:case AscDFH.historyitem_Paragraph_KeepNext:case AscDFH.historyitem_Paragraph_PageBreakBefore:case AscDFH.historyitem_Paragraph_Spacing_Line:case AscDFH.historyitem_Paragraph_Spacing_LineRule:case AscDFH.historyitem_Paragraph_Spacing_Before:case AscDFH.historyitem_Paragraph_Spacing_After:case AscDFH.historyitem_Paragraph_Spacing_AfterAutoSpacing:case AscDFH.historyitem_Paragraph_Spacing_BeforeAutoSpacing:case AscDFH.historyitem_Paragraph_WidowControl:case AscDFH.historyitem_Paragraph_Tabs:case AscDFH.historyitem_Paragraph_Borders_Between:case AscDFH.historyitem_Paragraph_Borders_Bottom:case AscDFH.historyitem_Paragraph_Borders_Left:case AscDFH.historyitem_Paragraph_Borders_Right:case AscDFH.historyitem_Paragraph_Borders_Top:case AscDFH.historyitem_Paragraph_FramePr:{bNeedRecalc=
true;break}case AscDFH.historyitem_Paragraph_Shd_Value:case AscDFH.historyitem_Paragraph_Shd_Color:case AscDFH.historyitem_Paragraph_Shd_Unifill:case AscDFH.historyitem_Paragraph_Shd:{if(this.Parent){var oDrawingShape=this.Parent.Is_DrawingShape(true);if(oDrawingShape&&oDrawingShape.getObjectType&&oDrawingShape.getObjectType()===AscDFH.historyitem_type_Shape)if(oDrawingShape.chekBodyPrTransform(oDrawingShape.getBodyPr())||oDrawingShape.checkContentWordArt(oDrawingShape.getDocContent()))bNeedRecalc=
true;if(this.Parent.IsTableHeader())bNeedRecalc=true}break}case AscDFH.historyitem_Paragraph_SectionPr:{if(this.Parent instanceof CDocument){this.Parent.UpdateContentIndexing();var nSectionIndex=this.Parent.GetSectionIndexByElementIndex(this.GetIndex());var oFirstElement=this.Parent.GetFirstElementInSection(nSectionIndex);if(oFirstElement)this.Parent.Refresh_RecalcData2(oFirstElement.GetIndex(),oFirstElement.private_GetRelativePageIndex(0))}break}case AscDFH.historyitem_Paragraph_PrChange:{if(Data instanceof
CChangesParagraphPrChange&&Data.IsChangedNumbering())bNeedRecalc=true;break}case AscDFH.historyitem_Paragraph_SuppressLineNumbers:{History.AddLineNumbersToRecalculateData();break}}if(true===bNeedRecalc){var Prev=this.Get_DocumentPrev();if(0===CurPage&&null!=Prev&&type_Paragraph===Prev.GetType()&&true===Prev.Get_CompiledPr2(false).ParaPr.KeepNext)Prev.Refresh_RecalcData2(Prev.Pages.length-1);return this.Refresh_RecalcData2(CurPage)}};Paragraph.prototype.Refresh_RecalcData2=function(CurPage){if(!CurPage)CurPage=

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1732,13 +1732,11 @@ define([
postMessage(clientId, "PAD_CACHE");
},
onCacheReady: function () {
channel.hasCache = true;
postMessage(clientId, "PAD_CACHE_READY");
},
onReady: function (pad) {
var padData = pad.metadata || {};
channel.data = padData;
channel.ready = true;
if (padData && padData.validateKey && store.messenger) {
store.messenger.storeValidateKey(data.channel, padData.validateKey);
}
@ -2624,22 +2622,28 @@ define([
// "cb" is wrapped in Util.once() and may have already been called
// if we have a local cache
var onReady = function (clientId, returned, cb) {
console.error('READY');
store.ready = true;
var proxy = store.proxy;
var manager = store.manager;
var userObject = store.userObject;
nThen(function (waitFor) {
if (manager) { return; }
if (!proxy.settings) { proxy.settings = NEW_USER_SETTINGS; }
if (!proxy.friends_pending) { proxy.friends_pending = {}; }
onCacheReady(clientId, waitFor());
manager = store.manager;
userObject = store.userObject;
}).nThen(function (waitFor) {
// Call onCacheReady if the manager is not yet defined
if (!manager) {
onCacheReady(clientId, waitFor());
manager = store.manager;
userObject = store.userObject;
}
// Initialize RPC in parallel of onCacheReady in case a shared folder
// is RESTRICTED and requires RPC authentication
initAnonRpc(null, null, waitFor());
initRpc(null, null, waitFor());
// Update loading progress
postMessage(clientId, 'LOADING_DRIVE', {
type: 'migrate',
progress: 0

@ -187,7 +187,7 @@ define([
team.rpc = call;
team.onRpcReadyEvt.fire();
cb();
});
}, Cache);
});
};
@ -351,10 +351,9 @@ define([
var team;
if (!ctx.store.proxy.teams[id]) { return; }
nThen(function (waitFor) {
if (ctx.cache[id]) { return; }
onCacheReady(ctx, id, lm, roster, keys, cId, waitFor());
}).nThen(function (waitFor) {
team = ctx.teams[id];
team = ctx.teams[id] || ctx.cache[id];
// Init Team RPC
if (!keys.drive.edPrivate) { return; }
initRpc(ctx, team, keys.drive, waitFor(function () {}));

@ -213,10 +213,6 @@ define([
evStart.reg(function () { toolbar.forgotten(); });
break;
}
case STATE.FORBIDDEN: {
evStart.reg(function () { toolbar.deleted(); });
break;
}
case STATE.DELETED: {
evStart.reg(function () { toolbar.deleted(); });
break;

@ -801,7 +801,7 @@ define([
$err.find('a').click(function () {
funcs.gotoURL();
});
UI.findOKButton().click();
UI.findOKButton().click(); // FIXME this might be randomly clicking something dangerous...
UI.errorLoadingScreen($err, true, true);
});

@ -546,6 +546,9 @@ MessengerUI, Messages) {
hidden: true
});
$shareBlock.click(function () {
if (toolbar.isDeleted) {
return void UI.warn(Messages.deletedFromServer);
}
var title = (config.title && config.title.getTitle && config.title.getTitle())
|| (config.title && config.title.defaultName)
|| "";
@ -569,6 +572,9 @@ MessengerUI, Messages) {
h('span.cp-button-name', Messages.accessButton)
]));
$accessBlock.click(function () {
if (toolbar.isDeleted) {
return void UI.warn(Messages.deletedFromServer);
}
var title = (config.title && config.title.getTitle && config.title.getTitle())
|| (config.title && config.title.defaultName)
|| "";

Loading…
Cancel
Save