PowerPoint.ThemeColorScheme class

表示主题配色方案。

扩展

注解

API 集:PowerPointApi 1.10

使用方

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/get-set-theme-color-scheme.yaml

// Resets accent colors on the first slide to default Office theme values and updates swatches if present.
await PowerPoint.run(async (context) => {
  const slide = context.presentation.slides.getItemAt(0);
  const colorScheme: PowerPoint.ThemeColorScheme = slide.themeColorScheme;

  colorScheme.setThemeColor(PowerPoint.ThemeColor.accent1, "#4472C4");
  colorScheme.setThemeColor(PowerPoint.ThemeColor.accent2, "#ED7D31");
  colorScheme.setThemeColor(PowerPoint.ThemeColor.accent3, "#A9D18E");
  colorScheme.setThemeColor(PowerPoint.ThemeColor.accent4, "#FFC000");
  colorScheme.setThemeColor(PowerPoint.ThemeColor.accent5, "#5B9BD5");
  colorScheme.setThemeColor(PowerPoint.ThemeColor.accent6, "#70AD47");
  await context.sync();

  await updateSwatches(context, slide);
  console.log("Accent colors reset to default Office theme values on slide 1.");
});

属性

context

与对象关联的请求上下文。 这将加载项的进程连接到 Office 主机应用程序的进程。

方法

getThemeColor(color)

获取指定的 ThemeColor颜色值。

getThemeColor(color)

获取指定的 ThemeColor颜色值。

setThemeColor(color, rgbColor)

设置指定的 ThemeColor颜色值。

setThemeColor(color, rgbColor)

设置指定的 ThemeColor颜色值。

toJSON()

覆盖 JavaScript toJSON() 方法,以便在将 API 对象传递给 JSON.stringify()时提供更有用的输出。 (JSON.stringify反过来调用 toJSON 传递给它的对象的方法。) 虽然原始 PowerPoint.ThemeColorScheme 对象是 API 对象, toJSON 但该方法返回一个纯 JavaScript 对象, (类型化为 PowerPoint.Interfaces.ThemeColorSchemeData) ,其中包含从原始对象加载的任何子属性的浅层副本。

属性详细信息

context

与对象关联的请求上下文。 这将加载项的进程连接到 Office 主机应用程序的进程。

context: RequestContext;

属性值

方法详细信息

getThemeColor(color)

获取指定的 ThemeColor颜色值。

getThemeColor(color: PowerPoint.ThemeColor): OfficeExtension.ClientResult<string>;

参数

color
PowerPoint.ThemeColor

主题颜色。 值 none 对于 mixed 此 API 无效。

返回

#RRGGBB 格式的颜色值 (例如“FFA500”) 。

注解

API 集:PowerPointApi 1.10

getThemeColor(color)

获取指定的 ThemeColor颜色值。

getThemeColor(color: "Mixed" | "None" | "Accent1" | "Accent2" | "Accent3" | "Accent4" | "Accent5" | "Accent6" | "Dark1" | "Dark2" | "FollowedHyperlink" | "Hyperlink" | "Light1" | "Light2"): OfficeExtension.ClientResult<string>;

参数

color

"Mixed" | "None" | "Accent1" | "Accent2" | "Accent3" | "Accent4" | "Accent5" | "Accent6" | "Dark1" | "Dark2" | "FollowedHyperlink" | "Hyperlink" | "Light1" | "Light2"

主题颜色。 值 none 对于 mixed 此 API 无效。

返回

#RRGGBB 格式的颜色值 (例如“FFA500”) 。

注解

API 集:PowerPointApi 1.10

setThemeColor(color, rgbColor)

设置指定的 ThemeColor颜色值。

setThemeColor(color: PowerPoint.ThemeColor, rgbColor: string): void;

参数

color
PowerPoint.ThemeColor

主题颜色。 值 none 对于 mixed 此 API 无效。

rgbColor

string

#RRGGBB 格式的颜色值 (例如“FFA500”) 或命名 HTML 颜色 (例如“orange”) 。

返回

void

注解

API 集:PowerPointApi 1.10

setThemeColor(color, rgbColor)

设置指定的 ThemeColor颜色值。

setThemeColor(color: "Mixed" | "None" | "Accent1" | "Accent2" | "Accent3" | "Accent4" | "Accent5" | "Accent6" | "Dark1" | "Dark2" | "FollowedHyperlink" | "Hyperlink" | "Light1" | "Light2", rgbColor: string): void;

参数

color

"Mixed" | "None" | "Accent1" | "Accent2" | "Accent3" | "Accent4" | "Accent5" | "Accent6" | "Dark1" | "Dark2" | "FollowedHyperlink" | "Hyperlink" | "Light1" | "Light2"

主题颜色。 值 none 对于 mixed 此 API 无效。

rgbColor

string

#RRGGBB 格式的颜色值 (例如“FFA500”) 或命名 HTML 颜色 (例如“orange”) 。

返回

void

注解

API 集:PowerPointApi 1.10

toJSON()

覆盖 JavaScript toJSON() 方法,以便在将 API 对象传递给 JSON.stringify()时提供更有用的输出。 (JSON.stringify反过来调用 toJSON 传递给它的对象的方法。) 虽然原始 PowerPoint.ThemeColorScheme 对象是 API 对象, toJSON 但该方法返回一个纯 JavaScript 对象, (类型化为 PowerPoint.Interfaces.ThemeColorSchemeData) ,其中包含从原始对象加载的任何子属性的浅层副本。

toJSON(): {
            [key: string]: string;
        };

返回

{ [key: string]: string; }