summaryrefslogtreecommitdiff
path: root/fpdfsdk/fxedit/fxet_pageobjs.cpp
diff options
context:
space:
mode:
authorthestig <thestig@chromium.org>2016-05-11 12:59:22 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-11 12:59:22 -0700
commit821d59e1d66b67af970c59b7681828b1b82858b6 (patch)
tree60e71c3c317f5843d0488e827c6932a956df7866 /fpdfsdk/fxedit/fxet_pageobjs.cpp
parenta244dfe2ba2cc82ee264475253cc16222e022524 (diff)
downloadpdfium-821d59e1d66b67af970c59b7681828b1b82858b6.tar.xz
CPDF_VariableText::GetIterator() never returns NULL.
Same goes for CFX_Edit::GetIterator(). Review-Url: https://codereview.chromium.org/1967963002
Diffstat (limited to 'fpdfsdk/fxedit/fxet_pageobjs.cpp')
-rw-r--r--fpdfsdk/fxedit/fxet_pageobjs.cpp607
1 files changed, 298 insertions, 309 deletions
diff --git a/fpdfsdk/fxedit/fxet_pageobjs.cpp b/fpdfsdk/fxedit/fxet_pageobjs.cpp
index b862e7396d..6e7deed00d 100644
--- a/fpdfsdk/fxedit/fxet_pageobjs.cpp
+++ b/fpdfsdk/fxedit/fxet_pageobjs.cpp
@@ -107,32 +107,31 @@ void IFX_Edit::DrawUnderline(CFX_RenderDevice* pDevice,
pDevice->SetClip_Rect(rcTemp.ToFxRect());
}
- if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
- if (pEdit->GetFontMap()) {
- if (pRange)
- pIterator->SetAt(pRange->BeginPos);
- else
- pIterator->SetAt(0);
-
- while (pIterator->NextWord()) {
- CPVT_WordPlace place = pIterator->GetAt();
- if (pRange && place.WordCmp(pRange->EndPos) > 0)
- break;
-
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- CFX_PathData pathUnderline;
- CFX_FloatRect rcUnderline = GetUnderLineRect(word);
- rcUnderline.left += ptOffset.x;
- rcUnderline.right += ptOffset.x;
- rcUnderline.top += ptOffset.y;
- rcUnderline.bottom += ptOffset.y;
- pathUnderline.AppendRect(rcUnderline.left, rcUnderline.bottom,
- rcUnderline.right, rcUnderline.top);
-
- pDevice->DrawPath(&pathUnderline, pUser2Device, NULL, color, 0,
- FXFILL_WINDING);
- }
+ IFX_Edit_Iterator* pIterator = pEdit->GetIterator();
+ if (pEdit->GetFontMap()) {
+ if (pRange)
+ pIterator->SetAt(pRange->BeginPos);
+ else
+ pIterator->SetAt(0);
+
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
+ if (pRange && place.WordCmp(pRange->EndPos) > 0)
+ break;
+
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ CFX_PathData pathUnderline;
+ CFX_FloatRect rcUnderline = GetUnderLineRect(word);
+ rcUnderline.left += ptOffset.x;
+ rcUnderline.right += ptOffset.x;
+ rcUnderline.top += ptOffset.y;
+ rcUnderline.bottom += ptOffset.y;
+ pathUnderline.AppendRect(rcUnderline.left, rcUnderline.bottom,
+ rcUnderline.right, rcUnderline.top);
+
+ pDevice->DrawPath(&pathUnderline, pUser2Device, NULL, color, 0,
+ FXFILL_WINDING);
}
}
}
@@ -176,95 +175,93 @@ void IFX_Edit::DrawEdit(CFX_RenderDevice* pDevice,
pDevice->SetClip_Rect(rcTemp.ToFxRect());
}
- if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
- if (IPVT_FontMap* pFontMap = pEdit->GetFontMap()) {
- if (pRange)
- pIterator->SetAt(pRange->BeginPos);
- else
- pIterator->SetAt(0);
-
- CPVT_WordPlace oldplace;
-
- while (pIterator->NextWord()) {
- CPVT_WordPlace place = pIterator->GetAt();
- if (pRange && place.WordCmp(pRange->EndPos) > 0)
- break;
-
- if (wrSelect.IsExist()) {
- bSelect = place.WordCmp(wrSelect.BeginPos) > 0 &&
- place.WordCmp(wrSelect.EndPos) <= 0;
- if (bSelect) {
- crCurFill = crWhite;
- } else {
- crCurFill = crTextFill;
- }
- }
- if (pSystemHandler && pSystemHandler->IsSelectionImplemented()) {
+ IFX_Edit_Iterator* pIterator = pEdit->GetIterator();
+ if (IPVT_FontMap* pFontMap = pEdit->GetFontMap()) {
+ if (pRange)
+ pIterator->SetAt(pRange->BeginPos);
+ else
+ pIterator->SetAt(0);
+
+ CPVT_WordPlace oldplace;
+
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
+ if (pRange && place.WordCmp(pRange->EndPos) > 0)
+ break;
+
+ if (wrSelect.IsExist()) {
+ bSelect = place.WordCmp(wrSelect.BeginPos) > 0 &&
+ place.WordCmp(wrSelect.EndPos) <= 0;
+ if (bSelect) {
+ crCurFill = crWhite;
+ } else {
crCurFill = crTextFill;
- crOldFill = crCurFill;
}
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- if (bSelect) {
- CPVT_Line line;
- pIterator->GetLine(line);
-
- if (pSystemHandler && pSystemHandler->IsSelectionImplemented()) {
- CFX_FloatRect rc(word.ptWord.x, line.ptLine.y + line.fLineDescent,
- word.ptWord.x + word.fWidth,
- line.ptLine.y + line.fLineAscent);
- rc.Intersect(rcClip);
- pSystemHandler->OutputSelectedRect(pFFLData, rc);
- } else {
- CFX_PathData pathSelBK;
- pathSelBK.AppendRect(word.ptWord.x,
- line.ptLine.y + line.fLineDescent,
- word.ptWord.x + word.fWidth,
- line.ptLine.y + line.fLineAscent);
-
- pDevice->DrawPath(&pathSelBK, pUser2Device, NULL, crSelBK, 0,
- FXFILL_WINDING);
- }
+ }
+ if (pSystemHandler && pSystemHandler->IsSelectionImplemented()) {
+ crCurFill = crTextFill;
+ crOldFill = crCurFill;
+ }
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ if (bSelect) {
+ CPVT_Line line;
+ pIterator->GetLine(line);
+
+ if (pSystemHandler && pSystemHandler->IsSelectionImplemented()) {
+ CFX_FloatRect rc(word.ptWord.x, line.ptLine.y + line.fLineDescent,
+ word.ptWord.x + word.fWidth,
+ line.ptLine.y + line.fLineAscent);
+ rc.Intersect(rcClip);
+ pSystemHandler->OutputSelectedRect(pFFLData, rc);
+ } else {
+ CFX_PathData pathSelBK;
+ pathSelBK.AppendRect(
+ word.ptWord.x, line.ptLine.y + line.fLineDescent,
+ word.ptWord.x + word.fWidth, line.ptLine.y + line.fLineAscent);
+
+ pDevice->DrawPath(&pathSelBK, pUser2Device, NULL, crSelBK, 0,
+ FXFILL_WINDING);
}
+ }
- if (bContinuous) {
- if (place.LineCmp(oldplace) != 0 || word.nFontIndex != nFontIndex ||
- crOldFill != crCurFill) {
- if (sTextBuf.GetLength() > 0) {
- DrawTextString(
- pDevice,
- CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
- pFontMap->GetPDFFont(nFontIndex), fFontSize, pUser2Device,
- sTextBuf.AsStringC(), crOldFill, crTextStroke, nHorzScale);
-
- sTextBuf.Clear();
- }
- nFontIndex = word.nFontIndex;
- ptBT = word.ptWord;
- crOldFill = crCurFill;
- }
+ if (bContinuous) {
+ if (place.LineCmp(oldplace) != 0 || word.nFontIndex != nFontIndex ||
+ crOldFill != crCurFill) {
+ if (sTextBuf.GetLength() > 0) {
+ DrawTextString(
+ pDevice,
+ CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
+ pFontMap->GetPDFFont(nFontIndex), fFontSize, pUser2Device,
+ sTextBuf.AsStringC(), crOldFill, crTextStroke, nHorzScale);
- sTextBuf << GetPDFWordString(pFontMap, word.nFontIndex, word.Word,
- SubWord)
- .AsStringC();
- } else {
- DrawTextString(
- pDevice, CFX_FloatPoint(word.ptWord.x + ptOffset.x,
- word.ptWord.y + ptOffset.y),
- pFontMap->GetPDFFont(word.nFontIndex), fFontSize, pUser2Device,
- GetPDFWordString(pFontMap, word.nFontIndex, word.Word, SubWord),
- crCurFill, crTextStroke, nHorzScale);
+ sTextBuf.Clear();
+ }
+ nFontIndex = word.nFontIndex;
+ ptBT = word.ptWord;
+ crOldFill = crCurFill;
}
- oldplace = place;
+
+ sTextBuf << GetPDFWordString(pFontMap, word.nFontIndex, word.Word,
+ SubWord)
+ .AsStringC();
+ } else {
+ DrawTextString(
+ pDevice, CFX_FloatPoint(word.ptWord.x + ptOffset.x,
+ word.ptWord.y + ptOffset.y),
+ pFontMap->GetPDFFont(word.nFontIndex), fFontSize, pUser2Device,
+ GetPDFWordString(pFontMap, word.nFontIndex, word.Word, SubWord),
+ crCurFill, crTextStroke, nHorzScale);
}
+ oldplace = place;
}
+ }
- if (sTextBuf.GetLength() > 0) {
- DrawTextString(
- pDevice, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
- pFontMap->GetPDFFont(nFontIndex), fFontSize, pUser2Device,
- sTextBuf.AsStringC(), crOldFill, crTextStroke, nHorzScale);
- }
+ if (sTextBuf.GetLength() > 0) {
+ DrawTextString(pDevice,
+ CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
+ pFontMap->GetPDFFont(nFontIndex), fFontSize, pUser2Device,
+ sTextBuf.AsStringC(), crOldFill, crTextStroke, nHorzScale);
}
}
@@ -297,102 +294,100 @@ void IFX_Edit::DrawRichEdit(CFX_RenderDevice* pDevice,
pDevice->SetClip_Rect(rcTemp.ToFxRect());
}
- if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
- if (IPVT_FontMap* pFontMap = pEdit->GetFontMap()) {
- if (pRange)
- pIterator->SetAt(pRange->BeginPos);
- else
- pIterator->SetAt(0);
+ IFX_Edit_Iterator* pIterator = pEdit->GetIterator();
+ if (IPVT_FontMap* pFontMap = pEdit->GetFontMap()) {
+ if (pRange)
+ pIterator->SetAt(pRange->BeginPos);
+ else
+ pIterator->SetAt(0);
- CPVT_WordPlace oldplace;
+ CPVT_WordPlace oldplace;
- while (pIterator->NextWord()) {
- CPVT_WordPlace place = pIterator->GetAt();
- if (pRange && place.WordCmp(pRange->EndPos) > 0)
- break;
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
+ if (pRange && place.WordCmp(pRange->EndPos) > 0)
+ break;
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- word.WordProps.fFontSize = word.fFontSize;
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ word.WordProps.fFontSize = word.fFontSize;
- crCurText = ArgbEncode(255, word.WordProps.dwWordColor);
+ crCurText = ArgbEncode(255, word.WordProps.dwWordColor);
- if (wrSelect.IsExist()) {
- bSelect = place.WordCmp(wrSelect.BeginPos) > 0 &&
- place.WordCmp(wrSelect.EndPos) <= 0;
- if (bSelect) {
- crCurText = crWhite;
- }
+ if (wrSelect.IsExist()) {
+ bSelect = place.WordCmp(wrSelect.BeginPos) > 0 &&
+ place.WordCmp(wrSelect.EndPos) <= 0;
+ if (bSelect) {
+ crCurText = crWhite;
}
+ }
- if (bSelect) {
- CPVT_Line line;
- pIterator->GetLine(line);
+ if (bSelect) {
+ CPVT_Line line;
+ pIterator->GetLine(line);
- CFX_PathData pathSelBK;
- pathSelBK.AppendRect(word.ptWord.x + ptOffset.x,
- line.ptLine.y + line.fLineDescent + ptOffset.y,
- word.ptWord.x + word.fWidth + ptOffset.x,
- line.ptLine.y + line.fLineAscent + ptOffset.y);
+ CFX_PathData pathSelBK;
+ pathSelBK.AppendRect(word.ptWord.x + ptOffset.x,
+ line.ptLine.y + line.fLineDescent + ptOffset.y,
+ word.ptWord.x + word.fWidth + ptOffset.x,
+ line.ptLine.y + line.fLineAscent + ptOffset.y);
- pDevice->DrawPath(&pathSelBK, pUser2Device, NULL, crSelBK, 0,
- FXFILL_WINDING);
- }
+ pDevice->DrawPath(&pathSelBK, pUser2Device, NULL, crSelBK, 0,
+ FXFILL_WINDING);
+ }
- if (place.LineCmp(oldplace) != 0 ||
- word.WordProps.fCharSpace > 0.0f ||
- word.WordProps.nHorzScale != 100 ||
- FXSYS_memcmp(&word.WordProps, &wp, sizeof(CPVT_WordProps)) != 0 ||
- crOld != crCurText) {
- if (sTextBuf.GetLength() > 0) {
- DrawTextString(
- pDevice,
- CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
- pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize,
- pUser2Device, sTextBuf.AsStringC(), crOld, 0, wp.nHorzScale);
+ if (place.LineCmp(oldplace) != 0 || word.WordProps.fCharSpace > 0.0f ||
+ word.WordProps.nHorzScale != 100 ||
+ FXSYS_memcmp(&word.WordProps, &wp, sizeof(CPVT_WordProps)) != 0 ||
+ crOld != crCurText) {
+ if (sTextBuf.GetLength() > 0) {
+ DrawTextString(
+ pDevice,
+ CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
+ pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, pUser2Device,
+ sTextBuf.AsStringC(), crOld, 0, wp.nHorzScale);
- sTextBuf.Clear();
- }
- wp = word.WordProps;
- ptBT = word.ptWord;
- crOld = crCurText;
+ sTextBuf.Clear();
}
+ wp = word.WordProps;
+ ptBT = word.ptWord;
+ crOld = crCurText;
+ }
- sTextBuf << GetPDFWordString(pFontMap, word.WordProps.nFontIndex,
- word.Word, 0)
- .AsStringC();
-
- if (word.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) {
- CFX_PathData pathUnderline;
- CFX_FloatRect rcUnderline = GetUnderLineRect(word);
- pathUnderline.AppendRect(rcUnderline.left, rcUnderline.bottom,
- rcUnderline.right, rcUnderline.top);
+ sTextBuf << GetPDFWordString(pFontMap, word.WordProps.nFontIndex,
+ word.Word, 0)
+ .AsStringC();
- pDevice->DrawPath(&pathUnderline, pUser2Device, NULL, crCurText, 0,
- FXFILL_WINDING);
- }
+ if (word.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) {
+ CFX_PathData pathUnderline;
+ CFX_FloatRect rcUnderline = GetUnderLineRect(word);
+ pathUnderline.AppendRect(rcUnderline.left, rcUnderline.bottom,
+ rcUnderline.right, rcUnderline.top);
- if (word.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) {
- CFX_PathData pathCrossout;
- CFX_FloatRect rcCrossout = GetCrossoutRect(word);
- pathCrossout.AppendRect(rcCrossout.left, rcCrossout.bottom,
- rcCrossout.right, rcCrossout.top);
+ pDevice->DrawPath(&pathUnderline, pUser2Device, NULL, crCurText, 0,
+ FXFILL_WINDING);
+ }
- pDevice->DrawPath(&pathCrossout, pUser2Device, NULL, crCurText, 0,
- FXFILL_WINDING);
- }
+ if (word.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) {
+ CFX_PathData pathCrossout;
+ CFX_FloatRect rcCrossout = GetCrossoutRect(word);
+ pathCrossout.AppendRect(rcCrossout.left, rcCrossout.bottom,
+ rcCrossout.right, rcCrossout.top);
- oldplace = place;
+ pDevice->DrawPath(&pathCrossout, pUser2Device, NULL, crCurText, 0,
+ FXFILL_WINDING);
}
- }
- if (sTextBuf.GetLength() > 0) {
- DrawTextString(
- pDevice, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
- pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, pUser2Device,
- sTextBuf.AsStringC(), crOld, 0, wp.nHorzScale);
+ oldplace = place;
}
}
+
+ if (sTextBuf.GetLength() > 0) {
+ DrawTextString(
+ pDevice, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
+ pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, pUser2Device,
+ sTextBuf.AsStringC(), crOld, 0, wp.nHorzScale);
+ }
}
pDevice->RestoreState();
@@ -471,52 +466,49 @@ void IFX_Edit::GeneratePageObjects(
ObjArray.RemoveAll();
- if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
- if (IPVT_FontMap* pFontMap = pEdit->GetFontMap()) {
- if (pRange)
- pIterator->SetAt(pRange->BeginPos);
- else
- pIterator->SetAt(0);
-
- CPVT_WordPlace oldplace;
-
- while (pIterator->NextWord()) {
- CPVT_WordPlace place = pIterator->GetAt();
- if (pRange && place.WordCmp(pRange->EndPos) > 0)
- break;
-
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- if (place.LineCmp(oldplace) != 0 ||
- nOldFontIndex != word.nFontIndex) {
- if (sTextBuf.GetLength() > 0) {
- ObjArray.Add(AddTextObjToPageObjects(
- pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex),
- fFontSize, 0.0f, 100,
- CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
- sTextBuf.AsStringC()));
-
- sTextBuf.Clear();
- }
-
- ptBT = word.ptWord;
- nOldFontIndex = word.nFontIndex;
+ IFX_Edit_Iterator* pIterator = pEdit->GetIterator();
+ if (IPVT_FontMap* pFontMap = pEdit->GetFontMap()) {
+ if (pRange)
+ pIterator->SetAt(pRange->BeginPos);
+ else
+ pIterator->SetAt(0);
+
+ CPVT_WordPlace oldplace;
+
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
+ if (pRange && place.WordCmp(pRange->EndPos) > 0)
+ break;
+
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ if (place.LineCmp(oldplace) != 0 || nOldFontIndex != word.nFontIndex) {
+ if (sTextBuf.GetLength() > 0) {
+ ObjArray.Add(AddTextObjToPageObjects(
+ pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex),
+ fFontSize, 0.0f, 100,
+ CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
+ sTextBuf.AsStringC()));
+
+ sTextBuf.Clear();
}
- sTextBuf << GetPDFWordString(pFontMap, word.nFontIndex, word.Word, 0)
- .AsStringC();
- oldplace = place;
+ ptBT = word.ptWord;
+ nOldFontIndex = word.nFontIndex;
}
- }
- if (sTextBuf.GetLength() > 0) {
- ObjArray.Add(AddTextObjToPageObjects(
- pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex),
- fFontSize, 0.0f, 100,
- CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
- sTextBuf.AsStringC()));
+ sTextBuf << GetPDFWordString(pFontMap, word.nFontIndex, word.Word, 0)
+ .AsStringC();
+ oldplace = place;
}
}
+
+ if (sTextBuf.GetLength() > 0) {
+ ObjArray.Add(AddTextObjToPageObjects(
+ pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex), fFontSize,
+ 0.0f, 100, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
+ sTextBuf.AsStringC()));
+ }
}
}
@@ -535,82 +527,80 @@ void IFX_Edit::GenerateRichPageObjects(
ObjArray.RemoveAll();
- if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
- if (IPVT_FontMap* pFontMap = pEdit->GetFontMap()) {
- if (pRange)
- pIterator->SetAt(pRange->BeginPos);
- else
- pIterator->SetAt(0);
-
- CPVT_WordPlace oldplace;
-
- while (pIterator->NextWord()) {
- CPVT_WordPlace place = pIterator->GetAt();
- if (pRange && place.WordCmp(pRange->EndPos) > 0)
- break;
-
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- word.WordProps.fFontSize = word.fFontSize;
-
- crCurText = ArgbEncode(255, word.WordProps.dwWordColor);
-
- if (place.LineCmp(oldplace) != 0 ||
- word.WordProps.fCharSpace > 0.0f ||
- word.WordProps.nHorzScale != 100 ||
- FXSYS_memcmp(&word.WordProps, &wp, sizeof(CPVT_WordProps)) != 0 ||
- crOld != crCurText) {
- if (sTextBuf.GetLength() > 0) {
- ObjArray.Add(AddTextObjToPageObjects(
- pObjectHolder, crOld, pFontMap->GetPDFFont(wp.nFontIndex),
- wp.fFontSize, wp.fCharSpace, wp.nHorzScale,
- CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
- sTextBuf.AsStringC()));
-
- sTextBuf.Clear();
- }
-
- wp = word.WordProps;
- ptBT = word.ptWord;
- crOld = crCurText;
+ IFX_Edit_Iterator* pIterator = pEdit->GetIterator();
+ if (IPVT_FontMap* pFontMap = pEdit->GetFontMap()) {
+ if (pRange)
+ pIterator->SetAt(pRange->BeginPos);
+ else
+ pIterator->SetAt(0);
+
+ CPVT_WordPlace oldplace;
+
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
+ if (pRange && place.WordCmp(pRange->EndPos) > 0)
+ break;
+
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ word.WordProps.fFontSize = word.fFontSize;
+
+ crCurText = ArgbEncode(255, word.WordProps.dwWordColor);
+
+ if (place.LineCmp(oldplace) != 0 || word.WordProps.fCharSpace > 0.0f ||
+ word.WordProps.nHorzScale != 100 ||
+ FXSYS_memcmp(&word.WordProps, &wp, sizeof(CPVT_WordProps)) != 0 ||
+ crOld != crCurText) {
+ if (sTextBuf.GetLength() > 0) {
+ ObjArray.Add(AddTextObjToPageObjects(
+ pObjectHolder, crOld, pFontMap->GetPDFFont(wp.nFontIndex),
+ wp.fFontSize, wp.fCharSpace, wp.nHorzScale,
+ CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
+ sTextBuf.AsStringC()));
+
+ sTextBuf.Clear();
}
- sTextBuf << GetPDFWordString(pFontMap, word.WordProps.nFontIndex,
- word.Word, 0)
- .AsStringC();
+ wp = word.WordProps;
+ ptBT = word.ptWord;
+ crOld = crCurText;
+ }
- if (word.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) {
- CFX_FloatRect rcUnderline = GetUnderLineRect(word);
- rcUnderline.left += ptOffset.x;
- rcUnderline.right += ptOffset.x;
- rcUnderline.top += ptOffset.y;
- rcUnderline.bottom += ptOffset.y;
+ sTextBuf << GetPDFWordString(pFontMap, word.WordProps.nFontIndex,
+ word.Word, 0)
+ .AsStringC();
- AddRectToPageObjects(pObjectHolder, crCurText, rcUnderline);
- }
+ if (word.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) {
+ CFX_FloatRect rcUnderline = GetUnderLineRect(word);
+ rcUnderline.left += ptOffset.x;
+ rcUnderline.right += ptOffset.x;
+ rcUnderline.top += ptOffset.y;
+ rcUnderline.bottom += ptOffset.y;
- if (word.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) {
- CFX_FloatRect rcCrossout = GetCrossoutRect(word);
- rcCrossout.left += ptOffset.x;
- rcCrossout.right += ptOffset.x;
- rcCrossout.top += ptOffset.y;
- rcCrossout.bottom += ptOffset.y;
+ AddRectToPageObjects(pObjectHolder, crCurText, rcUnderline);
+ }
- AddRectToPageObjects(pObjectHolder, crCurText, rcCrossout);
- }
+ if (word.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) {
+ CFX_FloatRect rcCrossout = GetCrossoutRect(word);
+ rcCrossout.left += ptOffset.x;
+ rcCrossout.right += ptOffset.x;
+ rcCrossout.top += ptOffset.y;
+ rcCrossout.bottom += ptOffset.y;
- oldplace = place;
+ AddRectToPageObjects(pObjectHolder, crCurText, rcCrossout);
}
- }
- if (sTextBuf.GetLength() > 0) {
- ObjArray.Add(AddTextObjToPageObjects(
- pObjectHolder, crOld, pFontMap->GetPDFFont(wp.nFontIndex),
- wp.fFontSize, wp.fCharSpace, wp.nHorzScale,
- CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
- sTextBuf.AsStringC()));
+ oldplace = place;
}
}
+
+ if (sTextBuf.GetLength() > 0) {
+ ObjArray.Add(AddTextObjToPageObjects(
+ pObjectHolder, crOld, pFontMap->GetPDFFont(wp.nFontIndex),
+ wp.fFontSize, wp.fCharSpace, wp.nHorzScale,
+ CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
+ sTextBuf.AsStringC()));
+ }
}
}
@@ -619,29 +609,28 @@ void IFX_Edit::GenerateUnderlineObjects(CPDF_PageObjectHolder* pObjectHolder,
const CFX_FloatPoint& ptOffset,
const CPVT_WordRange* pRange,
FX_COLORREF color) {
- if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
- if (pEdit->GetFontMap()) {
- if (pRange)
- pIterator->SetAt(pRange->BeginPos);
- else
- pIterator->SetAt(0);
-
- CPVT_WordPlace oldplace;
-
- while (pIterator->NextWord()) {
- CPVT_WordPlace place = pIterator->GetAt();
- if (pRange && place.WordCmp(pRange->EndPos) > 0)
- break;
-
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- CFX_FloatRect rcUnderline = GetUnderLineRect(word);
- rcUnderline.left += ptOffset.x;
- rcUnderline.right += ptOffset.x;
- rcUnderline.top += ptOffset.y;
- rcUnderline.bottom += ptOffset.y;
- AddRectToPageObjects(pObjectHolder, color, rcUnderline);
- }
+ IFX_Edit_Iterator* pIterator = pEdit->GetIterator();
+ if (pEdit->GetFontMap()) {
+ if (pRange)
+ pIterator->SetAt(pRange->BeginPos);
+ else
+ pIterator->SetAt(0);
+
+ CPVT_WordPlace oldplace;
+
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
+ if (pRange && place.WordCmp(pRange->EndPos) > 0)
+ break;
+
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ CFX_FloatRect rcUnderline = GetUnderLineRect(word);
+ rcUnderline.left += ptOffset.x;
+ rcUnderline.right += ptOffset.x;
+ rcUnderline.top += ptOffset.y;
+ rcUnderline.bottom += ptOffset.y;
+ AddRectToPageObjects(pObjectHolder, color, rcUnderline);
}
}
}