OptionalContent.h 1.92 KB
Newer Older
1 2 3 4 5
//========================================================================
//
// OptionalContent.h
//
// Copyright 2007 Brad Hards <bradh@kde.org>
6
// Copyright 2008 Carlos Garcia Campos <carlosgc@gnome.org>
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
//
// Released under the GPL (version 2, or later, at your option)
//
//========================================================================

#ifndef OPTIONALCONTENT_H
#define OPTIONALCONTENT_H

#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif

#include "Object.h"
#include "CharTypes.h"

class GooString;
class GooList;
class XRef;

class OptionalContentGroup; 

//------------------------------------------------------------------------

class OCGs {
public:

  OCGs(Object *ocgObject, XRef *xref);
  ~OCGs();

36 37 38
  // Is OCGS valid?
  GBool isOk() { return ok; }
  
39 40 41 42 43
  bool hasOCGs();
  GooList *getOCGs() const { return optionalContentGroups; }

  OptionalContentGroup* findOcgByRef( const Ref &ref);

44 45 46 47
  Array* getOrderArray() 
    { return (order.isArray() && order.arrayGetLength() > 0) ? order.getArray() : NULL; }
  Array* getRBGroupsArray() 
    { return (rbgroups.isArray() && rbgroups.arrayGetLength()) ? rbgroups.getArray() : NULL; }
48 49 50 51

  bool optContentIsVisible( Object *dictRef );

private:
52 53
  GBool ok;
  
54 55 56 57 58 59 60
  bool allOn( Array *ocgArray );
  bool allOff( Array *ocgArray );
  bool anyOn( Array *ocgArray );
  bool anyOff( Array *ocgArray );

  GooList *optionalContentGroups;

61 62
  Object order;
  Object rbgroups;
63 64 65 66 67 68 69 70 71
  XRef *m_xref;
};

//------------------------------------------------------------------------

class OptionalContentGroup {
public:
  enum State { On, Off };

72
  OptionalContentGroup(Dict *dict);
73 74 75 76 77

  OptionalContentGroup(GooString *label);

  ~OptionalContentGroup();

78
  GooString* getName() const;
79

80
  Ref getRef() const;
81 82
  void setRef(const Ref ref);

83
  State getState() { return m_state; };
84 85 86 87 88 89 90 91 92 93
  void setState(State state) { m_state = state; };

private:
  XRef *xref;
  GooString *m_name;
  Ref m_ref;
  State m_state;  
};

#endif