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/css/fde_csscache.h" | 12 #include "xfa/fde/css/fde_csscache.h" |
13 #include "xfa/fde/fde_object.h" | 13 #include "xfa/fde/fde_object.h" |
14 #include "xfa/fde/fde_pen.h" | |
15 #include "xfa/fde/xml/fde_xml_imp.h" | 14 #include "xfa/fde/xml/fde_xml_imp.h" |
16 #include "xfa/fgas/crt/fgas_algorithm.h" | 15 #include "xfa/fgas/crt/fgas_algorithm.h" |
17 #include "xfa/fgas/crt/fgas_codepage.h" | 16 #include "xfa/fgas/crt/fgas_codepage.h" |
18 #include "xfa/fxfa/app/xfa_ffwidgetacc.h" | 17 #include "xfa/fxfa/app/xfa_ffwidgetacc.h" |
19 #include "xfa/fxfa/include/xfa_ffapp.h" | 18 #include "xfa/fxfa/include/xfa_ffapp.h" |
20 #include "xfa/fxfa/include/xfa_ffdoc.h" | 19 #include "xfa/fxfa/include/xfa_ffdoc.h" |
21 #include "xfa/fxfa/include/xfa_fontmgr.h" | 20 #include "xfa/fxfa/include/xfa_fontmgr.h" |
22 | 21 |
23 CXFA_CSSTagProvider::~CXFA_CSSTagProvider() { | 22 CXFA_CSSTagProvider::~CXFA_CSSTagProvider() { |
24 FX_POSITION pos = m_Attributes.GetStartPosition(); | 23 FX_POSITION pos = m_Attributes.GetStartPosition(); |
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1216 FX_BOOL CXFA_TextLayout::DrawString(CFX_RenderDevice* pFxDevice, | 1215 FX_BOOL CXFA_TextLayout::DrawString(CFX_RenderDevice* pFxDevice, |
1217 const CFX_Matrix& tmDoc2Device, | 1216 const CFX_Matrix& tmDoc2Device, |
1218 const CFX_RectF& rtClip, | 1217 const CFX_RectF& rtClip, |
1219 int32_t iBlock) { | 1218 int32_t iBlock) { |
1220 IFDE_RenderDevice* pDevice = IFDE_RenderDevice::Create(pFxDevice); | 1219 IFDE_RenderDevice* pDevice = IFDE_RenderDevice::Create(pFxDevice); |
1221 if (pDevice == NULL) { | 1220 if (pDevice == NULL) { |
1222 return FALSE; | 1221 return FALSE; |
1223 } | 1222 } |
1224 FDE_HDEVICESTATE state = pDevice->SaveState(); | 1223 FDE_HDEVICESTATE state = pDevice->SaveState(); |
1225 pDevice->SetClipRect(rtClip); | 1224 pDevice->SetClipRect(rtClip); |
1226 IFDE_SolidBrush* pSolidBrush = new CFDE_SolidBrush; | 1225 CFDE_Brush* pSolidBrush = new CFDE_Brush; |
1227 IFDE_Pen* pPen = new CFDE_Pen; | 1226 CFDE_Pen* pPen = new CFDE_Pen; |
1228 FXSYS_assert(pDevice); | 1227 FXSYS_assert(pDevice); |
1229 | 1228 |
1230 if (m_pieceLines.GetSize() == 0) { | 1229 if (m_pieceLines.GetSize() == 0) { |
1231 int32_t iBlockCount = CountBlocks(); | 1230 int32_t iBlockCount = CountBlocks(); |
1232 for (int32_t i = 0; i < iBlockCount; i++) { | 1231 for (int32_t i = 0; i < iBlockCount; i++) { |
1233 Layout(i); | 1232 Layout(i); |
1234 } | 1233 } |
1235 } | 1234 } |
1236 FXTEXT_CHARPOS* pCharPos = NULL; | 1235 FXTEXT_CHARPOS* pCharPos = NULL; |
1237 int32_t iCharCount = 0; | 1236 int32_t iCharCount = 0; |
(...skipping 26 matching lines...) Expand all Loading... |
1264 } | 1263 } |
1265 FXSYS_memset(pCharPos, 0, iCharCount * sizeof(FXTEXT_CHARPOS)); | 1264 FXSYS_memset(pCharPos, 0, iCharCount * sizeof(FXTEXT_CHARPOS)); |
1266 RenderString(pDevice, pSolidBrush, pPieceLine, j, pCharPos, tmDoc2Device); | 1265 RenderString(pDevice, pSolidBrush, pPieceLine, j, pCharPos, tmDoc2Device); |
1267 } | 1266 } |
1268 for (j = 0; j < iPieces; j++) { | 1267 for (j = 0; j < iPieces; j++) { |
1269 RenderPath(pDevice, pPen, pPieceLine, j, pCharPos, tmDoc2Device); | 1268 RenderPath(pDevice, pPen, pPieceLine, j, pCharPos, tmDoc2Device); |
1270 } | 1269 } |
1271 } | 1270 } |
1272 pDevice->RestoreState(state); | 1271 pDevice->RestoreState(state); |
1273 FX_Free(pCharPos); | 1272 FX_Free(pCharPos); |
1274 pSolidBrush->Release(); | 1273 delete pSolidBrush; |
1275 pPen->Release(); | 1274 delete pPen; |
1276 pDevice->Release(); | 1275 pDevice->Release(); |
1277 return iPieceLines; | 1276 return iPieceLines; |
1278 } | 1277 } |
1279 void CXFA_TextLayout::UpdateAlign(FX_FLOAT fHeight, FX_FLOAT fBottom) { | 1278 void CXFA_TextLayout::UpdateAlign(FX_FLOAT fHeight, FX_FLOAT fBottom) { |
1280 fHeight -= fBottom; | 1279 fHeight -= fBottom; |
1281 if (fHeight < 0.1f) { | 1280 if (fHeight < 0.1f) { |
1282 return; | 1281 return; |
1283 } | 1282 } |
1284 switch (m_textParser.GetVAlgin(m_pTextProvider)) { | 1283 switch (m_textParser.GetVAlgin(m_pTextProvider)) { |
1285 case XFA_ATTRIBUTEENUM_Middle: | 1284 case XFA_ATTRIBUTEENUM_Middle: |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1833 pStyle->GetParagraphStyles()->GetTextIndent().GetValue(); | 1832 pStyle->GetParagraphStyles()->GetTextIndent().GetValue(); |
1834 if (fTextIndent < 0) { | 1833 if (fTextIndent < 0) { |
1835 fStart -= fTextIndent; | 1834 fStart -= fTextIndent; |
1836 } | 1835 } |
1837 m_pBreak->SetLineStartPos(fStart); | 1836 m_pBreak->SetLineStartPos(fStart); |
1838 pStyle->Release(); | 1837 pStyle->Release(); |
1839 } | 1838 } |
1840 m_iLines++; | 1839 m_iLines++; |
1841 } | 1840 } |
1842 void CXFA_TextLayout::RenderString(IFDE_RenderDevice* pDevice, | 1841 void CXFA_TextLayout::RenderString(IFDE_RenderDevice* pDevice, |
1843 IFDE_SolidBrush* pBrush, | 1842 CFDE_Brush* pBrush, |
1844 CXFA_PieceLine* pPieceLine, | 1843 CXFA_PieceLine* pPieceLine, |
1845 int32_t iPiece, | 1844 int32_t iPiece, |
1846 FXTEXT_CHARPOS* pCharPos, | 1845 FXTEXT_CHARPOS* pCharPos, |
1847 const CFX_Matrix& tmDoc2Device) { | 1846 const CFX_Matrix& tmDoc2Device) { |
1848 const XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(iPiece); | 1847 const XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(iPiece); |
1849 int32_t iCount = GetDisplayPos(pPiece, pCharPos); | 1848 int32_t iCount = GetDisplayPos(pPiece, pCharPos); |
1850 if (iCount > 0) { | 1849 if (iCount > 0) { |
1851 pBrush->SetColor(pPiece->dwColor); | 1850 pBrush->SetColor(pPiece->dwColor); |
1852 pDevice->DrawString(pBrush, pPiece->pFont, pCharPos, iCount, | 1851 pDevice->DrawString(pBrush, pPiece->pFont, pCharPos, iCount, |
1853 pPiece->fFontSize, &tmDoc2Device); | 1852 pPiece->fFontSize, &tmDoc2Device); |
1854 } | 1853 } |
1855 pPieceLine->m_charCounts.Add(iCount); | 1854 pPieceLine->m_charCounts.Add(iCount); |
1856 } | 1855 } |
1857 void CXFA_TextLayout::RenderPath(IFDE_RenderDevice* pDevice, | 1856 void CXFA_TextLayout::RenderPath(IFDE_RenderDevice* pDevice, |
1858 IFDE_Pen* pPen, | 1857 CFDE_Pen* pPen, |
1859 CXFA_PieceLine* pPieceLine, | 1858 CXFA_PieceLine* pPieceLine, |
1860 int32_t iPiece, | 1859 int32_t iPiece, |
1861 FXTEXT_CHARPOS* pCharPos, | 1860 FXTEXT_CHARPOS* pCharPos, |
1862 const CFX_Matrix& tmDoc2Device) { | 1861 const CFX_Matrix& tmDoc2Device) { |
1863 XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(iPiece); | 1862 XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(iPiece); |
1864 FX_BOOL bNoUnderline = pPiece->iUnderline < 1 || pPiece->iUnderline > 2; | 1863 FX_BOOL bNoUnderline = pPiece->iUnderline < 1 || pPiece->iUnderline > 2; |
1865 FX_BOOL bNoLineThrough = pPiece->iLineThrough < 1 || pPiece->iLineThrough > 2; | 1864 FX_BOOL bNoLineThrough = pPiece->iLineThrough < 1 || pPiece->iLineThrough > 2; |
1866 if (bNoUnderline && bNoLineThrough) { | 1865 if (bNoUnderline && bNoLineThrough) { |
1867 return; | 1866 return; |
1868 } | 1867 } |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1991 tr.iLength = iLength; | 1990 tr.iLength = iLength; |
1992 tr.fFontSize = pPiece->fFontSize; | 1991 tr.fFontSize = pPiece->fFontSize; |
1993 tr.iBidiLevel = pPiece->iBidiLevel; | 1992 tr.iBidiLevel = pPiece->iBidiLevel; |
1994 tr.iCharRotation = 0; | 1993 tr.iCharRotation = 0; |
1995 tr.wLineBreakChar = L'\n'; | 1994 tr.wLineBreakChar = L'\n'; |
1996 tr.iVerticalScale = pPiece->iVerScale; | 1995 tr.iVerticalScale = pPiece->iVerScale; |
1997 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab; | 1996 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab; |
1998 tr.iHorizontalScale = pPiece->iHorScale; | 1997 tr.iHorizontalScale = pPiece->iHorScale; |
1999 return TRUE; | 1998 return TRUE; |
2000 } | 1999 } |
OLD | NEW |