diff options
Diffstat (limited to 'xfa/fxfa/cxfa_textparser.cpp')
-rw-r--r-- | xfa/fxfa/cxfa_textparser.cpp | 85 |
1 files changed, 40 insertions, 45 deletions
diff --git a/xfa/fxfa/cxfa_textparser.cpp b/xfa/fxfa/cxfa_textparser.cpp index ecee36a9f1..b6538aa933 100644 --- a/xfa/fxfa/cxfa_textparser.cpp +++ b/xfa/fxfa/cxfa_textparser.cpp @@ -25,6 +25,7 @@ #include "xfa/fxfa/cxfa_textparsecontext.h" #include "xfa/fxfa/cxfa_textprovider.h" #include "xfa/fxfa/cxfa_texttabstopscontext.h" +#include "xfa/fxfa/parser/cxfa_font.h" #include "xfa/fxfa/parser/cxfa_measurement.h" #include "xfa/fxfa/parser/cxfa_para.h" @@ -59,9 +60,8 @@ void CXFA_TextParser::InitCSSData(CXFA_TextProvider* pTextProvider) { if (!m_pSelector) { m_pSelector = pdfium::MakeUnique<CFX_CSSStyleSelector>(); - CXFA_FontData fontData = pTextProvider->GetFontData(); - m_pSelector->SetDefFontSize(fontData.HasValidNode() ? fontData.GetFontSize() - : 10.0f); + CXFA_Font* font = pTextProvider->GetFont(); + m_pSelector->SetDefFontSize(font ? font->GetFontSize() : 10.0f); } if (m_cssInitialized) @@ -132,24 +132,23 @@ RetainPtr<CFX_CSSComputedStyle> CXFA_TextParser::CreateRootStyle( pStyle->SetMarginWidth(rtMarginWidth); } - CXFA_FontData fontData = pTextProvider->GetFontData(); - if (fontData.HasValidNode()) { - pStyle->SetColor(fontData.GetColor()); - pStyle->SetFontStyle(fontData.IsItalic() ? CFX_CSSFontStyle::Italic - : CFX_CSSFontStyle::Normal); - pStyle->SetFontWeight(fontData.IsBold() ? FXFONT_FW_BOLD - : FXFONT_FW_NORMAL); - pStyle->SetNumberVerticalAlign(-fontData.GetBaselineShift()); - fFontSize = fontData.GetFontSize(); + CXFA_Font* font = pTextProvider->GetFont(); + if (font) { + pStyle->SetColor(font->GetColor()); + pStyle->SetFontStyle(font->IsItalic() ? CFX_CSSFontStyle::Italic + : CFX_CSSFontStyle::Normal); + pStyle->SetFontWeight(font->IsBold() ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL); + pStyle->SetNumberVerticalAlign(-font->GetBaselineShift()); + fFontSize = font->GetFontSize(); CFX_CSSLength letterSpacing; - letterSpacing.Set(CFX_CSSLengthUnit::Point, fontData.GetLetterSpacing()); + letterSpacing.Set(CFX_CSSLengthUnit::Point, font->GetLetterSpacing()); pStyle->SetLetterSpacing(letterSpacing); uint32_t dwDecoration = 0; - if (fontData.GetLineThrough() > 0) + if (font->GetLineThrough() > 0) dwDecoration |= CFX_CSSTEXTDECORATION_LineThrough; - if (fontData.GetUnderline() > 1) + if (font->GetUnderline() > 1) dwDecoration |= CFX_CSSTEXTDECORATION_Double; - else if (fontData.GetUnderline() > 0) + else if (font->GetUnderline() > 0) dwDecoration |= CFX_CSSTEXTDECORATION_Underline; pStyle->SetTextDecoration(dwDecoration); @@ -330,12 +329,12 @@ RetainPtr<CFGAS_GEFont> CXFA_TextParser::GetFont( CFX_CSSComputedStyle* pStyle) const { WideString wsFamily = L"Courier"; uint32_t dwStyle = 0; - CXFA_FontData fontData = pTextProvider->GetFontData(); - if (fontData.HasValidNode()) { - wsFamily = fontData.GetTypeface(); - if (fontData.IsBold()) + CXFA_Font* font = pTextProvider->GetFont(); + if (font) { + wsFamily = font->GetTypeface(); + if (font->IsBold()) dwStyle |= FXFONT_BOLD; - if (fontData.IsItalic()) + if (font->IsItalic()) dwStyle |= FXFONT_BOLD; } @@ -361,8 +360,8 @@ float CXFA_TextParser::GetFontSize(CXFA_TextProvider* pTextProvider, if (pStyle) return pStyle->GetFontSize(); - CXFA_FontData fontData = pTextProvider->GetFontData(); - return fontData.HasValidNode() ? fontData.GetFontSize() : 10; + CXFA_Font* font = pTextProvider->GetFont(); + return font ? font->GetFontSize() : 10; } int32_t CXFA_TextParser::GetHorScale(CXFA_TextProvider* pTextProvider, @@ -387,10 +386,8 @@ int32_t CXFA_TextParser::GetHorScale(CXFA_TextProvider* pTextProvider, } } - CXFA_FontData fontData = pTextProvider->GetFontData(); - return fontData.HasValidNode() - ? static_cast<int32_t>(fontData.GetHorizontalScale()) - : 100; + CXFA_Font* font = pTextProvider->GetFont(); + return font ? static_cast<int32_t>(font->GetHorizontalScale()) : 100; } int32_t CXFA_TextParser::GetVerScale(CXFA_TextProvider* pTextProvider, @@ -401,10 +398,8 @@ int32_t CXFA_TextParser::GetVerScale(CXFA_TextProvider* pTextProvider, return wsValue.GetInteger(); } - CXFA_FontData fontData = pTextProvider->GetFontData(); - return fontData.HasValidNode() - ? static_cast<int32_t>(fontData.GetVerticalScale()) - : 100; + CXFA_Font* font = pTextProvider->GetFont(); + return font ? static_cast<int32_t>(font->GetVerticalScale()) : 100; } void CXFA_TextParser::GetUnderline(CXFA_TextProvider* pTextProvider, @@ -413,11 +408,11 @@ void CXFA_TextParser::GetUnderline(CXFA_TextProvider* pTextProvider, XFA_AttributeEnum& iPeriod) const { iUnderline = 0; iPeriod = XFA_AttributeEnum::All; - CXFA_FontData fontData = pTextProvider->GetFontData(); + CXFA_Font* font = pTextProvider->GetFont(); if (!pStyle) { - if (fontData.HasValidNode()) { - iUnderline = fontData.GetUnderline(); - iPeriod = fontData.GetUnderlinePeriod(); + if (font) { + iUnderline = font->GetUnderline(); + iPeriod = font->GetUnderlinePeriod(); } return; } @@ -432,8 +427,8 @@ void CXFA_TextParser::GetUnderline(CXFA_TextProvider* pTextProvider, if (pStyle->GetCustomStyle(L"underlinePeriod", wsValue)) { if (wsValue == L"word") iPeriod = XFA_AttributeEnum::Word; - } else if (fontData.HasValidNode()) { - iPeriod = fontData.GetUnderlinePeriod(); + } else if (font) { + iPeriod = font->GetUnderlinePeriod(); } } @@ -446,9 +441,9 @@ void CXFA_TextParser::GetLinethrough(CXFA_TextProvider* pTextProvider, return; } - CXFA_FontData fontData = pTextProvider->GetFontData(); - if (fontData.HasValidNode()) - iLinethrough = fontData.GetLineThrough(); + CXFA_Font* font = pTextProvider->GetFont(); + if (font) + iLinethrough = font->GetLineThrough(); } FX_ARGB CXFA_TextParser::GetColor(CXFA_TextProvider* pTextProvider, @@ -456,8 +451,8 @@ FX_ARGB CXFA_TextParser::GetColor(CXFA_TextProvider* pTextProvider, if (pStyle) return pStyle->GetColor(); - CXFA_FontData fontData = pTextProvider->GetFontData(); - return fontData.HasValidNode() ? fontData.GetColor() : 0xFF000000; + CXFA_Font* font = pTextProvider->GetFont(); + return font ? font->GetColor() : 0xFF000000; } float CXFA_TextParser::GetBaseline(CXFA_TextProvider* pTextProvider, @@ -466,9 +461,9 @@ float CXFA_TextParser::GetBaseline(CXFA_TextProvider* pTextProvider, if (pStyle->GetVerticalAlign() == CFX_CSSVerticalAlign::Number) return pStyle->GetNumberVerticalAlign(); } else { - CXFA_FontData fontData = pTextProvider->GetFontData(); - if (fontData.HasValidNode()) - return fontData.GetBaselineShift(); + CXFA_Font* font = pTextProvider->GetFont(); + if (font) + return font->GetBaselineShift(); } return 0; } |