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 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 void CFXEU_Clear::Undo() { | 599 void CFXEU_Clear::Undo() { |
600 if (m_pEdit) { | 600 if (m_pEdit) { |
601 m_pEdit->SelectNone(); | 601 m_pEdit->SelectNone(); |
602 m_pEdit->SetCaret(m_wrSel.BeginPos); | 602 m_pEdit->SetCaret(m_wrSel.BeginPos); |
603 m_pEdit->InsertText(m_swText.c_str(), DEFAULT_CHARSET, nullptr, nullptr, | 603 m_pEdit->InsertText(m_swText.c_str(), DEFAULT_CHARSET, nullptr, nullptr, |
604 FALSE, TRUE); | 604 FALSE, TRUE); |
605 m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos); | 605 m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos); |
606 } | 606 } |
607 } | 607 } |
608 | 608 |
609 CFXEU_ClearRich::CFXEU_ClearRich(CFX_Edit* pEdit, | |
610 const CPVT_WordPlace& wpOldPlace, | |
611 const CPVT_WordPlace& wpNewPlace, | |
612 const CPVT_WordRange& wrSel, | |
613 uint16_t word, | |
614 int32_t charset, | |
615 const CPVT_SecProps& SecProps, | |
616 const CPVT_WordProps& WordProps) | |
617 : m_pEdit(pEdit), | |
618 m_wpOld(wpOldPlace), | |
619 m_wpNew(wpNewPlace), | |
620 m_wrSel(wrSel), | |
621 m_Word(word), | |
622 m_nCharset(charset), | |
623 m_SecProps(SecProps), | |
624 m_WordProps(WordProps) {} | |
625 | |
626 CFXEU_ClearRich::~CFXEU_ClearRich() {} | |
627 | |
628 void CFXEU_ClearRich::Redo() { | |
629 if (m_pEdit && IsLast()) { | |
630 m_pEdit->SelectNone(); | |
631 m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos); | |
632 m_pEdit->Clear(FALSE, TRUE); | |
633 } | |
634 } | |
635 | |
636 void CFXEU_ClearRich::Undo() { | |
637 if (m_pEdit) { | |
638 m_pEdit->SelectNone(); | |
639 m_pEdit->SetCaret(m_wpOld); | |
640 if (m_wpNew.SecCmp(m_wpOld) != 0) { | |
641 m_pEdit->InsertReturn(&m_SecProps, &m_WordProps, FALSE, FALSE); | |
642 } else { | |
643 m_pEdit->InsertWord(m_Word, m_nCharset, &m_WordProps, FALSE, FALSE); | |
644 } | |
645 | |
646 if (IsFirst()) { | |
647 m_pEdit->PaintInsertText(m_wrSel.BeginPos, m_wrSel.EndPos); | |
648 m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos); | |
649 } | |
650 } | |
651 } | |
652 CFXEU_InsertText::CFXEU_InsertText(CFX_Edit* pEdit, | 609 CFXEU_InsertText::CFXEU_InsertText(CFX_Edit* pEdit, |
653 const CPVT_WordPlace& wpOldPlace, | 610 const CPVT_WordPlace& wpOldPlace, |
654 const CPVT_WordPlace& wpNewPlace, | 611 const CPVT_WordPlace& wpNewPlace, |
655 const CFX_WideString& swText, | 612 const CFX_WideString& swText, |
656 int32_t charset, | 613 int32_t charset, |
657 const CPVT_SecProps* pSecProps, | 614 const CPVT_SecProps* pSecProps, |
658 const CPVT_WordProps* pWordProps) | 615 const CPVT_WordProps* pWordProps) |
659 : m_pEdit(pEdit), | 616 : m_pEdit(pEdit), |
660 m_wpOld(wpOldPlace), | 617 m_wpOld(wpOldPlace), |
661 m_wpNew(wpNewPlace), | 618 m_wpNew(wpNewPlace), |
(...skipping 19 matching lines...) Expand all Loading... |
681 } | 638 } |
682 | 639 |
683 void CFXEU_InsertText::Undo() { | 640 void CFXEU_InsertText::Undo() { |
684 if (m_pEdit) { | 641 if (m_pEdit) { |
685 m_pEdit->SelectNone(); | 642 m_pEdit->SelectNone(); |
686 m_pEdit->SetSel(m_wpOld, m_wpNew); | 643 m_pEdit->SetSel(m_wpOld, m_wpNew); |
687 m_pEdit->Clear(FALSE, TRUE); | 644 m_pEdit->Clear(FALSE, TRUE); |
688 } | 645 } |
689 } | 646 } |
690 | 647 |
691 CFXEU_SetSecProps::CFXEU_SetSecProps(CFX_Edit* pEdit, | |
692 const CPVT_WordPlace& place, | |
693 EDIT_PROPS_E ep, | |
694 const CPVT_SecProps& oldsecprops, | |
695 const CPVT_WordProps& oldwordprops, | |
696 const CPVT_SecProps& newsecprops, | |
697 const CPVT_WordProps& newwordprops, | |
698 const CPVT_WordRange& range) | |
699 : m_pEdit(pEdit), | |
700 m_wpPlace(place), | |
701 m_wrPlace(range), | |
702 m_eProps(ep), | |
703 m_OldSecProps(oldsecprops), | |
704 m_NewSecProps(newsecprops), | |
705 m_OldWordProps(oldwordprops), | |
706 m_NewWordProps(newwordprops) {} | |
707 | |
708 CFXEU_SetSecProps::~CFXEU_SetSecProps() {} | |
709 | |
710 void CFXEU_SetSecProps::Redo() { | |
711 if (m_pEdit) { | |
712 m_pEdit->SetSecProps(m_eProps, m_wpPlace, &m_NewSecProps, &m_NewWordProps, | |
713 m_wrPlace, FALSE); | |
714 if (IsLast()) { | |
715 m_pEdit->SelectNone(); | |
716 m_pEdit->PaintSetProps(m_eProps, m_wrPlace); | |
717 m_pEdit->SetSel(m_wrPlace.BeginPos, m_wrPlace.EndPos); | |
718 } | |
719 } | |
720 } | |
721 | |
722 void CFXEU_SetSecProps::Undo() { | |
723 if (m_pEdit) { | |
724 m_pEdit->SetSecProps(m_eProps, m_wpPlace, &m_OldSecProps, &m_OldWordProps, | |
725 m_wrPlace, FALSE); | |
726 if (IsFirst()) { | |
727 m_pEdit->SelectNone(); | |
728 m_pEdit->PaintSetProps(m_eProps, m_wrPlace); | |
729 m_pEdit->SetSel(m_wrPlace.BeginPos, m_wrPlace.EndPos); | |
730 } | |
731 } | |
732 } | |
733 | |
734 CFXEU_SetWordProps::CFXEU_SetWordProps(CFX_Edit* pEdit, | |
735 const CPVT_WordPlace& place, | |
736 EDIT_PROPS_E ep, | |
737 const CPVT_WordProps& oldprops, | |
738 const CPVT_WordProps& newprops, | |
739 const CPVT_WordRange& range) | |
740 : m_pEdit(pEdit), | |
741 m_wpPlace(place), | |
742 m_wrPlace(range), | |
743 m_eProps(ep), | |
744 m_OldWordProps(oldprops), | |
745 m_NewWordProps(newprops) {} | |
746 | |
747 CFXEU_SetWordProps::~CFXEU_SetWordProps() {} | |
748 | |
749 void CFXEU_SetWordProps::Redo() { | |
750 if (m_pEdit) { | |
751 m_pEdit->SetWordProps(m_eProps, m_wpPlace, &m_NewWordProps, m_wrPlace, | |
752 FALSE); | |
753 if (IsLast()) { | |
754 m_pEdit->SelectNone(); | |
755 m_pEdit->PaintSetProps(m_eProps, m_wrPlace); | |
756 m_pEdit->SetSel(m_wrPlace.BeginPos, m_wrPlace.EndPos); | |
757 } | |
758 } | |
759 } | |
760 | |
761 void CFXEU_SetWordProps::Undo() { | |
762 if (m_pEdit) { | |
763 m_pEdit->SetWordProps(m_eProps, m_wpPlace, &m_OldWordProps, m_wrPlace, | |
764 FALSE); | |
765 if (IsFirst()) { | |
766 m_pEdit->SelectNone(); | |
767 m_pEdit->PaintSetProps(m_eProps, m_wrPlace); | |
768 m_pEdit->SetSel(m_wrPlace.BeginPos, m_wrPlace.EndPos); | |
769 } | |
770 } | |
771 } | |
772 | |
773 CFX_Edit::CFX_Edit(CPDF_VariableText* pVT) | 648 CFX_Edit::CFX_Edit(CPDF_VariableText* pVT) |
774 : m_pVT(pVT), | 649 : m_pVT(pVT), |
775 m_pNotify(nullptr), | 650 m_pNotify(nullptr), |
776 m_pOprNotify(nullptr), | 651 m_pOprNotify(nullptr), |
777 m_wpCaret(-1, -1, -1), | 652 m_wpCaret(-1, -1, -1), |
778 m_wpOldCaret(-1, -1, -1), | 653 m_wpOldCaret(-1, -1, -1), |
779 m_SelState(), | 654 m_SelState(), |
780 m_ptScrollPos(0, 0), | 655 m_ptScrollPos(0, 0), |
781 m_ptRefreshScrollPos(0, 0), | 656 m_ptRefreshScrollPos(0, 0), |
782 m_bEnableScroll(FALSE), | 657 m_bEnableScroll(FALSE), |
783 m_ptCaret(0.0f, 0.0f), | 658 m_ptCaret(0.0f, 0.0f), |
784 m_Undo(kEditUndoMaxItems), | 659 m_Undo(kEditUndoMaxItems), |
785 m_nAlignment(0), | 660 m_nAlignment(0), |
786 m_bNotifyFlag(FALSE), | 661 m_bNotifyFlag(FALSE), |
787 m_bEnableOverflow(FALSE), | 662 m_bEnableOverflow(FALSE), |
788 m_bEnableRefresh(TRUE), | 663 m_bEnableRefresh(TRUE), |
789 m_rcOldContent(0.0f, 0.0f, 0.0f, 0.0f), | 664 m_rcOldContent(0.0f, 0.0f, 0.0f, 0.0f), |
790 m_bEnableUndo(TRUE), | 665 m_bEnableUndo(TRUE), |
791 m_bNotify(TRUE), | |
792 m_bOprNotify(FALSE), | 666 m_bOprNotify(FALSE), |
793 m_pGroupUndoItem(nullptr) { | 667 m_pGroupUndoItem(nullptr) { |
794 ASSERT(pVT); | 668 ASSERT(pVT); |
795 } | 669 } |
796 | 670 |
797 CFX_Edit::~CFX_Edit() { | 671 CFX_Edit::~CFX_Edit() { |
798 ASSERT(!m_pGroupUndoItem); | 672 ASSERT(!m_pGroupUndoItem); |
799 } | 673 } |
800 | 674 |
801 void CFX_Edit::Initialize() { | 675 void CFX_Edit::Initialize() { |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 | 957 |
1084 if (wr1.EndPos.WordCmp(wr2.EndPos) < 0) { | 958 if (wr1.EndPos.WordCmp(wr2.EndPos) < 0) { |
1085 wrRet.EndPos = wr2.EndPos; | 959 wrRet.EndPos = wr2.EndPos; |
1086 } else { | 960 } else { |
1087 wrRet.EndPos = wr1.EndPos; | 961 wrRet.EndPos = wr1.EndPos; |
1088 } | 962 } |
1089 | 963 |
1090 return wrRet; | 964 return wrRet; |
1091 } | 965 } |
1092 | 966 |
1093 FX_BOOL CFX_Edit::IsRichText() const { | |
1094 return m_pVT->IsRichText(); | |
1095 } | |
1096 | |
1097 void CFX_Edit::SetRichText(FX_BOOL bRichText, FX_BOOL bPaint) { | |
1098 m_pVT->SetRichText(bRichText); | |
1099 if (bPaint) | |
1100 Paint(); | |
1101 } | |
1102 | |
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) { | |
1223 switch (eProps) { | |
1224 case EP_LINELEADING: | |
1225 case EP_LINEINDENT: | |
1226 case EP_ALIGNMENT: | |
1227 RearrangePart(wr); | |
1228 ScrollToCaret(); | |
1229 Refresh(RP_ANALYSE); | |
1230 SetCaretOrigin(); | |
1231 SetCaretInfo(); | |
1232 break; | |
1233 case EP_WORDCOLOR: | |
1234 case EP_UNDERLINE: | |
1235 case EP_CROSSOUT: | |
1236 Refresh(RP_OPTIONAL, &wr); | |
1237 break; | |
1238 case EP_FONTINDEX: | |
1239 case EP_FONTSIZE: | |
1240 case EP_SCRIPTTYPE: | |
1241 case EP_CHARSPACE: | |
1242 case EP_HORZSCALE: | |
1243 case EP_BOLD: | |
1244 case EP_ITALIC: | |
1245 RearrangePart(wr); | |
1246 ScrollToCaret(); | |
1247 | |
1248 CPVT_WordRange wrRefresh(m_pVT->GetSectionBeginPlace(wr.BeginPos), | |
1249 m_pVT->GetSectionEndPlace(wr.EndPos)); | |
1250 Refresh(RP_ANALYSE, &wrRefresh); | |
1251 | |
1252 SetCaretOrigin(); | |
1253 SetCaretInfo(); | |
1254 break; | |
1255 } | |
1256 } | |
1257 | |
1258 FX_BOOL CFX_Edit::SetSecProps(EDIT_PROPS_E eProps, | |
1259 const CPVT_WordPlace& place, | |
1260 const CPVT_SecProps* pSecProps, | |
1261 const CPVT_WordProps* pWordProps, | |
1262 const CPVT_WordRange& wr, | |
1263 FX_BOOL bAddUndo) { | |
1264 if (!m_pVT->IsValid() || !m_pVT->IsRichText()) | |
1265 return FALSE; | |
1266 | |
1267 CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator(); | |
1268 FX_BOOL bSet = FALSE; | |
1269 CPVT_Section secinfo; | |
1270 CPVT_Section OldSecinfo; | |
1271 | |
1272 CPVT_WordPlace oldplace = pIterator->GetAt(); | |
1273 | |
1274 if (eProps == EP_LINELEADING || eProps == EP_LINEINDENT || | |
1275 eProps == EP_ALIGNMENT) { | |
1276 if (pSecProps) { | |
1277 pIterator->SetAt(place); | |
1278 if (pIterator->GetSection(secinfo)) { | |
1279 if (bAddUndo) | |
1280 OldSecinfo = secinfo; | |
1281 | |
1282 switch (eProps) { | |
1283 case EP_LINELEADING: | |
1284 if (!FX_EDIT_IsFloatEqual(secinfo.SecProps.fLineLeading, | |
1285 pSecProps->fLineLeading)) { | |
1286 secinfo.SecProps.fLineLeading = pSecProps->fLineLeading; | |
1287 bSet = TRUE; | |
1288 } | |
1289 break; | |
1290 case EP_LINEINDENT: | |
1291 if (!FX_EDIT_IsFloatEqual(secinfo.SecProps.fLineIndent, | |
1292 pSecProps->fLineIndent)) { | |
1293 secinfo.SecProps.fLineIndent = pSecProps->fLineIndent; | |
1294 bSet = TRUE; | |
1295 } | |
1296 break; | |
1297 case EP_ALIGNMENT: | |
1298 if (secinfo.SecProps.nAlignment != pSecProps->nAlignment) { | |
1299 secinfo.SecProps.nAlignment = pSecProps->nAlignment; | |
1300 bSet = TRUE; | |
1301 } | |
1302 break; | |
1303 default: | |
1304 break; | |
1305 } | |
1306 } | |
1307 } | |
1308 } else { | |
1309 if (pWordProps && place == m_pVT->GetSectionBeginPlace(place)) { | |
1310 pIterator->SetAt(place); | |
1311 if (pIterator->GetSection(secinfo)) { | |
1312 if (bAddUndo) | |
1313 OldSecinfo = secinfo; | |
1314 | |
1315 switch (eProps) { | |
1316 case EP_FONTINDEX: | |
1317 if (secinfo.WordProps.nFontIndex != pWordProps->nFontIndex) { | |
1318 secinfo.WordProps.nFontIndex = pWordProps->nFontIndex; | |
1319 bSet = TRUE; | |
1320 } | |
1321 break; | |
1322 case EP_FONTSIZE: | |
1323 if (!FX_EDIT_IsFloatEqual(secinfo.WordProps.fFontSize, | |
1324 pWordProps->fFontSize)) { | |
1325 secinfo.WordProps.fFontSize = pWordProps->fFontSize; | |
1326 bSet = TRUE; | |
1327 } | |
1328 break; | |
1329 case EP_WORDCOLOR: | |
1330 if (secinfo.WordProps.dwWordColor != pWordProps->dwWordColor) { | |
1331 secinfo.WordProps.dwWordColor = pWordProps->dwWordColor; | |
1332 bSet = TRUE; | |
1333 } | |
1334 break; | |
1335 case EP_SCRIPTTYPE: | |
1336 if (secinfo.WordProps.nScriptType != pWordProps->nScriptType) { | |
1337 secinfo.WordProps.nScriptType = pWordProps->nScriptType; | |
1338 bSet = TRUE; | |
1339 } | |
1340 break; | |
1341 case EP_CHARSPACE: | |
1342 if (!FX_EDIT_IsFloatEqual(secinfo.WordProps.fCharSpace, | |
1343 pWordProps->fCharSpace)) { | |
1344 secinfo.WordProps.fCharSpace = pWordProps->fCharSpace; | |
1345 bSet = TRUE; | |
1346 } | |
1347 break; | |
1348 case EP_HORZSCALE: | |
1349 if (secinfo.WordProps.nHorzScale != pWordProps->nHorzScale) { | |
1350 secinfo.WordProps.nHorzScale = pWordProps->nHorzScale; | |
1351 bSet = TRUE; | |
1352 } | |
1353 break; | |
1354 case EP_UNDERLINE: | |
1355 if (pWordProps->nWordStyle & PVTWORD_STYLE_UNDERLINE) { | |
1356 if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) == | |
1357 0) { | |
1358 secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_UNDERLINE; | |
1359 bSet = TRUE; | |
1360 } | |
1361 } else { | |
1362 if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) != | |
1363 0) { | |
1364 secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_UNDERLINE; | |
1365 bSet = TRUE; | |
1366 } | |
1367 } | |
1368 break; | |
1369 case EP_CROSSOUT: | |
1370 if (pWordProps->nWordStyle & PVTWORD_STYLE_CROSSOUT) { | |
1371 if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) == | |
1372 0) { | |
1373 secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_CROSSOUT; | |
1374 bSet = TRUE; | |
1375 } | |
1376 } else { | |
1377 if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) != | |
1378 0) { | |
1379 secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_CROSSOUT; | |
1380 bSet = TRUE; | |
1381 } | |
1382 } | |
1383 break; | |
1384 case EP_BOLD: | |
1385 if (pWordProps->nWordStyle & PVTWORD_STYLE_BOLD) { | |
1386 if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) == 0) { | |
1387 secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_BOLD; | |
1388 bSet = TRUE; | |
1389 } | |
1390 } else { | |
1391 if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) != 0) { | |
1392 secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_BOLD; | |
1393 bSet = TRUE; | |
1394 } | |
1395 } | |
1396 break; | |
1397 case EP_ITALIC: | |
1398 if (pWordProps->nWordStyle & PVTWORD_STYLE_ITALIC) { | |
1399 if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) == 0) { | |
1400 secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_ITALIC; | |
1401 bSet = TRUE; | |
1402 } | |
1403 } else { | |
1404 if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) != 0) { | |
1405 secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_ITALIC; | |
1406 bSet = TRUE; | |
1407 } | |
1408 } | |
1409 break; | |
1410 default: | |
1411 break; | |
1412 } | |
1413 } | |
1414 } | |
1415 } | |
1416 | |
1417 if (bSet) { | |
1418 pIterator->SetSection(secinfo); | |
1419 | |
1420 if (bAddUndo && m_bEnableUndo) { | |
1421 AddEditUndoItem(new CFXEU_SetSecProps( | |
1422 this, place, eProps, OldSecinfo.SecProps, OldSecinfo.WordProps, | |
1423 secinfo.SecProps, secinfo.WordProps, wr)); | |
1424 } | |
1425 } | |
1426 | |
1427 pIterator->SetAt(oldplace); | |
1428 | |
1429 return bSet; | |
1430 } | |
1431 | |
1432 FX_BOOL CFX_Edit::SetWordProps(EDIT_PROPS_E eProps, | |
1433 const CPVT_WordPlace& place, | |
1434 const CPVT_WordProps* pWordProps, | |
1435 const CPVT_WordRange& wr, | |
1436 FX_BOOL bAddUndo) { | |
1437 if (!m_pVT->IsValid() || !m_pVT->IsRichText()) | |
1438 return FALSE; | |
1439 | |
1440 CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator(); | |
1441 FX_BOOL bSet = FALSE; | |
1442 CPVT_Word wordinfo; | |
1443 CPVT_Word OldWordinfo; | |
1444 | |
1445 CPVT_WordPlace oldplace = pIterator->GetAt(); | |
1446 | |
1447 if (pWordProps) { | |
1448 pIterator->SetAt(place); | |
1449 if (pIterator->GetWord(wordinfo)) { | |
1450 if (bAddUndo) | |
1451 OldWordinfo = wordinfo; | |
1452 | |
1453 switch (eProps) { | |
1454 case EP_FONTINDEX: | |
1455 if (wordinfo.WordProps.nFontIndex != pWordProps->nFontIndex) { | |
1456 if (IPVT_FontMap* pFontMap = GetFontMap()) { | |
1457 wordinfo.WordProps.nFontIndex = pFontMap->GetWordFontIndex( | |
1458 wordinfo.Word, wordinfo.nCharset, pWordProps->nFontIndex); | |
1459 } | |
1460 bSet = TRUE; | |
1461 } | |
1462 break; | |
1463 case EP_FONTSIZE: | |
1464 if (!FX_EDIT_IsFloatEqual(wordinfo.WordProps.fFontSize, | |
1465 pWordProps->fFontSize)) { | |
1466 wordinfo.WordProps.fFontSize = pWordProps->fFontSize; | |
1467 bSet = TRUE; | |
1468 } | |
1469 break; | |
1470 case EP_WORDCOLOR: | |
1471 if (wordinfo.WordProps.dwWordColor != pWordProps->dwWordColor) { | |
1472 wordinfo.WordProps.dwWordColor = pWordProps->dwWordColor; | |
1473 bSet = TRUE; | |
1474 } | |
1475 break; | |
1476 case EP_SCRIPTTYPE: | |
1477 if (wordinfo.WordProps.nScriptType != pWordProps->nScriptType) { | |
1478 wordinfo.WordProps.nScriptType = pWordProps->nScriptType; | |
1479 bSet = TRUE; | |
1480 } | |
1481 break; | |
1482 case EP_CHARSPACE: | |
1483 if (!FX_EDIT_IsFloatEqual(wordinfo.WordProps.fCharSpace, | |
1484 pWordProps->fCharSpace)) { | |
1485 wordinfo.WordProps.fCharSpace = pWordProps->fCharSpace; | |
1486 bSet = TRUE; | |
1487 } | |
1488 break; | |
1489 case EP_HORZSCALE: | |
1490 if (wordinfo.WordProps.nHorzScale != pWordProps->nHorzScale) { | |
1491 wordinfo.WordProps.nHorzScale = pWordProps->nHorzScale; | |
1492 bSet = TRUE; | |
1493 } | |
1494 break; | |
1495 case EP_UNDERLINE: | |
1496 if (pWordProps->nWordStyle & PVTWORD_STYLE_UNDERLINE) { | |
1497 if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) == | |
1498 0) { | |
1499 wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_UNDERLINE; | |
1500 bSet = TRUE; | |
1501 } | |
1502 } else { | |
1503 if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) != | |
1504 0) { | |
1505 wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_UNDERLINE; | |
1506 bSet = TRUE; | |
1507 } | |
1508 } | |
1509 break; | |
1510 case EP_CROSSOUT: | |
1511 if (pWordProps->nWordStyle & PVTWORD_STYLE_CROSSOUT) { | |
1512 if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) == 0) { | |
1513 wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_CROSSOUT; | |
1514 bSet = TRUE; | |
1515 } | |
1516 } else { | |
1517 if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) != 0) { | |
1518 wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_CROSSOUT; | |
1519 bSet = TRUE; | |
1520 } | |
1521 } | |
1522 break; | |
1523 case EP_BOLD: | |
1524 if (pWordProps->nWordStyle & PVTWORD_STYLE_BOLD) { | |
1525 if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) == 0) { | |
1526 wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_BOLD; | |
1527 bSet = TRUE; | |
1528 } | |
1529 } else { | |
1530 if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) != 0) { | |
1531 wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_BOLD; | |
1532 bSet = TRUE; | |
1533 } | |
1534 } | |
1535 break; | |
1536 case EP_ITALIC: | |
1537 if (pWordProps->nWordStyle & PVTWORD_STYLE_ITALIC) { | |
1538 if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) == 0) { | |
1539 wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_ITALIC; | |
1540 bSet = TRUE; | |
1541 } | |
1542 } else { | |
1543 if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) != 0) { | |
1544 wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_ITALIC; | |
1545 bSet = TRUE; | |
1546 } | |
1547 } | |
1548 break; | |
1549 default: | |
1550 break; | |
1551 } | |
1552 } | |
1553 } | |
1554 | |
1555 if (bSet) { | |
1556 pIterator->SetWord(wordinfo); | |
1557 | |
1558 if (bAddUndo && m_bEnableUndo) { | |
1559 AddEditUndoItem(new CFXEU_SetWordProps( | |
1560 this, place, eProps, OldWordinfo.WordProps, wordinfo.WordProps, wr)); | |
1561 } | |
1562 } | |
1563 | |
1564 pIterator->SetAt(oldplace); | |
1565 return bSet; | |
1566 } | |
1567 | |
1568 void CFX_Edit::SetText(const FX_WCHAR* text, | 967 void CFX_Edit::SetText(const FX_WCHAR* text, |
1569 int32_t charset, | 968 int32_t charset, |
1570 const CPVT_SecProps* pSecProps, | 969 const CPVT_SecProps* pSecProps, |
1571 const CPVT_WordProps* pWordProps) { | 970 const CPVT_WordProps* pWordProps) { |
1572 SetText(text, charset, pSecProps, pWordProps, TRUE, TRUE); | 971 SetText(text, charset, pSecProps, pWordProps, TRUE, TRUE); |
1573 } | 972 } |
1574 | 973 |
1575 FX_BOOL CFX_Edit::InsertWord(uint16_t word, | 974 FX_BOOL CFX_Edit::InsertWord(uint16_t word, |
1576 int32_t charset, | 975 int32_t charset, |
1577 const CPVT_WordProps* pWordProps) { | 976 const CPVT_WordProps* pWordProps) { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1687 if (m_pVT->IsValid()) { | 1086 if (m_pVT->IsValid()) { |
1688 m_pVT->UpdateWordPlace(m_wpCaret); | 1087 m_pVT->UpdateWordPlace(m_wpCaret); |
1689 m_pVT->RearrangePart(range); | 1088 m_pVT->RearrangePart(range); |
1690 m_pVT->UpdateWordPlace(m_wpCaret); | 1089 m_pVT->UpdateWordPlace(m_wpCaret); |
1691 SetScrollInfo(); | 1090 SetScrollInfo(); |
1692 SetContentChanged(); | 1091 SetContentChanged(); |
1693 } | 1092 } |
1694 } | 1093 } |
1695 | 1094 |
1696 void CFX_Edit::SetContentChanged() { | 1095 void CFX_Edit::SetContentChanged() { |
1697 if (m_bNotify && m_pNotify) { | 1096 if (m_pNotify) { |
1698 CFX_FloatRect rcContent = m_pVT->GetContentRect(); | 1097 CFX_FloatRect rcContent = m_pVT->GetContentRect(); |
1699 if (rcContent.Width() != m_rcOldContent.Width() || | 1098 if (rcContent.Width() != m_rcOldContent.Width() || |
1700 rcContent.Height() != m_rcOldContent.Height()) { | 1099 rcContent.Height() != m_rcOldContent.Height()) { |
1701 if (!m_bNotifyFlag) { | 1100 if (!m_bNotifyFlag) { |
1702 m_bNotifyFlag = TRUE; | 1101 m_bNotifyFlag = TRUE; |
1703 m_pNotify->IOnContentChange(rcContent); | 1102 m_pNotify->IOnContentChange(rcContent); |
1704 m_bNotifyFlag = FALSE; | 1103 m_bNotifyFlag = FALSE; |
1705 } | 1104 } |
1706 m_rcOldContent = rcContent; | 1105 m_rcOldContent = rcContent; |
1707 } | 1106 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1790 CFX_FloatRect CFX_Edit::EditToVT(const CFX_FloatRect& rect) const { | 1189 CFX_FloatRect CFX_Edit::EditToVT(const CFX_FloatRect& rect) const { |
1791 CFX_FloatPoint ptLeftBottom = | 1190 CFX_FloatPoint ptLeftBottom = |
1792 EditToVT(CFX_FloatPoint(rect.left, rect.bottom)); | 1191 EditToVT(CFX_FloatPoint(rect.left, rect.bottom)); |
1793 CFX_FloatPoint ptRightTop = EditToVT(CFX_FloatPoint(rect.right, rect.top)); | 1192 CFX_FloatPoint ptRightTop = EditToVT(CFX_FloatPoint(rect.right, rect.top)); |
1794 | 1193 |
1795 return CFX_FloatRect(ptLeftBottom.x, ptLeftBottom.y, ptRightTop.x, | 1194 return CFX_FloatRect(ptLeftBottom.x, ptLeftBottom.y, ptRightTop.x, |
1796 ptRightTop.y); | 1195 ptRightTop.y); |
1797 } | 1196 } |
1798 | 1197 |
1799 void CFX_Edit::SetScrollInfo() { | 1198 void CFX_Edit::SetScrollInfo() { |
1800 if (m_bNotify && m_pNotify) { | 1199 if (m_pNotify) { |
1801 CFX_FloatRect rcPlate = m_pVT->GetPlateRect(); | 1200 CFX_FloatRect rcPlate = m_pVT->GetPlateRect(); |
1802 CFX_FloatRect rcContent = m_pVT->GetContentRect(); | 1201 CFX_FloatRect rcContent = m_pVT->GetContentRect(); |
1803 | 1202 |
1804 if (!m_bNotifyFlag) { | 1203 if (!m_bNotifyFlag) { |
1805 m_bNotifyFlag = TRUE; | 1204 m_bNotifyFlag = TRUE; |
1806 m_pNotify->IOnSetScrollInfoX(rcPlate.left, rcPlate.right, rcContent.left, | 1205 m_pNotify->IOnSetScrollInfoX(rcPlate.left, rcPlate.right, rcContent.left, |
1807 rcContent.right, rcPlate.Width() / 3, | 1206 rcContent.right, rcPlate.Width() / 3, |
1808 rcPlate.Width()); | 1207 rcPlate.Width()); |
1809 | 1208 |
1810 m_pNotify->IOnSetScrollInfoY(rcPlate.bottom, rcPlate.top, | 1209 m_pNotify->IOnSetScrollInfoY(rcPlate.bottom, rcPlate.top, |
1811 rcContent.bottom, rcContent.top, | 1210 rcContent.bottom, rcContent.top, |
1812 rcPlate.Height() / 3, rcPlate.Height()); | 1211 rcPlate.Height() / 3, rcPlate.Height()); |
1813 m_bNotifyFlag = FALSE; | 1212 m_bNotifyFlag = FALSE; |
1814 } | 1213 } |
1815 } | 1214 } |
1816 } | 1215 } |
1817 | 1216 |
1818 void CFX_Edit::SetScrollPosX(FX_FLOAT fx) { | 1217 void CFX_Edit::SetScrollPosX(FX_FLOAT fx) { |
1819 if (!m_bEnableScroll) | 1218 if (!m_bEnableScroll) |
1820 return; | 1219 return; |
1821 | 1220 |
1822 if (m_pVT->IsValid()) { | 1221 if (m_pVT->IsValid()) { |
1823 if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.x, fx)) { | 1222 if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.x, fx)) { |
1824 m_ptScrollPos.x = fx; | 1223 m_ptScrollPos.x = fx; |
1825 Refresh(RP_NOANALYSE); | 1224 Refresh(RP_NOANALYSE); |
1826 | 1225 |
1827 if (m_bNotify && m_pNotify) { | 1226 if (m_pNotify) { |
1828 if (!m_bNotifyFlag) { | 1227 if (!m_bNotifyFlag) { |
1829 m_bNotifyFlag = TRUE; | 1228 m_bNotifyFlag = TRUE; |
1830 m_pNotify->IOnSetScrollPosX(fx); | 1229 m_pNotify->IOnSetScrollPosX(fx); |
1831 m_bNotifyFlag = FALSE; | 1230 m_bNotifyFlag = FALSE; |
1832 } | 1231 } |
1833 } | 1232 } |
1834 } | 1233 } |
1835 } | 1234 } |
1836 } | 1235 } |
1837 | 1236 |
1838 void CFX_Edit::SetScrollPosY(FX_FLOAT fy) { | 1237 void CFX_Edit::SetScrollPosY(FX_FLOAT fy) { |
1839 if (!m_bEnableScroll) | 1238 if (!m_bEnableScroll) |
1840 return; | 1239 return; |
1841 | 1240 |
1842 if (m_pVT->IsValid()) { | 1241 if (m_pVT->IsValid()) { |
1843 if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.y, fy)) { | 1242 if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.y, fy)) { |
1844 m_ptScrollPos.y = fy; | 1243 m_ptScrollPos.y = fy; |
1845 Refresh(RP_NOANALYSE); | 1244 Refresh(RP_NOANALYSE); |
1846 | 1245 |
1847 if (m_bNotify && m_pNotify) { | 1246 if (m_pNotify) { |
1848 if (!m_bNotifyFlag) { | 1247 if (!m_bNotifyFlag) { |
1849 m_bNotifyFlag = TRUE; | 1248 m_bNotifyFlag = TRUE; |
1850 m_pNotify->IOnSetScrollPosY(fy); | 1249 m_pNotify->IOnSetScrollPosY(fy); |
1851 m_bNotifyFlag = FALSE; | 1250 m_bNotifyFlag = FALSE; |
1852 } | 1251 } |
1853 } | 1252 } |
1854 } | 1253 } |
1855 } | 1254 } |
1856 } | 1255 } |
1857 | 1256 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1952 void CFX_Edit::Refresh(REFRESH_PLAN_E ePlan, | 1351 void CFX_Edit::Refresh(REFRESH_PLAN_E ePlan, |
1953 const CPVT_WordRange* pRange1, | 1352 const CPVT_WordRange* pRange1, |
1954 const CPVT_WordRange* pRange2) { | 1353 const CPVT_WordRange* pRange2) { |
1955 if (m_bEnableRefresh && m_pVT->IsValid()) { | 1354 if (m_bEnableRefresh && m_pVT->IsValid()) { |
1956 m_Refresh.BeginRefresh(); | 1355 m_Refresh.BeginRefresh(); |
1957 RefreshPushLineRects(GetVisibleWordRange()); | 1356 RefreshPushLineRects(GetVisibleWordRange()); |
1958 | 1357 |
1959 m_Refresh.NoAnalyse(); | 1358 m_Refresh.NoAnalyse(); |
1960 m_ptRefreshScrollPos = m_ptScrollPos; | 1359 m_ptRefreshScrollPos = m_ptScrollPos; |
1961 | 1360 |
1962 if (m_bNotify && m_pNotify) { | 1361 if (m_pNotify) { |
1963 if (!m_bNotifyFlag) { | 1362 if (!m_bNotifyFlag) { |
1964 m_bNotifyFlag = TRUE; | 1363 m_bNotifyFlag = TRUE; |
1965 if (const CFX_Edit_RectArray* pRects = m_Refresh.GetRefreshRects()) { | 1364 if (const CFX_Edit_RectArray* pRects = m_Refresh.GetRefreshRects()) { |
1966 for (int32_t i = 0, sz = pRects->GetSize(); i < sz; i++) | 1365 for (int32_t i = 0, sz = pRects->GetSize(); i < sz; i++) |
1967 m_pNotify->IOnInvalidateRect(pRects->GetAt(i)); | 1366 m_pNotify->IOnInvalidateRect(pRects->GetAt(i)); |
1968 } | 1367 } |
1969 m_bNotifyFlag = FALSE; | 1368 m_bNotifyFlag = FALSE; |
1970 } | 1369 } |
1971 } | 1370 } |
1972 | 1371 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2066 pIterator->GetWord(wordinfo); | 1465 pIterator->GetWord(wordinfo); |
2067 pIterator->GetLine(lineinfo); | 1466 pIterator->GetLine(lineinfo); |
2068 | 1467 |
2069 if (place.LineCmp(wrTemp.BeginPos) == 0 || | 1468 if (place.LineCmp(wrTemp.BeginPos) == 0 || |
2070 place.LineCmp(wrTemp.EndPos) == 0) { | 1469 place.LineCmp(wrTemp.EndPos) == 0) { |
2071 CFX_FloatRect rcWord(wordinfo.ptWord.x, | 1470 CFX_FloatRect rcWord(wordinfo.ptWord.x, |
2072 lineinfo.ptLine.y + lineinfo.fLineDescent, | 1471 lineinfo.ptLine.y + lineinfo.fLineDescent, |
2073 wordinfo.ptWord.x + wordinfo.fWidth, | 1472 wordinfo.ptWord.x + wordinfo.fWidth, |
2074 lineinfo.ptLine.y + lineinfo.fLineAscent); | 1473 lineinfo.ptLine.y + lineinfo.fLineAscent); |
2075 | 1474 |
2076 if (m_bNotify && m_pNotify) { | 1475 if (m_pNotify) { |
2077 if (!m_bNotifyFlag) { | 1476 if (!m_bNotifyFlag) { |
2078 m_bNotifyFlag = TRUE; | 1477 m_bNotifyFlag = TRUE; |
2079 CFX_FloatRect rcRefresh = VTToEdit(rcWord); | 1478 CFX_FloatRect rcRefresh = VTToEdit(rcWord); |
2080 m_pNotify->IOnInvalidateRect(&rcRefresh); | 1479 m_pNotify->IOnInvalidateRect(&rcRefresh); |
2081 m_bNotifyFlag = FALSE; | 1480 m_bNotifyFlag = FALSE; |
2082 } | 1481 } |
2083 } | 1482 } |
2084 } else { | 1483 } else { |
2085 CFX_FloatRect rcLine(lineinfo.ptLine.x, | 1484 CFX_FloatRect rcLine(lineinfo.ptLine.x, |
2086 lineinfo.ptLine.y + lineinfo.fLineDescent, | 1485 lineinfo.ptLine.y + lineinfo.fLineDescent, |
2087 lineinfo.ptLine.x + lineinfo.fLineWidth, | 1486 lineinfo.ptLine.x + lineinfo.fLineWidth, |
2088 lineinfo.ptLine.y + lineinfo.fLineAscent); | 1487 lineinfo.ptLine.y + lineinfo.fLineAscent); |
2089 | 1488 |
2090 if (m_bNotify && m_pNotify) { | 1489 if (m_pNotify) { |
2091 if (!m_bNotifyFlag) { | 1490 if (!m_bNotifyFlag) { |
2092 m_bNotifyFlag = TRUE; | 1491 m_bNotifyFlag = TRUE; |
2093 CFX_FloatRect rcRefresh = VTToEdit(rcLine); | 1492 CFX_FloatRect rcRefresh = VTToEdit(rcLine); |
2094 m_pNotify->IOnInvalidateRect(&rcRefresh); | 1493 m_pNotify->IOnInvalidateRect(&rcRefresh); |
2095 m_bNotifyFlag = FALSE; | 1494 m_bNotifyFlag = FALSE; |
2096 } | 1495 } |
2097 } | 1496 } |
2098 | 1497 |
2099 pIterator->NextLine(); | 1498 pIterator->NextLine(); |
2100 } | 1499 } |
2101 } | 1500 } |
2102 } | 1501 } |
2103 | 1502 |
2104 void CFX_Edit::SetCaret(const CPVT_WordPlace& place) { | 1503 void CFX_Edit::SetCaret(const CPVT_WordPlace& place) { |
2105 m_wpOldCaret = m_wpCaret; | 1504 m_wpOldCaret = m_wpCaret; |
2106 m_wpCaret = place; | 1505 m_wpCaret = place; |
2107 } | 1506 } |
2108 | 1507 |
2109 void CFX_Edit::SetCaretInfo() { | 1508 void CFX_Edit::SetCaretInfo() { |
2110 if (m_bNotify && m_pNotify) { | 1509 if (m_pNotify) { |
2111 if (!m_bNotifyFlag) { | 1510 if (!m_bNotifyFlag) { |
2112 CFX_FloatPoint ptHead(0.0f, 0.0f), ptFoot(0.0f, 0.0f); | 1511 CFX_FloatPoint ptHead(0.0f, 0.0f), ptFoot(0.0f, 0.0f); |
2113 | 1512 |
2114 CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator(); | 1513 CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator(); |
2115 pIterator->SetAt(m_wpCaret); | 1514 pIterator->SetAt(m_wpCaret); |
2116 CPVT_Word word; | 1515 CPVT_Word word; |
2117 CPVT_Line line; | 1516 CPVT_Line line; |
2118 if (pIterator->GetWord(word)) { | 1517 if (pIterator->GetWord(word)) { |
2119 ptHead.x = word.ptWord.x + word.fWidth; | 1518 ptHead.x = word.ptWord.x + word.fWidth; |
2120 ptHead.y = word.ptWord.y + word.fAscent; | 1519 ptHead.y = word.ptWord.y + word.fAscent; |
2121 ptFoot.x = word.ptWord.x + word.fWidth; | 1520 ptFoot.x = word.ptWord.x + word.fWidth; |
2122 ptFoot.y = word.ptWord.y + word.fDescent; | 1521 ptFoot.y = word.ptWord.y + word.fDescent; |
2123 } else if (pIterator->GetLine(line)) { | 1522 } else if (pIterator->GetLine(line)) { |
2124 ptHead.x = line.ptLine.x; | 1523 ptHead.x = line.ptLine.x; |
2125 ptHead.y = line.ptLine.y + line.fLineAscent; | 1524 ptHead.y = line.ptLine.y + line.fLineAscent; |
2126 ptFoot.x = line.ptLine.x; | 1525 ptFoot.x = line.ptLine.x; |
2127 ptFoot.y = line.ptLine.y + line.fLineDescent; | 1526 ptFoot.y = line.ptLine.y + line.fLineDescent; |
2128 } | 1527 } |
2129 | 1528 |
2130 m_bNotifyFlag = TRUE; | 1529 m_bNotifyFlag = TRUE; |
2131 m_pNotify->IOnSetCaret(!m_SelState.IsExist(), VTToEdit(ptHead), | 1530 m_pNotify->IOnSetCaret(!m_SelState.IsExist(), VTToEdit(ptHead), |
2132 VTToEdit(ptFoot), m_wpCaret); | 1531 VTToEdit(ptFoot), m_wpCaret); |
2133 m_bNotifyFlag = FALSE; | 1532 m_bNotifyFlag = FALSE; |
2134 } | 1533 } |
2135 } | 1534 } |
2136 | |
2137 SetCaretChange(); | |
2138 } | |
2139 | |
2140 void CFX_Edit::SetCaretChange() { | |
2141 if (m_wpCaret == m_wpOldCaret) | |
2142 return; | |
2143 | |
2144 if (!m_bNotify || !m_pVT->IsRichText() || !m_pNotify) | |
2145 return; | |
2146 | |
2147 CPVT_SecProps SecProps; | |
2148 CPVT_WordProps WordProps; | |
2149 | |
2150 CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator(); | |
2151 pIterator->SetAt(m_wpCaret); | |
2152 CPVT_Word word; | |
2153 CPVT_Section section; | |
2154 | |
2155 if (pIterator->GetSection(section)) { | |
2156 SecProps = section.SecProps; | |
2157 WordProps = section.WordProps; | |
2158 } | |
2159 | |
2160 if (pIterator->GetWord(word)) | |
2161 WordProps = word.WordProps; | |
2162 | |
2163 if (!m_bNotifyFlag) { | |
2164 m_bNotifyFlag = TRUE; | |
2165 m_pNotify->IOnCaretChange(SecProps, WordProps); | |
2166 m_bNotifyFlag = FALSE; | |
2167 } | |
2168 } | 1535 } |
2169 | 1536 |
2170 void CFX_Edit::SetCaret(int32_t nPos) { | 1537 void CFX_Edit::SetCaret(int32_t nPos) { |
2171 if (m_pVT->IsValid()) { | 1538 if (m_pVT->IsValid()) { |
2172 SelectNone(); | 1539 SelectNone(); |
2173 SetCaret(m_pVT->WordIndexToWordPlace(nPos)); | 1540 SetCaret(m_pVT->WordIndexToWordPlace(nPos)); |
2174 m_SelState.Set(m_wpCaret, m_wpCaret); | 1541 m_SelState.Set(m_wpCaret, m_wpCaret); |
2175 | 1542 |
2176 ScrollToCaret(); | 1543 ScrollToCaret(); |
2177 SetCaretOrigin(); | 1544 SetCaretOrigin(); |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2655 | 2022 |
2656 FX_BOOL CFX_Edit::Clear(FX_BOOL bAddUndo, FX_BOOL bPaint) { | 2023 FX_BOOL CFX_Edit::Clear(FX_BOOL bAddUndo, FX_BOOL bPaint) { |
2657 if (!m_pVT->IsValid()) | 2024 if (!m_pVT->IsValid()) |
2658 return FALSE; | 2025 return FALSE; |
2659 | 2026 |
2660 if (!m_SelState.IsExist()) | 2027 if (!m_SelState.IsExist()) |
2661 return FALSE; | 2028 return FALSE; |
2662 | 2029 |
2663 CPVT_WordRange range = m_SelState.ConvertToWordRange(); | 2030 CPVT_WordRange range = m_SelState.ConvertToWordRange(); |
2664 | 2031 |
2665 if (bAddUndo && m_bEnableUndo) { | 2032 if (bAddUndo && m_bEnableUndo) |
2666 if (m_pVT->IsRichText()) { | 2033 AddEditUndoItem(new CFXEU_Clear(this, range, GetSelText())); |
2667 BeginGroupUndo(L""); | |
2668 | |
2669 CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator(); | |
2670 pIterator->SetAt(range.EndPos); | |
2671 | |
2672 CPVT_Word wordinfo; | |
2673 CPVT_Section secinfo; | |
2674 do { | |
2675 CPVT_WordPlace place = pIterator->GetAt(); | |
2676 if (place.WordCmp(range.BeginPos) <= 0) | |
2677 break; | |
2678 | |
2679 CPVT_WordPlace oldplace = m_pVT->GetPrevWordPlace(place); | |
2680 | |
2681 if (oldplace.SecCmp(place) != 0) { | |
2682 if (pIterator->GetSection(secinfo)) { | |
2683 AddEditUndoItem(new CFXEU_ClearRich( | |
2684 this, oldplace, place, range, wordinfo.Word, wordinfo.nCharset, | |
2685 secinfo.SecProps, secinfo.WordProps)); | |
2686 } | |
2687 } else { | |
2688 if (pIterator->GetWord(wordinfo)) { | |
2689 oldplace = m_pVT->AdjustLineHeader(oldplace, TRUE); | |
2690 place = m_pVT->AdjustLineHeader(place, TRUE); | |
2691 | |
2692 AddEditUndoItem(new CFXEU_ClearRich( | |
2693 this, oldplace, place, range, wordinfo.Word, wordinfo.nCharset, | |
2694 secinfo.SecProps, wordinfo.WordProps)); | |
2695 } | |
2696 } | |
2697 } while (pIterator->PrevWord()); | |
2698 EndGroupUndo(); | |
2699 } else { | |
2700 AddEditUndoItem(new CFXEU_Clear(this, range, GetSelText())); | |
2701 } | |
2702 } | |
2703 | 2034 |
2704 SelectNone(); | 2035 SelectNone(); |
2705 SetCaret(m_pVT->DeleteWords(range)); | 2036 SetCaret(m_pVT->DeleteWords(range)); |
2706 m_SelState.Set(m_wpCaret, m_wpCaret); | 2037 m_SelState.Set(m_wpCaret, m_wpCaret); |
2707 | 2038 |
2708 if (bPaint) { | 2039 if (bPaint) { |
2709 RearrangePart(range); | 2040 RearrangePart(range); |
2710 ScrollToCaret(); | 2041 ScrollToCaret(); |
2711 | 2042 |
2712 CPVT_WordRange wr(m_wpOldCaret, GetVisibleWordRange().EndPos); | 2043 CPVT_WordRange wr(m_wpOldCaret, GetVisibleWordRange().EndPos); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2891 } | 2222 } |
2892 | 2223 |
2893 void CFX_Edit::EnableRefresh(FX_BOOL bRefresh) { | 2224 void CFX_Edit::EnableRefresh(FX_BOOL bRefresh) { |
2894 m_bEnableRefresh = bRefresh; | 2225 m_bEnableRefresh = bRefresh; |
2895 } | 2226 } |
2896 | 2227 |
2897 void CFX_Edit::EnableUndo(FX_BOOL bUndo) { | 2228 void CFX_Edit::EnableUndo(FX_BOOL bUndo) { |
2898 m_bEnableUndo = bUndo; | 2229 m_bEnableUndo = bUndo; |
2899 } | 2230 } |
2900 | 2231 |
2901 void CFX_Edit::EnableNotify(FX_BOOL bNotify) { | |
2902 m_bNotify = bNotify; | |
2903 } | |
2904 | |
2905 void CFX_Edit::EnableOprNotify(FX_BOOL bNotify) { | 2232 void CFX_Edit::EnableOprNotify(FX_BOOL bNotify) { |
2906 m_bOprNotify = bNotify; | 2233 m_bOprNotify = bNotify; |
2907 } | 2234 } |
2908 | 2235 |
2909 FX_FLOAT CFX_Edit::GetLineTop(const CPVT_WordPlace& place) const { | 2236 FX_FLOAT CFX_Edit::GetLineTop(const CPVT_WordPlace& place) const { |
2910 CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator(); | 2237 CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator(); |
2911 CPVT_WordPlace wpOld = pIterator->GetAt(); | 2238 CPVT_WordPlace wpOld = pIterator->GetAt(); |
2912 | 2239 |
2913 pIterator->SetAt(place); | 2240 pIterator->SetAt(place); |
2914 CPVT_Line line; | 2241 CPVT_Line line; |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3114 int32_t CFX_Edit_RectArray::GetSize() const { | 2441 int32_t CFX_Edit_RectArray::GetSize() const { |
3115 return m_Rects.GetSize(); | 2442 return m_Rects.GetSize(); |
3116 } | 2443 } |
3117 | 2444 |
3118 CFX_FloatRect* CFX_Edit_RectArray::GetAt(int32_t nIndex) const { | 2445 CFX_FloatRect* CFX_Edit_RectArray::GetAt(int32_t nIndex) const { |
3119 if (nIndex < 0 || nIndex >= m_Rects.GetSize()) | 2446 if (nIndex < 0 || nIndex >= m_Rects.GetSize()) |
3120 return nullptr; | 2447 return nullptr; |
3121 | 2448 |
3122 return m_Rects.GetAt(nIndex); | 2449 return m_Rects.GetAt(nIndex); |
3123 } | 2450 } |
OLD | NEW |