summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/app/xfa_ffcheckbutton.cpp3
-rw-r--r--xfa/fxfa/app/xfa_fffield.cpp9
-rw-r--r--xfa/fxfa/app/xfa_ffimageedit.cpp3
-rw-r--r--xfa/fxfa/app/xfa_ffwidgetacc.cpp9
-rw-r--r--xfa/fxfa/app/xfa_fwltheme.cpp154
-rw-r--r--xfa/fxfa/app/xfa_fwltheme.h17
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.cpp27
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.h5
8 files changed, 109 insertions, 118 deletions
diff --git a/xfa/fxfa/app/xfa_ffcheckbutton.cpp b/xfa/fxfa/app/xfa_ffcheckbutton.cpp
index 30ea09ff4d..e8a422ebd6 100644
--- a/xfa/fxfa/app/xfa_ffcheckbutton.cpp
+++ b/xfa/fxfa/app/xfa_ffcheckbutton.cpp
@@ -192,8 +192,7 @@ void CXFA_FFCheckButton::CapLeftRightPlacement(CXFA_Margin mgCap) {
}
}
void CXFA_FFCheckButton::AddUIMargin(int32_t iCapPlacement) {
- CFX_RectF rtUIMargin;
- m_pDataAcc->GetUIMargin(rtUIMargin);
+ CFX_RectF rtUIMargin = m_pDataAcc->GetUIMargin();
m_rtUI.top -= rtUIMargin.top / 2 - rtUIMargin.height / 2;
FX_FLOAT fLeftAddRight = rtUIMargin.left + rtUIMargin.width;
FX_FLOAT fTopAddBottom = rtUIMargin.top + rtUIMargin.height;
diff --git a/xfa/fxfa/app/xfa_fffield.cpp b/xfa/fxfa/app/xfa_fffield.cpp
index 2e15696ab7..0bd6160944 100644
--- a/xfa/fxfa/app/xfa_fffield.cpp
+++ b/xfa/fxfa/app/xfa_fffield.cpp
@@ -135,8 +135,7 @@ void CXFA_FFField::SetEditScrollOffset() {
FX_FLOAT fScrollOffset = 0;
CXFA_FFField* pPrev = static_cast<CXFA_FFField*>(GetPrev());
if (pPrev) {
- CFX_RectF rtMargin;
- m_pDataAcc->GetUIMargin(rtMargin);
+ CFX_RectF rtMargin = m_pDataAcc->GetUIMargin();
fScrollOffset = -rtMargin.top;
}
while (pPrev) {
@@ -265,8 +264,7 @@ void CXFA_FFField::CapPlacement() {
void CXFA_FFField::CapTopBottomPlacement(CXFA_Caption caption,
const CFX_RectF& rtWidget,
int32_t iCapPlacement) {
- CFX_RectF rtUIMargin;
- m_pDataAcc->GetUIMargin(rtUIMargin);
+ CFX_RectF rtUIMargin = m_pDataAcc->GetUIMargin();
m_rtCaption.left += rtUIMargin.left;
if (CXFA_Margin mgCap = caption.GetMargin()) {
XFA_RectWidthoutMargin(m_rtCaption, mgCap);
@@ -292,8 +290,7 @@ void CXFA_FFField::CapTopBottomPlacement(CXFA_Caption caption,
void CXFA_FFField::CapLeftRightPlacement(CXFA_Caption caption,
const CFX_RectF& rtWidget,
int32_t iCapPlacement) {
- CFX_RectF rtUIMargin;
- m_pDataAcc->GetUIMargin(rtUIMargin);
+ CFX_RectF rtUIMargin = m_pDataAcc->GetUIMargin();
m_rtCaption.top += rtUIMargin.top;
m_rtCaption.height -= rtUIMargin.top;
if (CXFA_Margin mgCap = caption.GetMargin()) {
diff --git a/xfa/fxfa/app/xfa_ffimageedit.cpp b/xfa/fxfa/app/xfa_ffimageedit.cpp
index 04ad313a27..3b063d6e98 100644
--- a/xfa/fxfa/app/xfa_ffimageedit.cpp
+++ b/xfa/fxfa/app/xfa_ffimageedit.cpp
@@ -107,8 +107,7 @@ void CXFA_FFImageEdit::SetFWLRect() {
if (!m_pNormalWidget) {
return;
}
- CFX_RectF rtUIMargin;
- m_pDataAcc->GetUIMargin(rtUIMargin);
+ CFX_RectF rtUIMargin = m_pDataAcc->GetUIMargin();
CFX_RectF rtImage(m_rtUI);
rtImage.Deflate(rtUIMargin.left, rtUIMargin.top, rtUIMargin.width,
rtUIMargin.height);
diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.cpp b/xfa/fxfa/app/xfa_ffwidgetacc.cpp
index 3ff159aa41..13145e6448 100644
--- a/xfa/fxfa/app/xfa_ffwidgetacc.cpp
+++ b/xfa/fxfa/app/xfa_ffwidgetacc.cpp
@@ -768,8 +768,7 @@ void CXFA_WidgetAcc::CalcCaptionSize(CFX_SizeF& szCap) {
bool CXFA_WidgetAcc::CalculateFieldAutoSize(CFX_SizeF& size) {
CFX_SizeF szCap;
CalcCaptionSize(szCap);
- CFX_RectF rtUIMargin;
- GetUIMargin(rtUIMargin);
+ CFX_RectF rtUIMargin = GetUIMargin();
size.x += rtUIMargin.left + rtUIMargin.width;
size.y += rtUIMargin.top + rtUIMargin.height;
if (szCap.x > 0 && szCap.y > 0) {
@@ -883,8 +882,7 @@ bool CXFA_WidgetAcc::CalculateTextEditAutoSize(CFX_SizeF& size) {
break;
}
}
- CFX_RectF rtUIMargin;
- GetUIMargin(rtUIMargin);
+ CFX_RectF rtUIMargin = GetUIMargin();
size.x -= rtUIMargin.left + rtUIMargin.width;
CXFA_Margin mgWidget = GetMargin();
if (mgWidget) {
@@ -1168,8 +1166,7 @@ bool CXFA_WidgetAcc::FindSplitPos(int32_t iBlockIndex, FX_FLOAT& fCalcHeight) {
mgWidget.GetTopInset(fTopInset);
mgWidget.GetBottomInset(fBottomInset);
}
- CFX_RectF rtUIMargin;
- GetUIMargin(rtUIMargin);
+ CFX_RectF rtUIMargin = GetUIMargin();
fTopInset += rtUIMargin.top;
fBottomInset += rtUIMargin.width;
}
diff --git a/xfa/fxfa/app/xfa_fwltheme.cpp b/xfa/fxfa/app/xfa_fwltheme.cpp
index c08e51f807..d12678e51b 100644
--- a/xfa/fxfa/app/xfa_fwltheme.cpp
+++ b/xfa/fxfa/app/xfa_fwltheme.cpp
@@ -32,6 +32,8 @@ const FX_WCHAR* const g_FWLTheme_CalFonts[] = {
L"Arial", L"Courier New", L"DejaVu Sans",
};
+const float kLineHeight = 12.0f;
+
} // namespace
CXFA_FFWidget* XFA_ThemeGetOuterWidget(CFWL_Widget* pWidget) {
@@ -54,8 +56,6 @@ CXFA_FWLTheme::CXFA_FWLTheme(CXFA_FFApp* pApp)
m_pCaretTP(new CFWL_CaretTP),
m_pBarcodeTP(new CFWL_BarcodeTP),
m_pTextOut(new CFDE_TextOut),
- m_fCapacity(0.0f),
- m_dwCapacity(0),
m_pCalendarFont(nullptr),
m_pApp(pApp) {
m_Rect.Reset();
@@ -151,84 +151,80 @@ void CXFA_FWLTheme::DrawText(CFWL_ThemeText* pParams) {
pParams->m_wsText.GetLength(), pParams->m_rtPart);
}
-void* CXFA_FWLTheme::GetCapacity(CFWL_ThemePart* pThemePart,
- CFWL_WidgetCapacity dwCapacity) {
- switch (dwCapacity) {
- case CFWL_WidgetCapacity::Font: {
- if (CXFA_FFWidget* pWidget =
- XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) {
- return pWidget->GetDataAcc()->GetFDEFont();
- }
- break;
- }
- case CFWL_WidgetCapacity::FontSize: {
- if (CXFA_FFWidget* pWidget =
- XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) {
- m_fCapacity = pWidget->GetDataAcc()->GetFontSize();
- return &m_fCapacity;
- }
- break;
- }
- case CFWL_WidgetCapacity::TextColor: {
- if (CXFA_FFWidget* pWidget =
- XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) {
- m_dwCapacity = pWidget->GetDataAcc()->GetTextColor();
- return &m_dwCapacity;
- }
- break;
- }
- case CFWL_WidgetCapacity::LineHeight: {
- if (CXFA_FFWidget* pWidget =
- XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) {
- m_fCapacity = pWidget->GetDataAcc()->GetLineHeight();
- return &m_fCapacity;
- }
- break;
- }
- case CFWL_WidgetCapacity::ScrollBarWidth: {
- m_fCapacity = 9;
- return &m_fCapacity;
- }
- case CFWL_WidgetCapacity::UIMargin: {
- CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget);
- if (pWidget) {
- CXFA_LayoutItem* pItem = pWidget;
- CXFA_WidgetAcc* pWidgetAcc = pWidget->GetDataAcc();
- pWidgetAcc->GetUIMargin(m_Rect);
- if (CXFA_Para para = pWidgetAcc->GetPara()) {
- m_Rect.left += para.GetMarginLeft();
- if (pWidgetAcc->IsMultiLine()) {
- m_Rect.width += para.GetMarginRight();
- }
- }
- if (!pItem->GetPrev()) {
- if (pItem->GetNext()) {
- m_Rect.height = 0;
- }
- } else if (!pItem->GetNext()) {
- m_Rect.top = 0;
- } else {
- m_Rect.top = 0;
- m_Rect.height = 0;
- }
- }
- return &m_Rect;
- }
- case CFWL_WidgetCapacity::SpaceAboveBelow: {
- CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget);
- if (pWidget) {
- CXFA_WidgetAcc* pWidgetAcc = pWidget->GetDataAcc();
- if (CXFA_Para para = pWidgetAcc->GetPara()) {
- m_SizeAboveBelow.x = para.GetSpaceAbove();
- m_SizeAboveBelow.y = para.GetSpaceBelow();
- }
- }
- return &m_SizeAboveBelow;
+CFX_RectF CXFA_FWLTheme::GetUIMargin(CFWL_ThemePart* pThemePart) const {
+ CFX_RectF rect;
+ rect.Reset();
+
+ CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget);
+ if (!pWidget)
+ return rect;
+
+ CXFA_LayoutItem* pItem = pWidget;
+ CXFA_WidgetAcc* pWidgetAcc = pWidget->GetDataAcc();
+ rect = pWidgetAcc->GetUIMargin();
+ if (CXFA_Para para = pWidgetAcc->GetPara()) {
+ rect.left += para.GetMarginLeft();
+ if (pWidgetAcc->IsMultiLine())
+ rect.width += para.GetMarginRight();
+ }
+ if (!pItem->GetPrev()) {
+ if (pItem->GetNext())
+ rect.height = 0;
+ } else if (!pItem->GetNext()) {
+ rect.top = 0;
+ } else {
+ rect.top = 0;
+ rect.height = 0;
+ }
+ return rect;
+}
+
+float CXFA_FWLTheme::GetCXBorderSize() const {
+ return 1.0f;
+}
+
+float CXFA_FWLTheme::GetCYBorderSize() const {
+ return 1.0f;
+}
+
+float CXFA_FWLTheme::GetFontSize(CFWL_ThemePart* pThemePart) const {
+ if (CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget))
+ return pWidget->GetDataAcc()->GetFontSize();
+ return FWLTHEME_CAPACITY_FontSize;
+}
+
+CFGAS_GEFont* CXFA_FWLTheme::GetFont(CFWL_ThemePart* pThemePart) const {
+ if (CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget))
+ return pWidget->GetDataAcc()->GetFDEFont();
+ return GetTheme(pThemePart->m_pWidget)->GetFont();
+}
+
+float CXFA_FWLTheme::GetLineHeight(CFWL_ThemePart* pThemePart) const {
+ if (CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget))
+ return pWidget->GetDataAcc()->GetLineHeight();
+ return kLineHeight;
+}
+
+float CXFA_FWLTheme::GetScrollBarWidth() const {
+ return 9.0f;
+}
+
+FX_COLORREF CXFA_FWLTheme::GetTextColor(CFWL_ThemePart* pThemePart) const {
+ if (CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget))
+ return pWidget->GetDataAcc()->GetTextColor();
+ return FWLTHEME_CAPACITY_TextColor;
+}
+
+CFX_SizeF CXFA_FWLTheme::GetSpaceAboveBelow(CFWL_ThemePart* pThemePart) const {
+ CFX_SizeF sizeAboveBelow;
+ if (CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) {
+ CXFA_WidgetAcc* pWidgetAcc = pWidget->GetDataAcc();
+ if (CXFA_Para para = pWidgetAcc->GetPara()) {
+ sizeAboveBelow.x = para.GetSpaceAbove();
+ sizeAboveBelow.y = para.GetSpaceBelow();
}
- default:
- break;
}
- return GetTheme(pThemePart->m_pWidget)->GetCapacity(pThemePart, dwCapacity);
+ return sizeAboveBelow;
}
void CXFA_FWLTheme::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) {
@@ -263,7 +259,7 @@ void CXFA_FWLTheme::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) {
pParams->m_wsText.GetLength(), rect);
}
-CFWL_WidgetTP* CXFA_FWLTheme::GetTheme(CFWL_Widget* pWidget) {
+CFWL_WidgetTP* CXFA_FWLTheme::GetTheme(CFWL_Widget* pWidget) const {
switch (pWidget->GetClassID()) {
case FWL_Type::CheckBox:
return m_pCheckBoxTP.get();
diff --git a/xfa/fxfa/app/xfa_fwltheme.h b/xfa/fxfa/app/xfa_fwltheme.h
index 98fd74c315..f8b804893a 100644
--- a/xfa/fxfa/app/xfa_fwltheme.h
+++ b/xfa/fxfa/app/xfa_fwltheme.h
@@ -32,12 +32,20 @@ class CXFA_FWLTheme final : public IFWL_ThemeProvider {
// IFWL_ThemeProvider:
void DrawBackground(CFWL_ThemeBackground* pParams) override;
void DrawText(CFWL_ThemeText* pParams) override;
- void* GetCapacity(CFWL_ThemePart* pThemePart,
- CFWL_WidgetCapacity dwCapacity) override;
void CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) override;
+ float GetCXBorderSize() const override;
+ float GetCYBorderSize() const override;
+ CFX_RectF GetUIMargin(CFWL_ThemePart* pThemePart) const override;
+ float GetFontSize(CFWL_ThemePart* pThemePart) const override;
+ CFGAS_GEFont* GetFont(CFWL_ThemePart* pThemePart) const override;
+ float GetLineHeight(CFWL_ThemePart* pThemePart) const override;
+ float GetScrollBarWidth() const override;
+ FX_COLORREF GetTextColor(CFWL_ThemePart* pThemePart) const override;
+ CFX_SizeF GetSpaceAboveBelow(CFWL_ThemePart* pThemePart) const override;
private:
- CFWL_WidgetTP* GetTheme(CFWL_Widget* pWidget);
+ CFWL_WidgetTP* GetTheme(CFWL_Widget* pWidget) const;
+
std::unique_ptr<CFWL_CheckBoxTP> m_pCheckBoxTP;
std::unique_ptr<CFWL_ListBoxTP> m_pListBoxTP;
std::unique_ptr<CFWL_PictureBoxTP> m_pPictureBoxTP;
@@ -50,13 +58,10 @@ class CXFA_FWLTheme final : public IFWL_ThemeProvider {
std::unique_ptr<CFWL_CaretTP> m_pCaretTP;
std::unique_ptr<CFWL_BarcodeTP> m_pBarcodeTP;
std::unique_ptr<CFDE_TextOut> m_pTextOut;
- FX_FLOAT m_fCapacity;
- uint32_t m_dwCapacity;
CFGAS_GEFont* m_pCalendarFont;
CFX_WideString m_wsResource;
CXFA_FFApp* const m_pApp;
CFX_RectF m_Rect;
- CFX_SizeF m_SizeAboveBelow;
};
CXFA_FFWidget* XFA_ThemeGetOuterWidget(CFWL_Widget* pWidget);
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp
index 48a26aafad..80c50b781e 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -399,29 +399,27 @@ bool CXFA_WidgetData::GetMaxHeight(FX_FLOAT& fMaxHeight) {
return TryMeasure(XFA_ATTRIBUTE_MaxH, fMaxHeight);
}
-CXFA_Border CXFA_WidgetData::GetUIBorder(bool bModified) {
+CXFA_Border CXFA_WidgetData::GetUIBorder() {
CXFA_Node* pUIChild = GetUIChild();
- return CXFA_Border(
- pUIChild ? pUIChild->GetProperty(0, XFA_Element::Border, bModified)
- : nullptr);
+ return CXFA_Border(pUIChild
+ ? pUIChild->GetProperty(0, XFA_Element::Border, false)
+ : nullptr);
}
-CXFA_Margin CXFA_WidgetData::GetUIMargin(bool bModified) {
+CFX_RectF CXFA_WidgetData::GetUIMargin() {
+ CFX_RectF rtUIMargin;
+ rtUIMargin.Reset();
+
CXFA_Node* pUIChild = GetUIChild();
- return CXFA_Margin(
- pUIChild ? pUIChild->GetProperty(0, XFA_Element::Margin, bModified)
+ CXFA_Margin mgUI = CXFA_Margin(
+ pUIChild ? pUIChild->GetProperty(0, XFA_Element::Margin, false)
: nullptr);
-}
-
-void CXFA_WidgetData::GetUIMargin(CFX_RectF& rtUIMargin) {
- rtUIMargin.Reset();
- CXFA_Margin mgUI = GetUIMargin();
if (!mgUI)
- return;
+ return rtUIMargin;
CXFA_Border border = GetUIBorder();
if (border && border.GetPresence() != XFA_ATTRIBUTEENUM_Visible)
- return;
+ return rtUIMargin;
FX_FLOAT fLeftInset, fTopInset, fRightInset, fBottomInset;
bool bLeft = mgUI.GetLeftInset(fLeftInset);
@@ -446,6 +444,7 @@ void CXFA_WidgetData::GetUIMargin(CFX_RectF& rtUIMargin) {
}
}
rtUIMargin.Set(fLeftInset, fTopInset, fRightInset, fBottomInset);
+ return rtUIMargin;
}
int32_t CXFA_WidgetData::GetButtonHighlight() {
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.h b/xfa/fxfa/parser/cxfa_widgetdata.h
index 0079996735..7986fa9d82 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.h
+++ b/xfa/fxfa/parser/cxfa_widgetdata.h
@@ -69,9 +69,8 @@ class CXFA_WidgetData : public CXFA_Data {
bool GetMinHeight(FX_FLOAT& fMinHeight);
bool GetMaxWidth(FX_FLOAT& fMaxWidth);
bool GetMaxHeight(FX_FLOAT& fMaxHeight);
- CXFA_Border GetUIBorder(bool bModified = false);
- CXFA_Margin GetUIMargin(bool bModified = false);
- void GetUIMargin(CFX_RectF& rtUIMargin);
+ CXFA_Border GetUIBorder();
+ CFX_RectF GetUIMargin();
int32_t GetButtonHighlight();
bool GetButtonRollover(CFX_WideString& wsRollover, bool& bRichText);
bool GetButtonDown(CFX_WideString& wsDown, bool& bRichText);