Commit 2da15db4 authored by Carlos Garcia Campos's avatar Carlos Garcia Campos
Browse files

Do not create an OCGs object if there isn't an OCProperties dictionary in the Catalog

parent d6fb5dcb
......@@ -178,8 +178,9 @@ Catalog::Catalog(XRef *xrefA) {
catDict.dictLookup("Outlines", &outline);
// get the Optional Content dictionary
catDict.dictLookup("OCProperties", &optContentProps);
optContent = new OCGs(&optContentProps, xref);
if (catDict.dictLookup("OCProperties", &optContentProps)->isDict()) {
optContent = new OCGs(&optContentProps, xref);
}
optContentProps.free();
// perform form-related loading after all widgets have been loaded
......
......@@ -4129,6 +4129,10 @@ void Gfx::opEndIgnoreUndef(Object args[], int numArgs) {
void Gfx::opBeginMarkedContent(Object args[], int numArgs) {
// TODO: we really need to be adding this to the markedContentStack
OCGs *contentConfig = catalog->getOptContentConfig();
if (!contentConfig)
return;
char* name0 = args[0].getName();
if ( strncmp( name0, "OC", 2) == 0 ) {
if ( numArgs >= 2 ) {
......@@ -4139,7 +4143,7 @@ void Gfx::opBeginMarkedContent(Object args[], int numArgs) {
Object markedContent;
if ( res->lookupMarkedContentNF( name1, &markedContent ) ) {
if ( markedContent.isRef() ) {
bool visible = catalog->getOptContentConfig()->optContentIsVisible( &markedContent );
bool visible = contentConfig->optContentIsVisible( &markedContent );
ocSuppressed = !(visible);
}
} else {
......@@ -4168,11 +4172,17 @@ void Gfx::opBeginMarkedContent(Object args[], int numArgs) {
void Gfx::opEndMarkedContent(Object args[], int numArgs) {
// TODO: we should turn this off based on the markedContentStack
if (!catalog->getOptContentConfig())
return;
ocSuppressed = false;
out->endMarkedContent(state);
}
void Gfx::opMarkPoint(Object args[], int numArgs) {
if (!catalog->getOptContentConfig())
return;
if (printCommands) {
printf(" mark point: %s ", args[0].getName());
if (numArgs == 2)
......
......@@ -26,13 +26,6 @@
OCGs::OCGs(Object *ocgObject, XRef *xref) :
m_orderArray(0), m_rBGroupsArray(), m_xref(xref)
{
optionalContentGroups = NULL;
if (!ocgObject->isDict()) {
// This isn't an error - OCProperties is optional.
return;
}
// we need to parse the dictionary here, and build optionalContentGroups
optionalContentGroups = new GooList();
......@@ -144,17 +137,12 @@ OCGs::OCGs(Object *ocgObject, XRef *xref) :
OCGs::~OCGs()
{
if (optionalContentGroups) {
deleteGooList(optionalContentGroups, OptionalContentGroup);
}
deleteGooList(optionalContentGroups, OptionalContentGroup);
}
bool OCGs::hasOCGs()
{
if (!optionalContentGroups) {
return false;
}
return ( optionalContentGroups->getLength() > 0 );
}
......@@ -162,13 +150,10 @@ OptionalContentGroup* OCGs::findOcgByRef( const Ref &ref)
{
//TODO: make this more efficient
OptionalContentGroup *ocg = NULL;
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;
}
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;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment