Chromium Code Reviews| 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/fxcodec/fx_codec.h" | 7 #include "../../core/include/fxcodec/fx_codec.h" |
| 8 #include "../../core/include/fxcrt/fx_safe_types.h" | 8 #include "../../core/include/fxcrt/fx_safe_types.h" |
| 9 #include "../../public/fpdf_ext.h" | 9 #include "../../public/fpdf_ext.h" |
| 10 #include "../../public/fpdf_progressive.h" | 10 #include "../../public/fpdf_progressive.h" |
| 11 #include "../../public/fpdfview.h" | 11 #include "../../public/fpdfview.h" |
| 12 #include "../../third_party/base/nonstd_unique_ptr.h" | 12 #include "../../third_party/base/nonstd_unique_ptr.h" |
| 13 #include "../../third_party/base/numerics/safe_conversions_impl.h" | 13 #include "../../third_party/base/numerics/safe_conversions_impl.h" |
| 14 #include "../include/fsdk_define.h" | 14 #include "../include/fsdk_define.h" |
| 15 #include "../include/fsdk_mgr.h" | 15 #include "../include/fsdk_mgr.h" |
| 16 #include "../include/fsdk_rendercontext.h" | 16 #include "../include/fsdk_rendercontext.h" |
| 17 | 17 |
| 18 CPDF_CustomAccess::CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess) | 18 CPDF_CustomAccess::CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess) |
| 19 { | 19 { |
| 20 » if (pFileAccess) | 20 if (pFileAccess) |
| 21 » » m_FileAccess = *pFileAccess; | 21 m_FileAccess = *pFileAccess; |
| 22 } | 22 } |
| 23 | 23 |
| 24 FX_BOOL CPDF_CustomAccess::ReadBlock(void* buffer, FX_FILESIZE offset, size_t si ze) | 24 FX_BOOL CPDF_CustomAccess::ReadBlock(void* buffer, FX_FILESIZE offset, size_t si ze) |
| 25 { | 25 { |
| 26 if (offset < 0) { | 26 if (offset < 0) { |
| 27 return FALSE; | 27 return FALSE; |
| 28 } | 28 } |
| 29 FX_SAFE_FILESIZE newPos = pdfium::base::checked_cast<FX_FILESIZE, size_t>(si ze); | 29 FX_SAFE_FILESIZE newPos = pdfium::base::checked_cast<FX_FILESIZE, size_t>(si ze); |
| 30 newPos += offset; | 30 newPos += offset; |
| 31 if (!newPos.IsValid() || newPos.ValueOrDie() > m_FileAccess.m_FileLen) { | 31 if (!newPos.IsValid() || newPos.ValueOrDie() > m_FileAccess.m_FileLen) { |
| 32 return FALSE; | 32 return FALSE; |
| 33 } | 33 } |
| 34 return m_FileAccess.m_GetBlock(m_FileAccess.m_Param, offset,(uint8_t*) buffe r, size); | 34 return m_FileAccess.m_GetBlock(m_FileAccess.m_Param, offset,(uint8_t*) buffe r, size); |
| 35 } | 35 } |
| 36 | 36 |
| 37 //0 bit: FPDF_POLICY_MACHINETIME_ACCESS | 37 //0 bit: FPDF_POLICY_MACHINETIME_ACCESS |
| 38 static FX_DWORD foxit_sandbox_policy = 0xFFFFFFFF; | 38 static FX_DWORD foxit_sandbox_policy = 0xFFFFFFFF; |
|
Lei Zhang
2015/07/17 01:06:35
would you mind making this a const?
Tom Sepez
2015/07/17 16:58:22
Turns out it gets updated in a couple of places.
| |
| 39 | 39 |
| 40 void FSDK_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable) | 40 void FSDK_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable) |
| 41 { | 41 { |
| 42 » switch(policy) | 42 switch(policy) |
| 43 » { | 43 { |
| 44 » case FPDF_POLICY_MACHINETIME_ACCESS: | 44 case FPDF_POLICY_MACHINETIME_ACCESS: |
| 45 » » { | 45 { |
| 46 » » » if(enable) | 46 if(enable) |
| 47 » » » » foxit_sandbox_policy |= 0x01; | 47 foxit_sandbox_policy |= 0x01; |
| 48 » » » else | 48 else |
| 49 » » » » foxit_sandbox_policy &= 0xFFFFFFFE; | 49 foxit_sandbox_policy &= 0xFFFFFFFE; |
| 50 » » } | 50 } |
| 51 » » break; | 51 break; |
| 52 » default: | 52 default: |
| 53 » » break; | 53 break; |
| 54 » } | 54 } |
| 55 } | 55 } |
| 56 | 56 |
| 57 FPDF_BOOL FSDK_IsSandBoxPolicyEnabled(FPDF_DWORD policy) | 57 FPDF_BOOL FSDK_IsSandBoxPolicyEnabled(FPDF_DWORD policy) |
| 58 { | 58 { |
| 59 » switch(policy) | 59 switch(policy) |
| 60 » { | 60 { |
| 61 » case FPDF_POLICY_MACHINETIME_ACCESS: | 61 case FPDF_POLICY_MACHINETIME_ACCESS: |
| 62 » » { | 62 { |
| 63 » » » if(foxit_sandbox_policy&0x01) | 63 if(foxit_sandbox_policy&0x01) |
|
Lei Zhang
2015/07/17 01:06:35
return foxit_sandbox_policy & 0x01;
| |
| 64 » » » » return TRUE; | 64 return TRUE; |
| 65 » » » else | 65 else |
| 66 » » » » return FALSE; | 66 return FALSE; |
| 67 » » } | 67 } |
| 68 » » break; | 68 break; |
|
Lei Zhang
2015/07/17 01:06:35
no need for a break
Tom Sepez
2015/07/17 16:58:22
Done.
| |
| 69 » default: | 69 default: |
| 70 » » break; | 70 break; |
|
Lei Zhang
2015/07/17 01:06:35
just return FALSE
Tom Sepez
2015/07/17 16:58:22
Done.
| |
| 71 » } | 71 } |
| 72 » return FALSE; | 72 return FALSE; |
| 73 } | 73 } |
| 74 | 74 |
| 75 | 75 |
| 76 #ifndef _T | 76 #ifndef _T |
| 77 #define _T(x) x | 77 #define _T(x) x |
| 78 #endif | 78 #endif |
| 79 | 79 |
| 80 CCodec_ModuleMgr* g_pCodecModule = nullptr; | 80 CCodec_ModuleMgr* g_pCodecModule = nullptr; |
| 81 | 81 |
| 82 #if _FX_OS_ == _FX_LINUX_EMBEDDED_ | 82 #if _FX_OS_ == _FX_LINUX_EMBEDDED_ |
| 83 class CFontMapper : public IPDF_FontMapper | 83 class CFontMapper : public IPDF_FontMapper |
| 84 { | 84 { |
| 85 public: | 85 public: |
| 86 » CFontMapper(); | 86 CFontMapper(); |
| 87 » virtual ~CFontMapper(); | 87 virtual ~CFontMapper(); |
| 88 | 88 |
| 89 » virtual FT_Face FindSubstFont( | 89 virtual FT_Face FindSubstFont( |
| 90 » » » » » » » CPDF_Document* pDoc,» » » » // [IN] The PDF document | 90 CPDF_Document* pDoc, // [IN] The PDF document |
| 91 » » » » » » » const CFX_ByteString& fa ce_name,» // [IN] Original name | 91 const CFX_ByteString& face_name, // [IN] Original name |
| 92 » » » » » » » FX_BOOL bTrueType,» » » » » // [IN] TrueType or Type1 | 92 FX_BOOL bTrueType, // [IN] TrueType or Type1 |
| 93 » » » » » » » FX_DWORD flags,»» » » » » // [IN] PDF font flags (see PDF Reference sectio n 5.7.1) | 93 FX_DWORD flags, // [IN] PDF font flags (see PDF Reference section 5.7.1) |
| 94 » » » » » » » int font_weight,» » » » » // [IN] original font weight. 0 for not specifie d | 94 int font_weight, // [IN] original font weight. 0 for not specified |
| 95 » » » » » » » int CharsetCP,» » » » » » // [IN] code page for charset (see Win32 GetACP( )) | 95 int CharsetCP, // [IN] code pag e for charset (see Win32 GetACP()) |
| 96 » » » » » » » FX_BOOL bVertical, | 96 FX_BOOL bVertical, |
| 97 » » » » » » » CPDF_SubstFont* pSubstFo nt» » » // [OUT] Subst font data | 97 CPDF_SubstFont* pSubstFont // [OUT] Subst f ont data |
| 98 » » » » » » ); | 98 ); |
| 99 | 99 |
| 100 » FT_Face m_SysFace; | 100 FT_Face m_SysFace; |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 CFontMapper* g_pFontMapper = NULL; | 103 CFontMapper* g_pFontMapper = NULL; |
| 104 #endif» » // #if _FX_OS_ == _FX_LINUX_EMBEDDED_ | 104 #endif // #if _FX_OS_ == _FX_LINUX_EMBEDDED_ |
| 105 | 105 |
| 106 DLLEXPORT void STDCALL FPDF_InitLibrary() | 106 DLLEXPORT void STDCALL FPDF_InitLibrary() |
| 107 { | 107 { |
| 108 » g_pCodecModule = new CCodec_ModuleMgr(); | 108 g_pCodecModule = new CCodec_ModuleMgr(); |
| 109 | 109 |
| 110 » CFX_GEModule::Create(); | 110 CFX_GEModule::Create(); |
| 111 » CFX_GEModule::Get()->SetCodecModule(g_pCodecModule); | 111 CFX_GEModule::Get()->SetCodecModule(g_pCodecModule); |
| 112 | 112 |
| 113 » CPDF_ModuleMgr::Create(); | 113 CPDF_ModuleMgr::Create(); |
| 114 » CPDF_ModuleMgr::Get()->SetCodecModule(g_pCodecModule); | 114 CPDF_ModuleMgr::Get()->SetCodecModule(g_pCodecModule); |
| 115 » CPDF_ModuleMgr::Get()->InitPageModule(); | 115 CPDF_ModuleMgr::Get()->InitPageModule(); |
| 116 » CPDF_ModuleMgr::Get()->InitRenderModule(); | 116 CPDF_ModuleMgr::Get()->InitRenderModule(); |
| 117 » CPDF_ModuleMgr * pModuleMgr = CPDF_ModuleMgr::Get(); | 117 CPDF_ModuleMgr * pModuleMgr = CPDF_ModuleMgr::Get(); |
| 118 » if ( pModuleMgr ) | 118 if ( pModuleMgr ) |
| 119 » { | 119 { |
| 120 » » pModuleMgr->LoadEmbeddedGB1CMaps(); | 120 pModuleMgr->LoadEmbeddedGB1CMaps(); |
| 121 » » pModuleMgr->LoadEmbeddedJapan1CMaps(); | 121 pModuleMgr->LoadEmbeddedJapan1CMaps(); |
| 122 » » pModuleMgr->LoadEmbeddedCNS1CMaps(); | 122 pModuleMgr->LoadEmbeddedCNS1CMaps(); |
| 123 » » pModuleMgr->LoadEmbeddedKorea1CMaps(); | 123 pModuleMgr->LoadEmbeddedKorea1CMaps(); |
| 124 » } | 124 } |
| 125 } | 125 } |
| 126 | 126 |
| 127 | 127 |
| 128 DLLEXPORT void STDCALL FPDF_DestroyLibrary() | 128 DLLEXPORT void STDCALL FPDF_DestroyLibrary() |
| 129 { | 129 { |
| 130 | 130 |
| 131 #if _FX_OS_ == _FX_LINUX_EMBEDDED_ | 131 #if _FX_OS_ == _FX_LINUX_EMBEDDED_ |
| 132 » delete g_pFontMapper; | 132 delete g_pFontMapper; |
| 133 » g_pFontMapper = nullptr; | 133 g_pFontMapper = nullptr; |
| 134 #endif | 134 #endif |
| 135 » CPDF_ModuleMgr::Destroy(); | 135 CPDF_ModuleMgr::Destroy(); |
| 136 » CFX_GEModule::Destroy(); | 136 CFX_GEModule::Destroy(); |
| 137 » delete g_pCodecModule; | 137 delete g_pCodecModule; |
| 138 » g_pCodecModule = nullptr; | 138 g_pCodecModule = nullptr; |
| 139 } | 139 } |
| 140 | 140 |
| 141 #ifndef _WIN32 | 141 #ifndef _WIN32 |
| 142 int g_LastError; | 142 int g_LastError; |
| 143 void SetLastError(int err) | 143 void SetLastError(int err) |
| 144 { | 144 { |
| 145 » g_LastError = err; | 145 g_LastError = err; |
| 146 } | 146 } |
| 147 | 147 |
| 148 int GetLastError() | 148 int GetLastError() |
| 149 { | 149 { |
| 150 » return g_LastError; | 150 return g_LastError; |
| 151 } | 151 } |
| 152 #endif | 152 #endif |
| 153 | 153 |
| 154 void ProcessParseError(FX_DWORD err_code) | 154 void ProcessParseError(FX_DWORD err_code) |
| 155 { | 155 { |
| 156 » // Translate FPDFAPI error code to FPDFVIEW error code | 156 // Translate FPDFAPI error code to FPDFVIEW error code |
| 157 » switch (err_code) { | 157 switch (err_code) { |
| 158 » » case PDFPARSE_ERROR_FILE: | 158 case PDFPARSE_ERROR_FILE: |
| 159 » » » err_code = FPDF_ERR_FILE; | 159 err_code = FPDF_ERR_FILE; |
| 160 » » » break; | 160 break; |
| 161 » » case PDFPARSE_ERROR_FORMAT: | 161 case PDFPARSE_ERROR_FORMAT: |
| 162 » » » err_code = FPDF_ERR_FORMAT; | 162 err_code = FPDF_ERR_FORMAT; |
| 163 » » » break; | 163 break; |
| 164 » » case PDFPARSE_ERROR_PASSWORD: | 164 case PDFPARSE_ERROR_PASSWORD: |
| 165 » » » err_code = FPDF_ERR_PASSWORD; | 165 err_code = FPDF_ERR_PASSWORD; |
| 166 » » » break; | 166 break; |
| 167 » » case PDFPARSE_ERROR_HANDLER: | 167 case PDFPARSE_ERROR_HANDLER: |
| 168 » » » err_code = FPDF_ERR_SECURITY; | 168 err_code = FPDF_ERR_SECURITY; |
| 169 » » » break; | 169 break; |
| 170 » } | 170 } |
| 171 » SetLastError(err_code); | 171 SetLastError(err_code); |
| 172 } | 172 } |
| 173 | 173 |
| 174 DLLEXPORT void» STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enabl e) | 174 DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enabl e) |
| 175 { | 175 { |
| 176 » return FSDK_SetSandBoxPolicy(policy, enable); | 176 return FSDK_SetSandBoxPolicy(policy, enable); |
| 177 } | 177 } |
| 178 | 178 |
| 179 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, FPDF_BY TESTRING password) | 179 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, FPDF_BY TESTRING password) |
| 180 { | 180 { |
| 181 » CPDF_Parser* pParser = new CPDF_Parser; | 181 CPDF_Parser* pParser = new CPDF_Parser; |
| 182 » pParser->SetPassword(password); | 182 pParser->SetPassword(password); |
| 183 | 183 |
| 184 » FX_DWORD err_code = pParser->StartParse((const FX_CHAR*)file_path); | 184 FX_DWORD err_code = pParser->StartParse((const FX_CHAR*)file_path); |
| 185 » if (err_code) { | 185 if (err_code) { |
| 186 » » delete pParser; | 186 delete pParser; |
| 187 » » ProcessParseError(err_code); | 187 ProcessParseError(err_code); |
| 188 » » return NULL; | 188 return NULL; |
| 189 » } | 189 } |
| 190 » return pParser->GetDocument(); | 190 return pParser->GetDocument(); |
| 191 } | 191 } |
| 192 | 192 |
| 193 extern void CheckUnSupportError(CPDF_Document * pDoc, FX_DWORD err_code); | 193 extern void CheckUnSupportError(CPDF_Document * pDoc, FX_DWORD err_code); |
| 194 | 194 |
| 195 class CMemFile final: public IFX_FileRead | 195 class CMemFile final: public IFX_FileRead |
| 196 { | 196 { |
| 197 public: | 197 public: |
| 198 » CMemFile(uint8_t* pBuf, FX_FILESIZE size):m_pBuf(pBuf),m_size(size) {} | 198 CMemFile(uint8_t* pBuf, FX_FILESIZE size):m_pBuf(pBuf),m_size(size) {} |
| 199 | 199 |
| 200 » virtual void» » » Release() {delete this;} | 200 virtual void Release() {delete this;} |
| 201 » virtual FX_FILESIZE» » GetSize() {return m_size;} | 201 virtual FX_FILESIZE GetSize() {return m_size;} |
| 202 » virtual FX_BOOL»» » ReadBlock(void* buffer, FX_FILESIZE offs et, size_t size) | 202 virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t s ize) |
| 203 » { | 203 { |
| 204 if (offset < 0) { | 204 if (offset < 0) { |
| 205 return FALSE; | 205 return FALSE; |
| 206 } | 206 } |
| 207 FX_SAFE_FILESIZE newPos = pdfium::base::checked_cast<FX_FILESIZE, si ze_t>(size); | 207 FX_SAFE_FILESIZE newPos = pdfium::base::checked_cast<FX_FILESIZE, si ze_t>(size); |
| 208 newPos += offset; | 208 newPos += offset; |
| 209 if (!newPos.IsValid() || newPos.ValueOrDie() > (FX_DWORD)m_size) { | 209 if (!newPos.IsValid() || newPos.ValueOrDie() > (FX_DWORD)m_size) { |
| 210 return FALSE; | 210 return FALSE; |
| 211 } | 211 } |
| 212 » FXSYS_memcpy(buffer, m_pBuf+offset, size); | 212 FXSYS_memcpy(buffer, m_pBuf+offset, size); |
| 213 » return TRUE; | 213 return TRUE; |
| 214 » } | 214 } |
| 215 private: | 215 private: |
| 216 » uint8_t* m_pBuf; | 216 uint8_t* m_pBuf; |
| 217 » FX_FILESIZE m_size; | 217 FX_FILESIZE m_size; |
| 218 }; | 218 }; |
| 219 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf, int s ize, FPDF_BYTESTRING password) | 219 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf, int s ize, FPDF_BYTESTRING password) |
| 220 { | 220 { |
| 221 » CPDF_Parser* pParser = new CPDF_Parser; | 221 CPDF_Parser* pParser = new CPDF_Parser; |
| 222 » pParser->SetPassword(password); | 222 pParser->SetPassword(password); |
| 223 » CMemFile* pMemFile = new CMemFile((uint8_t*)data_buf, size); | 223 CMemFile* pMemFile = new CMemFile((uint8_t*)data_buf, size); |
| 224 » FX_DWORD err_code = pParser->StartParse(pMemFile); | 224 FX_DWORD err_code = pParser->StartParse(pMemFile); |
| 225 » if (err_code) { | 225 if (err_code) { |
| 226 » » delete pParser; | 226 delete pParser; |
| 227 » » ProcessParseError(err_code); | 227 ProcessParseError(err_code); |
| 228 » » return NULL; | 228 return NULL; |
| 229 » } | 229 } |
| 230 » CPDF_Document * pDoc = NULL; | 230 CPDF_Document * pDoc = NULL; |
| 231 » pDoc = pParser?pParser->GetDocument():NULL; | 231 pDoc = pParser?pParser->GetDocument():NULL; |
| 232 » CheckUnSupportError(pDoc, err_code); | 232 CheckUnSupportError(pDoc, err_code); |
| 233 » return pParser->GetDocument(); | 233 return pParser->GetDocument(); |
| 234 } | 234 } |
| 235 | 235 |
| 236 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAc cess, FPDF_BYTESTRING password) | 236 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAc cess, FPDF_BYTESTRING password) |
| 237 { | 237 { |
| 238 » CPDF_Parser* pParser = new CPDF_Parser; | 238 CPDF_Parser* pParser = new CPDF_Parser; |
| 239 » pParser->SetPassword(password); | 239 pParser->SetPassword(password); |
| 240 » CPDF_CustomAccess* pFile = new CPDF_CustomAccess(pFileAccess); | 240 CPDF_CustomAccess* pFile = new CPDF_CustomAccess(pFileAccess); |
| 241 » FX_DWORD err_code = pParser->StartParse(pFile); | 241 FX_DWORD err_code = pParser->StartParse(pFile); |
| 242 » if (err_code) { | 242 if (err_code) { |
| 243 » » delete pParser; | 243 delete pParser; |
| 244 » » ProcessParseError(err_code); | 244 ProcessParseError(err_code); |
| 245 » » return NULL; | 245 return NULL; |
| 246 » } | 246 } |
| 247 » CPDF_Document * pDoc = NULL; | 247 CPDF_Document * pDoc = NULL; |
| 248 » pDoc = pParser?pParser->GetDocument():NULL; | 248 pDoc = pParser?pParser->GetDocument():NULL; |
| 249 » CheckUnSupportError(pDoc, err_code); | 249 CheckUnSupportError(pDoc, err_code); |
| 250 » return pParser->GetDocument(); | 250 return pParser->GetDocument(); |
| 251 } | 251 } |
| 252 | 252 |
| 253 DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc, int* fileVers ion) | 253 DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc, int* fileVers ion) |
| 254 { | 254 { |
| 255 » if(!doc||!fileVersion) return FALSE; | 255 if(!doc||!fileVersion) return FALSE; |
| 256 » *fileVersion = 0; | 256 *fileVersion = 0; |
| 257 » CPDF_Document* pDoc = (CPDF_Document*)doc; | 257 CPDF_Document* pDoc = (CPDF_Document*)doc; |
| 258 » CPDF_Parser* pParser = (CPDF_Parser*)pDoc->GetParser(); | 258 CPDF_Parser* pParser = (CPDF_Parser*)pDoc->GetParser(); |
| 259 » if(!pParser) | 259 if(!pParser) |
| 260 » » return FALSE; | 260 return FALSE; |
| 261 » *fileVersion = pParser->GetFileVersion(); | 261 *fileVersion = pParser->GetFileVersion(); |
| 262 » return TRUE; | 262 return TRUE; |
| 263 } | 263 } |
| 264 | 264 |
| 265 // jabdelmalek: changed return type from FX_DWORD to build on Linux (and match h eader). | 265 // jabdelmalek: changed return type from FX_DWORD to build on Linux (and match h eader). |
| 266 DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document) | 266 DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document) |
| 267 { | 267 { |
| 268 » if (document == NULL) return 0; | 268 if (document == NULL) return 0; |
| 269 » CPDF_Document*pDoc = (CPDF_Document*)document; | 269 CPDF_Document*pDoc = (CPDF_Document*)document; |
| 270 » CPDF_Parser* pParser = »(CPDF_Parser*)pDoc->GetParser(); | 270 CPDF_Parser* pParser = (CPDF_Parser*)pDoc->GetParser(); |
| 271 » CPDF_Dictionary* pDict = pParser->GetEncryptDict(); | 271 CPDF_Dictionary* pDict = pParser->GetEncryptDict(); |
| 272 » if (pDict == NULL) return (FX_DWORD)-1; | 272 if (pDict == NULL) return (FX_DWORD)-1; |
| 273 | 273 |
| 274 » return pDict->GetInteger("P"); | 274 return pDict->GetInteger("P"); |
| 275 } | 275 } |
| 276 | 276 |
| 277 DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document) | 277 DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document) |
| 278 { | 278 { |
| 279 if (document == NULL) return -1; | 279 if (document == NULL) return -1; |
| 280 CPDF_Document*pDoc = (CPDF_Document*)document; | 280 CPDF_Document*pDoc = (CPDF_Document*)document; |
| 281 CPDF_Parser* pParser = (CPDF_Parser*)pDoc->GetParser(); | 281 CPDF_Parser* pParser = (CPDF_Parser*)pDoc->GetParser(); |
| 282 CPDF_Dictionary* pDict = pParser->GetEncryptDict(); | 282 CPDF_Dictionary* pDict = pParser->GetEncryptDict(); |
| 283 if (pDict == NULL) return -1; | 283 if (pDict == NULL) return -1; |
| 284 | 284 |
| 285 return pDict->GetInteger("R"); | 285 return pDict->GetInteger("R"); |
| 286 } | 286 } |
| 287 | 287 |
| 288 DLLEXPORT int STDCALL FPDF_GetPageCount(FPDF_DOCUMENT document) | 288 DLLEXPORT int STDCALL FPDF_GetPageCount(FPDF_DOCUMENT document) |
| 289 { | 289 { |
| 290 » if (document == NULL) return 0; | 290 if (document == NULL) return 0; |
| 291 » return ((CPDF_Document*)document)->GetPageCount(); | 291 return ((CPDF_Document*)document)->GetPageCount(); |
| 292 } | 292 } |
| 293 | 293 |
| 294 DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document, int page_index ) | 294 DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document, int page_index ) |
| 295 { | 295 { |
| 296 » if (document == NULL) return NULL; | 296 if (document == NULL) return NULL; |
| 297 » if (page_index < 0 || page_index >= FPDF_GetPageCount(document)) return NULL; | 297 if (page_index < 0 || page_index >= FPDF_GetPageCount(document)) return NULL ; |
| 298 | 298 |
| 299 » CPDF_Document* pDoc = (CPDF_Document*)document; | 299 CPDF_Document* pDoc = (CPDF_Document*)document; |
| 300 » if (pDoc == NULL) return NULL; | 300 if (pDoc == NULL) return NULL; |
| 301 » CPDF_Dictionary* pDict = pDoc->GetPage(page_index); | 301 CPDF_Dictionary* pDict = pDoc->GetPage(page_index); |
| 302 » if (pDict == NULL) return NULL; | 302 if (pDict == NULL) return NULL; |
| 303 » CPDF_Page* pPage = new CPDF_Page; | 303 CPDF_Page* pPage = new CPDF_Page; |
| 304 » pPage->Load(pDoc, pDict); | 304 pPage->Load(pDoc, pDict); |
| 305 » pPage->ParseContent(); | 305 pPage->ParseContent(); |
| 306 » return pPage; | 306 return pPage; |
| 307 } | 307 } |
| 308 | 308 |
| 309 DLLEXPORT double STDCALL FPDF_GetPageWidth(FPDF_PAGE page) | 309 DLLEXPORT double STDCALL FPDF_GetPageWidth(FPDF_PAGE page) |
| 310 { | 310 { |
| 311 » if (!page) | 311 if (!page) |
| 312 » » return 0.0; | 312 return 0.0; |
| 313 » return ((CPDF_Page*)page)->GetPageWidth(); | 313 return ((CPDF_Page*)page)->GetPageWidth(); |
| 314 } | 314 } |
| 315 | 315 |
| 316 DLLEXPORT double STDCALL FPDF_GetPageHeight(FPDF_PAGE page) | 316 DLLEXPORT double STDCALL FPDF_GetPageHeight(FPDF_PAGE page) |
| 317 { | 317 { |
| 318 » if (!page) return 0.0; | 318 if (!page) return 0.0; |
| 319 » return ((CPDF_Page*)page)->GetPageHeight(); | 319 return ((CPDF_Page*)page)->GetPageHeight(); |
| 320 } | 320 } |
| 321 | 321 |
| 322 void DropContext(void* data) | 322 void DropContext(void* data) |
| 323 { | 323 { |
| 324 » delete (CRenderContext*)data; | 324 delete (CRenderContext*)data; |
| 325 } | 325 } |
| 326 | 326 |
| 327 #if defined(_DEBUG) || defined(DEBUG) | 327 #if defined(_DEBUG) || defined(DEBUG) |
| 328 #define DEBUG_TRACE | 328 #define DEBUG_TRACE |
| 329 #endif | 329 #endif |
| 330 | 330 |
| 331 #if defined(_WIN32) | 331 #if defined(_WIN32) |
| 332 DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc, FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y, | 332 DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc, FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y, |
| 333 » » » » » » int rotate, int flags) | 333 int rotate, int flags) |
| 334 { | 334 { |
| 335 » if (page==NULL) return; | 335 if (page==NULL) return; |
| 336 » CPDF_Page* pPage = (CPDF_Page*)page; | 336 CPDF_Page* pPage = (CPDF_Page*)page; |
| 337 | 337 |
| 338 » CRenderContext* pContext = new CRenderContext; | 338 CRenderContext* pContext = new CRenderContext; |
| 339 » pPage->SetPrivateData((void*)1, pContext, DropContext); | 339 pPage->SetPrivateData((void*)1, pContext, DropContext); |
| 340 | 340 |
| 341 #ifndef _WIN32_WCE | 341 #ifndef _WIN32_WCE |
| 342 » CFX_DIBitmap* pBitmap = NULL; | 342 CFX_DIBitmap* pBitmap = NULL; |
| 343 » FX_BOOL bBackgroundAlphaNeeded=FALSE; | 343 FX_BOOL bBackgroundAlphaNeeded=FALSE; |
| 344 » bBackgroundAlphaNeeded = pPage->BackgroundAlphaNeeded(); | 344 bBackgroundAlphaNeeded = pPage->BackgroundAlphaNeeded(); |
| 345 » if (bBackgroundAlphaNeeded) | 345 if (bBackgroundAlphaNeeded) |
| 346 » { | 346 { |
| 347 | 347 |
| 348 » » pBitmap = new CFX_DIBitmap; | 348 pBitmap = new CFX_DIBitmap; |
| 349 » » pBitmap->Create(size_x, size_y, FXDIB_Argb); | 349 pBitmap->Create(size_x, size_y, FXDIB_Argb); |
| 350 » » pBitmap->Clear(0x00ffffff); | 350 pBitmap->Clear(0x00ffffff); |
| 351 #ifdef _SKIA_SUPPORT_ | 351 #ifdef _SKIA_SUPPORT_ |
| 352 » » pContext->m_pDevice = new CFX_SkiaDevice; | 352 pContext->m_pDevice = new CFX_SkiaDevice; |
| 353 » » ((CFX_SkiaDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)pB itmap); | 353 ((CFX_SkiaDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)pBitmap); |
| 354 #else | 354 #else |
| 355 » » pContext->m_pDevice = new CFX_FxgeDevice; | 355 pContext->m_pDevice = new CFX_FxgeDevice; |
| 356 » » ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)pB itmap); | 356 ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)pBitmap); |
| 357 #endif | 357 #endif |
| 358 » } | 358 } |
| 359 » else | 359 else |
| 360 » pContext->m_pDevice = new CFX_WindowsDevice(dc); | 360 pContext->m_pDevice = new CFX_WindowsDevice(dc); |
| 361 | 361 |
| 362 » FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y, | 362 FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y, |
| 363 rotate, flags, TRUE, NULL); | 363 rotate, flags, TRUE, NULL); |
| 364 | 364 |
| 365 » if (bBackgroundAlphaNeeded) | 365 if (bBackgroundAlphaNeeded) |
| 366 » { | 366 { |
| 367 » » if (pBitmap) | 367 if (pBitmap) |
| 368 » » { | 368 { |
| 369 » » » CFX_WindowsDevice WinDC(dc); | 369 CFX_WindowsDevice WinDC(dc); |
| 370 | 370 |
| 371 » » » if (WinDC.GetDeviceCaps(FXDC_DEVICE_CLASS) == FXDC_PRINT ER) | 371 if (WinDC.GetDeviceCaps(FXDC_DEVICE_CLASS) == FXDC_PRINTER) |
| 372 » » » { | 372 { |
| 373 » » » » CFX_DIBitmap* pDst = new CFX_DIBitmap; | 373 CFX_DIBitmap* pDst = new CFX_DIBitmap; |
| 374 » » » » int pitch = pBitmap->GetPitch(); | 374 int pitch = pBitmap->GetPitch(); |
| 375 » » » » pDst->Create(size_x, size_y, FXDIB_Rgb32); | 375 pDst->Create(size_x, size_y, FXDIB_Rgb32); |
| 376 » » » » FXSYS_memset(pDst->GetBuffer(), -1, pitch*size_y ); | 376 FXSYS_memset(pDst->GetBuffer(), -1, pitch*size_y); |
| 377 » » » » pDst->CompositeBitmap(0, 0, size_x, size_y, pBit map, 0, 0, FXDIB_BLEND_NORMAL, NULL, FALSE, NULL); | 377 pDst->CompositeBitmap(0, 0, size_x, size_y, pBitmap, 0, 0, FXDIB _BLEND_NORMAL, NULL, FALSE, NULL); |
| 378 » » » » WinDC.StretchDIBits(pDst,0,0,size_x,size_y); | 378 WinDC.StretchDIBits(pDst,0,0,size_x,size_y); |
| 379 » » » » delete pDst; | 379 delete pDst; |
| 380 » » » } | 380 } |
| 381 » » » else | 381 else |
| 382 » » » » WinDC.SetDIBits(pBitmap,0,0); | 382 WinDC.SetDIBits(pBitmap,0,0); |
| 383 | 383 |
| 384 » » } | 384 } |
| 385 » } | 385 } |
| 386 #else | 386 #else |
| 387 » // get clip region | 387 // get clip region |
| 388 » RECT rect, cliprect; | 388 RECT rect, cliprect; |
| 389 » rect.left = start_x; | 389 rect.left = start_x; |
| 390 » rect.top = start_y; | 390 rect.top = start_y; |
| 391 » rect.right = start_x + size_x; | 391 rect.right = start_x + size_x; |
| 392 » rect.bottom = start_y + size_y; | 392 rect.bottom = start_y + size_y; |
| 393 » GetClipBox(dc, &cliprect); | 393 GetClipBox(dc, &cliprect); |
| 394 » IntersectRect(&rect, &rect, &cliprect); | 394 IntersectRect(&rect, &rect, &cliprect); |
| 395 » int width = rect.right - rect.left; | 395 int width = rect.right - rect.left; |
| 396 » int height = rect.bottom - rect.top; | 396 int height = rect.bottom - rect.top; |
| 397 | 397 |
| 398 #ifdef DEBUG_TRACE | 398 #ifdef DEBUG_TRACE |
| 399 » { | 399 { |
| 400 » » char str[128]; | 400 char str[128]; |
| 401 » » memset(str, 0, sizeof(str)); | 401 memset(str, 0, sizeof(str)); |
| 402 » » FXSYS_snprintf(str, sizeof(str) - 1, "Rendering DIB %d x %d", wi dth, height); | 402 FXSYS_snprintf(str, sizeof(str) - 1, "Rendering DIB %d x %d", width, hei ght); |
| 403 » » CPDF_ModuleMgr::Get()->ReportError(999, str); | 403 CPDF_ModuleMgr::Get()->ReportError(999, str); |
| 404 » } | 404 } |
| 405 #endif | 405 #endif |
| 406 | 406 |
| 407 » // Create a DIB section | 407 // Create a DIB section |
| 408 » LPVOID pBuffer; | 408 LPVOID pBuffer; |
| 409 » BITMAPINFOHEADER bmih; | 409 BITMAPINFOHEADER bmih; |
| 410 » FXSYS_memset(&bmih, 0, sizeof bmih); | 410 FXSYS_memset(&bmih, 0, sizeof bmih); |
| 411 » bmih.biSize = sizeof bmih; | 411 bmih.biSize = sizeof bmih; |
| 412 » bmih.biBitCount = 24; | 412 bmih.biBitCount = 24; |
| 413 » bmih.biHeight = -height; | 413 bmih.biHeight = -height; |
| 414 » bmih.biPlanes = 1; | 414 bmih.biPlanes = 1; |
| 415 » bmih.biWidth = width; | 415 bmih.biWidth = width; |
| 416 » pContext->m_hBitmap = CreateDIBSection(dc, (BITMAPINFO*)&bmih, DIB_RGB_C OLORS, &pBuffer, NULL, 0); | 416 pContext->m_hBitmap = CreateDIBSection(dc, (BITMAPINFO*)&bmih, DIB_RGB_COLOR S, &pBuffer, NULL, 0); |
| 417 » if (pContext->m_hBitmap == NULL) { | 417 if (pContext->m_hBitmap == NULL) { |
| 418 #if defined(DEBUG) || defined(_DEBUG) | 418 #if defined(DEBUG) || defined(_DEBUG) |
| 419 » » char str[128]; | 419 char str[128]; |
| 420 » » memset(str, 0, sizeof(str)); | 420 memset(str, 0, sizeof(str)); |
| 421 » » FXSYS_snprintf(str, sizeof(str) - 1, "Error CreateDIBSection: %d x %d, error code = %d", width, height, GetLastError()); | 421 FXSYS_snprintf(str, sizeof(str) - 1, "Error CreateDIBSection: %d x %d, e rror code = %d", width, height, GetLastError()); |
| 422 » » CPDF_ModuleMgr::Get()->ReportError(FPDFERR_OUT_OF_MEMORY, str); | 422 CPDF_ModuleMgr::Get()->ReportError(FPDFERR_OUT_OF_MEMORY, str); |
| 423 #else | 423 #else |
| 424 » » CPDF_ModuleMgr::Get()->ReportError(FPDFERR_OUT_OF_MEMORY, NULL); | 424 CPDF_ModuleMgr::Get()->ReportError(FPDFERR_OUT_OF_MEMORY, NULL); |
| 425 #endif | 425 #endif |
| 426 » } | 426 } |
| 427 » FXSYS_memset(pBuffer, 0xff, height*((width*3+3)/4*4)); | 427 FXSYS_memset(pBuffer, 0xff, height*((width*3+3)/4*4)); |
| 428 | 428 |
| 429 #ifdef DEBUG_TRACE | 429 #ifdef DEBUG_TRACE |
| 430 » { | 430 { |
| 431 » » CPDF_ModuleMgr::Get()->ReportError(999, "DIBSection created"); | 431 CPDF_ModuleMgr::Get()->ReportError(999, "DIBSection created"); |
| 432 » } | 432 } |
| 433 #endif | 433 #endif |
| 434 | 434 |
| 435 » // Create a device with this external buffer | 435 // Create a device with this external buffer |
| 436 » pContext->m_pBitmap = new CFX_DIBitmap; | 436 pContext->m_pBitmap = new CFX_DIBitmap; |
| 437 » pContext->m_pBitmap->Create(width, height, FXDIB_Rgb, (uint8_t*)pBuffer) ; | 437 pContext->m_pBitmap->Create(width, height, FXDIB_Rgb, (uint8_t*)pBuffer); |
| 438 » pContext->m_pDevice = new CPDF_FxgeDevice; | 438 pContext->m_pDevice = new CPDF_FxgeDevice; |
| 439 » ((CPDF_FxgeDevice*)pContext->m_pDevice)->Attach(pContext->m_pBitmap); | 439 ((CPDF_FxgeDevice*)pContext->m_pDevice)->Attach(pContext->m_pBitmap); |
| 440 | 440 |
| 441 #ifdef DEBUG_TRACE | 441 #ifdef DEBUG_TRACE |
| 442 » CPDF_ModuleMgr::Get()->ReportError(999, "Ready for PDF rendering"); | 442 CPDF_ModuleMgr::Get()->ReportError(999, "Ready for PDF rendering"); |
| 443 #endif | 443 #endif |
| 444 | 444 |
| 445 » // output to bitmap device | 445 // output to bitmap device |
| 446 » FPDF_RenderPage_Retail(pContext, page, start_x - rect.left, | 446 FPDF_RenderPage_Retail(pContext, page, start_x - rect.left, |
| 447 start_y - rect.top, size_x, size_y, rotate, flags); | 447 start_y - rect.top, size_x, size_y, rotate, flags); |
| 448 | 448 |
| 449 #ifdef DEBUG_TRACE | 449 #ifdef DEBUG_TRACE |
| 450 » CPDF_ModuleMgr::Get()->ReportError(999, "Finished PDF rendering"); | 450 CPDF_ModuleMgr::Get()->ReportError(999, "Finished PDF rendering"); |
| 451 #endif | 451 #endif |
| 452 | 452 |
| 453 » // Now output to real device | 453 // Now output to real device |
| 454 » HDC hMemDC = CreateCompatibleDC(dc); | 454 HDC hMemDC = CreateCompatibleDC(dc); |
| 455 » if (hMemDC == NULL) { | 455 if (hMemDC == NULL) { |
| 456 #if defined(DEBUG) || defined(_DEBUG) | 456 #if defined(DEBUG) || defined(_DEBUG) |
| 457 » » char str[128]; | 457 char str[128]; |
| 458 » » memset(str, 0, sizeof(str)); | 458 memset(str, 0, sizeof(str)); |
| 459 » » FXSYS_snprintf(str, sizeof(str) - 1, "Error CreateCompatibleDC. Error code = %d", GetLastError()); | 459 FXSYS_snprintf(str, sizeof(str) - 1, "Error CreateCompatibleDC. Error co de = %d", GetLastError()); |
| 460 » » CPDF_ModuleMgr::Get()->ReportError(FPDFERR_OUT_OF_MEMORY, str); | 460 CPDF_ModuleMgr::Get()->ReportError(FPDFERR_OUT_OF_MEMORY, str); |
| 461 #else | 461 #else |
| 462 » » CPDF_ModuleMgr::Get()->ReportError(FPDFERR_OUT_OF_MEMORY, NULL); | 462 CPDF_ModuleMgr::Get()->ReportError(FPDFERR_OUT_OF_MEMORY, NULL); |
| 463 #endif | 463 #endif |
| 464 » } | 464 } |
| 465 | 465 |
| 466 » HGDIOBJ hOldBitmap = SelectObject(hMemDC, pContext->m_hBitmap); | 466 HGDIOBJ hOldBitmap = SelectObject(hMemDC, pContext->m_hBitmap); |
| 467 | 467 |
| 468 #ifdef DEBUG_TRACE | 468 #ifdef DEBUG_TRACE |
| 469 » CPDF_ModuleMgr::Get()->ReportError(999, "Ready for screen rendering"); | 469 CPDF_ModuleMgr::Get()->ReportError(999, "Ready for screen rendering"); |
| 470 #endif | 470 #endif |
| 471 | 471 |
| 472 » BitBlt(dc, rect.left, rect.top, width, height, hMemDC, 0, 0, SRCCOPY); | 472 BitBlt(dc, rect.left, rect.top, width, height, hMemDC, 0, 0, SRCCOPY); |
| 473 » SelectObject(hMemDC, hOldBitmap); | 473 SelectObject(hMemDC, hOldBitmap); |
| 474 » DeleteDC(hMemDC); | 474 DeleteDC(hMemDC); |
| 475 | 475 |
| 476 #ifdef DEBUG_TRACE | 476 #ifdef DEBUG_TRACE |
| 477 » CPDF_ModuleMgr::Get()->ReportError(999, "Finished screen rendering"); | 477 CPDF_ModuleMgr::Get()->ReportError(999, "Finished screen rendering"); |
| 478 #endif | 478 #endif |
| 479 | 479 |
| 480 #endif | 480 #endif |
| 481 if (bBackgroundAlphaNeeded) { | 481 if (bBackgroundAlphaNeeded) { |
| 482 delete pBitmap; | 482 delete pBitmap; |
| 483 pBitmap = NULL; | 483 pBitmap = NULL; |
| 484 } | 484 } |
| 485 delete pContext; | 485 delete pContext; |
| 486 pPage->RemovePrivateData((void*)1); | 486 pPage->RemovePrivateData((void*)1); |
| 487 } | 487 } |
| 488 #endif | 488 #endif |
| 489 | 489 |
| 490 DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, FPDF_PAGE page, int start_x, int start_y, | 490 DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, FPDF_PAGE page, int start_x, int start_y, |
| 491 » » » » » » int size_x, int size_y, int rota te, int flags) | 491 int size_x, int size_y, int rotate, int flags) |
| 492 { | 492 { |
| 493 » if (bitmap == NULL || page == NULL) return; | 493 if (bitmap == NULL || page == NULL) return; |
| 494 » CPDF_Page* pPage = (CPDF_Page*)page; | 494 CPDF_Page* pPage = (CPDF_Page*)page; |
| 495 | 495 |
| 496 | 496 |
| 497 » CRenderContext* pContext = new CRenderContext; | 497 CRenderContext* pContext = new CRenderContext; |
| 498 » pPage->SetPrivateData((void*)1, pContext, DropContext); | 498 pPage->SetPrivateData((void*)1, pContext, DropContext); |
| 499 #ifdef _SKIA_SUPPORT_ | 499 #ifdef _SKIA_SUPPORT_ |
| 500 » pContext->m_pDevice = new CFX_SkiaDevice; | 500 pContext->m_pDevice = new CFX_SkiaDevice; |
| 501 | 501 |
| 502 » if (flags & FPDF_REVERSE_BYTE_ORDER) | 502 if (flags & FPDF_REVERSE_BYTE_ORDER) |
| 503 » » ((CFX_SkiaDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bi tmap,0,TRUE); | 503 ((CFX_SkiaDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap,0,T RUE); |
| 504 » else | 504 else |
| 505 » » ((CFX_SkiaDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bi tmap); | 505 ((CFX_SkiaDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap); |
| 506 #else | 506 #else |
| 507 » pContext->m_pDevice = new CFX_FxgeDevice; | 507 pContext->m_pDevice = new CFX_FxgeDevice; |
| 508 | 508 |
| 509 » if (flags & FPDF_REVERSE_BYTE_ORDER) | 509 if (flags & FPDF_REVERSE_BYTE_ORDER) |
| 510 » » ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bi tmap,0,TRUE); | 510 ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap,0,T RUE); |
| 511 » else | 511 else |
| 512 » » ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bi tmap); | 512 ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap); |
| 513 #endif | 513 #endif |
| 514 | 514 |
| 515 » FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y, | 515 FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y, |
| 516 rotate, flags, TRUE, NULL); | 516 rotate, flags, TRUE, NULL); |
| 517 | 517 |
| 518 » delete pContext; | 518 delete pContext; |
| 519 » pPage->RemovePrivateData((void*)1); | 519 pPage->RemovePrivateData((void*)1); |
| 520 } | 520 } |
| 521 | 521 |
| 522 DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page) | 522 DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page) |
| 523 { | 523 { |
| 524 » if (!page) return; | 524 if (!page) return; |
| 525 CPDFSDK_PageView* pPageView = (CPDFSDK_PageView*)(((CPDF_Page*)page))->G etPrivateData((void*)page); | 525 CPDFSDK_PageView* pPageView = (CPDFSDK_PageView*)(((CPDF_Page*)page))->G etPrivateData((void*)page); |
| 526 if (pPageView && pPageView->IsLocked()) { | 526 if (pPageView && pPageView->IsLocked()) { |
| 527 pPageView->TakeOverPage(); | 527 pPageView->TakeOverPage(); |
| 528 return; | 528 return; |
| 529 } | 529 } |
| 530 » delete (CPDF_Page*)page; | 530 delete (CPDF_Page*)page; |
| 531 | 531 |
| 532 } | 532 } |
| 533 | 533 |
| 534 DLLEXPORT void STDCALL FPDF_CloseDocument(FPDF_DOCUMENT document) | 534 DLLEXPORT void STDCALL FPDF_CloseDocument(FPDF_DOCUMENT document) |
| 535 { | 535 { |
| 536 » if (!document) | 536 if (!document) |
| 537 » » return; | 537 return; |
| 538 » CPDF_Document* pDoc = (CPDF_Document*)document; | 538 CPDF_Document* pDoc = (CPDF_Document*)document; |
| 539 » CPDF_Parser* pParser = (CPDF_Parser*)pDoc->GetParser(); | 539 CPDF_Parser* pParser = (CPDF_Parser*)pDoc->GetParser(); |
| 540 » if (pParser == NULL) | 540 if (pParser == NULL) |
| 541 » { | 541 { |
| 542 » » delete pDoc; | 542 delete pDoc; |
| 543 » » return; | 543 return; |
| 544 » } | 544 } |
| 545 » delete pParser; | 545 delete pParser; |
| 546 } | 546 } |
| 547 | 547 |
| 548 DLLEXPORT unsigned long STDCALL FPDF_GetLastError() | 548 DLLEXPORT unsigned long STDCALL FPDF_GetLastError() |
| 549 { | 549 { |
| 550 » return GetLastError(); | 550 return GetLastError(); |
| 551 } | 551 } |
| 552 | 552 |
| 553 DLLEXPORT void STDCALL FPDF_DeviceToPage(FPDF_PAGE page, int start_x, int start_ y, int size_x, int size_y, | 553 DLLEXPORT void STDCALL FPDF_DeviceToPage(FPDF_PAGE page, int start_x, int start_ y, int size_x, int size_y, |
| 554 » » » » » » int rotate, int device_x, int de vice_y, double* page_x, double* page_y) | 554 int rotate, int device_x, int device_y, double* page_x, double* page_y) |
| 555 { | 555 { |
| 556 » if (page == NULL || page_x == NULL || page_y == NULL) return; | 556 if (page == NULL || page_x == NULL || page_y == NULL) return; |
| 557 » CPDF_Page* pPage = (CPDF_Page*)page; | 557 CPDF_Page* pPage = (CPDF_Page*)page; |
| 558 | 558 |
| 559 » CPDF_Matrix page2device; | 559 CPDF_Matrix page2device; |
| 560 » pPage->GetDisplayMatrix(page2device, start_x, start_y, size_x, size_y, r otate); | 560 pPage->GetDisplayMatrix(page2device, start_x, start_y, size_x, size_y, rotat e); |
| 561 » CPDF_Matrix device2page; | 561 CPDF_Matrix device2page; |
| 562 » device2page.SetReverse(page2device); | 562 device2page.SetReverse(page2device); |
| 563 | 563 |
| 564 » FX_FLOAT page_x_f, page_y_f; | 564 FX_FLOAT page_x_f, page_y_f; |
| 565 » device2page.Transform((FX_FLOAT)(device_x), (FX_FLOAT)(device_y), page_x _f, page_y_f); | 565 device2page.Transform((FX_FLOAT)(device_x), (FX_FLOAT)(device_y), page_x_f, page_y_f); |
| 566 | 566 |
| 567 » *page_x = (page_x_f); | 567 *page_x = (page_x_f); |
| 568 » *page_y = (page_y_f); | 568 *page_y = (page_y_f); |
| 569 } | 569 } |
| 570 | 570 |
| 571 DLLEXPORT void STDCALL FPDF_PageToDevice(FPDF_PAGE page, int start_x, int start_ y, int size_x, int size_y, | 571 DLLEXPORT void STDCALL FPDF_PageToDevice(FPDF_PAGE page, int start_x, int start_ y, int size_x, int size_y, |
| 572 » » » » » » int rotate, double page_x, doubl e page_y, int* device_x, int* device_y) | 572 int rotate, double page_x, double page_y, int* device_x, int* device_y) |
| 573 { | 573 { |
| 574 » if (page == NULL || device_x == NULL || device_y == NULL) return; | 574 if (page == NULL || device_x == NULL || device_y == NULL) return; |
| 575 » CPDF_Page* pPage = (CPDF_Page*)page; | 575 CPDF_Page* pPage = (CPDF_Page*)page; |
| 576 | 576 |
| 577 » CPDF_Matrix page2device; | 577 CPDF_Matrix page2device; |
| 578 » pPage->GetDisplayMatrix(page2device, start_x, start_y, size_x, size_y, r otate); | 578 pPage->GetDisplayMatrix(page2device, start_x, start_y, size_x, size_y, rotat e); |
| 579 | 579 |
| 580 » FX_FLOAT device_x_f, device_y_f; | 580 FX_FLOAT device_x_f, device_y_f; |
| 581 » page2device.Transform(((FX_FLOAT)page_x), ((FX_FLOAT)page_y), device_x_f , device_y_f); | 581 page2device.Transform(((FX_FLOAT)page_x), ((FX_FLOAT)page_y), device_x_f, de vice_y_f); |
| 582 | 582 |
| 583 » *device_x = FXSYS_round(device_x_f); | 583 *device_x = FXSYS_round(device_x_f); |
| 584 » *device_y = FXSYS_round(device_y_f); | 584 *device_y = FXSYS_round(device_y_f); |
| 585 } | 585 } |
| 586 | 586 |
| 587 DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width, int height, int alpha ) | 587 DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width, int height, int alpha ) |
| 588 { | 588 { |
| 589 nonstd::unique_ptr<CFX_DIBitmap> pBitmap(new CFX_DIBitmap); | 589 nonstd::unique_ptr<CFX_DIBitmap> pBitmap(new CFX_DIBitmap); |
| 590 if (!pBitmap->Create(width, height, alpha ? FXDIB_Argb : FXDIB_Rgb32)) { | 590 if (!pBitmap->Create(width, height, alpha ? FXDIB_Argb : FXDIB_Rgb32)) { |
| 591 return NULL; | 591 return NULL; |
| 592 } | 592 } |
| 593 return pBitmap.release(); | 593 return pBitmap.release(); |
| 594 } | 594 } |
| 595 | 595 |
| 596 DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_CreateEx(int width, int height, int for mat, void* first_scan, int stride) | 596 DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_CreateEx(int width, int height, int for mat, void* first_scan, int stride) |
| 597 { | 597 { |
| 598 » FXDIB_Format fx_format; | 598 FXDIB_Format fx_format; |
| 599 » switch (format) { | 599 switch (format) { |
| 600 » » case FPDFBitmap_Gray: | 600 case FPDFBitmap_Gray: |
| 601 » » » fx_format = FXDIB_8bppRgb; | 601 fx_format = FXDIB_8bppRgb; |
| 602 » » » break; | 602 break; |
| 603 » » case FPDFBitmap_BGR: | 603 case FPDFBitmap_BGR: |
| 604 » » » fx_format = FXDIB_Rgb; | 604 fx_format = FXDIB_Rgb; |
| 605 » » » break; | 605 break; |
| 606 » » case FPDFBitmap_BGRx: | 606 case FPDFBitmap_BGRx: |
| 607 » » » fx_format = FXDIB_Rgb32; | 607 fx_format = FXDIB_Rgb32; |
| 608 » » » break; | 608 break; |
| 609 » » case FPDFBitmap_BGRA: | 609 case FPDFBitmap_BGRA: |
| 610 » » » fx_format = FXDIB_Argb; | 610 fx_format = FXDIB_Argb; |
| 611 » » » break; | 611 break; |
| 612 » » default: | 612 default: |
| 613 » » » return NULL; | 613 return NULL; |
| 614 » } | 614 } |
| 615 » CFX_DIBitmap* pBitmap = new CFX_DIBitmap; | 615 CFX_DIBitmap* pBitmap = new CFX_DIBitmap; |
| 616 » pBitmap->Create(width, height, fx_format, (uint8_t*)first_scan, stride); | 616 pBitmap->Create(width, height, fx_format, (uint8_t*)first_scan, stride); |
| 617 » return pBitmap; | 617 return pBitmap; |
| 618 } | 618 } |
| 619 | 619 |
| 620 DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap, int left, int top , int width, int height, FPDF_DWORD color) | 620 DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap, int left, int top , int width, int height, FPDF_DWORD color) |
| 621 { | 621 { |
| 622 » if (bitmap == NULL) return; | 622 if (bitmap == NULL) return; |
| 623 #ifdef _SKIA_SUPPORT_ | 623 #ifdef _SKIA_SUPPORT_ |
| 624 » CFX_SkiaDevice device; | 624 CFX_SkiaDevice device; |
| 625 #else | 625 #else |
| 626 » CFX_FxgeDevice device; | 626 CFX_FxgeDevice device; |
| 627 #endif | 627 #endif |
| 628 » device.Attach((CFX_DIBitmap*)bitmap); | 628 device.Attach((CFX_DIBitmap*)bitmap); |
| 629 » if (!((CFX_DIBitmap*)bitmap)->HasAlpha()) color |= 0xFF000000; | 629 if (!((CFX_DIBitmap*)bitmap)->HasAlpha()) color |= 0xFF000000; |
| 630 » FX_RECT rect(left, top, left+width, top+height); | 630 FX_RECT rect(left, top, left+width, top+height); |
| 631 » device.FillRect(&rect, color); | 631 device.FillRect(&rect, color); |
| 632 } | 632 } |
| 633 | 633 |
| 634 DLLEXPORT void* STDCALL FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap) | 634 DLLEXPORT void* STDCALL FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap) |
| 635 { | 635 { |
| 636 » if (bitmap == NULL) return NULL; | 636 if (bitmap == NULL) return NULL; |
| 637 » return ((CFX_DIBitmap*)bitmap)->GetBuffer(); | 637 return ((CFX_DIBitmap*)bitmap)->GetBuffer(); |
| 638 } | 638 } |
| 639 | 639 |
| 640 DLLEXPORT int STDCALL FPDFBitmap_GetWidth(FPDF_BITMAP bitmap) | 640 DLLEXPORT int STDCALL FPDFBitmap_GetWidth(FPDF_BITMAP bitmap) |
| 641 { | 641 { |
| 642 » if (bitmap == NULL) return 0; | 642 if (bitmap == NULL) return 0; |
| 643 » return ((CFX_DIBitmap*)bitmap)->GetWidth(); | 643 return ((CFX_DIBitmap*)bitmap)->GetWidth(); |
| 644 } | 644 } |
| 645 | 645 |
| 646 DLLEXPORT int STDCALL FPDFBitmap_GetHeight(FPDF_BITMAP bitmap) | 646 DLLEXPORT int STDCALL FPDFBitmap_GetHeight(FPDF_BITMAP bitmap) |
| 647 { | 647 { |
| 648 » if (bitmap == NULL) return 0; | 648 if (bitmap == NULL) return 0; |
| 649 » return ((CFX_DIBitmap*)bitmap)->GetHeight(); | 649 return ((CFX_DIBitmap*)bitmap)->GetHeight(); |
| 650 } | 650 } |
| 651 | 651 |
| 652 DLLEXPORT int STDCALL FPDFBitmap_GetStride(FPDF_BITMAP bitmap) | 652 DLLEXPORT int STDCALL FPDFBitmap_GetStride(FPDF_BITMAP bitmap) |
| 653 { | 653 { |
| 654 » if (bitmap == NULL) return 0; | 654 if (bitmap == NULL) return 0; |
| 655 » return ((CFX_DIBitmap*)bitmap)->GetPitch(); | 655 return ((CFX_DIBitmap*)bitmap)->GetPitch(); |
| 656 } | 656 } |
| 657 | 657 |
| 658 DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap) | 658 DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap) |
| 659 { | 659 { |
| 660 delete (CFX_DIBitmap*)bitmap; | 660 delete (CFX_DIBitmap*)bitmap; |
| 661 } | 661 } |
| 662 | 662 |
| 663 void FPDF_RenderPage_Retail(CRenderContext* pContext, FPDF_PAGE page, int start_ x, int start_y, int size_x, int size_y, | 663 void FPDF_RenderPage_Retail(CRenderContext* pContext, FPDF_PAGE page, int start_ x, int start_y, int size_x, int size_y, |
| 664 int rotate, int flags,FX_BOOL bNeedToRestore, IFSDK_ PAUSE_Adapter * pause ) | 664 int rotate, int flags,FX_BOOL bNeedToRestore, IFSDK_ PAUSE_Adapter * pause ) |
| 665 { | 665 { |
| 666 » CPDF_Page* pPage = (CPDF_Page*)page; | 666 CPDF_Page* pPage = (CPDF_Page*)page; |
| 667 » if (pPage == NULL) return; | 667 if (pPage == NULL) return; |
| 668 | 668 |
| 669 » if (!pContext->m_pOptions) | 669 if (!pContext->m_pOptions) |
| 670 » » pContext->m_pOptions = new CPDF_RenderOptions; | 670 pContext->m_pOptions = new CPDF_RenderOptions; |
| 671 | 671 |
| 672 » if (flags & FPDF_LCD_TEXT) | 672 if (flags & FPDF_LCD_TEXT) |
| 673 » » pContext->m_pOptions->m_Flags |= RENDER_CLEARTYPE; | 673 pContext->m_pOptions->m_Flags |= RENDER_CLEARTYPE; |
| 674 » else | 674 else |
| 675 » » pContext->m_pOptions->m_Flags &= ~RENDER_CLEARTYPE; | 675 pContext->m_pOptions->m_Flags &= ~RENDER_CLEARTYPE; |
| 676 » if (flags & FPDF_NO_NATIVETEXT) | 676 if (flags & FPDF_NO_NATIVETEXT) |
| 677 » » pContext->m_pOptions->m_Flags |= RENDER_NO_NATIVETEXT; | 677 pContext->m_pOptions->m_Flags |= RENDER_NO_NATIVETEXT; |
| 678 » if (flags & FPDF_RENDER_LIMITEDIMAGECACHE) | 678 if (flags & FPDF_RENDER_LIMITEDIMAGECACHE) |
| 679 » » pContext->m_pOptions->m_Flags |= RENDER_LIMITEDIMAGECACHE; | 679 pContext->m_pOptions->m_Flags |= RENDER_LIMITEDIMAGECACHE; |
| 680 » if (flags & FPDF_RENDER_FORCEHALFTONE) | 680 if (flags & FPDF_RENDER_FORCEHALFTONE) |
| 681 » » pContext->m_pOptions->m_Flags |= RENDER_FORCE_HALFTONE; | 681 pContext->m_pOptions->m_Flags |= RENDER_FORCE_HALFTONE; |
| 682 » if (flags & FPDF_RENDER_NO_SMOOTHTEXT) | 682 if (flags & FPDF_RENDER_NO_SMOOTHTEXT) |
| 683 » » pContext->m_pOptions->m_Flags |= RENDER_NOTEXTSMOOTH; | 683 pContext->m_pOptions->m_Flags |= RENDER_NOTEXTSMOOTH; |
| 684 » if (flags & FPDF_RENDER_NO_SMOOTHIMAGE) | 684 if (flags & FPDF_RENDER_NO_SMOOTHIMAGE) |
| 685 » » pContext->m_pOptions->m_Flags |= RENDER_NOIMAGESMOOTH; | 685 pContext->m_pOptions->m_Flags |= RENDER_NOIMAGESMOOTH; |
| 686 » if (flags & FPDF_RENDER_NO_SMOOTHPATH) | 686 if (flags & FPDF_RENDER_NO_SMOOTHPATH) |
| 687 » » pContext->m_pOptions->m_Flags |= RENDER_NOPATHSMOOTH; | 687 pContext->m_pOptions->m_Flags |= RENDER_NOPATHSMOOTH; |
| 688 » //Grayscale output | 688 //Grayscale output |
| 689 » if (flags & FPDF_GRAYSCALE) | 689 if (flags & FPDF_GRAYSCALE) |
| 690 » { | 690 { |
| 691 » » pContext->m_pOptions->m_ColorMode = RENDER_COLOR_GRAY; | 691 pContext->m_pOptions->m_ColorMode = RENDER_COLOR_GRAY; |
| 692 » » pContext->m_pOptions->m_ForeColor = 0; | 692 pContext->m_pOptions->m_ForeColor = 0; |
| 693 » » pContext->m_pOptions->m_BackColor = 0xffffff; | 693 pContext->m_pOptions->m_BackColor = 0xffffff; |
| 694 » } | 694 } |
| 695 » const CPDF_OCContext::UsageType usage = (flags & FPDF_PRINTING) ? CPDF_O CContext::Print : CPDF_OCContext::View; | 695 const CPDF_OCContext::UsageType usage = (flags & FPDF_PRINTING) ? CPDF_OCCon text::Print : CPDF_OCContext::View; |
| 696 » pContext->m_pOptions->m_AddFlags = flags >> 8; | 696 pContext->m_pOptions->m_AddFlags = flags >> 8; |
| 697 » pContext->m_pOptions->m_pOCContext = new CPDF_OCContext(pPage->m_pDocume nt, usage); | 697 pContext->m_pOptions->m_pOCContext = new CPDF_OCContext(pPage->m_pDocument, usage); |
| 698 | 698 |
| 699 » CFX_AffineMatrix matrix; | 699 CFX_AffineMatrix matrix; |
| 700 » pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate ); | 700 pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate); |
| 701 | 701 |
| 702 » FX_RECT clip; | 702 FX_RECT clip; |
| 703 » clip.left = start_x; | 703 clip.left = start_x; |
| 704 » clip.right = start_x + size_x; | 704 clip.right = start_x + size_x; |
| 705 » clip.top = start_y; | 705 clip.top = start_y; |
| 706 » clip.bottom = start_y + size_y; | 706 clip.bottom = start_y + size_y; |
| 707 » pContext->m_pDevice->SaveState(); | 707 pContext->m_pDevice->SaveState(); |
| 708 » pContext->m_pDevice->SetClip_Rect(&clip); | 708 pContext->m_pDevice->SetClip_Rect(&clip); |
| 709 | 709 |
| 710 » pContext->m_pContext = new CPDF_RenderContext; | 710 pContext->m_pContext = new CPDF_RenderContext; |
| 711 » pContext->m_pContext->Create(pPage); | 711 pContext->m_pContext->Create(pPage); |
| 712 » pContext->m_pContext->AppendObjectList(pPage, &matrix); | 712 pContext->m_pContext->AppendObjectList(pPage, &matrix); |
| 713 | 713 |
| 714 » if (flags & FPDF_ANNOT) { | 714 if (flags & FPDF_ANNOT) { |
| 715 » » pContext->m_pAnnots = new CPDF_AnnotList(pPage); | 715 pContext->m_pAnnots = new CPDF_AnnotList(pPage); |
| 716 » » FX_BOOL bPrinting = pContext->m_pDevice->GetDeviceClass() != FXD C_DISPLAY; | 716 FX_BOOL bPrinting = pContext->m_pDevice->GetDeviceClass() != FXDC_DISPLA Y; |
| 717 » » pContext->m_pAnnots->DisplayAnnots(pPage, pContext->m_pContext, bPrinting, &matrix, TRUE, NULL); | 717 pContext->m_pAnnots->DisplayAnnots(pPage, pContext->m_pContext, bPrintin g, &matrix, TRUE, NULL); |
| 718 » } | 718 } |
| 719 | 719 |
| 720 » pContext->m_pRenderer = new CPDF_ProgressiveRenderer; | 720 pContext->m_pRenderer = new CPDF_ProgressiveRenderer( |
| 721 » pContext->m_pRenderer->Start(pContext->m_pContext, pContext->m_pDevice, pContext->m_pOptions, pause); | 721 pContext->m_pContext, pContext->m_pDevice, pContext->m_pOptions); |
| 722 » if (bNeedToRestore) | 722 pContext->m_pRenderer->Start(pause); |
| 723 » { | 723 if (bNeedToRestore) |
| 724 » » pContext->m_pDevice->RestoreState(); | 724 pContext->m_pDevice->RestoreState(); |
| 725 » } | |
| 726 } | 725 } |
| 727 | 726 |
| 728 DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, int page_i ndex, double* width, double* height) | 727 DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, int page_i ndex, double* width, double* height) |
| 729 { | 728 { |
| 730 » CPDF_Document* pDoc = (CPDF_Document*)document; | 729 CPDF_Document* pDoc = (CPDF_Document*)document; |
| 731 » if(pDoc == NULL) | 730 if(pDoc == NULL) |
| 732 » » return FALSE; | 731 return FALSE; |
| 733 | 732 |
| 734 » CPDF_Dictionary* pDict = pDoc->GetPage(page_index); | 733 CPDF_Dictionary* pDict = pDoc->GetPage(page_index); |
| 735 » if (pDict == NULL) return FALSE; | 734 if (pDict == NULL) return FALSE; |
| 736 | 735 |
| 737 » CPDF_Page page; | 736 CPDF_Page page; |
| 738 » page.Load(pDoc, pDict); | 737 page.Load(pDoc, pDict); |
| 739 » *width = page.GetPageWidth(); | 738 *width = page.GetPageWidth(); |
| 740 » *height = page.GetPageHeight(); | 739 *height = page.GetPageHeight(); |
| 741 | 740 |
| 742 » return TRUE; | 741 return TRUE; |
| 743 } | 742 } |
| 744 | 743 |
| 745 DLLEXPORT FPDF_BOOL STDCALL FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT documen t) | 744 DLLEXPORT FPDF_BOOL STDCALL FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT documen t) |
| 746 { | 745 { |
| 747 » CPDF_Document* pDoc = (CPDF_Document*)document; | 746 CPDF_Document* pDoc = (CPDF_Document*)document; |
| 748 » if (!pDoc) return TRUE; | 747 if (!pDoc) return TRUE; |
| 749 » CPDF_ViewerPreferences viewRef(pDoc); | 748 CPDF_ViewerPreferences viewRef(pDoc); |
| 750 » return viewRef.PrintScaling(); | 749 return viewRef.PrintScaling(); |
| 751 } | 750 } |
| 752 | 751 |
| 753 DLLEXPORT int STDCALL FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document) | 752 DLLEXPORT int STDCALL FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document) |
| 754 { | 753 { |
| 755 CPDF_Document* pDoc = (CPDF_Document*)document; | 754 CPDF_Document* pDoc = (CPDF_Document*)document; |
| 756 if (!pDoc) return 1; | 755 if (!pDoc) return 1; |
| 757 CPDF_ViewerPreferences viewRef(pDoc); | 756 CPDF_ViewerPreferences viewRef(pDoc); |
| 758 return viewRef.NumCopies(); | 757 return viewRef.NumCopies(); |
| 759 } | 758 } |
| 760 | 759 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 792 CPDF_NameTree nameTree(pDoc, FX_BSTRC("Dests")); | 791 CPDF_NameTree nameTree(pDoc, FX_BSTRC("Dests")); |
| 793 int count = nameTree.GetCount(); | 792 int count = nameTree.GetCount(); |
| 794 CPDF_Dictionary* pDest = pRoot->GetDict(FX_BSTRC("Dests")); | 793 CPDF_Dictionary* pDest = pRoot->GetDict(FX_BSTRC("Dests")); |
| 795 if (pDest) | 794 if (pDest) |
| 796 count += pDest->GetCount(); | 795 count += pDest->GetCount(); |
| 797 return count; | 796 return count; |
| 798 } | 797 } |
| 799 | 798 |
| 800 DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document,FPDF_ BYTESTRING name) | 799 DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document,FPDF_ BYTESTRING name) |
| 801 { | 800 { |
| 802 » if (!document) | 801 if (!document) |
| 803 » » return NULL; | 802 return NULL; |
| 804 » if (!name || name[0] == 0) | 803 if (!name || name[0] == 0) |
| 805 » » return NULL; | 804 return NULL; |
| 806 | 805 |
| 807 » CPDF_Document* pDoc = (CPDF_Document*)document; | 806 CPDF_Document* pDoc = (CPDF_Document*)document; |
| 808 » CPDF_NameTree name_tree(pDoc, FX_BSTRC("Dests")); | 807 CPDF_NameTree name_tree(pDoc, FX_BSTRC("Dests")); |
| 809 » return name_tree.LookupNamedDest(pDoc, name); | 808 return name_tree.LookupNamedDest(pDoc, name); |
| 810 } | 809 } |
| 811 | 810 |
| 812 DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document, int index, void* buffer, long* buflen) | 811 DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document, int index, void* buffer, long* buflen) |
| 813 { | 812 { |
| 814 if (!buffer) | 813 if (!buffer) |
| 815 *buflen = 0; | 814 *buflen = 0; |
| 816 if (!document || index < 0) return NULL; | 815 if (!document || index < 0) return NULL; |
| 817 CPDF_Document* pDoc = (CPDF_Document*)document; | 816 CPDF_Document* pDoc = (CPDF_Document*)document; |
| 818 | 817 |
| 819 CPDF_Dictionary* pRoot = pDoc->GetRoot(); | 818 CPDF_Dictionary* pRoot = pDoc->GetRoot(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 851 if (!buffer) { | 850 if (!buffer) { |
| 852 *buflen = len; | 851 *buflen = len; |
| 853 } else if (*buflen >= len) { | 852 } else if (*buflen >= len) { |
| 854 memcpy(buffer, utf16Name.c_str(), len); | 853 memcpy(buffer, utf16Name.c_str(), len); |
| 855 *buflen = len; | 854 *buflen = len; |
| 856 } else { | 855 } else { |
| 857 *buflen = -1; | 856 *buflen = -1; |
| 858 } | 857 } |
| 859 return (FPDF_DEST)pDestObj; | 858 return (FPDF_DEST)pDestObj; |
| 860 } | 859 } |
| OLD | NEW |