sw/qa/extras/ooxmlexport/ooxmlexport8.cxx | 95 ++++++++++++++++++------------ 1 file changed, 59 insertions(+), 36 deletions(-)
New commits: commit 3ee6e4e7c2046c4124b5c34f053888d3ee0a5a53 Author: Attila Bakos (NISZ) <bakos.attilakar...@nisz.hu> AuthorDate: Thu Jan 6 16:41:09 2022 +0100 Commit: László Németh <nem...@numbertext.org> CommitDate: Wed Feb 2 18:18:16 2022 +0100 Related tdf#66039: restore unit tests disabled temporarily Follow-up to 121cbc250b36290f0f8c7265fea57256dad69553 "tdf#66039 DOCX: import textboxes (with tables, images etc.) in group shapes" Two tests have been restored. One of them had to be modified, where the test document has a pure VML shape inside, and after its reload, the shape has got a DML part with textboxes. This differs from the input, but verification handles it now. Change-Id: Ic71cd06496da7d07c09530770282c03c7438640e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128055 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx index 30c9d81627fc..392831f9387c 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx @@ -690,17 +690,17 @@ DECLARE_OOXMLEXPORT_TEST(testN792778, "n792778.docx") xInnerShape.set(xInnerGroupShape->getByIndex(0), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(11684), xInnerShape->getPosition().Y); } -//FIXME: -//DECLARE_OOXMLEXPORT_TEST(testGroupshapeSmarttag, "groupshape-smarttag.docx") -//{ -// uno::Reference<drawing::XShapes> xGroupShape(getShape(1), uno::UNO_QUERY); -// uno::Reference<text::XTextRange> xShape(xGroupShape->getByIndex(0), uno::UNO_QUERY); -// // First run of shape text was missing due to the w:smartTag wrapper around it. -// CPPUNIT_ASSERT_EQUAL(OUString("Box 2"), xShape->getString()); -// -// // Font size of the shape text was 10. -// CPPUNIT_ASSERT_EQUAL(12.f, getProperty<float>(getParagraphOfText(1, xShape->getText()), "CharHeight")); -//} + +DECLARE_OOXMLEXPORT_TEST(testGroupshapeSmarttag, "groupshape-smarttag.docx") +{ + uno::Reference<drawing::XShapes> xGroupShape(getShape(1), uno::UNO_QUERY); + uno::Reference<text::XTextRange> xShape(xGroupShape->getByIndex(0), uno::UNO_QUERY); + // First run of shape text was missing due to the w:smartTag wrapper around it. + CPPUNIT_ASSERT_EQUAL(OUString("Box 2"), xShape->getString()); + + // Font size of the shape text was 10. + CPPUNIT_ASSERT_EQUAL(12.f, getProperty<float>(getParagraphOfText(1, xShape->getText()), "CharHeight")); +} DECLARE_OOXMLEXPORT_TEST(testN793262, "n793262.docx") { @@ -1038,35 +1038,58 @@ DECLARE_OOXMLEXPORT_TEST(testTableAutoColumnFixedSize2, "table-auto-column-fixed // This was 17907, i.e. the sum of the width of the 3 cells (10152 twips each), which is too wide. CPPUNIT_ASSERT_EQUAL(sal_Int32(16891), getProperty<sal_Int32>(xTextTable, "Width")); } -#if 0 -// FIXME: + DECLARE_OOXMLEXPORT_TEST(testFdo46361, "fdo46361.docx") { uno::Reference<container::XIndexAccess> xGroupShape(getShape(1), uno::UNO_QUERY); - uno::Reference<drawing::XShape> xShape(xGroupShape->getByIndex(0), uno::UNO_QUERY); - // This was CENTER. - CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_TOP, getProperty<drawing::TextVerticalAdjust>(xShape, "TextVerticalAdjust")); - uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText(); - uno::Reference<text::XTextRange> xParagraph = getParagraphOfText(1, xText); - // This was LEFT. - CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(xParagraph, "ParaAdjust"))); - // This was black, not green. - CPPUNIT_ASSERT_EQUAL(Color(0x008000), Color(ColorTransparency, getProperty<sal_Int32>(getRun(xParagraph, 1), "CharColor"))); - // \n char was missing due to unhandled w:br. - uno::Reference<text::XText> xShapeText(xGroupShape->getByIndex(1), uno::UNO_QUERY_THROW); - CPPUNIT_ASSERT_EQUAL(OUString("text\ntext"), xShapeText->getString()); - // \n chars were missing, due to unhandled multiple w:p tags. - xShapeText.set(xGroupShape->getByIndex(2), uno::UNO_QUERY_THROW); - CPPUNIT_ASSERT_EQUAL(OUString("text\ntext\n"), xShapeText->getString()); - - // tdf#128153 The first and second lines are directly specified as centered. Make sure that doesn't change. - xParagraph.set(getParagraphOfText(2, xShapeText->getText(), "text")); - CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(xParagraph, "ParaAdjust"))); - // The last paragraph should be left aligned. - xParagraph.set(getParagraphOfText(3, xShapeText->getText(), "")); - CPPUNIT_ASSERT_MESSAGE("You FIXED me!", style::ParagraphAdjust_LEFT != static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(xParagraph, "ParaAdjust"))); + uno::Reference<text::XTextRange> xTextBox; + + // FIXME: + // uno::Reference<drawing::XShape> xShape(xGroupShape->getByIndex(0), uno::UNO_QUERY); + // CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_TOP, getProperty<drawing::TextVerticalAdjust>(xShape, "TextVerticalAdjust")); + + // This was CENTER + xTextBox.set(xGroupShape->getByIndex(0), uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, + static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>( + getParagraphOfText(1, xTextBox->getText()), "ParaAdjust"))); + // This was BLACK + CPPUNIT_ASSERT_EQUAL( + Color(0x008000), + Color(ColorTransparency, + getProperty<sal_Int32>(getRun(getParagraphOfText(1, xTextBox->getText()), 1), + "CharColor"))); + // Count the paragraphs + xTextBox.set(xGroupShape->getByIndex(1), uno::UNO_QUERY_THROW); + const auto& sText1 = xTextBox->getString(); + + xTextBox.set(xGroupShape->getByIndex(2), uno::UNO_QUERY_THROW); + const auto& sText2 = xTextBox->getString(); + + sal_Int32 nCount1 = 0; + sal_Int32 nCount2 = 0; + + for (sal_Int32 i = 0; i < sText1.getLength(); i++) + if (sText1[i] == '\n') + nCount1++; + for (sal_Int32 i = 0; i < sText2.getLength(); i++) + if (sText2[i] == '\n') + nCount2++; + + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nCount1); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), nCount2); + + // This was CENTER + CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, + static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>( + getParagraphOfText(2, xTextBox->getText(), "text"), "ParaAdjust"))); + + // This must not be left. + CPPUNIT_ASSERT_MESSAGE("You FIXED me!", style::ParagraphAdjust_LEFT != + static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>( + getParagraphOfText(3, xTextBox->getText(), ""), "ParaAdjust"))); } -#endif + DECLARE_OOXMLEXPORT_TEST(testFdo65632, "fdo65632.docx") { // The problem was that the footnote text had fake redline: only the body