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

Side by Side Diff: core/src/fpdfdoc/doc_vt.cpp

Issue 1296043002: Merge to XFA: Use override in more classes in core/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 4 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 "../../include/fpdfdoc/fpdf_doc.h" 7 #include "../../include/fpdfdoc/fpdf_doc.h"
8 #include "../../include/fpdfdoc/fpdf_vt.h" 8 #include "../../include/fpdfdoc/fpdf_vt.h"
9 #include "pdf_vt.h" 9 #include "pdf_vt.h"
10 const uint8_t gFontSizeSteps[] = {4, 6, 8, 9, 10, 12, 14, 18, 20, 10 const uint8_t gFontSizeSteps[] = {4, 6, 8, 9, 10, 12, 14, 18, 20,
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 ClearWords(PlaceRange); 954 ClearWords(PlaceRange);
955 if (PlaceRange.BeginPos.nSecIndex != PlaceRange.EndPos.nSecIndex) { 955 if (PlaceRange.BeginPos.nSecIndex != PlaceRange.EndPos.nSecIndex) {
956 ClearEmptySections(PlaceRange); 956 ClearEmptySections(PlaceRange);
957 if (!bLastSecPos) { 957 if (!bLastSecPos) {
958 LinkLatterSection(PlaceRange.BeginPos); 958 LinkLatterSection(PlaceRange.BeginPos);
959 } 959 }
960 } 960 }
961 return PlaceRange.BeginPos; 961 return PlaceRange.BeginPos;
962 } 962 }
963 CPVT_WordPlace CPDF_VariableText::DeleteWord(const CPVT_WordPlace& place) { 963 CPVT_WordPlace CPDF_VariableText::DeleteWord(const CPVT_WordPlace& place) {
964 return ClearRightWord(AjustLineHeader(place, TRUE)); 964 return ClearRightWord(AdjustLineHeader(place, TRUE));
965 } 965 }
966 CPVT_WordPlace CPDF_VariableText::BackSpaceWord(const CPVT_WordPlace& place) { 966 CPVT_WordPlace CPDF_VariableText::BackSpaceWord(const CPVT_WordPlace& place) {
967 return ClearLeftWord(AjustLineHeader(place, TRUE)); 967 return ClearLeftWord(AdjustLineHeader(place, TRUE));
968 } 968 }
969 void CPDF_VariableText::SetText(const FX_WCHAR* text, 969 void CPDF_VariableText::SetText(const FX_WCHAR* text,
970 int32_t charset, 970 int32_t charset,
971 const CPVT_SecProps* pSecProps, 971 const CPVT_SecProps* pSecProps,
972 const CPVT_WordProps* pWordProps) { 972 const CPVT_WordProps* pWordProps) {
973 DeleteWords(CPVT_WordRange(GetBeginWordPlace(), GetEndWordPlace())); 973 DeleteWords(CPVT_WordRange(GetBeginWordPlace(), GetEndWordPlace()));
974 CFX_WideString swText = text; 974 CFX_WideString swText = text;
975 CPVT_WordPlace wp(0, 0, -1); 975 CPVT_WordPlace wp(0, 0, -1);
976 CPVT_SectionInfo secinfo; 976 CPVT_SectionInfo secinfo;
977 if (m_bRichText) { 977 if (m_bRichText) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 nCharCount++; 1026 nCharCount++;
1027 } 1027 }
1028 } 1028 }
1029 void CPDF_VariableText::UpdateWordPlace(CPVT_WordPlace& place) const { 1029 void CPDF_VariableText::UpdateWordPlace(CPVT_WordPlace& place) const {
1030 if (place.nSecIndex < 0) { 1030 if (place.nSecIndex < 0) {
1031 place = GetBeginWordPlace(); 1031 place = GetBeginWordPlace();
1032 } 1032 }
1033 if (place.nSecIndex >= m_SectionArray.GetSize()) { 1033 if (place.nSecIndex >= m_SectionArray.GetSize()) {
1034 place = GetEndWordPlace(); 1034 place = GetEndWordPlace();
1035 } 1035 }
1036 place = AjustLineHeader(place, TRUE); 1036 place = AdjustLineHeader(place, TRUE);
1037 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { 1037 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) {
1038 pSection->UpdateWordPlace(place); 1038 pSection->UpdateWordPlace(place);
1039 } 1039 }
1040 } 1040 }
1041 int32_t CPDF_VariableText::WordPlaceToWordIndex( 1041 int32_t CPDF_VariableText::WordPlaceToWordIndex(
1042 const CPVT_WordPlace& place) const { 1042 const CPVT_WordPlace& place) const {
1043 CPVT_WordPlace newplace = place; 1043 CPVT_WordPlace newplace = place;
1044 UpdateWordPlace(newplace); 1044 UpdateWordPlace(newplace);
1045 int32_t nIndex = 0; 1045 int32_t nIndex = 0;
1046 int32_t i = 0; 1046 int32_t i = 0;
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 } 1423 }
1424 FX_FLOAT CPDF_VariableText::GetCharSpace(const CPVT_WordInfo& WordInfo) { 1424 FX_FLOAT CPDF_VariableText::GetCharSpace(const CPVT_WordInfo& WordInfo) {
1425 return m_bRichText && WordInfo.pWordProps ? WordInfo.pWordProps->fCharSpace 1425 return m_bRichText && WordInfo.pWordProps ? WordInfo.pWordProps->fCharSpace
1426 : m_fCharSpace; 1426 : m_fCharSpace;
1427 } 1427 }
1428 int32_t CPDF_VariableText::GetHorzScale(const CPVT_WordInfo& WordInfo) { 1428 int32_t CPDF_VariableText::GetHorzScale(const CPVT_WordInfo& WordInfo) {
1429 return m_bRichText && WordInfo.pWordProps ? WordInfo.pWordProps->nHorzScale 1429 return m_bRichText && WordInfo.pWordProps ? WordInfo.pWordProps->nHorzScale
1430 : m_nHorzScale; 1430 : m_nHorzScale;
1431 } 1431 }
1432 void CPDF_VariableText::ClearSectionRightWords(const CPVT_WordPlace& place) { 1432 void CPDF_VariableText::ClearSectionRightWords(const CPVT_WordPlace& place) {
1433 CPVT_WordPlace wordplace = AjustLineHeader(place, TRUE); 1433 CPVT_WordPlace wordplace = AdjustLineHeader(place, TRUE);
1434 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { 1434 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) {
1435 for (int32_t w = pSection->m_WordArray.GetSize() - 1; 1435 for (int32_t w = pSection->m_WordArray.GetSize() - 1;
1436 w > wordplace.nWordIndex; w--) { 1436 w > wordplace.nWordIndex; w--) {
1437 delete pSection->m_WordArray.GetAt(w); 1437 delete pSection->m_WordArray.GetAt(w);
1438 pSection->m_WordArray.RemoveAt(w); 1438 pSection->m_WordArray.RemoveAt(w);
1439 } 1439 }
1440 } 1440 }
1441 } 1441 }
1442 CPVT_WordPlace CPDF_VariableText::AjustLineHeader(const CPVT_WordPlace& place, 1442 CPVT_WordPlace CPDF_VariableText::AdjustLineHeader(const CPVT_WordPlace& place,
1443 FX_BOOL bPrevOrNext) const { 1443 FX_BOOL bPrevOrNext) const {
1444 if (place.nWordIndex < 0 && place.nLineIndex > 0) { 1444 if (place.nWordIndex < 0 && place.nLineIndex > 0) {
1445 return bPrevOrNext ? GetPrevWordPlace(place) : GetNextWordPlace(place); 1445 return bPrevOrNext ? GetPrevWordPlace(place) : GetNextWordPlace(place);
1446 } 1446 }
1447 return place; 1447 return place;
1448 } 1448 }
1449 FX_BOOL CPDF_VariableText::ClearEmptySection(const CPVT_WordPlace& place) { 1449 FX_BOOL CPDF_VariableText::ClearEmptySection(const CPVT_WordPlace& place) {
1450 if (place.nSecIndex == 0 && m_SectionArray.GetSize() == 1) { 1450 if (place.nSecIndex == 0 && m_SectionArray.GetSize() == 1) {
1451 return FALSE; 1451 return FALSE;
1452 } 1452 }
1453 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { 1453 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) {
1454 if (pSection->m_WordArray.GetSize() == 0) { 1454 if (pSection->m_WordArray.GetSize() == 0) {
1455 delete pSection; 1455 delete pSection;
1456 m_SectionArray.RemoveAt(place.nSecIndex); 1456 m_SectionArray.RemoveAt(place.nSecIndex);
1457 return TRUE; 1457 return TRUE;
1458 } 1458 }
1459 } 1459 }
1460 return FALSE; 1460 return FALSE;
1461 } 1461 }
1462 void CPDF_VariableText::ClearEmptySections(const CPVT_WordRange& PlaceRange) { 1462 void CPDF_VariableText::ClearEmptySections(const CPVT_WordRange& PlaceRange) {
1463 CPVT_WordPlace wordplace; 1463 CPVT_WordPlace wordplace;
1464 for (int32_t s = PlaceRange.EndPos.nSecIndex; 1464 for (int32_t s = PlaceRange.EndPos.nSecIndex;
1465 s > PlaceRange.BeginPos.nSecIndex; s--) { 1465 s > PlaceRange.BeginPos.nSecIndex; s--) {
1466 wordplace.nSecIndex = s; 1466 wordplace.nSecIndex = s;
1467 ClearEmptySection(wordplace); 1467 ClearEmptySection(wordplace);
1468 } 1468 }
1469 } 1469 }
1470 void CPDF_VariableText::LinkLatterSection(const CPVT_WordPlace& place) { 1470 void CPDF_VariableText::LinkLatterSection(const CPVT_WordPlace& place) {
1471 CPVT_WordPlace oldplace = AjustLineHeader(place, TRUE); 1471 CPVT_WordPlace oldplace = AdjustLineHeader(place, TRUE);
1472 if (CSection* pNextSection = m_SectionArray.GetAt(place.nSecIndex + 1)) { 1472 if (CSection* pNextSection = m_SectionArray.GetAt(place.nSecIndex + 1)) {
1473 if (CSection* pSection = m_SectionArray.GetAt(oldplace.nSecIndex)) { 1473 if (CSection* pSection = m_SectionArray.GetAt(oldplace.nSecIndex)) {
1474 for (int32_t w = 0, sz = pNextSection->m_WordArray.GetSize(); w < sz; 1474 for (int32_t w = 0, sz = pNextSection->m_WordArray.GetSize(); w < sz;
1475 w++) { 1475 w++) {
1476 if (CPVT_WordInfo* pWord = pNextSection->m_WordArray.GetAt(w)) { 1476 if (CPVT_WordInfo* pWord = pNextSection->m_WordArray.GetAt(w)) {
1477 oldplace.nWordIndex++; 1477 oldplace.nWordIndex++;
1478 pSection->AddWord(oldplace, *pWord); 1478 pSection->AddWord(oldplace, *pWord);
1479 } 1479 }
1480 } 1480 }
1481 } 1481 }
1482 delete pNextSection; 1482 delete pNextSection;
1483 m_SectionArray.RemoveAt(place.nSecIndex + 1); 1483 m_SectionArray.RemoveAt(place.nSecIndex + 1);
1484 } 1484 }
1485 } 1485 }
1486 void CPDF_VariableText::ClearWords(const CPVT_WordRange& PlaceRange) { 1486 void CPDF_VariableText::ClearWords(const CPVT_WordRange& PlaceRange) {
1487 CPVT_WordRange NewRange; 1487 CPVT_WordRange NewRange;
1488 NewRange.BeginPos = AjustLineHeader(PlaceRange.BeginPos, TRUE); 1488 NewRange.BeginPos = AdjustLineHeader(PlaceRange.BeginPos, TRUE);
1489 NewRange.EndPos = AjustLineHeader(PlaceRange.EndPos, TRUE); 1489 NewRange.EndPos = AdjustLineHeader(PlaceRange.EndPos, TRUE);
1490 for (int32_t s = NewRange.EndPos.nSecIndex; s >= NewRange.BeginPos.nSecIndex; 1490 for (int32_t s = NewRange.EndPos.nSecIndex; s >= NewRange.BeginPos.nSecIndex;
1491 s--) { 1491 s--) {
1492 if (CSection* pSection = m_SectionArray.GetAt(s)) { 1492 if (CSection* pSection = m_SectionArray.GetAt(s)) {
1493 pSection->ClearWords(NewRange); 1493 pSection->ClearWords(NewRange);
1494 } 1494 }
1495 } 1495 }
1496 } 1496 }
1497 CPVT_WordPlace CPDF_VariableText::ClearLeftWord(const CPVT_WordPlace& place) { 1497 CPVT_WordPlace CPDF_VariableText::ClearLeftWord(const CPVT_WordPlace& place) {
1498 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { 1498 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) {
1499 CPVT_WordPlace leftplace = GetPrevWordPlace(place); 1499 CPVT_WordPlace leftplace = GetPrevWordPlace(place);
1500 if (leftplace != place) { 1500 if (leftplace != place) {
1501 if (leftplace.nSecIndex != place.nSecIndex) { 1501 if (leftplace.nSecIndex != place.nSecIndex) {
1502 if (pSection->m_WordArray.GetSize() == 0) { 1502 if (pSection->m_WordArray.GetSize() == 0) {
1503 ClearEmptySection(place); 1503 ClearEmptySection(place);
1504 } else { 1504 } else {
1505 LinkLatterSection(leftplace); 1505 LinkLatterSection(leftplace);
1506 } 1506 }
1507 } else { 1507 } else {
1508 pSection->ClearWord(place); 1508 pSection->ClearWord(place);
1509 } 1509 }
1510 } 1510 }
1511 return leftplace; 1511 return leftplace;
1512 } 1512 }
1513 return place; 1513 return place;
1514 } 1514 }
1515 CPVT_WordPlace CPDF_VariableText::ClearRightWord(const CPVT_WordPlace& place) { 1515 CPVT_WordPlace CPDF_VariableText::ClearRightWord(const CPVT_WordPlace& place) {
1516 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { 1516 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) {
1517 CPVT_WordPlace rightplace = AjustLineHeader(GetNextWordPlace(place), FALSE); 1517 CPVT_WordPlace rightplace =
1518 AdjustLineHeader(GetNextWordPlace(place), FALSE);
1518 if (rightplace != place) { 1519 if (rightplace != place) {
1519 if (rightplace.nSecIndex != place.nSecIndex) { 1520 if (rightplace.nSecIndex != place.nSecIndex) {
1520 LinkLatterSection(place); 1521 LinkLatterSection(place);
1521 } else { 1522 } else {
1522 pSection->ClearWord(rightplace); 1523 pSection->ClearWord(rightplace);
1523 } 1524 }
1524 } 1525 }
1525 } 1526 }
1526 return place; 1527 return place;
1527 } 1528 }
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1821 if (pSection->m_SecInfo.pSecProps) { 1822 if (pSection->m_SecInfo.pSecProps) {
1822 *pSection->m_SecInfo.pSecProps = section.SecProps; 1823 *pSection->m_SecInfo.pSecProps = section.SecProps;
1823 } 1824 }
1824 if (pSection->m_SecInfo.pWordProps) { 1825 if (pSection->m_SecInfo.pWordProps) {
1825 *pSection->m_SecInfo.pWordProps = section.WordProps; 1826 *pSection->m_SecInfo.pWordProps = section.WordProps;
1826 } 1827 }
1827 return TRUE; 1828 return TRUE;
1828 } 1829 }
1829 return FALSE; 1830 return FALSE;
1830 } 1831 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698