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 | 10 |
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1188 } | 1188 } |
1189 } | 1189 } |
1190 return bPreIsCR; | 1190 return bPreIsCR; |
1191 } | 1191 } |
1192 void CFDE_TxtEdtEngine::RecoverParagEnd(CFX_WideString& wsText) { | 1192 void CFDE_TxtEdtEngine::RecoverParagEnd(CFX_WideString& wsText) { |
1193 FX_WCHAR wc = (m_nFirstLineEnd == FDE_TXTEDIT_LINEEND_CR) ? L'\n' : L'\r'; | 1193 FX_WCHAR wc = (m_nFirstLineEnd == FDE_TXTEDIT_LINEEND_CR) ? L'\n' : L'\r'; |
1194 if (m_nFirstLineEnd == FDE_TXTEDIT_LINEEND_CRLF) { | 1194 if (m_nFirstLineEnd == FDE_TXTEDIT_LINEEND_CRLF) { |
1195 CFX_ArrayTemplate<int32_t> PosArr; | 1195 CFX_ArrayTemplate<int32_t> PosArr; |
1196 int32_t nLength = wsText.GetLength(); | 1196 int32_t nLength = wsText.GetLength(); |
1197 int32_t i = 0; | 1197 int32_t i = 0; |
1198 FX_WCHAR* lpPos = (FX_WCHAR*)(const FX_WCHAR*)wsText; | 1198 FX_WCHAR* lpPos = const_cast<FX_WCHAR*>(wsText.c_str()); |
1199 for (i = 0; i < nLength; i++, lpPos++) { | 1199 for (i = 0; i < nLength; i++, lpPos++) { |
1200 if (*lpPos == m_wLineEnd) { | 1200 if (*lpPos == m_wLineEnd) { |
1201 *lpPos = wc; | 1201 *lpPos = wc; |
1202 PosArr.Add(i); | 1202 PosArr.Add(i); |
1203 } | 1203 } |
1204 } | 1204 } |
1205 const FX_WCHAR* lpSrcBuf = wsText.c_str(); | 1205 const FX_WCHAR* lpSrcBuf = wsText.c_str(); |
1206 CFX_WideString wsTemp; | 1206 CFX_WideString wsTemp; |
1207 int32_t nCount = PosArr.GetSize(); | 1207 int32_t nCount = PosArr.GetSize(); |
1208 FX_WCHAR* lpDstBuf = wsTemp.GetBuffer(nLength + nCount); | 1208 FX_WCHAR* lpDstBuf = wsTemp.GetBuffer(nLength + nCount); |
(...skipping 10 matching lines...) Expand all Loading... |
1219 nDstPos++; | 1219 nDstPos++; |
1220 } | 1220 } |
1221 if (nSrcPos < nLength) { | 1221 if (nSrcPos < nLength) { |
1222 FXSYS_memcpy(lpDstBuf + nDstPos, lpSrcBuf + nSrcPos, | 1222 FXSYS_memcpy(lpDstBuf + nDstPos, lpSrcBuf + nSrcPos, |
1223 (nLength - nSrcPos) * sizeof(FX_WCHAR)); | 1223 (nLength - nSrcPos) * sizeof(FX_WCHAR)); |
1224 } | 1224 } |
1225 wsTemp.ReleaseBuffer(nLength + nCount); | 1225 wsTemp.ReleaseBuffer(nLength + nCount); |
1226 wsText = wsTemp; | 1226 wsText = wsTemp; |
1227 } else { | 1227 } else { |
1228 int32_t nLength = wsText.GetLength(); | 1228 int32_t nLength = wsText.GetLength(); |
1229 FX_WCHAR* lpBuf = (FX_WCHAR*)(const FX_WCHAR*)wsText; | 1229 FX_WCHAR* lpBuf = const_cast<FX_WCHAR*>(wsText.c_str()); |
1230 for (int32_t i = 0; i < nLength; i++, lpBuf++) { | 1230 for (int32_t i = 0; i < nLength; i++, lpBuf++) { |
1231 if (*lpBuf == m_wLineEnd) { | 1231 if (*lpBuf == m_wLineEnd) { |
1232 *lpBuf = wc; | 1232 *lpBuf = wc; |
1233 } | 1233 } |
1234 } | 1234 } |
1235 } | 1235 } |
1236 } | 1236 } |
1237 int32_t CFDE_TxtEdtEngine::MovePage2Char(int32_t nIndex) { | 1237 int32_t CFDE_TxtEdtEngine::MovePage2Char(int32_t nIndex) { |
1238 FXSYS_assert(nIndex >= 0); | 1238 FXSYS_assert(nIndex >= 0); |
1239 FXSYS_assert(nIndex <= m_pTxtBuf->GetTextLength()); | 1239 FXSYS_assert(nIndex <= m_pTxtBuf->GetTextLength()); |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1520 dwStyle |= FDE_TTOSTYLE_SingleLine; | 1520 dwStyle |= FDE_TTOSTYLE_SingleLine; |
1521 } | 1521 } |
1522 if (m_Param.dwMode & FDE_TEXTEDITMODE_AutoLineWrap) { | 1522 if (m_Param.dwMode & FDE_TEXTEDITMODE_AutoLineWrap) { |
1523 dwStyle |= FDE_TTOSTYLE_LineWrap; | 1523 dwStyle |= FDE_TTOSTYLE_LineWrap; |
1524 rcText.width = m_Param.fPlateWidth; | 1524 rcText.width = m_Param.fPlateWidth; |
1525 } else { | 1525 } else { |
1526 rcText.width = 65535; | 1526 rcText.width = 65535; |
1527 } | 1527 } |
1528 pTextOut->SetStyles(dwStyle); | 1528 pTextOut->SetStyles(dwStyle); |
1529 wsText += L"\n"; | 1529 wsText += L"\n"; |
1530 pTextOut->CalcLogicSize(wsText, wsText.GetLength(), rcText); | 1530 pTextOut->CalcLogicSize(wsText.c_str(), wsText.GetLength(), rcText); |
1531 pTextOut->Release(); | 1531 pTextOut->Release(); |
1532 wsText.Delete(wsText.GetLength() - 1); | 1532 wsText.Delete(wsText.GetLength() - 1); |
1533 if ((m_Param.dwMode & FDE_TEXTEDITMODE_LimitArea_Horz) && | 1533 if ((m_Param.dwMode & FDE_TEXTEDITMODE_LimitArea_Horz) && |
1534 (rcText.width > m_Param.fPlateWidth)) { | 1534 (rcText.width > m_Param.fPlateWidth)) { |
1535 return FALSE; | 1535 return FALSE; |
1536 } | 1536 } |
1537 if ((m_Param.dwMode & FDE_TEXTEDITMODE_LimitArea_Vert) && | 1537 if ((m_Param.dwMode & FDE_TEXTEDITMODE_LimitArea_Vert) && |
1538 (rcText.height > m_Param.fLineSpace * m_Param.nLineCount)) { | 1538 (rcText.height > m_Param.fLineSpace * m_Param.nLineCount)) { |
1539 return FALSE; | 1539 return FALSE; |
1540 } | 1540 } |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1776 int32_t nEngine = 0; | 1776 int32_t nEngine = 0; |
1777 ArchiveLoader >> nEngine; | 1777 ArchiveLoader >> nEngine; |
1778 m_pEngine = (CFDE_TxtEdtEngine*)(uintptr_t)nEngine; | 1778 m_pEngine = (CFDE_TxtEdtEngine*)(uintptr_t)nEngine; |
1779 int32_t iSel = 0; | 1779 int32_t iSel = 0; |
1780 ArchiveLoader >> iSel; | 1780 ArchiveLoader >> iSel; |
1781 m_bSel = !!iSel; | 1781 m_bSel = !!iSel; |
1782 ArchiveLoader >> m_nIndex; | 1782 ArchiveLoader >> m_nIndex; |
1783 ArchiveLoader >> m_nCaret; | 1783 ArchiveLoader >> m_nCaret; |
1784 ArchiveLoader >> m_wsRange; | 1784 ArchiveLoader >> m_wsRange; |
1785 } | 1785 } |
OLD | NEW |