diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2021-09-08 16:34:42 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-09-11 02:17:30 +0200 |
commit | e3dae10c0b55aafa753f44e4b1c45bf93387f6c6 (patch) | |
tree | 482611a117736c3f88aaf9712914a2aec8efd06f /desktop | |
parent | aa093b7a16d5483310146896127952bc8279260e (diff) |
indexing: fix correct size and pos. for shapes + more tests
Determining the position and size of the shapes (SdrObjects) was
wrong as the assumption was the values are in Hmm but were in
twips. Added some more tests that check rendering of SdrObjects.
Change-Id: I6ef9287892d1774a1243118a5c97f58384bcfd68
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121801
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
(cherry picked from commit 160b6db92cc94f2ec2447ae0e9c60c8c9dcf3bad)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121818
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/qa/data/SearchIndexResultShapeTest.odt | bin | 0 -> 9046 bytes | |||
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 53 |
2 files changed, 50 insertions, 3 deletions
diff --git a/desktop/qa/data/SearchIndexResultShapeTest.odt b/desktop/qa/data/SearchIndexResultShapeTest.odt Binary files differnew file mode 100644 index 000000000000..4298eb8ad06e --- /dev/null +++ b/desktop/qa/data/SearchIndexResultShapeTest.odt diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index f19615e37fb8..4f0014f6e0ad 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -198,7 +198,8 @@ public: void testMetricField(); void testMultiDocuments(); void testJumpCursor(); - void testRenderSearchResult(); + void testRenderSearchResult_WriterNode(); + void testRenderSearchResult_CommonNode(); void testNoDuplicateTableSelection(); void testMultiViewTableSelection(); void testABI(); @@ -264,7 +265,8 @@ public: CPPUNIT_TEST(testMetricField); CPPUNIT_TEST(testMultiDocuments); CPPUNIT_TEST(testJumpCursor); - CPPUNIT_TEST(testRenderSearchResult); + CPPUNIT_TEST(testRenderSearchResult_WriterNode); + CPPUNIT_TEST(testRenderSearchResult_CommonNode); CPPUNIT_TEST(testNoDuplicateTableSelection); CPPUNIT_TEST(testMultiViewTableSelection); CPPUNIT_TEST(testABI); @@ -3096,7 +3098,7 @@ void DesktopLOKTest::testJumpCursor() comphelper::LibreOfficeKit::setTiledAnnotations(true); } -void DesktopLOKTest::testRenderSearchResult() +void DesktopLOKTest::testRenderSearchResult_WriterNode() { constexpr const bool bDumpBitmap = false; @@ -3141,6 +3143,51 @@ void DesktopLOKTest::testRenderSearchResult() std::free(pBuffer); } +void DesktopLOKTest::testRenderSearchResult_CommonNode() +{ + constexpr const bool bDumpBitmap = false; + + LibLODocument_Impl* pDocument = loadDoc("SearchIndexResultShapeTest.odt"); + pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}"); + + Scheduler::ProcessEventsToIdle(); + + unsigned char* pBuffer = nullptr; + OString aPayload = + "<indexing>" + "<paragraph node_type=\"common\" index=\"0\" object_name=\"Shape 1\" />" + "</indexing>"; + + int nWidth = 0; + int nHeight = 0; + size_t nByteSize = 0; + + bool bResult = pDocument->m_pDocumentClass->renderSearchResult(pDocument, aPayload.getStr(), &pBuffer, &nWidth, &nHeight, &nByteSize); + + CPPUNIT_ASSERT(bResult); + CPPUNIT_ASSERT(pBuffer); + + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(192, nWidth); + CPPUNIT_ASSERT_EQUAL(96, nHeight); + CPPUNIT_ASSERT_EQUAL(size_t(73728), nByteSize); + + const sal_uInt8* pD = reinterpret_cast<const sal_uInt8*>(pBuffer); + BitmapEx aBitmap = vcl::bitmap::CreateFromData(pD, nWidth, nHeight, nWidth * 4, 32, true); + + if (bDumpBitmap) + { + SvFileStream aStream("~/SearchResultBitmap.png", StreamMode::WRITE | StreamMode::TRUNC); + vcl::PNGWriter aPNGWriter(aBitmap); + aPNGWriter.Write(aStream); + } + CPPUNIT_ASSERT_EQUAL(tools::Long(192), aBitmap.GetSizePixel().Width()); + CPPUNIT_ASSERT_EQUAL(tools::Long(96), aBitmap.GetSizePixel().Height()); + + std::free(pBuffer); +} + static void lcl_repeatKeyStroke(LibLODocument_Impl *pDocument, int nCharCode, int nKeyCode, size_t nCount) { for (size_t nCtr = 0; nCtr < nCount; ++nCtr) |