Commit 06c6660d authored by Carlos Garcia Campos's avatar Carlos Garcia Campos

xpdf303: Parse usage dictionary of optional content groups

parent 528d5b0d
......@@ -360,6 +360,7 @@ bool OCGs::anyOff( Array *ocgArray )
OptionalContentGroup::OptionalContentGroup(Dict *ocgDict) : m_name(NULL)
{
Object obj1, obj2, obj3;
Object ocgName;
ocgDict->lookup("Name", &ocgName);
if (!ocgName.isString()) {
......@@ -368,6 +369,33 @@ OptionalContentGroup::OptionalContentGroup(Dict *ocgDict) : m_name(NULL)
m_name = new GooString( ocgName.getString() );
}
ocgName.free();
viewState = printState = ocUsageUnset;
if (ocgDict->lookup("Usage", &obj1)->isDict()) {
if (obj1.dictLookup("View", &obj2)->isDict()) {
if (obj2.dictLookup("ViewState", &obj3)->isName()) {
if (obj3.isName("ON")) {
viewState = ocUsageOn;
} else {
viewState = ocUsageOff;
}
}
obj3.free();
}
obj2.free();
if (obj1.dictLookup("Print", &obj2)->isDict()) {
if (obj2.dictLookup("PrintState", &obj3)->isName()) {
if (obj3.isName("ON")) {
printState = ocUsageOn;
} else {
printState = ocUsageOff;
}
}
obj3.free();
}
obj2.free();
}
obj1.free();
}
OptionalContentGroup::OptionalContentGroup(GooString *label)
......
......@@ -70,6 +70,13 @@ class OptionalContentGroup {
public:
enum State { On, Off };
// Values from the optional content usage dictionary.
enum UsageState {
ocUsageOn,
ocUsageOff,
ocUsageUnset
};
OptionalContentGroup(Dict *dict);
OptionalContentGroup(GooString *label);
......@@ -84,11 +91,16 @@ public:
State getState() { return m_state; };
void setState(State state) { m_state = state; };
UsageState getViewState() { return viewState; }
UsageState getPrintState() { return printState; }
private:
XRef *xref;
GooString *m_name;
Ref m_ref;
State m_state;
State m_state;
UsageState viewState; // suggested state when viewing
UsageState printState; // suggested state when printing
};
#endif
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