Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@926522 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Johannes Koch committed Mar 23, 2010
1 parent d3a5031 commit c619ecc
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@
import org.apache.pdfbox.cos.COSName;
import org.apache.pdfbox.cos.COSObject;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.common.COSObjectable;
import org.apache.pdfbox.pdmodel.documentinterchange.markedcontent.PDMarkedContent;

/**
* A structure element.
*
* @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
* @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>,
* <a href="mailto:Johannes%20Koch%20%3Ckoch@apache.org%3E">Johannes Koch</a>
* @version $Revision: 1.3 $
*/
public class PDStructureElement extends PDStructureNode
Expand Down Expand Up @@ -202,6 +204,10 @@ else if (item instanceof COSInteger)
*/
public void setClassNames(Revisions<String> classNames)
{
if (classNames == null)
{
return;
}
COSName key = COSName.C;
if ((classNames.size() == 1) && (classNames.getRevisionNumber(0) == 0))
{
Expand Down Expand Up @@ -231,6 +237,10 @@ public void setClassNames(Revisions<String> classNames)
*/
public void addClassName(String className)
{
if (className == null)
{
return;
}
COSName key = COSName.C;
COSBase c = this.getCOSDictionary().getDictionaryObject(key);
COSArray array = null;
Expand Down Expand Up @@ -259,6 +269,10 @@ public void addClassName(String className)
*/
public void removeClassName(String className)
{
if (className == null)
{
return;
}
COSName key = COSName.C;
COSBase c = this.getCOSDictionary().getDictionaryObject(key);
COSName name = COSName.getPDFName(className);
Expand Down Expand Up @@ -302,9 +316,21 @@ public int getRevisionNumber()
*/
public void setRevisionNumber(int revisionNumber)
{
if (revisionNumber < 0)
{
// TODO throw Exception because revision number must be > -1?
}
this.getCOSDictionary().setInt(COSName.R, revisionNumber);
}

/**
* Increments th revision number
*/
public void incrementRevisionNumber()
{
this.setRevisionNumber(this.getRevisionNumber() + 1);
}

/**
* Returns the title (T).
*
Expand Down Expand Up @@ -434,6 +460,10 @@ public String getStandardStructureType()
*/
public void appendKid(PDMarkedContent markedContent)
{
if (markedContent == null)
{
return;
}
this.appendKid(COSInteger.get(markedContent.getMCID()));
}

Expand Down Expand Up @@ -465,7 +495,7 @@ public void appendKid(PDObjectReference objectReference)
*/
public void insertBefore(COSInteger markedContentIdentifier, Object refKid)
{
this.insertBefore(markedContentIdentifier, refKid);
this.insertBefore((COSBase) markedContentIdentifier, refKid);
}

/**
Expand All @@ -474,9 +504,10 @@ public void insertBefore(COSInteger markedContentIdentifier, Object refKid)
* @param markedContentReference the marked-content reference
* @param refKid the reference kid
*/
public void insertBefore(PDMarkedContentReference markedContentReference, Object refKid)
public void insertBefore(PDMarkedContentReference markedContentReference,
Object refKid)
{
this.insertBefore(markedContentReference, refKid);
this.insertObjectableBefore(markedContentReference, refKid);
}

/**
Expand All @@ -487,7 +518,7 @@ public void insertBefore(PDMarkedContentReference markedContentReference, Object
*/
public void insertBefore(PDObjectReference objectReference, Object refKid)
{
this.insertBefore(objectReference, refKid);
this.insertObjectableBefore(objectReference, refKid);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ else if (k instanceof COSArray)
*/
public void insertBefore(PDStructureElement newKid, Object refKid)
{
this.insertBefore((COSObjectable) newKid, refKid);
this.insertObjectableBefore(newKid, refKid);
}

/**
Expand All @@ -227,7 +227,7 @@ public void insertBefore(PDStructureElement newKid, Object refKid)
* @param newKid the objectable
* @param refKid the reference kid
*/
protected void insertBefore(COSObjectable newKid, Object refKid)
protected void insertObjectableBefore(COSObjectable newKid, Object refKid)
{
if (newKid == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
/**
* A root of a structure tree.
*
* @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
* @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>,
* <a href="mailto:Johannes%20Koch%20%3Ckoch@apache.org%3E">Johannes Koch</a>
* @version $Revision: 1.2 $
*/
public class PDStructureTreeRoot extends PDStructureNode
Expand Down

0 comments on commit c619ecc

Please sign in to comment.