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 "../../include/fpdfapi/fpdf_resource.h" | 7 #include "../../include/fpdfapi/fpdf_resource.h" |
8 #include "../../include/fpdfapi/fpdf_pageobj.h" | 8 #include "../../include/fpdfapi/fpdf_pageobj.h" |
9 #include "../../include/fpdftext/fpdf_text.h" | 9 #include "../../include/fpdftext/fpdf_text.h" |
10 #include "../../include/fpdfapi/fpdf_page.h" | 10 #include "../../include/fpdfapi/fpdf_page.h" |
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 info.m_Unicode = charinfo.m_Unicode; | 645 info.m_Unicode = charinfo.m_Unicode; |
646 info.m_Flag = charinfo.m_Flag; | 646 info.m_Flag = charinfo.m_Flag; |
647 info.m_CharBox = charinfo.m_CharBox; | 647 info.m_CharBox = charinfo.m_CharBox; |
648 info.m_pTextObj = charinfo.m_pTextObj; | 648 info.m_pTextObj = charinfo.m_pTextObj; |
649 if (charinfo.m_pTextObj && charinfo.m_pTextObj->GetFont()) { | 649 if (charinfo.m_pTextObj && charinfo.m_pTextObj->GetFont()) { |
650 info.m_FontSize = charinfo.m_pTextObj->GetFontSize(); | 650 info.m_FontSize = charinfo.m_pTextObj->GetFontSize(); |
651 } | 651 } |
652 info.m_Matrix.Copy(charinfo.m_Matrix); | 652 info.m_Matrix.Copy(charinfo.m_Matrix); |
653 return; | 653 return; |
654 } | 654 } |
655 void CPDF_TextPage::CheckMarkedContentObject(FX_INT32& start, FX_INT32& nCount)
const | 655 void CPDF_TextPage::CheckMarkedContentObject(int32_t& start, int32_t& nCount) co
nst |
656 { | 656 { |
657 PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(start); | 657 PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(start); |
658 PAGECHAR_INFO charinfo2 = *(PAGECHAR_INFO*)m_charList.GetAt(start + nCount -
1); | 658 PAGECHAR_INFO charinfo2 = *(PAGECHAR_INFO*)m_charList.GetAt(start + nCount -
1); |
659 if (FPDFTEXT_CHAR_PIECE != charinfo.m_Flag && FPDFTEXT_CHAR_PIECE != charinf
o2.m_Flag) { | 659 if (FPDFTEXT_CHAR_PIECE != charinfo.m_Flag && FPDFTEXT_CHAR_PIECE != charinf
o2.m_Flag) { |
660 return; | 660 return; |
661 } | 661 } |
662 if (FPDFTEXT_CHAR_PIECE == charinfo.m_Flag) { | 662 if (FPDFTEXT_CHAR_PIECE == charinfo.m_Flag) { |
663 PAGECHAR_INFO charinfo1 = charinfo; | 663 PAGECHAR_INFO charinfo1 = charinfo; |
664 int startIndex = start; | 664 int startIndex = start; |
665 while(FPDFTEXT_CHAR_PIECE == charinfo1.m_Flag && charinfo1.m_Index == ch
arinfo.m_Index) { | 665 while(FPDFTEXT_CHAR_PIECE == charinfo1.m_Flag && charinfo1.m_Index == ch
arinfo.m_Index) { |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
956 while (++breakPos < m_charList.GetSize()) { | 956 while (++breakPos < m_charList.GetSize()) { |
957 charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(breakPos); | 957 charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(breakPos); |
958 if (!IsLetter(charinfo.m_Unicode)) { | 958 if (!IsLetter(charinfo.m_Unicode)) { |
959 return breakPos; | 959 return breakPos; |
960 } | 960 } |
961 } | 961 } |
962 return breakPos; | 962 return breakPos; |
963 } | 963 } |
964 return breakPos; | 964 return breakPos; |
965 } | 965 } |
966 FX_INT32 CPDF_TextPage::FindTextlineFlowDirection() | 966 int32_t CPDF_TextPage::FindTextlineFlowDirection() |
967 { | 967 { |
968 if (!m_pPage) { | 968 if (!m_pPage) { |
969 return -1; | 969 return -1; |
970 } | 970 } |
971 const FX_INT32 nPageWidth = (FX_INT32)((CPDF_Page*)m_pPage)->GetPageWidth(); | 971 const int32_t nPageWidth = (int32_t)((CPDF_Page*)m_pPage)->GetPageWidth(); |
972 const FX_INT32 nPageHeight = (FX_INT32)((CPDF_Page*)m_pPage)->GetPageHeight(
); | 972 const int32_t nPageHeight = (int32_t)((CPDF_Page*)m_pPage)->GetPageHeight(); |
973 CFX_ByteArray nHorizontalMask; | 973 CFX_ByteArray nHorizontalMask; |
974 if (!nHorizontalMask.SetSize(nPageWidth)) { | 974 if (!nHorizontalMask.SetSize(nPageWidth)) { |
975 return -1; | 975 return -1; |
976 } | 976 } |
977 FX_BYTE* pDataH = nHorizontalMask.GetData(); | 977 uint8_t* pDataH = nHorizontalMask.GetData(); |
978 CFX_ByteArray nVerticalMask; | 978 CFX_ByteArray nVerticalMask; |
979 if (!nVerticalMask.SetSize(nPageHeight)) { | 979 if (!nVerticalMask.SetSize(nPageHeight)) { |
980 return -1; | 980 return -1; |
981 } | 981 } |
982 FX_BYTE* pDataV = nVerticalMask.GetData(); | 982 uint8_t* pDataV = nVerticalMask.GetData(); |
983 FX_INT32 index = 0; | 983 int32_t index = 0; |
984 FX_FLOAT fLineHeight = 0.0f; | 984 FX_FLOAT fLineHeight = 0.0f; |
985 CPDF_PageObject* pPageObj = NULL; | 985 CPDF_PageObject* pPageObj = NULL; |
986 FX_POSITION pos = NULL; | 986 FX_POSITION pos = NULL; |
987 pos = m_pPage->GetFirstObjectPosition(); | 987 pos = m_pPage->GetFirstObjectPosition(); |
988 if(!pos) { | 988 if(!pos) { |
989 return -1; | 989 return -1; |
990 } | 990 } |
991 while(pos) { | 991 while(pos) { |
992 pPageObj = m_pPage->GetNextObject(pos); | 992 pPageObj = m_pPage->GetNextObject(pos); |
993 if(NULL == pPageObj) { | 993 if(NULL == pPageObj) { |
994 continue; | 994 continue; |
995 } | 995 } |
996 if(PDFPAGE_TEXT != pPageObj->m_Type) { | 996 if(PDFPAGE_TEXT != pPageObj->m_Type) { |
997 continue; | 997 continue; |
998 } | 998 } |
999 FX_INT32 minH = (FX_INT32)pPageObj->m_Left < 0 ? 0 : (FX_INT32)pPageObj-
>m_Left; | 999 int32_t minH = (int32_t)pPageObj->m_Left < 0 ? 0 : (int32_t)pPageObj->m_
Left; |
1000 FX_INT32 maxH = (FX_INT32)pPageObj->m_Right > nPageWidth ? nPageWidth :
(FX_INT32)pPageObj->m_Right; | 1000 int32_t maxH = (int32_t)pPageObj->m_Right > nPageWidth ? nPageWidth : (i
nt32_t)pPageObj->m_Right; |
1001 FX_INT32 minV = (FX_INT32)pPageObj->m_Bottom < 0 ? 0 : (FX_INT32)pPageOb
j->m_Bottom; | 1001 int32_t minV = (int32_t)pPageObj->m_Bottom < 0 ? 0 : (int32_t)pPageObj->
m_Bottom; |
1002 FX_INT32 maxV = (FX_INT32)pPageObj->m_Top > nPageHeight ? nPageHeight :
(FX_INT32)pPageObj->m_Top; | 1002 int32_t maxV = (int32_t)pPageObj->m_Top > nPageHeight ? nPageHeight : (i
nt32_t)pPageObj->m_Top; |
1003 if (minH >= maxH || minV >= maxV) { | 1003 if (minH >= maxH || minV >= maxV) { |
1004 continue; | 1004 continue; |
1005 } | 1005 } |
1006 FXSYS_memset8(pDataH + minH, 1, maxH - minH); | 1006 FXSYS_memset8(pDataH + minH, 1, maxH - minH); |
1007 FXSYS_memset8(pDataV + minV, 1, maxV - minV); | 1007 FXSYS_memset8(pDataV + minV, 1, maxV - minV); |
1008 if (fLineHeight <= 0.0f) { | 1008 if (fLineHeight <= 0.0f) { |
1009 fLineHeight = pPageObj->m_Top - pPageObj->m_Bottom; | 1009 fLineHeight = pPageObj->m_Top - pPageObj->m_Bottom; |
1010 } | 1010 } |
1011 pPageObj = NULL; | 1011 pPageObj = NULL; |
1012 } | 1012 } |
1013 FX_INT32 nStartH = 0; | 1013 int32_t nStartH = 0; |
1014 FX_INT32 nEndH = 0; | 1014 int32_t nEndH = 0; |
1015 FX_FLOAT nSumH = 0.0f; | 1015 FX_FLOAT nSumH = 0.0f; |
1016 for (index = 0; index < nPageWidth; index++) | 1016 for (index = 0; index < nPageWidth; index++) |
1017 if(1 == nHorizontalMask[index]) { | 1017 if(1 == nHorizontalMask[index]) { |
1018 break; | 1018 break; |
1019 } | 1019 } |
1020 nStartH = index; | 1020 nStartH = index; |
1021 for (index = nPageWidth; index > 0; index--) | 1021 for (index = nPageWidth; index > 0; index--) |
1022 if(1 == nHorizontalMask[index - 1]) { | 1022 if(1 == nHorizontalMask[index - 1]) { |
1023 break; | 1023 break; |
1024 } | 1024 } |
1025 nEndH = index; | 1025 nEndH = index; |
1026 for (index = nStartH; index < nEndH; index++) { | 1026 for (index = nStartH; index < nEndH; index++) { |
1027 nSumH += nHorizontalMask[index]; | 1027 nSumH += nHorizontalMask[index]; |
1028 } | 1028 } |
1029 nSumH /= nEndH - nStartH; | 1029 nSumH /= nEndH - nStartH; |
1030 FX_INT32 nStartV = 0; | 1030 int32_t nStartV = 0; |
1031 FX_INT32 nEndV = 0; | 1031 int32_t nEndV = 0; |
1032 FX_FLOAT nSumV = 0.0f; | 1032 FX_FLOAT nSumV = 0.0f; |
1033 for (index = 0; index < nPageHeight; index++) | 1033 for (index = 0; index < nPageHeight; index++) |
1034 if(1 == nVerticalMask[index]) { | 1034 if(1 == nVerticalMask[index]) { |
1035 break; | 1035 break; |
1036 } | 1036 } |
1037 nStartV = index; | 1037 nStartV = index; |
1038 for (index = nPageHeight; index > 0; index--) | 1038 for (index = nPageHeight; index > 0; index--) |
1039 if(1 == nVerticalMask[index - 1]) { | 1039 if(1 == nVerticalMask[index - 1]) { |
1040 break; | 1040 break; |
1041 } | 1041 } |
1042 nEndV = index; | 1042 nEndV = index; |
1043 for (index = nStartV; index < nEndV; index++) { | 1043 for (index = nStartV; index < nEndV; index++) { |
1044 nSumV += nVerticalMask[index]; | 1044 nSumV += nVerticalMask[index]; |
1045 } | 1045 } |
1046 nSumV /= nEndV - nStartV; | 1046 nSumV /= nEndV - nStartV; |
1047 if ((nEndV - nStartV) < (FX_INT32)(2 * fLineHeight)) { | 1047 if ((nEndV - nStartV) < (int32_t)(2 * fLineHeight)) { |
1048 return 0; | 1048 return 0; |
1049 } | 1049 } |
1050 if ((nEndH - nStartH) < (FX_INT32)(2 * fLineHeight)) { | 1050 if ((nEndH - nStartH) < (int32_t)(2 * fLineHeight)) { |
1051 return 1; | 1051 return 1; |
1052 } | 1052 } |
1053 if (nSumH > 0.8f) { | 1053 if (nSumH > 0.8f) { |
1054 return 0; | 1054 return 0; |
1055 } | 1055 } |
1056 if (nSumH - nSumV > 0.0f) { | 1056 if (nSumH - nSumV > 0.0f) { |
1057 return 0; | 1057 return 0; |
1058 } | 1058 } |
1059 if (nSumV - nSumH > 0.0f) { | 1059 if (nSumV - nSumH > 0.0f) { |
1060 return 1; | 1060 return 1; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1134 if(w == 0) { | 1134 if(w == 0) { |
1135 FX_RECT BBox; | 1135 FX_RECT BBox; |
1136 pFont->GetCharBBox(charCode, BBox); | 1136 pFont->GetCharBBox(charCode, BBox); |
1137 w = BBox.right - BBox.left; | 1137 w = BBox.right - BBox.left; |
1138 } | 1138 } |
1139 } | 1139 } |
1140 return w; | 1140 return w; |
1141 } | 1141 } |
1142 void CPDF_TextPage::OnPiece(IFX_BidiChar* pBidi, CFX_WideString& str) | 1142 void CPDF_TextPage::OnPiece(IFX_BidiChar* pBidi, CFX_WideString& str) |
1143 { | 1143 { |
1144 FX_INT32 start, count; | 1144 int32_t start, count; |
1145 FX_INT32 ret = pBidi->GetBidiInfo(start, count); | 1145 int32_t ret = pBidi->GetBidiInfo(start, count); |
1146 if(ret == 2) { | 1146 if(ret == 2) { |
1147 for(int i = start + count - 1; i >= start; i--) { | 1147 for(int i = start + count - 1; i >= start; i--) { |
1148 m_TextBuf.AppendChar(str.GetAt(i)); | 1148 m_TextBuf.AppendChar(str.GetAt(i)); |
1149 m_charList.Add(*(PAGECHAR_INFO*)m_TempCharList.GetAt(i)); | 1149 m_charList.Add(*(PAGECHAR_INFO*)m_TempCharList.GetAt(i)); |
1150 } | 1150 } |
1151 } else { | 1151 } else { |
1152 int end = start + count ; | 1152 int end = start + count ; |
1153 for(int i = start; i < end; i++) { | 1153 for(int i = start; i < end; i++) { |
1154 m_TextBuf.AppendChar(str.GetAt(i)); | 1154 m_TextBuf.AppendChar(str.GetAt(i)); |
1155 m_charList.Add(*(PAGECHAR_INFO*)m_TempCharList.GetAt(i)); | 1155 m_charList.Add(*(PAGECHAR_INFO*)m_TempCharList.GetAt(i)); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1225 void CPDF_TextPage::CloseTempLine() | 1225 void CPDF_TextPage::CloseTempLine() |
1226 { | 1226 { |
1227 int count1 = m_TempCharList.GetSize(); | 1227 int count1 = m_TempCharList.GetSize(); |
1228 if (count1 <= 0) { | 1228 if (count1 <= 0) { |
1229 return; | 1229 return; |
1230 } | 1230 } |
1231 IFX_BidiChar* BidiChar = IFX_BidiChar::Create(); | 1231 IFX_BidiChar* BidiChar = IFX_BidiChar::Create(); |
1232 CFX_WideString str = m_TempTextBuf.GetWideString(); | 1232 CFX_WideString str = m_TempTextBuf.GetWideString(); |
1233 CFX_WordArray order; | 1233 CFX_WordArray order; |
1234 FX_BOOL bR2L = FALSE; | 1234 FX_BOOL bR2L = FALSE; |
1235 FX_INT32 start = 0, count = 0; | 1235 int32_t start = 0, count = 0; |
1236 int nR2L = 0, nL2R = 0; | 1236 int nR2L = 0, nL2R = 0; |
1237 FX_BOOL bPrevSpace = FALSE; | 1237 FX_BOOL bPrevSpace = FALSE; |
1238 for (int i = 0; i < str.GetLength(); i++) { | 1238 for (int i = 0; i < str.GetLength(); i++) { |
1239 if(str.GetAt(i) == 32) { | 1239 if(str.GetAt(i) == 32) { |
1240 if(bPrevSpace) { | 1240 if(bPrevSpace) { |
1241 m_TempTextBuf.Delete(i, 1); | 1241 m_TempTextBuf.Delete(i, 1); |
1242 m_TempCharList.Delete(i); | 1242 m_TempCharList.Delete(i); |
1243 str.Delete(i); | 1243 str.Delete(i); |
1244 count1--; | 1244 count1--; |
1245 i--; | 1245 i--; |
1246 continue; | 1246 continue; |
1247 } | 1247 } |
1248 bPrevSpace = TRUE; | 1248 bPrevSpace = TRUE; |
1249 } else { | 1249 } else { |
1250 bPrevSpace = FALSE; | 1250 bPrevSpace = FALSE; |
1251 } | 1251 } |
1252 if(BidiChar && BidiChar->AppendChar(str.GetAt(i))) { | 1252 if(BidiChar && BidiChar->AppendChar(str.GetAt(i))) { |
1253 FX_INT32 ret = BidiChar->GetBidiInfo(start, count); | 1253 int32_t ret = BidiChar->GetBidiInfo(start, count); |
1254 order.Add(start); | 1254 order.Add(start); |
1255 order.Add(count); | 1255 order.Add(count); |
1256 order.Add(ret); | 1256 order.Add(ret); |
1257 if(!bR2L) { | 1257 if(!bR2L) { |
1258 if(ret == 2) { | 1258 if(ret == 2) { |
1259 nR2L++; | 1259 nR2L++; |
1260 } else if (ret == 1) { | 1260 } else if (ret == 1) { |
1261 nL2R++; | 1261 nL2R++; |
1262 } | 1262 } |
1263 } | 1263 } |
1264 } | 1264 } |
1265 } | 1265 } |
1266 if(BidiChar && BidiChar->EndChar()) { | 1266 if(BidiChar && BidiChar->EndChar()) { |
1267 FX_INT32 ret = BidiChar->GetBidiInfo(start, count); | 1267 int32_t ret = BidiChar->GetBidiInfo(start, count); |
1268 order.Add(start); | 1268 order.Add(start); |
1269 order.Add(count); | 1269 order.Add(count); |
1270 order.Add(ret); | 1270 order.Add(ret); |
1271 if(!bR2L) { | 1271 if(!bR2L) { |
1272 if(ret == 2) { | 1272 if(ret == 2) { |
1273 nR2L++; | 1273 nR2L++; |
1274 } else if(ret == 1) { | 1274 } else if(ret == 1) { |
1275 nL2R++; | 1275 nL2R++; |
1276 } | 1276 } |
1277 } | 1277 } |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1431 break; | 1431 break; |
1432 } | 1432 } |
1433 } | 1433 } |
1434 if(i < 0) { | 1434 if(i < 0) { |
1435 m_LineObj.InsertAt(0, Obj); | 1435 m_LineObj.InsertAt(0, Obj); |
1436 } | 1436 } |
1437 } else { | 1437 } else { |
1438 m_LineObj.Add(Obj); | 1438 m_LineObj.Add(Obj); |
1439 } | 1439 } |
1440 } | 1440 } |
1441 FX_INT32 CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) | 1441 int32_t CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) |
1442 { | 1442 { |
1443 CPDF_TextObject* pTextObj = Obj.m_pTextObj; | 1443 CPDF_TextObject* pTextObj = Obj.m_pTextObj; |
1444 CPDF_ContentMarkData* pMarkData = (CPDF_ContentMarkData*)pTextObj->m_Content
Mark.GetObject(); | 1444 CPDF_ContentMarkData* pMarkData = (CPDF_ContentMarkData*)pTextObj->m_Content
Mark.GetObject(); |
1445 if(!pMarkData) { | 1445 if(!pMarkData) { |
1446 return FPDFTEXT_MC_PASS; | 1446 return FPDFTEXT_MC_PASS; |
1447 } | 1447 } |
1448 int nContentMark = pMarkData->CountItems(); | 1448 int nContentMark = pMarkData->CountItems(); |
1449 if (nContentMark < 1) { | 1449 if (nContentMark < 1) { |
1450 return FPDFTEXT_MC_PASS; | 1450 return FPDFTEXT_MC_PASS; |
1451 } | 1451 } |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1591 { | 1591 { |
1592 CPDF_TextObject* pTextObj = Obj.m_pTextObj; | 1592 CPDF_TextObject* pTextObj = Obj.m_pTextObj; |
1593 if(FXSYS_fabs(pTextObj->m_Right - pTextObj->m_Left) < 0.01f ) { | 1593 if(FXSYS_fabs(pTextObj->m_Right - pTextObj->m_Left) < 0.01f ) { |
1594 return; | 1594 return; |
1595 } | 1595 } |
1596 CFX_AffineMatrix formMatrix = Obj.m_formMatrix; | 1596 CFX_AffineMatrix formMatrix = Obj.m_formMatrix; |
1597 CPDF_Font* pFont = pTextObj->GetFont(); | 1597 CPDF_Font* pFont = pTextObj->GetFont(); |
1598 CFX_AffineMatrix matrix; | 1598 CFX_AffineMatrix matrix; |
1599 pTextObj->GetTextMatrix(&matrix); | 1599 pTextObj->GetTextMatrix(&matrix); |
1600 matrix.Concat(formMatrix); | 1600 matrix.Concat(formMatrix); |
1601 FX_INT32 bPreMKC = PreMarkedContent(Obj); | 1601 int32_t bPreMKC = PreMarkedContent(Obj); |
1602 if (FPDFTEXT_MC_DONE == bPreMKC) { | 1602 if (FPDFTEXT_MC_DONE == bPreMKC) { |
1603 m_pPreTextObj = pTextObj; | 1603 m_pPreTextObj = pTextObj; |
1604 m_perMatrix.Copy(formMatrix); | 1604 m_perMatrix.Copy(formMatrix); |
1605 return; | 1605 return; |
1606 } | 1606 } |
1607 int result = 0; | 1607 int result = 0; |
1608 if (m_pPreTextObj) { | 1608 if (m_pPreTextObj) { |
1609 result = ProcessInsertObject(pTextObj, formMatrix); | 1609 result = ProcessInsertObject(pTextObj, formMatrix); |
1610 if (2 == result) { | 1610 if (2 == result) { |
1611 m_CurlineRect = CFX_FloatRect(Obj.m_pTextObj->m_Left, Obj.m_pTextObj
->m_Bottom, Obj.m_pTextObj->m_Right, Obj.m_pTextObj->m_Top); | 1611 m_CurlineRect = CFX_FloatRect(Obj.m_pTextObj->m_Left, Obj.m_pTextObj
->m_Bottom, Obj.m_pTextObj->m_Right, Obj.m_pTextObj->m_Top); |
(...skipping 26 matching lines...) Expand all Loading... |
1638 if(GenerateCharInfo(TEXT_LINEFEED_CHAR, generateChar)) { | 1638 if(GenerateCharInfo(TEXT_LINEFEED_CHAR, generateChar)) { |
1639 m_TextBuf.AppendChar(TEXT_LINEFEED_CHAR); | 1639 m_TextBuf.AppendChar(TEXT_LINEFEED_CHAR); |
1640 if (!formMatrix.IsIdentity()) { | 1640 if (!formMatrix.IsIdentity()) { |
1641 generateChar.m_Matrix.Copy(formMatrix); | 1641 generateChar.m_Matrix.Copy(formMatrix); |
1642 } | 1642 } |
1643 m_charList.Add(generateChar); | 1643 m_charList.Add(generateChar); |
1644 } | 1644 } |
1645 } | 1645 } |
1646 } | 1646 } |
1647 } else if (result == 3 && !m_ParseOptions.m_bOutputHyphen) { | 1647 } else if (result == 3 && !m_ParseOptions.m_bOutputHyphen) { |
1648 FX_INT32 nChars = pTextObj->CountChars(); | 1648 int32_t nChars = pTextObj->CountChars(); |
1649 if (nChars == 1) { | 1649 if (nChars == 1) { |
1650 CPDF_TextObjectItem item; | 1650 CPDF_TextObjectItem item; |
1651 pTextObj->GetCharInfo(0, &item); | 1651 pTextObj->GetCharInfo(0, &item); |
1652 CFX_WideString wstrItem = pTextObj->GetFont()->UnicodeFromCharCo
de(item.m_CharCode); | 1652 CFX_WideString wstrItem = pTextObj->GetFont()->UnicodeFromCharCo
de(item.m_CharCode); |
1653 if(wstrItem.IsEmpty()) { | 1653 if(wstrItem.IsEmpty()) { |
1654 wstrItem += (FX_WCHAR)item.m_CharCode; | 1654 wstrItem += (FX_WCHAR)item.m_CharCode; |
1655 } | 1655 } |
1656 FX_WCHAR curChar = wstrItem.GetAt(0); | 1656 FX_WCHAR curChar = wstrItem.GetAt(0); |
1657 if (0x2D == curChar || 0xAD == curChar) { | 1657 if (0x2D == curChar || 0xAD == curChar) { |
1658 return; | 1658 return; |
(...skipping 18 matching lines...) Expand all Loading... |
1677 m_perMatrix.Copy(formMatrix); | 1677 m_perMatrix.Copy(formMatrix); |
1678 return; | 1678 return; |
1679 } | 1679 } |
1680 m_pPreTextObj = pTextObj; | 1680 m_pPreTextObj = pTextObj; |
1681 m_perMatrix.Copy(formMatrix); | 1681 m_perMatrix.Copy(formMatrix); |
1682 int nItems = pTextObj->CountItems(); | 1682 int nItems = pTextObj->CountItems(); |
1683 FX_FLOAT baseSpace = _CalculateBaseSpace(pTextObj, matrix); | 1683 FX_FLOAT baseSpace = _CalculateBaseSpace(pTextObj, matrix); |
1684 | 1684 |
1685 FX_BOOL bIsBidiAndMirrosInverse = FALSE; | 1685 FX_BOOL bIsBidiAndMirrosInverse = FALSE; |
1686 IFX_BidiChar* BidiChar = IFX_BidiChar::Create(); | 1686 IFX_BidiChar* BidiChar = IFX_BidiChar::Create(); |
1687 FX_INT32 nR2L = 0; | 1687 int32_t nR2L = 0; |
1688 FX_INT32 nL2R = 0; | 1688 int32_t nL2R = 0; |
1689 FX_INT32 start = 0, count = 0; | 1689 int32_t start = 0, count = 0; |
1690 CPDF_TextObjectItem item; | 1690 CPDF_TextObjectItem item; |
1691 for (FX_INT32 i = 0; i < nItems; i++) { | 1691 for (int32_t i = 0; i < nItems; i++) { |
1692 pTextObj->GetItemInfo(i, &item); | 1692 pTextObj->GetItemInfo(i, &item); |
1693 if (item.m_CharCode == (FX_DWORD)-1) { | 1693 if (item.m_CharCode == (FX_DWORD)-1) { |
1694 continue; | 1694 continue; |
1695 } | 1695 } |
1696 CFX_WideString wstrItem = pFont->UnicodeFromCharCode(item.m_CharCode); | 1696 CFX_WideString wstrItem = pFont->UnicodeFromCharCode(item.m_CharCode); |
1697 FX_WCHAR wChar = wstrItem.GetAt(0); | 1697 FX_WCHAR wChar = wstrItem.GetAt(0); |
1698 if ((wstrItem.IsEmpty() || wChar == 0) && item.m_CharCode) { | 1698 if ((wstrItem.IsEmpty() || wChar == 0) && item.m_CharCode) { |
1699 wChar = (FX_WCHAR)item.m_CharCode; | 1699 wChar = (FX_WCHAR)item.m_CharCode; |
1700 } | 1700 } |
1701 if (!wChar) { | 1701 if (!wChar) { |
1702 continue; | 1702 continue; |
1703 } | 1703 } |
1704 if (BidiChar && BidiChar->AppendChar(wChar)) { | 1704 if (BidiChar && BidiChar->AppendChar(wChar)) { |
1705 FX_INT32 ret = BidiChar->GetBidiInfo(start, count); | 1705 int32_t ret = BidiChar->GetBidiInfo(start, count); |
1706 if (ret == 2) { | 1706 if (ret == 2) { |
1707 nR2L++; | 1707 nR2L++; |
1708 } | 1708 } |
1709 else if (ret == 1) { | 1709 else if (ret == 1) { |
1710 nL2R++; | 1710 nL2R++; |
1711 } | 1711 } |
1712 } | 1712 } |
1713 } | 1713 } |
1714 if (BidiChar && BidiChar->EndChar()) { | 1714 if (BidiChar && BidiChar->EndChar()) { |
1715 FX_INT32 ret = BidiChar->GetBidiInfo(start, count); | 1715 int32_t ret = BidiChar->GetBidiInfo(start, count); |
1716 if (ret == 2) { | 1716 if (ret == 2) { |
1717 nR2L++; | 1717 nR2L++; |
1718 } | 1718 } |
1719 else if (ret == 1) { | 1719 else if (ret == 1) { |
1720 nL2R++; | 1720 nL2R++; |
1721 } | 1721 } |
1722 } | 1722 } |
1723 FX_BOOL bR2L = FALSE; | 1723 FX_BOOL bR2L = FALSE; |
1724 if (nR2L > 0 && nR2L >= nL2R) { | 1724 if (nR2L > 0 && nR2L >= nL2R) { |
1725 bR2L = TRUE; | 1725 bR2L = TRUE; |
1726 } | 1726 } |
1727 bIsBidiAndMirrosInverse = bR2L && (matrix.a * matrix.d - matrix.b * matrix.c
) < 0; | 1727 bIsBidiAndMirrosInverse = bR2L && (matrix.a * matrix.d - matrix.b * matrix.c
) < 0; |
1728 FX_INT32 iBufStartAppend = m_TempTextBuf.GetLength(); | 1728 int32_t iBufStartAppend = m_TempTextBuf.GetLength(); |
1729 FX_INT32 iCharListStartAppend = m_TempCharList.GetSize(); | 1729 int32_t iCharListStartAppend = m_TempCharList.GetSize(); |
1730 | 1730 |
1731 FX_FLOAT spacing = 0; | 1731 FX_FLOAT spacing = 0; |
1732 for (int i = 0; i < nItems; i++) { | 1732 for (int i = 0; i < nItems; i++) { |
1733 CPDF_TextObjectItem item; | 1733 CPDF_TextObjectItem item; |
1734 PAGECHAR_INFO charinfo; | 1734 PAGECHAR_INFO charinfo; |
1735 charinfo.m_OriginX = 0; | 1735 charinfo.m_OriginX = 0; |
1736 charinfo.m_OriginY = 0; | 1736 charinfo.m_OriginY = 0; |
1737 pTextObj->GetItemInfo(i, &item); | 1737 pTextObj->GetItemInfo(i, &item); |
1738 if (item.m_CharCode == (FX_DWORD) - 1) { | 1738 if (item.m_CharCode == (FX_DWORD) - 1) { |
1739 CFX_WideString str = m_TempTextBuf.GetWideString(); | 1739 CFX_WideString str = m_TempTextBuf.GetWideString(); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1863 } else if(i == 0) { | 1863 } else if(i == 0) { |
1864 CFX_WideString str = m_TempTextBuf.GetWideString(); | 1864 CFX_WideString str = m_TempTextBuf.GetWideString(); |
1865 if (!str.IsEmpty() && str.GetAt(str.GetLength() - 1) == TEXT_BLA
NK_CHAR) { | 1865 if (!str.IsEmpty() && str.GetAt(str.GetLength() - 1) == TEXT_BLA
NK_CHAR) { |
1866 m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1); | 1866 m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1); |
1867 m_TempCharList.Delete(m_TempCharList.GetSize() - 1); | 1867 m_TempCharList.Delete(m_TempCharList.GetSize() - 1); |
1868 } | 1868 } |
1869 } | 1869 } |
1870 } | 1870 } |
1871 } | 1871 } |
1872 if (bIsBidiAndMirrosInverse) { | 1872 if (bIsBidiAndMirrosInverse) { |
1873 FX_INT32 i, j; | 1873 int32_t i, j; |
1874 i = iCharListStartAppend; | 1874 i = iCharListStartAppend; |
1875 j = m_TempCharList.GetSize() - 1; | 1875 j = m_TempCharList.GetSize() - 1; |
1876 for (; i < j; i++, j--) { | 1876 for (; i < j; i++, j--) { |
1877 std::swap(m_TempCharList[i], m_TempCharList[j]); | 1877 std::swap(m_TempCharList[i], m_TempCharList[j]); |
1878 std::swap(m_TempCharList[i].m_Index, m_TempCharList[j].m_Index); | 1878 std::swap(m_TempCharList[i].m_Index, m_TempCharList[j].m_Index); |
1879 } | 1879 } |
1880 FX_WCHAR * pTempBuffer = m_TempTextBuf.GetBuffer(); | 1880 FX_WCHAR * pTempBuffer = m_TempTextBuf.GetBuffer(); |
1881 i = iBufStartAppend; | 1881 i = iBufStartAppend; |
1882 j = m_TempTextBuf.GetLength() - 1; | 1882 j = m_TempTextBuf.GetLength() - 1; |
1883 for (; i < j; i++, j--) { | 1883 for (; i < j; i++, j--) { |
1884 std::swap(pTempBuffer[i], pTempBuffer[j]); | 1884 std::swap(pTempBuffer[i], pTempBuffer[j]); |
1885 } | 1885 } |
1886 } | 1886 } |
1887 } | 1887 } |
1888 FX_INT32 CPDF_TextPage::GetTextObjectWritingMode(const CPDF_TextObject* pTextObj
) | 1888 int32_t CPDF_TextPage::GetTextObjectWritingMode(const CPDF_TextObject* pTextObj) |
1889 { | 1889 { |
1890 FX_INT32 nChars = pTextObj->CountChars(); | 1890 int32_t nChars = pTextObj->CountChars(); |
1891 if (nChars == 1) { | 1891 if (nChars == 1) { |
1892 return m_TextlineDir; | 1892 return m_TextlineDir; |
1893 } | 1893 } |
1894 CPDF_TextObjectItem first, last; | 1894 CPDF_TextObjectItem first, last; |
1895 pTextObj->GetCharInfo(0, &first); | 1895 pTextObj->GetCharInfo(0, &first); |
1896 pTextObj->GetCharInfo(nChars - 1, &last); | 1896 pTextObj->GetCharInfo(nChars - 1, &last); |
1897 CFX_Matrix textMatrix; | 1897 CFX_Matrix textMatrix; |
1898 pTextObj->GetTextMatrix(&textMatrix); | 1898 pTextObj->GetTextMatrix(&textMatrix); |
1899 textMatrix.TransformPoint(first.m_OriginX, first.m_OriginY); | 1899 textMatrix.TransformPoint(first.m_OriginX, first.m_OriginY); |
1900 textMatrix.TransformPoint(last.m_OriginX, last.m_OriginY); | 1900 textMatrix.TransformPoint(last.m_OriginX, last.m_OriginY); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2044 } | 2044 } |
2045 } | 2045 } |
2046 } | 2046 } |
2047 } | 2047 } |
2048 if(bNewline) { | 2048 if(bNewline) { |
2049 if(IsHyphen(curChar)) { | 2049 if(IsHyphen(curChar)) { |
2050 return 3; | 2050 return 3; |
2051 } | 2051 } |
2052 return 2; | 2052 return 2; |
2053 } | 2053 } |
2054 FX_INT32 nChars = pObj->CountChars(); | 2054 int32_t nChars = pObj->CountChars(); |
2055 if (nChars == 1 && ( 0x2D == curChar || 0xAD == curChar)) | 2055 if (nChars == 1 && ( 0x2D == curChar || 0xAD == curChar)) |
2056 if (IsHyphen(curChar)) { | 2056 if (IsHyphen(curChar)) { |
2057 return 3; | 2057 return 3; |
2058 } | 2058 } |
2059 CFX_WideString PrevStr = m_pPreTextObj->GetFont()->UnicodeFromCharCode(PrevI
tem.m_CharCode); | 2059 CFX_WideString PrevStr = m_pPreTextObj->GetFont()->UnicodeFromCharCode(PrevI
tem.m_CharCode); |
2060 FX_WCHAR preChar = PrevStr.GetAt(PrevStr.GetLength() - 1); | 2060 FX_WCHAR preChar = PrevStr.GetAt(PrevStr.GetLength() - 1); |
2061 CFX_AffineMatrix matrix; | 2061 CFX_AffineMatrix matrix; |
2062 pObj->GetTextMatrix(&matrix); | 2062 pObj->GetTextMatrix(&matrix); |
2063 matrix.Concat(formMatrix); | 2063 matrix.Concat(formMatrix); |
2064 threshold = (FX_FLOAT)(nLastWidth > nThisWidth ? nLastWidth : nThisWidth); | 2064 threshold = (FX_FLOAT)(nLastWidth > nThisWidth ? nLastWidth : nThisWidth); |
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2828 if (!m_IsParserd || index < 0 || index >= m_LinkList.GetSize()) { | 2828 if (!m_IsParserd || index < 0 || index >= m_LinkList.GetSize()) { |
2829 return; | 2829 return; |
2830 } | 2830 } |
2831 CPDF_LinkExt* link = NULL; | 2831 CPDF_LinkExt* link = NULL; |
2832 link = m_LinkList.GetAt(index); | 2832 link = m_LinkList.GetAt(index); |
2833 if (!link) { | 2833 if (!link) { |
2834 return ; | 2834 return ; |
2835 } | 2835 } |
2836 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); | 2836 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); |
2837 } | 2837 } |
OLD | NEW |