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 |
11 #include "core/fxcrt/include/fx_coordinates.h" | 11 #include "core/fxcrt/include/fx_coordinates.h" |
12 #include "core/fxcrt/include/fx_system.h" | 12 #include "core/fxcrt/include/fx_system.h" |
13 #include "xfa/fde/fde_brush.h" | 13 #include "xfa/fde/fde_brush.h" |
| 14 #include "xfa/fde/fde_object.h" |
14 #include "xfa/fde/fde_pen.h" | 15 #include "xfa/fde/fde_pen.h" |
15 #include "xfa/fde/fde_renderdevice.h" | 16 #include "xfa/fde/fde_renderdevice.h" |
16 #include "xfa/fgas/crt/fgas_memory.h" | 17 #include "xfa/fgas/crt/fgas_memory.h" |
17 #include "xfa/fgas/crt/fgas_utils.h" | 18 #include "xfa/fgas/crt/fgas_utils.h" |
18 #include "xfa/fgas/layout/fgas_textbreak.h" | 19 #include "xfa/fgas/layout/fgas_textbreak.h" |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
22 struct FDE_TTOPIECE { | 23 struct FDE_TTOPIECE { |
23 public: | 24 public: |
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 } | 944 } |
944 } | 945 } |
945 void CFDE_TextOut::OnDraw(const CFX_RectF& rtClip) { | 946 void CFDE_TextOut::OnDraw(const CFX_RectF& rtClip) { |
946 if (m_pRenderDevice == NULL) { | 947 if (m_pRenderDevice == NULL) { |
947 return; | 948 return; |
948 } | 949 } |
949 int32_t iLines = m_ttoLines.GetSize(); | 950 int32_t iLines = m_ttoLines.GetSize(); |
950 if (iLines < 1) { | 951 if (iLines < 1) { |
951 return; | 952 return; |
952 } | 953 } |
953 IFDE_SolidBrush* pBrush = | 954 IFDE_SolidBrush* pBrush = new CFDE_SolidBrush; |
954 (IFDE_SolidBrush*)IFDE_Brush::Create(FDE_BRUSHTYPE_Solid); | |
955 pBrush->SetColor(m_TxtColor); | 955 pBrush->SetColor(m_TxtColor); |
956 IFDE_Pen* pPen = NULL; | 956 IFDE_Pen* pPen = NULL; |
957 FDE_HDEVICESTATE hDev = m_pRenderDevice->SaveState(); | 957 FDE_HDEVICESTATE hDev = m_pRenderDevice->SaveState(); |
958 if (rtClip.Width() > 0.0f && rtClip.Height() > 0.0f) { | 958 if (rtClip.Width() > 0.0f && rtClip.Height() > 0.0f) { |
959 m_pRenderDevice->SetClipRect(rtClip); | 959 m_pRenderDevice->SetClipRect(rtClip); |
960 } | 960 } |
961 for (int32_t i = 0; i < iLines; i++) { | 961 for (int32_t i = 0; i < iLines; i++) { |
962 CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(i); | 962 CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(i); |
963 int32_t iPieces = pLine->GetSize(); | 963 int32_t iPieces = pLine->GetSize(); |
964 for (int32_t j = 0; j < iPieces; j++) { | 964 for (int32_t j = 0; j < iPieces; j++) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1010 } | 1010 } |
1011 void CFDE_TextOut::DrawLine(const FDE_LPTTOPIECE pPiece, IFDE_Pen*& pPen) { | 1011 void CFDE_TextOut::DrawLine(const FDE_LPTTOPIECE pPiece, IFDE_Pen*& pPen) { |
1012 FX_BOOL bUnderLine = !!(m_dwStyles & FDE_TTOSTYLE_Underline); | 1012 FX_BOOL bUnderLine = !!(m_dwStyles & FDE_TTOSTYLE_Underline); |
1013 FX_BOOL bStrikeOut = !!(m_dwStyles & FDE_TTOSTYLE_Strikeout); | 1013 FX_BOOL bStrikeOut = !!(m_dwStyles & FDE_TTOSTYLE_Strikeout); |
1014 FX_BOOL bHotKey = !!(m_dwStyles & FDE_TTOSTYLE_HotKey); | 1014 FX_BOOL bHotKey = !!(m_dwStyles & FDE_TTOSTYLE_HotKey); |
1015 FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout); | 1015 FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout); |
1016 if (!bUnderLine && !bStrikeOut && !bHotKey) { | 1016 if (!bUnderLine && !bStrikeOut && !bHotKey) { |
1017 return; | 1017 return; |
1018 } | 1018 } |
1019 if (pPen == NULL) { | 1019 if (pPen == NULL) { |
1020 pPen = IFDE_Pen::Create(); | 1020 pPen = new CFDE_Pen; |
1021 pPen->SetColor(m_TxtColor); | 1021 pPen->SetColor(m_TxtColor); |
1022 } | 1022 } |
1023 IFDE_Path* pPath = IFDE_Path::Create(); | 1023 IFDE_Path* pPath = IFDE_Path::Create(); |
1024 int32_t iLineCount = 0; | 1024 int32_t iLineCount = 0; |
1025 CFX_RectF rtText = pPiece->rtPiece; | 1025 CFX_RectF rtText = pPiece->rtPiece; |
1026 CFX_PointF pt1, pt2; | 1026 CFX_PointF pt1, pt2; |
1027 if (bUnderLine) { | 1027 if (bUnderLine) { |
1028 if (bVertical) { | 1028 if (bVertical) { |
1029 pt1.x = rtText.left; | 1029 pt1.x = rtText.left; |
1030 pt1.y = rtText.top; | 1030 pt1.y = rtText.top; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 return NULL; | 1111 return NULL; |
1112 } | 1112 } |
1113 return m_pieces.GetPtrAt(index); | 1113 return m_pieces.GetPtrAt(index); |
1114 } | 1114 } |
1115 void CFDE_TTOLine::RemoveLast(int32_t iCount) { | 1115 void CFDE_TTOLine::RemoveLast(int32_t iCount) { |
1116 m_pieces.RemoveLast(iCount); | 1116 m_pieces.RemoveLast(iCount); |
1117 } | 1117 } |
1118 void CFDE_TTOLine::RemoveAll(FX_BOOL bLeaveMemory) { | 1118 void CFDE_TTOLine::RemoveAll(FX_BOOL bLeaveMemory) { |
1119 m_pieces.RemoveAll(bLeaveMemory); | 1119 m_pieces.RemoveAll(bLeaveMemory); |
1120 } | 1120 } |
OLD | NEW |