diff options
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 27 | ||||
-rw-r--r-- | sc/qa/unit/ucalc.hxx | 5 |
2 files changed, 24 insertions, 8 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index f09a0a4e12dd..c94ddca932cf 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -127,25 +127,36 @@ ScDocShell& Test::getDocShell() return *m_pImpl->m_xDocShell; } +void Test::getNewDocShell( ScDocShellRef& rDocShellRef ) +{ + rDocShellRef = new ScDocShell( + SfxModelFlags::EMBEDDED_OBJECT | + SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS | + SfxModelFlags::DISABLE_DOCUMENT_RECOVERY); + + rDocShellRef->SetIsInUcalc(); + rDocShellRef->DoInitUnitTest(); +} + +void Test::closeDocShell( ScDocShellRef& rDocShellRef ) +{ + rDocShellRef->DoClose(); + rDocShellRef.clear(); +} + void Test::setUp() { BootstrapFixture::setUp(); ScDLL::Init(); - m_pImpl->m_xDocShell = new ScDocShell( - SfxModelFlags::EMBEDDED_OBJECT | - SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS | - SfxModelFlags::DISABLE_DOCUMENT_RECOVERY); - m_pImpl->m_xDocShell->SetIsInUcalc(); - m_pImpl->m_xDocShell->DoInitUnitTest(); + getNewDocShell(m_pImpl->m_xDocShell); m_pDoc = &m_pImpl->m_xDocShell->GetDocument(); } void Test::tearDown() { - m_pImpl->m_xDocShell->DoClose(); - m_pImpl->m_xDocShell.clear(); + closeDocShell(m_pImpl->m_xDocShell); BootstrapFixture::tearDown(); } diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index 7b3b8fe4e210..cc38693db48e 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -99,6 +99,11 @@ public: ScDocShell& getDocShell(); + /** Get a separate new ScDocShell with ScDocument that suits unit test needs. */ + void getNewDocShell( ScDocShellRef& rDocShellRef ); + /** Close such new ScDocShell. */ + void closeDocShell( ScDocShellRef& rDocShellRef ); + virtual void setUp() override; virtual void tearDown() override; |