2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 10:58:58 +00:00

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.
This commit is contained in:
Jay Berkenbilt 2013-01-23 09:38:05 -05:00
parent 913eb5ac35
commit bfda717749
11 changed files with 102 additions and 102 deletions

View File

@ -17,7 +17,7 @@
objects in a content stream and calls handlers in a callback
class. The example pdf-parse-content illustrates it use.
* Add QPDF_Keyword and QPDF_InlineImage types along with
* Add QPDF_Operator and QPDF_InlineImage types along with
appropriate wrapper methods in QPDFObjectHandle. These new object
types are to facilitate content stream parsing.

View File

@ -1,11 +1,11 @@
keyword: BT
operator: BT
name: /F1
integer: 24
keyword: Tf
operator: Tf
integer: 72
integer: 720
keyword: Td
operator: Td
string: (Potato)
keyword: Tj
keyword: ET
operator: Tj
operator: ET
-EOF-

View File

@ -30,17 +30,17 @@ class QPDFObject
ot_uninitialized,
ot_reserved,
// Object types that can occur in the main document
ot_boolean,
ot_null,
ot_boolean,
ot_integer,
ot_real,
ot_name,
ot_string,
ot_name,
ot_array,
ot_dictionary,
ot_stream,
// Additional object types that can occur in content streams
ot_keyword,
ot_operator,
ot_inlineimage,
};

View File

@ -99,7 +99,7 @@ class QPDFObjectHandle
QPDF_DLL
char const* getTypeName() const;
// Exactly one of these will return true for any object. Keyword
// Exactly one of these will return true for any object. Operator
// and InlineImage are only allowed in content streams.
QPDF_DLL
bool isBool();
@ -114,7 +114,7 @@ class QPDFObjectHandle
QPDF_DLL
bool isString();
QPDF_DLL
bool isKeyword();
bool isOperator();
QPDF_DLL
bool isInlineImage();
QPDF_DLL
@ -182,7 +182,7 @@ class QPDFObjectHandle
QPDF_DLL
static QPDFObjectHandle newString(std::string const& str);
QPDF_DLL
static QPDFObjectHandle newKeyword(std::string const&);
static QPDFObjectHandle newOperator(std::string const&);
QPDF_DLL
static QPDFObjectHandle newInlineImage(std::string const&);
QPDF_DLL
@ -279,7 +279,7 @@ class QPDFObjectHandle
// Methods for content stream objects
QPDF_DLL
std::string getKeywordValue();
std::string getOperatorValue();
QPDF_DLL
std::string getInlineImageValue();
@ -554,7 +554,7 @@ class QPDFObjectHandle
QPDF_DLL
void assertString();
QPDF_DLL
void assertKeyword();
void assertOperator();
QPDF_DLL
void assertInlineImage();
QPDF_DLL

View File

@ -7,7 +7,7 @@
#include <qpdf/QPDF_Real.hh>
#include <qpdf/QPDF_Name.hh>
#include <qpdf/QPDF_String.hh>
#include <qpdf/QPDF_Keyword.hh>
#include <qpdf/QPDF_Operator.hh>
#include <qpdf/QPDF_InlineImage.hh>
#include <qpdf/QPDF_Array.hh>
#include <qpdf/QPDF_Dictionary.hh>
@ -180,10 +180,10 @@ QPDFObjectHandle::isString()
}
bool
QPDFObjectHandle::isKeyword()
QPDFObjectHandle::isOperator()
{
dereference();
return QPDFObjectTypeAccessor<QPDF_Keyword>::check(obj.getPointer());
return QPDFObjectTypeAccessor<QPDF_Operator>::check(obj.getPointer());
}
bool
@ -233,7 +233,7 @@ bool
QPDFObjectHandle::isScalar()
{
return (! (isArray() || isDictionary() || isStream() ||
isKeyword() || isInlineImage()));
isOperator() || isInlineImage()));
}
// Bool accessors
@ -288,13 +288,13 @@ QPDFObjectHandle::getUTF8Value()
return dynamic_cast<QPDF_String*>(obj.getPointer())->getUTF8Val();
}
// Keyword and Inline Image accessors
// Operator and Inline Image accessors
std::string
QPDFObjectHandle::getKeywordValue()
QPDFObjectHandle::getOperatorValue()
{
assertKeyword();
return dynamic_cast<QPDF_Keyword*>(obj.getPointer())->getVal();
assertOperator();
return dynamic_cast<QPDF_Operator*>(obj.getPointer())->getVal();
}
std::string
@ -760,7 +760,7 @@ QPDFObjectHandle::parseContentStream_internal(QPDFObjectHandle stream,
}
callbacks->handleObject(obj);
if (obj.isKeyword() && (obj.getKeywordValue() == "ID"))
if (obj.isOperator() && (obj.getOperatorValue() == "ID"))
{
// Discard next character; it is the space after ID that
// terminated the token. Read until end of inline image.
@ -970,7 +970,7 @@ QPDFObjectHandle::parseInternal(PointerHolder<InputSource> input,
}
else if (content_stream)
{
object = QPDFObjectHandle::newKeyword(token.getValue());
object = QPDFObjectHandle::newOperator(token.getValue());
}
else
{
@ -1108,9 +1108,9 @@ QPDFObjectHandle::newString(std::string const& str)
}
QPDFObjectHandle
QPDFObjectHandle::newKeyword(std::string const& value)
QPDFObjectHandle::newOperator(std::string const& value)
{
return QPDFObjectHandle(new QPDF_Keyword(value));
return QPDFObjectHandle(new QPDF_Operator(value));
}
QPDFObjectHandle
@ -1404,9 +1404,9 @@ QPDFObjectHandle::assertString()
}
void
QPDFObjectHandle::assertKeyword()
QPDFObjectHandle::assertOperator()
{
assertType("Keyword", isKeyword());
assertType("Operator", isOperator());
}
void

View File

@ -1,36 +0,0 @@
#include <qpdf/QPDF_Keyword.hh>
#include <qpdf/QUtil.hh>
QPDF_Keyword::QPDF_Keyword(std::string const& val) :
val(val)
{
}
QPDF_Keyword::~QPDF_Keyword()
{
}
std::string
QPDF_Keyword::unparse()
{
return this->val;
}
QPDFObject::object_type_e
QPDF_Keyword::getTypeCode() const
{
return QPDFObject::ot_keyword;
}
char const*
QPDF_Keyword::getTypeName() const
{
return "keyword";
}
std::string
QPDF_Keyword::getVal() const
{
return this->val;
}

36
libqpdf/QPDF_Operator.cc Normal file
View File

@ -0,0 +1,36 @@
#include <qpdf/QPDF_Operator.hh>
#include <qpdf/QUtil.hh>
QPDF_Operator::QPDF_Operator(std::string const& val) :
val(val)
{
}
QPDF_Operator::~QPDF_Operator()
{
}
std::string
QPDF_Operator::unparse()
{
return this->val;
}
QPDFObject::object_type_e
QPDF_Operator::getTypeCode() const
{
return QPDFObject::ot_operator;
}
char const*
QPDF_Operator::getTypeName() const
{
return "operator";
}
std::string
QPDF_Operator::getVal() const
{
return this->val;
}

View File

@ -43,8 +43,8 @@ SRCS_libqpdf = \
libqpdf/QPDF_InlineImage.cc \
libqpdf/QPDF_Integer.cc \
libqpdf/QPDF_Name.cc \
libqpdf/QPDF_Keyword.cc \
libqpdf/QPDF_Null.cc \
libqpdf/QPDF_Operator.cc \
libqpdf/QPDF_Real.cc \
libqpdf/QPDF_Reserved.cc \
libqpdf/QPDF_Stream.cc \

View File

@ -1,13 +1,13 @@
#ifndef __QPDF_KEYWORD_HH__
#define __QPDF_KEYWORD_HH__
#ifndef __QPDF_OPERATOR_HH__
#define __QPDF_OPERATOR_HH__
#include <qpdf/QPDFObject.hh>
class QPDF_Keyword: public QPDFObject
class QPDF_Operator: public QPDFObject
{
public:
QPDF_Keyword(std::string const& val);
virtual ~QPDF_Keyword();
QPDF_Operator(std::string const& val);
virtual ~QPDF_Operator();
virtual std::string unparse();
virtual QPDFObject::object_type_e getTypeCode() const;
virtual char const* getTypeName() const;
@ -17,4 +17,4 @@ class QPDF_Keyword: public QPDFObject
std::string val;
};
#endif // __QPDF_KEYWORD_HH__
#endif // __QPDF_OPERATOR_HH__

View File

@ -1,14 +1,14 @@
keyword: BT
operator: BT
name: /F1
integer: 24
keyword: Tf
operator: Tf
integer: 72
integer: 720
keyword: Td
operator: Td
string: (Potato)
keyword: Tj
keyword: ET
keyword: BI
operator: Tj
operator: ET
operator: BI
name: /CS
name: /G
name: /W
@ -21,5 +21,5 @@ name: /F
name: /Fl
name: /DP
dictionary: << /Columns 1 /Predictor 15 >>
keyword: ID
operator: ID
content stream object 4 0 (stream data, file position 139): EOF found while reading inline image

View File

@ -1,13 +1,13 @@
keyword: BT
operator: BT
name: /F1
integer: 24
keyword: Tf
operator: Tf
integer: 72
integer: 720
keyword: Td
operator: Td
string: (Potato)
keyword: Tj
keyword: ET
operator: Tj
operator: ET
-EOF-
real: 0.1
integer: 0
@ -15,16 +15,16 @@ integer: 0
real: 0.1
integer: 0
integer: 0
keyword: cm
keyword: q
operator: cm
operator: q
integer: 0
real: 1.1999
real: -1.1999
integer: 0
real: 121.19
real: 150.009
keyword: cm
keyword: BI
operator: cm
operator: BI
name: /CS
name: /G
name: /W
@ -37,19 +37,19 @@ name: /F
name: /Fl
name: /DP
dictionary: << /Columns 1 /Predictor 15 >>
keyword: ID
operator: ID
inline-image: 789c63fc0f0001030101
keyword: EI
keyword: Q
keyword: q
operator: EI
operator: Q
operator: q
integer: 0
real: 35.997
real: -128.389
integer: 0
real: 431.964
real: 7269.02
keyword: cm
keyword: BI
operator: cm
operator: BI
name: /CS
name: /G
name: /W
@ -62,19 +62,19 @@ name: /F
name: /Fl
name: /DP
dictionary: << /Columns 30 /Predictor 15 >>
keyword: ID
operator: ID
inline-image: 789cedd1a11100300800b1b2ffd06503148283bc8dfcf8af2a306ee352eff2e06318638c31c63b3801627b620a
keyword: EI
keyword: Q
keyword: q
operator: EI
operator: Q
operator: q
integer: 0
real: 38.3968
real: -93.5922
integer: 0
real: 431.964
real: 7567.79
keyword: cm
keyword: BI
operator: cm
operator: BI
name: /CS
name: /G
name: /W
@ -87,9 +87,9 @@ name: /F
name: /Fl
name: /DP
dictionary: << /Columns 32 /Predictor 15 >>
keyword: ID
operator: ID
inline-image: 789c63fccf801f308e2a185530aa60882a20203faa605401890a0643aa1e5530aa6054010d140000bdd03c13
keyword: EI
keyword: Q
operator: EI
operator: Q
-EOF-
test 37 done