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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 } | 332 } |
333 | 333 |
334 FX_BOOL CFX_Edit_Undo::IsModified() const { | 334 FX_BOOL CFX_Edit_Undo::IsModified() const { |
335 return m_bVirgin ? m_bModified : TRUE; | 335 return m_bVirgin ? m_bModified : TRUE; |
336 } | 336 } |
337 | 337 |
338 IFX_Edit_UndoItem* CFX_Edit_Undo::GetItem(int32_t nIndex) { | 338 IFX_Edit_UndoItem* CFX_Edit_Undo::GetItem(int32_t nIndex) { |
339 if (nIndex >= 0 && nIndex < m_UndoItemStack.GetSize()) | 339 if (nIndex >= 0 && nIndex < m_UndoItemStack.GetSize()) |
340 return m_UndoItemStack.GetAt(nIndex); | 340 return m_UndoItemStack.GetAt(nIndex); |
341 | 341 |
342 return NULL; | 342 return nullptr; |
343 } | 343 } |
344 | 344 |
345 void CFX_Edit_Undo::RemoveHeads() { | 345 void CFX_Edit_Undo::RemoveHeads() { |
346 ASSERT(m_UndoItemStack.GetSize() > 1); | 346 ASSERT(m_UndoItemStack.GetSize() > 1); |
347 | 347 |
348 delete m_UndoItemStack.GetAt(0); | 348 delete m_UndoItemStack.GetAt(0); |
349 m_UndoItemStack.RemoveAt(0); | 349 m_UndoItemStack.RemoveAt(0); |
350 } | 350 } |
351 | 351 |
352 void CFX_Edit_Undo::RemoveTails() { | 352 void CFX_Edit_Undo::RemoveTails() { |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 m_pEdit->SelectNone(); | 569 m_pEdit->SelectNone(); |
570 m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos); | 570 m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos); |
571 m_pEdit->Clear(FALSE, TRUE); | 571 m_pEdit->Clear(FALSE, TRUE); |
572 } | 572 } |
573 } | 573 } |
574 | 574 |
575 void CFXEU_Clear::Undo() { | 575 void CFXEU_Clear::Undo() { |
576 if (m_pEdit) { | 576 if (m_pEdit) { |
577 m_pEdit->SelectNone(); | 577 m_pEdit->SelectNone(); |
578 m_pEdit->SetCaret(m_wrSel.BeginPos); | 578 m_pEdit->SetCaret(m_wrSel.BeginPos); |
579 m_pEdit->InsertText(m_swText.c_str(), DEFAULT_CHARSET, NULL, NULL, FALSE, | 579 m_pEdit->InsertText(m_swText.c_str(), DEFAULT_CHARSET, nullptr, nullptr, |
580 TRUE); | 580 FALSE, TRUE); |
581 m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos); | 581 m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos); |
582 } | 582 } |
583 } | 583 } |
584 | 584 |
585 CFXEU_ClearRich::CFXEU_ClearRich(CFX_Edit* pEdit, | 585 CFXEU_ClearRich::CFXEU_ClearRich(CFX_Edit* pEdit, |
586 const CPVT_WordPlace& wpOldPlace, | 586 const CPVT_WordPlace& wpOldPlace, |
587 const CPVT_WordPlace& wpNewPlace, | 587 const CPVT_WordPlace& wpNewPlace, |
588 const CPVT_WordRange& wrSel, | 588 const CPVT_WordRange& wrSel, |
589 uint16_t word, | 589 uint16_t word, |
590 int32_t charset, | 590 int32_t charset, |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1072 | 1072 |
1073 void CFX_Edit::SetRichText(FX_BOOL bRichText, FX_BOOL bPaint) { | 1073 void CFX_Edit::SetRichText(FX_BOOL bRichText, FX_BOOL bPaint) { |
1074 m_pVT->SetRichText(bRichText); | 1074 m_pVT->SetRichText(bRichText); |
1075 if (bPaint) | 1075 if (bPaint) |
1076 Paint(); | 1076 Paint(); |
1077 } | 1077 } |
1078 | 1078 |
1079 FX_BOOL CFX_Edit::SetRichFontIndex(int32_t nFontIndex) { | 1079 FX_BOOL CFX_Edit::SetRichFontIndex(int32_t nFontIndex) { |
1080 CPVT_WordProps WordProps; | 1080 CPVT_WordProps WordProps; |
1081 WordProps.nFontIndex = nFontIndex; | 1081 WordProps.nFontIndex = nFontIndex; |
1082 return SetRichTextProps(EP_FONTINDEX, NULL, &WordProps); | 1082 return SetRichTextProps(EP_FONTINDEX, nullptr, &WordProps); |
1083 } | 1083 } |
1084 | 1084 |
1085 FX_BOOL CFX_Edit::SetRichFontSize(FX_FLOAT fFontSize) { | 1085 FX_BOOL CFX_Edit::SetRichFontSize(FX_FLOAT fFontSize) { |
1086 CPVT_WordProps WordProps; | 1086 CPVT_WordProps WordProps; |
1087 WordProps.fFontSize = fFontSize; | 1087 WordProps.fFontSize = fFontSize; |
1088 return SetRichTextProps(EP_FONTSIZE, NULL, &WordProps); | 1088 return SetRichTextProps(EP_FONTSIZE, nullptr, &WordProps); |
1089 } | 1089 } |
1090 | 1090 |
1091 FX_BOOL CFX_Edit::SetRichTextColor(FX_COLORREF dwColor) { | 1091 FX_BOOL CFX_Edit::SetRichTextColor(FX_COLORREF dwColor) { |
1092 CPVT_WordProps WordProps; | 1092 CPVT_WordProps WordProps; |
1093 WordProps.dwWordColor = dwColor; | 1093 WordProps.dwWordColor = dwColor; |
1094 return SetRichTextProps(EP_WORDCOLOR, NULL, &WordProps); | 1094 return SetRichTextProps(EP_WORDCOLOR, nullptr, &WordProps); |
1095 } | 1095 } |
1096 | 1096 |
1097 FX_BOOL CFX_Edit::SetRichTextScript(CPDF_VariableText::ScriptType nScriptType) { | 1097 FX_BOOL CFX_Edit::SetRichTextScript(CPDF_VariableText::ScriptType nScriptType) { |
1098 CPVT_WordProps WordProps; | 1098 CPVT_WordProps WordProps; |
1099 WordProps.nScriptType = nScriptType; | 1099 WordProps.nScriptType = nScriptType; |
1100 return SetRichTextProps(EP_SCRIPTTYPE, NULL, &WordProps); | 1100 return SetRichTextProps(EP_SCRIPTTYPE, nullptr, &WordProps); |
1101 } | 1101 } |
1102 | 1102 |
1103 FX_BOOL CFX_Edit::SetRichTextBold(FX_BOOL bBold) { | 1103 FX_BOOL CFX_Edit::SetRichTextBold(FX_BOOL bBold) { |
1104 CPVT_WordProps WordProps; | 1104 CPVT_WordProps WordProps; |
1105 if (bBold) | 1105 if (bBold) |
1106 WordProps.nWordStyle |= PVTWORD_STYLE_BOLD; | 1106 WordProps.nWordStyle |= PVTWORD_STYLE_BOLD; |
1107 return SetRichTextProps(EP_BOLD, NULL, &WordProps); | 1107 return SetRichTextProps(EP_BOLD, nullptr, &WordProps); |
1108 } | 1108 } |
1109 | 1109 |
1110 FX_BOOL CFX_Edit::SetRichTextItalic(FX_BOOL bItalic) { | 1110 FX_BOOL CFX_Edit::SetRichTextItalic(FX_BOOL bItalic) { |
1111 CPVT_WordProps WordProps; | 1111 CPVT_WordProps WordProps; |
1112 if (bItalic) | 1112 if (bItalic) |
1113 WordProps.nWordStyle |= PVTWORD_STYLE_ITALIC; | 1113 WordProps.nWordStyle |= PVTWORD_STYLE_ITALIC; |
1114 return SetRichTextProps(EP_ITALIC, NULL, &WordProps); | 1114 return SetRichTextProps(EP_ITALIC, nullptr, &WordProps); |
1115 } | 1115 } |
1116 | 1116 |
1117 FX_BOOL CFX_Edit::SetRichTextUnderline(FX_BOOL bUnderline) { | 1117 FX_BOOL CFX_Edit::SetRichTextUnderline(FX_BOOL bUnderline) { |
1118 CPVT_WordProps WordProps; | 1118 CPVT_WordProps WordProps; |
1119 if (bUnderline) | 1119 if (bUnderline) |
1120 WordProps.nWordStyle |= PVTWORD_STYLE_UNDERLINE; | 1120 WordProps.nWordStyle |= PVTWORD_STYLE_UNDERLINE; |
1121 return SetRichTextProps(EP_UNDERLINE, NULL, &WordProps); | 1121 return SetRichTextProps(EP_UNDERLINE, nullptr, &WordProps); |
1122 } | 1122 } |
1123 | 1123 |
1124 FX_BOOL CFX_Edit::SetRichTextCrossout(FX_BOOL bCrossout) { | 1124 FX_BOOL CFX_Edit::SetRichTextCrossout(FX_BOOL bCrossout) { |
1125 CPVT_WordProps WordProps; | 1125 CPVT_WordProps WordProps; |
1126 if (bCrossout) | 1126 if (bCrossout) |
1127 WordProps.nWordStyle |= PVTWORD_STYLE_CROSSOUT; | 1127 WordProps.nWordStyle |= PVTWORD_STYLE_CROSSOUT; |
1128 return SetRichTextProps(EP_CROSSOUT, NULL, &WordProps); | 1128 return SetRichTextProps(EP_CROSSOUT, nullptr, &WordProps); |
1129 } | 1129 } |
1130 | 1130 |
1131 FX_BOOL CFX_Edit::SetRichTextCharSpace(FX_FLOAT fCharSpace) { | 1131 FX_BOOL CFX_Edit::SetRichTextCharSpace(FX_FLOAT fCharSpace) { |
1132 CPVT_WordProps WordProps; | 1132 CPVT_WordProps WordProps; |
1133 WordProps.fCharSpace = fCharSpace; | 1133 WordProps.fCharSpace = fCharSpace; |
1134 return SetRichTextProps(EP_CHARSPACE, NULL, &WordProps); | 1134 return SetRichTextProps(EP_CHARSPACE, nullptr, &WordProps); |
1135 } | 1135 } |
1136 | 1136 |
1137 FX_BOOL CFX_Edit::SetRichTextHorzScale(int32_t nHorzScale) { | 1137 FX_BOOL CFX_Edit::SetRichTextHorzScale(int32_t nHorzScale) { |
1138 CPVT_WordProps WordProps; | 1138 CPVT_WordProps WordProps; |
1139 WordProps.nHorzScale = nHorzScale; | 1139 WordProps.nHorzScale = nHorzScale; |
1140 return SetRichTextProps(EP_HORZSCALE, NULL, &WordProps); | 1140 return SetRichTextProps(EP_HORZSCALE, nullptr, &WordProps); |
1141 } | 1141 } |
1142 | 1142 |
1143 FX_BOOL CFX_Edit::SetRichTextLineLeading(FX_FLOAT fLineLeading) { | 1143 FX_BOOL CFX_Edit::SetRichTextLineLeading(FX_FLOAT fLineLeading) { |
1144 CPVT_SecProps SecProps; | 1144 CPVT_SecProps SecProps; |
1145 SecProps.fLineLeading = fLineLeading; | 1145 SecProps.fLineLeading = fLineLeading; |
1146 return SetRichTextProps(EP_LINELEADING, &SecProps, NULL); | 1146 return SetRichTextProps(EP_LINELEADING, &SecProps, nullptr); |
1147 } | 1147 } |
1148 | 1148 |
1149 FX_BOOL CFX_Edit::SetRichTextLineIndent(FX_FLOAT fLineIndent) { | 1149 FX_BOOL CFX_Edit::SetRichTextLineIndent(FX_FLOAT fLineIndent) { |
1150 CPVT_SecProps SecProps; | 1150 CPVT_SecProps SecProps; |
1151 SecProps.fLineIndent = fLineIndent; | 1151 SecProps.fLineIndent = fLineIndent; |
1152 return SetRichTextProps(EP_LINEINDENT, &SecProps, NULL); | 1152 return SetRichTextProps(EP_LINEINDENT, &SecProps, nullptr); |
1153 } | 1153 } |
1154 | 1154 |
1155 FX_BOOL CFX_Edit::SetRichTextAlignment(int32_t nAlignment) { | 1155 FX_BOOL CFX_Edit::SetRichTextAlignment(int32_t nAlignment) { |
1156 CPVT_SecProps SecProps; | 1156 CPVT_SecProps SecProps; |
1157 SecProps.nAlignment = nAlignment; | 1157 SecProps.nAlignment = nAlignment; |
1158 return SetRichTextProps(EP_ALIGNMENT, &SecProps, NULL); | 1158 return SetRichTextProps(EP_ALIGNMENT, &SecProps, nullptr); |
1159 } | 1159 } |
1160 | 1160 |
1161 FX_BOOL CFX_Edit::SetRichTextProps(EDIT_PROPS_E eProps, | 1161 FX_BOOL CFX_Edit::SetRichTextProps(EDIT_PROPS_E eProps, |
1162 const CPVT_SecProps* pSecProps, | 1162 const CPVT_SecProps* pSecProps, |
1163 const CPVT_WordProps* pWordProps) { | 1163 const CPVT_WordProps* pWordProps) { |
1164 if (!m_pVT->IsValid() || !m_pVT->IsRichText()) | 1164 if (!m_pVT->IsValid() || !m_pVT->IsRichText()) |
1165 return FALSE; | 1165 return FALSE; |
1166 | 1166 |
1167 CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator(); | 1167 CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator(); |
1168 CPVT_WordRange wrTemp = m_SelState.ConvertToWordRange(); | 1168 CPVT_WordRange wrTemp = m_SelState.ConvertToWordRange(); |
(...skipping 1785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2954 ASSERT(!m_pGroupUndoItem); | 2954 ASSERT(!m_pGroupUndoItem); |
2955 | 2955 |
2956 m_pGroupUndoItem = new CFX_Edit_GroupUndoItem(sTitle); | 2956 m_pGroupUndoItem = new CFX_Edit_GroupUndoItem(sTitle); |
2957 } | 2957 } |
2958 | 2958 |
2959 void CFX_Edit::EndGroupUndo() { | 2959 void CFX_Edit::EndGroupUndo() { |
2960 m_pGroupUndoItem->UpdateItems(); | 2960 m_pGroupUndoItem->UpdateItems(); |
2961 m_Undo.AddItem(m_pGroupUndoItem); | 2961 m_Undo.AddItem(m_pGroupUndoItem); |
2962 if (m_bOprNotify && m_pOprNotify) | 2962 if (m_bOprNotify && m_pOprNotify) |
2963 m_pOprNotify->OnAddUndo(m_pGroupUndoItem); | 2963 m_pOprNotify->OnAddUndo(m_pGroupUndoItem); |
2964 m_pGroupUndoItem = NULL; | 2964 m_pGroupUndoItem = nullptr; |
2965 } | 2965 } |
2966 | 2966 |
2967 void CFX_Edit::AddEditUndoItem(CFX_Edit_UndoItem* pEditUndoItem) { | 2967 void CFX_Edit::AddEditUndoItem(CFX_Edit_UndoItem* pEditUndoItem) { |
2968 if (m_pGroupUndoItem) { | 2968 if (m_pGroupUndoItem) { |
2969 m_pGroupUndoItem->AddUndoItem(pEditUndoItem); | 2969 m_pGroupUndoItem->AddUndoItem(pEditUndoItem); |
2970 } else { | 2970 } else { |
2971 m_Undo.AddItem(pEditUndoItem); | 2971 m_Undo.AddItem(pEditUndoItem); |
2972 if (m_bOprNotify && m_pOprNotify) | 2972 if (m_bOprNotify && m_pOprNotify) |
2973 m_pOprNotify->OnAddUndo(pEditUndoItem); | 2973 m_pOprNotify->OnAddUndo(pEditUndoItem); |
2974 } | 2974 } |
2975 } | 2975 } |
2976 | 2976 |
2977 void CFX_Edit::AddUndoItem(IFX_Edit_UndoItem* pUndoItem) { | 2977 void CFX_Edit::AddUndoItem(IFX_Edit_UndoItem* pUndoItem) { |
2978 m_Undo.AddItem(pUndoItem); | 2978 m_Undo.AddItem(pUndoItem); |
2979 if (m_bOprNotify && m_pOprNotify) | 2979 if (m_bOprNotify && m_pOprNotify) |
2980 m_pOprNotify->OnAddUndo(pUndoItem); | 2980 m_pOprNotify->OnAddUndo(pUndoItem); |
2981 } | 2981 } |
OLD | NEW |