Added implementations for alignment buttoms.

This commit is contained in:
2025-03-09 15:59:31 +01:00
parent 10d3d8c453
commit b185e071ef
+102 -6
View File
@@ -44,8 +44,24 @@ export const AlignmentButtons: React.FC = () => {
setIsProcessing(true); setIsProcessing(true);
try { try {
await PowerPoint.run(async (context) => { await PowerPoint.run(async (context) => {
// Get the selected shapes
const shapes = context.presentation.getSelectedShapes(); const shapes = context.presentation.getSelectedShapes();
// Implementation will go here shapes.load("items");
await context.sync();
// Check if shapes are selected
if (shapes.items.length === 0) {
setStatusMessage("No shapes are selected. Please select shapes first.");
setStatusType("warning");
return;
}
// Loop through all select shapes and align them
for (let i = 0; i < shapes.items.length; i++) {
shapes.items[i].left = 81.1;
}
await context.sync();
setStatusMessage("Objects aligned to left."); setStatusMessage("Objects aligned to left.");
setStatusType("success"); setStatusType("success");
}); });
@@ -62,8 +78,24 @@ export const AlignmentButtons: React.FC = () => {
setIsProcessing(true); setIsProcessing(true);
try { try {
await PowerPoint.run(async (context) => { await PowerPoint.run(async (context) => {
// Get the selected shapes
const shapes = context.presentation.getSelectedShapes(); const shapes = context.presentation.getSelectedShapes();
// Implementation will go here shapes.load("items");
await context.sync();
// Check if shapes are selected
if (shapes.items.length === 0) {
setStatusMessage("No shapes are selected. Please select shapes first.");
setStatusType("warning");
return;
}
// Loop through all select shapes and align them
for (let i = 0; i < shapes.items.length; i++) {
shapes.items[i].left = 480 - (shapes.items[i].width / 2);
}
await context.sync();
setStatusMessage("Objects aligned to center."); setStatusMessage("Objects aligned to center.");
setStatusType("success"); setStatusType("success");
}); });
@@ -80,8 +112,24 @@ export const AlignmentButtons: React.FC = () => {
setIsProcessing(true); setIsProcessing(true);
try { try {
await PowerPoint.run(async (context) => { await PowerPoint.run(async (context) => {
// Get the selected shapes
const shapes = context.presentation.getSelectedShapes(); const shapes = context.presentation.getSelectedShapes();
// Implementation will go here shapes.load("items");
await context.sync();
// Check if shapes are selected
if (shapes.items.length === 0) {
setStatusMessage("No shapes are selected. Please select shapes first.");
setStatusType("warning");
return;
}
// Loop through all select shapes and align them
for (let i = 0; i < shapes.items.length; i++) {
shapes.items[i].left = 879.75 - shapes.items[i].width;
}
await context.sync();
setStatusMessage("Objects aligned to right."); setStatusMessage("Objects aligned to right.");
setStatusType("success"); setStatusType("success");
}); });
@@ -98,8 +146,24 @@ export const AlignmentButtons: React.FC = () => {
setIsProcessing(true); setIsProcessing(true);
try { try {
await PowerPoint.run(async (context) => { await PowerPoint.run(async (context) => {
// Get the selected shapes
const shapes = context.presentation.getSelectedShapes(); const shapes = context.presentation.getSelectedShapes();
// Implementation will go here shapes.load("items");
await context.sync();
// Check if shapes are selected
if (shapes.items.length === 0) {
setStatusMessage("No shapes are selected. Please select shapes first.");
setStatusType("warning");
return;
}
// Loop through all select shapes and align them
for (let i = 0; i < shapes.items.length; i++) {
shapes.items[i].top = 136.75;
}
await context.sync();
setStatusMessage("Objects aligned to top."); setStatusMessage("Objects aligned to top.");
setStatusType("success"); setStatusType("success");
}); });
@@ -116,8 +180,24 @@ export const AlignmentButtons: React.FC = () => {
setIsProcessing(true); setIsProcessing(true);
try { try {
await PowerPoint.run(async (context) => { await PowerPoint.run(async (context) => {
// Get the selected shapes
const shapes = context.presentation.getSelectedShapes(); const shapes = context.presentation.getSelectedShapes();
// Implementation will go here shapes.load("items");
await context.sync();
// Check if shapes are selected
if (shapes.items.length === 0) {
setStatusMessage("No shapes are selected. Please select shapes first.");
setStatusType("warning");
return;
}
// Loop through all select shapes and align them
for (let i = 0; i < shapes.items.length; i++) {
shapes.items[i].top = 321 - (shapes.items[i].height / 2);
}
await context.sync();
setStatusMessage("Objects aligned to middle."); setStatusMessage("Objects aligned to middle.");
setStatusType("success"); setStatusType("success");
}); });
@@ -134,8 +214,24 @@ export const AlignmentButtons: React.FC = () => {
setIsProcessing(true); setIsProcessing(true);
try { try {
await PowerPoint.run(async (context) => { await PowerPoint.run(async (context) => {
// Get the selected shapes
const shapes = context.presentation.getSelectedShapes(); const shapes = context.presentation.getSelectedShapes();
// Implementation will go here shapes.load("items");
await context.sync();
// Check if shapes are selected
if (shapes.items.length === 0) {
setStatusMessage("No shapes are selected. Please select shapes first.");
setStatusType("warning");
return;
}
// Loop through all select shapes and align them
for (let i = 0; i < shapes.items.length; i++) {
shapes.items[i].top = 505.25 - shapes.items[i].height;
}
await context.sync();
setStatusMessage("Objects aligned to bottom."); setStatusMessage("Objects aligned to bottom.");
setStatusType("success"); setStatusType("success");
}); });