Kaydet (Commit) 73668f8e authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in LwpGlobalMgr

Change-Id: I04651e32dd036bc12ed12097e4ee3bf6e5bf3dcf
Reviewed-on: https://gerrit.libreoffice.org/50725Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst dca7203a
......@@ -79,11 +79,11 @@ public:
~LwpGlobalMgr();
static LwpGlobalMgr* GetInstance(LwpSvStream* pSvStream=nullptr);
static void DeleteInstance();
LwpObjectFactory* GetLwpObjFactory(){return m_pObjFactory;}
LwpBookmarkMgr* GetLwpBookmarkMgr(){return m_pBookmarkMgr;}
LwpChangeMgr* GetLwpChangeMgr(){return m_pChangeMgr;}
XFFontFactory* GetXFFontFactory(){return m_pXFFontFactory;}
XFStyleManager* GetXFStyleManager(){return m_pXFStyleManager;}
LwpObjectFactory* GetLwpObjFactory(){return m_pObjFactory.get();}
LwpBookmarkMgr* GetLwpBookmarkMgr(){return m_pBookmarkMgr.get();}
LwpChangeMgr* GetLwpChangeMgr(){return m_pChangeMgr.get();}
XFFontFactory* GetXFFontFactory(){return m_pXFFontFactory.get();}
XFStyleManager* GetXFStyleManager(){return m_pXFStyleManager.get();}
void SetEditorAttrMap(sal_uInt16 nID, LwpEditorAttr* pAttr);
OUString GetEditorName(sal_uInt8 nID);
XFColor GetHighlightColor(sal_uInt8 nID);
......@@ -91,11 +91,11 @@ private:
explicit LwpGlobalMgr(LwpSvStream* pSvStream);
private:
static std::map< sal_uInt32,LwpGlobalMgr* > m_ThreadMap;
LwpObjectFactory* m_pObjFactory;
LwpBookmarkMgr* m_pBookmarkMgr;
LwpChangeMgr* m_pChangeMgr;
XFFontFactory* m_pXFFontFactory;
XFStyleManager* m_pXFStyleManager;
std::unique_ptr<LwpObjectFactory> m_pObjFactory;
std::unique_ptr<LwpBookmarkMgr> m_pBookmarkMgr;
std::unique_ptr<LwpChangeMgr> m_pChangeMgr;
std::unique_ptr<XFFontFactory> m_pXFFontFactory;
std::unique_ptr<XFStyleManager> m_pXFStyleManager;
std::map<sal_uInt16, std::unique_ptr<LwpEditorAttr>> m_EditorAttrMap;
};
......
......@@ -59,42 +59,20 @@ std::map< sal_uInt32,LwpGlobalMgr* > LwpGlobalMgr::m_ThreadMap;
LwpGlobalMgr::LwpGlobalMgr(LwpSvStream* pSvStream)
{
if (pSvStream)
m_pObjFactory = new LwpObjectFactory(pSvStream);
else
m_pObjFactory = nullptr;
m_pBookmarkMgr = new LwpBookmarkMgr;
m_pChangeMgr = new LwpChangeMgr;
m_pXFFontFactory = new XFFontFactory;
m_pXFStyleManager = new XFStyleManager;
m_pObjFactory.reset( new LwpObjectFactory(pSvStream) );
m_pBookmarkMgr.reset( new LwpBookmarkMgr );
m_pChangeMgr.reset( new LwpChangeMgr );
m_pXFFontFactory.reset( new XFFontFactory );
m_pXFStyleManager.reset( new XFStyleManager );
}
LwpGlobalMgr::~LwpGlobalMgr()
{
if (m_pObjFactory)
{
delete m_pObjFactory;
m_pObjFactory = nullptr;
}
if (m_pBookmarkMgr)
{
delete m_pBookmarkMgr;
m_pBookmarkMgr = nullptr;
}
if (m_pChangeMgr)
{
delete m_pChangeMgr;
m_pChangeMgr = nullptr;
}
if (m_pXFFontFactory)
{
delete m_pXFFontFactory;
m_pXFFontFactory = nullptr;
}
if (m_pXFStyleManager)
{
delete m_pXFStyleManager;
m_pXFStyleManager = nullptr;
}
m_pObjFactory.reset();
m_pBookmarkMgr.reset();
m_pChangeMgr.reset();
m_pXFFontFactory.reset();
m_pXFStyleManager.reset();
m_EditorAttrMap.clear();
}
......
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