| 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_pageobj.h" | 8 #include "../../include/fpdfapi/fpdf_pageobj.h" |
| 9 #include "../../include/fpdftext/fpdf_text.h" | 9 #include "../../include/fpdftext/fpdf_text.h" |
| 10 #include "txtproc.h" | 10 #include "txtproc.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 spacew = fontsize_h * pFont->GetCharWidthF(space_charcode) / 1000; | 68 spacew = fontsize_h * pFont->GetCharWidthF(space_charcode) / 1000; |
| 69 } | 69 } |
| 70 if (spacew == 0) { | 70 if (spacew == 0) { |
| 71 spacew = fontsize_h / 4; | 71 spacew = fontsize_h / 4; |
| 72 } | 72 } |
| 73 if (pText->m_TextState.GetBaselineAngle() != 0) { | 73 if (pText->m_TextState.GetBaselineAngle() != 0) { |
| 74 int cc = 0; | 74 int cc = 0; |
| 75 CFX_AffineMatrix matrix; | 75 CFX_AffineMatrix matrix; |
| 76 pText->GetTextMatrix(&matrix); | 76 pText->GetTextMatrix(&matrix); |
| 77 for (int i = 0; i < pText->m_nChars; i ++) { | 77 for (int i = 0; i < pText->m_nChars; i ++) { |
| 78 FX_DWORD charcode = pText->m_nChars == 1 ? (FX_DWORD)(FX_UINTPTR)pTe
xt->m_pCharCodes : pText->m_pCharCodes[i]; | 78 FX_DWORD charcode = pText->m_nChars == 1 ? (FX_DWORD)(uintptr_t)pTex
t->m_pCharCodes : pText->m_pCharCodes[i]; |
| 79 if (charcode == (FX_DWORD) - 1) { | 79 if (charcode == (FX_DWORD) - 1) { |
| 80 continue; | 80 continue; |
| 81 } | 81 } |
| 82 FX_RECT char_box; | 82 FX_RECT char_box; |
| 83 pFont->GetCharBBox(charcode, char_box); | 83 pFont->GetCharBBox(charcode, char_box); |
| 84 FX_FLOAT char_left = pPosArray ? pPosArray[cc * 2] : char_box.left *
pText->m_TextState.GetFontSize() / 1000; | 84 FX_FLOAT char_left = pPosArray ? pPosArray[cc * 2] : char_box.left *
pText->m_TextState.GetFontSize() / 1000; |
| 85 FX_FLOAT char_right = pPosArray ? pPosArray[cc * 2 + 1] : char_box.r
ight * pText->m_TextState.GetFontSize() / 1000; | 85 FX_FLOAT char_right = pPosArray ? pPosArray[cc * 2 + 1] : char_box.r
ight * pText->m_TextState.GetFontSize() / 1000; |
| 86 FX_FLOAT char_top = char_box.top * pText->m_TextState.GetFontSize()
/ 1000; | 86 FX_FLOAT char_top = char_box.top * pText->m_TextState.GetFontSize()
/ 1000; |
| 87 FX_FLOAT char_bottom = char_box.bottom * pText->m_TextState.GetFontS
ize() / 1000; | 87 FX_FLOAT char_bottom = char_box.bottom * pText->m_TextState.GetFontS
ize() / 1000; |
| 88 cc ++; | 88 cc ++; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 106 FX_FLOAT baseline = pText->m_PosY; | 106 FX_FLOAT baseline = pText->m_PosY; |
| 107 CTextBaseLine* pBaseLine = NULL; | 107 CTextBaseLine* pBaseLine = NULL; |
| 108 FX_FLOAT topy = pText->m_Top; | 108 FX_FLOAT topy = pText->m_Top; |
| 109 FX_FLOAT bottomy = pText->m_Bottom; | 109 FX_FLOAT bottomy = pText->m_Bottom; |
| 110 FX_FLOAT leftx = pText->m_Left; | 110 FX_FLOAT leftx = pText->m_Left; |
| 111 int cc = 0; | 111 int cc = 0; |
| 112 CFX_ByteString segment; | 112 CFX_ByteString segment; |
| 113 int space_count = 0; | 113 int space_count = 0; |
| 114 FX_FLOAT last_left = 0, last_right = 0, segment_left = 0, segment_right = 0; | 114 FX_FLOAT last_left = 0, last_right = 0, segment_left = 0, segment_right = 0; |
| 115 for (int i = 0; i < pText->m_nChars; i ++) { | 115 for (int i = 0; i < pText->m_nChars; i ++) { |
| 116 FX_DWORD charcode = pText->m_nChars == 1 ? (FX_DWORD)(FX_UINTPTR)pText->
m_pCharCodes : pText->m_pCharCodes[i]; | 116 FX_DWORD charcode = pText->m_nChars == 1 ? (FX_DWORD)(uintptr_t)pText->m
_pCharCodes : pText->m_pCharCodes[i]; |
| 117 if (charcode == (FX_DWORD) - 1) { | 117 if (charcode == (FX_DWORD) - 1) { |
| 118 continue; | 118 continue; |
| 119 } | 119 } |
| 120 FX_FLOAT char_left = pPosArray[cc * 2]; | 120 FX_FLOAT char_left = pPosArray[cc * 2]; |
| 121 FX_FLOAT char_right = pPosArray[cc * 2 + 1]; | 121 FX_FLOAT char_right = pPosArray[cc * 2 + 1]; |
| 122 cc ++; | 122 cc ++; |
| 123 if (char_left < last_left || (char_left - last_right) > spacew / 2) { | 123 if (char_left < last_left || (char_left - last_right) > spacew / 2) { |
| 124 pBaseLine = InsertTextBox(pBaseLine, baseline, leftx + segment_left,
leftx + segment_right, | 124 pBaseLine = InsertTextBox(pBaseLine, baseline, leftx + segment_left,
leftx + segment_right, |
| 125 topy, bottomy, spacew, fontsize_v, segment
, pFont); | 125 topy, bottomy, spacew, fontsize_v, segment
, pFont); |
| 126 segment_left = char_left; | 126 segment_left = char_left; |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 if (str.GetLength() <= 0) { | 304 if (str.GetLength() <= 0) { |
| 305 return; | 305 return; |
| 306 } | 306 } |
| 307 CFX_WideString sBuffer; | 307 CFX_WideString sBuffer; |
| 308 IFX_BidiChar* BidiChar = IFX_BidiChar::Create(); | 308 IFX_BidiChar* BidiChar = IFX_BidiChar::Create(); |
| 309 if (NULL == BidiChar) { | 309 if (NULL == BidiChar) { |
| 310 return; | 310 return; |
| 311 } | 311 } |
| 312 CFX_WordArray order; | 312 CFX_WordArray order; |
| 313 FX_BOOL bR2L = FALSE; | 313 FX_BOOL bR2L = FALSE; |
| 314 FX_INT32 start = 0, count = 0, i = 0; | 314 int32_t start = 0, count = 0, i = 0; |
| 315 int nR2L = 0, nL2R = 0; | 315 int nR2L = 0, nL2R = 0; |
| 316 for (i = 0; i < str.GetLength(); i++) { | 316 for (i = 0; i < str.GetLength(); i++) { |
| 317 if(BidiChar->AppendChar(str.GetAt(i))) { | 317 if(BidiChar->AppendChar(str.GetAt(i))) { |
| 318 FX_INT32 ret = BidiChar->GetBidiInfo(start, count); | 318 int32_t ret = BidiChar->GetBidiInfo(start, count); |
| 319 order.Add(start); | 319 order.Add(start); |
| 320 order.Add(count); | 320 order.Add(count); |
| 321 order.Add(ret); | 321 order.Add(ret); |
| 322 if(!bR2L) { | 322 if(!bR2L) { |
| 323 if(ret == 2) { | 323 if(ret == 2) { |
| 324 nR2L++; | 324 nR2L++; |
| 325 } else if (ret == 1) { | 325 } else if (ret == 1) { |
| 326 nL2R++; | 326 nL2R++; |
| 327 } | 327 } |
| 328 } | 328 } |
| 329 } | 329 } |
| 330 } | 330 } |
| 331 if(BidiChar->EndChar()) { | 331 if(BidiChar->EndChar()) { |
| 332 FX_INT32 ret = BidiChar->GetBidiInfo(start, count); | 332 int32_t ret = BidiChar->GetBidiInfo(start, count); |
| 333 order.Add(start); | 333 order.Add(start); |
| 334 order.Add(count); | 334 order.Add(count); |
| 335 order.Add(ret); | 335 order.Add(ret); |
| 336 if(!bR2L) { | 336 if(!bR2L) { |
| 337 if(ret == 2) { | 337 if(ret == 2) { |
| 338 nR2L++; | 338 nR2L++; |
| 339 } else if(ret == 1) { | 339 } else if(ret == 1) { |
| 340 nL2R++; | 340 nL2R++; |
| 341 } | 341 } |
| 342 } | 342 } |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 { | 769 { |
| 770 buffer.EstimateSize(0, 10240); | 770 buffer.EstimateSize(0, 10240); |
| 771 CPDF_Page page; | 771 CPDF_Page page; |
| 772 page.Load(pDoc, pPage); | 772 page.Load(pDoc, pPage); |
| 773 CPDF_ParseOptions options; | 773 CPDF_ParseOptions options; |
| 774 options.m_bTextOnly = TRUE; | 774 options.m_bTextOnly = TRUE; |
| 775 options.m_bSeparateForm = FALSE; | 775 options.m_bSeparateForm = FALSE; |
| 776 page.ParseContent(&options); | 776 page.ParseContent(&options); |
| 777 _PDF_GetTextStream_Unicode(buffer, &page, TRUE, NULL); | 777 _PDF_GetTextStream_Unicode(buffer, &page, TRUE, NULL); |
| 778 } | 778 } |
| OLD | NEW |