diff --git a/samples/word/45-shapes/manage-geometric-shapes.yaml b/samples/word/45-shapes/manage-geometric-shapes.yaml index 10849e12..d9410266 100644 --- a/samples/word/45-shapes/manage-geometric-shapes.yaml +++ b/samples/word/45-shapes/manage-geometric-shapes.yaml @@ -13,6 +13,7 @@ script: document.getElementById("get-moons").addEventListener("click", () => tryCatch(getMoonGeometricShapes)); document.getElementById("get-first-geometric-shape").addEventListener("click", () => tryCatch(getFirstGeometricShape)); document.getElementById("get-first-heptagon").addEventListener("click", () => tryCatch(getFirstHeptagon)); + document.getElementById("get-first-moon-fill").addEventListener("click", () => tryCatch(getFirstMoonColorFill)); async function insertGeometricShape_Heptagon() { await Word.run(async (context) => { @@ -41,7 +42,7 @@ script: selection.insertGeometricShape(Word.GeometricShapeType.moon, shapeOptions); await context.sync(); - console.log("Inserted a heptagon."); + console.log("Inserted a moon."); }); } @@ -110,6 +111,31 @@ script: }); } + async function getFirstMoonColorFill() { + await Word.run(async (context) => { + // Gets the color fill properties of the first moon found in the document body. + const moon: Word.Shape = context.document.body.shapes + .getByGeometricTypes([Word.GeometricShapeType.moon]) + .getFirstOrNullObject(); + moon.load("fill"); + await context.sync(); + + if (moon.isNullObject) { + console.log("No moons found in the document body."); + return; + } + + const moonFill: Word.ShapeFill = moon.fill; + const moonFillType = moonFill.type as Word.ShapeFillType; + + console.log("Color fill properties of the first moon found in the document body:"); + console.log(`\tForeground color: ${moonFill.foregroundColor}`); + console.log(`\tBackground color: ${moonFill.backgroundColor}`); + console.log(`\tTransparency: ${moonFill.transparency}`); + console.log(`\tFill type: ${moonFillType}`); + }); + } + // Default helper for invoking an action and handling errors. async function tryCatch(callback) { try { @@ -145,6 +171,9 @@ template: + language: html style: diff --git a/snippet-extractor-metadata/word.xlsx b/snippet-extractor-metadata/word.xlsx index a957c35e..549f9dd0 100644 Binary files a/snippet-extractor-metadata/word.xlsx and b/snippet-extractor-metadata/word.xlsx differ diff --git a/snippet-extractor-output/snippets.yaml b/snippet-extractor-output/snippets.yaml index 605c240b..a2f49f4a 100644 --- a/snippet-extractor-output/snippets.yaml +++ b/snippet-extractor-output/snippets.yaml @@ -27483,7 +27483,7 @@ Word.Range#insertGeometricShape:member(1): selection.insertGeometricShape(Word.GeometricShapeType.moon, shapeOptions); await context.sync(); - console.log("Inserted a heptagon."); + console.log("Inserted a moon."); }); Word.Range#insertTextBox:member(1): - >- @@ -27986,6 +27986,34 @@ Word.Shape#body:member: console.log("New content control properties:", newControl); }); +Word.Shape#fill:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-geometric-shapes.yaml + + + await Word.run(async (context) => { + // Gets the color fill properties of the first moon found in the document body. + const moon: Word.Shape = context.document.body.shapes + .getByGeometricTypes([Word.GeometricShapeType.moon]) + .getFirstOrNullObject(); + moon.load("fill"); + await context.sync(); + + if (moon.isNullObject) { + console.log("No moons found in the document body."); + return; + } + + const moonFill: Word.ShapeFill = moon.fill; + const moonFillType = moonFill.type as Word.ShapeFillType; + + console.log("Color fill properties of the first moon found in the document body:"); + console.log(`\tForeground color: ${moonFill.foregroundColor}`); + console.log(`\tBackground color: ${moonFill.backgroundColor}`); + console.log(`\tTransparency: ${moonFill.transparency}`); + console.log(`\tFill type: ${moonFillType}`); + }); Word.Shape#geometricShapeType:member: - >- // Link to full sample: @@ -28196,6 +28224,62 @@ Word.ShapeCollection#getFirstOrNullObject:member(1): : `Text in first text box: ${shape.body.text}` ); }); +Word.ShapeFill:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-geometric-shapes.yaml + + + await Word.run(async (context) => { + // Gets the color fill properties of the first moon found in the document body. + const moon: Word.Shape = context.document.body.shapes + .getByGeometricTypes([Word.GeometricShapeType.moon]) + .getFirstOrNullObject(); + moon.load("fill"); + await context.sync(); + + if (moon.isNullObject) { + console.log("No moons found in the document body."); + return; + } + + const moonFill: Word.ShapeFill = moon.fill; + const moonFillType = moonFill.type as Word.ShapeFillType; + + console.log("Color fill properties of the first moon found in the document body:"); + console.log(`\tForeground color: ${moonFill.foregroundColor}`); + console.log(`\tBackground color: ${moonFill.backgroundColor}`); + console.log(`\tTransparency: ${moonFill.transparency}`); + console.log(`\tFill type: ${moonFillType}`); + }); +Word.ShapeFillType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-geometric-shapes.yaml + + + await Word.run(async (context) => { + // Gets the color fill properties of the first moon found in the document body. + const moon: Word.Shape = context.document.body.shapes + .getByGeometricTypes([Word.GeometricShapeType.moon]) + .getFirstOrNullObject(); + moon.load("fill"); + await context.sync(); + + if (moon.isNullObject) { + console.log("No moons found in the document body."); + return; + } + + const moonFill: Word.ShapeFill = moon.fill; + const moonFillType = moonFill.type as Word.ShapeFillType; + + console.log("Color fill properties of the first moon found in the document body:"); + console.log(`\tForeground color: ${moonFill.foregroundColor}`); + console.log(`\tBackground color: ${moonFill.backgroundColor}`); + console.log(`\tTransparency: ${moonFill.transparency}`); + console.log(`\tFill type: ${moonFillType}`); + }); Word.ShapeTextOrientation:enum: - >- // Link to full sample: