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

Side by Side Diff: xfa/fde/tto/fde_textout.cpp

Issue 1896893003: Cleanup FDE interfaces. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 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 | « xfa/fde/tto/fde_textout.h ('k') | xfa/fee/fde_txtedtengine.cpp » ('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 "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/cfde_path.h"
14 #include "xfa/fde/fde_gedevice.h"
13 #include "xfa/fde/fde_object.h" 15 #include "xfa/fde/fde_object.h"
14 #include "xfa/fde/fde_renderdevice.h"
15 #include "xfa/fgas/crt/fgas_memory.h" 16 #include "xfa/fgas/crt/fgas_memory.h"
16 #include "xfa/fgas/crt/fgas_utils.h" 17 #include "xfa/fgas/crt/fgas_utils.h"
17 #include "xfa/fgas/layout/fgas_textbreak.h" 18 #include "xfa/fgas/layout/fgas_textbreak.h"
18 19
19 namespace {
20
21 struct FDE_TTOPIECE {
22 public:
23 int32_t iStartChar;
24 int32_t iChars;
25 uint32_t dwCharStyles;
26 CFX_RectF rtPiece;
27 };
28 typedef FDE_TTOPIECE* FDE_LPTTOPIECE;
29 typedef CFX_MassArrayTemplate<FDE_TTOPIECE> CFDE_TTOPieceArray;
30
31 class CFDE_TTOLine : public CFX_Target {
32 public:
33 CFDE_TTOLine();
34 CFDE_TTOLine(const CFDE_TTOLine& ttoLine);
35 ~CFDE_TTOLine();
36 int32_t AddPiece(int32_t index, const FDE_TTOPIECE& ttoPiece);
37 int32_t GetSize() const;
38 FDE_LPTTOPIECE GetPtrAt(int32_t index);
39 void RemoveLast(int32_t iCount);
40 void RemoveAll(FX_BOOL bLeaveMemory);
41 FX_BOOL m_bNewReload;
42 CFDE_TTOPieceArray m_pieces;
43
44 protected:
45 int32_t m_iPieceCount;
46 };
47 typedef CFX_ObjectMassArrayTemplate<CFDE_TTOLine> CFDE_TTOLineArray;
48
49 class CFDE_TextOut : public IFDE_TextOut, public CFX_Target {
50 public:
51 CFDE_TextOut();
52 ~CFDE_TextOut();
53 virtual void Release() { delete this; }
54 virtual void SetFont(IFX_Font* pFont);
55 virtual void SetFontSize(FX_FLOAT fFontSize);
56 virtual void SetTextColor(FX_ARGB color);
57 virtual void SetStyles(uint32_t dwStyles);
58 virtual void SetTabWidth(FX_FLOAT fTabWidth);
59 virtual void SetEllipsisString(const CFX_WideString& wsEllipsis);
60 virtual void SetParagraphBreakChar(FX_WCHAR wch);
61 virtual void SetAlignment(int32_t iAlignment);
62 virtual void SetLineSpace(FX_FLOAT fLineSpace);
63 virtual void SetDIBitmap(CFX_DIBitmap* pDIB);
64 virtual void SetRenderDevice(CFX_RenderDevice* pDevice);
65 virtual void SetClipRect(const CFX_Rect& rtClip);
66 virtual void SetClipRect(const CFX_RectF& rtClip);
67 virtual void SetMatrix(const CFX_Matrix& matrix);
68 virtual void SetLineBreakTolerance(FX_FLOAT fTolerance);
69 virtual void CalcSize(const FX_WCHAR* pwsStr,
70 int32_t iLength,
71 CFX_Size& size);
72 virtual void CalcSize(const FX_WCHAR* pwsStr,
73 int32_t iLength,
74 CFX_SizeF& size);
75 virtual void CalcSize(const FX_WCHAR* pwsStr,
76 int32_t iLength,
77 CFX_Rect& rect);
78 virtual void CalcSize(const FX_WCHAR* pwsStr,
79 int32_t iLength,
80 CFX_RectF& rect);
81
82 virtual void DrawText(const FX_WCHAR* pwsStr,
83 int32_t iLength,
84 int32_t x,
85 int32_t y);
86 virtual void DrawText(const FX_WCHAR* pwsStr,
87 int32_t iLength,
88 FX_FLOAT x,
89 FX_FLOAT y);
90 virtual void DrawText(const FX_WCHAR* pwsStr,
91 int32_t iLength,
92 const CFX_Rect& rect);
93 virtual void DrawText(const FX_WCHAR* pwsStr,
94 int32_t iLength,
95 const CFX_RectF& rect);
96
97 virtual void SetLogicClipRect(const CFX_RectF& rtClip);
98 virtual void CalcLogicSize(const FX_WCHAR* pwsStr,
99 int32_t iLength,
100 CFX_SizeF& size);
101 virtual void CalcLogicSize(const FX_WCHAR* pwsStr,
102 int32_t iLength,
103 CFX_RectF& rect);
104 virtual void DrawLogicText(const FX_WCHAR* pwsStr,
105 int32_t iLength,
106 FX_FLOAT x,
107 FX_FLOAT y);
108 virtual void DrawLogicText(const FX_WCHAR* pwsStr,
109 int32_t iLength,
110 const CFX_RectF& rect);
111 virtual int32_t GetTotalLines();
112
113 protected:
114 void CalcTextSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_RectF& rect);
115 FX_BOOL RetrieveLineWidth(uint32_t dwBreakStatus,
116 FX_FLOAT& fStartPos,
117 FX_FLOAT& fWidth,
118 FX_FLOAT& fHeight);
119 void SetLineWidth(CFX_RectF& rect);
120 void DrawText(const FX_WCHAR* pwsStr,
121 int32_t iLength,
122 const CFX_RectF& rect,
123 const CFX_RectF& rtClip);
124 void LoadText(const FX_WCHAR* pwsStr, int32_t iLength, const CFX_RectF& rect);
125 void LoadEllipsis();
126 void ExpandBuffer(int32_t iSize, int32_t iType);
127 void RetrieveEllPieces(int32_t*& pCharWidths);
128
129 void Reload(const CFX_RectF& rect);
130 void ReloadLinePiece(CFDE_TTOLine* pLine, const CFX_RectF& rect);
131 FX_BOOL RetriecePieces(uint32_t dwBreakStatus,
132 int32_t& iStartChar,
133 int32_t& iPieceWidths,
134 FX_BOOL bReload,
135 const CFX_RectF& rect);
136 void AppendPiece(const FDE_TTOPIECE& ttoPiece,
137 FX_BOOL bNeedReload,
138 FX_BOOL bEnd);
139 void ReplaceWidthEllipsis();
140 void DoAlignment(const CFX_RectF& rect);
141 void OnDraw(const CFX_RectF& rtClip);
142 int32_t GetDisplayPos(FDE_LPTTOPIECE pPiece);
143 int32_t GetCharRects(FDE_LPTTOPIECE pPiece);
144
145 FX_TXTRUN ToTextRun(const FDE_LPTTOPIECE pPiece);
146 void DrawLine(const FDE_LPTTOPIECE pPiece, CFDE_Pen*& pPen);
147
148 CFX_TxtBreak* m_pTxtBreak;
149 IFX_Font* m_pFont;
150 FX_FLOAT m_fFontSize;
151 FX_FLOAT m_fLineSpace;
152 FX_FLOAT m_fLinePos;
153 FX_FLOAT m_fTolerance;
154 int32_t m_iAlignment;
155 int32_t m_iTxtBkAlignment;
156 int32_t* m_pCharWidths;
157 int32_t m_iChars;
158 int32_t* m_pEllCharWidths;
159 int32_t m_iEllChars;
160 FX_WCHAR m_wParagraphBkChar;
161 FX_ARGB m_TxtColor;
162 uint32_t m_dwStyles;
163 uint32_t m_dwTxtBkStyles;
164 CFX_WideString m_wsEllipsis;
165 FX_BOOL m_bElliChanged;
166 int32_t m_iEllipsisWidth;
167 CFX_WideString m_wsText;
168 CFX_RectF m_rtClip;
169 CFX_RectF m_rtLogicClip;
170 CFX_Matrix m_Matrix;
171 CFDE_TTOLineArray m_ttoLines;
172 int32_t m_iCurLine;
173 int32_t m_iCurPiece;
174 int32_t m_iTotalLines;
175 FXTEXT_CHARPOS* m_pCharPos;
176 int32_t m_iCharPosSize;
177 IFDE_RenderDevice* m_pRenderDevice;
178 CFX_Int32Array m_hotKeys;
179 CFX_RectFArray m_rectArray;
180 };
181
182 } // namespace
183
184 IFDE_TextOut* IFDE_TextOut::Create() {
185 return new CFDE_TextOut;
186 }
187 CFDE_TextOut::CFDE_TextOut() 20 CFDE_TextOut::CFDE_TextOut()
188 : m_pFont(NULL), 21 : m_pFont(NULL),
189 m_fFontSize(12.0f), 22 m_fFontSize(12.0f),
190 m_fLineSpace(m_fFontSize), 23 m_fLineSpace(m_fFontSize),
191 m_fLinePos(0.0f), 24 m_fLinePos(0.0f),
192 m_fTolerance(0.0f), 25 m_fTolerance(0.0f),
193 m_iAlignment(0), 26 m_iAlignment(0),
194 m_iTxtBkAlignment(0), 27 m_iTxtBkAlignment(0),
195 m_pCharWidths(NULL), 28 m_pCharWidths(NULL),
196 m_iChars(0), 29 m_iChars(0),
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 m_iTxtBkAlignment = FX_TXTLINEALIGNMENT_Left; 125 m_iTxtBkAlignment = FX_TXTLINEALIGNMENT_Left;
293 break; 126 break;
294 } 127 }
295 m_pTxtBreak->SetAlignment(m_iTxtBkAlignment); 128 m_pTxtBreak->SetAlignment(m_iTxtBkAlignment);
296 } 129 }
297 void CFDE_TextOut::SetLineSpace(FX_FLOAT fLineSpace) { 130 void CFDE_TextOut::SetLineSpace(FX_FLOAT fLineSpace) {
298 FXSYS_assert(fLineSpace > 1.0f); 131 FXSYS_assert(fLineSpace > 1.0f);
299 m_fLineSpace = fLineSpace; 132 m_fLineSpace = fLineSpace;
300 } 133 }
301 void CFDE_TextOut::SetDIBitmap(CFX_DIBitmap* pDIB) { 134 void CFDE_TextOut::SetDIBitmap(CFX_DIBitmap* pDIB) {
302 FXSYS_assert(pDIB != NULL); 135 FXSYS_assert(pDIB);
303 if (m_pRenderDevice != NULL) { 136
137 if (m_pRenderDevice)
304 m_pRenderDevice->Release(); 138 m_pRenderDevice->Release();
305 } 139
306 m_pRenderDevice = IFDE_RenderDevice::Create(pDIB); 140 CFX_FxgeDevice* device = new CFX_FxgeDevice;
141 device->Attach(pDIB, 0, FALSE);
142 m_pRenderDevice = new CFDE_RenderDevice(device, FALSE);
307 } 143 }
144
308 void CFDE_TextOut::SetRenderDevice(CFX_RenderDevice* pDevice) { 145 void CFDE_TextOut::SetRenderDevice(CFX_RenderDevice* pDevice) {
309 FXSYS_assert(pDevice != NULL); 146 FXSYS_assert(pDevice);
310 if (m_pRenderDevice != NULL) { 147
148 if (m_pRenderDevice)
311 m_pRenderDevice->Release(); 149 m_pRenderDevice->Release();
312 } 150
313 m_pRenderDevice = IFDE_RenderDevice::Create(pDevice); 151 m_pRenderDevice = new CFDE_RenderDevice(pDevice, FALSE);
314 } 152 }
153
315 void CFDE_TextOut::SetClipRect(const CFX_Rect& rtClip) { 154 void CFDE_TextOut::SetClipRect(const CFX_Rect& rtClip) {
316 m_rtClip.Set((FX_FLOAT)rtClip.left, (FX_FLOAT)rtClip.top, 155 m_rtClip.Set((FX_FLOAT)rtClip.left, (FX_FLOAT)rtClip.top,
317 (FX_FLOAT)rtClip.Width(), (FX_FLOAT)rtClip.Height()); 156 (FX_FLOAT)rtClip.Width(), (FX_FLOAT)rtClip.Height());
318 } 157 }
319 void CFDE_TextOut::SetClipRect(const CFX_RectF& rtClip) { 158 void CFDE_TextOut::SetClipRect(const CFX_RectF& rtClip) {
320 m_rtClip = rtClip; 159 m_rtClip = rtClip;
321 } 160 }
322 void CFDE_TextOut::SetLogicClipRect(const CFX_RectF& rtClip) { 161 void CFDE_TextOut::SetLogicClipRect(const CFX_RectF& rtClip) {
323 m_rtLogicClip = rtClip; 162 m_rtLogicClip = rtClip;
324 } 163 }
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 for (int32_t i = 0; i < iLines; i++) { 666 for (int32_t i = 0; i < iLines; i++) {
828 CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(i); 667 CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(i);
829 if (!pLine->m_bNewReload) { 668 if (!pLine->m_bNewReload) {
830 continue; 669 continue;
831 } 670 }
832 int32_t iEllipsisCharIndex = iLength - 1; 671 int32_t iEllipsisCharIndex = iLength - 1;
833 int32_t iCharWidth = 0; 672 int32_t iCharWidth = 0;
834 int32_t iCharCount = 0; 673 int32_t iCharCount = 0;
835 int32_t iPiece = pLine->GetSize(); 674 int32_t iPiece = pLine->GetSize();
836 while (iPiece-- > 0) { 675 while (iPiece-- > 0) {
837 FDE_LPTTOPIECE pPiece = pLine->GetPtrAt(iPiece); 676 FDE_TTOPIECE* pPiece = pLine->GetPtrAt(iPiece);
838 if (pPiece == NULL) { 677 if (pPiece == NULL) {
839 break; 678 break;
840 } 679 }
841 for (int32_t j = pPiece->iChars - 1; j >= 0; j--) { 680 for (int32_t j = pPiece->iChars - 1; j >= 0; j--) {
842 if (iEllipsisCharIndex < 0) { 681 if (iEllipsisCharIndex < 0) {
843 break; 682 break;
844 } 683 }
845 int32_t index = pPiece->iStartChar + j; 684 int32_t index = pPiece->iStartChar + j;
846 iCharWidth += m_pCharWidths[index]; 685 iCharWidth += m_pCharWidths[index];
847 iCharCount++; 686 iCharCount++;
(...skipping 21 matching lines...) Expand all
869 } 708 }
870 m_iCurLine = i; 709 m_iCurLine = i;
871 m_iCurPiece = 0; 710 m_iCurPiece = 0;
872 ReloadLinePiece(pLine, rect); 711 ReloadLinePiece(pLine, rect);
873 } 712 }
874 } 713 }
875 void CFDE_TextOut::ReloadLinePiece(CFDE_TTOLine* pLine, const CFX_RectF& rect) { 714 void CFDE_TextOut::ReloadLinePiece(CFDE_TTOLine* pLine, const CFX_RectF& rect) {
876 const FX_WCHAR* pwsStr = m_wsText.c_str(); 715 const FX_WCHAR* pwsStr = m_wsText.c_str();
877 FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout); 716 FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout);
878 int32_t iPieceWidths = 0; 717 int32_t iPieceWidths = 0;
879 FDE_LPTTOPIECE pPiece = pLine->GetPtrAt(0); 718 FDE_TTOPIECE* pPiece = pLine->GetPtrAt(0);
880 int32_t iStartChar = pPiece->iStartChar; 719 int32_t iStartChar = pPiece->iStartChar;
881 m_fLinePos = bVertical ? pPiece->rtPiece.left : pPiece->rtPiece.top; 720 m_fLinePos = bVertical ? pPiece->rtPiece.left : pPiece->rtPiece.top;
882 int32_t iPieceCount = pLine->GetSize(); 721 int32_t iPieceCount = pLine->GetSize();
883 int32_t iPieceIndex = 0; 722 int32_t iPieceIndex = 0;
884 uint32_t dwBreakStatus = 0; 723 uint32_t dwBreakStatus = 0;
885 FX_WCHAR wch; 724 FX_WCHAR wch;
886 while (iPieceIndex < iPieceCount) { 725 while (iPieceIndex < iPieceCount) {
887 int32_t iStar = iStartChar; 726 int32_t iStar = iStartChar;
888 int32_t iEnd = pPiece->iChars + iStar; 727 int32_t iEnd = pPiece->iChars + iStar;
889 while (iStar < iEnd) { 728 while (iStar < iEnd) {
(...skipping 14 matching lines...) Expand all
904 m_pTxtBreak->Reset(); 743 m_pTxtBreak->Reset();
905 } 744 }
906 void CFDE_TextOut::DoAlignment(const CFX_RectF& rect) { 745 void CFDE_TextOut::DoAlignment(const CFX_RectF& rect) {
907 FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout); 746 FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout);
908 FX_FLOAT fLineStopS = bVertical ? rect.right() : rect.bottom(); 747 FX_FLOAT fLineStopS = bVertical ? rect.right() : rect.bottom();
909 int32_t iLines = m_ttoLines.GetSize(); 748 int32_t iLines = m_ttoLines.GetSize();
910 if (iLines < 1) { 749 if (iLines < 1) {
911 return; 750 return;
912 } 751 }
913 CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(iLines - 1); 752 CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(iLines - 1);
914 FDE_LPTTOPIECE pPiece = pLine->GetPtrAt(0); 753 FDE_TTOPIECE* pPiece = pLine->GetPtrAt(0);
915 if (pPiece == NULL) { 754 if (pPiece == NULL) {
916 return; 755 return;
917 } 756 }
918 FX_FLOAT fLineStopD = 757 FX_FLOAT fLineStopD =
919 bVertical ? pPiece->rtPiece.right() : pPiece->rtPiece.bottom(); 758 bVertical ? pPiece->rtPiece.right() : pPiece->rtPiece.bottom();
920 FX_FLOAT fInc = fLineStopS - fLineStopD; 759 FX_FLOAT fInc = fLineStopS - fLineStopD;
921 if (m_iAlignment >= FDE_TTOALIGNMENT_CenterLeft && 760 if (m_iAlignment >= FDE_TTOALIGNMENT_CenterLeft &&
922 m_iAlignment < FDE_TTOALIGNMENT_BottomLeft) { 761 m_iAlignment < FDE_TTOALIGNMENT_BottomLeft) {
923 fInc /= 2.0f; 762 fInc /= 2.0f;
924 } else if (m_iAlignment < FDE_TTOALIGNMENT_CenterLeft) { 763 } else if (m_iAlignment < FDE_TTOALIGNMENT_CenterLeft) {
925 fInc = 0.0f; 764 fInc = 0.0f;
926 } 765 }
927 if (fInc < 1.0f) { 766 if (fInc < 1.0f) {
928 return; 767 return;
929 } 768 }
930 for (int32_t i = 0; i < iLines; i++) { 769 for (int32_t i = 0; i < iLines; i++) {
931 CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(i); 770 CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(i);
932 int32_t iPieces = pLine->GetSize(); 771 int32_t iPieces = pLine->GetSize();
933 for (int32_t j = 0; j < iPieces; j++) { 772 for (int32_t j = 0; j < iPieces; j++) {
934 FDE_LPTTOPIECE pPiece = pLine->GetPtrAt(j); 773 FDE_TTOPIECE* pPiece = pLine->GetPtrAt(j);
935 if (bVertical) { 774 if (bVertical) {
936 pPiece->rtPiece.left += fInc; 775 pPiece->rtPiece.left += fInc;
937 } else { 776 } else {
938 pPiece->rtPiece.top += fInc; 777 pPiece->rtPiece.top += fInc;
939 } 778 }
940 } 779 }
941 } 780 }
942 } 781 }
943 void CFDE_TextOut::OnDraw(const CFX_RectF& rtClip) { 782 void CFDE_TextOut::OnDraw(const CFX_RectF& rtClip) {
944 if (m_pRenderDevice == NULL) { 783 if (m_pRenderDevice == NULL) {
945 return; 784 return;
946 } 785 }
947 int32_t iLines = m_ttoLines.GetSize(); 786 int32_t iLines = m_ttoLines.GetSize();
948 if (iLines < 1) { 787 if (iLines < 1) {
949 return; 788 return;
950 } 789 }
951 CFDE_Brush* pBrush = new CFDE_Brush; 790 CFDE_Brush* pBrush = new CFDE_Brush;
952 pBrush->SetColor(m_TxtColor); 791 pBrush->SetColor(m_TxtColor);
953 CFDE_Pen* pPen = NULL; 792 CFDE_Pen* pPen = NULL;
954 FDE_HDEVICESTATE hDev = m_pRenderDevice->SaveState(); 793 FDE_HDEVICESTATE hDev = m_pRenderDevice->SaveState();
955 if (rtClip.Width() > 0.0f && rtClip.Height() > 0.0f) { 794 if (rtClip.Width() > 0.0f && rtClip.Height() > 0.0f) {
956 m_pRenderDevice->SetClipRect(rtClip); 795 m_pRenderDevice->SetClipRect(rtClip);
957 } 796 }
958 for (int32_t i = 0; i < iLines; i++) { 797 for (int32_t i = 0; i < iLines; i++) {
959 CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(i); 798 CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(i);
960 int32_t iPieces = pLine->GetSize(); 799 int32_t iPieces = pLine->GetSize();
961 for (int32_t j = 0; j < iPieces; j++) { 800 for (int32_t j = 0; j < iPieces; j++) {
962 FDE_LPTTOPIECE pPiece = pLine->GetPtrAt(j); 801 FDE_TTOPIECE* pPiece = pLine->GetPtrAt(j);
963 if (pPiece == NULL) { 802 if (pPiece == NULL) {
964 continue; 803 continue;
965 } 804 }
966 int32_t iCount = GetDisplayPos(pPiece); 805 int32_t iCount = GetDisplayPos(pPiece);
967 if (iCount > 0) { 806 if (iCount > 0) {
968 m_pRenderDevice->DrawString(pBrush, m_pFont, m_pCharPos, iCount, 807 m_pRenderDevice->DrawString(pBrush, m_pFont, m_pCharPos, iCount,
969 m_fFontSize, &m_Matrix); 808 m_fFontSize, &m_Matrix);
970 } 809 }
971 DrawLine(pPiece, pPen); 810 DrawLine(pPiece, pPen);
972 } 811 }
973 } 812 }
974 m_pRenderDevice->RestoreState(hDev); 813 m_pRenderDevice->RestoreState(hDev);
975 delete pBrush; 814 delete pBrush;
976 delete pPen; 815 delete pPen;
977 } 816 }
978 817
979 int32_t CFDE_TextOut::GetDisplayPos(FDE_LPTTOPIECE pPiece) { 818 int32_t CFDE_TextOut::GetDisplayPos(FDE_TTOPIECE* pPiece) {
980 FX_TXTRUN tr = ToTextRun(pPiece); 819 FX_TXTRUN tr = ToTextRun(pPiece);
981 ExpandBuffer(tr.iLength, 2); 820 ExpandBuffer(tr.iLength, 2);
982 return m_pTxtBreak->GetDisplayPos(&tr, m_pCharPos); 821 return m_pTxtBreak->GetDisplayPos(&tr, m_pCharPos);
983 } 822 }
984 823
985 int32_t CFDE_TextOut::GetCharRects(FDE_LPTTOPIECE pPiece) { 824 int32_t CFDE_TextOut::GetCharRects(const FDE_TTOPIECE* pPiece) {
986 FX_TXTRUN tr = ToTextRun(pPiece); 825 FX_TXTRUN tr = ToTextRun(pPiece);
987 m_rectArray.RemoveAll(); 826 m_rectArray.RemoveAll();
988 return m_pTxtBreak->GetCharRects(&tr, m_rectArray); 827 return m_pTxtBreak->GetCharRects(&tr, m_rectArray);
989 } 828 }
990 829
991 FX_TXTRUN CFDE_TextOut::ToTextRun(const FDE_LPTTOPIECE pPiece) { 830 FX_TXTRUN CFDE_TextOut::ToTextRun(const FDE_TTOPIECE* pPiece) {
992 FX_TXTRUN tr; 831 FX_TXTRUN tr;
993 tr.wsStr = m_wsText + pPiece->iStartChar; 832 tr.wsStr = m_wsText + pPiece->iStartChar;
994 tr.pWidths = m_pCharWidths + pPiece->iStartChar; 833 tr.pWidths = m_pCharWidths + pPiece->iStartChar;
995 tr.iLength = pPiece->iChars; 834 tr.iLength = pPiece->iChars;
996 tr.pFont = m_pFont; 835 tr.pFont = m_pFont;
997 tr.fFontSize = m_fFontSize; 836 tr.fFontSize = m_fFontSize;
998 tr.dwStyles = m_dwTxtBkStyles; 837 tr.dwStyles = m_dwTxtBkStyles;
999 tr.dwCharStyles = pPiece->dwCharStyles; 838 tr.dwCharStyles = pPiece->dwCharStyles;
1000 tr.wLineBreakChar = m_wParagraphBkChar; 839 tr.wLineBreakChar = m_wParagraphBkChar;
1001 tr.pRect = &pPiece->rtPiece; 840 tr.pRect = &pPiece->rtPiece;
1002 return tr; 841 return tr;
1003 } 842 }
1004 843
1005 void CFDE_TextOut::DrawLine(const FDE_LPTTOPIECE pPiece, CFDE_Pen*& pPen) { 844 void CFDE_TextOut::DrawLine(const FDE_TTOPIECE* pPiece, CFDE_Pen*& pPen) {
1006 FX_BOOL bUnderLine = !!(m_dwStyles & FDE_TTOSTYLE_Underline); 845 FX_BOOL bUnderLine = !!(m_dwStyles & FDE_TTOSTYLE_Underline);
1007 FX_BOOL bStrikeOut = !!(m_dwStyles & FDE_TTOSTYLE_Strikeout); 846 FX_BOOL bStrikeOut = !!(m_dwStyles & FDE_TTOSTYLE_Strikeout);
1008 FX_BOOL bHotKey = !!(m_dwStyles & FDE_TTOSTYLE_HotKey); 847 FX_BOOL bHotKey = !!(m_dwStyles & FDE_TTOSTYLE_HotKey);
1009 FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout); 848 FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout);
1010 if (!bUnderLine && !bStrikeOut && !bHotKey) { 849 if (!bUnderLine && !bStrikeOut && !bHotKey) {
1011 return; 850 return;
1012 } 851 }
1013 if (pPen == NULL) { 852 if (pPen == NULL) {
1014 pPen = new CFDE_Pen; 853 pPen = new CFDE_Pen;
1015 pPen->SetColor(m_TxtColor); 854 pPen->SetColor(m_TxtColor);
1016 } 855 }
1017 IFDE_Path* pPath = IFDE_Path::Create(); 856 CFDE_Path* pPath = new CFDE_Path;
1018 int32_t iLineCount = 0; 857 int32_t iLineCount = 0;
1019 CFX_RectF rtText = pPiece->rtPiece; 858 CFX_RectF rtText = pPiece->rtPiece;
1020 CFX_PointF pt1, pt2; 859 CFX_PointF pt1, pt2;
1021 if (bUnderLine) { 860 if (bUnderLine) {
1022 if (bVertical) { 861 if (bVertical) {
1023 pt1.x = rtText.left; 862 pt1.x = rtText.left;
1024 pt1.y = rtText.top; 863 pt1.y = rtText.top;
1025 pt2.x = rtText.left; 864 pt2.x = rtText.left;
1026 pt2.y = rtText.bottom(); 865 pt2.y = rtText.bottom();
1027 } else { 866 } else {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 m_iPieceCount++; 932 m_iPieceCount++;
1094 } else { 933 } else {
1095 FDE_TTOPIECE& piece = m_pieces.GetAt(index); 934 FDE_TTOPIECE& piece = m_pieces.GetAt(index);
1096 piece = ttoPiece; 935 piece = ttoPiece;
1097 } 936 }
1098 return index; 937 return index;
1099 } 938 }
1100 int32_t CFDE_TTOLine::GetSize() const { 939 int32_t CFDE_TTOLine::GetSize() const {
1101 return m_iPieceCount; 940 return m_iPieceCount;
1102 } 941 }
1103 FDE_LPTTOPIECE CFDE_TTOLine::GetPtrAt(int32_t index) { 942 FDE_TTOPIECE* CFDE_TTOLine::GetPtrAt(int32_t index) {
1104 if (index >= m_iPieceCount) { 943 if (index >= m_iPieceCount) {
1105 return NULL; 944 return NULL;
1106 } 945 }
1107 return m_pieces.GetPtrAt(index); 946 return m_pieces.GetPtrAt(index);
1108 } 947 }
1109 void CFDE_TTOLine::RemoveLast(int32_t iCount) { 948 void CFDE_TTOLine::RemoveLast(int32_t iCount) {
1110 m_pieces.RemoveLast(iCount); 949 m_pieces.RemoveLast(iCount);
1111 } 950 }
1112 void CFDE_TTOLine::RemoveAll(FX_BOOL bLeaveMemory) { 951 void CFDE_TTOLine::RemoveAll(FX_BOOL bLeaveMemory) {
1113 m_pieces.RemoveAll(bLeaveMemory); 952 m_pieces.RemoveAll(bLeaveMemory);
1114 } 953 }
OLDNEW
« no previous file with comments | « xfa/fde/tto/fde_textout.h ('k') | xfa/fee/fde_txtedtengine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698