[Libreoffice-commits] core.git: sw/qa sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Fri Sep 2 10:28:42 UTC 2016
sw/qa/extras/tiledrendering/data/frame.odt |binary
sw/qa/extras/tiledrendering/tiledrendering.cxx | 41 +++++++++++++++++++++++++
sw/source/core/frmedt/fews.cxx | 7 +++-
3 files changed, 46 insertions(+), 2 deletions(-)
New commits:
commit 91733eff7fba157daf88b092189d842f9d6f1b68
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Sep 2 10:52:46 2016 +0200
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 at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
diff --git a/sw/qa/extras/tiledrendering/data/frame.odt b/sw/qa/extras/tiledrendering/data/frame.odt
new file mode 100644
index 0000000..167e8f5
Binary files /dev/null and b/sw/qa/extras/tiledrendering/data/frame.odt differ
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index ab9be3d..f46136e 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -70,6 +70,7 @@ public:
void testTrackChanges();
void testTrackChangesCallback();
void testRedlineUpdateCallback();
+ void testSetViewGraphicSelection();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -105,6 +106,7 @@ public:
CPPUNIT_TEST(testTrackChanges);
CPPUNIT_TEST(testTrackChangesCallback);
CPPUNIT_TEST(testRedlineUpdateCallback);
+ CPPUNIT_TEST(testSetViewGraphicSelection);
CPPUNIT_TEST_SUITE_END();
private:
@@ -602,6 +604,7 @@ public:
bool m_bTilesInvalidated;
bool m_bViewCursorVisible;
bool m_bGraphicViewSelection;
+ bool m_bGraphicSelection;
bool m_bViewLock;
ViewCallback()
@@ -612,6 +615,7 @@ public:
m_bTilesInvalidated(false),
m_bViewCursorVisible(false),
m_bGraphicViewSelection(false),
+ m_bGraphicSelection(false),
m_bViewLock(false)
{
}
@@ -623,6 +627,7 @@ public:
void callbackImpl(int nType, const char* pPayload)
{
+ OString aPayload(pPayload);
switch (nType)
{
case LOK_CALLBACK_INVALIDATE_TILES:
@@ -663,6 +668,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);
@@ -1230,6 +1240,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 9bc6d94..29ed7cc 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()
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 );
}
}
More information about the Libreoffice-commits
mailing list