[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - 2 commits - sd/qa sd/source
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Sat May 30 17:33:41 UTC 2020
sd/qa/unit/tiledrendering/LOKitSearchTest.cxx | 263 ++++++++++++++++++++++++++
sd/qa/unit/tiledrendering/data/MixedTest1.odg |binary
sd/qa/unit/tiledrendering/data/MixedTest2.odg |binary
sd/source/ui/view/Outliner.cxx | 2
4 files changed, 264 insertions(+), 1 deletion(-)
New commits:
commit b14f6aaabb010de2f790224977973bcbc2894424
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sat May 30 19:30:44 2020 +0200
Commit: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Sat May 30 19:32:50 2020 +0200
sd: Add another test of searching with mixed objects
This is to make sure that we switch between different objects
during the search correctly.
Change-Id: I18aa5b251cbaadd3a9cb15a04ec1a1e5f267d2e3
diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
index 24037a0780ba..7786bc1f1dae 100644
--- a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
+++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
@@ -56,6 +56,7 @@ public:
void testSearchInPDFNonExisting();
void testSearchInPDF();
void testSearchInMixedObject();
+ void testSearchInMixedObject2();
CPPUNIT_TEST_SUITE(LOKitSearchTest);
CPPUNIT_TEST(testSearch);
@@ -67,6 +68,7 @@ public:
CPPUNIT_TEST(testSearchInPDFNonExisting);
CPPUNIT_TEST(testSearchInPDF);
CPPUNIT_TEST(testSearchInMixedObject);
+ CPPUNIT_TEST(testSearchInMixedObject2);
CPPUNIT_TEST_SUITE_END();
private:
@@ -134,6 +136,15 @@ void lcl_search(const OUString& rKey, bool bFindAll = false)
Scheduler::ProcessEventsToIdle();
}
+SdrObject* lclGetSelectedObject(sd::ViewShell* pViewShell)
+{
+ SdrView* pSdrView = pViewShell->GetView();
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ CPPUNIT_ASSERT_EQUAL(size_t(1), rMarkList.GetMarkCount());
+ SdrObject* pObject = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ return pObject;
+}
+
} // end anonymous namespace
void LOKitSearchTest::testSearch()
@@ -319,6 +330,8 @@ void LOKitSearchTest::testSearchInPDF()
mpCallbackRecorder->m_aSelection[0]);
}
+// Test searching in document with mixed objects.
+// We have 2 objects: 1. Text Object, 2. Graphic Object with PDF
void LOKitSearchTest::testSearchInMixedObject()
{
SdXImpressDocument* pXImpressDocument = createDoc("MixedTest1.odg");
@@ -334,7 +347,7 @@ void LOKitSearchTest::testSearchInMixedObject()
SdPage* pPage = pViewShell->GetActualPage();
CPPUNIT_ASSERT(pPage);
- // Check page hase 2 objects only
+ // Check page has 2 objects only
CPPUNIT_ASSERT_EQUAL(size_t(2), pPage->GetObjCount());
// Check Object 1
@@ -403,6 +416,170 @@ void LOKitSearchTest::testSearchInMixedObject()
mpCallbackRecorder->m_aSearchResultSelection[0]);
}
+// Test searching in document with mixed objects. We have 6 objects.
+void LOKitSearchTest::testSearchInMixedObject2()
+{
+ SdXImpressDocument* pXImpressDocument = createDoc("MixedTest2.odg");
+ sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
+ CPPUNIT_ASSERT(pViewShell);
+ SdDrawDocument* pDocument = pXImpressDocument->GetDocShell()->GetDoc();
+ CPPUNIT_ASSERT(pDocument);
+ mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
+
+ // Check we have one page
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pDocument->GetSdPageCount(PageKind::Standard));
+
+ SdPage* pPage = pViewShell->GetActualPage();
+ CPPUNIT_ASSERT(pPage);
+
+ // Check page has 6 objects only
+ CPPUNIT_ASSERT_EQUAL(size_t(6), pPage->GetObjCount());
+
+ // Check we have the right objects that we expect
+
+ // Check Object 1
+ {
+ SdrObject* pObject = pPage->GetObj(0);
+ CPPUNIT_ASSERT(pObject);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(OBJ_TEXT), pObject->GetObjIdentifier());
+ }
+
+ // Check Object 2
+ {
+ SdrObject* pObject = pPage->GetObj(1);
+ CPPUNIT_ASSERT(pObject);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(OBJ_GRAF), pObject->GetObjIdentifier());
+ SdrGrafObj* pGraphicObject = dynamic_cast<SdrGrafObj*>(pObject);
+ CPPUNIT_ASSERT(pGraphicObject);
+ auto const& pVectorGraphicData = pGraphicObject->GetGraphic().getVectorGraphicData();
+ CPPUNIT_ASSERT(pVectorGraphicData);
+ CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
+ pVectorGraphicData->getVectorGraphicDataType());
+ }
+
+ // Check Object 3
+ {
+ SdrObject* pObject = pPage->GetObj(2);
+ CPPUNIT_ASSERT(pObject);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(OBJ_CUSTOMSHAPE), pObject->GetObjIdentifier());
+ }
+
+ // Check Object 4
+ {
+ SdrObject* pObject = pPage->GetObj(3);
+ CPPUNIT_ASSERT(pObject);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(OBJ_CUSTOMSHAPE), pObject->GetObjIdentifier());
+ }
+
+ // Check Object 5
+ {
+ SdrObject* pObject = pPage->GetObj(4);
+ CPPUNIT_ASSERT(pObject);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(OBJ_GRAF), pObject->GetObjIdentifier());
+ SdrGrafObj* pGraphicObject = dynamic_cast<SdrGrafObj*>(pObject);
+ CPPUNIT_ASSERT(pGraphicObject);
+ auto const& pVectorGraphicData = pGraphicObject->GetGraphic().getVectorGraphicData();
+ CPPUNIT_ASSERT(pVectorGraphicData);
+ CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Svg,
+ pVectorGraphicData->getVectorGraphicDataType());
+ }
+
+ // Check Object 6
+ {
+ SdrObject* pObject = pPage->GetObj(5);
+ CPPUNIT_ASSERT(pObject);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(OBJ_GRAF), pObject->GetObjIdentifier());
+ SdrGrafObj* pGraphicObject = dynamic_cast<SdrGrafObj*>(pObject);
+ CPPUNIT_ASSERT(pGraphicObject);
+ auto const& pVectorGraphicData = pGraphicObject->GetGraphic().getVectorGraphicData();
+ CPPUNIT_ASSERT(pVectorGraphicData);
+ CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
+ pVectorGraphicData->getVectorGraphicDataType());
+ }
+
+ // Search "ABC" which is in all objects (2 times in Object 3)
+
+ // Object 1
+ lcl_search("ABC");
+
+ CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+ CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_nSearchResultCount);
+
+ CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
+ CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
+ CPPUNIT_ASSERT_EQUAL(pPage->GetObj(0), lclGetSelectedObject(pViewShell));
+
+ // Object 2
+ lcl_search("ABC");
+
+ CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+ CPPUNIT_ASSERT_EQUAL(2, mpCallbackRecorder->m_nSearchResultCount);
+
+ CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
+ CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
+ CPPUNIT_ASSERT_EQUAL(pPage->GetObj(1), lclGetSelectedObject(pViewShell));
+
+ // Object 3
+ lcl_search("ABC");
+
+ CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+ CPPUNIT_ASSERT_EQUAL(3, mpCallbackRecorder->m_nSearchResultCount);
+
+ CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
+ CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
+ CPPUNIT_ASSERT_EQUAL(pPage->GetObj(2), lclGetSelectedObject(pViewShell));
+
+ // Object 3 again
+ lcl_search("ABC");
+
+ CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+ CPPUNIT_ASSERT_EQUAL(4, mpCallbackRecorder->m_nSearchResultCount);
+
+ CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
+ CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
+ CPPUNIT_ASSERT_EQUAL(pPage->GetObj(2), lclGetSelectedObject(pViewShell));
+
+ // Object 4
+ lcl_search("ABC");
+
+ CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+ CPPUNIT_ASSERT_EQUAL(5, mpCallbackRecorder->m_nSearchResultCount);
+
+ CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
+ CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
+ CPPUNIT_ASSERT_EQUAL(pPage->GetObj(3), lclGetSelectedObject(pViewShell));
+
+ // Object 5
+ lcl_search("ABC");
+
+ CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+ CPPUNIT_ASSERT_EQUAL(6, mpCallbackRecorder->m_nSearchResultCount);
+
+ CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
+ CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
+ CPPUNIT_ASSERT_EQUAL(pPage->GetObj(4), lclGetSelectedObject(pViewShell));
+
+ // Object 6
+ lcl_search("ABC");
+
+ CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+ CPPUNIT_ASSERT_EQUAL(7, mpCallbackRecorder->m_nSearchResultCount);
+
+ CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
+ CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
+ CPPUNIT_ASSERT_EQUAL(pPage->GetObj(5), lclGetSelectedObject(pViewShell));
+
+ // Loop to Object 1 again
+ lcl_search("ABC");
+
+ CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+ CPPUNIT_ASSERT_EQUAL(8, mpCallbackRecorder->m_nSearchResultCount);
+
+ CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
+ CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
+ CPPUNIT_ASSERT_EQUAL(pPage->GetObj(0), lclGetSelectedObject(pViewShell));
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(LOKitSearchTest);
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/qa/unit/tiledrendering/data/MixedTest2.odg b/sd/qa/unit/tiledrendering/data/MixedTest2.odg
new file mode 100644
index 000000000000..2709707c1ba6
Binary files /dev/null and b/sd/qa/unit/tiledrendering/data/MixedTest2.odg differ
commit 75441b42611689228531bb3f2d6b64de7582f6e6
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sat May 30 15:47:35 2020 +0200
Commit: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Sat May 30 15:47:35 2020 +0200
sd: fix issue when PDF search doesn't send a search result + test
This fixes the issue when PDF search doesn't send the search
result, because of premature exit.
Also add test which reproduces this issue and tests the behavior
of searching in multiple objects.
Change-Id: I3a676eeac36bde88c67e90a49583444b8595a346
diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
index 8d8b11e43fa1..24037a0780ba 100644
--- a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
+++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
@@ -55,6 +55,7 @@ public:
void testDontSearchInMasterPages();
void testSearchInPDFNonExisting();
void testSearchInPDF();
+ void testSearchInMixedObject();
CPPUNIT_TEST_SUITE(LOKitSearchTest);
CPPUNIT_TEST(testSearch);
@@ -65,6 +66,7 @@ public:
CPPUNIT_TEST(testDontSearchInMasterPages);
CPPUNIT_TEST(testSearchInPDFNonExisting);
CPPUNIT_TEST(testSearchInPDF);
+ CPPUNIT_TEST(testSearchInMixedObject);
CPPUNIT_TEST_SUITE_END();
private:
@@ -317,6 +319,90 @@ void LOKitSearchTest::testSearchInPDF()
mpCallbackRecorder->m_aSelection[0]);
}
+void LOKitSearchTest::testSearchInMixedObject()
+{
+ SdXImpressDocument* pXImpressDocument = createDoc("MixedTest1.odg");
+ sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
+ CPPUNIT_ASSERT(pViewShell);
+ SdDrawDocument* pDocument = pXImpressDocument->GetDocShell()->GetDoc();
+ CPPUNIT_ASSERT(pDocument);
+ mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
+
+ // Check we have one page
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pDocument->GetSdPageCount(PageKind::Standard));
+
+ SdPage* pPage = pViewShell->GetActualPage();
+ CPPUNIT_ASSERT(pPage);
+
+ // Check page hase 2 objects only
+ CPPUNIT_ASSERT_EQUAL(size_t(2), pPage->GetObjCount());
+
+ // Check Object 1
+ {
+ SdrObject* pObject = pPage->GetObj(0);
+ CPPUNIT_ASSERT(pObject);
+
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(OBJ_TEXT), pObject->GetObjIdentifier());
+ }
+
+ // Check Object 2
+ {
+ SdrObject* pObject = pPage->GetObj(1);
+ CPPUNIT_ASSERT(pObject);
+
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(OBJ_GRAF), pObject->GetObjIdentifier());
+
+ SdrGrafObj* pGraphicObject = dynamic_cast<SdrGrafObj*>(pObject);
+ CPPUNIT_ASSERT(pGraphicObject);
+
+ Graphic aGraphic = pGraphicObject->GetGraphic();
+ auto const& pVectorGraphicData = aGraphic.getVectorGraphicData();
+ CPPUNIT_ASSERT(pVectorGraphicData);
+
+ CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
+ pVectorGraphicData->getVectorGraphicDataType());
+ }
+
+ // Let's try to search now
+
+ lcl_search("ABC");
+
+ CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+ CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_nSearchResultCount);
+
+ CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
+ CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
+
+ CPPUNIT_ASSERT_EQUAL(OString("3546, 3174, 738, 402"),
+ mpCallbackRecorder->m_aSearchResultSelection[0]);
+
+ // Search next
+
+ lcl_search("ABC");
+
+ CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+ CPPUNIT_ASSERT_EQUAL(2, mpCallbackRecorder->m_nSearchResultCount);
+
+ CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
+ CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
+
+ CPPUNIT_ASSERT_EQUAL(OString("8412, 6385, 519, 174"),
+ mpCallbackRecorder->m_aSearchResultSelection[0]);
+
+ // Search next again - we should get the first object again
+
+ lcl_search("ABC");
+
+ CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+ CPPUNIT_ASSERT_EQUAL(3, mpCallbackRecorder->m_nSearchResultCount);
+
+ CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
+ CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
+
+ CPPUNIT_ASSERT_EQUAL(OString("3546, 3174, 738, 402"),
+ mpCallbackRecorder->m_aSearchResultSelection[0]);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(LOKitSearchTest);
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/qa/unit/tiledrendering/data/MixedTest1.odg b/sd/qa/unit/tiledrendering/data/MixedTest1.odg
new file mode 100644
index 000000000000..db952318c735
Binary files /dev/null and b/sd/qa/unit/tiledrendering/data/MixedTest1.odg differ
diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index a87ece2c8b6e..04c8201389c3 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -883,7 +883,7 @@ bool SdOutliner::SearchAndReplaceOnce(std::vector<sd::SearchSelection>* pSelecti
{
ProvideNextTextObject ();
- if (!mbEndOfSearch)
+ if (!mbEndOfSearch && !mpImpl->mbCurrentIsVectorGraphic)
{
// Remember the current position as the last one with a
// text object.
More information about the Libreoffice-commits
mailing list