PowerPoint.SlideBackgroundFill class
Representa el formato de relleno de un objeto de fondo de diapositiva.
- Extends
Comentarios
Conjunto de API: PowerPointApi 1.10
Usada por
- PowerPoint.SlideBackground: rellenar
- PowerPoint.SlideLayoutBackground: rellenar
- PowerPoint.SlideMasterBackground: rellenar
Ejemplos
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/get-set-background-fill.yaml
// Gets the background fill type of the first selected slide.
await PowerPoint.run(async (context) => {
const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0);
const fill: PowerPoint.SlideBackgroundFill = slide.background.fill;
fill.load("type");
await context.sync();
const fillType = fill.type as PowerPoint.SlideBackgroundFillType;
console.log(`Background fill type: ${fillType}`);
});
Propiedades
| context | El contexto de solicitud asociado al objeto. De esta forma, se conecta el proceso del complemento con el proceso de la aplicación host de Office. |
| type | Devuelve el tipo de relleno del fondo de la diapositiva. Vea PowerPoint.SlideBackgroundFillType para obtener más información. |
Métodos
| get |
Obtiene las propiedades de relleno degradado. Si el tipo de relleno no |
| get |
Obtiene las propiedades de relleno de trama. Si el tipo de relleno no |
| get |
Obtiene las propiedades de relleno de imagen o textura. Si el tipo de relleno no |
| get |
Obtiene las propiedades de relleno sólido. Si el tipo de relleno no |
| load(options) | Pone en cola un comando para cargar las propiedades especificadas del objeto. Debe llamar a |
| load(property |
Pone en cola un comando para cargar las propiedades especificadas del objeto. Debe llamar a |
| load(property |
Pone en cola un comando para cargar las propiedades especificadas del objeto. Debe llamar a |
| set |
Establece el formato de relleno del fondo de la diapositiva en un relleno degradado. Esto cambia el tipo de relleno a |
| set |
Establece el formato de relleno del fondo de la diapositiva en un relleno de trama. Esto cambia el tipo de relleno a |
| set |
Establece el formato de relleno del fondo de la diapositiva en un relleno de imagen o textura. Esto cambia el tipo de relleno a |
| set |
Establece el formato de relleno del fondo de la diapositiva en un relleno sólido. Esto cambia el tipo de relleno a |
| toJSON() | Reemplaza el método JavaScript |
Detalles de las propiedades
context
El contexto de solicitud asociado al objeto. De esta forma, se conecta el proceso del complemento con el proceso de la aplicación host de Office.
context: RequestContext;
Valor de propiedad
type
Devuelve el tipo de relleno del fondo de la diapositiva. Vea PowerPoint.SlideBackgroundFillType para obtener más información.
readonly type: PowerPoint.SlideBackgroundFillType | "Unsupported" | "Solid" | "Gradient" | "PictureOrTexture" | "Pattern";
Valor de propiedad
PowerPoint.SlideBackgroundFillType | "Unsupported" | "Solid" | "Gradient" | "PictureOrTexture" | "Pattern"
Comentarios
Detalles del método
getGradientFillOrNullObject()
Obtiene las propiedades de relleno degradado. Si el tipo de relleno no gradientes , se devuelve un objeto con una isNullObject propiedad establecida en true . Para obtener más información, vea los métodos y propiedades *OrNullObject.
getGradientFillOrNullObject(): PowerPoint.SlideBackgroundGradientFill;
Devoluciones
Comentarios
Conjunto de API: PowerPointApi 1.10
Ejemplos
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/get-set-background-fill.yaml
// Gets the gradient fill properties of the first selected slide's background.
await PowerPoint.run(async (context) => {
const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0);
const fill: PowerPoint.SlideBackgroundFill = slide.background.fill;
fill.load("type");
await context.sync();
if (fill.type !== PowerPoint.SlideBackgroundFillType.gradient) {
console.warn("The slide background isn't a gradient fill.");
return;
}
const gradientFill: PowerPoint.SlideBackgroundGradientFill = slide.background.fill.getGradientFillOrNullObject();
gradientFill.load("type");
await context.sync();
if (gradientFill.isNullObject) {
console.warn("The slide background isn't a gradient fill.");
} else {
console.log("Gradient fill:", `- type: ${gradientFill.type}`);
}
});
getPatternFillOrNullObject()
Obtiene las propiedades de relleno de trama. Si el tipo de relleno no patternes , se devuelve un objeto con una isNullObject propiedad establecida en true . Para obtener más información, vea los métodos y propiedades *OrNullObject.
getPatternFillOrNullObject(): PowerPoint.SlideBackgroundPatternFill;
Devoluciones
Comentarios
Conjunto de API: PowerPointApi 1.10
Ejemplos
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/get-set-background-fill.yaml
// Gets the pattern fill properties of the first selected slide's background.
await PowerPoint.run(async (context) => {
const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0);
const fill: PowerPoint.SlideBackgroundFill = slide.background.fill;
fill.load("type");
await context.sync();
if (fill.type !== PowerPoint.SlideBackgroundFillType.pattern) {
console.warn("The slide background isn't a pattern fill.");
return;
}
const patternFill: PowerPoint.SlideBackgroundPatternFill = slide.background.fill.getPatternFillOrNullObject();
patternFill.load(["foregroundColor", "backgroundColor", "pattern"]);
await context.sync();
if (patternFill.isNullObject) {
console.warn("The slide background isn't a pattern fill.");
} else {
console.log(
"Pattern fill:",
`- foregroundColor: ${patternFill.foregroundColor}`,
`- backgroundColor: ${patternFill.backgroundColor}`,
`- pattern: ${patternFill.pattern}`,
);
}
});
getPictureOrTextureFillOrNullObject()
Obtiene las propiedades de relleno de imagen o textura. Si el tipo de relleno no pictureOrTexturees , se devuelve un objeto con una isNullObject propiedad establecida en true . Para obtener más información, vea los métodos y propiedades *OrNullObject.
getPictureOrTextureFillOrNullObject(): PowerPoint.SlideBackgroundPictureOrTextureFill;
Devoluciones
Comentarios
Conjunto de API: PowerPointApi 1.10
Ejemplos
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/get-set-background-fill.yaml
// Gets the picture or texture fill properties of the first selected slide's background.
await PowerPoint.run(async (context) => {
const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0);
const fill: PowerPoint.SlideBackgroundFill = slide.background.fill;
fill.load("type");
await context.sync();
if (fill.type !== PowerPoint.SlideBackgroundFillType.pictureOrTexture) {
console.warn("The slide background isn't a picture or texture fill.");
return;
}
const pictureFill: PowerPoint.SlideBackgroundPictureOrTextureFill =
slide.background.fill.getPictureOrTextureFillOrNullObject();
pictureFill.load("transparency");
await context.sync();
if (pictureFill.isNullObject) {
console.warn("The slide background isn't a picture or texture fill.");
} else {
console.log("Picture or texture fill:", `- transparency: ${pictureFill.transparency}`);
}
});
getSolidFillOrNullObject()
Obtiene las propiedades de relleno sólido. Si el tipo de relleno no solides , se devuelve un objeto con una isNullObject propiedad establecida en true . Para obtener más información, vea los métodos y propiedades *OrNullObject.
getSolidFillOrNullObject(): PowerPoint.SlideBackgroundSolidFill;
Devoluciones
Comentarios
Conjunto de API: PowerPointApi 1.10
Ejemplos
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/get-set-background-fill.yaml
// Gets the solid fill properties of the first selected slide's background.
await PowerPoint.run(async (context) => {
const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0);
const fill: PowerPoint.SlideBackgroundFill = slide.background.fill;
fill.load("type");
await context.sync();
if (fill.type !== PowerPoint.SlideBackgroundFillType.solid) {
console.warn("The slide background isn't a solid fill.");
return;
}
const solidFill: PowerPoint.SlideBackgroundSolidFill = slide.background.fill.getSolidFillOrNullObject();
solidFill.load(["color", "transparency"]);
await context.sync();
if (solidFill.isNullObject) {
console.warn("The slide background isn't a solid fill.");
} else {
console.log("Solid fill:", `- color: ${solidFill.color}`, `- transparency: ${solidFill.transparency}`);
}
});
load(options)
Pone en cola un comando para cargar las propiedades especificadas del objeto. Debe llamar a context.sync() antes de leer las propiedades.
load(options?: PowerPoint.Interfaces.SlideBackgroundFillLoadOptions): PowerPoint.SlideBackgroundFill;
Parámetros
Proporciona opciones para las propiedades del objeto que se van a cargar.
Devoluciones
load(propertyNames)
Pone en cola un comando para cargar las propiedades especificadas del objeto. Debe llamar a context.sync() antes de leer las propiedades.
load(propertyNames?: string | string[]): PowerPoint.SlideBackgroundFill;
Parámetros
- propertyNames
-
string | string[]
Una cadena delimitada por comas o una matriz de cadenas que especifican las propiedades que se van a cargar.
Devoluciones
load(propertyNamesAndPaths)
Pone en cola un comando para cargar las propiedades especificadas del objeto. Debe llamar a context.sync() antes de leer las propiedades.
load(propertyNamesAndPaths?: {
select?: string;
expand?: string;
}): PowerPoint.SlideBackgroundFill;
Parámetros
- propertyNamesAndPaths
-
{ select?: string; expand?: string; }
propertyNamesAndPaths.select es una cadena delimitada por comas que especifica las propiedades que se van a cargar y propertyNamesAndPaths.expand es una cadena delimitada por comas que especifica las propiedades de navegación que se van a cargar.
Devoluciones
setGradientFill(options)
Establece el formato de relleno del fondo de la diapositiva en un relleno degradado. Esto cambia el tipo de relleno a gradient.
setGradientFill(options?: PowerPoint.SlideBackgroundGradientFillOptions): void;
Parámetros
Opciones para el relleno degradado.
Devoluciones
void
Comentarios
Conjunto de API: PowerPointApi 1.10
Ejemplos
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/get-set-background-fill.yaml
// Sets the background of the first selected slide to a linear gradient fill.
await PowerPoint.run(async (context) => {
const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0);
slide.background.fill.setGradientFill({
type: PowerPoint.SlideBackgroundGradientFillType.linear,
} as PowerPoint.SlideBackgroundGradientFillOptions);
await context.sync();
console.log("Background set to linear gradient fill.");
});
setPatternFill(options)
Establece el formato de relleno del fondo de la diapositiva en un relleno de trama. Esto cambia el tipo de relleno a pattern.
setPatternFill(options?: PowerPoint.SlideBackgroundPatternFillOptions): void;
Parámetros
Opciones para el relleno de trama.
Devoluciones
void
Comentarios
Conjunto de API: PowerPointApi 1.10
Ejemplos
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/get-set-background-fill.yaml
// Sets the background of the first selected slide to a diagonal cross pattern fill.
await PowerPoint.run(async (context) => {
const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0);
slide.background.fill.setPatternFill({
foregroundColor: "#1F3864",
backgroundColor: "#D6E4F7",
pattern: PowerPoint.SlideBackgroundPatternFillType.diagonalCross,
} as PowerPoint.SlideBackgroundPatternFillOptions);
await context.sync();
console.log("Background set to diagonal cross pattern fill.");
});
setPictureOrTextureFill(options)
Establece el formato de relleno del fondo de la diapositiva en un relleno de imagen o textura. Esto cambia el tipo de relleno a pictureOrTexture.
setPictureOrTextureFill(options?: PowerPoint.SlideBackgroundPictureOrTextureFillOptions): void;
Parámetros
Opciones para el relleno de imagen o textura.
Devoluciones
void
Comentarios
Conjunto de API: PowerPointApi 1.10
Ejemplos
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/get-set-background-fill.yaml
// Sets the background of the first selected slide to a picture fill at 60% transparency.
// Uses a sample image from a Base64-encoded string.
await PowerPoint.run(async (context) => {
const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0);
slide.background.fill.setPictureOrTextureFill({
imageBase64: getSampleImageAsBase64String(),
transparency: 0.6,
} as PowerPoint.SlideBackgroundPictureOrTextureFillOptions);
await context.sync();
console.log("Background set to picture fill (60% transparent).");
});
setSolidFill(options)
Establece el formato de relleno del fondo de la diapositiva en un relleno sólido. Esto cambia el tipo de relleno a solid.
setSolidFill(options?: PowerPoint.SlideBackgroundSolidFillOptions): void;
Parámetros
Opciones para el relleno sólido.
Devoluciones
void
Comentarios
Conjunto de API: PowerPointApi 1.10
Ejemplos
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/get-set-background-fill.yaml
// Sets the background of the first selected slide to a solid orange fill at 20% transparency.
await PowerPoint.run(async (context) => {
const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0);
slide.background.fill.setSolidFill({
color: "#FF8C00",
transparency: 0.2,
} as PowerPoint.SlideBackgroundSolidFillOptions);
await context.sync();
console.log("Background set to solid orange fill (20% transparent).");
});
toJSON()
Reemplaza el método JavaScript toJSON() para proporcionar una salida más útil cuando se pasa un objeto API a JSON.stringify(). (JSON.stringify, a su vez, llama al toJSON método del objeto que se le pasa). Mientras que el objeto original PowerPoint.SlideBackgroundFill es un objeto API, el toJSON método devuelve un objeto JavaScript simple (escrito como PowerPoint.Interfaces.SlideBackgroundFillData) que contiene copias superficiales de cualquier propiedad secundaria cargada del objeto original.
toJSON(): PowerPoint.Interfaces.SlideBackgroundFillData;