summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2021-09-08 16:34:42 +0900
committerTomaž Vajngerl <quikee@gmail.com>2021-09-08 15:18:52 +0200
commit160b6db92cc94f2ec2447ae0e9c60c8c9dcf3bad (patch)
treee29cdddaf23e4c85878b3fab10105301b460c8ef /desktop
parent11622c2eb319bb096d4d587ea06a932ba5fceafb (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>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/qa/data/SearchIndexResultShapeTest.odtbin0 -> 9046 bytes
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx53
2 files changed, 50 insertions, 3 deletions
diff --git a/desktop/qa/data/SearchIndexResultShapeTest.odt b/desktop/qa/data/SearchIndexResultShapeTest.odt
new file mode 100644
index 000000000000..4298eb8ad06e
--- /dev/null
+++ b/desktop/qa/data/SearchIndexResultShapeTest.odt
Binary files differ
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 28a5e76a6e1e..c593eca12562 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -207,7 +207,8 @@ public:
void testMetricField();
void testMultiDocuments();
void testJumpCursor();
- void testRenderSearchResult();
+ void testRenderSearchResult_WriterNode();
+ void testRenderSearchResult_CommonNode();
void testABI();
CPPUNIT_TEST_SUITE(DesktopLOKTest);
@@ -271,7 +272,8 @@ public:
CPPUNIT_TEST(testMetricField);
CPPUNIT_TEST(testMultiDocuments);
CPPUNIT_TEST(testJumpCursor);
- CPPUNIT_TEST(testRenderSearchResult);
+ CPPUNIT_TEST(testRenderSearchResult_WriterNode);
+ CPPUNIT_TEST(testRenderSearchResult_CommonNode);
CPPUNIT_TEST(testABI);
CPPUNIT_TEST_SUITE_END();
@@ -3107,7 +3109,7 @@ void DesktopLOKTest::testJumpCursor()
comphelper::LibreOfficeKit::setTiledAnnotations(true);
}
-void DesktopLOKTest::testRenderSearchResult()
+void DesktopLOKTest::testRenderSearchResult_WriterNode()
{
constexpr const bool bDumpBitmap = false;
@@ -3152,6 +3154,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, vcl::PixelFormat::N32_BPP, true, 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);
+}
+
namespace {
constexpr size_t classOffset(int i)