Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion samples/word/45-shapes/manage-geometric-shapes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -41,7 +42,7 @@ script:
selection.insertGeometricShape(Word.GeometricShapeType.moon, shapeOptions);
await context.sync();

console.log("Inserted a heptagon.");
console.log("Inserted a moon.");
});
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -145,6 +171,9 @@ template:
<button id="get-first-heptagon" class="ms-Button">
<span class="ms-Button-label">Get first heptagon</span>
</button>
<button id="get-first-moon-fill" class="ms-Button">
<span class="ms-Button-label">Get color fill of first moon</span>
</button>
</section>
language: html
style:
Expand Down
Binary file modified snippet-extractor-metadata/word.xlsx
Binary file not shown.
86 changes: 85 additions & 1 deletion snippet-extractor-output/snippets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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):
- >-
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down