diff --git a/writerperfect/qa/unit/WpftImportTestBase.cxx b/writerperfect/qa/unit/WpftImportTestBase.cxx index 773fa3b26451..4a05d05b8f23 100644 --- a/writerperfect/qa/unit/WpftImportTestBase.cxx +++ b/writerperfect/qa/unit/WpftImportTestBase.cxx @@ -80,6 +80,30 @@ bool WpftImportTestBase::load(const OUString &, const OUString &rURL, const OUSt m_xDesktop->loadComponentFromURL(m_aFactoryURL, "_blank", 0, uno::Sequence()), uno::UNO_QUERY_THROW); + // Find the model and frame. We need them later. + uno::Reference xFrame(xDoc, uno::UNO_QUERY); + uno::Reference xModel(xDoc, uno::UNO_QUERY); + uno::Reference xController(xDoc, uno::UNO_QUERY); + + if (xFrame.is()) + { + xController = xFrame->getController(); + xModel = xController->getModel(); + } + else if (xModel.is()) + { + xController = xModel->getCurrentController(); + xFrame = xController->getFrame(); + } + else if (xController.is()) + { + xFrame = xController->getFrame(); + xModel = xController->getModel(); + } + + if (!xFrame.is() || !xModel.is()) + throw uno::RuntimeException(); + bool result = false; // try to import the document (and load it into the prepared frame) @@ -105,7 +129,9 @@ bool WpftImportTestBase::load(const OUString &, const OUString &rURL, const OUSt impl_detectFilterName(aDescriptor, aTypeName); + xModel->lockControllers(); result = m_xFilter->filter(aDescriptor); + xModel->unlockControllers(); } catch (const uno::Exception &) { @@ -113,29 +139,9 @@ bool WpftImportTestBase::load(const OUString &, const OUString &rURL, const OUSt } // close the opened document - uno::Reference xCloseable(xDoc, uno::UNO_QUERY); - - if (!xCloseable.is()) - { - uno::Reference xController(xDoc, uno::UNO_QUERY); - - if (!xController.is()) - { - const uno::Reference xModel(xDoc, uno::UNO_QUERY); - if (xModel.is()) - xController = xModel->getCurrentController(); - } - - if (xController.is()) - { - const uno::Reference xFrame = xController->getFrame(); - if (xFrame.is()) - xCloseable.set(xFrame, uno::UNO_QUERY); - } - } - try { + uno::Reference xCloseable(xFrame, uno::UNO_QUERY); if (xCloseable.is()) xCloseable->close(true); else