From d23bf6505556c79b14c6fb2c198357420413c83f Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Tue, 28 Dec 2021 13:42:58 +0300 Subject: [PATCH 01/31] test push --- common/Drawings/Format/Format.js | 24 +++ common/Shapes/Serialize.js | 254 ++++++++++++++++--------------- common/Shapes/SerializeWriter.js | 14 +- 3 files changed, 164 insertions(+), 128 deletions(-) diff --git a/common/Drawings/Format/Format.js b/common/Drawings/Format/Format.js index 6bd23dd558..e2d6432dda 100644 --- a/common/Drawings/Format/Format.js +++ b/common/Drawings/Format/Format.js @@ -5428,6 +5428,24 @@ function FormatRGBAColor() return this.fill && this.fill.type !== window['Asc'].c_oAscFill.FILL_TYPE_NOFILL; }; + + function CBuBlip() { + this.blip = null; + } + + CBuBlip.prototype.toPPTY = function (pWriter) { + pWriter.StartRecord(AscFormat.BULLET_TYPE_BULLET_CHAR); + pWriter.WriteRecord1(0, this.blip); + pWriter.EndRecord(); + } + + CBuBlip.prototype.fromPPTY = function (pReader) { + this.blip = new AscFormat.CUniFill(); + this.blip.fill = new AscFormat.CBlipFill(); + pReader.ReadBlip(this.blip); + console.log(this.blip); + } + function CompareUniFill(unifill_1, unifill_2) { @@ -11506,6 +11524,7 @@ function CBulletType() this.type = null;//BULLET_TYPE_BULLET_NONE; this.Char = null; this.AutoNumType = null; + this.Blip = null; this.startAt = null; } @@ -11579,6 +11598,10 @@ CBulletType.prototype = return d; }, + setBlip(oPr) { + this.Blip = oPr; + }, + Write_ToBinary: function(w) { w.WriteBool(isRealNumber(this.type)); @@ -13569,6 +13592,7 @@ function CorrectUniColor(asc_color, unicolor, flag) window['AscFormat'].CHyperlink = CHyperlink; window['AscFormat'].CTextParagraphPr = CTextParagraphPr; window['AscFormat'].CompareBullets = CompareBullets; + window['AscFormat'].CBuBlip = CBuBlip; window['AscFormat'].CBullet = CBullet; window['AscFormat'].CBulletColor = CBulletColor; window['AscFormat'].CBulletSize = CBulletSize; diff --git a/common/Shapes/Serialize.js b/common/Shapes/Serialize.js index 776f6923fb..4f413ba291 100644 --- a/common/Shapes/Serialize.js +++ b/common/Shapes/Serialize.js @@ -3092,6 +3092,131 @@ function BinaryPPTYLoader() return ret; }; + this.ReadBlip = function (uni_fill, oSpPr, oImageShape, oLn) { + var s = this.stream; + var _s2 = s.cur; + var _e2 = _s2 + s.GetLong() + 4; + + s.Skip2(1); + + while (true) + { + var _at = s.GetUChar(); + if (g_nodeAttributeEnd == _at) + break; + + if (_at == 0) + s.Skip2(1); + } + + while (s.cur < _e2) + { + var _t = s.GetUChar(); + + switch (_t) + { + case 0: + case 1: + { + // id. embed / link + s.Skip2(4); + break; + } + case 10: + case 11: + { + // id. embed / link + s.GetString2(); + break; + } + case 2: + { + var len2 = s.GetLong(); + + var _end_rec_effect = s.cur + len2; + + var count_effects = s.GetULong(); + for (var _eff = 0; _eff < count_effects; ++_eff) + { + + s.Skip2(1); // type + var oEffect = this.ReadEffect(); + if(oEffect) + { + uni_fill.fill.Effects.push(oEffect); + if(oEffect instanceof AscFormat.CAlphaModFix && AscFormat.isRealNumber(oEffect.amt)) + { + uni_fill.setTransparent(255 * oEffect.amt / 100000); + } + } + } + s.Seek2(_end_rec_effect); + break; + } + case 3: + { + s.Skip2(6); // len + start attributes + type + + var sReadPath = s.GetString2(); + if (this.IsUseFullUrl && this.insertDocumentUrlsData && this.insertDocumentUrlsData.imageMap) { + var sReadPathNew = this.insertDocumentUrlsData.imageMap[AscCommon.g_oDocumentUrls.mediaPrefix + sReadPath]; + if(sReadPathNew){ + sReadPath = sReadPathNew; + } + } + if(this.IsUseFullUrl) { + if(window["native"] && window["native"]["CopyTmpToMedia"]){ + if(!(window.documentInfo && window.documentInfo["iscoauthoring"])){ + var sMedia = window["native"]["CopyTmpToMedia"](sReadPath); + if(typeof sMedia === "string" && sMedia.length > 0){ + sReadPath = sMedia; + } + } + } + } + uni_fill.fill.setRasterImageId(sReadPath); + + // TEST version --------------- + var _s = sReadPath; + var indS = _s.lastIndexOf("emf"); + if (indS == -1) + indS = _s.lastIndexOf("wmf"); + + if (indS != -1 && (indS == (_s.length - 3))) + { + _s = _s.substring(0, indS); + _s += "svg"; + sReadPath = _s; + uni_fill.fill.setRasterImageId(_s); + } + // ---------------------------- + + if (this.IsThemeLoader) + { + sReadPath = "theme" + (this.Api.ThemeLoader.CurrentLoadThemeIndex + 1) + "/media/" + sReadPath; + uni_fill.fill.setRasterImageId(sReadPath); + } + + if (this.ImageMapChecker != null) + this.ImageMapChecker[sReadPath] = true; + + if (this.IsUseFullUrl) + this.RebuildImages.push(new CBuilderImages(uni_fill.fill, sReadPath, oImageShape, oSpPr, oLn)); + + s.Skip2(1); // end attribute + break; + } + default: + { + s.SkipRecord(); + break; + } + } + } + + s.Seek2(_e2); + } + this.ReadUniFill = function(oSpPr, oImageShape, oLn) { @@ -3141,128 +3266,8 @@ function BinaryPPTYLoader() { case 0: { - var _s2 = s.cur; - var _e2 = _s2 + s.GetLong() + 4; - - s.Skip2(1); - - while (true) - { - var _at = s.GetUChar(); - if (g_nodeAttributeEnd == _at) - break; - - if (_at == 0) - s.Skip2(1); - } - - while (s.cur < _e2) - { - var _t = s.GetUChar(); - - switch (_t) - { - case 0: - case 1: - { - // id. embed / link - s.Skip2(4); - break; - } - case 10: - case 11: - { - // id. embed / link - s.GetString2(); - break; - } - case 2: - { - var len2 = s.GetLong(); - - var _end_rec_effect = s.cur + len2; - - var count_effects = s.GetULong(); - for (var _eff = 0; _eff < count_effects; ++_eff) - { - - s.Skip2(1); // type - var oEffect = this.ReadEffect(); - if(oEffect) - { - uni_fill.fill.Effects.push(oEffect); - if(oEffect instanceof AscFormat.CAlphaModFix && AscFormat.isRealNumber(oEffect.amt)) - { - uni_fill.setTransparent(255 * oEffect.amt / 100000); - } - } - } - s.Seek2(_end_rec_effect); - break; - } - case 3: - { - s.Skip2(6); // len + start attributes + type - - var sReadPath = s.GetString2(); - if (this.IsUseFullUrl && this.insertDocumentUrlsData && this.insertDocumentUrlsData.imageMap) { - var sReadPathNew = this.insertDocumentUrlsData.imageMap[AscCommon.g_oDocumentUrls.mediaPrefix + sReadPath]; - if(sReadPathNew){ - sReadPath = sReadPathNew; - } - } - if(this.IsUseFullUrl) { - if(window["native"] && window["native"]["CopyTmpToMedia"]){ - if(!(window.documentInfo && window.documentInfo["iscoauthoring"])){ - var sMedia = window["native"]["CopyTmpToMedia"](sReadPath); - if(typeof sMedia === "string" && sMedia.length > 0){ - sReadPath = sMedia; - } - } - } - } - uni_fill.fill.setRasterImageId(sReadPath); - - // TEST version --------------- - var _s = sReadPath; - var indS = _s.lastIndexOf("emf"); - if (indS == -1) - indS = _s.lastIndexOf("wmf"); - - if (indS != -1 && (indS == (_s.length - 3))) - { - _s = _s.substring(0, indS); - _s += "svg"; - sReadPath = _s; - uni_fill.fill.setRasterImageId(_s); - } - // ---------------------------- - - if (this.IsThemeLoader) - { - sReadPath = "theme" + (this.Api.ThemeLoader.CurrentLoadThemeIndex + 1) + "/media/" + sReadPath; - uni_fill.fill.setRasterImageId(sReadPath); - } - - if (this.ImageMapChecker != null) - this.ImageMapChecker[sReadPath] = true; - - if (this.IsUseFullUrl) - this.RebuildImages.push(new CBuilderImages(uni_fill.fill, sReadPath, oImageShape, oSpPr, oLn)); - - s.Skip2(1); // end attribute - break; - } - default: - { - s.SkipRecord(); - break; - } - } - } - - s.Seek2(_e2); - break; + this.ReadBlip(uni_fill, oSpPr, oImageShape, oLn); + break; } case 1: { @@ -9666,7 +9671,10 @@ function BinaryPPTYLoader() } else if (bullet.bulletType.type == AscFormat.BULLET_TYPE_BULLET_BLIP) { - s.SkipRecord(); + s.Skip2(5); + var buBlip = new AscFormat.CBuBlip(); + buBlip.fromPPTY(this); + bullet.bulletType.setBlip(buBlip); } else if (bullet.bulletType.type == AscFormat.BULLET_TYPE_BULLET_AUTONUM) { diff --git a/common/Shapes/SerializeWriter.js b/common/Shapes/SerializeWriter.js index 2cfad6bbb1..b4e0b8228b 100644 --- a/common/Shapes/SerializeWriter.js +++ b/common/Shapes/SerializeWriter.js @@ -2124,12 +2124,16 @@ function CBinaryFileWriter() } case AscFormat.BULLET_TYPE_BULLET_BLIP: { + + bullet.bulletType.Blip.toPPTY(oThis); + //oThis.StartRecord(AscFormat.BULLET_TYPE_BULLET_BLIP); + // not support. char (*) - oThis.StartRecord(AscFormat.BULLET_TYPE_BULLET_CHAR); - oThis.WriteUChar(g_nodeAttributeStart); - oThis._WriteString1(0, "*"); - oThis.WriteUChar(g_nodeAttributeEnd); - oThis.EndRecord(); + // oThis.StartRecord(AscFormat.BULLET_TYPE_BULLET_CHAR); + // oThis.WriteUChar(g_nodeAttributeStart); + // oThis._WriteString1(0, "*"); + // oThis.WriteUChar(g_nodeAttributeEnd); + // oThis.EndRecord(); break; } case AscFormat.BULLET_TYPE_BULLET_AUTONUM: From 238499967ccd3e1add7c1dbdc1af75377196b7ec Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Tue, 28 Dec 2021 15:15:33 +0300 Subject: [PATCH 02/31] refactor: replace part of code in readUniFill and writeUniFill methods readBlipFill and writeBlipFill --- common/Drawings/Format/Format.js | 6 +- common/Shapes/Serialize.js | 1 + common/Shapes/SerializeWriter.js | 97 ++++++++++--------- .../Editor/Numbering/PresentationNumbering.js | 3 + word/Editor/Styles.js | 4 +- 5 files changed, 58 insertions(+), 53 deletions(-) diff --git a/common/Drawings/Format/Format.js b/common/Drawings/Format/Format.js index e2d6432dda..5dda620afb 100644 --- a/common/Drawings/Format/Format.js +++ b/common/Drawings/Format/Format.js @@ -5434,16 +5434,14 @@ function FormatRGBAColor() } CBuBlip.prototype.toPPTY = function (pWriter) { - pWriter.StartRecord(AscFormat.BULLET_TYPE_BULLET_CHAR); - pWriter.WriteRecord1(0, this.blip); - pWriter.EndRecord(); + var _src = this.blip.RasterImageId; + pWriter.WriteBlip(this.blip, _src); } CBuBlip.prototype.fromPPTY = function (pReader) { this.blip = new AscFormat.CUniFill(); this.blip.fill = new AscFormat.CBlipFill(); pReader.ReadBlip(this.blip); - console.log(this.blip); } function CompareUniFill(unifill_1, unifill_2) diff --git a/common/Shapes/Serialize.js b/common/Shapes/Serialize.js index 4f413ba291..cfaa763937 100644 --- a/common/Shapes/Serialize.js +++ b/common/Shapes/Serialize.js @@ -9675,6 +9675,7 @@ function BinaryPPTYLoader() var buBlip = new AscFormat.CBuBlip(); buBlip.fromPPTY(this); bullet.bulletType.setBlip(buBlip); + console.log(bullet); } else if (bullet.bulletType.type == AscFormat.BULLET_TYPE_BULLET_AUTONUM) { diff --git a/common/Shapes/SerializeWriter.js b/common/Shapes/SerializeWriter.js index b4e0b8228b..6455fbe9fe 100644 --- a/common/Shapes/SerializeWriter.js +++ b/common/Shapes/SerializeWriter.js @@ -2124,7 +2124,7 @@ function CBinaryFileWriter() } case AscFormat.BULLET_TYPE_BULLET_BLIP: { - + console.log(bullet); bullet.bulletType.Blip.toPPTY(oThis); //oThis.StartRecord(AscFormat.BULLET_TYPE_BULLET_BLIP); @@ -2923,6 +2923,53 @@ function CBinaryFileWriter() } }; + this.WriteBlip = function (fill, _src) { + oThis.StartRecord(c_oAscFill.FILL_TYPE_BLIP); + + oThis.WriteUChar(g_nodeAttributeStart); + oThis.WriteUChar(g_nodeAttributeEnd); + oThis.StartRecord(0); + oThis.WriteUChar(g_nodeAttributeStart); + oThis.WriteUChar(g_nodeAttributeEnd); + + + var effects_count = fill.Effects.length; + if(effects_count > 0) + { + + oThis.StartRecord(2); + oThis.WriteULong(effects_count); + for(var effect_index = 0; effect_index < effects_count; ++effect_index) + { + oThis.WriteRecord1(0, fill.Effects[effect_index], oThis.WriteEffect); + } + oThis.EndRecord(); + } + + // if (null != trans) + // { + // oThis.StartRecord(2); + // oThis.WriteULong(1); + // oThis.StartRecord(3); + // oThis.StartRecord(21); + // oThis.WriteUChar(g_nodeAttributeStart); + // oThis._WriteInt1(0, (trans * 100000 / 255) >> 0); + // oThis.WriteUChar(g_nodeAttributeEnd); + // oThis.EndRecord(); + // oThis.EndRecord(); + // oThis.EndRecord(); + // } + + oThis.StartRecord(3); + oThis.WriteUChar(g_nodeAttributeStart); + oThis._WriteString1(0, _src); + oThis.WriteUChar(g_nodeAttributeEnd); + oThis.EndRecord(); + + oThis.EndRecord(); + + } + this.WriteUniFill = function(unifill) { if (undefined === unifill || null == unifill) @@ -3022,13 +3069,8 @@ function CBinaryFileWriter() } case c_oAscFill.FILL_TYPE_BLIP: { - oThis.StartRecord(c_oAscFill.FILL_TYPE_BLIP); - - oThis.WriteUChar(g_nodeAttributeStart); - oThis.WriteUChar(g_nodeAttributeEnd); - var _src = fill.RasterImageId; - var imageLocal = AscCommon.g_oDocumentUrls.getImageLocal(_src); + var imageLocal = AscCommon.g_oDocumentUrls.getImageLocal(_src); if(imageLocal) _src = imageLocal; else @@ -3074,46 +3116,7 @@ function CBinaryFileWriter() } } - - oThis.StartRecord(0); - oThis.WriteUChar(g_nodeAttributeStart); - oThis.WriteUChar(g_nodeAttributeEnd); - - - var effects_count = fill.Effects.length; - if(effects_count > 0) - { - - oThis.StartRecord(2); - oThis.WriteULong(effects_count); - for(var effect_index = 0; effect_index < effects_count; ++effect_index) - { - oThis.WriteRecord1(0, fill.Effects[effect_index], oThis.WriteEffect); - } - oThis.EndRecord(); - } - - // if (null != trans) - // { - // oThis.StartRecord(2); - // oThis.WriteULong(1); - // oThis.StartRecord(3); - // oThis.StartRecord(21); - // oThis.WriteUChar(g_nodeAttributeStart); - // oThis._WriteInt1(0, (trans * 100000 / 255) >> 0); - // oThis.WriteUChar(g_nodeAttributeEnd); - // oThis.EndRecord(); - // oThis.EndRecord(); - // oThis.EndRecord(); - // } - - oThis.StartRecord(3); - oThis.WriteUChar(g_nodeAttributeStart); - oThis._WriteString1(0, _src); - oThis.WriteUChar(g_nodeAttributeEnd); - oThis.EndRecord(); - - oThis.EndRecord(); + this.WriteBlip(fill, _src); if (fill.srcRect != null) { diff --git a/word/Editor/Numbering/PresentationNumbering.js b/word/Editor/Numbering/PresentationNumbering.js index 997b4da273..127b241690 100644 --- a/word/Editor/Numbering/PresentationNumbering.js +++ b/word/Editor/Numbering/PresentationNumbering.js @@ -86,6 +86,7 @@ var numbering_presentationnumfrmt_ThaiNumPeriod = 40; var numbering_presentationnumfrmt_None = 100; var numbering_presentationnumfrmt_Char = 101; +var numbering_presentationnumfrmt_Blip = 102; function IsAlphaPrNumbering(nType) { @@ -190,6 +191,8 @@ function CPresentationBullet() this.m_oTextPr = null; this.m_nNum = null; this.m_sString = null; + + this.m_oBlip = null; } CPresentationBullet.prototype.Get_Type = function() diff --git a/word/Editor/Styles.js b/word/Editor/Styles.js index 50afe131da..c5a0b27097 100644 --- a/word/Editor/Styles.js +++ b/word/Editor/Styles.js @@ -16895,8 +16895,8 @@ CParaPr.prototype.Get_PresentationBullet = function(theme, colorMap) } case AscFormat.BULLET_TYPE_BULLET_BLIP : { - Bullet.m_nType = numbering_presentationnumfrmt_Char; - Bullet.m_sChar = "•"; + Bullet.m_nType = numbering_presentationnumfrmt_Blip; + Bullet.m_oBlip = this.Bullet.bulletType.blip; break; } } From 4840375a1f8cb10d7bda2dbf089c448efcc20101 Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Wed, 29 Dec 2021 18:38:39 +0300 Subject: [PATCH 03/31] reset commit: thoughts about image bullet --- common/Drawings/Format/Format.js | 7 +- common/Shapes/Serialize.js | 1 + common/editorscommon.js | 11 +- word/Drawing/Graphics.js | 1 - .../Editor/Numbering/PresentationNumbering.js | 154 +++++++++++------- word/Editor/Styles.js | 2 +- 6 files changed, 111 insertions(+), 65 deletions(-) diff --git a/common/Drawings/Format/Format.js b/common/Drawings/Format/Format.js index 5dda620afb..b3dfdaf766 100644 --- a/common/Drawings/Format/Format.js +++ b/common/Drawings/Format/Format.js @@ -10848,7 +10848,11 @@ function CompareBullets(bullet1, bullet2) } case BULLET_TYPE_BULLET_BLIP: { - ret.bulletType.type = BULLET_TYPE_BULLET_CHAR; //TODO: в меню отдаем, что символьный. + ret.bulletType.type = BULLET_TYPE_BULLET_BLIP; + if(bullet1.bulletType.Blip === bullet2.bulletType.Blip) + { + ret.bulletType.Blip = bullet1.bulletType.Blip; + } break; } case BULLET_TYPE_BULLET_AUTONUM: @@ -11593,6 +11597,7 @@ CBulletType.prototype = d.Char = this.Char; d.AutoNumType = this.AutoNumType; d.startAt = this.startAt; + d.Blip = this.Blip; return d; }, diff --git a/common/Shapes/Serialize.js b/common/Shapes/Serialize.js index fdf03451dd..3d13ba86ad 100644 --- a/common/Shapes/Serialize.js +++ b/common/Shapes/Serialize.js @@ -3238,6 +3238,7 @@ function BinaryPPTYLoader() s.Skip2(1); uni_fill.setFill(new AscFormat.CBlipFill()); + console.log(oImageShape); while (true) { diff --git a/common/editorscommon.js b/common/editorscommon.js index 2668f83c15..c32052a67f 100644 --- a/common/editorscommon.js +++ b/common/editorscommon.js @@ -1001,7 +1001,14 @@ } return stack.join("/"); } - + function getSourceImageSize(src) + { + var _img = editor.ImageLoader.map_image_index[src]; + if (_img && _img.Image) { + return {width: _img.Image.width, height: _img.Image.height}; + } + return {width: 0, height: 0}; + } function getFullImageSrc2(src) { if (window["NATIVE_EDITOR_ENJINE"]) @@ -11779,6 +11786,8 @@ window["AscCommon"].backoffOnErrorImg = backoffOnErrorImg; window["AscCommon"].isEmptyObject = isEmptyObject; + window["AscCommon"].getSourceImageSize = getSourceImageSize; + window["AscCommon"].CSignatureDrawer = window["AscCommon"]["CSignatureDrawer"] = CSignatureDrawer; var prot = CSignatureDrawer.prototype; prot["getImages"] = prot.getImages; diff --git a/word/Drawing/Graphics.js b/word/Drawing/Graphics.js index 470f358072..4a53350875 100644 --- a/word/Drawing/Graphics.js +++ b/word/Drawing/Graphics.js @@ -833,7 +833,6 @@ CGraphics.prototype = this.drawImage2(nativeImage,x,y,w,h,alpha,srcRect); return; } - var _img = editor.ImageLoader.map_image_index[img]; if (_img != undefined && _img.Status == AscFonts.ImageLoadStatus.Loading) { diff --git a/word/Editor/Numbering/PresentationNumbering.js b/word/Editor/Numbering/PresentationNumbering.js index 10f086e988..78b341da26 100644 --- a/word/Editor/Numbering/PresentationNumbering.js +++ b/word/Editor/Numbering/PresentationNumbering.js @@ -356,6 +356,8 @@ CPresentationBullet.prototype.Measure = function(Context, FirstTextPr, Num, Them if ( null != this.m_sChar ) { sT = this.m_sChar; } + } else if (this.m_nType === numbering_presentationnumfrmt_Blip) { + } else { var typeOfNum = getAdaptedNumberingFormat(this.m_nType); var formatNum = IntToNumberFormat(Num, typeOfNum); @@ -364,10 +366,6 @@ CPresentationBullet.prototype.Measure = function(Context, FirstTextPr, Num, Them this.m_sString = sT; this.m_nNum = Num; - if(sT.length === 0) - { - return { Width : 0 }; - } var dFontSize = FirstTextPr.FontSize; if ( false === this.m_bSizeTx ) { @@ -433,7 +431,16 @@ CPresentationBullet.prototype.Measure = function(Context, FirstTextPr, Num, Them }); FirstTextPr_.Merge(TextPr_); this.m_oTextPr = FirstTextPr_; + if (this.m_nType === numbering_presentationnumfrmt_Blip) { + var _src = AscCommon.getFullImageSrc2(this.m_oBlip.blip.fill.RasterImageId); + var sizes = AscCommon.getSourceImageSize(_src); + return { Width: 0 }; + } + if(sT.length === 0) + { + return { Width : 0 }; + } var X = 0; var OldTextPr = Context.GetTextPr(); @@ -478,79 +485,104 @@ CPresentationBullet.prototype.Copy = function() return Bullet; }; + +CPresentationBullet.prototype.IsErrorInNumeration = function() { + return (null === this.m_oTextPr + || null === this.m_nNum + || null == this.m_sString + || this.m_sString.length === 0) + && this.m_oBlip === null; +} + CPresentationBullet.prototype.Draw = function(X, Y, Context, PDSE) { - if ( null === this.m_oTextPr || null === this.m_nNum || null == this.m_sString || this.m_sString.length == 0) + if (this.IsErrorInNumeration()) return; - var OldTextPr = Context.GetTextPr(); - var OldTextPr2 = g_oTextMeasurer.GetTextPr(); + var OldTextPr = Context.GetTextPr(); + var OldTextPr2 = g_oTextMeasurer.GetTextPr(); - var Hint = this.m_oTextPr.RFonts.Hint; - var bCS = this.m_oTextPr.CS; - var bRTL = this.m_oTextPr.RTL; - var lcid = this.m_oTextPr.Lang.EastAsia; + var Hint = this.m_oTextPr.RFonts.Hint; + var bCS = this.m_oTextPr.CS; + var bRTL = this.m_oTextPr.RTL; + var lcid = this.m_oTextPr.Lang.EastAsia; + + var sT = this.m_sString; + var FontSlot; + if (sT) { + FontSlot = g_font_detector.Get_FontClass( sT.getUnicodeIterator().value(), Hint, lcid, bCS, bRTL ); + } else { + FontSlot = g_font_detector.Get_FontClass( '|', Hint, lcid, bCS, bRTL ); + } - var sT = this.m_sString; - var FontSlot = g_font_detector.Get_FontClass( sT.getUnicodeIterator().value(), Hint, lcid, bCS, bRTL ); - if(this.m_oTextPr.Unifill){ - this.m_oTextPr.Unifill.check(PDSE.Theme, PDSE.ColorMap); - } - Context.SetTextPr( this.m_oTextPr, PDSE.Theme ); - Context.SetFontSlot( FontSlot ); - if(!Context.Start_Command){ if(this.m_oTextPr.Unifill){ - var RGBA = this.m_oTextPr.Unifill.getRGBAColor(); - this.m_oColor.r = RGBA.R; - this.m_oColor.g = RGBA.G; - this.m_oColor.b = RGBA.B; + this.m_oTextPr.Unifill.check(PDSE.Theme, PDSE.ColorMap); } - var r = this.m_oColor.r; - var g = this.m_oColor.g; - var b = this.m_oColor.b; - if(PDSE.Paragraph && PDSE.Paragraph.IsEmpty()) - { - var dAlpha = 0.4; - var rB, gB, bB; - if(PDSE.BgColor) - { - rB = PDSE.BgColor.r; - gB = PDSE.BgColor.g; - bB = PDSE.BgColor.b; + Context.SetTextPr( this.m_oTextPr, PDSE.Theme ); + Context.SetFontSlot( FontSlot ); + if(!Context.Start_Command){ + if(this.m_oTextPr.Unifill){ + var RGBA = this.m_oTextPr.Unifill.getRGBAColor(); + this.m_oColor.r = RGBA.R; + this.m_oColor.g = RGBA.G; + this.m_oColor.b = RGBA.B; } - else + var r = this.m_oColor.r; + var g = this.m_oColor.g; + var b = this.m_oColor.b; + if(PDSE.Paragraph && PDSE.Paragraph.IsEmpty()) { - rB = 255; - gB = 255; - bB = 255; + var dAlpha = 0.4; + var rB, gB, bB; + if(PDSE.BgColor) + { + rB = PDSE.BgColor.r; + gB = PDSE.BgColor.g; + bB = PDSE.BgColor.b; + } + else + { + rB = 255; + gB = 255; + bB = 255; + } + r = Math.min(255, (r * dAlpha + rB * (1 - dAlpha) + 0.5) >> 0); + g = Math.min(255, (g * dAlpha + gB * (1 - dAlpha) + 0.5) >> 0); + b = Math.min(255, (b * dAlpha + bB * (1 - dAlpha) + 0.5) >> 0); } - r = Math.min(255, (r * dAlpha + rB * (1 - dAlpha) + 0.5) >> 0); - g = Math.min(255, (g * dAlpha + gB * (1 - dAlpha) + 0.5) >> 0); - b = Math.min(255, (b * dAlpha + bB * (1 - dAlpha) + 0.5) >> 0); + Context.p_color(r, g, b, 255 ); + Context.b_color1(r, g, b, 255 ); + } + g_oTextMeasurer.SetTextPr( this.m_oTextPr, PDSE.Theme ); + g_oTextMeasurer.SetFontSlot( FontSlot ); + + var _src = AscCommon.getFullImageSrc2(this.m_oBlip.blip.fill.RasterImageId); + var sizes = AscCommon.getSourceImageSize(_src); + console.log(this.m_oTextPr) + var height = g_oTextMeasurer.GetHeight() - (g_oTextMeasurer.GetAscender() + g_oTextMeasurer.GetDescender());// TODO: think about it + console.log(height) + var imageHeight = height; + var imageWidth = sizes.width * imageHeight / sizes.height; + Context.drawImage(_src, X, Y - imageHeight, imageWidth, imageHeight); + + if (this.m_nType !== numbering_presentationnumfrmt_Blip) { + for (var iter = sT.getUnicodeIterator(); iter.check(); iter.next()) { + var charCode = iter.value(); + Context.FillTextCode( X, Y, charCode ); + X += g_oTextMeasurer.MeasureCode(charCode).Width; } - Context.p_color(r, g, b, 255 ); - Context.b_color1(r, g, b, 255 ); - } - g_oTextMeasurer.SetTextPr( this.m_oTextPr, PDSE.Theme ); - g_oTextMeasurer.SetFontSlot( FontSlot ); - - for (var iter = sT.getUnicodeIterator(); iter.check(); iter.next()) { - var charCode = iter.value(); - Context.FillTextCode( X, Y, charCode ); - X += g_oTextMeasurer.MeasureCode(charCode).Width; - } - - if(OldTextPr) - { - Context.SetTextPr( OldTextPr, PDSE.Theme ); - } - if(OldTextPr2) - { - g_oTextMeasurer.SetTextPr( OldTextPr2, PDSE.Theme ); } + if(OldTextPr) + { + Context.SetTextPr( OldTextPr, PDSE.Theme ); + } + if(OldTextPr2) + { + g_oTextMeasurer.SetTextPr( OldTextPr2, PDSE.Theme ); + } }; CPresentationBullet.prototype.IsNumbered = function() { diff --git a/word/Editor/Styles.js b/word/Editor/Styles.js index c5a0b27097..4e58a9db12 100644 --- a/word/Editor/Styles.js +++ b/word/Editor/Styles.js @@ -16896,7 +16896,7 @@ CParaPr.prototype.Get_PresentationBullet = function(theme, colorMap) case AscFormat.BULLET_TYPE_BULLET_BLIP : { Bullet.m_nType = numbering_presentationnumfrmt_Blip; - Bullet.m_oBlip = this.Bullet.bulletType.blip; + Bullet.m_oBlip = this.Bullet.bulletType.Blip; break; } } From 62e16f87a9da30eca32df6a6587bad25575ce010 Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Mon, 10 Jan 2022 20:16:17 +0300 Subject: [PATCH 04/31] feat: calculate images for presentation image bullet --- .../Editor/Numbering/PresentationNumbering.js | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/word/Editor/Numbering/PresentationNumbering.js b/word/Editor/Numbering/PresentationNumbering.js index 78b341da26..fab33c1c6d 100644 --- a/word/Editor/Numbering/PresentationNumbering.js +++ b/word/Editor/Numbering/PresentationNumbering.js @@ -194,6 +194,7 @@ function CPresentationBullet() this.m_sString = null; this.m_oBlip = null; + this.m_sSrc = null; } CPresentationBullet.prototype.getHighlightForNumbering = function(intFormat) { @@ -349,7 +350,7 @@ CPresentationBullet.prototype.Get_StartAt = function() { return this.m_nStartAt; }; -CPresentationBullet.prototype.Measure = function(Context, FirstTextPr, Num, Theme, ColorMap) +CPresentationBullet.prototype.Measure = function(Context, FirstTextPr, Num, Theme) { var sT = ""; if (this.m_nType === numbering_presentationnumfrmt_Char) { @@ -357,7 +358,7 @@ CPresentationBullet.prototype.Measure = function(Context, FirstTextPr, Num, Them sT = this.m_sChar; } } else if (this.m_nType === numbering_presentationnumfrmt_Blip) { - + this.m_sSrc = AscCommon.getFullImageSrc2(this.m_oBlip.blip.fill.RasterImageId); } else { var typeOfNum = getAdaptedNumberingFormat(this.m_nType); var formatNum = IntToNumberFormat(Num, typeOfNum); @@ -431,10 +432,13 @@ CPresentationBullet.prototype.Measure = function(Context, FirstTextPr, Num, Them }); FirstTextPr_.Merge(TextPr_); this.m_oTextPr = FirstTextPr_; + if (this.m_nType === numbering_presentationnumfrmt_Blip) { - var _src = AscCommon.getFullImageSrc2(this.m_oBlip.blip.fill.RasterImageId); - var sizes = AscCommon.getSourceImageSize(_src); - return { Width: 0 }; + var sizes = AscCommon.getSourceImageSize(this.m_sSrc); + var x_height = g_oTextMeasurer.GetHeight() - (g_oTextMeasurer.GetAscender() + g_oTextMeasurer.GetDescender()); + var adaptImageHeight = x_height; + var adaptImageWidth = sizes.width * adaptImageHeight / sizes.height; + return { Width: adaptImageWidth + 0.8 }; // TODO: существует добавочная единица (какая?) } if(sT.length === 0) @@ -514,7 +518,7 @@ CPresentationBullet.prototype.Draw = function(X, Y, Context, PDSE) if (sT) { FontSlot = g_font_detector.Get_FontClass( sT.getUnicodeIterator().value(), Hint, lcid, bCS, bRTL ); } else { - FontSlot = g_font_detector.Get_FontClass( '|', Hint, lcid, bCS, bRTL ); + FontSlot = g_font_detector.Get_FontClass( '*', Hint, lcid, bCS, bRTL ); } @@ -558,16 +562,15 @@ CPresentationBullet.prototype.Draw = function(X, Y, Context, PDSE) } g_oTextMeasurer.SetTextPr( this.m_oTextPr, PDSE.Theme ); g_oTextMeasurer.SetFontSlot( FontSlot ); + if (this.m_nType === numbering_presentationnumfrmt_Blip) { + var sizes = AscCommon.getSourceImageSize(this.m_sSrc); - var _src = AscCommon.getFullImageSrc2(this.m_oBlip.blip.fill.RasterImageId); - var sizes = AscCommon.getSourceImageSize(_src); - console.log(this.m_oTextPr) - var height = g_oTextMeasurer.GetHeight() - (g_oTextMeasurer.GetAscender() + g_oTextMeasurer.GetDescender());// TODO: think about it - console.log(height) - var imageHeight = height; - var imageWidth = sizes.width * imageHeight / sizes.height; - Context.drawImage(_src, X, Y - imageHeight, imageWidth, imageHeight); + var x_height = g_oTextMeasurer.GetHeight() - (g_oTextMeasurer.GetAscender() + g_oTextMeasurer.GetDescender());// TODO: think about it + var adaptImageHeight = x_height; + var adaptImageWidth = sizes.width * adaptImageHeight / sizes.height; + Context.drawImage(this.m_sSrc, X, Y - adaptImageHeight, adaptImageWidth, adaptImageHeight); + } if (this.m_nType !== numbering_presentationnumfrmt_Blip) { for (var iter = sT.getUnicodeIterator(); iter.check(); iter.next()) { var charCode = iter.value(); From 47bc4cd39fe9296a7358fa83f78aeda643e00399 Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Mon, 10 Jan 2022 20:17:25 +0300 Subject: [PATCH 05/31] feat: add require methods for BuBlip --- common/Drawings/Format/Format.js | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/common/Drawings/Format/Format.js b/common/Drawings/Format/Format.js index b3dfdaf766..ed337deca5 100644 --- a/common/Drawings/Format/Format.js +++ b/common/Drawings/Format/Format.js @@ -5444,6 +5444,23 @@ function FormatRGBAColor() pReader.ReadBlip(this.blip); } + CBuBlip.prototype.createDuplicate = function () { + var ret = new CBuBlip(); + ret.blip = this.blip.createDuplicate(); + return ret; + } + + CBuBlip.prototype.compare = function (compareObj) { + var ret = null; + if (compareObj instanceof CBuBlip) { + ret = new CBuBlip(); + if (this.blip) { + ret.blip = this.blip.compare(compareObj); + } + } + return ret; + } + function CompareUniFill(unifill_1, unifill_2) { @@ -10849,10 +10866,8 @@ function CompareBullets(bullet1, bullet2) case BULLET_TYPE_BULLET_BLIP: { ret.bulletType.type = BULLET_TYPE_BULLET_BLIP; - if(bullet1.bulletType.Blip === bullet2.bulletType.Blip) - { - ret.bulletType.Blip = bullet1.bulletType.Blip; - } + var compareBlip = bullet1.bulletType.Blip && bullet1.bulletType.Blip.compare(bullet2.bulletType.Blip); + ret.bulletType.Blip = compareBlip; break; } case BULLET_TYPE_BULLET_AUTONUM: @@ -11597,7 +11612,9 @@ CBulletType.prototype = d.Char = this.Char; d.AutoNumType = this.AutoNumType; d.startAt = this.startAt; - d.Blip = this.Blip; + if (this.Blip) { + d.Blip = this.Blip.createDuplicate(); + } return d; }, From 15929c73a60782436ba5f1b1a4ffff4d37b98d59 Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Mon, 10 Jan 2022 20:18:50 +0300 Subject: [PATCH 06/31] fix: add changes in write logic of Blip --- common/Drawings/Format/Format.js | 11 ++- common/Shapes/SerializeWriter.js | 122 ++++++++++++++----------------- 2 files changed, 63 insertions(+), 70 deletions(-) diff --git a/common/Drawings/Format/Format.js b/common/Drawings/Format/Format.js index ed337deca5..cbbd515d86 100644 --- a/common/Drawings/Format/Format.js +++ b/common/Drawings/Format/Format.js @@ -5434,8 +5434,15 @@ function FormatRGBAColor() } CBuBlip.prototype.toPPTY = function (pWriter) { - var _src = this.blip.RasterImageId; - pWriter.WriteBlip(this.blip, _src); + var _src = this.blip.fill.RasterImageId; + var imageLocal = AscCommon.g_oDocumentUrls.getImageLocal(_src); + if(imageLocal) + _src = imageLocal; + + pWriter.image_map[_src] = true; + + _src = pWriter.prepareRasterImageIdForWrite(_src); + pWriter.WriteBlip(this.blip.fill, _src); } CBuBlip.prototype.fromPPTY = function (pReader) { diff --git a/common/Shapes/SerializeWriter.js b/common/Shapes/SerializeWriter.js index 6455fbe9fe..4d5ef83065 100644 --- a/common/Shapes/SerializeWriter.js +++ b/common/Shapes/SerializeWriter.js @@ -2124,16 +2124,9 @@ function CBinaryFileWriter() } case AscFormat.BULLET_TYPE_BULLET_BLIP: { - console.log(bullet); + oThis.StartRecord(AscFormat.BULLET_TYPE_BULLET_BLIP); bullet.bulletType.Blip.toPPTY(oThis); - //oThis.StartRecord(AscFormat.BULLET_TYPE_BULLET_BLIP); - - // not support. char (*) - // oThis.StartRecord(AscFormat.BULLET_TYPE_BULLET_CHAR); - // oThis.WriteUChar(g_nodeAttributeStart); - // oThis._WriteString1(0, "*"); - // oThis.WriteUChar(g_nodeAttributeEnd); - // oThis.EndRecord(); + oThis.EndRecord(); break; } case AscFormat.BULLET_TYPE_BULLET_AUTONUM: @@ -2923,19 +2916,58 @@ function CBinaryFileWriter() } }; + this.prepareRasterImageIdForWrite = function(rawSrc) { + var _src = rawSrc; + + if (window["IsEmbedImagesInInternalFormat"] === true) + { + var _image = editor.ImageLoader.map_image_index[AscCommon.getFullImageSrc2(_src)]; + if (undefined !== _image) + { + var imgNatural = _image.Image; + + var _canvas = document.createElement("canvas"); + _canvas.width = imgNatural.width; + _canvas.height = imgNatural.height; + + _canvas.getContext("2d").drawImage(imgNatural, 0, 0, _canvas.width, _canvas.height); + _src = _canvas.toDataURL("image/png"); + } + } + else if (oThis.IsUseFullUrl) + { + if ((0 == _src.indexOf("theme")) && window.editor) + { + _src = oThis.PresentationThemesOrigin + _src; + } + else if (0 != _src.indexOf("http:") && 0 != _src.indexOf("data:") && 0 != _src.indexOf("https:") && 0 != _src.indexOf("ftp:") && 0 != _src.indexOf("file:")){ + if (AscCommon.EncryptionWorker && AscCommon.EncryptionWorker.isCryptoImages() && + window["AscDesktopEditor"] && window["AscDesktopEditor"]["Crypto_GetLocalImageBase64"]) { + _src = window["AscDesktopEditor"]["Crypto_GetLocalImageBase64"](_src); + } else { + var imageUrl = AscCommon.g_oDocumentUrls.getImageUrl(_src); + if (imageUrl) + _src = imageUrl; + } + } + if(window["native"] && window["native"]["GetImageTmpPath"]){ + if(!(window.documentInfo && window.documentInfo["iscoauthoring"])){ + _src = window["native"]["GetImageTmpPath"](_src); + } + + } + } + return _src; + } + this.WriteBlip = function (fill, _src) { - oThis.StartRecord(c_oAscFill.FILL_TYPE_BLIP); - oThis.WriteUChar(g_nodeAttributeStart); - oThis.WriteUChar(g_nodeAttributeEnd); oThis.StartRecord(0); oThis.WriteUChar(g_nodeAttributeStart); oThis.WriteUChar(g_nodeAttributeEnd); var effects_count = fill.Effects.length; - if(effects_count > 0) - { oThis.StartRecord(2); oThis.WriteULong(effects_count); @@ -2944,21 +2976,6 @@ function CBinaryFileWriter() oThis.WriteRecord1(0, fill.Effects[effect_index], oThis.WriteEffect); } oThis.EndRecord(); - } - - // if (null != trans) - // { - // oThis.StartRecord(2); - // oThis.WriteULong(1); - // oThis.StartRecord(3); - // oThis.StartRecord(21); - // oThis.WriteUChar(g_nodeAttributeStart); - // oThis._WriteInt1(0, (trans * 100000 / 255) >> 0); - // oThis.WriteUChar(g_nodeAttributeEnd); - // oThis.EndRecord(); - // oThis.EndRecord(); - // oThis.EndRecord(); - // } oThis.StartRecord(3); oThis.WriteUChar(g_nodeAttributeStart); @@ -3069,8 +3086,13 @@ function CBinaryFileWriter() } case c_oAscFill.FILL_TYPE_BLIP: { + oThis.StartRecord(c_oAscFill.FILL_TYPE_BLIP); + + oThis.WriteUChar(g_nodeAttributeStart); + oThis.WriteUChar(g_nodeAttributeEnd); + var _src = fill.RasterImageId; - var imageLocal = AscCommon.g_oDocumentUrls.getImageLocal(_src); + var imageLocal = AscCommon.g_oDocumentUrls.getImageLocal(_src); if(imageLocal) _src = imageLocal; else @@ -3078,45 +3100,9 @@ function CBinaryFileWriter() oThis.image_map[_src] = true; - if (window["IsEmbedImagesInInternalFormat"] === true) - { - var _image = editor.ImageLoader.map_image_index[AscCommon.getFullImageSrc2(_src)]; - if (undefined !== _image) - { - var imgNatural = _image.Image; + _src = oThis.prepareRasterImageIdForWrite(_src); - var _canvas = document.createElement("canvas"); - _canvas.width = imgNatural.width; - _canvas.height = imgNatural.height; - - _canvas.getContext("2d").drawImage(imgNatural, 0, 0, _canvas.width, _canvas.height); - _src = _canvas.toDataURL("image/png"); - } - } - else if (oThis.IsUseFullUrl) - { - if ((0 == _src.indexOf("theme")) && window.editor) - { - _src = oThis.PresentationThemesOrigin + _src; - } - else if (0 != _src.indexOf("http:") && 0 != _src.indexOf("data:") && 0 != _src.indexOf("https:") && 0 != _src.indexOf("ftp:") && 0 != _src.indexOf("file:")){ - if (AscCommon.EncryptionWorker && AscCommon.EncryptionWorker.isCryptoImages() && - window["AscDesktopEditor"] && window["AscDesktopEditor"]["Crypto_GetLocalImageBase64"]) { - _src = window["AscDesktopEditor"]["Crypto_GetLocalImageBase64"](_src); - } else { - var imageUrl = AscCommon.g_oDocumentUrls.getImageUrl(_src); - if (imageUrl) - _src = imageUrl; - } - } - if(window["native"] && window["native"]["GetImageTmpPath"]){ - if(!(window.documentInfo && window.documentInfo["iscoauthoring"])){ - _src = window["native"]["GetImageTmpPath"](_src); - } - - } - } - this.WriteBlip(fill, _src); + oThis.WriteBlip(fill, _src); if (fill.srcRect != null) { From 3d679f3857235dbbb82c74b5aeb44811d0e10b5a Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Tue, 11 Jan 2022 14:46:13 +0300 Subject: [PATCH 07/31] refactor: BuBlip class --- common/Drawings/Format/Format.js | 33 +++++++++++++++++++++++--------- common/HistoryCommon.js | 3 +++ common/TableId.js | 2 ++ 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/common/Drawings/Format/Format.js b/common/Drawings/Format/Format.js index cbbd515d86..dab86b3ca4 100644 --- a/common/Drawings/Format/Format.js +++ b/common/Drawings/Format/Format.js @@ -5429,9 +5429,30 @@ function FormatRGBAColor() }; + AscDFH.changesFactory[AscDFH.historyitem_BuBlipBlip] = CChangesDrawingsObjectNoId; + drawingsChangesMap[AscDFH.historyitem_BuBlipBlip] = function (oClass, value) { + oClass.blip = value; + }; function CBuBlip() { + CBaseFormatObject.call(this); this.blip = null; } + InitClass(CBuBlip, CBaseFormatObject, AscDFH.historyitem_type_BuBlip); + + CBuBlip.prototype.setBlip = function (oPr) { + History.Add(new CChangesDrawingsObjectNoId(this, AscDFH.historyitem_BuBlipBlip, this.blip, oPr)); + this.blip = oPr; + }; + + CBuBlip.prototype.fillObject = function (oCopy, oIdMap) { + if (this.blip) { + oCopy.setBlip(this.blip.createDuplicate(oIdMap)); + } + } + + CBuBlip.prototype.getChildren = function () { + return [this.blip]; + } CBuBlip.prototype.toPPTY = function (pWriter) { var _src = this.blip.fill.RasterImageId; @@ -5446,23 +5467,17 @@ function FormatRGBAColor() } CBuBlip.prototype.fromPPTY = function (pReader) { - this.blip = new AscFormat.CUniFill(); - this.blip.fill = new AscFormat.CBlipFill(); + this.setBlip(new AscFormat.CUniFill()); + this.blip.setFill(new AscFormat.CBlipFill()); pReader.ReadBlip(this.blip); } - CBuBlip.prototype.createDuplicate = function () { - var ret = new CBuBlip(); - ret.blip = this.blip.createDuplicate(); - return ret; - } - CBuBlip.prototype.compare = function (compareObj) { var ret = null; if (compareObj instanceof CBuBlip) { ret = new CBuBlip(); if (this.blip) { - ret.blip = this.blip.compare(compareObj); + ret.setBlip(this.blip.compare(compareObj)); } } return ret; diff --git a/common/HistoryCommon.js b/common/HistoryCommon.js index c9d0fbd375..4e2542103e 100644 --- a/common/HistoryCommon.js +++ b/common/HistoryCommon.js @@ -1624,6 +1624,7 @@ window['AscDFH'].historyitem_type_SmartArtTree = 2096 << 16; window['AscDFH'].historyitem_type_SmartArtNode = 2097 << 16; window['AscDFH'].historyitem_type_SmartArtNodeData = 2098 << 16; + window['AscDFH'].historyitem_type_BuBlip = 2099 << 16; @@ -3734,6 +3735,8 @@ AscDFH.historyitem_SmartArtNodeDataAddToLstPresPoint = AscDFH.historyitem_type_SmartArtNodeData | 7; AscDFH.historyitem_SmartArtNodeDataRemoveFromLstPresPoint = AscDFH.historyitem_type_SmartArtNodeData | 8; + AscDFH.historyitem_BuBlipBlip = AscDFH.historyitem_type_BuBlip | 1; + AscDFH.historyitem_PointInfoPoint = AscDFH.historyitem_type_PointInfo | 1; AscDFH.historyitem_PointInfoAssociation = AscDFH.historyitem_type_PointInfo | 2; diff --git a/common/TableId.js b/common/TableId.js index d5afed9c0d..7a0a19f900 100644 --- a/common/TableId.js +++ b/common/TableId.js @@ -374,6 +374,8 @@ this.m_oFactoryClass[AscDFH.historyitem_type_SmartArtTree ] = AscFormat.SmartArtTree; this.m_oFactoryClass[AscDFH.historyitem_type_SmartArtNode ] = AscFormat.SmartArtNode; this.m_oFactoryClass[AscDFH.historyitem_type_SmartArtNodeData ] = AscFormat.SmartArtNodeData; + this.m_oFactoryClass[AscDFH.historyitem_type_BuBlip ] = AscFormat.CBuBlip; + if (window['AscCommonSlide']) { this.m_oFactoryClass[AscDFH.historyitem_type_Slide] = AscCommonSlide.Slide; From c5b2e32b8ac0c7253c167ed7ab0fc57898bd7754 Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Tue, 11 Jan 2022 14:50:12 +0300 Subject: [PATCH 08/31] fix(pe): add calculate FontSlot for blip bullet in Measure method --- .../Editor/Numbering/PresentationNumbering.js | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/word/Editor/Numbering/PresentationNumbering.js b/word/Editor/Numbering/PresentationNumbering.js index fab33c1c6d..be05abdf83 100644 --- a/word/Editor/Numbering/PresentationNumbering.js +++ b/word/Editor/Numbering/PresentationNumbering.js @@ -433,7 +433,23 @@ CPresentationBullet.prototype.Measure = function(Context, FirstTextPr, Num, Them FirstTextPr_.Merge(TextPr_); this.m_oTextPr = FirstTextPr_; - if (this.m_nType === numbering_presentationnumfrmt_Blip) { + var X = 0; + var OldTextPr = Context.GetTextPr(); + var Hint = this.m_oTextPr.RFonts.Hint; + var bCS = this.m_oTextPr.CS; + var bRTL = this.m_oTextPr.RTL; + var lcid = this.m_oTextPr.Lang.EastAsia; + var FontSlot; + if (sT) + { + FontSlot = g_font_detector.Get_FontClass( sT.getUnicodeIterator().value(), Hint, lcid, bCS, bRTL ); + } else { + FontSlot = g_font_detector.Get_FontClass( '*', Hint, lcid, bCS, bRTL ); + } + Context.SetTextPr( this.m_oTextPr, Theme ); + Context.SetFontSlot( FontSlot ); + if (this.m_nType === numbering_presentationnumfrmt_Blip) + { var sizes = AscCommon.getSourceImageSize(this.m_sSrc); var x_height = g_oTextMeasurer.GetHeight() - (g_oTextMeasurer.GetAscender() + g_oTextMeasurer.GetDescender()); var adaptImageHeight = x_height; @@ -445,18 +461,8 @@ CPresentationBullet.prototype.Measure = function(Context, FirstTextPr, Num, Them { return { Width : 0 }; } - - var X = 0; - var OldTextPr = Context.GetTextPr(); - var Hint = this.m_oTextPr.RFonts.Hint; - var bCS = this.m_oTextPr.CS; - var bRTL = this.m_oTextPr.RTL; - var lcid = this.m_oTextPr.Lang.EastAsia; - - var FontSlot = g_font_detector.Get_FontClass( sT.getUnicodeIterator().value(), Hint, lcid, bCS, bRTL ); - Context.SetTextPr( this.m_oTextPr, Theme ); - Context.SetFontSlot( FontSlot ); - for (var iter = sT.getUnicodeIterator(); iter.check(); iter.next()) { + for (var iter = sT.getUnicodeIterator(); iter.check(); iter.next()) + { var charCode = iter.value(); X += Context.MeasureCode(charCode).Width; } From bb22b96d9dcf24a907fdaa860ba5d9b8a518c699 Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Tue, 11 Jan 2022 14:51:26 +0300 Subject: [PATCH 09/31] refactor(pe): set braces with new line --- .../Editor/Numbering/PresentationNumbering.js | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/word/Editor/Numbering/PresentationNumbering.js b/word/Editor/Numbering/PresentationNumbering.js index be05abdf83..0f850bc7ec 100644 --- a/word/Editor/Numbering/PresentationNumbering.js +++ b/word/Editor/Numbering/PresentationNumbering.js @@ -353,11 +353,14 @@ CPresentationBullet.prototype.Get_StartAt = function() CPresentationBullet.prototype.Measure = function(Context, FirstTextPr, Num, Theme) { var sT = ""; - if (this.m_nType === numbering_presentationnumfrmt_Char) { - if ( null != this.m_sChar ) { + if (this.m_nType === numbering_presentationnumfrmt_Char) + { + if ( null != this.m_sChar ) + { sT = this.m_sChar; } - } else if (this.m_nType === numbering_presentationnumfrmt_Blip) { + } else if (this.m_nType === numbering_presentationnumfrmt_Blip) + { this.m_sSrc = AscCommon.getFullImageSrc2(this.m_oBlip.blip.fill.RasterImageId); } else { var typeOfNum = getAdaptedNumberingFormat(this.m_nType); @@ -496,7 +499,8 @@ CPresentationBullet.prototype.Copy = function() return Bullet; }; -CPresentationBullet.prototype.IsErrorInNumeration = function() { +CPresentationBullet.prototype.IsErrorInNumeration = function() +{ return (null === this.m_oTextPr || null === this.m_nNum || null == this.m_sString @@ -521,7 +525,8 @@ CPresentationBullet.prototype.Draw = function(X, Y, Context, PDSE) var sT = this.m_sString; var FontSlot; - if (sT) { + if (sT) + { FontSlot = g_font_detector.Get_FontClass( sT.getUnicodeIterator().value(), Hint, lcid, bCS, bRTL ); } else { FontSlot = g_font_detector.Get_FontClass( '*', Hint, lcid, bCS, bRTL ); @@ -568,7 +573,8 @@ CPresentationBullet.prototype.Draw = function(X, Y, Context, PDSE) } g_oTextMeasurer.SetTextPr( this.m_oTextPr, PDSE.Theme ); g_oTextMeasurer.SetFontSlot( FontSlot ); - if (this.m_nType === numbering_presentationnumfrmt_Blip) { + if (this.m_nType === numbering_presentationnumfrmt_Blip) + { var sizes = AscCommon.getSourceImageSize(this.m_sSrc); var x_height = g_oTextMeasurer.GetHeight() - (g_oTextMeasurer.GetAscender() + g_oTextMeasurer.GetDescender());// TODO: think about it @@ -577,8 +583,10 @@ CPresentationBullet.prototype.Draw = function(X, Y, Context, PDSE) Context.drawImage(this.m_sSrc, X, Y - adaptImageHeight, adaptImageWidth, adaptImageHeight); } - if (this.m_nType !== numbering_presentationnumfrmt_Blip) { - for (var iter = sT.getUnicodeIterator(); iter.check(); iter.next()) { + if (this.m_nType !== numbering_presentationnumfrmt_Blip) + { + for (var iter = sT.getUnicodeIterator(); iter.check(); iter.next()) + { var charCode = iter.value(); Context.FillTextCode( X, Y, charCode ); X += g_oTextMeasurer.MeasureCode(charCode).Width; From cea56f77b13c6a2b463940b2e8a618438455f784 Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Tue, 11 Jan 2022 15:30:23 +0300 Subject: [PATCH 10/31] fix: try to repair unit tests --- common/Drawings/Format/Format.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/Drawings/Format/Format.js b/common/Drawings/Format/Format.js index dab86b3ca4..9c484ed4d2 100644 --- a/common/Drawings/Format/Format.js +++ b/common/Drawings/Format/Format.js @@ -11640,7 +11640,7 @@ CBulletType.prototype = return d; }, - setBlip(oPr) { + setBlip: function (oPr) { this.Blip = oPr; }, From b4d6ec10629c670a4121a3f56c928eea5aeef5b4 Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Tue, 11 Jan 2022 16:05:37 +0300 Subject: [PATCH 11/31] fix: add new adding unit --- word/Editor/Numbering/PresentationNumbering.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/word/Editor/Numbering/PresentationNumbering.js b/word/Editor/Numbering/PresentationNumbering.js index 0f850bc7ec..97e3e55283 100644 --- a/word/Editor/Numbering/PresentationNumbering.js +++ b/word/Editor/Numbering/PresentationNumbering.js @@ -457,7 +457,7 @@ CPresentationBullet.prototype.Measure = function(Context, FirstTextPr, Num, Them var x_height = g_oTextMeasurer.GetHeight() - (g_oTextMeasurer.GetAscender() + g_oTextMeasurer.GetDescender()); var adaptImageHeight = x_height; var adaptImageWidth = sizes.width * adaptImageHeight / sizes.height; - return { Width: adaptImageWidth + 0.8 }; // TODO: существует добавочная единица (какая?) + return { Width: adaptImageWidth + adaptImageWidth / 35 }; // TODO: существует добавочная единица (какая?) } if(sT.length === 0) From a4c07c36debd5122e3c8cd48628281f2b8c85da5 Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Mon, 17 Jan 2022 16:13:42 +0300 Subject: [PATCH 12/31] feat: add test upload methods for image bullets in api --- common/Drawings/CommonController.js | 16 ++++- common/Drawings/Format/Format.js | 95 ++++++++++++++++++++++++++++- slide/api.js | 44 +++++++++++-- word/Editor/Paragraph.js | 4 +- 4 files changed, 150 insertions(+), 9 deletions(-) diff --git a/common/Drawings/CommonController.js b/common/Drawings/CommonController.js index 5d018ebd76..c3a3f359bc 100644 --- a/common/Drawings/CommonController.js +++ b/common/Drawings/CommonController.js @@ -11548,8 +11548,21 @@ function CalcLiterByLength(aAlphaBet, nLength) return numberingType; } + function fFillImageBullet(bullet, url) { + var buBlip = new AscFormat.CBuBlip(); + var blip = CreateBlipFillUniFillFromUrl(url); + buBlip.setBlip(blip); + bullet.bulletType = new AscFormat.CBulletType(); + bullet.bulletType.type = AscFormat.BULLET_TYPE_BULLET_BLIP; + bullet.bulletType.setBlip(buBlip); + } + function fFillBullet(NumInfo, bullet) { + if (NumInfo.Blip) { + fFillImageBullet(bullet, NumInfo.Blip.url); + return; + } if(NumInfo.SubType < 0) { bullet.bulletType = new AscFormat.CBulletType(); @@ -11650,7 +11663,7 @@ function CalcLiterByLength(aAlphaBet, nLength) } } function fGetPresentationBulletByNumInfo(NumInfo){ - if(!AscFormat.isRealNumber(NumInfo.Type) && !AscFormat.isRealNumber(NumInfo.SubType)) + if(!AscFormat.isRealNumber(NumInfo.Type) && !AscFormat.isRealNumber(NumInfo.SubType) && !(NumInfo.Blip instanceof Asc.asc_CFillBlip)) { return null; } @@ -11993,6 +12006,7 @@ function CalcLiterByLength(aAlphaBet, nLength) window['AscFormat'].fGetDefaultShapeExtents = fGetDefaultShapeExtents; window['AscFormat'].HitToRect = HitToRect; window['AscFormat'].drawingsUpdateForeignCursor = drawingsUpdateForeignCursor; + window['AscFormat'].fFillImageBullet = fFillImageBullet; window['AscCommon'] = window['AscCommon'] || {}; window["AscCommon"].CDrawTask = CDrawTask; diff --git a/common/Drawings/Format/Format.js b/common/Drawings/Format/Format.js index 9c484ed4d2..f75602143b 100644 --- a/common/Drawings/Format/Format.js +++ b/common/Drawings/Format/Format.js @@ -5401,6 +5401,10 @@ function FormatRGBAColor() { return this.IsIdentical(unfill); }; + CUniFill.prototype.isEqual = function(unfill) + { + return this.IsIdentical(unfill); + }; CUniFill.prototype.compare = function(unifill) { if(unifill == null) @@ -11188,8 +11192,86 @@ function CompareBullets(bullet1, bullet2) } return true; }; + CBullet.prototype.fillBulletImage = function (url) { + if (!this.bulletType) { + this.bulletType = new CBulletType(); + } + if (!this.bulletType.Blip) { + this.bulletType.Blip = new AscFormat.CBuBlip(); + } + this.bulletType.Type = BULLET_TYPE_BULLET_BLIP; + this.bulletType.Blip.setBlip(AscFormat.CreateBlipFillUniFillFromUrl(url)); + + } //interface methods var prot = CBullet.prototype; + prot.put_ImageUrl = function (sUrl, token) { + var _this = this; + var Api = editor; + if(!Api) + { + return; + } + AscCommon.sendImgUrls(Api, [sUrl], function(data) { + if (data && data[0] && data[0].url !== "error") + { + var url = AscCommon.g_oDocumentUrls.imagePath2Local(data[0].path); + Api.ImageLoader.LoadImagesWithCallback([AscCommon.getFullImageSrc2(url)], function(){ + _this.fillBulletImage(url); + editor.WordControl.m_oLogicDocument.SetParagraphNumbering(this); + _this.Api.sendEvent("asc_onBulletImageLoaded"); + }); + } + }, false, undefined, token); + } + prot["put_ImageUrl"] = prot["asc_putImageUrl"] = CBullet.prototype.put_ImageUrl; + prot.showFileDialog = function () { + if(!editor){ + return; + } + var t = editor; + var _this = this; + AscCommon.ShowImageFileDialog(t.documentId, t.documentUserId, t.CoAuthoringApi.get_jwt(), function(error, files) + { + if (Asc.c_oAscError.ID.No !== error) + { + t.sendEvent("asc_onError", error, Asc.c_oAscError.Level.NoCritical); + } + else + { + t.sync_StartAction(Asc.c_oAscAsyncActionType.BlockInteraction, Asc.c_oAscAsyncAction.UploadImage); + AscCommon.UploadImageFiles(files, t.documentId, t.documentUserId, t.CoAuthoringApi.get_jwt(), function(error, urls) + { + if (Asc.c_oAscError.ID.No !== error) + { + t.sendEvent("asc_onError", error, Asc.c_oAscError.Level.NoCritical); + t.sync_EndAction(Asc.c_oAscAsyncActionType.BlockInteraction, Asc.c_oAscAsyncAction.UploadImage); + } + else + { + t.ImageLoader.LoadImagesWithCallback(urls, function(){ + if(urls.length > 0) + { + _this.fillBulletImage(urls[0]); + editor.WordControl.m_oLogicDocument.SetParagraphNumbering(this); + t.sendEvent("asc_onBulletImageLoaded"); + } + t.sync_EndAction(Asc.c_oAscAsyncActionType.BlockInteraction, Asc.c_oAscAsyncAction.UploadImage); + }); + } + }); + } + }, + function(error) + { + if (Asc.c_oAscError.ID.No !== error) + { + t.sendEvent("asc_onError", error, Asc.c_oAscError.Level.NoCritical); + } + t.sync_StartAction(Asc.c_oAscAsyncActionType.BlockInteraction, Asc.c_oAscAsyncAction.UploadImage); + }); + } + prot["showFileDialog"] = prot["asc_showFileDialog"] = CBullet.prototype.showFileDialog; prot.asc_getSize = function () { var nRet = 100; if(this.bulletSize) { @@ -11583,7 +11665,8 @@ CBulletType.prototype = return this.type === oBulletType.type && this.Char === oBulletType.Char && this.AutoNumType === oBulletType.AutoNumType - && this.startAt === oBulletType.startAt; + && this.startAt === oBulletType.startAt + && ((this.Blip && this.Blip.isEqual(oBulletType.Blip)) || this.Blip === oBulletType.Blip); }, merge: function(oBulletType) @@ -11598,6 +11681,9 @@ CBulletType.prototype = this.Char = oBulletType.Char; this.AutoNumType = oBulletType.AutoNumType; this.startAt = oBulletType.startAt; + if (oBulletType.Blip) { + this.Blip = oBulletType.Blip.createDuplicate(); + } } else { @@ -11612,6 +11698,12 @@ CBulletType.prototype = } } } + if(this.type === AscFormat.BULLET_TYPE_BULLET_BLIP) + { + if (this.Blip instanceof AscFormat.CBuBlip && this.Blip !== oBulletType.Blip) { + this.Blip = oBulletType.Blip.createDuplicate(); + } + } if(this.type === AscFormat.BULLET_TYPE_BULLET_AUTONUM) { if(oBulletType.AutoNumType !== null && this.AutoNumType !== oBulletType.AutoNumType) @@ -13848,6 +13940,7 @@ function CorrectUniColor(asc_color, unicolor, flag) window['AscFormat'].InitClass = InitClass; window['AscFormat'].CBaseObject = CBaseObject; window['AscFormat'].CBaseFormatObject = CBaseFormatObject; + window['AscFormat'].checkRasterImageId = checkRasterImageId; window['AscFormat'].DEFAULT_COLOR_MAP = GenerateDefaultColorMap(); })(window); diff --git a/slide/api.js b/slide/api.js index 6e2df21fce..e4b3af3d9b 100644 --- a/slide/api.js +++ b/slide/api.js @@ -2759,13 +2759,40 @@ background-repeat: no-repeat;\ 1.1.1 - SubType = 2 маркированный - SubType = 3 */ - asc_docs_api.prototype.put_ListType = function(type, subtype) - { + asc_docs_api.prototype.put_ImageBulletFromFile = function () { + this.asc_addImage({isImageBullet: true}); + } + asc_docs_api.prototype.put_ListType = function(type, subtype, blip) + { + var blipUrl = blip instanceof Asc.asc_CFillBlip && blip.url; + if (blipUrl) { + var that = this; + var checkImageUrlFromServer = AscFormat.checkRasterImageId(blipUrl); + if (checkImageUrlFromServer) { + blipUrl = checkImageUrlFromServer; + blip.url = blipUrl; + var isImageNotAttendInImageLoader = !this.ImageLoader.map_image_index[blipUrl]; + if (isImageNotAttendInImageLoader) { + var tryToSetImageBulletAgain = function () { + that.put_ListType(undefined, undefined, blip); + } + this.ImageLoader.LoadImagesWithCallback([blipUrl], tryToSetImageBulletAgain); + } + } else { + var changeBlipFillUrlToLocalAndTrySetImageBulletAgain = function (data) { + var uploadImageUrl = data[0].path; + blip.url = uploadImageUrl; + that.put_ListType(undefined, undefined, blip); + } + AscCommon.sendImgUrls(this, [blipUrl], changeBlipFillUrlToLocalAndTrySetImageBulletAgain, false, true, blip.token); + } + } var oPresentation = this.WordControl.m_oLogicDocument; var NumberInfo = { Type : type, - SubType : subtype + SubType : subtype, + Blip : blip }; var oBullet = AscFormat.fGetPresentationBulletByNumInfo(NumberInfo); var sBullet = oBullet.asc_getSymbol(); @@ -4223,7 +4250,7 @@ background-repeat: no-repeat;\ asc_docs_api.prototype._addImageUrl = function(urls, obj) { - if(obj && (obj.isImageChangeUrl || obj.isShapeImageChangeUrl || obj.isSlideImageChangeUrl || obj.isTextArtChangeUrl)){ + if(obj && (obj.isImageChangeUrl || obj.isShapeImageChangeUrl || obj.isSlideImageChangeUrl || obj.isTextArtChangeUrl || obj.isImageBullet)){ this.AddImageUrlAction(urls[0], undefined, obj); } else{ @@ -4268,6 +4295,13 @@ background-repeat: no-repeat;\ } this.ShapeApply(AscShapeProp); } + else if (obj && obj.isImageBullet) + { + console.log(_image) + var fillBlip = new Asc.asc_CFillBlip(); + fillBlip.asc_putUrl(src, null); + this.put_ListType(undefined, undefined, fillBlip); + } else if (obj && obj.isSlideImageChangeUrl) { var AscSlideProp = new CAscSlideProps(); @@ -8220,7 +8254,7 @@ background-repeat: no-repeat;\ asc_docs_api.prototype['asc_moveAnimationEarlier'] = asc_docs_api.prototype.asc_moveAnimationEarlier; asc_docs_api.prototype['asc_moveAnimationLater'] = asc_docs_api.prototype.asc_moveAnimationLater; asc_docs_api.prototype['asc_onShowAnimTab'] = asc_docs_api.prototype.asc_onShowAnimTab; - + asc_docs_api.prototype['StartAddShape'] = asc_docs_api.prototype.StartAddShape; asc_docs_api.prototype['asc_canEditGeometry'] = asc_docs_api.prototype.asc_canEditGeometry; diff --git a/word/Editor/Paragraph.js b/word/Editor/Paragraph.js index 73ec42b4c4..9d8019ff50 100644 --- a/word/Editor/Paragraph.js +++ b/word/Editor/Paragraph.js @@ -9515,7 +9515,7 @@ Paragraph.prototype.Add_PresentationNumbering = function(Bullet) if (NewType === UndefType) { - if (NewType === numbering_presentationnumfrmt_Char)//буллеты + if (NewType === numbering_presentationnumfrmt_Char || NewType === numbering_presentationnumfrmt_Blip)//буллеты { var oUndefPresentationBullet = oUndefParaPr.Bullet.getPresentationBullet(oTheme, oColorMap); var oNewPresentationBullet = oBullet2.getPresentationBullet(oTheme, oColorMap); @@ -9583,7 +9583,7 @@ Paragraph.prototype.Add_PresentationNumbering = function(Bullet) var oFirstRunPr = this.Get_FirstTextPr2(); var Indent = oFirstRunPr.FontSize*0.305954545 + 2.378363636; - if (NewType === numbering_presentationnumfrmt_Char) + if (NewType === numbering_presentationnumfrmt_Char || NewType === numbering_presentationnumfrmt_Blip) { this.Set_Ind({Left : LeftInd + Indent, FirstLine : -Indent}, false); } From 6bb3d1e7a4b2dab7cacc3e8a8cd0587d15196ae1 Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Mon, 17 Jan 2022 16:25:22 +0300 Subject: [PATCH 13/31] fix: get font by first symbol and method copy --- word/Editor/Numbering/PresentationNumbering.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/word/Editor/Numbering/PresentationNumbering.js b/word/Editor/Numbering/PresentationNumbering.js index 97e3e55283..5a19095e0b 100644 --- a/word/Editor/Numbering/PresentationNumbering.js +++ b/word/Editor/Numbering/PresentationNumbering.js @@ -447,7 +447,7 @@ CPresentationBullet.prototype.Measure = function(Context, FirstTextPr, Num, Them { FontSlot = g_font_detector.Get_FontClass( sT.getUnicodeIterator().value(), Hint, lcid, bCS, bRTL ); } else { - FontSlot = g_font_detector.Get_FontClass( '*', Hint, lcid, bCS, bRTL ); + FontSlot = g_font_detector.Get_FontClass( 42, Hint, lcid, bCS, bRTL ); } Context.SetTextPr( this.m_oTextPr, Theme ); Context.SetFontSlot( FontSlot ); @@ -495,6 +495,9 @@ CPresentationBullet.prototype.Copy = function() Bullet.m_dSize = this.m_dSize; Bullet.m_bSizeTx = this.m_bSizeTx; Bullet.m_bSizePct = this.m_bSizePct; + if (this.m_oBlip) { + Bullet.m_oBlip = this.m_oBlip.createDuplicate(); + } return Bullet; }; @@ -529,7 +532,7 @@ CPresentationBullet.prototype.Draw = function(X, Y, Context, PDSE) { FontSlot = g_font_detector.Get_FontClass( sT.getUnicodeIterator().value(), Hint, lcid, bCS, bRTL ); } else { - FontSlot = g_font_detector.Get_FontClass( '*', Hint, lcid, bCS, bRTL ); + FontSlot = g_font_detector.Get_FontClass( 42, Hint, lcid, bCS, bRTL ); } From dc424cff5583efbac73ef61299557d7d2252612a Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Mon, 17 Jan 2022 16:33:48 +0300 Subject: [PATCH 14/31] fix: add export for type BULLET_TYPE_BULLET_BLIP --- common/Drawings/Format/Format.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/Drawings/Format/Format.js b/common/Drawings/Format/Format.js index 5d3166c415..728d25a115 100644 --- a/common/Drawings/Format/Format.js +++ b/common/Drawings/Format/Format.js @@ -11199,7 +11199,7 @@ function CompareBullets(bullet1, bullet2) if (!this.bulletType.Blip) { this.bulletType.Blip = new AscFormat.CBuBlip(); } - this.bulletType.Type = BULLET_TYPE_BULLET_BLIP; + this.bulletType.Type = AscFormat.BULLET_TYPE_BULLET_BLIP; this.bulletType.Blip.setBlip(AscFormat.CreateBlipFillUniFillFromUrl(url)); } From 06a8ee3290bc1670b6516b51ab19256c2f81564e Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Mon, 17 Jan 2022 18:27:41 +0300 Subject: [PATCH 15/31] fix: compare method in CBuBlip class --- common/Drawings/Format/Format.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/Drawings/Format/Format.js b/common/Drawings/Format/Format.js index 728d25a115..9718c0ca42 100644 --- a/common/Drawings/Format/Format.js +++ b/common/Drawings/Format/Format.js @@ -5485,7 +5485,7 @@ function FormatRGBAColor() if (compareObj instanceof CBuBlip) { ret = new CBuBlip(); if (this.blip) { - ret.setBlip(this.blip.compare(compareObj)); + ret.setBlip(this.blip.compare(compareObj.blip)); } } return ret; From 463783313c13d88a47a5e648cf4953ad986bf63b Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Tue, 18 Jan 2022 18:14:21 +0300 Subject: [PATCH 16/31] fix: add return for cases, when image not available --- slide/api.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/slide/api.js b/slide/api.js index 2a84eeaf6a..e4d4594faa 100644 --- a/slide/api.js +++ b/slide/api.js @@ -2777,6 +2777,7 @@ background-repeat: no-repeat;\ that.put_ListType(undefined, undefined, blip); } this.ImageLoader.LoadImagesWithCallback([blipUrl], tryToSetImageBulletAgain); + return; } } else { var changeBlipFillUrlToLocalAndTrySetImageBulletAgain = function (data) { @@ -2785,6 +2786,7 @@ background-repeat: no-repeat;\ that.put_ListType(undefined, undefined, blip); } AscCommon.sendImgUrls(this, [blipUrl], changeBlipFillUrlToLocalAndTrySetImageBulletAgain, false, true, blip.token); + return; } } var oPresentation = this.WordControl.m_oLogicDocument; From cc9300fdef39cdd94c3a294f4439dc3e48dab071 Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Tue, 18 Jan 2022 18:15:43 +0300 Subject: [PATCH 17/31] fix: add Write_ToBinary and Read_FromBinary for new fields --- common/Drawings/Format/Format.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/common/Drawings/Format/Format.js b/common/Drawings/Format/Format.js index 9718c0ca42..1e019a7e3b 100644 --- a/common/Drawings/Format/Format.js +++ b/common/Drawings/Format/Format.js @@ -5480,6 +5480,20 @@ function FormatRGBAColor() pReader.ReadBlip(this.blip); } + CBuBlip.prototype.Read_FromBinary = function (r) { + if (r.GetBool()) { + this.blip = new CUniFill(); + this.blip.Read_FromBinary(r); + } + }; + + CBuBlip.prototype.Write_ToBinary = function (w) { + w.WriteBool(isRealObject(this.blip)); + if (isRealObject(this.blip)) { + this.blip.Write_ToBinary(w); + } + }; + CBuBlip.prototype.compare = function (compareObj) { var ret = null; if (compareObj instanceof CBuBlip) { @@ -11757,6 +11771,10 @@ CBulletType.prototype = { w.WriteLong(this.startAt); } + w.WriteBool(isRealObject(this.Blip)); + if (isRealObject(this.Blip)) { + this.Blip.Write_ToBinary(w); + } }, Read_FromBinary: function(r) @@ -11781,6 +11799,10 @@ CBulletType.prototype = { (this.startAt) = r.GetLong(); } + if (r.GetBool()) { + this.Blip = new CBuBlip(); + this.Blip.Read_FromBinary(r); + } } }; From 15beb972cff4b8b1c28c07f2cd5d1edd9a6a1c5e Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Tue, 18 Jan 2022 18:17:46 +0300 Subject: [PATCH 18/31] feat: add plug for change image bullet settings and method for get rasterImageId from bullet --- common/Drawings/Format/Format.js | 53 ++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/common/Drawings/Format/Format.js b/common/Drawings/Format/Format.js index 1e019a7e3b..3134623ee6 100644 --- a/common/Drawings/Format/Format.js +++ b/common/Drawings/Format/Format.js @@ -11217,6 +11217,55 @@ function CompareBullets(bullet1, bullet2) this.bulletType.Blip.setBlip(AscFormat.CreateBlipFillUniFillFromUrl(url)); } + CBullet.prototype.getImageBulletURL = function () { + return (this.bulletType + && this.bulletType.Blip + && this.bulletType.Blip.blip + && this.bulletType.Blip.blip.fill + && this.bulletType.Blip.blip.fill.RasterImageId); + } + + CBullet.prototype.drawSquareImage = function () { + var url = this.getImageBulletURL(); + if(!url || !editor){ + return; + } + var oDiv = document.getElementById(this.DivId); + if(!oDiv){ + return; + } + var aChildren = oDiv.children; + var oCanvas = null; + for(var i = 0; i < aChildren.length; ++i){ + if(aChildren[i].nodeName && aChildren[i].nodeName.toUpperCase() === 'CANVAS'){ + oCanvas = aChildren[i]; + break; + } + } + var nWidth = oDiv.clientWidth; + var nHeight = oDiv.clientHeight; + if (nWidth !== nHeight) { + return; + } + if(null === oCanvas){ + oCanvas = document.createElement('canvas'); + oCanvas.width = parseInt(nWidth); + oCanvas.height = parseInt(nHeight); + oDiv.appendChild(oCanvas); + } + var oContext = oCanvas.getContext('2d'); + oContext.clearRect(0, 0, oCanvas.width, oCanvas.height); + var _img = this.Api.ImageLoader.map_image_index[AscCommon.getFullImageSrc2(url)]; + if (_img != undefined && _img.Image != null && _img.Status != AscFonts.ImageLoadStatus.Loading) + { + var indent = nWidth * 0.125; + var _x = indent; + var _y = indent; + var _w = nWidth - indent; + var _h = nHeight - indent; + oContext.drawImage(_img.Image, _x, _y, _w, _h); + } + } //interface methods var prot = CBullet.prototype; prot.put_ImageUrl = function (sUrl, token) { @@ -11232,7 +11281,7 @@ function CompareBullets(bullet1, bullet2) var url = AscCommon.g_oDocumentUrls.imagePath2Local(data[0].path); Api.ImageLoader.LoadImagesWithCallback([AscCommon.getFullImageSrc2(url)], function(){ _this.fillBulletImage(url); - editor.WordControl.m_oLogicDocument.SetParagraphNumbering(this); + _this.drawSquareImage(); _this.Api.sendEvent("asc_onBulletImageLoaded"); }); } @@ -11267,7 +11316,7 @@ function CompareBullets(bullet1, bullet2) if(urls.length > 0) { _this.fillBulletImage(urls[0]); - editor.WordControl.m_oLogicDocument.SetParagraphNumbering(this); + _this.drawSquareImage(); t.sendEvent("asc_onBulletImageLoaded"); } t.sync_EndAction(Asc.c_oAscAsyncActionType.BlockInteraction, Asc.c_oAscAsyncAction.UploadImage); From 2793a6ad6e345d28130422de977dd35eb1088ca8 Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Tue, 18 Jan 2022 18:22:30 +0300 Subject: [PATCH 19/31] refactor: delete unusual for image bullet in presentation --- word/Editor/Numbering/PresentationNumbering.js | 13 ++++--------- word/Editor/Styles.js | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/word/Editor/Numbering/PresentationNumbering.js b/word/Editor/Numbering/PresentationNumbering.js index 5a19095e0b..042e47443c 100644 --- a/word/Editor/Numbering/PresentationNumbering.js +++ b/word/Editor/Numbering/PresentationNumbering.js @@ -193,7 +193,6 @@ function CPresentationBullet() this.m_nNum = null; this.m_sString = null; - this.m_oBlip = null; this.m_sSrc = null; } @@ -359,10 +358,8 @@ CPresentationBullet.prototype.Measure = function(Context, FirstTextPr, Num, Them { sT = this.m_sChar; } - } else if (this.m_nType === numbering_presentationnumfrmt_Blip) + } else if (this.m_nType !== numbering_presentationnumfrmt_Blip) { - this.m_sSrc = AscCommon.getFullImageSrc2(this.m_oBlip.blip.fill.RasterImageId); - } else { var typeOfNum = getAdaptedNumberingFormat(this.m_nType); var formatNum = IntToNumberFormat(Num, typeOfNum); sT = this.getHighlightForNumbering(formatNum); @@ -495,20 +492,18 @@ CPresentationBullet.prototype.Copy = function() Bullet.m_dSize = this.m_dSize; Bullet.m_bSizeTx = this.m_bSizeTx; Bullet.m_bSizePct = this.m_bSizePct; - if (this.m_oBlip) { - Bullet.m_oBlip = this.m_oBlip.createDuplicate(); - } + Bullet.m_sSrc = this.m_sSrc; return Bullet; }; CPresentationBullet.prototype.IsErrorInNumeration = function() { - return (null === this.m_oTextPr + return ((null === this.m_oTextPr || null === this.m_nNum || null == this.m_sString || this.m_sString.length === 0) - && this.m_oBlip === null; + && this.m_sSrc === null); } CPresentationBullet.prototype.Draw = function(X, Y, Context, PDSE) diff --git a/word/Editor/Styles.js b/word/Editor/Styles.js index 56653e4407..3b4d04b0ea 100644 --- a/word/Editor/Styles.js +++ b/word/Editor/Styles.js @@ -17145,7 +17145,7 @@ CParaPr.prototype.Get_PresentationBullet = function(theme, colorMap) case AscFormat.BULLET_TYPE_BULLET_BLIP : { Bullet.m_nType = numbering_presentationnumfrmt_Blip; - Bullet.m_oBlip = this.Bullet.bulletType.Blip; + Bullet.m_sSrc = AscCommon.getFullImageSrc2(this.Bullet.getImageBulletURL()); break; } } From 0cd2b855757d47e318f0e48b74e955db8ebf4f51 Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Tue, 18 Jan 2022 18:24:04 +0300 Subject: [PATCH 20/31] feat: add images for collaborative mode --- common/Drawings/CommonController.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common/Drawings/CommonController.js b/common/Drawings/CommonController.js index 925f2c632e..4d90378a6f 100644 --- a/common/Drawings/CommonController.js +++ b/common/Drawings/CommonController.js @@ -11558,6 +11558,14 @@ function CalcLiterByLength(aAlphaBet, nLength) bullet.bulletType = new AscFormat.CBulletType(); bullet.bulletType.type = AscFormat.BULLET_TYPE_BULLET_BLIP; bullet.bulletType.setBlip(buBlip); + var sRasterImageId = blip.fill.RasterImageId; + if(typeof AscCommon.CollaborativeEditing !== "undefined") + { + if(typeof sRasterImageId === "string" && sRasterImageId.length > 0) + { + AscCommon.CollaborativeEditing.Add_NewImage(sRasterImageId); + } + } } From 8eb19264e6aa0607c296582c1f8aaebfcef274c8 Mon Sep 17 00:00:00 2001 From: Sergey Luzyanin Date: Tue, 18 Jan 2022 19:03:11 +0300 Subject: [PATCH 21/31] [imageBullet] fix image loading on coauthoring --- common/Drawings/CommonController.js | 8 ------- common/Drawings/Format/Format.js | 33 ++++++++++++++++++----------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/common/Drawings/CommonController.js b/common/Drawings/CommonController.js index 4d90378a6f..925f2c632e 100644 --- a/common/Drawings/CommonController.js +++ b/common/Drawings/CommonController.js @@ -11558,14 +11558,6 @@ function CalcLiterByLength(aAlphaBet, nLength) bullet.bulletType = new AscFormat.CBulletType(); bullet.bulletType.type = AscFormat.BULLET_TYPE_BULLET_BLIP; bullet.bulletType.setBlip(buBlip); - var sRasterImageId = blip.fill.RasterImageId; - if(typeof AscCommon.CollaborativeEditing !== "undefined") - { - if(typeof sRasterImageId === "string" && sRasterImageId.length > 0) - { - AscCommon.CollaborativeEditing.Add_NewImage(sRasterImageId); - } - } } diff --git a/common/Drawings/Format/Format.js b/common/Drawings/Format/Format.js index 3134623ee6..79cdbe5758 100644 --- a/common/Drawings/Format/Format.js +++ b/common/Drawings/Format/Format.js @@ -5437,18 +5437,11 @@ function FormatRGBAColor() }; - AscDFH.changesFactory[AscDFH.historyitem_BuBlipBlip] = CChangesDrawingsObjectNoId; - drawingsChangesMap[AscDFH.historyitem_BuBlipBlip] = function (oClass, value) { - oClass.blip = value; - }; function CBuBlip() { - CBaseFormatObject.call(this); this.blip = null; } - InitClass(CBuBlip, CBaseFormatObject, AscDFH.historyitem_type_BuBlip); CBuBlip.prototype.setBlip = function (oPr) { - History.Add(new CChangesDrawingsObjectNoId(this, AscDFH.historyitem_BuBlipBlip, this.blip, oPr)); this.blip = oPr; }; @@ -5456,11 +5449,17 @@ function FormatRGBAColor() if (this.blip) { oCopy.setBlip(this.blip.createDuplicate(oIdMap)); } - } + }; + + CBuBlip.prototype.createDuplicate = function () { + var oCopy = new CBuBlip(); + this.fillObject(oCopy, {}); + return oCopy; + }; CBuBlip.prototype.getChildren = function () { return [this.blip]; - } + }; CBuBlip.prototype.toPPTY = function (pWriter) { var _src = this.blip.fill.RasterImageId; @@ -5472,13 +5471,13 @@ function FormatRGBAColor() _src = pWriter.prepareRasterImageIdForWrite(_src); pWriter.WriteBlip(this.blip.fill, _src); - } + }; CBuBlip.prototype.fromPPTY = function (pReader) { this.setBlip(new AscFormat.CUniFill()); this.blip.setFill(new AscFormat.CBlipFill()); pReader.ReadBlip(this.blip); - } + }; CBuBlip.prototype.Read_FromBinary = function (r) { if (r.GetBool()) { @@ -5503,7 +5502,7 @@ function FormatRGBAColor() } } return ret; - } + }; function CompareUniFill(unifill_1, unifill_2) { @@ -11851,6 +11850,16 @@ CBulletType.prototype = if (r.GetBool()) { this.Blip = new CBuBlip(); this.Blip.Read_FromBinary(r); + + var oUnifill = this.Blip.blip; + var sRasterImageId = oUnifill && oUnifill.fill && oUnifill.fill.RasterImageId; + if(typeof AscCommon.CollaborativeEditing !== "undefined") + { + if(typeof sRasterImageId === "string" && sRasterImageId.length > 0) + { + AscCommon.CollaborativeEditing.Add_NewImage(sRasterImageId); + } + } } } }; From eddf87a251c2e2d0f3d87f0831046ce0eb45d4c9 Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Wed, 19 Jan 2022 12:05:15 +0300 Subject: [PATCH 22/31] fix: recalculate image bullet drawing --- .../Editor/Numbering/PresentationNumbering.js | 45 ++++++++----------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/word/Editor/Numbering/PresentationNumbering.js b/word/Editor/Numbering/PresentationNumbering.js index 042e47443c..cda29033df 100644 --- a/word/Editor/Numbering/PresentationNumbering.js +++ b/word/Editor/Numbering/PresentationNumbering.js @@ -433,6 +433,15 @@ CPresentationBullet.prototype.Measure = function(Context, FirstTextPr, Num, Them FirstTextPr_.Merge(TextPr_); this.m_oTextPr = FirstTextPr_; + if (this.m_nType === numbering_presentationnumfrmt_Blip) + { + var sizes = AscCommon.getSourceImageSize(this.m_sSrc); + var x_height = this.m_oTextPr.FontSize / 4; + var adaptImageHeight = x_height; + var adaptImageWidth = sizes.width * adaptImageHeight / (sizes.height ? sizes.height : 1); + return { Width: adaptImageWidth + adaptImageWidth / 35 }; + } + var X = 0; var OldTextPr = Context.GetTextPr(); var Hint = this.m_oTextPr.RFonts.Hint; @@ -443,19 +452,9 @@ CPresentationBullet.prototype.Measure = function(Context, FirstTextPr, Num, Them if (sT) { FontSlot = g_font_detector.Get_FontClass( sT.getUnicodeIterator().value(), Hint, lcid, bCS, bRTL ); - } else { - FontSlot = g_font_detector.Get_FontClass( 42, Hint, lcid, bCS, bRTL ); } Context.SetTextPr( this.m_oTextPr, Theme ); Context.SetFontSlot( FontSlot ); - if (this.m_nType === numbering_presentationnumfrmt_Blip) - { - var sizes = AscCommon.getSourceImageSize(this.m_sSrc); - var x_height = g_oTextMeasurer.GetHeight() - (g_oTextMeasurer.GetAscender() + g_oTextMeasurer.GetDescender()); - var adaptImageHeight = x_height; - var adaptImageWidth = sizes.width * adaptImageHeight / sizes.height; - return { Width: adaptImageWidth + adaptImageWidth / 35 }; // TODO: существует добавочная единица (какая?) - } if(sT.length === 0) { @@ -511,7 +510,15 @@ CPresentationBullet.prototype.Draw = function(X, Y, Context, PDSE) if (this.IsErrorInNumeration()) return; - + if (this.m_nType === numbering_presentationnumfrmt_Blip) + { + var sizes = AscCommon.getSourceImageSize(this.m_sSrc); + var x_height = this.m_oTextPr.FontSize / 4; + var adaptImageHeight = x_height; + var adaptImageWidth = sizes.width * adaptImageHeight / (sizes.height ? sizes.height : 1); + Context.drawImage(this.m_sSrc, X, Y - adaptImageHeight, adaptImageWidth, adaptImageHeight); + return; + } var OldTextPr = Context.GetTextPr(); var OldTextPr2 = g_oTextMeasurer.GetTextPr(); @@ -526,11 +533,8 @@ CPresentationBullet.prototype.Draw = function(X, Y, Context, PDSE) if (sT) { FontSlot = g_font_detector.Get_FontClass( sT.getUnicodeIterator().value(), Hint, lcid, bCS, bRTL ); - } else { - FontSlot = g_font_detector.Get_FontClass( 42, Hint, lcid, bCS, bRTL ); } - if(this.m_oTextPr.Unifill){ this.m_oTextPr.Unifill.check(PDSE.Theme, PDSE.ColorMap); } @@ -571,25 +575,14 @@ CPresentationBullet.prototype.Draw = function(X, Y, Context, PDSE) } g_oTextMeasurer.SetTextPr( this.m_oTextPr, PDSE.Theme ); g_oTextMeasurer.SetFontSlot( FontSlot ); - if (this.m_nType === numbering_presentationnumfrmt_Blip) - { - var sizes = AscCommon.getSourceImageSize(this.m_sSrc); - var x_height = g_oTextMeasurer.GetHeight() - (g_oTextMeasurer.GetAscender() + g_oTextMeasurer.GetDescender());// TODO: think about it - var adaptImageHeight = x_height; - var adaptImageWidth = sizes.width * adaptImageHeight / sizes.height; - - Context.drawImage(this.m_sSrc, X, Y - adaptImageHeight, adaptImageWidth, adaptImageHeight); - } - if (this.m_nType !== numbering_presentationnumfrmt_Blip) - { for (var iter = sT.getUnicodeIterator(); iter.check(); iter.next()) { var charCode = iter.value(); Context.FillTextCode( X, Y, charCode ); X += g_oTextMeasurer.MeasureCode(charCode).Width; } - } + if(OldTextPr) { Context.SetTextPr( OldTextPr, PDSE.Theme ); From 3dc0b97de2fcc28f81ef5577da67185e8b47b505 Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Wed, 19 Jan 2022 12:05:55 +0300 Subject: [PATCH 23/31] fix: add BuBlip isEqual method --- common/Drawings/Format/Format.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/Drawings/Format/Format.js b/common/Drawings/Format/Format.js index 79cdbe5758..97e15b640c 100644 --- a/common/Drawings/Format/Format.js +++ b/common/Drawings/Format/Format.js @@ -5461,6 +5461,10 @@ function FormatRGBAColor() return [this.blip]; }; + CBuBlip.prototype.isEqual = function (oBlip) { + return this.blip.isEqual(oBlip.blip); + }; + CBuBlip.prototype.toPPTY = function (pWriter) { var _src = this.blip.fill.RasterImageId; var imageLocal = AscCommon.g_oDocumentUrls.getImageLocal(_src); From 861e7d788c9eccddbe03ae2e06724077aac2433a Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Wed, 19 Jan 2022 15:21:04 +0300 Subject: [PATCH 24/31] fix: load images to server from url blipFill --- slide/api.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/slide/api.js b/slide/api.js index e4d4594faa..686d170842 100644 --- a/slide/api.js +++ b/slide/api.js @@ -2767,7 +2767,14 @@ background-repeat: no-repeat;\ var blipUrl = blip instanceof Asc.asc_CFillBlip && blip.url; if (blipUrl) { var that = this; - var checkImageUrlFromServer = AscFormat.checkRasterImageId(blipUrl); + var checkImageUrlFromServer; + var localUrl = AscCommon.g_oDocumentUrls.getLocal(blipUrl); + var fullUrl = AscCommon.g_oDocumentUrls.getUrl(blipUrl); + if (fullUrl) { + checkImageUrlFromServer = fullUrl; + } else if (localUrl) { + checkImageUrlFromServer = blipUrl; + } if (checkImageUrlFromServer) { blipUrl = checkImageUrlFromServer; blip.url = blipUrl; @@ -2781,7 +2788,7 @@ background-repeat: no-repeat;\ } } else { var changeBlipFillUrlToLocalAndTrySetImageBulletAgain = function (data) { - var uploadImageUrl = data[0].path; + var uploadImageUrl = data[0].url; blip.url = uploadImageUrl; that.put_ListType(undefined, undefined, blip); } From 3db4217e0d016f9b03a31f5381a88d7865d56ff2 Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Wed, 19 Jan 2022 16:51:16 +0300 Subject: [PATCH 25/31] fix: indents in image bullets --- word/Editor/Paragraph.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/word/Editor/Paragraph.js b/word/Editor/Paragraph.js index 90c5f13865..71c07565ab 100644 --- a/word/Editor/Paragraph.js +++ b/word/Editor/Paragraph.js @@ -9587,7 +9587,7 @@ Paragraph.prototype.Add_PresentationNumbering = function(Bullet) var oFirstRunPr = this.Get_FirstTextPr2(); var Indent = oFirstRunPr.FontSize*0.305954545 + 2.378363636; - if (NewType === numbering_presentationnumfrmt_Char || NewType === numbering_presentationnumfrmt_Blip) + if (NewType === numbering_presentationnumfrmt_Char) { this.Set_Ind({Left : LeftInd + Indent, FirstLine : -Indent}, false); } @@ -9595,7 +9595,7 @@ Paragraph.prototype.Add_PresentationNumbering = function(Bullet) { this.Set_Ind({FirstLine : 0, Left : LeftInd}, false); } - else + else if (NewType !== numbering_presentationnumfrmt_Blip) { if (!IsPrNumberingSameType(NewType, UndefType)) { From 09e75e3f16a54d21974a8fce96dd23c407d3ae88 Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Thu, 20 Jan 2022 12:14:30 +0300 Subject: [PATCH 26/31] fix: koef for image size of image bullet --- word/Editor/Numbering/PresentationNumbering.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/word/Editor/Numbering/PresentationNumbering.js b/word/Editor/Numbering/PresentationNumbering.js index cda29033df..96f472b0bf 100644 --- a/word/Editor/Numbering/PresentationNumbering.js +++ b/word/Editor/Numbering/PresentationNumbering.js @@ -42,6 +42,7 @@ var g_oTextMeasurer = AscCommon.g_oTextMeasurer; var History = AscCommon.History; var IntToNumberFormat = window["AscCommon"].IntToNumberFormat; +var kHeightImageBullet = 1 / 4.043478260869565; var numbering_presentationnumfrmt_AlphaLcParenBoth = 0; var numbering_presentationnumfrmt_AlphaLcParenR = 1; @@ -436,10 +437,10 @@ CPresentationBullet.prototype.Measure = function(Context, FirstTextPr, Num, Them if (this.m_nType === numbering_presentationnumfrmt_Blip) { var sizes = AscCommon.getSourceImageSize(this.m_sSrc); - var x_height = this.m_oTextPr.FontSize / 4; + var x_height = this.m_oTextPr.FontSize * kHeightImageBullet; var adaptImageHeight = x_height; var adaptImageWidth = sizes.width * adaptImageHeight / (sizes.height ? sizes.height : 1); - return { Width: adaptImageWidth + adaptImageWidth / 35 }; + return { Width: adaptImageWidth }; } var X = 0; @@ -513,7 +514,7 @@ CPresentationBullet.prototype.Draw = function(X, Y, Context, PDSE) if (this.m_nType === numbering_presentationnumfrmt_Blip) { var sizes = AscCommon.getSourceImageSize(this.m_sSrc); - var x_height = this.m_oTextPr.FontSize / 4; + var x_height = this.m_oTextPr.FontSize * kHeightImageBullet; var adaptImageHeight = x_height; var adaptImageWidth = sizes.width * adaptImageHeight / (sizes.height ? sizes.height : 1); Context.drawImage(this.m_sSrc, X, Y - adaptImageHeight, adaptImageWidth, adaptImageHeight); From 929abe97da0b70ee4fed51dee6ae5a8cbcf914bd Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Thu, 20 Jan 2022 12:21:56 +0300 Subject: [PATCH 27/31] fix: check load images from url for errors --- slide/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slide/api.js b/slide/api.js index 686d170842..c3eccfa9d2 100644 --- a/slide/api.js +++ b/slide/api.js @@ -2792,7 +2792,7 @@ background-repeat: no-repeat;\ blip.url = uploadImageUrl; that.put_ListType(undefined, undefined, blip); } - AscCommon.sendImgUrls(this, [blipUrl], changeBlipFillUrlToLocalAndTrySetImageBulletAgain, false, true, blip.token); + AscCommon.sendImgUrls(this, [blipUrl], changeBlipFillUrlToLocalAndTrySetImageBulletAgain, false, false, blip.token); return; } } From 9c3643fd4863501456f66b8463892c76e22e84b5 Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Thu, 20 Jan 2022 12:26:23 +0300 Subject: [PATCH 28/31] refactor: delete unusual console.log --- common/Shapes/Serialize.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/common/Shapes/Serialize.js b/common/Shapes/Serialize.js index e42ad7f985..18550ccc6d 100644 --- a/common/Shapes/Serialize.js +++ b/common/Shapes/Serialize.js @@ -3238,7 +3238,6 @@ function BinaryPPTYLoader() s.Skip2(1); uni_fill.setFill(new AscFormat.CBlipFill()); - console.log(oImageShape); while (true) { @@ -9684,7 +9683,6 @@ function BinaryPPTYLoader() var buBlip = new AscFormat.CBuBlip(); buBlip.fromPPTY(this); bullet.bulletType.setBlip(buBlip); - console.log(bullet); } else if (bullet.bulletType.type == AscFormat.BULLET_TYPE_BULLET_AUTONUM) { From 01ce2249633662b312a6146e56cbeddadb2de92f Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Thu, 20 Jan 2022 12:31:08 +0300 Subject: [PATCH 29/31] docs: comment mock method --- common/Drawings/Format/Format.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/Drawings/Format/Format.js b/common/Drawings/Format/Format.js index 97e15b640c..b9613ae235 100644 --- a/common/Drawings/Format/Format.js +++ b/common/Drawings/Format/Format.js @@ -11284,11 +11284,11 @@ function CompareBullets(bullet1, bullet2) var url = AscCommon.g_oDocumentUrls.imagePath2Local(data[0].path); Api.ImageLoader.LoadImagesWithCallback([AscCommon.getFullImageSrc2(url)], function(){ _this.fillBulletImage(url); - _this.drawSquareImage(); + //_this.drawSquareImage(); _this.Api.sendEvent("asc_onBulletImageLoaded"); }); } - }, false, undefined, token); + }, false, false, token); } prot["put_ImageUrl"] = prot["asc_putImageUrl"] = CBullet.prototype.put_ImageUrl; prot.showFileDialog = function () { @@ -11319,7 +11319,7 @@ function CompareBullets(bullet1, bullet2) if(urls.length > 0) { _this.fillBulletImage(urls[0]); - _this.drawSquareImage(); + //_this.drawSquareImage(); t.sendEvent("asc_onBulletImageLoaded"); } t.sync_EndAction(Asc.c_oAscAsyncActionType.BlockInteraction, Asc.c_oAscAsyncAction.UploadImage); From 43b185357b899b10d4bc90942b55b317f021f31a Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Thu, 20 Jan 2022 17:09:12 +0300 Subject: [PATCH 30/31] refactor: delete unusual font pickers --- word/Editor/Numbering/NumberingLvl.js | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/word/Editor/Numbering/NumberingLvl.js b/word/Editor/Numbering/NumberingLvl.js index 39ac5651e1..1d9f36eea4 100644 --- a/word/Editor/Numbering/NumberingLvl.js +++ b/word/Editor/Numbering/NumberingLvl.js @@ -1746,10 +1746,6 @@ CNumberingLvl.prototype.private_CheckSymbols = function() AscFonts.FontPickerByCharacter.getFontBySymbol(0x4F70); AscFonts.FontPickerByCharacter.getFontBySymbol(0x4EDF); AscFonts.FontPickerByCharacter.getFontBySymbol(0x842C); - AscFonts.FontPickerByCharacter.getFontBySymbol('萬'.charCodeAt(0)); - AscFonts.FontPickerByCharacter.getFontBySymbol('仟'.charCodeAt(0)); - AscFonts.FontPickerByCharacter.getFontBySymbol('佰'.charCodeAt(0)); - AscFonts.FontPickerByCharacter.getFontBySymbol('拾'.charCodeAt(0)); break; } case Asc.c_oAscNumberingFormat.IdeographTraditional: @@ -1928,9 +1924,6 @@ CNumberingLvl.prototype.private_CheckSymbols = function() AscFonts.FontPickerByCharacter.getFontBySymbol(0x5341); AscFonts.FontPickerByCharacter.getFontBySymbol(0x5343); AscFonts.FontPickerByCharacter.getFontBySymbol(0x767E); - AscFonts.FontPickerByCharacter.getFontBySymbol('千'.charCodeAt(0)); - AscFonts.FontPickerByCharacter.getFontBySymbol('百'.charCodeAt(0)); - AscFonts.FontPickerByCharacter.getFontBySymbol('十'.charCodeAt(0)); break; } case Asc.c_oAscNumberingFormat.JapaneseLegal: @@ -1947,10 +1940,7 @@ CNumberingLvl.prototype.private_CheckSymbols = function() AscFonts.FontPickerByCharacter.getFontBySymbol(0x62FE); AscFonts.FontPickerByCharacter.getFontBySymbol(0x767E); AscFonts.FontPickerByCharacter.getFontBySymbol(0x842C); - AscFonts.FontPickerByCharacter.getFontBySymbol('萬'.charCodeAt(0)); - AscFonts.FontPickerByCharacter.getFontBySymbol('阡'.charCodeAt(0)); - AscFonts.FontPickerByCharacter.getFontBySymbol('百'.charCodeAt(0)); - AscFonts.FontPickerByCharacter.getFontBySymbol('拾'.charCodeAt(0)); + AscFonts.FontPickerByCharacter.getFontBySymbol(0x9621); break; } case Asc.c_oAscNumberingFormat.KoreanCounting: @@ -1968,10 +1958,6 @@ CNumberingLvl.prototype.private_CheckSymbols = function() AscFonts.FontPickerByCharacter.getFontBySymbol(0xB9CC); AscFonts.FontPickerByCharacter.getFontBySymbol(0xCC9C); AscFonts.FontPickerByCharacter.getFontBySymbol(0xBC31); - AscFonts.FontPickerByCharacter.getFontBySymbol('만'.charCodeAt(0)); - AscFonts.FontPickerByCharacter.getFontBySymbol('천'.charCodeAt(0)); - AscFonts.FontPickerByCharacter.getFontBySymbol('백'.charCodeAt(0)); - AscFonts.FontPickerByCharacter.getFontBySymbol('십'.charCodeAt(0)); break; } case Asc.c_oAscNumberingFormat.KoreanDigital: From e853997b02c90111ab75b3115f9e192ddf2cab7d Mon Sep 17 00:00:00 2001 From: Sergey Luzyanin Date: Thu, 20 Jan 2022 22:56:11 +0300 Subject: [PATCH 31/31] [imageBullet] fix loading images in spreadsheets, fix copy/paste --- common/Drawings/Format/Format.js | 4 ++-- common/Drawings/Format/Shape.js | 24 ++++++++++++++++++++++++ common/Shapes/Serialize.js | 27 +++++++++++++++++++++------ common/editorscommon.js | 9 ++++++--- 4 files changed, 53 insertions(+), 11 deletions(-) diff --git a/common/Drawings/Format/Format.js b/common/Drawings/Format/Format.js index b9613ae235..01151346d6 100644 --- a/common/Drawings/Format/Format.js +++ b/common/Drawings/Format/Format.js @@ -5477,10 +5477,10 @@ function FormatRGBAColor() pWriter.WriteBlip(this.blip.fill, _src); }; - CBuBlip.prototype.fromPPTY = function (pReader) { + CBuBlip.prototype.fromPPTY = function (pReader, oParagraph, oBullet) { this.setBlip(new AscFormat.CUniFill()); this.blip.setFill(new AscFormat.CBlipFill()); - pReader.ReadBlip(this.blip); + pReader.ReadBlip(this.blip, undefined, undefined, undefined, oParagraph, oBullet); }; CBuBlip.prototype.Read_FromBinary = function (r) { diff --git a/common/Drawings/Format/Shape.js b/common/Drawings/Format/Shape.js index a17857047f..150c3ec6f8 100644 --- a/common/Drawings/Format/Shape.js +++ b/common/Drawings/Format/Shape.js @@ -992,6 +992,25 @@ function SetXfrmFromMetrics(oDrawing, metrics) } }; + function getBulletImages(oContent, aImages) { + if(!oContent) { + return; + } + var aParagraphs = oContent.Content; + var sImageId; + for(var nPar = 0; nPar < aParagraphs.length; ++nPar) + { + var oPr = aParagraphs[nPar].Pr; + if(oPr.Bullet) + { + sImageId = oPr.Bullet.getImageBulletURL(); + if(sImageId) + { + aImages.push(sImageId); + } + } + } + } function CSignatureLine(){ this.id = null; @@ -1654,6 +1673,7 @@ CShape.prototype.getAllImages = function (images) { if (this.spPr && this.spPr.Fill && this.spPr.Fill.fill instanceof AscFormat.CBlipFill && typeof this.spPr.Fill.fill.RasterImageId === "string") { images[AscCommon.getFullImageSrc2(this.spPr.Fill.fill.RasterImageId)] = true; } + getBulletImages(this.getDocContent && this.getDocContent(), images); }; CShape.prototype.getAllFonts = function (fonts) { @@ -5914,6 +5934,10 @@ CShape.prototype.getAllRasterImages = function(images) drawings[i].GraphicObj && drawings[i].GraphicObj.getAllRasterImages && drawings[i].GraphicObj.getAllRasterImages(images); } } + else + { + getBulletImages(oContent, images); + } var fCallback = function(oRun) { var oTextPr = oRun && oRun.Pr; diff --git a/common/Shapes/Serialize.js b/common/Shapes/Serialize.js index 18550ccc6d..5d483e4a20 100644 --- a/common/Shapes/Serialize.js +++ b/common/Shapes/Serialize.js @@ -99,7 +99,7 @@ function IsHiddenObj(object) return false; } -function CBuilderImages(blip_fill, full_url, image_shape, sp_pr, ln, text_pr, para_text_pr, run, paragraph) +function CBuilderImages(blip_fill, full_url, image_shape, sp_pr, ln, text_pr, para_text_pr, run, paragraph, bullet) { this.Url = full_url; this.BlipFill = blip_fill; @@ -111,6 +111,7 @@ function CBuilderImages(blip_fill, full_url, image_shape, sp_pr, ln, text_pr, pa this.ParaTextPr = para_text_pr; this.Run = run; this.Paragraph = paragraph; + this.Bullet = bullet; this.AdditionalUrls = [];//для wmf, ole } CBuilderImages.prototype = @@ -169,6 +170,20 @@ CBuilderImages.prototype = } } } + if(this.Bullet) + { + if(this.Paragraph) + { + var oPr = this.Paragraph.Pr; + var oBullet = oPr.Bullet; + if(oBullet.getImageBulletURL()) + { + var oNewPr = oPr.Copy(); + oNewPr.Bullet.fillBulletImage(url); + this.Paragraph.Set_Pr(oNewPr); + } + } + } this.BlipFill.RasterImageId = url; } } @@ -3092,7 +3107,7 @@ function BinaryPPTYLoader() return ret; }; - this.ReadBlip = function (uni_fill, oSpPr, oImageShape, oLn) { + this.ReadBlip = function (uni_fill, oSpPr, oImageShape, oLn, oParagraph, oBullet) { var s = this.stream; var _s2 = s.cur; var _e2 = _s2 + s.GetLong() + 4; @@ -3201,7 +3216,7 @@ function BinaryPPTYLoader() this.ImageMapChecker[sReadPath] = true; if (this.IsUseFullUrl) - this.RebuildImages.push(new CBuilderImages(uni_fill.fill, sReadPath, oImageShape, oSpPr, oLn)); + this.RebuildImages.push(new CBuilderImages(uni_fill.fill, sReadPath, oImageShape, oSpPr, oLn, undefined, undefined, undefined, oParagraph, oBullet)); s.Skip2(1); // end attribute break; @@ -3218,7 +3233,7 @@ function BinaryPPTYLoader() } - this.ReadUniFill = function(oSpPr, oImageShape, oLn) + this.ReadUniFill = function(oSpPr, oImageShape, oLn, oParagraph, oBullet) { var s = this.stream; var read_start = s.cur; @@ -3266,7 +3281,7 @@ function BinaryPPTYLoader() { case 0: { - this.ReadBlip(uni_fill, oSpPr, oImageShape, oLn); + this.ReadBlip(uni_fill, oSpPr, oImageShape, oLn, oParagraph, oBullet); break; } case 1: @@ -9681,7 +9696,7 @@ function BinaryPPTYLoader() { s.Skip2(5); var buBlip = new AscFormat.CBuBlip(); - buBlip.fromPPTY(this); + buBlip.fromPPTY(this, par, bullet); bullet.bulletType.setBlip(buBlip); } else if (bullet.bulletType.type == AscFormat.BULLET_TYPE_BULLET_AUTONUM) diff --git a/common/editorscommon.js b/common/editorscommon.js index 44c7ddc4ba..18b41ee40b 100644 --- a/common/editorscommon.js +++ b/common/editorscommon.js @@ -1003,9 +1003,12 @@ } function getSourceImageSize(src) { - var _img = editor.ImageLoader.map_image_index[src]; - if (_img && _img.Image) { - return {width: _img.Image.width, height: _img.Image.height}; + var oApi = (Asc.editor || editor); + if(oApi) { + var _img = oApi.ImageLoader.map_image_index[src]; + if (_img && _img.Image) { + return {width: _img.Image.width, height: _img.Image.height}; + } } return {width: 0, height: 0}; }