OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "xfa/fxfa/app/xfa_textlayout.h" | 7 #include "xfa/fxfa/app/xfa_textlayout.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "core/fxcrt/include/fx_ext.h" | 11 #include "core/fxcrt/include/fx_ext.h" |
| 12 #include "xfa/fde/cfde_path.h" |
12 #include "xfa/fde/css/fde_csscache.h" | 13 #include "xfa/fde/css/fde_csscache.h" |
| 14 #include "xfa/fde/fde_gedevice.h" |
13 #include "xfa/fde/fde_object.h" | 15 #include "xfa/fde/fde_object.h" |
14 #include "xfa/fde/xml/fde_xml_imp.h" | 16 #include "xfa/fde/xml/fde_xml_imp.h" |
15 #include "xfa/fgas/crt/fgas_algorithm.h" | 17 #include "xfa/fgas/crt/fgas_algorithm.h" |
16 #include "xfa/fgas/crt/fgas_codepage.h" | 18 #include "xfa/fgas/crt/fgas_codepage.h" |
17 #include "xfa/fxfa/app/xfa_ffwidgetacc.h" | 19 #include "xfa/fxfa/app/xfa_ffwidgetacc.h" |
18 #include "xfa/fxfa/include/xfa_ffapp.h" | 20 #include "xfa/fxfa/include/xfa_ffapp.h" |
19 #include "xfa/fxfa/include/xfa_ffdoc.h" | 21 #include "xfa/fxfa/include/xfa_ffdoc.h" |
20 #include "xfa/fxfa/include/xfa_fontmgr.h" | 22 #include "xfa/fxfa/include/xfa_fontmgr.h" |
21 | 23 |
22 CXFA_CSSTagProvider::~CXFA_CSSTagProvider() { | 24 CXFA_CSSTagProvider::~CXFA_CSSTagProvider() { |
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1209 } | 1211 } |
1210 if (iCountHeight > 0 && (i - iLineIndex) > 0 && bEndItem) { | 1212 if (iCountHeight > 0 && (i - iLineIndex) > 0 && bEndItem) { |
1211 m_Blocks.Add(iLineIndex); | 1213 m_Blocks.Add(iLineIndex); |
1212 m_Blocks.Add(i - iLineIndex); | 1214 m_Blocks.Add(i - iLineIndex); |
1213 } | 1215 } |
1214 } | 1216 } |
1215 FX_BOOL CXFA_TextLayout::DrawString(CFX_RenderDevice* pFxDevice, | 1217 FX_BOOL CXFA_TextLayout::DrawString(CFX_RenderDevice* pFxDevice, |
1216 const CFX_Matrix& tmDoc2Device, | 1218 const CFX_Matrix& tmDoc2Device, |
1217 const CFX_RectF& rtClip, | 1219 const CFX_RectF& rtClip, |
1218 int32_t iBlock) { | 1220 int32_t iBlock) { |
1219 IFDE_RenderDevice* pDevice = IFDE_RenderDevice::Create(pFxDevice); | 1221 if (!pFxDevice) |
1220 if (pDevice == NULL) { | |
1221 return FALSE; | 1222 return FALSE; |
1222 } | 1223 |
| 1224 CFDE_RenderDevice* pDevice = new CFDE_RenderDevice(pFxDevice, FALSE); |
1223 FDE_HDEVICESTATE state = pDevice->SaveState(); | 1225 FDE_HDEVICESTATE state = pDevice->SaveState(); |
1224 pDevice->SetClipRect(rtClip); | 1226 pDevice->SetClipRect(rtClip); |
1225 CFDE_Brush* pSolidBrush = new CFDE_Brush; | 1227 CFDE_Brush* pSolidBrush = new CFDE_Brush; |
1226 CFDE_Pen* pPen = new CFDE_Pen; | 1228 CFDE_Pen* pPen = new CFDE_Pen; |
1227 FXSYS_assert(pDevice); | 1229 FXSYS_assert(pDevice); |
1228 | 1230 |
1229 if (m_pieceLines.GetSize() == 0) { | 1231 if (m_pieceLines.GetSize() == 0) { |
1230 int32_t iBlockCount = CountBlocks(); | 1232 int32_t iBlockCount = CountBlocks(); |
1231 for (int32_t i = 0; i < iBlockCount; i++) { | 1233 for (int32_t i = 0; i < iBlockCount; i++) { |
1232 Layout(i); | 1234 Layout(i); |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1831 FX_FLOAT fTextIndent = | 1833 FX_FLOAT fTextIndent = |
1832 pStyle->GetParagraphStyles()->GetTextIndent().GetValue(); | 1834 pStyle->GetParagraphStyles()->GetTextIndent().GetValue(); |
1833 if (fTextIndent < 0) { | 1835 if (fTextIndent < 0) { |
1834 fStart -= fTextIndent; | 1836 fStart -= fTextIndent; |
1835 } | 1837 } |
1836 m_pBreak->SetLineStartPos(fStart); | 1838 m_pBreak->SetLineStartPos(fStart); |
1837 pStyle->Release(); | 1839 pStyle->Release(); |
1838 } | 1840 } |
1839 m_iLines++; | 1841 m_iLines++; |
1840 } | 1842 } |
1841 void CXFA_TextLayout::RenderString(IFDE_RenderDevice* pDevice, | 1843 void CXFA_TextLayout::RenderString(CFDE_RenderDevice* pDevice, |
1842 CFDE_Brush* pBrush, | 1844 CFDE_Brush* pBrush, |
1843 CXFA_PieceLine* pPieceLine, | 1845 CXFA_PieceLine* pPieceLine, |
1844 int32_t iPiece, | 1846 int32_t iPiece, |
1845 FXTEXT_CHARPOS* pCharPos, | 1847 FXTEXT_CHARPOS* pCharPos, |
1846 const CFX_Matrix& tmDoc2Device) { | 1848 const CFX_Matrix& tmDoc2Device) { |
1847 const XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(iPiece); | 1849 const XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(iPiece); |
1848 int32_t iCount = GetDisplayPos(pPiece, pCharPos); | 1850 int32_t iCount = GetDisplayPos(pPiece, pCharPos); |
1849 if (iCount > 0) { | 1851 if (iCount > 0) { |
1850 pBrush->SetColor(pPiece->dwColor); | 1852 pBrush->SetColor(pPiece->dwColor); |
1851 pDevice->DrawString(pBrush, pPiece->pFont, pCharPos, iCount, | 1853 pDevice->DrawString(pBrush, pPiece->pFont, pCharPos, iCount, |
1852 pPiece->fFontSize, &tmDoc2Device); | 1854 pPiece->fFontSize, &tmDoc2Device); |
1853 } | 1855 } |
1854 pPieceLine->m_charCounts.Add(iCount); | 1856 pPieceLine->m_charCounts.Add(iCount); |
1855 } | 1857 } |
1856 void CXFA_TextLayout::RenderPath(IFDE_RenderDevice* pDevice, | 1858 void CXFA_TextLayout::RenderPath(CFDE_RenderDevice* pDevice, |
1857 CFDE_Pen* pPen, | 1859 CFDE_Pen* pPen, |
1858 CXFA_PieceLine* pPieceLine, | 1860 CXFA_PieceLine* pPieceLine, |
1859 int32_t iPiece, | 1861 int32_t iPiece, |
1860 FXTEXT_CHARPOS* pCharPos, | 1862 FXTEXT_CHARPOS* pCharPos, |
1861 const CFX_Matrix& tmDoc2Device) { | 1863 const CFX_Matrix& tmDoc2Device) { |
1862 XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(iPiece); | 1864 XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(iPiece); |
1863 FX_BOOL bNoUnderline = pPiece->iUnderline < 1 || pPiece->iUnderline > 2; | 1865 FX_BOOL bNoUnderline = pPiece->iUnderline < 1 || pPiece->iUnderline > 2; |
1864 FX_BOOL bNoLineThrough = pPiece->iLineThrough < 1 || pPiece->iLineThrough > 2; | 1866 FX_BOOL bNoLineThrough = pPiece->iLineThrough < 1 || pPiece->iLineThrough > 2; |
1865 if (bNoUnderline && bNoLineThrough) { | 1867 if (bNoUnderline && bNoLineThrough) { |
1866 return; | 1868 return; |
1867 } | 1869 } |
1868 pPen->SetColor(pPiece->dwColor); | 1870 pPen->SetColor(pPiece->dwColor); |
1869 IFDE_Path* pPath = IFDE_Path::Create(); | 1871 CFDE_Path* pPath = new CFDE_Path; |
1870 int32_t iChars = GetDisplayPos(pPiece, pCharPos); | 1872 int32_t iChars = GetDisplayPos(pPiece, pCharPos); |
1871 if (iChars > 0) { | 1873 if (iChars > 0) { |
1872 CFX_PointF pt1, pt2; | 1874 CFX_PointF pt1, pt2; |
1873 FX_FLOAT fEndY = pCharPos[0].m_OriginY + 1.05f; | 1875 FX_FLOAT fEndY = pCharPos[0].m_OriginY + 1.05f; |
1874 int32_t i = 0; | 1876 int32_t i = 0; |
1875 if (pPiece->iPeriod == XFA_ATTRIBUTEENUM_Word) { | 1877 if (pPiece->iPeriod == XFA_ATTRIBUTEENUM_Word) { |
1876 for (int32_t i = 0; i < pPiece->iUnderline; i++) { | 1878 for (int32_t i = 0; i < pPiece->iUnderline; i++) { |
1877 for (int32_t j = 0; j < iChars; j++) { | 1879 for (int32_t j = 0; j < iChars; j++) { |
1878 pt1.x = pCharPos[j].m_OriginX; | 1880 pt1.x = pCharPos[j].m_OriginX; |
1879 pt2.x = | 1881 pt2.x = |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1990 tr.iLength = iLength; | 1992 tr.iLength = iLength; |
1991 tr.fFontSize = pPiece->fFontSize; | 1993 tr.fFontSize = pPiece->fFontSize; |
1992 tr.iBidiLevel = pPiece->iBidiLevel; | 1994 tr.iBidiLevel = pPiece->iBidiLevel; |
1993 tr.iCharRotation = 0; | 1995 tr.iCharRotation = 0; |
1994 tr.wLineBreakChar = L'\n'; | 1996 tr.wLineBreakChar = L'\n'; |
1995 tr.iVerticalScale = pPiece->iVerScale; | 1997 tr.iVerticalScale = pPiece->iVerScale; |
1996 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab; | 1998 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab; |
1997 tr.iHorizontalScale = pPiece->iHorScale; | 1999 tr.iHorizontalScale = pPiece->iHorScale; |
1998 return TRUE; | 2000 return TRUE; |
1999 } | 2001 } |
OLD | NEW |