summaryrefslogtreecommitdiff
path: root/core/fpdftext/cpdf_textpage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdftext/cpdf_textpage.cpp')
-rw-r--r--core/fpdftext/cpdf_textpage.cpp242
1 files changed, 127 insertions, 115 deletions
diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp
index bd068a596b..55551dcfa0 100644
--- a/core/fpdftext/cpdf_textpage.cpp
+++ b/core/fpdftext/cpdf_textpage.cpp
@@ -55,7 +55,7 @@ FX_FLOAT CalculateBaseSpace(const CPDF_TextObject* pTextObj,
pTextObj->GetItemInfo(i, &item);
if (item.m_CharCode == static_cast<uint32_t>(-1)) {
FX_FLOAT fontsize_h = pTextObj->m_TextState.GetFontSizeH();
- FX_FLOAT kerning = -fontsize_h * item.m_Origin.x / 1000;
+ FX_FLOAT kerning = -fontsize_h * item.m_OriginX / 1000;
baseSpace = std::min(baseSpace, kerning + spacing);
bAllChar = false;
}
@@ -108,22 +108,6 @@ float MaskPercentFilled(const std::vector<bool>& mask,
} // namespace
-FPDF_CHAR_INFO::FPDF_CHAR_INFO()
- : m_Unicode(0),
- m_Charcode(0),
- m_Flag(0),
- m_FontSize(0),
- m_pTextObj(nullptr) {}
-
-FPDF_CHAR_INFO::~FPDF_CHAR_INFO() {}
-
-PAGECHAR_INFO::PAGECHAR_INFO()
- : m_CharCode(0), m_Unicode(0), m_Flag(0), m_pTextObj(nullptr), m_Index(0) {}
-
-PAGECHAR_INFO::PAGECHAR_INFO(const PAGECHAR_INFO&) = default;
-
-PAGECHAR_INFO::~PAGECHAR_INFO() {}
-
CPDF_TextPage::CPDF_TextPage(const CPDF_Page* pPage, FPDFText_Direction flags)
: m_pPage(pPage),
m_parserflag(flags),
@@ -255,30 +239,30 @@ std::vector<CFX_FloatRect> CPDF_TextPage::GetRectArray(int start,
bFlagNewRect = true;
}
if (bFlagNewRect) {
+ FX_FLOAT orgX = info_curchar.m_OriginX, orgY = info_curchar.m_OriginY;
CFX_Matrix matrix = info_curchar.m_pTextObj->GetTextMatrix();
matrix.Concat(info_curchar.m_Matrix);
CFX_Matrix matrix_reverse;
matrix_reverse.SetReverse(matrix);
- CFX_PointF origin = matrix_reverse.Transform(info_curchar.m_Origin);
-
+ matrix_reverse.TransformPoint(orgX, orgY);
rect.left = info_curchar.m_CharBox.left;
rect.right = info_curchar.m_CharBox.right;
if (pCurObj->GetFont()->GetTypeDescent()) {
- rect.bottom = origin.y +
+ rect.bottom = orgY +
pCurObj->GetFont()->GetTypeDescent() *
pCurObj->GetFontSize() / 1000;
- FX_FLOAT xPosTemp = origin.x;
+ FX_FLOAT xPosTemp = orgX;
matrix.TransformPoint(xPosTemp, rect.bottom);
} else {
rect.bottom = info_curchar.m_CharBox.bottom;
}
if (pCurObj->GetFont()->GetTypeAscent()) {
rect.top =
- origin.y +
+ orgY +
pCurObj->GetFont()->GetTypeAscent() * pCurObj->GetFontSize() / 1000;
FX_FLOAT xPosTemp =
- origin.x +
+ orgX +
GetCharWidth(info_curchar.m_CharCode, pCurObj->GetFont()) *
pCurObj->GetFontSize() / 1000;
matrix.TransformPoint(xPosTemp, rect.top);
@@ -313,7 +297,7 @@ int CPDF_TextPage::GetIndexAtPos(CFX_FloatPoint point,
while (pos < pdfium::CollectionSize<int>(m_CharList)) {
PAGECHAR_INFO charinfo = m_CharList[pos];
CFX_FloatRect charrect = charinfo.m_CharBox;
- if (charrect.Contains(point))
+ if (charrect.Contains(point.x, point.y))
break;
if (xTolerance > 0 || yTolerance > 0) {
CFX_FloatRect charRectExt;
@@ -322,7 +306,7 @@ int CPDF_TextPage::GetIndexAtPos(CFX_FloatPoint point,
charRectExt.right = charrect.right + xTolerance / 2;
charRectExt.top = charrect.top + yTolerance / 2;
charRectExt.bottom = charrect.bottom - yTolerance / 2;
- if (charRectExt.Contains(point)) {
+ if (charRectExt.Contains(point.x, point.y)) {
double curXdif, curYdif;
curXdif = FXSYS_fabs(point.x - charrect.left) <
FXSYS_fabs(point.x - charrect.right)
@@ -354,9 +338,9 @@ CFX_WideString CPDF_TextPage::GetTextByRect(const CFX_FloatRect& rect) const {
CFX_WideString strText;
for (const auto& charinfo : m_CharList) {
if (IsRectIntersect(rect, charinfo.m_CharBox)) {
- if (FXSYS_fabs(posy - charinfo.m_Origin.y) > 0 && !IsContainPreChar &&
+ if (FXSYS_fabs(posy - charinfo.m_OriginY) > 0 && !IsContainPreChar &&
IsAddLineFeed) {
- posy = charinfo.m_Origin.y;
+ posy = charinfo.m_OriginY;
if (!strText.IsEmpty())
strText += L"\r\n";
}
@@ -395,7 +379,8 @@ void CPDF_TextPage::GetCharInfo(int index, FPDF_CHAR_INFO* info) const {
const PAGECHAR_INFO& charinfo = m_CharList[index];
info->m_Charcode = charinfo.m_CharCode;
- info->m_Origin = charinfo.m_Origin;
+ info->m_OriginX = charinfo.m_OriginX;
+ info->m_OriginY = charinfo.m_OriginY;
info->m_Unicode = charinfo.m_Unicode;
info->m_Flag = charinfo.m_Flag;
info->m_CharBox = charinfo.m_CharBox;
@@ -753,9 +738,10 @@ void CPDF_TextPage::ProcessTextObject(
const CFX_Matrix& formMatrix,
const CPDF_PageObjectList* pObjList,
CPDF_PageObjectList::const_iterator ObjPos) {
+ CFX_FloatRect re(pTextObj->m_Left, pTextObj->m_Bottom, pTextObj->m_Right,
+ pTextObj->m_Top);
if (FXSYS_fabs(pTextObj->m_Right - pTextObj->m_Left) < 0.01f)
return;
-
size_t count = m_LineObj.size();
PDFTEXT_Obj Obj;
Obj.m_pTextObj = pTextObj;
@@ -766,7 +752,6 @@ void CPDF_TextPage::ProcessTextObject(
}
if (IsSameAsPreTextObject(pTextObj, pObjList, ObjPos))
return;
-
PDFTEXT_Obj prev_Obj = m_LineObj[count - 1];
CPDF_TextObjectItem item;
int nItem = prev_Obj.m_pTextObj->CountItems();
@@ -791,28 +776,28 @@ void CPDF_TextPage::ProcessTextObject(
FX_FLOAT threshold =
prev_width > this_width ? prev_width / 4 : this_width / 4;
- CFX_PointF prev = prev_Obj.m_pTextObj->GetPos();
- prev_Obj.m_formMatrix.Transform(prev);
- m_DisplayMatrix.Transform(prev);
-
- CFX_PointF this_pos = pTextObj->GetPos();
- formMatrix.Transform(this_pos);
- m_DisplayMatrix.Transform(this_pos);
- if (FXSYS_fabs(this_pos.y - prev.y) > threshold * 2) {
+ FX_FLOAT prev_x = prev_Obj.m_pTextObj->GetPosX(),
+ prev_y = prev_Obj.m_pTextObj->GetPosY();
+ prev_Obj.m_formMatrix.TransformPoint(prev_x, prev_y);
+ m_DisplayMatrix.TransformPoint(prev_x, prev_y);
+ FX_FLOAT this_x = pTextObj->GetPosX(), this_y = pTextObj->GetPosY();
+ formMatrix.TransformPoint(this_x, this_y);
+ m_DisplayMatrix.TransformPoint(this_x, this_y);
+ if (FXSYS_fabs(this_y - prev_y) > threshold * 2) {
for (size_t i = 0; i < count; i++)
ProcessTextObject(m_LineObj[i]);
m_LineObj.clear();
m_LineObj.push_back(Obj);
return;
}
-
size_t i;
for (i = count; i > 0; --i) {
PDFTEXT_Obj prev_text_obj = m_LineObj[i - 1];
- CFX_PointF new_prev = prev_text_obj.m_pTextObj->GetPos();
- prev_text_obj.m_formMatrix.Transform(new_prev);
- m_DisplayMatrix.Transform(new_prev);
- if (this_pos.x >= new_prev.x) {
+ FX_FLOAT Prev_x = prev_text_obj.m_pTextObj->GetPosX(),
+ Prev_y = prev_text_obj.m_pTextObj->GetPosY();
+ prev_text_obj.m_formMatrix.TransformPoint(Prev_x, Prev_y);
+ m_DisplayMatrix.TransformPoint(Prev_x, Prev_y);
+ if (this_x >= Prev_x) {
m_LineObj.insert(m_LineObj.begin() + i, Obj);
break;
}
@@ -908,7 +893,14 @@ void CPDF_TextPage::ProcessMarkedContent(PDFTEXT_Obj Obj) {
CFX_Matrix matrix = pTextObj->GetTextMatrix();
matrix.Concat(Obj.m_formMatrix);
+ FX_FLOAT fPosX = pTextObj->GetPosX();
+ FX_FLOAT fPosY = pTextObj->GetPosY();
int nCharInfoIndex = m_TextBuf.GetLength();
+ CFX_FloatRect charBox;
+ charBox.top = pTextObj->m_Top;
+ charBox.left = pTextObj->m_Left;
+ charBox.right = pTextObj->m_Right;
+ charBox.bottom = pTextObj->m_Bottom;
for (FX_STRSIZE k = 0; k < nItems; k++) {
FX_WCHAR wChar = actText.GetAt(k);
if (wChar <= 0x80 && !isprint(wChar))
@@ -917,13 +909,17 @@ void CPDF_TextPage::ProcessMarkedContent(PDFTEXT_Obj Obj) {
continue;
PAGECHAR_INFO charinfo;
- charinfo.m_Origin = pTextObj->GetPos();
+ charinfo.m_OriginX = fPosX;
+ charinfo.m_OriginY = fPosY;
charinfo.m_Index = nCharInfoIndex;
charinfo.m_Unicode = wChar;
charinfo.m_CharCode = pFont->CharCodeFromUnicode(wChar);
charinfo.m_Flag = FPDFTEXT_CHAR_PIECE;
charinfo.m_pTextObj = pTextObj;
- charinfo.m_CharBox = pTextObj->GetRect();
+ charinfo.m_CharBox.top = charBox.top;
+ charinfo.m_CharBox.left = charBox.left;
+ charinfo.m_CharBox.right = charBox.right;
+ charinfo.m_CharBox.bottom = charBox.bottom;
charinfo.m_Matrix = matrix;
m_TempTextBuf.AppendChar(wChar);
m_TempCharList.push_back(charinfo);
@@ -993,11 +989,15 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
GenerateCharacter result = GenerateCharacter::None;
if (m_pPreTextObj) {
result = ProcessInsertObject(pTextObj, formMatrix);
- if (result == GenerateCharacter::LineBreak)
- m_CurlineRect = Obj.m_pTextObj->GetRect();
- else
- m_CurlineRect.Union(Obj.m_pTextObj->GetRect());
-
+ if (result == GenerateCharacter::LineBreak) {
+ m_CurlineRect =
+ CFX_FloatRect(Obj.m_pTextObj->m_Left, Obj.m_pTextObj->m_Bottom,
+ Obj.m_pTextObj->m_Right, Obj.m_pTextObj->m_Top);
+ } else {
+ m_CurlineRect.Union(
+ CFX_FloatRect(Obj.m_pTextObj->m_Left, Obj.m_pTextObj->m_Bottom,
+ Obj.m_pTextObj->m_Right, Obj.m_pTextObj->m_Top));
+ }
switch (result) {
case GenerateCharacter::None:
break;
@@ -1044,9 +1044,10 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
break;
}
} else {
- m_CurlineRect = Obj.m_pTextObj->GetRect();
+ m_CurlineRect =
+ CFX_FloatRect(Obj.m_pTextObj->m_Left, Obj.m_pTextObj->m_Bottom,
+ Obj.m_pTextObj->m_Right, Obj.m_pTextObj->m_Top);
}
-
if (ePreMKC == FPDFText_MarkedContent::Delay) {
ProcessMarkedContent(Obj);
m_pPreTextObj = pTextObj;
@@ -1069,6 +1070,8 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
for (int i = 0; i < nItems; i++) {
CPDF_TextObjectItem item;
PAGECHAR_INFO charinfo;
+ charinfo.m_OriginX = 0;
+ charinfo.m_OriginY = 0;
pTextObj->GetItemInfo(i, &item);
if (item.m_CharCode == static_cast<uint32_t>(-1)) {
CFX_WideString str = m_TempTextBuf.MakeString();
@@ -1078,7 +1081,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
continue;
FX_FLOAT fontsize_h = pTextObj->m_TextState.GetFontSizeH();
- spacing = -fontsize_h * item.m_Origin.x / 1000;
+ spacing = -fontsize_h * item.m_OriginX / 1000;
continue;
}
FX_FLOAT charSpace = pTextObj->m_TextState.GetCharSpace();
@@ -1115,10 +1118,12 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
charinfo.m_CharCode = CPDF_Font::kInvalidCharCode;
charinfo.m_Matrix = formMatrix;
- charinfo.m_Origin = matrix.Transform(item.m_Origin);
+ charinfo.m_OriginX = item.m_OriginX;
+ charinfo.m_OriginY = item.m_OriginY;
+ matrix.TransformPoint(charinfo.m_OriginX, charinfo.m_OriginY);
charinfo.m_CharBox =
- CFX_FloatRect(charinfo.m_Origin.x, charinfo.m_Origin.y,
- charinfo.m_Origin.x, charinfo.m_Origin.y);
+ CFX_FloatRect(charinfo.m_OriginX, charinfo.m_OriginY,
+ charinfo.m_OriginX, charinfo.m_OriginY);
m_TempCharList.push_back(charinfo);
}
if (item.m_CharCode == CPDF_Font::kInvalidCharCode)
@@ -1139,18 +1144,20 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
charinfo.m_Flag = FPDFTEXT_CHAR_NORMAL;
charinfo.m_pTextObj = pTextObj;
- charinfo.m_Origin = matrix.Transform(item.m_Origin);
+ charinfo.m_OriginX = item.m_OriginX;
+ charinfo.m_OriginY = item.m_OriginY;
+ matrix.TransformPoint(charinfo.m_OriginX, charinfo.m_OriginY);
FX_RECT rect =
charinfo.m_pTextObj->GetFont()->GetCharBBox(charinfo.m_CharCode);
charinfo.m_CharBox.top =
- rect.top * pTextObj->GetFontSize() / 1000 + item.m_Origin.y;
+ rect.top * pTextObj->GetFontSize() / 1000 + item.m_OriginY;
charinfo.m_CharBox.left =
- rect.left * pTextObj->GetFontSize() / 1000 + item.m_Origin.x;
+ rect.left * pTextObj->GetFontSize() / 1000 + item.m_OriginX;
charinfo.m_CharBox.right =
- rect.right * pTextObj->GetFontSize() / 1000 + item.m_Origin.x;
+ rect.right * pTextObj->GetFontSize() / 1000 + item.m_OriginX;
charinfo.m_CharBox.bottom =
- rect.bottom * pTextObj->GetFontSize() / 1000 + item.m_Origin.y;
+ rect.bottom * pTextObj->GetFontSize() / 1000 + item.m_OriginY;
if (fabsf(charinfo.m_CharBox.top - charinfo.m_CharBox.bottom) < 0.01f) {
charinfo.m_CharBox.top =
charinfo.m_CharBox.bottom + pTextObj->GetFontSize();
@@ -1178,10 +1185,8 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
const PAGECHAR_INFO& charinfo1 = m_TempCharList[n - 1];
if (charinfo1.m_CharCode == charinfo.m_CharCode &&
charinfo1.m_pTextObj->GetFont() == charinfo.m_pTextObj->GetFont() &&
- FXSYS_fabs(charinfo1.m_Origin.x - charinfo.m_Origin.x) <
- threshold &&
- FXSYS_fabs(charinfo1.m_Origin.y - charinfo.m_Origin.y) <
- threshold) {
+ FXSYS_fabs(charinfo1.m_OriginX - charinfo.m_OriginX) < threshold &&
+ FXSYS_fabs(charinfo1.m_OriginY - charinfo.m_OriginY) < threshold) {
bDel = true;
break;
}
@@ -1222,11 +1227,10 @@ CPDF_TextPage::TextOrientation CPDF_TextPage::GetTextObjectWritingMode(
pTextObj->GetCharInfo(nChars - 1, &last);
CFX_Matrix textMatrix = pTextObj->GetTextMatrix();
- first.m_Origin = textMatrix.Transform(first.m_Origin);
- last.m_Origin = textMatrix.Transform(last.m_Origin);
-
- FX_FLOAT dX = FXSYS_fabs(last.m_Origin.x - first.m_Origin.x);
- FX_FLOAT dY = FXSYS_fabs(last.m_Origin.y - first.m_Origin.y);
+ textMatrix.TransformPoint(first.m_OriginX, first.m_OriginY);
+ textMatrix.TransformPoint(last.m_OriginX, last.m_OriginY);
+ FX_FLOAT dX = FXSYS_fabs(last.m_OriginX - first.m_OriginX);
+ FX_FLOAT dY = FXSYS_fabs(last.m_OriginY - first.m_OriginY);
if (dX <= 0.0001f && dY <= 0.0001f)
return TextOrientation::Unknown;
@@ -1283,8 +1287,10 @@ CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject(
if (WritingMode == TextOrientation::Unknown)
WritingMode = GetTextObjectWritingMode(m_pPreTextObj);
- CFX_FloatRect this_rect = pObj->GetRect();
- CFX_FloatRect prev_rect = m_pPreTextObj->GetRect();
+ CFX_FloatRect this_rect(pObj->m_Left, pObj->m_Bottom, pObj->m_Right,
+ pObj->m_Top);
+ CFX_FloatRect prev_rect(m_pPreTextObj->m_Left, m_pPreTextObj->m_Bottom,
+ m_pPreTextObj->m_Right, m_pPreTextObj->m_Top);
CPDF_TextObjectItem PrevItem, item;
int nItem = m_pPreTextObj->CountItems();
m_pPreTextObj->GetItemInfo(nItem - 1, &PrevItem);
@@ -1319,7 +1325,7 @@ CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject(
}
}
}
- FX_FLOAT last_pos = PrevItem.m_Origin.x;
+ FX_FLOAT last_pos = PrevItem.m_OriginX;
int nLastWidth = GetCharWidth(PrevItem.m_CharCode, m_pPreTextObj->GetFont());
FX_FLOAT last_width = nLastWidth * m_pPreTextObj->GetFontSize() / 1000;
last_width = FXSYS_fabs(last_width);
@@ -1334,39 +1340,42 @@ CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject(
CFX_Matrix prev_reverse;
prev_reverse.SetReverse(prev_matrix);
-
- CFX_PointF pos = pObj->GetPos();
- formMatrix.Transform(pos);
- prev_reverse.Transform(pos);
+ FX_FLOAT x = pObj->GetPosX();
+ FX_FLOAT y = pObj->GetPosY();
+ formMatrix.TransformPoint(x, y);
+ prev_reverse.TransformPoint(x, y);
if (last_width < this_width)
threshold = prev_reverse.TransformDistance(threshold);
bool bNewline = false;
if (WritingMode == TextOrientation::Horizontal) {
- CFX_FloatRect rect1 = m_pPreTextObj->GetRect();
- CFX_FloatRect rect2 = m_pPreTextObj->GetRect();
+ CFX_FloatRect rect1(m_pPreTextObj->m_Left, pObj->m_Bottom,
+ m_pPreTextObj->m_Right, pObj->m_Top);
+ CFX_FloatRect rect2(m_pPreTextObj->m_Left, m_pPreTextObj->m_Bottom,
+ m_pPreTextObj->m_Right, m_pPreTextObj->m_Top);
CFX_FloatRect rect3 = rect1;
rect1.Intersect(rect2);
if ((rect1.IsEmpty() && rect2.Height() > 5 && rect3.Height() > 5) ||
- ((pos.y > threshold * 2 || pos.y < threshold * -3) &&
- (FXSYS_fabs(pos.y) < 1 ? FXSYS_fabs(pos.x) < FXSYS_fabs(pos.y)
- : true))) {
+ ((y > threshold * 2 || y < threshold * -3) &&
+ (FXSYS_fabs(y) < 1 ? FXSYS_fabs(x) < FXSYS_fabs(y) : true))) {
bNewline = true;
if (nItem > 1) {
CPDF_TextObjectItem tempItem;
m_pPreTextObj->GetItemInfo(0, &tempItem);
CFX_Matrix m = m_pPreTextObj->GetTextMatrix();
- if (PrevItem.m_Origin.x > tempItem.m_Origin.x &&
+ if (PrevItem.m_OriginX > tempItem.m_OriginX &&
m_DisplayMatrix.a > 0.9 && m_DisplayMatrix.b < 0.1 &&
m_DisplayMatrix.c < 0.1 && m_DisplayMatrix.d < -0.9 && m.b < 0.1 &&
m.c < 0.1) {
CFX_FloatRect re(0, m_pPreTextObj->m_Bottom, 1000,
m_pPreTextObj->m_Top);
- if (re.Contains(pObj->GetPos())) {
+ if (re.Contains(pObj->GetPosX(), pObj->GetPosY())) {
bNewline = false;
} else {
CFX_FloatRect rect(0, pObj->m_Bottom, 1000, pObj->m_Top);
- if (rect.Contains(m_pPreTextObj->GetPos()))
+ if (rect.Contains(m_pPreTextObj->GetPosX(),
+ m_pPreTextObj->GetPosY())) {
bNewline = false;
+ }
}
}
}
@@ -1406,17 +1415,19 @@ CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject(
(threshold < 1.39001 && threshold > 1.38999)) {
threshold *= 1.5;
}
- if (FXSYS_fabs(last_pos + last_width - pos.x) > threshold &&
- curChar != L' ' && preChar != L' ') {
- if ((pos.x - last_pos - last_width) > threshold ||
- (last_pos - pos.x - last_width) > threshold) {
- return GenerateCharacter::Space;
- }
- if (pos.x < 0 && (last_pos - pos.x - last_width) > threshold)
- return GenerateCharacter::Space;
- if ((pos.x - last_pos - last_width) > this_width ||
- (pos.x - last_pos - this_width) > last_width) {
- return GenerateCharacter::Space;
+ if (FXSYS_fabs(last_pos + last_width - x) > threshold && curChar != L' ' &&
+ preChar != L' ') {
+ if (curChar != L' ' && preChar != L' ') {
+ if ((x - last_pos - last_width) > threshold ||
+ (last_pos - x - last_width) > threshold) {
+ return GenerateCharacter::Space;
+ }
+ if (x < 0 && (last_pos - x - last_width) > threshold)
+ return GenerateCharacter::Space;
+ if ((x - last_pos - last_width) > this_width ||
+ (x - last_pos - this_width) > last_width) {
+ return GenerateCharacter::Space;
+ }
}
}
return GenerateCharacter::None;
@@ -1426,8 +1437,10 @@ bool CPDF_TextPage::IsSameTextObject(CPDF_TextObject* pTextObj1,
CPDF_TextObject* pTextObj2) {
if (!pTextObj1 || !pTextObj2)
return false;
- CFX_FloatRect rcPreObj = pTextObj2->GetRect();
- CFX_FloatRect rcCurObj = pTextObj1->GetRect();
+ CFX_FloatRect rcPreObj(pTextObj2->m_Left, pTextObj2->m_Bottom,
+ pTextObj2->m_Right, pTextObj2->m_Top);
+ CFX_FloatRect rcCurObj(pTextObj1->m_Left, pTextObj1->m_Bottom,
+ pTextObj1->m_Right, pTextObj1->m_Top);
if (rcPreObj.IsEmpty() && rcCurObj.IsEmpty()) {
FX_FLOAT dbXdif = FXSYS_fabs(rcPreObj.left - rcCurObj.left);
size_t nCount = m_CharList.size();
@@ -1457,25 +1470,24 @@ bool CPDF_TextPage::IsSameTextObject(CPDF_TextObject* pTextObj1,
if (!nPreCount)
return true;
- CPDF_TextObjectItem itemPer;
- CPDF_TextObjectItem itemCur;
+ CPDF_TextObjectItem itemPer = {0, 0.0f, 0.0f};
+ CPDF_TextObjectItem itemCur = {0, 0.0f, 0.0f};
for (int i = 0; i < nPreCount; i++) {
pTextObj2->GetItemInfo(i, &itemPer);
pTextObj1->GetItemInfo(i, &itemCur);
if (itemCur.m_CharCode != itemPer.m_CharCode)
return false;
}
-
- CFX_PointF pos1 = pTextObj1->GetPos();
- CFX_PointF pos2 = pTextObj2->GetPos();
-
- return FXSYS_fabs(pos1.x - pos2.x) <=
- GetCharWidth(itemPer.m_CharCode, pTextObj2->GetFont()) *
- pTextObj2->GetFontSize() / 1000 * 0.9 &&
- FXSYS_fabs(pos1.y - pos2.y) <=
- std::max(std::max(rcPreObj.Height(), rcPreObj.Width()),
- pTextObj2->GetFontSize()) /
- 8.0;
+ if (FXSYS_fabs(pTextObj1->GetPosX() - pTextObj2->GetPosX()) >
+ GetCharWidth(itemPer.m_CharCode, pTextObj2->GetFont()) *
+ pTextObj2->GetFontSize() / 1000 * 0.9 ||
+ FXSYS_fabs(pTextObj1->GetPosY() - pTextObj2->GetPosY()) >
+ std::max(std::max(rcPreObj.Height(), rcPreObj.Width()),
+ pTextObj2->GetFontSize()) /
+ 8) {
+ return false;
+ }
+ return true;
}
bool CPDF_TextPage::IsSameAsPreTextObject(
@@ -1519,10 +1531,10 @@ bool CPDF_TextPage::GenerateCharInfo(FX_WCHAR unicode, PAGECHAR_INFO& info) {
if (!fFontSize)
fFontSize = kDefaultFontSize;
- info.m_Origin = CFX_PointF(preChar->m_Origin.x + preWidth * fFontSize / 1000,
- preChar->m_Origin.y);
- info.m_CharBox = CFX_FloatRect(info.m_Origin.x, info.m_Origin.y,
- info.m_Origin.x, info.m_Origin.y);
+ info.m_OriginX = preChar->m_OriginX + preWidth * (fFontSize) / 1000;
+ info.m_OriginY = preChar->m_OriginY;
+ info.m_CharBox = CFX_FloatRect(info.m_OriginX, info.m_OriginY, info.m_OriginX,
+ info.m_OriginY);
return true;
}