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 "xfa/fde/tto/fde_textout.h" | 7 #include "xfa/fde/tto/fde_textout.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 dwBreakStatus = m_pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); | 728 dwBreakStatus = m_pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); |
729 if (dwBreakStatus > FX_TXTBREAK_PieceBreak) { | 729 if (dwBreakStatus > FX_TXTBREAK_PieceBreak) { |
730 RetriecePieces(dwBreakStatus, iStartChar, iPieceWidths, TRUE, rect); | 730 RetriecePieces(dwBreakStatus, iStartChar, iPieceWidths, TRUE, rect); |
731 } | 731 } |
732 m_pTxtBreak->Reset(); | 732 m_pTxtBreak->Reset(); |
733 } | 733 } |
734 void CFDE_TextOut::DoAlignment(const CFX_RectF& rect) { | 734 void CFDE_TextOut::DoAlignment(const CFX_RectF& rect) { |
735 FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout); | 735 FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout); |
736 FX_FLOAT fLineStopS = bVertical ? rect.right() : rect.bottom(); | 736 FX_FLOAT fLineStopS = bVertical ? rect.right() : rect.bottom(); |
737 int32_t iLines = m_ttoLines.GetSize(); | 737 int32_t iLines = m_ttoLines.GetSize(); |
738 if (iLines < 1) { | 738 if (iLines < 1) |
739 return; | 739 return; |
740 } | 740 FDE_TTOPIECE* pFirstPiece = m_ttoLines.GetPtrAt(iLines - 1)->GetPtrAt(0); |
741 CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(iLines - 1); | 741 if (!pFirstPiece) |
742 FDE_TTOPIECE* pPiece = pLine->GetPtrAt(0); | |
743 if (pPiece == NULL) { | |
744 return; | 742 return; |
745 } | 743 |
746 FX_FLOAT fLineStopD = | 744 FX_FLOAT fLineStopD = |
747 bVertical ? pPiece->rtPiece.right() : pPiece->rtPiece.bottom(); | 745 bVertical ? pFirstPiece->rtPiece.right() : pFirstPiece->rtPiece.bottom(); |
748 FX_FLOAT fInc = fLineStopS - fLineStopD; | 746 FX_FLOAT fInc = fLineStopS - fLineStopD; |
749 if (m_iAlignment >= FDE_TTOALIGNMENT_CenterLeft && | 747 if (m_iAlignment >= FDE_TTOALIGNMENT_CenterLeft && |
750 m_iAlignment < FDE_TTOALIGNMENT_BottomLeft) { | 748 m_iAlignment < FDE_TTOALIGNMENT_BottomLeft) { |
751 fInc /= 2.0f; | 749 fInc /= 2.0f; |
752 } else if (m_iAlignment < FDE_TTOALIGNMENT_CenterLeft) { | 750 } else if (m_iAlignment < FDE_TTOALIGNMENT_CenterLeft) { |
753 fInc = 0.0f; | 751 fInc = 0.0f; |
754 } | 752 } |
755 if (fInc < 1.0f) { | 753 if (fInc < 1.0f) |
756 return; | 754 return; |
757 } | |
758 for (int32_t i = 0; i < iLines; i++) { | 755 for (int32_t i = 0; i < iLines; i++) { |
759 CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(i); | 756 CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(i); |
760 int32_t iPieces = pLine->GetSize(); | 757 int32_t iPieces = pLine->GetSize(); |
761 for (int32_t j = 0; j < iPieces; j++) { | 758 for (int32_t j = 0; j < iPieces; j++) { |
762 FDE_TTOPIECE* pPiece = pLine->GetPtrAt(j); | 759 FDE_TTOPIECE* pPiece = pLine->GetPtrAt(j); |
763 if (bVertical) { | 760 if (bVertical) |
764 pPiece->rtPiece.left += fInc; | 761 pPiece->rtPiece.left += fInc; |
765 } else { | 762 else |
766 pPiece->rtPiece.top += fInc; | 763 pPiece->rtPiece.top += fInc; |
767 } | |
768 } | 764 } |
769 } | 765 } |
770 } | 766 } |
771 void CFDE_TextOut::OnDraw(const CFX_RectF& rtClip) { | 767 void CFDE_TextOut::OnDraw(const CFX_RectF& rtClip) { |
772 if (!m_pRenderDevice) | 768 if (!m_pRenderDevice) |
773 return; | 769 return; |
774 | 770 |
775 int32_t iLines = m_ttoLines.GetSize(); | 771 int32_t iLines = m_ttoLines.GetSize(); |
776 if (iLines < 1) | 772 if (iLines < 1) |
777 return; | 773 return; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
935 return NULL; | 931 return NULL; |
936 } | 932 } |
937 return m_pieces.GetPtrAt(index); | 933 return m_pieces.GetPtrAt(index); |
938 } | 934 } |
939 void CFDE_TTOLine::RemoveLast(int32_t iCount) { | 935 void CFDE_TTOLine::RemoveLast(int32_t iCount) { |
940 m_pieces.RemoveLast(iCount); | 936 m_pieces.RemoveLast(iCount); |
941 } | 937 } |
942 void CFDE_TTOLine::RemoveAll(FX_BOOL bLeaveMemory) { | 938 void CFDE_TTOLine::RemoveAll(FX_BOOL bLeaveMemory) { |
943 m_pieces.RemoveAll(bLeaveMemory); | 939 m_pieces.RemoveAll(bLeaveMemory); |
944 } | 940 } |
OLD | NEW |