From 08d0c2cd6b6bdf37d6fc5c16359bafc6dddc9d09 Mon Sep 17 00:00:00 2001 From: Sarper Akdemir Date: Mon, 24 Oct 2022 01:50:36 +0300 Subject: tdf#149961 pptx import: fix indents for autofitted texboxes For autofitted textboxes, Impress scales the indents with the text size while PowerPoint doesn't. Scale the indents inversely propotional to autofit font scale so that the visual appearance on import is similar to PowerPoint. Change-Id: I7876b35a1f4221789564fcf23ccbe3fe21db3d48 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141717 Tested-by: Jenkins Reviewed-by: Miklos Vajna --- .../data/pptx/tdf149961-autofitIndentation.pptx | Bin 0 -> 34123 bytes sd/qa/unit/import-tests2.cxx | 40 +++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 sd/qa/unit/data/pptx/tdf149961-autofitIndentation.pptx (limited to 'sd/qa/unit') diff --git a/sd/qa/unit/data/pptx/tdf149961-autofitIndentation.pptx b/sd/qa/unit/data/pptx/tdf149961-autofitIndentation.pptx new file mode 100644 index 000000000000..25513df7c9e8 Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf149961-autofitIndentation.pptx differ diff --git a/sd/qa/unit/import-tests2.cxx b/sd/qa/unit/import-tests2.cxx index b95f2e3197e6..86641bde50ac 100644 --- a/sd/qa/unit/import-tests2.cxx +++ b/sd/qa/unit/import-tests2.cxx @@ -143,6 +143,7 @@ public: void testTdf144092TableHeight(); void testTdf89928BlackWhiteThreshold(); void testTdf151547TransparentWhiteText(); + void testTdf149961AutofitIndentation(); CPPUNIT_TEST_SUITE(SdImportTest2); @@ -219,6 +220,7 @@ public: CPPUNIT_TEST(testTdf144092TableHeight); CPPUNIT_TEST(testTdf89928BlackWhiteThreshold); CPPUNIT_TEST(testTdf151547TransparentWhiteText); + CPPUNIT_TEST(testTdf149961AutofitIndentation); CPPUNIT_TEST_SUITE_END(); }; @@ -2189,6 +2191,44 @@ void SdImportTest2::testTdf151547TransparentWhiteText() xDocShRef->DoClose(); } +void SdImportTest2::testTdf149961AutofitIndentation() +{ + sd::DrawDocShellRef xDocShRef = loadURL( + m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf149961-autofitIndentation.pptx"), + PPTX); + + const SdrPage* pPage = GetPage(1, xDocShRef); + + { + SdrTextObj* pTxtObj = dynamic_cast(pPage->GetObj(0)); + CPPUNIT_ASSERT_MESSAGE("no text object", pTxtObj != nullptr); + + const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject(); + const SvxNumBulletItem* pNumFmt = aEdit.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET); + CPPUNIT_ASSERT(pNumFmt); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(3175), pNumFmt->GetNumRule().GetLevel(0).GetAbsLSpace()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(-3175), + pNumFmt->GetNumRule().GetLevel(0).GetFirstLineOffset()); + } + + { + SdrTextObj* pTxtObj = dynamic_cast(pPage->GetObj(1)); + CPPUNIT_ASSERT_MESSAGE("no text object", pTxtObj != nullptr); + + const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject(); + const SvxNumBulletItem* pNumFmt = aEdit.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET); + CPPUNIT_ASSERT(pNumFmt); + + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 12700 + // - Actual : 3175 + CPPUNIT_ASSERT_EQUAL(sal_Int32(12700), pNumFmt->GetNumRule().GetLevel(0).GetAbsLSpace()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(-12700), + pNumFmt->GetNumRule().GetLevel(0).GetFirstLineOffset()); + } +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest2); CPPUNIT_PLUGIN_IMPLEMENT(); -- cgit v1.2.3