| 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 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 void CXFA_TextParseContext::SetDecls(const CFDE_CSSDeclaration** ppDeclArray, | 25 void CXFA_TextParseContext::SetDecls(const CFDE_CSSDeclaration** ppDeclArray, |
| 26 int32_t iDeclCount) { | 26 int32_t iDeclCount) { |
| 27 if (iDeclCount <= 0 || !ppDeclArray) | 27 if (iDeclCount <= 0 || !ppDeclArray) |
| 28 return; | 28 return; |
| 29 | 29 |
| 30 m_dwMatchedDecls = iDeclCount; | 30 m_dwMatchedDecls = iDeclCount; |
| 31 m_ppMatchedDecls = FX_Alloc(CFDE_CSSDeclaration*, iDeclCount); | 31 m_ppMatchedDecls = FX_Alloc(CFDE_CSSDeclaration*, iDeclCount); |
| 32 FXSYS_memcpy(m_ppMatchedDecls, ppDeclArray, | 32 FXSYS_memcpy(m_ppMatchedDecls, ppDeclArray, |
| 33 iDeclCount * sizeof(CFDE_CSSDeclaration*)); | 33 iDeclCount * sizeof(CFDE_CSSDeclaration*)); |
| 34 } | 34 } |
| 35 |
| 36 CXFA_TextParser::CXFA_TextParser() : m_pAllocator(NULL), m_pUASheet(NULL) {} |
| 37 |
| 35 CXFA_TextParser::~CXFA_TextParser() { | 38 CXFA_TextParser::~CXFA_TextParser() { |
| 36 if (m_pUASheet) | 39 if (m_pUASheet) |
| 37 m_pUASheet->Release(); | 40 m_pUASheet->Release(); |
| 38 if (m_pSelector) | 41 |
| 39 m_pSelector->Release(); | |
| 40 delete m_pAllocator; | 42 delete m_pAllocator; |
| 41 FX_POSITION ps = m_mapXMLNodeToParseContext.GetStartPosition(); | 43 FX_POSITION ps = m_mapXMLNodeToParseContext.GetStartPosition(); |
| 42 while (ps) { | 44 while (ps) { |
| 43 CFDE_XMLNode* pXMLNode; | 45 CFDE_XMLNode* pXMLNode; |
| 44 CXFA_TextParseContext* pParseContext; | 46 CXFA_TextParseContext* pParseContext; |
| 45 m_mapXMLNodeToParseContext.GetNextAssoc(ps, pXMLNode, pParseContext); | 47 m_mapXMLNodeToParseContext.GetNextAssoc(ps, pXMLNode, pParseContext); |
| 46 if (pParseContext) | 48 if (pParseContext) |
| 47 FXTARGET_DeleteWith(CXFA_TextParseContext, m_pAllocator, pParseContext); | 49 FXTARGET_DeleteWith(CXFA_TextParseContext, m_pAllocator, pParseContext); |
| 48 } | 50 } |
| 49 m_mapXMLNodeToParseContext.RemoveAll(); | 51 m_mapXMLNodeToParseContext.RemoveAll(); |
| 50 } | 52 } |
| 51 void CXFA_TextParser::Reset() { | 53 void CXFA_TextParser::Reset() { |
| 52 FX_POSITION ps = m_mapXMLNodeToParseContext.GetStartPosition(); | 54 FX_POSITION ps = m_mapXMLNodeToParseContext.GetStartPosition(); |
| 53 while (ps) { | 55 while (ps) { |
| 54 CFDE_XMLNode* pXMLNode; | 56 CFDE_XMLNode* pXMLNode; |
| 55 CXFA_TextParseContext* pParseContext; | 57 CXFA_TextParseContext* pParseContext; |
| 56 m_mapXMLNodeToParseContext.GetNextAssoc(ps, pXMLNode, pParseContext); | 58 m_mapXMLNodeToParseContext.GetNextAssoc(ps, pXMLNode, pParseContext); |
| 57 if (pParseContext) | 59 if (pParseContext) |
| 58 FXTARGET_DeleteWith(CXFA_TextParseContext, m_pAllocator, pParseContext); | 60 FXTARGET_DeleteWith(CXFA_TextParseContext, m_pAllocator, pParseContext); |
| 59 } | 61 } |
| 60 m_mapXMLNodeToParseContext.RemoveAll(); | 62 m_mapXMLNodeToParseContext.RemoveAll(); |
| 61 delete m_pAllocator; | 63 delete m_pAllocator; |
| 62 m_pAllocator = nullptr; | 64 m_pAllocator = nullptr; |
| 63 } | 65 } |
| 64 void CXFA_TextParser::InitCSSData(CXFA_TextProvider* pTextProvider) { | 66 void CXFA_TextParser::InitCSSData(CXFA_TextProvider* pTextProvider) { |
| 65 if (pTextProvider == NULL) { | 67 if (!pTextProvider) |
| 66 return; | 68 return; |
| 67 } | 69 |
| 68 if (m_pSelector == NULL) { | 70 if (!m_pSelector) { |
| 69 CXFA_FFDoc* pDoc = pTextProvider->GetDocNode(); | 71 CXFA_FFDoc* pDoc = pTextProvider->GetDocNode(); |
| 70 IFX_FontMgr* pFontMgr = pDoc->GetApp()->GetFDEFontMgr(); | 72 IFX_FontMgr* pFontMgr = pDoc->GetApp()->GetFDEFontMgr(); |
| 71 ASSERT(pFontMgr); | 73 ASSERT(pFontMgr); |
| 72 m_pSelector = new CFDE_CSSStyleSelector; | 74 m_pSelector.reset(new CFDE_CSSStyleSelector); |
| 73 m_pSelector->SetFontMgr(pFontMgr); | 75 m_pSelector->SetFontMgr(pFontMgr); |
| 74 FX_FLOAT fFontSize = 10; | 76 FX_FLOAT fFontSize = 10; |
| 75 CXFA_Font font = pTextProvider->GetFontNode(); | 77 CXFA_Font font = pTextProvider->GetFontNode(); |
| 76 if (font) { | 78 if (font) { |
| 77 fFontSize = font.GetFontSize(); | 79 fFontSize = font.GetFontSize(); |
| 78 } | 80 } |
| 79 m_pSelector->SetDefFontSize(fFontSize); | 81 m_pSelector->SetDefFontSize(fFontSize); |
| 80 } | 82 } |
| 81 if (m_pUASheet == NULL) { | 83 if (!m_pUASheet) { |
| 82 m_pUASheet = LoadDefaultSheetStyle(); | 84 m_pUASheet = LoadDefaultSheetStyle(); |
| 83 m_pSelector->SetStyleSheet(FDE_CSSSTYLESHEETGROUP_UserAgent, m_pUASheet); | 85 m_pSelector->SetStyleSheet(FDE_CSSSTYLESHEETGROUP_UserAgent, m_pUASheet); |
| 84 m_pSelector->UpdateStyleIndex(FDE_CSSMEDIATYPE_ALL); | 86 m_pSelector->UpdateStyleIndex(FDE_CSSMEDIATYPE_ALL); |
| 85 } | 87 } |
| 86 } | 88 } |
| 87 IFDE_CSSStyleSheet* CXFA_TextParser::LoadDefaultSheetStyle() { | 89 IFDE_CSSStyleSheet* CXFA_TextParser::LoadDefaultSheetStyle() { |
| 88 static const FX_WCHAR s_pStyle[] = | 90 static const FX_WCHAR s_pStyle[] = |
| 89 L"html,body,ol,p,ul{display:block}" | 91 L"html,body,ol,p,ul{display:block}" |
| 90 L"li{display:list-item}" | 92 L"li{display:list-item}" |
| 91 L"ol,ul{padding-left:33px}ol{list-style-type:decimal}ol,ul{margin-top:0;" | 93 L"ol,ul{padding-left:33px}ol{list-style-type:decimal}ol,ul{margin-top:0;" |
| (...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1176 m_Blocks.Add(i - iLineIndex); | 1178 m_Blocks.Add(i - iLineIndex); |
| 1177 } | 1179 } |
| 1178 } | 1180 } |
| 1179 FX_BOOL CXFA_TextLayout::DrawString(CFX_RenderDevice* pFxDevice, | 1181 FX_BOOL CXFA_TextLayout::DrawString(CFX_RenderDevice* pFxDevice, |
| 1180 const CFX_Matrix& tmDoc2Device, | 1182 const CFX_Matrix& tmDoc2Device, |
| 1181 const CFX_RectF& rtClip, | 1183 const CFX_RectF& rtClip, |
| 1182 int32_t iBlock) { | 1184 int32_t iBlock) { |
| 1183 if (!pFxDevice) | 1185 if (!pFxDevice) |
| 1184 return FALSE; | 1186 return FALSE; |
| 1185 | 1187 |
| 1186 CFDE_RenderDevice* pDevice = new CFDE_RenderDevice(pFxDevice, FALSE); | 1188 std::unique_ptr<CFDE_RenderDevice> pDevice( |
| 1189 new CFDE_RenderDevice(pFxDevice, FALSE)); |
| 1187 FDE_HDEVICESTATE state = pDevice->SaveState(); | 1190 FDE_HDEVICESTATE state = pDevice->SaveState(); |
| 1188 pDevice->SetClipRect(rtClip); | 1191 pDevice->SetClipRect(rtClip); |
| 1189 CFDE_Brush* pSolidBrush = new CFDE_Brush; | |
| 1190 CFDE_Pen* pPen = new CFDE_Pen; | |
| 1191 ASSERT(pDevice); | |
| 1192 | 1192 |
| 1193 std::unique_ptr<CFDE_Brush> pSolidBrush(new CFDE_Brush); |
| 1194 std::unique_ptr<CFDE_Pen> pPen(new CFDE_Pen); |
| 1193 if (m_pieceLines.GetSize() == 0) { | 1195 if (m_pieceLines.GetSize() == 0) { |
| 1194 int32_t iBlockCount = CountBlocks(); | 1196 int32_t iBlockCount = CountBlocks(); |
| 1195 for (int32_t i = 0; i < iBlockCount; i++) { | 1197 for (int32_t i = 0; i < iBlockCount; i++) { |
| 1196 Layout(i); | 1198 Layout(i); |
| 1197 } | 1199 } |
| 1198 } | 1200 } |
| 1199 FXTEXT_CHARPOS* pCharPos = NULL; | 1201 FXTEXT_CHARPOS* pCharPos = NULL; |
| 1200 int32_t iCharCount = 0; | 1202 int32_t iCharCount = 0; |
| 1201 int32_t iLineStart = 0; | 1203 int32_t iLineStart = 0; |
| 1202 int32_t iPieceLines = m_pieceLines.GetSize(); | 1204 int32_t iPieceLines = m_pieceLines.GetSize(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1219 int32_t j = 0; | 1221 int32_t j = 0; |
| 1220 for (j = 0; j < iPieces; j++) { | 1222 for (j = 0; j < iPieces; j++) { |
| 1221 const XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(j); | 1223 const XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(j); |
| 1222 int32_t iChars = pPiece->iChars; | 1224 int32_t iChars = pPiece->iChars; |
| 1223 if (iCharCount < iChars) { | 1225 if (iCharCount < iChars) { |
| 1224 FX_Free(pCharPos); | 1226 FX_Free(pCharPos); |
| 1225 pCharPos = FX_Alloc(FXTEXT_CHARPOS, iChars); | 1227 pCharPos = FX_Alloc(FXTEXT_CHARPOS, iChars); |
| 1226 iCharCount = iChars; | 1228 iCharCount = iChars; |
| 1227 } | 1229 } |
| 1228 FXSYS_memset(pCharPos, 0, iCharCount * sizeof(FXTEXT_CHARPOS)); | 1230 FXSYS_memset(pCharPos, 0, iCharCount * sizeof(FXTEXT_CHARPOS)); |
| 1229 RenderString(pDevice, pSolidBrush, pPieceLine, j, pCharPos, tmDoc2Device); | 1231 RenderString(pDevice.get(), pSolidBrush.get(), pPieceLine, j, pCharPos, |
| 1232 tmDoc2Device); |
| 1230 } | 1233 } |
| 1231 for (j = 0; j < iPieces; j++) { | 1234 for (j = 0; j < iPieces; j++) { |
| 1232 RenderPath(pDevice, pPen, pPieceLine, j, pCharPos, tmDoc2Device); | 1235 RenderPath(pDevice.get(), pPen.get(), pPieceLine, j, pCharPos, |
| 1236 tmDoc2Device); |
| 1233 } | 1237 } |
| 1234 } | 1238 } |
| 1235 pDevice->RestoreState(state); | 1239 pDevice->RestoreState(state); |
| 1236 FX_Free(pCharPos); | 1240 FX_Free(pCharPos); |
| 1237 delete pSolidBrush; | |
| 1238 delete pPen; | |
| 1239 pDevice->Release(); | |
| 1240 return iPieceLines; | 1241 return iPieceLines; |
| 1241 } | 1242 } |
| 1242 void CXFA_TextLayout::UpdateAlign(FX_FLOAT fHeight, FX_FLOAT fBottom) { | 1243 void CXFA_TextLayout::UpdateAlign(FX_FLOAT fHeight, FX_FLOAT fBottom) { |
| 1243 fHeight -= fBottom; | 1244 fHeight -= fBottom; |
| 1244 if (fHeight < 0.1f) { | 1245 if (fHeight < 0.1f) { |
| 1245 return; | 1246 return; |
| 1246 } | 1247 } |
| 1247 switch (m_textParser.GetVAlign(m_pTextProvider)) { | 1248 switch (m_textParser.GetVAlign(m_pTextProvider)) { |
| 1248 case XFA_ATTRIBUTEENUM_Middle: | 1249 case XFA_ATTRIBUTEENUM_Middle: |
| 1249 fHeight /= 2.0f; | 1250 fHeight /= 2.0f; |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1810 const CFX_Matrix& tmDoc2Device) { | 1811 const CFX_Matrix& tmDoc2Device) { |
| 1811 const XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(iPiece); | 1812 const XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(iPiece); |
| 1812 int32_t iCount = GetDisplayPos(pPiece, pCharPos); | 1813 int32_t iCount = GetDisplayPos(pPiece, pCharPos); |
| 1813 if (iCount > 0) { | 1814 if (iCount > 0) { |
| 1814 pBrush->SetColor(pPiece->dwColor); | 1815 pBrush->SetColor(pPiece->dwColor); |
| 1815 pDevice->DrawString(pBrush, pPiece->pFont, pCharPos, iCount, | 1816 pDevice->DrawString(pBrush, pPiece->pFont, pCharPos, iCount, |
| 1816 pPiece->fFontSize, &tmDoc2Device); | 1817 pPiece->fFontSize, &tmDoc2Device); |
| 1817 } | 1818 } |
| 1818 pPieceLine->m_charCounts.Add(iCount); | 1819 pPieceLine->m_charCounts.Add(iCount); |
| 1819 } | 1820 } |
| 1821 |
| 1820 void CXFA_TextLayout::RenderPath(CFDE_RenderDevice* pDevice, | 1822 void CXFA_TextLayout::RenderPath(CFDE_RenderDevice* pDevice, |
| 1821 CFDE_Pen* pPen, | 1823 CFDE_Pen* pPen, |
| 1822 CXFA_PieceLine* pPieceLine, | 1824 CXFA_PieceLine* pPieceLine, |
| 1823 int32_t iPiece, | 1825 int32_t iPiece, |
| 1824 FXTEXT_CHARPOS* pCharPos, | 1826 FXTEXT_CHARPOS* pCharPos, |
| 1825 const CFX_Matrix& tmDoc2Device) { | 1827 const CFX_Matrix& tmDoc2Device) { |
| 1826 XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(iPiece); | 1828 XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(iPiece); |
| 1827 FX_BOOL bNoUnderline = pPiece->iUnderline < 1 || pPiece->iUnderline > 2; | 1829 FX_BOOL bNoUnderline = pPiece->iUnderline < 1 || pPiece->iUnderline > 2; |
| 1828 FX_BOOL bNoLineThrough = pPiece->iLineThrough < 1 || pPiece->iLineThrough > 2; | 1830 FX_BOOL bNoLineThrough = pPiece->iLineThrough < 1 || pPiece->iLineThrough > 2; |
| 1829 if (bNoUnderline && bNoLineThrough) { | 1831 if (bNoUnderline && bNoLineThrough) { |
| 1830 return; | 1832 return; |
| 1831 } | 1833 } |
| 1832 pPen->SetColor(pPiece->dwColor); | 1834 pPen->SetColor(pPiece->dwColor); |
| 1833 CFDE_Path* pPath = new CFDE_Path; | 1835 std::unique_ptr<CFDE_Path> pPath(new CFDE_Path); |
| 1834 int32_t iChars = GetDisplayPos(pPiece, pCharPos); | 1836 int32_t iChars = GetDisplayPos(pPiece, pCharPos); |
| 1835 if (iChars > 0) { | 1837 if (iChars > 0) { |
| 1836 CFX_PointF pt1, pt2; | 1838 CFX_PointF pt1, pt2; |
| 1837 FX_FLOAT fEndY = pCharPos[0].m_OriginY + 1.05f; | 1839 FX_FLOAT fEndY = pCharPos[0].m_OriginY + 1.05f; |
| 1838 int32_t i = 0; | 1840 int32_t i = 0; |
| 1839 if (pPiece->iPeriod == XFA_ATTRIBUTEENUM_Word) { | 1841 if (pPiece->iPeriod == XFA_ATTRIBUTEENUM_Word) { |
| 1840 for (int32_t i = 0; i < pPiece->iUnderline; i++) { | 1842 for (int32_t i = 0; i < pPiece->iUnderline; i++) { |
| 1841 for (int32_t j = 0; j < iChars; j++) { | 1843 for (int32_t j = 0; j < iChars; j++) { |
| 1842 pt1.x = pCharPos[j].m_OriginX; | 1844 pt1.x = pCharPos[j].m_OriginX; |
| 1843 pt2.x = | 1845 pt2.x = |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1863 pt2.x = pCharPos[iChars - 1].m_OriginX + | 1865 pt2.x = pCharPos[iChars - 1].m_OriginX + |
| 1864 pCharPos[iChars - 1].m_FontCharWidth * pPiece->fFontSize / 1000.0f; | 1866 pCharPos[iChars - 1].m_FontCharWidth * pPiece->fFontSize / 1000.0f; |
| 1865 for (i = 0; i < pPiece->iLineThrough; i++) { | 1867 for (i = 0; i < pPiece->iLineThrough; i++) { |
| 1866 pt1.y = pt2.y = fEndY; | 1868 pt1.y = pt2.y = fEndY; |
| 1867 pPath->AddLine(pt1, pt2); | 1869 pPath->AddLine(pt1, pt2); |
| 1868 fEndY += 2.0f; | 1870 fEndY += 2.0f; |
| 1869 } | 1871 } |
| 1870 } else { | 1872 } else { |
| 1871 if (bNoLineThrough && | 1873 if (bNoLineThrough && |
| 1872 (bNoUnderline || pPiece->iPeriod != XFA_ATTRIBUTEENUM_All)) { | 1874 (bNoUnderline || pPiece->iPeriod != XFA_ATTRIBUTEENUM_All)) { |
| 1873 goto XFA_RenderPathRet; | 1875 return; |
| 1874 } | 1876 } |
| 1875 int32_t iCharsTmp = 0; | 1877 int32_t iCharsTmp = 0; |
| 1876 int32_t iPiecePrev = iPiece, iPieceNext = iPiece; | 1878 int32_t iPiecePrev = iPiece, iPieceNext = iPiece; |
| 1877 while (iPiecePrev > 0) { | 1879 while (iPiecePrev > 0) { |
| 1878 iPiecePrev--; | 1880 iPiecePrev--; |
| 1879 iCharsTmp = pPieceLine->m_charCounts.GetAt(iPiecePrev); | 1881 iCharsTmp = pPieceLine->m_charCounts.GetAt(iPiecePrev); |
| 1880 if (iCharsTmp > 0) { | 1882 if (iCharsTmp > 0) { |
| 1881 break; | 1883 break; |
| 1882 } | 1884 } |
| 1883 } | 1885 } |
| 1884 if (iCharsTmp == 0) { | 1886 if (iCharsTmp == 0) { |
| 1885 goto XFA_RenderPathRet; | 1887 return; |
| 1886 } | 1888 } |
| 1887 iCharsTmp = 0; | 1889 iCharsTmp = 0; |
| 1888 int32_t iPieces = pPieceLine->m_textPieces.GetSize(); | 1890 int32_t iPieces = pPieceLine->m_textPieces.GetSize(); |
| 1889 while (iPieceNext < iPieces - 1) { | 1891 while (iPieceNext < iPieces - 1) { |
| 1890 iPieceNext++; | 1892 iPieceNext++; |
| 1891 iCharsTmp = pPieceLine->m_charCounts.GetAt(iPieceNext); | 1893 iCharsTmp = pPieceLine->m_charCounts.GetAt(iPieceNext); |
| 1892 if (iCharsTmp > 0) { | 1894 if (iCharsTmp > 0) { |
| 1893 break; | 1895 break; |
| 1894 } | 1896 } |
| 1895 } | 1897 } |
| 1896 if (iCharsTmp == 0) { | 1898 if (iCharsTmp == 0) { |
| 1897 goto XFA_RenderPathRet; | 1899 return; |
| 1898 } | 1900 } |
| 1899 FX_FLOAT fOrgX = 0.0f, fEndX = 0.0f; | 1901 FX_FLOAT fOrgX = 0.0f, fEndX = 0.0f; |
| 1900 pPiece = pPieceLine->m_textPieces.GetAt(iPiecePrev); | 1902 pPiece = pPieceLine->m_textPieces.GetAt(iPiecePrev); |
| 1901 iChars = GetDisplayPos(pPiece, pCharPos); | 1903 iChars = GetDisplayPos(pPiece, pCharPos); |
| 1902 if (iChars < 1) { | 1904 if (iChars < 1) { |
| 1903 goto XFA_RenderPathRet; | 1905 return; |
| 1904 } | 1906 } |
| 1905 fOrgX = pCharPos[iChars - 1].m_OriginX + | 1907 fOrgX = pCharPos[iChars - 1].m_OriginX + |
| 1906 pCharPos[iChars - 1].m_FontCharWidth * pPiece->fFontSize / 1000.0f; | 1908 pCharPos[iChars - 1].m_FontCharWidth * pPiece->fFontSize / 1000.0f; |
| 1907 pPiece = pPieceLine->m_textPieces.GetAt(iPieceNext); | 1909 pPiece = pPieceLine->m_textPieces.GetAt(iPieceNext); |
| 1908 iChars = GetDisplayPos(pPiece, pCharPos); | 1910 iChars = GetDisplayPos(pPiece, pCharPos); |
| 1909 if (iChars < 1) { | 1911 if (iChars < 1) { |
| 1910 goto XFA_RenderPathRet; | 1912 return; |
| 1911 } | 1913 } |
| 1912 fEndX = pCharPos[0].m_OriginX; | 1914 fEndX = pCharPos[0].m_OriginX; |
| 1913 CFX_PointF pt1, pt2; | 1915 CFX_PointF pt1, pt2; |
| 1914 pt1.x = fOrgX, pt2.x = fEndX; | 1916 pt1.x = fOrgX, pt2.x = fEndX; |
| 1915 FX_FLOAT fEndY = pCharPos[0].m_OriginY + 1.05f; | 1917 FX_FLOAT fEndY = pCharPos[0].m_OriginY + 1.05f; |
| 1916 int32_t i = 0; | 1918 int32_t i = 0; |
| 1917 for (i = 0; i < pPiece->iUnderline; i++) { | 1919 for (i = 0; i < pPiece->iUnderline; i++) { |
| 1918 pt1.y = pt2.y = fEndY; | 1920 pt1.y = pt2.y = fEndY; |
| 1919 pPath->AddLine(pt1, pt2); | 1921 pPath->AddLine(pt1, pt2); |
| 1920 fEndY += 2.0f; | 1922 fEndY += 2.0f; |
| 1921 } | 1923 } |
| 1922 fEndY = pCharPos[0].m_OriginY - pPiece->rtPiece.height * 0.25f; | 1924 fEndY = pCharPos[0].m_OriginY - pPiece->rtPiece.height * 0.25f; |
| 1923 for (i = 0; i < pPiece->iLineThrough; i++) { | 1925 for (i = 0; i < pPiece->iLineThrough; i++) { |
| 1924 pt1.y = pt2.y = fEndY; | 1926 pt1.y = pt2.y = fEndY; |
| 1925 pPath->AddLine(pt1, pt2); | 1927 pPath->AddLine(pt1, pt2); |
| 1926 fEndY += 2.0f; | 1928 fEndY += 2.0f; |
| 1927 } | 1929 } |
| 1928 } | 1930 } |
| 1929 pDevice->DrawPath(pPen, 1, pPath, &tmDoc2Device); | 1931 pDevice->DrawPath(pPen, 1, pPath.get(), &tmDoc2Device); |
| 1930 XFA_RenderPathRet: | |
| 1931 pPath->Release(); | |
| 1932 } | 1932 } |
| 1933 |
| 1933 int32_t CXFA_TextLayout::GetDisplayPos(const XFA_TextPiece* pPiece, | 1934 int32_t CXFA_TextLayout::GetDisplayPos(const XFA_TextPiece* pPiece, |
| 1934 FXTEXT_CHARPOS* pCharPos, | 1935 FXTEXT_CHARPOS* pCharPos, |
| 1935 FX_BOOL bCharCode) { | 1936 FX_BOOL bCharCode) { |
| 1936 if (pPiece == NULL) { | 1937 if (pPiece == NULL) { |
| 1937 return 0; | 1938 return 0; |
| 1938 } | 1939 } |
| 1939 FX_RTFTEXTOBJ tr; | 1940 FX_RTFTEXTOBJ tr; |
| 1940 if (!ToRun(pPiece, tr)) { | 1941 if (!ToRun(pPiece, tr)) { |
| 1941 return 0; | 1942 return 0; |
| 1942 } | 1943 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1954 tr.iLength = iLength; | 1955 tr.iLength = iLength; |
| 1955 tr.fFontSize = pPiece->fFontSize; | 1956 tr.fFontSize = pPiece->fFontSize; |
| 1956 tr.iBidiLevel = pPiece->iBidiLevel; | 1957 tr.iBidiLevel = pPiece->iBidiLevel; |
| 1957 tr.iCharRotation = 0; | 1958 tr.iCharRotation = 0; |
| 1958 tr.wLineBreakChar = L'\n'; | 1959 tr.wLineBreakChar = L'\n'; |
| 1959 tr.iVerticalScale = pPiece->iVerScale; | 1960 tr.iVerticalScale = pPiece->iVerScale; |
| 1960 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab; | 1961 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab; |
| 1961 tr.iHorizontalScale = pPiece->iHorScale; | 1962 tr.iHorizontalScale = pPiece->iHorScale; |
| 1962 return TRUE; | 1963 return TRUE; |
| 1963 } | 1964 } |
| OLD | NEW |