OLD | NEW |
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/include/fpdfapi/fpdf_parser.h" | 7 #include "core/include/fpdfapi/fpdf_parser.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 1855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1866 } | 1866 } |
1867 } | 1867 } |
1868 GetNextChar(ch); | 1868 GetNextChar(ch); |
1869 return buf.GetByteString(); | 1869 return buf.GetByteString(); |
1870 } | 1870 } |
1871 CFX_ByteString CPDF_SyntaxParser::ReadHexString() { | 1871 CFX_ByteString CPDF_SyntaxParser::ReadHexString() { |
1872 uint8_t ch; | 1872 uint8_t ch; |
1873 if (!GetNextChar(ch)) | 1873 if (!GetNextChar(ch)) |
1874 return CFX_ByteString(); | 1874 return CFX_ByteString(); |
1875 | 1875 |
1876 CFX_BinaryBuf buf; | 1876 CFX_ByteTextBuf buf; |
1877 bool bFirst = true; | 1877 bool bFirst = true; |
1878 uint8_t code = 0; | 1878 uint8_t code = 0; |
1879 while (1) { | 1879 while (1) { |
1880 if (ch == '>') | 1880 if (ch == '>') |
1881 break; | 1881 break; |
1882 | 1882 |
1883 if (std::isxdigit(ch)) { | 1883 if (std::isxdigit(ch)) { |
1884 int val = FXSYS_toHexDigit(ch); | 1884 int val = FXSYS_toHexDigit(ch); |
1885 if (bFirst) { | 1885 if (bFirst) { |
1886 code = val * 16; | 1886 code = val * 16; |
1887 } else { | 1887 } else { |
1888 code += val; | 1888 code += val; |
1889 buf.AppendByte((uint8_t)code); | 1889 buf.AppendByte(code); |
1890 } | 1890 } |
1891 bFirst = !bFirst; | 1891 bFirst = !bFirst; |
1892 } | 1892 } |
1893 | 1893 |
1894 if (!GetNextChar(ch)) | 1894 if (!GetNextChar(ch)) |
1895 break; | 1895 break; |
1896 } | 1896 } |
1897 if (!bFirst) | 1897 if (!bFirst) |
1898 buf.AppendByte((uint8_t)code); | 1898 buf.AppendByte(code); |
1899 | 1899 |
1900 return buf.GetByteString(); | 1900 return buf.GetByteString(); |
1901 } | 1901 } |
1902 void CPDF_SyntaxParser::ToNextLine() { | 1902 void CPDF_SyntaxParser::ToNextLine() { |
1903 uint8_t ch; | 1903 uint8_t ch; |
1904 while (GetNextChar(ch)) { | 1904 while (GetNextChar(ch)) { |
1905 if (ch == '\n') { | 1905 if (ch == '\n') { |
1906 break; | 1906 break; |
1907 } | 1907 } |
1908 if (ch == '\r') { | 1908 if (ch == '\r') { |
(...skipping 2831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4740 if (!m_pLinearizedDict) | 4740 if (!m_pLinearizedDict) |
4741 return -1; | 4741 return -1; |
4742 CPDF_Array* pRange = m_pLinearizedDict->GetArrayBy("H"); | 4742 CPDF_Array* pRange = m_pLinearizedDict->GetArrayBy("H"); |
4743 if (!pRange) | 4743 if (!pRange) |
4744 return -1; | 4744 return -1; |
4745 CPDF_Object* pStreamLen = pRange->GetElementValue(1); | 4745 CPDF_Object* pStreamLen = pRange->GetElementValue(1); |
4746 if (!pStreamLen) | 4746 if (!pStreamLen) |
4747 return -1; | 4747 return -1; |
4748 return pStreamLen->GetInteger(); | 4748 return pStreamLen->GetInteger(); |
4749 } | 4749 } |
OLD | NEW |