/* * (c) Copyright Ascensio System SIA 2010-2014 * * This program is a free software product. You can redistribute it and/or * modify it under the terms of the GNU Affero General Public License (AGPL) * version 3 as published by the Free Software Foundation. In accordance with * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect * that Ascensio System SIA expressly excludes the warranty of non-infringement * of any third-party rights. * * This program is distributed WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html * * You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, * EU, LV-1021. * * The interactive user interfaces in modified source and object code versions * of the Program must display Appropriate Legal Notices, as required under * Section 5 of the GNU AGPL version 3. * * Pursuant to Section 7(b) of the License you must retain the original Product * logo when distributing the program. Pursuant to Section 7(e) we decline to * grant you any rights under trademark law for use of our trademarks. * * All the Product's GUI elements, including illustrations and icon sets, as * well as technical writing content are licensed under the terms of the * Creative Commons Attribution-ShareAlike 4.0 International. See the License * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * */ var g_dDpiX = 96; var g_dDpiY = 96; var g_dKoef_mm_to_pix = g_dDpiX / 25.4; var g_dKoef_pix_to_mm = 25.4 / g_dDpiX; var g_bIsMobile = AscBrowser.isMobile; var g_bIsMouseUpLockedSend = false; var Page_Width = 210; var Page_Height = 297; var X_Left_Margin = 30; var X_Right_Margin = 15; var Y_Bottom_Margin = 20; var Y_Top_Margin = 20; var Y_Default_Header = 12.5; var Y_Default_Footer = 12.5; var X_Left_Field = X_Left_Margin; var X_Right_Field = Page_Width - X_Right_Margin; var Y_Bottom_Field = Page_Height - Y_Bottom_Margin; var Y_Top_Field = Y_Top_Margin; var docpostype_Content = 0; var docpostype_FlowObjects = 1; var docpostype_HdrFtr = 2; var selectionflag_Common = 0; var selectionflag_Numbering = 1; var selectionflag_DrawingObject = 2; var orientation_Portrait = 0; var orientation_Landscape = 1; var tableSpacingMinValue = 0.02; if (AscBrowser.isIE || window.opera) { document.onselectstart = function () { return false; }; } function CEditorPage(api) { this.Name = ""; this.X = 0; this.Y = 0; this.Width = 10; this.Height = 10; this.m_oBody = null; this.m_oMenu = null; this.m_oPanelRight = null; this.m_oScrollHor = null; this.m_oMainContent = null; this.m_oLeftRuler = null; this.m_oTopRuler = null; this.m_oMainView = null; this.m_oEditor = null; this.m_oOverlay = null; this.TextBoxBackground = null; this.ReaderModeDivWrapper = null; this.ReaderModeDiv = null; this.m_oOverlayApi = new COverlay(); this.m_bIsIE = (AscBrowser.isIE || window.opera) ? true : false; this.m_oPanelRight_buttonRulers = null; this.m_oPanelRight_vertScroll = null; this.m_oPanelRight_buttonPrevPage = null; this.m_oPanelRight_buttonNextPage = null; this.m_oLeftRuler_buttonsTabs = null; this.m_oLeftRuler_vertRuler = null; this.m_oTopRuler_horRuler = null; this.m_bIsHorScrollVisible = false; this.m_bIsRuler = (api.isMobileVersion === true) ? false : true; this.m_nZoomValue = 100; this.m_oBoundsController = new CBoundsController(); this.m_nTabsType = 0; this.m_dScrollY = 0; this.m_dScrollX = 0; this.m_dScrollY_max = 1; this.m_dScrollX_max = 1; this.m_bIsRePaintOnScroll = true; this.m_dDocumentWidth = 0; this.m_dDocumentHeight = 0; this.m_dDocumentPageWidth = 0; this.m_dDocumentPageHeight = 0; this.NoneRepaintPages = false; this.m_bIsScroll = false; this.ScrollsWidthPx = 16; this.m_oHorRuler = new CHorRuler(); this.m_oVerRuler = new CVerRuler(); this.m_oDrawingDocument = new CDrawingDocument(); this.m_oLogicDocument = null; this.m_oDrawingDocument.m_oWordControl = this; this.m_oDrawingDocument.m_oLogicDocument = this.m_oLogicDocument; this.m_bIsUpdateHorRuler = false; this.m_bIsUpdateVerRuler = false; this.m_bIsUpdateTargetNoAttack = false; this.m_bIsFullRepaint = false; this.m_oScrollHor_ = null; this.m_oScrollVer_ = null; this.m_oScrollHorApi = null; this.m_oScrollVerApi = null; this.arrayEventHandlers = new Array(); this.m_oTimerScrollSelect = -1; this.IsFocus = true; this.m_bIsMouseLock = false; this.m_nTimeDrawingLast = 0; this.DrawingFreeze = false; this.m_oHorRuler.m_oWordControl = this; this.m_oVerRuler.m_oWordControl = this; this.IsKeyDownButNoPress = false; this.MouseDownDocumentCounter = 0; this.bIsUseKeyPress = true; this.bIsEventPaste = false; this.bIsDoublePx = true; var oTestSpan = document.createElement("span"); oTestSpan.setAttribute("style", "font-size:8pt"); document.body.appendChild(oTestSpan); var defaultView = oTestSpan.ownerDocument.defaultView; var computedStyle = defaultView.getComputedStyle(oTestSpan, null); if (null != computedStyle) { var fontSize = computedStyle.getPropertyValue("font-size"); if (-1 != fontSize.indexOf("px") && parseFloat(fontSize) == parseInt(fontSize)) { this.bIsDoublePx = false; } } document.body.removeChild(oTestSpan); this.m_nPaintTimerId = -1; this.m_nTimerScrollInterval = 40; this.m_nCurrentTimeClearCache = 0; this.m_bIsMouseUpSend = false; this.zoom_values = [50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]; this.m_nZoomType = 0; this.TextBoxInputMode = false; this.TextBoxInput = null; this.TextBoxInputFocus = false; this.TextBoxChangedValueEvent = true; this.TextBoxMaxWidth = 20; this.TextBoxMaxHeight = 20; this.MobileTouchManager = null; this.ReaderTouchManager = null; this.ReaderModeCurrent = 0; this.ReaderFontSizeCur = 2; this.ReaderFontSizes = [12, 14, 16, 18, 22, 28, 36, 48, 72]; this.bIsRetinaSupport = true; this.bIsRetinaNoSupportAttack = false; this.IsUpdateOverlayOnlyEnd = false; this.IsUpdateOverlayOnlyEndReturn = false; this.IsUpdateOverlayOnEndCheck = false; this.m_oApi = api; var oThis = this; this.UseRequestAnimationFrame = false; this.RequestAnimationFrame = (function () { return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || null; })(); this.CancelAnimationFrame = (function () { return window.cancelRequestAnimationFrame || window.webkitCancelAnimationFrame || window.webkitCancelRequestAnimationFrame || window.mozCancelRequestAnimationFrame || window.oCancelRequestAnimationFrame || window.msCancelRequestAnimationFrame || null; })(); if (this.UseRequestAnimationFrame) { if (null == this.RequestAnimationFrame) { this.UseRequestAnimationFrame = false; } } this.RequestAnimationOldTime = -1; this.checkBodySize = function () { var off = jQuery("#" + this.Name).offset(); this.X = off.left; this.Y = off.top; var el = document.getElementById(this.Name); if (this.Width != el.offsetWidth || this.Height != el.offsetHeight) { this.Width = el.offsetWidth; this.Height = el.offsetHeight; return true; } return false; }; this.Init = function () { this.m_oBody = CreateControlContainer(this.Name); var scrollWidthMm = this.ScrollsWidthPx * g_dKoef_pix_to_mm; this.m_oScrollHor = CreateControlContainer("id_horscrollpanel"); this.m_oScrollHor.Bounds.SetParams(0, 0, scrollWidthMm, 0, false, false, true, true, -1, scrollWidthMm); this.m_oScrollHor.Anchor = (g_anchor_left | g_anchor_right | g_anchor_bottom); this.m_oBody.AddControl(this.m_oScrollHor); this.m_oPanelRight = CreateControlContainer("id_panel_right"); this.m_oPanelRight.Bounds.SetParams(0, 0, 1000, 0, false, true, false, true, scrollWidthMm, -1); this.m_oPanelRight.Anchor = (g_anchor_top | g_anchor_right | g_anchor_bottom); this.m_oBody.AddControl(this.m_oPanelRight); if (this.m_oApi.isMobileVersion) { this.m_oPanelRight.HtmlElement.style.zIndex = -1; var hor_scroll = document.getElementById("id_horscrollpanel"); hor_scroll.style.zIndex = -1; } this.m_oPanelRight_buttonRulers = CreateControl("id_buttonRulers"); this.m_oPanelRight_buttonRulers.Bounds.SetParams(0, 0, 1000, 1000, false, false, false, false, -1, scrollWidthMm); this.m_oPanelRight_buttonRulers.Anchor = (g_anchor_left | g_anchor_top | g_anchor_right); this.m_oPanelRight.AddControl(this.m_oPanelRight_buttonRulers); this.m_oPanelRight_buttonNextPage = CreateControl("id_buttonNextPage"); this.m_oPanelRight_buttonNextPage.Bounds.SetParams(0, 0, 1000, 1000, false, false, false, false, -1, scrollWidthMm); this.m_oPanelRight_buttonNextPage.Anchor = (g_anchor_left | g_anchor_bottom | g_anchor_right); this.m_oPanelRight.AddControl(this.m_oPanelRight_buttonNextPage); this.m_oPanelRight_buttonPrevPage = CreateControl("id_buttonPrevPage"); this.m_oPanelRight_buttonPrevPage.Bounds.SetParams(0, 0, 1000, scrollWidthMm, false, false, false, true, -1, scrollWidthMm); this.m_oPanelRight_buttonPrevPage.Anchor = (g_anchor_left | g_anchor_bottom | g_anchor_right); this.m_oPanelRight.AddControl(this.m_oPanelRight_buttonPrevPage); this.m_oPanelRight_vertScroll = CreateControl("id_vertical_scroll"); this.m_oPanelRight_vertScroll.Bounds.SetParams(0, scrollWidthMm, 1000, 2 * scrollWidthMm, false, true, false, true, -1, -1); this.m_oPanelRight_vertScroll.Anchor = (g_anchor_left | g_anchor_top | g_anchor_right | g_anchor_bottom); this.m_oPanelRight.AddControl(this.m_oPanelRight_vertScroll); this.m_oMainContent = CreateControlContainer("id_main"); if (!this.m_oApi.isMobileVersion) { this.m_oMainContent.Bounds.SetParams(0, 0, scrollWidthMm, 0, false, true, true, true, -1, -1); } else { this.m_oMainContent.Bounds.SetParams(0, 0, 0, 0, false, true, true, true, -1, -1); } this.m_oMainContent.Anchor = (g_anchor_left | g_anchor_top | g_anchor_right | g_anchor_bottom); this.m_oBody.AddControl(this.m_oMainContent); this.m_oLeftRuler = CreateControlContainer("id_panel_left"); this.m_oLeftRuler.Bounds.SetParams(0, 0, 1000, 1000, false, false, false, false, 5, -1); this.m_oLeftRuler.Anchor = (g_anchor_left | g_anchor_top | g_anchor_bottom); this.m_oMainContent.AddControl(this.m_oLeftRuler); this.m_oLeftRuler_buttonsTabs = CreateControl("id_buttonTabs"); this.m_oLeftRuler_buttonsTabs.Bounds.SetParams(0, 0.8, 1000, 1000, false, true, false, false, -1, 5); this.m_oLeftRuler_buttonsTabs.Anchor = (g_anchor_left | g_anchor_top | g_anchor_right); this.m_oLeftRuler.AddControl(this.m_oLeftRuler_buttonsTabs); this.m_oLeftRuler_vertRuler = CreateControl("id_vert_ruler"); this.m_oLeftRuler_vertRuler.Bounds.SetParams(0, 7, 1000, 1000, false, true, false, false, -1, -1); this.m_oLeftRuler_vertRuler.Anchor = (g_anchor_left | g_anchor_right | g_anchor_top | g_anchor_bottom); this.m_oLeftRuler.AddControl(this.m_oLeftRuler_vertRuler); this.m_oTopRuler = CreateControlContainer("id_panel_top"); this.m_oTopRuler.Bounds.SetParams(5, 0, 1000, 1000, true, false, false, false, -1, 7); this.m_oTopRuler.Anchor = (g_anchor_left | g_anchor_top | g_anchor_right); this.m_oMainContent.AddControl(this.m_oTopRuler); this.m_oTopRuler_horRuler = CreateControl("id_hor_ruler"); this.m_oTopRuler_horRuler.Bounds.SetParams(0, 0, 1000, 1000, false, false, false, false, -1, -1); this.m_oTopRuler_horRuler.Anchor = (g_anchor_left | g_anchor_right | g_anchor_top | g_anchor_bottom); this.m_oTopRuler.AddControl(this.m_oTopRuler_horRuler); this.m_oMainView = CreateControlContainer("id_main_view"); this.m_oMainView.Bounds.SetParams(5, 7, 1000, 1000, true, true, false, false, -1, -1); this.m_oMainView.Anchor = (g_anchor_left | g_anchor_right | g_anchor_top | g_anchor_bottom); this.m_oMainContent.AddControl(this.m_oMainView); if (this.m_oApi.isMobileVersion) { var _tag_background = "textarea"; if (bIsAndroid) { _tag_background = "input"; } var _text_bx_back = document.createElement(_tag_background); _text_bx_back.id = "id_text_box_background"; _text_bx_back.setAttribute("style", "background:transparent;border-style:none;border-color:transparent;overflow:hidden;z-index:4;font-family:arial;font-size:12pt;position:absolute;resize:none;padding:0px;margin:0px;font-weight:normal;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;"); _text_bx_back.setAttribute("spellcheck", "false"); if (bIsAndroid) { _text_bx_back.setAttribute("autocomplete", "off"); _text_bx_back.setAttribute("type", "password"); } _text_bx_back.willValidate = false; this.m_oMainView.HtmlElement.appendChild(_text_bx_back); this.TextBoxBackground = CreateControl("id_text_box_background"); this.TextBoxBackground.Bounds.SetParams(-100, 0, 1100, 1000, false, false, false, false, -1, -1); this.TextBoxBackground.Anchor = (g_anchor_left | g_anchor_top | g_anchor_right | g_anchor_bottom); this.m_oMainView.AddControl(this.TextBoxBackground); this.TextBoxBackground.HtmlElement.value = "a"; } this.m_oEditor = CreateControl("id_viewer"); this.m_oEditor.Bounds.SetParams(0, 0, 1000, 1000, false, false, false, false, -1, -1); this.m_oEditor.Anchor = (g_anchor_left | g_anchor_top | g_anchor_right | g_anchor_bottom); this.m_oMainView.AddControl(this.m_oEditor); this.m_oOverlay = CreateControl("id_viewer_overlay"); this.m_oOverlay.Bounds.SetParams(0, 0, 1000, 1000, false, false, false, false, -1, -1); this.m_oOverlay.Anchor = (g_anchor_left | g_anchor_top | g_anchor_right | g_anchor_bottom); this.m_oMainView.AddControl(this.m_oOverlay); this.m_oDrawingDocument.TargetHtmlElement = document.getElementById("id_target_cursor"); if (this.m_oApi.isMobileVersion) { this.MobileTouchManager = new CMobileTouchManager(); this.MobileTouchManager.Init(this); } this.checkNeedRules(); this.initEvents2(); this.UnShowOverlay(); this.m_oOverlayApi.m_oControl = this.m_oOverlay; this.m_oOverlayApi.m_oHtmlPage = this; this.m_oOverlayApi.Clear(); this.m_oDrawingDocument.AutoShapesTrack = new CAutoshapeTrack(); this.m_oDrawingDocument.AutoShapesTrack.init2(this.m_oOverlayApi); this.OnResize(true); }; this.CheckRetinaDisplay = function () { var old = this.bIsRetinaSupport; if (!this.bIsRetinaNoSupportAttack) { if (window.devicePixelRatio != 2) { this.bIsRetinaSupport = false; } else { this.bIsRetinaSupport = true; } } else { this.bIsRetinaSupport = false; } if (old != this.bIsRetinaSupport) { this.m_oDrawingDocument.ClearCachePages(); } }; this.ShowOverlay = function () { this.m_oOverlay.HtmlElement.style.display = "block"; if (null == this.m_oOverlayApi.m_oContext) { this.m_oOverlayApi.m_oContext = this.m_oOverlayApi.m_oControl.HtmlElement.getContext("2d"); } }; this.UnShowOverlay = function () { this.m_oOverlay.HtmlElement.style.display = "none"; }; this.CheckUnShowOverlay = function () { var drDoc = this.m_oDrawingDocument; if (!drDoc.m_bIsSearching && !drDoc.m_bIsSelection && !this.MobileTouchManager) { this.UnShowOverlay(); return false; } return true; }; this.CheckShowOverlay = function () { var drDoc = this.m_oDrawingDocument; if (drDoc.m_bIsSearching || drDoc.m_bIsSelection || this.MobileTouchManager) { this.ShowOverlay(); } }; this.initEvents2 = function () { this.arrayEventHandlers[0] = new button_eventHandlers("", "0px 0px", "0px -16px", "0px -32px", this.m_oPanelRight_buttonRulers, this.onButtonRulersClick); this.arrayEventHandlers[1] = new button_eventHandlers("", "0px 0px", "0px -16px", "0px -32px", this.m_oPanelRight_buttonPrevPage, this.onPrevPage); this.arrayEventHandlers[2] = new button_eventHandlers("", "0px -48px", "0px -64px", "0px -80px", this.m_oPanelRight_buttonNextPage, this.onNextPage); this.m_oLeftRuler_buttonsTabs.HtmlElement.onclick = this.onButtonTabsClick; this.m_oEditor.HtmlElement.onmousedown = this.onMouseDown; this.m_oEditor.HtmlElement.onmousemove = this.onMouseMove; this.m_oEditor.HtmlElement.onmouseup = this.onMouseUp; this.m_oOverlay.HtmlElement.onmousedown = this.onMouseDown; this.m_oOverlay.HtmlElement.onmousemove = this.onMouseMove; this.m_oOverlay.HtmlElement.onmouseup = this.onMouseUp; var _cur = document.getElementById("id_target_cursor"); _cur.onmousedown = this.onMouseDown; _cur.onmousemove = this.onMouseMove; _cur.onmouseup = this.onMouseUp; this.m_oMainContent.HtmlElement.onmousewheel = this.onMouseWhell; if (this.m_oMainContent.HtmlElement.addEventListener) { this.m_oMainContent.HtmlElement.addEventListener("DOMMouseScroll", this.onMouseWhell, false); } this.m_oTopRuler_horRuler.HtmlElement.onmousedown = this.horRulerMouseDown; this.m_oTopRuler_horRuler.HtmlElement.onmouseup = this.horRulerMouseUp; this.m_oTopRuler_horRuler.HtmlElement.onmousemove = this.horRulerMouseMove; this.m_oLeftRuler_vertRuler.HtmlElement.onmousedown = this.verRulerMouseDown; this.m_oLeftRuler_vertRuler.HtmlElement.onmouseup = this.verRulerMouseUp; this.m_oLeftRuler_vertRuler.HtmlElement.onmousemove = this.verRulerMouseMove; window.onkeydown = this.onKeyDown; window.onkeypress = this.onKeyPress; window.onkeyup = this.onKeyUp; this.m_oBody.HtmlElement.oncontextmenu = function () { return false; }; this.initEvents2MobileAdvances(); }; this.initEvents2MobileAdvances = function () { this.m_oTopRuler_horRuler.HtmlElement["ontouchstart"] = function (e) { oThis.horRulerMouseDown(e.touches[0]); return false; }; this.m_oTopRuler_horRuler.HtmlElement["ontouchmove"] = function (e) { oThis.horRulerMouseMove(e.touches[0]); return false; }; this.m_oTopRuler_horRuler.HtmlElement["ontouchend"] = function (e) { oThis.horRulerMouseUp(e.changedTouches[0]); return false; }; this.m_oLeftRuler_vertRuler.HtmlElement["ontouchstart"] = function (e) { oThis.verRulerMouseDown(e.touches[0]); return false; }; this.m_oLeftRuler_vertRuler.HtmlElement["ontouchmove"] = function (e) { oThis.verRulerMouseMove(e.touches[0]); return false; }; this.m_oLeftRuler_vertRuler.HtmlElement["ontouchend"] = function (e) { oThis.verRulerMouseUp(e.changedTouches[0]); return false; }; if (this.m_oApi.isMobileVersion) { var __hasTouch = "ontouchstart" in window; if (__hasTouch) { this.TextBoxBackground.HtmlElement["ontouchcancel"] = function (e) { oThis.IsUpdateOverlayOnlyEndReturn = true; oThis.StartUpdateOverlay(); var ret = oThis.MobileTouchManager.onTouchEnd(e); oThis.IsUpdateOverlayOnlyEndReturn = false; oThis.EndUpdateOverlay(); return ret; }; this.TextBoxBackground.HtmlElement["ontouchstart"] = function (e) { oThis.IsUpdateOverlayOnlyEndReturn = true; oThis.StartUpdateOverlay(); var ret = oThis.MobileTouchManager.onTouchStart(e); oThis.IsUpdateOverlayOnlyEndReturn = false; oThis.EndUpdateOverlay(); return ret; }; this.TextBoxBackground.HtmlElement["ontouchmove"] = function (e) { oThis.IsUpdateOverlayOnlyEndReturn = true; oThis.StartUpdateOverlay(); var ret = oThis.MobileTouchManager.onTouchMove(e); oThis.IsUpdateOverlayOnlyEndReturn = false; oThis.EndUpdateOverlay(); return ret; }; this.TextBoxBackground.HtmlElement["ontouchend"] = function (e) { oThis.IsUpdateOverlayOnlyEndReturn = true; oThis.StartUpdateOverlay(); var ret = oThis.MobileTouchManager.onTouchEnd(e); oThis.IsUpdateOverlayOnlyEndReturn = false; oThis.EndUpdateOverlay(); return ret; }; } else { this.TextBoxBackground.HtmlElement["onmousedown"] = function (e) { oThis.IsUpdateOverlayOnlyEndReturn = true; oThis.StartUpdateOverlay(); var ret = oThis.MobileTouchManager.onTouchStart(e); oThis.IsUpdateOverlayOnlyEndReturn = false; oThis.EndUpdateOverlay(); return ret; }; this.TextBoxBackground.HtmlElement["onmousemove"] = function (e) { oThis.IsUpdateOverlayOnlyEndReturn = true; oThis.StartUpdateOverlay(); var ret = oThis.MobileTouchManager.onTouchMove(e); oThis.IsUpdateOverlayOnlyEndReturn = false; oThis.EndUpdateOverlay(); return ret; }; this.TextBoxBackground.HtmlElement["onmouseup"] = function (e) { oThis.IsUpdateOverlayOnlyEndReturn = true; oThis.StartUpdateOverlay(); var ret = oThis.MobileTouchManager.onTouchEnd(e); oThis.IsUpdateOverlayOnlyEndReturn = false; oThis.EndUpdateOverlay(); return ret; }; } if (bIsAndroid) { this.TextBoxBackground.HtmlElement["oncontextmenu"] = function (e) { if (e.preventDefault) { e.preventDefault(); } e.returnValue = false; return false; }; this.TextBoxBackground.HtmlElement["onselectstart"] = function (e) { oThis.m_oLogicDocument.Select_All(); if (e.preventDefault) { e.preventDefault(); } e.returnValue = false; return false; }; window.IS_USE_INPUT = true; this.TextBoxBackground.HtmlElement["oninput"] = function (e) { var val = oThis.TextBoxBackground.HtmlElement.value; oThis.TextBoxBackground.HtmlElement.value = "a"; if (val.length == 2) { var _e = { altKey: global_keyboardEvent.AltKey, ctrlKey: global_keyboardEvent.CtrlKey, shiftKey: global_keyboardEvent.ShiftKey, srcElement: global_keyboardEvent.Sender, charCode: global_keyboardEvent.CharCode, keyCode: global_keyboardEvent.KeyCode, which: val.charCodeAt(1) }; _e.preventDefault = function () {}; if (_e.which == 32) { _e.keyCode = 32; oThis.onKeyDown(_e); } else { oThis.onKeyPress(_e); } } else { if (0 == val.length) { var _e = { altKey: global_keyboardEvent.AltKey, ctrlKey: global_keyboardEvent.CtrlKey, shiftKey: global_keyboardEvent.ShiftKey, srcElement: global_keyboardEvent.Sender, charCode: global_keyboardEvent.CharCode, keyCode: global_keyboardEvent.KeyCode, which: 8 }; _e.preventDefault = function () {}; if (_e.which == 8) { _e.keyCode = 8; oThis.onKeyDown(_e); } } else { var _len = val.length; for (var i = 1; i < _len; i++) { var _e = { altKey: global_keyboardEvent.AltKey, ctrlKey: global_keyboardEvent.CtrlKey, shiftKey: global_keyboardEvent.ShiftKey, srcElement: global_keyboardEvent.Sender, charCode: global_keyboardEvent.CharCode, keyCode: global_keyboardEvent.KeyCode, which: val.charCodeAt(i) }; _e.preventDefault = function () {}; if (_e.which == 32) { _e.keyCode = 32; oThis.onKeyDown(_e); } else { oThis.onKeyPress(_e); } } } } if (e.preventDefault) { e.preventDefault(); } e.returnValue = false; }; } } }; this.onButtonRulersClick = function () { if (false === oThis.m_oApi.bInit_word_control || true === oThis.m_oApi.isViewMode) { return; } oThis.m_bIsRuler = !oThis.m_bIsRuler; oThis.checkNeedRules(); oThis.OnResize(true); }; this.HideRulers = function () { if (false === oThis.m_oApi.bInit_word_control) { return; } if (oThis.m_bIsRuler === false) { return; } oThis.m_bIsRuler = !oThis.m_bIsRuler; oThis.checkNeedRules(); oThis.OnResize(true); }; this.zoom_FitToWidth = function () { var w = this.m_oEditor.AbsolutePosition.R - this.m_oEditor.AbsolutePosition.L; var Zoom = 100; if (0 != this.m_dDocumentPageWidth) { Zoom = 100 * (w - 10) / this.m_dDocumentPageWidth; if (Zoom < 5) { Zoom = 5; } if (this.m_oApi.isMobileVersion) { var _w = this.m_oEditor.HtmlElement.width; if (this.bIsRetinaSupport) { _w >>= 1; } Zoom = 100 * _w * g_dKoef_pix_to_mm / this.m_dDocumentPageWidth; } } var _new_value = parseInt(Zoom - 0.5); this.m_nZoomType = 1; if (_new_value != this.m_nZoomValue) { var _old_val = this.m_nZoomValue; this.m_nZoomValue = _new_value; this.zoom_Fire(1, _old_val); if (this.MobileTouchManager) { this.MobileTouchManager.CheckZoomCriticalValues(this.m_nZoomValue); } return true; } else { this.m_oApi.sync_zoomChangeCallback(this.m_nZoomValue, 1); } return false; }; this.zoom_FitToPage = function () { var w = parseInt(this.m_oEditor.HtmlElement.width) * g_dKoef_pix_to_mm; var h = parseInt(this.m_oEditor.HtmlElement.height) * g_dKoef_pix_to_mm; if (this.bIsRetinaSupport) { w >>= 1; h >>= 1; } var _hor_Zoom = 100; if (0 != this.m_dDocumentPageWidth) { _hor_Zoom = (100 * (w - 10)) / this.m_dDocumentPageWidth; } var _ver_Zoom = 100; if (0 != this.m_dDocumentPageHeight) { _ver_Zoom = (100 * (h - 10)) / this.m_dDocumentPageHeight; } var _new_value = parseInt(Math.min(_hor_Zoom, _ver_Zoom) - 0.5); if (_new_value < 5) { _new_value = 5; } this.m_nZoomType = 2; if (_new_value != this.m_nZoomValue) { var _old_val = this.m_nZoomValue; this.m_nZoomValue = _new_value; this.zoom_Fire(2, _old_val); return true; } else { this.m_oApi.sync_zoomChangeCallback(this.m_nZoomValue, 2); } return false; }; this.zoom_Fire = function (type, old_zoom) { if (false === oThis.m_oApi.bInit_word_control) { return; } g_fontManager.ClearRasterMemory(); if (window.g_fontManager2 !== undefined && window.g_fontManager2 !== null) { window.g_fontManager2.ClearRasterMemory(); } var oWordControl = oThis; oWordControl.m_bIsRePaintOnScroll = false; var xScreen1 = oWordControl.m_oEditor.AbsolutePosition.R - oWordControl.m_oEditor.AbsolutePosition.L; var yScreen1 = oWordControl.m_oEditor.AbsolutePosition.B - oWordControl.m_oEditor.AbsolutePosition.T; xScreen1 *= g_dKoef_mm_to_pix; yScreen1 *= g_dKoef_mm_to_pix; xScreen1 >>= 1; yScreen1 >>= 1; var posDoc = oWordControl.m_oDrawingDocument.ConvertCoordsFromCursor2(xScreen1, yScreen1, true, undefined, old_zoom); oWordControl.CheckZoom(); oWordControl.CalculateDocumentSize(); var lCurPage = oWordControl.m_oDrawingDocument.m_lCurrentPage; if (-1 != lCurPage) { oWordControl.m_oHorRuler.CreateBackground(oWordControl.m_oDrawingDocument.m_arrPages[lCurPage]); oWordControl.m_bIsUpdateHorRuler = true; oWordControl.m_oVerRuler.CreateBackground(oWordControl.m_oDrawingDocument.m_arrPages[lCurPage]); oWordControl.m_bIsUpdateVerRuler = true; } oWordControl.OnCalculatePagesPlace(); var posScreenNew = oWordControl.m_oDrawingDocument.ConvertCoordsToCursor(posDoc.X, posDoc.Y, posDoc.Page); var _x_pos = oWordControl.m_oScrollHorApi.getCurScrolledX() + posScreenNew.X - xScreen1; var _y_pos = oWordControl.m_oScrollVerApi.getCurScrolledY() + posScreenNew.Y - yScreen1; _x_pos = Math.max(0, Math.min(_x_pos, oWordControl.m_dScrollX_max)); _y_pos = Math.max(0, Math.min(_y_pos, oWordControl.m_dScrollY_max)); if (oWordControl.m_dScrollY == 0) { _y_pos = 0; } oWordControl.m_oScrollVerApi.scrollToY(_y_pos); oWordControl.m_oScrollHorApi.scrollToX(_x_pos); if (this.MobileTouchManager) { this.MobileTouchManager.Resize(); } oWordControl.m_oApi.sync_zoomChangeCallback(this.m_nZoomValue, type); oWordControl.m_bIsUpdateTargetNoAttack = true; oWordControl.m_bIsRePaintOnScroll = true; if (oWordControl.m_oLogicDocument) { oWordControl.m_oLogicDocument.DrawingObjects.redrawCharts(); } oWordControl.OnScroll(); }; this.zoom_Out = function () { if (false === oThis.m_oApi.bInit_word_control) { return; } oThis.m_nZoomType = 0; var _zooms = oThis.zoom_values; var _count = _zooms.length; var _Zoom = _zooms[0]; for (var i = (_count - 1); i >= 0; i--) { if (this.m_nZoomValue > _zooms[i]) { _Zoom = _zooms[i]; break; } } var _old_val = oThis.m_nZoomValue; oThis.m_nZoomValue = _Zoom; oThis.zoom_Fire(0, _old_val); }; this.zoom_In = function () { if (false === oThis.m_oApi.bInit_word_control) { return; } oThis.m_nZoomType = 0; var _zooms = oThis.zoom_values; var _count = _zooms.length; var _Zoom = _zooms[_count - 1]; for (var i = 0; i < _count; i++) { if (this.m_nZoomValue < _zooms[i]) { _Zoom = _zooms[i]; break; } } var _old_val = oThis.m_nZoomValue; oThis.m_nZoomValue = _Zoom; oThis.zoom_Fire(0, _old_val); }; this.ToSearchResult = function () { var naviG = this.m_oDrawingDocument.CurrentSearchNavi; var navi = naviG[0]; var x = navi.X; var y = navi.Y; var type = (naviG.Type & 255); var PageNum = navi.PageNum; if (navi.Transform) { var xx = navi.Transform.TransformPointX(x, y); var yy = navi.Transform.TransformPointY(x, y); x = xx; y = yy; } var rectSize = (navi.H * this.m_nZoomValue * g_dKoef_mm_to_pix / 100); var pos = this.m_oDrawingDocument.ConvertCoordsToCursor2(x, y, PageNum); if (true === pos.Error) { return; } var boxX = 0; var boxY = 0; var boxR = this.m_oEditor.HtmlElement.width - 2; var boxB = this.m_oEditor.HtmlElement.height - rectSize; var nValueScrollHor = 0; if (pos.X < boxX) { nValueScrollHor = this.GetHorizontalScrollTo(x, PageNum); } if (pos.X > boxR) { var _mem = x - g_dKoef_pix_to_mm * this.m_oEditor.HtmlElement.width * 100 / this.m_nZoomValue; nValueScrollHor = this.GetHorizontalScrollTo(_mem, PageNum); } var nValueScrollVer = 0; if (pos.Y < boxY) { nValueScrollVer = this.GetVerticalScrollTo(y, PageNum); } if (pos.Y > boxB) { var _mem = y + navi.H + 10 - g_dKoef_pix_to_mm * this.m_oEditor.HtmlElement.height * 100 / this.m_nZoomValue; nValueScrollVer = this.GetVerticalScrollTo(_mem, PageNum); } var isNeedScroll = false; if (0 != nValueScrollHor) { isNeedScroll = true; this.m_bIsUpdateTargetNoAttack = true; var temp = nValueScrollHor * this.m_dScrollX_max / (this.m_dDocumentWidth - this.m_oEditor.HtmlElement.width); this.m_oScrollHorApi.scrollToX(parseInt(temp), false); } if (0 != nValueScrollVer) { isNeedScroll = true; this.m_bIsUpdateTargetNoAttack = true; var temp = nValueScrollVer * this.m_dScrollY_max / (this.m_dDocumentHeight - this.m_oEditor.HtmlElement.height); this.m_oScrollVerApi.scrollToY(parseInt(temp), false); } if (true === isNeedScroll) { this.OnScroll(); return; } this.OnUpdateOverlay(); }; this.ScrollToPosition = function (x, y, PageNum) { if (PageNum < 0 || PageNum >= this.m_oDrawingDocument.m_lCountCalculatePages) { return; } var _h = 5; var rectSize = (_h * g_dKoef_mm_to_pix / 100); var pos = this.m_oDrawingDocument.ConvertCoordsToCursor2(x, y, PageNum); if (true === pos.Error) { return; } var boxX = 0; var boxY = 0; var boxR = this.m_oEditor.HtmlElement.width - 2; var boxB = this.m_oEditor.HtmlElement.height - rectSize; var nValueScrollHor = 0; if (pos.X < boxX) { nValueScrollHor = this.GetHorizontalScrollTo(x, PageNum); } if (pos.X > boxR) { var _mem = x - g_dKoef_pix_to_mm * this.m_oEditor.HtmlElement.width * 100 / this.m_nZoomValue; nValueScrollHor = this.GetHorizontalScrollTo(_mem, PageNum); } var nValueScrollVer = 0; if (pos.Y < boxY) { nValueScrollVer = this.GetVerticalScrollTo(y, PageNum); } if (pos.Y > boxB) { var _mem = y + _h + 10 - g_dKoef_pix_to_mm * this.m_oEditor.HtmlElement.height * 100 / this.m_nZoomValue; nValueScrollVer = this.GetVerticalScrollTo(_mem, PageNum); } var isNeedScroll = false; if (0 != nValueScrollHor) { isNeedScroll = true; this.m_bIsUpdateTargetNoAttack = true; var temp = nValueScrollHor * this.m_dScrollX_max / (this.m_dDocumentWidth - this.m_oEditor.HtmlElement.width); this.m_oScrollHorApi.scrollToX(parseInt(temp), false); } if (0 != nValueScrollVer) { isNeedScroll = true; this.m_bIsUpdateTargetNoAttack = true; var temp = nValueScrollVer * this.m_dScrollY_max / (this.m_dDocumentHeight - this.m_oEditor.HtmlElement.height); this.m_oScrollVerApi.scrollToY(parseInt(temp), false); } if (true === isNeedScroll) { this.OnScroll(); return; } }; this.onButtonTabsClick = function () { if (false === oThis.m_oApi.bInit_word_control) { return; } var oWordControl = oThis; if (oWordControl.m_nTabsType == g_tabtype_left) { oWordControl.m_nTabsType = g_tabtype_center; oWordControl.m_oLeftRuler_buttonsTabs.HtmlElement.style.backgroundPosition = "0px -37px"; } else { if (oWordControl.m_nTabsType == g_tabtype_center) { oWordControl.m_nTabsType = g_tabtype_right; oWordControl.m_oLeftRuler_buttonsTabs.HtmlElement.style.backgroundPosition = "0px -18px"; } else { oWordControl.m_nTabsType = g_tabtype_left; oWordControl.m_oLeftRuler_buttonsTabs.HtmlElement.style.backgroundPosition = "0px 0px"; } } }; this.onPrevPage = function () { if (false === oThis.m_oApi.bInit_word_control) { return; } var oWordControl = oThis; if (0 < oWordControl.m_oDrawingDocument.m_lCurrentPage) { oWordControl.GoToPage(oWordControl.m_oDrawingDocument.m_lCurrentPage - 1); } else { oWordControl.GoToPage(0); } }; this.onNextPage = function () { if (false === oThis.m_oApi.bInit_word_control) { return; } var oWordControl = oThis; if ((oWordControl.m_oDrawingDocument.m_lPagesCount - 1) > oWordControl.m_oDrawingDocument.m_lCurrentPage) { oWordControl.GoToPage(oWordControl.m_oDrawingDocument.m_lCurrentPage + 1); } else { if (oWordControl.m_oDrawingDocument.m_lPagesCount > 0) { oWordControl.GoToPage(oWordControl.m_oDrawingDocument.m_lPagesCount - 1); } } }; this.horRulerMouseDown = function (e) { if (false === oThis.m_oApi.bInit_word_control) { return; } if (e.preventDefault) { e.preventDefault(); } else { e.returnValue = false; } var oWordControl = oThis; var _cur_page = oWordControl.m_oDrawingDocument.m_lCurrentPage; if (_cur_page < 0 || _cur_page >= oWordControl.m_oDrawingDocument.m_lPagesCount) { return; } oWordControl.m_oHorRuler.OnMouseDown(oWordControl.m_oDrawingDocument.m_arrPages[_cur_page].drawingPage.left, 0, e); }; this.horRulerMouseUp = function (e) { if (false === oThis.m_oApi.bInit_word_control) { return; } if (e.preventDefault) { e.preventDefault(); } else { e.returnValue = false; } var oWordControl = oThis; var _cur_page = oWordControl.m_oDrawingDocument.m_lCurrentPage; if (_cur_page < 0 || _cur_page >= oWordControl.m_oDrawingDocument.m_lPagesCount) { return; } oWordControl.m_oHorRuler.OnMouseUp(oWordControl.m_oDrawingDocument.m_arrPages[_cur_page].drawingPage.left, 0, e); }; this.horRulerMouseMove = function (e) { if (false === oThis.m_oApi.bInit_word_control) { return; } if (e.preventDefault) { e.preventDefault(); } else { e.returnValue = false; } var oWordControl = oThis; var _cur_page = oWordControl.m_oDrawingDocument.m_lCurrentPage; if (_cur_page < 0 || _cur_page >= oWordControl.m_oDrawingDocument.m_lPagesCount) { return; } oWordControl.m_oHorRuler.OnMouseMove(oWordControl.m_oDrawingDocument.m_arrPages[_cur_page].drawingPage.left, 0, e); }; this.verRulerMouseDown = function (e) { if (false === oThis.m_oApi.bInit_word_control) { return; } if (e.preventDefault) { e.preventDefault(); } else { e.returnValue = false; } var oWordControl = oThis; var _cur_page = oWordControl.m_oDrawingDocument.m_lCurrentPage; if (_cur_page < 0 || _cur_page >= oWordControl.m_oDrawingDocument.m_lPagesCount) { return; } oWordControl.m_oVerRuler.OnMouseDown(0, oWordControl.m_oDrawingDocument.m_arrPages[_cur_page].drawingPage.top, e); }; this.verRulerMouseUp = function (e) { if (false === oThis.m_oApi.bInit_word_control) { return; } if (e.preventDefault) { e.preventDefault(); } else { e.returnValue = false; } var oWordControl = oThis; var _cur_page = oWordControl.m_oDrawingDocument.m_lCurrentPage; if (_cur_page < 0 || _cur_page >= oWordControl.m_oDrawingDocument.m_lPagesCount) { return; } oWordControl.m_oVerRuler.OnMouseUp(0, oWordControl.m_oDrawingDocument.m_arrPages[_cur_page].drawingPage.top, e); }; this.verRulerMouseMove = function (e) { if (false === oThis.m_oApi.bInit_word_control) { return; } if (e.preventDefault) { e.preventDefault(); } else { e.returnValue = false; } var oWordControl = oThis; var _cur_page = oWordControl.m_oDrawingDocument.m_lCurrentPage; if (_cur_page < 0 || _cur_page >= oWordControl.m_oDrawingDocument.m_lPagesCount) { return; } oWordControl.m_oVerRuler.OnMouseMove(0, oWordControl.m_oDrawingDocument.m_arrPages[_cur_page].drawingPage.top, e); }; this.SelectWheel = function () { if (false === oThis.m_oApi.bInit_word_control) { return; } var oWordControl = oThis; var positionMinY = oWordControl.m_oMainContent.AbsolutePosition.T * g_dKoef_mm_to_pix + oWordControl.Y; if (oWordControl.m_bIsRuler) { positionMinY = (oWordControl.m_oMainContent.AbsolutePosition.T + oWordControl.m_oTopRuler_horRuler.AbsolutePosition.B) * g_dKoef_mm_to_pix + oWordControl.Y; } var positionMaxY = oWordControl.m_oMainContent.AbsolutePosition.B * g_dKoef_mm_to_pix + oWordControl.Y; var scrollYVal = 0; if (global_mouseEvent.Y < positionMinY) { var delta = 30; if (20 > (positionMinY - global_mouseEvent.Y)) { delta = 10; } scrollYVal = -delta; } else { if (global_mouseEvent.Y > positionMaxY) { var delta = 30; if (20 > (global_mouseEvent.Y - positionMaxY)) { delta = 10; } scrollYVal = delta; } } var scrollXVal = 0; if (oWordControl.m_bIsHorScrollVisible) { var positionMinX = oWordControl.m_oMainContent.AbsolutePosition.L * g_dKoef_mm_to_pix + oWordControl.X; if (oWordControl.m_bIsRuler) { positionMinX += oWordControl.m_oLeftRuler.AbsolutePosition.R * g_dKoef_mm_to_pix; } var positionMaxX = oWordControl.m_oMainContent.AbsolutePosition.R * g_dKoef_mm_to_pix + oWordControl.X; if (global_mouseEvent.X < positionMinX) { var delta = 30; if (20 > (positionMinX - global_mouseEvent.X)) { delta = 10; } scrollXVal = -delta; } else { if (global_mouseEvent.X > positionMaxX) { var delta = 30; if (20 > (global_mouseEvent.X - positionMaxX)) { delta = 10; } scrollXVal = delta; } } } if (0 != scrollYVal) { oWordControl.m_oScrollVerApi.scrollByY(scrollYVal, false); } if (0 != scrollXVal) { oWordControl.m_oScrollHorApi.scrollByX(scrollXVal, false); } if (scrollXVal != 0 || scrollYVal != 0) { oWordControl.onMouseMove2(); } }; this.onMouseDown = function (e) { if (false === oThis.m_oApi.bInit_word_control) { return; } if (!oThis.m_bIsIE) { if (e.preventDefault) { e.preventDefault(); } else { e.returnValue = false; } } var oWordControl = oThis; if (this.id == "id_viewer" && oThis.m_oOverlay.HtmlElement.style.display == "block") { return; } var _xOffset = oWordControl.X; var _yOffset = oWordControl.Y; if (true === oWordControl.m_bIsRuler) { _xOffset += (5 * g_dKoef_mm_to_pix); _yOffset += (7 * g_dKoef_mm_to_pix); } if (window.closeDialogs != undefined) { closeDialogs(); } check_MouseDownEvent(e, true); global_mouseEvent.LockMouse(); if ((0 == global_mouseEvent.Button) || (undefined == global_mouseEvent.Button)) { oWordControl.m_bIsMouseLock = true; } oWordControl.StartUpdateOverlay(); if ((0 == global_mouseEvent.Button) || (undefined == global_mouseEvent.Button)) { var pos = null; if (oWordControl.m_oDrawingDocument.AutoShapesTrackLockPageNum == -1) { pos = oWordControl.m_oDrawingDocument.ConvertCoordsFromCursor2(global_mouseEvent.X, global_mouseEvent.Y); } else { pos = oWordControl.m_oDrawingDocument.ConvetToPageCoords(global_mouseEvent.X, global_mouseEvent.Y, oWordControl.m_oDrawingDocument.AutoShapesTrackLockPageNum); } if (pos.Page == -1) { oWordControl.EndUpdateOverlay(); return; } if (oWordControl.m_oDrawingDocument.IsFreezePage(pos.Page)) { oWordControl.EndUpdateOverlay(); return; } if (null == oWordControl.m_oDrawingDocument.m_oDocumentRenderer) { var ret = oWordControl.m_oDrawingDocument.checkMouseDown_Drawing(pos); if (ret === true) { return; } oWordControl.m_oDrawingDocument.NeedScrollToTargetFlag = true; oWordControl.m_oLogicDocument.OnMouseDown(global_mouseEvent, pos.X, pos.Y, pos.Page); oWordControl.m_oDrawingDocument.NeedScrollToTargetFlag = false; oWordControl.MouseDownDocumentCounter++; } else { oWordControl.m_oDrawingDocument.m_oDocumentRenderer.OnMouseDown(pos.Page, pos.X, pos.Y); oWordControl.MouseDownDocumentCounter++; } } else { if (global_mouseEvent.Button == 2) { oWordControl.MouseDownDocumentCounter++; } } if (-1 == oWordControl.m_oTimerScrollSelect) { oWordControl.m_oTimerScrollSelect = setInterval(oWordControl.SelectWheel, 20); } oWordControl.EndUpdateOverlay(); }; this.onMouseMove = function (e) { if (false === oThis.m_oApi.bInit_word_control) { return; } if (e.preventDefault) { e.preventDefault(); } else { e.returnValue = false; } var oWordControl = oThis; check_MouseMoveEvent(e); var pos = null; if (oWordControl.m_oDrawingDocument.AutoShapesTrackLockPageNum == -1) { pos = oWordControl.m_oDrawingDocument.ConvertCoordsFromCursor2(global_mouseEvent.X, global_mouseEvent.Y); } else { pos = oWordControl.m_oDrawingDocument.ConvetToPageCoords(global_mouseEvent.X, global_mouseEvent.Y, oWordControl.m_oDrawingDocument.AutoShapesTrackLockPageNum); } if (pos.Page == -1) { return; } if (oWordControl.m_oDrawingDocument.IsFreezePage(pos.Page)) { return; } if (oWordControl.m_oDrawingDocument.m_sLockedCursorType != "") { oWordControl.m_oDrawingDocument.SetCursorType("default"); } if (oWordControl.m_oDrawingDocument.m_oDocumentRenderer != null) { oWordControl.m_oDrawingDocument.m_oDocumentRenderer.OnMouseMove(pos.Page, pos.X, pos.Y); return; } oWordControl.StartUpdateOverlay(); var is_drawing = oWordControl.m_oDrawingDocument.checkMouseMove_Drawing(pos); if (is_drawing === true) { return; } oWordControl.m_oDrawingDocument.TableOutlineDr.bIsNoTable = true; oWordControl.m_oLogicDocument.OnMouseMove(global_mouseEvent, pos.X, pos.Y, pos.Page); if (oWordControl.m_oDrawingDocument.TableOutlineDr.bIsNoTable === false) { oWordControl.ShowOverlay(); oWordControl.OnUpdateOverlay(); } oWordControl.EndUpdateOverlay(); }; this.onMouseMove2 = function () { if (false === oThis.m_oApi.bInit_word_control) { return; } var oWordControl = oThis; var pos = null; if (oWordControl.m_oDrawingDocument.AutoShapesTrackLockPageNum == -1) { pos = oWordControl.m_oDrawingDocument.ConvertCoordsFromCursor2(global_mouseEvent.X, global_mouseEvent.Y); } else { pos = oWordControl.m_oDrawingDocument.ConvetToPageCoords(global_mouseEvent.X, global_mouseEvent.Y, oWordControl.m_oDrawingDocument.AutoShapesTrackLockPageNum); } if (pos.Page == -1) { return; } if (null != oWordControl.m_oDrawingDocument.m_oDocumentRenderer) { oWordControl.m_oDrawingDocument.m_oDocumentRenderer.OnMouseMove(pos.Page, pos.X, pos.Y); return; } if (oWordControl.m_oDrawingDocument.IsFreezePage(pos.Page)) { return; } oWordControl.StartUpdateOverlay(); var is_drawing = oWordControl.m_oDrawingDocument.checkMouseMove_Drawing(pos); if (is_drawing === true) { return; } oWordControl.m_oLogicDocument.OnMouseMove(global_mouseEvent, pos.X, pos.Y, pos.Page); oWordControl.EndUpdateOverlay(); }; this.onMouseUp = function (e, bIsWindow) { if (false === oThis.m_oApi.bInit_word_control) { return; } var oWordControl = oThis; if (!global_mouseEvent.IsLocked && 0 == oWordControl.MouseDownDocumentCounter) { return; } if (this.id == "id_viewer" && oThis.m_oOverlay.HtmlElement.style.display == "block" && undefined == bIsWindow) { return; } if ((global_mouseEvent.Sender != oThis.m_oEditor.HtmlElement && global_mouseEvent.Sender != oThis.m_oOverlay.HtmlElement && global_mouseEvent.Sender != oThis.m_oDrawingDocument.TargetHtmlElement) && (oThis.TextBoxBackground && oThis.TextBoxBackground.HtmlElement != global_mouseEvent.Sender)) { return; } check_MouseUpEvent(e); var pos = null; if (oWordControl.m_oDrawingDocument.AutoShapesTrackLockPageNum == -1) { pos = oWordControl.m_oDrawingDocument.ConvertCoordsFromCursor2(global_mouseEvent.X, global_mouseEvent.Y); } else { pos = oWordControl.m_oDrawingDocument.ConvetToPageCoords(global_mouseEvent.X, global_mouseEvent.Y, oWordControl.m_oDrawingDocument.AutoShapesTrackLockPageNum); } if (pos.Page == -1) { return; } if (oWordControl.m_oDrawingDocument.IsFreezePage(pos.Page)) { return; } oWordControl.m_oDrawingDocument.UnlockCursorType(); oWordControl.StartUpdateOverlay(); oWordControl.m_bIsMouseLock = false; var is_drawing = oWordControl.m_oDrawingDocument.checkMouseUp_Drawing(pos); if (is_drawing === true) { return; } if (-1 != oWordControl.m_oTimerScrollSelect) { clearInterval(oWordControl.m_oTimerScrollSelect); oWordControl.m_oTimerScrollSelect = -1; } if (null != oWordControl.m_oDrawingDocument.m_oDocumentRenderer) { oWordControl.m_oDrawingDocument.m_oDocumentRenderer.OnMouseUp(); oWordControl.MouseDownDocumentCounter--; if (oWordControl.MouseDownDocumentCounter < 0) { oWordControl.MouseDownDocumentCounter = 0; } oWordControl.EndUpdateOverlay(); return; } oWordControl.m_bIsMouseUpSend = true; if (2 == global_mouseEvent.Button) {} oWordControl.m_oDrawingDocument.NeedScrollToTargetFlag = true; oWordControl.m_oLogicDocument.OnMouseUp(global_mouseEvent, pos.X, pos.Y, pos.Page); oWordControl.m_oDrawingDocument.NeedScrollToTargetFlag = false; oWordControl.MouseDownDocumentCounter--; if (oWordControl.MouseDownDocumentCounter < 0) { oWordControl.MouseDownDocumentCounter = 0; } oWordControl.m_bIsMouseUpSend = false; oWordControl.m_oLogicDocument.Document_UpdateInterfaceState(); oWordControl.m_oLogicDocument.Document_UpdateRulersState(); oWordControl.EndUpdateOverlay(); }; this.onMouseUpExternal = function (x, y) { if (false === oThis.m_oApi.bInit_word_control) { return; } var oWordControl = oThis; global_mouseEvent.X = x; global_mouseEvent.Y = y; global_mouseEvent.Type = g_mouse_event_type_up; g_bIsMouseUpLockedSend = true; if (oWordControl.m_oHorRuler.m_bIsMouseDown) { oWordControl.m_oHorRuler.OnMouseUpExternal(); } if (oWordControl.m_oVerRuler.DragType != 0) { oWordControl.m_oVerRuler.OnMouseUpExternal(); } global_mouseEvent.Sender = null; global_mouseEvent.UnLockMouse(); global_mouseEvent.IsPressed = false; var pos = null; if (oWordControl.m_oDrawingDocument.AutoShapesTrackLockPageNum == -1) { pos = oWordControl.m_oDrawingDocument.ConvertCoordsFromCursor2(global_mouseEvent.X, global_mouseEvent.Y); } else { pos = oWordControl.m_oDrawingDocument.ConvetToPageCoords(global_mouseEvent.X, global_mouseEvent.Y, oWordControl.m_oDrawingDocument.AutoShapesTrackLockPageNum); } if (pos.Page == -1) { return; } if (oWordControl.m_oDrawingDocument.IsFreezePage(pos.Page)) { return; } oWordControl.m_oDrawingDocument.UnlockCursorType(); oWordControl.StartUpdateOverlay(); oWordControl.m_bIsMouseLock = false; var is_drawing = oWordControl.m_oDrawingDocument.checkMouseUp_Drawing(pos); if (is_drawing === true) { return; } if (-1 != oWordControl.m_oTimerScrollSelect) { clearInterval(oWordControl.m_oTimerScrollSelect); oWordControl.m_oTimerScrollSelect = -1; } if (null != oWordControl.m_oDrawingDocument.m_oDocumentRenderer) { oWordControl.m_oDrawingDocument.m_oDocumentRenderer.OnMouseUp(); oWordControl.MouseDownDocumentCounter--; if (oWordControl.MouseDownDocumentCounter < 0) { oWordControl.MouseDownDocumentCounter = 0; } oWordControl.EndUpdateOverlay(); return; } oWordControl.m_bIsMouseUpSend = true; if (2 == global_mouseEvent.Button) {} oWordControl.m_oLogicDocument.OnMouseUp(global_mouseEvent, pos.X, pos.Y, pos.Page); oWordControl.MouseDownDocumentCounter--; if (oWordControl.MouseDownDocumentCounter < 0) { oWordControl.MouseDownDocumentCounter = 0; } oWordControl.m_bIsMouseUpSend = false; oWordControl.m_oLogicDocument.Document_UpdateInterfaceState(); oWordControl.m_oLogicDocument.Document_UpdateRulersState(); oWordControl.EndUpdateOverlay(); }; this.onMouseWhell = function (e) { if (false === oThis.m_oApi.bInit_word_control) { return; } var delta = 0; var deltaX = 0; var deltaY = 0; if (undefined != e.wheelDelta && e.wheelDelta != 0) { delta = -45 * e.wheelDelta / 120; } else { if (undefined != e.detail && e.detail != 0) { delta = 45 * e.detail / 3; } } deltaY = delta; if (oThis.m_bIsHorScrollVisible) { if (e.axis !== undefined && e.axis === e.HORIZONTAL_AXIS) { deltaY = 0; deltaX = delta; } if (e.wheelDeltaY !== undefined) { if (e.wheelDelta != 0) { deltaY = -45 * e.wheelDeltaY / 120; } } if (e.wheelDeltaX !== undefined) { if (e.wheelDeltaX != 0) { deltaX = -45 * e.wheelDeltaX / 120; } } } deltaX >>= 0; deltaY >>= 0; if (0 != deltaX) { oThis.m_oScrollHorApi.scrollBy(deltaX, 0, false); } else { if (0 != deltaY) { oThis.m_oScrollVerApi.scrollBy(0, deltaY, false); } } if (e.preventDefault) { e.preventDefault(); } else { e.returnValue = false; } return false; }; this.checkViewerModeKeys = function (e) { var isSendEditor = false; if (e.KeyCode == 33) {} else { if (e.KeyCode == 34) {} else { if (e.KeyCode == 35) { if (true === e.CtrlKey) { oThis.m_oScrollVerApi.scrollTo(0, oThis.m_dScrollY_max); } } else { if (e.KeyCode == 36) { if (true === e.CtrlKey) { oThis.m_oScrollVerApi.scrollTo(0, 0); } } else { if (e.KeyCode == 37) { if (oThis.m_bIsHorScrollVisible) { oThis.m_oScrollHorApi.scrollBy(-30, 0, false); } } else { if (e.KeyCode == 38) { oThis.m_oScrollVerApi.scrollBy(0, -30, false); } else { if (e.KeyCode == 39) { if (oThis.m_bIsHorScrollVisible) { oThis.m_oScrollHorApi.scrollBy(30, 0, false); } } else { if (e.KeyCode == 40) { oThis.m_oScrollVerApi.scrollBy(0, 30, false); } else { if (e.KeyCode == 65 && true === e.CtrlKey) { isSendEditor = true; } else { if (e.KeyCode == 67 && true === e.CtrlKey) { if (false === e.ShiftKey) { Editor_Copy(oThis.m_oApi); } } } } } } } } } } } return isSendEditor; }; this.ChangeReaderMode = function () { if (this.ReaderModeCurrent) { this.DisableReaderMode(); } else { this.EnableReaderMode(); } }; this.IncreaseReaderFontSize = function () { if (null == this.ReaderModeDiv) { return; } if (this.ReaderFontSizeCur >= (this.ReaderFontSizes.length - 1)) { this.ReaderFontSizeCur = this.ReaderFontSizes.length - 1; return; } this.ReaderFontSizeCur++; this.ReaderModeDiv.style.fontSize = this.ReaderFontSizes[this.ReaderFontSizeCur] + "pt"; this.ReaderTouchManager.ChangeFontSize(); }; this.DecreaseReaderFontSize = function () { if (null == this.ReaderModeDiv) { return; } if (this.ReaderFontSizeCur <= 0) { this.ReaderFontSizeCur = 0; return; } this.ReaderFontSizeCur--; this.ReaderModeDiv.style.fontSize = this.ReaderFontSizes[this.ReaderFontSizeCur] + "pt"; this.ReaderTouchManager.ChangeFontSize(); }; this.EnableReaderMode = function () { this.ReaderModeCurrent = 1; if (this.ReaderTouchManager) { this.TransformDivUseAnimation(this.ReaderModeDivWrapper, 0); return; } this.ReaderModeDivWrapper = document.createElement("div"); this.ReaderModeDivWrapper.setAttribute("style", "z-index:8;font-family:arial;font-size:12pt;position:absolute; resize:none;padding:0px;display:block; margin:0px;left:0px;top:0px;background-color:#FFFFFF"); var _c_h = parseInt(oThis.m_oMainView.HtmlElement.style.height); this.ReaderModeDivWrapper.style.top = _c_h + "px"; this.ReaderModeDivWrapper.style.width = this.m_oMainView.HtmlElement.style.width; this.ReaderModeDivWrapper.style.height = this.m_oMainView.HtmlElement.style.height; this.ReaderModeDivWrapper.id = "wrapper_reader_id"; this.ReaderModeDivWrapper.innerHTML = '