[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.1' - sd/qa sd/source

2017-03-17 Thread Jan Holesovsky
 sd/qa/unit/tiledrendering/tiledrendering.cxx |   17 +
 sd/source/ui/view/Outliner.cxx   |   10 +++---
 2 files changed, 24 insertions(+), 3 deletions(-)

New commits:
commit 260801511467854a4f9a5cdb3b0aed3661c26fe7
Author: Jan Holesovsky 
Date:   Mon Mar 13 19:03:48 2017 +0100

sd lok: Don't search on master pages & notes in Impress.

Change-Id: I43ed9f53618dca09e0289bffadc2c05056e0eebb

diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx 
b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index a23152a5bf86..9eba554cfc27 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -64,6 +64,7 @@ public:
 void testSearchAllSelections();
 void testSearchAllNotifications();
 void testSearchAllFollowedBySearch();
+void testDontSearchInMasterPages();
 void testInsertDeletePage();
 void testInsertTable();
 void testPartHash();
@@ -94,6 +95,7 @@ public:
 CPPUNIT_TEST(testSearchAllSelections);
 CPPUNIT_TEST(testSearchAllNotifications);
 CPPUNIT_TEST(testSearchAllFollowedBySearch);
+CPPUNIT_TEST(testDontSearchInMasterPages);
 CPPUNIT_TEST(testInsertDeletePage);
 CPPUNIT_TEST(testInsertTable);
 CPPUNIT_TEST(testPartHash);
@@ -604,6 +606,21 @@ void SdTiledRenderingTest::testSearchAllFollowedBySearch()
 CPPUNIT_ASSERT_EQUAL(OString("match"), 
pXImpressDocument->getTextSelection("text/plain;charset=utf-8", aUsedFormat));
 }
 
+void SdTiledRenderingTest::testDontSearchInMasterPages()
+{
+comphelper::LibreOfficeKit::setActive();
+SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
+sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
+
pViewShell->GetViewShellBase().registerLibreOfficeKitViewCallback(::callback,
 this);
+
+// This should trigger the not-found callback ("date" is present only on
+// the master page)
+lcl_search("date");
+CPPUNIT_ASSERT_EQUAL(false, m_bFound);
+
+comphelper::LibreOfficeKit::setActive(false);
+}
+
 namespace
 {
 
diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index 5b02bea8e63d..f3ff21a01449 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -1070,8 +1070,12 @@ void Outliner::ProvideNextTextObject()
 if (maObjectIterator != ::sd::outliner::OutlinerContainer(this).end())
 {
 maCurrentPosition = *maObjectIterator;
+
+// LOK: do not descent to notes or master pages when searching
+bool bForbiddenPage = comphelper::LibreOfficeKit::isActive() && 
(maCurrentPosition.mePageKind != PageKind::Standard || 
maCurrentPosition.meEditMode != EditMode::Page);
+
 // Switch to the current object only if it is a valid text object.
-if (IsValidTextObject (maCurrentPosition))
+if (!bForbiddenPage && IsValidTextObject(maCurrentPosition))
 {
 // Don't set yet in case of searching: the text object may not 
match.
 if (meMode != SEARCH)
@@ -1081,9 +1085,9 @@ void Outliner::ProvideNextTextObject()
 }
 ++maObjectIterator;
 
-if (mpObj != nullptr)
+if (mpObj)
 {
-PutTextIntoOutliner ();
+PutTextIntoOutliner();
 
 std::shared_ptr pViewShell (mpWeakViewShell.lock());
 if (pViewShell != nullptr)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.1' - sd/qa sd/source

2016-09-19 Thread Miklos Vajna
 sd/qa/unit/tiledrendering/tiledrendering.cxx |4 
 sd/source/ui/view/ViewShellBase.cxx  |   11 +++
 2 files changed, 15 insertions(+)

New commits:
commit 681dcf0063f8a22d9acbc617067832c50c84c2fe
Author: Miklos Vajna 
Date:   Fri Sep 16 17:15:05 2016 +0200

sd draw text: emit LOK_CALLBACK_VIEW_LOCK from registerCallback()

This is similar to commit 7b784e4e3927d91a96cd0b54fc43c9b488822e47 (sw
draw text: emit LOK_CALLBACK_VIEW_LOCK from registerCallback(),
2016-09-14), but this fix is for Impress.

Change-Id: I995d2ed223aa6ce7845c440039d176b6beada84e
(cherry picked from commit d53bb5c044f039bd2fd38977a85012b03abbe32c)

diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx 
b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 38e9174..4c92622 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -1054,7 +1054,11 @@ void SdTiledRenderingTest::testCursorViews()
 // second view as well, even if the second view was created after begin
 // text edit in the first view.
 ViewCallback aView2;
+aView2.m_bViewLock = false;
 
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(::callback,
 );
+// This failed: the second view didn't get a lock notification, even if the
+// first view already started text edit.
+CPPUNIT_ASSERT(aView2.m_bViewLock);
 SfxLokHelper::setView(nView1);
 aView2.m_bTilesInvalidated = false;
 pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
diff --git a/sd/source/ui/view/ViewShellBase.cxx 
b/sd/source/ui/view/ViewShellBase.cxx
index ad60dd7..b14774e 100644
--- a/sd/source/ui/view/ViewShellBase.cxx
+++ b/sd/source/ui/view/ViewShellBase.cxx
@@ -1071,6 +1071,17 @@ void ViewShellBase::NotifyCursor(SfxViewShell* 
pOtherShell) const
 rEditView.RegisterOtherShell(nullptr);
 // Text selection, if any.
 rEditView.DrawSelection(pOtherShell);
+
+// Shape text lock.
+if (OutlinerView* pOutlinerView = pDrawView->GetTextEditOutlinerView())
+{
+Rectangle aRectangle = pOutlinerView->GetOutputArea();
+vcl::Window* pWin = pThisShell->GetActiveWindow();
+if (pWin && pWin->GetMapMode().GetMapUnit() == MAP_100TH_MM)
+aRectangle = OutputDevice::LogicToLogic(aRectangle, 
MAP_100TH_MM, MAP_TWIP);
+OString sRectangle = aRectangle.toString();
+SfxLokHelper::notifyOtherView(>GetViewShellBase(), 
pOtherShell, LOK_CALLBACK_VIEW_LOCK, "rectangle", sRectangle);
+}
 }
 else
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.1' - sd/qa sd/source

2016-07-25 Thread Miklos Vajna
 sd/qa/unit/tiledrendering/tiledrendering.cxx |   45 ++-
 sd/source/ui/view/sdview.cxx |   19 +++
 2 files changed, 63 insertions(+), 1 deletion(-)

New commits:
commit 4a7c5abb15e559f23f737ef38202a5d72dcb8eb1
Author: Miklos Vajna 
Date:   Fri Jul 22 17:27:25 2016 +0200

sd: implement LOK_CALLBACK_VIEW_LOCK

So that edited shape text doesn't just disappear in other views without
any indication.

Change-Id: I806051492f7bc247c0e66eceda4df5eba8322aad
Reviewed-on: https://gerrit.libreoffice.org/27444
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins 
(cherry picked from commit ffd9972e2a21f6490f25c712cd0ba49e534238c8)

diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx 
b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 47fd21a..93b2272 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -66,6 +66,7 @@ public:
 void testViewCursors();
 void testViewCursorParts();
 void testCursorViews();
+void testViewLock();
 
 CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
 CPPUNIT_TEST(testRegisterCallback);
@@ -88,6 +89,7 @@ public:
 CPPUNIT_TEST(testViewCursors);
 CPPUNIT_TEST(testViewCursorParts);
 CPPUNIT_TEST(testCursorViews);
+CPPUNIT_TEST(testViewLock);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -821,12 +823,14 @@ public:
 /// Our current part, to be able to decide if a view cursor/selection is 
relevant for us.
 int m_nPart;
 bool m_bCursorVisibleChanged;
+bool m_bViewLock;
 
 ViewCallback()
 : m_bGraphicSelectionInvalidated(false),
   m_bGraphicViewSelectionInvalidated(false),
   m_nPart(0),
-  m_bCursorVisibleChanged(false)
+  m_bCursorVisibleChanged(false),
+  m_bViewLock(false)
 {
 }
 
@@ -859,6 +863,14 @@ public:
 m_bCursorVisibleChanged = true;
 }
 break;
+case LOK_CALLBACK_VIEW_LOCK:
+{
+std::stringstream aStream(pPayload);
+boost::property_tree::ptree aTree;
+boost::property_tree::read_json(aStream, aTree);
+m_bViewLock = 
aTree.get_child("rectangle").get_value() != "EMPTY";
+}
+break;
 }
 }
 };
@@ -963,6 +975,37 @@ void SdTiledRenderingTest::testCursorViews()
 comphelper::LibreOfficeKit::setActive(false);
 }
 
+void SdTiledRenderingTest::testViewLock()
+{
+comphelper::LibreOfficeKit::setActive();
+
+// Load a document that has a shape and create two views.
+SdXImpressDocument* pXImpressDocument = createDoc("shape.odp");
+ViewCallback aView1;
+
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(::callback,
 );
+SfxLokHelper::createView();
+
pXImpressDocument->initializeForTiledRendering(uno::Sequence());
+
+// Begin text edit in the second view and assert that the first gets a lock
+// notification.
+sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
+SdPage* pActualPage = pViewShell->GetActualPage();
+SdrObject* pObject = pActualPage->GetObj(0);
+SdrView* pView = pViewShell->GetView();
+aView1.m_bViewLock = false;
+pView->SdrBeginTextEdit(pObject);
+CPPUNIT_ASSERT(aView1.m_bViewLock);
+
+// End text edit in the second view, and assert that the lock is removed in
+// the first view.
+pView->SdrEndTextEdit();
+CPPUNIT_ASSERT(!aView1.m_bViewLock);
+
+mxComponent->dispose();
+mxComponent.clear();
+comphelper::LibreOfficeKit::setActive(false);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sd/source/ui/view/sdview.cxx b/sd/source/ui/view/sdview.cxx
index d3c6e16..01a23f0 100644
--- a/sd/source/ui/view/sdview.cxx
+++ b/sd/source/ui/view/sdview.cxx
@@ -91,6 +91,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 #include "DrawController.hxx"
 
 #include 
@@ -700,6 +703,18 @@ bool View::SdrBeginTextEdit(
 if ( mpViewSh )
 {
 
mpViewSh->GetViewShellBase().GetDrawController().FireSelectionChangeListener();
+
+if (comphelper::LibreOfficeKit::isActive())
+{
+if (OutlinerView* pView = GetTextEditOutlinerView())
+{
+Rectangle aRectangle = pView->GetOutputArea();
+if (pWin && pWin->GetMapMode().GetMapUnit() == MAP_100TH_MM)
+aRectangle = OutputDevice::LogicToLogic(aRectangle, 
MAP_100TH_MM, MAP_TWIP);
+OString sRectangle = aRectangle.toString();
+SfxLokHelper::notifyOtherViews(>GetViewShellBase(), 
LOK_CALLBACK_VIEW_LOCK, "rectangle", sRectangle);
+}
+}
 }
 
 if (bReturn)
@@ -790,6 +805,10 @@ SdrEndTextEditKind View::SdrEndTextEdit(bool 
bDontDeleteReally)
 if ( mpViewSh )
 {