Commit a906d12e authored by Carlos Garcia Campos's avatar Carlos Garcia Campos

Minor code cleanup and consistency issues

parent e73c2ce9
......@@ -51,7 +51,7 @@ OCGs::OCGs(Object *ocgObject, XRef *xref) :
ocg.free();
break;
}
OptionalContentGroup *thisOptionalContentGroup = new OptionalContentGroup(ocg.getDict(), xref);
OptionalContentGroup *thisOptionalContentGroup = new OptionalContentGroup(ocg.getDict());
ocg.free();
ocgList.arrayGetNF(i, &ocg);
// TODO: we should create a lookup map from Ref to the OptionalContentGroup
......@@ -159,7 +159,7 @@ OptionalContentGroup* OCGs::findOcgByRef( const Ref &ref)
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) ) {
if ( (ocg->getRef().num == ref.num) && (ocg->getRef().gen == ref.gen) ) {
return ocg;
}
}
......@@ -206,7 +206,7 @@ bool OCGs::optContentIsVisible( Object *dictRef )
}
} else if (ocg.isRef()) {
OptionalContentGroup* oc = findOcgByRef( ocg.getRef() );
if ( !oc || oc->state() == OptionalContentGroup::Off ) {
if ( !oc || oc->getState() == OptionalContentGroup::Off ) {
result = false;
} else {
result = true ;
......@@ -216,7 +216,7 @@ bool OCGs::optContentIsVisible( Object *dictRef )
policy.free();
} else if ( dictType.isName("OCG") ) {
OptionalContentGroup* oc = findOcgByRef( dictRef->getRef() );
if ( !oc || oc->state() == OptionalContentGroup::Off ) {
if ( !oc || oc->getState() == OptionalContentGroup::Off ) {
result=false;
}
}
......@@ -233,7 +233,7 @@ bool OCGs::allOn( Array *ocgArray )
ocgArray->getNF(i, &ocgItem);
if (ocgItem.isRef()) {
OptionalContentGroup* oc = findOcgByRef( ocgItem.getRef() );
if ( oc && oc->state() == OptionalContentGroup::Off ) {
if ( oc && oc->getState() == OptionalContentGroup::Off ) {
return false;
}
}
......@@ -248,7 +248,7 @@ bool OCGs::allOff( Array *ocgArray )
ocgArray->getNF(i, &ocgItem);
if (ocgItem.isRef()) {
OptionalContentGroup* oc = findOcgByRef( ocgItem.getRef() );
if ( oc && oc->state() == OptionalContentGroup::On ) {
if ( oc && oc->getState() == OptionalContentGroup::On ) {
return false;
}
}
......@@ -263,7 +263,7 @@ bool OCGs::anyOn( Array *ocgArray )
ocgArray->getNF(i, &ocgItem);
if (ocgItem.isRef()) {
OptionalContentGroup* oc = findOcgByRef( ocgItem.getRef() );
if ( oc && oc->state() == OptionalContentGroup::On ) {
if ( oc && oc->getState() == OptionalContentGroup::On ) {
return true;
}
}
......@@ -278,7 +278,7 @@ bool OCGs::anyOff( Array *ocgArray )
ocgArray->getNF(i, &ocgItem);
if (ocgItem.isRef()) {
OptionalContentGroup* oc = findOcgByRef( ocgItem.getRef() );
if ( oc && oc->state() == OptionalContentGroup::Off ) {
if ( oc && oc->getState() == OptionalContentGroup::Off ) {
return true;
}
}
......@@ -288,7 +288,7 @@ bool OCGs::anyOff( Array *ocgArray )
//------------------------------------------------------------------------
OptionalContentGroup::OptionalContentGroup(Dict *ocgDict, XRef *xrefA) : m_name(NULL)
OptionalContentGroup::OptionalContentGroup(Dict *ocgDict) : m_name(NULL)
{
Object ocgName;
ocgDict->lookup("Name", &ocgName);
......@@ -306,7 +306,7 @@ OptionalContentGroup::OptionalContentGroup(GooString *label)
m_state = On;
}
GooString* OptionalContentGroup::name() const
GooString* OptionalContentGroup::getName() const
{
return m_name;
}
......@@ -316,7 +316,7 @@ void OptionalContentGroup::setRef(const Ref ref)
m_ref = ref;
}
Ref OptionalContentGroup::ref() const
Ref OptionalContentGroup::getRef() const
{
return m_ref;
}
......
......@@ -66,18 +66,18 @@ class OptionalContentGroup {
public:
enum State { On, Off };
OptionalContentGroup(Dict *dict, XRef *xrefA);
OptionalContentGroup(Dict *dict);
OptionalContentGroup(GooString *label);
~OptionalContentGroup();
GooString* name() const;
GooString* getName() const;
Ref ref() const;
Ref getRef() const;
void setRef(const Ref ref);
State state() { return m_state; };
State getState() { return m_state; };
void setState(State state) { m_state = state; };
private:
......
......@@ -73,8 +73,8 @@ namespace Poppler
{
m_group = group;
m_parent = 0;
m_name = UnicodeParsedString( group->name() );
if ( group->state() == OptionalContentGroup::On ) {
m_name = UnicodeParsedString( group->getName() );
if ( group->getState() == OptionalContentGroup::On ) {
m_state = OptContentItem::On;
} else {
m_state = OptContentItem::Off;
......@@ -162,7 +162,7 @@ namespace Poppler
for (int i = 0; i < ocgs->getLength(); ++i) {
OptionalContentGroup *ocg = static_cast<OptionalContentGroup*>(ocgs->get(i));
OptContentItem *node = new OptContentItem( ocg );
m_optContentItems.insert( QString::number(ocg->ref().num), node);
m_optContentItems.insert( QString::number(ocg->getRef().num), node);
}
if ( optContent->getOrderArray() == 0 ) {
......
......@@ -184,8 +184,8 @@ void TestOptionalContent::checkVisibilitySetting()
OptionalContentGroup *ocgA = ocgs->findOcgByRef( ref21 );
QVERIFY( ocgA );
QVERIFY( (ocgA->name()->cmp("A")) == 0 );
QCOMPARE( ocgA->state(), OptionalContentGroup::On );
QVERIFY( (ocgA->getName()->cmp("A")) == 0 );
QCOMPARE( ocgA->getState(), OptionalContentGroup::On );
Object ref28obj;
ref28obj.initRef( 28, 0 );
......@@ -193,8 +193,8 @@ void TestOptionalContent::checkVisibilitySetting()
OptionalContentGroup *ocgB = ocgs->findOcgByRef( ref28 );
QVERIFY( ocgB );
QVERIFY( (ocgB->name()->cmp("B")) == 0 );
QCOMPARE( ocgB->state(), OptionalContentGroup::On );
QVERIFY( (ocgB->getName()->cmp("B")) == 0 );
QCOMPARE( ocgB->getState(), OptionalContentGroup::On );
// turn one Off
ocgA->setState( OptionalContentGroup::Off );
......
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