diff --git a/cell/apiBuilder.js b/cell/apiBuilder.js index 531b4cea8a..0c4f9dccfb 100644 --- a/cell/apiBuilder.js +++ b/cell/apiBuilder.js @@ -13152,6 +13152,84 @@ return false; }; + /** + * Sets the fill properties to the current shape. + * @memberof ApiShape + * @typeofeditors ["CSE"] + * @param {ApiFill} oFill - The fill type used to fill the shape. + * @returns {boolean} - returns false if param is invalid. + * @see office-js-api/Examples/{Editor}/ApiShape/Methods/SetFill.js + */ + ApiShape.prototype.SetFill = function(oFill) + { + if (!oFill || !oFill.GetClassType || oFill.GetClassType() !== "fill") + return false; + + if (this.Shape && this.Shape.spPr) + { + this.Shape.spPr.setFill(oFill.UniFill); + return true; + } + + return false; + }; + + /** + * Gets the fill properties from the current shape. + * @memberof ApiShape + * @typeofeditors ["CSE"] + * @returns {ApiFill | null} + * @see office-js-api/Examples/{Editor}/ApiShape/Methods/GetFill.js + */ + ApiShape.prototype.GetFill = function() + { + if (this.Shape && this.Shape.spPr && this.Shape.spPr.Fill) + { + return new AscBuilder.ApiFill(this.Shape.spPr.Fill); + } + + return null; + }; + + /** + * Sets the outline properties to the current shape. + * @memberof ApiShape + * @typeofeditors ["CSE"] + * @param {ApiStroke} oStroke - The stroke used to create the shape outline. + * @returns {boolean} - returns false if param is invalid. + * @see office-js-api/Examples/{Editor}/ApiShape/Methods/SetLine.js + */ + ApiShape.prototype.SetLine = function(oStroke) + { + if (!oStroke || !oStroke.GetClassType || oStroke.GetClassType() !== "stroke") + return false; + + if (this.Shape && this.Shape.spPr) + { + this.Shape.spPr.setLn(oStroke.Ln); + return true; + } + + return false; + }; + + /** + * Gets the outline properties from the current shape. + * @memberof ApiShape + * @typeofeditors ["CSE"] + * @returns {ApiStroke | null} + * @see office-js-api/Examples/{Editor}/ApiShape/Methods/GetLine.js + */ + ApiShape.prototype.GetLine = function() + { + if (this.Shape && this.Shape.spPr && this.Shape.spPr.ln) + { + return new AscBuilder.ApiStroke(this.Shape.spPr.ln); + } + + return null; + }; + //------------------------------------------------------------------------------------------------------------------ // // ApiChart @@ -27507,6 +27585,10 @@ ApiShape.prototype["SetVerticalTextAlign"] = ApiShape.prototype.SetVerticalTextAlign; ApiShape.prototype["GetGeometry"] = ApiShape.prototype.GetGeometry; ApiShape.prototype["SetGeometry"] = ApiShape.prototype.SetGeometry; + ApiShape.prototype["SetFill"] = ApiShape.prototype.SetFill; + ApiShape.prototype["GetFill"] = ApiShape.prototype.GetFill; + ApiShape.prototype["SetLine"] = ApiShape.prototype.SetLine; + ApiShape.prototype["GetLine"] = ApiShape.prototype.GetLine; ApiChart.prototype["GetClassType"] = ApiChart.prototype.GetClassType = AscBuilder.ApiChart.prototype.GetClassType; ApiChart.prototype["GetChartType"] = ApiChart.prototype.GetChartType = AscBuilder.ApiChart.prototype.GetChartType; diff --git a/slide/apiBuilder.js b/slide/apiBuilder.js index 4b2c794188..786436bcba 100644 --- a/slide/apiBuilder.js +++ b/slide/apiBuilder.js @@ -5831,6 +5831,84 @@ return false; }; + /** + * Sets the fill properties to the current shape. + * @memberof ApiShape + * @typeofeditors ["CPE"] + * @param {ApiFill} oFill - The fill type used to fill the shape. + * @returns {boolean} - returns false if param is invalid. + * @see office-js-api/Examples/{Editor}/ApiShape/Methods/SetFill.js + */ + ApiShape.prototype.SetFill = function(oFill) + { + if (!oFill || !oFill.GetClassType || oFill.GetClassType() !== "fill") + return false; + + if (this.Shape && this.Shape.spPr) + { + this.Shape.spPr.setFill(oFill.UniFill); + return true; + } + + return false; + }; + + /** + * Gets the fill properties from the current shape. + * @memberof ApiShape + * @typeofeditors ["CPE"] + * @returns {ApiFill | null} + * @see office-js-api/Examples/{Editor}/ApiShape/Methods/GetFill.js + */ + ApiShape.prototype.GetFill = function() + { + if (this.Shape && this.Shape.spPr && this.Shape.spPr.Fill) + { + return new AscBuilder.ApiFill(this.Shape.spPr.Fill); + } + + return null; + }; + + /** + * Sets the outline properties to the current shape. + * @memberof ApiShape + * @typeofeditors ["CPE"] + * @param {ApiStroke} oStroke - The stroke used to create the shape outline. + * @returns {boolean} - returns false if param is invalid. + * @see office-js-api/Examples/{Editor}/ApiShape/Methods/SetLine.js + */ + ApiShape.prototype.SetLine = function(oStroke) + { + if (!oStroke || !oStroke.GetClassType || oStroke.GetClassType() !== "stroke") + return false; + + if (this.Shape && this.Shape.spPr) + { + this.Shape.spPr.setLn(oStroke.Ln); + return true; + } + + return false; + }; + + /** + * Gets the outline properties from the current shape. + * @memberof ApiShape + * @typeofeditors ["CPE"] + * @returns {ApiStroke | null} + * @see office-js-api/Examples/{Editor}/ApiShape/Methods/GetLine.js + */ + ApiShape.prototype.GetLine = function() + { + if (this.Shape && this.Shape.spPr && this.Shape.spPr.ln) + { + return new AscBuilder.ApiStroke(this.Shape.spPr.ln); + } + + return null; + }; + //------------------------------------------------------------------------------------------------------------------ // @@ -6798,7 +6876,7 @@ ApiSlideShowTransition.prototype["SetAdvanceOnTime"] = ApiSlideShowTransition.prototype.SetAdvanceOnTime; ApiSlideShowTransition.prototype["GetAdvanceTime"] = ApiSlideShowTransition.prototype.GetAdvanceTime; ApiSlideShowTransition.prototype["SetAdvanceTime"] = ApiSlideShowTransition.prototype.SetAdvanceTime; - + ApiDrawing.prototype["GetClassType"] = ApiDrawing.prototype.GetClassType; ApiDrawing.prototype["SetSize"] = ApiDrawing.prototype.SetSize; ApiDrawing.prototype["SetPosition"] = ApiDrawing.prototype.SetPosition; @@ -6888,6 +6966,10 @@ ApiShape.prototype["SetVerticalTextAlign"] = ApiShape.prototype.SetVerticalTextAlign; ApiShape.prototype["GetGeometry"] = ApiShape.prototype.GetGeometry; ApiShape.prototype["SetGeometry"] = ApiShape.prototype.SetGeometry; + ApiShape.prototype["SetFill"] = ApiShape.prototype.SetFill; + ApiShape.prototype["GetFill"] = ApiShape.prototype.GetFill; + ApiShape.prototype["SetLine"] = ApiShape.prototype.SetLine; + ApiShape.prototype["GetLine"] = ApiShape.prototype.GetLine; ApiOleObject.prototype["GetClassType"] = ApiOleObject.prototype.GetClassType; ApiOleObject.prototype["SetData"] = ApiOleObject.prototype.SetData; diff --git a/word/apiBuilder.js b/word/apiBuilder.js index e8c323c54c..86e55cfa8b 100644 --- a/word/apiBuilder.js +++ b/word/apiBuilder.js @@ -4147,6 +4147,27 @@ */ /** + * The available fill types. + * @typedef {("solid" | "gradient" | "pattern" | "blip" | "nofill")} FillType + */ + + /** + * The available line dash types. + * "dash" - 0: Dashed line. + * "dashDot" - 1: Alternating dashes and dots. + * "dot" - 2: Dotted line. + * "lgDash" - 3: Long dashes. + * "lgDashDot" - 4: Alternating long dashes and dots. + * "lgDashDotDot" - 5: Alternating long dashes and double dots. + * "solid" - 6: Solid line (no dashes). + * "sysDash" - 7: System dash style. + * "sysDashDot" - 8: System dash-dot style. + * "sysDashDotDot" - 9: System dash-dot-dot style. + * "sysDot" - 10: System dot style. + * @typedef {("dash" | "dashDot" | "dot" | "lgDash" | "lgDashDot" | "lgDashDotDot" | "solid" | "sysDash" | "sysDashDot" | "sysDashDotDot" | "sysDot")} LineDashType + */ + + /** * The available color scheme identifiers. * @typedef {("accent1" | "accent2" | "accent3" | "accent4" | "accent5" | "accent6" | "bg1" | "bg2" | "dk1" | "dk2" * | "lt1" | "lt2" | "tx1" | "tx2")} SchemeColorId @@ -19655,6 +19676,84 @@ return false; }; + /** + * Sets the fill properties to the current shape. + * @memberof ApiShape + * @typeofeditors ["CDE"] + * @param {ApiFill} oFill - The fill type used to fill the shape. + * @returns {boolean} - returns false if param is invalid. + * @see office-js-api/Examples/{Editor}/ApiShape/Methods/SetFill.js + */ + ApiShape.prototype.SetFill = function(oFill) + { + if (!oFill || !oFill.GetClassType || oFill.GetClassType() !== "fill") + return false; + + if (this.Shape && this.Shape.spPr) + { + this.Shape.spPr.setFill(oFill.UniFill); + return true; + } + + return false; + }; + + /** + * Gets the fill properties from the current shape. + * @memberof ApiShape + * @typeofeditors ["CDE"] + * @returns {ApiFill | null} + * @see office-js-api/Examples/{Editor}/ApiShape/Methods/GetFill.js + */ + ApiShape.prototype.GetFill = function() + { + if (this.Shape && this.Shape.spPr && this.Shape.spPr.Fill) + { + return new ApiFill(this.Shape.spPr.Fill); + } + + return null; + }; + + /** + * Sets the outline properties to the current shape. + * @memberof ApiShape + * @typeofeditors ["CDE"] + * @param {ApiStroke} oStroke - The stroke used to create the shape outline. + * @returns {boolean} - returns false if param is invalid. + * @see office-js-api/Examples/{Editor}/ApiShape/Methods/SetLine.js + */ + ApiShape.prototype.SetLine = function(oStroke) + { + if (!oStroke || !oStroke.GetClassType || oStroke.GetClassType() !== "stroke") + return false; + + if (this.Shape && this.Shape.spPr) + { + this.Shape.spPr.setLn(oStroke.Ln); + return true; + } + + return false; + }; + + /** + * Gets the outline properties from the current shape. + * @memberof ApiShape + * @typeofeditors ["CDE"] + * @returns {ApiStroke | null} + * @see office-js-api/Examples/{Editor}/ApiShape/Methods/GetLine.js + */ + ApiShape.prototype.GetLine = function() + { + if (this.Shape && this.Shape.spPr && this.Shape.spPr.ln) + { + return new ApiStroke(this.Shape.spPr.ln); + } + + return null; + }; + //------------------------------------------------------------------------------------------------------------------ // @@ -21387,6 +21486,36 @@ return JSON.stringify(oWriter.SerFill(this.UniFill)); }; + /** + * Gets the fill type. + * @memberof ApiFill + * @typeofeditors ["CDE", "CSE", "CPE"] + * @returns {FillType} - returns "solid", "gradient", "pattern", "blip", "nofill" or null. + * @see office-js-api/Examples/{Editor}/ApiFill/Methods/GetType.js + */ + ApiFill.prototype.GetType = function() + { + if (!this.UniFill || !this.UniFill.fill) + return null; + + var c_oAscFill = window['Asc'].c_oAscFill; + switch(this.UniFill.fill.type) + { + case c_oAscFill.FILL_TYPE_SOLID: + return "solid"; + case c_oAscFill.FILL_TYPE_GRAD: + return "gradient"; + case c_oAscFill.FILL_TYPE_PATT: + return "pattern"; + case c_oAscFill.FILL_TYPE_BLIP: + return "blip"; + case c_oAscFill.FILL_TYPE_NOFILL: + return "nofill"; + default: + return null; + } + }; + //------------------------------------------------------------------------------------------------------------------ // // ApiStroke @@ -21417,6 +21546,56 @@ return JSON.stringify(oWriter.SerLn(this.Ln)); }; + /** + * Gets the width of the stroke in English Metric Units. + * @memberof ApiStroke + * @typeofeditors ["CDE", "CSE", "CPE"] + * @returns {EMU | null} + * @see office-js-api/Examples/{Editor}/ApiStroke/Methods/GetWidth.js + */ + ApiStroke.prototype.GetWidth = function() + { + if (this.Ln && this.Ln.w !== null && this.Ln.w !== undefined) + { + return this.Ln.w; + } + return null; + }; + + /** + * Gets the fill (color) of the stroke. + * @memberof ApiStroke + * @typeofeditors ["CDE", "CSE", "CPE"] + * @returns {ApiFill | null} + * @see office-js-api/Examples/{Editor}/ApiStroke/Methods/GetFill.js + */ + ApiStroke.prototype.GetFill = function() + { + if (this.Ln && this.Ln.Fill) + { + return new ApiFill(this.Ln.Fill); + } + return null; + }; + + /** + * Gets the dash type of the stroke. + * @memberof ApiStroke + * @typeofeditors ["CDE", "CSE", "CPE"] + * @returns {LineDashType | null} - returns dash type ("solid", "dash", etc.) or null. + * @see office-js-api/Examples/{Editor}/ApiStroke/Methods/GetDashType.js + */ + ApiStroke.prototype.GetDashType = function() + { + if (this.Ln && this.Ln.prstDash !== null && this.Ln.prstDash !== undefined) + { + // Convert numeric code to string value using GetDashByCode + var dashString = this.Ln.GetDashByCode ? this.Ln.GetDashByCode(this.Ln.prstDash) : null; + return dashString; + } + return null; + }; + //------------------------------------------------------------------------------------------------------------------ // // ApiGradientStop @@ -29650,6 +29829,10 @@ ApiShape.prototype["GetPrevShape"] = ApiShape.prototype.GetPrevShape; ApiShape.prototype["GetGeometry"] = ApiShape.prototype.GetGeometry; ApiShape.prototype["SetGeometry"] = ApiShape.prototype.SetGeometry; + ApiShape.prototype["SetFill"] = ApiShape.prototype.SetFill; + ApiShape.prototype["GetFill"] = ApiShape.prototype.GetFill; + ApiShape.prototype["SetLine"] = ApiShape.prototype.SetLine; + ApiShape.prototype["GetLine"] = ApiShape.prototype.GetLine; ApiGeometry.prototype["IsCustom"] = ApiGeometry.prototype.IsCustom; ApiGeometry.prototype["GetPreset"] = ApiGeometry.prototype.GetPreset; @@ -29757,9 +29940,13 @@ ApiFill.prototype["GetClassType"] = ApiFill.prototype.GetClassType; ApiFill.prototype["ToJSON"] = ApiFill.prototype.ToJSON; + ApiFill.prototype["GetType"] = ApiFill.prototype.GetType; ApiStroke.prototype["GetClassType"] = ApiStroke.prototype.GetClassType; ApiStroke.prototype["ToJSON"] = ApiStroke.prototype.ToJSON; + ApiStroke.prototype["GetWidth"] = ApiStroke.prototype.GetWidth; + ApiStroke.prototype["GetFill"] = ApiStroke.prototype.GetFill; + ApiStroke.prototype["GetDashType"] = ApiStroke.prototype.GetDashType; ApiGradientStop.prototype["GetClassType"] = ApiGradientStop.prototype.GetClassType; ApiGradientStop.prototype["ToJSON"] = ApiGradientStop.prototype.ToJSON; @@ -30200,6 +30387,8 @@ window['AscBuilder'].ApiCustomProperties = ApiCustomProperties; window['AscBuilder'].ApiCustomXmlParts = ApiCustomXmlParts; window['AscBuilder'].ApiColor = ApiColor; + window['AscBuilder'].ApiFill = ApiFill; + window['AscBuilder'].ApiStroke = ApiStroke; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Area for internal usage ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////