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