| OLD | NEW |
| 1 | 1 |
| 2 #include "SkPdfNativeTokenizer.h" | 2 #include "SkPdfNativeTokenizer.h" |
| 3 #include "SkPdfObject.h" | 3 #include "SkPdfObject.h" |
| 4 #include "SkPdfConfig.h" | 4 #include "SkPdfConfig.h" |
| 5 | 5 |
| 6 #include "SkPdfStreamCommonDictionary_autogen.h" | 6 #include "SkPdfStreamCommonDictionary_autogen.h" |
| 7 #include "SkPdfImageDictionary_autogen.h" | 7 #include "SkPdfImageDictionary_autogen.h" |
| 8 | 8 |
| 9 // TODO(edisonn): perf!!! | 9 // TODO(edisonn): perf!!! |
| 10 // there could be 0s between start and end! but not in the needle. | 10 // there could be 0s between start and end! but not in the needle. |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 118 |
| 119 while (start < end && !isPdfWhiteSpaceOrPdfDelimiter(*start)) { | 119 while (start < end && !isPdfWhiteSpaceOrPdfDelimiter(*start)) { |
| 120 TRACE_TK(*start); | 120 TRACE_TK(*start); |
| 121 start++; | 121 start++; |
| 122 } | 122 } |
| 123 return start; | 123 return start; |
| 124 } | 124 } |
| 125 | 125 |
| 126 // last elem has to be ] | 126 // last elem has to be ] |
| 127 static const unsigned char* readArray(int level, const unsigned char* start, con
st unsigned char* end, SkPdfObject* array, SkPdfAllocator* allocator, SkNativePa
rsedPDF* doc) { | 127 static const unsigned char* readArray(int level, const unsigned char* start, con
st unsigned char* end, SkPdfObject* array, SkPdfAllocator* allocator, SkNativePa
rsedPDF* doc) { |
| 128 if (allocator == NULL) { |
| 129 // TODO(edisonn): report/warning error |
| 130 return end; |
| 131 } |
| 132 |
| 128 TRACE_INDENT(level, "Array"); | 133 TRACE_INDENT(level, "Array"); |
| 129 while (start < end) { | 134 while (start < end) { |
| 130 // skip white spaces | 135 // skip white spaces |
| 131 start = skipPdfWhiteSpaces(level + 1, start, end); | 136 start = skipPdfWhiteSpaces(level + 1, start, end); |
| 132 | 137 |
| 133 const unsigned char* endOfToken = endOfPdfToken(level + 1, start, end); | 138 const unsigned char* endOfToken = endOfPdfToken(level + 1, start, end); |
| 134 | 139 |
| 135 if (endOfToken == start) { | 140 if (endOfToken == start) { |
| 136 // TODO(edisonn): report error in pdf file (end of stream with ] for
end of aray | 141 // TODO(edisonn): report error in pdf file (end of stream with ] for
end of aray |
| 137 return start; | 142 return start; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 break; | 206 break; |
| 202 | 207 |
| 203 case 'b': | 208 case 'b': |
| 204 // TODO(edisonn): any special meaning to backspace? | 209 // TODO(edisonn): any special meaning to backspace? |
| 205 if (hasOut) { *out = kBackspace_PdfSpecial; } | 210 if (hasOut) { *out = kBackspace_PdfSpecial; } |
| 206 out++; | 211 out++; |
| 207 in += 2; | 212 in += 2; |
| 208 break; | 213 break; |
| 209 | 214 |
| 210 case 'f': | 215 case 'f': |
| 211 *out = kFF_PdfWhiteSpace; | 216 if (hasOut) { *out = kFF_PdfWhiteSpace; } |
| 212 out++; | 217 out++; |
| 213 in += 2; | 218 in += 2; |
| 214 break; | 219 break; |
| 215 | 220 |
| 216 case kOpenedRoundBracket_PdfDelimiter: | 221 case kOpenedRoundBracket_PdfDelimiter: |
| 217 if (hasOut) { *out = kOpenedRoundBracket_PdfDelimiter; } | 222 if (hasOut) { *out = kOpenedRoundBracket_PdfDelimiter; } |
| 218 out++; | 223 out++; |
| 219 in += 2; | 224 in += 2; |
| 220 break; | 225 break; |
| 221 | 226 |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 inlineImage->addStream(start, (size_t)length); | 691 inlineImage->addStream(start, (size_t)length); |
| 687 } else { | 692 } else { |
| 688 // TODO(edisonn): report error in inline image stream (ID-EI) section | 693 // TODO(edisonn): report error in inline image stream (ID-EI) section |
| 689 // TODO(edisonn): based on filter, try to ignore a missing EI, and read
data properly | 694 // TODO(edisonn): based on filter, try to ignore a missing EI, and read
data properly |
| 690 return end; | 695 return end; |
| 691 } | 696 } |
| 692 return endEI; | 697 return endEI; |
| 693 } | 698 } |
| 694 | 699 |
| 695 static const unsigned char* readDictionary(int level, const unsigned char* start
, const unsigned char* end, SkPdfObject* dict, SkPdfAllocator* allocator, SkNati
veParsedPDF* doc) { | 700 static const unsigned char* readDictionary(int level, const unsigned char* start
, const unsigned char* end, SkPdfObject* dict, SkPdfAllocator* allocator, SkNati
veParsedPDF* doc) { |
| 701 if (allocator == NULL) { |
| 702 // TODO(edisonn): report/warning error |
| 703 return end; |
| 704 } |
| 696 TRACE_INDENT(level, "Dictionary"); | 705 TRACE_INDENT(level, "Dictionary"); |
| 697 SkPdfObject::makeEmptyDictionary(dict); | 706 SkPdfObject::makeEmptyDictionary(dict); |
| 698 | 707 |
| 699 start = skipPdfWhiteSpaces(level, start, end); | 708 start = skipPdfWhiteSpaces(level, start, end); |
| 700 SkPdfAllocator tmpStorage; // keys will be stored in dict, we can free them
immediately after set. | 709 SkPdfAllocator tmpStorage; // keys will be stored in dict, we can free them
immediately after set. |
| 701 | 710 |
| 702 while (start < end && *start == kNamed_PdfDelimiter) { | 711 while (start < end && *start == kNamed_PdfDelimiter) { |
| 703 SkPdfObject key; | 712 SkPdfObject key; |
| 704 //*start = '\0'; | 713 //*start = '\0'; |
| 705 start++; | 714 start++; |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1059 SkPdfObject* obj = fAllocator->allocObject(); | 1068 SkPdfObject* obj = fAllocator->allocObject(); |
| 1060 fUncompressedStream = nextObject(0, fUncompressedStream, fUncompress
edStreamEnd, obj, fAllocator, fDoc); | 1069 fUncompressedStream = nextObject(0, fUncompressedStream, fUncompress
edStreamEnd, obj, fAllocator, fDoc); |
| 1061 // TODO(edisonn): perf maybe we should not expand abreviation like t
his | 1070 // TODO(edisonn): perf maybe we should not expand abreviation like t
his |
| 1062 inlineImage->set(inlineImageKeyAbbreviationExpand(key), | 1071 inlineImage->set(inlineImageKeyAbbreviationExpand(key), |
| 1063 inlineImageValueAbbreviationExpand(obj)); | 1072 inlineImageValueAbbreviationExpand(obj)); |
| 1064 } | 1073 } |
| 1065 } | 1074 } |
| 1066 // TODO(edisonn): report end of data with inline image without an EI | 1075 // TODO(edisonn): report end of data with inline image without an EI |
| 1067 return inlineImage; | 1076 return inlineImage; |
| 1068 } | 1077 } |
| OLD | NEW |