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 "core/fpdftext/cpdf_textpage.h" | 7 #include "core/fpdftext/cpdf_textpage.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 | 663 |
664 void CPDF_TextPage::AddCharInfoByRLDirection(FX_WCHAR wChar, | 664 void CPDF_TextPage::AddCharInfoByRLDirection(FX_WCHAR wChar, |
665 PAGECHAR_INFO info) { | 665 PAGECHAR_INFO info) { |
666 if (IsControlChar(info)) { | 666 if (IsControlChar(info)) { |
667 info.m_Index = -1; | 667 info.m_Index = -1; |
668 m_CharList.push_back(info); | 668 m_CharList.push_back(info); |
669 return; | 669 return; |
670 } | 670 } |
671 | 671 |
672 info.m_Index = m_TextBuf.GetLength(); | 672 info.m_Index = m_TextBuf.GetLength(); |
673 wChar = FX_GetMirrorChar(wChar, TRUE, FALSE); | 673 wChar = FX_GetMirrorChar(wChar, true, false); |
674 FX_WCHAR* pDst = nullptr; | 674 FX_WCHAR* pDst = nullptr; |
675 FX_STRSIZE nCount = Unicode_GetNormalization(wChar, pDst); | 675 FX_STRSIZE nCount = Unicode_GetNormalization(wChar, pDst); |
676 if (nCount >= 1) { | 676 if (nCount >= 1) { |
677 pDst = FX_Alloc(FX_WCHAR, nCount); | 677 pDst = FX_Alloc(FX_WCHAR, nCount); |
678 Unicode_GetNormalization(wChar, pDst); | 678 Unicode_GetNormalization(wChar, pDst); |
679 for (int nIndex = 0; nIndex < nCount; nIndex++) { | 679 for (int nIndex = 0; nIndex < nCount; nIndex++) { |
680 PAGECHAR_INFO info2 = info; | 680 PAGECHAR_INFO info2 = info; |
681 info2.m_Unicode = pDst[nIndex]; | 681 info2.m_Unicode = pDst[nIndex]; |
682 info2.m_Flag = FPDFTEXT_CHAR_PIECE; | 682 info2.m_Flag = FPDFTEXT_CHAR_PIECE; |
683 m_TextBuf.AppendChar(info2.m_Unicode); | 683 m_TextBuf.AppendChar(info2.m_Unicode); |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 std::swap(m_TempCharList[i], m_TempCharList[j]); | 945 std::swap(m_TempCharList[i], m_TempCharList[j]); |
946 std::swap(m_TempCharList[i].m_Index, m_TempCharList[j].m_Index); | 946 std::swap(m_TempCharList[i].m_Index, m_TempCharList[j].m_Index); |
947 } | 947 } |
948 FX_WCHAR* pTempBuffer = m_TempTextBuf.GetBuffer(); | 948 FX_WCHAR* pTempBuffer = m_TempTextBuf.GetBuffer(); |
949 i = iBufStartAppend; | 949 i = iBufStartAppend; |
950 j = m_TempTextBuf.GetLength() - 1; | 950 j = m_TempTextBuf.GetLength() - 1; |
951 for (; i < j; i++, j--) | 951 for (; i < j; i++, j--) |
952 std::swap(pTempBuffer[i], pTempBuffer[j]); | 952 std::swap(pTempBuffer[i], pTempBuffer[j]); |
953 } | 953 } |
954 | 954 |
955 FX_BOOL CPDF_TextPage::IsRightToLeft(const CPDF_TextObject* pTextObj, | 955 bool CPDF_TextPage::IsRightToLeft(const CPDF_TextObject* pTextObj, |
956 const CPDF_Font* pFont, | 956 const CPDF_Font* pFont, |
957 int nItems) const { | 957 int nItems) const { |
958 CFX_WideString str; | 958 CFX_WideString str; |
959 for (int32_t i = 0; i < nItems; i++) { | 959 for (int32_t i = 0; i < nItems; i++) { |
960 CPDF_TextObjectItem item; | 960 CPDF_TextObjectItem item; |
961 pTextObj->GetItemInfo(i, &item); | 961 pTextObj->GetItemInfo(i, &item); |
962 if (item.m_CharCode == static_cast<uint32_t>(-1)) | 962 if (item.m_CharCode == static_cast<uint32_t>(-1)) |
963 continue; | 963 continue; |
964 CFX_WideString wstrItem = pFont->UnicodeFromCharCode(item.m_CharCode); | 964 CFX_WideString wstrItem = pFont->UnicodeFromCharCode(item.m_CharCode); |
965 FX_WCHAR wChar = wstrItem.GetAt(0); | 965 FX_WCHAR wChar = wstrItem.GetAt(0); |
966 if ((wstrItem.IsEmpty() || wChar == 0) && item.m_CharCode) | 966 if ((wstrItem.IsEmpty() || wChar == 0) && item.m_CharCode) |
967 wChar = (FX_WCHAR)item.m_CharCode; | 967 wChar = (FX_WCHAR)item.m_CharCode; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1052 ProcessMarkedContent(Obj); | 1052 ProcessMarkedContent(Obj); |
1053 m_pPreTextObj = pTextObj; | 1053 m_pPreTextObj = pTextObj; |
1054 m_perMatrix = formMatrix; | 1054 m_perMatrix = formMatrix; |
1055 return; | 1055 return; |
1056 } | 1056 } |
1057 m_pPreTextObj = pTextObj; | 1057 m_pPreTextObj = pTextObj; |
1058 m_perMatrix = formMatrix; | 1058 m_perMatrix = formMatrix; |
1059 int nItems = pTextObj->CountItems(); | 1059 int nItems = pTextObj->CountItems(); |
1060 FX_FLOAT baseSpace = CalculateBaseSpace(pTextObj, matrix); | 1060 FX_FLOAT baseSpace = CalculateBaseSpace(pTextObj, matrix); |
1061 | 1061 |
1062 const FX_BOOL bR2L = IsRightToLeft(pTextObj, pFont, nItems); | 1062 const bool bR2L = IsRightToLeft(pTextObj, pFont, nItems); |
1063 const FX_BOOL bIsBidiAndMirrorInverse = | 1063 const bool bIsBidiAndMirrorInverse = |
1064 bR2L && (matrix.a * matrix.d - matrix.b * matrix.c) < 0; | 1064 bR2L && (matrix.a * matrix.d - matrix.b * matrix.c) < 0; |
1065 int32_t iBufStartAppend = m_TempTextBuf.GetLength(); | 1065 int32_t iBufStartAppend = m_TempTextBuf.GetLength(); |
1066 int32_t iCharListStartAppend = | 1066 int32_t iCharListStartAppend = |
1067 pdfium::CollectionSize<int32_t>(m_TempCharList); | 1067 pdfium::CollectionSize<int32_t>(m_TempCharList); |
1068 | 1068 |
1069 FX_FLOAT spacing = 0; | 1069 FX_FLOAT spacing = 0; |
1070 for (int i = 0; i < nItems; i++) { | 1070 for (int i = 0; i < nItems; i++) { |
1071 CPDF_TextObjectItem item; | 1071 CPDF_TextObjectItem item; |
1072 PAGECHAR_INFO charinfo; | 1072 PAGECHAR_INFO charinfo; |
1073 charinfo.m_OriginX = 0; | 1073 charinfo.m_OriginX = 0; |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1234 v.Normalize(); | 1234 v.Normalize(); |
1235 if (v.y <= 0.0872f) | 1235 if (v.y <= 0.0872f) |
1236 return v.x <= 0.0872f ? m_TextlineDir : TextOrientation::Horizontal; | 1236 return v.x <= 0.0872f ? m_TextlineDir : TextOrientation::Horizontal; |
1237 | 1237 |
1238 if (v.x <= 0.0872f) | 1238 if (v.x <= 0.0872f) |
1239 return TextOrientation::Vertical; | 1239 return TextOrientation::Vertical; |
1240 | 1240 |
1241 return m_TextlineDir; | 1241 return m_TextlineDir; |
1242 } | 1242 } |
1243 | 1243 |
1244 FX_BOOL CPDF_TextPage::IsHyphen(FX_WCHAR curChar) { | 1244 bool CPDF_TextPage::IsHyphen(FX_WCHAR curChar) { |
1245 CFX_WideString strCurText = m_TempTextBuf.MakeString(); | 1245 CFX_WideString strCurText = m_TempTextBuf.MakeString(); |
1246 if (strCurText.IsEmpty()) | 1246 if (strCurText.IsEmpty()) |
1247 strCurText = m_TextBuf.AsStringC(); | 1247 strCurText = m_TextBuf.AsStringC(); |
1248 FX_STRSIZE nCount = strCurText.GetLength(); | 1248 FX_STRSIZE nCount = strCurText.GetLength(); |
1249 int nIndex = nCount - 1; | 1249 int nIndex = nCount - 1; |
1250 FX_WCHAR wcTmp = strCurText.GetAt(nIndex); | 1250 FX_WCHAR wcTmp = strCurText.GetAt(nIndex); |
1251 while (wcTmp == 0x20 && nIndex <= nCount - 1 && nIndex >= 0) | 1251 while (wcTmp == 0x20 && nIndex <= nCount - 1 && nIndex >= 0) |
1252 wcTmp = strCurText.GetAt(--nIndex); | 1252 wcTmp = strCurText.GetAt(--nIndex); |
1253 if (0x2D == wcTmp || 0xAD == wcTmp) { | 1253 if (0x2D == wcTmp || 0xAD == wcTmp) { |
1254 if (--nIndex > 0) { | 1254 if (--nIndex > 0) { |
1255 FX_WCHAR preChar = strCurText.GetAt((nIndex)); | 1255 FX_WCHAR preChar = strCurText.GetAt((nIndex)); |
1256 if (((preChar >= L'A' && preChar <= L'Z') || | 1256 if (((preChar >= L'A' && preChar <= L'Z') || |
1257 (preChar >= L'a' && preChar <= L'z')) && | 1257 (preChar >= L'a' && preChar <= L'z')) && |
1258 ((curChar >= L'A' && curChar <= L'Z') || | 1258 ((curChar >= L'A' && curChar <= L'Z') || |
1259 (curChar >= L'a' && curChar <= L'z'))) { | 1259 (curChar >= L'a' && curChar <= L'z'))) { |
1260 return TRUE; | 1260 return true; |
1261 } | 1261 } |
1262 } | 1262 } |
1263 const PAGECHAR_INFO* preInfo; | 1263 const PAGECHAR_INFO* preInfo; |
1264 if (!m_TempCharList.empty()) | 1264 if (!m_TempCharList.empty()) |
1265 preInfo = &m_TempCharList.back(); | 1265 preInfo = &m_TempCharList.back(); |
1266 else if (!m_CharList.empty()) | 1266 else if (!m_CharList.empty()) |
1267 preInfo = &m_CharList.back(); | 1267 preInfo = &m_CharList.back(); |
1268 else | 1268 else |
1269 return FALSE; | 1269 return false; |
1270 if (FPDFTEXT_CHAR_PIECE == preInfo->m_Flag && | 1270 if (FPDFTEXT_CHAR_PIECE == preInfo->m_Flag && |
1271 (0xAD == preInfo->m_Unicode || 0x2D == preInfo->m_Unicode)) { | 1271 (0xAD == preInfo->m_Unicode || 0x2D == preInfo->m_Unicode)) { |
1272 return TRUE; | 1272 return true; |
1273 } | 1273 } |
1274 } | 1274 } |
1275 return FALSE; | 1275 return false; |
1276 } | 1276 } |
1277 | 1277 |
1278 CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject( | 1278 CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject( |
1279 const CPDF_TextObject* pObj, | 1279 const CPDF_TextObject* pObj, |
1280 const CFX_Matrix& formMatrix) { | 1280 const CFX_Matrix& formMatrix) { |
1281 FindPreviousTextObject(); | 1281 FindPreviousTextObject(); |
1282 TextOrientation WritingMode = GetTextObjectWritingMode(pObj); | 1282 TextOrientation WritingMode = GetTextObjectWritingMode(pObj); |
1283 if (WritingMode == TextOrientation::Unknown) | 1283 if (WritingMode == TextOrientation::Unknown) |
1284 WritingMode = GetTextObjectWritingMode(m_pPreTextObj); | 1284 WritingMode = GetTextObjectWritingMode(m_pPreTextObj); |
1285 | 1285 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1343 bool bNewline = false; | 1343 bool bNewline = false; |
1344 if (WritingMode == TextOrientation::Horizontal) { | 1344 if (WritingMode == TextOrientation::Horizontal) { |
1345 CFX_FloatRect rect1(m_pPreTextObj->m_Left, pObj->m_Bottom, | 1345 CFX_FloatRect rect1(m_pPreTextObj->m_Left, pObj->m_Bottom, |
1346 m_pPreTextObj->m_Right, pObj->m_Top); | 1346 m_pPreTextObj->m_Right, pObj->m_Top); |
1347 CFX_FloatRect rect2(m_pPreTextObj->m_Left, m_pPreTextObj->m_Bottom, | 1347 CFX_FloatRect rect2(m_pPreTextObj->m_Left, m_pPreTextObj->m_Bottom, |
1348 m_pPreTextObj->m_Right, m_pPreTextObj->m_Top); | 1348 m_pPreTextObj->m_Right, m_pPreTextObj->m_Top); |
1349 CFX_FloatRect rect3 = rect1; | 1349 CFX_FloatRect rect3 = rect1; |
1350 rect1.Intersect(rect2); | 1350 rect1.Intersect(rect2); |
1351 if ((rect1.IsEmpty() && rect2.Height() > 5 && rect3.Height() > 5) || | 1351 if ((rect1.IsEmpty() && rect2.Height() > 5 && rect3.Height() > 5) || |
1352 ((y > threshold * 2 || y < threshold * -3) && | 1352 ((y > threshold * 2 || y < threshold * -3) && |
1353 (FXSYS_fabs(y) < 1 ? FXSYS_fabs(x) < FXSYS_fabs(y) : TRUE))) { | 1353 (FXSYS_fabs(y) < 1 ? FXSYS_fabs(x) < FXSYS_fabs(y) : true))) { |
1354 bNewline = true; | 1354 bNewline = true; |
1355 if (nItem > 1) { | 1355 if (nItem > 1) { |
1356 CPDF_TextObjectItem tempItem; | 1356 CPDF_TextObjectItem tempItem; |
1357 m_pPreTextObj->GetItemInfo(0, &tempItem); | 1357 m_pPreTextObj->GetItemInfo(0, &tempItem); |
1358 CFX_Matrix m; | 1358 CFX_Matrix m; |
1359 m_pPreTextObj->GetTextMatrix(&m); | 1359 m_pPreTextObj->GetTextMatrix(&m); |
1360 if (PrevItem.m_OriginX > tempItem.m_OriginX && | 1360 if (PrevItem.m_OriginX > tempItem.m_OriginX && |
1361 m_DisplayMatrix.a > 0.9 && m_DisplayMatrix.b < 0.1 && | 1361 m_DisplayMatrix.a > 0.9 && m_DisplayMatrix.b < 0.1 && |
1362 m_DisplayMatrix.c < 0.1 && m_DisplayMatrix.d < -0.9 && m.b < 0.1 && | 1362 m_DisplayMatrix.c < 0.1 && m_DisplayMatrix.d < -0.9 && m.b < 0.1 && |
1363 m.c < 0.1) { | 1363 m.c < 0.1) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1421 return GenerateCharacter::Space; | 1421 return GenerateCharacter::Space; |
1422 if ((x - last_pos - last_width) > this_width || | 1422 if ((x - last_pos - last_width) > this_width || |
1423 (x - last_pos - this_width) > last_width) { | 1423 (x - last_pos - this_width) > last_width) { |
1424 return GenerateCharacter::Space; | 1424 return GenerateCharacter::Space; |
1425 } | 1425 } |
1426 } | 1426 } |
1427 } | 1427 } |
1428 return GenerateCharacter::None; | 1428 return GenerateCharacter::None; |
1429 } | 1429 } |
1430 | 1430 |
1431 FX_BOOL CPDF_TextPage::IsSameTextObject(CPDF_TextObject* pTextObj1, | 1431 bool CPDF_TextPage::IsSameTextObject(CPDF_TextObject* pTextObj1, |
1432 CPDF_TextObject* pTextObj2) { | 1432 CPDF_TextObject* pTextObj2) { |
1433 if (!pTextObj1 || !pTextObj2) | 1433 if (!pTextObj1 || !pTextObj2) |
1434 return FALSE; | 1434 return false; |
1435 CFX_FloatRect rcPreObj(pTextObj2->m_Left, pTextObj2->m_Bottom, | 1435 CFX_FloatRect rcPreObj(pTextObj2->m_Left, pTextObj2->m_Bottom, |
1436 pTextObj2->m_Right, pTextObj2->m_Top); | 1436 pTextObj2->m_Right, pTextObj2->m_Top); |
1437 CFX_FloatRect rcCurObj(pTextObj1->m_Left, pTextObj1->m_Bottom, | 1437 CFX_FloatRect rcCurObj(pTextObj1->m_Left, pTextObj1->m_Bottom, |
1438 pTextObj1->m_Right, pTextObj1->m_Top); | 1438 pTextObj1->m_Right, pTextObj1->m_Top); |
1439 if (rcPreObj.IsEmpty() && rcCurObj.IsEmpty()) { | 1439 if (rcPreObj.IsEmpty() && rcCurObj.IsEmpty()) { |
1440 FX_FLOAT dbXdif = FXSYS_fabs(rcPreObj.left - rcCurObj.left); | 1440 FX_FLOAT dbXdif = FXSYS_fabs(rcPreObj.left - rcCurObj.left); |
1441 size_t nCount = m_CharList.size(); | 1441 size_t nCount = m_CharList.size(); |
1442 if (nCount >= 2) { | 1442 if (nCount >= 2) { |
1443 PAGECHAR_INFO perCharTemp = m_CharList[nCount - 2]; | 1443 PAGECHAR_INFO perCharTemp = m_CharList[nCount - 2]; |
1444 FX_FLOAT dbSpace = perCharTemp.m_CharBox.Width(); | 1444 FX_FLOAT dbSpace = perCharTemp.m_CharBox.Width(); |
1445 if (dbXdif > dbSpace) | 1445 if (dbXdif > dbSpace) |
1446 return FALSE; | 1446 return false; |
1447 } | 1447 } |
1448 } | 1448 } |
1449 if (!rcPreObj.IsEmpty() || !rcCurObj.IsEmpty()) { | 1449 if (!rcPreObj.IsEmpty() || !rcCurObj.IsEmpty()) { |
1450 rcPreObj.Intersect(rcCurObj); | 1450 rcPreObj.Intersect(rcCurObj); |
1451 if (rcPreObj.IsEmpty()) | 1451 if (rcPreObj.IsEmpty()) |
1452 return FALSE; | 1452 return false; |
1453 if (FXSYS_fabs(rcPreObj.Width() - rcCurObj.Width()) > | 1453 if (FXSYS_fabs(rcPreObj.Width() - rcCurObj.Width()) > |
1454 rcCurObj.Width() / 2) { | 1454 rcCurObj.Width() / 2) { |
1455 return FALSE; | 1455 return false; |
1456 } | 1456 } |
1457 if (pTextObj2->GetFontSize() != pTextObj1->GetFontSize()) | 1457 if (pTextObj2->GetFontSize() != pTextObj1->GetFontSize()) |
1458 return FALSE; | 1458 return false; |
1459 } | 1459 } |
1460 int nPreCount = pTextObj2->CountItems(); | 1460 int nPreCount = pTextObj2->CountItems(); |
1461 int nCurCount = pTextObj1->CountItems(); | 1461 int nCurCount = pTextObj1->CountItems(); |
1462 if (nPreCount != nCurCount) | 1462 if (nPreCount != nCurCount) |
1463 return FALSE; | 1463 return false; |
1464 // If both objects have no items, consider them same. | 1464 // If both objects have no items, consider them same. |
1465 if (!nPreCount) | 1465 if (!nPreCount) |
1466 return TRUE; | 1466 return true; |
1467 | 1467 |
1468 CPDF_TextObjectItem itemPer = {0, 0.0f, 0.0f}; | 1468 CPDF_TextObjectItem itemPer = {0, 0.0f, 0.0f}; |
1469 CPDF_TextObjectItem itemCur = {0, 0.0f, 0.0f}; | 1469 CPDF_TextObjectItem itemCur = {0, 0.0f, 0.0f}; |
1470 for (int i = 0; i < nPreCount; i++) { | 1470 for (int i = 0; i < nPreCount; i++) { |
1471 pTextObj2->GetItemInfo(i, &itemPer); | 1471 pTextObj2->GetItemInfo(i, &itemPer); |
1472 pTextObj1->GetItemInfo(i, &itemCur); | 1472 pTextObj1->GetItemInfo(i, &itemCur); |
1473 if (itemCur.m_CharCode != itemPer.m_CharCode) | 1473 if (itemCur.m_CharCode != itemPer.m_CharCode) |
1474 return FALSE; | 1474 return false; |
1475 } | 1475 } |
1476 if (FXSYS_fabs(pTextObj1->GetPosX() - pTextObj2->GetPosX()) > | 1476 if (FXSYS_fabs(pTextObj1->GetPosX() - pTextObj2->GetPosX()) > |
1477 GetCharWidth(itemPer.m_CharCode, pTextObj2->GetFont()) * | 1477 GetCharWidth(itemPer.m_CharCode, pTextObj2->GetFont()) * |
1478 pTextObj2->GetFontSize() / 1000 * 0.9 || | 1478 pTextObj2->GetFontSize() / 1000 * 0.9 || |
1479 FXSYS_fabs(pTextObj1->GetPosY() - pTextObj2->GetPosY()) > | 1479 FXSYS_fabs(pTextObj1->GetPosY() - pTextObj2->GetPosY()) > |
1480 std::max(std::max(rcPreObj.Height(), rcPreObj.Width()), | 1480 std::max(std::max(rcPreObj.Height(), rcPreObj.Width()), |
1481 pTextObj2->GetFontSize()) / | 1481 pTextObj2->GetFontSize()) / |
1482 8) { | 1482 8) { |
1483 return FALSE; | 1483 return false; |
1484 } | 1484 } |
1485 return TRUE; | 1485 return true; |
1486 } | 1486 } |
1487 | 1487 |
1488 FX_BOOL CPDF_TextPage::IsSameAsPreTextObject( | 1488 bool CPDF_TextPage::IsSameAsPreTextObject( |
1489 CPDF_TextObject* pTextObj, | 1489 CPDF_TextObject* pTextObj, |
1490 const CPDF_PageObjectList* pObjList, | 1490 const CPDF_PageObjectList* pObjList, |
1491 CPDF_PageObjectList::const_iterator iter) { | 1491 CPDF_PageObjectList::const_iterator iter) { |
1492 int i = 0; | 1492 int i = 0; |
1493 while (i < 5 && iter != pObjList->begin()) { | 1493 while (i < 5 && iter != pObjList->begin()) { |
1494 --iter; | 1494 --iter; |
1495 CPDF_PageObject* pOtherObj = iter->get(); | 1495 CPDF_PageObject* pOtherObj = iter->get(); |
1496 if (pOtherObj == pTextObj || !pOtherObj->IsText()) | 1496 if (pOtherObj == pTextObj || !pOtherObj->IsText()) |
1497 continue; | 1497 continue; |
1498 if (IsSameTextObject(pOtherObj->AsText(), pTextObj)) | 1498 if (IsSameTextObject(pOtherObj->AsText(), pTextObj)) |
1499 return TRUE; | 1499 return true; |
1500 ++i; | 1500 ++i; |
1501 } | 1501 } |
1502 return FALSE; | 1502 return false; |
1503 } | 1503 } |
1504 | 1504 |
1505 FX_BOOL CPDF_TextPage::GenerateCharInfo(FX_WCHAR unicode, PAGECHAR_INFO& info) { | 1505 bool CPDF_TextPage::GenerateCharInfo(FX_WCHAR unicode, PAGECHAR_INFO& info) { |
1506 const PAGECHAR_INFO* preChar; | 1506 const PAGECHAR_INFO* preChar; |
1507 if (!m_TempCharList.empty()) | 1507 if (!m_TempCharList.empty()) |
1508 preChar = &m_TempCharList.back(); | 1508 preChar = &m_TempCharList.back(); |
1509 else if (!m_CharList.empty()) | 1509 else if (!m_CharList.empty()) |
1510 preChar = &m_CharList.back(); | 1510 preChar = &m_CharList.back(); |
1511 else | 1511 else |
1512 return FALSE; | 1512 return false; |
1513 info.m_Index = m_TextBuf.GetLength(); | 1513 info.m_Index = m_TextBuf.GetLength(); |
1514 info.m_Unicode = unicode; | 1514 info.m_Unicode = unicode; |
1515 info.m_pTextObj = nullptr; | 1515 info.m_pTextObj = nullptr; |
1516 info.m_CharCode = CPDF_Font::kInvalidCharCode; | 1516 info.m_CharCode = CPDF_Font::kInvalidCharCode; |
1517 info.m_Flag = FPDFTEXT_CHAR_GENERATED; | 1517 info.m_Flag = FPDFTEXT_CHAR_GENERATED; |
1518 int preWidth = 0; | 1518 int preWidth = 0; |
1519 if (preChar->m_pTextObj && preChar->m_CharCode != -1) { | 1519 if (preChar->m_pTextObj && preChar->m_CharCode != -1) { |
1520 preWidth = | 1520 preWidth = |
1521 GetCharWidth(preChar->m_CharCode, preChar->m_pTextObj->GetFont()); | 1521 GetCharWidth(preChar->m_CharCode, preChar->m_pTextObj->GetFont()); |
1522 } | 1522 } |
1523 | 1523 |
1524 FX_FLOAT fFontSize = preChar->m_pTextObj ? preChar->m_pTextObj->GetFontSize() | 1524 FX_FLOAT fFontSize = preChar->m_pTextObj ? preChar->m_pTextObj->GetFontSize() |
1525 : preChar->m_CharBox.Height(); | 1525 : preChar->m_CharBox.Height(); |
1526 if (!fFontSize) | 1526 if (!fFontSize) |
1527 fFontSize = kDefaultFontSize; | 1527 fFontSize = kDefaultFontSize; |
1528 | 1528 |
1529 info.m_OriginX = preChar->m_OriginX + preWidth * (fFontSize) / 1000; | 1529 info.m_OriginX = preChar->m_OriginX + preWidth * (fFontSize) / 1000; |
1530 info.m_OriginY = preChar->m_OriginY; | 1530 info.m_OriginY = preChar->m_OriginY; |
1531 info.m_CharBox = CFX_FloatRect(info.m_OriginX, info.m_OriginY, info.m_OriginX, | 1531 info.m_CharBox = CFX_FloatRect(info.m_OriginX, info.m_OriginY, info.m_OriginX, |
1532 info.m_OriginY); | 1532 info.m_OriginY); |
1533 return TRUE; | 1533 return true; |
1534 } | 1534 } |
1535 | 1535 |
1536 FX_BOOL CPDF_TextPage::IsRectIntersect(const CFX_FloatRect& rect1, | 1536 bool CPDF_TextPage::IsRectIntersect(const CFX_FloatRect& rect1, |
1537 const CFX_FloatRect& rect2) { | 1537 const CFX_FloatRect& rect2) { |
1538 CFX_FloatRect rect = rect1; | 1538 CFX_FloatRect rect = rect1; |
1539 rect.Intersect(rect2); | 1539 rect.Intersect(rect2); |
1540 return !rect.IsEmpty(); | 1540 return !rect.IsEmpty(); |
1541 } | 1541 } |
OLD | NEW |