OptionalContent.h 2.31 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
  GBool ok;
53 54

  GBool evalOCVisibilityExpr(Object *expr, int recursion);
55 56 57 58 59 60 61
  bool allOn( Array *ocgArray );
  bool allOff( Array *ocgArray );
  bool anyOn( Array *ocgArray );
  bool anyOff( Array *ocgArray );

  GooList *optionalContentGroups;

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

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

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

73 74 75 76 77 78 79
  // Values from the optional content usage dictionary.
  enum UsageState {
    ocUsageOn,
    ocUsageOff,
    ocUsageUnset
  };

80
  OptionalContentGroup(Dict *dict);
81 82 83 84 85

  OptionalContentGroup(GooString *label);

  ~OptionalContentGroup();

86
  GooString* getName() const;
87

88
  Ref getRef() const;
89 90
  void setRef(const Ref ref);

91
  State getState() { return m_state; };
92 93
  void setState(State state) { m_state = state; };

94 95 96
  UsageState getViewState() { return viewState; }
  UsageState getPrintState() { return printState; }

97 98 99 100
private:
  XRef *xref;
  GooString *m_name;
  Ref m_ref;
101 102 103
  State m_state;
  UsageState viewState;	 // suggested state when viewing
  UsageState printState; // suggested state when printing
104 105 106
};

#endif