| 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/fx_ext.h" | 11 #include "core/fxcrt/fx_ext.h" |
| 12 #include "xfa/fde/cfde_path.h" | 12 #include "xfa/fde/cfde_path.h" |
| 13 #include "xfa/fde/css/fde_csscache.h" | 13 #include "xfa/fde/css/fde_csscache.h" |
| 14 #include "xfa/fde/css/fde_cssstyleselector.h" | 14 #include "xfa/fde/css/fde_cssstyleselector.h" |
| 15 #include "xfa/fde/fde_gedevice.h" | 15 #include "xfa/fde/fde_gedevice.h" |
| 16 #include "xfa/fde/fde_object.h" | 16 #include "xfa/fde/fde_object.h" |
| 17 #include "xfa/fde/xml/fde_xml_imp.h" | 17 #include "xfa/fde/xml/fde_xml_imp.h" |
| 18 #include "xfa/fgas/crt/fgas_codepage.h" | 18 #include "xfa/fgas/crt/fgas_codepage.h" |
| 19 #include "xfa/fxfa/app/xfa_ffwidgetacc.h" | 19 #include "xfa/fxfa/app/xfa_ffwidgetacc.h" |
| 20 #include "xfa/fxfa/parser/cxfa_measurement.h" | 20 #include "xfa/fxfa/parser/cxfa_measurement.h" |
| 21 #include "xfa/fxfa/xfa_ffapp.h" | 21 #include "xfa/fxfa/xfa_ffapp.h" |
| 22 #include "xfa/fxfa/xfa_ffdoc.h" | 22 #include "xfa/fxfa/xfa_ffdoc.h" |
| 23 #include "xfa/fxfa/xfa_fontmgr.h" | 23 #include "xfa/fxfa/xfa_fontmgr.h" |
| 24 | 24 |
| 25 CXFA_CSSTagProvider::CXFA_CSSTagProvider() | 25 CXFA_CSSTagProvider::CXFA_CSSTagProvider() |
| 26 : m_bTagAvailable(FALSE), m_bContent(FALSE) {} | 26 : m_bTagAvailable(false), m_bContent(false) {} |
| 27 | 27 |
| 28 CXFA_CSSTagProvider::~CXFA_CSSTagProvider() {} | 28 CXFA_CSSTagProvider::~CXFA_CSSTagProvider() {} |
| 29 | 29 |
| 30 XFA_TextPiece::XFA_TextPiece() | 30 XFA_TextPiece::XFA_TextPiece() |
| 31 : pszText(nullptr), pFont(nullptr), pLinkData(nullptr) {} | 31 : pszText(nullptr), pFont(nullptr), pLinkData(nullptr) {} |
| 32 | 32 |
| 33 XFA_TextPiece::~XFA_TextPiece() { | 33 XFA_TextPiece::~XFA_TextPiece() { |
| 34 if (pLinkData) | 34 if (pLinkData) |
| 35 pLinkData->Release(); | 35 pLinkData->Release(); |
| 36 } | 36 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 m_pSelector->SetDefFontSize(fFontSize); | 105 m_pSelector->SetDefFontSize(fFontSize); |
| 106 } | 106 } |
| 107 if (!m_pUASheet) { | 107 if (!m_pUASheet) { |
| 108 m_pUASheet = LoadDefaultSheetStyle(); | 108 m_pUASheet = LoadDefaultSheetStyle(); |
| 109 m_pSelector->SetStyleSheet(FDE_CSSSTYLESHEETGROUP_UserAgent, m_pUASheet); | 109 m_pSelector->SetStyleSheet(FDE_CSSSTYLESHEETGROUP_UserAgent, m_pUASheet); |
| 110 m_pSelector->UpdateStyleIndex(FDE_CSSMEDIATYPE_ALL); | 110 m_pSelector->UpdateStyleIndex(FDE_CSSMEDIATYPE_ALL); |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 CXFA_LoaderContext::CXFA_LoaderContext() | 114 CXFA_LoaderContext::CXFA_LoaderContext() |
| 115 : m_bSaveLineHeight(FALSE), | 115 : m_bSaveLineHeight(false), |
| 116 m_fWidth(0), | 116 m_fWidth(0), |
| 117 m_fHeight(0), | 117 m_fHeight(0), |
| 118 m_fLastPos(0), | 118 m_fLastPos(0), |
| 119 m_fStartLineOffset(0), | 119 m_fStartLineOffset(0), |
| 120 m_iChar(0), | 120 m_iChar(0), |
| 121 m_iTotalLines(-1), | 121 m_iTotalLines(-1), |
| 122 m_pXMLNode(nullptr), | 122 m_pXMLNode(nullptr), |
| 123 m_pNode(nullptr), | 123 m_pNode(nullptr), |
| 124 m_pParentStyle(nullptr), | 124 m_pParentStyle(nullptr), |
| 125 m_dwFlags(0) {} | 125 m_dwFlags(0) {} |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 pXMLElement->GetLocalTagName(wsName); | 334 pXMLElement->GetLocalTagName(wsName); |
| 335 tagProvider.SetTagNameObj(wsName); | 335 tagProvider.SetTagNameObj(wsName); |
| 336 tagProvider.m_bTagAvailable = TagValidate(wsName); | 336 tagProvider.m_bTagAvailable = TagValidate(wsName); |
| 337 | 337 |
| 338 CFX_WideString wsValue; | 338 CFX_WideString wsValue; |
| 339 pXMLElement->GetString(L"style", wsValue); | 339 pXMLElement->GetString(L"style", wsValue); |
| 340 if (!wsValue.IsEmpty()) { | 340 if (!wsValue.IsEmpty()) { |
| 341 tagProvider.SetAttribute(L"style", wsValue); | 341 tagProvider.SetAttribute(L"style", wsValue); |
| 342 } | 342 } |
| 343 } else if (pXMLNode->GetType() == FDE_XMLNODE_Text) { | 343 } else if (pXMLNode->GetType() == FDE_XMLNODE_Text) { |
| 344 tagProvider.m_bTagAvailable = TRUE; | 344 tagProvider.m_bTagAvailable = true; |
| 345 tagProvider.m_bContent = TRUE; | 345 tagProvider.m_bContent = true; |
| 346 } | 346 } |
| 347 } | 347 } |
| 348 | 348 |
| 349 int32_t CXFA_TextParser::GetVAlign(CXFA_TextProvider* pTextProvider) const { | 349 int32_t CXFA_TextParser::GetVAlign(CXFA_TextProvider* pTextProvider) const { |
| 350 CXFA_Para para = pTextProvider->GetParaNode(); | 350 CXFA_Para para = pTextProvider->GetParaNode(); |
| 351 return para ? para.GetVerticalAlign() : XFA_ATTRIBUTEENUM_Top; | 351 return para ? para.GetVerticalAlign() : XFA_ATTRIBUTEENUM_Top; |
| 352 } | 352 } |
| 353 | 353 |
| 354 FX_FLOAT CXFA_TextParser::GetTabInterval(IFDE_CSSComputedStyle* pStyle) const { | 354 FX_FLOAT CXFA_TextParser::GetTabInterval(IFDE_CSSComputedStyle* pStyle) const { |
| 355 CFX_WideString wsValue; | 355 CFX_WideString wsValue; |
| 356 if (pStyle && pStyle->GetCustomStyle(FX_WSTRC(L"tab-interval"), wsValue)) | 356 if (pStyle && pStyle->GetCustomStyle(FX_WSTRC(L"tab-interval"), wsValue)) |
| 357 return CXFA_Measurement(wsValue.AsStringC()).ToUnit(XFA_UNIT_Pt); | 357 return CXFA_Measurement(wsValue.AsStringC()).ToUnit(XFA_UNIT_Pt); |
| 358 return 36; | 358 return 36; |
| 359 } | 359 } |
| 360 | 360 |
| 361 int32_t CXFA_TextParser::CountTabs(IFDE_CSSComputedStyle* pStyle) const { | 361 int32_t CXFA_TextParser::CountTabs(IFDE_CSSComputedStyle* pStyle) const { |
| 362 CFX_WideString wsValue; | 362 CFX_WideString wsValue; |
| 363 if (pStyle && pStyle->GetCustomStyle(FX_WSTRC(L"xfa-tab-count"), wsValue)) | 363 if (pStyle && pStyle->GetCustomStyle(FX_WSTRC(L"xfa-tab-count"), wsValue)) |
| 364 return wsValue.GetInteger(); | 364 return wsValue.GetInteger(); |
| 365 return 0; | 365 return 0; |
| 366 } | 366 } |
| 367 | 367 |
| 368 FX_BOOL CXFA_TextParser::IsSpaceRun(IFDE_CSSComputedStyle* pStyle) const { | 368 bool CXFA_TextParser::IsSpaceRun(IFDE_CSSComputedStyle* pStyle) const { |
| 369 CFX_WideString wsValue; | 369 CFX_WideString wsValue; |
| 370 if (pStyle && pStyle->GetCustomStyle(FX_WSTRC(L"xfa-spacerun"), wsValue)) { | 370 if (pStyle && pStyle->GetCustomStyle(FX_WSTRC(L"xfa-spacerun"), wsValue)) { |
| 371 wsValue.MakeLower(); | 371 wsValue.MakeLower(); |
| 372 return wsValue == FX_WSTRC(L"yes"); | 372 return wsValue == FX_WSTRC(L"yes"); |
| 373 } | 373 } |
| 374 return FALSE; | 374 return false; |
| 375 } | 375 } |
| 376 CFGAS_GEFont* CXFA_TextParser::GetFont(CXFA_TextProvider* pTextProvider, | 376 CFGAS_GEFont* CXFA_TextParser::GetFont(CXFA_TextProvider* pTextProvider, |
| 377 IFDE_CSSComputedStyle* pStyle) const { | 377 IFDE_CSSComputedStyle* pStyle) const { |
| 378 CFX_WideStringC wsFamily = FX_WSTRC(L"Courier"); | 378 CFX_WideStringC wsFamily = FX_WSTRC(L"Courier"); |
| 379 uint32_t dwStyle = 0; | 379 uint32_t dwStyle = 0; |
| 380 CXFA_Font font = pTextProvider->GetFontNode(); | 380 CXFA_Font font = pTextProvider->GetFontNode(); |
| 381 if (font) { | 381 if (font) { |
| 382 font.GetTypeface(wsFamily); | 382 font.GetTypeface(wsFamily); |
| 383 if (font.IsBold()) { | 383 if (font.IsBold()) { |
| 384 dwStyle |= FX_FONTSTYLE_Bold; | 384 dwStyle |= FX_FONTSTYLE_Bold; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 if (pParaStyle->GetVerticalAlign() == FDE_CSSVERTICALALIGN_Number) { | 513 if (pParaStyle->GetVerticalAlign() == FDE_CSSVERTICALALIGN_Number) { |
| 514 return pParaStyle->GetNumberVerticalAlign(); | 514 return pParaStyle->GetNumberVerticalAlign(); |
| 515 } | 515 } |
| 516 } else if (CXFA_Font font = pTextProvider->GetFontNode()) { | 516 } else if (CXFA_Font font = pTextProvider->GetFontNode()) { |
| 517 return font.GetBaselineShift(); | 517 return font.GetBaselineShift(); |
| 518 } | 518 } |
| 519 return 0; | 519 return 0; |
| 520 } | 520 } |
| 521 FX_FLOAT CXFA_TextParser::GetLineHeight(CXFA_TextProvider* pTextProvider, | 521 FX_FLOAT CXFA_TextParser::GetLineHeight(CXFA_TextProvider* pTextProvider, |
| 522 IFDE_CSSComputedStyle* pStyle, | 522 IFDE_CSSComputedStyle* pStyle, |
| 523 FX_BOOL bFirst, | 523 bool bFirst, |
| 524 FX_FLOAT fVerScale) const { | 524 FX_FLOAT fVerScale) const { |
| 525 FX_FLOAT fLineHeight = 0; | 525 FX_FLOAT fLineHeight = 0; |
| 526 if (pStyle) { | 526 if (pStyle) { |
| 527 fLineHeight = pStyle->GetParagraphStyles()->GetLineHeight(); | 527 fLineHeight = pStyle->GetParagraphStyles()->GetLineHeight(); |
| 528 } else if (CXFA_Para para = pTextProvider->GetParaNode()) { | 528 } else if (CXFA_Para para = pTextProvider->GetParaNode()) { |
| 529 fLineHeight = para.GetLineHeight(); | 529 fLineHeight = para.GetLineHeight(); |
| 530 } | 530 } |
| 531 if (bFirst) { | 531 if (bFirst) { |
| 532 FX_FLOAT fFontSize = GetFontSize(pTextProvider, pStyle); | 532 FX_FLOAT fFontSize = GetFontSize(pTextProvider, pStyle); |
| 533 if (fLineHeight < 0.1f) { | 533 if (fLineHeight < 0.1f) { |
| 534 fLineHeight = fFontSize; | 534 fLineHeight = fFontSize; |
| 535 } else { | 535 } else { |
| 536 fLineHeight = std::min(fLineHeight, fFontSize); | 536 fLineHeight = std::min(fLineHeight, fFontSize); |
| 537 } | 537 } |
| 538 } else if (fLineHeight < 0.1f) { | 538 } else if (fLineHeight < 0.1f) { |
| 539 fLineHeight = GetFontSize(pTextProvider, pStyle) * 1.2f; | 539 fLineHeight = GetFontSize(pTextProvider, pStyle) * 1.2f; |
| 540 } | 540 } |
| 541 fLineHeight *= fVerScale; | 541 fLineHeight *= fVerScale; |
| 542 return fLineHeight; | 542 return fLineHeight; |
| 543 } | 543 } |
| 544 FX_BOOL CXFA_TextParser::GetEmbbedObj(CXFA_TextProvider* pTextProvider, | 544 bool CXFA_TextParser::GetEmbbedObj(CXFA_TextProvider* pTextProvider, |
| 545 CFDE_XMLNode* pXMLNode, | 545 CFDE_XMLNode* pXMLNode, |
| 546 CFX_WideString& wsValue) { | 546 CFX_WideString& wsValue) { |
| 547 wsValue.clear(); | 547 wsValue.clear(); |
| 548 if (!pXMLNode) { | 548 if (!pXMLNode) { |
| 549 return FALSE; | 549 return false; |
| 550 } | 550 } |
| 551 FX_BOOL bRet = FALSE; | 551 bool bRet = false; |
| 552 if (pXMLNode->GetType() == FDE_XMLNODE_Element) { | 552 if (pXMLNode->GetType() == FDE_XMLNODE_Element) { |
| 553 CFDE_XMLElement* pElement = static_cast<CFDE_XMLElement*>(pXMLNode); | 553 CFDE_XMLElement* pElement = static_cast<CFDE_XMLElement*>(pXMLNode); |
| 554 CFX_WideString wsAttr; | 554 CFX_WideString wsAttr; |
| 555 pElement->GetString(L"xfa:embed", wsAttr); | 555 pElement->GetString(L"xfa:embed", wsAttr); |
| 556 if (wsAttr.IsEmpty()) { | 556 if (wsAttr.IsEmpty()) { |
| 557 return FALSE; | 557 return false; |
| 558 } | 558 } |
| 559 if (wsAttr.GetAt(0) == L'#') { | 559 if (wsAttr.GetAt(0) == L'#') { |
| 560 wsAttr.Delete(0); | 560 wsAttr.Delete(0); |
| 561 } | 561 } |
| 562 CFX_WideString ws; | 562 CFX_WideString ws; |
| 563 pElement->GetString(L"xfa:embedType", ws); | 563 pElement->GetString(L"xfa:embedType", ws); |
| 564 if (ws.IsEmpty()) { | 564 if (ws.IsEmpty()) { |
| 565 ws = L"som"; | 565 ws = L"som"; |
| 566 } else { | 566 } else { |
| 567 ws.MakeLower(); | 567 ws.MakeLower(); |
| 568 } | 568 } |
| 569 FX_BOOL bURI = (ws == FX_WSTRC(L"uri")); | 569 bool bURI = (ws == FX_WSTRC(L"uri")); |
| 570 if (!bURI && ws != FX_WSTRC(L"som")) { | 570 if (!bURI && ws != FX_WSTRC(L"som")) { |
| 571 return FALSE; | 571 return false; |
| 572 } | 572 } |
| 573 ws.clear(); | 573 ws.clear(); |
| 574 pElement->GetString(L"xfa:embedMode", ws); | 574 pElement->GetString(L"xfa:embedMode", ws); |
| 575 if (ws.IsEmpty()) { | 575 if (ws.IsEmpty()) { |
| 576 ws = L"formatted"; | 576 ws = L"formatted"; |
| 577 } else { | 577 } else { |
| 578 ws.MakeLower(); | 578 ws.MakeLower(); |
| 579 } | 579 } |
| 580 FX_BOOL bRaw = (ws == FX_WSTRC(L"raw")); | 580 bool bRaw = (ws == FX_WSTRC(L"raw")); |
| 581 if (!bRaw && ws != FX_WSTRC(L"formatted")) { | 581 if (!bRaw && ws != FX_WSTRC(L"formatted")) { |
| 582 return FALSE; | 582 return false; |
| 583 } | 583 } |
| 584 bRet = pTextProvider->GetEmbbedObj(bURI, bRaw, wsAttr, wsValue); | 584 bRet = pTextProvider->GetEmbbedObj(bURI, bRaw, wsAttr, wsValue); |
| 585 } | 585 } |
| 586 return bRet; | 586 return bRet; |
| 587 } | 587 } |
| 588 CXFA_TextParseContext* CXFA_TextParser::GetParseContextFromMap( | 588 CXFA_TextParseContext* CXFA_TextParser::GetParseContextFromMap( |
| 589 CFDE_XMLNode* pXMLNode) { | 589 CFDE_XMLNode* pXMLNode) { |
| 590 return (CXFA_TextParseContext*)m_mapXMLNodeToParseContext.GetValueAt( | 590 return (CXFA_TextParseContext*)m_mapXMLNodeToParseContext.GetValueAt( |
| 591 pXMLNode); | 591 pXMLNode); |
| 592 } | 592 } |
| 593 enum XFA_TABSTOPSSTATUS { | 593 enum XFA_TABSTOPSSTATUS { |
| 594 XFA_TABSTOPSSTATUS_Error, | 594 XFA_TABSTOPSSTATUS_Error, |
| 595 XFA_TABSTOPSSTATUS_EOS, | 595 XFA_TABSTOPSSTATUS_EOS, |
| 596 XFA_TABSTOPSSTATUS_None, | 596 XFA_TABSTOPSSTATUS_None, |
| 597 XFA_TABSTOPSSTATUS_Alignment, | 597 XFA_TABSTOPSSTATUS_Alignment, |
| 598 XFA_TABSTOPSSTATUS_StartLeader, | 598 XFA_TABSTOPSSTATUS_StartLeader, |
| 599 XFA_TABSTOPSSTATUS_Leader, | 599 XFA_TABSTOPSSTATUS_Leader, |
| 600 XFA_TABSTOPSSTATUS_Location, | 600 XFA_TABSTOPSSTATUS_Location, |
| 601 }; | 601 }; |
| 602 FX_BOOL CXFA_TextParser::GetTabstops( | 602 bool CXFA_TextParser::GetTabstops(IFDE_CSSComputedStyle* pStyle, |
| 603 IFDE_CSSComputedStyle* pStyle, | 603 CXFA_TextTabstopsContext* pTabstopContext) { |
| 604 CXFA_TextTabstopsContext* pTabstopContext) { | |
| 605 if (!pStyle || !pTabstopContext) { | 604 if (!pStyle || !pTabstopContext) { |
| 606 return FALSE; | 605 return false; |
| 607 } | 606 } |
| 608 CFX_WideString wsValue; | 607 CFX_WideString wsValue; |
| 609 if (!pStyle->GetCustomStyle(FX_WSTRC(L"xfa-tab-stops"), wsValue) && | 608 if (!pStyle->GetCustomStyle(FX_WSTRC(L"xfa-tab-stops"), wsValue) && |
| 610 !pStyle->GetCustomStyle(FX_WSTRC(L"tab-stops"), wsValue)) { | 609 !pStyle->GetCustomStyle(FX_WSTRC(L"tab-stops"), wsValue)) { |
| 611 return FALSE; | 610 return false; |
| 612 } | 611 } |
| 613 int32_t iLength = wsValue.GetLength(); | 612 int32_t iLength = wsValue.GetLength(); |
| 614 const FX_WCHAR* pTabStops = wsValue.c_str(); | 613 const FX_WCHAR* pTabStops = wsValue.c_str(); |
| 615 int32_t iCur = 0; | 614 int32_t iCur = 0; |
| 616 int32_t iLast = 0; | 615 int32_t iLast = 0; |
| 617 CFX_WideString wsAlign; | 616 CFX_WideString wsAlign; |
| 618 XFA_TABSTOPSSTATUS eStatus = XFA_TABSTOPSSTATUS_None; | 617 XFA_TABSTOPSSTATUS eStatus = XFA_TABSTOPSSTATUS_None; |
| 619 FX_WCHAR ch; | 618 FX_WCHAR ch; |
| 620 while (iCur < iLength) { | 619 while (iCur < iLength) { |
| 621 ch = pTabStops[iCur]; | 620 ch = pTabStops[iCur]; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 default: | 678 default: |
| 680 break; | 679 break; |
| 681 } | 680 } |
| 682 } | 681 } |
| 683 if (!wsAlign.IsEmpty()) { | 682 if (!wsAlign.IsEmpty()) { |
| 684 uint32_t dwHashCode = FX_HashCode_GetW(wsAlign.AsStringC(), true); | 683 uint32_t dwHashCode = FX_HashCode_GetW(wsAlign.AsStringC(), true); |
| 685 CXFA_Measurement ms(CFX_WideStringC(pTabStops + iLast, iCur - iLast)); | 684 CXFA_Measurement ms(CFX_WideStringC(pTabStops + iLast, iCur - iLast)); |
| 686 FX_FLOAT fPos = ms.ToUnit(XFA_UNIT_Pt); | 685 FX_FLOAT fPos = ms.ToUnit(XFA_UNIT_Pt); |
| 687 pTabstopContext->Append(dwHashCode, fPos); | 686 pTabstopContext->Append(dwHashCode, fPos); |
| 688 } | 687 } |
| 689 return TRUE; | 688 return true; |
| 690 } | 689 } |
| 691 | 690 |
| 692 CXFA_TextLayout::CXFA_TextLayout(CXFA_TextProvider* pTextProvider) | 691 CXFA_TextLayout::CXFA_TextLayout(CXFA_TextProvider* pTextProvider) |
| 693 : m_bHasBlock(FALSE), | 692 : m_bHasBlock(false), |
| 694 m_pTextProvider(pTextProvider), | 693 m_pTextProvider(pTextProvider), |
| 695 m_pTextDataNode(nullptr), | 694 m_pTextDataNode(nullptr), |
| 696 m_bRichText(FALSE), | 695 m_bRichText(false), |
| 697 m_iLines(0), | 696 m_iLines(0), |
| 698 m_fMaxWidth(0), | 697 m_fMaxWidth(0), |
| 699 m_bBlockContinue(TRUE) { | 698 m_bBlockContinue(true) { |
| 700 ASSERT(m_pTextProvider); | 699 ASSERT(m_pTextProvider); |
| 701 } | 700 } |
| 702 | 701 |
| 703 CXFA_TextLayout::~CXFA_TextLayout() { | 702 CXFA_TextLayout::~CXFA_TextLayout() { |
| 704 m_textParser.Reset(); | 703 m_textParser.Reset(); |
| 705 Unload(); | 704 Unload(); |
| 706 } | 705 } |
| 707 | 706 |
| 708 void CXFA_TextLayout::Unload() { | 707 void CXFA_TextLayout::Unload() { |
| 709 for (int32_t i = 0; i < m_pieceLines.GetSize(); i++) { | 708 for (int32_t i = 0; i < m_pieceLines.GetSize(); i++) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 pXMLElement->GetLocalTagName(wsTag); | 755 pXMLElement->GetLocalTagName(wsTag); |
| 757 if (wsTag == FX_WSTRC(L"body") || wsTag == FX_WSTRC(L"html")) { | 756 if (wsTag == FX_WSTRC(L"body") || wsTag == FX_WSTRC(L"html")) { |
| 758 pXMLContainer = pXMLChild; | 757 pXMLContainer = pXMLChild; |
| 759 break; | 758 break; |
| 760 } | 759 } |
| 761 } | 760 } |
| 762 } | 761 } |
| 763 } | 762 } |
| 764 return pXMLContainer; | 763 return pXMLContainer; |
| 765 } | 764 } |
| 766 CFX_RTFBreak* CXFA_TextLayout::CreateBreak(FX_BOOL bDefault) { | 765 CFX_RTFBreak* CXFA_TextLayout::CreateBreak(bool bDefault) { |
| 767 uint32_t dwStyle = FX_RTFLAYOUTSTYLE_ExpandTab; | 766 uint32_t dwStyle = FX_RTFLAYOUTSTYLE_ExpandTab; |
| 768 if (!bDefault) { | 767 if (!bDefault) { |
| 769 dwStyle |= FX_RTFLAYOUTSTYLE_Pagination; | 768 dwStyle |= FX_RTFLAYOUTSTYLE_Pagination; |
| 770 } | 769 } |
| 771 CFX_RTFBreak* pBreak = new CFX_RTFBreak(0); | 770 CFX_RTFBreak* pBreak = new CFX_RTFBreak(0); |
| 772 pBreak->SetLayoutStyles(dwStyle); | 771 pBreak->SetLayoutStyles(dwStyle); |
| 773 pBreak->SetLineBreakChar(L'\n'); | 772 pBreak->SetLineBreakChar(L'\n'); |
| 774 pBreak->SetLineBreakTolerance(1); | 773 pBreak->SetLineBreakTolerance(1); |
| 775 pBreak->SetFont(m_textParser.GetFont(m_pTextProvider, nullptr)); | 774 pBreak->SetFont(m_textParser.GetFont(m_pTextProvider, nullptr)); |
| 776 pBreak->SetFontSize(m_textParser.GetFontSize(m_pTextProvider, nullptr)); | 775 pBreak->SetFontSize(m_textParser.GetFontSize(m_pTextProvider, nullptr)); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 return wsText.GetLength(); | 921 return wsText.GetLength(); |
| 923 } | 922 } |
| 924 FX_FLOAT CXFA_TextLayout::GetLayoutHeight() { | 923 FX_FLOAT CXFA_TextLayout::GetLayoutHeight() { |
| 925 if (!m_pLoader) { | 924 if (!m_pLoader) { |
| 926 return 0; | 925 return 0; |
| 927 } | 926 } |
| 928 int32_t iCount = m_pLoader->m_lineHeights.GetSize(); | 927 int32_t iCount = m_pLoader->m_lineHeights.GetSize(); |
| 929 if (iCount == 0 && m_pLoader->m_fWidth > 0) { | 928 if (iCount == 0 && m_pLoader->m_fWidth > 0) { |
| 930 CFX_SizeF szMax(m_pLoader->m_fWidth, m_pLoader->m_fHeight); | 929 CFX_SizeF szMax(m_pLoader->m_fWidth, m_pLoader->m_fHeight); |
| 931 CFX_SizeF szDef; | 930 CFX_SizeF szDef; |
| 932 m_pLoader->m_bSaveLineHeight = TRUE; | 931 m_pLoader->m_bSaveLineHeight = true; |
| 933 m_pLoader->m_fLastPos = 0; | 932 m_pLoader->m_fLastPos = 0; |
| 934 CalcSize(szMax, szMax, szDef); | 933 CalcSize(szMax, szMax, szDef); |
| 935 m_pLoader->m_bSaveLineHeight = FALSE; | 934 m_pLoader->m_bSaveLineHeight = false; |
| 936 return szDef.y; | 935 return szDef.y; |
| 937 } | 936 } |
| 938 FX_FLOAT fHeight = m_pLoader->m_fHeight; | 937 FX_FLOAT fHeight = m_pLoader->m_fHeight; |
| 939 if (fHeight < 0.1f) { | 938 if (fHeight < 0.1f) { |
| 940 fHeight = 0; | 939 fHeight = 0; |
| 941 for (int32_t i = 0; i < iCount; i++) { | 940 for (int32_t i = 0; i < iCount; i++) { |
| 942 fHeight += m_pLoader->m_lineHeights.ElementAt(i); | 941 fHeight += m_pLoader->m_lineHeights.ElementAt(i); |
| 943 } | 942 } |
| 944 } | 943 } |
| 945 return fHeight; | 944 return fHeight; |
| 946 } | 945 } |
| 947 FX_FLOAT CXFA_TextLayout::StartLayout(FX_FLOAT fWidth) { | 946 FX_FLOAT CXFA_TextLayout::StartLayout(FX_FLOAT fWidth) { |
| 948 if (!m_pLoader) | 947 if (!m_pLoader) |
| 949 m_pLoader.reset(new CXFA_LoaderContext); | 948 m_pLoader.reset(new CXFA_LoaderContext); |
| 950 | 949 |
| 951 if (fWidth < 0 || (m_pLoader->m_fWidth > -1 && | 950 if (fWidth < 0 || (m_pLoader->m_fWidth > -1 && |
| 952 FXSYS_fabs(fWidth - m_pLoader->m_fWidth) > 0)) { | 951 FXSYS_fabs(fWidth - m_pLoader->m_fWidth) > 0)) { |
| 953 m_pLoader->m_lineHeights.RemoveAll(); | 952 m_pLoader->m_lineHeights.RemoveAll(); |
| 954 m_Blocks.RemoveAll(); | 953 m_Blocks.RemoveAll(); |
| 955 Unload(); | 954 Unload(); |
| 956 m_pLoader->m_fStartLineOffset = 0; | 955 m_pLoader->m_fStartLineOffset = 0; |
| 957 } | 956 } |
| 958 m_pLoader->m_fWidth = fWidth; | 957 m_pLoader->m_fWidth = fWidth; |
| 959 if (fWidth < 0) { | 958 if (fWidth < 0) { |
| 960 CFX_SizeF szMax; | 959 CFX_SizeF szMax; |
| 961 CFX_SizeF szDef; | 960 CFX_SizeF szDef; |
| 962 m_pLoader->m_bSaveLineHeight = TRUE; | 961 m_pLoader->m_bSaveLineHeight = true; |
| 963 m_pLoader->m_fLastPos = 0; | 962 m_pLoader->m_fLastPos = 0; |
| 964 CalcSize(szMax, szMax, szDef); | 963 CalcSize(szMax, szMax, szDef); |
| 965 m_pLoader->m_bSaveLineHeight = FALSE; | 964 m_pLoader->m_bSaveLineHeight = false; |
| 966 fWidth = szDef.x; | 965 fWidth = szDef.x; |
| 967 } | 966 } |
| 968 return fWidth; | 967 return fWidth; |
| 969 } | 968 } |
| 970 FX_BOOL CXFA_TextLayout::DoLayout(int32_t iBlockIndex, | 969 bool CXFA_TextLayout::DoLayout(int32_t iBlockIndex, |
| 971 FX_FLOAT& fCalcHeight, | 970 FX_FLOAT& fCalcHeight, |
| 972 FX_FLOAT fContentAreaHeight, | 971 FX_FLOAT fContentAreaHeight, |
| 973 FX_FLOAT fTextHeight) { | 972 FX_FLOAT fTextHeight) { |
| 974 if (!m_pLoader) { | 973 if (!m_pLoader) { |
| 975 return FALSE; | 974 return false; |
| 976 } | 975 } |
| 977 int32_t iBlockCount = m_Blocks.GetSize(); | 976 int32_t iBlockCount = m_Blocks.GetSize(); |
| 978 FX_FLOAT fHeight = fTextHeight; | 977 FX_FLOAT fHeight = fTextHeight; |
| 979 if (fHeight < 0) { | 978 if (fHeight < 0) { |
| 980 fHeight = GetLayoutHeight(); | 979 fHeight = GetLayoutHeight(); |
| 981 } | 980 } |
| 982 m_pLoader->m_fHeight = fHeight; | 981 m_pLoader->m_fHeight = fHeight; |
| 983 if (fContentAreaHeight < 0) { | 982 if (fContentAreaHeight < 0) { |
| 984 return FALSE; | 983 return false; |
| 985 } | 984 } |
| 986 m_bHasBlock = TRUE; | 985 m_bHasBlock = true; |
| 987 if (iBlockCount == 0 && fHeight > 0) { | 986 if (iBlockCount == 0 && fHeight > 0) { |
| 988 fHeight = fTextHeight - GetLayoutHeight(); | 987 fHeight = fTextHeight - GetLayoutHeight(); |
| 989 if (fHeight > 0) { | 988 if (fHeight > 0) { |
| 990 int32_t iAlign = m_textParser.GetVAlign(m_pTextProvider); | 989 int32_t iAlign = m_textParser.GetVAlign(m_pTextProvider); |
| 991 if (iAlign == XFA_ATTRIBUTEENUM_Middle) { | 990 if (iAlign == XFA_ATTRIBUTEENUM_Middle) { |
| 992 fHeight /= 2.0f; | 991 fHeight /= 2.0f; |
| 993 } else if (iAlign != XFA_ATTRIBUTEENUM_Bottom) { | 992 } else if (iAlign != XFA_ATTRIBUTEENUM_Bottom) { |
| 994 fHeight = 0; | 993 fHeight = 0; |
| 995 } | 994 } |
| 996 m_pLoader->m_fStartLineOffset = fHeight; | 995 m_pLoader->m_fStartLineOffset = fHeight; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1010 fLinePos -= m_pLoader->m_BlocksHeight.ElementAt(i * 2 + 1); | 1009 fLinePos -= m_pLoader->m_BlocksHeight.ElementAt(i * 2 + 1); |
| 1011 } | 1010 } |
| 1012 } | 1011 } |
| 1013 } | 1012 } |
| 1014 int32_t iCount = m_pLoader->m_lineHeights.GetSize(); | 1013 int32_t iCount = m_pLoader->m_lineHeights.GetSize(); |
| 1015 int32_t i = 0; | 1014 int32_t i = 0; |
| 1016 for (i = iLineIndex; i < iCount; i++) { | 1015 for (i = iLineIndex; i < iCount; i++) { |
| 1017 FX_FLOAT fLineHeight = m_pLoader->m_lineHeights.ElementAt(i); | 1016 FX_FLOAT fLineHeight = m_pLoader->m_lineHeights.ElementAt(i); |
| 1018 if ((i == iLineIndex) && (fLineHeight - fContentAreaHeight > 0.001)) { | 1017 if ((i == iLineIndex) && (fLineHeight - fContentAreaHeight > 0.001)) { |
| 1019 fCalcHeight = 0; | 1018 fCalcHeight = 0; |
| 1020 return TRUE; | 1019 return true; |
| 1021 } | 1020 } |
| 1022 if (fLinePos + fLineHeight - fContentAreaHeight > 0.001) { | 1021 if (fLinePos + fLineHeight - fContentAreaHeight > 0.001) { |
| 1023 if (iBlockCount >= (iBlockIndex + 1) * 2) { | 1022 if (iBlockCount >= (iBlockIndex + 1) * 2) { |
| 1024 m_Blocks.SetAt(iBlockIndex * 2, iLineIndex); | 1023 m_Blocks.SetAt(iBlockIndex * 2, iLineIndex); |
| 1025 m_Blocks.SetAt(iBlockIndex * 2 + 1, i - iLineIndex); | 1024 m_Blocks.SetAt(iBlockIndex * 2 + 1, i - iLineIndex); |
| 1026 } else { | 1025 } else { |
| 1027 m_Blocks.Add(iLineIndex); | 1026 m_Blocks.Add(iLineIndex); |
| 1028 m_Blocks.Add(i - iLineIndex); | 1027 m_Blocks.Add(i - iLineIndex); |
| 1029 } | 1028 } |
| 1030 if (i == iLineIndex) { | 1029 if (i == iLineIndex) { |
| 1031 if (fCalcHeight <= fLinePos) { | 1030 if (fCalcHeight <= fLinePos) { |
| 1032 if (m_pLoader->m_BlocksHeight.GetSize() > iBlockIndex * 2 && | 1031 if (m_pLoader->m_BlocksHeight.GetSize() > iBlockIndex * 2 && |
| 1033 (m_pLoader->m_BlocksHeight.GetAt(iBlockIndex * 2) == | 1032 (m_pLoader->m_BlocksHeight.GetAt(iBlockIndex * 2) == |
| 1034 iBlockIndex)) { | 1033 iBlockIndex)) { |
| 1035 m_pLoader->m_BlocksHeight.SetAt(iBlockIndex * 2 + 1, fCalcHeight); | 1034 m_pLoader->m_BlocksHeight.SetAt(iBlockIndex * 2 + 1, fCalcHeight); |
| 1036 } else { | 1035 } else { |
| 1037 m_pLoader->m_BlocksHeight.Add((FX_FLOAT)iBlockIndex); | 1036 m_pLoader->m_BlocksHeight.Add((FX_FLOAT)iBlockIndex); |
| 1038 m_pLoader->m_BlocksHeight.Add(fCalcHeight); | 1037 m_pLoader->m_BlocksHeight.Add(fCalcHeight); |
| 1039 } | 1038 } |
| 1040 } | 1039 } |
| 1041 return TRUE; | 1040 return true; |
| 1042 } | 1041 } |
| 1043 fCalcHeight = fLinePos; | 1042 fCalcHeight = fLinePos; |
| 1044 return TRUE; | 1043 return true; |
| 1045 } | 1044 } |
| 1046 fLinePos += fLineHeight; | 1045 fLinePos += fLineHeight; |
| 1047 } | 1046 } |
| 1048 return FALSE; | 1047 return false; |
| 1049 } | 1048 } |
| 1050 int32_t CXFA_TextLayout::CountBlocks() const { | 1049 int32_t CXFA_TextLayout::CountBlocks() const { |
| 1051 int32_t iCount = m_Blocks.GetSize() / 2; | 1050 int32_t iCount = m_Blocks.GetSize() / 2; |
| 1052 return iCount > 0 ? iCount : 1; | 1051 return iCount > 0 ? iCount : 1; |
| 1053 } | 1052 } |
| 1054 | 1053 |
| 1055 FX_BOOL CXFA_TextLayout::CalcSize(const CFX_SizeF& minSize, | 1054 bool CXFA_TextLayout::CalcSize(const CFX_SizeF& minSize, |
| 1056 const CFX_SizeF& maxSize, | 1055 const CFX_SizeF& maxSize, |
| 1057 CFX_SizeF& defaultSize) { | 1056 CFX_SizeF& defaultSize) { |
| 1058 defaultSize.x = maxSize.x; | 1057 defaultSize.x = maxSize.x; |
| 1059 if (defaultSize.x < 1) | 1058 if (defaultSize.x < 1) |
| 1060 defaultSize.x = 0xFFFF; | 1059 defaultSize.x = 0xFFFF; |
| 1061 | 1060 |
| 1062 m_pBreak.reset(CreateBreak(FALSE)); | 1061 m_pBreak.reset(CreateBreak(false)); |
| 1063 FX_FLOAT fLinePos = 0; | 1062 FX_FLOAT fLinePos = 0; |
| 1064 m_iLines = 0; | 1063 m_iLines = 0; |
| 1065 m_fMaxWidth = 0; | 1064 m_fMaxWidth = 0; |
| 1066 Loader(defaultSize, fLinePos, FALSE); | 1065 Loader(defaultSize, fLinePos, false); |
| 1067 if (fLinePos < 0.1f) | 1066 if (fLinePos < 0.1f) |
| 1068 fLinePos = m_textParser.GetFontSize(m_pTextProvider, nullptr); | 1067 fLinePos = m_textParser.GetFontSize(m_pTextProvider, nullptr); |
| 1069 | 1068 |
| 1070 m_pTabstopContext.reset(); | 1069 m_pTabstopContext.reset(); |
| 1071 defaultSize = CFX_SizeF(m_fMaxWidth, fLinePos); | 1070 defaultSize = CFX_SizeF(m_fMaxWidth, fLinePos); |
| 1072 return TRUE; | 1071 return true; |
| 1073 } | 1072 } |
| 1074 | 1073 |
| 1075 FX_BOOL CXFA_TextLayout::Layout(const CFX_SizeF& size, FX_FLOAT* fHeight) { | 1074 bool CXFA_TextLayout::Layout(const CFX_SizeF& size, FX_FLOAT* fHeight) { |
| 1076 if (size.x < 1) | 1075 if (size.x < 1) |
| 1077 return FALSE; | 1076 return false; |
| 1078 | 1077 |
| 1079 Unload(); | 1078 Unload(); |
| 1080 m_pBreak.reset(CreateBreak(TRUE)); | 1079 m_pBreak.reset(CreateBreak(true)); |
| 1081 if (m_pLoader) { | 1080 if (m_pLoader) { |
| 1082 m_pLoader->m_iTotalLines = -1; | 1081 m_pLoader->m_iTotalLines = -1; |
| 1083 m_pLoader->m_iChar = 0; | 1082 m_pLoader->m_iChar = 0; |
| 1084 } | 1083 } |
| 1085 m_iLines = 0; | 1084 m_iLines = 0; |
| 1086 FX_FLOAT fLinePos = 0; | 1085 FX_FLOAT fLinePos = 0; |
| 1087 Loader(size, fLinePos, TRUE); | 1086 Loader(size, fLinePos, true); |
| 1088 UpdateAlign(size.y, fLinePos); | 1087 UpdateAlign(size.y, fLinePos); |
| 1089 m_pTabstopContext.reset(); | 1088 m_pTabstopContext.reset(); |
| 1090 if (fHeight) | 1089 if (fHeight) |
| 1091 *fHeight = fLinePos; | 1090 *fHeight = fLinePos; |
| 1092 return TRUE; | 1091 return true; |
| 1093 } | 1092 } |
| 1094 | 1093 |
| 1095 FX_BOOL CXFA_TextLayout::Layout(int32_t iBlock) { | 1094 bool CXFA_TextLayout::Layout(int32_t iBlock) { |
| 1096 if (!m_pLoader || iBlock < 0 || iBlock >= CountBlocks()) | 1095 if (!m_pLoader || iBlock < 0 || iBlock >= CountBlocks()) |
| 1097 return FALSE; | 1096 return false; |
| 1098 if (m_pLoader->m_fWidth < 1) | 1097 if (m_pLoader->m_fWidth < 1) |
| 1099 return FALSE; | 1098 return false; |
| 1100 | 1099 |
| 1101 m_pLoader->m_iTotalLines = -1; | 1100 m_pLoader->m_iTotalLines = -1; |
| 1102 m_iLines = 0; | 1101 m_iLines = 0; |
| 1103 FX_FLOAT fLinePos = 0; | 1102 FX_FLOAT fLinePos = 0; |
| 1104 CXFA_Node* pNode = nullptr; | 1103 CXFA_Node* pNode = nullptr; |
| 1105 CFX_SizeF szText(m_pLoader->m_fWidth, m_pLoader->m_fHeight); | 1104 CFX_SizeF szText(m_pLoader->m_fWidth, m_pLoader->m_fHeight); |
| 1106 int32_t iCount = m_Blocks.GetSize(); | 1105 int32_t iCount = m_Blocks.GetSize(); |
| 1107 int32_t iBlocksHeightCount = m_pLoader->m_BlocksHeight.GetSize(); | 1106 int32_t iBlocksHeightCount = m_pLoader->m_BlocksHeight.GetSize(); |
| 1108 iBlocksHeightCount /= 2; | 1107 iBlocksHeightCount /= 2; |
| 1109 if (iBlock < iBlocksHeightCount) | 1108 if (iBlock < iBlocksHeightCount) |
| 1110 return TRUE; | 1109 return true; |
| 1111 if (iBlock == iBlocksHeightCount) { | 1110 if (iBlock == iBlocksHeightCount) { |
| 1112 Unload(); | 1111 Unload(); |
| 1113 m_pBreak.reset(CreateBreak(TRUE)); | 1112 m_pBreak.reset(CreateBreak(true)); |
| 1114 fLinePos = m_pLoader->m_fStartLineOffset; | 1113 fLinePos = m_pLoader->m_fStartLineOffset; |
| 1115 for (int32_t i = 0; i < iBlocksHeightCount; i++) { | 1114 for (int32_t i = 0; i < iBlocksHeightCount; i++) { |
| 1116 fLinePos -= m_pLoader->m_BlocksHeight.ElementAt(i * 2 + 1); | 1115 fLinePos -= m_pLoader->m_BlocksHeight.ElementAt(i * 2 + 1); |
| 1117 } | 1116 } |
| 1118 m_pLoader->m_iChar = 0; | 1117 m_pLoader->m_iChar = 0; |
| 1119 if (iCount > 1) | 1118 if (iCount > 1) |
| 1120 m_pLoader->m_iTotalLines = m_Blocks.ElementAt(iBlock * 2 + 1); | 1119 m_pLoader->m_iTotalLines = m_Blocks.ElementAt(iBlock * 2 + 1); |
| 1121 Loader(szText, fLinePos, TRUE); | 1120 Loader(szText, fLinePos, true); |
| 1122 if (iCount == 0 && m_pLoader->m_fStartLineOffset < 0.1f) | 1121 if (iCount == 0 && m_pLoader->m_fStartLineOffset < 0.1f) |
| 1123 UpdateAlign(szText.y, fLinePos); | 1122 UpdateAlign(szText.y, fLinePos); |
| 1124 } else if (m_pTextDataNode) { | 1123 } else if (m_pTextDataNode) { |
| 1125 iBlock *= 2; | 1124 iBlock *= 2; |
| 1126 if (iBlock < iCount - 2) | 1125 if (iBlock < iCount - 2) |
| 1127 m_pLoader->m_iTotalLines = m_Blocks.ElementAt(iBlock + 1); | 1126 m_pLoader->m_iTotalLines = m_Blocks.ElementAt(iBlock + 1); |
| 1128 m_pBreak->Reset(); | 1127 m_pBreak->Reset(); |
| 1129 if (m_bRichText) { | 1128 if (m_bRichText) { |
| 1130 CFDE_XMLNode* pContainerNode = GetXMLContainerNode(); | 1129 CFDE_XMLNode* pContainerNode = GetXMLContainerNode(); |
| 1131 if (!pContainerNode) { | 1130 if (!pContainerNode) { |
| 1132 return TRUE; | 1131 return true; |
| 1133 } | 1132 } |
| 1134 CFDE_XMLNode* pXMLNode = m_pLoader->m_pXMLNode; | 1133 CFDE_XMLNode* pXMLNode = m_pLoader->m_pXMLNode; |
| 1135 if (!pXMLNode) | 1134 if (!pXMLNode) |
| 1136 return TRUE; | 1135 return true; |
| 1137 CFDE_XMLNode* pSaveXMLNode = m_pLoader->m_pXMLNode; | 1136 CFDE_XMLNode* pSaveXMLNode = m_pLoader->m_pXMLNode; |
| 1138 for (; pXMLNode; | 1137 for (; pXMLNode; |
| 1139 pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { | 1138 pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { |
| 1140 if (!LoadRichText(pXMLNode, szText, fLinePos, m_pLoader->m_pParentStyle, | 1139 if (!LoadRichText(pXMLNode, szText, fLinePos, m_pLoader->m_pParentStyle, |
| 1141 TRUE)) { | 1140 true)) { |
| 1142 break; | 1141 break; |
| 1143 } | 1142 } |
| 1144 } | 1143 } |
| 1145 while (!pXMLNode) { | 1144 while (!pXMLNode) { |
| 1146 pXMLNode = pSaveXMLNode->GetNodeItem(CFDE_XMLNode::Parent); | 1145 pXMLNode = pSaveXMLNode->GetNodeItem(CFDE_XMLNode::Parent); |
| 1147 if (pXMLNode == pContainerNode) | 1146 if (pXMLNode == pContainerNode) |
| 1148 break; | 1147 break; |
| 1149 if (!LoadRichText(pXMLNode, szText, fLinePos, m_pLoader->m_pParentStyle, | 1148 if (!LoadRichText(pXMLNode, szText, fLinePos, m_pLoader->m_pParentStyle, |
| 1150 TRUE, nullptr, FALSE)) { | 1149 true, nullptr, false)) { |
| 1151 break; | 1150 break; |
| 1152 } | 1151 } |
| 1153 pSaveXMLNode = pXMLNode; | 1152 pSaveXMLNode = pXMLNode; |
| 1154 pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling); | 1153 pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling); |
| 1155 if (!pXMLNode) | 1154 if (!pXMLNode) |
| 1156 continue; | 1155 continue; |
| 1157 for (; pXMLNode; | 1156 for (; pXMLNode; |
| 1158 pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { | 1157 pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { |
| 1159 if (!LoadRichText(pXMLNode, szText, fLinePos, | 1158 if (!LoadRichText(pXMLNode, szText, fLinePos, |
| 1160 m_pLoader->m_pParentStyle, TRUE)) { | 1159 m_pLoader->m_pParentStyle, true)) { |
| 1161 break; | 1160 break; |
| 1162 } | 1161 } |
| 1163 } | 1162 } |
| 1164 } | 1163 } |
| 1165 } else { | 1164 } else { |
| 1166 pNode = m_pLoader->m_pNode; | 1165 pNode = m_pLoader->m_pNode; |
| 1167 if (!pNode) | 1166 if (!pNode) |
| 1168 return TRUE; | 1167 return true; |
| 1169 LoadText(pNode, szText, fLinePos, TRUE); | 1168 LoadText(pNode, szText, fLinePos, true); |
| 1170 } | 1169 } |
| 1171 } | 1170 } |
| 1172 if (iBlock == iCount) { | 1171 if (iBlock == iCount) { |
| 1173 m_pTabstopContext.reset(); | 1172 m_pTabstopContext.reset(); |
| 1174 m_pLoader.reset(); | 1173 m_pLoader.reset(); |
| 1175 } | 1174 } |
| 1176 return TRUE; | 1175 return true; |
| 1177 } | 1176 } |
| 1178 void CXFA_TextLayout::ItemBlocks(const CFX_RectF& rtText, int32_t iBlockIndex) { | 1177 void CXFA_TextLayout::ItemBlocks(const CFX_RectF& rtText, int32_t iBlockIndex) { |
| 1179 if (!m_pLoader) { | 1178 if (!m_pLoader) { |
| 1180 return; | 1179 return; |
| 1181 } | 1180 } |
| 1182 int32_t iCountHeight = m_pLoader->m_lineHeights.GetSize(); | 1181 int32_t iCountHeight = m_pLoader->m_lineHeights.GetSize(); |
| 1183 if (iCountHeight == 0) { | 1182 if (iCountHeight == 0) { |
| 1184 return; | 1183 return; |
| 1185 } | 1184 } |
| 1186 FX_BOOL bEndItem = TRUE; | 1185 bool bEndItem = true; |
| 1187 int32_t iBlockCount = m_Blocks.GetSize(); | 1186 int32_t iBlockCount = m_Blocks.GetSize(); |
| 1188 FX_FLOAT fLinePos = m_pLoader->m_fStartLineOffset; | 1187 FX_FLOAT fLinePos = m_pLoader->m_fStartLineOffset; |
| 1189 int32_t iLineIndex = 0; | 1188 int32_t iLineIndex = 0; |
| 1190 if (iBlockIndex > 0) { | 1189 if (iBlockIndex > 0) { |
| 1191 int32_t iBlockHeightCount = m_pLoader->m_BlocksHeight.GetSize(); | 1190 int32_t iBlockHeightCount = m_pLoader->m_BlocksHeight.GetSize(); |
| 1192 iBlockHeightCount /= 2; | 1191 iBlockHeightCount /= 2; |
| 1193 if (iBlockHeightCount >= iBlockIndex) { | 1192 if (iBlockHeightCount >= iBlockIndex) { |
| 1194 for (int32_t i = 0; i < iBlockIndex; i++) { | 1193 for (int32_t i = 0; i < iBlockIndex; i++) { |
| 1195 fLinePos -= m_pLoader->m_BlocksHeight.ElementAt(i * 2 + 1); | 1194 fLinePos -= m_pLoader->m_BlocksHeight.ElementAt(i * 2 + 1); |
| 1196 } | 1195 } |
| 1197 } else { | 1196 } else { |
| 1198 fLinePos = 0; | 1197 fLinePos = 0; |
| 1199 } | 1198 } |
| 1200 iLineIndex = m_Blocks.ElementAt(iBlockCount - 1) + | 1199 iLineIndex = m_Blocks.ElementAt(iBlockCount - 1) + |
| 1201 m_Blocks.ElementAt(iBlockCount - 2); | 1200 m_Blocks.ElementAt(iBlockCount - 2); |
| 1202 } | 1201 } |
| 1203 int32_t i = 0; | 1202 int32_t i = 0; |
| 1204 for (i = iLineIndex; i < iCountHeight; i++) { | 1203 for (i = iLineIndex; i < iCountHeight; i++) { |
| 1205 FX_FLOAT fLineHeight = m_pLoader->m_lineHeights.ElementAt(i); | 1204 FX_FLOAT fLineHeight = m_pLoader->m_lineHeights.ElementAt(i); |
| 1206 if (fLinePos + fLineHeight - rtText.height > 0.001) { | 1205 if (fLinePos + fLineHeight - rtText.height > 0.001) { |
| 1207 m_Blocks.Add(iLineIndex); | 1206 m_Blocks.Add(iLineIndex); |
| 1208 m_Blocks.Add(i - iLineIndex); | 1207 m_Blocks.Add(i - iLineIndex); |
| 1209 bEndItem = FALSE; | 1208 bEndItem = false; |
| 1210 break; | 1209 break; |
| 1211 } | 1210 } |
| 1212 fLinePos += fLineHeight; | 1211 fLinePos += fLineHeight; |
| 1213 } | 1212 } |
| 1214 if (iCountHeight > 0 && (i - iLineIndex) > 0 && bEndItem) { | 1213 if (iCountHeight > 0 && (i - iLineIndex) > 0 && bEndItem) { |
| 1215 m_Blocks.Add(iLineIndex); | 1214 m_Blocks.Add(iLineIndex); |
| 1216 m_Blocks.Add(i - iLineIndex); | 1215 m_Blocks.Add(i - iLineIndex); |
| 1217 } | 1216 } |
| 1218 } | 1217 } |
| 1219 FX_BOOL CXFA_TextLayout::DrawString(CFX_RenderDevice* pFxDevice, | 1218 bool CXFA_TextLayout::DrawString(CFX_RenderDevice* pFxDevice, |
| 1220 const CFX_Matrix& tmDoc2Device, | 1219 const CFX_Matrix& tmDoc2Device, |
| 1221 const CFX_RectF& rtClip, | 1220 const CFX_RectF& rtClip, |
| 1222 int32_t iBlock) { | 1221 int32_t iBlock) { |
| 1223 if (!pFxDevice) | 1222 if (!pFxDevice) |
| 1224 return FALSE; | 1223 return false; |
| 1225 | 1224 |
| 1226 std::unique_ptr<CFDE_RenderDevice> pDevice( | 1225 std::unique_ptr<CFDE_RenderDevice> pDevice( |
| 1227 new CFDE_RenderDevice(pFxDevice, FALSE)); | 1226 new CFDE_RenderDevice(pFxDevice, false)); |
| 1228 pDevice->SaveState(); | 1227 pDevice->SaveState(); |
| 1229 pDevice->SetClipRect(rtClip); | 1228 pDevice->SetClipRect(rtClip); |
| 1230 | 1229 |
| 1231 std::unique_ptr<CFDE_Brush> pSolidBrush(new CFDE_Brush); | 1230 std::unique_ptr<CFDE_Brush> pSolidBrush(new CFDE_Brush); |
| 1232 std::unique_ptr<CFDE_Pen> pPen(new CFDE_Pen); | 1231 std::unique_ptr<CFDE_Pen> pPen(new CFDE_Pen); |
| 1233 if (m_pieceLines.GetSize() == 0) { | 1232 if (m_pieceLines.GetSize() == 0) { |
| 1234 int32_t iBlockCount = CountBlocks(); | 1233 int32_t iBlockCount = CountBlocks(); |
| 1235 for (int32_t i = 0; i < iBlockCount; i++) { | 1234 for (int32_t i = 0; i < iBlockCount; i++) { |
| 1236 Layout(i); | 1235 Layout(i); |
| 1237 } | 1236 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1296 for (int32_t i = 0; i < iCount; i++) { | 1295 for (int32_t i = 0; i < iCount; i++) { |
| 1297 CXFA_PieceLine* pPieceLine = m_pieceLines.GetAt(i); | 1296 CXFA_PieceLine* pPieceLine = m_pieceLines.GetAt(i); |
| 1298 int32_t iPieces = pPieceLine->m_textPieces.GetSize(); | 1297 int32_t iPieces = pPieceLine->m_textPieces.GetSize(); |
| 1299 for (int32_t j = 0; j < iPieces; j++) { | 1298 for (int32_t j = 0; j < iPieces; j++) { |
| 1300 XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(j); | 1299 XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(j); |
| 1301 CFX_RectF& rect = pPiece->rtPiece; | 1300 CFX_RectF& rect = pPiece->rtPiece; |
| 1302 rect.top += fHeight; | 1301 rect.top += fHeight; |
| 1303 } | 1302 } |
| 1304 } | 1303 } |
| 1305 } | 1304 } |
| 1306 FX_BOOL CXFA_TextLayout::Loader(const CFX_SizeF& szText, | 1305 bool CXFA_TextLayout::Loader(const CFX_SizeF& szText, |
| 1307 FX_FLOAT& fLinePos, | 1306 FX_FLOAT& fLinePos, |
| 1308 FX_BOOL bSavePieces) { | 1307 bool bSavePieces) { |
| 1309 if (!m_pAllocator) { | 1308 if (!m_pAllocator) { |
| 1310 m_pAllocator = IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Static, 256, 0); | 1309 m_pAllocator = IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Static, 256, 0); |
| 1311 } | 1310 } |
| 1312 GetTextDataNode(); | 1311 GetTextDataNode(); |
| 1313 if (!m_pTextDataNode) | 1312 if (!m_pTextDataNode) |
| 1314 return TRUE; | 1313 return true; |
| 1315 | 1314 |
| 1316 if (m_bRichText) { | 1315 if (m_bRichText) { |
| 1317 CFDE_XMLNode* pXMLContainer = GetXMLContainerNode(); | 1316 CFDE_XMLNode* pXMLContainer = GetXMLContainerNode(); |
| 1318 if (pXMLContainer) { | 1317 if (pXMLContainer) { |
| 1319 if (!m_textParser.IsParsed()) { | 1318 if (!m_textParser.IsParsed()) { |
| 1320 m_textParser.DoParse(pXMLContainer, m_pTextProvider); | 1319 m_textParser.DoParse(pXMLContainer, m_pTextProvider); |
| 1321 } | 1320 } |
| 1322 IFDE_CSSComputedStyle* pRootStyle = | 1321 IFDE_CSSComputedStyle* pRootStyle = |
| 1323 m_textParser.CreateRootStyle(m_pTextProvider); | 1322 m_textParser.CreateRootStyle(m_pTextProvider); |
| 1324 LoadRichText(pXMLContainer, szText, fLinePos, pRootStyle, bSavePieces); | 1323 LoadRichText(pXMLContainer, szText, fLinePos, pRootStyle, bSavePieces); |
| 1325 pRootStyle->Release(); | 1324 pRootStyle->Release(); |
| 1326 } | 1325 } |
| 1327 } else { | 1326 } else { |
| 1328 LoadText(m_pTextDataNode, szText, fLinePos, bSavePieces); | 1327 LoadText(m_pTextDataNode, szText, fLinePos, bSavePieces); |
| 1329 } | 1328 } |
| 1330 return TRUE; | 1329 return true; |
| 1331 } | 1330 } |
| 1332 void CXFA_TextLayout::LoadText(CXFA_Node* pNode, | 1331 void CXFA_TextLayout::LoadText(CXFA_Node* pNode, |
| 1333 const CFX_SizeF& szText, | 1332 const CFX_SizeF& szText, |
| 1334 FX_FLOAT& fLinePos, | 1333 FX_FLOAT& fLinePos, |
| 1335 FX_BOOL bSavePieces) { | 1334 bool bSavePieces) { |
| 1336 InitBreak(szText.x); | 1335 InitBreak(szText.x); |
| 1337 CXFA_Para para = m_pTextProvider->GetParaNode(); | 1336 CXFA_Para para = m_pTextProvider->GetParaNode(); |
| 1338 FX_FLOAT fSpaceAbove = 0; | 1337 FX_FLOAT fSpaceAbove = 0; |
| 1339 if (para) { | 1338 if (para) { |
| 1340 fSpaceAbove = para.GetSpaceAbove(); | 1339 fSpaceAbove = para.GetSpaceAbove(); |
| 1341 if (fSpaceAbove < 0.1f) { | 1340 if (fSpaceAbove < 0.1f) { |
| 1342 fSpaceAbove = 0; | 1341 fSpaceAbove = 0; |
| 1343 } | 1342 } |
| 1344 int32_t verAlign = para.GetVerticalAlign(); | 1343 int32_t verAlign = para.GetVerticalAlign(); |
| 1345 switch (verAlign) { | 1344 switch (verAlign) { |
| 1346 case XFA_ATTRIBUTEENUM_Top: | 1345 case XFA_ATTRIBUTEENUM_Top: |
| 1347 case XFA_ATTRIBUTEENUM_Middle: | 1346 case XFA_ATTRIBUTEENUM_Middle: |
| 1348 case XFA_ATTRIBUTEENUM_Bottom: { | 1347 case XFA_ATTRIBUTEENUM_Bottom: { |
| 1349 fLinePos += fSpaceAbove; | 1348 fLinePos += fSpaceAbove; |
| 1350 break; | 1349 break; |
| 1351 } | 1350 } |
| 1352 } | 1351 } |
| 1353 } | 1352 } |
| 1354 CFX_WideString wsText = pNode->GetContent(); | 1353 CFX_WideString wsText = pNode->GetContent(); |
| 1355 wsText.TrimRight(L" "); | 1354 wsText.TrimRight(L" "); |
| 1356 FX_BOOL bRet = AppendChar(wsText, fLinePos, fSpaceAbove, bSavePieces); | 1355 bool bRet = AppendChar(wsText, fLinePos, fSpaceAbove, bSavePieces); |
| 1357 if (bRet && m_pLoader) { | 1356 if (bRet && m_pLoader) { |
| 1358 m_pLoader->m_pNode = pNode; | 1357 m_pLoader->m_pNode = pNode; |
| 1359 } else { | 1358 } else { |
| 1360 EndBreak(FX_RTFBREAK_ParagraphBreak, fLinePos, bSavePieces); | 1359 EndBreak(FX_RTFBREAK_ParagraphBreak, fLinePos, bSavePieces); |
| 1361 } | 1360 } |
| 1362 } | 1361 } |
| 1363 FX_BOOL CXFA_TextLayout::LoadRichText(CFDE_XMLNode* pXMLNode, | 1362 bool CXFA_TextLayout::LoadRichText(CFDE_XMLNode* pXMLNode, |
| 1364 const CFX_SizeF& szText, | 1363 const CFX_SizeF& szText, |
| 1365 FX_FLOAT& fLinePos, | 1364 FX_FLOAT& fLinePos, |
| 1366 IFDE_CSSComputedStyle* pParentStyle, | 1365 IFDE_CSSComputedStyle* pParentStyle, |
| 1367 FX_BOOL bSavePieces, | 1366 bool bSavePieces, |
| 1368 CXFA_LinkUserData* pLinkData, | 1367 CXFA_LinkUserData* pLinkData, |
| 1369 FX_BOOL bEndBreak, | 1368 bool bEndBreak, |
| 1370 FX_BOOL bIsOl, | 1369 bool bIsOl, |
| 1371 int32_t iLiCount) { | 1370 int32_t iLiCount) { |
| 1372 if (!pXMLNode) { | 1371 if (!pXMLNode) { |
| 1373 return FALSE; | 1372 return false; |
| 1374 } | 1373 } |
| 1375 CXFA_TextParseContext* pContext = | 1374 CXFA_TextParseContext* pContext = |
| 1376 m_textParser.GetParseContextFromMap(pXMLNode); | 1375 m_textParser.GetParseContextFromMap(pXMLNode); |
| 1377 FDE_CSSDISPLAY eDisplay = FDE_CSSDISPLAY_None; | 1376 FDE_CSSDISPLAY eDisplay = FDE_CSSDISPLAY_None; |
| 1378 FX_BOOL bContentNode = FALSE; | 1377 bool bContentNode = false; |
| 1379 FX_FLOAT fSpaceBelow = 0; | 1378 FX_FLOAT fSpaceBelow = 0; |
| 1380 IFDE_CSSComputedStyle* pStyle = nullptr; | 1379 IFDE_CSSComputedStyle* pStyle = nullptr; |
| 1381 CFX_WideString wsName; | 1380 CFX_WideString wsName; |
| 1382 if (bEndBreak) { | 1381 if (bEndBreak) { |
| 1383 FX_BOOL bCurOl = FALSE; | 1382 bool bCurOl = false; |
| 1384 FX_BOOL bCurLi = FALSE; | 1383 bool bCurLi = false; |
| 1385 CFDE_XMLElement* pElement = nullptr; | 1384 CFDE_XMLElement* pElement = nullptr; |
| 1386 if (pContext) { | 1385 if (pContext) { |
| 1387 if (m_bBlockContinue || | 1386 if (m_bBlockContinue || |
| 1388 (m_pLoader && pXMLNode == m_pLoader->m_pXMLNode)) { | 1387 (m_pLoader && pXMLNode == m_pLoader->m_pXMLNode)) { |
| 1389 m_bBlockContinue = TRUE; | 1388 m_bBlockContinue = true; |
| 1390 } | 1389 } |
| 1391 if (pXMLNode->GetType() == FDE_XMLNODE_Text) { | 1390 if (pXMLNode->GetType() == FDE_XMLNODE_Text) { |
| 1392 bContentNode = TRUE; | 1391 bContentNode = true; |
| 1393 } else if (pXMLNode->GetType() == FDE_XMLNODE_Element) { | 1392 } else if (pXMLNode->GetType() == FDE_XMLNODE_Element) { |
| 1394 pElement = static_cast<CFDE_XMLElement*>(pXMLNode); | 1393 pElement = static_cast<CFDE_XMLElement*>(pXMLNode); |
| 1395 pElement->GetLocalTagName(wsName); | 1394 pElement->GetLocalTagName(wsName); |
| 1396 } | 1395 } |
| 1397 if (wsName == FX_WSTRC(L"ol")) { | 1396 if (wsName == FX_WSTRC(L"ol")) { |
| 1398 bIsOl = TRUE; | 1397 bIsOl = true; |
| 1399 bCurOl = TRUE; | 1398 bCurOl = true; |
| 1400 } | 1399 } |
| 1401 if (m_bBlockContinue || bContentNode == FALSE) { | 1400 if (m_bBlockContinue || bContentNode == false) { |
| 1402 eDisplay = pContext->GetDisplay(); | 1401 eDisplay = pContext->GetDisplay(); |
| 1403 if (eDisplay != FDE_CSSDISPLAY_Block && | 1402 if (eDisplay != FDE_CSSDISPLAY_Block && |
| 1404 eDisplay != FDE_CSSDISPLAY_Inline && | 1403 eDisplay != FDE_CSSDISPLAY_Inline && |
| 1405 eDisplay != FDE_CSSDISPLAY_ListItem) { | 1404 eDisplay != FDE_CSSDISPLAY_ListItem) { |
| 1406 return TRUE; | 1405 return true; |
| 1407 } | 1406 } |
| 1408 pStyle = m_textParser.ComputeStyle(pXMLNode, pParentStyle); | 1407 pStyle = m_textParser.ComputeStyle(pXMLNode, pParentStyle); |
| 1409 InitBreak(bContentNode ? pParentStyle : pStyle, eDisplay, szText.x, | 1408 InitBreak(bContentNode ? pParentStyle : pStyle, eDisplay, szText.x, |
| 1410 pXMLNode, pParentStyle); | 1409 pXMLNode, pParentStyle); |
| 1411 if ((eDisplay == FDE_CSSDISPLAY_Block || | 1410 if ((eDisplay == FDE_CSSDISPLAY_Block || |
| 1412 eDisplay == FDE_CSSDISPLAY_ListItem) && | 1411 eDisplay == FDE_CSSDISPLAY_ListItem) && |
| 1413 pStyle && | 1412 pStyle && |
| 1414 (wsName.IsEmpty() || | 1413 (wsName.IsEmpty() || |
| 1415 (wsName != FX_WSTRC(L"body") && wsName != FX_WSTRC(L"html") && | 1414 (wsName != FX_WSTRC(L"body") && wsName != FX_WSTRC(L"html") && |
| 1416 wsName != FX_WSTRC(L"ol") && wsName != FX_WSTRC(L"ul")))) { | 1415 wsName != FX_WSTRC(L"ol") && wsName != FX_WSTRC(L"ul")))) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1427 pElement->GetString(L"href", wsLinkContent); | 1426 pElement->GetString(L"href", wsLinkContent); |
| 1428 if (!wsLinkContent.IsEmpty()) { | 1427 if (!wsLinkContent.IsEmpty()) { |
| 1429 pLinkData = FXTARGET_NewWith(m_pAllocator.get()) CXFA_LinkUserData( | 1428 pLinkData = FXTARGET_NewWith(m_pAllocator.get()) CXFA_LinkUserData( |
| 1430 m_pAllocator.get(), | 1429 m_pAllocator.get(), |
| 1431 wsLinkContent.GetBuffer(wsLinkContent.GetLength())); | 1430 wsLinkContent.GetBuffer(wsLinkContent.GetLength())); |
| 1432 wsLinkContent.ReleaseBuffer(wsLinkContent.GetLength()); | 1431 wsLinkContent.ReleaseBuffer(wsLinkContent.GetLength()); |
| 1433 } | 1432 } |
| 1434 } | 1433 } |
| 1435 int32_t iTabCount = | 1434 int32_t iTabCount = |
| 1436 m_textParser.CountTabs(bContentNode ? pParentStyle : pStyle); | 1435 m_textParser.CountTabs(bContentNode ? pParentStyle : pStyle); |
| 1437 FX_BOOL bSpaceRun = | 1436 bool bSpaceRun = |
| 1438 m_textParser.IsSpaceRun(bContentNode ? pParentStyle : pStyle); | 1437 m_textParser.IsSpaceRun(bContentNode ? pParentStyle : pStyle); |
| 1439 CFX_WideString wsText; | 1438 CFX_WideString wsText; |
| 1440 if (bContentNode && iTabCount == 0) { | 1439 if (bContentNode && iTabCount == 0) { |
| 1441 static_cast<CFDE_XMLText*>(pXMLNode)->GetText(wsText); | 1440 static_cast<CFDE_XMLText*>(pXMLNode)->GetText(wsText); |
| 1442 } else if (wsName == FX_WSTRC(L"br")) { | 1441 } else if (wsName == FX_WSTRC(L"br")) { |
| 1443 wsText = L'\n'; | 1442 wsText = L'\n'; |
| 1444 } else if (wsName == FX_WSTRC(L"li")) { | 1443 } else if (wsName == FX_WSTRC(L"li")) { |
| 1445 bCurLi = TRUE; | 1444 bCurLi = true; |
| 1446 if (bIsOl) { | 1445 if (bIsOl) { |
| 1447 wsText.Format(L"%d. ", iLiCount); | 1446 wsText.Format(L"%d. ", iLiCount); |
| 1448 } else { | 1447 } else { |
| 1449 wsText = 0x00B7 + FX_WSTRC(L" "); | 1448 wsText = 0x00B7 + FX_WSTRC(L" "); |
| 1450 } | 1449 } |
| 1451 } else if (!bContentNode) { | 1450 } else if (!bContentNode) { |
| 1452 if (iTabCount > 0) { | 1451 if (iTabCount > 0) { |
| 1453 while (iTabCount-- > 0) | 1452 while (iTabCount-- > 0) |
| 1454 wsText += L'\t'; | 1453 wsText += L'\t'; |
| 1455 } else { | 1454 } else { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1492 if (m_pLoader) { | 1491 if (m_pLoader) { |
| 1493 m_pLoader->m_dwFlags &= ~XFA_LOADERCNTXTFLG_FILTERSPACE; | 1492 m_pLoader->m_dwFlags &= ~XFA_LOADERCNTXTFLG_FILTERSPACE; |
| 1494 } | 1493 } |
| 1495 if (IsEnd(bSavePieces)) { | 1494 if (IsEnd(bSavePieces)) { |
| 1496 if (m_pLoader && m_pLoader->m_iTotalLines > -1) { | 1495 if (m_pLoader && m_pLoader->m_iTotalLines > -1) { |
| 1497 m_pLoader->m_pXMLNode = pXMLNode; | 1496 m_pLoader->m_pXMLNode = pXMLNode; |
| 1498 m_pLoader->m_pParentStyle = pParentStyle; | 1497 m_pLoader->m_pParentStyle = pParentStyle; |
| 1499 } | 1498 } |
| 1500 if (pStyle) | 1499 if (pStyle) |
| 1501 pStyle->Release(); | 1500 pStyle->Release(); |
| 1502 return FALSE; | 1501 return false; |
| 1503 } | 1502 } |
| 1504 return TRUE; | 1503 return true; |
| 1505 } | 1504 } |
| 1506 } | 1505 } |
| 1507 } | 1506 } |
| 1508 } | 1507 } |
| 1509 FX_BOOL ret = TRUE; | 1508 bool ret = true; |
| 1510 for (CFDE_XMLNode* pChildNode = | 1509 for (CFDE_XMLNode* pChildNode = |
| 1511 pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild); | 1510 pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild); |
| 1512 pChildNode; | 1511 pChildNode; |
| 1513 pChildNode = pChildNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { | 1512 pChildNode = pChildNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { |
| 1514 if (bCurOl) { | 1513 if (bCurOl) { |
| 1515 iLiCount++; | 1514 iLiCount++; |
| 1516 } | 1515 } |
| 1517 ret = LoadRichText(pChildNode, szText, fLinePos, | 1516 ret = LoadRichText(pChildNode, szText, fLinePos, |
| 1518 pContext ? pStyle : pParentStyle, bSavePieces, | 1517 pContext ? pStyle : pParentStyle, bSavePieces, |
| 1519 pLinkData, TRUE, bIsOl, iLiCount); | 1518 pLinkData, true, bIsOl, iLiCount); |
| 1520 if (ret == FALSE) { | 1519 if (ret == false) { |
| 1521 return FALSE; | 1520 return false; |
| 1522 } | 1521 } |
| 1523 } | 1522 } |
| 1524 if (m_pLoader) { | 1523 if (m_pLoader) { |
| 1525 if (FDE_CSSDISPLAY_Block == eDisplay) { | 1524 if (FDE_CSSDISPLAY_Block == eDisplay) { |
| 1526 m_pLoader->m_dwFlags |= XFA_LOADERCNTXTFLG_FILTERSPACE; | 1525 m_pLoader->m_dwFlags |= XFA_LOADERCNTXTFLG_FILTERSPACE; |
| 1527 } | 1526 } |
| 1528 } | 1527 } |
| 1529 if (bCurLi) { | 1528 if (bCurLi) { |
| 1530 EndBreak(FX_RTFBREAK_LineBreak, fLinePos, bSavePieces); | 1529 EndBreak(FX_RTFBREAK_LineBreak, fLinePos, bSavePieces); |
| 1531 } | 1530 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1554 } | 1553 } |
| 1555 if (IsEnd(bSavePieces)) { | 1554 if (IsEnd(bSavePieces)) { |
| 1556 if (pStyle) { | 1555 if (pStyle) { |
| 1557 pStyle->Release(); | 1556 pStyle->Release(); |
| 1558 } | 1557 } |
| 1559 if (m_pLoader && m_pLoader->m_iTotalLines > -1) { | 1558 if (m_pLoader && m_pLoader->m_iTotalLines > -1) { |
| 1560 m_pLoader->m_pXMLNode = | 1559 m_pLoader->m_pXMLNode = |
| 1561 pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling); | 1560 pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling); |
| 1562 m_pLoader->m_pParentStyle = pParentStyle; | 1561 m_pLoader->m_pParentStyle = pParentStyle; |
| 1563 } | 1562 } |
| 1564 return FALSE; | 1563 return false; |
| 1565 } | 1564 } |
| 1566 } | 1565 } |
| 1567 } | 1566 } |
| 1568 if (pStyle) | 1567 if (pStyle) |
| 1569 pStyle->Release(); | 1568 pStyle->Release(); |
| 1570 return TRUE; | 1569 return true; |
| 1571 } | 1570 } |
| 1572 FX_BOOL CXFA_TextLayout::AppendChar(const CFX_WideString& wsText, | 1571 bool CXFA_TextLayout::AppendChar(const CFX_WideString& wsText, |
| 1573 FX_FLOAT& fLinePos, | 1572 FX_FLOAT& fLinePos, |
| 1574 FX_FLOAT fSpaceAbove, | 1573 FX_FLOAT fSpaceAbove, |
| 1575 FX_BOOL bSavePieces) { | 1574 bool bSavePieces) { |
| 1576 uint32_t dwStatus = 0; | 1575 uint32_t dwStatus = 0; |
| 1577 int32_t iChar = 0; | 1576 int32_t iChar = 0; |
| 1578 if (m_pLoader) { | 1577 if (m_pLoader) { |
| 1579 iChar = m_pLoader->m_iChar; | 1578 iChar = m_pLoader->m_iChar; |
| 1580 } | 1579 } |
| 1581 int32_t iLength = wsText.GetLength(); | 1580 int32_t iLength = wsText.GetLength(); |
| 1582 for (int32_t i = iChar; i < iLength; i++) { | 1581 for (int32_t i = iChar; i < iLength; i++) { |
| 1583 FX_WCHAR wch = wsText.GetAt(i); | 1582 FX_WCHAR wch = wsText.GetAt(i); |
| 1584 if (wch == 0xA0) { | 1583 if (wch == 0xA0) { |
| 1585 wch = 0x20; | 1584 wch = 0x20; |
| 1586 } | 1585 } |
| 1587 if ((dwStatus = m_pBreak->AppendChar(wch)) > FX_RTFBREAK_PieceBreak) { | 1586 if ((dwStatus = m_pBreak->AppendChar(wch)) > FX_RTFBREAK_PieceBreak) { |
| 1588 AppendTextLine(dwStatus, fLinePos, bSavePieces); | 1587 AppendTextLine(dwStatus, fLinePos, bSavePieces); |
| 1589 if (IsEnd(bSavePieces)) { | 1588 if (IsEnd(bSavePieces)) { |
| 1590 if (m_pLoader) | 1589 if (m_pLoader) |
| 1591 m_pLoader->m_iChar = i; | 1590 m_pLoader->m_iChar = i; |
| 1592 return TRUE; | 1591 return true; |
| 1593 } | 1592 } |
| 1594 if (dwStatus == FX_RTFBREAK_ParagraphBreak && m_bRichText) { | 1593 if (dwStatus == FX_RTFBREAK_ParagraphBreak && m_bRichText) { |
| 1595 fLinePos += fSpaceAbove; | 1594 fLinePos += fSpaceAbove; |
| 1596 } | 1595 } |
| 1597 } | 1596 } |
| 1598 } | 1597 } |
| 1599 if (m_pLoader) { | 1598 if (m_pLoader) { |
| 1600 m_pLoader->m_iChar = 0; | 1599 m_pLoader->m_iChar = 0; |
| 1601 } | 1600 } |
| 1602 return FALSE; | 1601 return false; |
| 1603 } | 1602 } |
| 1604 FX_BOOL CXFA_TextLayout::IsEnd(FX_BOOL bSavePieces) { | 1603 bool CXFA_TextLayout::IsEnd(bool bSavePieces) { |
| 1605 if (!bSavePieces) { | 1604 if (!bSavePieces) { |
| 1606 return FALSE; | 1605 return false; |
| 1607 } | 1606 } |
| 1608 if (m_pLoader && m_pLoader->m_iTotalLines > 0) { | 1607 if (m_pLoader && m_pLoader->m_iTotalLines > 0) { |
| 1609 return m_iLines >= m_pLoader->m_iTotalLines; | 1608 return m_iLines >= m_pLoader->m_iTotalLines; |
| 1610 } | 1609 } |
| 1611 return FALSE; | 1610 return false; |
| 1612 } | 1611 } |
| 1613 void CXFA_TextLayout::ProcessText(CFX_WideString& wsText) { | 1612 void CXFA_TextLayout::ProcessText(CFX_WideString& wsText) { |
| 1614 int32_t iLen = wsText.GetLength(); | 1613 int32_t iLen = wsText.GetLength(); |
| 1615 if (iLen == 0) { | 1614 if (iLen == 0) { |
| 1616 return; | 1615 return; |
| 1617 } | 1616 } |
| 1618 FX_WCHAR* psz = wsText.GetBuffer(iLen); | 1617 FX_WCHAR* psz = wsText.GetBuffer(iLen); |
| 1619 int32_t iTrimLeft = 0; | 1618 int32_t iTrimLeft = 0; |
| 1620 FX_WCHAR wch = 0, wPrev = 0; | 1619 FX_WCHAR wch = 0, wPrev = 0; |
| 1621 for (int32_t i = 0; i < iLen; i++) { | 1620 for (int32_t i = 0; i < iLen; i++) { |
| 1622 wch = psz[i]; | 1621 wch = psz[i]; |
| 1623 if (wch < 0x20) { | 1622 if (wch < 0x20) { |
| 1624 wch = 0x20; | 1623 wch = 0x20; |
| 1625 } | 1624 } |
| 1626 if (wch == 0x20 && wPrev == 0x20) { | 1625 if (wch == 0x20 && wPrev == 0x20) { |
| 1627 continue; | 1626 continue; |
| 1628 } | 1627 } |
| 1629 wPrev = wch; | 1628 wPrev = wch; |
| 1630 psz[iTrimLeft++] = wch; | 1629 psz[iTrimLeft++] = wch; |
| 1631 } | 1630 } |
| 1632 wsText.ReleaseBuffer(iLen); | 1631 wsText.ReleaseBuffer(iLen); |
| 1633 wsText = wsText.Left(iTrimLeft); | 1632 wsText = wsText.Left(iTrimLeft); |
| 1634 } | 1633 } |
| 1635 void CXFA_TextLayout::EndBreak(uint32_t dwStatus, | 1634 void CXFA_TextLayout::EndBreak(uint32_t dwStatus, |
| 1636 FX_FLOAT& fLinePos, | 1635 FX_FLOAT& fLinePos, |
| 1637 FX_BOOL bSavePieces) { | 1636 bool bSavePieces) { |
| 1638 dwStatus = m_pBreak->EndBreak(dwStatus); | 1637 dwStatus = m_pBreak->EndBreak(dwStatus); |
| 1639 if (dwStatus > FX_RTFBREAK_PieceBreak) { | 1638 if (dwStatus > FX_RTFBREAK_PieceBreak) { |
| 1640 AppendTextLine(dwStatus, fLinePos, bSavePieces, TRUE); | 1639 AppendTextLine(dwStatus, fLinePos, bSavePieces, true); |
| 1641 } | 1640 } |
| 1642 } | 1641 } |
| 1643 void CXFA_TextLayout::DoTabstops(IFDE_CSSComputedStyle* pStyle, | 1642 void CXFA_TextLayout::DoTabstops(IFDE_CSSComputedStyle* pStyle, |
| 1644 CXFA_PieceLine* pPieceLine) { | 1643 CXFA_PieceLine* pPieceLine) { |
| 1645 if (!m_pTabstopContext || m_pTabstopContext->m_iTabCount == 0) { | 1644 if (!m_pTabstopContext || m_pTabstopContext->m_iTabCount == 0) { |
| 1646 return; | 1645 return; |
| 1647 } | 1646 } |
| 1648 if (!pStyle || !pPieceLine) { | 1647 if (!pStyle || !pPieceLine) { |
| 1649 return; | 1648 return; |
| 1650 } | 1649 } |
| 1651 int32_t iPieces = pPieceLine->m_textPieces.GetSize(); | 1650 int32_t iPieces = pPieceLine->m_textPieces.GetSize(); |
| 1652 if (iPieces == 0) { | 1651 if (iPieces == 0) { |
| 1653 return; | 1652 return; |
| 1654 } | 1653 } |
| 1655 XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(iPieces - 1); | 1654 XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(iPieces - 1); |
| 1656 int32_t& iTabstopsIndex = m_pTabstopContext->m_iTabIndex; | 1655 int32_t& iTabstopsIndex = m_pTabstopContext->m_iTabIndex; |
| 1657 int32_t iCount = m_textParser.CountTabs(pStyle); | 1656 int32_t iCount = m_textParser.CountTabs(pStyle); |
| 1658 if (iTabstopsIndex > m_pTabstopContext->m_iTabCount - 1) { | 1657 if (iTabstopsIndex > m_pTabstopContext->m_iTabCount - 1) { |
| 1659 return; | 1658 return; |
| 1660 } | 1659 } |
| 1661 if (iCount > 0) { | 1660 if (iCount > 0) { |
| 1662 iTabstopsIndex++; | 1661 iTabstopsIndex++; |
| 1663 m_pTabstopContext->m_bTabstops = TRUE; | 1662 m_pTabstopContext->m_bTabstops = true; |
| 1664 FX_FLOAT fRight = 0; | 1663 FX_FLOAT fRight = 0; |
| 1665 if (iPieces > 1) { | 1664 if (iPieces > 1) { |
| 1666 XFA_TextPiece* p = pPieceLine->m_textPieces.GetAt(iPieces - 2); | 1665 XFA_TextPiece* p = pPieceLine->m_textPieces.GetAt(iPieces - 2); |
| 1667 fRight = p->rtPiece.right(); | 1666 fRight = p->rtPiece.right(); |
| 1668 } | 1667 } |
| 1669 m_pTabstopContext->m_fTabWidth = | 1668 m_pTabstopContext->m_fTabWidth = |
| 1670 pPiece->rtPiece.width + pPiece->rtPiece.left - fRight; | 1669 pPiece->rtPiece.width + pPiece->rtPiece.left - fRight; |
| 1671 } else if (iTabstopsIndex > -1) { | 1670 } else if (iTabstopsIndex > -1) { |
| 1672 FX_FLOAT fLeft = 0; | 1671 FX_FLOAT fLeft = 0; |
| 1673 if (m_pTabstopContext->m_bTabstops) { | 1672 if (m_pTabstopContext->m_bTabstops) { |
| 1674 XFA_TABSTOPS* pTabstops = | 1673 XFA_TABSTOPS* pTabstops = |
| 1675 m_pTabstopContext->m_tabstops.GetDataPtr(iTabstopsIndex); | 1674 m_pTabstopContext->m_tabstops.GetDataPtr(iTabstopsIndex); |
| 1676 uint32_t dwAlign = pTabstops->dwAlign; | 1675 uint32_t dwAlign = pTabstops->dwAlign; |
| 1677 if (dwAlign == FX_HashCode_GetW(L"center", false)) { | 1676 if (dwAlign == FX_HashCode_GetW(L"center", false)) { |
| 1678 fLeft = pPiece->rtPiece.width / 2.0f; | 1677 fLeft = pPiece->rtPiece.width / 2.0f; |
| 1679 } else if (dwAlign == FX_HashCode_GetW(L"right", false) || | 1678 } else if (dwAlign == FX_HashCode_GetW(L"right", false) || |
| 1680 dwAlign == FX_HashCode_GetW(L"before", false)) { | 1679 dwAlign == FX_HashCode_GetW(L"before", false)) { |
| 1681 fLeft = pPiece->rtPiece.width; | 1680 fLeft = pPiece->rtPiece.width; |
| 1682 } else if (dwAlign == FX_HashCode_GetW(L"decimal", false)) { | 1681 } else if (dwAlign == FX_HashCode_GetW(L"decimal", false)) { |
| 1683 int32_t iChars = pPiece->iChars; | 1682 int32_t iChars = pPiece->iChars; |
| 1684 for (int32_t i = 0; i < iChars; i++) { | 1683 for (int32_t i = 0; i < iChars; i++) { |
| 1685 if (pPiece->pszText[i] == L'.') { | 1684 if (pPiece->pszText[i] == L'.') { |
| 1686 break; | 1685 break; |
| 1687 } | 1686 } |
| 1688 fLeft += pPiece->pWidths[i] / 20000.0f; | 1687 fLeft += pPiece->pWidths[i] / 20000.0f; |
| 1689 } | 1688 } |
| 1690 } | 1689 } |
| 1691 m_pTabstopContext->m_fLeft = | 1690 m_pTabstopContext->m_fLeft = |
| 1692 std::min(fLeft, m_pTabstopContext->m_fTabWidth); | 1691 std::min(fLeft, m_pTabstopContext->m_fTabWidth); |
| 1693 m_pTabstopContext->m_bTabstops = FALSE; | 1692 m_pTabstopContext->m_bTabstops = false; |
| 1694 m_pTabstopContext->m_fTabWidth = 0; | 1693 m_pTabstopContext->m_fTabWidth = 0; |
| 1695 } | 1694 } |
| 1696 pPiece->rtPiece.left -= m_pTabstopContext->m_fLeft; | 1695 pPiece->rtPiece.left -= m_pTabstopContext->m_fLeft; |
| 1697 } | 1696 } |
| 1698 } | 1697 } |
| 1699 void CXFA_TextLayout::AppendTextLine(uint32_t dwStatus, | 1698 void CXFA_TextLayout::AppendTextLine(uint32_t dwStatus, |
| 1700 FX_FLOAT& fLinePos, | 1699 FX_FLOAT& fLinePos, |
| 1701 FX_BOOL bSavePieces, | 1700 bool bSavePieces, |
| 1702 FX_BOOL bEndBreak) { | 1701 bool bEndBreak) { |
| 1703 int32_t iPieces = m_pBreak->CountBreakPieces(); | 1702 int32_t iPieces = m_pBreak->CountBreakPieces(); |
| 1704 if (iPieces < 1) { | 1703 if (iPieces < 1) { |
| 1705 return; | 1704 return; |
| 1706 } | 1705 } |
| 1707 IFDE_CSSComputedStyle* pStyle = nullptr; | 1706 IFDE_CSSComputedStyle* pStyle = nullptr; |
| 1708 if (bSavePieces) { | 1707 if (bSavePieces) { |
| 1709 CXFA_PieceLine* pPieceLine = | 1708 CXFA_PieceLine* pPieceLine = |
| 1710 FXTARGET_NewWith(m_pAllocator.get()) CXFA_PieceLine; | 1709 FXTARGET_NewWith(m_pAllocator.get()) CXFA_PieceLine; |
| 1711 m_pieceLines.Add(pPieceLine); | 1710 m_pieceLines.Add(pPieceLine); |
| 1712 if (m_pTabstopContext) { | 1711 if (m_pTabstopContext) { |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1858 pPieceLine->m_charCounts.Add(iCount); | 1857 pPieceLine->m_charCounts.Add(iCount); |
| 1859 } | 1858 } |
| 1860 | 1859 |
| 1861 void CXFA_TextLayout::RenderPath(CFDE_RenderDevice* pDevice, | 1860 void CXFA_TextLayout::RenderPath(CFDE_RenderDevice* pDevice, |
| 1862 CFDE_Pen* pPen, | 1861 CFDE_Pen* pPen, |
| 1863 CXFA_PieceLine* pPieceLine, | 1862 CXFA_PieceLine* pPieceLine, |
| 1864 int32_t iPiece, | 1863 int32_t iPiece, |
| 1865 FXTEXT_CHARPOS* pCharPos, | 1864 FXTEXT_CHARPOS* pCharPos, |
| 1866 const CFX_Matrix& tmDoc2Device) { | 1865 const CFX_Matrix& tmDoc2Device) { |
| 1867 XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(iPiece); | 1866 XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(iPiece); |
| 1868 FX_BOOL bNoUnderline = pPiece->iUnderline < 1 || pPiece->iUnderline > 2; | 1867 bool bNoUnderline = pPiece->iUnderline < 1 || pPiece->iUnderline > 2; |
| 1869 FX_BOOL bNoLineThrough = pPiece->iLineThrough < 1 || pPiece->iLineThrough > 2; | 1868 bool bNoLineThrough = pPiece->iLineThrough < 1 || pPiece->iLineThrough > 2; |
| 1870 if (bNoUnderline && bNoLineThrough) { | 1869 if (bNoUnderline && bNoLineThrough) { |
| 1871 return; | 1870 return; |
| 1872 } | 1871 } |
| 1873 pPen->SetColor(pPiece->dwColor); | 1872 pPen->SetColor(pPiece->dwColor); |
| 1874 std::unique_ptr<CFDE_Path> pPath(new CFDE_Path); | 1873 std::unique_ptr<CFDE_Path> pPath(new CFDE_Path); |
| 1875 int32_t iChars = GetDisplayPos(pPiece, pCharPos); | 1874 int32_t iChars = GetDisplayPos(pPiece, pCharPos); |
| 1876 if (iChars > 0) { | 1875 if (iChars > 0) { |
| 1877 CFX_PointF pt1, pt2; | 1876 CFX_PointF pt1, pt2; |
| 1878 FX_FLOAT fEndY = pCharPos[0].m_OriginY + 1.05f; | 1877 FX_FLOAT fEndY = pCharPos[0].m_OriginY + 1.05f; |
| 1879 if (pPiece->iPeriod == XFA_ATTRIBUTEENUM_Word) { | 1878 if (pPiece->iPeriod == XFA_ATTRIBUTEENUM_Word) { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1963 pt1.y = pt2.y = fEndY; | 1962 pt1.y = pt2.y = fEndY; |
| 1964 pPath->AddLine(pt1, pt2); | 1963 pPath->AddLine(pt1, pt2); |
| 1965 fEndY += 2.0f; | 1964 fEndY += 2.0f; |
| 1966 } | 1965 } |
| 1967 } | 1966 } |
| 1968 pDevice->DrawPath(pPen, 1, pPath.get(), &tmDoc2Device); | 1967 pDevice->DrawPath(pPen, 1, pPath.get(), &tmDoc2Device); |
| 1969 } | 1968 } |
| 1970 | 1969 |
| 1971 int32_t CXFA_TextLayout::GetDisplayPos(const XFA_TextPiece* pPiece, | 1970 int32_t CXFA_TextLayout::GetDisplayPos(const XFA_TextPiece* pPiece, |
| 1972 FXTEXT_CHARPOS* pCharPos, | 1971 FXTEXT_CHARPOS* pCharPos, |
| 1973 FX_BOOL bCharCode) { | 1972 bool bCharCode) { |
| 1974 if (!pPiece) { | 1973 if (!pPiece) { |
| 1975 return 0; | 1974 return 0; |
| 1976 } | 1975 } |
| 1977 FX_RTFTEXTOBJ tr; | 1976 FX_RTFTEXTOBJ tr; |
| 1978 if (!ToRun(pPiece, tr)) { | 1977 if (!ToRun(pPiece, tr)) { |
| 1979 return 0; | 1978 return 0; |
| 1980 } | 1979 } |
| 1981 return m_pBreak->GetDisplayPos(&tr, pCharPos, bCharCode); | 1980 return m_pBreak->GetDisplayPos(&tr, pCharPos, bCharCode); |
| 1982 } | 1981 } |
| 1983 FX_BOOL CXFA_TextLayout::ToRun(const XFA_TextPiece* pPiece, FX_RTFTEXTOBJ& tr) { | 1982 bool CXFA_TextLayout::ToRun(const XFA_TextPiece* pPiece, FX_RTFTEXTOBJ& tr) { |
| 1984 int32_t iLength = pPiece->iChars; | 1983 int32_t iLength = pPiece->iChars; |
| 1985 if (iLength < 1) { | 1984 if (iLength < 1) { |
| 1986 return FALSE; | 1985 return false; |
| 1987 } | 1986 } |
| 1988 tr.pStr = pPiece->pszText; | 1987 tr.pStr = pPiece->pszText; |
| 1989 tr.pFont = pPiece->pFont; | 1988 tr.pFont = pPiece->pFont; |
| 1990 tr.pRect = &pPiece->rtPiece; | 1989 tr.pRect = &pPiece->rtPiece; |
| 1991 tr.pWidths = pPiece->pWidths; | 1990 tr.pWidths = pPiece->pWidths; |
| 1992 tr.iLength = iLength; | 1991 tr.iLength = iLength; |
| 1993 tr.fFontSize = pPiece->fFontSize; | 1992 tr.fFontSize = pPiece->fFontSize; |
| 1994 tr.iBidiLevel = pPiece->iBidiLevel; | 1993 tr.iBidiLevel = pPiece->iBidiLevel; |
| 1995 tr.iCharRotation = 0; | 1994 tr.iCharRotation = 0; |
| 1996 tr.wLineBreakChar = L'\n'; | 1995 tr.wLineBreakChar = L'\n'; |
| 1997 tr.iVerticalScale = pPiece->iVerScale; | 1996 tr.iVerticalScale = pPiece->iVerScale; |
| 1998 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab; | 1997 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab; |
| 1999 tr.iHorizontalScale = pPiece->iHorScale; | 1998 tr.iHorizontalScale = pPiece->iHorScale; |
| 2000 return TRUE; | 1999 return true; |
| 2001 } | 2000 } |
| 2002 | 2001 |
| 2003 CXFA_LinkUserData::CXFA_LinkUserData(IFX_MemoryAllocator* pAllocator, | 2002 CXFA_LinkUserData::CXFA_LinkUserData(IFX_MemoryAllocator* pAllocator, |
| 2004 FX_WCHAR* pszText) | 2003 FX_WCHAR* pszText) |
| 2005 : m_pAllocator(pAllocator), m_dwRefCount(1), m_wsURLContent(pszText) {} | 2004 : m_pAllocator(pAllocator), m_dwRefCount(1), m_wsURLContent(pszText) {} |
| 2006 | 2005 |
| 2007 CXFA_LinkUserData::~CXFA_LinkUserData() {} | 2006 CXFA_LinkUserData::~CXFA_LinkUserData() {} |
| 2008 | 2007 |
| 2009 uint32_t CXFA_LinkUserData::Retain() { | 2008 uint32_t CXFA_LinkUserData::Retain() { |
| 2010 return ++m_dwRefCount; | 2009 return ++m_dwRefCount; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2062 return dwRefCount; | 2061 return dwRefCount; |
| 2063 } | 2062 } |
| 2064 | 2063 |
| 2065 CXFA_PieceLine::CXFA_PieceLine() {} | 2064 CXFA_PieceLine::CXFA_PieceLine() {} |
| 2066 | 2065 |
| 2067 CXFA_PieceLine::~CXFA_PieceLine() {} | 2066 CXFA_PieceLine::~CXFA_PieceLine() {} |
| 2068 | 2067 |
| 2069 CXFA_TextTabstopsContext::CXFA_TextTabstopsContext() | 2068 CXFA_TextTabstopsContext::CXFA_TextTabstopsContext() |
| 2070 : m_iTabCount(0), | 2069 : m_iTabCount(0), |
| 2071 m_iTabIndex(-1), | 2070 m_iTabIndex(-1), |
| 2072 m_bTabstops(FALSE), | 2071 m_bTabstops(false), |
| 2073 m_fTabWidth(0), | 2072 m_fTabWidth(0), |
| 2074 m_fLeft(0) {} | 2073 m_fLeft(0) {} |
| 2075 | 2074 |
| 2076 CXFA_TextTabstopsContext::~CXFA_TextTabstopsContext() {} | 2075 CXFA_TextTabstopsContext::~CXFA_TextTabstopsContext() {} |
| 2077 | 2076 |
| 2078 void CXFA_TextTabstopsContext::Append(uint32_t dwAlign, FX_FLOAT fTabstops) { | 2077 void CXFA_TextTabstopsContext::Append(uint32_t dwAlign, FX_FLOAT fTabstops) { |
| 2079 int32_t i = 0; | 2078 int32_t i = 0; |
| 2080 for (i = 0; i < m_iTabCount; i++) { | 2079 for (i = 0; i < m_iTabCount; i++) { |
| 2081 XFA_TABSTOPS* pTabstop = m_tabstops.GetDataPtr(i); | 2080 XFA_TABSTOPS* pTabstop = m_tabstops.GetDataPtr(i); |
| 2082 if (fTabstops < pTabstop->fTabstops) { | 2081 if (fTabstops < pTabstop->fTabstops) { |
| 2083 break; | 2082 break; |
| 2084 } | 2083 } |
| 2085 } | 2084 } |
| 2086 m_tabstops.InsertSpaceAt(i, 1); | 2085 m_tabstops.InsertSpaceAt(i, 1); |
| 2087 XFA_TABSTOPS tabstop; | 2086 XFA_TABSTOPS tabstop; |
| 2088 tabstop.dwAlign = dwAlign; | 2087 tabstop.dwAlign = dwAlign; |
| 2089 tabstop.fTabstops = fTabstops; | 2088 tabstop.fTabstops = fTabstops; |
| 2090 m_tabstops.SetAt(i, tabstop); | 2089 m_tabstops.SetAt(i, tabstop); |
| 2091 m_iTabCount++; | 2090 m_iTabCount++; |
| 2092 } | 2091 } |
| 2093 | 2092 |
| 2094 void CXFA_TextTabstopsContext::RemoveAll() { | 2093 void CXFA_TextTabstopsContext::RemoveAll() { |
| 2095 m_tabstops.RemoveAll(); | 2094 m_tabstops.RemoveAll(); |
| 2096 m_iTabCount = 0; | 2095 m_iTabCount = 0; |
| 2097 } | 2096 } |
| 2098 | 2097 |
| 2099 void CXFA_TextTabstopsContext::Reset() { | 2098 void CXFA_TextTabstopsContext::Reset() { |
| 2100 m_iTabIndex = -1; | 2099 m_iTabIndex = -1; |
| 2101 m_bTabstops = FALSE; | 2100 m_bTabstops = false; |
| 2102 m_fTabWidth = 0; | 2101 m_fTabWidth = 0; |
| 2103 m_fLeft = 0; | 2102 m_fLeft = 0; |
| 2104 } | 2103 } |
| OLD | NEW |