| 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/fpdfdoc/fpdf_doc.h" | 7 #include "../../include/fpdfdoc/fpdf_doc.h" |
| 8 #include "../../include/fpdfdoc/fpdf_vt.h" | 8 #include "../../include/fpdfdoc/fpdf_vt.h" |
| 9 #include "pdf_vt.h" | 9 #include "pdf_vt.h" |
| 10 #include "../../include/fpdfdoc/fpdf_ap.h" | 10 #include "../../include/fpdfdoc/fpdf_ap.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 } | 35 } |
| 36 } | 36 } |
| 37 return FALSE; | 37 return FALSE; |
| 38 } | 38 } |
| 39 class CPVT_FontMap : public IPVT_FontMap | 39 class CPVT_FontMap : public IPVT_FontMap |
| 40 { | 40 { |
| 41 public: | 41 public: |
| 42 CPVT_FontMap(CPDF_Document * pDoc, CPDF_Dictionary * pResDict, CPDF_Font * p
DefFont, | 42 CPVT_FontMap(CPDF_Document * pDoc, CPDF_Dictionary * pResDict, CPDF_Font * p
DefFont, |
| 43 const CFX_ByteString & sDefFontAlias); | 43 const CFX_ByteString & sDefFontAlias); |
| 44 virtual ~CPVT_FontMap(); | 44 virtual ~CPVT_FontMap(); |
| 45 CPDF_Font*» » » » » » GetPDFFont(FX_INT32 nFon
tIndex); | 45 CPDF_Font*» » » » » » GetPDFFont(int32_t nFont
Index); |
| 46 CFX_ByteString» » » » » GetPDFFontAlias(FX_INT32
nFontIndex); | 46 CFX_ByteString» » » » » GetPDFFontAlias(int32_t
nFontIndex); |
| 47 static void GetAnnotSysPDFFont(CPDF_
Document * pDoc, CPDF_Dictionary * pResDict, | 47 static void GetAnnotSysPDFFont(CPDF_
Document * pDoc, CPDF_Dictionary * pResDict, |
| 48 CPDF_Font * & pSysFont, CFX_ByteString & sSysFontAlias); | 48 CPDF_Font * & pSysFont, CFX_ByteString & sSysFontAlias); |
| 49 private: | 49 private: |
| 50 CPDF_Document* m_pDocument; | 50 CPDF_Document* m_pDocument; |
| 51 CPDF_Dictionary* m_pResDict; | 51 CPDF_Dictionary* m_pResDict; |
| 52 CPDF_Font* m_pDefFont; | 52 CPDF_Font* m_pDefFont; |
| 53 CFX_ByteString m_sDefFontAlias; | 53 CFX_ByteString m_sDefFontAlias; |
| 54 CPDF_Font* m_pSysFont; | 54 CPDF_Font* m_pSysFont; |
| 55 CFX_ByteString m_sSysFontAlias; | 55 CFX_ByteString m_sSysFontAlias; |
| 56 }; | 56 }; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 77 if (CPDF_Font * pPDFFont = AddNativeInterFormFont(pFormDict, pDoc, sSysF
ontAlias)) { | 77 if (CPDF_Font * pPDFFont = AddNativeInterFormFont(pFormDict, pDoc, sSysF
ontAlias)) { |
| 78 if (CPDF_Dictionary * pFontList = pResDict->GetDict("Font")) { | 78 if (CPDF_Dictionary * pFontList = pResDict->GetDict("Font")) { |
| 79 if (!pFontList->KeyExist(sSysFontAlias)) { | 79 if (!pFontList->KeyExist(sSysFontAlias)) { |
| 80 pFontList->SetAtReference(sSysFontAlias, pDoc, pPDFFont->Get
FontDict()); | 80 pFontList->SetAtReference(sSysFontAlias, pDoc, pPDFFont->Get
FontDict()); |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 pSysFont = pPDFFont; | 83 pSysFont = pPDFFont; |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 CPDF_Font* CPVT_FontMap::GetPDFFont(FX_INT32 nFontIndex) | 87 CPDF_Font* CPVT_FontMap::GetPDFFont(int32_t nFontIndex) |
| 88 { | 88 { |
| 89 switch (nFontIndex) { | 89 switch (nFontIndex) { |
| 90 case 0: | 90 case 0: |
| 91 return m_pDefFont; | 91 return m_pDefFont; |
| 92 case 1: | 92 case 1: |
| 93 if (!m_pSysFont) { | 93 if (!m_pSysFont) { |
| 94 GetAnnotSysPDFFont(m_pDocument, m_pResDict, m_pSysFont, m_sSysFo
ntAlias); | 94 GetAnnotSysPDFFont(m_pDocument, m_pResDict, m_pSysFont, m_sSysFo
ntAlias); |
| 95 } | 95 } |
| 96 return m_pSysFont; | 96 return m_pSysFont; |
| 97 } | 97 } |
| 98 return NULL; | 98 return NULL; |
| 99 } | 99 } |
| 100 CFX_ByteString CPVT_FontMap::GetPDFFontAlias(FX_INT32 nFontIndex) | 100 CFX_ByteString CPVT_FontMap::GetPDFFontAlias(int32_t nFontIndex) |
| 101 { | 101 { |
| 102 switch (nFontIndex) { | 102 switch (nFontIndex) { |
| 103 case 0: | 103 case 0: |
| 104 return m_sDefFontAlias; | 104 return m_sDefFontAlias; |
| 105 case 1: | 105 case 1: |
| 106 if (!m_pSysFont) { | 106 if (!m_pSysFont) { |
| 107 GetAnnotSysPDFFont(m_pDocument, m_pResDict, m_pSysFont, m_sSysFo
ntAlias); | 107 GetAnnotSysPDFFont(m_pDocument, m_pResDict, m_pSysFont, m_sSysFo
ntAlias); |
| 108 } | 108 } |
| 109 return m_sSysFontAlias; | 109 return m_sSysFontAlias; |
| 110 } | 110 } |
| 111 return ""; | 111 return ""; |
| 112 } | 112 } |
| 113 CPVT_Provider::CPVT_Provider(IPVT_FontMap * pFontMap) : m_pFontMap(pFontMap) | 113 CPVT_Provider::CPVT_Provider(IPVT_FontMap * pFontMap) : m_pFontMap(pFontMap) |
| 114 { | 114 { |
| 115 ASSERT (m_pFontMap != NULL); | 115 ASSERT (m_pFontMap != NULL); |
| 116 } | 116 } |
| 117 CPVT_Provider::~CPVT_Provider() | 117 CPVT_Provider::~CPVT_Provider() |
| 118 { | 118 { |
| 119 } | 119 } |
| 120 FX_INT32 CPVT_Provider::GetCharWidth(FX_INT32 nFontIndex, FX_WORD word, FX_INT32
nWordStyle) | 120 int32_t CPVT_Provider::GetCharWidth(int32_t nFontIndex, FX_WORD word, int32_t nW
ordStyle) |
| 121 { | 121 { |
| 122 if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex)) { | 122 if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex)) { |
| 123 FX_DWORD charcode = pPDFFont->CharCodeFromUnicode(word); | 123 FX_DWORD charcode = pPDFFont->CharCodeFromUnicode(word); |
| 124 if (charcode != -1) { | 124 if (charcode != -1) { |
| 125 return pPDFFont->GetCharWidthF(charcode); | 125 return pPDFFont->GetCharWidthF(charcode); |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 return 0; | 128 return 0; |
| 129 } | 129 } |
| 130 FX_INT32 CPVT_Provider::GetTypeAscent(FX_INT32 nFontIndex) | 130 int32_t CPVT_Provider::GetTypeAscent(int32_t nFontIndex) |
| 131 { | 131 { |
| 132 if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex)) { | 132 if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex)) { |
| 133 return pPDFFont->GetTypeAscent(); | 133 return pPDFFont->GetTypeAscent(); |
| 134 } | 134 } |
| 135 return 0; | 135 return 0; |
| 136 } | 136 } |
| 137 FX_INT32 CPVT_Provider::GetTypeDescent(FX_INT32 nFontIndex) | 137 int32_t CPVT_Provider::GetTypeDescent(int32_t nFontIndex) |
| 138 { | 138 { |
| 139 if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex)) { | 139 if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex)) { |
| 140 return pPDFFont->GetTypeDescent(); | 140 return pPDFFont->GetTypeDescent(); |
| 141 } | 141 } |
| 142 return 0; | 142 return 0; |
| 143 } | 143 } |
| 144 FX_INT32 CPVT_Provider::GetWordFontIndex(FX_WORD word, FX_INT32 charset, FX_INT3
2 nFontIndex) | 144 int32_t CPVT_Provider::GetWordFontIndex(FX_WORD word, int32_t charset, int32_t n
FontIndex) |
| 145 { | 145 { |
| 146 if (CPDF_Font* pDefFont = m_pFontMap->GetPDFFont(0)) { | 146 if (CPDF_Font* pDefFont = m_pFontMap->GetPDFFont(0)) { |
| 147 if (pDefFont->CharCodeFromUnicode(word) != -1) { | 147 if (pDefFont->CharCodeFromUnicode(word) != -1) { |
| 148 return 0; | 148 return 0; |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 if (CPDF_Font* pSysFont = m_pFontMap->GetPDFFont(1)) | 151 if (CPDF_Font* pSysFont = m_pFontMap->GetPDFFont(1)) |
| 152 if (pSysFont->CharCodeFromUnicode(word) != -1) { | 152 if (pSysFont->CharCodeFromUnicode(word) != -1) { |
| 153 return 1; | 153 return 1; |
| 154 } | 154 } |
| 155 return -1; | 155 return -1; |
| 156 } | 156 } |
| 157 FX_BOOL CPVT_Provider::IsLatinWord(FX_WORD word) | 157 FX_BOOL CPVT_Provider::IsLatinWord(FX_WORD word) |
| 158 { | 158 { |
| 159 if ((word >= 0x61 && word <= 0x7A) || (word >= 0x41 && word <= 0x5A) || word
== 0x2D || word == 0x27) { | 159 if ((word >= 0x61 && word <= 0x7A) || (word >= 0x41 && word <= 0x5A) || word
== 0x2D || word == 0x27) { |
| 160 return TRUE; | 160 return TRUE; |
| 161 } | 161 } |
| 162 return FALSE; | 162 return FALSE; |
| 163 } | 163 } |
| 164 FX_INT32 CPVT_Provider::GetDefaultFontIndex() | 164 int32_t CPVT_Provider::GetDefaultFontIndex() |
| 165 { | 165 { |
| 166 return 0; | 166 return 0; |
| 167 } | 167 } |
| 168 static CFX_ByteString GetPDFWordString(IPVT_FontMap * pFontMap, FX_INT32 nFontIn
dex, FX_WORD Word, FX_WORD SubWord) | 168 static CFX_ByteString GetPDFWordString(IPVT_FontMap * pFontMap, int32_t nFontInd
ex, FX_WORD Word, FX_WORD SubWord) |
| 169 { | 169 { |
| 170 CFX_ByteString sWord; | 170 CFX_ByteString sWord; |
| 171 if (SubWord > 0) { | 171 if (SubWord > 0) { |
| 172 sWord.Format("%c", SubWord); | 172 sWord.Format("%c", SubWord); |
| 173 } else { | 173 } else { |
| 174 if (pFontMap) { | 174 if (pFontMap) { |
| 175 if (CPDF_Font * pPDFFont = pFontMap->GetPDFFont(nFontIndex)) { | 175 if (CPDF_Font * pPDFFont = pFontMap->GetPDFFont(nFontIndex)) { |
| 176 if (pPDFFont->GetBaseFont().Compare("Symbol") == 0 || pPDFFont->
GetBaseFont().Compare("ZapfDingbats") == 0) { | 176 if (pPDFFont->GetBaseFont().Compare("Symbol") == 0 || pPDFFont->
GetBaseFont().Compare("ZapfDingbats") == 0) { |
| 177 sWord.Format("%c", Word); | 177 sWord.Format("%c", Word); |
| 178 } else { | 178 } else { |
| 179 FX_DWORD dwCharCode = pPDFFont->CharCodeFromUnicode(Word); | 179 FX_DWORD dwCharCode = pPDFFont->CharCodeFromUnicode(Word); |
| 180 if (dwCharCode != -1) { | 180 if (dwCharCode != -1) { |
| 181 pPDFFont->AppendChar(sWord, dwCharCode); | 181 pPDFFont->AppendChar(sWord, dwCharCode); |
| 182 } | 182 } |
| 183 } | 183 } |
| 184 } | 184 } |
| 185 } | 185 } |
| 186 } | 186 } |
| 187 return sWord; | 187 return sWord; |
| 188 } | 188 } |
| 189 static CFX_ByteString GetWordRenderString(const CFX_ByteString & strWords) | 189 static CFX_ByteString GetWordRenderString(const CFX_ByteString & strWords) |
| 190 { | 190 { |
| 191 if (strWords.GetLength() > 0) { | 191 if (strWords.GetLength() > 0) { |
| 192 return PDF_EncodeString(strWords) + " Tj\n"; | 192 return PDF_EncodeString(strWords) + " Tj\n"; |
| 193 } | 193 } |
| 194 return ""; | 194 return ""; |
| 195 } | 195 } |
| 196 static CFX_ByteString GetFontSetString(IPVT_FontMap * pFontMap, FX_INT32 nFontIn
dex, FX_FLOAT fFontSize) | 196 static CFX_ByteString GetFontSetString(IPVT_FontMap * pFontMap, int32_t nFontInd
ex, FX_FLOAT fFontSize) |
| 197 { | 197 { |
| 198 CFX_ByteTextBuf sRet; | 198 CFX_ByteTextBuf sRet; |
| 199 if (pFontMap) { | 199 if (pFontMap) { |
| 200 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); | 200 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); |
| 201 if (sFontAlias.GetLength() > 0 && fFontSize > 0 ) { | 201 if (sFontAlias.GetLength() > 0 && fFontSize > 0 ) { |
| 202 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; | 202 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; |
| 203 } | 203 } |
| 204 } | 204 } |
| 205 return sRet.GetByteString(); | 205 return sRet.GetByteString(); |
| 206 } | 206 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 237 break; | 237 break; |
| 238 case 3: | 238 case 3: |
| 239 rt = CPVT_Color(CT_RGB, array.GetFloat(0), array.GetFloat(1), array.
GetFloat(2)); | 239 rt = CPVT_Color(CT_RGB, array.GetFloat(0), array.GetFloat(1), array.
GetFloat(2)); |
| 240 break; | 240 break; |
| 241 case 4: | 241 case 4: |
| 242 rt = CPVT_Color(CT_CMYK, array.GetFloat(0), array.GetFloat(1), array
.GetFloat(2), array.GetFloat(3)); | 242 rt = CPVT_Color(CT_CMYK, array.GetFloat(0), array.GetFloat(1), array
.GetFloat(2), array.GetFloat(3)); |
| 243 break; | 243 break; |
| 244 } | 244 } |
| 245 return rt; | 245 return rt; |
| 246 } | 246 } |
| 247 static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict
, const FX_INT32 & nWidgetType) | 247 static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict
, const int32_t & nWidgetType) |
| 248 { | 248 { |
| 249 CPDF_Dictionary* pFormDict = NULL; | 249 CPDF_Dictionary* pFormDict = NULL; |
| 250 if (CPDF_Dictionary * pRootDict = pDoc->GetRoot()) { | 250 if (CPDF_Dictionary * pRootDict = pDoc->GetRoot()) { |
| 251 pFormDict = pRootDict->GetDict("AcroForm"); | 251 pFormDict = pRootDict->GetDict("AcroForm"); |
| 252 } | 252 } |
| 253 if (!pFormDict) { | 253 if (!pFormDict) { |
| 254 return FALSE; | 254 return FALSE; |
| 255 } | 255 } |
| 256 CFX_ByteString DA; | 256 CFX_ByteString DA; |
| 257 if (CPDF_Object* pDAObj = FPDF_GetFieldAttr(pAnnotDict, "DA")) { | 257 if (CPDF_Object* pDAObj = FPDF_GetFieldAttr(pAnnotDict, "DA")) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 pFontDict->SetAtName(FX_BSTRC("BaseFont"), "Helvetica"); | 303 pFontDict->SetAtName(FX_BSTRC("BaseFont"), "Helvetica"); |
| 304 pFontDict->SetAtName(FX_BSTRC("Encoding"), "WinAnsiEncoding"); | 304 pFontDict->SetAtName(FX_BSTRC("Encoding"), "WinAnsiEncoding"); |
| 305 pDoc->AddIndirectObject(pFontDict); | 305 pDoc->AddIndirectObject(pFontDict); |
| 306 pDRFontDict->SetAtReference(sFontName.Mid(1), pDoc, pFontDict); | 306 pDRFontDict->SetAtReference(sFontName.Mid(1), pDoc, pFontDict); |
| 307 } | 307 } |
| 308 CPDF_Font* pDefFont = pDoc->LoadFont(pFontDict); | 308 CPDF_Font* pDefFont = pDoc->LoadFont(pFontDict); |
| 309 if (!pDefFont) { | 309 if (!pDefFont) { |
| 310 return FALSE; | 310 return FALSE; |
| 311 } | 311 } |
| 312 CPDF_Rect rcAnnot = pAnnotDict->GetRect("Rect"); | 312 CPDF_Rect rcAnnot = pAnnotDict->GetRect("Rect"); |
| 313 FX_INT32 nRotate = 0; | 313 int32_t nRotate = 0; |
| 314 if (CPDF_Dictionary * pMKDict = pAnnotDict->GetDict("MK")) { | 314 if (CPDF_Dictionary * pMKDict = pAnnotDict->GetDict("MK")) { |
| 315 nRotate = pMKDict->GetInteger("R"); | 315 nRotate = pMKDict->GetInteger("R"); |
| 316 } | 316 } |
| 317 CPDF_Rect rcBBox; | 317 CPDF_Rect rcBBox; |
| 318 CPDF_Matrix matrix; | 318 CPDF_Matrix matrix; |
| 319 switch (nRotate % 360) { | 319 switch (nRotate % 360) { |
| 320 case 0: | 320 case 0: |
| 321 rcBBox = CPDF_Rect(0, 0, rcAnnot.right - rcAnnot.left, rcAnnot.top -
rcAnnot.bottom); | 321 rcBBox = CPDF_Rect(0, 0, rcAnnot.right - rcAnnot.left, rcAnnot.top -
rcAnnot.bottom); |
| 322 break; | 322 break; |
| 323 case 90: | 323 case 90: |
| 324 matrix = CPDF_Matrix(0, 1, -1, 0, rcAnnot.right - rcAnnot.left, 0); | 324 matrix = CPDF_Matrix(0, 1, -1, 0, rcAnnot.right - rcAnnot.left, 0); |
| 325 rcBBox = CPDF_Rect(0, 0, rcAnnot.top - rcAnnot.bottom, rcAnnot.right
- rcAnnot.left); | 325 rcBBox = CPDF_Rect(0, 0, rcAnnot.top - rcAnnot.bottom, rcAnnot.right
- rcAnnot.left); |
| 326 break; | 326 break; |
| 327 case 180: | 327 case 180: |
| 328 matrix = CPDF_Matrix(-1, 0, 0, -1, rcAnnot.right - rcAnnot.left, rcA
nnot.top - rcAnnot.bottom); | 328 matrix = CPDF_Matrix(-1, 0, 0, -1, rcAnnot.right - rcAnnot.left, rcA
nnot.top - rcAnnot.bottom); |
| 329 rcBBox = CPDF_Rect(0, 0, rcAnnot.right - rcAnnot.left, rcAnnot.top -
rcAnnot.bottom); | 329 rcBBox = CPDF_Rect(0, 0, rcAnnot.right - rcAnnot.left, rcAnnot.top -
rcAnnot.bottom); |
| 330 break; | 330 break; |
| 331 case 270: | 331 case 270: |
| 332 matrix = CPDF_Matrix(0, -1, 1, 0, 0, rcAnnot.top - rcAnnot.bottom); | 332 matrix = CPDF_Matrix(0, -1, 1, 0, 0, rcAnnot.top - rcAnnot.bottom); |
| 333 rcBBox = CPDF_Rect(0, 0, rcAnnot.top - rcAnnot.bottom, rcAnnot.right
- rcAnnot.left); | 333 rcBBox = CPDF_Rect(0, 0, rcAnnot.top - rcAnnot.bottom, rcAnnot.right
- rcAnnot.left); |
| 334 break; | 334 break; |
| 335 } | 335 } |
| 336 FX_INT32 nBorderStyle = PBS_SOLID; | 336 int32_t nBorderStyle = PBS_SOLID; |
| 337 FX_FLOAT fBorderWidth = 1; | 337 FX_FLOAT fBorderWidth = 1; |
| 338 CPVT_Dash dsBorder(3, 0, 0); | 338 CPVT_Dash dsBorder(3, 0, 0); |
| 339 CPVT_Color crLeftTop, crRightBottom; | 339 CPVT_Color crLeftTop, crRightBottom; |
| 340 if (CPDF_Dictionary * pBSDict = pAnnotDict->GetDict("BS")) { | 340 if (CPDF_Dictionary * pBSDict = pAnnotDict->GetDict("BS")) { |
| 341 if (pBSDict->KeyExist("W")) { | 341 if (pBSDict->KeyExist("W")) { |
| 342 fBorderWidth = pBSDict->GetNumber("W"); | 342 fBorderWidth = pBSDict->GetNumber("W"); |
| 343 } | 343 } |
| 344 if (CPDF_Array * pArray = pBSDict->GetArray("D")) { | 344 if (CPDF_Array * pArray = pBSDict->GetArray("D")) { |
| 345 dsBorder = CPVT_Dash(pArray->GetInteger(0), pArray->GetInteger(1), p
Array->GetInteger(2)); | 345 dsBorder = CPVT_Dash(pArray->GetInteger(0), pArray->GetInteger(1), p
Array->GetInteger(2)); |
| 346 } | 346 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 return FALSE; | 398 return FALSE; |
| 399 } | 399 } |
| 400 pAnnotDict->SetAt("AP", pAPDict); | 400 pAnnotDict->SetAt("AP", pAPDict); |
| 401 } | 401 } |
| 402 CPDF_Stream* pNormalStream = pAPDict->GetStream("N"); | 402 CPDF_Stream* pNormalStream = pAPDict->GetStream("N"); |
| 403 if (pNormalStream == NULL) { | 403 if (pNormalStream == NULL) { |
| 404 pNormalStream = CPDF_Stream::Create(NULL, 0, NULL); | 404 pNormalStream = CPDF_Stream::Create(NULL, 0, NULL); |
| 405 if (pNormalStream == NULL) { | 405 if (pNormalStream == NULL) { |
| 406 return FALSE; | 406 return FALSE; |
| 407 } | 407 } |
| 408 FX_INT32 objnum = pDoc->AddIndirectObject(pNormalStream); | 408 int32_t objnum = pDoc->AddIndirectObject(pNormalStream); |
| 409 pAnnotDict->GetDict("AP")->SetAtReference("N", pDoc, objnum); | 409 pAnnotDict->GetDict("AP")->SetAtReference("N", pDoc, objnum); |
| 410 } | 410 } |
| 411 CPDF_Dictionary * pStreamDict = pNormalStream->GetDict(); | 411 CPDF_Dictionary * pStreamDict = pNormalStream->GetDict(); |
| 412 if (pStreamDict) { | 412 if (pStreamDict) { |
| 413 pStreamDict->SetAtMatrix("Matrix", matrix); | 413 pStreamDict->SetAtMatrix("Matrix", matrix); |
| 414 pStreamDict->SetAtRect("BBox", rcBBox); | 414 pStreamDict->SetAtRect("BBox", rcBBox); |
| 415 CPDF_Dictionary* pStreamResList = pStreamDict->GetDict("Resources"); | 415 CPDF_Dictionary* pStreamResList = pStreamDict->GetDict("Resources"); |
| 416 if (pStreamResList) { | 416 if (pStreamResList) { |
| 417 CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDict("Font"
); | 417 CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDict("Font"
); |
| 418 if (!pStreamResFontList) { | 418 if (!pStreamResFontList) { |
| 419 pStreamResFontList = CPDF_Dictionary::Create(); | 419 pStreamResFontList = CPDF_Dictionary::Create(); |
| 420 if (pStreamResFontList == NULL) { | 420 if (pStreamResFontList == NULL) { |
| 421 return FALSE; | 421 return FALSE; |
| 422 } | 422 } |
| 423 pStreamResList->SetAt("Font", pStreamResFontList); | 423 pStreamResList->SetAt("Font", pStreamResFontList); |
| 424 } | 424 } |
| 425 if (!pStreamResFontList->KeyExist(sFontName)) { | 425 if (!pStreamResFontList->KeyExist(sFontName)) { |
| 426 pStreamResFontList->SetAtReference(sFontName, pDoc, pFontDict); | 426 pStreamResFontList->SetAtReference(sFontName, pDoc, pFontDict); |
| 427 } | 427 } |
| 428 } else { | 428 } else { |
| 429 pStreamDict->SetAt("Resources", pFormDict->GetDict("DR")->Clone()); | 429 pStreamDict->SetAt("Resources", pFormDict->GetDict("DR")->Clone()); |
| 430 pStreamResList = pStreamDict->GetDict("Resources"); | 430 pStreamResList = pStreamDict->GetDict("Resources"); |
| 431 } | 431 } |
| 432 } | 432 } |
| 433 switch (nWidgetType) { | 433 switch (nWidgetType) { |
| 434 case 0: { | 434 case 0: { |
| 435 CFX_WideString swValue = FPDF_GetFieldAttr(pAnnotDict, "V")? FPD
F_GetFieldAttr(pAnnotDict, "V")->GetUnicodeText() : CFX_WideString(); | 435 CFX_WideString swValue = FPDF_GetFieldAttr(pAnnotDict, "V")? FPD
F_GetFieldAttr(pAnnotDict, "V")->GetUnicodeText() : CFX_WideString(); |
| 436 FX_INT32 nAlign = FPDF_GetFieldAttr(pAnnotDict, "Q")? FPDF_GetFi
eldAttr(pAnnotDict, "Q")->GetInteger() : 0; | 436 int32_t nAlign = FPDF_GetFieldAttr(pAnnotDict, "Q")? FPDF_GetFie
ldAttr(pAnnotDict, "Q")->GetInteger() : 0; |
| 437 FX_DWORD dwFlags = FPDF_GetFieldAttr(pAnnotDict, "Ff")? FPDF_Get
FieldAttr(pAnnotDict, "Ff")->GetInteger() : 0; | 437 FX_DWORD dwFlags = FPDF_GetFieldAttr(pAnnotDict, "Ff")? FPDF_Get
FieldAttr(pAnnotDict, "Ff")->GetInteger() : 0; |
| 438 FX_DWORD dwMaxLen = FPDF_GetFieldAttr(pAnnotDict, "MaxLen") ? FP
DF_GetFieldAttr(pAnnotDict, "MaxLen")->GetInteger() : 0; | 438 FX_DWORD dwMaxLen = FPDF_GetFieldAttr(pAnnotDict, "MaxLen") ? FP
DF_GetFieldAttr(pAnnotDict, "MaxLen")->GetInteger() : 0; |
| 439 CPVT_FontMap map(pDoc, pStreamDict ? pStreamDict->GetDict("Resou
rces") : NULL , pDefFont, sFontName.Right(sFontName.GetLength() - 1)); | 439 CPVT_FontMap map(pDoc, pStreamDict ? pStreamDict->GetDict("Resou
rces") : NULL , pDefFont, sFontName.Right(sFontName.GetLength() - 1)); |
| 440 CPVT_Provider prd(&map); | 440 CPVT_Provider prd(&map); |
| 441 CPDF_VariableText vt; | 441 CPDF_VariableText vt; |
| 442 vt.SetProvider(&prd); | 442 vt.SetProvider(&prd); |
| 443 vt.SetPlateRect(rcBody); | 443 vt.SetPlateRect(rcBody); |
| 444 vt.SetAlignment(nAlign); | 444 vt.SetAlignment(nAlign); |
| 445 if (IsFloatZero(fFontSize)) { | 445 if (IsFloatZero(fFontSize)) { |
| 446 vt.SetAutoFontSize(TRUE); | 446 vt.SetAutoFontSize(TRUE); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 sAppStream << sButton << "Q\n"; | 533 sAppStream << sButton << "Q\n"; |
| 534 } | 534 } |
| 535 } | 535 } |
| 536 } | 536 } |
| 537 break; | 537 break; |
| 538 case 2: { | 538 case 2: { |
| 539 CPVT_FontMap map(pDoc, pStreamDict ? pStreamDict->GetDict("Resou
rces"):NULL, pDefFont, sFontName.Right(sFontName.GetLength() - 1)); | 539 CPVT_FontMap map(pDoc, pStreamDict ? pStreamDict->GetDict("Resou
rces"):NULL, pDefFont, sFontName.Right(sFontName.GetLength() - 1)); |
| 540 CPVT_Provider prd(&map); | 540 CPVT_Provider prd(&map); |
| 541 CPDF_Array * pOpts = FPDF_GetFieldAttr(pAnnotDict, "Opt") ? FPDF
_GetFieldAttr(pAnnotDict, "Opt")->GetArray() : NULL; | 541 CPDF_Array * pOpts = FPDF_GetFieldAttr(pAnnotDict, "Opt") ? FPDF
_GetFieldAttr(pAnnotDict, "Opt")->GetArray() : NULL; |
| 542 CPDF_Array * pSels = FPDF_GetFieldAttr(pAnnotDict, "I") ? FPDF_G
etFieldAttr(pAnnotDict, "I")->GetArray() : NULL; | 542 CPDF_Array * pSels = FPDF_GetFieldAttr(pAnnotDict, "I") ? FPDF_G
etFieldAttr(pAnnotDict, "I")->GetArray() : NULL; |
| 543 FX_INT32 nTop = FPDF_GetFieldAttr(pAnnotDict, "TI") ? FPDF_GetFi
eldAttr(pAnnotDict, "TI")->GetInteger() : 0; | 543 int32_t nTop = FPDF_GetFieldAttr(pAnnotDict, "TI") ? FPDF_GetFie
ldAttr(pAnnotDict, "TI")->GetInteger() : 0; |
| 544 CFX_ByteTextBuf sBody; | 544 CFX_ByteTextBuf sBody; |
| 545 if (pOpts) { | 545 if (pOpts) { |
| 546 FX_FLOAT fy = rcBody.top; | 546 FX_FLOAT fy = rcBody.top; |
| 547 for (FX_INT32 i = nTop, sz = pOpts->GetCount(); i < sz; i++)
{ | 547 for (int32_t i = nTop, sz = pOpts->GetCount(); i < sz; i++)
{ |
| 548 if (IsFloatSmaller(fy, rcBody.bottom)) { | 548 if (IsFloatSmaller(fy, rcBody.bottom)) { |
| 549 break; | 549 break; |
| 550 } | 550 } |
| 551 if (CPDF_Object* pOpt = pOpts->GetElementValue(i)) { | 551 if (CPDF_Object* pOpt = pOpts->GetElementValue(i)) { |
| 552 CFX_WideString swItem; | 552 CFX_WideString swItem; |
| 553 if (pOpt->GetType() == PDFOBJ_STRING) { | 553 if (pOpt->GetType() == PDFOBJ_STRING) { |
| 554 swItem = pOpt->GetUnicodeText(); | 554 swItem = pOpt->GetUnicodeText(); |
| 555 } else if (pOpt->GetType() == PDFOBJ_ARRAY) { | 555 } else if (pOpt->GetType() == PDFOBJ_ARRAY) { |
| 556 swItem = ((CPDF_Array*)pOpt)->GetElementValue(1)
->GetUnicodeText(); | 556 swItem = ((CPDF_Array*)pOpt)->GetElementValue(1)
->GetUnicodeText(); |
| 557 } | 557 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 if (sBody.GetSize() > 0) { | 591 if (sBody.GetSize() > 0) { |
| 592 sAppStream << "/Tx BMC\n" << "q\n"; | 592 sAppStream << "/Tx BMC\n" << "q\n"; |
| 593 sAppStream << rcBody.left << " " << rcBody.bottom << " " | 593 sAppStream << rcBody.left << " " << rcBody.bottom << " " |
| 594 << rcBody.Width() << " " << rcBody.Height() << "
re\nW\nn\n"; | 594 << rcBody.Width() << " " << rcBody.Height() << "
re\nW\nn\n"; |
| 595 sAppStream << sBody.GetByteString() << "Q\nEMC\n"; | 595 sAppStream << sBody.GetByteString() << "Q\nEMC\n"; |
| 596 } | 596 } |
| 597 } | 597 } |
| 598 break; | 598 break; |
| 599 } | 599 } |
| 600 if (pNormalStream) { | 600 if (pNormalStream) { |
| 601 pNormalStream->SetData((FX_BYTE*)sAppStream.GetBuffer(), sAppStream.GetS
ize(), FALSE, FALSE); | 601 pNormalStream->SetData((uint8_t*)sAppStream.GetBuffer(), sAppStream.GetS
ize(), FALSE, FALSE); |
| 602 pStreamDict = pNormalStream->GetDict(); | 602 pStreamDict = pNormalStream->GetDict(); |
| 603 if (pStreamDict) { | 603 if (pStreamDict) { |
| 604 pStreamDict->SetAtMatrix("Matrix", matrix); | 604 pStreamDict->SetAtMatrix("Matrix", matrix); |
| 605 pStreamDict->SetAtRect("BBox", rcBBox); | 605 pStreamDict->SetAtRect("BBox", rcBBox); |
| 606 CPDF_Dictionary* pStreamResList = pStreamDict->GetDict("Resources"); | 606 CPDF_Dictionary* pStreamResList = pStreamDict->GetDict("Resources"); |
| 607 if (pStreamResList) { | 607 if (pStreamResList) { |
| 608 CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDict("F
ont"); | 608 CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDict("F
ont"); |
| 609 if (!pStreamResFontList) { | 609 if (!pStreamResFontList) { |
| 610 pStreamResFontList = CPDF_Dictionary::Create(); | 610 pStreamResFontList = CPDF_Dictionary::Create(); |
| 611 if (pStreamResFontList == NULL) { | 611 if (pStreamResFontList == NULL) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 633 return GenerateWidgetAP(pDoc, pAnnotDict, 1); | 633 return GenerateWidgetAP(pDoc, pAnnotDict, 1); |
| 634 } | 634 } |
| 635 FX_BOOL CPVT_GenerateAP::GenerateListBoxAP(CPDF_Document* pDoc, CPDF_Dictionary*
pAnnotDict) | 635 FX_BOOL CPVT_GenerateAP::GenerateListBoxAP(CPDF_Document* pDoc, CPDF_Dictionary*
pAnnotDict) |
| 636 { | 636 { |
| 637 return GenerateWidgetAP(pDoc, pAnnotDict, 2); | 637 return GenerateWidgetAP(pDoc, pAnnotDict, 2); |
| 638 } | 638 } |
| 639 CFX_ByteString CPVT_GenerateAP::GenerateEditAP(IPVT_FontMap * pFontMap, IPDF_Var
iableText_Iterator* pIterator, const CPDF_Point & ptOffset, FX_BOOL bContinuous,
FX_WORD SubWord, const CPVT_WordRange * pVisible) | 639 CFX_ByteString CPVT_GenerateAP::GenerateEditAP(IPVT_FontMap * pFontMap, IPDF_Var
iableText_Iterator* pIterator, const CPDF_Point & ptOffset, FX_BOOL bContinuous,
FX_WORD SubWord, const CPVT_WordRange * pVisible) |
| 640 { | 640 { |
| 641 CFX_ByteTextBuf sEditStream, sLineStream, sWords; | 641 CFX_ByteTextBuf sEditStream, sLineStream, sWords; |
| 642 CPDF_Point ptOld(0.0f, 0.0f), ptNew(0.0f, 0.0f); | 642 CPDF_Point ptOld(0.0f, 0.0f), ptNew(0.0f, 0.0f); |
| 643 FX_INT32 nCurFontIndex = -1; | 643 int32_t nCurFontIndex = -1; |
| 644 if (pIterator) { | 644 if (pIterator) { |
| 645 if (pVisible) { | 645 if (pVisible) { |
| 646 pIterator->SetAt(pVisible->BeginPos); | 646 pIterator->SetAt(pVisible->BeginPos); |
| 647 } else { | 647 } else { |
| 648 pIterator->SetAt(0); | 648 pIterator->SetAt(0); |
| 649 } | 649 } |
| 650 CPVT_WordPlace oldplace; | 650 CPVT_WordPlace oldplace; |
| 651 while (pIterator->NextWord()) { | 651 while (pIterator->NextWord()) { |
| 652 CPVT_WordPlace place = pIterator->GetAt(); | 652 CPVT_WordPlace place = pIterator->GetAt(); |
| 653 if (pVisible && place.WordCmp(pVisible->EndPos) > 0) { | 653 if (pVisible && place.WordCmp(pVisible->EndPos) > 0) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 if (sWords.GetSize() > 0) { | 706 if (sWords.GetSize() > 0) { |
| 707 sLineStream << GetWordRenderString(sWords.GetByteString()); | 707 sLineStream << GetWordRenderString(sWords.GetByteString()); |
| 708 sEditStream << sLineStream; | 708 sEditStream << sLineStream; |
| 709 sWords.Clear(); | 709 sWords.Clear(); |
| 710 } | 710 } |
| 711 } | 711 } |
| 712 return sEditStream.GetByteString(); | 712 return sEditStream.GetByteString(); |
| 713 } | 713 } |
| 714 CFX_ByteString CPVT_GenerateAP::GenerateBorderAP(const CPDF_Rect & rect, FX_FLOA
T fWidth, | 714 CFX_ByteString CPVT_GenerateAP::GenerateBorderAP(const CPDF_Rect & rect, FX_FLOA
T fWidth, |
| 715 const CPVT_Color & color, const CPVT_Color & crLeftTop, const CPVT_Color
& crRightBottom, | 715 const CPVT_Color & color, const CPVT_Color & crLeftTop, const CPVT_Color
& crRightBottom, |
| 716 FX_INT32 nStyle, const CPVT_Dash & dash) | 716 int32_t nStyle, const CPVT_Dash & dash) |
| 717 { | 717 { |
| 718 CFX_ByteTextBuf sAppStream; | 718 CFX_ByteTextBuf sAppStream; |
| 719 CFX_ByteString sColor; | 719 CFX_ByteString sColor; |
| 720 FX_FLOAT fLeft = rect.left; | 720 FX_FLOAT fLeft = rect.left; |
| 721 FX_FLOAT fRight = rect.right; | 721 FX_FLOAT fRight = rect.right; |
| 722 FX_FLOAT fTop = rect.top; | 722 FX_FLOAT fTop = rect.top; |
| 723 FX_FLOAT fBottom = rect.bottom; | 723 FX_FLOAT fBottom = rect.bottom; |
| 724 if (fWidth > 0.0f) { | 724 if (fWidth > 0.0f) { |
| 725 FX_FLOAT fHalfWidth = fWidth / 2.0f; | 725 FX_FLOAT fHalfWidth = fWidth / 2.0f; |
| 726 switch (nStyle) { | 726 switch (nStyle) { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 case CT_GRAY: | 801 case CT_GRAY: |
| 802 sColorStream << color.fColor1 << " " << (bFillOrStroke ? "g" : "G")
<< "\n"; | 802 sColorStream << color.fColor1 << " " << (bFillOrStroke ? "g" : "G")
<< "\n"; |
| 803 break; | 803 break; |
| 804 case CT_CMYK: | 804 case CT_CMYK: |
| 805 sColorStream << color.fColor1 << " " << color.fColor2 << " " << colo
r.fColor3 << " " << color.fColor4 << " " | 805 sColorStream << color.fColor1 << " " << color.fColor2 << " " << colo
r.fColor3 << " " << color.fColor4 << " " |
| 806 << (bFillOrStroke ? "k" : "K") << "\n"; | 806 << (bFillOrStroke ? "k" : "K") << "\n"; |
| 807 break; | 807 break; |
| 808 } | 808 } |
| 809 return sColorStream.GetByteString(); | 809 return sColorStream.GetByteString(); |
| 810 } | 810 } |
| OLD | NEW |