| 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_ffwidget.h" | 7 #include "xfa/fxfa/app/xfa_ffwidget.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| 11 #include "core/fpdfapi/fpdf_page/include/cpdf_pageobjectholder.h" | 11 #include "core/fpdfapi/fpdf_page/include/cpdf_pageobjectholder.h" |
| 12 #include "core/include/fxcodec/fx_codec.h" | 12 #include "core/include/fxcodec/fx_codec.h" |
| 13 #include "xfa/fxfa/app/xfa_ffapp.h" | 13 #include "xfa/fxfa/app/xfa_ffapp.h" |
| 14 #include "xfa/fxfa/app/xfa_ffdoc.h" | 14 #include "xfa/fxfa/app/xfa_ffdoc.h" |
| 15 #include "xfa/fxfa/app/xfa_ffdocview.h" | 15 #include "xfa/fxfa/app/xfa_ffdocview.h" |
| 16 #include "xfa/fxfa/app/xfa_ffpageview.h" | 16 #include "xfa/fxfa/app/xfa_ffpageview.h" |
| 17 #include "xfa/fxfa/app/xfa_textlayout.h" | 17 #include "xfa/fxfa/app/xfa_textlayout.h" |
| 18 #include "xfa/include/fxgraphics/fx_graphics.h" | 18 #include "xfa/fxgraphics/cfx_color.h" |
| 19 #include "xfa/fxgraphics/cfx_path.h" |
| 20 #include "xfa/fxgraphics/cfx_pattern.h" |
| 21 #include "xfa/fxgraphics/cfx_shading.h" |
| 22 #include "xfa/fxgraphics/include/cfx_graphics.h" |
| 19 | 23 |
| 20 CXFA_FFWidget::CXFA_FFWidget(CXFA_FFPageView* pPageView, | 24 CXFA_FFWidget::CXFA_FFWidget(CXFA_FFPageView* pPageView, |
| 21 CXFA_WidgetAcc* pDataAcc) | 25 CXFA_WidgetAcc* pDataAcc) |
| 22 : CXFA_ContentLayoutItem(pDataAcc->GetNode()), | 26 : CXFA_ContentLayoutItem(pDataAcc->GetNode()), |
| 23 m_pPageView(pPageView), | 27 m_pPageView(pPageView), |
| 24 m_pDataAcc(pDataAcc) { | 28 m_pDataAcc(pDataAcc) { |
| 25 m_rtWidget.Set(0, 0, 0, 0); | 29 m_rtWidget.Set(0, 0, 0, 0); |
| 26 } | 30 } |
| 27 CXFA_FFWidget::~CXFA_FFWidget() {} | 31 CXFA_FFWidget::~CXFA_FFWidget() {} |
| 28 IXFA_PageView* CXFA_FFWidget::GetPageView() { | 32 IXFA_PageView* CXFA_FFWidget::GetPageView() { |
| (...skipping 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1449 } | 1453 } |
| 1450 static void XFA_BOX_Fill_Radial(CXFA_Box box, | 1454 static void XFA_BOX_Fill_Radial(CXFA_Box box, |
| 1451 CFX_Graphics* pGS, | 1455 CFX_Graphics* pGS, |
| 1452 CFX_Path& fillPath, | 1456 CFX_Path& fillPath, |
| 1453 CFX_RectF rtFill, | 1457 CFX_RectF rtFill, |
| 1454 CFX_Matrix* pMatrix) { | 1458 CFX_Matrix* pMatrix) { |
| 1455 CXFA_Fill fill = box.GetFill(); | 1459 CXFA_Fill fill = box.GetFill(); |
| 1456 FX_ARGB crStart, crEnd; | 1460 FX_ARGB crStart, crEnd; |
| 1457 crStart = fill.GetColor(); | 1461 crStart = fill.GetColor(); |
| 1458 int32_t iType = fill.GetRadial(crEnd); | 1462 int32_t iType = fill.GetRadial(crEnd); |
| 1459 CFX_Shading shading; | |
| 1460 if (iType != XFA_ATTRIBUTEENUM_ToEdge) { | 1463 if (iType != XFA_ATTRIBUTEENUM_ToEdge) { |
| 1461 FX_ARGB temp = crEnd; | 1464 FX_ARGB temp = crEnd; |
| 1462 crEnd = crStart; | 1465 crEnd = crStart; |
| 1463 crStart = temp; | 1466 crStart = temp; |
| 1464 } | 1467 } |
| 1465 shading.CreateRadial(rtFill.Center(), rtFill.Center(), 0, | 1468 CFX_Shading shading(rtFill.Center(), rtFill.Center(), 0, |
| 1466 FXSYS_sqrt(rtFill.Width() * rtFill.Width() + | 1469 FXSYS_sqrt(rtFill.Width() * rtFill.Width() + |
| 1467 rtFill.Height() * rtFill.Height()) / | 1470 rtFill.Height() * rtFill.Height()) / |
| 1468 2, | 1471 2, |
| 1469 TRUE, TRUE, crStart, crEnd); | 1472 TRUE, TRUE, crStart, crEnd); |
| 1470 CFX_Color cr(&shading); | 1473 CFX_Color cr(&shading); |
| 1471 pGS->SetFillColor(&cr); | 1474 pGS->SetFillColor(&cr); |
| 1472 pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); | 1475 pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); |
| 1473 } | 1476 } |
| 1474 static void XFA_BOX_Fill_Pattern(CXFA_Box box, | 1477 static void XFA_BOX_Fill_Pattern(CXFA_Box box, |
| 1475 CFX_Graphics* pGS, | 1478 CFX_Graphics* pGS, |
| 1476 CFX_Path& fillPath, | 1479 CFX_Path& fillPath, |
| 1477 CFX_RectF rtFill, | 1480 CFX_RectF rtFill, |
| 1478 CFX_Matrix* pMatrix) { | 1481 CFX_Matrix* pMatrix) { |
| 1479 CXFA_Fill fill = box.GetFill(); | 1482 CXFA_Fill fill = box.GetFill(); |
| 1480 FX_ARGB crStart, crEnd; | 1483 FX_ARGB crStart, crEnd; |
| 1481 crStart = fill.GetColor(); | 1484 crStart = fill.GetColor(); |
| 1482 int32_t iType = fill.GetPattern(crEnd); | 1485 int32_t iType = fill.GetPattern(crEnd); |
| 1483 int32_t iHatch = FX_HATCHSTYLE_Cross; | 1486 FX_HatchStyle iHatch = FX_HATCHSTYLE_Cross; |
| 1484 switch (iType) { | 1487 switch (iType) { |
| 1485 case XFA_ATTRIBUTEENUM_CrossDiagonal: | 1488 case XFA_ATTRIBUTEENUM_CrossDiagonal: |
| 1486 iHatch = FX_HATCHSTYLE_DiagonalCross; | 1489 iHatch = FX_HATCHSTYLE_DiagonalCross; |
| 1487 break; | 1490 break; |
| 1488 case XFA_ATTRIBUTEENUM_DiagonalLeft: | 1491 case XFA_ATTRIBUTEENUM_DiagonalLeft: |
| 1489 iHatch = FX_HATCHSTYLE_ForwardDiagonal; | 1492 iHatch = FX_HATCHSTYLE_ForwardDiagonal; |
| 1490 break; | 1493 break; |
| 1491 case XFA_ATTRIBUTEENUM_DiagonalRight: | 1494 case XFA_ATTRIBUTEENUM_DiagonalRight: |
| 1492 iHatch = FX_HATCHSTYLE_BackwardDiagonal; | 1495 iHatch = FX_HATCHSTYLE_BackwardDiagonal; |
| 1493 break; | 1496 break; |
| 1494 case XFA_ATTRIBUTEENUM_Horizontal: | 1497 case XFA_ATTRIBUTEENUM_Horizontal: |
| 1495 iHatch = FX_HATCHSTYLE_Horizontal; | 1498 iHatch = FX_HATCHSTYLE_Horizontal; |
| 1496 break; | 1499 break; |
| 1497 case XFA_ATTRIBUTEENUM_Vertical: | 1500 case XFA_ATTRIBUTEENUM_Vertical: |
| 1498 iHatch = FX_HATCHSTYLE_Vertical; | 1501 iHatch = FX_HATCHSTYLE_Vertical; |
| 1499 break; | 1502 break; |
| 1500 default: | 1503 default: |
| 1501 break; | 1504 break; |
| 1502 } | 1505 } |
| 1503 CFX_Pattern pattern; | 1506 |
| 1504 pattern.Create(iHatch, crEnd, crStart); | 1507 CFX_Pattern pattern(iHatch, crEnd, crStart); |
| 1505 CFX_Color cr(&pattern); | 1508 CFX_Color cr(&pattern); |
| 1506 pGS->SetFillColor(&cr); | 1509 pGS->SetFillColor(&cr); |
| 1507 pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); | 1510 pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); |
| 1508 } | 1511 } |
| 1509 static void XFA_BOX_Fill_Linear(CXFA_Box box, | 1512 static void XFA_BOX_Fill_Linear(CXFA_Box box, |
| 1510 CFX_Graphics* pGS, | 1513 CFX_Graphics* pGS, |
| 1511 CFX_Path& fillPath, | 1514 CFX_Path& fillPath, |
| 1512 CFX_RectF rtFill, | 1515 CFX_RectF rtFill, |
| 1513 CFX_Matrix* pMatrix) { | 1516 CFX_Matrix* pMatrix) { |
| 1514 CXFA_Fill fill = box.GetFill(); | 1517 CXFA_Fill fill = box.GetFill(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1530 ptStart = CFX_PointF(rtFill.right(), rtFill.top); | 1533 ptStart = CFX_PointF(rtFill.right(), rtFill.top); |
| 1531 ptEnd = CFX_PointF(rtFill.left, rtFill.top); | 1534 ptEnd = CFX_PointF(rtFill.left, rtFill.top); |
| 1532 break; | 1535 break; |
| 1533 case XFA_ATTRIBUTEENUM_ToTop: | 1536 case XFA_ATTRIBUTEENUM_ToTop: |
| 1534 ptStart = CFX_PointF(rtFill.left, rtFill.bottom()); | 1537 ptStart = CFX_PointF(rtFill.left, rtFill.bottom()); |
| 1535 ptEnd = CFX_PointF(rtFill.left, rtFill.top); | 1538 ptEnd = CFX_PointF(rtFill.left, rtFill.top); |
| 1536 break; | 1539 break; |
| 1537 default: | 1540 default: |
| 1538 break; | 1541 break; |
| 1539 } | 1542 } |
| 1540 CFX_Shading shading; | 1543 CFX_Shading shading(ptStart, ptEnd, FALSE, FALSE, crStart, crEnd); |
| 1541 shading.CreateAxial(ptStart, ptEnd, FALSE, FALSE, crStart, crEnd); | |
| 1542 CFX_Color cr(&shading); | 1544 CFX_Color cr(&shading); |
| 1543 pGS->SetFillColor(&cr); | 1545 pGS->SetFillColor(&cr); |
| 1544 pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); | 1546 pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); |
| 1545 } | 1547 } |
| 1546 static void XFA_BOX_Fill(CXFA_Box box, | 1548 static void XFA_BOX_Fill(CXFA_Box box, |
| 1547 const CXFA_StrokeArray& strokes, | 1549 const CXFA_StrokeArray& strokes, |
| 1548 CFX_Graphics* pGS, | 1550 CFX_Graphics* pGS, |
| 1549 const CFX_RectF& rtWidget, | 1551 const CFX_RectF& rtWidget, |
| 1550 CFX_Matrix* pMatrix, | 1552 CFX_Matrix* pMatrix, |
| 1551 FX_DWORD dwFlags) { | 1553 FX_DWORD dwFlags) { |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1952 iType != XFA_ELEMENT_Rectangle) { | 1954 iType != XFA_ELEMENT_Rectangle) { |
| 1953 return; | 1955 return; |
| 1954 } | 1956 } |
| 1955 CXFA_StrokeArray strokes; | 1957 CXFA_StrokeArray strokes; |
| 1956 if (!(dwFlags & XFA_DRAWBOX_ForceRound) && iType != XFA_ELEMENT_Arc) { | 1958 if (!(dwFlags & XFA_DRAWBOX_ForceRound) && iType != XFA_ELEMENT_Arc) { |
| 1957 box.GetStrokes(strokes); | 1959 box.GetStrokes(strokes); |
| 1958 } | 1960 } |
| 1959 XFA_BOX_Fill(box, strokes, pGS, rtWidget, pMatrix, dwFlags); | 1961 XFA_BOX_Fill(box, strokes, pGS, rtWidget, pMatrix, dwFlags); |
| 1960 XFA_BOX_Stroke(box, strokes, pGS, rtWidget, pMatrix, dwFlags); | 1962 XFA_BOX_Stroke(box, strokes, pGS, rtWidget, pMatrix, dwFlags); |
| 1961 } | 1963 } |
| OLD | NEW |