PowerPoint.Shape class

スライド内の 1 つの図形を表します。

Extends

注釈

[ API セット: PowerPointApi 1.3 ]

プロパティ

context

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

fill

この図形の塗りつぶしの書式設定を返します。

height

図形の高さをポイント単位で指定します。 負の値を InvalidArgument 設定すると例外がスローされます。

id

図形の一意の ID を取得します。

left

図形の左側からスライドの左側までの距離をポイント単位で指定します。

lineFormat

この図形の線の書式設定を返します。

name

この図形の名前を指定します。

tags

図形内のタグのコレクションを返します。

textFrame

この図形のテキスト フレーム オブジェクトを返します。

top

図形の上端からスライドの上端までの距離をポイント単位で指定します。

type

この図形の種類を返します。 詳細については、「 PowerPoint.ShapeType 」を参照してください。

width

図形の幅をポイント単位で指定します。 負の値を InvalidArgument 設定すると例外がスローされます。

メソッド

delete()

図形コレクションから図形を削除します。 図形が存在しない場合は何も行いません。

getParentSlide()

この Shapeを保持する親 PowerPoint.Slide オブジェクトを返します。 この図形が に属していない場合は、例外を Slideスローします。

getParentSlideLayout()

この Shapeを保持する親 PowerPoint.SlideLayout オブジェクトを返します。 この図形が に属していない場合は、例外を SlideLayoutスローします。

getParentSlideLayoutOrNullObject()

この Shapeを保持する親 PowerPoint.SlideLayout オブジェクトを返します。 この図形が にSlideLayout属していない場合は、 プロパティが にtrue設定されたオブジェクトisNullObjectが返されます。

getParentSlideMaster()

この Shapeを保持する親 PowerPoint.SlideMaster オブジェクトを返します。 この図形が に属していない場合は、例外を SlideMasterスローします。

getParentSlideMasterOrNullObject()

この Shapeを保持する親 PowerPoint.SlideMaster オブジェクトを返します。 この図形が にSlideMaster属していない場合は、 プロパティが にtrue設定されたオブジェクトisNullObjectが返されます。

getParentSlideOrNullObject()

この Shapeを保持する親 PowerPoint.Slide オブジェクトを返します。 この図形が にSlide属していない場合は、 プロパティが にtrue設定されたオブジェクトisNullObjectが返されます。

load(options)

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

load(propertyNames)

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

load(propertyNamesAndPaths)

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

toJSON()

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

プロパティの詳細

context

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

context: RequestContext;

プロパティ値

fill

この図形の塗りつぶしの書式設定を返します。

readonly fill: PowerPoint.ShapeFill;

プロパティ値

注釈

[ API セット: PowerPointApi 1.4 ]

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml

// Changes the selected shapes fill color to red.
await PowerPoint.run(async (context) => {
  const shapes = context.presentation.getSelectedShapes();
  const shapeCount = shapes.getCount();
  shapes.load("items");
  await context.sync();
  shapes.items.map((shape) => {
    shape.fill.setSolidColor("red");
  });
  await context.sync();
});

height

図形の高さをポイント単位で指定します。 負の値を InvalidArgument 設定すると例外がスローされます。

height: number;

プロパティ値

number

注釈

[ API セット: PowerPointApi 1.4 ]

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml

// Arranges the selected shapes in a line from left to right.
await PowerPoint.run(async (context) => {
  const shapes = context.presentation.getSelectedShapes();
  const shapeCount = shapes.getCount();
  shapes.load("items");
  await context.sync();
  let maxHeight = 0;
  shapes.items.map((shape) => {
    shape.load("width,height");
  });
  await context.sync();
  shapes.items.map((shape) => {
    shape.left = currentLeft;
    shape.top = currentTop;
    currentLeft += shape.width;
    if (shape.height > maxHeight) maxHeight = shape.height;
  });
  await context.sync();
  currentLeft = 0;
  if (currentTop > slideHeight - 200) currentTop = 0;
});

id

図形の一意の ID を取得します。

readonly id: string;

プロパティ値

string

注釈

[ API セット: PowerPointApi 1.3 ]

left

図形の左側からスライドの左側までの距離をポイント単位で指定します。

left: number;

プロパティ値

number

注釈

[ API セット: PowerPointApi 1.4 ]

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml

// Arranges the selected shapes in a line from left to right.
await PowerPoint.run(async (context) => {
  const shapes = context.presentation.getSelectedShapes();
  const shapeCount = shapes.getCount();
  shapes.load("items");
  await context.sync();
  let maxHeight = 0;
  shapes.items.map((shape) => {
    shape.load("width,height");
  });
  await context.sync();
  shapes.items.map((shape) => {
    shape.left = currentLeft;
    shape.top = currentTop;
    currentLeft += shape.width;
    if (shape.height > maxHeight) maxHeight = shape.height;
  });
  await context.sync();
  currentLeft = 0;
  if (currentTop > slideHeight - 200) currentTop = 0;
});

lineFormat

この図形の線の書式設定を返します。

readonly lineFormat: PowerPoint.ShapeLineFormat;

プロパティ値

注釈

[ API セット: PowerPointApi 1.4 ]

name

この図形の名前を指定します。

name: string;

プロパティ値

string

注釈

[ API セット: PowerPointApi 1.4 ]

tags

図形内のタグのコレクションを返します。

readonly tags: PowerPoint.TagCollection;

プロパティ値

注釈

[ API セット: PowerPointApi 1.3 ]

textFrame

この図形のテキスト フレーム オブジェクトを返します。

readonly textFrame: PowerPoint.TextFrame;

プロパティ値

注釈

[ API セット: PowerPointApi 1.4 ]

top

図形の上端からスライドの上端までの距離をポイント単位で指定します。

top: number;

プロパティ値

number

注釈

[ API セット: PowerPointApi 1.4 ]

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml

// Arranges the selected shapes in a line from left to right.
await PowerPoint.run(async (context) => {
  const shapes = context.presentation.getSelectedShapes();
  const shapeCount = shapes.getCount();
  shapes.load("items");
  await context.sync();
  let maxHeight = 0;
  shapes.items.map((shape) => {
    shape.load("width,height");
  });
  await context.sync();
  shapes.items.map((shape) => {
    shape.left = currentLeft;
    shape.top = currentTop;
    currentLeft += shape.width;
    if (shape.height > maxHeight) maxHeight = shape.height;
  });
  await context.sync();
  currentLeft = 0;
  if (currentTop > slideHeight - 200) currentTop = 0;
});

type

この図形の種類を返します。 詳細については、「 PowerPoint.ShapeType 」を参照してください。

readonly type: PowerPoint.ShapeType | "Unsupported" | "Image" | "GeometricShape" | "Group" | "Line" | "Table";

プロパティ値

PowerPoint.ShapeType | "Unsupported" | "Image" | "GeometricShape" | "Group" | "Line" | "Table"

注釈

[ API セット: PowerPointApi 1.4 ]

width

図形の幅をポイント単位で指定します。 負の値を InvalidArgument 設定すると例外がスローされます。

width: number;

プロパティ値

number

注釈

[ API セット: PowerPointApi 1.4 ]

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml

// Arranges the selected shapes in a line from left to right.
await PowerPoint.run(async (context) => {
  const shapes = context.presentation.getSelectedShapes();
  const shapeCount = shapes.getCount();
  shapes.load("items");
  await context.sync();
  let maxHeight = 0;
  shapes.items.map((shape) => {
    shape.load("width,height");
  });
  await context.sync();
  shapes.items.map((shape) => {
    shape.left = currentLeft;
    shape.top = currentTop;
    currentLeft += shape.width;
    if (shape.height > maxHeight) maxHeight = shape.height;
  });
  await context.sync();
  currentLeft = 0;
  if (currentTop > slideHeight - 200) currentTop = 0;
});

メソッドの詳細

delete()

図形コレクションから図形を削除します。 図形が存在しない場合は何も行いません。

delete(): void;

戻り値

void

注釈

[ API セット: PowerPointApi 1.3 ]

getParentSlide()

この Shapeを保持する親 PowerPoint.Slide オブジェクトを返します。 この図形が に属していない場合は、例外を Slideスローします。

getParentSlide(): PowerPoint.Slide;

戻り値

注釈

[ API セット: PowerPointApi 1.5 ]

getParentSlideLayout()

この Shapeを保持する親 PowerPoint.SlideLayout オブジェクトを返します。 この図形が に属していない場合は、例外を SlideLayoutスローします。

getParentSlideLayout(): PowerPoint.SlideLayout;

戻り値

注釈

[ API セット: PowerPointApi 1.5 ]

getParentSlideLayoutOrNullObject()

この Shapeを保持する親 PowerPoint.SlideLayout オブジェクトを返します。 この図形が にSlideLayout属していない場合は、 プロパティが にtrue設定されたオブジェクトisNullObjectが返されます。

getParentSlideLayoutOrNullObject(): PowerPoint.SlideLayout;

戻り値

注釈

[ API セット: PowerPointApi 1.5 ]

getParentSlideMaster()

この Shapeを保持する親 PowerPoint.SlideMaster オブジェクトを返します。 この図形が に属していない場合は、例外を SlideMasterスローします。

getParentSlideMaster(): PowerPoint.SlideMaster;

戻り値

注釈

[ API セット: PowerPointApi 1.5 ]

getParentSlideMasterOrNullObject()

この Shapeを保持する親 PowerPoint.SlideMaster オブジェクトを返します。 この図形が にSlideMaster属していない場合は、 プロパティが にtrue設定されたオブジェクトisNullObjectが返されます。

getParentSlideMasterOrNullObject(): PowerPoint.SlideMaster;

戻り値

注釈

[ API セット: PowerPointApi 1.5 ]

getParentSlideOrNullObject()

この Shapeを保持する親 PowerPoint.Slide オブジェクトを返します。 この図形が にSlide属していない場合は、 プロパティが にtrue設定されたオブジェクトisNullObjectが返されます。

getParentSlideOrNullObject(): PowerPoint.Slide;

戻り値

注釈

[ API セット: PowerPointApi 1.5 ]

load(options)

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

load(options?: PowerPoint.Interfaces.ShapeLoadOptions): PowerPoint.Shape;

パラメーター

options
PowerPoint.Interfaces.ShapeLoadOptions

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

戻り値

load(propertyNames)

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

load(propertyNames?: string | string[]): PowerPoint.Shape;

パラメーター

propertyNames

string | string[]

読み込むプロパティを指定するコンマ区切り文字列または文字列の配列。

戻り値

load(propertyNamesAndPaths)

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

load(propertyNamesAndPaths?: {
            select?: string;
            expand?: string;
        }): PowerPoint.Shape;

パラメーター

propertyNamesAndPaths

{ select?: string; expand?: string; }

propertyNamesAndPaths.select は、読み込むプロパティを指定するコンマ区切り文字列で propertyNamesAndPaths.expand 、読み込むナビゲーション プロパティを指定するコンマ区切りの文字列です。

戻り値

toJSON()

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

toJSON(): PowerPoint.Interfaces.ShapeData;

戻り値