Kill off some more unreachable fopen's.
[pdfium.git] / core / src / fpdfapi / fpdf_font / font_int.h
index 779f58e..6048ba9 100644 (file)
-// Copyright 2014 PDFium Authors. All rights reserved.\r
-// Use of this source code is governed by a BSD-style license that can be\r
-// found in the LICENSE file.\r
\r
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
-\r
-typedef void* FXFT_Library;\r
-class CPDF_CMapManager : public CFX_Object\r
-{\r
-public:\r
-    CPDF_CMapManager();\r
-    ~CPDF_CMapManager();\r
-    FX_LPVOID                          GetPackage(FX_BOOL bPrompt);\r
-    CPDF_CMap*                         GetPredefinedCMap(const CFX_ByteString& name, FX_BOOL bPrompt);\r
-    CPDF_CID2UnicodeMap*       GetCID2UnicodeMap(int charset, FX_BOOL bPrompt);\r
-    void                                       ReloadAll();\r
-private:\r
-    CPDF_CMap*                         LoadPredefinedCMap(const CFX_ByteString& name,  FX_BOOL bPrompt);\r
-    CPDF_CID2UnicodeMap*       LoadCID2UnicodeMap(int charset, FX_BOOL bPrompt);\r
-    void                                       DropAll(FX_BOOL bReload);\r
-#ifndef _FPDFAPI_MINI_\r
-    FX_BOOL                                    m_bPrompted;\r
-    FX_LPVOID                          m_pPackage;\r
-#endif\r
-    CFX_MapByteStringToPtr     m_CMaps;\r
-    CPDF_CID2UnicodeMap*       m_CID2UnicodeMaps[6];\r
-};\r
-class CPDF_FontGlobals : public CFX_Object\r
-{\r
-public:\r
-    CPDF_FontGlobals();\r
-    ~CPDF_FontGlobals();\r
-    void                               ClearAll();\r
-    void                               Clear(void* key);\r
-    CPDF_Font*                 Find(void* key, int index);\r
-    void                               Set(void* key, int index, CPDF_Font* pFont);\r
-    CFX_MapPtrToPtr            m_pStockMap;\r
-    CPDF_CMapManager   m_CMapManager;\r
-    struct {\r
-        const struct FXCMAP_CMap*      m_pMapList;\r
-        int                            m_Count;\r
-    } m_EmbeddedCharsets[5];\r
-    struct {\r
-        const FX_WORD* m_pMap;\r
-        int                            m_Count;\r
-    } m_EmbeddedToUnicodes[5];\r
-    FX_LPBYTE                  m_pContrastRamps;\r
-};\r
-struct _CMap_CodeRange {\r
-    int                        m_CharSize;\r
-    FX_BYTE            m_Lower[4];\r
-    FX_BYTE            m_Upper[4];\r
-};\r
-class CPDF_CMapParser : public CFX_Object\r
-{\r
-public:\r
-    CPDF_CMapParser();\r
-    ~CPDF_CMapParser() {}\r
-    FX_BOOL    Initialize(CPDF_CMap*);\r
-    void       ParseWord(FX_BSTR str);\r
-    CFX_BinaryBuf      m_AddMaps;\r
-private:\r
-    CPDF_CMap* m_pCMap;\r
-    int                                m_Status;\r
-    int                                m_CodeSeq;\r
-    FX_DWORD           m_CodePoints[4];\r
-    CFX_ArrayTemplate<_CMap_CodeRange> m_CodeRanges;\r
-    CFX_ByteString     m_Registry, m_Ordering, m_Supplement;\r
-    CFX_ByteString     m_LastWord;\r
-};\r
-#define CIDCODING_UNKNOWN      0\r
-#define CIDCODING_GB           1\r
-#define CIDCODING_BIG5         2\r
-#define CIDCODING_JIS          3\r
-#define CIDCODING_KOREA                4\r
-#define CIDCODING_UCS2         5\r
-#define CIDCODING_CID          6\r
-#define CIDCODING_UTF16                7\r
-class CPDF_CMap : public CFX_Object\r
-{\r
-public:\r
-    CPDF_CMap();\r
-    FX_BOOL                                    LoadPredefined(CPDF_CMapManager* pMgr, const FX_CHAR* name, FX_BOOL bPromptCJK);\r
-    FX_BOOL                                    LoadEmbedded(FX_LPCBYTE pData, FX_DWORD dwSize);\r
-    void                                       Release();\r
-    FX_BOOL                                    IsLoaded() const\r
-    {\r
-        return m_bLoaded;\r
-    }\r
-    int                                                GetCharset()\r
-    {\r
-        return m_Charset;\r
-    }\r
-    FX_BOOL                                    IsVertWriting() const\r
-    {\r
-        return m_bVertical;\r
-    }\r
-    FX_WORD                                    CIDFromCharCode(FX_DWORD charcode) const;\r
-    FX_DWORD                           CharCodeFromCID(FX_WORD CID) const;\r
-    int                                                GetCharSize(FX_DWORD charcode) const;\r
-    FX_DWORD                           GetNextChar(const FX_CHAR* pString, int& offset) const;\r
-    int                                                CountChar(const FX_CHAR* pString, int size) const;\r
-    int                                                AppendChar(FX_LPSTR str, FX_DWORD charcode) const;\r
-    typedef enum {OneByte, TwoBytes, MixedTwoBytes, MixedFourBytes} CodingScheme;\r
-protected:\r
-    ~CPDF_CMap();\r
-    friend class                       CPDF_CMapParser;\r
-    friend class                       CPDF_CMapManager;\r
-    friend class                       CPDF_CIDFont;\r
-protected:\r
-    CFX_ByteString                     m_PredefinedCMap;\r
-    FX_BOOL                                    m_bVertical;\r
-    int                                                m_Charset, m_Coding;\r
-    CodingScheme                       m_CodingScheme;\r
-    int                                                m_nCodeRanges;\r
-    FX_BYTE*                           m_pLeadingBytes;\r
-    FX_WORD*                           m_pMapping;\r
-    FX_LPBYTE                          m_pAddMapping;\r
-    FX_BOOL                                    m_bLoaded;\r
-    const FXCMAP_CMap*         m_pEmbedMap;\r
-    CPDF_CMap*                         m_pUseMap;\r
-};\r
-class CPDF_PredefinedCMap\r
-{\r
-public:\r
-    FX_LPCSTR  m_pName;\r
-    int                        m_Charset;\r
-    int                        m_Coding;\r
-    CPDF_CMap::CodingScheme    m_CodingScheme;\r
-    FX_DWORD   m_LeadingSegCount;\r
-    FX_BYTE            m_LeadingSegs[4];\r
-};\r
-typedef struct _FileHeader {\r
-    FX_BYTE            btTag[4];\r
-    FX_BYTE            btVersion;\r
-    FX_BYTE            btFormat;\r
-    FX_BYTE            btReserved1[2];\r
-    FX_DWORD   dwStartIndex;\r
-    FX_DWORD   dwEndIndex;\r
-    FX_DWORD   dwDataSize;\r
-    FX_DWORD   dwDataOffset;\r
-    FX_DWORD   dwRecordSize;\r
-} FXMP_FILEHEADER;\r
-class CPDF_FXMP : public CFX_Object\r
-{\r
-public:\r
-    CPDF_FXMP()\r
-    {\r
-        m_pHeader = NULL;\r
-        m_pTable = NULL;\r
-    }\r
-    ~CPDF_FXMP()\r
-    {\r
-        if (m_pHeader) {\r
-            FX_Free(m_pHeader);\r
-        }\r
-    }\r
-    FX_BOOL            IsLoaded()\r
-    {\r
-        return m_pTable != NULL;\r
-    }\r
-    FX_BOOL            LoadFile(FX_LPVOID pPackage, FX_LPCSTR fileid);\r
-    FX_LPBYTE  GetRecord(FX_DWORD index);\r
-private:\r
-    FXMP_FILEHEADER*   m_pHeader;\r
-    FX_LPBYTE  m_pTable;\r
-};\r
-class CPDF_CID2UnicodeMap : public CFX_Object\r
-{\r
-public:\r
-    CPDF_CID2UnicodeMap();\r
-    ~CPDF_CID2UnicodeMap();\r
-    FX_BOOL            Initialize();\r
-    FX_BOOL            IsLoaded();\r
-    void               Load(CPDF_CMapManager* pMgr, int charset, FX_BOOL bPromptCJK);\r
-    FX_WCHAR   UnicodeFromCID(FX_WORD CID);\r
-protected:\r
-    int                        m_Charset;\r
-    const FX_WORD*     m_pEmbeddedMap;\r
-    FX_DWORD   m_EmbeddedCount;\r
-#ifndef _FPDFAPI_MINI_\r
-    CPDF_FXMP* m_pExternalMap;\r
-#endif\r
-};\r
-class CPDF_ToUnicodeMap : public CFX_Object\r
-{\r
-public:\r
-    void                                       Load(CPDF_Stream* pStream);\r
-    CFX_WideString                     Lookup(FX_DWORD charcode);\r
-    FX_DWORD                           ReverseLookup(FX_WCHAR unicode);\r
-protected:\r
-    CFX_CMapDWordToDWord       m_Map;\r
-    CPDF_CID2UnicodeMap*       m_pBaseMap;\r
-    CFX_WideTextBuf                    m_MultiCharBuf;\r
-};\r
-class CPDF_FontCharMap : public CFX_CharMap, public CFX_Object\r
-{\r
-public:\r
-    CPDF_FontCharMap(CPDF_Font* pFont);\r
-    CPDF_Font*         m_pFont;\r
-};\r
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+typedef void* FXFT_Library;
+class CPDF_CMapManager : public CFX_Object
+{
+public:
+    CPDF_CMapManager();
+    ~CPDF_CMapManager();
+    FX_LPVOID                          GetPackage(FX_BOOL bPrompt);
+    CPDF_CMap*                         GetPredefinedCMap(const CFX_ByteString& name, FX_BOOL bPrompt);
+    CPDF_CID2UnicodeMap*       GetCID2UnicodeMap(int charset, FX_BOOL bPrompt);
+    void                                       ReloadAll();
+private:
+    CPDF_CMap*                         LoadPredefinedCMap(const CFX_ByteString& name,  FX_BOOL bPrompt);
+    CPDF_CID2UnicodeMap*       LoadCID2UnicodeMap(int charset, FX_BOOL bPrompt);
+    void                                       DropAll(FX_BOOL bReload);
+    FX_BOOL                                    m_bPrompted;
+    CFX_MapByteStringToPtr     m_CMaps;
+    CPDF_CID2UnicodeMap*       m_CID2UnicodeMaps[6];
+};
+class CPDF_FontGlobals : public CFX_Object
+{
+public:
+    CPDF_FontGlobals();
+    ~CPDF_FontGlobals();
+    void                               ClearAll();
+    void                               Clear(void* key);
+    CPDF_Font*                 Find(void* key, int index);
+    void                               Set(void* key, int index, CPDF_Font* pFont);
+    CFX_MapPtrToPtr            m_pStockMap;
+    CPDF_CMapManager   m_CMapManager;
+    struct {
+        const struct FXCMAP_CMap*      m_pMapList;
+        int                            m_Count;
+    } m_EmbeddedCharsets[NUMBER_OF_CIDSETS];
+    struct {
+        const FX_WORD* m_pMap;
+        int                            m_Count;
+    } m_EmbeddedToUnicodes[NUMBER_OF_CIDSETS];
+    FX_LPBYTE                  m_pContrastRamps;
+};
+struct _CMap_CodeRange {
+    int                        m_CharSize;
+    FX_BYTE            m_Lower[4];
+    FX_BYTE            m_Upper[4];
+};
+class CPDF_CMapParser : public CFX_Object
+{
+public:
+    CPDF_CMapParser();
+    ~CPDF_CMapParser() {}
+    FX_BOOL    Initialize(CPDF_CMap*);
+    void       ParseWord(FX_BSTR str);
+    CFX_BinaryBuf      m_AddMaps;
+private:
+    CPDF_CMap* m_pCMap;
+    int                                m_Status;
+    int                                m_CodeSeq;
+    FX_DWORD           m_CodePoints[4];
+    CFX_ArrayTemplate<_CMap_CodeRange> m_CodeRanges;
+    CFX_ByteString     m_Registry, m_Ordering, m_Supplement;
+    CFX_ByteString     m_LastWord;
+};
+#define CIDCODING_UNKNOWN      0
+#define CIDCODING_GB           1
+#define CIDCODING_BIG5         2
+#define CIDCODING_JIS          3
+#define CIDCODING_KOREA                4
+#define CIDCODING_UCS2         5
+#define CIDCODING_CID          6
+#define CIDCODING_UTF16                7
+class CPDF_CMap : public CFX_Object
+{
+public:
+    CPDF_CMap();
+    FX_BOOL                                    LoadPredefined(CPDF_CMapManager* pMgr, const FX_CHAR* name, FX_BOOL bPromptCJK);
+    FX_BOOL                                    LoadEmbedded(FX_LPCBYTE pData, FX_DWORD dwSize);
+    void                                       Release();
+    FX_BOOL                                    IsLoaded() const
+    {
+        return m_bLoaded;
+    }
+    int                                                GetCharset()
+    {
+        return m_Charset;
+    }
+    FX_BOOL                                    IsVertWriting() const
+    {
+        return m_bVertical;
+    }
+    FX_WORD                                    CIDFromCharCode(FX_DWORD charcode) const;
+    FX_DWORD                           CharCodeFromCID(FX_WORD CID) const;
+    int                                                GetCharSize(FX_DWORD charcode) const;
+    FX_DWORD                           GetNextChar(const FX_CHAR* pString, int& offset) const;
+    int                                                CountChar(const FX_CHAR* pString, int size) const;
+    int                                                AppendChar(FX_LPSTR str, FX_DWORD charcode) const;
+    typedef enum {OneByte, TwoBytes, MixedTwoBytes, MixedFourBytes} CodingScheme;
+protected:
+    ~CPDF_CMap();
+    friend class                       CPDF_CMapParser;
+    friend class                       CPDF_CMapManager;
+    friend class                       CPDF_CIDFont;
+protected:
+    CFX_ByteString                     m_PredefinedCMap;
+    FX_BOOL                                    m_bVertical;
+    int                                                m_Charset, m_Coding;
+    CodingScheme                       m_CodingScheme;
+    int                                                m_nCodeRanges;
+    FX_BYTE*                           m_pLeadingBytes;
+    FX_WORD*                           m_pMapping;
+    FX_LPBYTE                          m_pAddMapping;
+    FX_BOOL                                    m_bLoaded;
+    const FXCMAP_CMap*         m_pEmbedMap;
+    CPDF_CMap*                         m_pUseMap;
+};
+class CPDF_PredefinedCMap
+{
+public:
+    FX_LPCSTR  m_pName;
+    int                        m_Charset;
+    int                        m_Coding;
+    CPDF_CMap::CodingScheme    m_CodingScheme;
+    FX_DWORD   m_LeadingSegCount;
+    FX_BYTE            m_LeadingSegs[4];
+};
+typedef struct _FileHeader {
+    FX_BYTE            btTag[4];
+    FX_BYTE            btVersion;
+    FX_BYTE            btFormat;
+    FX_BYTE            btReserved1[2];
+    FX_DWORD   dwStartIndex;
+    FX_DWORD   dwEndIndex;
+    FX_DWORD   dwDataSize;
+    FX_DWORD   dwDataOffset;
+    FX_DWORD   dwRecordSize;
+} FXMP_FILEHEADER;
+class CPDF_CID2UnicodeMap : public CFX_Object
+{
+public:
+    CPDF_CID2UnicodeMap();
+    ~CPDF_CID2UnicodeMap();
+    FX_BOOL            Initialize();
+    FX_BOOL            IsLoaded();
+    void               Load(CPDF_CMapManager* pMgr, int charset, FX_BOOL bPromptCJK);
+    FX_WCHAR   UnicodeFromCID(FX_WORD CID);
+protected:
+    int                        m_Charset;
+    const FX_WORD*     m_pEmbeddedMap;
+    FX_DWORD   m_EmbeddedCount;
+};
+class CPDF_ToUnicodeMap : public CFX_Object
+{
+public:
+    void                                       Load(CPDF_Stream* pStream);
+    CFX_WideString                     Lookup(FX_DWORD charcode);
+    FX_DWORD                           ReverseLookup(FX_WCHAR unicode);
+protected:
+    CFX_CMapDWordToDWord       m_Map;
+    CPDF_CID2UnicodeMap*       m_pBaseMap;
+    CFX_WideTextBuf                    m_MultiCharBuf;
+};
+class CPDF_FontCharMap : public CFX_CharMap, public CFX_Object
+{
+public:
+    CPDF_FontCharMap(CPDF_Font* pFont);
+    CPDF_Font*         m_pFont;
+};