[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - desktop/qa sw/source tools/qa tools/source
desktop/qa/desktop_lib/test_desktop_lib.cxx |2 sw/source/core/crsr/crsrsh.cxx | 69 +--- tools/qa/cppunit/test_json_writer.cxx |2 tools/source/misc/json_writer.cxx |2 4 files changed, 36 insertions(+), 39 deletions(-) New commits: commit d46c7bd597e51453ac420db97fd898ed2f3b26bf Author: Noel Grandin AuthorDate: Tue Aug 3 14:42:13 2021 +0200 Commit: Noel Grandin CommitDate: Wed Aug 11 13:22:30 2021 +0200 use tools::Json for cursor messages and tweak the JsonWriter to produce output more like the boost propertytree, to make the cypress tests happier. Change-Id: Ia2062508ae9f14a5f89306042c33884ff300f478 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119936 Tested-by: Jenkins CollaboraOffice Reviewed-by: Noel Grandin diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index d41777c5e77b..9d454752239c 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -2027,7 +2027,7 @@ public: break; case LOK_CALLBACK_TABLE_SELECTED: { -m_bEmptyTableSelection = (std::string(pPayload).compare("{\n}\n") == 0); +m_bEmptyTableSelection = (std::string(pPayload).compare("{ }") == 0); ++m_nTableSelectionCount; } break; diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index fd0e4aef29a8..dd0ca592aabe 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -73,7 +73,7 @@ #include #include #include -#include +#include using namespace com::sun::star; using namespace util; @@ -2044,69 +2044,66 @@ void SwCursorShell::sendLOKCursorUpdates() SwFrame* pCurrentFrame = GetCurrFrame(); SelectionType eType = pShell->GetSelectionType(); -boost::property_tree::ptree aRootTree; +tools::JsonWriter aJsonWriter; if (pCurrentFrame && (eType & SelectionType::Table) && pCurrentFrame->IsInTab()) { const SwRect& rPageRect = pShell->GetAnyCurRect(CurRectType::Page, nullptr); -boost::property_tree::ptree aTableColumns; { +auto columnsNode = aJsonWriter.startNode("columns"); SwTabCols aTabCols; pShell->GetTabCols(aTabCols); const int nColumnOffset = aTabCols.GetLeftMin() + rPageRect.Left(); -aTableColumns.put("left", aTabCols.GetLeft()); -aTableColumns.put("right", aTabCols.GetRight()); -aTableColumns.put("tableOffset", nColumnOffset); +aJsonWriter.put("left", aTabCols.GetLeft()); +aJsonWriter.put("right", aTabCols.GetRight()); +aJsonWriter.put("tableOffset", nColumnOffset); -boost::property_tree::ptree aEntries; -for (size_t i = 0; i < aTabCols.Count(); ++i) { -auto const & rEntry = aTabCols.GetEntry(i); -boost::property_tree::ptree aTableColumnEntry; -aTableColumnEntry.put("position", rEntry.nPos); -aTableColumnEntry.put("min", rEntry.nMin); -aTableColumnEntry.put("max", rEntry.nMax); -aTableColumnEntry.put("hidden", rEntry.bHidden); -aEntries.push_back(std::make_pair("", aTableColumnEntry)); +auto entriesNode = aJsonWriter.startArray("entries"); +for (size_t i = 0; i < aTabCols.Count(); ++i) +{ +auto entryNode = aJsonWriter.startStruct(); +auto const & rEntry = aTabCols.GetEntry(i); +aJsonWriter.put("position", rEntry.nPos); +aJsonWriter.put("min", rEntry.nMin); +aJsonWriter.put("max", rEntry.nMax); +aJsonWriter.put("hidden", rEntry.bHidden); +} } -aTableColumns.push_back(std::make_pair("entries", aEntries)); } -boost::property_tree::ptree aTableRows; { +auto rowsNode = aJsonWriter.startNode("rows"); SwTabCols aTabRows; pShell->GetTabRows(aTabRows); const int nRowOffset = aTabRows.GetLeftMin() + rPageRect.Top(); -aTableRows.put("left", aTabRows.GetLeft()); -aTableRows.put("right", aTabRows.GetRight()); -aTableRows.put("tableOffset", nRowOffset); +aJsonWriter.put("left", aTabRows.GetLeft()); +aJsonWriter.put("right", aTabRows.GetRight()); +aJsonWriter.put("tableOffset", nRowOffset); -boost::property_tree::ptree aEntries; -for (size_t i = 0; i < aTabRows.Count(); ++i) { -auto const & rEntry = aTabRows.GetEntry(i); -boost::property_tree::ptree aTableRowEntry; -aTableRowEntry.put("position", rEntry
[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - desktop/qa
desktop/qa/data/table-selection.odt |binary desktop/qa/desktop_lib/test_desktop_lib.cxx | 121 2 files changed, 121 insertions(+) New commits: commit 658c95f7bc3ed3c62dc802d1b9bcc026462f7340 Author: Dennis Francis AuthorDate: Mon Jun 28 13:32:48 2021 +0530 Commit: Miklos Vajna CommitDate: Fri Jul 9 09:32:32 2021 +0200 lok-desktop: unit tests for LOK_CALLBACK_TABLE_SELECTED Change-Id: I4e07ffc6f8eebbbee284d19cd9c77df13dddff3a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118002 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/desktop/qa/data/table-selection.odt b/desktop/qa/data/table-selection.odt new file mode 100644 index ..c19f8c79fc3a Binary files /dev/null and b/desktop/qa/data/table-selection.odt differ diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 28e9ef4ae612..d41777c5e77b 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -226,6 +226,8 @@ public: void testMetricField(); void testMultiDocuments(); void testJumpCursor(); +void testNoDuplicateTableSelection(); +void testMultiViewTableSelection(); void testABI(); CPPUNIT_TEST_SUITE(DesktopLOKTest); @@ -289,6 +291,8 @@ public: CPPUNIT_TEST(testMetricField); CPPUNIT_TEST(testMultiDocuments); CPPUNIT_TEST(testJumpCursor); +CPPUNIT_TEST(testNoDuplicateTableSelection); +CPPUNIT_TEST(testMultiViewTableSelection); CPPUNIT_TEST(testABI); CPPUNIT_TEST_SUITE_END(); @@ -1946,6 +1950,8 @@ class ViewCallback int mnView; public: OString m_aCellFormula; +int m_nTableSelectionCount; +bool m_bEmptyTableSelection; bool m_bTilesInvalidated; bool m_bZeroCursor; tools::Rectangle m_aOwnCursor; @@ -1954,6 +1960,8 @@ public: ViewCallback(LibLODocument_Impl* pDocument) : mpDocument(pDocument), + m_nTableSelectionCount(0), + m_bEmptyTableSelection(false), m_bTilesInvalidated(false), m_bZeroCursor(false) { @@ -2017,6 +2025,12 @@ public: m_aCellFormula = aPayload; } break; +case LOK_CALLBACK_TABLE_SELECTED: +{ +m_bEmptyTableSelection = (std::string(pPayload).compare("{\n}\n") == 0); +++m_nTableSelectionCount; +} +break; } } }; @@ -3089,6 +3103,113 @@ void DesktopLOKTest::testJumpCursor() comphelper::LibreOfficeKit::setTiledAnnotations(true); } +static void lcl_repeatKeyStroke(LibLODocument_Impl *pDocument, int nCharCode, int nKeyCode, size_t nCount) +{ +for (size_t nCtr = 0; nCtr < nCount; ++nCtr) +{ +pDocument->m_pDocumentClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, nCharCode, nKeyCode); +pDocument->m_pDocumentClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYUP, nCharCode, nKeyCode); +} +} + +void DesktopLOKTest::testNoDuplicateTableSelection() +{ +comphelper::LibreOfficeKit::setActive(); +LibLODocument_Impl* pDocument = loadDoc("table-selection.odt"); + +// Create view 1. +pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}"); +ViewCallback aView1(pDocument); + +lcl_repeatKeyStroke(pDocument, 0, KEY_DOWN, 1); +Scheduler::ProcessEventsToIdle(); +CPPUNIT_ASSERT_EQUAL(1, aView1.m_nTableSelectionCount); +CPPUNIT_ASSERT(aView1.m_bEmptyTableSelection); + +aView1.m_nTableSelectionCount = 0; +// Go to Table1. +lcl_repeatKeyStroke(pDocument, 0, KEY_DOWN, 1); +Scheduler::ProcessEventsToIdle(); +CPPUNIT_ASSERT_EQUAL(1, aView1.m_nTableSelectionCount); +CPPUNIT_ASSERT(!aView1.m_bEmptyTableSelection); + +aView1.m_nTableSelectionCount = 0; +// Move to the last row in Table1. +lcl_repeatKeyStroke(pDocument, 0, KEY_DOWN, 2); +Scheduler::ProcessEventsToIdle(); +CPPUNIT_ASSERT_EQUAL(0, aView1.m_nTableSelectionCount); + +// Go outside Table1. +lcl_repeatKeyStroke(pDocument, 0, KEY_DOWN, 1); +Scheduler::ProcessEventsToIdle(); +CPPUNIT_ASSERT_EQUAL(1, aView1.m_nTableSelectionCount); +CPPUNIT_ASSERT(aView1.m_bEmptyTableSelection); +} + +void DesktopLOKTest::testMultiViewTableSelection() +{ +comphelper::LibreOfficeKit::setActive(); +LibLODocument_Impl* pDocument = loadDoc("table-selection.odt"); + +// Create view 1. +pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}"); +ViewCallback aView1(pDocument); +int nView1 = pDocument->m_pDocumentClass->getView(pDocument); + +// Create view 2. +pDocument->m_pDocumentClass->createView(pDocument); +pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}"); +ViewCallback aView2(pDocument); +int nView2 = pDocument->m_pDocumentClass->getView(pDocument); + +// switch to view 1. +pDocument->m_pDocumentClass->setView(pDocumen
[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - desktop/qa sw/source
desktop/qa/desktop_lib/test_desktop_lib.cxx | 36 sw/source/uibase/docvw/AnnotationWin2.cxx |5 --- 2 files changed, 41 deletions(-) New commits: commit 7a9b6456227c2a54b0b23cfc18679883b638e969 Author: Henry Castro AuthorDate: Tue Feb 2 11:57:23 2021 -0400 Commit: Andras Timar CommitDate: Tue Feb 2 20:02:23 2021 +0100 lok: remove annotation viewshell notifier Unfortunately the Annotation window sends cursor position to client side and it causes horrible effects like scrolling document due to different coordinates with the document. This patch will disable any notification to client side, also it removes a unit test related to check annotation cursor position. Change-Id: Ib432ef020c48bb1a9c82acc43ffccdb4230589c8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110328 Tested-by: Jenkins CollaboraOffice Reviewed-by: Andras Timar diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 4f708dfe76c5..af9b93620351 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -199,7 +199,6 @@ public: void testTrackChanges(); void testRedlineCalc(); void testPaintPartTile(); -void testWriterCommentInsertCursor(); #if HAVE_MORE_FONTS void testGetFontSubset(); #endif @@ -261,7 +260,6 @@ public: CPPUNIT_TEST(testTrackChanges); CPPUNIT_TEST(testRedlineCalc); CPPUNIT_TEST(testPaintPartTile); -CPPUNIT_TEST(testWriterCommentInsertCursor); #if HAVE_MORE_FONTS CPPUNIT_TEST(testGetFontSubset); #endif @@ -2064,40 +2062,6 @@ void DesktopLOKTest::testPaintPartTile() //CPPUNIT_ASSERT(aView1.m_bTilesInvalidated); } -void DesktopLOKTest::testWriterCommentInsertCursor() -{ -// Load a document and type a character into the body text of the second view. -LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); -pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}"); -ViewCallback aView1(pDocument); -pDocument->m_pDocumentClass->createView(pDocument); -pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}"); -ViewCallback aView2(pDocument); -pDocument->m_pDocumentClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'x', 0); -pDocument->m_pDocumentClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYUP, 'x', 0); -Scheduler::ProcessEventsToIdle(); -tools::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); -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(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()); - -Scheduler::ProcessEventsToIdle(); -} - #if HAVE_MORE_FONTS void DesktopLOKTest::testGetFontSubset() { diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx b/sw/source/uibase/docvw/AnnotationWin2.cxx index 63cab37214b2..b3d976ddf850 100644 --- a/sw/source/uibase/docvw/AnnotationWin2.cxx +++ b/sw/source/uibase/docvw/AnnotationWin2.cxx @@ -934,11 +934,6 @@ void SwAnnotationWin::DoResize() mpOutliner->SetPaperSize( PixelToLogic( Size(aWidth,aHeight) ) ) ; -if (comphelper::LibreOfficeKit::isActive() && !mpOutlinerView->GetViewShell()) -{ -mpOutlinerView->RegisterViewShell(&mrView); -} - if (!mpVScrollbar->IsVisible()) { // if we do not have a scrollbar anymore, we want to see the complete text mpOutlinerView->SetVisArea( PixelToLogic( tools::Rectangle(0,0,aWidth,aHeight) ) ); ___ 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-6.4' - desktop/qa
desktop/qa/desktop_lib/test_desktop_lib.cxx | 39 +++- 1 file changed, 38 insertions(+), 1 deletion(-) New commits: commit 08d45119cfb875fa8a5c03d6e946a47f0f680932 Author: Henry Castro AuthorDate: Fri Jan 15 16:13:29 2021 -0400 Commit: Jan Holesovsky CommitDate: Wed Jan 20 14:55:25 2021 +0100 lok: unit test incorrect cursor position Test to not send client side cursor position (0,0) due to: mpOutlinerView->SetOutputArea( PixelToLogic( tools::Rectangle(0,0,1,1) ) ); Change-Id: Ib5cd7f1c0c45073c5d2039e8b889d3a6fd7ef70c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109417 Tested-by: Jenkins CollaboraOffice Reviewed-by: Jan Holesovsky diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 6fc8affd77eb..4f708dfe76c5 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -226,6 +226,7 @@ public: void testControlState(); void testMetricField(); void testMultiDocuments(); +void testJumpCursor(); void testABI(); CPPUNIT_TEST_SUITE(DesktopLOKTest); @@ -289,6 +290,7 @@ public: CPPUNIT_TEST(testControlState); CPPUNIT_TEST(testMetricField); CPPUNIT_TEST(testMultiDocuments); +CPPUNIT_TEST(testJumpCursor); CPPUNIT_TEST(testABI); CPPUNIT_TEST_SUITE_END(); @@ -1947,13 +1949,15 @@ class ViewCallback public: OString m_aCellFormula; bool m_bTilesInvalidated; +bool m_bZeroCursor; tools::Rectangle m_aOwnCursor; boost::property_tree::ptree m_aCommentCallbackResult; boost::property_tree::ptree m_aCallbackWindowResult; ViewCallback(LibLODocument_Impl* pDocument) : mpDocument(pDocument), - m_bTilesInvalidated(false) + m_bTilesInvalidated(false), + m_bZeroCursor(false) { mnView = SfxLokHelper::getView(); mpDocument->m_pDocumentClass->registerCallback(pDocument, &ViewCallback::callback, this); @@ -1990,6 +1994,9 @@ public: m_aOwnCursor.setY(aSeq[1].toInt32()); m_aOwnCursor.setWidth(aSeq[2].toInt32()); m_aOwnCursor.setHeight(aSeq[3].toInt32()); + +if (m_aOwnCursor.getX() == 0 && m_aOwnCursor.getY() == 0) +m_bZeroCursor = true; } break; case LOK_CALLBACK_COMMENT: @@ -3088,6 +3095,36 @@ void DesktopLOKTest::testMultiDocuments() } } +void DesktopLOKTest::testJumpCursor() +{ +comphelper::LibreOfficeKit::setTiledAnnotations(false); + +LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); +pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}"); + +pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'B', 0); +pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'o', 0); +pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'l', 0); +pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'i', 0); +pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'v', 0); +pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'i', 0); +pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'a', 0); +pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 0, com::sun::star::awt::Key::ESCAPE); +Scheduler::ProcessEventsToIdle(); + +// There is a cursor jump to (0, 0) due to +// mpOutlinerView->SetOutputArea( PixelToLogic( tools::Rectangle(0,0,1,1) ) ); +// when creating a comment +ViewCallback aView1(pDocument); + +pDocument->pClass->postUnoCommand(pDocument, ".uno:InsertAnnotation", nullptr, true); +Scheduler::ProcessEventsToIdle(); + +CPPUNIT_ASSERT(!aView1.m_bZeroCursor); + +comphelper::LibreOfficeKit::setTiledAnnotations(true); +} + namespace { constexpr size_t classOffset(int i) ___ 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-6.4' - desktop/qa
desktop/qa/desktop_lib/test_desktop_lib.cxx | 181 ++-- 1 file changed, 92 insertions(+), 89 deletions(-) New commits: commit ecda8127d8c3c3676a5af6e3d6b3dce243366898 Author: Tor Lillqvist AuthorDate: Thu Sep 3 21:51:16 2020 +0300 Commit: Tor Lillqvist CommitDate: Fri Sep 4 08:45:41 2020 +0200 Test also that loading more documents after closing all open ones works Just run the code in DesktopLOKTest::testMultiDocuments() in a short loop. Sadly this did not find the actual problem that is present in the code, though. (A follow-up commit will fix that problem, and then I might also change this unit test so that it would have found that problem.) Change-Id: Ie847d04e77ea3d712820413fa0f00521207eb7de Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102018 Tested-by: Jenkins CollaboraOffice Reviewed-by: Tor Lillqvist diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index f448965c02d7..6fc8affd77eb 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -2994,95 +2994,98 @@ void DesktopLOKTest::testSpellcheckerMultiView() void DesktopLOKTest::testMultiDocuments() { -// Load a document. -uno::Reference xComponent1; -std::unique_ptr document1; -std::tie(document1, xComponent1) = loadDocImpl("blank_text.odt"); -LibLODocument_Impl* pDocument1 = document1.get(); -CPPUNIT_ASSERT_EQUAL(1, pDocument1->m_pDocumentClass->getViewsCount(pDocument1)); -const int nDocId1 = pDocument1->mnDocumentId; - -const int nDoc1View0 = pDocument1->m_pDocumentClass->getView(pDocument1); -CPPUNIT_ASSERT_EQUAL(nDocId1, SfxLokHelper::getDocumentIdOfView(nDoc1View0)); -const int nDoc1View1 = pDocument1->m_pDocumentClass->createView(pDocument1); -CPPUNIT_ASSERT_EQUAL(nDoc1View1, pDocument1->m_pDocumentClass->getView(pDocument1)); -CPPUNIT_ASSERT_EQUAL(nDocId1, SfxLokHelper::getDocumentIdOfView(nDoc1View1)); -CPPUNIT_ASSERT_EQUAL(2, pDocument1->m_pDocumentClass->getViewsCount(pDocument1)); - -// Validate the views of document 1. -std::vector aViewIdsDoc1(2); -CPPUNIT_ASSERT(pDocument1->m_pDocumentClass->getViewIds(pDocument1, aViewIdsDoc1.data(), aViewIdsDoc1.size())); -CPPUNIT_ASSERT_EQUAL(nDoc1View0, aViewIdsDoc1[0]); -CPPUNIT_ASSERT_EQUAL(nDoc1View1, aViewIdsDoc1[1]); - -CPPUNIT_ASSERT_EQUAL(nDoc1View1, pDocument1->m_pDocumentClass->getView(pDocument1)); -CPPUNIT_ASSERT_EQUAL(nDocId1, SfxLokHelper::getDocumentIdOfView(nDoc1View1)); -pDocument1->m_pDocumentClass->setView(pDocument1, nDoc1View0); -CPPUNIT_ASSERT_EQUAL(nDoc1View0, pDocument1->m_pDocumentClass->getView(pDocument1)); -CPPUNIT_ASSERT_EQUAL(nDocId1, SfxLokHelper::getDocumentIdOfView(nDoc1View0)); -pDocument1->m_pDocumentClass->setView(pDocument1, nDoc1View1); -CPPUNIT_ASSERT_EQUAL(nDoc1View1, pDocument1->m_pDocumentClass->getView(pDocument1)); -CPPUNIT_ASSERT_EQUAL(nDocId1, SfxLokHelper::getDocumentIdOfView(nDoc1View1)); -CPPUNIT_ASSERT_EQUAL(2, pDocument1->m_pDocumentClass->getViewsCount(pDocument1)); - -// Load another document. -uno::Reference xComponent2; -std::unique_ptr document2; -std::tie(document2, xComponent2) = loadDocImpl("blank_presentation.odp"); -LibLODocument_Impl* pDocument2 = document2.get(); -CPPUNIT_ASSERT_EQUAL(1, pDocument2->m_pDocumentClass->getViewsCount(pDocument2)); -const int nDocId2 = pDocument2->mnDocumentId; - -const int nDoc2View0 = pDocument2->m_pDocumentClass->getView(pDocument2); -CPPUNIT_ASSERT_EQUAL(nDocId2, SfxLokHelper::getDocumentIdOfView(nDoc2View0)); -const int nDoc2View1 = pDocument2->m_pDocumentClass->createView(pDocument2); -CPPUNIT_ASSERT_EQUAL(nDoc2View1, pDocument2->m_pDocumentClass->getView(pDocument2)); -CPPUNIT_ASSERT_EQUAL(nDocId2, SfxLokHelper::getDocumentIdOfView(nDoc2View1)); -CPPUNIT_ASSERT_EQUAL(2, pDocument2->m_pDocumentClass->getViewsCount(pDocument2)); - -// Validate the views of document 2. -std::vector aViewIdsDoc2(2); -CPPUNIT_ASSERT(pDocument2->m_pDocumentClass->getViewIds(pDocument2, aViewIdsDoc2.data(), aViewIdsDoc2.size())); -CPPUNIT_ASSERT_EQUAL(nDoc2View0, aViewIdsDoc2[0]); -CPPUNIT_ASSERT_EQUAL(nDoc2View1, aViewIdsDoc2[1]); - -CPPUNIT_ASSERT_EQUAL(nDoc2View1, pDocument2->m_pDocumentClass->getView(pDocument2)); -CPPUNIT_ASSERT_EQUAL(nDocId2, SfxLokHelper::getDocumentIdOfView(nDoc2View1)); -pDocument2->m_pDocumentClass->setView(pDocument2, nDoc2View0); -CPPUNIT_ASSERT_EQUAL(nDoc2View0, pDocument2->m_pDocumentClass->getView(pDocument2)); -CPPUNIT_ASSERT_EQUAL(nDocId2, SfxLokHelper::getDocumentIdOfView(nDoc2View0)); -pDocument2->m_pDocumentClass->setView(pDocument2, nDoc2View1); -CPPUNIT_ASSERT_EQUAL(nDoc2View1, pDocument2->m_pDocumentClass->getView(pDocument2)); -CPPUNIT_
[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - desktop/qa
desktop/qa/desktop_lib/test_desktop_lib.cxx | 112 +--- 1 file changed, 86 insertions(+), 26 deletions(-) New commits: commit 347e0d5336ccd881356c89ecc5d8186dd9b773ad Author: Ashod Nakashian AuthorDate: Sun Aug 2 12:41:19 2020 -0400 Commit: Ashod Nakashian CommitDate: Mon Aug 10 04:50:20 2020 +0200 DesktopLOKTest: cleanup Refactor the handling of document loading and unloading and cleanup to allow more flexibility when loading multiple documents and for manual destruction. Also, correctly set the document type when loading, which was defaulted to TEXT even when loading spreadsheet and presentation documents. Minor misc cleanup such as dangling semicolons and unregistering the callback twice. Change-Id: Ia244aafd526d60f73c46e99fb8c7e63f63b0a8f2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99974 Tested-by: Jenkins CollaboraOffice Reviewed-by: Ashod Nakashian diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 0123037ec75d..864041b71d49 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -59,9 +59,34 @@ #include #include +#include + using namespace com::sun::star; using namespace desktop; +static LibreOfficeKitDocumentType getDocumentTypeFromName(const char* pName) +{ +CPPUNIT_ASSERT_MESSAGE("Document name must be valid.", pName != nullptr); + +const std::string name(pName); +CPPUNIT_ASSERT_MESSAGE("Document name must include extension.", name.size() > 4); + +const auto it = name.rfind('.'); +if (it != name.npos) +{ +const std::string ext = name.substr(it); + +if (ext == ".ods") +return LOK_DOCTYPE_SPREADSHEET; + +if (ext == ".odp") +return LOK_DOCTYPE_PRESENTATION; +} + +CPPUNIT_ASSERT_MESSAGE("Document name must include extension.", it != name.npos); +return LOK_DOCTYPE_TEXT; +} + class DesktopLOKTest : public UnoApiTest { class Resetter @@ -106,22 +131,39 @@ public: UnoApiTest::setUp(); mxDesktop.set(frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory(; SfxApplication::GetOrCreate(); -}; +} virtual void tearDown() override { -if (m_pDocument) -m_pDocument->pClass->registerCallback(m_pDocument.get(), nullptr, nullptr); closeDoc(); UnoApiTest::tearDown(); comphelper::LibreOfficeKit::setActive(false); -}; +} + +std::pair, uno::Reference> +loadDocImpl(const char* pName, LibreOfficeKitDocumentType eType); + +std::pair, uno::Reference> +loadDocImpl(const char* pName) +{ +return loadDocImpl(pName, getDocumentTypeFromName(pName)); +} + +std::pair, uno::Reference> +loadDocUrlImpl(const OUString& rFileURL, LibreOfficeKitDocumentType eType); LibLODocument_Impl* loadDocUrl(const OUString& rFileURL, LibreOfficeKitDocumentType eType); -LibLODocument_Impl* loadDoc(const char* pName, LibreOfficeKitDocumentType eType = LOK_DOCTYPE_TEXT); -void closeDoc(); +LibLODocument_Impl* loadDoc(const char* pName, LibreOfficeKitDocumentType eType); +LibLODocument_Impl* loadDoc(const char* pName) +{ +return loadDoc(pName, getDocumentTypeFromName(pName)); +} + +void closeDoc(std::unique_ptr& loDocument, + uno::Reference& xComponent); +void closeDoc() { closeDoc(m_pDocument, mxComponent); } static void callback(int nType, const char* pPayload, void* pData); void callbackImpl(int nType, const char* pPayload); @@ -287,7 +329,8 @@ static Control* GetFocusControl(vcl::Window const * pParent) return nullptr; } -LibLODocument_Impl* DesktopLOKTest::loadDocUrl(const OUString& rFileURL, LibreOfficeKitDocumentType eType) +std::pair, uno::Reference> +DesktopLOKTest::loadDocUrlImpl(const OUString& rFileURL, LibreOfficeKitDocumentType eType) { OUString aService; switch (eType) @@ -305,28 +348,48 @@ LibLODocument_Impl* DesktopLOKTest::loadDocUrl(const OUString& rFileURL, LibreOf CPPUNIT_ASSERT(false); break; } -mxComponent = loadFromDesktop(rFileURL, aService); -if (!mxComponent.is()) -{ -CPPUNIT_ASSERT(false); -} -m_pDocument.reset(new LibLODocument_Impl(mxComponent)); -return m_pDocument.get(); + +uno::Reference xComponent = loadFromDesktop(rFileURL, aService); +CPPUNIT_ASSERT(xComponent.is()); + +std::unique_ptr pDocument(new LibLODocument_Impl(xComponent)); + +return std::make_pair(std::move(pDocument), xComponent); } -LibLODocument_Impl* DesktopLOKTest::loadDoc(const char* pName, LibreOfficeKitDocumentType eType) +std::pair, uno::Reference> +DesktopLOKTest::loadDocImpl(const char* pName, LibreOfficeKitDocumentType eType) { OUString aFileURL;
[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - desktop/qa
desktop/qa/desktop_lib/test_desktop_lib.cxx | 35 1 file changed, 35 insertions(+) New commits: commit 0b5527daf908d485153ff5c2c0d4d8bd34644921 Author: Henry Castro AuthorDate: Thu May 7 16:47:36 2020 -0400 Commit: Henry Castro CommitDate: Thu May 21 00:46:46 2020 +0200 lok: unit test for metric field or formatted field control Change-Id: I0a3efef85ff889c4214ab326d1de96a4acd207a8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93779 Tested-by: Jenkins CollaboraOffice Reviewed-by: Henry Castro Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94527 Tested-by: Henry Castro diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 6f68380daea7..35314f0da0f3 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -27,10 +27,13 @@ #include #include #include +#include #include #include #include #include +#include +#include #include #include #include @@ -151,6 +154,7 @@ public: void testDialogInput(); void testCalcSaveAs(); void testControlState(); +void testMetricField(); void testABI(); CPPUNIT_TEST_SUITE(DesktopLOKTest); @@ -210,6 +214,7 @@ public: CPPUNIT_TEST(testDialogInput); CPPUNIT_TEST(testCalcSaveAs); CPPUNIT_TEST(testControlState); +CPPUNIT_TEST(testMetricField); CPPUNIT_TEST(testABI); CPPUNIT_TEST_SUITE_END(); @@ -2748,6 +2753,36 @@ void DesktopLOKTest::testControlState() CPPUNIT_ASSERT(!aState.empty()); } +void DesktopLOKTest::testMetricField() +{ +LibLODocument_Impl* pDocument = loadDoc("search.ods"); +pDocument->pClass->postUnoCommand(pDocument, ".uno:StarShapes", nullptr, false); +Scheduler::ProcessEventsToIdle(); + +SfxViewShell* pViewShell = SfxViewShell::Current(); +CPPUNIT_ASSERT(pViewShell); + +SfxViewFrame* pViewFrame = pViewShell->GetViewFrame(); +CPPUNIT_ASSERT(pViewFrame); + +SfxChildWindow* pSideBar = pViewFrame->GetChildWindow(SID_SIDEBAR); +CPPUNIT_ASSERT(pSideBar); + +vcl::Window* pWin = pSideBar->GetWindow(); +CPPUNIT_ASSERT(pWin); + +WindowUIObject aWinUI(pWin); +std::unique_ptr pUIWin(aWinUI.get_child("selectwidth")); +CPPUNIT_ASSERT(pUIWin.get()); + +StringMap aMap; +aMap["VALUE"] = "75.06"; +pUIWin->execute("VALUE", aMap); + +StringMap aRet = pUIWin->get_state(); +CPPUNIT_ASSERT_EQUAL(aMap["VALUE"], aRet["Value"]); +} + namespace { constexpr size_t classOffset(int i) ___ 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-6.4' - desktop/qa
desktop/qa/desktop_lib/test_desktop_lib.cxx | 16 1 file changed, 16 insertions(+) New commits: commit 400fc54e4288bfef1e3020f338df74fb5ae55e5b Author: Henry Castro AuthorDate: Mon Mar 30 19:38:31 2020 -0400 Commit: Henry Castro CommitDate: Thu May 21 00:41:59 2020 +0200 lok: unit test GetControlState Change-Id: I7187fe787aaed33d85ad76b612725741e9f586d9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91383 Tested-by: Jenkins CollaboraOffice Reviewed-by: Henry Castro Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91579 Tested-by: Jenkins Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94518 Tested-by: Henry Castro diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 9ce44aacafc7..6f68380daea7 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -53,6 +53,7 @@ #include #include +#include using namespace com::sun::star; using namespace desktop; @@ -149,6 +150,7 @@ public: void testShowHideDialog(); void testDialogInput(); void testCalcSaveAs(); +void testControlState(); void testABI(); CPPUNIT_TEST_SUITE(DesktopLOKTest); @@ -207,6 +209,7 @@ public: CPPUNIT_TEST(testShowHideDialog); CPPUNIT_TEST(testDialogInput); CPPUNIT_TEST(testCalcSaveAs); +CPPUNIT_TEST(testControlState); CPPUNIT_TEST(testABI); CPPUNIT_TEST_SUITE_END(); @@ -2732,6 +2735,19 @@ void DesktopLOKTest::testCalcSaveAs() CPPUNIT_ASSERT_EQUAL(OString("X"), aView.m_aCellFormula); } +void DesktopLOKTest::testControlState() +{ +LibLODocument_Impl* pDocument = loadDoc("search.ods"); +pDocument->pClass->postUnoCommand(pDocument, ".uno:StarShapes", nullptr, false); +Scheduler::ProcessEventsToIdle(); + +boost::property_tree::ptree aState; +SfxViewShell* pViewShell = SfxViewShell::Current(); +pViewShell->GetViewFrame()->GetBindings().Update(); + pViewShell->GetViewFrame()->GetBindings().QueryControlState(SID_ATTR_TRANSFORM_WIDTH, aState); +CPPUNIT_ASSERT(!aState.empty()); +} + namespace { constexpr size_t classOffset(int i) ___ 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-6.4' - desktop/qa desktop/source include/vcl sc/inc sc/source
desktop/qa/desktop_lib/test_desktop_lib.cxx |2 - desktop/source/lib/init.cxx | 40 +--- include/vcl/ITiledRenderable.hxx|8 +--- sc/inc/docuno.hxx |5 -- sc/source/ui/inc/gridwin.hxx|9 +--- sc/source/ui/inc/viewdata.hxx |4 ++ sc/source/ui/unoobj/docuno.cxx |5 +- sc/source/ui/view/gridwin.cxx | 54 +--- sc/source/ui/view/viewdata.cxx | 31 9 files changed, 49 insertions(+), 109 deletions(-) New commits: commit b703ac70fca000dc9e45f2faad33996305ca8ecf Author: Michael Meeks AuthorDate: Tue Dec 3 10:55:35 2019 + Commit: Tor Lillqvist CommitDate: Mon May 18 00:05:54 2020 +0200 lok: cleanup getCellCursor Switching the zoom is no longer necessary - we now have a known and fixed zoom per view now (as the core has), that saves some complexity. Change-Id: I14c952ca1e06fae016faa8b6ee07115c56312ed6 Reviewed-on: https://gerrit.libreoffice.org/84372 Reviewed-by: Michael Meeks Tested-by: Michael Meeks Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94392 Tested-by: Tor Lillqvist Reviewed-by: Tor Lillqvist diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index ad75b751a190..9ce44aacafc7 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -825,7 +825,7 @@ void DesktopLOKTest::testCellCursor() OString aRectangle(aTree.get("commandValues").c_str()); // cell cursor geometry + col + row -CPPUNIT_ASSERT_EQUAL(OString("0, 0, 1279, 255, 0, 0"), aRectangle); +CPPUNIT_ASSERT_EQUAL(OString("0, 0, 1274, 254, 0, 0"), aRectangle); } void DesktopLOKTest::testCommandResult() diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 1fd899a61829..c08baee81358 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -4848,44 +4848,8 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo SetLastExceptionMsg("Document doesn't support tiled rendering"); return nullptr; } - -// Command has parameters. -int nOutputWidth = 0; -int nOutputHeight = 0; -long nTileWidth = 0; -long nTileHeight = 0; -if (aCommand.getLength() > aCellCursor.getLength()) -{ -OString aArguments = aCommand.copy(aCellCursor.getLength() + 1); -sal_Int32 nParamIndex = 0; -do -{ -OString aParamToken = aArguments.getToken(0, '&', nParamIndex); -sal_Int32 nIndex = 0; -OString aKey; -OString aValue; -do -{ -OString aToken = aParamToken.getToken(0, '=', nIndex); -if (!aKey.getLength()) -aKey = aToken; -else -aValue = aToken; -} -while (nIndex >= 0); -if (aKey == "outputWidth") -nOutputWidth = aValue.toInt32(); -else if (aKey == "outputHeight") -nOutputHeight = aValue.toInt32(); -else if (aKey == "tileWidth") -nTileWidth = aValue.toInt64(); -else if (aKey == "tileHeight") -nTileHeight = aValue.toInt64(); -} -while (nParamIndex >= 0); -} - -return convertOString(pDoc->getCellCursor(nOutputWidth, nOutputHeight, nTileWidth, nTileHeight)); +// Ignore command's deprecated parameters. +return convertOString(pDoc->getCellCursor()); } else if (aCommand.startsWith(aFontSubset)) { diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx index e26c1387b6e1..163be5f55213 100644 --- a/include/vcl/ITiledRenderable.hxx +++ b/include/vcl/ITiledRenderable.hxx @@ -175,13 +175,11 @@ public: } /** - * Get position and size of cell cursor in Calc. + * Get position and size of cell cursor in Calc - as JSON in the + * current' views' co-ordinate system. * (This could maybe also be used for tables in Writer/Impress in future?) */ -virtual OString getCellCursor(int /*nOutputWidth*/, - int /*nOutputHeight*/, - long /*nTileWidth*/, - long /*nTileHeight*/) +virtual OString getCellCursor() { return OString(); } diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx index 46461142af3d..f2adcda7a80f 100644 --- a/sc/inc/docuno.hxx +++ b/sc/inc/docuno.hxx @@ -367,10 +367,7 @@ public: virtual OUString getRowColumnHeaders(const tools::Rectangle& rRectangle) o