| 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 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 info.m_Unicode = charinfo.m_Unicode; | 642 info.m_Unicode = charinfo.m_Unicode; |
| 643 info.m_Flag = charinfo.m_Flag; | 643 info.m_Flag = charinfo.m_Flag; |
| 644 info.m_CharBox = charinfo.m_CharBox; | 644 info.m_CharBox = charinfo.m_CharBox; |
| 645 info.m_pTextObj = charinfo.m_pTextObj; | 645 info.m_pTextObj = charinfo.m_pTextObj; |
| 646 if (charinfo.m_pTextObj && charinfo.m_pTextObj->GetFont()) { | 646 if (charinfo.m_pTextObj && charinfo.m_pTextObj->GetFont()) { |
| 647 info.m_FontSize = charinfo.m_pTextObj->GetFontSize(); | 647 info.m_FontSize = charinfo.m_pTextObj->GetFontSize(); |
| 648 } | 648 } |
| 649 info.m_Matrix.Copy(charinfo.m_Matrix); | 649 info.m_Matrix.Copy(charinfo.m_Matrix); |
| 650 return; | 650 return; |
| 651 } | 651 } |
| 652 void CPDF_TextPage::CheckMarkedContentObject(FX_INT32& start, FX_INT32& nCount)
const | 652 void CPDF_TextPage::CheckMarkedContentObject(int32_t& start, int32_t& nCount) co
nst |
| 653 { | 653 { |
| 654 PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(start); | 654 PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(start); |
| 655 PAGECHAR_INFO charinfo2 = *(PAGECHAR_INFO*)m_charList.GetAt(start + nCount -
1); | 655 PAGECHAR_INFO charinfo2 = *(PAGECHAR_INFO*)m_charList.GetAt(start + nCount -
1); |
| 656 if (FPDFTEXT_CHAR_PIECE != charinfo.m_Flag && FPDFTEXT_CHAR_PIECE != charinf
o2.m_Flag) { | 656 if (FPDFTEXT_CHAR_PIECE != charinfo.m_Flag && FPDFTEXT_CHAR_PIECE != charinf
o2.m_Flag) { |
| 657 return; | 657 return; |
| 658 } | 658 } |
| 659 if (FPDFTEXT_CHAR_PIECE == charinfo.m_Flag) { | 659 if (FPDFTEXT_CHAR_PIECE == charinfo.m_Flag) { |
| 660 PAGECHAR_INFO charinfo1 = charinfo; | 660 PAGECHAR_INFO charinfo1 = charinfo; |
| 661 int startIndex = start; | 661 int startIndex = start; |
| 662 while(FPDFTEXT_CHAR_PIECE == charinfo1.m_Flag && charinfo1.m_Index == ch
arinfo.m_Index) { | 662 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... |
| 953 while (++breakPos < m_charList.GetSize()) { | 953 while (++breakPos < m_charList.GetSize()) { |
| 954 charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(breakPos); | 954 charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(breakPos); |
| 955 if (!IsLetter(charinfo.m_Unicode)) { | 955 if (!IsLetter(charinfo.m_Unicode)) { |
| 956 return breakPos; | 956 return breakPos; |
| 957 } | 957 } |
| 958 } | 958 } |
| 959 return breakPos; | 959 return breakPos; |
| 960 } | 960 } |
| 961 return breakPos; | 961 return breakPos; |
| 962 } | 962 } |
| 963 FX_INT32 CPDF_TextPage::FindTextlineFlowDirection() | 963 int32_t CPDF_TextPage::FindTextlineFlowDirection() |
| 964 { | 964 { |
| 965 if (!m_pPage) { | 965 if (!m_pPage) { |
| 966 return -1; | 966 return -1; |
| 967 } | 967 } |
| 968 const FX_INT32 nPageWidth = (FX_INT32)((CPDF_Page*)m_pPage)->GetPageWidth(); | 968 const int32_t nPageWidth = (int32_t)((CPDF_Page*)m_pPage)->GetPageWidth(); |
| 969 const FX_INT32 nPageHeight = (FX_INT32)((CPDF_Page*)m_pPage)->GetPageHeight(
); | 969 const int32_t nPageHeight = (int32_t)((CPDF_Page*)m_pPage)->GetPageHeight(); |
| 970 CFX_ByteArray nHorizontalMask; | 970 CFX_ByteArray nHorizontalMask; |
| 971 if (!nHorizontalMask.SetSize(nPageWidth)) { | 971 if (!nHorizontalMask.SetSize(nPageWidth)) { |
| 972 return -1; | 972 return -1; |
| 973 } | 973 } |
| 974 FX_BYTE* pDataH = nHorizontalMask.GetData(); | 974 uint8_t* pDataH = nHorizontalMask.GetData(); |
| 975 CFX_ByteArray nVerticalMask; | 975 CFX_ByteArray nVerticalMask; |
| 976 if (!nVerticalMask.SetSize(nPageHeight)) { | 976 if (!nVerticalMask.SetSize(nPageHeight)) { |
| 977 return -1; | 977 return -1; |
| 978 } | 978 } |
| 979 FX_BYTE* pDataV = nVerticalMask.GetData(); | 979 uint8_t* pDataV = nVerticalMask.GetData(); |
| 980 FX_INT32 index = 0; | 980 int32_t index = 0; |
| 981 FX_FLOAT fLineHeight = 0.0f; | 981 FX_FLOAT fLineHeight = 0.0f; |
| 982 CPDF_PageObject* pPageObj = NULL; | 982 CPDF_PageObject* pPageObj = NULL; |
| 983 FX_POSITION pos = NULL; | 983 FX_POSITION pos = NULL; |
| 984 pos = m_pPage->GetFirstObjectPosition(); | 984 pos = m_pPage->GetFirstObjectPosition(); |
| 985 if(!pos) { | 985 if(!pos) { |
| 986 return -1; | 986 return -1; |
| 987 } | 987 } |
| 988 while(pos) { | 988 while(pos) { |
| 989 pPageObj = m_pPage->GetNextObject(pos); | 989 pPageObj = m_pPage->GetNextObject(pos); |
| 990 if(NULL == pPageObj) { | 990 if(NULL == pPageObj) { |
| 991 continue; | 991 continue; |
| 992 } | 992 } |
| 993 if(PDFPAGE_TEXT != pPageObj->m_Type) { | 993 if(PDFPAGE_TEXT != pPageObj->m_Type) { |
| 994 continue; | 994 continue; |
| 995 } | 995 } |
| 996 FX_INT32 minH = (FX_INT32)pPageObj->m_Left < 0 ? 0 : (FX_INT32)pPageObj-
>m_Left; | 996 int32_t minH = (int32_t)pPageObj->m_Left < 0 ? 0 : (int32_t)pPageObj->m_
Left; |
| 997 FX_INT32 maxH = (FX_INT32)pPageObj->m_Right > nPageWidth ? nPageWidth :
(FX_INT32)pPageObj->m_Right; | 997 int32_t maxH = (int32_t)pPageObj->m_Right > nPageWidth ? nPageWidth : (i
nt32_t)pPageObj->m_Right; |
| 998 FX_INT32 minV = (FX_INT32)pPageObj->m_Bottom < 0 ? 0 : (FX_INT32)pPageOb
j->m_Bottom; | 998 int32_t minV = (int32_t)pPageObj->m_Bottom < 0 ? 0 : (int32_t)pPageObj->
m_Bottom; |
| 999 FX_INT32 maxV = (FX_INT32)pPageObj->m_Top > nPageHeight ? nPageHeight :
(FX_INT32)pPageObj->m_Top; | 999 int32_t maxV = (int32_t)pPageObj->m_Top > nPageHeight ? nPageHeight : (i
nt32_t)pPageObj->m_Top; |
| 1000 if (minH >= maxH || minV >= maxV) { | 1000 if (minH >= maxH || minV >= maxV) { |
| 1001 continue; | 1001 continue; |
| 1002 } | 1002 } |
| 1003 FXSYS_memset8(pDataH + minH, 1, maxH - minH); | 1003 FXSYS_memset8(pDataH + minH, 1, maxH - minH); |
| 1004 FXSYS_memset8(pDataV + minV, 1, maxV - minV); | 1004 FXSYS_memset8(pDataV + minV, 1, maxV - minV); |
| 1005 if (fLineHeight <= 0.0f) { | 1005 if (fLineHeight <= 0.0f) { |
| 1006 fLineHeight = pPageObj->m_Top - pPageObj->m_Bottom; | 1006 fLineHeight = pPageObj->m_Top - pPageObj->m_Bottom; |
| 1007 } | 1007 } |
| 1008 pPageObj = NULL; | 1008 pPageObj = NULL; |
| 1009 } | 1009 } |
| 1010 FX_INT32 nStartH = 0; | 1010 int32_t nStartH = 0; |
| 1011 FX_INT32 nEndH = 0; | 1011 int32_t nEndH = 0; |
| 1012 FX_FLOAT nSumH = 0.0f; | 1012 FX_FLOAT nSumH = 0.0f; |
| 1013 for (index = 0; index < nPageWidth; index++) | 1013 for (index = 0; index < nPageWidth; index++) |
| 1014 if(1 == nHorizontalMask[index]) { | 1014 if(1 == nHorizontalMask[index]) { |
| 1015 break; | 1015 break; |
| 1016 } | 1016 } |
| 1017 nStartH = index; | 1017 nStartH = index; |
| 1018 for (index = nPageWidth; index > 0; index--) | 1018 for (index = nPageWidth; index > 0; index--) |
| 1019 if(1 == nHorizontalMask[index - 1]) { | 1019 if(1 == nHorizontalMask[index - 1]) { |
| 1020 break; | 1020 break; |
| 1021 } | 1021 } |
| 1022 nEndH = index; | 1022 nEndH = index; |
| 1023 for (index = nStartH; index < nEndH; index++) { | 1023 for (index = nStartH; index < nEndH; index++) { |
| 1024 nSumH += nHorizontalMask[index]; | 1024 nSumH += nHorizontalMask[index]; |
| 1025 } | 1025 } |
| 1026 nSumH /= nEndH - nStartH; | 1026 nSumH /= nEndH - nStartH; |
| 1027 FX_INT32 nStartV = 0; | 1027 int32_t nStartV = 0; |
| 1028 FX_INT32 nEndV = 0; | 1028 int32_t nEndV = 0; |
| 1029 FX_FLOAT nSumV = 0.0f; | 1029 FX_FLOAT nSumV = 0.0f; |
| 1030 for (index = 0; index < nPageHeight; index++) | 1030 for (index = 0; index < nPageHeight; index++) |
| 1031 if(1 == nVerticalMask[index]) { | 1031 if(1 == nVerticalMask[index]) { |
| 1032 break; | 1032 break; |
| 1033 } | 1033 } |
| 1034 nStartV = index; | 1034 nStartV = index; |
| 1035 for (index = nPageHeight; index > 0; index--) | 1035 for (index = nPageHeight; index > 0; index--) |
| 1036 if(1 == nVerticalMask[index - 1]) { | 1036 if(1 == nVerticalMask[index - 1]) { |
| 1037 break; | 1037 break; |
| 1038 } | 1038 } |
| 1039 nEndV = index; | 1039 nEndV = index; |
| 1040 for (index = nStartV; index < nEndV; index++) { | 1040 for (index = nStartV; index < nEndV; index++) { |
| 1041 nSumV += nVerticalMask[index]; | 1041 nSumV += nVerticalMask[index]; |
| 1042 } | 1042 } |
| 1043 nSumV /= nEndV - nStartV; | 1043 nSumV /= nEndV - nStartV; |
| 1044 if ((nEndV - nStartV) < (FX_INT32)(2 * fLineHeight)) { | 1044 if ((nEndV - nStartV) < (int32_t)(2 * fLineHeight)) { |
| 1045 return 0; | 1045 return 0; |
| 1046 } | 1046 } |
| 1047 if ((nEndH - nStartH) < (FX_INT32)(2 * fLineHeight)) { | 1047 if ((nEndH - nStartH) < (int32_t)(2 * fLineHeight)) { |
| 1048 return 1; | 1048 return 1; |
| 1049 } | 1049 } |
| 1050 if (nSumH > 0.8f) { | 1050 if (nSumH > 0.8f) { |
| 1051 return 0; | 1051 return 0; |
| 1052 } | 1052 } |
| 1053 if (nSumH - nSumV > 0.0f) { | 1053 if (nSumH - nSumV > 0.0f) { |
| 1054 return 0; | 1054 return 0; |
| 1055 } | 1055 } |
| 1056 if (nSumV - nSumH > 0.0f) { | 1056 if (nSumV - nSumH > 0.0f) { |
| 1057 return 1; | 1057 return 1; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1131 if(w == 0) { | 1131 if(w == 0) { |
| 1132 FX_RECT BBox; | 1132 FX_RECT BBox; |
| 1133 pFont->GetCharBBox(charCode, BBox); | 1133 pFont->GetCharBBox(charCode, BBox); |
| 1134 w = BBox.right - BBox.left; | 1134 w = BBox.right - BBox.left; |
| 1135 } | 1135 } |
| 1136 } | 1136 } |
| 1137 return w; | 1137 return w; |
| 1138 } | 1138 } |
| 1139 void CPDF_TextPage::OnPiece(IFX_BidiChar* pBidi, CFX_WideString& str) | 1139 void CPDF_TextPage::OnPiece(IFX_BidiChar* pBidi, CFX_WideString& str) |
| 1140 { | 1140 { |
| 1141 FX_INT32 start, count; | 1141 int32_t start, count; |
| 1142 FX_INT32 ret = pBidi->GetBidiInfo(start, count); | 1142 int32_t ret = pBidi->GetBidiInfo(start, count); |
| 1143 if(ret == 2) { | 1143 if(ret == 2) { |
| 1144 for(int i = start + count - 1; i >= start; i--) { | 1144 for(int i = start + count - 1; i >= start; i--) { |
| 1145 m_TextBuf.AppendChar(str.GetAt(i)); | 1145 m_TextBuf.AppendChar(str.GetAt(i)); |
| 1146 m_charList.Add(*(PAGECHAR_INFO*)m_TempCharList.GetAt(i)); | 1146 m_charList.Add(*(PAGECHAR_INFO*)m_TempCharList.GetAt(i)); |
| 1147 } | 1147 } |
| 1148 } else { | 1148 } else { |
| 1149 int end = start + count ; | 1149 int end = start + count ; |
| 1150 for(int i = start; i < end; i++) { | 1150 for(int i = start; i < end; i++) { |
| 1151 m_TextBuf.AppendChar(str.GetAt(i)); | 1151 m_TextBuf.AppendChar(str.GetAt(i)); |
| 1152 m_charList.Add(*(PAGECHAR_INFO*)m_TempCharList.GetAt(i)); | 1152 m_charList.Add(*(PAGECHAR_INFO*)m_TempCharList.GetAt(i)); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1222 void CPDF_TextPage::CloseTempLine() | 1222 void CPDF_TextPage::CloseTempLine() |
| 1223 { | 1223 { |
| 1224 int count1 = m_TempCharList.GetSize(); | 1224 int count1 = m_TempCharList.GetSize(); |
| 1225 if (count1 <= 0) { | 1225 if (count1 <= 0) { |
| 1226 return; | 1226 return; |
| 1227 } | 1227 } |
| 1228 IFX_BidiChar* BidiChar = IFX_BidiChar::Create(); | 1228 IFX_BidiChar* BidiChar = IFX_BidiChar::Create(); |
| 1229 CFX_WideString str = m_TempTextBuf.GetWideString(); | 1229 CFX_WideString str = m_TempTextBuf.GetWideString(); |
| 1230 CFX_WordArray order; | 1230 CFX_WordArray order; |
| 1231 FX_BOOL bR2L = FALSE; | 1231 FX_BOOL bR2L = FALSE; |
| 1232 FX_INT32 start = 0, count = 0; | 1232 int32_t start = 0, count = 0; |
| 1233 int nR2L = 0, nL2R = 0; | 1233 int nR2L = 0, nL2R = 0; |
| 1234 FX_BOOL bPrevSpace = FALSE; | 1234 FX_BOOL bPrevSpace = FALSE; |
| 1235 for (int i = 0; i < str.GetLength(); i++) { | 1235 for (int i = 0; i < str.GetLength(); i++) { |
| 1236 if(str.GetAt(i) == 32) { | 1236 if(str.GetAt(i) == 32) { |
| 1237 if(bPrevSpace) { | 1237 if(bPrevSpace) { |
| 1238 m_TempTextBuf.Delete(i, 1); | 1238 m_TempTextBuf.Delete(i, 1); |
| 1239 m_TempCharList.Delete(i); | 1239 m_TempCharList.Delete(i); |
| 1240 str.Delete(i); | 1240 str.Delete(i); |
| 1241 count1--; | 1241 count1--; |
| 1242 i--; | 1242 i--; |
| 1243 continue; | 1243 continue; |
| 1244 } | 1244 } |
| 1245 bPrevSpace = TRUE; | 1245 bPrevSpace = TRUE; |
| 1246 } else { | 1246 } else { |
| 1247 bPrevSpace = FALSE; | 1247 bPrevSpace = FALSE; |
| 1248 } | 1248 } |
| 1249 if(BidiChar && BidiChar->AppendChar(str.GetAt(i))) { | 1249 if(BidiChar && BidiChar->AppendChar(str.GetAt(i))) { |
| 1250 FX_INT32 ret = BidiChar->GetBidiInfo(start, count); | 1250 int32_t ret = BidiChar->GetBidiInfo(start, count); |
| 1251 order.Add(start); | 1251 order.Add(start); |
| 1252 order.Add(count); | 1252 order.Add(count); |
| 1253 order.Add(ret); | 1253 order.Add(ret); |
| 1254 if(!bR2L) { | 1254 if(!bR2L) { |
| 1255 if(ret == 2) { | 1255 if(ret == 2) { |
| 1256 nR2L++; | 1256 nR2L++; |
| 1257 } else if (ret == 1) { | 1257 } else if (ret == 1) { |
| 1258 nL2R++; | 1258 nL2R++; |
| 1259 } | 1259 } |
| 1260 } | 1260 } |
| 1261 } | 1261 } |
| 1262 } | 1262 } |
| 1263 if(BidiChar && BidiChar->EndChar()) { | 1263 if(BidiChar && BidiChar->EndChar()) { |
| 1264 FX_INT32 ret = BidiChar->GetBidiInfo(start, count); | 1264 int32_t ret = BidiChar->GetBidiInfo(start, count); |
| 1265 order.Add(start); | 1265 order.Add(start); |
| 1266 order.Add(count); | 1266 order.Add(count); |
| 1267 order.Add(ret); | 1267 order.Add(ret); |
| 1268 if(!bR2L) { | 1268 if(!bR2L) { |
| 1269 if(ret == 2) { | 1269 if(ret == 2) { |
| 1270 nR2L++; | 1270 nR2L++; |
| 1271 } else if(ret == 1) { | 1271 } else if(ret == 1) { |
| 1272 nL2R++; | 1272 nL2R++; |
| 1273 } | 1273 } |
| 1274 } | 1274 } |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1428 break; | 1428 break; |
| 1429 } | 1429 } |
| 1430 } | 1430 } |
| 1431 if(i < 0) { | 1431 if(i < 0) { |
| 1432 m_LineObj.InsertAt(0, Obj); | 1432 m_LineObj.InsertAt(0, Obj); |
| 1433 } | 1433 } |
| 1434 } else { | 1434 } else { |
| 1435 m_LineObj.Add(Obj); | 1435 m_LineObj.Add(Obj); |
| 1436 } | 1436 } |
| 1437 } | 1437 } |
| 1438 FX_INT32 CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) | 1438 int32_t CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) |
| 1439 { | 1439 { |
| 1440 CPDF_TextObject* pTextObj = Obj.m_pTextObj; | 1440 CPDF_TextObject* pTextObj = Obj.m_pTextObj; |
| 1441 CPDF_ContentMarkData* pMarkData = (CPDF_ContentMarkData*)pTextObj->m_Content
Mark.GetObject(); | 1441 CPDF_ContentMarkData* pMarkData = (CPDF_ContentMarkData*)pTextObj->m_Content
Mark.GetObject(); |
| 1442 if(!pMarkData) { | 1442 if(!pMarkData) { |
| 1443 return FPDFTEXT_MC_PASS; | 1443 return FPDFTEXT_MC_PASS; |
| 1444 } | 1444 } |
| 1445 int nContentMark = pMarkData->CountItems(); | 1445 int nContentMark = pMarkData->CountItems(); |
| 1446 if (nContentMark < 1) { | 1446 if (nContentMark < 1) { |
| 1447 return FPDFTEXT_MC_PASS; | 1447 return FPDFTEXT_MC_PASS; |
| 1448 } | 1448 } |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1588 { | 1588 { |
| 1589 CPDF_TextObject* pTextObj = Obj.m_pTextObj; | 1589 CPDF_TextObject* pTextObj = Obj.m_pTextObj; |
| 1590 if(FXSYS_fabs(pTextObj->m_Right - pTextObj->m_Left) < 0.01f ) { | 1590 if(FXSYS_fabs(pTextObj->m_Right - pTextObj->m_Left) < 0.01f ) { |
| 1591 return; | 1591 return; |
| 1592 } | 1592 } |
| 1593 CFX_AffineMatrix formMatrix = Obj.m_formMatrix; | 1593 CFX_AffineMatrix formMatrix = Obj.m_formMatrix; |
| 1594 CPDF_Font* pFont = pTextObj->GetFont(); | 1594 CPDF_Font* pFont = pTextObj->GetFont(); |
| 1595 CFX_AffineMatrix matrix; | 1595 CFX_AffineMatrix matrix; |
| 1596 pTextObj->GetTextMatrix(&matrix); | 1596 pTextObj->GetTextMatrix(&matrix); |
| 1597 matrix.Concat(formMatrix); | 1597 matrix.Concat(formMatrix); |
| 1598 FX_INT32 bPreMKC = PreMarkedContent(Obj); | 1598 int32_t bPreMKC = PreMarkedContent(Obj); |
| 1599 if (FPDFTEXT_MC_DONE == bPreMKC) { | 1599 if (FPDFTEXT_MC_DONE == bPreMKC) { |
| 1600 m_pPreTextObj = pTextObj; | 1600 m_pPreTextObj = pTextObj; |
| 1601 m_perMatrix.Copy(formMatrix); | 1601 m_perMatrix.Copy(formMatrix); |
| 1602 return; | 1602 return; |
| 1603 } | 1603 } |
| 1604 int result = 0; | 1604 int result = 0; |
| 1605 if (m_pPreTextObj) { | 1605 if (m_pPreTextObj) { |
| 1606 result = ProcessInsertObject(pTextObj, formMatrix); | 1606 result = ProcessInsertObject(pTextObj, formMatrix); |
| 1607 if (2 == result) { | 1607 if (2 == result) { |
| 1608 m_CurlineRect = CFX_FloatRect(Obj.m_pTextObj->m_Left, Obj.m_pTextObj
->m_Bottom, Obj.m_pTextObj->m_Right, Obj.m_pTextObj->m_Top); | 1608 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... |
| 1635 if(GenerateCharInfo(TEXT_LINEFEED_CHAR, generateChar)) { | 1635 if(GenerateCharInfo(TEXT_LINEFEED_CHAR, generateChar)) { |
| 1636 m_TextBuf.AppendChar(TEXT_LINEFEED_CHAR); | 1636 m_TextBuf.AppendChar(TEXT_LINEFEED_CHAR); |
| 1637 if (!formMatrix.IsIdentity()) { | 1637 if (!formMatrix.IsIdentity()) { |
| 1638 generateChar.m_Matrix.Copy(formMatrix); | 1638 generateChar.m_Matrix.Copy(formMatrix); |
| 1639 } | 1639 } |
| 1640 m_charList.Add(generateChar); | 1640 m_charList.Add(generateChar); |
| 1641 } | 1641 } |
| 1642 } | 1642 } |
| 1643 } | 1643 } |
| 1644 } else if (result == 3 && !m_ParseOptions.m_bOutputHyphen) { | 1644 } else if (result == 3 && !m_ParseOptions.m_bOutputHyphen) { |
| 1645 FX_INT32 nChars = pTextObj->CountChars(); | 1645 int32_t nChars = pTextObj->CountChars(); |
| 1646 if (nChars == 1) { | 1646 if (nChars == 1) { |
| 1647 CPDF_TextObjectItem item; | 1647 CPDF_TextObjectItem item; |
| 1648 pTextObj->GetCharInfo(0, &item); | 1648 pTextObj->GetCharInfo(0, &item); |
| 1649 CFX_WideString wstrItem = pTextObj->GetFont()->UnicodeFromCharCo
de(item.m_CharCode); | 1649 CFX_WideString wstrItem = pTextObj->GetFont()->UnicodeFromCharCo
de(item.m_CharCode); |
| 1650 if(wstrItem.IsEmpty()) { | 1650 if(wstrItem.IsEmpty()) { |
| 1651 wstrItem += (FX_WCHAR)item.m_CharCode; | 1651 wstrItem += (FX_WCHAR)item.m_CharCode; |
| 1652 } | 1652 } |
| 1653 FX_WCHAR curChar = wstrItem.GetAt(0); | 1653 FX_WCHAR curChar = wstrItem.GetAt(0); |
| 1654 if (0x2D == curChar || 0xAD == curChar) { | 1654 if (0x2D == curChar || 0xAD == curChar) { |
| 1655 return; | 1655 return; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1675 return; | 1675 return; |
| 1676 } | 1676 } |
| 1677 m_pPreTextObj = pTextObj; | 1677 m_pPreTextObj = pTextObj; |
| 1678 m_perMatrix.Copy(formMatrix); | 1678 m_perMatrix.Copy(formMatrix); |
| 1679 int nItems = pTextObj->CountItems(); | 1679 int nItems = pTextObj->CountItems(); |
| 1680 FX_FLOAT baseSpace = _CalculateBaseSpace(pTextObj, matrix); | 1680 FX_FLOAT baseSpace = _CalculateBaseSpace(pTextObj, matrix); |
| 1681 | 1681 |
| 1682 const FX_BOOL bR2L = IsRightToLeft(pTextObj, pFont, nItems); | 1682 const FX_BOOL bR2L = IsRightToLeft(pTextObj, pFont, nItems); |
| 1683 const FX_BOOL bIsBidiAndMirrorInverse = | 1683 const FX_BOOL bIsBidiAndMirrorInverse = |
| 1684 bR2L && (matrix.a * matrix.d - matrix.b * matrix.c) < 0; | 1684 bR2L && (matrix.a * matrix.d - matrix.b * matrix.c) < 0; |
| 1685 FX_INT32 iBufStartAppend = m_TempTextBuf.GetLength(); | 1685 int32_t iBufStartAppend = m_TempTextBuf.GetLength(); |
| 1686 FX_INT32 iCharListStartAppend = m_TempCharList.GetSize(); | 1686 int32_t iCharListStartAppend = m_TempCharList.GetSize(); |
| 1687 | 1687 |
| 1688 FX_FLOAT spacing = 0; | 1688 FX_FLOAT spacing = 0; |
| 1689 for (int i = 0; i < nItems; i++) { | 1689 for (int i = 0; i < nItems; i++) { |
| 1690 CPDF_TextObjectItem item; | 1690 CPDF_TextObjectItem item; |
| 1691 PAGECHAR_INFO charinfo; | 1691 PAGECHAR_INFO charinfo; |
| 1692 charinfo.m_OriginX = 0; | 1692 charinfo.m_OriginX = 0; |
| 1693 charinfo.m_OriginY = 0; | 1693 charinfo.m_OriginY = 0; |
| 1694 pTextObj->GetItemInfo(i, &item); | 1694 pTextObj->GetItemInfo(i, &item); |
| 1695 if (item.m_CharCode == (FX_DWORD) - 1) { | 1695 if (item.m_CharCode == (FX_DWORD) - 1) { |
| 1696 CFX_WideString str = m_TempTextBuf.GetWideString(); | 1696 CFX_WideString str = m_TempTextBuf.GetWideString(); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1823 m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1); | 1823 m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1); |
| 1824 m_TempCharList.Delete(m_TempCharList.GetSize() - 1); | 1824 m_TempCharList.Delete(m_TempCharList.GetSize() - 1); |
| 1825 } | 1825 } |
| 1826 } | 1826 } |
| 1827 } | 1827 } |
| 1828 } | 1828 } |
| 1829 if (bIsBidiAndMirrorInverse) { | 1829 if (bIsBidiAndMirrorInverse) { |
| 1830 SwapTempTextBuf(iCharListStartAppend, iBufStartAppend); | 1830 SwapTempTextBuf(iCharListStartAppend, iBufStartAppend); |
| 1831 } | 1831 } |
| 1832 } | 1832 } |
| 1833 void CPDF_TextPage::SwapTempTextBuf(FX_INT32 iCharListStartAppend, | 1833 void CPDF_TextPage::SwapTempTextBuf(int32_t iCharListStartAppend, |
| 1834 FX_INT32 iBufStartAppend) | 1834 int32_t iBufStartAppend) |
| 1835 { | 1835 { |
| 1836 FX_INT32 i, j; | 1836 int32_t i, j; |
| 1837 i = iCharListStartAppend; | 1837 i = iCharListStartAppend; |
| 1838 j = m_TempCharList.GetSize() - 1; | 1838 j = m_TempCharList.GetSize() - 1; |
| 1839 for (; i < j; i++, j--) { | 1839 for (; i < j; i++, j--) { |
| 1840 std::swap(m_TempCharList[i], m_TempCharList[j]); | 1840 std::swap(m_TempCharList[i], m_TempCharList[j]); |
| 1841 std::swap(m_TempCharList[i].m_Index, m_TempCharList[j].m_Index); | 1841 std::swap(m_TempCharList[i].m_Index, m_TempCharList[j].m_Index); |
| 1842 } | 1842 } |
| 1843 FX_WCHAR * pTempBuffer = m_TempTextBuf.GetBuffer(); | 1843 FX_WCHAR * pTempBuffer = m_TempTextBuf.GetBuffer(); |
| 1844 i = iBufStartAppend; | 1844 i = iBufStartAppend; |
| 1845 j = m_TempTextBuf.GetLength() - 1; | 1845 j = m_TempTextBuf.GetLength() - 1; |
| 1846 for (; i < j; i++, j--) { | 1846 for (; i < j; i++, j--) { |
| 1847 std::swap(pTempBuffer[i], pTempBuffer[j]); | 1847 std::swap(pTempBuffer[i], pTempBuffer[j]); |
| 1848 } | 1848 } |
| 1849 } | 1849 } |
| 1850 FX_BOOL CPDF_TextPage::IsRightToLeft(const CPDF_TextObject* pTextObj, | 1850 FX_BOOL CPDF_TextPage::IsRightToLeft(const CPDF_TextObject* pTextObj, |
| 1851 const CPDF_Font* pFont, | 1851 const CPDF_Font* pFont, |
| 1852 int nItems) const | 1852 int nItems) const |
| 1853 { | 1853 { |
| 1854 IFX_BidiChar* BidiChar = IFX_BidiChar::Create(); | 1854 IFX_BidiChar* BidiChar = IFX_BidiChar::Create(); |
| 1855 FX_INT32 nR2L = 0; | 1855 int32_t nR2L = 0; |
| 1856 FX_INT32 nL2R = 0; | 1856 int32_t nL2R = 0; |
| 1857 FX_INT32 start = 0, count = 0; | 1857 int32_t start = 0, count = 0; |
| 1858 CPDF_TextObjectItem item; | 1858 CPDF_TextObjectItem item; |
| 1859 for (FX_INT32 i = 0; i < nItems; i++) { | 1859 for (int32_t i = 0; i < nItems; i++) { |
| 1860 pTextObj->GetItemInfo(i, &item); | 1860 pTextObj->GetItemInfo(i, &item); |
| 1861 if (item.m_CharCode == (FX_DWORD)-1) { | 1861 if (item.m_CharCode == (FX_DWORD)-1) { |
| 1862 continue; | 1862 continue; |
| 1863 } | 1863 } |
| 1864 CFX_WideString wstrItem = pFont->UnicodeFromCharCode(item.m_CharCode); | 1864 CFX_WideString wstrItem = pFont->UnicodeFromCharCode(item.m_CharCode); |
| 1865 FX_WCHAR wChar = wstrItem.GetAt(0); | 1865 FX_WCHAR wChar = wstrItem.GetAt(0); |
| 1866 if ((wstrItem.IsEmpty() || wChar == 0) && item.m_CharCode) { | 1866 if ((wstrItem.IsEmpty() || wChar == 0) && item.m_CharCode) { |
| 1867 wChar = (FX_WCHAR)item.m_CharCode; | 1867 wChar = (FX_WCHAR)item.m_CharCode; |
| 1868 } | 1868 } |
| 1869 if (!wChar) { | 1869 if (!wChar) { |
| 1870 continue; | 1870 continue; |
| 1871 } | 1871 } |
| 1872 if (BidiChar && BidiChar->AppendChar(wChar)) { | 1872 if (BidiChar && BidiChar->AppendChar(wChar)) { |
| 1873 FX_INT32 ret = BidiChar->GetBidiInfo(start, count); | 1873 int32_t ret = BidiChar->GetBidiInfo(start, count); |
| 1874 if (ret == 2) { | 1874 if (ret == 2) { |
| 1875 nR2L++; | 1875 nR2L++; |
| 1876 } | 1876 } |
| 1877 else if (ret == 1) { | 1877 else if (ret == 1) { |
| 1878 nL2R++; | 1878 nL2R++; |
| 1879 } | 1879 } |
| 1880 } | 1880 } |
| 1881 } | 1881 } |
| 1882 if (BidiChar && BidiChar->EndChar()) { | 1882 if (BidiChar && BidiChar->EndChar()) { |
| 1883 FX_INT32 ret = BidiChar->GetBidiInfo(start, count); | 1883 int32_t ret = BidiChar->GetBidiInfo(start, count); |
| 1884 if (ret == 2) { | 1884 if (ret == 2) { |
| 1885 nR2L++; | 1885 nR2L++; |
| 1886 } | 1886 } |
| 1887 else if (ret == 1) { | 1887 else if (ret == 1) { |
| 1888 nL2R++; | 1888 nL2R++; |
| 1889 } | 1889 } |
| 1890 } | 1890 } |
| 1891 if (BidiChar) | 1891 if (BidiChar) |
| 1892 BidiChar->Release(); | 1892 BidiChar->Release(); |
| 1893 return (nR2L > 0 && nR2L >= nL2R); | 1893 return (nR2L > 0 && nR2L >= nL2R); |
| 1894 } | 1894 } |
| 1895 FX_INT32 CPDF_TextPage::GetTextObjectWritingMode(const CPDF_TextObject* pTextObj
) | 1895 int32_t CPDF_TextPage::GetTextObjectWritingMode(const CPDF_TextObject* pTextObj) |
| 1896 { | 1896 { |
| 1897 FX_INT32 nChars = pTextObj->CountChars(); | 1897 int32_t nChars = pTextObj->CountChars(); |
| 1898 if (nChars == 1) { | 1898 if (nChars == 1) { |
| 1899 return m_TextlineDir; | 1899 return m_TextlineDir; |
| 1900 } | 1900 } |
| 1901 CPDF_TextObjectItem first, last; | 1901 CPDF_TextObjectItem first, last; |
| 1902 pTextObj->GetCharInfo(0, &first); | 1902 pTextObj->GetCharInfo(0, &first); |
| 1903 pTextObj->GetCharInfo(nChars - 1, &last); | 1903 pTextObj->GetCharInfo(nChars - 1, &last); |
| 1904 CFX_Matrix textMatrix; | 1904 CFX_Matrix textMatrix; |
| 1905 pTextObj->GetTextMatrix(&textMatrix); | 1905 pTextObj->GetTextMatrix(&textMatrix); |
| 1906 textMatrix.TransformPoint(first.m_OriginX, first.m_OriginY); | 1906 textMatrix.TransformPoint(first.m_OriginX, first.m_OriginY); |
| 1907 textMatrix.TransformPoint(last.m_OriginX, last.m_OriginY); | 1907 textMatrix.TransformPoint(last.m_OriginX, last.m_OriginY); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2051 } | 2051 } |
| 2052 } | 2052 } |
| 2053 } | 2053 } |
| 2054 } | 2054 } |
| 2055 if(bNewline) { | 2055 if(bNewline) { |
| 2056 if(IsHyphen(curChar)) { | 2056 if(IsHyphen(curChar)) { |
| 2057 return 3; | 2057 return 3; |
| 2058 } | 2058 } |
| 2059 return 2; | 2059 return 2; |
| 2060 } | 2060 } |
| 2061 FX_INT32 nChars = pObj->CountChars(); | 2061 int32_t nChars = pObj->CountChars(); |
| 2062 if (nChars == 1 && ( 0x2D == curChar || 0xAD == curChar)) | 2062 if (nChars == 1 && ( 0x2D == curChar || 0xAD == curChar)) |
| 2063 if (IsHyphen(curChar)) { | 2063 if (IsHyphen(curChar)) { |
| 2064 return 3; | 2064 return 3; |
| 2065 } | 2065 } |
| 2066 CFX_WideString PrevStr = m_pPreTextObj->GetFont()->UnicodeFromCharCode(PrevI
tem.m_CharCode); | 2066 CFX_WideString PrevStr = m_pPreTextObj->GetFont()->UnicodeFromCharCode(PrevI
tem.m_CharCode); |
| 2067 FX_WCHAR preChar = PrevStr.GetAt(PrevStr.GetLength() - 1); | 2067 FX_WCHAR preChar = PrevStr.GetAt(PrevStr.GetLength() - 1); |
| 2068 CFX_AffineMatrix matrix; | 2068 CFX_AffineMatrix matrix; |
| 2069 pObj->GetTextMatrix(&matrix); | 2069 pObj->GetTextMatrix(&matrix); |
| 2070 matrix.Concat(formMatrix); | 2070 matrix.Concat(formMatrix); |
| 2071 threshold = (FX_FLOAT)(nLastWidth > nThisWidth ? nLastWidth : nThisWidth); | 2071 threshold = (FX_FLOAT)(nLastWidth > nThisWidth ? nLastWidth : nThisWidth); |
| (...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2831 if (!m_IsParserd || index < 0 || index >= m_LinkList.GetSize()) { | 2831 if (!m_IsParserd || index < 0 || index >= m_LinkList.GetSize()) { |
| 2832 return; | 2832 return; |
| 2833 } | 2833 } |
| 2834 CPDF_LinkExt* link = NULL; | 2834 CPDF_LinkExt* link = NULL; |
| 2835 link = m_LinkList.GetAt(index); | 2835 link = m_LinkList.GetAt(index); |
| 2836 if (!link) { | 2836 if (!link) { |
| 2837 return ; | 2837 return ; |
| 2838 } | 2838 } |
| 2839 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); | 2839 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); |
| 2840 } | 2840 } |
| OLD | NEW |