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

Side by Side Diff: fpdfsdk/fxedit/fxet_edit.cpp

Issue 2594153003: Remove CFX_ArrayTemplate, use unique_ptr in fpdfsdk/pdfwindow (Closed)
Patch Set: nits Created 4 years 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 "fpdfsdk/fxedit/fxet_edit.h" 7 #include "fpdfsdk/fxedit/fxet_edit.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 pDevice, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), 929 pDevice, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
930 pFontMap->GetPDFFont(nFontIndex), fFontSize, pUser2Device, 930 pFontMap->GetPDFFont(nFontIndex), fFontSize, pUser2Device,
931 sTextBuf.MakeString(), crOldFill, crTextStroke, nHorzScale); 931 sTextBuf.MakeString(), crOldFill, crTextStroke, nHorzScale);
932 } 932 }
933 } 933 }
934 934
935 pDevice->RestoreState(false); 935 pDevice->RestoreState(false);
936 } 936 }
937 937
938 // static 938 // static
939 void CFX_Edit::GeneratePageObjects( 939 void CFX_Edit::GeneratePageObjects(CPDF_PageObjectHolder* pObjectHolder,
940 CPDF_PageObjectHolder* pObjectHolder, 940 CFX_Edit* pEdit,
941 CFX_Edit* pEdit, 941 const CFX_FloatPoint& ptOffset,
942 const CFX_FloatPoint& ptOffset, 942 const CPVT_WordRange* pRange,
943 const CPVT_WordRange* pRange, 943 FX_COLORREF crText,
944 FX_COLORREF crText, 944 std::vector<CPDF_TextObject*>* ObjArray) {
945 CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) { 945 ObjArray->clear();
946
947 IPVT_FontMap* pFontMap = pEdit->GetFontMap();
948 if (!pFontMap)
949 return;
950
946 FX_FLOAT fFontSize = pEdit->GetFontSize(); 951 FX_FLOAT fFontSize = pEdit->GetFontSize();
952 int32_t nOldFontIndex = -1;
953 CFX_ByteTextBuf sTextBuf;
954 CPVT_WordPlace oldplace;
955 CFX_FloatPoint ptBT(0.0f, 0.0f);
956 CFX_Edit_Iterator* pIterator = pEdit->GetIterator();
957 pIterator->SetAt(pRange ? pRange->BeginPos : 0);
958 while (pIterator->NextWord()) {
959 CPVT_WordPlace place = pIterator->GetAt();
960 if (pRange && place.WordCmp(pRange->EndPos) > 0)
961 break;
947 962
948 int32_t nOldFontIndex = -1; 963 CPVT_Word word;
964 if (!pIterator->GetWord(word))
965 continue;
949 966
950 CFX_ByteTextBuf sTextBuf; 967 if (place.LineCmp(oldplace) != 0 || nOldFontIndex != word.nFontIndex) {
951 CFX_FloatPoint ptBT(0.0f, 0.0f); 968 if (sTextBuf.GetLength() > 0) {
969 ObjArray->push_back(AddTextObjToPageObjects(
970 pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex),
971 fFontSize, 0.0f, 100,
972 CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
973 sTextBuf.MakeString()));
952 974
953 ObjArray.RemoveAll(); 975 sTextBuf.Clear();
954
955 CFX_Edit_Iterator* pIterator = pEdit->GetIterator();
956 if (IPVT_FontMap* pFontMap = pEdit->GetFontMap()) {
957 if (pRange)
958 pIterator->SetAt(pRange->BeginPos);
959 else
960 pIterator->SetAt(0);
961
962 CPVT_WordPlace oldplace;
963
964 while (pIterator->NextWord()) {
965 CPVT_WordPlace place = pIterator->GetAt();
966 if (pRange && place.WordCmp(pRange->EndPos) > 0)
967 break;
968
969 CPVT_Word word;
970 if (pIterator->GetWord(word)) {
971 if (place.LineCmp(oldplace) != 0 || nOldFontIndex != word.nFontIndex) {
972 if (sTextBuf.GetLength() > 0) {
973 ObjArray.Add(AddTextObjToPageObjects(
974 pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex),
975 fFontSize, 0.0f, 100,
976 CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
977 sTextBuf.MakeString()));
978
979 sTextBuf.Clear();
980 }
981
982 ptBT = word.ptWord;
983 nOldFontIndex = word.nFontIndex;
984 }
985
986 sTextBuf << GetPDFWordString(pFontMap, word.nFontIndex, word.Word, 0)
987 .AsStringC();
988 oldplace = place;
989 } 976 }
977 ptBT = word.ptWord;
978 nOldFontIndex = word.nFontIndex;
990 } 979 }
991 980 sTextBuf << GetPDFWordString(pFontMap, word.nFontIndex, word.Word, 0)
992 if (sTextBuf.GetLength() > 0) { 981 .AsStringC();
993 ObjArray.Add(AddTextObjToPageObjects( 982 oldplace = place;
994 pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex), fFontSize, 983 }
995 0.0f, 100, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), 984 if (sTextBuf.GetLength() > 0) {
996 sTextBuf.MakeString())); 985 ObjArray->push_back(AddTextObjToPageObjects(
997 } 986 pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex), fFontSize,
987 0.0f, 100, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
988 sTextBuf.MakeString()));
998 } 989 }
999 } 990 }
1000 991
1001 CFX_Edit::CFX_Edit() 992 CFX_Edit::CFX_Edit()
1002 : m_pVT(new CPDF_VariableText), 993 : m_pVT(new CPDF_VariableText),
1003 m_pNotify(nullptr), 994 m_pNotify(nullptr),
1004 m_pOprNotify(nullptr), 995 m_pOprNotify(nullptr),
1005 m_wpCaret(-1, -1, -1), 996 m_wpCaret(-1, -1, -1),
1006 m_wpOldCaret(-1, -1, -1), 997 m_wpOldCaret(-1, -1, -1),
1007 m_SelState(), 998 m_SelState(),
(...skipping 1518 matching lines...) Expand 10 before | Expand all | Expand 10 after
2526 int32_t CFX_Edit_RectArray::GetSize() const { 2517 int32_t CFX_Edit_RectArray::GetSize() const {
2527 return m_Rects.GetSize(); 2518 return m_Rects.GetSize();
2528 } 2519 }
2529 2520
2530 CFX_FloatRect* CFX_Edit_RectArray::GetAt(int32_t nIndex) const { 2521 CFX_FloatRect* CFX_Edit_RectArray::GetAt(int32_t nIndex) const {
2531 if (nIndex < 0 || nIndex >= m_Rects.GetSize()) 2522 if (nIndex < 0 || nIndex >= m_Rects.GetSize())
2532 return nullptr; 2523 return nullptr;
2533 2524
2534 return m_Rects.GetAt(nIndex); 2525 return m_Rects.GetAt(nIndex);
2535 } 2526 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698