Search in sources :

Example 1 with ShapeSheetType

use of com.microsoft.schemas.office.visio.x2012.main.ShapeSheetType in project poi by apache.

the class XDGFShape method setupMaster.

/**
     * Setup top level shapes
     *
     * Shapes that have a 'Master' attribute refer to a specific master in the
     * page, whereas shapes with a 'MasterShape' attribute refer to a subshape
     * of a Master.
     */
protected void setupMaster(XDGFPageContents pageContents, XDGFMasterContents master) {
    ShapeSheetType obj = getXmlObject();
    if (obj.isSetMaster()) {
        _master = pageContents.getMasterById(obj.getMaster());
        if (_master == null)
            throw XDGFException.error("refers to non-existant master " + obj.getMaster(), this);
        /*
             * If a master has one top-level shape, a shape that inherits from
             * that master inherits the descendant elements of that master
             * shape. If a master has more than one master shape, a shape that
             * inherits from that master inherits those master shapes as
             * subshapes.
             */
        Collection<XDGFShape> masterShapes = _master.getContent().getTopLevelShapes();
        switch(masterShapes.size()) {
            case 0:
                throw XDGFException.error("Could not retrieve master shape from " + _master, this);
            case 1:
                _masterShape = masterShapes.iterator().next();
                break;
            default:
                break;
        }
    } else if (obj.isSetMasterShape()) {
        _masterShape = master.getShapeById(obj.getMasterShape());
        if (_masterShape == null)
            throw XDGFException.error("refers to non-existant master shape " + obj.getMasterShape(), this);
    }
    setupSectionMasters();
    if (_shapes != null) {
        for (XDGFShape shape : _shapes) {
            shape.setupMaster(pageContents, _master == null ? master : _master.getContent());
        }
    }
}
Also used : ShapeSheetType(com.microsoft.schemas.office.visio.x2012.main.ShapeSheetType)

Example 2 with ShapeSheetType

use of com.microsoft.schemas.office.visio.x2012.main.ShapeSheetType in project poi by apache.

the class XDGFBaseContents method onDocumentRead.

@Override
protected void onDocumentRead() {
    if (_pageContents.isSetShapes()) {
        for (ShapeSheetType shapeSheet : _pageContents.getShapes().getShapeArray()) {
            XDGFShape shape = new XDGFShape(shapeSheet, this, _document);
            _toplevelShapes.add(shape);
            addToShapeIndex(shape);
        }
    }
    if (_pageContents.isSetConnects()) {
        for (ConnectType connect : _pageContents.getConnects().getConnectArray()) {
            XDGFShape from = _shapes.get(connect.getFromSheet());
            XDGFShape to = _shapes.get(connect.getToSheet());
            if (from == null)
                throw new POIXMLException(this + "; Connect; Invalid from id: " + connect.getFromSheet());
            if (to == null)
                throw new POIXMLException(this + "; Connect; Invalid to id: " + connect.getToSheet());
            _connections.add(new XDGFConnection(connect, from, to));
        }
    }
}
Also used : ShapeSheetType(com.microsoft.schemas.office.visio.x2012.main.ShapeSheetType) POIXMLException(org.apache.poi.POIXMLException) ConnectType(com.microsoft.schemas.office.visio.x2012.main.ConnectType)

Aggregations

ShapeSheetType (com.microsoft.schemas.office.visio.x2012.main.ShapeSheetType)2 ConnectType (com.microsoft.schemas.office.visio.x2012.main.ConnectType)1 POIXMLException (org.apache.poi.POIXMLException)1