示例#1
0
    /**
     * Find hyperlink assigned to the supplied shape
     *
     * @param shape  <code>Shape</code> to lookup hyperlink in
     * @return found hyperlink or <code>null</code>
     */
    protected static Hyperlink Find(Shape shape){
        ArrayList lst = new ArrayList();
        SlideShow ppt = shape.Sheet.GetSlideShow();
        //document-level Container which stores info about all links in a presentation
        ExObjList exobj = ppt.GetDocumentRecord().GetExObjList();
        if (exobj == null) {
            return null;
        }

        EscherContainerRecord spContainer = shape.GetSpContainer();
        for (Iterator<EscherRecord> it = spContainer.GetChildIterator(); it.HasNext(); ) {
            EscherRecord obj = it.next();
            if (obj.GetRecordId() ==  EscherClientDataRecord.RECORD_ID){
                byte[] data = obj.Serialize();
                Record[] records = Record.FindChildRecords(data, 8, data.Length-8);
                if(records != null) Find(records, exobj, lst);
            }
        }

        return lst.Count == 1 ? (Hyperlink)lst.Get(0) : null;
    }
示例#2
0
文件: Sheet.cs 项目: ctddjyds/npoi
    /**
     * Add a new Shape to this Slide
     *
     * @param shape - the Shape to add
     */
    public void AddShape(Shape shape) {
        PPDrawing ppdrawing = GetPPDrawing();

        EscherContainerRecord dgContainer = (EscherContainerRecord) ppdrawing.GetEscherRecords()[0];
        EscherContainerRecord spgr = (EscherContainerRecord) Shape.GetEscherChild(dgContainer, EscherContainerRecord.SPGR_CONTAINER);
        spgr.AddChildRecord(shape.GetSpContainer());

        shape.SetSheet(this);
        shape.SetShapeId(allocateShapeId());
        shape.afterInsert(this);
    }
示例#3
0
文件: Sheet.cs 项目: ctddjyds/npoi
    /**
     * Removes the specified shape from this sheet.
     *
     * @param shape shape to be Removed from this sheet, if present.
     * @return <tt>true</tt> if the shape was deleted.
     */
    public bool RemoveShape(Shape shape) {
        PPDrawing ppdrawing = GetPPDrawing();

        EscherContainerRecord dg = (EscherContainerRecord) ppdrawing.GetEscherRecords()[0];
        EscherContainerRecord spgr = null;

        for (Iterator<EscherRecord> it = dg.GetChildIterator(); it.HasNext();) {
            EscherRecord rec = it.next();
            if (rec.GetRecordId() == EscherContainerRecord.SPGR_CONTAINER) {
                spgr = (EscherContainerRecord) rec;
                break;
            }
        }
        if(spgr == null) {
            return false;
        }

        List<EscherRecord> lst = spgr.GetChildRecords();
        bool result = lst.Remove(shape.GetSpContainer());
        spgr.SetChildRecords(lst);
        return result;
    }
示例#4
0
    /**
     * Add a shape to this group.
     *
     * @param shape - the Shape to add
     */
    public void AddShape(Shape shape){
        _escherContainer.AddChildRecord(shape.GetSpContainer());

        Sheet sheet = Sheet;
        shape.SetSheet(sheet);
        shape.SetShapeId(sheet.allocateShapeId());
        shape.afterInsert(sheet);
    }