From acd0d59e3c09f04bffd178aecd3638d3e189faba Mon Sep 17 00:00:00 2001 From: dsinclair Date: Thu, 21 Apr 2016 11:06:27 -0700 Subject: Cleanup FDE interfaces. This CL removes IFDE_TextOut, IFDE_Path, IFDE_RenderContext, IFDE_RenderDevice, and IFDE_VisualSetIterator in favour of the concrete classes. BUG=pdfium:468 Review URL: https://codereview.chromium.org/1896893003 --- xfa/fxfa/app/xfa_ffpageview.cpp | 54 +++++++++++++++++++++++++++++++++++++++- xfa/fxfa/app/xfa_ffwidgetacc.cpp | 15 ++++++----- xfa/fxfa/app/xfa_fwltheme.cpp | 2 +- xfa/fxfa/app/xfa_fwltheme.h | 2 +- xfa/fxfa/app/xfa_textlayout.cpp | 14 ++++++----- xfa/fxfa/app/xfa_textlayout.h | 6 ++--- 6 files changed, 75 insertions(+), 18 deletions(-) (limited to 'xfa/fxfa') diff --git a/xfa/fxfa/app/xfa_ffpageview.cpp b/xfa/fxfa/app/xfa_ffpageview.cpp index fe2e3ab4b4..a5217abe7a 100644 --- a/xfa/fxfa/app/xfa_ffpageview.cpp +++ b/xfa/fxfa/app/xfa_ffpageview.cpp @@ -18,6 +18,58 @@ #include "xfa/fxfa/include/xfa_ffdocview.h" #include "xfa/fxfa/include/xfa_ffwidget.h" +namespace { + +void GetPageMatrix(CFX_Matrix& pageMatrix, + const CFX_RectF& docPageRect, + const CFX_Rect& devicePageRect, + int32_t iRotate, + uint32_t dwCoordinatesType) { + FXSYS_assert(iRotate >= 0 && iRotate <= 3); + FX_BOOL bFlipX = (dwCoordinatesType & 0x01) != 0; + FX_BOOL bFlipY = (dwCoordinatesType & 0x02) != 0; + CFX_Matrix m; + m.Set((bFlipX ? -1.0f : 1.0f), 0, 0, (bFlipY ? -1.0f : 1.0f), 0, 0); + if (iRotate == 0 || iRotate == 2) { + m.a *= (FX_FLOAT)devicePageRect.width / docPageRect.width; + m.d *= (FX_FLOAT)devicePageRect.height / docPageRect.height; + } else { + m.a *= (FX_FLOAT)devicePageRect.height / docPageRect.width; + m.d *= (FX_FLOAT)devicePageRect.width / docPageRect.height; + } + m.Rotate(iRotate * 1.57079632675f); + switch (iRotate) { + case 0: + m.e = bFlipX ? (FX_FLOAT)devicePageRect.right() + : (FX_FLOAT)devicePageRect.left; + m.f = bFlipY ? (FX_FLOAT)devicePageRect.bottom() + : (FX_FLOAT)devicePageRect.top; + break; + case 1: + m.e = bFlipY ? (FX_FLOAT)devicePageRect.left + : (FX_FLOAT)devicePageRect.right(); + m.f = bFlipX ? (FX_FLOAT)devicePageRect.bottom() + : (FX_FLOAT)devicePageRect.top; + break; + case 2: + m.e = bFlipX ? (FX_FLOAT)devicePageRect.left + : (FX_FLOAT)devicePageRect.right(); + m.f = bFlipY ? (FX_FLOAT)devicePageRect.top + : (FX_FLOAT)devicePageRect.bottom(); + break; + case 3: + m.e = bFlipY ? (FX_FLOAT)devicePageRect.right() + : (FX_FLOAT)devicePageRect.left; + m.f = bFlipX ? (FX_FLOAT)devicePageRect.top + : (FX_FLOAT)devicePageRect.bottom(); + break; + default: + break; + } + pageMatrix = m; +} + +} // namespace CXFA_FFPageView::CXFA_FFPageView(CXFA_FFDocView* pDocView, CXFA_Node* pPageArea) : CXFA_ContainerLayoutItem(pPageArea), m_pDocView(pDocView) {} @@ -43,7 +95,7 @@ void CXFA_FFPageView::GetDisplayMatrix(CFX_Matrix& mt, GetPageSize(sz); CFX_RectF fdePage; fdePage.Set(0, 0, sz.x, sz.y); - FDE_GetPageMatrix(mt, fdePage, rtDisp, iRotate, 0); + GetPageMatrix(mt, fdePage, rtDisp, iRotate, 0); } IXFA_WidgetIterator* CXFA_FFPageView::CreateWidgetIterator( diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.cpp b/xfa/fxfa/app/xfa_ffwidgetacc.cpp index b1214dd685..561db255d8 100644 --- a/xfa/fxfa/app/xfa_ffwidgetacc.cpp +++ b/xfa/fxfa/app/xfa_ffwidgetacc.cpp @@ -142,7 +142,7 @@ class CXFA_FieldLayoutData : public CXFA_WidgetLayoutData { } CXFA_TextLayout* m_pCapTextLayout; CXFA_TextProvider* m_pCapTextProvider; - IFDE_TextOut* m_pTextOut; + CFDE_TextOut* m_pTextOut; CFX_FloatArray* m_pFieldSplitArray; }; class CXFA_TextEditData : public CXFA_FieldLayoutData { @@ -882,9 +882,12 @@ void CXFA_WidgetAcc::CalculateTextContentSize(CFX_SizeF& size) { if (wsLast == wcEnter) { wsText = wsText + wcEnter; } - if (!((CXFA_FieldLayoutData*)m_pLayoutData)->m_pTextOut) { - ((CXFA_FieldLayoutData*)m_pLayoutData)->m_pTextOut = IFDE_TextOut::Create(); - IFDE_TextOut* pTextOut = ((CXFA_FieldLayoutData*)m_pLayoutData)->m_pTextOut; + + CXFA_FieldLayoutData* layoutData = + static_cast(m_pLayoutData); + if (!layoutData->m_pTextOut) { + layoutData->m_pTextOut = new CFDE_TextOut; + CFDE_TextOut* pTextOut = layoutData->m_pTextOut; pTextOut->SetFont(GetFDEFont()); pTextOut->SetFontSize(fFontSize); pTextOut->SetLineBreakTolerance(fFontSize * 0.2f); @@ -895,8 +898,8 @@ void CXFA_WidgetAcc::CalculateTextContentSize(CFX_SizeF& size) { } pTextOut->SetStyles(dwStyles); } - ((CXFA_FieldLayoutData*)m_pLayoutData) - ->m_pTextOut->CalcLogicSize(wsText.c_str(), wsText.GetLength(), size); + layoutData->m_pTextOut->CalcLogicSize(wsText.c_str(), wsText.GetLength(), + size); } FX_BOOL CXFA_WidgetAcc::CalculateTextEditAutoSize(CFX_SizeF& size) { if (size.x > 0) { diff --git a/xfa/fxfa/app/xfa_fwltheme.cpp b/xfa/fxfa/app/xfa_fwltheme.cpp index 82cabcc678..462c7cb090 100644 --- a/xfa/fxfa/app/xfa_fwltheme.cpp +++ b/xfa/fxfa/app/xfa_fwltheme.cpp @@ -77,7 +77,7 @@ CXFA_FWLTheme::~CXFA_FWLTheme() { delete m_pBarcodeTP; } FWL_ERR CXFA_FWLTheme::Initialize() { - m_pTextOut = IFDE_TextOut::Create(); + m_pTextOut = new CFDE_TextOut; for (size_t i = 0; !m_pCalendarFont && i < FX_ArraySize(g_FWLTheme_CalFonts); ++i) { m_pCalendarFont = IFX_Font::LoadFont(g_FWLTheme_CalFonts[i], 0, 0, diff --git a/xfa/fxfa/app/xfa_fwltheme.h b/xfa/fxfa/app/xfa_fwltheme.h index 5fda005a74..75885a5a9e 100644 --- a/xfa/fxfa/app/xfa_fwltheme.h +++ b/xfa/fxfa/app/xfa_fwltheme.h @@ -78,7 +78,7 @@ class CXFA_FWLTheme : public IFWL_ThemeProvider { CFWL_PushButtonTP* m_pPushButtonTP; CFWL_CaretTP* m_pCaretTP; CFWL_BarcodeTP* m_pBarcodeTP; - IFDE_TextOut* m_pTextOut; + CFDE_TextOut* m_pTextOut; FX_FLOAT m_fCapacity; uint32_t m_dwCapacity; IFX_Font* m_pCalendarFont; diff --git a/xfa/fxfa/app/xfa_textlayout.cpp b/xfa/fxfa/app/xfa_textlayout.cpp index 532d6f54ce..c0a8895bc7 100644 --- a/xfa/fxfa/app/xfa_textlayout.cpp +++ b/xfa/fxfa/app/xfa_textlayout.cpp @@ -9,7 +9,9 @@ #include #include "core/fxcrt/include/fx_ext.h" +#include "xfa/fde/cfde_path.h" #include "xfa/fde/css/fde_csscache.h" +#include "xfa/fde/fde_gedevice.h" #include "xfa/fde/fde_object.h" #include "xfa/fde/xml/fde_xml_imp.h" #include "xfa/fgas/crt/fgas_algorithm.h" @@ -1216,10 +1218,10 @@ FX_BOOL CXFA_TextLayout::DrawString(CFX_RenderDevice* pFxDevice, const CFX_Matrix& tmDoc2Device, const CFX_RectF& rtClip, int32_t iBlock) { - IFDE_RenderDevice* pDevice = IFDE_RenderDevice::Create(pFxDevice); - if (pDevice == NULL) { + if (!pFxDevice) return FALSE; - } + + CFDE_RenderDevice* pDevice = new CFDE_RenderDevice(pFxDevice, FALSE); FDE_HDEVICESTATE state = pDevice->SaveState(); pDevice->SetClipRect(rtClip); CFDE_Brush* pSolidBrush = new CFDE_Brush; @@ -1838,7 +1840,7 @@ void CXFA_TextLayout::AppendTextLine(uint32_t dwStatus, } m_iLines++; } -void CXFA_TextLayout::RenderString(IFDE_RenderDevice* pDevice, +void CXFA_TextLayout::RenderString(CFDE_RenderDevice* pDevice, CFDE_Brush* pBrush, CXFA_PieceLine* pPieceLine, int32_t iPiece, @@ -1853,7 +1855,7 @@ void CXFA_TextLayout::RenderString(IFDE_RenderDevice* pDevice, } pPieceLine->m_charCounts.Add(iCount); } -void CXFA_TextLayout::RenderPath(IFDE_RenderDevice* pDevice, +void CXFA_TextLayout::RenderPath(CFDE_RenderDevice* pDevice, CFDE_Pen* pPen, CXFA_PieceLine* pPieceLine, int32_t iPiece, @@ -1866,7 +1868,7 @@ void CXFA_TextLayout::RenderPath(IFDE_RenderDevice* pDevice, return; } pPen->SetColor(pPiece->dwColor); - IFDE_Path* pPath = IFDE_Path::Create(); + CFDE_Path* pPath = new CFDE_Path; int32_t iChars = GetDisplayPos(pPiece, pCharPos); if (iChars > 0) { CFX_PointF pt1, pt2; diff --git a/xfa/fxfa/app/xfa_textlayout.h b/xfa/fxfa/app/xfa_textlayout.h index 88b29e2cd4..9c3184b48b 100644 --- a/xfa/fxfa/app/xfa_textlayout.h +++ b/xfa/fxfa/app/xfa_textlayout.h @@ -8,7 +8,7 @@ #define XFA_FXFA_APP_XFA_TEXTLAYOUT_H_ #include "xfa/fde/css/fde_css.h" -#include "xfa/fde/fde_renderdevice.h" +#include "xfa/fde/fde_gedevice.h" #include "xfa/fgas/layout/fgas_rtfbreak.h" #include "xfa/fxfa/include/xfa_ffdoc.h" #include "xfa/fxfa/parser/xfa_object.h" @@ -375,13 +375,13 @@ class CXFA_TextLayout { FX_BOOL IsEnd(FX_BOOL bSavePieces); void ProcessText(CFX_WideString& wsText); void UpdateAlign(FX_FLOAT fHeight, FX_FLOAT fBottom); - void RenderString(IFDE_RenderDevice* pDevice, + void RenderString(CFDE_RenderDevice* pDevice, CFDE_Brush* pBrush, CXFA_PieceLine* pPieceLine, int32_t iPiece, FXTEXT_CHARPOS* pCharPos, const CFX_Matrix& tmDoc2Device); - void RenderPath(IFDE_RenderDevice* pDevice, + void RenderPath(CFDE_RenderDevice* pDevice, CFDE_Pen* pPen, CXFA_PieceLine* pPieceLine, int32_t iPiece, -- cgit v1.2.3