summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi/fpdf_font
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-08-19 09:49:24 -0700
committerTom Sepez <tsepez@chromium.org>2015-08-19 09:49:24 -0700
commit09d33bcd82a82cb55039d41651df13e17d6c3e59 (patch)
tree7a748b7570ff6ad0321c4334319bac101da0e6af /core/src/fpdfapi/fpdf_font
parent1b0023986bc22ce362097b25deb9746b693ef235 (diff)
downloadpdfium-09d33bcd82a82cb55039d41651df13e17d6c3e59.tar.xz
Merge to XFA: CFX_MapByteStringToPtr considered harmful (combo patch).
New manual edits: two unused members deleted, one adapted. fde_csscache.cpp fde_csscache.h fpdfxfa_doc.h fx_ge_fontmap.cpp (cherry picked from commit 1d9dbd53b205b2b4d9e75a7eeb95e80837917ea3) (cherry picked from commit cb4d0ea68308e3c51a6ba9551b393bb2f639afc4) (cherry picked from commit 9cf44c2ed09a8b2ff243eb6dbb72a8cceae1b5ff) (cherry picked from commit 2a2a6aa7f51352fc481e78f6ad9d41f2738bcc48) (cherry picked from commit ce4ffb8183af3fa2bb5133f0f7370a88e064c516) Original Review URL: https://codereview.chromium.org/1297723002 . R=thestig@chromium.org Review URL: https://codereview.chromium.org/1301793002 .
Diffstat (limited to 'core/src/fpdfapi/fpdf_font')
-rw-r--r--core/src/fpdfapi/fpdf_font/font_int.h16
-rw-r--r--core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp51
2 files changed, 32 insertions, 35 deletions
diff --git a/core/src/fpdfapi/fpdf_font/font_int.h b/core/src/fpdfapi/fpdf_font/font_int.h
index d7cbe1b0b5..30223ad63a 100644
--- a/core/src/fpdfapi/fpdf_font/font_int.h
+++ b/core/src/fpdfapi/fpdf_font/font_int.h
@@ -3,10 +3,22 @@
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
#ifndef CORE_SRC_FPDFAPI_FPDF_FONT_FONT_INT_H_
#define CORE_SRC_FPDFAPI_FPDF_FONT_FONT_INT_H_
+#include <map>
+
+#include "../../../include/fxcrt/fx_basic.h"
+#include "../../../include/fpdfapi/fpdf_resource.h"
+
+class CPDF_CID2UnicodeMap;
+class CPDF_CMap;
+class CPDF_Font;
+class CPDF_Stream;
+
typedef void* FXFT_Library;
+
class CPDF_CMapManager {
public:
CPDF_CMapManager();
@@ -19,9 +31,9 @@ class CPDF_CMapManager {
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;
+ std::map<CFX_ByteString, CPDF_CMap*> m_CMaps;
CPDF_CID2UnicodeMap* m_CID2UnicodeMaps[6];
};
class CPDF_FontGlobals {
diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
index 6c728242e6..ebb99fad63 100644
--- a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
+++ b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
@@ -22,19 +22,24 @@ CPDF_CMapManager::CPDF_CMapManager() {
FXSYS_memset(m_CID2UnicodeMaps, 0, sizeof m_CID2UnicodeMaps);
}
CPDF_CMapManager::~CPDF_CMapManager() {
- DropAll(FALSE);
+ for (const auto& pair : m_CMaps) {
+ delete pair.second;
+ }
+ m_CMaps.clear();
+ for (int i = 0; i < FX_ArraySize(m_CID2UnicodeMaps); ++i) {
+ delete m_CID2UnicodeMaps[i];
+ }
}
CPDF_CMap* CPDF_CMapManager::GetPredefinedCMap(const CFX_ByteString& name,
FX_BOOL bPromptCJK) {
- CPDF_CMap* pCMap;
- if (m_CMaps.Lookup(name, (void*&)pCMap)) {
- return pCMap;
+ auto it = m_CMaps.find(name);
+ if (it != m_CMaps.end()) {
+ return it->second;
}
- pCMap = LoadPredefinedCMap(name, bPromptCJK);
- if (name.IsEmpty()) {
- return pCMap;
+ CPDF_CMap* pCMap = LoadPredefinedCMap(name, bPromptCJK);
+ if (!name.IsEmpty()) {
+ m_CMaps[name] = pCMap;
}
- m_CMaps.SetAt(name, pCMap);
return pCMap;
}
CPDF_CMap* CPDF_CMapManager::LoadPredefinedCMap(const CFX_ByteString& name,
@@ -59,33 +64,13 @@ int _CharsetFromOrdering(const CFX_ByteString& Ordering) {
return CIDSET_UNKNOWN;
}
void CPDF_CMapManager::ReloadAll() {
- DropAll(TRUE);
-}
-void CPDF_CMapManager::DropAll(FX_BOOL bReload) {
- FX_POSITION pos = m_CMaps.GetStartPosition();
- while (pos) {
- CFX_ByteString name;
- CPDF_CMap* pCMap;
- m_CMaps.GetNextAssoc(pos, name, (void*&)pCMap);
- if (pCMap == NULL) {
- continue;
- }
- if (bReload) {
- pCMap->LoadPredefined(this, name, FALSE);
- } else {
- delete pCMap;
- }
+ for (const auto& pair : m_CMaps) {
+ CPDF_CMap* pCMap = pair.second;
+ pCMap->LoadPredefined(this, pair.first, FALSE);
}
- for (int i = 0; i < sizeof m_CID2UnicodeMaps / sizeof(CPDF_CID2UnicodeMap*);
- i++) {
- CPDF_CID2UnicodeMap* pMap = m_CID2UnicodeMaps[i];
- if (pMap == NULL) {
- continue;
- }
- if (bReload) {
+ for (int i = 0; i < FX_ArraySize(m_CID2UnicodeMaps); ++i) {
+ if (CPDF_CID2UnicodeMap* pMap = m_CID2UnicodeMaps[i]) {
pMap->Load(this, i, FALSE);
- } else {
- delete pMap;
}
}
}