• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2017 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef CORE_FPDFAPI_FONT_CPDF_TOUNICODEMAP_H_
8 #define CORE_FPDFAPI_FONT_CPDF_TOUNICODEMAP_H_
9 
10 #include <map>
11 
12 #include "core/fxcrt/cfx_widetextbuf.h"
13 #include "core/fxcrt/unowned_ptr.h"
14 
15 class CPDF_CID2UnicodeMap;
16 class CPDF_SimpleParser;
17 class CPDF_Stream;
18 
19 class CPDF_ToUnicodeMap {
20  public:
21   explicit CPDF_ToUnicodeMap(const CPDF_Stream* pStream);
22   ~CPDF_ToUnicodeMap();
23 
24   WideString Lookup(uint32_t charcode) const;
25   uint32_t ReverseLookup(wchar_t unicode) const;
26 
27  private:
28   friend class cpdf_tounicodemap_StringToCode_Test;
29   friend class cpdf_tounicodemap_StringToWideString_Test;
30 
31   static pdfium::Optional<uint32_t> StringToCode(ByteStringView str);
32   static WideString StringToWideString(ByteStringView str);
33 
34   void Load(const CPDF_Stream* pStream);
35   void HandleBeginBFChar(CPDF_SimpleParser* pParser);
36   void HandleBeginBFRange(CPDF_SimpleParser* pParser);
37   uint32_t GetUnicode() const;
38   void SetCode(uint32_t srccode, WideString destcode);
39 
40   std::map<uint32_t, uint32_t> m_Map;
41   UnownedPtr<const CPDF_CID2UnicodeMap> m_pBaseMap;
42   CFX_WideTextBuf m_MultiCharBuf;
43 };
44 
45 #endif  // CORE_FPDFAPI_FONT_CPDF_TOUNICODEMAP_H_
46