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

Side by Side Diff: core/src/reflow/layoutprocessor_reflow.cpp

Issue 1177483002: Use stdint.h types throughout PDFium. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
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/reflow/autoreflow.cpp ('k') | core/src/reflow/reflowedpage.h » ('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/reflow/reflowengine.h" 7 #include "../../include/reflow/reflowengine.h"
8 #include "reflowedpage.h" 8 #include "reflowedpage.h"
9 #include "layoutprovider_taggedpdf.h" 9 #include "layoutprovider_taggedpdf.h"
10 IPDF_LayoutProcessor* IPDF_LayoutProcessor::Create_LayoutProcessor_Reflow(FX_FLO AT TopIndent, FX_FLOAT fWidth, FX_FLOAT fHeight, void* pReflowedPage, int flags, FX_FLOAT lineSpace ) 10 IPDF_LayoutProcessor* IPDF_LayoutProcessor::Create_LayoutProcessor_Reflow(FX_FLO AT TopIndent, FX_FLOAT fWidth, FX_FLOAT fHeight, void* pReflowedPage, int flags, FX_FLOAT lineSpace )
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 if(!GetIntersection(Rect1.left, Rect1.right, Rect2.left, Rect2.right, in ter_left, inter_right)) { 397 if(!GetIntersection(Rect1.left, Rect1.right, Rect2.left, Rect2.right, in ter_left, inter_right)) {
398 return FALSE; 398 return FALSE;
399 } 399 }
400 FX_FLOAT inter_w = inter_right - inter_left; 400 FX_FLOAT inter_w = inter_right - inter_left;
401 if (inter_w < (Rect1.right - Rect1.left) / 2 && inter_w < (Rect2.right - Rect2.left) / 2) { 401 if (inter_w < (Rect1.right - Rect1.left) / 2 && inter_w < (Rect2.right - Rect2.left) / 2) {
402 return FALSE; 402 return FALSE;
403 } 403 }
404 } 404 }
405 return TRUE; 405 return TRUE;
406 } 406 }
407 FX_INT32 IsCanMergeParagraph(IPDF_LayoutElement* pPrevElement, IPDF_LayoutElemen t* pNextElement) 407 int32_t IsCanMergeParagraph(IPDF_LayoutElement* pPrevElement, IPDF_LayoutElement * pNextElement)
408 { 408 {
409 FX_INT32 analogial = 100; 409 int32_t analogial = 100;
410 FX_INT32 nPrevObj = pPrevElement->CountObjects(), i; 410 int32_t nPrevObj = pPrevElement->CountObjects(), i;
411 CPDF_PageObject* pPrevObj = NULL; 411 CPDF_PageObject* pPrevObj = NULL;
412 CFX_FloatRect prevRect, rect; 412 CFX_FloatRect prevRect, rect;
413 CFX_PtrArray prevLine, line; 413 CFX_PtrArray prevLine, line;
414 FX_BOOL bParagraphStart = FALSE; 414 FX_BOOL bParagraphStart = FALSE;
415 for(i = 0; i < nPrevObj; i++) { 415 for(i = 0; i < nPrevObj; i++) {
416 CPDF_PageObject* pObj = pPrevElement->GetObject(i); 416 CPDF_PageObject* pObj = pPrevElement->GetObject(i);
417 if(!pPrevObj) { 417 if(!pPrevObj) {
418 pPrevObj = pObj; 418 pPrevObj = pObj;
419 rect = CFX_FloatRect(pObj->m_Left, pObj->m_Bottom, pObj->m_Right, pO bj->m_Top); 419 rect = CFX_FloatRect(pObj->m_Left, pObj->m_Bottom, pObj->m_Right, pO bj->m_Top);
420 line.Add(pObj); 420 line.Add(pObj);
(...skipping 18 matching lines...) Expand all
439 } 439 }
440 } 440 }
441 if(prevLine.GetSize()) { 441 if(prevLine.GetSize()) {
442 if(FXSYS_fabs(rect.right - prevRect.right) > rect.Height()) { 442 if(FXSYS_fabs(rect.right - prevRect.right) > rect.Height()) {
443 analogial -= 50; 443 analogial -= 50;
444 } 444 }
445 } 445 }
446 CPDF_PageObject* pObj = pPrevElement->GetObject(nPrevObj - 1); 446 CPDF_PageObject* pObj = pPrevElement->GetObject(nPrevObj - 1);
447 if(pObj->m_Type == PDFPAGE_TEXT) { 447 if(pObj->m_Type == PDFPAGE_TEXT) {
448 CPDF_TextObject* pText = (CPDF_TextObject*)pObj; 448 CPDF_TextObject* pText = (CPDF_TextObject*)pObj;
449 FX_INT32 nItem = pText->CountItems(); 449 int32_t nItem = pText->CountItems();
450 CPDF_TextObjectItem item; 450 CPDF_TextObjectItem item;
451 pText->GetItemInfo(nItem - 1, &item); 451 pText->GetItemInfo(nItem - 1, &item);
452 CFX_WideString wStr = pText->GetFont()->UnicodeFromCharCode(item.m_CharC ode); 452 CFX_WideString wStr = pText->GetFont()->UnicodeFromCharCode(item.m_CharC ode);
453 if(wStr.IsEmpty()) { 453 if(wStr.IsEmpty()) {
454 wStr = (FX_WCHAR)item.m_CharCode; 454 wStr = (FX_WCHAR)item.m_CharCode;
455 } 455 }
456 FX_WCHAR wch = wStr.GetAt(wStr.GetLength() - 1); 456 FX_WCHAR wch = wStr.GetAt(wStr.GetLength() - 1);
457 switch(wch) { 457 switch(wch) {
458 case '.': 458 case '.':
459 case 12290: 459 case 12290:
460 case 65311: 460 case 65311:
461 case 63: 461 case 63:
462 case 33: 462 case 33:
463 case 65281: 463 case 65281:
464 analogial -= 50; 464 analogial -= 50;
465 break; 465 break;
466 } 466 }
467 } 467 }
468 prevLine.RemoveAll(); 468 prevLine.RemoveAll();
469 prevLine.Append(line); 469 prevLine.Append(line);
470 line.RemoveAll(); 470 line.RemoveAll();
471 FX_INT32 nNextObj = pNextElement->CountObjects(); 471 int32_t nNextObj = pNextElement->CountObjects();
472 pPrevObj = NULL; 472 pPrevObj = NULL;
473 FX_BOOL bFirst = TRUE; 473 FX_BOOL bFirst = TRUE;
474 for(i = 0; i < nNextObj; i++) { 474 for(i = 0; i < nNextObj; i++) {
475 CPDF_PageObject* pObj = pNextElement->GetObject(i); 475 CPDF_PageObject* pObj = pNextElement->GetObject(i);
476 if(!pPrevObj) { 476 if(!pPrevObj) {
477 pPrevObj = pObj; 477 pPrevObj = pObj;
478 rect = CFX_FloatRect(pObj->m_Left, pObj->m_Bottom, pObj->m_Right, pO bj->m_Top); 478 rect = CFX_FloatRect(pObj->m_Left, pObj->m_Bottom, pObj->m_Right, pO bj->m_Top);
479 line.Add(pObj); 479 line.Add(pObj);
480 continue; 480 continue;
481 } 481 }
(...skipping 30 matching lines...) Expand all
512 } 512 }
513 return analogial; 513 return analogial;
514 } 514 }
515 void CPDF_LayoutProcessor_Reflow::ProcessElement(IPDF_LayoutElement* pElement, F X_FLOAT reflowWidth) 515 void CPDF_LayoutProcessor_Reflow::ProcessElement(IPDF_LayoutElement* pElement, F X_FLOAT reflowWidth)
516 { 516 {
517 if(pElement == NULL) { 517 if(pElement == NULL) {
518 return; 518 return;
519 } 519 }
520 if(m_Status == LayoutReady) { 520 if(m_Status == LayoutReady) {
521 LayoutType layoutType = pElement->GetType(); 521 LayoutType layoutType = pElement->GetType();
522 FX_INT32 ElementType = GetElementTypes(layoutType); 522 int32_t ElementType = GetElementTypes(layoutType);
523 switch(ElementType) { 523 switch(ElementType) {
524 case SST_IE: 524 case SST_IE:
525 m_bIllustration = TRUE; 525 m_bIllustration = TRUE;
526 break; 526 break;
527 case SST_BLSE: 527 case SST_BLSE:
528 FinishedCurrLine(); 528 FinishedCurrLine();
529 FX_FLOAT StartIndent = 0; 529 FX_FLOAT StartIndent = 0;
530 if(IPDF_LayoutElement* pParent = pElement->GetParent()) { 530 if(IPDF_LayoutElement* pParent = pElement->GetParent()) {
531 StartIndent = pParent->GetNumberAttr(LayoutStartIndent); 531 StartIndent = pParent->GetNumberAttr(LayoutStartIndent);
532 } 532 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 return ; 632 return ;
633 } 633 }
634 } 634 }
635 if(m_Status == LayoutToBeContinued && m_pLayoutElement == pChildElement) { 635 if(m_Status == LayoutToBeContinued && m_pLayoutElement == pChildElement) {
636 m_Status = LayoutReady; 636 m_Status = LayoutReady;
637 } 637 }
638 } 638 }
639 if(m_Status == LayoutReady) { 639 if(m_Status == LayoutReady) {
640 FX_FLOAT dx = 0; 640 FX_FLOAT dx = 0;
641 LayoutType layoutType = pElement->GetType(); 641 LayoutType layoutType = pElement->GetType();
642 FX_INT32 ElementType = GetElementTypes(layoutType); 642 int32_t ElementType = GetElementTypes(layoutType);
643 switch(ElementType) { 643 switch(ElementType) {
644 case SST_IE: 644 case SST_IE:
645 m_bIllustration = FALSE; 645 m_bIllustration = FALSE;
646 FinishedCurrLine(); 646 FinishedCurrLine();
647 break; 647 break;
648 case SST_BLSE: 648 case SST_BLSE:
649 FinishedCurrLine(); 649 FinishedCurrLine();
650 FX_FLOAT StartIndent = 0; 650 FX_FLOAT StartIndent = 0;
651 if(IPDF_LayoutElement* pParent = pElement->GetParent()) { 651 if(IPDF_LayoutElement* pParent = pElement->GetParent()) {
652 StartIndent = pParent->GetNumberAttr(LayoutStartIndent); 652 StartIndent = pParent->GetNumberAttr(LayoutStartIndent);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 CFX_AffineMatrix matrix(1, 0, 0, 1, dx, 0); 698 CFX_AffineMatrix matrix(1, 0, 0, 1, dx, 0);
699 int ReflowedSize = m_pReflowedPage->m_pReflowed->GetSize(); 699 int ReflowedSize = m_pReflowedPage->m_pReflowed->GetSize();
700 Transform(&matrix, m_pReflowedPage->m_pReflowed, ReflowedSiz e, m_pReflowedPage->m_pReflowed->GetSize() - ReflowedSize); 700 Transform(&matrix, m_pReflowedPage->m_pReflowed, ReflowedSiz e, m_pReflowedPage->m_pReflowed->GetSize() - ReflowedSize);
701 } 701 }
702 } 702 }
703 } 703 }
704 if(m_pRootElement == pElement) { 704 if(m_pRootElement == pElement) {
705 m_PausePosition = 100; 705 m_PausePosition = 100;
706 } 706 }
707 } 707 }
708 FX_INT32 CPDF_LayoutProcessor_Reflow::GetElementTypes(LayoutType layoutType) 708 int32_t CPDF_LayoutProcessor_Reflow::GetElementTypes(LayoutType layoutType)
709 { 709 {
710 switch(layoutType) { 710 switch(layoutType) {
711 case LayoutParagraph: 711 case LayoutParagraph:
712 case LayoutHeading: 712 case LayoutHeading:
713 case LayoutHeading1: 713 case LayoutHeading1:
714 case LayoutHeading2: 714 case LayoutHeading2:
715 case LayoutHeading3: 715 case LayoutHeading3:
716 case LayoutHeading4: 716 case LayoutHeading4:
717 case LayoutHeading5: 717 case LayoutHeading5:
718 case LayoutHeading6: 718 case LayoutHeading6:
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 if (preChar != L' ') { 1194 if (preChar != L' ') {
1195 return 1; 1195 return 1;
1196 } 1196 }
1197 return 2; 1197 return 2;
1198 } 1198 }
1199 if ((x - last_pos - last_width) > threshold && curChar != L' ' && preChar != L' ') { 1199 if ((x - last_pos - last_width) > threshold && curChar != L' ' && preChar != L' ') {
1200 return 1; 1200 return 1;
1201 } 1201 }
1202 return 0; 1202 return 0;
1203 } 1203 }
1204 FX_INT32 CPDF_LayoutProcessor_Reflow::LogicPreObj(CPDF_TextObject* pObj) 1204 int32_t CPDF_LayoutProcessor_Reflow::LogicPreObj(CPDF_TextObject* pObj)
1205 { 1205 {
1206 CPDF_TextObject* pPreObj = m_pPreObj; 1206 CPDF_TextObject* pPreObj = m_pPreObj;
1207 m_pPreObj = pObj; 1207 m_pPreObj = pObj;
1208 if(!pObj || !pPreObj) { 1208 if(!pObj || !pPreObj) {
1209 return 0; 1209 return 0;
1210 } 1210 }
1211 CPDF_TextObjectItem item; 1211 CPDF_TextObjectItem item;
1212 pPreObj->GetItemInfo(pPreObj->CountItems() - 1, &item); 1212 pPreObj->GetItemInfo(pPreObj->CountItems() - 1, &item);
1213 FX_FLOAT last_pos = item.m_OriginX; 1213 FX_FLOAT last_pos = item.m_OriginX;
1214 FX_FLOAT last_width = pPreObj->GetFont()->GetCharWidthF(item.m_CharCode) * p PreObj->GetFontSize() / 1000; 1214 FX_FLOAT last_width = pPreObj->GetFont()->GetCharWidthF(item.m_CharCode) * p PreObj->GetFontSize() / 1000;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 } 1331 }
1332 void CPDF_LayoutProcessor_Reflow::ProcessTextObject(CPDF_TextObject *pTextObj, F X_FLOAT reflowWidth, CFX_AffineMatrix objMatrix) 1332 void CPDF_LayoutProcessor_Reflow::ProcessTextObject(CPDF_TextObject *pTextObj, F X_FLOAT reflowWidth, CFX_AffineMatrix objMatrix)
1333 { 1333 {
1334 if(reflowWidth < 0 || !m_pCurrLine || !m_pTempLine) { 1334 if(reflowWidth < 0 || !m_pCurrLine || !m_pTempLine) {
1335 return; 1335 return;
1336 } 1336 }
1337 if(IsSameTextObject(pTextObj, m_pPreObj)) { 1337 if(IsSameTextObject(pTextObj, m_pPreObj)) {
1338 return; 1338 return;
1339 } 1339 }
1340 CPDF_PageObject* pPreObj = m_pPreObj; 1340 CPDF_PageObject* pPreObj = m_pPreObj;
1341 FX_INT32 logic = ProcessInsertObject(pTextObj, objMatrix); 1341 int32_t logic = ProcessInsertObject(pTextObj, objMatrix);
1342 m_pPreObj = pTextObj; 1342 m_pPreObj = pTextObj;
1343 m_perMatrix.Copy(objMatrix); 1343 m_perMatrix.Copy(objMatrix);
1344 int size = m_pTempLine->GetSize(); 1344 int size = m_pTempLine->GetSize();
1345 int curs = m_pCurrLine->GetSize(); 1345 int curs = m_pCurrLine->GetSize();
1346 CreateRFData(pTextObj); 1346 CreateRFData(pTextObj);
1347 size = m_pTempLine->GetSize(); 1347 size = m_pTempLine->GetSize();
1348 int reds = m_pReflowedPage->m_pReflowed->GetSize(); 1348 int reds = m_pReflowedPage->m_pReflowed->GetSize();
1349 if(size == 0) { 1349 if(size == 0) {
1350 return; 1350 return;
1351 } 1351 }
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1526 FinishedCurrLine(); 1526 FinishedCurrLine();
1527 FX_FLOAT f = reflowWidth / ObjWidth ; 1527 FX_FLOAT f = reflowWidth / ObjWidth ;
1528 matrix.Set(f, 0, 0, f, 0, 0); 1528 matrix.Set(f, 0, 0, f, 0, 0);
1529 } 1529 }
1530 CFX_AffineMatrix tempMatrix = matrix; 1530 CFX_AffineMatrix tempMatrix = matrix;
1531 matrix.Concat(objMatrix); 1531 matrix.Concat(objMatrix);
1532 FX_POSITION pos = pObjs->GetFirstObjectPosition(); 1532 FX_POSITION pos = pObjs->GetFirstObjectPosition();
1533 while(pos) { 1533 while(pos) {
1534 CPDF_PageObject* pObj = pObjs->GetNextObject(pos); 1534 CPDF_PageObject* pObj = pObjs->GetNextObject(pos);
1535 if(pObj->m_Type == PDFPAGE_TEXT) { 1535 if(pObj->m_Type == PDFPAGE_TEXT) {
1536 FX_INT32 ret = LogicPreObj((CPDF_TextObject*)pObj); 1536 int32_t ret = LogicPreObj((CPDF_TextObject*)pObj);
1537 if(ret == 1 || ret == 2) { 1537 if(ret == 1 || ret == 2) {
1538 continue; 1538 continue;
1539 } 1539 }
1540 } 1540 }
1541 CreateRFData(pObj, &matrix); 1541 CreateRFData(pObj, &matrix);
1542 } 1542 }
1543 if (m_pTempLine) { 1543 if (m_pTempLine) {
1544 Transform(&tempMatrix, m_pTempLine, 0, m_pTempLine->GetSize()); 1544 Transform(&tempMatrix, m_pTempLine, 0, m_pTempLine->GetSize());
1545 AddTemp2CurrLine(0, m_pTempLine->GetSize()); 1545 AddTemp2CurrLine(0, m_pTempLine->GetSize());
1546 m_pTempLine->RemoveAll(); 1546 m_pTempLine->RemoveAll();
1547 } 1547 }
1548 } 1548 }
1549 void CPDF_LayoutProcessor_Reflow::ProcessPathObject(CPDF_PathObject *pObj, FX_FL OAT reflowWidth) 1549 void CPDF_LayoutProcessor_Reflow::ProcessPathObject(CPDF_PathObject *pObj, FX_FL OAT reflowWidth)
1550 { 1550 {
1551 } 1551 }
OLDNEW
« no previous file with comments | « core/src/reflow/autoreflow.cpp ('k') | core/src/reflow/reflowedpage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698