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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
268 static const uint32_t s_XFATagName[] = { | 268 static const uint32_t s_XFATagName[] = { |
269 0x61, 0x62, 0x69, 0x70, 0x0001f714, | 269 0x61, 0x62, 0x69, 0x70, 0x0001f714, |
270 0x00022a55, 0x000239bb, 0x00025881, 0x0bd37faa, 0x0bd37fb8, | 270 0x00022a55, 0x000239bb, 0x00025881, 0x0bd37faa, 0x0bd37fb8, |
271 0xa73e3af2, 0xb182eaae, 0xdb8ac455, | 271 0xa73e3af2, 0xb182eaae, 0xdb8ac455, |
272 }; | 272 }; |
273 CFX_WideString wsName; | 273 CFX_WideString wsName; |
274 if (pXMLNode->GetType() == FDE_XMLNODE_Element) { | 274 if (pXMLNode->GetType() == FDE_XMLNODE_Element) { |
275 CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode); | 275 CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode); |
276 pXMLElement->GetLocalTagName(wsName); | 276 pXMLElement->GetLocalTagName(wsName); |
277 tagProvider.SetTagNameObj(wsName); | 277 tagProvider.SetTagNameObj(wsName); |
278 uint32_t dwHashCode = | 278 uint32_t dwHashCode = FX_HashCode_GetW(wsName.AsStringC(), true); |
279 FX_HashCode_String_GetW(wsName.c_str(), wsName.GetLength(), TRUE); | |
280 static const int32_t s_iCount = sizeof(s_XFATagName) / sizeof(uint32_t); | 279 static const int32_t s_iCount = sizeof(s_XFATagName) / sizeof(uint32_t); |
281 CFX_DSPATemplate<uint32_t> lookup; | 280 CFX_DSPATemplate<uint32_t> lookup; |
282 tagProvider.m_bTagAviliable = | 281 tagProvider.m_bTagAviliable = |
283 lookup.Lookup(dwHashCode, s_XFATagName, s_iCount) > -1; | 282 lookup.Lookup(dwHashCode, s_XFATagName, s_iCount) > -1; |
284 CFX_WideString wsValue; | 283 CFX_WideString wsValue; |
285 pXMLElement->GetString(FX_WSTRC(L"style").c_str(), wsValue); | 284 pXMLElement->GetString(FX_WSTRC(L"style").c_str(), wsValue); |
286 if (!wsValue.IsEmpty()) { | 285 if (!wsValue.IsEmpty()) { |
287 tagProvider.SetAttribute(FX_WSTRC(L"style"), wsValue); | 286 tagProvider.SetAttribute(FX_WSTRC(L"style"), wsValue); |
288 } | 287 } |
289 } else if (pXMLNode->GetType() == FDE_XMLNODE_Text) { | 288 } else if (pXMLNode->GetType() == FDE_XMLNODE_Text) { |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
606 } | 605 } |
607 while (iCur < iLength && pTabStops[iCur] <= ' ') { | 606 while (iCur < iLength && pTabStops[iCur] <= ' ') { |
608 iCur++; | 607 iCur++; |
609 } | 608 } |
610 iLast = iCur; | 609 iLast = iCur; |
611 eStatus = XFA_TABSTOPSSTATUS_Location; | 610 eStatus = XFA_TABSTOPSSTATUS_Location; |
612 } | 611 } |
613 break; | 612 break; |
614 case XFA_TABSTOPSSTATUS_Location: | 613 case XFA_TABSTOPSSTATUS_Location: |
615 if (ch == ' ') { | 614 if (ch == ' ') { |
616 uint32_t dwHashCode = FX_HashCode_String_GetW( | 615 uint32_t dwHashCode = FX_HashCode_GetW(wsAlign.AsStringC(), true); |
617 wsAlign.c_str(), wsAlign.GetLength(), TRUE); | |
618 CXFA_Measurement ms(CFX_WideStringC(pTabStops + iLast, iCur - iLast)); | 616 CXFA_Measurement ms(CFX_WideStringC(pTabStops + iLast, iCur - iLast)); |
619 FX_FLOAT fPos = ms.ToUnit(XFA_UNIT_Pt); | 617 FX_FLOAT fPos = ms.ToUnit(XFA_UNIT_Pt); |
620 pTabstopContext->Append(dwHashCode, fPos); | 618 pTabstopContext->Append(dwHashCode, fPos); |
621 wsAlign.clear(); | 619 wsAlign.clear(); |
622 eStatus = XFA_TABSTOPSSTATUS_None; | 620 eStatus = XFA_TABSTOPSSTATUS_None; |
623 } | 621 } |
624 iCur++; | 622 iCur++; |
625 break; | 623 break; |
626 default: | 624 default: |
627 break; | 625 break; |
628 } | 626 } |
629 } | 627 } |
630 if (!wsAlign.IsEmpty()) { | 628 if (!wsAlign.IsEmpty()) { |
631 uint32_t dwHashCode = | 629 uint32_t dwHashCode = FX_HashCode_GetW(wsAlign.AsStringC(), true); |
632 FX_HashCode_String_GetW(wsAlign.c_str(), wsAlign.GetLength(), TRUE); | |
633 CXFA_Measurement ms(CFX_WideStringC(pTabStops + iLast, iCur - iLast)); | 630 CXFA_Measurement ms(CFX_WideStringC(pTabStops + iLast, iCur - iLast)); |
634 FX_FLOAT fPos = ms.ToUnit(XFA_UNIT_Pt); | 631 FX_FLOAT fPos = ms.ToUnit(XFA_UNIT_Pt); |
635 pTabstopContext->Append(dwHashCode, fPos); | 632 pTabstopContext->Append(dwHashCode, fPos); |
636 } | 633 } |
637 return TRUE; | 634 return TRUE; |
638 } | 635 } |
639 CXFA_TextLayout::CXFA_TextLayout(CXFA_TextProvider* pTextProvider) | 636 CXFA_TextLayout::CXFA_TextLayout(CXFA_TextProvider* pTextProvider) |
640 : m_bHasBlock(FALSE), | 637 : m_bHasBlock(FALSE), |
641 m_pTextProvider(pTextProvider), | 638 m_pTextProvider(pTextProvider), |
642 m_pTextDataNode(nullptr), | 639 m_pTextDataNode(nullptr), |
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1636 XFA_TextPiece* p = pPieceLine->m_textPieces.GetAt(iPieces - 2); | 1633 XFA_TextPiece* p = pPieceLine->m_textPieces.GetAt(iPieces - 2); |
1637 fRight = p->rtPiece.right(); | 1634 fRight = p->rtPiece.right(); |
1638 } | 1635 } |
1639 m_pTabstopContext->m_fTabWidth = | 1636 m_pTabstopContext->m_fTabWidth = |
1640 pPiece->rtPiece.width + pPiece->rtPiece.left - fRight; | 1637 pPiece->rtPiece.width + pPiece->rtPiece.left - fRight; |
1641 } else if (iTabstopsIndex > -1) { | 1638 } else if (iTabstopsIndex > -1) { |
1642 FX_FLOAT fLeft = 0; | 1639 FX_FLOAT fLeft = 0; |
1643 if (m_pTabstopContext->m_bTabstops) { | 1640 if (m_pTabstopContext->m_bTabstops) { |
1644 XFA_TABSTOPS* pTabstops = | 1641 XFA_TABSTOPS* pTabstops = |
1645 m_pTabstopContext->m_tabstops.GetDataPtr(iTabstopsIndex); | 1642 m_pTabstopContext->m_tabstops.GetDataPtr(iTabstopsIndex); |
1646 uint32_t dwAlgin = pTabstops->dwAlign; | 1643 uint32_t dwAlgin = pTabstops->dwAlign; |
Lei Zhang
2016/04/23 01:33:29
s/dwAlgin/dwAlign/
Tom Sepez
2016/04/25 16:50:21
Done, global grep for Algin.
| |
1647 if (dwAlgin == FX_HashCode_String_GetW(L"center", 6)) { | 1644 if (dwAlgin == FX_HashCode_GetW(L"center", false)) { |
1648 fLeft = pPiece->rtPiece.width / 2.0f; | 1645 fLeft = pPiece->rtPiece.width / 2.0f; |
1649 } else if (dwAlgin == FX_HashCode_String_GetW(L"right", 5) || | 1646 } else if (dwAlgin == FX_HashCode_GetW(L"right", false) || |
1650 dwAlgin == FX_HashCode_String_GetW(L"before", 6)) { | 1647 dwAlgin == FX_HashCode_GetW(L"before", false)) { |
1651 fLeft = pPiece->rtPiece.width; | 1648 fLeft = pPiece->rtPiece.width; |
1652 } else if (dwAlgin == FX_HashCode_String_GetW(L"decimal", 7)) { | 1649 } else if (dwAlgin == FX_HashCode_GetW(L"decimal", false)) { |
1653 int32_t iChars = pPiece->iChars; | 1650 int32_t iChars = pPiece->iChars; |
1654 for (int32_t i = 0; i < iChars; i++) { | 1651 for (int32_t i = 0; i < iChars; i++) { |
1655 if (pPiece->pszText[i] == L'.') { | 1652 if (pPiece->pszText[i] == L'.') { |
1656 break; | 1653 break; |
1657 } | 1654 } |
1658 fLeft += pPiece->pWidths[i] / 20000.0f; | 1655 fLeft += pPiece->pWidths[i] / 20000.0f; |
1659 } | 1656 } |
1660 } | 1657 } |
1661 m_pTabstopContext->m_fLeft = | 1658 m_pTabstopContext->m_fLeft = |
1662 std::min(fLeft, m_pTabstopContext->m_fTabWidth); | 1659 std::min(fLeft, m_pTabstopContext->m_fTabWidth); |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1963 tr.iLength = iLength; | 1960 tr.iLength = iLength; |
1964 tr.fFontSize = pPiece->fFontSize; | 1961 tr.fFontSize = pPiece->fFontSize; |
1965 tr.iBidiLevel = pPiece->iBidiLevel; | 1962 tr.iBidiLevel = pPiece->iBidiLevel; |
1966 tr.iCharRotation = 0; | 1963 tr.iCharRotation = 0; |
1967 tr.wLineBreakChar = L'\n'; | 1964 tr.wLineBreakChar = L'\n'; |
1968 tr.iVerticalScale = pPiece->iVerScale; | 1965 tr.iVerticalScale = pPiece->iVerScale; |
1969 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab; | 1966 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab; |
1970 tr.iHorizontalScale = pPiece->iHorScale; | 1967 tr.iHorizontalScale = pPiece->iHorScale; |
1971 return TRUE; | 1968 return TRUE; |
1972 } | 1969 } |
OLD | NEW |