Kaydet (Commit) 91733eff authored tarafından Miklos Vajna's avatar Miklos Vajna

sw lok: avoid hiding / showing sdr mark handles on focus change

For one, this is unwanted: in the LOK case we want to switch between the
windows without any side effect to be able to e.g. paint tiles.

For another, this caused an invalidation loop when two views selected
the text frames or images in Writer. The loop looked like:

1) Press a key in view #1, so a setView(0) + paintTile() is necessary in
view #0.
2) SfxLokHelper::setView(0) to switch from view #1 to view #0.
3) SwFEShell::ShellLoseFocus() on view #1, which hides sdr marks ->
invalidate.
4) SwFEShell::ShellGetFocus() on view #0, which shows sdr marks ->
invalidate.
5) paintTile() in view #0.
6) SfxLokHelper::setView(1) to paint tiles due to 3). (Generates
invalidations in both views.)
7) SfxLokHelper::setView(0) to paint tiles due to 4).

And so on, this way a call to SfxLokHelper::setView(0) resulted in an
another (async) call to SfxLokHelper::setView(0) all the time.

Change-Id: Ice855b9128f61bb7b823b499cad366998f297b5d
Reviewed-on: https://gerrit.libreoffice.org/28611Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst 8ac2bdfd
...@@ -70,6 +70,7 @@ public: ...@@ -70,6 +70,7 @@ public:
void testTrackChanges(); void testTrackChanges();
void testTrackChangesCallback(); void testTrackChangesCallback();
void testRedlineUpdateCallback(); void testRedlineUpdateCallback();
void testSetViewGraphicSelection();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback); CPPUNIT_TEST(testRegisterCallback);
...@@ -105,6 +106,7 @@ public: ...@@ -105,6 +106,7 @@ public:
CPPUNIT_TEST(testTrackChanges); CPPUNIT_TEST(testTrackChanges);
CPPUNIT_TEST(testTrackChangesCallback); CPPUNIT_TEST(testTrackChangesCallback);
CPPUNIT_TEST(testRedlineUpdateCallback); CPPUNIT_TEST(testRedlineUpdateCallback);
CPPUNIT_TEST(testSetViewGraphicSelection);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
private: private:
...@@ -602,6 +604,7 @@ public: ...@@ -602,6 +604,7 @@ public:
bool m_bTilesInvalidated; bool m_bTilesInvalidated;
bool m_bViewCursorVisible; bool m_bViewCursorVisible;
bool m_bGraphicViewSelection; bool m_bGraphicViewSelection;
bool m_bGraphicSelection;
bool m_bViewLock; bool m_bViewLock;
ViewCallback() ViewCallback()
...@@ -612,6 +615,7 @@ public: ...@@ -612,6 +615,7 @@ public:
m_bTilesInvalidated(false), m_bTilesInvalidated(false),
m_bViewCursorVisible(false), m_bViewCursorVisible(false),
m_bGraphicViewSelection(false), m_bGraphicViewSelection(false),
m_bGraphicSelection(false),
m_bViewLock(false) m_bViewLock(false)
{ {
} }
...@@ -623,6 +627,7 @@ public: ...@@ -623,6 +627,7 @@ public:
void callbackImpl(int nType, const char* pPayload) void callbackImpl(int nType, const char* pPayload)
{ {
OString aPayload(pPayload);
switch (nType) switch (nType)
{ {
case LOK_CALLBACK_INVALIDATE_TILES: case LOK_CALLBACK_INVALIDATE_TILES:
...@@ -663,6 +668,11 @@ public: ...@@ -663,6 +668,11 @@ public:
m_bGraphicViewSelection = aTree.get_child("selection").get_value<std::string>() != "EMPTY"; m_bGraphicViewSelection = aTree.get_child("selection").get_value<std::string>() != "EMPTY";
} }
break; break;
case LOK_CALLBACK_GRAPHIC_SELECTION:
{
m_bGraphicSelection = aPayload != "EMPTY";
}
break;
case LOK_CALLBACK_VIEW_LOCK: case LOK_CALLBACK_VIEW_LOCK:
{ {
std::stringstream aStream(pPayload); std::stringstream aStream(pPayload);
...@@ -1230,6 +1240,37 @@ void SwTiledRenderingTest::testRedlineUpdateCallback() ...@@ -1230,6 +1240,37 @@ void SwTiledRenderingTest::testRedlineUpdateCallback()
comphelper::LibreOfficeKit::setActive(false); comphelper::LibreOfficeKit::setActive(false);
} }
void SwTiledRenderingTest::testSetViewGraphicSelection()
{
// Load a document.
comphelper::LibreOfficeKit::setActive();
SwXTextDocument* pXTextDocument = createDoc("frame.odt");
int nView1 = SfxLokHelper::getView();
ViewCallback aView1;
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
// Create a second view, and switch back to the first view.
SfxLokHelper::createView();
pXTextDocument->initializeForTiledRendering({});
SfxLokHelper::setView(nView1);
// Mark the textframe in the first view.
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
SdrPage* pPage = pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
SdrObject* pObject = pPage->GetObj(0);
SdrView* pView = pWrtShell->GetDrawView();
pView->MarkObj(pObject, pView->GetSdrPageView());
CPPUNIT_ASSERT(aView1.m_bGraphicSelection);
// Now start to switch to the second view (part of setView()).
pWrtShell->ShellLoseFocus();
// This failed, mark handles were hidden in the first view.
CPPUNIT_ASSERT(!pView->areMarkHandlesHidden());
mxComponent->dispose();
mxComponent.clear();
comphelper::LibreOfficeKit::setActive(false);
}
CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest); CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
#include <svx/svdobj.hxx> #include <svx/svdobj.hxx>
#include <comphelper/lok.hxx>
#include <init.hxx> #include <init.hxx>
#include <fesh.hxx> #include <fesh.hxx>
#include <pagefrm.hxx> #include <pagefrm.hxx>
...@@ -285,7 +286,8 @@ void SwFEShell::ShellGetFocus() ...@@ -285,7 +286,8 @@ void SwFEShell::ShellGetFocus()
if ( HasDrawView() ) if ( HasDrawView() )
{ {
Imp()->GetDrawView()->showMarkHandles(); if (!comphelper::LibreOfficeKit::isActive())
Imp()->GetDrawView()->showMarkHandles();
if ( Imp()->GetDrawView()->AreObjectsMarked() ) if ( Imp()->GetDrawView()->AreObjectsMarked() )
FrameNotify( this, FLY_DRAG_START ); FrameNotify( this, FLY_DRAG_START );
} }
...@@ -297,7 +299,8 @@ void SwFEShell::ShellLoseFocus() ...@@ -297,7 +299,8 @@ void SwFEShell::ShellLoseFocus()
if ( HasDrawView() && Imp()->GetDrawView()->AreObjectsMarked() ) if ( HasDrawView() && Imp()->GetDrawView()->AreObjectsMarked() )
{ {
Imp()->GetDrawView()->hideMarkHandles(); if (!comphelper::LibreOfficeKit::isActive())
Imp()->GetDrawView()->hideMarkHandles();
FrameNotify( this, FLY_DRAG_END ); FrameNotify( this, FLY_DRAG_END );
} }
} }
......
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