| 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/fpdfapi/fpdf_parser/include/cpdf_array.h" | 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
| 8 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 8 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
| 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_simple_parser.h" | 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_simple_parser.h" |
| 10 #include "core/fpdfdoc/doc_utils.h" | 10 #include "core/fpdfdoc/doc_utils.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 } | 129 } |
| 130 return m_sSysFontAlias; | 130 return m_sSysFontAlias; |
| 131 } | 131 } |
| 132 return ""; | 132 return ""; |
| 133 } | 133 } |
| 134 CPVT_Provider::CPVT_Provider(IPVT_FontMap* pFontMap) : m_pFontMap(pFontMap) { | 134 CPVT_Provider::CPVT_Provider(IPVT_FontMap* pFontMap) : m_pFontMap(pFontMap) { |
| 135 ASSERT(m_pFontMap); | 135 ASSERT(m_pFontMap); |
| 136 } | 136 } |
| 137 CPVT_Provider::~CPVT_Provider() {} | 137 CPVT_Provider::~CPVT_Provider() {} |
| 138 int32_t CPVT_Provider::GetCharWidth(int32_t nFontIndex, | 138 int32_t CPVT_Provider::GetCharWidth(int32_t nFontIndex, |
| 139 FX_WORD word, | 139 uint16_t word, |
| 140 int32_t nWordStyle) { | 140 int32_t nWordStyle) { |
| 141 if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex)) { | 141 if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex)) { |
| 142 FX_DWORD charcode = pPDFFont->CharCodeFromUnicode(word); | 142 FX_DWORD charcode = pPDFFont->CharCodeFromUnicode(word); |
| 143 if (charcode != CPDF_Font::kInvalidCharCode) { | 143 if (charcode != CPDF_Font::kInvalidCharCode) { |
| 144 return pPDFFont->GetCharWidthF(charcode); | 144 return pPDFFont->GetCharWidthF(charcode); |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 return 0; | 147 return 0; |
| 148 } | 148 } |
| 149 int32_t CPVT_Provider::GetTypeAscent(int32_t nFontIndex) { | 149 int32_t CPVT_Provider::GetTypeAscent(int32_t nFontIndex) { |
| 150 if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex)) { | 150 if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex)) { |
| 151 return pPDFFont->GetTypeAscent(); | 151 return pPDFFont->GetTypeAscent(); |
| 152 } | 152 } |
| 153 return 0; | 153 return 0; |
| 154 } | 154 } |
| 155 int32_t CPVT_Provider::GetTypeDescent(int32_t nFontIndex) { | 155 int32_t CPVT_Provider::GetTypeDescent(int32_t nFontIndex) { |
| 156 if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex)) { | 156 if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex)) { |
| 157 return pPDFFont->GetTypeDescent(); | 157 return pPDFFont->GetTypeDescent(); |
| 158 } | 158 } |
| 159 return 0; | 159 return 0; |
| 160 } | 160 } |
| 161 int32_t CPVT_Provider::GetWordFontIndex(FX_WORD word, | 161 int32_t CPVT_Provider::GetWordFontIndex(uint16_t word, |
| 162 int32_t charset, | 162 int32_t charset, |
| 163 int32_t nFontIndex) { | 163 int32_t nFontIndex) { |
| 164 if (CPDF_Font* pDefFont = m_pFontMap->GetPDFFont(0)) { | 164 if (CPDF_Font* pDefFont = m_pFontMap->GetPDFFont(0)) { |
| 165 if (pDefFont->CharCodeFromUnicode(word) != CPDF_Font::kInvalidCharCode) { | 165 if (pDefFont->CharCodeFromUnicode(word) != CPDF_Font::kInvalidCharCode) { |
| 166 return 0; | 166 return 0; |
| 167 } | 167 } |
| 168 } | 168 } |
| 169 if (CPDF_Font* pSysFont = m_pFontMap->GetPDFFont(1)) { | 169 if (CPDF_Font* pSysFont = m_pFontMap->GetPDFFont(1)) { |
| 170 if (pSysFont->CharCodeFromUnicode(word) != CPDF_Font::kInvalidCharCode) { | 170 if (pSysFont->CharCodeFromUnicode(word) != CPDF_Font::kInvalidCharCode) { |
| 171 return 1; | 171 return 1; |
| 172 } | 172 } |
| 173 } | 173 } |
| 174 return -1; | 174 return -1; |
| 175 } | 175 } |
| 176 FX_BOOL CPVT_Provider::IsLatinWord(FX_WORD word) { | 176 FX_BOOL CPVT_Provider::IsLatinWord(uint16_t word) { |
| 177 if ((word >= 0x61 && word <= 0x7A) || (word >= 0x41 && word <= 0x5A) || | 177 if ((word >= 0x61 && word <= 0x7A) || (word >= 0x41 && word <= 0x5A) || |
| 178 word == 0x2D || word == 0x27) { | 178 word == 0x2D || word == 0x27) { |
| 179 return TRUE; | 179 return TRUE; |
| 180 } | 180 } |
| 181 return FALSE; | 181 return FALSE; |
| 182 } | 182 } |
| 183 int32_t CPVT_Provider::GetDefaultFontIndex() { | 183 int32_t CPVT_Provider::GetDefaultFontIndex() { |
| 184 return 0; | 184 return 0; |
| 185 } | 185 } |
| 186 | 186 |
| 187 static CFX_ByteString GetPDFWordString(IPVT_FontMap* pFontMap, | 187 static CFX_ByteString GetPDFWordString(IPVT_FontMap* pFontMap, |
| 188 int32_t nFontIndex, | 188 int32_t nFontIndex, |
| 189 FX_WORD Word, | 189 uint16_t Word, |
| 190 FX_WORD SubWord) { | 190 uint16_t SubWord) { |
| 191 CFX_ByteString sWord; | 191 CFX_ByteString sWord; |
| 192 if (SubWord > 0) { | 192 if (SubWord > 0) { |
| 193 sWord.Format("%c", SubWord); | 193 sWord.Format("%c", SubWord); |
| 194 return sWord; | 194 return sWord; |
| 195 } | 195 } |
| 196 | 196 |
| 197 if (!pFontMap) | 197 if (!pFontMap) |
| 198 return sWord; | 198 return sWord; |
| 199 | 199 |
| 200 if (CPDF_Font* pPDFFont = pFontMap->GetPDFFont(nFontIndex)) { | 200 if (CPDF_Font* pPDFFont = pFontMap->GetPDFFont(nFontIndex)) { |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 if (IsFloatZero(fFontSize)) { | 478 if (IsFloatZero(fFontSize)) { |
| 479 vt.SetAutoFontSize(TRUE); | 479 vt.SetAutoFontSize(TRUE); |
| 480 } else { | 480 } else { |
| 481 vt.SetFontSize(fFontSize); | 481 vt.SetFontSize(fFontSize); |
| 482 } | 482 } |
| 483 FX_BOOL bMultiLine = (dwFlags >> 12) & 1; | 483 FX_BOOL bMultiLine = (dwFlags >> 12) & 1; |
| 484 if (bMultiLine) { | 484 if (bMultiLine) { |
| 485 vt.SetMultiLine(TRUE); | 485 vt.SetMultiLine(TRUE); |
| 486 vt.SetAutoReturn(TRUE); | 486 vt.SetAutoReturn(TRUE); |
| 487 } | 487 } |
| 488 FX_WORD subWord = 0; | 488 uint16_t subWord = 0; |
| 489 if ((dwFlags >> 13) & 1) { | 489 if ((dwFlags >> 13) & 1) { |
| 490 subWord = '*'; | 490 subWord = '*'; |
| 491 vt.SetPasswordChar(subWord); | 491 vt.SetPasswordChar(subWord); |
| 492 } | 492 } |
| 493 FX_BOOL bCharArray = (dwFlags >> 24) & 1; | 493 FX_BOOL bCharArray = (dwFlags >> 24) & 1; |
| 494 if (bCharArray) { | 494 if (bCharArray) { |
| 495 vt.SetCharArray(dwMaxLen); | 495 vt.SetCharArray(dwMaxLen); |
| 496 } else { | 496 } else { |
| 497 vt.SetLimitChar(dwMaxLen); | 497 vt.SetLimitChar(dwMaxLen); |
| 498 } | 498 } |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 } | 714 } |
| 715 FX_BOOL CPVT_GenerateAP::GenerateListBoxAP(CPDF_Document* pDoc, | 715 FX_BOOL CPVT_GenerateAP::GenerateListBoxAP(CPDF_Document* pDoc, |
| 716 CPDF_Dictionary* pAnnotDict) { | 716 CPDF_Dictionary* pAnnotDict) { |
| 717 return GenerateWidgetAP(pDoc, pAnnotDict, 2); | 717 return GenerateWidgetAP(pDoc, pAnnotDict, 2); |
| 718 } | 718 } |
| 719 CFX_ByteString CPVT_GenerateAP::GenerateEditAP( | 719 CFX_ByteString CPVT_GenerateAP::GenerateEditAP( |
| 720 IPVT_FontMap* pFontMap, | 720 IPVT_FontMap* pFontMap, |
| 721 IPDF_VariableText_Iterator* pIterator, | 721 IPDF_VariableText_Iterator* pIterator, |
| 722 const CFX_FloatPoint& ptOffset, | 722 const CFX_FloatPoint& ptOffset, |
| 723 FX_BOOL bContinuous, | 723 FX_BOOL bContinuous, |
| 724 FX_WORD SubWord, | 724 uint16_t SubWord, |
| 725 const CPVT_WordRange* pVisible) { | 725 const CPVT_WordRange* pVisible) { |
| 726 CFX_ByteTextBuf sEditStream, sLineStream, sWords; | 726 CFX_ByteTextBuf sEditStream, sLineStream, sWords; |
| 727 CFX_FloatPoint ptOld(0.0f, 0.0f), ptNew(0.0f, 0.0f); | 727 CFX_FloatPoint ptOld(0.0f, 0.0f), ptNew(0.0f, 0.0f); |
| 728 int32_t nCurFontIndex = -1; | 728 int32_t nCurFontIndex = -1; |
| 729 if (pIterator) { | 729 if (pIterator) { |
| 730 if (pVisible) { | 730 if (pVisible) { |
| 731 pIterator->SetAt(pVisible->BeginPos); | 731 pIterator->SetAt(pVisible->BeginPos); |
| 732 } else { | 732 } else { |
| 733 pIterator->SetAt(0); | 733 pIterator->SetAt(0); |
| 734 } | 734 } |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 case CPVT_Color::kCMYK: | 927 case CPVT_Color::kCMYK: |
| 928 sColorStream << color.fColor1 << " " << color.fColor2 << " " | 928 sColorStream << color.fColor1 << " " << color.fColor2 << " " |
| 929 << color.fColor3 << " " << color.fColor4 << " " | 929 << color.fColor3 << " " << color.fColor4 << " " |
| 930 << (bFillOrStroke ? "k" : "K") << "\n"; | 930 << (bFillOrStroke ? "k" : "K") << "\n"; |
| 931 break; | 931 break; |
| 932 case CPVT_Color::kTransparent: | 932 case CPVT_Color::kTransparent: |
| 933 break; | 933 break; |
| 934 } | 934 } |
| 935 return sColorStream.GetByteString(); | 935 return sColorStream.GetByteString(); |
| 936 } | 936 } |
| OLD | NEW |