Ejemplo n.º 1
0
    /**
     *
     * Assigns a hyperlink to this text shape
     *
     * @param linkId    id of the hyperlink, @see NPOI.HSLF.usermodel.SlideShow#AddHyperlink(Hyperlink)
     * @param      beginIndex   the beginning index, inclusive.
     * @param      endIndex     the ending index, exclusive.
     * @see NPOI.HSLF.usermodel.SlideShow#AddHyperlink(Hyperlink)
     */
    public void SetHyperlink(int linkId, int beginIndex, int endIndex){
        //TODO validate beginIndex and endIndex and throw ArgumentException

        InteractiveInfo info = new InteractiveInfo();
        InteractiveInfoAtom infoAtom = info.GetInteractiveInfoAtom();
        infoAtom.SetAction(InteractiveInfoAtom.ACTION_HYPERLINK);
        infoAtom.SetHyperlinkType(InteractiveInfoAtom.LINK_Url);
        infoAtom.SetHyperlinkID(linkId);

        _txtbox.AppendChildRecord(info);

        TxInteractiveInfoAtom txiatom = new TxInteractiveInfoAtom();
        txiatom.SetStartIndex(beginIndex);
        txiatom.SetEndIndex(endIndex);
        _txtbox.AppendChildRecord(txiatom);

    }
Ejemplo n.º 2
0
        public void SetHyperlink(Hyperlink link)
        {
            if (link.GetId() == -1)
            {
                throw new HSLFException("You must call SlideShow.AddHyperlink(Hyperlink link) first");
            }

            EscherClientDataRecord cldata = new EscherClientDataRecord();

            cldata.SetOptions((short)0xF);
            GetSpContainer().AddChildRecord(cldata); // TODO - junit to prove GetChildRecords().add is wrong

            InteractiveInfo     info     = new InteractiveInfo();
            InteractiveInfoAtom infoAtom = info.GetInteractiveInfoAtom();

            switch (link.GetType())
            {
            case Hyperlink.LINK_FIRSTSLIDE:
                infoAtom.SetAction(InteractiveInfoAtom.ACTION_JUMP);
                infoAtom.SetJump(InteractiveInfoAtom.JUMP_FIRSTSLIDE);
                infoAtom.SetHyperlinkType(InteractiveInfoAtom.LINK_FirstSlide);
                break;

            case Hyperlink.LINK_LASTSLIDE:
                infoAtom.SetAction(InteractiveInfoAtom.ACTION_JUMP);
                infoAtom.SetJump(InteractiveInfoAtom.JUMP_LASTSLIDE);
                infoAtom.SetHyperlinkType(InteractiveInfoAtom.LINK_LastSlide);
                break;

            case Hyperlink.LINK_NEXTSLIDE:
                infoAtom.SetAction(InteractiveInfoAtom.ACTION_JUMP);
                infoAtom.SetJump(InteractiveInfoAtom.JUMP_NEXTSLIDE);
                infoAtom.SetHyperlinkType(InteractiveInfoAtom.LINK_NextSlide);
                break;

            case Hyperlink.LINK_PREVIOUSSLIDE:
                infoAtom.SetAction(InteractiveInfoAtom.ACTION_JUMP);
                infoAtom.SetJump(InteractiveInfoAtom.JUMP_PREVIOUSSLIDE);
                infoAtom.SetHyperlinkType(InteractiveInfoAtom.LINK_PreviousSlide);
                break;

            case Hyperlink.LINK_URL:
                infoAtom.SetAction(InteractiveInfoAtom.ACTION_HYPERLINK);
                infoAtom.SetJump(InteractiveInfoAtom.JUMP_NONE);
                infoAtom.SetHyperlinkType(InteractiveInfoAtom.LINK_Url);
                break;
            }

            infoAtom.SetHyperlinkID(link.GetId());

            MemoryStream out1 = new MemoryStream();

            try
            {
                info.WriteOut(out1);
            }
            catch (Exception e)
            {
                throw new HSLFException(e);
            }
            cldata.SetRemainingData(out1.ToArray());
        }
Ejemplo n.º 3
0
    /**
     * Create a new Placeholder and Initialize internal structures
     *
     * @return the Created <code>EscherContainerRecord</code> which holds shape data
     */
    protected EscherContainerRecord CreateSpContainer(int idx, bool IsChild) {
        _escherContainer = super.CreateSpContainer(idx, isChild);

        SetEscherProperty(EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 0x1000100);
        SetEscherProperty(EscherProperties.FILL__NOFILLHITTEST, 0x10001);

        EscherClientDataRecord cldata = new EscherClientDataRecord();
        cldata.SetOptions((short)0xF);
        _escherContainer.AddChildRecord(cldata);

        OEShapeAtom oe = new OEShapeAtom();
        InteractiveInfo info = new InteractiveInfo();
        InteractiveInfoAtom infoAtom = info.GetInteractiveInfoAtom();
        infoAtom.SetAction(InteractiveInfoAtom.ACTION_MEDIA);
        infoAtom.SetHyperlinkType(InteractiveInfoAtom.LINK_NULL);

        AnimationInfo an = new AnimationInfo();
        AnimationInfoAtom anAtom = an.GetAnimationInfoAtom();
        anAtom.SetFlag(AnimationInfoAtom.Automatic, true);

        //convert hslf into ddf
        MemoryStream out = new MemoryStream();
        try {
            oe.WriteOut(out);
            an.WriteOut(out);
            info.WriteOut(out);
        } catch(Exception e){
            throw new HSLFException(e);
        }
        cldata.SetRemainingData(out.ToArray());

        return _escherContainer;
    }
Ejemplo n.º 4
0
        public void SetHyperlink(Hyperlink link)
        {
            if (link.GetId() == -1)
            {
                throw new HSLFException("You must call SlideShow.AddHyperlink(Hyperlink link) first");
            }

            EscherClientDataRecord cldata = new EscherClientDataRecord();
            cldata.SetOptions((short)0xF);
            GetSpContainer().AddChildRecord(cldata); // TODO - junit to prove GetChildRecords().add is wrong

            InteractiveInfo info = new InteractiveInfo();
            InteractiveInfoAtom infoAtom = info.GetInteractiveInfoAtom();

            switch (link.GetType())
            {
                case Hyperlink.LINK_FIRSTSLIDE:
                    infoAtom.SetAction(InteractiveInfoAtom.ACTION_JUMP);
                    infoAtom.SetJump(InteractiveInfoAtom.JUMP_FIRSTSLIDE);
                    infoAtom.SetHyperlinkType(InteractiveInfoAtom.LINK_FirstSlide);
                    break;
                case Hyperlink.LINK_LASTSLIDE:
                    infoAtom.SetAction(InteractiveInfoAtom.ACTION_JUMP);
                    infoAtom.SetJump(InteractiveInfoAtom.JUMP_LASTSLIDE);
                    infoAtom.SetHyperlinkType(InteractiveInfoAtom.LINK_LastSlide);
                    break;
                case Hyperlink.LINK_NEXTSLIDE:
                    infoAtom.SetAction(InteractiveInfoAtom.ACTION_JUMP);
                    infoAtom.SetJump(InteractiveInfoAtom.JUMP_NEXTSLIDE);
                    infoAtom.SetHyperlinkType(InteractiveInfoAtom.LINK_NextSlide);
                    break;
                case Hyperlink.LINK_PREVIOUSSLIDE:
                    infoAtom.SetAction(InteractiveInfoAtom.ACTION_JUMP);
                    infoAtom.SetJump(InteractiveInfoAtom.JUMP_PREVIOUSSLIDE);
                    infoAtom.SetHyperlinkType(InteractiveInfoAtom.LINK_PreviousSlide);
                    break;
                case Hyperlink.LINK_URL:
                    infoAtom.SetAction(InteractiveInfoAtom.ACTION_HYPERLINK);
                    infoAtom.SetJump(InteractiveInfoAtom.JUMP_NONE);
                    infoAtom.SetHyperlinkType(InteractiveInfoAtom.LINK_Url);
                    break;
            }

            infoAtom.SetHyperlinkID(link.GetId());

            MemoryStream out1 = new MemoryStream();
            try
            {
                info.WriteOut(out1);
            }
            catch (Exception e)
            {
                throw new HSLFException(e);
            }
            cldata.SetRemainingData(out1.ToArray());

        }