diff options
Diffstat (limited to 'xfa/fxfa')
-rw-r--r-- | xfa/fxfa/parser/cxfa_localevalue.cpp | 30 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_localevalue.h | 15 |
2 files changed, 18 insertions, 27 deletions
diff --git a/xfa/fxfa/parser/cxfa_localevalue.cpp b/xfa/fxfa/parser/cxfa_localevalue.cpp index 3a55045905..15082ae5e3 100644 --- a/xfa/fxfa/parser/cxfa_localevalue.cpp +++ b/xfa/fxfa/parser/cxfa_localevalue.cpp @@ -64,14 +64,7 @@ bool ValueSplitDateTime(const WideString& wsDateTime, } // namespace -CXFA_LocaleValue::CXFA_LocaleValue() - : m_pLocaleMgr(nullptr), m_dwType(XFA_VT_NULL), m_bValid(true) {} - -CXFA_LocaleValue::CXFA_LocaleValue(const CXFA_LocaleValue& value) - : m_pLocaleMgr(value.m_pLocaleMgr), - m_wsValue(value.m_wsValue), - m_dwType(value.m_dwType), - m_bValid(value.m_bValid) {} +CXFA_LocaleValue::CXFA_LocaleValue() = default; CXFA_LocaleValue::CXFA_LocaleValue(uint32_t dwType, CXFA_LocaleMgr* pLocaleMgr) : m_pLocaleMgr(pLocaleMgr), @@ -95,15 +88,12 @@ CXFA_LocaleValue::CXFA_LocaleValue(uint32_t dwType, m_dwType(dwType), m_bValid(ParsePatternValue(wsValue, wsFormat, pLocale)) {} -CXFA_LocaleValue& CXFA_LocaleValue::operator=(const CXFA_LocaleValue& value) { - m_wsValue = value.m_wsValue; - m_dwType = value.m_dwType; - m_bValid = value.m_bValid; - m_pLocaleMgr = value.m_pLocaleMgr; - return *this; -} +CXFA_LocaleValue::CXFA_LocaleValue(const CXFA_LocaleValue& that) = default; + +CXFA_LocaleValue& CXFA_LocaleValue::operator=(const CXFA_LocaleValue& that) = + default; -CXFA_LocaleValue::~CXFA_LocaleValue() {} +CXFA_LocaleValue::~CXFA_LocaleValue() = default; bool CXFA_LocaleValue::ValidateValue(const WideString& wsValue, const WideString& wsPattern, @@ -114,7 +104,7 @@ bool CXFA_LocaleValue::ValidateValue(const WideString& wsValue, if (pLocale) m_pLocaleMgr->SetDefLocale(pLocale); - auto pFormat = pdfium::MakeUnique<CFGAS_FormatString>(m_pLocaleMgr); + auto pFormat = pdfium::MakeUnique<CFGAS_FormatString>(m_pLocaleMgr.Get()); std::vector<WideString> wsPatterns; pFormat->SplitFormatString(wsPattern, &wsPatterns); @@ -310,7 +300,7 @@ bool CXFA_LocaleValue::FormatPatterns(WideString& wsResult, const WideString& wsFormat, LocaleIface* pLocale, XFA_VALUEPICTURE eValueType) const { - auto pFormat = pdfium::MakeUnique<CFGAS_FormatString>(m_pLocaleMgr); + auto pFormat = pdfium::MakeUnique<CFGAS_FormatString>(m_pLocaleMgr.Get()); std::vector<WideString> wsPatterns; pFormat->SplitFormatString(wsFormat, &wsPatterns); wsResult.clear(); @@ -332,7 +322,7 @@ bool CXFA_LocaleValue::FormatSinglePattern(WideString& wsResult, wsResult.clear(); bool bRet = false; - auto pFormat = pdfium::MakeUnique<CFGAS_FormatString>(m_pLocaleMgr); + auto pFormat = pdfium::MakeUnique<CFGAS_FormatString>(m_pLocaleMgr.Get()); FX_LOCALECATEGORY eCategory = ValueCategory(pFormat->GetCategory(wsFormat), m_dwType); switch (eCategory) { @@ -597,7 +587,7 @@ bool CXFA_LocaleValue::ParsePatternValue(const WideString& wsValue, if (pLocale) m_pLocaleMgr->SetDefLocale(pLocale); - auto pFormat = pdfium::MakeUnique<CFGAS_FormatString>(m_pLocaleMgr); + auto pFormat = pdfium::MakeUnique<CFGAS_FormatString>(m_pLocaleMgr.Get()); std::vector<WideString> wsPatterns; pFormat->SplitFormatString(wsPattern, &wsPatterns); bool bRet = false; diff --git a/xfa/fxfa/parser/cxfa_localevalue.h b/xfa/fxfa/parser/cxfa_localevalue.h index cedea10b10..c6f9c1ee98 100644 --- a/xfa/fxfa/parser/cxfa_localevalue.h +++ b/xfa/fxfa/parser/cxfa_localevalue.h @@ -9,6 +9,7 @@ #include "core/fxcrt/fx_string.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/unowned_ptr.h" #include "xfa/fxfa/parser/cxfa_node.h" class LocaleIface; @@ -28,7 +29,6 @@ class CXFA_LocaleMgr; class CXFA_LocaleValue { public: CXFA_LocaleValue(); - CXFA_LocaleValue(const CXFA_LocaleValue& value); CXFA_LocaleValue(uint32_t dwType, CXFA_LocaleMgr* pLocaleMgr); CXFA_LocaleValue(uint32_t dwType, const WideString& wsValue, @@ -38,8 +38,10 @@ class CXFA_LocaleValue { const WideString& wsFormat, LocaleIface* pLocale, CXFA_LocaleMgr* pLocaleMgr); + CXFA_LocaleValue(const CXFA_LocaleValue& that); ~CXFA_LocaleValue(); - CXFA_LocaleValue& operator=(const CXFA_LocaleValue& value); + + CXFA_LocaleValue& operator=(const CXFA_LocaleValue& that); bool ValidateValue(const WideString& wsValue, const WideString& wsPattern, @@ -56,6 +58,7 @@ class CXFA_LocaleValue { const WideString& wsFormat, LocaleIface* pLocale); + bool IsValid() const { return m_bValid; } WideString GetValue() const { return m_wsValue; } uint32_t GetType() const { return m_dwType; } double GetDoubleNum() const; @@ -63,8 +66,6 @@ class CXFA_LocaleValue { CFX_DateTime GetDate() const; CFX_DateTime GetTime() const; - bool IsValid() const { return m_bValid; } - private: bool FormatSinglePattern(WideString& wsResult, const WideString& wsFormat, @@ -81,10 +82,10 @@ class CXFA_LocaleValue { const WideString& wsPattern, LocaleIface* pLocale); - CXFA_LocaleMgr* m_pLocaleMgr; + UnownedPtr<CXFA_LocaleMgr> m_pLocaleMgr; WideString m_wsValue; - uint32_t m_dwType; - bool m_bValid; + uint32_t m_dwType = XFA_VT_NULL; + bool m_bValid = true; }; #endif // XFA_FXFA_PARSER_CXFA_LOCALEVALUE_H_ |