[
https://issues.apache.org/jira/browse/PDFBOX-1209?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Gilad Denneboom updated PDFBOX-1209:
------------------------------------
Description:
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...
was:
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.insertAfterSibling()). 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...
> 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
> Reporter: Gilad Denneboom
> Priority: Minor
> Labels: bookmarks
>
> 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 is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira