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

Side by Side Diff: fpdfsdk/src/fxedit/fxet_pageobjs.cpp

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

Powered by Google App Engine
This is Rietveld 408576698