summaryrefslogtreecommitdiff
path: root/fpdfsdk/fxedit/fxet_pageobjs.cpp
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-07-13 10:55:48 -0700
committerCommit bot <commit-bot@chromium.org>2016-07-13 10:55:49 -0700
commita2919b31197737d35e4e1df53b02f7ee7cb4cf5e (patch)
tree18cf18a9081ba48d35e218279d017a6be688f029 /fpdfsdk/fxedit/fxet_pageobjs.cpp
parent38506d3334fe114fb386ea9b719d432ff1760e42 (diff)
downloadpdfium-a2919b31197737d35e4e1df53b02f7ee7cb4cf5e.tar.xz
Remove RichText support from fpdfsdk/fxedit.
This CL removes the support code for RichText from fxedit as it is currently unused. Review-Url: https://codereview.chromium.org/2146503002
Diffstat (limited to 'fpdfsdk/fxedit/fxet_pageobjs.cpp')
-rw-r--r--fpdfsdk/fxedit/fxet_pageobjs.cpp329
1 files changed, 0 insertions, 329 deletions
diff --git a/fpdfsdk/fxedit/fxet_pageobjs.cpp b/fpdfsdk/fxedit/fxet_pageobjs.cpp
index 29ad135bca..98ec6f5318 100644
--- a/fpdfsdk/fxedit/fxet_pageobjs.cpp
+++ b/fpdfsdk/fxedit/fxet_pageobjs.cpp
@@ -19,20 +19,6 @@
namespace {
-CFX_FloatRect GetUnderLineRect(const CPVT_Word& word) {
- return CFX_FloatRect(word.ptWord.x, word.ptWord.y + word.fDescent * 0.5f,
- word.ptWord.x + word.fWidth,
- word.ptWord.y + word.fDescent * 0.25f);
-}
-
-CFX_FloatRect GetCrossoutRect(const CPVT_Word& word) {
- return CFX_FloatRect(word.ptWord.x,
- word.ptWord.y + (word.fAscent + word.fDescent) * 0.5f +
- word.fDescent * 0.25f,
- word.ptWord.x + word.fWidth,
- word.ptWord.y + (word.fAscent + word.fDescent) * 0.5f);
-}
-
void DrawTextString(CFX_RenderDevice* pDevice,
const CFX_FloatPoint& pt,
CPDF_Font* pFont,
@@ -94,25 +80,6 @@ void DrawTextString(CFX_RenderDevice* pDevice,
}
}
-void AddRectToPageObjects(CPDF_PageObjectHolder* pObjectHolder,
- FX_COLORREF crFill,
- const CFX_FloatRect& rcFill) {
- std::unique_ptr<CPDF_PathObject> pPathObj(new CPDF_PathObject);
- CFX_PathData* pPathData = pPathObj->m_Path.GetModify();
- pPathData->AppendRect(rcFill.left, rcFill.bottom, rcFill.right, rcFill.top);
-
- FX_FLOAT rgb[3];
- rgb[0] = FXARGB_R(crFill) / 255.0f;
- rgb[1] = FXARGB_G(crFill) / 255.0f;
- rgb[2] = FXARGB_B(crFill) / 255.0f;
- pPathObj->m_ColorState.SetFillColor(
- CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), rgb, 3);
-
- pPathObj->m_FillType = FXFILL_ALTERNATE;
- pPathObj->m_bStroke = FALSE;
- pObjectHolder->GetPageObjectList()->push_back(std::move(pPathObj));
-}
-
CPDF_TextObject* AddTextObjToPageObjects(CPDF_PageObjectHolder* pObjectHolder,
FX_COLORREF crText,
CPDF_Font* pFont,
@@ -152,53 +119,6 @@ CPDF_TextObject* AddTextObjToPageObjects(CPDF_PageObjectHolder* pObjectHolder,
} // namespace
-void IFX_Edit::DrawUnderline(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- IFX_Edit* pEdit,
- FX_COLORREF color,
- const CFX_FloatRect& rcClip,
- const CFX_FloatPoint& ptOffset,
- const CPVT_WordRange* pRange) {
- pDevice->SaveState();
-
- if (!rcClip.IsEmpty()) {
- CFX_FloatRect rcTemp = rcClip;
- pUser2Device->TransformRect(rcTemp);
- pDevice->SetClip_Rect(rcTemp.ToFxRect());
- }
-
- 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, nullptr, color, 0,
- FXFILL_WINDING);
- }
- }
- }
-
- pDevice->RestoreState(false);
-}
-
void IFX_Edit::DrawEdit(CFX_RenderDevice* pDevice,
CFX_Matrix* pUser2Device,
IFX_Edit* pEdit,
@@ -323,131 +243,6 @@ void IFX_Edit::DrawEdit(CFX_RenderDevice* pDevice,
pDevice->RestoreState(false);
}
-void IFX_Edit::DrawRichEdit(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- IFX_Edit* pEdit,
- const CFX_FloatRect& rcClip,
- const CFX_FloatPoint& ptOffset,
- const CPVT_WordRange* pRange) {
- CPVT_WordRange wrSelect = pEdit->GetSelectWordRange();
-
- FX_COLORREF crCurText = ArgbEncode(255, 0, 0, 0);
- FX_COLORREF crOld = crCurText;
- FX_BOOL bSelect = FALSE;
- const FX_COLORREF crWhite = ArgbEncode(255, 255, 255, 255);
- const FX_COLORREF crSelBK = ArgbEncode(255, 0, 51, 113);
-
- CFX_ByteTextBuf sTextBuf;
- CPVT_WordProps wp;
- CFX_FloatPoint ptBT(0.0f, 0.0f);
-
- pDevice->SaveState();
-
- if (!rcClip.IsEmpty()) {
- CFX_FloatRect rcTemp = rcClip;
- pUser2Device->TransformRect(rcTemp);
- pDevice->SetClip_Rect(rcTemp.ToFxRect());
- }
-
- 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 (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);
-
- 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, nullptr, 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.MakeString(), crOld, 0, wp.nHorzScale);
-
- 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);
-
- pDevice->DrawPath(&pathUnderline, pUser2Device, nullptr, 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);
-
- pDevice->DrawPath(&pathCrossout, pUser2Device, nullptr, crCurText, 0,
- FXFILL_WINDING);
- }
-
- 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.MakeString(), crOld, 0, wp.nHorzScale);
- }
- }
-
- pDevice->RestoreState(false);
-}
-
void IFX_Edit::GeneratePageObjects(
CPDF_PageObjectHolder* pObjectHolder,
IFX_Edit* pEdit,
@@ -509,127 +304,3 @@ void IFX_Edit::GeneratePageObjects(
}
}
}
-
-void IFX_Edit::GenerateRichPageObjects(
- CPDF_PageObjectHolder* pObjectHolder,
- IFX_Edit* pEdit,
- const CFX_FloatPoint& ptOffset,
- const CPVT_WordRange* pRange,
- CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) {
- FX_COLORREF crCurText = ArgbEncode(255, 0, 0, 0);
- FX_COLORREF crOld = crCurText;
-
- CFX_ByteTextBuf sTextBuf;
- CPVT_WordProps wp;
- CFX_FloatPoint ptBT(0.0f, 0.0f);
-
- ObjArray.RemoveAll();
-
- 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.MakeString()));
-
- 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_FloatRect rcUnderline = GetUnderLineRect(word);
- rcUnderline.left += ptOffset.x;
- rcUnderline.right += ptOffset.x;
- rcUnderline.top += ptOffset.y;
- rcUnderline.bottom += ptOffset.y;
-
- AddRectToPageObjects(pObjectHolder, crCurText, rcUnderline);
- }
-
- 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, rcCrossout);
- }
-
- 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.MakeString()));
- }
- }
-}
-
-void IFX_Edit::GenerateUnderlineObjects(CPDF_PageObjectHolder* pObjectHolder,
- IFX_Edit* pEdit,
- const CFX_FloatPoint& ptOffset,
- const CPVT_WordRange* pRange,
- FX_COLORREF color) {
- 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);
- }
- }
- }
-}