[Libreoffice-commits] core.git: desktop/qa sw/source

2021-09-22 Thread Andrea Gelmini (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |2 +-
 sw/source/uibase/utlui/content.cxx  |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 84e61754bfe2f07de412c24513774900702a48a2
Author: Andrea Gelmini 
AuthorDate: Wed Sep 22 22:10:23 2021 +0200
Commit: Adolfo Jayme Barrientos 
CommitDate: Thu Sep 23 05:29:21 2021 +0200

Fix typos

Change-Id: I01c46b864e296d4094f0a1579fdc64066eacc386
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122496
Tested-by: Jenkins
Reviewed-by: Adolfo Jayme Barrientos 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 680e48228d10..d827124a4e52 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -3299,7 +3299,7 @@ void DesktopLOKTest::testMultiViewTableSelection()
 Scheduler::ProcessEventsToIdle();
 // View1 should not get any table selection messages.
 CPPUNIT_ASSERT_EQUAL(0, aView1.m_nTableSelectionCount);
-// View2 will first get table selection of Table1, then emty selection, 
and finally on 7th down arrow keypress,
+// View2 will first get table selection of Table1, then empty selection, 
and finally on 7th down arrow keypress,
 // it will get table-selection of Table2. So in total it should get 3 
table selections.
 CPPUNIT_ASSERT_EQUAL(3, aView2.m_nTableSelectionCount);
 CPPUNIT_ASSERT(!aView2.m_bEmptyTableSelection);
diff --git a/sw/source/uibase/utlui/content.cxx 
b/sw/source/uibase/utlui/content.cxx
index fb8667ead94a..ff17d753e13e 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -3406,7 +3406,7 @@ void SwContentTree::UpdateTracking()
 m_pActiveShell->GetContentAtPos(m_pActiveShell->GetCursorDocPos(), 
aContentAtPos) &&
 !(m_bIsRoot && m_nRootType != ContentTypeId::URLFIELD))
 {
-// Because hyperlink item names do not need to be unique, finding the 
corrosponding item
+// Because hyperlink item names do not need to be unique, finding the 
corresponding item
 // in the tree by name may result in incorrect selection. Find the 
item in the tree by
 // comparing the SwTextINetFormat pointer at the document cursor 
position to that stored
 // in the item SwURLFieldContent.


[Libreoffice-commits] core.git: desktop/qa sw/source

2021-08-10 Thread Tomaž Vajngerl (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |7 ++--
 sw/source/uibase/uno/unotxdoc.cxx   |   49 
 2 files changed, 40 insertions(+), 16 deletions(-)

New commits:
commit 7da5537f6a43c1b82afc5e0c8d18b8d847293fda
Author: Tomaž Vajngerl 
AuthorDate: Mon Aug 2 22:27:28 2021 +0900
Commit: Tomaž Vajngerl 
CommitDate: Tue Aug 10 08:32:57 2021 +0200

indexing: use XML as input that is identical to indexing XML

Change-Id: I2242b4bd77220b55e67c2e0f0fe54f008759d282
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120194
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index f23f9709416e..dc8b4caf1de4 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -3117,13 +3117,16 @@ void DesktopLOKTest::testRenderSearchResult()
 Scheduler::ProcessEventsToIdle();
 
 unsigned char* pBuffer = nullptr;
-OString aJSON = "{ \"type\" : 1, \"node_index\" : 19 }";
+OString aPayload =
+""
+"ABC"
+"";
 
 int nWidth = 0;
 int nHeight = 0;
 size_t nByteSize = 0;
 
-bool bResult = pDocument->m_pDocumentClass->renderSearchResult(pDocument, 
aJSON.getStr(), , , , );
+bool bResult = pDocument->m_pDocumentClass->renderSearchResult(pDocument, 
aPayload.getStr(), , , , );
 
 CPPUNIT_ASSERT(bResult);
 CPPUNIT_ASSERT(pBuffer);
diff --git a/sw/source/uibase/uno/unotxdoc.cxx 
b/sw/source/uibase/uno/unotxdoc.cxx
index 2940c52b8256..51dfac84254c 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -122,7 +122,6 @@
 #include 
 #include 
 
-
 #include 
 #include 
 
@@ -164,7 +163,7 @@
 
 #include 
 #include 
-#include 
+#include 
 
 #define TWIPS_PER_PIXEL 15
 
@@ -3397,23 +3396,45 @@ SwXTextDocument::getSearchResultRectangles(const char* 
pPayload)
 {
 std::vector aRectangles;
 
-boost::property_tree::ptree aTree;
-std::stringstream aStream(pPayload);
-boost::property_tree::read_json(aStream, aTree);
+const OString aPayloadString(pPayload);
 
-sw::search::SearchIndexData aData;
+SvMemoryStream aStream(const_cast(aPayloadString.getStr()), 
aPayloadString.getLength(), StreamMode::READ);
+tools::XmlWalker aWalker;
+if (!aWalker.open())
+return aRectangles;
 
-int nType = aTree.get("type");
+if (aWalker.name() == "indexing")
+{
+SwDoc* pDoc = m_pDocShell->GetDoc();
 
-aData.nNodeIndex = sal_uInt32(aTree.get("node_index"));
-aData.eType = sw::search::NodeType(nType);
+sw::search::SearchIndexData aData;
 
-SwDoc* pDoc = m_pDocShell->GetDoc();
+aWalker.children();
+while (aWalker.isValid())
+{
+if (aWalker.name() == "paragraph")
+{
+OString sType = aWalker.attribute("type");
+OString sIndex = aWalker.attribute("index");
+
+if (!sType.isEmpty() && !sIndex.isEmpty())
+{
+aData.nNodeIndex = sIndex.toInt32();
+aData.eType = sw::search::NodeType(sType.toInt32());
 
-sw::search::SearchResultLocator aLocator(pDoc);
-sw::search::LocationResult aResult = aLocator.find(aData);
-if (aResult.mbFound)
-aRectangles = aResult.maRectangles;
+sw::search::SearchResultLocator aLocator(pDoc);
+sw::search::LocationResult aResult = aLocator.find(aData);
+if (aResult.mbFound)
+{
+for (auto const & rRect : aResult.maRectangles)
+aRectangles.push_back(rRect);
+}
+}
+}
+aWalker.next();
+}
+aWalker.parent();
+}
 
 return aRectangles;
 }


[Libreoffice-commits] core.git: desktop/qa sw/source

2016-09-28 Thread Miklos Vajna
 desktop/qa/desktop_lib/test_desktop_lib.cxx |   17 ++---
 sw/source/uibase/docvw/PostItMgr.cxx|   10 ++
 2 files changed, 24 insertions(+), 3 deletions(-)

New commits:
commit 7fd1516ed3eeb6523276eabbf9d7f8fcb246e96a
Author: Miklos Vajna 
Date:   Wed Sep 28 17:16:16 2016 +0200

sw lok: fix one view inserting a comment, other view jumping there as well

Views are expected to be more or less independent. So when one view
inserts a comment, don't emit cursor callbacks in the other views, so
that the other views don't jump to the comment position.

Change-Id: I5e4eadccef971dce2b7c759f3094f6d348d07645

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 3456576..1425c1c 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -1572,19 +1572,24 @@ void DesktopLOKTest::testPaintPartTile()
 
 void DesktopLOKTest::testWriterCommentInsertCursor()
 {
-// Load a document and type a character into the body text.
+// Load a document and type a character into the body text of the second 
view.
 comphelper::LibreOfficeKit::setActive();
 LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
 pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
 ViewCallback aView1;
 pDocument->m_pDocumentClass->registerCallback(pDocument, 
::callback, );
+pDocument->m_pDocumentClass->createView(pDocument);
+pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
+ViewCallback aView2;
+pDocument->m_pDocumentClass->registerCallback(pDocument, 
::callback, );
 pDocument->m_pDocumentClass->postKeyEvent(pDocument, 
LOK_KEYEVENT_KEYINPUT, 'x', 0);
 pDocument->m_pDocumentClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYUP, 
'x', 0);
 Scheduler::ProcessEventsToIdle();
-Rectangle aBodyCursor = aView1.m_aOwnCursor;
+Rectangle aBodyCursor = aView2.m_aOwnCursor;
 
 // Now insert a comment and make sure that the comment's cursor is shown,
 // not the body text's one.
+aView1.m_aOwnCursor.SetEmpty();
 const int nCtrlAltC = KEY_MOD1 + KEY_MOD2 + 512 + 'c' - 'a';
 pDocument->m_pDocumentClass->postKeyEvent(pDocument, 
LOK_KEYEVENT_KEYINPUT, 'c', nCtrlAltC);
 pDocument->m_pDocumentClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYUP, 
'c', nCtrlAltC);
@@ -1594,7 +1599,13 @@ void DesktopLOKTest::testWriterCommentInsertCursor()
 osl::Thread::wait(std::chrono::seconds(1));
 Scheduler::ProcessEventsToIdle();
 // This failed: the body cursor was shown right after inserting a comment.
-CPPUNIT_ASSERT(aView1.m_aOwnCursor.getX() > aBodyCursor.getX());
+CPPUNIT_ASSERT(aView2.m_aOwnCursor.getX() > aBodyCursor.getX());
+// This failed, the first view's cursor also jumped when the second view
+// inserted the comment.
+CPPUNIT_ASSERT(aView1.m_aOwnCursor.IsEmpty());
+
+mxComponent->dispose();
+mxComponent.clear();
 comphelper::LibreOfficeKit::setActive(false);
 }
 
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx 
b/sw/source/uibase/docvw/PostItMgr.cxx
index c417b91..2b8f5ee 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -731,7 +731,17 @@ void SwPostItMgr::LayoutPostIts()
 bool bTop = 
mpEditWin->PixelToLogic(Point(0,(*i)->VirtualPos().Y())).Y() >= 
(pPage->mPageRect.Top()+aSidebarheight);
 if ( bBottom && bTop )
 {
+// When tiled rendering, make sure that only the
+// view that has the comment focus emits callbacks,
+// so the editing view jumps to the comment, but
+// not the others.
+bool bTiledPainting = mpView->getTiledPainting();
+if (!bTiledPainting)
+// No focus -> disable callbacks.
+
mpView->setTiledPainting(!(*i)->HasChildPathFocus());
 (*i)->ShowNote();
+if (!bTiledPainting)
+mpView->setTiledPainting(bTiledPainting);
 }
 else
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: desktop/qa sw/source

2016-09-26 Thread Miklos Vajna
 desktop/qa/desktop_lib/test_desktop_lib.cxx |   48 +++-
 sw/source/core/crsr/viscrs.cxx  |   10 +
 2 files changed, 56 insertions(+), 2 deletions(-)

New commits:
commit b9cc6653606c829805c6c01b9613a3a25d81c20b
Author: Miklos Vajna 
Date:   Mon Sep 26 14:18:17 2016 +0200

sw lok: fix cursor position after inserting a comment

Make sure SwVisibleCursor::SetPosAndShow() doesn't emit LOK callbacks
till a comment window is active.

Need to invoke the unit test from desktop/, as the sw tests have the
status bar disabled.

Change-Id: Iab26024e9bb4da9c939bbd6cf769ec5c4dcb9a19

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index a7e24fc..3456576 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -32,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -100,6 +101,7 @@ public:
 void testTrackChanges();
 void testRedlineCalc();
 void testPaintPartTile();
+void testWriterCommentInsertCursor();
 
 CPPUNIT_TEST_SUITE(DesktopLOKTest);
 CPPUNIT_TEST(testGetStyles);
@@ -131,6 +133,7 @@ public:
 CPPUNIT_TEST(testTrackChanges);
 CPPUNIT_TEST(testRedlineCalc);
 CPPUNIT_TEST(testPaintPartTile);
+CPPUNIT_TEST(testWriterCommentInsertCursor);
 CPPUNIT_TEST_SUITE_END();
 
 uno::Reference mxComponent;
@@ -1484,6 +1487,7 @@ class ViewCallback
 {
 public:
 bool m_bTilesInvalidated;
+Rectangle m_aOwnCursor;
 
 ViewCallback()
 : m_bTilesInvalidated(false)
@@ -1495,8 +1499,9 @@ public:
 static_cast(pData)->callbackImpl(nType, pPayload);
 }
 
-void callbackImpl(int nType, const char* /*pPayload*/)
+void callbackImpl(int nType, const char* pPayload)
 {
+OString aPayload(pPayload);
 switch (nType)
 {
 case LOK_CALLBACK_INVALIDATE_TILES:
@@ -1504,6 +1509,18 @@ public:
 m_bTilesInvalidated = true;
 }
 break;
+case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
+{
+uno::Sequence aSeq = 
comphelper::string::convertCommaSeparated(OUString::fromUtf8(aPayload));
+if (OString("EMPTY") == pPayload)
+return;
+CPPUNIT_ASSERT_EQUAL(static_cast(4), aSeq.getLength());
+m_aOwnCursor.setX(aSeq[0].toInt32());
+m_aOwnCursor.setY(aSeq[1].toInt32());
+m_aOwnCursor.setWidth(aSeq[2].toInt32());
+m_aOwnCursor.setHeight(aSeq[3].toInt32());
+}
+break;
 }
 }
 };
@@ -1552,6 +1569,35 @@ void DesktopLOKTest::testPaintPartTile()
 mxComponent.clear();
 comphelper::LibreOfficeKit::setActive(false);
 }
+
+void DesktopLOKTest::testWriterCommentInsertCursor()
+{
+// Load a document and type a character into the body text.
+comphelper::LibreOfficeKit::setActive();
+LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
+pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
+ViewCallback aView1;
+pDocument->m_pDocumentClass->registerCallback(pDocument, 
::callback, );
+pDocument->m_pDocumentClass->postKeyEvent(pDocument, 
LOK_KEYEVENT_KEYINPUT, 'x', 0);
+pDocument->m_pDocumentClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYUP, 
'x', 0);
+Scheduler::ProcessEventsToIdle();
+Rectangle aBodyCursor = aView1.m_aOwnCursor;
+
+// Now insert a comment and make sure that the comment's cursor is shown,
+// not the body text's one.
+const int nCtrlAltC = KEY_MOD1 + KEY_MOD2 + 512 + 'c' - 'a';
+pDocument->m_pDocumentClass->postKeyEvent(pDocument, 
LOK_KEYEVENT_KEYINPUT, 'c', nCtrlAltC);
+pDocument->m_pDocumentClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYUP, 
'c', nCtrlAltC);
+Scheduler::ProcessEventsToIdle();
+// Wait for SfxBindings to actually update the state, which updated the
+// cursor as well.
+osl::Thread::wait(std::chrono::seconds(1));
+Scheduler::ProcessEventsToIdle();
+// This failed: the body cursor was shown right after inserting a comment.
+CPPUNIT_ASSERT(aView1.m_aOwnCursor.getX() > aBodyCursor.getX());
+comphelper::LibreOfficeKit::setActive(false);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index 0e848b8..7a886e9 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -59,6 +59,7 @@
 #include 
 #include 
 #include 
+#include 
 
 // Here static members are defined. They will get changed on alteration of the
 // MapMode. This is done so that on ShowCursor the same size does not have to 
be
@@ -182,7 +183,14 @@ void SwVisibleCursor::SetPosAndShow(SfxViewShell* 
pViewShell)
 
 m_aTextCursor.SetPos( aRect.Pos() );
 
-if (comphelper::LibreOfficeKit::isActive())
+