| 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/fpdfapi/fpdf_page.h" | 7 #include "../../../include/fpdfapi/fpdf_page.h" |
| 8 #include "../../../include/fpdfapi/fpdf_module.h" | 8 #include "../../../include/fpdfapi/fpdf_module.h" |
| 9 #include "pageint.h" | 9 #include "pageint.h" |
| 10 CPDF_PageObject* CPDF_PageObject::Create(int type) | 10 CPDF_PageObject* CPDF_PageObject::Create(int type) |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 { | 106 { |
| 107 if (m_nChars > 1 && m_pCharCodes) { | 107 if (m_nChars > 1 && m_pCharCodes) { |
| 108 FX_Free(m_pCharCodes); | 108 FX_Free(m_pCharCodes); |
| 109 } | 109 } |
| 110 if (m_pCharPos) { | 110 if (m_pCharPos) { |
| 111 FX_Free(m_pCharPos); | 111 FX_Free(m_pCharPos); |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 void CPDF_TextObject::GetItemInfo(int index, CPDF_TextObjectItem* pInfo) const | 114 void CPDF_TextObject::GetItemInfo(int index, CPDF_TextObjectItem* pInfo) const |
| 115 { | 115 { |
| 116 pInfo->m_CharCode = m_nChars == 1 ? (FX_DWORD)(FX_UINTPTR)m_pCharCodes : m_p
CharCodes[index]; | 116 pInfo->m_CharCode = m_nChars == 1 ? (FX_DWORD)(uintptr_t)m_pCharCodes : m_pC
harCodes[index]; |
| 117 pInfo->m_OriginX = index ? m_pCharPos[index - 1] : 0; | 117 pInfo->m_OriginX = index ? m_pCharPos[index - 1] : 0; |
| 118 pInfo->m_OriginY = 0; | 118 pInfo->m_OriginY = 0; |
| 119 if (pInfo->m_CharCode == -1) { | 119 if (pInfo->m_CharCode == -1) { |
| 120 return; | 120 return; |
| 121 } | 121 } |
| 122 CPDF_Font* pFont = m_TextState.GetFont(); | 122 CPDF_Font* pFont = m_TextState.GetFont(); |
| 123 if (pFont->GetFontType() != PDFFONT_CIDFONT) { | 123 if (pFont->GetFontType() != PDFFONT_CIDFONT) { |
| 124 return; | 124 return; |
| 125 } | 125 } |
| 126 if (!((CPDF_CIDFont*)pFont)->IsVertWriting()) { | 126 if (!((CPDF_CIDFont*)pFont)->IsVertWriting()) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 143 int count = 0; | 143 int count = 0; |
| 144 for (int i = 0; i < m_nChars; i ++) | 144 for (int i = 0; i < m_nChars; i ++) |
| 145 if (m_pCharCodes[i] != (FX_DWORD) - 1) { | 145 if (m_pCharCodes[i] != (FX_DWORD) - 1) { |
| 146 count ++; | 146 count ++; |
| 147 } | 147 } |
| 148 return count; | 148 return count; |
| 149 } | 149 } |
| 150 void CPDF_TextObject::GetCharInfo(int index, FX_DWORD& charcode, FX_FLOAT& kerni
ng) const | 150 void CPDF_TextObject::GetCharInfo(int index, FX_DWORD& charcode, FX_FLOAT& kerni
ng) const |
| 151 { | 151 { |
| 152 if (m_nChars == 1) { | 152 if (m_nChars == 1) { |
| 153 charcode = (FX_DWORD)(FX_UINTPTR)m_pCharCodes; | 153 charcode = (FX_DWORD)(uintptr_t)m_pCharCodes; |
| 154 kerning = 0; | 154 kerning = 0; |
| 155 return; | 155 return; |
| 156 } | 156 } |
| 157 int count = 0; | 157 int count = 0; |
| 158 for (int i = 0; i < m_nChars; i ++) { | 158 for (int i = 0; i < m_nChars; i ++) { |
| 159 if (m_pCharCodes[i] != (FX_DWORD) - 1) { | 159 if (m_pCharCodes[i] != (FX_DWORD) - 1) { |
| 160 if (count == index) { | 160 if (count == index) { |
| 161 charcode = m_pCharCodes[i]; | 161 charcode = m_pCharCodes[i]; |
| 162 if (i == m_nChars - 1 || m_pCharCodes[i + 1] != (FX_DWORD) - 1)
{ | 162 if (i == m_nChars - 1 || m_pCharCodes[i + 1] != (FX_DWORD) - 1)
{ |
| 163 kerning = 0; | 163 kerning = 0; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 while (offset < len) { | 247 while (offset < len) { |
| 248 m_pCharCodes[index++] = pFont->GetNextChar(segment, len, offset)
; | 248 m_pCharCodes[index++] = pFont->GetNextChar(segment, len, offset)
; |
| 249 } | 249 } |
| 250 if (i != nsegs - 1) { | 250 if (i != nsegs - 1) { |
| 251 m_pCharPos[index - 1] = pKerning[i]; | 251 m_pCharPos[index - 1] = pKerning[i]; |
| 252 m_pCharCodes[index ++] = (FX_DWORD) - 1; | 252 m_pCharCodes[index ++] = (FX_DWORD) - 1; |
| 253 } | 253 } |
| 254 } | 254 } |
| 255 } else { | 255 } else { |
| 256 int offset = 0; | 256 int offset = 0; |
| 257 m_pCharCodes = (FX_DWORD*)(FX_UINTPTR)pFont->GetNextChar(pStrs[0], pStrs
[0].GetLength(), offset); | 257 m_pCharCodes = (FX_DWORD*)(uintptr_t)pFont->GetNextChar(pStrs[0], pStrs[
0].GetLength(), offset); |
| 258 } | 258 } |
| 259 } | 259 } |
| 260 void CPDF_TextObject::SetText(const CFX_ByteString& str) | 260 void CPDF_TextObject::SetText(const CFX_ByteString& str) |
| 261 { | 261 { |
| 262 SetSegments(&str, NULL, 1); | 262 SetSegments(&str, NULL, 1); |
| 263 RecalcPositionData(); | 263 RecalcPositionData(); |
| 264 } | 264 } |
| 265 void CPDF_TextObject::SetEmpty() | 265 void CPDF_TextObject::SetEmpty() |
| 266 { | 266 { |
| 267 if (m_nChars > 1 && m_pCharCodes) { | 267 if (m_nChars > 1 && m_pCharCodes) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 int index = 0; | 304 int index = 0; |
| 305 for (int i = 0; i < nChars; i ++) { | 305 for (int i = 0; i < nChars; i ++) { |
| 306 m_pCharCodes[index++] = pCharCodes[i]; | 306 m_pCharCodes[index++] = pCharCodes[i]; |
| 307 if (pKernings[i] != 0 && i != nChars - 1) { | 307 if (pKernings[i] != 0 && i != nChars - 1) { |
| 308 m_pCharCodes[index] = (FX_DWORD) - 1; | 308 m_pCharCodes[index] = (FX_DWORD) - 1; |
| 309 m_pCharPos[index - 1] = pKernings[i]; | 309 m_pCharPos[index - 1] = pKernings[i]; |
| 310 index ++; | 310 index ++; |
| 311 } | 311 } |
| 312 } | 312 } |
| 313 } else { | 313 } else { |
| 314 m_pCharCodes = (FX_DWORD*)(FX_UINTPTR)pCharCodes[0]; | 314 m_pCharCodes = (FX_DWORD*)(uintptr_t)pCharCodes[0]; |
| 315 } | 315 } |
| 316 RecalcPositionData(); | 316 RecalcPositionData(); |
| 317 } | 317 } |
| 318 FX_FLOAT CPDF_TextObject::GetCharWidth(FX_DWORD charcode) const | 318 FX_FLOAT CPDF_TextObject::GetCharWidth(FX_DWORD charcode) const |
| 319 { | 319 { |
| 320 FX_FLOAT fontsize = m_TextState.GetFontSize() / 1000; | 320 FX_FLOAT fontsize = m_TextState.GetFontSize() / 1000; |
| 321 CPDF_Font* pFont = m_TextState.GetFont(); | 321 CPDF_Font* pFont = m_TextState.GetFont(); |
| 322 FX_BOOL bVertWriting = FALSE; | 322 FX_BOOL bVertWriting = FALSE; |
| 323 CPDF_CIDFont* pCIDFont = pFont->GetCIDFont(); | 323 CPDF_CIDFont* pCIDFont = pFont->GetCIDFont(); |
| 324 if (pCIDFont) { | 324 if (pCIDFont) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 353 { | 353 { |
| 354 CPDF_Font* pFont = m_TextState.GetFont(); | 354 CPDF_Font* pFont = m_TextState.GetFont(); |
| 355 FX_BOOL bVertWriting = FALSE; | 355 FX_BOOL bVertWriting = FALSE; |
| 356 CPDF_CIDFont* pCIDFont = pFont->GetCIDFont(); | 356 CPDF_CIDFont* pCIDFont = pFont->GetCIDFont(); |
| 357 if (pCIDFont) { | 357 if (pCIDFont) { |
| 358 bVertWriting = pCIDFont->IsVertWriting(); | 358 bVertWriting = pCIDFont->IsVertWriting(); |
| 359 } | 359 } |
| 360 FX_FLOAT fontsize = m_TextState.GetFontSize() / 1000; | 360 FX_FLOAT fontsize = m_TextState.GetFontSize() / 1000; |
| 361 int count = 0; | 361 int count = 0; |
| 362 for (int i = 0; i < m_nChars; i ++) { | 362 for (int i = 0; i < m_nChars; i ++) { |
| 363 FX_DWORD charcode = m_nChars == 1 ? (FX_DWORD)(FX_UINTPTR)m_pCharCodes :
m_pCharCodes[i]; | 363 FX_DWORD charcode = m_nChars == 1 ? (FX_DWORD)(uintptr_t)m_pCharCodes :
m_pCharCodes[i]; |
| 364 if (charcode == (FX_DWORD) - 1) { | 364 if (charcode == (FX_DWORD) - 1) { |
| 365 continue; | 365 continue; |
| 366 } | 366 } |
| 367 if( count != index) { | 367 if( count != index) { |
| 368 count++; | 368 count++; |
| 369 continue; | 369 continue; |
| 370 } | 370 } |
| 371 FX_FLOAT curpos = i > 0 ? m_pCharPos[i - 1] : 0; | 371 FX_FLOAT curpos = i > 0 ? m_pCharPos[i - 1] : 0; |
| 372 FX_RECT char_rect; | 372 FX_RECT char_rect; |
| 373 pFont->GetCharBBox(charcode, char_rect, 0); | 373 pFont->GetCharBBox(charcode, char_rect, 0); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 397 FX_FLOAT curpos = 0; | 397 FX_FLOAT curpos = 0; |
| 398 FX_FLOAT min_x = 10000 * 1.0f, max_x = -10000 * 1.0f, min_y = 10000 * 1.0f,
max_y = -10000 * 1.0f; | 398 FX_FLOAT min_x = 10000 * 1.0f, max_x = -10000 * 1.0f, min_y = 10000 * 1.0f,
max_y = -10000 * 1.0f; |
| 399 CPDF_Font* pFont = m_TextState.GetFont(); | 399 CPDF_Font* pFont = m_TextState.GetFont(); |
| 400 FX_BOOL bVertWriting = FALSE; | 400 FX_BOOL bVertWriting = FALSE; |
| 401 CPDF_CIDFont* pCIDFont = pFont->GetCIDFont(); | 401 CPDF_CIDFont* pCIDFont = pFont->GetCIDFont(); |
| 402 if (pCIDFont) { | 402 if (pCIDFont) { |
| 403 bVertWriting = pCIDFont->IsVertWriting(); | 403 bVertWriting = pCIDFont->IsVertWriting(); |
| 404 } | 404 } |
| 405 FX_FLOAT fontsize = m_TextState.GetFontSize(); | 405 FX_FLOAT fontsize = m_TextState.GetFontSize(); |
| 406 for (int i = 0; i < m_nChars; i ++) { | 406 for (int i = 0; i < m_nChars; i ++) { |
| 407 FX_DWORD charcode = m_nChars == 1 ? (FX_DWORD)(FX_UINTPTR)m_pCharCodes :
m_pCharCodes[i]; | 407 FX_DWORD charcode = m_nChars == 1 ? (FX_DWORD)(uintptr_t)m_pCharCodes :
m_pCharCodes[i]; |
| 408 if (charcode == (FX_DWORD) - 1) { | 408 if (charcode == (FX_DWORD) - 1) { |
| 409 curpos -= FXSYS_Mul(m_pCharPos[i - 1], fontsize) / 1000; | 409 curpos -= FXSYS_Mul(m_pCharPos[i - 1], fontsize) / 1000; |
| 410 continue; | 410 continue; |
| 411 } | 411 } |
| 412 if (i) { | 412 if (i) { |
| 413 m_pCharPos[i - 1] = curpos; | 413 m_pCharPos[i - 1] = curpos; |
| 414 } | 414 } |
| 415 FX_RECT char_rect; | 415 FX_RECT char_rect; |
| 416 pFont->GetCharBBox(charcode, char_rect, level); | 416 pFont->GetCharBBox(charcode, char_rect, level); |
| 417 FX_FLOAT charwidth; | 417 FX_FLOAT charwidth; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 { | 524 { |
| 525 CPDF_Font* pFont = m_TextState.GetFont(); | 525 CPDF_Font* pFont = m_TextState.GetFont(); |
| 526 FX_BOOL bVertWriting = FALSE; | 526 FX_BOOL bVertWriting = FALSE; |
| 527 CPDF_CIDFont* pCIDFont = pFont->GetCIDFont(); | 527 CPDF_CIDFont* pCIDFont = pFont->GetCIDFont(); |
| 528 if (pCIDFont) { | 528 if (pCIDFont) { |
| 529 bVertWriting = pCIDFont->IsVertWriting(); | 529 bVertWriting = pCIDFont->IsVertWriting(); |
| 530 } | 530 } |
| 531 FX_FLOAT fontsize = m_TextState.GetFontSize(); | 531 FX_FLOAT fontsize = m_TextState.GetFontSize(); |
| 532 int index = 0; | 532 int index = 0; |
| 533 for (int i = 0; i < m_nChars; i ++) { | 533 for (int i = 0; i < m_nChars; i ++) { |
| 534 FX_DWORD charcode = m_nChars == 1 ? (FX_DWORD)(FX_UINTPTR)m_pCharCodes :
m_pCharCodes[i]; | 534 FX_DWORD charcode = m_nChars == 1 ? (FX_DWORD)(uintptr_t)m_pCharCodes :
m_pCharCodes[i]; |
| 535 if (charcode == (FX_DWORD) - 1) { | 535 if (charcode == (FX_DWORD) - 1) { |
| 536 continue; | 536 continue; |
| 537 } | 537 } |
| 538 pPosArray[index++] = i ? m_pCharPos[i - 1] : 0; | 538 pPosArray[index++] = i ? m_pCharPos[i - 1] : 0; |
| 539 FX_FLOAT charwidth; | 539 FX_FLOAT charwidth; |
| 540 if (bVertWriting) { | 540 if (bVertWriting) { |
| 541 FX_WORD CID = pCIDFont->CIDFromCharCode(charcode); | 541 FX_WORD CID = pCIDFont->CIDFromCharCode(charcode); |
| 542 charwidth = pCIDFont->GetVertWidth(CID) * fontsize / 1000; | 542 charwidth = pCIDFont->GetVertWidth(CID) * fontsize / 1000; |
| 543 } else { | 543 } else { |
| 544 charwidth = pFont->GetCharWidthF(charcode) * fontsize / 1000; | 544 charwidth = pFont->GetCharWidthF(charcode) * fontsize / 1000; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 void CPDF_TextObject::SetData(int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pCharP
os, FX_FLOAT x, FX_FLOAT y) | 576 void CPDF_TextObject::SetData(int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pCharP
os, FX_FLOAT x, FX_FLOAT y) |
| 577 { | 577 { |
| 578 ASSERT(m_nChars == 0); | 578 ASSERT(m_nChars == 0); |
| 579 m_nChars = nChars; | 579 m_nChars = nChars; |
| 580 m_PosX = x; | 580 m_PosX = x; |
| 581 m_PosY = y; | 581 m_PosY = y; |
| 582 if (nChars == 0) { | 582 if (nChars == 0) { |
| 583 return; | 583 return; |
| 584 } | 584 } |
| 585 if (nChars == 1) { | 585 if (nChars == 1) { |
| 586 m_pCharCodes = (FX_DWORD*)(FX_UINTPTR) * pCharCodes; | 586 m_pCharCodes = (FX_DWORD*)(uintptr_t) * pCharCodes; |
| 587 } else { | 587 } else { |
| 588 m_pCharCodes = FX_Alloc(FX_DWORD, nChars); | 588 m_pCharCodes = FX_Alloc(FX_DWORD, nChars); |
| 589 FXSYS_memcpy32(m_pCharCodes, pCharCodes, sizeof(FX_DWORD)*nChars); | 589 FXSYS_memcpy32(m_pCharCodes, pCharCodes, sizeof(FX_DWORD)*nChars); |
| 590 m_pCharPos = FX_Alloc(FX_FLOAT, nChars - 1); | 590 m_pCharPos = FX_Alloc(FX_FLOAT, nChars - 1); |
| 591 FXSYS_memcpy32(m_pCharPos, pCharPos, sizeof(FX_FLOAT) * (nChars - 1)); | 591 FXSYS_memcpy32(m_pCharPos, pCharPos, sizeof(FX_FLOAT) * (nChars - 1)); |
| 592 } | 592 } |
| 593 RecalcPositionData(); | 593 RecalcPositionData(); |
| 594 } | 594 } |
| 595 void CPDF_TextObject::SetTextState(CPDF_TextState TextState) | 595 void CPDF_TextObject::SetTextState(CPDF_TextState TextState) |
| 596 { | 596 { |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 matrix = m_PageMatrix; | 1021 matrix = m_PageMatrix; |
| 1022 matrix.Concat(display_matrix); | 1022 matrix.Concat(display_matrix); |
| 1023 } | 1023 } |
| 1024 CPDF_ParseOptions::CPDF_ParseOptions() | 1024 CPDF_ParseOptions::CPDF_ParseOptions() |
| 1025 { | 1025 { |
| 1026 m_bTextOnly = FALSE; | 1026 m_bTextOnly = FALSE; |
| 1027 m_bMarkedContent = TRUE; | 1027 m_bMarkedContent = TRUE; |
| 1028 m_bSeparateForm = TRUE; | 1028 m_bSeparateForm = TRUE; |
| 1029 m_bDecodeInlineImage = FALSE; | 1029 m_bDecodeInlineImage = FALSE; |
| 1030 } | 1030 } |
| OLD | NEW |