summaryrefslogtreecommitdiff
path: root/fpdfsdk/fxedit/fxet_edit.cpp
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2017-02-14 14:58:49 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-02-14 14:59:09 +0000
commit92a32db931c1303388158f8a9e045e922d0b8dfa (patch)
tree5c6c05ffb40c1bb2653b415842537f7043bd6407 /fpdfsdk/fxedit/fxet_edit.cpp
parent4797c4240cb9e2d8cd36c583d46cd52ff94af95d (diff)
downloadpdfium-92a32db931c1303388158f8a9e045e922d0b8dfa.tar.xz
Revert "Convert CFX_FloatPoint to CFX_PointF"
This reverts commit 4797c4240cb9e2d8cd36c583d46cd52ff94af95d. Reason for revert: Reverting chain to see if fixes Chrome roll. Original change's description: > Convert CFX_FloatPoint to CFX_PointF > > The two classes store the same information, remove the CFX_FloatPoint variant. > > Change-Id: Ie598c2ba5af04fb2bb3347dd48c30fd5e4845e62 > Reviewed-on: https://pdfium-review.googlesource.com/2612 > Commit-Queue: dsinclair <dsinclair@chromium.org> > Reviewed-by: Tom Sepez <tsepez@chromium.org> > TBR=tsepez@chromium.org,dsinclair@chromium.org,pdfium-reviews@googlegroups.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: Ia42074e706983c62d2e57497c3079b3c338343a3 Reviewed-on: https://pdfium-review.googlesource.com/2694 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/fxedit/fxet_edit.cpp')
-rw-r--r--fpdfsdk/fxedit/fxet_edit.cpp104
1 files changed, 55 insertions, 49 deletions
diff --git a/fpdfsdk/fxedit/fxet_edit.cpp b/fpdfsdk/fxedit/fxet_edit.cpp
index 1d2269c0a0..1942232553 100644
--- a/fpdfsdk/fxedit/fxet_edit.cpp
+++ b/fpdfsdk/fxedit/fxet_edit.cpp
@@ -57,7 +57,7 @@ CFX_ByteString GetFontSetString(IPVT_FontMap* pFontMap,
}
void DrawTextString(CFX_RenderDevice* pDevice,
- const CFX_PointF& pt,
+ const CFX_FloatPoint& pt,
CPDF_Font* pFont,
FX_FLOAT fFontSize,
CFX_Matrix* pUser2Device,
@@ -78,8 +78,8 @@ void DrawTextString(CFX_RenderDevice* pDevice,
ro.m_ColorMode = RENDER_COLOR_NORMAL;
if (crTextStroke != 0) {
- CFX_PointF pt1;
- CFX_PointF pt2;
+ CFX_FloatPoint pt1;
+ CFX_FloatPoint pt2;
pUser2Device->TransformPoint(pt1.x, pt1.y);
pUser2Device->TransformPoint(pt2.x, pt2.y);
CFX_GraphStateData gsd;
@@ -99,8 +99,8 @@ void DrawTextString(CFX_RenderDevice* pDevice,
ro.m_ColorMode = RENDER_COLOR_NORMAL;
if (crTextStroke != 0) {
- CFX_PointF pt1;
- CFX_PointF pt2;
+ CFX_FloatPoint pt1;
+ CFX_FloatPoint pt2;
pUser2Device->TransformPoint(pt1.x, pt1.y);
pUser2Device->TransformPoint(pt2.x, pt2.y);
CFX_GraphStateData gsd;
@@ -125,7 +125,7 @@ CPDF_TextObject* AddTextObjToPageObjects(CPDF_PageObjectHolder* pObjectHolder,
FX_FLOAT fFontSize,
FX_FLOAT fCharSpace,
int32_t nHorzScale,
- const CFX_PointF& point,
+ const CFX_FloatPoint& point,
const CFX_ByteString& text) {
std::unique_ptr<CPDF_TextObject> pTxtObj(new CPDF_TextObject);
pTxtObj->m_TextState.SetFont(pFont);
@@ -640,7 +640,7 @@ void CFXEU_InsertText::Undo() {
// static
CFX_ByteString CFX_Edit::GetEditAppearanceStream(CFX_Edit* pEdit,
- const CFX_PointF& ptOffset,
+ const CFX_FloatPoint& ptOffset,
const CPVT_WordRange* pRange,
bool bContinuous,
uint16_t SubWord) {
@@ -653,8 +653,8 @@ CFX_ByteString CFX_Edit::GetEditAppearanceStream(CFX_Edit* pEdit,
CFX_ByteTextBuf sEditStream;
CFX_ByteTextBuf sWords;
int32_t nCurFontIndex = -1;
- CFX_PointF ptOld;
- CFX_PointF ptNew;
+ CFX_FloatPoint ptOld;
+ CFX_FloatPoint ptNew;
CPVT_WordPlace oldplace;
while (pIterator->NextWord()) {
@@ -671,13 +671,13 @@ CFX_ByteString CFX_Edit::GetEditAppearanceStream(CFX_Edit* pEdit,
CPVT_Word word;
if (pIterator->GetWord(word)) {
- ptNew = CFX_PointF(word.ptWord.x + ptOffset.x,
- word.ptWord.y + ptOffset.y);
+ ptNew = CFX_FloatPoint(word.ptWord.x + ptOffset.x,
+ word.ptWord.y + ptOffset.y);
} else {
CPVT_Line line;
pIterator->GetLine(line);
- ptNew = CFX_PointF(line.ptLine.x + ptOffset.x,
- line.ptLine.y + ptOffset.y);
+ ptNew = CFX_FloatPoint(line.ptLine.x + ptOffset.x,
+ line.ptLine.y + ptOffset.y);
}
if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
@@ -708,8 +708,8 @@ CFX_ByteString CFX_Edit::GetEditAppearanceStream(CFX_Edit* pEdit,
} else {
CPVT_Word word;
if (pIterator->GetWord(word)) {
- ptNew =
- CFX_PointF(word.ptWord.x + ptOffset.x, word.ptWord.y + ptOffset.y);
+ ptNew = CFX_FloatPoint(word.ptWord.x + ptOffset.x,
+ word.ptWord.y + ptOffset.y);
if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y
@@ -755,7 +755,7 @@ CFX_ByteString CFX_Edit::GetEditAppearanceStream(CFX_Edit* pEdit,
// static
CFX_ByteString CFX_Edit::GetSelectAppearanceStream(
CFX_Edit* pEdit,
- const CFX_PointF& ptOffset,
+ const CFX_FloatPoint& ptOffset,
const CPVT_WordRange* pRange) {
if (!pRange || !pRange->IsExist())
return CFX_ByteString();
@@ -788,7 +788,7 @@ void CFX_Edit::DrawEdit(CFX_RenderDevice* pDevice,
FX_COLORREF crTextFill,
FX_COLORREF crTextStroke,
const CFX_FloatRect& rcClip,
- const CFX_PointF& ptOffset,
+ const CFX_FloatPoint& ptOffset,
const CPVT_WordRange* pRange,
CFX_SystemHandler* pSystemHandler,
CFFL_FormFiller* pFFLData) {
@@ -808,7 +808,7 @@ void CFX_Edit::DrawEdit(CFX_RenderDevice* pDevice,
CFX_ByteTextBuf sTextBuf;
int32_t nFontIndex = -1;
- CFX_PointF ptBT;
+ CFX_FloatPoint ptBT;
pDevice->SaveState();
if (!rcClip.IsEmpty()) {
CFX_FloatRect rcTemp = rcClip;
@@ -866,7 +866,8 @@ void CFX_Edit::DrawEdit(CFX_RenderDevice* pDevice,
crOldFill != crCurFill) {
if (sTextBuf.GetLength() > 0) {
DrawTextString(
- pDevice, CFX_PointF(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
+ pDevice,
+ CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
pFontMap->GetPDFFont(nFontIndex), fFontSize, pUser2Device,
sTextBuf.MakeString(), crOldFill, crTextStroke, nHorzScale);
@@ -882,8 +883,8 @@ void CFX_Edit::DrawEdit(CFX_RenderDevice* pDevice,
.AsStringC();
} else {
DrawTextString(
- pDevice, CFX_PointF(word.ptWord.x + ptOffset.x,
- word.ptWord.y + ptOffset.y),
+ 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);
@@ -894,7 +895,7 @@ void CFX_Edit::DrawEdit(CFX_RenderDevice* pDevice,
if (sTextBuf.GetLength() > 0) {
DrawTextString(
- pDevice, CFX_PointF(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
+ pDevice, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
pFontMap->GetPDFFont(nFontIndex), fFontSize, pUser2Device,
sTextBuf.MakeString(), crOldFill, crTextStroke, nHorzScale);
}
@@ -906,7 +907,7 @@ void CFX_Edit::DrawEdit(CFX_RenderDevice* pDevice,
// static
void CFX_Edit::GeneratePageObjects(CPDF_PageObjectHolder* pObjectHolder,
CFX_Edit* pEdit,
- const CFX_PointF& ptOffset,
+ const CFX_FloatPoint& ptOffset,
const CPVT_WordRange* pRange,
FX_COLORREF crText,
std::vector<CPDF_TextObject*>* ObjArray) {
@@ -920,7 +921,7 @@ void CFX_Edit::GeneratePageObjects(CPDF_PageObjectHolder* pObjectHolder,
int32_t nOldFontIndex = -1;
CFX_ByteTextBuf sTextBuf;
CPVT_WordPlace oldplace;
- CFX_PointF ptBT(0.0f, 0.0f);
+ CFX_FloatPoint ptBT(0.0f, 0.0f);
CFX_Edit_Iterator* pIterator = pEdit->GetIterator();
if (pRange)
pIterator->SetAt(pRange->BeginPos);
@@ -941,7 +942,7 @@ void CFX_Edit::GeneratePageObjects(CPDF_PageObjectHolder* pObjectHolder,
ObjArray->push_back(AddTextObjToPageObjects(
pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex),
fFontSize, 0.0f, 100,
- CFX_PointF(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
+ CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
sTextBuf.MakeString()));
sTextBuf.Clear();
@@ -956,7 +957,7 @@ void CFX_Edit::GeneratePageObjects(CPDF_PageObjectHolder* pObjectHolder,
if (sTextBuf.GetLength() > 0) {
ObjArray->push_back(AddTextObjToPageObjects(
pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex), fFontSize,
- 0.0f, 100, CFX_PointF(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
+ 0.0f, 100, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
sTextBuf.MakeString()));
}
}
@@ -1016,7 +1017,7 @@ IPVT_FontMap* CFX_Edit::GetFontMap() {
void CFX_Edit::SetPlateRect(const CFX_FloatRect& rect) {
m_pVT->SetPlateRect(rect);
- m_ptScrollPos = CFX_PointF(rect.left, rect.top);
+ m_ptScrollPos = CFX_FloatPoint(rect.left, rect.top);
Paint();
}
@@ -1304,10 +1305,10 @@ CPVT_WordRange CFX_Edit::GetVisibleWordRange() const {
if (m_pVT->IsValid()) {
CFX_FloatRect rcPlate = m_pVT->GetPlateRect();
- CPVT_WordPlace place1 =
- m_pVT->SearchWordPlace(EditToVT(CFX_PointF(rcPlate.left, rcPlate.top)));
+ CPVT_WordPlace place1 = m_pVT->SearchWordPlace(
+ EditToVT(CFX_FloatPoint(rcPlate.left, rcPlate.top)));
CPVT_WordPlace place2 = m_pVT->SearchWordPlace(
- EditToVT(CFX_PointF(rcPlate.right, rcPlate.bottom)));
+ EditToVT(CFX_FloatPoint(rcPlate.right, rcPlate.bottom)));
return CPVT_WordRange(place1, place2);
}
@@ -1315,7 +1316,7 @@ CPVT_WordRange CFX_Edit::GetVisibleWordRange() const {
return CPVT_WordRange();
}
-CPVT_WordPlace CFX_Edit::SearchWordPlace(const CFX_PointF& point) const {
+CPVT_WordPlace CFX_Edit::SearchWordPlace(const CFX_FloatPoint& point) const {
if (m_pVT->IsValid()) {
return m_pVT->SearchWordPlace(EditToVT(point));
}
@@ -1392,7 +1393,7 @@ bool CFX_Edit::IsSelected() const {
return m_SelState.IsExist();
}
-CFX_PointF CFX_Edit::VTToEdit(const CFX_PointF& point) const {
+CFX_FloatPoint CFX_Edit::VTToEdit(const CFX_FloatPoint& point) const {
CFX_FloatRect rcContent = m_pVT->GetContentRect();
CFX_FloatRect rcPlate = m_pVT->GetPlateRect();
@@ -1410,11 +1411,11 @@ CFX_PointF CFX_Edit::VTToEdit(const CFX_PointF& point) const {
break;
}
- return CFX_PointF(point.x - (m_ptScrollPos.x - rcPlate.left),
- point.y - (m_ptScrollPos.y + fPadding - rcPlate.top));
+ return CFX_FloatPoint(point.x - (m_ptScrollPos.x - rcPlate.left),
+ point.y - (m_ptScrollPos.y + fPadding - rcPlate.top));
}
-CFX_PointF CFX_Edit::EditToVT(const CFX_PointF& point) const {
+CFX_FloatPoint CFX_Edit::EditToVT(const CFX_FloatPoint& point) const {
CFX_FloatRect rcContent = m_pVT->GetContentRect();
CFX_FloatRect rcPlate = m_pVT->GetPlateRect();
@@ -1432,13 +1433,14 @@ CFX_PointF CFX_Edit::EditToVT(const CFX_PointF& point) const {
break;
}
- return CFX_PointF(point.x + (m_ptScrollPos.x - rcPlate.left),
- point.y + (m_ptScrollPos.y + fPadding - rcPlate.top));
+ return CFX_FloatPoint(point.x + (m_ptScrollPos.x - rcPlate.left),
+ point.y + (m_ptScrollPos.y + fPadding - rcPlate.top));
}
CFX_FloatRect CFX_Edit::VTToEdit(const CFX_FloatRect& rect) const {
- CFX_PointF ptLeftBottom = VTToEdit(CFX_PointF(rect.left, rect.bottom));
- CFX_PointF ptRightTop = VTToEdit(CFX_PointF(rect.right, rect.top));
+ CFX_FloatPoint ptLeftBottom =
+ VTToEdit(CFX_FloatPoint(rect.left, rect.bottom));
+ CFX_FloatPoint ptRightTop = VTToEdit(CFX_FloatPoint(rect.right, rect.top));
return CFX_FloatRect(ptLeftBottom.x, ptLeftBottom.y, ptRightTop.x,
ptRightTop.y);
@@ -1491,14 +1493,14 @@ void CFX_Edit::SetScrollPosY(FX_FLOAT fy) {
}
}
-void CFX_Edit::SetScrollPos(const CFX_PointF& point) {
+void CFX_Edit::SetScrollPos(const CFX_FloatPoint& point) {
SetScrollPosX(point.x);
SetScrollPosY(point.y);
SetScrollLimit();
SetCaretInfo();
}
-CFX_PointF CFX_Edit::GetScrollPos() const {
+CFX_FloatPoint CFX_Edit::GetScrollPos() const {
return m_ptScrollPos;
}
@@ -1540,8 +1542,8 @@ void CFX_Edit::ScrollToCaret() {
CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator();
pIterator->SetAt(m_wpCaret);
- CFX_PointF ptHead;
- CFX_PointF ptFoot;
+ CFX_FloatPoint ptHead;
+ CFX_FloatPoint ptFoot;
CPVT_Word word;
CPVT_Line line;
if (pIterator->GetWord(word)) {
@@ -1556,8 +1558,8 @@ void CFX_Edit::ScrollToCaret() {
ptFoot.y = line.ptLine.y + line.fLineDescent;
}
- CFX_PointF ptHeadEdit = VTToEdit(ptHead);
- CFX_PointF ptFootEdit = VTToEdit(ptFoot);
+ CFX_FloatPoint ptHeadEdit = VTToEdit(ptHead);
+ CFX_FloatPoint ptFootEdit = VTToEdit(ptFoot);
CFX_FloatRect rcPlate = m_pVT->GetPlateRect();
if (!IsFloatEqual(rcPlate.left, rcPlate.right)) {
if (IsFloatSmaller(ptHeadEdit.x, rcPlate.left) ||
@@ -1699,8 +1701,8 @@ void CFX_Edit::SetCaretInfo() {
CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator();
pIterator->SetAt(m_wpCaret);
- CFX_PointF ptHead;
- CFX_PointF ptFoot;
+ CFX_FloatPoint ptHead;
+ CFX_FloatPoint ptFoot;
CPVT_Word word;
CPVT_Line line;
if (pIterator->GetWord(word)) {
@@ -1735,7 +1737,9 @@ void CFX_Edit::SetCaret(int32_t nPos) {
}
}
-void CFX_Edit::OnMouseDown(const CFX_PointF& point, bool bShift, bool bCtrl) {
+void CFX_Edit::OnMouseDown(const CFX_FloatPoint& point,
+ bool bShift,
+ bool bCtrl) {
if (m_pVT->IsValid()) {
SelectNone();
SetCaret(m_pVT->SearchWordPlace(EditToVT(point)));
@@ -1747,7 +1751,9 @@ void CFX_Edit::OnMouseDown(const CFX_PointF& point, bool bShift, bool bCtrl) {
}
}
-void CFX_Edit::OnMouseMove(const CFX_PointF& point, bool bShift, bool bCtrl) {
+void CFX_Edit::OnMouseMove(const CFX_FloatPoint& point,
+ bool bShift,
+ bool bCtrl) {
if (m_pVT->IsValid()) {
SetCaret(m_pVT->SearchWordPlace(EditToVT(point)));