[poppler] poppler/Catalog.cc poppler/Gfx.cc poppler/OptionalContent.cc
Carlos Garcia Campos
carlosgc at kemper.freedesktop.org
Mon Jun 23 06:03:42 PDT 2008
poppler/Catalog.cc | 5 +++--
poppler/Gfx.cc | 12 +++++++++++-
poppler/OptionalContent.cc | 25 +++++--------------------
3 files changed, 19 insertions(+), 23 deletions(-)
New commits:
commit 2da15db4751d3cb93d40b48e348dbc51f6e7a29f
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date: Fri Jun 20 11:39:08 2008 +0200
Do not create an OCGs object if there isn't an OCProperties dictionary in the Catalog
diff --git a/poppler/Catalog.cc b/poppler/Catalog.cc
index 7fc1cbe..69480c0 100644
--- a/poppler/Catalog.cc
+++ b/poppler/Catalog.cc
@@ -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
diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index da37016..1841873 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -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)
diff --git a/poppler/OptionalContent.cc b/poppler/OptionalContent.cc
index 64621a7..181fef0 100644
--- a/poppler/OptionalContent.cc
+++ b/poppler/OptionalContent.cc
@@ -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;
}
}
More information about the poppler
mailing list