| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 const CFX_RectF& rect); | 135 const CFX_RectF& rect); |
| 136 void AppendPiece(const FDE_TTOPIECE& ttoPiece, | 136 void AppendPiece(const FDE_TTOPIECE& ttoPiece, |
| 137 FX_BOOL bNeedReload, | 137 FX_BOOL bNeedReload, |
| 138 FX_BOOL bEnd); | 138 FX_BOOL bEnd); |
| 139 void ReplaceWidthEllipsis(); | 139 void ReplaceWidthEllipsis(); |
| 140 void DoAlignment(const CFX_RectF& rect); | 140 void DoAlignment(const CFX_RectF& rect); |
| 141 void OnDraw(const CFX_RectF& rtClip); | 141 void OnDraw(const CFX_RectF& rtClip); |
| 142 int32_t GetDisplayPos(FDE_LPTTOPIECE pPiece); | 142 int32_t GetDisplayPos(FDE_LPTTOPIECE pPiece); |
| 143 int32_t GetCharRects(FDE_LPTTOPIECE pPiece); | 143 int32_t GetCharRects(FDE_LPTTOPIECE pPiece); |
| 144 | 144 |
| 145 void ToTextRun(const FDE_LPTTOPIECE pPiece, FX_TXTRUN& tr); | 145 FX_TXTRUN ToTextRun(const FDE_LPTTOPIECE pPiece); |
| 146 void DrawLine(const FDE_LPTTOPIECE pPiece, CFDE_Pen*& pPen); | 146 void DrawLine(const FDE_LPTTOPIECE pPiece, CFDE_Pen*& pPen); |
| 147 | 147 |
| 148 CFX_TxtBreak* m_pTxtBreak; | 148 CFX_TxtBreak* m_pTxtBreak; |
| 149 IFX_Font* m_pFont; | 149 IFX_Font* m_pFont; |
| 150 FX_FLOAT m_fFontSize; | 150 FX_FLOAT m_fFontSize; |
| 151 FX_FLOAT m_fLineSpace; | 151 FX_FLOAT m_fLineSpace; |
| 152 FX_FLOAT m_fLinePos; | 152 FX_FLOAT m_fLinePos; |
| 153 FX_FLOAT m_fTolerance; | 153 FX_FLOAT m_fTolerance; |
| 154 int32_t m_iAlignment; | 154 int32_t m_iAlignment; |
| 155 int32_t m_iTxtBkAlignment; | 155 int32_t m_iTxtBkAlignment; |
| (...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 968 m_pRenderDevice->DrawString(pBrush, m_pFont, m_pCharPos, iCount, | 968 m_pRenderDevice->DrawString(pBrush, m_pFont, m_pCharPos, iCount, |
| 969 m_fFontSize, &m_Matrix); | 969 m_fFontSize, &m_Matrix); |
| 970 } | 970 } |
| 971 DrawLine(pPiece, pPen); | 971 DrawLine(pPiece, pPen); |
| 972 } | 972 } |
| 973 } | 973 } |
| 974 m_pRenderDevice->RestoreState(hDev); | 974 m_pRenderDevice->RestoreState(hDev); |
| 975 delete pBrush; | 975 delete pBrush; |
| 976 delete pPen; | 976 delete pPen; |
| 977 } | 977 } |
| 978 |
| 978 int32_t CFDE_TextOut::GetDisplayPos(FDE_LPTTOPIECE pPiece) { | 979 int32_t CFDE_TextOut::GetDisplayPos(FDE_LPTTOPIECE pPiece) { |
| 979 FX_TXTRUN tr; | 980 FX_TXTRUN tr = ToTextRun(pPiece); |
| 980 ToTextRun(pPiece, tr); | |
| 981 ExpandBuffer(tr.iLength, 2); | 981 ExpandBuffer(tr.iLength, 2); |
| 982 return m_pTxtBreak->GetDisplayPos(&tr, m_pCharPos); | 982 return m_pTxtBreak->GetDisplayPos(&tr, m_pCharPos); |
| 983 } | 983 } |
| 984 |
| 984 int32_t CFDE_TextOut::GetCharRects(FDE_LPTTOPIECE pPiece) { | 985 int32_t CFDE_TextOut::GetCharRects(FDE_LPTTOPIECE pPiece) { |
| 985 FX_TXTRUN tr; | 986 FX_TXTRUN tr = ToTextRun(pPiece); |
| 986 ToTextRun(pPiece, tr); | |
| 987 m_rectArray.RemoveAll(); | 987 m_rectArray.RemoveAll(); |
| 988 return m_pTxtBreak->GetCharRects(&tr, m_rectArray); | 988 return m_pTxtBreak->GetCharRects(&tr, m_rectArray); |
| 989 } | 989 } |
| 990 void CFDE_TextOut::ToTextRun(const FDE_LPTTOPIECE pPiece, FX_TXTRUN& tr) { | 990 |
| 991 tr.pAccess = NULL; | 991 FX_TXTRUN CFDE_TextOut::ToTextRun(const FDE_LPTTOPIECE pPiece) { |
| 992 tr.pIdentity = NULL; | 992 FX_TXTRUN tr; |
| 993 tr.pStr = (m_wsText + pPiece->iStartChar).c_str(); | 993 tr.wsStr = m_wsText + pPiece->iStartChar; |
| 994 tr.pWidths = m_pCharWidths + pPiece->iStartChar; | 994 tr.pWidths = m_pCharWidths + pPiece->iStartChar; |
| 995 tr.iLength = pPiece->iChars; | 995 tr.iLength = pPiece->iChars; |
| 996 tr.pFont = m_pFont; | 996 tr.pFont = m_pFont; |
| 997 tr.fFontSize = m_fFontSize; | 997 tr.fFontSize = m_fFontSize; |
| 998 tr.dwStyles = m_dwTxtBkStyles; | 998 tr.dwStyles = m_dwTxtBkStyles; |
| 999 tr.iCharRotation = 0; | |
| 1000 tr.dwCharStyles = pPiece->dwCharStyles; | 999 tr.dwCharStyles = pPiece->dwCharStyles; |
| 1001 tr.wLineBreakChar = m_wParagraphBkChar; | 1000 tr.wLineBreakChar = m_wParagraphBkChar; |
| 1002 tr.pRect = &pPiece->rtPiece; | 1001 tr.pRect = &pPiece->rtPiece; |
| 1002 return tr; |
| 1003 } | 1003 } |
| 1004 |
| 1004 void CFDE_TextOut::DrawLine(const FDE_LPTTOPIECE pPiece, CFDE_Pen*& pPen) { | 1005 void CFDE_TextOut::DrawLine(const FDE_LPTTOPIECE pPiece, CFDE_Pen*& pPen) { |
| 1005 FX_BOOL bUnderLine = !!(m_dwStyles & FDE_TTOSTYLE_Underline); | 1006 FX_BOOL bUnderLine = !!(m_dwStyles & FDE_TTOSTYLE_Underline); |
| 1006 FX_BOOL bStrikeOut = !!(m_dwStyles & FDE_TTOSTYLE_Strikeout); | 1007 FX_BOOL bStrikeOut = !!(m_dwStyles & FDE_TTOSTYLE_Strikeout); |
| 1007 FX_BOOL bHotKey = !!(m_dwStyles & FDE_TTOSTYLE_HotKey); | 1008 FX_BOOL bHotKey = !!(m_dwStyles & FDE_TTOSTYLE_HotKey); |
| 1008 FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout); | 1009 FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout); |
| 1009 if (!bUnderLine && !bStrikeOut && !bHotKey) { | 1010 if (!bUnderLine && !bStrikeOut && !bHotKey) { |
| 1010 return; | 1011 return; |
| 1011 } | 1012 } |
| 1012 if (pPen == NULL) { | 1013 if (pPen == NULL) { |
| 1013 pPen = new CFDE_Pen; | 1014 pPen = new CFDE_Pen; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1104 return NULL; | 1105 return NULL; |
| 1105 } | 1106 } |
| 1106 return m_pieces.GetPtrAt(index); | 1107 return m_pieces.GetPtrAt(index); |
| 1107 } | 1108 } |
| 1108 void CFDE_TTOLine::RemoveLast(int32_t iCount) { | 1109 void CFDE_TTOLine::RemoveLast(int32_t iCount) { |
| 1109 m_pieces.RemoveLast(iCount); | 1110 m_pieces.RemoveLast(iCount); |
| 1110 } | 1111 } |
| 1111 void CFDE_TTOLine::RemoveAll(FX_BOOL bLeaveMemory) { | 1112 void CFDE_TTOLine::RemoveAll(FX_BOOL bLeaveMemory) { |
| 1112 m_pieces.RemoveAll(bLeaveMemory); | 1113 m_pieces.RemoveAll(bLeaveMemory); |
| 1113 } | 1114 } |
| OLD | NEW |