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 "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 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 m_ptRefreshScrollPos(0, 0), | 781 m_ptRefreshScrollPos(0, 0), |
782 m_bEnableScroll(FALSE), | 782 m_bEnableScroll(FALSE), |
783 m_ptCaret(0.0f, 0.0f), | 783 m_ptCaret(0.0f, 0.0f), |
784 m_Undo(kEditUndoMaxItems), | 784 m_Undo(kEditUndoMaxItems), |
785 m_nAlignment(0), | 785 m_nAlignment(0), |
786 m_bNotifyFlag(FALSE), | 786 m_bNotifyFlag(FALSE), |
787 m_bEnableOverflow(FALSE), | 787 m_bEnableOverflow(FALSE), |
788 m_bEnableRefresh(TRUE), | 788 m_bEnableRefresh(TRUE), |
789 m_rcOldContent(0.0f, 0.0f, 0.0f, 0.0f), | 789 m_rcOldContent(0.0f, 0.0f, 0.0f, 0.0f), |
790 m_bEnableUndo(TRUE), | 790 m_bEnableUndo(TRUE), |
791 m_bNotify(TRUE), | |
792 m_bOprNotify(FALSE), | 791 m_bOprNotify(FALSE), |
793 m_pGroupUndoItem(nullptr) { | 792 m_pGroupUndoItem(nullptr) { |
794 ASSERT(pVT); | 793 ASSERT(pVT); |
795 } | 794 } |
796 | 795 |
797 CFX_Edit::~CFX_Edit() { | 796 CFX_Edit::~CFX_Edit() { |
798 ASSERT(!m_pGroupUndoItem); | 797 ASSERT(!m_pGroupUndoItem); |
799 } | 798 } |
800 | 799 |
801 void CFX_Edit::Initialize() { | 800 void CFX_Edit::Initialize() { |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1093 FX_BOOL CFX_Edit::IsRichText() const { | 1092 FX_BOOL CFX_Edit::IsRichText() const { |
1094 return m_pVT->IsRichText(); | 1093 return m_pVT->IsRichText(); |
1095 } | 1094 } |
1096 | 1095 |
1097 void CFX_Edit::SetRichText(FX_BOOL bRichText, FX_BOOL bPaint) { | 1096 void CFX_Edit::SetRichText(FX_BOOL bRichText, FX_BOOL bPaint) { |
1098 m_pVT->SetRichText(bRichText); | 1097 m_pVT->SetRichText(bRichText); |
1099 if (bPaint) | 1098 if (bPaint) |
1100 Paint(); | 1099 Paint(); |
1101 } | 1100 } |
1102 | 1101 |
1103 FX_BOOL CFX_Edit::SetRichFontIndex(int32_t nFontIndex) { | |
1104 CPVT_WordProps WordProps; | |
1105 WordProps.nFontIndex = nFontIndex; | |
1106 return SetRichTextProps(EP_FONTINDEX, nullptr, &WordProps); | |
1107 } | |
1108 | |
1109 FX_BOOL CFX_Edit::SetRichFontSize(FX_FLOAT fFontSize) { | |
1110 CPVT_WordProps WordProps; | |
1111 WordProps.fFontSize = fFontSize; | |
1112 return SetRichTextProps(EP_FONTSIZE, nullptr, &WordProps); | |
1113 } | |
1114 | |
1115 FX_BOOL CFX_Edit::SetRichTextColor(FX_COLORREF dwColor) { | |
1116 CPVT_WordProps WordProps; | |
1117 WordProps.dwWordColor = dwColor; | |
1118 return SetRichTextProps(EP_WORDCOLOR, nullptr, &WordProps); | |
1119 } | |
1120 | |
1121 FX_BOOL CFX_Edit::SetRichTextScript(CPDF_VariableText::ScriptType nScriptType) { | |
1122 CPVT_WordProps WordProps; | |
1123 WordProps.nScriptType = nScriptType; | |
1124 return SetRichTextProps(EP_SCRIPTTYPE, nullptr, &WordProps); | |
1125 } | |
1126 | |
1127 FX_BOOL CFX_Edit::SetRichTextBold(FX_BOOL bBold) { | |
1128 CPVT_WordProps WordProps; | |
1129 if (bBold) | |
1130 WordProps.nWordStyle |= PVTWORD_STYLE_BOLD; | |
1131 return SetRichTextProps(EP_BOLD, nullptr, &WordProps); | |
1132 } | |
1133 | |
1134 FX_BOOL CFX_Edit::SetRichTextItalic(FX_BOOL bItalic) { | |
1135 CPVT_WordProps WordProps; | |
1136 if (bItalic) | |
1137 WordProps.nWordStyle |= PVTWORD_STYLE_ITALIC; | |
1138 return SetRichTextProps(EP_ITALIC, nullptr, &WordProps); | |
1139 } | |
1140 | |
1141 FX_BOOL CFX_Edit::SetRichTextUnderline(FX_BOOL bUnderline) { | |
1142 CPVT_WordProps WordProps; | |
1143 if (bUnderline) | |
1144 WordProps.nWordStyle |= PVTWORD_STYLE_UNDERLINE; | |
1145 return SetRichTextProps(EP_UNDERLINE, nullptr, &WordProps); | |
1146 } | |
1147 | |
1148 FX_BOOL CFX_Edit::SetRichTextCrossout(FX_BOOL bCrossout) { | |
1149 CPVT_WordProps WordProps; | |
1150 if (bCrossout) | |
1151 WordProps.nWordStyle |= PVTWORD_STYLE_CROSSOUT; | |
1152 return SetRichTextProps(EP_CROSSOUT, nullptr, &WordProps); | |
1153 } | |
1154 | |
1155 FX_BOOL CFX_Edit::SetRichTextCharSpace(FX_FLOAT fCharSpace) { | |
1156 CPVT_WordProps WordProps; | |
1157 WordProps.fCharSpace = fCharSpace; | |
1158 return SetRichTextProps(EP_CHARSPACE, nullptr, &WordProps); | |
1159 } | |
1160 | |
1161 FX_BOOL CFX_Edit::SetRichTextHorzScale(int32_t nHorzScale) { | |
1162 CPVT_WordProps WordProps; | |
1163 WordProps.nHorzScale = nHorzScale; | |
1164 return SetRichTextProps(EP_HORZSCALE, nullptr, &WordProps); | |
1165 } | |
1166 | |
1167 FX_BOOL CFX_Edit::SetRichTextLineLeading(FX_FLOAT fLineLeading) { | |
1168 CPVT_SecProps SecProps; | |
1169 SecProps.fLineLeading = fLineLeading; | |
1170 return SetRichTextProps(EP_LINELEADING, &SecProps, nullptr); | |
1171 } | |
1172 | |
1173 FX_BOOL CFX_Edit::SetRichTextLineIndent(FX_FLOAT fLineIndent) { | |
1174 CPVT_SecProps SecProps; | |
1175 SecProps.fLineIndent = fLineIndent; | |
1176 return SetRichTextProps(EP_LINEINDENT, &SecProps, nullptr); | |
1177 } | |
1178 | |
1179 FX_BOOL CFX_Edit::SetRichTextAlignment(int32_t nAlignment) { | |
1180 CPVT_SecProps SecProps; | |
1181 SecProps.nAlignment = nAlignment; | |
1182 return SetRichTextProps(EP_ALIGNMENT, &SecProps, nullptr); | |
1183 } | |
1184 | |
1185 FX_BOOL CFX_Edit::SetRichTextProps(EDIT_PROPS_E eProps, | |
1186 const CPVT_SecProps* pSecProps, | |
1187 const CPVT_WordProps* pWordProps) { | |
1188 if (!m_pVT->IsValid() || !m_pVT->IsRichText()) | |
1189 return FALSE; | |
1190 | |
1191 CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator(); | |
1192 CPVT_WordRange wrTemp = m_SelState.ConvertToWordRange(); | |
1193 | |
1194 m_pVT->UpdateWordPlace(wrTemp.BeginPos); | |
1195 m_pVT->UpdateWordPlace(wrTemp.EndPos); | |
1196 pIterator->SetAt(wrTemp.BeginPos); | |
1197 | |
1198 BeginGroupUndo(L""); | |
1199 FX_BOOL bSet = | |
1200 SetSecProps(eProps, wrTemp.BeginPos, pSecProps, pWordProps, wrTemp, TRUE); | |
1201 | |
1202 while (pIterator->NextWord()) { | |
1203 CPVT_WordPlace place = pIterator->GetAt(); | |
1204 if (place.WordCmp(wrTemp.EndPos) > 0) | |
1205 break; | |
1206 FX_BOOL bSet1 = | |
1207 SetSecProps(eProps, place, pSecProps, pWordProps, wrTemp, TRUE); | |
1208 FX_BOOL bSet2 = SetWordProps(eProps, place, pWordProps, wrTemp, TRUE); | |
1209 | |
1210 if (!bSet) | |
1211 bSet = (bSet1 || bSet2); | |
1212 } | |
1213 | |
1214 EndGroupUndo(); | |
1215 | |
1216 if (bSet) | |
1217 PaintSetProps(eProps, wrTemp); | |
1218 | |
1219 return bSet; | |
1220 } | |
1221 | |
1222 void CFX_Edit::PaintSetProps(EDIT_PROPS_E eProps, const CPVT_WordRange& wr) { | 1102 void CFX_Edit::PaintSetProps(EDIT_PROPS_E eProps, const CPVT_WordRange& wr) { |
1223 switch (eProps) { | 1103 switch (eProps) { |
1224 case EP_LINELEADING: | 1104 case EP_LINELEADING: |
1225 case EP_LINEINDENT: | 1105 case EP_LINEINDENT: |
1226 case EP_ALIGNMENT: | 1106 case EP_ALIGNMENT: |
1227 RearrangePart(wr); | 1107 RearrangePart(wr); |
1228 ScrollToCaret(); | 1108 ScrollToCaret(); |
1229 Refresh(RP_ANALYSE); | 1109 Refresh(RP_ANALYSE); |
1230 SetCaretOrigin(); | 1110 SetCaretOrigin(); |
1231 SetCaretInfo(); | 1111 SetCaretInfo(); |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1687 if (m_pVT->IsValid()) { | 1567 if (m_pVT->IsValid()) { |
1688 m_pVT->UpdateWordPlace(m_wpCaret); | 1568 m_pVT->UpdateWordPlace(m_wpCaret); |
1689 m_pVT->RearrangePart(range); | 1569 m_pVT->RearrangePart(range); |
1690 m_pVT->UpdateWordPlace(m_wpCaret); | 1570 m_pVT->UpdateWordPlace(m_wpCaret); |
1691 SetScrollInfo(); | 1571 SetScrollInfo(); |
1692 SetContentChanged(); | 1572 SetContentChanged(); |
1693 } | 1573 } |
1694 } | 1574 } |
1695 | 1575 |
1696 void CFX_Edit::SetContentChanged() { | 1576 void CFX_Edit::SetContentChanged() { |
1697 if (m_bNotify && m_pNotify) { | 1577 if (m_pNotify) { |
1698 CFX_FloatRect rcContent = m_pVT->GetContentRect(); | 1578 CFX_FloatRect rcContent = m_pVT->GetContentRect(); |
1699 if (rcContent.Width() != m_rcOldContent.Width() || | 1579 if (rcContent.Width() != m_rcOldContent.Width() || |
1700 rcContent.Height() != m_rcOldContent.Height()) { | 1580 rcContent.Height() != m_rcOldContent.Height()) { |
1701 if (!m_bNotifyFlag) { | 1581 if (!m_bNotifyFlag) { |
1702 m_bNotifyFlag = TRUE; | 1582 m_bNotifyFlag = TRUE; |
1703 m_pNotify->IOnContentChange(rcContent); | 1583 m_pNotify->IOnContentChange(rcContent); |
1704 m_bNotifyFlag = FALSE; | 1584 m_bNotifyFlag = FALSE; |
1705 } | 1585 } |
1706 m_rcOldContent = rcContent; | 1586 m_rcOldContent = rcContent; |
1707 } | 1587 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1790 CFX_FloatRect CFX_Edit::EditToVT(const CFX_FloatRect& rect) const { | 1670 CFX_FloatRect CFX_Edit::EditToVT(const CFX_FloatRect& rect) const { |
1791 CFX_FloatPoint ptLeftBottom = | 1671 CFX_FloatPoint ptLeftBottom = |
1792 EditToVT(CFX_FloatPoint(rect.left, rect.bottom)); | 1672 EditToVT(CFX_FloatPoint(rect.left, rect.bottom)); |
1793 CFX_FloatPoint ptRightTop = EditToVT(CFX_FloatPoint(rect.right, rect.top)); | 1673 CFX_FloatPoint ptRightTop = EditToVT(CFX_FloatPoint(rect.right, rect.top)); |
1794 | 1674 |
1795 return CFX_FloatRect(ptLeftBottom.x, ptLeftBottom.y, ptRightTop.x, | 1675 return CFX_FloatRect(ptLeftBottom.x, ptLeftBottom.y, ptRightTop.x, |
1796 ptRightTop.y); | 1676 ptRightTop.y); |
1797 } | 1677 } |
1798 | 1678 |
1799 void CFX_Edit::SetScrollInfo() { | 1679 void CFX_Edit::SetScrollInfo() { |
1800 if (m_bNotify && m_pNotify) { | 1680 if (m_pNotify) { |
1801 CFX_FloatRect rcPlate = m_pVT->GetPlateRect(); | 1681 CFX_FloatRect rcPlate = m_pVT->GetPlateRect(); |
1802 CFX_FloatRect rcContent = m_pVT->GetContentRect(); | 1682 CFX_FloatRect rcContent = m_pVT->GetContentRect(); |
1803 | 1683 |
1804 if (!m_bNotifyFlag) { | 1684 if (!m_bNotifyFlag) { |
1805 m_bNotifyFlag = TRUE; | 1685 m_bNotifyFlag = TRUE; |
1806 m_pNotify->IOnSetScrollInfoX(rcPlate.left, rcPlate.right, rcContent.left, | 1686 m_pNotify->IOnSetScrollInfoX(rcPlate.left, rcPlate.right, rcContent.left, |
1807 rcContent.right, rcPlate.Width() / 3, | 1687 rcContent.right, rcPlate.Width() / 3, |
1808 rcPlate.Width()); | 1688 rcPlate.Width()); |
1809 | 1689 |
1810 m_pNotify->IOnSetScrollInfoY(rcPlate.bottom, rcPlate.top, | 1690 m_pNotify->IOnSetScrollInfoY(rcPlate.bottom, rcPlate.top, |
1811 rcContent.bottom, rcContent.top, | 1691 rcContent.bottom, rcContent.top, |
1812 rcPlate.Height() / 3, rcPlate.Height()); | 1692 rcPlate.Height() / 3, rcPlate.Height()); |
1813 m_bNotifyFlag = FALSE; | 1693 m_bNotifyFlag = FALSE; |
1814 } | 1694 } |
1815 } | 1695 } |
1816 } | 1696 } |
1817 | 1697 |
1818 void CFX_Edit::SetScrollPosX(FX_FLOAT fx) { | 1698 void CFX_Edit::SetScrollPosX(FX_FLOAT fx) { |
1819 if (!m_bEnableScroll) | 1699 if (!m_bEnableScroll) |
1820 return; | 1700 return; |
1821 | 1701 |
1822 if (m_pVT->IsValid()) { | 1702 if (m_pVT->IsValid()) { |
1823 if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.x, fx)) { | 1703 if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.x, fx)) { |
1824 m_ptScrollPos.x = fx; | 1704 m_ptScrollPos.x = fx; |
1825 Refresh(RP_NOANALYSE); | 1705 Refresh(RP_NOANALYSE); |
1826 | 1706 |
1827 if (m_bNotify && m_pNotify) { | 1707 if (m_pNotify) { |
1828 if (!m_bNotifyFlag) { | 1708 if (!m_bNotifyFlag) { |
1829 m_bNotifyFlag = TRUE; | 1709 m_bNotifyFlag = TRUE; |
1830 m_pNotify->IOnSetScrollPosX(fx); | 1710 m_pNotify->IOnSetScrollPosX(fx); |
1831 m_bNotifyFlag = FALSE; | 1711 m_bNotifyFlag = FALSE; |
1832 } | 1712 } |
1833 } | 1713 } |
1834 } | 1714 } |
1835 } | 1715 } |
1836 } | 1716 } |
1837 | 1717 |
1838 void CFX_Edit::SetScrollPosY(FX_FLOAT fy) { | 1718 void CFX_Edit::SetScrollPosY(FX_FLOAT fy) { |
1839 if (!m_bEnableScroll) | 1719 if (!m_bEnableScroll) |
1840 return; | 1720 return; |
1841 | 1721 |
1842 if (m_pVT->IsValid()) { | 1722 if (m_pVT->IsValid()) { |
1843 if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.y, fy)) { | 1723 if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.y, fy)) { |
1844 m_ptScrollPos.y = fy; | 1724 m_ptScrollPos.y = fy; |
1845 Refresh(RP_NOANALYSE); | 1725 Refresh(RP_NOANALYSE); |
1846 | 1726 |
1847 if (m_bNotify && m_pNotify) { | 1727 if (m_pNotify) { |
1848 if (!m_bNotifyFlag) { | 1728 if (!m_bNotifyFlag) { |
1849 m_bNotifyFlag = TRUE; | 1729 m_bNotifyFlag = TRUE; |
1850 m_pNotify->IOnSetScrollPosY(fy); | 1730 m_pNotify->IOnSetScrollPosY(fy); |
1851 m_bNotifyFlag = FALSE; | 1731 m_bNotifyFlag = FALSE; |
1852 } | 1732 } |
1853 } | 1733 } |
1854 } | 1734 } |
1855 } | 1735 } |
1856 } | 1736 } |
1857 | 1737 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1952 void CFX_Edit::Refresh(REFRESH_PLAN_E ePlan, | 1832 void CFX_Edit::Refresh(REFRESH_PLAN_E ePlan, |
1953 const CPVT_WordRange* pRange1, | 1833 const CPVT_WordRange* pRange1, |
1954 const CPVT_WordRange* pRange2) { | 1834 const CPVT_WordRange* pRange2) { |
1955 if (m_bEnableRefresh && m_pVT->IsValid()) { | 1835 if (m_bEnableRefresh && m_pVT->IsValid()) { |
1956 m_Refresh.BeginRefresh(); | 1836 m_Refresh.BeginRefresh(); |
1957 RefreshPushLineRects(GetVisibleWordRange()); | 1837 RefreshPushLineRects(GetVisibleWordRange()); |
1958 | 1838 |
1959 m_Refresh.NoAnalyse(); | 1839 m_Refresh.NoAnalyse(); |
1960 m_ptRefreshScrollPos = m_ptScrollPos; | 1840 m_ptRefreshScrollPos = m_ptScrollPos; |
1961 | 1841 |
1962 if (m_bNotify && m_pNotify) { | 1842 if (m_pNotify) { |
1963 if (!m_bNotifyFlag) { | 1843 if (!m_bNotifyFlag) { |
1964 m_bNotifyFlag = TRUE; | 1844 m_bNotifyFlag = TRUE; |
1965 if (const CFX_Edit_RectArray* pRects = m_Refresh.GetRefreshRects()) { | 1845 if (const CFX_Edit_RectArray* pRects = m_Refresh.GetRefreshRects()) { |
1966 for (int32_t i = 0, sz = pRects->GetSize(); i < sz; i++) | 1846 for (int32_t i = 0, sz = pRects->GetSize(); i < sz; i++) |
1967 m_pNotify->IOnInvalidateRect(pRects->GetAt(i)); | 1847 m_pNotify->IOnInvalidateRect(pRects->GetAt(i)); |
1968 } | 1848 } |
1969 m_bNotifyFlag = FALSE; | 1849 m_bNotifyFlag = FALSE; |
1970 } | 1850 } |
1971 } | 1851 } |
1972 | 1852 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2066 pIterator->GetWord(wordinfo); | 1946 pIterator->GetWord(wordinfo); |
2067 pIterator->GetLine(lineinfo); | 1947 pIterator->GetLine(lineinfo); |
2068 | 1948 |
2069 if (place.LineCmp(wrTemp.BeginPos) == 0 || | 1949 if (place.LineCmp(wrTemp.BeginPos) == 0 || |
2070 place.LineCmp(wrTemp.EndPos) == 0) { | 1950 place.LineCmp(wrTemp.EndPos) == 0) { |
2071 CFX_FloatRect rcWord(wordinfo.ptWord.x, | 1951 CFX_FloatRect rcWord(wordinfo.ptWord.x, |
2072 lineinfo.ptLine.y + lineinfo.fLineDescent, | 1952 lineinfo.ptLine.y + lineinfo.fLineDescent, |
2073 wordinfo.ptWord.x + wordinfo.fWidth, | 1953 wordinfo.ptWord.x + wordinfo.fWidth, |
2074 lineinfo.ptLine.y + lineinfo.fLineAscent); | 1954 lineinfo.ptLine.y + lineinfo.fLineAscent); |
2075 | 1955 |
2076 if (m_bNotify && m_pNotify) { | 1956 if (m_pNotify) { |
2077 if (!m_bNotifyFlag) { | 1957 if (!m_bNotifyFlag) { |
2078 m_bNotifyFlag = TRUE; | 1958 m_bNotifyFlag = TRUE; |
2079 CFX_FloatRect rcRefresh = VTToEdit(rcWord); | 1959 CFX_FloatRect rcRefresh = VTToEdit(rcWord); |
2080 m_pNotify->IOnInvalidateRect(&rcRefresh); | 1960 m_pNotify->IOnInvalidateRect(&rcRefresh); |
2081 m_bNotifyFlag = FALSE; | 1961 m_bNotifyFlag = FALSE; |
2082 } | 1962 } |
2083 } | 1963 } |
2084 } else { | 1964 } else { |
2085 CFX_FloatRect rcLine(lineinfo.ptLine.x, | 1965 CFX_FloatRect rcLine(lineinfo.ptLine.x, |
2086 lineinfo.ptLine.y + lineinfo.fLineDescent, | 1966 lineinfo.ptLine.y + lineinfo.fLineDescent, |
2087 lineinfo.ptLine.x + lineinfo.fLineWidth, | 1967 lineinfo.ptLine.x + lineinfo.fLineWidth, |
2088 lineinfo.ptLine.y + lineinfo.fLineAscent); | 1968 lineinfo.ptLine.y + lineinfo.fLineAscent); |
2089 | 1969 |
2090 if (m_bNotify && m_pNotify) { | 1970 if (m_pNotify) { |
2091 if (!m_bNotifyFlag) { | 1971 if (!m_bNotifyFlag) { |
2092 m_bNotifyFlag = TRUE; | 1972 m_bNotifyFlag = TRUE; |
2093 CFX_FloatRect rcRefresh = VTToEdit(rcLine); | 1973 CFX_FloatRect rcRefresh = VTToEdit(rcLine); |
2094 m_pNotify->IOnInvalidateRect(&rcRefresh); | 1974 m_pNotify->IOnInvalidateRect(&rcRefresh); |
2095 m_bNotifyFlag = FALSE; | 1975 m_bNotifyFlag = FALSE; |
2096 } | 1976 } |
2097 } | 1977 } |
2098 | 1978 |
2099 pIterator->NextLine(); | 1979 pIterator->NextLine(); |
2100 } | 1980 } |
2101 } | 1981 } |
2102 } | 1982 } |
2103 | 1983 |
2104 void CFX_Edit::SetCaret(const CPVT_WordPlace& place) { | 1984 void CFX_Edit::SetCaret(const CPVT_WordPlace& place) { |
2105 m_wpOldCaret = m_wpCaret; | 1985 m_wpOldCaret = m_wpCaret; |
2106 m_wpCaret = place; | 1986 m_wpCaret = place; |
2107 } | 1987 } |
2108 | 1988 |
2109 void CFX_Edit::SetCaretInfo() { | 1989 void CFX_Edit::SetCaretInfo() { |
2110 if (m_bNotify && m_pNotify) { | 1990 if (m_pNotify) { |
2111 if (!m_bNotifyFlag) { | 1991 if (!m_bNotifyFlag) { |
2112 CFX_FloatPoint ptHead(0.0f, 0.0f), ptFoot(0.0f, 0.0f); | 1992 CFX_FloatPoint ptHead(0.0f, 0.0f), ptFoot(0.0f, 0.0f); |
2113 | 1993 |
2114 CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator(); | 1994 CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator(); |
2115 pIterator->SetAt(m_wpCaret); | 1995 pIterator->SetAt(m_wpCaret); |
2116 CPVT_Word word; | 1996 CPVT_Word word; |
2117 CPVT_Line line; | 1997 CPVT_Line line; |
2118 if (pIterator->GetWord(word)) { | 1998 if (pIterator->GetWord(word)) { |
2119 ptHead.x = word.ptWord.x + word.fWidth; | 1999 ptHead.x = word.ptWord.x + word.fWidth; |
2120 ptHead.y = word.ptWord.y + word.fAscent; | 2000 ptHead.y = word.ptWord.y + word.fAscent; |
(...skipping 13 matching lines...) Expand all Loading... |
2134 } | 2014 } |
2135 } | 2015 } |
2136 | 2016 |
2137 SetCaretChange(); | 2017 SetCaretChange(); |
2138 } | 2018 } |
2139 | 2019 |
2140 void CFX_Edit::SetCaretChange() { | 2020 void CFX_Edit::SetCaretChange() { |
2141 if (m_wpCaret == m_wpOldCaret) | 2021 if (m_wpCaret == m_wpOldCaret) |
2142 return; | 2022 return; |
2143 | 2023 |
2144 if (!m_bNotify || !m_pVT->IsRichText() || !m_pNotify) | 2024 if (!m_pVT->IsRichText() || !m_pNotify) |
2145 return; | 2025 return; |
2146 | 2026 |
2147 CPVT_SecProps SecProps; | 2027 CPVT_SecProps SecProps; |
2148 CPVT_WordProps WordProps; | 2028 CPVT_WordProps WordProps; |
2149 | 2029 |
2150 CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator(); | 2030 CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator(); |
2151 pIterator->SetAt(m_wpCaret); | 2031 pIterator->SetAt(m_wpCaret); |
2152 CPVT_Word word; | 2032 CPVT_Word word; |
2153 CPVT_Section section; | 2033 CPVT_Section section; |
2154 | 2034 |
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2891 } | 2771 } |
2892 | 2772 |
2893 void CFX_Edit::EnableRefresh(FX_BOOL bRefresh) { | 2773 void CFX_Edit::EnableRefresh(FX_BOOL bRefresh) { |
2894 m_bEnableRefresh = bRefresh; | 2774 m_bEnableRefresh = bRefresh; |
2895 } | 2775 } |
2896 | 2776 |
2897 void CFX_Edit::EnableUndo(FX_BOOL bUndo) { | 2777 void CFX_Edit::EnableUndo(FX_BOOL bUndo) { |
2898 m_bEnableUndo = bUndo; | 2778 m_bEnableUndo = bUndo; |
2899 } | 2779 } |
2900 | 2780 |
2901 void CFX_Edit::EnableNotify(FX_BOOL bNotify) { | |
2902 m_bNotify = bNotify; | |
2903 } | |
2904 | |
2905 void CFX_Edit::EnableOprNotify(FX_BOOL bNotify) { | 2781 void CFX_Edit::EnableOprNotify(FX_BOOL bNotify) { |
2906 m_bOprNotify = bNotify; | 2782 m_bOprNotify = bNotify; |
2907 } | 2783 } |
2908 | 2784 |
2909 FX_FLOAT CFX_Edit::GetLineTop(const CPVT_WordPlace& place) const { | 2785 FX_FLOAT CFX_Edit::GetLineTop(const CPVT_WordPlace& place) const { |
2910 CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator(); | 2786 CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator(); |
2911 CPVT_WordPlace wpOld = pIterator->GetAt(); | 2787 CPVT_WordPlace wpOld = pIterator->GetAt(); |
2912 | 2788 |
2913 pIterator->SetAt(place); | 2789 pIterator->SetAt(place); |
2914 CPVT_Line line; | 2790 CPVT_Line line; |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3114 int32_t CFX_Edit_RectArray::GetSize() const { | 2990 int32_t CFX_Edit_RectArray::GetSize() const { |
3115 return m_Rects.GetSize(); | 2991 return m_Rects.GetSize(); |
3116 } | 2992 } |
3117 | 2993 |
3118 CFX_FloatRect* CFX_Edit_RectArray::GetAt(int32_t nIndex) const { | 2994 CFX_FloatRect* CFX_Edit_RectArray::GetAt(int32_t nIndex) const { |
3119 if (nIndex < 0 || nIndex >= m_Rects.GetSize()) | 2995 if (nIndex < 0 || nIndex >= m_Rects.GetSize()) |
3120 return nullptr; | 2996 return nullptr; |
3121 | 2997 |
3122 return m_Rects.GetAt(nIndex); | 2998 return m_Rects.GetAt(nIndex); |
3123 } | 2999 } |
OLD | NEW |