PowerPoint.SlideBackgroundFill class

スライドの背景オブジェクトの塗りつぶしの書式設定を表します。

Extends

注釈

API セット: PowerPointApi 1.10

使用元

// 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」 を参照してください。

メソッド

getGradientFillOrNullObject()

グラデーションの塗りつぶしのプロパティを取得します。 塗りつぶしの種類が gradient でない場合は、 isNullObject プロパティが true に設定されたオブジェクトが返されます。 詳細については、「 *OrNullObject のメソッドとプロパティ」を参照してください。

getPatternFillOrNullObject()

パターンの塗りつぶしプロパティを取得します。 塗りつぶしの種類が pattern でない場合は、 isNullObject プロパティが true に設定されたオブジェクトが返されます。 詳細については、「 *OrNullObject のメソッドとプロパティ」を参照してください。

getPictureOrTextureFillOrNullObject()

画像またはテクスチャ塗りつぶしのプロパティを取得します。 塗りつぶしの種類が pictureOrTexture でない場合は、 isNullObject プロパティが true に設定されたオブジェクトが返されます。 詳細については、「 *OrNullObject のメソッドとプロパティ」を参照してください。

getSolidFillOrNullObject()

塗りつぶしのプロパティを取得します。 塗りつぶしの種類が solid でない場合は、 isNullObject プロパティが true に設定されたオブジェクトが返されます。 詳細については、「 *OrNullObject のメソッドとプロパティ」を参照してください。

load(options)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNames)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNamesAndPaths)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

setGradientFill(options)

スライドの背景の塗りつぶしの書式設定をグラデーション塗りつぶしに設定します。 これにより、塗りつぶしの種類が gradient に変わります。

setPatternFill(options)

スライドの背景の塗りつぶしの書式設定を塗りつぶしパターンに設定します。 これにより、塗りつぶしの種類が pattern に変わります。

setPictureOrTextureFill(options)

スライド背景の塗りつぶしの書式設定を、図またはテクスチャの塗りつぶしに設定します。 これにより、塗りつぶしの種類が pictureOrTexture に変わります。

setSolidFill(options)

スライドの背景の塗りつぶしの書式設定を塗りつぶし (塗りつぶし) に設定します。 これにより、塗りつぶしの種類が solid に変わります。

toJSON()

API オブジェクトが JSON.stringify() に渡されるときに、より有用な出力を提供するために、JavaScript toJSON() メソッドをオーバーライドします。 (次に、JSON.stringify渡されたオブジェクトの toJSON メソッドを呼び出します)。元の PowerPoint.SlideBackgroundFill オブジェクトが API オブジェクトであるのに対し、 toJSON メソッドは、元のオブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト ( PowerPoint.Interfaces.SlideBackgroundFillData と型指定) を返します。

プロパティの詳細

context

オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。

context: RequestContext;

プロパティ値

type

スライド背景の塗りつぶしの種類を返します。 詳細については、「 PowerPoint.SlideBackgroundFillType」 を参照してください。

readonly type: PowerPoint.SlideBackgroundFillType | "Unsupported" | "Solid" | "Gradient" | "PictureOrTexture" | "Pattern";

プロパティ値

PowerPoint.SlideBackgroundFillType | "Unsupported" | "Solid" | "Gradient" | "PictureOrTexture" | "Pattern"

注釈

API セット: PowerPointApi 1.10

メソッドの詳細

getGradientFillOrNullObject()

グラデーションの塗りつぶしのプロパティを取得します。 塗りつぶしの種類が gradient でない場合は、 isNullObject プロパティが true に設定されたオブジェクトが返されます。 詳細については、「 *OrNullObject のメソッドとプロパティ」を参照してください。

getGradientFillOrNullObject(): PowerPoint.SlideBackgroundGradientFill;

返品

注釈

API セット: PowerPointApi 1.10

// 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;

返品

注釈

API セット: PowerPointApi 1.10

// 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;

返品

注釈

API セット: PowerPointApi 1.10

// 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;

返品

注釈

API セット: PowerPointApi 1.10

// 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;

パラメーター

options
PowerPoint.Interfaces.SlideBackgroundFillLoadOptions

読み込むオブジェクトのプロパティのオプションを指定します。

返品

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;

パラメーター

options
PowerPoint.SlideBackgroundGradientFillOptions

グラデーションの塗りつぶしのオプション。

返品

void

注釈

API セット: PowerPointApi 1.10

// 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;

パラメーター

options
PowerPoint.SlideBackgroundPatternFillOptions

パターン塗りつぶしのオプション。

返品

void

注釈

API セット: PowerPointApi 1.10

// 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;

パラメーター

options
PowerPoint.SlideBackgroundPictureOrTextureFillOptions

図またはテクスチャの塗りつぶしのオプション。

返品

void

注釈

API セット: PowerPointApi 1.10

// 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;

パラメーター

options
PowerPoint.SlideBackgroundSolidFillOptions

塗りつぶしのオプション。

返品

void

注釈

API セット: PowerPointApi 1.10

// 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()

API オブジェクトが JSON.stringify() に渡されるときに、より有用な出力を提供するために、JavaScript toJSON() メソッドをオーバーライドします。 (次に、JSON.stringify渡されたオブジェクトの toJSON メソッドを呼び出します)。元の PowerPoint.SlideBackgroundFill オブジェクトが API オブジェクトであるのに対し、 toJSON メソッドは、元のオブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト ( PowerPoint.Interfaces.SlideBackgroundFillData と型指定) を返します。

toJSON(): PowerPoint.Interfaces.SlideBackgroundFillData;

返品