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/include/fpdfapi/fpdf_pageobj.h" | 7 #include "core/include/fpdfapi/fpdf_pageobj.h" |
8 #include "core/include/fpdfapi/fpdf_render.h" | 8 #include "core/include/fpdfapi/fpdf_render.h" |
9 #include "fpdfsdk/include/fx_systemhandler.h" | 9 #include "fpdfsdk/include/fx_systemhandler.h" |
10 #include "fpdfsdk/include/fxedit/fx_edit.h" | 10 #include "fpdfsdk/include/fxedit/fx_edit.h" |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 pDevice, CPDF_Point(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), | 402 pDevice, CPDF_Point(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), |
403 pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, pUser2Device, | 403 pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, pUser2Device, |
404 sTextBuf.GetByteString(), crOld, 0, wp.nHorzScale); | 404 sTextBuf.GetByteString(), crOld, 0, wp.nHorzScale); |
405 } | 405 } |
406 } | 406 } |
407 } | 407 } |
408 | 408 |
409 pDevice->RestoreState(); | 409 pDevice->RestoreState(); |
410 } | 410 } |
411 | 411 |
412 static void AddRectToPageObjects(CPDF_PageObjects* pPageObjs, | 412 static void AddRectToPageObjects(CPDF_PageObjectList* pPageObjs, |
413 FX_COLORREF crFill, | 413 FX_COLORREF crFill, |
414 const CPDF_Rect& rcFill) { | 414 const CPDF_Rect& rcFill) { |
415 CPDF_PathObject* pPathObj = new CPDF_PathObject; | 415 CPDF_PathObject* pPathObj = new CPDF_PathObject; |
416 CPDF_PathData* pPathData = pPathObj->m_Path.GetModify(); | 416 CPDF_PathData* pPathData = pPathObj->m_Path.GetModify(); |
417 pPathData->AppendRect(rcFill.left, rcFill.bottom, rcFill.right, rcFill.top); | 417 pPathData->AppendRect(rcFill.left, rcFill.bottom, rcFill.right, rcFill.top); |
418 | 418 |
419 FX_FLOAT rgb[3]; | 419 FX_FLOAT rgb[3]; |
420 rgb[0] = FXARGB_R(crFill) / 255.0f; | 420 rgb[0] = FXARGB_R(crFill) / 255.0f; |
421 rgb[1] = FXARGB_G(crFill) / 255.0f; | 421 rgb[1] = FXARGB_G(crFill) / 255.0f; |
422 rgb[2] = FXARGB_B(crFill) / 255.0f; | 422 rgb[2] = FXARGB_B(crFill) / 255.0f; |
423 pPathObj->m_ColorState.SetFillColor( | 423 pPathObj->m_ColorState.SetFillColor( |
424 CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), rgb, 3); | 424 CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), rgb, 3); |
425 | 425 |
426 pPathObj->m_FillType = FXFILL_ALTERNATE; | 426 pPathObj->m_FillType = FXFILL_ALTERNATE; |
427 pPathObj->m_bStroke = FALSE; | 427 pPathObj->m_bStroke = FALSE; |
428 | 428 |
429 pPageObjs->InsertObject(pPageObjs->GetLastObjectPosition(), pPathObj); | 429 pPageObjs->InsertObject(pPageObjs->GetLastObjectPosition(), pPathObj); |
430 } | 430 } |
431 | 431 |
432 static CPDF_TextObject* AddTextObjToPageObjects(CPDF_PageObjects* pPageObjs, | 432 static CPDF_TextObject* AddTextObjToPageObjects(CPDF_PageObjectList* pPageObjs, |
433 FX_COLORREF crText, | 433 FX_COLORREF crText, |
434 CPDF_Font* pFont, | 434 CPDF_Font* pFont, |
435 FX_FLOAT fFontSize, | 435 FX_FLOAT fFontSize, |
436 FX_FLOAT fCharSpace, | 436 FX_FLOAT fCharSpace, |
437 int32_t nHorzScale, | 437 int32_t nHorzScale, |
438 const CPDF_Point& point, | 438 const CPDF_Point& point, |
439 const CFX_ByteString& text) { | 439 const CFX_ByteString& text) { |
440 CPDF_TextObject* pTxtObj = new CPDF_TextObject; | 440 CPDF_TextObject* pTxtObj = new CPDF_TextObject; |
441 | 441 |
442 CPDF_TextStateData* pTextStateData = pTxtObj->m_TextState.GetModify(); | 442 CPDF_TextStateData* pTextStateData = pTxtObj->m_TextState.GetModify(); |
(...skipping 18 matching lines...) Expand all Loading... |
461 | 461 |
462 pTxtObj->SetPosition(point.x, point.y); | 462 pTxtObj->SetPosition(point.x, point.y); |
463 pTxtObj->SetText(text); | 463 pTxtObj->SetText(text); |
464 | 464 |
465 pPageObjs->InsertObject(pPageObjs->GetLastObjectPosition(), pTxtObj); | 465 pPageObjs->InsertObject(pPageObjs->GetLastObjectPosition(), pTxtObj); |
466 | 466 |
467 return pTxtObj; | 467 return pTxtObj; |
468 } | 468 } |
469 | 469 |
470 void IFX_Edit::GeneratePageObjects( | 470 void IFX_Edit::GeneratePageObjects( |
471 CPDF_PageObjects* pPageObjects, | 471 CPDF_PageObjectList* pPageObjects, |
472 IFX_Edit* pEdit, | 472 IFX_Edit* pEdit, |
473 const CPDF_Point& ptOffset, | 473 const CPDF_Point& ptOffset, |
474 const CPVT_WordRange* pRange, | 474 const CPVT_WordRange* pRange, |
475 FX_COLORREF crText, | 475 FX_COLORREF crText, |
476 CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) { | 476 CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) { |
477 FX_FLOAT fFontSize = pEdit->GetFontSize(); | 477 FX_FLOAT fFontSize = pEdit->GetFontSize(); |
478 | 478 |
479 int32_t nOldFontIndex = -1; | 479 int32_t nOldFontIndex = -1; |
480 | 480 |
481 CFX_ByteTextBuf sTextBuf; | 481 CFX_ByteTextBuf sTextBuf; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 pPageObjects, crText, pFontMap->GetPDFFont(nOldFontIndex), | 525 pPageObjects, crText, pFontMap->GetPDFFont(nOldFontIndex), |
526 fFontSize, 0.0f, 100, | 526 fFontSize, 0.0f, 100, |
527 CPDF_Point(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), | 527 CPDF_Point(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), |
528 sTextBuf.GetByteString())); | 528 sTextBuf.GetByteString())); |
529 } | 529 } |
530 } | 530 } |
531 } | 531 } |
532 } | 532 } |
533 | 533 |
534 void IFX_Edit::GenerateRichPageObjects( | 534 void IFX_Edit::GenerateRichPageObjects( |
535 CPDF_PageObjects* pPageObjects, | 535 CPDF_PageObjectList* pPageObjects, |
536 IFX_Edit* pEdit, | 536 IFX_Edit* pEdit, |
537 const CPDF_Point& ptOffset, | 537 const CPDF_Point& ptOffset, |
538 const CPVT_WordRange* pRange, | 538 const CPVT_WordRange* pRange, |
539 CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) { | 539 CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) { |
540 FX_COLORREF crCurText = ArgbEncode(255, 0, 0, 0); | 540 FX_COLORREF crCurText = ArgbEncode(255, 0, 0, 0); |
541 FX_COLORREF crOld = crCurText; | 541 FX_COLORREF crOld = crCurText; |
542 | 542 |
543 CFX_ByteTextBuf sTextBuf; | 543 CFX_ByteTextBuf sTextBuf; |
544 CPVT_WordProps wp; | 544 CPVT_WordProps wp; |
545 CPDF_Point ptBT(0.0f, 0.0f); | 545 CPDF_Point ptBT(0.0f, 0.0f); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 ObjArray.Add(AddTextObjToPageObjects( | 617 ObjArray.Add(AddTextObjToPageObjects( |
618 pPageObjects, crOld, pFontMap->GetPDFFont(wp.nFontIndex), | 618 pPageObjects, crOld, pFontMap->GetPDFFont(wp.nFontIndex), |
619 wp.fFontSize, wp.fCharSpace, wp.nHorzScale, | 619 wp.fFontSize, wp.fCharSpace, wp.nHorzScale, |
620 CPDF_Point(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), | 620 CPDF_Point(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), |
621 sTextBuf.GetByteString())); | 621 sTextBuf.GetByteString())); |
622 } | 622 } |
623 } | 623 } |
624 } | 624 } |
625 } | 625 } |
626 | 626 |
627 void IFX_Edit::GenerateUnderlineObjects(CPDF_PageObjects* pPageObjects, | 627 void IFX_Edit::GenerateUnderlineObjects(CPDF_PageObjectList* pPageObjects, |
628 IFX_Edit* pEdit, | 628 IFX_Edit* pEdit, |
629 const CPDF_Point& ptOffset, | 629 const CPDF_Point& ptOffset, |
630 const CPVT_WordRange* pRange, | 630 const CPVT_WordRange* pRange, |
631 FX_COLORREF color) { | 631 FX_COLORREF color) { |
632 if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) { | 632 if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) { |
633 if (pEdit->GetFontMap()) { | 633 if (pEdit->GetFontMap()) { |
634 if (pRange) | 634 if (pRange) |
635 pIterator->SetAt(pRange->BeginPos); | 635 pIterator->SetAt(pRange->BeginPos); |
636 else | 636 else |
637 pIterator->SetAt(0); | 637 pIterator->SetAt(0); |
(...skipping 11 matching lines...) Expand all Loading... |
649 rcUnderline.left += ptOffset.x; | 649 rcUnderline.left += ptOffset.x; |
650 rcUnderline.right += ptOffset.x; | 650 rcUnderline.right += ptOffset.x; |
651 rcUnderline.top += ptOffset.y; | 651 rcUnderline.top += ptOffset.y; |
652 rcUnderline.bottom += ptOffset.y; | 652 rcUnderline.bottom += ptOffset.y; |
653 AddRectToPageObjects(pPageObjects, color, rcUnderline); | 653 AddRectToPageObjects(pPageObjects, color, rcUnderline); |
654 } | 654 } |
655 } | 655 } |
656 } | 656 } |
657 } | 657 } |
658 } | 658 } |
OLD | NEW |