[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - desktop/qa sw/qa sw/source
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Sat Sep 11 00:18:16 UTC 2021
desktop/qa/data/SearchIndexResultShapeTest.odt |binary
desktop/qa/desktop_lib/test_desktop_lib.cxx | 53 ++++++++++++++++++++--
sw/qa/extras/indexing/SearchResultLocatorTest.cxx | 16 +++---
sw/source/core/model/SearchResultLocator.cxx | 8 +--
4 files changed, 62 insertions(+), 15 deletions(-)
New commits:
commit e3dae10c0b55aafa753f44e4b1c45bf93387f6c6
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Wed Sep 8 16:34:42 2021 +0900
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Sat Sep 11 02:17:30 2021 +0200
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 at gmail.com>
(cherry picked from commit 160b6db92cc94f2ec2447ae0e9c60c8c9dcf3bad)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121818
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
diff --git a/desktop/qa/data/SearchIndexResultShapeTest.odt b/desktop/qa/data/SearchIndexResultShapeTest.odt
new file mode 100644
index 000000000000..4298eb8ad06e
Binary files /dev/null and b/desktop/qa/data/SearchIndexResultShapeTest.odt differ
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)
diff --git a/sw/qa/extras/indexing/SearchResultLocatorTest.cxx b/sw/qa/extras/indexing/SearchResultLocatorTest.cxx
index 62286674c9e6..5bb481640540 100644
--- a/sw/qa/extras/indexing/SearchResultLocatorTest.cxx
+++ b/sw/qa/extras/indexing/SearchResultLocatorTest.cxx
@@ -143,11 +143,11 @@ void SearchResultLocatorTest::testSearchResultLocatorForSdrObjects()
// inconsistent results
#if !defined(_WIN32) && !defined(MACOSX)
auto aRectangle = aResult.maRectangles[0];
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1478.0, aRectangle.getMinX(), 1e-4);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(3223.0, aRectangle.getMinY(), 1e-4);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(2607.0, aRectangle.getMinX(), 1e-4);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(5685.0, aRectangle.getMinY(), 1e-4);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(2059.0, aRectangle.getWidth(), 1e-4);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(2059.0, aRectangle.getHeight(), 1e-4);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(3631.0, aRectangle.getWidth(), 1e-4);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(3631.0, aRectangle.getHeight(), 1e-4);
#endif
}
@@ -168,11 +168,11 @@ void SearchResultLocatorTest::testSearchResultLocatorForSdrObjectsUsingJsonPaylo
// inconsistent results
#if !defined(_WIN32) && !defined(MACOSX)
auto aRectangle = aResult.maRectangles[0];
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1478.0, aRectangle.getMinX(), 1e-4);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(3223.0, aRectangle.getMinY(), 1e-4);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(2607.0, aRectangle.getMinX(), 1e-4);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(5685.0, aRectangle.getMinY(), 1e-4);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(2059.0, aRectangle.getWidth(), 1e-4);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(2059.0, aRectangle.getHeight(), 1e-4);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(3631.0, aRectangle.getWidth(), 1e-4);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(3631.0, aRectangle.getHeight(), 1e-4);
#endif
}
diff --git a/sw/source/core/model/SearchResultLocator.cxx b/sw/source/core/model/SearchResultLocator.cxx
index c1c81d017fd8..eaaec17f10d9 100644
--- a/sw/source/core/model/SearchResultLocator.cxx
+++ b/sw/source/core/model/SearchResultLocator.cxx
@@ -67,10 +67,10 @@ void SearchResultLocator::findOne(LocationResult& rResult, SearchIndexData const
if (pObject->GetName() == rSearchIndexData.maObjectName)
{
auto aLogicRect = pObject->GetLogicRect();
- auto nLeft = convertMm100ToTwip(aLogicRect.Left());
- auto nTop = convertMm100ToTwip(aLogicRect.Top());
- auto nWidth = convertMm100ToTwip(aLogicRect.GetWidth());
- auto nHeight = convertMm100ToTwip(aLogicRect.GetHeight());
+ auto nLeft = aLogicRect.Left();
+ auto nTop = aLogicRect.Top();
+ auto nWidth = aLogicRect.GetWidth();
+ auto nHeight = aLogicRect.GetHeight();
rResult.mbFound = true;
rResult.maRectangles.emplace_back(nLeft, nTop, nLeft + nWidth,
More information about the Libreoffice-commits
mailing list