| 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_txtedtparag.h" | 7 #include "xfa/fee/fde_txtedtparag.h" |
| 8 | 8 |
| 9 #include "xfa/fee/fde_txtedtbuf.h" | 9 #include "xfa/fee/fde_txtedtbuf.h" |
| 10 #include "xfa/fee/fde_txtedtengine.h" | 10 #include "xfa/fee/fde_txtedtengine.h" |
| 11 #include "xfa/fee/fx_wordbreak/fx_wordbreak.h" | 11 #include "xfa/fee/fx_wordbreak/fx_wordbreak.h" |
| 12 #include "xfa/fee/ifde_txtedtbuf.h" | |
| 13 #include "xfa/fee/ifde_txtedtengine.h" | 12 #include "xfa/fee/ifde_txtedtengine.h" |
| 14 #include "xfa/fgas/layout/fgas_textbreak.h" | 13 #include "xfa/fgas/layout/fgas_textbreak.h" |
| 15 | 14 |
| 16 CFDE_TxtEdtParag::CFDE_TxtEdtParag(CFDE_TxtEdtEngine* pEngine) | 15 CFDE_TxtEdtParag::CFDE_TxtEdtParag(CFDE_TxtEdtEngine* pEngine) |
| 17 : m_nCharStart(0), | 16 : m_nCharStart(0), |
| 18 m_nCharCount(0), | 17 m_nCharCount(0), |
| 19 m_nLineCount(0), | 18 m_nLineCount(0), |
| 20 m_lpData(NULL), | 19 m_lpData(NULL), |
| 21 m_pEngine(pEngine) { | 20 m_pEngine(pEngine) { |
| 22 ASSERT(m_pEngine); | 21 ASSERT(m_pEngine); |
| 23 } | 22 } |
| 24 CFDE_TxtEdtParag::~CFDE_TxtEdtParag() { | 23 CFDE_TxtEdtParag::~CFDE_TxtEdtParag() { |
| 25 if (m_lpData != NULL) { | 24 if (m_lpData != NULL) { |
| 26 FX_Free(m_lpData); | 25 FX_Free(m_lpData); |
| 27 } | 26 } |
| 28 } | 27 } |
| 29 void CFDE_TxtEdtParag::LoadParag() { | 28 void CFDE_TxtEdtParag::LoadParag() { |
| 30 if (m_lpData != NULL) { | 29 if (m_lpData != NULL) { |
| 31 ((int32_t*)m_lpData)[0]++; | 30 ((int32_t*)m_lpData)[0]++; |
| 32 return; | 31 return; |
| 33 } | 32 } |
| 34 CFX_TxtBreak* pTxtBreak = m_pEngine->GetTextBreak(); | 33 CFX_TxtBreak* pTxtBreak = m_pEngine->GetTextBreak(); |
| 35 IFDE_TxtEdtBuf* pTxtBuf = m_pEngine->GetTextBuf(); | 34 CFDE_TxtEdtBuf* pTxtBuf = m_pEngine->GetTextBuf(); |
| 36 const FDE_TXTEDTPARAMS* pParam = m_pEngine->GetEditParams(); | 35 const FDE_TXTEDTPARAMS* pParam = m_pEngine->GetEditParams(); |
| 37 FX_WCHAR wcAlias = 0; | 36 FX_WCHAR wcAlias = 0; |
| 38 if (pParam->dwMode & FDE_TEXTEDITMODE_Password) { | 37 if (pParam->dwMode & FDE_TEXTEDITMODE_Password) { |
| 39 wcAlias = m_pEngine->GetAliasChar(); | 38 wcAlias = m_pEngine->GetAliasChar(); |
| 40 } | 39 } |
| 41 IFX_CharIter* pIter = | 40 IFX_CharIter* pIter = |
| 42 new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)pTxtBuf, wcAlias); | 41 new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)pTxtBuf, wcAlias); |
| 43 pIter->SetAt(m_nCharStart); | 42 pIter->SetAt(m_nCharStart); |
| 44 int32_t nEndIndex = m_nCharStart + m_nCharCount; | 43 int32_t nEndIndex = m_nCharStart + m_nCharCount; |
| 45 CFX_ArrayTemplate<int32_t> LineBaseArr; | 44 CFX_ArrayTemplate<int32_t> LineBaseArr; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 ASSERT(m_lpData != NULL); | 94 ASSERT(m_lpData != NULL); |
| 96 ((int32_t*)m_lpData)[0]--; | 95 ((int32_t*)m_lpData)[0]--; |
| 97 ASSERT(((int32_t*)m_lpData)[0] >= 0); | 96 ASSERT(((int32_t*)m_lpData)[0] >= 0); |
| 98 if (((int32_t*)m_lpData)[0] == 0) { | 97 if (((int32_t*)m_lpData)[0] == 0) { |
| 99 FX_Free(m_lpData); | 98 FX_Free(m_lpData); |
| 100 m_lpData = NULL; | 99 m_lpData = NULL; |
| 101 } | 100 } |
| 102 } | 101 } |
| 103 void CFDE_TxtEdtParag::CalcLines() { | 102 void CFDE_TxtEdtParag::CalcLines() { |
| 104 CFX_TxtBreak* pTxtBreak = m_pEngine->GetTextBreak(); | 103 CFX_TxtBreak* pTxtBreak = m_pEngine->GetTextBreak(); |
| 105 IFDE_TxtEdtBuf* pTxtBuf = m_pEngine->GetTextBuf(); | 104 CFDE_TxtEdtBuf* pTxtBuf = m_pEngine->GetTextBuf(); |
| 106 IFX_CharIter* pIter = new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)pTxtBuf); | 105 IFX_CharIter* pIter = new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)pTxtBuf); |
| 107 int32_t nCount = 0; | 106 int32_t nCount = 0; |
| 108 uint32_t dwBreakStatus = FX_TXTBREAK_None; | 107 uint32_t dwBreakStatus = FX_TXTBREAK_None; |
| 109 int32_t nEndIndex = m_nCharStart + m_nCharCount; | 108 int32_t nEndIndex = m_nCharStart + m_nCharCount; |
| 110 pIter->SetAt(m_nCharStart); | 109 pIter->SetAt(m_nCharStart); |
| 111 FX_BOOL bReload = FALSE; | 110 FX_BOOL bReload = FALSE; |
| 112 do { | 111 do { |
| 113 if (bReload) { | 112 if (bReload) { |
| 114 dwBreakStatus = pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); | 113 dwBreakStatus = pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); |
| 115 } else { | 114 } else { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 141 int32_t* pLineBaseArr = (int32_t*)m_lpData; | 140 int32_t* pLineBaseArr = (int32_t*)m_lpData; |
| 142 ASSERT(nLineIndex < m_nLineCount); | 141 ASSERT(nLineIndex < m_nLineCount); |
| 143 nStart = m_nCharStart; | 142 nStart = m_nCharStart; |
| 144 pLineBaseArr++; | 143 pLineBaseArr++; |
| 145 for (int32_t i = 0; i < nLineIndex; i++) { | 144 for (int32_t i = 0; i < nLineIndex; i++) { |
| 146 nStart += *pLineBaseArr; | 145 nStart += *pLineBaseArr; |
| 147 pLineBaseArr++; | 146 pLineBaseArr++; |
| 148 } | 147 } |
| 149 nCount = *pLineBaseArr; | 148 nCount = *pLineBaseArr; |
| 150 } | 149 } |
| OLD | NEW |