Skip to content

Commit 1e3c8ad

Browse files
committed
PDFBOX-6076: avoid ClassCastexception, use ON as default
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1928739 13f79535-47bb-0310-9956-ffa450edef68
1 parent 609981b commit 1e3c8ad

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/optionalcontent/PDOptionalContentProperties.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ public COSDictionary getCOSObject()
112112
return this.dict;
113113
}
114114

115+
/**
116+
* Return the /OCGs array.
117+
*
118+
* @return /OCGs array, never null.
119+
*/
115120
private COSArray getOCGs()
116121
{
117122
COSArray ocgs = this.dict.getCOSArray(COSName.OCGS);
@@ -123,6 +128,11 @@ private COSArray getOCGs()
123128
return ocgs;
124129
}
125130

131+
/**
132+
* Return the the /D dictionary.
133+
*
134+
* @return the /D dictionary, never null.
135+
*/
126136
private COSDictionary getD()
127137
{
128138
COSDictionary d = dict.getCOSDictionary(COSName.D);
@@ -202,12 +212,12 @@ public Collection<PDOptionalContentGroup> getOptionalContentGroups()
202212

203213
/**
204214
* Returns the base state for optional content groups.
205-
* @return the base state
215+
* @return the base state, never null.
206216
*/
207217
public BaseState getBaseState()
208218
{
209219
COSDictionary d = getD();
210-
COSName name = (COSName)d.getItem(COSName.BASE_STATE);
220+
COSName name = d.getCOSName(COSName.BASE_STATE, COSName.ON);
211221
return BaseState.valueOf(name);
212222
}
213223

0 commit comments

Comments
 (0)