diff options
author | David Tardon <dtardon@redhat.com> | 2016-09-09 12:35:41 +0200 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2016-09-09 16:16:45 +0200 |
commit | ecb2850003ed2e9d40da1c3d3ac3ee043ce2bf76 (patch) | |
tree | 7c861ef3b3babadf06ef92d31e90393bccdcd64f | |
parent | bdd4a238a1d8a0cbbebbd759011050659668f92b (diff) |
use std::unique_ptr
Change-Id: Ic0cb9399e5cfc7237a3cda666b1d4f926761a9ca
-rw-r--r-- | include/xmloff/controlpropertyhdl.hxx | 20 | ||||
-rw-r--r-- | xmloff/source/forms/controlpropertyhdl.cxx | 48 |
2 files changed, 26 insertions, 42 deletions
diff --git a/include/xmloff/controlpropertyhdl.hxx b/include/xmloff/controlpropertyhdl.hxx index 685f4078e411..e043b167c7e2 100644 --- a/include/xmloff/controlpropertyhdl.hxx +++ b/include/xmloff/controlpropertyhdl.hxx @@ -21,6 +21,9 @@ #define INCLUDED_XMLOFF_CONTROLPROPERTYHDL_HXX #include <sal/config.h> + +#include <memory> + #include <xmloff/dllapi.h> #include <xmloff/prhdlfac.hxx> #include <rtl/ref.hxx> @@ -110,16 +113,13 @@ namespace xmloff class XMLOFF_DLLPUBLIC OControlPropertyHandlerFactory : public XMLPropertyHandlerFactory { protected: - mutable XMLConstantsPropertyHandler* m_pTextAlignHandler; - mutable OControlBorderHandler* m_pControlBorderStyleHandler; - mutable OControlBorderHandler* m_pControlBorderColorHandler; - mutable ORotationAngleHandler* m_pRotationAngleHandler; - mutable OFontWidthHandler* m_pFontWidthHandler; - mutable XMLConstantsPropertyHandler* m_pFontEmphasisHandler; - mutable XMLConstantsPropertyHandler* m_pFontReliefHandler; - - protected: - virtual ~OControlPropertyHandlerFactory(); + mutable std::unique_ptr<XMLConstantsPropertyHandler> m_pTextAlignHandler; + mutable std::unique_ptr<OControlBorderHandler> m_pControlBorderStyleHandler; + mutable std::unique_ptr<OControlBorderHandler> m_pControlBorderColorHandler; + mutable std::unique_ptr<ORotationAngleHandler> m_pRotationAngleHandler; + mutable std::unique_ptr<OFontWidthHandler> m_pFontWidthHandler; + mutable std::unique_ptr<XMLConstantsPropertyHandler> m_pFontEmphasisHandler; + mutable std::unique_ptr<XMLConstantsPropertyHandler> m_pFontReliefHandler; public: OControlPropertyHandlerFactory(); diff --git a/xmloff/source/forms/controlpropertyhdl.cxx b/xmloff/source/forms/controlpropertyhdl.cxx index 855df152f336..e313f980be34 100644 --- a/xmloff/source/forms/controlpropertyhdl.cxx +++ b/xmloff/source/forms/controlpropertyhdl.cxx @@ -19,6 +19,8 @@ #include <xmloff/controlpropertyhdl.hxx> +#include <o3tl/make_unique.hxx> + #include <com/sun/star/util/MeasureUnit.hpp> #include <com/sun/star/awt/TextAlign.hpp> #include <com/sun/star/awt/FontWidth.hpp> @@ -47,25 +49,7 @@ namespace xmloff //= OControlPropertyHandlerFactory OControlPropertyHandlerFactory::OControlPropertyHandlerFactory() - :m_pTextAlignHandler(nullptr) - ,m_pControlBorderStyleHandler(nullptr) - ,m_pControlBorderColorHandler(nullptr) - ,m_pRotationAngleHandler(nullptr) - ,m_pFontWidthHandler(nullptr) - ,m_pFontEmphasisHandler(nullptr) - ,m_pFontReliefHandler(nullptr) - { - } - - OControlPropertyHandlerFactory::~OControlPropertyHandlerFactory() { - delete m_pTextAlignHandler; - delete m_pControlBorderStyleHandler; - delete m_pControlBorderColorHandler; - delete m_pRotationAngleHandler; - delete m_pFontWidthHandler; - delete m_pFontEmphasisHandler; - delete m_pFontReliefHandler; } const XMLPropertyHandler* OControlPropertyHandlerFactory::GetPropertyHandler(sal_Int32 _nType) const @@ -76,44 +60,44 @@ namespace xmloff { case XML_TYPE_TEXT_ALIGN: if (!m_pTextAlignHandler) - m_pTextAlignHandler = new XMLConstantsPropertyHandler(OEnumMapper::getEnumMap(OEnumMapper::epTextAlign), XML_TOKEN_INVALID ); - pHandler = m_pTextAlignHandler; + m_pTextAlignHandler = o3tl::make_unique<XMLConstantsPropertyHandler>(OEnumMapper::getEnumMap(OEnumMapper::epTextAlign), XML_TOKEN_INVALID ); + pHandler = m_pTextAlignHandler.get(); break; case XML_TYPE_CONTROL_BORDER: if (!m_pControlBorderStyleHandler) - m_pControlBorderStyleHandler = new OControlBorderHandler( OControlBorderHandler::STYLE ); - pHandler = m_pControlBorderStyleHandler; + m_pControlBorderStyleHandler = o3tl::make_unique<OControlBorderHandler>( OControlBorderHandler::STYLE ); + pHandler = m_pControlBorderStyleHandler.get(); break; case XML_TYPE_CONTROL_BORDER_COLOR: if ( !m_pControlBorderColorHandler ) - m_pControlBorderColorHandler = new OControlBorderHandler( OControlBorderHandler::COLOR ); - pHandler = m_pControlBorderColorHandler; + m_pControlBorderColorHandler = o3tl::make_unique<OControlBorderHandler>( OControlBorderHandler::COLOR ); + pHandler = m_pControlBorderColorHandler.get(); break; case XML_TYPE_ROTATION_ANGLE: if (!m_pRotationAngleHandler) - m_pRotationAngleHandler = new ORotationAngleHandler; - pHandler = m_pRotationAngleHandler; + m_pRotationAngleHandler = o3tl::make_unique<ORotationAngleHandler>(); + pHandler = m_pRotationAngleHandler.get(); break; case XML_TYPE_FONT_WIDTH: if (!m_pFontWidthHandler) - m_pFontWidthHandler = new OFontWidthHandler; - pHandler = m_pFontWidthHandler; + m_pFontWidthHandler = o3tl::make_unique<OFontWidthHandler>(); + pHandler = m_pFontWidthHandler.get(); break; case XML_TYPE_CONTROL_TEXT_EMPHASIZE: if (!m_pFontEmphasisHandler) - m_pFontEmphasisHandler = new XMLConstantsPropertyHandler( OEnumMapper::getEnumMap(OEnumMapper::epFontEmphasis), XML_NONE ); - pHandler = m_pFontEmphasisHandler; + m_pFontEmphasisHandler = o3tl::make_unique<XMLConstantsPropertyHandler>( OEnumMapper::getEnumMap(OEnumMapper::epFontEmphasis), XML_NONE ); + pHandler = m_pFontEmphasisHandler.get(); break; case XML_TYPE_TEXT_FONT_RELIEF: if (!m_pFontReliefHandler) - m_pFontReliefHandler = new XMLConstantsPropertyHandler( OEnumMapper::getEnumMap(OEnumMapper::epFontRelief), XML_NONE ); - pHandler = m_pFontReliefHandler; + m_pFontReliefHandler = o3tl::make_unique<XMLConstantsPropertyHandler>( OEnumMapper::getEnumMap(OEnumMapper::epFontRelief), XML_NONE ); + pHandler = m_pFontReliefHandler.get(); break; case XML_TYPE_TEXT_LINE_MODE: pHandler = new XMLNamedBoolPropertyHdl( |