pkgsrc/print/poppler/patches/patch-ai
2008-05-15 17:51:29 +00:00

89 lines
3.1 KiB
Text

$NetBSD: patch-ai,v 1.3 2008/05/15 17:51:29 drochner Exp $
--- poppler/OptionalContent.cc.orig 2008-03-26 20:38:52.000000000 +0100
+++ poppler/OptionalContent.cc
@@ -162,12 +162,18 @@ OptionalContentGroup* OCGs::findOcgByRef
{
//TODO: make this more efficient
OptionalContentGroup *ocg = NULL;
- for (int i=0; i < optionalContentGroups->getLength(); ++i) {
- ocg = (OptionalContentGroup*)optionalContentGroups->get(i);
- if ( (ocg->ref().num == ref.num) && (ocg->ref().gen == ref.gen) ) {
- return ocg;
+ if (optionalContentGroups != NULL)
+ {
+ for (int i=0; i < optionalContentGroups->getLength(); ++i) {
+ ocg = (OptionalContentGroup*)optionalContentGroups->get(i);
+ if ( (ocg->ref().num == ref.num) && (ocg->ref().gen == ref.gen) ) {
+ return ocg;
+ }
}
}
+
+ error(-1, "Could not find a OCG with Ref (%d:%d)", ref.num, ref.gen);
+
// not found
return NULL;
}
@@ -208,7 +214,7 @@ bool OCGs::optContentIsVisible( Object *
}
} else if (ocg.isRef()) {
OptionalContentGroup* oc = findOcgByRef( ocg.getRef() );
- if ( oc->state() == OptionalContentGroup::Off ) {
+ if ( !oc || oc->state() == OptionalContentGroup::Off ) {
result = false;
} else {
result = true ;
@@ -218,13 +224,10 @@ bool OCGs::optContentIsVisible( Object *
policy.free();
} else if ( dictType.isName("OCG") ) {
OptionalContentGroup* oc = findOcgByRef( dictRef->getRef() );
- if ( oc ) {
-// printf("Found valid group object\n");
- if ( oc->state() == OptionalContentGroup::Off ) {
- result=false;
- }
+ if ( !oc || oc->state() == OptionalContentGroup::Off ) {
+ result=false;
}
- }
+ }
dictType.free();
dictObj.free();
// printf("visibility: %s\n", result? "on" : "off");
@@ -238,7 +241,7 @@ bool OCGs::allOn( Array *ocgArray )
ocgArray->getNF(i, &ocgItem);
if (ocgItem.isRef()) {
OptionalContentGroup* oc = findOcgByRef( ocgItem.getRef() );
- if ( oc->state() == OptionalContentGroup::Off ) {
+ if ( oc && oc->state() == OptionalContentGroup::Off ) {
return false;
}
}
@@ -253,7 +256,7 @@ bool OCGs::allOff( Array *ocgArray )
ocgArray->getNF(i, &ocgItem);
if (ocgItem.isRef()) {
OptionalContentGroup* oc = findOcgByRef( ocgItem.getRef() );
- if ( oc->state() == OptionalContentGroup::On ) {
+ if ( oc && oc->state() == OptionalContentGroup::On ) {
return false;
}
}
@@ -268,7 +271,7 @@ bool OCGs::anyOn( Array *ocgArray )
ocgArray->getNF(i, &ocgItem);
if (ocgItem.isRef()) {
OptionalContentGroup* oc = findOcgByRef( ocgItem.getRef() );
- if ( oc->state() == OptionalContentGroup::On ) {
+ if ( oc && oc->state() == OptionalContentGroup::On ) {
return true;
}
}
@@ -283,7 +286,7 @@ bool OCGs::anyOff( Array *ocgArray )
ocgArray->getNF(i, &ocgItem);
if (ocgItem.isRef()) {
OptionalContentGroup* oc = findOcgByRef( ocgItem.getRef() );
- if ( oc->state() == OptionalContentGroup::Off ) {
+ if ( oc && oc->state() == OptionalContentGroup::Off ) {
return true;
}
}