Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: xfa/src/fee/src/fee/fde_txtedtengine.cpp

Issue 1635853002: XFA: Fix a bunch of pointless returns. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <algorithm> 7 #include <algorithm>
8 8
9 #include "xfa/src/foxitlib.h" 9 #include "xfa/src/foxitlib.h"
10 #include "xfa/src/fee/include/ifde_txtedtengine.h" 10 #include "xfa/src/fee/include/ifde_txtedtengine.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 int32_t CFDE_TxtEdtEngine::GetTextLength() const { 160 int32_t CFDE_TxtEdtEngine::GetTextLength() const {
161 return GetTextBufLength(); 161 return GetTextBufLength();
162 } 162 }
163 void CFDE_TxtEdtEngine::GetText(CFX_WideString& wsText, 163 void CFDE_TxtEdtEngine::GetText(CFX_WideString& wsText,
164 int32_t nStart, 164 int32_t nStart,
165 int32_t nCount) { 165 int32_t nCount) {
166 int32_t nTextBufLength = GetTextBufLength(); 166 int32_t nTextBufLength = GetTextBufLength();
167 if (nCount == -1) { 167 if (nCount == -1) {
168 nCount = nTextBufLength - nStart; 168 nCount = nTextBufLength - nStart;
169 } 169 }
170 #ifdef FDE_USEFORMATBLOCK 170 #ifdef FDE_USEFORMATBLOCK
Tom Sepez 2016/01/26 00:15:38 Did we ever get an answer about FDE_USEFORMATBLOCK
Lei Zhang 2016/01/26 00:31:02 I forgot to ask. I'll do that now.
171 int32_t nBlockCount = m_BlockArray.GetSize(); 171 int32_t nBlockCount = m_BlockArray.GetSize();
172 if (nBlockCount == 0 || m_wsFixText.IsEmpty()) { 172 if (nBlockCount == 0 || m_wsFixText.IsEmpty()) {
173 m_pTxtBuf->GetRange(wsText, nStart, nCount); 173 m_pTxtBuf->GetRange(wsText, nStart, nCount);
174 return; 174 return;
175 } 175 }
176 CFX_WideString wsTemp; 176 CFX_WideString wsTemp;
177 const FX_WCHAR* lpFixBuffer = const FX_WCHAR * (m_wsFixText); 177 const FX_WCHAR* lpFixBuffer = const FX_WCHAR * (m_wsFixText);
178 FX_WCHAR* lpBuffer = wsTemp.GetBuffer(nTextBufLength); 178 FX_WCHAR* lpBuffer = wsTemp.GetBuffer(nTextBufLength);
179 int32_t nRealLength = 0; 179 int32_t nRealLength = 0;
180 int32_t nPrePos = 0; 180 int32_t nPrePos = 0;
(...skipping 22 matching lines...) Expand all
203 int32_t nRealBgn = GetRealIndex(nStart); 203 int32_t nRealBgn = GetRealIndex(nStart);
204 int32_t nRealEnd = GetRealIndex(nStart + nCount - 1); 204 int32_t nRealEnd = GetRealIndex(nStart + nCount - 1);
205 int32_t nRealCount = nRealEnd - nRealBgn; 205 int32_t nRealCount = nRealEnd - nRealBgn;
206 FX_WCHAR* lpDestBuf = wsText.GetBuffer(nRealCount); 206 FX_WCHAR* lpDestBuf = wsText.GetBuffer(nRealCount);
207 FXSYS_memcpy(lpDestBuf, const FX_WCHAR*(wsTemp) + nRealBgn, 207 FXSYS_memcpy(lpDestBuf, const FX_WCHAR*(wsTemp) + nRealBgn,
208 nRealCount * sizeof(FX_WCHAR)); 208 nRealCount * sizeof(FX_WCHAR));
209 wsText.ReleaseBuffer(); 209 wsText.ReleaseBuffer();
210 #else 210 #else
211 m_pTxtBuf->GetRange(wsText, nStart, nCount); 211 m_pTxtBuf->GetRange(wsText, nStart, nCount);
212 RecoverParagEnd(wsText); 212 RecoverParagEnd(wsText);
213 return;
214 #endif 213 #endif
215 } 214 }
215
216 void CFDE_TxtEdtEngine::ClearText() { 216 void CFDE_TxtEdtEngine::ClearText() {
217 DeleteRange(0, -1); 217 DeleteRange(0, -1);
218 } 218 }
219 int32_t CFDE_TxtEdtEngine::GetCaretRect(CFX_RectF& rtCaret) const { 219 int32_t CFDE_TxtEdtEngine::GetCaretRect(CFX_RectF& rtCaret) const {
220 rtCaret = m_rtCaret; 220 rtCaret = m_rtCaret;
221 return m_nCaret; 221 return m_nCaret;
222 } 222 }
223 int32_t CFDE_TxtEdtEngine::GetCaretPos() const { 223 int32_t CFDE_TxtEdtEngine::GetCaretPos() const {
224 if (IsLocked()) { 224 if (IsLocked()) {
225 return 0; 225 return 0;
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 int32_t nRangeCount = m_SelRangePtrArr.GetSize(); 927 int32_t nRangeCount = m_SelRangePtrArr.GetSize();
928 int32_t i = 0; 928 int32_t i = 0;
929 for (i = 0; i < nRangeCount; i++) { 929 for (i = 0; i < nRangeCount; i++) {
930 lpTemp = m_SelRangePtrArr[i]; 930 lpTemp = m_SelRangePtrArr[i];
931 if (lpTemp->nStart == nStart && lpTemp->nCount == nCount) { 931 if (lpTemp->nStart == nStart && lpTemp->nCount == nCount) {
932 delete lpTemp; 932 delete lpTemp;
933 m_SelRangePtrArr.RemoveAt(i); 933 m_SelRangePtrArr.RemoveAt(i);
934 return; 934 return;
935 } 935 }
936 } 936 }
937 return;
938 } 937 }
938
939 void CFDE_TxtEdtEngine::AddSelRange(int32_t nStart, int32_t nCount) { 939 void CFDE_TxtEdtEngine::AddSelRange(int32_t nStart, int32_t nCount) {
940 if (nCount == -1) { 940 if (nCount == -1) {
941 nCount = GetTextLength() - nStart; 941 nCount = GetTextLength() - nStart;
942 } 942 }
943 int32_t nSize = m_SelRangePtrArr.GetSize(); 943 int32_t nSize = m_SelRangePtrArr.GetSize();
944 if (nSize <= 0) { 944 if (nSize <= 0) {
945 FDE_LPTXTEDTSELRANGE lpSelRange = new FDE_TXTEDTSELRANGE; 945 FDE_LPTXTEDTSELRANGE lpSelRange = new FDE_TXTEDTSELRANGE;
946 lpSelRange->nStart = nStart; 946 lpSelRange->nStart = nStart;
947 lpSelRange->nCount = nCount; 947 lpSelRange->nCount = nCount;
948 m_SelRangePtrArr.Add(lpSelRange); 948 m_SelRangePtrArr.Add(lpSelRange);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 lpTemp->nStart = nStart; 996 lpTemp->nStart = nStart;
997 lpTemp->nCount = nCount; 997 lpTemp->nCount = nCount;
998 nRangeCnt--; 998 nRangeCnt--;
999 nRangeBgn++; 999 nRangeBgn++;
1000 while (nRangeCnt--) { 1000 while (nRangeCnt--) {
1001 delete m_SelRangePtrArr[nRangeBgn]; 1001 delete m_SelRangePtrArr[nRangeBgn];
1002 m_SelRangePtrArr.RemoveAt(nRangeBgn); 1002 m_SelRangePtrArr.RemoveAt(nRangeBgn);
1003 } 1003 }
1004 } 1004 }
1005 m_Param.pEventSink->On_SelChanged(this); 1005 m_Param.pEventSink->On_SelChanged(this);
1006 return;
1007 } 1006 }
1007
1008 int32_t CFDE_TxtEdtEngine::CountSelRanges() { 1008 int32_t CFDE_TxtEdtEngine::CountSelRanges() {
1009 return m_SelRangePtrArr.GetSize(); 1009 return m_SelRangePtrArr.GetSize();
1010 } 1010 }
1011 int32_t CFDE_TxtEdtEngine::GetSelRange(int32_t nIndex, int32_t& nStart) { 1011 int32_t CFDE_TxtEdtEngine::GetSelRange(int32_t nIndex, int32_t& nStart) {
1012 nStart = m_SelRangePtrArr[nIndex]->nStart; 1012 nStart = m_SelRangePtrArr[nIndex]->nStart;
1013 return m_SelRangePtrArr[nIndex]->nCount; 1013 return m_SelRangePtrArr[nIndex]->nCount;
1014 } 1014 }
1015 void CFDE_TxtEdtEngine::ClearSelection() { 1015 void CFDE_TxtEdtEngine::ClearSelection() {
1016 int32_t nCount = m_SelRangePtrArr.GetSize(); 1016 int32_t nCount = m_SelRangePtrArr.GetSize();
1017 FDE_LPTXTEDTSELRANGE lpRange = NULL; 1017 FDE_LPTXTEDTSELRANGE lpRange = NULL;
(...skipping 1839 matching lines...) Expand 10 before | Expand all | Expand 10 after
2857 ArchiveLoader >> nField; 2857 ArchiveLoader >> nField;
2858 m_pField = (CFDE_TxtEdtField*)nField; 2858 m_pField = (CFDE_TxtEdtField*)nField;
2859 ArchiveLoader >> m_nIndexInField; 2859 ArchiveLoader >> m_nIndexInField;
2860 ArchiveLoader >> m_nFieldBgn; 2860 ArchiveLoader >> m_nFieldBgn;
2861 ArchiveLoader >> m_nFieldNewLength; 2861 ArchiveLoader >> m_nFieldNewLength;
2862 ArchiveLoader >> m_wsDel; 2862 ArchiveLoader >> m_wsDel;
2863 ArchiveLoader >> m_wsIns; 2863 ArchiveLoader >> m_wsIns;
2864 ArchiveLoader >> m_bSel; 2864 ArchiveLoader >> m_bSel;
2865 } 2865 }
2866 #endif 2866 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698