Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: xfa/fxfa/app/xfa_textlayout.cpp

Issue 1846993002: Remove IXFA_* interfaces. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/app/xfa_textlayout.h ('k') | xfa/fxfa/fm2js/xfa_fm2jscontext.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fxfa/app/xfa_textlayout.h" 7 #include "xfa/fxfa/app/xfa_textlayout.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
11 #include "core/fxcrt/include/fx_ext.h" 11 #include "core/fxcrt/include/fx_ext.h"
12 #include "xfa/fde/fde_pen.h" 12 #include "xfa/fde/fde_pen.h"
13 #include "xfa/fde/xml/fde_xml_imp.h" 13 #include "xfa/fde/xml/fde_xml_imp.h"
14 #include "xfa/fgas/crt/fgas_algorithm.h" 14 #include "xfa/fgas/crt/fgas_algorithm.h"
15 #include "xfa/fgas/crt/fgas_codepage.h" 15 #include "xfa/fgas/crt/fgas_codepage.h"
16 #include "xfa/fxfa/app/xfa_ffapp.h" 16 #include "xfa/fxfa/app/xfa_ffwidgetacc.h"
17 #include "xfa/fxfa/app/xfa_ffdoc.h" 17 #include "xfa/include/fxfa/xfa_ffapp.h"
18 #include "xfa/fxfa/app/xfa_fontmgr.h" 18 #include "xfa/include/fxfa/xfa_ffdoc.h"
19 #include "xfa/include/fxfa/xfa_fontmgr.h"
19 20
20 CXFA_CSSTagProvider::~CXFA_CSSTagProvider() { 21 CXFA_CSSTagProvider::~CXFA_CSSTagProvider() {
21 FX_POSITION pos = m_Attributes.GetStartPosition(); 22 FX_POSITION pos = m_Attributes.GetStartPosition();
22 while (pos) { 23 while (pos) {
23 CFX_WideString *pName = NULL, *pValue = NULL; 24 CFX_WideString *pName = NULL, *pValue = NULL;
24 m_Attributes.GetNextAssoc(pos, (void*&)pName, (void*&)pValue); 25 m_Attributes.GetNextAssoc(pos, (void*&)pName, (void*&)pValue);
25 delete pName; 26 delete pName;
26 delete pValue; 27 delete pValue;
27 } 28 }
28 } 29 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 m_mapXMLNodeToParseContext.GetNextAssoc(ps, pXMLNode, pParseContext); 82 m_mapXMLNodeToParseContext.GetNextAssoc(ps, pXMLNode, pParseContext);
82 if (pParseContext) 83 if (pParseContext)
83 FXTARGET_DeleteWith(CXFA_TextParseContext, m_pAllocator, pParseContext); 84 FXTARGET_DeleteWith(CXFA_TextParseContext, m_pAllocator, pParseContext);
84 } 85 }
85 m_mapXMLNodeToParseContext.RemoveAll(); 86 m_mapXMLNodeToParseContext.RemoveAll();
86 if (m_pAllocator) { 87 if (m_pAllocator) {
87 m_pAllocator->Release(); 88 m_pAllocator->Release();
88 m_pAllocator = NULL; 89 m_pAllocator = NULL;
89 } 90 }
90 } 91 }
91 void CXFA_TextParser::InitCSSData(IXFA_TextProvider* pTextProvider) { 92 void CXFA_TextParser::InitCSSData(CXFA_TextProvider* pTextProvider) {
92 if (pTextProvider == NULL) { 93 if (pTextProvider == NULL) {
93 return; 94 return;
94 } 95 }
95 if (m_pSelector == NULL) { 96 if (m_pSelector == NULL) {
96 CXFA_FFDoc* pDoc = pTextProvider->GetDocNode(); 97 CXFA_FFDoc* pDoc = pTextProvider->GetDocNode();
97 IFX_FontMgr* pFontMgr = pDoc->GetApp()->GetFDEFontMgr(); 98 IFX_FontMgr* pFontMgr = pDoc->GetApp()->GetFDEFontMgr();
98 FXSYS_assert(pFontMgr); 99 FXSYS_assert(pFontMgr);
99 m_pSelector = IFDE_CSSStyleSelector::Create(); 100 m_pSelector = IFDE_CSSStyleSelector::Create();
100 m_pSelector->SetFontMgr(pFontMgr); 101 m_pSelector->SetFontMgr(pFontMgr);
101 FX_FLOAT fFontSize = 10; 102 FX_FLOAT fFontSize = 10;
(...skipping 16 matching lines...) Expand all
118 L"ol,ul{padding-left:33px}ol{list-style-type:decimal}ol,ul{margin-top:0;" 119 L"ol,ul{padding-left:33px}ol{list-style-type:decimal}ol,ul{margin-top:0;"
119 L"margin-bottom:0}ul,ol{margin:1.12em 0}" 120 L"margin-bottom:0}ul,ol{margin:1.12em 0}"
120 L"a{color:#0000ff;text-decoration:underline}b{font-weight:bolder}i{font-" 121 L"a{color:#0000ff;text-decoration:underline}b{font-weight:bolder}i{font-"
121 L"style:italic}" 122 L"style:italic}"
122 L"sup{vertical-align:+15em;font-size:.66em}sub{vertical-align:-15em;font-" 123 L"sup{vertical-align:+15em;font-size:.66em}sub{vertical-align:-15em;font-"
123 L"size:.66em}"; 124 L"size:.66em}";
124 return IFDE_CSSStyleSheet::LoadFromBuffer( 125 return IFDE_CSSStyleSheet::LoadFromBuffer(
125 CFX_WideString(), s_pStyle, FXSYS_wcslen(s_pStyle), FX_CODEPAGE_UTF8); 126 CFX_WideString(), s_pStyle, FXSYS_wcslen(s_pStyle), FX_CODEPAGE_UTF8);
126 } 127 }
127 IFDE_CSSComputedStyle* CXFA_TextParser::CreateRootStyle( 128 IFDE_CSSComputedStyle* CXFA_TextParser::CreateRootStyle(
128 IXFA_TextProvider* pTextProvider) { 129 CXFA_TextProvider* pTextProvider) {
129 CXFA_Font font = pTextProvider->GetFontNode(); 130 CXFA_Font font = pTextProvider->GetFontNode();
130 CXFA_Para para = pTextProvider->GetParaNode(); 131 CXFA_Para para = pTextProvider->GetParaNode();
131 IFDE_CSSComputedStyle* pStyle = m_pSelector->CreateComputedStyle(NULL); 132 IFDE_CSSComputedStyle* pStyle = m_pSelector->CreateComputedStyle(NULL);
132 IFDE_CSSFontStyle* pFontStyle = pStyle->GetFontStyles(); 133 IFDE_CSSFontStyle* pFontStyle = pStyle->GetFontStyles();
133 IFDE_CSSParagraphStyle* pParaStyle = pStyle->GetParagraphStyles(); 134 IFDE_CSSParagraphStyle* pParaStyle = pStyle->GetParagraphStyles();
134 FX_FLOAT fLineHeight = 0, fFontSize = 10; 135 FX_FLOAT fLineHeight = 0, fFontSize = 10;
135 if (para) { 136 if (para) {
136 fLineHeight = para.GetLineHeight(); 137 fLineHeight = para.GetLineHeight();
137 FDE_CSSLENGTH indent; 138 FDE_CSSLENGTH indent;
138 indent.Set(FDE_CSSLENGTHUNIT_Point, para.GetTextIndent()); 139 indent.Set(FDE_CSSLENGTHUNIT_Point, para.GetTextIndent());
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 return nullptr; 226 return nullptr;
226 IFDE_CSSComputedStyle* pStyle = CreateStyle(pParentStyle); 227 IFDE_CSSComputedStyle* pStyle = CreateStyle(pParentStyle);
227 IFDE_CSSAccelerator* pCSSAccel = m_pSelector->InitAccelerator(); 228 IFDE_CSSAccelerator* pCSSAccel = m_pSelector->InitAccelerator();
228 pCSSAccel->OnEnterTag(&tagProvider); 229 pCSSAccel->OnEnterTag(&tagProvider);
229 m_pSelector->ComputeStyle(&tagProvider, pContext->GetDecls(), 230 m_pSelector->ComputeStyle(&tagProvider, pContext->GetDecls(),
230 pContext->CountDecls(), pStyle); 231 pContext->CountDecls(), pStyle);
231 pCSSAccel->OnLeaveTag(&tagProvider); 232 pCSSAccel->OnLeaveTag(&tagProvider);
232 return pStyle; 233 return pStyle;
233 } 234 }
234 void CXFA_TextParser::DoParse(CFDE_XMLNode* pXMLContainer, 235 void CXFA_TextParser::DoParse(CFDE_XMLNode* pXMLContainer,
235 IXFA_TextProvider* pTextProvider) { 236 CXFA_TextProvider* pTextProvider) {
236 if (pXMLContainer == NULL || pTextProvider == NULL || m_pAllocator) { 237 if (pXMLContainer == NULL || pTextProvider == NULL || m_pAllocator) {
237 return; 238 return;
238 } 239 }
239 m_pAllocator = 240 m_pAllocator =
240 FX_CreateAllocator(FX_ALLOCTYPE_Fixed, 32, sizeof(CXFA_CSSTagProvider)); 241 FX_CreateAllocator(FX_ALLOCTYPE_Fixed, 32, sizeof(CXFA_CSSTagProvider));
241 InitCSSData(pTextProvider); 242 InitCSSData(pTextProvider);
242 IFDE_CSSComputedStyle* pRootStyle = CreateRootStyle(pTextProvider); 243 IFDE_CSSComputedStyle* pRootStyle = CreateRootStyle(pTextProvider);
243 ParseRichText(pXMLContainer, pRootStyle); 244 ParseRichText(pXMLContainer, pRootStyle);
244 pRootStyle->Release(); 245 pRootStyle->Release();
245 } 246 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 CFX_WideString wsValue; 310 CFX_WideString wsValue;
310 pXMLElement->GetString(FX_WSTRC(L"style").GetPtr(), wsValue); 311 pXMLElement->GetString(FX_WSTRC(L"style").GetPtr(), wsValue);
311 if (!wsValue.IsEmpty()) { 312 if (!wsValue.IsEmpty()) {
312 tagProvider.SetAttribute(FX_WSTRC(L"style"), wsValue); 313 tagProvider.SetAttribute(FX_WSTRC(L"style"), wsValue);
313 } 314 }
314 } else if (pXMLNode->GetType() == FDE_XMLNODE_Text) { 315 } else if (pXMLNode->GetType() == FDE_XMLNODE_Text) {
315 tagProvider.m_bTagAviliable = TRUE; 316 tagProvider.m_bTagAviliable = TRUE;
316 tagProvider.m_bContent = TRUE; 317 tagProvider.m_bContent = TRUE;
317 } 318 }
318 } 319 }
319 int32_t CXFA_TextParser::GetVAlgin(IXFA_TextProvider* pTextProvider) const { 320 int32_t CXFA_TextParser::GetVAlgin(CXFA_TextProvider* pTextProvider) const {
320 int32_t iAlign = XFA_ATTRIBUTEENUM_Top; 321 int32_t iAlign = XFA_ATTRIBUTEENUM_Top;
321 CXFA_Para para = pTextProvider->GetParaNode(); 322 CXFA_Para para = pTextProvider->GetParaNode();
322 if (para) { 323 if (para) {
323 iAlign = para.GetVerticalAlign(); 324 iAlign = para.GetVerticalAlign();
324 } 325 }
325 return iAlign; 326 return iAlign;
326 } 327 }
327 FX_FLOAT CXFA_TextParser::GetTabInterval(IFDE_CSSComputedStyle* pStyle) const { 328 FX_FLOAT CXFA_TextParser::GetTabInterval(IFDE_CSSComputedStyle* pStyle) const {
328 CFX_WideString wsValue; 329 CFX_WideString wsValue;
329 if (pStyle && pStyle->GetCustomStyle(FX_WSTRC(L"tab-interval"), wsValue)) { 330 if (pStyle && pStyle->GetCustomStyle(FX_WSTRC(L"tab-interval"), wsValue)) {
(...skipping 10 matching lines...) Expand all
340 return 0; 341 return 0;
341 } 342 }
342 FX_BOOL CXFA_TextParser::IsSpaceRun(IFDE_CSSComputedStyle* pStyle) const { 343 FX_BOOL CXFA_TextParser::IsSpaceRun(IFDE_CSSComputedStyle* pStyle) const {
343 CFX_WideString wsValue; 344 CFX_WideString wsValue;
344 if (pStyle && pStyle->GetCustomStyle(FX_WSTRC(L"xfa-spacerun"), wsValue)) { 345 if (pStyle && pStyle->GetCustomStyle(FX_WSTRC(L"xfa-spacerun"), wsValue)) {
345 wsValue.MakeLower(); 346 wsValue.MakeLower();
346 return wsValue == FX_WSTRC(L"yes"); 347 return wsValue == FX_WSTRC(L"yes");
347 } 348 }
348 return FALSE; 349 return FALSE;
349 } 350 }
350 IFX_Font* CXFA_TextParser::GetFont(IXFA_TextProvider* pTextProvider, 351 IFX_Font* CXFA_TextParser::GetFont(CXFA_TextProvider* pTextProvider,
351 IFDE_CSSComputedStyle* pStyle) const { 352 IFDE_CSSComputedStyle* pStyle) const {
352 CFX_WideStringC wsFamily = FX_WSTRC(L"Courier"); 353 CFX_WideStringC wsFamily = FX_WSTRC(L"Courier");
353 uint32_t dwStyle = 0; 354 uint32_t dwStyle = 0;
354 CXFA_Font font = pTextProvider->GetFontNode(); 355 CXFA_Font font = pTextProvider->GetFontNode();
355 if (font) { 356 if (font) {
356 font.GetTypeface(wsFamily); 357 font.GetTypeface(wsFamily);
357 if (font.IsBold()) { 358 if (font.IsBold()) {
358 dwStyle |= FX_FONTSTYLE_Bold; 359 dwStyle |= FX_FONTSTYLE_Bold;
359 } 360 }
360 if (font.IsItalic()) { 361 if (font.IsItalic()) {
(...skipping 11 matching lines...) Expand all
372 dwStyle |= FX_FONTSTYLE_Bold; 373 dwStyle |= FX_FONTSTYLE_Bold;
373 } 374 }
374 if (pFontStyle->GetFontStyle() == FDE_CSSFONTSTYLE_Italic) { 375 if (pFontStyle->GetFontStyle() == FDE_CSSFONTSTYLE_Italic) {
375 dwStyle |= FX_FONTSTYLE_Italic; 376 dwStyle |= FX_FONTSTYLE_Italic;
376 } 377 }
377 } 378 }
378 CXFA_FFDoc* pDoc = pTextProvider->GetDocNode(); 379 CXFA_FFDoc* pDoc = pTextProvider->GetDocNode();
379 CXFA_FontMgr* pFontMgr = pDoc->GetApp()->GetXFAFontMgr(); 380 CXFA_FontMgr* pFontMgr = pDoc->GetApp()->GetXFAFontMgr();
380 return pFontMgr->GetFont(pDoc, wsFamily, dwStyle); 381 return pFontMgr->GetFont(pDoc, wsFamily, dwStyle);
381 } 382 }
382 FX_FLOAT CXFA_TextParser::GetFontSize(IXFA_TextProvider* pTextProvider, 383 FX_FLOAT CXFA_TextParser::GetFontSize(CXFA_TextProvider* pTextProvider,
383 IFDE_CSSComputedStyle* pStyle) const { 384 IFDE_CSSComputedStyle* pStyle) const {
384 if (pStyle) 385 if (pStyle)
385 return pStyle->GetFontStyles()->GetFontSize(); 386 return pStyle->GetFontStyles()->GetFontSize();
386 387
387 CXFA_Font font = pTextProvider->GetFontNode(); 388 CXFA_Font font = pTextProvider->GetFontNode();
388 if (font) { 389 if (font) {
389 return font.GetFontSize(); 390 return font.GetFontSize();
390 } 391 }
391 return 10; 392 return 10;
392 } 393 }
393 int32_t CXFA_TextParser::GetHorScale(IXFA_TextProvider* pTextProvider, 394 int32_t CXFA_TextParser::GetHorScale(CXFA_TextProvider* pTextProvider,
394 IFDE_CSSComputedStyle* pStyle, 395 IFDE_CSSComputedStyle* pStyle,
395 CFDE_XMLNode* pXMLNode) const { 396 CFDE_XMLNode* pXMLNode) const {
396 if (pStyle) { 397 if (pStyle) {
397 CFX_WideString wsValue; 398 CFX_WideString wsValue;
398 if (pStyle->GetCustomStyle(FX_WSTRC(L"xfa-font-horizontal-scale"), 399 if (pStyle->GetCustomStyle(FX_WSTRC(L"xfa-font-horizontal-scale"),
399 wsValue)) { 400 wsValue)) {
400 return wsValue.GetInteger(); 401 return wsValue.GetInteger();
401 } 402 }
402 while (pXMLNode) { 403 while (pXMLNode) {
403 CXFA_TextParseContext* pContext = static_cast<CXFA_TextParseContext*>( 404 CXFA_TextParseContext* pContext = static_cast<CXFA_TextParseContext*>(
404 m_mapXMLNodeToParseContext.GetValueAt(pXMLNode)); 405 m_mapXMLNodeToParseContext.GetValueAt(pXMLNode));
405 if (pContext && pContext->m_pParentStyle && 406 if (pContext && pContext->m_pParentStyle &&
406 pContext->m_pParentStyle->GetCustomStyle( 407 pContext->m_pParentStyle->GetCustomStyle(
407 FX_WSTRC(L"xfa-font-horizontal-scale"), wsValue)) { 408 FX_WSTRC(L"xfa-font-horizontal-scale"), wsValue)) {
408 return wsValue.GetInteger(); 409 return wsValue.GetInteger();
409 } 410 }
410 pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::Parent); 411 pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::Parent);
411 } 412 }
412 } 413 }
413 if (CXFA_Font font = pTextProvider->GetFontNode()) { 414 if (CXFA_Font font = pTextProvider->GetFontNode()) {
414 return static_cast<int32_t>(font.GetHorizontalScale()); 415 return static_cast<int32_t>(font.GetHorizontalScale());
415 } 416 }
416 return 100; 417 return 100;
417 } 418 }
418 int32_t CXFA_TextParser::GetVerScale(IXFA_TextProvider* pTextProvider, 419 int32_t CXFA_TextParser::GetVerScale(CXFA_TextProvider* pTextProvider,
419 IFDE_CSSComputedStyle* pStyle) const { 420 IFDE_CSSComputedStyle* pStyle) const {
420 if (pStyle) { 421 if (pStyle) {
421 CFX_WideString wsValue; 422 CFX_WideString wsValue;
422 if (pStyle->GetCustomStyle(FX_WSTRC(L"xfa-font-vertical-scale"), wsValue)) { 423 if (pStyle->GetCustomStyle(FX_WSTRC(L"xfa-font-vertical-scale"), wsValue)) {
423 return wsValue.GetInteger(); 424 return wsValue.GetInteger();
424 } 425 }
425 } 426 }
426 if (CXFA_Font font = pTextProvider->GetFontNode()) { 427 if (CXFA_Font font = pTextProvider->GetFontNode()) {
427 return (int32_t)font.GetVerticalScale(); 428 return (int32_t)font.GetVerticalScale();
428 } 429 }
429 return 100; 430 return 100;
430 } 431 }
431 void CXFA_TextParser::GetUnderline(IXFA_TextProvider* pTextProvider, 432 void CXFA_TextParser::GetUnderline(CXFA_TextProvider* pTextProvider,
432 IFDE_CSSComputedStyle* pStyle, 433 IFDE_CSSComputedStyle* pStyle,
433 int32_t& iUnderline, 434 int32_t& iUnderline,
434 int32_t& iPeriod) const { 435 int32_t& iPeriod) const {
435 iUnderline = 0; 436 iUnderline = 0;
436 iPeriod = XFA_ATTRIBUTEENUM_All; 437 iPeriod = XFA_ATTRIBUTEENUM_All;
437 if (pStyle) { 438 if (pStyle) {
438 uint32_t dwDecoration = pStyle->GetParagraphStyles()->GetTextDecoration(); 439 uint32_t dwDecoration = pStyle->GetParagraphStyles()->GetTextDecoration();
439 if (dwDecoration & FDE_CSSTEXTDECORATION_Double) { 440 if (dwDecoration & FDE_CSSTEXTDECORATION_Double) {
440 iUnderline = 2; 441 iUnderline = 2;
441 } else if (dwDecoration & FDE_CSSTEXTDECORATION_Underline) { 442 } else if (dwDecoration & FDE_CSSTEXTDECORATION_Underline) {
442 iUnderline = 1; 443 iUnderline = 1;
443 } 444 }
444 CFX_WideString wsValue; 445 CFX_WideString wsValue;
445 if (pStyle->GetCustomStyle(FX_WSTRC(L"underlinePeriod"), wsValue)) { 446 if (pStyle->GetCustomStyle(FX_WSTRC(L"underlinePeriod"), wsValue)) {
446 if (wsValue == FX_WSTRC(L"word")) { 447 if (wsValue == FX_WSTRC(L"word")) {
447 iPeriod = XFA_ATTRIBUTEENUM_Word; 448 iPeriod = XFA_ATTRIBUTEENUM_Word;
448 } 449 }
449 } else if (CXFA_Font font = pTextProvider->GetFontNode()) { 450 } else if (CXFA_Font font = pTextProvider->GetFontNode()) {
450 iPeriod = font.GetUnderlinePeriod(); 451 iPeriod = font.GetUnderlinePeriod();
451 } 452 }
452 } else { 453 } else {
453 CXFA_Font font = pTextProvider->GetFontNode(); 454 CXFA_Font font = pTextProvider->GetFontNode();
454 if (font) { 455 if (font) {
455 iUnderline = font.GetUnderline(); 456 iUnderline = font.GetUnderline();
456 iPeriod = font.GetUnderlinePeriod(); 457 iPeriod = font.GetUnderlinePeriod();
457 } 458 }
458 } 459 }
459 } 460 }
460 void CXFA_TextParser::GetLinethrough(IXFA_TextProvider* pTextProvider, 461 void CXFA_TextParser::GetLinethrough(CXFA_TextProvider* pTextProvider,
461 IFDE_CSSComputedStyle* pStyle, 462 IFDE_CSSComputedStyle* pStyle,
462 int32_t& iLinethrough) const { 463 int32_t& iLinethrough) const {
463 if (pStyle) { 464 if (pStyle) {
464 uint32_t dwDecoration = pStyle->GetParagraphStyles()->GetTextDecoration(); 465 uint32_t dwDecoration = pStyle->GetParagraphStyles()->GetTextDecoration();
465 iLinethrough = (dwDecoration & FDE_CSSTEXTDECORATION_LineThrough) ? 1 : 0; 466 iLinethrough = (dwDecoration & FDE_CSSTEXTDECORATION_LineThrough) ? 1 : 0;
466 } else { 467 } else {
467 CXFA_Font font = pTextProvider->GetFontNode(); 468 CXFA_Font font = pTextProvider->GetFontNode();
468 if (font) { 469 if (font) {
469 iLinethrough = font.GetLineThrough(); 470 iLinethrough = font.GetLineThrough();
470 } 471 }
471 } 472 }
472 } 473 }
473 FX_ARGB CXFA_TextParser::GetColor(IXFA_TextProvider* pTextProvider, 474 FX_ARGB CXFA_TextParser::GetColor(CXFA_TextProvider* pTextProvider,
474 IFDE_CSSComputedStyle* pStyle) const { 475 IFDE_CSSComputedStyle* pStyle) const {
475 if (pStyle) 476 if (pStyle)
476 return pStyle->GetFontStyles()->GetColor(); 477 return pStyle->GetFontStyles()->GetColor();
477 478
478 if (CXFA_Font font = pTextProvider->GetFontNode()) 479 if (CXFA_Font font = pTextProvider->GetFontNode())
479 return font.GetColor(); 480 return font.GetColor();
480 481
481 return 0xFF000000; 482 return 0xFF000000;
482 } 483 }
483 FX_FLOAT CXFA_TextParser::GetBaseline(IXFA_TextProvider* pTextProvider, 484 FX_FLOAT CXFA_TextParser::GetBaseline(CXFA_TextProvider* pTextProvider,
484 IFDE_CSSComputedStyle* pStyle) const { 485 IFDE_CSSComputedStyle* pStyle) const {
485 if (pStyle) { 486 if (pStyle) {
486 IFDE_CSSParagraphStyle* pParaStyle = pStyle->GetParagraphStyles(); 487 IFDE_CSSParagraphStyle* pParaStyle = pStyle->GetParagraphStyles();
487 if (pParaStyle->GetVerticalAlign() == FDE_CSSVERTICALALIGN_Number) { 488 if (pParaStyle->GetVerticalAlign() == FDE_CSSVERTICALALIGN_Number) {
488 return pParaStyle->GetNumberVerticalAlign(); 489 return pParaStyle->GetNumberVerticalAlign();
489 } 490 }
490 } else if (CXFA_Font font = pTextProvider->GetFontNode()) { 491 } else if (CXFA_Font font = pTextProvider->GetFontNode()) {
491 return font.GetBaselineShift(); 492 return font.GetBaselineShift();
492 } 493 }
493 return 0; 494 return 0;
494 } 495 }
495 FX_FLOAT CXFA_TextParser::GetLineHeight(IXFA_TextProvider* pTextProvider, 496 FX_FLOAT CXFA_TextParser::GetLineHeight(CXFA_TextProvider* pTextProvider,
496 IFDE_CSSComputedStyle* pStyle, 497 IFDE_CSSComputedStyle* pStyle,
497 FX_BOOL bFirst, 498 FX_BOOL bFirst,
498 FX_FLOAT fVerScale) const { 499 FX_FLOAT fVerScale) const {
499 FX_FLOAT fLineHeight = 0; 500 FX_FLOAT fLineHeight = 0;
500 if (pStyle) { 501 if (pStyle) {
501 fLineHeight = pStyle->GetParagraphStyles()->GetLineHeight(); 502 fLineHeight = pStyle->GetParagraphStyles()->GetLineHeight();
502 } else if (CXFA_Para para = pTextProvider->GetParaNode()) { 503 } else if (CXFA_Para para = pTextProvider->GetParaNode()) {
503 fLineHeight = para.GetLineHeight(); 504 fLineHeight = para.GetLineHeight();
504 } 505 }
505 if (bFirst) { 506 if (bFirst) {
506 FX_FLOAT fFontSize = GetFontSize(pTextProvider, pStyle); 507 FX_FLOAT fFontSize = GetFontSize(pTextProvider, pStyle);
507 if (fLineHeight < 0.1f) { 508 if (fLineHeight < 0.1f) {
508 fLineHeight = fFontSize; 509 fLineHeight = fFontSize;
509 } else { 510 } else {
510 fLineHeight = std::min(fLineHeight, fFontSize); 511 fLineHeight = std::min(fLineHeight, fFontSize);
511 } 512 }
512 } else if (fLineHeight < 0.1f) { 513 } else if (fLineHeight < 0.1f) {
513 fLineHeight = GetFontSize(pTextProvider, pStyle) * 1.2f; 514 fLineHeight = GetFontSize(pTextProvider, pStyle) * 1.2f;
514 } 515 }
515 fLineHeight *= fVerScale; 516 fLineHeight *= fVerScale;
516 return fLineHeight; 517 return fLineHeight;
517 } 518 }
518 FX_BOOL CXFA_TextParser::GetEmbbedObj(IXFA_TextProvider* pTextProvider, 519 FX_BOOL CXFA_TextParser::GetEmbbedObj(CXFA_TextProvider* pTextProvider,
519 CFDE_XMLNode* pXMLNode, 520 CFDE_XMLNode* pXMLNode,
520 CFX_WideString& wsValue) { 521 CFX_WideString& wsValue) {
521 wsValue.Empty(); 522 wsValue.Empty();
522 if (pXMLNode == NULL) { 523 if (pXMLNode == NULL) {
523 return FALSE; 524 return FALSE;
524 } 525 }
525 FX_BOOL bRet = FALSE; 526 FX_BOOL bRet = FALSE;
526 if (pXMLNode->GetType() == FDE_XMLNODE_Element) { 527 if (pXMLNode->GetType() == FDE_XMLNODE_Element) {
527 CFDE_XMLElement* pElement = static_cast<CFDE_XMLElement*>(pXMLNode); 528 CFDE_XMLElement* pElement = static_cast<CFDE_XMLElement*>(pXMLNode);
528 CFX_WideString wsAttr; 529 CFX_WideString wsAttr;
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 } 658 }
658 if (!wsAlign.IsEmpty()) { 659 if (!wsAlign.IsEmpty()) {
659 uint32_t dwHashCode = 660 uint32_t dwHashCode =
660 FX_HashCode_String_GetW(wsAlign, wsAlign.GetLength(), TRUE); 661 FX_HashCode_String_GetW(wsAlign, wsAlign.GetLength(), TRUE);
661 CXFA_Measurement ms(CFX_WideStringC(pTabStops + iLast, iCur - iLast)); 662 CXFA_Measurement ms(CFX_WideStringC(pTabStops + iLast, iCur - iLast));
662 FX_FLOAT fPos = ms.ToUnit(XFA_UNIT_Pt); 663 FX_FLOAT fPos = ms.ToUnit(XFA_UNIT_Pt);
663 pTabstopContext->Append(dwHashCode, fPos); 664 pTabstopContext->Append(dwHashCode, fPos);
664 } 665 }
665 return TRUE; 666 return TRUE;
666 } 667 }
667 CXFA_TextLayout::CXFA_TextLayout(IXFA_TextProvider* pTextProvider) 668 CXFA_TextLayout::CXFA_TextLayout(CXFA_TextProvider* pTextProvider)
668 : m_bHasBlock(FALSE), 669 : m_bHasBlock(FALSE),
669 m_pTextProvider(pTextProvider), 670 m_pTextProvider(pTextProvider),
670 m_pTextDataNode(nullptr), 671 m_pTextDataNode(nullptr),
671 m_bRichText(FALSE), 672 m_bRichText(FALSE),
672 m_pAllocator(nullptr), 673 m_pAllocator(nullptr),
673 m_pBreak(nullptr), 674 m_pBreak(nullptr),
674 m_pLoader(nullptr), 675 m_pLoader(nullptr),
675 m_iLines(0), 676 m_iLines(0),
676 m_fMaxWidth(0), 677 m_fMaxWidth(0),
677 m_pTabstopContext(nullptr), 678 m_pTabstopContext(nullptr),
(...skipping 1315 matching lines...) Expand 10 before | Expand all | Expand 10 after
1993 tr.iLength = iLength; 1994 tr.iLength = iLength;
1994 tr.fFontSize = pPiece->fFontSize; 1995 tr.fFontSize = pPiece->fFontSize;
1995 tr.iBidiLevel = pPiece->iBidiLevel; 1996 tr.iBidiLevel = pPiece->iBidiLevel;
1996 tr.iCharRotation = 0; 1997 tr.iCharRotation = 0;
1997 tr.wLineBreakChar = L'\n'; 1998 tr.wLineBreakChar = L'\n';
1998 tr.iVerticalScale = pPiece->iVerScale; 1999 tr.iVerticalScale = pPiece->iVerScale;
1999 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab; 2000 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab;
2000 tr.iHorizontalScale = pPiece->iHorScale; 2001 tr.iHorizontalScale = pPiece->iHorScale;
2001 return TRUE; 2002 return TRUE;
2002 } 2003 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_textlayout.h ('k') | xfa/fxfa/fm2js/xfa_fm2jscontext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698