From a55a492ff6b60bce12895db5dd5a307846d3b011 Mon Sep 17 00:00:00 2001 From: Oleg Korshul Date: Sat, 9 Dec 2023 23:30:50 +0300 Subject: [PATCH] Remove native scripts --- cell/native/DrawingDocument.js | 3231 -------------- cell/native/Graphics.js | 1203 ----- cell/native/Overlay.js | 3090 ------------- cell/native/native.js | 5342 ----------------------- common/Native/Wrappers/DrawingStream.js | 1340 ------ common/Native/Wrappers/Overlay.js | 1006 ----- common/Native/Wrappers/ShapeDrawer.js | 1516 ------- common/Native/Wrappers/common.js | 169 - common/Native/Wrappers/memory.js | 810 ---- common/Native/Wrappers/serialize.js | 2117 --------- common/Native/native.js | 305 -- configs/cell.json | 17 +- configs/slide.json | 18 +- configs/word.json | 17 +- slide/Native/DrawingDocument.js | 1881 -------- slide/Native/HtmlPage.js | 611 --- slide/Native/api.js | 1081 ----- slide/Native/native.js | 1763 -------- word/Native/DrawingDocument.js | 3031 ------------- word/Native/HtmlPage.js | 505 --- word/Native/api.js | 4680 -------------------- 21 files changed, 3 insertions(+), 33730 deletions(-) delete mode 100644 cell/native/DrawingDocument.js delete mode 100644 cell/native/Graphics.js delete mode 100644 cell/native/Overlay.js delete mode 100644 cell/native/native.js delete mode 100755 common/Native/Wrappers/DrawingStream.js delete mode 100755 common/Native/Wrappers/Overlay.js delete mode 100755 common/Native/Wrappers/ShapeDrawer.js delete mode 100755 common/Native/Wrappers/common.js delete mode 100755 common/Native/Wrappers/memory.js delete mode 100644 common/Native/Wrappers/serialize.js delete mode 100755 common/Native/native.js delete mode 100644 slide/Native/DrawingDocument.js delete mode 100644 slide/Native/HtmlPage.js delete mode 100644 slide/Native/api.js delete mode 100644 slide/Native/native.js delete mode 100644 word/Native/DrawingDocument.js delete mode 100644 word/Native/HtmlPage.js delete mode 100644 word/Native/api.js diff --git a/cell/native/DrawingDocument.js b/cell/native/DrawingDocument.js deleted file mode 100644 index ce81fa9156..0000000000 --- a/cell/native/DrawingDocument.js +++ /dev/null @@ -1,3231 +0,0 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2023 - * - * This program is a free software product. You can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License (AGPL) - * version 3 as published by the Free Software Foundation. In accordance with - * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement - * of any third-party rights. - * - * This program is distributed WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ - -"use strict"; - -var g_dKoef_pix_to_mm = AscCommon.g_dKoef_pix_to_mm; -var g_dKoef_mm_to_pix = AscCommon.g_dKoef_mm_to_pix; - -function CTextMeasurer() -{ - this.m_oManager = new window['AscFonts'].CFontManager(); - - this.m_oFont = null; - - // RFonts - this.m_oTextPr = null; - this.m_oLastFont = new CFontSetup(); - this.LastFontOriginInfo = { Name : "", Replace : null }; - - this.Init = function() - { - this.m_oManager.Initialize(); - }; - - this.SetFont = function(font) - { - if (!font) - return; - - this.m_oFont = font; - - var bItalic = true === font.Italic; - var bBold = true === font.Bold; - - var oFontStyle = FontStyle.FontStyleRegular; - if ( !bItalic && bBold ) - oFontStyle = FontStyle.FontStyleBold; - else if ( bItalic && !bBold ) - oFontStyle = FontStyle.FontStyleItalic; - else if ( bItalic && bBold ) - oFontStyle = FontStyle.FontStyleBoldItalic; - - var _lastSetUp = this.m_oLastFont; - if (_lastSetUp.SetUpName != font.FontFamily.Name || _lastSetUp.SetUpSize != font.FontSize || _lastSetUp.SetUpStyle != oFontStyle) - { - _lastSetUp.SetUpName = font.FontFamily.Name; - _lastSetUp.SetUpSize = font.FontSize; - _lastSetUp.SetUpStyle = oFontStyle; - - g_fontApplication.LoadFont(_lastSetUp.SetUpName, AscCommon.g_font_loader, this.m_oManager, _lastSetUp.SetUpSize, _lastSetUp.SetUpStyle, 72, 72, undefined, this.LastFontOriginInfo); - } - }; - - this.SetFontInternal = function(_name, _size, _style) - { - var _lastSetUp = this.m_oLastFont; - if (_lastSetUp.SetUpName != _name || _lastSetUp.SetUpSize != _size || _lastSetUp.SetUpStyle != _style) - { - _lastSetUp.SetUpName = _name; - _lastSetUp.SetUpSize = _size; - _lastSetUp.SetUpStyle = _style; - - g_fontApplication.LoadFont(_lastSetUp.SetUpName, AscCommon.g_font_loader, this.m_oManager, _lastSetUp.SetUpSize, _lastSetUp.SetUpStyle, 72, 72, undefined, this.LastFontOriginInfo); - } - }; - - this.SetTextPr = function(textPr, theme) - { - this.m_oTextPr = textPr.Copy(); - this.theme = theme; - this.m_oTextPr.ReplaceThemeFonts(theme.themeElements.fontScheme); - }; - - this.SetFontSlot = function(slot, fontSizeKoef) - { - var _rfonts = this.m_oTextPr.RFonts; - var _lastFont = this.m_oLastFont; - - switch (slot) - { - case fontslot_ASCII: - { - _lastFont.Name = _rfonts.Ascii.Name; - _lastFont.Index = _rfonts.Ascii.Index; - - _lastFont.Size = this.m_oTextPr.FontSize; - _lastFont.Bold = this.m_oTextPr.Bold; - _lastFont.Italic = this.m_oTextPr.Italic; - - break; - } - case fontslot_CS: - { - _lastFont.Name = _rfonts.CS.Name; - _lastFont.Index = _rfonts.CS.Index; - - _lastFont.Size = this.m_oTextPr.FontSizeCS; - _lastFont.Bold = this.m_oTextPr.BoldCS; - _lastFont.Italic = this.m_oTextPr.ItalicCS; - - break; - } - case fontslot_EastAsia: - { - _lastFont.Name = _rfonts.EastAsia.Name; - _lastFont.Index = _rfonts.EastAsia.Index; - - _lastFont.Size = this.m_oTextPr.FontSize; - _lastFont.Bold = this.m_oTextPr.Bold; - _lastFont.Italic = this.m_oTextPr.Italic; - - break; - } - case fontslot_HAnsi: - default: - { - _lastFont.Name = _rfonts.HAnsi.Name; - _lastFont.Index = _rfonts.HAnsi.Index; - - _lastFont.Size = this.m_oTextPr.FontSize; - _lastFont.Bold = this.m_oTextPr.Bold; - _lastFont.Italic = this.m_oTextPr.Italic; - - break; - } - } - - if (undefined !== fontSizeKoef) - _lastFont.Size *= fontSizeKoef; - - var _style = 0; - if (_lastFont.Italic) - _style += 2; - if (_lastFont.Bold) - _style += 1; - - if (_lastFont.Name != _lastFont.SetUpName || _lastFont.Size != _lastFont.SetUpSize || _style != _lastFont.SetUpStyle) - { - _lastFont.SetUpName = _lastFont.Name; - _lastFont.SetUpSize = _lastFont.Size; - _lastFont.SetUpStyle = _style; - - g_fontApplication.LoadFont(_lastFont.SetUpName, AscCommon.g_font_loader, this.m_oManager, _lastFont.SetUpSize, _lastFont.SetUpStyle, 72, 72, undefined, this.LastFontOriginInfo); - } - }; - - this.GetTextPr = function() - { - return this.m_oTextPr; - }; - - this.GetFont = function() - { - return this.m_oFont; - }; - - this.Measure = function(text) - { - var Width = 0; - var Height = 0; - - var _code = text.charCodeAt(0); - if (null != this.LastFontOriginInfo.Replace) - _code = g_fontApplication.GetReplaceGlyph(_code, this.LastFontOriginInfo.Replace); - - var Temp = this.m_oManager.MeasureChar( _code); - - Width = Temp.fAdvanceX * 25.4 / 72; - Height = 0;//Temp.fHeight; - - return { Width : Width, Height : Height }; - }; - this.Measure2 = function(text) - { - var Width = 0; - - var _code = text.charCodeAt(0); - if (null != this.LastFontOriginInfo.Replace) - _code = g_fontApplication.GetReplaceGlyph(_code, this.LastFontOriginInfo.Replace); - - var Temp = this.m_oManager.MeasureChar( _code ); - - Width = Temp.fAdvanceX * 25.4 / 72; - - return { Width : Width, Ascent : (Temp.oBBox.fMaxY * 25.4 / 72), Height : ((Temp.oBBox.fMaxY - Temp.oBBox.fMinY) * 25.4 / 72), - WidthG: ((Temp.oBBox.fMaxX - Temp.oBBox.fMinX) * 25.4 / 72)}; - }; - - this.MeasureCode = function(lUnicode) - { - var Width = 0; - var Height = 0; - - if (null != this.LastFontOriginInfo.Replace) - lUnicode = g_fontApplication.GetReplaceGlyph(lUnicode, this.LastFontOriginInfo.Replace); - - var Temp = this.m_oManager.MeasureChar( lUnicode ); - - Width = Temp.fAdvanceX * 25.4 / 72; - Height = 0;//Temp.fHeight; - - return { Width : Width, Height : Height }; - }; - this.Measure2Code = function(lUnicode) - { - var Width = 0; - - if (null != this.LastFontOriginInfo.Replace) - lUnicode = g_fontApplication.GetReplaceGlyph(lUnicode, this.LastFontOriginInfo.Replace); - - var Temp = this.m_oManager.MeasureChar( lUnicode ); - - Width = Temp.fAdvanceX * 25.4 / 72; - - return { Width : Width, Ascent : (Temp.oBBox.fMaxY * 25.4 / 72), Height : ((Temp.oBBox.fMaxY - Temp.oBBox.fMinY) * 25.4 / 72), - WidthG: ((Temp.oBBox.fMaxX - Temp.oBBox.fMinX) * 25.4 / 72)}; - }; - - this.GetAscender = function() - { - var UnitsPerEm = this.m_oManager.m_lUnits_Per_Em; - var Ascender = this.m_oManager.m_lAscender; - - return Ascender * this.m_oLastFont.SetUpSize / UnitsPerEm * g_dKoef_pt_to_mm; - }; - this.GetDescender = function() - { - var UnitsPerEm = this.m_oManager.m_lUnits_Per_Em; - var Descender = this.m_oManager.m_lDescender; - - return Descender * this.m_oLastFont.SetUpSize / UnitsPerEm * g_dKoef_pt_to_mm; - }; - this.GetHeight = function() - { - var UnitsPerEm = this.m_oManager.m_lUnits_Per_Em; - var Height = this.m_oManager.m_lLineHeight; - - return Height * this.m_oLastFont.SetUpSize / UnitsPerEm * g_dKoef_pt_to_mm; - }; -} - -function CTableOutlineDr() -{ - this.image = document.createElement('canvas'); - this.image.width = 13; - this.image.height = 13; - - this.TableOutline = null; - this.Counter = 0; - this.bIsNoTable = true; - this.bIsTracked = false; - - this.CurPos = null; - this.TrackTablePos = 0; // 0 - left_top, 1 - right_top, 2 - right_bottom, 3 - left_bottom - this.TrackOffsetX = 0; - this.TrackOffsetY = 0; - - this.InlinePos = null; - - this.IsChangeSmall = true; - this.ChangeSmallPoint = null; - - this.TableMatrix = null; - this.CurrentPageIndex = null; - - this.checkMouseDown = function(pos, word_control) - { - if (null == this.TableOutline) - return false; - - var _table_track = this.TableOutline; - var _d = 13 * g_dKoef_pix_to_mm * 100 / word_control.m_nZoomValue; - - this.IsChangeSmall = true; - this.ChangeSmallPoint = pos; - - if (!this.TableMatrix || AscCommon.global_MatrixTransformer.IsIdentity(this.TableMatrix)) - { - if (word_control.MobileTouchManager) - { - var _move_point = word_control.MobileTouchManager.TableMovePoint; - - if (_move_point == null || pos.Page != _table_track.PageNum) - return false; - - var _pos1 = word_control.m_oDrawingDocument.ConvertCoordsToCursorWR(pos.X, pos.Y, pos.Page); - var _pos2 = word_control.m_oDrawingDocument.ConvertCoordsToCursorWR(_move_point.X, _move_point.Y, pos.Page); - - var _eps = word_control.MobileTouchManager.TrackTargetEps; - - var _offset1 = word_control.MobileTouchManager.TableRulersRectOffset; - var _offset2 = _offset1 + word_control.MobileTouchManager.TableRulersRectSize; - if ((_pos1.X >= (_pos2.X - _offset2 - _eps)) && (_pos1.X <= (_pos2.X - _offset1 + _eps)) && - (_pos1.Y >= (_pos2.Y - _offset2 - _eps)) && (_pos1.Y <= (_pos2.Y - _offset1 + _eps))) - { - this.TrackTablePos = 0; - return true; - } - - return false; - } - - switch (this.TrackTablePos) - { - case 1: - { - var _x = _table_track.X + _table_track.W; - var _b = _table_track.Y; - var _y = _b - _d; - var _r = _x + _d; - - if ((pos.X > _x) && (pos.X < _r) && (pos.Y > _y) && (pos.Y < _b)) - { - this.TrackOffsetX = pos.X - _x; - this.TrackOffsetY = pos.Y - _b; - return true; - } - return false; - } - case 2: - { - var _x = _table_track.X + _table_track.W; - var _y = _table_track.Y + _table_track.H; - var _r = _x + _d; - var _b = _y + _d; - - if ((pos.X > _x) && (pos.X < _r) && (pos.Y > _y) && (pos.Y < _b)) - { - this.TrackOffsetX = pos.X - _x; - this.TrackOffsetY = pos.Y - _y; - return true; - } - return false; - } - case 3: - { - var _r = _table_track.X; - var _x = _r - _d; - var _y = _table_track.Y + _table_track.H; - var _b = _y + _d; - - if ((pos.X > _x) && (pos.X < _r) && (pos.Y > _y) && (pos.Y < _b)) - { - this.TrackOffsetX = pos.X - _r; - this.TrackOffsetY = pos.Y - _y; - return true; - } - return false; - } - case 0: - default: - { - var _r = _table_track.X; - var _b = _table_track.Y; - var _x = _r - _d; - var _y = _b - _d; - - if ((pos.X > _x) && (pos.X < _r) && (pos.Y > _y) && (pos.Y < _b)) - { - this.TrackOffsetX = pos.X - _r; - this.TrackOffsetY = pos.Y - _b; - return true; - } - return false; - } - } - } - else - { - if (word_control.MobileTouchManager) - { - var _invert = AscCommon.global_MatrixTransformer.Invert(this.TableMatrix); - var _posx = _invert.TransformPointX(pos.X, pos.Y); - var _posy = _invert.TransformPointY(pos.X, pos.Y); - - var _move_point = word_control.MobileTouchManager.TableMovePoint; - - if (_move_point == null || pos.Page != _table_track.PageNum) - return false; - - var _koef = g_dKoef_pix_to_mm * 100 / word_control.m_nZoomValue; - var _eps = word_control.MobileTouchManager.TrackTargetEps * _koef; - - var _offset1 = word_control.MobileTouchManager.TableRulersRectOffset * _koef; - var _offset2 = _offset1 + word_control.MobileTouchManager.TableRulersRectSize * _koef; - if ((_posx >= (_move_point.X - _offset2 - _eps)) && (_posx <= (_move_point.X - _offset1 + _eps)) && - (_posy >= (_move_point.Y - _offset2 - _eps)) && (_posy <= (_move_point.Y - _offset1 + _eps))) - { - this.TrackTablePos = 0; - return true; - } - - return false; - } - - var _invert = AscCommon.global_MatrixTransformer.Invert(this.TableMatrix); - var _posx = _invert.TransformPointX(pos.X, pos.Y); - var _posy = _invert.TransformPointY(pos.X, pos.Y); - switch (this.TrackTablePos) - { - case 1: - { - var _x = _table_track.X + _table_track.W; - var _b = _table_track.Y; - var _y = _b - _d; - var _r = _x + _d; - - if ((_posx > _x) && (_posx < _r) && (_posy > _y) && (_posy < _b)) - { - this.TrackOffsetX = _posx - _x; - this.TrackOffsetY = _posy - _b; - return true; - } - return false; - } - case 2: - { - var _x = _table_track.X + _table_track.W; - var _y = _table_track.Y + _table_track.H; - var _r = _x + _d; - var _b = _y + _d; - - if ((_posx > _x) && (_posx < _r) && (_posy > _y) && (_posy < _b)) - { - this.TrackOffsetX = _posx - _x; - this.TrackOffsetY = _posy - _y; - return true; - } - return false; - } - case 3: - { - var _r = _table_track.X; - var _x = _r - _d; - var _y = _table_track.Y + _table_track.H; - var _b = _y + _d; - - if ((_posx > _x) && (_posx < _r) && (_posy > _y) && (_posy < _b)) - { - this.TrackOffsetX = _posx - _r; - this.TrackOffsetY = _posy - _y; - return true; - } - return false; - } - case 0: - default: - { - var _r = _table_track.X; - var _b = _table_track.Y; - var _x = _r - _d; - var _y = _b - _d; - - if ((_posx > _x) && (_posx < _r) && (_posy > _y) && (_posy < _b)) - { - this.TrackOffsetX = _posx - _r; - this.TrackOffsetY = _posy - _b; - return true; - } - return false; - } - } - } - - return false; - } - - this.checkMouseUp = function(X, Y, word_control) - { - this.bIsTracked = false; - - if (null == this.TableOutline || (true === this.IsChangeSmall) || word_control.m_oApi.isViewMode) - return false; - - var _d = 13 * g_dKoef_pix_to_mm * 100 / word_control.m_nZoomValue; - - var _outline = this.TableOutline; - var _table = _outline.Table; - - _table.MoveCursorToStartPos(); - _table.Document_SetThisElementCurrent(); - - if (!_table.Is_Inline()) - { - var pos; - switch (this.TrackTablePos) - { - case 1: - { - var _w_pix = this.TableOutline.W * g_dKoef_mm_to_pix * word_control.m_nZoomValue / 100; - pos = word_control.m_oDrawingDocument.ConvertCoordsFromCursor2(X - _w_pix, Y); - break; - } - case 2: - { - var _w_pix = this.TableOutline.W * g_dKoef_mm_to_pix * word_control.m_nZoomValue / 100; - var _h_pix = this.TableOutline.H * g_dKoef_mm_to_pix * word_control.m_nZoomValue / 100; - pos = word_control.m_oDrawingDocument.ConvertCoordsFromCursor2(X - _w_pix, Y - _h_pix); - break; - } - case 3: - { - var _h_pix = this.TableOutline.H * g_dKoef_mm_to_pix * word_control.m_nZoomValue / 100; - pos = word_control.m_oDrawingDocument.ConvertCoordsFromCursor2(X, Y - _h_pix); - break; - } - case 0: - default: - { - pos = word_control.m_oDrawingDocument.ConvertCoordsFromCursor2(X, Y); - break; - } - } - - var NearestPos = word_control.m_oLogicDocument.Get_NearestPos(pos.Page, pos.X - this.TrackOffsetX, pos.Y - this.TrackOffsetY); - _table.Move(pos.X - this.TrackOffsetX, pos.Y - this.TrackOffsetY, pos.Page, NearestPos); - _outline.X = pos.X - this.TrackOffsetX; - _outline.Y = pos.Y - this.TrackOffsetY; - _outline.PageNum = pos.Page; - } - else - { - if (null != this.InlinePos) - { - // inline move - _table.Move(this.InlinePos.X, this.InlinePos.Y, this.InlinePos.Page, this.InlinePos); - } - } - } - - this.checkMouseMove = function(X, Y, word_control) - { - if (null == this.TableOutline) - return false; - - if (true === this.IsChangeSmall) - { - var _pos = word_control.m_oDrawingDocument.ConvertCoordsFromCursor2(X, Y); - var _dist = 15 * g_dKoef_pix_to_mm * 100 / word_control.m_nZoomValue; - if ((Math.abs(_pos.X - this.ChangeSmallPoint.X) < _dist) && (Math.abs(_pos.Y - this.ChangeSmallPoint.Y) < _dist) && (_pos.Page == this.ChangeSmallPoint.Page)) - { - this.CurPos = { X: this.ChangeSmallPoint.X, Y : this.ChangeSmallPoint.Y, Page: this.ChangeSmallPoint.Page }; - - switch (this.TrackTablePos) - { - case 1: - { - this.CurPos.X -= this.TableOutline.W; - break; - } - case 2: - { - this.CurPos.X -= this.TableOutline.W; - this.CurPos.Y -= this.TableOutline.H; - break; - } - case 3: - { - this.CurPos.Y -= this.TableOutline.H; - break; - } - case 0: - default: - { - break; - } - } - - this.CurPos.X -= this.TrackOffsetX; - this.CurPos.Y -= this.TrackOffsetY; - return; - } - this.IsChangeSmall = false; - - this.TableOutline.Table.RemoveSelection(); - editor.WordControl.m_oLogicDocument.Document_UpdateSelectionState(); - } - - var _d = 13 * g_dKoef_pix_to_mm * 100 / word_control.m_nZoomValue; - switch (this.TrackTablePos) - { - case 1: - { - var _w_pix = this.TableOutline.W * g_dKoef_mm_to_pix * word_control.m_nZoomValue / 100; - this.CurPos = word_control.m_oDrawingDocument.ConvertCoordsFromCursor2(X - _w_pix, Y); - break; - } - case 2: - { - var _w_pix = this.TableOutline.W * g_dKoef_mm_to_pix * word_control.m_nZoomValue / 100; - var _h_pix = this.TableOutline.H * g_dKoef_mm_to_pix * word_control.m_nZoomValue / 100; - this.CurPos = word_control.m_oDrawingDocument.ConvertCoordsFromCursor2(X - _w_pix, Y - _h_pix); - break; - } - case 3: - { - var _h_pix = this.TableOutline.H * g_dKoef_mm_to_pix * word_control.m_nZoomValue / 100; - this.CurPos = word_control.m_oDrawingDocument.ConvertCoordsFromCursor2(X, Y - _h_pix); - break; - } - case 0: - default: - { - this.CurPos = word_control.m_oDrawingDocument.ConvertCoordsFromCursor2(X, Y); - break; - } - } - - this.CurPos.X -= this.TrackOffsetX; - this.CurPos.Y -= this.TrackOffsetY; - } - - this.CheckStartTrack = function(word_control, transform) - { - this.TableMatrix = null; - if (transform) - this.TableMatrix = transform.CreateDublicate(); - - if (!this.TableMatrix || AscCommon.global_MatrixTransformer.IsIdentity(this.TableMatrix)) - { - var pos = word_control.m_oDrawingDocument.ConvertCoordsToCursor(this.TableOutline.X, this.TableOutline.Y, this.TableOutline.PageNum, true); - - var _x0 = word_control.m_oEditor.AbsolutePosition.L; - var _y0 = word_control.m_oEditor.AbsolutePosition.T; - - if (pos.X < _x0 && pos.Y < _y0) - { - this.TrackTablePos = 2; - } - else if (pos.X < _x0) - { - this.TrackTablePos = 1; - } - else if (pos.Y < _y0) - { - this.TrackTablePos = 3; - } - else - { - this.TrackTablePos = 0; - } - } - else - { - var _x = this.TableOutline.X; - var _y = this.TableOutline.Y; - var _r = _x + this.TableOutline.W; - var _b = _y + this.TableOutline.H; - - var x0 = transform.TransformPointX(_x, _y); - var y0 = transform.TransformPointY(_x, _y); - - var x1 = transform.TransformPointX(_r, _y); - var y1 = transform.TransformPointY(_r, _y); - - var x2 = transform.TransformPointX(_r, _b); - var y2 = transform.TransformPointY(_r, _b); - - var x3 = transform.TransformPointX(_x, _b); - var y3 = transform.TransformPointY(_x, _b); - - var _x0 = word_control.m_oEditor.AbsolutePosition.L * g_dKoef_mm_to_pix; - var _y0 = word_control.m_oEditor.AbsolutePosition.T * g_dKoef_mm_to_pix; - var _x1 = word_control.m_oEditor.AbsolutePosition.R * g_dKoef_mm_to_pix; - var _y1 = word_control.m_oEditor.AbsolutePosition.B * g_dKoef_mm_to_pix; - - var pos0 = word_control.m_oDrawingDocument.ConvertCoordsToCursor(x0, y0, this.TableOutline.PageNum, true); - if (pos0.X > _x0 && pos0.X < _x1 && pos0.Y > _y0 && pos0.Y < _y1) - { - this.TrackTablePos = 0; - return; - } - - pos0 = word_control.m_oDrawingDocument.ConvertCoordsToCursor(x1, y1, this.TableOutline.PageNum, true); - if (pos0.X > _x0 && pos0.X < _x1 && pos0.Y > _y0 && pos0.Y < _y1) - { - this.TrackTablePos = 1; - return; - } - - pos0 = word_control.m_oDrawingDocument.ConvertCoordsToCursor(x3, y3, this.TableOutline.PageNum, true); - if (pos0.X > _x0 && pos0.X < _x1 && pos0.Y > _y0 && pos0.Y < _y1) - { - this.TrackTablePos = 3; - return; - } - - pos0 = word_control.m_oDrawingDocument.ConvertCoordsToCursor(x2, y2, this.TableOutline.PageNum, true); - if (pos0.X > _x0 && pos0.X < _x1 && pos0.Y > _y0 && pos0.Y < _y1) - { - this.TrackTablePos = 2; - return; - } - - this.TrackTablePos = 0; - } - } -} - -function CDrawingPage() -{ - this.left = 0; - this.top = 0; - this.right = 0; - this.bottom = 0; - - this.cachedImage = null; -} - -function CPage() -{ - this.width_mm = 210; - this.height_mm = 297; - - this.margin_left = 0; - this.margin_top = 0; - this.margin_right = 0; - this.margin_bottom = 0; - - this.pageIndex = -1; - - this.searchingArray = []; - this.selectionArray = []; - this.drawingPage = new CDrawingPage(); - - this.Draw = function(context, xDst, yDst, wDst, hDst, contextW, contextH) - { - if (null != this.drawingPage.cachedImage) - { - context.strokeStyle = "#81878F"; - context.strokeRect(xDst, yDst, wDst, hDst); - // потом посмотреть на кусочную отрисовку - context.drawImage(this.drawingPage.cachedImage.image, xDst, yDst, wDst, hDst); - } - else - { - context.fillStyle = "#ffffff"; - context.strokeStyle = "#81878F"; - context.strokeRect(xDst, yDst, wDst, hDst); - context.fillRect(xDst, yDst, wDst, hDst); - } - } - - this.DrawSelection = function(overlay, xDst, yDst, wDst, hDst, TextMatrix) - { - var dKoefX = wDst / this.width_mm; - var dKoefY = hDst / this.height_mm; - - var selectionArray = this.selectionArray; - - if (null == TextMatrix || AscCommon.global_MatrixTransformer.IsIdentity(TextMatrix)) - { - for (var i = 0; i < selectionArray.length; i++) - { - var r = selectionArray[i]; - - var _x = ((xDst + dKoefX * r.x) >> 0) - 0.5; - var _y = ((yDst + dKoefY * r.y) >> 0) - 0.5; - - var _w = (dKoefX * r.w + 1) >> 0; - var _h = (dKoefY * r.h + 1) >> 0; - - if (_x < overlay.min_x) - overlay.min_x = _x; - if ((_x + _w) > overlay.max_x) - overlay.max_x = _x + _w; - - if (_y < overlay.min_y) - overlay.min_y = _y; - if ((_y + _h) > overlay.max_y) - overlay.max_y = _y + _h; - - overlay.m_oContext.rect(_x,_y,_w,_h); - } - } - else - { - for (var i = 0; i < selectionArray.length; i++) - { - var r = selectionArray[i]; - - var _x1 = TextMatrix.TransformPointX(r.x, r.y); - var _y1 = TextMatrix.TransformPointY(r.x, r.y); - - var _x2 = TextMatrix.TransformPointX(r.x + r.w, r.y); - var _y2 = TextMatrix.TransformPointY(r.x + r.w, r.y); - - var _x3 = TextMatrix.TransformPointX(r.x + r.w, r.y + r.h); - var _y3 = TextMatrix.TransformPointY(r.x + r.w, r.y + r.h); - - var _x4 = TextMatrix.TransformPointX(r.x, r.y + r.h); - var _y4 = TextMatrix.TransformPointY(r.x, r.y + r.h); - - var x1 = xDst + dKoefX * _x1; - var y1 = yDst + dKoefY * _y1; - - var x2 = xDst + dKoefX * _x2; - var y2 = yDst + dKoefY * _y2; - - var x3 = xDst + dKoefX * _x3; - var y3 = yDst + dKoefY * _y3; - - var x4 = xDst + dKoefX * _x4; - var y4 = yDst + dKoefY * _y4; - - overlay.CheckPoint(x1, y1); - overlay.CheckPoint(x2, y2); - overlay.CheckPoint(x3, y3); - overlay.CheckPoint(x4, y4); - - var ctx = overlay.m_oContext; - ctx.moveTo(x1, y1); - ctx.lineTo(x2, y2); - ctx.lineTo(x3, y3); - ctx.lineTo(x4, y4); - ctx.closePath(); - } - } - } - this.DrawSearch = function(overlay, xDst, yDst, wDst, hDst, drDoc) - { - var dKoefX = wDst / this.width_mm; - var dKoefY = hDst / this.height_mm; - - // проверяем колонтитулы ------------ - var ret = this.drawInHdrFtr(overlay, xDst, yDst, wDst, hDst, dKoefX, dKoefY, drDoc._search_HdrFtr_All); - if (!ret && this.pageIndex != 0) - ret = this.drawInHdrFtr(overlay, xDst, yDst, wDst, hDst, dKoefX, dKoefY, drDoc._search_HdrFtr_All_no_First); - if (!ret && this.pageIndex == 0) - ret = this.drawInHdrFtr(overlay, xDst, yDst, wDst, hDst, dKoefX, dKoefY, drDoc._search_HdrFtr_First); - if (!ret && (this.pageIndex & 1) == 1) - ret = this.drawInHdrFtr(overlay, xDst, yDst, wDst, hDst, dKoefX, dKoefY, drDoc._search_HdrFtr_Even); - if (!ret && (this.pageIndex & 1) == 0) - ret = this.drawInHdrFtr(overlay, xDst, yDst, wDst, hDst, dKoefX, dKoefY, drDoc._search_HdrFtr_Odd); - if (!ret && (this.pageIndex != 0)) - ret = this.drawInHdrFtr(overlay, xDst, yDst, wDst, hDst, dKoefX, dKoefY, drDoc._search_HdrFtr_Odd_no_First); - // ---------------------------------- - - var ctx = overlay.m_oContext; - for (var i = 0; i < this.searchingArray.length; i++) - { - var place = this.searchingArray[i]; - - if (!place.Transform) - { - if (undefined === place.Ex) - { - var _x = parseInt(xDst + dKoefX * place.X) - 0.5; - var _y = parseInt(yDst + dKoefY * place.Y) - 0.5; - - var _w = parseInt(dKoefX * place.W) + 1; - var _h = parseInt(dKoefY * place.H) + 1; - - if (_x < overlay.min_x) - overlay.min_x = _x; - if ((_x + _w) > overlay.max_x) - overlay.max_x = _x + _w; - - if (_y < overlay.min_y) - overlay.min_y = _y; - if ((_y + _h) > overlay.max_y) - overlay.max_y = _y + _h; - - ctx.rect(_x,_y,_w,_h); - } - else - { - var _x1 = parseInt(xDst + dKoefX * place.X); - var _y1 = parseInt(yDst + dKoefY * place.Y); - - var x2 = place.X + place.W * place.Ex; - var y2 = place.Y + place.W * place.Ey; - var _x2 = parseInt(xDst + dKoefX * x2); - var _y2 = parseInt(yDst + dKoefY * y2); - - var x3 = x2 - place.H * place.Ey; - var y3 = y2 + place.H * place.Ex; - var _x3 = parseInt(xDst + dKoefX * x3); - var _y3 = parseInt(yDst + dKoefY * y3); - - var x4 = place.X - place.H * place.Ey; - var y4 = place.Y + place.H * place.Ex; - var _x4 = parseInt(xDst + dKoefX * x4); - var _y4 = parseInt(yDst + dKoefY * y4); - - overlay.CheckPoint(_x1, _y1); - overlay.CheckPoint(_x2, _y2); - overlay.CheckPoint(_x3, _y3); - overlay.CheckPoint(_x4, _y4); - - ctx.moveTo(_x1, _y1); - ctx.lineTo(_x2, _y2); - ctx.lineTo(_x3, _y3); - ctx.lineTo(_x4, _y4); - ctx.lineTo(_x1, _y1); - } - } - else - { - var _tr = place.Transform; - if (undefined === place.Ex) - { - var _x1 = xDst + dKoefX * _tr.TransformPointX(place.X, place.Y); - var _y1 = yDst + dKoefY * _tr.TransformPointY(place.X, place.Y); - - var _x2 = xDst + dKoefX * _tr.TransformPointX(place.X + place.W, place.Y); - var _y2 = yDst + dKoefY * _tr.TransformPointY(place.X + place.W, place.Y); - - var _x3 = xDst + dKoefX * _tr.TransformPointX(place.X + place.W, place.Y + place.H); - var _y3 = yDst + dKoefY * _tr.TransformPointY(place.X + place.W, place.Y + place.H); - - var _x4 = xDst + dKoefX * _tr.TransformPointX(place.X, place.Y + place.H); - var _y4 = yDst + dKoefY * _tr.TransformPointY(place.X, place.Y + place.H); - - overlay.CheckPoint(_x1, _y1); - overlay.CheckPoint(_x2, _y2); - overlay.CheckPoint(_x3, _y3); - overlay.CheckPoint(_x4, _y4); - - ctx.moveTo(_x1, _y1); - ctx.lineTo(_x2, _y2); - ctx.lineTo(_x3, _y3); - ctx.lineTo(_x4, _y4); - ctx.lineTo(_x1, _y1); - } - else - { - var x2 = place.X + place.W * place.Ex; - var y2 = place.Y + place.W * place.Ey; - - var x3 = x2 - place.H * place.Ey; - var y3 = y2 + place.H * place.Ex; - - var x4 = place.X - place.H * place.Ey; - var y4 = place.Y + place.H * place.Ex; - - var _x1 = xDst + dKoefX * _tr.TransformPointX(place.X, place.Y); - var _y1 = yDst + dKoefY * _tr.TransformPointY(place.X, place.Y); - - var _x2 = xDst + dKoefX * _tr.TransformPointX(x2, y2); - var _y2 = yDst + dKoefY * _tr.TransformPointY(x2, y2); - - var _x3 = xDst + dKoefX * _tr.TransformPointX(x3, y3); - var _y3 = yDst + dKoefY * _tr.TransformPointY(x3, y3); - - var _x4 = xDst + dKoefX * _tr.TransformPointX(x4, y4); - var _y4 = yDst + dKoefY * _tr.TransformPointY(x4, y4); - - overlay.CheckPoint(_x1, _y1); - overlay.CheckPoint(_x2, _y2); - overlay.CheckPoint(_x3, _y3); - overlay.CheckPoint(_x4, _y4); - - ctx.moveTo(_x1, _y1); - ctx.lineTo(_x2, _y2); - ctx.lineTo(_x3, _y3); - ctx.lineTo(_x4, _y4); - ctx.lineTo(_x1, _y1); - } - } - } - } - - this.drawInHdrFtr = function(overlay, xDst, yDst, wDst, hDst, dKoefX, dKoefY, arr) - { - var _c = arr.length; - if (0 == _c) - return false; - - var ctx = overlay.m_oContext; - for (var i = 0; i < _c; i++) - { - var place = arr[i]; - - if (!place.Transform) - { - if (undefined === place.Ex) - { - var _x = parseInt(xDst + dKoefX * place.X) - 0.5; - var _y = parseInt(yDst + dKoefY * place.Y) - 0.5; - - var _w = parseInt(dKoefX * place.W) + 1; - var _h = parseInt(dKoefY * place.H) + 1; - - if (_x < overlay.min_x) - overlay.min_x = _x; - if ((_x + _w) > overlay.max_x) - overlay.max_x = _x + _w; - - if (_y < overlay.min_y) - overlay.min_y = _y; - if ((_y + _h) > overlay.max_y) - overlay.max_y = _y + _h; - - ctx.rect(_x,_y,_w,_h); - } - else - { - var _x1 = parseInt(xDst + dKoefX * place.X); - var _y1 = parseInt(yDst + dKoefY * place.Y); - - var x2 = place.X + place.W * place.Ex; - var y2 = place.Y + place.W * place.Ey; - var _x2 = parseInt(xDst + dKoefX * x2); - var _y2 = parseInt(yDst + dKoefY * y2); - - var x3 = x2 - place.H * place.Ey; - var y3 = y2 + place.H * place.Ex; - var _x3 = parseInt(xDst + dKoefX * x3); - var _y3 = parseInt(yDst + dKoefY * y3); - - var x4 = place.X - place.H * place.Ey; - var y4 = place.Y + place.H * place.Ex; - var _x4 = parseInt(xDst + dKoefX * x4); - var _y4 = parseInt(yDst + dKoefY * y4); - - overlay.CheckPoint(_x1, _y1); - overlay.CheckPoint(_x2, _y2); - overlay.CheckPoint(_x3, _y3); - overlay.CheckPoint(_x4, _y4); - - ctx.moveTo(_x1, _y1); - ctx.lineTo(_x2, _y2); - ctx.lineTo(_x3, _y3); - ctx.lineTo(_x4, _y4); - ctx.lineTo(_x1, _y1); - } - } - else - { - var _tr = place.Transform; - if (undefined === place.Ex) - { - var _x1 = xDst + dKoefX * _tr.TransformPointX(place.X, place.Y); - var _y1 = yDst + dKoefY * _tr.TransformPointY(place.X, place.Y); - - var _x2 = xDst + dKoefX * _tr.TransformPointX(place.X + place.W, place.Y); - var _y2 = yDst + dKoefY * _tr.TransformPointY(place.X + place.W, place.Y); - - var _x3 = xDst + dKoefX * _tr.TransformPointX(place.X + place.W, place.Y + place.H); - var _y3 = yDst + dKoefY * _tr.TransformPointY(place.X + place.W, place.Y + place.H); - - var _x4 = xDst + dKoefX * _tr.TransformPointX(place.X, place.Y + place.H); - var _y4 = yDst + dKoefY * _tr.TransformPointY(place.X, place.Y + place.H); - - overlay.CheckPoint(_x1, _y1); - overlay.CheckPoint(_x2, _y2); - overlay.CheckPoint(_x3, _y3); - overlay.CheckPoint(_x4, _y4); - - ctx.moveTo(_x1, _y1); - ctx.lineTo(_x2, _y2); - ctx.lineTo(_x3, _y3); - ctx.lineTo(_x4, _y4); - ctx.lineTo(_x1, _y1); - } - else - { - var x2 = place.X + place.W * place.Ex; - var y2 = place.Y + place.W * place.Ey; - - var x3 = x2 - place.H * place.Ey; - var y3 = y2 + place.H * place.Ex; - - var x4 = place.X - place.H * place.Ey; - var y4 = place.Y + place.H * place.Ex; - - var _x1 = xDst + dKoefX * _tr.TransformPointX(place.X, place.Y); - var _y1 = yDst + dKoefY * _tr.TransformPointY(place.X, place.Y); - - var _x2 = xDst + dKoefX * _tr.TransformPointX(x2, y2); - var _y2 = yDst + dKoefY * _tr.TransformPointY(x2, y2); - - var _x3 = xDst + dKoefX * _tr.TransformPointX(x3, y3); - var _y3 = yDst + dKoefY * _tr.TransformPointY(x3, y3); - - var _x4 = xDst + dKoefX * _tr.TransformPointX(x4, y4); - var _y4 = yDst + dKoefY * _tr.TransformPointY(x4, y4); - - overlay.CheckPoint(_x1, _y1); - overlay.CheckPoint(_x2, _y2); - overlay.CheckPoint(_x3, _y3); - overlay.CheckPoint(_x4, _y4); - - ctx.moveTo(_x1, _y1); - ctx.lineTo(_x2, _y2); - ctx.lineTo(_x3, _y3); - ctx.lineTo(_x4, _y4); - ctx.lineTo(_x1, _y1); - } - } - } - return true; - } - - this.DrawSearchCur = function(overlay, xDst, yDst, wDst, hDst, navi) - { - var dKoefX = wDst / this.width_mm; - var dKoefY = hDst / this.height_mm; - - var places = navi.Place; - var len = places.length; - - var ctx = overlay.m_oContext; - - ctx.globalAlpha = 0.2; - ctx.fillStyle = "rgba(51,102,204,255)"; - - for (var i = 0; i < len; i++) - { - var place = places[i]; - if (undefined === place.Ex) - { - var _x = parseInt(xDst + dKoefX * place.X) - 0.5; - var _y = parseInt(yDst + dKoefY * place.Y) - 0.5; - - var _w = parseInt(dKoefX * place.W) + 1; - var _h = parseInt(dKoefY * place.H) + 1; - - if (_x < overlay.min_x) - overlay.min_x = _x; - if ((_x + _w) > overlay.max_x) - overlay.max_x = _x + _w; - - if (_y < overlay.min_y) - overlay.min_y = _y; - if ((_y + _h) > overlay.max_y) - overlay.max_y = _y + _h; - - ctx.rect(_x,_y,_w,_h); - } - else - { - var _x1 = parseInt(xDst + dKoefX * place.X); - var _y1 = parseInt(yDst + dKoefY * place.Y); - - var x2 = place.X + place.W * place.Ex; - var y2 = place.Y + place.W * place.Ey; - var _x2 = parseInt(xDst + dKoefX * x2); - var _y2 = parseInt(yDst + dKoefY * y2); - - var x3 = x2 - place.H * place.Ey; - var y3 = y2 + place.H * place.Ex; - var _x3 = parseInt(xDst + dKoefX * x3); - var _y3 = parseInt(yDst + dKoefY * y3); - - var x4 = place.X - place.H * place.Ey; - var y4 = place.Y + place.H * place.Ex; - var _x4 = parseInt(xDst + dKoefX * x4); - var _y4 = parseInt(yDst + dKoefY * y4); - - overlay.CheckPoint(_x1, _y1); - overlay.CheckPoint(_x2, _y2); - overlay.CheckPoint(_x3, _y3); - overlay.CheckPoint(_x4, _y4); - - ctx.moveTo(_x1, _y1); - ctx.lineTo(_x2, _y2); - ctx.lineTo(_x3, _y3); - ctx.lineTo(_x4, _y4); - ctx.lineTo(_x1, _y1); - } - } - - ctx.fill(); - ctx.globalAlpha = 1.0; - } - - this.DrawTableOutline = function(overlay, xDst, yDst, wDst, hDst, table_outline_dr) - { - var transform = table_outline_dr.TableMatrix; - if (null == transform || transform.IsIdentity2()) - { - var dKoefX = wDst / this.width_mm; - var dKoefY = hDst / this.height_mm; - - var _offX = (null == transform) ? 0 : transform.tx; - var _offY = (null == transform) ? 0 : transform.ty; - - var _x = 0; - var _y = 0; - switch (table_outline_dr.TrackTablePos) - { - case 1: - { - _x = parseInt(xDst + dKoefX * (table_outline_dr.TableOutline.X + table_outline_dr.TableOutline.W + _offX)); - _y = parseInt(yDst + dKoefY * (table_outline_dr.TableOutline.Y + _offY)) - 13; - break; - } - case 2: - { - _x = parseInt(xDst + dKoefX * (table_outline_dr.TableOutline.X + table_outline_dr.TableOutline.W + _offX)); - _y = parseInt(yDst + dKoefY * (table_outline_dr.TableOutline.Y + table_outline_dr.TableOutline.H + _offY)); - break; - } - case 3: - { - _x = parseInt(xDst + dKoefX * (table_outline_dr.TableOutline.X + _offX)) - 13; - _y = parseInt(yDst + dKoefY * (table_outline_dr.TableOutline.Y + table_outline_dr.TableOutline.H + _offY)); - break; - } - case 0: - default: - { - _x = parseInt(xDst + dKoefX * (table_outline_dr.TableOutline.X + _offX)) - 13; - _y = parseInt(yDst + dKoefY * (table_outline_dr.TableOutline.Y + _offY)) - 13; - break; - } - } - - var _w = 13; - var _h = 13; - - if (_x < overlay.min_x) - overlay.min_x = _x; - if ((_x + _w) > overlay.max_x) - overlay.max_x = _x + _w; - - if (_y < overlay.min_y) - overlay.min_y = _y; - if ((_y + _h) > overlay.max_y) - overlay.max_y = _y + _h; - - overlay.m_oContext.drawImage(table_outline_dr.image, _x, _y); - } - else - { - var ctx = overlay.m_oContext; - - - var _ft = new AscCommon.CMatrix(); - _ft.sx = transform.sx; - _ft.shx = transform.shx; - _ft.shy = transform.shy; - _ft.sy = transform.sy; - _ft.tx = transform.tx; - _ft.ty = transform.ty; - - var coords = new AscCommon.CMatrix(); - coords.sx = wDst / this.width_mm; - coords.sy = hDst / this.height_mm; - coords.tx = xDst; - coords.ty = yDst; - - AscCommon.global_MatrixTransformer.MultiplyAppend(_ft, coords); - - ctx.transform(_ft.sx,_ft.shy,_ft.shx,_ft.sy,_ft.tx,_ft.ty); - - var _x = 0; - var _y = 0; - var _w = 13 / coords.sx; - var _h = 13 / coords.sy; - switch (table_outline_dr.TrackTablePos) - { - case 1: - { - _x = (table_outline_dr.TableOutline.X + table_outline_dr.TableOutline.W); - _y = (table_outline_dr.TableOutline.Y - _h); - break; - } - case 2: - { - _x = (table_outline_dr.TableOutline.X + table_outline_dr.TableOutline.W); - _y = (table_outline_dr.TableOutline.Y + table_outline_dr.TableOutline.H); - break; - } - case 3: - { - _x = (table_outline_dr.TableOutline.X - _w); - _y = (table_outline_dr.TableOutline.Y + table_outline_dr.TableOutline.H); - break; - } - case 0: - default: - { - _x = (table_outline_dr.TableOutline.X - _w); - _y = (table_outline_dr.TableOutline.Y - _h); - break; - } - } - - overlay.CheckPoint(_ft.TransformPointX(_x, _y), _ft.TransformPointY(_x, _y)); - overlay.CheckPoint(_ft.TransformPointX(_x + _w, _y), _ft.TransformPointY(_x + _w, _y)); - overlay.CheckPoint(_ft.TransformPointX(_x + _w, _y + _h), _ft.TransformPointY(_x + _w, _y + _h)); - overlay.CheckPoint(_ft.TransformPointX(_x, _y + _h), _ft.TransformPointY(_x, _y + _h)); - - overlay.m_oContext.drawImage(table_outline_dr.image, _x, _y, _w, _h); - ctx.setTransform(1,0,0,1,0,0); - } - } -} - -function CDrawingDocument() -{ - this.Native = window["native"]; - this.Api = window.editor; - this.m_oApi = this.Api; - this.CanvasHitContext = CreateEmbedObject("CHitNativeEmbed"); - - this.IsLockObjectsEnable = false; - - this.m_oWordControl = null; - this.m_oLogicDocument = null; - this.m_oDocumentRenderer = null; - - this.m_arrPages = []; - this.m_lPagesCount = 0; - - this.m_lDrawingFirst = -1; - this.m_lDrawingEnd = -1; - this.m_lCurrentPage = -1; - - this.m_lCountCalculatePages = 0; - - this.m_lTimerTargetId = -1; - this.m_dTargetX = -1; - this.m_dTargetY = -1; - this.m_lTargetPage = -1; - this.m_dTargetSize = 1; - - this.NeedScrollToTarget = true; - this.NeedScrollToTargetFlag = false; - - this.TargetHtmlElement = null; - - this.m_bIsBreakRecalculate = false; - this.m_bIsUpdateDocSize = false; - - this.m_bIsSelection = false; - this.m_bIsSearching = false; - - this.CurrentSearchNavi = null; - this.SearchTransform = null; - - this.m_lTimerUpdateTargetID = -1; - this.m_tempX = 0; - this.m_tempY = 0; - this.m_tempPageIndex = 0; - - var oThis = this; - this.m_sLockedCursorType = ""; - this.TableOutlineDr = new CTableOutlineDr(); - - this.m_lCurrentRendererPage = -1; - this.m_oDocRenderer = null; - this.m_bOldShowMarks = false; - - this.UpdateTargetFromPaint = false; - this.UpdateTargetCheck = false; - this.NeedTarget = true; - this.TextMatrix = null; - this.TargetShowFlag = false; - this.TargetShowNeedFlag = false; - -// this.CanvasHit = document.createElement('canvas'); -// this.CanvasHit.width = 10; -// this.CanvasHit.height = 10; -// this.CanvasHitContext = this.CanvasHit.getContext('2d'); - - this.TargetCursorColor = {R: 0, G: 0, B: 0}; - - this.GuiControlColorsMap = null; - this.IsSendStandartColors = false; - - this.GuiCanvasFillTextureParentId = ""; - this.GuiCanvasFillTexture = null; - this.GuiCanvasFillTextureCtx = null; - this.LastDrawingUrl = ""; - - this.GuiCanvasFillTextureParentIdTextArt = ""; - this.GuiCanvasFillTextureTextArt = null; - this.GuiCanvasFillTextureCtxTextArt = null; - this.LastDrawingUrlTextArt = ""; - - this.GuiCanvasTextProps = null; - this.GuiLastTextProps = null; - - this.TableStylesLastLook = null; - this.LastParagraphMargins = null; - - this.AutoShapesTrack = null; - this.AutoShapesTrackLockPageNum = -1; - - this.Overlay = null; - this.IsTextMatrixUse = false; - - // массивы ректов для поиска - this._search_HdrFtr_All = []; // Поиск в колонтитуле, который находится на всех страницах - this._search_HdrFtr_All_no_First = []; // Поиск в колонтитуле, который находится на всех страницах, кроме первой - this._search_HdrFtr_First = []; // Поиск в колонтитуле, который находится только на первой странице - this._search_HdrFtr_Even = []; // Поиск в колонтитуле, который находится только на нечетных страницах - this._search_HdrFtr_Odd = []; // Поиск в колонтитуле, который находится только на четных страницах, включая первую - this._search_HdrFtr_Odd_no_First = []; // Поиск в колонтитуле, который находится только на нечетных страницах, кроме первой - - this.MathTrack = new AscCommon.CMathTrack(); - - this.getDrawingObjects = function() - { - var oWs = Asc.editor.wb.getWorksheet(); - if(oWs) { - return oWs.objectRender; - } - return null; - }; - - this.Start_CollaborationEditing = function() - { - this.IsLockObjectsEnable = true; - this.Native["DD_Start_CollaborationEditing"](); - }; - this.SetCursorType = function(sType, Data) - { - if ("" == this.m_sLockedCursorType) - this.Native["DD_SetCursorType"](sType, Data); - else - this.Native["DD_SetCursorType"](this.m_sLockedCursorType, Data); - }; - this.LockCursorType = function(sType) - { - this.m_sLockedCursorType = sType; - this.Native["DD_LockCursorType"](sType); - }; - this.LockCursorTypeCur = function() - { - this.m_sLockedCursorType = this.Native["DD_get_LockCursorType"](); - }; - this.UnlockCursorType = function() - { - this.m_sLockedCursorType = ""; - this.Native["DD_UnlockCursorType"](); - }; - - this.OnStartRecalculate = function(pageCount) - { - this.Native["DD_OnStartRecalculate"](pageCount); - }; - - this.OnRepaintPage = function(index) - { - this.Native["DD_OnRepaintPage"](index); - }; - - this.OnRecalculatePage = function(index, pageObject) - { - this.TableOutlineDr.TableOutline = null; - - this.Native["DD_OnRecalculatePage"](index, pageObject.Width, pageObject.Height, - pageObject.Margins.Left, pageObject.Margins.Top, pageObject.Margins.Right, pageObject.Margins.Bottom); - }; - - this.OnEndRecalculate = function(isFull, isBreak) - { - this.Native["DD_OnEndRecalculate"](isFull, isBreak); - }; - - this.ChangePageAttack = function(pageIndex) - { - }; - - this.StartRenderingPage = function(pageIndex) - { - }; - - this.IsFreezePage = function(pageIndex) - { - return this.Native["DD_IsFreezePage"](pageIndex); - }; - - this.RenderDocument = function(Renderer) - { - for (var i = 0; i < this.m_lPagesCount; i++) - { - var page = this.m_arrPages[i]; - Renderer.BeginPage(page.width_mm, page.height_mm); - this.m_oLogicDocument.DrawPage(i, Renderer); - Renderer.EndPage(); - } - }; - - this.ToRenderer = function() - { - var Renderer = new AscCommon.CDocumentRenderer(); - Renderer.VectorMemoryForPrint = new AscCommon.CMemory(); - var old_marks = this.m_oWordControl.m_oApi.ShowParaMarks; - this.m_oWordControl.m_oApi.ShowParaMarks = false; - this.RenderDocument(Renderer); - this.m_oWordControl.m_oApi.ShowParaMarks = old_marks; - var ret = Renderer.Memory.GetBase64Memory(); - //console.log(ret); - return ret; - }; - - this.ToRenderer2 = function() - { - var Renderer = new AscCommon.CDocumentRenderer(); - - var old_marks = this.m_oWordControl.m_oApi.ShowParaMarks; - this.m_oWordControl.m_oApi.ShowParaMarks = false; - - var ret = ""; - for (var i = 0; i < this.m_lPagesCount; i++) - { - var page = this.m_arrPages[i]; - Renderer.BeginPage(page.width_mm, page.height_mm); - this.m_oLogicDocument.DrawPage(i, Renderer); - Renderer.EndPage(); - - ret += Renderer.Memory.GetBase64Memory(); - Renderer.Memory.Seek(0); - } - - this.m_oWordControl.m_oApi.ShowParaMarks = old_marks; - //console.log(ret); - return ret; - }; - - this.isComleteRenderer = function() - { - var pagescount = Math.min(this.m_lPagesCount, this.m_lCountCalculatePages); - if (this.m_lCurrentRendererPage >= pagescount) - { - this.m_lCurrentRendererPage = -1; - this.m_oDocRenderer = null; - this.m_oWordControl.m_oApi.ShowParaMarks = this.m_bOldShowMarks; - return true; - } - return false; - }; - this.isComleteRenderer2 = function() - { - var pagescount = Math.min(this.m_lPagesCount, this.m_lCountCalculatePages); - var start = Math.max(this.m_lCurrentRendererPage, 0); - var end = Math.min(start + 50, pagescount - 1); - - if ((end + 1) >= pagescount) - return true; - - return false; - }; - this.ToRendererPart = function() - { - var pagescount = Math.min(this.m_lPagesCount, this.m_lCountCalculatePages); - - if (-1 == this.m_lCurrentRendererPage) - { - this.m_oDocRenderer = new AscCommon.CDocumentRenderer(); - this.m_oDocRenderer.VectorMemoryForPrint = new AscCommon.CMemory(); - this.m_lCurrentRendererPage = 0; - this.m_bOldShowMarks = this.m_oWordControl.m_oApi.ShowParaMarks; - this.m_oWordControl.m_oApi.ShowParaMarks = false; - } - - var start = this.m_lCurrentRendererPage; - var end = Math.min(this.m_lCurrentRendererPage + 50, pagescount - 1); - - var renderer = this.m_oDocRenderer; - renderer.Memory.Seek(0); - renderer.VectorMemoryForPrint.ClearNoAttack(); - - for (var i = start; i <= end; i++) - { - var page = this.m_arrPages[i]; - renderer.BeginPage(page.width_mm, page.height_mm); - this.m_oLogicDocument.DrawPage(i, renderer); - renderer.EndPage(); - - editor.async_SaveToPdf_Progress(parseInt((i + 1) * 100 / pagescount)); - } - - this.m_lCurrentRendererPage = end + 1; - - if (this.m_lCurrentRendererPage >= pagescount) - { - this.m_lCurrentRendererPage = -1; - this.m_oDocRenderer = null; - this.m_oWordControl.m_oApi.ShowParaMarks = this.m_bOldShowMarks; - } - - return renderer.Memory.GetBase64Memory(); - }; - - this.StopRenderingPage = function(pageIndex) - { - }; - - this.ClearCachePages = function() - { - this.Native["DD_ClearCachePages"](); - }; - - this.CheckRasterImageOnScreen = function(src) - { - if (null == this.m_oWordControl.m_oLogicDocument) - return; - - if (this.m_lDrawingFirst == -1 || this.m_lDrawingEnd == -1) - return; - - var bIsRaster = false; - var _checker = this.m_oWordControl.m_oLogicDocument.DrawingObjects; - for (var i = this.m_lDrawingFirst; i <= this.m_lDrawingEnd; i++) - { - var _imgs = _checker.getAllRasterImagesOnPage(i); - - var _len = _imgs.length; - for (var j = 0; j < _len; j++) - { - if (AscCommon.getFullImageSrc2(_imgs[j]) == src) - { - this.StopRenderingPage(i); - bIsRaster = true; - break; - } - } - } - - if (bIsRaster) - this.m_oWordControl.OnScroll(); - }; - - this.FirePaint = function() - { - this.Native["DD_FirePaint"](); - }; - - this.ConvertCoordsFromCursor = function(x, y, bIsRul) - { - var _x = x; - var _y = y; - - var dKoef = (100 * g_dKoef_pix_to_mm / this.m_oWordControl.m_nZoomValue); - - if (undefined == bIsRul) - { - var _xOffset = this.m_oWordControl.X; - var _yOffset = this.m_oWordControl.Y; - - /* - if (true == this.m_oWordControl.m_bIsRuler) - { - _xOffset += (5 * g_dKoef_mm_to_pix); - _yOffset += (7 * g_dKoef_mm_to_pix); - } - */ - - _x = x - _xOffset; - _y = y - _yOffset; - } - - for (var i = this.m_lDrawingFirst; i <= this.m_lDrawingEnd; i++) - { - var rect = this.m_arrPages[i].drawingPage; - - if ((rect.left <= _x) && (_x <= rect.right) && (rect.top <= _y) && (_y <= rect.bottom)) - { - var x_mm = (_x - rect.left) * dKoef; - var y_mm = (_y - rect.top) * dKoef; - - return { X : x_mm, Y : y_mm, Page: rect.pageIndex, DrawPage: i }; - } - } - - return { X : 0, Y : 0, Page: -1, DrawPage: -1 }; - }; - - this.ConvertCoordsFromCursorPage = function(x, y, page, bIsRul) - { - var _x = x - this.m_oWordControl.X; - var _y = y - this.m_oWordControl.Y; - - var dKoef = (100 * g_dKoef_pix_to_mm / this.m_oWordControl.m_nZoomValue); - - if (page < 0 || page >= this.m_lPagesCount) - return { X : 0, Y : 0, Page: -1, DrawPage: -1 }; - - var rect = this.m_arrPages[page].drawingPage; - var x_mm = (_x - rect.left) * dKoef; - var y_mm = (_y - rect.top) * dKoef; - - return { X : x_mm, Y : y_mm, Page: rect.pageIndex, DrawPage: i }; - }; - - this.ConvertCoordsToAnotherPage = function(x, y, pageCoord, pageNeed) - { - if (pageCoord < 0 || pageCoord >= this.m_lPagesCount || pageNeed < 0 || pageNeed >= this.m_lPagesCount) - return { X : 0, Y : 0, Error: true }; - - var dKoef1 = this.m_oWordControl.m_nZoomValue * g_dKoef_mm_to_pix / 100; - var dKoef2 = 100 * g_dKoef_pix_to_mm / this.m_oWordControl.m_nZoomValue; - - var page1 = this.m_arrPages[pageCoord].drawingPage; - var page2 = this.m_arrPages[pageNeed].drawingPage; - - var xCursor = page1.left + x * dKoef1; - var yCursor = page1.top + y * dKoef1; - - var _x = (xCursor - page2.left) * dKoef2; - var _y = (yCursor - page2.top) * dKoef2; - - return { X : _x, Y : _y, Error: false }; - }; - - this.ConvertCoordsFromCursor2 = function (x, y, zoomVal, isRulers) - { - var _x = x; - var _y = y; - - var dKoef = (100 * g_dKoef_pix_to_mm / this.m_oWordControl.m_nZoomValue); - if (undefined !== zoomVal) - dKoef = (100 * g_dKoef_pix_to_mm / zoomVal); - - if (true !== isRulers) - { - var _xOffset = this.m_oWordControl.X; - var _yOffset = this.m_oWordControl.Y; - - if (true === this.m_oWordControl.m_bIsRuler) - { - _xOffset += (5 * g_dKoef_mm_to_pix); - _yOffset += (7 * g_dKoef_mm_to_pix); - } - - _x = x - _xOffset; - _y = y - _yOffset; - } - - if (-1 == this.m_lDrawingFirst || -1 == this.m_lDrawingEnd) - return { X : 0, Y : 0, Page: -1, DrawPage: -1 }; - - for (var i = this.m_lDrawingFirst; i <= this.m_lDrawingEnd; i++) - { - var rect = this.m_arrPages[i].drawingPage; - - if ((rect.left <= _x) && (_x <= rect.right) && (rect.top <= _y) && (_y <= rect.bottom)) - { - var x_mm = (_x - rect.left) * dKoef; - var y_mm = (_y - rect.top) * dKoef; - - if (x_mm > (this.m_arrPages[i].width_mm + 10)) - x_mm = this.m_arrPages[i].width_mm + 10; - if (x_mm < -10) - x_mm = -10; - - return { X : x_mm, Y : y_mm, Page: rect.pageIndex, DrawPage: i }; - } - } - - // в страницу не попали. вторая попытка - это попробовать найти страницу по вертикали - var _start = Math.max(this.m_lDrawingFirst - 1, 0); - var _end = Math.min(this.m_lDrawingEnd + 1, this.m_lPagesCount - 1); - for (var i = _start; i <= _end; i++) - { - var rect = this.m_arrPages[i].drawingPage; - - var bIsCurrent = false; - if (i == this.m_lDrawingFirst && rect.top > _y) - { - bIsCurrent = true; - } - else if ((rect.top <= _y) && (_y <= rect.bottom)) - { - bIsCurrent = true; - } - else if (i != this.m_lPagesCount - 1) - { - if (_y > rect.bottom && _y < this.m_arrPages[i+1].drawingPage.top) - bIsCurrent = true; - } - else if (_y < rect.top) - { - // либо вышли раньше, либо это самая первая видимая страница - bIsCurrent = true; - } - else if (i == this.m_lDrawingEnd) - { - if (_y > rect.bottom) - bIsCurrent = true; - } - - if (bIsCurrent) - { - var x_mm = (_x - rect.left) * dKoef; - var y_mm = (_y - rect.top) * dKoef; - - return { X : x_mm, Y : y_mm, Page: rect.pageIndex, DrawPage: i }; - } - } - - return { X : 0, Y : 0, Page: -1, DrawPage: -1 }; - }; - - this.ConvetToPageCoords = function(x,y,pageIndex) - { - if (pageIndex < 0 || pageIndex >= this.m_lPagesCount) - { - return { X : 0, Y : 0, Page : pageIndex, Error: true }; - } - var dKoef = (100 * g_dKoef_pix_to_mm / this.m_oWordControl.m_nZoomValue); - var rect = this.m_arrPages[pageIndex].drawingPage; - - var _x = (x - rect.left) * dKoef; - var _y = (y - rect.top) * dKoef; - - return { X : _x, Y : _y, Page : pageIndex, Error: false }; - }; - - this.IsCursorInTableCur = function(x, y, page) - { - var _table = this.TableOutlineDr.TableOutline; - if (_table == null) - return false; - - if (page != _table.PageNum) - return false; - - var _dist = this.TableOutlineDr.mover_size * g_dKoef_pix_to_mm; - _dist *= (100 / this.m_oWordControl.m_nZoomValue); - - var _x = _table.X; - var _y = _table.Y; - var _r = _x + _table.W; - var _b = _y + _table.H; - - if ((x > (_x - _dist)) && (x < _r) && (y > (_y - _dist)) && (y < _b)) - { - if ((x < _x) || (y < _y)) - { - this.TableOutlineDr.Counter = 0; - this.TableOutlineDr.bIsNoTable = false; - return true; - } - } - return false; - }; - - this.ConvertCoordsToCursorWR = function(x, y, pageIndex, transform) - { - return {X: 0, Y: 0, Error: false}; - -// var dKoef = (this.m_oWordControl.m_nZoomValue * g_dKoef_mm_to_pix / 100); -// -// var _x = 0; -// var _y = 0; -// if (true == this.m_oWordControl.m_bIsRuler) -// { -// _x = 5 * g_dKoef_mm_to_pix; -// _y = 7 * g_dKoef_mm_to_pix; -// } -// -// // теперь крутить всякие циклы нет смысла -// if (pageIndex < 0 || pageIndex >= this.m_lPagesCount) -// { -// return { X : 0, Y : 0, Error: true }; -// } -// -// var __x = x; -// var __y = y; -// if (transform) -// { -// __x = transform.TransformPointX(x, y); -// __y = transform.TransformPointY(x, y); -// } -// -// var x_pix = parseInt(this.m_arrPages[pageIndex].drawingPage.left + __x * dKoef + _x); -// var y_pix = parseInt(this.m_arrPages[pageIndex].drawingPage.top + __y * dKoef + _y); -// -// return { X : x_pix, Y : y_pix, Error: false }; - }; - - this.ConvertCoordsToCursor = function(x, y, pageIndex, bIsRul) - { -// var dKoef = (this.m_oWordControl.m_nZoomValue * g_dKoef_mm_to_pix / 100); -// -// var _x = 0; -// var _y = 0; -// if (true == this.m_oWordControl.m_bIsRuler) -// { -// if (undefined == bIsRul) -// { -// //_x = 5 * g_dKoef_mm_to_pix; -// //_y = 7 * g_dKoef_mm_to_pix; -// } -// } -// -// // теперь крутить всякие циклы нет смысла -// if (pageIndex < 0 || pageIndex >= this.m_lPagesCount) -// { -// return { X : 0, Y : 0, Error: true }; -// } -// -// var x_pix = parseInt(this.m_arrPages[pageIndex].drawingPage.left + x * dKoef + _x); -// var y_pix = parseInt(this.m_arrPages[pageIndex].drawingPage.top + y * dKoef + _y); -// -// return { X : x_pix, Y : y_pix, Error: false }; -// -// // old version -// for (var i = this.m_lDrawingFirst; i <= this.m_lDrawingEnd; i++) -// { -// var rect = this.m_arrPages[i].drawingPage; -// -// if (this.m_arrPages[i].pageIndex == pageIndex) -// { -// var x_pix = parseInt(rect.left + x * dKoef + _x); -// var y_pix = parseInt(rect.top + y * dKoef + _y); -// -// return { X : x_pix, Y : y_pix, Error: false }; -// } -// } - - return { X : 0, Y : 0, Error: true }; - }; - this.ConvertCoordsToCursor2 = function(x, y, pageIndex, bIsRul) - { - return {X: 0, Y: 0, Error: false}; - -// var dKoef = (this.m_oWordControl.m_nZoomValue * g_dKoef_mm_to_pix / 100); -// -// var _x = 0; -// var _y = 0; -// if (true == this.m_oWordControl.m_bIsRuler) -// { -// if (undefined == bIsRul) -// { -// //_x = 5 * g_dKoef_mm_to_pix; -// //_y = 7 * g_dKoef_mm_to_pix; -// } -// } -// -// // теперь крутить всякие циклы нет смысла -// if (pageIndex < 0 || pageIndex >= this.m_lPagesCount) -// { -// return { X : 0, Y : 0, Error: true }; -// } -// -// var x_pix = parseInt(this.m_arrPages[pageIndex].drawingPage.left + x * dKoef + _x - 0.5); -// var y_pix = parseInt(this.m_arrPages[pageIndex].drawingPage.top + y * dKoef + _y - 0.5); -// -// return { X : x_pix, Y : y_pix, Error: false }; - }; - this.ConvertCoordsToCursor3 = function(x, y, pageIndex) - { - return {X: 0, Y: 0, Error: false}; - //var _return = this.Native["DD_ConvertCoordsToAnotherPage"](x, y, pageCoord, pageNeed); - //return { X : _return[0], Y : _return[1], Error : _return[2] }; - -// // теперь крутить всякие циклы нет смысла -// if (pageIndex < 0 || pageIndex >= this.m_lPagesCount) -// { -// return { X : 0, Y : 0, Error: true }; -// } -// -// var dKoef = (this.m_oWordControl.m_nZoomValue * g_dKoef_mm_to_pix / 100); -// -// var _x = this.m_oWordControl.X; -// var _y = this.m_oWordControl.Y; -// -// var x_pix = parseInt(this.m_arrPages[pageIndex].drawingPage.left + x * dKoef + _x + 0.5); -// var y_pix = parseInt(this.m_arrPages[pageIndex].drawingPage.top + y * dKoef + _y + 0.5); -// -// return { X : x_pix, Y : y_pix, Error: false }; - }; - - this.InitViewer = function() - { - }; - - this.TargetStart = function() - { - this.Native["DD_TargetStart"](); - }; - this.TargetEnd = function() - { - this.TargetShowFlag = false; - this.TargetShowNeedFlag = false; - this.Native["DD_TargetEnd"](); - }; - this.UpdateTargetNoAttack = function() - { - if (null == this.m_oWordControl) - return; - - this.CheckTargetDraw(this.m_dTargetX, this.m_dTargetY); - }; - - this.GetTargetStyle = function() - { - return "rgb(" + this.TargetCursorColor.R + "," + this.TargetCursorColor.G + "," + this.TargetCursorColor.B + ")"; - }; - - this.SetTargetColor = function(r, g, b) - { - this.Native["DD_SetTargetColor"](r, g, b); - }; - - this.CheckTargetDraw = function(x, y) - { - //TODO: - -// var _oldW = this.TargetHtmlElement.width; -// var _oldH = this.TargetHtmlElement.height; -// -// var dKoef = this.drawingObjects.convertMetric(1, 3, 0); -// -// var _newW = 2; -// var _newH = this.m_dTargetSize * dKoef; -// -// var _offX = 0; -// var _offY = 0; -// if (this.AutoShapesTrack && this.AutoShapesTrack.Graphics && this.AutoShapesTrack.Graphics.m_oCoordTransform) -// { -// _offX = this.AutoShapesTrack.Graphics.m_oCoordTransform.tx; -// _offY = this.AutoShapesTrack.Graphics.m_oCoordTransform.ty; -// } -// -// var _factor = AscBrowser.isRetina ? 1 : 0; -// -// if (null != this.TextMatrix && !global_MatrixTransformer.IsIdentity2(this.TextMatrix)) -// { -// var _x1 = this.TextMatrix.TransformPointX(x, y); -// var _y1 = this.TextMatrix.TransformPointY(x, y); -// -// var _x2 = this.TextMatrix.TransformPointX(x, y + this.m_dTargetSize); -// var _y2 = this.TextMatrix.TransformPointY(x, y + this.m_dTargetSize); -// -// var pos1 = { X : _offX + dKoef * _x1, Y : _offY + dKoef * _y1 }; -// var pos2 = { X : _offX + dKoef * _x2, Y : _offY + dKoef * _y2 }; -// -// _newW = (((Math.abs(pos1.X - pos2.X) >> 0) + 1) >> 1) << 1; -// _newH = (((Math.abs(pos1.Y - pos2.Y) >> 0) + 1) >> 1) << 1; -// -// if (2 > _newW) -// _newW = 2; -// if (2 > _newH) -// _newH = 2; -// -// if (_oldW == _newW && _oldH == _newH) -// { -// // просто очищаем -// this.TargetHtmlElement.width = _newW; -// } -// else -// { -// this.TargetHtmlElement.style.width = (_newW >> _factor) + "px"; -// this.TargetHtmlElement.style.height = (_newH >> _factor) + "px"; -// -// this.TargetHtmlElement.width = _newW; -// this.TargetHtmlElement.height = _newH; -// } -// var ctx = this.TargetHtmlElement.getContext('2d'); -// -// if (_newW == 2 || _newH == 2) -// { -// ctx.fillStyle = this.GetTargetStyle(); -// ctx.fillRect(0, 0, _newW, _newH); -// } -// else -// { -// ctx.beginPath(); -// ctx.strokeStyle = this.GetTargetStyle(); -// ctx.lineWidth = 2; -// -// if (((pos1.X - pos2.X)*(pos1.Y - pos2.Y)) >= 0) -// { -// ctx.moveTo(0, 0); -// ctx.lineTo(_newW, _newH); -// } -// else -// { -// ctx.moveTo(0, _newH); -// ctx.lineTo(_newW, 0); -// } -// -// ctx.stroke(); -// } -// -// this.TargetHtmlElement.style.left = (Math.min(pos1.X, pos2.X) >> _factor) + "px"; -// this.TargetHtmlElement.style.top = (Math.min(pos1.Y, pos2.Y) >> _factor) + "px"; -// } -// else -// { -// if (_oldW == _newW && _oldH == _newH) -// { -// // просто очищаем -// this.TargetHtmlElement.width = _newW; -// } -// else -// { -// this.TargetHtmlElement.style.width = (_newW >> _factor) + "px"; -// this.TargetHtmlElement.style.height = (_newH >> _factor) + "px"; -// -// this.TargetHtmlElement.width = _newW; -// this.TargetHtmlElement.height = _newH; -// } -// -// var ctx = this.TargetHtmlElement.getContext('2d'); -// -// ctx.fillStyle = this.GetTargetStyle(); -// ctx.fillRect(0, 0, _newW, _newH); -// -// if (null != this.TextMatrix) -// { -// x += this.TextMatrix.tx; -// y += this.TextMatrix.ty; -// } -// -// var pos = { X : _offX + dKoef * x, Y : _offY + dKoef * y }; -// -// this.TargetHtmlElement.style.left = (pos.X >> _factor) + "px"; -// this.TargetHtmlElement.style.top = (pos.Y >> _factor) + "px"; -// } - }; - - this.UpdateTargetTransform = function(matrix) - { - if (matrix) - { - if (null == this.TextMatrix) - this.TextMatrix = new AscCommon.CMatrix(); - this.TextMatrix.sx = matrix.sx; - this.TextMatrix.shy = matrix.shy; - this.TextMatrix.shx = matrix.shx; - this.TextMatrix.sy = matrix.sy; - this.TextMatrix.tx = matrix.tx; - this.TextMatrix.ty = matrix.ty; - - this.Native["DD_UpdateTargetTransform"](matrix.sx, matrix.shy, matrix.shx, matrix.sy, matrix.tx, matrix.ty); - } - else - { - this.TextMatrix = null; - this.Native["DD_RemoveTargetTransform"](); - } - }; - - this.UpdateTarget = function(x, y, pageIndex) - { - this.m_dTargetX = x; - this.m_dTargetY = y; - this.m_lTargetPage = pageIndex; - - this.Native["DD_UpdateTarget"](x, y, pageIndex); - - this.CheckTargetDraw(x, y); - }; - - this.UpdateTargetTimer = function() {}; - - this.SetTargetSize = function(size) - { - this.m_dTargetSize = size; - this.Native["DD_SetTargetSize"](size); - }; - this.DrawTarget = function() {}; - - this.TargetShow = function() - { - this.TargetShowNeedFlag = true; - this.Native["DD_TargetShow"](); - }; - this.CheckTargetShow = function() {}; - this.StartTrackImage = function(obj, x, y, w, h, type, pagenum) - { - }; - this.StartTrackTable = function(obj, transform) - { - //TODO: -// if (this.m_oWordControl.MobileTouchManager) -// { -// if (!this.m_oWordControl.MobileTouchManager.TableStartTrack_Check) -// return; -// } -// -// this.TableOutlineDr.TableOutline = obj; -// this.TableOutlineDr.Counter = 0; -// this.TableOutlineDr.bIsNoTable = false; -// this.TableOutlineDr.CheckStartTrack(this.m_oWordControl, transform); -// -// if (this.m_oWordControl.MobileTouchManager) -// this.m_oWordControl.OnUpdateOverlay(); - }; - this.EndTrackTable = function(pointer, bIsAttack) - { - if (this.TableOutlineDr.TableOutline != null) - { - if (pointer == this.TableOutlineDr.TableOutline.Table || bIsAttack) - { - this.TableOutlineDr.TableOutline = null; - this.TableOutlineDr.Counter = 0; - } - } - }; - this.CheckTrackTable = function() - { - if (null == this.TableOutlineDr.TableOutline) - return; - - if (this.TableOutlineDr.bIsNoTable && this.TableOutlineDr.bIsTracked === false) - { - this.TableOutlineDr.Counter++; - if (this.TableOutlineDr.Counter > 100) - { - this.TableOutlineDr.TableOutline = null; - this.m_oWordControl.OnUpdateOverlay(); - } - } - }; - this.DrawTableTrack = function(overlay) - { - //TODO: -// if (null == this.TableOutlineDr.TableOutline) -// return; -// -// var _table = this.TableOutlineDr.TableOutline.Table; -// -// if (!_table.Is_Inline()) -// { -// if (null == this.TableOutlineDr.CurPos) -// return; -// -// var _page = this.m_arrPages[this.TableOutlineDr.CurPos.Page]; -// var drPage = _page.drawingPage; -// -// var dKoefX = (drPage.right - drPage.left) / _page.width_mm; -// var dKoefY = (drPage.bottom - drPage.top) / _page.height_mm; -// -// if (!this.TableOutlineDr.TableMatrix || global_MatrixTransformer.IsIdentity(this.TableOutlineDr.TableMatrix)) -// { -// var _x = parseInt(drPage.left + dKoefX * (this.TableOutlineDr.CurPos.X + _table.GetTableOffsetCorrection())) + 0.5; -// var _y = parseInt(drPage.top + dKoefY * this.TableOutlineDr.CurPos.Y) + 0.5; -// -// var _r = _x + parseInt(dKoefX * this.TableOutlineDr.TableOutline.W); -// var _b = _y + parseInt(dKoefY * this.TableOutlineDr.TableOutline.H); -// -// if (_x < overlay.min_x) -// overlay.min_x = _x; -// if (_r > overlay.max_x) -// overlay.max_x = _r; -// -// if (_y < overlay.min_y) -// overlay.min_y = _y; -// if (_b > overlay.max_y) -// overlay.max_y = _b; -// -// var ctx = overlay.m_oContext; -// ctx.strokeStyle = "#FFFFFF"; -// -// ctx.beginPath(); -// ctx.rect(_x, _y, _r - _x, _b - _y); -// ctx.stroke(); -// -// ctx.strokeStyle = "#000000"; -// ctx.beginPath(); -// -// // набиваем пунктир -// var dot_size = 3; -// for (var i = _x; i < _r; i += dot_size) -// { -// ctx.moveTo(i, _y); -// i += dot_size; -// -// if (i > _r) -// i = _r; -// -// ctx.lineTo(i, _y); -// } -// for (var i = _y; i < _b; i += dot_size) -// { -// ctx.moveTo(_r, i); -// i += dot_size; -// -// if (i > _b) -// i = _b; -// -// ctx.lineTo(_r, i); -// } -// for (var i = _r; i > _x; i -= dot_size) -// { -// ctx.moveTo(i, _b); -// i -= dot_size; -// -// if (i < _x) -// i = _x; -// -// ctx.lineTo(i, _b); -// } -// for (var i = _b; i > _y; i -= dot_size) -// { -// ctx.moveTo(_x, i); -// i -= dot_size; -// -// if (i < _y) -// i = _y; -// -// ctx.lineTo(_x, i); -// } -// -// ctx.stroke(); -// ctx.beginPath(); -// } -// else -// { -// var _x = this.TableOutlineDr.CurPos.X + _table.GetTableOffsetCorrection(); -// var _y = this.TableOutlineDr.CurPos.Y; -// var _r = _x + this.TableOutlineDr.TableOutline.W; -// var _b = _y + this.TableOutlineDr.TableOutline.H; -// -// var transform = this.TableOutlineDr.TableMatrix; -// -// var x1 = transform.TransformPointX(_x, _y); -// var y1 = transform.TransformPointY(_x, _y); -// -// var x2 = transform.TransformPointX(_r, _y); -// var y2 = transform.TransformPointY(_r, _y); -// -// var x3 = transform.TransformPointX(_r, _b); -// var y3 = transform.TransformPointY(_r, _b); -// -// var x4 = transform.TransformPointX(_x, _b); -// var y4 = transform.TransformPointY(_x, _b); -// -// overlay.CheckPoint(x1, y1); -// overlay.CheckPoint(x2, y2); -// overlay.CheckPoint(x3, y3); -// overlay.CheckPoint(x4, y4); -// -// var ctx = overlay.m_oContext; -// ctx.strokeStyle = "#FFFFFF"; -// -// ctx.beginPath(); -// ctx.moveTo(x1, y1); -// ctx.lineTo(x2, y2); -// ctx.lineTo(x3, y3); -// ctx.lineTo(x4, y4); -// ctx.closePath(); -// ctx.stroke(); -// -// ctx.strokeStyle = "#000000"; -// ctx.beginPath(); -// -// this.AutoShapesTrack.AddRectDash(ctx, x1, y1, x2, y2, x4, y4, x3, y3, 3, 3); -// -// ctx.stroke(); -// ctx.beginPath(); -// } -// } -// else -// { -// this.LockCursorType("default"); -// -// var _x = global_mouseEvent.X; -// var _y = global_mouseEvent.Y; -// var posMouse = this.ConvertCoordsFromCursor2(_x, _y); -// -// this.TableOutlineDr.InlinePos = this.m_oWordControl.m_oLogicDocument.Get_NearestPos(posMouse.Page, posMouse.X, posMouse.Y); -// this.TableOutlineDr.InlinePos.Page = posMouse.Page; -// //var posView = this.ConvertCoordsToCursor(this.TableOutlineDr.InlinePos.X, this.TableOutlineDr.InlinePos.Y, posMouse.Page, true); -// -// var _near = this.TableOutlineDr.InlinePos; -// this.AutoShapesTrack.SetCurrentPage(_near.Page); -// this.AutoShapesTrack.DrawInlineMoveCursor(_near.X, _near.Y, _near.Height, _near.transform); -// } - }; - - this.DrawMathTrack = function (overlay) - { - //TODO: Implement - }; - this.SetCurrentPage = function(PageIndex) - { - this.m_lCurrentPage = this.Native["DD_SetCurrentPage"](PageIndex); - -// if (PageIndex >= this.m_arrPages.length) -// return; -// if (this.m_lCurrentPage == PageIndex) -// return; -// -// this.m_lCurrentPage = PageIndex; -// this.m_oWordControl.SetCurrentPage(); - }; - - this.SelectEnabled = function(bIsEnabled) - { - this.m_bIsSelection = bIsEnabled; - if (false === this.m_bIsSelection) - { - this.SelectClear(); -// //this.m_oWordControl.CheckUnShowOverlay(); -// //this.drawingObjects.OnUpdateOverlay(); -// this.drawingObjects.getOverlay().m_oContext.globalAlpha = 1.0; - } - }; - this.SelectClear = function() - { - this.Native["DD_SelectClear"](); - }; - this.SearchClear = function() - { - //TODO: -// for (var i = 0; i < this.m_lPagesCount; i++) -// { -// this.m_arrPages[i].searchingArray.splice(0, this.m_arrPages[i].searchingArray.length); -// } -// -// this._search_HdrFtr_All.splice(0, this._search_HdrFtr_All.length); -// this._search_HdrFtr_All_no_First.splice(0, this._search_HdrFtr_All_no_First.length); -// this._search_HdrFtr_First.splice(0, this._search_HdrFtr_First.length); -// this._search_HdrFtr_Even.splice(0, this._search_HdrFtr_Even.length); -// this._search_HdrFtr_Odd.splice(0, this._search_HdrFtr_Odd.length); -// this._search_HdrFtr_Odd_no_First.splice(0, this._search_HdrFtr_Odd_no_First.length); -// -// this.m_oWordControl.m_oOverlayApi.Clear(); -// this.m_bIsSearching = false; -// this.CurrentSearchNavi = null; - }; - this.AddPageSearch = function(findText, rects, type) - { - //TODO: - -// var _len = rects.length; -// if (_len == 0) -// return; -// -// if (this.m_oWordControl.m_oOverlay.HtmlElement.style.display == "none") -// { -// this.m_oWordControl.ShowOverlay(); -// this.m_oWordControl.m_oOverlayApi.m_oContext.globalAlpha = 0.2; -// } -// -// var navigator = { Page : rects[0].PageNum, Place : rects, Type : type }; -// -// var _find = { text: findText, navigator : navigator }; -// this.m_oWordControl.m_oApi.sync_SearchFoundCallback(_find); -// -// var is_update = false; -// -// var _type = type & 0x00FF; -// switch (_type) -// { -// case search_Common: -// { -// var _pages = this.m_arrPages; -// for (var i = 0; i < _len; i++) -// { -// var r = rects[i]; -// -// if (this.SearchTransform) -// r.Transform = this.SearchTransform; -// -// _pages[r.PageNum].searchingArray[_pages[r.PageNum].searchingArray.length] = r; -// -// if (r.PageNum >= this.m_lDrawingFirst && r.PageNum <= this.m_lDrawingEnd) -// is_update = true; -// } -// break; -// } -// case search_HdrFtr_All: -// { -// for (var i = 0; i < _len; i++) -// { -// if (this.SearchTransform) -// rects[i].Transform = this.SearchTransform; -// -// this._search_HdrFtr_All[this._search_HdrFtr_All.length] = rects[i]; -// } -// is_update = true; -// -// break; -// } -// case search_HdrFtr_All_no_First: -// { -// for (var i = 0; i < _len; i++) -// { -// if (this.SearchTransform) -// rects[i].Transform = this.SearchTransform; -// -// this._search_HdrFtr_All_no_First[this._search_HdrFtr_All_no_First.length] = rects[i]; -// } -// if (this.m_lDrawingEnd > 0) -// is_update = true; -// -// break; -// } -// case search_HdrFtr_First: -// { -// for (var i = 0; i < _len; i++) -// { -// if (this.SearchTransform) -// rects[i].Transform = this.SearchTransform; -// -// this._search_HdrFtr_First[this._search_HdrFtr_First.length] = rects[i]; -// } -// if (this.m_lDrawingFirst == 0) -// is_update = true; -// -// break; -// } -// case search_HdrFtr_Even: -// { -// for (var i = 0; i < _len; i++) -// { -// if (this.SearchTransform) -// rects[i].Transform = this.SearchTransform; -// -// this._search_HdrFtr_Even[this._search_HdrFtr_Even.length] = rects[i]; -// } -// var __c = this.m_lDrawingEnd - this.m_lDrawingFirst; -// -// if (__c > 1) -// is_update = true; -// else if (__c == 1 && (this.m_lDrawingFirst & 1) == 1) -// is_update = true; -// -// break; -// } -// case search_HdrFtr_Odd: -// { -// for (var i = 0; i < _len; i++) -// { -// if (this.SearchTransform) -// rects[i].Transform = this.SearchTransform; -// -// this._search_HdrFtr_Odd[this._search_HdrFtr_Odd.length] = rects[i]; -// } -// var __c = this.m_lDrawingEnd - this.m_lDrawingFirst; -// -// if (__c > 1) -// is_update = true; -// else if (__c == 1 && (this.m_lDrawingFirst & 1) == 0) -// is_update = true; -// -// break; -// } -// case search_HdrFtr_Odd_no_First: -// { -// for (var i = 0; i < _len; i++) -// { -// if (this.SearchTransform) -// rects[i].Transform = this.SearchTransform; -// -// this._search_HdrFtr_Odd_no_First[this._search_HdrFtr_Odd_no_First.length] = rects[i]; -// } -// -// if (this.m_lDrawingEnd > 1) -// { -// var __c = this.m_lDrawingEnd - this.m_lDrawingFirst; -// if (__c > 1) -// is_update = true; -// else if (__c == 1 && (this.m_lDrawingFirst & 1) == 0) -// is_update = true; -// } -// -// break; -// } -// default: -// break; -// } -// -// if (is_update) -// this.drawingObjects.OnUpdateOverlay(); - - }; - - this.StartSearchTransform = function(transform) - { - //TODO: - //this.SearchTransform = transform.CreateDublicate(); - }; - - this.EndSearchTransform = function() - { - //TODO: - // this.SearchTransform = null; - }; - - this.StartSearch = function() - { - //TODO: -// this.SearchClear(); -// if (this.m_bIsSelection) -// this.m_oWordControl.OnUpdateOverlay(); -// this.m_bIsSearching = true; -// this.CurrentSearchNavi = null; - }; - this.EndSearch = function(bIsChange) - { - //TODO: - -// if (bIsChange) -// { -// this.SearchClear(); -// this.m_bIsSearching = false; -// this.m_oWordControl.OnUpdateOverlay(); -// } -// else -// { -// this.m_bIsSearching = true; -// this.m_oWordControl.OnUpdateOverlay(); -// } -// this.m_oWordControl.m_oApi.sync_SearchEndCallback(); - }; - - this.private_StartDrawSelection = function(overlay) - { - this.Native["DD_StartDrawSelection"](); - - // this.Overlay = overlay; -// this.IsTextMatrixUse = ((null != this.TextMatrix) && !global_MatrixTransformer.IsIdentity(this.TextMatrix)); -// -// this.Overlay.m_oContext.fillStyle = "rgba(51,102,204,255)"; -// this.Overlay.m_oContext.beginPath(); -// -// if (this.IsTextMatrixUse) -// this.Overlay.m_oContext.strokeStyle = "#9ADBFE"; - }; - this.private_EndDrawSelection = function() - { - this.Native["DD_EndDrawSelection"](); - - //TODO: -// var ctx = this.Overlay.m_oContext; -// -// ctx.globalAlpha = 0.2; -// ctx.fill(); -// -// if (this.IsTextMatrixUse) -// { -// ctx.globalAlpha = 1.0; -// ctx.stroke(); -// } -// -// ctx.beginPath(); -// ctx.globalAlpha = 1.0; -// -// this.IsTextMatrixUse = false; -// this.Overlay = null; - }; - - this.AddPageSelection = function(pageIndex, x, y, w, h) - { - this.Native["DD_AddPageSelection"](pageIndex, x, y, w, h); - }; - - this.SelectShow = function() - { - var drawingObjects = this.getDrawingObjects(); - if(!drawingObjects) { - return; - } - drawingObjects.OnUpdateOverlay(); - }; - - this.Set_RulerState_Table = function(markup, transform) - { - //TODO: - -// var hor_ruler = this.m_oWordControl.m_oHorRuler; -// var ver_ruler = this.m_oWordControl.m_oVerRuler; -// -// hor_ruler.CurrentObjectType = RULER_OBJECT_TYPE_TABLE; -// hor_ruler.m_oTableMarkup = markup.CreateDublicate(); -// -// ver_ruler.CurrentObjectType = RULER_OBJECT_TYPE_TABLE; -// ver_ruler.m_oTableMarkup = markup.CreateDublicate(); -// -// this.TableOutlineDr.TableMatrix = null; -// this.TableOutlineDr.CurrentPageIndex = this.m_lCurrentPage; -// if (transform) -// { -// hor_ruler.m_oTableMarkup.TransformX = transform.tx; -// hor_ruler.m_oTableMarkup.TransformY = transform.ty; -// -// ver_ruler.m_oTableMarkup.TransformX = transform.tx; -// ver_ruler.m_oTableMarkup.TransformY = transform.ty; -// -// hor_ruler.m_oTableMarkup.CorrectFrom(); -// ver_ruler.m_oTableMarkup.CorrectFrom(); -// -// this.TableOutlineDr.TableMatrix = transform.CreateDublicate(); -// } -// -// hor_ruler.CalculateMargins(); -// -// if (0 <= this.m_lCurrentPage && this.m_lCurrentPage < this.m_lPagesCount) -// { -// hor_ruler.CreateBackground(this.m_arrPages[this.m_lCurrentPage]); -// ver_ruler.CreateBackground(this.m_arrPages[this.m_lCurrentPage]); -// } -// -// this.m_oWordControl.UpdateHorRuler(); -// this.m_oWordControl.UpdateVerRuler(); -// -// if (this.m_oWordControl.MobileTouchManager) -// { -// this.m_oWordControl.MobileTouchManager.TableStartTrack_Check = true; -// markup.Table.StartTrackTable(); -// this.m_oWordControl.MobileTouchManager.TableStartTrack_Check = false; -// } - }; - - this.Set_RulerState_Paragraph = function(margins) - { - //TODO: -// var hor_ruler = this.m_oWordControl.m_oHorRuler; -// var ver_ruler = this.m_oWordControl.m_oVerRuler; -// -// if (hor_ruler.CurrentObjectType == RULER_OBJECT_TYPE_PARAGRAPH && ver_ruler.CurrentObjectType == RULER_OBJECT_TYPE_PARAGRAPH) -// { -// if ((margins && !hor_ruler.IsCanMoveMargins) || (!margins && hor_ruler.IsCanMoveMargins)) -// { -// var bIsNeedUpdate = false; -// if (margins && this.LastParagraphMargins) -// { -// if (margins.L != this.LastParagraphMargins.L || -// margins.T != this.LastParagraphMargins.T || -// margins.R != this.LastParagraphMargins.R || -// margins.B != this.LastParagraphMargins.B) -// { -// bIsNeedUpdate = true; -// } -// } -// -// if (!bIsNeedUpdate) -// return; -// } -// } -// -// hor_ruler.CurrentObjectType = RULER_OBJECT_TYPE_PARAGRAPH; -// hor_ruler.m_oTableMarkup = null; -// -// ver_ruler.CurrentObjectType = RULER_OBJECT_TYPE_PARAGRAPH; -// ver_ruler.m_oTableMarkup = null; -// -// // вообще надо посмотреть... может и был параграф до этого. -// // тогда вэкграунд перерисовывать не нужно. Только надо знать, на той же странице это было или нет -// if (-1 != this.m_lCurrentPage) -// { -// if (margins) -// { -// var cachedPage = {}; -// cachedPage.width_mm = this.m_arrPages[this.m_lCurrentPage].width_mm; -// cachedPage.height_mm = this.m_arrPages[this.m_lCurrentPage].height_mm; -// -// cachedPage.margin_left = margins.L; -// cachedPage.margin_top = margins.T; -// cachedPage.margin_right = margins.R; -// cachedPage.margin_bottom = margins.B; -// -// hor_ruler.CreateBackground(cachedPage); -// ver_ruler.CreateBackground(cachedPage); -// -// // disable margins -// hor_ruler.IsCanMoveMargins = false; -// ver_ruler.IsCanMoveMargins = false; -// -// this.LastParagraphMargins = {}; -// this.LastParagraphMargins.L = margins.L; -// this.LastParagraphMargins.T = margins.T; -// this.LastParagraphMargins.R = margins.R; -// this.LastParagraphMargins.B = margins.B; -// } -// else -// { -// hor_ruler.CreateBackground(this.m_arrPages[this.m_lCurrentPage]); -// ver_ruler.CreateBackground(this.m_arrPages[this.m_lCurrentPage]); -// -// // enable margins -// hor_ruler.IsCanMoveMargins = true; -// ver_ruler.IsCanMoveMargins = true; -// -// this.LastParagraphMargins = null; -// } -// } -// -// this.m_oWordControl.UpdateHorRuler(); -// this.m_oWordControl.UpdateVerRuler(); - }; - - this.Set_RulerState_HdrFtr = function(bHeader, Y0, Y1) - { - var hor_ruler = this.m_oWordControl.m_oHorRuler; - var ver_ruler = this.m_oWordControl.m_oVerRuler; - - hor_ruler.CurrentObjectType = RULER_OBJECT_TYPE_PARAGRAPH; - hor_ruler.m_oTableMarkup = null; - - ver_ruler.CurrentObjectType = (true === bHeader) ? RULER_OBJECT_TYPE_HEADER : RULER_OBJECT_TYPE_FOOTER; - ver_ruler.header_top = Y0; - ver_ruler.header_bottom = Y1; - ver_ruler.m_oTableMarkup = null; - - // вообще надо посмотреть... может и бал параграф до этого. - // тогда вэкграунд перерисовывать не нужно. Только надо знать, на той же странице это было или нет - if (-1 != this.m_lCurrentPage) - { - hor_ruler.CreateBackground(this.m_arrPages[this.m_lCurrentPage]); - ver_ruler.CreateBackground(this.m_arrPages[this.m_lCurrentPage]); - } - - this.m_oWordControl.UpdateHorRuler(); - this.m_oWordControl.UpdateVerRuler(); - }; - - this.Update_MathTrack = function (IsActive, IsContentActive, oMath) - { - //TODO: Implement - }; - - this.Update_ParaTab = function(Default_Tab, ParaTabs) - { - //TODO: - -// var hor_ruler = this.m_oWordControl.m_oHorRuler; -// -// var __tabs = ParaTabs.Tabs; -// if (undefined === __tabs) -// __tabs = ParaTabs; -// -// var _len = __tabs.length; -// if ((Default_Tab == hor_ruler.m_dDefaultTab) && (hor_ruler.m_arrTabs.length == _len) && (_len == 0)) -// { -// // потом можно и проверить сами табы -// return; -// } -// -// hor_ruler.m_dDefaultTab = Default_Tab; -// hor_ruler.m_arrTabs = []; -// var _ar = hor_ruler.m_arrTabs; -// -// for (var i = 0; i < _len; i++) -// { -// if (__tabs[i].Value == tab_Left) -// _ar[i] = new CTab(__tabs[i].Pos, tab_Left); -// else if (__tabs[i].Value == tab_Center) -// _ar[i] = new CTab(__tabs[i].Pos, tab_Center); -// else if (__tabs[i].Value == tab_Right) -// _ar[i] = new CTab(__tabs[i].Pos, tab_Right); -// } -// -// hor_ruler.CorrectTabs(); -// this.m_oWordControl.UpdateHorRuler(); - }; - - this.UpdateTableRuler = function(isCols, index, position) - { - this.Native["DD_UpdateTableRuler"](isCols, index, position); - }; - this.GetDotsPerMM = function(value) - { - return value * this.Native["DD_GetDotsPerMM"](); - // return value * this.m_oWordControl.m_nZoomValue * g_dKoef_mm_to_pix / 100; - }; - - this.GetMMPerDot = function(value) - { - return value / this.GetDotsPerMM( 1 ); - }; - this.GetVisibleMMHeight = function() - { - return this.Native["DD_GetVisibleMMHeight"](); - -// var pixHeigth = this.m_oWordControl.m_oEditor.HtmlElement.height; -// var pixBetweenPages = 20 * (this.m_lDrawingEnd - this.m_lDrawingFirst); -// -// return (pixHeigth - pixBetweenPages) * g_dKoef_pix_to_mm * 100 / this.m_oWordControl.m_nZoomValue; - }; - - // вот оооочень важная функция. она выкидывает из кэша неиспользуемые шрифты - this.CheckFontCache = function() - { - var map_used = this.LogicDocument.Document_CreateFontMap(); - - for (var i in map_used) - { - this.Native["DD_CheckFontCacheAdd"](map_used[i].Name, map_used[i].Style, map_used[i].Size); - } - this.Native["DD_CheckFontCache"](); - -// var map_used = this.m_oWordControl.m_oLogicDocument.Document_CreateFontMap(); -// -// var _measure_map = g_oTextMeasurer.m_oManager.m_oFontsCache.Fonts; -// var _drawing_map = g_fontManager.m_oFontsCache.Fonts; -// -// var map_keys = {}; -// var api = this.m_oWordControl.m_oApi; -// for (var i in map_used) -// { -// var key = GenerateMapId(api, map_used[i].Name, map_used[i].Style, map_used[i].Size); -// map_keys[key] = true; -// } -// -// // а теперь просто пробегаем по кэшам и удаляем ненужное -// for (var i in _measure_map) -// { -// if (map_keys[i] == undefined) -// { -// //_measure_map[i] = undefined; -// delete _measure_map[i]; -// } -// } -// for (var i in _drawing_map) -// { -// if (map_keys[i] == undefined) -// { -// //_drawing_map[i] = undefined; -// if (null != _drawing_map[i]) -// _drawing_map[i].Destroy(); -// delete _drawing_map[i]; -// } -// } - }; - - // при загрузке документа - нужно понять какие шрифты используются - this.CheckFontNeeds = function() - { -// var map_keys = this.m_oWordControl.m_oLogicDocument.Document_Get_AllFontNames(); -// var dstfonts = []; -// for (var i in map_keys) -// { -// dstfonts[dstfonts.length] = new CFont(i, 0, "", 0, null); -// } -// this.m_oWordControl.m_oLogicDocument.Fonts = dstfonts; -// return; - - /* - var map_used = this.m_oWordControl.m_oLogicDocument.Document_CreateFontMap(); - - var map_keys = {}; - for (var i in map_used) - { - var search = map_used[i]; - var found = map_keys[search.Name]; - - var _need_style = 0; - switch (search.Style) - { - case FontStyle.FontStyleRegular: - { - _need_style = fontstyle_mask_regular; - break; - } - case FontStyle.FontStyleBold: - { - _need_style = fontstyle_mask_bold; - break; - } - case FontStyle.FontStyleItalic: - { - _need_style = fontstyle_mask_italic; - break; - } - case FontStyle.FontStyleBoldItalic: - { - _need_style = fontstyle_mask_bolditalic; - break; - } - default: - { - _need_style = fontstyle_mask_regular | fontstyle_mask_italic | fontstyle_mask_bold | fontstyle_mask_bolditalic; - break; - } - } - - if (undefined === found) - { - map_keys[search.Name] = _need_style; - } - else - { - map_keys[search.Name] |= _need_style; - } - } - - // теперь просто пробегаем и заполняем все объектами - var dstfonts = []; - for (var i in map_keys) - { - dstfonts[dstfonts.length] = new CFont(i, 0, "", 0, map_keys[i]); - } - this.m_oWordControl.m_oLogicDocument.Fonts = dstfonts; - */ - }; - - // фукнции для старта работы - this.OpenDocument = function() - { - //SetHintsProps(false, false); -// this.m_oDocumentRenderer.InitDocument(this); -// -// this.m_oWordControl.CalculateDocumentSize(); -// this.m_oWordControl.OnScroll(); - }; - - this.BeginDrawTracking = function() - { - this.AutoShapesTrack.BeginDrawTracking(); - }; - - this.EndDrawTracking = function() - { - this.AutoShapesTrack.EndDrawTracking(); - }; - - // вот здесь весь трекинг - this.DrawTrack = function(type, matrix, left, top, width, height, isLine, canRotate, isNoMove, isDrawHandles) - { - this.AutoShapesTrack.DrawTrack(type, matrix, left, top, width, height, isLine, canRotate, isNoMove, isDrawHandles); - }; - - this.DrawTrackSelectShapes = function(x, y, w, h) - { - this.AutoShapesTrack.DrawTrackSelectShapes(x, y, w, h); - }; - - this.DrawAdjustment = function(matrix, x, y, bTextWarp) - { - this.AutoShapesTrack.DrawAdjustment(matrix, x, y, bTextWarp); - }; - - this.LockTrackPageNum = function(nPageNum) - { - this.AutoShapesTrackLockPageNum = nPageNum; - }; - this.UnlockTrackPageNum = function() - { - this.AutoShapesTrackLockPageNum = -1; - }; - - this.CheckGuiControlColors = function() - { - - }; - - this.SendControlColors = function() - { - - }; - - this.DrawImageTextureFillShape = function(url) - { - - }; - - this.DrawImageTextureFillTextArt = function(url) - { - - }; - - this.InitGuiCanvasShape = function(div_id) - { - - }; - - this.InitGuiCanvasTextProps = function(div_id) - { - - }; - - this.InitGuiCanvasTextArt = function(div_id) - { - - }; - - this.DrawGuiCanvasTextProps = function(props) - { - - }; - - this.CheckTableStyles = function(tableLook) - { - // сначала проверим, подписан ли кто на этот евент - // а то во вьюере не стоит ничего посылать -// if (!this.m_oWordControl.m_oApi.asc_checkNeedCallback("asc_onInitTableTemplates")) -// return; - - let isChanged = false; - - if (!this.TableStylesLastLook || !this.TableStylesLastLook.IsEqual(tableLook)) - { - this.TableStylesLastLook = tableLook.Copy(); - isChanged = true; - } - - if (!isChanged) - return; - - var logicDoc = this.m_oWordControl.m_oLogicDocument; - var _dst_styles = []; - - var _styles = logicDoc.Styles.GetAllTableStyles(); - var _styles_len = _styles.length; - - if (_styles_len == 0) - return _dst_styles; - - var _x_mar = 10; - var _y_mar = 10; - var _r_mar = 10; - var _b_mar = 10; - var _pageW = 297; - var _pageH = 210; - - var W = (_pageW - _x_mar - _r_mar); - var H = (_pageH - _y_mar - _b_mar); - var Grid = []; - - var Rows = 5; - var Cols = 5; - - for (var i = 0; i < Cols; i++) - Grid[i] = W / Cols; - - var _canvas = document.createElement('canvas'); - _canvas.width = TABLE_STYLE_WIDTH_PIX; - _canvas.height = TABLE_STYLE_HEIGHT_PIX; - var ctx = _canvas.getContext('2d'); - - AscCommon.History.TurnOff(); - for (var i1 = 0; i1 < _styles_len; i1++) - { - let _style = _styles[i1]; - let i = _style.GetId(); - - var table = new CTable(this, logicDoc, true, Rows, Cols, Grid); - table.Set_Props({TableStyle : i, TableLook : tableLook}); - - for (var j = 0; j < Rows; j++) - table.Content[j].Set_Height(H / Rows, Asc.linerule_AtLeast); - - ctx.fillStyle = "#FFFFFF"; - ctx.fillRect(0, 0, _canvas.width, _canvas.height); - - var graphics = new AscCommon.CGraphics(); - graphics.init(ctx, _canvas.width, _canvas.height, _pageW, _pageH); - graphics.m_oFontManager = AscCommon.g_fontManager; - graphics.transform(1,0,0,1,0,0); - - table.Reset(_x_mar, _y_mar, 1000, 1000, 0, 0, 1); - table.Recalculate_Page(0); - table.Draw(0, graphics); - - var _styleD = new AscCommon.CStyleImage(); - _styleD.type = AscCommon.c_oAscStyleImage.Default; - _styleD.image = _canvas.toDataURL("image/png"); - _styleD.name = i; - _styleD.displayName = _style.Name; - _dst_styles.push(_styleD); - } - AscCommon.History.TurnOn(); - - this.m_oWordControl.m_oApi.sync_InitEditorTableStyles(_dst_styles); - }; - - this.GetTableStylesPreviews = function() - { - return []; - }; - this.GetTableLook = function(isDefault) - { - let oTableLook; - - if (isDefault) - { - oTableLook = new AscCommon.CTableLook(); - oTableLook.SetDefault(); - } - else - { - oTableLook = this.TableStylesLastLook; - } - - return oTableLook; - }; - - this.IsMobileVersion = function() - { - return this.IsMobile; - }; - - this.OnSelectEnd = function() - { - }; - - // collaborative targets - this.Collaborative_UpdateTarget = function(_id, _shortId, _x, _y, _size, _page, _transform, is_from_paint) - { - }; - this.Collaborative_RemoveTarget = function(_id) - { - }; - this.Collaborative_TargetsUpdate = function(bIsChangePosition) - { - }; - this.Collaborative_GetTargetPosition = function(UserId) - { - }; - -} - -//--------------------------------------------------------export---------------------------------------------------- -window['AscCommon'] = window['AscCommon'] || {}; -window['AscCommon'].CPage = CPage; -window['AscCommon'].CDrawingDocument = CDrawingDocument; diff --git a/cell/native/Graphics.js b/cell/native/Graphics.js deleted file mode 100644 index 3937b5a628..0000000000 --- a/cell/native/Graphics.js +++ /dev/null @@ -1,1203 +0,0 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2023 - * - * This program is a free software product. You can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License (AGPL) - * version 3 as published by the Free Software Foundation. In accordance with - * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement - * of any third-party rights. - * - * This program is distributed WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ - -"use strict"; - -function CGraphics() -{ - this.m_oContext = null; - this.m_dWidthMM = 0; - this.m_dHeightMM = 0; - this.m_lWidthPix = 0; - this.m_lHeightPix = 0; - this.m_dDpiX = 96.0; - this.m_dDpiY = 96.0; - this.m_bIsBreak = false; - - this.textBB_l = 10000; - this.textBB_t = 10000; - this.textBB_r = -10000; - this.textBB_b = -10000; - - this.m_oPen = new AscCommon.CPen(); - this.m_oBrush = new AscCommon.CBrush(); - this.m_oAutoShapesTrack = null; - - this.m_oFontManager = null; - - this.m_oCoordTransform = new AscCommon.CMatrixL(); - this.m_oBaseTransform = new AscCommon.CMatrixL(); - this.m_oTransform = new AscCommon.CMatrixL(); - this.m_oFullTransform = new AscCommon.CMatrixL(); - this.m_oInvertFullTransform = new AscCommon.CMatrixL(); - - this.ArrayPoints = null; - - this.m_oCurFont = - { - Name : "", - FontSize : 10, - Bold : false, - Italic : false - }; - - // RFonts - this.m_oTextPr = null; - this.m_oGrFonts = new AscCommon.CGrRFonts(); - this.m_oLastFont = new AscCommon.CFontSetup(); - - this.LastFontOriginInfo = { Name : "", Replace : null }; - - this.m_bIntegerGrid = true; - - this.ClipManager = new AscCommon.CClipManager(); - this.ClipManager.BaseObject = this; - - this.TextureFillTransformScaleX = 1; - this.TextureFillTransformScaleY = 1; - this.IsThumbnail = false; - - this.GrState = new AscCommon.CGrState(); - this.GrState.Parent = this; - - this.globalAlpha = 1; - - this.TextClipRect = null; - this.IsClipContext = false; - - this.IsUseFonts2 = false; - this.m_oFontManager2 = null; - this.m_oLastFont2 = null; - - this.ClearMode = false; - this.IsRetina = false; -} - -CGraphics.prototype = -{ - init : function(context,width_px,height_px,width_mm,height_mm) - { - this.Native = window["native"]; - - this.m_oContext = context; - this.m_lHeightPix = height_px; - this.m_lWidthPix = width_px; - this.m_dWidthMM = width_mm; - this.m_dHeightMM = height_mm; - this.m_dDpiX = 25.4 * this.m_lWidthPix / this.m_dWidthMM; - this.m_dDpiY = 25.4 * this.m_lHeightPix / this.m_dHeightMM; - - this.m_oCoordTransform.sx = this.m_dDpiX / 25.4; - this.m_oCoordTransform.sy = this.m_dDpiY / 25.4; - - this.TextureFillTransformScaleX = 1 / this.m_oCoordTransform.sx; - this.TextureFillTransformScaleY = 1 / this.m_oCoordTransform.sy; - - this.LastFontOriginInfo = { Name : "", Replace : null }; - this.m_oCurFont = - { - Name : "", - FontSize : 10, - Bold : false, - Italic : false - }; - - /* - if (this.IsThumbnail) - { - this.TextureFillTransformScaleX *= (width_px / (width_mm * g_dKoef_mm_to_pix)); - this.TextureFillTransformScaleY *= (height_px / (height_mm * g_dKoef_mm_to_pix)) - } - */ - - /* - if (true == this.m_oContext.mozImageSmoothingEnabled) - this.m_oContext.mozImageSmoothingEnabled = false; - */ - - //this.ClearParams(); - - this.m_oLastFont.Clear(); - this.Native["PD_Save"](); - - // this.m_oContext.save(); - }, - EndDraw : function() - { - }, - - ClearParams : function() - { - this.m_oTextPr = null; - this.m_oGrFonts = new AscCommon.CGrRFonts(); - this.m_oLastFont = new AscCommon.CFontSetup(); - - this.IsUseFonts2 = false; - this.m_oLastFont2 = null; - - this.m_bIntegerGrid = true; - }, - - put_GlobalAlpha : function(enable, alpha) - { - if (false === enable) - { - this.globalAlpha = 1; - } - else - { - this.globalAlpha = alpha; - } - - this.Native["PD_put_GlobalAlpha"](enable, alpha); - }, - // pen methods - p_color : function(r,g,b,a) - { - this.Native["PD_p_color"](r,g,b,a); - }, - p_width : function(w) - { - this.m_oPen.LineWidth = w / 1000.0; - - if (!this.m_bIntegerGrid) - { - if (0 != this.m_oPen.LineWidth) - { - this.Native["PD_p_width"](this.m_oPen.LineWidth); - this.m_oContext.lineWidth = this.m_oPen.LineWidth; - } - else - { - var _x1 = this.m_oFullTransform.TransformPointX(0, 0); - var _y1 = this.m_oFullTransform.TransformPointY(0, 0); - var _x2 = this.m_oFullTransform.TransformPointX(1, 1); - var _y2 = this.m_oFullTransform.TransformPointY(1, 1); - - var _koef = Math.sqrt(((_x2 - _x1)*(_x2 - _x1) + (_y2 - _y1)*(_y2 - _y1)) / 2); - this.Native["PD_p_width"](1 / _koef); - this.m_oContext.lineWidth = 1 / _koef; - } - } - else - { - if (0 != this.m_oPen.LineWidth) - { - var _m = this.m_oFullTransform; - var x = _m.sx + _m.shx; - var y = _m.sy + _m.shy; - - var koef = Math.sqrt((x * x + y * y) / 2); - this.Native["PD_p_width"](this.m_oPen.LineWidth * koef); - this.m_oContext.lineWidth = this.m_oPen.LineWidth * koef; - } - else - { - this.Native["PD_p_width"](1); - this.m_oContext.lineWidth = 1; - } - } - }, - - p_dash : function(params) - { - this.Native["PD_p_dash"](params ? params : []); - }, - - // brush methods - b_color1 : function(r,g,b,a) - { - var _c = this.m_oBrush.Color1; - _c.R = r; - _c.G = g; - _c.B = b; - _c.A = a; - - this.Native["PD_b_color1"](r,g,b,a); - }, - b_color2 : function(r,g,b,a) - { - var _c = this.m_oBrush.Color2; - _c.R = r; - _c.G = g; - _c.B = b; - _c.A = a; - - this.Native["PD_b_color2"](r,g,b,a); - }, - - transform : function(sx,shy,shx,sy,tx,ty) - { - var _t = this.m_oTransform; - _t.sx = sx; - _t.shx = shx; - _t.shy = shy; - _t.sy = sy; - _t.tx = tx; - _t.ty = ty; - - this.CalculateFullTransform(); - if (false === this.m_bIntegerGrid) - { - var _ft = this.m_oFullTransform; - this.Native["PD_transform"](_ft.sx,_ft.shy,_ft.shx,_ft.sy,_ft.tx,_ft.ty); - } - - //if (null != this.m_oFontManager) - //{ - // this.m_oFontManager.SetTextMatrix(_t.sx,_t.shy,_t.shx,_t.sy,_t.tx,_t.ty); - //} - }, - CalculateFullTransform : function(isInvertNeed) - { - var _ft = this.m_oFullTransform; - var _t = this.m_oTransform; - _ft.sx = _t.sx; - _ft.shx = _t.shx; - _ft.shy = _t.shy; - _ft.sy = _t.sy; - _ft.tx = _t.tx; - _ft.ty = _t.ty; - AscCommon.global_MatrixTransformer.MultiplyAppend(_ft, this.m_oCoordTransform); - - var _it = this.m_oInvertFullTransform; - _it.sx = _ft.sx; - _it.shx = _ft.shx; - _it.shy = _ft.shy; - _it.sy = _ft.sy; - _it.tx = _ft.tx; - _it.ty = _ft.ty; - - if (false !== isInvertNeed) - { - AscCommon.global_MatrixTransformer.MultiplyAppendInvert(_it, _t); - } - }, - // path commands - _s : function() - { - this.Native["PD_PathStart"](); - }, - _e : function() - { - this.Native["PD_PathEnd"](); - }, - _z : function() - { - this.Native["PD_PathClose"](); - }, - _m : function(x,y) - { - if (false === this.m_bIntegerGrid) - { - this.Native["PD_PathMoveTo"](x,y); - - if (this.ArrayPoints != null) - this.ArrayPoints[this.ArrayPoints.length] = {x: x, y: y}; - } - else - { - var _x = (this.m_oFullTransform.TransformPointX(x,y)) >> 0; - var _y = (this.m_oFullTransform.TransformPointY(x,y)) >> 0; - this.Native["PD_PathMoveTo"](_x + 0.5,_y + 0.5); - } - }, - _l : function(x,y) - { - if (false === this.m_bIntegerGrid) - { - this.Native["PD_PathLineTo"](x,y); - - if (this.ArrayPoints != null) - this.ArrayPoints[this.ArrayPoints.length] = {x: x, y: y}; - } - else - { - var _x = (this.m_oFullTransform.TransformPointX(x,y)) >> 0; - var _y = (this.m_oFullTransform.TransformPointY(x,y)) >> 0; - this.Native["PD_PathLineTo"](_x + 0.5,_y + 0.5); - } - - }, - _c : function(x1,y1,x2,y2,x3,y3) - { - if (false === this.m_bIntegerGrid) - { - this.Native["PD_PathCurveTo"](x1,y1,x2,y2,x3,y3); - - if (this.ArrayPoints != null) - { - this.ArrayPoints[this.ArrayPoints.length] = {x: x1, y: y1}; - this.ArrayPoints[this.ArrayPoints.length] = {x: x2, y: y2}; - this.ArrayPoints[this.ArrayPoints.length] = {x: x3, y: y3}; - } - } - else - { - var _x1 = (this.m_oFullTransform.TransformPointX(x1,y1)) >> 0; - var _y1 = (this.m_oFullTransform.TransformPointY(x1,y1)) >> 0; - - var _x2 = (this.m_oFullTransform.TransformPointX(x2,y2)) >> 0; - var _y2 = (this.m_oFullTransform.TransformPointY(x2,y2)) >> 0; - - var _x3 = (this.m_oFullTransform.TransformPointX(x3,y3)) >> 0; - var _y3 = (this.m_oFullTransform.TransformPointY(x3,y3)) >> 0; - - this.Native["PD_PathCurveTo"](_x1 + 0.5,_y1 + 0.5,_x2 + 0.5,_y2 + 0.5,_x3 + 0.5,_y3 + 0.5); - } - }, - _c2 : function(x1,y1,x2,y2) - { - if (false === this.m_bIntegerGrid) - { - this.Native["PD_PathCurveTo2"](x1,y1,x2,y2); - - if (this.ArrayPoints != null) - { - this.ArrayPoints[this.ArrayPoints.length] = {x: x1, y: y1}; - this.ArrayPoints[this.ArrayPoints.length] = {x: x2, y: y2}; - } - } - else - { - var _x1 = (this.m_oFullTransform.TransformPointX(x1,y1)) >> 0; - var _y1 = (this.m_oFullTransform.TransformPointY(x1,y1)) >> 0; - - var _x2 = (this.m_oFullTransform.TransformPointX(x2,y2)) >> 0; - var _y2 = (this.m_oFullTransform.TransformPointY(x2,y2)) >> 0; - - this.Native["PD_PathCurveTo2"](_x1 + 0.5,_y1 + 0.5,_x2 + 0.5,_y2 + 0.5); - } - }, - ds : function() - { - this.Native["PD_Stroke"](); - }, - df : function() - { - this.Native["PD_Fill"](); - }, - - // canvas state - save : function() - { - this.Native["PD_Save"](); - }, - restore : function() - { - this.Native["PD_Restore"](); - }, - clip : function() - { - this.Native["PD_clip"](); - }, - - reset : function() - { - this.m_oTransform.Reset(); - this.CalculateFullTransform(false); - - if (!this.m_bIntegerGrid) - this.Native["PD_transform"](this.m_oCoordTransform.sx,0,0,this.m_oCoordTransform.sy,0, 0); - - //this.ClearParams(); - - this.Native["PD_reset"](); - }, - - transform3 : function(m, isNeedInvert) - { - var _t = this.m_oTransform; - _t.sx = m.sx; - _t.shx = m.shx; - _t.shy = m.shy; - _t.sy = m.sy; - _t.tx = m.tx; - _t.ty = m.ty; - this.CalculateFullTransform(isNeedInvert); - - if (!this.m_bIntegerGrid) - { - var _ft = this.m_oFullTransform; - this.Native["PD_transform"](_ft.sx,_ft.shy,_ft.shx,_ft.sy,_ft.tx,_ft.ty); - } - else - { - this.SetIntegerGrid(false); - } - - // теперь трансформ выставляется ТОЛЬКО при загрузке шрифта. Здесь другого быть и не может - /* - if (null != this.m_oFontManager && false !== isNeedInvert) - { - this.m_oFontManager.SetTextMatrix(this.m_oTransform.sx,this.m_oTransform.shy,this.m_oTransform.shx, - this.m_oTransform.sy,this.m_oTransform.tx,this.m_oTransform.ty); - } - */ - }, - - CheckUseFonts2 : function(_transform) - { -// if (!global_MatrixTransformer.IsIdentity2(_transform)) -// { -// if (window.g_fontManager2 == null) -// { -// window.g_fontManager2 = new CFontManager(); -// window.g_fontManager2.Initialize(true); -// } -// -// this.m_oFontManager2 = window.g_fontManager2; -// -// if (null == this.m_oLastFont2) -// this.m_oLastFont2 = new CFontSetup(); -// -// this.IsUseFonts2 = true; -// } - }, - - UncheckUseFonts2 : function() - { - this.IsUseFonts2 = false; - }, - - FreeFont : function() - { - this.Native["PD_FreeFont"](); - - //// это чтобы не сбросился кэш при отрисовке следующего шейпа - this.m_oFontManager.m_pFont = null; - }, - - // images - drawImage2 : function(img,x,y,w,h,alpha,srcRect) - { - console.log('NOT IMPLEMENTED : drawImage2'); - - var isA = (undefined !== alpha && null != alpha && 255 != alpha); - var _oldGA = 0; - if (isA) - { - // _oldGA = this.m_oContext.globalAlpha; - // this.m_oContext.globalAlpha = alpha / 255; - } - - if (false === this.m_bIntegerGrid) - { - if (!srcRect) - { - // тут нужно проверить, можно ли нарисовать точно. т.е. может картинка ровно такая, какая нужна. - if (!AscCommon.global_MatrixTransformer.IsIdentity2(this.m_oTransform)) - { - // this.m_oContext.drawImage(img,x,y,w,h); - } - else - { - var xx = this.m_oFullTransform.TransformPointX(x, y); - var yy = this.m_oFullTransform.TransformPointY(x, y); - var rr = this.m_oFullTransform.TransformPointX(x + w, y + h); - var bb = this.m_oFullTransform.TransformPointY(x + w, y + h); - var ww = rr - xx; - var hh = bb - yy; - - if (Math.abs(img.width - ww) < 2 && Math.abs(img.height - hh) < 2) - { - // рисуем точно - this.m_oContext.setTransform(1, 0, 0, 1, 0, 0); - // this.m_oContext.drawImage(img, xx >> 0, yy >> 0); - - // var _ft = this.m_oFullTransform; - // this.m_oContext.setTransform(_ft.sx,_ft.shy,_ft.shx,_ft.sy,_ft.tx,_ft.ty); - - } - else - { - // this.m_oContext.drawImage(img,x,y,w,h); - } - } - } - else - { - var _w = img.width; - var _h = img.height; - if (_w > 0 && _h > 0) - { - var __w = w; - var __h = h; - var _delW = Math.max(0, -srcRect.l) + Math.max(0, srcRect.r - 100) + 100; - var _delH = Math.max(0, -srcRect.t) + Math.max(0, srcRect.b - 100) + 100; - - var _sx = 0; - if (srcRect.l > 0 && srcRect.l < 100) - _sx = Math.min((_w * srcRect.l / 100) >> 0, _w - 1); - else if (srcRect.l < 0) - { - var _off = ((-srcRect.l / _delW) * __w); - x += _off; - w -= _off; - } - var _sy = 0; - if (srcRect.t > 0 && srcRect.t < 100) - _sy = Math.min((_h * srcRect.t / 100) >> 0, _h - 1); - else if (srcRect.t < 0) - { - var _off = ((-srcRect.t / _delH) * __h); - y += _off; - h -= _off; - } - var _sr = _w; - if (srcRect.r > 0 && srcRect.r < 100) - _sr = Math.max(Math.min((_w * srcRect.r / 100) >> 0, _w - 1), _sx); - else if (srcRect.r > 100) - { - var _off = ((srcRect.r - 100) / _delW) * __w; - w -= _off; - } - var _sb = _h; - if (srcRect.b > 0 && srcRect.b < 100) - _sb = Math.max(Math.min((_h * srcRect.b / 100) >> 0, _h - 1), _sy); - else if (srcRect.b > 100) - { - var _off = ((srcRect.b - 100) / _delH) * __h; - h -= _off; - } - - // if ((_sr-_sx) > 0 && (_sb-_sy) > 0 && w > 0 && h > 0) - // this.m_oContext.drawImage(img,_sx,_sy,_sr-_sx,_sb-_sy,x,y,w,h); - } - else - { - // this.m_oContext.drawImage(img,x,y,w,h); - } - } - } - else - { - var _x1 = (this.m_oFullTransform.TransformPointX(x,y)) >> 0; - var _y1 = (this.m_oFullTransform.TransformPointY(x,y)) >> 0; - var _x2 = (this.m_oFullTransform.TransformPointX(x+w,y+h)) >> 0; - var _y2 = (this.m_oFullTransform.TransformPointY(x+w,y+h)) >> 0; - - x = _x1; - y = _y1; - w = _x2 - _x1; - h = _y2 - _y1; - - if (!srcRect) - { - // тут нужно проверить, можно ли нарисовать точно. т.е. может картинка ровно такая, какая нужна. - if (!AscCommon.global_MatrixTransformer.IsIdentity2(this.m_oTransform)) - { - // this.m_oContext.drawImage(img,_x1,_y1,w,h); - } - else - { - if (Math.abs(img.width - w) < 2 && Math.abs(img.height - h) < 2) - { - // рисуем точно - // this.m_oContext.drawImage(img, x, y); - } - else - { - // this.m_oContext.drawImage(img,_x1,_y1,w,h); - } - } - } - else - { - var _w = img.width; - var _h = img.height; - if (_w > 0 && _h > 0) - { - var __w = w; - var __h = h; - var _delW = Math.max(0, -srcRect.l) + Math.max(0, srcRect.r - 100) + 100; - var _delH = Math.max(0, -srcRect.t) + Math.max(0, srcRect.b - 100) + 100; - - var _sx = 0; - if (srcRect.l > 0 && srcRect.l < 100) - _sx = Math.min((_w * srcRect.l / 100) >> 0, _w - 1); - else if (srcRect.l < 0) - { - var _off = ((-srcRect.l / _delW) * __w); - x += _off; - w -= _off; - } - var _sy = 0; - if (srcRect.t > 0 && srcRect.t < 100) - _sy = Math.min((_h * srcRect.t / 100) >> 0, _h - 1); - else if (srcRect.t < 0) - { - var _off = ((-srcRect.t / _delH) * __h); - y += _off; - h -= _off; - } - var _sr = _w; - if (srcRect.r > 0 && srcRect.r < 100) - _sr = Math.max(Math.min((_w * srcRect.r / 100) >> 0, _w - 1), _sx); - else if (srcRect.r > 100) - { - var _off = ((srcRect.r - 100) / _delW) * __w; - w -= _off; - } - var _sb = _h; - if (srcRect.b > 0 && srcRect.b < 100) - _sb = Math.max(Math.min((_h * srcRect.b / 100) >> 0, _h - 1), _sy); - else if (srcRect.b > 100) - { - var _off = ((srcRect.b - 100) / _delH) * __h; - h -= _off; - } - - // if ((_sr-_sx) > 0 && (_sb-_sy) > 0 && w > 0 && h > 0) - // this.m_oContext.drawImage(img,_sx,_sy,_sr-_sx,_sb-_sy,x,y,w,h); - } - else - { - // this.m_oContext.drawImage(img,x,y,w,h); - } - } - } - - if (isA) - { - // this.m_oContext.globalAlpha = _oldGA; - } - }, - drawImage : function(img,x,y,w,h,alpha,srcRect,nativeImage) - { - if (!srcRect) - return this.Native["PD_drawImage"](img,x,y,w,h,alpha); - - return this.Native["PD_drawImage"](img,x,y,w,h,alpha,srcRect.l,srcRect.t,srcRect.r,srcRect.b); - - //if (nativeImage) - //{ - // this.drawImage2(nativeImage,x,y,w,h,alpha,srcRect); - // return; - //} - // - //var editor = window["Asc"]["editor"]; - //var _img = editor.ImageLoader.map_image_index[img]; - //if (_img != undefined && _img.Status == ImageLoadStatus.Loading) - //{ - // // TODO: IMAGE_LOADING - //} - //else if (_img != undefined && _img.Image != null) - //{ - // this.drawImage2(_img.Image,x,y,w,h,alpha,srcRect); - //} - //else - //{ - // var _x = x; - // var _y = y; - // var _r = x+w; - // var _b = y+h; - // if (this.m_bIntegerGrid) - // { - // _x = this.m_oFullTransform.TransformPointX(x,y); - // _y = this.m_oFullTransform.TransformPointY(x,y); - // _r = this.m_oFullTransform.TransformPointX(x+w,y+h); - // _b = this.m_oFullTransform.TransformPointY(x+w,y+h); - // } - // - // var ctx = this.m_oContext; - // var old_p = ctx.lineWidth; - // - // ctx.beginPath(); - // ctx.moveTo(_x,_y); - // ctx.lineTo(_r,_b); - // ctx.moveTo(_r,_y); - // ctx.lineTo(_x,_b); - // ctx.strokeStyle = "#FF0000"; - // ctx.stroke(); - // - // ctx.beginPath(); - // ctx.moveTo(_x,_y); - // ctx.lineTo(_r,_y); - // ctx.lineTo(_r,_b); - // ctx.lineTo(_x,_b); - // ctx.closePath(); - // - // ctx.lineWidth = 1; - // ctx.strokeStyle = "#000000"; - // ctx.stroke(); - // ctx.beginPath(); - // - // ctx.lineWidth = old_p; - // ctx.strokeStyle = "rgba(" + this.m_oPen.Color.R + "," + this.m_oPen.Color.G + "," + - // this.m_oPen.Color.B + "," + (this.m_oPen.Color.A / 255) + ")"; - //} - }, - - // text - GetFont : function() - { - return this.m_oCurFont; - }, - font : function(font_id,font_size,matrix) - { - this.Native["PD_font"](font_id, font_size); - }, - SetFont : function(font) - { - if (null == font) - return; - - this.m_oCurFont.Name = font.FontFamily.Name; - this.m_oCurFont.FontSize = font.FontSize; - this.m_oCurFont.Bold = font.Bold; - this.m_oCurFont.Italic = font.Italic; - - var bItalic = true === font.Italic; - var bBold = true === font.Bold; - - var oFontStyle = AscFonts.FontStyle.FontStyleRegular; - if ( !bItalic && bBold ) - oFontStyle = AscFonts.FontStyle.FontStyleBold; - else if ( bItalic && !bBold ) - oFontStyle = AscFonts.FontStyle.FontStyleItalic; - else if ( bItalic && bBold ) - oFontStyle = AscFonts.FontStyle.FontStyleBoldItalic; - - var _fontinfo = AscFonts.g_fontApplication.GetFontInfo(font.FontFamily.Name, oFontStyle, this.LastFontOriginInfo); - var _info = AscCommon.GetLoadInfoForMeasurer(_fontinfo, oFontStyle); - - this.m_oLastFont.SetUpName = font.FontFamily.Name; - this.m_oLastFont.SetUpSize = font.FontSize; - this.m_oLastFont.SetUpStyle = oFontStyle; - - var flag = 0; - if (_info.NeedBold) flag |= 0x01; - if (_info.NeedItalic) flag |= 0x02; - if (_info.SrcBold) flag |= 0x04; - if (_info.SrcItalic) flag |= 0x08; - - this.Native["PD_LoadFont"](_info.Path, _info.FaceIndex, font.FontSize, flag); - }, - - SetTextPr : function(textPr, theme) - { - this.m_oTextPr = textPr.Copy(); - this.theme = theme; - this.m_oTextPr.ReplaceThemeFonts(theme.themeElements.fontScheme); - }, - - SetFontInternal : function(name, size, style) - { - var _lastFont = this.m_oLastFont; - _lastFont.Name = name; - _lastFont.Size = size; - - // if (_lastFont.Name != _lastFont.SetUpName || _lastFont.Size != _lastFont.SetUpSize || style != _lastFont.SetUpStyle) - { - _lastFont.SetUpName = _lastFont.Name; - _lastFont.SetUpSize = _lastFont.Size; - _lastFont.SetUpStyle = style; - - var _fontinfo = AscFonts.g_fontApplication.GetFontInfo(_lastFont.SetUpName, _lastFont.SetUpStyle, this.LastFontOriginInfo); - var _info = AscCommon.GetLoadInfoForMeasurer(_fontinfo, _lastFont.SetUpStyle); - - var flag = 0; - if (_info.NeedBold) flag |= 0x01; - if (_info.NeedItalic) flag |= 0x02; - if (_info.SrcBold) flag |= 0x04; - if (_info.SrcItalic) flag |= 0x08; - - this.Native["PD_LoadFont"](_info.Path, _info.FaceIndex, _lastFont.SetUpSize, flag); - } - }, - - SetFontSlot : function(slot, fontSizeKoef) - { - var _rfonts = this.m_oTextPr.RFonts; - var _lastFont = this.m_oLastFont; - - switch (slot) - { - case fontslot_ASCII: - { - _lastFont.Name = _rfonts.Ascii.Name; - _lastFont.Size = this.m_oTextPr.FontSize; - _lastFont.Bold = this.m_oTextPr.Bold; - _lastFont.Italic = this.m_oTextPr.Italic; - - break; - } - case fontslot_CS: - { - _lastFont.Name = _rfonts.CS.Name; - _lastFont.Size = this.m_oTextPr.FontSizeCS; - _lastFont.Bold = this.m_oTextPr.BoldCS; - _lastFont.Italic = this.m_oTextPr.ItalicCS; - - break; - } - case fontslot_EastAsia: - { - _lastFont.Name = _rfonts.EastAsia.Name; - _lastFont.Size = this.m_oTextPr.FontSize; - _lastFont.Bold = this.m_oTextPr.Bold; - _lastFont.Italic = this.m_oTextPr.Italic; - - break; - } - case fontslot_HAnsi: - default: - { - _lastFont.Name = _rfonts.HAnsi.Name; - _lastFont.Size = this.m_oTextPr.FontSize; - _lastFont.Bold = this.m_oTextPr.Bold; - _lastFont.Italic = this.m_oTextPr.Italic; - - break; - } - } - - if (undefined !== fontSizeKoef) - _lastFont.Size *= fontSizeKoef; - - var _style = 0; - if (_lastFont.Italic) - _style += 2; - if (_lastFont.Bold) - _style += 1; - - // if (_lastFont.Name != _lastFont.SetUpName || _lastFont.Size != _lastFont.SetUpSize || _style != _lastFont.SetUpStyle) - { - _lastFont.SetUpName = _lastFont.Name; - _lastFont.SetUpSize = _lastFont.Size; - _lastFont.SetUpStyle = _style; - - var _fontinfo = AscFonts.g_fontApplication.GetFontInfo(_lastFont.SetUpName, _lastFont.SetUpStyle, this.LastFontOriginInfo); - var _info = AscCommon.GetLoadInfoForMeasurer(_fontinfo, _lastFont.SetUpStyle); - - var flag = 0; - if (_info.NeedBold) flag |= 0x01; - if (_info.NeedItalic) flag |= 0x02; - if (_info.SrcBold) flag |= 0x04; - if (_info.SrcItalic) flag |= 0x08; - - this.Native["PD_LoadFont"](_info.Path, _info.FaceIndex, _lastFont.SetUpSize, flag); - } - }, - - GetTextPr : function() - { - return this.m_oTextPr; - }, - - FillText : function(x,y,text) - { - var _code = text.charCodeAt(0); - if (null != this.LastFontOriginInfo.Replace) - _code = AscFonts.g_fontApplication.GetReplaceGlyph(_code, this.LastFontOriginInfo.Replace); - - // var _x = this.m_oInvertFullTransform.TransformPointX(x,y); - // var _y = this.m_oInvertFullTransform.TransformPointY(x,y); - - this.Native["PD_FillText"](x, y, _code); - }, - t : function(text,x,y) - { - var _arr = []; - var _len = text.length; - for (var i = 0; i < _len; i++) - _arr.push(text.charCodeAt(i)); - this.Native["PD_Text"](x,y,_arr); - }, - FillText2 : function(x,y,text,cropX,cropW) - { - var _code = text.charCodeAt(0); - if (null != this.LastFontOriginInfo.Replace) - _code = AscFonts.g_fontApplication.GetReplaceGlyph(_code, this.LastFontOriginInfo.Replace); - - this.Native["PD_FillText2"](x,y,_code,cropX,cropW); - }, - t2 : function(text,x,y,cropX,cropW) - { - var _arr = []; - var _len = text.length; - for (var i = 0; i < _len; i++) - _arr.push(text.charCodeAt(i)); - this.Native["PD_Text2"](x,y,_arr,cropX,cropW); - }, - FillTextCode : function(x,y,lUnicode) - { - if (null != this.LastFontOriginInfo.Replace) - lUnicode = AscFonts.g_fontApplication.GetReplaceGlyph(lUnicode, this.LastFontOriginInfo.Replace); - - this.Native["PD_FillText"](x,y,lUnicode); - }, - tg : function(gid,x,y) - { - this.Native["PD_FillTextG"](x,y,gid); - }, - charspace : function(space) - { - }, - - // private methods - private_FillGlyph : function(pGlyph) - { - console.log('NOT IMPLEMENTED private_FillGlyph'); - }, - private_FillGlyphC : function(pGlyph,cropX,cropW) - { - console.log('NOT IMPLEMENTED private_FillGlyphC'); - }, - - private_FillGlyph2 : function(pGlyph) - { - console.log('NOT IMPLEMENTED private_FillGlyph2'); - }, - - SetIntegerGrid : function(param) - { - // disable (поправить в native-sdk) - param = false; - - this.m_bIntegerGrid = param; - this.Native["PD_SetIntegerGrid"](param); - }, - GetIntegerGrid : function() - { - return this.m_bIntegerGrid; - }, - - DrawHeaderEdit : function(yPos, lock_type) - { - this.Native["PD_DrawHeaderEdit"](yPos, lock_type); - }, - - DrawFooterEdit : function(yPos, lock_type) - { - this.Native["PD_DrawFooterEdit"](yPos, lock_type); - }, - - DrawLockParagraph : function(lock_type, x, y1, y2) - { - this.Native["PD_DrawLockParagraph"](lock_type, x, y1, y2); - }, - - DrawLockObjectRect : function(lock_type, x, y, w, h) - { - this.Native["PD_DrawLockObjectRect"](lock_type, x, y, w, h); - }, - - DrawEmptyTableLine : function(x1,y1,x2,y2) - { - this.Native["PD_DrawEmptyTableLine"](x1,y1,x2,y2); - }, - - // smart methods for horizontal / vertical lines - drawHorLine : function(align, y, x, r, penW) - { - this.Native["PD_drawHorLine"](align, y, x, r, penW); - }, - drawHorLine2 : function(align, y, x, r, penW) - { - this.Native["PD_drawHorLine2"](align, y, x, r, penW); - }, - drawVerLine : function(align, x, y, b, penW) - { - this.Native["PD_drawVerLine"](align, x, y, b, penW); - }, - - // мега крутые функции для таблиц - drawHorLineExt : function(align, y, x, r, penW, leftMW, rightMW) - { - this.Native["PD_drawHorLineExt"](align, y, x, r, penW, leftMW, rightMW); - }, - - rect : function(x,y,w,h) - { - if (this.m_bIntegerGrid) - { - var _x = (this.m_oFullTransform.TransformPointX(x,y) + 0.5) >> 0; - var _y = (this.m_oFullTransform.TransformPointY(x,y) + 0.5) >> 0; - var _r = (this.m_oFullTransform.TransformPointX(x+w,y) + 0.5) >> 0; - var _b = (this.m_oFullTransform.TransformPointY(x,y+h) + 0.5) >> 0; - - this.Native["PD_rect"](_x, _y, _r - _x, _b - _y); - } - else - { - this.Native["PD_rect"](x,y,w,h); - } - }, - - TableRect : function(x,y,w,h) - { - this.Native["PD_TableRect"](x,y,w,h); - - }, - - // функции клиппирования - AddClipRect : function(x, y, w, h) - { - this.Native["PD_AddClipRect"](x,y,w,h); - ////this.ClipManager.AddRect(x, y, w, h); - //var __rect = new _rect(); - //__rect.x = x; - //__rect.y = y; - //__rect.w = w; - //__rect.h = h; - //this.GrState.AddClipRect(__rect); - }, - RemoveClipRect : function() - { - //this.ClipManager.RemoveRect(); - }, - - AddSmartRect : function(x, y, w, h, pen_w) - { - return this.Native["PD_AddSmartRect"](x, y, w, h, pen_w); - }, - - SetClip : function(r) - { - this.Native["PD_SetClip"](r.x, r.y, r.w, r.h); - - //var ctx = this.m_oContext; - //ctx.save(); - // - //ctx.beginPath(); - //if (!global_MatrixTransformer.IsIdentity(this.m_oTransform)) - //{ - // ctx.rect(r.x, r.y, r.w, r.h); - //} - //else - //{ - // var _x = (this.m_oFullTransform.TransformPointX(r.x,r.y) + 1) >> 0; - // var _y = (this.m_oFullTransform.TransformPointY(r.x,r.y) + 1) >> 0; - // var _r = (this.m_oFullTransform.TransformPointX(r.x+r.w,r.y) - 1) >> 0; - // var _b = (this.m_oFullTransform.TransformPointY(r.x,r.y+r.h) - 1) >> 0; - // - // ctx.rect(_x, _y, _r - _x + 1, _b - _y + 1); - //} - // - //this.clip(); - //ctx.beginPath(); - }, - - RemoveClip : function() - { - this.Native["PD_RemoveClip"](); - - //this.m_oContext.restore(); - //this.m_oContext.save(); - // - //if (this.m_oContext.globalAlpha != this.globalAlpha) - // this.m_oContext.globalAlpha = this.globalAlpha; - }, - - drawCollaborativeChanges : function(x, y, w, h) - { - this.Native["PD_drawCollaborativeChanges"](x, y, w, h); - }, - - drawSearchResult : function(x, y, w, h) - { - this.Native["PD_drawSearchResult"](x, y, w, h); - }, - - drawFlowAnchor : function(x, y) - { - this.Native["PD_drawFlowAnchor"](x, y); - - }, - - SavePen : function() - { - this.Native["PD_SavePen"](); - }, - RestorePen : function() - { - this.Native["PD_RestorePen"](); - }, - - SaveBrush : function() - { - this.Native["PD_SaveBrush"](); - }, - RestoreBrush : function() - { - this.Native["PD_RestoreBrush"](); - }, - - SavePenBrush : function() - { - this.Native["PD_SavePenBrush"](); - }, - RestorePenBrush : function() - { - this.Native["PD_RestorePenBrush"](); - }, - - SaveGrState : function() - { - this.Native["PD_SaveGrState"](); - }, - RestoreGrState : function() - { - this.Native["PD_RestoreGrState"](); - }, - - StartClipPath : function() - { - this.Native["PD_StartClipPath"](); - }, - - EndClipPath : function() - { - this.Native["PD_EndClipPath"](); - - }, - - StartCheckTableDraw : function() - { - return this.Native["PD_StartCheckTableDraw"](); - }, - - EndCheckTableDraw : function(bIsRestore) - { - return this.Native["PD_EndCheckTableDraw"](bIsRestore); - }, - - SetTextClipRect : function(_l, _t, _r, _b) - { - return this.Native["PD_SetTextClipRect"](_l, _t, _r, _b); - } -}; -//------------------------------------------------------------export---------------------------------------------------- -window['AscCommon'] = window['AscCommon'] || {}; -window['AscCommon'].CGraphics = CGraphics; diff --git a/cell/native/Overlay.js b/cell/native/Overlay.js deleted file mode 100644 index 672738643c..0000000000 --- a/cell/native/Overlay.js +++ /dev/null @@ -1,3090 +0,0 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2023 - * - * This program is a free software product. You can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License (AGPL) - * version 3 as published by the Free Software Foundation. In accordance with - * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement - * of any third-party rights. - * - * This program is distributed WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ - -"use strict"; - -var TRACK_CIRCLE_RADIUS = 10; -var TRACK_RECT_SIZE2 = 6;//4; -var TRACK_RECT_SIZE = 10;//8; -var TRACK_DISTANCE_ROTATE = 50; -var TRACK_DISTANCE_ROTATE2 = 25; -var TRACK_ADJUSTMENT_SIZE = 12;//10; -var TRACK_WRAPPOINTS_SIZE = 8;//6; -var IMAGE_ROTATE_TRACK_W = 25;//21; - - - -// заглушка -function CHtmlPage() -{ - var drawingPage = { top: 0, left: 0, right: 0, bottom: 0 }; - var width_mm, height_mm; - - this.init = function(x, y, w_pix, h_pix, w_mm, h_mm) { - drawingPage.top = y; - drawingPage.left = x; - drawingPage.right = w_pix; - drawingPage.bottom = h_pix; - width_mm = w_mm; - height_mm = h_mm; - } - - this.GetDrawingPageInfo = function() { - - return { drawingPage: drawingPage, width_mm: width_mm, height_mm: height_mm }; - } -} - -function COverlay() -{ - this.m_oControl = null; - this.m_oContext = null; - - this.min_x = 0xFFFF; - this.min_y = 0xFFFF; - this.max_x = -0xFFFF; - this.max_y = -0xFFFF; - - this.m_bIsShow = false; - this.m_bIsAlwaysUpdateOverlay = false; - - this.m_oHtmlPage = null; -} - -COverlay.prototype = -{ - init : function(context, controlName, x, y, w_pix, h_pix, w_mm, h_mm) - { - this.m_oContext = context; -// this.m_oControl = CreateControl(controlName); -// -// this.m_oHtmlPage = new CHtmlPage(); -// this.m_oHtmlPage.init(x, y, w_pix, h_pix, w_mm, h_mm); - }, - - Clear : function() - { -// if (null == this.m_oContext) -// { -// this.m_oContext = this.m_oControl.HtmlElement.getContext('2d'); -// -// this.m_oContext.imageSmoothingEnabled = false; -// this.m_oContext.mozImageSmoothingEnabled = false; -// this.m_oContext.oImageSmoothingEnabled = false; -// this.m_oContext.webkitImageSmoothingEnabled = false; -// } -// -// this.m_oContext.beginPath(); -// if (this.max_x != -0xFFFF && this.max_y != -0xFFFF) -// { -// this.m_oContext.clearRect(this.min_x - 5, this.min_y - 5, this.max_x - this.min_x + 10, this.max_y - this.min_y + 10); -// } - this.min_x = 0xFFFF; - this.min_y = 0xFFFF; - this.max_x = -0xFFFF; - this.max_y = -0xFFFF; - }, - - Show : function() - { -// if (this.m_bIsShow) -// return; -// -// this.m_bIsShow = true; -// this.m_oControl.HtmlElement.style.display = "block"; - }, - UnShow : function() - { -// if (!this.m_bIsShow) -// return; -// -// this.m_bIsShow = false; -// this.m_oControl.HtmlElement.style.display = "none"; - }, - - VertLine : function(position) - { -// this.Clear(); -// if (this.m_bIsAlwaysUpdateOverlay || editor.WordControl.m_oDrawingDocument.m_bIsSelection) -// { -// if (!editor.WordControl.OnUpdateOverlay()) -// { -// editor.WordControl.EndUpdateOverlay(); -// } -// } -// -// if (this.min_x > position) -// this.min_x = position; -// if (this.max_x < position) -// this.max_x = position; -// -// //this.min_x = position; -// //this.max_x = position; -// this.min_y = 0; -// this.max_y = this.m_oControl.HtmlElement.height; -// -// this.m_oContext.lineWidth = 1; -// -// var x = ((position + 0.5) >> 0) + 0.5; -// var y = 0; -// -// this.m_oContext.strokeStyle = "#000000"; -// this.m_oContext.beginPath(); -// -// while (y < this.max_y) -// { -// this.m_oContext.moveTo(x, y); y++; -// this.m_oContext.lineTo(x, y); y+=1; -// this.m_oContext.moveTo(x, y); y++; -// this.m_oContext.lineTo(x, y); y+=1; -// this.m_oContext.moveTo(x, y); y++; -// this.m_oContext.lineTo(x, y); y++; -// -// y += 5; -// } -// -// this.m_oContext.stroke(); -// -// y = 1; -// this.m_oContext.strokeStyle = "#FFFFFF"; -// this.m_oContext.beginPath(); -// -// while (y < this.max_y) -// { -// this.m_oContext.moveTo(x, y); y++; -// this.m_oContext.lineTo(x, y); y+=1; -// this.m_oContext.moveTo(x, y); y++; -// this.m_oContext.lineTo(x, y); y+=1; -// this.m_oContext.moveTo(x, y); y++; -// this.m_oContext.lineTo(x, y); y++; -// -// y += 5; -// } -// -// this.m_oContext.stroke(); -// this.Show(); - }, - - HorLine : function(position) - { -// this.Clear(); -// if (this.m_bIsAlwaysUpdateOverlay || editor.WordControl.m_oDrawingDocument.m_bIsSelection) -// { -// if (!editor.WordControl.OnUpdateOverlay()) -// { -// editor.WordControl.EndUpdateOverlay(); -// } -// } -// -// this.min_x = 0; -// this.max_x = this.m_oControl.HtmlElement.width; -// -// //this.min_y = position; -// //this.max_y = position; -// if (this.min_y > position) -// this.min_y = position; -// if (this.max_y < position) -// this.max_y = position; -// -// this.m_oContext.lineWidth = 1; -// -// var y = ((position + 0.5) >> 0) + 0.5; -// var x = 0; -// -// this.m_oContext.strokeStyle = "#000000"; -// this.m_oContext.beginPath(); -// -// while (x < this.max_x) -// { -// this.m_oContext.moveTo(x, y); x++; -// this.m_oContext.lineTo(x, y); x+=1; -// this.m_oContext.moveTo(x, y); x++; -// this.m_oContext.lineTo(x, y); x+=1; -// this.m_oContext.moveTo(x, y); x++; -// this.m_oContext.lineTo(x, y); x++; -// -// x += 5; -// } -// -// this.m_oContext.stroke(); -// -// x = 1; -// this.m_oContext.strokeStyle = "#FFFFFF"; -// this.m_oContext.beginPath(); -// -// while (x < this.max_x) -// { -// this.m_oContext.moveTo(x, y); x++; -// this.m_oContext.lineTo(x, y); x+=1; -// this.m_oContext.moveTo(x, y); x++; -// this.m_oContext.lineTo(x, y); x+=1; -// this.m_oContext.moveTo(x, y); x++; -// this.m_oContext.lineTo(x, y); x++; -// -// x += 5; -// } -// -// this.m_oContext.stroke(); -// this.Show(); - }, - - CheckPoint1 : function(x,y) - { - if (x < this.min_x) - this.min_x = x; - if (y < this.min_y) - this.min_y = y; - }, - CheckPoint2 : function(x,y) - { - if (x > this.max_x) - this.max_x = x; - if (y > this.max_y) - this.max_y = y; - }, - CheckPoint : function(x,y) - { - if (x < this.min_x) - this.min_x = x; - if (y < this.min_y) - this.min_y = y; - if (x > this.max_x) - this.max_x = x; - if (y > this.max_y) - this.max_y = y; - }, - - AddRect2 : function(x,y,r) - { - console.log('AddRect2!!!!!!!!!!!!'); -// var _x = x - ((r / 2) >> 0); -// var _y = y - ((r / 2) >> 0); -// this.CheckPoint1(_x,_y); -// this.CheckPoint2(_x+r,_y+r); -// -// this.m_oContext.moveTo(_x,_y); -// this.m_oContext.rect(_x,_y,r,r); - }, - - AddRect3 : function(x,y,r, ex1, ey1, ex2, ey2) - { - console.log('AddRect2!!!!!!!!!!!!'); - -// var _r = r / 2; -// -// var x1 = x + _r * (ex2 - ex1); -// var y1 = y + _r * (ey2 - ey1); -// -// var x2 = x + _r * (ex2 + ex1); -// var y2 = y + _r * (ey2 + ey1); -// -// var x3 = x + _r * (-ex2 + ex1); -// var y3 = y + _r * (-ey2 + ey1); -// -// var x4 = x + _r * (-ex2 - ex1); -// var y4 = y + _r * (-ey2 - ey1); -// -// this.CheckPoint(x1,y1); -// this.CheckPoint(x2,y2); -// this.CheckPoint(x3,y3); -// this.CheckPoint(x4,y4); -// -// var ctx = this.m_oContext; -// ctx.moveTo(x1,y1); -// ctx.lineTo(x2,y2); -// ctx.lineTo(x3,y3); -// ctx.lineTo(x4,y4); -// ctx.closePath(); - }, - - AddRect : function(x,y,w,h) - { - console.log('AddRect!!!!!!!!!!!!'); - -// this.CheckPoint1(x,y); -// this.CheckPoint2(x + w,y + h); -// -// this.m_oContext.moveTo(x,y); -// this.m_oContext.rect(x,y,w,h); -// //this.m_oContext.closePath(); - }, - CheckRectT : function(x,y,w,h,trans,eps) - { - var x1 = trans.TransformPointX(x, y); - var y1 = trans.TransformPointY(x, y); - - var x2 = trans.TransformPointX(x+w, y); - var y2 = trans.TransformPointY(x+w, y); - - var x3 = trans.TransformPointX(x+w, y+h); - var y3 = trans.TransformPointY(x+w, y+h); - - var x4 = trans.TransformPointX(x, y+h); - var y4 = trans.TransformPointY(x, y+h); - - this.CheckPoint(x1, y1); - this.CheckPoint(x2, y2); - this.CheckPoint(x3, y3); - this.CheckPoint(x4, y4); - - if (eps !== undefined) - { - this.min_x -= eps; - this.min_y -= eps; - this.max_x += eps; - this.max_y += eps; - } - }, - CheckRect : function(x,y,w,h) - { - this.CheckPoint1(x,y); - this.CheckPoint2(x + w,y + h); - }, - AddEllipse : function(x,y,r) - { - this.CheckPoint1(x-r,y-r); - this.CheckPoint2(x+r,y+r); - - console.log('AddEllipse!!!!!!!!!!!!'); - -// this.m_oContext.moveTo(x+r,y); -// this.m_oContext.arc(x,y,r,0,Math.PI*2,false); -// //this.m_oContext.closePath(); - }, - - AddRoundRect : function(x, y, w, h, r) - { - console.log('AddRoundRect!!!!!!!!!!!!'); - - -// if (w < (2 * r) || h < (2 * r)) -// return this.AddRect(x, y, w, h); -// -// this.CheckPoint1(x,y); -// this.CheckPoint2(x + w,y + h); -// -// var _ctx = this.m_oContext; -// _ctx.moveTo(x + r, y); -// _ctx.lineTo(x + w - r, y); -// _ctx.quadraticCurveTo(x + w, y, x + w, y + r); -// _ctx.lineTo(x + w, y + h - r); -// _ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h); -// _ctx.lineTo(x + r, y + h); -// _ctx.quadraticCurveTo(x, y + h, x, y + h - r); -// _ctx.lineTo(x, y + r); -// _ctx.quadraticCurveTo(x, y, x + r, y); - }, - - AddRoundRectCtx : function(ctx, x, y, w, h, r) - { - console.log('AddRoundRectCtx!!!!!!!!!!!!'); - - // if (w < (2 * r) || h < (2 * r)) - // return ctx.rect(x, y, w, h); - -// var _ctx = this.m_oContext; -// _ctx.moveTo(x + r, y); -// _ctx.lineTo(x + w - r, y); -// _ctx.quadraticCurveTo(x + w, y, x + w, y + r); -// _ctx.lineTo(x + w, y + h - r); -// _ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h); -// _ctx.lineTo(x + r, y + h); -// _ctx.quadraticCurveTo(x, y + h, x, y + h - r); -// _ctx.lineTo(x, y + r); -// _ctx.quadraticCurveTo(x, y, x + r, y); - }, - DrawFrozenPlaceHorLine: function(y, left, right) - { - }, - DrawFrozenPlaceVerLine: function(x, top, bottom) - { - } -}; - -function CBoundsController() -{ - this.min_x = 0xFFFF; - this.min_y = 0xFFFF; - this.max_x = -0xFFFF; - this.max_y = -0xFFFF; -} - -CBoundsController.prototype = -{ - ClearNoAttack : function() - { - this.min_x = 0xFFFF; - this.min_y = 0xFFFF; - this.max_x = -0xFFFF; - this.max_y = -0xFFFF; - }, - - Clear : function(ctx) - { - if (this.max_x != -0xFFFF && this.max_y != -0xFFFF) - { - ctx.fillRect(this.min_x - 5, this.min_y - 5, this.max_x - this.min_x + 10, this.max_y - this.min_y + 10); - } - this.min_x = 0xFFFF; - this.min_y = 0xFFFF; - this.max_x = -0xFFFF; - this.max_y = -0xFFFF; - }, - - CheckPoint1 : function(x,y) - { - if (x < this.min_x) - this.min_x = x; - if (y < this.min_y) - this.min_y = y; - }, - CheckPoint2 : function(x,y) - { - if (x > this.max_x) - this.max_x = x; - if (y > this.max_y) - this.max_y = y; - }, - CheckPoint : function(x,y) - { - if (x < this.min_x) - this.min_x = x; - if (y < this.min_y) - this.min_y = y; - if (x > this.max_x) - this.max_x = x; - if (y > this.max_y) - this.max_y = y; - }, - CheckRect : function(x,y,w,h) - { - this.CheckPoint1(x,y); - this.CheckPoint2(x + w,y + h); - } -}; - -function CAutoshapeTrack() -{ - this.m_oContext = null; - this.m_oOverlay = null; - - this.Graphics = null; - - this.MaxEpsLine = 0; - this.IsTrack = true; - - this.PageIndex = -1; - this.CurrentPageInfo = null; - - this.Native = window["native"]["CreateAutoShapesTrackControl"](); -} - -CAutoshapeTrack.prototype = -{ - AddClipRect: function() - {}, - - - SetFont : function(font) - { - }, - - init : function(overlay, x, y, r, b, w_mm, h_mm) - { - this.m_oOverlay = overlay; - this.m_oContext = this.m_oOverlay.m_oContext; - - this.Graphics = new AscCommon.CGraphics(); - this.Graphics.init(this.m_oContext, r - x, b - y, w_mm, h_mm); - - this.Graphics.m_oCoordTransform.tx = x; - this.Graphics.m_oCoordTransform.ty = y; - - this.Graphics.SetIntegerGrid(false); - - this.m_oContext.globalAlpha = 0.5; - }, - SetIntegerGrid : function(b) - { - //this.Native["PD_SetIntegerGrid"](param); - }, - // draw styles - p_color : function(r,g,b,a) - { - this.Native["PD_p_color"](r,g,b,a); - }, - p_width : function(w) - { - this.Native["PD_p_width"](w); - -// this.Graphics.p_width(w); -// -// var xx1 = 0; -// var yy1 = 0; -// var xx2 = 1; -// var yy2 = 1; -// -// var xxx1 = this.Graphics.m_oFullTransform.TransformPointX(xx1, yy1); -// var yyy1 = this.Graphics.m_oFullTransform.TransformPointY(xx1, yy1); -// var xxx2 = this.Graphics.m_oFullTransform.TransformPointX(xx2, yy2); -// var yyy2 = this.Graphics.m_oFullTransform.TransformPointY(xx2, yy2); -// -// var _len2 = ((xxx2 - xxx1)*(xxx2 - xxx1) + (yyy2 - yyy1)*(yyy2 - yyy1)); -// var koef = Math.sqrt(_len2 / 2); -// -// var _EpsLine = (w * koef / 1000) >> 0; -// _EpsLine += 5; -// -// if (_EpsLine > this.MaxEpsLine) -// this.MaxEpsLine = _EpsLine; - }, - b_color1 : function(r,g,b,a) - { - this.Native["PD_b_color1"](r,g,b,a); - //this.Graphics.b_color1(r,g,b,a); - }, - b_color2 : function(r,g,b,a) - { - this.Native["PD_b_color2"](r,g,b,a); - }, - - // path commands - _s : function() - { - console.log('PD_PathStart'); - this.Native["PD_PathStart"](); - }, - _e : function() - { - this.Native["PD_PathEnd"](); - }, - _z : function() - { - this.Native["PD_PathClose"](); - }, - _m : function(x,y) - { - this.Native["PD_PathMoveTo"](x,y); - -// this.Graphics._m(x,y); -// -// var _x = this.Graphics.m_oFullTransform.TransformPointX(x,y); -// var _y = this.Graphics.m_oFullTransform.TransformPointY(x,y); -// this.m_oOverlay.CheckPoint(_x, _y); - }, - _l : function(x,y) - { - this.Native["PD_PathLineTo"](x,y); - -// this.Graphics._l(x,y); -// -// var _x = this.Graphics.m_oFullTransform.TransformPointX(x,y); -// var _y = this.Graphics.m_oFullTransform.TransformPointY(x,y); -// this.m_oOverlay.CheckPoint(_x, _y); - }, - _c : function(x1,y1,x2,y2,x3,y3) - { - this.Native["PD_PathCurveTo"](x1,y1,x2,y2,x3,y3); - -// this.Graphics._c(x1,y1,x2,y2,x3,y3); -// -// var _x1 = this.Graphics.m_oFullTransform.TransformPointX(x1,y1); -// var _y1 = this.Graphics.m_oFullTransform.TransformPointY(x1,y1); -// -// var _x2 = this.Graphics.m_oFullTransform.TransformPointX(x2,y2); -// var _y2 = this.Graphics.m_oFullTransform.TransformPointY(x2,y2); -// -// var _x3 = this.Graphics.m_oFullTransform.TransformPointX(x3,y3); -// var _y3 = this.Graphics.m_oFullTransform.TransformPointY(x3,y3); -// -// this.m_oOverlay.CheckPoint(_x1, _y1); -// this.m_oOverlay.CheckPoint(_x2, _y2); -// this.m_oOverlay.CheckPoint(_x3, _y3); - }, - _c2 : function(x1,y1,x2,y2) - { - this.Native["PD_PathCurveTo2"](x1,y1,x2,y2); - -// this.Graphics._c2(x1,y1,x2,y2); -// -// var _x1 = this.Graphics.m_oFullTransform.TransformPointX(x1,y1); -// var _y1 = this.Graphics.m_oFullTransform.TransformPointY(x1,y1); -// -// var _x2 = this.Graphics.m_oFullTransform.TransformPointX(x2,y2); -// var _y2 = this.Graphics.m_oFullTransform.TransformPointY(x2,y2); -// -// this.m_oOverlay.CheckPoint(_x1, _y1); -// this.m_oOverlay.CheckPoint(_x2, _y2); - }, - ds : function() - { - this.Native["PD_Stroke"](); - // this.Graphics.ds(); - }, - df : function() - { - this.Native["PD_Fill"](); - //this.Graphics.df(); - }, - - // canvas state - save : function() - { - this.Native["PD_Save"](); - }, - restore : function() - { - this.Native["PD_Restore"](); - }, - clip : function() - { - this.Native["PD_clip"](); - }, - - // transform - reset : function() - { - this.Native["PD_reset"](); - }, - transform3 : function(m, isNeedInvert, funcName) - { - var isNeedInvert = false; - this.Native[funcName ? funcName : "PD_transform3"](m.sx,m.shy,m.shx,m.sy,m.tx,m.ty,isNeedInvert); - }, - transform : function(sx,shy,shx,sy,tx,ty) - { - this.Native["PD_transform"](sx,shy,shx,sy,tx,ty); - }, - drawImage : function(image, x, y, w, h, alpha, srcRect, nativeImage) - { - if (!srcRect) - return this.Native["PD_drawImage"](image,x,y,w,h,alpha); - - return this.Native["PD_drawImage"](image,x,y,w,h,alpha,srcRect.l,srcRect.t,srcRect.r,srcRect.b); - -// this.Graphics.drawImage(image, x, y, w, h, undefined, srcRect, nativeImage); -// -// var _x1 = this.Graphics.m_oFullTransform.TransformPointX(x,y); -// var _y1 = this.Graphics.m_oFullTransform.TransformPointY(x,y); -// -// var _x2 = this.Graphics.m_oFullTransform.TransformPointX(x+w,y); -// var _y2 = this.Graphics.m_oFullTransform.TransformPointY(x+w,y); -// -// var _x3 = this.Graphics.m_oFullTransform.TransformPointX(x+w,(y+h)); -// var _y3 = this.Graphics.m_oFullTransform.TransformPointY(x+w,(y+h)); -// -// var _x4 = this.Graphics.m_oFullTransform.TransformPointX(x,(y+h)); -// var _y4 = this.Graphics.m_oFullTransform.TransformPointY(x,(y+h)); -// -// this.m_oOverlay.CheckPoint(_x1, _y1); -// this.m_oOverlay.CheckPoint(_x2, _y2); -// this.m_oOverlay.CheckPoint(_x3, _y3); -// this.m_oOverlay.CheckPoint(_x4, _y4); - }, - CorrectOverlayBounds : function() - { - this.Native["DD_CorrectOverlayBounds"](); - -// this.m_oContext.setTransform(1,0,0,1,0,0); -// -// this.m_oOverlay.min_x -= this.MaxEpsLine; -// this.m_oOverlay.min_y -= this.MaxEpsLine; -// this.m_oOverlay.max_x += this.MaxEpsLine; -// this.m_oOverlay.max_y += this.MaxEpsLine; - }, - - SetCurrentPage : function(nPageIndex) - { - this.PageIndex = nPageIndex; - this.Native["DD_SetCurrentPage"](nPageIndex); - -// if (nPageIndex == this.PageIndex) -// return; -// -// var oPage = this.m_oOverlay.m_oHtmlPage.GetDrawingPageInfo(nPageIndex); -// this.PageIndex = nPageIndex; -// -// var drawPage = oPage.drawingPage; -// -// this.Graphics = new CGraphics(); -// this.Graphics.init(this.m_oContext, drawPage.right - drawPage.left, drawPage.bottom - drawPage.top, oPage.width_mm, oPage.height_mm); -// -// this.Graphics.m_oCoordTransform.tx = drawPage.left; -// this.Graphics.m_oCoordTransform.ty = drawPage.top; -// -// this.Graphics.SetIntegerGrid(false); -// -// this.m_oContext.globalAlpha = 0.5; - }, - - init2 : function(overlay) - { - //this.m_oOverlay = overlay; - //this.m_oContext = this.m_oOverlay.m_oContext; - //this.PageIndex = -1; - }, - - SetClip : function(r) - { - this.Native["PD_SetClip"](r.x, r.y, r.w, r.h); - }, - RemoveClip : function() - { - this.Native["PD_RemoveClip"](); - }, - - SavePen : function() - { - this.Native["PD_SavePen"](); - }, - RestorePen : function() - { - this.Native["PD_RestorePen"](); - }, - - SaveBrush : function() - { - this.Native["PD_SaveBrush"](); - }, - RestoreBrush : function() - { - this.Native["PD_RestoreBrush"](); - }, - - SavePenBrush : function() - { - this.Native["PD_SavePenBrush"](); - }, - RestorePenBrush : function() - { - this.Native["PD_RestorePenBrush"](); - }, - - SaveGrState : function() - { - this.Native["PD_SaveGrState"](); - }, - RestoreGrState : function() - { - this.Native["PD_RestoreGrState"](); - }, - - StartClipPath : function() - { - this.Native["PD_StartClipPath"](); - }, - - EndClipPath : function() - { - this.Native["PD_EndClipPath"](); - }, - - // NOTE! добавлять в CommonController в метод - drawSelect: function(pageIndex, drawingDocument) - - BeginDrawTracking: function() - { - this.Native["BeginDrawTracking"](); - }, - - EndDrawTracking: function() - { - this.Native["EndDrawTracking"](); - }, - - /*************************************************************************/ - /******************************** TRACKS *********************************/ - /*************************************************************************/ - DrawTrack : function(type, matrix, left, top, width, height, isLine, isCanRotate, isNoMove, isDrawHandles) - { - if (!matrix) - this.Native["DD_DrawTrackTransform"](); - else - this.Native["DD_DrawTrackTransform"](matrix.sx, matrix.shy, matrix.shx, matrix.sy, matrix.tx, matrix.ty); - - this.Native["DD_DrawTrack"](type, left, top, width, height, isLine, isCanRotate, isNoMove, isDrawHandles); - - -// if (true === isNoMove) -// return; -// -// // с самого начала нужно понять, есть ли поворот. Потому что если его нет, то можно -// // (и нужно!) рисовать все по-умному -// var overlay = this.m_oOverlay; -// overlay.Show(); -// -// var bIsClever = false; -// this.CurrentPageInfo = overlay.m_oHtmlPage.GetDrawingPageInfo(this.PageIndex); -// -// var drPage = this.CurrentPageInfo.drawingPage; -// -// var xDst = drPage.left + (this.Graphics ? this.Graphics.m_oCoordTransform.tx : 0); -// var yDst = drPage.top + (this.Graphics ? this.Graphics.m_oCoordTransform.ty : 0); -// var wDst = drPage.right - drPage.left; -// var hDst = drPage.bottom - drPage.top; -// -// var dKoefX = wDst / this.CurrentPageInfo.width_mm; -// var dKoefY = hDst / this.CurrentPageInfo.height_mm; -// -// var r = left + width; -// var b = top + height; -// -// // (x1,y1) --------- (x2,y2) -// // | | -// // | | -// // (x3,y3) --------- (x4,y4) -// -// var dx1 = xDst + dKoefX * (matrix.TransformPointX(left, top)); -// var dy1 = yDst + dKoefY * (matrix.TransformPointY(left, top)); -// -// var dx2 = xDst + dKoefX * (matrix.TransformPointX(r, top)); -// var dy2 = yDst + dKoefY * (matrix.TransformPointY(r, top)); -// -// var dx3 = xDst + dKoefX * (matrix.TransformPointX(left, b)); -// var dy3 = yDst + dKoefY * (matrix.TransformPointY(left, b)); -// -// var dx4 = xDst + dKoefX * (matrix.TransformPointX(r, b)); -// var dy4 = yDst + dKoefY * (matrix.TransformPointY(r, b)); -// -// var x1 = dx1 >> 0; -// var y1 = dy1 >> 0; -// -// var x2 = dx2 >> 0; -// var y2 = dy2 >> 0; -// -// var x3 = dx3 >> 0; -// var y3 = dy3 >> 0; -// -// var x4 = dx4 >> 0; -// var y4 = dy4 >> 0; -// -// var _eps = 0.001; -// if (Math.abs(dx1 - dx3) < _eps && -// Math.abs(dx2 - dx4) < _eps && -// Math.abs(dy1 - dy2) < _eps && -// Math.abs(dy3 - dy4) < _eps && -// x1 < x2 && y1 < y3) -// { -// x3 = x1; -// x4 = x2; -// y2 = y1; -// y4 = y3; -// bIsClever = true; -// } -// -// var nIsCleverWithTransform = bIsClever; -// var nType = 0; -// if (!nIsCleverWithTransform && -// Math.abs(dx1 - dx3) < _eps && -// Math.abs(dx2 - dx4) < _eps && -// Math.abs(dy1 - dy2) < _eps && -// Math.abs(dy3 - dy4) < _eps) -// { -// x3 = x1; -// x4 = x2; -// y2 = y1; -// y4 = y3; -// nIsCleverWithTransform = true; -// nType = 1; -// } -// if (!nIsCleverWithTransform && -// Math.abs(dx1 - dx2) < _eps && -// Math.abs(dx3 - dx4) < _eps && -// Math.abs(dy1 - dy3) < _eps && -// Math.abs(dy2 - dy4) < _eps) -// { -// x2 = x1; -// x4 = x3; -// y3 = y1; -// y4 = y2; -// nIsCleverWithTransform = true; -// nType = 2; -// } -// -// /* -// if (x1 == x3 && x2 == x4 && y1 == y2 && y3 == y4 && x1 < x2 && y1 < y3) -// bIsClever = true; -// -// var nIsCleverWithTransform = bIsClever; -// var nType = 0; -// if (!nIsCleverWithTransform && x1 == x3 && x2 == x4 && y1 == y2 && y3 == y4) -// { -// nIsCleverWithTransform = true; -// nType = 1; -// } -// if (!nIsCleverWithTransform && x1 == x2 && x3 == x4 && y1 == y3 && y2 == y4) -// { -// nIsCleverWithTransform = true; -// nType = 2; -// } -// */ -// -// var ctx = overlay.m_oContext; -// -// var bIsEllipceCorner = false; -// //var _style_blue = "#4D7399"; -// //var _style_blue = "#B2B2B2"; -// var _style_blue = "#939393"; -// var _style_green = "#84E036"; -// var _style_white = "#FFFFFF"; -// -// var _len_x = Math.sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2)); -// var _len_y = Math.sqrt((x1 - x3)*(x1 - x3) + (y1 - y3)*(y1 - y3)); -// -// if (_len_x < 1) -// _len_x = 1; -// if (_len_y < 1) -// _len_y = 1; -// -// var bIsRectsTrackX = (_len_x >= 30) ? true : false; -// var bIsRectsTrackY = (_len_y >= 30) ? true : false; -// var bIsRectsTrack = (bIsRectsTrackX || bIsRectsTrackY) ? true : false; -// -// if (nType == 2) -// { -// var _tmp = bIsRectsTrackX; -// bIsRectsTrackX = bIsRectsTrackY; -// bIsRectsTrackY = _tmp; -// } -// -// ctx.lineWidth = 1; -// ctx.beginPath(); -// -// var _oldGlobalAlpha = ctx.globalAlpha; -// ctx.globalAlpha = 1; -// -// switch (type) -// { -// case AscFormat.TYPE_TRACK.SHAPE: -// case AscFormat.TYPE_TRACK.GROUP: -// { -// if (bIsClever) -// { -// overlay.CheckRect(x1, y1, x4 - x1, y4 - y1); -// ctx.strokeStyle = _style_blue; -// -// if (!isLine) -// { -// ctx.rect(x1 + 0.5, y2 + 0.5, x4 - x1, y4 - y1); -// ctx.stroke(); -// ctx.beginPath(); -// } -// -// var xC = ((x1 + x2) / 2) >> 0; -// -// if (!isLine && isCanRotate) -// { -// if (!bIsUseImageRotateTrack) -// { -// ctx.beginPath(); -// overlay.AddEllipse(xC, y1 - TRACK_DISTANCE_ROTATE, TRACK_CIRCLE_RADIUS); -// -// ctx.fillStyle = _style_green; -// ctx.fill(); -// ctx.stroke(); -// } -// else -// { -// if (window.g_track_rotate_marker.asc_complete) -// { -// var _w = IMAGE_ROTATE_TRACK_W; -// var _xI = ((x1 + x2 - _w) / 2) >> 0; -// var _yI = y1 - TRACK_DISTANCE_ROTATE - (_w >> 1); -// -// overlay.CheckRect(_xI, _yI, _w, _w); -// ctx.drawImage(window.g_track_rotate_marker, _xI, _yI, _w, _w); -// } -// } -// -// ctx.beginPath(); -// ctx.moveTo(xC + 0.5, y1); -// ctx.lineTo(xC + 0.5, y1 - TRACK_DISTANCE_ROTATE2); -// ctx.stroke(); -// -// ctx.beginPath(); -// } -// -// ctx.fillStyle = _style_white; -// -// if (bIsEllipceCorner) -// { -// overlay.AddEllipse(x1, y1, TRACK_CIRCLE_RADIUS); -// if (!isLine) -// { -// overlay.AddEllipse(x2, y2, TRACK_CIRCLE_RADIUS); -// overlay.AddEllipse(x3, y3, TRACK_CIRCLE_RADIUS); -// } -// overlay.AddEllipse(x4, y4, TRACK_CIRCLE_RADIUS); -// } -// else -// { -// overlay.AddRect2(x1 + 0.5, y1 + 0.5, TRACK_RECT_SIZE); -// if (!isLine) -// { -// overlay.AddRect2(x2 + 0.5, y2 + 0.5, TRACK_RECT_SIZE); -// overlay.AddRect2(x3 + 0.5, y3 + 0.5, TRACK_RECT_SIZE); -// } -// overlay.AddRect2(x4 + 0.5, y4 + 0.5, TRACK_RECT_SIZE); -// } -// -// if (bIsRectsTrack && !isLine) -// { -// var _xC = (((x1 + x2) / 2) >> 0) + 0.5; -// var _yC = (((y1 + y3) / 2) >> 0) + 0.5; -// -// if (bIsRectsTrackX) -// { -// overlay.AddRect2(_xC, y1+0.5, TRACK_RECT_SIZE); -// overlay.AddRect2(_xC, y3+0.5, TRACK_RECT_SIZE); -// } -// -// if (bIsRectsTrackY) -// { -// overlay.AddRect2(x2+0.5, _yC, TRACK_RECT_SIZE); -// overlay.AddRect2(x1+0.5, _yC, TRACK_RECT_SIZE); -// } -// } -// -// ctx.fill(); -// ctx.stroke(); -// -// ctx.beginPath(); -// } -// else -// { -// var _x1 = x1; -// var _y1 = y1; -// var _x2 = x2; -// var _y2 = y2; -// var _x3 = x3; -// var _y3 = y3; -// var _x4 = x4; -// var _y4 = y4; -// -// if (nIsCleverWithTransform) -// { -// var _x1 = x1; -// if (x2 < _x1) -// _x1 = x2; -// if (x3 < _x1) -// _x1 = x3; -// if (x4 < _x1) -// _x1 = x4; -// -// var _x4 = x1; -// if (x2 > _x4) -// _x4 = x2; -// if (x3 > _x4) -// _x4 = x3; -// if (x4 > _x4) -// _x4 = x4; -// -// var _y1 = y1; -// if (y2 < _y1) -// _y1 = y2; -// if (y3 < _y1) -// _y1 = y3; -// if (y4 < _y1) -// _y1 = y4; -// -// var _y4 = y1; -// if (y2 > _y4) -// _y4 = y2; -// if (y3 > _y4) -// _y4 = y3; -// if (y4 > _y4) -// _y4 = y4; -// -// _x2 = _x4; -// _y2 = _y1; -// _x3 = _x1; -// _y3 = _y4; -// } -// -// ctx.strokeStyle = _style_blue; -// -// if (!isLine) -// { -// if (nIsCleverWithTransform) -// { -// ctx.rect(_x1 + 0.5, _y2 + 0.5, _x4 - _x1, _y4 - _y1); -// ctx.stroke(); -// ctx.beginPath(); -// } -// else -// { -// ctx.moveTo(x1, y1); -// ctx.lineTo(x2, y2); -// ctx.lineTo(x4, y4); -// ctx.lineTo(x3, y3); -// ctx.closePath(); -// ctx.stroke(); -// } -// } -// -// overlay.CheckPoint(x1, y1); -// overlay.CheckPoint(x2, y2); -// overlay.CheckPoint(x3, y3); -// overlay.CheckPoint(x4, y4); -// -// var ex1 = (x2 - x1) / _len_x; -// var ey1 = (y2 - y1) / _len_x; -// var ex2 = (x1 - x3) / _len_y; -// var ey2 = (y1 - y3) / _len_y; -// -// var _bAbsX1 = Math.abs(ex1) < 0.01; -// var _bAbsY1 = Math.abs(ey1) < 0.01; -// var _bAbsX2 = Math.abs(ex2) < 0.01; -// var _bAbsY2 = Math.abs(ey2) < 0.01; -// -// if (_bAbsX2 && _bAbsY2) -// { -// if (_bAbsX1 && _bAbsY1) -// { -// ex1 = 1; -// ey1 = 0; -// ex2 = 0; -// ey2 = 1; -// } -// else -// { -// ex2 = -ey1; -// ey2 = ex1; -// } -// } -// else if (_bAbsX1 && _bAbsY1) -// { -// ex1 = ey2; -// ey1 = -ex2; -// } -// -// var xc1 = (x1 + x2) / 2; -// var yc1 = (y1 + y2) / 2; -// -// ctx.beginPath(); -// -// if (!isLine && isCanRotate) -// { -// if (!bIsUseImageRotateTrack) -// { -// ctx.beginPath(); -// overlay.AddEllipse(xc1 + ex2 * TRACK_DISTANCE_ROTATE, yc1 + ey2 * TRACK_DISTANCE_ROTATE, TRACK_CIRCLE_RADIUS); -// -// ctx.fillStyle = _style_green; -// ctx.fill(); -// ctx.stroke(); -// } -// else -// { -// if (window.g_track_rotate_marker.asc_complete) -// { -// var _xI = xc1 + ex2 * TRACK_DISTANCE_ROTATE; -// var _yI = yc1 + ey2 * TRACK_DISTANCE_ROTATE; -// var _w = IMAGE_ROTATE_TRACK_W; -// var _w2 = IMAGE_ROTATE_TRACK_W / 2; -// -// if (nIsCleverWithTransform) -// { -// _xI >>= 0; -// _yI >>= 0; -// _w2 >>= 0; -// _w2 += 1; -// } -// -// //ctx.setTransform(ex1, ey1, -ey1, ex1, _xI, _yI); -// -// var _matrix = matrix.CreateDublicate(); -// _matrix.tx = 0; -// _matrix.ty = 0; -// var _xx = _matrix.TransformPointX(0, 1); -// var _yy = _matrix.TransformPointY(0, 1); -// var _angle = Math.atan2(_xx, -_yy) - Math.PI; -// var _px = Math.cos(_angle); -// var _py = Math.sin(_angle); -// -// ctx.translate(_xI, _yI); -// ctx.transform(_px, _py, -_py, _px, 0, 0); -// ctx.drawImage(window.g_track_rotate_marker, -_w2, -_w2, _w, _w); -// ctx.setTransform(1, 0, 0, 1, 0, 0); -// -// overlay.CheckRect(_xI - _w2, _yI - _w2, _w, _w); -// } -// } -// -// ctx.beginPath(); -// -// if (!nIsCleverWithTransform) -// { -// ctx.moveTo(xc1, yc1); -// ctx.lineTo(xc1 + ex2 * TRACK_DISTANCE_ROTATE2, yc1 + ey2 * TRACK_DISTANCE_ROTATE2); -// } -// else -// { -// ctx.moveTo((xc1 >> 0) + 0.5, (yc1 >> 0) + 0.5); -// ctx.lineTo(((xc1 + ex2 * TRACK_DISTANCE_ROTATE2) >> 0) + 0.5, ((yc1 + ey2 * TRACK_DISTANCE_ROTATE2) >> 0) + 0.5); -// } -// -// ctx.stroke(); -// -// ctx.beginPath(); -// } -// -// ctx.fillStyle = _style_white; -// -// if (!nIsCleverWithTransform) -// { -// if (bIsEllipceCorner) -// { -// overlay.AddEllipse(x1, y1, TRACK_CIRCLE_RADIUS); -// if (!isLine) -// { -// overlay.AddEllipse(x2, y2, TRACK_CIRCLE_RADIUS); -// overlay.AddEllipse(x3, y3, TRACK_CIRCLE_RADIUS); -// } -// overlay.AddEllipse(x4, y4, TRACK_CIRCLE_RADIUS); -// } -// else -// { -// overlay.AddRect3(x1, y1, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2); -// if (!isLine) -// { -// overlay.AddRect3(x2, y2, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2); -// overlay.AddRect3(x3, y3, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2); -// } -// overlay.AddRect3(x4, y4, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2); -// } -// } -// else -// { -// if (bIsEllipceCorner) -// { -// overlay.AddEllipse(_x1, _y1, TRACK_CIRCLE_RADIUS); -// if (!isLine) -// { -// overlay.AddEllipse(_x2, _y2, TRACK_CIRCLE_RADIUS); -// overlay.AddEllipse(_x3, _y3, TRACK_CIRCLE_RADIUS); -// } -// overlay.AddEllipse(_x4, _y4, TRACK_CIRCLE_RADIUS); -// } -// else -// { -// if (!isLine) -// { -// overlay.AddRect2(_x1 + 0.5, _y1 + 0.5, TRACK_RECT_SIZE); -// overlay.AddRect2(_x2 + 0.5, _y2 + 0.5, TRACK_RECT_SIZE); -// overlay.AddRect2(_x3 + 0.5, _y3 + 0.5, TRACK_RECT_SIZE); -// overlay.AddRect2(_x4 + 0.5, _y4 + 0.5, TRACK_RECT_SIZE); -// } -// else -// { -// overlay.AddRect2(x1 + 0.5, y1 + 0.5, TRACK_RECT_SIZE); -// overlay.AddRect2(x4 + 0.5, y4 + 0.5, TRACK_RECT_SIZE); -// } -// } -// } -// -// if (!isLine) -// { -// if (!nIsCleverWithTransform) -// { -// if (bIsRectsTrack) -// { -// if (bIsRectsTrackX) -// { -// overlay.AddRect3((x1 + x2) / 2, (y1 + y2) / 2, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2); -// overlay.AddRect3((x3 + x4) / 2, (y3 + y4) / 2, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2); -// } -// if (bIsRectsTrackY) -// { -// overlay.AddRect3((x2 + x4) / 2, (y2 + y4) / 2, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2); -// overlay.AddRect3((x3 + x1) / 2, (y3 + y1) / 2, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2); -// } -// } -// } -// else -// { -// var _xC = (((_x1 + _x2) / 2) >> 0) + 0.5; -// var _yC = (((_y1 + _y3) / 2) >> 0) + 0.5; -// -// if (bIsRectsTrackX) -// { -// overlay.AddRect2(_xC, _y1+0.5, TRACK_RECT_SIZE); -// overlay.AddRect2(_xC, _y3+0.5, TRACK_RECT_SIZE); -// } -// -// if (bIsRectsTrackY) -// { -// overlay.AddRect2(_x2+0.5, _yC, TRACK_RECT_SIZE); -// overlay.AddRect2(_x1+0.5, _yC, TRACK_RECT_SIZE); -// } -// } -// } -// -// ctx.fill(); -// ctx.stroke(); -// -// ctx.beginPath(); -// } -// -// break; -// } -// case AscFormat.TYPE_TRACK.TEXT: -// case AscFormat.TYPE_TRACK.GROUP_PASSIVE: -// { -// if (bIsClever) -// { -// overlay.CheckRect(x1, y1, x4 - x1, y4 - y1); -// this.AddRectDashClever(ctx, x1, y1, x4, y4, 8, 3); -// -// ctx.strokeStyle = _style_blue; -// ctx.stroke(); -// -// ctx.beginPath(); -// -// if (isCanRotate) -// { -// if (!bIsUseImageRotateTrack) -// { -// ctx.beginPath(); -// overlay.AddEllipse(xC, y1 - TRACK_DISTANCE_ROTATE, TRACK_CIRCLE_RADIUS); -// -// ctx.fillStyle = _style_green; -// ctx.fill(); -// ctx.stroke(); -// } -// else -// { -// if (window.g_track_rotate_marker.asc_complete) -// { -// var _w = IMAGE_ROTATE_TRACK_W; -// var _xI = ((x1 + x2 - _w) / 2) >> 0; -// var _yI = y1 - TRACK_DISTANCE_ROTATE - (_w >> 1); -// -// overlay.CheckRect(_xI, _yI, _w, _w); -// ctx.drawImage(window.g_track_rotate_marker, _xI, _yI, _w, _w); -// } -// } -// -// ctx.beginPath(); -// -// var xC = ((x1 + x2) / 2) >> 0; -// ctx.moveTo(xC + 0.5, y1); -// ctx.lineTo(xC + 0.5, y1 - TRACK_DISTANCE_ROTATE2); -// ctx.stroke(); -// -// ctx.beginPath(); -// } -// -// ctx.fillStyle = _style_white; -// -// if (bIsEllipceCorner) -// { -// overlay.AddEllipse(x1, y1, TRACK_CIRCLE_RADIUS); -// overlay.AddEllipse(x2, y2, TRACK_CIRCLE_RADIUS); -// overlay.AddEllipse(x3, y3, TRACK_CIRCLE_RADIUS); -// overlay.AddEllipse(x4, y4, TRACK_CIRCLE_RADIUS); -// } -// else -// { -// overlay.AddRect2(x1 + 0.5, y1 + 0.5, TRACK_RECT_SIZE); -// overlay.AddRect2(x2 + 0.5, y2 + 0.5, TRACK_RECT_SIZE); -// overlay.AddRect2(x3 + 0.5, y3 + 0.5, TRACK_RECT_SIZE); -// overlay.AddRect2(x4 + 0.5, y4 + 0.5, TRACK_RECT_SIZE); -// } -// -// if (bIsRectsTrack) -// { -// var _xC = (((x1 + x2) / 2) >> 0) + 0.5; -// var _yC = (((y1 + y3) / 2) >> 0) + 0.5; -// -// if (bIsRectsTrackX) -// { -// overlay.AddRect2(_xC, y1+0.5, TRACK_RECT_SIZE); -// overlay.AddRect2(_xC, y3+0.5, TRACK_RECT_SIZE); -// } -// if (bIsRectsTrackY) -// { -// overlay.AddRect2(x2+0.5, _yC, TRACK_RECT_SIZE); -// overlay.AddRect2(x1+0.5, _yC, TRACK_RECT_SIZE); -// } -// } -// -// ctx.fill(); -// ctx.stroke(); -// -// ctx.beginPath(); -// } -// else -// { -// var _x1 = x1; -// var _y1 = y1; -// var _x2 = x2; -// var _y2 = y2; -// var _x3 = x3; -// var _y3 = y3; -// var _x4 = x4; -// var _y4 = y4; -// -// if (nIsCleverWithTransform) -// { -// var _x1 = x1; -// if (x2 < _x1) -// _x1 = x2; -// if (x3 < _x1) -// _x1 = x3; -// if (x4 < _x1) -// _x1 = x4; -// -// var _x4 = x1; -// if (x2 > _x4) -// _x4 = x2; -// if (x3 > _x4) -// _x4 = x3; -// if (x4 > _x4) -// _x4 = x4; -// -// var _y1 = y1; -// if (y2 < _y1) -// _y1 = y2; -// if (y3 < _y1) -// _y1 = y3; -// if (y4 < _y1) -// _y1 = y4; -// -// var _y4 = y1; -// if (y2 > _y4) -// _y4 = y2; -// if (y3 > _y4) -// _y4 = y3; -// if (y4 > _y4) -// _y4 = y4; -// -// _x2 = _x4; -// _y2 = _y1; -// _x3 = _x1; -// _y3 = _y4; -// } -// -// overlay.CheckPoint(x1, y1); -// overlay.CheckPoint(x2, y2); -// overlay.CheckPoint(x3, y3); -// overlay.CheckPoint(x4, y4); -// -// if (!nIsCleverWithTransform) -// { -// this.AddRectDash(ctx, x1, y1, x2, y2, x3, y3, x4, y4, 8, 3); -// } -// else -// { -// this.AddRectDashClever(ctx, _x1, _y1, _x4, _y4, 8, 3); -// } -// -// ctx.strokeStyle = _style_blue; -// ctx.stroke(); -// -// var ex1 = (x2 - x1) / _len_x; -// var ey1 = (y2 - y1) / _len_x; -// var ex2 = (x1 - x3) / _len_y; -// var ey2 = (y1 - y3) / _len_y; -// -// var _bAbsX1 = Math.abs(ex1) < 0.01; -// var _bAbsY1 = Math.abs(ey1) < 0.01; -// var _bAbsX2 = Math.abs(ex2) < 0.01; -// var _bAbsY2 = Math.abs(ey2) < 0.01; -// -// if (_bAbsX2 && _bAbsY2) -// { -// if (_bAbsX1 && _bAbsY1) -// { -// ex1 = 1; -// ey1 = 0; -// ex2 = 0; -// ey2 = 1; -// } -// else -// { -// ex2 = -ey1; -// ey2 = ex1; -// } -// } -// else if (_bAbsX1 && _bAbsY1) -// { -// ex1 = ey2; -// ey1 = -ex2; -// } -// -// var xc1 = (x1 + x2) / 2; -// var yc1 = (y1 + y2) / 2; -// -// ctx.beginPath(); -// -// if (isCanRotate) -// { -// if (!bIsUseImageRotateTrack) -// { -// ctx.beginPath(); -// overlay.AddEllipse(xc1 + ex2 * TRACK_DISTANCE_ROTATE, yc1 + ey2 * TRACK_DISTANCE_ROTATE, TRACK_CIRCLE_RADIUS); -// -// ctx.fillStyle = _style_green; -// ctx.fill(); -// ctx.stroke(); -// } -// else -// { -// if (window.g_track_rotate_marker.asc_complete) -// { -// var _xI = xc1 + ex2 * TRACK_DISTANCE_ROTATE; -// var _yI = yc1 + ey2 * TRACK_DISTANCE_ROTATE; -// var _w = IMAGE_ROTATE_TRACK_W; -// var _w2 = IMAGE_ROTATE_TRACK_W / 2; -// -// if (nIsCleverWithTransform) -// { -// _xI >>= 0; -// _yI >>= 0; -// _w2 >>= 0; -// _w2 += 1; -// } -// -// //ctx.setTransform(ex1, ey1, -ey1, ex1, _xI, _yI); -// -// var _matrix = matrix.CreateDublicate(); -// _matrix.tx = 0; -// _matrix.ty = 0; -// var _xx = _matrix.TransformPointX(0, 1); -// var _yy = _matrix.TransformPointY(0, 1); -// var _angle = Math.atan2(_xx, -_yy) - Math.PI; -// var _px = Math.cos(_angle); -// var _py = Math.sin(_angle); -// -// ctx.translate(_xI, _yI); -// ctx.transform(_px, _py, -_py, _px, 0, 0); -// ctx.drawImage(window.g_track_rotate_marker, -_w2, -_w2, _w, _w); -// ctx.setTransform(1, 0, 0, 1, 0, 0); -// -// overlay.CheckRect(_xI - _w2, _yI - _w2, _w, _w); -// } -// } -// -// ctx.beginPath(); -// -// if (!nIsCleverWithTransform) -// { -// ctx.moveTo(xc1, yc1); -// ctx.lineTo(xc1 + ex2 * TRACK_DISTANCE_ROTATE2, yc1 + ey2 * TRACK_DISTANCE_ROTATE2); -// } -// else -// { -// ctx.moveTo((xc1 >> 0) + 0.5, (yc1 >> 0) + 0.5); -// ctx.lineTo(((xc1 + ex2 * TRACK_DISTANCE_ROTATE2) >> 0) + 0.5, ((yc1 + ey2 * TRACK_DISTANCE_ROTATE2) >> 0) + 0.5); -// } -// -// ctx.stroke(); -// -// ctx.beginPath(); -// -// } -// -// ctx.fillStyle = _style_white; -// -// if (!nIsCleverWithTransform) -// { -// if (bIsEllipceCorner) -// { -// overlay.AddEllipse(x1, y1, TRACK_CIRCLE_RADIUS); -// overlay.AddEllipse(x2, y2, TRACK_CIRCLE_RADIUS); -// overlay.AddEllipse(x3, y3, TRACK_CIRCLE_RADIUS); -// overlay.AddEllipse(x4, y4, TRACK_CIRCLE_RADIUS); -// } -// else -// { -// overlay.AddRect3(x1, y1, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2); -// overlay.AddRect3(x2, y2, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2); -// overlay.AddRect3(x3, y3, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2); -// overlay.AddRect3(x4, y4, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2); -// } -// } -// else -// { -// if (bIsEllipceCorner) -// { -// overlay.AddEllipse(x1, y1, TRACK_CIRCLE_RADIUS); -// overlay.AddEllipse(x2, y2, TRACK_CIRCLE_RADIUS); -// overlay.AddEllipse(x3, y3, TRACK_CIRCLE_RADIUS); -// overlay.AddEllipse(x4, y4, TRACK_CIRCLE_RADIUS); -// } -// else -// { -// overlay.AddRect2(_x1 + 0.5, _y1 + 0.5, TRACK_RECT_SIZE); -// overlay.AddRect2(_x2 + 0.5, _y2 + 0.5, TRACK_RECT_SIZE); -// overlay.AddRect2(_x3 + 0.5, _y3 + 0.5, TRACK_RECT_SIZE); -// overlay.AddRect2(_x4 + 0.5, _y4 + 0.5, TRACK_RECT_SIZE); -// } -// } -// -// if (!nIsCleverWithTransform) -// { -// if (bIsRectsTrack) -// { -// if (bIsRectsTrackX) -// { -// overlay.AddRect3((x1 + x2) / 2, (y1 + y2) / 2, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2); -// overlay.AddRect3((x3 + x4) / 2, (y3 + y4) / 2, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2); -// } -// if (bIsRectsTrackY) -// { -// overlay.AddRect3((x2 + x4) / 2, (y2 + y4) / 2, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2); -// overlay.AddRect3((x3 + x1) / 2, (y3 + y1) / 2, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2); -// } -// } -// } -// else -// { -// if (bIsRectsTrack) -// { -// var _xC = (((_x1 + _x2) / 2) >> 0) + 0.5; -// var _yC = (((_y1 + _y3) / 2) >> 0) + 0.5; -// -// if (bIsRectsTrackX) -// { -// overlay.AddRect2(_xC, _y1+0.5, TRACK_RECT_SIZE); -// overlay.AddRect2(_xC, _y3+0.5, TRACK_RECT_SIZE); -// } -// if (bIsRectsTrackY) -// { -// overlay.AddRect2(_x2+0.5, _yC, TRACK_RECT_SIZE); -// overlay.AddRect2(_x1+0.5, _yC, TRACK_RECT_SIZE); -// } -// } -// } -// -// ctx.fill(); -// ctx.stroke(); -// -// ctx.beginPath(); -// } -// -// break; -// } -// case AscFormat.TYPE_TRACK.EMPTY_PH: -// { -// if (bIsClever) -// { -// overlay.CheckRect(x1, y1, x4 - x1, y4 - y1); -// ctx.rect(x1 + 0.5, y2 + 0.5, x4 - x1 + 1, y4 - y1); -// ctx.fillStyle = _style_white; -// ctx.stroke(); -// -// ctx.beginPath(); -// -// this.AddRectDashClever(ctx, x1, y1, x4, y4, 8, 3); -// -// ctx.strokeStyle = _style_blue; -// ctx.stroke(); -// -// ctx.beginPath(); -// -// var xC = ((x1 + x2) / 2) >> 0; -// -// if (!bIsUseImageRotateTrack) -// { -// ctx.beginPath(); -// overlay.AddEllipse(xC, y1 - TRACK_DISTANCE_ROTATE); -// -// ctx.fillStyle = _style_green; -// ctx.fill(); -// ctx.stroke(); -// } -// else -// { -// if (window.g_track_rotate_marker.asc_complete) -// { -// var _w = IMAGE_ROTATE_TRACK_W; -// var _xI = ((x1 + x2 - _w) / 2) >> 0; -// var _yI = y1 - TRACK_DISTANCE_ROTATE - (_w >> 1); -// -// overlay.CheckRect(_xI, _yI, _w, _w); -// ctx.drawImage(window.g_track_rotate_marker, _xI, _yI, _w, _w); -// } -// } -// -// ctx.beginPath(); -// ctx.moveTo(xC + 0.5, y1); -// ctx.lineTo(xC + 0.5, y1 - TRACK_DISTANCE_ROTATE2); -// ctx.stroke(); -// -// ctx.beginPath(); -// -// ctx.fillStyle = _style_white; -// -// if (bIsEllipceCorner) -// { -// overlay.AddEllipse(x1, y1, TRACK_CIRCLE_RADIUS); -// overlay.AddEllipse(x2, y2, TRACK_CIRCLE_RADIUS); -// overlay.AddEllipse(x3, y3, TRACK_CIRCLE_RADIUS); -// overlay.AddEllipse(x4, y4, TRACK_CIRCLE_RADIUS); -// } -// else -// { -// overlay.AddRect2(x1 + 0.5, y1 + 0.5, TRACK_RECT_SIZE); -// overlay.AddRect2(x2 + 0.5, y2 + 0.5, TRACK_RECT_SIZE); -// overlay.AddRect2(x3 + 0.5, y3 + 0.5, TRACK_RECT_SIZE); -// overlay.AddRect2(x4 + 0.5, y4 + 0.5, TRACK_RECT_SIZE); -// } -// -// if (bIsRectsTrack && false) -// { -// var _xC = (((x1 + x2) / 2) >> 0) + 0.5; -// var _yC = (((y1 + y3) / 2) >> 0) + 0.5; -// -// overlay.AddRect2(_xC, y1+0.5, TRACK_RECT_SIZE); -// overlay.AddRect2(x2+0.5, _yC, TRACK_RECT_SIZE); -// overlay.AddRect2(_xC, y3+0.5, TRACK_RECT_SIZE); -// overlay.AddRect2(x1+0.5, _yC, TRACK_RECT_SIZE); -// } -// -// ctx.fill(); -// ctx.stroke(); -// -// ctx.beginPath(); -// } -// else -// { -// overlay.CheckPoint(x1, y1); -// overlay.CheckPoint(x2, y2); -// overlay.CheckPoint(x3, y3); -// overlay.CheckPoint(x4, y4); -// -// ctx.moveTo(x1, y1); -// ctx.lineTo(x2, y2); -// ctx.lineTo(x3, y3); -// ctx.lineTo(x4, y4); -// ctx.closePath(); -// -// overlay.CheckPoint(x1, y1); -// overlay.CheckPoint(x2, y2); -// overlay.CheckPoint(x3, y3); -// overlay.CheckPoint(x4, y4); -// -// ctx.strokeStyle = _style_white; -// ctx.stroke(); -// -// ctx.beginPath(); -// -// this.AddRectDash(ctx, x1, y1, x2, y2, x3, y3, x4, y4, 8, 3); -// -// ctx.strokeStyle = _style_blue; -// ctx.stroke(); -// -// var ex1 = (x2 - x1) / _len_x; -// var ey1 = (y2 - y1) / _len_x; -// var ex2 = (x1 - x3) / _len_y; -// var ey2 = (y1 - y3) / _len_y; -// -// var _bAbsX1 = Math.abs(ex1) < 0.01; -// var _bAbsY1 = Math.abs(ey1) < 0.01; -// var _bAbsX2 = Math.abs(ex2) < 0.01; -// var _bAbsY2 = Math.abs(ey2) < 0.01; -// -// if (_bAbsX2 && _bAbsY2) -// { -// if (_bAbsX1 && _bAbsY1) -// { -// ex1 = 1; -// ey1 = 0; -// ex2 = 0; -// ey2 = 1; -// } -// else -// { -// ex2 = -ey1; -// ey2 = ex1; -// } -// } -// else if (_bAbsX1 && _bAbsY1) -// { -// ex1 = ey2; -// ey1 = -ex2; -// } -// -// var xc1 = (x1 + x2) / 2; -// var yc1 = (y1 + y2) / 2; -// -// ctx.beginPath(); -// -// if (!bIsUseImageRotateTrack) -// { -// ctx.beginPath(); -// overlay.AddEllipse(xc1 + ex2 * TRACK_DISTANCE_ROTATE, yc1 + ey2 * TRACK_DISTANCE_ROTATE, TRACK_DISTANCE_ROTATE); -// -// ctx.fillStyle = _style_green; -// ctx.fill(); -// ctx.stroke(); -// } -// else -// { -// if (window.g_track_rotate_marker.asc_complete) -// { -// var _xI = xc1 + ex2 * TRACK_DISTANCE_ROTATE; -// var _yI = yc1 + ey2 * TRACK_DISTANCE_ROTATE; -// var _w = IMAGE_ROTATE_TRACK_W; -// var _w2 = IMAGE_ROTATE_TRACK_W / 2; -// -// ctx.setTransform(ex1, ey1, -ey1, ex1, _xI, _yI); -// ctx.drawImage(window.g_track_rotate_marker, -_w2, -_w2, _w, _w); -// ctx.setTransform(1, 0, 0, 1, 0, 0); -// -// overlay.CheckRect(_xI - _w2, _yI - _w2, _w, _w); -// } -// } -// -// ctx.beginPath(); -// ctx.moveTo(xc1, yc1); -// ctx.lineTo(xc1 + ex2 * TRACK_DISTANCE_ROTATE2, yc1 + ey2 * TRACK_DISTANCE_ROTATE2); -// ctx.stroke(); -// -// ctx.beginPath(); -// -// ctx.fillStyle = _style_white; -// -// if (bIsEllipceCorner) -// { -// overlay.AddEllipse(x1, y1, TRACK_CIRCLE_RADIUS); -// overlay.AddEllipse(x2, y2, TRACK_CIRCLE_RADIUS); -// overlay.AddEllipse(x3, y3, TRACK_CIRCLE_RADIUS); -// overlay.AddEllipse(x4, y4, TRACK_CIRCLE_RADIUS); -// } -// else -// { -// overlay.AddRect3(x1, y1, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2); -// overlay.AddRect3(x2, y2, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2); -// overlay.AddRect3(x3, y3, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2); -// overlay.AddRect3(x4, y4, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2); -// } -// -// if (bIsRectsTrack) -// { -// overlay.AddRect3((x1 + x2) / 2, (y1 + y2) / 2, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2); -// overlay.AddRect3((x2 + x4) / 2, (y2 + y4) / 2, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2); -// overlay.AddRect3((x3 + x4) / 2, (y3 + y4) / 2, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2); -// overlay.AddRect3((x3 + x1) / 2, (y3 + y1) / 2, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2); -// } -// -// ctx.fill(); -// ctx.stroke(); -// -// ctx.beginPath(); -// } -// -// break; -// } -// -// default: -// break; -// } -// -// ctx.globalAlpha = _oldGlobalAlpha; - }, - - DrawTrackSelectShapes : function(x, y, w, h) - { - this.Native["DD_DrawTrackSelectShapes"](x, y, w, h); - -// var overlay = this.m_oOverlay; -// overlay.Show(); -// -// this.CurrentPageInfo = overlay.m_oHtmlPage.GetDrawingPageInfo(this.PageIndex); -// -// var drPage = this.CurrentPageInfo.drawingPage; -// -// var xDst = drPage.left + (this.Graphics ? this.Graphics.m_oCoordTransform.tx : 0); -// var yDst = drPage.top + (this.Graphics ? this.Graphics.m_oCoordTransform.ty : 0); -// var wDst = drPage.right - drPage.left; -// var hDst = drPage.bottom - drPage.top; -// -// var dKoefX = wDst / this.CurrentPageInfo.width_mm; -// var dKoefY = hDst / this.CurrentPageInfo.height_mm; -// -// var x1 = (xDst + dKoefX * x) >> 0; -// var y1 = (yDst + dKoefY * y) >> 0; -// -// var x2 = (xDst + dKoefX * (x + w)) >> 0; -// var y2 = (yDst + dKoefY * (y + h)) >> 0; -// -// if (x1 > x2) -// { -// var tmp = x1; -// x1 = x2; -// x2 = tmp; -// } -// if (y1 > y2) -// { -// var tmp = y1; -// y1 = y2; -// y2 = tmp; -// } -// -// overlay.CheckRect(x1, y1, x2 - x1, y2 - y1); -// var ctx = overlay.m_oContext; -// ctx.setTransform(1, 0, 0, 1, 0, 0); -// -// var globalAlphaOld = ctx.globalAlpha; -// ctx.globalAlpha = 0.5; -// ctx.beginPath(); -// ctx.fillStyle = "rgba(51,102,204,255)"; -// ctx.strokeStyle = "#9ADBFE"; -// ctx.lineWidth = 1; -// ctx.fillRect(x1, y1, x2 - x1, y2 - y1); -// ctx.beginPath(); -// ctx.strokeRect(x1 - 0.5, y1 - 0.5, x2 - x1 + 1, y2 - y1 + 1); -// ctx.globalAlpha = globalAlphaOld; - }, - - DrawTrackDashRect : function(left, top, width, height, matrix) - { - console.log('DrawTrackDashRect !!!!!!!!!!!!!!!!!'); - -// var overlay = this.m_oOverlay; -// overlay.Show(); -// -// this.CurrentPageInfo = overlay.m_oHtmlPage.GetDrawingPageInfo(this.PageIndex); -// -// var drPage = this.CurrentPageInfo.drawingPage; -// -// var xDst = drPage.left + (this.Graphics ? this.Graphics.m_oCoordTransform.tx : 0); -// var yDst = drPage.top + (this.Graphics ? this.Graphics.m_oCoordTransform.ty : 0); -// var wDst = drPage.right - drPage.left; -// var hDst = drPage.bottom - drPage.top; -// -// var dKoefX = wDst / this.CurrentPageInfo.width_mm; -// var dKoefY = hDst / this.CurrentPageInfo.height_mm; -// -// var r = x + width; -// var b = y + height; -// -// var x1 = (xDst + dKoefX * (matrix.TransformPointX(left, top))) >> 0; -// var y1 = (yDst + dKoefY * (matrix.TransformPointY(left, top))) >> 0; -// -// var x2 = (xDst + dKoefX * (matrix.TransformPointX(r, top))) >> 0; -// var y2 = (yDst + dKoefY * (matrix.TransformPointY(r, top))) >> 0; -// -// var x3 = (xDst + dKoefX * (matrix.TransformPointX(left, b))) >> 0; -// var y3 = (yDst + dKoefY * (matrix.TransformPointY(left, b))) >> 0; -// -// var x4 = (xDst + dKoefX * (matrix.TransformPointX(r, b))) >> 0; -// var y4 = (yDst + dKoefY * (matrix.TransformPointY(r, b))) >> 0; -// -// var bIsClever = false; -// if (x1 == x3 && x2 == x4 && y1 == y2 && y3 == y4 && x1 < x2 && y1 < y3) -// bIsClever = true; -// -// var ctx = overlay.m_oContext; -// ctx.beginPath(); -// ctx.lineWidth = 1; -// ctx.strokeStyle = "#0000FF"; -// -// overlay.CheckPoint(x1, y1); -// overlay.CheckPoint(x2, y2); -// overlay.CheckPoint(x3, y3); -// overlay.CheckPoint(x4, y4); -// -// if (bIsClever) -// this.AddRectDashClever(ctx, x1, y1, x4, y4, 3, 2); -// else -// this.AddRectDash(ctx, x1, y1, x2, y2, x3, y3, x4, y4, 3, 2); -// -// ctx.stroke(); -// ctx.beginPath(); - }, - - AddRect : function(ctx, x, y, r, b, bIsClever) - { - console.log('AddRect !!!!!!!!!!!!!!!'); - -// if (bIsClever) -// ctx.rect(x + 0.5, y + 0.5, r - x + 1, b - y + 1); -// else -// { -// ctx.moveTo(x,y); -// ctx.rect(x, y, r - x + 1, b - y + 1); -// } - }, - - AddRectDashClever : function(ctx, x, y, r, b, w_dot, w_dist, bIsStrokeAndCanUseNative) - { - console.log('AddRectDashClever !!!!!!!!!!!!!!!'); - -// var _support_native_dash = (undefined !== ctx.setLineDash); -// -// var _x = x + 0.5; -// var _y = y + 0.5; -// var _r = r + 0.5; -// var _b = b + 0.5; -// -// if (_support_native_dash && bIsStrokeAndCanUseNative === true) -// { -// ctx.setLineDash([w_dot, w_dist]); -// -// //ctx.rect(x + 0.5, y + 0.5, r - x, b - y); -// ctx.moveTo(x, _y); -// ctx.lineTo(r - 1, _y); -// -// ctx.moveTo(_r, y); -// ctx.lineTo(_r, b - 1); -// -// ctx.moveTo(r + 1, _b); -// ctx.lineTo(x + 2, _b); -// -// ctx.moveTo(_x, b + 1); -// ctx.lineTo(_x, y + 2); -// -// ctx.stroke(); -// ctx.setLineDash([]); -// return; -// } -// -// for (var i = _x; i < _r; i += w_dist) -// { -// ctx.moveTo(i, _y); -// i += w_dot; -// -// if (i > _r) -// i = _r; -// -// ctx.lineTo(i, _y); -// } -// for (var i = _y; i < _b; i += w_dist) -// { -// ctx.moveTo(_r, i); -// i += w_dot; -// -// if (i > _b) -// i = _b; -// -// ctx.lineTo(_r, i); -// } -// for (var i = _r; i > _x; i -= w_dist) -// { -// ctx.moveTo(i, _b); -// i -= w_dot; -// -// if (i < _x) -// i = _x; -// -// ctx.lineTo(i, _b); -// } -// for (var i = _b; i > _y; i -= w_dist) -// { -// ctx.moveTo(_x, i); -// i -= w_dot; -// -// if (i < _y) -// i = _y; -// -// ctx.lineTo(_x, i); -// } -// -// if (bIsStrokeAndCanUseNative) -// ctx.stroke(); - }, - - AddLineDash : function(ctx, x1, y1, x2, y2, w_dot, w_dist) - { - console.log('AddLineDash !!!!!!!!!!!!!!!'); - -// var len = Math.sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)); -// if (len < 1) -// len = 1; -// -// var len_x1 = Math.abs(w_dot*(x2-x1)/len); -// var len_y1 = Math.abs(w_dot*(y2-y1)/len); -// var len_x2 = Math.abs(w_dist*(x2-x1)/len); -// var len_y2 = Math.abs(w_dist*(y2-y1)/len); -// -// if (x1 <= x2 && y1 <= y2) -// { -// for (var i = x1, j = y1; i < x2 || j < y2; i += len_x2, j += len_y2) -// { -// ctx.moveTo(i, j); -// -// i += len_x1; -// j += len_y1; -// -// if (i > x2) -// i = x2; -// if (j > y2) -// j = y2; -// -// ctx.lineTo(i, j); -// } -// } -// else if (x1 <= x2 && y1 > y2) -// { -// for (var i = x1, j = y1; i < x2 || j > y2; i += len_x2, j -= len_y2) -// { -// ctx.moveTo(i, j); -// -// i += len_x1; -// j -= len_y1; -// -// if (i > x2) -// i = x2; -// if (j < y2) -// j = y2; -// -// ctx.lineTo(i, j); -// } -// } -// else if (x1 > x2 && y1 <= y2) -// { -// for (var i = x1, j = y1; i > x2 || j < y2; i -= len_x2, j += len_y2) -// { -// ctx.moveTo(i, j); -// -// i -= len_x1; -// j += len_y1; -// -// if (i < x2) -// i = x2; -// if (j > y2) -// j = y2; -// -// ctx.lineTo(i, j); -// } -// } -// else -// { -// for (var i = x1, j = y1; i > x2 || j > y2; i -= len_x2, j -= len_y2) -// { -// ctx.moveTo(i, j); -// -// i -= len_x1; -// j -= len_y1; -// -// if (i < x2) -// i = x2; -// if (j < y2) -// j = y2; -// -// ctx.lineTo(i, j); -// } -// } - }, - - AddRectDash : function(ctx, x1, y1, x2, y2, x3, y3, x4, y4, w_dot, w_dist, bIsStrokeAndCanUseNative) - { - console.log('AddRectDash !!!!!!!!!!!!!!!'); - -// var _support_native_dash = (undefined !== ctx.setLineDash); -// -// if (_support_native_dash && bIsStrokeAndCanUseNative === true) -// { -// ctx.setLineDash([w_dot, w_dist]); -// -// ctx.moveTo(x1, y1); -// ctx.lineTo(x2, y2); -// ctx.lineTo(x4, y4); -// ctx.lineTo(x3, y3); -// ctx.closePath(); -// -// ctx.stroke(); -// ctx.setLineDash([]); -// return; -// } -// -// this.AddLineDash(ctx, x1, y1, x2, y2, w_dot, w_dist); -// this.AddLineDash(ctx, x2, y2, x4, y4, w_dot, w_dist); -// this.AddLineDash(ctx, x4, y4, x3, y3, w_dot, w_dist); -// this.AddLineDash(ctx, x3, y3, x1, y1, w_dot, w_dist); -// -// if (bIsStrokeAndCanUseNative) -// ctx.stroke(); - }, - - DrawAdjustment : function(matrix, x, y, bTextWarp) - { - if (!matrix) - this.Native["DD_DrawTrackTransform"](); - else - this.Native["DD_DrawTrackTransform"](matrix.sx, matrix.shy, matrix.shx, matrix.sy, matrix.tx, matrix.ty); - - this.Native["DD_DrawAdjustment"](x, y); - -// var overlay = this.m_oOverlay; -// this.CurrentPageInfo = overlay.m_oHtmlPage.GetDrawingPageInfo(this.PageIndex); -// -// var drPage = this.CurrentPageInfo.drawingPage; -// -// var xDst = drPage.left + (this.Graphics ? this.Graphics.m_oCoordTransform.tx : 0); -// var yDst = drPage.top + (this.Graphics ? this.Graphics.m_oCoordTransform.ty : 0); -// var wDst = drPage.right - drPage.left; -// var hDst = drPage.bottom - drPage.top; -// -// var dKoefX = wDst / this.CurrentPageInfo.width_mm; -// var dKoefY = hDst / this.CurrentPageInfo.height_mm; -// -// var cx = (xDst + dKoefX * (matrix.TransformPointX(x, y))) >> 0; -// var cy = (yDst + dKoefY * (matrix.TransformPointY(x, y))) >> 0; -// -// var _style_blue = "#4D7399"; -// var _style_yellow = "#FDF54A"; -// var _style_text_adj = "#F888FF"; -// -// var ctx = overlay.m_oContext; -// -// var dist = TRACK_ADJUSTMENT_SIZE / 2; -// ctx.moveTo(cx - dist, cy); -// ctx.lineTo(cx, cy - dist); -// ctx.lineTo(cx + dist, cy); -// ctx.lineTo(cx, cy + dist); -// ctx.closePath(); -// -// overlay.CheckRect(cx - dist, cy - dist, TRACK_ADJUSTMENT_SIZE, TRACK_ADJUSTMENT_SIZE); -// -// if(bTextWarp === true) -// { -// ctx.fillStyle = _style_text_adj; -// } -// else -// { -// ctx.fillStyle = _style_yellow; -// } -// ctx.strokeStyle = _style_blue; -// -// ctx.fill(); -// ctx.stroke(); -// ctx.beginPath(); - }, - - - DrawGeomEditPoint: function(matrix, gmEditPoint) - { - }, - - DrawGeometryEdit: function (matrix, pathLst, gmEditList, gmEditPoint, oBounds) - { - }, - - DrawEditWrapPointsPolygon : function(points, matrix) - { - if (!matrix) - this.Native["DD_DrawTrackTransform"](); - else - this.Native["DD_DrawTrackTransform"](matrix.sx, matrix.shy, matrix.shx, matrix.sy, matrix.tx, matrix.ty); - - this.Native["DD_DrawEditWrapPointsPolygon"](points); - -// var _len = points.length; -// if (0 == _len) -// return; -// -// var overlay = this.m_oOverlay; -// var ctx = overlay.m_oContext; -// -// this.CurrentPageInfo = overlay.m_oHtmlPage.GetDrawingPageInfo(this.PageIndex); -// -// var drPage = this.CurrentPageInfo.drawingPage; -// -// var xDst = drPage.left; -// var yDst = drPage.top; -// var wDst = drPage.right - drPage.left; -// var hDst = drPage.bottom - drPage.top; -// -// var dKoefX = wDst / this.CurrentPageInfo.width_mm; -// var dKoefY = hDst / this.CurrentPageInfo.height_mm; -// -// var _tr_points_x = new Array(_len); -// var _tr_points_y = new Array(_len); -// for (var i = 0; i < _len; i++) -// { -// _tr_points_x[i] = (xDst + dKoefX * (matrix.TransformPointX(points[i].x, points[i].y))) >> 0; -// _tr_points_y[i] = (yDst + dKoefY * (matrix.TransformPointY(points[i].x, points[i].y))) >> 0; -// } -// -// ctx.beginPath(); -// for (var i = 0; i < _len; i++) -// { -// if (0 == i) -// ctx.moveTo(_tr_points_x[i], _tr_points_y[i]); -// else -// ctx.lineTo(_tr_points_x[i], _tr_points_y[i]); -// -// overlay.CheckPoint(_tr_points_x[i], _tr_points_y[i]); -// } -// -// ctx.closePath(); -// ctx.lineWidth = 1; -// ctx.strokeStyle = "#FF0000"; -// ctx.stroke(); -// -// ctx.beginPath(); -// for (var i = 0; i < _len; i++) -// { -// overlay.AddRect2(_tr_points_x[i] + 0.5, _tr_points_y[i] + 0.5, TRACK_WRAPPOINTS_SIZE); -// } -// ctx.strokeStyle = "#FFFFFF"; -// ctx.fillStyle = "#000000"; -// ctx.fill(); -// ctx.stroke(); -// -// ctx.beginPath(); - }, - - DrawEditWrapPointsTrackLines : function(points, matrix) - { - if (!matrix) - this.Native["DD_DrawTrackTransform"](); - else - this.Native["DD_DrawTrackTransform"](matrix.sx, matrix.shy, matrix.shx, matrix.sy, matrix.tx, matrix.ty); - - this.Native["DD_DrawEditWrapPointsTrackLines"](points); - - -// var _len = points.length; -// if (0 == _len) -// return; -// -// var overlay = this.m_oOverlay; -// var ctx = overlay.m_oContext; -// -// this.CurrentPageInfo = overlay.m_oHtmlPage.GetDrawingPageInfo(this.PageIndex); -// -// var drPage = this.CurrentPageInfo.drawingPage; -// -// var xDst = drPage.left; -// var yDst = drPage.top; -// var wDst = drPage.right - drPage.left; -// var hDst = drPage.bottom - drPage.top; -// -// var dKoefX = wDst / this.CurrentPageInfo.width_mm; -// var dKoefY = hDst / this.CurrentPageInfo.height_mm; -// -// var _tr_points_x = new Array(_len); -// var _tr_points_y = new Array(_len); -// for (var i = 0; i < _len; i++) -// { -// _tr_points_x[i] = (xDst + dKoefX * (matrix.TransformPointX(points[i].x, points[i].y))) >> 0; -// _tr_points_y[i] = (yDst + dKoefY * (matrix.TransformPointY(points[i].x, points[i].y))) >> 0; -// } -// -// var globalAlpha = ctx.globalAlpha; -// ctx.globalAlpha = 1.0; -// -// ctx.beginPath(); -// for (var i = 0; i < _len; i++) -// { -// if (0 == i) -// ctx.moveTo(_tr_points_x[i], _tr_points_y[i]); -// else -// ctx.lineTo(_tr_points_x[i], _tr_points_y[i]); -// -// overlay.CheckPoint(_tr_points_x[i], _tr_points_y[i]); -// } -// ctx.lineWidth = 1; -// ctx.strokeStyle = "#FFFFFF"; -// ctx.stroke(); -// -// ctx.beginPath(); -// for (var i = 1; i < _len; i++) -// { -// this.AddLineDash(ctx, _tr_points_x[i-1], _tr_points_y[i-1], _tr_points_x[i], _tr_points_y[i], 4, 4); -// } -// ctx.lineWidth = 1; -// ctx.strokeStyle = "#000000"; -// ctx.stroke(); -// -// ctx.beginPath(); -// -// ctx.globalAlpha = globalAlpha; - }, - - DrawInlineMoveCursor : function(x, y, h, matrix) - { - if (!m) - { - this.Native["DD_DrawInlineMoveCursor"](this.PageIndex, x, y, h); - } - else - { - this.Native["DD_DrawInlineMoveCursor"](this.PageIndex, x, y, h, m.sx, m.shy, m.shx, m.sy, m.tx, m.ty); - } - -// var overlay = this.m_oOverlay; -// this.CurrentPageInfo = overlay.m_oHtmlPage.GetDrawingPageInfo(this.PageIndex); -// -// var drPage = this.CurrentPageInfo.drawingPage; -// -// var xDst = drPage.left; -// var yDst = drPage.top; -// var wDst = drPage.right - drPage.left; -// var hDst = drPage.bottom - drPage.top; -// -// var dKoefX = wDst / this.CurrentPageInfo.width_mm; -// var dKoefY = hDst / this.CurrentPageInfo.height_mm; -// -// var bIsIdentMatr = true; -// if (matrix !== undefined && matrix != null) -// { -// if (matrix.IsIdentity2()) -// { -// x += matrix.tx; -// y += matrix.ty; -// } -// else -// { -// bIsIdentMatr = false; -// } -// } -// -// if (bIsIdentMatr) -// { -// var __x = (xDst + dKoefX * x) >> 0; -// var __y = (yDst + dKoefY * y) >> 0; -// var __h = (h * dKoefY) >> 0; -// -// overlay.CheckRect(__x,__y,2,__h); -// -// var ctx = overlay.m_oContext; -// -// var _oldAlpha = ctx.globalAlpha; -// ctx.globalAlpha = 1; -// -// ctx.lineWidth = 1; -// ctx.strokeStyle = "#000000"; -// for (var i = 0; i < __h; i+=2) -// { -// ctx.moveTo(__x,__y+i+0.5); -// ctx.lineTo(__x+2,__y+i+0.5); -// } -// ctx.stroke(); -// -// ctx.beginPath(); -// ctx.strokeStyle = "#FFFFFF"; -// for (var i = 1; i < __h; i+=2) -// { -// ctx.moveTo(__x,__y+i+0.5); -// ctx.lineTo(__x+2,__y+i+0.5); -// } -// ctx.stroke(); -// -// ctx.globalAlpha = _oldAlpha; -// } -// else -// { -// var _x1 = matrix.TransformPointX(x, y); -// var _y1 = matrix.TransformPointY(x, y); -// -// var _x2 = matrix.TransformPointX(x, y + h); -// var _y2 = matrix.TransformPointY(x, y + h); -// -// _x1 = xDst + dKoefX * _x1; -// _y1 = yDst + dKoefY * _y1; -// -// _x2 = xDst + dKoefX * _x2; -// _y2 = yDst + dKoefY * _y2; -// -// overlay.CheckPoint(_x1, _y1); -// overlay.CheckPoint(_x2, _y2); -// -// var ctx = overlay.m_oContext; -// -// var _oldAlpha = ctx.globalAlpha; -// ctx.globalAlpha = 1; -// -// ctx.lineWidth = 2; -// ctx.beginPath(); -// ctx.strokeStyle = "#FFFFFF"; -// ctx.moveTo(_x1, _y1); -// ctx.lineTo(_x2, _y2); -// ctx.stroke(); -// ctx.beginPath(); -// -// ctx.strokeStyle = "#000000"; -// -// var _vec_len = Math.sqrt((_x2 - _x1)*(_x2 - _x1) + (_y2 - _y1)*(_y2 - _y1)); -// var _dx = (_x2 - _x1) / _vec_len; -// var _dy = (_y2 - _y1) / _vec_len; -// -// var __x = _x1; -// var __y = _y1; -// for (var i = 0; i < _vec_len; i += 2) -// { -// ctx.moveTo(__x, __y); -// -// __x += _dx; -// __y += _dy; -// -// ctx.lineTo(__x, __y); -// -// __x += _dx; -// __y += _dy; -// } -// ctx.stroke(); -// -// ctx.globalAlpha = _oldAlpha; -// } - }, - - drawFlowAnchor : function(x, y) - { - this.Native["PD_drawFlowAnchor"](x, y); - -// var _flow_anchor = (AscCommon.OverlayRasterIcons && AscCommon.OverlayRasterIcons.Anchor) ? AscCommon.OverlayRasterIcons.Anchor.get() : undefined; -// if (!_flow_anchor || (!editor || !editor.ShowParaMarks)) -// return; -// -// var overlay = this.m_oOverlay; -// this.CurrentPageInfo = overlay.m_oHtmlPage.GetDrawingPageInfo(this.PageIndex); -// -// var drPage = this.CurrentPageInfo.drawingPage; -// -// var xDst = drPage.left; -// var yDst = drPage.top; -// var wDst = drPage.right - drPage.left; -// var hDst = drPage.bottom - drPage.top; -// -// var dKoefX = wDst / this.CurrentPageInfo.width_mm; -// var dKoefY = hDst / this.CurrentPageInfo.height_mm; -// -// var __x = (xDst + dKoefX * x) >> 0; -// var __y = (yDst + dKoefY * y) >> 0; -// -// __x -= 8; -// -// overlay.CheckRect(__x,__y,16,17); -// -// var ctx = overlay.m_oContext; -// var _oldAlpha = ctx.globalAlpha; -// ctx.globalAlpha = 1; -// -// ctx.setTransform(1,0,0,1,0,0); -// -// ctx.drawImage(_flow_anchor, __x, __y); -// ctx.globalAlpha = _oldAlpha; - } -}; - -function CSlideBoundsChecker() -{ - this.map_bounds_shape = {}; - this.map_bounds_shape["heart"] = true; - - this.IsSlideBoundsCheckerType = true; - - this.Bounds = new CBoundsController(); - - this.m_oCurFont = null; - - this.m_oCoordTransform = new AscCommon.CMatrixL(); - this.m_oTransform = new AscCommon.CMatrixL(); - this.m_oFullTransform = new AscCommon.CMatrixL(); - - this.IsNoSupportTextDraw = true; - - this.LineWidth = null; - this.AutoCheckLineWidth = false; -} - -CSlideBoundsChecker.prototype = -{ - IsShapeNeedBounds : function(preset) - { - if (preset === undefined || preset == null) - return true; - return (true === this.map_bounds_shape[preset]) ? false : true; - }, - drawHorLine2 : function(preset) - { - }, - AddSmartRect: function() - {}, - - init : function(width_px, height_px, width_mm, height_mm) - { - this.m_lHeightPix = height_px; - this.m_lWidthPix = width_px; - this.m_dWidthMM = width_mm; - this.m_dHeightMM = height_mm; - this.m_dDpiX = 25.4 * this.m_lWidthPix / this.m_dWidthMM; - this.m_dDpiY = 25.4 * this.m_lHeightPix / this.m_dHeightMM; - - this.m_oCoordTransform.sx = this.m_dDpiX / 25.4; - this.m_oCoordTransform.sy = this.m_dDpiY / 25.4; - - this.Bounds.ClearNoAttack(); - }, - - SetCurrentPage: function() - {}, - - GetIntegerGrid: function() - { - return false; - }, - - GetTextPr: function() - {}, - - EndDraw : function(){}, - put_GlobalAlpha : function(enable, alpha) - { - }, - // pen methods - p_color : function(r,g,b,a) - { - }, - p_width : function(w) - { - }, - // brush methods - b_color1 : function(r,g,b,a) - { - }, - b_color2 : function(r,g,b,a) - { - }, - - SetIntegerGrid : function() - { - }, - - transform : function(sx,shy,shx,sy,tx,ty) - { - this.m_oTransform.sx = sx; - this.m_oTransform.shx = shx; - this.m_oTransform.shy = shy; - this.m_oTransform.sy = sy; - this.m_oTransform.tx = tx; - this.m_oTransform.ty = ty; - - this.CalculateFullTransform(); - }, - CalculateFullTransform : function() - { - this.m_oFullTransform.sx = this.m_oTransform.sx; - this.m_oFullTransform.shx = this.m_oTransform.shx; - this.m_oFullTransform.shy = this.m_oTransform.shy; - this.m_oFullTransform.sy = this.m_oTransform.sy; - this.m_oFullTransform.tx = this.m_oTransform.tx; - this.m_oFullTransform.ty = this.m_oTransform.ty; - AscCommon.global_MatrixTransformer.MultiplyAppend(this.m_oFullTransform, this.m_oCoordTransform); - }, - - SetTextPr: function() - {}, - - SetFontSlot: function() - {}, - - // path commands - _s : function() - { - }, - _e : function() - { - }, - _z : function() - { - }, - _m : function(x,y) - { - var _x = this.m_oFullTransform.TransformPointX(x,y); - var _y = this.m_oFullTransform.TransformPointY(x,y); - - this.Bounds.CheckPoint(_x, _y); - }, - _l : function(x,y) - { - var _x = this.m_oFullTransform.TransformPointX(x,y); - var _y = this.m_oFullTransform.TransformPointY(x,y); - - this.Bounds.CheckPoint(_x, _y); - }, - _c : function(x1,y1,x2,y2,x3,y3) - { - var _x1 = this.m_oFullTransform.TransformPointX(x1,y1); - var _y1 = this.m_oFullTransform.TransformPointY(x1,y1); - - var _x2 = this.m_oFullTransform.TransformPointX(x2,y2); - var _y2 = this.m_oFullTransform.TransformPointY(x2,y2); - - var _x3 = this.m_oFullTransform.TransformPointX(x3,y3); - var _y3 = this.m_oFullTransform.TransformPointY(x3,y3); - - this.Bounds.CheckPoint(_x1, _y1); - this.Bounds.CheckPoint(_x2, _y2); - this.Bounds.CheckPoint(_x3, _y3); - }, - _c2 : function(x1,y1,x2,y2) - { - var _x1 = this.m_oFullTransform.TransformPointX(x1,y1); - var _y1 = this.m_oFullTransform.TransformPointY(x1,y1); - - var _x2 = this.m_oFullTransform.TransformPointX(x2,y2); - var _y2 = this.m_oFullTransform.TransformPointY(x2,y2); - - this.Bounds.CheckPoint(_x1, _y1); - this.Bounds.CheckPoint(_x2, _y2); - }, - ds : function() - { - }, - df : function() - { - }, - - // canvas state - save : function() - { - }, - restore : function() - { - }, - clip : function() - { - }, - - reset : function() - { - this.m_oTransform.Reset(); - this.CalculateFullTransform(); - }, - - transform3 : function(m) - { - this.m_oTransform = m.CreateDublicate(); - this.CalculateFullTransform(); - }, - - transform00 : function(m) - { - this.m_oTransform = m.CreateDublicate(); - this.m_oTransform.tx = 0; - this.m_oTransform.ty = 0; - this.CalculateFullTransform(); - }, - - // images - drawImage2 : function(img,x,y,w,h) - { - var _x1 = this.m_oFullTransform.TransformPointX(x,y); - var _y1 = this.m_oFullTransform.TransformPointY(x,y); - - var _x2 = this.m_oFullTransform.TransformPointX(x+w,y); - var _y2 = this.m_oFullTransform.TransformPointY(x+w,y); - - var _x3 = this.m_oFullTransform.TransformPointX(x+w,y+h); - var _y3 = this.m_oFullTransform.TransformPointY(x+w,y+h); - - var _x4 = this.m_oFullTransform.TransformPointX(x,y+h); - var _y4 = this.m_oFullTransform.TransformPointY(x,y+h); - - this.Bounds.CheckPoint(_x1, _y1); - this.Bounds.CheckPoint(_x2, _y2); - this.Bounds.CheckPoint(_x3, _y3); - this.Bounds.CheckPoint(_x4, _y4); - }, - drawImage : function(img,x,y,w,h) - { - return this.drawImage2(img, x, y, w, h); - }, - - // text - font : function(font_id,font_size) - { - this.m_oFontManager.LoadFontFromFile(font_id, font_size, this.m_dDpiX, this.m_dDpiY); - }, - GetFont : function() - { - return this.m_oCurFont; - }, - SetFont : function(font) - { - this.m_oCurFont = font; - }, - FillText : function(x,y,text) - { - // убыстеренный вариант. здесь везде заточка на то, что приходит одна буква - if (this.m_bIsBreak) - return; - - // TODO: нужен другой метод отрисовки!!! - var _x = this.m_oFullTransform.TransformPointX(x, y); - var _y = this.m_oFullTransform.TransformPointY(x, y); - this.Bounds.CheckRect(_x, _y, 1, 1); - }, - - FillTextCode : function(x,y,lUnicode) - { - // убыстеренный вариант. здесь везде заточка на то, что приходит одна буква - if (this.m_bIsBreak) - return; - - // TODO: нужен другой метод отрисовки!!! - var _x = this.m_oFullTransform.TransformPointX(x, y); - var _y = this.m_oFullTransform.TransformPointY(x, y); - this.Bounds.CheckRect(_x, _y, 1, 1); - }, - - tg : function(gid,x,y) - { - // убыстеренный вариант. здесь везде заточка на то, что приходит одна буква - if (this.m_bIsBreak) - return; - - // TODO: нужен другой метод отрисовки!!! - var _x = this.m_oFullTransform.TransformPointX(x, y); - var _y = this.m_oFullTransform.TransformPointY(x, y); - this.Bounds.CheckRect(_x, _y, 1, 1); - }, - - t : function(text,x,y) - { - if (this.m_bIsBreak) - return; - - // TODO: нужен другой метод отрисовки!!! - var _x = this.m_oFullTransform.TransformPointX(x, y); - var _y = this.m_oFullTransform.TransformPointY(x, y); - this.Bounds.CheckRect(_x, _y, 1, 1); - }, - FillText2 : function(x,y,text,cropX,cropW) - { - // убыстеренный вариант. здесь везде заточка на то, что приходит одна буква - if (this.m_bIsBreak) - return; - - // TODO: нужен другой метод отрисовки!!! - var _x = this.m_oFullTransform.TransformPointX(x, y); - var _y = this.m_oFullTransform.TransformPointY(x, y); - this.Bounds.CheckRect(_x, _y, 1, 1); - }, - t2 : function(text,x,y,cropX,cropW) - { - if (this.m_bIsBreak) - return; - - // TODO: нужен другой метод отрисовки!!! - var _x = this.m_oFullTransform.TransformPointX(x, y); - var _y = this.m_oFullTransform.TransformPointY(x, y); - this.Bounds.CheckRect(_x, _y, 1, 1); - }, - charspace : function(space) - { - }, - - // private methods - DrawHeaderEdit : function(yPos) - { - }, - DrawFooterEdit : function(yPos) - { - }, - - DrawEmptyTableLine : function(x1,y1,x2,y2) - { - }, - - // smart methods for horizontal / vertical lines - drawHorLine : function(align, y, x, r, penW) - { - var _x1 = this.m_oFullTransform.TransformPointX(x,y-penW); - var _y1 = this.m_oFullTransform.TransformPointY(x,y-penW); - - var _x2 = this.m_oFullTransform.TransformPointX(x,y+penW); - var _y2 = this.m_oFullTransform.TransformPointY(x,y+penW); - - var _x3 = this.m_oFullTransform.TransformPointX(r,y-penW); - var _y3 = this.m_oFullTransform.TransformPointY(r,y-penW); - - var _x4 = this.m_oFullTransform.TransformPointX(r,y+penW); - var _y4 = this.m_oFullTransform.TransformPointY(r,y+penW); - - this.Bounds.CheckPoint(_x1, _y1); - this.Bounds.CheckPoint(_x2, _y2); - this.Bounds.CheckPoint(_x3, _y3); - this.Bounds.CheckPoint(_x4, _y4); - }, - drawVerLine : function(align, x, y, b, penW) - { - var _x1 = this.m_oFullTransform.TransformPointX(x-penW,y); - var _y1 = this.m_oFullTransform.TransformPointY(x-penW,y); - - var _x2 = this.m_oFullTransform.TransformPointX(x+penW,y); - var _y2 = this.m_oFullTransform.TransformPointY(x+penW,y); - - var _x3 = this.m_oFullTransform.TransformPointX(x-penW,b); - var _y3 = this.m_oFullTransform.TransformPointY(x-penW,b); - - var _x4 = this.m_oFullTransform.TransformPointX(x+penW,b); - var _y4 = this.m_oFullTransform.TransformPointY(x+penW,b); - - this.Bounds.CheckPoint(_x1, _y1); - this.Bounds.CheckPoint(_x2, _y2); - this.Bounds.CheckPoint(_x3, _y3); - this.Bounds.CheckPoint(_x4, _y4); - }, - - // мега крутые функции для таблиц - drawHorLineExt : function(align, y, x, r, penW, leftMW, rightMW) - { - this.drawHorLine(align, y, x + leftMW, r + rightMW); - }, - - rect : function(x,y,w,h) - { - var _x1 = this.m_oFullTransform.TransformPointX(x,y); - var _y1 = this.m_oFullTransform.TransformPointY(x,y); - - var _x2 = this.m_oFullTransform.TransformPointX(x+w,y); - var _y2 = this.m_oFullTransform.TransformPointY(x+w,y); - - var _x3 = this.m_oFullTransform.TransformPointX(x+w,y+h); - var _y3 = this.m_oFullTransform.TransformPointY(x+w,y+h); - - var _x4 = this.m_oFullTransform.TransformPointX(x,y+h); - var _y4 = this.m_oFullTransform.TransformPointY(x,y+h); - - this.Bounds.CheckPoint(_x1, _y1); - this.Bounds.CheckPoint(_x2, _y2); - this.Bounds.CheckPoint(_x3, _y3); - this.Bounds.CheckPoint(_x4, _y4); - }, - - rect2 : function(x,y,w,h) - { - var _x1 = this.m_oFullTransform.TransformPointX(x,y); - var _y1 = this.m_oFullTransform.TransformPointY(x,y); - - var _x2 = this.m_oFullTransform.TransformPointX(x+w,y); - var _y2 = this.m_oFullTransform.TransformPointY(x+w,y); - - var _x3 = this.m_oFullTransform.TransformPointX(x+w,y-h); - var _y3 = this.m_oFullTransform.TransformPointY(x+w,y-h); - - var _x4 = this.m_oFullTransform.TransformPointX(x,y-h); - var _y4 = this.m_oFullTransform.TransformPointY(x,y-h); - - this.Bounds.CheckPoint(_x1, _y1); - this.Bounds.CheckPoint(_x2, _y2); - this.Bounds.CheckPoint(_x3, _y3); - this.Bounds.CheckPoint(_x4, _y4); - }, - - TableRect : function(x,y,w,h) - { - this.rect(x, y, w, h); - }, - - // функции клиппирования - AddClipRect : function(x, y, w, h) - { - }, - RemoveClipRect : function() - { - }, - - SetClip : function(r) - { - }, - RemoveClip : function() - { - }, - - SavePen : function() - { - }, - RestorePen : function() - { - }, - - SaveBrush : function() - { - }, - RestoreBrush : function() - { - }, - - SavePenBrush : function() - { - }, - RestorePenBrush : function() - { - }, - - SaveGrState : function() - { - }, - RestoreGrState : function() - { - }, - - StartClipPath : function() - { - }, - - EndClipPath : function() - { - }, - - CorrectBounds : function() - { - if (this.LineWidth != null) - { - var _correct = this.LineWidth / 2.0; - - this.Bounds.min_x -= _correct; - this.Bounds.min_y -= _correct; - this.Bounds.max_x += _correct; - this.Bounds.max_y += _correct; - } - }, - - CorrectBounds2 : function() - { - if (this.LineWidth != null) - { - var _correct = this.LineWidth * this.m_oCoordTransform.sx / 2; - - this.Bounds.min_x -= _correct; - this.Bounds.min_y -= _correct; - this.Bounds.max_x += _correct; - this.Bounds.max_y += _correct; - } - } -}; - -//--------------------------------------------------------export---------------------------------------------------- -window['AscCommon'] = window['AscCommon'] || {}; -window['AscCommon'].COverlay = COverlay; -window['AscCommon'].TRACK_CIRCLE_RADIUS = TRACK_CIRCLE_RADIUS; -window['AscCommon'].TRACK_DISTANCE_ROTATE = TRACK_DISTANCE_ROTATE; -window['AscCommon'].CAutoshapeTrack = CAutoshapeTrack; diff --git a/cell/native/native.js b/cell/native/native.js deleted file mode 100644 index 0c4ab7b8d6..0000000000 --- a/cell/native/native.js +++ /dev/null @@ -1,5342 +0,0 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2023 - * - * This program is a free software product. You can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License (AGPL) - * version 3 as published by the Free Software Foundation. In accordance with - * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement - * of any third-party rights. - * - * This program is distributed WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ - -var _internalStorage = {}; - -function asc_ReadCBorder(s, p) { - var color = null; - var style = null; - var _continue = true; - while (_continue) - { - var _attr = s[p.pos++]; - switch (_attr) - { - case 0: - { - var type = s[p.pos++]; - if (type == "thin") { - style = Asc.c_oAscBorderStyles.Thin; - } else if (type == "medium") { - style = Asc.c_oAscBorderStyles.Medium; - } else if (type == "thick") { - style = Asc.c_oAscBorderStyles.Thick; - } - break; - } - case 1: - { - color = AscCommon.asc_menu_ReadColor(s, p); - break; - } - case 255: - default: - { - _continue = false; - break; - } - } - } - - if (color && style) { - return new Asc.asc_CBorder(style, color); - } - - return null; -} -function asc_ReadAdjustPrint(s, p) { - var adjustPrint = new window["Asc"].asc_CAdjustPrint(); - - var next = true; - while (next) - { - var _attr = s[p.pos++]; - switch (_attr) - { - case 0: - { - adjustPrint.asc_setPrintType(s[p.pos++]); - break; - } - case 1: - { - // ToDo что-то тут нужно поправить...Теперь нет asc_setLayoutPageType - //adjustPrint.asc_setLayoutPageType(s[p.pos++]); - break; - } - case 255: - default: - { - next = false; - break; - } - } - } - - return adjustPrint; -} -function asc_ReadCPageMargins(s, p) { - var pageMargins = new Asc.asc_CPageMargins(); - - var next = true; - while (next) - { - var _attr = s[p.pos++]; - switch (_attr) - { - case 0: - { - pageMargins.asc_setLeft(s[p.pos++]); - break; - } - case 1: - { - pageMargins.asc_setRight(s[p.pos++]); - break; - } - case 2: - { - pageMargins.asc_setTop(s[p.pos++]); - break; - } - case 3: - { - pageMargins.asc_setBottom(s[p.pos++]); - break; - } - - case 255: - default: - { - next = false; - break; - } - } - } - - return pageMargins; -} -function asc_ReadCPageSetup(s, p) { - var pageSetup = new Asc.asc_CPageSetup(); - - var next = true; - while (next) - { - var _attr = s[p.pos++]; - switch (_attr) - { - case 0: - { - pageSetup.asc_setOrientation(s[p.pos++]); - break; - } - case 1: - { - pageSetup.asc_setWidth(s[p.pos++]); - break; - } - case 2: - { - pageSetup.asc_setHeight(s[p.pos++]); - break; - } - - case 255: - default: - { - next = false; - break; - } - } - } - - return pageSetup; -} -function asc_ReadPageOptions(s, p) { - var pageOptions = new Asc.asc_CPageOptions(); - - var next = true; - while (next) - { - var _attr = s[p.pos++]; - switch (_attr) - { - case 0: - { - pageOptions.pageIndex = s[p.pos++]; - break; - } - case 1: - { - pageOptions.asc_setPageMargins(asc_ReadCPageMargins(s,p)); - break; - } - case 2: - { - pageOptions.asc_setPageSetup(asc_ReadCPageSetup(s,p)); - break; - } - case 3: - { - pageOptions.asc_setGridLines(s[p.pos++]); - break; - } - case 4: - { - pageOptions.asc_setHeadings(s[p.pos++]); - break; - } - case 255: - default: - { - next = false; - break; - } - } - } - - return pageOptions; -} -function asc_ReadCHyperLink(_params, _cursor) { - var _settings = new Asc.asc_CHyperlink(); - - var _continue = true; - while (_continue) - { - var _attr = _params[_cursor.pos++]; - switch (_attr) - { - case 0: - { - _settings.asc_setType(_params[_cursor.pos++]); - break; - } - case 1: - { - _settings.asc_setHyperlinkUrl(_params[_cursor.pos++]); - break; - } - case 2: - { - _settings.asc_setTooltip(_params[_cursor.pos++]); - break; - } - case 3: - { - _settings.asc_setLocation(_params[_cursor.pos++]); - break; - } - case 4: - { - _settings.asc_setSheet(_params[_cursor.pos++]); - break; - } - case 5: - { - _settings.asc_setRange(_params[_cursor.pos++]); - break; - } - case 6: - { - _settings.asc_setText(_params[_cursor.pos++]); - break; - } - case 255: - default: - { - _continue = false; - break; - } - } - } - - return _settings; -} -function asc_ReadAddFormatTableOptions(s, p) { - var format = new AscCommonExcel.AddFormatTableOptions(); - - var next = true; - while (next) - { - var _attr = s[p.pos++]; - switch (_attr) - { - case 0: - { - format.asc_setRange(s[p.pos++]); - break; - } - case 1: - { - format.asc_setIsTitle(s[p.pos++]); - break; - } - case 255: - default: - { - next = false; - break; - } - } - } - - return format; -} -function asc_ReadAutoFilter(s, p) { - var filter = {}; - - var next = true; - while (next) - { - var _attr = s[p.pos++]; - switch (_attr) - { - case 0: - { - filter.styleName = s[p.pos++]; - break; - } - case 1: - { - filter.format = asc_ReadAddFormatTableOptions(s, p); - break; - } - case 2: - { - filter.tableName = s[p.pos++]; - break; - } - case 3: - { - filter.optionType = s[p.pos++]; - break; - } - case 255: - default: - { - next = false; - break; - } - } - } - - return filter; -} -function asc_ReadAutoFilterObj(s, p) { - var filter = new Asc.AutoFilterObj(); - - var next = true; - while (next) - { - var _attr = s[p.pos++]; - switch (_attr) - { - case 0: - { - filter.asc_setType(s[p.pos++]); - break; - } - - // TODO: color, top10, - - case 255: - default: - { - next = false; - break; - } - } - } - - return filter; -} -function asc_ReadAutoFiltersOptionsElements(s, p) { - var filter = new AscCommonExcel.AutoFiltersOptionsElements(); - - var next = true; - while (next) - { - var _attr = s[p.pos++]; - switch (_attr) - { - case 0: - { - filter.asc_setIsDateFormat(s[p.pos++]); - break; - } - case 1: - { - filter.asc_setText(s[p.pos++]); - break; - } - case 2: - { - filter.asc_setVal(s[p.pos++]); - break; - } - case 3: - { - filter.asc_setVisible(s[p.pos++]); - break; - } - case 255: - default: - { - next = false; - break; - } - } - } - - return filter; -} - -function asc_ReadAutoFiltersOptions(s, p) { - var filter = new Asc.AutoFiltersOptions(); - - var next = true; - while (next) - { - var _attr = s[p.pos++]; - switch (_attr) - { - case 0: - { - filter.asc_setCellId(s[p.pos++]); - break; - } - case 1: - { - filter.asc_setDiplayName(s[p.pos++]); - break; - } - case 2: - { - filter.asc_setIsTextFilter(s[p.pos++]); - break; - } - case 3: - { - filter.asc_setSortState(s[p.pos++]); - break; - } - case 4: - { - filter.asc_setSortColor(AscCommon.asc_menu_ReadColor(s, p)); - break; - } - case 5: - { - filter.asc_setFilterObj(asc_ReadAutoFilterObj(s, p)); - break; - } - case 6: - { - var values = []; - var count = s[p.pos++]; - - for (var i = 0; i < count; ++i) { - p.pos++; - values.push(asc_ReadAutoFiltersOptionsElements(s,p)); - } - - filter.asc_setValues(values); - break; - } - case 255: - default: - { - next = false; - break; - } - } - } - - return filter; -} -function asc_ReadFormatTableInfo(s, p) { - var fmt = new AscCommonExcel.asc_CFormatTableInfo(); - var isNull = true; - var next = true; - while (next) - { - var _attr = s[p.pos++]; - switch (_attr) - { - case 0: - { - fmt.tableStyleName = s[p.pos++]; isNull = false; - break; - } - case 1: - { - fmt.tableRange = s[p.pos++]; isNull = false; - break; - } - case 2: - { - fmt.tableStyleName = s[p.pos++]; isNull = false; - break; - } - case 3: - { - fmt.bandHor = s[p.pos++]; isNull = false; - break; - } - case 4: - { - fmt.bandVer = s[p.pos++]; isNull = false; - break; - } - case 5: - { - fmt.filterButton = s[p.pos++]; isNull = false; - break; - } - case 6: - { - fmt.firstCol = s[p.pos++]; isNull = false; - break; - } - case 7: - { - fmt.firstRow = s[p.pos++]; isNull = false; - break; - } - case 8: - { - fmt.isDeleteColumn = s[p.pos++]; isNull = false; - break; - } - case 9: - { - fmt.isDeleteRow = s[p.pos++]; isNull = false; - break; - } - case 10: - { - fmt.isDeleteTable = s[p.pos++]; isNull = false; - break; - } - case 11: - { - fmt.isInsertColumnLeft = s[p.pos++]; isNull = false; - break; - } - case 12: - { - fmt.isInsertColumnRight = s[p.pos++]; isNull = false; - break; - } - case 13: - { - fmt.IsInsertRowAbove = s[p.pos++]; isNull = false; - break; - } - case 14: - { - fmt.isInsertRowBelow = s[p.pos++]; isNull = false; - break; - } - case 15: - { - fmt.lastCol = s[p.pos++]; isNull = false; - break; - } - case 16: - { - fmt.lastRow = s[p.pos++]; isNull = false; - break; - } - - case 255: - default: - { - next = false; - break; - } - } - } - - return isNull ? null : fmt; -} - -function asc_WriteCBorder(i, c, s) { - if (!c) return; - - s['WriteByte'](i); - - if (c.asc_getStyle()) { - s['WriteByte'](0); - s['WriteString2'](c.asc_getStyle()); - } - - if (c.asc_getColor()) { - s['WriteByte'](1); - s['WriteLong'](c.asc_getColor()); - } - - s['WriteByte'](255); -} -function asc_WriteCHyperLink(i, c, s) { - if (!c) return; - - s['WriteByte'](i); - - s['WriteByte'](0); - s['WriteLong'](c.asc_getType()); - - if (c.asc_getHyperlinkUrl()) { - s['WriteByte'](1); - s['WriteString2'](c.asc_getHyperlinkUrl()); - } - - if (c.asc_getTooltip()) { - s['WriteByte'](2); - s['WriteString2'](c.asc_getTooltip()); - } - - if (c.asc_getLocation()) { - s['WriteByte'](3); - s['WriteString2'](c.asc_getLocation()); - } - - if (c.asc_getSheet()) { - s['WriteByte'](4); - s['WriteString2'](c.asc_getSheet()); - } - - if (c.asc_getRange()) { - s['WriteByte'](5); - s['WriteString2'](c.asc_getRange()); - } - - if (c.asc_getText()) { - s['WriteByte'](6); - s['WriteString2'](c.asc_getText()); - } - - s['WriteByte'](255); -} -function asc_WriteCFont(i, c, s) { - if (!c) return; - - if (i !== -1) s['WriteByte'](i); - - s['WriteByte'](0); - s['WriteString2'](c.asc_getFontName()); - s['WriteDouble2'](c.asc_getFontSize()); - s['WriteBool'](c.asc_getFontBold()); - s['WriteBool'](c.asc_getFontItalic()); - s['WriteBool'](c.asc_getFontUnderline()); - s['WriteBool'](c.asc_getFontStrikeout()); - s['WriteBool'](c.asc_getFontSubscript()); - s['WriteBool'](c.asc_getFontSuperscript()); - - asc_menu_WriteColor(1, c.asc_getFontColor(), s); - - s['WriteByte'](255); -} -function asc_WriteCBorders(i, c, s) { - if (!c) return; - - s['WriteByte'](i); - - if (c.asc_getLeft()) asc_WriteCBorder(0, c.asc_getLeft(), s); - if (c.asc_getTop()) asc_WriteCBorder(0, c.asc_getTop(), s); - if (c.asc_getRight()) asc_WriteCBorder(0, c.asc_getRight(), s); - if (c.asc_getBottom()) asc_WriteCBorder(0, c.asc_getBottom(), s); - if (c.asc_getDiagDown()) asc_WriteCBorder(0, c.asc_getDiagDown(), s); - if (c.asc_getDiagUp()) asc_WriteCBorder(0, c.asc_getDiagUp(), s); - - s['WriteByte'](255); -} -function asc_WriteAutoFilterInfo(i, c, s) { - - if (i !== -1) s['WriteByte'](i); - - if (c.asc_getTableStyleName()) { - s['WriteByte'](0); - s['WriteString2'](c.asc_getTableStyleName()); - } - - if (c.asc_getTableName()) { - s['WriteByte'](1); - s['WriteString2'](c.asc_getTableName()); - } - if (null !== c.asc_getIsAutoFilter()) { - s['WriteByte'](2); - s['WriteBool'](c.asc_getIsAutoFilter()); - } - - if (null !== c.asc_getIsApplyAutoFilter()) { - s['WriteByte'](3); - s['WriteBool'](c.asc_getIsApplyAutoFilter()); - } - - s['WriteByte'](255); -} -function asc_WriteFormatTableInfo(i, c, s) { - - if (i !== -1) s['WriteByte'](i); - - if (c.asc_getTableName()) { - s['WriteByte'](0); - s['WriteString2'](c.asc_getTableName()); - } - - if (c.asc_getTableRange()) { - s['WriteByte'](1); - s['WriteString2'](c.asc_getTableRange()); - } - - if (c.asc_getTableStyleName()) { - s['WriteByte'](2); - s['WriteString2'](c.asc_getTableStyleName()); - } - - if (null !== c.asc_getBandHor()) { - s['WriteByte'](3); - s['WriteBool'](c.asc_getBandHor()); - } - - if (null !== c.asc_getBandVer()) { - s['WriteByte'](4); - s['WriteBool'](c.asc_getBandVer()); - } - - if (null !== c.asc_getFilterButton()) { - s['WriteByte'](5); - s['WriteBool'](c.asc_getFilterButton()); - } - - if (null !== c.asc_getFirstCol()) { - s['WriteByte'](6); - s['WriteBool'](c.asc_getFirstCol()); - } - - if (null !== c.asc_getFirstRow()) { - s['WriteByte'](7); - s['WriteBool'](c.asc_getFirstRow()); - } - - if (null !== c.asc_getIsDeleteColumn()) { - s['WriteByte'](8); - s['WriteBool'](c.asc_getIsDeleteColumn()); - } - - if (null !== c.asc_getIsDeleteRow()) { - s['WriteByte'](9); - s['WriteBool'](c.asc_getIsDeleteRow()); - } - - if (null !== c.asc_getIsDeleteTable()) { - s['WriteByte'](10); - s['WriteBool'](c.asc_getIsDeleteTable()); - } - - if (null !== c.asc_getIsInsertColumnLeft()) { - s['WriteByte'](11); - s['WriteBool'](c.asc_getIsInsertColumnLeft()); - } - - if (null !== c.asc_getIsInsertColumnRight()) { - s['WriteByte'](12); - s['WriteBool'](c.asc_getIsInsertColumnRight()); - } - - if (null !== c.asc_getIsInsertRowAbove()) { - s['WriteByte'](13); - s['WriteBool'](c.asc_getIsInsertRowAbove()); - } - - if (null !== c.asc_getIsInsertRowBelow()) { - s['WriteByte'](14); - s['WriteBool'](c.asc_getIsInsertRowBelow()); - } - - if (null !== c.asc_getLastCol()) { - s['WriteByte'](15); - s['WriteBool'](c.asc_getLastCol()); - } - - if (null !== c.asc_getLastRow()) { - s['WriteByte'](16); - s['WriteBool'](c.asc_getLastRow()); - } - - s['WriteByte'](255); -} - -function asc_WriteCCellInfo(c, s) { - if (!c) return; - var xfs = c.asc_getXfs(); - - var v = c.asc_getText(); - if (null !== v) { - s['WriteByte'](2); - s['WriteString2'](v); - } - - v = xfs.asc_getHorAlign(); - if (null !== v) { - s['WriteByte'](3); - s['WriteLong'](v); - } - - v = xfs.asc_getVertAlign(); - if (null !== v) { - s['WriteByte'](4); - s['WriteLong'](v); - } - - s['WriteByte'](5); - s['WriteBool'](c.asc_getMerge()); - s['WriteBool'](xfs.asc_getShrinkToFit()); - s['WriteBool'](xfs.asc_getWrapText()); - s['WriteLong'](c.asc_getSelectionType()); - s['WriteBool'](c.asc_getLockText()); - - asc_WriteCFont(6, xfs, s); - - if (null != xfs.asc_getFillColor() && xfs.asc_getFillColor().asc_getAuto() !== true) { - asc_menu_WriteColor(8, xfs.asc_getFillColor(), s); - } - - asc_WriteCBorders(9, c.asc_getBorders(), s); - - v = c.asc_getInnerText(); - if (null !== v) { - s['WriteByte'](15); - s['WriteString2'](v); - } - - v = xfs.asc_getNumFormat(); - if (null !== v) { - s['WriteByte'](16); - s['WriteString2'](v); - } - - asc_WriteCHyperLink(17, c.asc_getHyperlink(), s); - - s['WriteByte'](18); - s['WriteBool'](c.asc_getLocked()); - - v = c.asc_getStyleName(); - if (null != v) { - s['WriteByte'](21); - s['WriteString2'](v); - } - - v = xfs.asc_getNumFormatInfo(); - if (null != v) { - s['WriteByte'](22); - s['WriteLong'](v.asc_getType()); - } - - v = xfs.asc_getAngle(); - if (null != v) { - s['WriteByte'](23); - s['WriteDouble2'](v); - } - - v = c.asc_getAutoFilterInfo(); - if (v) { - asc_WriteAutoFilterInfo(30, v, s); - } - v = c.asc_getFormatTableInfo(); - if (v) { - asc_WriteFormatTableInfo(31, v, s); - } - - s['WriteByte'](32); - s['WriteString2'](asc_CellInfoToJson(c)); - - s['WriteByte'](255); -} -function asc_CellInfoToJson(cellInfo) { - var json = { - asc_getSelectionType: cellInfo.asc_getSelectionType(), - asc_getLocked: cellInfo.asc_getLocked(), - asc_getLockedTable: cellInfo.asc_getLockedTable(), - asc_getComments: [] - }; - - var cellComments = cellInfo.asc_getComments(); - var jsonComments = []; - for (var i = 0; i < cellComments.length; ++i) { - jsonComments.push(JSON.stringify(readSDKComment(cellComments[i].asc_getId(), cellComments[i]))); - } - - json["asc_getComments"] = jsonComments; - - return JSON.stringify(json); -} -function asc_WriteAddFormatTableOptions(c, s) { - if (!c) return; - - if (c.asc_getRange()) { - s['WriteByte'](0); - s['WriteString2'](c.asc_getRange()); - } - - if (c.asc_getIsTitle()) { - s['WriteByte'](1); - s['WriteBool'](c.asc_getIsTitle()); - } - - s['WriteByte'](255); -} - -function asc_WriteAutoFilterObj(i, c, s) { - if (!c) return; - - s['WriteByte'](i); - - if (undefined !== c.asc_getType()) { - s['WriteByte'](0); - s['WriteLong'](c.asc_getType()); - } - - s['WriteByte'](255); -} -function asc_WriteAutoFiltersOptionsElements(i, c, s) { - if (!c) return; - - s['WriteByte'](i); - - if (undefined !== c.asc_getIsDateFormat()) { - s['WriteByte'](0); - s['WriteBool'](c.asc_getIsDateFormat()); - } - - if (c.asc_getText()) { - s['WriteByte'](1); - s['WriteString2'](c.asc_getText()); - } - - if (c.asc_getVal()) { - s['WriteByte'](2); - s['WriteString2'](c.asc_getVal()); - } - - if (undefined !== c.asc_getVisible()) { - s['WriteByte'](3); - s['WriteBool'](c.asc_getVisible()); - } - - s['WriteByte'](255); -} -function asc_WriteAutoFiltersOptions(c, s) { - if (!c) return; - - if (c.asc_getCellId()) { - s['WriteByte'](0); - s['WriteString2'](c.asc_getCellId()); - } - - if (c.asc_getDisplayName()) { - s['WriteByte'](1); - s['WriteString2'](c.asc_getDisplayName()); - } - - if (c.asc_getIsTextFilter()) { - s['WriteByte'](2); - s['WriteBool'](c.asc_getIsTextFilter()); - } - - if (c.asc_getCellCoord()) { - s['WriteByte'](3); - s['WriteDouble2'](c.asc_getCellCoord().asc_getX()); - s['WriteDouble2'](c.asc_getCellCoord().asc_getY()); - s['WriteDouble2'](c.asc_getCellCoord().asc_getWidth()); - s['WriteDouble2'](c.asc_getCellCoord().asc_getHeight()); - } - - if (c.asc_getSortColor()) { - asc_menu_WriteColor(4, c.asc_getSortColor(), s); - } - - if (c.asc_getValues() && c.asc_getValues().length > 0) { - var count = c.asc_getValues().length; - - s['WriteByte'](5); - s['WriteLong'](count); - - for (var i = 0; i < count; ++i) { - asc_WriteAutoFiltersOptionsElements(1, c.asc_getValues()[i], s); - } - } - - if (undefined !== c.asc_getSortState()) { - s['WriteByte'](6); - s['WriteLong'](c.asc_getSortState()); - } - - if (c.asc_getFilterObj()) { - asc_WriteAutoFilterObj(7, c.asc_getFilterObj(), s); - } - - s['WriteByte'](255); -} - -//-------------------------------------------------------------------------------- -// defines -//-------------------------------------------------------------------------------- - -var PageType = { -PageDefaultType: 0, -PageTopType: 1, -PageLeftType: 2, -PageCornerType: 3 -}; - -var kBeginOfLine = -1; -var kBeginOfText = -2; -var kEndOfLine = -3; -var kEndOfText = -4; -var kNextChar = -5; -var kNextWord = -6; -var kNextLine = -7; -var kPrevChar = -8; -var kPrevWord = -9; -var kPrevLine = -10; -var kPosition = -11; -var kPositionLength = -12; - -var deviceScale = 1; - -var sdkCheck = true; - -//-------------------------------------------------------------------------------- -// OfflineEditor -//-------------------------------------------------------------------------------- - -var _api = null; -function OfflineEditor () { - - this.zoom = 1.0; - this.textSelection = 0; - this.selection = []; - this.cellPin = 0; - this.col0 = 0; - this.row0 = 0; - this.translate = null; - this.initSettings = null; - - // main - - this.beforeOpen = function() { - - window['AscFormat'].DrawingArea.prototype.drawSelection = function(drawingDocument) { - - var canvas = this.worksheet.objectRender.getDrawingCanvas(); - var shapeCtx = canvas.shapeCtx; - var shapeOverlayCtx = canvas.shapeOverlayCtx; - var autoShapeTrack = canvas.autoShapeTrack; - var trackOverlay = canvas.trackOverlay; - - var ctx = trackOverlay.m_oContext; - trackOverlay.Clear(); - drawingDocument.Overlay = trackOverlay; - - this.worksheet.overlayCtx.clear(); - this.worksheet.overlayGraphicCtx.clear(); - this.worksheet._drawCollaborativeElements(autoShapeTrack); - - if (!this.worksheet.objectRender.controller.selectedObjects.length && !this.api.isStartAddShape && !this.api.isInkDrawerOn()) - this.worksheet._drawSelection(); - - var chart; - var controller = this.worksheet.objectRender.controller; - var selected_objects = controller.selection.groupSelection ? controller.selection.groupSelection.selectedObjects : controller.selectedObjects; - if(selected_objects.length === 1 && selected_objects[0].getObjectType() === AscDFH.historyitem_type_ChartSpace) - { - chart = selected_objects[0]; - this.worksheet.objectRender.selectDrawingObjectRange(chart); - } - for ( var i = 0; i < this.frozenPlaces.length; i++ ) { - - this.frozenPlaces[i].setTransform(shapeCtx, shapeOverlayCtx, autoShapeTrack); - - // Clip - this.frozenPlaces[i].clip(shapeOverlayCtx, this.worksheet.rangeToRectRel(this.frozenPlaces[i].range, 0)); - - if (null == drawingDocument.m_oDocumentRenderer) { - if (drawingDocument.m_bIsSelection) { - drawingDocument.private_StartDrawSelection(trackOverlay); - this.worksheet.objectRender.controller.drawTextSelection(); - drawingDocument.private_EndDrawSelection(); - } - - ctx.globalAlpha = 1.0; - - this.worksheet.objectRender.controller.drawSelection(drawingDocument); - - if ( this.worksheet.objectRender.controller.needUpdateOverlay() ) { - trackOverlay.Show(); - shapeOverlayCtx.put_GlobalAlpha(true, 0.5); - this.worksheet.objectRender.controller.drawTracks(shapeOverlayCtx); - shapeOverlayCtx.put_GlobalAlpha(true, 1); - } - } else { - - ctx.fillStyle = "rgba(51,102,204,255)"; - ctx.beginPath(); - - for (var j = drawingDocument.m_lDrawingFirst; j <= drawingDocument.m_lDrawingEnd; j++) { - var drawPage = drawingDocument.m_arrPages[j].drawingPage; - drawingDocument.m_oDocumentRenderer.DrawSelection(j, trackOverlay, drawPage.left, drawPage.top, drawPage.right - drawPage.left, drawPage.bottom - drawPage.top); - } - - ctx.globalAlpha = 0.2; - ctx.fill(); - ctx.beginPath(); - ctx.globalAlpha = 1.0; - } - - // Restore - this.frozenPlaces[i].restore(shapeOverlayCtx); - } - }; - - window['AscFormat'].Path.prototype.drawSmart = function(shape_drawer) { - - var _graphics = shape_drawer.Graphics; - var _full_trans = _graphics.m_oFullTransform; - - if (!_graphics || !_full_trans || undefined == _graphics.m_bIntegerGrid || true === shape_drawer.bIsNoSmartAttack) - return this.draw(shape_drawer); - - var bIsTransformed = (_full_trans.shx == 0 && _full_trans.shy == 0) ? false : true; - - if (bIsTransformed) - return this.draw(shape_drawer); - - var isLine = this.isSmartLine(); - var isRect = false; - if (!isLine) - isRect = this.isSmartRect(); - - //if (!isLine && !isRect) // IOS убрать - return this.draw(shape_drawer); - - var _old_int = _graphics.m_bIntegerGrid; - - if (false == _old_int) - _graphics.SetIntegerGrid(true); - - var dKoefMMToPx = Math.max(_graphics.m_oCoordTransform.sx, 0.001); - - var _ctx = _graphics.m_oContext; - var bIsStroke = (shape_drawer.bIsNoStrokeAttack || (this.stroke !== true)) ? false : true; - var bIsEven = false; - if (bIsStroke) - { - var _lineWidth = Math.max((shape_drawer.StrokeWidth * dKoefMMToPx + 0.5) >> 0, 1); - _ctx.lineWidth = _lineWidth; - - if ((_lineWidth & 0x01) == 0x01) - bIsEven = true; - } - - var bIsDrawLast = false; - var path = this.ArrPathCommand; - shape_drawer._s(); - - if (!isRect) - { - for(var j = 0, l = path.length; j < l; ++j) - { - var cmd=path[j]; - switch(cmd.id) - { - case AscFormat.moveTo: - { - bIsDrawLast = true; - - var _x = (_full_trans.TransformPointX(cmd.X, cmd.Y)) >> 0; - var _y = (_full_trans.TransformPointY(cmd.X, cmd.Y)) >> 0; - if (bIsEven) - { - _x -= 0.5; - _y -= 0.5; - } - _ctx.moveTo(_x, _y); - break; - } - case AscFormat.lineTo: - { - bIsDrawLast = true; - - var _x = (_full_trans.TransformPointX(cmd.X, cmd.Y)) >> 0; - var _y = (_full_trans.TransformPointY(cmd.X, cmd.Y)) >> 0; - if (bIsEven) - { - _x -= 0.5; - _y -= 0.5; - } - _ctx.lineTo(_x, _y); - break; - } - case AscFormat.close: - { - _ctx.closePath(); - break; - } - } - } - } - else - { - var minX = 100000; - var minY = 100000; - var maxX = -100000; - var maxY = -100000; - bIsDrawLast = true; - for(var j = 0, l = path.length; j < l; ++j) - { - var cmd=path[j]; - switch(cmd.id) - { - case AscFormat.moveTo: - case AscFormat.lineTo: - { - if (minX > cmd.X) - minX = cmd.X; - if (minY > cmd.Y) - minY = cmd.Y; - - if (maxX < cmd.X) - maxX = cmd.X; - if (maxY < cmd.Y) - maxY = cmd.Y; - - break; - } - default: - break; - } - } - - var _x1 = (_full_trans.TransformPointX(minX, minY)) >> 0; - var _y1 = (_full_trans.TransformPointY(minX, minY)) >> 0; - var _x2 = (_full_trans.TransformPointX(maxX, maxY)) >> 0; - var _y2 = (_full_trans.TransformPointY(maxX, maxY)) >> 0; - - if (bIsEven) - _ctx.rect(_x1 + 0.5, _y1 + 0.5, _x2 - _x1, _y2 - _y1); - else - _ctx.rect(_x1, _y1, _x2 - _x1, _y2 - _y1); - } - - if (bIsDrawLast) - { - shape_drawer.drawFillStroke(true, this.fill, bIsStroke); - } - - shape_drawer._e(); - - if (false == _old_int) - _graphics.SetIntegerGrid(false); - }; - - var asc_Range = window["Asc"].Range; - - AscCommonExcel.WorksheetView.prototype.__drawGrid = function (drawingCtx, c1, r1, c2, r2, leftFieldInPx, topFieldInPx, width, height) { - var range = new asc_Range(c1, r1, c2, r2); - this._prepareCellTextMetricsCache(range); - this._drawGrid(drawingCtx, range, leftFieldInPx, topFieldInPx, width, height); - }; - - AscCommonExcel.WorksheetView.prototype.__drawCellsAndBorders = function (drawingCtx, c1, r1, c2, r2, offsetXForDraw, offsetYForDraw, istoplayer) { - var range = new asc_Range(c1, r1, c2, r2); - - if (false === istoplayer) { - this._drawCellsAndBorders(drawingCtx, range, offsetXForDraw, offsetYForDraw); - this.af_drawButtons(range, offsetXForDraw, offsetYForDraw); - } - - var oldrange = this.visibleRange; - this.visibleRange = range; - - var cellsLeft_Local = this.cellsLeft; - var cellsTop_Local = this.cellsTop; - - this.cellsLeft = -(offsetXForDraw - this._getColLeft(c1)); - this.cellsTop = -(offsetYForDraw - this._getRowTop(r1)); - - // TODO: frozen places implementation native only - if (this.drawingArea.frozenPlaces.length) { - this.drawingArea.frozenPlaces[0].range = range; - } - - window["native"]["SwitchMemoryLayer"](); - - this.objectRender.showDrawingObjectsEx(); - - this.cellsLeft = cellsLeft_Local; - this.cellsTop = cellsTop_Local; - this.visibleRange = oldrange; - }; - - AscCommonExcel.WorksheetView.prototype.__selection = function (c1, r1, c2, r2, isFrozen) { - - var selection = []; - - this.visibleRange = new asc_Range(c1, r1, c2, r2); - - isFrozen = !!isFrozen; - if (window["Asc"]["editor"].isStartAddShape || window["Asc"]["editor"].isInkDrawerOn() || this.objectRender.selectedGraphicObjectsExists()) { - return; - } - - var offsetX = this._getColLeft(this.visibleRange.c1) - this.cellsLeft; - var offsetY = this._getRowTop(this.visibleRange.r1) - this.cellsTop; - - selection.push(0); - selection.push(0); - selection.push(0); - selection.push(0); - - selection.push(0); - selection.push(0); - selection.push(0); - selection.push(0); - - var oSelection = this.model.getSelection(); - var ranges = oSelection.ranges; - var range, selectionLineType, type; - for (var i = 0, l = ranges.length; i < l; ++i) { - range = ranges[i].clone(); - type = range.getType(); - if (Asc.c_oAscSelectionType.RangeMax === type) { - range.c2 = this.nColsCount - 1; - range.r2 = this.nRowsCount - 1; - } else if (Asc.c_oAscSelectionType.RangeCol === type) { - range.r2 = this.nRowsCount - 1; - } else if (Asc.c_oAscSelectionType.RangeRow === type) { - range.c2 = this.nColsCount - 1; - } - - selection.push(type); - - selection.push(range.c1); - selection.push(range.c2); - selection.push(range.r1); - selection.push(range.r2); - - selection.push(this._getColLeft(range.c1) - offsetX); - selection.push(this._getRowTop(range.r1) - offsetY); - selection.push(this._getColLeft(range.c2) + this._getColumnWidth(range.c2) - this._getColLeft(range.c1)); - selection.push(this._getRowTop(range.r2) + this._getRowHeight(range.r2) - this._getRowTop(range.r1)); - - selectionLineType = AscCommonExcel.selectionLineType.Selection; - if (1 === l) { - selectionLineType |= - AscCommonExcel.selectionLineType.ActiveCell | AscCommonExcel.selectionLineType.Promote; - } else if (i === oSelection.activeCellId) { - selectionLineType |= AscCommonExcel.selectionLineType.ActiveCell; - } - - var isActive = AscCommonExcel.selectionLineType.ActiveCell & selectionLineType; - if (isActive) { - var cell = this.model.getSelection().activeCell; - var fs = this.model.getMergedByCell(cell.row, cell.col); - fs = range.intersectionSimple(fs ? fs : new asc_Range(cell.col, cell.row, cell.col, cell.row)); - if (fs) { - - selection[0] = fs.c1; - selection[1] = fs.c2; - selection[2] = fs.r1; - selection[3] = fs.r2; - - selection[4] = this._getColLeft(fs.c1) - offsetX; - selection[5] = this._getRowTop(fs.r1) - offsetY; - selection[6] = this._getColLeft(fs.c2) + this._getColumnWidth(fs.c2) - this._getColLeft(fs.c1); - selection[7] = this._getRowTop(fs.r2) + this._getRowHeight(fs.r2) - this._getRowTop(fs.r1); - } - } - } - - var formularanges = []; - if (!isFrozen && this.getFormulaEditMode()) { - formularanges = this.__selectedCellRanges(offsetX, offsetY); - } - - return {'selection': selection, 'formularanges': formularanges}; - }; - - AscCommonExcel.WorksheetView.prototype.__changeSelectionPoint = function (x, y, isCoord, isSelectMode, isReverse) { - var isChangeSelectionShape = false; - if (isCoord) { - isChangeSelectionShape = this._endSelectionShape(); - } - - var isMoveActiveCellToLeftTop = false; - - var selection = this._getSelection(); - - var col = selection.activeCell.col; - var row = selection.activeCell.row; - - if (isReverse) { - selection.activeCell.col = this.leftTopRange.c2; - selection.activeCell.row = this.leftTopRange.r2; - } else { - selection.activeCell.col = this.leftTopRange.c1; - selection.activeCell.row = this.leftTopRange.r1; - } - - var ar = this._getSelection().getLast(); - - var newRange = isCoord ? this._calcSelectionEndPointByXY(x, y) : - this._calcSelectionEndPointByOffset(x, y); - var isEqual = newRange.isEqual(ar); - if (!isEqual || isChangeSelectionShape) { - - if (newRange.c1 > col || newRange.c2 < col) { - col = newRange.c1; - isMoveActiveCellToLeftTop = true; - } - - if (newRange.r1 > row || newRange.r2 < row) { - row = newRange.r1; - isMoveActiveCellToLeftTop = true; - } - - ar.assign2(newRange); - - selection.activeCell.col = col; - selection.activeCell.row = row; - - if (isMoveActiveCellToLeftTop) { - selection.activeCell.col = newRange.c1; - selection.activeCell.row = newRange.r1; - } - - if (this.getSelectionDialogMode()) { - this.handlers.trigger("selectionRangeChanged", this.getSelectionRangeValue()); - } else { - this.handlers.trigger("selectionNameChanged", this.getSelectionName(/*bRangeText*/true)); - if (!isSelectMode) { - this.handlers.trigger("selectionChanged"); - let t = this; - this.getSelectionMathInfo(function (info) { - t.handlers.trigger("selectionMathInfoChanged", info); - }); - } - } - } else { - selection.activeCell.col = col; - selection.activeCell.row = row; - } - - this.model.workbook.handlers.trigger("asc_onHideComment"); - - return isCoord ? this._calcActiveRangeOffsetIsCoord(x, y) : - this._calcRangeOffset(); - }; - - AscCommonExcel.WorksheetView.prototype.__chartsRanges = function(ranges) { - - if (ranges) { - return this.__selectedCellRange(ranges, 0, 0, Asc.c_oAscSelectionType.RangeChart); - } - - if (window["Asc"]["editor"].isStartAddShape || window["Asc"]["editor"].isInkDrawerOn() || this.objectRender.selectedGraphicObjectsExists()) { - if (this.isChartAreaEditMode && this.oOtherRanges) { - return this.__selectedCellRanges(0, 0, Asc.c_oAscSelectionType.RangeChart); - } - } - - return null; - }; - - AscCommonExcel.WorksheetView.prototype.__selectedCellRanges = function (offsetX, offsetY, rangetype) { - var ranges = []; - if (!this.oOtherRanges) { - return ranges; - } - - var arrRanges = this.oOtherRanges.ranges; - var type, left, right, top, bottom; - var addt, addl, addr, addb, colsCount = this.nColsCount - 1, rowsCount = this.nRowsCount - 1; - var defaultRowHeight = AscCommonExcel.oDefaultMetrics.RowHeight; - - if (colsCount < 1 || rowsCount < 1) { - return []; - } - - for (var i = 0; i < arrRanges.length; ++i) { - type = arrRanges[i].getType(); - ranges.push(undefined !== rangetype ? rangetype : type); - ranges.push(arrRanges[i].c1); - ranges.push(arrRanges[i].c2); - ranges.push(arrRanges[i].r1); - ranges.push(arrRanges[i].r2); - - addl = Math.max(arrRanges[i].c1 - colsCount, 0); - addt = Math.max(arrRanges[i].r1 - rowsCount, 0); - addr = Math.max(arrRanges[i].c2 - colsCount, 0); - addb = Math.max(arrRanges[i].r2 - rowsCount, 0); - - if (1 === type) { // cells or chart - if (addl > 0) - left = this._getColLeft(colsCount - 1) + this.defaultColWidthPx * addl - offsetX; - else - left = this._getColLeft(Math.max(0, arrRanges[i].c1)) - offsetX; - - if (addt > 0) - top = this._getRowTop(rowsCount - 1) + addt * defaultRowHeight - offsetY; - else - top = this._getRowTop(Math.max(0, arrRanges[i].r1)) - offsetY; - - if (addr > 0) - right = this._getColLeft(colsCount - 1) + this.defaultColWidthPx * addr - offsetX; - else - right = this._getColLeft(arrRanges[i].c2) + this._getColumnWidth(arrRanges[i].c2) - offsetX; - - if (addb > 0) - bottom = this._getRowTop(rowsCount - 1) + addb * defaultRowHeight - offsetY; - else - bottom = this._getRowTop(arrRanges[i].r2) + this._getRowHeight(arrRanges[i].r2) - offsetY; - } else if (2 === type) { // column range - if (addl > 0) - left = this._getColLeft(colsCount - 1) + this.defaultColWidthPx * addl - offsetX; - else - left = this._getColLeft(Math.max(0, arrRanges[i].c1)) - offsetX; - - if (addt > 0) - top = this._getRowTop(rowsCount - 1) + addt * defaultRowHeight - offsetY; - else - top = this._getRowTop(Math.max(0, arrRanges[i].r1)) - offsetY; - - if (addr > 0) - right = this._getColLeft(colsCount - 1) + this.defaultColWidthPx * addr - offsetX; - else - right = this._getColLeft(arrRanges[i].c2) + this._getColumnWidth(arrRanges[i].c2) - offsetX; - - bottom = 0; - } else if (3 === type) { // row range - if (addl > 0) - left = this._getColLeft(colsCount - 1) + this.defaultColWidthPx * addl - offsetX; - else - left = this._getColLeft(arrRanges[i].c1) - offsetX; - - if (addt > 0) - top = this._getRowTop(rowsCount - 1) + addt * defaultRowHeight - offsetY; - else - top = this._getRowTop(arrRanges[i].r1) - offsetY; - - right = 0; - - if (addb > 0) - bottom = this._getRowTop(rowsCount - 1) + addb * defaultRowHeight - offsetY; - else - bottom = this._getRowTop(arrRanges[i].r2) + this._getRowHeight(arrRanges[i].r2) - offsetY; - } else if (4 === type) { // max - if (addl > 0) - left = this._getColLeft(colsCount - 1) + this.defaultColWidthPx * addl - offsetX; - else - left = this._getColLeft(arrRanges[i].c1) - offsetX; - - if (addt > 0) - top = this._getRowTop(rowsCount - 1) + addt * defaultRowHeight - offsetY; - else - top = this._getRowTop(arrRanges[i].r1) - offsetY; - - right = 0; - bottom = 0; - } else { - if (addl > 0) - left = this._getColLeft(colsCount - 1) + this.defaultColWidthPx * addl - offsetX; - else - left = this._getColLeft(Math.max(0, arrRanges[i].c1)) - offsetX; - - if (addt > 0) - top = this._getRowTop(rowsCount - 1) + addt * defaultRowHeight - offsetY; - else - top = this._getRowTop(Math.max(0, arrRanges[i].r1)) - offsetY; - - if (addr > 0) - right = this._getColLeft(colsCount - 1) + this.defaultColWidthPx * addr - offsetX; - else - right = this._getColLeft(Math.max(0, arrRanges[i].c2)) + this._getColumnWidth(Math.max(0, arrRanges[i].c2)) - offsetX; - - if (addb > 0) - bottom = this._getRowTop(rowsCount - 1) + addb * defaultRowHeight - offsetY; - else - bottom = this._getRowTop(Math.max(0, arrRanges[i].r2)) + this._getRowHeight(Math.max(0, arrRanges[i].r2)) - offsetY; - } - - // else if (5 === type) { // range image - // } - // else if (6 === type) { // range chart - // } - - ranges.push(left); - ranges.push(top); - ranges.push(right); - ranges.push(bottom); - } - - return ranges; - }; - - AscCommonExcel.WorksheetView.prototype.__selectedCellRange = function (arrRanges, offsetX, offsetY, rangetype) { - - var ranges = [], j = 0, i = 0, type = 0, left = 0, right = 0, top = 0, bottom = 0; - - var type = 0, left = 0, right = 0, top = 0, bottom = 0; - var addt, addl, addr, addb, colsCount = this.nColsCount - 1, rowsCount = this.nRowsCount - 1; - var defaultRowHeight = AscCommonExcel.oDefaultMetrics.RowHeight; - - if (colsCount < 1 || rowsCount < 1) { - return []; - } - - for (i = 0; i < arrRanges.length; ++i) { - type = (arrRanges[i].getType == undefined) ? 0 : arrRanges[i].getType(); - ranges.push(undefined !== rangetype ? rangetype : type); - ranges.push(arrRanges[i].c1); - ranges.push(arrRanges[i].c2); - ranges.push(arrRanges[i].r1); - ranges.push(arrRanges[i].r2); - - addl = Math.max(arrRanges[i].c1 - colsCount,0); - addt = Math.max(arrRanges[i].r1 - rowsCount,0); - addr = Math.max(arrRanges[i].c2 - colsCount,0); - addb = Math.max(arrRanges[i].r2 - rowsCount,0); - - if (1 === type) { // cells or chart - if (addl > 0) - left = this._getColLeft(colsCount - 1) + this.defaultColWidthPx * addl - offsetX; - else - left = this._getColLeft(Math.max(0,arrRanges[i].c1)) - offsetX; - - if (addt > 0) - top = this._getRowTop(rowsCount - 1) + addt * defaultRowHeight - offsetY; - else - top = this._getRowTop(Math.max(0,arrRanges[i].r1,0)) - offsetY; - - if (addr > 0) - right = this._getColLeft(colsCount - 1) + this.defaultColWidthPx * addr - offsetX; - else - right = this._getColLeft(arrRanges[i].c2) + this._getColumnWidth(arrRanges[i].c2) - offsetX; - - if (addb > 0) - bottom = this._getRowTop(rowsCount - 1) + addb * defaultRowHeight - offsetY; - else - bottom = this._getRowTop(arrRanges[i].r2) + this._getRowHeight(arrRanges[i].r2) - offsetY; - } - else if (2 === type) { // column range - if (addl > 0) - left = this._getColLeft(colsCount - 1) + this.defaultColWidthPx * addl - offsetX; - else - left = this._getColLeft(Math.max(0,arrRanges[i].c1)) - offsetX; - - if (addt > 0) - top = this._getRowTop(rowsCount - 1) + addt * defaultRowHeight - offsetY; - else - top = this._getRowTop(Math.max(0,arrRanges[i].r1)) - offsetY; - - if (addr > 0) - right = this._getColLeft(colsCount - 1) + this.defaultColWidthPx * addr - offsetX; - else - right = this._getColLeft(arrRanges[i].c2) + this._getColumnWidth(arrRanges[i].c2) - offsetX; - - bottom = 0; - } - else if (3 === type) { // row range - if (addl > 0) - left = this._getColLeft(colsCount - 1) + this.defaultColWidthPx * addl - offsetX; - else - left = this._getColLeft(arrRanges[i].c1) - offsetX; - - if (addt > 0) - top = this._getRowTop(rowsCount - 1) + addt * defaultRowHeight - offsetY; - else - top = this._getRowTop(arrRanges[i].r1) - offsetY; - - right = 0; - - if (addb > 0) - bottom = this._getRowTop(rowsCount - 1) + addb * defaultRowHeight - offsetY; - else - bottom = this._getRowTop(arrRanges[i].r2) + this._getRowHeight(arrRanges[i].r2) - offsetY; - } - else if (4 === type) { // max - if (addl > 0) - left = this._getColLeft(colsCount - 1) + this.defaultColWidthPx * addl - offsetX; - else - left = this._getColLeft(arrRanges[i].c1) - offsetX; - - if (addt > 0) - top = this._getRowTop(rowsCount - 1) + addt * defaultRowHeight - offsetY; - else - top = this._getRowTop(arrRanges[i].r1) - offsetY; - - right = 0; - bottom = 0; - } else { - if (addl > 0) - left = this._getColLeft(colsCount - 1) + this.defaultColWidthPx * addl - offsetX; - else - left = this._getColLeft(Math.max(0,arrRanges[i].c1)) - offsetX; - - if (addt > 0) - top = this._getRowTop(rowsCount - 1) + addt * defaultRowHeight - offsetY; - else - top = this._getRowTop(Math.max(0,arrRanges[i].r1)) - offsetY; - - if (addr > 0) - right = this._getColLeft(colsCount - 1) + this.defaultColWidthPx * addr - offsetX; - else - right = this._getColLeft(Math.max(0,arrRanges[i].c2)) + this._getColumnWidth(Math.max(0,arrRanges[i].c2)) - offsetX; - - if (addb > 0) - bottom = this._getRowTop(rowsCount - 1) + addb * defaultRowHeight - offsetY; - else - bottom = this._getRowTop(Math.max(0,arrRanges[i].r2)) + this._getRowHeight(Math.max(0,arrRanges[i].r2)) - offsetY; - } - - // else if (5 === type) { // range image - // } - // else if (6 === type) { // range chart - // } - - ranges.push(left); - ranges.push(top); - ranges.push(right); - ranges.push(bottom); - } - - return ranges; - }; - }; - - this.openFile = function(settings) { - - window["NativeSupportTimeouts"] = true; - - // try - // { - // throw "OpenFile"; - // } - // catch (e) - // { - // - // } - - AscFonts.FontPickerByCharacter.IsUseNoSquaresMode = true; - - this.initSettings = settings; - - this.beforeOpen(); - - deviceScale = window["native"]["GetDeviceScale"](); - sdkCheck = settings["sdkCheck"]; - - // в таблицах неправильно выставляются dpi. пока фиксируем. - AscCommon.global_mouseEvent.AscHitToHandlesEpsilon = 18; - - window.NATIVE_DOCUMENT_TYPE = ""; - - var translations = this.initSettings["translations"]; - if (undefined != translations && null != translations && translations.length > 0) { - translations = JSON.parse(translations) - } else { - translations = ""; - } - - window["_api"] = window["API"] = _api = new window["Asc"]["spreadsheet_api"](translations); - - AscCommon.g_clipboardBase.Init(_api); - - var userInfo = new Asc.asc_CUserInfo(); - userInfo.asc_putId(this.initSettings["docUserId"]); - userInfo.asc_putFullName(this.initSettings["docUserName"]); - userInfo.asc_putFirstName(this.initSettings["docUserFirstName"]); - userInfo.asc_putLastName(this.initSettings["docUserLastName"]); - - var docInfo = new Asc.asc_CDocInfo(); - docInfo.put_Id(this.initSettings["docKey"]); - docInfo.put_Url(this.initSettings["docURL"]); - docInfo.put_Format("xlsx"); - docInfo.put_UserInfo(userInfo); - docInfo.put_Token(this.initSettings["token"]); - - _internalStorage.externalUserInfo = userInfo; - _internalStorage.externalDocInfo = docInfo; - - var permissions = this.initSettings["permissions"]; - if (undefined != permissions && null != permissions && permissions.length > 0) { - docInfo.put_Permissions(JSON.parse(permissions)); - } - - _api.asc_setDocInfo(docInfo); - - this.offline_beforeInit(); - - this.registerEventsHandlers(); - - if (this.initSettings["iscoauthoring"]) { - _api.asc_setAutoSaveGap(1); - _api._coAuthoringInit(); - _api.asc_SetFastCollaborative(true); - - window["native"]["onTokenJWT"](_api.CoAuthoringApi.get_jwt()); - - } else { - - var t = this; - - var thenCallback = function() { - - _api.setDrawGroupsRestriction(); - t.asc_WriteAllWorksheets(true); - t.asc_WriteCurrentCell(); - - _api.asc_CheckGuiControlColors(); - _api.sendColorThemes(_api.wbModel.theme); - _api.asc_ApplyColorScheme(false); - _api._applyFirstLoadChanges(); - // Go to if sent options - _api.goTo(); - - var ws = _api.wb.getWorksheet(); - - _api.wb.showWorksheet(undefined, true); - ws._fixSelectionOfMergedCells(); - - if (ws.topLeftFrozenCell) { - t.row0 = ws.topLeftFrozenCell.getRow0(); - t.col0 = ws.topLeftFrozenCell.getCol0(); - } - - var chartData = t.initSettings["chartData"]; - - if (chartData.length > 0) { - var json = JSON.parse(chartData); - if (json) { - - _api.asc_addChartDrawingObject(json); - - var objects = ws.objectRender.controller.drawingObjects.getDrawingObjects(); - if (objects.length > 0) { - - var left = t.initSettings["chartLeft"]; - var top = t.initSettings["chartTop"]; - var right = t.initSettings["chartRight"]; - var bottom = t.initSettings["chartBottom"]; - - var chart = objects[0].graphicObject; - - chart.spPr.xfrm.setOffX(parseInt(left)); - chart.spPr.xfrm.setOffY(parseInt(top)); - chart.spPr.xfrm.setExtX(parseInt(right - left)); - chart.spPr.xfrm.setExtY(parseInt(bottom - top)); - - chart.checkDrawingBaseCoords(); - chart.recalculate(); - } - - //console.log(JSON.stringify(json)); - } - } - }; - - _api.asc_nativeOpenFile(window["native"]["GetFileString"](), undefined, true, window["native"]["GetXlsxPath"]()); - thenCallback(); - - // TODO: Implement frozen places - // TODO: Implement Text Art Styles - } - - this.offline_afteInit(); - }; - this.registerEventsHandlers = function () { - - var t = this; - - _api.asc_registerCallback("asc_onCanUndoChanged", function (bCanUndo) { - var stream = global_memory_stream_menu; - stream["ClearNoAttack"](); - stream["WriteBool"](bCanUndo); - window["native"]["OnCallMenuEvent"](60, stream); // ASC_MENU_EVENT_TYPE_CAN_UNDO - }); - - _api.asc_registerCallback("asc_onCanRedoChanged", function (bCanRedo) { - var stream = global_memory_stream_menu; - stream["ClearNoAttack"](); - stream["WriteBool"](bCanRedo); - window["native"]["OnCallMenuEvent"](61, stream); // ASC_MENU_EVENT_TYPE_CAN_REDO - }); - - _api.asc_registerCallback("asc_onDocumentModifiedChanged", function(change) { - var stream = global_memory_stream_menu; - stream["ClearNoAttack"](); - stream["WriteBool"](change); - window["native"]["OnCallMenuEvent"](66, stream); // ASC_MENU_EVENT_TYPE_DOCUMETN_MODIFITY - }); - - _api.asc_registerCallback("asc_onActiveSheetChanged", function(index) { - t.asc_WriteAllWorksheets(true, true); - }); - - _api.asc_registerCallback("asc_onRenameCellTextEnd", function(found, replaced) { - var stream = global_memory_stream_menu; - stream["ClearNoAttack"](); - stream["WriteLong"](found); - stream["WriteLong"](replaced); - window["native"]["OnCallMenuEvent"](63, stream); // ASC_MENU_EVENT_TYPE_SEARCH_REPLACETEXT - }); - - _api.asc_registerCallback("asc_onSelectionChanged", function(cellInfo) { - var stream = global_memory_stream_menu; - stream["ClearNoAttack"](); - asc_WriteCCellInfo(cellInfo, stream); - window["native"]["OnCallMenuEvent"](2402, stream); // ASC_SPREADSHEETS_EVENT_TYPE_SELECTION_CHANGED - t.onSelectionChanged(cellInfo); - }); - - _api.asc_registerCallback("asc_onSelectionNameChanged", function(name) { - var stream = global_memory_stream_menu; - stream["ClearNoAttack"](); - stream["WriteString2"](name); - window["native"]["OnCallMenuEvent"](2310, stream); // ASC_SPREADSHEETS_EVENT_TYPE_EDITOR_SELECTION_NAME_CHANGED - }); - - _api.asc_registerCallback("asc_onEditorSelectionChanged", function(xfs) { - var stream = global_memory_stream_menu; - stream["ClearNoAttack"](); - asc_WriteCFont(-1, xfs, stream); - window["native"]["OnCallMenuEvent"](2403, stream); // ASC_SPREADSHEETS_EVENT_TYPE_EDITOR_SELECTION_CHANGED - }); - - _api.asc_registerCallback("asc_onSendThemeColorSchemes", function(schemes) { - var stream = global_memory_stream_menu; - stream["ClearNoAttack"](); - asc_WriteColorSchemes(schemes, stream); - window["native"]["OnCallMenuEvent"](2404, stream); // ASC_SPREADSHEETS_EVENT_TYPE_COLOR_SCHEMES - }); - - _api.asc_registerCallback("asc_onInitTablePictures", function () { - var stream = global_memory_stream_menu; - stream["ClearNoAttack"](); - window["native"]["OnCallMenuEvent"](12, stream); // ASC_MENU_EVENT_TYPE_TABLE_STYLES - }); - - _api.asc_registerCallback("asc_onInitEditorStyles", function () { - var stream = global_memory_stream_menu; - stream["ClearNoAttack"](); - window["native"]["OnCallMenuEvent"](2405, stream); // ASC_SPREADSHEETS_EVENT_TYPE_CELL_STYLES - }); - - _api.asc_registerCallback("asc_onError", function(id, level, errData) { - var stream = global_memory_stream_menu; - stream["ClearNoAttack"](); - stream["WriteLong"](id); - stream["WriteLong"](level); - window["native"]["OnCallMenuEvent"](500, stream); // ASC_MENU_EVENT_TYPE_ON_ERROR - }); - - _api.asc_registerCallback("asc_onEditCell", function(state) { - if (Asc.c_oAscCellEditorState.editStart === state) { - var stream = global_memory_stream_menu; - stream["ClearNoAttack"](); - window["native"]["OnCallMenuEvent"](50000, stream); // ASC_SPREADSHEETS_EVENT_TYPE_AFTER_INSERT_FORMULA - } else { - var stream = global_memory_stream_menu; - stream["ClearNoAttack"](); - stream["WriteLong"](state); - window["native"]["OnCallMenuEvent"](2600, stream); // ASC_SPREADSHEETS_EVENT_TYPE_ON_EDIT_CELL - } - }); - - _api.asc_registerCallback("asc_onSetAFDialog", function(state) { - var stream = global_memory_stream_menu; - stream["ClearNoAttack"](); - asc_WriteAutoFiltersOptions(state, stream); - window["native"]["OnCallMenuEvent"](3060, stream); // ASC_SPREADSHEETS_EVENT_TYPE_FILTER_DIALOG - }); - - _api.asc_registerCallback("asc_onAuthParticipantsChanged", onApiAuthParticipantsChanged); - _api.asc_registerCallback("asc_onParticipantsChanged", onApiParticipantsChanged); - - _api.asc_registerCallback("asc_onSheetsChanged", function () { - t.asc_WriteAllWorksheets(true, true); - }); - - _api.asc_registerCallback("asc_onWorkbookLocked", function(locked) { - var stream = global_memory_stream_menu; - stream["ClearNoAttack"](); - stream["WriteBool"](locked); - window["native"]["OnCallMenuEvent"](30104, stream); // ASC_COAUTH_EVENT_TYPE_WORKBOOK_LOCKED - }); - - _api.asc_registerCallback("asc_onWorksheetLocked", function(index, locked) { - var stream = global_memory_stream_menu; - stream["ClearNoAttack"](); - stream["WriteLong"](index); - stream["WriteBool"](locked); - window["native"]["OnCallMenuEvent"](30105, stream); // ASC_COAUTH_EVENT_TYPE_WORKSHEET_LOCKED - }); - - _api.asc_registerCallback("asc_onGetEditorPermissions", function(state) { - var rData = { - "c" : "open", - "id" : t.initSettings["docKey"], - "userid" : t.initSettings["docUserId"], - "format" : "xlsx", - "vkey" : undefined, - "url" : t.initSettings["docURL"], - "title" : this.documentTitle, - "nobase64" : true}; - - _api.CoAuthoringApi.auth(t.initSettings["viewmode"], rData); - }); - - _api.asc_registerCallback("asc_onDocumentUpdateVersion", function(callback) { - var me = this; - me.needToUpdateVersion = true; - if (callback) callback.call(me); - }); - - _api.asc_registerCallback("asc_onAdvancedOptions", function(type, options) { - var stream = global_memory_stream_menu; - if (options === undefined) { - options = {}; - } - options["optionId"] = type; - stream["ClearNoAttack"](); - stream["WriteString2"](JSON.stringify(options)); - window["native"]["OnCallMenuEvent"](22000, stream); // ASC_MENU_EVENT_TYPE_ADVANCED_OPTIONS - }); - - _api.asc_registerCallback("asc_onSendThemeColors", onApiSendThemeColors); - - // Common - _api.asc_registerCallback('asc_onStartAction', onApiLongActionBegin); - _api.asc_registerCallback('asc_onEndAction', onApiLongActionEnd); - _api.asc_registerCallback('asc_onError', onApiError); - - // Comments - _api.asc_registerCallback("asc_onAddComment", onApiAddComment); - _api.asc_registerCallback("asc_onAddComments", onApiAddComments); - _api.asc_registerCallback("asc_onRemoveComment", onApiRemoveComment); - _api.asc_registerCallback("asc_onChangeComments", onApiChangeComments); - _api.asc_registerCallback("asc_onRemoveComments", onApiRemoveComments); - _api.asc_registerCallback("asc_onChangeCommentData", onApiChangeCommentData); - _api.asc_registerCallback("asc_onLockComment", onApiLockComment); - _api.asc_registerCallback("asc_onUnLockComment", onApiUnLockComment); - _api.asc_registerCallback("asc_onShowComment", onApiShowComment); - _api.asc_registerCallback("asc_onHideComment", onApiHideComment); - _api.asc_registerCallback("asc_onUpdateCommentPosition", onApiUpdateCommentPosition); - }; - this.updateFrozen = function () { - var ws = _api.wb.getWorksheet(); - if (ws.topLeftFrozenCell) { - _s.row0 = ws.topLeftFrozenCell.getRow0(); - _s.col0 = ws.topLeftFrozenCell.getCol0(); - } - else - { - _s.row0 = 0; - _s.col0 = 0; - } - }; - - // prop - - this.getMaxBounds = function () { - var worksheet = _api.wb.getWorksheet(); - - var left = worksheet._getColLeft(worksheet.nColsCount - 1); - var top = worksheet._getRowTop(worksheet.nRowsCount - 1); - - left += (AscCommon.gc_nMaxCol - worksheet.nColsCount) * worksheet.defaultColWidthPx; - top += (AscCommon.gc_nMaxRow - worksheet.nRowsCount) * AscCommonExcel.oDefaultMetrics.RowHeight; - - return [left, top]; - }; - this.getSelection = function(x, y, width, height, autocorrection) { - - _null_object.width = width; - _null_object.height = height; - - var ws = _api.wb.getWorksheet(); - var region = null; - //var range = ws.activeRange.intersection(worksheet.visibleRange); - - var ranges = ws.model.getSelection().ranges; - var range = ws.visibleRange; - for (var i = 0, l = ranges.length; i < l; ++i) { - range = range.intersection(ranges[i]); - } - - if ((null === range) && (ranges.length > 0)) { - range = ranges[0]; - } - - if (autocorrection) { - this._resizeWorkRegion(ws, range.c2, range.r2); - region = {columnBeg:0, columnEnd: ws.nColsCount - 1, columnOff:0, rowBeg:0, rowEnd: ws.nRowsCount - 1, rowOff:0}; - } else { - region = this._updateRegion(worksheet, x, y, width, height); - } - - this.selection = _api.wb.getWorksheet().__selection(region.columnBeg, region.rowBeg, region.columnEnd, region.rowEnd); - - return this.selection; - }; - this.getNearCellCoord = function(x, y) { - - //TODO: optimize search ( bin2_search ) - - var cell = [], - worksheet = _api.wb.getWorksheet(), - count = 0, - i = 0; - - count = worksheet.nColsCount; - if (count) { - if (worksheet._getColLeft(0) > x) { - cell.push(0); - } else { - for (i = 0; i < count; ++i) { - if (worksheet._getColLeft(i) - worksheet._getColLeft(0) <= x && - x < worksheet._getColLeft(i) + worksheet._getColumnWidth(i) - worksheet._getColLeft(0)) { - - if (x - worksheet._getColLeft(i) - worksheet._getColLeft(0) > worksheet._getColumnWidth(i) * 0.5) { - cell.push(worksheet._getColLeft(i + 1) - worksheet._getColLeft(0)); - } - else { - cell.push(worksheet._getColLeft(i) - worksheet._getColLeft(0)); - } - - break; - } - } - } - } - - count = worksheet.nRowsCount; - if (count) { - if (worksheet._getRowTop(0) > y) { - cell.push(0); - } else { - for (i = 0; i < count; ++i) { - if (worksheet._getRowTop(i) - worksheet._getRowTop(0) <= y && - y < worksheet._getRowTop(i) + worksheet._getRowHeight(i) - worksheet._getRowTop(0)) { - if (y - worksheet._getRowTop(i) - worksheet._getRowTop(0) > worksheet._getRowHeight(i) * 0.5) - cell.push(worksheet._getRowTop(i + 1) - worksheet._getRowTop(0)); - else - cell.push(worksheet._getRowTop(i) - worksheet._getRowTop(0)); - - break; - } - } - } - } - - return cell; - }; - - // serialize - - this.asc_WriteAllWorksheets = function (callEvent, isSheetChange) { - - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - - _stream["WriteByte"](0); - _stream["WriteString2"](_api.asc_getActiveWorksheetId(i)); - - for (var i = 0; i < _api.asc_getWorksheetsCount(); ++i) { - - var viewSettings = _api.wb.getWorksheet(i).getSheetViewSettings(); - - if (_api.asc_getWorksheetTabColor(i)) { - _stream["WriteByte"](1); - } else { - _stream["WriteByte"](2); - } - _stream["WriteLong"](i); - _stream["WriteString2"](_api.asc_getWorksheetId(i)); - _stream["WriteString2"](_api.asc_getWorksheetName(i)); - _stream["WriteBool"](_api.asc_isWorksheetHidden(i)); - _stream["WriteBool"](_api.asc_isWorkbookLocked(i)); - _stream["WriteBool"](_api.asc_isWorksheetLockedOrDeleted(i)); - _stream["WriteBool"](viewSettings.asc_getShowGridLines()); - _stream["WriteBool"](viewSettings.asc_getShowRowColHeaders()); - _stream["WriteBool"](viewSettings.asc_getIsFreezePane()); - - if (_api.asc_getWorksheetTabColor(i)) - asc_menu_WriteColor(0, _api.asc_getWorksheetTabColor(i), _stream); - } - - _stream["WriteByte"](255); - - if (callEvent) { - window["native"]["OnCallMenuEvent"](isSheetChange ? 2300 : 2130, global_memory_stream_menu); // ASC_SPREADSHEETS_EVENT_TYPE_WORKSHEETS - } - }; - this.asc_writeWorksheet = function(i) { - - var viewSettings = _api.wb.getWorksheet(i).getSheetViewSettings(); - - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - - if (_api.asc_getWorksheetTabColor(i)) { - _stream["WriteByte"](1); - } else { - _stream["WriteByte"](2); - } - _stream["WriteLong"](i); - _stream["WriteString2"](_api.asc_getWorksheetId(i)); - _stream["WriteString2"](_api.asc_getWorksheetName(i)); - _stream["WriteBool"](_api.asc_isWorksheetHidden(i)); - _stream["WriteBool"](_api.asc_isWorkbookLocked(i)); - _stream["WriteBool"](_api.asc_isWorksheetLockedOrDeleted(i)); - _stream["WriteBool"](viewSettings.asc_getShowGridLines()); - _stream["WriteBool"](viewSettings.asc_getShowRowColHeaders()); - _stream["WriteBool"](viewSettings.asc_getIsFreezePane()); - - if (_api.asc_getWorksheetTabColor(i)) { - asc_menu_WriteColor(0, _api.asc_getWorksheetTabColor(i), _stream); - } - - _stream["WriteByte"](255); - }; - - this.asc_WriteCurrentCell = function() { - var cellInfo = _api.asc_getCellInfo(); - var stream = global_memory_stream_menu; - stream["ClearNoAttack"](); - asc_WriteCCellInfo(cellInfo, stream); - window["native"]["OnCallMenuEvent"](2402, stream); // ASC_SPREADSHEETS_EVENT_TYPE_SELECTION_CHANGED - }; - - // render - - this.drawSheet = function (x, y, width, height, ratio, istoplayer) { - _null_object.width = width * ratio; - _null_object.height = height * ratio; - - var worksheet = _api.wb.getWorksheet(); - worksheet._recalculate(); - var region = this._updateRegion(worksheet, x, y, width * ratio, height * ratio); - var colRowHeaders = _api.asc_getSheetViewSettings(); - - if (colRowHeaders.asc_getShowGridLines() && false == istoplayer) { - worksheet.__drawGrid(null, - region.columnBeg, region.rowBeg, region.columnEnd, region.rowEnd, - region.columnOff, region.rowOff, - width + region.columnOff, height + region.rowOff); - } - - worksheet.stringRender.fontNeedUpdate = true; - worksheet.__drawCellsAndBorders(null, - region.columnBeg, region.rowBeg, region.columnEnd, region.rowEnd, - region.columnOff, region.rowOff, istoplayer); - }; - this.drawHeader = function (x, y, width, height, type, ratio) { - - _null_object.width = width * ratio; - _null_object.height = height * ratio; - - var worksheet = _api.wb.getWorksheet(); - var region = this._updateRegion(worksheet, x, y, width * ratio, height * ratio); - - var isColumn = type == PageType.PageTopType || type == PageType.PageCornerType; - var isRow = type == PageType.PageLeftType || type == PageType.PageCornerType; - - if (!isColumn && isRow) - worksheet._drawRowHeaders(null, region.rowBeg, region.rowEnd, undefined, 0, region.rowOff); - else if (isColumn && !isRow) - worksheet._drawColumnHeaders(null, region.columnBeg, region.columnEnd, undefined, region.columnOff, 0); - else if (isColumn && isRow) - worksheet._drawCorner(); - }; - - // internal - - this._updateRegion = function (worksheet, x, y, width, height) { - - var i = 0; - var nativeToEditor = 1.0 / deviceScale; - - // координаты в СО редактора - - var logicX = x * nativeToEditor + worksheet.headersWidth; - var logicY = y * nativeToEditor + worksheet.headersHeight; - var logicToX = ( x + width ) * nativeToEditor + worksheet.headersWidth; - var logicToY = ( y + height ) * nativeToEditor + worksheet.headersHeight; - - var columnBeg = -1; - var columnEnd = -1; - var columnOff = 0; - var rowBeg = -1; - var rowEnd = -1; - var rowOff = 0; - var count = 0; - - // добавляем отсутствующие колонки ( с небольшим зазором ) - - var logicToXMAX = logicToX;//10000 * (1 + Math.floor(logicToX / 10000)); - - if (logicToXMAX >= worksheet._getColLeft(worksheet.nColsCount - 1)) { - - do { - worksheet.nColsCount = worksheet.nColsCount + 1; - worksheet._calcWidthColumns(AscCommonExcel.recalcType.newLines); - - if (logicToXMAX < worksheet._getColLeft(worksheet.nColsCount - 1)) { - break - } - } while (1); - } - - - - if (logicX < worksheet._getColLeft(worksheet.nColsCount - 1)) { - count = worksheet.nColsCount; - for (i = 0; i < count; ++i) { - if (-1 === columnBeg) { - if (worksheet._getColLeft(i) <= logicX && logicX < worksheet._getColLeft(i) + worksheet._getColumnWidth(i)) { - columnBeg = i; - columnOff = logicX; - } - } - - if (worksheet._getColLeft(i) <= logicToX && logicToX < worksheet._getColLeft(i) + worksheet._getColumnWidth(i)) { - columnEnd = i; - break; - } - } - } - - // добавляем отсутствующие строки ( с небольшим зазором ) - - var logicToYMAX = logicToY;//10000 * (1 + Math.floor(logicToY / 10000)); - - if (logicToYMAX >= worksheet._getRowTop(worksheet.nRowsCount - 1)) { - - do { - worksheet.nRowsCount = worksheet.nRowsCount + 1; - worksheet._calcHeightRows(AscCommonExcel.recalcType.newLines); - - if (logicToYMAX < worksheet._getRowTop(worksheet.nRowsCount - 1)) { - break - } - } while (1); - } - - - if (logicY < worksheet._getRowTop(worksheet.nRowsCount - 1)) { - count = worksheet.nRowsCount; - for (i = 0; i < count; ++i) { - if (-1 === rowBeg) { - if (worksheet._getRowTop(i) <= logicY && logicY < worksheet._getRowTop(i) + worksheet._getRowHeight(i)) { - rowBeg = i; - rowOff = logicY; - } - } - - if (worksheet._getRowTop(i) <= logicToY && logicToY < worksheet._getRowTop(i) + worksheet._getRowHeight(i)) { - rowEnd = i; - break; - } - } - } - - return { - columnBeg: Math.max(0,columnBeg), - columnEnd: Math.max(0, columnEnd), - columnOff: columnOff, - rowBeg: Math.max(0, rowBeg), - rowEnd: Math.max(0, rowEnd), - rowOff: rowOff - }; - }; - this._resizeWorkRegion = function (worksheet, col, row, isCoords) { - - if (undefined !== isCoords) { - - if (col >= worksheet._getColLeft(worksheet.nColsCount - 1)) { - - do { - worksheet.nColsCount = worksheet.nColsCount + 1; - worksheet._calcWidthColumns(AscCommonExcel.recalcType.newLines); - - if (col < worksheet._getColLeft(worksheet.nColsCount - 1)) { - break - } - } while (1); - } - - if (row >= worksheet._getRowTop(worksheet.nRowsCount - 1)) { - - do { - worksheet.nRowsCount = worksheet.nRowsCount + 1; - worksheet._calcHeightRows(AscCommonExcel.recalcType.newLines); - - if (row < worksheet._getRowTop(worksheet.nRowsCount - 1)) { - break - } - } while (1); - } - } - else - { - if (col >= worksheet.nColsCount) { - do { - worksheet.nColsCount = worksheet.nColsCount + 1; - worksheet._calcWidthColumns(AscCommonExcel.recalcType.newLines); - - if (col < worksheet.nColsCount) - break - } while (1); - } - - if (row >= worksheet.nRowsCount) { - do { - worksheet.nRowsCount = worksheet.nRowsCount + 1; - worksheet._calcHeightRows(AscCommonExcel.recalcType.newLines); - - if (row < worksheet.nRowsCount) - break - } while (1); - } - } - }; - this.offline_print = function(s, p) { - var adjustPrint = asc_ReadAdjustPrint(s, p); - var printPagesData = _api.wb.calcPagesPrint(adjustPrint); - var pdfPrinterMemory = _api.wb.printSheets(printPagesData).DocumentRenderer.Memory; - return pdfPrinterMemory.GetBase64Memory(); - }; - - this.onSelectionChanged = function(info) { - var stream = global_memory_stream_menu; - stream["ClearNoAttack"](); - - var SelectedObjects = [], selectType = info.asc_getSelectionType(); - if (selectType == Asc.c_oAscSelectionType.RangeImage || selectType == Asc.c_oAscSelectionType.RangeShape || - selectType == Asc.c_oAscSelectionType.RangeChart || selectType == Asc.c_oAscSelectionType.RangeChartText || - selectType == Asc.c_oAscSelectionType.RangeShapeText) - { - SelectedObjects = _api.asc_getGraphicObjectProps(); - - var count = SelectedObjects.length; - stream["WriteLong"](count); - - for (var i = 0; i < count; i++) - { - switch (SelectedObjects[i].asc_getObjectType()) - { - case Asc.c_oAscTypeSelectElement.Paragraph: - { - stream["WriteLong"](Asc.c_oAscTypeSelectElement.Paragraph); - asc_menu_WriteParagraphPr(SelectedObjects[i].Value, stream); - break; - } - case Asc.c_oAscTypeSelectElement.Image: - { - stream["WriteLong"](Asc.c_oAscTypeSelectElement.Image); - asc_menu_WriteImagePr(SelectedObjects[i].Value, stream); - break; - } - case Asc.c_oAscTypeSelectElement.Hyperlink: - { - stream["WriteLong"](Asc.c_oAscTypeSelectElement.Hyperlink); - asc_menu_WriteHyperPr(SelectedObjects[i].Value, stream); - break; - } - case Asc.c_oAscTypeSelectElement.Math: - { - stream["WriteLong"](Asc.c_oAscTypeSelectElement.Math); - asc_menu_WriteMath(SelectedObjects[i].Value, stream); - break; - } - default: - { - // none - break; - } - } - } - - if (count) - { - window["native"]["OnCallMenuEvent"](6, stream); - } - } - }; - - this.offline_addImageDrawingObject = function(options) { - var worksheet = _api.wb.getWorksheet(); - var objectRender = worksheet.objectRender; - var _this = objectRender; - var objectId = null; - var imageUrl = options[0]; - - function ascCvtRatio(fromUnits, toUnits) { - return window["Asc"].getCvtRatio(fromUnits, toUnits, objectRender.getContext().getPPIX()); - } - function pxToMm(val) { - return val * ascCvtRatio(0, 3); - } - - if (imageUrl && objectRender.canEdit()) { - - var _image = new Image(); - _image.src = imageUrl; - - var isOption = true;//options && options.cell; - - var calculateObjectMetrics = function (object, width, height) { - // Обработка картинок большого разрешения - var metricCoeff = 1; - - var coordsFrom = _this.calculateCoords(object.from); - var realTopOffset = coordsFrom.y; - var realLeftOffset = coordsFrom.x; - - var areaWidth = worksheet._getColLeft(worksheet.getLastVisibleCol()) - worksheet._getColLeft(worksheet.getFirstVisibleCol(true)); // по ширине - if (areaWidth < width) { - metricCoeff = width / areaWidth; - - width = areaWidth; - height /= metricCoeff; - } - - var areaHeight = worksheet._getRowTop(worksheet.getLastVisibleRow()) - worksheet._getRowTop(worksheet.getFirstVisibleRow(true)); // по высоте - if (areaHeight < height) { - metricCoeff = height / areaHeight; - - height = areaHeight; - width /= metricCoeff; - } - - var toCell = worksheet.findCellByXY(realLeftOffset + width, realTopOffset + height, true, false, false); - object.to.col = toCell.col; - object.to.colOff = pxToMm(toCell.colOff); - object.to.row = toCell.row; - object.to.rowOff = pxToMm(toCell.rowOff); - }; - - var addImageObject = function (_image) { - - var drawingObject = _this.createDrawingObject(); - drawingObject.worksheet = worksheet; - - var activeCell = worksheet.model.selectionRange.activeCell; - drawingObject.from.col = activeCell.col; - drawingObject.from.row = activeCell.row; - - calculateObjectMetrics(drawingObject, options[1], options[2]); - - var coordsFrom = _this.calculateCoords(drawingObject.from); - var coordsTo = _this.calculateCoords(drawingObject.to); - _this.controller.resetSelection(); - History.Create_NewPoint(); - _this.controller.addImageFromParams(_image.src, pxToMm(coordsFrom.x) + MOVE_DELTA, pxToMm(coordsFrom.y) + MOVE_DELTA, pxToMm(coordsTo.x - coordsFrom.x), pxToMm(coordsTo.y - coordsFrom.y)); - _this.controller.startRecalculate(); - worksheet.setSelectionShape(true); - - if (_this.controller.selectedObjects.length) { - objectId = _this.controller.selectedObjects[0].Id; - } - }; - - addImageObject(_image); - } - - return objectId; - }; - this.offline_addShapeDrawingObject = function(options) { - var ws = _api.wb.getWorksheet(); - var objectRender = ws.objectRender; - var objectId = null; - var current = {pos: 0}; - - var shapeProp = asc_menu_ReadShapePr(options["shape"], current); - - var left = options["l"]; - var top = options["t"]; - var right = options["r"]; - var bottom = options["b"]; - - function ascCvtRatio(fromUnits, toUnits) { - return window["Asc"].getCvtRatio(fromUnits, toUnits, objectRender.getContext().getPPIX()); - } - function pxToMm(val) { - return val * ascCvtRatio(0, 3); - } - - _api.asc_startAddShape(shapeProp.type); - - objectRender.controller.OnMouseDown({}, pxToMm(left), pxToMm(top), 0); - objectRender.controller.OnMouseMove({IsLocked: true}, pxToMm(right), pxToMm(bottom), 0); - objectRender.controller.OnMouseUp({}, pxToMm(left), pxToMm(bottom), 0); - - _api.asc_endAddShape(); - - if (objectRender.controller.selectedObjects.length) { - objectId = objectRender.controller.selectedObjects[0].Id; - } - - ws.setSelectionShape(true); - - return objectId; - }; - this.offline_addChartDrawingObject = function(options) { - var ws = _api.wb.getWorksheet(); - var objectRender = ws.objectRender; - var objectId = null; - var current = {pos: 0}; - - var settings = asc_menu_ReadChartPr(options["chart"], current); - - var left = options["l"]; - var top = options["t"]; - var right = options["r"]; - var bottom = options["b"]; - - var selectedRange = ws.getSelectedRange(); - if (selectedRange) - { - var box = selectedRange.getBBox0(); - settings.putInColumns(!(box.r2 - box.r1 < box.c2 - box.c1)); - } - - settings.putRanges(ws.getSelectionRangeValues(true, true)); - - settings.putStyle(2); - settings.putTitle(Asc.c_oAscChartTitleShowSettings.noOverlay); - var vert_axis_settings = new AscCommon.asc_ValAxisSettings(); - vert_axis_settings.setDefault(); - vert_axis_settings.putLabel(Asc.c_oAscChartVertAxisLabelShowSettings.none); - vert_axis_settings.putGridlines(Asc.c_oAscGridLinesSettings.major); - settings.addVertAxesProps(vert_axis_settings); - - var hor_axis_settings = new AscCommon.asc_CatAxisSettings(); - hor_axis_settings.setDefault(); - hor_axis_settings.putLabel(Asc.c_oAscChartHorAxisLabelShowSettings.none); - hor_axis_settings.putGridlines(Asc.c_oAscGridLinesSettings.none); - settings.addHorAxesProps(hor_axis_settings); - - var series = AscFormat.getChartSeries(settings); - if(series.length > 1) - { - settings.putLegendPos(Asc.c_oAscChartLegendShowSettings.right); - } - else - { - settings.putLegendPos(Asc.c_oAscChartLegendShowSettings.none); - } - settings.putDataLabelsPos(Asc.c_oAscChartDataLabelsPos.none); - settings.putSeparator(","); - settings.putLine(true); - settings.putShowMarker(false); - - - settings.left = left; - settings.top = top; - settings.width = right - left; - settings.height = bottom - top; - - _api.asc_addChartDrawingObject(settings); - - if (objectRender.controller.selectedObjects.length) { - objectId = objectRender.controller.selectedObjects[0].Id; - } - - ws.setSelectionShape(true); - - return objectId; - }; - - this.offline_beforeInit = function () { - - // chat styles - AscCommon.ChartPreviewManager.prototype.clearPreviews = function() {window["native"]["ClearCacheChartStyles"]();}; - AscCommon.ChartPreviewManager.prototype.createChartPreview = function(_graphics, type, styleIndex) { - return AscFormat.ExecuteNoHistory(function(){ - - var chart_space = this.checkChartForPreview(type, AscCommon.g_oChartStyles[type][styleIndex]); - window["native"]["BeginDrawStyle"](AscCommon.c_oAscStyleImage.Default, type + ''); - - chart_space.draw(_graphics); - _graphics.ClearParams(); - - window["native"]["EndDrawStyle"](); - - }, this, []); - }; - - AscCommon.ChartPreviewManager.prototype.getChartPreviews = function(chartType) { - - if (AscFormat.isRealNumber(chartType)) { - - var bIsCached = window["native"]["IsCachedChartStyles"](chartType); - if (!bIsCached) { - - window["native"]["SetStylesType"](2); - - var _graphics = new CDrawingStream(); - - if(AscCommon.g_oChartStyles[chartType]){ - var nStylesCount = AscCommon.g_oChartStyles[chartType].length; - for(var i = 0; i < nStylesCount; ++i) - this.createChartPreview(_graphics, chartType, i); - } - } - } - }; - }; - this.offline_afteInit = function () {window.AscAlwaysSaveAspectOnResizeTrack = true;}; -} -var _s = new OfflineEditor(); - -window["native"]["offline_of"] = function(arg) {_s.openFile(arg);} -window["native"]["offline_stz"] = function(v) {_s.zoom = v; _api.asc_setZoom(v);} -window["native"]["offline_ds"] = function(x, y, width, height, ratio, istoplayer) { - _s.drawSheet(x, y, width, height, ratio, istoplayer); -} -window["native"]["offline_dh"] = function(x, y, width, height, ratio, type) { - _s.drawHeader(x, y, width, height, type, ratio); -} - -window["native"]["offline_mouse_down"] = function(x, y, pin, isViewerMode, isFormulaEditMode, isRangeResize, isChartRange, - indexRange, c1, r1, c2, r2, targetCol, targetRow, - typePin, beginX, beginY, endX, endY) { - - _s.isShapeAction = false; - - var ws = _api.wb.getWorksheet(); - var wb = _api.wb; - - _s._resizeWorkRegion(ws, x, y, true); - - var range = wb.getWorksheet().getVisibleRange().clone(); - - range.c1 = _s.col0; - range.r1 = _s.row0; - - wb.getWorksheet().visibleRange = range; - - ws._updateDrawingArea(); - var graphicsInfo = wb._onGetGraphicsInfo(x, y); - if (graphicsInfo) { - ws.endEditChart(); - window.AscDisableTextSelection = true; - - var e = {isLocked:true, Button:0, ClickCount:1, shiftKey:false, metaKey:false, ctrlKey:false}; - - if (1 === typePin) { - wb._onGraphicObjectMouseDown(e, beginX, beginY); - wb._onGraphicObjectMouseUp(e, endX, endY); - e.shiftKey = true; - } - - if (-1 === typePin) { - wb._onGraphicObjectMouseDown(e, endX, endY); - wb._onGraphicObjectMouseUp(e, beginX, beginY); - e.shiftKey = true; - } - - wb._onGraphicObjectMouseDown(e, x, y); - wb._onUpdateSelectionShape(true); - - _s.isShapeAction = true; - ws.visibleRange = range; - - if (graphicsInfo.object && !graphicsInfo.object.graphicObject instanceof AscFormat.CChartSpace) { - ws.isChartAreaEditMode = false; - } - - if (!_s.enableTextSelection) { - window.AscAlwaysSaveAspectOnResizeTrack = true; - } - - var ischart = false; - var isimage = false; - var controller = ws.objectRender.controller; - var selected_objects = controller.selection.groupSelection ? controller.selection.groupSelection.selectedObjects : controller.selectedObjects; - if (selected_objects.length === 1 && selected_objects[0].getObjectType() === AscDFH.historyitem_type_ChartSpace) { - ischart = true; - } - else if (selected_objects.length === 1 && selected_objects[0].getObjectType() === AscDFH.historyitem_type_Shape) { - var shapeObj = selected_objects[0]; - if (shapeObj.spPr && shapeObj.spPr.geometry && shapeObj.spPr.geometry.preset === "line") { - window.AscAlwaysSaveAspectOnResizeTrack = false; - } - } - else if (selected_objects.length === 1 && selected_objects[0].getObjectType() === AscDFH.historyitem_type_ImageShape) { - isimage = true; - } - - return {id:graphicsInfo.id, ischart:ischart, isimage:isimage, - 'textselect':(null !== ws.objectRender.controller.selection.textSelection), - 'chartselect':(null !== ws.objectRender.controller.selection.chartSelection) - }; - } - - _s.cellPin = pin; - - var ct = ws.getCursorTypeFromXY(x, y); - if (ct.target && ct.target === AscCommonExcel.c_oTargetType.FilterObject) { - ws.af_setDialogProp(ct.idFilter); - //var cell = offline_get_cell_in_coord(x, y); - return {}; - } - - if (isRangeResize) { - - if (!isViewerMode) { - - var ct = ws.getCursorTypeFromXY(x, y); - - ws.startCellMoveResizeRange = null; - - var target = { - row: ct.row, - col: ct.col, - target: ct.target, - cursor: "se-resize", - indexFormulaRange: indexRange - }; - ws.changeSelectionMoveResizeRangeHandle(x, y, target, wb.cellEditor); - } - - } else { - - if (0 != _s.cellPin) { - - var selection = ws._getSelection(); - if (selection !== null) { - var lastRange = selection.getLast(); - ws.leftTopRange = lastRange.clone(); - } - - } else { - wb._onChangeSelection(true, x, y, true); - } - } - - wb.getWorksheet().visibleRange = range; - - return null; -} -window["native"]["offline_mouse_move"] = function(x, y, isViewerMode, isRangeResize, isChartRange, indexRange, c1, r1, c2, r2, targetCol, targetRow, textPin) { - var ws = _api.wb.getWorksheet(); - var wb = _api.wb; - - var range = wb.getWorksheet().getVisibleRange().clone(); - - range.c1 = _s.col0; - range.r1 = _s.row0; - - wb.getWorksheet().visibleRange = range; - - if (isRangeResize) { - if (!isViewerMode) { - var ct = ws.getCursorTypeFromXY(x, y); - - var target = { - row: isChartRange ? ct.row : targetRow, - col: isChartRange ? ct.col : targetCol, - target: ct.target, - cursor: "se-resize", - indexFormulaRange: indexRange - }; - ws.changeSelectionMoveResizeRangeHandle(x, y, target, wb.cellEditor); - } - } else { - - if (_s.isShapeAction) { - if (!isViewerMode) { - - var e = {isLocked: true, Button: 0, ClickCount: 1, shiftKey: false, metaKey: false, ctrlKey: false}; - - if (textPin && 0 == textPin["pin"]) { - wb._onGraphicObjectMouseDown(e, x, y); - wb._onGraphicObjectMouseUp(e, x, y); - } else { - ws.objectRender.graphicObjectMouseMove(e, x, y); - } - } - } else { - if (wb.isFormulaEditMode) { - wb._onChangeSelection(false, x, y, true); - } else { - if (-1 == _s.cellPin) - ws.__changeSelectionPoint(x, y, true, true, true); - else if (1 === _s.cellPin) - ws.__changeSelectionPoint(x, y, true, true, false); - else { - wb._onChangeSelection(false, x, y, true); - } - } - } - } - - wb.getWorksheet().visibleRange = range; - - return null; -} -window["native"]["offline_mouse_up"] = function(x, y, isViewerMode, isRangeResize, isChartRange, indexRange, c1, r1, c2, r2, targetCol, targetRow) { - var ret = null; - var ws = _api.wb.getWorksheet(); - var wb = _api.wb; - - var range = wb.getWorksheet().getVisibleRange().clone(); - - range.c1 = _s.col0; - range.r1 = _s.row0; - - wb.getWorksheet().visibleRange = range; - - if (_s.isShapeAction) { - var e = {isLocked: true, Button: 0, ClickCount: 1, shiftKey: false, metaKey: false, ctrlKey: false}; - wb._onGraphicObjectMouseUp(e, x, y); - wb._onChangeSelectionDone(x, y); - _s.isShapeAction = false; - - ret = {'isShapeAction': true}; - - } else { - - if (isRangeResize) { - if (!isViewerMode) { - if (ws.moveRangeDrawingObjectTo) { - ws.moveRangeDrawingObjectTo.c1 = Math.max(0, ws.moveRangeDrawingObjectTo.c1); - ws.moveRangeDrawingObjectTo.c2 = Math.max(0, ws.moveRangeDrawingObjectTo.c2); - ws.moveRangeDrawingObjectTo.r1 = Math.max(0, ws.moveRangeDrawingObjectTo.r1); - ws.moveRangeDrawingObjectTo.r2 = Math.max(0, ws.moveRangeDrawingObjectTo.r2); - } - - ws.applyMoveResizeRangeHandle(); - - var controller = ws.objectRender.controller; - controller.updateOverlay(); - } - } else { - - wb._onChangeSelectionDone(-1, -1); - _s.cellPin = 0; - wb.getWorksheet().leftTopRange = undefined; - } - } - - wb.getWorksheet().visibleRange = range; - - return ret; -} -window["native"]["offline_mouse_double_tap"] = function(x, y) { - var ws = _api.wb.getWorksheet(); - var e = {isLocked:true, Button:0, ClickCount:2, shiftKey:false, metaKey:false, ctrlKey:false}; - - ws.objectRender.graphicObjectMouseDown(e, x, y); - ws.objectRender.graphicObjectMouseUp(e, x, y); -} -window["native"]["offline_shape_text_select"] = function() { - var ws = _api.wb.getWorksheet(); - - var controller = ws.objectRender.controller; - - window.AscDisableTextSelection = false; - controller.startEditTextCurrentShape(); - - _s.enableTextSelection = true; -} - -window["native"]["offline_get_selection"] = function(x, y, width, height, autocorrection) {return _s.getSelection(x, y, width, height, autocorrection);} -window["native"]["offline_get_charts_ranges"] = function() { - var ws = _api.wb.getWorksheet(); - - var ranges = ws.__chartsRanges(); - var cattbbox = null; - var serbbox = null; - - var chart; - var controller = ws.objectRender.controller; - var selected_objects = controller.selection.groupSelection ? controller.selection.groupSelection.selectedObjects : controller.selectedObjects; - if (selected_objects.length === 1 && selected_objects[0].getObjectType() === AscDFH.historyitem_type_ChartSpace) { - chart = selected_objects[0]; - var oDataRange = null, oCatRange = null, oSerRange = null; - if (ws.isChartAreaEditMode && ws.oOtherRanges) { - var aChartRanges = ws.oOtherRanges.ranges; - for(var nRange = 0; nRange < aChartRanges.length; ++nRange) { - var oChartRange = aChartRanges[nRange]; - if(oChartRange.chartRangeIndex === 0) { - oDataRange = oChartRange; - } - else if(oChartRange.chartRangeIndex === 1) { - oSerRange = oChartRange; - } - else if(oChartRange.chartRangeIndex === 2) { - oCatRange = oChartRange; - } - } - if(oDataRange) { - var ranges = ranges ? ranges : ws.__chartsRanges([oDataRange]); - var catbbox = null;//oCatRange ? ws.__chartsRanges([oCatRange]) : null; - var serbbox = null;//oSerRange ? ws.__chartsRanges([oSerRange]) : null; - return { - 'ranges': ranges, - 'cattbbox': catbbox, - 'serbbox': serbbox - }; - } - } - return {'ranges': null, 'cattbbox': null, 'serbbox': null}; - } - return {'ranges':ranges, 'cattbbox':cattbbox, 'serbbox':serbbox}; -} -window["native"]["offline_get_worksheet_bounds"] = function() {return _s.getMaxBounds();} -window["native"]["offline_complete_cell"] = function(x, y) {return _s.getNearCellCoord(x, y);} -window["native"]["offline_keyboard_down"] = function(inputKeys) { - var wb = _api.wb; - var ws = _api.wb.getWorksheet(); - - var isFormulaEditMode = wb.isFormulaEditMode; - wb.isFormulaEditMode = false; - - for (var i = 0; i < inputKeys.length; i += 3) { - - var operationCode = inputKeys[i]; - - // TODO: commands for text in shape - - var codeKey = inputKeys[i + 2]; - - if (100 == inputKeys[i + 1]) { - - var event = {which:codeKey,keyCode:codeKey,metaKey:false,altKey:false,ctrlKey:false,shiftKey:false, preventDefault:function(){}}; - - if (6 === operationCode) { // SELECT_ALL - - event.keyCode = 65; - event.ctrlKey = true; - ws.objectRender.graphicObjectKeyDown(event); - - } else if (3 === operationCode) { // SELECT - - var content = ws.objectRender.controller.getTargetDocContent(); - - content.MoveCursorLeft(false, true); - content.MoveCursorRight(true, true); - - ws.objectRender.controller.updateSelectionState(); - ws.objectRender.controller.drawingObjects.sendGraphicObjectProps(); - - } else if (9 === operationCode ) { // Select cell - - if (37 === codeKey) { // LEFT - wb._onChangeSelection(false, -1, 0, false); - } else if (39 === codeKey) { // RIGHT - wb._onChangeSelection(false, 1, 0, false); - } else if (38 === codeKey) { // UP - wb._onChangeSelection(false, 0, -1, false); - } else if (40 === codeKey) { // DOWN - wb._onChangeSelection(false, 0, 1, false); - } - - } else { - - if (8 === codeKey || 13 === codeKey || 27 == codeKey) { - ws.objectRender.graphicObjectKeyDown(event); - } else { - ws.objectRender.graphicObjectKeyPress(event); - } - - if (27 == codeKey) { - window.AscDisableTextSelection = true; - } - } - } else if (37 === codeKey) { // LEFT - wb._onChangeSelection(true, -1, 0, false); - } else if (39 === codeKey) { // RIGHT - wb._onChangeSelection(true, 1, 0, false); - } else if (38 === codeKey) { // UP - wb._onChangeSelection(true, 0, -1, false); - } else if (40 === codeKey) { // DOWN - wb._onChangeSelection(true, 0, 1, false); - } else if (9 === codeKey) { // TAB - wb._onChangeSelection(true, -1, 0, false); - } else if (13 === codeKey) { // ENTER - wb._onChangeSelection(true, 0, 1, false); - } - } - - wb.isFormulaEditMode = isFormulaEditMode; -} - -window["native"]["offline_cell_editor_draw"] = function(width, height, ratio) { - _null_object.width = width * ratio; - _null_object.height = height * ratio; - - var wb = _api.wb; - var cellEditor = _api.wb.cellEditor; - cellEditor._draw(); - - return [wb.cellEditor.left, wb.cellEditor.top, wb.cellEditor.right, wb.cellEditor.bottom, - wb.cellEditor.curLeft, wb.cellEditor.curTop, wb.cellEditor.curHeight, - cellEditor.textRender.chars.length]; -} -window["native"]["offline_cell_editor_open"] = function(x, y, width, height, ratio, isSelectAll, isFormulaInsertMode, c1, r1, c2, r2) { - _null_object.width = width * ratio; - _null_object.height = height * ratio; - - var wb = _api.wb; - - var range = wb.getWorksheet().getVisibleRange().clone(); - - wb.getWorksheet().visibleRange.c1 = c1; - wb.getWorksheet().visibleRange.r1 = r1; - wb.getWorksheet().visibleRange.c2 = c2; - wb.getWorksheet().visibleRange.r2 = r2; - - wb.cellEditor.isSelectAll = isSelectAll; - - if (!isFormulaInsertMode) { - var t = wb; - - var ws = t.getWorksheet(); - var selectionRange = ws.model.selectionRange.clone(); - - t.setCellEditMode(true); - var enterOptions = new AscCommonExcel.CEditorEnterOptions(); - enterOptions.hideCursor = true; - ws.openCellEditor(t.cellEditor, enterOptions, selectionRange); - //t.input.disabled = false; - - t.Api.cleanSpelling(); - } - - wb.getWorksheet().visibleRange = range; -}; -window["native"]["offline_cell_editor_test_cells"] = function(x, y, width, height, ratio, isSelectAll, isFormulaInsertMode, c1, r1, c2, r2) { - _null_object.width = width * ratio; - _null_object.height = height * ratio; - - var wb = _api.wb; - var ws = _api.wb.getWorksheet(); - - var range = wb.getWorksheet().getVisibleRange().clone(); - - wb.getWorksheet().getVisibleRange().c1 = c1; - wb.getWorksheet().getVisibleRange().r1 = r1; - wb.getWorksheet().getVisibleRange().c2 = c2; - wb.getWorksheet().getVisibleRange().r2 = r2; - - wb.cellEditor.isSelectAll = isSelectAll; - - var editFunction = function() { - window["native"]["openCellEditor"](); - }; - - var editLockCallback = function(res) { - - if (!res) { - - window["native"]["closeCellEditor"](); - - //t.setCellEditMode(false); - //t.input.disabled = true; - - // Выключаем lock для редактирования ячейки - wb.collaborativeEditing.onStopEditCell(); - //t.cellEditor.close(false); - wb._onWSSelectionChanged(); - } - }; - - // Стартуем редактировать ячейку - wb.collaborativeEditing.onStartEditCell(); - if (ws._isLockedCells(ws.getActiveCell(0, 0, false), /*subType*/null, editLockCallback)) { - editFunction(); - } - - wb.getWorksheet().visibleRange = range; -} - -window["native"]["offline_cell_editor_process_input_commands"] = function(sendArguments) { - - _null_object.width = width * ratio; - _null_object.height = height * ratio; - - var wb = _api.wb; - var cellEditor = _api.wb.cellEditor; - var operationCode, left,right, position, value, value2; - - var width = sendArguments[0]; - var height = sendArguments[1]; - var ratio = sendArguments[2]; - - for (var i = 3; i < sendArguments.length; i += 4) { - - operationCode = sendArguments[i + 0]; - value = sendArguments[i + 1]; - value2 = sendArguments[i + 2]; - - var event = {which:value,metaKey:undefined,ctrlKey:undefined}; - event.stopPropagation = function() {}; - event.preventDefault = function() {}; - - switch (operationCode) { - - // KEY_DOWN - case 0: { - cellEditor._onWindowKeyDown(event); - break; - } - - // KEY_PRESS - case 1: { - cellEditor._onWindowKeyPress(event); - break; - } - - // MOVE - case 2: { - position = value; - if (position < 0) { - cellEditor._moveCursor(position); - } else { - cellEditor._moveCursor(kPosition, position); - } - break; - } - - // SELECT - case 3: { - - left = value; - right = value2; - - cellEditor.cursorPos = left; - cellEditor.selectionBegin = left; - cellEditor.selectionEnd = right; - - break; - } - - // PASTE - case 4: { - cellEditor.pasteText(sendArguments[i + 3]); - break; - } - - // 5 - REFRESH - noop command - - // SELECT_ALL - case 6: { - cellEditor._moveCursor(kBeginOfText); - cellEditor._selectChars(kEndOfText); - break; - } - - // SELECT_WORD - case 7: { - - cellEditor.isSelectMode = AscCommonExcel.c_oAscCellEditorSelectState.word; - // Окончание слова - var endWord = cellEditor.textRender.getNextWord(cellEditor.cursorPos); - // Начало слова (ищем по окончанию, т.к. могли попасть в пробел) - var startWord = cellEditor.textRender.getPrevWord(endWord); - - cellEditor._moveCursor(kPosition, startWord); - cellEditor._selectChars(kPosition, endWord); - - break; - } - - // DELETE_TEXT - case 8: { - cellEditor._removeChars(kPrevChar); - break; - } - } - } - - cellEditor._draw(); - - return [cellEditor.left, cellEditor.top, cellEditor.right, cellEditor.bottom, - cellEditor.curLeft, cellEditor.curTop, cellEditor.curHeight, - cellEditor.textRender.chars.length]; -} -window["native"]["offline_cell_editor_get_cursor_position"] = function() { - var cellEditor = _api.wb.cellEditor; - var pos = 0; - pos = cellEditor.cursorPos; - return {'cursorPos': pos}; -} - -window["native"]["offline_cell_editor_get_selection_text"] = function() { - var cellEditor = _api.wb.cellEditor; - var selectBegin = 0; - var selectEnd = 0; - selectBegin = cellEditor.selectionBegin; - selectEnd = cellEditor.selectionEnd; - return {'selectionBegin': selectBegin, 'selectionEnd': selectEnd}; -} - -window["native"]["offline_cell_editor_mouse_event"] = function(sendEvents) { - - var left, right; - var cellEditor = _api.wb.cellEditor; - - for (var i = 0; i < sendEvents.length; i += 5) { - var event = { - pageX:sendEvents[i + 1], - pageY:sendEvents[i + 2], - which: 1, - shiftKey:sendEvents[i + 3], - button:0 - }; - - if (sendEvents[i + 3]) { - if (-1 == sendEvents[i + 4]) { - left = Math.min(cellEditor.selectionBegin, cellEditor.selectionEnd); - right = Math.max(cellEditor.selectionBegin, cellEditor.selectionEnd); - cellEditor.cursorPos = left; - cellEditor.selectionBegin = right; - cellEditor.selectionEnd = left; - - _s.textSelection = -1; - } - - if (1 == sendEvents[i + 4]) { - left = Math.min(cellEditor.selectionBegin, cellEditor.selectionEnd); - right = Math.max(cellEditor.selectionBegin, cellEditor.selectionEnd); - cellEditor.cursorPos = right; - cellEditor.selectionBegin = left; - cellEditor.selectionEnd = right; - - _s.textSelection = 1; - } - } - - if (0 === sendEvents[i + 0]) { - var pos = cellEditor.cursorPos; - left = cellEditor.selectionBegin; - right = cellEditor.selectionEnd; - - cellEditor.clickCounter.clickCount = 1; - - cellEditor._onMouseDown(event); - - if (-1 === _s.textSelection) { - cellEditor.cursorPos = Math.min(left - 1, cellEditor.cursorPos); - cellEditor.selectionBegin = left; - cellEditor.selectionEnd = Math.min(left - 1, cellEditor.selectionEnd); - } - else if (1 === _s.textSelection) { - cellEditor.cursorPos = Math.max(left + 1, cellEditor.cursorPos); - cellEditor.selectionBegin = left; - cellEditor.selectionEnd = Math.max(left + 1, cellEditor.selectionEnd); - } - - } else if (1 === sendEvents[i + 0]) { - cellEditor._onMouseUp(event); - _s.textSelection = 0; - } else if (2 == sendEvents[i + 0]) { - - cellEditor._onMouseMove(event); - - } else if (3 == sendEvents[i + 0]) { - cellEditor.clickCounter.clickCount = 2; - cellEditor._onMouseDown(event); - cellEditor._onMouseUp(event); - cellEditor.clickCounter.clickCount = 0; - - _s.textSelection = 0; - } - } - - return [cellEditor.left, cellEditor.top, cellEditor.right, cellEditor.bottom, - cellEditor.curLeft, cellEditor.curTop, cellEditor.curHeight, - cellEditor.textRender.chars.length]; -} -window["native"]["offline_cell_editor_close"] = function(x, y, width, height, ratio) { - var e = {which: 13, shiftKey: false, metaKey: false, ctrlKey: false}; - - var wb = _api.wb; - var ws = _api.wb.getWorksheet(); - var cellEditor = wb.cellEditor; - - // TODO: SHOW POPUP - - var length = cellEditor.undoList.length; - - if (cellEditor.close(true)) { - wb.getWorksheet().handlers.trigger('applyCloseEvent', e); - } else { - cellEditor.close(); - length = 0; - } - - wb.collaborativeEditing.onStopEditCell(); - wb._onWSSelectionChanged() - - return {'undo': length}; -} -window["native"]["offline_cell_editor_selection"] = function() {return _api.wb.cellEditor._drawSelection();} -window["native"]["offline_cell_editor_move_select"] = function(position) {_api.wb.cellEditor._moveCursor(kPosition, Math.min(position,cellEditor.textRender.chars.length));} -window["native"]["offline_cell_editor_select_range"] = function(from, to) { - var cellEditor = _api.wb.cellEditor; - - cellEditor.cursorPos = from; - cellEditor.selectionBegin = from; - cellEditor.selectionEnd = to; -} - -window["native"]["offline_get_cell_in_coord"] = function(x, y) { - var worksheet = _api.wb.getWorksheet(), - activeCell = worksheet.getActiveCell(x, y, true); - - return [ - activeCell.c1, - activeCell.r1, - activeCell.c2, - activeCell.r2, - worksheet._getColLeft(activeCell.c1), - worksheet._getRowTop(activeCell.r1), - worksheet._getColumnWidth(activeCell.c1), - worksheet._getRowHeight(activeCell.r1) ]; -} -window["native"]["offline_get_cell_coord"] = function(c, r) { - var worksheet = _api.wb.getWorksheet(); - - return [ - worksheet._getColLeft(c), - worksheet._getRowTop(r), - worksheet._getColumnWidth(c), - worksheet._getRowHeight(r) ]; -} -window["native"]["offline_get_header_sizes"] = function() { - var worksheet = _api.wb.getWorksheet(); - return [worksheet.headersWidth, worksheet.headersHeight]; -} -window["native"]["offline_get_graphics_object"] = function(x, y) { - var ws = _api.wb.getWorksheet(); - ws._updateDrawingArea(); - - var drawingInfo = ws.objectRender.checkCursorDrawingObject(x, y); - if (drawingInfo) { - return drawingInfo.id; - } - - return null; -} -window["native"]["offline_get_selected_object"] = function() { - var ws = _api.wb.getWorksheet(); - var selectedImages = ws.objectRender.getSelectedGraphicObjects(); - if (selectedImages && selectedImages.length) - return selectedImages[0].Get_Id(); - - return null; -} -window["native"]["offline_can_enter_cell_range"] = function() {return _api.wb.cellEditor.canEnterCellRange();} - -window["native"]["offline_copy"] = function() { - var worksheet = _api.wb.getWorksheet(); - var sBase64 = {}; - - var dataBuffer = {}; - - if (_api.wb.cellEditor.isOpened) { - var v = _api.wb.cellEditor.copySelection(); - if (v) { - dataBuffer.text = AscCommonExcel.getFragmentsText(v); - } - } else { - - var clipboard = {}; - clipboard.pushData = function(type, data) { - - if (AscCommon.c_oAscClipboardDataFormat.Text === type) { - - dataBuffer.text = data; - - } else if (AscCommon.c_oAscClipboardDataFormat.Internal === type) { - - if (null != data.drawingUrls && data.drawingUrls.length > 0) { - dataBuffer.drawingUrls = data.drawingUrls[0]; - } - - dataBuffer.sBase64 = data.sBase64; - } - } - - _api.asc_CheckCopy(clipboard, AscCommon.c_oAscClipboardDataFormat.Internal|AscCommon.c_oAscClipboardDataFormat.Text); - } - - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - - if (dataBuffer.text) { - _stream["WriteByte"](0); - _stream["WriteString2"](dataBuffer.text); - } - - if (dataBuffer.drawingUrls) { - _stream["WriteByte"](1); - _stream["WriteStringA"](dataBuffer.drawingUrls); - } - - if (dataBuffer.sBase64) { - _stream["WriteByte"](2); - _stream["WriteStringA"](dataBuffer.sBase64); - } - - _stream["WriteByte"](255); - - return _stream; -} -window["native"]["offline_paste"] = function(params) { - var type = params[0]; - var worksheet = _api.wb.getWorksheet(); - - if (0 == type) - { - _api.asc_PasteData(AscCommon.c_oAscClipboardDataFormat.Text, params[1]); - } - else if (1 == type) - { - _s.offline_addImageDrawingObject([params[1], params[2],params[3]]); - } - else if (2 == type) - { - _api.asc_PasteData(AscCommon.c_oAscClipboardDataFormat.Internal, params[1]); - } -} -window["native"]["offline_cut"] = function() { - var worksheet = _api.wb.getWorksheet(); - - var dataBuffer = {}; - - if (_api.wb.cellEditor.isOpened) { - var v = _api.wb.cellEditor.copySelection(); - if (v) { - dataBuffer.text = AscCommonExcel.getFragmentsText(v); - _api.wb.cellEditor.cutSelection(); - } - - } else { - - var clipboard = {}; - clipboard.pushData = function(type, data) { - - if (AscCommon.c_oAscClipboardDataFormat.Text === type) { - - dataBuffer.text = data; - - } else if (AscCommon.c_oAscClipboardDataFormat.Internal === type) { - - if (null != data.drawingUrls && data.drawingUrls.length > 0) { - dataBuffer.drawingUrls = data.drawingUrls[0]; - } - - dataBuffer.sBase64 = data.sBase64; - } - } - - _api.asc_CheckCopy(clipboard, AscCommon.c_oAscClipboardDataFormat.Internal|AscCommon.c_oAscClipboardDataFormat.Text); - - worksheet.emptySelection(Asc.c_oAscCleanOptions.All, true); - } - - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - - if (dataBuffer.text) { - _stream["WriteByte"](0); - _stream["WriteString2"](dataBuffer.text); - } - - if (dataBuffer.drawingUrls) { - _stream["WriteByte"](1); - _stream["WriteStringA"](dataBuffer.drawingUrls); - } - - if (dataBuffer.sBase64) { - _stream["WriteByte"](2); - _stream["WriteStringA"](dataBuffer.sBase64); - } - - _stream["WriteByte"](255); - - return _stream; -} -window["native"]["offline_delete"] = function() { - var e = {altKey: false, - bubbles: true, - cancelBubble: false, - cancelable: true, - charCode: 0, - ctrlKey: false, - defaultPrevented: false, - detail: 0, - eventPhase: 3, - keyCode: 46, - type: 'keydown', - which: 46, - preventDefault: function() {} - }; - - var stream = global_memory_stream_menu; - stream["ClearNoAttack"](); - - var ws = _api.wb.getWorksheet(); - var graphicObjects = ws.objectRender.getSelectedGraphicObjects(); - if (graphicObjects.length) { - if (ws.objectRender.graphicObjectKeyDown(e)) { - stream["WriteLong"](1); // SHAPE - return stream; - } - } - - stream["WriteString"](0); - - var worksheet = _api.wb.getWorksheet(); - worksheet.emptySelection(Asc.c_oAscCleanOptions.Text); - - return stream; -} -window["native"]["offline_calculate_range"] = function(x, y, w, h) { - var ws = _api.wb.getWorksheet(); - var range = _s._updateRegion(ws, x, y, w, h); - - range.c1 = range.columnBeg < 0 ? 0 : range.columnBeg; - range.r1 = range.rowBeg < 0 ? 0 : range.rowBeg; - range.c2 = range.columnEnd < 0 ? 0 : range.columnEnd; - range.r2 = range.rowEnd < 0 ? 0 : range.rowEnd; - - return [1, range.c1, range.c2, range.r1, range.r2, - ws._getColLeft(range.c1), - ws._getRowTop(range.r1), - ws._getColLeft(range.c2) + ws._getColumnWidth(range.c2), - ws._getRowTop(range.r2) + ws._getRowHeight(range.r1) ]; -} -window["native"]["offline_calculate_complete_range"] = function(x, y, w, h) { - var ws = _api.wb.getWorksheet(); - var range = _s._updateRegion(ws, x, y, w, h); - - range.c1 = range.columnBeg < 0 ? 0 : range.columnBeg; - range.r1 = range.rowBeg < 0 ? 0 : range.rowBeg; - range.c2 = range.columnEnd < 0 ? 0 : range.columnEnd; - range.r2 = range.rowEnd < 0 ? 0 : range.rowEnd; - - var nativeToEditor = 1.0 / deviceScale; - w = ( x + w ) * nativeToEditor + ws.headersWidth; - h = ( y + h ) * nativeToEditor + ws.headersHeight; - x = x * nativeToEditor + ws.headersWidth; - y = y * nativeToEditor + ws.headersHeight; - - if (ws._getColLeft(range.c2) + ws._getColumnWidth(range.c2) > w) { - range.c2--; - } - - if (ws._getRowTop(range.r2) + ws._getRowHeight(range.r1) > h) { - range.r2--; - } - - return [1, range.c1, range.c2, range.r1, range.r2, - ws._getColLeft(range.c1), - ws._getRowTop(range.r1), - ws._getColLeft(range.c2) + ws._getColumnWidth(range.c2), - ws._getRowTop(range.r2) + ws._getRowHeight(range.r1)]; -} - -window["Asc"]["spreadsheet_api"].prototype.asc_nativeGetFileData = function() { - var oBinaryFileWriter = new AscCommonExcel.BinaryFileWriter(this.wbModel); - - oBinaryFileWriter.Write(true); - - window["native"]["GetFileData"]( - oBinaryFileWriter.Memory.ImData.data, - oBinaryFileWriter.Memory.GetCurPosition()); - - return true; -}; - -window["native"]["offline_apply_event"] = function(type,params) { - var _borderOptions = Asc.c_oAscBorderOptions; - var _stream = null; - var _return = undefined; - var _current = {pos: 0}; - var _continue = true; - var _attr, _ret; - - switch (type) { - - // document interface - - case 3: // ASC_MENU_EVENT_TYPE_UNDO - { - _api.asc_Undo(); - _s.asc_WriteAllWorksheets(true); - break; - } - case 4: // ASC_MENU_EVENT_TYPE_REDO - { - _api.asc_Redo(); - _s.asc_WriteAllWorksheets(true); - break; - } - - case 9: // ASC_MENU_EVENT_TYPE_IMAGE - { - var ws = _api.wb.getWorksheet(); - if (ws && ws.objectRender && ws.objectRender.controller) { - var selectedImageProp = ws.objectRender.controller.getGraphicObjectProps(); - - var _imagePr = new Asc.asc_CImgProperty(); - while (_continue) - { - _attr = params[_current.pos++]; - switch (_attr) - { - case 0: - { - _imagePr.CanBeFlow = params[_current.pos++]; - break; - } - case 1: - { - _imagePr.Width = params[_current.pos++]; - break; - } - case 2: - { - _imagePr.Height = params[_current.pos++]; - break; - } - case 3: - { - _imagePr.WrappingStyle = params[_current.pos++]; - break; - } - case 4: - { - _imagePr.Paddings = AscCommon.asc_menu_ReadPaddings(params, _current); - break; - } - case 5: - { - _imagePr.Position = asc_menu_ReadPosition(params, _current); - break; - } - case 6: - { - _imagePr.AllowOverlap = params[_current.pos++]; - break; - } - case 7: - { - _imagePr.PositionH = asc_menu_ReadImagePosition(params, _current); - break; - } - case 8: - { - _imagePr.PositionV = asc_menu_ReadImagePosition(params, _current); - break; - } - case 9: - { - _imagePr.Internal_Position = params[_current.pos++]; - break; - } - case 10: - { - _imagePr.ImageUrl = params[_current.pos++]; - break; - } - case 11: - { - _imagePr.Locked = params[_current.pos++]; - break; - } - case 12: - { - _imagePr.ChartProperties = asc_menu_ReadChartPr(params, _current); - break; - } - case 13: - { - _imagePr.ShapeProperties = asc_menu_ReadShapePr(params, _current); - break; - } - case 14: - { - { - var layer = params[_current.pos++]; - _api.asc_setSelectedDrawingObjectLayer(layer); - return _return; - } - break; - } - case 15: - { - _imagePr.Group = params[_current.pos++]; - break; - } - case 16: - { - _imagePr.fromGroup = params[_current.pos++]; - break; - } - case 17: - { - _imagePr.severalCharts = params[_current.pos++]; - break; - } - case 18: - { - _imagePr.severalChartTypes = params[_current.pos++]; - break; - } - case 19: - { - _imagePr.severalChartStyles = params[_current.pos++]; - break; - } - case 20: - { - _imagePr.verticalTextAlign = params[_current.pos++]; - break; - } - case 21: - { - _imagePr.vert = params[_current.pos++]; - break; - } - case 22: - { - var bIsNeed = params[_current.pos++]; - if (bIsNeed) { - for (var j = 0; j < selectedImageProp.length; ++j) { - if (selectedImageProp[j] && selectedImageProp[j].Value) { - var urlSource = selectedImageProp[j].Value.ImageUrl; - if (urlSource) { - var _originSize = window["native"]["GetOriginalImageSize"](urlSource); - var _w = _originSize[0] * 25.4 / 96.0 / window["native"]["GetDeviceScale"](); - var _h = _originSize[1] * 25.4 / 96.0 / window["native"]["GetDeviceScale"](); - - _imagePr.ImageUrl = undefined; - - _imagePr.Width = _w; - _imagePr.Height = _h; - } - } - } - } - - break; - } - case 255: - default: - { - _continue = false; - break; - } - } - } - - ws.objectRender.controller.setGraphicObjectProps(_imagePr); - } - break; - } - - case 12: // ASC_MENU_EVENT_TYPE_TABLESTYLES - { - var props, retinaPixelRatio; - - while (_continue) - { - _attr = params[_current.pos++]; - switch (_attr) { - case 0: - { - props = asc_ReadFormatTableInfo(params, _current); - break; - } - case 1: - { - retinaPixelRatio = params[_current.pos++]; - break; - } - case 255: - default: - { - _continue = false; - break; - } - } - } - - AscCommon.AscBrowser.isRetina = true; - AscCommon.AscBrowser.retinaPixelRatio = retinaPixelRatio; - - window["native"]["SetStylesType"](1); - _api.wb.getTableStyles(props); - - AscCommon.AscBrowser.isRetina = false; - AscCommon.AscBrowser.retinaPixelRatio = 1.0; - - break; - } - - case 52: // ASC_MENU_EVENT_TYPE_INSERT_HYPERLINK - { - var props = asc_ReadCHyperLink(params, _current); - _api.asc_insertHyperlink(props); - break; - } - case 59: // ASC_MENU_EVENT_TYPE_REMOVE_HYPERLINK - { - _api.asc_removeHyperlink(); - break; - } - - case 62: // ASC_MENU_EVENT_TYPE_SEARCH_FINDTEXT - { - var findOptions = new Asc.asc_CFindOptions(); - - if (7 === params.length) { - findOptions.asc_setFindWhat(params[0]); - findOptions.asc_setScanForward(params[1]); - findOptions.asc_setIsMatchCase(params[2]); - findOptions.asc_setIsWholeCell(params[3]); - findOptions.asc_setScanOnOnlySheet(params[4]); - findOptions.asc_setScanByRows(params[5]); - findOptions.asc_setLookIn(params[6]); - - _ret = _api.asc_findText(findOptions); - _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - if (_ret) { - _stream["WriteBool"](true); - _stream["WriteDouble2"](_ret[0]); - _stream["WriteDouble2"](_ret[1]); - } else { - _stream["WriteBool"](false); - _stream["WriteDouble2"](0); - _stream["WriteDouble2"](0); - } - - _return = _stream; - } - - break; - } - case 63: // ASC_MENU_EVENT_TYPE_SEARCH_REPLACETEXT - { - var replaceOptions = new Asc.asc_CFindOptions(); - if (8 === params.length) { - replaceOptions.asc_setFindWhat(params[0]); - replaceOptions.asc_setReplaceWith(params[1]); - replaceOptions.asc_setIsMatchCase(params[2]); - replaceOptions.asc_setIsWholeCell(params[3]); - replaceOptions.asc_setScanOnOnlySheet(params[4]); - replaceOptions.asc_setScanByRows(params[5]); - replaceOptions.asc_setLookIn(params[6]); - replaceOptions.asc_setIsReplaceAll(params[7]); - - _api.asc_replaceText(replaceOptions); - } - break; - } - - case 200: // ASC_MENU_EVENT_TYPE_DOCUMENT_BASE64 - { - _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - _stream["WriteStringA"](_api.asc_nativeGetFileData()); - _return = _stream; - break; - } - case 201: // ASC_MENU_EVENT_TYPE_DOCUMENT_CHARTSTYLES - { - var chartPreviewsType = parseInt(params[0]); - var retinaPixelRatio = params[1]; - - AscCommon.AscBrowser.isRetina = true; - AscCommon.AscBrowser.retinaPixelRatio = retinaPixelRatio; - - _api.chartPreviewManager.getChartPreviews(chartPreviewsType); - - AscCommon.AscBrowser.isRetina = false; - AscCommon.AscBrowser.retinaPixelRatio = 1.0; - - _return = global_memory_stream_menu; - break; - } - case 202: // ASC_MENU_EVENT_TYPE_DOCUMENT_PDFBASE64 - { - _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - _stream["WriteStringA"](_s.offline_print(params,_current)); - _return = _stream; - break; - } - - case 110: // ASC_MENU_EVENT_TYPE_CONTEXTMENU_COPY - { - _return = window["native"]["offline_copy"](); - break; - } - case 111 : // ASC_MENU_EVENT_TYPE_CONTEXTMENU_CUT - { - _return = window["native"]["offline_cut"](); - break; - } - case 112: // ASC_MENU_EVENT_TYPE_CONTEXTMENU_PASTE - { - window["native"]["offline_paste"](params); - break; - } - case 113: // ASC_MENU_EVENT_TYPE_CONTEXTMENU_DELETE - { - _return = window["native"]["offline_delete"](); - break; - } - case 114: // ASC_MENU_EVENT_TYPE_CONTEXTMENU_SELECT - { - //this.Call_Menu_Context_Select(); - break; - } - - // add objects - - case 50: // ASC_MENU_EVENT_TYPE_INSERT_IMAGE - { - _return = _s.offline_addImageDrawingObject(params); - break; - } - case 53: // ASC_MENU_EVENT_TYPE_INSERT_SHAPE - { - _return = _s.offline_addShapeDrawingObject(params); - break; - } - case 400: // ASC_MENU_EVENT_TYPE_INSERT_CHART - { - _return = _s.offline_addChartDrawingObject(params); - break; - } - case 450: // ASC_MENU_EVENT_TYPE_GET_CHART_DATA - { - var chart = _api.asc_getWordChartObject(); - - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - _stream["WriteStringA"](JSON.stringify(chart)); - _return = _stream; - - break; - } - - // Cell interface - - case 2000: // ASC_SPREADSHEETS_EVENT_TYPE_SET_CELL_INFO - { - var borders = null; - var border = null; - var filterInfo = null; - - while (_continue) { - _attr = params[_current.pos++]; - switch (_attr) { - case 0: - { - _api.asc_setCellAlign(params[_current.pos++]); - break; - } - case 1: - { - _api.asc_setCellVertAlign(params[_current.pos++]); - break; - } - case 2: - { - _api.asc_setCellFontName(params[_current.pos++]); - break; - } - case 3: - { - _api.asc_setCellFontSize(params[_current.pos++]); - break; - } - case 4: - { - _api.asc_setCellBold(params[_current.pos++]); - break; - } - case 5: - { - _api.asc_setCellItalic(params[_current.pos++]); - break; - } - case 6: - { - _api.asc_setCellUnderline(params[_current.pos++]); - break; - } - case 7: - { - _api.asc_setCellStrikeout(params[_current.pos++]); - break; - } - case 8: - { - _api.asc_setCellSubscript(params[_current.pos++]); - break; - } - case 9: - { - _api.asc_setCellSuperscript(params[_current.pos++]); - break; - } - case 10: - { - _api.asc_setCellTextColor(AscCommon.asc_menu_ReadColor(params, _current)); - break; - } - case 11: - { - _api.asc_setCellTextWrap(params[_current.pos++]); - break; - } - case 12: - { - _api.asc_setCellTextShrink(params[_current.pos++]); - break; - } - case 13: - { - var fillColor = AscCommon.asc_menu_ReadColor(params, _current); - if (0.0 === fillColor.a) { - _api.asc_setCellBackgroundColor(null); - } else { - _api.asc_setCellBackgroundColor(fillColor); - } - break; - } - case 14: - { - _api.asc_setCellFormat(params[_current.pos++]); - break; - } - case 15: - { - _api.asc_setCellAngle(parseFloat(params[_current.pos++])); - break; - } - case 16: - { - _api.asc_setCellStyle(params[_current.pos++]); - break; - } - - case 20: - { - if (!borders) borders = []; - border = asc_ReadCBorder(params, _current); - if (border) { - borders[_borderOptions.Left] = border; - } - break; - } - - case 21: - { - if (!borders) borders = []; - border = asc_ReadCBorder(params, _current); - if (border && borders) { - borders[_borderOptions.Top] = border; - } - break; - } - - case 22: - { - if (!borders) borders = []; - border = asc_ReadCBorder(params, _current); - if (border && borders) { - borders[_borderOptions.Right] = border; - } - break; - } - - case 23: - { - if (!borders) borders = []; - border = asc_ReadCBorder(params, _current); - if (border && borders) { - borders[_borderOptions.Bottom] = border; - } - break; - } - - case 24: - { - if (!borders) borders = []; - border = asc_ReadCBorder(params, _current); - if (border && borders) { - borders[_borderOptions.DiagD] = border; - } - break; - } - - case 25: - { - if (!borders) borders = []; - border = asc_ReadCBorder(params, _current); - if (border && borders) { - borders[_borderOptions.DiagU] = border; - } - break; - } - - case 26: - { - if (!borders) borders = []; - border = asc_ReadCBorder(params, _current); - if (border && borders) { - borders[_borderOptions.InnerV] = border; - } - break; - } - - case 27: - { - if (!borders) borders = []; - border = asc_ReadCBorder(params, _current); - if (border && borders) { - borders[_borderOptions.InnerH] = border; - } - break; - } - - case 28: - { - _api.asc_setCellBorders([]); - break; - } - - case 255: - default: - { - _continue = false; - break; - } - } - } - - if (borders) { - _api.asc_setCellBorders(borders); - } - - break; - } - case 2010: // ASC_SPREADSHEETS_EVENT_TYPE_CELLS_MERGE_TEST - { - _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - - var merged = _api.asc_getCellInfo().asc_getMerge(); - - if (!merged && _api.asc_mergeCellsDataLost(params)) { - _stream["WriteBool"](true); - } else { - _stream["WriteBool"](false); - } - - _return = _stream; - break; - } - case 2020: // ASC_SPREADSHEETS_EVENT_TYPE_CELLS_MERGE - { - _api.asc_mergeCells(params); - break; - } - case 2030: // ASC_SPREADSHEETS_EVENT_TYPE_CELLS_FORMAT - { - _api.asc_setCellFormat(params); - break; - } - case 2031: // ASC_SPREADSHEETS_EVENT_TYPE_CELLS_DECREASE_DIGIT_NUMBERS - { - _api.asc_decreaseCellDigitNumbers(); - break; - } - case 2032: // ASC_SPREADSHEETS_EVENT_TYPE_CELLS_ICREASE_DIGIT_NUMBERS - { - _api.asc_increaseCellDigitNumbers(); - break; - } - case 2040: // ASC_SPREADSHEETS_EVENT_TYPE_COLUMN_SORT_FILTER - { - if (params.length) { - var typeF = parseInt(params[0]), cellId = ''; - if (2 === params.length) - cellId = params[1]; - _api.asc_sortColFilter(typeF, cellId); - } - break; - } - case 2050: // ASC_SPREADSHEETS_EVENT_TYPE_CLEAR_STYLE - { - _api.asc_emptyCells(params); - break; - } - - // Workbook interface - - case 2100: // ASC_SPREADSHEETS_EVENT_TYPE_WORKSHEETS_COUNT - { - _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - _stream["WriteLong"](_api.asc_getWorksheetsCount()); - _return = _stream; - break; - } - case 2110: // ASC_SPREADSHEETS_EVENT_TYPE_GET_WORKSHEET - { - _stream = global_memory_stream_menu; - _s.asc_writeWorksheet(params); - _return = _stream; - break - } - case 2120: // ASC_SPREADSHEETS_EVENT_TYPE_SET_WORKSHEET - { - var index = -1; - while (_continue) { - _attr = params[_current.pos++]; - switch (_attr) { - case 0: // index - { - index = (params[_current.pos++]); - break; - } - case 1: // name - { - var name = (params[_current.pos++]); - _api.asc_renameWorksheet(name); - _s.asc_WriteAllWorksheets(true); - break; - } - case 2: // color - { - var tabColor = AscCommon.asc_menu_ReadColor(params, _current); - _api.asc_setWorksheetTabColor(tabColor); - _s.asc_WriteAllWorksheets(true); - break; - } - case 4: // hidden - { - _api.asc_hideWorksheet(); - _s.asc_WriteAllWorksheets(true); - break; - } - - case 5: // show gridlines - { - var isLines = _api.asc_getSheetViewSettings(); - isLines.asc_setShowGridLines(params[_current.pos++]); - _api.asc_setDisplayGridlines(isLines.showGridLines); - _s.asc_WriteAllWorksheets(true); - break; - } - - case 6: // row col headers - { - var isHeaders = _api.asc_getSheetViewSettings(); - isHeaders.asc_setShowRowColHeaders(params[_current.pos++]); - _api.asc_setDisplayHeadings(isHeaders.showRowColHeaders); - _s.asc_WriteAllWorksheets(true); - break; - } - - case 255: - default: - { - _continue = false; - break; - } - } - } - break; - } - case 2130: // ASC_SPREADSHEETS_EVENT_TYPE_WORKSHEETS - { - _stream = global_memory_stream_menu; - _s.asc_WriteAllWorksheets(); - _return = _stream; - break; - } - case 2140: // ASC_SPREADSHEETS_EVENT_TYPE_ADD_WORKSHEET - { - _api.asc_addWorksheet(params); - _s.asc_WriteAllWorksheets(true); - break; - } - case 2150: // ASC_SPREADSHEETS_EVENT_TYPE_INSERT_WORKSHEET - { - _api.asc_insertWorksheet(params); - _s.asc_WriteAllWorksheets(true); - break; - } - case 2160: // ASC_SPREADSHEETS_EVENT_TYPE_DELETE_WORKSHEET - { - _api.asc_deleteWorksheet([params]); - _s.asc_WriteAllWorksheets(true); - break; - } - case 2170: // ASC_SPREADSHEETS_EVENT_TYPE_COPY_WORKSHEET - { - if (params.length) { - _api.asc_copyWorksheet(params[0], params[1]); // where, newName - _s.asc_WriteAllWorksheets(true); - } - - break; - } - case 2180: // ASC_SPREADSHEETS_EVENT_TYPE_MOVE_WORKSHEET - { - _api.asc_moveWorksheet(params); - _s.asc_WriteAllWorksheets(true); - break; - } - case 2200: // ASC_SPREADSHEETS_EVENT_TYPE_SHOW_WORKSHEET - { - _api.asc_showWorksheet(params); - break; - } - case 2201: // ASC_SPREADSHEETS_EVENT_TYPE_UNHIDE_WORKSHEET - { - _api.asc_showWorksheet(params); - _s.asc_WriteAllWorksheets(true); - break; - } - case 2205: // ASC_SPREADSHEETS_EVENT_TYPE_WORKSHEET_SHOW_LINES - { - _api.asc_setDisplayGridlines(params > 0); - break; - } - case 2210: // ASC_SPREADSHEETS_EVENT_TYPE_WORKSHEET_SHOW_HEADINGS - { - _api.asc_setDisplayHeadings(params > 0); - break; - } - case 2215: // ASC_SPREADSHEETS_EVENT_TYPE_SET_PAGE_OPTIONS - { - var pageOptions = asc_ReadPageOptions(params, _current); - _api.asc_setPageOptions(pageOptions, pageOptions.pageIndex); - break; - } - - case 2400: // ASC_SPREADSHEETS_EVENT_TYPE_COMPLETE_SEARCH - { - _api.asc_endFindText(); - break; - } - - case 2405: // ASC_SPREADSHEETS_EVENT_TYPE_CELL_STYLES - { - var retinaPixelRatio = params[0]; - - AscCommon.AscBrowser.isRetina = true; - AscCommon.AscBrowser.retinaPixelRatio = retinaPixelRatio; - - window["native"]["SetStylesType"](0); - _api.wb.getCellStyles(92, 48); - - AscCommon.AscBrowser.isRetina = false; - AscCommon.AscBrowser.retinaPixelRatio = 1.0; - break; - } - - case 2415: // ASC_SPREADSHEETS_EVENT_TYPE_CHANGE_COLOR_SCHEME - { - if (undefined !== params) { - var indexScheme = parseInt(params); - _api.asc_ChangeColorSchemeByIdx(indexScheme); - } - break; - } - - case 2416: // ASC_MENU_EVENT_TYPE_GET_COLOR_SCHEME - { - var index = _api.asc_GetCurrentColorSchemeIndex(); - var stream = global_memory_stream_menu; - stream["ClearNoAttack"](); - stream["WriteLong"](index); - _return = stream; - break; - } - - case 3000: // ASC_SPREADSHEETS_EVENT_TYPE_FILTER_ADD_AUTO - { - var filter = asc_ReadAutoFilter(params, _current); - _api.asc_addAutoFilter(filter.styleName, filter.format); - _api.wb.getWorksheet().handlers.trigger('selectionChanged'); - break; - } - - case 3010: // ASC_SPREADSHEETS_EVENT_TYPE_AUTO_FILTER_CHANGE - { - var changeFilter = asc_ReadAutoFilter(params, _current); - - if (changeFilter && 'FALSE' === changeFilter.styleName) { - changeFilter.styleName = false; - } - - _api.asc_changeAutoFilter(changeFilter.tableName, changeFilter.optionType, changeFilter.styleName); - _api.wb.getWorksheet().handlers.trigger('selectionChanged'); - break; - } - - case 3020: // ASC_SPREADSHEETS_EVENT_TYPE_AUTO_FILTER_APPLY - { - var autoFilter = asc_ReadAutoFiltersOptions(params, _current); - _api.asc_applyAutoFilter(autoFilter); - break; - } - - case 3040: // ASC_SPREADSHEETS_EVENT_TYPE_AUTO_FILTER_FORMAT_TABLE_OPTIONS - { - var formatOptions = _api.asc_getAddFormatTableOptions(params); - _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - asc_WriteAddFormatTableOptions(formatOptions, _stream); - _return = _stream; - break; - } - - case 3050: // ASC_SPREADSHEETS_EVENT_TYPE_FILTER_CLEAR - { - _api.asc_clearFilter(); - break; - } - - case 4010: // ASC_SPREADSHEETS_EVENT_TYPE_INSERT_FORMULA - { - if (params && params.length && params[0]) { - _api.asc_insertInCell(params[0], Asc.c_oAscPopUpSelectorType.Func, params[1]); - } - break; - } - - case 4020: // ASC_SPREADSHEETS_EVENT_TYPE_GET_FORMULAS - { - if (undefined !== params) { - var localizeData = JSON.parse(params); - _api.asc_setLocalization(localizeData); - } - - _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - - var info = _api.asc_getFormulasInfo(); - if (info) { - _stream["WriteLong"](info.length); - - for (var i = 0; i < info.length; ++i) { - _stream["WriteString2"](info[i].asc_getGroupName()); - - var ascFunctions = info[i].asc_getFormulasArray(); - _stream["WriteLong"](ascFunctions.length); - - for (var j = 0; j < ascFunctions.length; ++j) { - _stream["WriteString2"](ascFunctions[j].asc_getName()); - _stream["WriteString2"](""); - } - } - } else { - _stream["WriteLong"](0); - } - - _return = _stream; - - break; - } - - case 5000: // ASC_SPREADSHEETS_EVENT_TYPE_GO_LINK_TYPE_INTERNAL_DATA_RANGE - { - var cellX = params[0]; - var cellY = params[1]; - var ws = _api.wb.getWorksheet(); - var ct = ws.getCursorTypeFromXY(cellX, cellY); - - var curIndex = _api.asc_getActiveWorksheetIndex(); - - if (AscCommonExcel.c_oTargetType.Hyperlink === ct.target) { - _api._asc_setWorksheetRange(ct.hyperlink); - } - - _stream = global_memory_stream_menu; - - _stream["ClearNoAttack"](); - _stream["WriteBool"](!(curIndex === _api.asc_getActiveWorksheetIndex())); - - _return = _stream; - break; - } - - case 6000: // ASC_SPREADSHEETS_EVENT_TYPE_CONTEXTMENU_CLEAR_ALL: - { - _api.asc_emptyCells(Asc.c_oAscCleanOptions.All); - break; - } - - case 6010: // ASC_SPREADSHEETS_EVENT_TYPE_CONTEXTMENU_CLEAR_TEXT - { - _api.asc_emptyCells(Asc.c_oAscCleanOptions.Text); - break; - } - - case 6020: // ASC_SPREADSHEETS_EVENT_TYPE_CONTEXTMENU_CLEAR_FORMAT - { - _api.asc_emptyCells(Asc.c_oAscCleanOptions.Format); - break; - } - - case 6030: // ASC_SPREADSHEETS_EVENT_TYPE_CONTEXTMENU_CLEAR_COMMENTS - { - _api.asc_emptyCells(Asc.c_oAscCleanOptions.Comments); - break; - } - - case 6040: // ASC_SPREADSHEETS_EVENT_TYPE_CONTEXTMENU_CLEAR_HYPERLINKS - { - _api.asc_emptyCells(Asc.c_oAscCleanOptions.Hyperlinks); - break; - } - - case 6050: // ASC_SPREADSHEETS_EVENT_TYPE_CONTEXTMENU_INSERT_LEFT - { - _api.asc_insertCells(Asc.c_oAscInsertOptions.InsertColumns); - break; - } - - case 6060: // ASC_SPREADSHEETS_EVENT_TYPE_CONTEXTMENU_INSERT_TOP - { - _api.asc_insertCells(Asc.c_oAscInsertOptions.InsertRows); - break; - } - - case 6070: // ASC_SPREADSHEETS_EVENT_TYPE_CONTEXTMENU_DELETE_COLUMNES - { - _api.asc_deleteCells(Asc.c_oAscDeleteOptions.DeleteColumns); - break; - } - - case 6080: // ASC_SPREADSHEETS_EVENT_TYPE_CONTEXTMENU_DELETE_ROWS - { - _api.asc_deleteCells(Asc.c_oAscDeleteOptions.DeleteRows); - break; - } - - case 6090: // ASC_SPREADSHEETS_EVENT_TYPE_CONTEXTMENU_SHOW_COLUMNES - { - (0 != params) ? _api.asc_showColumns() : _api.asc_hideColumns(); - break; - } - - case 6100: // ASC_SPREADSHEETS_EVENT_TYPE_CONTEXTMENU_SHOW_ROWS - { - (0 != params) ? _api.asc_showRows() : _api.asc_hideRows(); - break; - } - - case 6190: // ASC_SPREADSHEETS_EVENT_TYPE_CONTEXTMENU_FREEZE_PANES - { - - break; - } - - case 7001: // ASC_SPREADSHEETS_EVENT_TYPE_CHECK_DATA_RANGE - { - var isValid = _api.asc_checkDataRange(parseInt(params[0]), params[1], params[2], params[3], parseInt(params[4])); - - _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - _stream["WriteLong"](isValid); - _return = _stream; - break; - } - - case 7005: // ASC_SPREADSHEETS_EVENT_TYPE_GET_CHART_SETTINGS - { - var chartSettings = _api.asc_getChartObject(); - if (chartSettings) { - _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - - asc_menu_WriteChartPr(12, chartSettings, _stream); - _return = _stream; - } - break; - } - - case 7010: // ASC_SPREADSHEETS_EVENT_TYPE_SET_COLUMN_WIDTH - { - var width = params[0]; - var fromColumn = params[1]; - var toColumn = params[2]; - - var ws = _api.wb.getWorksheet(); - ws.changeColumnWidth(toColumn, width, 0); - break; - } - - case 7020: // ASC_SPREADSHEETS_EVENT_TYPE_SET_ROW_HEIGHT - { - var height = params[0]; - var fromRow = params[1]; - var toRow = params[2]; - - var ws = _api.wb.getWorksheet(); - ws.changeRowHeight(toRow, height, 0); - break; - } - - case 10000: // ASC_SOCKET_EVENT_TYPE_OPEN - { - _api.CoAuthoringApi._CoAuthoringApi.socketio.onMessage("connect"); - break; - } - - case 10010: // ASC_SOCKET_EVENT_TYPE_ON_CLOSE - { - // NOT USED - break; - } - - case 10020: // ASC_SOCKET_EVENT_TYPE_MESSAGE - { - _api.CoAuthoringApi._CoAuthoringApi.socketio.onMessage("message", params ? JSON.parse(params) : {}); - break; - } - - case 11010: // ASC_SOCKET_EVENT_TYPE_ON_DISCONNECT - { - _api.CoAuthoringApi._CoAuthoringApi.socketio.onMessage("disconnect", params || ""); - break; - } - - case 11020: // ASC_SOCKET_EVENT_TYPE_TRY_RECONNECT - { - // NOT USED - break; - } - - case 21000: // ASC_COAUTH_EVENT_TYPE_INSERT_URL_IMAGE - { - var urls = JSON.parse(params[0]); - AscCommon.g_oDocumentUrls.addUrls(urls); - var firstUrl; - for (var i in urls) { - if (urls.hasOwnProperty(i)) { - firstUrl = urls[i]; - break; - } - } - - params[0] = firstUrl; - _return = _s.offline_addImageDrawingObject(params); - - break; - } - - case 21002: // ASC_COAUTH_EVENT_TYPE_REPLACE_URL_IMAGE - { - var urls = JSON.parse(params[0]); - AscCommon.g_oDocumentUrls.addUrls(urls); - var firstUrl; - for (var i in urls) { - if (urls.hasOwnProperty(i)) { - firstUrl = urls[i]; - break; - } - } - - var _src = firstUrl; - - var imageProp = new Asc.asc_CImgProperty(); - imageProp.ImageUrl = _src; - - var ws = _api.wb.getWorksheet(); - if (ws && ws.objectRender && ws.objectRender.controller) { - ws.objectRender.controller.setGraphicObjectProps(imageProp); - } - - break; - } - - case 22000: // ASC_MENU_EVENT_TYPE_ADVANCED_OPTIONS - { - var obj = JSON.parse(params); - var type = parseInt(obj["type"]); - var encoding = parseInt(obj["encoding"]); - var delimiter = parseInt(obj["delimiter"]); - - _api.advancedOptionsAction = AscCommon.c_oAscAdvancedOptionsAction.Open; - _api.documentFormat = "csv"; - - _api.asc_setAdvancedOptions(type, new Asc.asc_CTextOptions(encoding, delimiter, null)); - - break; - } - - case 22001: // ASC_MENU_EVENT_TYPE_SET_PASSWORD - { - _api.asc_setDocumentPassword(params[0]); - break; - } - - case 23101: // ASC_MENU_EVENT_TYPE_DO_SELECT_COMMENT - { - var json = JSON.parse(params[0]); - if (json && json["id"]) { - if (_api.asc_selectComment) { - _api.asc_selectComment(json["id"]); - } - } - break; - } - - case 23102: // ASC_MENU_EVENT_TYPE_DO_SHOW_COMMENT - { - var json = JSON.parse(params[0]); - if (json && json["id"]) { - if (_api.asc_showComment) { - _api.asc_showComment(json["id"], json["isNew"] === true); - } - } - break; - } - - case 23103: // ASC_MENU_EVENT_TYPE_DO_SELECT_COMMENTS - { - var json = JSON.parse(params[0]); - if (json) { - if (_api.asc_showComments) { - _api.asc_showComments(json["resolved"] === true); - } - } - break; - } - - case 23104: // ASC_MENU_EVENT_TYPE_DO_DESELECT_COMMENTS - { - if (_api.asc_hideComments) { - _api.asc_hideComments(); - } - break; - } - - case 23105: // ASC_MENU_EVENT_TYPE_DO_ADD_COMMENT - { - var json = JSON.parse(params[0]); - if (json) { - var buildCommentData = function () { - if (typeof Asc.asc_CCommentDataWord !== 'undefined') { - return new Asc.asc_CCommentDataWord(null); - } - return new Asc.asc_CCommentData(null); - }; - - var comment = buildCommentData(); - var now = new Date(); - var timeZoneOffsetInMs = (new Date()).getTimezoneOffset() * 60000; - var currentUserId = _internalStorage.externalUserInfo.asc_getId(); - var currentUserName = _internalStorage.externalUserInfo.asc_getFullName(); - - if (comment) { - comment.asc_putText(json["text"]); - comment.asc_putTime((now.getTime() - timeZoneOffsetInMs).toString()); - comment.asc_putOnlyOfficeTime(now.getTime().toString()); - comment.asc_putUserId(currentUserId); - comment.asc_putUserName(currentUserName); - comment.asc_putSolved(false); - - if (comment.asc_putDocumentFlag) { - comment.asc_putDocumentFlag(json["unattached"]); - } - - _api.asc_addComment(comment); - } - } - break; - } - - case 23106: // ASC_MENU_EVENT_TYPE_DO_REMOVE_COMMENT - { - var json = JSON.parse(params[0]); - if (json && json["id"]) { // id - String - if (_api.asc_removeComment) { - _api.asc_removeComment(json["id"]); - } - } - break; - } - - case 23107: // ASC_MENU_EVENT_TYPE_DO_REMOVE_ALL_COMMENTS - { - var json = JSON.parse(params[0]), - type = json["type"], - canEditComments = json["canEditComments"]; - if (json && type) { - if (_api.asc_RemoveAllComments) { - _api.asc_RemoveAllComments(type == 'my' || !(canEditComments === true), type == 'current'); // 1 param = true if remove only my comments, 2 param - remove current comments - } - } - break; - } - - case 23108: // ASC_MENU_EVENT_TYPE_DO_CHANGE_COMMENT - { - var json = JSON.parse(params[0]), - commentId = json["id"], - comment = json["comment"], - updateAuthor = json["updateAuthor"] || false; - - if (json && commentId) { - var timeZoneOffsetInMs = (new Date()).getTimezoneOffset() * 60000; - var currentUserId = _internalStorage.externalUserInfo.asc_getId(); - var currentUserName = _internalStorage.externalUserInfo.asc_getFullName(); - var buildCommentData = function () { - if (typeof Asc.asc_CCommentDataWord !== 'undefined') { - return new Asc.asc_CCommentDataWord(null); - } - return new Asc.asc_CCommentData(null); - }; - var ooDateToString = function (date) { - if (Object.prototype.toString.call(date) === '[object Date]') - return (date.getTime()).toString(); - return ""; - }; - var utcDateToString = function (date) { - if (Object.prototype.toString.call(date) === '[object Date]') - return (date.getTime() - timeZoneOffsetInMs).toString(); - return ""; - }; - var ascComment = buildCommentData(); - - if (ascComment && comment && _api.asc_changeComment) { - var sTime = new Date(parseInt(comment["date"])); - ascComment.asc_putText(comment["text"]); - ascComment.asc_putQuoteText(comment["quoteText"]); - ascComment.asc_putTime(utcDateToString(sTime)); - ascComment.asc_putOnlyOfficeTime(ooDateToString(sTime)); - ascComment.asc_putUserId(updateAuthor ? currentUserId : comment["userId"]); - ascComment.asc_putUserName(updateAuthor ? currentUserName : comment["userName"]); - ascComment.asc_putSolved(comment["solved"]); - ascComment.asc_putGuid(comment["id"]); - - if (ascComment.asc_putDocumentFlag !== undefined) { - ascComment.asc_putDocumentFlag(comment["unattached"]); - } - - var replies = comment["replies"]; - - if (replies && replies.length) { - replies.forEach(function (reply) { - var addReply = buildCommentData(); // new asc_CCommentData(null); - if (addReply) { - var sTime = new Date(parseInt(reply["date"])); - addReply.asc_putText(reply["text"]); - addReply.asc_putTime(utcDateToString(sTime)); - addReply.asc_putOnlyOfficeTime(ooDateToString(sTime)); - addReply.asc_putUserId(reply["userId"]); - addReply.asc_putUserName(reply["userName"]); - - ascComment.asc_addReply(addReply); - } - }); - } - _api.asc_changeComment(commentId, ascComment); - } - } - break; - } - - case 25001: // ASC_MENU_EVENT_TYPE_DO_API_FUNCTION_CALL - { - var json = JSON.parse(params[0]), - func = json["func"], - params = json["params"] || [], - returnable = json["returnable"] || false; // need return result - - if (json && func) { - if (_api[func]) { - if (returnable) { - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - var result = _api[func].apply(_api, params); - _stream["WriteString2"](JSON.stringify({ - result: result - })); - _return = _stream; - } else { - _api[func].apply(_api, params); - } - } - } - break; - } - - default: - break; - } - - return _return; -} - -AscCommon.isApiAddCommentAsync = true; - -window["Asc"]["spreadsheet_api"].prototype.asc_setDocumentPassword = function(password) -{ - var v = { - "id": this.documentId, - "userid": this.documentUserId, - "format": this.documentFormat, - "c": "reopen", - "title": this.documentTitle, - "password": password - }; - - AscCommon.sendCommand(this, null, v); -}; - -function testLockedObjects () { - - var ws = _api.wb.getWorksheet(); - var objectRender = ws.objectRender; - var aObjects = ws.model.Drawings; - - var overlay = objectRender.getDrawingCanvas().autoShapeTrack; - if (!overlay) - return; - var drawingArea = objectRender.drawingArea; - overlay.Native["PD_DrawLockedObjectsBegin"](); - - for (var i = 0; i < aObjects.length; i++) { - var drawingObject = aObjects[i]; - - if (drawingObject.isGraphicObject()) { - ws._updateDrawingArea(); - - for (var j = 0; j < drawingArea.frozenPlaces.length; ++j) { - if (drawingArea.frozenPlaces[j].isObjectInside(drawingObject)) { - - // Lock - if ( (drawingObject.graphicObject.lockType != undefined) && (drawingObject.graphicObject.lockType != AscCommon.c_oAscLockTypes.kLockTypeNone) ) { - overlay.transform3(drawingObject.graphicObject.transform, false, "PD_LockObjectTransform"); - overlay.Native["PD_DrawLockObjectRect"](drawingObject.graphicObject.lockType, 0, 0, drawingObject.graphicObject.extX, drawingObject.graphicObject.extY); - } - } - } - } - } - - if ( ws.collaborativeEditing.getCollaborativeEditing() ) { - ws._drawCollaborativeElementsMeOther(AscCommon.c_oAscLockTypes.kLockTypeMine, overlay); - ws._drawCollaborativeElementsMeOther(AscCommon.c_oAscLockTypes.kLockTypeOther, overlay); - ws._drawCollaborativeElementsAllLock(overlay); - } - - overlay.Native["PD_DrawLockedObjectsEnd"](); -} - -window["AscCommonExcel"].WorksheetView.prototype._drawCollaborativeElementsMeOther = function (type, overlay) { - var currentSheetId = this.model.getId(), i, strokeColor, arrayCells, oCellTmp; - - if (!currentSheetId) - return; - - if (AscCommon.c_oAscLockTypes.kLockTypeMine === type) { - strokeColor = AscCommonExcel.c_oAscCoAuthoringMeBorderColor; - arrayCells = this.collaborativeEditing.getLockCellsMe(currentSheetId); - - arrayCells = arrayCells.concat(this.collaborativeEditing.getArrayInsertColumnsBySheetId(currentSheetId)); - arrayCells = arrayCells.concat(this.collaborativeEditing.getArrayInsertRowsBySheetId(currentSheetId)); - } else { - strokeColor = AscCommonExcel.c_oAscCoAuthoringOtherBorderColor; - arrayCells = this.collaborativeEditing.getLockCellsOther(currentSheetId); - } - - var sheetId = this.model.getId(); - if (!sheetId) - return; - - for (i = 0; i < arrayCells.length; ++i) { - - var left = this._getColLeft(arrayCells[i].c1), top = this._getRowTop(arrayCells[i].r1); - - var userId = ""; - if (AscCommon.c_oAscLockTypes.kLockTypeMine !== type) { - var lockInfo = this.collaborativeEditing.getLockInfo(AscCommonExcel.c_oAscLockTypeElem.Range, - null, - sheetId, - new AscCommonExcel.asc_CCollaborativeRange(arrayCells[i].c1, arrayCells[i].r1, arrayCells[i].c2, arrayCells[i].r2)); - var isLocked = this.collaborativeEditing.getLockIntersection(lockInfo, AscCommon.c_oAscLockTypes, AscCommon.c_oAscLockTypes.kLockTypeOther, false); - if (false !== isLocked) { - userId = isLocked.UserId; - } - } - - overlay.Native["PD_DrawLockCell"](arrayCells[i].c1, - arrayCells[i].r1, - Math.min(arrayCells[i].c2, this.nColsCount - 1), - Math.min(arrayCells[i].r2, this.nRowsCount - 1), - left, - top, - this._getColumnWidth(Math.min(arrayCells[i].c2, this.nColsCount - 1)) + this._getColLeft(Math.min(arrayCells[i].c2, this.nColsCount - 1)) - left, - this._getRowHeight(Math.min(arrayCells[i].r2, this.nRowsCount - 1)) + this._getRowTop(Math.min(arrayCells[i].r2, this.nRowsCount - 1)) - top, - strokeColor.r, - strokeColor.g, - strokeColor.b, - strokeColor.a, - userId); - } -}; - -window["AscCommonExcel"].WorksheetView.prototype._drawCollaborativeElementsAllLock = function (overlay) { - var currentSheetId = this.model.getId(); - if (!currentSheetId) - return; - - var nLockAllType = this.collaborativeEditing.isLockAllOther(currentSheetId); - if (Asc.c_oAscMouseMoveLockedObjectType.None !== nLockAllType) { - var isAllRange = true, strokeColor = (Asc.c_oAscMouseMoveLockedObjectType.TableProperties === nLockAllType) ? - AscCommonExcel.c_oAscCoAuthoringLockTablePropertiesBorderColor : - AscCommonExcel.c_oAscCoAuthoringOtherBorderColor, oAllRange = new window["Asc"].Range(0, 0, AscCommon.gc_nMaxCol0, AscCommon.gc_nMaxRow0); - - var left = this._getColLeft(oAllRange.c1), top = this._getRowTop(oAllRange.r1); - - var sheetId = this.model.getId(); - if (!sheetId) - return; - - var userId = ""; - var lockInfo = this.collaborativeEditing.getLockInfo(AscCommonExcel.c_oAscLockTypeElem.Range, - null, - sheetId, - new AscCommonExcel.asc_CCollaborativeRange(oAllRange.c1, oAllRange.c2, oAllRange.c2, oAllRange.r2)); - var isLocked = this.collaborativeEditing.getLockIntersection(lockInfo, AscCommon.c_oAscLockTypes, AscCommon.c_oAscLockTypes.kLockTypeOther, false); - if (false !== isLocked) { - userId = isLocked.UserId; - } - - overlay.Native["PD_DrawLockCell"](oAllRange.c1, - oAllRange.r1, - Math.min(oAllRange.c2, this.nColsCount - 1), - Math.min(oAllRange.r2, this.nRowsCount - 1), - left, - top, - this._getColumnWidth(Math.min(oAllRange.c2, this.nColsCount - 1)) + this._getColLeft(Math.min(oAllRange.c2, this.nColsCount - 1)) - left, - this._getRowHeight(Math.min(oAllRange.r2, this.nRowsCount - 1)) + this._getRowTop(Math.min(oAllRange.r2, this.nRowsCount - 1)) - top, - strokeColor.r, - strokeColor.g, - strokeColor.b, - strokeColor.a, - userId); - } -}; - -window["AscCommonExcel"].WorksheetView.prototype._drawCollaborativeElements = function(overlay) { - if (this.collaborativeEditing.getCollaborativeEditing()) { - this._drawCollaborativeElementsMeOther(AscCommon.c_oAscLockTypes.kLockTypeMine, overlay); - this._drawCollaborativeElementsMeOther(AscCommon.c_oAscLockTypes.kLockTypeOther, overlay); - this._drawCollaborativeElementsAllLock(AscCommon.overlay); - } -}; - -window["Asc"]["spreadsheet_api"].prototype.openDocument = function(file) { - - var t = this; - - setTimeout(function() { - - //console.log("JS - openDocument()"); - - t._openDocument(file.data); - - var thenCallback = function() { - Asc.ReadDefTableStyles(t.wbModel); - t.wb = new AscCommonExcel.WorkbookView(t.wbModel, t.controller, t.handlers, - window["_null_object"], window["_null_object"], t, - t.collaborativeEditing, t.fontRenderingMode); - t.setDrawGroupsRestriction(); - - if (!sdkCheck) { - - //console.log("OPEN FILE ONLINE"); - - t.wb.showWorksheet(undefined, true); - - var ws = t.wb.getWorksheet(); - window["native"]["onEndLoadingFile"](ws.headersWidth, ws.headersHeight); - - _s.asc_WriteAllWorksheets(true); - _s.asc_WriteCurrentCell(); - t.asc_setZoom(_s.zoom); - - return; - } - - t.asc_CheckGuiControlColors(); - t.sendColorThemes(_api.wbModel.theme); - t.asc_ApplyColorScheme(false); - - t.sendStandartTextures(); - - //console.log("JS - applyFirstLoadChanges() before"); - - t._applyPreOpenLocks(); - // Применяем пришедшие при открытии изменения - t._applyFirstLoadChanges(); - // Go to if sent options - t.goTo(); - - t.isDocumentLoadComplete = true; - - // Меняем тип состояния (на никакое) - t.advancedOptionsAction = AscCommon.c_oAscAdvancedOptionsAction.None; - - // Были ошибки при открытии, посылаем предупреждение - if (0 < t.wbModel.openErrors.length) { - t.sendEvent('asc_onError', c_oAscError.ID.OpenWarning, c_oAscError.Level.NoCritical); - } - - //console.log("JS - applyFirstLoadChanges() after"); - - setTimeout(function() { - - t.wb.showWorksheet(undefined, true); - //console.log("JS - showWorksheet()"); - - var ws = t.wb.getWorksheet(); - //console.log("JS - getWorksheet()"); - - window["native"]["onTokenJWT"](_api.CoAuthoringApi.get_jwt()); - window["native"]["onEndLoadingFile"](ws.headersWidth, ws.headersHeight); - //console.log("JS - onEndLoadingFile()"); - - _s.asc_WriteAllWorksheets(true); - _s.asc_WriteCurrentCell(); - - // до этого зум если вызывался - то не применился (см. реализацию asc_setZoom) - // но нужно ПОСЛЕ onEndLoadingFile (headersWidth & headersHeight должны прийти без зума) - t.asc_setZoom(_s.zoom); - - setInterval(function() { - - _api._autoSave(); - - testLockedObjects(); - - }, 100); - - //console.log("JS - openDocument()"); - - }, 5); - }; - - t.openDocumentFromZip(t.wbModel, window["native"]["GetXlsxPath"]()); - thenCallback(); - - }, 5); -}; - -// The helper function, called from the native application, -// returns information about the document as a JSON string. -window["Asc"]["spreadsheet_api"].prototype["asc_nativeGetCoreProps"] = function() { - var props = (_api) ? _api.asc_getCoreProps() : null, - value; - - if (props) { - var coreProps = {}; - coreProps["asc_getModified"] = props.asc_getModified(); - - value = props.asc_getLastModifiedBy(); - if (value) - coreProps["asc_getLastModifiedBy"] = AscCommon.UserInfoParser.getParsedName(value); - - coreProps["asc_getTitle"] = props.asc_getTitle(); - coreProps["asc_getSubject"] = props.asc_getSubject(); - coreProps["asc_getDescription"] = props.asc_getDescription(); - coreProps["asc_getCreated"] = props.asc_getCreated(); - - var authors = []; - value = props.asc_getCreator();//"123\"\"\"\<\>,456"; - value && value.split(/\s*[,;]\s*/).forEach(function (item) { - authors.push(item); - }); - - coreProps["asc_getCreator"] = authors; - - return coreProps; - } - - return {}; -} - -window["AscCommon"].getFullImageSrc2 = function (src) { - - var start = src.slice(0, 6); - if (0 === start.indexOf('theme') && editor.ThemeLoader){ - return editor.ThemeLoader.ThemesUrlAbs + src; - } - - if (0 !== start.indexOf('http:') && 0 !== start.indexOf('data:') && 0 !== start.indexOf('https:') && - 0 !== start.indexOf('file:') && 0 !== start.indexOf('ftp:')){ - var srcFull = AscCommon.g_oDocumentUrls.getImageUrl(src); - if(srcFull){ - window["native"]["loadUrlImage"](srcFull, src); - return srcFull; - } - } - - return src; -} diff --git a/common/Native/Wrappers/DrawingStream.js b/common/Native/Wrappers/DrawingStream.js deleted file mode 100755 index 6df2baaff9..0000000000 --- a/common/Native/Wrappers/DrawingStream.js +++ /dev/null @@ -1,1340 +0,0 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2023 - * - * This program is a free software product. You can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License (AGPL) - * version 3 as published by the Free Software Foundation. In accordance with - * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement - * of any third-party rights. - * - * This program is distributed WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ - -function CDrawingStreamSerializer() -{ - this.Memory = []; -} - -CDrawingStreamSerializer.prototype["PD_put_GlobalAlpha"] = function(enable, alpha) -{ - this.Memory.push(0); - this.Memory.push(enable); - this.Memory.push(alpha); -}; -CDrawingStreamSerializer.prototype["PD_End_GlobalAlpha"] = function() -{ - this.Memory.push(1); -}; -CDrawingStreamSerializer.prototype["PD_p_color"] = function(r,g,b,a) -{ - this.Memory.push(2); - this.Memory.push(r); - this.Memory.push(g); - this.Memory.push(b); - this.Memory.push(a); -}; -CDrawingStreamSerializer.prototype["PD_p_width"] = function(w) -{ - this.Memory.push(3); - this.Memory.push(w); -}; -CDrawingStreamSerializer.prototype["PD_b_color1"] = function(r,g,b,a) -{ - this.Memory.push(4); - this.Memory.push(r); - this.Memory.push(g); - this.Memory.push(b); - this.Memory.push(a); -}; -CDrawingStreamSerializer.prototype["PD_b_color2"] = function(r,g,b,a) -{ - this.Memory.push(5); - this.Memory.push(r); - this.Memory.push(g); - this.Memory.push(b); - this.Memory.push(a); -}; -CDrawingStreamSerializer.prototype["PD_transform"] = function(sx,shy,shx,sy,tx,ty) -{ - this.Memory.push(6); - this.Memory.push(sx); - this.Memory.push(shy); - this.Memory.push(shx); - this.Memory.push(sy); - this.Memory.push(tx); - this.Memory.push(ty); -}; -CDrawingStreamSerializer.prototype["PD_PathStart"] = function() -{ - this.Memory.push(11); -}; -CDrawingStreamSerializer.prototype["PD_PathEnd"] = function() -{ - this.Memory.push(12); -}; -CDrawingStreamSerializer.prototype["PD_PathClose"] = function() -{ - this.Memory.push(13); -}; -CDrawingStreamSerializer.prototype["PD_PathMoveTo"] = function(x,y) -{ - this.Memory.push(7); - this.Memory.push(x); - this.Memory.push(y); -}; -CDrawingStreamSerializer.prototype["PD_PathLineTo"] = function(x,y) -{ - this.Memory.push(8); - this.Memory.push(x); - this.Memory.push(y); -}; -CDrawingStreamSerializer.prototype["PD_PathCurveTo"] = function(x1,y1,x2,y2,x3,y3) -{ - this.Memory.push(9); - this.Memory.push(x1); - this.Memory.push(y1); - this.Memory.push(x2); - this.Memory.push(y2); - this.Memory.push(x3); - this.Memory.push(y3); -}; -CDrawingStreamSerializer.prototype["PD_PathCurveTo2"] = function(x1,y1,x2,y2) -{ - this.Memory.push(10); - this.Memory.push(x1); - this.Memory.push(y1); - this.Memory.push(x2); - this.Memory.push(y2); -}; -CDrawingStreamSerializer.prototype["PD_Stroke"] = function() -{ - this.Memory.push(14); -}; -CDrawingStreamSerializer.prototype["PD_Fill"] = function() -{ - this.Memory.push(15); -}; -CDrawingStreamSerializer.prototype["PD_Save"] = function() -{ - this.Memory.push(16); -}; -CDrawingStreamSerializer.prototype["PD_Restore"] = function() -{ - this.Memory.push(17); -}; -CDrawingStreamSerializer.prototype["PD_clip"] = function() -{ - this.Memory.push(18); -}; -CDrawingStreamSerializer.prototype["PD_reset"] = function() -{ - this.Memory.push(19); -}; -CDrawingStreamSerializer.prototype["PD_transform3"] = function(sx,shy,shx,sy,tx,ty,isNeedInvert) -{ - this.Memory.push(20); - this.Memory.push(sx); - this.Memory.push(shy); - this.Memory.push(shx); - this.Memory.push(sy); - this.Memory.push(tx); - this.Memory.push(ty); - this.Memory.push(isNeedInvert); -}; -CDrawingStreamSerializer.prototype["PD_FreeFont"] = function() -{ - // none -}; -CDrawingStreamSerializer.prototype["PD_drawImage"] = function(img,x,y,w,h,alpha,srcRect_l,srcRect_t,srcRect_r,srcRect_b) -{ - if (srcRect_l === undefined) - { - this.Memory.push(22); - this.Memory.push(img); - this.Memory.push(x); - this.Memory.push(y); - this.Memory.push(w); - this.Memory.push(h); - this.Memory.push(alpha); - return; - } - this.Memory.push(23); - this.Memory.push(img); - this.Memory.push(x); - this.Memory.push(y); - this.Memory.push(w); - this.Memory.push(h); - this.Memory.push(alpha); - this.Memory.push(srcRect_l); - this.Memory.push(srcRect_t); - this.Memory.push(srcRect_r); - this.Memory.push(srcRect_b); -}; -CDrawingStreamSerializer.prototype["PD_font"] = function(font_id, font_size) -{ - // nothing -}; -CDrawingStreamSerializer.prototype["PD_LoadFont"] = function(Path, FaceIndex, FontSize, flag) -{ - this.Memory.push(25); - this.Memory.push(Path); - this.Memory.push(FaceIndex); - this.Memory.push(FontSize); - this.Memory.push(flag); -}; -CDrawingStreamSerializer.prototype["PD_FillText"] = function(x,y,text_code) -{ - this.Memory.push(26); - this.Memory.push(x); - this.Memory.push(y); - this.Memory.push(text_code); -}; -CDrawingStreamSerializer.prototype["PD_Text"] = function(x,y,_arr) -{ - // not used. -}; -CDrawingStreamSerializer.prototype["PD_FillText2"] = function(x,y,text_code,cropX,cropW) -{ - this.Memory.push(28); - this.Memory.push(x); - this.Memory.push(y); - this.Memory.push(text_code); - this.Memory.push(cropX); - this.Memory.push(cropW); -}; -CDrawingStreamSerializer.prototype["PD_Text2"] = function(x,y,_arr,cropX,cropW) -{ - // not used. -}; -CDrawingStreamSerializer.prototype["PD_FillTextG"] = function(x,y,text_code) -{ - this.Memory.push(31); - this.Memory.push(x); - this.Memory.push(y); - this.Memory.push(text_code); -}; -CDrawingStreamSerializer.prototype["PD_SetIntegerGrid"] = function(param) -{ - this.Memory.push(32); - this.Memory.push(param); -}; -CDrawingStreamSerializer.prototype["PD_DrawHeaderEdit"] = function(yPos, lock_type) -{ - this.Memory.push(33); - this.Memory.push(yPos); - this.Memory.push(lock_type); -}; -CDrawingStreamSerializer.prototype["PD_DrawFooterEdit"] = function(yPos, lock_type) -{ - this.Memory.push(34); - this.Memory.push(yPos); - this.Memory.push(lock_type); -}; -CDrawingStreamSerializer.prototype["PD_DrawLockParagraph"] = function(lock_type, x, y1, y2) -{ - this.Memory.push(35); - this.Memory.push(lock_type); - this.Memory.push(x); - this.Memory.push(y1); - this.Memory.push(y2); -}; -CDrawingStreamSerializer.prototype["PD_DrawLockObjectRect"] = function(lock_type, x, y, w, h) -{ - this.Memory.push(36); - this.Memory.push(lock_type); - this.Memory.push(x); - this.Memory.push(y); - this.Memory.push(w); - this.Memory.push(h); -}; -CDrawingStreamSerializer.prototype["PD_DrawEmptyTableLine"] = function(x1,y1,x2,y2) -{ - this.Memory.push(37); - this.Memory.push(x1); - this.Memory.push(y1); - this.Memory.push(x2); - this.Memory.push(y2); -}; -CDrawingStreamSerializer.prototype["PD_DrawSpellingLine"] = function(y0, x0, x1, w) -{ - this.Memory.push(38); - this.Memory.push(y0); - this.Memory.push(x0); - this.Memory.push(x1); - this.Memory.push(w); -}; -CDrawingStreamSerializer.prototype["PD_drawHorLine"] = function(align, y, x, r, penW) -{ - this.Memory.push(39); - this.Memory.push(align); - this.Memory.push(y); - this.Memory.push(x); - this.Memory.push(r); - this.Memory.push(penW); -}; -CDrawingStreamSerializer.prototype["PD_drawHorLine2"] = function(align, y, x, r, penW) -{ - this.Memory.push(40); - this.Memory.push(align); - this.Memory.push(y); - this.Memory.push(x); - this.Memory.push(r); - this.Memory.push(penW); -}; -CDrawingStreamSerializer.prototype["PD_drawVerLine"] = function(align, x, y, b, penW) -{ - this.Memory.push(41); - this.Memory.push(align); - this.Memory.push(x); - this.Memory.push(y); - this.Memory.push(b); - this.Memory.push(penW); -}; -CDrawingStreamSerializer.prototype["PD_drawHorLineExt"] = function(align, y, x, r, penW, leftMW, rightMW) -{ - this.Memory.push(42); - this.Memory.push(align); - this.Memory.push(y); - this.Memory.push(x); - this.Memory.push(r); - this.Memory.push(penW); - this.Memory.push(leftMW); - this.Memory.push(rightMW); -}; -CDrawingStreamSerializer.prototype["PD_rect"] = function(x,y,w,h) -{ - this.Memory.push(43); - this.Memory.push(x); - this.Memory.push(y); - this.Memory.push(w); - this.Memory.push(h); -}; -CDrawingStreamSerializer.prototype["PD_TableRect"] = function(x,y,w,h) -{ - this.Memory.push(44); - this.Memory.push(x); - this.Memory.push(y); - this.Memory.push(w); - this.Memory.push(h); -}; -CDrawingStreamSerializer.prototype["PD_AddClipRect"] = function(x,y,w,h) -{ - this.Memory.push(45); - this.Memory.push(x); - this.Memory.push(y); - this.Memory.push(w); - this.Memory.push(h); -}; -CDrawingStreamSerializer.prototype["PD_SetClip"] = function(x,y,w,h) -{ - this.Memory.push(46); - this.Memory.push(x); - this.Memory.push(y); - this.Memory.push(w); - this.Memory.push(h); -}; -CDrawingStreamSerializer.prototype["PD_RemoveClip"] = function() -{ - this.Memory.push(47); -}; -CDrawingStreamSerializer.prototype["PD_drawCollaborativeChanges"] = function(x, y, w, h) -{ - this.Memory.push(48); - this.Memory.push(x); - this.Memory.push(y); - this.Memory.push(w); - this.Memory.push(h); -}; -CDrawingStreamSerializer.prototype["PD_drawSearchResult"] = function(x, y, w, h) -{ - this.Memory.push(49); - this.Memory.push(x); - this.Memory.push(y); - this.Memory.push(w); - this.Memory.push(h); -}; -CDrawingStreamSerializer.prototype["PD_drawFlowAnchor"] = function(x, y) -{ - this.Memory.push(50); - this.Memory.push(x); - this.Memory.push(y); -}; -CDrawingStreamSerializer.prototype["PD_SavePen"] = function() -{ - this.Memory.push(51); -}; -CDrawingStreamSerializer.prototype["PD_RestorePen"] = function() -{ - this.Memory.push(52); -}; -CDrawingStreamSerializer.prototype["PD_SaveBrush"] = function() -{ - this.Memory.push(53); -}; -CDrawingStreamSerializer.prototype["PD_RestoreBrush"] = function() -{ - this.Memory.push(54); -}; -CDrawingStreamSerializer.prototype["PD_SavePenBrush"] = function() -{ - this.Memory.push(55); -}; -CDrawingStreamSerializer.prototype["PD_RestorePenBrush"] = function() -{ - this.Memory.push(56); -}; -CDrawingStreamSerializer.prototype["PD_SaveGrState"] = function() -{ - this.Memory.push(57); -}; -CDrawingStreamSerializer.prototype["PD_RestoreGrState"] = function() -{ - this.Memory.push(58); -}; -CDrawingStreamSerializer.prototype["PD_StartClipPath"] = function() -{ - this.Memory.push(59); -}; -CDrawingStreamSerializer.prototype["PD_EndClipPath"] = function() -{ - this.Memory.push(65); -}; -CDrawingStreamSerializer.prototype["PD_StartCheckTableDraw"] = function() -{ - this.Memory.push(60); -}; -CDrawingStreamSerializer.prototype["PD_EndCheckTableDraw"] = function(bIsRestore) -{ - this.Memory.push(61); -}; -CDrawingStreamSerializer.prototype["PD_SetTextClipRect"] = function(_l, _t, _r, _b) -{ - this.Memory.push(62); - this.Memory.push(_l); - this.Memory.push(_t); - this.Memory.push(_r); - this.Memory.push(_b); -}; -CDrawingStreamSerializer.prototype["PD_AddSmartRect"] = function(x, y, w, h, pen_w) -{ - this.Memory.push(63); - this.Memory.push(x); - this.Memory.push(y); - this.Memory.push(w); - this.Memory.push(h); - this.Memory.push(pen_w); -}; -CDrawingStreamSerializer.prototype["PD_DrawPresentationComment"] = function(type, x, y, w, h) -{ - this.Memory.push(64); - this.Memory.push(type); - this.Memory.push(x); - this.Memory.push(y); - this.Memory.push(w); - this.Memory.push(h); -}; -CDrawingStreamSerializer.prototype["PD_StartShapeDraw"] = function(IsRectShape) -{ - this.Memory.push(70); - this.Memory.push(IsRectShape); -}; -CDrawingStreamSerializer.prototype["PD_EndShapeDraw"] = function() -{ - this.Memory.push(71); -}; -CDrawingStreamSerializer.prototype["PD_put_BrushTexture"] = function(id, l, t, r, b) -{ - if (l === undefined) - { - this.Memory.push(72); - this.Memory.push(id); - return; - } - this.Memory.push(73); - this.Memory.push(id); - this.Memory.push(l); - this.Memory.push(t); - this.Memory.push(r); - this.Memory.push(b); -}; -CDrawingStreamSerializer.prototype["PD_put_BrushTextureMode"] = function(mode) -{ - this.Memory.push(74); - this.Memory.push(mode); -}; -CDrawingStreamSerializer.prototype["PD_put_BrushBounds"] = function(x, y, w, h) -{ - this.Memory.push(75); - this.Memory.push(x); - this.Memory.push(y); - this.Memory.push(w); - this.Memory.push(h); -}; -CDrawingStreamSerializer.prototype["PD_put_BrushGradientLinear"] = function(x0, y0, x1, y1) -{ - this.Memory.push(76); - this.Memory.push(x0); - this.Memory.push(y0); - this.Memory.push(x1); - this.Memory.push(y1); -}; -CDrawingStreamSerializer.prototype["PD_put_BrushGragientColors"] = function(arr_pos, arr_colors) -{ - this.Memory.push(77); - this.Memory.push(arr_colors.length); - - for (var i = 0; i < arr_colors.length; i++) - { - this.Memory.push(arr_pos[i].pos / 100000); - - var _rgba = arr_colors[i].color.RGBA; - this.Memory.push(_rgba.R * 256*256*256 + _rgba.G * 256*256 + _rgba.B * 256 + _rgba.A); - } -}; -CDrawingStreamSerializer.prototype["PD_put_BrushPattern"] = function(_patt_name) -{ - this.Memory.push(78); - this.Memory.push(_patt_name); -}; -CDrawingStreamSerializer.prototype["PD_lineJoin"] = function(_join) -{ - this.Memory.push(79); - this.Memory.push(_join); -}; -CDrawingStreamSerializer.prototype["PD_put_BrushGradientRadial"] = function(x1, y1, r1, x2, y2, r2) -{ - this.Memory.push(80); - this.Memory.push(x1); - this.Memory.push(y1); - this.Memory.push(r1); - this.Memory.push(x2); - this.Memory.push(y2); - this.Memory.push(r2); -}; - -function CDrawingStream(_writer) -{ - this.Native = (undefined === _writer) ? window["native"] : _writer; - - this.m_oContext = null; - this.m_dWidthMM = 0; - this.m_dHeightMM = 0; - this.m_lWidthPix = 0; - this.m_lHeightPix = 0; - this.m_dDpiX = 96.0; - this.m_dDpiY = 96.0; - this.m_bIsBreak = false; - - this.textBB_l = 10000; - this.textBB_t = 10000; - this.textBB_r = -10000; - this.textBB_b = -10000; - - this.m_oPen = new AscCommon.CPen(); - this.m_oBrush = new AscCommon.CBrush(); - this.m_oAutoShapesTrack = null; - - this.m_oFontManager = null; - - this.m_oCoordTransform = new AscCommon.CMatrixL(); - this.m_oBaseTransform = new AscCommon.CMatrixL(); - this.m_oTransform = new AscCommon.CMatrixL(); - this.m_oFullTransform = new AscCommon.CMatrixL(); - this.m_oInvertFullTransform = new AscCommon.CMatrixL(); - - this.ArrayPoints = null; - - this.m_oCurFont = - { - Name : "", - FontSize : 10, - Bold : false, - Italic : false - }; - - // RFonts - this.m_oTextPr = null; - this.m_oGrFonts = new AscCommon.CGrRFonts(); - this.m_oLastFont = new AscCommon.CFontSetup(); - - this.LastFontOriginInfo = { Name : "", Replace : null }; - - this.m_bIntegerGrid = true; - - this.ClipManager = new AscCommon.CClipManager(); - this.ClipManager.BaseObject = this; - - this.TextureFillTransformScaleX = 1; - this.TextureFillTransformScaleY = 1; - this.IsThumbnail = false; - - this.GrState = new AscCommon.CGrState(); - this.GrState.Parent = this; - - this.globalAlpha = 1; - - this.TextClipRect = null; - this.IsClipContext = false; - - this.IsUseFonts2 = false; - this.m_oFontManager2 = null; - this.m_oLastFont2 = null; - - this.ClearMode = false; - this.IsRetina = false; - - this.ForceChangeFont = false; -} - -CDrawingStream.prototype = -{ - - init : function(context,width_px,height_px,width_mm,height_mm) - { - this.m_oContext = context; - this.m_lHeightPix = height_px >> 0; - this.m_lWidthPix = width_px >> 0; - this.m_dWidthMM = width_mm; - this.m_dHeightMM = height_mm; - this.m_dDpiX = 25.4 * this.m_lWidthPix / this.m_dWidthMM; - this.m_dDpiY = 25.4 * this.m_lHeightPix / this.m_dHeightMM; - - this.m_oCoordTransform.sx = this.m_dDpiX / 25.4; - this.m_oCoordTransform.sy = this.m_dDpiY / 25.4; - - - /* - if (this.IsThumbnail) - { - this.TextureFillTransformScaleX *= (width_px / (width_mm * g_dKoef_mm_to_pix)); - this.TextureFillTransformScaleY *= (height_px / (height_mm * g_dKoef_mm_to_pix)) - } - */ - - /* - if (true == this.m_oContext.mozImageSmoothingEnabled) - this.m_oContext.mozImageSmoothingEnabled = false; - */ - - this.m_oLastFont.Clear(); - //this.m_oContext.save(); - }, - ClearParams : function() - { - this.m_oTextPr = null; - this.m_oGrFonts = new AscCommon.CGrRFonts(); - this.m_oLastFont = new AscCommon.CFontSetup(); - - this.IsUseFonts2 = false; - this.m_oLastFont2 = null; - - this.m_bIntegerGrid = true; - }, - - EndDraw : function() - { - // not used - }, - - put_GlobalAlpha : function(enable, alpha) - { - if (false === enable) - { - this.globalAlpha = 1; - } - else - { - this.globalAlpha = alpha; - } - - this.Native["PD_put_GlobalAlpha"](enable, alpha); - }, - Start_GlobalAlpha : function() - { - // nothing - }, - End_GlobalAlpha : function() - { - this.Native["PD_End_GlobalAlpha"](); - }, - // pen methods - p_color : function(r,g,b,a) - { - var _c = this.m_oPen.Color; - _c.R = r; - _c.G = g; - _c.B = b; - _c.A = a; - this.Native["PD_p_color"](r,g,b,a); - }, - p_width : function(w) - { - this.Native["PD_p_width"](w / 1000); - }, - - p_dash : function(params) - { - this.Native["PD_p_dash"](params ? params : []); - }, - - // brush methods - b_color1 : function(r,g,b,a) - { - var _c = this.m_oBrush.Color1; - _c.R = r; - _c.G = g; - _c.B = b; - _c.A = a; - this.Native["PD_b_color1"](r,g,b,a); - }, - b_color2 : function(r,g,b,a) - { - this.Native["PD_b_color2"](r,g,b,a); - }, - - transform : function(sx,shy,shx,sy,tx,ty) - { - var _t = this.m_oTransform; - _t.sx = sx; - _t.shx = shx; - _t.shy = shy; - _t.sy = sy; - _t.tx = tx; - _t.ty = ty; - - this.CalculateFullTransform(); - if (false === this.m_bIntegerGrid) - { - var _ft = this.m_oFullTransform; - this.Native["PD_transform"](_ft.sx,_ft.shy,_ft.shx,_ft.sy,_ft.tx,_ft.ty); - } - - //if (null != this.m_oFontManager) - //{ - // this.m_oFontManager.SetTextMatrix(_t.sx,_t.shy,_t.shx,_t.sy,_t.tx,_t.ty); - //} - }, - CalculateFullTransform : function(isInvertNeed) - { - var _ft = this.m_oFullTransform; - var _t = this.m_oTransform; - _ft.sx = _t.sx; - _ft.shx = _t.shx; - _ft.shy = _t.shy; - _ft.sy = _t.sy; - _ft.tx = _t.tx; - _ft.ty = _t.ty; - AscCommon.global_MatrixTransformer.MultiplyAppend(_ft, this.m_oCoordTransform); - - var _it = this.m_oInvertFullTransform; - _it.sx = _ft.sx; - _it.shx = _ft.shx; - _it.shy = _ft.shy; - _it.sy = _ft.sy; - _it.tx = _ft.tx; - _it.ty = _ft.ty; - - if (false !== isInvertNeed) - { - AscCommon.global_MatrixTransformer.MultiplyAppendInvert(_it, _t); - } - }, - // path commands - _s : function() - { - this.Native["PD_PathStart"](); - }, - _e : function() - { - this.Native["PD_PathEnd"](); - }, - _z : function() - { - this.Native["PD_PathClose"](); - }, - _m : function(x,y) - { - if (false === this.m_bIntegerGrid) - { - this.Native["PD_PathMoveTo"](x,y); - - if (this.ArrayPoints != null) - this.ArrayPoints[this.ArrayPoints.length] = {x: x, y: y}; - } - else - { - var _x = (this.m_oFullTransform.TransformPointX(x,y)) >> 0; - var _y = (this.m_oFullTransform.TransformPointY(x,y)) >> 0; - this.Native["PD_PathMoveTo"](_x + 0.5,_y + 0.5); - } - }, - _l : function(x,y) - { - if (false === this.m_bIntegerGrid) - { - this.Native["PD_PathLineTo"](x,y); - - if (this.ArrayPoints != null) - this.ArrayPoints[this.ArrayPoints.length] = {x: x, y: y}; - } - else - { - var _x = (this.m_oFullTransform.TransformPointX(x,y)) >> 0; - var _y = (this.m_oFullTransform.TransformPointY(x,y)) >> 0; - this.Native["PD_PathLineTo"](_x + 0.5,_y + 0.5); - } - - }, - _c : function(x1,y1,x2,y2,x3,y3) - { - if (false === this.m_bIntegerGrid) - { - this.Native["PD_PathCurveTo"](x1,y1,x2,y2,x3,y3); - - if (this.ArrayPoints != null) - { - this.ArrayPoints[this.ArrayPoints.length] = {x: x1, y: y1}; - this.ArrayPoints[this.ArrayPoints.length] = {x: x2, y: y2}; - this.ArrayPoints[this.ArrayPoints.length] = {x: x3, y: y3}; - } - } - else - { - var _x1 = (this.m_oFullTransform.TransformPointX(x1,y1)) >> 0; - var _y1 = (this.m_oFullTransform.TransformPointY(x1,y1)) >> 0; - - var _x2 = (this.m_oFullTransform.TransformPointX(x2,y2)) >> 0; - var _y2 = (this.m_oFullTransform.TransformPointY(x2,y2)) >> 0; - - var _x3 = (this.m_oFullTransform.TransformPointX(x3,y3)) >> 0; - var _y3 = (this.m_oFullTransform.TransformPointY(x3,y3)) >> 0; - - this.Native["PD_PathCurveTo"](_x1 + 0.5,_y1 + 0.5,_x2 + 0.5,_y2 + 0.5,_x3 + 0.5,_y3 + 0.5); - } - }, - _c2 : function(x1,y1,x2,y2) - { - if (false === this.m_bIntegerGrid) - { - this.Native["PD_PathCurveTo2"](x1,y1,x2,y2); - - if (this.ArrayPoints != null) - { - this.ArrayPoints[this.ArrayPoints.length] = {x: x1, y: y1}; - this.ArrayPoints[this.ArrayPoints.length] = {x: x2, y: y2}; - } - } - else - { - var _x1 = (this.m_oFullTransform.TransformPointX(x1,y1)) >> 0; - var _y1 = (this.m_oFullTransform.TransformPointY(x1,y1)) >> 0; - - var _x2 = (this.m_oFullTransform.TransformPointX(x2,y2)) >> 0; - var _y2 = (this.m_oFullTransform.TransformPointY(x2,y2)) >> 0; - - this.Native["PD_PathCurveTo2"](_x1 + 0.5,_y1 + 0.5,_x2 + 0.5,_y2 + 0.5); - } - }, - ds : function() - { - this.Native["PD_Stroke"](); - }, - df : function() - { - this.Native["PD_Fill"](); - }, - - // canvas state - save : function() - { - this.Native["PD_Save"](); - }, - restore : function() - { - this.Native["PD_Restore"](); - }, - clip : function() - { - this.Native["PD_clip"](); - }, - - reset : function() - { - this.m_oTransform.Reset(); - this.CalculateFullTransform(false); - - if (!this.m_bIntegerGrid) - this.Native["PD_transform"](this.m_oCoordTransform.sx,0,0,this.m_oCoordTransform.sy,0, 0); - - //this.ClearParams(); - - this.Native["PD_reset"](); - }, - - transform3 : function(m, isNeedInvert) - { - - this.Native["PD_transform3"](m.sx,m.shy,m.shx,m.sy,m.tx,m.ty, isNeedInvert); - // теперь трансформ выставляется ТОЛЬКО при загрузке шрифта. Здесь другого быть и не может - /* - if (null != this.m_oFontManager && false !== isNeedInvert) - { - this.m_oFontManager.SetTextMatrix(this.m_oTransform.sx,this.m_oTransform.shy,this.m_oTransform.shx, - this.m_oTransform.sy,this.m_oTransform.tx,this.m_oTransform.ty); - } - */ - }, - - FreeFont : function() - { - this.Native["PD_FreeFont"](); - }, - - // images - drawImage : function(img,x,y,w,h,alpha,srcRect) - { - if (!srcRect) - return this.Native["PD_drawImage"](img,x,y,w,h,alpha); - - return this.Native["PD_drawImage"](img,x,y,w,h,alpha,srcRect.l,srcRect.t,srcRect.r,srcRect.b); - }, - - // text - GetFont : function() - { - return this.m_oCurFont; - }, - font : function(font_id,font_size) - { - this.Native["PD_font"](font_id, font_size); - }, - SetFont : function(font) - { - if (null == font) - return; - - this.m_oCurFont = - { - FontFamily : - { - Index : font.FontFamily.Index, - Name : font.FontFamily.Name - }, - - FontSize : font.FontSize, - Bold : font.Bold, - Italic : font.Italic - }; - - var bItalic = true === font.Italic; - var bBold = true === font.Bold; - - var oFontStyle = AscFonts.FontStyle.FontStyleRegular; - if ( !bItalic && bBold ) - oFontStyle = AscFonts.FontStyle.FontStyleBold; - else if ( bItalic && !bBold ) - oFontStyle = AscFonts.FontStyle.FontStyleItalic; - else if ( bItalic && bBold ) - oFontStyle = AscFonts.FontStyle.FontStyleBoldItalic; - - var _fontinfo = AscFonts.g_fontApplication.GetFontInfo(font.FontFamily.Name, oFontStyle, this.LastFontOriginInfo); - var _info = AscCommon.GetLoadInfoForMeasurer(_fontinfo, oFontStyle); - - var flag = 0; - if (_info.NeedBold) flag |= 0x01; - if (_info.NeedItalic) flag |= 0x02; - if (_info.SrcBold) flag |= 0x04; - if (_info.SrcItalic) flag |= 0x08; - - this.ForceChangeFont = true; - this.Native["PD_LoadFont"](_info.Path, _info.FaceIndex, font.FontSize, flag); - }, - - SetTextPr : function(textPr, theme) - { - if (theme && textPr && textPr.ReplaceThemeFonts) - textPr.ReplaceThemeFonts(theme.themeElements.fontScheme); - - this.m_oTextPr = textPr; - if (theme) - this.m_oGrFonts.checkFromTheme(theme.themeElements.fontScheme, this.m_oTextPr.RFonts); - else - this.m_oGrFonts = this.m_oTextPr.RFonts; - }, - GetTextPr : function() - { - return this.m_oTextPr; - }, - - SetFontInternal : function(name, size, style) - { - var _lastFont = this.IsUseFonts2 ? this.m_oLastFont2 : this.m_oLastFont; - _lastFont.Name = name; - _lastFont.Size = size; - - if (_lastFont.Name != _lastFont.SetUpName || - _lastFont.Size != _lastFont.SetUpSize || - style != _lastFont.SetUpStyle || - this.ForceChangeFont) - { - this.ForceChangeFont = false; - _lastFont.SetUpName = _lastFont.Name; - _lastFont.SetUpSize = _lastFont.Size; - _lastFont.SetUpStyle = style; - - var _fontinfo = AscFonts.g_fontApplication.GetFontInfo(_lastFont.SetUpName, _lastFont.SetUpStyle, this.LastFontOriginInfo); - var _info = AscCommon.GetLoadInfoForMeasurer(_fontinfo, _lastFont.SetUpStyle); - - var flag = 0; - if (_info.NeedBold) flag |= 0x01; - if (_info.NeedItalic) flag |= 0x02; - if (_info.SrcBold) flag |= 0x04; - if (_info.SrcItalic) flag |= 0x08; - - this.Native["PD_LoadFont"](_info.Path, _info.FaceIndex, _lastFont.SetUpSize, flag); - } - }, - - SetFontSlot : function(slot, fontSizeKoef) - { - var _rfonts = this.m_oGrFonts; - var _lastFont = this.IsUseFonts2 ? this.m_oLastFont2 : this.m_oLastFont; - - switch (slot) - { - case fontslot_ASCII: - { - _lastFont.Name = _rfonts.Ascii.Name; - _lastFont.Size = this.m_oTextPr.FontSize; - _lastFont.Bold = this.m_oTextPr.Bold; - _lastFont.Italic = this.m_oTextPr.Italic; - - break; - } - case fontslot_CS: - { - _lastFont.Name = _rfonts.CS.Name; - _lastFont.Size = this.m_oTextPr.FontSizeCS; - _lastFont.Bold = this.m_oTextPr.BoldCS; - _lastFont.Italic = this.m_oTextPr.ItalicCS; - - break; - } - case fontslot_EastAsia: - { - _lastFont.Name = _rfonts.EastAsia.Name; - _lastFont.Size = this.m_oTextPr.FontSize; - _lastFont.Bold = this.m_oTextPr.Bold; - _lastFont.Italic = this.m_oTextPr.Italic; - - break; - } - case fontslot_HAnsi: - default: - { - _lastFont.Name = _rfonts.HAnsi.Name; - _lastFont.Size = this.m_oTextPr.FontSize; - _lastFont.Bold = this.m_oTextPr.Bold; - _lastFont.Italic = this.m_oTextPr.Italic; - - break; - } - } - - if (undefined !== fontSizeKoef) - _lastFont.Size *= fontSizeKoef; - - var _style = 0; - if (_lastFont.Italic) - _style += 2; - if (_lastFont.Bold) - _style += 1; - - if (_lastFont.Name != _lastFont.SetUpName || - _lastFont.Size != _lastFont.SetUpSize || - _style != _lastFont.SetUpStyle || - this.ForceChangeFont) - { - this.ForceChangeFont = false; - _lastFont.SetUpName = _lastFont.Name; - _lastFont.SetUpSize = _lastFont.Size; - _lastFont.SetUpStyle = _style; - - var _fontinfo = AscFonts.g_fontApplication.GetFontInfo(_lastFont.SetUpName, _lastFont.SetUpStyle, this.LastFontOriginInfo); - var _info = AscCommon.GetLoadInfoForMeasurer(_fontinfo, _lastFont.SetUpStyle); - - var flag = 0; - if (_info.NeedBold) flag |= 0x01; - if (_info.NeedItalic) flag |= 0x02; - if (_info.SrcBold) flag |= 0x04; - if (_info.SrcItalic) flag |= 0x08; - - this.Native["PD_LoadFont"](_info.Path, _info.FaceIndex, _lastFont.SetUpSize, flag); - } - }, - - FillText : function(x,y,text) - { - var _code = text.charCodeAt(0); - if (null != this.LastFontOriginInfo.Replace) - _code = AscFonts.g_fontApplication.GetReplaceGlyph(_code, this.LastFontOriginInfo.Replace); - - this.Native["PD_FillText"](x,y,_code); - }, - t : function(text,x,y) - { - var _arr = []; - var _len = text.length; - for (var i = 0; i < _len; i++) - _arr.push(text.charCodeAt(i)); - this.Native["PD_Text"](x,y,_arr); - }, - FillText2 : function(x,y,text,cropX,cropW) - { - var _code = text.charCodeAt(0); - if (null != this.LastFontOriginInfo.Replace) - _code = AscFonts.g_fontApplication.GetReplaceGlyph(_code, this.LastFontOriginInfo.Replace); - - this.Native["PD_FillText2"](x,y,_code,cropX,cropW); - }, - t2 : function(text,x,y,cropX,cropW) - { - var _arr = []; - var _len = text.length; - for (var i = 0; i < _len; i++) - _arr.push(text.charCodeAt(i)); - this.Native["PD_Text2"](x,y,_arr,cropX,cropW); - }, - FillTextCode : function(x,y,lUnicode) - { - if (null != this.LastFontOriginInfo.Replace) - lUnicode = AscFonts.g_fontApplication.GetReplaceGlyph(lUnicode, this.LastFontOriginInfo.Replace); - - this.Native["PD_FillText"](x,y,lUnicode); - }, - - tg : function(text,x,y) - { - this.Native["PD_FillTextG"](x,y,text); - }, - charspace : function(space) - { - // nothing - }, - - SetIntegerGrid : function(param) - { - this.m_bIntegerGrid = param; - this.Native["PD_SetIntegerGrid"](param); - }, - GetIntegerGrid : function() - { - return this.m_bIntegerGrid; - }, - - DrawHeaderEdit : function(yPos, lock_type) - { - this.Native["PD_DrawHeaderEdit"](yPos, lock_type); - }, - - DrawFooterEdit : function(yPos, lock_type) - { - this.Native["PD_DrawFooterEdit"](yPos, lock_type); - }, - - DrawLockParagraph : function(lock_type, x, y1, y2) - { - this.Native["PD_DrawLockParagraph"](lock_type, x, y1, y2); - }, - - DrawLockObjectRect : function(lock_type, x, y, w, h) - { - if (this.IsThumbnail || lock_type == AscCommon.locktype_None || this.IsDemonstrationMode) - return; - - this.Native["PD_DrawLockObjectRect"](lock_type, x, y, w, h); - }, - - DrawEmptyTableLine : function(x1,y1,x2,y2) - { - this.Native["PD_DrawEmptyTableLine"](x1,y1,x2,y2); - }, - - DrawSpellingLine : function(y0, x0, x1, w) - { - this.Native["PD_DrawSpellingLine"](y0, x0, x1, w); - }, - - // smart methods for horizontal / vertical lines - drawHorLine : function(align, y, x, r, penW) - { - this.Native["PD_drawHorLine"](align, y, x, r, penW); - }, - drawHorLine2 : function(align, y, x, r, penW) - { - this.Native["PD_drawHorLine2"](align, y, x, r, penW); - }, - drawVerLine : function(align, x, y, b, penW) - { - this.Native["PD_drawVerLine"](align, x, y, b, penW); - }, - - // мега крутые функции для таблиц - drawHorLineExt : function(align, y, x, r, penW, leftMW, rightMW) - { - this.Native["PD_drawHorLineExt"](align, y, x, r, penW, leftMW, rightMW); - }, - - rect : function(x,y,w,h) - { - this.Native["PD_rect"](x,y,w,h); - }, - - TableRect : function(x,y,w,h) - { - this.Native["PD_TableRect"](x,y,w,h); - }, - - // функции клиппирования - AddClipRect : function(x, y, w, h) - { - this.Native["PD_AddClipRect"](x,y,w,h); - }, - RemoveClipRect : function() - { - // nothing - }, - - SetClip : function(r) - { - this.Native["PD_SetClip"](r.x, r.y, r.w, r.h); - }, - - RemoveClip : function() - { - this.Native["PD_RemoveClip"](); - }, - - drawCollaborativeChanges : function(x, y, w, h) - { - this.Native["PD_drawCollaborativeChanges"](x, y, w, h); - }, - - drawSearchResult : function(x, y, w, h) - { - this.Native["PD_drawSearchResult"](x, y, w, h); - }, - - drawFlowAnchor : function(x, y) - { - this.Native["PD_drawFlowAnchor"](x, y); - }, - - drawMailMergeField : function(x, y, w, h) - { - this.b_color1(206, 212, 223, 204); - this.rect( x, y, w, h ); - this.df(); - }, - - SavePen : function() - { - this.Native["PD_SavePen"](); - }, - RestorePen : function() - { - this.Native["PD_RestorePen"](); - }, - - SaveBrush : function() - { - this.Native["PD_SaveBrush"](); - }, - RestoreBrush : function() - { - this.Native["PD_RestoreBrush"](); - }, - - SavePenBrush : function() - { - this.Native["PD_SavePenBrush"](); - }, - RestorePenBrush : function() - { - this.Native["PD_RestorePenBrush"](); - }, - - SaveGrState : function() - { - this.Native["PD_SaveGrState"](); - }, - RestoreGrState : function() - { - this.Native["PD_RestoreGrState"](); - }, - - StartClipPath : function() - { - this.Native["PD_StartClipPath"](); - }, - - EndClipPath : function() - { - this.Native["PD_EndClipPath"](); - }, - - StartCheckTableDraw : function() - { - return this.Native["PD_StartCheckTableDraw"](); - }, - - EndCheckTableDraw : function(bIsRestore) - { - return this.Native["PD_EndCheckTableDraw"](bIsRestore); - }, - - SetTextClipRect : function(_l, _t, _r, _b) - { - return this.Native["PD_SetTextClipRect"](_l, _t, _r, _b); - }, - - AddSmartRect : function(x, y, w, h, pen_w) - { - return this.Native["PD_AddSmartRect"](x, y, w, h, pen_w); - }, - - Drawing_StartCheckBounds : function(x, y, w, h) - { - - }, - - Drawing_EndCheckBounds : function() - { - - }, - - DrawPresentationComment : function(type, x, y, w, h) - { - return this.Native["PD_DrawPresentationComment"](type, x, y, w, h); - } -}; diff --git a/common/Native/Wrappers/Overlay.js b/common/Native/Wrappers/Overlay.js deleted file mode 100755 index dac3add2de..0000000000 --- a/common/Native/Wrappers/Overlay.js +++ /dev/null @@ -1,1006 +0,0 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2023 - * - * This program is a free software product. You can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License (AGPL) - * version 3 as published by the Free Software Foundation. In accordance with - * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement - * of any third-party rights. - * - * This program is distributed WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ - -var TRACK_CIRCLE_RADIUS = 5; -var TRACK_RECT_SIZE2 = 4; -var TRACK_RECT_SIZE = 8; -var TRACK_RECT_SIZE_CT = 6; -var TRACK_DISTANCE_ROTATE = 50; -var TRACK_DISTANCE_ROTATE2 = 25; -var TRACK_ADJUSTMENT_SIZE = 10; -var TRACK_WRAPPOINTS_SIZE = 6; -var IMAGE_ROTATE_TRACK_W = 21; - - -var bIsUseImageRotateTrack = true; -if (bIsUseImageRotateTrack) -{ - window.g_track_rotate_marker = new Image(); - window.g_track_rotate_marker; - window.g_track_rotate_marker.asc_complete = false; - window.g_track_rotate_marker.onload = function(){ - window.g_track_rotate_marker.asc_complete = true; - }; - window.g_track_rotate_marker.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAMAAACeyVWkAAAAVFBMVEUAAAD///////////////////////////////////////////////////////98fHy2trb09PTT09OysrKqqqqJiYng4ODr6+uamprGxsbi4uKGhoYjgM0eAAAADnRSTlMAy00k7/z0jbeuMzDljsugwZgAAACpSURBVBjTdZHbEoMgDESDAl6bgIqX9v//s67UYpm6D0xyYMImoaiuUr3pVdVRUtnwqaY8YaE5SRcfaPgqc+DSIh7WIGGaEVoUqRGN4oZlcDIiqYlaPjQz5CNu6cFJwLiuSO3nlLBDrKhn3l4rcnH4NcAdGd5EZMfCsoMFBxM6CD57G+u6vC48PMVnHtrYhP/x+7+3cw7zdJnD3cyA7QXa4nYXaW+a9Xdvb6zqE5Jb7LmzAAAAAElFTkSuQmCC"; - - window.g_track_rotate_marker2 = new Image(); - window.g_track_rotate_marker2; - window.g_track_rotate_marker2.asc_complete = false; - window.g_track_rotate_marker2.onload = function(){ - window.g_track_rotate_marker2.asc_complete = true; - }; - window.g_track_rotate_marker2.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAMAAAC7IEhfAAAAeFBMVEUAAAD///////////////////////////////////////////////////////////////////////////+Tk5Obm5v8/PzAwMD5+fmWlpbt7e3k5OSfn5/z8/PLy8vn5+fExMSsrKyqqqrf39+vr6+9vb2urq7c3NxSmuRpAAAAE3RSTlMA+u2XA+PTrId4WBwTN7EKtLY4iqQP6AAAAWhJREFUOMudVe2SgjAMLN+goN51CxTLp3r3/m943BAqIJTR/RU6O02yTRY2g5tEgW9blu0HUeKyLRxDj0/ghcdVWuxYfAHLiV95B5uvwD4saK7DN+DMSj1f+CYu58l9J27A6XnnJG9R3ZWU6l4Vk+y6D310baHRXvUxdRSP/aYZILJbmebFLRNAlo69x7PEeQdZ5Xz8qiS6fJr8aOnEquATFApdSsr/v1HINUo+Q6nwoDDspfH4JmoJ6shzWcINaNBSlLCI6uvLfyXmAlR2xIKBB/A1ZKiGIGA+8QCtphBawRt+hsBnNvE0M0OPZmwcijRnFvE0U6CuIcbrIUlJRnJL9L0YifTQCgU3p/aH4I7fnWaCIajwMMszCl5A7Aj+TWctGuMT6qG4QtbGodBj9oAyjpke3LSDYXCXq9A8V6GZrsLGcqXlcrneW9elAQgpxdwA3rcUdv4ymdQHtrdvpPvW/LHZ7/8+/gBTWGFPbAkGiAAAAABJRU5ErkJggg=="; - -} - - -function COverlay() -{ - this.m_oControl = null; - this.m_oContext = null; - - this.min_x = 0xFFFF; - this.min_y = 0xFFFF; - this.max_x = -0xFFFF; - this.max_y = -0xFFFF; - - this.m_bIsShow = false; - this.m_bIsAlwaysUpdateOverlay = false; - - this.m_oHtmlPage = null; - - this.DashLineColor = "#000000"; - this.ClearAll = false; - - this.IsRetina = false; -} - -COverlay.prototype = -{ - init : function(context, controlName, x, y, w_pix, h_pix, w_mm, h_mm) - { - this.m_oContext = context; - //this.m_oControl = AscCommon.CreateControl(controlName); - - //this.m_oHtmlPage = new AscCommon.CHtmlPage(); - //this.m_oHtmlPage.init(x, y, w_pix, h_pix, w_mm, h_mm); - }, - - Clear : function() - { -// if (null == this.m_oContext) -// { -// this.m_oContext = this.m_oControl.HtmlElement.getContext('2d'); -// -// this.m_oContext.imageSmoothingEnabled = false; -// this.m_oContext.mozImageSmoothingEnabled = false; -// this.m_oContext.oImageSmoothingEnabled = false; -// this.m_oContext.webkitImageSmoothingEnabled = false; -// } -// -// this.SetBaseTransform(); -// -// this.m_oContext.beginPath(); -// if (this.max_x != -0xFFFF && this.max_y != -0xFFFF) -// { -// if (this.ClearAll === true) -// { -// this.m_oContext.clearRect(0, 0, this.m_oControl.HtmlElement.width, this.m_oControl.HtmlElement.height); -// this.ClearAll = false; -// } -// else -// { -// var _eps = 5; -// this.m_oContext.clearRect(this.min_x - _eps, this.min_y - _eps, this.max_x - this.min_x + 2*_eps, this.max_y - this.min_y + 2*_eps); -// } -// } - this.min_x = 0xFFFF; - this.min_y = 0xFFFF; - this.max_x = -0xFFFF; - this.max_y = -0xFFFF; - }, - - GetImageTrackRotationImage : function() - { - return this.IsRetina ? window.g_track_rotate_marker2 : window.g_track_rotate_marker; - }, - - SetTransform : function(sx, shy, shx, sy, tx, ty) - { - this.SetBaseTransform(); - this.m_oContext.setTransform(sx, shy, shx, sy, tx, ty); - - }, - - SetBaseTransform : function() - { - if (this.IsRetina) - this.m_oContext.setTransform(2, 0, 0, 2, 0, 0); - else - this.m_oContext.setTransform(1, 0, 0, 1, 0, 0); - }, - - Show : function() - { - if (this.m_bIsShow) - return; - - this.m_bIsShow = true; - //this.m_oControl.HtmlElement.style.display = "block"; - }, - UnShow : function() - { - if (!this.m_bIsShow) - return; - - this.m_bIsShow = false; - //this.m_oControl.HtmlElement.style.display = "none"; - }, - - VertLine : function(position, bIsSimpleAdd) - { - if (bIsSimpleAdd !== true) - { - this.Clear(); - if (this.m_bIsAlwaysUpdateOverlay || true/*мало ли что есть на оверлее*/) - { - //if (!editor.WordControl.OnUpdateOverlay()) - { - // editor.WordControl.EndUpdateOverlay(); - } - } - } - - if (this.min_x > position) - this.min_x = position; - if (this.max_x < position) - this.max_x = position; - - //this.min_x = position; - //this.max_x = position; - this.min_y = 0; - this.max_y = this.m_oControl.HtmlElement.height; - - this.m_oContext.lineWidth = 1; - - var x = ((position + 0.5) >> 0) + 0.5; - var y = 0; - - this.m_oContext.strokeStyle = this.DashLineColor; - this.m_oContext.beginPath(); - - while (y < this.max_y) - { - this.m_oContext.moveTo(x, y); y++; - this.m_oContext.lineTo(x, y); y+=1; - this.m_oContext.moveTo(x, y); y++; - this.m_oContext.lineTo(x, y); y+=1; - this.m_oContext.moveTo(x, y); y++; - this.m_oContext.lineTo(x, y); y++; - - y += 5; - } - - this.m_oContext.stroke(); - - y = 1; - this.m_oContext.strokeStyle = "#FFFFFF"; - this.m_oContext.beginPath(); - - while (y < this.max_y) - { - this.m_oContext.moveTo(x, y); y++; - this.m_oContext.lineTo(x, y); y+=1; - this.m_oContext.moveTo(x, y); y++; - this.m_oContext.lineTo(x, y); y+=1; - this.m_oContext.moveTo(x, y); y++; - this.m_oContext.lineTo(x, y); y++; - - y += 5; - } - - this.m_oContext.stroke(); - this.Show(); - }, - - VertLine2 : function(position) - { - if (this.min_x > position) - this.min_x = position; - if (this.max_x < position) - this.max_x = position; - - var _old_global = this.m_oContext.globalAlpha; - this.m_oContext.globalAlpha = 1; - - this.min_y = 0; - this.max_y = this.m_oControl.HtmlElement.height; - - this.m_oContext.lineWidth = 1; - - var x = ((position + 0.5) >> 0) + 0.5; - var y = 0; - - /* - this.m_oContext.strokeStyle = "#FFFFFF"; - this.m_oContext.beginPath(); - this.m_oContext.moveTo(x, y); - this.m_oContext.lineTo(x, this.max_y); - this.m_oContext.stroke(); - */ - - this.m_oContext.strokeStyle = this.DashLineColor; - this.m_oContext.beginPath(); - - var dist = 1; - - while (y < this.max_y) - { - this.m_oContext.moveTo(x, y); - y += dist; - this.m_oContext.lineTo(x, y); - y += dist; - } - - this.m_oContext.stroke(); - this.m_oContext.beginPath(); - this.Show(); - - this.m_oContext.globalAlpha = _old_global; - }, - - HorLine : function(position, bIsSimpleAdd) - { - if (bIsSimpleAdd !== true) - { - this.Clear(); - if (this.m_bIsAlwaysUpdateOverlay || true/*мало ли что есть на оверлее*/) - { - // if (!editor.WordControl.OnUpdateOverlay()) - { - // editor.WordControl.EndUpdateOverlay(); - } - } - } - - this.min_x = 0; - this.max_x = this.m_oControl.HtmlElement.width; - - if (this.min_y > position) - this.min_y = position; - if (this.max_y < position) - this.max_y = position; - - this.m_oContext.lineWidth = 1; - - var y = ((position + 0.5) >> 0) + 0.5; - var x = 0; - - this.m_oContext.strokeStyle = this.DashLineColor; - this.m_oContext.beginPath(); - - while (x < this.max_x) - { - this.m_oContext.moveTo(x, y); x++; - this.m_oContext.lineTo(x, y); x+=1; - this.m_oContext.moveTo(x, y); x++; - this.m_oContext.lineTo(x, y); x+=1; - this.m_oContext.moveTo(x, y); x++; - this.m_oContext.lineTo(x, y); x++; - - x += 5; - } - - this.m_oContext.stroke(); - - x = 1; - this.m_oContext.strokeStyle = "#FFFFFF"; - this.m_oContext.beginPath(); - - while (x < this.max_x) - { - this.m_oContext.moveTo(x, y); x++; - this.m_oContext.lineTo(x, y); x+=1; - this.m_oContext.moveTo(x, y); x++; - this.m_oContext.lineTo(x, y); x+=1; - this.m_oContext.moveTo(x, y); x++; - this.m_oContext.lineTo(x, y); x++; - - x += 5; - } - - this.m_oContext.stroke(); - this.Show(); - }, - - HorLine2 : function(position) - { - if (this.min_y > position) - this.min_y = position; - if (this.max_y < position) - this.max_y = position; - - var _old_global = this.m_oContext.globalAlpha; - this.m_oContext.globalAlpha = 1; - - this.min_x = 0; - this.max_x = this.m_oControl.HtmlElement.width; - - this.m_oContext.lineWidth = 1; - - var y = ((position + 0.5) >> 0) + 0.5; - var x = 0; - - /* - this.m_oContext.strokeStyle = "#FFFFFF"; - this.m_oContext.beginPath(); - this.m_oContext.moveTo(x, y); - this.m_oContext.lineTo(this.max_x, y); - this.m_oContext.stroke(); - */ - - this.m_oContext.strokeStyle = this.DashLineColor; - this.m_oContext.beginPath(); - - var dist = 1; - - while (x < this.max_x) - { - this.m_oContext.moveTo(x, y); - x += dist; - this.m_oContext.lineTo(x, y); - x += dist; - } - - this.m_oContext.stroke(); - this.m_oContext.beginPath(); - this.Show(); - - this.m_oContext.globalAlpha = _old_global; - }, - - CheckPoint1 : function(x,y) - { - if (x < this.min_x) - this.min_x = x; - if (y < this.min_y) - this.min_y = y; - }, - CheckPoint2 : function(x,y) - { - if (x > this.max_x) - this.max_x = x; - if (y > this.max_y) - this.max_y = y; - }, - CheckPoint : function(x,y) - { - if (x < this.min_x) - this.min_x = x; - if (y < this.min_y) - this.min_y = y; - if (x > this.max_x) - this.max_x = x; - if (y > this.max_y) - this.max_y = y; - }, - - AddRect2 : function(x,y,r) - { - var _x = x - ((r / 2) >> 0); - var _y = y - ((r / 2) >> 0); - this.CheckPoint1(_x,_y); - this.CheckPoint2(_x+r,_y+r); - - this.m_oContext.moveTo(_x,_y); - this.m_oContext.rect(_x,_y,r,r); - }, - - AddRect3 : function(x,y,r, ex1, ey1, ex2, ey2) - { - var _r = r / 2; - - var x1 = x + _r * (ex2 - ex1); - var y1 = y + _r * (ey2 - ey1); - - var x2 = x + _r * (ex2 + ex1); - var y2 = y + _r * (ey2 + ey1); - - var x3 = x + _r * (-ex2 + ex1); - var y3 = y + _r * (-ey2 + ey1); - - var x4 = x + _r * (-ex2 - ex1); - var y4 = y + _r * (-ey2 - ey1); - - this.CheckPoint(x1,y1); - this.CheckPoint(x2,y2); - this.CheckPoint(x3,y3); - this.CheckPoint(x4,y4); - - var ctx = this.m_oContext; - ctx.moveTo(x1,y1); - ctx.lineTo(x2,y2); - ctx.lineTo(x3,y3); - ctx.lineTo(x4,y4); - ctx.closePath(); - }, - - AddRect : function(x,y,w,h) - { - this.CheckPoint1(x,y); - this.CheckPoint2(x + w,y + h); - - this.m_oContext.moveTo(x,y); - this.m_oContext.rect(x,y,w,h); - //this.m_oContext.closePath(); - }, - CheckRectT : function(x,y,w,h,trans,eps) - { - var x1 = trans.TransformPointX(x, y); - var y1 = trans.TransformPointY(x, y); - - var x2 = trans.TransformPointX(x+w, y); - var y2 = trans.TransformPointY(x+w, y); - - var x3 = trans.TransformPointX(x+w, y+h); - var y3 = trans.TransformPointY(x+w, y+h); - - var x4 = trans.TransformPointX(x, y+h); - var y4 = trans.TransformPointY(x, y+h); - - this.CheckPoint(x1, y1); - this.CheckPoint(x2, y2); - this.CheckPoint(x3, y3); - this.CheckPoint(x4, y4); - - if (eps !== undefined) - { - this.min_x -= eps; - this.min_y -= eps; - this.max_x += eps; - this.max_y += eps; - } - }, - CheckRect : function(x,y,w,h) - { - this.CheckPoint1(x,y); - this.CheckPoint2(x + w,y + h); - }, - AddEllipse : function(x,y,r) - { - this.CheckPoint1(x-r,y-r); - this.CheckPoint2(x+r,y+r); - - this.m_oContext.moveTo(x+r,y); - this.m_oContext.arc(x,y,r,0,Math.PI*2,false); - //this.m_oContext.closePath(); - }, - - AddRoundRect : function(x, y, w, h, r) - { - if (w < (2 * r) || h < (2 * r)) - return this.AddRect(x, y, w, h); - - this.CheckPoint1(x,y); - this.CheckPoint2(x + w,y + h); - - var _ctx = this.m_oContext; -// _ctx.moveTo(x + r, y); -// _ctx.lineTo(x + w - r, y); -// _ctx.quadraticCurveTo(x + w, y, x + w, y + r); -// _ctx.lineTo(x + w, y + h - r); -// _ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h); -// _ctx.lineTo(x + r, y + h); -// _ctx.quadraticCurveTo(x, y + h, x, y + h - r); -// _ctx.lineTo(x, y + r); -// _ctx.quadraticCurveTo(x, y, x + r, y); - }, - - AddRoundRectCtx : function(ctx, x, y, w, h, r) - { - if (w < (2 * r) || h < (2 * r)) - return ctx.rect(x, y, w, h); - - var _ctx = this.m_oContext; -// _ctx.moveTo(x + r, y); -// _ctx.lineTo(x + w - r, y); -// _ctx.quadraticCurveTo(x + w, y, x + w, y + r); -// _ctx.lineTo(x + w, y + h - r); -// _ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h); -// _ctx.lineTo(x + r, y + h); -// _ctx.quadraticCurveTo(x, y + h, x, y + h - r); -// _ctx.lineTo(x, y + r); -// _ctx.quadraticCurveTo(x, y, x + r, y); - }, - DrawFrozenPlaceHorLine: function(y, left, right) - { - }, - DrawFrozenPlaceVerLine: function(x, top, bottom) - { - } -}; - -function CAutoshapeTrack() -{ - this.IsTrack = true; - - this.PageIndex = -1; - this.CurrentPageInfo = null; - - this.Native = window["native"]["CreateAutoShapesTrackControl"](); -} - -CAutoshapeTrack.prototype = -{ - init2 : function() - { - }, - - CorrectOverlayBounds : function() - { - this.Native["DD_CorrectOverlayBounds"](); - }, - - SetCurrentPage : function(nPageIndex) - { - //if (nPageIndex == this.PageIndex) - // return; - - this.PageIndex = nPageIndex; - this.Native["DD_SetCurrentPage"](nPageIndex); - }, - - SetPageIndexSimple : function(nPageIndex) - { - this.Native["DD_SetPageIndexSimple"](nPageIndex); - }, - - transform3 : function(m) - { - this.Native["PD_transform3"](m.sx,m.shy,m.shx,m.sy,m.tx,m.ty); - }, - - /*************************************************************************/ - /******************************** TRACKS *********************************/ - /*************************************************************************/ - DrawTrack : function(type, matrix, left, top, width, height, isLine, isCanRotate, isNoMove, isDrawHandles) - { - if (!matrix) - this.Native["DD_DrawTrackTransform"](); - else - this.Native["DD_DrawTrackTransform"](matrix.sx, matrix.shy, matrix.shx, matrix.sy, matrix.tx, matrix.ty); - - this.Native["DD_DrawTrack"](type, left, top, width, height, isLine, isCanRotate, isNoMove, isDrawHandles); - }, - - DrawTrackSelectShapes : function(x, y, w, h) - { - this.Native["DD_DrawTrackSelectShapes"](x, y, w, h); - }, - - DrawAdjustment : function(matrix, x, y) - { - if (!matrix) - this.Native["DD_DrawTrackTransform"](); - else - this.Native["DD_DrawTrackTransform"](matrix.sx, matrix.shy, matrix.shx, matrix.sy, matrix.tx, matrix.ty); - - this.Native["DD_DrawAdjustment"](x, y); - }, - - DrawGeomEditPoint: function(matrix, gmEditPoint) - { - }, - - DrawGeometryEdit: function (matrix, pathLst, gmEditList, gmEditPoint, oBounds) - { - }, - - DrawEditWrapPointsPolygon : function(points, matrix) - { - if (!matrix) - this.Native["DD_DrawTrackTransform"](); - else - this.Native["DD_DrawTrackTransform"](matrix.sx, matrix.shy, matrix.shx, matrix.sy, matrix.tx, matrix.ty); - - this.Native["DD_DrawEditWrapPointsPolygon"](points); - }, - - DrawEditWrapPointsTrackLines : function(points, matrix) - { - if (!matrix) - this.Native["DD_DrawTrackTransform"](); - else - this.Native["DD_DrawTrackTransform"](matrix.sx, matrix.shy, matrix.shx, matrix.sy, matrix.tx, matrix.ty); - - this.Native["DD_DrawEditWrapPointsTrackLines"](points); - }, - - DrawInlineMoveCursor : function(x, y, h, m) - { - if (!m) - { - this.Native["DD_DrawInlineMoveCursor"](this.PageIndex, x, y, h); - } - else - { - this.Native["DD_DrawInlineMoveCursor"](this.PageIndex, x, y, h, m.sx, m.shy, m.shx, m.sy, m.tx, m.ty); - } - }, - - drawFlowAnchor : function(x, y) - { - this.Native["PD_drawFlowAnchor"](x, y); - }, - - DrawPresentationComment : function(type, x, y, w, h) - { - this.Native["PD_DrawPresentationComment"](type, x, y, w, h); - }, - - // repeat drawing interface - put_GlobalAlpha : function(enable, alpha) - { - this.Native["PD_put_GlobalAlpha"](enable, alpha); - }, - Start_GlobalAlpha : function() - { - // nothing - }, - End_GlobalAlpha : function() - { - this.Native["PD_End_GlobalAlpha"](); - }, - // pen methods - p_color : function(r,g,b,a) - { - this.Native["PD_p_color"](r,g,b,a); - }, - p_width : function(w) - { - this.Native["PD_p_width"](w); - }, - // brush methods - b_color1 : function(r,g,b,a) - { - this.Native["PD_b_color1"](r,g,b,a); - }, - b_color2 : function(r,g,b,a) - { - this.Native["PD_b_color2"](r,g,b,a); - }, - - transform : function(sx,shy,shx,sy,tx,ty) - { - this.Native["PD_transform"](sx,shy,shx,sy,tx,ty); - }, - // path commands - _s : function() - { - this.Native["PD_PathStart"](); - }, - _e : function() - { - this.Native["PD_PathEnd"](); - }, - _z : function() - { - this.Native["PD_PathClose"](); - }, - _m : function(x,y) - { - this.Native["PD_PathMoveTo"](x,y); - }, - _l : function(x,y) - { - this.Native["PD_PathLineTo"](x,y); - }, - _c : function(x1,y1,x2,y2,x3,y3) - { - this.Native["PD_PathCurveTo"](x1,y1,x2,y2,x3,y3); - }, - _c2 : function(x1,y1,x2,y2) - { - this.Native["PD_PathCurveTo2"](x1,y1,x2,y2); - }, - ds : function() - { - this.Native["PD_Stroke"](); - }, - df : function() - { - this.Native["PD_Fill"](); - }, - - // canvas state - save : function() - { - this.Native["PD_Save"](); - }, - restore : function() - { - this.Native["PD_Restore"](); - }, - clip : function() - { - this.Native["PD_clip"](); - }, - - reset : function() - { - this.Native["PD_reset"](); - }, - - FreeFont : function() - { - }, - - // images - drawImage : function(img,x,y,w,h,alpha,srcRect) - { - if (!srcRect) - return this.Native["PD_drawImage"](img,x,y,w,h,alpha); - - return this.Native["PD_drawImage"](img,x,y,w,h,alpha,srcRect.l,srcRect.t,srcRect.r,srcRect.b); - }, - - // text - GetFont : function() - { - }, - font : function(font_id,font_size) - { - }, - SetFont : function(font) - { - }, - - SetTextPr : function(textPr, theme) - { - }, - GetTextPr : function() - { - }, - - SetFontInternal : function(name, size, style) - { - }, - - SetFontSlot : function(slot, fontSizeKoef) - { - }, - - FillText : function(x,y,text) - { - }, - t : function(text,x,y) - { - }, - FillText2 : function(x,y,text,cropX,cropW) - { - }, - t2 : function(text,x,y,cropX,cropW) - { - }, - FillTextCode : function(x,y,lUnicode) - { - }, - tg : function(text,x,y) - { - }, - charspace : function(space) - { - }, - - SetIntegerGrid : function(param) - { - //this.Native["PD_SetIntegerGrid"](param); - }, - GetIntegerGrid : function() - { - //return this.m_bIntegerGrid; - return false; - }, - - DrawHeaderEdit : function(yPos, lock_type) - { - this.Native["PD_DrawHeaderEdit"](yPos, lock_type); - }, - - DrawFooterEdit : function(yPos, lock_type) - { - this.Native["PD_DrawFooterEdit"](yPos, lock_type); - }, - - DrawLockParagraph : function(lock_type, x, y1, y2) - { - this.Native["PD_DrawLockParagraph"](lock_type, x, y1, y2); - }, - - DrawLockObjectRect : function(lock_type, x, y, w, h) - { - this.Native["PD_DrawLockObjectRect"](lock_type, x, y, w, h); - }, - - DrawEmptyTableLine : function(x1,y1,x2,y2) - { - this.Native["PD_DrawEmptyTableLine"](x1,y1,x2,y2); - }, - - DrawSpellingLine : function(y0, x0, x1, w) - { - this.Native["PD_DrawSpellingLine"](y0, x0, x1, w); - }, - - // smart methods for horizontal / vertical lines - drawHorLine : function(align, y, x, r, penW) - { - this.Native["PD_drawHorLine"](align, y, x, r, penW); - }, - drawHorLine2 : function(align, y, x, r, penW) - { - this.Native["PD_drawHorLine2"](align, y, x, r, penW); - }, - drawVerLine : function(align, x, y, b, penW) - { - this.Native["PD_drawVerLine"](align, x, y, b, penW); - }, - - // мега крутые функции для таблиц - drawHorLineExt : function(align, y, x, r, penW, leftMW, rightMW) - { - this.Native["PD_drawHorLineExt"](align, y, x, r, penW, leftMW, rightMW); - }, - - rect : function(x,y,w,h) - { - this.Native["PD_rect"](x,y,w,h); - }, - - TableRect : function(x,y,w,h) - { - this.Native["PD_TableRect"](x,y,w,h); - }, - - // функции клиппирования - AddClipRect : function(x, y, w, h) - { - this.Native["PD_AddClipRect"](x,y,w,h); - }, - RemoveClipRect : function() - { - // nothing - }, - - SetClip : function(r) - { - this.Native["PD_SetClip"](r.x, r.y, r.w, r.h); - }, - - RemoveClip : function() - { - this.Native["PD_RemoveClip"](); - }, - - drawCollaborativeChanges : function(x, y, w, h) - { - this.Native["PD_drawCollaborativeChanges"](x, y, w, h); - }, - - drawSearchResult : function(x, y, w, h) - { - this.Native["PD_drawSearchResult"](x, y, w, h); - }, - - SavePen : function() - { - this.Native["PD_SavePen"](); - }, - RestorePen : function() - { - this.Native["PD_RestorePen"](); - }, - - SaveBrush : function() - { - this.Native["PD_SaveBrush"](); - }, - RestoreBrush : function() - { - this.Native["PD_RestoreBrush"](); - }, - - SavePenBrush : function() - { - this.Native["PD_SavePenBrush"](); - }, - RestorePenBrush : function() - { - this.Native["PD_RestorePenBrush"](); - }, - - SaveGrState : function() - { - this.Native["PD_SaveGrState"](); - }, - RestoreGrState : function() - { - this.Native["PD_RestoreGrState"](); - }, - - StartClipPath : function() - { - this.Native["PD_StartClipPath"](); - }, - - EndClipPath : function() - { - this.Native["PD_EndClipPath"](); - }, - - StartCheckTableDraw : function() - { - return this.Native["PD_StartCheckTableDraw"](); - }, - - EndCheckTableDraw : function(bIsRestore) - { - return this.Native["PD_EndCheckTableDraw"](bIsRestore); - }, - - SetTextClipRect : function(_l, _t, _r, _b) - { - return this.Native["PD_SetTextClipRect"](_l, _t, _r, _b); - }, - - AddSmartRect : function(x, y, w, h, pen_w) - { - return this.Native["PD_AddSmartRect"](x, y, w, h, pen_w); - }, - - Drawing_StartCheckBounds : function(x, y, w, h) - { - - }, - - Drawing_EndCheckBounds : function() - { - - } -}; - -//--------------------------------------------------------export---------------------------------------------------- -window['AscCommon'] = window['AscCommon'] || {}; -window['AscCommon'].COverlay = COverlay; -window['AscCommon'].TRACK_CIRCLE_RADIUS = TRACK_CIRCLE_RADIUS; -window['AscCommon'].TRACK_DISTANCE_ROTATE = TRACK_DISTANCE_ROTATE; -window['AscCommon'].CAutoshapeTrack = CAutoshapeTrack; diff --git a/common/Native/Wrappers/ShapeDrawer.js b/common/Native/Wrappers/ShapeDrawer.js deleted file mode 100755 index e858b92c59..0000000000 --- a/common/Native/Wrappers/ShapeDrawer.js +++ /dev/null @@ -1,1516 +0,0 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2023 - * - * This program is a free software product. You can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License (AGPL) - * version 3 as published by the Free Software Foundation. In accordance with - * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement - * of any third-party rights. - * - * This program is distributed WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ - -function DrawLineEnd(xEnd, yEnd, xPrev, yPrev, type, w, len, drawer, trans) -{ - switch (type) - { - case AscFormat.LineEndType.None: - break; - case AscFormat.LineEndType.Arrow: - { - var _ex = xPrev - xEnd; - var _ey = yPrev - yEnd; - var _elen = Math.sqrt(_ex*_ex + _ey*_ey); - _ex /= _elen; - _ey /= _elen; - - var _vx = _ey; - var _vy = -_ex; - - var tmpx = xEnd + len * _ex; - var tmpy = yEnd + len * _ey; - - var x1 = tmpx + _vx * w/2; - var y1 = tmpy + _vy * w/2; - - var x3 = tmpx - _vx * w/2; - var y3 = tmpy - _vy * w/2; - - drawer._s(); - drawer._m(trans.TransformPointX(x1, y1), trans.TransformPointY(x1, y1)); - drawer._l(trans.TransformPointX(xEnd, yEnd), trans.TransformPointY(xEnd, yEnd)); - drawer._l(trans.TransformPointX(x3, y3), trans.TransformPointY(x3, y3)); - drawer.ds(); - drawer._e(); - - break; - } - case AscFormat.LineEndType.Diamond: - { - var _ex = xPrev - xEnd; - var _ey = yPrev - yEnd; - var _elen = Math.sqrt(_ex*_ex + _ey*_ey); - _ex /= _elen; - _ey /= _elen; - - var _vx = _ey; - var _vy = -_ex; - - var tmpx = xEnd + len/2 * _ex; - var tmpy = yEnd + len/2 * _ey; - - var x1 = xEnd + _vx * w/2; - var y1 = yEnd + _vy * w/2; - - var x3 = xEnd - _vx * w/2; - var y3 = yEnd - _vy * w/2; - - var tmpx2 = xEnd - len/2 * _ex; - var tmpy2 = yEnd - len/2 * _ey; - - drawer._s(); - drawer._m(trans.TransformPointX(tmpx, tmpy), trans.TransformPointY(tmpx, tmpy)); - drawer._l(trans.TransformPointX(x1, y1), trans.TransformPointY(x1, y1)); - drawer._l(trans.TransformPointX(tmpx2, tmpy2), trans.TransformPointY(tmpx2, tmpy2)); - drawer._l(trans.TransformPointX(x3, y3), trans.TransformPointY(x3, y3)); - drawer._z(); - drawer.drawStrokeFillStyle(); - drawer._e(); - - drawer._s(); - drawer._m(trans.TransformPointX(tmpx, tmpy), trans.TransformPointY(tmpx, tmpy)); - drawer._l(trans.TransformPointX(x1, y1), trans.TransformPointY(x1, y1)); - drawer._l(trans.TransformPointX(tmpx2, tmpy2), trans.TransformPointY(tmpx2, tmpy2)); - drawer._l(trans.TransformPointX(x3, y3), trans.TransformPointY(x3, y3)); - drawer._z(); - drawer.ds(); - drawer._e(); - - break; - } - case AscFormat.LineEndType.Oval: - { - var _ex = xPrev - xEnd; - var _ey = yPrev - yEnd; - var _elen = Math.sqrt(_ex*_ex + _ey*_ey); - _ex /= _elen; - _ey /= _elen; - - var _vx = _ey; - var _vy = -_ex; - - var tmpx = xEnd + len/2 * _ex; - var tmpy = yEnd + len/2 * _ey; - - var tmpx2 = xEnd - len/2 * _ex; - var tmpy2 = yEnd - len/2 * _ey; - - var cx1 = tmpx + _vx * 3*w/4; - var cy1 = tmpy + _vy * 3*w/4; - var cx2 = tmpx2 + _vx * 3*w/4; - var cy2 = tmpy2 + _vy * 3*w/4; - - var cx3 = tmpx - _vx * 3*w/4; - var cy3 = tmpy - _vy * 3*w/4; - var cx4 = tmpx2 - _vx * 3*w/4; - var cy4 = tmpy2 - _vy * 3*w/4; - - drawer._s(); - drawer._m(trans.TransformPointX(tmpx, tmpy), trans.TransformPointY(tmpx, tmpy)); - drawer._c(trans.TransformPointX(cx1, cy1), trans.TransformPointY(cx1, cy1), - trans.TransformPointX(cx2, cy2), trans.TransformPointY(cx2, cy2), - trans.TransformPointX(tmpx2, tmpy2), trans.TransformPointY(tmpx2, tmpy2)); - - drawer._c(trans.TransformPointX(cx4, cy4), trans.TransformPointY(cx4, cy4), - trans.TransformPointX(cx3, cy3), trans.TransformPointY(cx3, cy3), - trans.TransformPointX(tmpx, tmpy), trans.TransformPointY(tmpx, tmpy)); - - drawer.drawStrokeFillStyle(); - drawer._e(); - - drawer._s(); - drawer._m(trans.TransformPointX(tmpx, tmpy), trans.TransformPointY(tmpx, tmpy)); - drawer._c(trans.TransformPointX(cx1, cy1), trans.TransformPointY(cx1, cy1), - trans.TransformPointX(cx2, cy2), trans.TransformPointY(cx2, cy2), - trans.TransformPointX(tmpx2, tmpy2), trans.TransformPointY(tmpx2, tmpy2)); - - drawer._c(trans.TransformPointX(cx4, cy4), trans.TransformPointY(cx4, cy4), - trans.TransformPointX(cx3, cy3), trans.TransformPointY(cx3, cy3), - trans.TransformPointX(tmpx, tmpy), trans.TransformPointY(tmpx, tmpy)); - - drawer.ds(); - drawer._e(); - break; - } - case AscFormat.LineEndType.Stealth: - { - var _ex = xPrev - xEnd; - var _ey = yPrev - yEnd; - var _elen = Math.sqrt(_ex*_ex + _ey*_ey); - _ex /= _elen; - _ey /= _elen; - - var _vx = _ey; - var _vy = -_ex; - - var tmpx = xEnd + len * _ex; - var tmpy = yEnd + len * _ey; - - var x1 = tmpx + _vx * w/2; - var y1 = tmpy + _vy * w/2; - - var x3 = tmpx - _vx * w/2; - var y3 = tmpy - _vy * w/2; - - var x4 = xEnd + (len - w/2) * _ex; - var y4 = yEnd + (len - w/2) * _ey; - - drawer._s(); - drawer._m(trans.TransformPointX(x1, y1), trans.TransformPointY(x1, y1)); - drawer._l(trans.TransformPointX(xEnd, yEnd), trans.TransformPointY(xEnd, yEnd)); - drawer._l(trans.TransformPointX(x3, y3), trans.TransformPointY(x3, y3)); - drawer._l(trans.TransformPointX(x4, y4), trans.TransformPointY(x4, y4)); - drawer._z(); - drawer.drawStrokeFillStyle(); - drawer._e(); - - drawer._s(); - drawer._m(trans.TransformPointX(x1, y1), trans.TransformPointY(x1, y1)); - drawer._l(trans.TransformPointX(xEnd, yEnd), trans.TransformPointY(xEnd, yEnd)); - drawer._l(trans.TransformPointX(x3, y3), trans.TransformPointY(x3, y3)); - drawer._l(trans.TransformPointX(x4, y4), trans.TransformPointY(x4, y4)); - drawer._z(); - drawer.ds(); - drawer._e(); - - break; - } - case AscFormat.LineEndType.Triangle: - { - var _ex = xPrev - xEnd; - var _ey = yPrev - yEnd; - var _elen = Math.sqrt(_ex*_ex + _ey*_ey); - _ex /= _elen; - _ey /= _elen; - - var _vx = _ey; - var _vy = -_ex; - - var tmpx = xEnd + len * _ex; - var tmpy = yEnd + len * _ey; - - var x1 = tmpx + _vx * w/2; - var y1 = tmpy + _vy * w/2; - - var x3 = tmpx - _vx * w/2; - var y3 = tmpy - _vy * w/2; - - drawer._s(); - drawer._m(trans.TransformPointX(x1, y1), trans.TransformPointY(x1, y1)); - drawer._l(trans.TransformPointX(xEnd, yEnd), trans.TransformPointY(xEnd, yEnd)); - drawer._l(trans.TransformPointX(x3, y3), trans.TransformPointY(x3, y3)); - drawer._z(); - drawer.drawStrokeFillStyle(); - drawer._e(); - - drawer._s(); - drawer._m(trans.TransformPointX(x1, y1), trans.TransformPointY(x1, y1)); - drawer._l(trans.TransformPointX(xEnd, yEnd), trans.TransformPointY(xEnd, yEnd)); - drawer._l(trans.TransformPointX(x3, y3), trans.TransformPointY(x3, y3)); - drawer._z(); - drawer.ds(); - drawer._e(); - break; - } - } -} - - -function CShapeDrawer() -{ - this.Shape = null; - this.Graphics = null; - this.UniFill = null; - this.Ln = null; - this.Transform = null; - - this.bIsTexture = false; - this.bIsNoFillAttack = false; - this.bIsNoStrokeAttack = false; - this.bDrawSmartAttack = false; - this.FillUniColor = null; - this.StrokeUniColor = null; - this.StrokeWidth = 0; - - this.min_x = 0xFFFF; - this.min_y = 0xFFFF; - this.max_x = -0xFFFF; - this.max_y = -0xFFFF; - - this.OldLineJoin = null; - this.IsArrowsDrawing = false; - this.IsCurrentPathCanArrows = true; - - this.bIsCheckBounds = false; - - this.IsRectShape = false; -} - -CShapeDrawer.prototype = -{ - Clear : function() - { - //this.Shape = null; - //this.Graphics = null; - this.UniFill = null; - this.Ln = null; - this.Transform = null; - - this.bIsTexture = false; - this.bIsNoFillAttack = false; - this.bIsNoStrokeAttack = false; - this.FillUniColor = null; - this.StrokeUniColor = null; - this.StrokeWidth = 0; - - this.min_x = 0xFFFF; - this.min_y = 0xFFFF; - this.max_x = -0xFFFF; - this.max_y = -0xFFFF; - - this.OldLineJoin = null; - this.IsArrowsDrawing = false; - this.IsCurrentPathCanArrows = true; - - this.bIsCheckBounds = false; - - this.IsRectShape = false; - }, - - CheckPoint : function(x, y) - { - if (x < this.min_x) - this.min_x = x; - if (y < this.min_y) - this.min_y = y; - if (x > this.max_x) - this.max_x = x; - if (y > this.max_y) - this.max_y = y; - }, - - CheckDash : function() - { - if (this.Ln.prstDash != null && AscCommon.DashPatternPresets[this.Ln.prstDash]) - { - var _arr = AscCommon.DashPatternPresets[this.Ln.prstDash].slice(); - for (var indexD = 0; indexD < _arr.length; indexD++) - _arr[indexD] *= this.StrokeWidth; - if (this.Graphics && this.Graphics.RENDERER_PDF_FLAG) - this.Graphics.p_dash(_arr); - else - this.NativeGraphics && this.NativeGraphics["PD_p_dash"](_arr); - } - }, - - fromShape2 : function(shape, graphics, geom) - { - this.fromShape(shape, graphics); - - if (!geom) - { - this.IsRectShape = true; - } - else - { - if (geom.preset == "rect") - this.IsRectShape = true; - } - }, - - fromShape : function(shape, graphics) - { - this.IsRectShape = false; - this.Shape = shape; - - this.Graphics = graphics; - this.NativeGraphics = window["native"]; - - if (graphics.IsSlideBoundsCheckerType) - { - this.Graphics = graphics; - this.NativeGraphics = null; - } - else if (graphics.IsTrack) - { - this.NativeGraphics = graphics.Native; - } - - this.UniFill = shape.brush; - this.Ln = shape.pen; - this.Transform = shape.TransformMatrix; - - this.min_x = 0xFFFF; - this.min_y = 0xFFFF; - this.max_x = -0xFFFF; - this.max_y = -0xFFFF; - - var bIsCheckBounds = false; - - if (this.UniFill == null || this.UniFill.fill == null) - this.bIsNoFillAttack = true; - else - { - var _fill = this.UniFill.fill; - switch (_fill.type) - { - case Asc.c_oAscFill.FILL_TYPE_BLIP: - { - this.bIsTexture = true; - break; - } - case Asc.c_oAscFill.FILL_TYPE_SOLID: - { - if(_fill.color) - { - this.FillUniColor = _fill.color.RGBA; - } - else - { - this.FillUniColor = new AscFormat.CUniColor().RGBA; - } - break; - } - case Asc.c_oAscFill.FILL_TYPE_GRAD: - { - bIsCheckBounds = true; - - break; - } - case Asc.c_oAscFill.FILL_TYPE_PATT: - { - bIsCheckBounds = true; - break; - } - case Asc.c_oAscFill.FILL_TYPE_NOFILL: - { - this.bIsNoFillAttack = true; - break; - } - default: - { - this.bIsNoFillAttack = true; - break; - } - } - } - - if (this.Ln == null || this.Ln.Fill == null || this.Ln.Fill.fill == null) - { - this.bIsNoStrokeAttack = true; - if (true === graphics.IsTrack) { - if (graphics.Graphics != undefined && graphics.Graphics != null) { - graphics.Graphics.ArrayPoints = null; - } - - } else { - graphics.ArrayPoints = null; - } - } - else - { - var _fill = this.Ln.Fill.fill; - switch (_fill.type) - { - case Asc.c_oAscFill.FILL_TYPE_BLIP: - { - this.StrokeUniColor = new AscFormat.CUniColor().RGBA; - break; - } - case Asc.c_oAscFill.FILL_TYPE_SOLID: - { - if(_fill.color) - { - this.StrokeUniColor = _fill.color.RGBA; - } - else - { - this.StrokeUniColor = new AscFormat.CUniColor().RGBA; - } - break; - } - case Asc.c_oAscFill.FILL_TYPE_GRAD: - { - var _c = _fill.colors; - if (_c == 0) - this.StrokeUniColor = new AscFormat.CUniColor().RGBA; - else - { - if(_fill.colors[0].color) - { - this.StrokeUniColor = _fill.colors[0].color.RGBA; - } - else - { - this.StrokeUniColor = new AscFormat.CUniColor().RGBA; - } - } - - break; - } - case Asc.c_oAscFill.FILL_TYPE_PATT: - { - this.StrokeUniColor = _fill.fgClr.RGBA; - break; - } - case Asc.c_oAscFill.FILL_TYPE_NOFILL: - { - this.bIsNoStrokeAttack = true; - break; - } - default: - { - this.bIsNoStrokeAttack = true; - break; - } - } - - this.StrokeWidth = (this.Ln.w == null) ? 12700 : parseInt(this.Ln.w); - this.StrokeWidth /= 36000.0; - - this.p_width(1000 * this.StrokeWidth); - - this.CheckDash(); - - if (graphics.IsSlideBoundsCheckerType && !this.bIsNoStrokeAttack) - graphics.LineWidth = this.StrokeWidth; - - var isUseArrayPoints = false; - if ((this.Ln.headEnd != null && this.Ln.headEnd.type != null) || (this.Ln.tailEnd != null && this.Ln.tailEnd.type != null)) - isUseArrayPoints = true; - - if (true === graphics.IsTrack && graphics.Graphics != undefined && graphics.Graphics != null) - graphics.Graphics.ArrayPoints = isUseArrayPoints ? [] : null; - else - graphics.ArrayPoints = isUseArrayPoints ? [] : null; - - if (this.Graphics.m_oContext != null && this.Ln.Join != null && this.Ln.Join.type != null) - this.OldLineJoin = this.Graphics.m_oContext.lineJoin; - } - - if (this.bIsTexture || bIsCheckBounds) - { - // сначала нужно определить границы - this.bIsCheckBounds = true; - this.check_bounds(); - this.bIsCheckBounds = false; - } - }, - - draw : function(geom) - { - if (this.Graphics.RENDERER_PDF_FLAG) - { - return this.drawPDF(geom); - } - - if (this.bIsNoStrokeAttack && this.bIsNoFillAttack) - return; - - if (this.Graphics.IsSlideBoundsCheckerType) - { - // slide bounds checker - if(geom) - { - geom.draw(this); - } - else - { - this._s(); - this._m(0, 0); - this._l(this.Shape.extX, 0); - this._l(this.Shape.extX, this.Shape.extY); - this._l(0, this.Shape.extY); - this._z(); - this.drawFillStroke(true, "norm", true && !this.bIsNoStrokeAttack); - this._e(); - } - - if (this.Graphics.IsSlideBoundsCheckerType && this.Graphics.AutoCheckLineWidth) - { - this.Graphics.CorrectBounds2(); - } - - return; - } - - this.NativeGraphics["PD_StartShapeDraw"](this.IsRectShape); - - if(geom) - { - geom.draw(this); - } - else - { - this._s(); - this._m(0, 0); - this._l(this.Shape.extX, 0); - this._l(this.Shape.extX, this.Shape.extY); - this._l(0, this.Shape.extY); - this._z(); - this.drawFillStroke(true, "norm", true && !this.bIsNoStrokeAttack); - this._e(); - } - this.NativeGraphics["PD_EndShapeDraw"](); - this.NativeGraphics["PD_p_dash"]([]); - }, - - drawPDF : function(geom) - { - if (this.bIsNoStrokeAttack && this.bIsNoFillAttack) - return; - - var bIsPatt = false; - if (this.UniFill != null && this.UniFill.fill != null && - ((this.UniFill.fill.type == Asc.c_oAscFill.FILL_TYPE_PATT) || (this.UniFill.fill.type == Asc.c_oAscFill.FILL_TYPE_GRAD))) - { - bIsPatt = true; - } - - if (this.bIsTexture || bIsPatt) - { - this.Graphics.put_TextureBoundsEnabled(true); - this.Graphics.put_TextureBounds(this.min_x, this.min_y, this.max_x - this.min_x, this.max_y - this.min_y); - } - - if (geom) - { - geom.draw(this); - } - else - { - this._s(); - this._m(0, 0); - this._l(this.Shape.extX, 0); - this._l(this.Shape.extX, this.Shape.extY); - this._l(0, this.Shape.extY); - this._z(); - this.drawFillStroke(true, "norm", true && !this.bIsNoStrokeAttack); - this._e(); - } - this.Graphics.ArrayPoints = null; - - if (this.bIsTexture || bIsPatt) - { - this.Graphics.put_TextureBoundsEnabled(false); - } - }, - - p_width : function(w) - { - return this.Graphics.p_width(w); - }, - - _m : function(x, y) - { - if (this.bIsCheckBounds) - { - this.CheckPoint(x, y); - return; - } - return this.Graphics._m(x, y); - }, - _l : function(x, y) - { - if (this.bIsCheckBounds) - { - this.CheckPoint(x, y); - return; - } - return this.Graphics._l(x, y); - }, - _c : function(x1, y1, x2, y2, x3, y3) - { - if (this.bIsCheckBounds) - { - this.CheckPoint(x1, y1); - this.CheckPoint(x2, y2); - this.CheckPoint(x3, y3); - return; - } - return this.Graphics._c(x1, y1, x2, y2, x3, y3); - }, - _c2 : function(x1, y1, x2, y2) - { - if (this.bIsCheckBounds) - { - this.CheckPoint(x1, y1); - this.CheckPoint(x2, y2); - return; - } - return this.Graphics._c2(x1, y1, x2, y2); - }, - _z : function() - { - this.IsCurrentPathCanArrows = false; - if (this.bIsCheckBounds) - return; - return this.Graphics._z(); - }, - _s : function() - { - this.IsCurrentPathCanArrows = true; - return this.Graphics._s(); - }, - _e : function() - { - this.IsCurrentPathCanArrows = true; - return this.Graphics._e(); - }, - - df : function(mode) - { - if (mode == "none" || this.bIsNoFillAttack) - return; - - if (this.Graphics.IsTrack && this.Graphics.m_oOverlay) - this.Graphics.m_oOverlay.ClearAll = true; - - if (this.Graphics.IsSlideBoundsCheckerType) - return; - - var _fill = this.UniFill.fill; - switch (_fill.type) - { - case Asc.c_oAscFill.FILL_TYPE_BLIP: - { - if (!_fill.srcRect) - this.NativeGraphics["PD_put_BrushTexture"](_fill.RasterImageId); - else - { - var _sR = _fill.srcRect; - this.NativeGraphics["PD_put_BrushTexture"](_fill.RasterImageId, _sR.l, _sR.t, _sR.r, _sR.b); - } - - this.NativeGraphics["PD_put_BrushTextureMode"]((null == _fill.tile) ? 1 : 2); - this.NativeGraphics["PD_put_BrushTextureAlpha"]((null === this.UniFill.transparent) ? 255 : this.UniFill.transparent); - this.NativeGraphics["PD_put_BrushBounds"](this.min_x, this.min_y, (this.max_x - this.min_x), (this.max_y - this.min_y)); - - break; - } - case Asc.c_oAscFill.FILL_TYPE_SOLID: - { - var rgba = this.FillUniColor; - if (mode == "darken") - { - var _color1 = new AscFormat.CShapeColor(rgba.R, rgba.G, rgba.B); - var rgb = _color1.darken(); - rgba = { R: rgb.r, G: rgb.g, B: rgb.b, A: rgba.A }; - } - else if (mode == "darkenLess") - { - var _color1 = new AscFormat.CShapeColor(rgba.R, rgba.G, rgba.B); - var rgb = _color1.darkenLess(); - rgba = { R: rgb.r, G: rgb.g, B: rgb.b, A: rgba.A }; - } - else if (mode == "lighten") - { - var _color1 = new AscFormat.CShapeColor(rgba.R, rgba.G, rgba.B); - var rgb = _color1.lighten(); - rgba = { R: rgb.r, G: rgb.g, B: rgb.b, A: rgba.A }; - } - else if (mode == "lightenLess") - { - var _color1 = new AscFormat.CShapeColor(rgba.R, rgba.G, rgba.B); - var rgb = _color1.lightenLess(); - rgba = { R: rgb.r, G: rgb.g, B: rgb.b, A: rgba.A }; - } - if (rgba) - { - if (this.UniFill.transparent != null) - rgba.A = this.UniFill.transparent; - this.NativeGraphics["PD_b_color1"](rgba.R, rgba.G, rgba.B, rgba.A); - } - break; - } - case Asc.c_oAscFill.FILL_TYPE_GRAD: - { - this.NativeGraphics["PD_put_BrushBounds"](this.min_x, this.min_y, (this.max_x - this.min_x), (this.max_y - this.min_y)); - var points = null; - if (_fill.lin) - { - points = this.getGradientPoints(this.min_x, this.min_y, this.max_x, this.max_y, _fill.lin.angle, _fill.lin.scale); - this.NativeGraphics["PD_put_BrushGradientLinear"](points.x0, points.y0, points.x1, points.y1); - } - else if (_fill.path) - { - var _cx = (this.min_x + this.max_x) / 2; - var _cy = (this.min_y + this.max_y) / 2; - var _r = Math.max(this.max_x - this.min_x, this.max_y - this.min_y) / 2; - this.NativeGraphics["PD_put_BrushGradientRadial"](_cx, _cy, 1, _cx, _cy, _r); - } - else - { - //gradObj = _ctx.createLinearGradient(this.min_x, this.min_y, this.max_x, this.min_y); - points = this.getGradientPoints(this.min_x, this.min_y, this.max_x, this.max_y, 0, false); - this.NativeGraphics["PD_put_BrushGradientLinear"](points.x0, points.y0, points.x1, points.y1); - } - - var arr_pos = []; - var arr_colors = []; - - for (var i = 0; i < _fill.colors.length; i++) - { - arr_pos.push(_fill.colors[i].pos / 100000); - - var _c = _fill.colors[i].color.RGBA; - var _a = _c.A; - if (this.UniFill.transparent != null) - _c.A = this.UniFill.transparent; - - arr_colors.push(_c.R * 256*256*256 + _c.G * 256*256 + _c.B * 256 + _c.A); - _c.A = _a; - } - this.NativeGraphics["PD_put_BrushGragientColors"](arr_pos, arr_colors); - - break; - } - case Asc.c_oAscFill.FILL_TYPE_PATT: - { - var _patt_name = AscCommon.global_hatch_names[_fill.ftype]; - if (undefined == _patt_name) - _patt_name = "cross"; - - var _fc = _fill.fgClr && _fill.fgClr.RGBA || {R: 0, G: 0, B: 0, A: 255}; - var _bc = _fill.bgClr && _fill.bgClr.RGBA || {R: 255, G: 255, B: 255, A: 255}; - - var __fa = (null === this.UniFill.transparent) ? _fc.A : (this.UniFill.transparent >> 0); - var __ba = (null === this.UniFill.transparent) ? _bc.A : (this.UniFill.transparent >> 0); - - this.NativeGraphics["PD_b_color1"](_fc.R, _fc.G, _fc.B, __fa); - this.NativeGraphics["PD_b_color2"](_bc.R, _bc.G, _bc.B, __ba); - this.NativeGraphics["PD_put_BrushPattern"](_patt_name); - break; - } - default: - break; - } - - this.NativeGraphics["PD_Fill"](); - }, - ds : function() - { - if (this.bIsNoStrokeAttack) - return; - - if (this.Graphics.IsSlideBoundsCheckerType) - return; - - if (this.Graphics.RENDERER_PDF_FLAG) - { - this.Graphics.drawpath(1); - return; - } - if (this.Ln.Join != null && this.Ln.Join.type != null) - { - switch (this.Ln.Join.type) - { - case AscFormat.LineJoinType.Round: - { - this.NativeGraphics["PD_lineJoin"]("round"); - break; - } - case AscFormat.LineJoinType.Bevel: - { - this.NativeGraphics["PD_lineJoin"]("bevel"); - break; - } - case AscFormat.LineJoinType.Empty: - { - this.NativeGraphics["PD_lineJoin"]("miter"); - break; - } - case AscFormat.LineJoinType.Miter: - { - this.NativeGraphics["PD_lineJoin"]("miter"); - break; - } - } - } - - var rgba = this.StrokeUniColor; - this.NativeGraphics["PD_p_width"](this.StrokeWidth); - this.NativeGraphics["PD_p_color"](rgba.R, rgba.G, rgba.B, rgba.A); - - this.NativeGraphics["PD_Stroke"](); - - if (this.IsRectShape && this.Graphics.AddSmartRect !== undefined) - { - if (undefined !== this.Shape.extX) - this.Graphics.AddSmartRect(0, 0, this.Shape.extX, this.Shape.extY, this.StrokeWidth); - else - this.Graphics.ds(); - } - else - { - this.Graphics.ds(); - } - - if (null != this.OldLineJoin && !this.IsArrowsDrawing) - { - this.Graphics.m_oContext.lineJoin = this.OldLineJoin; - } - - var arr = (this.Graphics.IsTrack === true) ? (this.Graphics.Graphics ? this.Graphics.Graphics.ArrayPoints : null) : this.Graphics.ArrayPoints; - if (arr != undefined && arr != null && arr.length > 1 && this.IsCurrentPathCanArrows === true) - { - this.IsArrowsDrawing = true; - // this.NativeGraphics["PD_p_dash"]([]); - // значит стрелки есть. теперь: - // определяем толщину линии "как есть" - // трансформируем точки в окончательные. - // и отправляем на отрисовку (с матрицей) - - var trans = (this.Graphics.IsTrack === true) ? this.Graphics.Graphics.m_oFullTransform : this.Graphics.m_oFullTransform; - var trans1 = AscCommon.global_MatrixTransformer.Invert(trans); - - var x1 = trans.TransformPointX(0, 0); - var y1 = trans.TransformPointY(0, 0); - var x2 = trans.TransformPointX(1, 1); - var y2 = trans.TransformPointY(1, 1); - var dKoef = Math.sqrt(((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))/2); - var _pen_w = this.StrokeWidth * dKoef; // (this.Graphics.IsTrack === true) ? (this.Graphics.Graphics.m_oContext.lineWidth * dKoef) : (this.Graphics.m_oContext.lineWidth * dKoef); - - var _max_delta_eps2 = 0.001; - - if (this.Ln.headEnd != null) - { - var _x1 = trans.TransformPointX(arr[0].x, arr[0].y); - var _y1 = trans.TransformPointY(arr[0].x, arr[0].y); - var _x2 = trans.TransformPointX(arr[1].x, arr[1].y); - var _y2 = trans.TransformPointY(arr[1].x, arr[1].y); - - var _max_delta_eps = Math.max(this.Ln.headEnd.GetLen(_pen_w), 5); - - var _max_delta = Math.max(Math.abs(_x1 - _x2), Math.abs(_y1 - _y2)); - var cur_point = 2; - while (_max_delta < _max_delta_eps && cur_point < arr.length) - { - _x2 = trans.TransformPointX(arr[cur_point].x, arr[cur_point].y); - _y2 = trans.TransformPointY(arr[cur_point].x, arr[cur_point].y); - _max_delta = Math.max(Math.abs(_x1 - _x2), Math.abs(_y1 - _y2)); - cur_point++; - } - - if (_max_delta > _max_delta_eps2) - { - if (this.Graphics.IsTrack) - { - this.Graphics.Graphics.ArrayPoints = null; - DrawLineEnd(_x1, _y1, _x2, _y2, this.Ln.headEnd.type, this.Ln.headEnd.GetWidth(_pen_w), this.Ln.headEnd.GetLen(_pen_w), this, trans1); - this.Graphics.Graphics.ArrayPoints = arr; - } - else - { - this.Graphics.ArrayPoints = null; - DrawLineEnd(_x1, _y1, _x2, _y2, this.Ln.headEnd.type, this.Ln.headEnd.GetWidth(_pen_w), this.Ln.headEnd.GetLen(_pen_w), this, trans1); - this.Graphics.ArrayPoints = arr; - } - } - } - if (this.Ln.tailEnd != null) - { - var _1 = arr.length-1; - var _2 = arr.length-2; - var _x1 = trans.TransformPointX(arr[_1].x, arr[_1].y); - var _y1 = trans.TransformPointY(arr[_1].x, arr[_1].y); - var _x2 = trans.TransformPointX(arr[_2].x, arr[_2].y); - var _y2 = trans.TransformPointY(arr[_2].x, arr[_2].y); - - var _max_delta_eps = Math.max(this.Ln.tailEnd.GetLen(_pen_w), 5); - - var _max_delta = Math.max(Math.abs(_x1 - _x2), Math.abs(_y1 - _y2)); - var cur_point = _2 - 1; - while (_max_delta < _max_delta_eps && cur_point >= 0) - { - _x2 = trans.TransformPointX(arr[cur_point].x, arr[cur_point].y); - _y2 = trans.TransformPointY(arr[cur_point].x, arr[cur_point].y); - _max_delta = Math.max(Math.abs(_x1 - _x2), Math.abs(_y1 - _y2)); - cur_point--; - } - - if (_max_delta > _max_delta_eps2) - { - if (this.Graphics.IsTrack) - { - this.Graphics.Graphics.ArrayPoints = null; - DrawLineEnd(_x1, _y1, _x2, _y2, this.Ln.tailEnd.type, this.Ln.tailEnd.GetWidth(_pen_w), this.Ln.tailEnd.GetLen(_pen_w), this, trans1); - this.Graphics.Graphics.ArrayPoints = arr; - } - else - { - this.Graphics.ArrayPoints = null; - DrawLineEnd(_x1, _y1, _x2, _y2, this.Ln.tailEnd.type, this.Ln.tailEnd.GetWidth(_pen_w), this.Ln.tailEnd.GetLen(_pen_w), this, trans1); - this.Graphics.ArrayPoints = arr; - } - } - } - this.IsArrowsDrawing = false; - this.CheckDash(); - } - }, - - drawFillStroke : function(bIsFill, fill_mode, bIsStroke) - { - if (this.Graphics.RENDERER_PDF_FLAG) - { - return this.drawFillStrokePDF(bIsFill, fill_mode, bIsStroke); - } - - if (bIsFill) - this.df(fill_mode); - if (bIsStroke) - this.ds(); - }, - - drawFillStrokePDF : function(bIsFill, fill_mode, bIsStroke) - { - if (this.bIsNoStrokeAttack) - bIsStroke = false; - - if (bIsStroke) - { - if (null != this.OldLineJoin && !this.IsArrowsDrawing) - { - this.Graphics.put_PenLineJoin(AscFormat.ConvertJoinAggType(this.Ln.Join.type)); - } - - var rgba = this.StrokeUniColor; - this.Graphics.p_width(1000 * this.StrokeWidth); - this.Graphics.p_color(rgba.R, rgba.G, rgba.B, rgba.A); - } - - if (fill_mode == "none" || this.bIsNoFillAttack) - bIsFill = false; - - var bIsPattern = false; - - if (bIsFill) - { - if (this.bIsTexture) - { - if (null == this.UniFill.fill.tile) - { - if (null == this.UniFill.fill.srcRect) - { - if (this.UniFill.fill.RasterImageId && this.UniFill.fill.RasterImageId.indexOf(".svg") != 0) - { - this.Graphics.drawImage(AscCommon.getFullImageSrc2(this.UniFill.fill.RasterImageId), this.min_x, this.min_y, (this.max_x - this.min_x), (this.max_y - this.min_y), undefined, undefined); - bIsFill = false; - } - else - { - if (this.UniFill.fill.canvas) - { - this.Graphics.put_brushTexture(this.UniFill.fill.canvas.toDataURL("image/png"), 0); - } - else - { - this.Graphics.put_brushTexture(AscCommon.getFullImageSrc2(this.UniFill.fill.RasterImageId), 0); - } - } - } - else - { - this.Graphics.drawImage(AscCommon.getFullImageSrc2(this.UniFill.fill.RasterImageId), this.min_x, this.min_y, (this.max_x - this.min_x), (this.max_y - this.min_y), undefined, this.UniFill.fill.srcRect); - bIsFill = false; - } - } - else - { - if (this.UniFill.fill.canvas) - { - this.Graphics.put_brushTexture(this.UniFill.fill.canvas.toDataURL("image/png"), 1); - } - else - { - this.Graphics.put_brushTexture(AscCommon.getFullImageSrc2(this.UniFill.fill.RasterImageId), 1); - } - } - this.Graphics.put_BrushTextureAlpha(this.UniFill.transparent); - } - else - { - var _fill = this.UniFill.fill; - if (_fill.type == Asc.c_oAscFill.FILL_TYPE_PATT) - { - var _patt_name = AscCommon.global_hatch_names[_fill.ftype]; - if (undefined == _patt_name) - _patt_name = "cross"; - - var _fc = _fill.fgClr.RGBA || {R: 0, G: 0, B: 0, A: 255}; - var _bc = _fill.bgClr.RGBA || {R: 255, G: 255, B: 255, A: 255}; - - var __fa = (null === this.UniFill.transparent) ? _fc.A : 255; - var __ba = (null === this.UniFill.transparent) ? _bc.A : 255; - - var _pattern = AscCommon.GetHatchBrush(_patt_name, _fc.R, _fc.G, _fc.B, __fa, _bc.R, _bc.G, _bc.B, __ba); - - var _url64 = ""; - try - { - _url64 = _pattern.toDataURL("image/png"); - } - catch (err) - { - _url64 = ""; - } - - this.Graphics.put_brushTexture(_url64, 1); - - if (null != this.UniFill.transparent) - this.Graphics.put_BrushTextureAlpha(this.UniFill.transparent); - else - this.Graphics.put_BrushTextureAlpha(255); - - bIsPattern = true; - } - else if (_fill.type == Asc.c_oAscFill.FILL_TYPE_GRAD) - { - var points = null; - if (_fill.lin) - { - var _angle = _fill.lin.angle; - if (_fill.rotateWithShape === false && this.Graphics.m_oTransform) - { - //_angle -= (60000 * this.Graphics.m_oTransform.GetRotation()); - _angle = AscCommon.GradientGetAngleNoRotate(_angle, this.Graphics.m_oTransform); - } - - points = this.getGradientPoints(this.min_x, this.min_y, this.max_x, this.max_y, _angle, _fill.lin.scale); - } - else if (_fill.path) - { - var _cx = (this.min_x + this.max_x) / 2; - var _cy = (this.min_y + this.max_y) / 2; - var _r = Math.max(this.max_x - this.min_x, this.max_y - this.min_y) / 2; - - points = { x0 : _cx, y0 : _cy, x1 : _cx, y1 : _cy, r0 : 1, r1 : _r }; - } - else - { - points = this.getGradientPoints(this.min_x, this.min_y, this.max_x, this.max_y, 0, false); - } - - this.Graphics.put_BrushGradient(_fill, points, this.UniFill.transparent); - } - else - { - var rgba = this.FillUniColor; - if (fill_mode == "darken") - { - var _color1 = new AscFormat.CShapeColor(rgba.R, rgba.G, rgba.B); - var rgb = _color1.darken(); - rgba = { R: rgb.r, G: rgb.g, B: rgb.b, A: rgba.A }; - } - else if (fill_mode == "darkenLess") - { - var _color1 = new AscFormat.CShapeColor(rgba.R, rgba.G, rgba.B); - var rgb = _color1.darkenLess(); - rgba = { R: rgb.r, G: rgb.g, B: rgb.b, A: rgba.A }; - } - else if (fill_mode == "lighten") - { - var _color1 = new AscFormat.CShapeColor(rgba.R, rgba.G, rgba.B); - var rgb = _color1.lighten(); - rgba = { R: rgb.r, G: rgb.g, B: rgb.b, A: rgba.A }; - } - else if (fill_mode == "lightenLess") - { - var _color1 = new AscFormat.CShapeColor(rgba.R, rgba.G, rgba.B); - var rgb = _color1.lightenLess(); - rgba = { R: rgb.r, G: rgb.g, B: rgb.b, A: rgba.A }; - } - if (rgba) - { - if (this.UniFill != null && this.UniFill.transparent != null) - rgba.A = this.UniFill.transparent; - this.Graphics.b_color1(rgba.R, rgba.G, rgba.B, rgba.A); - } - } - } - } - - if (bIsFill && bIsStroke) - { - if (this.bIsTexture || bIsPattern) - { - this.Graphics.drawpath(256); - this.Graphics.drawpath(1); - } - else - { - this.Graphics.drawpath(256 + 1); - } - } - else if (bIsFill) - { - this.Graphics.drawpath(256); - } - else if (bIsStroke) - { - this.Graphics.drawpath(1); - } - else - { - // такого быть не должно по идее - // может - см выше: 1) this.Graphics.drawImage(...); 2) bIsFill = false; - - //this.Graphics.b_color1(0, 0, 0, 0); - //this.Graphics.drawpath(256); - } - - var arr = this.Graphics.ArrayPoints; - if (arr != null && arr.length > 1 && this.IsCurrentPathCanArrows === true) - { - this.IsArrowsDrawing = true; - // this.NativeGraphics["PD_p_dash"]([]); - // значит стрелки есть. теперь: - // определяем толщину линии "как есть" - // трансформируем точки в окончательные. - // и отправляем на отрисовку (с матрицей) - - var trans = this.Graphics.GetTransform(); - var trans1 = AscCommon.global_MatrixTransformer.Invert(trans); - - var lineSize = this.Graphics.GetLineWidth(); - - var x1 = trans.TransformPointX(0, 0); - var y1 = trans.TransformPointY(0, 0); - var x2 = trans.TransformPointX(1, 1); - var y2 = trans.TransformPointY(1, 1); - var dKoef = Math.sqrt(((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))/2); - var _pen_w = lineSize * dKoef; - - if (this.Ln.headEnd != null) - { - var _x1 = trans.TransformPointX(arr[0].x, arr[0].y); - var _y1 = trans.TransformPointY(arr[0].x, arr[0].y); - var _x2 = trans.TransformPointX(arr[1].x, arr[1].y); - var _y2 = trans.TransformPointY(arr[1].x, arr[1].y); - - var _max_delta = Math.max(Math.abs(_x1 - _x2), Math.abs(_y1 - _y2)); - var cur_point = 2; - while (_max_delta < 0.001 && cur_point < arr.length) - { - _x2 = trans.TransformPointX(arr[cur_point].x, arr[cur_point].y); - _y2 = trans.TransformPointY(arr[cur_point].x, arr[cur_point].y); - _max_delta = Math.max(Math.abs(_x1 - _x2), Math.abs(_y1 - _y2)); - cur_point++; - } - - if (_max_delta > 0.001) - { - this.Graphics.ArrayPoints = null; - DrawLineEnd(_x1, _y1, _x2, _y2, this.Ln.headEnd.type, this.Ln.headEnd.GetWidth(_pen_w), this.Ln.headEnd.GetLen(_pen_w), this, trans1); - this.Graphics.ArrayPoints = arr; - } - } - if (this.Ln.tailEnd != null) - { - var _1 = arr.length-1; - var _2 = arr.length-2; - var _x1 = trans.TransformPointX(arr[_1].x, arr[_1].y); - var _y1 = trans.TransformPointY(arr[_1].x, arr[_1].y); - var _x2 = trans.TransformPointX(arr[_2].x, arr[_2].y); - var _y2 = trans.TransformPointY(arr[_2].x, arr[_2].y); - - var _max_delta = Math.max(Math.abs(_x1 - _x2), Math.abs(_y1 - _y2)); - var cur_point = _2 - 1; - while (_max_delta < 0.001 && cur_point >= 0) - { - _x2 = trans.TransformPointX(arr[cur_point].x, arr[cur_point].y); - _y2 = trans.TransformPointY(arr[cur_point].x, arr[cur_point].y); - _max_delta = Math.max(Math.abs(_x1 - _x2), Math.abs(_y1 - _y2)); - cur_point--; - } - - if (_max_delta > 0.001) - { - this.Graphics.ArrayPoints = null; - DrawLineEnd(_x1, _y1, _x2, _y2, this.Ln.tailEnd.type, this.Ln.tailEnd.GetWidth(_pen_w, 7 / AscCommon.g_dKoef_mm_to_pix), this.Ln.tailEnd.GetLen(_pen_w, 7 / AscCommon.g_dKoef_mm_to_pix), this, trans1); - this.Graphics.ArrayPoints = arr; - } - } - this.IsArrowsDrawing = false; - this.CheckDash(); - } - }, - - drawStrokeFillStyle : function() - { - if (this.Graphics.RENDERER_PDF_FLAG === undefined) - { - var gr = (this.Graphics.IsTrack == true) ? this.Graphics.Graphics : this.Graphics; - - var tmp = gr.m_oBrush.Color1; - var p_c = gr.m_oPen.Color; - gr.b_color1(p_c.R, p_c.G, p_c.B, p_c.A); - gr.df(); - gr.b_color1(tmp.R, tmp.G, tmp.B, tmp.A); - } - else - { - var tmp = this.Graphics.GetBrush().Color1; - var p_c = this.Graphics.GetPen().Color; - this.Graphics.b_color1(p_c.R, p_c.G, p_c.B, p_c.A); - this.Graphics.df(); - this.Graphics.b_color1(tmp.R, tmp.G, tmp.B, tmp.A); - } - }, - - check_bounds : function() - { - this.Shape.check_bounds(this); - }, - - // common funcs - getNormalPoint : function(x0, y0, angle, x1, y1) - { - // точка - пересечение прямой, проходящей через точку (x0, y0) под углом angle и - // перпендикуляра к первой прямой, проведенной из точки (x1, y1) - var ex1 = Math.cos(angle); - var ey1 = Math.sin(angle); - - var ex2 = -ey1; - var ey2 = ex1; - - var a = ex1 / ey1; - var b = ex2 / ey2; - - var x = ((a * b * y1 - a * b * y0) - (a * x1 - b * x0)) / (b - a); - var y = (x - x0) / a + y0; - - return { X : x, Y : y }; - }, - - getGradientPoints : function(min_x, min_y, max_x, max_y, _angle, scale) - { - var points = { x0 : 0, y0 : 0, x1 : 0, y1 : 0 }; - - var angle = _angle / 60000; - while (angle < 0) - angle += 360; - while (angle >= 360) - angle -= 360; - - if (Math.abs(angle) < 1) - { - points.x0 = min_x; - points.y0 = min_y; - points.x1 = max_x; - points.y1 = min_y; - - return points; - } - else if (Math.abs(angle - 90) < 1) - { - points.x0 = min_x; - points.y0 = min_y; - points.x1 = min_x; - points.y1 = max_y; - - return points; - } - else if (Math.abs(angle - 180) < 1) - { - points.x0 = max_x; - points.y0 = min_y; - points.x1 = min_x; - points.y1 = min_y; - - return points; - } - else if (Math.abs(angle - 270) < 1) - { - points.x0 = min_x; - points.y0 = max_y; - points.x1 = min_x; - points.y1 = min_y; - - return points; - } - - var grad_a = AscCommon.deg2rad(angle); - if (!scale) - { - if (angle > 0 && angle < 90) - { - var p = this.getNormalPoint(min_x, min_y, grad_a, max_x, max_y); - - points.x0 = min_x; - points.y0 = min_y; - points.x1 = p.X; - points.y1 = p.Y; - - return points; - } - if (angle > 90 && angle < 180) - { - var p = this.getNormalPoint(max_x, min_y, grad_a, min_x, max_y); - - points.x0 = max_x; - points.y0 = min_y; - points.x1 = p.X; - points.y1 = p.Y; - - return points; - } - if (angle > 180 && angle < 270) - { - var p = this.getNormalPoint(max_x, max_y, grad_a, min_x, min_y); - - points.x0 = max_x; - points.y0 = max_y; - points.x1 = p.X; - points.y1 = p.Y; - - return points; - } - if (angle > 270 && angle < 360) - { - var p = this.getNormalPoint(min_x, max_y, grad_a, max_x, min_y); - - points.x0 = min_x; - points.y0 = max_y; - points.x1 = p.X; - points.y1 = p.Y; - - return points; - } - // никогда сюда не зайдем - return points; - } - - // scale == true - var _grad_45 = (Math.PI / 2) - Math.atan2(max_y - min_y, max_x - min_x); - var _grad_90_45 = (Math.PI / 2) - _grad_45; - if (angle > 0 && angle < 90) - { - if (angle <= 45) - { - grad_a = (_grad_45 * angle / 45); - } - else - { - grad_a = _grad_45 + _grad_90_45 * (angle - 45) / 45; - } - - var p = this.getNormalPoint(min_x, min_y, grad_a, max_x, max_y); - - points.x0 = min_x; - points.y0 = min_y; - points.x1 = p.X; - points.y1 = p.Y; - - return points; - } - if (angle > 90 && angle < 180) - { - if (angle <= 135) - { - grad_a = Math.PI / 2 + _grad_90_45 * (angle - 90) / 45; - } - else - { - grad_a = Math.PI / 2 + _grad_90_45 + _grad_45 * (angle - 135) / 45; - } - - var p = this.getNormalPoint(max_x, min_y, grad_a, min_x, max_y); - - points.x0 = max_x; - points.y0 = min_y; - points.x1 = p.X; - points.y1 = p.Y; - - return points; - } - if (angle > 180 && angle < 270) - { - if (angle <= 225) - { - grad_a = Math.PI + _grad_45 * (angle - 180) / 45; - } - else - { - grad_a = Math.PI + _grad_45 + _grad_90_45 * (angle - 225) / 45; - } - - var p = this.getNormalPoint(max_x, max_y, grad_a, min_x, min_y); - - points.x0 = max_x; - points.y0 = max_y; - points.x1 = p.X; - points.y1 = p.Y; - - return points; - } - if (angle > 270 && angle < 360) - { - if (angle <= 315) - { - grad_a = 3 * Math.PI / 2 + _grad_90_45 * (angle - 270) / 45; - } - else - { - grad_a = 3 * Math.PI / 2 + _grad_90_45 + _grad_45 * (angle - 315) / 45; - } - - var p = this.getNormalPoint(min_x, max_y, grad_a, max_x, min_y); - - points.x0 = min_x; - points.y0 = max_y; - points.x1 = p.X; - points.y1 = p.Y; - - return points; - } - // никогда сюда не зайдем - return points; - }, - - DrawPresentationComment : function(type, x, y, w, h) - { - } -}; - -function ShapeToImageConverter(shape, pageIndex) -{ - return ""; -} - -//------------------------------------------------------------export---------------------------------------------------- -window['AscCommon'] = window['AscCommon'] || {}; -window['AscCommon'].CShapeDrawer = CShapeDrawer; -window['AscCommon'].ShapeToImageConverter = ShapeToImageConverter; -window['AscCommon'].IsShapeToImageConverter = false; diff --git a/common/Native/Wrappers/common.js b/common/Native/Wrappers/common.js deleted file mode 100755 index 17c3df63bf..0000000000 --- a/common/Native/Wrappers/common.js +++ /dev/null @@ -1,169 +0,0 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2023 - * - * This program is a free software product. You can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License (AGPL) - * version 3 as published by the Free Software Foundation. In accordance with - * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement - * of any third-party rights. - * - * This program is distributed WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ - -window.IS_NATIVE_EDITOR = true; - -window.NativeSupportTimeouts = true; -window.NativeTimeoutObject = {}; - -var clearTimeout = function(id) { - if (!window.NativeSupportTimeouts) - return; - - window.NativeTimeoutObject["" + id] = undefined; - window["native"]["ClearTimeout"](id); -} - -var setTimeout = function(func, interval) { - if (!window.NativeSupportTimeouts) - return; - - var id = window["native"]["GenerateTimeoutId"](interval); - window.NativeTimeoutObject["" + id] = {"func": func, repeat: false}; - - return id; -} - -var clearInterval = function(id) { - if (!window.NativeSupportTimeouts) - return; - - - window.NativeTimeoutObject["" + id] = undefined; - window["native"]["ClearTimeout"](id); -} - -var setInterval = function(func, interval) { - if (!window.NativeSupportTimeouts) - return; - - var id = window["native"]["GenerateTimeoutId"](interval); - window.NativeTimeoutObject["" + id] = {func: func, repeat: true, interval: interval}; - - return id; -} - -window.native.Call_TimeoutFire = function(id) { - if (!window.NativeSupportTimeouts) - return; - - var prop = "" + id; - - if (undefined === window.NativeTimeoutObject[prop]) { - return; - } - - var func = window.NativeTimeoutObject[prop].func; - var repeat = window.NativeTimeoutObject[prop].repeat; - var interval = window.NativeTimeoutObject[prop].interval; - - window.NativeTimeoutObject[prop] = undefined; - - if (!func) - return; - - func.call(null); - - if (repeat) { - setInterval(func, interval); - } - - func = null; -}; - -function offline_timeoutFire(id) { - return window.native.Call_TimeoutFire(id); -} - -var console = { - log : function(param) { window["native"]["ConsoleLog"](param); }, - time : function (param) {}, - timeEnd : function (param) {} -}; - -window["NativeCorrectImageUrlOnPaste"] = function (url) -{ - return window["native"]["CorrectImageUrlOnPaste"](url); -}; -window["NativeCorrectImageUrlOnCopy"] = function (url) -{ - return window["native"]["CorrectImageUrlOnCopy"](url); -}; - -window.NativeCalculateFile = function() -{ - Asc.editor.asc_nativeCalculateFile(); -} - -window.native.Call_OnUpdateOverlay = function(param) -{ - return window["API"].Call_OnUpdateOverlay(param); -}; - -window.native.Call_OnMouseDown = function(e) -{ - return window["API"].Call_OnMouseDown(e); -}; -window.native.Call_OnMouseUp = function(e) -{ - return window["API"].Call_OnMouseUp(e); -}; -window.native.Call_OnMouseMove = function(e) -{ - return window["API"].Call_OnMouseMove(e); -}; -window.native.Call_OnCheckMouseDown = function(e) -{ - return window["API"].Call_OnCheckMouseDown(e); -}; - -window.native.Call_OnKeyDown = function(e) -{ - return window["API"].Call_OnKeyDown(e); -}; -window.native.Call_OnKeyPress = function(e) -{ - return window["API"].Call_OnKeyPress(e); -}; -window.native.Call_OnKeyUp = function(e) -{ - return window["API"].Call_OnKeyUp(e); -}; -window.native.Call_OnKeyboardEvent = function(e) -{ - return window["API"].Call_OnKeyboardEvent(e); -}; - -window.native.Call_Menu_Event = function (type, _params) -{ - return window["API"].Call_Menu_Event(type, _params); -}; diff --git a/common/Native/Wrappers/memory.js b/common/Native/Wrappers/memory.js deleted file mode 100755 index 94847d3281..0000000000 --- a/common/Native/Wrappers/memory.js +++ /dev/null @@ -1,810 +0,0 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2023 - * - * This program is a free software product. You can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License (AGPL) - * version 3 as published by the Free Software Foundation. In accordance with - * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement - * of any third-party rights. - * - * This program is distributed WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ - -function CPointer() -{ - this.obj = null; - this.data = null; - this.pos = 0; -} -function dublicate_pointer(p) -{ - if (null == p) - return null; - - var d = new CPointer(); - d.data = p.data; - d.pos = p.pos; - return d; -} -function copy_pointer(p, size) -{ - var _p = g_memory.Alloc(size); - for (var i = 0; i < size; i++) - _p.data[i] = p.data[p.pos + i]; - return _p; -} - -function FT_Memory() -{ - this.canvas = document.createElement('canvas'); - this.canvas.width = 1; - this.canvas.height = 1; - this.ctx = this.canvas.getContext('2d'); - - this.Alloc = function(size) - { - var p = new CPointer(); - p.obj = this.ctx.createImageData(1,parseInt((size + 3) / 4)); - p.data = p.obj.data; - p.pos = 0; - return p; - } - this.AllocHeap = function() - { - // TODO: - } - this.CreateStream = function(size) - { - console.log("not impl"); - } -} -var g_memory = new FT_Memory(); - -function FT_Stream(data, size) -{ - this.obj = null; - this.data = data; - this.size = size; - this.pos = 0; - this.cur = 0; - - this.Seek = function(_pos) - { - if (_pos > this.size) - return 85; - this.pos = _pos; - return 0; - } - this.Skip = function(_skip) - { - if (_skip < 0) - return 85; - return this.Seek(this.pos + _skip); - } - this.Read = function(pointer, count) - { - return this.ReadAt(this.pos, pointer, count); - } - this.ReadArray = function(count) - { - var read_bytes = this.size - this.pos; - if (read_bytes > count) - read_bytes = count; - if (0 == read_bytes) - return null; - var a = new Array(read_bytes); - for (var i = 0;i this.size) - return 85; - var read_bytes = this.size - _pos; - if (read_bytes > count) - read_bytes = count; - - FT_Common.memcpy_p2(pointer,this.data,_pos,count); - - this.pos = _pos + read_bytes; - - if (read_bytes < count) - return 85; - - return 0; - } - this.TryRead = function(pointer, count) - { - var read_bytes = 0; - if (this.pos < this.size) - return read_bytes; - read_bytes = this.size - this.pos; - if (read_bytes > count) - read_bytes = count; - - FT_Common.memcpy_p2(pointer,this.data,this.pos,count); - - this.pos += read_bytes; - return read_bytes; - } - - // 1 bytes - this.GetUChar = function() - { - if (this.cur >= this.size) - return 0; - return this.data[this.cur++]; - } - this.GetChar = function() - { - if (this.cur >= this.size) - return 0; - var m = this.data[this.cur++]; - if (m > 127) - m -= 256; - return m; - } - this.GetString1 = function(len) - { - if (this.cur + len > this.size) - return ""; - var t = ""; - for (var i = 0; i < len; i++) - t += String.fromCharCode(this.data[this.cur + i]); - this.cur += len; - return t; - } - this.ReadString1 = function(len) - { - if (this.pos + len > this.size) - return ""; - var t = ""; - for (var i = 0; i < len; i++) - t += String.fromCharCode(this.data[this.pos + i]); - this.pos += len; - return t; - } - - this.ReadUChar = function() - { - if (this.pos >= this.size) - { - FT_Error = 85; - return 0; - } - FT_Error = 0; - return this.data[this.pos++]; - } - this.ReadChar = function() - { - if (this.pos >= this.size) - { - FT_Error = 85; - return 0; - } - FT_Error = 0; - var m = this.data[this.pos++]; - if (m > 127) - m -= 256; - return m; - } - - // 2 byte - this.GetUShort = function() - { - if (this.cur + 1 >= this.size) - return 0; - return (this.data[this.cur++] << 8 | this.data[this.cur++]); - } - this.GetShort = function() - { - return FT_Common.UShort_To_Short(this.GetUShort()); - } - this.ReadUShort = function() - { - if (this.pos + 1 >= this.size) - { - FT_Error = 85; - return 0; - } - FT_Error = 0; - return (this.data[this.pos++] << 8 | this.data[this.pos++]); - } - this.ReadShort = function() - { - return FT_Common.UShort_To_Short(this.ReadUShort()); - } - this.GetUShortLE = function() - { - if (this.cur + 1 >= this.size) - return 0; - return (this.data[this.cur++] | this.data[this.cur++] << 8); - } - this.GetShortLE = function() - { - return FT_Common.UShort_To_Short(this.GetUShortLE()); - } - this.ReadUShortLE = function() - { - if (this.pos + 1 >= this.size) - { - FT_Error = 85; - return 0; - } - FT_Error = 0; - return (this.data[this.pos++] | this.data[this.pos++] << 8); - } - this.ReadShortLE = function() - { - return FT_Common.UShort_To_Short(this.ReadUShortLE()); - } - - // 4 byte - this.GetULong = function() - { - if (this.cur + 3 >= this.size) - return 0; - //return (this.data[this.cur++] << 24 | this.data[this.cur++] << 16 | this.data[this.cur++] << 8 | this.data[this.cur++]); - var s = (this.data[this.cur++] << 24 | this.data[this.cur++] << 16 | this.data[this.cur++] << 8 | this.data[this.cur++]); - if (s < 0) - s += 4294967296; - return s; - } - this.GetLong = function() - { - // 32-битные числа - по умолчанию знаковые!!! - //return FT_Common.UintToInt(this.GetULong()); - return (this.data[this.cur++] << 24 | this.data[this.cur++] << 16 | this.data[this.cur++] << 8 | this.data[this.cur++]); - } - this.ReadULong = function() - { - if (this.pos + 3 >= this.size) - { - FT_Error = 85; - return 0; - } - FT_Error = 0; - var s = (this.data[this.pos++] << 24 | this.data[this.pos++] << 16 | this.data[this.pos++] << 8 | this.data[this.pos++]); - if (s < 0) - s += 4294967296; - return s; - } - this.ReadLong = function() - { - // 32-битные числа - по умолчанию знаковые!!! - //return FT_Common.Uint_To_int(this.ReadULong()); - if (this.pos + 3 >= this.size) - { - FT_Error = 85; - return 0; - } - FT_Error = 0; - return (this.data[this.pos++] << 24 | this.data[this.pos++] << 16 | this.data[this.pos++] << 8 | this.data[this.pos++]); - } - - this.GetULongLE = function() - { - if (this.cur + 3 >= this.size) - return 0; - return (this.data[this.cur++] | this.data[this.cur++] << 8 | this.data[this.cur++] << 16 | this.data[this.cur++] << 24); - } - this.GetLongLE = function() - { - return FT_Common.Uint_To_int(this.GetULongLE()); - } - this.ReadULongLE = function() - { - if (this.pos + 3 >= this.size) - { - FT_Error = 85; - return 0; - } - FT_Error = 0; - return (this.data[this.pos++] | this.data[this.pos++] << 8 | this.data[this.pos++] << 16 | this.data[this.pos++] << 24); - } - this.ReadLongLE = function() - { - return FT_Common.Uint_To_int(this.ReadULongLE()); - } - - // 3 byte - this.GetUOffset = function() - { - if (this.cur + 2 >= this.size) - return 0; - return (this.data[this.cur++] << 16 | this.data[this.cur++] << 8 | this.data[this.cur++]); - } - this.GetUOffsetLE = function() - { - if (this.cur + 2 >= this.size) - return 0; - return (this.data[this.cur++] | this.data[this.cur++] << 8 | this.data[this.cur++] << 16); - } - this.ReadUOffset = function() - { - if (this.pos + 2 >= this.size) - { - FT_Error = 85; - return 0; - } - FT_Error = 0; - return (this.data[this.pos++] << 16 | this.data[this.pos++] << 8 | this.data[this.pos++]); - } - this.ReadUOffsetLE = function() - { - if (this.pos + 2 >= this.size) - { - FT_Error = 85; - return 0; - } - FT_Error = 0; - return (this.data[this.pos++] | this.data[this.pos++] << 8 | this.data[this.pos++] << 16); - } - this.EnterFrame = function(count) - { - if (this.pos >= this.size || this.size - this.pos < count) - return 85; - - this.cur = this.pos; - this.pos += count; - return 0; - } - this.ExtractFrame = function(count, pointer) - { - if (null == pointer) - pointer = new CPointer(); - - var err = this.EnterFrame(count); - if (err != 0) - return err; - - pointer.data = this.data; - pointer.pos = this.cur; - - this.cur = 0; - return err; - } - this.ReleaseFrame = function() - { - } - this.ExitFrame = function() - { - this.cur = 0; - } - - this.ReadFields = function(arrayFields, structure) - { - // arrayFields : array {value, size, offset} - // structures : data pointer - var error = 0; - var cursor = this.cur; - var frame_accessed = false; - - var data = null; - var pos = 0; - - var ind = 0; - do - { - var value; - var sign_shift; - - switch (arrayFields[ind].value) - { - case 4: /* access a new frame */ - error = this.EnterFrame(arrayFields[ind].offset); - if (error != 0) - { - if (frame_accessed === true) - this.ExitFrame(); - return error; - } - - frame_accessed = true; - cursor = this.cur; - ind++; - continue; /* loop! */ - - case 24: /* read a byte sequence */ - case 25: /* skip some bytes */ - { - var len = arrayFields[ind].size; - if ( cursor + len > this.size ) - { - error = 85; - if (frame_accessed === true) - this.ExitFrame(); - return error; - } - - if ( arrayFields[ind] == 24 ) - { - data = structure.data; - pos = structure.pos + arrayFields[ind].offset; - - for (var i=0;i>> sign_shift) & 0xFFFFFFFF; - - /* finally, store the value in the object */ - - data = structure.data; - pos = structure.pos + arrayFields[ind].offset; - switch (arrayFields[ind]) - { - case 1: - data[pos] = value & 0xFF; - break; - - case 2: - data[pos] = (value >>> 8)&0xFF; - data[pos+1] = value&0xFF; - break; - - case 4: - data[pos] = (value >>> 24)&0xFF; - data[pos+1] = (value >>> 16)&0xFF; - data[pos+2] = (value >>> 8)&0xFF; - data[pos+3] = value&0xFF; - break; - - default: - data[pos] = (value >>> 24)&0xFF; - data[pos+1] = (value >>> 16)&0xFF; - data[pos+2] = (value >>> 8)&0xFF; - data[pos+3] = value&0xFF; - } - - /* go to next field */ - ind++; - } - while ( 1 ); - - return error; - } - this.ReadFields2 = function(fields, structure) - { - // arrayFields : array {value, size, offset} - // structures : data pointer - var error = 0; - var cursor = this.cur; - var frame_accessed = false; - - var data = null; - var pos = 0; - - var ind = 0; - do - { - var value; - var sign_shift; - - var fval = fields[ind]; - var fsize = fields[ind+1]; - var foffset = fields[ind+2]; - - switch (fval) - { - case 4: /* access a new frame */ - error = this.EnterFrame(foffset); - if (error != 0) - { - if (frame_accessed === true) - this.ExitFrame(); - return error; - } - - frame_accessed = true; - cursor = this.cur; - ind+=3; - continue; /* loop! */ - - case 24: /* read a byte sequence */ - case 25: /* skip some bytes */ - { - var len = arrayFields[ind].size; - if ( cursor + fsize > this.size ) - { - error = 85; - if (frame_accessed === true) - this.ExitFrame(); - return error; - } - - if ( fval == 24 ) - { - data = structure.data; - pos = structure.pos + fields[ind].offset; - - for (var i=0;i>> sign_shift) & 0xFFFFFFFF; - - /* finally, store the value in the object */ - - data = structure.data; - pos = structure.pos + fields[ind].offset; - switch (fields[ind]) - { - case 1: - data[pos] = value & 0xFF; - break; - - case 2: - data[pos] = (value >>> 8)&0xFF; - data[pos+1] = value&0xFF; - break; - - case 4: - data[pos] = (value >>> 24)&0xFF; - data[pos+1] = (value >>> 16)&0xFF; - data[pos+2] = (value >>> 8)&0xFF; - data[pos+3] = value&0xFF; - break; - - default: - data[pos] = (value >>> 24)&0xFF; - data[pos+1] = (value >>> 16)&0xFF; - data[pos+2] = (value >>> 8)&0xFF; - data[pos+3] = value&0xFF; - } - - /* go to next field */ - ind+=3; - } - while ( 1 ); - - return error; - } -} - -window["fts"] = FT_Stream; - -window['AscFonts'].FT_Memory = FT_Memory; -window['AscFonts'].FT_Stream = FT_Stream; -window['AscFonts'].g_memory = g_memory; - -// FT_Common -function _FT_Common() { - this.UintToInt = function(v) - { - return (v>2147483647)?v-4294967296:v; - }; - this.UShort_To_Short = function(v) - { - return (v>32767)?v-65536:v; - }; - this.IntToUInt = function(v) - { - return (v<0)?v+4294967296:v; - }; - this.Short_To_UShort = function(v) - { - return (v<0)?v+65536:v; - }; - this.memset = function(d,v,s) - { - for (var i=0;i1) ? groupname[1] : null, - replies : readSDKReplies(data) - }; -} - -function readSDKReplies(data) -{ - var i = 0, - replies = [], - date = null; - var repliesCount = data.asc_getRepliesCount(); - if (repliesCount) - { - for (i = 0; i < repliesCount; ++i) - { - var reply = data.asc_getReply(i); - date = (reply.asc_getOnlyOfficeTime()) - ? new Date(stringOOToLocalDate(reply.asc_getOnlyOfficeTime())) - : ((reply.asc_getTime() == '') ? new Date() : new Date(stringUtcToLocalDate(reply.asc_getTime()))); - replies.push({ - userId : reply.asc_getUserId(), - userName : reply.asc_getUserName(), - text : reply.asc_getText(), - date : date.getTime().toString() - }); - } - } - return replies; -} - -function onApiAddComment(id, data) -{ - function _apply() { - var comment = readSDKComment(id, data) || {}; - postDataAsJSONString(comment, 23001); // ASC_MENU_EVENT_TYPE_ADD_COMMENT - } - if (AscCommon.isApiAddCommentAsync === true) - setTimeout(_apply, 5); - else - _apply(); -} - -function onApiAddComments(data) -{ - function _apply() { - var comments = []; - for (var i = 0; i < data.length; ++i) - comments.push(readSDKComment(data[i].asc_getId(), data[i])); - postDataAsJSONString(comments, 23002); // ASC_MENU_EVENT_TYPE_ADD_COMMENTS - } - if (AscCommon.isApiAddCommentAsync === true) - setTimeout(_apply, 5); - else - _apply(); -} - -function onApiRemoveComment(id) -{ - var data = { - "id": id - }; - postDataAsJSONString(data, 23003); // ASC_MENU_EVENT_TYPE_REMOVE_COMMENT -} - -function onApiChangeComments(data) -{ - var comments = []; - for (var i = 0; i < data.length; ++i) - comments.push(readSDKComment(data[i].asc_getId(), data[i])); - postDataAsJSONString(comments, 23004); // ASC_MENU_EVENT_TYPE_CHANGE_COMMENTS -} - -function onApiRemoveComments(data) -{ - var ids = []; - for (var i = 0; i < data.length; ++i) - { - ids.push({ - "id": data[i] - }); - } - postDataAsJSONString(ids, 23005); // ASC_MENU_EVENT_TYPE_REMOVE_COMMENTS -} - -function onApiChangeCommentData(id, data) -{ - var comment = readSDKComment(id, data) || {}, - change = { - "id": id, - "comment": comment - }; - - postDataAsJSONString(change, 23006); // ASC_MENU_EVENT_TYPE_CHANGE_COMMENTDATA -} - -function onApiLockComment(id, userId) -{ - var data = { - "id": id, - "userId": userId - }; - postDataAsJSONString(data, 23007); // ASC_MENU_EVENT_TYPE_LOCK_COMMENT -} - -function onApiUnLockComment(id) -{ - var data = { - "id": id - }; - postDataAsJSONString(data, 23008); // ASC_MENU_EVENT_TYPE_UNLOCK_COMMENT -} - -function onApiShowComment(uids, posX, posY, leftX, opts, hint) -{ - var data = { - "uids": uids, - "posX": posX, - "posY": posY, - "leftX": leftX, - "opts": opts, - "hint": hint - }; - postDataAsJSONString(data, 23009); // ASC_MENU_EVENT_TYPE_SHOW_COMMENT -} - -function onApiHideComment(hint) -{ - var data = { - "hint": hint - }; - postDataAsJSONString(data, 23010); // ASC_MENU_EVENT_TYPE_HIDE_COMMENT -} - -function onApiUpdateCommentPosition(uids, posX, posY, leftX) -{ - var data = { - "uids": uids, - "posX": posX, - "posY": posY, - "leftX": leftX - }; - postDataAsJSONString(data, 23011); // ASC_MENU_EVENT_TYPE_UPDATE_COMMENT_POSITION -} - -// USERS -function sdkUsersToJson(users) -{ - var arrUsers = []; - - for (var userId in users) - { - if (undefined !== userId) - { - var user = users[userId]; - if (user) { - arrUsers.push({ - id : user.asc_getId(), - idOriginal : user.asc_getIdOriginal(), - userName : user.asc_getUserName(), - online : true, - color : user.asc_getColor(), - view : user.asc_getView() - }); - } - } - } - return arrUsers; -} - -function onApiAuthParticipantsChanged(users) -{ - var _users = sdkUsersToJson(users) || []; - postDataAsJSONString(_users, 20101); // ASC_COAUTH_EVENT_TYPE_PARTICIPANTS_CHANGED -} - -function onApiParticipantsChanged(users) -{ - var _users = sdkUsersToJson(users) || []; - postDataAsJSONString(_users, 20101); // ASC_COAUTH_EVENT_TYPE_PARTICIPANTS_CHANGED -} - -// PLACE -function onDocumentPlaceChanged() -{ - postDataAsJSONString(null, 23012); // ASC_MENU_EVENT_TYPE_DOCUMENT_PLACE_CHANGED -} - -// ACTIONS -function onApiLongActionBegin(type, id) -{ - var info = { - "type" : type, - "id" : id - }; - postDataAsJSONString(info, 26102); // ASC_MENU_EVENT_TYPE_LONGACTION_BEGIN -} - -function onApiLongActionEnd(type, id) -{ - var info = { - "type" : type, - "id" : id - }; - postDataAsJSONString(info, 26103); // ASC_MENU_EVENT_TYPE_LONGACTION_END -} - -// ERRORS -function onApiError(id, level, errData) -{ - var info = { - "level" : level, - "id" : id, - "errData" : JSON.prune(errData, 4) - }; - postDataAsJSONString(info, 26104); // ASC_MENU_EVENT_TYPE_API_ERROR -} - -// THEME COLORS -function onApiSendThemeColors(theme_colors, standart_colors) -{ - var colors = { - "themeColors": theme_colors.map(function(color) { - return getHexColor(color.get_r(), color.get_g(), color.get_b()); - }) - } - if (standart_colors != null) { - colors["standartColors"] = standart_colors.map(function(color) { - return getHexColor(color.get_r(), color.get_g(), color.get_b()); - }); - } - postDataAsJSONString(colors, 2417); // ASC_MENU_EVENT_TYPE_THEMECOLORS -} - -// JSON.prune -// JSON.prune : a function to stringify any object without overflow -// two additional optional parameters : -// - the maximal depth (default : 6) -// - the maximal length of arrays (default : 50) -// You can also pass an "options" object. -// examples : -// var json = JSON.prune(window) -// var arr = Array.apply(0,Array(1000)); var json = JSON.prune(arr, 4, 20) -// var json = JSON.prune(window.location, {inheritedProperties:true}) -// Web site : http://dystroy.org/JSON.prune/ -// JSON.prune on github : https://github.com/Canop/JSON.prune -// This was discussed here : http://stackoverflow.com/q/13861254/263525 -// The code is based on Douglas Crockford's code : https://github.com/douglascrockford/JSON-js/blob/master/json2.js -// No effort was done to support old browsers. JSON.prune will fail on IE8. -(function () { - 'use strict'; - - var DEFAULT_MAX_DEPTH = 6; - var DEFAULT_ARRAY_MAX_LENGTH = 50; - var DEFAULT_PRUNED_VALUE = '"-pruned-"'; - var seen; // Same variable used for all stringifications - var iterator; // either forEachEnumerableOwnProperty, forEachEnumerableProperty or forEachProperty - - // iterates on enumerable own properties (default behavior) - var forEachEnumerableOwnProperty = function(obj, callback) { - for (var k in obj) { - if (Object.prototype.hasOwnProperty.call(obj, k)) callback(k); - } - }; - // iterates on enumerable properties - var forEachEnumerableProperty = function(obj, callback) { - for (var k in obj) callback(k); - }; - // iterates on properties, even non enumerable and inherited ones - // This is dangerous - var forEachProperty = function(obj, callback, excluded) { - if (obj==null) return; - excluded = excluded || {}; - Object.getOwnPropertyNames(obj).forEach(function(k){ - if (!excluded[k]) { - callback(k); - excluded[k] = true; - } - }); - forEachProperty(Object.getPrototypeOf(obj), callback, excluded); - }; - - Object.defineProperty(Date.prototype, "toPrunedJSON", {value:Date.prototype.toJSON}); - - var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, - escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, - meta = { // table of character substitutions - '\b': '\\b', - '\t': '\\t', - '\n': '\\n', - '\f': '\\f', - '\r': '\\r', - '"' : '\\"', - '\\': '\\\\' - }; - - function quote(string) { - escapable.lastIndex = 0; - return escapable.test(string) ? '"' + string.replace(escapable, function (a) { - var c = meta[a]; - return typeof c === 'string' - ? c - : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); - }) + '"' : '"' + string + '"'; - } - - var prune = function (value, depthDecr, arrayMaxLength) { - var prunedString = DEFAULT_PRUNED_VALUE; - var replacer; - if (typeof depthDecr == "object") { - var options = depthDecr; - depthDecr = options.depthDecr; - arrayMaxLength = options.arrayMaxLength; - iterator = options.iterator || forEachEnumerableOwnProperty; - if (options.allProperties) iterator = forEachProperty; - else if (options.inheritedProperties) iterator = forEachEnumerableProperty - if ("prunedString" in options) { - prunedString = options.prunedString; - } - if (options.replacer) { - replacer = options.replacer; - } - } else { - iterator = forEachEnumerableOwnProperty; - } - seen = []; - depthDecr = depthDecr || DEFAULT_MAX_DEPTH; - arrayMaxLength = arrayMaxLength || DEFAULT_ARRAY_MAX_LENGTH; - function str(key, holder, depthDecr) { - var i, k, v, length, partial, value = holder[key]; - - if (value && typeof value === 'object' && typeof value.toPrunedJSON === 'function') { - value = value.toPrunedJSON(key); - } - if (value && typeof value.toJSON === 'function') { - value = value.toJSON(); - } - - switch (typeof value) { - case 'string': - return quote(value); - case 'number': - return isFinite(value) ? String(value) : 'null'; - case 'boolean': - case 'null': - return String(value); - case 'object': - if (!value) { - return 'null'; - } - if (depthDecr<=0 || seen.indexOf(value)!==-1) { - if (replacer) { - var replacement = replacer(value, prunedString, true); - return replacement===undefined ? undefined : ''+replacement; - } - return prunedString; - } - seen.push(value); - partial = []; - if (Object.prototype.toString.apply(value) === '[object Array]') { - length = Math.min(value.length, arrayMaxLength); - for (i = 0; i < length; i += 1) { - partial[i] = str(i, value, depthDecr-1) || 'null'; - } - v = '[' + partial.join(',') + ']'; - if (replacer && value.length>arrayMaxLength) return replacer(value, v, false); - return v; - } - if (value instanceof RegExp) { - return quote(value.toString()); - } - iterator(value, function(k) { - try { - v = str(k, value, depthDecr-1); - if (v) partial.push(quote(k) + ':' + v); - } catch (e) { - // this try/catch due to forbidden accessors on some objects - } - }); - return '{' + partial.join(',') + '}'; - case 'function': - case 'undefined': - return replacer ? replacer(value, undefined, false) : undefined; - } - } - return str('', {'': value}, depthDecr); - }; - - prune.log = function() { - console.log.apply(console, Array.prototype.map.call(arguments, function(v) { - return JSON.parse(JSON.prune(v)); - })); - }; - prune.forEachProperty = forEachProperty; // you might want to also assign it to Object.forEachProperty - - if (typeof module !== "undefined") module.exports = prune; - else JSON.prune = prune; -}()); diff --git a/common/Native/native.js b/common/Native/native.js deleted file mode 100755 index 06411e6ded..0000000000 --- a/common/Native/native.js +++ /dev/null @@ -1,305 +0,0 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2023 - * - * This program is a free software product. You can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License (AGPL) - * version 3 as published by the Free Software Foundation. In accordance with - * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement - * of any third-party rights. - * - * This program is distributed WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ - -var editor = undefined; -var navigator = {}; -navigator.userAgent = "chrome"; - -window.location = {}; - -window.location.protocol = ""; -window.location.host = ""; -window.location.href = ""; -window.location.pathname = ""; - -window.XMLHttpRequest = function () {}; - -window.NATIVE_EDITOR_ENJINE = true; -window.NATIVE_EDITOR_ENJINE_SYNC_RECALC = true; - -var document = {}; - -var Asc = {}; -var AscFonts = {}; -var AscCommon = {}; -var AscFormat = {}; -var AscDFH = {}; -var AscCH = {}; -var AscCommonExcel = {}; -var AscCommonWord = {}; -var AscMath = {}; -var AscCommonSlide = {}; -var AscBuilder = {}; -var AscWord = {}; -var AscJsonConverter = {}; - -function Image() -{ - this.src = ""; - this.onload = function () {}; - this.onerror = function () {}; -} - -function _image_data() -{ - this.data = null; - this.length = 0; -} - -function native_pattern_fill() -{ -} -native_pattern_fill.prototype = -{ - setTransform: function (transform) {} -}; - -function native_gradient_fill() {} -native_gradient_fill.prototype = -{ - addColorStop: function (offset, color) {} -}; - -function native_context2d(parent) -{ - this.canvas = parent; - - this.globalAlpha = 0; - this.globalCompositeOperation = ""; - this.fillStyle = "#000000"; - this.strokeStyle = "#000000"; - - this.lineWidth = 0; - this.lineCap = 0; - this.lineJoin = 0; - this.miterLimit = 0; - this.shadowOffsetX = 0; - this.shadowOffsetY = 0; - this.shadowBlur = 0; - this.shadowColor = 0; - this.font = ""; - this.textAlign = 0; - this.textBaseline = 0; -} -native_context2d.prototype = -{ - save: function () {}, - restore: function () {}, - - scale: function (x, y) {}, - rotate: function (angle) {}, - translate: function (x, y) {}, - transform: function (m11, m12, m21, m22, dx, dy) {}, - setTransform: function (m11, m12, m21, m22, dx, dy) {}, - - createLinearGradient: function (x0, y0, x1, y1) {}, - createRadialGradient: function (x0, y0, r0, x1, y1, r1) {}, - createPattern: function (image, repetition) {}, - - clearRect: function (x, y, w, h) {}, - fillRect: function (x, y, w, h) {}, - strokeRect: function (x, y, w, h) {}, - - beginPath: function () {}, - closePath: function () {}, - moveTo: function (x, y) {}, - lineTo: function (x, y) {}, - quadraticCurveTo: function (cpx, cpy, x, y) {}, - bezierCurveTo: function (cp1x, cp1y, cp2x, cp2y, x, y) {}, - arcTo: function (x1, y1, x2, y2, radius) {}, - rect: function (x, y, w, h) {}, - arc: function (x, y, radius, startAngle, endAngle, anticlockwise) {}, - - fill: function () {}, - stroke: function () {}, - clip: function () {}, - isPointInPath: function (x, y) {}, - drawFocusRing: function (element, xCaret, yCaret, canDrawCustom) {}, - - fillText: function (text, x, y, maxWidth) {}, - strokeText: function (text, x, y, maxWidth) {}, - measureText: function (text) {}, - - drawImage: function (img_elem, dx_or_sx, dy_or_sy, dw_or_sw, dh_or_sh, dx, dy, dw, dh) {}, - - createImageData: function (imagedata_or_sw, sh) - { - var _data = new _image_data(); - _data.length = imagedata_or_sw * sh * 4; - _data.data = (typeof(Uint8Array) != 'undefined') ? new Uint8Array(_data.length) : new Array(_data.length); - return _data; - }, - getImageData: function (sx, sy, sw, sh) {}, - putImageData: function (image_data, dx, dy, dirtyX, dirtyY, dirtyWidth, dirtyHeight) {} -}; - -function native_canvas() -{ - this.id = ""; - this.width = 300; - this.height = 150; - - this.nodeType = 1; -} -native_canvas.prototype = -{ - getContext: function (type) { return (type == "2d") ? new native_context2d(this) : null; }, - toDataUrl: function (type) { return ""; }, - addEventListener: function () {}, - attr: function () {} -}; - -var _null_object = {}; -_null_object.length = 0; -_null_object.nodeType = 1; -_null_object.offsetWidth = 1; -_null_object.offsetHeight = 1; -_null_object.clientWidth = 1; -_null_object.clientHeight = 1; -_null_object.scrollWidth = 1; -_null_object.scrollHeight = 1; -_null_object.style = {}; -_null_object.documentElement = _null_object; -_null_object.body = _null_object; -_null_object.ownerDocument = _null_object; -_null_object.defaultView = _null_object; - -_null_object.addEventListener = function () {}; -_null_object.setAttribute = function () {}; -_null_object.getElementsByTagName = function () { return []; }; -_null_object.appendChild = function () {}; -_null_object.removeChild = function () {}; -_null_object.insertBefore = function () {}; -_null_object.childNodes = []; -_null_object.parent = _null_object; -_null_object.parentNode = _null_object; -_null_object.find = function () { return this; }; -_null_object.appendTo = function () { return this; }; -_null_object.css = function () { return this; }; -_null_object.width = function () { return 0; }; -_null_object.height = function () { return 0; }; -_null_object.attr = function () { return this; }; -_null_object.prop = function () { return this; }; -_null_object.val = function () { return this; }; -_null_object.remove = function () {}; -_null_object.getComputedStyle = function () { return null; }; -_null_object.getContext = function (type) { return (type == "2d") ? new native_context2d(this) : null; }; -_null_object.getBoundingClientRect = function() { return { left : 0, top : 0, right : 0, bottom : 0 }; }; - -document.createElement = function (type) -{ - if (type && type.toLowerCase) - { - if (type.toLowerCase() == "canvas") - return new native_canvas(); - } - - return _null_object; -}; - -function _return_empty_html_element() { return _null_object; } - -document.createDocumentFragment = _return_empty_html_element; -document.getElementsByTagName = function (tag) { return ("head" == tag) ? [_null_object] : []; }; -document.insertBefore = function () {}; -document.appendChild = function () {}; -document.removeChild = function () {}; -document.getElementById = function () { return _null_object; }; -document.createComment = function () { return undefined; }; - -document.documentElement = _null_object; -document.body = _null_object; - -// NATIVE OBJECT -window.native = native; -function GetNativeEngine() { return window.native; } - -var Api = null; // main builder object -window.devicePixelRatio = 1; -if (window.native && window.native.GetDevicePixelRatio) - window.devicePixelRatio = window.native.GetDevicePixelRatio(); - -// OPEN -function NativeOpenFileData(data, version, xlsx_file_path, options) -{ - window.NATIVE_DOCUMENT_TYPE = window.native.GetEditorType(); - Api = null; - - if (options && options["printOptions"] && options["printOptions"]["retina"]) - AscBrowser.isRetina = true; - - var configApi = {}; - if (options && undefined !== options["translate"]) - configApi["translate"] = options["translate"]; - - if (window.NATIVE_DOCUMENT_TYPE === "presentation" || window.NATIVE_DOCUMENT_TYPE === "document") - { - Api = new window["Asc"]["asc_docs_api"](configApi); - if (options && options["documentLayout"] && undefined !== options["documentLayout"]["openedAt"]) - Api.setOpenedAt(options["documentLayout"]["openedAt"]); - } - else - { - Api = new window["Asc"]["spreadsheet_api"](configApi); - } - - if (options && undefined !== options["locale"]) - Api.asc_setLocale(options["locale"]); - - if (window.NATIVE_DOCUMENT_TYPE === "presentation" || window.NATIVE_DOCUMENT_TYPE === "document") - { - Api.asc_nativeOpenFile(data, version); - } - else - { - Api.asc_nativeOpenFile(data, version, undefined, xlsx_file_path); - } -} - -var clearTimeout = window.clearTimeout = function() {}; -var setTimeout = window.setTimeout = function() {}; -var clearInterval = window.clearInterval = function() {}; -var setInterval = window.setInterval = function() {}; - -var console = { - log: function (param) { window.native.ConsoleLog(param); }, - time: function (param) {}, - timeEnd: function (param) {}, - warn: function() {} -}; - -var performance = window.performance = (function(){ - var basePerformanceOffset = Date.now(); - return { - now : function() { return Date.now() - basePerformanceOffset; } - }; -})(); diff --git a/configs/cell.json b/configs/cell.json index f27ae8fe06..070e1b385c 100644 --- a/configs/cell.json +++ b/configs/cell.json @@ -371,24 +371,9 @@ "cell/Local/api.js" ] }, - "mobile_banners": { - "min": [ - "common/Native/Wrappers/memory.js" - ], - "common": [] - }, "mobile": [ "common/libfont/engine/fonts_native.js", - "common/Charts/ChartStyles.js", - - "common/Native/Wrappers/serialize.js", - "common/Native/Wrappers/DrawingStream.js", - "common/Native/Wrappers/ShapeDrawer.js", - - "cell/native/Overlay.js", - "cell/native/Graphics.js", - "cell/native/DrawingDocument.js", - "cell/native/native.js" + "common/Charts/ChartStyles.js" ], "exclude_mobile": [ "vendor/iscroll.js", diff --git a/configs/slide.json b/configs/slide.json index e2de6701db..c69d08ef2d 100644 --- a/configs/slide.json +++ b/configs/slide.json @@ -353,25 +353,9 @@ "slide/Local/api.js" ] }, - "mobile_banners": { - "min": [ - "common/Native/Wrappers/memory.js" - ], - "common": [] - }, "mobile": [ "common/libfont/engine/fonts_native.js", - "common/Charts/ChartStyles.js", - - "common/Native/Wrappers/serialize.js", - "common/Native/Wrappers/DrawingStream.js", - "common/Native/Wrappers/ShapeDrawer.js", - "common/Native/Wrappers/Overlay.js", - - "slide/Native/api.js", - "slide/Native/HtmlPage.js", - "slide/Native/DrawingDocument.js", - "slide/Native/native.js" + "common/Charts/ChartStyles.js" ], "exclude_mobile": [ "vendor/iscroll.js", diff --git a/configs/word.json b/configs/word.json index 6227390734..94508c5468 100644 --- a/configs/word.json +++ b/configs/word.json @@ -388,24 +388,9 @@ "word/Local/api.js" ] }, - "mobile_banners": { - "min": [ - "common/Native/Wrappers/memory.js" - ], - "common": [] - }, "mobile": [ "common/libfont/engine/fonts_native.js", - "common/Charts/ChartStyles.js", - - "common/Native/Wrappers/serialize.js", - "common/Native/Wrappers/DrawingStream.js", - "common/Native/Wrappers/ShapeDrawer.js", - "common/Native/Wrappers/Overlay.js", - - "word/Native/HtmlPage.js", - "word/Native/DrawingDocument.js", - "word/Native/api.js" + "common/Charts/ChartStyles.js" ], "exclude_mobile": [ "vendor/iscroll.js", diff --git a/slide/Native/DrawingDocument.js b/slide/Native/DrawingDocument.js deleted file mode 100644 index d73dfe8bf7..0000000000 --- a/slide/Native/DrawingDocument.js +++ /dev/null @@ -1,1881 +0,0 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2023 - * - * This program is a free software product. You can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License (AGPL) - * version 3 as published by the Free Software Foundation. In accordance with - * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement - * of any third-party rights. - * - * This program is distributed WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ - -"use strict"; - -var FOCUS_OBJECT_THUMBNAILS = 0; -var FOCUS_OBJECT_MAIN = 1; -var FOCUS_OBJECT_NOTES = 2; - -var COMMENT_WIDTH = 18; -var COMMENT_HEIGHT = 16; - -var global_mouseEvent = AscCommon.global_mouseEvent; - - -var THEME_TH_WIDTH = 140; -var THEME_TH_HEIGHT = 112;//THEME_TH_WIDTH*0.8 - -function check_KeyboardEvent(e) -{ - AscCommon.global_keyboardEvent.AltKey = ((e["Flags"] & 0x01) == 0x01); - AscCommon.global_keyboardEvent.CtrlKey = ((e["Flags"] & 0x02) == 0x02); - AscCommon.global_keyboardEvent.ShiftKey = ((e["Flags"] & 0x04) == 0x04); - - AscCommon.global_keyboardEvent.Sender = null; - - AscCommon.global_keyboardEvent.CharCode = e["CharCode"]; - AscCommon.global_keyboardEvent.KeyCode = e["KeyCode"]; - AscCommon.global_keyboardEvent.Which = null; -} -function check_KeyboardEvent_Array(_params, i) -{ - AscCommon.global_keyboardEvent.AltKey = ((_params[i + 1] & 0x01) == 0x01); - AscCommon.global_keyboardEvent.CtrlKey = ((_params[i + 1] & 0x02) == 0x02); - AscCommon.global_keyboardEvent.ShiftKey = ((_params[i + 1] & 0x04) == 0x04); - - AscCommon.global_keyboardEvent.Sender = null; - - AscCommon.global_keyboardEvent.CharCode = _params[i + 3]; - AscCommon.global_keyboardEvent.KeyCode = _params[i + 2]; - AscCommon.global_keyboardEvent.Which = null; -} - -function check_MouseDownEvent(e, isClicks) -{ - global_mouseEvent.X = e["X"]; - global_mouseEvent.Y = e["Y"]; - - global_mouseEvent.AltKey = ((e["Flags"] & 0x01) == 0x01); - global_mouseEvent.CtrlKey = ((e["Flags"] & 0x02) == 0x02); - global_mouseEvent.ShiftKey = ((e["Flags"] & 0x04) == 0x04); - - global_mouseEvent.Type = AscCommon.g_mouse_event_type_down; - global_mouseEvent.Button = e["Button"]; - - global_mouseEvent.Sender = null; - - if (isClicks) - { - global_mouseEvent.ClickCount = e["ClickCount"]; - } - else - { - global_mouseEvent.ClickCount = 1; - } - global_mouseEvent.KoefPixToMM = e["PixToMM"]; - global_mouseEvent.IsLocked = true; -} - -function check_MouseMoveEvent(e) -{ - global_mouseEvent.X = e["X"]; - global_mouseEvent.Y = e["Y"]; - - global_mouseEvent.AltKey = ((e["Flags"] & 0x01) == 0x01); - global_mouseEvent.CtrlKey = ((e["Flags"] & 0x02) == 0x02); - global_mouseEvent.ShiftKey = ((e["Flags"] & 0x04) == 0x04); - - global_mouseEvent.Type = AscCommon.g_mouse_event_type_move; - global_mouseEvent.Button = e["Button"]; - global_mouseEvent.KoefPixToMM = e["PixToMM"]; -} - -function check_MouseUpEvent(e) -{ - global_mouseEvent.X = e["X"]; - global_mouseEvent.Y = e["Y"]; - - global_mouseEvent.AltKey = ((e["Flags"] & 0x01) == 0x01); - global_mouseEvent.CtrlKey = ((e["Flags"] & 0x02) == 0x02); - global_mouseEvent.ShiftKey = ((e["Flags"] & 0x04) == 0x04); - - global_mouseEvent.Type = AscCommon.g_mouse_event_type_up; - global_mouseEvent.Button = e["Button"]; - - global_mouseEvent.Sender = null; - - global_mouseEvent.IsLocked = false; - global_mouseEvent.KoefPixToMM = e["PixToMM"]; -} - - -function CDrawingDocument() -{ - this.IsLockObjectsEnable = false; - - this.m_oWordControl = null; - this.m_oLogicDocument = null; - - this.SlidesCount = 0; - this.IsEmptyPresentation = false; - - this.SlideCurrent = -1; - - this.Native = window["native"]; - - this.m_sLockedCursorType = ""; - - this.UpdateTargetFromPaint = false; - this.TextMatrix = null; - - this.CanvasHitContext = CreateEmbedObject("CHitNativeEmbed"); - - this.TargetCursorColor = {R: 0, G: 0, B: 0}; - - this.TargetPos = {X: 0.0, Y: 0.0, Page: 0}; - - this.LockEvents = false; - - this.AutoShapesTrack = new AscCommon.CAutoshapeTrack(); - - this.m_lCurrentRendererPage = -1; - this.m_oDocRenderer = null; - - this.CollaborativeTargets = []; - this.CollaborativeTargetsUpdateTasks = []; - - this.MathTrack = new AscCommon.CMathTrack(); - - - this.TableStylesLastTheme = null; - this.TableStylesLastColorScheme = null; - this.TableStylesLastColorMap = null; - this.TableStylesLastLook = null; -} - -CDrawingDocument.prototype.Notes_GetWidth = function() -{ - return 100; -}; - -CDrawingDocument.prototype.Notes_OnRecalculate = function() -{ - return 100; -}; - -CDrawingDocument.prototype.RenderPage = function(nPageIndex, bTh, bIsPlayMode) -{ - var _graphics = new CDrawingStream(); - _graphics.IsThumbnail = (!!bTh); - _graphics.IsDemonstrationMode = (!!bIsPlayMode); - _graphics.IsNoDrawingEmptyPlaceholder = (bIsPlayMode || bTh); - this.m_oWordControl.m_oLogicDocument.DrawPage(nPageIndex, _graphics); -}; - -CDrawingDocument.prototype.AfterLoad = function() -{ - this.Api = window.editor; - this.m_oApi = this.Api; - this.m_oApi.DocumentUrl = ""; - this.LogicDocument = window.editor.WordControl.m_oLogicDocument; - this.LogicDocument.DrawingDocument = this; -}; -CDrawingDocument.prototype.Start_CollaborationEditing = function() -{ - this.Native["DD_Start_CollaborationEditing"](); -}; - -CDrawingDocument.prototype.IsMobileVersion = function() -{ - return true; -}; - -CDrawingDocument.prototype.ConvertCoordsToAnotherPage = function(x, y) -{ - return {X: x, Y: y}; -}; - -CDrawingDocument.prototype.SetCursorType = function(sType, Data) -{ - var sResultCursorType = sType; - if ("" === this.m_sLockedCursorType) - { - sResultCursorType = sType; - } - else - sResultCursorType = this.m_sLockedCursorType; - if ( "undefined" === typeof(Data) || null === Data ) - Data = new AscCommon.CMouseMoveData(); - this.Native["DD_SetCursorType"](sResultCursorType, Data); -}; -CDrawingDocument.prototype.LockCursorType = function(sType) -{ - this.m_sLockedCursorType = sType; - - this.Native["DD_LockCursorType"](sType); -}; -CDrawingDocument.prototype.LockCursorTypeCur = function() -{ - this.m_sLockedCursorType = this.Native["DD_LockCursorType"](); -}; -CDrawingDocument.prototype.UnlockCursorType = function() -{ - this.m_sLockedCursorType = ""; - this.Native["DD_UnlockCursorType"](); -}; - -CDrawingDocument.prototype.OnStartRecalculate = function(pageCount) -{ - if(this.LockEvents) - { - return; - } - this.Native["DD_OnStartRecalculate"](pageCount, this.LogicDocument.GetWidthMM(), this.LogicDocument.GetHeightMM()); -}; - -CDrawingDocument.prototype.SetTargetColor = function(r, g, b) -{ - this.Native["DD_SetTargetColor"](r, g, b); -}; - -CDrawingDocument.prototype.StartTrackTable = function() -{}; -// track text (inline) -CDrawingDocument.prototype.StartTrackText = function () -{ -}; -CDrawingDocument.prototype.EndTrackText = function (isOnlyMoveTarget) -{ -}; - -CDrawingDocument.prototype.IsTrackText = function () -{ -}; - -CDrawingDocument.prototype.CancelTrackText = function () -{ -}; - -CDrawingDocument.prototype.OnRecalculatePage = function(index, pageObject) -{ - if(this.LockEvents) - { - return; - } - var l, t, r, b, bIsHidden = !pageObject.isVisible(); - if(index === this.m_oLogicDocument.CurPage) - { - var oBoundsChecker = new AscFormat.CSlideBoundsChecker(); - pageObject.draw(oBoundsChecker); - r = oBoundsChecker.Bounds.max_x; - l = oBoundsChecker.Bounds.min_x; - b = oBoundsChecker.Bounds.max_y; - t = oBoundsChecker.Bounds.min_y; - } - else - { - r = this.m_oLogicDocument.GetWidthMM(); - l = 0.0; - b = this.m_oLogicDocument.GetHeightMM(); - t = 0.0; - } - this.Native["DD_OnRecalculatePage"](index, l, t, r, b, bIsHidden, pageObject.Get_Id()); -}; - -CDrawingDocument.prototype.OnEndRecalculate = function() -{ - this.SlidesCount = this.m_oLogicDocument.Slides.length; - this.SlideCurrent = this.m_oLogicDocument.CurPage; - - if(this.LockEvents) - { - return; - } - this.Native["DD_OnEndRecalculate"](); -}; - -CDrawingDocument.prototype.ChangePageAttack = function(pageIndex) -{ -}; - -CDrawingDocument.prototype.RenderDocument = function(Renderer) -{ - for (var i = 0; i < this.SlidesCount; i++) - { - Renderer.BeginPage(this.m_oLogicDocument.GetWidthMM(), this.m_oLogicDocument.GetHeightMM()); - this.m_oLogicDocument.DrawPage(i, Renderer); - Renderer.EndPage(); - } -}; - -CDrawingDocument.prototype.ToRenderer = function() -{ - var Renderer = new AscCommon.CDocumentRenderer(); - Renderer.IsNoDrawingEmptyPlaceholder = true; - Renderer.VectorMemoryForPrint = new AscCommon.CMemory(); - var old_marks = this.m_oWordControl.m_oApi.ShowParaMarks; - this.m_oWordControl.m_oApi.ShowParaMarks = false; - this.RenderDocument(Renderer); - this.m_oWordControl.m_oApi.ShowParaMarks = old_marks; - var ret = Renderer.Memory.GetBase64Memory(); - - // DEBUG - //console.log(ret); - - return ret; -}; - -CDrawingDocument.prototype.ToRenderer2 = function() -{ - var Renderer = new AscCommon.CDocumentRenderer(); - - var old_marks = this.m_oWordControl.m_oApi.ShowParaMarks; - this.m_oWordControl.m_oApi.ShowParaMarks = false; - - var ret = ""; - for (var i = 0; i < this.SlidesCount; i++) - { - Renderer.BeginPage(this.m_oLogicDocument.GetWidthMM(), this.m_oLogicDocument.GetHeightMM()); - this.m_oLogicDocument.DrawPage(i, Renderer); - Renderer.EndPage(); - - ret += Renderer.Memory.GetBase64Memory(); - Renderer.Memory.Seek(0); - } - - this.m_oWordControl.m_oApi.ShowParaMarks = old_marks; - return ret; -}; - -CDrawingDocument.prototype.ToRendererPart = function(noBase64) -{ - var watermark = this.m_oWordControl.m_oApi.watermarkDraw; - - var pagescount = this.SlidesCount; - - if (-1 == this.m_lCurrentRendererPage) - { - if (watermark) - watermark.StartRenderer(); - - this.m_oDocRenderer = new AscCommon.CDocumentRenderer(); - this.m_oDocRenderer.VectorMemoryForPrint = new AscCommon.CMemory(); - this.m_lCurrentRendererPage = 0; - this.m_bOldShowMarks = this.m_oWordControl.m_oApi.ShowParaMarks; - this.m_oWordControl.m_oApi.ShowParaMarks = false; - this.m_oDocRenderer.IsNoDrawingEmptyPlaceholder = true; - } - - var start = this.m_lCurrentRendererPage; - var end = pagescount - 1; - - var renderer = this.m_oDocRenderer; - renderer.Memory.Seek(0); - renderer.VectorMemoryForPrint.ClearNoAttack(); - - for (var i = start; i <= end; i++) - { - renderer.BeginPage(this.m_oLogicDocument.GetWidthMM(), this.m_oLogicDocument.GetHeightMM()); - this.m_oLogicDocument.DrawPage(i, renderer); - renderer.EndPage(); - - if (watermark) - watermark.DrawOnRenderer(renderer, this.m_oLogicDocument.GetWidthMM(), this.m_oLogicDocument.GetHeightMM()); - } - - if (end == -1) - { - renderer.BeginPage(this.m_oLogicDocument.GetWidthMM(), this.m_oLogicDocument.GetHeightMM()); - renderer.EndPage() - } - - this.m_lCurrentRendererPage = end + 1; - - if (this.m_lCurrentRendererPage >= pagescount) - { - if (watermark) - watermark.EndRenderer(); - - this.m_lCurrentRendererPage = -1; - this.m_oDocRenderer = null; - this.m_oWordControl.m_oApi.ShowParaMarks = this.m_bOldShowMarks; - } - - if (noBase64) { - return renderer.Memory.GetData(); - } else { - return renderer.Memory.GetBase64Memory(); - } -}; - - -CDrawingDocument.prototype.InitGuiCanvasTextProps = function(div_id) -{ - -}; - -CDrawingDocument.prototype.DrawGuiCanvasTextProps = function(props) -{ - -}; - -CDrawingDocument.prototype.DrawSearch = function(overlay) -{ -}; - -CDrawingDocument.prototype.DrawSearchCur = function(overlay, place) -{ -}; - -CDrawingDocument.prototype.StopRenderingPage = function(pageIndex) -{ - -}; - -CDrawingDocument.prototype.ClearCachePages = function() -{ - this.Native["DD_ClearCachePages"](); -}; - -CDrawingDocument.prototype.FirePaint = function() -{ - this.Native["DD_FirePaint"](); -}; - - - -CDrawingDocument.prototype.ConvertCoordsFromCursor2 = function(x, y) -{ - return this.Native["DD_ConvertCoordsFromCursor2"](); -}; - -CDrawingDocument.prototype.IsCursorInTableCur = function(x, y, page) -{ - - return false; -}; - -CDrawingDocument.prototype.ConvertCoordsToCursorWR = function(x, y, pageIndex, transform) -{ - var m11, m22, m12, m21, tx, ty, _page_index; - if(transform) - { - m11 = transform.sx; - m22 = transform.sy; - m12 = transform.shx; - m21 = transform.shy; - tx = transform.tx; - ty = transform.ty; - } - else - { - m11 = 1.0; - m22 = 1.0; - m12 = 0.0; - m21 = 0.0; - tx = 0.0; - ty = 0.0; - } - if(AscFormat.isRealNumber(pageIndex)) - { - _page_index = pageIndex; - } - else - { - _page_index = 0; - } - return this.Native["DD_ConvertCoordsToCursor"](x, y, _page_index, m11, m21, m12, m22, tx, ty); -}; - -CDrawingDocument.prototype.ConvertCoordsToCursorWR_Comment = function(x, y) -{ - return this.Native["DD_ConvertCoordsToCursorWR_Comment"](); -}; - -CDrawingDocument.prototype.ConvertCoordsToCursor = function(x, y) -{ - return this.Native["DD_ConvertCoordsToCursor"](x, y, 0); -}; - -CDrawingDocument.prototype.TargetStart = function() -{ - return this.Native["DD_TargetStart"](); -}; -CDrawingDocument.prototype.TargetEnd = function() -{ - return this.Native["DD_TargetEnd"](); -}; -CDrawingDocument.prototype.UpdateTargetNoAttack = function() -{ -}; - -CDrawingDocument.prototype.CheckTargetDraw = function(x, y) -{ - return this.Native["DD_CheckTargetDraw"](x, y); -}; - -CDrawingDocument.prototype.UpdateTarget = function(x, y, pageIndex) -{ - this.TargetPos.X = x; - this.TargetPos.Y = y; - this.TargetPos.Page = pageIndex; - return this.Native["DD_UpdateTarget"](x, y, pageIndex); -}; - -CDrawingDocument.prototype.SetTargetSize = function(size) -{ - return this.Native["DD_SetTargetSize"](size); -}; -CDrawingDocument.prototype.DrawTarget = function() -{ - return this.Native["DD_DrawTarget"](); -}; -CDrawingDocument.prototype.TargetShow = function() -{ - return this.Native["DD_TargetShow"](); -}; -CDrawingDocument.prototype.CheckTargetShow = function() -{ - return this.Native["DD_CheckTargetShow"](); -}; - -CDrawingDocument.prototype.SetCurrentPage = function(PageIndex) -{ - return this.Native["DD_SetCurrentPage"](PageIndex); -}; - -CDrawingDocument.prototype.SelectEnabled = function(bIsEnabled) -{ - this.m_bIsSelection = bIsEnabled; - if (false === this.m_bIsSelection) - { - this.SelectClear(); -// //this.m_oWordControl.CheckUnShowOverlay(); -// //this.drawingObjects.OnUpdateOverlay(); -// this.drawingObjects.getOverlay().m_oContext.globalAlpha = 1.0; - } - //return this.Native["DD_SelectEnabled"](bIsEnabled); -}; -CDrawingDocument.prototype.SelectClear = function() -{ - if (!this.SelectClearLock) - { - this.SelectDrag = -1; - this.SelectRect1 = null; - this.SelectRect2 = null; - } - return this.Native["DD_SelectClear"](); -}; -CDrawingDocument.prototype.SearchClear = function() -{ - return this.Native["DD_SearchClear"](); -}; -CDrawingDocument.prototype.AddPageSearch = function(findText, rects) -{ - return this.Native["DD_AddPageSearch"](findText, rects); -}; - -CDrawingDocument.prototype.StartSearch = function() -{ - this.Native["DD_StartSearch"](); -}; -CDrawingDocument.prototype.EndSearch = function(bIsChange) -{ - this.Native["DD_EndSearch"](bIsChange); -}; -CDrawingDocument.prototype.AddPageSelection = function(pageIndex, x, y, width, height) -{ - this.Native["DD_AddPageSelection"](pageIndex, x, y, width, height); -}; -CDrawingDocument.prototype.SelectShow = function() -{ - this.m_oWordControl.OnUpdateOverlay(); -}; - -CDrawingDocument.prototype.Set_RulerState_Table = function(markup, transform) -{ - this.Native["DD_Set_RulerState_Table"](markup, transform); -}; - -CDrawingDocument.prototype.Set_RulerState_Paragraph = function(obj, margins) -{ - this.Native["DD_Set_RulerState_Paragraph"](obj, margins); -}; - -CDrawingDocument.prototype.Update_MathTrack = function (IsActive, IsContentActive, oMath) -{ - //TODO: Implement -}; - -CDrawingDocument.prototype.Update_ParaTab = function(Default_Tab, ParaTabs) -{ - this.Native["DD_Update_ParaTab"](Default_Tab, ParaTabs); -}; - -CDrawingDocument.prototype.UpdateTableRuler = function(isCols, index, position) -{ - this.Native["DD_UpdateTableRuler"](isCols, index, position); -}; -CDrawingDocument.prototype.GetDotsPerMM = function(value) -{ - return this.Native["DD_GetDotsPerMM"](value); -}; - -CDrawingDocument.prototype.GetMMPerDot = function(value) -{ - return value / this.GetDotsPerMM( 1 ); -}; -CDrawingDocument.prototype.GetVisibleMMHeight = function() -{ - return this.Native["DD_GetVisibleMMHeight"](); -}; - -// вот оооочень важная функция. она выкидывает из кэша неиспользуемые шрифты -CDrawingDocument.prototype.CheckFontCache = function() -{ - return this.Native["DD_CheckFontCache"](); -}; - -CDrawingDocument.prototype.CheckFontNeeds = function() -{ - this.m_oWordControl.m_oLogicDocument.Fonts = []; -}; - -CDrawingDocument.prototype.CorrectRulerPosition = function(pos) -{ - return this.Native["DD_CorrectRulerPosition"](pos); -}; - -// вот здесь весь трекинг -CDrawingDocument.prototype.DrawTrack = function(type, matrix, left, top, width, height, isLine, canRotate, isNoMove, isDrawHandles) -{ - this.AutoShapesTrack.DrawTrack(type, matrix, left, top, width, height, isLine, canRotate, isNoMove, isDrawHandles); -}; - -CDrawingDocument.prototype.LockSlide = function(slideNum) -{ - //this.Native["DD_LockSlide"](slideNum); -}; - -CDrawingDocument.prototype.UnLockSlide = function(slideNum) -{ - //this.Native["DD_UnLockSlide"](slideNum); -}; - -CDrawingDocument.prototype.DrawTrackSelectShapes = function(x, y, w, h) -{ - this.AutoShapesTrack.DrawTrackSelectShapes(x, y, w, h); -}; - -CDrawingDocument.prototype.DrawAdjustment = function(matrix, x, y, bTextWarp) -{ - this.AutoShapesTrack.DrawAdjustment(matrix, x, y, bTextWarp); -}; - -CDrawingDocument.prototype.DrawMathTrack = function (overlay) -{ - //TODO: Implement -}; - -// cursor -CDrawingDocument.prototype.UpdateTargetTransform = function(matrix) -{ - if (matrix) - { - if (null == this.TextMatrix) - this.TextMatrix = new AscCommon.CMatrix(); - this.TextMatrix.sx = matrix.sx; - this.TextMatrix.shy = matrix.shy; - this.TextMatrix.shx = matrix.shx; - this.TextMatrix.sy = matrix.sy; - this.TextMatrix.tx = matrix.tx; - this.TextMatrix.ty = matrix.ty; - - this.Native["DD_UpdateTargetTransform"](matrix.sx, matrix.shy, matrix.shx, matrix.sy, matrix.tx, matrix.ty); - } - else - { - this.TextMatrix = null; - this.Native["DD_RemoveTargetTransform"](); - } -}; - -CDrawingDocument.prototype.UpdateThumbnailsAttack = function() -{ - var aSlides = this.m_oWordControl.m_oLogicDocument.Slides; - var DrawingDocument = this.m_oWordControl.m_oLogicDocument.DrawingDocument; - DrawingDocument.OnStartRecalculate(aSlides.length); - if(this.LockEvents !== true) - { - for(var i = 0; i < aSlides.length; ++i) - { - var oSlide = aSlides[i]; - this.Native["DD_UpdateThumbnailAttack"](i, oSlide.Id, !oSlide.isVisible()); - } - } - DrawingDocument.OnEndRecalculate(); -}; - -CDrawingDocument.prototype.CheckGuiControlColors = function(bIsAttack) -{ - var _slide = null; - var _layout = null; - var _master = null; - - // потом реализовать проверку на то, что нужно ли посылать - if (-1 != this.SlideCurrent) - { - _slide = this.m_oWordControl.m_oLogicDocument.Slides[this.SlideCurrent]; - if(!_slide){ - return; - } - if( this.m_oWordControl.m_oLogicDocument.FocusOnNotes){ - if(!_slide.notes){ - return; - } - _master = _slide.notes.Master; - } - else{ - _layout = _slide.Layout; - _master = _layout.Master; - } - } - else if ((0 < this.m_oWordControl.m_oLogicDocument.slideMasters.length) && - (0 < this.m_oWordControl.m_oLogicDocument.slideMasters[0].sldLayoutLst.length)) - { - _layout = this.m_oWordControl.m_oLogicDocument.slideMasters[0].sldLayoutLst[0]; - _master = this.m_oWordControl.m_oLogicDocument.slideMasters[0]; - } - else - { - return; - } - - var arr_colors = new Array(10); - - var _theme = _master.Theme; - var rgba = {R : 0, G : 0, B : 0, A : 255}; - // bg1,tx1,bg2,tx2,accent1 - accent6 - var array_colors_types = [6, 15, 7, 16, 0, 1, 2, 3, 4, 5]; - var _count = array_colors_types.length; - - var color = new AscFormat.CUniColor(); - color.color = new AscFormat.CSchemeColor(); - for (var i = 0; i < _count; ++i) - { - color.color.id = array_colors_types[i]; - color.Calculate(_theme, _slide, _layout, _master, rgba); - - var _rgba = color.RGBA; - arr_colors[i] = new Asc.asc_CColor(_rgba.R, _rgba.G, _rgba.B); - arr_colors[i].setColorSchemeId(color.color.id); - } - - // теперь проверим - var bIsSend = false; - if (this.GuiControlColorsMap != null) - { - for (var i = 0; i < _count; ++i) - { - var _color1 = this.GuiControlColorsMap[i]; - var _color2 = arr_colors[i]; - - if ((_color1.r != _color2.r) || (_color1.g != _color2.g) || (_color1.b != _color2.b)) - { - bIsSend = true; - break; - } - } - } - else - { - this.GuiControlColorsMap = new Array(_count); - bIsSend = true; - } - - if (bIsSend || (bIsAttack === true)) - { - for (var i = 0; i < _count; ++i) - { - this.GuiControlColorsMap[i] = arr_colors[i]; - } - - this.SendControlColors(bIsAttack); - } -}; - -CDrawingDocument.prototype.SendControlColors = function(bIsAttack) -{ - let standart_colors = null; - if (!this.IsSendStandartColors || (bIsAttack === true)) - { - let standartColors = AscCommon.g_oStandartColors; - let _c_s = standartColors.length; - standart_colors = new Array(_c_s); - - for (let i = 0; i < _c_s; ++i) - { - standart_colors[i] = new Asc.asc_CColor(standartColors[i].R, standartColors[i].G, standartColors[i].B); - } - - this.IsSendStandartColors = true; - } - - let _count = this.GuiControlColorsMap.length; - - let _ret_array = new Array(_count * 6); - let _cur_index = 0; - - let array_colors_types = [6, 15, 7, 16, 0, 1, 2, 3, 4, 5]; - for (let i = 0; i < _count; ++i) - { - let _color_src = this.GuiControlColorsMap[i]; - - _ret_array[_cur_index] = new Asc.asc_CColor(_color_src.r, _color_src.g, _color_src.b); - _ret_array[_cur_index].setColorSchemeId(array_colors_types[i]); - _cur_index++; - - // теперь с модификаторами - let _count_mods = 5; - for (let j = 0; j < _count_mods; ++j) - { - let dst_mods = new AscFormat.CColorModifiers(); - dst_mods.Mods = AscCommon.GetDefaultMods(_color_src.r, _color_src.g, _color_src.b, j + 1, 0); - - let _rgba = {R : _color_src.r, G : _color_src.g, B : _color_src.b, A : 255}; - dst_mods.Apply(_rgba); - - let oColor = new Asc.asc_CColor(_rgba.R, _rgba.G, _rgba.B); - oColor.put_effectValue(dst_mods.getEffectValue()); - oColor.setColorSchemeId(array_colors_types[i]); - _ret_array[_cur_index] = oColor; - _cur_index++; - } - } - - this.m_oWordControl.m_oApi.sync_SendThemeColors(_ret_array, standart_colors); -}; - -CDrawingDocument.prototype.DrawImageTextureFillShape = function(url) -{ -}; - -CDrawingDocument.prototype.DrawImageTextureFillSlide = function(url) -{ -}; - - - -CDrawingDocument.prototype.DrawImageTextureFillTextArt = function(url) -{ -}; - -CDrawingDocument.prototype.InitGuiCanvasShape = function(div_id) -{ -}; - -CDrawingDocument.prototype.InitGuiCanvasSlide = function(div_id) -{ -}; - -CDrawingDocument.prototype.InitGuiCanvasTextArt = function(div_id) -{ -}; - -CDrawingDocument.prototype.CheckTableStyles = function(oTableLook) -{ - var logicDoc = this.m_oWordControl.m_oLogicDocument; - var isChanged = logicDoc.CheckNeedUpdateTableStyles(oTableLook); - if(!isChanged) - { - return; - } - var oPreviewGenerator = new AscCommon.CTableStylesPreviewGenerator(logicDoc); - var dScale = 2;//TODO - var page_w_mm = 297; - var page_h_mm = 210; - var page_w_px = TABLE_STYLE_WIDTH_PIX; - var page_h_px = TABLE_STYLE_HEIGHT_PIX; - var oStream = global_memory_stream_menu; - var oGraphics = new CDrawingStream(); - var oNative = this.Native; - oPreviewGenerator.GetAllPreviewsNative(false, oGraphics, oStream, oNative, page_w_mm, page_h_mm, page_w_px, page_h_px); -}; -CDrawingDocument.prototype.CheckTableStylesDefault = function () -{ - var tableLook = this.GetTableLook(true); - return this.CheckTableStyles(tableLook); -}; -CDrawingDocument.prototype.GetTableStylesPreviews = function(bUseDefault) -{ - return []; -}; -CDrawingDocument.prototype.GetTableLook = function(isDefault) -{ - let oTableLook; - - if (isDefault) - { - oTableLook = new AscCommon.CTableLook(); - oTableLook.SetDefault(); - } - else - { - oTableLook = this.TableStylesLastLook; - } - - return oTableLook; -}; - -CDrawingDocument.prototype.GetTableStylesPreviews = function() -{ - return []; -}; - -CDrawingDocument.prototype.CheckThemes = function(){ - - window["native"]["ClearCacheThemeThumbnails"](); - var logicDoc = this.m_oWordControl.m_oLogicDocument; - var _dst_styles = []; - - // NOTE: need check - - var page_w_mm = THEME_TH_WIDTH * 2.54 / (72.0 / 96.0); - var page_h_mm = THEME_TH_HEIGHT * 2.54 / (72.0 / 96.0); - var page_w_px = THEME_TH_WIDTH * 3; - var page_h_px = THEME_TH_HEIGHT * 3; - - var stream = global_memory_stream_menu; - var graphics = new CDrawingStream(); - var thDrawer = new CMasterThumbnailDrawer(); - thDrawer.DrawingDocument = this; - - this.Native["DD_PrepareNativeDraw"](); - - AscCommon.History.TurnOff(); - AscCommon.g_oTableId.m_bTurnOff = true; - - for (var i = 0; i < logicDoc.slideMasters.length; i++) - { - var oMaster = logicDoc.slideMasters[i]; - if(oMaster.ThemeIndex < 0){ - var oTheme = oMaster.Theme; - this.Native["DD_StartNativeDraw"](page_w_px, page_h_px, page_w_mm, page_h_mm); - thDrawer.WidthMM = page_w_mm; - thDrawer.HeightMM = page_h_mm; - thDrawer.WidthPx = page_w_px; - thDrawer.HeightPx = page_h_px; - var oldW = oMaster.Width; - var oldH = oMaster.Height; - var oLayout = null; - oMaster.changeSize(page_w_mm, page_h_mm); - oMaster.recalculate(); - - for (var j = 0; j < oMaster.sldLayoutLst.length; j++) { - if (oMaster.sldLayoutLst[j].type == AscFormat.nSldLtTTitle) { - oLayout = oMaster.sldLayoutLst[j]; - break; - } - } - if(oLayout){ - oLayout.changeSize(page_w_mm, page_h_mm); - oLayout.recalculate(); - } - - thDrawer.Draw(graphics, oMaster, undefined, undefined); - oMaster.changeSize(oldW, oldH); - oMaster.recalculate(); - if(oLayout){ - oLayout.changeSize(oldW, oldH); - oLayout.recalculate(); - } - - stream["ClearNoAttack"](); - stream["WriteByte"](6); - stream["WriteLong"](oMaster.ThemeIndex); - var sThemeName = typeof oTheme.name === "string" && oTheme.name.length > 0 ? oTheme.name : "Doc theme " + (i + 1); - stream["WriteString2"](sThemeName); - - this.Native["DD_EndNativeDraw"](stream); - graphics.ClearParams(); - } - } - - AscCommon.g_oTableId.m_bTurnOff = false; - AscCommon.History.TurnOn(); - - stream["ClearNoAttack"](); - stream["WriteByte"](7); - - this.Native["DD_EndNativeDraw"](stream); - - - - var _masters = logicDoc.slideMasters; - var aDocumentThemes = logicDoc.Api.ThemeLoader.Themes.DocumentThemes; - var aThemeInfo = logicDoc.Api.ThemeLoader.themes_info_document; - aDocumentThemes.length = 0; - aThemeInfo.length = 0; - for (var i = 0; i < _masters.length; i++) - { - if (_masters[i].ThemeIndex < 0)//только темы презентации - { - var theme_load_info = new AscCommonSlide.CThemeLoadInfo(); - theme_load_info.Master = _masters[i]; - theme_load_info.Theme = _masters[i].Theme; - var _lay_cnt = _masters[i].sldLayoutLst.length; - for (var j = 0; j < _lay_cnt; j++) - { - theme_load_info.Layouts[j] = _masters[i].sldLayoutLst[j]; - } - var th_info = {}; - th_info.Name = "Doc Theme " + i; - th_info.Url = ""; - th_info.Thumbnail = _masters[i].ImageBase64; - var th = new AscCommonSlide.CAscThemeInfo(th_info); - aDocumentThemes[aDocumentThemes.length] = th; - th.Index = -logicDoc.Api.ThemeLoader.Themes.DocumentThemes.length; - aThemeInfo[aDocumentThemes.length - 1] = theme_load_info; - } - } - - -}; - -CDrawingDocument.prototype.CheckLayouts = function(oMaster){ - - window["native"]["ClearCacheLayoutThumbnails"](); - var logicDoc = this.m_oWordControl.m_oLogicDocument; - var _dst_styles = []; - - // NOTE: need check - - var page_w_mm = logicDoc.GetWidthMM();//THEME_TH_WIDTH * 2.54 / (72.0 / 96.0); - var page_h_mm = logicDoc.GetHeightMM();//THEME_TH_HEIGHT * 2.54 / (72.0 / 96.0); - var page_w_px = THEME_TH_WIDTH * 2; - var page_h_px = THEME_TH_HEIGHT * 2; - - var stream = global_memory_stream_menu; - var graphics = new CDrawingStream(); - var thDrawer = new CLayoutThumbnailDrawer(); - thDrawer.DrawingDocument = this; - - this.Native["DD_PrepareNativeDraw"](); - - AscCommon.History.TurnOff(); - AscCommon.g_oTableId.m_bTurnOff = true; - - for (var i = 0; i < oMaster.sldLayoutLst.length; i++) - { - var oLayout = oMaster.sldLayoutLst[i]; - this.Native["DD_StartNativeDraw"](page_w_px, page_h_px, page_w_mm, page_h_mm); - thDrawer.WidthMM = page_w_mm; - thDrawer.HeightMM = page_h_mm; - thDrawer.WidthPx = page_w_px; - thDrawer.HeightPx = page_h_px; - - graphics.init(null, page_w_px, page_h_px, page_w_px, page_h_px); - graphics.CalculateFullTransform(); - thDrawer.Draw(graphics, oLayout, undefined, undefined, undefined); - stream["ClearNoAttack"](); - stream["WriteByte"](8); - stream["WriteLong"](i); - var sLayoutName = typeof oLayout.cSld.name === "string" && oLayout.cSld.name.length > 0 ? oLayout.cSld.name : "Layout " + (i + 1); - stream["WriteString2"](sLayoutName); - - this.Native["DD_EndNativeDraw"](stream); - graphics.ClearParams(); - } - - AscCommon.g_oTableId.m_bTurnOff = false; - AscCommon.History.TurnOn(); - - stream["ClearNoAttack"](); - stream["WriteByte"](9); - - this.Native["DD_EndNativeDraw"](stream); -}; - -CDrawingDocument.prototype.OnSelectEnd = function() -{ -}; - -CDrawingDocument.prototype.GetCommentWidth = function(type) -{ -}; - -CDrawingDocument.prototype.GetCommentHeight = function(type) -{ -}; - -CDrawingDocument.prototype.GetMouseMoveCoords = function() -{ - return {X: global_mouseEvent.X, Y: global_mouseEvent.Y, Page: this.LogicDocument.CurPage}; -}; - -CDrawingDocument.prototype.StartUpdateOverlay = function() -{ - this.IsUpdateOverlayOnlyEnd = true; -}; - -CDrawingDocument.prototype.EndUpdateOverlay = function() -{ - if (this.IsUpdateOverlayOnlyEndReturn) - return; - - this.IsUpdateOverlayOnlyEnd = false; - if (this.IsUpdateOverlayOnEndCheck) - this.m_oWordControl.OnUpdateOverlay(); - - this.IsUpdateOverlayOnEndCheck = false; -}; - -CDrawingDocument.prototype.OnMouseDown = function(e) -{ - check_MouseDownEvent(e, true); - - // у Илюхи есть проблема при вводе с клавы, пока нажата кнопка мыши - if ((0 == global_mouseEvent.Button) || (undefined == global_mouseEvent.Button)) - this.m_bIsMouseLock = true; - - this.StartUpdateOverlay(); - - if ((0 == global_mouseEvent.Button) || (undefined == global_mouseEvent.Button)) - { - var pos = {X: global_mouseEvent.X, Y: global_mouseEvent.Y, Page: this.LogicDocument.CurPage}; - - // if (pos.Page == -1) - // { - // this.EndUpdateOverlay(); - // return; - // } - - // if (this.IsFreezePage(pos.Page)) - // { - // this.EndUpdateOverlay(); - // return; - // } - - // теперь проверить трек таблиц - /* - var ret = this.Native["checkMouseDown_Drawing"](pos.X, pos.Y, pos.Page); - if (ret === true) - return; - */ - // var is_drawing = this.checkMouseDown_Drawing(pos); - // if (is_drawing === true) { - // return; - // } - - //this.Native["DD_NeedScrollToTargetFlag"](true); - this.LogicDocumentOnMouseDown(global_mouseEvent, pos.X, pos.Y, pos.Page); - //this.Native["DD_NeedScrollToTargetFlag"](false); - } - - //this.Native["DD_CheckTimerScroll"](true); - this.EndUpdateOverlay(); -}; - -CDrawingDocument.prototype.OnMouseMove = function(e) - { - check_MouseMoveEvent(e); - - var pos = this.GetMouseMoveCoords(); - if (pos.Page == -1) - return; - - // if (this.IsFreezePage(pos.Page)) - // return; - - // if (this.m_sLockedCursorType != "") - // this.SetCursorType("default"); - - this.StartUpdateOverlay(); - - /* - var is_drawing = this.Native["checkMouseMove_Drawing"](pos.X, pos.Y, pos.Page); - if (is_drawing === true) - return; - */ - // var is_drawing = this.checkMouseMove_Drawing(pos); - // if (is_drawing === true) - // return; - - //this.TableOutlineDr.bIsNoTable = true; - - if (this.SelectDrag == 1 || this.SelectDrag == 2) - { - var oController = this.LogicDocument.GetCurrentController(); - if(oController) - { - this.SelectClearLock = true; - var oTargetTextObject = AscFormat.getTargetTextObject(oController); - if(oTargetTextObject){ - var _oldShift = global_mouseEvent.ShiftKey; - global_mouseEvent.ShiftKey = true; - oTargetTextObject.selectionSetStart(global_mouseEvent, pos.X, pos.Y, 0); - oTargetTextObject.selectionSetEnd(global_mouseEvent, pos.X, pos.Y, 0); - global_mouseEvent.ShiftKey = _oldShift; - this.LogicDocument.Document_UpdateSelectionState(); - this.m_oWordControl.OnUpdateOverlay(); - } - this.SelectClearLock = false; - } - } - else - { - this.LogicDocument.OnMouseMove(global_mouseEvent, pos.X, pos.Y, pos.Page); - } - - this.EndUpdateOverlay(); - }; - - - CDrawingDocument.prototype.OnMouseUp = function(e) - { - check_MouseUpEvent(e); - - var pos = this.GetMouseMoveCoords(); - var _is_select = false; - if (this.SelectDrag == 1 || this.SelectDrag == 2) - { - _is_select = true; - } - this.SelectDrag = -1; - - if (pos.Page == -1) - return this.CheckReturnMouseUp(); - - // if (this.IsFreezePage(pos.Page)) - // return this.CheckReturnMouseUp(); - - // this.UnlockCursorType(); - - this.StartUpdateOverlay(); - - // восстанавливаем фокус - this.m_bIsMouseLock = false; - - /* - var is_drawing = this.Native["checkMouseUp_Drawing"](pos.X, pos.Y, pos.Page); - if (is_drawing === true) - return; - */ - // var is_drawing = this.checkMouseUp_Drawing(pos); - // if (is_drawing === true) - // return this.CheckReturnMouseUp(); - - // this.Native["DD_CheckTimerScroll"](false); - - // this.Native.m_bIsMouseUpSend = true; - - // this.Native["DD_NeedScrollToTargetFlag"](true); - - if (_is_select) - { - var oController = this.LogicDocument.GetCurrentController(); - if(oController) - { - this.SelectClearLock = true; - var oTargetTextObject = AscFormat.getTargetTextObject(oController); - if(oTargetTextObject){ - var _oldShift = global_mouseEvent.ShiftKey; - global_mouseEvent.ShiftKey = true; - oTargetTextObject.selectionSetStart(global_mouseEvent, pos.X, pos.Y, 0); - oTargetTextObject.selectionSetEnd(global_mouseEvent, pos.X, pos.Y, 0); - global_mouseEvent.ShiftKey = _oldShift; - this.LogicDocument.Document_UpdateSelectionState(); - this.m_oWordControl.OnUpdateOverlay(); - } - this.SelectClearLock = false; - } - } - else - { - this.LogicDocumentOnMouseUp(global_mouseEvent, pos.X, pos.Y, pos.Page); - this.LogicDocument.Document_UpdateSelectionState(); - this.m_oWordControl.OnUpdateOverlay(); - } - // this.Native["DD_NeedScrollToTargetFlag"](false); - - // this.Native.m_bIsMouseUpSend = false; - this.LogicDocument.Document_UpdateInterfaceState(); - this.LogicDocument.Document_UpdateRulersState(); - - this.EndUpdateOverlay(); - return this.CheckReturnMouseUp(); - }; - - - - -CDrawingDocument.prototype.CheckReturnMouseUp = function() - { - // return: array - // first: type (0 - none, 1 - onlytarget, 2 - select, 3 - tracks) - // type = 0: none - // type = 1: (double)x, (double)y, (int)page, [option: transform (6 double values)] - // type = 2: (double)x1, (double)y1, (int)page1, (double)x2, (double)y2, (int)page2, [option: transform (6 double values)] - // type = 3: (double)x, (double)y, (double)w, (double)h, (int)page, [option: transform (6 double values)] - - - var _ret = []; - _ret.push(0); - - this.SelectRect1 = null; - this.SelectRect2 = null; - - var oController = this.m_oLogicDocument.GetCurrentController(); - - - - var oTargetContent = oController.getTargetDocContent(); - - if(oTargetContent) - { - var _target = oTargetContent.IsSelectionUse(); - var oTextTransform = oTargetContent.Get_ParentTextTransform(); - if (_target === false) - { - _ret[0] = 1; - - _ret.push(this.TargetPos.X); - _ret.push(this.TargetPos.Y); - _ret.push(this.TargetPos.Page); - - if (oTextTransform && !oTextTransform.IsIdentity()) - { - _ret.push(oTextTransform.sx); - _ret.push(oTextTransform.shy); - _ret.push(oTextTransform.shx); - _ret.push(oTextTransform.sy); - _ret.push(oTextTransform.tx); - _ret.push(oTextTransform.ty); - } - - return _ret; - } - - var _select = oTargetContent.GetSelectionBounds(); - if (_select) - { - - _ret[0] = 2; - var _rect1 = _select.Start; - var _rect2 = _select.End; - this.SelectRect1 = _rect1; - this.SelectRect2 = _rect2; - - var _x1 = _rect1.X; - var _y1 = _rect1.Y; - var _y11 = _rect1.Y + _rect2.H; - var _x2 = _rect2.X + _rect2.W; - var _y2 = _rect2.Y; - var _y22 = _rect2.Y + _rect2.Y; - - var _eps = 0.0001; - if (Math.abs(_x1 - _x2) < _eps && - Math.abs(_y1 - _y2) < _eps && - Math.abs(_y11 - _y22) < _eps) - { - _ret[0] = 0; - - } - else - { - _ret.push(_select.Start.X); - _ret.push(_select.Start.Y); - _ret.push(_select.Start.Page); - _ret.push(_select.End.X + _select.End.W); - _ret.push(_select.End.Y + _select.End.H); - _ret.push(_select.End.Page); - - if (oTextTransform && !oTextTransform.IsIdentity()) - { - - _ret.push(oTextTransform.sx); - _ret.push(oTextTransform.shy); - _ret.push(oTextTransform.shx); - _ret.push(oTextTransform.sy); - _ret.push(oTextTransform.tx); - _ret.push(oTextTransform.ty); - } - - return _ret; - } - } - } - - var _object_bounds = oController.getSelectedObjectsBounds(); - if (_object_bounds) - { - - _ret[0] = 3; - _ret.push(_object_bounds.minX); - _ret.push(_object_bounds.minY); - _ret.push(_object_bounds.maxX); - _ret.push(_object_bounds.maxY); - _ret.push(_object_bounds.pageIndex); - - return _ret; - } - - - return _ret; - }; - - CDrawingDocument.prototype.EndTrackTable = function() - {}; - -// collaborative targets -CDrawingDocument.prototype.Collaborative_UpdateTarget = function (_id, _shortId, _x, _y, _size, _page, _transform, is_from_paint) - { - if (is_from_paint !== true) - { - this.CollaborativeTargetsUpdateTasks.push([_id, _shortId, _x, _y, _size, _page, _transform]); - this.m_oWordControl.OnUpdateOverlay(); - this.m_oWordControl.EndUpdateOverlay(); - return; - } - else - { - var color = AscCommon.getUserColorById(_shortId, null, true); - - if (null != _transform) { - this.Native["collaborativeUpdateTarget"](_id, _shortId, _x, _y, _size, _page, - _transform.sx, _transform.shy, _transform.shx, _transform.sy, _transform.tx, _transform.ty, - color.r, color.g, color.b - ); - } else { - this.Native["collaborativeUpdateTarget"](_id, _shortId, _x, _y, _size, _page, - 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, - color.r, color.g, color.b - ); - } - } - - for (var i = 0; i < this.CollaborativeTargets.length; i++) - { - if (_id == this.CollaborativeTargets[i].Id) - { - this.CollaborativeTargets[i].CheckPosition(_x, _y, _size, _page, _transform); - return; - } - } - var _target = new CDrawingCollaborativeTarget(this); - _target.Id = _id; - _target.ShortId = _shortId; - _target.CheckPosition(_x, _y, _size, _page, _transform); - this.CollaborativeTargets[this.CollaborativeTargets.length] = _target; - }; - CDrawingDocument.prototype.Collaborative_RemoveTarget = function (_id) - { - this.Native["collaborativeRemoveTarget"](_id); - - for (var i = 0; i < this.CollaborativeTargets.length; i++) - { - if (_id == this.CollaborativeTargets[i].Id) - { - this.CollaborativeTargets[i].Remove(this); - this.CollaborativeTargets.splice(i, 1); - } - } - - this.m_oWordControl.OnUpdateOverlay(); - this.m_oWordControl.EndUpdateOverlay(); - }; - CDrawingDocument.prototype.Collaborative_TargetsUpdate = function (bIsChangePosition) - { - var _len_tasks = this.CollaborativeTargetsUpdateTasks.length; - var i = 0; - for (i = 0; i < _len_tasks; i++) - { - var _tmp = this.CollaborativeTargetsUpdateTasks[i]; - this.Collaborative_UpdateTarget(_tmp[0], _tmp[1], _tmp[2], _tmp[3], _tmp[4], _tmp[5], _tmp[6], true); - } - if (_len_tasks != 0) - this.CollaborativeTargetsUpdateTasks.splice(0, _len_tasks); - - if (bIsChangePosition) - { - for (i = 0; i < this.CollaborativeTargets.length; i++) - { - this.CollaborativeTargets[i].Update(this); - } - } - }; - CDrawingDocument.prototype.Collaborative_GetTargetPosition = function (UserId) - { - for (var i = 0; i < this.CollaborativeTargets.length; i++) - { - if (UserId == this.CollaborativeTargets[i].Id) - return {X: this.CollaborativeTargets[i].HtmlElementX, Y: this.CollaborativeTargets[i].HtmlElementY}; - } - - return null; - }; - -CDrawingDocument.prototype.DrawHorAnchor = function(pageIndex, x) -{ -}; -CDrawingDocument.prototype.DrawVerAnchor = function(pageIndex, y) -{ -}; - -CDrawingDocument.prototype.CheckSelectMobile = function() -{ - this.SelectRect1 = null; - this.SelectRect2 = null; - - var _select = this.LogicDocument.GetSelectionBounds(); - if (!_select) - return; - - var _rect1 = _select.Start; - var _rect2 = _select.End; - - if (!_rect1 || !_rect2) - return; - - this.SelectRect1 = _rect1; - this.SelectRect2 = _rect2; - - this.Native["DD_DrawMobileSelection"](_rect1.X, _rect1.Y, _rect1.W, _rect1.H, _rect1.Page, - _rect2.X, _rect2.Y, _rect2.W, _rect2.H, _rect2.Page); -}; - - -CDrawingDocument.prototype.LogicDocumentOnMouseDown = function(e, x, y, page) -{ - if (this.m_bIsMouseLockDocument) - { - this.LogicDocument.OnMouseUp(e, x, y, page); - this.m_bIsMouseLockDocument = false; - } - this.LogicDocument.OnMouseDown(e, x, y, page); - this.m_bIsMouseLockDocument = true; -}; - -CDrawingDocument.prototype.LogicDocumentOnMouseUp = function(e, x, y, page) -{ - if (!this.m_bIsMouseLockDocument) - { - this.LogicDocument.OnMouseDown(e, x, y, page); - this.m_bIsMouseLockDocument = true; - } - this.LogicDocument.OnMouseUp(e, x, y, page); - this.m_bIsMouseLockDocument = false; -}; - -CDrawingDocument.prototype.GetInvertTextMatrix = function(oController){ - -}; - -CDrawingDocument.prototype.OnCheckMouseDown = function(e) -{ - // 0 - none - // 1 - select markers - // 2 - drawing track - - var oController = this.LogicDocument.GetCurrentController(); - check_MouseDownEvent(e, false); - if(!oController){ - return -1; - } - - var oTargetTextObject = AscFormat.getTargetTextObject(oController); - var matrixCheck = oController.getTargetTransform(); - var oInvertMaxtrix; - if(oTargetTextObject && oTargetTextObject.invertTransformText){ - oInvertMaxtrix = oTargetTextObject.invertTransformText; - } - else{ - oInvertMaxtrix = AscCommon.global_MatrixTransformer.Invert(matrixCheck); - } - var oDocContent; - var pos = {X: global_mouseEvent.X, Y: global_mouseEvent.Y, Page: this.LogicDocument.CurPage}; - if (pos.Page == -1) - return 0; - - this.SelectDrag = -1; - if (this.SelectRect1 && this.SelectRect2) - { - // проверям попадание в селект - var radiusMM = 5; - if (this.IsRetina) - radiusMM *= 2; - radiusMM /= this.Native["DD_GetDotsPerMM"](); - - var _circlePos1_x = 0; - var _circlePos1_y = 0; - var _circlePos2_x = 0; - var _circlePos2_y = 0; - - if (!matrixCheck) - { - _circlePos1_x = this.SelectRect1.X; - _circlePos1_y = this.SelectRect1.Y - radiusMM; - - _circlePos2_x = this.SelectRect2.X + this.SelectRect2.W; - _circlePos2_y = this.SelectRect2.Y + this.SelectRect2.H + radiusMM; - } - else - { - var _circlePos1_x_mem = this.SelectRect1.X; - var _circlePos1_y_mem = this.SelectRect1.Y - radiusMM; - - var _circlePos2_x_mem = this.SelectRect2.X + this.SelectRect2.W; - var _circlePos2_y_mem = this.SelectRect2.Y + this.SelectRect2.H + radiusMM; - - _circlePos1_x = matrixCheck.TransformPointX(_circlePos1_x_mem, _circlePos1_y_mem); - _circlePos1_y = matrixCheck.TransformPointY(_circlePos1_x_mem, _circlePos1_y_mem); - _circlePos2_x = matrixCheck.TransformPointX(_circlePos2_x_mem, _circlePos2_y_mem); - _circlePos2_y = matrixCheck.TransformPointY(_circlePos2_x_mem, _circlePos2_y_mem); - } - - var _selectCircleEpsMM = 10; // 1cm; - var _selectCircleEpsMM_square = _selectCircleEpsMM * _selectCircleEpsMM; - - var _distance1 = ((pos.X - _circlePos1_x) * (pos.X - _circlePos1_x) + (pos.Y - _circlePos1_y) * (pos.Y - _circlePos1_y)); - var _distance2 = ((pos.X - _circlePos2_x) * (pos.X - _circlePos2_x) + (pos.Y - _circlePos2_y) * (pos.Y - _circlePos2_y)); - - var candidate = 1; - if (_distance2 < _distance1) - candidate = 2; - - - if (1 == candidate && _distance1 < _selectCircleEpsMM_square) - { - this.SelectClearLock = true; - this.SelectDrag = 1; - - var oTargetTextObject = AscFormat.getTargetTextObject(oController); - if(oTargetTextObject){ - var _oldShift = global_mouseEvent.ShiftKey; - global_mouseEvent.ShiftKey = true; - oController.cursorMoveRight(false, false); - oTargetTextObject.selectionSetStart(global_mouseEvent, pos.X, pos.Y, 0); - oTargetTextObject.selectionSetEnd(global_mouseEvent, pos.X, pos.Y, 0); - global_mouseEvent.ShiftKey = _oldShift; - this.LogicDocument.Document_UpdateSelectionState(); - this.m_oWordControl.OnUpdateOverlay(); - } - this.SelectClearLock = false; - } - - if (2 == candidate && _distance2 < _selectCircleEpsMM_square) - { - this.SelectClearLock = true; - this.SelectDrag = 2; - var oTargetTextObject = AscFormat.getTargetTextObject(oController); - if(oTargetTextObject){ - var _oldShift = global_mouseEvent.ShiftKey; - global_mouseEvent.ShiftKey = true; - oController.cursorMoveLeft(false, false); - oTargetTextObject.selectionSetStart(global_mouseEvent, pos.X, pos.Y, 0); - oTargetTextObject.selectionSetEnd(global_mouseEvent, pos.X, pos.Y, 0); - global_mouseEvent.ShiftKey = _oldShift; - this.LogicDocument.Document_UpdateSelectionState(); - this.m_oWordControl.OnUpdateOverlay(); - } - - this.SelectClearLock = false; - } - - if (this.SelectDrag != -1) - return 1; - } - - if (true) - { - // проверям н]а попадание в графические объекты (грубо говоря - треки) - if (!this.IsViewMode) - { - global_mouseEvent.KoefPixToMM = 5; - - if (this.Native["GetDeviceDPI"]) - { - // 1см - global_mouseEvent.AscHitToHandlesEpsilon = 5 * this.Native["GetDeviceDPI"]() / (25.4 * this.Native["DD_GetDotsPerMM"]() ); - } - - var oController = this.LogicDocument.GetCurrentController(); - var _isDrawings = false; - _isDrawings = oController.isPointInDrawingObjects4(pos.X, pos.Y, pos.Page, true); - - - if (_isDrawings) { - this.OnMouseDown(e); - } - - global_mouseEvent.KoefPixToMM = 1; - - if (_isDrawings) - return 2; - } - } - - return 0; -}; - - -CDrawingDocument.prototype.OnKeyboardEvent = function(_params){ - var _len = _params.length / 4; - - - for (var i = 0; i < _len; i++) - { - var _offset = i * 4; - switch (_params[_offset]) - { - case 4: // down - { - this.IsKeyDownButNoPress = true; - check_KeyboardEvent_Array(_params, _offset); - this.bIsUseKeyPress = (this.LogicDocument.OnKeyDown(AscCommon.global_keyboardEvent) === true) ? false : true; - break; - } - case 5: // Press - { - check_KeyboardEvent_Array(_params, _offset); - this.LogicDocument.OnKeyPress(AscCommon.global_keyboardEvent); - break; - } - case 6: // up - { - AscCommon.global_keyboardEvent.AltKey = false; - AscCommon.global_keyboardEvent.CtrlKey = false; - AscCommon.global_keyboardEvent.ShiftKey = false; - break; - } - default: - break; - } - } - this.m_oWordControl.OnUpdateOverlay(); -}; - - -CDrawingDocument.prototype.OnAnimPaneChanged = function(nSlideNum, oRect) -{ -}; - -function DrawBackground(graphics, unifill, w, h) -{ - // первым делом рисуем белый рект! - if (true) - { - // ну какой-то бэкграунд должен быть - graphics.SetIntegerGrid(false); - - var _l = 0; - var _t = 0; - var _r = (0 + w); - var _b = (0 + h); - - graphics._s(); - graphics._m(_l, _t); - graphics._l(_r, _t); - graphics._l(_r, _b); - graphics._l(_l, _b); - graphics._z(); - - graphics.b_color1(255, 255, 255, 255); - graphics.df(); - graphics._e(); - } - - if (unifill == null || unifill.fill == null) - return; - - graphics.SetIntegerGrid(false); - - var _shape = {}; - - _shape.brush = unifill; - _shape.pen = null; - _shape.TransformMatrix = new AscCommon.CMatrix(); - _shape.extX = w; - _shape.extY = h; - _shape.check_bounds = function(checker) - { - checker._s(); - checker._m(0, 0); - checker._l(this.extX, 0); - checker._l(this.extX, this.extY); - checker._l(0, this.extY); - checker._z(); - checker._e(); - }; - - var shape_drawer = new AscCommon.CShapeDrawer(); - shape_drawer.fromShape2(_shape, graphics, null); - shape_drawer.draw(null); -} - -function CSlideDrawer() -{ - this.CONST_BORDER = 10; // in px - - this.CheckRecalculateSlide = function() - { - }; - - this.CheckSlideSize = function(zoom, slideNum) - { - }; - - this.CheckSlide = function(slideNum) - { - - }; - - this.DrawSlide = function(outputCtx, scrollX, scrollX_max, scrollY, scrollY_max, slideNum) - { - }; -} - -function CDrawingCollaborativeTarget(DrawingDocument) -{ - AscCommon.CDrawingCollaborativeTargetBase.call(this); - this.Page = -1; - this.DrawingDocument = DrawingDocument; -} -CDrawingCollaborativeTarget.prototype = Object.create(AscCommon.CDrawingCollaborativeTargetBase.prototype); -CDrawingCollaborativeTarget.prototype.CheckPosition = function (_x, _y, _size, _page, _transform) -{ - this.Transform = _transform; - this.Size = _size; - this.X = _x; - this.Y = _y; - this.Page = _page; -}; -CDrawingCollaborativeTarget.prototype.Remove = function () -{ -}; -CDrawingCollaborativeTarget.prototype.Update = function () -{ -}; -//--------------------------------------------------------export---------------------------------------------------- -window['AscCommon'] = window['AscCommon'] || {}; -window['AscCommon'].CDrawingDocument = CDrawingDocument; diff --git a/slide/Native/HtmlPage.js b/slide/Native/HtmlPage.js deleted file mode 100644 index 8024bc4476..0000000000 --- a/slide/Native/HtmlPage.js +++ /dev/null @@ -1,611 +0,0 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2023 - * - * This program is a free software product. You can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License (AGPL) - * version 3 as published by the Free Software Foundation. In accordance with - * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement - * of any third-party rights. - * - * This program is distributed WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ - -"use strict"; - -var Page_Width = 297; -var Page_Height = 210; - -var X_Left_Margin = 30; // 3 cm -var X_Right_Margin = 15; // 1.5 cm -var Y_Bottom_Margin = 20; // 2 cm -var Y_Top_Margin = 20; // 2 cm - -function CEditorPage(api) -{ - // ------------------------------------------------------------------ - this.Name = ""; - this.IsSupportNotes = false; - - this.EditorType = "presentations"; - - this.X = 0; - this.Y = 0; - this.Width = 10; - this.Height = 10; - - - this.m_oDrawingDocument = new AscCommon.CDrawingDocument(); - this.m_oLogicDocument = null; - - - this.SlideDrawer = new CSlideDrawer(); - - this.m_oDrawingDocument.m_oWordControl = this; - this.m_oDrawingDocument.m_oLogicDocument = this.m_oLogicDocument; - this.m_oApi = api; - - this.Native = window["native"]; -} - - -CEditorPage.prototype.MainScrollLock = function() -{ -}; - - -CEditorPage.prototype.MainScrollUnLock = function() -{ -}; - -CEditorPage.prototype.checkBodySize = function() -{ -}; - -CEditorPage.prototype.Init = function() -{ - -}; - -CEditorPage.prototype.CheckRetinaDisplay = function() -{ - -}; - -CEditorPage.prototype.CheckRetinaElement = function(htmlElem) -{ - -}; - -CEditorPage.prototype.ShowOverlay = function() -{ -}; - -CEditorPage.prototype.UnShowOverlay = function() -{ -}; - -CEditorPage.prototype.CheckUnShowOverlay = function() -{ -}; - -CEditorPage.prototype.CheckShowOverlay = function() -{ -}; - -CEditorPage.prototype.initEvents = function() -{ - -}; - -CEditorPage.prototype.initEvents2MobileAdvances = function() -{ -}; - -CEditorPage.prototype.onButtonRulersClick = function() -{ -}; - -CEditorPage.prototype.HideRulers = function() -{ -}; - -CEditorPage.prototype.zoom_FitToWidth = function() -{ -}; - -CEditorPage.prototype.zoom_FitToPage = function() -{ -}; - -CEditorPage.prototype.zoom_Fire = function(type) -{ -}; - -CEditorPage.prototype.zoom_Out = function() -{ -}; - -CEditorPage.prototype.zoom_In = function() -{ -}; - -CEditorPage.prototype.DisableRulerMarkers = function() -{ -}; - -CEditorPage.prototype.EnableRulerMarkers = function() -{ -}; - -CEditorPage.prototype.ToSearchResult = function() -{ -}; - -CEditorPage.prototype.onButtonTabsClick = function() -{ -}; - -CEditorPage.prototype.onButtonTabsDraw = function() -{ -}; - -CEditorPage.prototype.onPrevPage = function() -{ - var DD = this.m_oDrawingDocument; - if(DD) - { - if (0 < DD.SlideCurrent) - { - this.GoToPage(DD.SlideCurrent - 1); - } - else - { - this.GoToPage(0); - } - } -}; -CEditorPage.prototype.onNextPage = function() -{ - var oWordControl = this; - if ((oWordControl.m_oDrawingDocument.SlidesCount - 1) > oWordControl.m_oDrawingDocument.SlideCurrent) - { - oWordControl.GoToPage(oWordControl.m_oDrawingDocument.SlideCurrent + 1); - } - else if (oWordControl.m_oDrawingDocument.SlidesCount > 0) - { - oWordControl.GoToPage(oWordControl.m_oDrawingDocument.SlidesCount - 1); - } - var DD = this.m_oDrawingDocument; - if(DD) - { - if (DD.SlidesCount - 1 > DD.SlideCurrent) - { - this.GoToPage(DD.SlideCurrent + 1); - } - else - { - this.GoToPage(oWordControl.m_oDrawingDocument.SlidesCount - 1); - } - } -}; - - -CEditorPage.prototype.horRulerMouseDown = function(e) -{ -}; - -CEditorPage.prototype.horRulerMouseUp = function(e) -{ -}; - -CEditorPage.prototype.horRulerMouseMove = function(e) -{ -}; - -CEditorPage.prototype.verRulerMouseDown = function(e) -{ -}; - -CEditorPage.prototype.verRulerMouseUp = function(e) -{ -}; - -CEditorPage.prototype.verRulerMouseMove = function(e) -{ -}; - -CEditorPage.prototype.SelectWheel = function() -{ -}; - -CEditorPage.prototype.createSplitterDiv = function(nIdx) -{ -}; - -CEditorPage.prototype.onBodyMouseDown = function(e) -{ -}; - -CEditorPage.prototype.onBodyMouseMove = function(e) -{ -}; - -CEditorPage.prototype.OnResizeSplitter = function() -{ -}; - -CEditorPage.prototype.onBodyMouseUp = function(e) -{ -}; - -CEditorPage.prototype.onMouseDown = function(e) -{ -}; - -CEditorPage.prototype.onMouseMove = function(e) -{ -}; -CEditorPage.prototype.onMouseMove2 = function() -{ -}; -CEditorPage.prototype.onMouseUp = function(e, bIsWindow) -{ -}; - -CEditorPage.prototype.onMouseUpExternal = function(x, y) -{ -}; - -CEditorPage.prototype.onMouseWhell = function(e) -{ -}; - -CEditorPage.prototype.onKeyUp = function(e) -{ -}; - -CEditorPage.prototype.onKeyDown = function(e) -{ -}; - -CEditorPage.prototype.onKeyDownNoActiveControl = function(e) -{ -}; - -CEditorPage.prototype.onKeyDownTBIM = function(e) -{ -}; - -CEditorPage.prototype.DisableTextEATextboxAttack = function() -{ -}; - -CEditorPage.prototype.onKeyPress = function(e) -{ -}; - -// -------------------------------------------------------- // -// -----------------end demonstration---------------------- // -// -------------------------------------------------------- // - -CEditorPage.prototype.verticalScroll = function(sender,scrollPositionY,maxY,isAtTop,isAtBottom) -{ -}; - -CEditorPage.prototype.verticalScrollMouseUp = function(sender, e) -{ -}; - -CEditorPage.prototype.CorrectSpeedVerticalScroll = function(newScrollPos) -{ -}; - -CEditorPage.prototype.CorrectVerticalScrollByYDelta = function(delta) -{ -}; - -CEditorPage.prototype.horizontalScroll = function(sender,scrollPositionX,maxX,isAtLeft,isAtRight) -{ -}; - -CEditorPage.prototype.UpdateScrolls = function() -{ -}; - -CEditorPage.prototype.OnRePaintAttack = function() -{ -}; - -CEditorPage.prototype.DeleteVerticalScroll = function() -{ - -}; - -CEditorPage.prototype.OnResize = function(isAttack) -{ -}; - -CEditorPage.prototype.OnResize2 = function(isAttack) -{ - -}; - -CEditorPage.prototype.checkNeedRules = function() -{ - -}; - -CEditorPage.prototype.checkNeedHorScroll = function() -{ -}; - -CEditorPage.prototype.StartUpdateOverlay = function() -{ -}; - -CEditorPage.prototype.EndUpdateOverlay = function() -{ -}; - -CEditorPage.prototype.OnUpdateOverlay = function() -{ - if(!this.m_oLogicDocument) - { - return false; - } - if (this.IsUpdateOverlayOnlyEnd) - { - this.IsUpdateOverlayOnEndCheck = true; - return false; - } - var drDoc = this.m_oDrawingDocument; - this.Native["DD_Overlay_UpdateStart"](); - drDoc.AutoShapesTrack.SetCurrentPage(-100); - this.Native["DD_Overlay_Clear"](); - var oSlide = this.m_oLogicDocument.Slides[this.m_oLogicDocument.CurPage]; - if(oSlide) - { - if (drDoc.m_bIsSelection) - { - this.Native["DD_Overlay_StartDrawSelection"](); - drDoc.AutoShapesTrack.SetCurrentPage(-101); - if (oSlide) - { - oSlide.drawSelect(1); - drDoc.CheckSelectMobile(); - } - drDoc.AutoShapesTrack.SetCurrentPage(-100); - this.Native["DD_Overlay_EndDrawSelection"](); - } - if (this.m_oLogicDocument && this.m_oLogicDocument.CurPage > -1) - { - drDoc.AutoShapesTrack.SetCurrentPage(-101); - oSlide.drawSelect(2); - drDoc.AutoShapesTrack.SetCurrentPage(-100); - var elements = oSlide.graphicObjects; - if (!elements.canReceiveKeyPress()) - { - elements.DrawOnOverlay(drDoc.AutoShapesTrack); - drDoc.AutoShapesTrack.CorrectOverlayBounds(); - } - } - } - drDoc.Collaborative_TargetsUpdate(); - this.Native["DD_Overlay_UpdateEnd"](); - return true; -}; - -CEditorPage.prototype.GetDrawingPageInfo = function(nPageIndex) -{ -}; - -CEditorPage.prototype.OnCalculatePagesPlace = function() -{ -}; - -CEditorPage.prototype.OnPaint = function() -{ -}; - -CEditorPage.prototype.CheckFontCache = function() -{ -}; - -CEditorPage.prototype.OnScroll = function() -{ -}; - -CEditorPage.prototype.CheckZoom = function() -{ -}; - -CEditorPage.prototype.CalculateDocumentSize = function(bIsAttack) -{ -}; - -CEditorPage.prototype.CheckCalculateDocumentSize = function(_bounds) -{ -}; - -CEditorPage.prototype.InitDocument = function(bIsEmpty) -{ -}; - -CEditorPage.prototype.InitControl = function() -{ -}; - -CEditorPage.prototype.StartMainTimer = function() -{ - this.onTimerScroll(); -}; -CEditorPage.prototype.onTimerScroll = function() -{ - var oWordControl = editor.WordControl; - if(oWordControl.m_oLogicDocument) - { - oWordControl.m_oLogicDocument.ContinueSpellCheck(); - } - oWordControl.m_nPaintTimerId = setTimeout(oWordControl.onTimerScroll, 500); -}; - -CEditorPage.prototype.onTimerScroll_sync = function(isThUpdateSync) -{ -}; - -CEditorPage.prototype.UpdateHorRuler = function() -{ -}; - -CEditorPage.prototype.UpdateVerRuler = function() -{ -}; - -CEditorPage.prototype.SetCurrentPage = function() -{ -}; - -CEditorPage.prototype.UpdateHorRulerBack = function() -{ -}; - -CEditorPage.prototype.UpdateVerRulerBack = function() -{ -}; - -CEditorPage.prototype.CreateBackgroundHorRuler = function(margins) -{ -}; - -CEditorPage.prototype.CreateBackgroundVerRuler = function(margins) -{ -}; - -CEditorPage.prototype.ThemeGenerateThumbnails = function(_master) -{ -}; - -CEditorPage.prototype.CheckLayouts = function(bIsAttack) -{ - if(!this.m_oLogicDocument || !this.m_oLogicDocument.Api){ - return; - } - - var master; - var slide = this.m_oLogicDocument.Slides[this.m_oLogicDocument.CurPage]; - if (slide) { - master = slide.Layout.Master; - } - else { - master = this.m_oLogicDocument.lastMaster; - if(!master) { - master = this.m_oLogicDocument.slideMasters[0]; - } - } - if(!master) { - return; - } - if(bIsAttack || this.MasterLayouts !== master){ - this.MasterLayouts = master; - this.m_oDrawingDocument.CheckLayouts(master); - this.m_oLogicDocument.Api.sendEvent("asc_onUpdateThemeIndex", master.ThemeIndex); - this.m_oLogicDocument.Api.sendColorThemes(master.Theme); - } -}; - -CEditorPage.prototype.GoToPage = function(lPageNum) -{ - if(this.m_oDrawingDocument){ - this.m_oDrawingDocument.SlidesCount = this.m_oLogicDocument.Slides.length; - this.m_oDrawingDocument.SlideCurrent = this.m_oLogicDocument.CurPage; - } - if(this.m_oLogicDocument) - { - this.m_oLogicDocument.Set_CurPage(lPageNum); - } - this.Native["DD_SetCurrentPage"](lPageNum); - this.CheckLayouts(false); -}; - -CEditorPage.prototype.GetVerticalScrollTo = function(y) -{ -}; - -CEditorPage.prototype.GetHorizontalScrollTo = function(x) -{ -}; - -// -------------------------------------------------------- // -// -------------------- east asian fonts ------------------ // -// -------------------------------------------------------- // - -CEditorPage.prototype.ReinitTB = function() -{ -}; - -CEditorPage.prototype.SetTextBoxMode = function(isEA) -{ -}; - -CEditorPage.prototype.TextBoxFocus = function() -{ -}; - -CEditorPage.prototype.OnTextBoxInput = function() -{ -}; - -CEditorPage.prototype.CheckTextBoxSize = function() -{ -}; - -CEditorPage.prototype.TextBoxOnKeyDown = function(e) -{ -}; - -CEditorPage.prototype.onChangeTB = function() -{ -}; - -CEditorPage.prototype.setNotesEnable = function() -{}; - -CEditorPage.prototype.CheckTextBoxInputPos = function() -{ -}; - -CEditorPage.prototype.SaveDocument = function() -{ -}; - -//------------------------------------------------------------export---------------------------------------------------- -window['AscCommon'] = window['AscCommon'] || {}; -window['AscCommonSlide'] = window['AscCommonSlide'] || {}; -window['AscCommonSlide'].CEditorPage = CEditorPage; - -window['AscCommon'].Page_Width = Page_Width; -window['AscCommon'].Page_Height = Page_Height; -window['AscCommon'].X_Left_Margin = X_Left_Margin; -window['AscCommon'].X_Right_Margin = X_Right_Margin; -window['AscCommon'].Y_Bottom_Margin = Y_Bottom_Margin; -window['AscCommon'].Y_Top_Margin = Y_Top_Margin; diff --git a/slide/Native/api.js b/slide/Native/api.js deleted file mode 100644 index 5c85b2080e..0000000000 --- a/slide/Native/api.js +++ /dev/null @@ -1,1081 +0,0 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2023 - * - * This program is a free software product. You can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License (AGPL) - * version 3 as published by the Free Software Foundation. In accordance with - * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement - * of any third-party rights. - * - * This program is distributed WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ - -var _api = null; - -var sdkCheck = true; -var spellCheck = true; -var _internalStorage = {}; - -function asc_menu_WriteSlidePr(_slidePr, _stream){ - if(_slidePr.Background) { - _slidePr.Background.write(0, _stream); - } - asc_menu_WriteTransition(1, _slidePr.Transition, _stream); - if(AscFormat.isRealNumber(_slidePr.LayoutIndex)){ - _stream["WriteByte"](2); - _stream["WriteLong"](_slidePr.LayoutIndex); - } - if(AscFormat.isRealBool(_slidePr.isHidden)){ - _stream["WriteByte"](3); - _stream["WriteBool"](_slidePr.isHidden); - } - if(AscFormat.isRealBool(_slidePr.lockBackground)){ - _stream["WriteByte"](4); - _stream["WriteBool"](_slidePr.lockBackground); - } - if(AscFormat.isRealBool(_slidePr.lockDelete)){ - _stream["WriteByte"](5); - _stream["WriteBool"](_slidePr.lockDelete); - } - if(AscFormat.isRealBool(_slidePr.lockLayout)){ - _stream["WriteByte"](6); - _stream["WriteBool"](_slidePr.lockLayout); - } - if(AscFormat.isRealBool(_slidePr.lockRemove)){ - _stream["WriteByte"](7); - _stream["WriteBool"](_slidePr.lockRemove); - } - if(AscFormat.isRealBool(_slidePr.lockTiming)){ - _stream["WriteByte"](8); - _stream["WriteBool"](_slidePr.lockTiming); - } - if(AscFormat.isRealBool(_slidePr.lockTransition)){ - _stream["WriteByte"](9); - _stream["WriteBool"](_slidePr.lockTransition); - } - _stream["WriteByte"](255); -} - -function asc_menu_ReadSlidePr(_params, _cursor){ - var _settings = new Asc.CAscSlideProps(); - - var _continue = true; - while (_continue) - { - var _attr = _params[_cursor.pos++]; - switch (_attr) - { - case 0: - { - _settings.Background = new Asc.asc_CShapeFill(); - _settings.Background.read(_params, _cursor); - break; - } - case 1: - { - _settings.Transition = asc_menu_ReadTransition(_params, _cursor); - break; - } - case 2: - { - _settings.LayoutIndex = _params[_cursor.pos++]; - break; - } - case 3: - { - _settings.isHidden = _params[_cursor.pos++]; - break; - } - case 4: - { - _settings.lockBackground = _params[_cursor.pos++]; - break; - } - case 5: - { - _settings.lockDelete = _params[_cursor.pos++]; - break; - } - case 6: - { - _settings.lockLayout = _params[_cursor.pos++]; - break; - } - case 7: - { - _settings.lockRemove = _params[_cursor.pos++]; - break; - } - case 8: - { - _settings.lockTiming = _params[_cursor.pos++]; - break; - } - case 9: - { - _settings.lockTransition = _params[_cursor.pos++]; - break; - } - case 255: - default: - { - _continue = false; - break; - } - } - } - return _settings; -} - -function asc_menu_WriteTransition(type, _transition, _stream){ - - _stream["WriteByte"](type); - if(AscFormat.isRealNumber(_transition.TransitionType)){ - _stream["WriteByte"](0); - _stream["WriteLong"](_transition.TransitionType); - } - if(AscFormat.isRealNumber(_transition.TransitionOption)){ - _stream["WriteByte"](1); - _stream["WriteLong"](_transition.TransitionOption); - } - if(AscFormat.isRealNumber(_transition.TransitionDuration)){ - _stream["WriteByte"](2); - _stream["WriteLong"](_transition.TransitionDuration); - } - if(AscFormat.isRealBool(_transition.SlideAdvanceOnMouseClick)){ - _stream["WriteByte"](3); - _stream["WriteBool"](_transition.SlideAdvanceOnMouseClick); - } - if(AscFormat.isRealBool(_transition.SlideAdvanceAfter)){ - _stream["WriteByte"](4); - _stream["WriteBool"](_transition.SlideAdvanceAfter); - } - if(AscFormat.isRealBool(_transition.ShowLoop)){ - _stream["WriteByte"](5); - _stream["WriteBool"](_transition.ShowLoop); - } - if(AscFormat.isRealNumber(_transition.SlideAdvanceDuration)){ - _stream["WriteByte"](6); - _stream["WriteLong"](_transition.SlideAdvanceDuration); - } - - _stream["WriteByte"](255); -} - -function asc_menu_ReadTransition(_params, _cursor) -{ - var _settings = new Asc.CAscSlideTransition(); - - var _continue = true; - while (_continue) - { - var _attr = _params[_cursor.pos++]; - switch (_attr) - { - case 0: - { - _settings.TransitionType = _params[_cursor.pos++]; - break; - } - case 1: - { - _settings.TransitionOption = _params[_cursor.pos++]; - break; - } - case 2: - { - _settings.TransitionDuration = _params[_cursor.pos++]; - break; - } - case 3: - { - _settings.SlideAdvanceOnMouseClick = _params[_cursor.pos++]; - break; - } - case 4: - { - _settings.SlideAdvanceAfter = _params[_cursor.pos++]; - break; - } - case 5: - { - _settings.ShowLoop = _params[_cursor.pos++]; - break; - } - case 6: - { - _settings.SlideAdvanceDuration = _params[_cursor.pos++]; - } - case 255: - default: - { - _continue = false; - break; - } - } - } - - return _settings; -} - -function initSpellCheckApi() { - - _api.SpellCheckApi = new AscCommon.CSpellCheckApi(); - _api.isSpellCheckEnable = true; - - _api.SpellCheckApi.spellCheck = function (spellData) { - window["native"]["SpellCheck"](JSON.stringify(spellData)); - }; - - _api.SpellCheckApi.disconnect = function () {}; - - _api.sendEvent('asc_onSpellCheckInit', [ - "1026", - "1027", - "1029", - "1030", - "1031", - "1032", - "1033", - "1036", - "1038", - "1040", - "1042", - "1043", - "1044", - "1045", - "1046", - "1048", - "1049", - "1050", - "1051", - "1053", - "1055", - "1057", - "1058", - "1060", - "1062", - "1063", - "1066", - "1068", - "1069", - "1087", - "1104", - "1110", - "1134", - "2051", - "2055", - "2057", - "2068", - "2070", - "3079", - "3081", - "3082", - "4105", - "7177", - "9242", - "10266" - ]); - - _api.SpellCheckApi.onInit = function (e) { - _api.sendEvent('asc_onSpellCheckInit', e); - }; - - _api.SpellCheckApi.onSpellCheck = function (e) { - _api.SpellCheck_CallBack(e); - }; - - _api.SpellCheckApi.init(_api.documentId); - - _api.asc_setSpellCheck(spellCheck); - -} - -function NativeOpenFileP(_params, documentInfo){ - window.NATIVE_DOCUMENT_TYPE = window["native"]["GetEditorType"](); - if ("presentation" !== window.NATIVE_DOCUMENT_TYPE){ - return; - } - - sdkCheck = documentInfo["sdkCheck"]; - spellCheck = documentInfo["spellCheck"]; - - var translations = documentInfo["translations"]; - if (undefined != translations && null != translations && translations.length > 0) { - translations = JSON.parse(translations) - } else { - translations = ""; - } - - window["_api"] = window["API"] = _api = new window["Asc"]["asc_docs_api"](translations); - window["_editor"] = window.editor; - - AscCommon.g_clipboardBase.Init(_api); - _api["Native_Editor_Initialize_Settings"](_params); - window.documentInfo = documentInfo; - var userInfo = new Asc.asc_CUserInfo(); - userInfo.asc_putId(window.documentInfo["docUserId"]); - userInfo.asc_putFullName(window.documentInfo["docUserName"]); - userInfo.asc_putFirstName(window.documentInfo["docUserFirstName"]); - userInfo.asc_putLastName(window.documentInfo["docUserLastName"]); - - var docInfo = new Asc.asc_CDocInfo(); - docInfo.put_Id(window.documentInfo["docKey"]); - docInfo.put_Url(window.documentInfo["docURL"]); - docInfo.put_Format("pptx"); - docInfo.put_UserInfo(userInfo); - docInfo.put_Token(window.documentInfo["token"]); - - _internalStorage.externalUserInfo = userInfo; - _internalStorage.externalDocInfo = docInfo; - - var permissions = window.documentInfo["permissions"]; - if (undefined != permissions && null != permissions && permissions.length > 0) { - docInfo.put_Permissions(JSON.parse(permissions)); - } - _api.asc_setDocInfo(docInfo); - - _api.asc_registerCallback("asc_onAdvancedOptions", function(type, options) { - var stream = global_memory_stream_menu; - if (options === undefined) { - options = {}; - } - options["optionId"] = type; - stream["ClearNoAttack"](); - stream["WriteString2"](JSON.stringify(options)); - window["native"]["OnCallMenuEvent"](22000, stream); // ASC_MENU_EVENT_TYPE_ADVANCED_OPTIONS - }); - - _api.asc_registerCallback("asc_onSendThemeColorSchemes", function(schemes) { - var stream = global_memory_stream_menu; - stream["ClearNoAttack"](); - asc_WriteColorSchemes(schemes, stream); - window["native"]["OnCallMenuEvent"](2404, stream); // ASC_SPREADSHEETS_EVENT_TYPE_COLOR_SCHEMES - }); - - _api.asc_registerCallback("asc_onSendThemeColors", onApiSendThemeColors); - _api.asc_registerCallback("asc_onPresentationSize", onApiPresentationSize); - - _api.asc_registerCallback("asc_onUpdateThemeIndex", function(nIndex) { - var stream = global_memory_stream_menu; - stream["ClearNoAttack"](); - stream["WriteLong"](nIndex); - window["native"]["OnCallMenuEvent"](8093, stream); // ASC_PRESENTATIONS_EVENT_TYPE_THEME_INDEX - }); - _api.asc_registerCallback('asc_onError', onApiError); - - // Edit - - _api.asc_registerCallback('asc_canIncreaseIndent', onApiCanIncreaseIndent); - _api.asc_registerCallback('asc_canDecreaseIndent', onApiCanDecreaseIndent); - - // Comments - - _api.asc_registerCallback("asc_onAddComment", onApiAddComment); - _api.asc_registerCallback("asc_onAddComments", onApiAddComments); - _api.asc_registerCallback("asc_onRemoveComment", onApiRemoveComment); - _api.asc_registerCallback("asc_onChangeComments", onApiChangeComments); - _api.asc_registerCallback("asc_onRemoveComments", onApiRemoveComments); - _api.asc_registerCallback("asc_onChangeCommentData", onApiChangeCommentData); - _api.asc_registerCallback("asc_onLockComment", onApiLockComment); - _api.asc_registerCallback("asc_onUnLockComment", onApiUnLockComment); - _api.asc_registerCallback("asc_onShowComment", onApiShowComment); - _api.asc_registerCallback("asc_onHideComment", onApiHideComment); - _api.asc_registerCallback("asc_onUpdateCommentPosition", onApiUpdateCommentPosition); - - if (window.documentInfo["iscoauthoring"]) { - _api.isSpellCheckEnable = false; - _api.asc_setAutoSaveGap(1); - _api._coAuthoringInit(); - _api.asc_SetFastCollaborative(true); - _api.SetCollaborativeMarksShowType(Asc.c_oAscCollaborativeMarksShowType.None); - window["native"]["onTokenJWT"](_api.CoAuthoringApi.get_jwt()); - - _api.asc_registerCallback("asc_onAuthParticipantsChanged", onApiAuthParticipantsChanged); - _api.asc_registerCallback("asc_onParticipantsChanged", onApiParticipantsChanged); - - _api.asc_registerCallback("asc_onGetEditorPermissions", function(state) { - - var rData = { - "c" : "open", - "id" : window.documentInfo["docKey"], - "userid" : window.documentInfo["docUserId"], - "format" : "pptx", - "vkey" : undefined, - "url" : window.documentInfo["docURL"], - "title" : this.documentTitle, - "nobase64" : true}; - - _api.CoAuthoringApi.auth(window.documentInfo["viewmode"], rData); - }); - - _api.asc_registerCallback("asc_onDocumentUpdateVersion", function(callback) { - var me = this; - me.needToUpdateVersion = true; - if (callback) callback.call(me); - }); - } else { - var doc_bin = window["native"]["GetFileString"]("native_open_file"); - _api["asc_nativeOpenFile"](doc_bin); - _api.documentId = "1"; - _api.WordControl.m_oDrawingDocument.AfterLoad(); - window["_api"] = window["API"] = Api = _api; - window["_editor"] = window.editor; - if (window.documentInfo["viewmode"]) { - _api.ShowParaMarks = false; - AscCommon.CollaborativeEditing.Set_GlobalLock(true); - _api.isViewMode = true; - _api.WordControl.m_oDrawingDocument.IsViewMode = true; - } - var _presentation = _api.WordControl.m_oLogicDocument; - - var nSlidesCount = _presentation.Slides.length; - var dPresentationWidth = _presentation.GetWidthMM(); - var dPresentationHeight = _presentation.GetHeightMM(); - - var aTransitions = []; - var slides = _presentation.Slides; - // for(var i = 0; i < slides.length; ++i){ - // aTransitions.push(slides[i].transition.ToArray()); - // } - - _api.asc_GetDefaultTableStyles(); - _presentation.Recalculate({Drawings:{All:true, Map:{}}}); - _presentation.CurPage = Math.min(0, _presentation.Slides.length - 1); - _presentation.Document_UpdateInterfaceState(); - _presentation.DrawingDocument.CheckThemes(); - _presentation.DrawingDocument.CheckGuiControlColors(); - _api.WordControl.CheckLayouts(); - initSpellCheckApi(); - - if (!_api.bNoSendComments) { - var _slides = _presentation.Slides; - var _slidesCount = _slides.length; - for (var i = 0; i < _slidesCount; i++) { - var slideComments = _slides[i].slideComments; - if (slideComments) { - var _comments = slideComments.comments; - var _commentsCount = _comments.length; - for (var j = 0; j < _commentsCount; j++) { - _api.sync_AddComment(_comments[j].Get_Id(), _comments[j].Data); - } - } - } - } - - return [nSlidesCount, dPresentationWidth, dPresentationHeight, aTransitions]; - } -} - -function onApiCanIncreaseIndent(value) { - var data = { "result": value }; - postDataAsJSONString(data, 8127); // ASC_PRESENTATIONS_EVENT_CANINCREASEINDENT -} - -function onApiCanDecreaseIndent(value) { - var data = { "result": value }; - postDataAsJSONString(data, 8128); // ASC_PRESENTATIONS_EVENT_CANDECREASEINDENT -} - -function onApiPresentationSize(width, height, type) { - var size = { - "width" : width, - "height" : height, - }; - postDataAsJSONString(size, 8129); // ASC_PRESENTATIONS_EVENT_TYPE_SLIDE_SIZE_CHANGE -} - -Asc['asc_docs_api'].prototype.UpdateTextPr = function(TextPr) -{ - if (!TextPr) - return; - - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - - if (TextPr.Bold !== undefined) - { - _stream["WriteByte"](0); - _stream["WriteBool"](TextPr.Bold); - } - if (TextPr.Italic !== undefined) - { - _stream["WriteByte"](1); - _stream["WriteBool"](TextPr.Italic); - } - if (TextPr.Underline !== undefined) - { - _stream["WriteByte"](2); - _stream["WriteBool"](TextPr.Underline); - } - if (TextPr.Strikeout !== undefined) - { - _stream["WriteByte"](3); - _stream["WriteBool"](TextPr.Strikeout); - } - - asc_menu_WriteFontFamily(4, TextPr.FontFamily, _stream); - - if (TextPr.FontSize !== undefined) - { - _stream["WriteByte"](5); - _stream["WriteDouble2"](TextPr.FontSize); - } - - if(TextPr.Unifill && TextPr.Unifill.fill && TextPr.Unifill.fill.type === Asc.c_oAscFill.FILL_TYPE_SOLID && TextPr.Unifill.fill.color) - { - var _color = AscCommon.CreateAscColor(TextPr.Unifill.fill.color); - asc_menu_WriteColor(6, AscCommon.CreateAscColorCustom(_color.r, _color.g, _color.b, false), _stream); - } - else if (TextPr.Color !== undefined) - { - asc_menu_WriteColor(6, AscCommon.CreateAscColorCustom(TextPr.Color.r, TextPr.Color.g, TextPr.Color.b, TextPr.Color.Auto), _stream); - } - - if (TextPr.VertAlign !== undefined) - { - _stream["WriteByte"](7); - _stream["WriteLong"](TextPr.VertAlign); - } - - if (TextPr.HighLight !== undefined) - { - if (TextPr.HighLight === AscCommonWord.highlight_None) - { - _stream["WriteByte"](12); - } - else - { - asc_menu_WriteColor(8, AscCommon.CreateAscColorCustom(TextPr.HighLight.r, TextPr.HighLight.g, TextPr.HighLight.b), _stream); - } - } - - if (TextPr.DStrikeout !== undefined) - { - _stream["WriteByte"](9); - _stream["WriteBool"](TextPr.DStrikeout); - } - if (TextPr.Caps !== undefined) - { - _stream["WriteByte"](10); - _stream["WriteBool"](TextPr.Caps); - } - if (TextPr.SmallCaps !== undefined) - { - _stream["WriteByte"](11); - _stream["WriteBool"](TextPr.SmallCaps); - } - if (TextPr.Spacing !== undefined) - { - _stream["WriteByte"](13); - _stream["WriteDouble2"](TextPr.Spacing); - } - - _stream["WriteByte"](255); - - window["native"]["OnCallMenuEvent"](1, _stream); -}; - -Asc['asc_docs_api'].prototype["Native_Editor_Initialize_Settings"] = function(_params) -{ - window["NativeSupportTimeouts"] = true; - - if (!_params) - return; - - var _current = { pos : 0 }; - var _continue = true; - while (_continue) - { - var _attr = _params[_current.pos++]; - switch (_attr) - { - case 0: - { - AscCommon.GlobalSkin.STYLE_THUMBNAIL_WIDTH = _params[_current.pos++]; - break; - } - case 1: - { - AscCommon.GlobalSkin.STYLE_THUMBNAIL_HEIGHT = _params[_current.pos++]; - break; - } - case 2: - { - TABLE_STYLE_WIDTH_PIX = _params[_current.pos++]; - break; - } - case 3: - { - TABLE_STYLE_HEIGHT_PIX = _params[_current.pos++]; - break; - } - case 4: - { - this.chartPreviewManager.CHART_PREVIEW_WIDTH_PIX = _params[_current.pos++]; - break; - } - case 5: - { - this.chartPreviewManager.CHART_PREVIEW_HEIGHT_PIX = _params[_current.pos++]; - break; - } - case 6: - { - var _val = _params[_current.pos++]; - if (_val === true) - { - this.ShowParaMarks = false; - AscCommon.CollaborativeEditing.Set_GlobalLock(true); - - this.isViewMode = true; - this.WordControl.m_oDrawingDocument.IsViewMode = true; - } - break; - } - case 100: - { - this.WordControl.m_oDrawingDocument.IsRetina = _params[_current.pos++]; - break; - } - case 101: - { - this.WordControl.m_oDrawingDocument.IsMobile = _params[_current.pos++]; - window.AscAlwaysSaveAspectOnResizeTrack = true; - break; - } - case 255: - default: - { - _continue = false; - break; - } - } - } - - AscCommon.AscBrowser.isRetina = this.WordControl.m_oDrawingDocument.IsRetina; -}; - - -Asc['asc_docs_api'].prototype["CheckSlideBounds"] = function(nSlideIndex){ - var oBoundsChecker = new AscFormat.CSlideBoundsChecker(); - this.WordControl.m_oLogicDocument.Draw(nSlideIndex, oBoundsChecker); - var oBounds = oBoundsChecker.Bounds; - return [ - oBounds.min_x, oBounds.max_x, oBounds.min_y, oBounds.max_y - ] -} - -Asc['asc_docs_api'].prototype["GetNativePageMeta"] = function(pageIndex, bTh, bIsPlayMode) -{ - this.WordControl.m_oDrawingDocument.RenderPage(pageIndex, bTh, bIsPlayMode); -}; - -Asc["asc_docs_api"].prototype["asc_nativeOpenFile2"] = function(base64File, version) -{ - this.SpellCheckUrl = ''; - - this.WordControl.m_bIsRuler = false; - this.WordControl.Init(); - - this.InitEditor(); - - this.DocumentType = 2; - - AscCommon.g_oIdCounter.Set_Load(true); - - var _loader = new AscCommon.BinaryPPTYLoader(); - _loader.Api = this; - - _loader.Load(base64File, this.WordControl.m_oLogicDocument); - this.LoadedObject = 1; - AscCommon.g_oIdCounter.Set_Load(false); -}; - -Asc['asc_docs_api'].prototype.openDocument = function(file) -{ - _api.asc_nativeOpenFile2(file.data); - - - var _presentation = _api.WordControl.m_oLogicDocument; - - var nSlidesCount = _presentation.Slides.length; - var dPresentationWidth = _presentation.GetWidthMM(); - var dPresentationHeight = _presentation.GetHeightMM(); - - var aTransitions = []; - var slides = _presentation.Slides; - // for(var i = 0; i < slides.length; ++i){ - // aTransitions.push(slides[i].transition.ToArray()); - // } - var _result = [nSlidesCount, dPresentationWidth, dPresentationHeight, aTransitions]; - var oTheme = null; - - if (null != slides[0]) - { - oTheme = slides[0].getTheme(); - } - if (false) { - - this.WordControl.m_oDrawingDocument.AfterLoad(); - - - this.ImageLoader.bIsLoadDocumentFirst = true; - - if (oTheme) - { - _api.sendColorThemes(oTheme); - } - - window["native"]["onEndLoadingFile"](_result); - this.asc_nativeCalculateFile(); - - return; - } - - var version; - if (file.changes && this.VersionHistory) - { - this.VersionHistory.changes = file.changes; - this.VersionHistory.applyChanges(this); - } - - this.WordControl.m_oDrawingDocument.AfterLoad(); - - //console.log("ImageMap : " + JSON.stringify(this.WordControl.m_oLogicDocument)); - - this.ImageLoader.bIsLoadDocumentFirst = true; - this.ImageLoader.LoadDocumentImages(this.WordControl.m_oLogicDocument.ImageMap); - - this.WordControl.m_oLogicDocument.Continue_FastCollaborativeEditing(); - - //this.asyncFontsDocumentEndLoaded(); - // - // if (oTheme) - // { - // _api.sendColorThemes(oTheme); - // } - - if (null != this.WordControl.m_oLogicDocument) - { - this.WordControl.m_oDrawingDocument.CheckGuiControlColors(); - } - window["native"]["onTokenJWT"](_api.CoAuthoringApi.get_jwt()); - window["native"]["onEndLoadingFile"](_result); - - this.asc_nativeCalculateFile(); - - this.WordControl.m_oDrawingDocument.Collaborative_TargetsUpdate(true); - - _api.asc_GetDefaultTableStyles(); - - initSpellCheckApi(); - - var t = this; - setInterval(function() { - t._autoSave(); - }, 40); -}; - -Asc['asc_docs_api'].prototype.Update_ParaInd = function( Ind ) -{ - // this.WordControl.m_oDrawingDocument.Update_ParaInd(Ind); -}; - -Asc['asc_docs_api'].prototype.Internal_Update_Ind_Left = function(Left) -{ -}; - -Asc['asc_docs_api'].prototype.Internal_Update_Ind_Right = function(Right) -{ -}; - -Asc['asc_docs_api'].prototype.IsAsyncOpenDocumentImages = function() -{ - return true; -}; - -Asc['asc_docs_api'].prototype.asyncImageEndLoadedBackground = function(_image) -{ -}; - -/***************************** COPY|PASTE *******************************/ - -Asc['asc_docs_api'].prototype.Call_Menu_Context_Copy = function() -{ - var dataBuffer = {}; - - var clipboard = {}; - clipboard.pushData = function(type, data) { - - if (AscCommon.c_oAscClipboardDataFormat.Text === type) { - - dataBuffer.text = data; - - } else if (AscCommon.c_oAscClipboardDataFormat.Internal === type) { - - if (null != data.drawingUrls && data.drawingUrls.length > 0) { - dataBuffer.drawingUrls = data.drawingUrls[0]; - } - - dataBuffer.sBase64 = data; - } - }; - - this.asc_CheckCopy(clipboard, AscCommon.c_oAscClipboardDataFormat.Internal|AscCommon.c_oAscClipboardDataFormat.Text); - - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - - if (dataBuffer.text) { - _stream["WriteByte"](0); - _stream["WriteString2"](dataBuffer.text); - } - - if (dataBuffer.drawingUrls) { - _stream["WriteByte"](1); - _stream["WriteStringA"](dataBuffer.drawingUrls); - } - - if (dataBuffer.sBase64) { - _stream["WriteByte"](2); - _stream["WriteStringA"](dataBuffer.sBase64); - } - - _stream["WriteByte"](255); - - return _stream; -}; -Asc['asc_docs_api'].prototype.Call_Menu_Context_Cut = function() -{ - var dataBuffer = {}; - - var clipboard = {}; - clipboard.pushData = function(type, data) { - - if (AscCommon.c_oAscClipboardDataFormat.Text === type) { - - dataBuffer.text = data; - - } else if (AscCommon.c_oAscClipboardDataFormat.Internal === type) { - - if (null != data.drawingUrls && data.drawingUrls.length > 0) { - dataBuffer.drawingUrls = data.drawingUrls[0]; - } - - dataBuffer.sBase64 = data; - } - } - - this.asc_CheckCopy(clipboard, AscCommon.c_oAscClipboardDataFormat.Internal|AscCommon.c_oAscClipboardDataFormat.Text); - - this.asc_SelectionCut(); - - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - - if (dataBuffer.text) { - _stream["WriteByte"](0); - _stream["WriteString2"](dataBuffer.text); - } - - if (dataBuffer.drawingUrls) { - _stream["WriteByte"](1); - _stream["WriteStringA"](dataBuffer.drawingUrls); - } - - if (dataBuffer.sBase64) { - _stream["WriteByte"](2); - _stream["WriteStringA"](dataBuffer.sBase64); - } - - _stream["WriteByte"](255); - - return _stream; -}; - -Asc['asc_docs_api'].prototype.Call_Menu_Context_Paste = function(type, param) -{ - if (0 == type) - { - this.asc_PasteData(AscCommon.c_oAscClipboardDataFormat.Text, param); - } - else if (1 == type) - { - this.AddImageUrlNative(param, 200, 200); - } - else if (2 == type) - { - this.asc_PasteData(AscCommon.c_oAscClipboardDataFormat.Internal, param); - } -}; - -Asc['asc_docs_api'].prototype.Call_Menu_Context_Select = function() -{ - this.WordControl.m_oLogicDocument.MoveCursorLeft(false, true); - this.WordControl.m_oLogicDocument.MoveCursorRight(true, true); - this.WordControl.m_oLogicDocument.Document_UpdateSelectionState(); -}; - -Asc['asc_docs_api'].prototype.Call_Menu_Context_Delete = function() -{ - this.WordControl.m_oLogicDocument.Remove(-1); -}; - -Asc['asc_docs_api'].prototype.Call_Menu_Context_SelectAll = function() -{ - this.WordControl.m_oLogicDocument.SelectAll(); -}; - -Asc['asc_docs_api'].prototype.asc_setDocumentPassword = function(password) -{ - var v = { - "id": this.documentId, - "userid": this.documentUserId, - "format": this.documentFormat, - "c": "reopen", - "title": this.documentTitle, - "password": password - }; - - AscCommon.sendCommand(this, null, v); -}; - -Asc["asc_docs_api"].prototype["asc_nativeGetFileData"] = function() -{ - var oBinaryFileWriter = new AscCommon.CBinaryFileWriter(); - this.WordControl.m_oLogicDocument.CalculateComments(); - oBinaryFileWriter.WriteDocument3(this.WordControl.m_oLogicDocument); - - window["native"]["GetFileData"](oBinaryFileWriter.ImData.data, oBinaryFileWriter.GetCurPosition()); - - return true; -}; - -Asc['asc_docs_api'].prototype.asc_setSpellCheck = function(isOn) -{ - if (editor.WordControl.m_oLogicDocument) - { - var _presentation = editor.WordControl.m_oLogicDocument; - _presentation.Spelling.Use = isOn; - var _drawing_document = editor.WordControl.m_oDrawingDocument; - if(isOn) - { - this.spellCheckTimerId = setInterval(function(){_presentation.ContinueSpellCheck();}, 500); - } - else - { - if(this.spellCheckTimerId) - { - clearInterval(this.spellCheckTimerId); - } - } - var oCurSlide = _presentation.Slides[_presentation.CurPage]; - - if(oCurSlide) - { - _drawing_document.OnStartRecalculate(_presentation.Slides.length); - _drawing_document.OnRecalculatePage(_presentation.CurPage, oCurSlide); - _drawing_document.OnEndRecalculate(); - } - } -}; - -window["native"]["Call_CheckSlideBounds"] = function(nIndex){ - if (window.editor) { - return window.editor["CheckSlideBounds"](nIndex); - } -}; - -window["native"]["Call_GetPageMeta"] = function(nIndex, bTh, bIsPlayMode){ - if (window.editor) { - return window.editor["GetNativePageMeta"](nIndex, bTh, bIsPlayMode); - } -}; - -window["native"]["Call_OnMouseDown"] = function(e) { - if (window.editor) { - return window.editor.WordControl.m_oDrawingDocument.OnMouseDown(e); - } - return -1; - }; - -window["native"]["Call_OnMouseUp"] = function(e) { - if(window.editor) { - return window.editor.WordControl.m_oDrawingDocument.OnMouseUp(e); - } - - return []; -}; - -window["native"]["Call_OnMouseMove"] = function(e) { - if(window.editor) { - window.editor.WordControl.m_oDrawingDocument.OnMouseMove(e); - } -}; - -window["native"]["Call_OnKeyboardEvent"] = function(e) { - return window.editor.WordControl.m_oDrawingDocument.OnKeyboardEvent(e); -}; - -window["native"]["Call_OnCheckMouseDown"] = function(e) { - return window.editor.WordControl.m_oDrawingDocument.OnCheckMouseDown(e); -}; - -window["native"]["Call_ResetSelection"] = function() { - window.editor.WordControl.m_oLogicDocument.RemoveSelection(false); - window.editor.WordControl.m_oLogicDocument.Document_UpdateSelectionState(); - window.editor.WordControl.m_oLogicDocument.Document_UpdateInterfaceState(); -}; - -window["native"]["Call_OnUpdateOverlay"] = function(param) { - if (window.editor) { - window.editor.WordControl.OnUpdateOverlay(param); - } -}; -window["native"]["Call_SetCurrentPage"] = function(param){ - if (window.editor) { - var oWC = window.editor.WordControl; - oWC.m_oLogicDocument.Set_CurPage(param); - if(oWC.m_oDrawingDocument) - { - oWC.m_oDrawingDocument.SlidesCount = oWC.m_oLogicDocument.Slides.length; - oWC.m_oDrawingDocument.SlideCurrent = oWC.m_oLogicDocument.CurPage; - } - oWC.CheckLayouts(false); - } -}; - -window["native"]["Call_Menu_Event"] = function (type, _params) -{ - return _api["Call_Menu_Event"](type, _params); -}; - -window["AscCommon"].sendImgUrls = function(api, images, callback) -{ - var _data = []; - callback(_data); -}; - -window["native"]["offline_of"] = function(_params, documentInfo) { return NativeOpenFileP(_params, documentInfo); }; - diff --git a/slide/Native/native.js b/slide/Native/native.js deleted file mode 100644 index c23cbe0b76..0000000000 --- a/slide/Native/native.js +++ /dev/null @@ -1,1763 +0,0 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2023 - * - * This program is a free software product. You can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License (AGPL) - * version 3 as published by the Free Software Foundation. In accordance with - * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement - * of any third-party rights. - * - * This program is distributed WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ - -Asc['asc_docs_api'].prototype.sync_CanUndoCallback = function(bCanUndo) -{ - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - _stream["WriteBool"](bCanUndo); - window["native"]["OnCallMenuEvent"](60, _stream); // ASC_MENU_EVENT_TYPE_CAN_UNDO -}; - -Asc['asc_docs_api'].prototype.sync_CanRedoCallback = function(bCanRedo) -{ - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - _stream["WriteBool"](bCanRedo); - window["native"]["OnCallMenuEvent"](61, _stream); // ASC_MENU_EVENT_TYPE_CAN_REDO -}; - -Asc['asc_docs_api'].prototype.SetDocumentModified = function(bValue) -{ - this.isDocumentModify = bValue; - - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - _stream["WriteBool"](this.isDocumentModify); - window["native"]["OnCallMenuEvent"](66, _stream); // ASC_MENU_EVENT_TYPE_DOCUMETN_MODIFITY -}; - -Asc['asc_docs_api'].prototype.sync_EndCatchSelectedElements = function() -{ - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - - var _count = this.SelectedObjectsStack.length; - var _naturalCount = 0; - - for (var i = 0; i < _count; i++) - { - switch (this.SelectedObjectsStack[i].Type) - { - case Asc.c_oAscTypeSelectElement.Paragraph: - case Asc.c_oAscTypeSelectElement.Table: - case Asc.c_oAscTypeSelectElement.Image: - case Asc.c_oAscTypeSelectElement.Hyperlink: - case Asc.c_oAscTypeSelectElement.Slide: - case Asc.c_oAscTypeSelectElement.Shape: - case Asc.c_oAscTypeSelectElement.Chart: - case Asc.c_oAscTypeSelectElement.Math: - { - ++_naturalCount; - break; - } - default: - break; - } - } - - _stream["WriteLong"](_naturalCount); - - for (var i = 0; i < _count; i++) - { - switch (this.SelectedObjectsStack[i].Type) - { - case Asc.c_oAscTypeSelectElement.Slide: - { - //console.log("StackObjects -> Slide"); - _stream["WriteLong"](Asc.c_oAscTypeSelectElement.Slide); - asc_menu_WriteSlidePr(this.SelectedObjectsStack[i].Value, _stream); - break; - } - - case Asc.c_oAscTypeSelectElement.Shape: - { - //console.log("StackObjects -> Shape"); - _stream["WriteLong"](Asc.c_oAscTypeSelectElement.Shape); - asc_menu_WriteShapePr(undefined, this.SelectedObjectsStack[i].Value, _stream); - break; - } - - case Asc.c_oAscTypeSelectElement.Chart: - { - //console.log("StackObjects -> Chart"); - _stream["WriteLong"](Asc.c_oAscTypeSelectElement.Chart); - asc_menu_WriteChartPr(undefined, this.SelectedObjectsStack[i].Value.ChartProperties, _stream); - break; - } - - case Asc.c_oAscTypeSelectElement.Paragraph: - { - //console.log("StackObjects -> Paragraph"); - _stream["WriteLong"](Asc.c_oAscTypeSelectElement.Paragraph); - asc_menu_WriteParagraphPr(this.SelectedObjectsStack[i].Value, _stream); - break; - } - - case Asc.c_oAscTypeSelectElement.Table: - { - //console.log("StackObjects -> Table"); - _stream["WriteLong"](Asc.c_oAscTypeSelectElement.Table); - asc_menu_WriteTablePr(this.SelectedObjectsStack[i].Value, _stream); - break; - } - case Asc.c_oAscTypeSelectElement.Image: - { - //console.log("StackObjects -> Image"); - _stream["WriteLong"](Asc.c_oAscTypeSelectElement.Image); - asc_menu_WriteImagePr(this.SelectedObjectsStack[i].Value, _stream); - break; - } - case Asc.c_oAscTypeSelectElement.Hyperlink: - { - //console.log("StackObjects -> Hyperlink"); - _stream["WriteLong"](Asc.c_oAscTypeSelectElement.Hyperlink); - asc_menu_WriteHyperPr(this.SelectedObjectsStack[i].Value, _stream); - break; - } - case Asc.c_oAscTypeSelectElement.Math: - { - _stream["WriteLong"](Asc.c_oAscTypeSelectElement.Math); - asc_menu_WriteMath(this.SelectedObjectsStack[i].Value, _stream); - break; - } - default: - { - // none - break; - } - } - } - - window["native"]["OnCallMenuEvent"](6, global_memory_stream_menu); -}; - -// chat styles -AscCommon.ChartPreviewManager.prototype.clearPreviews = function() -{ - window["native"]["ClearCacheChartStyles"](); -}; - -AscCommon.ChartPreviewManager.prototype.createChartPreview = function(_graphics, type, styleIndex) -{ - return AscFormat.ExecuteNoHistory(function(){ - var chart_space = this.checkChartForPreview(type, AscCommon.g_oChartStyles[type][styleIndex]); - - // sizes for imageView - window["native"]["DD_StartNativeDraw"](85 * 2, 85 * 2, 75, 75); - - chart_space.draw(_graphics); - _graphics.ClearParams(); - - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - _stream["WriteByte"](4); - _stream["WriteLong"](type); - _stream["WriteLong"](styleIndex); - window["native"]["DD_EndNativeDraw"](_stream); - - }, this, []); -}; - -AscCommon.ChartPreviewManager.prototype.getChartPreviews = function(chartType) -{ - if (AscFormat.isRealNumber(chartType)) - { - var bIsCached = window["native"]["IsCachedChartStyles"](chartType); - if (!bIsCached) - { - window["native"]["DD_PrepareNativeDraw"](); - - var _graphics = new CDrawingStream(); - - if(AscCommon.g_oChartStyles[chartType]){ - var nStylesCount = AscCommon.g_oChartStyles[chartType].length; - for(var i = 0; i < nStylesCount; ++i) - this.createChartPreview(_graphics, chartType, i); - } - - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - _stream["WriteByte"](5); - _api.WordControl.m_oDrawingDocument.Native["DD_EndNativeDraw"](_stream); - } - } -}; - - -// The helper function, called from the native application, -// returns information about the document as a JSON string. -Asc["asc_docs_api"].prototype["asc_nativeGetCoreProps"] = function() { - var props = (_api) ? _api.asc_getCoreProps() : null, - value; - - if (props) { - var coreProps = {}; - coreProps["asc_getModified"] = props.asc_getModified(); - - value = props.asc_getLastModifiedBy(); - if (value) - coreProps["asc_getLastModifiedBy"] = AscCommon.UserInfoParser.getParsedName(value); - - coreProps["asc_getTitle"] = props.asc_getTitle(); - coreProps["asc_getSubject"] = props.asc_getSubject(); - coreProps["asc_getDescription"] = props.asc_getDescription(); - coreProps["asc_getCreated"] = props.asc_getCreated(); - - var authors = []; - value = props.asc_getCreator();//"123\"\"\"\<\>,456"; - value && value.split(/\s*[,;]\s*/).forEach(function (item) { - authors.push(item); - }); - - coreProps["asc_getCreator"] = authors; - - return coreProps; - } - - return {}; -} - -window["AscCommon"].getFullImageSrc2 = function (src) { - - var start = src.slice(0, 6); - if (0 === start.indexOf('theme') && editor.ThemeLoader){ - return editor.ThemeLoader.ThemesUrlAbs + src; - } - - if (0 !== start.indexOf('http:') && 0 !== start.indexOf('data:') && 0 !== start.indexOf('https:') && - 0 !== start.indexOf('file:') && 0 !== start.indexOf('ftp:')){ - var srcFull = AscCommon.g_oDocumentUrls.getImageUrl(src); - var srcFull2 = srcFull; - if(src.endsWith(".svg")){ - var sName = src.slice(0, src.length - 3); - - src = sName + 'wmf'; - srcFull = AscCommon.g_oDocumentUrls.getImageUrl(src); - if(!srcFull){ - src = sName + 'emf'; - srcFull = AscCommon.g_oDocumentUrls.getImageUrl(src); - } - } - - if(srcFull){ - window["native"]["loadUrlImage"](srcFull, src); - return srcFull2; - } - } - return src; -}; - -Asc['asc_docs_api'].prototype["Call_Menu_Event"] = function(type, _params) -{ - var _return = undefined; - var _current = { pos : 0 }; - var _continue = true; - - switch (type) - { - case 1: // ASC_MENU_EVENT_TYPE_TEXTPR - { - var _textPr = new AscCommonWord.CTextPr(); - while (_continue) - { - var _attr = _params[_current.pos++]; - switch (_attr) - { - case 0: - { - _textPr.Bold = _params[_current.pos++]; - break; - } - case 1: - { - _textPr.Italic = _params[_current.pos++]; - break; - } - case 2: - { - _textPr.Underline = _params[_current.pos++]; - break; - } - case 3: - { - _textPr.Strikeout = _params[_current.pos++]; - break; - } - case 4: - { - _textPr.FontFamily = asc_menu_ReadFontFamily(_params, _current); - break; - } - case 5: - { - _textPr.FontSize = _params[_current.pos++]; - break; - } - case 6: - { - var Unifill = new AscFormat.CUniFill(); - Unifill.fill = new AscFormat.CSolidFill(); - var color = AscCommon.asc_menu_ReadColor(_params, _current); - Unifill.fill.color = AscFormat.CorrectUniColor(color, Unifill.fill.color, 1); - _textPr.Unifill = Unifill; - break; - } - case 7: - { - _textPr.VertAlign = _params[_current.pos++]; - break; - } - case 8: - { - var color = AscCommon.asc_menu_ReadColor(_params, _current); - _textPr.HighLight = { r: color.r, g: color.g, b: color.b }; - break; - } - case 9: - { - _textPr.DStrikeout = _params[_current.pos++]; - break; - } - case 10: - { - _textPr.Caps = _params[_current.pos++]; - break; - } - case 11: - { - _textPr.SmallCaps = _params[_current.pos++]; - break; - } - case 12: - { - _textPr.HighLight = AscCommonWord.highlight_None; - break; - } - case 13: - { - _textPr.Spacing = _params[_current.pos++]; - break; - } - case 255: - default: - { - _continue = false; - break; - } - } - } - - this.WordControl.m_oLogicDocument.Create_NewHistoryPoint(); - this.WordControl.m_oLogicDocument.AddToParagraph(new AscCommonWord.ParaTextPr(_textPr)); - this.WordControl.m_oLogicDocument.Document_UpdateInterfaceState(); - - break; - } - - case 2: // ASC_MENU_EVENT_TYPE_PARAPR - { - var _textPr = undefined; - - this.WordControl.m_oLogicDocument.Create_NewHistoryPoint(); - - while (_continue) - { - var _attr = _params[_current.pos++]; - switch (_attr) - { - case 0: - { - this.WordControl.m_oLogicDocument.SetParagraphContextualSpacing( _params[_current.pos++] ); - break; - } - case 1: - { - var _ind = asc_menu_ReadParaInd(_params, _current); - this.WordControl.m_oLogicDocument.SetParagraphIndent( _ind ); - break; - } - case 2: - { - this.WordControl.m_oLogicDocument.SetParagraphKeepLines( _params[_current.pos++] ); - break; - } - case 3: - { - this.WordControl.m_oLogicDocument.SetParagraphKeepNext( _params[_current.pos++] ); - break; - } - case 4: - { - this.WordControl.m_oLogicDocument.SetParagraphWidowControl( _params[_current.pos++] ); - break; - } - case 5: - { - this.WordControl.m_oLogicDocument.SetParagraphPageBreakBefore( _params[_current.pos++] ); - break; - } - case 6: - { - var _spacing = asc_menu_ReadParaSpacing(_params, _current); - this.WordControl.m_oLogicDocument.SetParagraphSpacing( _spacing ); - break; - } - case 7: - { - // TODO: - var _brds = asc_menu_ReadParaBorders(_params, _current); - - if (_brds.Left && _brds.Left.Color) - { - _brds.Left.Unifill = AscFormat.CreateUnifillFromAscColor(_brds.Left.Color); - } - if (_brds.Top && _brds.Top.Color) - { - _brds.Top.Unifill = AscFormat.CreateUnifillFromAscColor(_brds.Top.Color); - } - if (_brds.Right && _brds.Right.Color) - { - _brds.Right.Unifill = AscFormat.CreateUnifillFromAscColor(_brds.Right.Color); - } - if (_brds.Bottom && _brds.Bottom.Color) - { - _brds.Bottom.Unifill = AscFormat.CreateUnifillFromAscColor(_brds.Bottom.Color); - } - - this.WordControl.m_oLogicDocument.SetParagraphBorders( _brds ); - break; - } - case 8: - { - var _shd = asc_menu_ReadParaShd(_params, _current); - this.WordControl.m_oLogicDocument.SetParagraphShd( _shd ); - break; - } - case 9: - case 10: - case 11: - { - // nothing - _current.pos++; - break; - } - case 12: - { - this.WordControl.m_oLogicDocument.Set_DocumentDefaultTab( _params[_current.pos++] ); - break; - } - case 13: - { - var _tabs = asc_menu_ReadParaTabs(_params, _current); - // TODO: - this.WordControl.m_oLogicDocument.SetParagraphTabs( _tabs.Tabs ); - break; - } - case 14: - { - var _framePr = asc_menu_ReadParaFrame(_params, _current); - this.WordControl.m_oLogicDocument.SetParagraphFramePr( _framePr ); - break; - } - case 15: - { - if (_textPr === undefined) - _textPr = new AscCommonWord.CTextPr(); - if (true == _params[_current.pos++]) - _textPr.VertAlign = AscCommon.vertalign_SubScript; - else - _textPr.VertAlign = AscCommon.vertalign_Baseline; - break; - } - case 16: - { - if (_textPr === undefined) - _textPr = new AscCommonWord.CTextPr(); - if (true == _params[_current.pos++]) - _textPr.VertAlign = AscCommon.vertalign_SuperScript; - else - _textPr.VertAlign = AscCommon.vertalign_Baseline; - break; - } - case 17: - { - if (_textPr === undefined) - _textPr = new AscCommonWord.CTextPr(); - _textPr.SmallCaps = _params[_current.pos++]; - _textPr.Caps = false; - break; - } - case 18: - { - if (_textPr === undefined) - _textPr = new AscCommonWord.CTextPr(); - _textPr.Caps = _params[_current.pos++]; - if (true == _textPr.Caps) - _textPr.SmallCaps = false; - break; - } - case 19: - { - if (_textPr === undefined) - _textPr = new AscCommonWord.CTextPr(); - _textPr.Strikeout = _params[_current.pos++]; - _textPr.DStrikeout = false; - break; - } - case 20: - { - if (_textPr === undefined) - _textPr = new AscCommonWord.CTextPr(); - _textPr.DStrikeout = _params[_current.pos++]; - if (true == _textPr.DStrikeout) - _textPr.Strikeout = false; - break; - } - case 21: - { - if (_textPr === undefined) - _textPr = new AscCommonWord.CTextPr(); - _textPr.TextSpacing = _params[_current.pos++]; - break; - } - case 22: - { - if (_textPr === undefined) - _textPr = new AscCommonWord.CTextPr(); - _textPr.Position = _params[_current.pos++]; - break; - } - case 23: - { - var _listType = asc_menu_ReadParaListType(_params, _current); - var oBullet = AscFormat.fGetPresentationBulletByNumInfo(_listType); - this.WordControl.m_oLogicDocument.SetParagraphNumbering( oBullet ); - break; - } - case 24: - { - this.WordControl.m_oLogicDocument.SetParagraphStyle( _params[_current.pos++] ); - break; - } - case 25: - { - this.WordControl.m_oLogicDocument.SetParagraphAlign( _params[_current.pos++] ); - break; - } - case 255: - default: - { - _continue = false; - break; - } - } - } - - if (undefined !== _textPr) - this.WordControl.m_oLogicDocument.AddToParagraph(new AscCommonWord.ParaTextPr(_textPr)); - - this.WordControl.m_oLogicDocument.Document_UpdateInterfaceState(); - break; - } - case 22003: //ASC_MENU_EVENT_TYPE_ON_EDIT_TEXT - { - var oController = this.WordControl.m_oLogicDocument.GetCurrentController(); - if(oController) - { - oController.startEditTextCurrentShape(); - } - break; - } - case 3: // ASC_MENU_EVENT_TYPE_UNDO - { - this.WordControl.m_oLogicDocument.Document_Undo(); - break; - } - - case 4: // ASC_MENU_EVENT_TYPE_REDO - { - this.WordControl.m_oLogicDocument.Document_Redo(); - break; - } - - case 8: // ASC_MENU_EVENT_TYPE_HYPERLINK - { - var props = asc_menu_ReadHyperPr(_params, _current); - this.change_Hyperlink(props); - break; - } - - case 9 : // ASC_MENU_EVENT_TYPE_IMAGE - { - var _imagePr = new Asc.asc_CImgProperty(); - while (_continue) - { - var _attr = _params[_current.pos++]; - switch (_attr) - { - case 0: - { - _imagePr.CanBeFlow = _params[_current.pos++]; - break; - } - case 1: - { - _imagePr.Width = _params[_current.pos++]; - break; - } - case 2: - { - _imagePr.Height = _params[_current.pos++]; - break; - } - case 3: - { - _imagePr.WrappingStyle = _params[_current.pos++]; - break; - } - case 4: - { - _imagePr.Paddings = AscCommon.asc_menu_ReadPaddings(_params, _current); - break; - } - case 5: - { - _imagePr.Position = asc_menu_ReadPosition(_params, _current); - break; - } - case 6: - { - _imagePr.AllowOverlap = _params[_current.pos++]; - break; - } - case 7: - { - _imagePr.PositionH = asc_menu_ReadImagePosition(_params, _current); - break; - } - case 8: - { - _imagePr.PositionV = asc_menu_ReadImagePosition(_params, _current); - break; - } - case 9: - { - _imagePr.Internal_Position = _params[_current.pos++]; - break; - } - case 10: - { - _imagePr.ImageUrl = _params[_current.pos++]; - break; - } - case 11: - { - _imagePr.Locked = _params[_current.pos++]; - break; - } - case 12: - { - _imagePr.ChartProperties = asc_menu_ReadChartPr(_params, _current); - break; - } - case 13: - { - _imagePr.ShapeProperties = asc_menu_ReadShapePr(_params, _current); - break; - } - case 14: - { - _imagePr.ChangeLevel = _params[_current.pos++]; - break; - } - case 15: - { - _imagePr.Group = _params[_current.pos++]; - break; - } - case 16: - { - _imagePr.fromGroup = _params[_current.pos++]; - break; - } - case 17: - { - _imagePr.severalCharts = _params[_current.pos++]; - break; - } - case 18: - { - _imagePr.severalChartTypes = _params[_current.pos++]; - break; - } - case 19: - { - _imagePr.severalChartStyles = _params[_current.pos++]; - break; - } - case 20: - { - _imagePr.verticalTextAlign = _params[_current.pos++]; - break; - } - case 21: - { - _imagePr.vert = _params[_current.pos++]; - break; - } - case 22: - { - var bIsNeed = _params[_current.pos++]; - - if (bIsNeed) - { - var url = this.WordControl.m_oLogicDocument.GetCurrentController().getDrawingProps().imageProps.ImageUrl; - if (url != undefined) { - var sizes = this.WordControl.m_oDrawingDocument.Native["DD_GetOriginalImageSize"](url); - - var w = sizes[0]; - var h = sizes[1]; - - _imagePr.Width = (undefined !== w) ? Math.max(w * AscCommon.g_dKoef_pix_to_mm, 1) : 1; - _imagePr.Height = (undefined !== h) ? Math.max(h * AscCommon.g_dKoef_pix_to_mm, 1) : 1; - } - } - - break; - } - case 255: - default: - { - _continue = false; - break; - } - } - } - - this.ImgApply(_imagePr); - this.WordControl.m_oLogicDocument.Recalculate(); - - break; - } - - case 10: // ASC_MENU_EVENT_TYPE_TABLE - { - var _tablePr = new Asc.CTableProp(); - while (_continue) - { - var _attr = _params[_current.pos++]; - switch (_attr) - { - case 0: - { - _tablePr.CanBeFlow = _params[_current.pos++]; - break; - } - case 1: - { - _tablePr.CellSelect = _params[_current.pos++]; - break; - } - case 2: - { - _tablePr.TableWidth = _params[_current.pos++]; - break; - } - case 3: - { - _tablePr.TableSpacing = _params[_current.pos++]; - break; - } - case 4: - { - _tablePr.TableDefaultMargins = AscCommon.asc_menu_ReadPaddings(_params, _current); - break; - } - case 5: - { - _tablePr.CellMargins = asc_menu_ReadCellMargins(_params, _current); - break; - } - case 6: - { - _tablePr.TableAlignment = _params[_current.pos++]; - break; - } - case 7: - { - _tablePr.TableIndent = _params[_current.pos++]; - break; - } - case 8: - { - _tablePr.TableWrappingStyle = _params[_current.pos++]; - break; - } - case 9: - { - _tablePr.TablePaddings = AscCommon.asc_menu_ReadPaddings(_params, _current); - break; - } - case 10: - { - _tablePr.TableBorders = asc_menu_ReadCellBorders(_params, _current); - break; - } - case 11: - { - _tablePr.CellBorders = asc_menu_ReadCellBorders(_params, _current); - break; - } - case 12: - { - _tablePr.TableBackground = asc_menu_ReadCellBackground(_params, _current); - break; - } - case 13: - { - _tablePr.CellsBackground = asc_menu_ReadCellBackground(_params, _current); - break; - } - case 14: - { - _tablePr.Position = asc_menu_ReadPosition(_params, _current); - break; - } - case 15: - { - _tablePr.PositionH = asc_menu_ReadImagePosition(_params, _current); - break; - } - case 16: - { - _tablePr.PositionV = asc_menu_ReadImagePosition(_params, _current); - break; - } - case 17: - { - _tablePr.Internal_Position = asc_menu_ReadTableAnchorPosition(_params, _current); - break; - } - case 18: - { - _tablePr.ForSelectedCells = _params[_current.pos++]; - break; - } - case 19: - { - _tablePr.TableStyle = _params[_current.pos++]; - break; - } - case 20: - { - _tablePr.TableLook = asc_menu_ReadTableLook(_params, _current); - break; - } - case 21: - { - _tablePr.RowsInHeader = _params[_current.pos++]; - break; - } - case 22: - { - _tablePr.CellsVAlign = _params[_current.pos++]; - break; - } - case 23: - { - _tablePr.AllowOverlap = _params[_current.pos++]; - break; - } - case 24: - { - _tablePr.TableLayout = _params[_current.pos++]; - break; - } - case 25: - { - _tablePr.Locked = _params[_current.pos++]; - break; - } - case 255: - default: - { - _continue = false; - break; - } - } - } - - this.tblApply(_tablePr); - this.WordControl.m_oLogicDocument.Recalculate(); - - break; - } - - case 12: // ASC_MENU_EVENT_TYPE_TABLESTYLES - { - - } - - case 13: // ASC_MENU_EVENT_TYPE_INCREASEPARAINDENT - { - this.IncreaseIndent(); - break; - } - case 14: // ASC_MENU_EVENT_TYPE_DECREASEPARAINDENT - { - this.DecreaseIndent(); - break; - } - - case 18: // ASC_MENU_EVENT_TYPE_SHAPE - { - var shapeProp = asc_menu_ReadShapePr(_params, _current); - this.ShapeApply(shapeProp); - this.WordControl.m_oLogicDocument.Recalculate(); - break; - } - - case 20: // ASC_MENU_EVENT_TYPE_SLIDE - { - var props = asc_menu_ReadSlidePr(_params, _current); - this.SetSlideProps(props); - break; - } - - case 21: // ASC_MENU_EVENT_TYPE_CHART - { - var chartProp = asc_menu_ReadChartPr(_params, _current); - var prop = new Asc.CAscChartProp(); - prop.put_ChartProperties(chartProp); - prop.put_SeveralCharts(false); - this.ChartApply(prop); - this.WordControl.m_oLogicDocument.Recalculate(); - break; - } - - case 50: // ASC_MENU_EVENT_TYPE_INSERT_IMAGE - { - var oImageObject = {}; - oImageObject.src = _params[0]; - oImageObject.Image = {}; - oImageObject.Image.width = _params[1]; - oImageObject.Image.height = _params[2]; - this.WordControl.m_oLogicDocument.addImages([oImageObject]); - break; - } - - case 51: // ASC_MENU_EVENT_TYPE_INSERT_TABLE - { - var rows = 2; - var cols = 2; - var style = null; - - while (_continue) - { - var _attr = _params[_current.pos++]; - switch (_attr) - { - case 0: - { - rows = _params[_current.pos++]; - break; - } - case 1: - { - cols = _params[_current.pos++]; - break; - } - case 2: - { - style = _params[_current.pos++]; - break; - } - case 255: - default: - { - _continue = false; - break; - } - } - } - - this.put_Table(cols, rows, undefined, style); - - break; - } - - case 52: // ASC_MENU_EVENT_TYPE_INSERT_HYPERLINK - { - var props = asc_menu_ReadHyperPr(_params, _current); - this.add_Hyperlink(props); - break; - } - - case 53: // ASC_MENU_EVENT_TYPE_INSERT_SHAPE - { - var shapeProp = asc_menu_ReadShapePr(_params["shape"], _current); - var aspect = parseFloat(_params["aspect"]); - - var logicDocument = this.WordControl.m_oLogicDocument; - - if (logicDocument && logicDocument.Slides[logicDocument.CurPage]) { - var oDrawingObjects = logicDocument.Slides[logicDocument.CurPage].graphicObjects; - oDrawingObjects.changeCurrentState(new AscFormat.StartAddNewShape(oDrawingObjects, shapeProp.type)); - - var dsx = logicDocument.GetHeightMM() / 2.5 * aspect; - var dsy = logicDocument.GetHeightMM() / 2.5; - var dx = logicDocument.GetWidthMM() * 0.5 - dsx * 0.5; - var dy = logicDocument.GetHeightMM() * 0.5 - dsy * 0.5; - - logicDocument.OnMouseDown({}, dx, dy, logicDocument.CurPage); - logicDocument.OnMouseMove({IsLocked: true}, dx + dsx, dy + dsy, logicDocument.CurPage); - logicDocument.OnMouseUp({}, dx, dy, logicDocument.CurPage); - logicDocument.Document_UpdateInterfaceState(); - logicDocument.Document_UpdateRulersState(); - logicDocument.Document_UpdateSelectionState(); - } - break; - } - - case 58: // ASC_MENU_EVENT_TYPE_CAN_ADD_HYPERLINK - { - var canAdd = this.can_AddHyperlink(); - - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - - if (canAdd !== false) { - var _text = this.WordControl.m_oLogicDocument.GetSelectedText(true); - if (null != _text) { - _stream["WriteString2"](_text); - } - } - - _return = _stream; - break; - } - - case 59: // ASC_MENU_EVENT_TYPE_REMOVE_HYPERLINK - { - this.remove_Hyperlink(); - break; - } - - case 62: //ASC_MENU_EVENT_TYPE_SEARCH_FINDTEXT - { - let oProps = new AscCommon.CSearchSettings(); - oProps.SetText(_params[0]); - oProps.SetMatchCase(_params[2]); - - var SearchEngine = this.WordControl.m_oLogicDocument.Search(oProps); - var Id = this.WordControl.m_oLogicDocument.GetSearchElementId(_params[1]); - if (null != Id) - this.WordControl.m_oLogicDocument.SelectSearchElement(Id); - - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - _stream["WriteLong"](SearchEngine.Count); - _return = _stream; - break; - } - - case 63: // ASC_MENU_EVENT_TYPE_SEARCH_REPLACETEXT - { - var searchSettings = new AscCommon.CSearchSettings(); - searchSettings.put_Text(_params[0]); - searchSettings.put_MatchCase(_params[3]); - - var _ret = this.asc_replaceText(searchSettings, _params[1], _params[2]); - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - _stream["WriteBool"](_ret); - _return = _stream; - break; - } - - case 71: // ASC_MENU_EVENT_TYPE_TABLE_INSERTDELETE_ROWCOLUMN - { - var _type = 0; - var _is_add = true; - var _is_above = true; - while (_continue) - { - var _attr = _params[_current.pos++]; - switch (_attr) - { - case 0: - { - _type = _params[_current.pos++]; - break; - } - case 1: - { - _is_add = _params[_current.pos++]; - break; - } - case 2: - { - _is_above = _params[_current.pos++]; - break; - } - case 255: - default: - { - _continue = false; - break; - } - } - } - - if (1 == _type) { - if (_is_add) { - _is_above ? this.addColumnLeft() : this.addColumnRight(); - } else { - this.remColumn(); - } - } else if (2 == _type) { - if (_is_add) { - _is_above ? this.addRowAbove() : this.addRowBelow(); - } else { - this.remRow(); - } - } else if (3 == _type) { - this.remTable(); - } - - break; - } - - case 110: // ASC_MENU_EVENT_TYPE_CONTEXTMENU_COPY - { - _return = this.Call_Menu_Context_Copy(); - break; - } - - case 111 : // ASC_MENU_EVENT_TYPE_CONTEXTMENU_CUT - { - _return = this.Call_Menu_Context_Cut(); - break; - } - case 112: // ASC_MENU_EVENT_TYPE_CONTEXTMENU_PASTE - { - if(undefined !== _params) - { - this.Call_Menu_Context_Paste(_params[0], _params[1]); - } - break; - } - case 113: // ASC_MENU_EVENT_TYPE_CONTEXTMENU_DELETE - { - this.Call_Menu_Context_Delete(); - break; - } - - case 114: // ASC_MENU_EVENT_TYPE_CONTEXTMENU_SELECT - { - this.Call_Menu_Context_Select(); - break; - } - - case 115: // ASC_MENU_EVENT_TYPE_CONTEXTMENU_SELECTALL - { - this.Call_Menu_Context_SelectAll(); - break; - } - - case 200: // ASC_MENU_EVENT_TYPE_DOCUMENT_BASE64 - { - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - _stream["WriteStringA"](this["asc_nativeGetFileData"]()); - _return = _stream; - break; - } - - case 201: // ASC_MENU_EVENT_TYPE_DOCUMENT_CHARTSTYLES - { - var typeChart = _params[0]; - this.chartPreviewManager.getChartPreviews(typeChart); - _return = global_memory_stream_menu; - break; - } - - case 202: // ASC_MENU_EVENT_TYPE_DOCUMENT_PDFBASE64 - { - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - _stream["WriteStringA"](this.WordControl.m_oDrawingDocument.ToRenderer()); - _return = _stream; - break; - } - - case 400: // ASC_MENU_EVENT_TYPE_INSERT_CHART - { - - break; - } - - case 440: // ASC_MENU_EVENT_TYPE_ADD_CHART_DATA - { - if (undefined !== _params) { - var chartData = _params[0]; - if (chartData && chartData.length > 0) { - var json = JSON.parse(chartData); - if (json) { - _api.asc_addChartDrawingObject(json); - } - } - } - break; - } - - case 450: // ASC_MENU_EVENT_TYPE_GET_CHART_DATA - { - var index = null; - if (undefined !== _params) { - index = parseInt(_params); - } - - var chart = _api.asc_getChartObject(index); - - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - _stream["WriteStringA"](JSON.stringify(new Asc.asc_CChartBinary(chart))); - _return = _stream; - - break; - } - - case 460: // ASC_MENU_EVENT_TYPE_SET_CHART_DATA - { - if (undefined !== _params) { - var chartData = _params[0]; - if (chartData && chartData.length > 0) { - var json = JSON.parse(chartData); - if (json) { - _api.asc_editChartDrawingObject(json); - } - } - } - break; - } - - case 2415: // ASC_MENU_EVENT_TYPE_CHANGE_COLOR_SCHEME - { - if (undefined !== _params) { - var indexScheme = parseInt(_params); - _api.asc_ChangeColorSchemeByIdx(indexScheme); - } - break; - } - - case 2416: // ASC_MENU_EVENT_TYPE_GET_COLOR_SCHEME - { - var index = _api.asc_GetCurrentColorSchemeIndex(); - var stream = global_memory_stream_menu; - stream["ClearNoAttack"](); - stream["WriteLong"](index); - _return = stream; - break; - } - - case 8001: //ASC_PRESENTATIONS_EVENT_TYPE_ALL_TRANSITIONS - { - var aTransitions = []; - var slides = this.WordControl.m_oLogicDocument.Slides; - for(var i = 0; i < slides.length; ++i){ - aTransitions.push(slides[i].transition.ToArray()); - } - _return = aTransitions; - break; - } - - case 8111: // ASC_PRESENTATIONS_EVENT_TYPE_ADD_SLIDE - { - var index = parseInt(_params); - this.AddSlide(index); - break; - } - - case 8112: // ASC_PRESENTATIONS_EVENT_TYPE_DELETE_SLIDE - { - var oLogicDocument = this.WordControl.m_oLogicDocument; - var oCurSlide = oLogicDocument.Slides[oLogicDocument.CurPage]; - if(oCurSlide && oCurSlide.Layout && oCurSlide.Layout.Master) - { - oLogicDocument.lastMaster = oCurSlide.Layout.Master; - } - this.WordControl.m_oLogicDocument.deleteSlides(_params); - break; - } - - case 8113: // ASC_PRESENTATIONS_EVENT_TYPE_DUBLICATE_SLIDE - { - this.WordControl.m_oLogicDocument.shiftSlides(Math.max.apply(Math, _params) + 1, _params, true); - break; - } - - case 8114: // ASC_PRESENTATIONS_EVENT_TYPE_MOVE_SLIDE - { - var _stream = global_memory_stream_menu; - var nPos = _params[0]; - var aMoveArray = _params.slice(1); - this.WordControl.m_oDrawingDocument.LockEvents = true; - this.WordControl.m_oLogicDocument.CurPage = this.WordControl.m_oLogicDocument.shiftSlides(nPos, aMoveArray, false); - this.WordControl.m_oDrawingDocument.LockEvents = false; - this.WordControl.m_oDrawingDocument.UpdateThumbnailsAttack(); - _return = _stream; - break; - } - - case 8115: // ASC_PRESENTATIONS_EVENT_TYPE_HIDE_SLIDE - { - var bIsHide = this.WordControl.m_oLogicDocument.Slides[_params[0]].isVisible(); - var aHideArray = _params; - this.WordControl.m_oLogicDocument.hideSlides(bIsHide, aHideArray); - break; - } - - case 8116: //ASC_PRESENTATIONS_EVENT_TYPE_CHANGE_LAYOUT - { - this.ChangeLayout(parseInt(_params)) - break; - } - case 8117: //ASC_PRESENTATIONS_EVENT_TYPE_CHANGE_THEME - { - this.ChangeTheme(parseInt(_params), false); - break; - } - - case 8120: // ASC_PRESENTATIONS_EVENT_TYPE_CHANGE_LEVEL - { - var level = parseInt(_params); - - if (level == Asc.c_oAscDrawingLayerType.BringToFront) { - this.shapes_bringToFront(); - } else if (level == Asc.c_oAscDrawingLayerType.SendToBack) { - this.shapes_bringToBack(); - } else if (level == Asc.c_oAscDrawingLayerType.BringForward) { - this.shapes_bringForward(); - } else if (level == Asc.c_oAscDrawingLayerType.SendBackward) { - this.shapes_bringBackward(); - } - - break; - } - - case 8121: // ASC_PRESENTATIONS_EVENT_TYPE_SHAPE_ALIGN - { - var level = parseInt(_params); - - if (c_oAscAlignShapeType.ALIGN_LEFT == level) { - this.put_ShapesAlign(c_oAscAlignShapeType.ALIGN_LEFT); - } else if (c_oAscAlignShapeType.ALIGN_CENTER == level) { - this.put_ShapesAlign(c_oAscAlignShapeType.ALIGN_CENTER); - } else if (c_oAscAlignShapeType.ALIGN_RIGHT == level) { - this.put_ShapesAlign(c_oAscAlignShapeType.ALIGN_RIGHT); - } else if (c_oAscAlignShapeType.ALIGN_TOP == level) { - this.put_ShapesAlign(c_oAscAlignShapeType.ALIGN_TOP); - } else if (c_oAscAlignShapeType.ALIGN_MIDDLE == level) { - this.put_ShapesAlign(c_oAscAlignShapeType.ALIGN_MIDDLE); - } else if (c_oAscAlignShapeType.ALIGN_BOTTOM == level) { - this.put_ShapesAlign(c_oAscAlignShapeType.ALIGN_BOTTOM); - } else if (6 == level) { - this.DistributeHorizontally(); - } else if (7 == level) { - this.DistributeVertically(); - } - - break; - } - - case 8124: // ASC_PRESENTATIONS_EVENT_TYPE_SLIDE_TIMIN_GALL - { - this.SlideTransitionApplyToAll(); - break; - } - - case 8125: //ASC_PRESENTATIONS_EVENT_TYPE_PASTE_CONTENT_TYPE - { - if(_params[0]){ - var oPasteProcessor = new AscCommon.PasteProcessor(this, false, false, false); - var aContent = AscFormat.ExecuteNoHistory(function(){ - return oPasteProcessor._readPresentationSelectedContent2(_params[0]); - }, this, []); - if(Array.isArray(aContent) && aContent.length > 0){ - _return = aContent[0].getContentType(); - } - } - _return = 0; - break; - } - - case 5000: // ASC_MENU_EVENT_TYPE_GO_TO_INTERNAL_LINK - { - - var aStack = this.SelectedObjectsStack; - for(var i = 0; i < aStack.length; ++i){ - if(aStack[i].Type === Asc.c_oAscTypeSelectElement.Hyperlink){ - var value = aStack[i].Value && aStack[i].Value.Value; - if(value){ - this.sync_HyperlinkClickCallback(value); - } - break; - } - } - break; - } - - case 10000: // ASC_SOCKET_EVENT_TYPE_OPEN - { - this.CoAuthoringApi._CoAuthoringApi.socketio.onMessage("connect"); - break; - } - - case 10010: // ASC_SOCKET_EVENT_TYPE_ON_CLOSE - { - // NOT USED - break; - } - - case 10020: // ASC_SOCKET_EVENT_TYPE_MESSAGE - { - this.CoAuthoringApi._CoAuthoringApi.socketio.onMessage("message", _params ? JSON.parse(_params) : {}); - break; - } - - case 11010: // ASC_SOCKET_EVENT_TYPE_ON_DISCONNECT - { - this.CoAuthoringApi._CoAuthoringApi.socketio.onMessage("disconnect", _params || ""); - break; - } - - case 11020: // ASC_SOCKET_EVENT_TYPE_TRY_RECONNECT - { - // NOT USED - break; - } - case 21000: // ASC_COAUTH_EVENT_TYPE_INSERT_URL_IMAGE - { - var urls = JSON.parse(_params[0]); - AscCommon.g_oDocumentUrls.addUrls(urls); - var firstUrl; - for (var i in urls) { - if (urls.hasOwnProperty(i)) { - firstUrl = urls[i]; - break; - } - } - var oImageObject = {}; - oImageObject.src = firstUrl; - oImageObject.Image = {}; - oImageObject.Image.width = _params[1]; - oImageObject.Image.height = _params[2]; - this.WordControl.m_oLogicDocument.addImages([oImageObject]); - break; - } - - - case 21001: // ASC_COAUTH_EVENT_TYPE_LOAD_URL_IMAGE - { - if(this.RedrawTimer != null){ - clearTimeout(this.RedrawTimer); - } - var oThis = this; - this.RedrawTimer = setTimeout(function(){ - oThis.WordControl.m_oDrawingDocument.ClearCachePages(); - oThis.WordControl.m_oDrawingDocument.FirePaint(); - oThis.WordControl.m_oDrawingDocument.UpdateThumbnailsAttack(); - oThis.WordControl.m_oDrawingDocument.CheckThemes(); - oThis.WordControl.CheckLayouts(true); - oThis.RedrawTimer = null; - }, 1000); - break; - } - - case 21002: // ASC_COAUTH_EVENT_TYPE_REPLACE_URL_IMAGE - { - var urls = JSON.parse(_params[0]); - AscCommon.g_oDocumentUrls.addUrls(urls); - var firstUrl; - for (var i in urls) { - if (urls.hasOwnProperty(i)) { - firstUrl = urls[i]; - break; - } - } - - var _src = firstUrl; - - var imageProp = new Asc.asc_CImgProperty(); - imageProp.ImageUrl = _src; - this.ImgApply(imageProp); - this.WordControl.m_oLogicDocument.Recalculate(); - - break; - } - - case 22001: // ASC_MENU_EVENT_TYPE_SET_PASSWORD - { - this.asc_setDocumentPassword(_params[0]); - break; - } - - case 22004: // ASC_EVENT_TYPE_SPELLCHECK_MESSAGE - { - var spellData = JSON.parse(_params[0]); - if (this.SpellCheckApi && spellData) - this.SpellCheckApi.onSpellCheck(spellData); - break; - } - - case 22005: // ASC_EVENT_TYPE_SPELLCHECK_TURN_ON - { - var status = parseInt(_params[0]); - if (status !== undefined) { - this.asc_setSpellCheck(status == 0 ? false : true); - } - break; - } - - case 23101: // ASC_MENU_EVENT_TYPE_DO_SELECT_COMMENT - { - var json = JSON.parse(_params[0]); - if (json && json["id"]) { - var id = parseInt(json["id"]); - if (_api.asc_selectComment && id) { - _api.asc_selectComment(id); - } - } - break; - } - - case 23102: // ASC_MENU_EVENT_TYPE_DO_SHOW_COMMENT - { - var json = JSON.parse(params[0]); - if (json && json["id"]) { - if (_api.asc_showComment) { - _api.asc_showComment(json["id"], json["isNew"]); - } - } - break; - } - - case 23103: // ASC_MENU_EVENT_TYPE_DO_SELECT_COMMENTS - { - var json = JSON.parse(_params[0]); - if (json) { - if (_api.asc_showComments) { - _api.asc_showComments(json["resolved"] === true); - } - } - break; - } - - case 23104: // ASC_MENU_EVENT_TYPE_DO_DESELECT_COMMENTS - { - if (_api.asc_hideComments) { - _api.asc_hideComments(); - } - break; - } - - case 23105: // ASC_MENU_EVENT_TYPE_DO_ADD_COMMENT - { - var json = JSON.parse(_params[0]); - if (json) { - var buildCommentData = function () { - if (typeof Asc.asc_CCommentDataWord !== 'undefined') { - return new Asc.asc_CCommentDataWord(null); - } - return new Asc.asc_CCommentData(null); - }; - - var comment = buildCommentData(); - var now = new Date(); - var timeZoneOffsetInMs = (new Date()).getTimezoneOffset() * 60000; - var currentUserId = _internalStorage.externalUserInfo.asc_getId(); - var currentUserName = _internalStorage.externalUserInfo.asc_getFullName(); - - if (comment) { - comment.asc_putText(json["text"]); - comment.asc_putTime((now.getTime() - timeZoneOffsetInMs).toString()); - comment.asc_putOnlyOfficeTime(now.getTime().toString()); - comment.asc_putUserId(currentUserId); - comment.asc_putUserName(currentUserName); - comment.asc_putSolved(false); - - if (comment.asc_putDocumentFlag) { - comment.asc_putDocumentFlag(json["unattached"]); - } - - _api.asc_addComment(comment); - } - } - break; - } - - case 23106: // ASC_MENU_EVENT_TYPE_DO_REMOVE_COMMENT - { - var json = JSON.parse(_params[0]); - if (json && json["id"]) { // id - String - if (_api.asc_removeComment) { - _api.asc_removeComment(json["id"]); - } - } - break; - } - - case 23107: // ASC_MENU_EVENT_TYPE_DO_REMOVE_ALL_COMMENTS - { - var json = JSON.parse(_params[0]), - type = json["type"], - canEditComments = json["canEditComments"]; - if (json && type) { - if (_api.asc_RemoveAllComments) { - _api.asc_RemoveAllComments(type=='my' || !(canEditComments === true), type=='current'); // 1 param = true if remove only my comments, 2 param - remove current comments - } - } - break; - } - - case 23108: // ASC_MENU_EVENT_TYPE_DO_CHANGE_COMMENT - { - var json = JSON.parse(_params[0]), - commentId = json["id"], - comment = json["comment"], - updateAuthor = json["updateAuthor"] || false; - - if (json && commentId) { - var timeZoneOffsetInMs = (new Date()).getTimezoneOffset() * 60000; - var currentUserId = _internalStorage.externalUserInfo.asc_getId(); - var currentUserName = _internalStorage.externalUserInfo.asc_getFullName(); - var buildCommentData = function () { - if (typeof Asc.asc_CCommentDataWord !== 'undefined') { - return new Asc.asc_CCommentDataWord(null); - } - return new Asc.asc_CCommentData(null); - }; - var ooDateToString = function (date) { - if (Object.prototype.toString.call(date) === '[object Date]') - return (date.getTime()).toString(); - return ""; - }; - var utcDateToString = function (date) { - if (Object.prototype.toString.call(date) === '[object Date]') - return (date.getTime() - timeZoneOffsetInMs).toString(); - return ""; - }; - var ascComment = buildCommentData(); - - if (ascComment && comment && _api.asc_changeComment) { - var sTime = new Date(parseInt(comment["date"])); - ascComment.asc_putText(comment["text"]); - ascComment.asc_putQuoteText(comment["quoteText"]); - ascComment.asc_putTime(utcDateToString(sTime)); - ascComment.asc_putOnlyOfficeTime(ooDateToString(sTime)); - ascComment.asc_putUserId(updateAuthor ? currentUserId : comment["userId"]); - ascComment.asc_putUserName(updateAuthor ? currentUserName : comment["userName"]); - ascComment.asc_putSolved(comment["solved"]); - ascComment.asc_putGuid(comment["id"]); - - if (ascComment.asc_putDocumentFlag !== undefined) { - ascComment.asc_putDocumentFlag(comment["unattached"]); - } - - var replies = comment["replies"]; - - if (replies && replies.length) { - replies.forEach(function (reply) { - var addReply = buildCommentData(); // new asc_CCommentData(null); - if (addReply) { - var sTime = new Date(parseInt(reply["date"])); - addReply.asc_putText(reply["text"]); - addReply.asc_putTime(utcDateToString(sTime)); - addReply.asc_putOnlyOfficeTime(ooDateToString(sTime)); - addReply.asc_putUserId(reply["userId"]); - addReply.asc_putUserName(reply["userName"]); - - ascComment.asc_addReply(addReply); - } - }); - } - - _api.asc_changeComment(commentId, ascComment); - } - } - break; - } - - case 23109: // ASC_MENU_EVENT_TYPE_DO_CAN_ADD_QUOTED_COMMENT - { - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - _stream["WriteString2"](JSON.stringify({ - result: this.can_AddQuotedComment() - })); - _return = _stream; - break; - } - - case 25001: // ASC_MENU_EVENT_TYPE_DO_API_FUNCTION_CALL - { - var json = JSON.parse(_params[0]), - func = json["func"], - params = json["params"] || [], - returnable = json["returnable"] || false; // need return result - - if (json && func) { - if (_api[func]) { - if (returnable) { - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - var result = _api[func].apply(_api, params); - _stream["WriteString2"](JSON.stringify({ - result: result - })); - _return = _stream; - } else { - _api[func].apply(_api, params); - } - } - } - break; - } - - default: - break; - } - - return _return; -}; diff --git a/word/Native/DrawingDocument.js b/word/Native/DrawingDocument.js deleted file mode 100644 index 2064324df8..0000000000 --- a/word/Native/DrawingDocument.js +++ /dev/null @@ -1,3031 +0,0 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2023 - * - * This program is a free software product. You can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License (AGPL) - * version 3 as published by the Free Software Foundation. In accordance with - * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement - * of any third-party rights. - * - * This program is distributed WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ - -// Import -var FontStyle = AscFonts.FontStyle; -var g_fontApplication = AscFonts.g_fontApplication; - -var CColor = AscCommon.CColor; -var CAscMathCategory = AscCommon.CAscMathCategory; -var g_oTableId = AscCommon.g_oTableId; -var g_oTextMeasurer = AscCommon.g_oTextMeasurer; -var global_mouseEvent = AscCommon.global_mouseEvent; -var History = AscCommon.History; -var global_MatrixTransformer = AscCommon.global_MatrixTransformer; -var g_dKoef_pix_to_mm = AscCommon.g_dKoef_pix_to_mm; -var g_dKoef_mm_to_pix = AscCommon.g_dKoef_mm_to_pix; - -var _canvas_tables = null; -var _table_styles = null; - -function CColumnsMarkupColumn() -{ - this.W = 0; - this.Space = 0; -} - -function CColumnsMarkup() -{ - this.CurCol = 0; - this.X = 0; // левое поле - this.R = 0; // правое поле - - this.EqualWidth = true; - this.Num = 1; - this.Space = 30; - this.Cols = []; - - this.SectPr = null; - this.PageIndex = 0; -} -CColumnsMarkup.prototype.UpdateFromSectPr = function(oSectPr, nPageIndex) -{ - if (!oSectPr) - return; - - this.SectPr = oSectPr; - this.PageIndex = nPageIndex; - - var Columns = oSectPr.Columns; - - var oFrame = oSectPr.GetContentFrame(nPageIndex); - this.X = oFrame.Left; - this.R = oFrame.Right; - - this.EqualWidth = Columns.EqualWidth; - this.Num = Columns.Num; - this.Space = Columns.Space; - - this.Cols = []; - for (var Index = 0, Count = Columns.Cols.length; Index < Count; ++Index) - { - this.Cols[Index] = new CColumnsMarkupColumn(); - this.Cols[Index].W = Columns.Cols[Index].W; - this.Cols[Index].Space = Columns.Cols[Index].Space; - } -}; -CColumnsMarkup.prototype.SetCurCol = function(nCurCol) -{ - this.CurCol = nCurCol; -}; -CColumnsMarkup.prototype.CreateDuplicate = function () -{ - var _ret = new CColumnsMarkup(); - - _ret.PageIndex = this.PageIndex; - - _ret.SectPr = this.SectPr; - _ret.CurCol = this.CurCol; - _ret.X = this.X; - _ret.R = this.R; - - _ret.EqualWidth = this.EqualWidth; - _ret.Num = this.Num; - _ret.Space = this.Space; - - _ret.Cols = []; - - for (var i = 0; i < this.Cols.length; i++) - { - var _col = new CColumnsMarkupColumn(); - _col.W = this.Cols[i].W; - _col.Space = this.Cols[i].Space; - _ret.Cols.push(_col); - } - return _ret; -}; - -function CTableOutlineDr() -{ - this.image = {}; - this.image.width = 13; - this.image.height = 13; - - this.TableOutline = null; - this.Counter = 0; - this.bIsNoTable = true; - this.bIsTracked = false; - - this.CurPos = null; - this.TrackTablePos = 0; // 0 - left_top, 1 - right_top, 2 - right_bottom, 3 - left_bottom - this.TrackOffsetX = 0; - this.TrackOffsetY = 0; - - this.InlinePos = null; - - this.IsChangeSmall = true; - this.ChangeSmallPoint = null; - - this.TableMatrix = null; - this.CurrentPageIndex = null; - - // TABLE_STYLES - this.TableStylesLastLook = null; - this.TableStylesCheckLook = null; - this.TableStylesCheckLookFlag = false; - - this.TableStylesSendOne = false; - - this.Native = window["native"]; - - this.checkMouseDown = function(pos, drDoc) - { - if (null == this.TableOutline) - return false; - - var _table_track = this.TableOutline; - var _d = 13 / this.Native["DD_GetDotsPerMM"](); - - this.IsChangeSmall = true; - this.ChangeSmallPoint = pos; - - if (!this.TableMatrix || AscCommon.global_MatrixTransformer.IsIdentity(this.TableMatrix)) - { - switch (this.TrackTablePos) - { - case 1: - { - var _x = _table_track.X + _table_track.W; - var _b = _table_track.Y; - var _y = _b - _d; - var _r = _x + _d; - - if ((pos.X > _x) && (pos.X < _r) && (pos.Y > _y) && (pos.Y < _b)) - { - this.TrackOffsetX = pos.X - _x; - this.TrackOffsetY = pos.Y - _b; - return true; - } - return false; - } - case 2: - { - var _x = _table_track.X + _table_track.W; - var _y = _table_track.Y + _table_track.H; - var _r = _x + _d; - var _b = _y + _d; - - if ((pos.X > _x) && (pos.X < _r) && (pos.Y > _y) && (pos.Y < _b)) - { - this.TrackOffsetX = pos.X - _x; - this.TrackOffsetY = pos.Y - _y; - return true; - } - return false; - } - case 3: - { - var _r = _table_track.X; - var _x = _r - _d; - var _y = _table_track.Y + _table_track.H; - var _b = _y + _d; - - if ((pos.X > _x) && (pos.X < _r) && (pos.Y > _y) && (pos.Y < _b)) - { - this.TrackOffsetX = pos.X - _r; - this.TrackOffsetY = pos.Y - _y; - return true; - } - return false; - } - case 0: - default: - { - var _r = _table_track.X; - var _b = _table_track.Y; - var _x = _r - _d; - var _y = _b - _d; - - if ((pos.X > _x) && (pos.X < _r) && (pos.Y > _y) && (pos.Y < _b)) - { - this.TrackOffsetX = pos.X - _r; - this.TrackOffsetY = pos.Y - _b; - return true; - } - return false; - } - } - } - else - { - var _invert = AscCommon.global_MatrixTransformer.Invert(this.TableMatrix); - var _posx = _invert.TransformPointX(pos.X, pos.Y); - var _posy = _invert.TransformPointY(pos.X, pos.Y); - switch (this.TrackTablePos) - { - case 1: - { - var _x = _table_track.X + _table_track.W; - var _b = _table_track.Y; - var _y = _b - _d; - var _r = _x + _d; - - if ((_posx > _x) && (_posx < _r) && (_posy > _y) && (_posy < _b)) - { - this.TrackOffsetX = _posx - _x; - this.TrackOffsetY = _posy - _b; - return true; - } - return false; - } - case 2: - { - var _x = _table_track.X + _table_track.W; - var _y = _table_track.Y + _table_track.H; - var _r = _x + _d; - var _b = _y + _d; - - if ((_posx > _x) && (_posx < _r) && (_posy > _y) && (_posy < _b)) - { - this.TrackOffsetX = _posx - _x; - this.TrackOffsetY = _posy - _y; - return true; - } - return false; - } - case 3: - { - var _r = _table_track.X; - var _x = _r - _d; - var _y = _table_track.Y + _table_track.H; - var _b = _y + _d; - - if ((_posx > _x) && (_posx < _r) && (_posy > _y) && (_posy < _b)) - { - this.TrackOffsetX = _posx - _r; - this.TrackOffsetY = _posy - _y; - return true; - } - return false; - } - case 0: - default: - { - var _r = _table_track.X; - var _b = _table_track.Y; - var _x = _r - _d; - var _y = _b - _d; - - if ((_posx > _x) && (_posx < _r) && (_posy > _y) && (_posy < _b)) - { - this.TrackOffsetX = _posx - _r; - this.TrackOffsetY = _posy - _b; - return true; - } - return false; - } - } - } - - return false; - } - - this.checkMouseUp = function(X, Y, drDoc) - { - this.bIsTracked = false; - - if (null == this.TableOutline || (true === this.IsChangeSmall) || drDoc.Api.isViewMode) - return false; - - var _dKoef_mm_to_pix = this.Native["DD_GetDotsPerMM"](); - var _d = 13 / _dKoef_mm_to_pix; - - var _outline = this.TableOutline; - var _table = _outline.Table; - - _table.MoveCursorToStartPos(); - _table.Document_SetThisElementCurrent(true); - - if (!_table.Is_Inline()) - { - var pos; - switch (this.TrackTablePos) - { - case 1: - { - var _w_pix = this.TableOutline.W * _dKoef_mm_to_pix; - pos = drDoc.__DD_ConvertCoordsFromCursor(X - _w_pix, Y); - break; - } - case 2: - { - var _w_pix = this.TableOutline.W * _dKoef_mm_to_pix; - var _h_pix = this.TableOutline.H * _dKoef_mm_to_pix; - pos = drDoc.__DD_ConvertCoordsFromCursor(X - _w_pix, Y - _h_pix); - break; - } - case 3: - { - var _h_pix = this.TableOutline.H * _dKoef_mm_to_pix; - pos = drDoc.__DD_ConvertCoordsFromCursor(X, Y - _h_pix); - break; - } - case 0: - default: - { - pos = drDoc.__DD_ConvertCoordsFromCursor(X, Y); - break; - } - } - - var NearestPos = drDoc.LogicDocument.Get_NearestPos(pos.Page, pos.X - this.TrackOffsetX, pos.Y - this.TrackOffsetY); - _table.Move(pos.X - this.TrackOffsetX, pos.Y - this.TrackOffsetY, pos.Page, NearestPos); - _outline.X = pos.X - this.TrackOffsetX; - _outline.Y = pos.Y - this.TrackOffsetY; - _outline.PageNum = pos.Page; - } - else - { - if (null != this.InlinePos) - { - // inline move - _table.Move(this.InlinePos.X, this.InlinePos.Y, this.InlinePos.Page, this.InlinePos); - } - } - } - - this.checkMouseMove = function(X, Y, drDoc) - { - if (null == this.TableOutline) - return false; - - var _dKoef_mm_to_pix = this.Native["DD_GetDotsPerMM"](); - - if (true === this.IsChangeSmall) - { - var _pos = drDoc.__DD_ConvertCoordsFromCursor(X, Y); - var _dist = 15 / _dKoef_mm_to_pix; - if ((Math.abs(_pos.X - this.ChangeSmallPoint.X) < _dist) && (Math.abs(_pos.Y - this.ChangeSmallPoint.Y) < _dist) && (_pos.Page == this.ChangeSmallPoint.Page)) - { - this.CurPos = { X: this.ChangeSmallPoint.X, Y : this.ChangeSmallPoint.Y, Page: this.ChangeSmallPoint.Page }; - - switch (this.TrackTablePos) - { - case 1: - { - this.CurPos.X -= this.TableOutline.W; - break; - } - case 2: - { - this.CurPos.X -= this.TableOutline.W; - this.CurPos.Y -= this.TableOutline.H; - break; - } - case 3: - { - this.CurPos.Y -= this.TableOutline.H; - break; - } - case 0: - default: - { - break; - } - } - - this.CurPos.X -= this.TrackOffsetX; - this.CurPos.Y -= this.TrackOffsetY; - return; - } - this.IsChangeSmall = false; - - this.TableOutline.Table.RemoveSelection(); - editor.WordControl.m_oLogicDocument.Document_UpdateSelectionState(); - } - - var _d = 13 / _dKoef_mm_to_pix; - switch (this.TrackTablePos) - { - case 1: - { - var _w_pix = this.TableOutline.W * _dKoef_mm_to_pix; - this.CurPos = drDoc.__DD_ConvertCoordsFromCursor(X - _w_pix, Y); - break; - } - case 2: - { - var _w_pix = this.TableOutline.W * _dKoef_mm_to_pix; - var _h_pix = this.TableOutline.H * _dKoef_mm_to_pix; - this.CurPos = drDoc.__DD_ConvertCoordsFromCursor(X - _w_pix, Y - _h_pix); - break; - } - case 3: - { - var _h_pix = this.TableOutline.H * _dKoef_mm_to_pix; - this.CurPos = drDoc.__DD_ConvertCoordsFromCursor(X, Y - _h_pix); - break; - } - case 0: - default: - { - this.CurPos = drDoc.__DD_ConvertCoordsFromCursor(X, Y); - break; - } - } - - this.CurPos.X -= this.TrackOffsetX; - this.CurPos.Y -= this.TrackOffsetY; - } - - this.CheckStartTrack = function(drDoc, transform) - { - this.TableMatrix = null; - if (transform) - this.TableMatrix = transform.CreateDublicate(); - - var _bounds = this.Native["DD_GetControlSizes"](); - - if (!this.TableMatrix || AscCommon.global_MatrixTransformer.IsIdentity(this.TableMatrix)) - { - var pos = drDoc.__DD_ConvertCoordsToCursor(this.TableOutline.X, this.TableOutline.Y, this.TableOutline.PageNum); - - var _x0 = 0; - var _y0 = 0; - - if (pos.X < _x0 && pos.Y < _y0) - { - this.TrackTablePos = 2; - } - else if (pos.X < _x0) - { - this.TrackTablePos = 1; - } - else if (pos.Y < _y0) - { - this.TrackTablePos = 3; - } - else - { - this.TrackTablePos = 0; - } - } - else - { - var _x = this.TableOutline.X; - var _y = this.TableOutline.Y; - var _r = _x + this.TableOutline.W; - var _b = _y + this.TableOutline.H; - - var x0 = transform.TransformPointX(_x, _y); - var y0 = transform.TransformPointY(_x, _y); - - var x1 = transform.TransformPointX(_r, _y); - var y1 = transform.TransformPointY(_r, _y); - - var x2 = transform.TransformPointX(_r, _b); - var y2 = transform.TransformPointY(_r, _b); - - var x3 = transform.TransformPointX(_x, _b); - var y3 = transform.TransformPointY(_x, _b); - - var _x0 = 0; - var _y0 = 0; - var _x1 = _bounds[0]; - var _y1 = _bounds[1]; - - var pos0 = drDoc.__DD_ConvertCoordsToCursor(x0, y0, this.TableOutline.PageNum); - if (pos0.X > _x0 && pos0.X < _x1 && pos0.Y > _y0 && pos0.Y < _y1) - { - this.TrackTablePos = 0; - return; - } - - pos0 = drDoc.__DD_ConvertCoordsToCursor(x1, y1, this.TableOutline.PageNum); - if (pos0.X > _x0 && pos0.X < _x1 && pos0.Y > _y0 && pos0.Y < _y1) - { - this.TrackTablePos = 1; - return; - } - - pos0 = drDoc.__DD_ConvertCoordsToCursor(x3, y3, this.TableOutline.PageNum); - if (pos0.X > _x0 && pos0.X < _x1 && pos0.Y > _y0 && pos0.Y < _y1) - { - this.TrackTablePos = 3; - return; - } - - pos0 = drDoc.__DD_ConvertCoordsToCursor(x2, y2, this.TableOutline.PageNum); - if (pos0.X > _x0 && pos0.X < _x1 && pos0.Y > _y0 && pos0.Y < _y1) - { - this.TrackTablePos = 2; - return; - } - - this.TrackTablePos = 0; - } - } -} - -function CDrawingCollaborativeTarget(DrawingDocument) -{ - AscCommon.CDrawingCollaborativeTargetBase.call(this); - this.DrawingDocument = DrawingDocument; -} -CDrawingCollaborativeTarget.prototype = Object.create(AscCommon.CDrawingCollaborativeTargetBase.prototype); -CDrawingCollaborativeTarget.prototype.CheckPosition = function (_x, _y, _size, _page, _transform) -{ - this.Transform = _transform; - this.Size = _size; - this.X = _x; - this.Y = _y; - this.Page = _page; -}; -CDrawingCollaborativeTarget.prototype.Remove = function () -{ -}; -CDrawingCollaborativeTarget.prototype.Update = function () -{ -}; - -function CDrawingDocument() -{ - this.Native = window["native"]; - this.Api = window.editor; - this.m_oApi = this.Api; - - this.IsLockObjectsEnable = false; - this.LogicDocument = null; - this.m_bIsMouseLock = false; - - this.CanvasHitContext = CreateEmbedObject("CHitNativeEmbed"); - - this.m_dTargetSize = 0; - this.m_lCurrentPage = -1; - - this.Frame = null; - this.Table = null; - this.AutoShapesTrack = new AscCommon.CAutoshapeTrack(); - - this.m_oWordControl = this; - - this.IsUpdateOverlayOnlyEnd = false; - this.IsUpdateOverlayOnlyEndReturn = false; - this.IsUpdateOverlayOnEndCheck = false; - - this.UpdateTargetFromPaint = false; - this.UpdateTargetCheck = true; - - this.TargetPos = { X: 0, Y : 0, Page : -1 }; - - this.TargetShowNeedFlag = false; - this.TargetShowNeedFlag = false; - - this.m_bIsSelection = false; - this.m_bIsMouseLockDocument = false; - - this.IsKeyDownButNoPress = false; - this.bIsUseKeyPress = false; - - this.m_sLockedCursorType = ""; - - this.AutoShapesTrackLockPageNum = -1; - - // inline text track - this.InlineTextTrackEnabled = false; - this.InlineTextTrack = null; - this.InlineTextTrackPage = -1; - - // frame rect - this.FrameRect = { IsActive : false, Rect : { X : 0, Y : 0, R : 0, B : 0 }, Frame : null, - Track : { X : 0, Y : 0, L : 0, T : 0, R : 0, B : 0, PageIndex : 0, Type : -1 }, IsTracked : false, PageIndex : 0 }; - - // math rect - this.MathTrack = new AscCommon.CMathTrack(); - - // table track - this.TableOutlineDr = new CTableOutlineDr(); - - this.IsRetina = false; - this.IsMobile = false; - this.IsViewMode = false; - - this.SelectRect1 = null; - this.SelectRect2 = null; - this.SelectClearLock = false; - - this.SelectMobileXOffset = 0; - this.SelectMobileYOffset = 0; - this.SelectMobileConstantOffsetEpsilon = 1; - - this.SelectDrag = -1; - - this.UpdateRulerStateFlag = false; - this.UpdateRulerStateParams = []; - - this.CollaborativeTargets = []; - this.CollaborativeTargetsUpdateTasks = []; -} - -var _table_styles = null; - -CDrawingDocument.prototype = -{ - AfterLoad : function() - { - this.m_oWordControl = this; - this.Api = window.editor; - this.m_oApi = this.Api; - this.m_oApi.DocumentUrl = ""; - this.LogicDocument = window.editor.WordControl.m_oLogicDocument; - this.LogicDocument.DrawingDocument = this; - - this.selectionMatrix = null; - this.isSelectionMatrix = false; - }, - RenderPage : function(nPageIndex) - { - var _graphics = new CDrawingStream(); - this.LogicDocument.DrawPage(nPageIndex, _graphics); - }, - // init lock objects draw - Start_CollaborationEditing : function() - { - this.IsLockObjectsEnable = true; - this.Native["DD_Start_CollaborationEditing"](); - }, - - // cursor types - SetCursorType : function(sType, Data) - { - if ("" == this.m_sLockedCursorType) - this.Native["DD_SetCursorType"](sType, Data); - else - this.Native["DD_SetCursorType"](this.m_sLockedCursorType, Data); - }, - LockCursorType : function(sType) - { - this.m_sLockedCursorType = sType; - this.Native["DD_LockCursorType"](sType); - }, - LockCursorTypeCur : function() - { - this.m_sLockedCursorType = this.Native["DD_get_LockCursorType"](); - }, - UnlockCursorType : function() - { - this.m_sLockedCursorType = ""; - this.Native["DD_UnlockCursorType"](); - }, - - // calculatePages - OnStartRecalculate : function(pageCount) - { - this.Native["DD_OnStartRecalculate"](pageCount); - }, - OnRecalculatePage : function(index, pageObject) - { - this.TableOutlineDr.TableOutline = null; - - this.Native["DD_OnRecalculatePage"](index, pageObject.Width, pageObject.Height, - pageObject.Margins.Left, pageObject.Margins.Top, pageObject.Margins.Right, pageObject.Margins.Bottom); - }, - OnEndRecalculate : function(isFull, isBreak) - { - this.Native["DD_OnEndRecalculate"](isFull, isBreak); - }, - - // repaint pages - OnRepaintPage : function(index) - { - this.Native["DD_OnRepaintPage"](index); - }, - ChangePageAttack : function(pageIndex) - { - // unused function - }, - ClearCachePages : function() - { - this.Native["DD_ClearCachePages"](); - }, - - // is freeze - IsFreezePage : function(pageIndex) - { - if (this.Native["DD_IsFreezePage"](pageIndex)) - return true; - if (this.m_oLogicDocument) - { - if (pageIndex >= this.m_oLogicDocument.Pages.length) - return true; - else if (!this.m_oLogicDocument.CanDrawPage(pageIndex)) - return true; - } - return false; - }, - - RenderPageToMemory : function(pageIndex) - { - var _stream = new CDrawingStream(); - _stream.Native = this.Native["DD_GetPageStream"](); - this.LogicDocument.DrawPage(pageIndex, _stream); - return _stream.Native; - }, - - CheckRasterImageOnScreen : function(src, pageIndex) - { - if (!this.LogicDocument || !this.LogicDocument.DrawingObjects) - return false; - - var _imgs = this.LogicDocument.DrawingObject.getAllRasterImagesOnPage(i); - var _len = _imgs.length; - for (var j = 0; j < _len; j++) - { - if (_imgs[j] == src) - return true; - } - return false; - }, - - FirePaint : function() - { - this.Native["DD_FirePaint"](); - }, - - IsCursorInTableCur : function(x, y, page) - { - return this.Native["DD_IsCursorInTable"](x, y, page); - }, - - // convert coords - ConvertCoordsToCursorWR : function(x, y, pageIndex, transform) - { - var _return = null; - if (!transform) { - _return = this.__DD_ConvertCoordsToCursor(x, y, pageIndex); - } else { - _return = this.__DD_ConvertCoordsToCursor(x, y, pageIndex, transform.sx, transform.shy, transform.shx, transform.sy, transform.tx, transform.ty); - } - return { X : _return.X, Y : _return.Y, Error : _return.Error }; - }, - - ConvertCoordsToAnotherPage : function(x, y, pageCoord, pageNeed) - { - var _return = this.Native["DD_ConvertCoordsToAnotherPage"](x, y, pageCoord, pageNeed); - return { X : _return[0], Y : _return[1], Error : _return[2] }; - }, - - // target - TargetStart : function() - { - this.Native["DD_TargetStart"](); - this.TextMatrix = null; - }, - TargetEnd : function() - { - this.TargetShowFlag = false; - this.TargetShowNeedFlag = false; - this.Native["DD_TargetEnd"](); - }, - SetTargetColor : function(r, g, b) - { - this.Native["DD_SetTargetColor"](r, g, b); - }, - UpdateTargetTransform : function(matrix) - { - if (matrix) - { - if (null == this.TextMatrix) - this.TextMatrix = new AscCommon.CMatrix(); - this.TextMatrix.sx = matrix.sx; - this.TextMatrix.shy = matrix.shy; - this.TextMatrix.shx = matrix.shx; - this.TextMatrix.sy = matrix.sy; - this.TextMatrix.tx = matrix.tx; - this.TextMatrix.ty = matrix.ty; - - this.Native["DD_UpdateTargetTransform"](matrix.sx, matrix.shy, matrix.shx, matrix.sy, matrix.tx, matrix.ty); - } - else - { - this.TextMatrix = null; - this.Native["DD_RemoveTargetTransform"](); - } - }, - MultiplyTargetTransform: function (matrix) - { - if (!this.TextMatrix) { - - if (null == this.TextMatrix) { - this.TextMatrix = new AscCommon.CMatrix(); - } - - this.TextMatrix.sx = matrix.sx; - this.TextMatrix.shy = matrix.shy; - this.TextMatrix.shx = matrix.shx; - this.TextMatrix.sy = matrix.sy; - this.TextMatrix.tx = matrix.tx; - this.TextMatrix.ty = matrix.ty; - - this.Native["DD_UpdateTargetTransform"](matrix.sx, matrix.shy, matrix.shx, matrix.sy, matrix.tx, matrix.ty); - } else if (matrix) { - this.TextMatrix.Multiply(matrix, AscCommon.MATRIX_ORDER_PREPEND); - } - }, - UpdateTarget : function(x, y, pageIndex) - { - this.TargetPos.X = x; - this.TargetPos.Y = y; - this.TargetPos.Page = pageIndex; - this.m_lCurrentPage = pageIndex; - - this.LogicDocument.Set_TargetPos(x, y, pageIndex); - this.UpdateTargetCheck = true; - this.Native["DD_UpdateTarget"](x, y, pageIndex); - }, - SetTargetSize : function(size) - { - this.m_dTargetSize = size; - this.Native["DD_SetTargetSize"](size); - }, - TargetShow : function() - { - this.TargetShowNeedFlag = true; - this.Native["DD_TargetShow"](); - }, - CheckTargetShow : function() - { - return; - if (this.TargetShowFlag && this.TargetShowNeedFlag) - { - this.Native["DD_TargetShow"](); - this.TargetShowNeedFlag = false; - return; - } - - if (!this.TargetShowNeedFlag) - return; - - this.TargetShowNeedFlag = false; - - this.TargetStart(); - - this.Native["DD_TargetShow"](); - - this.TargetShowFlag = true; - }, - - // track images - StartTrackImage : function(obj, x, y, w, h, type, pagenum) - { - // unused function - }, - - // track tables - StartTrackTable : function(obj, transform) - { - this.TableOutlineDr.TableOutline = obj; - this.TableOutlineDr.Counter = 0; - this.TableOutlineDr.bIsNoTable = false; - this.TableOutlineDr.CheckStartTrack(this, transform); - }, - EndTrackTable : function(pointer, bIsAttack) - { - if (this.TableOutlineDr.TableOutline != null) - { - if (pointer == this.TableOutlineDr.TableOutline.Table || bIsAttack) - { - this.TableOutlineDr.TableOutline = null; - this.TableOutlineDr.Counter = 0; - } - } - }, - - CheckTrackTable : function() - { - if (null == this.TableOutlineDr.TableOutline) - return; - - if (this.TableOutlineDr.bIsNoTable && this.TableOutlineDr.bIsTracked === false) - { - this.TableOutlineDr.Counter++; - if (this.TableOutlineDr.Counter > 100) - { - this.TableOutlineDr.TableOutline = null; - this.OnUpdateOverlay(); - } - } - }, - - OnDrawContentControl : function(ctrl, state, rects) - {}, - - // current page - SetCurrentPage : function(PageIndex) - { - this.m_lCurrentPage = this.Native["DD_SetCurrentPage"](PageIndex); - }, - - // select - SelectEnabled : function(bIsEnabled) - { - this.m_bIsSelection = bIsEnabled; - if (false === this.m_bIsSelection) - { - this.SelectClear(); - this.OnUpdateOverlay(); - } - //this.Native["DD_SelectEnabled"](bIsEnabled); - }, - SelectClear : function() - { - if (!this.SelectClearLock) - { - this.SelectDrag = -1; - this.SelectRect1 = null; - this.SelectRect2 = null; - } - this.Native["DD_SelectClear"](); - }, - AddPageSelection : function(pageIndex, x, y, w, h) - { - this.selectionMatrix = this.TextMatrix; - - this.Native["DD_AddPageSelection"](pageIndex, x, y, w, h); - }, - OnSelectEnd : function() - { - // none - }, - - CheckSelectMobile : function() - { - this.SelectRect1 = null; - this.SelectRect2 = null; - - var _select = this.LogicDocument.GetSelectionBounds(); - if (!_select) - return; - - var _rect1 = _select.Start; - var _rect2 = _select.End; - - if (!_rect1 || !_rect2) - return; - - this.SelectRect1 = _rect1; - this.SelectRect2 = _rect2; - - this.Native["DD_DrawMobileSelection"](_rect1.X, _rect1.Y, _rect1.W, _rect1.H, _rect1.Page, - _rect2.X, _rect2.Y, _rect2.W, _rect2.H, _rect2.Page); - }, - - SelectShow : function() - { - this.OnUpdateOverlay(); - }, - - // search - StartSearchTransform : function(transform) - { - // TODO: - }, - - EndSearchTransform : function() - { - // TODO: - }, - - StartSearch : function() - { - this.Native["DD_StartSearch"](); - }, - EndSearch : function(bIsChange) - { - this.Native["DD_EndSearch"](bIsChange); - }, - - SetTextSelectionOutline : function(isSelectionOutline) - { - - }, - - // ruler states - Set_RulerState_Start : function() - { - this.UpdateRulerStateFlag = true; - }, - Set_RulerState_End : function() - { - if (this.UpdateRulerStateFlag) - { - this.UpdateRulerStateFlag = false; - if (this.UpdateRulerStateParams.length > 0) - { - switch (this.UpdateRulerStateParams[0]) - { - case 0: - { - this.Set_RulerState_Table(this.UpdateRulerStateParams[1], - this.UpdateRulerStateParams[2]); - break; - } - case 1: - { - this.Set_RulerState_Paragraph(this.UpdateRulerStateParams[1], - this.UpdateRulerStateParams[2]); - break; - } - case 2: - { - this.Set_RulerState_HdrFtr(this.UpdateRulerStateParams[1], - this.UpdateRulerStateParams[2], - this.UpdateRulerStateParams[3]); - break; - } - default: - break; - } - - this.UpdateRulerStateParams = []; - } - } - }, - - Set_RulerState_Table : function(markup, transform) - { - if (this.UpdateRulerStateFlag) - { - this.UpdateRulerStateParams.splice(0, this.UpdateRulerStateParams.length); - this.UpdateRulerStateParams.push(0); - this.UpdateRulerStateParams.push(markup); - this.UpdateRulerStateParams.push(transform); - return; - } - - this.FrameRect.IsActive = false; - this.Table = markup.Table; - - var _array_params1 = []; - _array_params1.push(markup.Internal.RowIndex); - _array_params1.push(markup.Internal.CellIndex); - _array_params1.push(markup.Internal.PageNum); - - _array_params1.push(markup.X); - - _array_params1.push(markup.CurCol); - _array_params1.push(markup.CurRow); - - this.TableOutlineDr.TableMatrix = null; - this.TableOutlineDr.CurrentPageIndex = this.m_lCurrentPage; - - if (transform) - { - _array_params1.push(transform.sx); - _array_params1.push(transform.shy); - _array_params1.push(transform.shx); - _array_params1.push(transform.sy); - _array_params1.push(transform.tx); - _array_params1.push(transform.ty); - - this.TableOutlineDr.TableMatrix = transform.CreateDublicate(); - } - - var _array_params_margins = []; - for (var i = 0; i < markup.Margins.length; i++) - { - _array_params_margins.push(markup.Margins[i].Left); - _array_params_margins.push(markup.Margins[i].Right); - } - - var _array_params_rows = []; - for (var i = 0; i < markup.Rows.length; i++) - { - _array_params_rows.push(markup.Rows[i].Y); - _array_params_rows.push(markup.Rows[i].H); - } - - this.Native["DD_Set_RulerState_Table"](_array_params1, markup.Cols, _array_params_margins, _array_params_rows); - }, - - Set_RulerState_Paragraph : function(margins, isCanTrackMargins) - { - if (this.UpdateRulerStateFlag) - { - this.UpdateRulerStateParams.splice(0, this.UpdateRulerStateParams.length); - this.UpdateRulerStateParams.push(1); - this.UpdateRulerStateParams.push(margins); - this.UpdateRulerStateParams.push(isCanTrackMargins); - return; - } - - if (margins && margins.Frame !== undefined) - { - var bIsUpdate = false; - - if (!this.FrameRect.IsActive) - bIsUpdate = true; - - if (!bIsUpdate) - { - if (this.FrameRect.Rect.X != margins.L || - this.FrameRect.Rect.Y != margins.T || - this.FrameRect.Rect.R != margins.R || - this.FrameRect.Rect.B != margins.B || - this.FrameRect.PageIndex != margins.PageIndex) - { - bIsUpdate = true; - } - } - - this.FrameRect.IsActive = true; - this.FrameRect.Rect.X = margins.L; - this.FrameRect.Rect.Y = margins.T; - this.FrameRect.Rect.R = margins.R; - this.FrameRect.Rect.B = margins.B; - this.FrameRect.PageIndex = margins.PageIndex; - this.FrameRect.Frame = margins.Frame; - - if (bIsUpdate) - { - this.OnUpdateOverlay(); - } - } - else - { - if (this.FrameRect.IsActive) - { - this.FrameRect.IsActive = false; - this.OnUpdateOverlay(); - } - else - this.FrameRect.IsActive = false; - } - - this.Table = null; - if (margins && margins.Frame) - { - this.Native["DD_Set_RulerState_Paragraph"](margins.L, margins.T, margins.R, margins.B, true, margins.PageIndex); - } - else if (margins) - { - this.Frame = null; - this.Native["DD_Set_RulerState_Paragraph"](margins.L, margins.T, margins.R, margins.B); - } - else - { - this.Frame = null; - this.Native["DD_Set_RulerState_Paragraph"](); - } - }, - - Set_RulerState_HdrFtr : function(bHeader, Y0, Y1) - { - if (this.UpdateRulerStateFlag) - { - this.UpdateRulerStateParams.splice(0, this.UpdateRulerStateParams.length); - this.UpdateRulerStateParams.push(2); - this.UpdateRulerStateParams.push(bHeader); - this.UpdateRulerStateParams.push(Y0); - this.UpdateRulerStateParams.push(Y1); - return; - } - - this.Frame = null; - this.Table = null; - this.Native["DD_Set_RulerState_HdrFtr"](bHeader, Y0, Y1); - }, - - Set_RulerState_Columns : function(markup) - { - // TODO: - }, - - Update_ParaInd : function(Ind) - { - var FirstLine = 0, - Left = 0, - Right = 0; - if ("undefined" != typeof(Ind)) - { - if ("undefined" != typeof(Ind.FirstLine)) - { - FirstLine = Ind.FirstLine; - } - if ("undefined" != typeof(Ind.Left)) - { - Left = Ind.Left; - } - if ("undefined" != typeof(Ind.Right)) - { - Right = Ind.Right; - } - } - - this.Native["DD_Update_ParaInd"](FirstLine, Left, Right); - }, - - Update_ParaTab : function(Default_Tab, ParaTabs) - { - var _arr_pos = []; - var _arr_types = []; - - var __tabs = ParaTabs.Tabs; - if (undefined === __tabs) - __tabs = ParaTabs; - - var _len = __tabs.length; - for (var i = 0; i < _len; i++) - { - if (__tabs[i].Value == tab_Left || __tabs[i].Value == tab_Center || __tabs[i].Value == tab_Right) - _arr_types.push(__tabs[i].Value); - else - _arr_types.push(tab_Left); - - _arr_pos.push(__tabs[i].Pos); - } - - this.Native["DD_Update_ParaTab"](Default_Tab, _arr_pos, _arr_types); - }, - - CorrectRulerPosition : function(pos) - { - if (AscCommon.global_keyboardEvent.AltKey) - return pos; - - return ((pos / 2.5 + 0.5) >> 0) * 2.5; - }, - - UpdateTableRuler : function(isCols, index, position) - { - this.Native["DD_UpdateTableRuler"](isCols, index, position); - }, - - // convert pixels - GetDotsPerMM : function(value) - { - return value * this.Native["DD_GetDotsPerMM"](); - }, - GetMMPerDot : function(value) - { - return value / this.GetDotsPerMM(1); - }, - GetVisibleMMHeight : function() - { - return this.Native["DD_GetVisibleMMHeight"](); - }, - - // вот оооочень важная функция. она выкидывает из кэша неиспользуемые шрифты - CheckFontCache : function() - { - var map_used = this.LogicDocument.Document_CreateFontMap(); - - for (var i in map_used) - { - this.Native["DD_CheckFontCacheAdd"](map_used[i].Name, map_used[i].Style, map_used[i].Size); - } - this.Native["DD_CheckFontCache"](); - }, - - // при загрузке документа - нужно понять какие шрифты используются - CheckFontNeeds : function() - { - }, - - BeginDrawTracking: function() - { - if (this.AutoShapesTrack.BeginDrawTracking) { - this.AutoShapesTrack.BeginDrawTracking(); - } - }, - - EndDrawTracking: function() - { - if (this.AutoShapesTrack.EndDrawTracking) { - this.AutoShapesTrack.EndDrawTracking(); - } - }, - - // треки - DrawTrack : function(type, matrix, left, top, width, height, isLine, canRotate, isNoMove, isDrawHandles) - { - this.AutoShapesTrack.DrawTrack(type, matrix, left, top, width, height, isLine, canRotate, isNoMove, isDrawHandles); - }, - DrawTrackSelectShapes : function(x, y, w, h) - { - this.AutoShapesTrack.DrawTrackSelectShapes(x, y, w, h); - }, - DrawAdjustment : function(matrix, x, y) - { - this.AutoShapesTrack.DrawAdjustment(matrix, x, y); - }, - - LockTrackPageNum : function(nPageNum) - { - this.AutoShapesTrackLockPageNum = nPageNum; - //this.Native["DD_AutoShapesTrackLockPageNum"](nPageNum); - }, - UnlockTrackPageNum : function() - { - this.AutoShapesTrackLockPageNum = -1; - //this.Native["DD_AutoShapesTrackLockPageNum"](-1); - }, - - IsMobileVersion : function() - { - return this.IsMobile; - }, - - DrawVerAnchor : function(pageNum, xPos) - { - this.Native["DD_DrawVerAnchor"](pageNum, xPos); - }, - DrawHorAnchor : function(pageNum, yPos) - { - this.Native["DD_DrawHorAnchor"](pageNum, yPos); - }, - - // track text (inline) - StartTrackText : function() - { - this.InlineTextTrackEnabled = true; - this.InlineTextTrack = null; - this.InlineTextTrackPage = -1; - this.Native["DD_StartTrackText"](); - }, - EndTrackText : function() - { - this.InlineTextTrackEnabled = false; - - this.LogicDocument.OnEndTextDrag(this.InlineTextTrack, AscCommon.global_keyboardEvent.CtrlKey); - this.InlineTextTrack = null; - this.InlineTextTrackPage = -1; - this.Native["DD_EndTrackText"](); - }, - - // html page - StartUpdateOverlay : function() - { - this.IsUpdateOverlayOnlyEnd = true; - }, - EndUpdateOverlay : function() - { - if (this.IsUpdateOverlayOnlyEndReturn) - return; - - this.IsUpdateOverlayOnlyEnd = false; - if (this.IsUpdateOverlayOnEndCheck) - this.OnUpdateOverlay(); - - this.IsUpdateOverlayOnEndCheck = false; - }, - OnUpdateOverlay : function() - { - this.isSelectionMatrix = false; - - if (this.IsUpdateOverlayOnlyEnd) - { - this.IsUpdateOverlayOnEndCheck = true; - return false; - } - - this.Native["DD_Overlay_UpdateStart"](); - - this.Native["DD_Overlay_Clear"](); - - var drawingFirst = this.Native["GetDrawingFirstPage"](); - var drawingEnd = this.Native["GetDrawingEndPage"](); - - if (-1 == drawingFirst || -1 == drawingEnd) - { - this.Native["DD_Overlay_UpdateEnd"](); - return true; - } - - if (this.m_bIsSelection) - { - this.Native["DD_Overlay_StartDrawSelection"](); - - for (var i = drawingFirst; i <= drawingEnd; i++) - { - if (!this.IsFreezePage(i)) - this.LogicDocument.DrawSelectionOnPage(i); - } - - this.Native["DD_Overlay_EndDrawSelection"](); - - if (this.IsMobile) - this.CheckSelectMobile(); - } - - var _table_outline = this.TableOutlineDr.TableOutline; - if (_table_outline != null) - { - var _page = _table_outline.PageNum; - if (_page >= drawingFirst && _page <= drawingEnd) - { - var _m = this.TableOutlineDr.TableMatrix; - if (!_m) - { - this.Native["DD_Overlay_DrawTableOutline"](_page, _table_outline.TrackTablePos, - _table_outline.X, _table_outline.Y, _table_outline.W, _table_outline.H); - } - else - { - this.Native["DD_Overlay_DrawTableOutline"](_page, _table_outline.TrackTablePos, - _table_outline.X, _table_outline.Y, _table_outline.W, _table_outline.H, - _m.sx, _m.shy, _m.shx, _m.sy, _m.tx, _m.ty); - - } - } - } - - // drawShapes (+ track) - if (this.LogicDocument.DrawingObjects) - { - for (var indP = drawingFirst; indP <= drawingEnd; indP++) - { - this.AutoShapesTrack.SetPageIndexSimple(indP); - this.LogicDocument.DrawingObjects.drawSelect(indP); - } - - this.AutoShapesTrack.SetCurrentPage(-100); - if (this.LogicDocument.DrawingObjects.needUpdateOverlay()) - { - this.AutoShapesTrack.PageIndex = -1; - this.LogicDocument.DrawingObjects.drawOnOverlay(this.AutoShapesTrack); - this.AutoShapesTrack.CorrectOverlayBounds(); - } - this.AutoShapesTrack.SetCurrentPage(-101); - } - - if (this.TableOutlineDr.bIsTracked) - { - this.DrawTableTrack(); - } - - this.DrawFrameTrack(); - this.DrawMathTrack(); - this.DrawFieldTrack(); - - if (this.InlineTextTrackEnabled && null != this.InlineTextTrack) - { - this.AutoShapesTrack.SetCurrentPage(this.InlineTextTrackPage); - this.AutoShapesTrack.DrawInlineMoveCursor(this.InlineTextTrack.X, this.InlineTextTrack.Y, this.InlineTextTrack.Height, - this.InlineTextTrack.transform); - } - - this.Collaborative_TargetsUpdate(); - - this.Native["DD_Overlay_DrawHorVerAnchor"](); - - this.Native["DD_Overlay_UpdateEnd"](); - - return true; - }, - - LogicDocumentOnMouseDown : function(e, x, y, page) - { - if (this.m_bIsMouseLockDocument) - { - this.LogicDocument.OnMouseUp(e, x, y, page); - this.m_bIsMouseLockDocument = false; - } - this.LogicDocument.OnMouseDown(e, x, y, page); - this.m_bIsMouseLockDocument = true; - }, - LogicDocumentOnMouseUp : function(e, x, y, page) - { - if (!this.m_bIsMouseLockDocument) - { - this.LogicDocument.OnMouseDown(e, x, y, page); - this.m_bIsMouseLockDocument = true; - } - this.LogicDocument.OnMouseUp(e, x, y, page); - this.m_bIsMouseLockDocument = false; - }, - - OnCheckMouseDown : function(e) - { - // 0 - none - // 1 - select markers - // 2 - drawing track - - var matrixCheck = this.selectionMatrix; // this.TextMatrix - - check_MouseDownEvent(e, false); - - var pos = null; - if (this.AutoShapesTrackLockPageNum == -1) - pos = this.__DD_ConvertCoordsFromCursor(global_mouseEvent.X, global_mouseEvent.Y); - else - pos = this.__DD_ConvetToPageCoords(global_mouseEvent.X, global_mouseEvent.Y, this.AutoShapesTrackLockPageNum); - - if (pos.Page == -1) - return 0; - - this.SelectDrag = -1; - if (this.SelectRect1 && this.SelectRect2) - { - // проверям попадание в селект - var radiusMM = 5; - if (this.IsRetina) - radiusMM *= 2; - radiusMM /= this.Native["DD_GetDotsPerMM"](); - - var _circlePos1_x = 0; - var _circlePos1_y = 0; - var _circlePos2_x = 0; - var _circlePos2_y = 0; - - if (!matrixCheck) - { - _circlePos1_x = this.SelectRect1.X; - _circlePos1_y = this.SelectRect1.Y - radiusMM; - - _circlePos2_x = this.SelectRect2.X + this.SelectRect2.W; - _circlePos2_y = this.SelectRect2.Y + this.SelectRect2.H + radiusMM; - } - else - { - var _circlePos1_x_mem = this.SelectRect1.X; - var _circlePos1_y_mem = this.SelectRect1.Y - radiusMM; - - var _circlePos2_x_mem = this.SelectRect2.X + this.SelectRect2.W; - var _circlePos2_y_mem = this.SelectRect2.Y + this.SelectRect2.H + radiusMM; - - _circlePos1_x = matrixCheck.TransformPointX(_circlePos1_x_mem, _circlePos1_y_mem); - _circlePos1_y = matrixCheck.TransformPointY(_circlePos1_x_mem, _circlePos1_y_mem); - _circlePos2_x = matrixCheck.TransformPointX(_circlePos2_x_mem, _circlePos2_y_mem); - _circlePos2_y = matrixCheck.TransformPointY(_circlePos2_x_mem, _circlePos2_y_mem); - } - - var _selectCircleEpsMM = 10; // 1cm; - var _selectCircleEpsMM_square = _selectCircleEpsMM * _selectCircleEpsMM; - - var _distance1 = ((pos.X - _circlePos1_x) * (pos.X - _circlePos1_x) + (pos.Y - _circlePos1_y) * (pos.Y - _circlePos1_y)); - var _distance2 = ((pos.X - _circlePos2_x) * (pos.X - _circlePos2_x) + (pos.Y - _circlePos2_y) * (pos.Y - _circlePos2_y)); - - var candidate = 1; - if (_distance2 < _distance1) - candidate = 2; - - - if (1 == candidate && _distance1 < _selectCircleEpsMM_square) - { - this.SelectClearLock = true; - this.SelectDrag = 1; - this.LogicDocument.MoveCursorRight(); - - var _xStamp = this.SelectRect1.X; - var _yStamp = this.SelectRect1.Y; - if (matrixCheck) - { - _xStamp = matrixCheck.TransformPointX(this.SelectRect1.X, this.SelectRect1.Y); - _yStamp = matrixCheck.TransformPointY(this.SelectRect1.X, this.SelectRect1.Y); - } - - var ret = this.__DD_ConvertCoordsToCursor(_xStamp, _yStamp, this.SelectRect1.Page); - var ret2 = this.CorrectMouseSelectPosition(Math.min(this.SelectMobileConstantOffsetEpsilon, this.SelectRect1.H / 2)); - this.SelectMobileXOffset = (ret.X + ret2.X) - global_mouseEvent.X; - this.SelectMobileYOffset = (ret.Y + ret2.Y) - global_mouseEvent.Y; - - var pos = this.GetMouseMoveCoords(); - if (pos.Page == -1) - return; - - var _oldShift = global_mouseEvent.ShiftKey; - global_mouseEvent.ShiftKey = true; - this.LogicDocumentOnMouseDown(global_mouseEvent, pos.X, pos.Y, pos.Page); - this.LogicDocumentOnMouseUp(global_mouseEvent, pos.X, pos.Y, pos.Page); - global_mouseEvent.ShiftKey = _oldShift; - - this.SelectClearLock = false; - } - - if (2 == candidate && _distance2 < _selectCircleEpsMM_square) - { - this.SelectClearLock = true; - this.SelectDrag = 2; - this.LogicDocument.MoveCursorLeft(); - - var _xStamp = this.SelectRect2.X + this.SelectRect2.W; - var _yStamp = this.SelectRect2.Y + this.SelectRect2.H; - if (matrixCheck) - { - var _xTmp = _xStamp; - _xStamp = matrixCheck.TransformPointX(_xTmp, _yStamp); - _yStamp = matrixCheck.TransformPointY(_xTmp, _yStamp); - } - - var ret = this.__DD_ConvertCoordsToCursor(_xStamp, _yStamp, this.SelectRect2.Page); - var ret2 = this.CorrectMouseSelectPosition(Math.min(this.SelectMobileConstantOffsetEpsilon, this.SelectRect2.H / 2)); - this.SelectMobileXOffset = (ret.X - ret2.X) - global_mouseEvent.X; - this.SelectMobileYOffset = (ret.Y - ret2.Y) - global_mouseEvent.Y; - - var pos = this.GetMouseMoveCoords(); - if (pos.Page == -1) - return; - - var _oldShift = global_mouseEvent.ShiftKey; - global_mouseEvent.ShiftKey = true; - this.LogicDocumentOnMouseDown(global_mouseEvent, pos.X, pos.Y, pos.Page); - this.LogicDocumentOnMouseUp(global_mouseEvent, pos.X, pos.Y, pos.Page); - global_mouseEvent.ShiftKey = _oldShift; - - this.SelectClearLock = false; - } - - if (this.SelectDrag != -1) - return 1; - } - - if (true) - { - // проверям н]а попадание в графические объекты (грубо говоря - треки) - if (!this.IsViewMode) - { - global_mouseEvent.KoefPixToMM = 5; - - if (this.Native["GetDeviceDPI"]) - { - // 1см - global_mouseEvent.AscHitToHandlesEpsilon = 5 * this.Native["GetDeviceDPI"]() / (25.4 * this.Native["DD_GetDotsPerMM"]() ); - } - - var _isDrawings = this.LogicDocument.DrawingObjects.isPointInDrawingObjects2(pos.X, pos.Y, pos.Page, true); - - if (_isDrawings) { - this.OnMouseDown(e); - } - - global_mouseEvent.KoefPixToMM = 1; - - if (_isDrawings) - return 2; - } - } - - return 0; - }, - - OnMouseDown : function(e) - { - check_MouseDownEvent(e, true); - - // у Илюхи есть проблема при вводе с клавы, пока нажата кнопка мыши - if ((0 == global_mouseEvent.Button) || (undefined == global_mouseEvent.Button)) - this.m_bIsMouseLock = true; - - this.StartUpdateOverlay(); - - if ((0 == global_mouseEvent.Button) || (undefined == global_mouseEvent.Button)) - { - var pos = null; - if (this.AutoShapesTrackLockPageNum == -1) - pos = this.__DD_ConvertCoordsFromCursor(global_mouseEvent.X, global_mouseEvent.Y); - else - pos = this.__DD_ConvetToPageCoords(global_mouseEvent.X, global_mouseEvent.Y, this.AutoShapesTrackLockPageNum); - - if (pos.Page == -1) - { - this.EndUpdateOverlay(); - return; - } - - if (this.IsFreezePage(pos.Page)) - { - this.EndUpdateOverlay(); - return; - } - - // теперь проверить трек таблиц - /* - var ret = this.Native["checkMouseDown_Drawing"](pos.X, pos.Y, pos.Page); - if (ret === true) - return; - */ - var is_drawing = this.checkMouseDown_Drawing(pos); - if (is_drawing === true) { - return; - } - - this.Native["DD_NeedScrollToTargetFlag"](true); - this.LogicDocumentOnMouseDown(global_mouseEvent, pos.X, pos.Y, pos.Page); - this.Native["DD_NeedScrollToTargetFlag"](false); - } - - this.Native["DD_CheckTimerScroll"](true); - this.EndUpdateOverlay(); - }, - - OnMouseUp : function(e) - { - check_MouseUpEvent(e); - - var pos = this.GetMouseMoveCoords(); - var _is_select = false; - if (this.SelectDrag == 1 || this.SelectDrag == 2) - { - _is_select = true; - } - this.SelectDrag = -1; - - if (pos.Page == -1) - return this.CheckReturnMouseUp(); - - if (this.IsFreezePage(pos.Page)) - return this.CheckReturnMouseUp(); - - this.UnlockCursorType(); - - this.StartUpdateOverlay(); - - // восстанавливаем фокус - this.m_bIsMouseLock = false; - - /* - var is_drawing = this.Native["checkMouseUp_Drawing"](pos.X, pos.Y, pos.Page); - if (is_drawing === true) - return; - */ - var is_drawing = this.checkMouseUp_Drawing(pos); - if (is_drawing === true) - return this.CheckReturnMouseUp(); - - this.Native["DD_CheckTimerScroll"](false); - - this.Native.m_bIsMouseUpSend = true; - - this.Native["DD_NeedScrollToTargetFlag"](true); - - if (_is_select) - { - var _oldShift = global_mouseEvent.ShiftKey; - global_mouseEvent.ShiftKey = true; - this.LogicDocumentOnMouseDown(global_mouseEvent, pos.X, pos.Y, pos.Page); - this.LogicDocumentOnMouseUp(global_mouseEvent, pos.X, pos.Y, pos.Page); - global_mouseEvent.ShiftKey = _oldShift; - } - else - { - this.LogicDocumentOnMouseUp(global_mouseEvent, pos.X, pos.Y, pos.Page); - } - this.Native["DD_NeedScrollToTargetFlag"](false); - - this.Native.m_bIsMouseUpSend = false; - this.LogicDocument.Document_UpdateInterfaceState(); - this.LogicDocument.Document_UpdateRulersState(); - - this.EndUpdateOverlay(); - return this.CheckReturnMouseUp(); - }, - - OnMouseMove : function(e) - { - check_MouseMoveEvent(e); - - var pos = this.GetMouseMoveCoords(); - if (pos.Page == -1) - return; - - if (this.IsFreezePage(pos.Page)) - return; - - if (this.m_sLockedCursorType != "") - this.SetCursorType("default"); - - this.StartUpdateOverlay(); - - /* - var is_drawing = this.Native["checkMouseMove_Drawing"](pos.X, pos.Y, pos.Page); - if (is_drawing === true) - return; - */ - var is_drawing = this.checkMouseMove_Drawing(pos); - if (is_drawing === true) - return; - - this.TableOutlineDr.bIsNoTable = true; - - if (this.SelectDrag == 1 || this.SelectDrag == 2) - { - this.SelectClearLock = true; - var _oldShift = global_mouseEvent.ShiftKey; - global_mouseEvent.ShiftKey = true; - this.LogicDocumentOnMouseDown(global_mouseEvent, pos.X, pos.Y, pos.Page); - this.LogicDocumentOnMouseUp(global_mouseEvent, pos.X, pos.Y, pos.Page); - global_mouseEvent.ShiftKey = _oldShift; - this.SelectClearLock = false; - } - else - { - this.LogicDocument.OnMouseMove(global_mouseEvent, pos.X, pos.Y, pos.Page); - } - - if (this.TableOutlineDr.bIsNoTable === false) - { - // TODO: нужно посмотреть, может в ЭТОМ же месте трек для таблицы уже нарисован - this.OnUpdateOverlay(); - } - - this.EndUpdateOverlay(); - }, - - GetMouseMoveCoords : function() - { - if (this.SelectDrag == 1 || this.SelectDrag == 2) - { - // global_mouseEvent.X += this.SelectMobileXOffset; - // global_mouseEvent.Y += this.SelectMobileYOffset; - } - - var pos = null; - if (this.AutoShapesTrackLockPageNum == -1) - pos = this.__DD_ConvertCoordsFromCursor(global_mouseEvent.X, global_mouseEvent.Y); - else - pos = this.__DD_ConvetToPageCoords(global_mouseEvent.X, global_mouseEvent.Y, this.AutoShapesTrackLockPageNum); - - return pos; - }, - - CorrectMouseSelectPosition : function(eps) - { - var xOff = 0; - var yOff = 1; - - if (null != this.selectionMatrix) - { - var xOff1 = this.selectionMatrix.TransformPointX(0, 0); - var yOff1 = this.selectionMatrix.TransformPointY(0, 0); - var xOff2 = this.selectionMatrix.TransformPointX(0, 1); - var yOff2 = this.selectionMatrix.TransformPointY(0, 1); - - // по идее скэйла нет. но на всякий - var _len = Math.sqrt((xOff1 - xOff2) * (xOff1 - xOff2) + (yOff1 - yOff2) * (yOff1 - yOff2)); - if (_len < 0.01) - _len = 0.01; - - xOff = (xOff2 - xOff1) / _len; - yOff = (yOff2 - yOff1) / _len; - } - - var _pixelsH = this.GetDotsPerMM(eps); - return { X : xOff * _pixelsH, Y : yOff * _pixelsH }; - }, - - CheckReturnMouseUp : function() - { - // return: array - // first: type (0 - none, 1 - onlytarget, 2 - select, 3 - tracks) - // type = 0: none - // type = 1: (double)x, (double)y, (int)page, [option: transform (6 double values)] - // type = 2: (double)x1, (double)y1, (int)page1, (double)x2, (double)y2, (int)page2, [option: transform (6 double values)] - // type = 3: (double)x, (double)y, (double)w, (double)h, (int)page, [option: transform (6 double values)] - - var _ret = []; - _ret.push(0); - - this.SelectRect1 = null; - this.SelectRect2 = null; - - var _target = this.LogicDocument.IsSelectionUse(); - if (_target === false) - { - _ret[0] = 1; - - _ret.push(this.TargetPos.X); - _ret.push(this.TargetPos.Y); - _ret.push(this.TargetPos.Page); - - if (this.selectionMatrix && !this.selectionMatrix.IsIdentity()) - { - _ret.push(this.selectionMatrix.sx); - _ret.push(this.selectionMatrix.shy); - _ret.push(this.selectionMatrix.shx); - _ret.push(this.selectionMatrix.sy); - _ret.push(this.selectionMatrix.tx); - _ret.push(this.selectionMatrix.ty); - } - - return _ret; - } - - var _select = this.LogicDocument.GetSelectionBounds(); - if (_select) - { - _ret[0] = 2; - var _rect1 = _select.Start; - var _rect2 = _select.End; - - this.SelectRect1 = _rect1; - this.SelectRect2 = _rect2; - - var _x1 = _rect1.X; - var _y1 = _rect1.Y; - var _y11 = _rect1.Y + _rect2.H; - var _x2 = _rect2.X + _rect2.W; - var _y2 = _rect2.Y; - var _y22 = _rect2.Y + _rect2.Y; - - var _eps = 0.0001; - if (Math.abs(_x1 - _x2) < _eps && - Math.abs(_y1 - _y2) < _eps && - Math.abs(_y11 - _y22) < _eps) - { - _ret[0] = 0; - } - else - { - _ret.push(_select.Start.X); - _ret.push(_select.Start.Y); - _ret.push(_select.Start.Page); - _ret.push(_select.End.X + _select.End.W); - _ret.push(_select.End.Y + _select.End.H); - _ret.push(_select.End.Page); - - if (this.selectionMatrix && !this.selectionMatrix.IsIdentity()) - { - _ret.push(this.selectionMatrix.sx); - _ret.push(this.selectionMatrix.shy); - _ret.push(this.selectionMatrix.shx); - _ret.push(this.selectionMatrix.sy); - _ret.push(this.selectionMatrix.tx); - _ret.push(this.selectionMatrix.ty); - } - - return _ret; - } - } - - var _object_bounds = this.LogicDocument.DrawingObjects.getSelectedObjectsBounds(); - if (_object_bounds) - { - _ret[0] = 3; - _ret.push(_object_bounds.minX); - _ret.push(_object_bounds.minY); - _ret.push(_object_bounds.maxX); - _ret.push(_object_bounds.maxY); - _ret.push(_object_bounds.pageIndex); - - return _ret; - } - - return _ret; - }, - - OnKeyDown : function(e) - { - check_KeyboardEvent(e); - - this.StartUpdateOverlay(); - - this.IsKeyDownButNoPress = true; - this.bIsUseKeyPress = (this.LogicDocument.OnKeyDown(AscCommon.global_keyboardEvent) === true) ? false : true; - - this.EndUpdateOverlay(); - }, - - OnKeyUp : function(e) - { - AscCommon.global_keyboardEvent.AltKey = false; - AscCommon.global_keyboardEvent.CtrlKey = false; - AscCommon.global_keyboardEvent.ShiftKey = false; - }, - - OnKeyPress : function(e) - { - if (false === this.bIsUseKeyPress) - return; - - check_KeyboardEvent(e); - - this.StartUpdateOverlay(); - var retValue = this.LogicDocument.OnKeyPress(AscCommon.global_keyboardEvent); - this.EndUpdateOverlay(); - return retValue; - }, - - OnKeyboardEvent : function(_params) - { - var _len = _params.length / 4; - - //this.LogicDocument.TurnOff_Recalculate(); - // если выключить - падает на некоторых документах. Например в списке если заселектить - // несколько параграфов и ввести букву - - this.LogicDocument.TurnOff_InterfaceEvents(); - - this.StartUpdateOverlay(); - - for (var i = 0; i < _len; i++) - { - var _offset = i * 4; - switch (_params[_offset]) - { - case 4: // down - { - this.IsKeyDownButNoPress = true; - check_KeyboardEvent_Array(_params, _offset); - this.bIsUseKeyPress = (this.LogicDocument.OnKeyDown(AscCommon.global_keyboardEvent) === true) ? false : true; - break; - } - case 5: // Press - { - this.StartUpdateOverlay(); - check_KeyboardEvent_Array(_params, _offset); - this.LogicDocument.OnKeyPress(AscCommon.global_keyboardEvent); - break; - } - case 6: // up - { - AscCommon.global_keyboardEvent.AltKey = false; - AscCommon.global_keyboardEvent.CtrlKey = false; - AscCommon.global_keyboardEvent.ShiftKey = false; - break; - } - default: - break; - } - } - - this.EndUpdateOverlay(); - - //this.LogicDocument.TurnOn_Recalculate(true); - this.LogicDocument.TurnOn_InterfaceEvents(true); - }, - - __DD_ConvertCoordsFromCursor : function(x, y) - { - var pos = this.Native["DD_ConvertCoordsFromCursor"](x, y); - return { X : pos["X"], Y : pos["Y"], Page : pos["Page"] }; - }, - - __DD_ConvertCoordsToCursor : function(x, y, page) - { - var _arr = window["native"]["DD_ConvertCoordsToCursor"](x, y, page); - return { X : _arr[0], Y : _arr[1], Error : _arr[2] }; - }, - - __DD_ConvetToPageCoords : function(x, y, page) - { - var pos = window["native"]["DD_ConvetToPageCoords"](x, y, page); - return { X : pos["X"], Y : pos["Y"], Page : pos["Page"] }; - }, - - /////////////////////////////////////////// - StartTableStylesCheck : function() - { - this.TableStylesCheckLookFlag = true; - }, - - EndTableStylesCheck : function() - { - this.TableStylesCheckLookFlag = false; - if (this.TableStylesCheckLook != null) - { - this.CheckTableStyles(this.TableStylesCheckLook); - this.TableStylesCheckLook = null; - } - }, - - CheckTableStylesOne : function() - { - let oTableLook = new AscCommon.CTableLook(true, true, false, false, true, false); - this.CheckTableStyles(oTableLook); - - this.TableStylesSendOne = true; - }, - - CheckTableStyles : function(tableLook) - { - if (true === this.TableStylesSendOne) - return; - - if (this.TableStylesCheckLookFlag) - { - this.TableStylesCheckLook = tableLook; - return; - } - - // сначала проверим, подписан ли кто на этот евент - // а то во вьюере не стоит ничего посылать - - /* - TODO: - if (!this.m_oWordControl.m_oApi.asc_checkNeedCallback("asc_onInitTableTemplates")) - return; - */ - - let isChanged = false; - - if (!this.TableStylesLastLook || !this.TableStylesLastLook.IsEqual(tableLook)) - { - this.TableStylesLastLook = tableLook.Copy(); - isChanged = true; - } - - if (!isChanged) - return; - - var logicDoc = this.m_oWordControl.m_oLogicDocument; - var oPreviewGenerator = new AscCommon.CTableStylesPreviewGenerator(logicDoc); - var dScale = 2; - var _w_px = TABLE_STYLE_WIDTH_PIX; - var _h_px = TABLE_STYLE_HEIGHT_PIX; - var _pageW = 297; - var _pageH = 210; - var oStream = global_memory_stream_menu; - var oGraphics = new CDrawingStream(); - var oNative = this.Native; - oPreviewGenerator.GetAllPreviewsNative(false, oGraphics, oStream, oNative, _pageW, _pageH, _w_px, _h_px); - }, - - GetTableStylesPreviews : function(bUseDefault) - { - return []; - }, - - GetTableLook : function(isDefault) - { - let oTableLook; - - if (isDefault) - { - oTableLook = new AscCommon.CTableLook(); - oTableLook.SetDefault(); - } - else - { - oTableLook = this.TableStylesLastLook; - } - - return oTableLook; - }, - - CheckGuiControlColors : function () - { - // потом реализовать проверку на то, что нужно ли посылать - var _theme = this.m_oWordControl.m_oLogicDocument.theme; - var _clrMap = this.m_oWordControl.m_oLogicDocument.clrSchemeMap.color_map; - - var arr_colors = new Array(10); - var rgba = {R: 0, G: 0, B: 0, A: 255}; - // bg1,tx1,bg2,tx2,accent1 - accent6 - var array_colors_types = [6, 15, 7, 16, 0, 1, 2, 3, 4, 5]; - var _count = array_colors_types.length; - - var color = new AscFormat.CUniColor(); - color.color = new AscFormat.CSchemeColor(); - for (var i = 0; i < _count; ++i) - { - color.color.id = array_colors_types[i]; - color.Calculate(_theme, _clrMap, rgba); - - var _rgba = color.RGBA; - arr_colors[i] = new Asc.asc_CColor(_rgba.R, _rgba.G, _rgba.B); - arr_colors[i].setColorSchemeId(color.color.id); - } - - // теперь проверим - var bIsSend = false; - if (this.GuiControlColorsMap != null) - { - for (var i = 0; i < _count; ++i) - { - var _color1 = this.GuiControlColorsMap[i]; - var _color2 = arr_colors[i]; - - if ((_color1.r != _color2.r) || (_color1.g != _color2.g) || (_color1.b != _color2.b)) - { - bIsSend = true; - break; - } - } - } - else - { - this.GuiControlColorsMap = new Array(_count); - bIsSend = true; - } - - if (bIsSend) - { - for (var i = 0; i < _count; ++i) - { - this.GuiControlColorsMap[i] = arr_colors[i]; - } - - this.SendControlColors(); - } - }, - - SendControlColors : function() - { - var standart_colors = null; - if (!this.IsSendStandartColors) { - var standartColors = AscCommon.g_oStandartColors; - var _c_s = standartColors.length; - standart_colors = new Array(_c_s); - - for (var i = 0; i < _c_s; ++i) { - standart_colors[i] = new Asc.asc_CColor(standartColors[i].R, standartColors[i].G, standartColors[i].B); - } - - this.IsSendStandartColors = true; - } - - var _count = this.GuiControlColorsMap.length; - - var _ret_array = new Array(_count * 6); - var _cur_index = 0; - - var array_colors_types = [6, 15, 7, 16, 0, 1, 2, 3, 4, 5]; - for (var i = 0; i < _count; ++i) { - var _color_src = this.GuiControlColorsMap[i]; - - _ret_array[_cur_index] = new Asc.asc_CColor(_color_src.r, _color_src.g, _color_src.b); - _cur_index++; - - // теперь с модификаторами - var _count_mods = 5; - for (var j = 0; j < _count_mods; ++j) { - let dst_mods = new AscFormat.CColorModifiers(); - dst_mods.Mods = AscCommon.GetDefaultMods(_color_src.r, _color_src.g, _color_src.b, j + 1, 1); - - let _rgba = { R: _color_src.r, G: _color_src.g, B: _color_src.b, A: 255 }; - dst_mods.Apply(_rgba); - - let oColor = new Asc.asc_CColor(_rgba.R, _rgba.G, _rgba.B); - oColor.put_effectValue(dst_mods.getEffectValue()); - oColor.setColorSchemeId(array_colors_types[i]); - - _ret_array[_cur_index] = oColor; - _cur_index++; - } - } - - this.m_oWordControl.m_oApi.sync_SendThemeColors(_ret_array, standart_colors); - - // regenerate styles - if (null == this.m_oWordControl.m_oApi._gui_styles) { - if (window["NATIVE_EDITOR_ENJINE"] === true) { - if (!this.m_oWordControl.m_oApi.asc_checkNeedCallback("asc_onInitEditorStyles")) - return; - } - var StylesPainter = new CStylesPainter(); - StylesPainter.GenerateStyles(this.m_oWordControl.m_oApi, this.m_oWordControl.m_oLogicDocument.Get_Styles().Style); - } - }, - - DrawImageTextureFillShape : function() - { - }, - DrawGuiCanvasTextProps : function() - { - }, - - // drawings mouse events - checkMouseDown_Drawing : function(pos) - { - var _ret = this.TableOutlineDr.checkMouseDown(pos, this); - if (_ret === true) - { - this.LogicDocument.RemoveSelection(); - this.TableOutlineDr.bIsTracked = true; - this.LockCursorType("move"); - - this.TableOutlineDr.TableOutline.Table.SelectAll(); - this.TableOutlineDr.TableOutline.Table.Document_SetThisElementCurrent(true); - - this.EndUpdateOverlay(); - return true; - } - - if (this.FrameRect.IsActive) - { - var eps = 10 / this.Native["DD_GetDotsPerMM"](); - var _check = this.checkCursorOnTrackRect(pos.X, pos.Y, eps, this.FrameRect.Rect); - - if (-1 != _check) - { - this.FrameRect.IsTracked = true; - this.FrameRect.Track.X = pos.X; - this.FrameRect.Track.Y = pos.Y; - this.FrameRect.Track.Type = _check; - - switch (_check) - { - case 0: - { - this.LockCursorType("nw-resize"); - break; - } - case 1: - { - this.LockCursorType("n-resize"); - break; - } - case 2: - { - this.LockCursorType("ne-resize"); - break; - } - case 3: - { - this.LockCursorType("e-resize"); - break; - } - case 4: - { - this.LockCursorType("se-resize"); - break; - } - case 5: - { - this.LockCursorType("s-resize"); - break; - } - case 6: - { - this.LockCursorType("sw-resize"); - break; - } - case 7: - { - this.LockCursorType("w-resize"); - break; - } - default: - { - this.LockCursorType("move"); - break; - } - } - - this.EndUpdateOverlay(); - return true; - } - } - - return false; - }, - - checkMouseMove_Drawing : function(pos) - { - if (this.TableOutlineDr.bIsTracked) - { - this.TableOutlineDr.checkMouseMove(global_mouseEvent.X, global_mouseEvent.Y, this); - this.OnUpdateOverlay(); - this.EndUpdateOverlay(); - return true; - } - - if (this.InlineTextTrackEnabled) - { - this.InlineTextTrack = this.LogicDocument.Get_NearestPos(pos.Page, pos.X, pos.Y); - this.InlineTextTrackPage = pos.Page; - - this.OnUpdateOverlay(); - this.EndUpdateOverlay(); - return true; - } - - if (this.FrameRect.IsActive) - { - if (!this.FrameRect.IsTracked && this.FrameRect.PageIndex == pos.Page) - { - var eps = 10 / this.Native["DD_GetDotsPerMM"](); - var _check = this.checkCursorOnTrackRect(pos.X, pos.Y, eps, this.FrameRect.Rect); - - if (_check != -1) - { - switch (_check) - { - case 0: - { - this.SetCursorType("nw-resize"); - break; - } - case 1: - { - this.SetCursorType("n-resize"); - break; - } - case 2: - { - this.SetCursorType("ne-resize"); - break; - } - case 3: - { - this.SetCursorType("e-resize"); - break; - } - case 4: - { - this.SetCursorType("se-resize"); - break; - } - case 5: - { - this.SetCursorType("s-resize"); - break; - } - case 6: - { - this.SetCursorType("sw-resize"); - break; - } - case 7: - { - this.SetCursorType("w-resize"); - break; - } - default: - { - this.SetCursorType("move"); - break; - } - } - // оверлей не нужно перерисовывать - this.EndUpdateOverlay(); - return true; - } - } - else - { - this.checkTrackRect(pos); - - this.OnUpdateOverlay(); - this.EndUpdateOverlay(); - return true; - } - } - - return false; - }, - - checkMouseUp_Drawing : function(pos) - { - if (this.TableOutlineDr.bIsTracked) - { - this.TableOutlineDr.checkMouseUp(global_mouseEvent.X, global_mouseEvent.Y, this); - this.LogicDocument.Document_UpdateInterfaceState(); - this.LogicDocument.Document_UpdateRulersState(); - - this.OnUpdateOverlay(); - this.EndUpdateOverlay(); - return true; - } - - if (this.InlineTextTrackEnabled) - { - this.InlineTextTrack = this.LogicDocument.Get_NearestPos(pos.Page, pos.X, pos.Y); - this.InlineTextTrackPage = pos.Page; - this.EndTrackText(); - - this.OnUpdateOverlay(); - this.EndUpdateOverlay(); - return true; - } - - if (this.FrameRect.IsActive && this.FrameRect.IsTracked) - { - this.FrameRect.IsTracked = false; - - this.checkTrackRect(pos); - var _track = this.FrameRect.Track; - this.FrameRect.Frame.Change_Frame(_track.L, _track.T, _track.R - _track.L, _track.B - _track.T, _track.PageIndex); - - this.OnUpdateOverlay(); - this.EndUpdateOverlay(); - return true; - } - - return false; - }, - - checkCursorOnTrackRect : function(X, Y, eps, rect) - { - // 0-1-...-7 - точки по часовой стрелке, начиная с left-top, - // 8-..-11 - стороны по часовой стрелке, начиная с top - - var __x_dist1 = Math.abs(X - rect.X); - var __x_dist2 = Math.abs(X - ((rect.X + rect.R) / 2)); - var __x_dist3 = Math.abs(X - rect.R); - - var __y_dist1 = Math.abs(Y - rect.Y); - var __y_dist2 = Math.abs(Y - ((rect.Y + rect.B) / 2)); - var __y_dist3 = Math.abs(Y - rect.B); - - if (__y_dist1 < eps) - { - if ((X < (rect.X - eps)) || (X > (rect.R + eps))) - return -1; - - if (__x_dist1 <= __x_dist2 && __x_dist1 <= __x_dist3) - return (__x_dist1 < eps) ? 0 : 8; - - if (__x_dist2 <= __x_dist1 && __x_dist2 <= __x_dist3) - return (__x_dist2 < eps) ? 1 : 8; - - if (__x_dist3 <= __x_dist1 && __x_dist3 <= __x_dist2) - return (__x_dist3 < eps) ? 2 : 8; - - return 8; - } - - if (__y_dist3 < eps) - { - if ((X < (rect.X - eps)) || (X > (rect.R + eps))) - return -1; - - if (__x_dist1 <= __x_dist2 && __x_dist1 <= __x_dist3) - return (__x_dist1 < eps) ? 6 : 10; - - if (__x_dist2 <= __x_dist1 && __x_dist2 <= __x_dist3) - return (__x_dist2 < eps) ? 5 : 10; - - if (__x_dist3 <= __x_dist1 && __x_dist3 <= __x_dist2) - return (__x_dist3 < eps) ? 4 : 10; - - return 8; - } - - if (__x_dist1 < eps) - { - if ((Y < (rect.Y - eps)) || (Y > (rect.B + eps))) - return -1; - - if (__y_dist1 <= __y_dist2 && __y_dist1 <= __y_dist3) - return (__y_dist1 < eps) ? 0 : 11; - - if (__y_dist2 <= __y_dist1 && __y_dist2 <= __y_dist3) - return (__y_dist2 < eps) ? 7 : 11; - - if (__y_dist3 <= __y_dist1 && __y_dist3 <= __y_dist2) - return (__y_dist3 < eps) ? 6 : 11; - - return 11; - } - - if (__x_dist3 < eps) - { - if ((Y < (rect.Y - eps)) || (Y > (rect.B + eps))) - return -1; - - if (__y_dist1 <= __y_dist2 && __y_dist1 <= __y_dist3) - return (__y_dist1 < eps) ? 2 : 9; - - if (__y_dist2 <= __y_dist1 && __y_dist2 <= __y_dist3) - return (__y_dist2 < eps) ? 3 : 9; - - if (__y_dist3 <= __y_dist1 && __y_dist3 <= __y_dist2) - return (__y_dist3 < eps) ? 4 : 9; - - return 9; - } - - return -1; - }, - - checkTrackRect : function(pos) - { - var _min_dist = 3; // mm; - - var _track = this.FrameRect.Track; - var _rect = this.FrameRect.Rect; - _track.PageIndex = this.FrameRect.PageIndex; - switch (_track.Type) - { - case 0: - { - _track.L = _rect.X + (pos.X - _track.X); - _track.T = _rect.Y + (pos.Y - _track.Y); - _track.R = _rect.R; - _track.B = _rect.B; - - if (_track.L > (_track.R - _min_dist)) - _track.L = _track.R - _min_dist; - if (_track.T > (_track.B - _min_dist)) - _track.T = _track.B - _min_dist; - - break; - } - case 1: - { - _track.L = _rect.X; - _track.T = _rect.Y + (pos.Y - _track.Y); - _track.R = _rect.R; - _track.B = _rect.B; - - if (_track.T > (_track.B - _min_dist)) - _track.T = _track.B - _min_dist; - - break; - } - case 2: - { - _track.L = _rect.X; - _track.T = _rect.Y + (pos.Y - _track.Y); - _track.R = _rect.R + (pos.X - _track.X); - _track.B = _rect.B; - - if (_track.R < (_track.L + _min_dist)) - _track.R = _track.L + _min_dist; - if (_track.T > (_track.B - _min_dist)) - _track.T = _track.B - _min_dist; - - break; - } - case 3: - { - _track.L = _rect.X; - _track.T = _rect.Y; - _track.R = _rect.R + (pos.X - _track.X); - _track.B = _rect.B; - - if (_track.R < (_track.L + _min_dist)) - _track.R = _track.L + _min_dist; - - break; - } - case 4: - { - _track.L = _rect.X; - _track.T = _rect.Y; - _track.R = _rect.R + (pos.X - _track.X); - _track.B = _rect.B + (pos.Y - _track.Y); - - if (_track.R < (_track.L + _min_dist)) - _track.R = _track.L + _min_dist; - if (_track.B < (_track.T + _min_dist)) - _track.B = _track.T + _min_dist; - - break; - } - case 5: - { - _track.L = _rect.X; - _track.T = _rect.Y; - _track.R = _rect.R; - _track.B = _rect.B + (pos.Y - _track.Y); - - if (_track.B < (_track.T + _min_dist)) - _track.B = _track.T + _min_dist; - - break; - } - case 6: - { - _track.L = _rect.X + (pos.X - _track.X); - _track.T = _rect.Y; - _track.R = _rect.R; - _track.B = _rect.B + (pos.Y - _track.Y); - - if (_track.L > (_track.R - _min_dist)) - _track.L = _track.R - _min_dist; - if (_track.B < (_track.T + _min_dist)) - _track.B = _track.T + _min_dist; - - break; - } - case 7: - { - _track.L = _rect.X + (pos.X - _track.X); - _track.T = _rect.Y; - _track.R = _rect.R; - _track.B = _rect.B; - - if (_track.L > (_track.R - _min_dist)) - _track.L = _track.R - _min_dist; - - break; - } - default: - { - _track.L = pos.X - (_track.X - _rect.X); - _track.T = pos.Y - (_track.Y - _rect.Y); - _track.R = _track.L + _rect.R - _rect.X; - _track.B = _track.T + _rect.B - _rect.Y; - - _track.PageIndex = pos.Page; - break; - } - } - }, - - DrawFrameTrack : function() - { - if (!this.FrameRect.IsActive) - return; - - this.Native["DD_Overlay_DrawFrameTrack1"](this.FrameRect.PageIndex, - this.FrameRect.Rect.X, this.FrameRect.Rect.Y, this.FrameRect.Rect.R, this.FrameRect.Rect.B); - - // move - if (this.FrameRect.IsTracked) - { - this.Native["DD_Overlay_DrawFrameTrack2"](this.FrameRect.Track.PageIndex, - this.FrameRect.Track.L, this.FrameRect.Track.T, this.FrameRect.Track.R, this.FrameRect.Track.B); - } - }, - - DrawMathTrack : function() - { - //TODO: Implement! - //if (!this.MathRect.IsActive) - // return; - // - //this.Native["DD_Overlay_DrawFrameTrack1"](this.MathRect.Rect.PageIndex, - // this.MathRect.Rect.X, this.MathRect.Rect.Y, this.MathRect.Rect.R, this.MathRect.Rect.B); - }, - - DrawFieldTrack : function() - { - // TODO: - }, - - Update_FieldTrack : function() - { - // TODO: - }, - - Update_MathTrack : function(IsActive, IsContentActive, oMath) - { - var PixelError = this.GetMMPerDot(1) * 3; - this.MathTrack.Update(IsActive, IsContentActive, oMath, PixelError); - }, - - DrawTableTrack : function() - { - if (null == this.TableOutlineDr.TableOutline) - return; - - var _table = this.TableOutlineDr.TableOutline.Table; - - if (!_table.Is_Inline()) - { - if (null == this.TableOutlineDr.CurPos) - return; - - var _matrix = this.TableOutlineDr.TableMatrix; - - if (!_matrix) - { - this.Native["DD_Overlay_DrawTableTrack"](this.TableOutlineDr.CurPos.Page, - this.TableOutlineDr.CurPos.X, this.TableOutlineDr.CurPos.Y, - this.TableOutlineDr.TableOutline.W, this.TableOutlineDr.TableOutline.H); - } - else - { - this.Native["DD_Overlay_DrawTableTrack"](this.TableOutlineDr.CurPos.Page, - this.TableOutlineDr.CurPos.X, this.TableOutlineDr.CurPos.Y, - this.TableOutlineDr.TableOutline.W, this.TableOutlineDr.TableOutline.H, - _matrix.sx, _matrix.shy, _matrix.shx, _matrix.sy, _matrix.tx, _matrix.ty); - } - } - else - { - this.LockCursorType("default"); - - var _x = global_mouseEvent.X; - var _y = global_mouseEvent.Y; - var posMouse = this.__DD_ConvertCoordsFromCursor(_x, _y); - - this.TableOutlineDr.InlinePos = this.LogicDocument.Get_NearestPos(posMouse.Page, posMouse.X, posMouse.Y); - this.TableOutlineDr.InlinePos.Page = posMouse.Page; - - var _near = this.TableOutlineDr.InlinePos; - - this.AutoShapesTrack.SetCurrentPage(_near.Page); - this.AutoShapesTrack.DrawInlineMoveCursor(_near.X, _near.Y, _near.Height, _near.transform); - } - }, - - RenderDocument : function(Renderer) - { - var _count = this.LogicDocument.Pages.length; - for (var i = 0; i < _count; i++) - { - var _info = this.LogicDocument.Get_PageLimits(i); - - Renderer.BeginPage(_info.XLimit, _info.YLimit); - this.LogicDocument.DrawPage(i, Renderer); - Renderer.EndPage(); - } - }, - - ToRenderer : function() - { - var Renderer = new AscCommon.CDocumentRenderer(); - Renderer.VectorMemoryForPrint = new AscCommon.CMemory(); - var old_marks = this.m_oWordControl.m_oApi.ShowParaMarks; - this.m_oWordControl.m_oApi.ShowParaMarks = false; - this.RenderDocument(Renderer); - this.m_oWordControl.m_oApi.ShowParaMarks = old_marks; - var ret = Renderer.Memory.GetBase64Memory(); - //console.log(ret); - return ret; - }, - - // collaborative targets - Collaborative_UpdateTarget : function (_id, _shortId, _x, _y, _size, _page, _transform, is_from_paint) - { - if (is_from_paint !== true) - { - this.CollaborativeTargetsUpdateTasks.push([_id, _shortId, _x, _y, _size, _page, _transform]); - this.OnUpdateOverlay(); - this.EndUpdateOverlay(); - return; - } - else - { - var color = AscCommon.getUserColorById(_shortId, null, true); - - if (null != _transform) { - this.Native["collaborativeUpdateTarget"](_id, _shortId, _x, _y, _size, _page, - _transform.sx, _transform.shy, _transform.shx, _transform.sy, _transform.tx, _transform.ty, - color.r, color.g, color.b - ); - } else { - this.Native["collaborativeUpdateTarget"](_id, _shortId, _x, _y, _size, _page, - 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, - color.r, color.g, color.b - ); - } - } - - for (var i = 0; i < this.CollaborativeTargets.length; i++) - { - if (_id == this.CollaborativeTargets[i].Id) - { - this.CollaborativeTargets[i].CheckPosition(_x, _y, _size, _page, _transform); - return; - } - } - var _target = new CDrawingCollaborativeTarget(this); - _target.Id = _id; - _target.ShortId = _shortId; - _target.CheckPosition(_x, _y, _size, _page, _transform); - this.CollaborativeTargets[this.CollaborativeTargets.length] = _target; - }, - Collaborative_RemoveTarget : function (_id) - { - this.Native["collaborativeRemoveTarget"](_id); - - for (var i = 0; i < this.CollaborativeTargets.length; i++) - { - if (_id == this.CollaborativeTargets[i].Id) - { - this.CollaborativeTargets[i].Remove(this); - this.CollaborativeTargets.splice(i, 1); - } - } - - this.OnUpdateOverlay(); - this.EndUpdateOverlay(); - }, - Collaborative_TargetsUpdate : function (bIsChangePosition) - { - var _len_tasks = this.CollaborativeTargetsUpdateTasks.length; - var i = 0; - for (i = 0; i < _len_tasks; i++) - { - var _tmp = this.CollaborativeTargetsUpdateTasks[i]; - this.Collaborative_UpdateTarget(_tmp[0], _tmp[1], _tmp[2], _tmp[3], _tmp[4], _tmp[5], _tmp[6], true); - } - if (_len_tasks != 0) - this.CollaborativeTargetsUpdateTasks.splice(0, _len_tasks); - - if (bIsChangePosition) - { - for (i = 0; i < this.CollaborativeTargets.length; i++) - { - this.CollaborativeTargets[i].Update(this); - } - } - }, - Collaborative_GetTargetPosition : function (UserId) - { - for (var i = 0; i < this.CollaborativeTargets.length; i++) - { - if (UserId == this.CollaborativeTargets[i].Id) - return {X: this.CollaborativeTargets[i].HtmlElementX, Y: this.CollaborativeTargets[i].HtmlElementY}; - } - - return null; - }, - - GetVisibleRegion : function() - { - return null; - } -}; - -function check_KeyboardEvent(e) -{ - AscCommon.global_keyboardEvent.AltKey = ((e["Flags"] & 0x01) == 0x01); - AscCommon.global_keyboardEvent.CtrlKey = ((e["Flags"] & 0x02) == 0x02); - AscCommon.global_keyboardEvent.ShiftKey = ((e["Flags"] & 0x04) == 0x04); - - AscCommon.global_keyboardEvent.Sender = null; - - AscCommon.global_keyboardEvent.CharCode = e["CharCode"]; - AscCommon.global_keyboardEvent.KeyCode = e["KeyCode"]; - AscCommon.global_keyboardEvent.Which = null; -} -function check_KeyboardEvent_Array(_params, i) -{ - AscCommon.global_keyboardEvent.AltKey = ((_params[i + 1] & 0x01) == 0x01); - AscCommon.global_keyboardEvent.CtrlKey = ((_params[i + 1] & 0x02) == 0x02); - AscCommon.global_keyboardEvent.ShiftKey = ((_params[i + 1] & 0x04) == 0x04); - - AscCommon.global_keyboardEvent.Sender = null; - - AscCommon.global_keyboardEvent.CharCode = _params[i + 3]; - AscCommon.global_keyboardEvent.KeyCode = _params[i + 2]; - AscCommon.global_keyboardEvent.Which = null; -} - -function check_MouseDownEvent(e, isClicks) -{ - global_mouseEvent.X = e["X"]; - global_mouseEvent.Y = e["Y"]; - - global_mouseEvent.AltKey = ((e["Flags"] & 0x01) == 0x01); - global_mouseEvent.CtrlKey = ((e["Flags"] & 0x02) == 0x02); - global_mouseEvent.ShiftKey = ((e["Flags"] & 0x04) == 0x04); - - global_mouseEvent.Type = AscCommon.g_mouse_event_type_down; - global_mouseEvent.Button = e["Button"]; - - global_mouseEvent.Sender = null; - - if (isClicks) - { - global_mouseEvent.ClickCount = e["ClickCount"]; - } - else - { - global_mouseEvent.ClickCount = 1; - } - - global_mouseEvent.IsLocked = true; -} - -function check_MouseMoveEvent(e) -{ - global_mouseEvent.X = e["X"]; - global_mouseEvent.Y = e["Y"]; - - global_mouseEvent.AltKey = ((e["Flags"] & 0x01) == 0x01); - global_mouseEvent.CtrlKey = ((e["Flags"] & 0x02) == 0x02); - global_mouseEvent.ShiftKey = ((e["Flags"] & 0x04) == 0x04); - - global_mouseEvent.Type = AscCommon.g_mouse_event_type_move; - global_mouseEvent.Button = e["Button"]; -} - -function check_MouseUpEvent(e) -{ - global_mouseEvent.X = e["X"]; - global_mouseEvent.Y = e["Y"]; - - global_mouseEvent.AltKey = ((e["Flags"] & 0x01) == 0x01); - global_mouseEvent.CtrlKey = ((e["Flags"] & 0x02) == 0x02); - global_mouseEvent.ShiftKey = ((e["Flags"] & 0x04) == 0x04); - - global_mouseEvent.Type = AscCommon.g_mouse_event_type_up; - global_mouseEvent.Button = e["Button"]; - - global_mouseEvent.Sender = null; - - global_mouseEvent.IsLocked = false; -} - -//--------------------------------------------------------export---------------------------------------------------- -window['AscCommon'] = window['AscCommon'] || {}; -window['AscCommonWord'] = window['AscCommonWord'] || {}; -//window['AscCommon'].CPage = CPage; -window['AscCommon'].CDrawingDocument = CDrawingDocument; diff --git a/word/Native/HtmlPage.js b/word/Native/HtmlPage.js deleted file mode 100644 index 2d602b5de6..0000000000 --- a/word/Native/HtmlPage.js +++ /dev/null @@ -1,505 +0,0 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2023 - * - * This program is a free software product. You can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License (AGPL) - * version 3 as published by the Free Software Foundation. In accordance with - * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement - * of any third-party rights. - * - * This program is distributed WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ - -var Page_Width = 210; -var Page_Height = 297; - -var X_Left_Margin = 30; // 3 cm -var X_Right_Margin = 15; // 1.5 cm -var Y_Bottom_Margin = 20; // 2 cm -var Y_Top_Margin = 20; // 2 cm - -var X_Right_Field = Page_Width - X_Right_Margin; -var Y_Bottom_Field = Page_Height - Y_Bottom_Margin; - -var docpostype_Content = 0x00; -var docpostype_HdrFtr = 0x02; - -var selectionflag_Common = 0x00; -var selectionflag_Numbering = 0x01; -var selectionflag_DrawingObject = 0x002; - -var tableSpacingMinValue = 0.02;//0.02мм - -function CEditorPage(api) -{ - this.Name = ""; - - this.X = 0; - this.Y = 0; - this.Width = 10; - this.Height = 10; - - this.m_oDrawingDocument = new AscCommon.CDrawingDocument(); - this.m_oLogicDocument = null; - - this.m_oDrawingDocument.m_oWordControl = this; - this.m_oDrawingDocument.m_oLogicDocument = this.m_oLogicDocument; - this.m_oApi = api; - - this.Init = function() - { - }; - - this.CheckRetinaDisplay = function() - { - }; - - this.ShowOverlay = function() - { - }; - this.UnShowOverlay = function() - { - }; - this.CheckUnShowOverlay = function() - { - }; - this.CheckShowOverlay = function() - { - }; - - this.initEvents = function() - { - }; - - this.onButtonRulersClick = function() - { - }; - - this.HideRulers = function() - { - }; - - this.zoom_FitToWidth = function() - { - }; - this.zoom_FitToPage = function() - { - }; - - this.zoom_Fire = function(type, old_zoom) - { - }; - - this.zoom_Out = function() - { - }; - - this.zoom_In = function() - { - }; - - this.ToSearchResult = function() - { - }; - - this.ScrollToPosition = function(x, y, PageNum, height) - { - }; - - this.ScrollToAbsolutePosition = function(x, y, PageNum, isBottom) - { - }; - - this.onButtonTabsClick = function() - { - }; - - this.onPrevPage = function() - { - }; - this.onNextPage = function() - { - }; - - this.horRulerMouseDown = function(e) - { - }; - this.horRulerMouseUp = function(e) - { - }; - this.horRulerMouseMove = function(e) - { - }; - - this.verRulerMouseDown = function(e) - { - }; - this.verRulerMouseUp = function(e) - { - }; - this.verRulerMouseMove = function(e) - { - }; - - this.SelectWheel = function() - { - }; - - this.onMouseDown = function(e) - { - }; - - this.onMouseMove = function(e) - { - }; - this.onMouseMove2 = function() - { - }; - this.onMouseUp = function(e, bIsWindow) - { - }; - - this.onMouseUpMainSimple = function() - { - }; - - this.onMouseUpExternal = function(x, y) - { - }; - - this.onMouseWhell = function(e) - { - }; - - this.checkViewerModeKeys = function(e) - { - }; - - this.IncreaseReaderFontSize = function() - { - }; - this.DecreaseReaderFontSize = function() - { - }; - - this.EnableReaderMode = function() - { - }; - - this.DisableReaderMode = function() - { - }; - - this.CheckDestroyReader = function() - { - }; - - this.TransformDivUseAnimation = function(_div, topPos) - { - }; - - this.onKeyDown = function(e) - { - }; - - this.onKeyDownNoActiveControl = function(e) - { - }; - - this.onKeyDownTBIM = function(e) - { - }; - - this.DisableTextEATextboxAttack = function() - { - }; - - this.onKeyUp = function(e) - { - }; - this.onKeyPress = function(e) - { - }; - - this.verticalScroll = function(sender,scrollPositionY,maxY,isAtTop,isAtBottom) - { - }; - this.CorrectSpeedVerticalScroll = function(newScrollPos) - { - }; - - this.horizontalScroll = function(sender,scrollPositionX,maxX,isAtLeft,isAtRight) - { - }; - - this.UpdateScrolls = function() - { - }; - - this.OnRePaintAttack = function() - { - }; - - this.OnResize = function(isAttack) - { - }; - - this.checkNeedRules = function() - { - }; - this.checkNeedHorScroll = function() - { - }; - - this.getScrollMaxX = function(size) - { - }; - this.getScrollMaxY = function(size) - { - }; - - this.StartUpdateOverlay = function() - { - }; - this.EndUpdateOverlay = function() - { - }; - - this.OnUpdateOverlay = function() - { - }; - - this.OnUpdateSelection = function() - { - }; - - this.OnCalculatePagesPlace = function() - { - }; - - this.OnPaint = function() - { - }; - - this.CheckRetinaElement = function(htmlElem) - { - }; - - this.GetDrawingPageInfo = function(nPageIndex) - { - }; - - this.CheckFontCache = function() - { - }; - this.OnScroll = function() - { - }; - - this.CheckZoom = function() - { - }; - - this.ChangeHintProps = function() - { - }; - - this.CalculateDocumentSize = function() - { - }; - - this.InitDocument = function(bIsEmpty) - { - }; - - this.InitControl = function() - { - }; - - this.OpenDocument = function(info) - { - }; - - this.AnimationFrame = function() - { - }; - - this.onTimerScroll = function() - { - var oWordControl = editor.WordControl; - if(oWordControl.m_oLogicDocument) - { - oWordControl.m_oLogicDocument.ContinueSpellCheck(); - } - oWordControl.m_nPaintTimerId = setTimeout(oWordControl.onTimerScroll, 500); - }; - - this.StartMainTimer = function() - { - this.onTimerScroll(); - }; - - this.onTimerScroll2 = function() - { - }; - - this.onTimerScroll2_sync = function() - { - }; - - this.UpdateHorRuler = function() - { - }; - this.UpdateVerRuler = function() - { - }; - - this.SetCurrentPage = function(isNoUpdateRulers) - { - }; - this.SetCurrentPage2 = function() - { - }; - - this.UpdateHorRulerBack = function() - { - }; - this.UpdateVerRulerBack = function() - { - }; - - this.GoToPage = function(lPageNum) - { - }; - - this.GetVerticalScrollTo = function(y, page) - { - }; - - this.GetHorizontalScrollTo = function(x, page) - { - }; - - this.ReinitTB = function() - { - }; - - this.SetTextBoxMode = function(isEA) - { - }; - - this.TextBoxFocus = function() - { - }; - - this.OnTextBoxInput = function() - { - }; - - this.CheckTextBoxSize = function() - { - }; - - this.TextBoxOnKeyDown = function(e) - { - }; - - this.onChangeTB = function() - { - }; - this.CheckTextBoxInputPos = function() - { - }; - - this.checkMouseHandMode = function() - { - }; - - this.ReaderModeCurrent = 0; - this.ReaderFontSizeCur = 2; - this.ReaderFontSizes = [12, 14, 16, 18, 22, 28, 36, 48, 72]; - this.ChangeReaderMode = function() - { - if (!this.m_oLogicDocument) - return; - - if (this.ReaderModeCurrent) - { - this.m_oLogicDocument.SetDocumentPrintMode(); - this.ReaderModeCurrent = 0; - } - else - { - this.SetNewMobileMode(); - this.ReaderModeCurrent = 1; - } - }; - - this.SetNewMobileMode = function() - { - if (this.m_oLogicDocument) - { - let sectPr = this.m_oLogicDocument.GetSectionsInfo().Get(0).SectPr; - let scale = 2; // TODO: get deviceScale - const nPageW = sectPr.GetPageWidth() / scale; - const nPageH = sectPr.GetPageHeight() / scale; - const nScale = this.ReaderFontSizes[this.ReaderFontSizeCur] / 16; - this.m_oLogicDocument.SetDocumentReadMode(nPageW, nPageH, nScale); - return true; - } - return false; - }; - - this.IncreaseReaderFontSize = function() - { - if (this.ReaderFontSizeCur >= (this.ReaderFontSizes.length - 1)) - { - this.ReaderFontSizeCur = this.ReaderFontSizes.length - 1; - return false; - } - this.ReaderFontSizeCur++; - return this.SetNewMobileMode(); - }; - this.DecreaseReaderFontSize = function() - { - if (this.ReaderFontSizeCur <= 0) - { - this.ReaderFontSizeCur = 0; - return false; - } - this.ReaderFontSizeCur--; - return this.SetNewMobileMode(); - }; -} - -//------------------------------------------------------------export---------------------------------------------------- -window['AscCommon'] = window['AscCommon'] || {}; -window['AscCommonWord'] = window['AscCommonWord'] || {}; -window['AscCommonWord'].CEditorPage = CEditorPage; - -window['AscCommon'].Page_Width = Page_Width; -window['AscCommon'].Page_Height = Page_Height; -window['AscCommon'].X_Left_Margin = X_Left_Margin; -window['AscCommon'].X_Right_Margin = X_Right_Margin; -window['AscCommon'].Y_Bottom_Margin = Y_Bottom_Margin; -window['AscCommon'].Y_Top_Margin = Y_Top_Margin; diff --git a/word/Native/api.js b/word/Native/api.js deleted file mode 100644 index 90038ed5c0..0000000000 --- a/word/Native/api.js +++ /dev/null @@ -1,4680 +0,0 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2023 - * - * This program is a free software product. You can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License (AGPL) - * version 3 as published by the Free Software Foundation. In accordance with - * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement - * of any third-party rights. - * - * This program is distributed WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ - -var sdkCheck = true; -var spellCheck = true; -var _api = null; -var _internalStorage = { - changesReview : [] -}; - -// SERIALIZE -function asc_menu_WriteHeaderFooterPr(_hdrftrPr, _stream) -{ - if (_hdrftrPr.Type !== undefined && _hdrftrPr.Type !== null) - { - _stream["WriteByte"](0); - _stream["WriteLong"](_hdrftrPr.Type); - } - if (_hdrftrPr.Position !== undefined && _hdrftrPr.Position !== null) - { - _stream["WriteByte"](1); - _stream["WriteDouble2"](_hdrftrPr.Position); - } - - if (_hdrftrPr.DifferentFirst !== undefined && _hdrftrPr.DifferentFirst !== null) - { - _stream["WriteByte"](2); - _stream["WriteBool"](_hdrftrPr.DifferentFirst); - } - if (_hdrftrPr.DifferentEvenOdd !== undefined && _hdrftrPr.DifferentEvenOdd !== null) - { - _stream["WriteByte"](3); - _stream["WriteBool"](_hdrftrPr.DifferentEvenOdd); - } - if (_hdrftrPr.LinkToPrevious !== undefined && _hdrftrPr.LinkToPrevious !== null) - { - _stream["WriteByte"](4); - _stream["WriteBool"](_hdrftrPr.LinkToPrevious); - } - if (_hdrftrPr.Locked !== undefined && _hdrftrPr.Locked !== null) - { - _stream["WriteByte"](5); - _stream["WriteBool"](_hdrftrPr.Locked); - } - if (_hdrftrPr.StartPageNumber !== undefined && _hdrftrPr.StartPageNumber !== null) - { - _stream["WriteByte"](6); - _stream["WriteLong"](_hdrftrPr.StartPageNumber); - } - - _stream["WriteByte"](255); -} - -function Deserialize_Table_Markup(_params, _cols, _margins, _rows) -{ - var _markup = new CTableMarkup(null); - _markup.Internal.RowIndex = _params[0]; - _markup.Internal.CellIndex = _params[1]; - _markup.Internal.PageNum = _params[2]; - _markup.X = _params[3]; - _markup.CurCol = _params[4]; - _markup.CurRow = _params[5]; - // 6 - DragPos - _markup.TransformX = _params[7]; - _markup.TransformY = _params[8]; - - _markup.Cols = _cols; - - var _len = _margins.length; - for (var i = 0; i < _len; i += 2) - { - _markup.Margins.push({ Left : _margins[i], Right : _margins[i + 1] }); - } - - _len = _rows.length; - for (var i = 0; i < _len; i += 2) - { - _markup.Rows.push({ Y : _rows[i], H : _rows[i + 1] }); - } - - return _markup; -} - -// editor -Asc['asc_docs_api'].prototype["NativeAfterLoad"] = function() -{ - this.WordControl.m_oDrawingDocument.AfterLoad(); - this.WordControl.m_oLogicDocument.SetUseTextShd(false); -}; -Asc['asc_docs_api'].prototype["GetNativePageMeta"] = function(pageIndex) -{ - this.WordControl.m_oDrawingDocument.LogicDocument = _api.WordControl.m_oDrawingDocument.m_oLogicDocument; - this.WordControl.m_oDrawingDocument.RenderPage(pageIndex); -}; - -Asc['asc_docs_api'].prototype["Native_Editor_Initialize_Settings"] = function(_params) -{ - window["NativeSupportTimeouts"] = true; - - if (!_params) - return; - - var _current = { pos : 0 }; - var _continue = true; - while (_continue) - { - var _attr = _params[_current.pos++]; - switch (_attr) - { - case 0: - { - AscCommon.GlobalSkin.STYLE_THUMBNAIL_WIDTH = _params[_current.pos++]; - break; - } - case 1: - { - AscCommon.GlobalSkin.STYLE_THUMBNAIL_HEIGHT = _params[_current.pos++]; - break; - } - case 2: - { - TABLE_STYLE_WIDTH_PIX = _params[_current.pos++]; - break; - } - case 3: - { - TABLE_STYLE_HEIGHT_PIX = _params[_current.pos++]; - break; - } - case 4: - { - this.chartPreviewManager.CHART_PREVIEW_WIDTH_PIX = _params[_current.pos++]; - break; - } - case 5: - { - this.chartPreviewManager.CHART_PREVIEW_HEIGHT_PIX = _params[_current.pos++]; - break; - } - case 6: - { - var _val = _params[_current.pos++]; - if (_val === true) - { - this.ShowParaMarks = false; - AscCommon.CollaborativeEditing.Set_GlobalLock(true); - - this.isViewMode = true; - this.WordControl.m_oDrawingDocument.IsViewMode = true; - } - break; - } - case 100: - { - this.WordControl.m_oDrawingDocument.IsRetina = _params[_current.pos++]; - break; - } - case 101: - { - this.WordControl.m_oDrawingDocument.IsMobile = _params[_current.pos++]; - window.AscAlwaysSaveAspectOnResizeTrack = true; - break; - } - case 255: - default: - { - _continue = false; - break; - } - } - } - - AscCommon.AscBrowser.isRetina = this.WordControl.m_oDrawingDocument.IsRetina; -}; - -// HTML page interface -Asc['asc_docs_api'].prototype["Call_OnUpdateOverlay"] = function(param) -{ - this.WordControl.m_oDrawingDocument.OnUpdateOverlay(); -}; - -Asc['asc_docs_api'].prototype["Call_OnMouseDown"] = function(e) -{ - return this.WordControl.m_oDrawingDocument.OnMouseDown(e); -}; -Asc['asc_docs_api'].prototype["Call_OnMouseUp"] = function(e) -{ - return this.WordControl.m_oDrawingDocument.OnMouseUp(e); -}; -Asc['asc_docs_api'].prototype["Call_OnMouseMove"] = function(e) -{ - return this.WordControl.m_oDrawingDocument.OnMouseMove(e); -}; -Asc['asc_docs_api'].prototype["Call_OnCheckMouseDown"] = function(e) -{ - return this.WordControl.m_oDrawingDocument.OnCheckMouseDown(e); -}; - -Asc['asc_docs_api'].prototype["Call_OnKeyDown"] = function(e) -{ - this.WordControl.m_oDrawingDocument.OnKeyDown(e); -}; -Asc['asc_docs_api'].prototype["Call_OnKeyPress"] = function(e) -{ - this.WordControl.m_oDrawingDocument.OnKeyPress(e); -}; -Asc['asc_docs_api'].prototype["Call_OnKeyUp"] = function(e) -{ - this.WordControl.m_oDrawingDocument.OnKeyUp(e); -}; -Asc['asc_docs_api'].prototype["Call_OnKeyboardEvent"] = function(e) -{ - this.WordControl.m_oDrawingDocument.OnKeyboardEvent(e); -}; - -Asc['asc_docs_api'].prototype["Call_CalculateResume"] = function() -{ - Document_Recalculate_Page(); -}; - -Asc['asc_docs_api'].prototype["Call_TurnOffRecalculate"] = function() -{ - this.WordControl.m_oLogicDocument.TurnOff_Recalculate(); -}; -Asc['asc_docs_api'].prototype["Call_TurnOnRecalculate"] = function() -{ - this.WordControl.m_oLogicDocument.TurnOn_Recalculate(); - this.WordControl.m_oLogicDocument.Recalculate(); -}; - -Asc['asc_docs_api'].prototype["Call_CheckTargetUpdate"] = function() -{ - this.WordControl.m_oDrawingDocument.UpdateTargetFromPaint = true; - this.WordControl.m_oLogicDocument.CheckTargetUpdate(); - this.WordControl.m_oDrawingDocument.CheckTargetShow(); - this.WordControl.m_oDrawingDocument.UpdateTargetFromPaint = false; - - this.WordControl.m_oDrawingDocument.Collaborative_TargetsUpdate(false); -}; - -Asc['asc_docs_api'].prototype["Call_Common"] = function(type, param) -{ - switch (type) - { - case 1: - { - this.WordControl.m_oLogicDocument.MoveCursorLeft(); - break; - } - case 67: - { - this.startGetDocInfo(); - break; - } - case 68: - { - this.stopGetDocInfo(); - break; - } - default: - break; - } -}; - -Asc['asc_docs_api'].prototype["Call_HR_Tabs"] = function(arrT, arrP) -{ - var _arr = new AscCommonWord.CParaTabs(); - var _c = arrT.length; - for (var i = 0; i < _c; i++) - { - if (arrT[i] == 1) - _arr.Add( new CParaTab( tab_Left, arrP[i] ) ); - if (arrT[i] == 2) - _arr.Add( new CParaTab( tab_Right, arrP[i] ) ); - if (arrT[i] == 3) - _arr.Add( new CParaTab( tab_Center, arrP[i] ) ); - } - - var _logic = this.WordControl.m_oLogicDocument; - if ( false === _logic.Document_Is_SelectionLocked(AscCommon.changestype_Paragraph_Properties) ) - { - _logic.StartAction(); - _logic.SetParagraphTabs(_arr); - _logic.FinalizeAction(); - } -}; -Asc['asc_docs_api'].prototype["Call_HR_Pr"] = function(_indent_left, _indent_right, _indent_first) -{ - var _logic = this.WordControl.m_oLogicDocument; - if ( false === _logic.Document_Is_SelectionLocked(AscCommon.changestype_Paragraph_Properties) ) - { - _logic.StartAction(); - _logic.SetParagraphIndent( { Left : _indent_left, Right : _indent_right, FirstLine: _indent_first } ); - _logic.FinalizeAction(); - } -}; -Asc['asc_docs_api'].prototype["Call_HR_Margins"] = function(_margin_left, _margin_right) -{ - var _logic = this.WordControl.m_oLogicDocument; - if ( false === _logic.Document_Is_SelectionLocked(AscCommon.changestype_Document_SectPr) ) - { - _logic.StartAction(); - _logic.SetDocumentMargin( { Left : _margin_left, Right : _margin_right }); - _logic.FinalizeAction(); - } -}; -Asc['asc_docs_api'].prototype["Call_HR_Table"] = function(_params, _cols, _margins, _rows) -{ - var _logic = this.WordControl.m_oLogicDocument; - if ( false === _logic.Document_Is_SelectionLocked(AscCommon.changestype_Table_Properties) ) - { - _logic.StartAction(); - - var _table_murkup = Deserialize_Table_Markup(_params, _cols, _margins, _rows); - _table_murkup.Table = this.WordControl.m_oDrawingDocument.Table; - - _table_murkup.CorrectTo(); - _table_murkup.Table.Update_TableMarkupFromRuler(_table_murkup, true, _params[6]); - _table_murkup.CorrectFrom(); - - _logic.FinalizeAction(); - } -}; - -Asc['asc_docs_api'].prototype["Call_VR_Margins"] = function(_top, _bottom) -{ - var _logic = this.WordControl.m_oLogicDocument; - if ( false === _logic.Document_Is_SelectionLocked(AscCommon.changestype_Document_SectPr) ) - { - _logic.StartAction(); - _logic.SetDocumentMargin( { Top : _top, Bottom : _bottom }); - _logic.FinalizeAction(); - } -}; -Asc['asc_docs_api'].prototype["Call_VR_Header"] = function(_header_top, _header_bottom) -{ - var _logic = this.WordControl.m_oLogicDocument; - if ( false === _logic.Document_Is_SelectionLocked(AscCommon.changestype_HdrFtr) ) - { - _logic.StartAction(); - _logic.Document_SetHdrFtrBounds(_header_top, _header_bottom); - _logic.FinalizeAction(); - } -}; -Asc['asc_docs_api'].prototype["Call_VR_Table"] = function(_params, _cols, _margins, _rows) -{ - var _logic = this.WordControl.m_oLogicDocument; - if ( false === _logic.Document_Is_SelectionLocked(AscCommon.changestype_Table_Properties) ) - { - _logic.StartAction(); - - var _table_murkup = Deserialize_Table_Markup(_params, _cols, _margins, _rows); - _table_murkup.Table = this.WordControl.m_oDrawingDocument.Table; - - _table_murkup.CorrectTo(); - _table_murkup.Table.Update_TableMarkupFromRuler(_table_murkup, false, _params[6]); - _table_murkup.CorrectFrom(); - - _logic.FinalizeAction(); - } -}; - -Asc['asc_docs_api'].prototype["Call_Menu_Event"] = function(type, _params) -{ - if (this.WordControl.m_oDrawingDocument.m_bIsMouseLockDocument) - { - // не делаем ничего. Как в веб версии отрубаем клавиатуру - return undefined; - } - - var _return = undefined; - var _current = { pos : 0 }; - var _continue = true; - switch (type) - { - case 1: // ASC_MENU_EVENT_TYPE_TEXTPR - { - var _textPr = new AscCommonWord.CTextPr(); - while (_continue) - { - var _attr = _params[_current.pos++]; - switch (_attr) - { - case 0: - { - _textPr.Bold = _params[_current.pos++]; - break; - } - case 1: - { - _textPr.Italic = _params[_current.pos++]; - break; - } - case 2: - { - _textPr.Underline = _params[_current.pos++]; - break; - } - case 3: - { - _textPr.Strikeout = _params[_current.pos++]; - break; - } - case 4: - { - _textPr.FontFamily = asc_menu_ReadFontFamily(_params, _current); - break; - } - case 5: - { - _textPr.FontSize = _params[_current.pos++]; - break; - } - case 6: - { - var Unifill = new AscFormat.CUniFill(); - Unifill.fill = new AscFormat.CSolidFill(); - var color = AscCommon.asc_menu_ReadColor(_params, _current); - Unifill.fill.color = AscFormat.CorrectUniColor(color, Unifill.fill.color, 1); - _textPr.Unifill = Unifill; - break; - } - case 7: - { - _textPr.VertAlign = _params[_current.pos++]; - break; - } - case 8: - { - var color = AscCommon.asc_menu_ReadColor(_params, _current); - if (color.a < 1) { - _textPr.HighLight = AscCommonWord.highlight_None; - } else { - _textPr.HighLight = { r: color.r, g: color.g, b: color.b }; - } - break; - } - case 9: - { - _textPr.DStrikeout = _params[_current.pos++]; - break; - } - case 10: - { - _textPr.Caps = _params[_current.pos++]; - break; - } - case 11: - { - _textPr.SmallCaps = _params[_current.pos++]; - break; - } - case 12: - { - _textPr.HighLight = AscCommonWord.highlight_None; - break; - } - case 13: - { - _textPr.Spacing = _params[_current.pos++]; - break; - } - case 255: - default: - { - _continue = false; - break; - } - } - } - - this.WordControl.m_oLogicDocument.StartAction(); - this.WordControl.m_oLogicDocument.AddToParagraph(new AscCommonWord.ParaTextPr(_textPr)); - this.WordControl.m_oLogicDocument.UpdateInterface(); - this.WordControl.m_oLogicDocument.FinalizeAction(); - break; - } - case 2: // ASC_MENU_EVENT_TYPE_PARAPR - { - var _textPr = undefined; - - this.WordControl.m_oLogicDocument.StartAction(); - - while (_continue) - { - var _attr = _params[_current.pos++]; - switch (_attr) - { - case 0: - { - this.WordControl.m_oLogicDocument.SetParagraphContextualSpacing( _params[_current.pos++] ); - break; - } - case 1: - { - var _ind = asc_menu_ReadParaInd(_params, _current); - this.WordControl.m_oLogicDocument.SetParagraphIndent( _ind ); - break; - } - case 2: - { - this.WordControl.m_oLogicDocument.SetParagraphKeepLines( _params[_current.pos++] ); - break; - } - case 3: - { - this.WordControl.m_oLogicDocument.SetParagraphKeepNext( _params[_current.pos++] ); - break; - } - case 4: - { - this.WordControl.m_oLogicDocument.SetParagraphWidowControl( _params[_current.pos++] ); - break; - } - case 5: - { - this.WordControl.m_oLogicDocument.SetParagraphPageBreakBefore( _params[_current.pos++] ); - break; - } - case 6: - { - var _spacing = asc_menu_ReadParaSpacing(_params, _current); - this.WordControl.m_oLogicDocument.SetParagraphSpacing( _spacing ); - break; - } - case 7: - { - // TODO: - var _brds = asc_menu_ReadParaBorders(_params, _current); - - if (_brds.Left && _brds.Left.Color) - { - _brds.Left.Unifill = AscFormat.CreateUnifillFromAscColor(_brds.Left.Color); - } - if (_brds.Top && _brds.Top.Color) - { - _brds.Top.Unifill = AscFormat.CreateUnifillFromAscColor(_brds.Top.Color); - } - if (_brds.Right && _brds.Right.Color) - { - _brds.Right.Unifill = AscFormat.CreateUnifillFromAscColor(_brds.Right.Color); - } - if (_brds.Bottom && _brds.Bottom.Color) - { - _brds.Bottom.Unifill = AscFormat.CreateUnifillFromAscColor(_brds.Bottom.Color); - } - - this.WordControl.m_oLogicDocument.SetParagraphBorders( _brds ); - break; - } - case 8: - { - var _shd = asc_menu_ReadParaShd(_params, _current); - this.WordControl.m_oLogicDocument.SetParagraphShd( _shd ); - break; - } - case 9: - case 10: - case 11: - { - // nothing - _current.pos++; - break; - } - case 12: - { - this.WordControl.m_oLogicDocument.Set_DocumentDefaultTab( _params[_current.pos++] ); - break; - } - case 13: - { - var _tabs = asc_menu_ReadParaTabs(_params, _current); - // TODO: - this.WordControl.m_oLogicDocument.SetParagraphTabs( _tabs.Tabs ); - break; - } - case 14: - { - var _framePr = asc_menu_ReadParaFrame(_params, _current); - this.WordControl.m_oLogicDocument.SetParagraphFramePr( _framePr ); - break; - } - case 15: - { - if (_textPr === undefined) - _textPr = new AscCommonWord.CTextPr(); - if (true == _params[_current.pos++]) - _textPr.VertAlign = AscCommon.vertalign_SubScript; - else - _textPr.VertAlign = AscCommon.vertalign_Baseline; - break; - } - case 16: - { - if (_textPr === undefined) - _textPr = new AscCommonWord.CTextPr(); - if (true == _params[_current.pos++]) - _textPr.VertAlign = AscCommon.vertalign_SuperScript; - else - _textPr.VertAlign = AscCommon.vertalign_Baseline; - break; - } - case 17: - { - if (_textPr === undefined) - _textPr = new AscCommonWord.CTextPr(); - _textPr.SmallCaps = _params[_current.pos++]; - _textPr.Caps = false; - break; - } - case 18: - { - if (_textPr === undefined) - _textPr = new AscCommonWord.CTextPr(); - _textPr.Caps = _params[_current.pos++]; - if (true == _textPr.Caps) - _textPr.SmallCaps = false; - break; - } - case 19: - { - if (_textPr === undefined) - _textPr = new AscCommonWord.CTextPr(); - _textPr.Strikeout = _params[_current.pos++]; - _textPr.DStrikeout = false; - break; - } - case 20: - { - if (_textPr === undefined) - _textPr = new AscCommonWord.CTextPr(); - _textPr.DStrikeout = _params[_current.pos++]; - if (true == _textPr.DStrikeout) - _textPr.Strikeout = false; - break; - } - case 21: - { - if (_textPr === undefined) - _textPr = new AscCommonWord.CTextPr(); - _textPr.TextSpacing = _params[_current.pos++]; - break; - } - case 22: - { - if (_textPr === undefined) - _textPr = new AscCommonWord.CTextPr(); - _textPr.Position = _params[_current.pos++]; - break; - } - case 23: - { - var _listType = asc_menu_ReadParaListType(_params, _current); - this.put_ListType(_listType.asc_getListType(), _listType.asc_getListSubType()); - break; - } - case 24: - { - this.WordControl.m_oLogicDocument.SetParagraphStyle( _params[_current.pos++] ); - break; - } - case 25: - { - this.WordControl.m_oLogicDocument.SetParagraphAlign( _params[_current.pos++] ); - break; - } - case 255: - default: - { - _continue = false; - break; - } - } - } - - if (undefined !== _textPr) - this.WordControl.m_oLogicDocument.AddToParagraph(new AscCommonWord.ParaTextPr(_textPr)); - - this.WordControl.m_oLogicDocument.UpdateInterface(); - this.WordControl.m_oLogicDocument.FinalizeAction(); - break; - } - case 22003: //ASC_MENU_EVENT_TYPE_ON_EDIT_TEXT - { - var oController = this.WordControl.m_oLogicDocument.DrawingObjects; - if(oController) - { - oController.startEditTextCurrentShape(); - } - break; - } - case 3: // ASC_MENU_EVENT_TYPE_UNDO - { - this.WordControl.m_oLogicDocument.Document_Undo(); - break; - } - case 4: // ASC_MENU_EVENT_TYPE_REDO - { - this.WordControl.m_oLogicDocument.Document_Redo(); - break; - } - case 7: // ASC_MENU_EVENT_TYPE_HEADERFOOTER - { - var bIsApply = (this.WordControl.m_oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_HdrFtr) === false) ? true : false; - - if (bIsApply) - this.WordControl.m_oLogicDocument.StartAction(); - - while (_continue) - { - var _attr = _params[_current.pos++]; - switch (_attr) - { - case 0: - { - _current.pos++; - break; - } - case 1: - { - if (bIsApply) - this.WordControl.m_oLogicDocument.Document_SetHdrFtrDistance(_params[_current.pos]); - - _current.pos++; - break; - } - case 2: - { - if (bIsApply) - this.WordControl.m_oLogicDocument.Document_SetHdrFtrFirstPage(_params[_current.pos]); - - _current.pos++; - break; - } - case 3: - { - if (bIsApply) - this.WordControl.m_oLogicDocument.Document_SetHdrFtrEvenAndOddHeaders(_params[_current.pos]); - - _current.pos++; - break; - } - case 4: - { - if (bIsApply) - this.WordControl.m_oLogicDocument.Document_SetHdrFtrLink(_params[_current.pos]); - - _current.pos++; - break; - } - case 5: - { - _current.pos++; - break; - } - case 6: - { - _current.pos++; - break; - } - case 255: - default: - { - _continue = false; - break; - } - } - } - - if (bIsApply) - this.WordControl.m_oLogicDocument.FinalizeAction(); - - break; - } - case 13: // ASC_MENU_EVENT_TYPE_INCREASEPARAINDENT - { - this.IncreaseIndent(); - break; - } - case 14: // ASC_MENU_EVENT_TYPE_DECREASEPARAINDENT - { - this.DecreaseIndent(); - break; - } - case 54: // ASC_MENU_EVENT_TYPE_INSERT_PAGEBREAK - { - this.put_AddPageBreak(); - break; - } - case 55: // ASC_MENU_EVENT_TYPE_INSERT_LINEBREAK - { - this.put_AddLineBreak(); - break; - } - case 56: // ASC_MENU_EVENT_TYPE_INSERT_PAGENUMBER - { - if (_params[0] < 0) { - this.put_PageNum(-1); - } else { - this.put_PageNum((_params[0] >> 16) & 0xFFFF, _params[0] & 0xFFFF); - } - break; - } - case 57: // ASC_MENU_EVENT_TYPE_INSERT_SECTIONBREAK - { - this.add_SectionBreak(_params[0]); - break; - } - case 10: // ASC_MENU_EVENT_TYPE_TABLE - { - var _tablePr = new Asc.CTableProp(); - while (_continue) - { - var _attr = _params[_current.pos++]; - switch (_attr) - { - case 0: - { - _tablePr.CanBeFlow = _params[_current.pos++]; - break; - } - case 1: - { - _tablePr.CellSelect = _params[_current.pos++]; - break; - } - case 2: - { - _tablePr.TableWidth = _params[_current.pos++]; - break; - } - case 3: - { - _tablePr.TableSpacing = _params[_current.pos++]; - break; - } - case 4: - { - _tablePr.TableDefaultMargins = AscCommon.asc_menu_ReadPaddings(_params, _current); - break; - } - case 5: - { - _tablePr.CellMargins = asc_menu_ReadCellMargins(_params, _current); - break; - } - case 6: - { - _tablePr.TableAlignment = _params[_current.pos++]; - break; - } - case 7: - { - _tablePr.TableIndent = _params[_current.pos++]; - break; - } - case 8: - { - _tablePr.TableWrappingStyle = _params[_current.pos++]; - break; - } - case 9: - { - _tablePr.TablePaddings = AscCommon.asc_menu_ReadPaddings(_params, _current); - break; - } - case 10: - { - _tablePr.TableBorders = asc_menu_ReadCellBorders(_params, _current); - break; - } - case 11: - { - _tablePr.CellBorders = asc_menu_ReadCellBorders(_params, _current); - break; - } - case 12: - { - _tablePr.TableBackground = asc_menu_ReadCellBackground(_params, _current); - break; - } - case 13: - { - _tablePr.CellsBackground = asc_menu_ReadCellBackground(_params, _current); - break; - } - case 14: - { - _tablePr.Position = asc_menu_ReadPosition(_params, _current); - break; - } - case 15: - { - _tablePr.PositionH = asc_menu_ReadImagePosition(_params, _current); - break; - } - case 16: - { - _tablePr.PositionV = asc_menu_ReadImagePosition(_params, _current); - break; - } - case 17: - { - _tablePr.Internal_Position = asc_menu_ReadTableAnchorPosition(_params, _current); - break; - } - case 18: - { - _tablePr.ForSelectedCells = _params[_current.pos++]; - break; - } - case 19: - { - _tablePr.TableStyle = _params[_current.pos++]; - break; - } - case 20: - { - _tablePr.TableLook = asc_menu_ReadTableLook(_params, _current); - break; - } - case 21: - { - _tablePr.RowsInHeader = _params[_current.pos++]; - break; - } - case 22: - { - _tablePr.CellsVAlign = _params[_current.pos++]; - break; - } - case 23: - { - _tablePr.AllowOverlap = _params[_current.pos++]; - break; - } - case 24: - { - _tablePr.TableLayout = _params[_current.pos++]; - break; - } - case 25: - { - _tablePr.Locked = _params[_current.pos++]; - break; - } - case 255: - default: - { - _continue = false; - break; - } - } - } - - this.tblApply(_tablePr); - break; - } - case 9 : // ASC_MENU_EVENT_TYPE_IMAGE - { - var _imagePr = new Asc.asc_CImgProperty(); - while (_continue) - { - var _attr = _params[_current.pos++]; - switch (_attr) - { - case 0: - { - _imagePr.CanBeFlow = _params[_current.pos++]; - break; - } - case 1: - { - _imagePr.Width = _params[_current.pos++]; - break; - } - case 2: - { - _imagePr.Height = _params[_current.pos++]; - break; - } - case 3: - { - _imagePr.WrappingStyle = _params[_current.pos++]; - break; - } - case 4: - { - _imagePr.Paddings = AscCommon.asc_menu_ReadPaddings(_params, _current); - break; - } - case 5: - { - _imagePr.Position = asc_menu_ReadPosition(_params, _current); - break; - } - case 6: - { - _imagePr.AllowOverlap = _params[_current.pos++]; - break; - } - case 7: - { - _imagePr.PositionH = asc_menu_ReadImagePosition(_params, _current); - break; - } - case 8: - { - _imagePr.PositionV = asc_menu_ReadImagePosition(_params, _current); - break; - } - case 9: - { - _imagePr.Internal_Position = _params[_current.pos++]; - break; - } - case 10: - { - _imagePr.ImageUrl = _params[_current.pos++]; - break; - } - case 11: - { - _imagePr.Locked = _params[_current.pos++]; - break; - } - case 12: - { - _imagePr.ChartProperties = asc_menu_ReadChartPr(_params, _current); - break; - } - case 13: - { - _imagePr.ShapeProperties = asc_menu_ReadShapePr(_params, _current); - break; - } - case 14: - { - _imagePr.put_ChangeLevel(parseInt(_params[_current.pos++])); - break; - } - case 15: - { - _imagePr.Group = _params[_current.pos++]; - break; - } - case 16: - { - _imagePr.fromGroup = _params[_current.pos++]; - break; - } - case 17: - { - _imagePr.severalCharts = _params[_current.pos++]; - break; - } - case 18: - { - _imagePr.severalChartTypes = _params[_current.pos++]; - break; - } - case 19: - { - _imagePr.severalChartStyles = _params[_current.pos++]; - break; - } - case 20: - { - _imagePr.verticalTextAlign = _params[_current.pos++]; - break; - } - case 21: - { - _imagePr.vert = _params[_current.pos++]; - break; - } - case 22: - { - var bIsNeed = _params[_current.pos++]; - - if (bIsNeed) { - var properties = this.WordControl.m_oLogicDocument.DrawingObjects.Get_Props(); - if (properties) { - for (var i = 0; i < properties.length; i++) { - if (undefined !== properties[i].ImageUrl && null != properties[i].ImageUrl) { - var section_select = this.WordControl.m_oLogicDocument.Get_PageSizesByDrawingObjects(); - var page_width = AscCommon.Page_Width; - var page_height = AscCommon.Page_Height; - var page_x_left_margin = AscCommon.X_Left_Margin; - var page_y_top_margin = AscCommon.Y_Top_Margin; - var page_x_right_margin = AscCommon.X_Right_Margin; - var page_y_bottom_margin = AscCommon.Y_Bottom_Margin; - - if (section_select) { - if (section_select.W) { - page_width = section_select.W; - } - - if (section_select.H) { - page_height = section_select.H; - } - } - - var boundingWidth = Math.max(1, page_width - (page_x_left_margin + page_x_right_margin)); - var boundingHeight = Math.max(1, page_height - (page_y_top_margin + page_y_bottom_margin)); - - var size = this.WordControl.m_oDrawingDocument.Native["DD_GetOriginalImageSize"](properties[i].ImageUrl); - - var w = (undefined !== size[0]) ? Math.max(size[0] * AscCommon.g_dKoef_pix_to_mm, 1) : 1; - var h = (undefined !== size[1]) ? Math.max(size[1] * AscCommon.g_dKoef_pix_to_mm, 1) : 1; - - var mW = boundingWidth / w; - var mH = boundingHeight / h; - - if (mH < mW) { - boundingWidth = boundingHeight / h * w; - } else if (mW < mH) { - boundingHeight = boundingWidth / w * h; - } - - //var __w = Math.max(1, page_width - (page_x_left_margin + page_x_right_margin)); - //var __h = Math.max(1, page_height - (page_y_top_margin + page_y_bottom_margin)); - - //w = Math.max(5, boundingWidth); - //h = Math.max(5, boundingHeight); - - _imagePr.Width = Math.max(5, boundingWidth); - _imagePr.Height = Math.max(5, boundingHeight); - _imagePr.ImageUrl = undefined; - - break; - } - } - } - } - - break; - } - case 255: - default: - { - _continue = false; - break; - } - } - } - - this.ImgApply(_imagePr); - break; - } - case 15: // ASC_MENU_EVENT_TYPE_TABLEMERGECELLS - { - this.MergeCells(); - break; - } - case 16: // ASC_MENU_EVENT_TYPE_TABLESPLITCELLS - { - this.SplitCell(_params[0], _params[1]); - break; - } - case 51: // ASC_MENU_EVENT_TYPE_INSERT_TABLE - { - var _rows = 2; - var _cols = 2; - var _style = null; - - while (_continue) - { - var _attr = _params[_current.pos++]; - switch (_attr) - { - case 0: - { - _rows = _params[_current.pos++]; - break; - } - case 1: - { - _cols = _params[_current.pos++]; - break; - } - case 2: - { - _style = _params[_current.pos++]; - break; - } - case 255: - default: - { - _continue = false; - break; - } - } - } - _style = _style + ""; - this.put_Table(_rows, _cols, _style); - break; - } - case 50: // ASC_MENU_EVENT_TYPE_INSERT_IMAGE - { - var _src = _params[_current.pos++]; - var _w = _params[_current.pos++]; - var _h = _params[_current.pos++]; - var _pageNum = _params[_current.pos++]; - var _additionalParams = _params[_current.pos++]; - var _posX = _params[_current.pos++]; - var _posY = _params[_current.pos++]; - var _wrapType = _params[_current.pos++]; - - this.AddImageUrlNative(_src, _w, _h, _pageNum); - break; - } - case 401: // ASC_MENU_EVENT_TYPE_INSERT_SCREEN_IMAGE - { - var _src = _params[_current.pos++]; - var _w = _params[_current.pos++]; - var _h = _params[_current.pos++]; - var _pageNum = _params[_current.pos++]; - var _additionalParams = _params[_current.pos++]; - var _posX = _params[_current.pos++]; - var _posY = _params[_current.pos++]; - var _wrapType = _params[_current.pos++]; - - this.AddImageUrlAtPosNative(_src, _w, _h, _pageNum, _posX, _posY, _wrapType); - break; - } - case 53: // ASC_MENU_EVENT_TYPE_INSERT_SHAPE - { - var _shapeProp = asc_menu_ReadShapePr(_params, _current); - var _pageNum = _shapeProp.InsertPageNum; - this.WordControl.m_oLogicDocument.DrawingObjects.addShapeOnPage(_shapeProp.type, _shapeProp.InsertPageNum); - break; - } - case 52: // ASC_MENU_EVENT_TYPE_INSERT_HYPERLINK - { - var _props = asc_menu_ReadHyperPr(_params, _current); - if ( false === this.WordControl.m_oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_Paragraph_Content) ) - { - this.WordControl.m_oLogicDocument.StartAction(); - this.WordControl.m_oLogicDocument.AddHyperlink( _props ); - this.WordControl.m_oLogicDocument.FinalizeAction(); - } - break; - } - case 8: // ASC_MENU_EVENT_TYPE_HYPERLINK - { - var _props = asc_menu_ReadHyperPr(_params, _current); - var oHyperProps = null; - for(var i = 0; i < this.SelectedObjectsStack.length; ++i) - { - if(this.SelectedObjectsStack[i].Type === Asc.c_oAscTypeSelectElement.Hyperlink) - { - oHyperProps = this.SelectedObjectsStack[i].Value; - _props.Class = oHyperProps.Class; - break; - } - } - if ( oHyperProps && false === this.WordControl.m_oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_Paragraph_Content) ) - { - this.WordControl.m_oLogicDocument.StartAction(); - this.WordControl.m_oLogicDocument.ModifyHyperlink( _props ); - this.WordControl.m_oLogicDocument.FinalizeAction(); - } - break; - } - case 59: // ASC_MENU_EVENT_TYPE_REMOVE_HYPERLINK - { - - var oHyperProps = null; - for(var i = 0; i < this.SelectedObjectsStack.length; ++i) - { - if(this.SelectedObjectsStack[i].Type === Asc.c_oAscTypeSelectElement.Hyperlink) - { - oHyperProps = this.SelectedObjectsStack[i].Value; - break; - } - } - if (oHyperProps && false === this.WordControl.m_oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_Paragraph_Content) ) - { - this.WordControl.m_oLogicDocument.StartAction(); - this.WordControl.m_oLogicDocument.RemoveHyperlink(oHyperProps); - this.WordControl.m_oLogicDocument.FinalizeAction(); - } - break; - } - case 58: // ASC_MENU_EVENT_TYPE_CAN_ADD_HYPERLINK - { - var bCanAdd = this.WordControl.m_oLogicDocument.CanAddHyperlink(true); - - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - if ( true === bCanAdd ) - { - var _text = this.WordControl.m_oLogicDocument.GetSelectedText(true); - if (null == _text) - _stream["WriteByte"](1); - else - { - _stream["WriteByte"](2); - _stream["WriteString2"](_text); - } - } - else - { - _stream["WriteByte"](0); - } - _return = _stream; - break; - } - case 62: // ASC_MENU_EVENT_TYPE_SEARCH_FINDTEXT - { - var searchSettings = new AscCommon.CSearchSettings(); - searchSettings.put_Text(_params[0]); - searchSettings.put_MatchCase(_params[2]); - - var _ret = _api.asc_findText(searchSettings, _params[1]); - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - _stream["WriteLong"](_ret); - _return = _stream; - break; - } - case 63: // ASC_MENU_EVENT_TYPE_SEARCH_REPLACETEXT - { - var searchSettings = new AscCommon.CSearchSettings(); - searchSettings.put_Text(_params[0]); - searchSettings.put_MatchCase(_params[3]); - - var _ret = _api.asc_replaceText(searchSettings, _params[1], _params[2]); - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - _stream["WriteBool"](_ret); - _return = _stream; - break; - } - case 64: // ASC_MENU_EVENT_TYPE_SEARCH_SELECTRESULTS - { - this.asc_selectSearchingResults(_params[0]); - break; - } - case 65: // ASC_MENU_EVENT_TYPE_SEARCH_ISSELECTRESULTS - { - var _ret = this.asc_isSelectSearchingResults(); - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - _stream["WriteBool"](_ret); - _return = _stream; - break; - } - case 67: // ASC_MENU_EVENT_TYPE_STATISTIC_START - { - _api.startGetDocInfo(); - break; - } - case 68: // ASC_MENU_EVENT_TYPE_STATISTIC_STOP - { - _api.stopGetDocInfo(); - break; - } - case 17: - { - var _sect_width = undefined; - var _sect_height = undefined; - var _sect_orient = undefined; - - while (_continue) - { - var _attr = _params[_current.pos++]; - switch (_attr) - { - case 0: - { - _sect_width = _params[_current.pos++]; - break; - } - case 1: - { - _sect_height = _params[_current.pos++]; - break; - } - case 2: - { - // margin_left - _current.pos++; - break; - } - case 3: - { - // margin_top - _current.pos++; - break; - } - case 4: - { - // margin_right - _current.pos++; - break; - } - case 5: - { - // margin_bottom - _current.pos++; - break; - } - case 6: - { - _sect_orient = _params[_current.pos++]; - break; - } - case 255: - default: - { - _continue = false; - break; - } - } - } - - if (undefined !== _sect_width && undefined !== _sect_height) - this.change_DocSize(_sect_width, _sect_height); - - if (undefined !== _sect_orient) - this.change_PageOrient(_sect_orient); - - break; - } - case 200: // ASC_MENU_EVENT_TYPE_DOCUMENT_BASE64 - { - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - _stream["WriteStringA"](this["asc_nativeGetFileData"]()); - _return = _stream; - break; - } - case 202: // ASC_MENU_EVENT_TYPE_DOCUMENT_PDFBASE64 - case 203: // ASC_MENU_EVENT_TYPE_DOCUMENT_PDFBASE64_PRINT - { - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - _stream["WriteStringA"](this.WordControl.m_oDrawingDocument.ToRenderer(203 === type)); - _return = _stream; - break; - } - case 110: // ASC_MENU_EVENT_TYPE_CONTEXTMENU_COPY - { - _return = this.Call_Menu_Context_Copy(); - break; - } - case 111 : // ASC_MENU_EVENT_TYPE_CONTEXTMENU_CUT - { - _return = this.Call_Menu_Context_Cut(); - break; - } - case 112: // ASC_MENU_EVENT_TYPE_CONTEXTMENU_PASTE - { - this.Call_Menu_Context_Paste(_params[0], _params[1]); - break; - } - case 113: // ASC_MENU_EVENT_TYPE_CONTEXTMENU_DELETE - { - this.Call_Menu_Context_Delete(); - break; - } - case 114: // ASC_MENU_EVENT_TYPE_CONTEXTMENU_SELECT - { - this.Call_Menu_Context_Select(); - break; - } - case 115: // ASC_MENU_EVENT_TYPE_CONTEXTMENU_SELECTALL - { - this.Call_Menu_Context_SelectAll(); - break; - } - case 201: // ASC_MENU_EVENT_TYPE_DOCUMENT_CHARTSTYLES - { - var _typeChart = _params[0]; - this.chartPreviewManager.getChartPreviews(_typeChart); - _return = global_memory_stream_menu; - break; - } - case 71: // ASC_MENU_EVENT_TYPE_TABLE_INSERTDELETE_ROWCOLUMN - { - if (typeof _params[0] === 'string') { - var json = JSON.parse(_params[0]); - if (json) { - var isInsert = json["insert"] || false; - var isDelete = json["delete"] || false; - var type = json["type"] || "table"; - - if (isInsert) { - if (type === "row") { - json["above"] ? _api.addRowAbove() : _api.addRowBelow(); - } else if (type == "column") { - json["left"] ? _api.addColumnLeft() : _api.addColumnRight(); - } - } else if (isDelete) { - if (type === "row") { - _api.remRow(); - } else if (type === "column") { - _api.remColumn(); - } else { - _api.remTable(); - } - } - } - } else { - var _type = 0; - var _is_add = true; - var _is_above = true; - while (_continue) { - var _attr = _params[_current.pos++]; - switch (_attr) { - case 0: - { - _type = _params[_current.pos++]; - break; - } - case 1: - { - _is_add = _params[_current.pos++]; - break; - } - case 2: - { - _is_above = _params[_current.pos++]; - break; - } - case 255: - default: - { - _continue = false; - break; - } - } - } - - if (1 == _type) { - if (false === this.WordControl.m_oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_Table_Properties)) { - this.WordControl.m_oLogicDocument.StartAction(AscDFH.historydescription_Document_TableAddColumnLeft); - if (_is_add) - this.WordControl.m_oLogicDocument.AddTableColumn(!_is_above); - else - this.WordControl.m_oLogicDocument.RemoveTableColumn(); - - this.WordControl.m_oLogicDocument.FinalizeAction(); - } - } - else if (2 == _type) { - if (false === this.WordControl.m_oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_Table_Properties)) { - this.WordControl.m_oLogicDocument.StartAction(AscDFH.historydescription_Document_TableAddColumnLeft); - if (_is_add) - this.WordControl.m_oLogicDocument.AddTableRow(!_is_above); - else - this.WordControl.m_oLogicDocument.RemoveTableRow(); - - this.WordControl.m_oLogicDocument.FinalizeAction(); - } - } - - } - break; - } - - case 440: // ASC_MENU_EVENT_TYPE_ADD_CHART_DATA - { - if (undefined !== _params) { - var chartData = _params[0]; - if (chartData && chartData.length > 0) { - var json = JSON.parse(chartData); - if (json) { - _api.asc_addChartDrawingObject(json); - } - } - } - break; - } - - case 450: // ASC_MENU_EVENT_TYPE_GET_CHART_DATA - { - var index = null; - if (undefined !== _params) { - index = parseInt(_params); - } - - var chart = _api.asc_getChartObject(index); - - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - _stream["WriteStringA"](JSON.stringify(new Asc.asc_CChartBinary(chart))); - _return = _stream; - break; - } - - case 460: // ASC_MENU_EVENT_TYPE_SET_CHART_DATA - { - if (undefined !== _params) { - var chartData = _params[0]; - if (chartData && chartData.length > 0) { - var json = JSON.parse(chartData); - if (json) { - _api.asc_editChartDrawingObject(json); - } - } - } - break; - } - - case 2415: // ASC_MENU_EVENT_TYPE_CHANGE_COLOR_SCHEME - { - if (undefined !== _params) { - var indexScheme = parseInt(_params); - _api.asc_ChangeColorSchemeByIdx(indexScheme); - } - break; - } - - case 2416: // ASC_MENU_EVENT_TYPE_GET_COLOR_SCHEME - { - var index = _api.asc_GetCurrentColorSchemeIndex(); - var stream = global_memory_stream_menu; - stream["ClearNoAttack"](); - stream["WriteLong"](index); - _return = stream; - break; - } - - case 10000: // ASC_SOCKET_EVENT_TYPE_OPEN - { - _api.CoAuthoringApi._CoAuthoringApi.socketio.onMessage("connect"); - break; - } - - case 10010: // ASC_SOCKET_EVENT_TYPE_ON_CLOSE - { - // NOT USED - break; - } - - case 10020: // ASC_SOCKET_EVENT_TYPE_MESSAGE - { - _api.CoAuthoringApi._CoAuthoringApi.socketio.onMessage("message", _params ? JSON.parse(_params) : {}); - break; - } - - case 11010: // ASC_SOCKET_EVENT_TYPE_ON_DISCONNECT - { - _api.CoAuthoringApi._CoAuthoringApi.socketio.onMessage("disconnect", _params || ""); - break; - } - - case 11020: // ASC_SOCKET_EVENT_TYPE_TRY_RECONNECT - { - // NOT USED - break; - } - - case 21000: // ASC_COAUTH_EVENT_TYPE_INSERT_URL_IMAGE - { - var urls = JSON.parse(_params[0]); - AscCommon.g_oDocumentUrls.addUrls(urls); - var firstUrl; - for (var i in urls) { - if (urls.hasOwnProperty(i)) { - firstUrl = urls[i]; - break; - } - } - - var _src = firstUrl; - var _w = _params[1]; - var _h = _params[2]; - var _pageNum = _params[3]; - - this.AddImageUrlActionNative(_src, _w, _h, _pageNum); - break; - } - - case 21001: // ASC_COAUTH_EVENT_TYPE_LOAD_URL_IMAGE - { - _api.WordControl.m_oDrawingDocument.ClearCachePages(); - _api.WordControl.m_oDrawingDocument.FirePaint(); - - break; - } - - case 21002: // ASC_COAUTH_EVENT_TYPE_REPLACE_URL_IMAGE - { - var urls = JSON.parse(_params[0]); - AscCommon.g_oDocumentUrls.addUrls(urls); - var firstUrl; - for (var i in urls) { - if (urls.hasOwnProperty(i)) { - firstUrl = urls[i]; - break; - } - } - - var _src = firstUrl; - - var imageProp = new asc_CImgProperty(); - imageProp.ImageUrl = _src; - this.ImgApply(imageProp); - - break; - } - - case 21003: // ASC_COAUTH_EVENT_TYPE_INSERT_SCREEN_URL_IMAGE - { - var urls = JSON.parse(_params[_current.pos++]); - AscCommon.g_oDocumentUrls.addUrls(urls); - var firstUrl; - for (var i in urls) { - if (urls.hasOwnProperty(i)) { - firstUrl = urls[i]; - break; - } - } - - var _src = firstUrl; - var _w = _params[_current.pos++]; - var _h = _params[_current.pos++]; - var _pageNum = _params[_current.pos++]; - var _additionalParams = _params[_current.pos++]; - var _posX = _params[_current.pos++]; - var _posY = _params[_current.pos++]; - var _wrapType = _params[_current.pos++]; - - this.AddImageUrlAtPosNative(_src, _w, _h, _pageNum, _posX, _posY, _wrapType); - break; - } - - case 22001: // ASC_MENU_EVENT_TYPE_SET_PASSWORD - { - _api.asc_setDocumentPassword(_params[0]); - break; - } - - case 22000: // ASC_MENU_EVENT_TYPE_ADVANCED_OPTIONS - { - var obj = JSON.parse(_params); - var type = parseInt(obj["type"]); - var encoding = parseInt(obj["encoding"]); - - _api.advancedOptionsAction = AscCommon.c_oAscAdvancedOptionsAction.Open; - _api.documentFormat = "txt"; - - _api.asc_setAdvancedOptions(type, new Asc.asc_CTextOptions(encoding)); - - break; - } - - case 22004: // ASC_EVENT_TYPE_SPELLCHECK_MESSAGE - { - var spellData = JSON.parse(_params[0]); - if (_api.SpellCheckApi && spellData) - _api.SpellCheckApi.onSpellCheck(spellData); - break; - } - - case 22005: // ASC_EVENT_TYPE_SPELLCHECK_TURN_ON - { - var status = parseInt(_params[0]); - if (status !== undefined) { - this.asc_setSpellCheck(status == 0 ? false : true); - } - break; - } - - case 22006: // ASC_EVENT_TYPE_DO_NONPRINTING_DISPLAY - { - var json = JSON.parse(_params[0]); - if (json) { - var display = json["display"] || false; - if (_api.put_ShowParaMarks) { - _api.put_ShowParaMarks(display); - } - if (_api.put_ShowTableEmptyLine) { - _api.put_ShowTableEmptyLine(display); - } - _api.WordControl.m_oDrawingDocument.ClearCachePages(); - _api.WordControl.m_oDrawingDocument.FirePaint(); - } - break; - } - - case 23101: // ASC_MENU_EVENT_TYPE_DO_SELECT_COMMENT - { - var json = JSON.parse(_params[0]); - if (json && json["id"]) { - var id = parseInt(json["id"]); - if (_api.asc_selectComment && id) { - _api.asc_selectComment(id); - } - } - break; - } - - case 23102: // ASC_MENU_EVENT_TYPE_DO_SHOW_COMMENT - { - var json = JSON.parse(_params[0]); - if (json && json["id"]) { - if (_api.asc_showComment) { - _api.asc_showComment(json["id"], json["isNew"] === true); - } - } - break; - } - - case 23103: // ASC_MENU_EVENT_TYPE_DO_SELECT_COMMENTS - { - var json = JSON.parse(_params[0]); - if (json) { - if (_api.asc_showComments) { - _api.asc_showComments(json["resolved"] === true); - } - } - break; - } - - case 23104: // ASC_MENU_EVENT_TYPE_DO_DESELECT_COMMENTS - { - if (_api.asc_hideComments) { - _api.asc_hideComments(); - } - break; - } - - case 23105: // ASC_MENU_EVENT_TYPE_DO_ADD_COMMENT - { - var json = JSON.parse(_params[0]); - if (json) { - var buildCommentData = function () { - if (typeof Asc.asc_CCommentDataWord !== 'undefined') { - return new Asc.asc_CCommentDataWord(null); - } - return new Asc.asc_CCommentData(null); - }; - - var comment = buildCommentData(); - var now = new Date(); - var timeZoneOffsetInMs = (new Date()).getTimezoneOffset() * 60000; - var currentUserId = _internalStorage.externalUserInfo.asc_getId(); - var currentUserName = _internalStorage.externalUserInfo.asc_getFullName(); - - if (comment) { - comment.asc_putText(json["text"]); - comment.asc_putTime((now.getTime() - timeZoneOffsetInMs).toString()); - comment.asc_putOnlyOfficeTime(now.getTime().toString()); - comment.asc_putUserId(currentUserId); - comment.asc_putUserName(currentUserName); - comment.asc_putSolved(false); - - if (comment.asc_putDocumentFlag) { - comment.asc_putDocumentFlag(json["unattached"]); - } - - _api.asc_addComment(comment); - } - } - break; - } - - case 23106: // ASC_MENU_EVENT_TYPE_DO_REMOVE_COMMENT - { - var json = JSON.parse(_params[0]); - if (json && json["id"]) { // id - String - if (_api.asc_removeComment) { - _api.asc_removeComment(json["id"]); - } - } - break; - } - - case 23107: // ASC_MENU_EVENT_TYPE_DO_REMOVE_ALL_COMMENTS - { - var json = JSON.parse(_params[0]), - type = json["type"], - canEditComments = json["canEditComments"]; - if (json && type) { - if (_api.asc_RemoveAllComments) { - _api.asc_RemoveAllComments(type=='my' || !(canEditComments === true), type=='current'); // 1 param = true if remove only my comments, 2 param - remove current comments - } - } - break; - } - - case 23108: // ASC_MENU_EVENT_TYPE_DO_CHANGE_COMMENT - { - var json = JSON.parse(_params[0]), - commentId = json["id"], - comment = json["comment"], - updateAuthor = json["updateAuthor"] || false; - - if (json && commentId) { - var timeZoneOffsetInMs = (new Date()).getTimezoneOffset() * 60000; - var currentUserId = _internalStorage.externalUserInfo.asc_getId(); - var currentUserName = _internalStorage.externalUserInfo.asc_getFullName(); - var buildCommentData = function () { - if (typeof Asc.asc_CCommentDataWord !== 'undefined') { - return new Asc.asc_CCommentDataWord(null); - } - return new Asc.asc_CCommentData(null); - }; - var ooDateToString = function (date) { - if (Object.prototype.toString.call(date) === '[object Date]') - return (date.getTime()).toString(); - return ""; - }; - var utcDateToString = function (date) { - if (Object.prototype.toString.call(date) === '[object Date]') - return (date.getTime() - timeZoneOffsetInMs).toString(); - return ""; - }; - var ascComment = buildCommentData(); - - if (ascComment && comment && _api.asc_changeComment) { - var sTime = new Date(parseInt(comment["date"])); - ascComment.asc_putText(comment["text"]); - ascComment.asc_putQuoteText(comment["quoteText"]); - ascComment.asc_putTime(utcDateToString(sTime)); - ascComment.asc_putOnlyOfficeTime(ooDateToString(sTime)); - ascComment.asc_putUserId(updateAuthor ? currentUserId : comment["userId"]); - ascComment.asc_putUserName(updateAuthor ? currentUserName : comment["userName"]); - ascComment.asc_putSolved(comment["solved"]); - ascComment.asc_putGuid(comment["id"]); - - if (ascComment.asc_putDocumentFlag !== undefined) { - ascComment.asc_putDocumentFlag(comment["unattached"]); - } - - var replies = comment["replies"]; - - if (replies && replies.length) { - replies.forEach(function (reply) { - var addReply = buildCommentData(); // new asc_CCommentData(null); - if (addReply) { - var sTime = new Date(parseInt(reply["date"])); - addReply.asc_putText(reply["text"]); - addReply.asc_putTime(utcDateToString(sTime)); - addReply.asc_putOnlyOfficeTime(ooDateToString(sTime)); - addReply.asc_putUserId(reply["userId"]); - addReply.asc_putUserName(reply["userName"]); - - ascComment.asc_addReply(addReply); - } - }); - } - - _api.asc_changeComment(commentId, ascComment); - } - } - break; - } - - case 23109: // ASC_MENU_EVENT_TYPE_DO_CAN_ADD_QUOTED_COMMENT - { - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - _stream["WriteString2"](JSON.stringify({ - result: this.can_AddQuotedComment() !== false - })); - _return = _stream; - break; - } - - case 24101: // ASC_MENU_EVENT_TYPE_DO_SET_TRACK_REVISIONS - { - var json = JSON.parse(_params[0]); - if (json) { - if (_api.asc_SetTrackRevisions) { - _api.asc_SetTrackRevisions(json["state"] === true); - } - } - break; - } - case 24102: // ASC_MENU_EVENT_TYPE_DO_BEGIN_VIEWMODE_IN_REVIEW - { - var json = JSON.parse(_params[0]); - if (json) { - if (_api.asc_BeginViewModeInReview) { - _api.asc_BeginViewModeInReview(json["review"] === true); - } - } - break; - } - case 24103: // ASC_MENU_EVENT_TYPE_DO_END_VIEWMODE_IN_REVIEW - { - if (_api.asc_EndViewModeInReview) { - _api.asc_EndViewModeInReview(); - } - break; - } - case 24104: // ASC_MENU_EVENT_TYPE_DO_ACCEPT_ALL_CHANGES - { - if (_api.asc_AcceptAllChanges) { - _api.asc_AcceptAllChanges(); - } - break; - } - case 24105: // ASC_MENU_EVENT_TYPE_DO_REJECT_ALL_CHANGES - { - if (_api.asc_RejectAllChanges) { - _api.asc_RejectAllChanges(); - } - break; - } - case 24106: // ASC_MENU_EVENT_TYPE_DO_GET_PREV_REVISIONS_CHANGE - { - if (_api.asc_GetPrevRevisionsChange) { - _api.asc_GetPrevRevisionsChange(); - } - break; - } - case 24107: // ASC_MENU_EVENT_TYPE_DO_GET_NEXT_REVISIONSCHANGE - { - if (_api.asc_GetNextRevisionsChange) { - _api.asc_GetNextRevisionsChange(); - } - break; - } - case 24108: // ASC_MENU_EVENT_TYPE_DO_ACCEPT_CHANGES - { - var api = _api; - if (api.asc_AcceptChanges) { - api.asc_AcceptChanges(_internalStorage.changesReview[0]); - - if (api.asc_GetNextRevisionsChange) { - setTimeout(function () { - api.asc_GetNextRevisionsChange(); - }, 10); - } - } - break; - } - case 24109: // ASC_MENU_EVENT_TYPE_DO_REJECT_CHANGES - { - var api = _api; - if (api.asc_RejectChanges) { - api.asc_RejectChanges(_internalStorage.changesReview[0]); - if (api.asc_GetNextRevisionsChange) { - setTimeout(function () { - api.asc_GetNextRevisionsChange(); - }, 10); - } - } - break; - } - case 24110: // ASC_MENU_EVENT_TYPE_DO_FOLLOW_REVISION_MOVE - { - if (_api.asc_FollowRevisionMove) { - _api.asc_FollowRevisionMove(_internalStorage.changesReview[0]); - } - break; - } - - case 25001: // ASC_MENU_EVENT_TYPE_DO_API_FUNCTION_CALL - { - var json = JSON.parse(_params[0]), - func = json["func"], - params = json["params"] || [], - returnable = json["returnable"] || false; // need return result - - if (json && func) { - if (_api[func]) { - if (returnable) { - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - var result = _api[func].apply(_api, params); - _stream["WriteString2"](JSON.stringify({ - result: result - })); - _return = _stream; - } else { - _api[func].apply(_api, params); - } - } - } - break; - } - - case 26003: // ASC_MENU_EVENT_TYPE_DO_SET_CONTENTCONTROL_PICTURE - { - var _src = _params[_current.pos++]; - var _w = _params[_current.pos++]; - var _h = _params[_current.pos++]; - var _pageNum = _params[_current.pos++]; - var _additionalParams = _params[_current.pos++]; - - var json = JSON.parse(_additionalParams); - if (json) { - var internalId = json["internalId"] || ""; - _api.SetContentControlPictureUrlNative(_src, internalId) - } - break; - } - - case 26004: // ASC_MENU_EVENT_TYPE_DO_SET_CONTENTCONTROL_PICTURE_URL - { - var urls = JSON.parse(_params[0]); - AscCommon.g_oDocumentUrls.addUrls(urls); - var firstUrl; - for (var i in urls) { - if (urls.hasOwnProperty(i)) { - firstUrl = urls[i]; - break; - } - } - - var _src = firstUrl; - var _w = _params[1]; - var _h = _params[2]; - var _pageNum = _params[3]; - var _additionalParams = _params[4]; - - var json = JSON.parse(_additionalParams); - if (json) { - var internalId = json["internalId"] || ""; - _api.SetContentControlPictureUrlNative(_src, internalId); - } - break; - } - - case 27001: //ASC_MENU_EVENT_TYPE_SET_FOOTNOTE_PROP - { - var json = JSON.parse(_params), - pos = json["Pos"], - numFormat = json["NumFormat"], - numStart = json["NumStart"], - numRestart = json["NumRestart"], - isAll = json["IsAll"] || true, - isEndnote = json["IsEndnote"] || false; - - var props = new Asc.CAscFootnotePr(); - props.put_Pos(pos); - props.put_NumFormat(numFormat); - props.put_NumStart(numStart); - props.put_NumRestart(numRestart); - - if (isEndnote) { - _api.asc_SetEndnoteProps(props, isAll); - } else { - _api.asc_SetFootnoteProps(props, isAll); - } - break; - } - case 2500: // ASC_MENU_EVENT_TYPE_CHANGE_MOBILE_MODE - { - _api.ChangeReaderMode(); - break; - } - - default: - break; - } - return _return; -}; - -// STYLES -Asc['asc_docs_api'].prototype.GenerateNativeStyles = function() -{ - var StylesPainter = new CStylesPainter(); - StylesPainter.GenerateStyles(this, this.LoadedObjectDS); -}; - -Asc['asc_docs_api'].prototype.asc_setDocumentPassword = function(password) -{ - var v = { - "id": this.documentId, - "userid": this.documentUserId, - "format": this.documentFormat, - "c": "reopen", - "title": this.documentTitle, - "password": password - }; - - AscCommon.sendCommand(this, null, v); -}; - -Asc['asc_docs_api'].prototype.Update_ParaInd = function( Ind ) -{ - this.WordControl.m_oDrawingDocument.Update_ParaInd(Ind); -}; - -Asc['asc_docs_api'].prototype.Internal_Update_Ind_Left = function(Left) -{ -}; - -Asc['asc_docs_api'].prototype.Internal_Update_Ind_Right = function(Right) -{ -}; - -Asc['asc_docs_api'].prototype.UpdateTextPr = function(TextPr) -{ - if (!TextPr) - return; - - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - - if (TextPr.Bold !== undefined) - { - _stream["WriteByte"](0); - _stream["WriteBool"](TextPr.Bold); - } - if (TextPr.Italic !== undefined) - { - _stream["WriteByte"](1); - _stream["WriteBool"](TextPr.Italic); - } - if (TextPr.Underline !== undefined) - { - _stream["WriteByte"](2); - _stream["WriteBool"](TextPr.Underline); - } - if (TextPr.Strikeout !== undefined) - { - _stream["WriteByte"](3); - _stream["WriteBool"](TextPr.Strikeout); - } - - asc_menu_WriteFontFamily(4, TextPr.FontFamily, _stream); - - if (TextPr.FontSize !== undefined) - { - _stream["WriteByte"](5); - _stream["WriteDouble2"](TextPr.FontSize); - } - - if(TextPr.Unifill && TextPr.Unifill.fill && TextPr.Unifill.fill.type === Asc.c_oAscFill.FILL_TYPE_SOLID && TextPr.Unifill.fill.color) - { - var _color = AscCommon.CreateAscColor(TextPr.Unifill.fill.color); - asc_menu_WriteColor(6, AscCommon.CreateAscColorCustom(_color.r, _color.g, _color.b, false), _stream); - } - else if (TextPr.Color !== undefined) - { - asc_menu_WriteColor(6, AscCommon.CreateAscColorCustom(TextPr.Color.r, TextPr.Color.g, TextPr.Color.b, TextPr.Color.Auto), _stream); - } - - if (TextPr.VertAlign !== undefined) - { - _stream["WriteByte"](7); - _stream["WriteLong"](TextPr.VertAlign); - } - - if (TextPr.HighLight !== undefined) - { - if (TextPr.HighLight === AscCommonWord.highlight_None) - { - _stream["WriteByte"](12); - } - else - { - asc_menu_WriteColor(8, AscCommon.CreateAscColorCustom(TextPr.HighLight.r, TextPr.HighLight.g, TextPr.HighLight.b), _stream); - } - } - - if (TextPr.DStrikeout !== undefined) - { - _stream["WriteByte"](9); - _stream["WriteBool"](TextPr.DStrikeout); - } - if (TextPr.Caps !== undefined) - { - _stream["WriteByte"](10); - _stream["WriteBool"](TextPr.Caps); - } - if (TextPr.SmallCaps !== undefined) - { - _stream["WriteByte"](11); - _stream["WriteBool"](TextPr.SmallCaps); - } - if (TextPr.Spacing !== undefined) - { - _stream["WriteByte"](13); - _stream["WriteDouble2"](TextPr.Spacing); - } - - _stream["WriteByte"](255); - - this.Send_Menu_Event(1); -}; - -Asc['asc_docs_api'].prototype.UpdateParagraphProp = function(ParaPr) -{ - // TODO: как только разъединят настройки параграфа и текста переделать тут - var TextPr = this.WordControl.m_oLogicDocument.GetCalculatedTextPr(); - ParaPr.Subscript = ( TextPr.VertAlign === AscCommon.vertalign_SubScript ? true : false ); - ParaPr.Superscript = ( TextPr.VertAlign === AscCommon.vertalign_SuperScript ? true : false ); - ParaPr.Strikeout = TextPr.Strikeout; - ParaPr.DStrikeout = TextPr.DStrikeout; - ParaPr.AllCaps = TextPr.Caps; - ParaPr.SmallCaps = TextPr.SmallCaps; - ParaPr.TextSpacing = TextPr.Spacing; - ParaPr.Position = TextPr.Position; - //----------------------------------------------------------------------------- - - if ( -1 === ParaPr.PStyle ) - ParaPr.StyleName = ""; - else if ( undefined === ParaPr.PStyle ) - ParaPr.StyleName = this.WordControl.m_oLogicDocument.Styles.Style[this.WordControl.m_oLogicDocument.Styles.Get_Default_Paragraph()].Name; - else - ParaPr.StyleName = this.WordControl.m_oLogicDocument.Styles.Style[ParaPr.PStyle].Name; - - var NumType = -1; - var NumSubType = -1; - if ( !(null == ParaPr.NumPr || 0 === ParaPr.NumPr.NumId || "0" === ParaPr.NumPr.NumId) ) - { - var oNum = this.WordControl.m_oLogicDocument.GetNumbering().GetNum(ParaPr.NumPr.NumId); - - if (oNum && oNum.GetLvl(ParaPr.NumPr.Lvl)) - { - var Lvl = oNum.GetLvl(ParaPr.NumPr.Lvl); - var NumFormat = Lvl.GetFormat(); - var NumText = Lvl.GetLvlText(); - - if ( Asc.c_oAscNumberingFormat.Bullet === NumFormat ) - { - NumType = 0; - NumSubType = 0; - - var TextLen = NumText.length; - if ( 1 === TextLen && numbering_lvltext_Text === NumText[0].Type ) - { - var NumVal = NumText[0].Value.charCodeAt(0); - - if ( 0x00B7 === NumVal ) - NumSubType = 1; - else if ( 0x006F === NumVal ) - NumSubType = 2; - else if ( 0x00A7 === NumVal ) - NumSubType = 3; - else if ( 0x0076 === NumVal ) - NumSubType = 4; - else if ( 0x00D8 === NumVal ) - NumSubType = 5; - else if ( 0x00FC === NumVal ) - NumSubType = 6; - else if ( 0x00A8 === NumVal ) - NumSubType = 7; - } - } - else - { - NumType = 1; - NumSubType = 0; - - var TextLen = NumText.length; - if ( 2 === TextLen && numbering_lvltext_Num === NumText[0].Type && numbering_lvltext_Text === NumText[1].Type ) - { - var NumVal2 = NumText[1].Value; - - if ( Asc.c_oAscNumberingFormat.Decimal === NumFormat ) - { - if ( "." === NumVal2 ) - NumSubType = 1; - else if ( ")" === NumVal2 ) - NumSubType = 2; - } - else if ( Asc.c_oAscNumberingFormat.UpperRoman === NumFormat ) - { - if ( "." === NumVal2 ) - NumSubType = 3; - } - else if ( Asc.c_oAscNumberingFormat.UpperLetter === NumFormat ) - { - if ( "." === NumVal2 ) - NumSubType = 4; - } - else if ( Asc.c_oAscNumberingFormat.LowerLetter === NumFormat ) - { - if ( ")" === NumVal2 ) - NumSubType = 5; - else if ( "." === NumVal2 ) - NumSubType = 6; - } - else if ( Asc.c_oAscNumberingFormat.LowerRoman === NumFormat ) - { - if ( "." === NumVal2 ) - NumSubType = 7; - } - } - } - } - } - - ParaPr.ListType = { Type : NumType, SubType : NumSubType }; - - if ( undefined !== ParaPr.FramePr && undefined !== ParaPr.FramePr.Wrap ) - { - if ( wrap_NotBeside === ParaPr.FramePr.Wrap ) - ParaPr.FramePr.Wrap = false; - else if ( wrap_Around === ParaPr.FramePr.Wrap ) - ParaPr.FramePr.Wrap = true; - else - ParaPr.FramePr.Wrap = undefined; - } - - var _len = this.SelectedObjectsStack.length; - if (_len > 0) - { - if (this.SelectedObjectsStack[_len - 1].Type == Asc.c_oAscTypeSelectElement.Paragraph) - { - this.SelectedObjectsStack[_len - 1].Value = ParaPr; - return; - } - } - - this.SelectedObjectsStack[this.SelectedObjectsStack.length] = new AscCommon.asc_CSelectedObject ( Asc.c_oAscTypeSelectElement.Paragraph, ParaPr ); -}; - -Asc['asc_docs_api'].prototype.put_PageNum = function(where,align) -{ - if ( where >= 0 ) - { - if ( false === this.WordControl.m_oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_None, { Type : AscCommon.changestype_2_HdrFtr }) ) - { - this.WordControl.m_oLogicDocument.StartAction(); - this.WordControl.m_oLogicDocument.Document_AddPageNum( where, align ); - this.WordControl.m_oLogicDocument.FinalizeAction(); - } - } - else - { - if ( false === this.WordControl.m_oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_Paragraph_Content) ) - { - this.WordControl.m_oLogicDocument.StartAction(); - this.WordControl.m_oLogicDocument.Document_AddPageNum( where, align ); - this.WordControl.m_oLogicDocument.FinalizeAction(); - } - } -}; - -Asc['asc_docs_api'].prototype.put_AddPageBreak = function() -{ - if ( false === this.WordControl.m_oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_Paragraph_Content) ) - { - var Document = this.WordControl.m_oLogicDocument; - - if ( null === Document.IsCursorInHyperlink(false) ) - { - Document.StartAction(); - Document.AddToParagraph(new AscWord.CRunBreak(AscWord.break_Page)); - Document.FinalizeAction(); - } - } -}; - -Asc['asc_docs_api'].prototype.add_SectionBreak = function(_Type) -{ - if ( false === this.WordControl.m_oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_Paragraph_Content) ) - { - this.WordControl.m_oLogicDocument.StartAction(); - this.WordControl.m_oLogicDocument.Add_SectionBreak(_Type); - this.WordControl.m_oLogicDocument.FinalizeAction(); - } -}; - -Asc['asc_docs_api'].prototype.put_AddLineBreak = function() -{ - if ( false === this.WordControl.m_oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_Paragraph_Content) ) - { - var Document = this.WordControl.m_oLogicDocument; - - if ( null === Document.IsCursorInHyperlink(false) ) - { - Document.StartAction(); - Document.AddToParagraph(new AscWord.CRunBreak(AscWord.break_Line)); - Document.FinalizeAction(); - } - } -}; - -Asc['asc_docs_api'].prototype.ImgApply = function(obj) -{ - - var ImagePr = obj; - - // Если у нас меняется с Float->Inline мы также должны залочить соответствующий параграф - var AdditionalData = null; - var LogicDocument = this.WordControl.m_oLogicDocument; - if(obj && obj.ChartProperties && obj.ChartProperties.type === Asc.c_oAscChartTypeSettings.stock) - { - var selectedObjectsByType = LogicDocument.DrawingObjects.getSelectedObjectsByTypes(); - if(selectedObjectsByType.charts[0]) - { - var chartSpace = selectedObjectsByType.charts[0]; - if(chartSpace && chartSpace.chart && chartSpace.chart.plotArea && chartSpace.chart.plotArea.charts[0] && chartSpace.chart.plotArea.charts[0].getObjectType() !== AscDFH.historyitem_type_StockChart) - { - if(chartSpace.chart.plotArea.charts[0].series.length !== 4) - { - this.sendEvent("asc_onError", Asc.c_oAscError.ID.StockChartError,Asc.c_oAscError.Level.NoCritical); - this.WordControl.m_oLogicDocument.Document_UpdateInterfaceState(); - return; - } - } - } - } - - /* change z-index */ - if (AscFormat.isRealNumber(ImagePr.ChangeLevel)) - { - switch (ImagePr.ChangeLevel) - { - case 0: - { - this.WordControl.m_oLogicDocument.DrawingObjects.bringToFront(); - break; - } - case 1: - { - this.WordControl.m_oLogicDocument.DrawingObjects.bringForward(); - break; - } - case 2: - { - this.WordControl.m_oLogicDocument.DrawingObjects.sendToBack(); - break; - } - case 3: - { - this.WordControl.m_oLogicDocument.DrawingObjects.bringBackward(); - } - } - return; - } - - if ( false === this.WordControl.m_oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_Drawing_Props, AdditionalData) ) - { - - if (ImagePr.ShapeProperties) - ImagePr.ImageUrl = ""; - - if(ImagePr.ImageUrl != undefined && ImagePr.ImageUrl != null && ImagePr.ImageUrl != "") - { - this.WordControl.m_oLogicDocument.StartAction(); - this.WordControl.m_oLogicDocument.SetImageProps( ImagePr ); - this.WordControl.m_oLogicDocument.FinalizeAction(); - } - else if (ImagePr.ShapeProperties && ImagePr.ShapeProperties.fill && ImagePr.ShapeProperties.fill.fill && - ImagePr.ShapeProperties.fill.fill.url !== undefined && ImagePr.ShapeProperties.fill.fill.url != null && ImagePr.ShapeProperties.fill.fill.url != "") - { - this.WordControl.m_oLogicDocument.StartAction(); - this.WordControl.m_oLogicDocument.SetImageProps( ImagePr ); - this.WordControl.m_oLogicDocument.FinalizeAction(); - } - else - { - ImagePr.ImageUrl = null; - if (!this.noCreatePoint || this.exucuteHistory) - { - if (!this.noCreatePoint && !this.exucuteHistory && this.exucuteHistoryEnd) - { - if (-1 !== this.nCurPointItemsLength) - { - History.UndoLastPoint(); - } - else - { - this.WordControl.m_oLogicDocument.Create_NewHistoryPoint(AscDFH.historydescription_Document_ApplyImagePr); - } - this.WordControl.m_oLogicDocument.SetImageProps(ImagePr); - this.exucuteHistoryEnd = false; - this.nCurPointItemsLength = -1; - } - else - { - this.WordControl.m_oLogicDocument.StartAction(AscDFH.historydescription_Document_ApplyImagePr); - this.WordControl.m_oLogicDocument.SetImageProps(ImagePr); - this.WordControl.m_oLogicDocument.UpdateInterface(); - this.WordControl.m_oLogicDocument.UpdateSelection(); - this.WordControl.m_oLogicDocument.FinalizeAction(); - } - if (this.exucuteHistory) - { - this.exucuteHistory = false; - var oPoint = History.Points[History.Index]; - if (oPoint) - { - this.nCurPointItemsLength = oPoint.Items.length; - } - } - if(this.exucuteHistoryEnd) - { - this.exucuteHistoryEnd = false; - } - } - else - { - var bNeedCheckChangesCount = false; - if (-1 !== this.nCurPointItemsLength) - { - History.UndoLastPoint(); - } - else - { - bNeedCheckChangesCount = true; - this.WordControl.m_oLogicDocument.Create_NewHistoryPoint(AscDFH.historydescription_Document_ApplyImagePr); - } - this.WordControl.m_oLogicDocument.SetImageProps(ImagePr); - if (bNeedCheckChangesCount) - { - var oPoint = History.Points[History.Index]; - if (oPoint) - { - this.nCurPointItemsLength = oPoint.Items.length; - } - } - } - this.exucuteHistoryEnd = false; - } - } -}; - -Asc['asc_docs_api'].prototype.MergeCells = function() -{ - if ( false === this.WordControl.m_oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_Table_Properties) ) - { - this.WordControl.m_oLogicDocument.StartAction(); - this.WordControl.m_oLogicDocument.MergeTableCells(); - this.WordControl.m_oLogicDocument.FinalizeAction(); - } -} -Asc['asc_docs_api'].prototype.SplitCell = function(Cols, Rows) -{ - if ( false === this.WordControl.m_oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_Table_Properties) ) - { - this.WordControl.m_oLogicDocument.StartAction(); - this.WordControl.m_oLogicDocument.SplitTableCells(Cols, Rows); - this.WordControl.m_oLogicDocument.FinalizeAction(); - } -} - -Asc['asc_docs_api'].prototype.StartAddShape = function(sPreset, is_apply) -{ - this.isStartAddShape = true; - this.addShapePreset = sPreset; - if (is_apply) - { - this.WordControl.m_oDrawingDocument.LockCursorType("crosshair"); - } - else - { - editor.sync_EndAddShape(); - editor.sync_StartAddShapeCallback(false); - } -}; - -Asc['asc_docs_api'].prototype.AddImageUrlNative = function(url, _w, _h, _pageNum) -{ - var _section_select = this.WordControl.m_oLogicDocument.Get_PageSizesByDrawingObjects(); - var _page_width = AscCommon.Page_Width; - var _page_height = AscCommon.Page_Height; - var _page_x_left_margin = AscCommon.X_Left_Margin; - var _page_y_top_margin = AscCommon.Y_Top_Margin; - var _page_x_right_margin = AscCommon.X_Right_Margin; - var _page_y_bottom_margin = AscCommon.Y_Bottom_Margin; - - if (_section_select) - { - if (_section_select.W) - _page_width = _section_select.W; - - if (_section_select.H) - _page_height = _section_select.H; - } - - var __w = Math.max(1, (_page_width - (_page_x_left_margin + _page_x_right_margin)) / 2); - var __h = Math.max(1, (_page_height - (_page_y_top_margin + _page_y_bottom_margin)) / 2); - - var wI = (undefined !== _w) ? Math.max(_w * AscCommon.g_dKoef_pix_to_mm, 1) : 1; - var hI = (undefined !== _h) ? Math.max(_h * AscCommon.g_dKoef_pix_to_mm, 1) : 1; - - if (wI < 5) - wI = 5; - if (hI < 5) - hI = 5; - - if (wI > __w || hI > __h) - { - var _koef = Math.min(__w / wI, __h / hI); - wI *= _koef; - hI *= _koef; - } - - this.WordControl.m_oLogicDocument.StartAction(); - this.WordControl.m_oLogicDocument.AddInlineImage(wI, hI, url); - this.WordControl.m_oLogicDocument.Recalculate(); - this.WordControl.m_oLogicDocument.FinalizeAction(); -}; -Asc['asc_docs_api'].prototype.AddImageUrlAtPosNative = function(url, _w, _h, _pageNum, _posX, _posY, _wrapType) -{ - _api.AddImageToPage(url, _pageNum, _posX, _posY, _w, _h, _wrapType); -}; -Asc['asc_docs_api'].prototype.SetContentControlPictureUrlNative = function(sUrl, sId) -{ - if (this.WordControl && this.WordControl.m_oDrawingDocument) - { - this.WordControl.m_oDrawingDocument.UnlockCursorType(); - } - - var oLogicDocument = this.private_GetLogicDocument(); - if (!oLogicDocument || AscCommon.isNullOrEmptyString(sUrl)) - return; - - var oCC = oLogicDocument.GetContentControl(sId); - oCC.SkipSpecialContentControlLock(true); - if (!oCC || !oCC.IsPicture() || !oCC.SelectPicture() || !oCC.CanBeEdited()) - { - oCC.SkipSpecialContentControlLock(false); - return; - } - - if (!oLogicDocument.IsSelectionLocked(AscCommon.changestype_Image_Properties, undefined, false, oLogicDocument.IsFormFieldEditing())) - { - oCC.SkipSpecialContentControlLock(false); - oLogicDocument.StartAction(AscDFH.historydescription_Document_ApplyImagePrWithUrl); - oLogicDocument.SetImageProps({ImageUrl : sUrl}); - oCC.SetShowingPlcHdr(false); - oLogicDocument.UpdateTracks(); - oLogicDocument.FinalizeAction(); - } - else - { - oCC.SkipSpecialContentControlLock(false); - } -} -Asc['asc_docs_api'].prototype.AddImageUrlActionNative = function(src, _w, _h, _pageNum) -{ - var section_select = this.WordControl.m_oLogicDocument.Get_PageSizesByDrawingObjects(); - var page_width = AscCommon.Page_Width; - var page_height = AscCommon.Page_Height; - var page_x_left_margin = AscCommon.X_Left_Margin; - var page_y_top_margin = AscCommon.Y_Top_Margin; - var page_x_right_margin = AscCommon.X_Right_Margin; - var page_y_bottom_margin = AscCommon.Y_Bottom_Margin; - - var boundingWidth = Math.max(1, page_width - (page_x_left_margin + page_x_right_margin)); - var boundingHeight = Math.max(1, page_height - (page_y_top_margin + page_y_bottom_margin)); - - var w = Math.max(_w * AscCommon.g_dKoef_pix_to_mm, 1); - var h = Math.max(_h * AscCommon.g_dKoef_pix_to_mm, 1); - - var mW = boundingWidth / w; - var mH = boundingHeight / h; - - if (mH < mW) { - boundingWidth = boundingHeight / h * w; - } else if (mW < mH) { - boundingHeight = boundingWidth / w * h; - } - - _w = Math.max(5, boundingWidth); - _h = Math.max(5, boundingHeight); - - if (false === this.WordControl.m_oLogicDocument.Document_Is_SelectionLocked(changestype_Paragraph_Content)) - { - var imageLocal = AscCommon.g_oDocumentUrls.getImageLocal(src); - if (imageLocal) - { - src = imageLocal; - } - this.WordControl.m_oLogicDocument.StartAction(AscDFH.historydescription_Document_AddImageUrlLong); - //if (undefined === imgProp || undefined === imgProp.WrappingStyle || 0 == imgProp.WrappingStyle) - this.WordControl.m_oLogicDocument.AddInlineImage(_w, _h, src); - //else - // this.WordControl.m_oLogicDocument.AddInlineImage(_w, _h, src, null, true); - this.WordControl.m_oLogicDocument.FinalizeAction(); - } -}; - -Asc['asc_docs_api'].prototype.Send_Menu_Event = function(type) -{ - window["native"]["OnCallMenuEvent"](type, global_memory_stream_menu); -}; - -Asc['asc_docs_api'].prototype.sync_EndCatchSelectedElements = function(isExternalTrigger) -{ - if (this.WordControl && this.WordControl.m_oDrawingDocument) - this.WordControl.m_oDrawingDocument.EndTableStylesCheck(); - - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - - var _count = this.SelectedObjectsStack.length; - var _naturalCount = 0; - - for (var i = 0; i < _count; i++) - { - switch (this.SelectedObjectsStack[i].Type) - { - case Asc.c_oAscTypeSelectElement.Paragraph: - case Asc.c_oAscTypeSelectElement.Header: - case Asc.c_oAscTypeSelectElement.Table: - case Asc.c_oAscTypeSelectElement.Image: - case Asc.c_oAscTypeSelectElement.Hyperlink: - case Asc.c_oAscTypeSelectElement.Math: - { - ++_naturalCount; - break; - } - default: - break; - } - } - - _stream["WriteLong"](_naturalCount); - - for (var i = 0; i < _count; i++) - { - switch (this.SelectedObjectsStack[i].Type) - { - //console.log(JSON.stringify(this.SelectedObjectsStack[i].Value)); - case Asc.c_oAscTypeSelectElement.Paragraph: - { - _stream["WriteLong"](Asc.c_oAscTypeSelectElement.Paragraph); - asc_menu_WriteParagraphPr(this.SelectedObjectsStack[i].Value, _stream); - break; - } - case Asc.c_oAscTypeSelectElement.Header: - { - _stream["WriteLong"](Asc.c_oAscTypeSelectElement.Header); - asc_menu_WriteHeaderFooterPr(this.SelectedObjectsStack[i].Value, _stream); - break; - } - case Asc.c_oAscTypeSelectElement.Table: - { - _stream["WriteLong"](Asc.c_oAscTypeSelectElement.Table); - asc_menu_WriteTablePr(this.SelectedObjectsStack[i].Value, _stream); - break; - } - case Asc.c_oAscTypeSelectElement.Image: - { - _stream["WriteLong"](Asc.c_oAscTypeSelectElement.Image); - asc_menu_WriteImagePr(this.SelectedObjectsStack[i].Value, _stream); - break; - } - case Asc.c_oAscTypeSelectElement.Hyperlink: - { - _stream["WriteLong"](Asc.c_oAscTypeSelectElement.Hyperlink); - asc_menu_WriteHyperPr(this.SelectedObjectsStack[i].Value, _stream); - break; - } - case Asc.c_oAscTypeSelectElement.Math: - { - _stream["WriteLong"](Asc.c_oAscTypeSelectElement.Math); - asc_menu_WriteMath(this.SelectedObjectsStack[i].Value, _stream); - break; - } - case Asc.c_oAscTypeSelectElement.SpellCheck: - default: - { - // none - break; - } - } - } - - this.Send_Menu_Event(6); - this.sendEvent("asc_onFocusObject", this.SelectedObjectsStack, !isExternalTrigger); -}; - -Asc['asc_docs_api'].prototype.startGetDocInfo = function() -{ - /* - Возвращаем объект следующего вида: - { - PageCount: 12, - WordsCount: 2321, - ParagraphCount: 45, - SymbolsCount: 232345, - SymbolsWSCount: 34356 - } - */ - this.sync_GetDocInfoStartCallback(); - - if (null != this.WordControl.m_oLogicDocument) - this.WordControl.m_oLogicDocument.Statistics_Start(); -}; -Asc['asc_docs_api'].prototype.stopGetDocInfo = function() -{ - this.sync_GetDocInfoStopCallback(); - - if (null != this.WordControl.m_oLogicDocument) - this.WordControl.m_oLogicDocument.Statistics_Stop(); -}; -Asc['asc_docs_api'].prototype.sync_DocInfoCallback = function(obj) -{ - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - _stream["WriteLong"](obj.PageCount); - _stream["WriteLong"](obj.WordsCount); - _stream["WriteLong"](obj.ParagraphCount); - _stream["WriteLong"](obj.SymbolsCount); - _stream["WriteLong"](obj.SymbolsWSCount); - - window["native"]["OnCallMenuEvent"](70, _stream); // ASC_MENU_EVENT_TYPE_STATISTIC_INFO -}; -Asc['asc_docs_api'].prototype.sync_GetDocInfoStartCallback = function() -{ - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - - window["native"]["OnCallMenuEvent"](67, _stream); // ASC_MENU_EVENT_TYPE_STATISTIC_START -}; -Asc['asc_docs_api'].prototype.sync_GetDocInfoStopCallback = function() -{ - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - - window["native"]["OnCallMenuEvent"](68, _stream); // ASC_MENU_EVENT_TYPE_STATISTIC_STOP -}; -Asc['asc_docs_api'].prototype.sync_GetDocInfoEndCallback = function() -{ - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - - window["native"]["OnCallMenuEvent"](69, _stream); // ASC_MENU_EVENT_TYPE_STATISTIC_END -}; - -Asc['asc_docs_api'].prototype.sync_CanUndoCallback = function(bCanUndo) -{ - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - _stream["WriteBool"](bCanUndo); - window["native"]["OnCallMenuEvent"](60, _stream); // ASC_MENU_EVENT_TYPE_CAN_UNDO -}; -Asc['asc_docs_api'].prototype.sync_CanRedoCallback = function(bCanRedo) -{ - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - _stream["WriteBool"](bCanRedo); - window["native"]["OnCallMenuEvent"](61, _stream); // ASC_MENU_EVENT_TYPE_CAN_REDO -}; - -Asc['asc_docs_api'].prototype.SetDocumentModified = function(bValue) -{ - this.isDocumentModify = bValue; - - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - _stream["WriteBool"](this.isDocumentModify); - window["native"]["OnCallMenuEvent"](66, _stream); // ASC_MENU_EVENT_TYPE_DOCUMETN_MODIFITY -}; - -// find ------------------------------------------------------------------------------------------------- -Asc['asc_docs_api'].prototype._selectSearchingResults = function(bShow) -{ - this.WordControl.m_oLogicDocument.HighlightSearchResults(bShow); -}; - -Asc['asc_docs_api'].prototype.asc_isSelectSearchingResults = function() -{ - return this.WordControl.m_oLogicDocument.IsHighlightSearchResults(); -}; -// endfind ---------------------------------------------------------------------------------------------- - -// sectionPr -------------------------------------------------------------------------------------------- -Asc['asc_docs_api'].prototype.change_PageOrient = function(isPortrait) -{ - if ( false === this.WordControl.m_oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_Document_SectPr) ) - { - this.WordControl.m_oLogicDocument.StartAction(); - if (isPortrait) - { - this.WordControl.m_oLogicDocument.Set_DocumentOrientation(Asc.c_oAscPageOrientation.PagePortrait); - this.DocumentOrientation = isPortrait; - } - else - { - this.WordControl.m_oLogicDocument.Set_DocumentOrientation(Asc.c_oAscPageOrientation.PageLandscape); - this.DocumentOrientation = isPortrait; - } - this.WordControl.m_oLogicDocument.FinalizeAction(); - this.sync_PageOrientCallback(editor.get_DocumentOrientation()); - } -}; -Asc['asc_docs_api'].prototype.change_DocSize = function(width,height) -{ - if ( false === this.WordControl.m_oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_Document_SectPr) ) - { - this.WordControl.m_oLogicDocument.StartAction(); - if (this.DocumentOrientation) - this.WordControl.m_oLogicDocument.Set_DocumentPageSize(width, height); - else - this.WordControl.m_oLogicDocument.Set_DocumentPageSize(height, width); - - this.WordControl.m_oLogicDocument.FinalizeAction(); - } -}; -Asc['asc_docs_api'].prototype.sync_PageOrientCallback = function(isPortrait) -{ - this.DocumentOrientation = isPortrait; - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - _stream["WriteByte"](6); - _stream["WriteBool"](this.DocumentOrientation); - _stream["WriteByte"](255); - this.Send_Menu_Event(17, _stream); // ASC_MENU_EVENT_TYPE_SECTION -}; -Asc['asc_docs_api'].prototype.sync_DocSizeCallback = function(width,height) -{ - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - _stream["WriteByte"](0); - _stream["WriteDouble2"](width); - _stream["WriteByte"](1); - _stream["WriteDouble2"](height); - _stream["WriteByte"](255); - this.Send_Menu_Event(17, _stream); // ASC_MENU_EVENT_TYPE_SECTION -}; -// endsectionPr ----------------------------------------------------------------------------------------- - -// STYLES -function CStylesPainter() -{ - this.STYLE_THUMBNAIL_WIDTH = AscCommon.GlobalSkin.STYLE_THUMBNAIL_WIDTH; - this.STYLE_THUMBNAIL_HEIGHT = AscCommon.GlobalSkin.STYLE_THUMBNAIL_HEIGHT; - - this.CurrentTranslate = null; - this.IsRetinaEnabled = false; - - this.defaultStyles = []; - this.docStyles = []; - this.mergedStyles = []; -} -CStylesPainter.prototype = -{ - GenerateStyles: function(_api, ds) - { - if (_api.WordControl.bIsRetinaSupport) - { - this.STYLE_THUMBNAIL_WIDTH <<= 1; - this.STYLE_THUMBNAIL_HEIGHT <<= 1; - this.IsRetinaEnabled = true; - } - - this.CurrentTranslate = _api.CurrentTranslate; - - var _stream = global_memory_stream_menu; - var _graphics = new CDrawingStream(); - - _api.WordControl.m_oDrawingDocument.Native["DD_PrepareNativeDraw"](); - - this.GenerateDefaultStyles(_api, ds, _graphics); - this.GenerateDocumentStyles(_api, _graphics); - - // стили сформированы. осталось просто сформировать единый список - var _count_default = this.defaultStyles.length; - var _count_doc = 0; - if (null != this.docStyles) - _count_doc = this.docStyles.length; - - var aPriorityStyles = []; - var fAddToPriorityStyles = function(style){ - var index = style.Style.uiPriority; - if(null == index) - index = 0; - var aSubArray = aPriorityStyles[index]; - if(null == aSubArray) - { - aSubArray = []; - aPriorityStyles[index] = aSubArray; - } - aSubArray.push(style); - }; - var _map_document = {}; - - for (var i = 0; i < _count_doc; i++) - { - var style = this.docStyles[i]; - _map_document[style.Name] = 1; - fAddToPriorityStyles(style); - } - - for (var i = 0; i < _count_default; i++) - { - var style = this.defaultStyles[i]; - if(null == _map_document[style.Name]) - fAddToPriorityStyles(style); - } - - this.mergedStyles = []; - for(var index in aPriorityStyles) - { - var aSubArray = aPriorityStyles[index]; - aSubArray.sort(function(a, b){ - if(a.Name < b.Name) - return -1; - else if(a.Name > b.Name) - return 1; - else - return 0; - }); - for(var i = 0, length = aSubArray.length; i < length; ++i) - { - this.mergedStyles.push(aSubArray[i]); - } - } - - var _count = this.mergedStyles.length; - for (var i = 0; i < _count; i++) - { - this.drawStyle(_graphics, this.mergedStyles[i].Style, _api); - } - - _stream["ClearNoAttack"](); - - _stream["WriteByte"](1); - - _api.WordControl.m_oDrawingDocument.Native["DD_EndNativeDraw"](_stream); - }, - GenerateDefaultStyles: function(_api, ds, _graphics) - { - var styles = ds; - - for (var i in styles) - { - var style = styles[i]; - if (true == style.qFormat) - { - this.defaultStyles.push({ Name: style.Name, Style: style }); - } - } - }, - - GenerateDocumentStyles: function(_api, _graphics) - { - if (_api.WordControl.m_oLogicDocument == null) - return; - - var __Styles = _api.WordControl.m_oLogicDocument.Get_Styles(); - var styles = __Styles.Style; - - if (styles == null) - return; - - for (var i in styles) - { - var style = styles[i]; - if (true == style.qFormat) - { - // как только меняется сериалайзер - меняется и код здесь. Да, не очень удобно, - // зато быстро делается - var formalStyle = i.toLowerCase().replace(/\s/g, ""); - var res = formalStyle.match(/^heading([1-9][0-9]*)$/); - var index = (res) ? res[1] - 1 : -1; - - var _dr_style = __Styles.Get_Pr(i, styletype_Paragraph); - _dr_style.Name = style.Name; - _dr_style.Id = i; - - var _name = _dr_style.Name; - - // алгоритм смены имени - if (style.Default) - { - switch (style.Default) - { - case 1: - break; - case 2: - _name = "No List"; - break; - case 3: - _name = "Normal"; - break; - case 4: - _name = "Normal Table"; - break; - } - } - else if (index != -1) - { - _name = "Heading ".concat(index + 1); - } - - this.docStyles.push({ Name: _name, Style: _dr_style }); - } - } - }, - - drawStyle: function(graphics, style, _api) - { - var _w_px = this.STYLE_THUMBNAIL_WIDTH; - var _h_px = this.STYLE_THUMBNAIL_HEIGHT; - var dKoefToMM = AscCommon.g_dKoef_pix_to_mm; - - if (AscCommon.AscBrowser.isRetina) - dKoefToMM /= 2; - - _api.WordControl.m_oDrawingDocument.Native["DD_StartNativeDraw"](_w_px, _h_px, _w_px * dKoefToMM, _h_px * dKoefToMM); - - AscCommon.g_oTableId.m_bTurnOff = true; - AscCommon.History.TurnOff(); - - var oldDefTabStop = AscCommonWord.Default_Tab_Stop; - AscCommonWord.Default_Tab_Stop = 1; - - var hdr = new CHeaderFooter(_api.WordControl.m_oLogicDocument.HdrFtr, _api.WordControl.m_oLogicDocument, _api.WordControl.m_oDrawingDocument, AscCommon.hdrftr_Header); - var _dc = hdr.Content;//new CDocumentContent(editor.WordControl.m_oLogicDocument, editor.WordControl.m_oDrawingDocument, 0, 0, 0, 0, false, true, false); - - var par = new AscCommonWord.Paragraph(_api.WordControl.m_oDrawingDocument, _dc, 0, 0, 0, 0, false); - var run = new AscCommonWord.ParaRun(par, false); - run.AddText(AscCommon.translateManager.getValue(style.Name)); - - _dc.Internal_Content_Add(0, par, false); - par.Add_ToContent(0, run); - par.Style_Add(style.Id, false); - par.Set_Align(AscCommon.align_Left); - par.Set_Tabs(new AscCommonWord.CParaTabs()); - - var _brdL = style.ParaPr.Brd.Left; - if ( undefined !== _brdL && null !== _brdL ) - { - var brdL = new CDocumentBorder(); - brdL.Set_FromObject(_brdL); - brdL.Space = 0; - par.Set_Border(brdL, AscDFH.historyitem_Paragraph_Borders_Left); - } - - var _brdT = style.ParaPr.Brd.Top; - if ( undefined !== _brdT && null !== _brdT ) - { - var brd = new CDocumentBorder(); - brd.Set_FromObject(_brdT); - brd.Space = 0; - par.Set_Border(brd, AscDFH.historyitem_Paragraph_Borders_Top); - } - - var _brdB = style.ParaPr.Brd.Bottom; - if ( undefined !== _brdB && null !== _brdB ) - { - var brd = new CDocumentBorder(); - brd.Set_FromObject(_brdB); - brd.Space = 0; - par.Set_Border(brd, AscDFH.historyitem_Paragraph_Borders_Bottom); - } - - var _brdR = style.ParaPr.Brd.Right; - if ( undefined !== _brdR && null !== _brdR ) - { - var brd = new CDocumentBorder(); - brd.Set_FromObject(_brdR); - brd.Space = 0; - par.Set_Border(brd, AscDFH.historyitem_Paragraph_Borders_Right); - } - - var _ind = new CParaInd(); - _ind.FirstLine = 0; - _ind.Left = 0; - _ind.Right = 0; - par.Set_Ind(_ind, false); - - var _sp = new CParaSpacing(); - _sp.Line = 1; - _sp.LineRule = Asc.linerule_Auto; - _sp.Before = 0; - _sp.BeforeAutoSpacing = false; - _sp.After = 0; - _sp.AfterAutoSpacing = false; - par.Set_Spacing(_sp, false); - - _dc.Reset(0, 0, 10000, 10000); - _dc.Recalculate_Page(0, true); - - _dc.Reset(0, 0, par.Lines[0].Ranges[0].W + 0.001, 10000); - _dc.Recalculate_Page(0, true); - - var y = 0; - var b = dKoefToMM * _h_px; - var w = dKoefToMM * _w_px; - var off = 10 * dKoefToMM; - var off2 = 5 * dKoefToMM; - var off3 = 1 * dKoefToMM; - - graphics.transform(1,0,0,1,0,0); - graphics.save(); - graphics._s(); - graphics._m(off2, y + off3); - graphics._l(w - off, y + off3); - graphics._l(w - off, b - off3); - graphics._l(off2, b - off3); - graphics._z(); - graphics.clip(); - - var baseline = par.Lines[0].Y; - par.Shift(0, off + 0.5, y + 0.75 * (b - y) - baseline); - par.Draw(0, graphics); - - graphics.restore(); - - AscCommonWord.Default_Tab_Stop = oldDefTabStop; - - AscCommon.g_oTableId.m_bTurnOff = false; - AscCommon.History.TurnOn(); - - var _stream = global_memory_stream_menu; - - _stream["ClearNoAttack"](); - - _stream["WriteByte"](0); - _stream["WriteString2"](style.Name); - - _api.WordControl.m_oDrawingDocument.Native["DD_EndNativeDraw"](_stream); - graphics.ClearParams(); - } -}; - -// ------------------------------------------------- - -/***************************** COPY|PASTE *******************************/ - -Asc['asc_docs_api'].prototype.Call_Menu_Context_Copy = function() -{ - var dataBuffer = {}; - - var clipboard = {}; - clipboard.pushData = function(type, data) { - - if (AscCommon.c_oAscClipboardDataFormat.Text === type) { - - dataBuffer.text = data; - - } else if (AscCommon.c_oAscClipboardDataFormat.Internal === type) { - - if (null != data.drawingUrls && data.drawingUrls.length > 0) { - dataBuffer.drawingUrls = data.drawingUrls[0]; - } - - dataBuffer.sBase64 = data.sBase64; - } - } - - this.asc_CheckCopy(clipboard, AscCommon.c_oAscClipboardDataFormat.Internal|AscCommon.c_oAscClipboardDataFormat.Text); - - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - - if (dataBuffer.text) { - _stream["WriteByte"](0); - _stream["WriteString2"](dataBuffer.text); - } - - if (dataBuffer.drawingUrls) { - _stream["WriteByte"](1); - _stream["WriteStringA"](dataBuffer.drawingUrls); - } - - if (dataBuffer.sBase64) { - _stream["WriteByte"](2); - _stream["WriteStringA"](dataBuffer.sBase64); - } - - _stream["WriteByte"](255); - - return _stream; -}; -Asc['asc_docs_api'].prototype.Call_Menu_Context_Cut = function() -{ - var dataBuffer = {}; - - var clipboard = {}; - clipboard.pushData = function(type, data) { - - if (AscCommon.c_oAscClipboardDataFormat.Text === type) { - - dataBuffer.text = data; - - } else if (AscCommon.c_oAscClipboardDataFormat.Internal === type) { - - if (null != data.drawingUrls && data.drawingUrls.length > 0) { - dataBuffer.drawingUrls = data.drawingUrls[0]; - } - - dataBuffer.sBase64 = data.sBase64; - } - } - - this.asc_CheckCopy(clipboard, AscCommon.c_oAscClipboardDataFormat.Internal|AscCommon.c_oAscClipboardDataFormat.Text); - - this.asc_SelectionCut(); - - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - - if (dataBuffer.text) { - _stream["WriteByte"](0); - _stream["WriteString2"](dataBuffer.text); - } - - if (dataBuffer.drawingUrls) { - _stream["WriteByte"](1); - _stream["WriteStringA"](dataBuffer.drawingUrls); - } - - if (dataBuffer.sBase64) { - _stream["WriteByte"](2); - _stream["WriteStringA"](dataBuffer.sBase64); - } - - _stream["WriteByte"](255); - - return _stream; -}; -Asc['asc_docs_api'].prototype.Call_Menu_Context_Paste = function(type, param) -{ - if (0 == type) - { - this.asc_PasteData(AscCommon.c_oAscClipboardDataFormat.Text, param); - } - else if (1 == type) - { - this.AddImageUrlNative(param, 200, 200); - } - else if (2 == type) - { - this.asc_PasteData(AscCommon.c_oAscClipboardDataFormat.Internal, param); - } -}; -Asc['asc_docs_api'].prototype.Call_Menu_Context_Delete = function() -{ - if ( false === this.WordControl.m_oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_Delete) ) - { - this.WordControl.m_oLogicDocument.StartAction(); - this.WordControl.m_oLogicDocument.Remove( 1, true ); - this.WordControl.m_oLogicDocument.FinalizeAction(); - } -}; -Asc['asc_docs_api'].prototype.Call_Menu_Context_Select = function() -{ - this.WordControl.m_oLogicDocument.MoveCursorLeft(false, true); - this.WordControl.m_oLogicDocument.MoveCursorRight(true, true); - this.WordControl.m_oLogicDocument.Document_UpdateSelectionState(); -}; -Asc['asc_docs_api'].prototype.Call_Menu_Context_SelectAll = function() -{ - this.WordControl.m_oLogicDocument.SelectAll(); -}; -/************************************************************************/ - -// chat styles -AscCommon.ChartPreviewManager.prototype.clearPreviews = function() -{ - window["native"]["ClearCacheChartStyles"](); -}; - -AscCommon.ChartPreviewManager.prototype.createChartPreview = function(_graphics, type, styleIndex) -{ - return AscFormat.ExecuteNoHistory(function(){ - var chart_space = this.checkChartForPreview(type, AscCommon.g_oChartStyles[type][styleIndex]); - // sizes for imageView - window["native"]["DD_StartNativeDraw"](85 * 2, 85 * 2, 75, 75); - - chart_space.draw(_graphics); - _graphics.ClearParams(); - - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - _stream["WriteByte"](4); - _stream["WriteLong"](type); - _stream["WriteLong"](styleIndex); - window["native"]["DD_EndNativeDraw"](_stream); - - }, this, []); -}; - -AscCommon.ChartPreviewManager.prototype.getChartPreviews = function(chartType) -{ - if (AscFormat.isRealNumber(chartType)) - { - var bIsCached = window["native"]["IsCachedChartStyles"](chartType); - if (!bIsCached) - { - window["native"]["DD_PrepareNativeDraw"](); - - var _graphics = new CDrawingStream(); - - if(AscCommon.g_oChartStyles[chartType]){ - var nStylesCount = AscCommon.g_oChartStyles[chartType].length; - for(var i = 0; i < nStylesCount; ++i) - this.createChartPreview(_graphics, chartType, i); - } - - var _stream = global_memory_stream_menu; - _stream["ClearNoAttack"](); - _stream["WriteByte"](5); - _api.WordControl.m_oDrawingDocument.Native["DD_EndNativeDraw"](_stream); - } - } -}; - -function initTrackRevisions() { - this.trackRevisionsTimerId = setInterval(function () { - _api.WordControl.m_oLogicDocument.ContinueTrackRevisions(); - }, 40); -} - -function initSpellCheckApi() { - - _api.SpellCheckApi = new AscCommon.CSpellCheckApi(); - _api.isSpellCheckEnable = true; - - _api.SpellCheckApi.spellCheck = function (spellData) { - window["native"]["SpellCheck"](JSON.stringify(spellData)); - }; - - _api.SpellCheckApi.disconnect = function () {}; - - _api.sendEvent('asc_onSpellCheckInit', [ - "1026", - "1027", - "1029", - "1030", - "1031", - "1032", - "1033", - "1036", - "1038", - "1040", - "1042", - "1043", - "1044", - "1045", - "1046", - "1048", - "1049", - "1050", - "1051", - "1053", - "1055", - "1057", - "1058", - "1060", - "1062", - "1063", - "1066", - "1068", - "1069", - "1087", - "1104", - "1110", - "1134", - "2051", - "2055", - "2057", - "2068", - "2070", - "3079", - "3081", - "3082", - "4105", - "7177", - "9242", - "10266" - ]); - - _api.SpellCheckApi.onInit = function (e) { - _api.sendEvent('asc_onSpellCheckInit', e); - }; - - _api.SpellCheckApi.onSpellCheck = function (e) { - _api.SpellCheck_CallBack(e); - }; - - _api.SpellCheckApi.init(_api.documentId); - - _api.asc_setSpellCheck(spellCheck); -} - -function NativeOpenFile3(_params, documentInfo) -{ - window.NATIVE_DOCUMENT_TYPE = window["native"]["GetEditorType"](); - if (window.NATIVE_DOCUMENT_TYPE == "presentation" || window.NATIVE_DOCUMENT_TYPE == "document") - { - sdkCheck = documentInfo["sdkCheck"]; - spellCheck = documentInfo["spellCheck"]; - - var translations = documentInfo["translations"]; - if (undefined != translations && null != translations && translations.length > 0) { - translations = JSON.parse(translations) - } else { - translations = ""; - } - - window["_api"] = window["API"] = _api = new window["Asc"]["asc_docs_api"](translations); - window["_editor"] = window.editor; - - AscCommon.g_clipboardBase.Init(_api); - - if (undefined !== _api["Native_Editor_Initialize_Settings"]) - { - _api["Native_Editor_Initialize_Settings"](_params); - } - - window.documentInfo = documentInfo; - - var userInfo = new Asc.asc_CUserInfo(); - userInfo.asc_putId(window.documentInfo["docUserId"]); - userInfo.asc_putFullName(window.documentInfo["docUserName"]); - userInfo.asc_putFirstName(window.documentInfo["docUserFirstName"]); - userInfo.asc_putLastName(window.documentInfo["docUserLastName"]); - - var docInfo = new Asc.asc_CDocInfo(); - docInfo.put_Id(window.documentInfo["docKey"]); - docInfo.put_Url(window.documentInfo["docURL"]); - docInfo.put_Format("docx"); - docInfo.put_UserInfo(userInfo); - docInfo.put_Token(window.documentInfo["token"]); - - _internalStorage.externalUserInfo = userInfo; - _internalStorage.externalDocInfo = docInfo; - - var permissions = window.documentInfo["permissions"]; - if (undefined != permissions && null != permissions && permissions.length > 0) { - docInfo.put_Permissions(JSON.parse(permissions)); - } - - // Settings - - _api.asc_setDocInfo(docInfo); - - _api.asc_registerCallback("asc_onAdvancedOptions", function(type, options) { - var stream = global_memory_stream_menu; - if (options === undefined) { - options = {}; - } - options["optionId"] = type; - stream["ClearNoAttack"](); - stream["WriteString2"](JSON.stringify(options)); - window["native"]["OnCallMenuEvent"](22000, stream); // ASC_MENU_EVENT_TYPE_ADVANCED_OPTIONS - }); - - _api.asc_registerCallback("asc_onSendThemeColorSchemes", function(schemes) { - var stream = global_memory_stream_menu; - stream["ClearNoAttack"](); - asc_WriteColorSchemes(schemes, stream); - window["native"]["OnCallMenuEvent"](2404, stream); // ASC_SPREADSHEETS_EVENT_TYPE_COLOR_SCHEMES - }); - _api.asc_registerCallback("asc_onSendThemeColors", onApiSendThemeColors); - - _api.asc_registerCallback("asc_onFocusObject", onFocusObject); - _api.asc_registerCallback('asc_onStartAction', onApiLongActionBegin); - _api.asc_registerCallback('asc_onEndAction', onApiLongActionEnd); - _api.asc_registerCallback('asc_onError', onApiError); - - // Comments - - _api.asc_registerCallback("asc_onAddComment", onApiAddComment); - _api.asc_registerCallback("asc_onAddComments", onApiAddComments); - _api.asc_registerCallback("asc_onRemoveComment", onApiRemoveComment); - _api.asc_registerCallback("asc_onChangeComments", onApiChangeComments); - _api.asc_registerCallback("asc_onRemoveComments", onApiRemoveComments); - _api.asc_registerCallback("asc_onChangeCommentData", onApiChangeCommentData); - _api.asc_registerCallback("asc_onLockComment", onApiLockComment); - _api.asc_registerCallback("asc_onUnLockComment", onApiUnLockComment); - _api.asc_registerCallback("asc_onShowComment", onApiShowComment); - _api.asc_registerCallback("asc_onHideComment", onApiHideComment); - _api.asc_registerCallback("asc_onUpdateCommentPosition", onApiUpdateCommentPosition); - - // Revisions Change - - _api.asc_registerCallback("asc_onDocumentPlaceChanged", onDocumentPlaceChanged); - _api.asc_registerCallback("asc_onShowRevisionsChange", onApiShowRevisionsChange); - - // Fill forms - - _api.asc_registerCallback('asc_onShowContentControlsActions', onShowContentControlsActions); - _api.asc_registerCallback('asc_onHideContentControlsActions', onHideContentControlsActions); - - // Co-authoring - - if (window.documentInfo["iscoauthoring"]) { - - _api.isSpellCheckEnable = false; - - _api.asc_setAutoSaveGap(1); - _api._coAuthoringInit(); - _api.asc_SetFastCollaborative(true); - _api.SetCollaborativeMarksShowType(Asc.c_oAscCollaborativeMarksShowType.None); - - window["native"]["onTokenJWT"](_api.CoAuthoringApi.get_jwt()); - - _api.asc_registerCallback("asc_onAuthParticipantsChanged", onApiAuthParticipantsChanged); - _api.asc_registerCallback("asc_onParticipantsChanged", onApiParticipantsChanged); - - _api.asc_registerCallback("asc_onGetEditorPermissions", function(state) { - - var rData = { - "c" : "open", - "id" : window.documentInfo["docKey"], - "userid" : window.documentInfo["docUserId"], - "format" : "docx", - "vkey" : undefined, - "url" : window.documentInfo["docURL"], - "title" : this.documentTitle, - "nobase64" : true - }; - - _api.CoAuthoringApi.auth(window.documentInfo["viewmode"], rData); - }); - - _api.asc_registerCallback("asc_onDocumentUpdateVersion", function(callback) { - var me = this; - me.needToUpdateVersion = true; - if (callback) callback.call(me); - }); - - - } else { - var doc_bin = window["native"]["GetFileString"]("native_open_file"); - _api["asc_nativeOpenFile"](doc_bin); - - if (window.documentInfo["viewmode"]) { - _api.ShowParaMarks = false; - AscCommon.CollaborativeEditing.Set_GlobalLock(true); - _api.isViewMode = true; - _api.WordControl.m_oDrawingDocument.IsViewMode = true; - } - - if (null != _api.WordControl.m_oLogicDocument) - { - _api.WordControl.m_oDrawingDocument.CheckGuiControlColors(); - _api.sendColorThemes(_api.WordControl.m_oLogicDocument.theme); - } - - _api["NativeAfterLoad"](); - - initSpellCheckApi(); - initTrackRevisions(); - } - } - _api.isDocumentLoadComplete = true; -} - -// Revisions Change - -function onApiShowRevisionsChange(data) { - _internalStorage.changesReview = data - var revisionChanges = []; - - if (data && data.length > 0) { - var recalcFromMM = function (value) { - return parseFloat((value / 10.).toFixed(4)); // value in mm need to convert to cm - }; - var metricName = "|cm|"; - var c_paragraphLinerule = { - LINERULE_LEAST: 0, - LINERULE_AUTO: 1, - LINERULE_EXACT: 2 - }; - - data.forEach(function (item) { - var commonChanges = [], changes = [], - value = item.get_Value(), - movetype = item.get_MoveType(); - switch (item.get_Type()) { - case Asc.c_oAscRevisionsChangeType.TextAdd: - commonChanges.push((movetype == Asc.c_oAscRevisionsMove.NoMove) ? "|Inserted|" : "|Moved|"); - if (typeof value == 'object') { - value.forEach(function (obj) { - if (typeof obj === 'string') { - changes.push(obj); - } else { - switch (obj) { - case 0: - changes.push("<|Image|>"); - break; - case 1: - changes.push("<|Shape|>"); - break; - case 2: - changes.push("<|Chart|>"); - break; - case 3: - changes.push("<|Equation|>"); - break; - } - } - }); - } else if (typeof value === 'string') { - changes.push(value); - } - break; - case Asc.c_oAscRevisionsChangeType.TextRem: - commonChanges.push((movetype == Asc.c_oAscRevisionsMove.NoMove) ? "|Deleted|" : (item.is_MovedDown() ? "|Moved Down|" : "|Moved Up")); - if (typeof value == 'object') { - value.forEach(function (obj) { - if (typeof obj === 'string') { - changes.push(obj); - } else { - switch (obj) { - case 0: - changes.push("<|Image|>"); - break; - case 1: - changes.push("<|Shape|>"); - break; - case 2: - changes.push("<|Chart|>"); - break; - case 3: - changes.push("<|Equation|>"); - break; - } - } - }); - } else if (typeof value === 'string') { - changes.push(value); - } - break; - case Asc.c_oAscRevisionsChangeType.ParaAdd: - commonChanges.push("|Paragraph Inserted|"); - break; - case Asc.c_oAscRevisionsChangeType.ParaRem: - commonChanges.push("|Paragraph Deleted|"); - break; - case Asc.c_oAscRevisionsChangeType.TextPr: - commonChanges.push("|Formatted|"); - if (value.Get_Bold() !== undefined) - changes.push((value.Get_Bold() ? '' : ("|Not|" + " ")) + "|Bold|"); - if (value.Get_Italic() !== undefined) - changes.push((value.Get_Italic() ? '' : ("|Not|" + " ")) + "|Italic|"); - if (value.Get_Underline() !== undefined) - changes.push((value.Get_Underline() ? '' : ("|Not|" + " ")) + "|Underline|"); - if (value.Get_Strikeout() !== undefined) - changes.push((value.Get_Strikeout() ? '' : ("|Not|" + " ")) + "|Strikeout|"); - if (value.Get_DStrikeout() !== undefined) - changes.push((value.Get_DStrikeout() ? '' : ("|Not|" + " ")) + "|Double strikeout|"); - if (value.Get_Caps() !== undefined) - changes.push((value.Get_Caps() ? '' : ("|Not|" + " ")) + "|All caps|"); - if (value.Get_SmallCaps() !== undefined) - changes.push((value.Get_SmallCaps() ? '' : ("|Not|" + " ")) + "|Small caps|"); - if (value.GetVertAlign() !== undefined) - changes.push(((value.GetVertAlign() === AscCommon.vertalign_SuperScript) ? "|Superscript|" : ((value.GetVertAlign() === AscCommon.vertalign_SubScript) ? "|Subscript|" : "|Baseline|"))); - if (value.Get_Color() !== undefined) - changes.push("|Font color|"); - if (value.Get_Highlight() !== undefined) - changes.push("|Highlight color|"); - if (value.Get_Shd() !== undefined) - changes.push("|Background color|"); - if (value.Get_FontFamily() !== undefined) - changes.push(value.Get_FontFamily()); - if (value.Get_FontSize() !== undefined) - changes.push(value.Get_FontSize()); - if (value.Get_Spacing() !== undefined) - changes.push("|Spacing|" + " " + recalcFromMM(value.Get_Spacing()).toFixed(2) + " " + metricName); - if (value.Get_Position() !== undefined) - changes.push("|Position|" + " " + recalcFromMM(value.Get_Position()).toFixed(2) + " " + metricName); - if (value.Get_Lang() !== undefined) - changes.push("[lang]" + value.Get_Lang()); - break; - case Asc.c_oAscRevisionsChangeType.ParaPr: - commonChanges.push("|Paragraph Formatted|"); - if (value.Get_ContextualSpacing()) - changes.push(value.Get_ContextualSpacing() ? "|Don't add interval between paragraphs of the same style|" : "|Add interval between paragraphs of the same style|"); - if (value.Get_IndLeft() !== undefined) - changes.push("|Indent left|" + " " + recalcFromMM(value.Get_IndLeft()).toFixed(2) + " " + metricName); - if (value.Get_IndRight() !== undefined) - changes.push("|Indent right|" + " " + recalcFromMM(value.Get_IndRight()).toFixed(2) + " " + metricName); - if (value.Get_IndFirstLine() !== undefined) - changes.push("|First line|" + " " + recalcFromMM(value.Get_IndFirstLine()).toFixed(2) + " " + metricName); - if (value.Get_Jc() !== undefined) { - switch (value.Get_Jc()) { - case 0: - changes.push("|Align right|"); - break; - case 1: - changes.push("|Align left|"); - break; - case 2: - changes.push("|Align center|"); - break; - case 3: - changes.push("|Align justify|"); - break; - } - } - if (value.Get_KeepLines() !== undefined) - changes.push(value.Get_KeepLines() ? "|Keep lines together|" : "|Don't keep lines together|"); - if (value.Get_KeepNext()) - changes.push(value.Get_KeepNext() ? "|Keep with next|" : "|Don't keep with next|"); - if (value.Get_PageBreakBefore()) - changes.push(value.Get_PageBreakBefore() ? "|Page break before|" : "|No page break before|"); - if (value.Get_SpacingLineRule() !== undefined && value.Get_SpacingLine() !== undefined) { - changes.push("|Line Spacing|: "); - changes.push((value.Get_SpacingLineRule() == c_paragraphLinerule.LINERULE_LEAST) ? "|at least|" : ((value.Get_SpacingLineRule() == c_paragraphLinerule.LINERULE_AUTO) ? "|multiple|" : "|exactly|")); - changes.push((value.Get_SpacingLineRule() == c_paragraphLinerule.LINERULE_AUTO) ? value.Get_SpacingLine() : recalcFromMM(value.Get_SpacingLine()).toFixed(2) + " " + metricName); - } - if (value.Get_SpacingBeforeAutoSpacing()) - changes.push("|Spacing before| |auto|"); - else if (value.Get_SpacingBefore() !== undefined) - changes.push("|Spacing before|" + " " + recalcFromMM(value.Get_SpacingBefore()).toFixed(2) + ' ' + metricName); - if (value.Get_SpacingAfterAutoSpacing()) - changes.push("|Spacing after| |auto|"); - else if (value.Get_SpacingAfter() !== undefined) - changes.push("|Spacing after| " + recalcFromMM(value.Get_SpacingAfter()).toFixed(2) + " " + metricName); - if (value.Get_WidowControl()) - changes.push(value.Get_WidowControl() ? "|Widow control|" : "|No widow control|"); - if (value.Get_Tabs() !== undefined) - changes.push("|Change tabs|"); - if (value.Get_NumPr() !== undefined) - changes.push("|Change numbering|"); - if (value.GetPStyle() !== undefined) { - var style = me.api.asc_GetStyleNameById(value.GetPStyle()); - if (!_.isEmpty(style)) { - changes.push(style) - } - } - break; - case Asc.c_oAscRevisionsChangeType.TablePr: - case Asc.c_oAscRevisionsChangeType.TableRowPr: - commonChanges.push("|Table Settings Changed|"); - break; - case Asc.c_oAscRevisionsChangeType.RowsAdd: - commonChanges.push("|Table Rows Added|"); - break; - case Asc.c_oAscRevisionsChangeType.RowsRem: - commonChanges.push("|Table Rows Deleted|"); - break; - } - - var userName = ''; - - if (item.get_UserName() != '') { - userName = item.get_UserName() - } else { - if (_internalStorage.externalUserInfo && _internalStorage.externalUserInfo.asc_getFullName) { - userName = _internalStorage.externalUserInfo.asc_getFullName() - } - } - - var revisionChange = { - userName: userName, - userId: item.get_UserId(), - lock: (item.get_LockUserId()!==null), - date: (item.get_DateTime() == '' ? new Date().getMilliseconds() : item.get_DateTime()), - goto: (item.get_MoveType() == Asc.c_oAscRevisionsMove.MoveTo || item.get_MoveType() == Asc.c_oAscRevisionsMove.MoveFrom), - commonChanges: commonChanges, - changes: changes - }; - - Object.keys(revisionChange).forEach(function (key) { - if (typeof revisionChange[key] === 'undefined') { - delete revisionChange[key]; - } - }); - - revisionChanges.push(revisionChange); - }); - } - postDataAsJSONString(revisionChanges, 24001); // ASC_MENU_EVENT_TYPE_SHOW_REVISIONS_CHANGE -}; - -// Fill forms - -function readSDKContentControl(props, selectedObjects) { - var type = props.get_SpecificType(), - internalId = props.get_InternalId(), - specProps; - - var result = { - get_InternalId: internalId, - get_PlaceholderText: props.get_PlaceholderText(), - get_Lock: props.get_Lock(), - get_SpecificType: type - }; - - // for list controls - if (type == Asc.c_oAscContentControlSpecificType.ComboBox || type == Asc.c_oAscContentControlSpecificType.DropDownList) { - specProps = (type == Asc.c_oAscContentControlSpecificType.ComboBox) ? props.get_ComboBoxPr() : props.get_DropDownListPr(); - if (specProps) { - var count = specProps.get_ItemsCount(); - var arr = []; - for (var i = 0; i < count; i++) { - (specProps.get_ItemValue(i) !== '') && arr.push({ - value: specProps.get_ItemValue(i), - name: specProps.get_ItemDisplayText(i) - }); - } - result["values"] = arr; - } - } else if (type == Asc.c_oAscContentControlSpecificType.CheckBox) { - specProps = props.get_CheckBoxPr(); - } else if (type == Asc.c_oAscContentControlSpecificType.Picture) { - for (i = 0; i < selectedObjects.length; i++) { - var eltype = selectedObjects[i].get_ObjectType(); - - if (eltype === Asc.c_oAscTypeSelectElement.Image) { - var value = selectedObjects[i].get_ObjectValue(); - if (value.get_ChartProperties() == null && value.get_ShapeProperties() == null) { - result["get_ImageUrl"] = value.get_ImageUrl(); - break; - } - } - } - } else if (type == Asc.c_oAscContentControlSpecificType.DateTime) { - specProps = props.get_DateTimePr(); - result["get_FullDate"] = specProps ? specProps.get_FullDate() : null; - } - - // form settings - var formPr = props.get_FormPr(); - if (formPr) { - var data = []; - if (type == Asc.c_oAscContentControlSpecificType.CheckBox) { - data = _api.asc_GetCheckBoxFormKeys(); - result["asc_GetCheckBoxFormKeys"] = data; - } else if (type == Asc.c_oAscContentControlSpecificType.Picture) { - data = _api.asc_GetPictureFormKeys(); - result["asc_GetPictureFormKeys"] = data; - } else { - data = _api.asc_GetTextFormKeys(); - result["asc_GetTextFormKeys"] = data; - } - - var arr = []; - data.forEach(function (item) { - arr.push({ displayValue: item, value: item }); - }); - - result["FormKeys"] = arr; - - var val = formPr.get_Key(); - result["get_Key"] = val; - - if (val) { - val = _api.asc_GetFormsCountByKey(val); - result["asc_GetFormsCountByKey"] = val; - } - - val = formPr.get_HelpText(); - result["get_HelpText"] = val; - - if (type == Asc.c_oAscContentControlSpecificType.CheckBox && specProps) { - val = specProps.get_GroupKey(); - result["get_GroupKey"] = val; - - var ischeckbox = (typeof val !== 'string'); - result["isCheckBox"] = ischeckbox; - - val = specProps.get_Checked(); - result["get_Checked"] = val; - - val = _api.asc_IsContentControlCheckBoxChecked(internalId); - result["asc_IsContentControlCheckBoxChecked"] = val; - - - if (!ischeckbox) { - data = _api.asc_GetRadioButtonGroupKeys(); - result["asc_GetRadioButtonGroupKeys"] = data; - - var arr = []; - data.forEach(function(item) { - arr.push({ displayValue: item, value: item }); - }); - - result["GroupKeys"] = arr; - } - } - - var formTextPr = props.get_TextFormPr(); - if (formTextPr) { - val = formTextPr.get_Comb(); - result["get_Comb"] = val; - - val = formTextPr.get_Width(); - result["get_Width"] = val; - - val = _api.asc_GetTextFormAutoWidth(); - result["asc_GetTextFormAutoWidth"] = val; - - val = formTextPr.get_MaxCharacters(); - result["get_MaxCharacters"] = val; - } - } - - return result; -} - -function onShowContentControlsActions(obj, x, y) { - var type = obj.type; - var data = { - "x": x, - "y": y, - "type": type - }; - var contentControllJSON = {}; - - switch (type) { - case Asc.c_oAscContentControlSpecificType.DateTime: - contentControllJSON = contentControllDateTimeToJSON(obj); - break; - case Asc.c_oAscContentControlSpecificType.Picture: - if (obj.pr && obj.pr.get_Lock) { - var lock = obj.pr.get_Lock(); - if (lock == Asc.c_oAscSdtLockType.SdtContentLocked || lock == Asc.c_oAscSdtLockType.ContentLocked) - return; - } - break; - case Asc.c_oAscContentControlSpecificType.DropDownList: - case Asc.c_oAscContentControlSpecificType.ComboBox: - contentControllJSON = contentControllListAToJSON(obj); - break; - } - - // merge - for(var key in contentControllJSON) { - data[key] = contentControllJSON[key]; - } - - postDataAsJSONString(data, 26001); // ASC_MENU_EVENT_TYPE_SHOW_CONTENT_CONTROLS_ACTIONS -} - -function onHideContentControlsActions() { - postDataAsJSONString(null, 26002); // ASC_MENU_EVENT_TYPE_HIDE_CONTENT_CONTROLS_ACTIONS -} - -function contentControllDateTimeToJSON(obj) { - var props = obj.pr, - specProps = props.get_DateTimePr(); - - return { - date: specProps ? specProps.get_FullDate() : null - } -} - -function contentControllListAToJSON(obj) { - var type = obj.type, - props = obj.pr, - specProps = (type == Asc.c_oAscContentControlSpecificType.ComboBox) ? props.get_ComboBoxPr() : props.get_DropDownListPr(), - isForm = !!props.get_FormPr(), - internalId = props.get_InternalId() - items = []; - - if (specProps) { - if (isForm) { // for dropdown and combobox form control always add placeholder item - var text = props.get_PlaceholderText(); - items.push({ - caption: text, - value: '' - }); - } - var count = specProps.get_ItemsCount(); - for (var i = 0; i < count; i++) { - (specProps.get_ItemValue(i) !== '' || !isForm) && items.push({ - caption: specProps.get_ItemDisplayText(i), - value: specProps.get_ItemValue(i) - }); - } - if (!isForm && menu.items.length < 1) { - items.push({ - caption: '', - value: '-1' - }); - } - } - - return { - internalId: internalId, - isForm: isForm, - items: items - } -} - -// Common - -function onFocusObject(SelectedObjects, localTrigger) { - var settings = []; - var control_props = _api.asc_IsContentControl() ? _api.asc_GetContentControlProperties() : null; - - for (var i = 0; i < SelectedObjects.length; i++) { - var eltype = SelectedObjects[i].get_ObjectType(); - var value = SelectedObjects[i].get_ObjectValue(); - - switch (eltype) - { - case Asc.c_oAscTypeSelectElement.Paragraph: - case Asc.c_oAscTypeSelectElement.Header: - case Asc.c_oAscTypeSelectElement.Table: - case Asc.c_oAscTypeSelectElement.Image: - case Asc.c_oAscTypeSelectElement.Hyperlink: - case Asc.c_oAscTypeSelectElement.Math: - { - settings.push({ - type: eltype, - localTrigger: (typeof localTrigger === 'boolean') ? localTrigger : true, - rawValue: JSON.prune(value, 5) - }); - break; - } - case Asc.c_oAscTypeSelectElement.SpellCheck: - default: - { - break; - } - } - } - - // Form object - if (control_props) { - var spectype = control_props.get_SpecificType(); - settings.push({ - type: Asc.c_oAscTypeSelectElement.ContentControl, - spectype: spectype, - localTrigger: (typeof localTrigger === 'boolean') ? localTrigger : true, - rawValue: JSON.prune(control_props, 4), - value: readSDKContentControl(control_props, SelectedObjects) - }); - } - - postDataAsJSONString(settings, 26101); // ASC_MENU_EVENT_TYPE_FOCUS_OBJECT -} - -// Others - -var DocumentPageSize = new function() -{ - this.oSizes = [{name : "US Letter", w_mm : 215.9, h_mm : 279.4, w_tw : 12240, h_tw : 15840}, - {name : "US Legal", w_mm : 215.9, h_mm : 355.6, w_tw : 12240, h_tw : 20160}, - {name : "A4", w_mm : 210, h_mm : 297, w_tw : 11907, h_tw : 16839}, - {name : "A5", w_mm : 148.1, h_mm : 209.9, w_tw : 8391, h_tw : 11907}, - {name : "B5", w_mm : 176, h_mm : 250.1, w_tw : 9979, h_tw : 14175}, - {name : "Envelope #10", w_mm : 104.8, h_mm : 241.3, w_tw : 5940, h_tw : 13680}, - {name : "Envelope DL", w_mm : 110.1, h_mm : 220.1, w_tw : 6237, h_tw : 12474}, - {name : "Tabloid", w_mm : 279.4, h_mm : 431.7, w_tw : 15842, h_tw : 24477}, - {name : "A3", w_mm : 297, h_mm : 420.1, w_tw : 16840, h_tw : 23820}, - {name : "Tabloid Oversize", w_mm : 304.8, h_mm : 457.1, w_tw : 17282, h_tw : 25918}, - {name : "ROC 16K", w_mm : 196.8, h_mm : 273, w_tw : 11164, h_tw : 15485}, - {name : "Envelope Coukei 3", w_mm : 119.9, h_mm : 234.9, w_tw : 6798, h_tw : 13319}, - {name : "Super B/A3", w_mm : 330.2, h_mm : 482.5, w_tw : 18722, h_tw : 27358} - ]; - this.sizeEpsMM = 0.5; - this.getSize = function(widthMm, heightMm) - { - for (var index in this.oSizes) - { - var item = this.oSizes[index]; - if (Math.abs(widthMm - item.w_mm) < this.sizeEpsMM && Math.abs(heightMm - item.h_mm) < this.sizeEpsMM) - return item; - } - return {w_mm : widthMm, h_mm : heightMm}; - }; -}; - -Asc["asc_docs_api"].prototype["asc_nativeOpenFile2"] = function(base64File, version) -{ - this.SpellCheckUrl = ''; - - this.WordControl.m_bIsRuler = false; - this.WordControl.Init(); - - this.InitEditor(); - this.DocumentType = 2; - this.LoadedObjectDS = this.WordControl.m_oLogicDocument.CopyStyle(); - - AscCommon.g_oIdCounter.Set_Load(true); - - var openParams = {checkFileSize : /*this.isMobileVersion*/false, charCount : 0, parCount : 0}; - var oBinaryFileReader = new AscCommonWord.BinaryFileReader(this.WordControl.m_oLogicDocument, openParams); - - if (undefined === version) - { - if (oBinaryFileReader.Read(base64File)) - { - AscCommon.g_oIdCounter.Set_Load(false); - this.LoadedObject = 1; - - this.sync_EndAction(Asc.c_oAscAsyncActionType.BlockInteraction, Asc.c_oAscAsyncAction.Open); - - // проверяем какие шрифты нужны - //this.WordControl.m_oDrawingDocument.CheckFontNeeds(); - AscCommon.pptx_content_loader.CheckImagesNeeds(this.WordControl.m_oLogicDocument); - - //this.FontLoader.LoadDocumentFonts(this.WordControl.m_oLogicDocument.Fonts, false); - } - else - this.sendEvent("asc_onError", Asc.c_oAscError.ID.MobileUnexpectedCharCount, Asc.c_oAscError.Level.Critical); - } - else - { - AscCommon.CurFileVersion = version; - if (oBinaryFileReader.Read(base64File)) - { - AscCommon.g_oIdCounter.Set_Load(false); - this.LoadedObject = 1; - - this.sync_EndAction(Asc.c_oAscAsyncActionType.BlockInteraction, Asc.c_oAscAsyncAction.Open); - } - else - this.sendEvent("asc_onError", Asc.c_oAscError.ID.MobileUnexpectedCharCount, Asc.c_oAscError.Level.Critical); - } - - /* - if (window["NATIVE_EDITOR_ENJINE"] === true && undefined != window["native"]) - { - AscCommon.CDocsCoApi.prototype.askSaveChanges = function(callback) - { - callback({"saveLock" : false}); - }; - AscCommon.CDocsCoApi.prototype.saveChanges = function(arrayChanges, deleteIndex, excelAdditionalInfo) - { - if (window["native"]["SaveChanges"]) - window["native"]["SaveChanges"](arrayChanges.join("\",\""), deleteIndex, arrayChanges.length); - }; - } - */ - - if (undefined != window["Native"]) - return; - - //callback - this.DocumentOrientation = (null == editor.WordControl.m_oLogicDocument) ? true : !editor.WordControl.m_oLogicDocument.Orientation; - var sizeMM; - if (this.DocumentOrientation) - sizeMM = DocumentPageSize.getSize(AscCommon.Page_Width, AscCommon.Page_Height); - else - sizeMM = DocumentPageSize.getSize(AscCommon.Page_Height, AscCommon.Page_Width); - this.sync_DocSizeCallback(sizeMM.w_mm, sizeMM.h_mm); - this.sync_PageOrientCallback(editor.get_DocumentOrientation()); - - if (this.GenerateNativeStyles !== undefined) - { - this.GenerateNativeStyles(); - - if (this.WordControl.m_oDrawingDocument.CheckTableStylesOne !== undefined) - this.WordControl.m_oDrawingDocument.CheckTableStylesOne(); - } -}; - -Asc['asc_docs_api'].prototype.openDocument = function(file) -{ - _api.asc_nativeOpenFile2(file.data); - - if (window.documentInfo["viewmode"]) { - _api.ShowParaMarks = false; - _api.isViewMode = true; - _api.WordControl.m_oDrawingDocument.IsViewMode = true; - } - - if (!sdkCheck) { - - console.log("OPEN FILE ONLINE READ MODE"); - - _api["NativeAfterLoad"](); - - this.ImageLoader.bIsLoadDocumentFirst = true; - - if (null != _api.WordControl.m_oLogicDocument) - { - _api.WordControl.m_oDrawingDocument.CheckGuiControlColors(); - _api.sendColorThemes(_api.WordControl.m_oLogicDocument.theme); - } - - window["native"]["onEndLoadingFile"](); - - return; - } - - var version; - if (file.changes && this.VersionHistory) - { - this.VersionHistory.changes = file.changes; - this.VersionHistory.applyChanges(this); - } - - _api["NativeAfterLoad"](); - - //console.log("ImageMap : " + JSON.stringify(this.WordControl.m_oLogicDocument)); - - this.ImageLoader.bIsLoadDocumentFirst = true; - this.ImageLoader.LoadDocumentImages(this.WordControl.m_oLogicDocument.ImageMap); - - this.WordControl.m_oLogicDocument.Continue_FastCollaborativeEditing(); - - //this.asyncFontsDocumentEndLoaded(); - - if (null != _api.WordControl.m_oLogicDocument) - { - _api.WordControl.m_oDrawingDocument.CheckGuiControlColors(); - _api.sendColorThemes(_api.WordControl.m_oLogicDocument.theme); - } - - window["native"]["onTokenJWT"](_api.CoAuthoringApi.get_jwt()); - window["native"]["onEndLoadingFile"](); - - this.WordControl.m_oDrawingDocument.Collaborative_TargetsUpdate(true); - - initSpellCheckApi(); - initTrackRevisions(); - - var t = this; - setInterval(function () { - t._autoSave(); - }, 40); -}; - -Asc["asc_docs_api"].prototype["asc_nativeGetFileData"] = function() -{ - var oBinaryFileWriter = new AscCommonWord.BinaryFileWriter(this.WordControl.m_oLogicDocument); - var memory = oBinaryFileWriter.memory; - - oBinaryFileWriter.Write(true); - - window["native"]["GetFileData"](memory.ImData.data, memory.GetCurPosition()); - - return true; -}; - -Asc['asc_docs_api'].prototype.asc_setSpellCheck = function(isOn) -{ - if (this.WordControl && this.WordControl.m_oLogicDocument) - { - var oLogicDoc = this.WordControl.m_oLogicDocument; - if(isOn) - { - this.spellCheckTimerId = setInterval(function(){oLogicDoc.ContinueSpellCheck();}, 500); - } - else - { - if(this.spellCheckTimerId) - { - clearInterval(this.spellCheckTimerId); - } - } - editor.WordControl.m_oLogicDocument.Spelling.Use = isOn; - editor.WordControl.m_oDrawingDocument.ClearCachePages(); - editor.WordControl.m_oDrawingDocument.FirePaint(); - } -}; - -// The helper function, called from the native application, -// returns information about the document as a JSON string. -Asc["asc_docs_api"].prototype["asc_nativeGetCoreProps"] = function() { - var props = (_api) ? _api.asc_getCoreProps() : null, - value; - - if (props) { - var coreProps = {}; - coreProps["asc_getModified"] = props.asc_getModified(); - - value = props.asc_getLastModifiedBy(); - if (value) - coreProps["asc_getLastModifiedBy"] = AscCommon.UserInfoParser.getParsedName(value); - - coreProps["asc_getTitle"] = props.asc_getTitle(); - coreProps["asc_getSubject"] = props.asc_getSubject(); - coreProps["asc_getDescription"] = props.asc_getDescription(); - coreProps["asc_getCreated"] = props.asc_getCreated(); - - var authors = []; - value = props.asc_getCreator();//"123\"\"\"\<\>,456"; - value && value.split(/\s*[,;]\s*/).forEach(function (item) { - authors.push(item); - }); - - coreProps["asc_getCreator"] = authors; - - return coreProps; - } - - return {}; -} - -// The helper function, wrap of asc_SetContentControlDatePickerDate -Asc["asc_docs_api"].prototype["asc_nativeSetContentControlDatePickerDate"] = function(textDate, sId) { - var oLogicDocument = this.WordControl.m_oLogicDocument; - if (!oLogicDocument) - return; - - var oContentControl = oLogicDocument.GetContentControl(sId); - if (!oContentControl || !oContentControl.IsDatePicker() || !oContentControl.CanBeEdited()) - return; - - var oPr = oContentControl.GetContentControlPr().get_DateTimePr(); - oPr.put_FullDate(new Date(textDate)); - - _api.asc_SetContentControlDatePickerPr(oPr, sId, true); -} - -/** - * one - 0 - * two - 1 - * three - 2 - * left - 3 - * right - 4 - * @param {*} sId - * @returns - */ -Asc["asc_docs_api"].prototype["asc_nativeSetColumnsSettings"] = function(sId) { - var props = new Asc.CDocumentColumnsProps(), - cols = sId, - def_space = 12.5; - props.put_EqualWidth(cols<3); - if (cols<3) { - props.put_Num(cols+1); - props.put_Space(def_space); - } else { - var total = _api.asc_GetColumnsProps().get_TotalWidth(), - left = (total - def_space*2)/3, - right = total - def_space - left; - props.put_ColByValue(0, (cols == 3) ? left : right, def_space); - props.put_ColByValue(1, (cols == 3) ? right : left, 0); - props.colbyva - } - _api.asc_SetColumnsProps(props); - -} - -/** - * one - 0 - * two - 1 - * three - 2 - * left - 3 - * right - 4 - * @returns (-1, 0, 1, 2, 3, 4) - */ -Asc["asc_docs_api"].prototype["asc_getNativeSetColumnsSettings"] = function() { - var props = _api.asc_GetColumnsProps(); - var equal = props.get_EqualWidth(), - num = (equal) ? props.get_Num() : props.get_ColsCount(), - def_space = 12.5, - index = -1; - if (equal && num<4 && (num==1 || Math.abs(props.get_Space() - def_space)<0.1)) - index = (num-1); - else if (!equal && num==2) { - var left = props.get_Col(0).get_W(), - space = props.get_Col(0).get_Space(), - right = props.get_Col(1).get_W(), - total = props.get_TotalWidth(); - if (Math.abs(space - def_space)<0.1) { - var width = (total - space*2)/3; - if ( leftright && Math.abs(right - width)<0.1) - index = 4; - } - } - return index; -} - -Asc["asc_docs_api"].prototype["asc_nativeAddText"] = function(text, wrapWithSpaces) { - var settings = new AscCommon.CAddTextSettings(); - - if (wrapWithSpaces) { - settings.SetWrapWithSpaces(true); - } - - _api.asc_AddText(text, settings); -} - -Asc["asc_docs_api"].prototype["asc_nativeGetDocumentProtection"] = function() { - var props = (_api) ? _api.asc_getDocumentProtection() : null; - if (props) { - return { - "asc_getEditType": props.asc_getEditType(), - "asc_getIsPassword": props.asc_getIsPassword() - } - } - return {}; -} - -window["AscCommon"].getFullImageSrc2 = function(src) { - var start = src.slice(0, 6); - if (0 === start.indexOf("theme") && editor.ThemeLoader) { - return editor.ThemeLoader.ThemesUrlAbs + src; - } - if (0 !== start.indexOf("http:") && 0 !== start.indexOf("data:") && 0 !== start.indexOf("https:") && 0 !== start.indexOf("file:") && 0 !== start.indexOf("ftp:")) { - var srcFull = AscCommon.g_oDocumentUrls.getImageUrl(src); - var srcFull2 = srcFull; - if (src.endsWith(".svg")) { - var sName = src.slice(0, src.length - 3); - src = sName + "wmf"; - srcFull = AscCommon.g_oDocumentUrls.getImageUrl(src); - if (!srcFull) { - src = sName + "emf"; - srcFull = AscCommon.g_oDocumentUrls.getImageUrl(src); - } - } - if (srcFull) { - window["native"]["loadUrlImage"](srcFull, src); - return srcFull2; - } - } - return src; - }; - -window["AscCommon"].sendImgUrls = function(api, images, callback) -{ - var _data = []; - callback(_data); -}; - -window["native"]["offline_of"] = function(_params, documentInfo) {NativeOpenFile3(_params, documentInfo);}; - -window["GetNativePageMeta"] = function(pageIndex) -{ - return window["API"].GetNativePageMeta(pageIndex); -} - -window.native.Call_CalculateResume = function () -{ - return window["API"].Call_CalculateResume(); -}; - -window.native.Call_TurnOffRecalculate = function () -{ - return window["API"].Call_TurnOffRecalculate(); -}; -window.native.Call_TurnOnRecalculate = function () -{ - return window["API"].Call_TurnOnRecalculate(); -}; - -window.native.Call_CheckTargetUpdate = function () -{ - return window["API"].Call_CheckTargetUpdate(); -}; -window.native.Call_Common = function (type, param) -{ - return window["API"].Call_Common(type, param); -}; - -window.native.Call_HR_Tabs = function (arrT, arrP) -{ - return window["API"].Call_HR_Tabs(arrT, arrP); -}; -window.native.Call_HR_Pr = function (_indent_left, _indent_right, _indent_first) -{ - return window["API"].Call_HR_Pr(_indent_left, _indent_right, _indent_first); -}; -window.native.Call_HR_Margins = function (_margin_left, _margin_right) -{ - return window["API"].Call_HR_Margins(_margin_left, _margin_right); -}; -window.native.Call_HR_Table = function (_params, _cols, _margins, _rows) -{ - return window["API"].Call_HR_Table(_params, _cols, _margins, _rows); -}; - -window.native.Call_VR_Margins = function (_top, _bottom) -{ - return window["API"].Call_VR_Margins(_top, _bottom); -}; -window.native.Call_VR_Header = function (_header_top, _header_bottom) -{ - return window["API"].Call_VR_Header(_header_top, _header_bottom); -}; -window.native.Call_VR_Table = function (_params, _cols, _margins, _rows) -{ - return window["API"].Call_VR_Table(_params, _cols, _margins, _rows); -};