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, FX_INT32 nFo
ntIndex, FX_WORD Word, FX_WORD SubWord); | 14 extern CFX_ByteString GetPDFWordString(IFX_Edit_FontMap * pFontMap, int32_t nFon
tIndex, FX_WORD Word, FX_WORD SubWord); |
15 | 15 |
16 CPDF_Rect GetUnderLineRect(const CPVT_Word& word) | 16 CPDF_Rect GetUnderLineRect(const CPVT_Word& word) |
17 { | 17 { |
18 return CPDF_Rect(word.ptWord.x, word.ptWord.y + word.fDescent * 0.5f, | 18 return CPDF_Rect(word.ptWord.x, word.ptWord.y + word.fDescent * 0.5f, |
19 word.ptWord.x + word.fWidth, wor
d.ptWord.y + word.fDescent * 0.25f); | 19 word.ptWord.x + word.fWidth, wor
d.ptWord.y + word.fDescent * 0.25f); |
20 } | 20 } |
21 | 21 |
22 CPDF_Rect GetCrossoutRect(const CPVT_Word& word) | 22 CPDF_Rect GetCrossoutRect(const CPVT_Word& word) |
23 { | 23 { |
24 return CPDF_Rect(word.ptWord.x, word.ptWord.y + (word.fAscent + word.fDe
scent) * 0.5f + 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, |
25 word.ptWord.x + word.fWi
dth, word.ptWord.y + (word.fAscent + word.fDescent) * 0.5f); | 25 word.ptWord.x + word.fWi
dth, word.ptWord.y + (word.fAscent + word.fDescent) * 0.5f); |
26 } | 26 } |
27 | 27 |
28 static void DrawTextString(CFX_RenderDevice* pDevice, const CPDF_Point& pt, CPDF
_Font* pFont, FX_FLOAT fFontSize, CPDF_Matrix* pUser2Device, | 28 static void DrawTextString(CFX_RenderDevice* pDevice, const CPDF_Point& pt, CPDF
_Font* pFont, FX_FLOAT fFontSize, CPDF_Matrix* pUser2Device, |
29 » » » » » const CFX_ByteString& str, FX_ARGB crT
extFill, FX_ARGB crTextStroke, FX_INT32 nHorzScale) | 29 » » » » » const CFX_ByteString& str, FX_ARGB crT
extFill, FX_ARGB crTextStroke, int32_t nHorzScale) |
30 { | 30 { |
31 FX_FLOAT x = pt.x, y = pt.y; | 31 FX_FLOAT x = pt.x, y = pt.y; |
32 pUser2Device->Transform(x, y); | 32 pUser2Device->Transform(x, y); |
33 | 33 |
34 if (pFont) | 34 if (pFont) |
35 { | 35 { |
36 if (nHorzScale != 100) | 36 if (nHorzScale != 100) |
37 { | 37 { |
38 CPDF_Matrix mt(nHorzScale/100.0f,0,0,1,0,0); | 38 CPDF_Matrix mt(nHorzScale/100.0f,0,0,1,0,0); |
39 mt.Concat(*pUser2Device); | 39 mt.Concat(*pUser2Device); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 void IFX_Edit::DrawUnderline(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Devic
e, IFX_Edit* pEdit, FX_COLORREF color, | 80 void IFX_Edit::DrawUnderline(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Devic
e, IFX_Edit* pEdit, FX_COLORREF color, |
81 const CPDF_Rect&
rcClip, const CPDF_Point& ptOffset, const CPVT_WordRange* pRange) | 81 const CPDF_Rect&
rcClip, const CPDF_Point& ptOffset, const CPVT_WordRange* pRange) |
82 { | 82 { |
83 pDevice->SaveState(); | 83 pDevice->SaveState(); |
84 | 84 |
85 if (!rcClip.IsEmpty()) | 85 if (!rcClip.IsEmpty()) |
86 { | 86 { |
87 CPDF_Rect rcTemp = rcClip; | 87 CPDF_Rect rcTemp = rcClip; |
88 pUser2Device->TransformRect(rcTemp); | 88 pUser2Device->TransformRect(rcTemp); |
89 FX_RECT rcDevClip; | 89 FX_RECT rcDevClip; |
90 » » rcDevClip.left = (FX_INT32)rcTemp.left; | 90 » » rcDevClip.left = (int32_t)rcTemp.left; |
91 » » rcDevClip.right = (FX_INT32)rcTemp.right; | 91 » » rcDevClip.right = (int32_t)rcTemp.right; |
92 » » rcDevClip.top = (FX_INT32)rcTemp.top; | 92 » » rcDevClip.top = (int32_t)rcTemp.top; |
93 » » rcDevClip.bottom = (FX_INT32)rcTemp.bottom; | 93 » » rcDevClip.bottom = (int32_t)rcTemp.bottom; |
94 pDevice->SetClip_Rect(&rcDevClip); | 94 pDevice->SetClip_Rect(&rcDevClip); |
95 } | 95 } |
96 | 96 |
97 if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) | 97 if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) |
98 { | 98 { |
99 if (pEdit->GetFontMap()) | 99 if (pEdit->GetFontMap()) |
100 { | 100 { |
101 if (pRange) | 101 if (pRange) |
102 pIterator->SetAt(pRange->BeginPos); | 102 pIterator->SetAt(pRange->BeginPos); |
103 else | 103 else |
(...skipping 28 matching lines...) Expand all Loading... |
132 const CPDF_Rect& rcClip, const C
PDF_Point& ptOffset, const CPVT_WordRange* pRange, IFX_SystemHandler* pSystemHan
dler, void* pFFLData) | 132 const CPDF_Rect& rcClip, const C
PDF_Point& ptOffset, const CPVT_WordRange* pRange, IFX_SystemHandler* pSystemHan
dler, void* pFFLData) |
133 { | 133 { |
134 | 134 |
135 FX_BOOL bContinuous = pEdit->GetCharArray() == 0; | 135 FX_BOOL bContinuous = pEdit->GetCharArray() == 0; |
136 if (pEdit->GetCharSpace() > 0.0f) | 136 if (pEdit->GetCharSpace() > 0.0f) |
137 bContinuous = FALSE; | 137 bContinuous = FALSE; |
138 | 138 |
139 FX_WORD SubWord = pEdit->GetPasswordChar(); | 139 FX_WORD SubWord = pEdit->GetPasswordChar(); |
140 FX_FLOAT fFontSize = pEdit->GetFontSize(); | 140 FX_FLOAT fFontSize = pEdit->GetFontSize(); |
141 CPVT_WordRange wrSelect = pEdit->GetSelectWordRange(); | 141 CPVT_WordRange wrSelect = pEdit->GetSelectWordRange(); |
142 » FX_INT32 nHorzScale = pEdit->GetHorzScale(); | 142 » int32_t nHorzScale = pEdit->GetHorzScale(); |
143 | 143 |
144 FX_COLORREF crCurFill = crTextFill; | 144 FX_COLORREF crCurFill = crTextFill; |
145 FX_COLORREF crOldFill = crCurFill; | 145 FX_COLORREF crOldFill = crCurFill; |
146 | 146 |
147 FX_BOOL bSelect = FALSE; | 147 FX_BOOL bSelect = FALSE; |
148 const FX_COLORREF crWhite = ArgbEncode(255,255,255,255); | 148 const FX_COLORREF crWhite = ArgbEncode(255,255,255,255); |
149 const FX_COLORREF crSelBK = ArgbEncode(255,0,51,113); | 149 const FX_COLORREF crSelBK = ArgbEncode(255,0,51,113); |
150 | 150 |
151 CFX_ByteTextBuf sTextBuf; | 151 CFX_ByteTextBuf sTextBuf; |
152 » FX_INT32 nFontIndex = -1; | 152 » int32_t nFontIndex = -1; |
153 CPDF_Point ptBT(0.0f,0.0f); | 153 CPDF_Point ptBT(0.0f,0.0f); |
154 | 154 |
155 pDevice->SaveState(); | 155 pDevice->SaveState(); |
156 | 156 |
157 if (!rcClip.IsEmpty()) | 157 if (!rcClip.IsEmpty()) |
158 { | 158 { |
159 CPDF_Rect rcTemp = rcClip; | 159 CPDF_Rect rcTemp = rcClip; |
160 pUser2Device->TransformRect(rcTemp); | 160 pUser2Device->TransformRect(rcTemp); |
161 FX_RECT rcDevClip; | 161 FX_RECT rcDevClip; |
162 » » rcDevClip.left = (FX_INT32)rcTemp.left; | 162 » » rcDevClip.left = (int32_t)rcTemp.left; |
163 » » rcDevClip.right = (FX_INT32)rcTemp.right; | 163 » » rcDevClip.right = (int32_t)rcTemp.right; |
164 » » rcDevClip.top = (FX_INT32)rcTemp.top; | 164 » » rcDevClip.top = (int32_t)rcTemp.top; |
165 » » rcDevClip.bottom = (FX_INT32)rcTemp.bottom; | 165 » » rcDevClip.bottom = (int32_t)rcTemp.bottom; |
166 pDevice->SetClip_Rect(&rcDevClip); | 166 pDevice->SetClip_Rect(&rcDevClip); |
167 } | 167 } |
168 | 168 |
169 if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) | 169 if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) |
170 { | 170 { |
171 if (IFX_Edit_FontMap* pFontMap = pEdit->GetFontMap()) | 171 if (IFX_Edit_FontMap* pFontMap = pEdit->GetFontMap()) |
172 { | 172 { |
173 if (pRange) | 173 if (pRange) |
174 pIterator->SetAt(pRange->BeginPos); | 174 pIterator->SetAt(pRange->BeginPos); |
175 else | 175 else |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 CPVT_WordProps wp; | 286 CPVT_WordProps wp; |
287 CPDF_Point ptBT(0.0f,0.0f); | 287 CPDF_Point ptBT(0.0f,0.0f); |
288 | 288 |
289 pDevice->SaveState(); | 289 pDevice->SaveState(); |
290 | 290 |
291 if (!rcClip.IsEmpty()) | 291 if (!rcClip.IsEmpty()) |
292 { | 292 { |
293 CPDF_Rect rcTemp = rcClip; | 293 CPDF_Rect rcTemp = rcClip; |
294 pUser2Device->TransformRect(rcTemp); | 294 pUser2Device->TransformRect(rcTemp); |
295 FX_RECT rcDevClip; | 295 FX_RECT rcDevClip; |
296 » » rcDevClip.left = (FX_INT32)rcTemp.left; | 296 » » rcDevClip.left = (int32_t)rcTemp.left; |
297 » » rcDevClip.right = (FX_INT32)rcTemp.right; | 297 » » rcDevClip.right = (int32_t)rcTemp.right; |
298 » » rcDevClip.top = (FX_INT32)rcTemp.top; | 298 » » rcDevClip.top = (int32_t)rcTemp.top; |
299 » » rcDevClip.bottom = (FX_INT32)rcTemp.bottom; | 299 » » rcDevClip.bottom = (int32_t)rcTemp.bottom; |
300 pDevice->SetClip_Rect(&rcDevClip); | 300 pDevice->SetClip_Rect(&rcDevClip); |
301 } | 301 } |
302 | 302 |
303 if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) | 303 if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) |
304 { | 304 { |
305 if (IFX_Edit_FontMap* pFontMap = pEdit->GetFontMap()) | 305 if (IFX_Edit_FontMap* pFontMap = pEdit->GetFontMap()) |
306 { | 306 { |
307 if (pRange) | 307 if (pRange) |
308 pIterator->SetAt(pRange->BeginPos); | 308 pIterator->SetAt(pRange->BeginPos); |
309 else | 309 else |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 rgb[2] = FXARGB_B(crFill) / 255.0f; | 409 rgb[2] = FXARGB_B(crFill) / 255.0f; |
410 pPathObj->m_ColorState.SetFillColor(CPDF_ColorSpace::GetStockCS(PDFCS_DE
VICERGB), rgb, 3); | 410 pPathObj->m_ColorState.SetFillColor(CPDF_ColorSpace::GetStockCS(PDFCS_DE
VICERGB), rgb, 3); |
411 | 411 |
412 pPathObj->m_FillType = FXFILL_ALTERNATE; | 412 pPathObj->m_FillType = FXFILL_ALTERNATE; |
413 pPathObj->m_bStroke = FALSE; | 413 pPathObj->m_bStroke = FALSE; |
414 | 414 |
415 pPageObjs->InsertObject(pPageObjs->GetLastObjectPosition(),pPathObj); | 415 pPageObjs->InsertObject(pPageObjs->GetLastObjectPosition(),pPathObj); |
416 } | 416 } |
417 | 417 |
418 static CPDF_TextObject* AddTextObjToPageObjects(CPDF_PageObjects* pPageObjs, FX_
COLORREF crText, | 418 static CPDF_TextObject* AddTextObjToPageObjects(CPDF_PageObjects* pPageObjs, FX_
COLORREF crText, |
419 » » » » » » » CPDF_Font* pFont, FX_FL
OAT fFontSize, FX_FLOAT fCharSpace, FX_INT32 nHorzScale, | 419 » » » » » » » CPDF_Font* pFont, FX_FL
OAT fFontSize, FX_FLOAT fCharSpace, int32_t nHorzScale, |
420 const CPDF_Point& point
, const CFX_ByteString& text) | 420 const CPDF_Point& point
, const CFX_ByteString& text) |
421 { | 421 { |
422 CPDF_TextObject* pTxtObj = new CPDF_TextObject; | 422 CPDF_TextObject* pTxtObj = new CPDF_TextObject; |
423 | 423 |
424 CPDF_TextStateData* pTextStateData = pTxtObj->m_TextState.GetModify(); | 424 CPDF_TextStateData* pTextStateData = pTxtObj->m_TextState.GetModify(); |
425 pTextStateData->m_pFont = pFont; | 425 pTextStateData->m_pFont = pFont; |
426 pTextStateData->m_FontSize = fFontSize; | 426 pTextStateData->m_FontSize = fFontSize; |
427 pTextStateData->m_CharSpace = fCharSpace; | 427 pTextStateData->m_CharSpace = fCharSpace; |
428 pTextStateData->m_WordSpace = 0; | 428 pTextStateData->m_WordSpace = 0; |
429 pTextStateData->m_TextMode = 0; | 429 pTextStateData->m_TextMode = 0; |
(...skipping 15 matching lines...) Expand all Loading... |
445 pPageObjs->InsertObject(pPageObjs->GetLastObjectPosition(),pTxtObj); | 445 pPageObjs->InsertObject(pPageObjs->GetLastObjectPosition(),pTxtObj); |
446 | 446 |
447 return pTxtObj; | 447 return pTxtObj; |
448 } | 448 } |
449 | 449 |
450 void IFX_Edit::GeneratePageObjects(CPDF_PageObjects* pPageObjects, IFX_Edit* pEd
it, | 450 void IFX_Edit::GeneratePageObjects(CPDF_PageObjects* pPageObjects, IFX_Edit* pEd
it, |
451 const CPDF_Po
int& ptOffset, const CPVT_WordRange* pRange, FX_COLORREF crText, CFX_ArrayTempla
te<CPDF_TextObject*>& ObjArray) | 451 const CPDF_Po
int& ptOffset, const CPVT_WordRange* pRange, FX_COLORREF crText, CFX_ArrayTempla
te<CPDF_TextObject*>& ObjArray) |
452 { | 452 { |
453 FX_FLOAT fFontSize = pEdit->GetFontSize(); | 453 FX_FLOAT fFontSize = pEdit->GetFontSize(); |
454 | 454 |
455 » FX_INT32 nOldFontIndex = -1; | 455 » int32_t nOldFontIndex = -1; |
456 | 456 |
457 CFX_ByteTextBuf sTextBuf; | 457 CFX_ByteTextBuf sTextBuf; |
458 CPDF_Point ptBT(0.0f,0.0f); | 458 CPDF_Point ptBT(0.0f,0.0f); |
459 | 459 |
460 ObjArray.RemoveAll(); | 460 ObjArray.RemoveAll(); |
461 | 461 |
462 if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) | 462 if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) |
463 { | 463 { |
464 if (IFX_Edit_FontMap* pFontMap = pEdit->GetFontMap()) | 464 if (IFX_Edit_FontMap* pFontMap = pEdit->GetFontMap()) |
465 { | 465 { |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 rcUnderline.right += ptOffset.x; | 632 rcUnderline.right += ptOffset.x; |
633 rcUnderline.top += ptOffset.y; | 633 rcUnderline.top += ptOffset.y; |
634 rcUnderline.bottom += ptOffset.y; | 634 rcUnderline.bottom += ptOffset.y; |
635 AddRectToPageObjects(pPageObjects, color
, rcUnderline); | 635 AddRectToPageObjects(pPageObjects, color
, rcUnderline); |
636 } | 636 } |
637 } | 637 } |
638 } | 638 } |
639 } | 639 } |
640 } | 640 } |
641 | 641 |
OLD | NEW |