[Libreoffice-commits] core.git: sc/qa sc/source
Miklos Vajna
vmiklos at collabora.co.uk
Tue Jul 19 13:54:06 UTC 2016
sc/qa/unit/tiledrendering/tiledrendering.cxx | 51 ++++++++++++++++++++++++++-
sc/source/ui/unoobj/docuno.cxx | 2 +
sc/source/ui/view/gridwin.cxx | 2 +
3 files changed, 54 insertions(+), 1 deletion(-)
New commits:
commit 495cfa27c173741caa233575438c18746272b4aa
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Jul 19 14:35:56 2016 +0200
sc lok: notify other views about selection changes of multiple cells
A single cell is handled by the cell cursor, which was already handled.
This one takes care of the situation when multiple cells are selected.
Change-Id: I11b3045e4884ad9629655e2c05c16af83d21e7b2
Reviewed-on: https://gerrit.libreoffice.org/27318
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index d0ea09d..e66585d 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -14,6 +14,7 @@
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/frame/DispatchHelper.hpp>
#include <comphelper/dispatchcommand.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/propertysequence.hxx>
@@ -54,6 +55,7 @@ public:
void testDocumentSize();
void testEmptyColumnSelection();
void testViewCursors();
+ void testTextViewSelection();
CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
CPPUNIT_TEST(testRowColumnSelections);
@@ -62,6 +64,7 @@ public:
CPPUNIT_TEST(testDocumentSize);
CPPUNIT_TEST(testEmptyColumnSelection);
CPPUNIT_TEST(testViewCursors);
+ CPPUNIT_TEST(testTextViewSelection);
CPPUNIT_TEST_SUITE_END();
private:
@@ -357,10 +360,12 @@ class ViewCallback
public:
bool m_bOwnCursorInvalidated;
bool m_bViewCursorInvalidated;
+ bool m_bTextViewSelectionInvalidated;
ViewCallback()
: m_bOwnCursorInvalidated(false),
- m_bViewCursorInvalidated(false)
+ m_bViewCursorInvalidated(false),
+ m_bTextViewSelectionInvalidated(false)
{
}
@@ -383,6 +388,11 @@ public:
m_bViewCursorInvalidated = true;
}
break;
+ case LOK_CALLBACK_TEXT_VIEW_SELECTION:
+ {
+ m_bTextViewSelectionInvalidated = true;
+ }
+ break;
}
}
};
@@ -409,6 +419,45 @@ void ScTiledRenderingTest::testViewCursors()
comphelper::LibreOfficeKit::setActive(false);
}
+void lcl_dispatchCommand(const uno::Reference<lang::XComponent>& xComponent, const OUString& rCommand)
+{
+ uno::Reference<frame::XController> xController = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY)->getCurrentController();
+ CPPUNIT_ASSERT(xController.is());
+ uno::Reference<frame::XDispatchProvider> xFrame(xController->getFrame(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xFrame.is());
+
+ uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
+ uno::Reference<frame::XDispatchHelper> xDispatchHelper(frame::DispatchHelper::create(xContext));
+ CPPUNIT_ASSERT(xDispatchHelper.is());
+
+ xDispatchHelper->executeDispatch(xFrame, rCommand, OUString(), 0, {});
+}
+
+void ScTiledRenderingTest::testTextViewSelection()
+{
+ comphelper::LibreOfficeKit::setActive();
+
+ // Create two views, and leave the second one current.
+ ScModelObj* pModelObj = createDoc("select-row-cols.ods");
+ ViewCallback aView1;
+ SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
+ SfxLokHelper::createView();
+ ViewCallback aView2;
+ pModelObj->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
+ SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
+
+ // Create a selection on two cells in the second view, that's a text selection in LOK terms.
+ aView1.m_bTextViewSelectionInvalidated = false;
+ lcl_dispatchCommand(mxComponent, ".uno:GoRightSel");
+ Scheduler::ProcessEventsToIdle();
+ // Make sure the first view got its notification.
+ CPPUNIT_ASSERT(aView1.m_bTextViewSelectionInvalidated);
+
+ mxComponent->dispose();
+ mxComponent.clear();
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
}
CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest);
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index f7d8b91..0146c20 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -71,6 +71,7 @@
#if HAVE_FEATURE_OPENCL
#include <opencl/platforminfo.hxx>
#endif
+#include <sfx2/lokhelper.hxx>
#include "cellsuno.hxx"
#include <columnspanset.hxx>
@@ -862,6 +863,7 @@ void ScModelObj::resetSelection()
// and hide the cell and text selection
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, "");
+ SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection", "");
}
void ScModelObj::setClipboard(const uno::Reference<datatransfer::clipboard::XClipboard>& xClipboard)
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 076dd45..2a91ffc 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5876,6 +5876,7 @@ static void updateLibreOfficeKitSelection(ScViewData* pViewData, const std::vect
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION_START, aStart.toString().getStr());
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION_END, aEnd.toString().getStr());
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, aSelection.getStr());
+ SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection", aSelection.getStr());
}
void ScGridWindow::UpdateCursorOverlay()
@@ -6120,6 +6121,7 @@ void ScGridWindow::UpdateSelectionOverlay()
{
ScTabViewShell* pViewShell = pViewData->GetViewShell();
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, "EMPTY");
+ SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection", "EMPTY");
}
if ( aOldMode != aDrawMode )
More information about the Libreoffice-commits
mailing list