| 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" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 ((int32_t*)m_lpData)[0]++; | 30 ((int32_t*)m_lpData)[0]++; |
| 31 return; | 31 return; |
| 32 } | 32 } |
| 33 CFX_TxtBreak* pTxtBreak = m_pEngine->GetTextBreak(); | 33 CFX_TxtBreak* pTxtBreak = m_pEngine->GetTextBreak(); |
| 34 CFDE_TxtEdtBuf* pTxtBuf = m_pEngine->GetTextBuf(); | 34 CFDE_TxtEdtBuf* pTxtBuf = m_pEngine->GetTextBuf(); |
| 35 const FDE_TXTEDTPARAMS* pParam = m_pEngine->GetEditParams(); | 35 const FDE_TXTEDTPARAMS* pParam = m_pEngine->GetEditParams(); |
| 36 FX_WCHAR wcAlias = 0; | 36 FX_WCHAR wcAlias = 0; |
| 37 if (pParam->dwMode & FDE_TEXTEDITMODE_Password) { | 37 if (pParam->dwMode & FDE_TEXTEDITMODE_Password) { |
| 38 wcAlias = m_pEngine->GetAliasChar(); | 38 wcAlias = m_pEngine->GetAliasChar(); |
| 39 } | 39 } |
| 40 IFX_CharIter* pIter = | 40 std::unique_ptr<IFX_CharIter> pIter( |
| 41 new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)pTxtBuf, wcAlias); | 41 new CFDE_TxtEdtBufIter(static_cast<CFDE_TxtEdtBuf*>(pTxtBuf), wcAlias)); |
| 42 pIter->SetAt(m_nCharStart); | 42 pIter->SetAt(m_nCharStart); |
| 43 int32_t nEndIndex = m_nCharStart + m_nCharCount; | 43 int32_t nEndIndex = m_nCharStart + m_nCharCount; |
| 44 CFX_ArrayTemplate<int32_t> LineBaseArr; | 44 CFX_ArrayTemplate<int32_t> LineBaseArr; |
| 45 FX_BOOL bReload = FALSE; | 45 FX_BOOL bReload = FALSE; |
| 46 uint32_t dwBreakStatus = FX_TXTBREAK_None; | 46 uint32_t dwBreakStatus = FX_TXTBREAK_None; |
| 47 do { | 47 do { |
| 48 if (bReload) { | 48 if (bReload) { |
| 49 dwBreakStatus = pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); | 49 dwBreakStatus = pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); |
| 50 } else { | 50 } else { |
| 51 FX_WCHAR wAppend = pIter->GetChar(); | 51 FX_WCHAR wAppend = pIter->GetChar(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 64 } | 64 } |
| 65 LineBaseArr.Add(nTotal); | 65 LineBaseArr.Add(nTotal); |
| 66 pTxtBreak->ClearBreakPieces(); | 66 pTxtBreak->ClearBreakPieces(); |
| 67 } | 67 } |
| 68 if ((pIter->GetAt() + 1 == nEndIndex) && | 68 if ((pIter->GetAt() + 1 == nEndIndex) && |
| 69 (dwBreakStatus == FX_TXTBREAK_LineBreak)) { | 69 (dwBreakStatus == FX_TXTBREAK_LineBreak)) { |
| 70 bReload = TRUE; | 70 bReload = TRUE; |
| 71 pIter->Next(TRUE); | 71 pIter->Next(TRUE); |
| 72 } | 72 } |
| 73 } while (pIter->Next(FALSE) && (pIter->GetAt() < nEndIndex)); | 73 } while (pIter->Next(FALSE) && (pIter->GetAt() < nEndIndex)); |
| 74 pIter->Release(); | |
| 75 pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); | 74 pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); |
| 76 pTxtBreak->ClearBreakPieces(); | 75 pTxtBreak->ClearBreakPieces(); |
| 77 int32_t nLineCount = LineBaseArr.GetSize(); | 76 int32_t nLineCount = LineBaseArr.GetSize(); |
| 78 m_nLineCount = nLineCount; | 77 m_nLineCount = nLineCount; |
| 79 if (m_lpData == NULL) { | 78 if (m_lpData == NULL) { |
| 80 m_lpData = FX_Alloc(int32_t, nLineCount + 1); | 79 m_lpData = FX_Alloc(int32_t, nLineCount + 1); |
| 81 } else { | 80 } else { |
| 82 m_lpData = FX_Realloc(int32_t, m_lpData, (nLineCount + 1)); | 81 m_lpData = FX_Realloc(int32_t, m_lpData, (nLineCount + 1)); |
| 83 } | 82 } |
| 84 int32_t* pIntArr = (int32_t*)m_lpData; | 83 int32_t* pIntArr = (int32_t*)m_lpData; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 95 ((int32_t*)m_lpData)[0]--; | 94 ((int32_t*)m_lpData)[0]--; |
| 96 ASSERT(((int32_t*)m_lpData)[0] >= 0); | 95 ASSERT(((int32_t*)m_lpData)[0] >= 0); |
| 97 if (((int32_t*)m_lpData)[0] == 0) { | 96 if (((int32_t*)m_lpData)[0] == 0) { |
| 98 FX_Free(m_lpData); | 97 FX_Free(m_lpData); |
| 99 m_lpData = NULL; | 98 m_lpData = NULL; |
| 100 } | 99 } |
| 101 } | 100 } |
| 102 void CFDE_TxtEdtParag::CalcLines() { | 101 void CFDE_TxtEdtParag::CalcLines() { |
| 103 CFX_TxtBreak* pTxtBreak = m_pEngine->GetTextBreak(); | 102 CFX_TxtBreak* pTxtBreak = m_pEngine->GetTextBreak(); |
| 104 CFDE_TxtEdtBuf* pTxtBuf = m_pEngine->GetTextBuf(); | 103 CFDE_TxtEdtBuf* pTxtBuf = m_pEngine->GetTextBuf(); |
| 105 IFX_CharIter* pIter = new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)pTxtBuf); | |
| 106 int32_t nCount = 0; | 104 int32_t nCount = 0; |
| 107 uint32_t dwBreakStatus = FX_TXTBREAK_None; | 105 uint32_t dwBreakStatus = FX_TXTBREAK_None; |
| 108 int32_t nEndIndex = m_nCharStart + m_nCharCount; | 106 int32_t nEndIndex = m_nCharStart + m_nCharCount; |
| 107 std::unique_ptr<IFX_CharIter> pIter( |
| 108 new CFDE_TxtEdtBufIter(static_cast<CFDE_TxtEdtBuf*>(pTxtBuf))); |
| 109 pIter->SetAt(m_nCharStart); | 109 pIter->SetAt(m_nCharStart); |
| 110 FX_BOOL bReload = FALSE; | 110 FX_BOOL bReload = FALSE; |
| 111 do { | 111 do { |
| 112 if (bReload) { | 112 if (bReload) { |
| 113 dwBreakStatus = pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); | 113 dwBreakStatus = pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); |
| 114 } else { | 114 } else { |
| 115 FX_WCHAR wAppend = pIter->GetChar(); | 115 FX_WCHAR wAppend = pIter->GetChar(); |
| 116 dwBreakStatus = pTxtBreak->AppendChar(wAppend); | 116 dwBreakStatus = pTxtBreak->AppendChar(wAppend); |
| 117 } | 117 } |
| 118 if (pIter->GetAt() + 1 == nEndIndex && | 118 if (pIter->GetAt() + 1 == nEndIndex && |
| 119 dwBreakStatus < FX_TXTBREAK_LineBreak) { | 119 dwBreakStatus < FX_TXTBREAK_LineBreak) { |
| 120 dwBreakStatus = pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); | 120 dwBreakStatus = pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); |
| 121 } | 121 } |
| 122 if (dwBreakStatus > FX_TXTBREAK_PieceBreak) { | 122 if (dwBreakStatus > FX_TXTBREAK_PieceBreak) { |
| 123 nCount++; | 123 nCount++; |
| 124 pTxtBreak->ClearBreakPieces(); | 124 pTxtBreak->ClearBreakPieces(); |
| 125 } | 125 } |
| 126 if ((pIter->GetAt() + 1 == nEndIndex) && | 126 if ((pIter->GetAt() + 1 == nEndIndex) && |
| 127 (dwBreakStatus == FX_TXTBREAK_LineBreak)) { | 127 (dwBreakStatus == FX_TXTBREAK_LineBreak)) { |
| 128 bReload = TRUE; | 128 bReload = TRUE; |
| 129 pIter->Next(TRUE); | 129 pIter->Next(TRUE); |
| 130 } | 130 } |
| 131 } while (pIter->Next(FALSE) && (pIter->GetAt() < nEndIndex)); | 131 } while (pIter->Next(FALSE) && (pIter->GetAt() < nEndIndex)); |
| 132 pIter->Release(); | |
| 133 pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); | 132 pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); |
| 134 pTxtBreak->ClearBreakPieces(); | 133 pTxtBreak->ClearBreakPieces(); |
| 135 m_nLineCount = nCount; | 134 m_nLineCount = nCount; |
| 136 } | 135 } |
| 137 void CFDE_TxtEdtParag::GetLineRange(int32_t nLineIndex, | 136 void CFDE_TxtEdtParag::GetLineRange(int32_t nLineIndex, |
| 138 int32_t& nStart, | 137 int32_t& nStart, |
| 139 int32_t& nCount) const { | 138 int32_t& nCount) const { |
| 140 int32_t* pLineBaseArr = (int32_t*)m_lpData; | 139 int32_t* pLineBaseArr = (int32_t*)m_lpData; |
| 141 ASSERT(nLineIndex < m_nLineCount); | 140 ASSERT(nLineIndex < m_nLineCount); |
| 142 nStart = m_nCharStart; | 141 nStart = m_nCharStart; |
| 143 pLineBaseArr++; | 142 pLineBaseArr++; |
| 144 for (int32_t i = 0; i < nLineIndex; i++) { | 143 for (int32_t i = 0; i < nLineIndex; i++) { |
| 145 nStart += *pLineBaseArr; | 144 nStart += *pLineBaseArr; |
| 146 pLineBaseArr++; | 145 pLineBaseArr++; |
| 147 } | 146 } |
| 148 nCount = *pLineBaseArr; | 147 nCount = *pLineBaseArr; |
| 149 } | 148 } |
| OLD | NEW |