Kaydet (Commit) d77d0d8e authored tarafından Takeshi Abe's avatar Takeshi Abe Kaydeden (comit) Noel Grandin

svtools: Simplify DoubleNumericField with std::unique_ptr

Change-Id: I25df3a06afa5e1eb2fa282f2be2ae1ea69aa0ab5
Reviewed-on: https://gerrit.libreoffice.org/47077Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 3b35f1d9
......@@ -23,6 +23,7 @@
#include <svtools/svtdllapi.h>
#include <vcl/spinfld.hxx>
#include <svl/zforlist.hxx>
#include <memory>
namespace validation { class NumberValidator; }
......@@ -255,15 +256,9 @@ protected:
class SVT_DLLPUBLIC DoubleNumericField final : public FormattedField
{
public:
DoubleNumericField(vcl::Window* pParent, WinBits nStyle)
:FormattedField(pParent, nStyle)
,m_pNumberValidator( nullptr )
{
ResetConformanceTester();
}
DoubleNumericField(vcl::Window* pParent, WinBits nStyle);
virtual ~DoubleNumericField() override;
virtual void dispose() override;
private:
virtual bool CheckText(const OUString& sText) const override;
......@@ -271,7 +266,7 @@ private:
virtual void FormatChanged(FORMAT_CHANGE_TYPE nWhat) override;
void ResetConformanceTester();
validation::NumberValidator* m_pNumberValidator;
std::unique_ptr<validation::NumberValidator> m_pNumberValidator;
};
......
......@@ -1007,16 +1007,13 @@ void FormattedField::UseInputStringForFormatting()
}
DoubleNumericField::~DoubleNumericField()
DoubleNumericField::DoubleNumericField(vcl::Window* pParent, WinBits nStyle)
: FormattedField(pParent, nStyle)
{
disposeOnce();
ResetConformanceTester();
}
void DoubleNumericField::dispose()
{
delete m_pNumberValidator;
FormattedField::dispose();
}
DoubleNumericField::~DoubleNumericField() = default;
void DoubleNumericField::FormatChanged(FORMAT_CHANGE_TYPE nWhat)
{
......@@ -1052,8 +1049,7 @@ void DoubleNumericField::ResetConformanceTester()
cSeparatorDecimal = sSeparator[0];
}
delete m_pNumberValidator;
m_pNumberValidator = new validation::NumberValidator( cSeparatorThousand, cSeparatorDecimal );
m_pNumberValidator.reset(new validation::NumberValidator( cSeparatorThousand, cSeparatorDecimal ));
}
DoubleCurrencyField::DoubleCurrencyField(vcl::Window* pParent, WinBits nStyle)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment