| 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 "core/include/fpdfapi/fpdf_pageobj.h" |
| 8 #include "core/include/fpdfapi/fpdf_render.h" |
| 9 #include "fpdfsdk/include/fx_systemhandler.h" |
| 7 #include "fpdfsdk/include/fxedit/fx_edit.h" | 10 #include "fpdfsdk/include/fxedit/fx_edit.h" |
| 8 #include "fpdfsdk/include/fxedit/fxet_edit.h" | 11 #include "fpdfsdk/include/fxedit/fxet_edit.h" |
| 9 #include "fpdfsdk/include/fxedit/fxet_stub.h" | |
| 10 | 12 |
| 11 #define FX_EDIT_UNDERLINEHALFWIDTH 0.5f | 13 #define FX_EDIT_UNDERLINEHALFWIDTH 0.5f |
| 12 #define FX_EDIT_CROSSOUTHALFWIDTH 0.5f | 14 #define FX_EDIT_CROSSOUTHALFWIDTH 0.5f |
| 13 | 15 |
| 14 CPDF_Rect GetUnderLineRect(const CPVT_Word& word) { | 16 CPDF_Rect GetUnderLineRect(const CPVT_Word& word) { |
| 15 return CPDF_Rect(word.ptWord.x, word.ptWord.y + word.fDescent * 0.5f, | 17 return CPDF_Rect(word.ptWord.x, word.ptWord.y + word.fDescent * 0.5f, |
| 16 word.ptWord.x + word.fWidth, | 18 word.ptWord.x + word.fWidth, |
| 17 word.ptWord.y + word.fDescent * 0.25f); | 19 word.ptWord.y + word.fDescent * 0.25f); |
| 18 } | 20 } |
| 19 | 21 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 50 CPDF_Point pt1(0, 0), pt2(1, 0); | 52 CPDF_Point pt1(0, 0), pt2(1, 0); |
| 51 pUser2Device->Transform(pt1.x, pt1.y); | 53 pUser2Device->Transform(pt1.x, pt1.y); |
| 52 pUser2Device->Transform(pt2.x, pt2.y); | 54 pUser2Device->Transform(pt2.x, pt2.y); |
| 53 CFX_GraphStateData gsd; | 55 CFX_GraphStateData gsd; |
| 54 gsd.m_LineWidth = | 56 gsd.m_LineWidth = |
| 55 (FX_FLOAT)FXSYS_fabs((pt2.x + pt2.y) - (pt1.x + pt1.y)); | 57 (FX_FLOAT)FXSYS_fabs((pt2.x + pt2.y) - (pt1.x + pt1.y)); |
| 56 | 58 |
| 57 CPDF_TextRenderer::DrawTextString(pDevice, x, y, pFont, fFontSize, &mt, | 59 CPDF_TextRenderer::DrawTextString(pDevice, x, y, pFont, fFontSize, &mt, |
| 58 str, crTextFill, crTextStroke, &gsd, | 60 str, crTextFill, crTextStroke, &gsd, |
| 59 &ro); | 61 &ro); |
| 60 } else | 62 } else { |
| 61 CPDF_TextRenderer::DrawTextString(pDevice, x, y, pFont, fFontSize, &mt, | 63 CPDF_TextRenderer::DrawTextString(pDevice, x, y, pFont, fFontSize, &mt, |
| 62 str, crTextFill, 0, NULL, &ro); | 64 str, crTextFill, 0, NULL, &ro); |
| 65 } |
| 63 } else { | 66 } else { |
| 64 CPDF_RenderOptions ro; | 67 CPDF_RenderOptions ro; |
| 65 ro.m_Flags = RENDER_CLEARTYPE; | 68 ro.m_Flags = RENDER_CLEARTYPE; |
| 66 ro.m_ColorMode = RENDER_COLOR_NORMAL; | 69 ro.m_ColorMode = RENDER_COLOR_NORMAL; |
| 67 | 70 |
| 68 if (crTextStroke != 0) { | 71 if (crTextStroke != 0) { |
| 69 CPDF_Point pt1(0, 0), pt2(1, 0); | 72 CPDF_Point pt1(0, 0), pt2(1, 0); |
| 70 pUser2Device->Transform(pt1.x, pt1.y); | 73 pUser2Device->Transform(pt1.x, pt1.y); |
| 71 pUser2Device->Transform(pt2.x, pt2.y); | 74 pUser2Device->Transform(pt2.x, pt2.y); |
| 72 CFX_GraphStateData gsd; | 75 CFX_GraphStateData gsd; |
| 73 gsd.m_LineWidth = | 76 gsd.m_LineWidth = |
| 74 (FX_FLOAT)FXSYS_fabs((pt2.x + pt2.y) - (pt1.x + pt1.y)); | 77 (FX_FLOAT)FXSYS_fabs((pt2.x + pt2.y) - (pt1.x + pt1.y)); |
| 75 | 78 |
| 76 CPDF_TextRenderer::DrawTextString(pDevice, x, y, pFont, fFontSize, | 79 CPDF_TextRenderer::DrawTextString(pDevice, x, y, pFont, fFontSize, |
| 77 pUser2Device, str, crTextFill, | 80 pUser2Device, str, crTextFill, |
| 78 crTextStroke, &gsd, &ro); | 81 crTextStroke, &gsd, &ro); |
| 79 } else | 82 } else { |
| 80 CPDF_TextRenderer::DrawTextString(pDevice, x, y, pFont, fFontSize, | 83 CPDF_TextRenderer::DrawTextString(pDevice, x, y, pFont, fFontSize, |
| 81 pUser2Device, str, crTextFill, 0, | 84 pUser2Device, str, crTextFill, 0, |
| 82 NULL, &ro); | 85 NULL, &ro); |
| 86 } |
| 83 } | 87 } |
| 84 } | 88 } |
| 85 } | 89 } |
| 86 | 90 |
| 87 void IFX_Edit::DrawUnderline(CFX_RenderDevice* pDevice, | 91 void IFX_Edit::DrawUnderline(CFX_RenderDevice* pDevice, |
| 88 CFX_Matrix* pUser2Device, | 92 CFX_Matrix* pUser2Device, |
| 89 IFX_Edit* pEdit, | 93 IFX_Edit* pEdit, |
| 90 FX_COLORREF color, | 94 FX_COLORREF color, |
| 91 const CPDF_Rect& rcClip, | 95 const CPDF_Rect& rcClip, |
| 92 const CPDF_Point& ptOffset, | 96 const CPDF_Point& ptOffset, |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 if (pIterator->GetWord(word)) { | 215 if (pIterator->GetWord(word)) { |
| 212 if (bSelect) { | 216 if (bSelect) { |
| 213 CPVT_Line line; | 217 CPVT_Line line; |
| 214 pIterator->GetLine(line); | 218 pIterator->GetLine(line); |
| 215 | 219 |
| 216 if (pSystemHandler && pSystemHandler->IsSelectionImplemented()) { | 220 if (pSystemHandler && pSystemHandler->IsSelectionImplemented()) { |
| 217 CPDF_Rect rc(word.ptWord.x, line.ptLine.y + line.fLineDescent, | 221 CPDF_Rect rc(word.ptWord.x, line.ptLine.y + line.fLineDescent, |
| 218 word.ptWord.x + word.fWidth, | 222 word.ptWord.x + word.fWidth, |
| 219 line.ptLine.y + line.fLineAscent); | 223 line.ptLine.y + line.fLineAscent); |
| 220 rc.Intersect(rcClip); | 224 rc.Intersect(rcClip); |
| 221 // CFX_Edit* pEt = (CFX_Edit*)pEdit; | |
| 222 // CPDF_Rect rcEdit = pEt->VTToEdit(rc); | |
| 223 pSystemHandler->OutputSelectedRect(pFFLData, rc); | 225 pSystemHandler->OutputSelectedRect(pFFLData, rc); |
| 224 } else { | 226 } else { |
| 225 CFX_PathData pathSelBK; | 227 CFX_PathData pathSelBK; |
| 226 pathSelBK.AppendRect(word.ptWord.x, | 228 pathSelBK.AppendRect(word.ptWord.x, |
| 227 line.ptLine.y + line.fLineDescent, | 229 line.ptLine.y + line.fLineDescent, |
| 228 word.ptWord.x + word.fWidth, | 230 word.ptWord.x + word.fWidth, |
| 229 line.ptLine.y + line.fLineAscent); | 231 line.ptLine.y + line.fLineAscent); |
| 230 | 232 |
| 231 pDevice->DrawPath(&pathSelBK, pUser2Device, NULL, crSelBK, 0, | 233 pDevice->DrawPath(&pathSelBK, pUser2Device, NULL, crSelBK, 0, |
| 232 FXFILL_WINDING); | 234 FXFILL_WINDING); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 | 277 |
| 276 pDevice->RestoreState(); | 278 pDevice->RestoreState(); |
| 277 } | 279 } |
| 278 | 280 |
| 279 void IFX_Edit::DrawRichEdit(CFX_RenderDevice* pDevice, | 281 void IFX_Edit::DrawRichEdit(CFX_RenderDevice* pDevice, |
| 280 CFX_Matrix* pUser2Device, | 282 CFX_Matrix* pUser2Device, |
| 281 IFX_Edit* pEdit, | 283 IFX_Edit* pEdit, |
| 282 const CPDF_Rect& rcClip, | 284 const CPDF_Rect& rcClip, |
| 283 const CPDF_Point& ptOffset, | 285 const CPDF_Point& ptOffset, |
| 284 const CPVT_WordRange* pRange) { | 286 const CPVT_WordRange* pRange) { |
| 285 // FX_FLOAT fFontSize = pEdit->GetFontSize(); | |
| 286 CPVT_WordRange wrSelect = pEdit->GetSelectWordRange(); | 287 CPVT_WordRange wrSelect = pEdit->GetSelectWordRange(); |
| 287 | 288 |
| 288 FX_COLORREF crCurText = ArgbEncode(255, 0, 0, 0); | 289 FX_COLORREF crCurText = ArgbEncode(255, 0, 0, 0); |
| 289 FX_COLORREF crOld = crCurText; | 290 FX_COLORREF crOld = crCurText; |
| 290 FX_BOOL bSelect = FALSE; | 291 FX_BOOL bSelect = FALSE; |
| 291 const FX_COLORREF crWhite = ArgbEncode(255, 255, 255, 255); | 292 const FX_COLORREF crWhite = ArgbEncode(255, 255, 255, 255); |
| 292 const FX_COLORREF crSelBK = ArgbEncode(255, 0, 51, 113); | 293 const FX_COLORREF crSelBK = ArgbEncode(255, 0, 51, 113); |
| 293 | 294 |
| 294 CFX_ByteTextBuf sTextBuf; | 295 CFX_ByteTextBuf sTextBuf; |
| 295 CPVT_WordProps wp; | 296 CPVT_WordProps wp; |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 } | 582 } |
| 582 | 583 |
| 583 wp = word.WordProps; | 584 wp = word.WordProps; |
| 584 ptBT = word.ptWord; | 585 ptBT = word.ptWord; |
| 585 crOld = crCurText; | 586 crOld = crCurText; |
| 586 } | 587 } |
| 587 | 588 |
| 588 sTextBuf << GetPDFWordString(pFontMap, word.WordProps.nFontIndex, | 589 sTextBuf << GetPDFWordString(pFontMap, word.WordProps.nFontIndex, |
| 589 word.Word, 0); | 590 word.Word, 0); |
| 590 | 591 |
| 591 if (word.WordProps.nWordStyle & | 592 if (word.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) { |
| 592 PVTWORD_STYLE_UNDERLINE) { /* | |
| 593 AddLineToPageObjects(pPageObject
s, | |
| 594 crCurText, | |
| 595 CPDF_Point(word.ptWord.x
, | |
| 596 word.ptWord.y + word.fDescent * | |
| 597 0.4f), | |
| 598 CPDF_Point(word.ptWord.x | |
| 599 + word.fWidth, word.ptWord.y + | |
| 600 word.fDescent * 0.4f)); | |
| 601 */ | |
| 602 CPDF_Rect rcUnderline = GetUnderLineRect(word); | 593 CPDF_Rect rcUnderline = GetUnderLineRect(word); |
| 603 rcUnderline.left += ptOffset.x; | 594 rcUnderline.left += ptOffset.x; |
| 604 rcUnderline.right += ptOffset.x; | 595 rcUnderline.right += ptOffset.x; |
| 605 rcUnderline.top += ptOffset.y; | 596 rcUnderline.top += ptOffset.y; |
| 606 rcUnderline.bottom += ptOffset.y; | 597 rcUnderline.bottom += ptOffset.y; |
| 607 | 598 |
| 608 AddRectToPageObjects(pPageObjects, crCurText, rcUnderline); | 599 AddRectToPageObjects(pPageObjects, crCurText, rcUnderline); |
| 609 } | 600 } |
| 610 | 601 |
| 611 if (word.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) { | 602 if (word.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 rcUnderline.left += ptOffset.x; | 649 rcUnderline.left += ptOffset.x; |
| 659 rcUnderline.right += ptOffset.x; | 650 rcUnderline.right += ptOffset.x; |
| 660 rcUnderline.top += ptOffset.y; | 651 rcUnderline.top += ptOffset.y; |
| 661 rcUnderline.bottom += ptOffset.y; | 652 rcUnderline.bottom += ptOffset.y; |
| 662 AddRectToPageObjects(pPageObjects, color, rcUnderline); | 653 AddRectToPageObjects(pPageObjects, color, rcUnderline); |
| 663 } | 654 } |
| 664 } | 655 } |
| 665 } | 656 } |
| 666 } | 657 } |
| 667 } | 658 } |
| OLD | NEW |