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 <algorithm> |
| 8 |
7 #include "xfa/src/foxitlib.h" | 9 #include "xfa/src/foxitlib.h" |
8 #include "xfa/src/fxfa/src/common/xfa_common.h" | 10 #include "xfa/src/fxfa/src/common/xfa_common.h" |
9 #include "xfa_ffapp.h" | 11 #include "xfa_ffapp.h" |
10 #include "xfa_ffdoc.h" | 12 #include "xfa_ffdoc.h" |
11 #include "xfa_ffdocview.h" | 13 #include "xfa_ffdocview.h" |
12 #include "xfa_ffwidget.h" | 14 #include "xfa_ffwidget.h" |
13 #include "xfa_ffpageview.h" | 15 #include "xfa_ffpageview.h" |
14 #include "xfa_textlayout.h" | 16 #include "xfa_textlayout.h" |
15 CXFA_FFWidget::CXFA_FFWidget(CXFA_FFPageView* pPageView, | 17 CXFA_FFWidget::CXFA_FFWidget(CXFA_FFPageView* pPageView, |
16 CXFA_WidgetAcc* pDataAcc) | 18 CXFA_WidgetAcc* pDataAcc) |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 FX_FLOAT fWidth = | 771 FX_FLOAT fWidth = |
770 XFA_UnitPx2Pt((FX_FLOAT)pDIBitmap->GetWidth(), (FX_FLOAT)iImageXDpi); | 772 XFA_UnitPx2Pt((FX_FLOAT)pDIBitmap->GetWidth(), (FX_FLOAT)iImageXDpi); |
771 FX_FLOAT fHeight = | 773 FX_FLOAT fHeight = |
772 XFA_UnitPx2Pt((FX_FLOAT)pDIBitmap->GetHeight(), (FX_FLOAT)iImageYDpi); | 774 XFA_UnitPx2Pt((FX_FLOAT)pDIBitmap->GetHeight(), (FX_FLOAT)iImageYDpi); |
773 CFX_RectF rtFit; | 775 CFX_RectF rtFit; |
774 rtFit.Set(rtImage.left, rtImage.top, fWidth, fHeight); | 776 rtFit.Set(rtImage.left, rtImage.top, fWidth, fHeight); |
775 switch (iAspect) { | 777 switch (iAspect) { |
776 case XFA_ATTRIBUTEENUM_Fit: { | 778 case XFA_ATTRIBUTEENUM_Fit: { |
777 FX_FLOAT f1 = rtImage.height / rtFit.height; | 779 FX_FLOAT f1 = rtImage.height / rtFit.height; |
778 FX_FLOAT f2 = rtImage.width / rtFit.width; | 780 FX_FLOAT f2 = rtImage.width / rtFit.width; |
779 f1 = FX_MIN(f1, f2); | 781 f1 = std::min(f1, f2); |
780 rtFit.height = rtFit.height * f1; | 782 rtFit.height = rtFit.height * f1; |
781 rtFit.width = rtFit.width * f1; | 783 rtFit.width = rtFit.width * f1; |
782 } break; | 784 } break; |
783 case XFA_ATTRIBUTEENUM_Actual: | 785 case XFA_ATTRIBUTEENUM_Actual: |
784 break; | 786 break; |
785 case XFA_ATTRIBUTEENUM_Height: { | 787 case XFA_ATTRIBUTEENUM_Height: { |
786 FX_FLOAT f1 = rtImage.height / rtFit.height; | 788 FX_FLOAT f1 = rtImage.height / rtFit.height; |
787 rtFit.height = rtImage.height; | 789 rtFit.height = rtImage.height; |
788 rtFit.width = f1 * rtFit.width; | 790 rtFit.width = f1 * rtFit.width; |
789 } break; | 791 } break; |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1109 iType == XFA_ELEMENT_Subform || iType == XFA_ELEMENT_ExclGroup; | 1111 iType == XFA_ELEMENT_Subform || iType == XFA_ELEMENT_ExclGroup; |
1110 } | 1112 } |
1111 static void XFA_BOX_GetPath_Arc(CXFA_Box box, | 1113 static void XFA_BOX_GetPath_Arc(CXFA_Box box, |
1112 CFX_RectF rtDraw, | 1114 CFX_RectF rtDraw, |
1113 CFX_Path& fillPath, | 1115 CFX_Path& fillPath, |
1114 FX_DWORD dwFlags) { | 1116 FX_DWORD dwFlags) { |
1115 FX_FLOAT a, b; | 1117 FX_FLOAT a, b; |
1116 a = rtDraw.width / 2.0f; | 1118 a = rtDraw.width / 2.0f; |
1117 b = rtDraw.height / 2.0f; | 1119 b = rtDraw.height / 2.0f; |
1118 if (box.IsCircular() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) { | 1120 if (box.IsCircular() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) { |
1119 a = b = FX_MIN(a, b); | 1121 a = b = std::min(a, b); |
1120 } | 1122 } |
1121 CFX_PointF center = rtDraw.Center(); | 1123 CFX_PointF center = rtDraw.Center(); |
1122 rtDraw.left = center.x - a; | 1124 rtDraw.left = center.x - a; |
1123 rtDraw.top = center.y - b; | 1125 rtDraw.top = center.y - b; |
1124 rtDraw.width = a + a; | 1126 rtDraw.width = a + a; |
1125 rtDraw.height = b + b; | 1127 rtDraw.height = b + b; |
1126 FX_FLOAT startAngle = 0, sweepAngle = 360; | 1128 FX_FLOAT startAngle = 0, sweepAngle = 360; |
1127 FX_BOOL bStart = box.GetStartAngle(startAngle); | 1129 FX_BOOL bStart = box.GetStartAngle(startAngle); |
1128 FX_BOOL bEnd = box.GetSweepAngle(sweepAngle); | 1130 FX_BOOL bEnd = box.GetSweepAngle(sweepAngle); |
1129 if (!bStart && !bEnd) { | 1131 if (!bStart && !bEnd) { |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1648 XFA_BOX_GetPath_Arc(box, rtWidget, arcPath, dwFlags); | 1650 XFA_BOX_GetPath_Arc(box, rtWidget, arcPath, dwFlags); |
1649 XFA_BOX_StrokePath(edge, &arcPath, pGS, pMatrix); | 1651 XFA_BOX_StrokePath(edge, &arcPath, pGS, pMatrix); |
1650 return; | 1652 return; |
1651 } | 1653 } |
1652 pGS->SaveGraphState(); | 1654 pGS->SaveGraphState(); |
1653 pGS->SetLineWidth(fHalf); | 1655 pGS->SetLineWidth(fHalf); |
1654 FX_FLOAT a, b; | 1656 FX_FLOAT a, b; |
1655 a = rtWidget.width / 2.0f; | 1657 a = rtWidget.width / 2.0f; |
1656 b = rtWidget.height / 2.0f; | 1658 b = rtWidget.height / 2.0f; |
1657 if (dwFlags & XFA_DRAWBOX_ForceRound) { | 1659 if (dwFlags & XFA_DRAWBOX_ForceRound) { |
1658 a = b = FX_MIN(a, b); | 1660 a = b = std::min(a, b); |
1659 } | 1661 } |
1660 CFX_PointF center = rtWidget.Center(); | 1662 CFX_PointF center = rtWidget.Center(); |
1661 rtWidget.left = center.x - a; | 1663 rtWidget.left = center.x - a; |
1662 rtWidget.top = center.y - b; | 1664 rtWidget.top = center.y - b; |
1663 rtWidget.width = a + a; | 1665 rtWidget.width = a + a; |
1664 rtWidget.height = b + b; | 1666 rtWidget.height = b + b; |
1665 FX_FLOAT startAngle = 0, sweepAngle = 360; | 1667 FX_FLOAT startAngle = 0, sweepAngle = 360; |
1666 startAngle = startAngle * FX_PI / 180.0f; | 1668 startAngle = startAngle * FX_PI / 180.0f; |
1667 sweepAngle = -sweepAngle * FX_PI / 180.0f; | 1669 sweepAngle = -sweepAngle * FX_PI / 180.0f; |
1668 CFX_Path arcPath; | 1670 CFX_Path arcPath; |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1948 iType != XFA_ELEMENT_Rectangle) { | 1950 iType != XFA_ELEMENT_Rectangle) { |
1949 return; | 1951 return; |
1950 } | 1952 } |
1951 CXFA_StrokeArray strokes; | 1953 CXFA_StrokeArray strokes; |
1952 if (!(dwFlags & XFA_DRAWBOX_ForceRound) && iType != XFA_ELEMENT_Arc) { | 1954 if (!(dwFlags & XFA_DRAWBOX_ForceRound) && iType != XFA_ELEMENT_Arc) { |
1953 box.GetStrokes(strokes); | 1955 box.GetStrokes(strokes); |
1954 } | 1956 } |
1955 XFA_BOX_Fill(box, strokes, pGS, rtWidget, pMatrix, dwFlags); | 1957 XFA_BOX_Fill(box, strokes, pGS, rtWidget, pMatrix, dwFlags); |
1956 XFA_BOX_Stroke(box, strokes, pGS, rtWidget, pMatrix, dwFlags); | 1958 XFA_BOX_Stroke(box, strokes, pGS, rtWidget, pMatrix, dwFlags); |
1957 } | 1959 } |
OLD | NEW |