Commit bfda71774907263f5263a3ae2e8c8fa40fbc2cca

Authored by Jay Berkenbilt
1 parent 913eb5ac

Cosmetic changes to be closer to Adobe terminology

Change object type Keyword to Operator, and place the order of the
object types in object_type_e in the same order as they are mentioned
in the PDF specification.

Note that this change only breaks backward compatibility with code
that has not yet been released.
ChangeLog
@@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
17 objects in a content stream and calls handlers in a callback 17 objects in a content stream and calls handlers in a callback
18 class. The example pdf-parse-content illustrates it use. 18 class. The example pdf-parse-content illustrates it use.
19 19
20 - * Add QPDF_Keyword and QPDF_InlineImage types along with 20 + * Add QPDF_Operator and QPDF_InlineImage types along with
21 appropriate wrapper methods in QPDFObjectHandle. These new object 21 appropriate wrapper methods in QPDFObjectHandle. These new object
22 types are to facilitate content stream parsing. 22 types are to facilitate content stream parsing.
23 23
examples/qtest/parse-content/content.out
1 -keyword: BT 1 +operator: BT
2 name: /F1 2 name: /F1
3 integer: 24 3 integer: 24
4 -keyword: Tf 4 +operator: Tf
5 integer: 72 5 integer: 72
6 integer: 720 6 integer: 720
7 -keyword: Td 7 +operator: Td
8 string: (Potato) 8 string: (Potato)
9 -keyword: Tj  
10 -keyword: ET 9 +operator: Tj
  10 +operator: ET
11 -EOF- 11 -EOF-
include/qpdf/QPDFObject.hh
@@ -30,17 +30,17 @@ class QPDFObject @@ -30,17 +30,17 @@ class QPDFObject
30 ot_uninitialized, 30 ot_uninitialized,
31 ot_reserved, 31 ot_reserved,
32 // Object types that can occur in the main document 32 // Object types that can occur in the main document
33 - ot_boolean,  
34 ot_null, 33 ot_null,
  34 + ot_boolean,
35 ot_integer, 35 ot_integer,
36 ot_real, 36 ot_real,
37 - ot_name,  
38 ot_string, 37 ot_string,
  38 + ot_name,
39 ot_array, 39 ot_array,
40 ot_dictionary, 40 ot_dictionary,
41 ot_stream, 41 ot_stream,
42 // Additional object types that can occur in content streams 42 // Additional object types that can occur in content streams
43 - ot_keyword, 43 + ot_operator,
44 ot_inlineimage, 44 ot_inlineimage,
45 }; 45 };
46 46
include/qpdf/QPDFObjectHandle.hh
@@ -99,7 +99,7 @@ class QPDFObjectHandle @@ -99,7 +99,7 @@ class QPDFObjectHandle
99 QPDF_DLL 99 QPDF_DLL
100 char const* getTypeName() const; 100 char const* getTypeName() const;
101 101
102 - // Exactly one of these will return true for any object. Keyword 102 + // Exactly one of these will return true for any object. Operator
103 // and InlineImage are only allowed in content streams. 103 // and InlineImage are only allowed in content streams.
104 QPDF_DLL 104 QPDF_DLL
105 bool isBool(); 105 bool isBool();
@@ -114,7 +114,7 @@ class QPDFObjectHandle @@ -114,7 +114,7 @@ class QPDFObjectHandle
114 QPDF_DLL 114 QPDF_DLL
115 bool isString(); 115 bool isString();
116 QPDF_DLL 116 QPDF_DLL
117 - bool isKeyword(); 117 + bool isOperator();
118 QPDF_DLL 118 QPDF_DLL
119 bool isInlineImage(); 119 bool isInlineImage();
120 QPDF_DLL 120 QPDF_DLL
@@ -182,7 +182,7 @@ class QPDFObjectHandle @@ -182,7 +182,7 @@ class QPDFObjectHandle
182 QPDF_DLL 182 QPDF_DLL
183 static QPDFObjectHandle newString(std::string const& str); 183 static QPDFObjectHandle newString(std::string const& str);
184 QPDF_DLL 184 QPDF_DLL
185 - static QPDFObjectHandle newKeyword(std::string const&); 185 + static QPDFObjectHandle newOperator(std::string const&);
186 QPDF_DLL 186 QPDF_DLL
187 static QPDFObjectHandle newInlineImage(std::string const&); 187 static QPDFObjectHandle newInlineImage(std::string const&);
188 QPDF_DLL 188 QPDF_DLL
@@ -279,7 +279,7 @@ class QPDFObjectHandle @@ -279,7 +279,7 @@ class QPDFObjectHandle
279 279
280 // Methods for content stream objects 280 // Methods for content stream objects
281 QPDF_DLL 281 QPDF_DLL
282 - std::string getKeywordValue(); 282 + std::string getOperatorValue();
283 QPDF_DLL 283 QPDF_DLL
284 std::string getInlineImageValue(); 284 std::string getInlineImageValue();
285 285
@@ -554,7 +554,7 @@ class QPDFObjectHandle @@ -554,7 +554,7 @@ class QPDFObjectHandle
554 QPDF_DLL 554 QPDF_DLL
555 void assertString(); 555 void assertString();
556 QPDF_DLL 556 QPDF_DLL
557 - void assertKeyword(); 557 + void assertOperator();
558 QPDF_DLL 558 QPDF_DLL
559 void assertInlineImage(); 559 void assertInlineImage();
560 QPDF_DLL 560 QPDF_DLL
libqpdf/QPDFObjectHandle.cc
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 #include <qpdf/QPDF_Real.hh> 7 #include <qpdf/QPDF_Real.hh>
8 #include <qpdf/QPDF_Name.hh> 8 #include <qpdf/QPDF_Name.hh>
9 #include <qpdf/QPDF_String.hh> 9 #include <qpdf/QPDF_String.hh>
10 -#include <qpdf/QPDF_Keyword.hh> 10 +#include <qpdf/QPDF_Operator.hh>
11 #include <qpdf/QPDF_InlineImage.hh> 11 #include <qpdf/QPDF_InlineImage.hh>
12 #include <qpdf/QPDF_Array.hh> 12 #include <qpdf/QPDF_Array.hh>
13 #include <qpdf/QPDF_Dictionary.hh> 13 #include <qpdf/QPDF_Dictionary.hh>
@@ -180,10 +180,10 @@ QPDFObjectHandle::isString() @@ -180,10 +180,10 @@ QPDFObjectHandle::isString()
180 } 180 }
181 181
182 bool 182 bool
183 -QPDFObjectHandle::isKeyword() 183 +QPDFObjectHandle::isOperator()
184 { 184 {
185 dereference(); 185 dereference();
186 - return QPDFObjectTypeAccessor<QPDF_Keyword>::check(obj.getPointer()); 186 + return QPDFObjectTypeAccessor<QPDF_Operator>::check(obj.getPointer());
187 } 187 }
188 188
189 bool 189 bool
@@ -233,7 +233,7 @@ bool @@ -233,7 +233,7 @@ bool
233 QPDFObjectHandle::isScalar() 233 QPDFObjectHandle::isScalar()
234 { 234 {
235 return (! (isArray() || isDictionary() || isStream() || 235 return (! (isArray() || isDictionary() || isStream() ||
236 - isKeyword() || isInlineImage())); 236 + isOperator() || isInlineImage()));
237 } 237 }
238 238
239 // Bool accessors 239 // Bool accessors
@@ -288,13 +288,13 @@ QPDFObjectHandle::getUTF8Value() @@ -288,13 +288,13 @@ QPDFObjectHandle::getUTF8Value()
288 return dynamic_cast<QPDF_String*>(obj.getPointer())->getUTF8Val(); 288 return dynamic_cast<QPDF_String*>(obj.getPointer())->getUTF8Val();
289 } 289 }
290 290
291 -// Keyword and Inline Image accessors 291 +// Operator and Inline Image accessors
292 292
293 std::string 293 std::string
294 -QPDFObjectHandle::getKeywordValue() 294 +QPDFObjectHandle::getOperatorValue()
295 { 295 {
296 - assertKeyword();  
297 - return dynamic_cast<QPDF_Keyword*>(obj.getPointer())->getVal(); 296 + assertOperator();
  297 + return dynamic_cast<QPDF_Operator*>(obj.getPointer())->getVal();
298 } 298 }
299 299
300 std::string 300 std::string
@@ -760,7 +760,7 @@ QPDFObjectHandle::parseContentStream_internal(QPDFObjectHandle stream, @@ -760,7 +760,7 @@ QPDFObjectHandle::parseContentStream_internal(QPDFObjectHandle stream,
760 } 760 }
761 761
762 callbacks->handleObject(obj); 762 callbacks->handleObject(obj);
763 - if (obj.isKeyword() && (obj.getKeywordValue() == "ID")) 763 + if (obj.isOperator() && (obj.getOperatorValue() == "ID"))
764 { 764 {
765 // Discard next character; it is the space after ID that 765 // Discard next character; it is the space after ID that
766 // terminated the token. Read until end of inline image. 766 // terminated the token. Read until end of inline image.
@@ -970,7 +970,7 @@ QPDFObjectHandle::parseInternal(PointerHolder&lt;InputSource&gt; input, @@ -970,7 +970,7 @@ QPDFObjectHandle::parseInternal(PointerHolder&lt;InputSource&gt; input,
970 } 970 }
971 else if (content_stream) 971 else if (content_stream)
972 { 972 {
973 - object = QPDFObjectHandle::newKeyword(token.getValue()); 973 + object = QPDFObjectHandle::newOperator(token.getValue());
974 } 974 }
975 else 975 else
976 { 976 {
@@ -1108,9 +1108,9 @@ QPDFObjectHandle::newString(std::string const&amp; str) @@ -1108,9 +1108,9 @@ QPDFObjectHandle::newString(std::string const&amp; str)
1108 } 1108 }
1109 1109
1110 QPDFObjectHandle 1110 QPDFObjectHandle
1111 -QPDFObjectHandle::newKeyword(std::string const& value) 1111 +QPDFObjectHandle::newOperator(std::string const& value)
1112 { 1112 {
1113 - return QPDFObjectHandle(new QPDF_Keyword(value)); 1113 + return QPDFObjectHandle(new QPDF_Operator(value));
1114 } 1114 }
1115 1115
1116 QPDFObjectHandle 1116 QPDFObjectHandle
@@ -1404,9 +1404,9 @@ QPDFObjectHandle::assertString() @@ -1404,9 +1404,9 @@ QPDFObjectHandle::assertString()
1404 } 1404 }
1405 1405
1406 void 1406 void
1407 -QPDFObjectHandle::assertKeyword() 1407 +QPDFObjectHandle::assertOperator()
1408 { 1408 {
1409 - assertType("Keyword", isKeyword()); 1409 + assertType("Operator", isOperator());
1410 } 1410 }
1411 1411
1412 void 1412 void
libqpdf/QPDF_Keyword.cc renamed to libqpdf/QPDF_Operator.cc
1 -#include <qpdf/QPDF_Keyword.hh> 1 +#include <qpdf/QPDF_Operator.hh>
2 2
3 #include <qpdf/QUtil.hh> 3 #include <qpdf/QUtil.hh>
4 4
5 -QPDF_Keyword::QPDF_Keyword(std::string const& val) : 5 +QPDF_Operator::QPDF_Operator(std::string const& val) :
6 val(val) 6 val(val)
7 { 7 {
8 } 8 }
9 9
10 -QPDF_Keyword::~QPDF_Keyword() 10 +QPDF_Operator::~QPDF_Operator()
11 { 11 {
12 } 12 }
13 13
14 std::string 14 std::string
15 -QPDF_Keyword::unparse() 15 +QPDF_Operator::unparse()
16 { 16 {
17 return this->val; 17 return this->val;
18 } 18 }
19 19
20 QPDFObject::object_type_e 20 QPDFObject::object_type_e
21 -QPDF_Keyword::getTypeCode() const 21 +QPDF_Operator::getTypeCode() const
22 { 22 {
23 - return QPDFObject::ot_keyword; 23 + return QPDFObject::ot_operator;
24 } 24 }
25 25
26 char const* 26 char const*
27 -QPDF_Keyword::getTypeName() const 27 +QPDF_Operator::getTypeName() const
28 { 28 {
29 - return "keyword"; 29 + return "operator";
30 } 30 }
31 31
32 std::string 32 std::string
33 -QPDF_Keyword::getVal() const 33 +QPDF_Operator::getVal() const
34 { 34 {
35 return this->val; 35 return this->val;
36 } 36 }
libqpdf/build.mk
@@ -43,8 +43,8 @@ SRCS_libqpdf = \ @@ -43,8 +43,8 @@ SRCS_libqpdf = \
43 libqpdf/QPDF_InlineImage.cc \ 43 libqpdf/QPDF_InlineImage.cc \
44 libqpdf/QPDF_Integer.cc \ 44 libqpdf/QPDF_Integer.cc \
45 libqpdf/QPDF_Name.cc \ 45 libqpdf/QPDF_Name.cc \
46 - libqpdf/QPDF_Keyword.cc \  
47 libqpdf/QPDF_Null.cc \ 46 libqpdf/QPDF_Null.cc \
  47 + libqpdf/QPDF_Operator.cc \
48 libqpdf/QPDF_Real.cc \ 48 libqpdf/QPDF_Real.cc \
49 libqpdf/QPDF_Reserved.cc \ 49 libqpdf/QPDF_Reserved.cc \
50 libqpdf/QPDF_Stream.cc \ 50 libqpdf/QPDF_Stream.cc \
libqpdf/qpdf/QPDF_Keyword.hh renamed to libqpdf/qpdf/QPDF_Operator.hh
1 -#ifndef __QPDF_KEYWORD_HH__  
2 -#define __QPDF_KEYWORD_HH__ 1 +#ifndef __QPDF_OPERATOR_HH__
  2 +#define __QPDF_OPERATOR_HH__
3 3
4 #include <qpdf/QPDFObject.hh> 4 #include <qpdf/QPDFObject.hh>
5 5
6 -class QPDF_Keyword: public QPDFObject 6 +class QPDF_Operator: public QPDFObject
7 { 7 {
8 public: 8 public:
9 - QPDF_Keyword(std::string const& val);  
10 - virtual ~QPDF_Keyword(); 9 + QPDF_Operator(std::string const& val);
  10 + virtual ~QPDF_Operator();
11 virtual std::string unparse(); 11 virtual std::string unparse();
12 virtual QPDFObject::object_type_e getTypeCode() const; 12 virtual QPDFObject::object_type_e getTypeCode() const;
13 virtual char const* getTypeName() const; 13 virtual char const* getTypeName() const;
@@ -17,4 +17,4 @@ class QPDF_Keyword: public QPDFObject @@ -17,4 +17,4 @@ class QPDF_Keyword: public QPDFObject
17 std::string val; 17 std::string val;
18 }; 18 };
19 19
20 -#endif // __QPDF_KEYWORD_HH__ 20 +#endif // __QPDF_OPERATOR_HH__
qpdf/qtest/qpdf/eof-in-inline-image.out
1 -keyword: BT 1 +operator: BT
2 name: /F1 2 name: /F1
3 integer: 24 3 integer: 24
4 -keyword: Tf 4 +operator: Tf
5 integer: 72 5 integer: 72
6 integer: 720 6 integer: 720
7 -keyword: Td 7 +operator: Td
8 string: (Potato) 8 string: (Potato)
9 -keyword: Tj  
10 -keyword: ET  
11 -keyword: BI 9 +operator: Tj
  10 +operator: ET
  11 +operator: BI
12 name: /CS 12 name: /CS
13 name: /G 13 name: /G
14 name: /W 14 name: /W
@@ -21,5 +21,5 @@ name: /F @@ -21,5 +21,5 @@ name: /F
21 name: /Fl 21 name: /Fl
22 name: /DP 22 name: /DP
23 dictionary: << /Columns 1 /Predictor 15 >> 23 dictionary: << /Columns 1 /Predictor 15 >>
24 -keyword: ID 24 +operator: ID
25 content stream object 4 0 (stream data, file position 139): EOF found while reading inline image 25 content stream object 4 0 (stream data, file position 139): EOF found while reading inline image
qpdf/qtest/qpdf/tokenize-content-streams.out
1 -keyword: BT 1 +operator: BT
2 name: /F1 2 name: /F1
3 integer: 24 3 integer: 24
4 -keyword: Tf 4 +operator: Tf
5 integer: 72 5 integer: 72
6 integer: 720 6 integer: 720
7 -keyword: Td 7 +operator: Td
8 string: (Potato) 8 string: (Potato)
9 -keyword: Tj  
10 -keyword: ET 9 +operator: Tj
  10 +operator: ET
11 -EOF- 11 -EOF-
12 real: 0.1 12 real: 0.1
13 integer: 0 13 integer: 0
@@ -15,16 +15,16 @@ integer: 0 @@ -15,16 +15,16 @@ integer: 0
15 real: 0.1 15 real: 0.1
16 integer: 0 16 integer: 0
17 integer: 0 17 integer: 0
18 -keyword: cm  
19 -keyword: q 18 +operator: cm
  19 +operator: q
20 integer: 0 20 integer: 0
21 real: 1.1999 21 real: 1.1999
22 real: -1.1999 22 real: -1.1999
23 integer: 0 23 integer: 0
24 real: 121.19 24 real: 121.19
25 real: 150.009 25 real: 150.009
26 -keyword: cm  
27 -keyword: BI 26 +operator: cm
  27 +operator: BI
28 name: /CS 28 name: /CS
29 name: /G 29 name: /G
30 name: /W 30 name: /W
@@ -37,19 +37,19 @@ name: /F @@ -37,19 +37,19 @@ name: /F
37 name: /Fl 37 name: /Fl
38 name: /DP 38 name: /DP
39 dictionary: << /Columns 1 /Predictor 15 >> 39 dictionary: << /Columns 1 /Predictor 15 >>
40 -keyword: ID 40 +operator: ID
41 inline-image: 789c63fc0f0001030101 41 inline-image: 789c63fc0f0001030101
42 -keyword: EI  
43 -keyword: Q  
44 -keyword: q 42 +operator: EI
  43 +operator: Q
  44 +operator: q
45 integer: 0 45 integer: 0
46 real: 35.997 46 real: 35.997
47 real: -128.389 47 real: -128.389
48 integer: 0 48 integer: 0
49 real: 431.964 49 real: 431.964
50 real: 7269.02 50 real: 7269.02
51 -keyword: cm  
52 -keyword: BI 51 +operator: cm
  52 +operator: BI
53 name: /CS 53 name: /CS
54 name: /G 54 name: /G
55 name: /W 55 name: /W
@@ -62,19 +62,19 @@ name: /F @@ -62,19 +62,19 @@ name: /F
62 name: /Fl 62 name: /Fl
63 name: /DP 63 name: /DP
64 dictionary: << /Columns 30 /Predictor 15 >> 64 dictionary: << /Columns 30 /Predictor 15 >>
65 -keyword: ID 65 +operator: ID
66 inline-image: 789cedd1a11100300800b1b2ffd06503148283bc8dfcf8af2a306ee352eff2e06318638c31c63b3801627b620a 66 inline-image: 789cedd1a11100300800b1b2ffd06503148283bc8dfcf8af2a306ee352eff2e06318638c31c63b3801627b620a
67 -keyword: EI  
68 -keyword: Q  
69 -keyword: q 67 +operator: EI
  68 +operator: Q
  69 +operator: q
70 integer: 0 70 integer: 0
71 real: 38.3968 71 real: 38.3968
72 real: -93.5922 72 real: -93.5922
73 integer: 0 73 integer: 0
74 real: 431.964 74 real: 431.964
75 real: 7567.79 75 real: 7567.79
76 -keyword: cm  
77 -keyword: BI 76 +operator: cm
  77 +operator: BI
78 name: /CS 78 name: /CS
79 name: /G 79 name: /G
80 name: /W 80 name: /W
@@ -87,9 +87,9 @@ name: /F @@ -87,9 +87,9 @@ name: /F
87 name: /Fl 87 name: /Fl
88 name: /DP 88 name: /DP
89 dictionary: << /Columns 32 /Predictor 15 >> 89 dictionary: << /Columns 32 /Predictor 15 >>
90 -keyword: ID 90 +operator: ID
91 inline-image: 789c63fccf801f308e2a185530aa60882a20203faa605401890a0643aa1e5530aa6054010d140000bdd03c13 91 inline-image: 789c63fccf801f308e2a185530aa60882a20203faa605401890a0643aa1e5530aa6054010d140000bdd03c13
92 -keyword: EI  
93 -keyword: Q 92 +operator: EI
  93 +operator: Q
94 -EOF- 94 -EOF-
95 test 37 done 95 test 37 done