loplugin:useuniqueptr in XFConfigManager

Change-Id: Ia442d2dba8c6fdf577c6cdc950d518cc863d6e0e
Reviewed-on: https://gerrit.libreoffice.org/50741
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2018-03-01 11:17:05 +02:00
parent 2affed9bfd
commit fe40724421
2 changed files with 10 additions and 18 deletions

View file

@ -65,6 +65,7 @@
#include <xfilter/xffootnoteconfig.hxx>
#include <xfilter/xfendnoteconfig.hxx>
#include <xfilter/xfdefs.hxx>
#include <memory>
/**
* @brief
@ -100,9 +101,9 @@ public:
virtual void ToXml(IXFStream *pStrm) override;
private:
XFLineNumberConfig *m_pLineNumberConfig;
XFFootnoteConfig *m_pFootnoteConfig;
XFEndnoteConfig *m_pEndnoteConfig;
std::unique_ptr<XFLineNumberConfig> m_pLineNumberConfig;
std::unique_ptr<XFFootnoteConfig> m_pFootnoteConfig;
std::unique_ptr<XFEndnoteConfig> m_pEndnoteConfig;
};
#endif

View file

@ -69,43 +69,34 @@ XFConfigManager::XFConfigManager()
XFConfigManager::~XFConfigManager()
{
delete m_pEndnoteConfig;
delete m_pFootnoteConfig;
delete m_pLineNumberConfig;
}
void XFConfigManager::SetLineNumberConfig(XFLineNumberConfig *pLNConfig)
{
delete m_pLineNumberConfig;
m_pLineNumberConfig = pLNConfig;
m_pLineNumberConfig.reset( pLNConfig );
}
void XFConfigManager::SetFootnoteConfig(XFFootnoteConfig *pFNConfig)
{
delete m_pFootnoteConfig;
m_pFootnoteConfig = pFNConfig;
m_pFootnoteConfig.reset( pFNConfig );
}
void XFConfigManager::SetEndnoteConfig(XFEndnoteConfig *pENConfig)
{
delete m_pEndnoteConfig;
m_pEndnoteConfig = pENConfig;
m_pEndnoteConfig.reset( pENConfig );
}
void XFConfigManager::ToXml(IXFStream *pStrm)
{
if( m_pLineNumberConfig )
AddStyle(m_pLineNumberConfig);
AddStyle(m_pLineNumberConfig.release());
if( m_pFootnoteConfig )
AddStyle(m_pFootnoteConfig);
AddStyle(m_pFootnoteConfig.release());
if( m_pEndnoteConfig )
AddStyle(m_pEndnoteConfig);
AddStyle(m_pEndnoteConfig.release());
XFStyleContainer::ToXml(pStrm);
XFStyleContainer::Reset();
m_pLineNumberConfig = nullptr;
m_pFootnoteConfig = nullptr;
m_pEndnoteConfig = nullptr;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */