You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "John Hewson (JIRA)" <ji...@apache.org> on 2014/10/11 03:26:34 UTC

[jira] [Updated] (PDFBOX-1209) Add insertSiblingBefore() to PDOutlineItem

     [ https://issues.apache.org/jira/browse/PDFBOX-1209?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

John Hewson updated PDFBOX-1209:
--------------------------------
    Affects Version/s: 2.0.0

> Add insertSiblingBefore() to PDOutlineItem
> ------------------------------------------
>
>                 Key: PDFBOX-1209
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1209
>             Project: PDFBox
>          Issue Type: New Feature
>          Components: PDModel
>    Affects Versions: 1.6.0, 2.0.0
>            Reporter: Gilad Denneboom
>            Priority: Minor
>              Labels: bookmarks
>             Fix For: 2.0.0
>
>
> At the moment it's not possible to insert a first child to a pre-existing PDDocumentOutline because all the available methods only allow you to add a PDOutlineItem at the end of the list (PDDocumentOutline.appendChild()) or after an existing child (PDOutlineItem.insertSiblingAfter()). As a result, if you wish to insert a new first child, you have to manually traverse and re-create the entire tree, which is ridiculous.
> As a solution, I offer to add a new method to the PDOutlineItem class, insertSiblingBefore(). I've written the code necessary based on insertSiblingAfter(). It's very straight-forward...
>  /**
>      * Insert a sibling before this node.
>      *
>      * @param item The item to insert.
>      */
>     public void insertSiblingBefore( PDOutlineItem item )
>     {
>         item.setParent( getParent() );
>         PDOutlineItem previous = getPreviousSibling();
>         setPreviousSibling( item );
>         item.setNextSibling( this );
>         if( previous != null )
>         {
>             item.setPreviousSibling( previous );
>             previous.setNextSibling( item );
>         }
>         updateParentOpenCount( 1 );
>     }
> I hope this can be integrated in the next release...



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)