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 "xfa/fee/fde_txtedtengine.h" | 7 #include "xfa/fee/fde_txtedtengine.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> |
10 | 11 |
11 #include "xfa/fde/tto/fde_textout.h" | 12 #include "xfa/fde/tto/fde_textout.h" |
12 #include "xfa/fee/fde_txtedtparag.h" | 13 #include "xfa/fee/fde_txtedtparag.h" |
13 #include "xfa/fee/ifde_txtedtengine.h" | 14 #include "xfa/fee/ifde_txtedtengine.h" |
14 #include "xfa/fee/ifde_txtedtpage.h" | 15 #include "xfa/fee/ifde_txtedtpage.h" |
15 #include "xfa/fwl/basewidget/fwl_editimp.h" | 16 #include "xfa/fwl/basewidget/fwl_editimp.h" |
16 | 17 |
17 #define FDE_PAGEWIDTH_MAX 0xFFFF | 18 #define FDE_PAGEWIDTH_MAX 0xFFFF |
18 #define FDE_TXTPLATESIZE (1024 * 12) | 19 #define FDE_TXTPLATESIZE (1024 * 12) |
19 #define FDE_UNICODE_PARAGRAPH_SPERATOR (0x2029) | 20 #define FDE_UNICODE_PARAGRAPH_SPERATOR (0x2029) |
(...skipping 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1481 FX_BOOL CFDE_TxtEdtEngine::MoveHome() { | 1482 FX_BOOL CFDE_TxtEdtEngine::MoveHome() { |
1482 UpdateCaretRect(0, TRUE); | 1483 UpdateCaretRect(0, TRUE); |
1483 return TRUE; | 1484 return TRUE; |
1484 } | 1485 } |
1485 FX_BOOL CFDE_TxtEdtEngine::MoveEnd() { | 1486 FX_BOOL CFDE_TxtEdtEngine::MoveEnd() { |
1486 UpdateCaretRect(GetTextBufLength(), TRUE); | 1487 UpdateCaretRect(GetTextBufLength(), TRUE); |
1487 return TRUE; | 1488 return TRUE; |
1488 } | 1489 } |
1489 | 1490 |
1490 FX_BOOL CFDE_TxtEdtEngine::IsFitArea(CFX_WideString& wsText) { | 1491 FX_BOOL CFDE_TxtEdtEngine::IsFitArea(CFX_WideString& wsText) { |
1491 CFDE_TextOut* pTextOut = new CFDE_TextOut; | 1492 std::unique_ptr<CFDE_TextOut> pTextOut(new CFDE_TextOut); |
1492 pTextOut->SetLineSpace(m_Param.fLineSpace); | 1493 pTextOut->SetLineSpace(m_Param.fLineSpace); |
1493 pTextOut->SetFont(m_Param.pFont); | 1494 pTextOut->SetFont(m_Param.pFont); |
1494 pTextOut->SetFontSize(m_Param.fFontSize); | 1495 pTextOut->SetFontSize(m_Param.fFontSize); |
1495 CFX_RectF rcText; | 1496 CFX_RectF rcText; |
1496 FXSYS_memset(&rcText, 0, sizeof(rcText)); | 1497 FXSYS_memset(&rcText, 0, sizeof(rcText)); |
1497 uint32_t dwStyle = 0; | 1498 uint32_t dwStyle = 0; |
1498 if (!(m_Param.dwMode & FDE_TEXTEDITMODE_MultiLines)) { | 1499 if (!(m_Param.dwMode & FDE_TEXTEDITMODE_MultiLines)) { |
1499 dwStyle |= FDE_TTOSTYLE_SingleLine; | 1500 dwStyle |= FDE_TTOSTYLE_SingleLine; |
1500 } | 1501 } |
1501 if (m_Param.dwMode & FDE_TEXTEDITMODE_AutoLineWrap) { | 1502 if (m_Param.dwMode & FDE_TEXTEDITMODE_AutoLineWrap) { |
1502 dwStyle |= FDE_TTOSTYLE_LineWrap; | 1503 dwStyle |= FDE_TTOSTYLE_LineWrap; |
1503 rcText.width = m_Param.fPlateWidth; | 1504 rcText.width = m_Param.fPlateWidth; |
1504 } else { | 1505 } else { |
1505 rcText.width = 65535; | 1506 rcText.width = 65535; |
1506 } | 1507 } |
1507 pTextOut->SetStyles(dwStyle); | 1508 pTextOut->SetStyles(dwStyle); |
1508 wsText += L"\n"; | 1509 wsText += L"\n"; |
1509 pTextOut->CalcLogicSize(wsText.c_str(), wsText.GetLength(), rcText); | 1510 pTextOut->CalcLogicSize(wsText.c_str(), wsText.GetLength(), rcText); |
1510 pTextOut->Release(); | |
1511 wsText.Delete(wsText.GetLength() - 1); | 1511 wsText.Delete(wsText.GetLength() - 1); |
1512 if ((m_Param.dwMode & FDE_TEXTEDITMODE_LimitArea_Horz) && | 1512 if ((m_Param.dwMode & FDE_TEXTEDITMODE_LimitArea_Horz) && |
1513 (rcText.width > m_Param.fPlateWidth)) { | 1513 (rcText.width > m_Param.fPlateWidth)) { |
1514 return FALSE; | 1514 return FALSE; |
1515 } | 1515 } |
1516 if ((m_Param.dwMode & FDE_TEXTEDITMODE_LimitArea_Vert) && | 1516 if ((m_Param.dwMode & FDE_TEXTEDITMODE_LimitArea_Vert) && |
1517 (rcText.height > m_Param.fLineSpace * m_Param.nLineCount)) { | 1517 (rcText.height > m_Param.fLineSpace * m_Param.nLineCount)) { |
1518 return FALSE; | 1518 return FALSE; |
1519 } | 1519 } |
1520 return TRUE; | 1520 return TRUE; |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1755 int32_t nEngine = 0; | 1755 int32_t nEngine = 0; |
1756 ArchiveLoader >> nEngine; | 1756 ArchiveLoader >> nEngine; |
1757 m_pEngine = (CFDE_TxtEdtEngine*)(uintptr_t)nEngine; | 1757 m_pEngine = (CFDE_TxtEdtEngine*)(uintptr_t)nEngine; |
1758 int32_t iSel = 0; | 1758 int32_t iSel = 0; |
1759 ArchiveLoader >> iSel; | 1759 ArchiveLoader >> iSel; |
1760 m_bSel = !!iSel; | 1760 m_bSel = !!iSel; |
1761 ArchiveLoader >> m_nIndex; | 1761 ArchiveLoader >> m_nIndex; |
1762 ArchiveLoader >> m_nCaret; | 1762 ArchiveLoader >> m_nCaret; |
1763 ArchiveLoader >> m_wsRange; | 1763 ArchiveLoader >> m_wsRange; |
1764 } | 1764 } |
OLD | NEW |