OLD | NEW |
1 #ifndef EXPERIMENTAL_PDFVIEWER_PDFPARSER_NATIVE_SKPDFOBJECT_H_ | 1 #ifndef EXPERIMENTAL_PDFVIEWER_PDFPARSER_NATIVE_SKPDFOBJECT_H_ |
2 #define EXPERIMENTAL_PDFVIEWER_PDFPARSER_NATIVE_SKPDFOBJECT_H_ | 2 #define EXPERIMENTAL_PDFVIEWER_PDFPARSER_NATIVE_SKPDFOBJECT_H_ |
3 | 3 |
4 #include <stdint.h> | 4 #include <stdint.h> |
5 #include <string.h> | 5 #include <string.h> |
6 #include <string> | 6 #include <string> |
7 #include "SkTDArray.h" | 7 #include "SkTDArray.h" |
8 #include "SkTDict.h" | 8 #include "SkTDict.h" |
9 #include "SkRect.h" | 9 #include "SkRect.h" |
10 #include "SkMatrix.h" | 10 #include "SkMatrix.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 fObjectType = kInvalid_PdfObjectType; | 116 fObjectType = kInvalid_PdfObjectType; |
117 } | 117 } |
118 | 118 |
119 ObjectType type() { return fObjectType; } | 119 ObjectType type() { return fObjectType; } |
120 | 120 |
121 const char* c_str() const { | 121 const char* c_str() const { |
122 switch (fObjectType) { | 122 switch (fObjectType) { |
123 case kString_PdfObjectType: | 123 case kString_PdfObjectType: |
124 case kHexString_PdfObjectType: | 124 case kHexString_PdfObjectType: |
125 case kKeyword_PdfObjectType: | 125 case kKeyword_PdfObjectType: |
| 126 case kName_PdfObjectType: |
126 return (const char*)fStr.fBuffer; | 127 return (const char*)fStr.fBuffer; |
127 | 128 |
128 default: | 129 default: |
129 // TODO(edisonn): report/warning | 130 // TODO(edisonn): report/warning |
130 return NULL; | 131 return NULL; |
131 } | 132 } |
132 } | 133 } |
133 | 134 |
134 size_t lenstr() const { | 135 size_t lenstr() const { |
135 switch (fObjectType) { | 136 switch (fObjectType) { |
136 case kString_PdfObjectType: | 137 case kString_PdfObjectType: |
137 case kHexString_PdfObjectType: | 138 case kHexString_PdfObjectType: |
138 case kKeyword_PdfObjectType: | 139 case kKeyword_PdfObjectType: |
| 140 case kName_PdfObjectType: |
139 return fStr.fBytes; | 141 return fStr.fBytes; |
140 | 142 |
141 default: | 143 default: |
142 // TODO(edisonn): report/warning | 144 // TODO(edisonn): report/warning |
143 return 0; | 145 return 0; |
144 } | 146 } |
145 } | 147 } |
146 | 148 |
147 | 149 |
148 // TODO(edisonn): NYI | 150 // TODO(edisonn): NYI |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 return ""; | 677 return ""; |
676 } | 678 } |
677 return (const char*)fStr.fBuffer; | 679 return (const char*)fStr.fBuffer; |
678 } | 680 } |
679 | 681 |
680 inline NotOwnedString strRef() { | 682 inline NotOwnedString strRef() { |
681 switch (fObjectType) { | 683 switch (fObjectType) { |
682 case kString_PdfObjectType: | 684 case kString_PdfObjectType: |
683 case kHexString_PdfObjectType: | 685 case kHexString_PdfObjectType: |
684 case kKeyword_PdfObjectType: | 686 case kKeyword_PdfObjectType: |
| 687 case kName_PdfObjectType: |
685 return fStr; | 688 return fStr; |
686 | 689 |
687 default: | 690 default: |
688 // TODO(edisonn): report/warning | 691 // TODO(edisonn): report/warning |
689 return NotOwnedString(); | 692 return NotOwnedString(); |
690 } | 693 } |
691 } | 694 } |
692 | 695 |
693 // TODO(edisonn): nameValue2 and stringValue2 are used to make code generati
on easy, | 696 // TODO(edisonn): nameValue2 and stringValue2 are used to make code generati
on easy, |
694 // but it is not a performat way to do it, since it will create an extra cop
y | 697 // but it is not a performat way to do it, since it will create an extra cop
y |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 if (!isDictionary() || hasStream()) { | 826 if (!isDictionary() || hasStream()) { |
824 return false; | 827 return false; |
825 } | 828 } |
826 | 829 |
827 fStr.fBuffer = buffer; | 830 fStr.fBuffer = buffer; |
828 fStr.fBytes = (len << 2) + kUnfilteredStreamBit; | 831 fStr.fBytes = (len << 2) + kUnfilteredStreamBit; |
829 | 832 |
830 return true; | 833 return true; |
831 } | 834 } |
832 | 835 |
833 void appendSpaces(SkString* str, int level) { | 836 static void appendSpaces(SkString* str, int level) { |
834 for (int i = 0 ; i < level; i++) { | 837 for (int i = 0 ; i < level; i++) { |
835 str->append(" "); | 838 str->append(" "); |
836 } | 839 } |
837 } | 840 } |
838 | 841 |
839 SkString toString(int firstRowLevel = 0, int level = 0) { | 842 SkString toString(int firstRowLevel = 0, int level = 0) const { |
840 SkString str; | 843 SkString str; |
841 appendSpaces(&str, firstRowLevel); | 844 appendSpaces(&str, firstRowLevel); |
842 switch (fObjectType) { | 845 switch (fObjectType) { |
843 case kInvalid_PdfObjectType: | 846 case kInvalid_PdfObjectType: |
844 str.append("__Invalid"); | 847 str.append("__Invalid"); |
845 break; | 848 break; |
846 | 849 |
847 case kBoolean_PdfObjectType: | 850 case kBoolean_PdfObjectType: |
848 str.appendf("%s", fBooleanValue ? "true" : "false"); | 851 str.appendf("%s", fBooleanValue ? "true" : "false"); |
849 break; | 852 break; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
961 SkPdfName() : SkPdfObject() { | 964 SkPdfName() : SkPdfObject() { |
962 SkPdfObject::makeName((const unsigned char*)"", this); | 965 SkPdfObject::makeName((const unsigned char*)"", this); |
963 } | 966 } |
964 public: | 967 public: |
965 SkPdfName(char* name) : SkPdfObject() { | 968 SkPdfName(char* name) : SkPdfObject() { |
966 this->makeName((const unsigned char*)name, this); | 969 this->makeName((const unsigned char*)name, this); |
967 } | 970 } |
968 }; | 971 }; |
969 | 972 |
970 #endif // EXPERIMENTAL_PDFVIEWER_PDFPARSER_NATIVE_SKPDFOBJECT_H_ | 973 #endif // EXPERIMENTAL_PDFVIEWER_PDFPARSER_NATIVE_SKPDFOBJECT_H_ |
OLD | NEW |