PowerPoint.ShapeCollection class

Representa a coleção de formas.

Extends

Comentários

[ Conjunto de API: PowerPointApi 1.3 ]

Propriedades

context

O contexto de solicitação associado ao objeto. Isso conecta o processo do suplemento ao processo do aplicativo host do Office.

items

Obtém os itens filhos carregados nesta coleção.

Métodos

addGeometricShape(geometricShapeType, options)

Adiciona uma forma geométrica ao slide. Retorna um Shape objeto que representa a nova forma.

addGeometricShape(geometricShapeTypeString, options)

Adiciona uma forma geométrica ao slide. Retorna um Shape objeto que representa a nova forma.

addLine(connectorType, options)

Adiciona uma linha ao slide. Retorna um Shape objeto que representa a nova linha.

addLine(connectorTypeString, options)

Adiciona uma linha ao slide. Retorna um Shape objeto que representa a nova linha.

addTextBox(text, options)

Adiciona uma caixa de texto ao slide com o texto fornecido como o conteúdo. Retorna um Shape objeto que representa a nova caixa de texto.

getCount()

Obtém o número de formas na coleção.

getItem(key)

Obtém uma forma usando sua ID exclusiva. Um erro será gerado se a forma não existir.

getItemAt(index)

Obtém uma forma usando seu índice baseado em zero na coleção. Um erro será gerado se o índice estiver fora do intervalo.

getItemOrNullObject(id)

Obtém uma forma usando sua ID exclusiva. Se essa forma não existir, um objeto com uma isNullObject propriedade definida como true será retornado.

load(options)

Coloca um comando na fila para carregar as propriedades especificadas do objeto. Você deve chamar context.sync() antes de ler as propriedades.

load(propertyNames)

Coloca um comando na fila para carregar as propriedades especificadas do objeto. Você deve chamar context.sync() antes de ler as propriedades.

load(propertyNamesAndPaths)

Coloca um comando na fila para carregar as propriedades especificadas do objeto. Você deve chamar context.sync() antes de ler as propriedades.

toJSON()

Substitui o método JavaScript toJSON() para fornecer uma saída mais útil quando um objeto de API é passado para JSON.stringify(). (JSON.stringifypor sua vez, chama o toJSON método do objeto que é passado para ele.) Considerando que o objeto original PowerPoint.ShapeCollection é um objeto API, o toJSON método retorna um objeto JavaScript simples (digitado como PowerPoint.Interfaces.ShapeCollectionData) que contém uma matriz de "itens" com cópias rasas de quaisquer propriedades carregadas dos itens da coleção.

Detalhes da propriedade

context

O contexto de solicitação associado ao objeto. Isso conecta o processo do suplemento ao processo do aplicativo host do Office.

context: RequestContext;

Valor da propriedade

items

Obtém os itens filhos carregados nesta coleção.

readonly items: PowerPoint.Shape[];

Valor da propriedade

Detalhes do método

addGeometricShape(geometricShapeType, options)

Adiciona uma forma geométrica ao slide. Retorna um Shape objeto que representa a nova forma.

addGeometricShape(geometricShapeType: PowerPoint.GeometricShapeType, options?: PowerPoint.ShapeAddOptions): PowerPoint.Shape;

Parâmetros

geometricShapeType
PowerPoint.GeometricShapeType

Especifica o tipo da forma geométrica. Consulte PowerPoint.GeometricShapeType para obter detalhes.

options
PowerPoint.ShapeAddOptions

Um parâmetro opcional para especificar as opções adicionais, como a posição da forma.

Retornos

A forma recém-inserida.

Comentários

[ Conjunto de API: PowerPointApi 1.4 ]

Exemplos

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

// This function gets the collection of shapes on the first slide,
// and adds a hexagon shape to the collection, while specifying its
// location and size. Then it names the shape.
await PowerPoint.run(async (context) => {
  const shapes = context.presentation.slides.getItemAt(0).shapes;
  const hexagon = shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon, 
      {
        left: 100,
        top: 100,
        height: 150,
        width: 150
      });
  hexagon.name = "Hexagon";

  await context.sync();
});

addGeometricShape(geometricShapeTypeString, options)

Adiciona uma forma geométrica ao slide. Retorna um Shape objeto que representa a nova forma.

addGeometricShape(geometricShapeTypeString: "LineInverse" | "Triangle" | "RightTriangle" | "Rectangle" | "Diamond" | "Parallelogram" | "Trapezoid" | "NonIsoscelesTrapezoid" | "Pentagon" | "Hexagon" | "Heptagon" | "Octagon" | "Decagon" | "Dodecagon" | "Star4" | "Star5" | "Star6" | "Star7" | "Star8" | "Star10" | "Star12" | "Star16" | "Star24" | "Star32" | "RoundRectangle" | "Round1Rectangle" | "Round2SameRectangle" | "Round2DiagonalRectangle" | "SnipRoundRectangle" | "Snip1Rectangle" | "Snip2SameRectangle" | "Snip2DiagonalRectangle" | "Plaque" | "Ellipse" | "Teardrop" | "HomePlate" | "Chevron" | "PieWedge" | "Pie" | "BlockArc" | "Donut" | "NoSmoking" | "RightArrow" | "LeftArrow" | "UpArrow" | "DownArrow" | "StripedRightArrow" | "NotchedRightArrow" | "BentUpArrow" | "LeftRightArrow" | "UpDownArrow" | "LeftUpArrow" | "LeftRightUpArrow" | "QuadArrow" | "LeftArrowCallout" | "RightArrowCallout" | "UpArrowCallout" | "DownArrowCallout" | "LeftRightArrowCallout" | "UpDownArrowCallout" | "QuadArrowCallout" | "BentArrow" | "UturnArrow" | "CircularArrow" | "LeftCircularArrow" | "LeftRightCircularArrow" | "CurvedRightArrow" | "CurvedLeftArrow" | "CurvedUpArrow" | "CurvedDownArrow" | "SwooshArrow" | "Cube" | "Can" | "LightningBolt" | "Heart" | "Sun" | "Moon" | "SmileyFace" | "IrregularSeal1" | "IrregularSeal2" | "FoldedCorner" | "Bevel" | "Frame" | "HalfFrame" | "Corner" | "DiagonalStripe" | "Chord" | "Arc" | "LeftBracket" | "RightBracket" | "LeftBrace" | "RightBrace" | "BracketPair" | "BracePair" | "Callout1" | "Callout2" | "Callout3" | "AccentCallout1" | "AccentCallout2" | "AccentCallout3" | "BorderCallout1" | "BorderCallout2" | "BorderCallout3" | "AccentBorderCallout1" | "AccentBorderCallout2" | "AccentBorderCallout3" | "WedgeRectCallout" | "WedgeRRectCallout" | "WedgeEllipseCallout" | "CloudCallout" | "Cloud" | "Ribbon" | "Ribbon2" | "EllipseRibbon" | "EllipseRibbon2" | "LeftRightRibbon" | "VerticalScroll" | "HorizontalScroll" | "Wave" | "DoubleWave" | "Plus" | "FlowChartProcess" | "FlowChartDecision" | "FlowChartInputOutput" | "FlowChartPredefinedProcess" | "FlowChartInternalStorage" | "FlowChartDocument" | "FlowChartMultidocument" | "FlowChartTerminator" | "FlowChartPreparation" | "FlowChartManualInput" | "FlowChartManualOperation" | "FlowChartConnector" | "FlowChartPunchedCard" | "FlowChartPunchedTape" | "FlowChartSummingJunction" | "FlowChartOr" | "FlowChartCollate" | "FlowChartSort" | "FlowChartExtract" | "FlowChartMerge" | "FlowChartOfflineStorage" | "FlowChartOnlineStorage" | "FlowChartMagneticTape" | "FlowChartMagneticDisk" | "FlowChartMagneticDrum" | "FlowChartDisplay" | "FlowChartDelay" | "FlowChartAlternateProcess" | "FlowChartOffpageConnector" | "ActionButtonBlank" | "ActionButtonHome" | "ActionButtonHelp" | "ActionButtonInformation" | "ActionButtonForwardNext" | "ActionButtonBackPrevious" | "ActionButtonEnd" | "ActionButtonBeginning" | "ActionButtonReturn" | "ActionButtonDocument" | "ActionButtonSound" | "ActionButtonMovie" | "Gear6" | "Gear9" | "Funnel" | "MathPlus" | "MathMinus" | "MathMultiply" | "MathDivide" | "MathEqual" | "MathNotEqual" | "CornerTabs" | "SquareTabs" | "PlaqueTabs" | "ChartX" | "ChartStar" | "ChartPlus", options?: PowerPoint.ShapeAddOptions): PowerPoint.Shape;

Parâmetros

geometricShapeTypeString

"LineInverse" | "Triangle" | "RightTriangle" | "Rectangle" | "Diamond" | "Parallelogram" | "Trapezoid" | "NonIsoscelesTrapezoid" | "Pentagon" | "Hexagon" | "Heptagon" | "Octagon" | "Decagon" | "Dodecagon" | "Star4" | "Star5" | "Star6" | "Star7" | "Star8" | "Star10" | "Star12" | "Star16" | "Star24" | "Star32" | "RoundRectangle" | "Round1Rectangle" | "Round2SameRectangle" | "Round2DiagonalRectangle" | "SnipRoundRectangle" | "Snip1Rectangle" | "Snip2SameRectangle" | "Snip2DiagonalRectangle" | "Plaque" | "Ellipse" | "Teardrop" | "HomePlate" | "Chevron" | "PieWedge" | "Pie" | "BlockArc" | "Donut" | "NoSmoking" | "RightArrow" | "LeftArrow" | "UpArrow" | "DownArrow" | "StripedRightArrow" | "NotchedRightArrow" | "BentUpArrow" | "LeftRightArrow" | "UpDownArrow" | "LeftUpArrow" | "LeftRightUpArrow" | "QuadArrow" | "LeftArrowCallout" | "RightArrowCallout" | "UpArrowCallout" | "DownArrowCallout" | "LeftRightArrowCallout" | "UpDownArrowCallout" | "QuadArrowCallout" | "BentArrow" | "UturnArrow" | "CircularArrow" | "LeftCircularArrow" | "LeftRightCircularArrow" | "CurvedRightArrow" | "CurvedLeftArrow" | "CurvedUpArrow" | "CurvedDownArrow" | "SwooshArrow" | "Cube" | "Can" | "LightningBolt" | "Heart" | "Sun" | "Moon" | "SmileyFace" | "IrregularSeal1" | "IrregularSeal2" | "FoldedCorner" | "Bevel" | "Frame" | "HalfFrame" | "Corner" | "DiagonalStripe" | "Chord" | "Arc" | "LeftBracket" | "RightBracket" | "LeftBrace" | "RightBrace" | "BracketPair" | "BracePair" | "Callout1" | "Callout2" | "Callout3" | "AccentCallout1" | "AccentCallout2" | "AccentCallout3" | "BorderCallout1" | "BorderCallout2" | "BorderCallout3" | "AccentBorderCallout1" | "AccentBorderCallout2" | "AccentBorderCallout3" | "WedgeRectCallout" | "WedgeRRectCallout" | "WedgeEllipseCallout" | "CloudCallout" | "Cloud" | "Ribbon" | "Ribbon2" | "EllipseRibbon" | "EllipseRibbon2" | "LeftRightRibbon" | "VerticalScroll" | "HorizontalScroll" | "Wave" | "DoubleWave" | "Plus" | "FlowChartProcess" | "FlowChartDecision" | "FlowChartInputOutput" | "FlowChartPredefinedProcess" | "FlowChartInternalStorage" | "FlowChartDocument" | "FlowChartMultidocument" | "FlowChartTerminator" | "FlowChartPreparation" | "FlowChartManualInput" | "FlowChartManualOperation" | "FlowChartConnector" | "FlowChartPunchedCard" | "FlowChartPunchedTape" | "FlowChartSummingJunction" | "FlowChartOr" | "FlowChartCollate" | "FlowChartSort" | "FlowChartExtract" | "FlowChartMerge" | "FlowChartOfflineStorage" | "FlowChartOnlineStorage" | "FlowChartMagneticTape" | "FlowChartMagneticDisk" | "FlowChartMagneticDrum" | "FlowChartDisplay" | "FlowChartDelay" | "FlowChartAlternateProcess" | "FlowChartOffpageConnector" | "ActionButtonBlank" | "ActionButtonHome" | "ActionButtonHelp" | "ActionButtonInformation" | "ActionButtonForwardNext" | "ActionButtonBackPrevious" | "ActionButtonEnd" | "ActionButtonBeginning" | "ActionButtonReturn" | "ActionButtonDocument" | "ActionButtonSound" | "ActionButtonMovie" | "Gear6" | "Gear9" | "Funnel" | "MathPlus" | "MathMinus" | "MathMultiply" | "MathDivide" | "MathEqual" | "MathNotEqual" | "CornerTabs" | "SquareTabs" | "PlaqueTabs" | "ChartX" | "ChartStar" | "ChartPlus"

Especifica o tipo da forma geométrica. Consulte PowerPoint.GeometricShapeType para obter detalhes.

options
PowerPoint.ShapeAddOptions

Um parâmetro opcional para especificar as opções adicionais, como a posição da forma.

Retornos

A forma recém-inserida.

Comentários

[ Conjunto de API: PowerPointApi 1.4 ]

addLine(connectorType, options)

Adiciona uma linha ao slide. Retorna um Shape objeto que representa a nova linha.

addLine(connectorType?: PowerPoint.ConnectorType, options?: PowerPoint.ShapeAddOptions): PowerPoint.Shape;

Parâmetros

connectorType
PowerPoint.ConnectorType

Especifica o tipo de conector da linha. Se não for fornecido, straight o tipo de conector será usado. Consulte PowerPoint.ConnectorType para obter detalhes.

options
PowerPoint.ShapeAddOptions

Um parâmetro opcional para especificar as opções adicionais, como a posição do objeto shape que contém a linha.

Retornos

A forma recém-inserida.

Comentários

[ Conjunto de API: PowerPointApi 1.4 ]

Exemplos

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

// This function gets the collection of shapes on the first slide,
// and adds a line to the collection, while specifying its
// start and end points. Then it names the shape.
await PowerPoint.run(async (context) => {
  const shapes = context.presentation.slides.getItemAt(0).shapes;

  // For a line, left and top are the coordinates of the start point,
  // while height and width are the coordinates of the end point.
  const line = shapes.addLine(PowerPoint.ConnectorType.straight, 
      { 
        left: 400, 
        top: 200, 
        height: 20, 
        width: 150 
      });
  line.name = "StraightLine";

  await context.sync();
});

addLine(connectorTypeString, options)

Adiciona uma linha ao slide. Retorna um Shape objeto que representa a nova linha.

addLine(connectorTypeString?: "Straight" | "Elbow" | "Curve", options?: PowerPoint.ShapeAddOptions): PowerPoint.Shape;

Parâmetros

connectorTypeString

"Straight" | "Elbow" | "Curve"

Especifica o tipo de conector da linha. Se não for fornecido, straight o tipo de conector será usado. Consulte PowerPoint.ConnectorType para obter detalhes.

options
PowerPoint.ShapeAddOptions

Um parâmetro opcional para especificar as opções adicionais, como a posição do objeto shape que contém a linha.

Retornos

A forma recém-inserida.

Comentários

[ Conjunto de API: PowerPointApi 1.4 ]

addTextBox(text, options)

Adiciona uma caixa de texto ao slide com o texto fornecido como o conteúdo. Retorna um Shape objeto que representa a nova caixa de texto.

addTextBox(text: string, options?: PowerPoint.ShapeAddOptions): PowerPoint.Shape;

Parâmetros

text

string

Especifica o texto que será mostrado na caixa de texto criada.

options
PowerPoint.ShapeAddOptions

Um parâmetro opcional para especificar as opções adicionais, como a posição da caixa de texto.

Retornos

A forma recém-inserida.

Comentários

[ Conjunto de API: PowerPointApi 1.4 ]

Exemplos

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

// This function gets the collection of shapes on the first slide,
// and adds a text box to the collection, while specifying its text,
// location, and size. Then it names the text box.
await PowerPoint.run(async (context) => {
  const shapes = context.presentation.slides.getItemAt(0).shapes;
  const textbox = shapes.addTextBox("Hello!", 
      { 
        left: 100, 
        top: 300, 
        height: 300, 
        width: 450 
      });
  textbox.name = "Textbox";

  return context.sync();
});

getCount()

Obtém o número de formas na coleção.

getCount(): OfficeExtension.ClientResult<number>;

Retornos

O número de formas na coleção.

Comentários

[ Conjunto de API: PowerPointApi 1.3 ]

getItem(key)

Obtém uma forma usando sua ID exclusiva. Um erro será gerado se a forma não existir.

getItem(key: string): PowerPoint.Shape;

Parâmetros

key

string

A ID da forma.

Retornos

A forma com a ID exclusiva. Se essa forma não existir, um erro será gerado.

Comentários

[ Conjunto de API: PowerPointApi 1.3 ]

getItemAt(index)

Obtém uma forma usando seu índice baseado em zero na coleção. Um erro será gerado se o índice estiver fora do intervalo.

getItemAt(index: number): PowerPoint.Shape;

Parâmetros

index

number

O índice da forma na coleção.

Retornos

A forma no índice determinado. Um erro será gerado se o índice estiver fora do intervalo.

Comentários

[ Conjunto de API: PowerPointApi 1.3 ]

Exemplos

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

await PowerPoint.run(async function(context) {
  const slide = context.presentation.slides.getItemAt(0);
  const shape = slide.shapes.getItemAt(0);
  shape.tags.add("MOUNTAIN", "Denali");

  await context.sync();

  const myShapeTag = shape.tags.getItem("MOUNTAIN");
  myShapeTag.load("key, value");

  await context.sync();

  console.log("Added key " + JSON.stringify(myShapeTag.key) + " with value " + JSON.stringify(myShapeTag.value));
});

getItemOrNullObject(id)

Obtém uma forma usando sua ID exclusiva. Se essa forma não existir, um objeto com uma isNullObject propriedade definida como true será retornado.

getItemOrNullObject(id: string): PowerPoint.Shape;

Parâmetros

id

string

A ID da forma.

Retornos

A forma com a ID exclusiva. Se essa forma não existir, um objeto com uma isNullObject propriedade definida como true será retornado.

Comentários

[ Conjunto de API: PowerPointApi 1.3 ]

load(options)

Coloca um comando na fila para carregar as propriedades especificadas do objeto. Você deve chamar context.sync() antes de ler as propriedades.

load(options?: PowerPoint.Interfaces.ShapeCollectionLoadOptions & PowerPoint.Interfaces.CollectionLoadOptions): PowerPoint.ShapeCollection;

Parâmetros

options

PowerPoint.Interfaces.ShapeCollectionLoadOptions & PowerPoint.Interfaces.CollectionLoadOptions

Fornece opções para quais propriedades do objeto carregar.

Retornos

load(propertyNames)

Coloca um comando na fila para carregar as propriedades especificadas do objeto. Você deve chamar context.sync() antes de ler as propriedades.

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

Parâmetros

propertyNames

string | string[]

Uma cadeia de caracteres delimitada por vírgulas ou uma matriz de cadeias de caracteres que especificam as propriedades a serem carregadas.

Retornos

load(propertyNamesAndPaths)

Coloca um comando na fila para carregar as propriedades especificadas do objeto. Você deve chamar context.sync() antes de ler as propriedades.

load(propertyNamesAndPaths?: OfficeExtension.LoadOption): PowerPoint.ShapeCollection;

Parâmetros

propertyNamesAndPaths
OfficeExtension.LoadOption

propertyNamesAndPaths.select é uma cadeia de caracteres delimitada por vírgulas que especifica as propriedades a serem carregadas e propertyNamesAndPaths.expand é uma cadeia de caracteres delimitada por vírgulas que especifica as propriedades de navegação a serem carregadas.

Retornos

toJSON()

Substitui o método JavaScript toJSON() para fornecer uma saída mais útil quando um objeto de API é passado para JSON.stringify(). (JSON.stringifypor sua vez, chama o toJSON método do objeto que é passado para ele.) Considerando que o objeto original PowerPoint.ShapeCollection é um objeto API, o toJSON método retorna um objeto JavaScript simples (digitado como PowerPoint.Interfaces.ShapeCollectionData) que contém uma matriz de "itens" com cópias rasas de quaisquer propriedades carregadas dos itens da coleção.

toJSON(): PowerPoint.Interfaces.ShapeCollectionData;

Retornos