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

Side by Side Diff: core/src/fpdftext/fpdf_text_int.cpp

Issue 1519693002: Merge to XFA: Remove CFX_AffineMatrix/CPDF_Matrix (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: XFA-specific changes Created 5 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 <cctype> 7 #include <cctype>
8 #include <cwctype> 8 #include <cwctype>
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 if (threshold < 500) { 44 if (threshold < 500) {
45 return threshold / 4.0f; 45 return threshold / 4.0f;
46 } 46 }
47 if (threshold < 700) { 47 if (threshold < 700) {
48 return threshold / 5.0f; 48 return threshold / 5.0f;
49 } 49 }
50 return threshold / 6.0f; 50 return threshold / 6.0f;
51 } 51 }
52 52
53 FX_FLOAT _CalculateBaseSpace(const CPDF_TextObject* pTextObj, 53 FX_FLOAT _CalculateBaseSpace(const CPDF_TextObject* pTextObj,
54 const CFX_AffineMatrix& matrix) { 54 const CFX_Matrix& matrix) {
55 FX_FLOAT baseSpace = 0.0; 55 FX_FLOAT baseSpace = 0.0;
56 const int nItems = pTextObj->CountItems(); 56 const int nItems = pTextObj->CountItems();
57 if (pTextObj->m_TextState.GetObject()->m_CharSpace && nItems >= 3) { 57 if (pTextObj->m_TextState.GetObject()->m_CharSpace && nItems >= 3) {
58 FX_BOOL bAllChar = TRUE; 58 FX_BOOL bAllChar = TRUE;
59 FX_FLOAT spacing = matrix.TransformDistance( 59 FX_FLOAT spacing = matrix.TransformDistance(
60 pTextObj->m_TextState.GetObject()->m_CharSpace); 60 pTextObj->m_TextState.GetObject()->m_CharSpace);
61 baseSpace = spacing; 61 baseSpace = spacing;
62 for (int i = 0; i < nItems; i++) { 62 for (int i = 0; i < nItems; i++) {
63 CPDF_TextObjectItem item; 63 CPDF_TextObjectItem item;
64 pTextObj->GetItemInfo(i, &item); 64 pTextObj->GetItemInfo(i, &item);
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 if (!pCurObj) { 258 if (!pCurObj) {
259 pCurObj = info_curchar.m_pTextObj; 259 pCurObj = info_curchar.m_pTextObj;
260 } 260 }
261 if (pCurObj != info_curchar.m_pTextObj) { 261 if (pCurObj != info_curchar.m_pTextObj) {
262 rectArray.Add(rect); 262 rectArray.Add(rect);
263 pCurObj = info_curchar.m_pTextObj; 263 pCurObj = info_curchar.m_pTextObj;
264 flagNewRect = TRUE; 264 flagNewRect = TRUE;
265 } 265 }
266 if (flagNewRect) { 266 if (flagNewRect) {
267 FX_FLOAT orgX = info_curchar.m_OriginX, orgY = info_curchar.m_OriginY; 267 FX_FLOAT orgX = info_curchar.m_OriginX, orgY = info_curchar.m_OriginY;
268 CFX_AffineMatrix matrix, matrix_reverse; 268 CFX_Matrix matrix, matrix_reverse;
269 info_curchar.m_pTextObj->GetTextMatrix(&matrix); 269 info_curchar.m_pTextObj->GetTextMatrix(&matrix);
270 matrix.Concat(info_curchar.m_Matrix); 270 matrix.Concat(info_curchar.m_Matrix);
271 matrix_reverse.SetReverse(matrix); 271 matrix_reverse.SetReverse(matrix);
272 matrix_reverse.Transform(orgX, orgY); 272 matrix_reverse.Transform(orgX, orgY);
273 rect.left = info_curchar.m_CharBox.left; 273 rect.left = info_curchar.m_CharBox.left;
274 rect.right = info_curchar.m_CharBox.right; 274 rect.right = info_curchar.m_CharBox.right;
275 if (pCurObj->GetFont()->GetTypeDescent()) { 275 if (pCurObj->GetFont()->GetTypeDescent()) {
276 rect.bottom = orgY + 276 rect.bottom = orgY +
277 pCurObj->GetFont()->GetTypeDescent() * 277 pCurObj->GetFont()->GetTypeDescent() *
278 pCurObj->GetFontSize() / 1000; 278 pCurObj->GetFontSize() / 1000;
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 pos = m_pPage->GetFirstObjectPosition(); 901 pos = m_pPage->GetFirstObjectPosition();
902 if (!pos) { 902 if (!pos) {
903 return; 903 return;
904 } 904 }
905 m_TextlineDir = FindTextlineFlowDirection(); 905 m_TextlineDir = FindTextlineFlowDirection();
906 int nCount = 0; 906 int nCount = 0;
907 while (pos) { 907 while (pos) {
908 pPageObj = m_pPage->GetNextObject(pos); 908 pPageObj = m_pPage->GetNextObject(pos);
909 if (pPageObj) { 909 if (pPageObj) {
910 if (pPageObj->m_Type == PDFPAGE_TEXT) { 910 if (pPageObj->m_Type == PDFPAGE_TEXT) {
911 CFX_AffineMatrix matrix; 911 CFX_Matrix matrix;
912 ProcessTextObject((CPDF_TextObject*)pPageObj, matrix, pos); 912 ProcessTextObject((CPDF_TextObject*)pPageObj, matrix, pos);
913 nCount++; 913 nCount++;
914 } else if (pPageObj->m_Type == PDFPAGE_FORM) { 914 } else if (pPageObj->m_Type == PDFPAGE_FORM) {
915 CFX_AffineMatrix formMatrix(1, 0, 0, 1, 0, 0); 915 CFX_Matrix formMatrix(1, 0, 0, 1, 0, 0);
916 ProcessFormObject((CPDF_FormObject*)pPageObj, formMatrix); 916 ProcessFormObject((CPDF_FormObject*)pPageObj, formMatrix);
917 } 917 }
918 } 918 }
919 pPageObj = NULL; 919 pPageObj = NULL;
920 } 920 }
921 int count = m_LineObj.GetSize(); 921 int count = m_LineObj.GetSize();
922 for (int i = 0; i < count; i++) { 922 for (int i = 0; i < count; i++) {
923 ProcessTextObject(m_LineObj.GetAt(i)); 923 ProcessTextObject(m_LineObj.GetAt(i));
924 } 924 }
925 m_LineObj.RemoveAll(); 925 m_LineObj.RemoveAll();
926 CloseTempLine(); 926 CloseTempLine();
927 } 927 }
928 void CPDF_TextPage::ProcessFormObject(CPDF_FormObject* pFormObj, 928 void CPDF_TextPage::ProcessFormObject(CPDF_FormObject* pFormObj,
929 const CFX_AffineMatrix& formMatrix) { 929 const CFX_Matrix& formMatrix) {
930 CPDF_PageObject* pPageObj = NULL; 930 CPDF_PageObject* pPageObj = NULL;
931 FX_POSITION pos; 931 FX_POSITION pos;
932 if (!pFormObj) { 932 if (!pFormObj) {
933 return; 933 return;
934 } 934 }
935 pos = pFormObj->m_pForm->GetFirstObjectPosition(); 935 pos = pFormObj->m_pForm->GetFirstObjectPosition();
936 if (!pos) { 936 if (!pos) {
937 return; 937 return;
938 } 938 }
939 CFX_AffineMatrix curFormMatrix; 939 CFX_Matrix curFormMatrix;
940 curFormMatrix.Copy(pFormObj->m_FormMatrix); 940 curFormMatrix.Copy(pFormObj->m_FormMatrix);
941 curFormMatrix.Concat(formMatrix); 941 curFormMatrix.Concat(formMatrix);
942 while (pos) { 942 while (pos) {
943 pPageObj = pFormObj->m_pForm->GetNextObject(pos); 943 pPageObj = pFormObj->m_pForm->GetNextObject(pos);
944 if (pPageObj) { 944 if (pPageObj) {
945 if (pPageObj->m_Type == PDFPAGE_TEXT) { 945 if (pPageObj->m_Type == PDFPAGE_TEXT) {
946 ProcessTextObject((CPDF_TextObject*)pPageObj, curFormMatrix, pos); 946 ProcessTextObject((CPDF_TextObject*)pPageObj, curFormMatrix, pos);
947 } else if (pPageObj->m_Type == PDFPAGE_FORM) { 947 } else if (pPageObj->m_Type == PDFPAGE_FORM) {
948 ProcessFormObject((CPDF_FormObject*)pPageObj, curFormMatrix); 948 ProcessFormObject((CPDF_FormObject*)pPageObj, curFormMatrix);
949 } 949 }
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 AddCharInfoByLRDirection(str, n); 1180 AddCharInfoByLRDirection(str, n);
1181 } 1181 }
1182 } 1182 }
1183 } 1183 }
1184 } 1184 }
1185 order.RemoveAll(); 1185 order.RemoveAll();
1186 m_TempCharList.RemoveAll(); 1186 m_TempCharList.RemoveAll();
1187 m_TempTextBuf.Delete(0, m_TempTextBuf.GetLength()); 1187 m_TempTextBuf.Delete(0, m_TempTextBuf.GetLength());
1188 } 1188 }
1189 void CPDF_TextPage::ProcessTextObject(CPDF_TextObject* pTextObj, 1189 void CPDF_TextPage::ProcessTextObject(CPDF_TextObject* pTextObj,
1190 const CFX_AffineMatrix& formMatrix, 1190 const CFX_Matrix& formMatrix,
1191 FX_POSITION ObjPos) { 1191 FX_POSITION ObjPos) {
1192 CFX_FloatRect re(pTextObj->m_Left, pTextObj->m_Bottom, pTextObj->m_Right, 1192 CFX_FloatRect re(pTextObj->m_Left, pTextObj->m_Bottom, pTextObj->m_Right,
1193 pTextObj->m_Top); 1193 pTextObj->m_Top);
1194 if (FXSYS_fabs(pTextObj->m_Right - pTextObj->m_Left) < 0.01f) { 1194 if (FXSYS_fabs(pTextObj->m_Right - pTextObj->m_Left) < 0.01f) {
1195 return; 1195 return;
1196 } 1196 }
1197 int count = m_LineObj.GetSize(); 1197 int count = m_LineObj.GetSize();
1198 PDFTEXT_Obj Obj; 1198 PDFTEXT_Obj Obj;
1199 Obj.m_pTextObj = pTextObj; 1199 Obj.m_pTextObj = pTextObj;
1200 Obj.m_formMatrix = formMatrix; 1200 Obj.m_formMatrix = formMatrix;
1201 if (count == 0) { 1201 if (count == 0) {
1202 m_LineObj.Add(Obj); 1202 m_LineObj.Add(Obj);
1203 return; 1203 return;
1204 } 1204 }
1205 if (IsSameAsPreTextObject(pTextObj, ObjPos)) { 1205 if (IsSameAsPreTextObject(pTextObj, ObjPos)) {
1206 return; 1206 return;
1207 } 1207 }
1208 PDFTEXT_Obj prev_Obj = m_LineObj.GetAt(count - 1); 1208 PDFTEXT_Obj prev_Obj = m_LineObj.GetAt(count - 1);
1209 CPDF_TextObjectItem item; 1209 CPDF_TextObjectItem item;
1210 int nItem = prev_Obj.m_pTextObj->CountItems(); 1210 int nItem = prev_Obj.m_pTextObj->CountItems();
1211 prev_Obj.m_pTextObj->GetItemInfo(nItem - 1, &item); 1211 prev_Obj.m_pTextObj->GetItemInfo(nItem - 1, &item);
1212 FX_FLOAT prev_width = 1212 FX_FLOAT prev_width =
1213 GetCharWidth(item.m_CharCode, prev_Obj.m_pTextObj->GetFont()) * 1213 GetCharWidth(item.m_CharCode, prev_Obj.m_pTextObj->GetFont()) *
1214 prev_Obj.m_pTextObj->GetFontSize() / 1000; 1214 prev_Obj.m_pTextObj->GetFontSize() / 1000;
1215 CFX_AffineMatrix prev_matrix; 1215 CFX_Matrix prev_matrix;
1216 prev_Obj.m_pTextObj->GetTextMatrix(&prev_matrix); 1216 prev_Obj.m_pTextObj->GetTextMatrix(&prev_matrix);
1217 prev_width = FXSYS_fabs(prev_width); 1217 prev_width = FXSYS_fabs(prev_width);
1218 prev_matrix.Concat(prev_Obj.m_formMatrix); 1218 prev_matrix.Concat(prev_Obj.m_formMatrix);
1219 prev_width = prev_matrix.TransformDistance(prev_width); 1219 prev_width = prev_matrix.TransformDistance(prev_width);
1220 pTextObj->GetItemInfo(0, &item); 1220 pTextObj->GetItemInfo(0, &item);
1221 FX_FLOAT this_width = GetCharWidth(item.m_CharCode, pTextObj->GetFont()) * 1221 FX_FLOAT this_width = GetCharWidth(item.m_CharCode, pTextObj->GetFont()) *
1222 pTextObj->GetFontSize() / 1000; 1222 pTextObj->GetFontSize() / 1000;
1223 this_width = FXSYS_fabs(this_width); 1223 this_width = FXSYS_fabs(this_width);
1224 CFX_AffineMatrix this_matrix; 1224 CFX_Matrix this_matrix;
1225 pTextObj->GetTextMatrix(&this_matrix); 1225 pTextObj->GetTextMatrix(&this_matrix);
1226 this_width = FXSYS_fabs(this_width); 1226 this_width = FXSYS_fabs(this_width);
1227 this_matrix.Concat(formMatrix); 1227 this_matrix.Concat(formMatrix);
1228 this_width = this_matrix.TransformDistance(this_width); 1228 this_width = this_matrix.TransformDistance(this_width);
1229 FX_FLOAT threshold = 1229 FX_FLOAT threshold =
1230 prev_width > this_width ? prev_width / 4 : this_width / 4; 1230 prev_width > this_width ? prev_width / 4 : this_width / 4;
1231 FX_FLOAT prev_x = prev_Obj.m_pTextObj->GetPosX(), 1231 FX_FLOAT prev_x = prev_Obj.m_pTextObj->GetPosX(),
1232 prev_y = prev_Obj.m_pTextObj->GetPosY(); 1232 prev_y = prev_Obj.m_pTextObj->GetPosY();
1233 prev_Obj.m_formMatrix.Transform(prev_x, prev_y); 1233 prev_Obj.m_formMatrix.Transform(prev_x, prev_y);
1234 m_DisplayMatrix.Transform(prev_x, prev_y); 1234 m_DisplayMatrix.Transform(prev_x, prev_y);
1235 FX_FLOAT this_x = pTextObj->GetPosX(), this_y = pTextObj->GetPosY(); 1235 FX_FLOAT this_x = pTextObj->GetPosX(), this_y = pTextObj->GetPosY();
1236 formMatrix.Transform(this_x, this_y); 1236 formMatrix.Transform(this_x, this_y);
1237 m_DisplayMatrix.Transform(this_x, this_y); 1237 m_DisplayMatrix.Transform(this_x, this_y);
1238 if (FXSYS_fabs(this_y - prev_y) > threshold * 2) { 1238 if (FXSYS_fabs(this_y - prev_y) > threshold * 2) {
1239 for (int i = 0; i < count; i++) { 1239 for (int i = 0; i < count; i++) {
1240 ProcessTextObject(m_LineObj.GetAt(i)); 1240 ProcessTextObject(m_LineObj.GetAt(i));
1241 } 1241 }
1242 m_LineObj.RemoveAll(); 1242 m_LineObj.RemoveAll();
1243 m_LineObj.Add(Obj); 1243 m_LineObj.Add(Obj);
1244 return; 1244 return;
1245 } 1245 }
1246 int i = 0; 1246 int i = 0;
1247 if (m_ParseOptions.m_bNormalizeObjs) { 1247 if (m_ParseOptions.m_bNormalizeObjs) {
1248 for (i = count - 1; i >= 0; i--) { 1248 for (i = count - 1; i >= 0; i--) {
1249 PDFTEXT_Obj prev_Obj = m_LineObj.GetAt(i); 1249 PDFTEXT_Obj prev_Obj = m_LineObj.GetAt(i);
1250 CFX_AffineMatrix prev_matrix; 1250 CFX_Matrix prev_matrix;
1251 prev_Obj.m_pTextObj->GetTextMatrix(&prev_matrix); 1251 prev_Obj.m_pTextObj->GetTextMatrix(&prev_matrix);
1252 FX_FLOAT Prev_x = prev_Obj.m_pTextObj->GetPosX(), 1252 FX_FLOAT Prev_x = prev_Obj.m_pTextObj->GetPosX(),
1253 Prev_y = prev_Obj.m_pTextObj->GetPosY(); 1253 Prev_y = prev_Obj.m_pTextObj->GetPosY();
1254 prev_Obj.m_formMatrix.Transform(Prev_x, Prev_y); 1254 prev_Obj.m_formMatrix.Transform(Prev_x, Prev_y);
1255 m_DisplayMatrix.Transform(Prev_x, Prev_y); 1255 m_DisplayMatrix.Transform(Prev_x, Prev_y);
1256 if (this_x >= Prev_x) { 1256 if (this_x >= Prev_x) {
1257 if (i == count - 1) { 1257 if (i == count - 1) {
1258 m_LineObj.Add(Obj); 1258 m_LineObj.Add(Obj);
1259 } else { 1259 } else {
1260 m_LineObj.InsertAt(i + 1, Obj); 1260 m_LineObj.InsertAt(i + 1, Obj);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1362 ToString(pDict ? pDict->GetElement(FX_BSTRC("ActualText")) : nullptr); 1362 ToString(pDict ? pDict->GetElement(FX_BSTRC("ActualText")) : nullptr);
1363 if (temp) { 1363 if (temp) {
1364 actText = temp->GetUnicodeText(); 1364 actText = temp->GetUnicodeText();
1365 } 1365 }
1366 } 1366 }
1367 FX_STRSIZE nItems = actText.GetLength(); 1367 FX_STRSIZE nItems = actText.GetLength();
1368 if (nItems < 1) { 1368 if (nItems < 1) {
1369 return; 1369 return;
1370 } 1370 }
1371 CPDF_Font* pFont = pTextObj->GetFont(); 1371 CPDF_Font* pFont = pTextObj->GetFont();
1372 CFX_AffineMatrix formMatrix = Obj.m_formMatrix; 1372 CFX_Matrix formMatrix = Obj.m_formMatrix;
1373 CFX_AffineMatrix matrix; 1373 CFX_Matrix matrix;
1374 pTextObj->GetTextMatrix(&matrix); 1374 pTextObj->GetTextMatrix(&matrix);
1375 matrix.Concat(formMatrix); 1375 matrix.Concat(formMatrix);
1376 FX_FLOAT fPosX = pTextObj->GetPosX(); 1376 FX_FLOAT fPosX = pTextObj->GetPosX();
1377 FX_FLOAT fPosY = pTextObj->GetPosY(); 1377 FX_FLOAT fPosY = pTextObj->GetPosY();
1378 int nCharInfoIndex = m_TextBuf.GetLength(); 1378 int nCharInfoIndex = m_TextBuf.GetLength();
1379 CFX_FloatRect charBox; 1379 CFX_FloatRect charBox;
1380 charBox.top = pTextObj->m_Top; 1380 charBox.top = pTextObj->m_Top;
1381 charBox.left = pTextObj->m_Left; 1381 charBox.left = pTextObj->m_Left;
1382 charBox.right = pTextObj->m_Right; 1382 charBox.right = pTextObj->m_Right;
1383 charBox.bottom = pTextObj->m_Bottom; 1383 charBox.bottom = pTextObj->m_Bottom;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 nL2R++; 1475 nL2R++;
1476 } 1476 }
1477 } 1477 }
1478 return (nR2L > 0 && nR2L >= nL2R); 1478 return (nR2L > 0 && nR2L >= nL2R);
1479 } 1479 }
1480 void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { 1480 void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
1481 CPDF_TextObject* pTextObj = Obj.m_pTextObj; 1481 CPDF_TextObject* pTextObj = Obj.m_pTextObj;
1482 if (FXSYS_fabs(pTextObj->m_Right - pTextObj->m_Left) < 0.01f) { 1482 if (FXSYS_fabs(pTextObj->m_Right - pTextObj->m_Left) < 0.01f) {
1483 return; 1483 return;
1484 } 1484 }
1485 CFX_AffineMatrix formMatrix = Obj.m_formMatrix; 1485 CFX_Matrix formMatrix = Obj.m_formMatrix;
1486 CPDF_Font* pFont = pTextObj->GetFont(); 1486 CPDF_Font* pFont = pTextObj->GetFont();
1487 CFX_AffineMatrix matrix; 1487 CFX_Matrix matrix;
1488 pTextObj->GetTextMatrix(&matrix); 1488 pTextObj->GetTextMatrix(&matrix);
1489 matrix.Concat(formMatrix); 1489 matrix.Concat(formMatrix);
1490 int32_t bPreMKC = PreMarkedContent(Obj); 1490 int32_t bPreMKC = PreMarkedContent(Obj);
1491 if (FPDFTEXT_MC_DONE == bPreMKC) { 1491 if (FPDFTEXT_MC_DONE == bPreMKC) {
1492 m_pPreTextObj = pTextObj; 1492 m_pPreTextObj = pTextObj;
1493 m_perMatrix.Copy(formMatrix); 1493 m_perMatrix.Copy(formMatrix);
1494 return; 1494 return;
1495 } 1495 }
1496 int result = 0; 1496 int result = 0;
1497 if (m_pPreTextObj) { 1497 if (m_pPreTextObj) {
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
1807 preChar = (PAGECHAR_INFO)m_charList[size - 1]; 1807 preChar = (PAGECHAR_INFO)m_charList[size - 1];
1808 } 1808 }
1809 if (FPDFTEXT_CHAR_PIECE == preChar.m_Flag) 1809 if (FPDFTEXT_CHAR_PIECE == preChar.m_Flag)
1810 if (0xAD == preChar.m_Unicode || 0x2D == preChar.m_Unicode) { 1810 if (0xAD == preChar.m_Unicode || 0x2D == preChar.m_Unicode) {
1811 return TRUE; 1811 return TRUE;
1812 } 1812 }
1813 } 1813 }
1814 return FALSE; 1814 return FALSE;
1815 } 1815 }
1816 int CPDF_TextPage::ProcessInsertObject(const CPDF_TextObject* pObj, 1816 int CPDF_TextPage::ProcessInsertObject(const CPDF_TextObject* pObj,
1817 const CFX_AffineMatrix& formMatrix) { 1817 const CFX_Matrix& formMatrix) {
1818 FindPreviousTextObject(); 1818 FindPreviousTextObject();
1819 FX_BOOL bNewline = FALSE; 1819 FX_BOOL bNewline = FALSE;
1820 int WritingMode = GetTextObjectWritingMode(pObj); 1820 int WritingMode = GetTextObjectWritingMode(pObj);
1821 if (WritingMode == -1) { 1821 if (WritingMode == -1) {
1822 WritingMode = GetTextObjectWritingMode(m_pPreTextObj); 1822 WritingMode = GetTextObjectWritingMode(m_pPreTextObj);
1823 } 1823 }
1824 CFX_FloatRect this_rect(pObj->m_Left, pObj->m_Bottom, pObj->m_Right, 1824 CFX_FloatRect this_rect(pObj->m_Left, pObj->m_Bottom, pObj->m_Right,
1825 pObj->m_Top); 1825 pObj->m_Top);
1826 CFX_FloatRect prev_rect(m_pPreTextObj->m_Left, m_pPreTextObj->m_Bottom, 1826 CFX_FloatRect prev_rect(m_pPreTextObj->m_Left, m_pPreTextObj->m_Bottom,
1827 m_pPreTextObj->m_Right, m_pPreTextObj->m_Top); 1827 m_pPreTextObj->m_Right, m_pPreTextObj->m_Top);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1866 } 1866 }
1867 FX_FLOAT last_pos = PrevItem.m_OriginX; 1867 FX_FLOAT last_pos = PrevItem.m_OriginX;
1868 int nLastWidth = GetCharWidth(PrevItem.m_CharCode, m_pPreTextObj->GetFont()); 1868 int nLastWidth = GetCharWidth(PrevItem.m_CharCode, m_pPreTextObj->GetFont());
1869 FX_FLOAT last_width = nLastWidth * m_pPreTextObj->GetFontSize() / 1000; 1869 FX_FLOAT last_width = nLastWidth * m_pPreTextObj->GetFontSize() / 1000;
1870 last_width = FXSYS_fabs(last_width); 1870 last_width = FXSYS_fabs(last_width);
1871 int nThisWidth = GetCharWidth(item.m_CharCode, pObj->GetFont()); 1871 int nThisWidth = GetCharWidth(item.m_CharCode, pObj->GetFont());
1872 FX_FLOAT this_width = nThisWidth * pObj->GetFontSize() / 1000; 1872 FX_FLOAT this_width = nThisWidth * pObj->GetFontSize() / 1000;
1873 this_width = FXSYS_fabs(this_width); 1873 this_width = FXSYS_fabs(this_width);
1874 FX_FLOAT threshold = 1874 FX_FLOAT threshold =
1875 last_width > this_width ? last_width / 4 : this_width / 4; 1875 last_width > this_width ? last_width / 4 : this_width / 4;
1876 CFX_AffineMatrix prev_matrix, prev_reverse; 1876 CFX_Matrix prev_matrix, prev_reverse;
1877 m_pPreTextObj->GetTextMatrix(&prev_matrix); 1877 m_pPreTextObj->GetTextMatrix(&prev_matrix);
1878 prev_matrix.Concat(m_perMatrix); 1878 prev_matrix.Concat(m_perMatrix);
1879 prev_reverse.SetReverse(prev_matrix); 1879 prev_reverse.SetReverse(prev_matrix);
1880 FX_FLOAT x = pObj->GetPosX(); 1880 FX_FLOAT x = pObj->GetPosX();
1881 FX_FLOAT y = pObj->GetPosY(); 1881 FX_FLOAT y = pObj->GetPosY();
1882 formMatrix.Transform(x, y); 1882 formMatrix.Transform(x, y);
1883 prev_reverse.Transform(x, y); 1883 prev_reverse.Transform(x, y);
1884 if (last_width < this_width) { 1884 if (last_width < this_width) {
1885 threshold = prev_reverse.TransformDistance(threshold); 1885 threshold = prev_reverse.TransformDistance(threshold);
1886 } 1886 }
1887 CFX_FloatRect rect1(m_pPreTextObj->m_Left, pObj->m_Bottom, 1887 CFX_FloatRect rect1(m_pPreTextObj->m_Left, pObj->m_Bottom,
1888 m_pPreTextObj->m_Right, pObj->m_Top); 1888 m_pPreTextObj->m_Right, pObj->m_Top);
1889 CFX_FloatRect rect2(m_pPreTextObj->m_Left, m_pPreTextObj->m_Bottom, 1889 CFX_FloatRect rect2(m_pPreTextObj->m_Left, m_pPreTextObj->m_Bottom,
1890 m_pPreTextObj->m_Right, m_pPreTextObj->m_Top); 1890 m_pPreTextObj->m_Right, m_pPreTextObj->m_Top);
1891 CFX_FloatRect rect3 = rect1; 1891 CFX_FloatRect rect3 = rect1;
1892 rect1.Intersect(rect2); 1892 rect1.Intersect(rect2);
1893 if (WritingMode == 0) { 1893 if (WritingMode == 0) {
1894 if ((rect1.IsEmpty() && rect2.Height() > 5 && rect3.Height() > 5) || 1894 if ((rect1.IsEmpty() && rect2.Height() > 5 && rect3.Height() > 5) ||
1895 ((y > threshold * 2 || y < threshold * -3) && 1895 ((y > threshold * 2 || y < threshold * -3) &&
1896 (FXSYS_fabs(y) < 1 ? FXSYS_fabs(x) < FXSYS_fabs(y) : TRUE))) { 1896 (FXSYS_fabs(y) < 1 ? FXSYS_fabs(x) < FXSYS_fabs(y) : TRUE))) {
1897 bNewline = TRUE; 1897 bNewline = TRUE;
1898 if (nItem > 1) { 1898 if (nItem > 1) {
1899 CPDF_TextObjectItem tempItem; 1899 CPDF_TextObjectItem tempItem;
1900 m_pPreTextObj->GetItemInfo(0, &tempItem); 1900 m_pPreTextObj->GetItemInfo(0, &tempItem);
1901 CFX_AffineMatrix m; 1901 CFX_Matrix m;
1902 m_pPreTextObj->GetTextMatrix(&m); 1902 m_pPreTextObj->GetTextMatrix(&m);
1903 if (PrevItem.m_OriginX > tempItem.m_OriginX && 1903 if (PrevItem.m_OriginX > tempItem.m_OriginX &&
1904 m_DisplayMatrix.a > 0.9 && m_DisplayMatrix.b < 0.1 && 1904 m_DisplayMatrix.a > 0.9 && m_DisplayMatrix.b < 0.1 &&
1905 m_DisplayMatrix.c < 0.1 && m_DisplayMatrix.d < -0.9 && m.b < 0.1 && 1905 m_DisplayMatrix.c < 0.1 && m_DisplayMatrix.d < -0.9 && m.b < 0.1 &&
1906 m.c < 0.1) { 1906 m.c < 0.1) {
1907 CFX_FloatRect re(0, m_pPreTextObj->m_Bottom, 1000, 1907 CFX_FloatRect re(0, m_pPreTextObj->m_Bottom, 1000,
1908 m_pPreTextObj->m_Top); 1908 m_pPreTextObj->m_Top);
1909 if (re.Contains(pObj->GetPosX(), pObj->GetPosY())) { 1909 if (re.Contains(pObj->GetPosX(), pObj->GetPosY())) {
1910 bNewline = FALSE; 1910 bNewline = FALSE;
1911 } else { 1911 } else {
(...skipping 14 matching lines...) Expand all
1926 return 2; 1926 return 2;
1927 } 1927 }
1928 int32_t nChars = pObj->CountChars(); 1928 int32_t nChars = pObj->CountChars();
1929 if (nChars == 1 && (0x2D == curChar || 0xAD == curChar)) 1929 if (nChars == 1 && (0x2D == curChar || 0xAD == curChar))
1930 if (IsHyphen(curChar)) { 1930 if (IsHyphen(curChar)) {
1931 return 3; 1931 return 3;
1932 } 1932 }
1933 CFX_WideString PrevStr = 1933 CFX_WideString PrevStr =
1934 m_pPreTextObj->GetFont()->UnicodeFromCharCode(PrevItem.m_CharCode); 1934 m_pPreTextObj->GetFont()->UnicodeFromCharCode(PrevItem.m_CharCode);
1935 FX_WCHAR preChar = PrevStr.GetAt(PrevStr.GetLength() - 1); 1935 FX_WCHAR preChar = PrevStr.GetAt(PrevStr.GetLength() - 1);
1936 CFX_AffineMatrix matrix; 1936 CFX_Matrix matrix;
1937 pObj->GetTextMatrix(&matrix); 1937 pObj->GetTextMatrix(&matrix);
1938 matrix.Concat(formMatrix); 1938 matrix.Concat(formMatrix);
1939 threshold = (FX_FLOAT)(nLastWidth > nThisWidth ? nLastWidth : nThisWidth); 1939 threshold = (FX_FLOAT)(nLastWidth > nThisWidth ? nLastWidth : nThisWidth);
1940 threshold = threshold > 400 1940 threshold = threshold > 400
1941 ? (threshold < 700 1941 ? (threshold < 700
1942 ? threshold / 4 1942 ? threshold / 4
1943 : (threshold > 800 ? threshold / 6 : threshold / 5)) 1943 : (threshold > 800 ? threshold / 6 : threshold / 5))
1944 : (threshold / 2); 1944 : (threshold / 2);
1945 if (nLastWidth >= nThisWidth) { 1945 if (nLastWidth >= nThisWidth) {
1946 threshold *= FXSYS_fabs(m_pPreTextObj->GetFontSize()); 1946 threshold *= FXSYS_fabs(m_pPreTextObj->GetFontSize());
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
2726 if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) { 2726 if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) {
2727 return; 2727 return;
2728 } 2728 }
2729 CPDF_LinkExt* link = NULL; 2729 CPDF_LinkExt* link = NULL;
2730 link = m_LinkList.GetAt(index); 2730 link = m_LinkList.GetAt(index);
2731 if (!link) { 2731 if (!link) {
2732 return; 2732 return;
2733 } 2733 }
2734 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); 2734 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects);
2735 } 2735 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698