Kaydet (Commit) c3fcb4a1 authored tarafından Miklos Vajna's avatar Miklos Vajna Kaydeden (comit) Michael Meeks

CppunitTest_sw_tiledrendering: close the document while LOK is still active

This is the same type of problem that was fixed for
CppunitTest_desktop_lib in commit
da17ccae (CppunitTest_desktop_lib: close
the document while LOK is still active, 2019-05-09).

(cherry picked from commit c1486533)

Conflicts:
	sw/qa/extras/tiledrendering/tiledrendering.cxx

Change-Id: I2fe050bf40d68dafa0334f4149e54958c492122d
Reviewed-on: https://gerrit.libreoffice.org/72216Reviewed-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
Tested-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
üst d06197f6
...@@ -1457,6 +1457,9 @@ void SfxViewShell::registerLibreOfficeKitViewCallback(LibreOfficeKitCallback pCa ...@@ -1457,6 +1457,9 @@ void SfxViewShell::registerLibreOfficeKitViewCallback(LibreOfficeKitCallback pCa
afterCallbackRegistered(); afterCallbackRegistered();
if (!pCallback)
return;
// Ask other views to tell us about their cursors. // Ask other views to tell us about their cursors.
SfxViewShell* pViewShell = SfxViewShell::GetFirst(); SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell) while (pViewShell)
......
...@@ -55,6 +55,7 @@ class SwTiledRenderingTest : public SwModelTestBase ...@@ -55,6 +55,7 @@ class SwTiledRenderingTest : public SwModelTestBase
{ {
public: public:
SwTiledRenderingTest(); SwTiledRenderingTest();
virtual void tearDown() override;
void testRegisterCallback(); void testRegisterCallback();
void testPostKeyEvent(); void testPostKeyEvent();
void testPostMouseEvent(); void testPostMouseEvent();
...@@ -196,6 +197,27 @@ SwTiledRenderingTest::SwTiledRenderingTest() ...@@ -196,6 +197,27 @@ SwTiledRenderingTest::SwTiledRenderingTest()
{ {
} }
void SwTiledRenderingTest::tearDown()
{
if (mxComponent.is())
{
SwXTextDocument* pTextDocument = dynamic_cast<SwXTextDocument*>(mxComponent.get());
if (pTextDocument)
{
SwWrtShell* pWrtShell = pTextDocument->GetDocShell()->GetWrtShell();
if (pWrtShell)
{
pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
}
}
mxComponent->dispose();
mxComponent.clear();
}
comphelper::LibreOfficeKit::setActive(false);
test::BootstrapFixture::tearDown();
}
SwXTextDocument* SwTiledRenderingTest::createDoc(const char* pName) SwXTextDocument* SwTiledRenderingTest::createDoc(const char* pName)
{ {
if (!pName) if (!pName)
...@@ -309,7 +331,6 @@ void SwTiledRenderingTest::testRegisterCallback() ...@@ -309,7 +331,6 @@ void SwTiledRenderingTest::testRegisterCallback()
CPPUNIT_ASSERT(!m_aInvalidation.IsEmpty()); CPPUNIT_ASSERT(!m_aInvalidation.IsEmpty());
tools::Rectangle aTopLeft(0, 0, 256*15, 256*15); // 1 px = 15 twips, assuming 96 DPI. tools::Rectangle aTopLeft(0, 0, 256*15, 256*15); // 1 px = 15 twips, assuming 96 DPI.
CPPUNIT_ASSERT(m_aInvalidation.IsOver(aTopLeft)); CPPUNIT_ASSERT(m_aInvalidation.IsOver(aTopLeft));
comphelper::LibreOfficeKit::setActive(false);
} }
void SwTiledRenderingTest::testPostKeyEvent() void SwTiledRenderingTest::testPostKeyEvent()
...@@ -345,7 +366,6 @@ void SwTiledRenderingTest::testPostMouseEvent() ...@@ -345,7 +366,6 @@ void SwTiledRenderingTest::testPostMouseEvent()
Scheduler::ProcessEventsToIdle(); Scheduler::ProcessEventsToIdle();
// The new cursor position must be before the first word. // The new cursor position must be before the first word.
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), pShellCursor->GetPoint()->nContent.GetIndex()); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), pShellCursor->GetPoint()->nContent.GetIndex());
comphelper::LibreOfficeKit::setActive(false);
} }
void SwTiledRenderingTest::testSetTextSelection() void SwTiledRenderingTest::testSetTextSelection()
...@@ -404,8 +424,6 @@ void SwTiledRenderingTest::testGetTextSelection() ...@@ -404,8 +424,6 @@ void SwTiledRenderingTest::testGetTextSelection()
ESelection aWordSelection(0, 0, 0, 5); ESelection aWordSelection(0, 0, 0, 5);
rEditView.SetSelection(aWordSelection); rEditView.SetSelection(aWordSelection);
CPPUNIT_ASSERT_EQUAL(OString("Shape"), pXTextDocument->getTextSelection("text/plain;charset=utf-8", aUsedFormat)); CPPUNIT_ASSERT_EQUAL(OString("Shape"), pXTextDocument->getTextSelection("text/plain;charset=utf-8", aUsedFormat));
comphelper::LibreOfficeKit::setActive(false);
} }
void SwTiledRenderingTest::testSetGraphicSelection() void SwTiledRenderingTest::testSetGraphicSelection()
...@@ -475,8 +493,6 @@ void SwTiledRenderingTest::testInsertShape() ...@@ -475,8 +493,6 @@ void SwTiledRenderingTest::testInsertShape()
// check that it is in the foreground layer // check that it is in the foreground layer
CPPUNIT_ASSERT(rDrawModelAccess.GetHeavenId() == pObject->GetLayer()); CPPUNIT_ASSERT(rDrawModelAccess.GetHeavenId() == pObject->GetLayer());
comphelper::LibreOfficeKit::setActive(false);
} }
void lcl_search(bool bBackward) void lcl_search(bool bBackward)
...@@ -529,8 +545,6 @@ void SwTiledRenderingTest::testSearch() ...@@ -529,8 +545,6 @@ void SwTiledRenderingTest::testSearch()
CPPUNIT_ASSERT(!pWrtShell->GetDrawView()->GetTextEditObject()); CPPUNIT_ASSERT(!pWrtShell->GetDrawView()->GetTextEditObject());
nActual = pWrtShell->getShellCursor(false)->Start()->nNode.GetNode().GetIndex(); nActual = pWrtShell->getShellCursor(false)->Start()->nNode.GetNode().GetIndex();
CPPUNIT_ASSERT_EQUAL(nNode + 1, nActual); CPPUNIT_ASSERT_EQUAL(nNode + 1, nActual);
comphelper::LibreOfficeKit::setActive(false);
} }
void SwTiledRenderingTest::testSearchViewArea() void SwTiledRenderingTest::testSearchViewArea()
...@@ -573,8 +587,6 @@ void SwTiledRenderingTest::testSearchTextFrame() ...@@ -573,8 +587,6 @@ void SwTiledRenderingTest::testSearchTextFrame()
comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues); comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues);
// This was empty: nothing was highlighted after searching for 'TextFrame'. // This was empty: nothing was highlighted after searching for 'TextFrame'.
CPPUNIT_ASSERT(!m_aTextSelection.isEmpty()); CPPUNIT_ASSERT(!m_aTextSelection.isEmpty());
comphelper::LibreOfficeKit::setActive(false);
} }
void SwTiledRenderingTest::testSearchTextFrameWrapAround() void SwTiledRenderingTest::testSearchTextFrameWrapAround()
...@@ -610,7 +622,6 @@ void SwTiledRenderingTest::testDocumentSizeChanged() ...@@ -610,7 +622,6 @@ void SwTiledRenderingTest::testDocumentSizeChanged()
CPPUNIT_ASSERT_EQUAL(aSize.getWidth(), m_aDocumentSize.getWidth()); CPPUNIT_ASSERT_EQUAL(aSize.getWidth(), m_aDocumentSize.getWidth());
// Document height should be smaller now. // Document height should be smaller now.
CPPUNIT_ASSERT(aSize.getHeight() > m_aDocumentSize.getHeight()); CPPUNIT_ASSERT(aSize.getHeight() > m_aDocumentSize.getHeight());
comphelper::LibreOfficeKit::setActive(false);
} }
void SwTiledRenderingTest::testSearchAll() void SwTiledRenderingTest::testSearchAll()
...@@ -631,8 +642,6 @@ void SwTiledRenderingTest::testSearchAll() ...@@ -631,8 +642,6 @@ void SwTiledRenderingTest::testSearchAll()
CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(2), m_aSearchResultSelection.size()); CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(2), m_aSearchResultSelection.size());
// Writer documents are always a single part. // Writer documents are always a single part.
CPPUNIT_ASSERT_EQUAL(0, m_aSearchResultPart[0]); CPPUNIT_ASSERT_EQUAL(0, m_aSearchResultPart[0]);
comphelper::LibreOfficeKit::setActive(false);
} }
void SwTiledRenderingTest::testSearchAllNotifications() void SwTiledRenderingTest::testSearchAllNotifications()
...@@ -656,8 +665,6 @@ void SwTiledRenderingTest::testSearchAllNotifications() ...@@ -656,8 +665,6 @@ void SwTiledRenderingTest::testSearchAllNotifications()
CPPUNIT_ASSERT_EQUAL(0, m_nSelectionBeforeSearchResult); CPPUNIT_ASSERT_EQUAL(0, m_nSelectionBeforeSearchResult);
// But we do get the selection afterwards. // But we do get the selection afterwards.
CPPUNIT_ASSERT(m_nSelectionAfterSearchResult > 0); CPPUNIT_ASSERT(m_nSelectionAfterSearchResult > 0);
comphelper::LibreOfficeKit::setActive(false);
} }
void SwTiledRenderingTest::testPageDownInvalidation() void SwTiledRenderingTest::testPageDownInvalidation()
...@@ -676,8 +683,6 @@ void SwTiledRenderingTest::testPageDownInvalidation() ...@@ -676,8 +683,6 @@ void SwTiledRenderingTest::testPageDownInvalidation()
// This was 2. // This was 2.
CPPUNIT_ASSERT_EQUAL(0, m_nInvalidations); CPPUNIT_ASSERT_EQUAL(0, m_nInvalidations);
comphelper::LibreOfficeKit::setActive(false);
} }
void SwTiledRenderingTest::testPartHash() void SwTiledRenderingTest::testPartHash()
...@@ -690,8 +695,6 @@ void SwTiledRenderingTest::testPartHash() ...@@ -690,8 +695,6 @@ void SwTiledRenderingTest::testPartHash()
{ {
CPPUNIT_ASSERT(!pXTextDocument->getPartHash(it).isEmpty()); CPPUNIT_ASSERT(!pXTextDocument->getPartHash(it).isEmpty());
} }
comphelper::LibreOfficeKit::setActive(false);
} }
/// A view callback tracks callbacks invoked on one specific view. /// A view callback tracks callbacks invoked on one specific view.
...@@ -912,10 +915,11 @@ void SwTiledRenderingTest::testMissingInvalidation() ...@@ -912,10 +915,11 @@ void SwTiledRenderingTest::testMissingInvalidation()
Scheduler::ProcessEventsToIdle(); Scheduler::ProcessEventsToIdle();
CPPUNIT_ASSERT(aView1.m_bTilesInvalidated); CPPUNIT_ASSERT(aView1.m_bTilesInvalidated);
CPPUNIT_ASSERT(aView2.m_bTilesInvalidated); CPPUNIT_ASSERT(aView2.m_bTilesInvalidated);
mxComponent->dispose();
mxComponent.clear();
comphelper::LibreOfficeKit::setActive(false); SfxLokHelper::setView(nView1);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
SfxLokHelper::setView(nView2);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
} }
void SwTiledRenderingTest::testViewCursors() void SwTiledRenderingTest::testViewCursors()
...@@ -955,10 +959,6 @@ void SwTiledRenderingTest::testViewCursors() ...@@ -955,10 +959,6 @@ void SwTiledRenderingTest::testViewCursors()
CPPUNIT_ASSERT(aView1.m_bViewSelectionSet); CPPUNIT_ASSERT(aView1.m_bViewSelectionSet);
CPPUNIT_ASSERT(aView2.m_bOwnSelectionSet); CPPUNIT_ASSERT(aView2.m_bOwnSelectionSet);
CPPUNIT_ASSERT(!aView2.m_bViewSelectionSet); CPPUNIT_ASSERT(!aView2.m_bViewSelectionSet);
mxComponent->dispose();
mxComponent.clear();
comphelper::LibreOfficeKit::setActive(false);
} }
void SwTiledRenderingTest::testShapeViewCursors() void SwTiledRenderingTest::testShapeViewCursors()
...@@ -969,7 +969,9 @@ void SwTiledRenderingTest::testShapeViewCursors() ...@@ -969,7 +969,9 @@ void SwTiledRenderingTest::testShapeViewCursors()
SwXTextDocument* pXTextDocument = createDoc("shape.fodt"); SwXTextDocument* pXTextDocument = createDoc("shape.fodt");
ViewCallback aView1; ViewCallback aView1;
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
int nView1 = SfxLokHelper::getView();
SfxLokHelper::createView(); SfxLokHelper::createView();
int nView2 = SfxLokHelper::getView();
ViewCallback aView2; ViewCallback aView2;
pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2); SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
...@@ -1000,10 +1002,11 @@ void SwTiledRenderingTest::testShapeViewCursors() ...@@ -1000,10 +1002,11 @@ void SwTiledRenderingTest::testShapeViewCursors()
CPPUNIT_ASSERT(aView1.m_bViewCursorInvalidated && aLastViewCursor1 != aView1.m_aViewCursor); CPPUNIT_ASSERT(aView1.m_bViewCursorInvalidated && aLastViewCursor1 != aView1.m_aViewCursor);
CPPUNIT_ASSERT(aView2.m_bOwnCursorInvalidated && aLastOwnCursor2 != aView2.m_aOwnCursor); CPPUNIT_ASSERT(aView2.m_bOwnCursorInvalidated && aLastOwnCursor2 != aView2.m_aOwnCursor);
CPPUNIT_ASSERT_EQUAL(aLastViewCursor2, aView2.m_aViewCursor); CPPUNIT_ASSERT_EQUAL(aLastViewCursor2, aView2.m_aViewCursor);
mxComponent->dispose();
mxComponent.clear();
comphelper::LibreOfficeKit::setActive(false); SfxLokHelper::setView(nView1);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
SfxLokHelper::setView(nView2);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
} }
void SwTiledRenderingTest::testViewCursorVisibility() void SwTiledRenderingTest::testViewCursorVisibility()
...@@ -1014,7 +1017,9 @@ void SwTiledRenderingTest::testViewCursorVisibility() ...@@ -1014,7 +1017,9 @@ void SwTiledRenderingTest::testViewCursorVisibility()
SwXTextDocument* pXTextDocument = createDoc("shape.fodt"); SwXTextDocument* pXTextDocument = createDoc("shape.fodt");
ViewCallback aView1; ViewCallback aView1;
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
int nView1 = SfxLokHelper::getView();
SfxLokHelper::createView(); SfxLokHelper::createView();
int nView2 = SfxLokHelper::getView();
pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
ViewCallback aView2; ViewCallback aView2;
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2); SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
...@@ -1032,10 +1037,11 @@ void SwTiledRenderingTest::testViewCursorVisibility() ...@@ -1032,10 +1037,11 @@ void SwTiledRenderingTest::testViewCursorVisibility()
Scheduler::ProcessEventsToIdle(); Scheduler::ProcessEventsToIdle();
// Make sure the "view/text" cursor of the first view gets a notification. // Make sure the "view/text" cursor of the first view gets a notification.
CPPUNIT_ASSERT(!aView1.m_bViewCursorVisible); CPPUNIT_ASSERT(!aView1.m_bViewCursorVisible);
mxComponent->dispose();
mxComponent.clear();
comphelper::LibreOfficeKit::setActive(false); SfxLokHelper::setView(nView1);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
SfxLokHelper::setView(nView2);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
} }
void SwTiledRenderingTest::testViewCursorCleanup() void SwTiledRenderingTest::testViewCursorCleanup()
...@@ -1046,6 +1052,7 @@ void SwTiledRenderingTest::testViewCursorCleanup() ...@@ -1046,6 +1052,7 @@ void SwTiledRenderingTest::testViewCursorCleanup()
SwXTextDocument* pXTextDocument = createDoc("shape.fodt"); SwXTextDocument* pXTextDocument = createDoc("shape.fodt");
ViewCallback aView1; ViewCallback aView1;
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
int nView1 = SfxLokHelper::getView();
int nView2 = SfxLokHelper::createView(); int nView2 = SfxLokHelper::createView();
pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
ViewCallback aView2; ViewCallback aView2;
...@@ -1069,10 +1076,11 @@ void SwTiledRenderingTest::testViewCursorCleanup() ...@@ -1069,10 +1076,11 @@ void SwTiledRenderingTest::testViewCursorCleanup()
CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(1), SfxLokHelper::getViewsCount()); CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(1), SfxLokHelper::getViewsCount());
// Make sure that the graphic view selection on the first view is cleaned up. // Make sure that the graphic view selection on the first view is cleaned up.
CPPUNIT_ASSERT(!aView1.m_bGraphicViewSelection); CPPUNIT_ASSERT(!aView1.m_bGraphicViewSelection);
mxComponent->dispose();
mxComponent.clear();
comphelper::LibreOfficeKit::setActive(false); SfxLokHelper::setView(nView1);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
SfxLokHelper::setView(nView2);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
} }
void SwTiledRenderingTest::testViewLock() void SwTiledRenderingTest::testViewLock()
...@@ -1083,7 +1091,8 @@ void SwTiledRenderingTest::testViewLock() ...@@ -1083,7 +1091,8 @@ void SwTiledRenderingTest::testViewLock()
SwXTextDocument* pXTextDocument = createDoc("shape.fodt"); SwXTextDocument* pXTextDocument = createDoc("shape.fodt");
ViewCallback aView1; ViewCallback aView1;
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
SfxLokHelper::createView(); int nView1 = SfxLokHelper::getView();
int nView2 = SfxLokHelper::createView();
pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
ViewCallback aView2; ViewCallback aView2;
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2); SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
...@@ -1103,10 +1112,10 @@ void SwTiledRenderingTest::testViewLock() ...@@ -1103,10 +1112,10 @@ void SwTiledRenderingTest::testViewLock()
pWrtShell->EndTextEdit(); pWrtShell->EndTextEdit();
CPPUNIT_ASSERT(!aView1.m_bViewLock); CPPUNIT_ASSERT(!aView1.m_bViewLock);
mxComponent->dispose(); SfxLokHelper::setView(nView1);
mxComponent.clear(); SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
SfxLokHelper::setView(nView2);
comphelper::LibreOfficeKit::setActive(false); SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
} }
void SwTiledRenderingTest::testTextEditViewInvalidations() void SwTiledRenderingTest::testTextEditViewInvalidations()
...@@ -1116,7 +1125,8 @@ void SwTiledRenderingTest::testTextEditViewInvalidations() ...@@ -1116,7 +1125,8 @@ void SwTiledRenderingTest::testTextEditViewInvalidations()
SwXTextDocument* pXTextDocument = createDoc("shape.fodt"); SwXTextDocument* pXTextDocument = createDoc("shape.fodt");
ViewCallback aView1; ViewCallback aView1;
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
SfxLokHelper::createView(); int nView1 = SfxLokHelper::getView();
int nView2 = SfxLokHelper::createView();
pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
ViewCallback aView2; ViewCallback aView2;
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2); SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
...@@ -1140,9 +1150,11 @@ void SwTiledRenderingTest::testTextEditViewInvalidations() ...@@ -1140,9 +1150,11 @@ void SwTiledRenderingTest::testTextEditViewInvalidations()
CPPUNIT_ASSERT(aView1.m_bTilesInvalidated); CPPUNIT_ASSERT(aView1.m_bTilesInvalidated);
pWrtShell->EndTextEdit(); pWrtShell->EndTextEdit();
mxComponent->dispose();
mxComponent.clear(); SfxLokHelper::setView(nView1);
comphelper::LibreOfficeKit::setActive(false); SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
SfxLokHelper::setView(nView2);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
} }
void SwTiledRenderingTest::testUndoInvalidations() void SwTiledRenderingTest::testUndoInvalidations()
...@@ -1157,6 +1169,7 @@ void SwTiledRenderingTest::testUndoInvalidations() ...@@ -1157,6 +1169,7 @@ void SwTiledRenderingTest::testUndoInvalidations()
pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
ViewCallback aView2; ViewCallback aView2;
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2); SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
int nView2 = SfxLokHelper::getView();
SfxLokHelper::setView(nView1); SfxLokHelper::setView(nView1);
// Insert a character the end of the document. // Insert a character the end of the document.
...@@ -1179,9 +1192,10 @@ void SwTiledRenderingTest::testUndoInvalidations() ...@@ -1179,9 +1192,10 @@ void SwTiledRenderingTest::testUndoInvalidations()
// Undo was dispatched on the first view, this second view was not invalidated. // Undo was dispatched on the first view, this second view was not invalidated.
CPPUNIT_ASSERT(aView2.m_bTilesInvalidated); CPPUNIT_ASSERT(aView2.m_bTilesInvalidated);
mxComponent->dispose(); SfxLokHelper::setView(nView1);
mxComponent.clear(); SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
comphelper::LibreOfficeKit::setActive(false); SfxLokHelper::setView(nView2);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
} }
void SwTiledRenderingTest::testUndoLimiting() void SwTiledRenderingTest::testUndoLimiting()
...@@ -1190,7 +1204,8 @@ void SwTiledRenderingTest::testUndoLimiting() ...@@ -1190,7 +1204,8 @@ void SwTiledRenderingTest::testUndoLimiting()
comphelper::LibreOfficeKit::setActive(); comphelper::LibreOfficeKit::setActive();
SwXTextDocument* pXTextDocument = createDoc("dummy.fodt"); SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
SwWrtShell* pWrtShell1 = pXTextDocument->GetDocShell()->GetWrtShell(); SwWrtShell* pWrtShell1 = pXTextDocument->GetDocShell()->GetWrtShell();
SfxLokHelper::createView(); int nView1 = SfxLokHelper::getView();
int nView2 = SfxLokHelper::createView();
pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
// Insert a character the end of the document in the second view. // Insert a character the end of the document in the second view.
...@@ -1206,7 +1221,10 @@ void SwTiledRenderingTest::testUndoLimiting() ...@@ -1206,7 +1221,10 @@ void SwTiledRenderingTest::testUndoLimiting()
CPPUNIT_ASSERT(!pWrtShell1->GetLastUndoInfo(nullptr, nullptr, &pWrtShell1->GetView())); CPPUNIT_ASSERT(!pWrtShell1->GetLastUndoInfo(nullptr, nullptr, &pWrtShell1->GetView()));
CPPUNIT_ASSERT(pWrtShell2->GetLastUndoInfo(nullptr, nullptr, &pWrtShell2->GetView())); CPPUNIT_ASSERT(pWrtShell2->GetLastUndoInfo(nullptr, nullptr, &pWrtShell2->GetView()));
comphelper::LibreOfficeKit::setActive(false); SfxLokHelper::setView(nView1);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
SfxLokHelper::setView(nView2);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
} }
void SwTiledRenderingTest::testUndoShapeLimiting() void SwTiledRenderingTest::testUndoShapeLimiting()
...@@ -1215,7 +1233,8 @@ void SwTiledRenderingTest::testUndoShapeLimiting() ...@@ -1215,7 +1233,8 @@ void SwTiledRenderingTest::testUndoShapeLimiting()
comphelper::LibreOfficeKit::setActive(); comphelper::LibreOfficeKit::setActive();
SwXTextDocument* pXTextDocument = createDoc("shape.fodt"); SwXTextDocument* pXTextDocument = createDoc("shape.fodt");
SwWrtShell* pWrtShell1 = pXTextDocument->GetDocShell()->GetWrtShell(); SwWrtShell* pWrtShell1 = pXTextDocument->GetDocShell()->GetWrtShell();
SfxLokHelper::createView(); int nView1 = SfxLokHelper::getView();
int nView2 = SfxLokHelper::createView();
pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
SwWrtShell* pWrtShell2 = pXTextDocument->GetDocShell()->GetWrtShell(); SwWrtShell* pWrtShell2 = pXTextDocument->GetDocShell()->GetWrtShell();
...@@ -1239,7 +1258,11 @@ void SwTiledRenderingTest::testUndoShapeLimiting() ...@@ -1239,7 +1258,11 @@ void SwTiledRenderingTest::testUndoShapeLimiting()
pWrtShell2->EndTextEdit(); pWrtShell2->EndTextEdit();
rUndoManager.SetView(nullptr); rUndoManager.SetView(nullptr);
comphelper::LibreOfficeKit::setActive(false);
SfxLokHelper::setView(nView1);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
SfxLokHelper::setView(nView2);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
} }
void SwTiledRenderingTest::testUndoDispatch() void SwTiledRenderingTest::testUndoDispatch()
...@@ -1276,7 +1299,10 @@ void SwTiledRenderingTest::testUndoDispatch() ...@@ -1276,7 +1299,10 @@ void SwTiledRenderingTest::testUndoDispatch()
// This failed: setView() did not update the active frame. // This failed: setView() did not update the active frame.
CPPUNIT_ASSERT(xFrame1 != xFrame2); CPPUNIT_ASSERT(xFrame1 != xFrame2);
comphelper::LibreOfficeKit::setActive(false); SfxLokHelper::setView(nView1);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
SfxLokHelper::setView(nView2);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
} }
void SwTiledRenderingTest::testUndoRepairDispatch() void SwTiledRenderingTest::testUndoRepairDispatch()
...@@ -1316,7 +1342,10 @@ void SwTiledRenderingTest::testUndoRepairDispatch() ...@@ -1316,7 +1342,10 @@ void SwTiledRenderingTest::testUndoRepairDispatch()
// This was 1: repair mode couldn't undo the action, either. // This was 1: repair mode couldn't undo the action, either.
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), rUndoManager.GetUndoActionCount()); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), rUndoManager.GetUndoActionCount());
comphelper::LibreOfficeKit::setActive(false); SfxLokHelper::setView(nView1);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
SfxLokHelper::setView(nView2);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
} }
void SwTiledRenderingTest::testShapeTextUndoShells() void SwTiledRenderingTest::testShapeTextUndoShells()
...@@ -1342,10 +1371,6 @@ void SwTiledRenderingTest::testShapeTextUndoShells() ...@@ -1342,10 +1371,6 @@ void SwTiledRenderingTest::testShapeTextUndoShells()
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rUndoManager.GetUndoActionCount()); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rUndoManager.GetUndoActionCount());
// This was -1: the view shell id for the undo action wasn't known. // This was -1: the view shell id for the undo action wasn't known.
CPPUNIT_ASSERT_EQUAL(ViewShellId(nView1), rUndoManager.GetUndoAction()->GetViewShellId()); CPPUNIT_ASSERT_EQUAL(ViewShellId(nView1), rUndoManager.GetUndoAction()->GetViewShellId());
mxComponent->dispose();
mxComponent.clear();
comphelper::LibreOfficeKit::setActive(false);
} }
void SwTiledRenderingTest::testShapeTextUndoGroupShells() void SwTiledRenderingTest::testShapeTextUndoGroupShells()
...@@ -1387,7 +1412,7 @@ void SwTiledRenderingTest::testShapeTextUndoGroupShells() ...@@ -1387,7 +1412,7 @@ void SwTiledRenderingTest::testShapeTextUndoGroupShells()
// Create a second view, and make sure that the new view sees the same // Create a second view, and make sure that the new view sees the same
// cursor position as the old one. // cursor position as the old one.
SfxLokHelper::createView(); int nView2 = SfxLokHelper::createView();
pXTextDocument->initializeForTiledRendering({}); pXTextDocument->initializeForTiledRendering({});
ViewCallback aView2; ViewCallback aView2;
aView2.m_aViewCursor = tools::Rectangle(); aView2.m_aViewCursor = tools::Rectangle();
...@@ -1404,9 +1429,10 @@ void SwTiledRenderingTest::testShapeTextUndoGroupShells() ...@@ -1404,9 +1429,10 @@ void SwTiledRenderingTest::testShapeTextUndoGroupShells()
// by the old view. // by the old view.
CPPUNIT_ASSERT(aView2.m_bViewLock); CPPUNIT_ASSERT(aView2.m_bViewLock);
mxComponent->dispose(); SfxLokHelper::setView(nView1);
mxComponent.clear(); SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
comphelper::LibreOfficeKit::setActive(false); SfxLokHelper::setView(nView2);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
} }
void SwTiledRenderingTest::testTrackChanges() void SwTiledRenderingTest::testTrackChanges()
...@@ -1442,8 +1468,6 @@ void SwTiledRenderingTest::testTrackChanges() ...@@ -1442,8 +1468,6 @@ void SwTiledRenderingTest::testTrackChanges()
SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false); SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false);
// This was 'Aaa bbb.zzz', the change wasn't rejected. // This was 'Aaa bbb.zzz', the change wasn't rejected.
CPPUNIT_ASSERT_EQUAL(OUString("Aaa bbb."), pShellCursor->GetPoint()->nNode.GetNode().GetTextNode()->GetText()); CPPUNIT_ASSERT_EQUAL(OUString("Aaa bbb."), pShellCursor->GetPoint()->nNode.GetNode().GetTextNode()->GetText());
comphelper::LibreOfficeKit::setActive(false);
} }
void SwTiledRenderingTest::testTrackChangesCallback() void SwTiledRenderingTest::testTrackChangesCallback()
...@@ -1472,8 +1496,6 @@ void SwTiledRenderingTest::testTrackChangesCallback() ...@@ -1472,8 +1496,6 @@ void SwTiledRenderingTest::testTrackChangesCallback()
pWrtShell->GetView().GetState(aSet); pWrtShell->GetView().GetState(aSet);
// This failed, LOK_CALLBACK_STATE_CHANGED wasn't sent. // This failed, LOK_CALLBACK_STATE_CHANGED wasn't sent.
CPPUNIT_ASSERT_EQUAL(0, m_nTrackedChangeIndex); CPPUNIT_ASSERT_EQUAL(0, m_nTrackedChangeIndex);
comphelper::LibreOfficeKit::setActive(false);
} }
void SwTiledRenderingTest::testRedlineUpdateCallback() void SwTiledRenderingTest::testRedlineUpdateCallback()
...@@ -1514,8 +1536,6 @@ void SwTiledRenderingTest::testRedlineUpdateCallback() ...@@ -1514,8 +1536,6 @@ void SwTiledRenderingTest::testRedlineUpdateCallback()
// No Modify callbacks // No Modify callbacks
CPPUNIT_ASSERT_EQUAL(3, m_nRedlineTableEntryModified); CPPUNIT_ASSERT_EQUAL(3, m_nRedlineTableEntryModified);
comphelper::LibreOfficeKit::setActive(false);
} }
void SwTiledRenderingTest::testSetViewGraphicSelection() void SwTiledRenderingTest::testSetViewGraphicSelection()
...@@ -1527,7 +1547,7 @@ void SwTiledRenderingTest::testSetViewGraphicSelection() ...@@ -1527,7 +1547,7 @@ void SwTiledRenderingTest::testSetViewGraphicSelection()
ViewCallback aView1; ViewCallback aView1;
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
// Create a second view, and switch back to the first view. // Create a second view, and switch back to the first view.
SfxLokHelper::createView(); int nView2 = SfxLokHelper::createView();
pXTextDocument->initializeForTiledRendering({}); pXTextDocument->initializeForTiledRendering({});
SfxLokHelper::setView(nView1); SfxLokHelper::setView(nView1);
...@@ -1544,9 +1564,10 @@ void SwTiledRenderingTest::testSetViewGraphicSelection() ...@@ -1544,9 +1564,10 @@ void SwTiledRenderingTest::testSetViewGraphicSelection()
// This failed, mark handles were hidden in the first view. // This failed, mark handles were hidden in the first view.
CPPUNIT_ASSERT(!pView->areMarkHandlesHidden()); CPPUNIT_ASSERT(!pView->areMarkHandlesHidden());
mxComponent->dispose(); SfxLokHelper::setView(nView1);
mxComponent.clear(); SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
comphelper::LibreOfficeKit::setActive(false); SfxLokHelper::setView(nView2);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
} }
void SwTiledRenderingTest::testCreateViewGraphicSelection() void SwTiledRenderingTest::testCreateViewGraphicSelection()
...@@ -1568,7 +1589,8 @@ void SwTiledRenderingTest::testCreateViewGraphicSelection() ...@@ -1568,7 +1589,8 @@ void SwTiledRenderingTest::testCreateViewGraphicSelection()
CPPUNIT_ASSERT(aView1.m_bGraphicSelection); CPPUNIT_ASSERT(aView1.m_bGraphicSelection);
// Create a second view. // Create a second view.
SfxLokHelper::createView(); int nView1 = SfxLokHelper::getView();
int nView2 = SfxLokHelper::createView();
// This was false, creating a second view cleared the selection of the // This was false, creating a second view cleared the selection of the
// first one. // first one.
CPPUNIT_ASSERT(aView1.m_bGraphicSelection); CPPUNIT_ASSERT(aView1.m_bGraphicSelection);
...@@ -1585,9 +1607,10 @@ void SwTiledRenderingTest::testCreateViewGraphicSelection() ...@@ -1585,9 +1607,10 @@ void SwTiledRenderingTest::testCreateViewGraphicSelection()
// first view. // first view.
CPPUNIT_ASSERT(aView2.m_bGraphicViewSelection); CPPUNIT_ASSERT(aView2.m_bGraphicViewSelection);
mxComponent->dispose(); SfxLokHelper::setView(nView1);
mxComponent.clear(); SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
comphelper::LibreOfficeKit::setActive(false); SfxLokHelper::setView(nView2);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
} }
void SwTiledRenderingTest::testCreateViewTextSelection() void SwTiledRenderingTest::testCreateViewTextSelection()
...@@ -1609,7 +1632,8 @@ void SwTiledRenderingTest::testCreateViewTextSelection() ...@@ -1609,7 +1632,8 @@ void SwTiledRenderingTest::testCreateViewTextSelection()
CPPUNIT_ASSERT_EQUAL(OUString("bbb"), pShellCursor->GetText()); CPPUNIT_ASSERT_EQUAL(OUString("bbb"), pShellCursor->GetText());
// Create a second view. // Create a second view.
SfxLokHelper::createView(); int nView1 = SfxLokHelper::getView();
int nView2 = SfxLokHelper::createView();
// Make sure that the text selection is visible in the second view. // Make sure that the text selection is visible in the second view.
ViewCallback aView2; ViewCallback aView2;
...@@ -1618,9 +1642,10 @@ void SwTiledRenderingTest::testCreateViewTextSelection() ...@@ -1618,9 +1642,10 @@ void SwTiledRenderingTest::testCreateViewTextSelection()
// This failed, the second view didn't get the text selection of the first view. // This failed, the second view didn't get the text selection of the first view.
CPPUNIT_ASSERT(!aView2.m_aViewSelection.isEmpty()); CPPUNIT_ASSERT(!aView2.m_aViewSelection.isEmpty());
mxComponent->dispose(); SfxLokHelper::setView(nView1);
mxComponent.clear(); SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
comphelper::LibreOfficeKit::setActive(false); SfxLokHelper::setView(nView2);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
} }
void SwTiledRenderingTest::testRedlineColors() void SwTiledRenderingTest::testRedlineColors()
...@@ -1642,8 +1667,6 @@ void SwTiledRenderingTest::testRedlineColors() ...@@ -1642,8 +1667,6 @@ void SwTiledRenderingTest::testRedlineColors()
boost::property_tree::ptree aTree; boost::property_tree::ptree aTree;
boost::property_tree::read_json(aStream, aTree); boost::property_tree::read_json(aStream, aTree);
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aTree.get_child("authors").size()); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aTree.get_child("authors").size());
comphelper::LibreOfficeKit::setActive(false);
} }
void SwTiledRenderingTest::testCommentEndTextEdit() void SwTiledRenderingTest::testCommentEndTextEdit()
...@@ -1683,10 +1706,6 @@ void SwTiledRenderingTest::testCommentEndTextEdit() ...@@ -1683,10 +1706,6 @@ void SwTiledRenderingTest::testCommentEndTextEdit()
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_RETURN); pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_RETURN);
Scheduler::ProcessEventsToIdle(); Scheduler::ProcessEventsToIdle();
CPPUNIT_ASSERT(aView1.m_bTilesInvalidated); CPPUNIT_ASSERT(aView1.m_bTilesInvalidated);
mxComponent->dispose();
mxComponent.clear();
comphelper::LibreOfficeKit::setActive(false);
} }
void SwTiledRenderingTest::testCursorPosition() void SwTiledRenderingTest::testCursorPosition()
...@@ -1698,7 +1717,8 @@ void SwTiledRenderingTest::testCursorPosition() ...@@ -1698,7 +1717,8 @@ void SwTiledRenderingTest::testCursorPosition()
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
// Crete a second view, so the first view gets a collaborative cursor. // Crete a second view, so the first view gets a collaborative cursor.
SfxLokHelper::createView(); int nView1 = SfxLokHelper::getView();
int nView2 = SfxLokHelper::createView();
pXTextDocument->initializeForTiledRendering({}); pXTextDocument->initializeForTiledRendering({});
ViewCallback aView2; ViewCallback aView2;
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2); SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
...@@ -1708,9 +1728,10 @@ void SwTiledRenderingTest::testCursorPosition() ...@@ -1708,9 +1728,10 @@ void SwTiledRenderingTest::testCursorPosition()
// '1425, 1425', due to pixel alignment. // '1425, 1425', due to pixel alignment.
CPPUNIT_ASSERT_EQUAL(aView1.m_aOwnCursor.toString(), aView1.m_aViewCursor.toString()); CPPUNIT_ASSERT_EQUAL(aView1.m_aOwnCursor.toString(), aView1.m_aViewCursor.toString());
mxComponent->dispose(); SfxLokHelper::setView(nView1);
mxComponent.clear(); SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
comphelper::LibreOfficeKit::setActive(false); SfxLokHelper::setView(nView2);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
} }
void SwTiledRenderingTest::testPaintCallbacks() void SwTiledRenderingTest::testPaintCallbacks()
...@@ -1723,9 +1744,10 @@ void SwTiledRenderingTest::testPaintCallbacks() ...@@ -1723,9 +1744,10 @@ void SwTiledRenderingTest::testPaintCallbacks()
SwXTextDocument* pXTextDocument = createDoc(); SwXTextDocument* pXTextDocument = createDoc();
ViewCallback aView1; ViewCallback aView1;
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
int nView1 = SfxLokHelper::getView();
// Create a second view and paint a tile on that second view. // Create a second view and paint a tile on that second view.
SfxLokHelper::createView(); int nView2 = SfxLokHelper::createView();
int nCanvasWidth = 256; int nCanvasWidth = 256;
int nCanvasHeight = 256; int nCanvasHeight = 256;
std::vector<unsigned char> aBuffer(nCanvasWidth * nCanvasHeight * 4); std::vector<unsigned char> aBuffer(nCanvasWidth * nCanvasHeight * 4);
...@@ -1736,10 +1758,14 @@ void SwTiledRenderingTest::testPaintCallbacks() ...@@ -1736,10 +1758,14 @@ void SwTiledRenderingTest::testPaintCallbacks()
aView1.m_bCalled = false; aView1.m_bCalled = false;
pXTextDocument->paintTile(*pDevice.get(), nCanvasWidth, nCanvasHeight, /*nTilePosX=*/0, /*nTilePosY=*/0, /*nTileWidth=*/3840, /*nTileHeight=*/3840); pXTextDocument->paintTile(*pDevice.get(), nCanvasWidth, nCanvasHeight, /*nTilePosX=*/0, /*nTilePosY=*/0, /*nTileWidth=*/3840, /*nTileHeight=*/3840);
CPPUNIT_ASSERT(!aView1.m_bCalled); CPPUNIT_ASSERT(!aView1.m_bCalled);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
SfxLokHelper::setView(nView1);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
mxComponent->dispose(); SfxLokHelper::setView(nView1);
mxComponent.clear(); SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
comphelper::LibreOfficeKit::setActive(false); SfxLokHelper::setView(nView2);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
} }
void SwTiledRenderingTest::testUndoRepairResult() void SwTiledRenderingTest::testUndoRepairResult()
...@@ -1772,9 +1798,10 @@ void SwTiledRenderingTest::testUndoRepairResult() ...@@ -1772,9 +1798,10 @@ void SwTiledRenderingTest::testUndoRepairResult()
Scheduler::ProcessEventsToIdle(); Scheduler::ProcessEventsToIdle();
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(SID_REPAIRPACKAGE), pResult2->m_nDocRepair); CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(SID_REPAIRPACKAGE), pResult2->m_nDocRepair);
mxComponent->dispose(); SfxLokHelper::setView(nView1);
mxComponent.clear(); SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
comphelper::LibreOfficeKit::setActive(false); SfxLokHelper::setView(nView2);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
} }
void SwTiledRenderingTest::testRedoRepairResult() void SwTiledRenderingTest::testRedoRepairResult()
...@@ -1810,9 +1837,10 @@ void SwTiledRenderingTest::testRedoRepairResult() ...@@ -1810,9 +1837,10 @@ void SwTiledRenderingTest::testRedoRepairResult()
Scheduler::ProcessEventsToIdle(); Scheduler::ProcessEventsToIdle();
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(SID_REPAIRPACKAGE), pResult2->m_nDocRepair); CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(SID_REPAIRPACKAGE), pResult2->m_nDocRepair);
mxComponent->dispose(); SfxLokHelper::setView(nView1);
mxComponent.clear(); SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
comphelper::LibreOfficeKit::setActive(false); SfxLokHelper::setView(nView2);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
} }
namespace { namespace {
...@@ -1896,9 +1924,10 @@ void SwTiledRenderingTest::testDisableUndoRepair() ...@@ -1896,9 +1924,10 @@ void SwTiledRenderingTest::testDisableUndoRepair()
Scheduler::ProcessEventsToIdle(); Scheduler::ProcessEventsToIdle();
checkUndoRepairStates(pXTextDocument, pView1, pView2); checkUndoRepairStates(pXTextDocument, pView1, pView2);
mxComponent->dispose(); SfxLokHelper::setView(nView1);
mxComponent.clear(); SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
comphelper::LibreOfficeKit::setActive(false); SfxLokHelper::setView(nView2);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
} }
void SwTiledRenderingTest::testAllTrackedChanges() void SwTiledRenderingTest::testAllTrackedChanges()
...@@ -1916,7 +1945,8 @@ void SwTiledRenderingTest::testAllTrackedChanges() ...@@ -1916,7 +1945,8 @@ void SwTiledRenderingTest::testAllTrackedChanges()
SwWrtShell* pWrtShell1 = pView1->GetWrtShellPtr(); SwWrtShell* pWrtShell1 = pView1->GetWrtShellPtr();
// view #2 // view #2
SfxLokHelper::createView(); int nView1 = SfxLokHelper::getView();
int nView2 = SfxLokHelper::createView();
SwView* pView2 = dynamic_cast<SwView*>(SfxViewShell::Current()); SwView* pView2 = dynamic_cast<SwView*>(SfxViewShell::Current());
CPPUNIT_ASSERT(pView2 && pView1 != pView2); CPPUNIT_ASSERT(pView2 && pView1 != pView2);
SwWrtShell* pWrtShell2 = pView2->GetWrtShellPtr(); SwWrtShell* pWrtShell2 = pView2->GetWrtShellPtr();
...@@ -1968,7 +1998,10 @@ void SwTiledRenderingTest::testAllTrackedChanges() ...@@ -1968,7 +1998,10 @@ void SwTiledRenderingTest::testAllTrackedChanges()
CPPUNIT_ASSERT_EQUAL(OUString("hyyAaa bbb.cyy"), pShellCursor->GetPoint()->nNode.GetNode().GetTextNode()->GetText()); CPPUNIT_ASSERT_EQUAL(OUString("hyyAaa bbb.cyy"), pShellCursor->GetPoint()->nNode.GetNode().GetTextNode()->GetText());
} }
comphelper::LibreOfficeKit::setActive(false); SfxLokHelper::setView(nView1);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
SfxLokHelper::setView(nView2);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
} }
void SwTiledRenderingTest::testDocumentRepair() void SwTiledRenderingTest::testDocumentRepair()
...@@ -1981,6 +2014,7 @@ void SwTiledRenderingTest::testDocumentRepair() ...@@ -1981,6 +2014,7 @@ void SwTiledRenderingTest::testDocumentRepair()
SfxViewShell* pView1 = SfxViewShell::Current(); SfxViewShell* pView1 = SfxViewShell::Current();
// view #2 // view #2
int nView1 = SfxLokHelper::getView();
SfxLokHelper::createView(); SfxLokHelper::createView();
SfxViewShell* pView2 = SfxViewShell::Current(); SfxViewShell* pView2 = SfxViewShell::Current();
int nView2 = SfxLokHelper::getView(); int nView2 = SfxLokHelper::getView();
...@@ -2012,7 +2046,10 @@ void SwTiledRenderingTest::testDocumentRepair() ...@@ -2012,7 +2046,10 @@ void SwTiledRenderingTest::testDocumentRepair()
CPPUNIT_ASSERT_EQUAL(true, dynamic_cast< const SfxBoolItem* >(pItem2.get())->GetValue()); CPPUNIT_ASSERT_EQUAL(true, dynamic_cast< const SfxBoolItem* >(pItem2.get())->GetValue());
} }
comphelper::LibreOfficeKit::setActive(false); SfxLokHelper::setView(nView1);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
SfxLokHelper::setView(nView2);
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
} }
namespace { namespace {
...@@ -2061,10 +2098,6 @@ void SwTiledRenderingTest::testPageHeader() ...@@ -2061,10 +2098,6 @@ void SwTiledRenderingTest::testPageHeader()
} }
// Check Page Header State // Check Page Header State
checkPageHeaderOrFooter(pViewShell, FN_INSERT_PAGEHEADER, false); checkPageHeaderOrFooter(pViewShell, FN_INSERT_PAGEHEADER, false);
mxComponent->dispose();
mxComponent.clear();
comphelper::LibreOfficeKit::setActive(false);
} }
void SwTiledRenderingTest::testPageFooter() void SwTiledRenderingTest::testPageFooter()
...@@ -2092,10 +2125,6 @@ void SwTiledRenderingTest::testPageFooter() ...@@ -2092,10 +2125,6 @@ void SwTiledRenderingTest::testPageFooter()
} }
// Check Footer State // Check Footer State
checkPageHeaderOrFooter(pViewShell, FN_INSERT_PAGEFOOTER, false); checkPageHeaderOrFooter(pViewShell, FN_INSERT_PAGEFOOTER, false);
mxComponent->dispose();
mxComponent.clear();
comphelper::LibreOfficeKit::setActive(false);
} }
void SwTiledRenderingTest::testRedlineField() void SwTiledRenderingTest::testRedlineField()
...@@ -2118,8 +2147,6 @@ void SwTiledRenderingTest::testRedlineField() ...@@ -2118,8 +2147,6 @@ void SwTiledRenderingTest::testRedlineField()
CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(1), rTable.size()); CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(1), rTable.size());
SwRangeRedline* pRedline = rTable[0]; SwRangeRedline* pRedline = rTable[0];
CPPUNIT_ASSERT(pRedline->GetDescr().indexOf(aDate.GetFieldName())!= -1); CPPUNIT_ASSERT(pRedline->GetDescr().indexOf(aDate.GetFieldName())!= -1);
comphelper::LibreOfficeKit::setActive(false);
} }
void SwTiledRenderingTest::testIMESupport() void SwTiledRenderingTest::testIMESupport()
...@@ -2150,8 +2177,6 @@ void SwTiledRenderingTest::testIMESupport() ...@@ -2150,8 +2177,6 @@ void SwTiledRenderingTest::testIMESupport()
// content contains only the last IME composition, not all // content contains only the last IME composition, not all
CPPUNIT_ASSERT_EQUAL(aInputs[aInputs.size() - 1].concat("Aaa bbb."), pShellCursor->GetPoint()->nNode.GetNode().GetTextNode()->GetText()); CPPUNIT_ASSERT_EQUAL(aInputs[aInputs.size() - 1].concat("Aaa bbb."), pShellCursor->GetPoint()->nNode.GetNode().GetTextNode()->GetText());
comphelper::LibreOfficeKit::setActive(false);
} }
void SwTiledRenderingTest::testSplitNodeRedlineCallback() void SwTiledRenderingTest::testSplitNodeRedlineCallback()
...@@ -2211,8 +2236,6 @@ void SwTiledRenderingTest::testSplitNodeRedlineCallback() ...@@ -2211,8 +2236,6 @@ void SwTiledRenderingTest::testSplitNodeRedlineCallback()
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_RETURN); pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_RETURN);
Scheduler::ProcessEventsToIdle(); Scheduler::ProcessEventsToIdle();
CPPUNIT_ASSERT_EQUAL(0, m_nRedlineTableEntryModified); CPPUNIT_ASSERT_EQUAL(0, m_nRedlineTableEntryModified);
comphelper::LibreOfficeKit::setActive(false);
} }
void SwTiledRenderingTest::testDeleteNodeRedlineCallback() void SwTiledRenderingTest::testDeleteNodeRedlineCallback()
...@@ -2272,8 +2295,6 @@ void SwTiledRenderingTest::testDeleteNodeRedlineCallback() ...@@ -2272,8 +2295,6 @@ void SwTiledRenderingTest::testDeleteNodeRedlineCallback()
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_BACKSPACE); pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_BACKSPACE);
Scheduler::ProcessEventsToIdle(); Scheduler::ProcessEventsToIdle();
CPPUNIT_ASSERT_EQUAL(0, m_nRedlineTableEntryModified); CPPUNIT_ASSERT_EQUAL(0, m_nRedlineTableEntryModified);
comphelper::LibreOfficeKit::setActive(false);
} }
...@@ -2350,10 +2371,10 @@ void SwTiledRenderingTest::testVisCursorInvalidation() ...@@ -2350,10 +2371,10 @@ void SwTiledRenderingTest::testVisCursorInvalidation()
CPPUNIT_ASSERT_EQUAL(nView2, aView2.m_nOwnCursorInvalidatedBy); CPPUNIT_ASSERT_EQUAL(nView2, aView2.m_nOwnCursorInvalidatedBy);
comphelper::LibreOfficeKit::setViewIdForVisCursorInvalidation(false); comphelper::LibreOfficeKit::setViewIdForVisCursorInvalidation(false);
SfxLokHelper::setView(nView1);
mxComponent->dispose(); SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
mxComponent.clear(); SfxLokHelper::setView(nView2);
comphelper::LibreOfficeKit::setActive(false); SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
} }
void SwTiledRenderingTest::testDeselectCustomShape() void SwTiledRenderingTest::testDeselectCustomShape()
...@@ -2375,8 +2396,6 @@ void SwTiledRenderingTest::testDeselectCustomShape() ...@@ -2375,8 +2396,6 @@ void SwTiledRenderingTest::testDeselectCustomShape()
pXTextDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, aStart.getX(), aStart.getY(), 1, MOUSE_LEFT, 0); pXTextDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, aStart.getX(), aStart.getY(), 1, MOUSE_LEFT, 0);
Scheduler::ProcessEventsToIdle(); Scheduler::ProcessEventsToIdle();
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pWrtShell->GetDrawView()->GetMarkedObjectList().GetMarkCount()); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pWrtShell->GetDrawView()->GetMarkedObjectList().GetMarkCount());
comphelper::LibreOfficeKit::setActive(false);
} }
CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest); CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
......
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