Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: core/src/fpdftext/fpdf_text.cpp

Issue 1172793002: Merge to XFA: Use stdint.h types throughout PDFium. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fpdfdoc/pdf_vt.h ('k') | core/src/fpdftext/fpdf_text_int.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 if (str.GetLength() <= 0) { 307 if (str.GetLength() <= 0) {
308 return; 308 return;
309 } 309 }
310 CFX_WideString sBuffer; 310 CFX_WideString sBuffer;
311 IFX_BidiChar* BidiChar = IFX_BidiChar::Create(); 311 IFX_BidiChar* BidiChar = IFX_BidiChar::Create();
312 if (NULL == BidiChar) { 312 if (NULL == BidiChar) {
313 return; 313 return;
314 } 314 }
315 CFX_WordArray order; 315 CFX_WordArray order;
316 FX_BOOL bR2L = FALSE; 316 FX_BOOL bR2L = FALSE;
317 FX_INT32 start = 0, count = 0, i = 0; 317 int32_t start = 0, count = 0, i = 0;
318 int nR2L = 0, nL2R = 0; 318 int nR2L = 0, nL2R = 0;
319 for (i = 0; i < str.GetLength(); i++) { 319 for (i = 0; i < str.GetLength(); i++) {
320 if(BidiChar->AppendChar(str.GetAt(i))) { 320 if(BidiChar->AppendChar(str.GetAt(i))) {
321 FX_INT32 ret = BidiChar->GetBidiInfo(start, count); 321 int32_t ret = BidiChar->GetBidiInfo(start, count);
322 order.Add(start); 322 order.Add(start);
323 order.Add(count); 323 order.Add(count);
324 order.Add(ret); 324 order.Add(ret);
325 if(!bR2L) { 325 if(!bR2L) {
326 if(ret == 2) { 326 if(ret == 2) {
327 nR2L++; 327 nR2L++;
328 } else if (ret == 1) { 328 } else if (ret == 1) {
329 nL2R++; 329 nL2R++;
330 } 330 }
331 } 331 }
332 } 332 }
333 } 333 }
334 if(BidiChar->EndChar()) { 334 if(BidiChar->EndChar()) {
335 FX_INT32 ret = BidiChar->GetBidiInfo(start, count); 335 int32_t ret = BidiChar->GetBidiInfo(start, count);
336 order.Add(start); 336 order.Add(start);
337 order.Add(count); 337 order.Add(count);
338 order.Add(ret); 338 order.Add(ret);
339 if(!bR2L) { 339 if(!bR2L) {
340 if(ret == 2) { 340 if(ret == 2) {
341 nR2L++; 341 nR2L++;
342 } else if(ret == 1) { 342 } else if(ret == 1) {
343 nL2R++; 343 nL2R++;
344 } 344 }
345 } 345 }
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 { 777 {
778 buffer.EstimateSize(0, 10240); 778 buffer.EstimateSize(0, 10240);
779 CPDF_Page page; 779 CPDF_Page page;
780 page.Load(pDoc, pPage); 780 page.Load(pDoc, pPage);
781 CPDF_ParseOptions options; 781 CPDF_ParseOptions options;
782 options.m_bTextOnly = TRUE; 782 options.m_bTextOnly = TRUE;
783 options.m_bSeparateForm = FALSE; 783 options.m_bSeparateForm = FALSE;
784 page.ParseContent(&options); 784 page.ParseContent(&options);
785 _PDF_GetTextStream_Unicode(buffer, &page, TRUE, NULL); 785 _PDF_GetTextStream_Unicode(buffer, &page, TRUE, NULL);
786 } 786 }
OLDNEW
« no previous file with comments | « core/src/fpdfdoc/pdf_vt.h ('k') | core/src/fpdftext/fpdf_text_int.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698