summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xfa/fxfa/app/xfa_ffpushbutton.cpp62
-rw-r--r--xfa/fxfa/app/xfa_ffpushbutton.h10
2 files changed, 35 insertions, 37 deletions
diff --git a/xfa/fxfa/app/xfa_ffpushbutton.cpp b/xfa/fxfa/app/xfa_ffpushbutton.cpp
index 7989e3207d..2233c5a6bb 100644
--- a/xfa/fxfa/app/xfa_ffpushbutton.cpp
+++ b/xfa/fxfa/app/xfa_ffpushbutton.cpp
@@ -19,12 +19,7 @@
#include "xfa/fxgraphics/cfx_path.h"
CXFA_FFPushButton::CXFA_FFPushButton(CXFA_WidgetAcc* pDataAcc)
- : CXFA_FFField(pDataAcc),
- m_pRolloverTextLayout(nullptr),
- m_pDownTextLayout(nullptr),
- m_pDownProvider(nullptr),
- m_pRollProvider(nullptr),
- m_pOldDelegate(nullptr) {}
+ : CXFA_FFField(pDataAcc), m_pOldDelegate(nullptr) {}
CXFA_FFPushButton::~CXFA_FFPushButton() {
CXFA_FFPushButton::UnloadWidget();
@@ -86,14 +81,10 @@ void CXFA_FFPushButton::UpdateWidgetProperty() {
}
void CXFA_FFPushButton::UnloadWidget() {
- delete m_pRolloverTextLayout;
- m_pRolloverTextLayout = nullptr;
- delete m_pDownTextLayout;
- m_pDownTextLayout = nullptr;
- delete m_pDownProvider;
- m_pDownProvider = nullptr;
- delete m_pRollProvider;
- m_pRollProvider = nullptr;
+ m_pRolloverTextLayout.reset();
+ m_pDownTextLayout.reset();
+ m_pRollProvider.reset();
+ m_pDownProvider.reset();
CXFA_FFField::UnloadWidget();
}
@@ -125,36 +116,41 @@ float CXFA_FFPushButton::GetLineWidth() {
}
return 0;
}
+
FX_ARGB CXFA_FFPushButton::GetLineColor() {
return 0xFF000000;
}
+
FX_ARGB CXFA_FFPushButton::GetFillColor() {
return 0xFFFFFFFF;
}
+
void CXFA_FFPushButton::LoadHighlightCaption() {
CXFA_Caption caption = m_pDataAcc->GetCaption();
- if (caption && caption.GetPresence() != XFA_ATTRIBUTEENUM_Hidden) {
- {
- CFX_WideString wsRollover;
- bool bRichText;
- if (m_pDataAcc->GetButtonRollover(wsRollover, bRichText)) {
- if (!m_pRollProvider) {
- m_pRollProvider =
- new CXFA_TextProvider(m_pDataAcc, XFA_TEXTPROVIDERTYPE_Rollover);
- }
- m_pRolloverTextLayout = new CXFA_TextLayout(m_pRollProvider);
- }
- CFX_WideString wsDown;
- if (m_pDataAcc->GetButtonDown(wsDown, bRichText)) {
- if (!m_pDownProvider) {
- m_pDownProvider =
- new CXFA_TextProvider(m_pDataAcc, XFA_TEXTPROVIDERTYPE_Down);
- }
- m_pDownTextLayout = new CXFA_TextLayout(m_pDownProvider);
- }
+ if (!caption || caption.GetPresence() == XFA_ATTRIBUTEENUM_Hidden)
+ return;
+
+ bool bRichText;
+ CFX_WideString wsRollover;
+ if (m_pDataAcc->GetButtonRollover(wsRollover, bRichText)) {
+ if (!m_pRollProvider) {
+ m_pRollProvider = pdfium::MakeUnique<CXFA_TextProvider>(
+ m_pDataAcc, XFA_TEXTPROVIDERTYPE_Rollover);
+ }
+ m_pRolloverTextLayout =
+ pdfium::MakeUnique<CXFA_TextLayout>(m_pRollProvider.get());
+ }
+ CFX_WideString wsDown;
+ if (m_pDataAcc->GetButtonDown(wsDown, bRichText)) {
+ if (!m_pDownProvider) {
+ m_pDownProvider = pdfium::MakeUnique<CXFA_TextProvider>(
+ m_pDataAcc, XFA_TEXTPROVIDERTYPE_Down);
}
+ m_pDownTextLayout =
+ pdfium::MakeUnique<CXFA_TextLayout>(m_pDownProvider.get());
}
}
+
void CXFA_FFPushButton::LayoutHighlightCaption() {
CFX_SizeF sz(m_rtCaption.width, m_rtCaption.height);
LayoutCaption();
diff --git a/xfa/fxfa/app/xfa_ffpushbutton.h b/xfa/fxfa/app/xfa_ffpushbutton.h
index 70853e8942..7e6e9e57d5 100644
--- a/xfa/fxfa/app/xfa_ffpushbutton.h
+++ b/xfa/fxfa/app/xfa_ffpushbutton.h
@@ -7,6 +7,8 @@
#ifndef XFA_FXFA_APP_XFA_FFPUSHBUTTON_H_
#define XFA_FXFA_APP_XFA_FFPUSHBUTTON_H_
+#include <memory>
+
#include "xfa/fxfa/app/xfa_fffield.h"
#define XFA_FWL_PSBSTYLEEXT_HiliteNone (0L << 0)
@@ -42,10 +44,10 @@ class CXFA_FFPushButton : public CXFA_FFField {
FX_ARGB GetLineColor();
FX_ARGB GetFillColor();
- CXFA_TextLayout* m_pRolloverTextLayout;
- CXFA_TextLayout* m_pDownTextLayout;
- CXFA_TextProvider* m_pDownProvider;
- CXFA_TextProvider* m_pRollProvider;
+ std::unique_ptr<CXFA_TextLayout> m_pRolloverTextLayout;
+ std::unique_ptr<CXFA_TextLayout> m_pDownTextLayout;
+ std::unique_ptr<CXFA_TextProvider> m_pRollProvider;
+ std::unique_ptr<CXFA_TextProvider> m_pDownProvider;
IFWL_WidgetDelegate* m_pOldDelegate;
};