XAccessibleComponent

From Apache OpenOffice Wiki
< Documentation‎ | DevGuide
Revision as of 17:55, 21 December 2020 by DiGro (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search



The XAccessibleComponent interface gives access to geometric properties, such as size and position on the screen. This interface should be implemented by every object that has a visible representation, that is, by all objects that are not simple containers.

The coordinates used by the functions of this interface are returned and and are expected in pixel values and not, as is elsewhere in the UDK, in internal coordinates (100th of mm). There are three different origins to which coordinates may be specified:

Because all three coordinate systems are based on pixel values, the getSize() function is independent of the coordinate system.

The bounding rectangle that encloses the visual presentation of an object can be retrieved by calling getBounds(). If you only need the location or the size, then call getLocation() or getSize(). The function getLocationOnScreen() returns the absolute screen coordinates.

There or two functions that determine whether the bounding boxes of the object or one of its children contain a given test point. The function containsPoint() checks whether the test point lies within the bounding box of the object. Children can be tested with getAccessibleAtPoint(). When one of the direct children contains the test point, a reference to this object is returned.

In addition to the geometrical functions, there are the two getForeground() and getBackground() functions that describe an object's appearance. Keep in mind that an object does not necessarily have a monochrome background color. There can be a hatching, gradient, or bitmap as well. The returned background color in this case is an approximation.

Geometrical information in the SSR

The showComponentInfo() method of the TextualDisplay class takes as argument a reference to the accessible object for which geometrical information is shown, as well as the indentation string computed in the showParents() method.

  private void showComponentInfo (XAccessibleContext xContext, String sIndentation) {

When given an XAccessibleContext reference, you must cast it to a XAccessibleComponent reference in order to access geometrical information about an accessible object.

      XAccessibleComponent xComponent = (XAccessibleComponent)UnoRuntime.queryInterface(
          XAccessibleComponent.class, xContext);
      if (xComponent != null) {

If the cast was successful, then simply call the getLocationOnScreen() and getSize() methods to obtain the object's bounding box in screen coordinates. If getBounds() is called instead, the parent's screen coordinates must be added to obtain an absolute position.

          Point aLocation = xComponent.getLocationOnScreen();
          msTextContent += sIndentation + "Position : " 
                + aLocation.X + ", " + aLocation.Y + "\n";
 
          Size aSize = xComponent.getSize();
          msTextContent += sIndentation + "Size : " 
                + aSize.Width + ", " + aSize.Height + "\n";
      }
  }
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages