summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-09-02 10:52:46 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-09-02 14:58:07 +0200
commitc7e48d8bf23e0fce7af5fa90ac173f0d477d7aac (patch)
treef6d930732ecff112d537c279015dd7db9320f920
parent455b38e175b6a617f60107c79dcfb50ad7f1c1ce (diff)
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/28611 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org> (cherry picked from commit 91733eff7fba157daf88b092189d842f9d6f1b68)
-rw-r--r--sw/qa/extras/tiledrendering/data/frame.odtbin0 -> 8370 bytes
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx41
-rw-r--r--sw/source/core/frmedt/fews.cxx7
3 files changed, 46 insertions, 2 deletions
diff --git a/sw/qa/extras/tiledrendering/data/frame.odt b/sw/qa/extras/tiledrendering/data/frame.odt
new file mode 100644
index 000000000000..167e8f5b1014
--- /dev/null
+++ b/sw/qa/extras/tiledrendering/data/frame.odt
Binary files differ
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 1eda2ad59fb2..4861f128dd8e 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -71,6 +71,7 @@ public:
void testTrackChanges();
void testTrackChangesCallback();
void testRedlineUpdateCallback();
+ void testSetViewGraphicSelection();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -106,6 +107,7 @@ public:
CPPUNIT_TEST(testTrackChanges);
CPPUNIT_TEST(testTrackChangesCallback);
CPPUNIT_TEST(testRedlineUpdateCallback);
+ CPPUNIT_TEST(testSetViewGraphicSelection);
CPPUNIT_TEST_SUITE_END();
private:
@@ -603,6 +605,7 @@ public:
bool m_bTilesInvalidated;
bool m_bViewCursorVisible;
bool m_bGraphicViewSelection;
+ bool m_bGraphicSelection;
bool m_bViewLock;
ViewCallback()
@@ -613,6 +616,7 @@ public:
m_bTilesInvalidated(false),
m_bViewCursorVisible(false),
m_bGraphicViewSelection(false),
+ m_bGraphicSelection(false),
m_bViewLock(false)
{
}
@@ -624,6 +628,7 @@ public:
void callbackImpl(int nType, const char* pPayload)
{
+ OString aPayload(pPayload);
switch (nType)
{
case LOK_CALLBACK_INVALIDATE_TILES:
@@ -664,6 +669,11 @@ public:
m_bGraphicViewSelection = aTree.get_child("selection").get_value<std::string>() != "EMPTY";
}
break;
+ case LOK_CALLBACK_GRAPHIC_SELECTION:
+ {
+ m_bGraphicSelection = aPayload != "EMPTY";
+ }
+ break;
case LOK_CALLBACK_VIEW_LOCK:
{
std::stringstream aStream(pPayload);
@@ -1231,6 +1241,37 @@ void SwTiledRenderingTest::testRedlineUpdateCallback()
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_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/frmedt/fews.cxx b/sw/source/core/frmedt/fews.cxx
index 287b94bca4b1..7f2685e9b141 100644
--- a/sw/source/core/frmedt/fews.cxx
+++ b/sw/source/core/frmedt/fews.cxx
@@ -18,6 +18,7 @@
*/
#include <svx/svdobj.hxx>
+#include <comphelper/lok.hxx>
#include <init.hxx>
#include <fesh.hxx>
#include <pagefrm.hxx>
@@ -285,7 +286,8 @@ void SwFEShell::ShellGetFocus( bool bUpdate )
if ( HasDrawView() )
{
- Imp()->GetDrawView()->showMarkHandles();
+ if (!comphelper::LibreOfficeKit::isActive())
+ Imp()->GetDrawView()->showMarkHandles();
if ( Imp()->GetDrawView()->AreObjectsMarked() )
FrameNotify( this, FLY_DRAG_START );
}
@@ -297,7 +299,8 @@ void SwFEShell::ShellLoseFocus()
if ( HasDrawView() && Imp()->GetDrawView()->AreObjectsMarked() )
{
- Imp()->GetDrawView()->hideMarkHandles();
+ if (!comphelper::LibreOfficeKit::isActive())
+ Imp()->GetDrawView()->hideMarkHandles();
FrameNotify( this, FLY_DRAG_END );
}
}