diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2015-12-22 12:00:49 +0900 |
---|---|---|
committer | Kohei Yoshida <libreoffice@kohei.us> | 2015-12-31 17:43:25 +0000 |
commit | eb65936f1996cc37632f7241cf07fc85ff633049 (patch) | |
tree | 55f1e531287229230a87bcdd553e1b0d4b3f4ea2 | |
parent | 054b25c9ce96eb50d80177cb48cd9b10513806c3 (diff) |
starmath: Manage SmDocShell's pCursor via std::unique_ptr
Change-Id: Id9c67638e5c2e535cc06e9566c9a169471f55da8
Reviewed-on: https://gerrit.libreoffice.org/20856
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Kohei Yoshida <libreoffice@kohei.us>
-rw-r--r-- | starmath/inc/document.hxx | 5 | ||||
-rw-r--r-- | starmath/source/document.cxx | 17 |
2 files changed, 10 insertions, 12 deletions
diff --git a/starmath/inc/document.hxx b/starmath/inc/document.hxx index 67ef680e79c6..2cda3759af52 100644 --- a/starmath/inc/document.hxx +++ b/starmath/inc/document.hxx @@ -32,6 +32,7 @@ #include <oox/core/filterbase.hxx> #include <oox/mathml/import.hxx> +#include <memory> #include <set> #include "format.hxx" @@ -102,7 +103,7 @@ class SM_DLLPUBLIC SmDocShell : public SfxObjectShell, public SfxListener VclPtr<Printer> pTmpPrinter; //ditto sal_uInt16 nModifyCount; bool bIsFormulaArranged; - SmCursor *pCursor; + std::unique_ptr<SmCursor> pCursor; std::set< OUString > aUsedSymbols; // to export used symbols only when saving @@ -219,7 +220,7 @@ public: /** True, if cursor have previously been requested and thus * has some sort of position. */ - bool HasCursor() { return pCursor != nullptr; } + bool HasCursor(); }; #endif diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx index dae21759c0b2..9657bf6b89d4 100644 --- a/starmath/source/document.cxx +++ b/starmath/source/document.cxx @@ -489,17 +489,19 @@ Size SmDocShell::GetSize() } void SmDocShell::InvalidateCursor(){ - delete pCursor; - pCursor = nullptr; + pCursor.reset(); } SmCursor& SmDocShell::GetCursor(){ if(!pCursor) - pCursor = new SmCursor(pTree, this); + pCursor.reset(new SmCursor(pTree, this)); return *pCursor; } - +bool SmDocShell::HasCursor() +{ + return pCursor.get() != nullptr; +} SmPrinterAccess::SmPrinterAccess( SmDocShell &rDocShell ) { @@ -656,8 +658,6 @@ SmDocShell::SmDocShell( SfxModelFlags i_nSfxCreationFlags ) , nModifyCount(0) , bIsFormulaArranged(false) { - pCursor = nullptr; - SetPool(&SfxGetpApp()->GetPool()); SmModule *pp = SM_MOD(); @@ -676,10 +676,7 @@ SmDocShell::~SmDocShell() EndListening(aFormat); EndListening(*pp->GetConfig()); - - delete pCursor; - pCursor = nullptr; - + pCursor.reset(); delete pEditEngine; SfxItemPool::Free(pEditEngineItemPool); delete pTree; |