diff --git a/cell/api.js b/cell/api.js index 33ef23147b..da76ef6b2c 100644 --- a/cell/api.js +++ b/cell/api.js @@ -1275,7 +1275,7 @@ var editor; "title": this.documentTitle, "delimiter": option.asc_getDelimiter(), "delimiterChar": option.asc_getDelimiterChar(), - "codepage": option.asc_getCodePage(), + "codepage": option.asc_getCodePageOrDefault(), "nobase64": true }; sendCommand(this, null, v); diff --git a/cell/apiBuilder.js b/cell/apiBuilder.js index e504b8f3fe..64f98c2560 100644 --- a/cell/apiBuilder.js +++ b/cell/apiBuilder.js @@ -12053,6 +12053,45 @@ return null; }; + /** + * Sets the rotation angle to the current drawing object. + * @memberof ApiDrawing + * @param {number} nRotAngle - new drawing rot angle + * @typeofeditors ["CSE"] + * @returns {boolean} + * @see office-js-api/Examples/{Editor}/ApiDrawing/Methods/SetRotation.js + */ + ApiDrawing.prototype.SetRotation = function(nRotAngle) + { + if (!this.Drawing.canRotate()) { + return false; + } + + let oXfrm = this.Drawing.getXfrm(); + oXfrm.setRot(nRotAngle * Math.PI / 180); + this.Drawing.checkDrawingBaseCoords(); + + return true; + }; + /** + * Gets the rotation angle of the current drawing object. + * @memberof ApiDrawing + * @typeofeditors ["CSE"] + * @returns {number} + * @see office-js-api/Examples/{Editor}/ApiDrawing/Methods/GetRotation.js + */ + ApiDrawing.prototype.GetRotation = function() + { + if (!this.Drawing.canRotate()) { + return 0; + } + + let oXfrm = this.Drawing.getXfrm(); + let nRad = oXfrm.getRot(); + + return nRad * 180 / Math.PI + }; + //------------------------------------------------------------------------------------------------------------------ // // ApiGroup @@ -17855,6 +17894,8 @@ ApiDrawing.prototype["GetLockValue"] = ApiDrawing.prototype.GetLockValue; ApiDrawing.prototype["SetLockValue"] = ApiDrawing.prototype.SetLockValue; ApiDrawing.prototype["GetParentSheet"] = ApiDrawing.prototype.GetParentSheet; + ApiDrawing.prototype["SetRotation"] = ApiDrawing.prototype.SetRotation; + ApiDrawing.prototype["GetRotation"] = ApiDrawing.prototype.GetRotation; ApiImage.prototype["GetClassType"] = ApiImage.prototype.GetClassType; diff --git a/cell/model/FormulaObjects/parserFormula.js b/cell/model/FormulaObjects/parserFormula.js index 0101baf580..95a56d0547 100644 --- a/cell/model/FormulaObjects/parserFormula.js +++ b/cell/model/FormulaObjects/parserFormula.js @@ -6663,9 +6663,11 @@ function parserFormula( formula, parent, _ws ) { function _getNewOutStack(aOutStack) { const aNewOutStack = []; const nMainFuncIndex = _findLastOperandId(aOutStack, function (oElement) { - return oElement.type === cElementType.func || oElement.type === cElementType.operator; + return oElement.type && (oElement.type === cElementType.func || oElement.type === cElementType.operator); }); - + if (!~nMainFuncIndex) { + return aNewOutStack; + } for (let i = 0; i < aOutStack.length; i++) { if (!(aOutStack[i] instanceof cBaseOperator) && aOutStack[i].type === cElementType.operator) { continue; @@ -6696,8 +6698,14 @@ function parserFormula( formula, parent, _ws ) { let nPrevIndex = i - 1; let nEndIndexArg = i - aOutStack[i].argumentsCurrent; for (let j = nPrevIndex; j >= nEndIndexArg; j--) { + if (j < 0) { // over reaching minimum edge + break; + } aArgsOfOperator.unshift(aNewOutStack.pop()); } + if (aArgsOfOperator.length < aOperatorData[1]) { + break; + } aOperatorData.push(aArgsOfOperator); aNewOutStack.push(aOperatorData); continue; @@ -7178,6 +7186,9 @@ function parserFormula( formula, parent, _ws ) { parserFormula.prototype.isRecursiveCondFormula = function (sFunctionName, aArgs) { const aCellFormulas = ['IF', 'IFS', 'SWITCH']; const aOutStack = aArgs && aArgs.length ? aArgs : _getNewOutStack(this.outStack); + if (!aOutStack.length) { + return false; + } if (aOutStack.length === 1 && aOutStack[0][0].type === cElementType.operator) { const aArgs = aOutStack[0][2]; let bHasRecursion = false; @@ -8653,7 +8664,7 @@ function parserFormula( formula, parent, _ws ) { this.outStack.push(operand); } } - if (bConditionalFormula && t.getParent() && t.getParent() instanceof AscCommonExcel.CCellWithFormula && !t.ca) { + if (bConditionalFormula && t.getParent() && t.getParent() instanceof AscCommonExcel.CCellWithFormula && !t.ca && !ignoreErrors) { t.ca = t.isRecursiveCondFormula(levelFuncMap[0].func.name); t.outStack.forEach(function (oOperand) { if (oOperand.type === cElementType.name || oOperand.type === cElementType.name3D) { diff --git a/cell/model/History.js b/cell/model/History.js index 80fe618777..a32e2a7ff9 100644 --- a/cell/model/History.js +++ b/cell/model/History.js @@ -611,7 +611,7 @@ CHistory.prototype.RedoAdd = function(oRedoObjectParam, Class, Type, sheetid, ra } var curPoint = this.Points[this.Index]; //if(Class) - this.Add(Class, Type, sheetid, range, Data, LocalChange); + this.Add(Class, Type, sheetid, range, Data, LocalChange, true); if(bNeedOff) this.TurnOff(); @@ -1188,7 +1188,7 @@ CHistory.prototype.Create_NewPoint = function() // Регистрируем новое изменение: // Class - объект, в котором оно произошло // Data - сами изменения -CHistory.prototype.Add = function(Class, Type, sheetid, range, Data, LocalChange) +CHistory.prototype.Add = function(Class, Type, sheetid, range, Data, LocalChange, isRedoAdd) { if (!this.CanAddChanges()) return; @@ -1231,7 +1231,9 @@ CHistory.prototype.Add = function(Class, Type, sheetid, range, Data, LocalChange if(null != LocalChange) Item.LocalChange = LocalChange; - this.Refresh_SpreadsheetChanges(Item); + if (!isRedoAdd) { + this.Refresh_SpreadsheetChanges(Item); + } var curPoint = this.Points[this.Index]; curPoint.Items.push( Item ); diff --git a/cell/model/Workbook.js b/cell/model/Workbook.js index aceced79aa..c0369b6309 100644 --- a/cell/model/Workbook.js +++ b/cell/model/Workbook.js @@ -5760,7 +5760,7 @@ } SheetMemory.prototype.checkIndex = function(index) { if (index > this.maxIndex) { - return; + index = this.maxIndex; } if (this.data) { let allocatedCount = this.getAllocatedCount(); @@ -5850,11 +5850,11 @@ this.indexA += insertCount; this.indexB += insertCount; } else { - let oldCount = (this.indexB + 1 - this.indexA); this.checkIndex(this.indexB + insertCount); - var startOffset = (insA - this.indexA) * this.structSize; - var endOffset = (insB - this.indexA) * this.structSize; - var endData = oldCount * this.structSize; + const newCount = (this.indexB + 1 - this.indexA); + const startOffset = (insA - this.indexA) * this.structSize; + const endOffset = (insB - this.indexA) * this.structSize; + const endData = (newCount - insertCount) * this.structSize; this.data.set(this.data.subarray(startOffset, endData), endOffset); this.data.fill(0, startOffset, endOffset); } diff --git a/cell/model/WorkbookElems.js b/cell/model/WorkbookElems.js index 10d26ca49d..0ba7ffb349 100644 --- a/cell/model/WorkbookElems.js +++ b/cell/model/WorkbookElems.js @@ -6146,7 +6146,7 @@ StyleManager.prototype = }; Hyperlink.prototype.getProperty = function (nType) { switch (nType) { - case this.Properties.Ref: return parserHelp.get3DRef(this.Ref.worksheet.getName(), this.Ref.getName()); + case this.Properties.Ref: return this.Ref && parserHelp.get3DRef(this.Ref.worksheet.getName(), this.Ref.getName()) || null; case this.Properties.Location: return this.getLocation(); case this.Properties.Hyperlink: return this.Hyperlink; case this.Properties.Tooltip: return this.Tooltip; @@ -13324,10 +13324,10 @@ function RangeDataManagerElem(bbox, data) } }; - asc_CPageSetup.prototype.asc_setScale = function (newVal) { + asc_CPageSetup.prototype.asc_setScale = function (newVal, isNotHistory) { var oldVal = this.scale; this.scale = newVal; - if (this.ws && AscCommon.History.Is_On() && oldVal !== this.scale) { + if (!isNotHistory && this.ws && AscCommon.History.Is_On() && oldVal !== this.scale) { AscCommon.History.Add(AscCommonExcel.g_oUndoRedoLayout, AscCH.historyitem_Layout_Scale, this.ws.getId(), null, new UndoRedoData_Layout(oldVal, newVal)); } diff --git a/cell/view/WorksheetView.js b/cell/view/WorksheetView.js index f22cfff2ea..0477731794 100644 --- a/cell/view/WorksheetView.js +++ b/cell/view/WorksheetView.js @@ -4210,10 +4210,11 @@ var calcScale = this.calcPrintScale(width, height); if(!isNaN(calcScale)) { + let viewMode = this.handlers.trigger('getViewMode'); let realLockDraw = this.lockDraw; //TODO add lock draw here. need review all draw calls(try to replace on recalculate) this.lockDraw = true; - this._setPrintScale(calcScale); + this._setPrintScale(calcScale, viewMode); this.lockDraw = realLockDraw; } @@ -4334,7 +4335,7 @@ } }; - WorksheetView.prototype._setPrintScale = function (val) { + WorksheetView.prototype._setPrintScale = function (val, isNotHistory) { var pageOptions = this.model.PagePrintOptions; var pageSetup = pageOptions.asc_getPageSetup(); var oldScale = pageSetup.asc_getScale(); @@ -4343,7 +4344,7 @@ History.Create_NewPoint(); History.StartTransaction(); - pageSetup.asc_setScale(val); + pageSetup.asc_setScale(val, isNotHistory); History.EndTransaction(); } @@ -18427,7 +18428,7 @@ WorksheetView.prototype._saveCellValueAfterEdit = function (c, val, flags, isNotHistory, lockDraw) { const t = this; - const ws = t.model + const ws = t.model; let bbox = c.bbox; let ctrlKey = flags && flags.ctrlKey; @@ -28693,7 +28694,9 @@ pastedRangeProps.hidden = newVal.getHidden(); - pastedRangeProps.locked = newVal.getLocked(); + if (!t.ws.model.getSheetProtection()) { + pastedRangeProps.locked = newVal.getLocked(); + } } var tableDxf = getTableDxf(fromRow, fromCol, newVal); diff --git a/common/AdvancedOptions.js b/common/AdvancedOptions.js index d87bcfd6ae..ee2bf50792 100644 --- a/common/AdvancedOptions.js +++ b/common/AdvancedOptions.js @@ -105,6 +105,13 @@ asc_CTextOptions.prototype.asc_getDelimiterChar = function(){return this.delimiterChar;}; asc_CTextOptions.prototype.asc_setDelimiterChar = function(v){this.delimiterChar = v;}; asc_CTextOptions.prototype.asc_getCodePage = function(){return this.codePage;}; + asc_CTextOptions.prototype.asc_getCodePageOrDefault = function() { + //c_oAscCodePageNone is invalid codepage for convertion. undefined codepage cause repeated dialog + if (this.codePage === AscCommon.c_oAscCodePageNone || this.codePage === undefined || this.codePage === null) { + return AscCommon.c_oAscCodePageUtf8; + } + return this.codePage; + }; asc_CTextOptions.prototype.asc_setCodePage = function(v){this.codePage = v;}; asc_CTextOptions.prototype.asc_getNumberDecimalSeparator = function () { return this.numberDecimalSeparator !== null ? this.numberDecimalSeparator : AscCommon.g_oDefaultCultureInfo.NumberDecimalSeparator; @@ -232,6 +239,7 @@ prot["asc_getDelimiterChar"] = prot.asc_getDelimiterChar; prot["asc_setDelimiterChar"] = prot.asc_setDelimiterChar; prot["asc_getCodePage"] = prot.asc_getCodePage; + prot["asc_getCodePageOrDefault"] = prot.asc_getCodePageOrDefault; prot["asc_setCodePage"] = prot.asc_setCodePage; prot["asc_setNumberDecimalSeparator"] = prot.asc_setNumberDecimalSeparator; prot["asc_setNumberGroupSeparator"] = prot.asc_setNumberGroupSeparator; diff --git a/common/Drawings/Format/ChartSpace.js b/common/Drawings/Format/ChartSpace.js index d3b8889359..25110c28e4 100644 --- a/common/Drawings/Format/ChartSpace.js +++ b/common/Drawings/Format/ChartSpace.js @@ -1973,6 +1973,9 @@ function(window, undefined) { let allSeries = this.getAllSeries(); if (allSeries.length === 0) { return false; + } + if(this.isChartEx()) { + } return true; }; @@ -4396,7 +4399,17 @@ function(window, undefined) { this.group = group; }; CChartSpace.prototype.hasCharts = function () { - if (this.isChartEx() || !this.isChartEx() && this.chart && this.chart.plotArea && this.chart.plotArea.charts.length > 0) { + if(this.isChartEx()) { + let plotAreaRegion = this.chart.plotArea.plotAreaRegion; + if (!plotAreaRegion) { + return false; + } + + let oSeries = plotAreaRegion.series[0]; + if(!oSeries) return false; + return true; + } + if (this.chart && this.chart.plotArea && this.chart.plotArea.charts.length > 0) { return true; } return false; @@ -4469,11 +4482,15 @@ function(window, undefined) { return true; } if (this.isChartEx()) { - if (!this.chart.plotArea.plotAreaRegion) { + let plotAreaRegion = this.chart.plotArea.plotAreaRegion; + if (!plotAreaRegion) { return true; } - const numLit = this.chart.plotArea.plotAreaRegion.series[0].getValLit(); + let oSeries = plotAreaRegion.series[0]; + if(!oSeries) return true; + + const numLit = oSeries.getValLit(); if (!numLit) { return true; } diff --git a/common/Drawings/Format/Format.js b/common/Drawings/Format/Format.js index 81325a044d..890bea08f1 100644 --- a/common/Drawings/Format/Format.js +++ b/common/Drawings/Format/Format.js @@ -8035,6 +8035,9 @@ this.rot = pr; this.handleUpdateRot(); }; + CXfrm.prototype.getRot = function() { + return this.rot; + }; CXfrm.prototype.shift = function(dDX, dDY) { if(this.offX !== null && this.offY !== null) { this.setOffX(this.offX + dDX); diff --git a/common/apiBase.js b/common/apiBase.js index 2ccea44c35..8213aaa87a 100644 --- a/common/apiBase.js +++ b/common/apiBase.js @@ -223,6 +223,8 @@ this.skinObject = config['skin']; this.isDarkMode = false; + this.isRtlInterface = config['isRtlInterface'] === true; + this.Shortcuts = new AscCommon.CShortcuts(); this.initDefaultShortcuts(); diff --git a/common/apiBase_plugins.js b/common/apiBase_plugins.js index 96dc64cc2a..db15a6ead1 100644 --- a/common/apiBase_plugins.js +++ b/common/apiBase_plugins.js @@ -1177,7 +1177,7 @@ Api.prototype["pluginMethod_GetSelectedContent"] = function(prop) { let type = AscCommon.c_oAscClipboardDataFormat.Text; - if (prop && "html" === prop.type) + if (prop && "html" === prop["type"]) type = AscCommon.c_oAscClipboardDataFormat.Html; return this.getSelectedContent(type); diff --git a/common/commonDefines.js b/common/commonDefines.js index a53c6891fc..f36661e774 100644 --- a/common/commonDefines.js +++ b/common/commonDefines.js @@ -3671,10 +3671,10 @@ window.AscCommon.g_cIsBeta = "false"; var availableIdeographLanguages = ['zh-CN', 'vi-VN', 'ko-KR', 'ja-JP', 'zh-Hans', 'zh-TW', 'zh-CN', 'zh-HK', 'zh-SG', 'zh-MO', 'zh-Hant', 'zh']; var availableBidiLanguages = []; - var document_compatibility_mode_Word11 = 11; + var document_compatibility_mode_Word11 = 11; // 2003 (doc) var document_compatibility_mode_Word12 = 12; - var document_compatibility_mode_Word14 = 14; - var document_compatibility_mode_Word15 = 15; + var document_compatibility_mode_Word14 = 14; // 2010 + var document_compatibility_mode_Word15 = 15; // 2013/2015/2019 var document_compatibility_mode_Current = document_compatibility_mode_Word12; diff --git a/common/libfont/test/header.js b/common/libfont/test/header.js new file mode 100644 index 0000000000..facd1d1f65 --- /dev/null +++ b/common/libfont/test/header.js @@ -0,0 +1,40 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2024 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ + +"use strict"; + +(function (window, undefined) +{ + + window['AscCommonExcel'] = window['AscCommonExcel'] || {}; + +})(window); diff --git a/common/libfont/test/shaper.html b/common/libfont/test/shaper.html index b09e2a4a00..50b0ddc12c 100644 --- a/common/libfont/test/shaper.html +++ b/common/libfont/test/shaper.html @@ -3,6 +3,7 @@
+ @@ -14,7 +15,6 @@ - @@ -23,6 +23,8 @@ + + diff --git a/pdf/api.js b/pdf/api.js index 7fe2320044..b47ef621b6 100644 --- a/pdf/api.js +++ b/pdf/api.js @@ -1680,7 +1680,7 @@ oParaPr.ListType = AscFormat.fGetListTypeFromBullet(oParaPr.Bullet); this.sync_ParaSpacingLine(oParaPr.Spacing); - this.Update_ParaInd(oParaPr.Ind); + this.Update_ParaInd(oParaPr.Ind, false); this.sync_PrAlignCallBack(oParaPr.Jc); this.sync_ParaStyleName(oParaPr.StyleName); this.sync_ListType(oParaPr.ListType); diff --git a/pdf/src/annotations/base.js b/pdf/src/annotations/base.js index 0c9cf0b3f5..b69bb1a2b5 100644 --- a/pdf/src/annotations/base.js +++ b/pdf/src/annotations/base.js @@ -581,11 +581,12 @@ this.SetWasChanged(true); }; CAnnotationBase.prototype.IsUseInDocument = function() { - let oDoc = Asc.editor.getPDFDoc(); - if (oDoc.annots.indexOf(this) == -1) - return false; + let oPage = this.GetParentPage(); + if (oPage && oPage.annots.includes(this)) { + return true; + } - return true; + return false; }; CAnnotationBase.prototype.GetRect = function() { diff --git a/pdf/src/drawings/drawingPrototype.js b/pdf/src/drawings/drawingPrototype.js index bef1f75c40..996d0f0609 100644 --- a/pdf/src/drawings/drawingPrototype.js +++ b/pdf/src/drawings/drawingPrototype.js @@ -82,12 +82,12 @@ if (this.group && this.group.IsUseInDocument) return this.group.IsUseInDocument(); - let oDoc = this.GetDocument(); - if (!oDoc) { - return false; + let oPage = this.GetParentPage(); + if (oPage && oPage.drawings.includes(this)) { + return true; } - return (-1 !== oDoc.drawings.indexOf(this)); + return false; }; CPdfDrawingPrototype.prototype.OnBlur = function() { AscCommon.History.ForbidUnionPoint(); diff --git a/pdf/src/forms/base/base.js b/pdf/src/forms/base/base.js index f049614a78..c62baee5d5 100644 --- a/pdf/src/forms/base/base.js +++ b/pdf/src/forms/base/base.js @@ -746,11 +746,12 @@ oActionsQueue.Start(); }; CBaseField.prototype.IsUseInDocument = function() { - let oDoc = Asc.editor.getPDFDoc(); - if (oDoc.widgets.indexOf(this) == -1) - return false; + let oPage = this.GetParentPage(); + if (oPage && oPage.fields.includes(this)) { + return true; + } - return true; + return false; }; CBaseField.prototype.DrawHighlight = function(oCtx) { if (this.IsHidden() == true) diff --git a/pdf/src/history/documentChanges.js b/pdf/src/history/documentChanges.js index 6bf04153e5..ba0941cfe6 100644 --- a/pdf/src/history/documentChanges.js +++ b/pdf/src/history/documentChanges.js @@ -156,6 +156,7 @@ CChangesPDFDocumentAnnotsContent.prototype.Redo = function() oItem._page = -1; oItem.selectStartPage = -1; + oViewer.DrawingObjects.resetSelection(); oItem.AddToRedraw(); Asc.editor.sync_RemoveComment(oItem.GetId()); } diff --git a/pdf/src/viewer.js b/pdf/src/viewer.js index 40da63bb8a..8328b92041 100644 --- a/pdf/src/viewer.js +++ b/pdf/src/viewer.js @@ -2254,7 +2254,7 @@ }; this.canInteract = function() { // не даем взаимодействовать с документом пока не произошла отрисовка - return this.scheduledRepaintTimer == null && this.isRepaint != true; + return this.scheduledRepaintTimer == null && this.isRepaint != true && this.initPaintDone == true; }; this.getPageDrawingByMouse = function() { @@ -3227,6 +3227,8 @@ // Обязательно делаем в конце, т.к. во время отрисовки происходит пересчет this._checkTargetUpdate(); + + this.initPaintDone = true; }; this.updatePageDetector = function() { this.pageDetector = new CCurrentPageDetector(this.canvas.width, this.canvas.height); diff --git a/slide/Drawing/HtmlPage.js b/slide/Drawing/HtmlPage.js index b94bc04115..beb6a3c79f 100644 --- a/slide/Drawing/HtmlPage.js +++ b/slide/Drawing/HtmlPage.js @@ -1205,6 +1205,10 @@ // Splitter elements CEditorPage.prototype.createSplitterElement = function (splitterIndex) { const splitterElement = document.createElement("div"); + this.GetVertRulerLeft = function() + { + return 0; + }; const position = Math.round(this.splitters[splitterIndex - 1].position * g_dKoef_mm_to_pix); const splitterWidth = Math.round(GlobalSkin.SplitterWidthMM * g_dKoef_mm_to_pix); diff --git a/slide/api.js b/slide/api.js index dca7ecd8da..3fb61872bb 100644 --- a/slide/api.js +++ b/slide/api.js @@ -2137,7 +2137,7 @@ background-repeat: no-repeat;\ ParaPr.Position = TextPr.Position; ParaPr.ListType = AscFormat.fGetListTypeFromBullet(ParaPr.Bullet); this.sync_ParaSpacingLine(ParaPr.Spacing); - this.Update_ParaInd(ParaPr.Ind); + this.Update_ParaInd(ParaPr.Ind, ParaPr.Bidi); this.sync_PrAlignCallBack(ParaPr.Jc); this.sync_ParaStyleName(ParaPr.StyleName); this.sync_ListType(ParaPr.ListType); diff --git a/slide/apiBuilder.js b/slide/apiBuilder.js index de2a19a6a4..ead3071e99 100644 --- a/slide/apiBuilder.js +++ b/slide/apiBuilder.js @@ -1633,7 +1633,7 @@ { if (this.Master) { - if (!(oDrawing instanceof ApiDrawing) || oDrawing.Drawing.group || oDrawing.Drawing.IsUseInDocument()) + if (oDrawing.Drawing.group || oDrawing.Drawing.IsUseInDocument()) return false; oDrawing.Drawing.setParent(this.Master); @@ -2010,7 +2010,7 @@ { if (this.Layout) { - if (!(oDrawing instanceof ApiDrawing) || oDrawing.Drawing.group || oDrawing.Drawing.IsUseInDocument()) + if (oDrawing.Drawing.group || oDrawing.Drawing.IsUseInDocument()) return false; oDrawing.Drawing.setParent(this.Layout); @@ -2935,7 +2935,7 @@ */ ApiSlide.prototype.AddObject = function(oDrawing){ if(this.Slide){ - if (!(oDrawing instanceof ApiDrawing) || oDrawing.Drawing.group || oDrawing.Drawing.IsUseInDocument()) + if (oDrawing.Drawing.group || oDrawing.Drawing.IsUseInDocument()) return false; oDrawing.Drawing.setParent(this.Slide); @@ -3906,6 +3906,44 @@ oController.updateOverlay(); }; + /** + * Sets the rotation angle to the current drawing object. + * @memberof ApiDrawing + * @param {number} nRotAngle - new drawing rot angle + * @typeofeditors ["CPE"] + * @returns {boolean} + * @see office-js-api/Examples/{Editor}/ApiDrawing/Methods/SetRotation.js + */ + ApiDrawing.prototype.SetRotation = function(nRotAngle) + { + if (!this.Drawing.canRotate()) { + return false; + } + + let oXfrm = this.Drawing.getXfrm(); + oXfrm.setRot(nRotAngle * Math.PI / 180); + + return true; + }; + /** + * Gets the rotation angle of the current drawing object. + * @memberof ApiDrawing + * @typeofeditors ["CPE"] + * @returns {number} + * @see office-js-api/Examples/{Editor}/ApiDrawing/Methods/GetRotation.js + */ + ApiDrawing.prototype.GetRotation = function() + { + if (!this.Drawing.canRotate()) { + return 0; + } + + let oXfrm = this.Drawing.getXfrm(); + let nRad = oXfrm.getRot(); + + return nRad * 180 / Math.PI + }; + //------------------------------------------------------------------------------------------------------------------ // // ApiGroup @@ -4992,6 +5030,8 @@ ApiDrawing.prototype["GetLockValue"] = ApiDrawing.prototype.GetLockValue; ApiDrawing.prototype["SetLockValue"] = ApiDrawing.prototype.SetLockValue; ApiDrawing.prototype["Select"] = ApiDrawing.prototype.Select; + ApiDrawing.prototype["SetRotation"] = ApiDrawing.prototype.SetRotation; + ApiDrawing.prototype["GetRotation"] = ApiDrawing.prototype.GetRotation; ApiGroup.prototype["GetClassType"] = ApiGroup.prototype.GetClassType; ApiGroup.prototype["Ungroup"] = ApiGroup.prototype.Ungroup; diff --git a/tests/cell/spreadsheet-calculation/SheetMemoryTest.js b/tests/cell/spreadsheet-calculation/SheetMemoryTest.js index 1f7e04bf9a..2f060c0f70 100644 --- a/tests/cell/spreadsheet-calculation/SheetMemoryTest.js +++ b/tests/cell/spreadsheet-calculation/SheetMemoryTest.js @@ -50,21 +50,21 @@ $(function () { sheetMemory.checkIndex(200); assert.strictEqual(sheetMemory.hasIndex(200), false); assert.strictEqual(sheetMemory.getMinIndex(), 10); - assert.strictEqual(sheetMemory.getMaxIndex(), 10); + assert.strictEqual(sheetMemory.getMaxIndex(), 100); sheetMemory.checkIndex(15); assert.strictEqual(sheetMemory.hasIndex(15), true); - assert.strictEqual(sheetMemory.hasIndex(16), false); + assert.strictEqual(sheetMemory.hasIndex(16), true); assert.strictEqual(sheetMemory.getMinIndex(), 10); - assert.strictEqual(sheetMemory.getMaxIndex(), 15); + assert.strictEqual(sheetMemory.getMaxIndex(), 100); sheetMemory.checkIndex(5); assert.strictEqual(sheetMemory.hasIndex(4), false); assert.strictEqual(sheetMemory.hasIndex(5), true); assert.strictEqual(sheetMemory.getMinIndex(), 5); - assert.strictEqual(sheetMemory.getMaxIndex(), 15); + assert.strictEqual(sheetMemory.getMaxIndex(), 100); - let allocThreshOld = sheetMemory.getMinIndex() + sheetMemory.getAllocatedCount(); + let allocThreshOld = sheetMemory.getMinIndex() + sheetMemory.getAllocatedCount() - 1; sheetMemory.checkIndex(allocThreshOld); sheetMemory.setUint8(allocThreshOld, 0, 1); assert.strictEqual(sheetMemory.getMinIndex(), 5); diff --git a/tests/word/document-calculation/paragraph.html b/tests/word/document-calculation/paragraph.html index d35226d72d..fcd31aec07 100644 --- a/tests/word/document-calculation/paragraph.html +++ b/tests/word/document-calculation/paragraph.html @@ -26,6 +26,7 @@ + diff --git a/tests/word/document-calculation/paragraph/paragraph-wrap.js b/tests/word/document-calculation/paragraph/paragraph-wrap.js new file mode 100644 index 0000000000..0793589a14 --- /dev/null +++ b/tests/word/document-calculation/paragraph/paragraph-wrap.js @@ -0,0 +1,323 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2025 + * + * 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 () { + + let logicDocument = AscTest.CreateLogicDocument(); + + const charWidth = AscTest.CharWidth * AscTest.FontSize; + + const L_FIELD = 20 * charWidth; + const R_FIELD = 30 * charWidth; + const PAGE_W = 150 * charWidth; + + + function addFlowImageToParagraph(p, w, h, x, y) + { + let d = AscTest.CreateImage(w, h); + let run = new AscWord.CRun(); + p.AddToContent(0, run); + run.AddToContent(0, d); + + d.Set_DrawingType(drawing_Anchor); + d.Set_Distance(0, 0, 0, 0); + d.Set_WrappingType(WRAPPING_TYPE_SQUARE); + d.Set_PositionH(Asc.c_oAscRelativeFromH.Page, false, x); + d.Set_PositionV(Asc.c_oAscRelativeFromV.Page, false, y); + return d; + } + + function initDocument() + { + AscTest.ClearDocument(); + logicDocument.AddToContent(0, AscTest.CreateParagraph()); + + let sectPr = AscTest.GetFinalSection(); + sectPr.SetPageSize(PAGE_W, 1000); + sectPr.SetPageMargins(L_FIELD, 50, R_FIELD, 50); + } + + function checkText(assert, para, lines) + { + assert.strictEqual(para.getLineCount(), lines.length, "Check number of lines"); + + for (let i = 0, lineCount = Math.min(lines.length, para.GetLinesCount()); i < lineCount; ++i) + { + assert.strictEqual(para.getRangeCount(i), lines[i].length, "Check number of ranges in " + (i + 1) + " line"); + for (let j = 0, rangeCount = Math.min(lines[i].length, para.getRangeCount(i)); j < rangeCount; ++j) + { + assert.strictEqual(para.getTextInLineRange(i, j), lines[i][j], "Check text in range " + j); + } + } + } + function checkRangeBounds(assert, para, lines) + { + for (let i = 0, lineCount = Math.min(lines.length, para.GetLinesCount()); i < lineCount; ++i) + { + for (let j = 0, rangeCount = Math.min(lines[i].length, para.getRangeCount(i)); j < rangeCount; ++j) + { + let range = para.getRange(i, j); + assert.close(range.X, lines[i][j][0], 0.001, "Check x for " + j + "range"); + assert.close(range.XEnd, lines[i][j][1], 0.001, "Check x for " + j + "range"); + } + } + } + + QUnit.module("Test paragraph wrap", { + beforeEach : function() + { + initDocument(); + AscTest.SetCompatibilityMode(AscCommon.document_compatibility_mode_Current); + } + }); + + QUnit.test("Test simple wrap", function(assert) + { + let imageX0 = 45 * charWidth; + let imageX1 = imageX0 + 30 * charWidth; + let imageY0 = 40; + let imageY1 = imageY0 + 50; + + let p1 = logicDocument.GetElement(0); + + let p2 = AscTest.CreateParagraph(); + + logicDocument.AddToContent(0, p2); + + addFlowImageToParagraph(p2, imageX1 - imageX0, imageY1 - imageY0, imageX0, imageY0); + + AscTest.AddTextToParagraph(p1, "VeryLongWord The quick brown fox jumps over the lazy dog"); + AscTest.Recalculate(); + + checkText(assert, p1, [ + ["VeryLongWord The quick ", "brown fox jumps over the lazy dog\r\n"] + ]); + checkRangeBounds(assert, p1, [ + [[L_FIELD, imageX0], [imageX1, PAGE_W - R_FIELD]] + ]); + + // Check ranges order for RTL paragraph + p1.SetParagraphBidi(true); + AscTest.Recalculate(); + checkText(assert, p1, [ + ["VeryLongWord The quick brown fox jumps over ", "the lazy dog\r\n"] + ]); + checkRangeBounds(assert, p1, [ + [[imageX1, PAGE_W - R_FIELD], [L_FIELD, imageX0]] + ]); + }); + + QUnit.test("Test the first line indent", function(assert) + { + let imageX0 = 45 * charWidth; + let imageX1 = imageX0 + 10 * charWidth; + let imageY0 = 40; + let imageY1 = 90; + let firstLine = 5 * charWidth; + let leftInd = 5 * charWidth; + let rightInd = 0; + + let text = "VeryLongWord The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog."; + + function initParagraphWithImage() + { + initDocument(); + + let p1 = logicDocument.GetElement(0); + let p2 = AscTest.CreateParagraph(); + logicDocument.AddToContent(0, p2); + + addFlowImageToParagraph(p2, imageX1 - imageX0, imageY1 - imageY0, imageX0, imageY0); + + p1.SetParagraphIndent({FirstLine : firstLine, Left : leftInd, Right : rightInd}); + p1.SetParagraphSpacing({Line : 1, LineRule : Asc.linerule_Auto, Before : 0, After : 0}); + AscTest.AddTextToParagraph(p1, text); + AscTest.Recalculate(); + return p1; + } + + function test(textLines, ranges) + { + let p = initParagraphWithImage(); + checkText(assert, p, textLines); + checkRangeBounds(assert, p, ranges); + } + + AscTest.SetCompatibilityMode(AscCommon.document_compatibility_mode_Word15); + + // Simple situation + test([ + ["VeryLongWord ", "The quick brown fox jumps over the lazy dog. The quick brown fox "], + ["jumps over the lazy ", "dog.\r\n"], + ], [ + [[L_FIELD + firstLine + leftInd, imageX0], [imageX1, PAGE_W - R_FIELD]], + [[L_FIELD + leftInd, imageX0], [imageX1, PAGE_W - R_FIELD]] + ]); + + AscTest.SetCompatibilityMode(AscCommon.document_compatibility_mode_Word14); + + text = "VeryLongWord The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog."; + + firstLine = 5 * charWidth; + leftInd = 15 * charWidth; + test([ + ["", "VeryLongWord The quick brown fox jumps over the lazy dog. "], + ["The quick ", "brown fox jumps over the lazy dog. The quick brown fox jumps over "], + ["the lazy dog.\r\n"], + ], [ + [[L_FIELD + firstLine + leftInd, imageX0], [imageX1 + firstLine, PAGE_W - R_FIELD]], + [[L_FIELD + leftInd, imageX0], [imageX1, PAGE_W - R_FIELD]], + [[L_FIELD + leftInd, PAGE_W - R_FIELD]] + ]); + + firstLine = 15 * charWidth; + leftInd = 0; + test([ + ["", "VeryLongWord The quick brown fox jumps over the "], + ["lazy dog. The quick brown ", "fox jumps over the lazy dog. The quick brown fox jumps over the "], + ["lazy dog.\r\n"], + ], [ + [[L_FIELD + firstLine + leftInd, imageX0], [imageX1 + firstLine, PAGE_W - R_FIELD]], + [[L_FIELD + leftInd, imageX0], [imageX1, PAGE_W - R_FIELD]], + [[L_FIELD + leftInd, PAGE_W - R_FIELD]] + ]); + + + AscTest.SetCompatibilityMode(AscCommon.document_compatibility_mode_Word15); + + firstLine = 5 * charWidth; + leftInd = 15 * charWidth; + test([ + ["", "VeryLongWord The quick brown fox jumps over the lazy dog. "], + ["The quick ", "brown fox jumps over the lazy dog. The quick brown fox jumps over "], + ["the lazy dog.\r\n"], + ], [ + [[L_FIELD + firstLine + leftInd, imageX0], [imageX1 + firstLine, PAGE_W - R_FIELD]], + [[L_FIELD + leftInd, imageX0], [imageX1, PAGE_W - R_FIELD]], + [[L_FIELD + leftInd, PAGE_W - R_FIELD]] + ]); + + + // Check the indentation when the first range is empty + AscTest.SetCompatibilityMode(AscCommon.document_compatibility_mode_Word14); + + firstLine = 0; + leftInd = 0; + text = "VeryLongLongLongLongLongLongLongWord" + test([ + ["", "VeryLongLongLongLongLongLongLongWord\r\n"], + ], [ + [[L_FIELD + firstLine + leftInd, imageX0], [imageX1 + firstLine, PAGE_W - R_FIELD]] + ]); + + firstLine = 10 * charWidth; + leftInd = 0; + test([ + ["", "VeryLongLongLongLongLongLongLongWord\r\n"], + ], [ + [[L_FIELD + firstLine + leftInd, imageX0], [imageX1 + firstLine, PAGE_W - R_FIELD]] + ]); + + firstLine = 10 * charWidth; + leftInd = 10 * charWidth; + test([ + ["", "VeryLongLongLongLongLongLongLongWord\r\n"], + ], [ + [[L_FIELD + firstLine + leftInd, imageX0], [imageX1 + firstLine, PAGE_W - R_FIELD]] + ]); + + firstLine = -5 * charWidth; + leftInd = 10 * charWidth; + test([ + ["", "VeryLongLongLongLongLongLongLongWord\r\n"], + ], [ + [[L_FIELD + firstLine + leftInd, imageX0], [imageX1 + leftInd + firstLine, PAGE_W - R_FIELD]] + ]); + + firstLine = -15 * charWidth; + leftInd = 10 * charWidth; + test([ + ["", "VeryLongLongLongLongLongLongLongWord\r\n"], + ], [ + [[L_FIELD + firstLine + leftInd, imageX0], [imageX1 + leftInd + firstLine, PAGE_W - R_FIELD]] + ]); + + // Check the indentation when the first range is empty + AscTest.SetCompatibilityMode(AscCommon.document_compatibility_mode_Word15); + + firstLine = 0; + leftInd = 0; + text = "VeryLongLongLongLongLongLongLongWord" + test([ + ["", "VeryLongLongLongLongLongLongLongWord\r\n"], + ], [ + [[L_FIELD + firstLine + leftInd, imageX0], [imageX1 + Math.max(0, firstLine), PAGE_W - R_FIELD]] + ]); + + firstLine = 10 * charWidth; + leftInd = 0; + test([ + ["", "VeryLongLongLongLongLongLongLongWord\r\n"], + ], [ + [[L_FIELD + firstLine + leftInd, imageX0], [imageX1 + Math.max(0, firstLine), PAGE_W - R_FIELD]] + ]); + + firstLine = 10 * charWidth; + leftInd = 10 * charWidth; + test([ + ["", "VeryLongLongLongLongLongLongLongWord\r\n"], + ], [ + [[L_FIELD + firstLine + leftInd, imageX0], [imageX1 + Math.max(0, firstLine), PAGE_W - R_FIELD]] + ]); + + firstLine = -5 * charWidth; + leftInd = 10 * charWidth; + test([ + ["", "VeryLongLongLongLongLongLongLongWord\r\n"], + ], [ + [[L_FIELD + firstLine + leftInd, imageX0], [imageX1 + Math.max(0, firstLine), PAGE_W - R_FIELD]] + ]); + + firstLine = -15 * charWidth; + leftInd = 10 * charWidth; + test([ + ["", "VeryLongLongLongLongLongLongLongWord\r\n"], + ], [ + [[L_FIELD + firstLine + leftInd, imageX0], [imageX1 + Math.max(0, firstLine), PAGE_W - R_FIELD]] + ]); + + AscTest.SetCompatibilityMode(AscCommon.document_compatibility_mode_Current); + + }); +}); diff --git a/vendor/easysax.js b/vendor/easysax.js index 47a646e0cf..b6dd3888dd 100644 --- a/vendor/easysax.js +++ b/vendor/easysax.js @@ -1215,7 +1215,15 @@ StaxParser.prototype.next = function() { // --------------------------------------------- var w = this.xml.charCodeAt(i + 1); if (w === 33) { // 33 == "!" - this.index = this.xml.indexOf('>', i); + if (i + 3 < this.length && 45 === this.xml.charCodeAt(i + 2) && 45 === this.xml.charCodeAt(i + 3)) { // COMMENT + this.index = this.xml.indexOf('-->', i) + 3; + } else { // CDATA + this.index = this.xml.indexOf(']]>', i) + 3; + } + if (-1 === this.index) { + this.stop = true; + } + this.eventType = EasySAXEvent.Unknown; return this.eventType; } // QUESTION diff --git a/visio/Drawing/HtmlPage.js b/visio/Drawing/HtmlPage.js index 8a3a16b2c8..d4702867af 100644 --- a/visio/Drawing/HtmlPage.js +++ b/visio/Drawing/HtmlPage.js @@ -566,6 +566,10 @@ function CEditorPage(api) { return this.m_oMainParent.AbsolutePosition; }; + this.GetVertRulerLeft = function() + { + return 0; + }; // splitter this.createSplitterElement = function() diff --git a/word/Drawing/DrawingDocument.js b/word/Drawing/DrawingDocument.js index 0ea844374e..fc2e546c9f 100644 --- a/word/Drawing/DrawingDocument.js +++ b/word/Drawing/DrawingDocument.js @@ -4189,6 +4189,29 @@ function CDrawingDocument() return {X: _x, Y: _y, Error: false}; }; + this.GetMainOffset = function(isUseRuler) + { + let result = { + x : 0, + y : 0 + }; + + if (this.m_oWordControl.m_oApi.isMobileVersion) + return result; + + if (this.m_oWordControl.m_oApi.isRtlInterface) + result.x += this.m_oWordControl.ScrollsWidthPx; + + if (true === this.m_oWordControl.m_bIsRuler && isUseRuler !== false) + { + if (!this.m_oWordControl.m_oApi.isRtlInterface) + result.x += (5 * g_dKoef_mm_to_pix); + + result.y += (7 * g_dKoef_mm_to_pix); + } + return result; + } + this.ConvertCoordsFromCursor2 = function (x, y, zoomVal, isRulers) { var _x = x; @@ -4203,11 +4226,9 @@ function CDrawingDocument() 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); - } + let offsets = this.GetMainOffset(); + _xOffset += offsets.x; + _yOffset += offsets.y; _x = x - _xOffset; _y = y - _yOffset; @@ -4340,11 +4361,9 @@ function CDrawingDocument() _x = this.m_oWordControl.X; _y = this.m_oWordControl.Y; - if (this.m_oWordControl.m_bIsRuler) - { - _x += 5 * g_dKoef_mm_to_pix; - _y += 7 * g_dKoef_mm_to_pix; - } + let offsets = this.GetMainOffset(); + _x += offsets.x; + _y += offsets.y; } return this.private_ConvertCoordsToCursor(x, y, pageIndex, true, _x + 0.5, _y + 0.5); }; @@ -4358,11 +4377,10 @@ function CDrawingDocument() { var _x = 0; var _y = 0; - if (true == this.m_oWordControl.m_bIsRuler && (id_ruler_no_use !== false)) - { - _x = 5 * g_dKoef_mm_to_pix; - _y = 7 * g_dKoef_mm_to_pix; - } + + let offsets = this.GetMainOffset(id_ruler_no_use); + _x += offsets.x; + _y += offsets.y; return this.private_ConvertCoordsToCursor(x, y, pageIndex, true, _x, _y, transform); }; diff --git a/word/Drawing/HtmlPage.js b/word/Drawing/HtmlPage.js index 86fb1f0e45..cad99114ad 100644 --- a/word/Drawing/HtmlPage.js +++ b/word/Drawing/HtmlPage.js @@ -277,8 +277,16 @@ function CEditorPage(api) // panel right -------------------------------------------------------------- this.m_oPanelRight = AscCommon.CreateControlContainer("id_panel_right"); - this.m_oPanelRight.Bounds.SetParams(0, 0, 1000, 0, false, true, false, true, scrollWidthMm, -1); - this.m_oPanelRight.Anchor = (g_anchor_top | g_anchor_right | g_anchor_bottom); + if (!this.m_oApi.isRtlInterface) + { + this.m_oPanelRight.Bounds.SetParams(0, 0, 1000, 0, false, true, false, true, scrollWidthMm, -1); + this.m_oPanelRight.Anchor = (g_anchor_top | g_anchor_right | g_anchor_bottom); + } + else + { + this.m_oPanelRight.Bounds.SetParams(0, 0, 0, 0, false, true, false, true, scrollWidthMm, -1); + this.m_oPanelRight.Anchor = (g_anchor_top | g_anchor_left | g_anchor_bottom); + } this.m_oBody.AddControl(this.m_oPanelRight); if (this.m_oApi.isMobileVersion) @@ -328,18 +336,44 @@ function CEditorPage(api) // main content ------------------------------------------------------------- this.m_oMainContent = AscCommon.CreateControlContainer("id_main"); if (!this.m_oApi.isMobileVersion) - this.m_oMainContent.Bounds.SetParams(0, 0, scrollWidthMm, 0, false, true, true, true, -1, -1); + { + if (!this.m_oApi.isRtlInterface) + this.m_oMainContent.Bounds.SetParams(0, 0, scrollWidthMm, 0, false, true, true, true, -1, -1); + else + this.m_oMainContent.Bounds.SetParams(scrollWidthMm, 0, 0, 0, true, true, true, true, -1, -1); + } else + { this.m_oMainContent.Bounds.SetParams(0, 0, 0, 0, false, true, true, true, -1, -1); + } this.m_oMainContent.Anchor = (g_anchor_left | g_anchor_top | g_anchor_right | g_anchor_bottom); this.m_oBody.AddControl(this.m_oMainContent); // --- left --- - this.m_oLeftRuler = AscCommon.CreateControlContainer("id_panel_left"); - this.m_oLeftRuler.Bounds.SetParams(0, 0, 1000, 1000, false, false, false, false, 5, -1); - this.m_oLeftRuler.Anchor = (g_anchor_left | g_anchor_top | g_anchor_bottom); - this.m_oMainContent.AddControl(this.m_oLeftRuler); + if (!this.m_oApi.isRtlInterface) + { + this.m_oLeftRuler = AscCommon.CreateControlContainer("id_panel_left"); + this.m_oLeftRuler.Bounds.SetParams(0, 0, 1000, 1000, false, false, false, false, 5, -1); + this.m_oLeftRuler.Anchor = (g_anchor_left | g_anchor_top | g_anchor_bottom); + this.m_oMainContent.AddControl(this.m_oLeftRuler); + this.m_oMainView = AscCommon.CreateControlContainer("id_main_view"); + this.m_oMainView.Bounds.SetParams(5, 7, 1000, 1000, true, true, false, false, -1, -1); + this.m_oMainView.Anchor = (g_anchor_left | g_anchor_right | g_anchor_top | g_anchor_bottom); + this.m_oMainContent.AddControl(this.m_oMainView); + } + else + { + this.m_oLeftRuler = AscCommon.CreateControlContainer("id_panel_left"); + this.m_oLeftRuler.Bounds.SetParams(0, 0, 1000, 1000, false, false, false, false, 5, -1); + this.m_oLeftRuler.Anchor = (g_anchor_right | g_anchor_top | g_anchor_bottom); + this.m_oMainContent.AddControl(this.m_oLeftRuler); + + this.m_oMainView = AscCommon.CreateControlContainer("id_main_view"); + this.m_oMainView.Bounds.SetParams(0, 7, 5, 1000, false, true, true, false, -1, -1); + this.m_oMainView.Anchor = (g_anchor_left | g_anchor_right | g_anchor_top | g_anchor_bottom); + this.m_oMainContent.AddControl(this.m_oMainView); + } this.m_oLeftRuler_buttonsTabs = AscCommon.CreateControl("id_buttonTabs"); this.m_oLeftRuler_buttonsTabs.Bounds.SetParams(0, 0.8, 1000, 1000, false, true, false, false, -1, 5); this.m_oLeftRuler_buttonsTabs.Anchor = (g_anchor_left | g_anchor_top | g_anchor_right); @@ -352,10 +386,20 @@ function CEditorPage(api) // ------------ // --- top ---- - this.m_oTopRuler = AscCommon.CreateControlContainer("id_panel_top"); - this.m_oTopRuler.Bounds.SetParams(5, 0, 1000, 1000, true, false, false, false, -1, 7); - this.m_oTopRuler.Anchor = (g_anchor_left | g_anchor_top | g_anchor_right); - this.m_oMainContent.AddControl(this.m_oTopRuler); + if (!this.m_oApi.isRtlInterface) + { + this.m_oTopRuler = AscCommon.CreateControlContainer("id_panel_top"); + this.m_oTopRuler.Bounds.SetParams(5, 0, 1000, 1000, true, false, false, false, -1, 7); + this.m_oTopRuler.Anchor = (g_anchor_left | g_anchor_top | g_anchor_right); + this.m_oMainContent.AddControl(this.m_oTopRuler); + } + else + { + this.m_oTopRuler = AscCommon.CreateControlContainer("id_panel_top"); + this.m_oTopRuler.Bounds.SetParams(0, 0, 5, 1000, false, false, true, false, -1, 7); + this.m_oTopRuler.Anchor = (g_anchor_left | g_anchor_top | g_anchor_right); + this.m_oMainContent.AddControl(this.m_oTopRuler); + } this.m_oTopRuler_horRuler = AscCommon.CreateControl("id_hor_ruler"); this.m_oTopRuler_horRuler.Bounds.SetParams(0, 0, 1000, 1000, false, false, false, false, -1, -1); @@ -363,11 +407,6 @@ function CEditorPage(api) this.m_oTopRuler.AddControl(this.m_oTopRuler_horRuler); // ------------ - this.m_oMainView = AscCommon.CreateControlContainer("id_main_view"); - this.m_oMainView.Bounds.SetParams(5, 7, 1000, 1000, true, true, false, false, -1, -1); - this.m_oMainView.Anchor = (g_anchor_left | g_anchor_right | g_anchor_top | g_anchor_bottom); - this.m_oMainContent.AddControl(this.m_oMainView); - // проблема с фокусом fixed-позиционированного элемента внутри (bug 63194) this.m_oMainView.HtmlElement.onscroll = function() { this.scrollTop = 0; @@ -705,7 +744,11 @@ function CEditorPage(api) this.m_oLeftRuler.HtmlElement.style.display = 'block'; this.m_oTopRuler.HtmlElement.style.display = 'block'; - this.m_oMainView.Bounds.L = 5; + if (!this.m_oApi.isRtlInterface) + this.m_oMainView.Bounds.L = 5; + else + this.m_oMainView.Bounds.R = 5; + this.m_oMainView.Bounds.T = 7; } else @@ -713,7 +756,11 @@ function CEditorPage(api) this.m_oLeftRuler.HtmlElement.style.display = 'none'; this.m_oTopRuler.HtmlElement.style.display = 'none'; - this.m_oMainView.Bounds.L = 0; + if (!this.m_oApi.isRtlInterface) + this.m_oMainView.Bounds.L = 0; + else + this.m_oMainView.Bounds.R = 0; + this.m_oMainView.Bounds.T = 0; } }; @@ -1758,11 +1805,9 @@ function CEditorPage(api) var _xOffset = oWordControl.X; var _yOffset = oWordControl.Y; - if (true === oWordControl.m_bIsRuler) - { - _xOffset += (5 * g_dKoef_mm_to_pix); - _yOffset += (7 * g_dKoef_mm_to_pix); - } + let offsets = oWordControl.m_oDrawingDocument.GetMainOffset(); + _xOffset += offsets.x; + _yOffset += offsets.y; if (window['closeDialogs'] != undefined) window['closeDialogs'](); @@ -3794,6 +3839,10 @@ function CEditorPage(api) { return this.m_oMainContent.AbsolutePosition; }; + this.GetVertRulerLeft = function() + { + return this.m_oLeftRuler.AbsolutePosition.L; + }; // mobile --- this.setOffsetTop = function(offset, offsetScrollTop) diff --git a/word/Drawing/Rulers.js b/word/Drawing/Rulers.js index a600fa903d..34c2f93f04 100644 --- a/word/Drawing/Rulers.js +++ b/word/Drawing/Rulers.js @@ -81,6 +81,7 @@ function CHorRulerRepaintChecker() this.BlitIndentRight = 0; this.BlitDefaultTab = 0; this.BlitTabs = null; + this.BlitRtl = false; this.BlitMarginLeftInd = 0; this.BlitMarginRightInd = 0; @@ -173,6 +174,22 @@ RulerCheckSimpleChanges.prototype = } }; +(function(){ + AscWord.RULER_DRAG_TYPE = { + none : 0, + leftMargin : 1, + rightMargin : 2, + leftFirstInd : 3, + leftInd : 4, + firstInd : 5, + rightInd : 6, + tab : 7, + table : 8, + columnSize : 9, + columnPos : 10 + }; +})(); + function CHorRuler() { this.m_oPage = null; // текущая страница. Нужна для размеров и маргинов в режиме RULER_OBJECT_TYPE_PARAGRAPH @@ -194,20 +211,14 @@ function CHorRuler() this.m_dIndentLeft = 10; this.m_dIndentRight = 20; this.m_dIndentLeftFirst = 20; + this.m_bRtl = false; this.m_oCanvas = null; this.m_dZoom = 1; - - this.DragType = 0; // 0 - none - // 1 - left margin, 2 - right margin - // 3 - indent left + indent left first, 4 - indent left // 5 - indent left first, 6 - indent right - // 7 - tabs - // 8 - table - // 9 - column size - // 10 - column move - - this.DragTypeMouseDown = 0; + + this.DragType = AscWord.RULER_DRAG_TYPE.none; + this.DragTypeMouseDown = AscWord.RULER_DRAG_TYPE.none; this.m_dIndentLeft_old = -10000; this.m_dIndentLeftFirst_old = -10000; @@ -457,7 +468,8 @@ function CHorRuler() // промежуток между маргинами var left_margin = 0; var right_margin = 0; - + + let isRtl = false; if (this.CurrentObjectType == RULER_OBJECT_TYPE_PARAGRAPH) { left_margin = (this.m_dMarginLeft * dKoef_mm_to_pix) >> 0; @@ -465,6 +477,7 @@ function CHorRuler() checker.MarginLeft = this.m_dMarginLeft; checker.MarginRight = this.m_dMarginRight; + isRtl = this.m_bRtl; } else if (this.CurrentObjectType == RULER_OBJECT_TYPE_TABLE && null != markup) { @@ -536,256 +549,167 @@ function CHorRuler() context.lineWidth = Math.round(dPR); context.strokeStyle = GlobalSkin.RulerTextColor; context.fillStyle = GlobalSkin.RulerTextColor; - - var mm_1_4 = 10 * dKoef_mm_to_pix / 4; - var inch_1_8 = 25.4 * dKoef_mm_to_pix / 8; - var isDraw1_4 = (mm_1_4 > 7) ? true : false; + + let mm_1_4 = 10 * dKoef_mm_to_pix / 4; + let inch_1_8 = 25.4 * dKoef_mm_to_pix / 8; + let point_1_12 = 25.4 * dKoef_mm_to_pix / 12; var middleVert = (this.m_nTop + this.m_nBottom) / 2; var part1 = 1.5 * Math.round(dPR); var part2 = 2.5 * Math.round(dPR); context.font = Math.round(7 * dPR) + "pt Arial"; - - if (this.Units == c_oAscDocumentUnits.Millimeter) - { - var lCount1 = ((width - left_margin) / mm_1_4) >> 0; - var lCount2 = (left_margin / mm_1_4) >> 0; - - var index = 0; - var num = 0; - for (var i = 1; i < lCount1; i++) - { - var lXPos = ((left_margin + i * mm_1_4) >> 0) + indent; - index++; - - if (index == 4) - index = 0; - - if (0 == index) - { - num++; - // number - var strNum = "" + num; - var lWidthText = context.measureText(strNum).width; - lXPos -= (lWidthText / 2.0); - context.fillText(strNum, lXPos, this.m_nBottom - Math.round(3 * dPR)); - } - else if (1 == index && isDraw1_4) - { - // 1/4 - context.beginPath(); - context.moveTo(lXPos, middleVert - part1); - context.lineTo(lXPos, middleVert + part1); - context.stroke(); - } - else if (2 == index) - { - // 1/2 - context.beginPath(); - context.moveTo(lXPos, middleVert - part2); - context.lineTo(lXPos, middleVert + part2); - context.stroke(); - } - else if (isDraw1_4) - { - // 1/4 - context.beginPath(); - context.moveTo(lXPos, middleVert - part1); - context.lineTo(lXPos, middleVert + part1); - context.stroke(); - } - } - - index = 0; - num = 0; - for (var i = 1; i <= lCount2; i++) - { - var lXPos = ((left_margin - i * mm_1_4) >> 0) + indent; - index++; - - if (index == 4) - index = 0; - - if (0 == index) - { - num++; - // number - var strNum = "" + num; - var lWidthText = context.measureText(strNum).width; - lXPos -= (lWidthText / 2.0); - context.fillText(strNum, lXPos, this.m_nBottom - Math.round(3 * dPR) ); - } - else if (1 == index && isDraw1_4) - { - // 1/4 - context.beginPath(); - context.moveTo(lXPos, middleVert - part1); - context.lineTo(lXPos, middleVert + part1); - context.stroke(); - } - else if (2 == index) - { - // 1/2 - context.beginPath(); - context.moveTo(lXPos, middleVert - part2); - context.lineTo(lXPos, middleVert + part2); - context.stroke(); - } - else if (isDraw1_4) - { - // 1/4 - context.beginPath(); - context.moveTo(lXPos, middleVert - part1); - context.lineTo(lXPos, middleVert + part1); - context.stroke(); - } - } - } - else if (this.Units == c_oAscDocumentUnits.Inch) - { - var lCount1 = ((width - left_margin) / inch_1_8) >> 0; - var lCount2 = (left_margin / inch_1_8) >> 0; - - var index = 0; - var num = 0; - for (var i = 1; i < lCount1; i++) - { - var lXPos = ((left_margin + i * inch_1_8) >> 0) + indent; - index++; - - if (index == 8) - index = 0; - - if (0 == index) - { - num++; - // number - var strNum = "" + num; - var lWidthText = context.measureText(strNum).width; - lXPos -= (lWidthText / 2.0); - context.fillText(strNum, lXPos, this.m_nBottom - Math.round(3 * dPR)); - } - else if (4 == index) - { - // 1/2 - context.beginPath(); - context.moveTo(lXPos, middleVert - part2); - context.lineTo(lXPos, middleVert + part2); - context.stroke(); - } - else if (inch_1_8 > 8) - { - // 1/8 - context.beginPath(); - context.moveTo(lXPos, middleVert - part1); - context.lineTo(lXPos, middleVert + part1); - context.stroke(); - } - } - - index = 0; - num = 0; - for (var i = 1; i <= lCount2; i++) - { - var lXPos = ((left_margin - i * inch_1_8) >> 0) + indent; - index++; - - if (index == 8) - index = 0; - - if (0 == index) - { - num++; - // number - var strNum = "" + num; - var lWidthText = context.measureText(strNum).width; - lXPos -= (lWidthText / 2.0); - context.fillText(strNum, lXPos, this.m_nBottom - Math.round(3 * dPR)); - } - else if (4 == index) - { - // 1/2 - context.beginPath(); - context.moveTo(lXPos, middleVert - part2); - context.lineTo(lXPos, middleVert + part2); - context.stroke(); - } - else if (inch_1_8 > 8) - { - // 1/8 - context.beginPath(); - context.moveTo(lXPos, middleVert - part1); - context.lineTo(lXPos, middleVert + part1); - context.stroke(); - } - } - } - else if (this.Units == c_oAscDocumentUnits.Point) - { - var point_1_12 = 25.4 * dKoef_mm_to_pix / 12; - - var lCount1 = ((width - left_margin) / point_1_12) >> 0; - var lCount2 = (left_margin / point_1_12) >> 0; - - var index = 0; - var num = 0; - for (var i = 1; i < lCount1; i++) - { - var lXPos = ((left_margin + i * point_1_12) >> 0) + indent; - index++; - - if (index == 12) - index = 0; - - if (0 == index || 6 == index) - { - num++; - // number - var strNum = "" + (num * 36); - var lWidthText = context.measureText(strNum).width; - lXPos -= (lWidthText / 2.0); - context.fillText(strNum, lXPos, this.m_nBottom - Math.round(3 * dPR)); - } - else if (point_1_12 > 5) - { - // 1/12 - context.beginPath(); - context.moveTo(lXPos, middleVert - part1); - context.lineTo(lXPos, middleVert + part1); - context.stroke(); - } - } - - index = 0; - num = 0; - for (var i = 1; i <= lCount2; i++) - { - var lXPos = ((left_margin - i * point_1_12) >> 0) + indent; - index++; - - if (index == 12) - index = 0; - - if (0 == index || 6 == index) - { - num++; - // number - var strNum = "" + (num * 36); - var lWidthText = context.measureText(strNum).width; - lXPos -= (lWidthText / 2.0); - context.fillText(strNum, lXPos, this.m_nBottom - Math.round(3 * dPR)); - } - else if (point_1_12 > 5) - { - // 1/12 - context.beginPath(); - context.moveTo(lXPos, middleVert - part1); - context.lineTo(lXPos, middleVert + part1); - context.stroke(); - } - } - } + + let _bottom = this.m_nBottom; + function drawLayoutMM(x, step, count) + { + let isDraw1_4 = Math.abs(step) > 7; + let index = 0; + let num = 0; + for (let i = 1; i <= count; ++i) + { + let lXPos = ((x + i * step) >> 0) + indent; + index++; + + if (index === 4) + index = 0; + + if (0 === index) + { + num++; + // number + let strNum = "" + num; + let lWidthText = context.measureText(strNum).width; + lXPos -= (lWidthText / 2.0); + context.fillText(strNum, lXPos, _bottom - Math.round(3 * dPR)); + } + else if (1 === index && isDraw1_4) + { + // 1/4 + context.beginPath(); + context.moveTo(lXPos, middleVert - part1); + context.lineTo(lXPos, middleVert + part1); + context.stroke(); + } + else if (2 === index) + { + // 1/2 + context.beginPath(); + context.moveTo(lXPos, middleVert - part2); + context.lineTo(lXPos, middleVert + part2); + context.stroke(); + } + else if (isDraw1_4) + { + // 1/4 + context.beginPath(); + context.moveTo(lXPos, middleVert - part1); + context.lineTo(lXPos, middleVert + part1); + context.stroke(); + } + } + } + function drawLayoutInch(x, step, count) + { + let isDraw1_8 = Math.abs(step) > 8; + let index = 0; + let num = 0; + for (let i = 1; i <= count; ++i) + { + let lXPos = ((x + i * step) >> 0) + indent; + index++; + + if (index === 8) + index = 0; + + if (0 === index) + { + num++; + // number + let strNum = "" + num; + let lWidthText = context.measureText(strNum).width; + lXPos -= (lWidthText / 2.0); + context.fillText(strNum, lXPos, _bottom - Math.round(3 * dPR)); + } + else if (4 === index) + { + // 1/2 + context.beginPath(); + context.moveTo(lXPos, middleVert - part2); + context.lineTo(lXPos, middleVert + part2); + context.stroke(); + } + else if (isDraw1_8) + { + // 1/8 + context.beginPath(); + context.moveTo(lXPos, middleVert - part1); + context.lineTo(lXPos, middleVert + part1); + context.stroke(); + } + } + } + function drawLayoutPt(x, step, count) + { + let isDraw1_12 = Math.abs(step) > 5; + let index = 0; + let num = 0; + for (let i = 1; i <= count; ++i) + { + let lXPos = ((x + i * step) >> 0) + indent; + index++; + + if (index === 12) + index = 0; + + if (0 === index || 6 === index) + { + num++; + // number + let strNum = "" + (num * 36); + let lWidthText = context.measureText(strNum).width; + lXPos -= (lWidthText / 2.0); + context.fillText(strNum, lXPos, _bottom - Math.round(3 * dPR)); + } + else if (isDraw1_12) + { + // 1/12 + context.beginPath(); + context.moveTo(lXPos, middleVert - part1); + context.lineTo(lXPos, middleVert + part1); + context.stroke(); + } + } + } + + let step = point_1_12; + let drawFunc = null; + + if (this.Units === c_oAscDocumentUnits.Millimeter) + { + step = mm_1_4; + drawFunc = drawLayoutMM; + } + else if (this.Units === c_oAscDocumentUnits.Inch) + { + step = inch_1_8; + drawFunc = drawLayoutInch; + } + else if (this.Units === c_oAscDocumentUnits.Point) + { + step = point_1_12; + drawFunc = drawLayoutPt; + } + + if (drawFunc) + { + let zeroX = isRtl ? right_margin : left_margin; + let rCount = isRtl ? ((width - right_margin) / step) >> 0 : (((width - left_margin) / step) >> 0) - 1; + let lCount = isRtl ? ((right_margin / step) >> 0) - 1 : left_margin / step >> 0; + + drawFunc(zeroX, step, rCount); + drawFunc(zeroX, -step, lCount); + } if (null != markup && this.CurrentObjectType == RULER_OBJECT_TYPE_TABLE) { @@ -1012,7 +936,10 @@ function CHorRuler() var hor_ruler = word_control.m_oTopRuler_horRuler; var dKoefPxToMM = 100 * g_dKoef_pix_to_mm / word_control.m_nZoomValue; - var _x = global_mouseEvent.X - 5 * g_dKoef_mm_to_pix - left - word_control.X - word_control.GetMainContentBounds().L * g_dKoef_mm_to_pix; + var _x = global_mouseEvent.X - left - word_control.X - word_control.GetMainContentBounds().L * g_dKoef_mm_to_pix; + if (!word_control.m_oApi.isRtlInterface) + _x -= 5 * g_dKoef_mm_to_pix; + _x *= dKoefPxToMM; var _y = (global_mouseEvent.Y - word_control.Y) * g_dKoef_pix_to_mm; @@ -1034,7 +961,7 @@ function CHorRuler() switch (this.DragType) { - case 0: + case AscWord.RULER_DRAG_TYPE.none: { var position = this.CheckMouseType(_x, _y); if ((1 == position) || (2 == position) || (8 == position) || (9 == position) || (10 == position)) @@ -1044,7 +971,7 @@ function CHorRuler() break; } - case 1: + case AscWord.RULER_DRAG_TYPE.leftMargin: { var newVal = RulerCorrectPosition(this, _x, _margin_left); @@ -1070,7 +997,7 @@ function CHorRuler() word_control.m_oDrawingDocument.SetCursorType("w-resize"); break; } - case 2: + case AscWord.RULER_DRAG_TYPE.rightMargin: { var newVal = RulerCorrectPosition(this, _x, _margin_left); @@ -1098,138 +1025,203 @@ function CHorRuler() word_control.m_oDrawingDocument.SetCursorType("w-resize"); break; } - case 3: - { - var newVal = RulerCorrectPosition(this, _x, _margin_left); - - var min = 0; - if (this.m_dIndentLeftFirst < this.m_dIndentLeft) - min = this.m_dIndentLeft - this.m_dIndentLeftFirst; - - if (newVal < min) - newVal = min; - - if (_presentations) - { - min = _margin_left; - if (this.m_dIndentLeftFirst < this.m_dIndentLeft) - min += (this.m_dIndentLeft - this.m_dIndentLeftFirst); - if (newVal < min) - newVal = min; - } - - var max = _margin_right; - if (0 < this.m_dIndentRight) - max = _margin_right - this.m_dIndentRight; - if (this.m_dIndentLeftFirst > this.m_dIndentLeft) - { - max = max + (this.m_dIndentLeft - this.m_dIndentLeftFirst); - } - - if (newVal > (max - 20)) - newVal = Math.max(max - 20, (this.m_dIndentLeft_old + _margin_left)); - - var newIndent = newVal - _margin_left; - this.m_dIndentLeftFirst = (this.m_dIndentLeftFirst - this.m_dIndentLeft) + newIndent; - this.m_dIndentLeft = newIndent; - word_control.UpdateHorRulerBack(); - - var pos = left + (_margin_left + this.m_dIndentLeft) * dKoef_mm_to_pix; - word_control.m_oOverlayApi.VertLine(pos); - - break; - } - case 4: - { - var newVal = RulerCorrectPosition(this, _x, _margin_left); - - if (newVal < 0) - newVal = 0; - - var max = _margin_right - 20; - if (0 < this.m_dIndentRight) - max -= this.m_dIndentRight; - - if (_presentations) - { - if (newVal < _margin_left) - newVal = _margin_left; - } - - if (newVal > max) - newVal = Math.max(max, _margin_left + this.m_dIndentLeft_old); - - this.m_dIndentLeft = newVal - _margin_left; - word_control.UpdateHorRulerBack(); - - var pos = left + (_margin_left + this.m_dIndentLeft) * dKoef_mm_to_pix; - word_control.m_oOverlayApi.VertLine(pos); - - break; - } - case 5: - { - var newVal = RulerCorrectPosition(this, _x, _margin_left); - - if (newVal < 0) - newVal = 0; - - var max = _margin_right - 20; - if (0 < this.m_dIndentRight) - max -= this.m_dIndentRight; - - if (_presentations) - { - if (newVal < _margin_left) - newVal = _margin_left; - } - - if (newVal > max) - newVal = Math.max(max, _margin_left + this.m_dIndentLeftFirst_old); - - this.m_dIndentLeftFirst = newVal - _margin_left; - word_control.UpdateHorRulerBack(); - - var pos = left + (_margin_left + this.m_dIndentLeftFirst) * dKoef_mm_to_pix; - word_control.m_oOverlayApi.VertLine(pos); - - break; - } - case 6: - { - var newVal = RulerCorrectPosition(this, _x, _margin_left); - - if (newVal > (this.m_oPage.width_mm)) - newVal = this.m_oPage.width_mm; - - var min = _margin_left; - if ((_margin_left + this.m_dIndentLeft) > min) - min = _margin_left + this.m_dIndentLeft; - if ((_margin_left + this.m_dIndentLeftFirst) > min) - min = _margin_left + this.m_dIndentLeftFirst; - - min += 20; - - if (newVal < min) - newVal = Math.min(min, _margin_right - this.m_dIndentRight_old); - - if (_presentations) - { - if (newVal > _margin_right) - newVal = _margin_right; - } - this.m_dIndentRight = _margin_right - newVal; - word_control.UpdateHorRulerBack(); - - var pos = left + (_margin_right - this.m_dIndentRight) * dKoef_mm_to_pix; - word_control.m_oOverlayApi.VertLine(pos); - - // if (!this.SimpleChanges.IsSimple) - // this.SetPrProperties(true); - - break; - } - case 7: + case AscWord.RULER_DRAG_TYPE.leftFirstInd: + { + let newVal = RulerCorrectPosition(this, _x, this.m_bRtl ? _margin_right : _margin_left); + + if (this.m_bRtl) + { + let max = this.m_oPage.width_mm; + if (_presentations) + max = _margin_right; + else if (this.m_dIndentLeftFirst < this.m_dIndentLeft) + max = this.m_oPage.width_mm - (this.m_dIndentLeft - this.m_dIndentLeftFirst); + + if (newVal > max) + newVal = max; + + let min = _margin_left; + if (this.m_dIndentRight > 0) + min = _margin_left + this.m_dIndentRight; + + if (this.m_dIndentLeftFirst > this.m_dIndentLeft) + min += this.m_dIndentLeftFirst - this.m_dIndentLeft; + + if (newVal < min + 20) + newVal = Math.min(min + 20, _margin_right - this.m_dIndentLeft_old); + + let newIndent = _margin_right - newVal; + this.m_dIndentLeftFirst = (this.m_dIndentLeftFirst - this.m_dIndentLeft) + newIndent; + this.m_dIndentLeft = newIndent; + } + else + { + let min = 0; + + if (_presentations) + min = _margin_left; + else if (this.m_dIndentLeftFirst < this.m_dIndentLeft) + min = this.m_dIndentLeft - this.m_dIndentLeftFirst; + + if (newVal < min) + newVal = min; + + let max = _margin_right; + if (0 < this.m_dIndentRight) + max = _margin_right - this.m_dIndentRight; + + if (this.m_dIndentLeftFirst > this.m_dIndentLeft) + max = max + (this.m_dIndentLeft - this.m_dIndentLeftFirst); + + if (newVal > (max - 20)) + newVal = Math.max(max - 20, (this.m_dIndentLeft_old + _margin_left)); + + let newIndent = newVal - _margin_left; + this.m_dIndentLeftFirst = (this.m_dIndentLeftFirst - this.m_dIndentLeft) + newIndent; + this.m_dIndentLeft = newIndent; + } + let pos = left + newVal * dKoef_mm_to_pix; + word_control.UpdateHorRulerBack(); + word_control.m_oOverlayApi.VertLine(pos); + break; + } + case AscWord.RULER_DRAG_TYPE.leftInd: + { + let newVal = RulerCorrectPosition(this, _x, this.m_bRtl ? _margin_right : _margin_left); + if (newVal < 0) + newVal = 0; + + if (this.m_bRtl) + { + if (newVal > (this.m_oPage.width_mm)) + newVal = this.m_oPage.width_mm; + + let min = Math.max(_margin_left, _margin_left + this.m_dIndentRight) + 20; + if (_presentations) + { + if (newVal > _margin_right) + newVal = _margin_right; + } + + if (newVal < min) + newVal = Math.min(min, _margin_right - this.m_dIndentLeft_old); + + this.m_dIndentLeft = _margin_right - newVal; + } + else + { + let max = _margin_right - 20; + if (0 < this.m_dIndentRight) + max -= this.m_dIndentRight; + + if (_presentations) + { + if (newVal < _margin_left) + newVal = _margin_left; + } + + if (newVal > max) + newVal = Math.max(max, _margin_left + this.m_dIndentLeft_old); + + this.m_dIndentLeft = newVal - _margin_left; + } + let pos = left + newVal * dKoef_mm_to_pix; + word_control.UpdateHorRulerBack(); + word_control.m_oOverlayApi.VertLine(pos); + break; + } + case AscWord.RULER_DRAG_TYPE.firstInd: + { + let newVal = RulerCorrectPosition(this, _x, this.m_bRtl ? _margin_right : _margin_left); + + if (newVal < 0) + newVal = 0; + + if (this.m_bRtl) + { + if (newVal > (this.m_oPage.width_mm)) + newVal = this.m_oPage.width_mm; + + let min = 20 + Math.max(_margin_left, _margin_left + this.m_dIndentRight); + if (_presentations) + { + if (newVal > _margin_right) + newVal = _margin_right; + } + + if (newVal < min) + newVal = Math.min(min, _margin_right - this.m_dIndentLeftFirst_old); + + this.m_dIndentLeftFirst = _margin_right - newVal; + } + else + { + let max = _margin_right - 20; + if (0 < this.m_dIndentRight) + max -= this.m_dIndentRight; + + if (_presentations) + { + if (newVal < _margin_left) + newVal = _margin_left; + } + + if (newVal > max) + newVal = Math.max(max, _margin_left + this.m_dIndentLeftFirst_old); + + this.m_dIndentLeftFirst = newVal - _margin_left; + } + let pos = left + newVal * dKoef_mm_to_pix; + word_control.UpdateHorRulerBack(); + word_control.m_oOverlayApi.VertLine(pos); + break; + } + case AscWord.RULER_DRAG_TYPE.rightInd: + { + let newVal = RulerCorrectPosition(this, _x, this.m_bRtl ? _margin_right : _margin_left); + + if (newVal > (this.m_oPage.width_mm)) + newVal = this.m_oPage.width_mm; + if (newVal < 0) + newVal = 0; + + if (this.m_bRtl) + { + let max = -20 + Math.min(_margin_right, _margin_right - this.m_dIndentLeft, _margin_right - this.m_dIndentLeftFirst); + if (newVal > max) + newVal = Math.max(max, _margin_left + this.m_dIndentRight_old); + + if (_presentations && newVal < _margin_left) + newVal = _margin_left; + + this.m_dIndentRight = newVal - _margin_left; + } + else + { + let min = _margin_left; + if ((_margin_left + this.m_dIndentLeft) > min) + min = _margin_left + this.m_dIndentLeft; + if ((_margin_left + this.m_dIndentLeftFirst) > min) + min = _margin_left + this.m_dIndentLeftFirst; + + min += 20; + + if (newVal < min) + newVal = Math.min(min, _margin_right - this.m_dIndentRight_old); + + if (_presentations) + { + if (newVal > _margin_right) + newVal = _margin_right; + } + this.m_dIndentRight = _margin_right - newVal; + } + let pos = left + newVal * dKoef_mm_to_pix; + word_control.UpdateHorRulerBack(); + word_control.m_oOverlayApi.VertLine(pos); + break; + } + case AscWord.RULER_DRAG_TYPE.tab: { var newVal = RulerCorrectPosition(this, _x, _margin_left); @@ -1253,7 +1245,7 @@ function CHorRuler() word_control.m_oOverlayApi.VertLine(pos); break; } - case 8: + case AscWord.RULER_DRAG_TYPE.table: { var newVal = RulerCorrectPosition(this, _x, this.TableMarginLeftTrackStart); @@ -1298,7 +1290,7 @@ function CHorRuler() word_control.m_oOverlayApi.VertLine(pos); break; } - case 9: + case AscWord.RULER_DRAG_TYPE.columnSize: { var newVal = RulerCorrectPosition(this, _x, this.TableMarginLeftTrackStart); @@ -1447,7 +1439,7 @@ function CHorRuler() word_control.m_oOverlayApi.VertLine(pos); break; } - case 10: + case AscWord.RULER_DRAG_TYPE.columnPos: { var newVal = RulerCorrectPosition(this, _x, this.TableMarginLeftTrackStart); @@ -1525,13 +1517,13 @@ function CHorRuler() { if (true === isMouseDown) this.m_lCurrentTab = i; - return 7; + return AscWord.RULER_DRAG_TYPE.tab; } } } // left indent - var dCenterX = _margin_left + this.m_dIndentLeft; + var dCenterX = this.m_bRtl ? _margin_right - this.m_dIndentLeft : _margin_left + this.m_dIndentLeft; var var1 = dCenterX - 1; var var2 = 1.4; @@ -1541,13 +1533,13 @@ function CHorRuler() if ((x >= var1) && (x <= var4)) { if ((y >= _bottom) && (y < (_bottom + var2))) - return 3; + return AscWord.RULER_DRAG_TYPE.leftFirstInd; else if ((y > (_bottom - var3)) && (y < _bottom)) - return 4; + return AscWord.RULER_DRAG_TYPE.leftInd; } // right indent - dCenterX = _margin_right - this.m_dIndentRight; + dCenterX = this.m_bRtl ? _margin_left + this.m_dIndentRight : _margin_right - this.m_dIndentRight; var1 = dCenterX - 1; var4 = dCenterX + 1; @@ -1555,11 +1547,11 @@ function CHorRuler() if ((x >= var1) && (x <= var4)) { if ((y > (_bottom - var3)) && (y < _bottom)) - return 6; + return AscWord.RULER_DRAG_TYPE.rightInd; } // first line indent - dCenterX = _margin_left + this.m_dIndentLeftFirst; + dCenterX = this.m_bRtl ? _margin_right - this.m_dIndentLeftFirst : _margin_left + this.m_dIndentLeftFirst; var1 = dCenterX - 1; var4 = dCenterX + 1; @@ -1571,9 +1563,9 @@ function CHorRuler() if (0 == this.m_dIndentLeftFirst && 0 == this.m_dIndentLeft && this.CurrentObjectType == RULER_OBJECT_TYPE_PARAGRAPH && this.IsCanMoveMargins) { if (y > (_top + 1)) - return 1; + return this.m_bRtl ? AscWord.RULER_DRAG_TYPE.rightMargin : AscWord.RULER_DRAG_TYPE.leftMargin; } - return 5; + return AscWord.RULER_DRAG_TYPE.firstInd; } } } @@ -1589,19 +1581,19 @@ function CHorRuler() // внутри линейки if (Math.abs(x - this.m_dMarginLeft) < 1) { - return 1; + return AscWord.RULER_DRAG_TYPE.leftMargin; } else if (Math.abs(x - this.m_dMarginRight) < 1) { - return 2; + return AscWord.RULER_DRAG_TYPE.rightMargin; } if (isNegative) { if (x < this.m_dMarginLeft) - return -1; + return -AscWord.RULER_DRAG_TYPE.leftMargin; if (x > this.m_dMarginRight) - return -2; + return -AscWord.RULER_DRAG_TYPE.rightMargin; } } } @@ -1619,7 +1611,7 @@ function CHorRuler() if (Math.abs(x - pos) < 1) { this.DragTablePos = i; - return 8; + return AscWord.RULER_DRAG_TYPE.table; } if (i == _count) { @@ -1660,7 +1652,7 @@ function CHorRuler() if (Math.abs(x - _x) < 1) { this.DragTablePos = _index; - return 9; + return AscWord.RULER_DRAG_TYPE.columnSize; } } else @@ -1668,7 +1660,7 @@ function CHorRuler() if (x < _x + 1 && x > _x - 2) { this.DragTablePos = _index; - return 9; + return AscWord.RULER_DRAG_TYPE.columnSize; } } @@ -1681,7 +1673,7 @@ function CHorRuler() if (Math.abs(x - _x) < 1) { this.DragTablePos = _index; - return 9; + return AscWord.RULER_DRAG_TYPE.columnSize; } } else @@ -1689,7 +1681,7 @@ function CHorRuler() if (x < _x + 2 && x > _x - 1) { this.DragTablePos = _index; - return 9; + return AscWord.RULER_DRAG_TYPE.columnSize; } if (x > _x && x < (_x + markup.Space)) @@ -1712,7 +1704,7 @@ function CHorRuler() if (Math.abs(x - _x) < 1) { this.DragTablePos = _index; - return 9; + return AscWord.RULER_DRAG_TYPE.columnSize; } } else @@ -1720,7 +1712,7 @@ function CHorRuler() if (x < _x + 1 && x > _x - 2) { this.DragTablePos = _index; - return 9; + return AscWord.RULER_DRAG_TYPE.columnSize; } } @@ -1733,7 +1725,7 @@ function CHorRuler() if (Math.abs(x - _x) < 1) { this.DragTablePos = _index; - return 9; + return AscWord.RULER_DRAG_TYPE.columnSize; } } else @@ -1741,7 +1733,7 @@ function CHorRuler() if (x < _x + 2 && x > _x - 1) { this.DragTablePos = _index; - return 9; + return AscWord.RULER_DRAG_TYPE.columnSize; } } @@ -1750,7 +1742,7 @@ function CHorRuler() if (Math.abs(x - (_x + markup.Cols[i].Space / 2)) < 1) { this.DragTablePos = i; - return 10; + return AscWord.RULER_DRAG_TYPE.columnPos; } if (x > _x && x < (_x + markup.Cols[i].Space)) @@ -1770,23 +1762,23 @@ function CHorRuler() if (isNegative) { if (isColumnsInside) - return -9; + return -AscWord.RULER_DRAG_TYPE.columnSize; // если вникуда - то ВСЕГДА margins - return -1; + return -AscWord.RULER_DRAG_TYPE.leftMargin; if (isColumnsInside2) return 0; if ((y >= _top && y <= _bottom) && !isTableInside) { if (x < _margin_left) - return -1; + return -AscWord.RULER_DRAG_TYPE.leftMargin; if (x > _margin_right) - return -2; + return -AscWord.RULER_DRAG_TYPE.rightMargin; } } - return 0; + return AscWord.RULER_DRAG_TYPE.none; } this.OnMouseDown = function(left, top, e) @@ -1811,7 +1803,10 @@ function CHorRuler() var dKoefPxToMM = 100 * g_dKoef_pix_to_mm / word_control.m_nZoomValue; var dKoef_mm_to_pix = g_dKoef_mm_to_pix * this.m_dZoom; - var _x = global_mouseEvent.X - 5 * g_dKoef_mm_to_pix - left - word_control.X - word_control.GetMainContentBounds().L * g_dKoef_mm_to_pix; + var _x = global_mouseEvent.X - left - word_control.X - word_control.GetMainContentBounds().L * g_dKoef_mm_to_pix; + if (!word_control.m_oApi.isRtlInterface) + _x -= 5 * g_dKoef_mm_to_pix; + _x *= dKoefPxToMM; var _y = (global_mouseEvent.Y - word_control.Y) * g_dKoef_pix_to_mm; @@ -1819,7 +1814,7 @@ function CHorRuler() if (this.DragType < 0) { this.DragTypeMouseDown = -this.DragType; - this.DragType = 0; + this.DragType = AscWord.RULER_DRAG_TYPE.none; } else { @@ -1829,46 +1824,44 @@ function CHorRuler() if (global_mouseEvent.ClickCount > 1) { var eventType = ""; - switch (this.DragTypeMouseDown) - { - case 1: - case 2: - { + switch (this.DragTypeMouseDown) + { + case AscWord.RULER_DRAG_TYPE.leftMargin: + case AscWord.RULER_DRAG_TYPE.rightMargin: + { eventType = "margins"; - break; - } - case 3: - case 4: - case 5: - case 6: - { + break; + } + case AscWord.RULER_DRAG_TYPE.leftFirstInd: + case AscWord.RULER_DRAG_TYPE.leftInd: + case AscWord.RULER_DRAG_TYPE.firstInd: + case AscWord.RULER_DRAG_TYPE.rightInd: + { eventType = "indents"; - break; - } - case 7: - { + break; + } + case AscWord.RULER_DRAG_TYPE.tab: + { eventType = "tabs"; - break; - } - case 8: - { + break; + } + case AscWord.RULER_DRAG_TYPE.table: + { eventType = "tables"; - break; - } - case 9: - case 10: - { + break; + } + case AscWord.RULER_DRAG_TYPE.columnSize: + case AscWord.RULER_DRAG_TYPE.columnPos: + { eventType = "columns"; - break; - } - default: - break; - } + break; + } + } if (eventType != "") { word_control.m_oApi.sendEvent("asc_onRulerDblClick", eventType); - this.DragType = 0; + this.DragType = AscWord.RULER_DRAG_TYPE.none; this.OnMouseUp(left, top, e); return; } @@ -1886,59 +1879,63 @@ function CHorRuler() switch (this.DragType) { - case 1: + case AscWord.RULER_DRAG_TYPE.leftMargin: { var pos = left + _margin_left * dKoef_mm_to_pix; word_control.m_oOverlayApi.VertLine(pos); break; } - case 2: + case AscWord.RULER_DRAG_TYPE.rightMargin: { var pos = left + _margin_right * dKoef_mm_to_pix; word_control.m_oOverlayApi.VertLine(pos); break; } - case 3: - { - var pos = left + (_margin_left + this.m_dIndentLeft) * dKoef_mm_to_pix; - word_control.m_oOverlayApi.VertLine(pos); - - this.m_dIndentLeft_old = this.m_dIndentLeft; - this.m_dIndentLeftFirst_old = this.m_dIndentLeftFirst; - break; - } - case 4: - { - var pos = left + (_margin_left + this.m_dIndentLeft) * dKoef_mm_to_pix; - word_control.m_oOverlayApi.VertLine(pos); - - this.m_dIndentLeft_old = this.m_dIndentLeft; - break; - } - case 5: - { - var pos = left + (_margin_left + this.m_dIndentLeftFirst) * dKoef_mm_to_pix; - word_control.m_oOverlayApi.VertLine(pos); - - this.m_dIndentLeftFirst_old = this.m_dIndentLeftFirst; - break; - } - case 6: - { - var pos = left + (_margin_right - this.m_dIndentRight) * dKoef_mm_to_pix; - word_control.m_oOverlayApi.VertLine(pos); - - this.m_dIndentRight_old = this.m_dIndentRight; - break; - } - case 7: + case AscWord.RULER_DRAG_TYPE.leftFirstInd: + { + let offset = this.m_bRtl ? (_margin_right - this.m_dIndentLeft) : (_margin_left + this.m_dIndentLeft); + let pos = left + offset * dKoef_mm_to_pix; + word_control.m_oOverlayApi.VertLine(pos); + + this.m_dIndentLeft_old = this.m_dIndentLeft; + this.m_dIndentLeftFirst_old = this.m_dIndentLeftFirst; + break; + } + case AscWord.RULER_DRAG_TYPE.leftInd: + { + let offset = this.m_bRtl ? (_margin_right - this.m_dIndentLeft) : (_margin_left + this.m_dIndentLeft); + let pos = left + offset * dKoef_mm_to_pix; + word_control.m_oOverlayApi.VertLine(pos); + + this.m_dIndentLeft_old = this.m_dIndentLeft; + break; + } + case AscWord.RULER_DRAG_TYPE.firstInd: + { + let offset = this.m_bRtl ? (_margin_right - this.m_dIndentLeftFirst) : (_margin_left + this.m_dIndentLeftFirst); + let pos = left + offset * dKoef_mm_to_pix; + word_control.m_oOverlayApi.VertLine(pos); + + this.m_dIndentLeftFirst_old = this.m_dIndentLeftFirst; + break; + } + case AscWord.RULER_DRAG_TYPE.rightInd: + { + let offset = this.m_bRtl ? (_margin_left + this.m_dIndentRight) : (_margin_right - this.m_dIndentRight); + let pos = left + offset * dKoef_mm_to_pix; + word_control.m_oOverlayApi.VertLine(pos); + + this.m_dIndentRight_old = this.m_dIndentRight; + break; + } + case AscWord.RULER_DRAG_TYPE.tab: { var pos = left + (_margin_left + this.m_arrTabs[this.m_lCurrentTab].pos) * dKoef_mm_to_pix; this.m_dCurrentTabNewPosition = this.m_arrTabs[this.m_lCurrentTab].pos; word_control.m_oOverlayApi.VertLine(pos); break; } - case 8: + case AscWord.RULER_DRAG_TYPE.table: { var markup = this.m_oTableMarkup; var pos = markup.X; @@ -1953,7 +1950,7 @@ function CHorRuler() this.TableMarginLeftTrackStart = this.TableMarginLeft; break; } - case 9: + case AscWord.RULER_DRAG_TYPE.columnSize: { var markup = this.m_oColumnMarkup; var pos = 0; @@ -1995,7 +1992,7 @@ function CHorRuler() this.TableMarginLeftTrackStart = markup.X; break; } - case 10: + case AscWord.RULER_DRAG_TYPE.columnPos: { var markup = this.m_oColumnMarkup; var pos = markup.X; @@ -2023,7 +2020,7 @@ function CHorRuler() } } - if (0 == this.DragType) + if (AscWord.RULER_DRAG_TYPE.none === this.DragType) { // посмотрим - может это добавляется таб var _top = 1.8; @@ -2055,7 +2052,7 @@ function CHorRuler() } */ - this.DragType = 7; + this.DragType = AscWord.RULER_DRAG_TYPE.tab; this.m_dCurrentTabNewPosition = _new_tab_pos; var pos = left + (_margin_left + _new_tab_pos) * dKoef_mm_to_pix; @@ -2075,7 +2072,7 @@ function CHorRuler() this.m_dIndentLeftFirst_old = -10000; this.m_dIndentRight_old = -10000; - if (7 != this.DragType) + if (AscWord.RULER_DRAG_TYPE.tab !== this.DragType) { word_control.UpdateHorRuler(); //word_control.m_oOverlayApi.UnShow(); @@ -2091,17 +2088,17 @@ function CHorRuler() switch (this.DragType) { - case 1: - case 2: + case AscWord.RULER_DRAG_TYPE.leftMargin: + case AscWord.RULER_DRAG_TYPE.rightMargin: { if (!this.SimpleChanges.IsSimple) this.SetMarginProperties(); break; } - case 3: - case 4: - case 5: - case 6: + case AscWord.RULER_DRAG_TYPE.leftFirstInd: + case AscWord.RULER_DRAG_TYPE.leftInd: + case AscWord.RULER_DRAG_TYPE.firstInd: + case AscWord.RULER_DRAG_TYPE.rightInd: { if (!this.SimpleChanges.IsSimple) this.SetPrProperties(); @@ -2109,7 +2106,7 @@ function CHorRuler() word_control.OnUpdateOverlay(); break; } - case 7: + case AscWord.RULER_DRAG_TYPE.tab: { // смотрим, сохраняем ли таб var _y = (global_mouseEvent.Y - word_control.Y) * g_dKoef_pix_to_mm; @@ -2130,15 +2127,15 @@ function CHorRuler() this.SetTabsProperties(); break; } - case 8: + case AscWord.RULER_DRAG_TYPE.table: { if (!this.SimpleChanges.IsSimple) this.SetTableProperties(); this.DragTablePos = -1; break; } - case 9: - case 10: + case AscWord.RULER_DRAG_TYPE.columnSize: + case AscWord.RULER_DRAG_TYPE.columnPos: { if (!this.SimpleChanges.IsSimple) this.SetColumnsProperties(); @@ -2147,7 +2144,7 @@ function CHorRuler() } } - if (7 == this.DragType) + if (AscWord.RULER_DRAG_TYPE.tab === this.DragType) { word_control.UpdateHorRuler(); //word_control.m_oOverlayApi.UnShow(); @@ -2170,7 +2167,7 @@ function CHorRuler() this.m_dIndentLeftFirst_old = -10000; this.m_dIndentRight_old = -10000; - if (7 != this.DragType) + if (AscWord.RULER_DRAG_TYPE.tab !== this.DragType) { word_control.UpdateHorRuler(); //word_control.m_oOverlayApi.UnShow(); @@ -2186,23 +2183,23 @@ function CHorRuler() switch (this.DragType) { - case 1: - case 2: + case AscWord.RULER_DRAG_TYPE.leftMargin: + case AscWord.RULER_DRAG_TYPE.rightMargin: { if (!this.SimpleChanges.IsSimple) this.SetMarginProperties(); break; } - case 3: - case 4: - case 5: - case 6: + case AscWord.RULER_DRAG_TYPE.leftFirstInd: + case AscWord.RULER_DRAG_TYPE.leftInd: + case AscWord.RULER_DRAG_TYPE.firstInd: + case AscWord.RULER_DRAG_TYPE.rightInd: { if (!this.SimpleChanges.IsSimple) this.SetPrProperties(); break; } - case 7: + case AscWord.RULER_DRAG_TYPE.tab: { // смотрим, сохраняем ли таб var _y = (global_mouseEvent.Y - word_control.Y) * g_dKoef_pix_to_mm; @@ -2222,15 +2219,15 @@ function CHorRuler() this.SetTabsProperties(); break; } - case 8: + case AscWord.RULER_DRAG_TYPE.table: { if (!this.SimpleChanges.IsSimple) this.SetTableProperties(); this.DragTablePos = -1; break; } - case 9: - case 10: + case AscWord.RULER_DRAG_TYPE.columnSize: + case AscWord.RULER_DRAG_TYPE.columnPos: { if (!this.SimpleChanges.IsSimple) this.SetColumnsProperties(); @@ -2239,7 +2236,7 @@ function CHorRuler() } } - if (7 == this.DragType) + if (AscWord.RULER_DRAG_TYPE.tab === this.DragType) { word_control.UpdateHorRuler(); //word_control.m_oOverlayApi.UnShow(); @@ -2359,9 +2356,13 @@ function CHorRuler() var checker = this.RepaintChecker; if (!checker.BlitAttack && left == checker.BlitLeft && !this.m_bIsMouseDown) { - if (checker.BlitIndentLeft == this.m_dIndentLeft && checker.BlitIndentLeftFirst == this.m_dIndentLeftFirst - && checker.BlitIndentRight == this.m_dIndentRight && checker.BlitDefaultTab == this.m_dDefaultTab && - _margin_left == checker.BlitMarginLeftInd && _margin_right == checker.BlitMarginRightInd) + if (checker.BlitIndentLeft == this.m_dIndentLeft + && checker.BlitIndentLeftFirst == this.m_dIndentLeftFirst + && checker.BlitIndentRight == this.m_dIndentRight + && checker.BlitRtl === this.m_bRtl + && checker.BlitDefaultTab == this.m_dDefaultTab + && _margin_left == checker.BlitMarginLeftInd + && _margin_right == checker.BlitMarginRightInd) { // осталось проверить только табы кастомные var _count1 = 0; @@ -2394,6 +2395,7 @@ function CHorRuler() if (null != this.m_oCanvas) { checker.BlitLeft = left; + checker.BlitRtl = this.m_bRtl; checker.BlitIndentLeft = this.m_dIndentLeft; checker.BlitIndentLeftFirst = this.m_dIndentLeftFirst; checker.BlitIndentRight = this.m_dIndentRight; @@ -2420,10 +2422,8 @@ function CHorRuler() return; var dKoef_mm_to_pix = g_dKoef_mm_to_pix * this.m_dZoom * dPR; var dCenterX = 0; - var var1 = 0; var var2 = 0; var var3 = 0; - var var4 = 0; var _positon_y = this.m_nBottom - 5 * dPR; @@ -2435,77 +2435,96 @@ function CHorRuler() checker.BlitMarginRightInd = _margin_right; var _1mm_to_pix = g_dKoef_mm_to_pix * dPR; - - // old position -------------------------------------- + let top = this.m_nTop; + let bottom = this.m_nBottom; + + function blitLeftInd(ind, isRtl) + { + let offset = isRtl ? (_margin_right - ind) : (_margin_left + ind); + let dCenterX = left + offset * dKoef_mm_to_pix; + + let var1 = parseInt(dCenterX - _1mm_to_pix) - indent + Math.round(dPR) - 1; + let var4 = parseInt(dCenterX + _1mm_to_pix) + indent + Math.round(dPR) - 1; + + if (0 !== ((var1 - var4 + Math.round(dPR)) & 1)) + var4 += 1; + + context.beginPath(); + context.lineWidth = Math.round(dPR); + context.moveTo(var1, bottom + indent); + context.lineTo(var4, bottom + indent); + context.lineTo(var4, bottom + indent + Math.round(var2)); + context.lineTo(var1, bottom + indent + Math.round(var2)); + context.lineTo(var1, bottom + indent); + context.lineTo(var1, bottom + indent - Math.round(var3)); + context.lineTo((var1 + var4) / 2, bottom - Math.round(var2 * 1.2)); + context.lineTo(var4, bottom + indent - Math.round(var3)); + context.lineTo(var4, bottom + indent); + + context.fill(); + context.stroke(); + } + + function blitFirstInd(ind, isRtl) + { + let offset = isRtl ? (_margin_right - ind) : (_margin_left + ind); + dCenterX = left + offset * dKoef_mm_to_pix; + + let var1 = parseInt(dCenterX - _1mm_to_pix) - indent + Math.round(dPR) - 1; + let var4 = parseInt(dCenterX + _1mm_to_pix) + indent + Math.round(dPR) - 1; + + if (0 !== ((var1 - var4 + Math.round(dPR)) & 1)) + var4 += 1; + + // first line indent + context.beginPath(); + context.lineWidth = Math.round(dPR); + context.moveTo(var1, top + indent); + context.lineTo(var1, top + indent - Math.round(var3)); + context.lineTo(var4, top + indent - Math.round(var3)); + context.lineTo(var4, top + indent); + context.lineTo((var1 + var4) / 2, top + Math.round(var2 * 1.2)); + context.closePath(); + + context.fill(); + context.stroke(); + } + + function blitRightInd(ind, isRtl) + { + let offset = isRtl ? (_margin_left + ind) : (_margin_right - ind); + dCenterX = left + offset * dKoef_mm_to_pix; + + let var1 = parseInt(dCenterX - _1mm_to_pix) - indent + Math.round(dPR) - 1; + let var4 = parseInt(dCenterX + _1mm_to_pix) + indent + Math.round(dPR) - 1; + + if (0 !== ((var1 - var4 + Math.round(dPR)) & 1)) + var4 += 1; + + context.beginPath(); + context.lineWidth = Math.round(dPR); + context.moveTo(var1, bottom + indent); + context.lineTo(var4, bottom + indent); + context.lineTo(var4, bottom + indent - Math.round(var3)); + context.lineTo((var1 + var4) / 2, bottom - Math.round(var2 * 1.2)); + context.lineTo(var1, bottom + indent - Math.round(var3)); + context.closePath(); + + context.fill(); + context.stroke(); + } + + // old position -------------------------------------- context.strokeStyle = GlobalSkin.RulerMarkersOutlineColorOld; - context.fillStyle = GlobalSkin.RulerMarkersFillColorOld; - if ((-10000 != this.m_dIndentLeft_old) && (this.m_dIndentLeft_old != this.m_dIndentLeft)) - { - dCenterX = left + (_margin_left + this.m_dIndentLeft_old) * dKoef_mm_to_pix; - var1 = parseInt(dCenterX - _1mm_to_pix) - indent + Math.round(dPR) - 1; - var4 = parseInt(dCenterX + _1mm_to_pix) + indent + Math.round(dPR) - 1; - - if ( 0 != ((var1 - var4 + Math.round(dPR)) & 1)) - var4 += 1; - - context.beginPath(); - context.lineWidth = Math.round(dPR); - context.moveTo(var1, this.m_nBottom + indent); - context.lineTo(var4, this.m_nBottom + indent); - context.lineTo(var4, this.m_nBottom + indent + Math.round(var2)); - context.lineTo(var1, this.m_nBottom + indent + Math.round(var2)); - context.lineTo(var1, this.m_nBottom + indent); - context.lineTo(var1, this.m_nBottom + indent - Math.round(var3)); - context.lineTo((var1 + var4) / 2, this.m_nBottom - Math.round(var2 * 1.2)); - context.lineTo(var4, this.m_nBottom + indent - Math.round(var3)); - context.lineTo(var4, this.m_nBottom + indent); - - context.fill(); - context.stroke(); - } - if ((-10000 != this.m_dIndentLeftFirst_old) && (this.m_dIndentLeftFirst_old != this.m_dIndentLeftFirst)) - { - dCenterX = left + (_margin_left + this.m_dIndentLeftFirst_old) * dKoef_mm_to_pix; - var1 = parseInt(dCenterX - _1mm_to_pix) - indent + Math.round(dPR) - 1; - var4 = parseInt(dCenterX + _1mm_to_pix) + indent + Math.round(dPR) - 1; - - if ( 0 != ((var1 - var4 + Math.round(dPR)) & 1)) - var4 += 1; - - // first line indent - context.beginPath(); - context.lineWidth = Math.round(dPR); - context.moveTo(var1, this.m_nTop + indent); - context.lineTo(var1, this.m_nTop + indent - Math.round(var3)); - context.lineTo(var4, this.m_nTop + indent - Math.round(var3)); - context.lineTo(var4, this.m_nTop + indent); - context.lineTo((var1 + var4) / 2, this.m_nTop + Math.round(var2 * 1.2)); - context.closePath(); - - context.fill(); - context.stroke(); - } - if ((-10000 != this.m_dIndentRight_old) && (this.m_dIndentRight_old != this.m_dIndentRight)) - { - dCenterX = left + (_margin_right - this.m_dIndentRight_old) * dKoef_mm_to_pix; - var1 = parseInt(dCenterX - _1mm_to_pix) - indent + Math.round(dPR) - 1; - var4 = parseInt(dCenterX + _1mm_to_pix) + indent + Math.round(dPR) - 1; - - if ( 0 != ((var1 - var4 + Math.round(dPR)) & 1)) - var4 += 1; - - context.beginPath(); - context.lineWidth = Math.round(dPR); - context.moveTo(var1, this.m_nBottom + indent); - context.lineTo(var4, this.m_nBottom + indent); - context.lineTo(var4, this.m_nBottom + indent - Math.round(var3)); - context.lineTo((var1 + var4) / 2, this.m_nBottom - Math.round(var2 * 1.2)); - context.lineTo(var1, this.m_nBottom + indent - Math.round(var3)); - context.closePath(); - - context.fill(); - context.stroke(); - } + context.fillStyle = GlobalSkin.RulerMarkersFillColorOld; + if (-10000 !== this.m_dIndentLeft_old && this.m_dIndentLeft_old !== this.m_dIndentLeft) + blitLeftInd(this.m_dIndentLeft_old, this.m_bRtl); + + if (-10000 !== this.m_dIndentLeftFirst_old && this.m_dIndentLeftFirst_old !== this.m_dIndentLeftFirst) + blitFirstInd(this.m_dIndentLeftFirst_old, this.m_bRtl); + + if (-10000 !== this.m_dIndentRight_old && this.m_dIndentRight_old !== this.m_dIndentRight) + blitRightInd(this.m_dIndentRight_old, this.m_bRtl); context.strokeStyle = GlobalSkin.RulerTabsColorOld; if (-1 != this.m_lCurrentTab && this.m_lCurrentTab < this.m_arrTabs.length) @@ -2566,76 +2585,14 @@ function CHorRuler() posR = _margin_right - this.m_dIndentRight; if (posL < posR) - { + { context.strokeStyle = GlobalSkin.RulerMarkersOutlineColor; - context.fillStyle = GlobalSkin.RulerMarkersFillColor; - - // left indent - dCenterX = left + (_margin_left + this.m_dIndentLeft) * dKoef_mm_to_pix; - - var _1mm_to_pix = g_dKoef_mm_to_pix * dPR; - - var1 = parseInt(dCenterX - _1mm_to_pix) - indent + Math.round(dPR) - 1; - var4 = parseInt(dCenterX + _1mm_to_pix) + indent + Math.round(dPR) - 1; - - if ( 0 != ((var1 - var4 + Math.round(dPR)) & 1)) - var4 += 1; - - context.beginPath(); - context.lineWidth = roundDPR; - context.moveTo(var1, this.m_nBottom + indent); - context.lineTo(var4, this.m_nBottom + indent); - context.lineTo(var4, this.m_nBottom + indent + Math.round(var2)); - context.lineTo(var1, this.m_nBottom + indent + Math.round(var2)); - context.lineTo(var1, this.m_nBottom + indent); - context.lineTo(var1, this.m_nBottom + indent - Math.round(var3)); - context.lineTo((var1 + var4) / 2, this.m_nBottom - Math.round(var2 * 1.2)); - context.lineTo(var4, this.m_nBottom + indent - Math.round(var3)); - context.lineTo(var4, this.m_nBottom + indent); - - context.fill(); - context.stroke(); - - // right indent - dCenterX = left + (_margin_right - this.m_dIndentRight) * dKoef_mm_to_pix; - var1 = parseInt(dCenterX - _1mm_to_pix) - indent + Math.round(dPR) - 1; - var4 = parseInt(dCenterX + _1mm_to_pix) + indent + Math.round(dPR) - 1; - - if ( 0 != ((var1 - var4 + Math.round(dPR)) & 1)) - var4 += 1; - - context.beginPath(); - context.lineWidth = Math.round(dPR); - context.moveTo(var1, this.m_nBottom + indent); - context.lineTo(var4, this.m_nBottom + indent); - context.lineTo(var4, this.m_nBottom + indent - Math.round(var3)); - context.lineTo((var1 + var4) / 2, this.m_nBottom - Math.round(var2 * 1.2)); - context.lineTo(var1, this.m_nBottom + indent - Math.round(var3)); - context.closePath(); - - context.fill(); - context.stroke(); - - // first line indent - dCenterX = left + (_margin_left + this.m_dIndentLeftFirst) * dKoef_mm_to_pix; - var1 = parseInt(dCenterX - _1mm_to_pix) - indent + Math.round(dPR) - 1; - var4 = parseInt(dCenterX + _1mm_to_pix) + indent + Math.round(dPR) - 1; - - if ( 0 != ((var1 - var4 + Math.round(dPR)) & 1)) - var4 += 1; - - context.beginPath(); - context.lineWidth = Math.round(dPR); - context.moveTo(var1, this.m_nTop + indent); - context.lineTo(var1, this.m_nTop + indent - Math.round(var3)); - context.lineTo(var4, this.m_nTop + indent - Math.round(var3)); - context.lineTo(var4, this.m_nTop + indent); - context.lineTo((var1 + var4) / 2, this.m_nTop + Math.round(var2 * 1.2)); - context.closePath(); - - context.fill(); - context.stroke(); - } + context.fillStyle = GlobalSkin.RulerMarkersFillColor; + + blitLeftInd(this.m_dIndentLeft, this.m_bRtl); + blitRightInd(this.m_dIndentRight, this.m_bRtl) + blitFirstInd(this.m_dIndentLeftFirst, this.m_bRtl); + } // теперь рисуем табы ---------------------------------------- // default @@ -2643,27 +2600,46 @@ function CHorRuler() _positon_y = this.m_nBottom + Math.round(1.5 * dPR); var _min_default_value = Math.max(0, this.m_dMaxTab); - if (this.m_dDefaultTab > 0.01) - { - while (true) - { - if ((_margin_left + position_default_tab) > this.m_dMarginRight) - break; - - if (position_default_tab < _min_default_value) - { - position_default_tab += this.m_dDefaultTab; - continue; - } - - var _x = parseInt((_margin_left + position_default_tab) * dKoef_mm_to_pix) + left + indent; - context.beginPath(); - context.moveTo(_x, _positon_y); - context.lineTo(_x, _positon_y + Math.round(3 * dPR)); - context.stroke(); - - position_default_tab += this.m_dDefaultTab; - } + if (this.m_dDefaultTab > 0.01) + { + if (this.m_bRtl) + { + while (_margin_right - position_default_tab > this.m_dMarginLeft) + { + if (position_default_tab < _min_default_value) + { + position_default_tab += this.m_dDefaultTab; + continue; + } + + let _x = parseInt((_margin_right - position_default_tab) * dKoef_mm_to_pix) + left + indent; + context.beginPath(); + context.moveTo(_x, _positon_y); + context.lineTo(_x, _positon_y + Math.round(3 * dPR)); + context.stroke(); + + position_default_tab += this.m_dDefaultTab; + } + } + else + { + while (_margin_left + position_default_tab < this.m_dMarginRight) + { + if (position_default_tab < _min_default_value) + { + position_default_tab += this.m_dDefaultTab; + continue; + } + + let _x = parseInt((_margin_left + position_default_tab) * dKoef_mm_to_pix) + left + indent; + context.beginPath(); + context.moveTo(_x, _positon_y); + context.lineTo(_x, _positon_y + Math.round(3 * dPR)); + context.stroke(); + + position_default_tab += this.m_dDefaultTab; + } + } } // custom tabs @@ -2733,6 +2709,45 @@ function CHorRuler() // ----------------------------------------------------------- } } + + this.UpdateParaInd = function(paraInd, isRtl) + { + if (!paraInd) + return 0; + + let left = undefined !== paraInd.Left ? paraInd.Left : 0; + let right = undefined !== paraInd.Right ? paraInd.Right : 0; + let firstLine = undefined !== paraInd.FirstLine ? left + paraInd.FirstLine : 0; + + let update = 0; + + if (Math.abs(this.m_dIndentLeft - left) > AscWord.EPSILON) + { + this.m_dIndentLeft = left; + update |= 1; + } + + if (Math.abs(this.m_dIndentLeftFirst - firstLine) > AscWord.EPSILON) + { + this.m_dIndentLeftFirst = firstLine; + update |= 1; + } + + if (Math.abs(this.m_dIndentRight - right) > AscWord.EPSILON) + { + this.m_dIndentRight = right; + update |= 1; + } + + if (this.m_bRtl !== isRtl) + { + this.m_bRtl = isRtl; + update |= 1; + update |= 2; + } + + return update; + }; } function CVerRuler() @@ -3560,7 +3575,7 @@ function CVerRuler() var _y = global_mouseEvent.Y - 7 * g_dKoef_mm_to_pix - top - word_control.Y; _y *= dKoefPxToMM; - var _x = (global_mouseEvent.X - word_control.X) * g_dKoef_pix_to_mm - word_control.GetMainContentBounds().L; + var _x = (global_mouseEvent.X - word_control.X) * g_dKoef_pix_to_mm - word_control.GetMainContentBounds().L - word_control.GetVertRulerLeft(); this.DragType = this.CheckMouseType(_x, _y); this.DragTypeMouseDown = this.DragType; diff --git a/word/Editor/Common.js b/word/Editor/Common.js index 0334bd52d8..79c574b25d 100644 --- a/word/Editor/Common.js +++ b/word/Editor/Common.js @@ -658,6 +658,7 @@ window['AscCommonWord'].CTextToTableEngine = CTextToTableEngine; window['AscWord'].sortByDocumentPosition = sortByDocumentPosition; window['AscWord'].checkAsYouTypeEnterText = checkAsYouTypeEnterText; + window['AscWord'].EPSILON = 0.001; window['AscWord'].MAX_MM_VALUE = 558.7; window['AscWord'].Direction = Direction; diff --git a/word/Editor/Document.js b/word/Editor/Document.js index 6114e3cf44..be9106003a 100644 --- a/word/Editor/Document.js +++ b/word/Editor/Document.js @@ -6934,8 +6934,18 @@ CDocument.prototype.MoveCursorLeft = function(AddToSelect, Word) if (undefined === Word || null === Word) Word = false; - - this.Controller.MoveCursorLeft(AddToSelect, Word); + + let isRtl = false; + if (!this.IsSelectionUse() || this.IsTextSelectionUse()) + { + let curPara = this.GetCurrentParagraph(true); + isRtl = (curPara ? curPara.isRtlDirection() : false); + } + + if (isRtl) + this.Controller.MoveCursorRight(AddToSelect, Word); + else + this.Controller.MoveCursorLeft(AddToSelect, Word); this.CorrectCursorPosition(false); this.Document_UpdateInterfaceState(); @@ -6949,8 +6959,18 @@ CDocument.prototype.MoveCursorRight = function(AddToSelect, Word, FromPaste) if (undefined === Word || null === Word) Word = false; - - this.Controller.MoveCursorRight(AddToSelect, Word, FromPaste); + + let isRtl = false; + if (!this.IsSelectionUse() || this.IsTextSelectionUse()) + { + let curPara = this.GetCurrentParagraph(true); + isRtl = (curPara ? curPara.isRtlDirection() : false); + } + + if (isRtl) + this.Controller.MoveCursorLeft(AddToSelect, Word); + else + this.Controller.MoveCursorRight(AddToSelect, Word, FromPaste); this.CorrectCursorPosition(true); this.Document_UpdateInterfaceState(); diff --git a/word/Editor/DocumentChanges.js b/word/Editor/DocumentChanges.js index 2f791628a8..681e16677f 100644 --- a/word/Editor/DocumentChanges.js +++ b/word/Editor/DocumentChanges.js @@ -1226,3 +1226,4 @@ CChangesDocumentDisconnectEveryone.prototype.Redo = function() editorApi.setViewModeDisconnect(true); editorApi.asc_coAuthoringDisconnect(); }; +AscDFH.CChangesDocumentDisconnectEveryone = CChangesDocumentDisconnectEveryone; diff --git a/word/Editor/GraphicObjects/GraphicObjects.js b/word/Editor/GraphicObjects/GraphicObjects.js index b2ce840722..d35cc3d58c 100644 --- a/word/Editor/GraphicObjects/GraphicObjects.js +++ b/word/Editor/GraphicObjects/GraphicObjects.js @@ -2313,14 +2313,14 @@ CGraphicObjects.prototype = let oDrawing = this.getMajorParaDrawing(); if(oDrawing) { - let oParagraph = oDrawing.Get_ParentParagraph(), ParaPr; + let oParagraph = oDrawing.Get_ParentParagraph(); if(oParagraph) { let oParaPr = oParagraph.Get_CompiledPr2(true).ParaPr; if (oParaPr) { editor.sync_ParaSpacingLine( oParaPr.Spacing ); - editor.Update_ParaInd(oParaPr.Ind); + editor.Update_ParaInd(oParaPr.Ind, oParaPr.Bidi); editor.sync_PrAlignCallBack(oParaPr.Jc); editor.sync_ParaStyleName(oParaPr.StyleName); } @@ -2390,7 +2390,7 @@ CGraphicObjects.prototype = // editor.UpdateTextPr(oTextPr); editor.Update_ParaTab(AscCommonWord.Default_Tab_Stop, new CParaTabs()); editor.sync_ParaSpacingLine( new CParaSpacing() ); - editor.Update_ParaInd(new CParaInd()); + editor.Update_ParaInd(new CParaInd(), false); editor.sync_PrAlignCallBack(null); editor.sync_ParaStyleName(null); }, diff --git a/word/Editor/HeaderFooter.js b/word/Editor/HeaderFooter.js index fd8dff080a..202727ad53 100644 --- a/word/Editor/HeaderFooter.js +++ b/word/Editor/HeaderFooter.js @@ -205,8 +205,12 @@ CHeaderFooter.prototype = var CurPage = 0; var RecalcResult = recalcresult2_NextPage; - while ( recalcresult2_End != RecalcResult ) - RecalcResult = this.Content.Recalculate_Page( CurPage++, true ); + while (recalcresult2_End !== RecalcResult) + { + RecalcResult = this.Content.Recalculate_Page(CurPage, true); + if (RecalcResult !== recalcresult2_CurPage) + ++CurPage; + } this.RecalcInfo.RecalcObj[Page_abs] = this.Content.SaveRecalculateObject(); this.RecalcInfo.PageNumInfo[Page_abs] = this.LogicDocument.Get_SectionPageNumInfo(Page_abs); @@ -316,10 +320,14 @@ CHeaderFooter.prototype = this.Content.Set_StartPage(nPageAbs); this.Content.PrepareRecalculateObject(); - var nCurPage = 0; - var nRecalcResult = recalcresult2_NextPage; - while (recalcresult2_End !== nRecalcResult) - nRecalcResult = this.Content.Recalculate_Page(nCurPage++, true); + var curPage = 0; + var recalcResult = recalcresult2_NextPage; + while (recalcresult2_End !== recalcResult) + { + recalcResult = this.Content.Recalculate_Page(curPage, true); + if (recalcResult === recalcresult2_NextPage) + ++curPage; + } this.OnEndRecalculate(); }, @@ -1305,8 +1313,9 @@ CHeaderFooter.prototype = this.Id = Reader.GetString2(); this.Type = Reader.GetLong(); - - this.Content = AscCommon.g_oTableId.Get_ById( Reader.GetString2() ); + + this.Content = AscCommon.g_oTableId.Get_ById(Reader.GetString2()); + this.Content.SetParent(this); }, //----------------------------------------------------------------------------------- // Функции для работы с комментариями diff --git a/word/Editor/Paragraph.js b/word/Editor/Paragraph.js index ff25d70b51..aedc3c913d 100644 --- a/word/Editor/Paragraph.js +++ b/word/Editor/Paragraph.js @@ -2054,6 +2054,36 @@ Paragraph.prototype.getTextOnLine = function(line) return this.GetTextOnLine(line); }; +/** + * @param {number} line + * @return {number} + */ +Paragraph.prototype.getRangeCount = function(line) +{ + return this.Lines[line] ? this.Lines[line].Ranges.length : 0; +}; +Paragraph.prototype.getRange = function(line, range) +{ + return this.Lines[line] && this.Lines[line].Ranges[range] ? this.Lines[line].Ranges[range] : null; +}; +Paragraph.prototype.getTextInLineRange = function(line, range) +{ + if (!this.IsRecalculated() || !this.Lines[line] || !this.Lines[line].Ranges[range]) + return ""; + + let paraState = this.SaveSelectionState(); + + let startPos = this.Get_StartRangePos2(line, range); + let endPos = this.Get_EndRangePos2(line, range); + + this.Selection.Use = true; + this.Selection.Start = false; + this.SetSelectionContentPos(startPos, endPos); + + let result = this.GetSelectedText(false, {Numbering : false}); + this.LoadSelectionState(paraState); + return result; +}; Paragraph.prototype.Reset_RecalculateCache = function() { diff --git a/word/Editor/Paragraph/position-calculator.js b/word/Editor/Paragraph/position-calculator.js index de7cd67e63..669ca9e7ec 100644 --- a/word/Editor/Paragraph/position-calculator.js +++ b/word/Editor/Paragraph/position-calculator.js @@ -52,6 +52,8 @@ this.x = 0; this.y = 0; + this.startX = 0; + this.bidi = new AscWord.BidiFlow(this); this.isNextCurrent = false; @@ -94,6 +96,8 @@ this.x = p.Lines[line].Ranges[range].XVisible; this.y = p.Pages[page].Y + p.Lines[line].Y; + this.startX = this.x; + if (p.Numbering.checkRange(range, line)) this.x += p.Numbering.WidthVisible; @@ -371,7 +375,7 @@ if (this.isNextCurrent) { - this.posInfo.x = this.x; + this.posInfo.x = this.paragraph.isRtlDirection() ? this.startX : this.x; this.posInfo.y = this.y; this.posInfo.run = this.nextRun; diff --git a/word/Editor/Paragraph/search-position-by-coords.js b/word/Editor/Paragraph/search-position-by-coords.js index 8cc9ce6453..2ec32decb8 100644 --- a/word/Editor/Paragraph/search-position-by-coords.js +++ b/word/Editor/Paragraph/search-position-by-coords.js @@ -446,12 +446,25 @@ return 0; let range = 0; - for (; range < rangeCount - 1; ++range) + if (p.isRtlDirection()) { - let currRange = p.Lines[this.line].Ranges[range]; - let nextRange = p.Lines[this.line].Ranges[range + 1]; - if (x < (currRange.XEnd + nextRange.X) / 2 || currRange.WEnd > 0.001) - break; + for (; range < rangeCount - 1; ++range) + { + let currRange = p.Lines[this.line].Ranges[range]; + let nextRange = p.Lines[this.line].Ranges[range + 1]; + if (x > (currRange.X + nextRange.XEnd) / 2 || currRange.WEnd > 0.001) + break; + } + } + else + { + for (; range < rangeCount - 1; ++range) + { + let currRange = p.Lines[this.line].Ranges[range]; + let nextRange = p.Lines[this.line].Ranges[range + 1]; + if (x < (currRange.XEnd + nextRange.X) / 2 || currRange.WEnd > 0.001) + break; + } } return Math.max(0, Math.min(range, rangeCount - 1)); diff --git a/word/Editor/Paragraph_Recalculate.js b/word/Editor/Paragraph_Recalculate.js index 4d8e9720f0..17c5f1cd12 100644 --- a/word/Editor/Paragraph_Recalculate.js +++ b/word/Editor/Paragraph_Recalculate.js @@ -610,7 +610,7 @@ Paragraph.prototype.private_RecalculateFastRange = function(PRS, CurRange, let nEndPos = Range.EndPos; // Обновляем состояние пересчета - PRS.Reset_Range(Range.X, Range.XEnd); + PRS.resetRange(Range); let arrSavedLines = []; for (let nPos = nStartPos; nPos <= nEndPos; ++nPos) @@ -1113,7 +1113,7 @@ Paragraph.prototype.private_RecalculateLineWidow = function(CurLine, CurPa return true; }; -Paragraph.prototype.private_RecalculateLineFillRanges = function(CurLine, CurPage, PRS, ParaPr) +Paragraph.prototype.private_RecalculateLineFillRanges = function(CurLine, CurPage, PRS, paraPr) { this.Lines[CurLine].Info = 0; @@ -1158,14 +1158,38 @@ Paragraph.prototype.private_RecalculateLineFillRanges = function(CurLine, CurPa } PRS.UseFirstLine = UseFirstLine; + + // Заполняем строку отрезками обтекания. Выставляем начальные сдвиги для отрезков. Начало промежутка = конец вырезаемого промежутка + this.Lines[CurLine].Reset(); + if (paraPr.Bidi) + { + let xStart = PRS.XStart; + + let x0 = RangesCount > 0 ? Ranges[Ranges.length - 1].X1 : xStart; + let x1 = (UseFirstLine ? PRS.XLimit - paraPr.Ind.Left - paraPr.Ind.FirstLine : PRS.XLimit - paraPr.Ind.Left); + this.Lines[CurLine].addRange(x0, x1); + for (let rangeIndex = Ranges.length - 1; rangeIndex >= 0; --rangeIndex) + { + x0 = rangeIndex > 0 ? Ranges[rangeIndex - 1].X1 : xStart; + x1 = Ranges[rangeIndex].X0; + this.Lines[CurLine].addRange(x0, x1); + } - // Заполняем строку отрезками обтекания. Выставляем начальные сдвиги для отрезков. Начало промежутка = конец вырезаемого промежутка - this.Lines[CurLine].Reset(); - this.Lines[CurLine].Add_Range( ( true === UseFirstLine ? PRS.XStart + ParaPr.Ind.Left + ParaPr.Ind.FirstLine : PRS.XStart + ParaPr.Ind.Left ), (RangesCount == 0 ? PRS.XLimit : Ranges[0].X0) ); - for ( var Index = 1; Index < Ranges.length + 1; Index++ ) - { - this.Lines[CurLine].Add_Range( Ranges[Index - 1].X1, (RangesCount == Index ? PRS.XLimit : Ranges[Index].X0) ); - } + } + else + { + let xLimit = PRS.XLimit; + + let x0 = (UseFirstLine ? PRS.XStart + paraPr.Ind.Left + paraPr.Ind.FirstLine : PRS.XStart + paraPr.Ind.Left); + let x1 = RangesCount > 0 ? Ranges[0].X0 : xLimit; + this.Lines[CurLine].addRange(x0, x1); + for (let rangeIndex = 1, rangeCount = Ranges.length; rangeIndex <= rangeCount; ++rangeIndex) + { + x0 = Ranges[rangeIndex - 1].X1 + x1 = rangeIndex === RangesCount ? xLimit : Ranges[rangeIndex].X0; + this.Lines[CurLine].addRange(x0, x1); + } + } if (true === PRS.RangeY) { @@ -2157,7 +2181,7 @@ Paragraph.prototype.private_RecalculateLineCheckEndnotes = function(CurLine, Cur oTopDocument.GetEndnotesController().RegisterEndnotes(PRS.PageAbs, arrEndnotes); }; -Paragraph.prototype.private_RecalculateRange = function(CurRange, CurLine, CurPage, RangesCount, PRS, ParaPr) +Paragraph.prototype.private_RecalculateRange = function(CurRange, CurLine, CurPage, RangesCount, PRS, paraPr) { // Найдем начальную позицию данного отрезка var StartPos = 0; @@ -2170,26 +2194,25 @@ Paragraph.prototype.private_RecalculateRange = function(CurRange, CurL var Line = this.Lines[CurLine]; var Range = Line.Ranges[CurRange]; - - this.Lines[CurLine].Set_RangeStartPos( CurRange, StartPos ); - - if ( true === PRS.UseFirstLine && 0 !== CurRange && true === PRS.EmptyLine ) - { - if ( ParaPr.Ind.FirstLine < 0 ) - { - Range.X += ParaPr.Ind.Left + ParaPr.Ind.FirstLine; - } - else - { - Range.X += ParaPr.Ind.FirstLine; - } - } - - var X = Range.X; - var XEnd = ( CurRange == RangesCount ? PRS.XLimit : PRS.Ranges[CurRange].X0 ); - - // Обновляем состояние пересчета - PRS.Reset_Range(X, XEnd); + + this.Lines[CurLine].setRangeStartPos(CurRange, StartPos); + + // Correct first line indentation if previous ranges were empty + if (PRS.UseFirstLine && 0 !== CurRange && PRS.EmptyLine) + { + let shift = 0; + if (PRS.getCompatibilityMode() >= AscCommon.document_compatibility_mode_Word15) + shift = Math.max(paraPr.Ind.FirstLine, 0); + else + shift = paraPr.Ind.FirstLine < 0.001 ? paraPr.Ind.Left + paraPr.Ind.FirstLine : paraPr.Ind.FirstLine; + + if (paraPr.Bidi) + Range.XEnd -= shift; + else + Range.X += shift; + } + + PRS.resetRange(Range); var ContentLen = this.Content.length; @@ -2218,7 +2241,7 @@ Paragraph.prototype.private_RecalculateRange = function(CurRange, CurL } PRS.Update_CurPos( Pos, 0 ); - Item.Recalculate_Range( PRS, ParaPr, 1 ); + Item.Recalculate_Range( PRS, paraPr, 1 ); if ( true === PRS.NewRange ) { @@ -2241,7 +2264,7 @@ Paragraph.prototype.private_RecalculateRange = function(CurRange, CurL this.private_RecalculateRangeEndPos( PRS, PRS.LineBreakPos, 0 ); } else - this.Lines[CurLine].Set_RangeEndPos( CurRange, Pos ); + this.Lines[CurLine].setRangeEndPos(CurRange, Pos); } }; @@ -2252,7 +2275,7 @@ Paragraph.prototype.private_RecalculateRangeEndPos = function(PRS, PRP, Dept var CurPos = PRP.Get(Depth); this.Content[CurPos].Recalculate_Set_RangeEndPos(PRS, PRP, Depth + 1); - this.Lines[CurLine].Set_RangeEndPos( CurRange, CurPos ); + this.Lines[CurLine].setRangeEndPos(CurRange, CurPos); }; Paragraph.prototype.private_RecalculateGetTabPos = function(PRS, X, ParaPr, CurPage, NumTab) @@ -2753,14 +2776,8 @@ function CParaLine() // 4 бит : строка переносится по Y по обтекаемому объекту this.CF = []; } - CParaLine.prototype = { - Add_Range : function(X, XEnd) - { - this.Ranges.push(new CParaLineRange(X, XEnd)); - }, - Shift : function(Dx, Dy) { // По Y мы ничего не переносим, т.к. все значени по Y у строки относительно начала страницы данного параграфа @@ -2786,16 +2803,6 @@ CParaLine.prototype = return this.Ranges[this.Ranges.length - 1].EndPos; }, - Set_RangeStartPos : function(CurRange, StartPos) - { - this.Ranges[CurRange].StartPos = StartPos; - }, - - Set_RangeEndPos : function(CurRange, EndPos) - { - this.Ranges[CurRange].EndPos = EndPos; - }, - Copy : function() { var NewLine = new CParaLine(); @@ -2831,6 +2838,18 @@ CParaLine.prototype = this.Info = 0; } }; +CParaLine.prototype.addRange = function(x, xEnd) +{ + this.Ranges.push(new AscWord.CParaLineRange(x, xEnd)); +}; +CParaLine.prototype.setRangeStartPos = function(rangeIndex, startPos) +{ + this.Ranges[rangeIndex].StartPos = startPos; +}; +CParaLine.prototype.setRangeEndPos = function(rangeIndex, endPos) +{ + this.Ranges[rangeIndex].EndPos = endPos; +}; function CParaLineMetrics() { @@ -3057,6 +3076,7 @@ CParaLineRange.prototype.IsZeroRange = function() { return ((this.XEnd - this.X) < 0.001); }; +AscWord.CParaLineRange = CParaLineRange; function CParaPage(X, Y, XLimit, YLimit, FirstLine) { @@ -3460,7 +3480,7 @@ CParagraphRecalculateStateWrap.prototype.Reset_Line = function() if (this.Line >= 0) this.LineY[this.Line] = this.Y; }; -CParagraphRecalculateStateWrap.prototype.Reset_Range = function(X, XEnd) +CParagraphRecalculateStateWrap.prototype.resetRange = function(range) { this.LastTab.Reset(); @@ -3472,9 +3492,9 @@ CParagraphRecalculateStateWrap.prototype.Reset_Range = function(X, XEnd) this.FirstItemOnLine = true; this.StartWord = false; this.NewRange = false; - this.X = X; - this.XEnd = XEnd; - this.XRange = X; + this.X = range.X; + this.XEnd = range.XEnd; + this.XRange = range.X; this.RangeSpaces = []; this.MoveToLBP = false; diff --git a/word/Editor/Run.js b/word/Editor/Run.js index ef64e7fcd2..89584575a1 100644 --- a/word/Editor/Run.js +++ b/word/Editor/Run.js @@ -5643,7 +5643,9 @@ ParaRun.prototype.Recalculate_Range_Spaces = function(PRSA, _CurLine, _CurRange, // Обновляем позицию объекта Item.Update_Position(PRSA.Paragraph, new CParagraphLayout( PRSA.X, PRSA.Y , PageAbs, PRSA.LastW, ColumnStartX, ColumnEndX, X_Left_Margin, X_Right_Margin, Page_Width, Top_Margin, Bottom_Margin, Page_H, PageFields.X, PageFields.Y, Para.Pages[CurPage].Y + Para.Lines[_CurLine].Y - Para.Lines[_CurLine].Metrics.Ascent, Para.Pages[_CurPage].Y), PageLimits, PageLimitsOrigin, _CurLine); - if (PRSA.getCompatibilityMode() >= AscCommon.document_compatibility_mode_Word15 + // For headers we do not check for exceeding lower bound in this case + if (!isInHdrFtr + && PRSA.getCompatibilityMode() >= AscCommon.document_compatibility_mode_Word15 && 0 === CurPage && Item.Get_Bounds().Bottom >= Y_Bottom_Field && Item.IsMoveWithTextVertically()) @@ -9642,27 +9644,26 @@ function CParaRunLine() this.Ranges[0] = new CParaRunRange( 0, 0 ); this.RangesLength = 0; } +CParaRunLine.prototype.addRange = function(RangeIndex, StartPos, EndPos) +{ + if (0 !== RangeIndex) + { + this.Ranges[RangeIndex] = new CParaRunRange(StartPos, EndPos); + this.RangesLength = RangeIndex + 1; + } + else + { + this.Ranges[0].StartPos = StartPos; + this.Ranges[0].EndPos = EndPos; + this.RangesLength = 1; + } + + if (this.Ranges.length > this.RangesLength) + this.Ranges.legth = this.RangesLength; +}; CParaRunLine.prototype = { - Add_Range : function(RangeIndex, StartPos, EndPos) - { - if ( 0 !== RangeIndex ) - { - this.Ranges[RangeIndex] = new CParaRunRange( StartPos, EndPos ); - this.RangesLength = RangeIndex + 1; - } - else - { - this.Ranges[0].StartPos = StartPos; - this.Ranges[0].EndPos = EndPos; - this.RangesLength = 1; - } - - if ( this.Ranges.length > this.RangesLength ) - this.Ranges.legth = this.RangesLength; - }, - Copy : function() { var NewLine = new CParaRunLine(); diff --git a/word/Editor/StructuredDocumentTags/BlockLevel.js b/word/Editor/StructuredDocumentTags/BlockLevel.js index 378846b297..d7328ac48e 100644 --- a/word/Editor/StructuredDocumentTags/BlockLevel.js +++ b/word/Editor/StructuredDocumentTags/BlockLevel.js @@ -201,9 +201,11 @@ CBlockLevelSdt.prototype.Read_FromBinary2 = function(Reader) }; CBlockLevelSdt.prototype.Draw = function(CurPage, oGraphics) { + let logicDocument = this.GetLogicDocument(); + let shdColor = this.getShdColor(); - if (!shdColor && (this.LogicDocument.GetSdtGlobalShowHighlight() && !oGraphics.isPdf())) - shdColor = AscWord.CDocumentColorA.fromObjectRgb(this.LogicDocument.GetSdtGlobalColor()); + if (logicDocument && !shdColor && (logicDocument.GetSdtGlobalShowHighlight() && !oGraphics.isPdf())) + shdColor = AscWord.CDocumentColorA.fromObjectRgb(logicDocument.GetSdtGlobalColor()); if (shdColor) { diff --git a/word/api.js b/word/api.js index e06d5bc5b6..f6b725ce30 100644 --- a/word/api.js +++ b/word/api.js @@ -2272,7 +2272,7 @@ background-repeat: no-repeat;\ } this.sync_ParaSpacingLine(ParaPr.Spacing); - this.Update_ParaInd(ParaPr.Ind); + this.Update_ParaInd(ParaPr.Ind, ParaPr.Bidi); this.sync_PrAlignCallBack(ParaPr.Jc); let bidi = ParaPr.Bidi; @@ -2916,7 +2916,7 @@ background-repeat: no-repeat;\ "format" : this.documentFormat, "c" : "reopen", "title" : this.documentTitle, - "codepage" : option.asc_getCodePage(), + "codepage" : option.asc_getCodePageOrDefault(), "nobase64" : true }; sendCommand(this, null, rData); @@ -5375,45 +5375,12 @@ background-repeat: no-repeat;\ } } }; - asc_docs_api.prototype.Update_ParaInd = function(Ind) + asc_docs_api.prototype.Update_ParaInd = function(paraInd, isRtl) { - 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; - } - } - - var bIsUpdate = false; - var _ruler = this.WordControl.m_oHorRuler; - if (_ruler.m_dIndentLeft != Left) - { - _ruler.m_dIndentLeft = Left; - bIsUpdate = true; - } - if (_ruler != (FirstLine + Left)) - { - _ruler.m_dIndentLeftFirst = (FirstLine + Left); - bIsUpdate = true; - } - if (_ruler.m_dIndentRight != Right) - { - _ruler.m_dIndentRight = Right; - bIsUpdate = true; - } - if (bIsUpdate) + let updateFlag = this.WordControl.m_oHorRuler.UpdateParaInd(paraInd, isRtl); + if (updateFlag & 2) + this.WordControl.UpdateHorRulerBack(true); + if (updateFlag & 1) this.WordControl.UpdateHorRuler(); }; asc_docs_api.prototype.Internal_Update_Ind_FirstLine = function(FirstLine, Left) @@ -5444,23 +5411,29 @@ background-repeat: no-repeat;\ // "where" где нижний или верхний, align выравнивание asc_docs_api.prototype.put_PageNum = function(where, align) { + let logicDocument = this.private_GetLogicDocument(); + if (!logicDocument) + return; + if (where >= 0) { - if (false === this.WordControl.m_oLogicDocument.Document_Is_SelectionLocked(changestype_None, {Type : AscCommon.changestype_2_HdrFtr})) - { - this.WordControl.m_oLogicDocument.StartAction(AscDFH.historydescription_Document_AddPageNumToHdrFtr); - this.WordControl.m_oLogicDocument.Document_AddPageNum(where, align); - this.WordControl.m_oLogicDocument.FinalizeAction(); - } + if (logicDocument.IsSelectionLocked(AscCommon.changestype_None, {Type : AscCommon.changestype_2_HdrFtr})) + return; + + logicDocument.StartAction(AscDFH.historydescription_Document_AddPageNumToHdrFtr); + logicDocument.Document_AddPageNum(where, align); + logicDocument.Recalculate(); + logicDocument.FinalizeAction(); } else { - if (false === this.WordControl.m_oLogicDocument.Document_Is_SelectionLocked(changestype_Paragraph_Content)) - { - this.WordControl.m_oLogicDocument.StartAction(AscDFH.historydescription_Document_AddPageNumToCurrentPos); - this.WordControl.m_oLogicDocument.Document_AddPageNum(where, align); - this.WordControl.m_oLogicDocument.FinalizeAction(); - } + if (logicDocument.IsSelectionLocked(AscCommon.changestype_Paragraph_Content)) + return; + + logicDocument.StartAction(AscDFH.historydescription_Document_AddPageNumToCurrentPos); + logicDocument.Document_AddPageNum(where, align); + logicDocument.Recalculate(); + logicDocument.FinalizeAction(); } }; @@ -11437,7 +11410,7 @@ background-repeat: no-repeat;\ return false; logicDocument.StartAction(AscDFH.historydescription_DisconnectEveryone); - logicDocument.GetHistory().Add(new CChangesDocumentDisconnectEveryone(logicDocument)); + logicDocument.GetHistory().Add(new AscDFH.CChangesDocumentDisconnectEveryone(logicDocument)); logicDocument.FinalizeAction(); this.forceSaveDisconnectRequest = true; @@ -11456,7 +11429,7 @@ background-repeat: no-repeat;\ logicDocument.StartAction(AscDFH.historydescription_OForm_CompletePreparation); logicDocument.GetOFormDocument().setAllRolesNotFilled(); if (disconnect) - logicDocument.GetHistory().Add(new CChangesDocumentDisconnectEveryone(logicDocument)); + logicDocument.GetHistory().Add(new AscDFH.CChangesDocumentDisconnectEveryone(logicDocument)); logicDocument.FinalizeAction(); diff --git a/word/apiBuilder.js b/word/apiBuilder.js index 5c380802fa..0e6bd50fe6 100644 --- a/word/apiBuilder.js +++ b/word/apiBuilder.js @@ -4274,7 +4274,7 @@ /** * The watermark direction. - * @typedef {("horizontal" | "clockwise45" | "counterclockwise45")} WatermarkDirection + * @typedef {("horizontal" | "clockwise45" | "counterclockwise45" | "clockwise90" | "counterclockwise90")} WatermarkDirection * @see office-js-api/Examples/Enumerations/WatermarkDirection.js */ @@ -16534,6 +16534,44 @@ return true; }; + /** + * Sets the rotation angle to the current drawing object. + * @memberof ApiDrawing + * @param {number} nRotAngle - new drawing rot angle + * @typeofeditors ["CDE"] + * @returns {boolean} + * @see office-js-api/Examples/{Editor}/ApiDrawing/Methods/SetRotation.js + */ + ApiDrawing.prototype.SetRotation = function(nRotAngle) + { + if (!this.Drawing.canRotate()) { + return false; + } + + let oXfrm = this.Drawing.getXfrm(); + oXfrm.setRot(nRotAngle * Math.PI / 180); + + return true; + }; + /** + * Gets the rotation angle of the current drawing object. + * @memberof ApiDrawing + * @typeofeditors ["CDE"] + * @returns {number} + * @see office-js-api/Examples/{Editor}/ApiDrawing/Methods/GetRotation.js + */ + ApiDrawing.prototype.GetRotation = function() + { + if (!this.Drawing.canRotate()) { + return 0; + } + + let oXfrm = this.Drawing.getXfrm(); + let nRad = oXfrm.getRot(); + + return nRad * 180 / Math.PI + }; + //------------------------------------------------------------------------------------------------------------------ // // ApiImage @@ -20967,7 +21005,43 @@ return true; }, this); }; - + /** + * Get the choice name for the current radio button. + * @memberof ApiCheckBoxForm + * @typeofeditors ["CDE", "CFE"] + * @since 8.3.2 + * @returns {string} + * @see office-js-api/Examples/{Editor}/ApiCheckBoxForm/Methods/GetChoiceName.js + * */ + ApiCheckBoxForm.prototype.GetChoiceName = function() + { + if (this.Sdt.IsRadioButton()) + return this.Sdt.GetFormKey(); + else + return ""; + }; + /** + * Set the choice name for the current radio button. + * @memberof ApiCheckBoxForm + * @param {string} choiceName - Radio button choice name. + * @typeofeditors ["CDE", "CFE"] + * @since 8.3.2 + * @returns {boolean} + * @see office-js-api/Examples/{Editor}/ApiCheckBoxForm/Methods/SetChoiceName.js + * */ + ApiCheckBoxForm.prototype.SetChoiceName = function(choiceName) + { + return executeNoFormLockCheck(function() { + let formPr = this.Sdt.GetFormPr(); + if (!formPr || typeof (choiceName) !== "string" || "" === choiceName || !this.Sdt.IsRadioButton()) + return false; + + formPr = formPr.Copy(); + formPr.SetKey(choiceName); + this.Sdt.SetFormPr(formPr); + return true; + }, this); + }; //------------------------------------------------------------------------------------------------------------------ // // ApiDateForm @@ -22205,6 +22279,16 @@ this.Settings.put_Angle(-45); break; } + case "clockwise90": + { + this.Settings.put_Angle(90); + break; + } + case "counterclockwise90": + { + this.Settings.put_Angle(-90); + break; + } default: return false; } @@ -23121,6 +23205,8 @@ ApiDrawing.prototype["GetLockValue"] = ApiDrawing.prototype.GetLockValue; ApiDrawing.prototype["SetLockValue"] = ApiDrawing.prototype.SetLockValue; ApiDrawing.prototype["SetDrawingPrFromDrawing"] = ApiDrawing.prototype.SetDrawingPrFromDrawing; + ApiDrawing.prototype["SetRotation"] = ApiDrawing.prototype.SetRotation; + ApiDrawing.prototype["GetRotation"] = ApiDrawing.prototype.GetRotation; ApiDrawing.prototype["ToJSON"] = ApiDrawing.prototype.ToJSON; @@ -23378,6 +23464,8 @@ ApiCheckBoxForm.prototype["IsRadioButton"] = ApiCheckBoxForm.prototype.IsRadioButton; ApiCheckBoxForm.prototype["GetRadioGroup"] = ApiCheckBoxForm.prototype.GetRadioGroup; ApiCheckBoxForm.prototype["SetRadioGroup"] = ApiCheckBoxForm.prototype.SetRadioGroup; + ApiCheckBoxForm.prototype["GetChoiceName"] = ApiCheckBoxForm.prototype.GetChoiceName; + ApiCheckBoxForm.prototype["SetChoiceName"] = ApiCheckBoxForm.prototype.SetChoiceName; ApiCheckBoxForm.prototype["Copy"] = ApiCheckBoxForm.prototype.Copy; ApiComment.prototype["GetClassType"] = ApiComment.prototype.GetClassType; diff --git a/word/api_plugins.js b/word/api_plugins.js index 79503d0fca..d8b7b058ec 100644 --- a/word/api_plugins.js +++ b/word/api_plugins.js @@ -639,7 +639,7 @@ */ Api.prototype["pluginMethod_AddContentControl"] = function(type, commonPr) { - var _content_control_pr = readContentControlCommonPr(commonPr); + var _content_control_pr = readContentControlCommonPr(new AscCommon.CContentControlPr(), commonPr); var _obj = this.asc_AddContentControl(type, _content_control_pr); if (!_obj)