Compartir a través de


PowerPoint.ShapeCollection class

Representa la colección de formas.

Extends

Comentarios

[ Conjunto de API: PowerPointApi 1.3 ]

Propiedades

context

Contexto de solicitud asociado al objeto . Esto conecta el proceso del complemento al proceso de la aplicación host de Office.

items

Obtiene los elementos secundarios cargados en esta colección.

Métodos

addGeometricShape(geometricShapeType, options)

Agrega una forma geométrica a la diapositiva. Devuelve un Shape objeto que representa la nueva forma.

addGeometricShape(geometricShapeTypeString, options)

Agrega una forma geométrica a la diapositiva. Devuelve un Shape objeto que representa la nueva forma.

addLine(connectorType, options)

Agrega una línea a la diapositiva. Devuelve un Shape objeto que representa la nueva línea.

addLine(connectorTypeString, options)

Agrega una línea a la diapositiva. Devuelve un Shape objeto que representa la nueva línea.

addTextBox(text, options)

Agrega un cuadro de texto a la diapositiva con el texto proporcionado como contenido. Devuelve un Shape objeto que representa el nuevo cuadro de texto.

getCount()

Obtiene el número de formas de la colección.

getItem(key)

Obtiene una forma con su identificador único. Se produce un error si la forma no existe.

getItemAt(index)

Obtiene una forma mediante su índice de base cero en la colección. Se produce un error si el índice está fuera del intervalo.

getItemOrNullObject(id)

Obtiene una forma con su identificador único. Si dicha forma no existe, se devuelve un objeto con una isNullObject propiedad establecida en true.

load(options)

Pone en cola un comando para cargar las propiedades especificadas del objeto. Debe llamar a context.sync() antes de leer las propiedades.

load(propertyNames)

Pone en cola un comando para cargar las propiedades especificadas del objeto. Debe llamar a context.sync() antes de leer las propiedades.

load(propertyNamesAndPaths)

Pone en cola un comando para cargar las propiedades especificadas del objeto. Debe llamar a context.sync() antes de leer las propiedades.

toJSON()

Invalida el método JavaScript toJSON() para proporcionar una salida más útil cuando se pasa un objeto de API a JSON.stringify(). (JSON.stringifya su vez, llama al toJSON método del objeto que se le pasa). Mientras que el objeto original PowerPoint.ShapeCollection es un objeto de API, el toJSON método devuelve un objeto JavaScript sin formato (escrito como PowerPoint.Interfaces.ShapeCollectionData) que contiene una matriz de "elementos" con copias superficiales de las propiedades cargadas de los elementos de la colección.

Detalles de las propiedades

context

Contexto de solicitud asociado al objeto . Esto conecta el proceso del complemento al proceso de la aplicación host de Office.

context: RequestContext;

Valor de propiedad

items

Obtiene los elementos secundarios cargados en esta colección.

readonly items: PowerPoint.Shape[];

Valor de propiedad

Detalles del método

addGeometricShape(geometricShapeType, options)

Agrega una forma geométrica a la diapositiva. Devuelve un Shape objeto que representa la nueva forma.

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

Parámetros

geometricShapeType
PowerPoint.GeometricShapeType

Especifica el tipo de la forma geométrica. Consulte PowerPoint.GeometricShapeType para obtener más información.

options
PowerPoint.ShapeAddOptions

Parámetro opcional para especificar las opciones adicionales, como la posición de la forma.

Devoluciones

Forma recién insertada.

Comentarios

[ Conjunto de API: PowerPointApi 1.4 ]

Ejemplos

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

Agrega una forma geométrica a la diapositiva. Devuelve un Shape objeto que representa la nueva 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 el tipo de la forma geométrica. Consulte PowerPoint.GeometricShapeType para obtener más información.

options
PowerPoint.ShapeAddOptions

Parámetro opcional para especificar las opciones adicionales, como la posición de la forma.

Devoluciones

Forma recién insertada.

Comentarios

[ Conjunto de API: PowerPointApi 1.4 ]

addLine(connectorType, options)

Agrega una línea a la diapositiva. Devuelve un Shape objeto que representa la nueva línea.

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

Parámetros

connectorType
PowerPoint.ConnectorType

Especifica el tipo de conector de la línea. Si no se proporciona, straight se usará el tipo de conector. Vea PowerPoint.ConnectorType para obtener más información.

options
PowerPoint.ShapeAddOptions

Parámetro opcional para especificar las opciones adicionales, como la posición del objeto de forma que contiene la línea.

Devoluciones

Forma recién insertada.

Comentarios

[ Conjunto de API: PowerPointApi 1.4 ]

Ejemplos

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

Agrega una línea a la diapositiva. Devuelve un Shape objeto que representa la nueva línea.

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

Parámetros

connectorTypeString

"Straight" | "Elbow" | "Curve"

Especifica el tipo de conector de la línea. Si no se proporciona, straight se usará el tipo de conector. Vea PowerPoint.ConnectorType para obtener más información.

options
PowerPoint.ShapeAddOptions

Parámetro opcional para especificar las opciones adicionales, como la posición del objeto de forma que contiene la línea.

Devoluciones

Forma recién insertada.

Comentarios

[ Conjunto de API: PowerPointApi 1.4 ]

addTextBox(text, options)

Agrega un cuadro de texto a la diapositiva con el texto proporcionado como contenido. Devuelve un Shape objeto que representa el nuevo cuadro de texto.

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

Parámetros

text

string

Especifica el texto que se mostrará en el cuadro de texto creado.

options
PowerPoint.ShapeAddOptions

Parámetro opcional para especificar las opciones adicionales, como la posición del cuadro de texto.

Devoluciones

Forma recién insertada.

Comentarios

[ Conjunto de API: PowerPointApi 1.4 ]

Ejemplos

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

Obtiene el número de formas de la colección.

getCount(): OfficeExtension.ClientResult<number>;

Devoluciones

Número de formas de la colección.

Comentarios

[ Conjunto de API: PowerPointApi 1.3 ]

getItem(key)

Obtiene una forma con su identificador único. Se produce un error si la forma no existe.

getItem(key: string): PowerPoint.Shape;

Parámetros

key

string

Identificador de la forma.

Devoluciones

Forma con el identificador único. Si dicha forma no existe, se produce un error.

Comentarios

[ Conjunto de API: PowerPointApi 1.3 ]

getItemAt(index)

Obtiene una forma mediante su índice de base cero en la colección. Se produce un error si el índice está fuera del intervalo.

getItemAt(index: number): PowerPoint.Shape;

Parámetros

index

number

Índice de la forma de la colección.

Devoluciones

Forma en el índice especificado. Se produce un error si el índice está fuera del intervalo.

Comentarios

[ Conjunto de API: PowerPointApi 1.3 ]

Ejemplos

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

Obtiene una forma con su identificador único. Si dicha forma no existe, se devuelve un objeto con una isNullObject propiedad establecida en true.

getItemOrNullObject(id: string): PowerPoint.Shape;

Parámetros

id

string

Identificador de la forma.

Devoluciones

Forma con el identificador único. Si dicha forma no existe, se devuelve un objeto con una isNullObject propiedad establecida en true.

Comentarios

[ Conjunto de API: PowerPointApi 1.3 ]

load(options)

Pone en cola un comando para cargar las propiedades especificadas del objeto. Debe llamar a context.sync() antes de leer las propiedades.

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

Parámetros

options

PowerPoint.Interfaces.ShapeCollectionLoadOptions & PowerPoint.Interfaces.CollectionLoadOptions

Proporciona opciones para las propiedades del objeto que se van a cargar.

Devoluciones

load(propertyNames)

Pone en cola un comando para cargar las propiedades especificadas del objeto. Debe llamar a context.sync() antes de leer las propiedades.

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

Parámetros

propertyNames

string | string[]

Una cadena delimitada por comas o una matriz de cadenas que especifican las propiedades que se van a cargar.

Devoluciones

Ejemplos

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

// Changes the transparency of every geometric shape in the slide.
await PowerPoint.run(async (context) => {
  // Get the type of shape for every shape in the collection.
  const shapes = context.presentation.slides.getItemAt(0).shapes;
  shapes.load("type");
  await context.sync();

  // Change the shape transparency to be halfway transparent.
  shapes.items.forEach((shape) => {
    if (shape.type === PowerPoint.ShapeType.geometricShape) {
      shape.fill.transparency = 0.5;
    }
  });
  await context.sync();
});

load(propertyNamesAndPaths)

Pone en cola un comando para cargar las propiedades especificadas del objeto. Debe llamar a context.sync() antes de leer las propiedades.

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

Parámetros

propertyNamesAndPaths
OfficeExtension.LoadOption

propertyNamesAndPaths.select es una cadena delimitada por comas que especifica las propiedades que se van a cargar y propertyNamesAndPaths.expand es una cadena delimitada por comas que especifica las propiedades de navegación que se van a cargar.

Devoluciones

toJSON()

Invalida el método JavaScript toJSON() para proporcionar una salida más útil cuando se pasa un objeto de API a JSON.stringify(). (JSON.stringifya su vez, llama al toJSON método del objeto que se le pasa). Mientras que el objeto original PowerPoint.ShapeCollection es un objeto de API, el toJSON método devuelve un objeto JavaScript sin formato (escrito como PowerPoint.Interfaces.ShapeCollectionData) que contiene una matriz de "elementos" con copias superficiales de las propiedades cargadas de los elementos de la colección.

toJSON(): PowerPoint.Interfaces.ShapeCollectionData;

Devoluciones