PowerPoint.SlideBackgroundFill class
Представляет форматирование заливки объекта фона слайда.
- Extends
Комментарии
Используется
- PowerPoint.SlideBackground: заливка
- PowerPoint.SlideLayoutBackground: fill
- PowerPoint.SlideMasterBackground: fill
Примеры
// 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}`);
});
Свойства
| context | Контекст запроса, связанный с объектом . Это соединяет процесс надстройки с процессом ведущего приложения Office. |
| type | Возвращает тип заливки фона слайда. Дополнительные сведения см. в разделе PowerPoint.SlideBackgroundFillType . |
Методы
| get |
Возвращает свойства градиентной заливки. Если тип заполнения не |
| get |
Возвращает свойства заливки шаблона. Если тип заполнения не |
| get |
Возвращает свойства заливки рисунка или текстуры. Если тип заполнения не |
| get |
Возвращает свойства сплошной заливки. Если тип заполнения не |
| load(options) | Добавляет в очередь команду для загрузки указанных свойств объекта. Перед чтением свойств требуется вызвать метод |
| load(property |
Добавляет в очередь команду для загрузки указанных свойств объекта. Перед чтением свойств требуется вызвать метод |
| load(property |
Добавляет в очередь команду для загрузки указанных свойств объекта. Перед чтением свойств требуется вызвать метод |
| set |
Задает для форматирования фона слайда градиентную заливку. При этом тип заполнения изменится на |
| set |
Задает для форматирования фона слайда узорную заливку. При этом тип заполнения изменится на |
| set |
Задает форматирование фона слайда для заливки рисунка или текстуры. При этом тип заполнения изменится на |
| set |
Задает для форматирования фона слайда сплошную заливку. При этом тип заполнения изменится на |
| toJSON() | Переопределяет метод JavaScript |
Сведения о свойстве
context
Контекст запроса, связанный с объектом . Это соединяет процесс надстройки с процессом ведущего приложения Office.
context: RequestContext;
Значение свойства
type
Возвращает тип заливки фона слайда. Дополнительные сведения см. в разделе PowerPoint.SlideBackgroundFillType .
readonly type: PowerPoint.SlideBackgroundFillType | "Unsupported" | "Solid" | "Gradient" | "PictureOrTexture" | "Pattern";
Значение свойства
PowerPoint.SlideBackgroundFillType | "Unsupported" | "Solid" | "Gradient" | "PictureOrTexture" | "Pattern"
Комментарии
Сведения о методе
getGradientFillOrNullObject()
Возвращает свойства градиентной заливки. Если тип заполнения не gradientявляется , возвращается объект со свойством isNullObject , для свойства имеет значение true . Дополнительные сведения см. в разделе Методы и свойства *OrNullObject.
getGradientFillOrNullObject(): PowerPoint.SlideBackgroundGradientFill;
Возвращаемое значение
Комментарии
Примеры
// 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()
Возвращает свойства заливки шаблона. Если тип заполнения не patternявляется , возвращается объект со свойством isNullObject , для свойства имеет значение true . Дополнительные сведения см. в разделе Методы и свойства *OrNullObject.
getPatternFillOrNullObject(): PowerPoint.SlideBackgroundPatternFill;
Возвращаемое значение
Комментарии
Примеры
// 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()
Возвращает свойства заливки рисунка или текстуры. Если тип заполнения не pictureOrTextureявляется , возвращается объект со свойством isNullObject , для свойства имеет значение true . Дополнительные сведения см. в разделе Методы и свойства *OrNullObject.
getPictureOrTextureFillOrNullObject(): PowerPoint.SlideBackgroundPictureOrTextureFill;
Возвращаемое значение
Комментарии
Примеры
// 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()
Возвращает свойства сплошной заливки. Если тип заполнения не solidявляется , возвращается объект со свойством isNullObject , для свойства имеет значение true . Дополнительные сведения см. в разделе Методы и свойства *OrNullObject.
getSolidFillOrNullObject(): PowerPoint.SlideBackgroundSolidFill;
Возвращаемое значение
Комментарии
Примеры
// 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)
Добавляет в очередь команду для загрузки указанных свойств объекта. Перед чтением свойств требуется вызвать метод context.sync().
load(options?: PowerPoint.Interfaces.SlideBackgroundFillLoadOptions): PowerPoint.SlideBackgroundFill;
Параметры
Предоставляет параметры свойств объекта для загрузки.
Возвращаемое значение
load(propertyNames)
Добавляет в очередь команду для загрузки указанных свойств объекта. Перед чтением свойств требуется вызвать метод context.sync().
load(propertyNames?: string | string[]): PowerPoint.SlideBackgroundFill;
Параметры
- propertyNames
-
string | string[]
Строка с разделителями-запятыми или массив строк, указывающих свойства для загрузки.
Возвращаемое значение
load(propertyNamesAndPaths)
Добавляет в очередь команду для загрузки указанных свойств объекта. Перед чтением свойств требуется вызвать метод context.sync().
load(propertyNamesAndPaths?: {
select?: string;
expand?: string;
}): PowerPoint.SlideBackgroundFill;
Параметры
- propertyNamesAndPaths
-
{ select?: string; expand?: string; }
propertyNamesAndPaths.select — это строка с разделителями-запятыми, указывающая загружаемые свойства, и propertyNamesAndPaths.expand строка с разделителями-запятыми, указывающая загружаемые свойства навигации.
Возвращаемое значение
setGradientFill(options)
Задает для форматирования фона слайда градиентную заливку. При этом тип заполнения изменится на gradient.
setGradientFill(options?: PowerPoint.SlideBackgroundGradientFillOptions): void;
Параметры
Параметры градиентной заливки.
Возвращаемое значение
void
Комментарии
Примеры
// 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)
Задает для форматирования фона слайда узорную заливку. При этом тип заполнения изменится на pattern.
setPatternFill(options?: PowerPoint.SlideBackgroundPatternFillOptions): void;
Параметры
Параметры заливки шаблона.
Возвращаемое значение
void
Комментарии
Примеры
// 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)
Задает форматирование фона слайда для заливки рисунка или текстуры. При этом тип заполнения изменится на pictureOrTexture.
setPictureOrTextureFill(options?: PowerPoint.SlideBackgroundPictureOrTextureFillOptions): void;
Параметры
Параметры для заливки рисунка или текстуры.
Возвращаемое значение
void
Комментарии
Примеры
// 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)
Задает для форматирования фона слайда сплошную заливку. При этом тип заполнения изменится на solid.
setSolidFill(options?: PowerPoint.SlideBackgroundSolidFillOptions): void;
Параметры
Параметры сплошной заливки.
Возвращаемое значение
void
Комментарии
Примеры
// 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()
Переопределяет метод JavaScript toJSON() , чтобы обеспечить более полезные выходные данные при передаче объекта API в JSON.stringify(). (JSON.stringifyв свою очередь вызывает toJSON метод переданного ему объекта.) В то время как исходный PowerPoint.SlideBackgroundFill объект является объектом API, toJSON метод возвращает обычный объект JavaScript (типизированный как PowerPoint.Interfaces.SlideBackgroundFillData), который содержит неглубокие копии всех загруженных дочерних свойств из исходного объекта.
toJSON(): PowerPoint.Interfaces.SlideBackgroundFillData;