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 "../../include/fxedit/fxet_stub.h" | 7 #include "../../include/fxedit/fxet_stub.h" |
8 #include "../../include/fxedit/fx_edit.h" | 8 #include "../../include/fxedit/fx_edit.h" |
9 #include "../../include/fxedit/fxet_edit.h" | 9 #include "../../include/fxedit/fxet_edit.h" |
10 | 10 |
11 #define FX_EDIT_UNDERLINEHALFWIDTH 0.5f | 11 #define FX_EDIT_UNDERLINEHALFWIDTH 0.5f |
12 #define FX_EDIT_CROSSOUTHALFWIDTH 0.5f | 12 #define FX_EDIT_CROSSOUTHALFWIDTH 0.5f |
13 | 13 |
14 extern CFX_ByteString GetPDFWordString(IFX_Edit_FontMap * pFontMap, int32_t nFon
tIndex, FX_WORD Word, FX_WORD SubWord); | 14 extern CFX_ByteString GetPDFWordString(IFX_Edit_FontMap* pFontMap, |
15 | 15 int32_t nFontIndex, |
16 CPDF_Rect GetUnderLineRect(const CPVT_Word& word) | 16 FX_WORD Word, |
17 { | 17 FX_WORD SubWord); |
18 return CPDF_Rect(word.ptWord.x, word.ptWord.y + word.fDescent * 0.5f, | 18 |
19 word.ptWord.x + word.fWidth, wor
d.ptWord.y + word.fDescent * 0.25f); | 19 CPDF_Rect GetUnderLineRect(const CPVT_Word& word) { |
20 } | 20 return CPDF_Rect(word.ptWord.x, word.ptWord.y + word.fDescent * 0.5f, |
21 | 21 word.ptWord.x + word.fWidth, |
22 CPDF_Rect GetCrossoutRect(const CPVT_Word& word) | 22 word.ptWord.y + word.fDescent * 0.25f); |
23 { | 23 } |
24 return CPDF_Rect(word.ptWord.x, word.ptWord.y + (word.fAscent + word.fDe
scent) * 0.5f + word.fDescent * 0.25f, | 24 |
25 word.ptWord.x + word.fWi
dth, word.ptWord.y + (word.fAscent + word.fDescent) * 0.5f); | 25 CPDF_Rect GetCrossoutRect(const CPVT_Word& word) { |
26 } | 26 return CPDF_Rect(word.ptWord.x, |
27 | 27 word.ptWord.y + (word.fAscent + word.fDescent) * 0.5f + |
28 static void DrawTextString(CFX_RenderDevice* pDevice, const CPDF_Point& pt, CPDF
_Font* pFont, FX_FLOAT fFontSize, CPDF_Matrix* pUser2Device, | 28 word.fDescent * 0.25f, |
29 const CFX_ByteString& str, FX_ARGB crT
extFill, FX_ARGB crTextStroke, int32_t nHorzScale) | 29 word.ptWord.x + word.fWidth, |
30 { | 30 word.ptWord.y + (word.fAscent + word.fDescent) * 0.5f); |
31 FX_FLOAT x = pt.x, y = pt.y; | 31 } |
32 pUser2Device->Transform(x, y); | 32 |
33 | 33 static void DrawTextString(CFX_RenderDevice* pDevice, |
34 if (pFont) | 34 const CPDF_Point& pt, |
35 { | 35 CPDF_Font* pFont, |
36 if (nHorzScale != 100) | 36 FX_FLOAT fFontSize, |
37 { | 37 CPDF_Matrix* pUser2Device, |
38 CPDF_Matrix mt(nHorzScale/100.0f,0,0,1,0,0); | 38 const CFX_ByteString& str, |
39 mt.Concat(*pUser2Device); | 39 FX_ARGB crTextFill, |
40 | 40 FX_ARGB crTextStroke, |
41 CPDF_RenderOptions ro; | 41 int32_t nHorzScale) { |
42 ro.m_Flags = RENDER_CLEARTYPE; | 42 FX_FLOAT x = pt.x, y = pt.y; |
43 ro.m_ColorMode = RENDER_COLOR_NORMAL; | 43 pUser2Device->Transform(x, y); |
44 | 44 |
45 if (crTextStroke != 0) | 45 if (pFont) { |
46 { | 46 if (nHorzScale != 100) { |
47 CPDF_Point pt1(0,0), pt2(1,0); | 47 CPDF_Matrix mt(nHorzScale / 100.0f, 0, 0, 1, 0, 0); |
48 pUser2Device->Transform(pt1.x, pt1.y); | 48 mt.Concat(*pUser2Device); |
49 pUser2Device->Transform(pt2.x, pt2.y); | 49 |
50 CFX_GraphStateData gsd; | 50 CPDF_RenderOptions ro; |
51 gsd.m_LineWidth = (FX_FLOAT)FXSYS_fabs((pt2.x +
pt2.y) - (pt1.x + pt1.y)); | 51 ro.m_Flags = RENDER_CLEARTYPE; |
52 | 52 ro.m_ColorMode = RENDER_COLOR_NORMAL; |
53 CPDF_TextRenderer::DrawTextString(pDevice,x, y,
pFont, fFontSize, &mt, str, crTextFill, crTextStroke, &gsd, &ro); | 53 |
54 } | 54 if (crTextStroke != 0) { |
55 else | 55 CPDF_Point pt1(0, 0), pt2(1, 0); |
56 CPDF_TextRenderer::DrawTextString(pDevice,x, y,
pFont, fFontSize, &mt, str, crTextFill, 0, NULL, &ro); | 56 pUser2Device->Transform(pt1.x, pt1.y); |
57 } | 57 pUser2Device->Transform(pt2.x, pt2.y); |
58 else | 58 CFX_GraphStateData gsd; |
59 { | 59 gsd.m_LineWidth = |
60 CPDF_RenderOptions ro; | 60 (FX_FLOAT)FXSYS_fabs((pt2.x + pt2.y) - (pt1.x + pt1.y)); |
61 ro.m_Flags = RENDER_CLEARTYPE; | 61 |
62 ro.m_ColorMode = RENDER_COLOR_NORMAL; | 62 CPDF_TextRenderer::DrawTextString(pDevice, x, y, pFont, fFontSize, &mt, |
63 | 63 str, crTextFill, crTextStroke, &gsd, |
64 if (crTextStroke != 0) | 64 &ro); |
65 { | 65 } else |
66 CPDF_Point pt1(0,0), pt2(1,0); | 66 CPDF_TextRenderer::DrawTextString(pDevice, x, y, pFont, fFontSize, &mt, |
67 pUser2Device->Transform(pt1.x, pt1.y); | 67 str, crTextFill, 0, NULL, &ro); |
68 pUser2Device->Transform(pt2.x, pt2.y); | 68 } else { |
69 CFX_GraphStateData gsd; | 69 CPDF_RenderOptions ro; |
70 gsd.m_LineWidth = (FX_FLOAT)FXSYS_fabs((pt2.x +
pt2.y) - (pt1.x + pt1.y)); | 70 ro.m_Flags = RENDER_CLEARTYPE; |
71 | 71 ro.m_ColorMode = RENDER_COLOR_NORMAL; |
72 CPDF_TextRenderer::DrawTextString(pDevice,x, y,
pFont, fFontSize, pUser2Device, str, crTextFill, crTextStroke, &gsd, &ro); | 72 |
73 } | 73 if (crTextStroke != 0) { |
74 else | 74 CPDF_Point pt1(0, 0), pt2(1, 0); |
75 CPDF_TextRenderer::DrawTextString(pDevice,x, y,
pFont, fFontSize, pUser2Device, str, crTextFill, 0, NULL, &ro); | 75 pUser2Device->Transform(pt1.x, pt1.y); |
76 } | 76 pUser2Device->Transform(pt2.x, pt2.y); |
77 } | 77 CFX_GraphStateData gsd; |
78 } | 78 gsd.m_LineWidth = |
79 | 79 (FX_FLOAT)FXSYS_fabs((pt2.x + pt2.y) - (pt1.x + pt1.y)); |
80 void IFX_Edit::DrawUnderline(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Devic
e, IFX_Edit* pEdit, FX_COLORREF color, | 80 |
81 const CPDF_Rect&
rcClip, const CPDF_Point& ptOffset, const CPVT_WordRange* pRange) | 81 CPDF_TextRenderer::DrawTextString(pDevice, x, y, pFont, fFontSize, |
82 { | 82 pUser2Device, str, crTextFill, |
83 pDevice->SaveState(); | 83 crTextStroke, &gsd, &ro); |
84 | 84 } else |
85 if (!rcClip.IsEmpty()) | 85 CPDF_TextRenderer::DrawTextString(pDevice, x, y, pFont, fFontSize, |
86 { | 86 pUser2Device, str, crTextFill, 0, |
87 CPDF_Rect rcTemp = rcClip; | 87 NULL, &ro); |
88 pUser2Device->TransformRect(rcTemp); | 88 } |
89 FX_RECT rcDevClip; | 89 } |
90 rcDevClip.left = (int32_t)rcTemp.left; | 90 } |
91 rcDevClip.right = (int32_t)rcTemp.right; | 91 |
92 rcDevClip.top = (int32_t)rcTemp.top; | 92 void IFX_Edit::DrawUnderline(CFX_RenderDevice* pDevice, |
93 rcDevClip.bottom = (int32_t)rcTemp.bottom; | 93 CPDF_Matrix* pUser2Device, |
94 pDevice->SetClip_Rect(&rcDevClip); | 94 IFX_Edit* pEdit, |
95 } | 95 FX_COLORREF color, |
96 | 96 const CPDF_Rect& rcClip, |
97 if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) | 97 const CPDF_Point& ptOffset, |
98 { | 98 const CPVT_WordRange* pRange) { |
99 if (pEdit->GetFontMap()) | 99 pDevice->SaveState(); |
100 { | 100 |
101 if (pRange) | 101 if (!rcClip.IsEmpty()) { |
102 pIterator->SetAt(pRange->BeginPos); | 102 CPDF_Rect rcTemp = rcClip; |
103 else | 103 pUser2Device->TransformRect(rcTemp); |
104 pIterator->SetAt(0); | 104 FX_RECT rcDevClip; |
105 | 105 rcDevClip.left = (int32_t)rcTemp.left; |
106 while (pIterator->NextWord()) | 106 rcDevClip.right = (int32_t)rcTemp.right; |
107 { | 107 rcDevClip.top = (int32_t)rcTemp.top; |
108 CPVT_WordPlace place = pIterator->GetAt(); | 108 rcDevClip.bottom = (int32_t)rcTemp.bottom; |
109 if (pRange && place.WordCmp(pRange->EndPos) > 0)
break; | 109 pDevice->SetClip_Rect(&rcDevClip); |
110 | 110 } |
111 CPVT_Word word; | 111 |
112 if (pIterator->GetWord(word)) | 112 if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) { |
113 { | 113 if (pEdit->GetFontMap()) { |
114 CFX_PathData pathUnderline; | 114 if (pRange) |
115 CPDF_Rect rcUnderline = GetUnderLineRect
(word); | 115 pIterator->SetAt(pRange->BeginPos); |
116 rcUnderline.left += ptOffset.x; | 116 else |
117 rcUnderline.right += ptOffset.x; | 117 pIterator->SetAt(0); |
118 rcUnderline.top += ptOffset.y; | 118 |
119 rcUnderline.bottom += ptOffset.y; | 119 while (pIterator->NextWord()) { |
120 pathUnderline.AppendRect(rcUnderline.lef
t, rcUnderline.bottom, rcUnderline.right, rcUnderline.top); | 120 CPVT_WordPlace place = pIterator->GetAt(); |
121 | 121 if (pRange && place.WordCmp(pRange->EndPos) > 0) |
122 pDevice->DrawPath(&pathUnderline, pUser2
Device, NULL, color, 0, FXFILL_WINDING); | 122 break; |
123 } | 123 |
124 } | 124 CPVT_Word word; |
125 } | 125 if (pIterator->GetWord(word)) { |
126 } | 126 CFX_PathData pathUnderline; |
127 | 127 CPDF_Rect rcUnderline = GetUnderLineRect(word); |
128 pDevice->RestoreState(); | 128 rcUnderline.left += ptOffset.x; |
129 } | 129 rcUnderline.right += ptOffset.x; |
130 | 130 rcUnderline.top += ptOffset.y; |
131 void IFX_Edit::DrawEdit(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, IF
X_Edit* pEdit, FX_COLORREF crTextFill, FX_COLORREF crTextStroke, | 131 rcUnderline.bottom += ptOffset.y; |
132 const CPDF_Rect& rcClip, const C
PDF_Point& ptOffset, const CPVT_WordRange* pRange, IFX_SystemHandler* pSystemHan
dler, void* pFFLData) | 132 pathUnderline.AppendRect(rcUnderline.left, rcUnderline.bottom, |
133 { | 133 rcUnderline.right, rcUnderline.top); |
134 | 134 |
135 FX_BOOL bContinuous = pEdit->GetCharArray() == 0; | 135 pDevice->DrawPath(&pathUnderline, pUser2Device, NULL, color, 0, |
136 if (pEdit->GetCharSpace() > 0.0f) | 136 FXFILL_WINDING); |
137 bContinuous = FALSE; | 137 } |
138 | 138 } |
139 FX_WORD SubWord = pEdit->GetPasswordChar(); | 139 } |
140 FX_FLOAT fFontSize = pEdit->GetFontSize(); | 140 } |
141 CPVT_WordRange wrSelect = pEdit->GetSelectWordRange(); | 141 |
142 int32_t nHorzScale = pEdit->GetHorzScale(); | 142 pDevice->RestoreState(); |
143 | 143 } |
144 FX_COLORREF crCurFill = crTextFill; | 144 |
145 FX_COLORREF crOldFill = crCurFill; | 145 void IFX_Edit::DrawEdit(CFX_RenderDevice* pDevice, |
146 | 146 CPDF_Matrix* pUser2Device, |
147 FX_BOOL bSelect = FALSE; | 147 IFX_Edit* pEdit, |
148 const FX_COLORREF crWhite = ArgbEncode(255,255,255,255); | 148 FX_COLORREF crTextFill, |
149 const FX_COLORREF crSelBK = ArgbEncode(255,0,51,113); | 149 FX_COLORREF crTextStroke, |
150 | 150 const CPDF_Rect& rcClip, |
151 CFX_ByteTextBuf sTextBuf; | 151 const CPDF_Point& ptOffset, |
152 int32_t nFontIndex = -1; | 152 const CPVT_WordRange* pRange, |
153 CPDF_Point ptBT(0.0f,0.0f); | 153 IFX_SystemHandler* pSystemHandler, |
154 | 154 void* pFFLData) { |
155 pDevice->SaveState(); | 155 FX_BOOL bContinuous = pEdit->GetCharArray() == 0; |
156 | 156 if (pEdit->GetCharSpace() > 0.0f) |
157 if (!rcClip.IsEmpty()) | 157 bContinuous = FALSE; |
158 { | 158 |
159 CPDF_Rect rcTemp = rcClip; | 159 FX_WORD SubWord = pEdit->GetPasswordChar(); |
160 pUser2Device->TransformRect(rcTemp); | 160 FX_FLOAT fFontSize = pEdit->GetFontSize(); |
161 FX_RECT rcDevClip; | 161 CPVT_WordRange wrSelect = pEdit->GetSelectWordRange(); |
162 rcDevClip.left = (int32_t)rcTemp.left; | 162 int32_t nHorzScale = pEdit->GetHorzScale(); |
163 rcDevClip.right = (int32_t)rcTemp.right; | 163 |
164 rcDevClip.top = (int32_t)rcTemp.top; | 164 FX_COLORREF crCurFill = crTextFill; |
165 rcDevClip.bottom = (int32_t)rcTemp.bottom; | 165 FX_COLORREF crOldFill = crCurFill; |
166 pDevice->SetClip_Rect(&rcDevClip); | 166 |
167 } | 167 FX_BOOL bSelect = FALSE; |
168 | 168 const FX_COLORREF crWhite = ArgbEncode(255, 255, 255, 255); |
169 if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) | 169 const FX_COLORREF crSelBK = ArgbEncode(255, 0, 51, 113); |
170 { | 170 |
171 if (IFX_Edit_FontMap* pFontMap = pEdit->GetFontMap()) | 171 CFX_ByteTextBuf sTextBuf; |
172 { | 172 int32_t nFontIndex = -1; |
173 if (pRange) | 173 CPDF_Point ptBT(0.0f, 0.0f); |
174 pIterator->SetAt(pRange->BeginPos); | 174 |
175 else | 175 pDevice->SaveState(); |
176 pIterator->SetAt(0); | 176 |
177 | 177 if (!rcClip.IsEmpty()) { |
178 CPVT_WordPlace oldplace; | 178 CPDF_Rect rcTemp = rcClip; |
179 | 179 pUser2Device->TransformRect(rcTemp); |
180 while (pIterator->NextWord()) | 180 FX_RECT rcDevClip; |
181 { | 181 rcDevClip.left = (int32_t)rcTemp.left; |
182 CPVT_WordPlace place = pIterator->GetAt(); | 182 rcDevClip.right = (int32_t)rcTemp.right; |
183 if (pRange && place.WordCmp(pRange->EndPos) > 0)
break; | 183 rcDevClip.top = (int32_t)rcTemp.top; |
184 | 184 rcDevClip.bottom = (int32_t)rcTemp.bottom; |
185 if (wrSelect.IsExist()) | 185 pDevice->SetClip_Rect(&rcDevClip); |
186 { | 186 } |
187 bSelect = place.WordCmp(wrSelect.BeginPo
s) > 0 && place.WordCmp(wrSelect.EndPos) <= 0; | 187 |
188 if (bSelect) | 188 if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) { |
189 { | 189 if (IFX_Edit_FontMap* pFontMap = pEdit->GetFontMap()) { |
190 crCurFill = crWhite; | 190 if (pRange) |
191 } | 191 pIterator->SetAt(pRange->BeginPos); |
192 else | 192 else |
193 { | 193 pIterator->SetAt(0); |
194 crCurFill = crTextFill; | 194 |
195 } | 195 CPVT_WordPlace oldplace; |
196 } | 196 |
197 if(pSystemHandler && pSystemHandler->IsSelection
Implemented()) | 197 while (pIterator->NextWord()) { |
198 { | 198 CPVT_WordPlace place = pIterator->GetAt(); |
199 crCurFill = crTextFill; | 199 if (pRange && place.WordCmp(pRange->EndPos) > 0) |
200 crOldFill = crCurFill; | 200 break; |
201 } | 201 |
202 CPVT_Word word; | 202 if (wrSelect.IsExist()) { |
203 if (pIterator->GetWord(word)) | 203 bSelect = place.WordCmp(wrSelect.BeginPos) > 0 && |
204 { | 204 place.WordCmp(wrSelect.EndPos) <= 0; |
205 | 205 if (bSelect) { |
206 if (bSelect) | 206 crCurFill = crWhite; |
207 { | 207 } else { |
208 | 208 crCurFill = crTextFill; |
209 CPVT_Line line; | 209 } |
210 pIterator->GetLine(line); | 210 } |
211 | 211 if (pSystemHandler && pSystemHandler->IsSelectionImplemented()) { |
212 if(pSystemHandler && pSystemHand
ler->IsSelectionImplemented()) | 212 crCurFill = crTextFill; |
213 { | 213 crOldFill = crCurFill; |
214 CPDF_Rect rc(word.ptWord
.x,line.ptLine.y + line.fLineDescent, | 214 } |
215 word.ptWord.x+wo
rd.fWidth,line.ptLine.y + line.fLineAscent); | 215 CPVT_Word word; |
216 rc.Intersect(rcClip); | 216 if (pIterator->GetWord(word)) { |
217 //CFX_Edit* pEt = (CFX_E
dit*)pEdit; | 217 if (bSelect) { |
218 //CPDF_Rect rcEdit = pEt
->VTToEdit(rc); | 218 CPVT_Line line; |
219 pSystemHandler->OutputSe
lectedRect(pFFLData,rc); | 219 pIterator->GetLine(line); |
220 } | 220 |
221 else | 221 if (pSystemHandler && pSystemHandler->IsSelectionImplemented()) { |
222 { | 222 CPDF_Rect rc(word.ptWord.x, line.ptLine.y + line.fLineDescent, |
223 CFX_PathData pathSelBK; | 223 word.ptWord.x + word.fWidth, |
224 pathSelBK.AppendRect(wor
d.ptWord.x,line.ptLine.y + line.fLineDescent, | 224 line.ptLine.y + line.fLineAscent); |
225 word.ptWord.x+wo
rd.fWidth,line.ptLine.y + line.fLineAscent); | 225 rc.Intersect(rcClip); |
226 | 226 // CFX_Edit* pEt = (CFX_Edit*)pEdit; |
227 pDevice->DrawPath(&pathS
elBK, pUser2Device, NULL, crSelBK, 0, FXFILL_WINDING); | 227 // CPDF_Rect rcEdit = pEt->VTToEdit(rc); |
228 } | 228 pSystemHandler->OutputSelectedRect(pFFLData, rc); |
229 } | 229 } else { |
230 | 230 CFX_PathData pathSelBK; |
231 if (bContinuous) | 231 pathSelBK.AppendRect(word.ptWord.x, |
232 { | 232 line.ptLine.y + line.fLineDescent, |
233 if (place.LineCmp(oldplace) != 0
|| word.nFontIndex != nFontIndex || | 233 word.ptWord.x + word.fWidth, |
234 crOldFill != crCurFill) | 234 line.ptLine.y + line.fLineAscent); |
235 { | 235 |
236 if (sTextBuf.GetLength()
> 0) | 236 pDevice->DrawPath(&pathSelBK, pUser2Device, NULL, crSelBK, 0, |
237 { | 237 FXFILL_WINDING); |
238 DrawTextString(p
Device, CPDF_Point(ptBT.x+ptOffset.x, ptBT.y+ptOffset.y), pFontMap->GetPDFFont(n
FontIndex), | 238 } |
239 fFontSiz
e, pUser2Device, sTextBuf.GetByteString(), crOldFill, crTextStroke, nHorzScale); | 239 } |
240 | 240 |
241 sTextBuf.Clear()
; | 241 if (bContinuous) { |
242 } | 242 if (place.LineCmp(oldplace) != 0 || word.nFontIndex != nFontIndex || |
243 nFontIndex = word.nFontI
ndex; | 243 crOldFill != crCurFill) { |
244 ptBT = word.ptWord; | 244 if (sTextBuf.GetLength() > 0) { |
245 crOldFill = crCurFill; | 245 DrawTextString(pDevice, CPDF_Point(ptBT.x + ptOffset.x, |
246 } | 246 ptBT.y + ptOffset.y), |
247 | 247 pFontMap->GetPDFFont(nFontIndex), fFontSize, |
248 sTextBuf << GetPDFWordString(pFo
ntMap, word.nFontIndex, word.Word, SubWord); | 248 pUser2Device, sTextBuf.GetByteString(), |
249 } | 249 crOldFill, crTextStroke, nHorzScale); |
250 else | 250 |
251 { | 251 sTextBuf.Clear(); |
252 DrawTextString(pDevice,CPDF_Poin
t(word.ptWord.x+ptOffset.x, word.ptWord.y+ptOffset.y), pFontMap->GetPDFFont(word
.nFontIndex), | 252 } |
253 fFontSize, pUser2Device,
GetPDFWordString(pFontMap, word.nFontIndex, word.Word, SubWord), crCurFill, crT
extStroke, nHorzScale); | 253 nFontIndex = word.nFontIndex; |
254 | 254 ptBT = word.ptWord; |
255 } | 255 crOldFill = crCurFill; |
256 oldplace = place; | 256 } |
257 | 257 |
258 | 258 sTextBuf << GetPDFWordString(pFontMap, word.nFontIndex, word.Word, |
259 } | 259 SubWord); |
260 } | 260 } else { |
261 | 261 DrawTextString( |
262 if (sTextBuf.GetLength() > 0) | 262 pDevice, CPDF_Point(word.ptWord.x + ptOffset.x, |
263 { | 263 word.ptWord.y + ptOffset.y), |
264 DrawTextString(pDevice, CPDF_Point(ptBT.x+ptOffs
et.x, ptBT.y+ptOffset.y), pFontMap->GetPDFFont(nFontIndex), | 264 pFontMap->GetPDFFont(word.nFontIndex), fFontSize, pUser2Device, |
265 fFontSize, pUser2Device, sTextBuf.GetByt
eString(), crOldFill, crTextStroke, nHorzScale); | 265 GetPDFWordString(pFontMap, word.nFontIndex, word.Word, SubWord), |
266 } | 266 crCurFill, crTextStroke, nHorzScale); |
267 } | 267 } |
268 } | 268 oldplace = place; |
269 | 269 } |
270 pDevice->RestoreState(); | 270 } |
271 } | 271 |
272 | 272 if (sTextBuf.GetLength() > 0) { |
273 void IFX_Edit::DrawRichEdit(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device
, IFX_Edit* pEdit, | 273 DrawTextString( |
274 const CPDF_Rect& rcClip, const C
PDF_Point& ptOffset, const CPVT_WordRange* pRange) | 274 pDevice, CPDF_Point(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), |
275 { | 275 pFontMap->GetPDFFont(nFontIndex), fFontSize, pUser2Device, |
276 //FX_FLOAT fFontSize = pEdit->GetFontSize(); | 276 sTextBuf.GetByteString(), crOldFill, crTextStroke, nHorzScale); |
277 CPVT_WordRange wrSelect = pEdit->GetSelectWordRange(); | 277 } |
278 | 278 } |
279 FX_COLORREF crCurText = ArgbEncode(255, 0,0,0); | 279 } |
280 FX_COLORREF crOld = crCurText; | 280 |
281 FX_BOOL bSelect = FALSE; | 281 pDevice->RestoreState(); |
282 const FX_COLORREF crWhite = ArgbEncode(255,255,255,255); | 282 } |
283 const FX_COLORREF crSelBK = ArgbEncode(255,0,51,113); | 283 |
284 | 284 void IFX_Edit::DrawRichEdit(CFX_RenderDevice* pDevice, |
285 CFX_ByteTextBuf sTextBuf; | 285 CPDF_Matrix* pUser2Device, |
286 CPVT_WordProps wp; | 286 IFX_Edit* pEdit, |
287 CPDF_Point ptBT(0.0f,0.0f); | 287 const CPDF_Rect& rcClip, |
288 | 288 const CPDF_Point& ptOffset, |
289 pDevice->SaveState(); | 289 const CPVT_WordRange* pRange) { |
290 | 290 // FX_FLOAT fFontSize = pEdit->GetFontSize(); |
291 if (!rcClip.IsEmpty()) | 291 CPVT_WordRange wrSelect = pEdit->GetSelectWordRange(); |
292 { | 292 |
293 CPDF_Rect rcTemp = rcClip; | 293 FX_COLORREF crCurText = ArgbEncode(255, 0, 0, 0); |
294 pUser2Device->TransformRect(rcTemp); | 294 FX_COLORREF crOld = crCurText; |
295 FX_RECT rcDevClip; | 295 FX_BOOL bSelect = FALSE; |
296 rcDevClip.left = (int32_t)rcTemp.left; | 296 const FX_COLORREF crWhite = ArgbEncode(255, 255, 255, 255); |
297 rcDevClip.right = (int32_t)rcTemp.right; | 297 const FX_COLORREF crSelBK = ArgbEncode(255, 0, 51, 113); |
298 rcDevClip.top = (int32_t)rcTemp.top; | 298 |
299 rcDevClip.bottom = (int32_t)rcTemp.bottom; | 299 CFX_ByteTextBuf sTextBuf; |
300 pDevice->SetClip_Rect(&rcDevClip); | 300 CPVT_WordProps wp; |
301 } | 301 CPDF_Point ptBT(0.0f, 0.0f); |
302 | 302 |
303 if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) | 303 pDevice->SaveState(); |
304 { | 304 |
305 if (IFX_Edit_FontMap* pFontMap = pEdit->GetFontMap()) | 305 if (!rcClip.IsEmpty()) { |
306 { | 306 CPDF_Rect rcTemp = rcClip; |
307 if (pRange) | 307 pUser2Device->TransformRect(rcTemp); |
308 pIterator->SetAt(pRange->BeginPos); | 308 FX_RECT rcDevClip; |
309 else | 309 rcDevClip.left = (int32_t)rcTemp.left; |
310 pIterator->SetAt(0); | 310 rcDevClip.right = (int32_t)rcTemp.right; |
311 | 311 rcDevClip.top = (int32_t)rcTemp.top; |
312 CPVT_WordPlace oldplace; | 312 rcDevClip.bottom = (int32_t)rcTemp.bottom; |
313 | 313 pDevice->SetClip_Rect(&rcDevClip); |
314 while (pIterator->NextWord()) | 314 } |
315 { | 315 |
316 CPVT_WordPlace place = pIterator->GetAt(); | 316 if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) { |
317 if (pRange && place.WordCmp(pRange->EndPos) > 0)
break; | 317 if (IFX_Edit_FontMap* pFontMap = pEdit->GetFontMap()) { |
318 | 318 if (pRange) |
319 CPVT_Word word; | 319 pIterator->SetAt(pRange->BeginPos); |
320 if (pIterator->GetWord(word)) | 320 else |
321 { | 321 pIterator->SetAt(0); |
322 word.WordProps.fFontSize = word.fFontSiz
e; | 322 |
323 | 323 CPVT_WordPlace oldplace; |
324 crCurText = ArgbEncode(255,word.WordProp
s.dwWordColor); | 324 |
325 | 325 while (pIterator->NextWord()) { |
326 if (wrSelect.IsExist()) | 326 CPVT_WordPlace place = pIterator->GetAt(); |
327 { | 327 if (pRange && place.WordCmp(pRange->EndPos) > 0) |
328 bSelect = place.WordCmp(wrSelect
.BeginPos) > 0 && place.WordCmp(wrSelect.EndPos) <= 0; | 328 break; |
329 if (bSelect) | 329 |
330 { | 330 CPVT_Word word; |
331 crCurText = crWhite; | 331 if (pIterator->GetWord(word)) { |
332 } | 332 word.WordProps.fFontSize = word.fFontSize; |
333 } | 333 |
334 | 334 crCurText = ArgbEncode(255, word.WordProps.dwWordColor); |
335 if (bSelect) | 335 |
336 { | 336 if (wrSelect.IsExist()) { |
337 CPVT_Line line; | 337 bSelect = place.WordCmp(wrSelect.BeginPos) > 0 && |
338 pIterator->GetLine(line); | 338 place.WordCmp(wrSelect.EndPos) <= 0; |
339 | 339 if (bSelect) { |
340 CFX_PathData pathSelBK; | 340 crCurText = crWhite; |
341 pathSelBK.AppendRect(word.ptWord
.x + ptOffset.x, | 341 } |
342 line.ptLine.y + line.fLi
neDescent + ptOffset.y, | 342 } |
343 word.ptWord.x+word.fWidt
h + ptOffset.x, | 343 |
344 line.ptLine.y + line.fLi
neAscent + ptOffset.y); | 344 if (bSelect) { |
345 | 345 CPVT_Line line; |
346 pDevice->DrawPath(&pathSelBK, pU
ser2Device, NULL, crSelBK, 0, FXFILL_WINDING); | 346 pIterator->GetLine(line); |
347 } | 347 |
348 | 348 CFX_PathData pathSelBK; |
349 if (place.LineCmp(oldplace) != 0 || word
.WordProps.fCharSpace > 0.0f || word.WordProps.nHorzScale != 100 || | 349 pathSelBK.AppendRect(word.ptWord.x + ptOffset.x, |
350 FXSYS_memcmp(&word.WordProps, &w
p, sizeof(CPVT_WordProps)) != 0 || | 350 line.ptLine.y + line.fLineDescent + ptOffset.y, |
351 crOld != crCurText) | 351 word.ptWord.x + word.fWidth + ptOffset.x, |
352 { | 352 line.ptLine.y + line.fLineAscent + ptOffset.y); |
353 if (sTextBuf.GetLength() > 0) | 353 |
354 { | 354 pDevice->DrawPath(&pathSelBK, pUser2Device, NULL, crSelBK, 0, |
355 DrawTextString(pDevice,
CPDF_Point(ptBT.x+ptOffset.x, ptBT.y+ptOffset.y), pFontMap->GetPDFFont(wp.nFontI
ndex), | 355 FXFILL_WINDING); |
356 wp.fFontSize, pU
ser2Device, sTextBuf.GetByteString(), crOld, 0, wp.nHorzScale); | 356 } |
357 | 357 |
358 sTextBuf.Clear(); | 358 if (place.LineCmp(oldplace) != 0 || |
359 } | 359 word.WordProps.fCharSpace > 0.0f || |
360 wp = word.WordProps; | 360 word.WordProps.nHorzScale != 100 || |
361 ptBT = word.ptWord; | 361 FXSYS_memcmp(&word.WordProps, &wp, sizeof(CPVT_WordProps)) != 0 || |
362 crOld = crCurText; | 362 crOld != crCurText) { |
363 } | 363 if (sTextBuf.GetLength() > 0) { |
364 | 364 DrawTextString( |
365 sTextBuf << GetPDFWordString(pFontMap, w
ord.WordProps.nFontIndex, word.Word, 0); | 365 pDevice, CPDF_Point(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), |
366 | 366 pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, |
367 if (word.WordProps.nWordStyle & PVTWORD_
STYLE_UNDERLINE) | 367 pUser2Device, sTextBuf.GetByteString(), crOld, 0, |
368 { | 368 wp.nHorzScale); |
369 CFX_PathData pathUnderline; | 369 |
370 CPDF_Rect rcUnderline = GetUnder
LineRect(word); | 370 sTextBuf.Clear(); |
371 pathUnderline.AppendRect(rcUnder
line.left, rcUnderline.bottom, rcUnderline.right, rcUnderline.top); | 371 } |
372 | 372 wp = word.WordProps; |
373 pDevice->DrawPath(&pathUnderline
, pUser2Device, NULL, crCurText, 0, FXFILL_WINDING); | 373 ptBT = word.ptWord; |
374 } | 374 crOld = crCurText; |
375 | 375 } |
376 if (word.WordProps.nWordStyle & PVTWORD_
STYLE_CROSSOUT) | 376 |
377 { | 377 sTextBuf << GetPDFWordString(pFontMap, word.WordProps.nFontIndex, |
378 CFX_PathData pathCrossout; | 378 word.Word, 0); |
379 CPDF_Rect rcCrossout = GetCrosso
utRect(word); | 379 |
380 pathCrossout.AppendRect(rcCrosso
ut.left, rcCrossout.bottom, rcCrossout.right, rcCrossout.top); | 380 if (word.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) { |
381 | 381 CFX_PathData pathUnderline; |
382 pDevice->DrawPath(&pathCrossout,
pUser2Device, NULL, crCurText, 0, FXFILL_WINDING); | 382 CPDF_Rect rcUnderline = GetUnderLineRect(word); |
383 } | 383 pathUnderline.AppendRect(rcUnderline.left, rcUnderline.bottom, |
384 | 384 rcUnderline.right, rcUnderline.top); |
385 oldplace = place; | 385 |
386 } | 386 pDevice->DrawPath(&pathUnderline, pUser2Device, NULL, crCurText, 0, |
387 } | 387 FXFILL_WINDING); |
388 | 388 } |
389 if (sTextBuf.GetLength() > 0) | 389 |
390 { | 390 if (word.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) { |
391 DrawTextString(pDevice, CPDF_Point(ptBT.x+ptOffs
et.x, ptBT.y+ptOffset.y), pFontMap->GetPDFFont(wp.nFontIndex), | 391 CFX_PathData pathCrossout; |
392 wp.fFontSize, pUser2Device, sTextBuf.Get
ByteString(), crOld, 0, wp.nHorzScale); | 392 CPDF_Rect rcCrossout = GetCrossoutRect(word); |
393 } | 393 pathCrossout.AppendRect(rcCrossout.left, rcCrossout.bottom, |
394 } | 394 rcCrossout.right, rcCrossout.top); |
395 } | 395 |
396 | 396 pDevice->DrawPath(&pathCrossout, pUser2Device, NULL, crCurText, 0, |
397 pDevice->RestoreState(); | 397 FXFILL_WINDING); |
398 } | 398 } |
399 | 399 |
400 static void AddRectToPageObjects(CPDF_PageObjects* pPageObjs, FX_COLORREF crFill
, const CPDF_Rect& rcFill) | 400 oldplace = place; |
401 { | 401 } |
402 CPDF_PathObject* pPathObj = new CPDF_PathObject; | 402 } |
403 CPDF_PathData* pPathData = pPathObj->m_Path.GetModify(); | 403 |
404 pPathData->AppendRect(rcFill.left,rcFill.bottom,rcFill.right,rcFill.top)
; | 404 if (sTextBuf.GetLength() > 0) { |
405 | 405 DrawTextString( |
406 FX_FLOAT rgb[3]; | 406 pDevice, CPDF_Point(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), |
407 rgb[0] = FXARGB_R(crFill) / 255.0f ; | 407 pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, pUser2Device, |
408 rgb[1] = FXARGB_G(crFill) / 255.0f; | 408 sTextBuf.GetByteString(), crOld, 0, wp.nHorzScale); |
409 rgb[2] = FXARGB_B(crFill) / 255.0f; | 409 } |
410 pPathObj->m_ColorState.SetFillColor(CPDF_ColorSpace::GetStockCS(PDFCS_DE
VICERGB), rgb, 3); | 410 } |
411 | 411 } |
412 pPathObj->m_FillType = FXFILL_ALTERNATE; | 412 |
413 pPathObj->m_bStroke = FALSE; | 413 pDevice->RestoreState(); |
414 | 414 } |
415 pPageObjs->InsertObject(pPageObjs->GetLastObjectPosition(),pPathObj); | 415 |
416 } | 416 static void AddRectToPageObjects(CPDF_PageObjects* pPageObjs, |
417 | 417 FX_COLORREF crFill, |
418 static CPDF_TextObject* AddTextObjToPageObjects(CPDF_PageObjects* pPageObjs, FX_
COLORREF crText, | 418 const CPDF_Rect& rcFill) { |
419 CPDF_Font* pFont, FX_FL
OAT fFontSize, FX_FLOAT fCharSpace, int32_t nHorzScale, | 419 CPDF_PathObject* pPathObj = new CPDF_PathObject; |
420 const CPDF_Point& point
, const CFX_ByteString& text) | 420 CPDF_PathData* pPathData = pPathObj->m_Path.GetModify(); |
421 { | 421 pPathData->AppendRect(rcFill.left, rcFill.bottom, rcFill.right, rcFill.top); |
422 CPDF_TextObject* pTxtObj = new CPDF_TextObject; | 422 |
423 | 423 FX_FLOAT rgb[3]; |
424 CPDF_TextStateData* pTextStateData = pTxtObj->m_TextState.GetModify(); | 424 rgb[0] = FXARGB_R(crFill) / 255.0f; |
425 pTextStateData->m_pFont = pFont; | 425 rgb[1] = FXARGB_G(crFill) / 255.0f; |
426 pTextStateData->m_FontSize = fFontSize; | 426 rgb[2] = FXARGB_B(crFill) / 255.0f; |
427 pTextStateData->m_CharSpace = fCharSpace; | 427 pPathObj->m_ColorState.SetFillColor( |
428 pTextStateData->m_WordSpace = 0; | 428 CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), rgb, 3); |
429 pTextStateData->m_TextMode = 0; | 429 |
430 pTextStateData->m_Matrix[0] = nHorzScale / 100.0f; | 430 pPathObj->m_FillType = FXFILL_ALTERNATE; |
431 pTextStateData->m_Matrix[1] = 0; | 431 pPathObj->m_bStroke = FALSE; |
432 pTextStateData->m_Matrix[2] = 0; | 432 |
433 pTextStateData->m_Matrix[3] = 1; | 433 pPageObjs->InsertObject(pPageObjs->GetLastObjectPosition(), pPathObj); |
434 | 434 } |
435 FX_FLOAT rgb[3]; | 435 |
436 rgb[0] = FXARGB_R(crText) / 255.0f ; | 436 static CPDF_TextObject* AddTextObjToPageObjects(CPDF_PageObjects* pPageObjs, |
437 rgb[1] = FXARGB_G(crText) / 255.0f; | 437 FX_COLORREF crText, |
438 rgb[2] = FXARGB_B(crText) / 255.0f; | 438 CPDF_Font* pFont, |
439 pTxtObj->m_ColorState.SetFillColor(CPDF_ColorSpace::GetStockCS(PDFCS_DEV
ICERGB),rgb, 3); | 439 FX_FLOAT fFontSize, |
440 pTxtObj->m_ColorState.SetStrokeColor(CPDF_ColorSpace::GetStockCS(PDFCS_D
EVICERGB),rgb, 3); | 440 FX_FLOAT fCharSpace, |
441 | 441 int32_t nHorzScale, |
442 pTxtObj->SetPosition(point.x,point.y); | 442 const CPDF_Point& point, |
443 pTxtObj->SetText(text); | 443 const CFX_ByteString& text) { |
444 | 444 CPDF_TextObject* pTxtObj = new CPDF_TextObject; |
445 pPageObjs->InsertObject(pPageObjs->GetLastObjectPosition(),pTxtObj); | 445 |
446 | 446 CPDF_TextStateData* pTextStateData = pTxtObj->m_TextState.GetModify(); |
447 return pTxtObj; | 447 pTextStateData->m_pFont = pFont; |
448 } | 448 pTextStateData->m_FontSize = fFontSize; |
449 | 449 pTextStateData->m_CharSpace = fCharSpace; |
450 void IFX_Edit::GeneratePageObjects(CPDF_PageObjects* pPageObjects, IFX_Edit* pEd
it, | 450 pTextStateData->m_WordSpace = 0; |
451 const CPDF_Po
int& ptOffset, const CPVT_WordRange* pRange, FX_COLORREF crText, CFX_ArrayTempla
te<CPDF_TextObject*>& ObjArray) | 451 pTextStateData->m_TextMode = 0; |
452 { | 452 pTextStateData->m_Matrix[0] = nHorzScale / 100.0f; |
453 FX_FLOAT fFontSize = pEdit->GetFontSize(); | 453 pTextStateData->m_Matrix[1] = 0; |
454 | 454 pTextStateData->m_Matrix[2] = 0; |
455 int32_t nOldFontIndex = -1; | 455 pTextStateData->m_Matrix[3] = 1; |
456 | 456 |
457 CFX_ByteTextBuf sTextBuf; | 457 FX_FLOAT rgb[3]; |
458 CPDF_Point ptBT(0.0f,0.0f); | 458 rgb[0] = FXARGB_R(crText) / 255.0f; |
459 | 459 rgb[1] = FXARGB_G(crText) / 255.0f; |
460 ObjArray.RemoveAll(); | 460 rgb[2] = FXARGB_B(crText) / 255.0f; |
461 | 461 pTxtObj->m_ColorState.SetFillColor( |
462 if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) | 462 CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), rgb, 3); |
463 { | 463 pTxtObj->m_ColorState.SetStrokeColor( |
464 if (IFX_Edit_FontMap* pFontMap = pEdit->GetFontMap()) | 464 CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), rgb, 3); |
465 { | 465 |
466 if (pRange) | 466 pTxtObj->SetPosition(point.x, point.y); |
467 pIterator->SetAt(pRange->BeginPos); | 467 pTxtObj->SetText(text); |
468 else | 468 |
469 pIterator->SetAt(0); | 469 pPageObjs->InsertObject(pPageObjs->GetLastObjectPosition(), pTxtObj); |
470 | 470 |
471 CPVT_WordPlace oldplace; | 471 return pTxtObj; |
472 | 472 } |
473 while (pIterator->NextWord()) | 473 |
474 { | 474 void IFX_Edit::GeneratePageObjects( |
475 CPVT_WordPlace place = pIterator->GetAt(); | 475 CPDF_PageObjects* pPageObjects, |
476 if (pRange && place.WordCmp(pRange->EndPos) > 0)
break; | 476 IFX_Edit* pEdit, |
477 | 477 const CPDF_Point& ptOffset, |
478 CPVT_Word word; | 478 const CPVT_WordRange* pRange, |
479 if (pIterator->GetWord(word)) | 479 FX_COLORREF crText, |
480 { | 480 CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) { |
481 if (place.LineCmp(oldplace) != 0 || nOld
FontIndex != word.nFontIndex) | 481 FX_FLOAT fFontSize = pEdit->GetFontSize(); |
482 { | 482 |
483 if (sTextBuf.GetLength() > 0) | 483 int32_t nOldFontIndex = -1; |
484 { | 484 |
485 ObjArray.Add(AddTextObjT
oPageObjects(pPageObjects, crText, pFontMap->GetPDFFont(nOldFontIndex), fFontSiz
e, 0.0f, 100, | 485 CFX_ByteTextBuf sTextBuf; |
486 CPDF_Point(ptBT.
x+ptOffset.x, ptBT.y+ptOffset.y), sTextBuf.GetByteString())); | 486 CPDF_Point ptBT(0.0f, 0.0f); |
487 | 487 |
488 sTextBuf.Clear(); | 488 ObjArray.RemoveAll(); |
489 } | 489 |
490 | 490 if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) { |
491 ptBT = word.ptWord; | 491 if (IFX_Edit_FontMap* pFontMap = pEdit->GetFontMap()) { |
492 nOldFontIndex = word.nFontIndex; | 492 if (pRange) |
493 } | 493 pIterator->SetAt(pRange->BeginPos); |
494 | 494 else |
495 sTextBuf << GetPDFWordString(pFontMap, w
ord.nFontIndex, word.Word, 0); | 495 pIterator->SetAt(0); |
496 oldplace = place; | 496 |
497 } | 497 CPVT_WordPlace oldplace; |
498 } | 498 |
499 | 499 while (pIterator->NextWord()) { |
500 if (sTextBuf.GetLength() > 0) | 500 CPVT_WordPlace place = pIterator->GetAt(); |
501 { | 501 if (pRange && place.WordCmp(pRange->EndPos) > 0) |
502 ObjArray.Add(AddTextObjToPageObjects(pPageObject
s, crText, pFontMap->GetPDFFont(nOldFontIndex), fFontSize, 0.0f, 100, | 502 break; |
503 CPDF_Point(ptBT.x+ptOffset.x, ptBT.y+ptO
ffset.y), sTextBuf.GetByteString())); | 503 |
504 } | 504 CPVT_Word word; |
505 } | 505 if (pIterator->GetWord(word)) { |
506 } | 506 if (place.LineCmp(oldplace) != 0 || |
507 } | 507 nOldFontIndex != word.nFontIndex) { |
508 | 508 if (sTextBuf.GetLength() > 0) { |
509 void IFX_Edit::GenerateRichPageObjects(CPDF_PageObjects* pPageObjects, IFX_Edit*
pEdit, | 509 ObjArray.Add(AddTextObjToPageObjects( |
510 const CPDF_Po
int& ptOffset, const CPVT_WordRange* pRange, CFX_ArrayTemplate<CPDF_TextObject*>
& ObjArray) | 510 pPageObjects, crText, pFontMap->GetPDFFont(nOldFontIndex), |
511 { | 511 fFontSize, 0.0f, 100, |
512 | 512 CPDF_Point(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), |
513 | 513 sTextBuf.GetByteString())); |
514 FX_COLORREF crCurText = ArgbEncode(255, 0, 0, 0); | 514 |
515 FX_COLORREF crOld = crCurText; | 515 sTextBuf.Clear(); |
516 | 516 } |
517 | 517 |
518 CFX_ByteTextBuf sTextBuf; | 518 ptBT = word.ptWord; |
519 CPVT_WordProps wp; | 519 nOldFontIndex = word.nFontIndex; |
520 CPDF_Point ptBT(0.0f,0.0f); | 520 } |
521 | 521 |
522 ObjArray.RemoveAll(); | 522 sTextBuf << GetPDFWordString(pFontMap, word.nFontIndex, word.Word, 0); |
523 | 523 oldplace = place; |
524 if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) | 524 } |
525 { | 525 } |
526 if (IFX_Edit_FontMap* pFontMap = pEdit->GetFontMap()) | 526 |
527 { | 527 if (sTextBuf.GetLength() > 0) { |
528 if (pRange) | 528 ObjArray.Add(AddTextObjToPageObjects( |
529 pIterator->SetAt(pRange->BeginPos); | 529 pPageObjects, crText, pFontMap->GetPDFFont(nOldFontIndex), |
530 else | 530 fFontSize, 0.0f, 100, |
531 pIterator->SetAt(0); | 531 CPDF_Point(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), |
532 | 532 sTextBuf.GetByteString())); |
533 CPVT_WordPlace oldplace; | 533 } |
534 | 534 } |
535 while (pIterator->NextWord()) | 535 } |
536 { | 536 } |
537 CPVT_WordPlace place = pIterator->GetAt(); | 537 |
538 if (pRange && place.WordCmp(pRange->EndPos) > 0)
break; | 538 void IFX_Edit::GenerateRichPageObjects( |
539 | 539 CPDF_PageObjects* pPageObjects, |
540 CPVT_Word word; | 540 IFX_Edit* pEdit, |
541 if (pIterator->GetWord(word)) | 541 const CPDF_Point& ptOffset, |
542 { | 542 const CPVT_WordRange* pRange, |
543 word.WordProps.fFontSize = word.fFontSiz
e; | 543 CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) { |
544 | 544 FX_COLORREF crCurText = ArgbEncode(255, 0, 0, 0); |
545 crCurText = ArgbEncode(255,word.WordProp
s.dwWordColor); | 545 FX_COLORREF crOld = crCurText; |
546 | 546 |
547 if (place.LineCmp(oldplace) != 0 || word
.WordProps.fCharSpace > 0.0f || word.WordProps.nHorzScale != 100 || | 547 CFX_ByteTextBuf sTextBuf; |
548 FXSYS_memcmp(&word.WordProps, &w
p, sizeof(CPVT_WordProps)) != 0 || | 548 CPVT_WordProps wp; |
549 crOld != crCurText) | 549 CPDF_Point ptBT(0.0f, 0.0f); |
550 { | 550 |
551 if (sTextBuf.GetLength() > 0) | 551 ObjArray.RemoveAll(); |
552 { | 552 |
553 ObjArray.Add(AddTextObjT
oPageObjects(pPageObjects, crOld, pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontS
ize, wp.fCharSpace, wp.nHorzScale, | 553 if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) { |
554 CPDF_Point(ptBT.
x+ptOffset.x, ptBT.y+ptOffset.y), sTextBuf.GetByteString())); | 554 if (IFX_Edit_FontMap* pFontMap = pEdit->GetFontMap()) { |
555 | 555 if (pRange) |
556 sTextBuf.Clear(); | 556 pIterator->SetAt(pRange->BeginPos); |
557 } | 557 else |
558 | 558 pIterator->SetAt(0); |
559 wp = word.WordProps; | 559 |
560 ptBT = word.ptWord; | 560 CPVT_WordPlace oldplace; |
561 crOld = crCurText; | 561 |
562 | 562 while (pIterator->NextWord()) { |
563 } | 563 CPVT_WordPlace place = pIterator->GetAt(); |
564 | 564 if (pRange && place.WordCmp(pRange->EndPos) > 0) |
565 sTextBuf << GetPDFWordString(pFontMap, w
ord.WordProps.nFontIndex, word.Word, 0); | 565 break; |
566 | 566 |
567 if (word.WordProps.nWordStyle & PVTWORD_
STYLE_UNDERLINE) | 567 CPVT_Word word; |
568 {/* | 568 if (pIterator->GetWord(word)) { |
569 AddLineToPageObjects(pPageObject
s, crCurText, | 569 word.WordProps.fFontSize = word.fFontSize; |
570 CPDF_Point(word.ptWord.x
, word.ptWord.y + word.fDescent * 0.4f), | 570 |
571 CPDF_Point(word.ptWord.x
+ word.fWidth, word.ptWord.y + word.fDescent * 0.4f)); | 571 crCurText = ArgbEncode(255, word.WordProps.dwWordColor); |
| 572 |
| 573 if (place.LineCmp(oldplace) != 0 || |
| 574 word.WordProps.fCharSpace > 0.0f || |
| 575 word.WordProps.nHorzScale != 100 || |
| 576 FXSYS_memcmp(&word.WordProps, &wp, sizeof(CPVT_WordProps)) != 0 || |
| 577 crOld != crCurText) { |
| 578 if (sTextBuf.GetLength() > 0) { |
| 579 ObjArray.Add(AddTextObjToPageObjects( |
| 580 pPageObjects, crOld, pFontMap->GetPDFFont(wp.nFontIndex), |
| 581 wp.fFontSize, wp.fCharSpace, wp.nHorzScale, |
| 582 CPDF_Point(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), |
| 583 sTextBuf.GetByteString())); |
| 584 |
| 585 sTextBuf.Clear(); |
| 586 } |
| 587 |
| 588 wp = word.WordProps; |
| 589 ptBT = word.ptWord; |
| 590 crOld = crCurText; |
| 591 } |
| 592 |
| 593 sTextBuf << GetPDFWordString(pFontMap, word.WordProps.nFontIndex, |
| 594 word.Word, 0); |
| 595 |
| 596 if (word.WordProps.nWordStyle & |
| 597 PVTWORD_STYLE_UNDERLINE) { /* |
| 598 AddLineToPageObjects(pPageObject
s, |
| 599 crCurText, |
| 600 CPDF_Point(word.ptWord.x
, |
| 601 word.ptWord.y + word.fDescent * |
| 602 0.4f), |
| 603 CPDF_Point(word.ptWord.x |
| 604 + word.fWidth, word.ptWord.y + |
| 605 word.fDescent * 0.4f)); |
572 */ | 606 */ |
573 » » » » » » CPDF_Rect rcUnderline = GetUnder
LineRect(word); | 607 CPDF_Rect rcUnderline = GetUnderLineRect(word); |
574 » » » » » » rcUnderline.left += ptOffset.x; | 608 rcUnderline.left += ptOffset.x; |
575 » » » » » » rcUnderline.right += ptOffset.x; | 609 rcUnderline.right += ptOffset.x; |
576 » » » » » » rcUnderline.top += ptOffset.y; | 610 rcUnderline.top += ptOffset.y; |
577 » » » » » » rcUnderline.bottom += ptOffset.y
; | 611 rcUnderline.bottom += ptOffset.y; |
578 | 612 |
579 » » » » » » AddRectToPageObjects(pPageObject
s, crCurText, rcUnderline); | 613 AddRectToPageObjects(pPageObjects, crCurText, rcUnderline); |
580 » » » » » } | 614 } |
581 | 615 |
582 » » » » » if (word.WordProps.nWordStyle & PVTWORD_
STYLE_CROSSOUT) | 616 if (word.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) { |
583 » » » » » { | 617 CPDF_Rect rcCrossout = GetCrossoutRect(word); |
584 » » » » » » CPDF_Rect rcCrossout = GetCrosso
utRect(word); | 618 rcCrossout.left += ptOffset.x; |
585 » » » » » » rcCrossout.left += ptOffset.x; | 619 rcCrossout.right += ptOffset.x; |
586 » » » » » » rcCrossout.right += ptOffset.x; | 620 rcCrossout.top += ptOffset.y; |
587 » » » » » » rcCrossout.top += ptOffset.y; | 621 rcCrossout.bottom += ptOffset.y; |
588 » » » » » » rcCrossout.bottom += ptOffset.y; | 622 |
589 | 623 AddRectToPageObjects(pPageObjects, crCurText, rcCrossout); |
590 » » » » » » AddRectToPageObjects(pPageObject
s, crCurText, rcCrossout); | 624 } |
591 » » » » » } | 625 |
592 | 626 oldplace = place; |
593 » » » » » oldplace = place; | 627 } |
594 » » » » } | 628 } |
595 » » » } | 629 |
596 | 630 if (sTextBuf.GetLength() > 0) { |
597 » » » if (sTextBuf.GetLength() > 0) | 631 ObjArray.Add(AddTextObjToPageObjects( |
598 » » » { | 632 pPageObjects, crOld, pFontMap->GetPDFFont(wp.nFontIndex), |
599 » » » » ObjArray.Add(AddTextObjToPageObjects(pPageObject
s, crOld, pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, wp.fCharSpace, wp.n
HorzScale, | 633 wp.fFontSize, wp.fCharSpace, wp.nHorzScale, |
600 » » » » » CPDF_Point(ptBT.x+ptOffset.x, ptBT.y+ptO
ffset.y), sTextBuf.GetByteString())); | 634 CPDF_Point(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), |
601 » » » } | 635 sTextBuf.GetByteString())); |
602 » » } | 636 } |
603 » } | 637 } |
604 } | 638 } |
605 | 639 } |
606 void IFX_Edit::GenerateUnderlineObjects(CPDF_PageObjects* pPageObjects, IFX_Edit
* pEdit, | 640 |
607 » » » » » » » » const CPDF_Po
int& ptOffset, const CPVT_WordRange* pRange, FX_COLORREF color) | 641 void IFX_Edit::GenerateUnderlineObjects(CPDF_PageObjects* pPageObjects, |
608 { | 642 IFX_Edit* pEdit, |
609 | 643 const CPDF_Point& ptOffset, |
610 | 644 const CPVT_WordRange* pRange, |
611 » if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) | 645 FX_COLORREF color) { |
612 » { | 646 if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) { |
613 » » if (pEdit->GetFontMap()) | 647 if (pEdit->GetFontMap()) { |
614 » » { | 648 if (pRange) |
615 » » » if (pRange) | 649 pIterator->SetAt(pRange->BeginPos); |
616 » » » » pIterator->SetAt(pRange->BeginPos); | 650 else |
617 » » » else | 651 pIterator->SetAt(0); |
618 » » » » pIterator->SetAt(0); | 652 |
619 | 653 CPVT_WordPlace oldplace; |
620 » » » CPVT_WordPlace oldplace; | 654 |
621 | 655 while (pIterator->NextWord()) { |
622 » » » while (pIterator->NextWord()) | 656 CPVT_WordPlace place = pIterator->GetAt(); |
623 » » » { | 657 if (pRange && place.WordCmp(pRange->EndPos) > 0) |
624 » » » » CPVT_WordPlace place = pIterator->GetAt(); | 658 break; |
625 » » » » if (pRange && place.WordCmp(pRange->EndPos) > 0)
break; | 659 |
626 | 660 CPVT_Word word; |
627 » » » » CPVT_Word word; | 661 if (pIterator->GetWord(word)) { |
628 » » » » if (pIterator->GetWord(word)) | 662 CPDF_Rect rcUnderline = GetUnderLineRect(word); |
629 » » » » { | 663 rcUnderline.left += ptOffset.x; |
630 » » » » » CPDF_Rect rcUnderline = GetUnderLineRect
(word); | 664 rcUnderline.right += ptOffset.x; |
631 » » » » » rcUnderline.left += ptOffset.x; | 665 rcUnderline.top += ptOffset.y; |
632 » » » » » rcUnderline.right += ptOffset.x; | 666 rcUnderline.bottom += ptOffset.y; |
633 » » » » » rcUnderline.top += ptOffset.y; | 667 AddRectToPageObjects(pPageObjects, color, rcUnderline); |
634 » » » » » rcUnderline.bottom += ptOffset.y; | 668 } |
635 » » » » » AddRectToPageObjects(pPageObjects, color
, rcUnderline); | 669 } |
636 » » » » } | 670 } |
637 » » » } | 671 } |
638 » » } | 672 } |
639 » } | |
640 } | |
641 | |
OLD | NEW |