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 "../../include/fxcodec/fx_codec.h" | 7 #include "../../include/fxcodec/fx_codec.h" |
8 #include "../../include/fpdfapi/fpdf_module.h" | 8 #include "../../include/fpdfapi/fpdf_module.h" |
9 static CPDF_ModuleMgr* g_FPDFAPI_pDefaultMgr = NULL; | 9 static CPDF_ModuleMgr* g_FPDFAPI_pDefaultMgr = NULL; |
10 CPDF_ModuleMgr* CPDF_ModuleMgr::Get() | 10 CPDF_ModuleMgr* CPDF_ModuleMgr::Get() |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 return (folder + "\\") + name; | 71 return (folder + "\\") + name; |
72 } | 72 } |
73 #else | 73 #else |
74 if (folder[folder_len - 1] == '/') { | 74 if (folder[folder_len - 1] == '/') { |
75 return folder + name; | 75 return folder + name; |
76 } else { | 76 } else { |
77 return (folder + "/") + name; | 77 return (folder + "/") + name; |
78 } | 78 } |
79 #endif | 79 #endif |
80 } | 80 } |
81 void CPDF_ModuleMgr::SetModulePath(FX_LPCSTR module_name, FX_LPCSTR path) | |
82 { | |
83 if (module_name == NULL || module_name[0] == 0) { | |
84 m_DefaultModulePath = path; | |
85 } else { | |
86 m_ModulePathList.SetAt(module_name, FX_NEW CFX_ByteString(path, -1)); | |
87 } | |
88 } | |
89 CFX_ByteString CPDF_ModuleMgr::GetModuleFilePath(FX_LPCSTR module_name, FX_LPCST
R name) | |
90 { | |
91 CFX_ByteString* pPath = NULL; | |
92 if (m_ModulePathList.Lookup(module_name, (FX_LPVOID&)pPath)) { | |
93 return _GetPath(*pPath, name); | |
94 } | |
95 if (!m_DefaultModulePath.IsEmpty()) { | |
96 return _GetPath(m_DefaultModulePath, name); | |
97 } | |
98 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | |
99 FX_WCHAR app_path[260]; | |
100 ::GetModuleFileNameW(NULL, (LPWSTR)app_path, 260); | |
101 FX_INTPTR len = FXSYS_wcslen(app_path); | |
102 for (FX_INTPTR i = len; i >= 0; i --) | |
103 if (app_path[i] == '\\') { | |
104 app_path[i] = 0; | |
105 break; | |
106 } | |
107 CFX_ByteString path = CFX_ByteString::FromUnicode(app_path); | |
108 path += '\\'; | |
109 path += name; | |
110 return path; | |
111 #else | |
112 return name; | |
113 #endif | |
114 } | |
115 void CPDF_ModuleMgr::NotifyModuleAvailable(FX_LPCSTR module_name) | 81 void CPDF_ModuleMgr::NotifyModuleAvailable(FX_LPCSTR module_name) |
116 { | 82 { |
117 if (FXSYS_strcmp(module_name, ADDIN_NAME_CJK) == 0) { | 83 if (FXSYS_strcmp(module_name, ADDIN_NAME_CJK) == 0) { |
118 m_pPageModule->NotifyCJKAvailable(); | 84 m_pPageModule->NotifyCJKAvailable(); |
119 } else if (FXSYS_strcmp(module_name, ADDIN_NAME_DECODER) == 0) { | 85 } else if (FXSYS_strcmp(module_name, ADDIN_NAME_DECODER) == 0) { |
120 m_pRenderModule->NotifyDecoderAvailable(); | 86 m_pRenderModule->NotifyDecoderAvailable(); |
121 } | 87 } |
122 } | 88 } |
123 void CPDF_ModuleMgr::RegisterSecurityHandler(FX_LPCSTR filter, CPDF_SecurityHand
ler * (*CreateHandler)(void* param), void* param) | 89 void CPDF_ModuleMgr::RegisterSecurityHandler(FX_LPCSTR filter, CPDF_SecurityHand
ler * (*CreateHandler)(void* param), void* param) |
124 { | 90 { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 return m_pCodecModule ? m_pCodecModule->GetJbig2Module() : NULL; | 135 return m_pCodecModule ? m_pCodecModule->GetJbig2Module() : NULL; |
170 } | 136 } |
171 ICodec_IccModule* CPDF_ModuleMgr::GetIccModule() | 137 ICodec_IccModule* CPDF_ModuleMgr::GetIccModule() |
172 { | 138 { |
173 return m_pCodecModule ? m_pCodecModule->GetIccModule() : NULL; | 139 return m_pCodecModule ? m_pCodecModule->GetIccModule() : NULL; |
174 } | 140 } |
175 ICodec_FlateModule* CPDF_ModuleMgr::GetFlateModule() | 141 ICodec_FlateModule* CPDF_ModuleMgr::GetFlateModule() |
176 { | 142 { |
177 return m_pCodecModule ? m_pCodecModule->GetFlateModule() : NULL; | 143 return m_pCodecModule ? m_pCodecModule->GetFlateModule() : NULL; |
178 } | 144 } |
OLD | NEW |