| 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 10 matching lines...) Expand all Loading... |
| 21 #include "core/fpdfdoc/include/ipvt_fontmap.h" | 21 #include "core/fpdfdoc/include/ipvt_fontmap.h" |
| 22 #include "core/fxge/include/cfx_graphstatedata.h" | 22 #include "core/fxge/include/cfx_graphstatedata.h" |
| 23 #include "core/fxge/include/cfx_pathdata.h" | 23 #include "core/fxge/include/cfx_pathdata.h" |
| 24 #include "core/fxge/include/cfx_renderdevice.h" | 24 #include "core/fxge/include/cfx_renderdevice.h" |
| 25 #include "fpdfsdk/cfx_systemhandler.h" | 25 #include "fpdfsdk/cfx_systemhandler.h" |
| 26 #include "fpdfsdk/fxedit/include/fx_edit.h" | 26 #include "fpdfsdk/fxedit/include/fx_edit.h" |
| 27 #include "fpdfsdk/fxedit/include/fxet_edit.h" | 27 #include "fpdfsdk/fxedit/include/fxet_edit.h" |
| 28 #include "fpdfsdk/pdfwindow/PWL_Edit.h" | 28 #include "fpdfsdk/pdfwindow/PWL_Edit.h" |
| 29 #include "fpdfsdk/pdfwindow/PWL_EditCtrl.h" | 29 #include "fpdfsdk/pdfwindow/PWL_EditCtrl.h" |
| 30 | 30 |
| 31 #define PVTWORD_STYLE_UNDERLINE 0x0002L | |
| 32 #define PVTWORD_STYLE_CROSSOUT 0x0004L | |
| 33 #define PVTWORD_STYLE_BOLD 0x0020L | |
| 34 #define PVTWORD_STYLE_ITALIC 0x0040L | |
| 35 | |
| 36 namespace { | 31 namespace { |
| 37 | 32 |
| 38 const int kEditUndoMaxItems = 10000; | 33 const int kEditUndoMaxItems = 10000; |
| 39 | 34 |
| 40 CFX_ByteString GetWordRenderString(const CFX_ByteString& strWords) { | 35 CFX_ByteString GetWordRenderString(const CFX_ByteString& strWords) { |
| 41 if (strWords.GetLength() > 0) | 36 if (strWords.GetLength() > 0) |
| 42 return PDF_EncodeString(strWords) + " Tj\n"; | 37 return PDF_EncodeString(strWords) + " Tj\n"; |
| 43 return CFX_ByteString(); | 38 return CFX_ByteString(); |
| 44 } | 39 } |
| 45 | 40 |
| 46 CFX_ByteString GetFontSetString(IPVT_FontMap* pFontMap, | 41 CFX_ByteString GetFontSetString(IPVT_FontMap* pFontMap, |
| 47 int32_t nFontIndex, | 42 int32_t nFontIndex, |
| 48 FX_FLOAT fFontSize) { | 43 FX_FLOAT fFontSize) { |
| 49 if (!pFontMap) | 44 if (!pFontMap) |
| 50 return CFX_ByteString(); | 45 return CFX_ByteString(); |
| 51 | 46 |
| 52 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); | 47 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); |
| 53 if (sFontAlias.GetLength() <= 0 || fFontSize <= 0) | 48 if (sFontAlias.GetLength() <= 0 || fFontSize <= 0) |
| 54 return CFX_ByteString(); | 49 return CFX_ByteString(); |
| 55 | 50 |
| 56 CFX_ByteTextBuf sRet; | 51 CFX_ByteTextBuf sRet; |
| 57 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; | 52 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; |
| 58 return sRet.MakeString(); | 53 return sRet.MakeString(); |
| 59 } | 54 } |
| 60 | 55 |
| 61 CFX_FloatRect GetUnderLineRect(const CPVT_Word& word) { | |
| 62 return CFX_FloatRect(word.ptWord.x, word.ptWord.y + word.fDescent * 0.5f, | |
| 63 word.ptWord.x + word.fWidth, | |
| 64 word.ptWord.y + word.fDescent * 0.25f); | |
| 65 } | |
| 66 | |
| 67 CFX_FloatRect GetCrossoutRect(const CPVT_Word& word) { | |
| 68 return CFX_FloatRect(word.ptWord.x, | |
| 69 word.ptWord.y + (word.fAscent + word.fDescent) * 0.5f + | |
| 70 word.fDescent * 0.25f, | |
| 71 word.ptWord.x + word.fWidth, | |
| 72 word.ptWord.y + (word.fAscent + word.fDescent) * 0.5f); | |
| 73 } | |
| 74 | |
| 75 void DrawTextString(CFX_RenderDevice* pDevice, | 56 void DrawTextString(CFX_RenderDevice* pDevice, |
| 76 const CFX_FloatPoint& pt, | 57 const CFX_FloatPoint& pt, |
| 77 CPDF_Font* pFont, | 58 CPDF_Font* pFont, |
| 78 FX_FLOAT fFontSize, | 59 FX_FLOAT fFontSize, |
| 79 CFX_Matrix* pUser2Device, | 60 CFX_Matrix* pUser2Device, |
| 80 const CFX_ByteString& str, | 61 const CFX_ByteString& str, |
| 81 FX_ARGB crTextFill, | 62 FX_ARGB crTextFill, |
| 82 FX_ARGB crTextStroke, | 63 FX_ARGB crTextStroke, |
| 83 int32_t nHorzScale) { | 64 int32_t nHorzScale) { |
| 84 FX_FLOAT x = pt.x, y = pt.y; | 65 FX_FLOAT x = pt.x, y = pt.y; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 crTextStroke, &gsd, &ro); | 107 crTextStroke, &gsd, &ro); |
| 127 } else { | 108 } else { |
| 128 CPDF_TextRenderer::DrawTextString(pDevice, x, y, pFont, fFontSize, | 109 CPDF_TextRenderer::DrawTextString(pDevice, x, y, pFont, fFontSize, |
| 129 pUser2Device, str, crTextFill, 0, | 110 pUser2Device, str, crTextFill, 0, |
| 130 nullptr, &ro); | 111 nullptr, &ro); |
| 131 } | 112 } |
| 132 } | 113 } |
| 133 } | 114 } |
| 134 } | 115 } |
| 135 | 116 |
| 136 void AddRectToPageObjects(CPDF_PageObjectHolder* pObjectHolder, | |
| 137 FX_COLORREF crFill, | |
| 138 const CFX_FloatRect& rcFill) { | |
| 139 std::unique_ptr<CPDF_PathObject> pPathObj(new CPDF_PathObject); | |
| 140 pPathObj->m_Path.AppendRect(rcFill.left, rcFill.bottom, rcFill.right, | |
| 141 rcFill.top); | |
| 142 | |
| 143 FX_FLOAT rgb[3]; | |
| 144 rgb[0] = FXARGB_R(crFill) / 255.0f; | |
| 145 rgb[1] = FXARGB_G(crFill) / 255.0f; | |
| 146 rgb[2] = FXARGB_B(crFill) / 255.0f; | |
| 147 pPathObj->m_ColorState.SetFillColor( | |
| 148 CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), rgb, 3); | |
| 149 | |
| 150 pPathObj->m_FillType = FXFILL_ALTERNATE; | |
| 151 pPathObj->m_bStroke = FALSE; | |
| 152 pObjectHolder->GetPageObjectList()->push_back(std::move(pPathObj)); | |
| 153 } | |
| 154 | |
| 155 CPDF_TextObject* AddTextObjToPageObjects(CPDF_PageObjectHolder* pObjectHolder, | 117 CPDF_TextObject* AddTextObjToPageObjects(CPDF_PageObjectHolder* pObjectHolder, |
| 156 FX_COLORREF crText, | 118 FX_COLORREF crText, |
| 157 CPDF_Font* pFont, | 119 CPDF_Font* pFont, |
| 158 FX_FLOAT fFontSize, | 120 FX_FLOAT fFontSize, |
| 159 FX_FLOAT fCharSpace, | 121 FX_FLOAT fCharSpace, |
| 160 int32_t nHorzScale, | 122 int32_t nHorzScale, |
| 161 const CFX_FloatPoint& point, | 123 const CFX_FloatPoint& point, |
| 162 const CFX_ByteString& text) { | 124 const CFX_ByteString& text) { |
| 163 std::unique_ptr<CPDF_TextObject> pTxtObj(new CPDF_TextObject); | 125 std::unique_ptr<CPDF_TextObject> pTxtObj(new CPDF_TextObject); |
| 164 pTxtObj->m_TextState.SetFont(pFont); | 126 pTxtObj->m_TextState.SetFont(pFont); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 195 CFX_Edit_Iterator::CFX_Edit_Iterator(CFX_Edit* pEdit, | 157 CFX_Edit_Iterator::CFX_Edit_Iterator(CFX_Edit* pEdit, |
| 196 CPDF_VariableText::Iterator* pVTIterator) | 158 CPDF_VariableText::Iterator* pVTIterator) |
| 197 : m_pEdit(pEdit), m_pVTIterator(pVTIterator) {} | 159 : m_pEdit(pEdit), m_pVTIterator(pVTIterator) {} |
| 198 | 160 |
| 199 CFX_Edit_Iterator::~CFX_Edit_Iterator() {} | 161 CFX_Edit_Iterator::~CFX_Edit_Iterator() {} |
| 200 | 162 |
| 201 FX_BOOL CFX_Edit_Iterator::NextWord() { | 163 FX_BOOL CFX_Edit_Iterator::NextWord() { |
| 202 return m_pVTIterator->NextWord(); | 164 return m_pVTIterator->NextWord(); |
| 203 } | 165 } |
| 204 | 166 |
| 205 FX_BOOL CFX_Edit_Iterator::NextLine() { | |
| 206 return m_pVTIterator->NextLine(); | |
| 207 } | |
| 208 | |
| 209 FX_BOOL CFX_Edit_Iterator::NextSection() { | |
| 210 return m_pVTIterator->NextSection(); | |
| 211 } | |
| 212 | |
| 213 FX_BOOL CFX_Edit_Iterator::PrevWord() { | 167 FX_BOOL CFX_Edit_Iterator::PrevWord() { |
| 214 return m_pVTIterator->PrevWord(); | 168 return m_pVTIterator->PrevWord(); |
| 215 } | 169 } |
| 216 | 170 |
| 217 FX_BOOL CFX_Edit_Iterator::PrevLine() { | |
| 218 return m_pVTIterator->PrevLine(); | |
| 219 } | |
| 220 | |
| 221 FX_BOOL CFX_Edit_Iterator::PrevSection() { | |
| 222 return m_pVTIterator->PrevSection(); | |
| 223 } | |
| 224 | |
| 225 FX_BOOL CFX_Edit_Iterator::GetWord(CPVT_Word& word) const { | 171 FX_BOOL CFX_Edit_Iterator::GetWord(CPVT_Word& word) const { |
| 226 ASSERT(m_pEdit); | 172 ASSERT(m_pEdit); |
| 227 | 173 |
| 228 if (m_pVTIterator->GetWord(word)) { | 174 if (m_pVTIterator->GetWord(word)) { |
| 229 word.ptWord = m_pEdit->VTToEdit(word.ptWord); | 175 word.ptWord = m_pEdit->VTToEdit(word.ptWord); |
| 230 return TRUE; | 176 return TRUE; |
| 231 } | 177 } |
| 232 return FALSE; | 178 return FALSE; |
| 233 } | 179 } |
| 234 | 180 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 257 } | 203 } |
| 258 | 204 |
| 259 void CFX_Edit_Iterator::SetAt(const CPVT_WordPlace& place) { | 205 void CFX_Edit_Iterator::SetAt(const CPVT_WordPlace& place) { |
| 260 m_pVTIterator->SetAt(place); | 206 m_pVTIterator->SetAt(place); |
| 261 } | 207 } |
| 262 | 208 |
| 263 const CPVT_WordPlace& CFX_Edit_Iterator::GetAt() const { | 209 const CPVT_WordPlace& CFX_Edit_Iterator::GetAt() const { |
| 264 return m_pVTIterator->GetAt(); | 210 return m_pVTIterator->GetAt(); |
| 265 } | 211 } |
| 266 | 212 |
| 267 CFX_Edit* CFX_Edit_Iterator::GetEdit() const { | |
| 268 return m_pEdit; | |
| 269 } | |
| 270 | |
| 271 CFX_Edit_Provider::CFX_Edit_Provider(IPVT_FontMap* pFontMap) | 213 CFX_Edit_Provider::CFX_Edit_Provider(IPVT_FontMap* pFontMap) |
| 272 : CPDF_VariableText::Provider(pFontMap), m_pFontMap(pFontMap) { | 214 : CPDF_VariableText::Provider(pFontMap), m_pFontMap(pFontMap) { |
| 273 ASSERT(m_pFontMap); | 215 ASSERT(m_pFontMap); |
| 274 } | 216 } |
| 275 | 217 |
| 276 CFX_Edit_Provider::~CFX_Edit_Provider() {} | 218 CFX_Edit_Provider::~CFX_Edit_Provider() {} |
| 277 | 219 |
| 278 IPVT_FontMap* CFX_Edit_Provider::GetFontMap() { | 220 IPVT_FontMap* CFX_Edit_Provider::GetFontMap() { |
| 279 return m_pFontMap; | 221 return m_pFontMap; |
| 280 } | 222 } |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 IFX_Edit_UndoItem* pItem = m_UndoItemStack.GetAt(m_nCurUndoPos); | 349 IFX_Edit_UndoItem* pItem = m_UndoItemStack.GetAt(m_nCurUndoPos); |
| 408 pItem->Redo(); | 350 pItem->Redo(); |
| 409 | 351 |
| 410 m_nCurUndoPos++; | 352 m_nCurUndoPos++; |
| 411 m_bModified = (m_nCurUndoPos != 0); | 353 m_bModified = (m_nCurUndoPos != 0); |
| 412 } | 354 } |
| 413 | 355 |
| 414 m_bWorking = FALSE; | 356 m_bWorking = FALSE; |
| 415 } | 357 } |
| 416 | 358 |
| 417 FX_BOOL CFX_Edit_Undo::IsWorking() const { | |
| 418 return m_bWorking; | |
| 419 } | |
| 420 | |
| 421 void CFX_Edit_Undo::AddItem(IFX_Edit_UndoItem* pItem) { | 359 void CFX_Edit_Undo::AddItem(IFX_Edit_UndoItem* pItem) { |
| 422 ASSERT(!m_bWorking); | 360 ASSERT(!m_bWorking); |
| 423 ASSERT(pItem); | 361 ASSERT(pItem); |
| 424 ASSERT(m_nBufSize > 1); | 362 ASSERT(m_nBufSize > 1); |
| 425 | 363 |
| 426 if (m_nCurUndoPos < m_UndoItemStack.GetSize()) | 364 if (m_nCurUndoPos < m_UndoItemStack.GetSize()) |
| 427 RemoveTails(); | 365 RemoveTails(); |
| 428 | 366 |
| 429 if (m_UndoItemStack.GetSize() >= m_nBufSize) { | 367 if (m_UndoItemStack.GetSize() >= m_nBufSize) { |
| 430 RemoveHeads(); | 368 RemoveHeads(); |
| 431 m_bVirgin = FALSE; | 369 m_bVirgin = FALSE; |
| 432 } | 370 } |
| 433 | 371 |
| 434 m_UndoItemStack.Add(pItem); | 372 m_UndoItemStack.Add(pItem); |
| 435 m_nCurUndoPos = m_UndoItemStack.GetSize(); | 373 m_nCurUndoPos = m_UndoItemStack.GetSize(); |
| 436 | 374 |
| 437 m_bModified = (m_nCurUndoPos != 0); | 375 m_bModified = (m_nCurUndoPos != 0); |
| 438 } | 376 } |
| 439 | 377 |
| 440 FX_BOOL CFX_Edit_Undo::IsModified() const { | 378 FX_BOOL CFX_Edit_Undo::IsModified() const { |
| 441 return m_bVirgin ? m_bModified : TRUE; | 379 return m_bVirgin ? m_bModified : TRUE; |
| 442 } | 380 } |
| 443 | 381 |
| 444 IFX_Edit_UndoItem* CFX_Edit_Undo::GetItem(int32_t nIndex) { | |
| 445 if (nIndex >= 0 && nIndex < m_UndoItemStack.GetSize()) | |
| 446 return m_UndoItemStack.GetAt(nIndex); | |
| 447 | |
| 448 return nullptr; | |
| 449 } | |
| 450 | |
| 451 void CFX_Edit_Undo::RemoveHeads() { | 382 void CFX_Edit_Undo::RemoveHeads() { |
| 452 ASSERT(m_UndoItemStack.GetSize() > 1); | 383 ASSERT(m_UndoItemStack.GetSize() > 1); |
| 453 | 384 |
| 454 delete m_UndoItemStack.GetAt(0); | 385 delete m_UndoItemStack.GetAt(0); |
| 455 m_UndoItemStack.RemoveAt(0); | 386 m_UndoItemStack.RemoveAt(0); |
| 456 } | 387 } |
| 457 | 388 |
| 458 void CFX_Edit_Undo::RemoveTails() { | 389 void CFX_Edit_Undo::RemoveTails() { |
| 459 for (int32_t i = m_UndoItemStack.GetSize() - 1; i >= m_nCurUndoPos; i--) { | 390 for (int32_t i = m_UndoItemStack.GetSize() - 1; i >= m_nCurUndoPos; i--) { |
| 460 delete m_UndoItemStack.GetAt(i); | 391 delete m_UndoItemStack.GetAt(i); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 475 CFX_Edit_UndoItem::~CFX_Edit_UndoItem() {} | 406 CFX_Edit_UndoItem::~CFX_Edit_UndoItem() {} |
| 476 | 407 |
| 477 CFX_WideString CFX_Edit_UndoItem::GetUndoTitle() { | 408 CFX_WideString CFX_Edit_UndoItem::GetUndoTitle() { |
| 478 return L""; | 409 return L""; |
| 479 } | 410 } |
| 480 | 411 |
| 481 void CFX_Edit_UndoItem::SetFirst(FX_BOOL bFirst) { | 412 void CFX_Edit_UndoItem::SetFirst(FX_BOOL bFirst) { |
| 482 m_bFirst = bFirst; | 413 m_bFirst = bFirst; |
| 483 } | 414 } |
| 484 | 415 |
| 485 FX_BOOL CFX_Edit_UndoItem::IsFirst() { | |
| 486 return m_bFirst; | |
| 487 } | |
| 488 | |
| 489 void CFX_Edit_UndoItem::SetLast(FX_BOOL bLast) { | 416 void CFX_Edit_UndoItem::SetLast(FX_BOOL bLast) { |
| 490 m_bLast = bLast; | 417 m_bLast = bLast; |
| 491 } | 418 } |
| 492 | 419 |
| 493 FX_BOOL CFX_Edit_UndoItem::IsLast() { | 420 FX_BOOL CFX_Edit_UndoItem::IsLast() { |
| 494 return m_bLast; | 421 return m_bLast; |
| 495 } | 422 } |
| 496 | 423 |
| 497 CFX_Edit_GroupUndoItem::CFX_Edit_GroupUndoItem(const CFX_WideString& sTitle) | 424 CFX_Edit_GroupUndoItem::CFX_Edit_GroupUndoItem(const CFX_WideString& sTitle) |
| 498 : m_sTitle(sTitle) {} | 425 : m_sTitle(sTitle) {} |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 sRet << word.ptWord.x + ptOffset.x << " " | 804 sRet << word.ptWord.x + ptOffset.x << " " |
| 878 << line.ptLine.y + line.fLineDescent << " " << word.fWidth << " " | 805 << line.ptLine.y + line.fLineDescent << " " << word.fWidth << " " |
| 879 << line.fLineAscent - line.fLineDescent << " re\nf\n"; | 806 << line.fLineAscent - line.fLineDescent << " re\nf\n"; |
| 880 } | 807 } |
| 881 } | 808 } |
| 882 | 809 |
| 883 return sRet.MakeString(); | 810 return sRet.MakeString(); |
| 884 } | 811 } |
| 885 | 812 |
| 886 // static | 813 // static |
| 887 void CFX_Edit::DrawUnderline(CFX_RenderDevice* pDevice, | |
| 888 CFX_Matrix* pUser2Device, | |
| 889 CFX_Edit* pEdit, | |
| 890 FX_COLORREF color, | |
| 891 const CFX_FloatRect& rcClip, | |
| 892 const CFX_FloatPoint& ptOffset, | |
| 893 const CPVT_WordRange* pRange) { | |
| 894 pDevice->SaveState(); | |
| 895 | |
| 896 if (!rcClip.IsEmpty()) { | |
| 897 CFX_FloatRect rcTemp = rcClip; | |
| 898 pUser2Device->TransformRect(rcTemp); | |
| 899 pDevice->SetClip_Rect(rcTemp.ToFxRect()); | |
| 900 } | |
| 901 | |
| 902 CFX_Edit_Iterator* pIterator = pEdit->GetIterator(); | |
| 903 if (pEdit->GetFontMap()) { | |
| 904 if (pRange) | |
| 905 pIterator->SetAt(pRange->BeginPos); | |
| 906 else | |
| 907 pIterator->SetAt(0); | |
| 908 | |
| 909 while (pIterator->NextWord()) { | |
| 910 CPVT_WordPlace place = pIterator->GetAt(); | |
| 911 if (pRange && place.WordCmp(pRange->EndPos) > 0) | |
| 912 break; | |
| 913 | |
| 914 CPVT_Word word; | |
| 915 if (pIterator->GetWord(word)) { | |
| 916 CFX_PathData pathUnderline; | |
| 917 CFX_FloatRect rcUnderline = GetUnderLineRect(word); | |
| 918 rcUnderline.left += ptOffset.x; | |
| 919 rcUnderline.right += ptOffset.x; | |
| 920 rcUnderline.top += ptOffset.y; | |
| 921 rcUnderline.bottom += ptOffset.y; | |
| 922 pathUnderline.AppendRect(rcUnderline.left, rcUnderline.bottom, | |
| 923 rcUnderline.right, rcUnderline.top); | |
| 924 | |
| 925 pDevice->DrawPath(&pathUnderline, pUser2Device, nullptr, color, 0, | |
| 926 FXFILL_WINDING); | |
| 927 } | |
| 928 } | |
| 929 } | |
| 930 | |
| 931 pDevice->RestoreState(false); | |
| 932 } | |
| 933 | |
| 934 // static | |
| 935 void CFX_Edit::DrawEdit(CFX_RenderDevice* pDevice, | 814 void CFX_Edit::DrawEdit(CFX_RenderDevice* pDevice, |
| 936 CFX_Matrix* pUser2Device, | 815 CFX_Matrix* pUser2Device, |
| 937 CFX_Edit* pEdit, | 816 CFX_Edit* pEdit, |
| 938 FX_COLORREF crTextFill, | 817 FX_COLORREF crTextFill, |
| 939 FX_COLORREF crTextStroke, | 818 FX_COLORREF crTextStroke, |
| 940 const CFX_FloatRect& rcClip, | 819 const CFX_FloatRect& rcClip, |
| 941 const CFX_FloatPoint& ptOffset, | 820 const CFX_FloatPoint& ptOffset, |
| 942 const CPVT_WordRange* pRange, | 821 const CPVT_WordRange* pRange, |
| 943 CFX_SystemHandler* pSystemHandler, | 822 CFX_SystemHandler* pSystemHandler, |
| 944 void* pFFLData) { | 823 void* pFFLData) { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1050 pDevice, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), | 929 pDevice, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), |
| 1051 pFontMap->GetPDFFont(nFontIndex), fFontSize, pUser2Device, | 930 pFontMap->GetPDFFont(nFontIndex), fFontSize, pUser2Device, |
| 1052 sTextBuf.MakeString(), crOldFill, crTextStroke, nHorzScale); | 931 sTextBuf.MakeString(), crOldFill, crTextStroke, nHorzScale); |
| 1053 } | 932 } |
| 1054 } | 933 } |
| 1055 | 934 |
| 1056 pDevice->RestoreState(false); | 935 pDevice->RestoreState(false); |
| 1057 } | 936 } |
| 1058 | 937 |
| 1059 // static | 938 // static |
| 1060 void CFX_Edit::DrawRichEdit(CFX_RenderDevice* pDevice, | |
| 1061 CFX_Matrix* pUser2Device, | |
| 1062 CFX_Edit* pEdit, | |
| 1063 const CFX_FloatRect& rcClip, | |
| 1064 const CFX_FloatPoint& ptOffset, | |
| 1065 const CPVT_WordRange* pRange) { | |
| 1066 CPVT_WordRange wrSelect = pEdit->GetSelectWordRange(); | |
| 1067 | |
| 1068 FX_COLORREF crCurText = ArgbEncode(255, 0, 0, 0); | |
| 1069 FX_COLORREF crOld = crCurText; | |
| 1070 FX_BOOL bSelect = FALSE; | |
| 1071 const FX_COLORREF crWhite = ArgbEncode(255, 255, 255, 255); | |
| 1072 const FX_COLORREF crSelBK = ArgbEncode(255, 0, 51, 113); | |
| 1073 | |
| 1074 CFX_ByteTextBuf sTextBuf; | |
| 1075 CPVT_WordProps wp; | |
| 1076 CFX_FloatPoint ptBT(0.0f, 0.0f); | |
| 1077 | |
| 1078 pDevice->SaveState(); | |
| 1079 | |
| 1080 if (!rcClip.IsEmpty()) { | |
| 1081 CFX_FloatRect rcTemp = rcClip; | |
| 1082 pUser2Device->TransformRect(rcTemp); | |
| 1083 pDevice->SetClip_Rect(rcTemp.ToFxRect()); | |
| 1084 } | |
| 1085 | |
| 1086 CFX_Edit_Iterator* pIterator = pEdit->GetIterator(); | |
| 1087 if (IPVT_FontMap* pFontMap = pEdit->GetFontMap()) { | |
| 1088 if (pRange) | |
| 1089 pIterator->SetAt(pRange->BeginPos); | |
| 1090 else | |
| 1091 pIterator->SetAt(0); | |
| 1092 | |
| 1093 CPVT_WordPlace oldplace; | |
| 1094 | |
| 1095 while (pIterator->NextWord()) { | |
| 1096 CPVT_WordPlace place = pIterator->GetAt(); | |
| 1097 if (pRange && place.WordCmp(pRange->EndPos) > 0) | |
| 1098 break; | |
| 1099 | |
| 1100 CPVT_Word word; | |
| 1101 if (pIterator->GetWord(word)) { | |
| 1102 word.WordProps.fFontSize = word.fFontSize; | |
| 1103 | |
| 1104 crCurText = ArgbEncode(255, word.WordProps.dwWordColor); | |
| 1105 | |
| 1106 if (wrSelect.IsExist()) { | |
| 1107 bSelect = place.WordCmp(wrSelect.BeginPos) > 0 && | |
| 1108 place.WordCmp(wrSelect.EndPos) <= 0; | |
| 1109 if (bSelect) { | |
| 1110 crCurText = crWhite; | |
| 1111 } | |
| 1112 } | |
| 1113 | |
| 1114 if (bSelect) { | |
| 1115 CPVT_Line line; | |
| 1116 pIterator->GetLine(line); | |
| 1117 | |
| 1118 CFX_PathData pathSelBK; | |
| 1119 pathSelBK.AppendRect(word.ptWord.x + ptOffset.x, | |
| 1120 line.ptLine.y + line.fLineDescent + ptOffset.y, | |
| 1121 word.ptWord.x + word.fWidth + ptOffset.x, | |
| 1122 line.ptLine.y + line.fLineAscent + ptOffset.y); | |
| 1123 | |
| 1124 pDevice->DrawPath(&pathSelBK, pUser2Device, nullptr, crSelBK, 0, | |
| 1125 FXFILL_WINDING); | |
| 1126 } | |
| 1127 | |
| 1128 if (place.LineCmp(oldplace) != 0 || word.WordProps.fCharSpace > 0.0f || | |
| 1129 word.WordProps.nHorzScale != 100 || | |
| 1130 FXSYS_memcmp(&word.WordProps, &wp, sizeof(CPVT_WordProps)) != 0 || | |
| 1131 crOld != crCurText) { | |
| 1132 if (sTextBuf.GetLength() > 0) { | |
| 1133 DrawTextString( | |
| 1134 pDevice, | |
| 1135 CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), | |
| 1136 pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, pUser2Device, | |
| 1137 sTextBuf.MakeString(), crOld, 0, wp.nHorzScale); | |
| 1138 | |
| 1139 sTextBuf.Clear(); | |
| 1140 } | |
| 1141 wp = word.WordProps; | |
| 1142 ptBT = word.ptWord; | |
| 1143 crOld = crCurText; | |
| 1144 } | |
| 1145 | |
| 1146 sTextBuf << GetPDFWordString(pFontMap, word.WordProps.nFontIndex, | |
| 1147 word.Word, 0) | |
| 1148 .AsStringC(); | |
| 1149 | |
| 1150 if (word.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) { | |
| 1151 CFX_PathData pathUnderline; | |
| 1152 CFX_FloatRect rcUnderline = GetUnderLineRect(word); | |
| 1153 pathUnderline.AppendRect(rcUnderline.left, rcUnderline.bottom, | |
| 1154 rcUnderline.right, rcUnderline.top); | |
| 1155 | |
| 1156 pDevice->DrawPath(&pathUnderline, pUser2Device, nullptr, crCurText, 0, | |
| 1157 FXFILL_WINDING); | |
| 1158 } | |
| 1159 | |
| 1160 if (word.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) { | |
| 1161 CFX_PathData pathCrossout; | |
| 1162 CFX_FloatRect rcCrossout = GetCrossoutRect(word); | |
| 1163 pathCrossout.AppendRect(rcCrossout.left, rcCrossout.bottom, | |
| 1164 rcCrossout.right, rcCrossout.top); | |
| 1165 | |
| 1166 pDevice->DrawPath(&pathCrossout, pUser2Device, nullptr, crCurText, 0, | |
| 1167 FXFILL_WINDING); | |
| 1168 } | |
| 1169 | |
| 1170 oldplace = place; | |
| 1171 } | |
| 1172 } | |
| 1173 | |
| 1174 if (sTextBuf.GetLength() > 0) { | |
| 1175 DrawTextString( | |
| 1176 pDevice, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), | |
| 1177 pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, pUser2Device, | |
| 1178 sTextBuf.MakeString(), crOld, 0, wp.nHorzScale); | |
| 1179 } | |
| 1180 } | |
| 1181 | |
| 1182 pDevice->RestoreState(false); | |
| 1183 } | |
| 1184 | |
| 1185 // static | |
| 1186 void CFX_Edit::GeneratePageObjects( | 939 void CFX_Edit::GeneratePageObjects( |
| 1187 CPDF_PageObjectHolder* pObjectHolder, | 940 CPDF_PageObjectHolder* pObjectHolder, |
| 1188 CFX_Edit* pEdit, | 941 CFX_Edit* pEdit, |
| 1189 const CFX_FloatPoint& ptOffset, | 942 const CFX_FloatPoint& ptOffset, |
| 1190 const CPVT_WordRange* pRange, | 943 const CPVT_WordRange* pRange, |
| 1191 FX_COLORREF crText, | 944 FX_COLORREF crText, |
| 1192 CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) { | 945 CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) { |
| 1193 FX_FLOAT fFontSize = pEdit->GetFontSize(); | 946 FX_FLOAT fFontSize = pEdit->GetFontSize(); |
| 1194 | 947 |
| 1195 int32_t nOldFontIndex = -1; | 948 int32_t nOldFontIndex = -1; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1238 | 991 |
| 1239 if (sTextBuf.GetLength() > 0) { | 992 if (sTextBuf.GetLength() > 0) { |
| 1240 ObjArray.Add(AddTextObjToPageObjects( | 993 ObjArray.Add(AddTextObjToPageObjects( |
| 1241 pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex), fFontSize, | 994 pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex), fFontSize, |
| 1242 0.0f, 100, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), | 995 0.0f, 100, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), |
| 1243 sTextBuf.MakeString())); | 996 sTextBuf.MakeString())); |
| 1244 } | 997 } |
| 1245 } | 998 } |
| 1246 } | 999 } |
| 1247 | 1000 |
| 1248 // static | |
| 1249 void CFX_Edit::GenerateRichPageObjects( | |
| 1250 CPDF_PageObjectHolder* pObjectHolder, | |
| 1251 CFX_Edit* pEdit, | |
| 1252 const CFX_FloatPoint& ptOffset, | |
| 1253 const CPVT_WordRange* pRange, | |
| 1254 CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) { | |
| 1255 FX_COLORREF crCurText = ArgbEncode(255, 0, 0, 0); | |
| 1256 FX_COLORREF crOld = crCurText; | |
| 1257 | |
| 1258 CFX_ByteTextBuf sTextBuf; | |
| 1259 CPVT_WordProps wp; | |
| 1260 CFX_FloatPoint ptBT(0.0f, 0.0f); | |
| 1261 | |
| 1262 ObjArray.RemoveAll(); | |
| 1263 | |
| 1264 CFX_Edit_Iterator* pIterator = pEdit->GetIterator(); | |
| 1265 if (IPVT_FontMap* pFontMap = pEdit->GetFontMap()) { | |
| 1266 if (pRange) | |
| 1267 pIterator->SetAt(pRange->BeginPos); | |
| 1268 else | |
| 1269 pIterator->SetAt(0); | |
| 1270 | |
| 1271 CPVT_WordPlace oldplace; | |
| 1272 | |
| 1273 while (pIterator->NextWord()) { | |
| 1274 CPVT_WordPlace place = pIterator->GetAt(); | |
| 1275 if (pRange && place.WordCmp(pRange->EndPos) > 0) | |
| 1276 break; | |
| 1277 | |
| 1278 CPVT_Word word; | |
| 1279 if (pIterator->GetWord(word)) { | |
| 1280 word.WordProps.fFontSize = word.fFontSize; | |
| 1281 | |
| 1282 crCurText = ArgbEncode(255, word.WordProps.dwWordColor); | |
| 1283 | |
| 1284 if (place.LineCmp(oldplace) != 0 || word.WordProps.fCharSpace > 0.0f || | |
| 1285 word.WordProps.nHorzScale != 100 || | |
| 1286 FXSYS_memcmp(&word.WordProps, &wp, sizeof(CPVT_WordProps)) != 0 || | |
| 1287 crOld != crCurText) { | |
| 1288 if (sTextBuf.GetLength() > 0) { | |
| 1289 ObjArray.Add(AddTextObjToPageObjects( | |
| 1290 pObjectHolder, crOld, pFontMap->GetPDFFont(wp.nFontIndex), | |
| 1291 wp.fFontSize, wp.fCharSpace, wp.nHorzScale, | |
| 1292 CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), | |
| 1293 sTextBuf.MakeString())); | |
| 1294 | |
| 1295 sTextBuf.Clear(); | |
| 1296 } | |
| 1297 | |
| 1298 wp = word.WordProps; | |
| 1299 ptBT = word.ptWord; | |
| 1300 crOld = crCurText; | |
| 1301 } | |
| 1302 | |
| 1303 sTextBuf << GetPDFWordString(pFontMap, word.WordProps.nFontIndex, | |
| 1304 word.Word, 0) | |
| 1305 .AsStringC(); | |
| 1306 | |
| 1307 if (word.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) { | |
| 1308 CFX_FloatRect rcUnderline = GetUnderLineRect(word); | |
| 1309 rcUnderline.left += ptOffset.x; | |
| 1310 rcUnderline.right += ptOffset.x; | |
| 1311 rcUnderline.top += ptOffset.y; | |
| 1312 rcUnderline.bottom += ptOffset.y; | |
| 1313 | |
| 1314 AddRectToPageObjects(pObjectHolder, crCurText, rcUnderline); | |
| 1315 } | |
| 1316 | |
| 1317 if (word.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) { | |
| 1318 CFX_FloatRect rcCrossout = GetCrossoutRect(word); | |
| 1319 rcCrossout.left += ptOffset.x; | |
| 1320 rcCrossout.right += ptOffset.x; | |
| 1321 rcCrossout.top += ptOffset.y; | |
| 1322 rcCrossout.bottom += ptOffset.y; | |
| 1323 | |
| 1324 AddRectToPageObjects(pObjectHolder, crCurText, rcCrossout); | |
| 1325 } | |
| 1326 | |
| 1327 oldplace = place; | |
| 1328 } | |
| 1329 } | |
| 1330 | |
| 1331 if (sTextBuf.GetLength() > 0) { | |
| 1332 ObjArray.Add(AddTextObjToPageObjects( | |
| 1333 pObjectHolder, crOld, pFontMap->GetPDFFont(wp.nFontIndex), | |
| 1334 wp.fFontSize, wp.fCharSpace, wp.nHorzScale, | |
| 1335 CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), | |
| 1336 sTextBuf.MakeString())); | |
| 1337 } | |
| 1338 } | |
| 1339 } | |
| 1340 | |
| 1341 // static | |
| 1342 void CFX_Edit::GenerateUnderlineObjects(CPDF_PageObjectHolder* pObjectHolder, | |
| 1343 CFX_Edit* pEdit, | |
| 1344 const CFX_FloatPoint& ptOffset, | |
| 1345 const CPVT_WordRange* pRange, | |
| 1346 FX_COLORREF color) { | |
| 1347 CFX_Edit_Iterator* pIterator = pEdit->GetIterator(); | |
| 1348 if (pEdit->GetFontMap()) { | |
| 1349 if (pRange) | |
| 1350 pIterator->SetAt(pRange->BeginPos); | |
| 1351 else | |
| 1352 pIterator->SetAt(0); | |
| 1353 | |
| 1354 CPVT_WordPlace oldplace; | |
| 1355 | |
| 1356 while (pIterator->NextWord()) { | |
| 1357 CPVT_WordPlace place = pIterator->GetAt(); | |
| 1358 if (pRange && place.WordCmp(pRange->EndPos) > 0) | |
| 1359 break; | |
| 1360 | |
| 1361 CPVT_Word word; | |
| 1362 if (pIterator->GetWord(word)) { | |
| 1363 CFX_FloatRect rcUnderline = GetUnderLineRect(word); | |
| 1364 rcUnderline.left += ptOffset.x; | |
| 1365 rcUnderline.right += ptOffset.x; | |
| 1366 rcUnderline.top += ptOffset.y; | |
| 1367 rcUnderline.bottom += ptOffset.y; | |
| 1368 AddRectToPageObjects(pObjectHolder, color, rcUnderline); | |
| 1369 } | |
| 1370 } | |
| 1371 } | |
| 1372 } | |
| 1373 | |
| 1374 CFX_Edit::CFX_Edit() | 1001 CFX_Edit::CFX_Edit() |
| 1375 : m_pVT(new CPDF_VariableText), | 1002 : m_pVT(new CPDF_VariableText), |
| 1376 m_pNotify(nullptr), | 1003 m_pNotify(nullptr), |
| 1377 m_pOprNotify(nullptr), | 1004 m_pOprNotify(nullptr), |
| 1378 m_wpCaret(-1, -1, -1), | 1005 m_wpCaret(-1, -1, -1), |
| 1379 m_wpOldCaret(-1, -1, -1), | 1006 m_wpOldCaret(-1, -1, -1), |
| 1380 m_SelState(), | 1007 m_SelState(), |
| 1381 m_ptScrollPos(0, 0), | 1008 m_ptScrollPos(0, 0), |
| 1382 m_ptRefreshScrollPos(0, 0), | 1009 m_ptRefreshScrollPos(0, 0), |
| 1383 m_bEnableScroll(FALSE), | 1010 m_bEnableScroll(FALSE), |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1414 void CFX_Edit::SetOprNotify(CPWL_Edit* pOprNotify) { | 1041 void CFX_Edit::SetOprNotify(CPWL_Edit* pOprNotify) { |
| 1415 m_pOprNotify = pOprNotify; | 1042 m_pOprNotify = pOprNotify; |
| 1416 } | 1043 } |
| 1417 | 1044 |
| 1418 CFX_Edit_Iterator* CFX_Edit::GetIterator() { | 1045 CFX_Edit_Iterator* CFX_Edit::GetIterator() { |
| 1419 if (!m_pIterator) | 1046 if (!m_pIterator) |
| 1420 m_pIterator.reset(new CFX_Edit_Iterator(this, m_pVT->GetIterator())); | 1047 m_pIterator.reset(new CFX_Edit_Iterator(this, m_pVT->GetIterator())); |
| 1421 return m_pIterator.get(); | 1048 return m_pIterator.get(); |
| 1422 } | 1049 } |
| 1423 | 1050 |
| 1424 CPDF_VariableText* CFX_Edit::GetVariableText() { | |
| 1425 return m_pVT.get(); | |
| 1426 } | |
| 1427 | |
| 1428 IPVT_FontMap* CFX_Edit::GetFontMap() { | 1051 IPVT_FontMap* CFX_Edit::GetFontMap() { |
| 1429 return m_pVTProvider ? m_pVTProvider->GetFontMap() : nullptr; | 1052 return m_pVTProvider ? m_pVTProvider->GetFontMap() : nullptr; |
| 1430 } | 1053 } |
| 1431 | 1054 |
| 1432 void CFX_Edit::SetPlateRect(const CFX_FloatRect& rect) { | 1055 void CFX_Edit::SetPlateRect(const CFX_FloatRect& rect) { |
| 1433 m_pVT->SetPlateRect(rect); | 1056 m_pVT->SetPlateRect(rect); |
| 1434 m_ptScrollPos = CFX_FloatPoint(rect.left, rect.top); | 1057 m_ptScrollPos = CFX_FloatPoint(rect.left, rect.top); |
| 1435 Paint(); | 1058 Paint(); |
| 1436 } | 1059 } |
| 1437 | 1060 |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1644 while (pIterator->NextLine()) | 1267 while (pIterator->NextLine()) |
| 1645 ++nLines; | 1268 ++nLines; |
| 1646 | 1269 |
| 1647 return nLines; | 1270 return nLines; |
| 1648 } | 1271 } |
| 1649 | 1272 |
| 1650 CPVT_WordRange CFX_Edit::GetSelectWordRange() const { | 1273 CPVT_WordRange CFX_Edit::GetSelectWordRange() const { |
| 1651 return m_SelState.ConvertToWordRange(); | 1274 return m_SelState.ConvertToWordRange(); |
| 1652 } | 1275 } |
| 1653 | 1276 |
| 1654 CPVT_WordRange CFX_Edit::CombineWordRange(const CPVT_WordRange& wr1, | |
| 1655 const CPVT_WordRange& wr2) { | |
| 1656 CPVT_WordRange wrRet; | |
| 1657 | |
| 1658 if (wr1.BeginPos.WordCmp(wr2.BeginPos) < 0) { | |
| 1659 wrRet.BeginPos = wr1.BeginPos; | |
| 1660 } else { | |
| 1661 wrRet.BeginPos = wr2.BeginPos; | |
| 1662 } | |
| 1663 | |
| 1664 if (wr1.EndPos.WordCmp(wr2.EndPos) < 0) { | |
| 1665 wrRet.EndPos = wr2.EndPos; | |
| 1666 } else { | |
| 1667 wrRet.EndPos = wr1.EndPos; | |
| 1668 } | |
| 1669 | |
| 1670 return wrRet; | |
| 1671 } | |
| 1672 | |
| 1673 void CFX_Edit::SetText(const CFX_WideString& sText) { | 1277 void CFX_Edit::SetText(const CFX_WideString& sText) { |
| 1674 Empty(); | 1278 Empty(); |
| 1675 DoInsertText(CPVT_WordPlace(0, 0, -1), sText, DEFAULT_CHARSET); | 1279 DoInsertText(CPVT_WordPlace(0, 0, -1), sText, DEFAULT_CHARSET); |
| 1676 Paint(); | 1280 Paint(); |
| 1677 } | 1281 } |
| 1678 | 1282 |
| 1679 FX_BOOL CFX_Edit::InsertWord(uint16_t word, int32_t charset) { | 1283 FX_BOOL CFX_Edit::InsertWord(uint16_t word, int32_t charset) { |
| 1680 return InsertWord(word, charset, nullptr, TRUE, TRUE); | 1284 return InsertWord(word, charset, nullptr, TRUE, TRUE); |
| 1681 } | 1285 } |
| 1682 | 1286 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1705 } | 1309 } |
| 1706 | 1310 |
| 1707 uint16_t CFX_Edit::GetPasswordChar() const { | 1311 uint16_t CFX_Edit::GetPasswordChar() const { |
| 1708 return m_pVT->GetPasswordChar(); | 1312 return m_pVT->GetPasswordChar(); |
| 1709 } | 1313 } |
| 1710 | 1314 |
| 1711 int32_t CFX_Edit::GetCharArray() const { | 1315 int32_t CFX_Edit::GetCharArray() const { |
| 1712 return m_pVT->GetCharArray(); | 1316 return m_pVT->GetCharArray(); |
| 1713 } | 1317 } |
| 1714 | 1318 |
| 1715 CFX_FloatRect CFX_Edit::GetPlateRect() const { | |
| 1716 return m_pVT->GetPlateRect(); | |
| 1717 } | |
| 1718 | |
| 1719 CFX_FloatRect CFX_Edit::GetContentRect() const { | 1319 CFX_FloatRect CFX_Edit::GetContentRect() const { |
| 1720 return VTToEdit(m_pVT->GetContentRect()); | 1320 return VTToEdit(m_pVT->GetContentRect()); |
| 1721 } | 1321 } |
| 1722 | 1322 |
| 1723 int32_t CFX_Edit::GetHorzScale() const { | 1323 int32_t CFX_Edit::GetHorzScale() const { |
| 1724 return m_pVT->GetHorzScale(); | 1324 return m_pVT->GetHorzScale(); |
| 1725 } | 1325 } |
| 1726 | 1326 |
| 1727 FX_FLOAT CFX_Edit::GetCharSpace() const { | 1327 FX_FLOAT CFX_Edit::GetCharSpace() const { |
| 1728 return m_pVT->GetCharSpace(); | 1328 return m_pVT->GetCharSpace(); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1876 | 1476 |
| 1877 CFX_FloatRect CFX_Edit::VTToEdit(const CFX_FloatRect& rect) const { | 1477 CFX_FloatRect CFX_Edit::VTToEdit(const CFX_FloatRect& rect) const { |
| 1878 CFX_FloatPoint ptLeftBottom = | 1478 CFX_FloatPoint ptLeftBottom = |
| 1879 VTToEdit(CFX_FloatPoint(rect.left, rect.bottom)); | 1479 VTToEdit(CFX_FloatPoint(rect.left, rect.bottom)); |
| 1880 CFX_FloatPoint ptRightTop = VTToEdit(CFX_FloatPoint(rect.right, rect.top)); | 1480 CFX_FloatPoint ptRightTop = VTToEdit(CFX_FloatPoint(rect.right, rect.top)); |
| 1881 | 1481 |
| 1882 return CFX_FloatRect(ptLeftBottom.x, ptLeftBottom.y, ptRightTop.x, | 1482 return CFX_FloatRect(ptLeftBottom.x, ptLeftBottom.y, ptRightTop.x, |
| 1883 ptRightTop.y); | 1483 ptRightTop.y); |
| 1884 } | 1484 } |
| 1885 | 1485 |
| 1886 CFX_FloatRect CFX_Edit::EditToVT(const CFX_FloatRect& rect) const { | |
| 1887 CFX_FloatPoint ptLeftBottom = | |
| 1888 EditToVT(CFX_FloatPoint(rect.left, rect.bottom)); | |
| 1889 CFX_FloatPoint ptRightTop = EditToVT(CFX_FloatPoint(rect.right, rect.top)); | |
| 1890 | |
| 1891 return CFX_FloatRect(ptLeftBottom.x, ptLeftBottom.y, ptRightTop.x, | |
| 1892 ptRightTop.y); | |
| 1893 } | |
| 1894 | |
| 1895 void CFX_Edit::SetScrollInfo() { | 1486 void CFX_Edit::SetScrollInfo() { |
| 1896 if (m_pNotify) { | 1487 if (m_pNotify) { |
| 1897 CFX_FloatRect rcPlate = m_pVT->GetPlateRect(); | 1488 CFX_FloatRect rcPlate = m_pVT->GetPlateRect(); |
| 1898 CFX_FloatRect rcContent = m_pVT->GetContentRect(); | 1489 CFX_FloatRect rcContent = m_pVT->GetContentRect(); |
| 1899 | 1490 |
| 1900 if (!m_bNotifyFlag) { | 1491 if (!m_bNotifyFlag) { |
| 1901 m_bNotifyFlag = TRUE; | 1492 m_bNotifyFlag = TRUE; |
| 1902 m_pNotify->IOnSetScrollInfoY(rcPlate.bottom, rcPlate.top, | 1493 m_pNotify->IOnSetScrollInfoY(rcPlate.bottom, rcPlate.top, |
| 1903 rcContent.bottom, rcContent.top, | 1494 rcContent.bottom, rcContent.top, |
| 1904 rcPlate.Height() / 3, rcPlate.Height()); | 1495 rcPlate.Height() / 3, rcPlate.Height()); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2077 CFX_FloatRect rcLine(lineinfo.ptLine.x, | 1668 CFX_FloatRect rcLine(lineinfo.ptLine.x, |
| 2078 lineinfo.ptLine.y + lineinfo.fLineDescent, | 1669 lineinfo.ptLine.y + lineinfo.fLineDescent, |
| 2079 lineinfo.ptLine.x + lineinfo.fLineWidth, | 1670 lineinfo.ptLine.x + lineinfo.fLineWidth, |
| 2080 lineinfo.ptLine.y + lineinfo.fLineAscent); | 1671 lineinfo.ptLine.y + lineinfo.fLineAscent); |
| 2081 | 1672 |
| 2082 m_Refresh.Push(CPVT_WordRange(lineinfo.lineplace, lineinfo.lineEnd), | 1673 m_Refresh.Push(CPVT_WordRange(lineinfo.lineplace, lineinfo.lineEnd), |
| 2083 VTToEdit(rcLine)); | 1674 VTToEdit(rcLine)); |
| 2084 } while (pIterator->NextLine()); | 1675 } while (pIterator->NextLine()); |
| 2085 } | 1676 } |
| 2086 | 1677 |
| 2087 void CFX_Edit::RefreshPushRandomRects(const CPVT_WordRange& wr) { | |
| 2088 if (!m_pVT->IsValid()) | |
| 2089 return; | |
| 2090 | |
| 2091 CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator(); | |
| 2092 CPVT_WordRange wrTemp = wr; | |
| 2093 | |
| 2094 m_pVT->UpdateWordPlace(wrTemp.BeginPos); | |
| 2095 m_pVT->UpdateWordPlace(wrTemp.EndPos); | |
| 2096 pIterator->SetAt(wrTemp.BeginPos); | |
| 2097 | |
| 2098 CPVT_Word wordinfo; | |
| 2099 CPVT_Line lineinfo; | |
| 2100 CPVT_WordPlace place; | |
| 2101 | |
| 2102 while (pIterator->NextWord()) { | |
| 2103 place = pIterator->GetAt(); | |
| 2104 if (place.WordCmp(wrTemp.EndPos) > 0) | |
| 2105 break; | |
| 2106 | |
| 2107 pIterator->GetWord(wordinfo); | |
| 2108 pIterator->GetLine(lineinfo); | |
| 2109 | |
| 2110 if (place.LineCmp(wrTemp.BeginPos) == 0 || | |
| 2111 place.LineCmp(wrTemp.EndPos) == 0) { | |
| 2112 CFX_FloatRect rcWord(wordinfo.ptWord.x, | |
| 2113 lineinfo.ptLine.y + lineinfo.fLineDescent, | |
| 2114 wordinfo.ptWord.x + wordinfo.fWidth, | |
| 2115 lineinfo.ptLine.y + lineinfo.fLineAscent); | |
| 2116 | |
| 2117 m_Refresh.AddRefresh(VTToEdit(rcWord)); | |
| 2118 } else { | |
| 2119 CFX_FloatRect rcLine(lineinfo.ptLine.x, | |
| 2120 lineinfo.ptLine.y + lineinfo.fLineDescent, | |
| 2121 lineinfo.ptLine.x + lineinfo.fLineWidth, | |
| 2122 lineinfo.ptLine.y + lineinfo.fLineAscent); | |
| 2123 | |
| 2124 m_Refresh.AddRefresh(VTToEdit(rcLine)); | |
| 2125 | |
| 2126 pIterator->NextLine(); | |
| 2127 } | |
| 2128 } | |
| 2129 } | |
| 2130 | |
| 2131 void CFX_Edit::RefreshWordRange(const CPVT_WordRange& wr) { | 1678 void CFX_Edit::RefreshWordRange(const CPVT_WordRange& wr) { |
| 2132 CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator(); | 1679 CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator(); |
| 2133 CPVT_WordRange wrTemp = wr; | 1680 CPVT_WordRange wrTemp = wr; |
| 2134 | 1681 |
| 2135 m_pVT->UpdateWordPlace(wrTemp.BeginPos); | 1682 m_pVT->UpdateWordPlace(wrTemp.BeginPos); |
| 2136 m_pVT->UpdateWordPlace(wrTemp.EndPos); | 1683 m_pVT->UpdateWordPlace(wrTemp.EndPos); |
| 2137 pIterator->SetAt(wrTemp.BeginPos); | 1684 pIterator->SetAt(wrTemp.BeginPos); |
| 2138 | 1685 |
| 2139 CPVT_Word wordinfo; | 1686 CPVT_Word wordinfo; |
| 2140 CPVT_Line lineinfo; | 1687 CPVT_Line lineinfo; |
| (...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2795 return TRUE; | 2342 return TRUE; |
| 2796 } | 2343 } |
| 2797 | 2344 |
| 2798 if (IsFloatBigger(rcContent.Width(), rcPlate.Width())) | 2345 if (IsFloatBigger(rcContent.Width(), rcPlate.Width())) |
| 2799 return TRUE; | 2346 return TRUE; |
| 2800 } | 2347 } |
| 2801 | 2348 |
| 2802 return FALSE; | 2349 return FALSE; |
| 2803 } | 2350 } |
| 2804 | 2351 |
| 2805 CPVT_WordPlace CFX_Edit::GetLineBeginPlace(const CPVT_WordPlace& place) const { | |
| 2806 return m_pVT->GetLineBeginPlace(place); | |
| 2807 } | |
| 2808 | |
| 2809 CPVT_WordPlace CFX_Edit::GetLineEndPlace(const CPVT_WordPlace& place) const { | |
| 2810 return m_pVT->GetLineEndPlace(place); | |
| 2811 } | |
| 2812 | |
| 2813 CPVT_WordPlace CFX_Edit::GetSectionBeginPlace( | |
| 2814 const CPVT_WordPlace& place) const { | |
| 2815 return m_pVT->GetSectionBeginPlace(place); | |
| 2816 } | |
| 2817 | |
| 2818 CPVT_WordPlace CFX_Edit::GetSectionEndPlace(const CPVT_WordPlace& place) const { | |
| 2819 return m_pVT->GetSectionEndPlace(place); | |
| 2820 } | |
| 2821 | |
| 2822 FX_BOOL CFX_Edit::CanUndo() const { | 2352 FX_BOOL CFX_Edit::CanUndo() const { |
| 2823 if (m_bEnableUndo) { | 2353 if (m_bEnableUndo) { |
| 2824 return m_Undo.CanUndo(); | 2354 return m_Undo.CanUndo(); |
| 2825 } | 2355 } |
| 2826 | 2356 |
| 2827 return FALSE; | 2357 return FALSE; |
| 2828 } | 2358 } |
| 2829 | 2359 |
| 2830 FX_BOOL CFX_Edit::CanRedo() const { | 2360 FX_BOOL CFX_Edit::CanRedo() const { |
| 2831 if (m_bEnableUndo) { | 2361 if (m_bEnableUndo) { |
| 2832 return m_Undo.CanRedo(); | 2362 return m_Undo.CanRedo(); |
| 2833 } | 2363 } |
| 2834 | 2364 |
| 2835 return FALSE; | 2365 return FALSE; |
| 2836 } | 2366 } |
| 2837 | 2367 |
| 2838 FX_BOOL CFX_Edit::IsModified() const { | |
| 2839 if (m_bEnableUndo) { | |
| 2840 return m_Undo.IsModified(); | |
| 2841 } | |
| 2842 | |
| 2843 return FALSE; | |
| 2844 } | |
| 2845 | |
| 2846 void CFX_Edit::EnableRefresh(FX_BOOL bRefresh) { | 2368 void CFX_Edit::EnableRefresh(FX_BOOL bRefresh) { |
| 2847 m_bEnableRefresh = bRefresh; | 2369 m_bEnableRefresh = bRefresh; |
| 2848 } | 2370 } |
| 2849 | 2371 |
| 2850 void CFX_Edit::EnableUndo(FX_BOOL bUndo) { | 2372 void CFX_Edit::EnableUndo(FX_BOOL bUndo) { |
| 2851 m_bEnableUndo = bUndo; | 2373 m_bEnableUndo = bUndo; |
| 2852 } | 2374 } |
| 2853 | 2375 |
| 2854 void CFX_Edit::EnableOprNotify(FX_BOOL bNotify) { | 2376 void CFX_Edit::EnableOprNotify(FX_BOOL bNotify) { |
| 2855 m_bOprNotify = bNotify; | 2377 m_bOprNotify = bNotify; |
| 2856 } | 2378 } |
| 2857 | 2379 |
| 2858 FX_FLOAT CFX_Edit::GetLineTop(const CPVT_WordPlace& place) const { | |
| 2859 CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator(); | |
| 2860 CPVT_WordPlace wpOld = pIterator->GetAt(); | |
| 2861 | |
| 2862 pIterator->SetAt(place); | |
| 2863 CPVT_Line line; | |
| 2864 pIterator->GetLine(line); | |
| 2865 | |
| 2866 pIterator->SetAt(wpOld); | |
| 2867 | |
| 2868 return line.ptLine.y + line.fLineAscent; | |
| 2869 } | |
| 2870 | |
| 2871 FX_FLOAT CFX_Edit::GetLineBottom(const CPVT_WordPlace& place) const { | |
| 2872 CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator(); | |
| 2873 CPVT_WordPlace wpOld = pIterator->GetAt(); | |
| 2874 | |
| 2875 pIterator->SetAt(place); | |
| 2876 CPVT_Line line; | |
| 2877 pIterator->GetLine(line); | |
| 2878 | |
| 2879 pIterator->SetAt(wpOld); | |
| 2880 | |
| 2881 return line.ptLine.y + line.fLineDescent; | |
| 2882 } | |
| 2883 | |
| 2884 CPVT_WordPlace CFX_Edit::DoInsertText(const CPVT_WordPlace& place, | 2380 CPVT_WordPlace CFX_Edit::DoInsertText(const CPVT_WordPlace& place, |
| 2885 const CFX_WideString& sText, | 2381 const CFX_WideString& sText, |
| 2886 int32_t charset) { | 2382 int32_t charset) { |
| 2887 CPVT_WordPlace wp = place; | 2383 CPVT_WordPlace wp = place; |
| 2888 | 2384 |
| 2889 if (m_pVT->IsValid()) { | 2385 if (m_pVT->IsValid()) { |
| 2890 for (int32_t i = 0, sz = sText.GetLength(); i < sz; i++) { | 2386 for (int32_t i = 0, sz = sText.GetLength(); i < sz; i++) { |
| 2891 uint16_t word = sText[i]; | 2387 uint16_t word = sText[i]; |
| 2892 switch (word) { | 2388 switch (word) { |
| 2893 case 0x0D: | 2389 case 0x0D: |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2912 | 2408 |
| 2913 return wp; | 2409 return wp; |
| 2914 } | 2410 } |
| 2915 | 2411 |
| 2916 int32_t CFX_Edit::GetCharSetFromUnicode(uint16_t word, int32_t nOldCharset) { | 2412 int32_t CFX_Edit::GetCharSetFromUnicode(uint16_t word, int32_t nOldCharset) { |
| 2917 if (IPVT_FontMap* pFontMap = GetFontMap()) | 2413 if (IPVT_FontMap* pFontMap = GetFontMap()) |
| 2918 return pFontMap->CharSetFromUnicode(word, nOldCharset); | 2414 return pFontMap->CharSetFromUnicode(word, nOldCharset); |
| 2919 return nOldCharset; | 2415 return nOldCharset; |
| 2920 } | 2416 } |
| 2921 | 2417 |
| 2922 void CFX_Edit::BeginGroupUndo(const CFX_WideString& sTitle) { | |
| 2923 ASSERT(!m_pGroupUndoItem); | |
| 2924 | |
| 2925 m_pGroupUndoItem = new CFX_Edit_GroupUndoItem(sTitle); | |
| 2926 } | |
| 2927 | |
| 2928 void CFX_Edit::EndGroupUndo() { | |
| 2929 m_pGroupUndoItem->UpdateItems(); | |
| 2930 m_Undo.AddItem(m_pGroupUndoItem); | |
| 2931 m_pGroupUndoItem = nullptr; | |
| 2932 } | |
| 2933 | |
| 2934 void CFX_Edit::AddEditUndoItem(CFX_Edit_UndoItem* pEditUndoItem) { | 2418 void CFX_Edit::AddEditUndoItem(CFX_Edit_UndoItem* pEditUndoItem) { |
| 2935 if (m_pGroupUndoItem) { | 2419 if (m_pGroupUndoItem) { |
| 2936 m_pGroupUndoItem->AddUndoItem(pEditUndoItem); | 2420 m_pGroupUndoItem->AddUndoItem(pEditUndoItem); |
| 2937 } else { | 2421 } else { |
| 2938 m_Undo.AddItem(pEditUndoItem); | 2422 m_Undo.AddItem(pEditUndoItem); |
| 2939 } | 2423 } |
| 2940 } | 2424 } |
| 2941 | 2425 |
| 2942 void CFX_Edit::AddUndoItem(IFX_Edit_UndoItem* pUndoItem) { | |
| 2943 m_Undo.AddItem(pUndoItem); | |
| 2944 } | |
| 2945 | |
| 2946 CFX_Edit_LineRectArray::CFX_Edit_LineRectArray() {} | 2426 CFX_Edit_LineRectArray::CFX_Edit_LineRectArray() {} |
| 2947 | 2427 |
| 2948 CFX_Edit_LineRectArray::~CFX_Edit_LineRectArray() { | 2428 CFX_Edit_LineRectArray::~CFX_Edit_LineRectArray() { |
| 2949 Empty(); | 2429 Empty(); |
| 2950 } | 2430 } |
| 2951 | 2431 |
| 2952 void CFX_Edit_LineRectArray::Empty() { | 2432 void CFX_Edit_LineRectArray::Empty() { |
| 2953 for (int32_t i = 0, sz = m_LineRects.GetSize(); i < sz; i++) | 2433 for (int32_t i = 0, sz = m_LineRects.GetSize(); i < sz; i++) |
| 2954 delete m_LineRects.GetAt(i); | 2434 delete m_LineRects.GetAt(i); |
| 2955 | 2435 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3015 } | 2495 } |
| 3016 | 2496 |
| 3017 void CFX_Edit_Select::SetEndPos(const CPVT_WordPlace& end) { | 2497 void CFX_Edit_Select::SetEndPos(const CPVT_WordPlace& end) { |
| 3018 EndPos = end; | 2498 EndPos = end; |
| 3019 } | 2499 } |
| 3020 | 2500 |
| 3021 FX_BOOL CFX_Edit_Select::IsExist() const { | 2501 FX_BOOL CFX_Edit_Select::IsExist() const { |
| 3022 return BeginPos != EndPos; | 2502 return BeginPos != EndPos; |
| 3023 } | 2503 } |
| 3024 | 2504 |
| 3025 FX_BOOL CFX_Edit_Select::operator!=(const CPVT_WordRange& wr) const { | |
| 3026 return wr.BeginPos != BeginPos || wr.EndPos != EndPos; | |
| 3027 } | |
| 3028 | |
| 3029 CFX_Edit_RectArray::CFX_Edit_RectArray() {} | 2505 CFX_Edit_RectArray::CFX_Edit_RectArray() {} |
| 3030 | 2506 |
| 3031 CFX_Edit_RectArray::~CFX_Edit_RectArray() { | 2507 CFX_Edit_RectArray::~CFX_Edit_RectArray() { |
| 3032 Empty(); | 2508 Empty(); |
| 3033 } | 2509 } |
| 3034 | 2510 |
| 3035 void CFX_Edit_RectArray::Empty() { | 2511 void CFX_Edit_RectArray::Empty() { |
| 3036 for (int32_t i = 0, sz = m_Rects.GetSize(); i < sz; i++) | 2512 for (int32_t i = 0, sz = m_Rects.GetSize(); i < sz; i++) |
| 3037 delete m_Rects.GetAt(i); | 2513 delete m_Rects.GetAt(i); |
| 3038 | 2514 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3053 int32_t CFX_Edit_RectArray::GetSize() const { | 2529 int32_t CFX_Edit_RectArray::GetSize() const { |
| 3054 return m_Rects.GetSize(); | 2530 return m_Rects.GetSize(); |
| 3055 } | 2531 } |
| 3056 | 2532 |
| 3057 CFX_FloatRect* CFX_Edit_RectArray::GetAt(int32_t nIndex) const { | 2533 CFX_FloatRect* CFX_Edit_RectArray::GetAt(int32_t nIndex) const { |
| 3058 if (nIndex < 0 || nIndex >= m_Rects.GetSize()) | 2534 if (nIndex < 0 || nIndex >= m_Rects.GetSize()) |
| 3059 return nullptr; | 2535 return nullptr; |
| 3060 | 2536 |
| 3061 return m_Rects.GetAt(nIndex); | 2537 return m_Rects.GetAt(nIndex); |
| 3062 } | 2538 } |
| OLD | NEW |