org.apache.poi.xslf.usermodel

## Class XSLFShape

- java.lang.Object
- - org.apache.poi.xslf.usermodel.XSLFShape

- All Implemented Interfaces:
    Shape<XSLFShape,XSLFTextParagraph>
  Direct Known Subclasses:
    XSLFGraphicFrame, XSLFGroupShape, XSLFShadow, XSLFSimpleShape

      @Beta
      public abstract class XSLFShape
      extends java.lang.Object
      implements Shape<XSLFShape,XSLFTextParagraph>

  Base super-class class for all shapes in PresentationML

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `XSLFShape.ReparseFactory<T extends org.apache.xmlbeans.XmlObject>`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `XSLFShape(org.apache.xmlbeans.XmlObject shape, XSLFSheet sheet)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `draw(java.awt.Graphics2D graphics, java.awt.geom.Rectangle2D bounds)` Convenience method to draw a single shape
    `protected boolean` | `fetchShapeProperty(PropertyFetcher<?> visitor)` Walk up the inheritance tree and fetch shape properties.
    `protected org.openxmlformats.schemas.presentationml.x2006.main.CTBackgroundProperties` | `getBgPr()`
    `protected org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrixReference` | `getBgRef()`
    `protected <T extends org.apache.xmlbeans.XmlObject> T` | `getChild(java.lang.Class<T> childClass, java.lang.String namespace, java.lang.String nodename)` Return direct child objects of this shape
    `protected org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps` | `getCNvPr()`
    `protected PaintStyle` | `getFillPaint()`
    `protected org.openxmlformats.schemas.drawingml.x2006.main.CTGroupShapeProperties` | `getGrpSpPr()`
    `XSLFShapeContainer` | `getParent()`
    `Placeholder` | `getPlaceholder()`
    `XSLFPlaceholderDetails` | `getPlaceholderDetails()`
    `int` | `getShapeId()` Returns a unique identifier for this shape within the current slide.
    `java.lang.String` | `getShapeName()`
    `protected org.apache.xmlbeans.XmlObject` | `getShapeProperties()` Return the shape specific (visual) properties
    `XSLFSheet` | `getSheet()`
    `protected org.openxmlformats.schemas.drawingml.x2006.main.CTShapeStyle` | `getSpStyle()`
    `org.apache.xmlbeans.XmlObject` | `getXmlObject()`
    `boolean` | `isPlaceholder()`
    `protected PaintStyle` | `selectPaint(org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties blipFill, PackagePart parentPart, org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor phClr, XSLFTheme theme)`
    `protected PaintStyle` | `selectPaint(org.openxmlformats.schemas.drawingml.x2006.main.CTGradientFillProperties gradFill, org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor phClr, XSLFTheme theme)`
    `protected PaintStyle` | `selectPaint(org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties solidFill, org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor phClr, XSLFTheme theme)`
    `protected PaintStyle` | `selectPaint(org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrixReference fillRef, XSLFTheme theme, boolean isLineStyle, boolean hasPlaceholder)`
    `protected PaintStyle` | `selectPaint(XSLFPropertiesDelegate.XSLFFillProperties fp, org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor phClr, PackagePart parentPart, XSLFTheme theme, boolean hasPlaceholder)` Convert shape fill into java.awt.Paint.
    `protected <T extends org.apache.xmlbeans.XmlObject> T` | `selectProperty(java.lang.Class<T> resultClass, java.lang.String xquery)` As there's no xmlbeans hierarchy, but XSLF works with subclassing, not all child classes work with a `CTShape` object, but often contain the same properties.
    `<T extends org.apache.xmlbeans.XmlObject> T` | `selectProperty(java.lang.Class<T> resultClass, XSLFShape.ReparseFactory<T> factory, javax.xml.namespace.QName[]... path)` Internal code - API may change any time!
    `void` | `setParent(XSLFShapeContainer parent)`
    `void` | `setPlaceholder(Placeholder placeholder)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.poi.sl.usermodel.Shape

      `getAnchor`

- - ### Constructor Detail

    - #### XSLFShape

          protected XSLFShape(org.apache.xmlbeans.XmlObject shape,
                              XSLFSheet sheet)

  - ### Method Detail

    - #### getXmlObject

          public final org.apache.xmlbeans.XmlObject getXmlObject()

      Returns:
        the xml bean holding this shape's data

    - #### getSheet

          public XSLFSheet getSheet()

      Specified by:
        `getSheet` in interface `Shape<XSLFShape,XSLFTextParagraph>`
      Returns:
        the sheet this shape belongs to

    - #### getShapeName

          public java.lang.String getShapeName()

      Specified by:
        `getShapeName` in interface `Shape<XSLFShape,XSLFTextParagraph>`
      Returns:
        human-readable name of this shape, e.g. "Rectange 3"

    - #### getShapeId

          public int getShapeId()

      Description copied from interface: `Shape`
      Returns a unique identifier for this shape within the current slide. This ID may be used to assist in uniquely identifying this object so that it can be referred to by other parts of the document.

      If multiple objects within the same slide share the same id attribute value, then the document shall be considered non-conformant.

      Specified by:
        `getShapeId` in interface `Shape<XSLFShape,XSLFTextParagraph>`
      Returns:
        unique id of this shape

    - #### setParent

          public void setParent(XSLFShapeContainer parent)

    - #### getParent

          public XSLFShapeContainer getParent()

      Specified by:
        `getParent` in interface `Shape<XSLFShape,XSLFTextParagraph>`

    - #### getFillPaint

          protected PaintStyle getFillPaint()

    - #### getBgPr

          protected org.openxmlformats.schemas.presentationml.x2006.main.CTBackgroundProperties getBgPr()

    - #### getBgRef

          protected org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrixReference getBgRef()

    - #### getGrpSpPr

          protected org.openxmlformats.schemas.drawingml.x2006.main.CTGroupShapeProperties getGrpSpPr()

    - #### getCNvPr

          protected org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps getCNvPr()

    - #### getSpStyle

          protected org.openxmlformats.schemas.drawingml.x2006.main.CTShapeStyle getSpStyle()

    - #### getChild

          protected <T extends org.apache.xmlbeans.XmlObject> T getChild(java.lang.Class<T> childClass,
                                                                         java.lang.String namespace,
                                                                         java.lang.String nodename)

      Return direct child objects of this shape
      Parameters:
        `childClass` - the class to cast the properties to
        `namespace` - the namespace - usually it is `"http://schemas.openxmlformats.org/presentationml/2006/main"`
        `nodename` - the node name, without prefix
      Returns:
        the properties object or null if it can't be found

    - #### isPlaceholder

          public boolean isPlaceholder()

    - #### getPlaceholder

          public Placeholder getPlaceholder()

      See Also:
        `PlaceholderDetails.getPlaceholder()`

    - #### setPlaceholder

          public void setPlaceholder(Placeholder placeholder)

      See Also:
        `PlaceholderDetails.setPlaceholder(Placeholder)`

    - #### getPlaceholderDetails

          public XSLFPlaceholderDetails getPlaceholderDetails()

      See Also:
        `SimpleShape.getPlaceholderDetails()`

    - #### selectProperty

          protected <T extends org.apache.xmlbeans.XmlObject> T selectProperty(java.lang.Class<T> resultClass,
                                                                               java.lang.String xquery)

      As there's no xmlbeans hierarchy, but XSLF works with subclassing, not all child classes work with a `CTShape` object, but often contain the same properties. This method is the generalized form of selecting and casting those properties.
      Parameters:
        `resultClass` - the requested result class
        `xquery` - the simple (xmlbean) xpath expression to the property
      Returns:
        the xml object at the xpath location, or null if not found

    - #### selectProperty

          @Internal
          public <T extends org.apache.xmlbeans.XmlObject> T selectProperty(java.lang.Class<T> resultClass,
                                                                                      XSLFShape.ReparseFactory<T> factory,
                                                                                      javax.xml.namespace.QName[]... path)
                                                                               throws org.apache.xmlbeans.XmlException

      Internal code - API may change any time!

      The `selectProperty(Class, String)` xquery method has some performance penalties, which can be workaround by using `XmlCursor`. This method also takes into account that `AlternateContent` tags can occur anywhere on the given path.

      It returns the first element found - the search order is:

      - searching for a direct child
      - searching for a AlternateContent.Choice child
      - searching for a AlternateContent.Fallback child
      Currently POI OOXML is based on the first edition of the ECMA 376 schema, which doesn't allow AlternateContent tags to show up everywhere. The factory flag is a workaround to process files based on a later edition. But it comes with the drawback: any change on the returned XmlObject aren't saved back to the underlying document - so it's a non updatable clone. If factory is null, a XmlException is thrown if the AlternateContent is not allowed by the surrounding element or if the extracted object is of the generic type XmlAnyTypeImpl.
      Parameters:
        `resultClass` - the requested result class
        `factory` - a factory parse method reference to allow reparsing of elements extracted from AlternateContent elements. Usually the enclosing XmlBeans type needs to be used to parse the stream
        `path` - the elements path, each array must contain at least 1 QName, but can contain additional alternative tags
      Returns:
        the xml object at the path location, or null if not found
      Throws:
        `org.apache.xmlbeans.XmlException` - If factory is null, a XmlException is thrown if the AlternateContent is not allowed by the surrounding element or if the extracted object is of the generic type XmlAnyTypeImpl.
      Since:
        POI 4.1.2

    - #### fetchShapeProperty

          protected boolean fetchShapeProperty(PropertyFetcher<?> visitor)

      Walk up the inheritance tree and fetch shape properties.

      The following order of inheritance is assumed:

      1. slide
      2. slideLayout
      3. slideMaster
      Currently themes and their defaults aren't correctly handled
      Parameters:
        `visitor` - the object that collects the desired property
      Returns:
        true if the property was fetched

    - #### selectPaint

          protected PaintStyle selectPaint(XSLFPropertiesDelegate.XSLFFillProperties fp,
                                           org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor phClr,
                                           PackagePart parentPart,
                                           XSLFTheme theme,
                                           boolean hasPlaceholder)

      Convert shape fill into java.awt.Paint. The result is either Color or TexturePaint or GradientPaint or null
      Parameters:
        `fp` - a properties handler specific to the underlying shape properties
        `phClr` - context color
        `parentPart` - the parent package part. Any external references (images, etc.) are resolved relative to it.
        `theme` - the theme for the shape/sheet
      Returns:
        the applied Paint or null if none was applied

    - #### selectPaint

          protected PaintStyle selectPaint(org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties solidFill,
                                           org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor phClr,
                                           XSLFTheme theme)

    - #### selectPaint

          protected PaintStyle selectPaint(org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties blipFill,
                                           PackagePart parentPart,
                                           org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor phClr,
                                           XSLFTheme theme)

    - #### selectPaint

          protected PaintStyle selectPaint(org.openxmlformats.schemas.drawingml.x2006.main.CTGradientFillProperties gradFill,
                                           org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor phClr,
                                           XSLFTheme theme)

    - #### selectPaint

          protected PaintStyle selectPaint(org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrixReference fillRef,
                                           XSLFTheme theme,
                                           boolean isLineStyle,
                                           boolean hasPlaceholder)

    - #### draw

          public void draw(java.awt.Graphics2D graphics,
                           java.awt.geom.Rectangle2D bounds)

      Description copied from interface: `Shape`
      Convenience method to draw a single shape
      Specified by:
        `draw` in interface `Shape<XSLFShape,XSLFTextParagraph>`
      Parameters:
        `graphics` - the graphics context
        `bounds` - the rectangle to fit the shape to. if null, the bounds of the shape are used.

    - #### getShapeProperties

          protected org.apache.xmlbeans.XmlObject getShapeProperties()

      Return the shape specific (visual) properties
      Returns:
        the shape specific properties

Copyright 2020 The Apache Software Foundation or its licensors, as applicable.