diff --git a/cell/api.js b/cell/api.js index db96b6efde..292a6e727c 100644 --- a/cell/api.js +++ b/cell/api.js @@ -1475,6 +1475,7 @@ var editor; } var openXml = AscCommon.openXml; + var StaxParser = AscCommon.StaxParser; var pivotCaches = {}; var xmlParserContext = new AscCommon.XmlParserContext(); xmlParserContext.DrawingDocument = this.wbModel.DrawingDocument; diff --git a/cell/graphics/DrawingContext.js b/cell/graphics/DrawingContext.js index ea9df58c27..43087f1b38 100644 --- a/cell/graphics/DrawingContext.js +++ b/cell/graphics/DrawingContext.js @@ -384,33 +384,6 @@ NativeContext.prototype.getImageData = function (sx,sy,sw,sh) {}; NativeContext.prototype.putImageData = function (image_data,dx,dy,dirtyX,dirtyY,dirtyWidth,dirtyHeight) {}; - function NativeFontManager() { - this.m_lUnits_Per_Em = 0; - this.m_lAscender = 0; - this.m_lDescender = 0; - this.m_lLineHeight = 0; - } - - NativeFontManager.prototype.init = function (fontInfo) { - this.m_lUnits_Per_Em = fontInfo[3]; - this.m_lAscender = fontInfo[0]; - this.m_lDescender = fontInfo[2]; - this.m_lLineHeight = fontInfo[2]; - }; - NativeFontManager.prototype.MeasureChar = function (lUnicode) { - var bounds = g_oTextMeasurer.Measurer["GetDrawingBox"](lUnicode); - return { - fAdvanceX: bounds[0], oBBox: { - fMinX: bounds[1], fMaxX: bounds[2], fMinY: bounds[3], fMaxY: bounds[4] - } - }; - }; - NativeFontManager.prototype.SetTextMatrix = function (fA, fB, fC, fD, fE, fF) { - window["native"]["PD_transform"](fA, fB, fC, fD, fE, fF); - }; - - - /** * Emulates scalable canvas context * ----------------------------------------------------------------------------- @@ -447,9 +420,6 @@ this.changeUnits(undefined !== settings.units ? settings.units : this.units); this.fmgrGraphics = undefined !== settings.fmgrGraphics ? settings.fmgrGraphics : null; - if (window["IS_NATIVE_EDITOR"]) { - this.fmgrGraphics = [new NativeFontManager(), new NativeFontManager(), new NativeFontManager(), new NativeFontManager()]; - } if (null === this.fmgrGraphics) { throw "Can not set graphics in DrawingContext"; @@ -876,24 +846,25 @@ res.descender = factor * d; res.lineGap = factor * (fm.m_lLineHeight - fm.m_lAscender - d); - var face; - if (window["IS_NATIVE_EDITOR"]) { - face = g_oTextMeasurer.Measurer['GetFace'](); - res.nat_scale = face[0]; - res.nat_y1 = face[1]; - res.nat_y2 = face[2]; - } else { - var faceMetrics = fm.m_pFont.cellGetMetrics(); - res.nat_scale = faceMetrics[0]; - res.nat_y1 = faceMetrics[1]; - res.nat_y2 = faceMetrics[2]; - } + var faceMetrics = fm.m_pFont.cellGetMetrics(); + res.nat_scale = faceMetrics[0]; + res.nat_y1 = faceMetrics[1]; + res.nat_y2 = faceMetrics[2]; res.nat_y1 *= r2; res.nat_y2 *= r2; return res; }; + DrawingContext.prototype.nativeTextDecorationTransform = function(isStart) + { + // текст рисуется с трансформом, а strikeout/underline - без (матрица применяется ДО отрисовщика) + if (isStart) + window["native"]["PD_transform"](this._im.sx, this._im.shy, this._im.shx, this._im.sy, this._im.tx, this._im.ty); + else + window["native"]["PD_transform"](this._mt.sx, this._mt.shy, this._mt.shx, this._mt.sy, this._mt.tx, this._mt.ty); + }; + /** * * @param font @@ -905,14 +876,6 @@ var r; this.font.assign(font); - if (window["IS_NATIVE_EDITOR"]) { - this.font.fs = this.font.getSize() * this.scaleFactor * 96.0 / 25.4; - // this.font.fs = this.font.getSize() * 2.54 * this.scaleFactor * this.deviceDPI / 72.0; - - // this.font.fs = this.font.getSize() * 2.54 * this.scaleFactor * - // this.deviceScale * this.deviceDPI / 96.0 * (96.0 / (this.deviceDPI * this.deviceScale)); - } - var italic = this.font.getItalic(); var bold = this.font.getBold(); var fontStyle; @@ -928,7 +891,7 @@ if (window["IS_NATIVE_EDITOR"]) { var fontInfo = AscFonts.g_fontApplication.GetFontInfo(this.font.getName(), fontStyle, this.LastFontOriginInfo); - fontInfo = GetLoadInfoForMeasurer(fontInfo, fontStyle); + fontInfo = AscCommon.GetLoadInfoForMeasurer(fontInfo, fontStyle); var flag = 0; if (fontInfo.NeedBold) { @@ -944,18 +907,19 @@ flag |= 0x08; } - if (!angle) { - window["native"]["PD_LoadFont"](fontInfo.Path, fontInfo.FaceIndex, this.font.getSize(), flag); - } - AscCommon.g_oTextMeasurer.Flush(); - fontInfo = g_oTextMeasurer.Measurer["LoadFont"](fontInfo.Path, fontInfo.FaceIndex, this.font.getSize(), flag); - if (angle) { - this.fmgrGraphics[1].init(fontInfo); - } else { - this.fmgrGraphics[0].init(fontInfo); - this.fmgrGraphics[3].init(fontInfo); - } - r = true; + // выставляем шрифт и отрисовщику... + var drawFontSize = this.font.getSize() * this.scaleFactor * 96.0 / 25.4; + window["native"]["PD_LoadFont"](fontInfo.Path, fontInfo.FaceIndex, drawFontSize, flag); + + // на отрисовке ячейки трансформ выставляется/сбрасывается. так что тут - только если есть angle + if (angle) + window["native"]["PD_transform"](this._mt.sx, this._mt.shy, this._mt.shx, this._mt.sy, this._mt.tx, this._mt.ty); + + // ...и измерятелю + AscFonts.g_fontApplication.LoadFont(this.font.getName(), AscCommon.g_font_loader, this.fmgrGraphics[3], + this.font.getSize(), fontStyle, this.ppiX, this.ppiY); + + return this; } else { if (angle) { r = AscFonts.g_fontApplication.LoadFont(this.font.getName(), AscCommon.g_font_loader, this.fmgrGraphics[1], @@ -1042,12 +1006,9 @@ // Replace Non-breaking space(0xA0) with White-space(0x20) code = 0xA0 === code ? 0x20 : code; if (window["IS_NATIVE_EDITOR"]) { - //TODO: cache - // if (null != this.LastFontOriginInfo.Replace) - // code = g_fontApplication.GetReplaceGlyph(code, this.LastFontOriginInfo.Replace); - window["native"]["PD_FillText"](_x, _y, code); - _x += Asc.round(g_oTextMeasurer.Measurer["MeasureChar"](code)); + // убрать это!!! все сдвиги ДОЛЖНЫ быть вщять из измерятеля/шейпера + _x += asc_round((this.measureChar(undefined, 3, code).width) * this.scaleFactor * 96.0 / 25.4); } else { _x = asc_round(manager.LoadString4C(code, _x, _y)); pGlyph = manager.m_oGlyphString.m_pGlyphsBuffer[0]; diff --git a/cell/model/DataValidation.js b/cell/model/DataValidation.js index 524be55a1b..8138407603 100644 --- a/cell/model/DataValidation.js +++ b/cell/model/DataValidation.js @@ -1484,24 +1484,20 @@ CDataValidations.prototype._containRanges = function (_ranges1, _ranges2) { //проверка на то, что диапазон второго range входит в дипапазон первого + var res = false; if (_ranges1 && _ranges2 && _ranges1.length && _ranges2.length) { for (var j = 0; j < _ranges1.length; j++) { - var _contains = false; - for (var n = 0; n < _ranges2.length; n++) { - if (_ranges1[j].containsRange(_ranges2[n])) { - _contains = true; - break; - } - } - if (!_contains) { - return false; + //проверяем, вошёл ли целиком массив диапазонов второго в один из первых + if (_ranges1[j].containsRanges(_ranges2)) { + res = true; + break; } } } else { - return false; + res = false; } - return true; + return res; }; CDataValidations.prototype.clear = function (ws, ranges, addToHistory) { diff --git a/cell/model/DrawingObjects/Format/ShapePrototype.js b/cell/model/DrawingObjects/Format/ShapePrototype.js index 6837e2d8f7..c1f3e2bde3 100644 --- a/cell/model/DrawingObjects/Format/ShapePrototype.js +++ b/cell/model/DrawingObjects/Format/ShapePrototype.js @@ -39,7 +39,7 @@ var CShape = AscFormat.CShape; var History = AscCommon.History; -var G_O_DEFAULT_COLOR_MAP = AscFormat.GenerateDefaultColorMap(); + CShape.prototype.getEditorType = function() { @@ -837,7 +837,7 @@ CShape.prototype.recalculateContent = function() CShape.prototype.Get_ColorMap = function() { - return G_O_DEFAULT_COLOR_MAP; + return AscFormat.DEFAULT_COLOR_MAP; }; CShape.prototype.getStyles = function(index) @@ -895,6 +895,5 @@ AscFormat.CTextBody.prototype.getDrawingDocument = function() //------------------------------------------------------------export---------------------------------------------------- window['AscFormat'] = window['AscFormat'] || {}; - window['AscFormat'].G_O_DEFAULT_COLOR_MAP = G_O_DEFAULT_COLOR_MAP; window['AscFormat'].addToDrawings = addToDrawings; })(window); diff --git a/cell/model/Serialize.js b/cell/model/Serialize.js index 77e8c004c5..e8861ea530 100644 --- a/cell/model/Serialize.js +++ b/cell/model/Serialize.js @@ -7417,10 +7417,10 @@ if ( c_oSer_PivotTypes.id == type ) { pivotCache.id = this.stream.GetLong(); } else if ( c_oSer_PivotTypes.cache == type ) { - new openXml.SaxParserBase().parse(AscCommon.GetStringUtf8(this.stream, length), pivotCache); + new AscCommon.openXml.SaxParserBase().parse(AscCommon.GetStringUtf8(this.stream, length), pivotCache); } else if ( c_oSer_PivotTypes.record == type ) { var cacheRecords = new Asc.CT_PivotCacheRecords(); - new openXml.SaxParserBase().parse(AscCommon.GetStringUtf8(this.stream, length), cacheRecords); + new AscCommon.openXml.SaxParserBase().parse(AscCommon.GetStringUtf8(this.stream, length), cacheRecords); pivotCache.cacheRecords = cacheRecords; } else res = c_oSerConstants.ReadUnknown; @@ -8010,7 +8010,7 @@ data.cacheId = this.stream.GetLong(); } else if (c_oSer_PivotTypes.table == type) { data.table = new Asc.CT_pivotTableDefinition(true); - new openXml.SaxParserBase().parse(AscCommon.GetStringUtf8(this.stream, length), data.table); + new AscCommon.openXml.SaxParserBase().parse(AscCommon.GetStringUtf8(this.stream, length), data.table); } else res = c_oSerConstants.ReadUnknown; return res; @@ -10372,7 +10372,7 @@ newContext.readAttributes(attr, uq); } this.CustomStyles[newContext.name] = newContext; - openXml.SaxParserDataTransfer.curTableStyle = newContext; + AscCommon.openXml.SaxParserDataTransfer.curTableStyle = newContext; } else { newContext = null; } @@ -10631,7 +10631,7 @@ var val; val = vals["type"]; if(undefined !== val){ - var tableStyle = openXml.SaxParserDataTransfer.curTableStyle; + var tableStyle = AscCommon.openXml.SaxParserDataTransfer.curTableStyle; if("wholeTable"===val) tableStyle.wholeTable = this; else if("headerRow"===val) @@ -10695,7 +10695,7 @@ } val = vals["dxfId"]; if (undefined !== val) { - this.dxf = openXml.SaxParserDataTransfer.dxfs[tableStyle.pivot ? val - 0 : val - 1] || null; + this.dxf = AscCommon.openXml.SaxParserDataTransfer.dxfs[tableStyle.pivot ? val - 0 : val - 1] || null; } } }; @@ -10715,7 +10715,7 @@ var content = jsZipWrapper.files["presetTableStyles.xml"].sync("string"); jsZipWrapper.close(); var stylesXml = new CT_PresetTableStyles(wb.TableStyles.DefaultStyles, wb.TableStyles.DefaultStylesPivot); - new openXml.SaxParserBase().parse(content, stylesXml); + new AscCommon.openXml.SaxParserBase().parse(content, stylesXml); wb.TableStyles.concatStyles(); } } @@ -10962,7 +10962,7 @@ } this.fonts.push(newContext); } else if ("fills" === elem) { - openXml.SaxParserDataTransfer.priorityBg = false; + AscCommon.openXml.SaxParserDataTransfer.priorityBg = false; } else if ("fill" === elem) { newContext = new AscCommonExcel.Fill(); if (newContext.readAttributes) { @@ -10996,8 +10996,8 @@ // } // this.cellStyles = newContext; } else if ("dxfs" === elem) { - openXml.SaxParserDataTransfer.dxfs = this.dxfs; - openXml.SaxParserDataTransfer.priorityBg = true; + AscCommon.openXml.SaxParserDataTransfer.dxfs = this.dxfs; + AscCommon.openXml.SaxParserDataTransfer.priorityBg = true; } else if ("dxf" === elem) { newContext = new CT_Dxf(); if (newContext.readAttributes) { diff --git a/cell/model/SerializeXml.js b/cell/model/SerializeXml.js index 358919c913..cb3c00916a 100644 --- a/cell/model/SerializeXml.js +++ b/cell/model/SerializeXml.js @@ -2683,7 +2683,7 @@ let oRel = reader.rels.getRelationship(context.InitOpenManager.legacyDrawingId); let oRelPart = reader.rels.pkg.getPartByUri(oRel.targetFullName); let oContent = oRelPart.getDocumentContent(); - let oReader = new StaxParser(oContent, oRelPart, reader.context); + let oReader = new AscCommon.StaxParser(oContent, oRelPart, reader.context); let oElement = new AscFormat.CVMLDrawing(); if (oElement) { oElement.fromXml(oReader, true); diff --git a/cell/native/Graphics.js b/cell/native/Graphics.js index 91408ab72e..3a4005318b 100644 --- a/cell/native/Graphics.js +++ b/cell/native/Graphics.js @@ -789,7 +789,7 @@ CGraphics.prototype = oFontStyle = AscFonts.FontStyle.FontStyleBoldItalic; var _fontinfo = AscFonts.g_fontApplication.GetFontInfo(font.FontFamily.Name, oFontStyle, this.LastFontOriginInfo); - var _info = GetLoadInfoForMeasurer(_fontinfo, oFontStyle); + var _info = AscCommon.GetLoadInfoForMeasurer(_fontinfo, oFontStyle); this.m_oLastFont.SetUpName = font.FontFamily.Name; this.m_oLastFont.SetUpSize = font.FontSize; @@ -801,8 +801,6 @@ CGraphics.prototype = if (_info.SrcBold) flag |= 0x04; if (_info.SrcItalic) flag |= 0x08; - g_oTextMeasurer.Measurer["LoadFont"](_info.Path, _info.FaceIndex, font.FontSize, flag); - this.Native["PD_LoadFont"](_info.Path, _info.FaceIndex, font.FontSize, flag); }, @@ -875,7 +873,7 @@ CGraphics.prototype = _lastFont.SetUpStyle = _style; var _fontinfo = AscFonts.g_fontApplication.GetFontInfo(_lastFont.SetUpName, _lastFont.SetUpStyle, this.LastFontOriginInfo); - var _info = GetLoadInfoForMeasurer(_fontinfo, _lastFont.SetUpStyle); + var _info = AscCommon.GetLoadInfoForMeasurer(_fontinfo, _lastFont.SetUpStyle); var flag = 0; if (_info.NeedBold) flag |= 0x01; @@ -883,8 +881,6 @@ CGraphics.prototype = if (_info.SrcBold) flag |= 0x04; if (_info.SrcItalic) flag |= 0x08; - g_oTextMeasurer.Measurer["LoadFont"](_info.Path, _info.FaceIndex, _lastFont.SetUpSize, flag); - this.Native["PD_LoadFont"](_info.Path, _info.FaceIndex, _lastFont.SetUpSize, flag); } }, diff --git a/cell/native/native.js b/cell/native/native.js index 24297eff9f..f33538782a 100644 --- a/cell/native/native.js +++ b/cell/native/native.js @@ -2755,8 +2755,6 @@ function OfflineEditor () { window['AscFormat'].DrawingArea.prototype.drawSelection = function(drawingDocument) { - AscCommon.g_oTextMeasurer.Flush(); - var canvas = this.worksheet.objectRender.getDrawingCanvas(); var shapeCtx = canvas.shapeCtx; var shapeOverlayCtx = canvas.shapeOverlayCtx; @@ -3000,8 +2998,6 @@ function OfflineEditor () { window["native"]["SwitchMemoryLayer"](); - AscCommon.g_oTextMeasurer.Flush(); - this.objectRender.showDrawingObjectsEx(); this.cellsLeft = cellsLeft_Local; @@ -4427,14 +4423,10 @@ var _s = new OfflineEditor(); window["native"]["offline_of"] = function(arg) {_s.openFile(arg);} window["native"]["offline_stz"] = function(v) {_s.zoom = v; _api.asc_setZoom(v);} -window["native"]["offline_ds"] = function(x, y, width, height, ratio, istoplayer) { - AscCommon.g_oTextMeasurer.Flush(); - +window["native"]["offline_ds"] = function(x, y, width, height, ratio, istoplayer) { _s.drawSheet(x, y, width, height, ratio, istoplayer); } window["native"]["offline_dh"] = function(x, y, width, height, ratio, type) { - AscCommon.g_oTextMeasurer.Flush(); - _s.drawHeader(x, y, width, height, type, ratio); } @@ -4731,8 +4723,6 @@ window["native"]["offline_keyboard_down"] = function(inputKeys) { var wb = _api.wb; var ws = _api.wb.getWorksheet(); - AscCommon.g_oTextMeasurer.Flush(); - var isFormulaEditMode = wb.isFormulaEditMode; wb.isFormulaEditMode = false; @@ -5409,17 +5399,13 @@ window["native"]["offline_apply_event"] = function(type,params) { // document interface case 3: // ASC_MENU_EVENT_TYPE_UNDO - { - AscCommon.g_oTextMeasurer.Flush(); - + { _api.asc_Undo(); _s.asc_WriteAllWorksheets(true); break; } case 4: // ASC_MENU_EVENT_TYPE_REDO { - AscCommon.g_oTextMeasurer.Flush(); - _api.asc_Redo(); _s.asc_WriteAllWorksheets(true); break; diff --git a/cell/utils/utils.js b/cell/utils/utils.js index 35897d3baa..e9ab13b80c 100644 --- a/cell/utils/utils.js +++ b/cell/utils/utils.js @@ -520,6 +520,18 @@ return this.contains(range.c1, range.r1) && this.contains(range.c2, range.r2); }; + Range.prototype.containsRanges = function (ranges) { + if (ranges && ranges.length) { + for (var i = 0; i < ranges.length; i++) { + if (!this.containsRange(ranges[i])) { + return false; + } + } + return true; + } + return false; + }; + Range.prototype.containsFirstLineRange = function (range) { return this.contains(range.c1, range.r1) && this.contains(range.c2, range.r1); }; diff --git a/cell/view/StringRender.js b/cell/view/StringRender.js index 356ef23257..9e8b4c71f9 100644 --- a/cell/view/StringRender.js +++ b/cell/view/StringRender.js @@ -1092,6 +1092,10 @@ } if (isSO || ul) { + + if (angle && window["IS_NATIVE_EDITOR"]) + ctx.nativeTextDecorationTransform(true); + x2 = x1 + dw; fsz = prop.font.getSize(); lw = asc_round(fsz * ppiy / 72 / 18) || 1; @@ -1109,6 +1113,9 @@ ctx.lineHor(x1, y - dy, x2 + 1/*px*/); // ToDo вопрос тут } ctx.stroke(); + + if (angle && window["IS_NATIVE_EDITOR"]) + ctx.nativeTextDecorationTransform(false); } return dw; diff --git a/common/Charts/DrawingArea.js b/common/Charts/DrawingArea.js index 33e270be3d..c84f99158b 100755 --- a/common/Charts/DrawingArea.js +++ b/common/Charts/DrawingArea.js @@ -816,9 +816,6 @@ DrawingArea.prototype.reinitRanges = function() { }; DrawingArea.prototype.drawSelection = function(drawingDocument) { - if (window["IS_NATIVE_EDITOR"]) { - AscCommon.g_oTextMeasurer.Flush(); - } var oWS = this.worksheet; var canvas = oWS.objectRender.getDrawingCanvas(); var shapeCtx = canvas.shapeCtx; diff --git a/common/Drawings/CommonController.js b/common/Drawings/CommonController.js index 750ca44bdb..3a25b3a6a1 100644 --- a/common/Drawings/CommonController.js +++ b/common/Drawings/CommonController.js @@ -3927,7 +3927,7 @@ DrawingObjectsController.prototype = getColorMap: function() { - return AscFormat.G_O_DEFAULT_COLOR_MAP; + return AscFormat.DEFAULT_COLOR_MAP }, diff --git a/common/Drawings/Externals.js b/common/Drawings/Externals.js index db895d19e4..1c596f46ff 100644 --- a/common/Drawings/Externals.js +++ b/common/Drawings/Externals.js @@ -515,13 +515,6 @@ function CFontFileLoader(id) this.LoadFontNative = function() { - if (window["use_native_fonts_only"] === true) - { - // all font engine now native - this.Status = 0; - return; - } - var __font_data_idx = g_fonts_streams.length; var _data = window["native"]["GetFontBinary"](this.Id); g_fonts_streams[__font_data_idx] = new AscFonts.FontStream(_data, _data.length); diff --git a/common/Drawings/Format/ChartFormat.js b/common/Drawings/Format/ChartFormat.js index dd4166d9d9..e9661c860b 100644 --- a/common/Drawings/Format/ChartFormat.js +++ b/common/Drawings/Format/ChartFormat.js @@ -2976,7 +2976,7 @@ return this.series.Get_ColorMap(); } } - return AscFormat.G_O_DEFAULT_COLOR_MAP; + return AscFormat.DEFAULT_COLOR_MAP; }; CDLbl.prototype.Get_AbsolutePage = function() { if(this.chart && this.chart.Get_AbsolutePage) { diff --git a/common/Drawings/Format/Format.js b/common/Drawings/Format/Format.js index 5160a9e474..b8f93a1779 100644 --- a/common/Drawings/Format/Format.js +++ b/common/Drawings/Format/Format.js @@ -1065,7 +1065,7 @@ } else if (master.clrMap) { color_map = master.clrMap; } else { - color_map = AscFormat.G_O_DEFAULT_COLOR_MAP; + color_map = AscFormat.DEFAULT_COLOR_MAP; } checkObjectUnifill(cellPr.Shd, theme, color_map); @@ -2874,8 +2874,8 @@ writer.WriteXmlNodeStart(sName_); writer.WriteXmlNullableAttributeUInt("l", getPercentageValueForWrite(this.l)); writer.WriteXmlNullableAttributeUInt("t", getPercentageValueForWrite(this.t)); - writer.WriteXmlNullableAttributeUInt("r", getPercentageValueForWrite(this.r)); - writer.WriteXmlNullableAttributeUInt("b", getPercentageValueForWrite(this.b)); + writer.WriteXmlNullableAttributeUInt("r", 100000 - getPercentageValueForWrite(this.r)); + writer.WriteXmlNullableAttributeUInt("b", 100000 - getPercentageValueForWrite(this.b)); writer.WriteXmlAttributesEnd(true); }; @@ -3222,25 +3222,11 @@ CBlip.prototype.toXml = function (writer, sNamespace, sRasterImageId) { let sNamespace_ = sNamespace || "a"; let strName = ("" === sNamespace_) ? ("blip") : (sNamespace_ + (":blip")); - var context = writer.context; - var imagePart = context.imageMap[sRasterImageId]; - if (!imagePart) { - if (context.part) { - var ext = AscCommon.GetFileExtension(sRasterImageId); - var type = context.editorId === AscCommon.c_oEditorId.Word ? AscCommon.openXml.Types.imageWord : AscCommon.openXml.Types.image; - type = Object.assign({}, type); - type.filename += ext; - type.contentType = AscCommon.openXml.GetMimeType(ext); - imagePart = context.part.addPart(type); - if (imagePart) { - context.imageMap[sRasterImageId] = imagePart; - } - } - } + let context = writer.context; //writer.WriteXmlNullable(blip); writer.WriteXmlNodeStart(strName); writer.WriteXmlString(' xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"'); - writer.WriteXmlAttributeString("r:embed", imagePart && imagePart.rId || ""); + writer.WriteXmlAttributeString("r:embed", context.getImageRId(sRasterImageId)); writer.WriteXmlAttributesEnd(); writer.WriteXmlString(''); writer.WriteXmlNodeEnd(strName); @@ -8279,7 +8265,7 @@ //writer.WriteXmlNullableAttributeBool("title", this.form); if(this.hlinkClick || this.hlinkHover) { - let sNS = StaxParser.prototype.GetNSFromNodeName(name); + let sNS = AscCommon.StaxParser.prototype.GetNSFromNodeName(name); writer.WriteXmlAttributesEnd(); writer.WriteXmlNullable(this.hlinkClick, sNS + ":hlinkClick"); writer.WriteXmlNullable(this.hlinkHover, sNS + ":hlinkHover"); @@ -9448,7 +9434,7 @@ writer.WriteXmlAttributesEnd(); this.cNvPr.toXml(writer, namespace_ + ":cNvPr"); - this.nvUniSpPr.toXmlSp(writer); + this.nvUniSpPr.toXmlGrSp(writer); if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_PPTX) { @@ -10730,6 +10716,28 @@ writer.WriteXmlAttributesEnd(true); } }; + CSpPr.prototype.toXmlGroup = function(writer) { + let namespace_ = "a"; + if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_DOCX || + writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) namespace_ = "wpg"; + else if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_XLSX) namespace_ = "xdr"; + else if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = "a"; + else if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_CHART_DRAWING) namespace_ = "cdr"; + else if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_DIAGRAM) namespace_ = "dgm"; + else if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_DSP_DRAWING) namespace_ = "dsp"; + else if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_PPTX) namespace_ = "p"; + + writer.WriteXmlNodeStart(namespace_ + ":grpSpPr"); + writer.WriteXmlAttributeString("bwMode", "auto"); + writer.WriteXmlAttributesEnd(); + + writer.WriteXmlNullable(this.xfrm, "a:xfrm"); + writer.WriteXmlNullable(this.Fill); + writer.WriteXmlNullable(this.effectProps); + //writer.Write(scene3d); + + writer.WriteXmlNodeEnd(namespace_ + ":grpSpPr"); + }; // ---------------------------------- // THEME ---------------------------- @@ -10912,6 +10920,9 @@ InitClass(ClrMap, CBaseFormatObject, AscDFH.historyitem_type_ClrMap); ClrMap.prototype.Refresh_RecalcData = function () { }; + ClrMap.prototype.notAllowedWithoutId = function () { + return false; + }; ClrMap.prototype.createDuplicate = function () { var _copy = new ClrMap(); for (var _color_index = g_clr_MIN; _color_index <= this.color_map.length; ++_color_index) { @@ -11233,7 +11244,7 @@ }; ClrMap.prototype.toXmlWord = function (writer, name) { writer.WriteXmlNodeStart(name); - let ns = StaxParser.prototype.GetNSFromNodeName(name); + let ns = AscCommon.StaxParser.prototype.GetNSFromNodeName(name); for (let i in this.color_map) { if (this.color_map.hasOwnProperty(i)) { let name = this.SchemeClr_GetStringCodeWord(parseInt(i)); @@ -11762,6 +11773,9 @@ InitClass(CTheme, CBaseFormatObject, 0); + CTheme.prototype.notAllowedWithoutId = function () { + return false; + }; CTheme.prototype.createDuplicate = function () { var oTheme = new CTheme(); oTheme.setName(this.name); @@ -12111,7 +12125,7 @@ break; } case "sldNum": { - this.setSlideNum(reader.GetValueBool()); + this.setSldNum(reader.GetValueBool()); break; } } @@ -12507,7 +12521,7 @@ } return oSp; }; - CSpTree.prototype.toXml = function (writer) { + CSpTree.prototype.toXml = function (writer, bGroup) { let name_; if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_DOCX || @@ -12539,7 +12553,13 @@ } if (this.spPr) { - this.spPr.toXml(writer); + if(bGroup) { + this.spPr.toXmlGroup(writer); + } + else { + + this.spPr.toXml(writer); + } } writer.context.groupIndex++; @@ -14858,7 +14878,7 @@ switch (name) { case "val": { if (this.type === AscFormat.BULLET_TYPE_SIZE_PCT) { - this.val = getPercentageValue(reader.GetValue()); + this.val = reader.GetValueInt(); } else if (this.type === AscFormat.BULLET_TYPE_SIZE_PTS) { this.val = reader.GetValueInt(); } @@ -14871,7 +14891,7 @@ if (this.type === AscFormat.BULLET_TYPE_SIZE_PCT) { writer.WriteXmlNodeStart("a:buSzPct"); - writer.WriteXmlNullableAttributeInt("val", getPercentageValueForWrite(this.val)); + writer.WriteXmlNullableAttributeInt("val", this.val); writer.WriteXmlAttributesEnd(); writer.WriteXmlNodeEnd("a:buSzPct"); } else if (this.type === AscFormat.BULLET_TYPE_SIZE_PTS) { diff --git a/common/Drawings/Format/GraphicFrame.js b/common/Drawings/Format/GraphicFrame.js index 9b79b4e4df..d73971c6bd 100644 --- a/common/Drawings/Format/GraphicFrame.js +++ b/common/Drawings/Format/GraphicFrame.js @@ -1460,7 +1460,7 @@ CGraphicFrame.prototype.Is_ThisElementCurrent = function() writer.WriteXmlNodeStart(sName); writer.WriteXmlAttributesEnd(); - var ns = StaxParser.prototype.GetNSFromNodeName(sName); + var ns = AscCommon.StaxParser.prototype.GetNSFromNodeName(sName); let oSpTreeDrawing = this.getSpTreeDrawing(); diff --git a/common/Drawings/Format/GraphicObjectBase.js b/common/Drawings/Format/GraphicObjectBase.js index a56526116b..4c6aa73831 100644 --- a/common/Drawings/Format/GraphicObjectBase.js +++ b/common/Drawings/Format/GraphicObjectBase.js @@ -2219,7 +2219,7 @@ oImage.pen = AscFormat.CreatePenBrushForChartTrack().pen; oImage.parent = this.parent; var oParentObjects = this.getParentObjects(); - oImage.cropBrush.calculate(oParentObjects.theme, oParentObjects.slide, oParentObjects.layout, oParentObjects.master, {R:0, G:0, B:0, A:255, needRecalc: true}, AscFormat.G_O_DEFAULT_COLOR_MAP); + oImage.cropBrush.calculate(oParentObjects.theme, oParentObjects.slide, oParentObjects.layout, oParentObjects.master, {R:0, G:0, B:0, A:255, needRecalc: true}, AscFormat.DEFAULT_COLOR_MAP); this.cropObject = oImage; return true; } diff --git a/common/Drawings/Format/GroupShape.js b/common/Drawings/Format/GroupShape.js index 1fb00e73a4..7acb88b005 100644 --- a/common/Drawings/Format/GroupShape.js +++ b/common/Drawings/Format/GroupShape.js @@ -2047,7 +2047,7 @@ function CGroupShape() }; CGroupShape.prototype.toXml = function (writer) { writer.context.groupIndex++; - AscFormat.CSpTree.prototype.toXml.call(this, writer); + AscFormat.CSpTree.prototype.toXml.call(this, writer, true); writer.context.groupIndex--; }; CGroupShape.prototype.checkXfrm = function () { diff --git a/common/Drawings/Format/Shape.js b/common/Drawings/Format/Shape.js index c41fe34eb7..ec3468cd65 100644 --- a/common/Drawings/Format/Shape.js +++ b/common/Drawings/Format/Shape.js @@ -6789,9 +6789,6 @@ CShape.prototype.checkTextWarp = function(oContent, oBodyPr, dWidth, dHeight, bN { return AscFormat.ExecuteNoHistory(function(){ var oRet = {oTxWarpStruct: null, oTxWarpStructParamarks: null, oTxWarpStructNoTransform: null, oTxWarpStructParamarksNoTransform: null}; - if(window["IS_NATIVE_EDITOR"]){ - return oRet; - } //return oRet; var bTransform = this.chekBodyPrTransform(oBodyPr) && bNeedWarp; var warpGeometry = oBodyPr.prstTxWarp; diff --git a/common/Native/Wrappers/DrawingStream.js b/common/Native/Wrappers/DrawingStream.js index 513039bd3d..0534b9357a 100755 --- a/common/Native/Wrappers/DrawingStream.js +++ b/common/Native/Wrappers/DrawingStream.js @@ -956,7 +956,7 @@ CDrawingStream.prototype = oFontStyle = AscFonts.FontStyle.FontStyleBoldItalic; var _fontinfo = AscFonts.g_fontApplication.GetFontInfo(font.FontFamily.Name, oFontStyle, this.LastFontOriginInfo); - var _info = GetLoadInfoForMeasurer(_fontinfo, oFontStyle); + var _info = AscCommon.GetLoadInfoForMeasurer(_fontinfo, oFontStyle); var flag = 0; if (_info.NeedBold) flag |= 0x01; @@ -1045,7 +1045,7 @@ CDrawingStream.prototype = _lastFont.SetUpStyle = _style; var _fontinfo = AscFonts.g_fontApplication.GetFontInfo(_lastFont.SetUpName, _lastFont.SetUpStyle, this.LastFontOriginInfo); - var _info = GetLoadInfoForMeasurer(_fontinfo, _lastFont.SetUpStyle); + var _info = AscCommon.GetLoadInfoForMeasurer(_fontinfo, _lastFont.SetUpStyle); var flag = 0; if (_info.NeedBold) flag |= 0x01; diff --git a/common/Native/Wrappers/TextMeasurerWrapper.js b/common/Native/Wrappers/TextMeasurerWrapper.js deleted file mode 100755 index ccd2d68c9a..0000000000 --- a/common/Native/Wrappers/TextMeasurerWrapper.js +++ /dev/null @@ -1,449 +0,0 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2019 - * - * 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-12 Ernesta Birznieka-Upisha - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ - -function CTextMeasurerWrapper() -{ - this.Measurer = CreateNativeTextMeasurer(); - - this.m_oFont = null; - - // RFonts - this.m_oTextPr = null; - this.m_oGrFonts = new AscCommon.CGrRFonts(); - this.m_oLastFont = new AscCommon.CFontSetup(); - - this.LastFontOriginInfo = { Name : "", Replace : null }; - - // font params - this.Ascender = 0; - this.Descender = 0; - this.Height = 0; - this.UnitsPerEm = 0; -} - -CTextMeasurerWrapper.prototype = -{ - SetParams : function(params) - { - // TODO: set params to native engine - }, - - Init : function() - { - this.Measurer["Initialize"](window["native"]); - }, - - SetFont : function(font) - { - if (!font) - return; - - this.m_oFont = font; - - var bItalic = true === font.Italic; - var bBold = true === font.Bold; - - var oFontStyle = AscFonts.FontStyle.FontStyleRegular; - if ( !bItalic && bBold ) - oFontStyle = AscFonts.FontStyle.FontStyleBold; - else if ( bItalic && !bBold ) - oFontStyle = AscFonts.FontStyle.FontStyleItalic; - else if ( bItalic && bBold ) - oFontStyle = AscFonts.FontStyle.FontStyleBoldItalic; - - this.SetFontInternal(font.FontFamily.Name, font.FontSize, oFontStyle); - }, - - SetFontInternal : function(_name, _size, _style) - { - var _lastSetUp = this.m_oLastFont; - if (_lastSetUp.SetUpName != _name || _lastSetUp.SetUpSize != _size || _lastSetUp.SetUpStyle != _style) - { - _lastSetUp.SetUpName = _name; - _lastSetUp.SetUpSize = _size; - _lastSetUp.SetUpStyle = _style; - - var _fontinfo = AscFonts.g_fontApplication.GetFontInfo(_lastSetUp.SetUpName, _lastSetUp.SetUpStyle, this.LastFontOriginInfo); - var _info = GetLoadInfoForMeasurer(_fontinfo, _lastSetUp.SetUpStyle); - - var flag = 0; - if (_info.NeedBold) flag |= 0x01; - if (_info.NeedItalic) flag |= 0x02; - if (_info.SrcBold) flag |= 0x04; - if (_info.SrcItalic) flag |= 0x08; - - var _bounds = this.Measurer["LoadFont"](_info.Path, _info.FaceIndex, _lastSetUp.SetUpSize, flag); - - this.UnitsPerEm = _bounds[3]; - var dKoef = g_dKoef_pt_to_mm * _lastSetUp.SetUpSize / this.UnitsPerEm; - this.Ascender = _bounds[0] * dKoef; - this.Descender = _bounds[1] * dKoef; - this.Height = _bounds[2] * dKoef; - } - }, - - SetTextPr : function(textPr, theme) - { - if (theme && textPr && textPr.ReplaceThemeFonts) - textPr.ReplaceThemeFonts(theme.themeElements.fontScheme); - - this.m_oTextPr = textPr; - if (theme) - this.m_oGrFonts.checkFromTheme(theme.themeElements.fontScheme, this.m_oTextPr.RFonts); - else - this.m_oGrFonts = this.m_oTextPr.RFonts; - }, - - SetFontSlot : function(slot, fontSizeKoef) - { - var _rfonts = this.m_oGrFonts; - var _lastFont = this.m_oLastFont; - - switch (slot) - { - case fontslot_ASCII: - { - _lastFont.Name = _rfonts.Ascii.Name; - _lastFont.Size = this.m_oTextPr.FontSize; - _lastFont.Bold = this.m_oTextPr.Bold; - _lastFont.Italic = this.m_oTextPr.Italic; - - break; - } - case fontslot_CS: - { - _lastFont.Name = _rfonts.CS.Name; - _lastFont.Size = this.m_oTextPr.FontSizeCS; - _lastFont.Bold = this.m_oTextPr.BoldCS; - _lastFont.Italic = this.m_oTextPr.ItalicCS; - - break; - } - case fontslot_EastAsia: - { - _lastFont.Name = _rfonts.EastAsia.Name; - _lastFont.Index = _rfonts.EastAsia.Index; - _lastFont.Size = this.m_oTextPr.FontSize; - _lastFont.Bold = this.m_oTextPr.Bold; - _lastFont.Italic = this.m_oTextPr.Italic; - - break; - } - case fontslot_HAnsi: - default: - { - _lastFont.Name = _rfonts.HAnsi.Name; - _lastFont.Index = _rfonts.HAnsi.Index; - _lastFont.Size = this.m_oTextPr.FontSize; - _lastFont.Bold = this.m_oTextPr.Bold; - _lastFont.Italic = this.m_oTextPr.Italic; - - break; - } - } - - if (undefined !== fontSizeKoef) - _lastFont.Size *= fontSizeKoef; - - var _style = 0; - if (_lastFont.Italic) - _style += 2; - if (_lastFont.Bold) - _style += 1; - - this.SetFontInternal(_lastFont.Name, _lastFont.Size, _style); - }, - - GetTextPr : function() - { - return this.m_oTextPr; - }, - - GetFont : function() - { - return this.m_oFont; - }, - - Measure : function(text) - { - var _code = text.charCodeAt(0); - if (null != this.LastFontOriginInfo.Replace) - _code = AscFonts.g_fontApplication.GetReplaceGlyph(_code, this.LastFontOriginInfo.Replace); - - var _width = this.Measurer["MeasureChar"](_code); - return { Width : _width, Height : 0 }; - }, - Measure2 : function(text) - { - var _code = text.charCodeAt(0); - if (null != this.LastFontOriginInfo.Replace) - _code = AscFonts.g_fontApplication.GetReplaceGlyph(_code, this.LastFontOriginInfo.Replace); - - var _bounds = this.Measurer["GetDrawingBox"](_code); - - return { - Width : _bounds[0], - Ascent : _bounds[4], - Height : _bounds[4] - _bounds[3], - WidthG : _bounds[2] - _bounds[1], - rasterOffsetX: 0, - rasterOffsetY: 0 - }; - }, - - MeasureCode : function(lUnicode) - { - if (null != this.LastFontOriginInfo.Replace) - lUnicode = AscFonts.g_fontApplication.GetReplaceGlyph(lUnicode, this.LastFontOriginInfo.Replace); - - var _bounds = this.Measurer["GetDrawingBox"](lUnicode); - - return { - Width : _bounds[0], - Ascent : _bounds[4], - Height : _bounds[4] - _bounds[3] - }; - }, - Measure2Code : function(lUnicode) - { - if (null != this.LastFontOriginInfo.Replace) - lUnicode = AscFonts.g_fontApplication.GetReplaceGlyph(lUnicode, this.LastFontOriginInfo.Replace); - - var _bounds = this.Measurer["GetDrawingBox"](lUnicode); - - return { - Width : _bounds[0], - Ascent : _bounds[4], - Height : _bounds[4] - _bounds[3], - WidthG : _bounds[2] - _bounds[1], - rasterOffsetX: 0, - rasterOffsetY: 0 - }; - }, - - GetAscender : function() - { - return this.Ascender; - }, - GetDescender : function() - { - return this.Descender; - }, - GetHeight : function() - { - return this.Height; - }, - GetLimitsY : function() - { - var _limits = this.Measurer["GetLimitsY"](); - var dKoef = g_dKoef_pt_to_mm * this.m_oLastFont.SetUpSize / this.UnitsPerEm; - - return { - min : _limits[0] * dKoef, - max : _limits[1] * dKoef - }; - }, - - Flush : function() - { - this.m_oFont = null; - this.m_oTextPr = null; - this.m_oGrFonts = new AscCommon.CGrRFonts(); - this.m_oLastFont = new AscCommon.CFontSetup(); - this.LastFontOriginInfo = { Name : "", Replace : null }; - this.Ascender = 0; - this.Descender = 0; - this.Height = 0; - this.UnitsPerEm = 0; - } -}; - -function GetLoadInfoForMeasurer(info, lStyle) -{ - // подбираем шрифт по стилю - var sReturnName = info.Name; - var bNeedBold = false; - var bNeedItalic = false; - - var index = -1; - var faceIndex = 0; - - var bSrcItalic = false; - var bSrcBold = false; - - switch (lStyle) - { - case AscFonts.FontStyle.FontStyleBoldItalic: - { - bSrcItalic = true; - bSrcBold = true; - - bNeedBold = true; - bNeedItalic = true; - if (-1 != info.indexBI) - { - index = info.indexBI; - faceIndex = info.faceIndexBI; - bNeedBold = false; - bNeedItalic = false; - } - else if (-1 != info.indexB) - { - index = info.indexB; - faceIndex = info.faceIndexB; - bNeedBold = false; - } - else if (-1 != info.indexI) - { - index = info.indexI; - faceIndex = info.faceIndexI; - bNeedItalic = false; - } - else - { - index = info.indexR; - faceIndex = info.faceIndexR; - } - break; - } - case AscFonts.FontStyle.FontStyleBold: - { - bSrcBold = true; - - bNeedBold = true; - bNeedItalic = false; - if (-1 != info.indexB) - { - index = info.indexB; - faceIndex = info.faceIndexB; - bNeedBold = false; - } - else if (-1 != info.indexR) - { - index = info.indexR; - faceIndex = info.faceIndexR; - } - else if (-1 != info.indexBI) - { - index = info.indexBI; - faceIndex = info.faceIndexBI; - bNeedBold = false; - } - else - { - index = info.indexI; - faceIndex = info.faceIndexI; - } - break; - } - case AscFonts.FontStyle.FontStyleItalic: - { - bSrcItalic = true; - - bNeedBold = false; - bNeedItalic = true; - if (-1 != info.indexI) - { - index = info.indexI; - faceIndex = info.faceIndexI; - bNeedItalic = false; - } - else if (-1 != info.indexR) - { - index = info.indexR; - faceIndex = info.faceIndexR; - } - else if (-1 != info.indexBI) - { - index = info.indexBI; - faceIndex = info.faceIndexBI; - bNeedItalic = false; - } - else - { - index = info.indexB; - faceIndex = info.faceIndexB; - } - break; - } - case AscFonts.FontStyle.FontStyleRegular: - { - bNeedBold = false; - bNeedItalic = false; - if (-1 != info.indexR) - { - index = info.indexR; - faceIndex = info.faceIndexR; - } - else if (-1 != info.indexI) - { - index = info.indexI; - faceIndex = info.faceIndexI; - } - else if (-1 != info.indexB) - { - index = info.indexB; - faceIndex = info.faceIndexB; - } - else - { - index = info.indexBI; - faceIndex = info.faceIndexBI; - } - } - } - - return { - Path : AscFonts.g_font_files[index].Id, - FaceIndex : faceIndex, - NeedBold : bNeedBold, - NeedItalic : bNeedItalic, - SrcBold : bSrcBold, - SrcItalic : bSrcItalic - }; -} - -CTextMeasurerWrapper.prototype["Init"] = CTextMeasurerWrapper.prototype.Init; - -window["CreateTextMeasurerWrapper"] = function() -{ - return new CTextMeasurerWrapper(); -}; -window["CreateMainTextMeasurerWrapper"] = function() -{ - g_oTextMeasurer = new CTextMeasurerWrapper(); - AscCommon.g_oTextMeasurer = g_oTextMeasurer; - g_oTextMeasurer.Init(); - window['AscCommon'].g_oTextMeasurer = g_oTextMeasurer; - - return AscCommon.g_oTextMeasurer.Measurer; -}; diff --git a/common/Native/Wrappers/api.js b/common/Native/Wrappers/api.js index e57897474c..2e343e119f 100755 --- a/common/Native/Wrappers/api.js +++ b/common/Native/Wrappers/api.js @@ -5576,12 +5576,6 @@ FontStyleUnderline: 4, FontStyleStrikeout: 8 }; -function CFontManager() -{ - this.m_oLibrary = {}; - this.Initialize = function(){}; -} - function CStylesPainter() { this.STYLE_THUMBNAIL_WIDTH = AscCommon.GlobalSkin.STYLE_THUMBNAIL_WIDTH; @@ -6224,8 +6218,6 @@ function initSpellCheckApi() { function NativeOpenFile3(_params, documentInfo) { - window["CreateMainTextMeasurerWrapper"](); - window.g_file_path = "native_open_file"; window.NATIVE_DOCUMENT_TYPE = window["native"]["GetEditorType"](); var doc_bin = window["native"]["GetFileString"](window.g_file_path); diff --git a/common/Native/Wrappers/memory.js b/common/Native/Wrappers/memory.js index bbbc876bd2..53e11d0915 100755 --- a/common/Native/Wrappers/memory.js +++ b/common/Native/Wrappers/memory.js @@ -703,16 +703,6 @@ window['AscFonts'].FT_Memory = FT_Memory; window['AscFonts'].FT_Stream = FT_Stream; window['AscFonts'].g_memory = g_memory; -window['AscFonts'].CFontManager = function CFontManager() { - this.m_pFont = null; - this.m_oFontsCache = { Fonts : {} }; - this.Initialize = function(){}; - this.SetHintsProps = function(){}; - this.LoadFont = function(){}; - this.ClearRasterMemory = function(){}; - this.ClearFontsRasterCache = function(){}; -}; - // FT_Common function _FT_Common() { this.UintToInt = function(v) diff --git a/common/SerializeMathXml.js b/common/SerializeMathXml.js index c607269668..99b905234b 100644 --- a/common/SerializeMathXml.js +++ b/common/SerializeMathXml.js @@ -1280,7 +1280,7 @@ let count = 0; let mcJc = MCJC_CENTER; if (elem.members["mcPr"].members["count"]) { - count = StaxParser.prototype.GetUInt(elem.members["mcPr"].members["count"].attributes["val"], count); + count = AscCommon.StaxParser.prototype.GetUInt(elem.members["mcPr"].members["count"].attributes["val"], count); } if (elem.members["mcPr"].members["mcJc"]) { mcJc = fromXml_ST_XAlignMath(elem.members["mcPr"].members["mcJc"].attributes["val"], mcJc); diff --git a/common/Shapes/Serialize.js b/common/Shapes/Serialize.js index 6d4d3dd8c0..00561a16d0 100644 --- a/common/Shapes/Serialize.js +++ b/common/Shapes/Serialize.js @@ -10407,7 +10407,7 @@ function BinaryPPTYLoader() }); } else { var oMath = new ParaMath(); - par.AddToContentEnd(oMath); + par.AddToContentToEnd(oMath); boMathr.bcr.Read1(nDocLength, function(t, l){ return boMathr.ReadMathArg(t,l,oMath.Root,par); }); diff --git a/common/Shapes/SerializeWriter.js b/common/Shapes/SerializeWriter.js index 2b87714451..bc58ee6f4b 100644 --- a/common/Shapes/SerializeWriter.js +++ b/common/Shapes/SerializeWriter.js @@ -3138,12 +3138,12 @@ function CBinaryFileWriter() var _num = (fill.srcRect.t * 1000) >> 0; oThis._WriteString1(1, "" + _num); } - if (fill.srcRect.l != null) + if (fill.srcRect.r != null) { var _num = ((100 - fill.srcRect.r) * 1000) >> 0; oThis._WriteString1(2, "" + _num); } - if (fill.srcRect.l != null) + if (fill.srcRect.b != null) { var _num = ((100 - fill.srcRect.b) * 1000) >> 0; oThis._WriteString1(3, "" + _num); diff --git a/common/Shapes/SerializeXml.js b/common/Shapes/SerializeXml.js index 43bbb8e513..6b37f327b8 100644 --- a/common/Shapes/SerializeXml.js +++ b/common/Shapes/SerializeXml.js @@ -203,7 +203,7 @@ var chartPart = reader.rels.pkg.getPartByUri(rel.targetFullName); if (chartPart) { var chartContent = chartPart.getDocumentContent(); - var chartReader = new StaxParser(chartContent, chartPart, reader.context); + var chartReader = new AscCommon.StaxParser(chartContent, chartPart, reader.context); res = new AscFormat.CChartSpace(); res.fromXml(chartReader); @@ -214,7 +214,7 @@ let chartStyleContent = chartStylePart.getDocumentContent(); if (chartStyleContent) { let chartStyle = new AscFormat.CChartStyle(); - let readerStyle = new StaxParser(chartStyleContent, chartStylePart, reader.context); + let readerStyle = new AscCommon.StaxParser(chartStyleContent, chartStylePart, reader.context); chartStyle.fromXml(readerStyle); res.setChartStyle(chartStyle); } @@ -224,7 +224,7 @@ let chartColorStyleContent = chartColorStylePart.getDocumentContent(); if (chartColorStyleContent) { let chartStyle = new AscFormat.CChartColors(); - let readerStyle = new StaxParser(chartColorStyleContent, chartColorStylePart, reader.context); + let readerStyle = new AscCommon.StaxParser(chartColorStyleContent, chartColorStylePart, reader.context); chartStyle.fromXml(readerStyle); res.setChartColors(chartStyle); } diff --git a/common/editorscommon.js b/common/editorscommon.js index be0c93376e..3d1b0d1d0c 100644 --- a/common/editorscommon.js +++ b/common/editorscommon.js @@ -9974,7 +9974,7 @@ const drawInfo = infoOfDrawings[i]; const type = drawInfo.type; const bullet = new AscCommonWord.CPresentationBullet(); - const textPr = new CTextPr(); + const textPr = new AscCommonWord.CTextPr(); textPr.Color = g_oDocumentDefaultStrokeColor; switch (type) { @@ -10167,9 +10167,9 @@ oNewShape.createTextBody(); const par = oNewShape.txBody.content.GetAllParagraphs()[0]; par.MoveCursorToStartPos(); - par.Pr = new CParaPr(); + par.Pr = new AscCommonWord.CParaPr(); - const parRun = new ParaRun(par); + const parRun = new AscCommonWord.ParaRun(par); const textPr = lvl.textPr.Copy(); textPr.FontSize = ((2 * line_distance * 72 / 96) >> 0) / 2; parRun.Set_Pr(textPr); @@ -10206,11 +10206,11 @@ par.MoveCursorToStartPos(); //par.Pr = level.ParaPr.Copy(); - par.Pr = new CParaPr(); + par.Pr = new AscCommonWord.CParaPr(); textPr = textPr.Copy(); textPr.FontSize = textPr.FontSizeCS = ((2 * lineHeight * 72 / 96) >> 0) / 2; - const parRun = new ParaRun(par); + const parRun = new AscCommonWord.ParaRun(par); parRun.Set_Pr(textPr); parRun.AddText(text); par.AddToContent(0, parRun); diff --git a/common/externs/cell.js b/common/externs/cell.js index d9de806eba..b3357e7f43 100644 --- a/common/externs/cell.js +++ b/common/externs/cell.js @@ -48,7 +48,6 @@ var CCommentAuthor; var PresentationSelectedContent; var DrawingCopyObject; -var GetLoadInfoForMeasurer; var RULER_OBJECT_TYPE_PARAGRAPH; var RULER_OBJECT_TYPE_HEADER; var RULER_OBJECT_TYPE_FOOTER; diff --git a/common/libfont/textmeasurer.js b/common/libfont/textmeasurer.js index 02cf8a1af0..4bc2c2a329 100644 --- a/common/libfont/textmeasurer.js +++ b/common/libfont/textmeasurer.js @@ -384,8 +384,154 @@ var g_oTextMeasurer = new CTextMeasurer(); g_oTextMeasurer.Init(); + function GetLoadInfoForMeasurer(info, lStyle) + { + // подбираем шрифт по стилю + var sReturnName = info.Name; + var bNeedBold = false; + var bNeedItalic = false; + + var index = -1; + var faceIndex = 0; + + var bSrcItalic = false; + var bSrcBold = false; + + switch (lStyle) + { + case AscFonts.FontStyle.FontStyleBoldItalic: + { + bSrcItalic = true; + bSrcBold = true; + + bNeedBold = true; + bNeedItalic = true; + if (-1 != info.indexBI) + { + index = info.indexBI; + faceIndex = info.faceIndexBI; + bNeedBold = false; + bNeedItalic = false; + } + else if (-1 != info.indexB) + { + index = info.indexB; + faceIndex = info.faceIndexB; + bNeedBold = false; + } + else if (-1 != info.indexI) + { + index = info.indexI; + faceIndex = info.faceIndexI; + bNeedItalic = false; + } + else + { + index = info.indexR; + faceIndex = info.faceIndexR; + } + break; + } + case AscFonts.FontStyle.FontStyleBold: + { + bSrcBold = true; + + bNeedBold = true; + bNeedItalic = false; + if (-1 != info.indexB) + { + index = info.indexB; + faceIndex = info.faceIndexB; + bNeedBold = false; + } + else if (-1 != info.indexR) + { + index = info.indexR; + faceIndex = info.faceIndexR; + } + else if (-1 != info.indexBI) + { + index = info.indexBI; + faceIndex = info.faceIndexBI; + bNeedBold = false; + } + else + { + index = info.indexI; + faceIndex = info.faceIndexI; + } + break; + } + case AscFonts.FontStyle.FontStyleItalic: + { + bSrcItalic = true; + + bNeedBold = false; + bNeedItalic = true; + if (-1 != info.indexI) + { + index = info.indexI; + faceIndex = info.faceIndexI; + bNeedItalic = false; + } + else if (-1 != info.indexR) + { + index = info.indexR; + faceIndex = info.faceIndexR; + } + else if (-1 != info.indexBI) + { + index = info.indexBI; + faceIndex = info.faceIndexBI; + bNeedItalic = false; + } + else + { + index = info.indexB; + faceIndex = info.faceIndexB; + } + break; + } + case AscFonts.FontStyle.FontStyleRegular: + { + bNeedBold = false; + bNeedItalic = false; + if (-1 != info.indexR) + { + index = info.indexR; + faceIndex = info.faceIndexR; + } + else if (-1 != info.indexI) + { + index = info.indexI; + faceIndex = info.faceIndexI; + } + else if (-1 != info.indexB) + { + index = info.indexB; + faceIndex = info.faceIndexB; + } + else + { + index = info.indexBI; + faceIndex = info.faceIndexBI; + } + } + } + + return { + Path : AscFonts.g_font_files[index].Id, + FaceIndex : faceIndex, + NeedBold : bNeedBold, + NeedItalic : bNeedItalic, + SrcBold : bSrcBold, + SrcItalic : bSrcItalic + }; + } + //--------------------------------------------------------export---------------------------------------------------- window['AscCommon'] = window['AscCommon'] || {}; window['AscCommon'].CTextMeasurer = CTextMeasurer; window['AscCommon'].g_oTextMeasurer = g_oTextMeasurer; + window['AscCommon'].GetLoadInfoForMeasurer = GetLoadInfoForMeasurer; })(window); diff --git a/common/openxml.js b/common/openxml.js index d4a3072f3f..69e40a5e09 100644 --- a/common/openxml.js +++ b/common/openxml.js @@ -366,7 +366,6 @@ openXml.OpenXmlPackage.prototype.getXmlBytes = function(part, data, writer) { var oldPart = writer.context.part; writer.context.part = part; - var oldPos = writer.GetCurPosition(); data.toXml(writer); var pos = writer.GetCurPosition(); @@ -417,6 +416,7 @@ this.pkg.zip.addFile(this.getUriRelative(), data); }; openXml.OpenXmlPart.prototype.setDataXml = function (xmlObj, writer) { + writer.context.clearCurrentPartImageMap(); var data = this.pkg.getXmlBytes(this, xmlObj, writer); this.pkg.zip.addFile(this.getUriRelative(), data); }; @@ -777,7 +777,6 @@ external: "External" }; - window.openXml = openXml; //----------------------------------------------------------export---------------------------------------------------- window['AscCommon'] = window['AscCommon'] || {}; window['AscCommon'].openXml = openXml; diff --git a/common/zlib/zlib.js b/common/zlib/zlib.js index 82c0a31ce9..2c2cf53ba9 100644 --- a/common/zlib/zlib.js +++ b/common/zlib/zlib.js @@ -54,7 +54,7 @@ { function ZLib() { - this.engine = window["NATIVE_EDITOR_ENJINE"] ? CreateNativeZip() : window.nativeZlibEngine; + this.engine = window["NATIVE_EDITOR_ENJINE"] ? CreateNativeZip() : window["nativeZlibEngine"]; this.files = []; } /** diff --git a/configs/cell.json b/configs/cell.json index 0161274eaf..6215a03fcb 100644 --- a/configs/cell.json +++ b/configs/cell.json @@ -303,6 +303,7 @@ "common": [] }, "mobile": [ + "common/libfont/engine/fonts_native.js", "common/Charts/ChartStyles.js", "common/Native/Wrappers/TextMeasurerWrapper.js", "common/Native/Wrappers/DrawingStream.js", @@ -313,17 +314,13 @@ "cell/native/native.js" ], "exclude_mobile": [ + "vendor/iscroll.js", "common/Overlay.js", "common/Controls.js", + "common/Scrolls/mobileTouchManagerBase.js", "word/Drawing/ShapeDrawer.js", "cell/model/DrawingObjects/DrawingDocument.js", - "common/libfont/rasterheap.js", - "common/libfont/glyphstring.js", - "common/libfont/manager.js", - "common/libfont/textmeasurer.js", "cell/model/DrawingObjects/Graphics.js", - "vendor/iscroll.js", - "common/Scrolls/mobileTouchManagerBase.js", "cell/view/mobileTouch.js" ] } diff --git a/configs/slide.json b/configs/slide.json index 30c0d819a9..0db8f71861 100644 --- a/configs/slide.json +++ b/configs/slide.json @@ -283,8 +283,8 @@ "common": [] }, "mobile": [ + "common/libfont/engine/fonts_native.js", "common/Charts/ChartStyles.js", - "common/Native/Wrappers/TextMeasurerWrapper.js", "common/Native/Wrappers/DrawingStream.js", "common/Native/Wrappers/ShapeDrawer.js", "common/Native/Wrappers/Overlay.js", @@ -294,14 +294,11 @@ "slide/Native/Wrappers/native.js" ], "exclude_mobile": [ - "word/Drawing/ShapeDrawer.js", + "vendor/iscroll.js", "common/Overlay.js", + "word/Drawing/ShapeDrawer.js", "slide/Drawing/HtmlPage.js", - "slide/Drawing/DrawingDocument.js", - "common/libfont/rasterheap.js", - "common/libfont/glyphstring.js", - "common/libfont/manager.js", - "common/libfont/textmeasurer.js" + "slide/Drawing/DrawingDocument.js" ] } } diff --git a/configs/word.json b/configs/word.json index ad20ea26de..7f7aeccb06 100644 --- a/configs/word.json +++ b/configs/word.json @@ -282,9 +282,9 @@ "common": [] }, "mobile": [ + "common/libfont/engine/fonts_native.js", "common/Charts/ChartStyles.js", "common/Native/Wrappers/HtmlPage.js", - "common/Native/Wrappers/TextMeasurerWrapper.js", "common/Native/Wrappers/DrawingStream.js", "common/Native/Wrappers/ShapeDrawer.js", "common/Native/Wrappers/Overlay.js", @@ -292,17 +292,13 @@ "common/Native/Wrappers/api.js" ], "exclude_mobile": [ - "common/Overlay.js", - "word/Drawing/ShapeDrawer.js", - "word/Drawing/DrawingDocument.js", - "common/libfont/rasterheap.js", - "common/libfont/glyphstring.js", - "common/libfont/manager.js", - "common/libfont/textmeasurer.js", "vendor/iscroll.js", "common/Scrolls/mobileTouchManagerBase.js", + "common/Overlay.js", "word/Drawing/mobileTouchManager.js", - "word/Drawing/HtmlPage.js" + "word/Drawing/HtmlPage.js", + "word/Drawing/ShapeDrawer.js", + "word/Drawing/DrawingDocument.js" ] } } diff --git a/slide/Editor/DrawingObjectsController.js b/slide/Editor/DrawingObjectsController.js index 7633cbfcdb..eb6a89df8b 100644 --- a/slide/Editor/DrawingObjectsController.js +++ b/slide/Editor/DrawingObjectsController.js @@ -137,7 +137,7 @@ DrawingObjectsController.prototype.getColorMap = function() } } } - return AscFormat.G_O_DEFAULT_COLOR_MAP; + return AscFormat.DEFAULT_COLOR_MAP; }; diff --git a/slide/Editor/Format/NotesMaster.js b/slide/Editor/Format/NotesMaster.js index 125e982e0a..c3fed69783 100644 --- a/slide/Editor/Format/NotesMaster.js +++ b/slide/Editor/Format/NotesMaster.js @@ -234,7 +234,7 @@ var oThemePart = reader.rels.getPartByRelationshipType(AscCommon.openXml.Types.theme.relationType); if(oThemePart) { var oThemeContent = oThemePart.getDocumentContent(); - let oThemeReader = new StaxParser(oThemeContent, oThemePart, reader.context); + let oThemeReader = new AscCommon.StaxParser(oThemeContent, oThemePart, reader.context); let oTheme = new AscFormat.CTheme(); oTheme.fromXml(oThemeReader, true); this.setTheme(oTheme, true); diff --git a/slide/Editor/Format/Presentation.js b/slide/Editor/Format/Presentation.js index f85581b756..1c18ad1d47 100644 --- a/slide/Editor/Format/Presentation.js +++ b/slide/Editor/Format/Presentation.js @@ -6125,7 +6125,7 @@ CPresentation.prototype.Get_Theme = function () { }; CPresentation.prototype.Get_ColorMap = function () { - return AscFormat.G_O_DEFAULT_COLOR_MAP; + return AscFormat.DEFAULT_COLOR_MAP; }; CPresentation.prototype.Get_PageFields = function () { @@ -11928,14 +11928,16 @@ CPresentation.prototype.toZip = function(zip, context) { aThemes.push(oSlideMasterTheme); oAddedMap[oSlideMasterTheme.Id] = true; } - if(oNotes && oNotesMaster && !oAddedMap[oNotesMaster.Id]) { + if(oNotes && oNotesMaster) { aNotes.push(oNotes); - aNotesMasters.push(oNotesMaster); - oAddedMap[oNotesMaster.Id] = true; - let oNotesTheme = oNotesMaster.Theme; - if(oNotesTheme && !oAddedMap[oNotesTheme.Id]) { - aThemes.push(oNotesTheme); - oAddedMap[oNotesTheme.Id] = true; + if(!oAddedMap[oNotesMaster.Id]) { + aNotesMasters.push(oNotesMaster); + oAddedMap[oNotesMaster.Id] = true; + let oNotesTheme = oNotesMaster.Theme; + if(oNotesTheme && !oAddedMap[oNotesTheme.Id]) { + aThemes.push(oNotesTheme); + oAddedMap[oNotesTheme.Id] = true; + } } } } @@ -12193,7 +12195,7 @@ IdList.prototype.readList = function(reader, fConstructor) { oRel = reader.rels.getRelationship(aList[nItem].rId); oRelPart = reader.rels.pkg.getPartByUri(oRel.targetFullName); let oContent = oRelPart.getDocumentContent(); - let oReader = new StaxParser(oContent, oRelPart, reader.context); + let oReader = new AscCommon.StaxParser(oContent, oRelPart, reader.context); let oElement = fConstructor(oReader); if(oElement) { oElement.fromXml(oReader, true); diff --git a/slide/Editor/Format/ShapePrototype.js b/slide/Editor/Format/ShapePrototype.js index a4fe74b63e..a3afe55b29 100644 --- a/slide/Editor/Format/ShapePrototype.js +++ b/slide/Editor/Format/ShapePrototype.js @@ -37,10 +37,6 @@ // Import var CShape = AscFormat.CShape; -var G_O_DEFAULT_COLOR_MAP = AscFormat.GenerateDefaultColorMap(); - - - CShape.prototype.Is_UseInDocument = function(drawingObjects) { if(this.group) @@ -576,7 +572,7 @@ CShape.prototype.Get_ColorMap = function() { return parent_objects.master.clrMap; } - return G_O_DEFAULT_COLOR_MAP; + return AscFormat.DEFAULT_COLOR_MAP; }; CShape.prototype.getStyles = function(index) @@ -684,5 +680,4 @@ CShape.prototype.OnContentReDraw = function(){ //--------------------------------------------------------export---------------------------------------------------- window['AscFormat'] = window['AscFormat'] || {}; - window['AscFormat'].G_O_DEFAULT_COLOR_MAP = G_O_DEFAULT_COLOR_MAP; })(window); diff --git a/slide/Editor/Format/Slide.js b/slide/Editor/Format/Slide.js index cf99ae5b4a..7abe6a054b 100644 --- a/slide/Editor/Format/Slide.js +++ b/slide/Editor/Format/Slide.js @@ -1173,7 +1173,7 @@ AscFormat.InitClass(Slide, AscFormat.CBaseFormatObject, AscDFH.historyitem_type_ { return this.Layout.Master.clrMap; } - return AscFormat.G_O_DEFAULT_COLOR_MAP; + return AscFormat.DEFAULT_COLOR_MAP; }; Slide.prototype.recalculate = function() @@ -1942,7 +1942,7 @@ Slide.prototype.readCommentXml = function(reader) { let oNotesPart = reader.rels.getPartByRelationshipType(AscCommon.openXml.Types.notesSlide.relationType); if(oNotesPart) { let oNotesContent = oNotesPart.getDocumentContent(); - let oNotesReader = new StaxParser(oNotesContent, oNotesPart, reader.context); + let oNotesReader = new AscCommon.StaxParser(oNotesContent, oNotesPart, reader.context); let oNotes = new AscCommonSlide.CNotes(); oNotes.fromXml(oNotesReader, true); let oRel = oNotesReader.rels.getPartByRelationshipType(AscCommon.openXml.Types.notesMaster.relationType); @@ -1955,7 +1955,7 @@ Slide.prototype.readCommentXml = function(reader) { if(oCommentsPart) { let oCommentsPartContent = oCommentsPart.getDocumentContent(); if(oCommentsPartContent) { - let oCommentsReader = new StaxParser(oCommentsPartContent, oCommentsPart, reader.context); + let oCommentsReader = new AscCommon.StaxParser(oCommentsPartContent, oCommentsPart, reader.context); this.readCommentsXml(oCommentsReader); } } diff --git a/slide/Editor/Format/SlideMaster.js b/slide/Editor/Format/SlideMaster.js index 04f674627d..1584f7d41c 100644 --- a/slide/Editor/Format/SlideMaster.js +++ b/slide/Editor/Format/SlideMaster.js @@ -504,7 +504,7 @@ MasterSlide.prototype.fromXml = function(reader, bSkipFirstNode) { var oThemePart = reader.rels.getPartByRelationshipType(AscCommon.openXml.Types.theme.relationType); if(oThemePart) { var oThemeContent = oThemePart.getDocumentContent(); - let oThemeReader = new StaxParser(oThemeContent, oThemePart, reader.context); + let oThemeReader = new AscCommon.StaxParser(oThemeContent, oThemePart, reader.context); let oTheme = new AscFormat.CTheme(); oTheme.fromXml(oThemeReader, true); this.setTheme(oTheme, true); diff --git a/slide/Native/Wrappers/api.js b/slide/Native/Wrappers/api.js index 20565bcccb..8530a9af8e 100644 --- a/slide/Native/Wrappers/api.js +++ b/slide/Native/Wrappers/api.js @@ -54,7 +54,6 @@ var FontStyle = FontStyleStrikeout: 8 }; -window["use_native_fonts_only"] = true; // ------------------------------------------------- // declarate unused methods and objects @@ -2789,7 +2788,6 @@ function initSpellCheckApi() { } function NativeOpenFileP(_params, documentInfo){ - window["CreateMainTextMeasurerWrapper"](); window.g_file_path = "native_open_file"; window.NATIVE_DOCUMENT_TYPE = window["native"]["GetEditorType"](); var doc_bin = window["native"]["GetFileString"](window.g_file_path); diff --git a/slide/api.js b/slide/api.js index 526ff11354..6daa15d461 100644 --- a/slide/api.js +++ b/slide/api.js @@ -1569,12 +1569,15 @@ background-repeat: no-repeat;\ setInterval(AscCommon.SafariIntervalFocus, 10); }; - asc_docs_api.prototype.OpenDocumentFromZip = function(data) + + asc_docs_api.prototype.OpenDocumentFromZipNoInit = function(data) { + if (!data) { return false; } var openXml = AscCommon.openXml; + var StaxParser = AscCommon.StaxParser; var xmlParserContext = new AscCommon.XmlParserContext(); xmlParserContext.DrawingDocument = this.WordControl.m_oDrawingDocument; var jsZipWrapper = new AscCommon.JSZipWrapper(); @@ -1582,9 +1585,7 @@ background-repeat: no-repeat;\ return false; } - this.InitEditor(); var reader; - this.DocumentType = 2; xmlParserContext.zip = jsZipWrapper; var doc = new openXml.OpenXmlPackage(jsZipWrapper, null); @@ -1626,7 +1627,6 @@ background-repeat: no-repeat;\ oPresPr.fromXml(oPresentationReader, true); } } - let oCorePart = doc.getPartByRelationshipType(openXml.Types.coreFileProperties.relationType); if(oCorePart) { let oContentCore = oCorePart.getDocumentContent(); @@ -1636,7 +1636,6 @@ background-repeat: no-repeat;\ this.WordControl.m_oLogicDocument.Core.fromXml(oCoreReader, true); } } - let oCustomPrPart = doc.getPartByRelationshipType(openXml.Types.customFileProperties.relationType); if(oCustomPrPart) { let oContentCustomPr = oCustomPrPart.getDocumentContent(); @@ -1646,8 +1645,6 @@ background-repeat: no-repeat;\ this.WordControl.m_oLogicDocument.CustomPr.fromXml(oCustomPrReader, true); } } - - this.WordControl.m_oLogicDocument.ImageMap = {}; var _cur_ind = 0; var context = reader.context; @@ -1663,17 +1660,27 @@ background-repeat: no-repeat;\ }); } } + jsZipWrapper.close(); + return true; + }; + asc_docs_api.prototype.OpenDocumentFromZip = function(data) + { + + this.InitEditor(); + this.DocumentType = 2; + + g_oIdCounter.Set_Load(true); + this.OpenDocumentFromZipNoInit(data); + g_oIdCounter.Set_Load(false); this.WordControl.m_oLogicDocument.Set_FastCollaborativeEditing(true); this.LoadedObject = 1; - g_oIdCounter.Set_Load(false); AscFonts.IsCheckSymbols = false; this.WordControl.m_oDrawingDocument.CheckFontNeeds(); this.FontLoader.LoadDocumentFonts(this.WordControl.m_oLogicDocument.Fonts, false); - g_oIdCounter.Set_Load(false); if (this.isMobileVersion) { @@ -1681,11 +1688,9 @@ background-repeat: no-repeat;\ PasteElementsId.PASTE_ELEMENT_ID = "wrd_pastebin"; PasteElementsId.ELEMENT_DISPAY_STYLE = "none"; } - if (AscCommon.AscBrowser.isSafariMacOs) setInterval(AscCommon.SafariIntervalFocus, 10); - jsZipWrapper.close(); return true; }; @@ -7967,7 +7972,7 @@ background-repeat: no-repeat;\ this.isOpenOOXInBrowser = AscCommon.checkOOXMLSignature(base64File); if (this.isOpenOOXInBrowser) { - this.OpenDocumentFromZip(base64File); + this.OpenDocumentFromZipNoInit(base64File); } else { var _loader = new AscCommon.BinaryPPTYLoader(); _loader.Api = this; diff --git a/vendor/easysax.js b/vendor/easysax.js index 1fdd097acf..18ac4dbbf5 100644 --- a/vendor/easysax.js +++ b/vendor/easysax.js @@ -1653,6 +1653,8 @@ function XmlWriterContext(editorId){ this.zip = null; this.part = null; this.imageMap = {}; + this.currentPartImageMap = {}; + this.oUriMap = {}; this.objectId = 1; this.groupIndex = 0; @@ -1724,6 +1726,34 @@ XmlWriterContext.prototype.getSlideMastersCount = function() { XmlWriterContext.prototype.getSlidesCount = function() { return this.sldIdLst.length; }; +XmlWriterContext.prototype.clearCurrentPartImageMap = function() { + this.currentPartImageMap = {}; +}; +XmlWriterContext.prototype.getImageRId = function(sRasterImageId) { + let imagePart = this.imageMap[sRasterImageId]; + let type = this.editorId === AscCommon.c_oEditorId.Word ? AscCommon.openXml.Types.imageWord : AscCommon.openXml.Types.image; + if (!imagePart) { + if (this.part) { + let ext = AscCommon.GetFileExtension(sRasterImageId); + type = Object.assign({}, type); + type.filename += ext; + type.contentType = AscCommon.openXml.GetMimeType(ext); + imagePart = this.part.addPart(type); + if (imagePart) { + this.imageMap[sRasterImageId] = imagePart; + this.currentPartImageMap[sRasterImageId] = imagePart.rId; + } + } + } + else { + if(!this.currentPartImageMap[sRasterImageId]) { + if(this.part) { + this.currentPartImageMap[sRasterImageId] = this.part.addRelationship(type.relationType, imagePart.part.uri); + } + } + } + return this.currentPartImageMap[sRasterImageId] ? this.currentPartImageMap[sRasterImageId] : ""; +}; function CT_XmlNode(opt_elemReader) { this.attributes = {}; this.attributes = {}; @@ -1791,8 +1821,8 @@ CT_XmlNode.prototype.toXml = function(writer, name) { } writer.WriteXmlNodeEnd(name); }; -window.StaxParser = StaxParser; window['AscCommon'] = window['AscCommon'] || {}; window['AscCommon'].XmlParserContext = XmlParserContext; window["AscCommon"].XmlWriterContext = XmlWriterContext; +window['AscCommon'].StaxParser = StaxParser; diff --git a/word/Editor/SerializeXml.js b/word/Editor/SerializeXml.js index 11dc7e00d4..5cb2d373cd 100644 --- a/word/Editor/SerializeXml.js +++ b/word/Editor/SerializeXml.js @@ -34,6 +34,7 @@ (function(window, undefined) { let openXml = AscCommon.openXml; + let StaxParser = AscCommon.StaxParser; let CT_BoolW = window['AscCommon'].CT_BoolW; let CT_StringW = window['AscCommon'].CT_StringW; let CT_IntW = window['AscCommon'].CT_IntW; @@ -1504,8 +1505,8 @@ case "oMathPara": elem = new AscCommon.CT_OMathPara(); elem.fromXml(reader); - if (elem.OMath) { - elem.OMath.Correct_Content(true); + if (elem.OMath && elem.OMath.Root) { + elem.OMath.Root.Correct_Content(true); this.AddToContent(this.GetElementsCount(), elem.OMath); } break; diff --git a/word/Math/matrix.js b/word/Math/matrix.js index 3c760eb6b6..4f83c07fd3 100644 --- a/word/Math/matrix.js +++ b/word/Math/matrix.js @@ -676,8 +676,8 @@ CMathMatrix.prototype.init = function(props) this.setProperties(props); this.Pr.initByContent(props.mrs); + this.column = this.Pr.Get_ColumnsCount(); if (props.mrs) { - this.column = this.Pr.Get_ColumnsCount(); props.content = this.flatContent(props.mrs, this.column); }