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 2017/09/09 10:44:26 UTC
svn commit: r1807879 -
/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotation.java
Author: tilman
Date: Sat Sep 9 10:44:25 2017
New Revision: 1807879
URL: http://svn.apache.org/viewvc?rev=1807879&view=rev
Log:
PDFBOX-2852: add comment, avoid ClassClastException, simplify code
Modified:
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotation.java
Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotation.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotation.java?rev=1807879&r1=1807878&r2=1807879&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotation.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotation.java Sat Sep 9 10:44:25 2017
@@ -137,6 +137,7 @@ public abstract class PDAnnotation imple
|| PDAnnotationTextMarkup.SUB_TYPE_SQUIGGLY.equals(subtype)
|| PDAnnotationTextMarkup.SUB_TYPE_STRIKEOUT.equals(subtype))
{
+ // see 12.5.6.10 Text Markup Annotations
annot = new PDAnnotationTextMarkup(annotDic);
}
else if (PDAnnotationLink.SUB_TYPE.equals(subtype))
@@ -267,12 +268,7 @@ public abstract class PDAnnotation imple
*/
public COSName getAppearanceState()
{
- COSName name = (COSName) getCOSObject().getDictionaryObject(COSName.AS);
- if (name != null)
- {
- return name;
- }
- return null;
+ return getCOSObject().getCOSName(COSName.AS);
}
/**
@@ -282,14 +278,7 @@ public abstract class PDAnnotation imple
*/
public void setAppearanceState(String as)
{
- if (as == null)
- {
- getCOSObject().removeItem(COSName.AS);
- }
- else
- {
- getCOSObject().setItem(COSName.AS, COSName.getPDFName(as));
- }
+ getCOSObject().setName(COSName.AS, as);
}
/**
@@ -299,10 +288,10 @@ public abstract class PDAnnotation imple
*/
public PDAppearanceDictionary getAppearance()
{
- COSDictionary apDic = (COSDictionary) dictionary.getDictionaryObject(COSName.AP);
- if (apDic != null)
+ COSBase base = dictionary.getDictionaryObject(COSName.AP);
+ if (base instanceof COSDictionary)
{
- return new PDAppearanceDictionary(apDic);
+ return new PDAppearanceDictionary((COSDictionary) base);
}
return null;
}
@@ -314,12 +303,7 @@ public abstract class PDAnnotation imple
*/
public void setAppearance(PDAppearanceDictionary appearance)
{
- COSDictionary ap = null;
- if (appearance != null)
- {
- ap = appearance.getCOSObject();
- }
- dictionary.setItem(COSName.AP, ap);
+ dictionary.setItem(COSName.AP, appearance);
}
/**
@@ -785,10 +769,10 @@ public abstract class PDAnnotation imple
*/
public PDPage getPage()
{
- COSDictionary p = (COSDictionary) this.getCOSObject().getDictionaryObject(COSName.P);
- if (p != null)
+ COSBase base = this.getCOSObject().getDictionaryObject(COSName.P);
+ if (base instanceof COSDictionary)
{
- return new PDPage(p);
+ return new PDPage((COSDictionary) base);
}
return null;
}