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

Side by Side Diff: fpdfsdk/fxedit/fxet_edit.cpp

Issue 2341453002: CFX_FloatPoint default constructor and equals operators (Closed)
Patch Set: style Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/formfiller/cffl_formfiller.cpp ('k') | fpdfsdk/fxedit/fxet_list.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "fpdfsdk/fxedit/include/fxet_edit.h" 7 #include "fpdfsdk/fxedit/include/fxet_edit.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 if (pFont) { 68 if (pFont) {
69 if (nHorzScale != 100) { 69 if (nHorzScale != 100) {
70 CFX_Matrix mt(nHorzScale / 100.0f, 0, 0, 1, 0, 0); 70 CFX_Matrix mt(nHorzScale / 100.0f, 0, 0, 1, 0, 0);
71 mt.Concat(*pUser2Device); 71 mt.Concat(*pUser2Device);
72 72
73 CPDF_RenderOptions ro; 73 CPDF_RenderOptions ro;
74 ro.m_Flags = RENDER_CLEARTYPE; 74 ro.m_Flags = RENDER_CLEARTYPE;
75 ro.m_ColorMode = RENDER_COLOR_NORMAL; 75 ro.m_ColorMode = RENDER_COLOR_NORMAL;
76 76
77 if (crTextStroke != 0) { 77 if (crTextStroke != 0) {
78 CFX_FloatPoint pt1(0, 0), pt2(1, 0); 78 CFX_FloatPoint pt1;
79 CFX_FloatPoint pt2;
79 pUser2Device->Transform(pt1.x, pt1.y); 80 pUser2Device->Transform(pt1.x, pt1.y);
80 pUser2Device->Transform(pt2.x, pt2.y); 81 pUser2Device->Transform(pt2.x, pt2.y);
81 CFX_GraphStateData gsd; 82 CFX_GraphStateData gsd;
82 gsd.m_LineWidth = 83 gsd.m_LineWidth =
83 (FX_FLOAT)FXSYS_fabs((pt2.x + pt2.y) - (pt1.x + pt1.y)); 84 (FX_FLOAT)FXSYS_fabs((pt2.x + pt2.y) - (pt1.x + pt1.y));
84 85
85 CPDF_TextRenderer::DrawTextString(pDevice, x, y, pFont, fFontSize, &mt, 86 CPDF_TextRenderer::DrawTextString(pDevice, x, y, pFont, fFontSize, &mt,
86 str, crTextFill, crTextStroke, &gsd, 87 str, crTextFill, crTextStroke, &gsd,
87 &ro); 88 &ro);
88 } else { 89 } else {
89 CPDF_TextRenderer::DrawTextString(pDevice, x, y, pFont, fFontSize, &mt, 90 CPDF_TextRenderer::DrawTextString(pDevice, x, y, pFont, fFontSize, &mt,
90 str, crTextFill, 0, nullptr, &ro); 91 str, crTextFill, 0, nullptr, &ro);
91 } 92 }
92 } else { 93 } else {
93 CPDF_RenderOptions ro; 94 CPDF_RenderOptions ro;
94 ro.m_Flags = RENDER_CLEARTYPE; 95 ro.m_Flags = RENDER_CLEARTYPE;
95 ro.m_ColorMode = RENDER_COLOR_NORMAL; 96 ro.m_ColorMode = RENDER_COLOR_NORMAL;
96 97
97 if (crTextStroke != 0) { 98 if (crTextStroke != 0) {
98 CFX_FloatPoint pt1(0, 0), pt2(1, 0); 99 CFX_FloatPoint pt1;
100 CFX_FloatPoint pt2;
99 pUser2Device->Transform(pt1.x, pt1.y); 101 pUser2Device->Transform(pt1.x, pt1.y);
100 pUser2Device->Transform(pt2.x, pt2.y); 102 pUser2Device->Transform(pt2.x, pt2.y);
101 CFX_GraphStateData gsd; 103 CFX_GraphStateData gsd;
102 gsd.m_LineWidth = 104 gsd.m_LineWidth =
103 (FX_FLOAT)FXSYS_fabs((pt2.x + pt2.y) - (pt1.x + pt1.y)); 105 (FX_FLOAT)FXSYS_fabs((pt2.x + pt2.y) - (pt1.x + pt1.y));
104 106
105 CPDF_TextRenderer::DrawTextString(pDevice, x, y, pFont, fFontSize, 107 CPDF_TextRenderer::DrawTextString(pDevice, x, y, pFont, fFontSize,
106 pUser2Device, str, crTextFill, 108 pUser2Device, str, crTextFill,
107 crTextStroke, &gsd, &ro); 109 crTextStroke, &gsd, &ro);
108 } else { 110 } else {
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 uint16_t SubWord) { 677 uint16_t SubWord) {
676 CFX_Edit_Iterator* pIterator = pEdit->GetIterator(); 678 CFX_Edit_Iterator* pIterator = pEdit->GetIterator();
677 if (pRange) 679 if (pRange)
678 pIterator->SetAt(pRange->BeginPos); 680 pIterator->SetAt(pRange->BeginPos);
679 else 681 else
680 pIterator->SetAt(0); 682 pIterator->SetAt(0);
681 683
682 CFX_ByteTextBuf sEditStream; 684 CFX_ByteTextBuf sEditStream;
683 CFX_ByteTextBuf sWords; 685 CFX_ByteTextBuf sWords;
684 int32_t nCurFontIndex = -1; 686 int32_t nCurFontIndex = -1;
685 CFX_FloatPoint ptOld(0.0f, 0.0f); 687 CFX_FloatPoint ptOld;
686 CFX_FloatPoint ptNew(0.0f, 0.0f); 688 CFX_FloatPoint ptNew;
687 CPVT_WordPlace oldplace; 689 CPVT_WordPlace oldplace;
690
688 while (pIterator->NextWord()) { 691 while (pIterator->NextWord()) {
689 CPVT_WordPlace place = pIterator->GetAt(); 692 CPVT_WordPlace place = pIterator->GetAt();
690
691 if (pRange && place.WordCmp(pRange->EndPos) > 0) 693 if (pRange && place.WordCmp(pRange->EndPos) > 0)
692 break; 694 break;
693 695
694 if (bContinuous) { 696 if (bContinuous) {
695 if (place.LineCmp(oldplace) != 0) { 697 if (place.LineCmp(oldplace) != 0) {
696 if (sWords.GetSize() > 0) { 698 if (sWords.GetSize() > 0) {
697 sEditStream << GetWordRenderString(sWords.MakeString()); 699 sEditStream << GetWordRenderString(sWords.MakeString());
698 sWords.Clear(); 700 sWords.Clear();
699 } 701 }
700 702
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 832
831 FX_COLORREF crCurFill = crTextFill; 833 FX_COLORREF crCurFill = crTextFill;
832 FX_COLORREF crOldFill = crCurFill; 834 FX_COLORREF crOldFill = crCurFill;
833 835
834 FX_BOOL bSelect = FALSE; 836 FX_BOOL bSelect = FALSE;
835 const FX_COLORREF crWhite = ArgbEncode(255, 255, 255, 255); 837 const FX_COLORREF crWhite = ArgbEncode(255, 255, 255, 255);
836 const FX_COLORREF crSelBK = ArgbEncode(255, 0, 51, 113); 838 const FX_COLORREF crSelBK = ArgbEncode(255, 0, 51, 113);
837 839
838 CFX_ByteTextBuf sTextBuf; 840 CFX_ByteTextBuf sTextBuf;
839 int32_t nFontIndex = -1; 841 int32_t nFontIndex = -1;
840 CFX_FloatPoint ptBT(0.0f, 0.0f); 842 CFX_FloatPoint ptBT;
841
842 pDevice->SaveState(); 843 pDevice->SaveState();
843
844 if (!rcClip.IsEmpty()) { 844 if (!rcClip.IsEmpty()) {
845 CFX_FloatRect rcTemp = rcClip; 845 CFX_FloatRect rcTemp = rcClip;
846 pUser2Device->TransformRect(rcTemp); 846 pUser2Device->TransformRect(rcTemp);
847 pDevice->SetClip_Rect(rcTemp.ToFxRect()); 847 pDevice->SetClip_Rect(rcTemp.ToFxRect());
848 } 848 }
849 849
850 CFX_Edit_Iterator* pIterator = pEdit->GetIterator(); 850 CFX_Edit_Iterator* pIterator = pEdit->GetIterator();
851 if (IPVT_FontMap* pFontMap = pEdit->GetFontMap()) { 851 if (IPVT_FontMap* pFontMap = pEdit->GetFontMap()) {
852 if (pRange) 852 if (pRange)
853 pIterator->SetAt(pRange->BeginPos); 853 pIterator->SetAt(pRange->BeginPos);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 } 998 }
999 } 999 }
1000 1000
1001 CFX_Edit::CFX_Edit() 1001 CFX_Edit::CFX_Edit()
1002 : m_pVT(new CPDF_VariableText), 1002 : m_pVT(new CPDF_VariableText),
1003 m_pNotify(nullptr), 1003 m_pNotify(nullptr),
1004 m_pOprNotify(nullptr), 1004 m_pOprNotify(nullptr),
1005 m_wpCaret(-1, -1, -1), 1005 m_wpCaret(-1, -1, -1),
1006 m_wpOldCaret(-1, -1, -1), 1006 m_wpOldCaret(-1, -1, -1),
1007 m_SelState(), 1007 m_SelState(),
1008 m_ptScrollPos(0, 0),
1009 m_ptRefreshScrollPos(0, 0),
1010 m_bEnableScroll(FALSE), 1008 m_bEnableScroll(FALSE),
1011 m_ptCaret(0.0f, 0.0f),
1012 m_Undo(kEditUndoMaxItems), 1009 m_Undo(kEditUndoMaxItems),
1013 m_nAlignment(0), 1010 m_nAlignment(0),
1014 m_bNotifyFlag(FALSE), 1011 m_bNotifyFlag(FALSE),
1015 m_bEnableOverflow(FALSE), 1012 m_bEnableOverflow(FALSE),
1016 m_bEnableRefresh(TRUE), 1013 m_bEnableRefresh(TRUE),
1017 m_rcOldContent(0.0f, 0.0f, 0.0f, 0.0f), 1014 m_rcOldContent(0.0f, 0.0f, 0.0f, 0.0f),
1018 m_bEnableUndo(TRUE), 1015 m_bEnableUndo(TRUE),
1019 m_bOprNotify(FALSE), 1016 m_bOprNotify(FALSE),
1020 m_pGroupUndoItem(nullptr) {} 1017 m_pGroupUndoItem(nullptr) {}
1021 1018
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
1569 } 1566 }
1570 } 1567 }
1571 } 1568 }
1572 1569
1573 void CFX_Edit::ScrollToCaret() { 1570 void CFX_Edit::ScrollToCaret() {
1574 SetScrollLimit(); 1571 SetScrollLimit();
1575 1572
1576 if (!m_pVT->IsValid()) 1573 if (!m_pVT->IsValid())
1577 return; 1574 return;
1578 1575
1579 CFX_FloatPoint ptHead(0, 0);
1580 CFX_FloatPoint ptFoot(0, 0);
1581
1582 CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator(); 1576 CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator();
1583 pIterator->SetAt(m_wpCaret); 1577 pIterator->SetAt(m_wpCaret);
1584 1578
1579 CFX_FloatPoint ptHead;
1580 CFX_FloatPoint ptFoot;
1585 CPVT_Word word; 1581 CPVT_Word word;
1586 CPVT_Line line; 1582 CPVT_Line line;
1587 if (pIterator->GetWord(word)) { 1583 if (pIterator->GetWord(word)) {
1588 ptHead.x = word.ptWord.x + word.fWidth; 1584 ptHead.x = word.ptWord.x + word.fWidth;
1589 ptHead.y = word.ptWord.y + word.fAscent; 1585 ptHead.y = word.ptWord.y + word.fAscent;
1590 ptFoot.x = word.ptWord.x + word.fWidth; 1586 ptFoot.x = word.ptWord.x + word.fWidth;
1591 ptFoot.y = word.ptWord.y + word.fDescent; 1587 ptFoot.y = word.ptWord.y + word.fDescent;
1592 } else if (pIterator->GetLine(line)) { 1588 } else if (pIterator->GetLine(line)) {
1593 ptHead.x = line.ptLine.x; 1589 ptHead.x = line.ptLine.x;
1594 ptHead.y = line.ptLine.y + line.fLineAscent; 1590 ptHead.y = line.ptLine.y + line.fLineAscent;
1595 ptFoot.x = line.ptLine.x; 1591 ptFoot.x = line.ptLine.x;
1596 ptFoot.y = line.ptLine.y + line.fLineDescent; 1592 ptFoot.y = line.ptLine.y + line.fLineDescent;
1597 } 1593 }
1598 1594
1599 CFX_FloatPoint ptHeadEdit = VTToEdit(ptHead); 1595 CFX_FloatPoint ptHeadEdit = VTToEdit(ptHead);
1600 CFX_FloatPoint ptFootEdit = VTToEdit(ptFoot); 1596 CFX_FloatPoint ptFootEdit = VTToEdit(ptFoot);
1601
1602 CFX_FloatRect rcPlate = m_pVT->GetPlateRect(); 1597 CFX_FloatRect rcPlate = m_pVT->GetPlateRect();
1603
1604 if (!IsFloatEqual(rcPlate.left, rcPlate.right)) { 1598 if (!IsFloatEqual(rcPlate.left, rcPlate.right)) {
1605 if (IsFloatSmaller(ptHeadEdit.x, rcPlate.left) || 1599 if (IsFloatSmaller(ptHeadEdit.x, rcPlate.left) ||
1606 IsFloatEqual(ptHeadEdit.x, rcPlate.left)) { 1600 IsFloatEqual(ptHeadEdit.x, rcPlate.left)) {
1607 SetScrollPosX(ptHead.x); 1601 SetScrollPosX(ptHead.x);
1608 } else if (IsFloatBigger(ptHeadEdit.x, rcPlate.right)) { 1602 } else if (IsFloatBigger(ptHeadEdit.x, rcPlate.right)) {
1609 SetScrollPosX(ptHead.x - rcPlate.Width()); 1603 SetScrollPosX(ptHead.x - rcPlate.Width());
1610 } 1604 }
1611 } 1605 }
1612 1606
1613 if (!IsFloatEqual(rcPlate.top, rcPlate.bottom)) { 1607 if (!IsFloatEqual(rcPlate.top, rcPlate.bottom)) {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1731 } 1725 }
1732 1726
1733 void CFX_Edit::SetCaret(const CPVT_WordPlace& place) { 1727 void CFX_Edit::SetCaret(const CPVT_WordPlace& place) {
1734 m_wpOldCaret = m_wpCaret; 1728 m_wpOldCaret = m_wpCaret;
1735 m_wpCaret = place; 1729 m_wpCaret = place;
1736 } 1730 }
1737 1731
1738 void CFX_Edit::SetCaretInfo() { 1732 void CFX_Edit::SetCaretInfo() {
1739 if (m_pNotify) { 1733 if (m_pNotify) {
1740 if (!m_bNotifyFlag) { 1734 if (!m_bNotifyFlag) {
1741 CFX_FloatPoint ptHead(0.0f, 0.0f), ptFoot(0.0f, 0.0f);
1742
1743 CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator(); 1735 CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator();
1744 pIterator->SetAt(m_wpCaret); 1736 pIterator->SetAt(m_wpCaret);
1737
1738 CFX_FloatPoint ptHead;
1739 CFX_FloatPoint ptFoot;
1745 CPVT_Word word; 1740 CPVT_Word word;
1746 CPVT_Line line; 1741 CPVT_Line line;
1747 if (pIterator->GetWord(word)) { 1742 if (pIterator->GetWord(word)) {
1748 ptHead.x = word.ptWord.x + word.fWidth; 1743 ptHead.x = word.ptWord.x + word.fWidth;
1749 ptHead.y = word.ptWord.y + word.fAscent; 1744 ptHead.y = word.ptWord.y + word.fAscent;
1750 ptFoot.x = word.ptWord.x + word.fWidth; 1745 ptFoot.x = word.ptWord.x + word.fWidth;
1751 ptFoot.y = word.ptWord.y + word.fDescent; 1746 ptFoot.y = word.ptWord.y + word.fDescent;
1752 } else if (pIterator->GetLine(line)) { 1747 } else if (pIterator->GetLine(line)) {
1753 ptHead.x = line.ptLine.x; 1748 ptHead.x = line.ptLine.x;
1754 ptHead.y = line.ptLine.y + line.fLineAscent; 1749 ptHead.y = line.ptLine.y + line.fLineAscent;
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
2529 int32_t CFX_Edit_RectArray::GetSize() const { 2524 int32_t CFX_Edit_RectArray::GetSize() const {
2530 return m_Rects.GetSize(); 2525 return m_Rects.GetSize();
2531 } 2526 }
2532 2527
2533 CFX_FloatRect* CFX_Edit_RectArray::GetAt(int32_t nIndex) const { 2528 CFX_FloatRect* CFX_Edit_RectArray::GetAt(int32_t nIndex) const {
2534 if (nIndex < 0 || nIndex >= m_Rects.GetSize()) 2529 if (nIndex < 0 || nIndex >= m_Rects.GetSize())
2535 return nullptr; 2530 return nullptr;
2536 2531
2537 return m_Rects.GetAt(nIndex); 2532 return m_Rects.GetAt(nIndex);
2538 } 2533 }
OLDNEW
« no previous file with comments | « fpdfsdk/formfiller/cffl_formfiller.cpp ('k') | fpdfsdk/fxedit/fxet_list.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698