You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Tilman Hausherr (JIRA)" <ji...@apache.org> on 2015/02/05 12:54:34 UTC

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

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

Tilman Hausherr reassigned PDFBOX-1209:
---------------------------------------

    Assignee: Tilman Hausherr

> 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
>            Assignee: Tilman Hausherr
>            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...
> {code}
>  /**
>      * 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 );
>     }
> {code}
> I hope this can be integrated in the next release...



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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org