Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1299)

Side by Side Diff: core/fpdfapi/fpdf_page/fpdf_page_parser.cpp

Issue 1847333004: Remove _FXBSTR* and calls to FX_BSTRC. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | xfa/fde/css/fde_css.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "core/fpdfapi/fpdf_page/pageint.h" 7 #include "core/fpdfapi/fpdf_page/pageint.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 23 matching lines...) Expand all
34 namespace { 34 namespace {
35 35
36 const char kPathOperatorSubpath = 'm'; 36 const char kPathOperatorSubpath = 'm';
37 const char kPathOperatorLine = 'l'; 37 const char kPathOperatorLine = 'l';
38 const char kPathOperatorCubicBezier1 = 'c'; 38 const char kPathOperatorCubicBezier1 = 'c';
39 const char kPathOperatorCubicBezier2 = 'v'; 39 const char kPathOperatorCubicBezier2 = 'v';
40 const char kPathOperatorCubicBezier3 = 'y'; 40 const char kPathOperatorCubicBezier3 = 'y';
41 const char kPathOperatorClosePath = 'h'; 41 const char kPathOperatorClosePath = 'h';
42 const char kPathOperatorRectangle[] = "re"; 42 const char kPathOperatorRectangle[] = "re";
43 43
44 struct _FX_BSTR { 44 struct SimpleString {
45 const FX_CHAR* m_Ptr; 45 const FX_CHAR* m_Ptr;
46 int m_Size; 46 size_t m_Size;
47 }; 47 };
48 #define _FX_BSTRC(str) \ 48 #define MakeSimpleString(str) \
49 { str, sizeof(str) - 1 } 49 { str, strlen(str) }
50 50
51 struct PDF_AbbrPairs { 51 struct PDF_AbbrPairs {
Tom Sepez 2016/04/01 21:45:53 nit: singular (e.g AbbrPair).
dsinclair 2016/04/02 00:13:33 Done.
52 _FX_BSTR full_name; 52 SimpleString full_name;
Tom Sepez 2016/04/01 21:45:53 Actually, its hard to justify this being anything
dsinclair 2016/04/02 00:13:33 Done.
53 _FX_BSTR abbr; 53 SimpleString abbr;
54 }; 54 };
55 55
56 const PDF_AbbrPairs PDF_InlineKeyAbbr[] = { 56 const PDF_AbbrPairs PDF_InlineKeyAbbr[] = {
57 {_FX_BSTRC("BitsPerComponent"), _FX_BSTRC("BPC")}, 57 {MakeSimpleString("BitsPerComponent"), MakeSimpleString("BPC")},
Tom Sepez 2016/04/01 16:43:03 This theoretically generates static initializers s
dsinclair 2016/04/01 20:18:34 Ah, I failed to understand the comment in pdfium:1
58 {_FX_BSTRC("ColorSpace"), _FX_BSTRC("CS")}, 58 {MakeSimpleString("ColorSpace"), MakeSimpleString("CS")},
59 {_FX_BSTRC("Decode"), _FX_BSTRC("D")}, 59 {MakeSimpleString("Decode"), MakeSimpleString("D")},
60 {_FX_BSTRC("DecodeParms"), _FX_BSTRC("DP")}, 60 {MakeSimpleString("DecodeParms"), MakeSimpleString("DP")},
61 {_FX_BSTRC("Filter"), _FX_BSTRC("F")}, 61 {MakeSimpleString("Filter"), MakeSimpleString("F")},
62 {_FX_BSTRC("Height"), _FX_BSTRC("H")}, 62 {MakeSimpleString("Height"), MakeSimpleString("H")},
63 {_FX_BSTRC("ImageMask"), _FX_BSTRC("IM")}, 63 {MakeSimpleString("ImageMask"), MakeSimpleString("IM")},
64 {_FX_BSTRC("Interpolate"), _FX_BSTRC("I")}, 64 {MakeSimpleString("Interpolate"), MakeSimpleString("I")},
65 {_FX_BSTRC("Width"), _FX_BSTRC("W")}, 65 {MakeSimpleString("Width"), MakeSimpleString("W")},
66 }; 66 };
67 67
68 const PDF_AbbrPairs PDF_InlineValueAbbr[] = { 68 const PDF_AbbrPairs PDF_InlineValueAbbr[] = {
69 {_FX_BSTRC("DeviceGray"), _FX_BSTRC("G")}, 69 {MakeSimpleString("DeviceGray"), MakeSimpleString("G")},
70 {_FX_BSTRC("DeviceRGB"), _FX_BSTRC("RGB")}, 70 {MakeSimpleString("DeviceRGB"), MakeSimpleString("RGB")},
71 {_FX_BSTRC("DeviceCMYK"), _FX_BSTRC("CMYK")}, 71 {MakeSimpleString("DeviceCMYK"), MakeSimpleString("CMYK")},
72 {_FX_BSTRC("Indexed"), _FX_BSTRC("I")}, 72 {MakeSimpleString("Indexed"), MakeSimpleString("I")},
73 {_FX_BSTRC("ASCIIHexDecode"), _FX_BSTRC("AHx")}, 73 {MakeSimpleString("ASCIIHexDecode"), MakeSimpleString("AHx")},
74 {_FX_BSTRC("ASCII85Decode"), _FX_BSTRC("A85")}, 74 {MakeSimpleString("ASCII85Decode"), MakeSimpleString("A85")},
75 {_FX_BSTRC("LZWDecode"), _FX_BSTRC("LZW")}, 75 {MakeSimpleString("LZWDecode"), MakeSimpleString("LZW")},
76 {_FX_BSTRC("FlateDecode"), _FX_BSTRC("Fl")}, 76 {MakeSimpleString("FlateDecode"), MakeSimpleString("Fl")},
77 {_FX_BSTRC("RunLengthDecode"), _FX_BSTRC("RL")}, 77 {MakeSimpleString("RunLengthDecode"), MakeSimpleString("RL")},
78 {_FX_BSTRC("CCITTFaxDecode"), _FX_BSTRC("CCF")}, 78 {MakeSimpleString("CCITTFaxDecode"), MakeSimpleString("CCF")},
79 {_FX_BSTRC("DCTDecode"), _FX_BSTRC("DCT")}, 79 {MakeSimpleString("DCTDecode"), MakeSimpleString("DCT")},
80 }; 80 };
81 81
82 struct AbbrReplacementOp { 82 struct AbbrReplacementOp {
83 bool is_replace_key; 83 bool is_replace_key;
84 CFX_ByteString key; 84 CFX_ByteString key;
85 CFX_ByteStringC replacement; 85 CFX_ByteStringC replacement;
86 }; 86 };
87 87
88 class CPDF_StreamParserAutoClearer { 88 class CPDF_StreamParserAutoClearer {
89 public: 89 public:
90 CPDF_StreamParserAutoClearer(CPDF_StreamParser** scoped_variable, 90 CPDF_StreamParserAutoClearer(CPDF_StreamParser** scoped_variable,
91 CPDF_StreamParser* new_parser) 91 CPDF_StreamParser* new_parser)
92 : scoped_variable_(scoped_variable) { 92 : scoped_variable_(scoped_variable) {
93 *scoped_variable_ = new_parser; 93 *scoped_variable_ = new_parser;
94 } 94 }
95 ~CPDF_StreamParserAutoClearer() { *scoped_variable_ = NULL; } 95 ~CPDF_StreamParserAutoClearer() { *scoped_variable_ = NULL; }
96 96
97 private: 97 private:
98 CPDF_StreamParser** scoped_variable_; 98 CPDF_StreamParser** scoped_variable_;
99 }; 99 };
100 100
101 CFX_ByteStringC PDF_FindFullName(const PDF_AbbrPairs* table, 101 CFX_ByteStringC PDF_FindFullName(const PDF_AbbrPairs* table,
102 size_t count, 102 size_t count,
103 const CFX_ByteStringC& abbr) { 103 const CFX_ByteStringC& abbr) {
104 for (size_t i = 0; i < count; ++i) { 104 for (size_t i = 0; i < count; ++i) {
Tom Sepez 2016/04/01 16:43:03 std::find using cfx_ByteStringC's == operator shou
dsinclair 2016/04/02 00:13:33 Acknowledged.
105 if (abbr.GetLength() != table[i].abbr.m_Size) 105 if (abbr.GetLength() < 0 ||
106 static_cast<size_t>(abbr.GetLength()) != table[i].abbr.m_Size)
106 continue; 107 continue;
107 if (memcmp(abbr.GetPtr(), table[i].abbr.m_Ptr, abbr.GetLength())) 108 if (memcmp(abbr.GetPtr(), table[i].abbr.m_Ptr, abbr.GetLength()))
108 continue; 109 continue;
109 return CFX_ByteStringC(table[i].full_name.m_Ptr, table[i].full_name.m_Size); 110 return CFX_ByteStringC(table[i].full_name.m_Ptr, table[i].full_name.m_Size);
110 } 111 }
111 return CFX_ByteStringC(); 112 return CFX_ByteStringC();
112 } 113 }
113 114
114 } // namespace 115 } // namespace
115 116
(...skipping 1705 matching lines...) Expand 10 before | Expand all | Expand 10 after
1821 } else { 1822 } else {
1822 PDF_ReplaceAbbr(pElement); 1823 PDF_ReplaceAbbr(pElement);
1823 } 1824 }
1824 } 1825 }
1825 break; 1826 break;
1826 } 1827 }
1827 default: 1828 default:
1828 break; 1829 break;
1829 } 1830 }
1830 } 1831 }
OLDNEW
« no previous file with comments | « no previous file | xfa/fde/css/fde_css.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698