You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2018/09/28 18:28:59 UTC
svn commit: r1842278 -
/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageNode.java
Author: tilman
Date: Fri Sep 28 18:28:59 2018
New Revision: 1842278
URL: http://svn.apache.org/viewvc?rev=1842278&view=rev
Log:
PDFBOX-4071: improve skip duplicates
Modified:
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageNode.java
Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageNode.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageNode.java?rev=1842278&r1=1842277&r2=1842278&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageNode.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageNode.java Fri Sep 28 18:28:59 2018
@@ -33,6 +33,7 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
/**
* This represents a page node in a pdf document.
@@ -171,7 +172,7 @@ public class PDPageNode implements COSOb
public List getKids()
{
List actuals = new ArrayList();
- COSArray kids = getAllKids(actuals, page, false);
+ COSArray kids = getAllKids(actuals, page, false, new HashSet<COSBase>());
return new COSArrayList( actuals, kids );
}
@@ -182,7 +183,7 @@ public class PDPageNode implements COSOb
*/
public void getAllKids(List result)
{
- getAllKids(result, page, true);
+ getAllKids(result, page, true, new HashSet<COSBase>());
}
/**
@@ -191,8 +192,9 @@ public class PDPageNode implements COSOb
* @param result All direct and optionally indirect descendents of this node are added to this list.
* @param page Page dictionary of a page node.
* @param recurse if true indirect descendents are processed recursively
+ * @param seen set of objects that have been added
*/
- private static COSArray getAllKids(List result, COSDictionary page, boolean recurse)
+ private static COSArray getAllKids(List result, COSDictionary page, boolean recurse, Set<COSBase> seen)
{
if(page == null)
return null;
@@ -202,7 +204,6 @@ public class PDPageNode implements COSOb
log.error("No Kids found in getAllKids(). Probably a malformed pdf.");
return null;
}
- HashSet<COSBase> seen = new HashSet<COSBase>();
for( int i=0; i<kids.size(); i++ )
{
// ignore duplicates (from malformed PDFs)
@@ -220,7 +221,7 @@ public class PDPageNode implements COSOb
{
if (recurse)
{
- getAllKids(result, kid, recurse);
+ getAllKids(result, kid, recurse, seen);
}
else
{