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 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 | 832 |
833 return true; | 833 return true; |
834 } | 834 } |
835 | 835 |
836 static void appendSpaces(SkString* str, int level) { | 836 static void appendSpaces(SkString* str, int level) { |
837 for (int i = 0 ; i < level; i++) { | 837 for (int i = 0 ; i < level; i++) { |
838 str->append(" "); | 838 str->append(" "); |
839 } | 839 } |
840 } | 840 } |
841 | 841 |
842 SkString toString(int firstRowLevel = 0, int level = 0) const { | 842 SkString toString(int firstRowLevel = 0, int level = 0) { |
843 SkString str; | 843 SkString str; |
844 appendSpaces(&str, firstRowLevel); | 844 appendSpaces(&str, firstRowLevel); |
845 switch (fObjectType) { | 845 switch (fObjectType) { |
846 case kInvalid_PdfObjectType: | 846 case kInvalid_PdfObjectType: |
847 str.append("__Invalid"); | 847 str.append("__Invalid"); |
848 break; | 848 break; |
849 | 849 |
850 case kBoolean_PdfObjectType: | 850 case kBoolean_PdfObjectType: |
851 str.appendf("%s", fBooleanValue ? "true" : "false"); | 851 str.appendf("%s", fBooleanValue ? "true" : "false"); |
852 break; | 852 break; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
898 SkPdfObject* obj = NULL; | 898 SkPdfObject* obj = NULL; |
899 const char* key = NULL; | 899 const char* key = NULL; |
900 str.append("<<\n"); | 900 str.append("<<\n"); |
901 while ((key = iter.next(&obj)) != NULL) { | 901 while ((key = iter.next(&obj)) != NULL) { |
902 appendSpaces(&str, level + 2); | 902 appendSpaces(&str, level + 2); |
903 str.appendf("/%s %s\n", key, obj->toString(0, level + st
rlen(key) + 4).c_str()); | 903 str.appendf("/%s %s\n", key, obj->toString(0, level + st
rlen(key) + 4).c_str()); |
904 } | 904 } |
905 appendSpaces(&str, level); | 905 appendSpaces(&str, level); |
906 str.append(">>"); | 906 str.append(">>"); |
907 if (hasStream()) { | 907 if (hasStream()) { |
908 str.append("stream HAS_STREAM endstream"); | 908 const unsigned char* stream = NULL; |
| 909 size_t length = 0; |
| 910 if (GetFilteredStreamRef(&stream, &length)) { |
| 911 str.append("stream"); |
| 912 str.append((const char*)stream, length > 256 ? 256 :
length); |
| 913 str.append("endstream"); |
| 914 } else { |
| 915 str.append("stream STREAM_ERROR endstream"); |
| 916 } |
909 } | 917 } |
910 } | 918 } |
911 break; | 919 break; |
912 | 920 |
913 case kNull_PdfObjectType: | 921 case kNull_PdfObjectType: |
914 str = "NULL"; | 922 str = "NULL"; |
915 break; | 923 break; |
916 | 924 |
917 case kReference_PdfObjectType: | 925 case kReference_PdfObjectType: |
918 str.appendf("%i %i R", fRef.fId, fRef.fGen); | 926 str.appendf("%i %i R", fRef.fId, fRef.fGen); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 SkPdfName() : SkPdfObject() { | 972 SkPdfName() : SkPdfObject() { |
965 SkPdfObject::makeName((const unsigned char*)"", this); | 973 SkPdfObject::makeName((const unsigned char*)"", this); |
966 } | 974 } |
967 public: | 975 public: |
968 SkPdfName(char* name) : SkPdfObject() { | 976 SkPdfName(char* name) : SkPdfObject() { |
969 this->makeName((const unsigned char*)name, this); | 977 this->makeName((const unsigned char*)name, this); |
970 } | 978 } |
971 }; | 979 }; |
972 | 980 |
973 #endif // EXPERIMENTAL_PDFVIEWER_PDFPARSER_NATIVE_SKPDFOBJECT_H_ | 981 #endif // EXPERIMENTAL_PDFVIEWER_PDFPARSER_NATIVE_SKPDFOBJECT_H_ |
OLD | NEW |