[
https://issues.apache.org/jira/browse/PDFBOX-4496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16803319#comment-16803319
]
Tilman Hausherr edited comment on PDFBOX-4496 at 3/27/19 8:20 PM:
------------------------------------------------------------------
But the current code is
{code:java}
public boolean setGroupEnabled(String groupName, boolean enable)
{
return setGroupEnabled(getGroup(groupName), enable);
}{code}
And your patch removes a lot of lines that aren't there:
{code}
public boolean setGroupEnabled(String groupName, boolean enable)
{
- boolean result = false;
- COSArray ocgs = getOCGs();
- for (COSBase o : ocgs)
- {
- COSDictionary ocg = toDictionary(o);
- String name = ocg.getString(COSName.NAME);
- if (groupName.equals(name))
- {
- setGroupEnabled(new PDOptionalContentGroup(ocg), enable);
- }
- }
- return result;
+ return setGroupEnabled(getGroup(groupName), enable);
}
{code}
was (Author: tilman):
But the current code is
{code:java}
public boolean setGroupEnabled(String groupName, boolean enable)
{
return setGroupEnabled(getGroup(groupName), enable);
}{code}
And your patch removes a lot of lines that aren't there:
{code}
public boolean isGroupEnabled(String groupName)
{
- Boolean result = null;
- COSArray ocgs = getOCGs();
- for (COSBase o : ocgs)
- {
- COSDictionary ocg = toDictionary(o);
- String name = ocg.getString(COSName.NAME);
- if (groupName.equals(name))
- {
- boolean enabled = isGroupEnabled(new
PDOptionalContentGroup(ocg));
- if (result == null)
- {
- result = Boolean.valueOf(enabled);
- }
- else if (enabled != result.booleanValue())
- {
- // dont know what to do ?!?
- }
-
- }
- }
- return result == null ? false : result.booleanValue();
+ return isGroupEnabled(getGroup(groupName));
}
{code}
> OCG enablement with string parameter is not well defined
> --------------------------------------------------------
>
> Key: PDFBOX-4496
> URL: https://issues.apache.org/jira/browse/PDFBOX-4496
> Project: PDFBox
> Issue Type: Bug
> Affects Versions: 2.0.14
> Reporter: Stefan Ziel
> Priority: Major
> Labels: OCGs
> Attachments: PDFBOX-4496.patch, original.pdf
>
>
> The class {noformat}
> org.apache.pdfbox.pdmodel.graphics.optionalcontent.PDOptionalContentProperties
> {noformat}
> contains two methods
> {noformat} setGroupEnabled(String, boolean){noformat} and {noformat}
> isGroupEnabled(String){noformat}
> accessing the OCG's state using a name as parameter.
> As there can exist various OCG with the same name this access is not well
> defined.
> The current implementation accesses the first group with this name it can
> find.
> To make the setter work a solution would be a loop over all groups with the
> given name and add them to ON or OFF. Consider to rename it to
> {noformat}setGroupsEnabledByName{noformat}
> The getter should return some error state if the groups diverge in state - or
> better drop it ...
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]