File indexing completed on 2025-12-10 10:23:49
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef OPTIONALCONTENT_H
0016 #define OPTIONALCONTENT_H
0017
0018 #include "Object.h"
0019 #include "CharTypes.h"
0020 #include "poppler_private_export.h"
0021 #include <unordered_map>
0022 #include <memory>
0023
0024 class GooString;
0025 class XRef;
0026
0027 class OptionalContentGroup;
0028
0029
0030
0031 class POPPLER_PRIVATE_EXPORT OCGs
0032 {
0033 public:
0034 OCGs(Object *ocgObject, XRef *xref);
0035
0036 OCGs(const OCGs &) = delete;
0037 OCGs &operator=(const OCGs &) = delete;
0038
0039
0040 bool isOk() const { return ok; }
0041
0042 bool hasOCGs() const;
0043 const std::unordered_map<Ref, std::unique_ptr<OptionalContentGroup>> &getOCGs() const { return optionalContentGroups; }
0044
0045 OptionalContentGroup *findOcgByRef(const Ref ref);
0046
0047 Array *getOrderArray() { return (order.isArray() && order.arrayGetLength() > 0) ? order.getArray() : nullptr; }
0048 Array *getRBGroupsArray() { return (rbgroups.isArray() && rbgroups.arrayGetLength()) ? rbgroups.getArray() : nullptr; }
0049
0050 bool optContentIsVisible(const Object *dictRef);
0051
0052 private:
0053 bool ok;
0054
0055 bool evalOCVisibilityExpr(const Object *expr, int recursion);
0056 bool allOn(Array *ocgArray);
0057 bool allOff(Array *ocgArray);
0058 bool anyOn(Array *ocgArray);
0059 bool anyOff(Array *ocgArray);
0060
0061 std::unordered_map<Ref, std::unique_ptr<OptionalContentGroup>> optionalContentGroups;
0062
0063 Object order;
0064 Object rbgroups;
0065 XRef *m_xref;
0066 };
0067
0068
0069
0070 class POPPLER_PRIVATE_EXPORT OptionalContentGroup
0071 {
0072 public:
0073 enum State
0074 {
0075 On,
0076 Off
0077 };
0078
0079
0080 enum UsageState
0081 {
0082 ocUsageOn,
0083 ocUsageOff,
0084 ocUsageUnset
0085 };
0086
0087 explicit OptionalContentGroup(Dict *dict);
0088
0089 explicit OptionalContentGroup(GooString *label);
0090
0091 ~OptionalContentGroup();
0092
0093 OptionalContentGroup(const OptionalContentGroup &) = delete;
0094 OptionalContentGroup &operator=(const OptionalContentGroup &) = delete;
0095
0096 const GooString *getName() const;
0097
0098 Ref getRef() const;
0099 void setRef(const Ref ref);
0100
0101 State getState() const { return m_state; };
0102 void setState(State state) { m_state = state; };
0103
0104 UsageState getViewState() const { return viewState; }
0105 UsageState getPrintState() const { return printState; }
0106
0107 private:
0108 GooString *m_name;
0109 Ref m_ref;
0110 State m_state;
0111 UsageState viewState;
0112 UsageState printState;
0113 };
0114
0115
0116
0117 #endif